2 * Copyright (C) 2015 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17#include "fake_optionselectoroptions.h"
19#include "fake_optionselectorfilter.h"
21FakeOptionSelectorOptions::FakeOptionSelectorOptions(const QStringList &optionLabels, FakeOptionSelectorFilter* parent)
22 : unity::shell::scopes::OptionSelectorOptionsInterface(parent),
23 m_optionLabels(optionLabels)
27int FakeOptionSelectorOptions::rowCount(const QModelIndex &parent) const
32 return m_optionLabels.count();
35QVariant FakeOptionSelectorOptions::data(const QModelIndex &index, int role) const
37 const int row = index.row();
38 if (row < 0 || row >= m_optionLabels.count())
43 const QString id = static_cast<FakeOptionSelectorFilter*>(parent())->filterId() + QString::number(row);
47 return m_optionLabels[row];
48 case RoleOptionChecked:
49 return m_checkedIndexes.contains(row);
56void FakeOptionSelectorOptions::setChecked(int row, bool checked)
59 if (!static_cast<FakeOptionSelectorFilter*>(parent())->multiSelect()) {
60 if (!m_checkedIndexes.isEmpty()) {
61 setChecked(*m_checkedIndexes.begin(), false);
63 Q_ASSERT(m_checkedIndexes.isEmpty());
65 m_checkedIndexes << row;
67 m_checkedIndexes.remove(row);
69 const QModelIndex idx = index(row, 0);
70 Q_EMIT dataChanged(idx, idx, QVector<int>() << RoleOptionChecked);
71 Q_EMIT anyCheckedChanged();
74bool FakeOptionSelectorOptions::anyChecked() const
76 return !m_checkedIndexes.isEmpty();
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