Changeset View
Changeset View
Standalone View
Standalone View
applets/kicker/plugin/computermodel.h.orig
- This file was added.
1 | /*************************************************************************** | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2015 by Eike Hein <hein@kde.org> * | ||||
3 | * * | ||||
4 | * This program is free software; you can redistribute it and/or modify * | ||||
5 | * it under the terms of the GNU General Public License as published by * | ||||
6 | * the Free Software Foundation; either version 2 of the License, or * | ||||
7 | * (at your option) any later version. * | ||||
8 | * * | ||||
9 | * This program is distributed in the hope that it will be useful, * | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||||
12 | * GNU General Public License for more details. * | ||||
13 | * * | ||||
14 | * You should have received a copy of the GNU General Public License * | ||||
15 | * along with this program; if not, write to the * | ||||
16 | * Free Software Foundation, Inc., * | ||||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | ||||
18 | ***************************************************************************/ | ||||
19 | | ||||
20 | #ifndef COMPUTERMODEL_H | ||||
21 | #define COMPUTERMODEL_H | ||||
22 | | ||||
23 | #include "forwardingmodel.h" | ||||
24 | #include "appentry.h" | ||||
25 | | ||||
26 | #include <QSortFilterProxyModel> | ||||
27 | #include <Solid/StorageAccess> | ||||
28 | | ||||
29 | class FavoritesModel; | ||||
30 | | ||||
31 | class KConcatenateRowsProxyModel; | ||||
32 | class KFilePlacesModel; | ||||
33 | | ||||
34 | namespace Solid { | ||||
35 | class Device; | ||||
36 | } | ||||
37 | | ||||
38 | class FilteredPlacesModel : public QSortFilterProxyModel | ||||
39 | { | ||||
40 | Q_OBJECT | ||||
41 | | ||||
42 | public: | ||||
43 | FilteredPlacesModel(QObject *parent = 0); | ||||
44 | ~FilteredPlacesModel(); | ||||
45 | | ||||
46 | QUrl url(const QModelIndex &index) const; | ||||
47 | bool isDevice(const QModelIndex &index) const; | ||||
48 | Solid::Device deviceForIndex(const QModelIndex &index) const; | ||||
49 | | ||||
50 | protected: | ||||
51 | bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const Q_DECL_OVERRIDE; | ||||
52 | bool lessThan(const QModelIndex &left, const QModelIndex &right) const Q_DECL_OVERRIDE; | ||||
53 | | ||||
54 | private: | ||||
55 | KFilePlacesModel *m_placesModel; | ||||
56 | }; | ||||
57 | | ||||
58 | class RunCommandModel : public AbstractModel | ||||
59 | { | ||||
60 | Q_OBJECT | ||||
61 | | ||||
62 | public: | ||||
63 | RunCommandModel(QObject *parent = 0); | ||||
64 | ~RunCommandModel(); | ||||
65 | | ||||
66 | QString description() const Q_DECL_OVERRIDE; | ||||
67 | | ||||
68 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; | ||||
69 | | ||||
70 | int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE; | ||||
71 | | ||||
72 | Q_INVOKABLE bool trigger(int row, const QString &actionId, const QVariant &argument) Q_DECL_OVERRIDE; | ||||
73 | }; | ||||
74 | | ||||
75 | class ComputerModel : public ForwardingModel | ||||
76 | { | ||||
77 | Q_OBJECT | ||||
78 | | ||||
79 | Q_PROPERTY(int appNameFormat READ appNameFormat WRITE setAppNameFormat NOTIFY appNameFormatChanged) | ||||
80 | Q_PROPERTY(QObject* appletInterface READ appletInterface WRITE setAppletInterface NOTIFY appletInterfaceChanged) | ||||
81 | Q_PROPERTY(QStringList systemApplications READ systemApplications WRITE setSystemApplications NOTIFY systemApplicationsChanged) | ||||
82 | | ||||
83 | public: | ||||
84 | explicit ComputerModel(QObject *parent = 0); | ||||
85 | ~ComputerModel(); | ||||
86 | | ||||
87 | QString description() const Q_DECL_OVERRIDE; | ||||
88 | | ||||
89 | int appNameFormat() const; | ||||
90 | void setAppNameFormat(int format); | ||||
91 | | ||||
92 | QObject *appletInterface() const; | ||||
93 | void setAppletInterface(QObject *appletInterface); | ||||
94 | | ||||
95 | QStringList systemApplications() const; | ||||
96 | void setSystemApplications(const QStringList &apps); | ||||
97 | | ||||
98 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE; | ||||
99 | | ||||
100 | Q_INVOKABLE bool trigger(int row, const QString &actionId, const QVariant &argument) Q_DECL_OVERRIDE; | ||||
101 | | ||||
102 | Q_SIGNALS: | ||||
103 | void appNameFormatChanged() const; | ||||
104 | void appletInterfaceChanged() const; | ||||
105 | void systemApplicationsChanged() const; | ||||
106 | | ||||
107 | private Q_SLOTS: | ||||
108 | void onSetupDone(Solid::ErrorType error, QVariant errorData, const QString &udi); | ||||
109 | | ||||
110 | private: | ||||
111 | KConcatenateRowsProxyModel *m_concatProxy; | ||||
112 | RunCommandModel *m_runCommandModel; | ||||
113 | FavoritesModel *m_systemAppsModel; | ||||
114 | FilteredPlacesModel *m_filteredPlacesModel; | ||||
115 | AppEntry::NameFormat m_appNameFormat; | ||||
116 | QObject *m_appletInterface; | ||||
117 | }; | ||||
118 | | ||||
119 | #endif |