1
// This file is part of QtUbuntu, a set of Qt components for Ubuntu.
2
// Copyright © 2013 Canonical Ltd.
4
// This program is free software: you can redistribute it and/or modify it under
5
// the terms of the GNU Lesser General Public License version 3, as published by
6
// the Free Software Foundation.
8
// This program is distributed in the hope that it will be useful, but WITHOUT
9
// ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10
// SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
// Lesser General Public License for more details.
13
// You should have received a copy of the GNU Lesser General Public License
14
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
#ifndef APPLICATION_LIST_MODEL_H
17
#define APPLICATION_LIST_MODEL_H
19
#include <QtCore/QAbstractListModel>
23
class ApplicationListModel : public QAbstractListModel {
26
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
29
explicit ApplicationListModel(QObject* parent = 0);
30
~ApplicationListModel();
32
// QAbstractItemModel methods.
33
int rowCount(const QModelIndex& parent = QModelIndex()) const;
34
QVariant data(const QModelIndex& index, int role) const;
35
QHash<int,QByteArray> roleNames() const { return roleNames_; }
36
Q_INVOKABLE QVariant get(int index) const;
37
Q_INVOKABLE void move(int from, int to);
43
Q_DISABLE_COPY(ApplicationListModel)
45
void add(Application* application);
46
void remove(Application* application);
47
Application* findFromTimerId(int timerId);
48
#if !defined(QT_NO_DEBUG)
49
bool contains(Application* application) const { return applications_.contains(application); }
52
QHash<int,QByteArray> roleNames_;
53
QList<Application*> applications_;
55
friend class ApplicationManager;
58
Q_DECLARE_METATYPE(ApplicationListModel*)
60
#endif // APPLICATION_LIST_MODEL_H