Changeset View
Changeset View
Standalone View
Standalone View
applets/kicker/plugin/kastatsfavoritesmodel.cpp
Show All 22 Lines | |||||
23 | #include "contactentry.h" | 23 | #include "contactentry.h" | ||
24 | #include "fileentry.h" | 24 | #include "fileentry.h" | ||
25 | #include "actionlist.h" | 25 | #include "actionlist.h" | ||
26 | #include "debug.h" | 26 | #include "debug.h" | ||
27 | 27 | | |||
28 | #include <QFileInfo> | 28 | #include <QFileInfo> | ||
29 | #include <QTimer> | 29 | #include <QTimer> | ||
30 | #include <QSortFilterProxyModel> | 30 | #include <QSortFilterProxyModel> | ||
31 | #include <QDir> | ||||
31 | 32 | | |||
32 | #include <KLocalizedString> | 33 | #include <KLocalizedString> | ||
33 | #include <KSharedConfig> | 34 | #include <KSharedConfig> | ||
34 | #include <KConfigGroup> | 35 | #include <KConfigGroup> | ||
35 | 36 | | |||
36 | #include <KActivities/Consumer> | 37 | #include <KActivities/Consumer> | ||
37 | #include <KActivities/Stats/Terms> | 38 | #include <KActivities/Stats/Terms> | ||
38 | #include <KActivities/Stats/Query> | 39 | #include <KActivities/Stats/Query> | ||
▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Line(s) | 152 | { | |||
153 | 154 | | |||
154 | const auto agent = | 155 | const auto agent = | ||
155 | agentForUrl(resource); | 156 | agentForUrl(resource); | ||
156 | 157 | | |||
157 | if (agent == AGENT_CONTACTS) { | 158 | if (agent == AGENT_CONTACTS) { | ||
158 | return SP(new ContactEntry(q, resource)); | 159 | return SP(new ContactEntry(q, resource)); | ||
159 | 160 | | |||
160 | } else if (agent == AGENT_DOCUMENTS) { | 161 | } else if (agent == AGENT_DOCUMENTS) { | ||
161 | if (resource.startsWith(QLatin1String("/"))) { | 162 | if (QDir::isAbsolutePath(resource)) { | ||
162 | return SP(new FileEntry(q, QUrl::fromLocalFile(resource))); | 163 | return SP(new FileEntry(q, QUrl::fromLocalFile(resource))); | ||
163 | } else { | 164 | } else { | ||
164 | return SP(new FileEntry(q, QUrl(resource))); | 165 | return SP(new FileEntry(q, QUrl(resource))); | ||
165 | } | 166 | } | ||
166 | 167 | | |||
167 | } else if (agent == AGENT_APPLICATIONS) { | 168 | } else if (agent == AGENT_APPLICATIONS) { | ||
168 | if (resource.startsWith(QLatin1String("applications:"))) { | 169 | if (resource.startsWith(QLatin1String("applications:"))) { | ||
169 | return SP(new AppEntry(q, resource.mid(13))); | 170 | return SP(new AppEntry(q, resource.mid(13))); | ||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Line(s) | 264 | std::transform(m_items.cbegin(), m_items.cend(), itemStrings.begin(), | |||
266 | }); | 267 | }); | ||
267 | qCDebug(KICKER_DEBUG) << "After ordering: " << itemStrings; | 268 | qCDebug(KICKER_DEBUG) << "After ordering: " << itemStrings; | ||
268 | } | 269 | } | ||
269 | 270 | | |||
270 | void addResult(const QString &_resource, int index, bool notifyModel = true) | 271 | void addResult(const QString &_resource, int index, bool notifyModel = true) | ||
271 | { | 272 | { | ||
272 | // We want even files to have a proper URL | 273 | // We want even files to have a proper URL | ||
273 | const auto resource = | 274 | const auto resource = | ||
274 | _resource.startsWith(QLatin1Char('/')) ? QUrl::fromLocalFile(_resource).toString() : _resource; | 275 | QDir::isAbsolutePath(_resource) ? QUrl::fromLocalFile(_resource).toString() : _resource; | ||
275 | 276 | | |||
276 | qCDebug(KICKER_DEBUG) << "Adding result" << resource << "already present?" << m_itemEntries.contains(resource); | 277 | qCDebug(KICKER_DEBUG) << "Adding result" << resource << "already present?" << m_itemEntries.contains(resource); | ||
277 | 278 | | |||
278 | if (m_itemEntries.contains(resource)) return; | 279 | if (m_itemEntries.contains(resource)) return; | ||
279 | 280 | | |||
280 | auto entry = entryForResource(resource); | 281 | auto entry = entryForResource(resource); | ||
281 | 282 | | |||
282 | if (!entry || !entry->isValid()) { | 283 | if (!entry || !entry->isValid()) { | ||
▲ Show 20 Lines • Show All 437 Lines • Show Last 20 Lines |