on bc8fff5 help sign in
97 lines 3.1 kB history raw
1/*
2 * Copyright (C) 2014,2015 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 */
17#ifndef SESSION_H
18#define SESSION_H
20#include "ObjectListModel.h"
21#include "SessionModel.h"
23#include <QQuickItem>
25class ApplicationInfo;
26class MirSurface;
28class Session : public QObject
30 Q_OBJECT
31 Q_PROPERTY(QString name READ name CONSTANT)
32 Q_PROPERTY(MirSurface* lastSurface READ lastSurface NOTIFY lastSurfaceChanged)
33 Q_PROPERTY(ObjectListModel<MirSurface>* surfaces READ surfaces CONSTANT)
34 Q_PROPERTY(ApplicationInfo* application READ application NOTIFY applicationChanged)
35 Q_PROPERTY(Session* parentSession READ parentSession NOTIFY parentSessionChanged DESIGNABLE false)
36 Q_PROPERTY(SessionModel* childSessions READ childSessions DESIGNABLE false CONSTANT)
37 Q_PROPERTY(bool live READ live NOTIFY liveChanged)
39public:
40 explicit Session(const QString &name,
41 const QUrl& screenshot,
42 QObject *parent = 0);
43 ~Session();
45 Q_INVOKABLE void release();
47 //getters
48 QString name() const { return m_name; }
49 bool live() const { return m_live; }
50 ApplicationInfo* application() const { return m_application; }
51 MirSurface *lastSurface() const;
52 ObjectListModel<MirSurface>* surfaces() const;
53 Session* parentSession() const { return m_parentSession; }
55 void setApplication(ApplicationInfo* item);
56 void appendSurface(MirSurface* surface);
57 void removeSurface(MirSurface* surface);
58 void setScreenshot(const QUrl& m_screenshot);
59 void setLive(bool live);
61 Q_INVOKABLE void addChildSession(Session* session);
62 void insertChildSession(uint index, Session* session);
63 Q_INVOKABLE void removeChildSession(Session* session);
65Q_SIGNALS:
66 void applicationChanged(ApplicationInfo*);
67 void parentSessionChanged(Session*);
68 void liveChanged(bool live);
69 void surfaceAdded(MirSurface *surface);
70 void lastSurfaceChanged(MirSurface *surface);
72 // internal mock use
73 void deregister();
75public Q_SLOTS:
76 Q_INVOKABLE void createSurface();
78private:
79 SessionModel* childSessions() const;
80 void setParentSession(Session* session);
82 QString m_name;
83 bool m_live;
84 QUrl m_screenshot;
85 ApplicationInfo* m_application;
86 MirSurface* m_surface;
87 Session* m_parentSession;
88 SessionModel* m_children;
89 ObjectListModel<MirSurface> m_surfaces;
91 friend class ApplicationTestInterface;
92};
94Q_DECLARE_METATYPE(Session*)
95Q_DECLARE_METATYPE(ObjectListModel<MirSurface>*)
97#endif // SESSION_H