on xenial help sign in
merge prereq
fab32a5Michael Zanetti
plugins/Unity/Launcher/launchermodel.cpp+20−17
@@ -162,22 +162,7 @@ void LauncherModel::pin(const QString &appId, int index)
162
162
163void LauncherModel::requestRemove(const QString &appId)
163void LauncherModel::requestRemove(const QString &appId)
164{
164{
165− int index = findApplication(appId);
165+ unpin(appId);
166− if (index < 0) {
167− return;
168− }
169−
170− if (m_appManager->findApplication(appId)) {
171− m_list.at(index)->setPinned(false);
172− QModelIndex modelIndex = this->index(index);
173− Q_EMIT dataChanged(modelIndex, modelIndex, QVector<int>() << RolePinned);
174− return;
175− }
176−
177− beginRemoveRows(QModelIndex(), index, index);
178− m_list.takeAt(index)->deleteLater();
179− endRemoveRows();
180−
181 storeAppList();
166 storeAppList();
182}
167}
183
168
@@ -288,6 +273,24 @@ void LauncherModel::storeAppList()
288 m_settings->setStoredApplications(appIds);
273 m_settings->setStoredApplications(appIds);
289}
274}
290
275
276+void LauncherModel::unpin(const QString &appId)
277+{
278+ int index = findApplication(appId);
279+ if (index < 0) {
280+ return;
281+ }
282+
283+ if (m_appManager->findApplication(appId)) {
284+ m_list.at(index)->setPinned(false);
285+ QModelIndex modelIndex = this->index(index);
286+ Q_EMIT dataChanged(modelIndex, modelIndex, QVector<int>() << RolePinned);
287+ } else {
288+ beginRemoveRows(QModelIndex(), index, index);
289+ m_list.takeAt(index)->deleteLater();
290+ endRemoveRows();
291+ }
292+}
293+
291int LauncherModel::findApplication(const QString &appId)
294int LauncherModel::findApplication(const QString &appId)
292{
295{
293 for (int i = 0; i < m_list.count(); ++i) {
296 for (int i = 0; i < m_list.count(); ++i) {
@@ -370,7 +373,7 @@ void LauncherModel::refresh()
370 }
373 }
371
374
372 Q_FOREACH (LauncherItem* item, toBeRemoved) {
375 Q_FOREACH (LauncherItem* item, toBeRemoved) {
373− requestRemove(item->appId());
376+ unpin(item->appId());
374 }
377 }
375
378
376 bool changed = toBeRemoved.count() > 0;
379 bool changed = toBeRemoved.count() > 0;
plugins/Unity/Launcher/launchermodel.h+2
@@ -62,6 +62,8 @@ public Q_SLOTS:
62private:
62private:
63 void storeAppList();
63 void storeAppList();
64
64
65+ void unpin(const QString &appId);
66+
65private Q_SLOTS:
67private Q_SLOTS:
66 void countChanged(const QString &appId, int count);
68 void countChanged(const QString &appId, int count);
67 void countVisibleChanged(const QString &appId, int count);
69 void countVisibleChanged(const QString &appId, int count);
tests/plugins/Unity/Launcher/gsettings.cpp+2−1
@@ -37,8 +37,9 @@ void GSettings::setStoredApplications(const QStringList &storedApplications)
37 m_entries = storedApplications;
37 m_entries = storedApplications;
38}
38}
39
39
40−void GSettings::simulateDconfChange(const QStringList &storedApplications)
40+void GSettings::simulateDConfChanged(const QStringList &storedApplications)
41{
41{
42 m_entries = storedApplications;
42 m_entries = storedApplications;
43+ setStoredApplications(storedApplications);
43 Q_EMIT changed();
44 Q_EMIT changed();
44}
45}
tests/plugins/Unity/Launcher/gsettings.h+1−1
@@ -35,7 +35,7 @@ public:
35 void setStoredApplications(const QStringList &storedApplications);
35 void setStoredApplications(const QStringList &storedApplications);
36
36
37 // Only for testing
37 // Only for testing
38− void simulateDconfChange(const QStringList &storedApplications);
38+ void simulateDConfChanged(const QStringList &storedApplications);
39
39
40Q_SIGNALS:
40Q_SIGNALS:
41 void changed();
41 void changed();
tests/plugins/Unity/Launcher/launchermodeltest.cpp+2−2
@@ -451,7 +451,7 @@ private Q_SLOTS:
451 QCOMPARE(settings->storedApplications().count(), 2);
451 QCOMPARE(settings->storedApplications().count(), 2);
452
452
453 // Now remove 1 app through the backend, make sure one is still there
453 // Now remove 1 app through the backend, make sure one is still there
454− settings->simulateDconfChange(QStringList() << "abs-icon");
454+ settings->simulateDConfChanged(QStringList() << "abs-icon");
455 QCOMPARE(settings->storedApplications().count(), 1);
455 QCOMPARE(settings->storedApplications().count(), 1);
456 QCOMPARE(spy.count(), 1);
456 QCOMPARE(spy.count(), 1);
457
457
@@ -459,7 +459,7 @@ private Q_SLOTS:
459 QCOMPARE(launcherModel->rowCount(), 1);
459 QCOMPARE(launcherModel->rowCount(), 1);
460
460
461 // Add them back but in reverse order
461 // Add them back but in reverse order
462− settings->simulateDconfChange(QStringList() << "no-icon" << "abs-icon");
462+ settings->simulateDConfChanged(QStringList() << "no-icon" << "abs-icon");
463 QCOMPARE(launcherModel->rowCount(), 2);
463 QCOMPARE(launcherModel->rowCount(), 2);
464 QCOMPARE(launcherModel->get(0)->appId(), QString("no-icon"));
464 QCOMPARE(launcherModel->get(0)->appId(), QString("no-icon"));
465 QCOMPARE(launcherModel->get(1)->appId(), QString("abs-icon"));
465 QCOMPARE(launcherModel->get(1)->appId(), QString("abs-icon"));