2 * Copyright (C) 2014 Canonical, Ltd.
5 * Michał Sawicz <michal.sawicz@canonical.com>
6 * Michal Hruby <michal.hruby@canonical.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 3.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22#include "fake_previewwidgetmodel.h"
33 PreviewData(QString const& id_, QString const& type_, QVariantMap const& data_): id(id_), type(type_), data(data_)
38PreviewWidgetModel::PreviewWidgetModel(QObject* parent) : QAbstractListModel(parent)
40 m_roles[Roles::RoleWidgetId] = "widgetId";
41 m_roles[Roles::RoleType] = "type";
42 m_roles[Roles::RoleProperties] = "properties";
47void PreviewWidgetModel::populateWidgets()
50 m_previewWidgets.clear();
51 for (int i = 0; i <= 20; i++) {
52 // FIXME: the API will expose nicer getters soon, use those!
53 QVariantMap attributes;
54 attributes["text"] = QVariant::fromValue(QString("Widget %1").arg(i));
55 attributes["title"] = QVariant::fromValue(QString("Title %1").arg(i));
56 PreviewData* preview_data = new PreviewData(QString("widget-%1").arg(i), QString("text"), attributes);
57 m_previewWidgets.append(QSharedPointer<PreviewData>(preview_data));
63QHash<int, QByteArray> PreviewWidgetModel::roleNames() const
68int PreviewWidgetModel::rowCount(const QModelIndex&) const
70 return m_previewWidgets.size();
73QVariant PreviewWidgetModel::data(const QModelIndex& index, int role) const
75 auto widget_data = m_previewWidgets.at(index.row());
78 return widget_data->id;
80 return widget_data->type;
82 return widget_data->data;
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