Back to index

unity  6.0.0
Classes | Public Types | Public Member Functions | Public Attributes | Private Attributes
unity::dash::HomeLens Class Reference

A special Lens implementation that merges together a set of source Lens instances. More...

#include <HomeLens.h>

Inheritance diagram for unity::dash::HomeLens:
Inheritance graph
[legend]
Collaboration diagram for unity::dash::HomeLens:
Collaboration graph
[legend]

List of all members.

Classes

class  CategoryMerger
class  CategoryRegistry
class  FiltersMerger
class  Impl
class  ModelMerger
class  ResultsMerger

Public Types

typedef std::shared_ptr< HomeLensPtr
typedef std::map< std::string,
unity::glib::Variant
Hints
typedef std::vector< Lens::PtrLensList

Public Member Functions

 HomeLens (std::string const &name, std::string const &description, std::string const &search_hint)
 Should be constructed with i18n arguments: _("Home"), _("Home screen"), _("Search")
virtual ~HomeLens ()
void AddLenses (Lenses &lenses)
Lenses::LensList GetLenses () const
 Get the currently loaded Lenses.
Lens::Ptr GetLens (std::string const &lens_id) const
Lens::Ptr GetLensAtIndex (std::size_t index) const
void GlobalSearch (std::string const &search_string)
void Search (std::string const &search_string)
void Activate (std::string const &uri)
void Preview (std::string const &uri)

Public Attributes

nux::RWProperty< std::string > id
nux::RWProperty< std::string > dbus_name
nux::RWProperty< std::string > dbus_path
nux::RWProperty< std::string > name
nux::RWProperty< std::string > icon_hint
nux::RWProperty< std::string > description
nux::RWProperty< std::string > search_hint
nux::RWProperty< bool > visible
nux::RWProperty< bool > search_in_global
nux::RWProperty< std::string > shortcut
nux::RWProperty< Results::Ptrresults
nux::RWProperty< Results::Ptrglobal_results
nux::RWProperty< Categories::Ptrcategories
nux::RWProperty< Filters::Ptrfilters
nux::RWProperty< bool > connected
nux::Property< ViewTypeview_type
sigc::signal< void, Hints const & > search_finished
sigc::signal< void, Hints const & > global_search_finished
sigc::signal< void,
std::string const
&, HandledType, Hints const & > 
activated
sigc::signal< void,
std::string const
&, Preview::Ptr
preview_ready
nux::ROProperty< std::size_t > count
sigc::signal< void, Lens::Ptr & > lens_added

Private Attributes

Implpimpl

Detailed Description

A special Lens implementation that merges together a set of source Lens instances.

NOTE: Changes in the filter models are currently not propagated back to the the source lenses. If we want to support filters on the dash home screen this needs to be addressed.

Definition at line 44 of file HomeLens.h.


Member Typedef Documentation

typedef std::map<std::string, unity::glib::Variant> unity::dash::Lens::Hints [inherited]

Definition at line 58 of file Lens.h.

typedef std::vector<Lens::Ptr> unity::dash::Lenses::LensList [inherited]

Definition at line 36 of file Lenses.h.

typedef std::shared_ptr<HomeLens> unity::dash::HomeLens::Ptr

Reimplemented from unity::dash::Lens.

Definition at line 47 of file HomeLens.h.


Constructor & Destructor Documentation

unity::dash::HomeLens::HomeLens ( std::string const &  name,
std::string const &  description,
std::string const &  search_hint 
)

Should be constructed with i18n arguments: _("Home"), _("Home screen"), _("Search")

Definition at line 874 of file HomeLens.cpp.

  : Lens("home.lens", "", "", name, PKGDATADIR"/lens-nav-home.svg",
         description, search_hint, true, "",
         ModelType::LOCAL)
  , pimpl(new Impl(this))
{
  count.SetGetterFunction(sigc::mem_fun(&pimpl->lenses_, &Lenses::LensList::size));
  search_in_global = false;
}

Definition at line 884 of file HomeLens.cpp.

{
  delete pimpl;
}

Member Function Documentation

void unity::dash::HomeLens::Activate ( std::string const &  uri) [virtual]

Reimplemented from unity::dash::Lens.

Definition at line 957 of file HomeLens.cpp.

{
  LOG_DEBUG(logger) << "Activate '" << uri << "'";

  Lens::Ptr lens = pimpl->FindLensForUri(uri);

  /* Fall back to default handling of URIs if no lens is found.
   *  - Although, this shouldn't really happen */
  if (lens)
  {
    LOG_DEBUG(logger) << "Activation request passed to '" << lens->id() << "'";
    lens->Activate(uri);
  }
  else
  {
    LOG_WARN(logger) << "Unable to find a lens for activating '" << uri
                     << "'. Using fallback activation.";
    activated.emit(uri, HandledType::NOT_HANDLED, Hints());
  }
}

Here is the call graph for this function:

Definition at line 889 of file HomeLens.cpp.

{
  for (auto lens : lenses.GetLenses())
  {
    pimpl->OnLensAdded(lens);
  }

  lenses.lens_added.connect(sigc::mem_fun(pimpl, &HomeLens::Impl::OnLensAdded));
}

Here is the call graph for this function:

Lens::Ptr unity::dash::HomeLens::GetLens ( std::string const &  lens_id) const [virtual]

Implements unity::dash::Lenses.

Definition at line 904 of file HomeLens.cpp.

