@@ -92,25 +92,27 @@ void LauncherModel::move(int oldIndex, int newIndex)
9292 pin(m_list.at(newIndex)->appId());
9393}
9494
95−void LauncherModel::pin(const QString &appId)
95+void LauncherModel::pin(const QString &appId, int index)
9696{
97− int index = findApplication(appId);
98− if (index < 0) {
99− return;
100− }
101−
102− LauncherItem *item = m_list.at(index);
103− if (!item->pinned()) {
97+ int currentIndex = findApplication(appId);
10498
99+ if (currentIndex >= 0) {
100+ if (index == -1 || index == currentIndex) {
101+ m_list.at(currentIndex)->setPinned(true);
102+ QModelIndex modelIndex = this->index(currentIndex);
103+ Q_EMIT dataChanged(modelIndex, modelIndex);
104+ } else {
105+ move(currentIndex, index);
106+ }
107+ } else {
108+ beginInsertRows(QModelIndex(), index, index);
109+ LauncherItem *item = new LauncherItem(appId,
110+ m_backend->desktopFile(appId),
111+ m_backend->displayName(appId),
112+ m_backend->icon(appId));
105113 item->setPinned(true);
106− item->setRecent(false);
107−
108− m_backend->setPinned(item->appId(), true);
109−
110− QModelIndex modelIndex = this->index(index);
111− Q_EMIT dataChanged(modelIndex, modelIndex);
112−
113− storeAppList();
114+ m_list.insert(index, item);
115+ endInsertRows();
114116 }
115117}
116118
@@ -128,7 +130,7 @@ void LauncherModel::requestRemove(const QString &appId)
128130 storeAppList();
129131}
130132
131−void LauncherModel::triggerQuickListAction(const QString &appId, int quickListIndex)
133+void LauncherModel::quickListActionInvoked(const QString &appId, int quickListIndex)
132134{
133135 int index = findApplication(appId);
134136 if (index < 0) {