Changeset View
Changeset View
Standalone View
Standalone View
applets/kicker/plugin/recentusagemodel.cpp
Show All 15 Lines | |||||
16 | * Free Software Foundation, Inc., * | 16 | * Free Software Foundation, Inc., * | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | ||
18 | ***************************************************************************/ | 18 | ***************************************************************************/ | ||
19 | 19 | | |||
20 | #include "recentusagemodel.h" | 20 | #include "recentusagemodel.h" | ||
21 | #include "actionlist.h" | 21 | #include "actionlist.h" | ||
22 | #include "appsmodel.h" | 22 | #include "appsmodel.h" | ||
23 | #include "appentry.h" | 23 | #include "appentry.h" | ||
24 | #include "kastatsfavoritesmodel.h" | | |||
25 | #include <kio_version.h> | 24 | #include <kio_version.h> | ||
26 | 25 | | |||
27 | #include <config-X11.h> | 26 | #include <config-X11.h> | ||
28 | 27 | | |||
29 | #include <QIcon> | 28 | #include <QIcon> | ||
30 | #include <QMimeDatabase> | 29 | #include <QMimeDatabase> | ||
31 | #include <QQmlEngine> | 30 | #include <QQmlEngine> | ||
32 | #include <QTimer> | 31 | #include <QTimer> | ||
Show All 27 Lines | |||||
60 | 59 | | |||
61 | GroupSortProxy::~GroupSortProxy() | 60 | GroupSortProxy::~GroupSortProxy() | ||
62 | { | 61 | { | ||
63 | } | 62 | } | ||
64 | 63 | | |||
65 | InvalidAppsFilterProxy::InvalidAppsFilterProxy(AbstractModel *parentModel, QAbstractItemModel *sourceModel) : QSortFilterProxyModel(parentModel) | 64 | InvalidAppsFilterProxy::InvalidAppsFilterProxy(AbstractModel *parentModel, QAbstractItemModel *sourceModel) : QSortFilterProxyModel(parentModel) | ||
66 | , m_parentModel(parentModel) | 65 | , m_parentModel(parentModel) | ||
67 | { | 66 | { | ||
68 | connect(parentModel, &AbstractModel::favoritesModelChanged, this, &InvalidAppsFilterProxy::connectNewFavoritesModel); | | |||
69 | connectNewFavoritesModel(); | | |||
70 | | ||||
71 | sourceModel->setParent(this); | 67 | sourceModel->setParent(this); | ||
72 | setSourceModel(sourceModel); | 68 | setSourceModel(sourceModel); | ||
73 | } | 69 | } | ||
74 | 70 | | |||
75 | InvalidAppsFilterProxy::~InvalidAppsFilterProxy() | 71 | InvalidAppsFilterProxy::~InvalidAppsFilterProxy() | ||
76 | { | 72 | { | ||
77 | } | 73 | } | ||
78 | 74 | | |||
79 | void InvalidAppsFilterProxy::connectNewFavoritesModel() | | |||
80 | { | | |||
81 | KAStatsFavoritesModel* favoritesModel = static_cast<KAStatsFavoritesModel *>(m_parentModel->favoritesModel()); | | |||
82 | connect(favoritesModel, &KAStatsFavoritesModel::favoritesChanged, this, &QSortFilterProxyModel::invalidate); | | |||
83 | | ||||
84 | invalidate(); | | |||
85 | } | | |||
86 | | ||||
87 | bool InvalidAppsFilterProxy::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const | 75 | bool InvalidAppsFilterProxy::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const | ||
88 | { | 76 | { | ||
89 | Q_UNUSED(source_parent); | 77 | Q_UNUSED(source_parent); | ||
90 | 78 | | |||
91 | const QString resource = sourceModel()->index(source_row, 0).data(ResultModel::ResourceRole).toString(); | 79 | const QString resource = sourceModel()->index(source_row, 0).data(ResultModel::ResourceRole).toString(); | ||
92 | 80 | | |||
93 | if (resource.startsWith(QLatin1String("applications:"))) { | 81 | if (resource.startsWith(QLatin1String("applications:"))) { | ||
94 | KService::Ptr service = KService::serviceByStorageId(resource.section(QLatin1Char(':'), 1)); | 82 | return KService::serviceByStorageId(resource.section(QLatin1Char(':'), 1)); | ||
95 | | ||||
96 | KAStatsFavoritesModel* favoritesModel = m_parentModel ? static_cast<KAStatsFavoritesModel *>(m_parentModel->favoritesModel()) : nullptr; | | |||
97 | | ||||
98 | return (service && (!favoritesModel || !favoritesModel->isFavorite(service->storageId()))); | | |||
davidedmundson: This is doing two things.
1) It's removing any favourite in the history that returns a defunct… | |||||
99 | } | 83 | } | ||
100 | 84 | | |||
101 | return true; | 85 | return true; | ||
102 | } | 86 | } | ||
103 | 87 | | |||
104 | bool InvalidAppsFilterProxy::lessThan(const QModelIndex &left, const QModelIndex &right) const | 88 | bool InvalidAppsFilterProxy::lessThan(const QModelIndex &left, const QModelIndex &right) const | ||
105 | { | 89 | { | ||
106 | return (left.row() < right.row()); | 90 | return (left.row() < right.row()); | ||
▲ Show 20 Lines • Show All 376 Lines • ▼ Show 20 Line(s) | 466 | if (m_usage != OnlyDocs) { | |||
483 | model = new InvalidAppsFilterProxy(this, model); | 467 | model = new InvalidAppsFilterProxy(this, model); | ||
484 | } | 468 | } | ||
485 | 469 | | |||
486 | if (m_usage == AppsAndDocs) { | 470 | if (m_usage == AppsAndDocs) { | ||
487 | model = new GroupSortProxy(this, model); | 471 | model = new GroupSortProxy(this, model); | ||
488 | } | 472 | } | ||
489 | 473 | | |||
490 | setSourceModel(model); | 474 | setSourceModel(model); | ||
491 | } | 475 | } | ||
If this is called before refresh model will be null, and then we don't update m_showAllRecent This needs to be outside the if statement. Or you can simplify the whole thing and just use refresh() davidedmundson: If this is called before refresh model will be null, and then we don't update m_showAllRecent… |
This is doing two things.
We definitely still want 1.
2 definitely makes sense to be optional, even off by default, but simply removing it will change kicker.
Is there a reason to change kicker? If not, it needs to be a property.