{
  for (auto lens: pimpl->lenses_)
  {
    if (lens->id == lens_id)
    {
      return lens;
    }
  }

  return Lens::Ptr();
}
Lens::Ptr unity::dash::HomeLens::GetLensAtIndex ( std::size_t  index) const [virtual]

Implements unity::dash::Lenses.

Definition at line 917 of file HomeLens.cpp.

{
  try
  {
    return pimpl->lenses_.at(index);
  }
  catch (std::out_of_range& error)
  {
    LOG_WARN(logger) << error.what();
  }

  return Lens::Ptr();
}

Get the currently loaded Lenses.

This is necessary as some of the consumers of this object employ a lazy-loading technique to reduce the overhead of starting Unity. Therefore, the Lenses may already have been loaded by the time the objects have been initiated (and so just connecting to the signals is not enough)

Implements unity::dash::Lenses.

Definition at line 899 of file HomeLens.cpp.

{
  return pimpl->lenses_;
}
void unity::dash::HomeLens::GlobalSearch ( std::string const &  search_string) [virtual]

Reimplemented from unity::dash::Lens.

Definition at line 931 of file HomeLens.cpp.

{
  LOG_WARN(logger) << "Global search not enabled for HomeLens class."
                   << " Ignoring query '" << search_string << "'";
}
void unity::dash::HomeLens::Preview ( std::string const &  uri) [virtual]

Reimplemented from unity::dash::Lens.

Definition at line 978 of file HomeLens.cpp.

{
  LOG_DEBUG(logger) << "Preview '" << uri << "'";

  Lens::Ptr lens = pimpl->FindLensForUri(uri);

  if (lens)
    lens->Preview(uri);
  else
    LOG_WARN(logger) << "Unable to find a lens for previewing '" << uri << "'";
}

Here is the call graph for this function:

void unity::dash::HomeLens::Search ( std::string const &  search_string) [virtual]

Reimplemented from unity::dash::Lens.

Definition at line 937 of file HomeLens.cpp.

{
  LOG_DEBUG(logger) << "Search '" << search_string << "'";

  /* Reset running search counter */
  pimpl->running_searches_ = 0;

  for (auto lens: pimpl->lenses_)
  {
    if (lens->search_in_global())
    {
      LOG_INFO(logger) << " - Global search on '" << lens->id() << "' for '"
          << search_string << "'";
      lens->view_type = ViewType::HOME_VIEW;
      lens->GlobalSearch(search_string);
      pimpl->running_searches_++;
    }
  }
}

Member Data Documentation

sigc::signal<void, std::string const&, HandledType, Hints const&> unity::dash::Lens::activated [inherited]

Definition at line 108 of file Lens.h.

nux::RWProperty<Categories::Ptr> unity::dash::Lens::categories [inherited]

Definition at line 100 of file Lens.h.

nux::RWProperty<bool> unity::dash::Lens::connected [inherited]

Definition at line 102 of file Lens.h.

nux::ROProperty<std::size_t> unity::dash::Lenses::count [inherited]

Definition at line 49 of file Lenses.h.

nux::RWProperty<std::string> unity::dash::Lens::dbus_name [inherited]

Definition at line 89 of file Lens.h.

nux::RWProperty<std::string> unity::dash::Lens::dbus_path [inherited]

Definition at line 90 of file Lens.h.

nux::RWProperty<std::string> unity::dash::Lens::description [inherited]

Definition at line 93 of file Lens.h.

nux::RWProperty<Filters::Ptr> unity::dash::Lens::filters [inherited]

Definition at line 101 of file Lens.h.

nux::RWProperty<Results::Ptr> unity::dash::Lens::global_results [inherited]

Definition at line 99 of file Lens.h.

sigc::signal<void, Hints const&> unity::dash::Lens::global_search_finished [inherited]

Definition at line 107 of file Lens.h.

nux::RWProperty<std::string> unity::dash::Lens::icon_hint [inherited]

Definition at line 92 of file Lens.h.

nux::RWProperty<std::string> unity::dash::Lens::id [inherited]

Definition at line 88 of file Lens.h.

sigc::signal<void, Lens::Ptr&> unity::dash::Lenses::lens_added [inherited]

Definition at line 51 of file Lenses.h.

nux::RWProperty<std::string> unity::dash::Lens::name [inherited]

Definition at line 91 of file Lens.h.

Reimplemented from unity::dash::Lens.

Definition at line 73 of file HomeLens.h.

sigc::signal<void, std::string const&, Preview::Ptr> unity::dash::Lens::preview_ready [inherited]

Definition at line 109 of file Lens.h.

nux::RWProperty<Results::Ptr> unity::dash::Lens::results [inherited]

Definition at line 98 of file Lens.h.

sigc::signal<void, Hints const&> unity::dash::Lens::search_finished [inherited]

Definition at line 106 of file Lens.h.

nux::RWProperty<std::string> unity::dash::Lens::search_hint [inherited]

Definition at line 94 of file Lens.h.

nux::RWProperty<bool> unity::dash::Lens::search_in_global [inherited]

Definition at line 96 of file Lens.h.

nux::RWProperty<std::string> unity::dash::Lens::shortcut [inherited]

Definition at line 97 of file Lens.h.

nux::Property<ViewType> unity::dash::Lens::view_type [inherited]

Definition at line 104 of file Lens.h.

nux::RWProperty<bool> unity::dash::Lens::visible [inherited]

Definition at line 95 of file Lens.h.


The documentation for this class was generated from the following files: