/* * Copyright (C) 2016 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License version 3, as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef UNITY_SCREENS_H #define UNITY_SCREENS_H #include #include #include namespace qtmir { class Screen; class Screens; } class Screen; class ProxyScreens; class Screens : public QAbstractListModel { Q_OBJECT Q_PROPERTY(int count READ count NOTIFY countChanged) Q_PROPERTY(QVariant activeScreen READ activeScreen WRITE activateScreen NOTIFY activeScreenChanged) public: enum ItemRoles { ScreenRole = Qt::UserRole + 1 }; ~Screens(); /* QAbstractItemModel */ QHash roleNames() const override; QVariant data(const QModelIndex &index, int role = ScreenRole) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override; int count() const; QVariant activeScreen() const; bool isSyncing() const { return m_syncing; } const QVector& list() const { return m_screens; } public Q_SLOTS: void activateScreen(const QVariant& index); Q_SIGNALS: void countChanged(); void activeScreenChanged(); void screenAdded(Screen* screen); void screenRemoved(Screen* screen); protected: Screens(const QSharedPointer& model); QVector m_screens; const QSharedPointer m_wrapped; bool m_syncing; friend class ProxyScreens; }; class ConcreteScreens : public Screens { Q_OBJECT public: explicit ConcreteScreens(const QSharedPointer& model); Q_INVOKABLE ProxyScreens *createProxy(); Q_INVOKABLE void sync(Screens *proxy); static ConcreteScreens *self(); protected Q_SLOTS: void onScreenAdded(qtmir::Screen *screen); void onScreenRemoved(qtmir::Screen *screen); private: static ConcreteScreens* m_self; }; class ProxyScreens : public Screens { public: explicit ProxyScreens(Screens*const screens); private: const QPointer m_original; }; #endif // SCREENS_H