Unity 8
SessionsModel.h
1 /*
2  * Copyright (C) 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  *
16  */
17 
18 #ifndef UNITY_INTEGRATED_SESSIONSMODEL_H
19 #define UNITY_INTEGRATED_SESSIONSMODEL_H
20 
21 #include <QtCore/QAbstractListModel>
22 #include <QtCore/QString>
23 
24 /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
25  * CHANGES MADE HERE MUST BE REFLECTED ON THE MOCK LIB
26  * COUNTERPART IN tests/mocks/LightDM/IntegratedLightDM/liblightdm
27  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
28 
29 // This is taken from liblightdm and modified to confirm to our syle conventions
30 namespace QLightDM
31 {
32 class SessionsModelPrivate;
33 
34 class Q_DECL_EXPORT SessionsModel : public QAbstractListModel
35  {
36  Q_OBJECT
37 
38  Q_ENUMS(SessionModelRoles SessionType)
39 
40  public:
41 
42  enum SessionModelRoles {
43  //name is exposed as Qt::DisplayRole
44  //comment is exposed as Qt::TooltipRole
45  KeyRole = Qt::UserRole,
46  IdRole = KeyRole,
47  TypeRole
48  };
49 
50  enum SessionType {
51  LocalSessions,
52  RemoteSessions
53  };
54 
55  explicit SessionsModel(QObject* parent=0);
56  explicit SessionsModel(SessionsModel::SessionType, QObject* parent=0);
57  virtual ~SessionsModel();
58 
59  QHash<int, QByteArray> roleNames() const override;
60  int rowCount(const QModelIndex& parent) const override;
61  QVariant data(const QModelIndex& index, int role) const override;
62 
63  protected:
64  SessionsModelPrivate* const d_ptr;
65 
66  private:
67  QHash<int, QByteArray> m_roleNames;
68  Q_DECLARE_PRIVATE(SessionsModel)
69  };
70 }
71 
72 #endif // UNITY_INTEGRATED_SESSIONSMODEL_H