2 * Copyright (C) 2013 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/>.
16 * Author: Nick Dedekind <nick.dedekind@canonical.com>
20#include "fake_categories.h"
22#include "fake_resultsmodel.h"
24Categories::Categories(int category_count, QObject* parent)
25 : unity::shell::scopes::CategoriesInterface(parent)
26 , m_category_count(category_count)
30int Categories::rowCount(const QModelIndex& /*parent*/) const
32 return m_category_count;
35void Categories::addSpecialCategory(QString const& /*categoryId*/, QString const& /*name*/, QString const& /*icon*/, QString const& /*rawTemplate*/, QObject* /*countObject*/)
37 qFatal("Using un-implemented Categories::addSpecialCategory");
40bool Categories::overrideCategoryJson(QString const& /* categoryId */, QString const& /* json */)
42 qFatal("Using un-implemented Categories::overrideCategoryJson");
46Categories::data(const QModelIndex& index, int role) const
48 if (!index.isValid()) {
52 ResultsModel *resultsModel = resultModel(index.row());
55 return QString("%1").arg(index.row());
57 return QString("Category %1").arg(index.row());
60 case RoleRawRendererTemplate:
61 qFatal("Using un-implemented RoleRawRendererTemplate Categories role");
66 if (index.row() % 2 == 0) {
67 map["category-layout"] = "grid";
69 map["category-layout"] = "carousel";
71 if (index.row() == 18) {
72 map["category-layout"] = "horizontal-list";
74 if (index.row() == 19) {
75 map["category-layout"] = "grid";
76 map["collapsed-rows"] = 0;
78 map["card-size"] = "small";
80 map["category-layout"] = m_layouts.value(index.row(), map["category-layout"].toString());
82 if (map["category-layout"] == "carousel") {
83 map["overlay"] = true;
90 QVariantMap map, artMap, attributeMap;
91 if (index.row() % 2 != 0) {
92 artMap["aspect-ratio"] = QString("1.%1").arg(index.row());
94 artMap["aspect-ratio"] = "1.0";
96 artMap["field"] = "art";
98 map["title"] = "HOLA";
99 map["subtitle"] = "HOLA";
100 attributeMap["field"] = "attribute";
101 map["attributes"] = attributeMap;
107 if (index.row() == 1 || index.row() == 4) {
108 res = QString("scope://query/1");
110 res = m_headerLinks.value(index.row(), res);
114 return QVariant::fromValue(resultsModel);
116 return resultsModel->rowCount();
118 qFatal("Using un-implemented Categories role");
124Categories::data(int row, int role) const
126 return data(index(row, 0), role);
129void Categories::setCount(int count)
131 if (m_category_count != count) {
132 beginResetModel(); // This is just for test setup so we can be lazy and reset
133 m_category_count = count;
138ResultsModel* Categories::resultModel(int row) const
140 ResultsModel *result = m_resultsModels[row];
142 Categories *that = const_cast<Categories*>(this);
143 result = new ResultsModel(15, row, that);
144 m_resultsModels[row] = result;
149void Categories::setLayout(int row, const QString &layout)
151 m_layouts[row] = layout;
154void Categories::setHeaderLink(int row, const QString &headerLink)
156 m_headerLinks[row] = headerLink;
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