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"
25ResultsModel::ResultsModel(int result_count, int categoryId, QObject* parent)
26 : QAbstractListModel(parent)
27 , m_result_count(result_count)
28 , m_categoryId(categoryId)
30 m_roles[ResultsModel::RoleUri] = "uri";
31 m_roles[ResultsModel::RoleCategoryId] = "categoryId";
32 m_roles[ResultsModel::RoleDndUri] = "dndUri";
33 m_roles[ResultsModel::RoleResult] = "result";
34 m_roles[ResultsModel::RoleTitle] = "title";
35 m_roles[ResultsModel::RoleArt] = "art";
36 m_roles[ResultsModel::RoleSubtitle] = "subtitle";
37 m_roles[ResultsModel::RoleMascot] = "mascot";
38 m_roles[ResultsModel::RoleEmblem] = "emblem";
39 m_roles[ResultsModel::RoleOldPrice] = "oldPrice";
40 m_roles[ResultsModel::RolePrice] = "price";
41 m_roles[ResultsModel::RoleAltPrice] = "altPrice";
42 m_roles[ResultsModel::RoleRating] = "rating";
43 m_roles[ResultsModel::RoleAltRating] = "altRating";
44 m_roles[ResultsModel::RoleSummary] = "summary";
47QString ResultsModel::categoryId() const
49 return QString::number(m_categoryId);
52void ResultsModel::setCategoryId(QString const& /*id*/)
54 qFatal("Calling un-implemented ResultsModel::setCategoryId");
58ResultsModel::roleNames() const
63int ResultsModel::rowCount(const QModelIndex& parent) const
67 return m_result_count;
70int ResultsModel::count() const
75QVariant ResultsModel::get(int row) const
77 if (row >= m_result_count || row < 0) return QVariantMap();
80 QModelIndex modelIndex(index(row));
81 QHashIterator<int, QByteArray> it(roleNames());
82 while (it.hasNext()) {
84 QVariant val(data(modelIndex, it.key()));
85 if (val.isNull()) continue;
86 result[it.value()] = val;
93ResultsModel::data(const QModelIndex& index, int role) const
102 return QString("Title.%1.%2").arg(m_categoryId).arg(index.row());
104 return qmlDirectory() + "graphics/applicationIcons/dash.png";
106 return QString("Subtitle.%1.%2").arg(m_categoryId).arg(index.row());
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