@@ -0,0 +1,97 @@
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_preview_model.h"
25+#include <QVariantMap>
36+ PreviewData(QString const& id_, QString const& type_, QVariantMap const& data_): id(id_), type(type_), data(data_)
41+PreviewModel::PreviewModel(QObject* parent) : QAbstractListModel(parent)
43+ m_roles[Roles::RoleWidgetId] = "widgetId";
44+ m_roles[Roles::RoleType] = "type";
45+ m_roles[Roles::RoleProperties] = "properties";
50+void PreviewModel::populateWidgets()
53+ m_previewWidgets.clear();
55+ beginInsertRows(QModelIndex(), 0, 4);
56+ for (int i = 0; i <= 5; ++i) {
57+ // FIXME: the API will expose nicer getters soon, use those!
58+ QVariantMap attributes;
59+ attributes["text"] = QVariant::fromValue(QString("Text"));
60+ attributes["title"] = QVariant::fromValue(QString("Title"));
61+ PreviewData* preview_data = new PreviewData(QString("widget-%1").arg(i), QString("text"), attributes);
62+ m_previewWidgets.append(QSharedPointer<PreviewData>(preview_data));
67+void PreviewModel::triggered(QString widgetId, QString actionId, QVariantMap data)
69+ Q_EMIT actionTriggered(widgetId, actionId, data);
72+QHash<int, QByteArray> PreviewModel::roleNames() const
77+int PreviewModel::rowCount(const QModelIndex&) const
79+ return m_previewWidgets.size();
82+QVariant PreviewModel::data(const QModelIndex& index, int role) const
84+ auto widget_data = m_previewWidgets.at(index.row());
87+ return widget_data->id;
89+ return widget_data->type;
91+ return widget_data->data;
97+} // namespace scopes_ng