on xenial help sign in
Make the mock compile
3f644ceAlbert Astals
qml/Dash/Dash.qml+9−11
@@ -30,7 +30,13 @@ Showable {
30 property real contentScale: 1.0
30 property real contentScale: 1.0
31
31
32 function setCurrentScope(scopeId, animate, reset) {
32 function setCurrentScope(scopeId, animate, reset) {
33− var scopeIndex = filteredScopes.findFirst(Scopes.RoleId, scopeId)
33+ var scopeIndex = -1;
34+ for (var i = 0; i < scopes.count; ++i) {
35+ if (scopes.getScope(i).id == scopeId) {
36+ scopeIndex = i;
37+ break;
38+ }
39+ }
34
40
35 if (scopeIndex == -1) {
41 if (scopeIndex == -1) {
36 console.warn("No match for scope with id: %1".arg(scopeId))
42 console.warn("No match for scope with id: %1".arg(scopeId))
@@ -55,15 +61,8 @@ Showable {
55 }
61 }
56 }
62 }
57
63
58− SortFilterProxyModel {
64+ Scopes {
59− id: filteredScopes
60− model: Scopes {
61− id: scopes
65+ id: scopes
62− }
63− dynamicSortFilter: true
64−
65− filterRole: Scopes.RoleVisible
66− filterRegExp: RegExp("^true$")
67 }
66 }
68
67
69 DashContent {
68 DashContent {
@@ -71,7 +70,6 @@ Showable {
71 objectName: "dashContent"
70 objectName: "dashContent"
72 width: parent.width
71 width: parent.width
73 height: parent.height
72 height: parent.height
74− model: filteredScopes
75 scopes: scopes
73 scopes: scopes
76 visible: x != -width
74 visible: x != -width
77 onGotoScope: {
75 onGotoScope: {
qml/Dash/DashContent.qml+1−3
@@ -23,8 +23,7 @@ import "../Components"
23Item {
23Item {
24 id: dashContent
24 id: dashContent
25
25
26− property var model: null
26+ property alias scopes: dashContentList.model
27− property var scopes: null
28 readonly property alias currentIndex: dashContentList.currentIndex
27 readonly property alias currentIndex: dashContentList.currentIndex
29
28
30 signal scopeLoaded(string scopeId)
29 signal scopeLoaded(string scopeId)
@@ -92,7 +91,6 @@ Item {
92 interactive: dashContent.scopes.loaded && currentItem && !currentItem.moving
91 interactive: dashContent.scopes.loaded && currentItem && !currentItem.moving
93
92
94 anchors.fill: parent
93 anchors.fill: parent
95− model: dashContent.model
96 orientation: ListView.Horizontal
94 orientation: ListView.Horizontal
97 boundsBehavior: Flickable.DragAndOvershootBounds
95 boundsBehavior: Flickable.DragAndOvershootBounds
98 flickDeceleration: units.gu(625)
96 flickDeceleration: units.gu(625)
qml/Dash/DashDepartments.qml+1−1
@@ -15,7 +15,7 @@
15 */
15 */
16
16
17import QtQuick 2.2
17import QtQuick 2.2
18−import Ubuntu.Components 0.1
18+import Ubuntu.Components 1.1
19
19
20AbstractButton {
20AbstractButton {
21 id: root
21 id: root
qml/Dash/DashDepartmentsList.qml+1−1
@@ -15,7 +15,7 @@
15 */
15 */
16
16
17import QtQuick 2.2
17import QtQuick 2.2
18−import Ubuntu.Components 0.1
18+import Ubuntu.Components 1.1
19
19
20Item {
20Item {
21 id: root
21 id: root
tests/mocks/Unity/CMakeLists.txt+2−2
@@ -22,14 +22,14 @@ set(UnityQML_SOURCES
22 fake_scope.cpp
22 fake_scope.cpp
23 fake_scopes.cpp
23 fake_scopes.cpp
24 fake_categories.cpp
24 fake_categories.cpp
25− fake_department.cpp
25+ fake_navigation.cpp
26 fake_resultsmodel.cpp
26 fake_resultsmodel.cpp
27 fake_previewmodel.cpp
27 fake_previewmodel.cpp
28 fake_previewstack.cpp
28 fake_previewstack.cpp
29 fake_previewwidgetmodel.cpp
29 fake_previewwidgetmodel.cpp
30 fake_unity_plugin.cpp
30 fake_unity_plugin.cpp
31 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/CategoriesInterface.h
31 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/CategoriesInterface.h
32− ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/DepartmentInterface.h
32+ ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/NavigationInterface.h
33 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewModelInterface.h
33 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewModelInterface.h
34 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewStackInterface.h
34 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewStackInterface.h
35 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewWidgetModelInterface.h
35 ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewWidgetModelInterface.h
tests/mocks/Unity/fake_department.cpp → tests/mocks/Unity/fake_navigation.cpprenamed+44−40
@@ -14,14 +14,15 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
15 */
16
16
17−#include "fake_department.h"
17+#include "fake_navigation.h"
18
18
19#include "fake_scope.h"
19#include "fake_scope.h"
20
20
21+#include <QDebug>
21#include <QTimer>
22#include <QTimer>
22
23
23−Department::Department(const QString& departmentId, const QString& label, const QString& allLabel, const QString& parentId, const QString& parentLabel, Scope* scope)
24+Navigation::Navigation(const QString& navigationId, const QString& label, const QString& allLabel, const QString& parentId, const QString& parentLabel, Scope* scope)
24− : m_departmentId(departmentId)
25+ : m_navigationId(navigationId)
25 , m_label(label)
26 , m_label(label)
26 , m_allLabel(allLabel)
27 , m_allLabel(allLabel)
27 , m_parentId(parentId)
28 , m_parentId(parentId)
@@ -30,96 +31,99 @@ Department::Department(const QString& departmentId, const QString& label, const
30 , m_scope(scope)
31 , m_scope(scope)
31{
32{
32 QTimer::singleShot(1500, this, SLOT(slotLoaded()));
33 QTimer::singleShot(1500, this, SLOT(slotLoaded()));
33− connect(scope, SIGNAL(currentDepartmentIdChanged()), this, SLOT(slotCurrentDepartmentChanged()));
34+ connect(scope, SIGNAL(currentNavigationIdChanged()), this, SLOT(slotCurrentNavigationChanged()));
34}
35}
35
36
36−QString Department::departmentId() const
37+QString Navigation::navigationId() const
37{
38{
38− return m_departmentId;
39+ return m_navigationId;
39}
40}
40
41
41−QString Department::label() const
42+QString Navigation::query() const
43+{
44+ return "navigation:/" + m_navigationId;
45+}
46+
47+QString Navigation::label() const
42{
48{
43 return m_label;
49 return m_label;
44}
50}
45
51
46−QString Department::allLabel() const
52+QString Navigation::allLabel() const
47{
53{
48 return m_allLabel;
54 return m_allLabel;
49}
55}
50
56
51−QString Department::parentDepartmentId() const
57+QString Navigation::parentNavigationId() const
52{
58{
53 return m_parentId;
59 return m_parentId;
54}
60}
55
61
62+QString Navigation::parentQuery() const
63+{
64+ return "navigation:/" + m_parentId;
65+}
66+
56−QString Department::parentLabel() const
67+QString Navigation::parentLabel() const
57{
68{
58 return m_parentLabel;
69 return m_parentLabel;
59}
70}
60
71
61−void Department::slotLoaded()
72+void Navigation::slotLoaded()
62{
73{
63 m_loaded = true;
74 m_loaded = true;
64 Q_EMIT loadedChanged();
75 Q_EMIT loadedChanged();
65}
76}
66
77
67−bool Department::loaded() const
78+bool Navigation::loaded() const
68{
79{
69 return m_loaded;
80 return m_loaded;
70}
81}
71
82
72−int Department::count() const
83+int Navigation::count() const
73{
84{
74 return rowCount();
85 return rowCount();
75}
86}
76
87
77−bool Department::isRoot() const
88+bool Navigation::isRoot() const
78{
89{
79− return m_departmentId == "root";
90+ return m_navigationId == "root" || m_navigationId == "altroot";
80}
91}
81
92
82−int Department::rowCount(const QModelIndex & /*parent*/) const
93+bool Navigation::hidden() const
83{
94{
84− if (!m_loaded || m_departmentId.startsWith("child") || m_departmentId == "middle3")
95+ return m_navigationId == "altroot";
85− return 0;
86− else
87− return 8;
88}
96}
89
97
90−QHash<int, QByteArray> Department::roleNames() const
98+int Navigation::rowCount(const QModelIndex & /*parent*/) const
91{
99{
92− QHash<int, QByteArray> res;
100+ if (!m_loaded || m_navigationId.startsWith("child") || m_navigationId == "middle3")
93− res[RoleDepartmentId] = "departmentId";
101+ return 0;
94− res[RoleLabel] = "label";
102+ else
95− res[RoleHasChildren] = "hasChildren";
96− res[RoleIsActive] = "isActive";
97− return res;
103+ return 8;
98}
104}
99
105
100−QVariant Department::data(const QModelIndex &index, int role) const
106+QVariant Navigation::data(const QModelIndex &index, int role) const
101{
107{
102 switch (role) {
108 switch (role) {
103− case RoleDepartmentId:
109+ case RoleQuery:
104− if (m_departmentId == "root")
110+ return QString("navigation:/%1").arg(data(index, RoleNavigationId).toString());
111+ case RoleNavigationId:
112+ if (m_navigationId == "root")
105 return QString("middle%1").arg(index.row());
113 return QString("middle%1").arg(index.row());
106− else if (m_departmentId.startsWith("middle"))
114+ else if (m_navigationId.startsWith("middle"))
107− return QString("child%1%2").arg(m_departmentId).arg(index.row());
115+ return QString("child%1%2").arg(m_navigationId).arg(index.row());
108− break;
109 case RoleLabel:
116 case RoleLabel:
110− return QString("%1Child%2").arg(m_departmentId).arg(index.row());
117+ return QString("%1Child%2").arg(m_navigationId).arg(index.row());
111− break;
112 case RoleHasChildren:
118 case RoleHasChildren:
113− return m_departmentId == "root" && index.row() != 3;
119+ return m_navigationId == "root" && index.row() != 3;
114− break;
115 case RoleIsActive:
120 case RoleIsActive:
116− return m_scope->currentDepartmentId() == data(index, RoleDepartmentId);
121+ return m_scope->currentNavigationId() == data(index, RoleNavigationId);
117− break;
118 }
122 }
119 return QVariant();
123 return QVariant();
120}
124}
121
125
122−void Department::slotCurrentDepartmentChanged()
126+void Navigation::slotCurrentNavigationChanged()
123{
127{
124 // This is wasteful, should only emit it if really something changed in this
128 // This is wasteful, should only emit it if really something changed in this
125 // deparment, but this is a mock, so no need to optimize
129 // deparment, but this is a mock, so no need to optimize
tests/mocks/Unity/fake_department.h → tests/mocks/Unity/fake_navigation.hrenamed+15−13
@@ -14,48 +14,50 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
15 */
16
16
17−#ifndef FAKE_DEPARTMENT_H
17+#ifndef FAKE_NAVIGATION_H
18−#define FAKE_DEPARTMENT_H
18+#define FAKE_NAVIGATION_H
19
19
20−#include <unity/shell/scopes/DepartmentInterface.h>
20+#include <unity/shell/scopes/NavigationInterface.h>
21
21
22class Scope;
22class Scope;
23
23
24−class Department : public unity::shell::scopes::DepartmentInterface
24+class Navigation : public unity::shell::scopes::NavigationInterface
25{
25{
26 Q_OBJECT
26 Q_OBJECT
27
27
28public:
28public:
29− Department(const QString& departmentId, const QString& label, const QString& allLabel, const QString& parentId, const QString& parentLabel, Scope* scope);
29+ Navigation(const QString& navigationId, const QString& label, const QString& allLabel, const QString& parentId, const QString& parentLabel, Scope* scope);
30
30
31+ QString navigationId() const override;
31− QString departmentId() const override;
32+ QString query() const override;
32 QString label() const override;
33 QString label() const override;
33 QString allLabel() const override;
34 QString allLabel() const override;
34− QString parentDepartmentId() const override;
35+ QString parentNavigationId() const override;
36+ QString parentQuery() const override;
35 QString parentLabel() const override;
37 QString parentLabel() const override;
36 bool loaded() const override;
38 bool loaded() const override;
37− int count() const override;
38 bool isRoot() const override;
39 bool isRoot() const override;
40+ bool hidden() const override;
41+ int count() const override;
39
42
40 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
43 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
41− QHash<int, QByteArray> roleNames() const;
42 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
44 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
43
45
44public Q_SLOTS:
46public Q_SLOTS:
45− void slotCurrentDepartmentChanged();
47+ void slotCurrentNavigationChanged();
46
48
47private Q_SLOTS:
49private Q_SLOTS:
48 void slotLoaded();
50 void slotLoaded();
49
51
50private:
52private:
51− QString m_departmentId;
53+ QString m_navigationId;
52 QString m_label;
54 QString m_label;
53 QString m_allLabel;
55 QString m_allLabel;
54 QString m_parentId;
56 QString m_parentId;
55 QString m_parentLabel;
57 QString m_parentLabel;
56 bool m_loaded;
58 bool m_loaded;
57− QString m_currentDepartment;
59+ QString m_currentNavigation;
58 Scope *m_scope;
60 Scope *m_scope;
59};
61};
60
62
61−#endif // FAKE_DEPARTMENT_H
63+#endif // FAKE_NAVIGATION_H
tests/mocks/Unity/fake_scope.cpp+64−17
@@ -14,24 +14,26 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
15 */
16
16
17+#include <QDebug>
17#include <QUrl>
18#include <QUrl>
18
19
19#include "fake_scope.h"
20#include "fake_scope.h"
20−#include "fake_department.h"
21+#include "fake_navigation.h"
21#include "fake_resultsmodel.h"
22#include "fake_resultsmodel.h"
22
23
23Scope::Scope(QObject* parent) : Scope(QString(), QString(), false, parent)
24Scope::Scope(QObject* parent) : Scope(QString(), QString(), false, parent)
24{
25{
25}
26}
26
27
27−Scope::Scope(QString const& id, QString const& name, bool visible, QObject* parent, int categories)
28+Scope::Scope(QString const& id, QString const& name, bool favorite, QObject* parent, int categories)
28 : unity::shell::scopes::ScopeInterface(parent)
29 : unity::shell::scopes::ScopeInterface(parent)
29 , m_id(id)
30 , m_id(id)
30 , m_name(name)
31 , m_name(name)
31− , m_visible(visible)
32 , m_searching(false)
32 , m_searching(false)
33+ , m_favorite(favorite)
33 , m_isActive(false)
34 , m_isActive(false)
34− , m_currentDeparment("root")
35+ , m_currentNavigationId("root")
36+ , m_currentAltNavigationId("altroot")
35 , m_previewRendererName("preview-generic")
37 , m_previewRendererName("preview-generic")
36 , m_categories(new Categories(categories, this))
38 , m_categories(new Categories(categories, this))
37{
39{
@@ -77,6 +79,11 @@ bool Scope::searchInProgress() const
77 return m_searching;
79 return m_searching;
78}
80}
79
81
82+bool Scope::favorite() const
83+{
84+ return m_favorite;
85+}
86+
80unity::shell::scopes::CategoriesInterface* Scope::categories() const
87unity::shell::scopes::CategoriesInterface* Scope::categories() const
81{
88{
82 return m_categories;
89 return m_categories;
@@ -97,11 +104,6 @@ QString Scope::formFactor() const
97 return m_formFactor;
104 return m_formFactor;
98}
105}
99
106
100−bool Scope::visible() const
101−{
102− return m_visible;
103−}
104−
105bool Scope::isActive() const
107bool Scope::isActive() const
106{
108{
107 return m_isActive;
109 return m_isActive;
@@ -131,6 +133,13 @@ void Scope::setActive(const bool active)
131 }
133 }
132}
134}
133
135
136+void Scope::setFavorite(const bool favorite)
137+{
138+ if (favorite != m_favorite) {
139+ m_favorite = favorite;
140+ Q_EMIT favoriteChanged();
141+ }
142+}
134void Scope::setSearchInProgress(const bool inProg)
143void Scope::setSearchInProgress(const bool inProg)
135{
144{
136 if (inProg != m_searching) {
145 if (inProg != m_searching) {
@@ -170,16 +179,31 @@ void Scope::closeScope(unity::shell::scopes::ScopeInterface* /*scope*/)
170 qFatal("Scope::closeScope is not implemented");
179 qFatal("Scope::closeScope is not implemented");
171}
180}
172
181
173−QString Scope::currentDepartmentId() const
182+QString Scope::currentNavigationId() const
174{
183{
175− return m_currentDeparment;
184+ return m_currentNavigationId;
176}
185}
177
186
178−bool Scope::hasDepartments() const
187+bool Scope::hasNavigation() const
179{
188{
180 return true;
189 return true;
181}
190}
182
191
192+QString Scope::currentAltNavigationId() const
193+{
194+ return m_currentAltNavigationId;
195+}
196+
197+bool Scope::hasAltNavigation() const
198+{
199+ return true;
200+}
201+
202+Scope::Status Scope::status() const
203+{
204+ return Status::Okay;
205+}
206+
183QVariantMap Scope::customizations() const
207QVariantMap Scope::customizations() const
184{
208{
185 QVariantMap m, h;
209 QVariantMap m, h;
@@ -196,7 +220,7 @@ QVariantMap Scope::customizations() const
196 return m;
220 return m;
197}
221}
198
222
199−unity::shell::scopes::DepartmentInterface* Scope::getDepartment(const QString& id)
223+unity::shell::scopes::NavigationInterface* Scope::getNavigation(const QString& id)
200{
224{
201 if (id.isEmpty())
225 if (id.isEmpty())
202 return nullptr;
226 return nullptr;
@@ -210,11 +234,34 @@ unity::shell::scopes::DepartmentInterface* Scope::getDepartment(const QString& i
210 parentId = id.mid(5, 7);
234 parentId = id.mid(5, 7);
211 parentLabel = parentId;
235 parentLabel = parentId;
212 }
236 }
237+ return new Navigation(id, id, "all"+id, parentId, parentLabel, this);
238+}
239+
240+unity::shell::scopes::NavigationInterface* Scope::getAltNavigation(QString const& id)
241+{
242+ if (id.isEmpty())
243+ return nullptr;
244+
245+ QString parentId;
246+ QString parentLabel;
247+ if (id.startsWith("altmiddle")) {
248+ parentId = "altroot";
249+ parentLabel = "altroot";
250+ }
213− return new Department(id, id, "all"+id, parentId, parentLabel, this);
251+ return new Navigation(id, id, "all"+id, parentId, parentLabel, this);
214}
252}
215
253
216−void Scope::loadDepartment(const QString& id)
254+void Scope::performQuery(const QString& query)
217{
255{
218− m_currentDeparment = id;
256+ if (query.startsWith("navigation:/")) {
219− Q_EMIT currentDepartmentIdChanged();
257+ QString navigationId = query;
258+ navigationId.remove(0, QString("navigation:/").length());
259+ if (navigationId.startsWith("alt")) {
260+ m_currentAltNavigationId = navigationId;
261+ Q_EMIT currentAltNavigationIdChanged();
262+ } else {
263+ m_currentNavigationId = navigationId;
264+ Q_EMIT currentNavigationIdChanged();
265+ }
266+ }
220}
267}
tests/mocks/Unity/fake_scope.h+14−9
@@ -30,7 +30,7 @@ class Scope : public unity::shell::scopes::ScopeInterface
30
30
31public:
31public:
32 Scope(QObject* parent = 0);
32 Scope(QObject* parent = 0);
33− Scope(QString const& id, QString const& name, bool visible, QObject* parent = 0, int categories = 20);
33+ Scope(QString const& id, QString const& name, bool favorite, QObject* parent = 0, int categories = 20);
34
34
35 /* getters */
35 /* getters */
36 QString id() const override;
36 QString id() const override;
@@ -38,9 +38,9 @@ public:
38 QString iconHint() const override;
38 QString iconHint() const override;
39 QString description() const override;
39 QString description() const override;
40 QString searchHint() const override;
40 QString searchHint() const override;
41− bool visible() const override;
42 QString shortcut() const override;
41 QString shortcut() const override;
43 bool searchInProgress() const override;
42 bool searchInProgress() const override;
43+ bool favorite() const override;
44 unity::shell::scopes::CategoriesInterface* categories() const override;
44 unity::shell::scopes::CategoriesInterface* categories() const override;
45 QString searchQuery() const override;
45 QString searchQuery() const override;
46 QString noResultsHint() const override;
46 QString noResultsHint() const override;
@@ -53,6 +53,7 @@ public:
53 void setNoResultsHint(const QString& hint) override;
53 void setNoResultsHint(const QString& hint) override;
54 void setFormFactor(const QString& form_factor) override;
54 void setFormFactor(const QString& form_factor) override;
55 void setActive(const bool) override;
55 void setActive(const bool) override;
56+ void setFavorite(const bool) override;
56 Q_INVOKABLE void setSearchInProgress(const bool inProg); // This is not invokable in the Interface, here for testing benefits
57 Q_INVOKABLE void setSearchInProgress(const bool inProg); // This is not invokable in the Interface, here for testing benefits
57
58
58 Q_INVOKABLE void activate(QVariant const& result) override;
59 Q_INVOKABLE void activate(QVariant const& result) override;
@@ -60,12 +61,15 @@ public:
60 Q_INVOKABLE void cancelActivation() override;
61 Q_INVOKABLE void cancelActivation() override;
61 Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface* scope) override;
62 Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface* scope) override;
62
63
63− QString currentDepartmentId() const override;
64+ QString currentNavigationId() const override;
65+ bool hasNavigation() const override;
66+ QString currentAltNavigationId() const override;
64− bool hasDepartments() const override;
67+ bool hasAltNavigation() const override;
65− Q_INVOKABLE unity::shell::scopes::DepartmentInterface* getDepartment(const QString& id) override;
68+ Q_INVOKABLE unity::shell::scopes::NavigationInterface* getNavigation(QString const& navigationId) override;
66− Q_INVOKABLE void loadDepartment(const QString& id) override;
69+ Q_INVOKABLE unity::shell::scopes::NavigationInterface* getAltNavigation(QString const& altNavigationId) override;
67− Q_SIGNAL void performQuery(const QString& query) override;
70+ Q_INVOKABLE void performQuery(const QString& query) override;
68
71
72+ Status status() const override;
69 QVariantMap customizations() const override;
73 QVariantMap customizations() const override;
70
74
71protected:
75protected:
@@ -77,10 +81,11 @@ protected:
77 QString m_searchQuery;
81 QString m_searchQuery;
78 QString m_noResultsHint;
82 QString m_noResultsHint;
79 QString m_formFactor;
83 QString m_formFactor;
80− bool m_visible;
81 bool m_searching;
84 bool m_searching;
85+ bool m_favorite;
82 bool m_isActive;
86 bool m_isActive;
83− QString m_currentDeparment;
87+ QString m_currentNavigationId;
88+ QString m_currentAltNavigationId;
84
89
85 QString m_previewRendererName;
90 QString m_previewRendererName;
86
91
tests/mocks/Unity/fake_scopes.cpp+10−2
@@ -32,6 +32,11 @@ Scopes::Scopes(QObject *parent)
32 timer.setSingleShot(true);
32 timer.setSingleShot(true);
33 timer.setInterval(100);
33 timer.setInterval(100);
34 QObject::connect(&timer, SIGNAL(timeout()), this, SLOT(updateScopes()));
34 QObject::connect(&timer, SIGNAL(timeout()), this, SLOT(updateScopes()));
35+
36+ QObject::connect(this, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SIGNAL(countChanged()));
37+ QObject::connect(this, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SIGNAL(countChanged()));
38+ QObject::connect(this, SIGNAL(modelReset()), this, SIGNAL(countChanged()));
39+
35 load();
40 load();
36}
41}
37
42
@@ -92,8 +97,6 @@ QVariant Scopes::data(const QModelIndex& index, int role) const
92 return QVariant::fromValue(scope);
97 return QVariant::fromValue(scope);
93 } else if (role == Scopes::RoleId) {
98 } else if (role == Scopes::RoleId) {
94 return QVariant::fromValue(scope->id());
99 return QVariant::fromValue(scope->id());
95− } else if (role == Scopes::RoleVisible) {
96− return QVariant::fromValue(scope->visible());
97 } else if (role == Scopes::RoleTitle) {
100 } else if (role == Scopes::RoleTitle) {
98 return QVariant::fromValue(scope->name());
101 return QVariant::fromValue(scope->name());
99 } else {
102 } else {
@@ -125,6 +128,11 @@ bool Scopes::loaded() const
125 return m_loaded;
128 return m_loaded;
126}
129}
127
130
131+int Scopes::count() const
132+{
133+ return rowCount();
134+}
135+
128unity::shell::scopes::ScopeInterface* Scopes::overviewScope() const
136unity::shell::scopes::ScopeInterface* Scopes::overviewScope() const
129{
137{
130 return nullptr;
138 return nullptr;
tests/mocks/Unity/fake_scopes.h+1
@@ -50,6 +50,7 @@ public:
50 QModelIndex parent ( const QModelIndex & index ) const;
50 QModelIndex parent ( const QModelIndex & index ) const;
51
51
52 bool loaded() const override;
52 bool loaded() const override;
53+ int count() const override;
53 unity::shell::scopes::ScopeInterface* overviewScope() const override;
54 unity::shell::scopes::ScopeInterface* overviewScope() const override;
54
55
55private Q_SLOTS:
56private Q_SLOTS:
tests/mocks/Unity/fake_unity_plugin.cpp+2−2
@@ -22,7 +22,7 @@
22// local
22// local
23#include "fake_scopes.h"
23#include "fake_scopes.h"
24#include "fake_categories.h"
24#include "fake_categories.h"
25−#include "fake_department.h"
25+#include "fake_navigation.h"
26#include "fake_previewmodel.h"
26#include "fake_previewmodel.h"
27#include "fake_previewwidgetmodel.h"
27#include "fake_previewwidgetmodel.h"
28#include "fake_resultsmodel.h"
28#include "fake_resultsmodel.h"
@@ -43,7 +43,7 @@ void FakeUnityPlugin::registerTypes(const char *uri)
43 qmlRegisterType<Scopes>(uri, 0, 2, "Scopes");
43 qmlRegisterType<Scopes>(uri, 0, 2, "Scopes");
44 qmlRegisterType<Scope>(uri, 0, 2, "MockScope");
44 qmlRegisterType<Scope>(uri, 0, 2, "MockScope");
45 qmlRegisterUncreatableType<unity::shell::scopes::ScopeInterface>(uri, 0, 2, "Scope", "Can't create Scope object in QML.");
45 qmlRegisterUncreatableType<unity::shell::scopes::ScopeInterface>(uri, 0, 2, "Scope", "Can't create Scope object in QML.");
46− qmlRegisterUncreatableType<unity::shell::scopes::DepartmentInterface>(uri, 0, 2, "Department", "Can't create Department object in QML.");
46+ qmlRegisterUncreatableType<unity::shell::scopes::NavigationInterface>(uri, 0, 2, "Navigation", "Can't create Navigation object in QML.");
47 qmlRegisterUncreatableType<unity::shell::scopes::CategoriesInterface>(uri, 0, 2, "Categories", "Can't create Categories object in QML.");
47 qmlRegisterUncreatableType<unity::shell::scopes::CategoriesInterface>(uri, 0, 2, "Categories", "Can't create Categories object in QML.");
48 qmlRegisterUncreatableType<unity::shell::scopes::PreviewModelInterface>(uri, 0, 2, "PreviewModel", "Can't create new PreviewModel in QML. Get them from PreviewStack instance.");
48 qmlRegisterUncreatableType<unity::shell::scopes::PreviewModelInterface>(uri, 0, 2, "PreviewModel", "Can't create new PreviewModel in QML. Get them from PreviewStack instance.");
49 qmlRegisterUncreatableType<ResultsModel>(uri, 0, 2, "ResultsModel", "Can't create ResultsModel object in QML.");
49 qmlRegisterUncreatableType<ResultsModel>(uri, 0, 2, "ResultsModel", "Can't create ResultsModel object in QML.");