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
unity::dash::RatingsFilter Class Reference

#include <RatingsFilter.h>

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

List of all members.

Public Types

typedef std::shared_ptr
< RatingsFilter
Ptr
typedef std::map< std::string,
unity::glib::Variant
Hints

Public Member Functions

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

Static Public Member Functions

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

Public Attributes

nux::Property< float > rating
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 OnRatingChanged (float new_value)
void UpdateState (float new_rating)

Detailed Description

Definition at line 30 of file RatingsFilter.h.


Member Typedef Documentation

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 RatingsFilter.h.


Constructor & Destructor Documentation

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

Definition at line 34 of file RatingsFilter.cpp.

  : Filter(model, iter)
  , rating(0.0f)
{
  rating.changed.connect(sigc::mem_fun(this, &RatingsFilter::OnRatingChanged));
  Refresh();
}

Here is the call graph for this function:


Member Function Documentation

Implements unity::dash::Filter.

Definition at line 42 of file RatingsFilter.cpp.

{
  rating = 0.0f;
}
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:

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::RatingsFilter::OnRatingChanged ( float  new_value) [private]

Definition at line 62 of file RatingsFilter.cpp.

{
  UpdateState(new_value);
}

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::RatingsFilter::Update ( Filter::Hints hints) [protected, virtual]

Implements unity::dash::Filter.

Definition at line 47 of file RatingsFilter.cpp.

{
  GVariant* rating_variant = hints["rating"];

  if (rating_variant)
  {
    rating = (float)g_variant_get_double(rating_variant);
  }
  else
  {
    LOG_WARN(logger) << "Hints do not contain a 'rating' key";
    rating = 0.0f;
  }
}
void unity::dash::RatingsFilter::UpdateState ( float  new_rating) [private]

Definition at line 67 of file RatingsFilter.cpp.

{
  if (!IsValid())
    return;
    
  bool new_filtering = raw_rating > 0.0f;

  GVariantBuilder b;
  g_variant_builder_init(&b, G_VARIANT_TYPE("a{sv}"));
  g_variant_builder_add(&b, "{sv}", "rating", g_variant_new("d", raw_rating));

  IgnoreChanges(true);
  dee_model_set_value(model_,iter_,
                      FilterColumn::RENDERER_STATE,
                      g_variant_builder_end(&b));
  dee_model_set_value(model_, iter_,
                      FilterColumn::FILTERING,
                      g_variant_new("b", new_filtering ? TRUE : FALSE));
  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.

nux::Property<float> unity::dash::RatingsFilter::rating

Definition at line 39 of file RatingsFilter.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: