on xenial help sign in
remove debug prints
commit216b5d61cd0c8707695cfdaabff41179d6215ddf authorMichael Zanetti <michael.zanetti@canonical.com> dateWed 4 Sep 2013, 11:28 (13 years ago) parent787fcde
2 files changed+19−16
plugins/Unity/Launcher/backend/launcherbackend.cpp+1−11 plugins/Unity/Launcher/launchermodel.cpp+18−5
plugins/Unity/Launcher/backend/launcherbackend.cpp+1−11
@@ -82,7 +82,7 @@ void LauncherBackend::setStoredApplications(const QStringList &appIds)
8282 m_itemCache.insert(appId, item);
8383 } else {
8484 // Cannot find any data for that app... ignoring it.
85− qDebug() << "cannot find desktop file for" << appId << ". discarding app";
85+ qWarning() << "cannot find desktop file for" << appId << ". discarding app.";
8686 m_storedApps.removeAll(appId);
8787 }
8888 }
@@ -213,16 +213,12 @@ void LauncherBackend::syncFromAccounts()
213213
214214 m_storedApps.clear();
215215
216− qDebug() << "syncing from accounts" << m_accounts << m_user;
217−
218216 if (m_accounts && !m_user.isEmpty()) {
219217 QVariant variant = m_accounts->getUserProperty(m_user, "launcher-items");
220218 apps = qdbus_cast<QList<QVariantMap>>(variant.value<QDBusArgument>());
221219 defaults = isDefaultsItem(apps);
222220 }
223221
224− qDebug() << "--------------------- should load defaults?" << defaults;
225−
226222 if (m_accounts && defaults) { // Checking accounts as it'll be null when !useStorage
227223 QGSettings gSettings("com.canonical.Unity.Launcher", "/com/canonical/unity/launcher/");
228224 Q_FOREACH(const QString &entry, gSettings.get("favorites").toStringList()) {
@@ -243,7 +239,6 @@ void LauncherBackend::syncFromAccounts()
243239 }
244240 } else {
245241 for (const QVariant &app: apps) {
246− qDebug() << "should load app" << app;
247242 loadFromVariant(app.toMap());
248243 }
249244 }
@@ -251,19 +246,15 @@ void LauncherBackend::syncFromAccounts()
251246
252247void LauncherBackend::syncToAccounts()
253248{
254− qDebug() << "syncing to accounts" << m_accounts << m_user << m_storedApps;
255249 if (m_accounts && !m_user.isEmpty()) {
256250 QList<QVariantMap> items;
257251
258252 Q_FOREACH(const QString &appId, m_storedApps) {
259− qDebug() << "appending item" << appId;
260253 items << itemToVariant(appId);
261254 }
262255
263− qDebug() << "syncing apps" << items;
264256 m_accounts->setUserProperty(m_user, "launcher-items", QVariant::fromValue(items));
265257 }
266− qDebug() << "done synving";
267258}
268259
269260QString LauncherBackend::findDesktopFile(const QString &appId) const
@@ -340,6 +331,5 @@ bool LauncherBackend::isDefaultsItem(const QList<QVariantMap> &apps) const
340331 // To differentiate between an empty list and a list that hasn't been set
341332 // yet (and should thus be populated with the defaults), we use a special
342333 // list of one item with the 'defaults' field set to true.
343− qDebug() << "checking isDefaults" << apps;
344334 return (apps.size() == 1 && apps[0].value("defaults").toBool());
345335}
plugins/Unity/Launcher/launchermodel.cpp+18−5
@@ -21,8 +21,6 @@
2121#include "launcheritem.h"
2222#include "backend/launcherbackend.h"
2323
24−#include <QDebug>
25−
2624LauncherModel::LauncherModel(QObject *parent):
2725 LauncherModelInterface(parent),
2826 m_backend(new LauncherBackend(true, this))
@@ -200,6 +198,8 @@ void LauncherModel::applicationFocused(const QString &appId)
200198 if (index >= 0) {
201199 // TODO: Mark application as focued
202200 } else {
201+ // Add app to recent apps
202+
203203 // FIXME: The backend does not yet support this stuff
204204 // and currently the appId still is the desktopFile
205205 //QString desktopFile = m_backend->desktopFile(appId);
@@ -213,6 +213,22 @@ void LauncherModel::applicationFocused(const QString &appId)
213213 beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
214214 m_list.append(item);
215215 endInsertRows();
216+
217+ // Clean up old recent apps
218+ QList<int> recentAppIndices;
219+ for (int i = 0; i < m_list.count(); ++i) {
220+ if (m_list.at(i)->recent()) {
221+ recentAppIndices << i;
222+ }
223+ }
224+ int run = 0;
225+ while (recentAppIndices.count() > 5) {
226+ beginRemoveRows(QModelIndex(), recentAppIndices.first() - run, recentAppIndices.first() - run);
227+ m_list.takeAt(recentAppIndices.first() - run)->deleteLater();
228+ endRemoveRows();
229+ recentAppIndices.takeFirst();
230+ ++run;
231+ }
216232 storeAppList();
217233 }
218234}
@@ -221,13 +237,10 @@ void LauncherModel::storeAppList()
221237{
222238 QStringList appIds;
223239 Q_FOREACH(LauncherItem *item, m_list) {
224− qDebug() << "shouldI store app" << item->appId();
225240 if (item->pinned() || item->recent()) {
226− qDebug() << "yes";
227241 appIds << item->appId();
228242 }
229243 }
230− qDebug() << "storing appids" << appIds;
231244 m_backend->setStoredApplications(appIds);
232245}
233246