@@ -133,16 +133,9 @@ QString LauncherBackend::displayName(const QString &appId) const
133QString LauncherBackend::icon(const QString &appId) const
133QString LauncherBackend::icon(const QString &appId) const
135 QString iconName;
135 QString iconName;
136− LauncherBackendItem *item = m_itemCache.value(appId);
136+ LauncherBackendItem *item = getItem(appId);
137 if (item) {
137 if (item) {
138 iconName = item->icon;
138 iconName = item->icon;
140− QString df = findDesktopFile(appId);
141− if (!df.isEmpty()) {
142− LauncherBackendItem *item = parseDesktopFile(df);
143− m_itemCache.insert(appId, item);
144− iconName = item->icon;
148 return iconName;
141 return iconName;
@@ -169,14 +162,7 @@ int LauncherBackend::progress(const QString &appId) const
169int LauncherBackend::count(const QString &appId) const
162int LauncherBackend::count(const QString &appId) const
171 int count = -1;
164 int count = -1;
172− LauncherBackendItem *item = m_itemCache.value(appId);
165+ LauncherBackendItem *item = getItem(appId);
174− QString df = findDesktopFile(appId);
175− if (!df.isEmpty()) {
176− item = parseDesktopFile(df);
177− m_itemCache.insert(appId, item);
181 if (!item) {
167 if (!item) {
182 if (item->countVisible) {
168 if (item->countVisible) {
@@ -189,14 +175,7 @@ int LauncherBackend::count(const QString &appId) const
190void LauncherBackend::setCount(const QString &appId, int count) const
176void LauncherBackend::setCount(const QString &appId, int count) const
192− LauncherBackendItem *item = m_itemCache.value(appId);
178+ LauncherBackendItem *item = getItem(appId);
194− QString df = findDesktopFile(appId);
195− if (!df.isEmpty()) {
196− item = parseDesktopFile(df);
197− m_itemCache.insert(appId, item);
201 bool emitchange = false;
180 bool emitchange = false;
202 if (!item) {
181 if (!item) {
@@ -217,14 +196,7 @@ void LauncherBackend::setCount(const QString &appId, int count) const
217bool LauncherBackend::countVisible(const QString &appId) const
196bool LauncherBackend::countVisible(const QString &appId) const
219 bool visible = false;
198 bool visible = false;
220− LauncherBackendItem *item = m_itemCache.value(appId);
199+ LauncherBackendItem *item = getItem(appId);
222− QString df = findDesktopFile(appId);
223− if (!df.isEmpty()) {
224− item = parseDesktopFile(df);
225− m_itemCache.insert(appId, item);
229 if (!item) {
201 if (!item) {
230 visible = item->countVisible;
202 visible = item->countVisible;
@@ -235,20 +207,13 @@ bool LauncherBackend::countVisible(const QString &appId) const
236void LauncherBackend::setCountVisible(const QString &appId, bool visible) const
208void LauncherBackend::setCountVisible(const QString &appId, bool visible) const
238− LauncherBackendItem *item = m_itemCache.value(appId);
210+ LauncherBackendItem *item = getItem(appId);
240− QString df = findDesktopFile(appId);
241− if (!df.isEmpty()) {
242− item = parseDesktopFile(df);
243− m_itemCache.insert(appId, item);
247 bool emitchange = false;
212 bool emitchange = false;
248 if (!item) {
213 if (!item) {
249 emitchange = (item->countVisible != visible);
214 emitchange = (item->countVisible != visible);
250 item->countVisible = visible;
215 item->countVisible = visible;
253 if (emitchange) {
218 if (emitchange) {
254 /* TODO: Because we're using visible in determining the
219 /* TODO: Because we're using visible in determining the
@@ -384,6 +349,23 @@ LauncherBackendItem* LauncherBackend::parseDesktopFile(const QString &desktopFil
384 return item;
349 return item;
352+/* Gets an item, and tries to create a new one if we need it to */
353+LauncherBackendItem* LauncherBackend::getItem (const QString &appId) const
355+ LauncherBackendItem *item = m_itemCache.value(appId);
357+ QString df = findDesktopFile(appId);
358+ if (!df.isEmpty()) {
359+ item = parseDesktopFile(df);
361+ m_itemCache.insert(appId, item);
387void LauncherBackend::loadFromVariant(const QVariantMap &details)
369void LauncherBackend::loadFromVariant(const QVariantMap &details)
389 if (!details.contains("id")) {
371 if (!details.contains("id")) {