summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp28
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp30
-rw-r--r--src/declarative/qml/qdeclarativeimport.cpp38
-rw-r--r--src/declarative/qml/qdeclarativeinclude.cpp24
-rw-r--r--src/declarative/qml/qdeclarativeproperty.cpp19
-rw-r--r--src/declarative/qml/qdeclarativesqldatabase.cpp26
6 files changed, 117 insertions, 48 deletions
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index a72e04e..a8b1c3f 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -147,32 +147,36 @@ class QByteArray;
Components are reusable, encapsulated QML elements with well-defined interfaces.
Components are often defined by \l {qdeclarativedocuments.html}{component files} -
- that is, \c .qml files. The \e Component element allows components to be defined
- within QML items rather than in a separate file. This may be useful for reusing
- a small component within a QML file, or for defining a component that logically
- belongs with other QML components within a file.
+ that is, \c .qml files. The \e Component element essentially allows QML components
+ to be defined inline, within a \l {QML Document}{QML document}, rather than as a separate QML file.
+ This may be useful for reusing a small component within a QML file, or for defining
+ a component that logically belongs with other QML components within a file.
For example, here is a component that is used by multiple \l Loader objects.
- It contains a top level \l Rectangle item:
+ It contains a single item, a \l Rectangle:
\snippet doc/src/snippets/declarative/component.qml 0
Notice that while a \l Rectangle by itself would be automatically
rendered and displayed, this is not the case for the above rectangle
because it is defined inside a \c Component. The component encapsulates the
- QML elements within, as if they were defined in a separate \c .qml
+ QML elements within, as if they were defined in a separate QML
file, and is not loaded until requested (in this case, by the
two \l Loader objects).
- A Component cannot contain anything other
- than an \c id and a single top level item. While the \c id is optional,
- the top level item is not; you cannot define an empty component.
+ Defining a \c Component is similar to defining a \l {QML Document}{QML document}.
+ A QML document has a single top-level item that defines the behaviors and
+ properties of that component, and cannot define properties or behaviors outside
+ of that top-level item. In the same way, a \c Component definition contains a single
+ top level item (which in the above example is a \l Rectangle) and cannot define any
+ data outside of this item, with the exception of an \e id (which in the above example
+ is \e redSquare).
- The Component element is commonly used to provide graphical components
- for views. For example, the ListView::delegate property requires a Component
+ The \c Component element is commonly used to provide graphical components
+ for views. For example, the ListView::delegate property requires a \c Component
to specify how each list item is to be displayed.
- Component objects can also be dynamically created using
+ \c Component objects can also be created dynamically using
\l{QML:Qt::createComponent()}{Qt.createComponent()}.
*/
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 48bf3d1..3a5fe66 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -262,6 +262,33 @@ of their use.
\endlist
*/
+/*!
+\qmlmethod object Qt::include(string url, jsobject callback)
+
+Includes another JavaScript file. This method can only be used from within JavaScript files,
+and not regular QML files.
+
+This imports all functions from \a url into the current script's namespace.
+
+Qt.include() returns an object that describes the status of the operation. The object has
+a single property, \c {status}, that is set to one of the following values:
+
+\table
+\header \o Symbol \o Value \o Description
+\row \o result.OK \o 0 \o The include completed successfully.
+\row \o result.LOADING \o 1 \o Data is being loaded from the network.
+\row \o result.NETWORK_ERROR \o 2 \o A network error occurred while fetching the url.
+\row \o result.EXCEPTION \o 3 \o A JavaScript exception occurred while executing the included code.
+An additional \c exception property will be set in this case.
+\endtable
+
+The \c status property will be updated as the operation progresses.
+
+If provided, \a callback is invoked when the operation completes. The callback is passed
+the same object as is returned from the Qt.include() call.
+*/
+// Qt.include() is implemented in qdeclarativeinclude.cpp
+
QDeclarativeEnginePrivate::QDeclarativeEnginePrivate(QDeclarativeEngine *e)
: captureProperties(false), rootContext(0), isDebugging(false),
@@ -679,6 +706,9 @@ QNetworkAccessManager *QDeclarativeEngine::networkAccessManager() const
requests. See the QDeclarativeImageProvider documentation for details on
implementing and using image providers.
+ All required image providers should be added to the engine before any
+ QML sources files are loaded.
+
Note that images loaded from a QDeclarativeImageProvider are cached
by QPixmapCache, similar to any image loaded by QML.
diff --git a/src/declarative/qml/qdeclarativeimport.cpp b/src/declarative/qml/qdeclarativeimport.cpp
index 6f5216a..94765f2 100644
--- a/src/declarative/qml/qdeclarativeimport.cpp
+++ b/src/declarative/qml/qdeclarativeimport.cpp
@@ -51,6 +51,10 @@
#include <private/qdeclarativetypenamecache_p.h>
#include <private/qdeclarativeengine_p.h>
+#ifdef Q_OS_SYMBIAN
+#include "private/qcore_symbian_p.h"
+#endif
+
QT_BEGIN_NAMESPACE
DEFINE_BOOL_CONFIG_OPTION(qmlImportTrace, QML_IMPORT_TRACE)
@@ -378,7 +382,13 @@ bool QDeclarativeImportsPrivate::importExtension(const QString &absoluteFilePath
foreach (const QDeclarativeDirParser::Plugin &plugin, qmldirParser.plugins()) {
QString resolvedFilePath = database->resolvePlugin(dir, plugin.path, plugin.name);
-
+#if defined(QT_LIBINFIX) && defined(Q_OS_SYMBIAN)
+ if (resolvedFilePath.isEmpty()) {
+ // In case of libinfixed build, attempt to load libinfixed version, too.
+ QString infixedPluginName = plugin.name + QLatin1String(QT_LIBINFIX);
+ resolvedFilePath = database->resolvePlugin(dir, plugin.path, infixedPluginName);
+ }
+#endif
if (!resolvedFilePath.isEmpty()) {
if (!database->importPlugin(resolvedFilePath, uri, errorString)) {
if (errorString)
@@ -658,8 +668,32 @@ QDeclarativeImportDatabase::QDeclarativeImportDatabase(QDeclarativeEngine *e)
// Search order is applicationDirPath(), $QML_IMPORT_PATH, QLibraryInfo::ImportsPath
- addImportPath(QLibraryInfo::location(QLibraryInfo::ImportsPath));
+ QString installImportsPath = QLibraryInfo::location(QLibraryInfo::ImportsPath);
+#if defined(Q_OS_SYMBIAN)
+ // Append imports path for all available drives in Symbian
+ if (installImportsPath.at(1) != QChar(QLatin1Char(':'))) {
+ QString tempPath = installImportsPath;
+ if (tempPath.at(tempPath.length() - 1) != QDir::separator()) {
+ tempPath += QDir::separator();
+ }
+ RFs& fs = qt_s60GetRFs();
+ TPtrC tempPathPtr(reinterpret_cast<const TText*> (tempPath.constData()));
+ TFindFile finder(fs);
+ TInt err = finder.FindByDir(tempPathPtr, tempPathPtr);
+ while (err == KErrNone) {
+ QString foundDir(reinterpret_cast<const QChar *>(finder.File().Ptr()),
+ finder.File().Length());
+ foundDir = QDir(foundDir).canonicalPath();
+ addImportPath(foundDir);
+ err = finder.Find();
+ }
+ } else {
+ addImportPath(installImportsPath);
+ }
+#else
+ addImportPath(installImportsPath);
+#endif
// env import paths
QByteArray envImportPath = qgetenv("QML_IMPORT_PATH");
if (!envImportPath.isEmpty()) {
diff --git a/src/declarative/qml/qdeclarativeinclude.cpp b/src/declarative/qml/qdeclarativeinclude.cpp
index 1e240d7..a9ecdda 100644
--- a/src/declarative/qml/qdeclarativeinclude.cpp
+++ b/src/declarative/qml/qdeclarativeinclude.cpp
@@ -172,28 +172,8 @@ void QDeclarativeInclude::callback(QScriptEngine *engine, QScriptValue &callback
}
}
-/*!
-\qmlmethod object Qt::include(string url, jsobject callback)
-
-Include another JavaScript file. This method can only be used from within JavaScript files,
-and not regular QML files.
-
-Qt.include() returns an object that describes the status of the operation. The object has
-a single property, \c {status} that is set to one of the following values:
-
-\table
-\header \o Symbol \o Value \o Description
-\row \o result.OK \o 0 \o The include completed successfully.
-\row \o result.LOADING \o 1 \o Data is being loaded from the network.
-\row \o result.NETWORK_ERROR \o 2 \o A network error occurred while fetching the url.
-\row \o result.EXCEPTION \o 3 \o A JavaScript exception occurred while executing the included code.
-An additional \c exception property will be set in this case.
-\endtable
-
-The return object's properties will be updated as the operation progresses.
-
-If provided, \a callback is invoked when the operation completes. The callback is passed
-the same object as is returned from the Qt.include() call.
+/*
+ Documented in qdeclarativeengine.cpp
*/
QScriptValue QDeclarativeInclude::include(QScriptContext *ctxt, QScriptEngine *engine)
{
diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp
index df0917f..60edd64 100644
--- a/src/declarative/qml/qdeclarativeproperty.cpp
+++ b/src/declarative/qml/qdeclarativeproperty.cpp
@@ -77,15 +77,28 @@ a property on a specific object instance. To read a property's value, programme
QDeclarativeProperty instance and call the read() method. Likewise to write a property value the
write() method is used.
+For example, for the following QML code:
+
+\qml
+// MyItem.qml
+import QtQuick 1.0
+
+Text { text: "A bit of text" }
+\endqml
+
+The \l Text object's properties could be accessed using QDeclarativeProperty, like this:
+
\code
+#include <QDeclarativeProperty>
+#include <QGraphicsObject>
-QObject *object = declarativeComponent.create();
+...
-QDeclarativeProperty property(object, "font.pixelSize");
+QDeclarativeView view(QUrl::fromLocalFile("MyItem.qml"));
+QDeclarativeProperty property(view.rootObject(), "font.pixelSize");
qWarning() << "Current pixel size:" << property.read().toInt();
property.write(24);
qWarning() << "Pixel size should now be 24:" << property.read().toInt();
-
\endcode
*/
diff --git a/src/declarative/qml/qdeclarativesqldatabase.cpp b/src/declarative/qml/qdeclarativesqldatabase.cpp
index 45f277e..bda02a5 100644
--- a/src/declarative/qml/qdeclarativesqldatabase.cpp
+++ b/src/declarative/qml/qdeclarativesqldatabase.cpp
@@ -172,16 +172,23 @@ static const char* sqlerror[] = {
return errorValue; \
}
-
-static QString databaseFile(const QString& connectionName, QScriptEngine *engine)
+static QString qmlsqldatabase_databasesPath(QScriptEngine *engine)
{
QDeclarativeScriptEngine *qmlengine = static_cast<QDeclarativeScriptEngine*>(engine);
- QString basename = qmlengine->offlineStoragePath
- + QDir::separator() + QLatin1String("Databases") + QDir::separator();
- basename += connectionName;
- return basename;
+ return qmlengine->offlineStoragePath
+ + QDir::separator() + QLatin1String("Databases");
}
+static void qmlsqldatabase_initDatabasesPath(QScriptEngine *engine)
+{
+ QDir().mkpath(qmlsqldatabase_databasesPath(engine));
+}
+
+static QString qmlsqldatabase_databaseFile(const QString& connectionName, QScriptEngine *engine)
+{
+ return qmlsqldatabase_databasesPath(engine) + QDir::separator()
+ + connectionName;
+}
static QScriptValue qmlsqldatabase_item(QScriptContext *context, QScriptEngine *engine)
@@ -302,7 +309,7 @@ static QScriptValue qmlsqldatabase_change_version(QScriptContext *context, QScri
if (ok) {
context->thisObject().setProperty(QLatin1String("version"), to_version, QScriptValue::ReadOnly);
- QSettings ini(databaseFile(db.connectionName(),engine)+QLatin1String(".ini"),QSettings::IniFormat);
+ QSettings ini(qmlsqldatabase_databaseFile(db.connectionName(),engine) + QLatin1String(".ini"), QSettings::IniFormat);
ini.setValue(QLatin1String("Version"), to_version);
}
@@ -348,6 +355,8 @@ static QScriptValue qmlsqldatabase_read_transaction(QScriptContext *context, QSc
*/
static QScriptValue qmlsqldatabase_open_sync(QScriptContext *context, QScriptEngine *engine)
{
+ qmlsqldatabase_initDatabasesPath(engine);
+
QSqlDatabase database;
QString dbname = context->argument(0).toString();
@@ -360,7 +369,7 @@ static QScriptValue qmlsqldatabase_open_sync(QScriptContext *context, QScriptEng
md5.addData(dbname.toUtf8());
QString dbid(QLatin1String(md5.result().toHex()));
- QString basename = databaseFile(dbid,engine);
+ QString basename = qmlsqldatabase_databaseFile(dbid, engine);
bool created = false;
QString version = dbversion;
@@ -375,7 +384,6 @@ static QScriptValue qmlsqldatabase_open_sync(QScriptContext *context, QScriptEng
} else {
created = !QFile::exists(basename+QLatin1String(".sqlite"));
database = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"), dbid);
- QDir().mkpath(basename);
if (created) {
ini.setValue(QLatin1String("Name"), dbname);
if (dbcreationCallback.isFunction())