2 * Copyright (C) 2011, 2013 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"
25#include "ratingfilteroption.h"
30RatingsFilter::RatingsFilter(QObject *parent) :
31 Filter(parent), m_unityRatingsFilter(nullptr), m_options(nullptr)
35GenericListModel* RatingsFilter::options() const
40void RatingsFilter::setUnityFilter(unity::dash::Filter::Ptr filter)
42 if (m_unityFilter != nullptr) {
43 m_signals.disconnectAll();
46 Filter::setUnityFilter(filter);
47 m_unityRatingsFilter = std::dynamic_pointer_cast<unity::dash::RatingsFilter>(m_unityFilter);
53 m_options = new GenericListModel(this);
54 for (int i=1; i<=5; i++) {
55 auto opt = new RatingFilterOption(QString::number(i), i*0.2f, this);
56 connect(opt, SIGNAL(activeChanged(bool)), this, SLOT(onActiveChanged()));
57 m_options->addObject(opt);
60 Q_EMIT ratingsChanged();
63void RatingsFilter::onActiveChanged()
65 RatingFilterOption *option = dynamic_cast<RatingFilterOption*>(QObject::sender());
66 if (option != nullptr) {
67 if (option->active()) {
68 // disable all other options
69 for (auto it = m_options->optionsBegin(); it != m_options->optionsEnd(); it++) {
70 RatingFilterOption *opt = dynamic_cast<RatingFilterOption *>(*it);
71 if (opt && opt != option && opt->active()) {
72 opt->setActive(false);
75 m_unityRatingsFilter->rating = option->value();
78 Q_EMIT ratingsChanged();
80 qWarning() << "Invalid option";
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