on xenial help sign in
Implementation of onScopeRemoved.
commit552b10debde30764d2e182d138135f9c6692c9d8 authorPawel Stolowski <pawel.stolowski@canonical.com> dateWed 12 Jun 2013, 17:58 (13 years ago) parenta6b356f
2 files changed+22−1
plugins/Unity/scopes.cpp+20−1 plugins/Unity/scopes.h+2
plugins/Unity/scopes.cpp+20−1
@@ -115,7 +115,15 @@ void Scopes::onScopesLoaded()
115115
116116void Scopes::onScopeRemoved(const unity::dash::Scope::Ptr& scope)
117117{
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+ }
119127}
120128
121129void Scopes::onScopesReordered(const unity::dash::Scopes::ScopeList& scopes)
@@ -144,3 +152,14 @@ void Scopes::removeUnityScope(int index)
144152
145153 delete scope;
146154}
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:
7070Q_SIGNALS:
7171 void activateScopeRequested(const QString& scope_id);
7272 void loadedChanged(bool loaded);
73+ void scopeRemoved(const QString& scope_id, int index);
7374
7475private Q_SLOTS:
7576 void onScopesLoaded();
@@ -87,6 +88,7 @@ private:
8788
8889 void addUnityScope(const unity::dash::Scope::Ptr& unity_scope);
8990 void removeUnityScope(int index);
91+ int removeUnityScope(const QString& scope_id);
9092};
9193
9294#endif // SCOPES_H