My Project
Loading...
Searching...
No Matches
MirSurfaceListInterface.h
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
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; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef LOMIRI_SHELL_APPLICATION_MIRSURFACELISTINTERFACE_H
18#define LOMIRI_SHELL_APPLICATION_MIRSURFACELISTINTERFACE_H
19
20#include <QAbstractListModel>
21
22#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
23Q_MOC_INCLUDE("MirSurfaceInterface.h")
24#endif
25
26namespace lomiri {
27namespace shell {
28namespace application {
29
30class MirSurfaceInterface;
31
35class MirSurfaceListInterface : public QAbstractListModel
36{
37
38 Q_OBJECT
39
45 Q_PROPERTY(int count READ count NOTIFY countChanged)
46
47
53 Q_PROPERTY(lomiri::shell::application::MirSurfaceInterface* first READ first NOTIFY firstChanged)
54public:
60 enum Roles {
61 SurfaceRole = Qt::UserRole,
62 };
63
65 MirSurfaceListInterface(QObject *parent = 0) : QAbstractListModel(parent) {}
66 virtual ~MirSurfaceListInterface() {}
68
73 Q_INVOKABLE virtual MirSurfaceInterface *get(int index) = 0;
74
76 // QAbstractItemModel methods
77 QHash<int, QByteArray> roleNames() const override {
78 QHash<int, QByteArray> roleNames;
79 roleNames.insert(SurfaceRole, "surface");
80 return roleNames;
81 }
82
83 int count() const { return rowCount(); }
84
85 MirSurfaceInterface *first() {
86 if (rowCount() > 0) {
87 return get(0);
88 } else {
89 return nullptr;
90 }
91 }
93
94Q_SIGNALS:
96 void countChanged(int count);
97 void firstChanged();
99};
100
101} // namespace application
102} // namespace shell
103} // namespace lomiri
104
106
107#endif // LOMIRI_SHELL_APPLICATION_MIRSURFACELISTINTERFACE_H
Holds a Mir surface. Pretty much an opaque class.
Definition MirSurfaceInterface.h:46
Interface for a list model of MirSurfaces.
Definition MirSurfaceListInterface.h:36
int count
Number of surfaces in this model.
Definition MirSurfaceListInterface.h:45
virtual Q_INVOKABLE MirSurfaceInterface * get(int index)=0
Returns the surface at the specified index.
Roles
The Roles supported by the model.
Definition MirSurfaceListInterface.h:60
lomiri::shell::application::MirSurfaceInterface * first
The first (index 0) surface in this model.
Definition MirSurfaceListInterface.h:53
Top-level namespace for all things Lomiri-related.
Definition Version.h:38