on ec68c6e help sign in
unity8/plugins/Unity/launchermodel.h
86 lines 2.3 kB history raw
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 */
20#include <QAbstractListModel>
22class LauncherItem;
24class LauncherModel: public QAbstractListModel
26 Q_OBJECT
28public:
29 enum Roles {
30 RoleDesktopFile = Qt::UserRole,
31 RoleName,
32 RoleIcon,
33 RoleFavorite,
34 RoleRunning
35 };
37 LauncherModel(QObject *parent = 0);
38 ~LauncherModel();
40 int rowCount(const QModelIndex &parent) const;
42 QVariant data(const QModelIndex &index, int role) const;
44 Q_INVOKABLE LauncherItem* get(int index) const;
45 Q_INVOKABLE void move(int oldIndex, int newIndex);
47 QHash<int, QByteArray> roleNames() const;
49private:
50 QList<LauncherItem*> m_list;
51};
53class LauncherItem: public QObject
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)
62public:
63 LauncherItem(const QString &desktopFile, const QString &name, const QString &icon, QObject *parent = 0);
65 QString desktopFile() const;
67 QString name() const;
68 QString icon() const;
70 bool favorite() const;
71 void setFavorite(bool favorite);
73 bool running() const;
74 void setRunning(bool running);
76Q_SIGNALS:
77 void favoriteChanged(bool favorite);
78 void runningChanged(bool running);
80private:
81 QString m_desktopFile;
82 QString m_name;
83 QString m_icon;
84 bool m_favorite;
85 bool m_running;
86};