on xenial help sign in
Launcher - remove support for pinning items in the backend

After the latest design changes, recent apps is everything that is contained in the ApplicationManager. So no need for storing anything else than pinned apps in the config. Approved by Albert Astals Cid.

commite878ba09a4717faf4670b10363cdc214bce75b1a authorMichael Zanetti <michael.zanetti@canonical.com> dateWed 9 Oct 2013, 18:37 (13 years ago) parentcc21ad54f6d35e
4 files changed+3−76
plugins/Unity/Launcher/backend/launcherbackend.cpp−33 plugins/Unity/Launcher/backend/launcherbackend.h−15 plugins/Unity/Launcher/launchermodel.cpp+3−7 tests/plugins/Unity/Launcher/launcherbackendtest.cpp−21
plugins/Unity/Launcher/backend/launcherbackend.cpp−33
@@ -30,12 +30,9 @@
3030class LauncherBackendItem
3131{
3232public:
33− LauncherBackendItem(): pinned(false) {}
34−
3533 QString desktopFile;
3634 QString displayName;
3735 QString icon;
38− bool pinned;
3936};
4037
4138LauncherBackend::LauncherBackend(QObject *parent):
@@ -135,32 +132,6 @@ QString LauncherBackend::icon(const QString &appId) const
135132 return iconName;
136133}
137134
138−bool LauncherBackend::isPinned(const QString &appId) const
139−{
140− LauncherBackendItem *item = m_itemCache.value(appId);
141− if (item) {
142− return item->pinned;
143− }
144− return false;
145−}
146−
147−void LauncherBackend::setPinned(const QString &appId, bool pinned)
148−{
149− if (!m_storedApps.contains(appId)) {
150− return;
151− }
152−
153− LauncherBackendItem *item = m_itemCache.value(appId);
154− if (!item) {
155− item = new LauncherBackendItem();
156− m_itemCache.insert(appId, item);
157− }
158− if (item->pinned != pinned) {
159− item->pinned = pinned;
160− syncToAccounts();
161− }
162−}
163−
164135QList<QuickListEntry> LauncherBackend::quickList(const QString &appId) const
165136{
166137 // TODO: Get static (from .desktop file) and dynamic (from the app itself)
@@ -233,7 +204,6 @@ void LauncherBackend::syncFromAccounts()
233204 if (!m_itemCache.contains(appId)) {
234205 m_itemCache.insert(appId, parseDesktopFile(df));
235206 }
236− m_itemCache.value(appId)->pinned = true;
237207 }
238208 }
239209 }
@@ -305,7 +275,6 @@ LauncherBackendItem* LauncherBackend::parseDesktopFile(const QString &desktopFil
305275 } else {
306276 item->icon = "image://theme/" + iconString;
307277 }
308− item->pinned = false;
309278 return item;
310279}
311280
@@ -326,7 +295,6 @@ void LauncherBackend::loadFromVariant(const QVariantMap &details)
326295 item->desktopFile = details.value("desktopFile").toString();
327296 item->displayName = details.value("name").toString();
328297 item->icon = details.value("icon").toString();
329− item->pinned = details.value("is-pinned").toBool();
330298
331299 m_itemCache.insert(appId, item);
332300 m_storedApps.append(appId);
@@ -340,7 +308,6 @@ QVariantMap LauncherBackend::itemToVariant(const QString &appId) const
340308 details.insert("name", item->displayName);
341309 details.insert("icon", item->icon);
342310 details.insert("desktopFile", item->desktopFile);
343− details.insert("is-pinned", item->pinned);
344311 return details;
345312}
346313
plugins/Unity/Launcher/backend/launcherbackend.h−15
@@ -88,21 +88,6 @@ public:
8888 */
8989 QString icon(const QString &appId) const;
9090
91− /**
92− * @brief Is the app manually pinned?
93− * @returns true if pinned, otherwise false.
94− */
95− bool isPinned(const QString &appId) const;
96−
97− /**
98− * @brief Change the pinned state of an application.
99− * @param appId The application where the pinned flag should be set.
100− * @param pinned true if pinned, otherwise false.
101− */
102− void setPinned(const QString &appId, bool pinned);
103−
104− //TODO: Fill in getters for all the other things needed from the .desktop file.
105−
10691 /**
10792 * @brief Get the QuickList for an application.
10893 * @param appId The ID of the application.
plugins/Unity/Launcher/launchermodel.cpp+3−7
@@ -38,11 +38,7 @@ LauncherModel::LauncherModel(QObject *parent):
3838 m_backend->displayName(entry),
3939 m_backend->icon(entry),
4040 this);
41− if (m_backend->isPinned(entry)) {
42− item->setPinned(true);
43− } else {
44− item->setRecent(true);
45− }
41+ item->setPinned(true);
4642 m_list.append(item);
4743 }
4844}
@@ -129,11 +125,12 @@ void LauncherModel::pin(const QString &appId, int index)
129125 if (currentIndex >= 0) {
130126 if (index == -1 || index == currentIndex) {
131127 m_list.at(currentIndex)->setPinned(true);
132− m_backend->setPinned(appId, true);
133128 QModelIndex modelIndex = this->index(currentIndex);
134129 Q_EMIT dataChanged(modelIndex, modelIndex);
135130 } else {
136131 move(currentIndex, index);
132+ // move() will store the list to the backend itself, so just exit at this point.
133+ return;
137134 }
138135 } else {
139136 if (index == -1) {
@@ -144,7 +141,6 @@ void LauncherModel::pin(const QString &appId, int index)
144141 m_backend->displayName(appId),
145142 m_backend->icon(appId));
146143 item->setPinned(true);
147− m_backend->setPinned(appId, true);
148144 m_list.insert(index, item);
149145 endInsertRows();
150146 }
tests/plugins/Unity/Launcher/launcherbackendtest.cpp−21
@@ -43,27 +43,6 @@ private Q_SLOTS:
4343 QCOMPARE(backend.storedApplications(), QStringList() << "rel-icon" << "abs-icon");
4444 }
4545
46− void testPinning()
47− {
48− LauncherBackend backend;
49−
50− backend.setStoredApplications(QStringList() << "rel-icon" << "abs-icon");
51− QCOMPARE(backend.isPinned("rel-icon"), false);
52− QCOMPARE(backend.isPinned("abs-icon"), false);
53−
54− backend.setPinned("rel-icon", true);
55− QCOMPARE(backend.isPinned("rel-icon"), true);
56−
57− backend.setStoredApplications(QStringList() << "rel-icon" << "abs-icon" << "no-name");
58− QCOMPARE(backend.isPinned("rel-icon"), true);
59− QCOMPARE(backend.isPinned("no-name"), false);
60−
61− backend.setPinned("no-name", true);
62− backend.setStoredApplications(QStringList() << "rel-icon" << "abs-icon");
63− QCOMPARE(backend.isPinned("rel-icon"), true);
64− QCOMPARE(backend.isPinned("no-name"), false); // doesn't exist anymore!
65− }
66−
6746 void testIcon_data() {
6847 QTest::addColumn<QString>("appId");
6948 QTest::addColumn<QString>("expectedIcon");