2 * Copyright (C) 2014 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/>.
17#include "fake_scopesoverview.h"
19#include "fake_scopes.h"
23ScopesOverview::ScopesOverview(Scopes* parent)
24 : Scope("scopesOverview", "Scopes Overview", false, parent)
26 m_searchCategories = m_categories; // save the usual categories as search result
27 m_scopesOverviewCategories = new ScopesOverviewCategories(parent, this);
28 m_categories = m_scopesOverviewCategories;
31void ScopesOverview::setSearchQuery(const QString& search_query)
33 Scope::setSearchQuery(search_query);
35 auto origCategories = m_categories;
36 if (search_query.isEmpty()) m_categories = m_scopesOverviewCategories;
37 else m_categories = m_searchCategories;
39 if (m_categories != origCategories)
40 Q_EMIT categoriesChanged();
44ScopesOverviewCategories::ScopesOverviewCategories(Scopes *scopes, QObject* parent)
45 : unity::shell::scopes::CategoriesInterface(parent)
50int ScopesOverviewCategories::rowCount(const QModelIndex& /*parent*/) const
55void ScopesOverviewCategories::addSpecialCategory(QString const&, QString const&, QString const&, QString const&, QObject*)
57 qFatal("Using un-implemented ScopesOverviewCategories::addSpecialCategory");
60bool ScopesOverviewCategories::overrideCategoryJson(QString const& /* categoryId */, QString const& /* json */)
62 qFatal("Using un-implemented ScopesOverviewCategories::overrideCategoryJson");
66ScopesOverviewCategories::data(const QModelIndex& index, int role) const
68 if (!index.isValid()) {
72 unity::shell::scopes::ResultsModelInterface *resultsModel = m_resultsModels[index.row()];
74 QObject *that = const_cast<ScopesOverviewCategories*>(this);
75 resultsModel = new ScopesOverviewResultsModel(m_scopes, index.row() == 0, that);
76 m_resultsModels[index.row()] = resultsModel;
80 return index.row() == 0 ? "favorites" : "all";
82 return index.row() == 0 ? "Favorites" : "All";
85 case RoleRawRendererTemplate:
86 qFatal("Using un-implemented RoleRawRendererTemplate Categories role");
91 map["category-layout"] = "grid";
92 map["card-size"] = "small";
93 map["overlay"] = true;
98 QVariantMap map, artMap;
99 artMap["aspect-ratio"] = "0.5";
100 artMap["field"] = "art";
102 map["title"] = "HOLA";
106 return QVariant::fromValue(resultsModel);
108 return resultsModel->rowCount();
110 qFatal("Using un-implemented Categories role");
117ScopesOverviewResultsModel::ScopesOverviewResultsModel(Scopes *scopes, bool isFavoriteCategory, QObject* parent)
118 : unity::shell::scopes::ResultsModelInterface(parent)
120 , m_isFavoriteCategory(isFavoriteCategory)
124QString ScopesOverviewResultsModel::categoryId() const
126 return m_isFavoriteCategory ? "favorites" : "all";
129void ScopesOverviewResultsModel::setCategoryId(QString const& /*id*/)
131 qFatal("Calling un-implemented ScopesOverviewResultsModel::setCategoryId");
134int ScopesOverviewResultsModel::scopeIndex(QString const& id) const
136 const int scopeCount = count();
137 for (int i = 0; i < scopeCount; ++i) {
138 if (m_scopes->scopeAt(i, m_isFavoriteCategory)->id() == id)
144QHash<int, QByteArray> ScopesOverviewResultsModel::roleNames() const
146 QHash<int, QByteArray> roles = unity::shell::scopes::ResultsModelInterface::roleNames();
147 roles[RoleBackground + 1] = "scopeId";
151int ScopesOverviewResultsModel::rowCount(const QModelIndex& parent) const
155 return m_scopes->count(m_isFavoriteCategory);
158int ScopesOverviewResultsModel::count() const
164ScopesOverviewResultsModel::data(const QModelIndex& index, int role) const
172 return m_scopes->scopeAt(index.row(), m_isFavoriteCategory)->id();
174 return m_scopes->scopeAt(index.row(), m_isFavoriteCategory)->name();
176 return qmlDirectory() + "graphics/applicationIcons/dash.png";
180 case RoleBackground + 1: // scopeId
181 return m_scopes->scopeAt(index.row(), m_isFavoriteCategory)->id();
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