on bbbdccd help sign in
unity8/tests/mocks/Unity/fake_scopesoverview.h
117 lines 3.6 kB history raw
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
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.
7 *
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.
12 *
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/>.
15 */
17#ifndef FAKE_SCOPESOVERVIEW_H
18#define FAKE_SCOPESOVERVIEW_H
20#include "fake_scope.h"
21#include <unity/shell/scopes/ResultsModelInterface.h>
23class Scopes;
24class ScopesOverviewCategories;
25class ScopesOverviewResultsModel;
27class ScopesOverview : public Scope
29 Q_OBJECT
31public:
32 ScopesOverview(Scopes* parent = 0);
34 void setSearchQuery(const QString& search_query) override;
35 Q_INVOKABLE void activate(QVariant const& result, QString const& categoryId) override;
37 // This is implementation detail
38 void setFavorite(Scope *scope, bool favorite);
39 void moveFavoriteTo(Scope *scope, int index);
41private:
42 ScopesOverviewCategories *m_scopesOverviewCategories;
43 unity::shell::scopes::CategoriesInterface *m_searchCategories;
44};
46class ScopesOverviewCategories : public unity::shell::scopes::CategoriesInterface
48 Q_OBJECT
50public:
51 ScopesOverviewCategories(Scopes *scopes, QObject* parent = 0);
53 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
54 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
56 Q_INVOKABLE bool overrideCategoryJson(QString const& categoryId, QString const& json) override;
58 // This is implementation detail
59 void setFavorite(Scope *scope, bool favorite);
60 void moveFavoriteTo(Scope *scope, int index);
62private:
63 mutable QHash<int, ScopesOverviewResultsModel*> m_resultsModels;
65 Scopes *m_scopes;
66};
68class ScopesOverviewSearchCategories : public unity::shell::scopes::CategoriesInterface
70 Q_OBJECT
72public:
73 ScopesOverviewSearchCategories(Scopes *scopes, QObject* parent = 0);
75 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
76 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
78 Q_INVOKABLE bool overrideCategoryJson(QString const& categoryId, QString const& json) override;
80private:
81 mutable QHash<int, ScopesOverviewResultsModel*> m_resultsModels;
83 Scopes *m_scopes;
84};
86class ScopesOverviewResultsModel : public unity::shell::scopes::ResultsModelInterface
88 Q_OBJECT
90public:
91 explicit ScopesOverviewResultsModel(const QList<Scope *> &scopes, const QString &categoryId, QObject* parent = 0);
93 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
94 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
96 /* getters */
97 QString categoryId() const override;
98 int count() const override;
100 /* setters */
101 void setCategoryId(QString const& id) override;
103 /* Special API */
104 Q_INVOKABLE int scopeIndex(QString const& id) const;
105 QHash<int, QByteArray> roleNames() const override;
107 // This is implementation detail
108 void appendScope(Scope *scope);
109 void removeScope(Scope *scope);
110 void moveScopeTo(Scope *scope, int index);
112private:
113 QList<Scope *> m_scopes;
114 QString m_categoryId;
115};
117#endif // FAKE_SCOPESOVERVIEW_H