2
* Copyright 2012 Canonical Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation; version 3.
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 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/>.
17
* Renato Araujo Oliveira Filho <renato@canonical.com>
23
#include <QAbstractListModel>
27
class WidgetsMap : public QObject
31
WidgetsMap(QObject *parent=0)
35
void append(QMap<QString, QUrl> types)
37
Q_FOREACH(QString key, types.keys()) {
38
m_map.insert(key, types[key]);
41
void clear() { m_map.clear(); }
43
Q_INVOKABLE QMap<QString, QUrl> map() const { return m_map; }
44
Q_INVOKABLE QUrl find(const QString &widget) const { return m_map[widget]; }
47
QMap<QString, QUrl> m_map;
51
class PluginModel : public QAbstractListModel
54
Q_PROPERTY(WidgetsMap* widgetsMap READ widgetsMap NOTIFY widgetsMapChanged)
55
Q_PROPERTY(int count READ count NOTIFY countChanged)
68
PluginModel(QObject *parent=0);
71
WidgetsMap* widgetsMap() const;
73
Q_INVOKABLE void load();
74
Q_INVOKABLE void unload();
76
Q_INVOKABLE QVariantMap get(int row) const;
78
/* QAbstractItemModel */
79
QHash<int, QByteArray> roleNames() const;
80
int columnCount(const QModelIndex &parent = QModelIndex()) const;
81
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
82
QModelIndex parent (const QModelIndex &index) const;
83
int rowCount(const QModelIndex &parent = QModelIndex()) const;
86
void widgetsMapChanged(WidgetsMap *widgetsMap);
90
WidgetsMap* m_widgetsMap;