Merge lp:~mhr3/unity-scopes-shell/fix-1329890 into lp:unity-scopes-shell

Proposed by Michal Hruby
Status: Merged
Approved by: Pete Woods
Approved revision: 110
Merged at revision: 107
Proposed branch: lp:~mhr3/unity-scopes-shell/fix-1329890
Merge into: lp:unity-scopes-shell
Prerequisite: lp:~mhr3/unity-scopes-shell/expansion-queries
Diff against target: 112 lines (+25/-7)
2 files modified
src/Unity/scope.cpp (+20/-7)
src/Unity/scope.h (+5/-0)
To merge this branch: bzr merge lp:~mhr3/unity-scopes-shell/fix-1329890
Reviewer Review Type Date Requested Status
Pete Woods (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+226167@code.launchpad.net

This proposal supersedes a proposal from 2014-07-09.

Commit message

Emit openScope() and gotoScope() also from temp scopes.

Description of the change

Emit openScope() and gotoScope() also from temp scopes.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Pete Woods (pete-woods) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Unity/scope.cpp'
2--- src/Unity/scope.cpp 2014-07-09 16:22:03 +0000
3+++ src/Unity/scope.cpp 2014-07-09 16:22:03 +0000
4@@ -79,6 +79,8 @@
5 m_settings = QGSettings::isSchemaInstalled("com.canonical.Unity.Lenses") ? new QGSettings("com.canonical.Unity.Lenses", QByteArray(), this) : nullptr;
6 QObject::connect(m_settings, &QGSettings::changed, this, &Scope::internetFlagChanged);
7
8+ setScopesInstance(qobject_cast<scopes_ng::Scopes*>(parent));
9+
10 m_aggregatorTimer.setSingleShot(true);
11 QObject::connect(&m_aggregatorTimer, &QTimer::timeout, this, &Scope::flushUpdates);
12 m_clearTimer.setSingleShot(true);
13@@ -206,9 +208,8 @@
14
15 void Scope::executeCannedQuery(unity::scopes::CannedQuery const& query, bool allowDelayedActivation)
16 {
17- scopes_ng::Scopes* scopes = qobject_cast<scopes_ng::Scopes*>(parent());
18- if (scopes == nullptr) {
19- qWarning("Scope instance %p doesn't have Scopes as a parent", static_cast<void*>(this));
20+ if (!m_scopesInstance) {
21+ qWarning("Scope instance %p doesn't have associated Scopes instance", static_cast<void*>(this));
22 return;
23 }
24
25@@ -216,7 +217,7 @@
26 QString searchString(QString::fromStdString(query.query_string()));
27 QString departmentId(QString::fromStdString(query.department_id()));
28 // figure out if this scope is already favourited
29- Scope* scope = scopes->getScopeById(scopeId);
30+ Scope* scope = m_scopesInstance->getScopeById(scopeId);
31 if (scope != nullptr) {
32 // TODO: change filters?
33 scope->setCurrentDepartmentId(departmentId);
34@@ -224,10 +225,11 @@
35 Q_EMIT gotoScope(scopeId);
36 } else {
37 // create temp dash page
38- auto meta_sptr = scopes->getCachedMetadata(scopeId);
39+ auto meta_sptr = m_scopesInstance->getCachedMetadata(scopeId);
40 if (meta_sptr) {
41 scope = new scopes_ng::Scope(this);
42 scope->setScopeData(*meta_sptr);
43+ scope->setScopesInstance(m_scopesInstance);
44 scope->setCurrentDepartmentId(departmentId);
45 scope->setSearchQuery(searchString);
46 m_tempScopes.insert(scope);
47@@ -235,8 +237,7 @@
48 } else if (allowDelayedActivation) {
49 // request registry refresh to get the missing metadata
50 m_delayedActivation = std::make_shared<scopes::ActivationResponse>(query);
51- QObject::connect(scopes, &Scopes::metadataRefreshed, this, &Scope::metadataRefreshed);
52- scopes->refreshScopeMetadata();
53+ m_scopesInstance->refreshScopeMetadata();
54 } else {
55 qWarning("Unable to find scope \"%s\" after metadata refresh", query.scope_id().c_str());
56 }
57@@ -453,6 +454,18 @@
58 }
59 }
60
61+void Scope::setScopesInstance(Scopes* scopes)
62+{
63+ if (m_metadataConnection) {
64+ QObject::disconnect(m_metadataConnection);
65+ }
66+
67+ m_scopesInstance = scopes;
68+ if (m_scopesInstance) {
69+ m_metadataConnection = QObject::connect(scopes, &Scopes::metadataRefreshed, this, &Scope::metadataRefreshed);
70+ }
71+}
72+
73 void Scope::setSearchInProgress(bool searchInProgress)
74 {
75 if (m_searchInProgress != searchInProgress) {
76
77=== modified file 'src/Unity/scope.h'
78--- src/Unity/scope.h 2014-07-09 16:22:03 +0000
79+++ src/Unity/scope.h 2014-07-09 16:22:03 +0000
80@@ -25,6 +25,7 @@
81 #include <QString>
82 #include <QTimer>
83 #include <QMetaType>
84+#include <QMetaObject>
85 #include <QPointer>
86 #include <QMultiMap>
87 #include <QSet>
88@@ -48,6 +49,7 @@
89 class PushEvent;
90 class PreviewStack;
91 class SettingsModel;
92+class Scopes;
93
94 class CollectionController
95 {
96@@ -159,6 +161,7 @@
97 void departmentModelDestroyed(QObject* obj);
98
99 private:
100+ void setScopesInstance(Scopes*);
101 void startTtlTimer();
102 void setSearchInProgress(bool searchInProgress);
103 void setCurrentDepartmentId(QString const& id);
104@@ -201,6 +204,8 @@
105 QSet<unity::shell::scopes::ScopeInterface*> m_tempScopes;
106 QMultiMap<QString, Department*> m_departmentModels;
107 QMap<Department*, QString> m_inverseDepartments;
108+ QPointer<Scopes> m_scopesInstance;
109+ QMetaObject::Connection m_metadataConnection;
110 };
111
112 } // namespace scopes_ng

Subscribers

People subscribed via source and target branches

to all changes: