Improve QJSValueIterator implementation.
[profile/ivi/qtdeclarative.git] / src / declarative / qml / qdeclarativeengine.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 **
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 **
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
29 **
30 ** Other Usage
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QDECLARATIVEENGINE_H
43 #define QDECLARATIVEENGINE_H
44
45 #include <QtCore/qurl.h>
46 #include <QtCore/qobject.h>
47 #include <QtCore/qmap.h>
48 #include <QtDeclarative/qjsengine.h>
49 #include <QtDeclarative/qjsvalue.h>
50 #include <QtDeclarative/qdeclarativeerror.h>
51
52 QT_BEGIN_HEADER
53
54 QT_BEGIN_NAMESPACE
55
56 QT_MODULE(Declarative)
57
58 class QDeclarativeComponent;
59 class QDeclarativeEnginePrivate;
60 class QDeclarativeImportsPrivate;
61 class QDeclarativeExpression;
62 class QDeclarativeContext;
63 class QDeclarativeType;
64 class QUrl;
65 class QJSEngine;
66 class QScriptContext;
67 class QDeclarativeImageProvider;
68 class QNetworkAccessManager;
69 class QDeclarativeNetworkAccessManagerFactory;
70 class Q_DECLARATIVE_EXPORT QDeclarativeEngine : public QJSEngine
71 {
72     Q_PROPERTY(QString offlineStoragePath READ offlineStoragePath WRITE setOfflineStoragePath)
73     Q_OBJECT
74 public:
75     QDeclarativeEngine(QObject *p = 0);
76     virtual ~QDeclarativeEngine();
77
78     QDeclarativeContext *rootContext() const;
79
80     void clearComponentCache();
81
82     QStringList importPathList() const;
83     void setImportPathList(const QStringList &paths);
84     void addImportPath(const QString& dir);
85
86     QStringList pluginPathList() const;
87     void setPluginPathList(const QStringList &paths);
88     void addPluginPath(const QString& dir);
89
90     bool importPlugin(const QString &filePath, const QString &uri, QString *errorString); // XXX: Qt 5: Remove this function
91     bool importPlugin(const QString &filePath, const QString &uri, QList<QDeclarativeError> *errors);
92
93     void setNetworkAccessManagerFactory(QDeclarativeNetworkAccessManagerFactory *);
94     QDeclarativeNetworkAccessManagerFactory *networkAccessManagerFactory() const;
95
96     QNetworkAccessManager *networkAccessManager() const;
97
98     void addImageProvider(const QString &id, QDeclarativeImageProvider *);
99     QDeclarativeImageProvider *imageProvider(const QString &id) const;
100     void removeImageProvider(const QString &id);
101
102     void setOfflineStoragePath(const QString& dir);
103     QString offlineStoragePath() const;
104
105     QUrl baseUrl() const;
106     void setBaseUrl(const QUrl &);
107
108     bool outputWarningsToStandardError() const;
109     void setOutputWarningsToStandardError(bool);
110
111     void collectGarbage();
112     
113     static QDeclarativeContext *contextForObject(const QObject *);
114     static void setContextForObject(QObject *, QDeclarativeContext *);
115
116     enum ObjectOwnership { CppOwnership, JavaScriptOwnership };
117     static void setObjectOwnership(QObject *, ObjectOwnership);
118     static ObjectOwnership objectOwnership(QObject *);
119
120 Q_SIGNALS:
121     void quit();
122     void warnings(const QList<QDeclarativeError> &warnings);
123
124 private:
125     Q_DISABLE_COPY(QDeclarativeEngine)
126     Q_DECLARE_PRIVATE(QDeclarativeEngine)
127 };
128
129 QT_END_NAMESPACE
130
131 QT_END_HEADER
132
133 #endif // QDECLARATIVEENGINE_H