on xenial help sign in
Implementation of onScopeRemoved.
552b10dPawel Stolowski
plugins/Unity/scopes.cpp+20−1
@@ -115,7 +115,15 @@ void Scopes::onScopesLoaded()
115
115
116void Scopes::onScopeRemoved(const unity::dash::Scope::Ptr& scope)
116void Scopes::onScopeRemoved(const unity::dash::Scope::Ptr& scope)
117{
117{
118− //TODO
118+ auto index = m_scopes.count();
119+ auto id = QString::fromStdString(scope->id);
120+ beginRemoveRows(QModelIndex(), index, index);
121+ auto removed_idx = removeUnityScope(id);
122+ endRemoveRows();
123+
124+ if (removed_idx >= 0) {
125+ Q_EMIT scopeRemoved(id, removed_idx);
126+ }
119}
127}
120
128
121void Scopes::onScopesReordered(const unity::dash::Scopes::ScopeList& scopes)
129void Scopes::onScopesReordered(const unity::dash::Scopes::ScopeList& scopes)
@@ -144,3 +152,14 @@ void Scopes::removeUnityScope(int index)
144
152
145 delete scope;
153 delete scope;
146}
154}
155+
156+int Scopes::removeUnityScope(const QString& scope_id)
157+{
158+ for (int i=0; i<m_scopes.count(); i++) {
159+ if (m_scopes[i]->id() == scope_id) {
160+ removeUnityScope(i);
161+ return i;
162+ }
163+ }
164+ return -1;
165+}
plugins/Unity/scopes.h+2
@@ -70,6 +70,7 @@ public:
70Q_SIGNALS:
70Q_SIGNALS:
71 void activateScopeRequested(const QString& scope_id);
71 void activateScopeRequested(const QString& scope_id);
72 void loadedChanged(bool loaded);
72 void loadedChanged(bool loaded);
73+ void scopeRemoved(const QString& scope_id, int index);
73
74
74private Q_SLOTS:
75private Q_SLOTS:
75 void onScopesLoaded();
76 void onScopesLoaded();
@@ -87,6 +88,7 @@ private:
87
88
88 void addUnityScope(const unity::dash::Scope::Ptr& unity_scope);
89 void addUnityScope(const unity::dash::Scope::Ptr& unity_scope);
89 void removeUnityScope(int index);
90 void removeUnityScope(int index);
91+ int removeUnityScope(const QString& scope_id);
90};
92};
91
93
92#endif // SCOPES_H
94#endif // SCOPES_H