2 * Copyright (C) 2014 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_settingsmodel.h"
19SettingsModel::SettingsModel(QObject* parent) :
20 SettingsModelInterface(parent) {
22 QVariantMap parameters;
23 m_data << QSharedPointer<Data>(new Data("boolean-setting", "Boolean Setting", "boolean", parameters, true));
26 QVariantMap parameters;
27 parameters["values"] = QVariantList() << "First" << "Second" << "Third";
28 m_data << QSharedPointer<Data>(new Data("list-setting", "List Setting", "list", parameters, 1));
31 QVariantMap parameters;
32 m_data << QSharedPointer<Data>(new Data("number-setting", "Number Setting", "number", parameters, 1.23));
35 QVariantMap parameters;
36 m_data << QSharedPointer<Data>(new Data("string-setting", "String Setting", "string", parameters, "flibble"));
40QVariant SettingsModel::data(const QModelIndex& index, int role) const {
41 int row = index.row();
44 if (row < m_data.size()) {
45 auto data = m_data[row];
48 case Roles::RoleSettingId:
51 case Roles::RoleDisplayName:
52 result = data->displayName;
57 case Roles::RoleProperties:
58 result = data->properties;
60 case Roles::RoleValue: {
72bool SettingsModel::setData(const QModelIndex &index, const QVariant &value, int role) {
73 int row = index.row();
74 if (row < m_data.size()) {
76 case SettingsModelInterface::RoleValue: {
77 auto data = m_data[row];
89int SettingsModel::rowCount(const QModelIndex&) const {
93int SettingsModel::count() const {
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