Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / src / declarative / qml / qdeclarativeimport_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
7 **
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.
16 **
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.
20 **
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.
28 **
29 ** Other Usage
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.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QDECLARATIVEIMPORT_P_H
43 #define QDECLARATIVEIMPORT_P_H
44
45 #include <QtCore/qurl.h>
46 #include <QtCore/qcoreapplication.h>
47 #include <QtCore/qset.h>
48 #include <QtCore/qstringlist.h>
49 #include <private/qdeclarativedirparser_p.h>
50 #include <private/qdeclarativescript_p.h>
51 #include <private/qdeclarativemetatype_p.h>
52
53 //
54 //  W A R N I N G
55 //  -------------
56 //
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.
60 //
61 // We mean it.
62 //
63
64 QT_BEGIN_NAMESPACE
65
66 class QDeclarativeTypeNameCache;
67 class QDeclarativeEngine;
68 class QDir;
69 class QDeclarativeImportedNamespace;
70 class QDeclarativeImportsPrivate;
71 class QDeclarativeImportDatabase;
72 class QDeclarativeTypeLoader;
73
74 // Exported for QtQuick1
75 class Q_DECLARATIVE_EXPORT QDeclarativeImports
76 {
77 public:
78     QDeclarativeImports(QDeclarativeTypeLoader *);
79     QDeclarativeImports(const QDeclarativeImports &);
80     ~QDeclarativeImports();
81     QDeclarativeImports &operator=(const QDeclarativeImports &);
82
83     void setBaseUrl(const QUrl &url);
84     QUrl baseUrl() const;
85
86     bool resolveType(const QString& type,
87                      QDeclarativeType** type_return, QString* url_return,
88                      int *version_major, int *version_minor,
89                      QDeclarativeImportedNamespace** ns_return,
90                      QList<QDeclarativeError> *errors = 0) const;
91     bool resolveType(QDeclarativeImportedNamespace*, 
92                      const QString& type,
93                      QDeclarativeType** type_return, QString* url_return,
94                      int *version_major, int *version_minor) const;
95
96     bool addImport(QDeclarativeImportDatabase *, 
97                    const QString& uri, const QString& prefix, int vmaj, int vmin, 
98                    QDeclarativeScript::Import::Type importType,
99                    const QDeclarativeDirComponents &qmldircomponentsnetwork, 
100                    QList<QDeclarativeError> *errors);
101
102     void populateCache(QDeclarativeTypeNameCache *cache, QDeclarativeEngine *) const;
103
104     struct ScriptReference
105     {
106         QString nameSpace;
107         QString qualifier;
108         QUrl location;
109     };
110
111     QList<ScriptReference> resolvedScripts() const;
112
113 private:
114     friend class QDeclarativeImportDatabase;
115     QDeclarativeImportsPrivate *d;
116 };
117
118 class QDeclarativeImportDatabase
119 {
120     Q_DECLARE_TR_FUNCTIONS(QDeclarativeImportDatabase)
121 public:
122     QDeclarativeImportDatabase(QDeclarativeEngine *);
123     ~QDeclarativeImportDatabase();
124
125     bool importPlugin(const QString &filePath, const QString &uri, QList<QDeclarativeError> *errors);
126
127     QStringList importPathList() const;
128     void setImportPathList(const QStringList &paths);
129     void addImportPath(const QString& dir);
130
131     QStringList pluginPathList() const;
132     void setPluginPathList(const QStringList &paths);
133     void addPluginPath(const QString& path);
134
135 private:
136     friend class QDeclarativeImportsPrivate;
137     QString resolvePlugin(QDeclarativeTypeLoader *typeLoader,
138                           const QString &qmldirPath, const QString &qmldirPluginPath,
139                           const QString &baseName, const QStringList &suffixes,
140                           const QString &prefix = QString());
141     QString resolvePlugin(QDeclarativeTypeLoader *typeLoader,
142                           const QString &qmldirPath, const QString &qmldirPluginPath,
143                           const QString &baseName);
144
145
146     // XXX thread
147     QStringList filePluginPath;
148     QStringList fileImportPath;
149
150     QSet<QString> initializedPlugins;
151     QDeclarativeEngine *engine;
152 };
153
154 QT_END_NAMESPACE
155
156 #endif // QDECLARATIVEIMPORT_P_H
157