diff --git a/applets/kicker/plugin/recentusagemodel.h b/applets/kicker/plugin/recentusagemodel.h --- a/applets/kicker/plugin/recentusagemodel.h +++ b/applets/kicker/plugin/recentusagemodel.h @@ -40,28 +40,37 @@ class InvalidAppsFilterProxy : public QSortFilterProxyModel { Q_OBJECT + /* current kicker filters out recent apps that are also favorites, set this to true to bypass that */ + Q_PROPERTY(bool showAllRecents READ showAllRecents WRITE setShowAllRecents NOTIFY showAllRecentsChanged) public: explicit InvalidAppsFilterProxy(AbstractModel *parentModel, QAbstractItemModel *sourceModel); ~InvalidAppsFilterProxy() override; + bool showAllRecents() const; + void setShowAllRecents(bool showAll); protected: bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const override; bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; + Q_SIGNALS: + void showAllRecentsChanged(bool showAll); + private Q_SLOTS: void connectNewFavoritesModel(); private: QPointer m_parentModel; + bool m_showAllRecents; }; class RecentUsageModel : public ForwardingModel, public QQmlParserStatus { Q_OBJECT Q_INTERFACES(QQmlParserStatus) Q_PROPERTY(int ordering READ ordering WRITE setOrdering NOTIFY orderingChanged) + Q_PROPERTY(bool showAllRecents READ showAllRecents WRITE setShowAllRecents NOTIFY showAllRecentsChanged) public: enum IncludeUsage { AppsAndDocs, OnlyApps, OnlyDocs }; @@ -89,9 +98,12 @@ void classBegin() override; void componentComplete() override; + bool showAllRecents() const; + void setShowAllRecents(bool showAll); Q_SIGNALS: void orderingChanged(int ordering); + void showAllRecentsChanged(bool showAll); private Q_SLOTS: void refresh() override; @@ -110,6 +122,7 @@ Ordering m_ordering; bool m_complete; + bool m_showAllRecents; }; #endif diff --git a/applets/kicker/plugin/recentusagemodel.cpp b/applets/kicker/plugin/recentusagemodel.cpp --- a/applets/kicker/plugin/recentusagemodel.cpp +++ b/applets/kicker/plugin/recentusagemodel.cpp @@ -64,6 +64,7 @@ InvalidAppsFilterProxy::InvalidAppsFilterProxy(AbstractModel *parentModel, QAbstractItemModel *sourceModel) : QSortFilterProxyModel(parentModel) , m_parentModel(parentModel) +, m_showAllRecents(false) { connect(parentModel, &AbstractModel::favoritesModelChanged, this, &InvalidAppsFilterProxy::connectNewFavoritesModel); connectNewFavoritesModel(); @@ -76,6 +77,20 @@ { } +bool InvalidAppsFilterProxy::showAllRecents() const +{ + return m_showAllRecents; +} + +void InvalidAppsFilterProxy::setShowAllRecents(bool showAllRecents) +{ + if (m_showAllRecents != showAllRecents) { + m_showAllRecents = showAllRecents; + Q_EMIT showAllRecentsChanged(showAllRecents); + invalidate(); + } +} + void InvalidAppsFilterProxy::connectNewFavoritesModel() { KAStatsFavoritesModel* favoritesModel = static_cast(m_parentModel->favoritesModel()); @@ -94,6 +109,9 @@ KService::Ptr service = KService::serviceByStorageId(resource.section(QLatin1Char(':'), 1)); KAStatsFavoritesModel* favoritesModel = m_parentModel ? static_cast(m_parentModel->favoritesModel()) : nullptr; + if (m_showAllRecents) { + return service; + } return (service && (!favoritesModel || !favoritesModel->isFavorite(service->storageId()))); } @@ -127,6 +145,7 @@ , m_usage(usage) , m_ordering((Ordering)ordering) , m_complete(false) +, m_showAllRecents(false) { refresh(); } @@ -480,12 +499,29 @@ } if (m_usage != OnlyDocs) { - model = new InvalidAppsFilterProxy(this, model); + auto* invalidAppsFilterModel = new InvalidAppsFilterProxy(this, model); + invalidAppsFilterModel->setShowAllRecents(m_showAllRecents); } if (m_usage == AppsAndDocs) { model = new GroupSortProxy(this, model); } setSourceModel(model); } + +bool RecentUsageModel::showAllRecents() const +{ + return m_showAllRecents; +} + +void RecentUsageModel::setShowAllRecents(bool recents) +{ + if (m_showAllRecents != recents) { + if (auto model = qobject_cast(sourceModel())) { + model->setShowAllRecents(m_showAllRecents); + m_showAllRecents = recents; + Q_EMIT showAllRecentsChanged(recents); + } + } +}