Back to index

unity  6.0.0
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
unity::dash::CheckOptionFilter Class Reference

#include <CheckOptionFilter.h>

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

List of all members.

Public Types

typedef std::shared_ptr
< CheckOptionFilter
Ptr
typedef std::vector
< FilterOption::Ptr
CheckOptions
typedef std::map< std::string,
unity::glib::Variant
Hints

Public Member Functions

 CheckOptionFilter (DeeModel *model, DeeModelIter *iter)
void Clear ()
bool IsValid () const

Static Public Member Functions

static Filter::Ptr FilterFromIter (DeeModel *model, DeeModelIter *iter)

Public Attributes

nux::ROProperty< CheckOptionsoptions
sigc::signal< void,
FilterOption::Ptr
option_added
sigc::signal< void,
FilterOption::Ptr
option_removed
nux::ROProperty< std::string > id
nux::ROProperty< std::string > name
nux::ROProperty< std::string > icon_hint
nux::ROProperty< std::string > renderer_name
nux::ROProperty< bool > visible
nux::ROProperty< bool > collapsed
nux::ROProperty< bool > filtering
sigc::signal< void > removed

Protected Member Functions

void Update (Filter::Hints &hints)
void Refresh ()
void IgnoreChanges (bool ignore)

Protected Attributes

DeeModel * model_
DeeModelIter * iter_
glib::SignalManager signal_manager_
bool ignore_changes_

Private Member Functions

void UpdateState ()
CheckOptions const & get_options () const
void OptionChanged (bool is_active, std::string const &id)

Private Attributes

CheckOptions options_

Detailed Description

Definition at line 30 of file CheckOptionFilter.h.


Member Typedef Documentation

Definition at line 35 of file CheckOptionFilter.h.

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

Definition at line 70 of file Filter.h.

Reimplemented from unity::dash::Filter.

Definition at line 33 of file CheckOptionFilter.h.


Constructor & Destructor Documentation

unity::dash::CheckOptionFilter::CheckOptionFilter ( DeeModel *  model,
DeeModelIter *  iter 
)

Definition at line 34 of file CheckOptionFilter.cpp.

  : Filter(model, iter)
{
  options.SetGetterFunction(sigc::mem_fun(this, &CheckOptionFilter::get_options));
  Refresh();
}

Here is the call graph for this function:


Member Function Documentation

Implements unity::dash::Filter.

Definition at line 41 of file CheckOptionFilter.cpp.

{
  for(auto option: options_)
    option->active = false;
}
Filter::Ptr unity::dash::Filter::FilterFromIter ( DeeModel *  model,
DeeModelIter *  iter 
) [static, inherited]

Definition at line 82 of file Filter.cpp.

{
  std::string renderer = dee_model_get_string(model, iter, 3);

  if (renderer == "filter-ratings")
    return std::make_shared<RatingsFilter>(model, iter);
  else if (renderer == "filter-radiooption")
    return std::make_shared<RadioOptionFilter>(model, iter);
  else if (renderer == "filter-checkoption")
    return std::make_shared<CheckOptionFilter>(model, iter);
  else if (renderer == "filter-checkoption-compact")
    return std::make_shared<CheckOptionFilter>(model, iter);
  else if (renderer == "filter-multirange")
    return std::make_shared<MultiRangeFilter>(model, iter);
  else
    return std::make_shared<RatingsFilter>(model, iter);
}

Here is the caller graph for this function:

Definition at line 82 of file CheckOptionFilter.cpp.

{
  return options_;
}

Here is the caller graph for this function:

void unity::dash::Filter::IgnoreChanges ( bool  ignore) [protected, inherited]

Definition at line 111 of file Filter.cpp.

{
  ignore_changes_ = ignore;
}

Here is the caller graph for this function:

bool unity::dash::Filter::IsValid ( ) const [inherited]

Definition at line 100 of file Filter.cpp.

{
  return model_ && iter_;
}

Here is the caller graph for this function:

void unity::dash::CheckOptionFilter::OptionChanged ( bool  is_active,
std::string const &  id 
) [private]

Definition at line 77 of file CheckOptionFilter.cpp.

