on xenial help sign in
implement openscope in the fake plugin so we can go to temp scopes from dash
commitfbd182d797387cff034665ce5cb2977c4e5aa294 authorAlbert Astals <albert.astals@canonical.com> dateThu 17 Jul 2014, 16:58 (12 years ago) parent94d598f
2 files changed+22−7
tests/mocks/Unity/fake_scope.cpp+17−5 tests/mocks/Unity/fake_scope.h+5−2
tests/mocks/Unity/fake_scope.cpp+17−5
@@ -18,14 +18,16 @@
1818#include <QUrl>
1919
2020#include "fake_scope.h"
21+
2122#include "fake_department.h"
2223#include "fake_resultsmodel.h"
24+#include "fake_scopes.h"
2325
24−Scope::Scope(QObject* parent) : Scope(QString(), QString(), false, parent)
26+Scope::Scope(Scopes* parent) : Scope(QString(), QString(), false, parent)
2527{
2628}
2729
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)
2931 : unity::shell::scopes::ScopeInterface(parent)
3032 , m_id(id)
3133 , m_name(name)
@@ -35,6 +37,7 @@ Scope::Scope(QString const& id, QString const& name, bool visible, QObject* pare
3537 , m_currentDeparment("root")
3638 , m_previewRendererName("preview-generic")
3739 , m_categories(new Categories(20, this))
40+ , m_openScope(nullptr)
3841{
3942}
4043
@@ -150,7 +153,12 @@ void Scope::setNoResultsHint(const QString& str)
150153
151154void Scope::activate(QVariant const& result)
152155{
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+ }
154162}
155163
156164PreviewStack* Scope::preview(QVariant const& result)
@@ -166,9 +174,13 @@ void Scope::cancelActivation()
166174{
167175}
168176
169−void Scope::closeScope(unity::shell::scopes::ScopeInterface* /*scope*/)
177+void Scope::closeScope(unity::shell::scopes::ScopeInterface* scope)
170178{
171− qFatal("Scope::closeScope is not implemented");
179+ if (scope != m_openScope) {
180+ qDebug() << scope << m_openScope;
181+ qFatal("Scope::closeScope got wrong scope in closeScope");
182+ }
183+ m_openScope = nullptr;
172184}
173185
174186QString Scope::currentDepartmentId() const
tests/mocks/Unity/fake_scope.h+5−2
@@ -24,13 +24,15 @@
2424
2525#include <QTimer>
2626
27+class Scopes;
28+
2729class Scope : public unity::shell::scopes::ScopeInterface
2830{
2931 Q_OBJECT
3032
3133public:
32− Scope(QObject* parent = 0);
33− Scope(QString const& id, QString const& name, bool visible, QObject* parent = 0);
34+ Scope(Scopes* parent = 0);
35+ Scope(QString const& id, QString const& name, bool visible, Scopes* parent = 0);
3436
3537 /* getters */
3638 QString id() const override;
@@ -85,6 +87,7 @@ protected:
8587 QString m_previewRendererName;
8688
8789 unity::shell::scopes::CategoriesInterface* m_categories;
90+ unity::shell::scopes::ScopeInterface* m_openScope;
8891};
8992
9093#endif // FAKE_SCOPE_H