@@ -0,0 +1,149 @@
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"
23+ScopesOverview::ScopesOverview(Scopes* parent)
24+ : Scope("scopesOverview", "Scopes Overview", false, parent)
27+ m_categories = new ScopesOverviewCategories(this);
30+ScopesOverviewCategories::ScopesOverviewCategories(QObject* parent)
31+ : unity::shell::scopes::CategoriesInterface(parent)
35+int ScopesOverviewCategories::rowCount(const QModelIndex& /*parent*/) const
40+void ScopesOverviewCategories::addSpecialCategory(QString const&, QString const&, QString const&, QString const&, QObject*)
42+ qFatal("Using un-implemented ScopesOverviewCategories::addSpecialCategory");
45+bool ScopesOverviewCategories::overrideCategoryJson(QString const& /* categoryId */, QString const& /* json */)
47+ qFatal("Using un-implemented ScopesOverviewCategories::overrideCategoryJson");
51+ScopesOverviewCategories::data(const QModelIndex& index, int role) const
53+ if (!index.isValid()) {
58+ unity::shell::scopes::ResultsModelInterface *resultsModel = m_resultsModels[index.row()];
60+ QObject *that = const_cast<ScopesOverviewCategories*>(this);
61+ resultsModel = new ScopesOverviewResultsModel(static_cast<Scopes*>(parent()), index.row() == 0, that);
62+ m_resultsModels[index.row()] = resultsModel;
66+ return index.row() == 0 ? "favourites" : "all";
68+ return index.row() == 0 ? "Favourites" : "All";
71+ case RoleRawRendererTemplate:
72+ qFatal("Using un-implemented RoleRawRendererTemplate Categories role");
77+ map["category-layout"] = "grid";
78+ map["card-size"] = "medium";
79+ map["overlay"] = true;
84+ QVariantMap map, artMap;
85+ artMap["aspect-ratio"] = "1.0";
86+ artMap["field"] = "art";
88+ map["title"] = "HOLA";
92+ return QVariant::fromValue(resultsModel);
94+ return resultsModel->rowCount();
96+ qFatal("Using un-implemented Categories role");
101+ScopesOverviewResultsModel::ScopesOverviewResultsModel(Scopes *scopes, bool isFavoriteCategory, QObject* parent)
102+ : unity::shell::scopes::ResultsModelInterface(parent)
104+ , m_isFavoriteCategory(isFavoriteCategory)
108+QString ScopesOverviewResultsModel::categoryId() const
110+ return m_isFavoriteCategory ? "favourites" : "all";
113+void ScopesOverviewResultsModel::setCategoryId(QString const& /*id*/)
115+ qFatal("Calling un-implemented ScopesOverviewResultsModel::setCategoryId");
118+int ScopesOverviewResultsModel::rowCount(const QModelIndex& parent) const
122+ return m_scopes->count(m_isFavoriteCategory);
125+int ScopesOverviewResultsModel::count() const
131+ScopesOverviewResultsModel::data(const QModelIndex& index, int role) const
135+ case RoleCategoryId:
140+ return m_scopes->scopeAt(index.row(), m_isFavoriteCategory)->name();
142+ return qmlDirectory() + "graphics/applicationIcons/dash.png";