1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtQml module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QQMLIMPORT_P_H
43 #define QQMLIMPORT_P_H
45 #include <QtCore/qurl.h>
46 #include <QtCore/qcoreapplication.h>
47 #include <QtCore/qset.h>
48 #include <QtCore/qstringlist.h>
49 #include <private/qqmldirparser_p.h>
50 #include <private/qqmlscript_p.h>
51 #include <private/qqmlmetatype_p.h>
57 // This file is not part of the Qt API. It exists purely as an
58 // implementation detail. This header file may change from version to
59 // version without notice, or even be removed.
66 class QQmlTypeNameCache;
69 class QQmlImportNamespace;
70 class QQmlImportsPrivate;
71 class QQmlImportDatabase;
74 // Exported for QtQuick1
75 class Q_QML_EXPORT QQmlImports
78 QQmlImports(QQmlTypeLoader *);
79 QQmlImports(const QQmlImports &);
81 QQmlImports &operator=(const QQmlImports &);
83 void setBaseUrl(const QUrl &url, const QString &urlString = QString());
86 bool resolveType(const QString& type,
87 QQmlType** type_return, QString* url_return,
88 int *version_major, int *version_minor,
89 QQmlImportNamespace** ns_return,
90 QList<QQmlError> *errors = 0) const;
91 bool resolveType(QQmlImportNamespace*,
93 QQmlType** type_return, QString* url_return,
94 int *version_major, int *version_minor) const;
96 bool addImplicitImport(QQmlImportDatabase *importDb,
97 const QQmlDirComponents &qmldircomponentsnetwork,
98 QList<QQmlError> *errors);
100 bool addImport(QQmlImportDatabase *,
101 const QString& uri, const QString& prefix, int vmaj, int vmin,
102 QQmlScript::Import::Type importType,
103 const QQmlDirComponents &qmldircomponentsnetwork,
104 QString *url, QList<QQmlError> *errors);
106 void populateCache(QQmlTypeNameCache *cache, QQmlEngine *) const;
108 struct ScriptReference
115 QList<ScriptReference> resolvedScripts() const;
118 friend class QQmlImportDatabase;
119 QQmlImportsPrivate *d;
122 class QQmlImportDatabase
124 Q_DECLARE_TR_FUNCTIONS(QQmlImportDatabase)
126 QQmlImportDatabase(QQmlEngine *);
127 ~QQmlImportDatabase();
129 bool importPlugin(const QString &filePath, const QString &uri, QList<QQmlError> *errors);
131 QStringList importPathList() const;
132 void setImportPathList(const QStringList &paths);
133 void addImportPath(const QString& dir);
135 QStringList pluginPathList() const;
136 void setPluginPathList(const QStringList &paths);
137 void addPluginPath(const QString& path);
140 friend class QQmlImportsPrivate;
141 QString resolvePlugin(QQmlTypeLoader *typeLoader,
142 const QString &qmldirPath, const QString &qmldirPluginPath,
143 const QString &baseName, const QStringList &suffixes,
144 const QString &prefix = QString());
145 QString resolvePlugin(QQmlTypeLoader *typeLoader,
146 const QString &qmldirPath, const QString &qmldirPluginPath,
147 const QString &baseName);
152 QString qmldirFilePath;
153 QString qmldirPathUrl;
156 // Maps from an import to a linked list of qmldir info.
157 // Used in QQmlImportsPrivate::locateQmldir()
158 QStringHash<QmldirCache *> qmldirCache;
161 QStringList filePluginPath;
162 QStringList fileImportPath;
164 QSet<QString> initializedPlugins;
170 #endif // QQMLIMPORT_P_H