2 * Copyright (C) 2013 Canonical, Ltd.
5 * Pawel Stolowski <pawel.stolowski@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/>.
20#include "combinedfilteroptions.h"
22CombinedFilterOptions::CombinedFilterOptions(const std::vector<unity::dash::FilterOption::Ptr>& list, QObject *parent)
23 : QAbstractListModel(parent)
29QVariant CombinedFilterOptions::data(const QModelIndex& index, int /* role */) const
31 if (!index.isValid()) {
35 CombinedFilterOption* item = m_list.at(index.row());
36 return QVariant::fromValue(item);
39int CombinedFilterOptions::rowCount(const QModelIndex& /* parent */) const
41 return m_list.count();
44void CombinedFilterOptions::initList(const std::vector<unity::dash::FilterOption::Ptr>& list)
46 // combine options, e.g. A, B, C becomes A-B, B-C, C
48 while (i < list.size() - 1) {
49 unity::dash::FilterOption::Ptr option1 = list[i];
50 unity::dash::FilterOption::Ptr option2 = list[i+1];
51 auto co = new CombinedFilterOption(option1, option2);
52 connect(co, SIGNAL(activeChanged(bool)), this, SLOT(onActiveChanged(bool)));
56 if (list.size() > 0) {
57 auto co = new CombinedFilterOption(list[i], NULL);
62void CombinedFilterOptions::addOption(CombinedFilterOption *option)
64 int index = m_list.count();
65 beginInsertRows(QModelIndex(), index, index);
66 m_list.insert(index, option);
70void CombinedFilterOptions::onActiveChanged(bool state)
72 // if option became active, need to disable all other options
74 CombinedFilterOption *option = dynamic_cast<CombinedFilterOption*>(QObject::sender());
76 Q_FOREACH (auto fo, m_list) {
78 // note that changing state will result in onActiveChanged signal for that option, but
79 // since it will be 'false', we won't end up in an infinite loop
80 fo->setInactive(*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