@@ -0,0 +1,113 @@
2+ * Copyright (C) 2013 Canonical, Ltd.
5+ * Michal Hruby <michal.hruby@canonical.com>
7+ * This program is free software; you can redistribute it and/or modify
8+ * it under the terms of the GNU General Public License as published by
9+ * the Free Software Foundation; version 3.
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
16+ * You should have received a copy of the GNU General Public License
17+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
21+#include "fake_resultsmodel.h"
23+ResultsModel::ResultsModel(int result_count, int categoryId, QObject* parent)
24+ : QAbstractListModel(parent)
25+ , m_result_count(result_count)
26+ , m_categoryId(categoryId)
28+ m_roles[ResultsModel::RoleUri] = "uri";
29+ m_roles[ResultsModel::RoleCategoryId] = "categoryId";
30+ m_roles[ResultsModel::RoleDndUri] = "dndUri";
31+ m_roles[ResultsModel::RoleResult] = "result";
32+ m_roles[ResultsModel::RoleTitle] = "title";
33+ m_roles[ResultsModel::RoleArt] = "art";
34+ m_roles[ResultsModel::RoleSubtitle] = "subtitle";
35+ m_roles[ResultsModel::RoleMascot] = "mascot";
36+ m_roles[ResultsModel::RoleEmblem] = "emblem";
37+ m_roles[ResultsModel::RoleOldPrice] = "oldPrice";
38+ m_roles[ResultsModel::RolePrice] = "price";
39+ m_roles[ResultsModel::RoleAltPrice] = "altPrice";
40+ m_roles[ResultsModel::RoleRating] = "rating";
41+ m_roles[ResultsModel::RoleAltRating] = "altRating";
42+ m_roles[ResultsModel::RoleSummary] = "summary";
45+QString ResultsModel::categoryId() const
47+ return QString::number(m_categoryId);
50+void ResultsModel::setCategoryId(QString const& id)
52+ qFatal("Calling un-implemented ResultsModel::setCategoryId");
55+QHash<int, QByteArray>
56+ResultsModel::roleNames() const
61+int ResultsModel::rowCount(const QModelIndex& parent) const
65+ return m_result_count;
68+int ResultsModel::count() const
73+QVariant ResultsModel::get(int row) const
75+ if (row >= m_result_count || row < 0) return QVariantMap();
78+ QModelIndex modelIndex(index(row));
79+ QHashIterator<int, QByteArray> it(roleNames());
80+ while (it.hasNext()) {
82+ QVariant val(data(modelIndex, it.key()));
83+ if (val.isNull()) continue;
84+ result[it.value()] = val;
91+ResultsModel::data(const QModelIndex& index, int role) const