~mterry/+junk/u8

« back to all changes in this revision

Viewing changes to tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModel.h

Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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_MOCK_SESSIONSMODEL_H
 
19
#define UNITY_MOCK_SESSIONSMODEL_H
 
20
 
 
21
#include <QtCore/QAbstractListModel>
 
22
#include <QtCore/QString>
 
23
 
 
24
namespace QLightDM
 
25
{
 
26
class SessionsModelPrivate;
 
27
 
 
28
class Q_DECL_EXPORT SessionsModel : public QAbstractListModel
 
29
    {
 
30
        Q_OBJECT
 
31
 
 
32
        Q_ENUMS(SessionModelRoles SessionType)
 
33
 
 
34
    public:
 
35
 
 
36
        enum SessionModelRoles {
 
37
            //name is exposed as Qt::DisplayRole
 
38
            //comment is exposed as Qt::TooltipRole
 
39
            KeyRole = Qt::UserRole,
 
40
            IdRole = KeyRole, /** Deprecated */
 
41
            TypeRole
 
42
        };
 
43
 
 
44
        enum SessionType {
 
45
            LocalSessions,
 
46
            RemoteSessions
 
47
        };
 
48
 
 
49
        explicit SessionsModel(QObject* parent=nullptr); /** Deprecated. Loads local sessions*/
 
50
        explicit SessionsModel(SessionsModel::SessionType, QObject* parent=nullptr);
 
51
        virtual ~SessionsModel();
 
52
 
 
53
        QHash<int, QByteArray> roleNames() const override;
 
54
        int rowCount(const QModelIndex& parent) const override;
 
55
        QVariant data(const QModelIndex& index, int role) const override;
 
56
 
 
57
        int numSessions() const;
 
58
        int numAvailableSessions() const;
 
59
        QString testScenario() const;
 
60
        void setNumSessions(int numSessions);
 
61
        void setTestScenario(QString testScenario);
 
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_MOCK_SESSIONSMODEL_H