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,
23 sigc::signal<void, unity::dash::FilterOption::Ptr> itemAddedSignal,
24 sigc::signal<void, unity::dash::FilterOption::Ptr> itemRemovedSignal,
26 : QAbstractListModel(parent)
31QVariant CombinedFilterOptions::data(const QModelIndex& index, int /* role */) const
33 if (!index.isValid()) {
37 CombinedFilterOption* item = m_list.at(index.row());
38 return QVariant::fromValue(item);
41int CombinedFilterOptions::rowCount(const QModelIndex& /* parent */) const
43 return m_list.count();
46void CombinedFilterOptions::initList(const std::vector<unity::dash::FilterOption::Ptr>& list,
47 sigc::signal<void, unity::dash::FilterOption::Ptr> itemAddedSignal,
48 sigc::signal<void, unity::dash::FilterOption::Ptr> itemRemovedSignal)
50 // combine options, e.g. A, B, C becomes A-B, B-C, C
52 while (i < list.size()) {
53 unity::dash::FilterOption::Ptr option1 = list[i];
54 unity::dash::FilterOption::Ptr option2 = NULL;
55 if (i < list.size()-1) {
58 auto co = new CombinedFilterOption(option1);
59 connect(co, SIGNAL(activeChanged(bool)), this, SLOT(onActiveChanged(bool)));
63 if (list.size() > 1) {
64 auto co = new CombinedFilterOption(list[i-1], NULL);
68 itemAddedSignal.connect(sigc::mem_fun(this, &CombinedFilterOptions::onItemAdded));
69 itemRemovedSignal.connect(sigc::mem_fun(this, &CombinedFilterOptions::onItemRemoved));
72void CombinedFilterOptions::addOption(CombinedFilterOption *option)
74 int index = m_list.count();
75 beginInsertRows(QModelIndex(), index, index);
76 m_list.insert(index, option);
80void CombinedFilterOptions::onActiveChanged(bool state)
82 CombinedFilterOption *option = dynamic_cast<CombinedFilterOption*>(QObject::sender());
84 //TODO: de-activate all others?
88void CombinedFilterOptions::onItemAdded(unity::dash::FilterOption::Ptr item)
92void CombinedFilterOptions::onItemRemoved(unity::dash::FilterOption::Ptr item)
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