on 2ecb97b help sign in
82 lines 2.0 kB history raw
1/*
2 * Copyright 2012 Canonical Ltd.
3 *
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.
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 Lesser General Public License for more details.
12 *
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/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 */
20#include "widgetsmap.h"
22/*!
23 \qmltype WidgetsMap
24 \inherits QObject
26 \brief The WidgetsMap class defines a auxiliary map class with all widgets registered by the plugins.
28 \b {This component is under heavy development.}
30 \code
31 PluginModel {
32 id: menuModel
33 baseDir: "/usr/share/indicators"
34 }
36 ListView {
37 id: view
38 model: menuModel
39 delegate: menuModel.widgetsMap.find("myWidget")
40 Component.onCompleted: menuModel.load()
41 }
42 \endcode
43*/
44WidgetsMap::WidgetsMap(QObject *parent)
45 :QObject(parent)
49/*! \internal */
50void WidgetsMap::append(WidgetsMapType types)
52 Q_FOREACH(QString key, types.keys()) {
53 m_map.insert(key, types[key]);
54 }
57/*! \internal */
58void WidgetsMap::clear()
60 m_map.clear();
63/*!
64 \qmlmethod WidgetsMap::map()
66 Return a QVariantMap with the WidgetsMap contents.
67*/
68WidgetsMapType WidgetsMap::map() const
70 return m_map;
73/*!
74 \qmlmethod WidgetsMap::find(QString widgetType)
76 Look for a widgetType registered by any plugin and return the file that represent
77 this type, or a empty QUrl if the type does not exists.
78*/
79QUrl WidgetsMap::find(const QString &widget) const
81 return m_map[widget];