Loading...
Searching...
No Matches
MirSurfaceListInterface.h
/*
* Copyright (C) 2016 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LOMIRI_SHELL_APPLICATION_MIRSURFACELISTINTERFACE_H
#define LOMIRI_SHELL_APPLICATION_MIRSURFACELISTINTERFACE_H
#include <QAbstractListModel>
namespace lomiri {
namespace shell {
namespace application {
class MirSurfaceInterface;
class MirSurfaceListInterface : public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_PROPERTY(lomiri::shell::application::MirSurfaceInterface* first READ first NOTIFY firstChanged)
public:
enum Roles {
SurfaceRole = Qt::UserRole,
};
MirSurfaceListInterface(QObject *parent = 0) : QAbstractListModel(parent) {}
virtual ~MirSurfaceListInterface() {}
Q_INVOKABLE virtual MirSurfaceInterface *get(int index) = 0;
// QAbstractItemModel methods
QHash<int, QByteArray> roleNames() const override {
QHash<int, QByteArray> roleNames;
roleNames.insert(SurfaceRole, "surface");
return roleNames;
}
int count() const { return rowCount(); }
MirSurfaceInterface *first() {
if (rowCount() > 0) {
return get(0);
} else {
return nullptr;
}
}
Q_SIGNALS:
void countChanged(int count);
void firstChanged();
};
} // namespace application
} // namespace shell
} // namespace lomiri
Q_DECLARE_METATYPE(lomiri::shell::application::MirSurfaceListInterface*)
#endif // LOMIRI_SHELL_APPLICATION_MIRSURFACELISTINTERFACE_H
lomiri::shell::application::MirSurfaceInterface
Holds a Mir surface. Pretty much an opaque class.
Definition MirSurfaceInterface.h:42
lomiri::shell::application::MirSurfaceListInterface
Interface for a list model of MirSurfaces.
Definition MirSurfaceListInterface.h:32
lomiri::shell::application::MirSurfaceListInterface::count
int count
Number of surfaces in this model.
Definition MirSurfaceListInterface.h:41
lomiri::shell::application::MirSurfaceListInterface::get
virtual Q_INVOKABLE MirSurfaceInterface * get(int index)=0
Returns the surface at the specified index.
lomiri::shell::application::MirSurfaceListInterface::Roles
Roles
The Roles supported by the model.
Definition MirSurfaceListInterface.h:56
lomiri::shell::application::MirSurfaceListInterface::first
lomiri::shell::application::MirSurfaceInterface * first
The first (index 0) surface in this model.
Definition MirSurfaceListInterface.h:49
lomiri
Top-level namespace for all things Lomiri-related.
Definition Version.h:38