on xenial help sign in
don't emit pinnedChanged if it actually doesn't unpin, update test
a060334Michael Zanetti
plugins/Unity/Launcher/launchermodel.cpp+5−3
@@ -281,9 +281,11 @@ void LauncherModel::unpin(const QString &appId)
281 }
281 }
282
282
283 if (m_appManager->findApplication(appId)) {
283 if (m_appManager->findApplication(appId)) {
284+ if (m_list.at(index)->pinned()) {
284− m_list.at(index)->setPinned(false);
285+ m_list.at(index)->setPinned(false);
285− QModelIndex modelIndex = this->index(index);
286+ QModelIndex modelIndex = this->index(index);
286− Q_EMIT dataChanged(modelIndex, modelIndex, QVector<int>() << RolePinned);
287+ Q_EMIT dataChanged(modelIndex, modelIndex, QVector<int>() << RolePinned);
288+ }
287 } else {
289 } else {
288 beginRemoveRows(QModelIndex(), index, index);
290 beginRemoveRows(QModelIndex(), index, index);
289 m_list.takeAt(index)->deleteLater();
291 m_list.takeAt(index)->deleteLater();
tests/plugins/Unity/Launcher/launchermodeltest.cpp+3−2
@@ -186,6 +186,7 @@ private Q_SLOTS:
186 QCOMPARE(spy.count() > 0, true);
186 QCOMPARE(spy.count() > 0, true);
187 QCOMPARE(spy.at(0).at(2).value<QVector<int>>().first(), (int)LauncherModelInterface::RolePinned);
187 QCOMPARE(spy.at(0).at(2).value<QVector<int>>().first(), (int)LauncherModelInterface::RolePinned);
188
188
189+ // App should be pinned now
189 spy.clear();
190 spy.clear();
190 launcherModel->requestRemove(launcherModel->get(0)->appId());
191 launcherModel->requestRemove(launcherModel->get(0)->appId());
191 QCOMPARE(launcherModel->get(0)->pinned(), false);
192 QCOMPARE(launcherModel->get(0)->pinned(), false);
@@ -193,12 +194,12 @@ private Q_SLOTS:
193 QCOMPARE(spy.count(), 1);
194 QCOMPARE(spy.count(), 1);
194 QCOMPARE(spy.at(0).at(2).value<QVector<int>>().first(), (int)LauncherModelInterface::RolePinned);
195 QCOMPARE(spy.at(0).at(2).value<QVector<int>>().first(), (int)LauncherModelInterface::RolePinned);
195
196
197+ // Now that the app is unpinned, nothing should change, but the signal shouldn't be emitted
196 spy.clear();
198 spy.clear();
197 launcherModel->requestRemove(launcherModel->get(0)->appId());
199 launcherModel->requestRemove(launcherModel->get(0)->appId());
198 QCOMPARE(launcherModel->get(0)->pinned(), false);
200 QCOMPARE(launcherModel->get(0)->pinned(), false);
199 QCOMPARE(launcherModel->get(1)->pinned(), false);
201 QCOMPARE(launcherModel->get(1)->pinned(), false);
200− QCOMPARE(spy.count(), 1);
202+ QCOMPARE(spy.count(), 0);
201− QCOMPARE(spy.at(0).at(2).value<QVector<int>>().first(), (int)LauncherModelInterface::RolePinned);
202 }
203 }
203
204
204 void testRemove_data() {
205 void testRemove_data() {