From 69479992d8b4af73481df12e6f052269ae88ccc1 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 18 May 2010 12:24:20 +0200 Subject: Renaming "Qml Launcher" back to "QML Viewer" Change the official name of the qml executable back to "Qt QML Viewer" - the original name before it got renamed to "QML Runtime" and then "QML Launcher". Also, the new Mac OS X bundle name is "QMLViewer" (without a space to ease command line use). --- doc/src/declarative/qmlruntime.qdoc | 22 +++++++++++----------- doc/src/snippets/declarative/gridview/gridview.qml | 2 +- .../snippets/declarative/listview/highlight.qml | 2 +- doc/src/snippets/declarative/listview/listview.qml | 2 +- src/declarative/QmlChanges.txt | 4 ++-- tools/qdoc3/test/macros.qdocconf | 2 +- tools/qml/content/Browser.qml | 6 +++--- tools/qml/main.cpp | 14 +++++++------- tools/qml/qml.pro | 2 +- tools/qml/qmlruntime.cpp | 12 ++++++------ 10 files changed, 34 insertions(+), 34 deletions(-) diff --git a/doc/src/declarative/qmlruntime.qdoc b/doc/src/declarative/qmlruntime.qdoc index b105df4..a03b9c2 100644 --- a/doc/src/declarative/qmlruntime.qdoc +++ b/doc/src/declarative/qmlruntime.qdoc @@ -42,17 +42,17 @@ /*! \page qmlruntime.html \title Qt Declarative UI Runtime - \keyword qml runtime + \keyword QML Viewer (qml) \ingroup qttools This page documents the \e{Declarative UI Runtime} for the Qt GUI - toolkit, and the \QQL which can be used to run apps - written for the runtime. The \QQL reads a declarative + toolkit, and the \QQV which can be used to run apps + written for the runtime. The \QQV reads a declarative user interface definition (\c .qml) file and displays the user interface it describes. QML is a runtime, as you can run plain QML files which pull in their required modules. To run apps with the QML runtime, you can either start the runtime - from your own application (using a QDeclarativeView) or with the simple \QQL. + from your own application (using a QDeclarativeView) or with the simple \QQV. The launcher can be installed in a production environment, assuming that it is not already present in the system. It is generally packaged alongside Qt. @@ -61,16 +61,16 @@ \list \o Write your own Qt application including a QDeclarative view and deploy it the same as any other Qt application (not discussed further on this page), or - \o Write a main QML file for your application, and run your application using the included \QQL. + \o Write a main QML file for your application, and run your application using the included \QQV. \endlist - To run an application with the \QQL, pass the filename as an argument: + To run an application with the \QQV, pass the filename as an argument: \code qml myQmlFile.qml \endcode - Deploying a QML application via the \QQL allows for QML only deployments, but can also + Deploying a QML application via the \QQV allows for QML only deployments, but can also include custom C++ modules just as easily. Below is an example of how you might structure a complex application deployed via the QML runtime, it is a listing of the files that would be included in the deployment package. @@ -92,8 +92,8 @@ as the appropriate module file is chosen based on platform naming conventions. The C++ modules must contain a QDeclarativeExtentionPlugin subclass. - The application would be executed either with your own application, the command 'qml MyApp.qml' or by - opening the file if your system has the \QQL registered as the handler for QML files. The MyApp.qml file would have access + The application would be executed either with your own application, the command 'qml MyApp.qml' or by + opening the file if your system has the \QQV registered as the handler for QML files. The MyApp.qml file would have access to all of the deployed types using the import statements such as the following: \code @@ -101,8 +101,8 @@ import "OtherModule" 1.0 as Other \endcode - \section1 Qt QML Launcher functionality - The \QQL implements some additional functionality to help it supporting + \section1 Qt QML Viewer functionality + The \QQV implements some additional functionality to help it supporting myriad applications. If you implement your own application, you may also wish to reimplement some or all of this functionality. However, much of this functionality is intended to aid the prototyping of QML applications and may not be necessary for a deployed application. diff --git a/doc/src/snippets/declarative/gridview/gridview.qml b/doc/src/snippets/declarative/gridview/gridview.qml index cf345aa..1d3df97 100644 --- a/doc/src/snippets/declarative/gridview/gridview.qml +++ b/doc/src/snippets/declarative/gridview/gridview.qml @@ -4,7 +4,7 @@ import Qt 4.7 Rectangle { width: 240; height: 180; color: "white" // ContactModel model is defined in dummydata/ContactModel.qml - // The launcher automatically loads files in dummydata/* to assist + // The viewer automatically loads files in dummydata/* to assist // development without a real data source. // Define a delegate component. A component will be diff --git a/doc/src/snippets/declarative/listview/highlight.qml b/doc/src/snippets/declarative/listview/highlight.qml index 1282f8d..794b3f2 100644 --- a/doc/src/snippets/declarative/listview/highlight.qml +++ b/doc/src/snippets/declarative/listview/highlight.qml @@ -4,7 +4,7 @@ Rectangle { width: 180; height: 200; color: "white" // ContactModel model is defined in dummydata/ContactModel.qml - // The launcher automatically loads files in dummydata/* to assist + // The viewer automatically loads files in dummydata/* to assist // development without a real data source. // Define a delegate component. A component will be diff --git a/doc/src/snippets/declarative/listview/listview.qml b/doc/src/snippets/declarative/listview/listview.qml index 44f0540..61bf126 100644 --- a/doc/src/snippets/declarative/listview/listview.qml +++ b/doc/src/snippets/declarative/listview/listview.qml @@ -5,7 +5,7 @@ Rectangle { width: 180; height: 200; color: "white" // ContactModel model is defined in dummydata/ContactModel.qml - // The launcher automatically loads files in dummydata/* to assist + // The viewer automatically loads files in dummydata/* to assist // development without a real data source. // Define a delegate component. A component will be diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index b1f4f1b..c121a2d 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -23,9 +23,9 @@ The QDeclarativeExpression constructor has changed from to QDeclarativeExpression(context, scope, expression, parent = 0) -QML Launcher +QML Viewer ------------ -The standalone executable has been renamed to qml launcher. Runtime warnings +The standalone qml executable has been renamed back to Qml Viewer. Runtime warnings can be now accessed via the menu (Debugging->Show Warnings). ============================================================================= diff --git a/tools/qdoc3/test/macros.qdocconf b/tools/qdoc3/test/macros.qdocconf index e7a1dbc..510a8b3 100644 --- a/tools/qdoc3/test/macros.qdocconf +++ b/tools/qdoc3/test/macros.qdocconf @@ -18,7 +18,7 @@ macro.ouml.HTML = "ö" macro.QA = "\\e{Qt Assistant}" macro.QD = "\\e{Qt Designer}" macro.QL = "\\e{Qt Linguist}" -macro.QQL = "\\e{Qt QML Launcher}" +macro.QQV = "\\e{Qt QML Viewer}" macro.param = "\\e" macro.raisedaster.HTML = "*" macro.rarrow.HTML = "→" diff --git a/tools/qml/content/Browser.qml b/tools/qml/content/Browser.qml index fe7ad9c..7238203 100644 --- a/tools/qml/content/Browser.qml +++ b/tools/qml/content/Browser.qml @@ -13,12 +13,12 @@ Rectangle { FolderListModel { id: folders1 nameFilters: [ "*.qml" ] - folder: qmlLauncherFolder + folder: qmlViewerFolder } FolderListModel { id: folders2 nameFilters: [ "*.qml" ] - folder: qmlLauncherFolder + folder: qmlViewerFolder } SystemPalette { id: palette } @@ -63,7 +63,7 @@ Rectangle { if (folders.isFolder(index)) { down(filePath); } else { - qmlLauncher.launch(filePath); + qmlViewer.launch(filePath); } } width: root.width diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 18e2531..22fc5ca 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -85,7 +85,7 @@ QString warnings; void showWarnings() { if (!warnings.isEmpty()) { - QMessageBox::warning(0, QApplication::tr("Qt QML Launcher"), warnings); + QMessageBox::warning(0, QApplication::tr("Qt QML Viewer"), warnings); } } @@ -117,7 +117,7 @@ void usage() qWarning(" -frameless ............................... run with no window frame"); qWarning(" -maximized................................ run maximized"); qWarning(" -fullscreen............................... run fullscreen"); - qWarning(" -stayontop................................ keep launcher window on top"); + qWarning(" -stayontop................................ keep viewer window on top"); qWarning(" -sizeviewtorootobject .................... the view resizes to the changes in the content"); qWarning(" -sizerootobjecttoview .................... the content resizes to the changes in the view"); qWarning(" -qmlbrowser .............................. use a QML-based file browser"); @@ -156,9 +156,9 @@ void scriptOptsUsage() qWarning(" testerror ................................ test 'error' property of root item on playback"); qWarning(" snapshot ................................. file being recorded is static,"); qWarning(" only one frame will be recorded or tested"); - qWarning(" exitoncomplete ........................... cleanly exit the launcher on script completion"); - qWarning(" exitonfailure ............................ immediately exit the launcher on script failure"); - qWarning(" saveonexit ............................... save recording on launcher exit"); + qWarning(" exitoncomplete ........................... cleanly exit the viewer on script completion"); + qWarning(" exitonfailure ............................ immediately exit the viewer on script failure"); + qWarning(" saveonexit ............................... save recording on viewer exit"); qWarning(" "); qWarning(" One of record, play or both must be specified."); exit(1); @@ -196,7 +196,7 @@ int main(int argc, char ** argv) #endif QApplication app(argc, argv); - app.setApplicationName("QtQmlLauncher"); + app.setApplicationName("QtQmlViewer"); app.setOrganizationName("Nokia"); app.setOrganizationDomain("nokia.com"); @@ -277,7 +277,7 @@ int main(int argc, char ** argv) if (lastArg) usage(); app.setStartDragDistance(QString(argv[++i]).toInt()); } else if (arg == QLatin1String("-v") || arg == QLatin1String("-version")) { - qWarning("Qt QML Launcher version %s", QT_VERSION_STR); + qWarning("Qt QML Viewer version %s", QT_VERSION_STR); exit(0); } else if (arg == "-translation") { if (lastArg) usage(); diff --git a/tools/qml/qml.pro b/tools/qml/qml.pro index 6129639..886f0d9 100644 --- a/tools/qml/qml.pro +++ b/tools/qml/qml.pro @@ -37,6 +37,6 @@ symbian { } mac { QMAKE_INFO_PLIST=Info_mac.plist - TARGET="QML Launcher" + TARGET=QMLViewer ICON=qml.icns } diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index 490fa34..8df250f 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -350,7 +350,7 @@ QNetworkAccessManager *NetworkAccessManagerFactory::create(QObject *parent) setupProxy(manager); if (cacheSize > 0) { QNetworkDiskCache *cache = new QNetworkDiskCache; - cache->setCacheDirectory(QDir::tempPath()+QLatin1String("/qml-launcher-network-cache")); + cache->setCacheDirectory(QDir::tempPath()+QLatin1String("/qml-viewer-network-cache")); cache->setMaximumCacheSize(cacheSize); manager->setCache(cache); } else { @@ -388,7 +388,7 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags) , translator(0) { QDeclarativeViewer::registerTypes(); - setWindowTitle(tr("Qt QML Launcher")); + setWindowTitle(tr("Qt QML Viewer")); devicemode = false; canvas = 0; @@ -887,7 +887,7 @@ bool QDeclarativeViewer::open(const QString& file_or_url) url = QUrl::fromLocalFile(fi.absoluteFilePath()); else url = QUrl(file_or_url); - setWindowTitle(tr("%1 - Qt QML Launcher").arg(file_or_url)); + setWindowTitle(tr("%1 - Qt QML Viewer").arg(file_or_url)); if (!m_script.isEmpty()) tester = new QDeclarativeTester(m_script, m_scriptOptions, canvas); @@ -895,11 +895,11 @@ bool QDeclarativeViewer::open(const QString& file_or_url) delete canvas->rootObject(); canvas->engine()->clearComponentCache(); QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("qmlLauncher", this); + ctxt->setContextProperty("qmlViewer", this); #ifdef Q_OS_SYMBIAN - ctxt->setContextProperty("qmlLauncherFolder", "E:\\"); // Documents on your S60 phone + ctxt->setContextProperty("qmlViewerFolder", "E:\\"); // Documents on your S60 phone #else - ctxt->setContextProperty("qmlLauncherFolder", QDir::currentPath()); + ctxt->setContextProperty("qmlViewerFolder", QDir::currentPath()); #endif ctxt->setContextProperty("runtime", Runtime::instance()); -- cgit v0.12 From 2108142dcd0a2dbb639443b594eb2c1c24e480cc Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 19 May 2010 10:16:36 +1000 Subject: Fix folderlistmodel with qt namespace --- src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp | 4 ++++ src/imports/folderlistmodel/qdeclarativefolderlistmodel.h | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp index a16f0c6..2ff7412 100644 --- a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp +++ b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp @@ -44,6 +44,8 @@ #include #include +QT_BEGIN_NAMESPACE + class QDeclarativeFolderListModelPrivate { public: @@ -387,3 +389,5 @@ void QDeclarativeFolderListModel::setShowOnlyReadable(bool on) else d->model.setFilter(d->model.filter() & ~QDir::Readable); } + +QT_END_NAMESPACE diff --git a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h index e610a14..dbde4c0 100644 --- a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h +++ b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h @@ -47,6 +47,12 @@ #include #include +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + class QDeclarativeContext; class QModelIndex; @@ -119,6 +125,10 @@ private: QDeclarativeFolderListModelPrivate *d; }; +QT_END_NAMESPACE + QML_DECLARE_TYPE(QDeclarativeFolderListModel) +QT_END_HEADER + #endif // QDECLARATIVEFOLDERLISTMODEL_H -- cgit v0.12 From e007505d8f35c1194caf80ffc4f1e46561ff7be3 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 19 May 2010 11:10:11 +1000 Subject: When changing Loader source, remove old item from scene immediately. This ensures focus is restored to the correct item. Task-number: QTBUG-10787 --- src/declarative/graphicsitems/qdeclarativeloader.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp index 94983c4..4995baf 100644 --- a/src/declarative/graphicsitems/qdeclarativeloader.cpp +++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp @@ -81,8 +81,12 @@ void QDeclarativeLoaderPrivate::clear() // We can't delete immediately because our item may have triggered // the Loader to load a different item. - item->setVisible(false); - item->setParentItem(0); + if (item->scene()) { + item->scene()->removeItem(item); + } else { + item->setParentItem(0); + item->setVisible(false); + } item->deleteLater(); item = 0; } -- cgit v0.12 From 5f3e8f33083be7bd7b858c8880f52a99952e0b75 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 19 May 2010 12:36:06 +1000 Subject: doc --- doc/src/declarative/examples.qdoc | 6 + doc/src/examples/qml-folderlistmodel.qdoc | 142 +++++++++++++++++++++ doc/src/images/declarative-folderlistmodel.png | Bin 0 -> 17764 bytes doc/src/snippets/declarative/folderlistmodel.qml | 17 +++ src/imports/folderlistmodel/plugin.cpp | 4 + .../qdeclarativefolderlistmodel.cpp | 9 ++ .../folderlistmodel/qdeclarativefolderlistmodel.h | 31 ++++- 7 files changed, 204 insertions(+), 5 deletions(-) create mode 100644 doc/src/examples/qml-folderlistmodel.qdoc create mode 100644 doc/src/images/declarative-folderlistmodel.png create mode 100644 doc/src/snippets/declarative/folderlistmodel.qml diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc index cdc308a..94f27e9 100644 --- a/doc/src/declarative/examples.qdoc +++ b/doc/src/declarative/examples.qdoc @@ -168,5 +168,11 @@ For example, from your build directory, run: \o \l{demos/declarative/snake}{Snake} \endlist +\section1 Labs + +\list +\o \l{src/imports/folderlistmodel}{Folder List Model} - a C++ model plugin +\endlist + */ diff --git a/doc/src/examples/qml-folderlistmodel.qdoc b/doc/src/examples/qml-folderlistmodel.qdoc new file mode 100644 index 0000000..6e5f493 --- /dev/null +++ b/doc/src/examples/qml-folderlistmodel.qdoc @@ -0,0 +1,142 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + +\title FolderListModel - a C++ model plugin +\example src/imports/folderlistmodel + +This plugin shows how to make a C++ model available to QML. It presents +a simple file list for a single folder (directory) and allows the presented +folder to be changed. + +\image declarative-folderlistmodel.png The FolderListModel used to choose a QML file + +We do not explain the model implementation in detail, but rather focus on the mechanics of +making the model available to QML. + +\section1 Usage from QML + +The type we are creating can be used from QML like this: + +\snippet doc/src/snippets/declarative/folderlistmodel.qml 0 + +\section1 Defining the Model + +We are subclassing QAbstractListModel which will allow us to give data to QML and +send notifications when the data changes: + +\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h class begin + +As you see, we also inherit the QDeclarativeParserStatus interface, so that we +can delay initial processing until we have all properties set (via componentComplete() below). + +The first thing to do when devising a new type for QML is to define the properties +you want the type to have: + +\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h class props + +The purposes of each of these should be pretty obvious - in QML we will set the folder +to display (a file: URL), and the kinds of files we want to show in the view of the model. + +Next are the constructor, destructor, and standard QAbstractListModel subclassing requirements: + +\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h abslistmodel + +The data() function is where we provide model values. The rowCount() function +is also a standard part of the QAbstractListModel interface, but we also want to provide +a simpler count property: + +\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h count + +Then we have the functions for the remaining properties which we defined above: + +\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h prop funcs + +Imperative actions upon the model are made available to QML via a Q_INVOKABLE tag on +a normal member function. The isFolder(index) function says whether the value at \e index +is a folder: + +\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h isfolder + +Then we have the QDeclarativeParserStatus interface: + +\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h parserstatus + +Then the NOTIFY function for the folders property. The implementation will emit this +when the folder property is changed. + +\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h notifier + +The class ends with some implementation details: + +\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h class end + +Lastly, the boilerplare to declare the type for QML use: + +\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h qml decl + +To make this class available to QML, we only need to make a simple subclass of QDeclarativeExtensionPlugin: + +\snippet src/imports/folderlistmodel/plugin.cpp class decl + +and then use the standard Qt plugin export macro: + +\snippet src/imports/folderlistmodel/plugin.cpp plugin export decl + +Finally, in order for QML to connect the "import" statement to our plugin, we list it in the qmldir file: + +\l{src/imports/folderlistmodel/qmldir} + +This qmldir file and the compiled plugin will be installed in \c $QTDIR/imports/Qt/labs/folderlistmodel/ where +the QML engine will find it (since \c $QTDIR/imports is the value of QLibraryInf::libraryPath()). + +\section1 Implementing the Model + +We'll not discuss the model implementation in detail, as it is not specific to QML - any Qt C++ model +can be interfaced to QML. +This implementation is basically just takes the krufty old QDirModel, +which is a tree with lots of detailed roles and re-presents it as a simpler list model where +each item is just a fileName and a filePath (as a file: URL rather than a plain file, since QML +works with URLs for all content). + +\l{src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp} +*/ diff --git a/doc/src/images/declarative-folderlistmodel.png b/doc/src/images/declarative-folderlistmodel.png new file mode 100644 index 0000000..a469f96 Binary files /dev/null and b/doc/src/images/declarative-folderlistmodel.png differ diff --git a/doc/src/snippets/declarative/folderlistmodel.qml b/doc/src/snippets/declarative/folderlistmodel.qml new file mode 100644 index 0000000..e90f9fd --- /dev/null +++ b/doc/src/snippets/declarative/folderlistmodel.qml @@ -0,0 +1,17 @@ +//![0] +import Qt 4.7 +import Qt.labs.folderlistmodel 1.0 + +ListView { + FolderListModel { + id: foldermodel + nameFilters: ["*.qml"] + } + Component { + id: filedelegate + Text { text: fileName } + } + model: foldermodel + delegate: filedelegate +} +//![0] diff --git a/src/imports/folderlistmodel/plugin.cpp b/src/imports/folderlistmodel/plugin.cpp index b94efb0..d4569f7 100644 --- a/src/imports/folderlistmodel/plugin.cpp +++ b/src/imports/folderlistmodel/plugin.cpp @@ -46,6 +46,7 @@ QT_BEGIN_NAMESPACE +//![class decl] class QmlFolderListModelPlugin : public QDeclarativeExtensionPlugin { Q_OBJECT @@ -56,10 +57,13 @@ public: qmlRegisterType(uri,1,0,"FolderListModel"); } }; +//![class decl] QT_END_NAMESPACE #include "plugin.moc" +//![plugin export decl] Q_EXPORT_PLUGIN2(qmlfolderlistmodelplugin, QT_PREPEND_NAMESPACE(QmlFolderListModelPlugin)); +//![plugin export decl] diff --git a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp index a16f0c6..0a75edf 100644 --- a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp +++ b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +//![code] #include "qdeclarativefolderlistmodel.h" #include #include @@ -99,6 +100,12 @@ public: separator, Qt will translate your paths to conform to the underlying operating system. + This type is made available by importing the \c Qt.labs.folderlistmodel module. + \e {Elements in the Qt.labs module are not guaranteed to remain compatible + in future versions.} + + \bold{import Qt.labs.folderlistmodel 1.0} + The roles available are: \list \o fileName @@ -387,3 +394,5 @@ void QDeclarativeFolderListModel::setShowOnlyReadable(bool on) else d->model.setFilter(d->model.filter() & ~QDir::Readable); } + +//![code] diff --git a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h index e610a14..87141c5 100644 --- a/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h +++ b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h @@ -51,11 +51,15 @@ class QDeclarativeContext; class QModelIndex; class QDeclarativeFolderListModelPrivate; + +//![class begin] class QDeclarativeFolderListModel : public QAbstractListModel, public QDeclarativeParserStatus { Q_OBJECT Q_INTERFACES(QDeclarativeParserStatus) +//![class begin] +//![class props] Q_PROPERTY(QUrl folder READ folder WRITE setFolder NOTIFY folderChanged) Q_PROPERTY(QUrl parentFolder READ parentFolder NOTIFY folderChanged) Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters) @@ -65,7 +69,9 @@ class QDeclarativeFolderListModel : public QAbstractListModel, public QDeclarati Q_PROPERTY(bool showDotAndDotDot READ showDotAndDotDot WRITE setShowDotAndDotDot) Q_PROPERTY(bool showOnlyReadable READ showOnlyReadable WRITE setShowOnlyReadable) Q_PROPERTY(int count READ count) +//![class props] +//![abslistmodel] public: QDeclarativeFolderListModel(QObject *parent = 0); ~QDeclarativeFolderListModel(); @@ -74,9 +80,13 @@ public: int rowCount(const QModelIndex &parent) const; QVariant data(const QModelIndex &index, int role) const; +//![abslistmodel] +//![count] int count() const { return rowCount(QModelIndex()); } +//![count] +//![prop funcs] QUrl folder() const; void setFolder(const QUrl &folder); @@ -85,11 +95,6 @@ public: QStringList nameFilters() const; void setNameFilters(const QStringList &filters); - virtual void classBegin(); - virtual void componentComplete(); - - Q_INVOKABLE bool isFolder(int index) const; - enum SortField { Unsorted, Name, Time, Size, Type }; SortField sortField() const; void setSortField(SortField field); @@ -104,10 +109,23 @@ public: void setShowDotAndDotDot(bool); bool showOnlyReadable() const; void setShowOnlyReadable(bool); +//![prop funcs] + +//![isfolder] + Q_INVOKABLE bool isFolder(int index) const; +//![isfolder] + +//![parserstatus] + virtual void classBegin(); + virtual void componentComplete(); +//![parserstatus] +//![notifier] Q_SIGNALS: void folderChanged(); +//![notifier] +//![class end] private Q_SLOTS: void refresh(); void inserted(const QModelIndex &index, int start, int end); @@ -118,7 +136,10 @@ private: Q_DISABLE_COPY(QDeclarativeFolderListModel) QDeclarativeFolderListModelPrivate *d; }; +//![class end] +//![qml decl] QML_DECLARE_TYPE(QDeclarativeFolderListModel) +//![qml decl] #endif // QDECLARATIVEFOLDERLISTMODEL_H -- cgit v0.12 From cd707a865625c7ee0ec836d2a1bdcda847ab0517 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 19 May 2010 12:41:50 +1000 Subject: doc --- doc/src/examples/qml-folderlistmodel.qdoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/src/examples/qml-folderlistmodel.qdoc b/doc/src/examples/qml-folderlistmodel.qdoc index 6e5f493..b820528 100644 --- a/doc/src/examples/qml-folderlistmodel.qdoc +++ b/doc/src/examples/qml-folderlistmodel.qdoc @@ -114,6 +114,8 @@ Lastly, the boilerplare to declare the type for QML use: \snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h qml decl +\section1 Connecting the Model to QML + To make this class available to QML, we only need to make a simple subclass of QDeclarativeExtensionPlugin: \snippet src/imports/folderlistmodel/plugin.cpp class decl -- cgit v0.12 From 36c51fe5229580ddaef7b7feb23822ecb775bffc Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 19 May 2010 12:54:59 +1000 Subject: Bug moved. --- .../qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp index 831e318..4173a44 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp +++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp @@ -238,7 +238,7 @@ void tst_qdeclarativexmllistmodel::roleErrors() QCOMPARE(data.value(Qt::UserRole+1), QVariant()); QCOMPARE(data.value(Qt::UserRole+2), QVariant()); - QEXPECT_FAIL("", "QT-2456", Continue); + QEXPECT_FAIL("", "QTBUG-10797", Continue); QCOMPARE(data.value(Qt::UserRole+3), QVariant()); delete model; -- cgit v0.12 From 90faa4aafc32adcf8fc3415fa0aa36d765b51087 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 19 May 2010 13:17:00 +1000 Subject: Introduce a threaded interpreter for QML binding bytecode Reviewed-by: Roberto Raggi --- .../qml/qdeclarativecompiledbindings.cpp | 389 ++++++++++++--------- 1 file changed, 233 insertions(+), 156 deletions(-) diff --git a/src/declarative/qml/qdeclarativecompiledbindings.cpp b/src/declarative/qml/qdeclarativecompiledbindings.cpp index 7ddc735..ad05e80 100644 --- a/src/declarative/qml/qdeclarativecompiledbindings.cpp +++ b/src/declarative/qml/qdeclarativecompiledbindings.cpp @@ -64,6 +64,73 @@ DEFINE_BOOL_CONFIG_OPTION(bindingsDump, QML_BINDINGS_DUMP); Q_GLOBAL_STATIC(QDeclarativeFastProperties, fastProperties); +#ifdef __GNUC__ +# define QML_THREADED_INTERPRETER +#endif + +#define FOR_EACH_QML_INSTR(F) \ + F(Noop) /* Nop */ \ + F(BindingId) /* id */ \ + F(Subscribe) /* subscribe */ \ + F(SubscribeId) /* subscribe */ \ + F(FetchAndSubscribe) /* fetchAndSubscribe */ \ + F(LoadId) /* load */ \ + F(LoadScope) /* load */ \ + F(LoadRoot) /* load */ \ + F(LoadAttached) /* attached */ \ + F(ConvertIntToReal) /* unaryop */ \ + F(ConvertRealToInt) /* unaryop */ \ + F(Real) /* real_value */ \ + F(Int) /* int_value */ \ + F(Bool) /* bool_value */ \ + F(String) /* string_value */ \ + F(AddReal) /* binaryop */ \ + F(AddInt) /* binaryop */ \ + F(AddString) /* binaryop */ \ + F(MinusReal) /* binaryop */ \ + F(MinusInt) /* binaryop */ \ + F(CompareReal) /* binaryop */ \ + F(CompareString) /* binaryop */ \ + F(NotCompareReal) /* binaryop */ \ + F(NotCompareString) /* binaryop */ \ + F(GreaterThanReal) /* binaryop */ \ + F(MaxReal) /* binaryop */ \ + F(MinReal) /* binaryop */ \ + F(NewString) /* construct */ \ + F(NewUrl) /* construct */ \ + F(CleanupUrl) /* cleanup */ \ + F(CleanupString) /* cleanup */ \ + F(Copy) /* copy */ \ + F(Fetch) /* fetch */ \ + F(Store) /* store */ \ + F(Skip) /* skip */ \ + F(Done) /* done */ \ + /* Speculative property resolution */ \ + F(InitString) /* initstring */ \ + F(FindGeneric) /* find */ \ + F(FindGenericTerminal) /* find */ \ + F(FindProperty) /* find */ \ + F(FindPropertyTerminal) /* find */ \ + F(CleanupGeneric) /* cleanup */ \ + F(ConvertGenericToReal) /* unaryop */ \ + F(ConvertGenericToBool) /* unaryop */ \ + F(ConvertGenericToString) /* unaryop */ \ + F(ConvertGenericToUrl) /* unaryop */ + +#define QML_INSTR_ENUM(I) I, +#define QML_INSTR_ADDR(I) &&op_##I, + +#ifdef QML_THREADED_INTERPRETER +# define QML_BEGIN_INSTR(I) op_##I: +# define QML_END_INSTR(I) ++instr; goto *instr->common.code; +# define QML_INSTR_HEADER void *code; +#else +# define QML_BEGIN_INSTR(I) case Instr::I: +# define QML_END_INSTR(I) break; +# define QML_INSTR_HEADER +#endif + + using namespace QDeclarativeJS; namespace { @@ -328,101 +395,45 @@ namespace { // This structure is exactly 8-bytes in size struct Instr { enum { - Noop, - BindingId, // id - - Subscribe, // subscribe - SubscribeId, // subscribe - - FetchAndSubscribe, // fetchAndSubscribe - - LoadId, // load - LoadScope, // load - LoadRoot, // load - LoadAttached, // attached - - ConvertIntToReal, // unaryop - ConvertRealToInt, // unaryop - - Real, // real_value - Int, // int_value - Bool, // bool_value - String, // string_value - - AddReal, // binaryop - AddInt, // binaryop - AddString, // binaryop - - MinusReal, // binaryop - MinusInt, // binaryop - - CompareReal, // binaryop - CompareString, // binaryop - - NotCompareReal, // binaryop - NotCompareString, // binaryop - - GreaterThanReal, // binaryop - MaxReal, // binaryop - MinReal, // binaryop - - NewString, // construct - NewUrl, // construct - - CleanupUrl, // cleanup - CleanupString, // cleanup - - Copy, // copy - Fetch, // fetch - Store, // store - - Skip, // skip - - Done, - - // Speculative property resolution - InitString, // initstring - FindGeneric, // find - FindGenericTerminal, // find - FindProperty, // find - FindPropertyTerminal, // find - CleanupGeneric, // cleanup - ConvertGenericToReal, // unaryop - ConvertGenericToBool, // unaryop - ConvertGenericToString, // unaryop - ConvertGenericToUrl, // unaryop + FOR_EACH_QML_INSTR(QML_INSTR_ENUM) }; union { struct { + QML_INSTR_HEADER quint8 type; quint8 packing[7]; } common; struct { + QML_INSTR_HEADER quint8 type; quint8 packing; quint16 column; quint32 line; } id; struct { + QML_INSTR_HEADER quint8 type; quint8 packing[3]; quint16 subscriptions; quint16 identifiers; } init; struct { + QML_INSTR_HEADER quint8 type; qint8 reg; quint16 offset; quint32 index; } subscribe; struct { + QML_INSTR_HEADER quint8 type; qint8 reg; quint8 packing[2]; quint32 index; } load; struct { + QML_INSTR_HEADER quint8 type; qint8 output; qint8 reg; @@ -430,6 +441,7 @@ struct Instr { quint32 index; } attached; struct { + QML_INSTR_HEADER quint8 type; qint8 output; qint8 reg; @@ -437,6 +449,7 @@ struct Instr { quint32 index; } store; struct { + QML_INSTR_HEADER quint8 type; qint8 output; qint8 objectReg; @@ -445,6 +458,7 @@ struct Instr { quint16 function; } fetchAndSubscribe; struct { + QML_INSTR_HEADER quint8 type; qint8 output; qint8 objectReg; @@ -452,41 +466,48 @@ struct Instr { quint32 index; } fetch; struct { + QML_INSTR_HEADER quint8 type; qint8 reg; qint8 src; quint8 packing[5]; } copy; struct { + QML_INSTR_HEADER quint8 type; qint8 reg; quint8 packing[6]; } construct; struct { + QML_INSTR_HEADER quint8 type; qint8 reg; quint8 packing[2]; float value; } real_value; struct { + QML_INSTR_HEADER quint8 type; qint8 reg; quint8 packing[2]; int value; } int_value; struct { + QML_INSTR_HEADER quint8 type; qint8 reg; bool value; quint8 packing[5]; } bool_value; struct { + QML_INSTR_HEADER quint8 type; qint8 reg; quint16 length; quint32 offset; } string_value; struct { + QML_INSTR_HEADER quint8 type; qint8 output; qint8 src1; @@ -494,18 +515,21 @@ struct Instr { quint8 packing[4]; } binaryop; struct { + QML_INSTR_HEADER quint8 type; qint8 output; qint8 src; quint8 packing[5]; } unaryop; struct { + QML_INSTR_HEADER quint8 type; qint8 reg; quint8 packing[2]; quint32 count; } skip; struct { + QML_INSTR_HEADER quint8 type; qint8 reg; qint8 src; @@ -514,11 +538,13 @@ struct Instr { quint16 subscribeIndex; } find; struct { + QML_INSTR_HEADER quint8 type; qint8 reg; quint8 packing[6]; } cleanup; struct { + QML_INSTR_HEADER quint8 type; quint8 packing[1]; quint16 offset; @@ -535,7 +561,7 @@ struct Program { quint16 subscriptions; quint16 identifiers; quint16 instructionCount; - quint16 dummy; + quint16 compiled; const char *data() const { return ((const char *)this) + sizeof(Program); } const Instr *instructions() const { return (const Instr *)(data() + dataLength); } @@ -1097,35 +1123,57 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, instr += instrIndex; const char *data = program->data(); +#ifdef QML_THREADED_INTERPRETER + static void *decode_instr[] = { + FOR_EACH_QML_INSTR(QML_INSTR_ADDR) + }; + + if (!program->compiled) { + program->compiled = true; + const Instr *inop = program->instructions(); + for (int i = 0; i < program->instructionCount; ++i) { + Instr *op = (Instr *) inop++; + op->common.code = decode_instr[op->common.type]; + } + } + + goto *instr->common.code; +#else // return; + #ifdef COMPILEDBINDINGS_DEBUG qWarning().nospace() << "Begin binding run"; #endif while (instr) { + switch (instr->common.type) { + #ifdef COMPILEDBINDINGS_DEBUG dumpInstruction(instr); #endif - switch (instr->common.type) { - case Instr::Noop: - case Instr::BindingId: - break; +#endif - case Instr::SubscribeId: + QML_BEGIN_INSTR(Noop) + QML_END_INSTR(Noop) + + QML_BEGIN_INSTR(BindingId) + QML_END_INSTR(BindingId) + + QML_BEGIN_INSTR(SubscribeId) subscribeId(context, instr->subscribe.index, instr->subscribe.offset); - break; + QML_END_INSTR(SubscribeId) - case Instr::Subscribe: + QML_BEGIN_INSTR(Subscribe) { QObject *o = 0; const Register &object = registers[instr->subscribe.reg]; if (!object.isUndefined()) o = object.getQObject(); subscribe(o, instr->subscribe.index, instr->subscribe.offset); } - break; + QML_END_INSTR(Subscribe) - case Instr::FetchAndSubscribe: + QML_BEGIN_INSTR(FetchAndSubscribe) { const Register &input = registers[instr->fetchAndSubscribe.objectReg]; Register &output = registers[instr->fetchAndSubscribe.output]; @@ -1149,21 +1197,21 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, fastProperties()->accessor(instr->fetchAndSubscribe.function)(object, output.typeDataPtr(), sub); } } - break; + QML_END_INSTR(FetchAndSubscribe) - case Instr::LoadId: + QML_BEGIN_INSTR(LoadId) registers[instr->load.reg].setQObject(context->idValues[instr->load.index].data()); - break; + QML_END_INSTR(LoadId) - case Instr::LoadScope: + QML_BEGIN_INSTR(LoadScope) registers[instr->load.reg].setQObject(scope); - break; + QML_END_INSTR(LoadScope) - case Instr::LoadRoot: + QML_BEGIN_INSTR(LoadRoot) registers[instr->load.reg].setQObject(context->contextObject); - break; + QML_END_INSTR(LoadRoot) - case Instr::LoadAttached: + QML_BEGIN_INSTR(LoadAttached) { const Register &input = registers[instr->attached.reg]; Register &output = registers[instr->attached.output]; @@ -1184,48 +1232,48 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, output.setQObject(attached); } } - break; + QML_END_INSTR(LoadAttached) - case Instr::ConvertIntToReal: + QML_BEGIN_INSTR(ConvertIntToReal) { const Register &input = registers[instr->unaryop.src]; Register &output = registers[instr->unaryop.output]; if (input.isUndefined()) output.setUndefined(); else output.setqreal(qreal(input.getint())); } - break; + QML_END_INSTR(ConvertIntToReal) - case Instr::ConvertRealToInt: + QML_BEGIN_INSTR(ConvertRealToInt) { const Register &input = registers[instr->unaryop.src]; Register &output = registers[instr->unaryop.output]; if (input.isUndefined()) output.setUndefined(); else output.setint(qRound(input.getqreal())); } - break; + QML_END_INSTR(ConvertRealToInt) - case Instr::Real: + QML_BEGIN_INSTR(Real) registers[instr->real_value.reg].setqreal(instr->real_value.value); - break; + QML_END_INSTR(Real) - case Instr::Int: + QML_BEGIN_INSTR(Int) registers[instr->int_value.reg].setint(instr->int_value.value); - break; + QML_END_INSTR(Int) - case Instr::Bool: + QML_BEGIN_INSTR(Bool) registers[instr->bool_value.reg].setbool(instr->bool_value.value); - break; + QML_END_INSTR(Bool) - case Instr::String: + QML_BEGIN_INSTR(String) { Register &output = registers[instr->string_value.reg]; new (output.getstringptr()) QString((QChar *)(data + instr->string_value.offset), instr->string_value.length); output.settype(QMetaType::QString); } - break; + QML_END_INSTR(String) - case Instr::AddReal: + QML_BEGIN_INSTR(AddReal) { const Register &lhs = registers[instr->binaryop.src1]; const Register &rhs = registers[instr->binaryop.src2]; @@ -1233,9 +1281,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN(); else output.setqreal(lhs.getqreal() + rhs.getqreal()); } - break; + QML_END_INSTR(AddReal) - case Instr::AddInt: + QML_BEGIN_INSTR(AddInt) { const Register &lhs = registers[instr->binaryop.src1]; const Register &rhs = registers[instr->binaryop.src2]; @@ -1243,9 +1291,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN(); else output.setint(lhs.getint() + rhs.getint()); } - break; + QML_END_INSTR(AddInt) - case Instr::AddString: + QML_BEGIN_INSTR(AddString) { const Register &lhs = registers[instr->binaryop.src1]; const Register &rhs = registers[instr->binaryop.src2]; @@ -1265,9 +1313,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, output.settype(QMetaType::QString); } } - break; + QML_END_INSTR(AddString) - case Instr::MinusReal: + QML_BEGIN_INSTR(MinusReal) { const Register &lhs = registers[instr->binaryop.src1]; const Register &rhs = registers[instr->binaryop.src2]; @@ -1275,9 +1323,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN(); else output.setqreal(lhs.getqreal() - rhs.getqreal()); } - break; + QML_END_INSTR(MinusReal) - case Instr::MinusInt: + QML_BEGIN_INSTR(MinusInt) { const Register &lhs = registers[instr->binaryop.src1]; const Register &rhs = registers[instr->binaryop.src2]; @@ -1285,9 +1333,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN(); else output.setint(lhs.getint() - rhs.getint()); } - break; + QML_END_INSTR(MinusInt) - case Instr::CompareReal: + QML_BEGIN_INSTR(CompareReal) { const Register &lhs = registers[instr->binaryop.src1]; const Register &rhs = registers[instr->binaryop.src2]; @@ -1295,9 +1343,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() == rhs.isUndefined()); else output.setbool(lhs.getqreal() == rhs.getqreal()); } - break; + QML_END_INSTR(CompareReal) - case Instr::CompareString: + QML_BEGIN_INSTR(CompareString) { const Register &lhs = registers[instr->binaryop.src1]; const Register &rhs = registers[instr->binaryop.src2]; @@ -1305,9 +1353,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() == rhs.isUndefined()); else output.setbool(*lhs.getstringptr() == *rhs.getstringptr()); } - break; + QML_END_INSTR(CompareString) - case Instr::NotCompareReal: + QML_BEGIN_INSTR(NotCompareReal) { const Register &lhs = registers[instr->binaryop.src1]; const Register &rhs = registers[instr->binaryop.src2]; @@ -1315,9 +1363,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() != rhs.isUndefined()); else output.setbool(lhs.getqreal() != rhs.getqreal()); } - break; + QML_END_INSTR(NotCompareReal) - case Instr::NotCompareString: + QML_BEGIN_INSTR(NotCompareString) { const Register &lhs = registers[instr->binaryop.src1]; const Register &rhs = registers[instr->binaryop.src2]; @@ -1325,9 +1373,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(lhs.isUndefined() != rhs.isUndefined()); else output.setbool(*lhs.getstringptr() != *rhs.getstringptr()); } - break; + QML_END_INSTR(NotCompareString) - case Instr::GreaterThanReal: + QML_BEGIN_INSTR(GreaterThanReal) { const Register &lhs = registers[instr->binaryop.src1]; const Register &rhs = registers[instr->binaryop.src2]; @@ -1335,9 +1383,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, if (lhs.isUndefined() || rhs.isUndefined()) output.setbool(false); else output.setbool(lhs.getqreal() > rhs.getqreal()); } - break; + QML_END_INSTR(GreaterThanReal) - case Instr::MaxReal: + QML_BEGIN_INSTR(MaxReal) { const Register &lhs = registers[instr->binaryop.src1]; const Register &rhs = registers[instr->binaryop.src2]; @@ -1345,9 +1393,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN(); else output.setqreal(qMax(lhs.getqreal(), rhs.getqreal())); } - break; + QML_END_INSTR(MaxReal) - case Instr::MinReal: + QML_BEGIN_INSTR(MinReal) { const Register &lhs = registers[instr->binaryop.src1]; const Register &rhs = registers[instr->binaryop.src2]; @@ -1355,33 +1403,33 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, if (lhs.isUndefined() || rhs.isUndefined()) output.setNaN(); else output.setqreal(qMin(lhs.getqreal(), rhs.getqreal())); } - break; + QML_END_INSTR(MinReal) - case Instr::NewString: + QML_BEGIN_INSTR(NewString) { Register &output = registers[instr->construct.reg]; new (output.getstringptr()) QString; output.settype(QMetaType::QString); } - break; + QML_END_INSTR(NewString) - case Instr::NewUrl: + QML_BEGIN_INSTR(NewUrl) { Register &output = registers[instr->construct.reg]; new (output.geturlptr()) QUrl; output.settype(QMetaType::QUrl); } - break; + QML_END_INSTR(NewUrl) - case Instr::CleanupString: + QML_BEGIN_INSTR(CleanupString) registers[instr->cleanup.reg].getstringptr()->~QString(); - break; + QML_END_INSTR(CleanupString) - case Instr::CleanupUrl: + QML_BEGIN_INSTR(CleanupUrl) registers[instr->cleanup.reg].geturlptr()->~QUrl(); - break; + QML_END_INSTR(CleanupUrl) - case Instr::Fetch: + QML_BEGIN_INSTR(Fetch) { const Register &input = registers[instr->fetch.objectReg]; Register &output = registers[instr->fetch.output]; @@ -1399,9 +1447,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, QMetaObject::metacall(object, QMetaObject::ReadProperty, instr->fetch.index, argv); } } - break; + QML_END_INSTR(Fetch) - case Instr::Store: + QML_BEGIN_INSTR(Store) { Register &data = registers[instr->store.reg]; if (data.isUndefined()) { @@ -1415,21 +1463,22 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, QMetaObject::metacall(output, QMetaObject::WriteProperty, instr->store.index, argv); } - break; + QML_END_INSTR(Store) - case Instr::Copy: + QML_BEGIN_INSTR(Copy) registers[instr->copy.reg] = registers[instr->copy.src]; - break; + QML_END_INSTR(Copy) - case Instr::Skip: + QML_BEGIN_INSTR(Skip) if (instr->skip.reg == -1 || !registers[instr->skip.reg].getbool()) instr += instr->skip.count; - break; + QML_END_INSTR(Skip) - case Instr::Done: + QML_BEGIN_INSTR(Done) return; + QML_END_INSTR(Done) - case Instr::InitString: + QML_BEGIN_INSTR(InitString) if (!identifiers[instr->initstring.offset].identifier) { quint32 len = *(quint32 *)(data + instr->initstring.dataIdx); QChar *strdata = (QChar *)(data + instr->initstring.dataIdx + sizeof(quint32)); @@ -1438,10 +1487,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, identifiers[instr->initstring.offset] = engine->objectClass->createPersistentIdentifier(str); } - break; + QML_END_INSTR(InitString) - case Instr::FindGenericTerminal: - case Instr::FindGeneric: + QML_BEGIN_INSTR(FindGenericTerminal) // We start the search in the parent context, as we know that the // name is not present in the current context or it would have been // found during the static compile @@ -1449,10 +1497,19 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, context->parent, identifiers[instr->find.name].identifier, instr->common.type == Instr::FindGenericTerminal); - break; + QML_END_INSTR(FindGenericTerminal) - case Instr::FindPropertyTerminal: - case Instr::FindProperty: + QML_BEGIN_INSTR(FindGeneric) + // We start the search in the parent context, as we know that the + // name is not present in the current context or it would have been + // found during the static compile + findgeneric(registers + instr->find.reg, instr->find.subscribeIndex, + context->parent, + identifiers[instr->find.name].identifier, + instr->common.type == Instr::FindGenericTerminal); + QML_END_INSTR(FindGeneric) + + QML_BEGIN_INSTR(FindPropertyTerminal) { const Register &object = registers[instr->find.src]; if (object.isUndefined()) { @@ -1465,9 +1522,24 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, instr->find.subscribeIndex, identifiers[instr->find.name].identifier, instr->common.type == Instr::FindPropertyTerminal); } - break; + QML_END_INSTR(FindPropertyTerminal) - case Instr::CleanupGeneric: + QML_BEGIN_INSTR(FindProperty) + { + const Register &object = registers[instr->find.src]; + if (object.isUndefined()) { + throwException(instr->find.exceptionId, error, program, context); + return; + } + + findproperty(object.getQObject(), registers + instr->find.reg, + QDeclarativeEnginePrivate::get(context->engine), + instr->find.subscribeIndex, identifiers[instr->find.name].identifier, + instr->common.type == Instr::FindPropertyTerminal); + } + QML_END_INSTR(FindProperty) + + QML_BEGIN_INSTR(CleanupGeneric) { int type = registers[instr->cleanup.reg].gettype(); if (type == qMetaTypeId()) { @@ -1478,9 +1550,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, registers[instr->cleanup.reg].geturlptr()->~QUrl(); } } - break; + QML_END_INSTR(CleanupGeneric) - case Instr::ConvertGenericToReal: + QML_BEGIN_INSTR(ConvertGenericToReal) { Register &output = registers[instr->unaryop.output]; Register &input = registers[instr->unaryop.src]; @@ -1488,9 +1560,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, output.setqreal(toReal(&input, input.gettype(), &ok)); if (!ok) output.setUndefined(); } - break; + QML_END_INSTR(ConvertGenericToReal) - case Instr::ConvertGenericToBool: + QML_BEGIN_INSTR(ConvertGenericToBool) { Register &output = registers[instr->unaryop.output]; Register &input = registers[instr->unaryop.src]; @@ -1498,9 +1570,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, output.setbool(toBool(&input, input.gettype(), &ok)); if (!ok) output.setUndefined(); } - break; + QML_END_INSTR(ConvertGenericToBool) - case Instr::ConvertGenericToString: + QML_BEGIN_INSTR(ConvertGenericToString) { Register &output = registers[instr->unaryop.output]; Register &input = registers[instr->unaryop.src]; @@ -1509,9 +1581,9 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, if (ok) { new (output.getstringptr()) QString(str); output.settype(QMetaType::QString); } else { output.setUndefined(); } } - break; + QML_END_INSTR(ConvertGenericToString) - case Instr::ConvertGenericToUrl: + QML_BEGIN_INSTR(ConvertGenericToUrl) { Register &output = registers[instr->unaryop.output]; Register &input = registers[instr->unaryop.src]; @@ -1520,15 +1592,19 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex, if (ok) { new (output.geturlptr()) QUrl(url); output.settype(QMetaType::QUrl); } else { output.setUndefined(); } } - break; + QML_END_INSTR(ConvertGenericToUrl) +#ifdef QML_THREADED_INTERPRETER + // nothing to do +#else default: qFatal("EEK"); break; - } + } // switch - instr++; - } + ++instr; + } // while +#endif } void QDeclarativeBindingCompiler::dump(const QByteArray &programData) @@ -2781,6 +2857,7 @@ QByteArray QDeclarativeBindingCompiler::program() const prog.subscriptions = d->committed.subscriptionIds.count(); prog.identifiers = d->committed.registeredStrings.count(); prog.instructionCount = bytecode.count(); + prog.compiled = false; int size = sizeof(Program) + bytecode.count() * sizeof(Instr); size += prog.dataLength; -- cgit v0.12 From 14ecb79de540af894e779fcc11937c82ffda8cc8 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 19 May 2010 14:29:24 +1000 Subject: Don't crash if the target parent is destroyed. Task-number: QTBUG-10755 --- src/declarative/util/qdeclarativestateoperations.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp index b11c0c2..80ae5f5 100644 --- a/src/declarative/util/qdeclarativestateoperations.cpp +++ b/src/declarative/util/qdeclarativestateoperations.cpp @@ -69,7 +69,7 @@ public: rewindParent(0), rewindStackBefore(0) {} QDeclarativeItem *target; - QDeclarativeItem *parent; + QDeclarativeGuard parent; QDeclarativeGuard origParent; QDeclarativeGuard origStackBefore; QDeclarativeItem *rewindParent; -- cgit v0.12 From 399bb3dbeacc1d055191c200bbbc2ab262a8eb9b Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 19 May 2010 08:23:52 +0200 Subject: Rename qml executable to qmlviewer Revert the name of the 'qml' executable back to qmlviewer (QMLViewer on mac). --- doc/src/declarative/qmlruntime.qdoc | 8 ++++---- tools/qml/main.cpp | 4 ++-- tools/qml/qml.pro | 2 ++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/doc/src/declarative/qmlruntime.qdoc b/doc/src/declarative/qmlruntime.qdoc index a03b9c2..cef5e63 100644 --- a/doc/src/declarative/qmlruntime.qdoc +++ b/doc/src/declarative/qmlruntime.qdoc @@ -42,7 +42,7 @@ /*! \page qmlruntime.html \title Qt Declarative UI Runtime - \keyword QML Viewer (qml) + \keyword QML Viewer \ingroup qttools This page documents the \e{Declarative UI Runtime} for the Qt GUI @@ -67,7 +67,7 @@ To run an application with the \QQV, pass the filename as an argument: \code - qml myQmlFile.qml + qmlviewer myQmlFile.qml \endcode Deploying a QML application via the \QQV allows for QML only deployments, but can also @@ -92,7 +92,7 @@ as the appropriate module file is chosen based on platform naming conventions. The C++ modules must contain a QDeclarativeExtentionPlugin subclass. - The application would be executed either with your own application, the command 'qml MyApp.qml' or by + The application would be executed either with your own application, the command 'qmlviewer MyApp.qml' or by opening the file if your system has the \QQV registered as the handler for QML files. The MyApp.qml file would have access to all of the deployed types using the import statements such as the following: @@ -109,7 +109,7 @@ \section2 Options - When run with the \c -help option, \c qml shows available options. + When run with the \c -help option, \c qmlviewer shows available options. \section2 Translations diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 22fc5ca..0cce1cc 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -110,7 +110,7 @@ void myMessageOutput(QtMsgType type, const char *msg) void usage() { - qWarning("Usage: qml [options] "); + qWarning("Usage: qmlviewer [options] "); qWarning(" "); qWarning(" options:"); qWarning(" -v, -version ............................. display version"); @@ -148,7 +148,7 @@ void usage() void scriptOptsUsage() { - qWarning("Usage: qml -scriptopts