~unity-team/unity8/ota9.5

« back to all changes in this revision

Viewing changes to tests/qmltests/plugins/Unity/fake_launchermodel.h

  • Committer: Michał Sawicz
  • Date: 2013-06-05 22:03:08 UTC
  • Revision ID: michal.sawicz@canonical.com-20130605220308-yny8fv3futtr04fg
Inital unity8 commit.

Previous history can be found at https://code.launchpad.net/~unity-team/unity/phablet

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2011 Canonical, Ltd.
 
3
 *
 
4
 * Authors:
 
5
 *  Michael Zanetti <michael.zanetti@canonical.com>
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation; version 3.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
 
 
20
#include <QAbstractListModel>
 
21
 
 
22
class LauncherItem;
 
23
 
 
24
class LauncherModel: public QAbstractListModel
 
25
{
 
26
   Q_OBJECT
 
27
 
 
28
public:
 
29
    enum Roles {
 
30
        RoleDesktopFile = Qt::UserRole,
 
31
        RoleName,
 
32
        RoleIcon,
 
33
        RoleFavorite,
 
34
        RoleRunning
 
35
    };
 
36
 
 
37
    LauncherModel(QObject *parent = 0);
 
38
    ~LauncherModel();
 
39
 
 
40
    int rowCount(const QModelIndex &parent) const;
 
41
 
 
42
    QVariant data(const QModelIndex &index, int role) const;
 
43
 
 
44
    Q_INVOKABLE LauncherItem* get(int index) const;
 
45
    Q_INVOKABLE void move(int oldIndex, int newIndex);
 
46
 
 
47
    QHash<int, QByteArray> roleNames() const;
 
48
 
 
49
private:
 
50
    QList<LauncherItem*> m_list;
 
51
};
 
52
 
 
53
class LauncherItem: public QObject
 
54
{
 
55
    Q_OBJECT
 
56
    Q_PROPERTY(QString desktopFile READ desktopFile CONSTANT)
 
57
    Q_PROPERTY(QString name READ name CONSTANT)
 
58
    Q_PROPERTY(QString icon READ icon CONSTANT)
 
59
    Q_PROPERTY(bool favorite READ favorite WRITE setFavorite NOTIFY favoriteChanged)
 
60
    Q_PROPERTY(bool running READ running WRITE setRunning NOTIFY runningChanged)
 
61
 
 
62
public:
 
63
    LauncherItem(const QString &desktopFile, const QString &name, const QString &icon, QObject *parent = 0);
 
64
 
 
65
    QString desktopFile() const;
 
66
 
 
67
    QString name() const;
 
68
    QString icon() const;
 
69
 
 
70
    bool favorite() const;
 
71
    void setFavorite(bool favorite);
 
72
 
 
73
    bool running() const;
 
74
    void setRunning(bool running);
 
75
 
 
76
Q_SIGNALS:
 
77
    void favoriteChanged(bool favorite);
 
78
    void runningChanged(bool running);
 
79
 
 
80
private:
 
81
    QString m_desktopFile;
 
82
    QString m_name;
 
83
    QString m_icon;
 
84
    bool m_favorite;
 
85
    bool m_running;
 
86
};