Changeset View
Changeset View
Standalone View
Standalone View
applets/pager/plugin/pagermodel.h
- This file was added.
1 | /******************************************************************** | ||||
---|---|---|---|---|---|
2 | Copyright 2016 Eike Hein <hein.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 PAGERMODEL_H | ||||
21 | #define PAGERMODEL_H | ||||
22 | | ||||
23 | #include <config-X11.h> | ||||
24 | | ||||
25 | #if HAVE_X11 | ||||
26 | #include <netwm.h> | ||||
27 | #include <QX11Info> | ||||
28 | #endif | ||||
29 | | ||||
30 | #include <QAbstractListModel> | ||||
31 | | ||||
32 | class QMimeData; | ||||
33 | | ||||
34 | class PagerModel : public QAbstractListModel | ||||
35 | { | ||||
36 | Q_OBJECT | ||||
37 | | ||||
38 | Q_ENUMS(PagerType) | ||||
39 | Q_ENUMS(AdditionalRoles) | ||||
40 | | ||||
41 | Q_PROPERTY(int count READ rowCount NOTIFY countChanged) | ||||
42 | Q_PROPERTY(PagerType pagerType READ pagerType WRITE setPagerType NOTIFY pagerTypeChanged) | ||||
43 | Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) | ||||
44 | Q_PROPERTY(bool showDesktop READ showDesktop WRITE setShowDesktop NOTIFY showDesktopChanged) | ||||
45 | Q_PROPERTY(int currentPage READ currentPage NOTIFY currentPageChanged) | ||||
46 | Q_PROPERTY(int layoutRows READ layoutRows NOTIFY layoutRowsChanged) | ||||
47 | Q_PROPERTY(QSize pagerItemSize READ pagerItemSize NOTIFY pagerItemSizeChanged) | ||||
48 | | ||||
49 | public: | ||||
50 | enum PagerType { | ||||
51 | VirtualDesktops = 0, | ||||
52 | Activities | ||||
53 | }; | ||||
54 | | ||||
55 | enum AdditionalRoles { | ||||
56 | TasksModel = Qt::UserRole + 1 | ||||
57 | }; | ||||
58 | | ||||
59 | explicit PagerModel(QObject *parent = nullptr); | ||||
60 | virtual ~PagerModel(); | ||||
61 | | ||||
62 | QHash<int, QByteArray> roleNames() const override; | ||||
63 | | ||||
64 | int rowCount(const QModelIndex &parent = QModelIndex()) const override; | ||||
65 | | ||||
66 | QVariant data(const QModelIndex &index, int role) const override; | ||||
67 | | ||||
68 | PagerType pagerType() const; | ||||
69 | void setPagerType(PagerType type); | ||||
70 | | ||||
71 | bool enabled() const; | ||||
72 | void setEnabled(bool enabled); | ||||
73 | | ||||
74 | bool showDesktop() const; | ||||
75 | void setShowDesktop(bool show); | ||||
76 | | ||||
77 | int currentPage() const; | ||||
78 | | ||||
79 | int layoutRows() const; | ||||
80 | QSize pagerItemSize() const; | ||||
81 | | ||||
82 | #if HAVE_X11 | ||||
83 | QList<WId> stackingOrder() const; | ||||
84 | #endif | ||||
85 | | ||||
86 | Q_INVOKABLE void refresh(); | ||||
87 | | ||||
88 | Q_INVOKABLE void moveWindow(int window, double x, double y, int targetItemId, int sourceItemId, | ||||
89 | qreal widthScaleFactor, qreal heightScaleFactor); | ||||
90 | Q_INVOKABLE void changePage(int itemId); | ||||
91 | Q_INVOKABLE void drop(QMimeData *mimeData, int itemId); | ||||
92 | Q_INVOKABLE void addDesktop(); | ||||
93 | Q_INVOKABLE void removeDesktop(); | ||||
94 | | ||||
95 | Q_SIGNALS: | ||||
96 | void countChanged() const; | ||||
97 | void pagerTypeChanged() const; | ||||
98 | void enabledChanged() const; | ||||
99 | void showDesktopChanged() const; | ||||
100 | void currentPageChanged() const; | ||||
101 | void layoutRowsChanged() const; | ||||
102 | void pagerItemSizeChanged() const; | ||||
103 | | ||||
104 | private: | ||||
105 | class Private; | ||||
106 | QScopedPointer<Private> d; | ||||
107 | }; | ||||
108 | | ||||
109 | #endif |