File indexing completed on 2024-05-26 05:38:26
0001 /* 0002 SPDX-FileCopyrightText: 2014-2015 Eike Hein <hein@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "appsmodel.h" 0010 0011 class KAStatsFavoritesModel; 0012 class RecentUsageModel; 0013 class SystemModel; 0014 0015 class RootModel; 0016 0017 class GroupEntry : public AbstractGroupEntry 0018 { 0019 public: 0020 GroupEntry(AppsModel *parentModel, const QString &name, const QString &iconName, AbstractModel *childModel); 0021 0022 QString icon() const override; 0023 QString name() const override; 0024 0025 bool hasChildren() const override; 0026 AbstractModel *childModel() const override; 0027 0028 private: 0029 QString m_name; 0030 QString m_iconName; 0031 QPointer<AbstractModel> m_childModel; 0032 }; 0033 0034 class RootModel : public AppsModel 0035 { 0036 Q_OBJECT 0037 0038 Q_PROPERTY(QObject *systemFavoritesModel READ systemFavoritesModel NOTIFY systemFavoritesModelChanged) 0039 Q_PROPERTY(bool showAllApps READ showAllApps WRITE setShowAllApps NOTIFY showAllAppsChanged) 0040 Q_PROPERTY(bool showAllAppsCategorized READ showAllAppsCategorized WRITE setShowAllAppsCategorized NOTIFY showAllAppsCategorizedChanged) 0041 Q_PROPERTY(bool showRecentApps READ showRecentApps WRITE setShowRecentApps NOTIFY showRecentAppsChanged) 0042 Q_PROPERTY(bool showRecentDocs READ showRecentDocs WRITE setShowRecentDocs NOTIFY showRecentDocsChanged) 0043 Q_PROPERTY(int recentOrdering READ recentOrdering WRITE setRecentOrdering NOTIFY recentOrderingChanged) 0044 Q_PROPERTY(bool showPowerSession READ showPowerSession WRITE setShowPowerSession NOTIFY showPowerSessionChanged) 0045 Q_PROPERTY(bool showFavoritesPlaceholder READ showFavoritesPlaceholder WRITE setShowFavoritesPlaceholder NOTIFY showFavoritesPlaceholderChanged) 0046 0047 public: 0048 explicit RootModel(QObject *parent = nullptr); 0049 ~RootModel() override; 0050 0051 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0052 0053 Q_INVOKABLE bool trigger(int row, const QString &actionId, const QVariant &argument) override; 0054 0055 bool showAllApps() const; 0056 void setShowAllApps(bool show); 0057 0058 bool showAllAppsCategorized() const; 0059 void setShowAllAppsCategorized(bool showCategorized); 0060 0061 bool showRecentApps() const; 0062 void setShowRecentApps(bool show); 0063 0064 bool showRecentDocs() const; 0065 void setShowRecentDocs(bool show); 0066 0067 int recentOrdering() const; 0068 void setRecentOrdering(int ordering); 0069 0070 bool showPowerSession() const; 0071 void setShowPowerSession(bool show); 0072 0073 bool showFavoritesPlaceholder() const; 0074 void setShowFavoritesPlaceholder(bool show); 0075 0076 AbstractModel *favoritesModel() override; 0077 AbstractModel *systemFavoritesModel(); 0078 0079 Q_SIGNALS: 0080 void refreshed() const; 0081 void systemFavoritesModelChanged() const; 0082 void showAllAppsChanged() const; 0083 void showAllAppsCategorizedChanged() const; 0084 void showRecentAppsChanged() const; 0085 void showRecentDocsChanged() const; 0086 void showPowerSessionChanged() const; 0087 void recentOrderingChanged() const; 0088 void recentAppsModelChanged() const; 0089 void showFavoritesPlaceholderChanged() const; 0090 0091 protected Q_SLOTS: 0092 void refresh() override; 0093 0094 private: 0095 KAStatsFavoritesModel *m_favorites; 0096 SystemModel *m_systemModel; 0097 0098 bool m_showAllApps; 0099 bool m_showAllAppsCategorized; 0100 bool m_showRecentApps; 0101 bool m_showRecentDocs; 0102 int m_recentOrdering; 0103 bool m_showPowerSession; 0104 bool m_showFavoritesPlaceholder; 0105 0106 RecentUsageModel *m_recentAppsModel; 0107 RecentUsageModel *m_recentDocsModel; 0108 };