@@ -0,0 +1,63 @@
1+/*
2+ * Copyright (C) 2015 Canonical, Ltd.
3+ *
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.
7+ *
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.
12+ *
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/>.
15+ */
16+
17+#include "fake_optionselectoroptions.h"
18+
19+#include "fake_optionselectorfilter.h"
20+
21+FakeOptionSelectorOptions::FakeOptionSelectorOptions(const QStringList &optionLabels, FakeOptionSelectorFilter* parent)
22+ : unity::shell::scopes::OptionSelectorOptionsInterface(parent),
23+ m_optionLabels(optionLabels)
24+{
25+}
26+
27+int FakeOptionSelectorOptions::rowCount(const QModelIndex &parent) const
28+{
29+ if (parent.isValid())
30+ return 0;
31+
32+ return m_optionLabels.count();
33+}
34+
35+QVariant FakeOptionSelectorOptions::data(const QModelIndex &index, int role) const
36+{
37+ const int row = index.row();
38+ if (row < 0 || row >= m_optionLabels.count())
39+ return QVariant();
40+
41+ switch (role) {
42+ case RoleOptionId:
43+ return static_cast<FakeOptionSelectorFilter*>(parent())->filterId() + QString::number(row);
44+ case RoleOptionLabel:
45+ return m_optionLabels[row];
46+ case RoleOptionChecked:
47+ return m_checkedIndexes.contains(row);
48+ default:
49+ return QVariant();
50+ }
51+
52+}
53+
54+void FakeOptionSelectorOptions::setChecked(int row, bool checked)
55+{
56+ if (checked) {
57+ m_checkedIndexes << row;
58+ } else {
59+ m_checkedIndexes.remove(row);
60+ }
61+ const QModelIndex idx = index(row, 0);
62+ Q_EMIT dataChanged(idx, idx, QVector<int>() << RoleOptionChecked);
63+}