2 * Copyright (C) 2011 Canonical, Ltd.
5 * Florian Boucault <florian.boucault@canonical.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21#include "ratingsfilter.h"
24#include "genericlistmodel.h"
26RatingsFilter::RatingsFilter(QObject *parent) :
27 Filter(parent), m_unityRatingsFilter(NULL), m_options(nullptr)
31float RatingsFilter::rating() const
33 return m_unityRatingsFilter->rating();
36GenericListModel* RatingsFilter::options() const
41void RatingsFilter::setRating(float rating)
43 m_unityRatingsFilter->rating = rating;
46void RatingsFilter::setUnityFilter(unity::dash::Filter::Ptr filter)
48 if (m_unityFilter != NULL) {
49 m_signals.disconnectAll();
52 Filter::setUnityFilter(filter);
53 m_unityRatingsFilter = std::dynamic_pointer_cast<unity::dash::RatingsFilter>(m_unityFilter);
59 m_options = new GenericListModel(this);
60 for (int i=1; i<=5; i++) {
61 auto opt = new RatingFilterOption(QString::number(i), i*0.2f, this);
62 connect(opt, SIGNAL(activeChanged(bool)), this, SLOT(onActiveChanged()));
63 m_options->addOption(opt);
66 /* Property change signals */
67 m_signals << m_unityRatingsFilter->rating.changed.connect(sigc::mem_fun(this, &RatingsFilter::ratingChanged));
70void RatingsFilter::onActiveChanged()
72 RatingFilterOption *option = dynamic_cast<RatingFilterOption*>(QObject::sender());
73 if (option != nullptr) {
74 setRating(option->value());
78#include "ratingsfilter.moc"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list