1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #ifndef WIDGETPLUGINPATH_H
34 #define WIDGETPLUGINPATH_H
36 #include "widgetpluginmanager.h"
38 #include <QtCore/QObject>
39 #include <QWeakPointer>
40 #include <QtCore/QList>
41 #include <QtCore/QDir>
42 #include <QtGui/QStandardItem>
46 class QAbstractItemModel;
49 namespace QmlDesigner {
55 // Dumb plugin data structure. Note that whereas QObjects can
56 // casted to an interface, QWeakPointer does not work with the
57 // interface class, so, we need a separate QWeakPointer as a guard
58 // to detect the deletion of a plugin instance which can happen
60 struct WidgetPluginData {
61 WidgetPluginData(const QString &p = QString());
66 QWeakPointer<QObject> instanceGuard;
67 IWidgetPlugin *instance;
71 // PluginPath: Manages a plugin directory. It does nothing
72 // on construction following the "as lazy as possible" principle.
73 // In the "loaded" stage, it scans the directories and creates
74 // a list of PluginData for the libraries found.
75 // getInstances() will return the fully initialized list of
78 class WidgetPluginPath {
80 explicit WidgetPluginPath(const QDir &path);
83 void getInstances(WidgetPluginManager::IWidgetPluginList *list);
85 QDir path() const { return m_path; }
87 // Convenience to populate a "About Plugin" dialog with
88 // plugins from that path. Forces initialization.
89 QStandardItem *createModelItem();
92 typedef QList<WidgetPluginData> PluginDataList;
94 static QStringList libraryFilePaths(const QDir &dir);
100 PluginDataList m_plugins;
103 } // namespace Internal
104 } // namespace QmlDesigner
105 #endif // WIDGETPLUGINPATH_H