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;
35bool Categories::overrideCategoryJson(QString const& /* categoryId */, QString const& /* json */)
37 qFatal("Using un-implemented Categories::overrideCategoryJson");
41Categories::data(const QModelIndex& index, int role) const
43 if (!index.isValid()) {
47 ResultsModel *resultsModel = resultModel(index.row());
50 if (index.row() == 6) {
51 return QString("predefined");
52 } else if (index.row() == 8) {
53 return QString("local");
55 return QString("%1").arg(index.row());
58 return QString("Category %1").arg(index.row());
61 case RoleRawRendererTemplate:
62 qFatal("Using un-implemented RoleRawRendererTemplate Categories role");
67 if (index.row() % 2 == 0) {
68 map["category-layout"] = "grid";
70 map["category-layout"] = "carousel";
72 if (index.row() == 16) {
73 map["expandable"] = false;
74 map["collapsed-rows"] = 1;
76 if (index.row() == 18) {
77 map["category-layout"] = "horizontal-list";
79 if (index.row() == 19) {
80 map["category-layout"] = "grid";
81 map["collapsed-rows"] = 0;
83 map["card-size"] = "small";
85 map["category-layout"] = m_layouts.value(index.row(), map["category-layout"].toString());
87 if (map["category-layout"] == "carousel") {
88 map["overlay"] = true;
95 QVariantMap map, artMap, attributeMap, socialActionMap;
96 if (index.row() % 2 != 0) {
97 artMap["aspect-ratio"] = QString("1.%1").arg(index.row());
99 artMap["aspect-ratio"] = "1.0";
101 artMap["field"] = "art";
103 map["title"] = "HOLA";
104 map["subtitle"] = "HOLA";
105 attributeMap["field"] = "attribute";
106 socialActionMap["icon"] = "icon";
107 socialActionMap["id"] = "socialHola";
108 map["socialActions"] = socialActionMap;
109 map["attributes"] = attributeMap;
115 if (index.row() == 1 || index.row() == 4) {
116 res = QString("scope://query/1");
118 res = m_headerLinks.value(index.row(), res);
122 return QVariant::fromValue(resultsModel);
124 return resultsModel->rowCount();
126 qFatal("Using un-implemented Categories role");
132Categories::data(int row, int role) const
134 return data(index(row, 0), role);
137void Categories::setCount(int count)
139 if (m_category_count != count) {
140 beginResetModel(); // This is just for test setup so we can be lazy and reset
141 m_category_count = count;
146ResultsModel* Categories::resultModel(int row) const
148 ResultsModel *result = m_resultsModels[row];
150 Categories *that = const_cast<Categories*>(this);
151 result = new ResultsModel(25, row, that);
152 m_resultsModels[row] = result;
157void Categories::setLayout(int row, const QString &layout)
159 m_layouts[row] = layout;
162void Categories::setHeaderLink(int row, const QString &headerLink)
164 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