@@ -162,23 +162,7 @@ void LauncherModel::pin(const QString &appId, int index)
162162
163163void LauncherModel::requestRemove(const QString &appId)
164164{
165− int index = findApplication(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− storeAppList();
175− return;
176− }
177−
178− beginRemoveRows(QModelIndex(), index, index);
179− m_list.takeAt(index)->deleteLater();
180− endRemoveRows();
181−
165+ unpin(appId);
182166 storeAppList();
183167}
184168
@@ -289,6 +273,24 @@ void LauncherModel::storeAppList()
289273 m_settings->setStoredApplications(appIds);
290274}
291275
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+
292294int LauncherModel::findApplication(const QString &appId)
293295{
294296 for (int i = 0; i < m_list.count(); ++i) {
@@ -370,18 +372,8 @@ void LauncherModel::refresh()
370372 }
371373 }
372374
373− // If running, just unpin, otherwise really remove
374375 Q_FOREACH (LauncherItem* item, toBeRemoved) {
375− int index = m_list.indexOf(item);
376− if (m_appManager->findApplication(item->appId())) {
377− item->setPinned(false);
378− QModelIndex modelIndex = this->index(index);
379− Q_EMIT dataChanged(modelIndex, modelIndex, QVector<int>() << RolePinned);
380− } else {
381− beginRemoveRows(QModelIndex(), index, index);
382− m_list.takeAt(index)->deleteLater();
383− endRemoveRows();
384− }
376+ unpin(item->appId());
385377 }
386378
387379 // This brings the Launcher into sync with the settings backend again. There's an issue though: