Changeset View
Changeset View
Standalone View
Standalone View
applets/kicker/plugin/recentusagemodel.cpp
Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Line(s) | 100 | { | |||
---|---|---|---|---|---|
107 | } else if (!lResource.startsWith(QLatin1String("applications:")) | 107 | } else if (!lResource.startsWith(QLatin1String("applications:")) | ||
108 | && rResource.startsWith(QLatin1String("applications:"))) { | 108 | && rResource.startsWith(QLatin1String("applications:"))) { | ||
109 | return false; | 109 | return false; | ||
110 | } | 110 | } | ||
111 | 111 | | |||
112 | return (left.row() < right.row()); | 112 | return (left.row() < right.row()); | ||
113 | } | 113 | } | ||
114 | 114 | | |||
115 | RecentUsageModel::RecentUsageModel(QObject *parent, IncludeUsage usage) : ForwardingModel(parent) | 115 | RecentUsageModel::RecentUsageModel(QObject *parent, IncludeUsage usage, int ordering) | ||
116 | : ForwardingModel(parent) | ||||
116 | , m_usage(usage) | 117 | , m_usage(usage) | ||
118 | , m_ordering((Ordering)ordering) | ||||
117 | { | 119 | { | ||
118 | refresh(); | 120 | refresh(); | ||
119 | } | 121 | } | ||
120 | 122 | | |||
121 | RecentUsageModel::~RecentUsageModel() | 123 | RecentUsageModel::~RecentUsageModel() | ||
122 | { | 124 | { | ||
123 | } | 125 | } | ||
124 | 126 | | |||
▲ Show 20 Lines • Show All 248 Lines • ▼ Show 20 Line(s) | 372 | switch (m_usage) { | |||
373 | case OnlyApps: | 375 | case OnlyApps: | ||
374 | return i18n("Forget All Applications"); | 376 | return i18n("Forget All Applications"); | ||
375 | case OnlyDocs: | 377 | case OnlyDocs: | ||
376 | default: | 378 | default: | ||
377 | return i18n("Forget All Documents"); | 379 | return i18n("Forget All Documents"); | ||
378 | } | 380 | } | ||
379 | } | 381 | } | ||
380 | 382 | | |||
383 | void RecentUsageModel::setOrdering(int ordering) | ||||
384 | { | ||||
385 | if (ordering == m_ordering) return; | ||||
386 | | ||||
387 | m_ordering = (Ordering)ordering; | ||||
388 | refresh(); | ||||
389 | | ||||
390 | emit orderingChanged(ordering); | ||||
391 | } | ||||
392 | | ||||
393 | int RecentUsageModel::ordering() const | ||||
394 | { | ||||
395 | return m_ordering; | ||||
396 | } | ||||
397 | | ||||
381 | void RecentUsageModel::refresh() | 398 | void RecentUsageModel::refresh() | ||
382 | { | 399 | { | ||
383 | QAbstractItemModel *oldModel = sourceModel(); | 400 | QAbstractItemModel *oldModel = sourceModel(); | ||
384 | 401 | | |||
385 | auto query = UsedResources | 402 | auto query = UsedResources | ||
386 | | RecentlyUsedFirst | 403 | | (m_ordering == Recent ? RecentlyUsedFirst : HighScoredFirst) | ||
387 | | Agent::any() | 404 | | Agent::any() | ||
388 | | Type::any() | 405 | | Type::any() | ||
389 | | Activity::current(); | 406 | | Activity::current(); | ||
390 | 407 | | |||
391 | switch (m_usage) { | 408 | switch (m_usage) { | ||
392 | case AppsAndDocs: | 409 | case AppsAndDocs: | ||
393 | { | 410 | { | ||
394 | query = query | Url::startsWith("applications:") | Url::file() | Limit(30); | 411 | query = query | Url::startsWith("applications:") | Url::file() | Limit(30); | ||
Show All 35 Lines |