on xenial help sign in
implement openscope in the fake plugin so we can go to temp scopes from dash
fbd182dAlbert Astals
tests/mocks/Unity/fake_scope.cpp+17−5
@@ -18,14 +18,16 @@
18#include <QUrl>
18#include <QUrl>
19
19
20#include "fake_scope.h"
20#include "fake_scope.h"
21+
21#include "fake_department.h"
22#include "fake_department.h"
22#include "fake_resultsmodel.h"
23#include "fake_resultsmodel.h"
24+#include "fake_scopes.h"
23
25
24−Scope::Scope(QObject* parent) : Scope(QString(), QString(), false, parent)
26+Scope::Scope(Scopes* parent) : Scope(QString(), QString(), false, parent)
25{
27{
26}
28}
27
29
28−Scope::Scope(QString const& id, QString const& name, bool visible, QObject* parent)
30+Scope::Scope(QString const& id, QString const& name, bool visible, Scopes* parent)
29 : unity::shell::scopes::ScopeInterface(parent)
31 : unity::shell::scopes::ScopeInterface(parent)
30 , m_id(id)
32 , m_id(id)
31 , m_name(name)
33 , m_name(name)
@@ -35,6 +37,7 @@ Scope::Scope(QString const& id, QString const& name, bool visible, QObject* pare
35 , m_currentDeparment("root")
37 , m_currentDeparment("root")
36 , m_previewRendererName("preview-generic")
38 , m_previewRendererName("preview-generic")
37 , m_categories(new Categories(20, this))
39 , m_categories(new Categories(20, this))
40+ , m_openScope(nullptr)
38{
41{
39}
42}
40
43
@@ -150,7 +153,12 @@ void Scope::setNoResultsHint(const QString& str)
150
153
151void Scope::activate(QVariant const& result)
154void Scope::activate(QVariant const& result)
152{
155{
153− qDebug() << "Called activate on scope" << m_id << "with result" << result;;
156+ qDebug() << "Called activate on scope" << m_id << "with result" << result;
157+ if (result.toString() == "Result.2.2") {
158+ Scopes *scopes = dynamic_cast<Scopes*>(parent());
159+ m_openScope = scopes->getScope("MockScope2");
160+ Q_EMIT openScope(m_openScope);
161+ }
154}
162}
155
163
156PreviewStack* Scope::preview(QVariant const& result)
164PreviewStack* Scope::preview(QVariant const& result)
@@ -166,9 +174,13 @@ void Scope::cancelActivation()
166{
174{
167}
175}
168
176
169−void Scope::closeScope(unity::shell::scopes::ScopeInterface* /*scope*/)
177+void Scope::closeScope(unity::shell::scopes::ScopeInterface* scope)
170{
178{
179+ if (scope != m_openScope) {
180+ qDebug() << scope << m_openScope;
171− qFatal("Scope::closeScope is not implemented");
181+ qFatal("Scope::closeScope got wrong scope in closeScope");
182+ }
183+ m_openScope = nullptr;
172}
184}
173
185
174QString Scope::currentDepartmentId() const
186QString Scope::currentDepartmentId() const
tests/mocks/Unity/fake_scope.h+5−2
@@ -24,13 +24,15 @@
24
24
25#include <QTimer>
25#include <QTimer>
26
26
27+class Scopes;
28+
27class Scope : public unity::shell::scopes::ScopeInterface
29class Scope : public unity::shell::scopes::ScopeInterface
28{
30{
29 Q_OBJECT
31 Q_OBJECT
30
32
31public:
33public:
32− Scope(QObject* parent = 0);
34+ Scope(Scopes* parent = 0);
33− Scope(QString const& id, QString const& name, bool visible, QObject* parent = 0);
35+ Scope(QString const& id, QString const& name, bool visible, Scopes* parent = 0);
34
36
35 /* getters */
37 /* getters */
36 QString id() const override;
38 QString id() const override;
@@ -85,6 +87,7 @@ protected:
85 QString m_previewRendererName;
87 QString m_previewRendererName;
86
88
87 unity::shell::scopes::CategoriesInterface* m_categories;
89 unity::shell::scopes::CategoriesInterface* m_categories;
90+ unity::shell::scopes::ScopeInterface* m_openScope;
88};
91};
89
92
90#endif // FAKE_SCOPE_H
93#endif // FAKE_SCOPE_H