{
  UpdateState();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::dash::Filter::Refresh ( ) [protected, inherited]

Definition at line 105 of file Filter.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::dash::CheckOptionFilter::Update ( Filter::Hints hints) [protected, virtual]

Implements unity::dash::Filter.

Definition at line 47 of file CheckOptionFilter.cpp.

{
  GVariant* options_variant = hints["options"];
  GVariantIter* options_iter;

  g_variant_get(options_variant, "a(sssb)", &options_iter);

  char *id = NULL;
  char *name = NULL;
  char *icon_hint = NULL;
  gboolean active = false;

  for (auto option: options_)
    option_removed.emit(option);

  options_.clear();

  while (g_variant_iter_loop(options_iter, "(sssb)", &id, &name, &icon_hint, &active))
  {
    FilterOption::Ptr option(new FilterOption(id, name, icon_hint, active));

    std::string data(id);
    option->active.changed.connect(sigc::bind(sigc::mem_fun(this, &CheckOptionFilter::OptionChanged), data));
    options_.push_back(option);
    option_added.emit(option);
  }

  g_variant_iter_free(options_iter);
}

Here is the call graph for this function:

Definition at line 87 of file CheckOptionFilter.cpp.

{
  if (!IsValid())
    return;
  gboolean raw_filtering = FALSE;

  GVariantBuilder options;
  g_variant_builder_init(&options, G_VARIANT_TYPE("a(sssb)"));

  for(auto option: options_)
  {
    std::string id = option->id;
    std::string name = option->name;
    std::string icon_hint = option->icon_hint;
    bool active = option->active;

    raw_filtering = raw_filtering ? TRUE : active;

    g_variant_builder_add(&options, "(sssb)",
                          id.c_str(), name.c_str(),
                          icon_hint.c_str(), active ? TRUE : FALSE);
  }
  
  GVariantBuilder hints;
  g_variant_builder_init(&hints, G_VARIANT_TYPE("a{sv}"));
  g_variant_builder_add(&hints, "{sv}", "options", g_variant_builder_end(&options));

  IgnoreChanges(true);
  dee_model_set_value(model_,iter_,
                      FilterColumn::RENDERER_STATE,
                      g_variant_builder_end(&hints));
  dee_model_set_value(model_, iter_,
                      FilterColumn::FILTERING,
                      g_variant_new("b", raw_filtering));
  IgnoreChanges(false);

  filtering.EmitChanged(filtering);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

nux::ROProperty<bool> unity::dash::Filter::collapsed [inherited]

Definition at line 85 of file Filter.h.

nux::ROProperty<bool> unity::dash::Filter::filtering [inherited]

Definition at line 86 of file Filter.h.

nux::ROProperty<std::string> unity::dash::Filter::icon_hint [inherited]

Definition at line 82 of file Filter.h.

nux::ROProperty<std::string> unity::dash::Filter::id [inherited]

Definition at line 80 of file Filter.h.

bool unity::dash::Filter::ignore_changes_ [protected, inherited]

Reimplemented in unity::dash::MultiRangeFilter, and unity::dash::RadioOptionFilter.

Definition at line 114 of file Filter.h.

DeeModelIter* unity::dash::Filter::iter_ [protected, inherited]

Definition at line 112 of file Filter.h.

DeeModel* unity::dash::Filter::model_ [protected, inherited]

Definition at line 111 of file Filter.h.

nux::ROProperty<std::string> unity::dash::Filter::name [inherited]

Definition at line 81 of file Filter.h.

Definition at line 43 of file CheckOptionFilter.h.

Definition at line 44 of file CheckOptionFilter.h.

Definition at line 41 of file CheckOptionFilter.h.

Definition at line 55 of file CheckOptionFilter.h.

sigc::signal<void> unity::dash::Filter::removed [inherited]

Definition at line 88 of file Filter.h.

nux::ROProperty<std::string> unity::dash::Filter::renderer_name [inherited]

Definition at line 83 of file Filter.h.

Definition at line 113 of file Filter.h.

nux::ROProperty<bool> unity::dash::Filter::visible [inherited]

Definition at line 84 of file Filter.h.


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