diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-05-19 14:55:11 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-05-19 14:55:11 (GMT) |
commit | 83df329a42107764889f46b9019a37804c36776a (patch) | |
tree | b80e45fb0df8f8384724a9a788a61d30e9d2751c | |
parent | 8a97a1cac688d0e6e6aef40bfa396a81d7bfc0b8 (diff) | |
parent | e758b6fcbda482d1482c2a7258413711801bd746 (diff) | |
download | Qt-83df329a42107764889f46b9019a37804c36776a.zip Qt-83df329a42107764889f46b9019a37804c36776a.tar.gz Qt-83df329a42107764889f46b9019a37804c36776a.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: (37 commits)
Search for QML import libraries also in application directory
Doc improvements
Disable mouse-based selection in TextInput/TextEdit
Rename qml executable to qmlviewer
Don't crash if the target parent is destroyed.
Introduce a threaded interpreter for QML binding bytecode
Bug moved.
doc
doc
Remove image example (covered in class docs)
When changing Loader source, remove old item from scene immediately.
Add missing .qmlproject files
Fix folderlistmodel with qt namespace
Renaming "Qml Launcher" back to "QML Viewer"
Rename some examples: proxyviewer -> networkaccessmanagerfactory,
Regression fix for Loader anchors not working
Make Qt.include() work for js files that have '.pragma library'
doc fix
Improve docs for Qt.quit()
Prevent assignment of values (string, number, bool) to signal handlers.
...
148 files changed, 2840 insertions, 860 deletions
@@ -60,6 +60,7 @@ bin/lrelease* bin/lupdate* bin/lconvert* bin/moc* +bin/makeqpf* bin/pixeltool* bin/qmake* bin/qdoc3* diff --git a/demos/declarative/photoviewer/PhotoViewerCore/Button.qml b/demos/declarative/photoviewer/PhotoViewerCore/Button.qml index c681064..5be096a 100644 --- a/demos/declarative/photoviewer/PhotoViewerCore/Button.qml +++ b/demos/declarative/photoviewer/PhotoViewerCore/Button.qml @@ -4,7 +4,7 @@ Item { id: container property alias label: labelText.text - property color tint: "#FFFFFFFF" + property string tint: "" signal clicked width: labelText.width + 70 ; height: labelText.height + 18 @@ -19,7 +19,7 @@ Item { Rectangle { anchors.fill: container; color: container.tint; visible: container.tint != "" - opacity: 0.1; smooth: true + opacity: 0.25; smooth: true } Text { id: labelText; font.pixelSize: 15; anchors.centerIn: parent; smooth: true } diff --git a/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml b/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml index ccfda02..15ffe56 100644 --- a/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml +++ b/demos/declarative/photoviewer/PhotoViewerCore/EditableButton.qml @@ -4,11 +4,10 @@ Item { id: container property string label - property color tint: "#FFFFFFFF" signal clicked signal labelChanged(string label) - width: labelText.width + 70 ; height: labelText.height + 18 + width: textInput.width + 70 ; height: textInput.height + 18 BorderImage { anchors { fill: container; leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 } @@ -18,36 +17,25 @@ Item { Image { anchors.fill: parent; source: "images/cardboard.png"; smooth: true } - Rectangle { - anchors.fill: container; color: container.tint; visible: container.tint != "" - opacity: 0.1; smooth: true - } - - Text { id: labelText; text: label; font.pixelSize: 15; anchors.centerIn: parent; smooth: true } - TextInput { - id: textInput; text: label; font.pixelSize: 15; anchors.centerIn: parent; smooth: true; visible: false - Keys.onReturnPressed: container.labelChanged(textInput.text) + id: textInput; text: label; font.pixelSize: 15; anchors.centerIn: parent; smooth: true + Keys.onReturnPressed: { + container.labelChanged(textInput.text) + container.focus = true + } Keys.onEscapePressed: { - textInput.text = labelText.text - container.state = '' + textInput.text = container.label + container.focus = true } } - MouseArea { - anchors { fill: parent; leftMargin: -20; topMargin: -20; rightMargin: -20; bottomMargin: -20 } - onClicked: container.state = "editMode" - } - - states: State { - name: "editMode" - PropertyChanges { target: container; width: textInput.width + 70; height: textInput.height + 17 } - PropertyChanges { target: textInput; visible: true; focus: true } - PropertyChanges { target: labelText; visible: false } + Rectangle { + anchors.fill: container; border.color: "steelblue"; border.width: 4 + color: "transparent"; visible: textInput.focus; smooth: true } - onLabelChanged: { - labelText.text = label - container.state = '' + MouseArea { + anchors { fill: parent; leftMargin: -20; topMargin: -20; rightMargin: -20; bottomMargin: -20 } + onClicked: textInput.forceFocus() } } diff --git a/examples/declarative/toys/velocity/velocity.qmlproject b/demos/declarative/rssnews/rssnews.qmlproject index d4909f8..d4909f8 100644 --- a/examples/declarative/toys/velocity/velocity.qmlproject +++ b/demos/declarative/rssnews/rssnews.qmlproject diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc index cdc308a..5b8c937 100644 --- a/doc/src/declarative/examples.qdoc +++ b/doc/src/declarative/examples.qdoc @@ -82,7 +82,6 @@ For example, from your build directory, run: \section2 Image Elements \list \o \l{declarative/imageelements/borderimage}{BorderImage} -\o \l{declarative/imageelements/image}{Image} \endlist \section2 \l{declarative/positioners}{Positioners} @@ -122,7 +121,6 @@ For example, from your build directory, run: \section2 XML \list -\o \l{declarative/xml/xmldata}{XML data} \o \l{declarative/xml/xmlhttprequest}{XmlHttpRequest} \endlist @@ -140,20 +138,20 @@ For example, from your build directory, run: \list \o \l{declarative/cppextensions/referenceexamples}{Reference examples} (discussed in \l {Extending QML in C++}) \o \l{declarative/cppextensions/plugins}{Plugins} -\o \l{declarative/cppextensions/proxywidgets}{QtWidgets} \o \l{declarative/cppextensions/qgraphicslayouts}{QGraphicsLayouts} +\o \l{declarative/cppextensions/qwidgets}{QWidgets} \o \l{declarative/cppextensions/imageprovider}{Image provider} -\o \l{declarative/cppextensions/proxyviewer}{Network access manager factory} +\o \l{declarative/cppextensions/networkaccessmanagerfactory}{Network access manager factory} \endlist \section2 Toys \list \o \l{declarative/toys/clocks}{Clocks} +\o \l{declarative/toys/corkboards}{Corkboards} \o \l{declarative/toys/dial}{Dial} -\o \l{declarative/toys/dynamic}{Dynamic} +\o \l{declarative/toys/dynamicscene}{Dynamic Scene} \o \l{declarative/toys/tic-tac-toe}{Tic Tac Toe} \o \l{declarative/toys/tvtennis}{TV Tennis} -\o \l{declarative/toys/velocity}{Velocity} \endlist @@ -161,12 +159,19 @@ For example, from your build directory, run: \list \o \l{demos/declarative/calculator}{Calculator} +\o \l{demos/declarative/flickr}{Flickr Mobile} \o \l{demos/declarative/minehunt}{Minehunt} \o \l{demos/declarative/photoviewer}{Photo Viewer} -\o \l{demos/declarative/flickr}{Flickr Mobile} +\o \l{demos/declarative/rssnews}{RSS News Reader} \o \l{demos/declarative/samegame}{Same Game} \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/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc index 5b695f7..574b0b2 100644 --- a/doc/src/declarative/extending.qdoc +++ b/doc/src/declarative/extending.qdoc @@ -61,8 +61,11 @@ QML for their own independent use. The QML snippet shown above instantiates one \c Person instance and sets the \c name and \c shoeSize properties on it. Everything in QML ultimately comes down to either instantiating an object instance, or assigning a property a value. + QML relies heavily on Qt's meta object system and can only instantiate classes -that derive from QObject. +that derive from QObject. For visual element types, this will usually mean a subclass +of QDeclarativeItem; for models used with the view elements, a subclass of QAbstractItemModel; +and for abitrary objects with properties, a direct subclass of QObject. The QML engine has no intrinsic knowledge of any class types. Instead the programmer must register the C++ types with their corresponding QML names. diff --git a/doc/src/declarative/focus.qdoc b/doc/src/declarative/focus.qdoc index e2b8bb6..4c4a317 100644 --- a/doc/src/declarative/focus.qdoc +++ b/doc/src/declarative/focus.qdoc @@ -67,7 +67,12 @@ item and thus subsequently be \l {QEvent::ignore()}{ignored}. \code Item { Item { - Keys.onPressed: if (event.key == Qt.Key_A) { console.log('Key A was pressed'); event.accepted = true } + Keys.onPressed: { + if (event.key == Qt.Key_A) { + console.log('Key A was pressed'); + event.accepted = true; + } + } Rectangle {} } } diff --git a/doc/src/declarative/globalobject.qdoc b/doc/src/declarative/globalobject.qdoc index 2a83e30..c29a796 100644 --- a/doc/src/declarative/globalobject.qdoc +++ b/doc/src/declarative/globalobject.qdoc @@ -219,8 +219,9 @@ Binary to ASCII - this function returns a base64 encoding of \c data. ASCII to binary - this function returns a base64 decoding of \c data. \section3 Qt.quit() -This function causes the QML engine to emit the quit signal, which in -\l {Qt Declarative UI Runtime}{qml} causes the runtime to quit. +This function causes the QDeclarativeEngine::quit() signal to be emitted. +Within the \l {Qt Declarative UI Runtime}{qml} application this causes the +launcher application to exit. \section3 Qt.resolvedUrl(url) This function returns \c url resolved relative to the URL of the diff --git a/doc/src/declarative/pics/trivialListView.png b/doc/src/declarative/pics/listview-highlight.png Binary files differindex dc5c6b3..dc5c6b3 100644 --- a/doc/src/declarative/pics/trivialListView.png +++ b/doc/src/declarative/pics/listview-highlight.png diff --git a/doc/src/declarative/pics/listview-simple.png b/doc/src/declarative/pics/listview-simple.png Binary files differnew file mode 100644 index 0000000..71a1c51 --- /dev/null +++ b/doc/src/declarative/pics/listview-simple.png diff --git a/doc/src/declarative/qdeclarativemodels.qdoc b/doc/src/declarative/qdeclarativemodels.qdoc index 788d417..109d390 100644 --- a/doc/src/declarative/qdeclarativemodels.qdoc +++ b/doc/src/declarative/qdeclarativemodels.qdoc @@ -99,7 +99,8 @@ There are a number of QML elements that operate using data models: \endlist QML supports several types of data model, which may be provided by QML -or C++ (via QDeclarativeContext::setContextProperty(), for example). +or C++ (via QDeclarativeContext::setContextProperty() or as plugin types, +for example). \section1 QML Data Models @@ -210,8 +211,13 @@ will be positioned by the view. \section1 C++ Data Models +Models defined in C++ can be made available to QML either from a C++ application or from a +\l{QDeclarativeExtensionPlugin}{QML C++ plugin}. + \section2 QAbstractItemModel +A model can be defined by subclassing QAbstractItemModel. + QAbstractItemModel provides the roles set via the QAbstractItemModel::setRoleNames() method. The default role names set by Qt are: @@ -227,7 +233,18 @@ The default role names set by Qt are: \o decoration \endtable -QAbstractItemModel presents a heirachy of tables. Views currently provided by QML +The model could be made available to QML either directly: + +\code +QDeclarativeContext *ctxt = view.rootContext(); +MyModel *model = new MyModel; // subclass of QAbstractItemModel +ctxt->setContextProperty("myModel", model); +\endcode + +or by registering the subclass as a new QML type in +a \l{QDeclarativeExtensionPlugin}{QML C++ plugin}. + +QAbstractItemModel presents a heirachy of tables, but views currently provided by QML can only display list data. In order to display child lists of a heirachical model the VisualDataModel element provides several properties and functions for use @@ -242,7 +259,7 @@ with models of type QAbstractItemModel: \section2 QStringList -QStringList provides the contents of the list via the \e modelData role: +A model may be a simple QStringList, which provides the contents of the list via the \e modelData role: \table \row diff --git a/doc/src/declarative/qmlruntime.qdoc b/doc/src/declarative/qmlruntime.qdoc index b105df4..cef5e63 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 \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 + qmlviewer 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 '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: \code @@ -101,15 +101,15 @@ 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. \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/doc/src/examples/qml-examples.qdoc b/doc/src/examples/qml-examples.qdoc index 22113ee..7a0fcca 100644 --- a/doc/src/examples/qml-examples.qdoc +++ b/doc/src/examples/qml-examples.qdoc @@ -71,13 +71,6 @@ */ /*! - \title Image - \example declarative/imageelements/image - - This example shows uses of the \l Image element in QML. -*/ - -/*! \title Reference examples \example declarative/cppextensions/referenceexamples */ @@ -88,13 +81,13 @@ */ /*! - \title QtWidgets - \example declarative/cppextensions/proxywidgets + \title QGraphicsLayouts + \example declarative/cppextensions/qgraphicslayouts */ /*! - \title QGraphicsLayouts - \example declarative/cppextensions/qgraphicslayouts + \title QWidgets + \example declarative/cppextensions/qwidgets */ /*! @@ -104,7 +97,7 @@ /*! \title Network access manager - \example declarative/cppextensions/proxyviewer + \example declarative/cppextensions/networkaccessmanagerfactory */ /*! @@ -175,7 +168,7 @@ */ /*! - \title Threaded ListModel + \title Threaded ListModel \example declarative/threading/threadedlistmodel */ @@ -192,6 +185,11 @@ */ /*! + \title Corkboards + \example declarative/toys/corkboards +*/ + +/*! \title Dial \example declarative/toys/dial @@ -199,8 +197,8 @@ */ /*! - \title Dynamic - \example declarative/toys/dynamic + \title Dynamic Scene + \example declarative/toys/dynamicscene This example shows how to create dynamic objects QML. */ @@ -216,11 +214,6 @@ */ /*! - \title Velocity - \example declarative/toys/velocity -*/ - -/*! \title Gestures \example declarative/touchinteraction/gestures */ @@ -268,11 +261,6 @@ */ /*! - \title XML Data - \example declarative/xml/xmldata -*/ - -/*! \title XMLHttpRequest \example declarative/xml/xmlhttprequest */ diff --git a/doc/src/examples/qml-folderlistmodel.qdoc b/doc/src/examples/qml-folderlistmodel.qdoc new file mode 100644 index 0000000..b820528 --- /dev/null +++ b/doc/src/examples/qml-folderlistmodel.qdoc @@ -0,0 +1,144 @@ +/**************************************************************************** +** +** 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 + +\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 + +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/examples/qml-rssnews.qdoc b/doc/src/examples/qml-rssnews.qdoc new file mode 100644 index 0000000..0e7bdef --- /dev/null +++ b/doc/src/examples/qml-rssnews.qdoc @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** 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 RSS News + \example demos/declarative/rssnews + + This demo shows how to write a RSS news reader in QML. + + \image qml-rssnews-example.png +*/ diff --git a/doc/src/images/declarative-folderlistmodel.png b/doc/src/images/declarative-folderlistmodel.png Binary files differnew file mode 100644 index 0000000..a469f96 --- /dev/null +++ b/doc/src/images/declarative-folderlistmodel.png diff --git a/doc/src/images/qml-rssnews-example.png b/doc/src/images/qml-rssnews-example.png Binary files differnew file mode 100644 index 0000000..948ef4d --- /dev/null +++ b/doc/src/images/qml-rssnews-example.png 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/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/dummydata/ContactModel.qml b/doc/src/snippets/declarative/listview/ContactModel.qml index 20687cf..b930c06 100644 --- a/doc/src/snippets/declarative/listview/dummydata/ContactModel.qml +++ b/doc/src/snippets/declarative/listview/ContactModel.qml @@ -1,7 +1,7 @@ +//![0] import Qt 4.7 ListModel { - id: contactModel ListElement { name: "Bill Smith" number: "555 3264" @@ -15,3 +15,4 @@ ListModel { number: "555 0473" } } +//![0] 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..1e9ccd9 100644 --- a/doc/src/snippets/declarative/listview/listview.qml +++ b/doc/src/snippets/declarative/listview/listview.qml @@ -1,49 +1,101 @@ +//![import] import Qt 4.7 +//![import] -//! [3] -Rectangle { - width: 180; height: 200; color: "white" +Item { + +//![classdocs simple] +ListView { + width: 180; height: 200 + + model: ContactModel {} + delegate: Text { + text: name + ": " + number + } +} +//![classdocs simple] - // ContactModel model is defined in dummydata/ContactModel.qml - // The launcher automatically loads files in dummydata/* to assist - // development without a real data source. +//![classdocs advanced] +Rectangle { + width: 180; height: 200 - // Define a delegate component. A component will be - // instantiated for each visible item in the list. -//! [0] Component { - id: delegate + id: contactDelegate Item { - id: wrapper width: 180; height: 40 Column { - x: 5; y: 5 Text { text: '<b>Name:</b> ' + name } Text { text: '<b>Number:</b> ' + number } } } } -//! [0] - // Define a highlight component. Just one of these will be instantiated - // by each ListView and placed behind the current item. -//! [1] - Component { - id: highlight - Rectangle { - color: "lightsteelblue" - radius: 5 - } - } -//! [1] - // The actual list -//! [2] + ListView { - width: parent.width; height: parent.height - model: ContactModel - delegate: delegate - highlight: highlight + anchors.fill: parent + model: ContactModel {} + delegate: contactDelegate + highlight: Rectangle { color: "lightsteelblue"; radius: 5 } focus: true } -//! [2] } -//! [3] +//![classdocs advanced] + +//![delayRemove] +Component { + id: delegate + Item { + ListView.onRemove: SequentialAnimation { + PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true } + NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing.type: Easing.InOutQuad } + PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false } + } + } +} +//![delayRemove] + +//![highlightFollowsCurrentItem] +Component { + id: highlight + Rectangle { + width: 180; height: 40 + color: "lightsteelblue"; radius: 5 + SpringFollow on y { + to: list.currentItem.y + spring: 3 + damping: 0.2 + } + } +} + +ListView { + id: list + width: 180; height: 200 + model: ContactModel {} + delegate: Text { text: name } + + highlight: highlight + highlightFollowsCurrentItem: false + focus: true +} +//![highlightFollowsCurrentItem] + +//![isCurrentItem] +ListView { + width: 180; height: 200 + + Component { + id: contactsDelegate + Text { + id: contactInfo + text: name + ": " + number + color: contactInfo.ListView.isCurrentItem ? "red" : "black" + } + } + + model: ContactModel {} + delegate: contactsDelegate + focus: true +} +//![isCurrentItem] + +} diff --git a/examples/declarative/cppextensions/cppextensions.pro b/examples/declarative/cppextensions/cppextensions.pro index caa6092..33762fe 100644 --- a/examples/declarative/cppextensions/cppextensions.pro +++ b/examples/declarative/cppextensions/cppextensions.pro @@ -3,8 +3,8 @@ TEMPLATE = subdirs SUBDIRS += \ imageprovider \ plugins \ - proxyviewer \ - proxywidgets \ + networkaccessmanagerfactory \ + qwidgets \ qgraphicslayouts \ referenceexamples diff --git a/examples/declarative/cppextensions/proxyviewer/main.cpp b/examples/declarative/cppextensions/networkaccessmanagerfactory/main.cpp index b82d2c9..4ecbb5c 100644 --- a/examples/declarative/cppextensions/proxyviewer/main.cpp +++ b/examples/declarative/cppextensions/networkaccessmanagerfactory/main.cpp @@ -53,7 +53,7 @@ create a QNetworkAccessManager with a proxy. Usage: - proxyviewer [-host <proxy> -port <port>] [file] + networkaccessmanagerfactory [-host <proxy> -port <port>] [file] */ static QString proxyHost; @@ -93,7 +93,7 @@ int main(int argc, char ** argv) } else if (arg[0] != '-') { source = QUrl::fromLocalFile(arg); } else { - qWarning() << "Usage: proxyviewer [-host <proxy> -port <port>] [file]"; + qWarning() << "Usage: networkaccessmanagerfactory [-host <proxy> -port <port>] [file]"; exit(1); } } diff --git a/examples/declarative/cppextensions/proxyviewer/proxyviewer.pro b/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro index b6bfa7f..74d8db3 100644 --- a/examples/declarative/cppextensions/proxyviewer/proxyviewer.pro +++ b/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro @@ -1,9 +1,9 @@ TEMPLATE = app -TARGET = proxyviewer +TARGET = networkaccessmanagerfactory DEPENDPATH += . INCLUDEPATH += . QT += declarative network # Input SOURCES += main.cpp -RESOURCES += proxyviewer.qrc +RESOURCES += networkaccessmanagerfactory.qrc diff --git a/examples/declarative/toys/dynamic/dynamic.qmlproject b/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject index d4909f8..d4909f8 100644 --- a/examples/declarative/toys/dynamic/dynamic.qmlproject +++ b/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject diff --git a/examples/declarative/cppextensions/proxyviewer/proxyviewer.qrc b/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc index 17e9301..17e9301 100644 --- a/examples/declarative/cppextensions/proxyviewer/proxyviewer.qrc +++ b/examples/declarative/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc diff --git a/examples/declarative/cppextensions/proxyviewer/view.qml b/examples/declarative/cppextensions/networkaccessmanagerfactory/view.qml index 7f1bdef..7f1bdef 100644 --- a/examples/declarative/cppextensions/proxyviewer/view.qml +++ b/examples/declarative/cppextensions/networkaccessmanagerfactory/view.qml diff --git a/examples/declarative/cppextensions/proxywidgets/README b/examples/declarative/cppextensions/proxywidgets/README deleted file mode 100644 index f50fa22..0000000 --- a/examples/declarative/cppextensions/proxywidgets/README +++ /dev/null @@ -1,4 +0,0 @@ -To run: - - make install - qml proxywidgets.qml diff --git a/examples/declarative/imageelements/image/image.qmlproject b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicsLayouts.qmlproject index d4909f8..d4909f8 100644 --- a/examples/declarative/imageelements/image/image.qmlproject +++ b/examples/declarative/cppextensions/qgraphicslayouts/graphicsLayouts/graphicsLayouts.qmlproject diff --git a/examples/declarative/cppextensions/proxywidgets/proxywidgets.qmlproject b/examples/declarative/cppextensions/qgraphicslayouts/layoutItem/layoutItem.qmlproject index d4909f8..d4909f8 100644 --- a/examples/declarative/cppextensions/proxywidgets/proxywidgets.qmlproject +++ b/examples/declarative/cppextensions/qgraphicslayouts/layoutItem/layoutItem.qmlproject diff --git a/examples/declarative/cppextensions/proxywidgets/ProxyWidgets/qmldir b/examples/declarative/cppextensions/qwidgets/QWidgets/qmldir index e55267c..e55267c 100644 --- a/examples/declarative/cppextensions/proxywidgets/ProxyWidgets/qmldir +++ b/examples/declarative/cppextensions/qwidgets/QWidgets/qmldir diff --git a/examples/declarative/cppextensions/qwidgets/README b/examples/declarative/cppextensions/qwidgets/README new file mode 100644 index 0000000..e2f1b2b --- /dev/null +++ b/examples/declarative/cppextensions/qwidgets/README @@ -0,0 +1,6 @@ +This example shows how to embed QWidget-based objects into QML. + +To run: + + make install + qml qwidgets.qml diff --git a/examples/declarative/cppextensions/proxywidgets/proxywidgets.cpp b/examples/declarative/cppextensions/qwidgets/qwidgets.cpp index 067eb2c..228f9f1 100644 --- a/examples/declarative/cppextensions/proxywidgets/proxywidgets.cpp +++ b/examples/declarative/cppextensions/qwidgets/qwidgets.cpp @@ -82,7 +82,7 @@ private: QPushButton *widget; }; -class ProxyWidgetsPlugin : public QDeclarativeExtensionPlugin +class QWidgetsPlugin : public QDeclarativeExtensionPlugin { Q_OBJECT public: @@ -92,6 +92,6 @@ public: } }; -#include "proxywidgets.moc" +#include "qwidgets.moc" -Q_EXPORT_PLUGIN2(proxywidgetsplugin, ProxyWidgetsPlugin); +Q_EXPORT_PLUGIN2(qwidgetsplugin, QWidgetsPlugin); diff --git a/examples/declarative/cppextensions/proxywidgets/proxywidgets.pro b/examples/declarative/cppextensions/qwidgets/qwidgets.pro index cb07d80..37f313d 100644 --- a/examples/declarative/cppextensions/proxywidgets/proxywidgets.pro +++ b/examples/declarative/cppextensions/qwidgets/qwidgets.pro @@ -1,12 +1,12 @@ TEMPLATE = lib -DESTDIR = ProxyWidgets -TARGET = proxywidgetsplugin +DESTDIR = QWidgets +TARGET = qwidgetsplugin CONFIG += qt plugin QT += declarative -SOURCES += proxywidgets.cpp +SOURCES += qwidgets.cpp -sources.files += proxywidgets.pro proxywidgets.cpp proxywidgets.qml +sources.files += qwidgets.pro qwidgets.cpp qwidgets.qml sources.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins @@ -18,4 +18,4 @@ symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) symbian:{ TARGET.EPOCALLOWDLLDATA = 1 -}
\ No newline at end of file +} diff --git a/examples/declarative/cppextensions/proxywidgets/proxywidgets.qml b/examples/declarative/cppextensions/qwidgets/qwidgets.qml index 88de37f..47f9573 100644 --- a/examples/declarative/cppextensions/proxywidgets/proxywidgets.qml +++ b/examples/declarative/cppextensions/qwidgets/qwidgets.qml @@ -1,5 +1,5 @@ import Qt 4.7 -import "ProxyWidgets" 1.0 +import "QWidgets" 1.0 Rectangle { id: window diff --git a/examples/declarative/cppextensions/qwidgets/qwidgets.qmlproject b/examples/declarative/cppextensions/qwidgets/qwidgets.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/cppextensions/qwidgets/qwidgets.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/imageelements/image/face_fit.qml b/examples/declarative/imageelements/image/face_fit.qml deleted file mode 100644 index 52cd4c2..0000000 --- a/examples/declarative/imageelements/image/face_fit.qml +++ /dev/null @@ -1,26 +0,0 @@ -import Qt 4.7 - -// Here, we implement a hybrid of the "scale to fit" and "scale and crop" -// behaviours which will crop up to 25% from *one* dimension if necessary -// to fully scale the other. This is a realistic algorithm, for example -// when the edges of the image contain less vital information than the -// center - such as a face. -// -Rectangle { - // default size: whole image, unscaled - width: face.width - height: face.height - color: "gray" - clip: true - - Image { - id: face - smooth: true - anchors.centerIn: parent - source: "pics/face.png" - x: (parent.width-width*scale)/2 - y: (parent.height-height*scale)/2 - scale: Math.max(Math.min(parent.width/width*1.333,parent.height/height), - Math.min(parent.width/width,parent.height/height*1.333)) - } -} diff --git a/examples/declarative/imageelements/image/face_fit_animated.qml b/examples/declarative/imageelements/image/face_fit_animated.qml deleted file mode 100644 index 63fc9c6..0000000 --- a/examples/declarative/imageelements/image/face_fit_animated.qml +++ /dev/null @@ -1,28 +0,0 @@ -import Qt 4.7 - -// Here, we extend the "face_fit" example with animation to show how truly -// diverse and usage-specific behaviours are made possible by NOT putting a -// hard-coded aspect ratio feature into the Image primitive. -// -Rectangle { - // default size: whole image, unscaled - width: face.width - height: face.height - color: "gray" - clip: true - - Image { - id: face - smooth: true - anchors.centerIn: parent - source: "pics/face.png" - x: (parent.width-width*scale)/2 - y: (parent.height-height*scale)/2 - SpringFollow on scale { - to: Math.max(Math.min(face.parent.width/face.width*1.333,face.parent.height/face.height), - Math.min(face.parent.width/face.width,face.parent.height/face.height*1.333)) - spring: 1 - damping: 0.05 - } - } -} diff --git a/examples/declarative/imageelements/image/pics/face.png b/examples/declarative/imageelements/image/pics/face.png Binary files differdeleted file mode 100644 index 3d66d72..0000000 --- a/examples/declarative/imageelements/image/pics/face.png +++ /dev/null diff --git a/examples/declarative/imageelements/image/scale_and_crop.qml b/examples/declarative/imageelements/image/scale_and_crop.qml deleted file mode 100644 index a438104..0000000 --- a/examples/declarative/imageelements/image/scale_and_crop.qml +++ /dev/null @@ -1,21 +0,0 @@ -import Qt 4.7 - -// Here, we implement "Scale and Crop" behaviour. -// -Rectangle { - // default size: whole image, unscaled - width: face.width - height: face.height - color: "gray" - clip: true - - Image { - id: face - smooth: true - anchors.centerIn: parent - source: "pics/face.png" - x: (parent.width-width*scale)/2 - y: (parent.height-height*scale)/2 - scale: Math.max(parent.width/width,parent.height/height) - } -} diff --git a/examples/declarative/imageelements/image/scale_and_crop_simple.qml b/examples/declarative/imageelements/image/scale_and_crop_simple.qml deleted file mode 100644 index 1160ec5..0000000 --- a/examples/declarative/imageelements/image/scale_and_crop_simple.qml +++ /dev/null @@ -1,20 +0,0 @@ -import Qt 4.7 - -// Here, we implement "Scale to Fit" behaviour, using the -// fillMode property. -// -Rectangle { - // default size: whole image, unscaled - width: face.width - height: face.height - color: "gray" - clip: true - - Image { - id: face - smooth: true - source: "pics/face.png" - fillMode: Image.PreserveAspectCrop - anchors.fill: parent - } -} diff --git a/examples/declarative/imageelements/image/scale_and_sidecrop.qml b/examples/declarative/imageelements/image/scale_and_sidecrop.qml deleted file mode 100644 index 5593ab8..0000000 --- a/examples/declarative/imageelements/image/scale_and_sidecrop.qml +++ /dev/null @@ -1,22 +0,0 @@ -import Qt 4.7 - -// Here, we implement a variant of "Scale and Crop" behaviour, where we -// crop the sides if necessary to fully fit vertically, but not the reverse. -// -Rectangle { - // default size: whole image, unscaled - width: face.width - height: face.height - color: "gray" - clip: true - - Image { - id: face - smooth: true - anchors.centerIn: parent - source: "pics/face.png" - x: (parent.width-width*scale)/2 - y: (parent.height-height*scale)/2 - scale: parent.height/height - } -} diff --git a/examples/declarative/imageelements/image/scale_to_fit.qml b/examples/declarative/imageelements/image/scale_to_fit.qml deleted file mode 100644 index 724a36e..0000000 --- a/examples/declarative/imageelements/image/scale_to_fit.qml +++ /dev/null @@ -1,22 +0,0 @@ -import Qt 4.7 - -// Here, we implement "Scale to Fit" behaviour "manually", rather -// than using the preserveAspect property. -// -Rectangle { - // default size: whole image, unscaled - width: face.width - height: face.height - color: "gray" - clip: true - - Image { - id: face - smooth: true - anchors.centerIn: parent - source: "pics/face.png" - x: (parent.width-width*scale)/2 - y: (parent.height-height*scale)/2 - scale: Math.min(parent.width/width,parent.height/height) - } -} diff --git a/examples/declarative/imageelements/image/scale_to_fit_simple.qml b/examples/declarative/imageelements/image/scale_to_fit_simple.qml deleted file mode 100644 index 0e960b4..0000000 --- a/examples/declarative/imageelements/image/scale_to_fit_simple.qml +++ /dev/null @@ -1,20 +0,0 @@ -import Qt 4.7 - -// Here, we implement "Scale to Fit" behaviour, using the -// fillMode property. -// -Rectangle { - // default size: whole image, unscaled - width: face.width - height: face.height - color: "gray" - clip: true - - Image { - id: face - smooth: true - source: "pics/face.png" - fillMode: Image.PreserveAspectFit - anchors.fill: parent - } -} diff --git a/examples/declarative/toys/velocity/Day.qml b/examples/declarative/toys/corkboards/Day.qml index 350c1c4..350c1c4 100644 --- a/examples/declarative/toys/velocity/Day.qml +++ b/examples/declarative/toys/corkboards/Day.qml diff --git a/examples/declarative/toys/velocity/cork.jpg b/examples/declarative/toys/corkboards/cork.jpg Binary files differindex 160bc00..160bc00 100644 --- a/examples/declarative/toys/velocity/cork.jpg +++ b/examples/declarative/toys/corkboards/cork.jpg diff --git a/examples/declarative/toys/velocity/velocity.qml b/examples/declarative/toys/corkboards/corkboards.qml index 871bafc..871bafc 100644 --- a/examples/declarative/toys/velocity/velocity.qml +++ b/examples/declarative/toys/corkboards/corkboards.qml diff --git a/examples/declarative/toys/corkboards/corkboards.qmlproject b/examples/declarative/toys/corkboards/corkboards.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/toys/corkboards/corkboards.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/toys/velocity/note-yellow.png b/examples/declarative/toys/corkboards/note-yellow.png Binary files differindex 8ddecc8..8ddecc8 100644 --- a/examples/declarative/toys/velocity/note-yellow.png +++ b/examples/declarative/toys/corkboards/note-yellow.png diff --git a/examples/declarative/toys/velocity/tack.png b/examples/declarative/toys/corkboards/tack.png Binary files differindex cef2d1c..cef2d1c 100644 --- a/examples/declarative/toys/velocity/tack.png +++ b/examples/declarative/toys/corkboards/tack.png diff --git a/examples/declarative/toys/dynamic/dynamic.qml b/examples/declarative/toys/dynamicscene/dynamicscene.qml index 52c7c1e..52c7c1e 100644 --- a/examples/declarative/toys/dynamic/dynamic.qml +++ b/examples/declarative/toys/dynamicscene/dynamicscene.qml diff --git a/examples/declarative/toys/dynamicscene/dynamicscene.qmlproject b/examples/declarative/toys/dynamicscene/dynamicscene.qmlproject new file mode 100644 index 0000000..d4909f8 --- /dev/null +++ b/examples/declarative/toys/dynamicscene/dynamicscene.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ " ../exampleplugin " ] +} diff --git a/examples/declarative/toys/dynamic/images/NOTE b/examples/declarative/toys/dynamicscene/images/NOTE index fcd87f9..fcd87f9 100644 --- a/examples/declarative/toys/dynamic/images/NOTE +++ b/examples/declarative/toys/dynamicscene/images/NOTE diff --git a/examples/declarative/toys/dynamic/images/face-smile.png b/examples/declarative/toys/dynamicscene/images/face-smile.png Binary files differindex 3d66d72..3d66d72 100644 --- a/examples/declarative/toys/dynamic/images/face-smile.png +++ b/examples/declarative/toys/dynamicscene/images/face-smile.png diff --git a/examples/declarative/toys/dynamic/images/moon.png b/examples/declarative/toys/dynamicscene/images/moon.png Binary files differindex 1c0d606..1c0d606 100644 --- a/examples/declarative/toys/dynamic/images/moon.png +++ b/examples/declarative/toys/dynamicscene/images/moon.png diff --git a/examples/declarative/toys/dynamic/images/rabbit_brown.png b/examples/declarative/toys/dynamicscene/images/rabbit_brown.png Binary files differindex ebfdeed..ebfdeed 100644 --- a/examples/declarative/toys/dynamic/images/rabbit_brown.png +++ b/examples/declarative/toys/dynamicscene/images/rabbit_brown.png diff --git a/examples/declarative/toys/dynamic/images/rabbit_bw.png b/examples/declarative/toys/dynamicscene/images/rabbit_bw.png Binary files differindex 7bff9b9..7bff9b9 100644 --- a/examples/declarative/toys/dynamic/images/rabbit_bw.png +++ b/examples/declarative/toys/dynamicscene/images/rabbit_bw.png diff --git a/examples/declarative/toys/dynamic/images/star.png b/examples/declarative/toys/dynamicscene/images/star.png Binary files differindex 27ef924..27ef924 100644 --- a/examples/declarative/toys/dynamic/images/star.png +++ b/examples/declarative/toys/dynamicscene/images/star.png diff --git a/examples/declarative/toys/dynamic/images/sun.png b/examples/declarative/toys/dynamicscene/images/sun.png Binary files differindex 7713ca5..7713ca5 100644 --- a/examples/declarative/toys/dynamic/images/sun.png +++ b/examples/declarative/toys/dynamicscene/images/sun.png diff --git a/examples/declarative/toys/dynamic/images/tree_s.png b/examples/declarative/toys/dynamicscene/images/tree_s.png Binary files differindex 6eac35a..6eac35a 100644 --- a/examples/declarative/toys/dynamic/images/tree_s.png +++ b/examples/declarative/toys/dynamicscene/images/tree_s.png diff --git a/examples/declarative/toys/dynamic/qml/Button.qml b/examples/declarative/toys/dynamicscene/qml/Button.qml index 963a850..963a850 100644 --- a/examples/declarative/toys/dynamic/qml/Button.qml +++ b/examples/declarative/toys/dynamicscene/qml/Button.qml diff --git a/examples/declarative/toys/dynamic/qml/PaletteItem.qml b/examples/declarative/toys/dynamicscene/qml/PaletteItem.qml index dcb5cc3..dcb5cc3 100644 --- a/examples/declarative/toys/dynamic/qml/PaletteItem.qml +++ b/examples/declarative/toys/dynamicscene/qml/PaletteItem.qml diff --git a/examples/declarative/toys/dynamic/qml/PerspectiveItem.qml b/examples/declarative/toys/dynamicscene/qml/PerspectiveItem.qml index c04d3dc..c04d3dc 100644 --- a/examples/declarative/toys/dynamic/qml/PerspectiveItem.qml +++ b/examples/declarative/toys/dynamicscene/qml/PerspectiveItem.qml diff --git a/examples/declarative/toys/dynamic/qml/Sun.qml b/examples/declarative/toys/dynamicscene/qml/Sun.qml index 43dcb9a..43dcb9a 100644 --- a/examples/declarative/toys/dynamic/qml/Sun.qml +++ b/examples/declarative/toys/dynamicscene/qml/Sun.qml diff --git a/examples/declarative/toys/dynamic/qml/itemCreation.js b/examples/declarative/toys/dynamicscene/qml/itemCreation.js index 59750f3..59750f3 100644 --- a/examples/declarative/toys/dynamic/qml/itemCreation.js +++ b/examples/declarative/toys/dynamicscene/qml/itemCreation.js diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index ec8f508..c121a2d 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -18,9 +18,14 @@ C++ API QDeclarativeExpression::value() has been renamed to QDeclarativeExpression::evaluate() -QML Launcher +The QDeclarativeExpression constructor has changed from + QDeclarativeExpression(context, expression, scope) +to + QDeclarativeExpression(context, scope, expression, parent = 0) + +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/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp index fe642e0..4593cf8 100644 --- a/src/declarative/graphicsitems/qdeclarativeimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp @@ -58,10 +58,8 @@ QT_BEGIN_NAMESPACE \table \row - \o - \image declarative-qtlogo.png - \o - \qml + \o \image declarative-qtlogo.png + \o \qml import Qt 4.7 Image { source: "qtlogo.png" } @@ -281,14 +279,27 @@ qreal QDeclarativeImage::paintedHeight() const (although it reflects what has happened with the image internally). If you wish to react to the change in status you need to do it yourself, for example in one of the following ways: - \list - \o Create a state, so that a state change occurs, e.g. - \qml State { name: 'loaded'; when: image.status = Image.Ready } \endqml - \o Do something inside the onStatusChanged signal handler, e.g. - \qml Image { id: image; onStatusChanged: if (image.status == Image.Ready) console.log('Loaded') } \endqml - \o Bind to the status variable somewhere, e.g. - \qml Text { text: if (image.status != Image.Ready) { 'Not Loaded' } else { 'Loaded' } } \endqml - \endlist + + Use this status to provide an update or respond to the status change in some way. + For example, you could: + + \e {Trigger a state change:} + \qml + State { name: 'loaded'; when: image.status = Image.Ready } + \endqml + + \e {Implement an \c onStatusChanged signal handler:} + \qml + Image { + id: image + onStatusChanged: if (image.status == Image.Ready) console.log('Loaded') + } + \endqml + + \e {Bind to the status value:} + \qml + Text { text: image.status != Image.Ready ? 'Not Loaded' : 'Loaded' } + \endqml \sa progress */ diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 936f9b0..23a6f63 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -1308,23 +1308,43 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m \inherits Flickable \brief The ListView item provides a list view of items provided by a model. - The model is typically provided by a QAbstractListModel "C++ model object", - but can also be created directly in QML. The items are laid out vertically - or horizontally and may be flicked to scroll. - - The below example creates a very simple vertical list, using a QML model. - \image trivialListView.png - - The user interface defines a delegate to display an item, a highlight, - and the ListView which uses the above. - - \snippet doc/src/snippets/declarative/listview/listview.qml 3 - - The model is defined as a ListModel using QML: - \quotefile doc/src/snippets/declarative/listview/dummydata/ContactModel.qml - - In this case ListModel is a handy way for us to test our UI. In practice - the model would be implemented in C++, or perhaps via a SQL data source. + A ListView displays data from models created from built-in QML elements like ListModel + and XmlListModel, or custom model classes defined in C++ that inherit from + QAbstractListModel. + + A ListView has a \l model, which defines the data to be displayed, and + a \l delegate, which defines how the data should be displayed. Items in a + ListView are laid out horizontally or vertically. List views are inherently flickable + as ListView inherits from \l Flickable. + + For example, if there is a simple list model defined in a file \c ContactModel.qml like this: + + \snippet doc/src/snippets/declarative/listview/ContactModel.qml 0 + + A ListView can display the data in the model, like this: + + \table + \row + \o \snippet doc/src/snippets/declarative/listview/listview.qml import + \codeline + \snippet doc/src/snippets/declarative/listview/listview.qml classdocs simple + \o \image listview-simple.png + \endtable + + Here, the ListView creates a \c ContactModel component for its model, and a \l Text element + for its delegate. The view creates a new \l Text component for each item in the model. Note + the delegate is able to access the model's \c name and \c number data directly. + + An improved list view is shown below. The delegate is visually improved and is moved + into a separate \c contactDelegate component. Also, the currently selected item is highlighted + with a blue \l Rectangle using the \l highlight property, and \c focus is set to \c true + to enable keyboard navigation for the list. + + \table + \row + \o \snippet doc/src/snippets/declarative/listview/listview.qml classdocs advanced + \o \image listview-highlight.png + \endtable Delegates are instantiated as needed and may be destroyed at any time. State should \e never be stored in a delegate. @@ -1360,7 +1380,7 @@ QDeclarativeListView::~QDeclarativeListView() This property may be used to adjust the appearance of the current item, for example: - \snippet doc/src/snippets/declarative/listview/highlight.qml 0 + \snippet doc/src/snippets/declarative/listview/listview.qml isCurrentItem */ /*! @@ -1397,22 +1417,10 @@ QDeclarativeListView::~QDeclarativeListView() It is sometimes necessary to delay the destruction of an item until an animation completes. - The example below ensures that the animation completes before + The example delegate below ensures that the animation completes before the item is removed from the list. - \code - Component { - id: myDelegate - Item { - id: wrapper - ListView.onRemove: SequentialAnimation { - PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true } - NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing.type: Easing.InOutQuad } - PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false } - } - } - } - \endcode + \snippet doc/src/snippets/declarative/listview/listview.qml delayRemove */ /*! @@ -1429,13 +1437,10 @@ QDeclarativeListView::~QDeclarativeListView() \qmlproperty model ListView::model This property holds the model providing data for the list. - The model provides a set of data that is used to create the items - for the view. For large or dynamic datasets the model is usually - provided by a C++ model object. The C++ model object must be a \l - {QAbstractItemModel} subclass or a simple list. - - Models can also be created directly in QML, using a \l{ListModel}, - \l{XmlListModel} or \l{VisualItemModel}. + The model provides the set of data that is used to create the items + in the view. Models can be created directly in QML using \l ListModel, \l XmlListModel + or \l VisualItemModel, or provided by C++ model classes. If a C++ model class is + used, it must be a subclass of \l QAbstractItemModel or a simple list. \sa {qmlmodels}{Data Models} */ @@ -1511,11 +1516,11 @@ void QDeclarativeListView::setModel(const QVariant &model) that is not needed for the normal display of the delegate in a \l Loader which can load additional elements when needed. - Note that the ListView will layout the items based on the size of the root item + Tthe ListView will lay out the items based on the size of the root item in the delegate. - Here is an example delegate: - \snippet doc/src/snippets/declarative/listview/listview.qml 0 + \note Delegates are instantiated as needed and may be destroyed at any time. + State should \e never be stored in a delegate. */ QDeclarativeComponent *QDeclarativeListView::delegate() const { @@ -1591,10 +1596,9 @@ QDeclarativeItem *QDeclarativeListView::currentItem() /*! \qmlproperty Item ListView::highlightItem - \c highlightItem holds the highlight item, which was created - from the \l highlight component. + This holds the highlight item created from the \l highlight component. - The highlightItem is managed by the view unless + The \c highlightItem is managed by the view unless \l highlightFollowsCurrentItem is set to false. \sa highlight, highlightFollowsCurrentItem @@ -1623,17 +1627,11 @@ int QDeclarativeListView::count() const \qmlproperty Component ListView::highlight This property holds the component to use as the highlight. - An instance of the highlight component will be created for each list. - The geometry of the resultant component instance will be managed by the list + An instance of the highlight component is created for each list. + The geometry of the resultant component instance is managed by the list so as to stay with the current item, unless the highlightFollowsCurrentItem property is false. - The below example demonstrates how to make a simple highlight - for a vertical list. - - \snippet doc/src/snippets/declarative/listview/listview.qml 1 - \image trivialListView.png - \sa highlightItem, highlightFollowsCurrentItem */ QDeclarativeComponent *QDeclarativeListView::highlight() const @@ -1658,13 +1656,14 @@ void QDeclarativeListView::setHighlight(QDeclarativeComponent *highlight) \qmlproperty bool ListView::highlightFollowsCurrentItem This property holds whether the highlight is managed by the view. - If highlightFollowsCurrentItem is true, the highlight will be moved smoothly - to follow the current item. If highlightFollowsCurrentItem is false, the - highlight will not be moved by the view, and must be implemented - by the highlight. The following example creates a highlight with - its motion defined by the spring \l {SpringFollow}: + If this property is true, the highlight is moved smoothly + to follow the current item. Otherwise, the + highlight is not moved by the view, and any movement must be implemented + by the highlight. + + Here is a highlight with its motion defined by the a \l {SpringFollow} item: - \snippet doc/src/snippets/declarative/listview/highlight.qml 1 + \snippet doc/src/snippets/declarative/listview/listview.qml highlightFollowsCurrentItem Note that the highlight animation also affects the way that the view is scrolled. This is because the view moves to maintain the @@ -1695,31 +1694,29 @@ void QDeclarativeListView::setHighlightFollowsCurrentItem(bool autoHighlight) \qmlproperty enumeration ListView::highlightRangeMode These properties set the preferred range of the highlight (current item) - within the view. - - Note that this is the correct way to influence where the - current item ends up when the list scrolls. For example, if you want the - currently selected item to be in the middle of the list, then set the - highlight range to be where the middle item would go. Then, when the list scrolls, - the currently selected item will be the item at that spot. This also applies to - when the currently selected item changes - it will scroll to within the preferred - highlight range. Furthermore, the behaviour of the current item index will occur - whether or not a highlight exists. - - If highlightRangeMode is set to \e ListView.ApplyRange the view will - attempt to maintain the highlight within the range, however - the highlight can move outside of the range at the ends of the list - or due to a mouse interaction. - - If highlightRangeMode is set to \e ListView.StrictlyEnforceRange the highlight will never - move outside of the range. This means that the current item will change - if a keyboard or mouse action would cause the highlight to move - outside of the range. - - The default value is \e ListView.NoHighlightRange. - - Note that a valid range requires preferredHighlightEnd to be greater - than or equal to preferredHighlightBegin. + within the view. The \c preferredHighlightEnd must be greater than or equal to + \c preferredHighlightBegin. + + These properties affect the position of the current item when the list is scrolled. + For example, if the currently selected item should stay in the middle of the + list when the view is scrolled, set the \c preferredHighlightBegin and + \c preferredHighlightEnd values to the top and bottom coordinates of where the middle + item would be. If the \c currentItem is changed programmatically, the list will + automatically scroll so that the current item is in the middle of the view. + Furthermore, the behavior of the current item index will occur whether or not a + highlight exists. + + Valid values for \c highlightRangeMode are: + + \list + \o ListView.ApplyRange - the view attempts to maintain the highlight within the range. + However, the highlight can move outside of the range at the ends of the list or due + to mouse interaction. + \o ListView.StrictlyEnforceRange - the highlight never moves outside of the range. + The current item changes if a keyboard or mouse action would cause the highlight to move + outside of the range. + \o ListView.NoHighlightRange - this is the default value. + \endlist */ qreal QDeclarativeListView::preferredHighlightBegin() const { @@ -1772,7 +1769,7 @@ void QDeclarativeListView::setHighlightRangeMode(HighlightRangeMode mode) /*! \qmlproperty real ListView::spacing - This property holds the spacing to leave between items. + This property holds the spacing between items. */ qreal QDeclarativeListView::spacing() const { @@ -1794,12 +1791,22 @@ void QDeclarativeListView::setSpacing(qreal spacing) \qmlproperty enumeration ListView::orientation This property holds the orientation of the list. - Possible values are \c Vertical (default) and \c Horizontal. + Possible values: - ListView.Vertical Example: - \image trivialListView.png - ListView.Horizontal Example: + \list + \o ListView.Horizontal - Items are laid out horizontally. + \o ListView.Vertical - Items are laid out vertically. This is the default value. + \endlist + + \table + \row + \o Horizontal orientation: \image ListViewHorizontal.png + + \row + \o Vertical orientation: + \image listview-highlight.png + \endtable */ QDeclarativeListView::Orientation QDeclarativeListView::orientation() const { @@ -1829,10 +1836,11 @@ void QDeclarativeListView::setOrientation(QDeclarativeListView::Orientation orie /*! \qmlproperty bool ListView::keyNavigationWraps - This property holds whether the list wraps key navigation + This property holds whether the list wraps key navigation. - If this property is true then key presses to move off of one end of the list will cause the - current item to jump to the other end. + If this is true, key navigation that would move the current item selection + past the end of the list instead wraps around and moves the selection to + the start of the list, and vice-versa. */ bool QDeclarativeListView::isWrapEnabled() const { @@ -1854,8 +1862,8 @@ void QDeclarativeListView::setWrapEnabled(bool wrap) This property determines whether delegates are retained outside the visible area of the view. - If non-zero the view will keep as many delegates - instantiated as will fit within the buffer specified. For example, + If this value is non-zero, the view keeps as many delegates + instantiated as it can fit within the buffer specified. For example, if in a vertical view the delegate is 20 pixels high and \c cacheBuffer is set to 40, then up to 2 delegates above and 2 delegates below the visible area may be retained. @@ -1863,9 +1871,9 @@ void QDeclarativeListView::setWrapEnabled(bool wrap) Note that cacheBuffer is not a pixel buffer - it only maintains additional instantiated delegates. - Setting this value can make scrolling the list smoother at the expense + Setting this value can improve the smoothness of scrolling behavior at the expense of additional memory usage. It is not a substitute for creating efficient - delegates; the fewer elements in a delegate, the faster a view may be + delegates; the fewer elements in a delegate, the faster a view can be scrolled. */ int QDeclarativeListView::cacheBuffer() const @@ -1890,13 +1898,14 @@ void QDeclarativeListView::setCacheBuffer(int b) /*! \qmlproperty string ListView::section.property \qmlproperty enumeration ListView::section.criteria - These properties hold the expression to be evaluated for the section attached property. + These properties hold the expression to be evaluated for the \l section attached property. - section.property hold the name of the property to use to determine - the section the item is in. + \c section.property hold the name of the property to use to determine + the section that holds the item. - section.criteria holds the criteria to use to get the section. It + \c section.criteria holds the criteria to use to access the section. It can be either: + \list \o ViewSection.FullString (default) - section is the value of the property. \o ViewSection.FirstCharacter - section is the first character of the property value. @@ -1935,9 +1944,10 @@ QString QDeclarativeListView::currentSection() const \qmlproperty int ListView::highlightMoveDuration \qmlproperty real ListView::highlightResizeSpeed \qmlproperty int ListView::highlightResizeDuration + These properties hold the move and resize animation speed of the highlight delegate. - highlightFollowsCurrentItem must be true for these properties + \c highlightFollowsCurrentItem must be true for these properties to have effect. The default value for the speed properties is 400 pixels/second. @@ -2019,21 +2029,21 @@ void QDeclarativeListView::setHighlightResizeDuration(int duration) /*! \qmlproperty enumeration ListView::snapMode - This property determines where the view will settle following a drag or flick. + This property determines where the view's scrolling behavior stops following a drag or flick. The allowed values are: \list - \o ListView.NoSnap (default) - the view will stop anywhere within the visible area. - \o ListView.SnapToItem - the view will settle with an item aligned with the start of + \o ListView.NoSnap (default) - the view stops anywhere within the visible area. + \o ListView.SnapToItem - the view settles with an item aligned with the start of the view. - \o ListView.SnapOneItem - the view will settle no more than one item away from the first + \o ListView.SnapOneItem - the view settles no more than one item away from the first visible item at the time the mouse button is released. This mode is particularly useful for moving one page at a time. \endlist - snapMode does not affect the currentIndex. To update the - currentIndex as the list is moved set \e highlightRangeMode - to \e ListView.StrictlyEnforceRange. + \c snapMode does not affect the \l currentIndex. To update the + \l currentIndex as the list is moved, set \l highlightRangeMode + to \c ListView.StrictlyEnforceRange. \sa highlightRangeMode */ @@ -2335,23 +2345,23 @@ void QDeclarativeListView::decrementCurrentIndex() \a mode: \list - \o Beginning - position item at the top (or left for horizontal orientation) of the view. - \o Center- position item in the center of the view. - \o End - position item at bottom (or right for horizontal orientation) of the view. - \o Visible - if any part of the item is visible then take no action, otherwise + \o ListView.Beginning - position item at the top (or left for horizontal orientation) of the view. + \o ListView.Center - position item in the center of the view. + \o ListView.End - position item at bottom (or right for horizontal orientation) of the view. + \o ListView.Visible - if any part of the item is visible then take no action, otherwise bring the item into view. - \o Contain - ensure the entire item is visible. If the item is larger than + \o ListView.Contain - ensure the entire item is visible. If the item is larger than the view the item is positioned at the top (or left for horizontal orientation) of the view. \endlist - If positioning the view at the index would cause empty space to be displayed at + If positioning the view at \a index would cause empty space to be displayed at the beginning or end of the view, the view will be positioned at the boundary. - It is not recommended to use contentX or contentY to position the view + It is not recommended to use \l {Flickable::}{contentX} or \l {Flickable::}{contentY} to position the view at a particular index. This is unreliable since removing items from the start of the list does not cause all other items to be repositioned, and because the actual start of the view can vary based on the size of the delegates. - The correct way to bring an item into view is with positionViewAtIndex. + The correct way to bring an item into view is with \c positionViewAtIndex. */ void QDeclarativeListView::positionViewAtIndex(int index, int mode) { diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp index cbdfd87..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; } @@ -366,6 +370,7 @@ QDeclarativeLoader::Status QDeclarativeLoader::status() const void QDeclarativeLoader::componentComplete() { + QDeclarativeItem::componentComplete(); if (status() == Ready) emit loaded(); } diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 45b79a7..40d37a2 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -773,6 +773,33 @@ void QDeclarativeTextEdit::componentComplete() } /*! + \qmlproperty string TextEdit::selectByMouse + + Defaults to false. + + If true, the user can use the mouse to select text in some + platform-specific way. Note that for some platforms this may + not be an appropriate interaction (eg. may conflict with how + the text needs to behave inside a Flickable. +*/ +bool QDeclarativeTextEdit::selectByMouse() const +{ + Q_D(const QDeclarativeTextEdit); + return d->selectByMouse; +} + +void QDeclarativeTextEdit::setSelectByMouse(bool on) +{ + Q_D(QDeclarativeTextEdit); + if (d->selectByMouse != on) { + d->selectByMouse = on; + emit selectByMouseChanged(on); + } +} + + + +/*! \qmlproperty bool TextEdit::readOnly Whether the user an interact with the TextEdit item. If this @@ -914,7 +941,8 @@ void QDeclarativeTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event) } if (!hadFocus && hasFocus()) d->clickCausedFocus = true; - d->control->processEvent(event, QPointF(0, 0)); + if (event->type() != QEvent::GraphicsSceneMouseDoubleClick || d->selectByMouse) + d->control->processEvent(event, QPointF(0, 0)); if (!event->isAccepted()) QDeclarativePaintedItem::mousePressEvent(event); } @@ -943,9 +971,13 @@ Handles the given mouse \a event. void QDeclarativeTextEdit::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) { Q_D(QDeclarativeTextEdit); - d->control->processEvent(event, QPointF(0, 0)); - if (!event->isAccepted()) + if (d->selectByMouse) { + d->control->processEvent(event, QPointF(0, 0)); + if (!event->isAccepted()) + QDeclarativePaintedItem::mouseDoubleClickEvent(event); + } else { QDeclarativePaintedItem::mouseDoubleClickEvent(event); + } } /*! @@ -955,10 +987,14 @@ Handles the given mouse \a event. void QDeclarativeTextEdit::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { Q_D(QDeclarativeTextEdit); - d->control->processEvent(event, QPointF(0, 0)); - if (!event->isAccepted()) + if (d->selectByMouse) { + d->control->processEvent(event, QPointF(0, 0)); + if (!event->isAccepted()) + QDeclarativePaintedItem::mouseMoveEvent(event); + event->setAccepted(true); + } else { QDeclarativePaintedItem::mouseMoveEvent(event); - event->setAccepted(true); + } } /*! diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p.h index 474de09..8848d47 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextedit_p.h @@ -86,6 +86,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeTextEdit : public QDeclarativePaintedItem Q_PROPERTY(bool persistentSelection READ persistentSelection WRITE setPersistentSelection NOTIFY persistentSelectionChanged) Q_PROPERTY(qreal textMargin READ textMargin WRITE setTextMargin NOTIFY textMarginChanged) Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints) + Q_PROPERTY(bool selectByMouse READ selectByMouse WRITE setSelectByMouse NOTIFY selectByMouseChanged) public: QDeclarativeTextEdit(QDeclarativeItem *parent=0); @@ -167,6 +168,9 @@ public: qreal textMargin() const; void setTextMargin(qreal margin); + bool selectByMouse() const; + void setSelectByMouse(bool); + virtual void componentComplete(); /* FROM EDIT */ @@ -200,6 +204,7 @@ Q_SIGNALS: void focusOnPressChanged(bool focusIsPressed); void persistentSelectionChanged(bool isPersistentSelection); void textMarginChanged(qreal textMargin); + void selectByMouseChanged(bool selectByMouse); public Q_SLOTS: void selectAll(); diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h index 5e19c3d..885620d 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextedit_p_p.h @@ -72,7 +72,8 @@ public: imgDirty(true), dirty(false), richText(false), cursorVisible(false), focusOnPress(true), persistentSelection(true), clickCausedFocus(false), textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0), cursorComponent(0), cursor(0), format(QDeclarativeTextEdit::AutoText), document(0), - wrapMode(QDeclarativeTextEdit::NoWrap) + wrapMode(QDeclarativeTextEdit::NoWrap), + selectByMouse(false) { } @@ -110,6 +111,7 @@ public: QTextDocument *document; QTextControl *control; QDeclarativeTextEdit::WrapMode wrapMode; + bool selectByMouse; }; QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 8aa7e99..2e7715f 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -907,8 +907,12 @@ void QDeclarativeTextInput::mousePressEvent(QGraphicsSceneMouseEvent *event) void QDeclarativeTextInput::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { Q_D(QDeclarativeTextInput); - d->control->moveCursor(d->xToPos(event->pos().x()), true); - event->setAccepted(true); + if (d->selectByMouse) { + d->control->moveCursor(d->xToPos(event->pos().x()), true); + event->setAccepted(true); + } else { + QDeclarativePaintedItem::mouseMoveEvent(event); + } } /*! @@ -939,6 +943,8 @@ bool QDeclarativeTextInput::event(QEvent* ev) case QEvent::GraphicsSceneMouseRelease: break; default: + if (ev->type() == QEvent::GraphicsSceneMouseDoubleClick && !d->selectByMouse) + break; handled = d->control->processEvent(ev); if (ev->type() == QEvent::InputMethod) updateSize(); @@ -1114,6 +1120,32 @@ QString QDeclarativeTextInput::displayText() const } /*! + \qmlproperty string TextInput::selectByMouse + + Defaults to false. + + If true, the user can use the mouse to select text in some + platform-specific way. Note that for some platforms this may + not be an appropriate interaction (eg. may conflict with how + the text needs to behave inside a Flickable. +*/ +bool QDeclarativeTextInput::selectByMouse() const +{ + Q_D(const QDeclarativeTextInput); + return d->selectByMouse; +} + +void QDeclarativeTextInput::setSelectByMouse(bool on) +{ + Q_D(QDeclarativeTextInput); + if (d->selectByMouse != on) { + d->selectByMouse = on; + emit selectByMouseChanged(on); + } +} + + +/*! \qmlmethod void TextInput::moveCursorSelection(int position) Moves the cursor to \a position and updates the selection accordingly. diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p.h index c0c1e50..b2fd057 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextinput_p.h @@ -89,6 +89,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeTextInput : public QDeclarativePaintedIte Q_PROPERTY(QString passwordCharacter READ passwordCharacter WRITE setPasswordCharacter NOTIFY passwordCharacterChanged) Q_PROPERTY(QString displayText READ displayText NOTIFY displayTextChanged) Q_PROPERTY(bool autoScroll READ autoScroll WRITE setAutoScroll NOTIFY autoScrollChanged) + Q_PROPERTY(bool selectByMouse READ selectByMouse WRITE setSelectByMouse NOTIFY selectByMouseChanged) public: QDeclarativeTextInput(QDeclarativeItem* parent=0); @@ -174,6 +175,9 @@ public: bool autoScroll() const; void setAutoScroll(bool); + bool selectByMouse() const; + void setSelectByMouse(bool); + bool hasAcceptableInput() const; void drawContents(QPainter *p,const QRect &r); @@ -203,6 +207,7 @@ Q_SIGNALS: void displayTextChanged(const QString &text); void focusOnPressChanged(bool focusOnPress); void autoScrollChanged(bool autoScroll); + void selectByMouseChanged(bool selectByMouse); protected: virtual void geometryChanged(const QRectF &newGeometry, diff --git a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h index 99866b8..1d8e0f7 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativetextinput_p_p.h @@ -72,7 +72,8 @@ public: color((QRgb)0), style(QDeclarativeText::Normal), styleColor((QRgb)0), hAlign(QDeclarativeTextInput::AlignLeft), hscroll(0), oldScroll(0), focused(false), focusOnPress(true), - cursorVisible(false), autoScroll(true), clickCausedFocus(false) + cursorVisible(false), autoScroll(true), clickCausedFocus(false), + selectByMouse(false) { } @@ -117,6 +118,7 @@ public: bool cursorVisible; bool autoScroll; bool clickCausedFocus; + bool selectByMouse; }; QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index 0e4217e..291378f 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -204,7 +204,7 @@ QVariant QDeclarativeVisualItemModel::evaluate(int index, const QString &express QDeclarativeContext *ccontext = qmlContext(this); QDeclarativeContext *ctxt = new QDeclarativeContext(ccontext); ctxt->setContextObject(d->children.at(index)); - QDeclarativeExpression e(ctxt, expression, objectContext); + QDeclarativeExpression e(ctxt, objectContext, expression); QVariant value = e.evaluate(); delete ctxt; return value; @@ -775,9 +775,6 @@ void QDeclarativeVisualDataModel::setModel(const QVariant &model) The delegate provides a template defining each item instantiated by a view. The index is exposed as an accessible \c index property. Properties of the model are also available depending upon the type of \l {qmlmodels}{Data Model}. - - Here is an example delegate: - \snippet doc/src/snippets/declarative/listview/listview.qml 0 */ QDeclarativeComponent *QDeclarativeVisualDataModel::delegate() const { @@ -1176,7 +1173,7 @@ QVariant QDeclarativeVisualDataModel::evaluate(int index, const QString &express if (nobj) { QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(nobj); if (item) { - QDeclarativeExpression e(qmlContext(item), expression, objectContext); + QDeclarativeExpression e(qmlContext(item), objectContext, expression); value = e.evaluate(); } } else { @@ -1185,7 +1182,7 @@ QVariant QDeclarativeVisualDataModel::evaluate(int index, const QString &express QDeclarativeContext *ctxt = new QDeclarativeContext(ccontext); QDeclarativeVisualDataModelData *data = new QDeclarativeVisualDataModelData(index, this); ctxt->setContextObject(data); - QDeclarativeExpression e(ctxt, expression, objectContext); + QDeclarativeExpression e(ctxt, objectContext, expression); value = e.evaluate(); delete data; delete ctxt; diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp index 2e905b9..8230941 100644 --- a/src/declarative/qml/qdeclarativebinding.cpp +++ b/src/declarative/qml/qdeclarativebinding.cpp @@ -88,7 +88,7 @@ QDeclarativeBinding::QDeclarativeBinding(void *data, QDeclarativeRefCount *rc, Q QDeclarativeBinding::QDeclarativeBinding(const QString &str, QObject *obj, QDeclarativeContext *ctxt, QObject *parent) -: QDeclarativeExpression(QDeclarativeContextData::get(ctxt), str, obj, *new QDeclarativeBindingPrivate) +: QDeclarativeExpression(QDeclarativeContextData::get(ctxt), obj, str, *new QDeclarativeBindingPrivate) { setParent(parent); setNotifyOnValueChanged(true); @@ -96,7 +96,7 @@ QDeclarativeBinding::QDeclarativeBinding(const QString &str, QObject *obj, QDecl QDeclarativeBinding::QDeclarativeBinding(const QString &str, QObject *obj, QDeclarativeContextData *ctxt, QObject *parent) -: QDeclarativeExpression(ctxt, str, obj, *new QDeclarativeBindingPrivate) +: QDeclarativeExpression(ctxt, obj, str, *new QDeclarativeBindingPrivate) { setParent(parent); setNotifyOnValueChanged(true); diff --git a/src/declarative/qml/qdeclarativeboundsignal.cpp b/src/declarative/qml/qdeclarativeboundsignal.cpp index 89f1256..8769122 100644 --- a/src/declarative/qml/qdeclarativeboundsignal.cpp +++ b/src/declarative/qml/qdeclarativeboundsignal.cpp @@ -119,7 +119,7 @@ QDeclarativeBoundSignal::QDeclarativeBoundSignal(QDeclarativeContext *ctxt, cons QDeclarative_setParent_noEvent(this, parent); QMetaObject::connect(scope, m_signal.methodIndex(), this, evaluateIdx); - m_expression = new QDeclarativeExpression(ctxt, val, scope); + m_expression = new QDeclarativeExpression(ctxt, scope, val); } QDeclarativeBoundSignal::~QDeclarativeBoundSignal() diff --git a/src/declarative/qml/qdeclarativecompiledbindings.cpp b/src/declarative/qml/qdeclarativecompiledbindings.cpp index f55d330..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(int(input.getqreal())); + 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<QVariant>()) { @@ -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; diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index a43b9ac..b5bf972 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -180,7 +180,7 @@ bool QDeclarativeCompiler::isSignalPropertyName(const QByteArray &name) bool QDeclarativeCompiler::testLiteralAssignment(const QMetaProperty &prop, QDeclarativeParser::Value *v) { - QString string = v->value.asScript(); + QString string = v->value.asString(); if (!prop.isWritable()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: \"%1\" is a read-only property").arg(QString::fromUtf8(prop.name()))); @@ -207,31 +207,31 @@ bool QDeclarativeCompiler::testLiteralAssignment(const QMetaProperty &prop, break; case QVariant::UInt: { - bool ok; - string.toUInt(&ok); - if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: unsigned int expected")); + bool ok = v->value.isNumber(); + if (ok) { + double n = v->value.asNumber(); + if (double(uint(n)) != n) + ok = false; + } + if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: unsigned int expected")); } break; case QVariant::Int: { - bool ok; - string.toInt(&ok); - if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: int expected")); + bool ok = v->value.isNumber(); + if (ok) { + double n = v->value.asNumber(); + if (double(int(n)) != n) + ok = false; + } + if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: int expected")); } break; case QMetaType::Float: - { - bool ok; - string.toFloat(&ok); - if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: float expected")); - } + if (!v->value.isNumber()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: float expected")); break; case QVariant::Double: - { - bool ok; - string.toDouble(&ok); - if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: double expected")); - } + if (!v->value.isNumber()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: double expected")); break; case QVariant::Color: { @@ -319,7 +319,7 @@ bool QDeclarativeCompiler::testLiteralAssignment(const QMetaProperty &prop, void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop, QDeclarativeParser::Value *v) { - QString string = v->value.asScript(); + QString string = v->value.asString(); QDeclarativeInstruction instr; instr.line = v->location.start.line; @@ -382,28 +382,28 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop, { instr.type = QDeclarativeInstruction::StoreInteger; instr.storeInteger.propertyIndex = prop.propertyIndex(); - instr.storeInteger.value = string.toUInt(); + instr.storeInteger.value = uint(v->value.asNumber()); } break; case QVariant::Int: { instr.type = QDeclarativeInstruction::StoreInteger; instr.storeInteger.propertyIndex = prop.propertyIndex(); - instr.storeInteger.value = string.toInt(); + instr.storeInteger.value = int(v->value.asNumber()); } break; case QMetaType::Float: { instr.type = QDeclarativeInstruction::StoreFloat; instr.storeFloat.propertyIndex = prop.propertyIndex(); - instr.storeFloat.value = string.toFloat(); + instr.storeFloat.value = float(v->value.asNumber()); } break; case QVariant::Double: { instr.type = QDeclarativeInstruction::StoreDouble; instr.storeDouble.propertyIndex = prop.propertyIndex(); - instr.storeDouble.value = string.toDouble(); + instr.storeDouble.value = v->value.asNumber(); } break; case QVariant::Color: @@ -1187,7 +1187,7 @@ bool QDeclarativeCompiler::buildComponent(QDeclarativeParser::Object *obj, if (idProp) { if (idProp->value || idProp->values.count() > 1 || idProp->values.at(0)->object) COMPILE_EXCEPTION(idProp, tr("Invalid component id specification")); - COMPILE_CHECK(checkValidId(idProp->values.first(), idProp->values.first()->primitive())); + COMPILE_CHECK(checkValidId(idProp->values.first(), idProp->values.first()->primitive())) QString idVal = idProp->values.first()->primitive(); @@ -1316,6 +1316,9 @@ bool QDeclarativeCompiler::buildSignal(QDeclarativeParser::Property *prop, QDecl } else { prop->values.at(0)->type = Value::SignalExpression; + if (!prop->values.at(0)->value.isScript()) + COMPILE_EXCEPTION(prop, tr("Cannot assign a value to a signal (expecting a script to be run)")); + QString script = prop->values.at(0)->value.asScript().trimmed(); if (script.isEmpty()) COMPILE_EXCEPTION(prop, tr("Empty signal assignment")); @@ -1893,7 +1896,7 @@ bool QDeclarativeCompiler::buildScriptStringProperty(QDeclarativeParser::Propert if (prop->values.count() > 1) COMPILE_EXCEPTION(prop->values.at(1), tr( "Cannot assign multiple values to a script property")); - if (prop->values.at(0)->object || !prop->values.at(0)->value.isScript()) + if (prop->values.at(0)->object) COMPILE_EXCEPTION(prop->values.at(0), tr( "Invalid property assignment: script expected")); obj->addScriptStringProperty(prop, ctxt.stack); diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 79f8a17..3ab94d3 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -1550,8 +1550,9 @@ void QDeclarativeEngine::addImportPath(const QString& path) provided by that module. A \c qmldir file is required for defining the type version mapping and possibly declarative extensions plugins. - By default, the list contains the paths specified in the \c QML_IMPORT_PATH environment - variable, then the builtin \c ImportsPath from QLibraryInfo. + By default, the list contains the directory of the application executable, + paths specified in the \c QML_IMPORT_PATH environment variable, + and the builtin \c ImportsPath from QLibraryInfo. \sa addImportPath() setImportPathList() */ @@ -1565,8 +1566,9 @@ QStringList QDeclarativeEngine::importPathList() const Sets \a paths as the list of directories where the engine searches for installed modules in a URL-based directory structure. - By default, the list contains the paths specified in the \c QML_IMPORT_PATH environment - variable, then the builtin \c ImportsPath from QLibraryInfo. + By default, the list contains the directory of the application executable, + paths specified in the \c QML_IMPORT_PATH environment variable, + and the builtin \c ImportsPath from QLibraryInfo. \sa importPathList() addImportPath() */ diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp index 69e42f8..7ae0050 100644 --- a/src/declarative/qml/qdeclarativeenginedebug.cpp +++ b/src/declarative/qml/qdeclarativeenginedebug.cpp @@ -414,7 +414,7 @@ void QDeclarativeEngineDebugServer::messageReceived(const QByteArray &message) QDeclarativeContext *context = qmlContext(object); QVariant result; if (object && context) { - QDeclarativeExpression exprObj(context, expr, object); + QDeclarativeExpression exprObj(context, object, expr); bool undefined = false; QVariant value = exprObj.evaluate(&undefined); if (undefined) diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp index 5ceb918..b1aecfa 100644 --- a/src/declarative/qml/qdeclarativeexpression.cpp +++ b/src/declarative/qml/qdeclarativeexpression.cpp @@ -241,15 +241,17 @@ QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, vo } /*! - Create a QDeclarativeExpression object. + Create a QDeclarativeExpression object that is a child of \a parent. The \a expression JavaScript will be executed in the \a ctxt QDeclarativeContext. If specified, the \a scope object's properties will also be in scope during the expression's execution. */ -QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContext *ctxt, const QString &expression, - QObject *scope) -: QObject(*new QDeclarativeExpressionPrivate, 0) +QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContext *ctxt, + QObject *scope, + const QString &expression, + QObject *parent) +: QObject(*new QDeclarativeExpressionPrivate, parent) { Q_D(QDeclarativeExpression); d->init(QDeclarativeContextData::get(ctxt), expression, scope); @@ -258,8 +260,8 @@ QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContext *ctxt, const /*! \internal */ -QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, const QString &expression, - QObject *scope) +QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, QObject *scope, + const QString &expression) : QObject(*new QDeclarativeExpressionPrivate, 0) { Q_D(QDeclarativeExpression); @@ -267,8 +269,8 @@ QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, co } /*! \internal */ -QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, const QString &expression, - QObject *scope, QDeclarativeExpressionPrivate &dd) +QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, QObject *scope, + const QString &expression, QDeclarativeExpressionPrivate &dd) : QObject(dd, 0) { Q_D(QDeclarativeExpression); diff --git a/src/declarative/qml/qdeclarativeexpression.h b/src/declarative/qml/qdeclarativeexpression.h index 6c72e4d..a8c86da 100644 --- a/src/declarative/qml/qdeclarativeexpression.h +++ b/src/declarative/qml/qdeclarativeexpression.h @@ -64,7 +64,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeExpression : public QObject Q_OBJECT public: QDeclarativeExpression(); - QDeclarativeExpression(QDeclarativeContext *, const QString &, QObject *); + QDeclarativeExpression(QDeclarativeContext *, QObject *, const QString &, QObject * = 0); virtual ~QDeclarativeExpression(); QDeclarativeEngine *engine() const; @@ -92,13 +92,13 @@ Q_SIGNALS: void valueChanged(); protected: - QDeclarativeExpression(QDeclarativeContextData *, const QString &, QObject *, + QDeclarativeExpression(QDeclarativeContextData *, QObject *, const QString &, QDeclarativeExpressionPrivate &dd); QDeclarativeExpression(QDeclarativeContextData *, void *, QDeclarativeRefCount *rc, QObject *me, const QString &, int, QDeclarativeExpressionPrivate &dd); private: - QDeclarativeExpression(QDeclarativeContextData *, const QString &, QObject *); + QDeclarativeExpression(QDeclarativeContextData *, QObject *, const QString &); Q_DISABLE_COPY(QDeclarativeExpression) Q_DECLARE_PRIVATE(QDeclarativeExpression) diff --git a/src/declarative/qml/qdeclarativeimport.cpp b/src/declarative/qml/qdeclarativeimport.cpp index 576e048..cb36818 100644 --- a/src/declarative/qml/qdeclarativeimport.cpp +++ b/src/declarative/qml/qdeclarativeimport.cpp @@ -576,9 +576,9 @@ QDeclarativeImportDatabase::QDeclarativeImportDatabase(QDeclarativeEngine *e) { filePluginPath << QLatin1String("."); - QString builtinPath = QLibraryInfo::location(QLibraryInfo::ImportsPath); - if (!builtinPath.isEmpty()) - addImportPath(builtinPath); + // Search order is applicationDirPath(), $QML_IMPORT_PATH, QLibraryInfo::ImportsPath + + addImportPath(QLibraryInfo::location(QLibraryInfo::ImportsPath)); // env import paths QByteArray envImportPath = qgetenv("QML_IMPORT_PATH"); @@ -592,6 +592,8 @@ QDeclarativeImportDatabase::QDeclarativeImportDatabase(QDeclarativeEngine *e) for (int ii = paths.count() - 1; ii >= 0; --ii) addImportPath(paths.at(ii)); } + + addImportPath(QCoreApplication::applicationDirPath()); } QDeclarativeImportDatabase::~QDeclarativeImportDatabase() @@ -843,6 +845,9 @@ void QDeclarativeImportDatabase::addImportPath(const QString& path) if (qmlImportTrace()) qDebug() << "QDeclarativeImportDatabase::addImportPath" << path; + if (path.isEmpty()) + return; + QUrl url = QUrl(path); QString cPath; @@ -853,7 +858,8 @@ void QDeclarativeImportDatabase::addImportPath(const QString& path) cPath = path; } - if (!fileImportPath.contains(cPath)) + if (!cPath.isEmpty() + && !fileImportPath.contains(cPath)) fileImportPath.prepend(cPath); } diff --git a/src/declarative/qml/qdeclarativeinclude.cpp b/src/declarative/qml/qdeclarativeinclude.cpp index 619264a..e37b68b 100644 --- a/src/declarative/qml/qdeclarativeinclude.cpp +++ b/src/declarative/qml/qdeclarativeinclude.cpp @@ -140,6 +140,7 @@ void QDeclarativeInclude::finished() scriptContext->pushScope(m_scope[1]); scriptContext->setActivationObject(m_scope[1]); + QDeclarativeScriptParser::extractPragmas(code); m_scriptEngine->evaluate(code, urlString, 1); @@ -230,6 +231,7 @@ QScriptValue QDeclarativeInclude::include(QScriptContext *ctxt, QScriptEngine *e QScriptValue scope = QScriptDeclarativeClass::scopeChainValue(ctxt, -5); scriptContext->pushScope(scope); scriptContext->setActivationObject(scope); + QDeclarativeScriptParser::extractPragmas(code); engine->evaluate(code, urlString, 1); @@ -291,6 +293,7 @@ QScriptValue QDeclarativeInclude::worker_include(QScriptContext *ctxt, QScriptEn QScriptValue scope = QScriptDeclarativeClass::scopeChainValue(ctxt, -4); scriptContext->pushScope(scope); scriptContext->setActivationObject(scope); + QDeclarativeScriptParser::extractPragmas(code); engine->evaluate(code, urlString, 1); diff --git a/src/declarative/qml/qdeclarativeparser.cpp b/src/declarative/qml/qdeclarativeparser.cpp index b38bd76..8d00ef8 100644 --- a/src/declarative/qml/qdeclarativeparser.cpp +++ b/src/declarative/qml/qdeclarativeparser.cpp @@ -57,6 +57,7 @@ #include <QPointF> #include <QSizeF> #include <QRectF> +#include <QStringBuilder> #include <QtDebug> QT_BEGIN_NAMESPACE @@ -310,6 +311,49 @@ double QDeclarativeParser::Variant::asNumber() const return d; } +//reverse of Lexer::singleEscape() +QString escapedString(const QString &string) +{ + QString tmp = QLatin1String("\""); + for (int i = 0; i < string.length(); ++i) { + const QChar &c = string.at(i); + switch(c.unicode()) { + case 0x08: + tmp += QLatin1String("\\b"); + break; + case 0x09: + tmp += QLatin1String("\\t"); + break; + case 0x0A: + tmp += QLatin1String("\\n"); + break; + case 0x0B: + tmp += QLatin1String("\\v"); + break; + case 0x0C: + tmp += QLatin1String("\\f"); + break; + case 0x0D: + tmp += QLatin1String("\\r"); + break; + case 0x22: + tmp += QLatin1String("\\\""); + break; + case 0x27: + tmp += QLatin1String("\\\'"); + break; + case 0x5C: + tmp += QLatin1String("\\\\"); + break; + default: + tmp += c; + break; + } + } + tmp += QLatin1Char('\"'); + return tmp; +} + QString QDeclarativeParser::Variant::asScript() const { switch(type()) { @@ -324,6 +368,7 @@ QString QDeclarativeParser::Variant::asScript() const else return s; case String: + return escapedString(s); case Script: return s; } diff --git a/src/declarative/qml/qdeclarativeparser_p.h b/src/declarative/qml/qdeclarativeparser_p.h index 25777f5..d192f3a 100644 --- a/src/declarative/qml/qdeclarativeparser_p.h +++ b/src/declarative/qml/qdeclarativeparser_p.h @@ -307,8 +307,8 @@ namespace QDeclarativeParser }; Type type; - // ### Temporary - QString primitive() const { return value.asScript(); } + // ### Temporary (for id only) + QString primitive() const { return value.isString() ? value.asString() : value.asScript(); } // Primitive value Variant value; diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp index 8ba79a6..3247f85 100644 --- a/src/declarative/qml/qdeclarativevme.cpp +++ b/src/declarative/qml/qdeclarativevme.cpp @@ -627,7 +627,7 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack, QDeclarativeBoundSignal *bs = new QDeclarativeBoundSignal(target, signal, target); QDeclarativeExpression *expr = - new QDeclarativeExpression(ctxt, primitives.at(instr.storeSignal.value), context); + new QDeclarativeExpression(ctxt, context, primitives.at(instr.storeSignal.value)); expr->setSourceLocation(comp->name, instr.line); bs->setExpression(expr); } diff --git a/src/declarative/qml/qdeclarativewatcher.cpp b/src/declarative/qml/qdeclarativewatcher.cpp index 842b3c4..da1419f 100644 --- a/src/declarative/qml/qdeclarativewatcher.cpp +++ b/src/declarative/qml/qdeclarativewatcher.cpp @@ -153,7 +153,7 @@ bool QDeclarativeWatcher::addWatch(int id, quint32 objectId, const QString &expr QObject *object = QDeclarativeDebugService::objectForId(objectId); QDeclarativeContext *context = qmlContext(object); if (context) { - QDeclarativeExpression *exprObj = new QDeclarativeExpression(context, expr, object); + QDeclarativeExpression *exprObj = new QDeclarativeExpression(context, object, expr); exprObj->setNotifyOnValueChanged(true); QDeclarativeWatchProxy *proxy = new QDeclarativeWatchProxy(id, exprObj, objectId, this); exprObj->setParent(proxy); diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp index 4b687a9..8182998 100644 --- a/src/declarative/qml/qdeclarativeworkerscript.cpp +++ b/src/declarative/qml/qdeclarativeworkerscript.cpp @@ -527,7 +527,7 @@ void QDeclarativeWorkerScriptEngine::run() \snippet doc/src/snippets/declarative/workerscript.qml 0 The above worker script specifies a javascript file, "script.js", that handles - the operations to be performed in the new thread: + the operations to be performed in the new thread. Here is \c script.js: \qml WorkerScript.onMessage = function(message) { @@ -538,7 +538,7 @@ void QDeclarativeWorkerScriptEngine::run() When the user clicks anywhere within the rectangle, \c sendMessage() is called, triggering the \tt WorkerScript.onMessage() handler in - \tt source.js. This in turn sends a reply message that is then received + \tt script.js. This in turn sends a reply message that is then received by the \tt onMessage() handler of \tt myWorker. */ QDeclarativeWorkerScript::QDeclarativeWorkerScript(QObject *parent) diff --git a/src/declarative/qml/qdeclarativexmlhttprequest.cpp b/src/declarative/qml/qdeclarativexmlhttprequest.cpp index 80510f8..acd1f51 100644 --- a/src/declarative/qml/qdeclarativexmlhttprequest.cpp +++ b/src/declarative/qml/qdeclarativexmlhttprequest.cpp @@ -995,7 +995,7 @@ private: int m_status; QString m_statusText; QNetworkRequest m_request; - QNetworkReply *m_network; + QDeclarativeGuard<QNetworkReply> m_network; void destroyNetwork(); QNetworkAccessManager *m_nam; diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 67440b6..1365cd7 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -786,7 +786,7 @@ void QDeclarativeScriptActionPrivate::execute() const QString &str = scriptStr.script(); if (!str.isEmpty()) { - QDeclarativeExpression expr(scriptStr.context(), str, scriptStr.scopeObject()); + QDeclarativeExpression expr(scriptStr.context(), scriptStr.scopeObject(), str); QDeclarativeData *ddata = QDeclarativeData::get(q); if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber); @@ -1947,6 +1947,9 @@ void QDeclarativePropertyAnimation::setTo(const QVariant &t) easing.period is only applicable if type is: Easing.InElastic, Easing.OutElastic, Easing.InOutElastic or Easing.OutInElastic. + + See the \l {declarative/animation/easing}{easing} example for a demonstration of + the different easing settings. */ QEasingCurve QDeclarativePropertyAnimation::easing() const { diff --git a/src/declarative/util/qdeclarativeconnections.cpp b/src/declarative/util/qdeclarativeconnections.cpp index ffa160f..808d196 100644 --- a/src/declarative/util/qdeclarativeconnections.cpp +++ b/src/declarative/util/qdeclarativeconnections.cpp @@ -262,7 +262,7 @@ void QDeclarativeConnections::connectSignals() if (prop.isValid() && (prop.type() & QDeclarativeProperty::SignalProperty)) { QDeclarativeBoundSignal *signal = new QDeclarativeBoundSignal(target(), prop.method(), this); - signal->setExpression(new QDeclarativeExpression(qmlContext(this), script, 0)); + signal->setExpression(new QDeclarativeExpression(qmlContext(this), 0, script)); d->boundsignals += signal; } else { if (!d->ignoreUnknownSignals) diff --git a/src/declarative/util/qdeclarativepropertychanges.cpp b/src/declarative/util/qdeclarativepropertychanges.cpp index 12fef36..d99de7a 100644 --- a/src/declarative/util/qdeclarativepropertychanges.cpp +++ b/src/declarative/util/qdeclarativepropertychanges.cpp @@ -321,7 +321,7 @@ void QDeclarativePropertyChangesPrivate::decode() QDeclarativeProperty prop = property(name); //### better way to check for signal property? if (prop.type() & QDeclarativeProperty::SignalProperty) { - QDeclarativeExpression *expression = new QDeclarativeExpression(qmlContext(q), data.toString(), object); + QDeclarativeExpression *expression = new QDeclarativeExpression(qmlContext(q), object, data.toString()); QDeclarativeData *ddata = QDeclarativeData::get(q); if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) expression->setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber); @@ -330,7 +330,7 @@ void QDeclarativePropertyChangesPrivate::decode() handler->expression = expression; signalReplacements << handler; } else if (isScript) { - QDeclarativeExpression *expression = new QDeclarativeExpression(qmlContext(q), data.toString(), object); + QDeclarativeExpression *expression = new QDeclarativeExpression(qmlContext(q), object, data.toString()); QDeclarativeData *ddata = QDeclarativeData::get(q); if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) expression->setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber); diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp index 0326f6d..80ae5f5 100644 --- a/src/declarative/util/qdeclarativestateoperations.cpp +++ b/src/declarative/util/qdeclarativestateoperations.cpp @@ -69,18 +69,18 @@ public: rewindParent(0), rewindStackBefore(0) {} QDeclarativeItem *target; - QDeclarativeItem *parent; + QDeclarativeGuard<QDeclarativeItem> parent; QDeclarativeGuard<QDeclarativeItem> origParent; QDeclarativeGuard<QDeclarativeItem> origStackBefore; QDeclarativeItem *rewindParent; QDeclarativeItem *rewindStackBefore; - QDeclarativeNullableValue<qreal> x; - QDeclarativeNullableValue<qreal> y; - QDeclarativeNullableValue<qreal> width; - QDeclarativeNullableValue<qreal> height; - QDeclarativeNullableValue<qreal> scale; - QDeclarativeNullableValue<qreal> rotation; + QDeclarativeNullableValue<QDeclarativeScriptString> xString; + QDeclarativeNullableValue<QDeclarativeScriptString> yString; + QDeclarativeNullableValue<QDeclarativeScriptString> widthString; + QDeclarativeNullableValue<QDeclarativeScriptString> heightString; + QDeclarativeNullableValue<QDeclarativeScriptString> scaleString; + QDeclarativeNullableValue<QDeclarativeScriptString> rotationString; void doChange(QDeclarativeItem *targetParent, QDeclarativeItem *stackBefore = 0); }; @@ -196,112 +196,112 @@ QDeclarativeParentChange::~QDeclarativeParentChange() These properties hold the new position, size, scale, and rotation for the item in this state. */ -qreal QDeclarativeParentChange::x() const +QDeclarativeScriptString QDeclarativeParentChange::x() const { Q_D(const QDeclarativeParentChange); - return d->x.isNull ? qreal(0.) : d->x.value; + return d->xString.value; } -void QDeclarativeParentChange::setX(qreal x) +void QDeclarativeParentChange::setX(QDeclarativeScriptString x) { Q_D(QDeclarativeParentChange); - d->x = x; + d->xString = x; } bool QDeclarativeParentChange::xIsSet() const { Q_D(const QDeclarativeParentChange); - return d->x.isValid(); + return d->xString.isValid(); } -qreal QDeclarativeParentChange::y() const +QDeclarativeScriptString QDeclarativeParentChange::y() const { Q_D(const QDeclarativeParentChange); - return d->y.isNull ? qreal(0.) : d->y.value; + return d->yString.value; } -void QDeclarativeParentChange::setY(qreal y) +void QDeclarativeParentChange::setY(QDeclarativeScriptString y) { Q_D(QDeclarativeParentChange); - d->y = y; + d->yString = y; } bool QDeclarativeParentChange::yIsSet() const { Q_D(const QDeclarativeParentChange); - return d->y.isValid(); + return d->yString.isValid(); } -qreal QDeclarativeParentChange::width() const +QDeclarativeScriptString QDeclarativeParentChange::width() const { Q_D(const QDeclarativeParentChange); - return d->width.isNull ? qreal(0.) : d->width.value; + return d->widthString.value; } -void QDeclarativeParentChange::setWidth(qreal width) +void QDeclarativeParentChange::setWidth(QDeclarativeScriptString width) { Q_D(QDeclarativeParentChange); - d->width = width; + d->widthString = width; } bool QDeclarativeParentChange::widthIsSet() const { Q_D(const QDeclarativeParentChange); - return d->width.isValid(); + return d->widthString.isValid(); } -qreal QDeclarativeParentChange::height() const +QDeclarativeScriptString QDeclarativeParentChange::height() const { Q_D(const QDeclarativeParentChange); - return d->height.isNull ? qreal(0.) : d->height.value; + return d->heightString.value; } -void QDeclarativeParentChange::setHeight(qreal height) +void QDeclarativeParentChange::setHeight(QDeclarativeScriptString height) { Q_D(QDeclarativeParentChange); - d->height = height; + d->heightString = height; } bool QDeclarativeParentChange::heightIsSet() const { Q_D(const QDeclarativeParentChange); - return d->height.isValid(); + return d->heightString.isValid(); } -qreal QDeclarativeParentChange::scale() const +QDeclarativeScriptString QDeclarativeParentChange::scale() const { Q_D(const QDeclarativeParentChange); - return d->scale.isNull ? qreal(1.) : d->scale.value; + return d->scaleString.value; } -void QDeclarativeParentChange::setScale(qreal scale) +void QDeclarativeParentChange::setScale(QDeclarativeScriptString scale) { Q_D(QDeclarativeParentChange); - d->scale = scale; + d->scaleString = scale; } bool QDeclarativeParentChange::scaleIsSet() const { Q_D(const QDeclarativeParentChange); - return d->scale.isValid(); + return d->scaleString.isValid(); } -qreal QDeclarativeParentChange::rotation() const +QDeclarativeScriptString QDeclarativeParentChange::rotation() const { Q_D(const QDeclarativeParentChange); - return d->rotation.isNull ? qreal(0.) : d->rotation.value; + return d->rotationString.value; } -void QDeclarativeParentChange::setRotation(qreal rotation) +void QDeclarativeParentChange::setRotation(QDeclarativeScriptString rotation) { Q_D(QDeclarativeParentChange); - d->rotation = rotation; + d->rotationString = rotation; } bool QDeclarativeParentChange::rotationIsSet() const { Q_D(const QDeclarativeParentChange); - return d->rotation.isValid(); + return d->rotationString.isValid(); } QDeclarativeItem *QDeclarativeParentChange::originalParent() const @@ -356,34 +356,118 @@ QDeclarativeStateOperation::ActionList QDeclarativeParentChange::actions() a.event = this; actions << a; - if (d->x.isValid()) { - QDeclarativeAction xa(d->target, QLatin1String("x"), x()); - actions << xa; + if (d->xString.isValid()) { + bool ok = false; + QString script = d->xString.value.script(); + qreal x = script.toFloat(&ok); + if (ok) { + QDeclarativeAction xa(d->target, QLatin1String("x"), x); + actions << xa; + } else { + QDeclarativeBinding *newBinding = new QDeclarativeBinding(script, d->target, qmlContext(this)); + newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("x"))); + QDeclarativeAction xa; + xa.property = newBinding->property(); + xa.toBinding = newBinding; + xa.fromValue = xa.property.read(); + xa.deletableToBinding = true; + actions << xa; + } } - if (d->y.isValid()) { - QDeclarativeAction ya(d->target, QLatin1String("y"), y()); - actions << ya; + if (d->yString.isValid()) { + bool ok = false; + QString script = d->yString.value.script(); + qreal y = script.toFloat(&ok); + if (ok) { + QDeclarativeAction ya(d->target, QLatin1String("y"), y); + actions << ya; + } else { + QDeclarativeBinding *newBinding = new QDeclarativeBinding(script, d->target, qmlContext(this)); + newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("y"))); + QDeclarativeAction ya; + ya.property = newBinding->property(); + ya.toBinding = newBinding; + ya.fromValue = ya.property.read(); + ya.deletableToBinding = true; + actions << ya; + } } - if (d->scale.isValid()) { - QDeclarativeAction sa(d->target, QLatin1String("scale"), scale()); - actions << sa; + if (d->scaleString.isValid()) { + bool ok = false; + QString script = d->scaleString.value.script(); + qreal scale = script.toFloat(&ok); + if (ok) { + QDeclarativeAction sa(d->target, QLatin1String("scale"), scale); + actions << sa; + } else { + QDeclarativeBinding *newBinding = new QDeclarativeBinding(script, d->target, qmlContext(this)); + newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("scale"))); + QDeclarativeAction sa; + sa.property = newBinding->property(); + sa.toBinding = newBinding; + sa.fromValue = sa.property.read(); + sa.deletableToBinding = true; + actions << sa; + } } - if (d->rotation.isValid()) { - QDeclarativeAction ra(d->target, QLatin1String("rotation"), rotation()); - actions << ra; + if (d->rotationString.isValid()) { + bool ok = false; + QString script = d->rotationString.value.script(); + qreal rotation = script.toFloat(&ok); + if (ok) { + QDeclarativeAction ra(d->target, QLatin1String("rotation"), rotation); + actions << ra; + } else { + QDeclarativeBinding *newBinding = new QDeclarativeBinding(script, d->target, qmlContext(this)); + newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("rotation"))); + QDeclarativeAction ra; + ra.property = newBinding->property(); + ra.toBinding = newBinding; + ra.fromValue = ra.property.read(); + ra.deletableToBinding = true; + actions << ra; + } } - if (d->width.isValid()) { - QDeclarativeAction wa(d->target, QLatin1String("width"), width()); - actions << wa; + if (d->widthString.isValid()) { + bool ok = false; + QString script = d->widthString.value.script(); + qreal width = script.toFloat(&ok); + if (ok) { + QDeclarativeAction wa(d->target, QLatin1String("width"), width); + actions << wa; + } else { + QDeclarativeBinding *newBinding = new QDeclarativeBinding(script, d->target, qmlContext(this)); + newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("width"))); + QDeclarativeAction wa; + wa.property = newBinding->property(); + wa.toBinding = newBinding; + wa.fromValue = wa.property.read(); + wa.deletableToBinding = true; + actions << wa; + } } - if (d->height.isValid()) { - QDeclarativeAction ha(d->target, QLatin1String("height"), height()); - actions << ha; + if (d->heightString.isValid()) { + bool ok = false; + QString script = d->heightString.value.script(); + qreal height = script.toFloat(&ok); + if (ok) { + QDeclarativeAction ha(d->target, QLatin1String("height"), height); + actions << ha; + } else { + QDeclarativeBinding *newBinding = new QDeclarativeBinding(script, d->target, qmlContext(this)); + newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("height"))); + QDeclarativeAction ha; + ha.property = newBinding->property(); + ha.toBinding = newBinding; + ha.fromValue = ha.property.read(); + ha.deletableToBinding = true; + actions << ha; + } } return actions; @@ -575,7 +659,7 @@ void QDeclarativeStateChangeScript::execute(Reason) Q_D(QDeclarativeStateChangeScript); const QString &script = d->script.script(); if (!script.isEmpty()) { - QDeclarativeExpression expr(d->script.context(), script, d->script.scopeObject()); + QDeclarativeExpression expr(d->script.context(), d->script.scopeObject(), script); QDeclarativeData *ddata = QDeclarativeData::get(this); if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber); diff --git a/src/declarative/util/qdeclarativestateoperations_p.h b/src/declarative/util/qdeclarativestateoperations_p.h index 21a86f5..05ad052 100644 --- a/src/declarative/util/qdeclarativestateoperations_p.h +++ b/src/declarative/util/qdeclarativestateoperations_p.h @@ -62,12 +62,12 @@ class Q_DECLARATIVE_EXPORT QDeclarativeParentChange : public QDeclarativeStateOp Q_PROPERTY(QDeclarativeItem *target READ object WRITE setObject) Q_PROPERTY(QDeclarativeItem *parent READ parent WRITE setParent) - Q_PROPERTY(qreal x READ x WRITE setX) - Q_PROPERTY(qreal y READ y WRITE setY) - Q_PROPERTY(qreal width READ width WRITE setWidth) - Q_PROPERTY(qreal height READ height WRITE setHeight) - Q_PROPERTY(qreal scale READ scale WRITE setScale) - Q_PROPERTY(qreal rotation READ rotation WRITE setRotation) + Q_PROPERTY(QDeclarativeScriptString x READ x WRITE setX) + Q_PROPERTY(QDeclarativeScriptString y READ y WRITE setY) + Q_PROPERTY(QDeclarativeScriptString width READ width WRITE setWidth) + Q_PROPERTY(QDeclarativeScriptString height READ height WRITE setHeight) + Q_PROPERTY(QDeclarativeScriptString scale READ scale WRITE setScale) + Q_PROPERTY(QDeclarativeScriptString rotation READ rotation WRITE setRotation) public: QDeclarativeParentChange(QObject *parent=0); ~QDeclarativeParentChange(); @@ -80,28 +80,28 @@ public: QDeclarativeItem *originalParent() const; - qreal x() const; - void setX(qreal x); + QDeclarativeScriptString x() const; + void setX(QDeclarativeScriptString x); bool xIsSet() const; - qreal y() const; - void setY(qreal y); + QDeclarativeScriptString y() const; + void setY(QDeclarativeScriptString y); bool yIsSet() const; - qreal width() const; - void setWidth(qreal width); + QDeclarativeScriptString width() const; + void setWidth(QDeclarativeScriptString width); bool widthIsSet() const; - qreal height() const; - void setHeight(qreal height); + QDeclarativeScriptString height() const; + void setHeight(QDeclarativeScriptString height); bool heightIsSet() const; - qreal scale() const; - void setScale(qreal scale); + QDeclarativeScriptString scale() const; + void setScale(QDeclarativeScriptString scale); bool scaleIsSet() const; - qreal rotation() const; - void setRotation(qreal rotation); + QDeclarativeScriptString rotation() const; + void setRotation(QDeclarativeScriptString rotation); bool rotationIsSet() const; virtual ActionList actions(); diff --git a/src/gui/painting/qdrawutil.cpp b/src/gui/painting/qdrawutil.cpp index ef9b18c..3ce95ef 100644 --- a/src/gui/painting/qdrawutil.cpp +++ b/src/gui/painting/qdrawutil.cpp @@ -1138,12 +1138,10 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin yTarget.resize(rows + 1); bool oldAA = painter->testRenderHint(QPainter::Antialiasing); - bool oldSmooth = painter->testRenderHint(QPainter::SmoothPixmapTransform); if (painter->paintEngine()->type() != QPaintEngine::OpenGL && painter->paintEngine()->type() != QPaintEngine::OpenGL2 - && (oldSmooth || oldAA) && painter->combinedTransform().type() != QTransform::TxNone) { + && oldAA && painter->combinedTransform().type() != QTransform::TxNone) { painter->setRenderHint(QPainter::Antialiasing, false); - painter->setRenderHint(QPainter::SmoothPixmapTransform, false); } xTarget[0] = targetRect.left(); @@ -1354,8 +1352,6 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin if (oldAA) painter->setRenderHint(QPainter::Antialiasing, true); - if (oldSmooth) - painter->setRenderHint(QPainter::SmoothPixmapTransform, true); } QT_END_NAMESPACE diff --git a/src/imports/folderlistmodel/folderlistmodel.pro b/src/imports/folderlistmodel/folderlistmodel.pro new file mode 100644 index 0000000..781dfc2 --- /dev/null +++ b/src/imports/folderlistmodel/folderlistmodel.pro @@ -0,0 +1,26 @@ +TARGET = qmlfolderlistmodelplugin +TARGETPATH = Qt/labs/folderlistmodel +include(../qimportbase.pri) + +QT += declarative script + +SOURCES += qdeclarativefolderlistmodel.cpp plugin.cpp +HEADERS += qdeclarativefolderlistmodel.h + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/imports/$$TARGETPATH +target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH + +qmldir.files += $$PWD/qmldir +qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH + +symbian:{ + load(data_caging_paths) + include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) + + importFiles.sources = qmlfolderlistmodelplugin.dll qmldir + importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH + + DEPLOYMENT = importFiles +} + +INSTALLS += target qmldir diff --git a/src/imports/folderlistmodel/plugin.cpp b/src/imports/folderlistmodel/plugin.cpp new file mode 100644 index 0000000..d4569f7 --- /dev/null +++ b/src/imports/folderlistmodel/plugin.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** 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 plugins 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$ +** +****************************************************************************/ + +#include <QtDeclarative/qdeclarativeextensionplugin.h> +#include <QtDeclarative/qdeclarative.h> + +#include "qdeclarativefolderlistmodel.h" + +QT_BEGIN_NAMESPACE + +//![class decl] +class QmlFolderListModelPlugin : public QDeclarativeExtensionPlugin +{ + Q_OBJECT +public: + virtual void registerTypes(const char *uri) + { + Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.folderlistmodel")); + qmlRegisterType<QDeclarativeFolderListModel>(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/tools/qml/qdeclarativefolderlistmodel.cpp b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp index 7ac25d6..6a7383a 100644 --- a/tools/qml/qdeclarativefolderlistmodel.cpp +++ b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +//![code] #include "qdeclarativefolderlistmodel.h" #include <QDirModel> #include <QDebug> @@ -101,6 +102,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 @@ -112,8 +119,13 @@ public: */ QDeclarativeFolderListModel::QDeclarativeFolderListModel(QObject *parent) - : QListModelInterface(parent) + : QAbstractListModel(parent) { + QHash<int, QByteArray> roles; + roles[FileNameRole] = "fileName"; + roles[FilePathRole] = "filePath"; + setRoleNames(roles); + d = new QDeclarativeFolderListModelPrivate; d->model.setFilter(QDir::AllDirs | QDir::Files | QDir::Drives | QDir::NoDotAndDotDot); connect(&d->model, SIGNAL(rowsInserted(const QModelIndex&,int,int)) @@ -131,58 +143,25 @@ QDeclarativeFolderListModel::~QDeclarativeFolderListModel() delete d; } -QHash<int,QVariant> QDeclarativeFolderListModel::data(int index, const QList<int> &roles) const -{ - Q_UNUSED(roles); - QHash<int,QVariant> folderData; - QModelIndex modelIndex = d->model.index(index, 0, d->folderIndex); - if (modelIndex.isValid()) { - folderData[QDirModel::FileNameRole] = d->model.data(modelIndex, QDirModel::FileNameRole); - folderData[QDirModel::FilePathRole] = QUrl::fromLocalFile(d->model.data(modelIndex, QDirModel::FilePathRole).toString()); - } - - return folderData; -} - -QVariant QDeclarativeFolderListModel::data(int index, int role) const +QVariant QDeclarativeFolderListModel::data(const QModelIndex &index, int role) const { QVariant rv; - QModelIndex modelIndex = d->model.index(index, 0, d->folderIndex); + QModelIndex modelIndex = d->model.index(index.row(), 0, d->folderIndex); if (modelIndex.isValid()) { - if (role == QDirModel::FileNameRole) - rv = d->model.data(modelIndex, QDirModel::FileNameRole); - else if (role == QDirModel::FilePathRole) + if (role == FileNameRole) + rv = d->model.data(modelIndex, QDirModel::FileNameRole).toString(); + else if (role == FilePathRole) rv = QUrl::fromLocalFile(d->model.data(modelIndex, QDirModel::FilePathRole).toString()); } - return rv; } -int QDeclarativeFolderListModel::count() const +int QDeclarativeFolderListModel::rowCount(const QModelIndex &parent) const { + Q_UNUSED(parent); return d->count; } -QList<int> QDeclarativeFolderListModel::roles() const -{ - QList<int> r; - r << QDirModel::FileNameRole; - r << QDirModel::FilePathRole; - return r; -} - -QString QDeclarativeFolderListModel::toString(int role) const -{ - switch (role) { - case QDirModel::FileNameRole: - return QLatin1String("fileName"); - case QDirModel::FilePathRole: - return QLatin1String("filePath"); - } - - return QString(); -} - /*! \qmlproperty string FolderListModel::folder @@ -315,37 +294,41 @@ void QDeclarativeFolderListModel::refresh() { d->folderIndex = QModelIndex(); if (d->count) { - int tmpCount = d->count; + emit beginRemoveRows(QModelIndex(), 0, d->count); d->count = 0; - emit itemsRemoved(0, tmpCount); + emit endRemoveRows(); } d->folderIndex = d->model.index(d->folder.toLocalFile()); - d->count = d->model.rowCount(d->folderIndex); - if (d->count) { - emit itemsInserted(0, d->count); + int newcount = d->model.rowCount(d->folderIndex); + if (newcount) { + emit beginInsertRows(QModelIndex(), 0, newcount-1); + d->count = newcount; + emit endInsertRows(); } } void QDeclarativeFolderListModel::inserted(const QModelIndex &index, int start, int end) { if (index == d->folderIndex) { + emit beginInsertRows(QModelIndex(), start, end); d->count = d->model.rowCount(d->folderIndex); - emit itemsInserted(start, end - start + 1); + emit endInsertRows(); } } void QDeclarativeFolderListModel::removed(const QModelIndex &index, int start, int end) { if (index == d->folderIndex) { + emit beginRemoveRows(QModelIndex(), start, end); d->count = d->model.rowCount(d->folderIndex); - emit itemsRemoved(start, end - start + 1); + emit endRemoveRows(); } } void QDeclarativeFolderListModel::dataChanged(const QModelIndex &start, const QModelIndex &end) { if (start.parent() == d->folderIndex) - emit itemsChanged(start.row(), end.row() - start.row() + 1, roles()); + emit dataChanged(index(start.row(),0), index(end.row(),0)); } /*! @@ -414,10 +397,5 @@ void QDeclarativeFolderListModel::setShowOnlyReadable(bool on) d->model.setFilter(d->model.filter() & ~QDir::Readable); } -void QDeclarativeFolderListModel::registerTypes() -{ - qmlRegisterType<QDeclarativeFolderListModel>("Qt",4,7,"FolderListModel"); -} - +//![code] QT_END_NAMESPACE - diff --git a/tools/qml/qdeclarativefolderlistmodel.h b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h index 1ecc784..ea7d701 100644 --- a/tools/qml/qdeclarativefolderlistmodel.h +++ b/src/imports/folderlistmodel/qdeclarativefolderlistmodel.h @@ -45,19 +45,27 @@ #include <qdeclarative.h> #include <QStringList> #include <QUrl> -#include "../../src/declarative/3rdparty/qlistmodelinterface_p.h" +#include <QAbstractListModel> + +QT_BEGIN_HEADER QT_BEGIN_NAMESPACE +QT_MODULE(Declarative) + class QDeclarativeContext; class QModelIndex; class QDeclarativeFolderListModelPrivate; -class QDeclarativeFolderListModel : public QListModelInterface, public QDeclarativeParserStatus + +//![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) @@ -66,19 +74,25 @@ class QDeclarativeFolderListModel : public QListModelInterface, public QDeclarat Q_PROPERTY(bool showDirs READ showDirs WRITE setShowDirs) 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(); - static void registerTypes(); + enum Roles { FileNameRole = Qt::UserRole+1, FilePathRole = Qt::UserRole+2 }; + + int rowCount(const QModelIndex &parent) const; + QVariant data(const QModelIndex &index, int role) const; +//![abslistmodel] - virtual QHash<int,QVariant> data(int index, const QList<int> &roles = (QList<int>())) const; - virtual QVariant data(int index, int role) const; - virtual int count() const; - virtual QList<int> roles() const; - virtual QString toString(int role) const; +//![count] + int count() const { return rowCount(QModelIndex()); } +//![count] +//![prop funcs] QUrl folder() const; void setFolder(const QUrl &folder); @@ -87,11 +101,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); @@ -106,10 +115,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); @@ -120,9 +142,14 @@ private: Q_DISABLE_COPY(QDeclarativeFolderListModel) QDeclarativeFolderListModelPrivate *d; }; +//![class end] QT_END_NAMESPACE +//![qml decl] QML_DECLARE_TYPE(QDeclarativeFolderListModel) +//![qml decl] + +QT_END_HEADER #endif // QDECLARATIVEFOLDERLISTMODEL_H diff --git a/src/imports/folderlistmodel/qmldir b/src/imports/folderlistmodel/qmldir new file mode 100644 index 0000000..6e115bb --- /dev/null +++ b/src/imports/folderlistmodel/qmldir @@ -0,0 +1 @@ +plugin qmlfolderlistmodelplugin diff --git a/src/imports/gestures/qdeclarativegesturearea.cpp b/src/imports/gestures/qdeclarativegesturearea.cpp index 19afe0c..1b0aeeb 100644 --- a/src/imports/gestures/qdeclarativegesturearea.cpp +++ b/src/imports/gestures/qdeclarativegesturearea.cpp @@ -226,7 +226,7 @@ void QDeclarativeGestureArea::connectSignals() ds >> gesturetype; QString script; ds >> script; - QDeclarativeExpression *exp = new QDeclarativeExpression(qmlContext(this), script, 0); + QDeclarativeExpression *exp = new QDeclarativeExpression(qmlContext(this), 0, script); d->bindings.insert(Qt::GestureType(gesturetype),exp); grabGesture(Qt::GestureType(gesturetype)); } diff --git a/src/imports/imports.pro b/src/imports/imports.pro index a45af95..7f9331a 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -1,6 +1,6 @@ TEMPLATE = subdirs -SUBDIRS += particles gestures +SUBDIRS += folderlistmodel particles gestures contains(QT_CONFIG, webkit): SUBDIRS += webkit diff --git a/tests/auto/declarative/.gitignore b/tests/.gitignore index 57608cf..b203473 100644 --- a/tests/auto/declarative/.gitignore +++ b/tests/.gitignore @@ -1,3 +1,4 @@ +QObject.log tst_* !tst_*.* tst_*.log diff --git a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp index 851460f..7f0e6c0 100644 --- a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp +++ b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp @@ -398,7 +398,7 @@ void tst_qdeclarativecontext::destruction() QObject obj; QDeclarativeEngine::setContextForObject(&obj, ctxt); - QDeclarativeExpression expr(ctxt, "a", 0); + QDeclarativeExpression expr(ctxt, 0, "a"); QCOMPARE(ctxt, QDeclarativeEngine::contextForObject(&obj)); QCOMPARE(ctxt, expr.context()); diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma.qml b/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma.qml new file mode 100644 index 0000000..67b8cfd --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma.qml @@ -0,0 +1,11 @@ +import Qt 4.7 +import "include_pragma_outer.js" as Script + +Item { + property int test1 + + Component.onCompleted: { + test1 = Script.callFunction() + } +} + diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma_inner.js b/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma_inner.js new file mode 100644 index 0000000..a0380a2 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma_inner.js @@ -0,0 +1,5 @@ +.pragma library + +function getValue() { + return 100; +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma_outer.js b/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma_outer.js new file mode 100644 index 0000000..d87bafc --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/include_pragma_outer.js @@ -0,0 +1,6 @@ +Qt.include("include_pragma_inner.js") + +function callFunction() { + return getValue(); +} + diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h index 1381d57..7bb8a8e 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h @@ -190,7 +190,7 @@ class MyExpression : public QDeclarativeExpression Q_OBJECT public: MyExpression(QDeclarativeContext *ctxt, const QString &expr) - : QDeclarativeExpression(ctxt, expr, 0), changed(false) + : QDeclarativeExpression(ctxt, 0, expr), changed(false) { QObject::connect(this, SIGNAL(valueChanged()), this, SLOT(expressionValueChanged())); setNotifyOnValueChanged(true); diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 64e5b3f..9a88237 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -2083,10 +2083,9 @@ void tst_qdeclarativeecmascript::compiled() QCOMPARE(object->property("test15").toBool(), false); QCOMPARE(object->property("test16").toBool(), true); - QCOMPARE(object->property("test17").toInt(), 4); + QCOMPARE(object->property("test17").toInt(), 5); QCOMPARE(object->property("test18").toReal(), qreal(176)); - QEXPECT_FAIL("", "QTBUG-9538", Continue); - QCOMPARE(object->property("test19").toInt(), 6); + QCOMPARE(object->property("test19").toInt(), 7); QCOMPARE(object->property("test20").toReal(), qreal(6.7)); QCOMPARE(object->property("test21").toString(), QLatin1String("6.7")); QCOMPARE(object->property("test22").toString(), QLatin1String("!")); @@ -2425,6 +2424,17 @@ void tst_qdeclarativeecmascript::include() delete o; } + // Including file with ".pragma library" + { + QDeclarativeComponent component(&engine, TEST_FILE("include_pragma.qml")); + qDebug() << "errors:" << component.errorsString(); + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(o->property("test1").toInt(), 100); + + delete o; + } + // Remote - success { TestHTTPServer server(8111); diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/data/basic.qml b/tests/auto/declarative/qdeclarativefolderlistmodel/data/basic.qml new file mode 100644 index 0000000..2c4977d --- /dev/null +++ b/tests/auto/declarative/qdeclarativefolderlistmodel/data/basic.qml @@ -0,0 +1,5 @@ +import Qt.labs.folderlistmodel 1.0 + +FolderListModel { + nameFilters: [ "*.qml" ] +} diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/data/dummy.qml b/tests/auto/declarative/qdeclarativefolderlistmodel/data/dummy.qml new file mode 100644 index 0000000..609638b --- /dev/null +++ b/tests/auto/declarative/qdeclarativefolderlistmodel/data/dummy.qml @@ -0,0 +1 @@ +// This file is not used, it is just content for QDirModel diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro b/tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro new file mode 100644 index 0000000..487d0e1 --- /dev/null +++ b/tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro @@ -0,0 +1,17 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +macx:CONFIG -= app_bundle + +SOURCES += tst_qdeclarativefolderlistmodel.cpp + +# Define SRCDIR equal to test's source directory +symbian: { + DEFINES += SRCDIR=\".\" + importFiles.sources = data + importFiles.path = + DEPLOYMENT = importFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} + +CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp b/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp new file mode 100644 index 0000000..8a8bfe7 --- /dev/null +++ b/tests/auto/declarative/qdeclarativefolderlistmodel/tst_qdeclarativefolderlistmodel.cpp @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** 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 test suite 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$ +** +****************************************************************************/ +#include <qtest.h> +#include <QtTest/QSignalSpy> +#include "../../../shared/util.h" +#include <QtDeclarative/qdeclarativeengine.h> +#include <QtDeclarative/qdeclarativecomponent.h> +#include <QtCore/qdir.h> +#include <QtCore/qfile.h> +#include <QtCore/qabstractitemmodel.h> +#include <QDebug> + +// From qdeclarastivefolderlistmodel.h +const int FileNameRole = Qt::UserRole+1; +const int FilePathRole = Qt::UserRole+2; +enum SortField { Unsorted, Name, Time, Size, Type }; + +class tst_qdeclarativefolderlistmodel : public QObject +{ + Q_OBJECT +public: + tst_qdeclarativefolderlistmodel() {} + +private slots: + void basicProperties(); + +private: + void checkNoErrors(const QDeclarativeComponent& component); + QDeclarativeEngine engine; +}; + +void tst_qdeclarativefolderlistmodel::checkNoErrors(const QDeclarativeComponent& component) +{ + // Wait until the component is ready + QTRY_VERIFY(component.isReady() || component.isError()); + + if (component.isError()) { + QList<QDeclarativeError> errors = component.errors(); + for (int ii = 0; ii < errors.count(); ++ii) { + const QDeclarativeError &error = errors.at(ii); + QByteArray errorStr = QByteArray::number(error.line()) + ":" + + QByteArray::number(error.column()) + ":" + + error.description().toUtf8(); + qWarning() << errorStr; + } + } + QVERIFY(!component.isError()); +} + +void tst_qdeclarativefolderlistmodel::basicProperties() +{ + QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/basic.qml")); + checkNoErrors(component); + + QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create()); + QVERIFY(flm != 0); + + + flm->setProperty("folder",QUrl::fromLocalFile(SRCDIR "/data")); + QTRY_COMPARE(flm->property("count").toInt(),2); // wait for refresh + QCOMPARE(flm->property("folder").toUrl(), QUrl::fromLocalFile(SRCDIR "/data")); + QCOMPARE(flm->property("parentFolder").toUrl(), QUrl::fromLocalFile(SRCDIR)); + QCOMPARE(flm->property("sortField").toInt(), int(Name)); + QCOMPARE(flm->property("nameFilters").toStringList(), QStringList() << "*.qml"); + QCOMPARE(flm->property("sortReversed").toBool(), false); + QCOMPARE(flm->property("showDirs").toBool(), true); + QCOMPARE(flm->property("showDotAndDotDot").toBool(), false); + QCOMPARE(flm->property("showOnlyReadable").toBool(), false); + QCOMPARE(flm->data(flm->index(0),FileNameRole).toString(), QLatin1String("basic.qml")); + QCOMPARE(flm->data(flm->index(1),FileNameRole).toString(), QLatin1String("dummy.qml")); +} + +QTEST_MAIN(tst_qdeclarativefolderlistmodel) + +#include "tst_qdeclarativefolderlistmodel.moc" diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index e0143a6..720702a 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -400,7 +400,7 @@ T *tst_qdeclarativeimage::findItem(QGraphicsObject *parent, const QString &objec //qDebug() << "try" << item; if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { if (index != -1) { - QDeclarativeExpression e(qmlContext(item), "index", item); + QDeclarativeExpression e(qmlContext(item), item, "index"); if (e.evaluate().toInt() == index) return static_cast<T*>(item); } else { diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.errors.txt new file mode 100644 index 0000000..eb1430a --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.errors.txt @@ -0,0 +1 @@ +4:5:Cannot assign a value to a signal (expecting a script to be run) diff --git a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.qml index c84fea3..6fa1259 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.2.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.qml @@ -1,7 +1,6 @@ import Test 1.0 MyQmlObject { - onBasicSignal { - } + onBasicSignal: "hello world" } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.2.errors.txt deleted file mode 100644 index 8b20434..0000000 --- a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.2.errors.txt +++ /dev/null @@ -1 +0,0 @@ -4:5:Incorrectly specified signal assignment diff --git a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.errors.txt index 353bbf5..8b20434 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.errors.txt @@ -1 +1 @@ -4:5:Empty signal assignment +4:5:Incorrectly specified signal assignment diff --git a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.qml b/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.qml index 4c5a122..c84fea3 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.qml @@ -1,6 +1,7 @@ import Test 1.0 MyQmlObject { - onBasicSignal: " " + onBasicSignal { + } } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/scriptString2.qml b/tests/auto/declarative/qdeclarativelanguage/data/scriptString2.qml new file mode 100644 index 0000000..c42da2b --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/scriptString2.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyTypeObject { + scriptProperty: "hello\n\"world\"" +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/scriptString3.qml b/tests/auto/declarative/qdeclarativelanguage/data/scriptString3.qml new file mode 100644 index 0000000..0cd82ff --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/scriptString3.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyTypeObject { + scriptProperty: 12.345 +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/scriptString4.qml b/tests/auto/declarative/qdeclarativelanguage/data/scriptString4.qml new file mode 100644 index 0000000..3e2f9a4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/scriptString4.qml @@ -0,0 +1,5 @@ +import Test 1.0 + +MyTypeObject { + scriptProperty: true +} diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 6b070f5..200f016 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -351,8 +351,8 @@ void tst_qdeclarativelanguage::errors_data() QTest::newRow("invalidAttachedProperty.12") << "invalidAttachedProperty.12.qml" << "invalidAttachedProperty.12.errors.txt" << false; QTest::newRow("invalidAttachedProperty.13") << "invalidAttachedProperty.13.qml" << "invalidAttachedProperty.13.errors.txt" << false; + QTest::newRow("assignValueToSignal") << "assignValueToSignal.qml" << "assignValueToSignal.errors.txt" << false; QTest::newRow("emptySignal") << "emptySignal.qml" << "emptySignal.errors.txt" << false; - QTest::newRow("emptySignal.2") << "emptySignal.2.qml" << "emptySignal.2.errors.txt" << false; QTest::newRow("nestedErrors") << "nestedErrors.qml" << "nestedErrors.errors.txt" << false; QTest::newRow("defaultGrouped") << "defaultGrouped.qml" << "defaultGrouped.errors.txt" << false; @@ -1105,19 +1105,48 @@ void tst_qdeclarativelanguage::onDestruction() // Check that assignments to QDeclarativeScriptString properties work void tst_qdeclarativelanguage::scriptString() { - QDeclarativeComponent component(&engine, TEST_FILE("scriptString.qml")); - VERIFY_ERRORS(0); + { + QDeclarativeComponent component(&engine, TEST_FILE("scriptString.qml")); + VERIFY_ERRORS(0); - MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create()); - QVERIFY(object != 0); - QCOMPARE(object->scriptProperty().script(), QString("foo + bar")); - QCOMPARE(object->scriptProperty().scopeObject(), qobject_cast<QObject*>(object)); - QCOMPARE(object->scriptProperty().context(), qmlContext(object)); - - QVERIFY(object->grouped() != 0); - QCOMPARE(object->grouped()->script().script(), QString("console.log(1921)")); - QCOMPARE(object->grouped()->script().scopeObject(), qobject_cast<QObject*>(object)); - QCOMPARE(object->grouped()->script().context(), qmlContext(object)); + MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->scriptProperty().script(), QString("foo + bar")); + QCOMPARE(object->scriptProperty().scopeObject(), qobject_cast<QObject*>(object)); + QCOMPARE(object->scriptProperty().context(), qmlContext(object)); + + QVERIFY(object->grouped() != 0); + QCOMPARE(object->grouped()->script().script(), QString("console.log(1921)")); + QCOMPARE(object->grouped()->script().scopeObject(), qobject_cast<QObject*>(object)); + QCOMPARE(object->grouped()->script().context(), qmlContext(object)); + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("scriptString2.qml")); + VERIFY_ERRORS(0); + + MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->scriptProperty().script(), QString("\"hello\\n\\\"world\\\"\"")); + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("scriptString3.qml")); + VERIFY_ERRORS(0); + + MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->scriptProperty().script(), QString("12.345")); + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("scriptString4.qml")); + VERIFY_ERRORS(0); + + MyTypeObject *object = qobject_cast<MyTypeObject*>(component.create()); + QVERIFY(object != 0); + QCOMPARE(object->scriptProperty().script(), QString("true")); + } } // Check that default property assignments are correctly spliced into explicit diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp index 26a12f0..be4ffe8 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp +++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp @@ -275,7 +275,7 @@ void tst_qdeclarativelistmodel::dynamic() QDeclarativeListModel model; QDeclarativeEngine::setContextForObject(&model,engine.rootContext()); engine.rootContext()->setContextObject(&model); - QDeclarativeExpression e(engine.rootContext(), script, &model); + QDeclarativeExpression e(engine.rootContext(), &model, script); if (!warning.isEmpty()) QTest::ignoreMessage(QtWarningMsg, warning.toLatin1()); @@ -332,7 +332,7 @@ void tst_qdeclarativelistmodel::dynamic_worker() Q_ARG(QVariant, operations.mid(0, operations.length()-1)))); waitForWorker(item); - QDeclarativeExpression e(eng.rootContext(), operations.last().toString(), &model); + QDeclarativeExpression e(eng.rootContext(), &model, operations.last().toString()); if (QByteArray(QTest::currentDataTag()).startsWith("nested")) QVERIFY(e.evaluate().toInt() != result); else diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index ec2afae..fde2e43 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -1550,7 +1550,7 @@ T *tst_QDeclarativeListView::findItem(QGraphicsObject *parent, const QString &ob //qDebug() << "try" << item; if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { if (index != -1) { - QDeclarativeExpression e(qmlContext(item), "index", item); + QDeclarativeExpression e(qmlContext(item), item, "index"); if (e.evaluate().toInt() == index) return static_cast<T*>(item); } else { diff --git a/tests/auto/declarative/qdeclarativeloader/data/AnchoredLoader.qml b/tests/auto/declarative/qdeclarativeloader/data/AnchoredLoader.qml new file mode 100644 index 0000000..5d02dae --- /dev/null +++ b/tests/auto/declarative/qdeclarativeloader/data/AnchoredLoader.qml @@ -0,0 +1,14 @@ +import Qt 4.7 + +Rectangle { + width: 300 + height: 200 + color: "blue" + Loader { + objectName: "loader" + anchors.fill: parent + sourceComponent: Component { + Rectangle { color: "red"; objectName: "sourceElement" } + } + } +} diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp index 59580ea..11cc61b 100644 --- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp +++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp @@ -78,6 +78,7 @@ private slots: void clear(); void urlToComponent(); void componentToUrl(); + void anchoredLoader(); void sizeLoaderToItem(); void sizeItemToLoader(); void noResize(); @@ -266,6 +267,27 @@ void tst_QDeclarativeLoader::componentToUrl() delete item; } +void tst_QDeclarativeLoader::anchoredLoader() +{ + QDeclarativeComponent component(&engine, TEST_FILE("/AnchoredLoader.qml")); + QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(component.create()); + QVERIFY(rootItem != 0); + QDeclarativeItem *loader = rootItem->findChild<QDeclarativeItem*>("loader"); + QDeclarativeItem *sourceElement = rootItem->findChild<QDeclarativeItem*>("sourceElement"); + + QVERIFY(loader != 0); + QVERIFY(sourceElement != 0); + + QCOMPARE(rootItem->width(), 300.0); + QCOMPARE(rootItem->height(), 200.0); + + QCOMPARE(loader->width(), 300.0); + QCOMPARE(loader->height(), 200.0); + + QCOMPARE(sourceElement->width(), 300.0); + QCOMPARE(sourceElement->height(), 200.0); +} + void tst_QDeclarativeLoader::sizeLoaderToItem() { QDeclarativeComponent component(&engine, TEST_FILE("/SizeToItem.qml")); diff --git a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp index 0e16f66..f32a6c7 100644 --- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp +++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp @@ -760,7 +760,7 @@ T *tst_QDeclarativePathView::findItem(QGraphicsObject *parent, const QString &ob //qDebug() << "try" << item; if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { if (index != -1) { - QDeclarativeExpression e(qmlContext(item), "index", item); + QDeclarativeExpression e(qmlContext(item), item, "index"); if (e.evaluate().toInt() == index) return static_cast<T*>(item); } else { diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index c65c883..4befc4c 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -76,6 +76,8 @@ private slots: void persistentSelection(); void focusOnPress(); void selection(); + void mouseSelection_data(); + void mouseSelection(); void inputMethodHints(); void cursorDelegate(); @@ -602,6 +604,49 @@ void tst_qdeclarativetextedit::selection() QVERIFY(textEditObject->selectedText().size() == 10); } +void tst_qdeclarativetextedit::mouseSelection_data() +{ + QTest::addColumn<QString>("qmlfile"); + QTest::addColumn<bool>("expectSelection"); + + // import installed + QTest::newRow("on") << SRCDIR "/data/mouseselection_true.qml" << true; + QTest::newRow("off") << SRCDIR "/data/mouseselection_false.qml" << false; + QTest::newRow("default") << SRCDIR "/data/mouseselection_default.qml" << false; +} + +void tst_qdeclarativetextedit::mouseSelection() +{ + QFETCH(QString, qmlfile); + QFETCH(bool, expectSelection); + + QDeclarativeView *canvas = createView(qmlfile); + + canvas->show(); + QApplication::setActiveWindow(canvas); + QTest::qWaitForWindowShown(canvas); + QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas)); + + QVERIFY(canvas->rootObject() != 0); + QDeclarativeTextEdit *textEditObject = qobject_cast<QDeclarativeTextEdit *>(canvas->rootObject()); + QVERIFY(textEditObject != 0); + + // press-and-drag-and-release from x1 to x2 + int x1 = 10; + int x2 = 70; + int y = textEditObject->height()/2; + QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y))); + //QTest::mouseMove(canvas->viewport(), canvas->mapFromScene(QPoint(x2,y))); // doesn't work + QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); + QApplication::sendEvent(canvas->viewport(), &mv); + QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y))); + QString str = textEditObject->selectedText(); + if (expectSelection) + QVERIFY(str.length() > 3); // don't reallly care *what* was selected (and it's too sensitive to platform) + else + QVERIFY(str.isEmpty()); +} + void tst_qdeclarativetextedit::inputMethodHints() { QDeclarativeView *canvas = createView(SRCDIR "/data/inputmethodhints.qml"); diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp index c238ef9..8f3fb16 100644 --- a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp +++ b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp @@ -190,7 +190,7 @@ T *tst_qdeclarativevisualdatamodel::findItem(QGraphicsObject *parent, const QStr //qDebug() << "try" << item; if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { if (index != -1) { - QDeclarativeExpression e(qmlContext(item), "index", item); + QDeclarativeExpression e(qmlContext(item), item, "index"); if (e.evaluate().toInt() == index) return static_cast<T*>(item); } else { 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; diff --git a/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.0.png b/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.0.png Binary files differnew file mode 100644 index 0000000..135911c --- /dev/null +++ b/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.0.png diff --git a/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.1.png b/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.1.png Binary files differnew file mode 100644 index 0000000..0d71292 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.1.png diff --git a/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.2.png b/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.2.png Binary files differnew file mode 100644 index 0000000..920d992 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.2.png diff --git a/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.3.png b/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.3.png Binary files differnew file mode 100644 index 0000000..1c4d89e --- /dev/null +++ b/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.3.png diff --git a/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.qml b/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.qml new file mode 100644 index 0000000..9e1b923 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/animation/parentAnimation2/data/parentAnimation2.qml @@ -0,0 +1,1023 @@ +import Qt.VisualTest 4.7 + +VisualTest { + Frame { + msec: 0 + } + Frame { + msec: 16 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 32 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 48 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 64 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 80 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 96 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 112 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 128 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 144 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 160 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 176 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 192 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 208 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 224 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 240 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 256 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 272 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 288 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 304 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 320 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 336 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 352 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 368 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 384 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 400 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 416 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 432 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 448 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 464 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 480 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 496 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 512 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 528 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 544 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 560 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 576 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 592 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 608 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 624 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 640 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 656 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 672 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 688 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 704 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Mouse { + type: 2 + button: 1 + buttons: 1 + x: 350; y: 182 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 720 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 736 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 752 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 768 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 784 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 800 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Mouse { + type: 3 + button: 1 + buttons: 0 + x: 350; y: 182 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 816 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 832 + hash: "9b524b546d250d239ea99dd3319f3d6a" + } + Frame { + msec: 848 + hash: "593300f166c2fd3c325cb35114ca595b" + } + Frame { + msec: 864 + hash: "4451e76e111c99faa77b5fff9a2642fa" + } + Frame { + msec: 880 + hash: "0b4a5675afba935e17eba19e29b709ee" + } + Frame { + msec: 896 + hash: "8682866f0234eebf25aca27a7737c777" + } + Frame { + msec: 912 + hash: "5b3b70dd366bb4c1b5e7d56ce50e59a6" + } + Frame { + msec: 928 + hash: "897394982c93ebcbea68c25cec6d47d3" + } + Frame { + msec: 944 + hash: "23c3c0383a517d33767adeebc53bfa3a" + } + Frame { + msec: 960 + image: "parentAnimation2.0.png" + } + Frame { + msec: 976 + hash: "95b4fe1e5eeffe1673e199308e8ce76c" + } + Frame { + msec: 992 + hash: "dbb9a5aa9f569b97711aa2c1f5ebda47" + } + Frame { + msec: 1008 + hash: "0a5a73409b019e650ea860e1a8e27328" + } + Frame { + msec: 1024 + hash: "496bd0d053522bcf71d506b497ede0d5" + } + Frame { + msec: 1040 + hash: "97a32b4a6c99ffe842c35e903bd23d79" + } + Frame { + msec: 1056 + hash: "496dfbbb0c0c28e108adf4c25341ef11" + } + Frame { + msec: 1072 + hash: "aa2e5eb88b1498f0d36897be2a36b0ff" + } + Frame { + msec: 1088 + hash: "0c6f7b54264ab36cfd5145fb7b30432f" + } + Frame { + msec: 1104 + hash: "797fc3ea1db51f12d900b4e0e4998065" + } + Frame { + msec: 1120 + hash: "2b076b8bc1ec1e2f21a4d7a77c94cfeb" + } + Frame { + msec: 1136 + hash: "8d5888ca1cfba19cea569bd38bada417" + } + Frame { + msec: 1152 + hash: "15ae94de5aa106eaa18d0faefa5d61f5" + } + Frame { + msec: 1168 + hash: "96e90d74d5a7788d5a6da6cfdb92b185" + } + Frame { + msec: 1184 + hash: "5698a5e9e628209fc28644198eac65da" + } + Frame { + msec: 1200 + hash: "074ac8f08de8f22c241e23ad8b89b0f0" + } + Frame { + msec: 1216 + hash: "a49fdf41e9ee1e5d764262d4585af2ff" + } + Frame { + msec: 1232 + hash: "accc9b6573a676a40fcf0129085f6fce" + } + Frame { + msec: 1248 + hash: "1cc956d55f0c382c2f74dcc05a05494f" + } + Frame { + msec: 1264 + hash: "38ff3121566b2c719f47d027fcef8b8e" + } + Frame { + msec: 1280 + hash: "4de97b3361a16ca1710f2e75d5c9de6f" + } + Frame { + msec: 1296 + hash: "dbd1455105630bb8f262140e79ceda1b" + } + Frame { + msec: 1312 + hash: "bcdac4ab71a29b78bfa756b56b8d8414" + } + Frame { + msec: 1328 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1344 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1360 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1376 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1392 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1408 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1424 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1440 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1456 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1472 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1488 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1504 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1520 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1536 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1552 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1568 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1584 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1600 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1616 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1632 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1648 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1664 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1680 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1696 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1712 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Mouse { + type: 2 + button: 1 + buttons: 1 + x: 415; y: 121 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 1728 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1744 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1760 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1776 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1792 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1808 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1824 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Mouse { + type: 3 + button: 1 + buttons: 0 + x: 415; y: 121 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 1840 + hash: "f02f73a85532c1dd403d64c50c7e73ca" + } + Frame { + msec: 1856 + hash: "b59fbcfb7db77cf30ea4ff039a9163ae" + } + Frame { + msec: 1872 + hash: "432a76f0663bfd35f6bbeb3fbeb91799" + } + Frame { + msec: 1888 + hash: "098e18005d3a2ff9095587954c92339c" + } + Frame { + msec: 1904 + hash: "069100bf4ec523a9e9d5bf557ffc51d1" + } + Frame { + msec: 1920 + image: "parentAnimation2.1.png" + } + Frame { + msec: 1936 + hash: "60ed700e49bf2c51aba9b44400b56294" + } + Frame { + msec: 1952 + hash: "79aa15dc74668d963f36f28524f4d091" + } + Frame { + msec: 1968 + hash: "6838cb2d728259adc8d91a4a69e35adf" + } + Frame { + msec: 1984 + hash: "3f73c720ce5f1e65fb8537a9beb66d26" + } + Frame { + msec: 2000 + hash: "95d990ccd3e45e780d875aae1f4654f8" + } + Frame { + msec: 2016 + hash: "5389a121571f61e73903305860e60016" + } + Frame { + msec: 2032 + hash: "66f0018b6f35c1c18b28f4959eef96a8" + } + Frame { + msec: 2048 + hash: "c0fa0560a9a5a0f773394c4fd98c9fa3" + } + Frame { + msec: 2064 + hash: "e2d665ae0ac3007520003bb4a24ca708" + } + Frame { + msec: 2080 + hash: "ab6e6976e4214c725f71a4f0ba6d3f68" + } + Frame { + msec: 2096 + hash: "642f48f731f896d0d4b66956485b615b" + } + Frame { + msec: 2112 + hash: "cdc36222978e4361dd3ddc2cba78328d" + } + Frame { + msec: 2128 + hash: "22fe869d83d9d290c4d1702e7553c7aa" + } + Frame { + msec: 2144 + hash: "3cf2b6a4fd5c73c24717a1ce901cfb19" + } + Frame { + msec: 2160 + hash: "ea7ecad2a9b7e6ca9a9d1c9c46e0f6dc" + } + Frame { + msec: 2176 + hash: "3a7e7e2145b40732ef4e18218a959536" + } + Frame { + msec: 2192 + hash: "1386046373ab246ae533aba206ffe502" + } + Frame { + msec: 2208 + hash: "2183072e2117c2bc660767bc67e6c355" + } + Frame { + msec: 2224 + hash: "659c6fedf573d19727f9852a9034e4fe" + } + Frame { + msec: 2240 + hash: "5be4e8fa87593aeb4d59768a61441c37" + } + Frame { + msec: 2256 + hash: "2030b883508d07735b20726d218fd751" + } + Frame { + msec: 2272 + hash: "fd70334fa8a1ff80369cce6aa69255c4" + } + Frame { + msec: 2288 + hash: "be666aafc8a3d2de9ffaff54d9ac15d1" + } + Frame { + msec: 2304 + hash: "3370f2246f679068e40cdb48c92decad" + } + Frame { + msec: 2320 + hash: "f0b4565fd441c071112bdc8225861f76" + } + Frame { + msec: 2336 + hash: "61babd82afc20a3023c2fe483a2e73cb" + } + Frame { + msec: 2352 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2368 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2384 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2400 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2416 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2432 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2448 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2464 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2480 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2496 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2512 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2528 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2544 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2560 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2576 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2592 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2608 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2624 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2640 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2656 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2672 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2688 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2704 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2720 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2736 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2752 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2768 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Mouse { + type: 2 + button: 1 + buttons: 1 + x: 207; y: 255 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 2784 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2800 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2816 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2832 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2848 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2864 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2880 + image: "parentAnimation2.2.png" + } + Frame { + msec: 2896 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Mouse { + type: 3 + button: 1 + buttons: 0 + x: 207; y: 255 + modifiers: 0 + sendToViewport: true + } + Frame { + msec: 2912 + hash: "acab4a79f22ebc8a45759ae282e8f3db" + } + Frame { + msec: 2928 + hash: "608af88c841d6058c3304cc134de0187" + } + Frame { + msec: 2944 + hash: "96a727d6ff02c7baf85865fda9d871bd" + } + Frame { + msec: 2960 + hash: "22cacf109e40b457041d6c2862c4f97f" + } + Frame { + msec: 2976 + hash: "ea2a53381eef8ac75fce23c518f1e261" + } + Frame { + msec: 2992 + hash: "a719237e74e9c40b46cc1f27cca5e286" + } + Frame { + msec: 3008 + hash: "804ef3519ba9852afb0bd4ef793e0006" + } + Frame { + msec: 3024 + hash: "4abc5026f0de1165717bd14630c9d9f6" + } + Frame { + msec: 3040 + hash: "1e4dd04698691932725076073a0bd2e7" + } + Frame { + msec: 3056 + hash: "12aae9dcfd9597ce600588b19bdf5a7d" + } + Frame { + msec: 3072 + hash: "9176b69f7df68d860b7d7aecc2496f09" + } + Frame { + msec: 3088 + hash: "9cba95a510685ab6367ba87246f6c922" + } + Frame { + msec: 3104 + hash: "33ef448b9485fafb7a2af319f9f6e816" + } + Frame { + msec: 3120 + hash: "791760db748e46aceb9f469c33b7bf2f" + } + Frame { + msec: 3136 + hash: "201a00feef1bb445f2fd0ba8ef9467a1" + } + Frame { + msec: 3152 + hash: "6e8962c3cb522f5a45b093f1780d2dae" + } + Frame { + msec: 3168 + hash: "d75cb08203a4f2c05b4dfdca2196e3db" + } + Frame { + msec: 3184 + hash: "0417d681c9b64e2cc252ab6fcf20148b" + } + Frame { + msec: 3200 + hash: "85993e5a91a86cedb8c88819b035b6bb" + } + Frame { + msec: 3216 + hash: "d7a0db647e641df9625b8eb5078a8ec3" + } + Frame { + msec: 3232 + hash: "fa29824ed3fd3d4e0d8036079be6bcf8" + } + Frame { + msec: 3248 + hash: "4fc84a3ae74bb6ab7b0b846c8747eb54" + } + Frame { + msec: 3264 + hash: "a172921ffe15077382db8e8915fb340b" + } + Frame { + msec: 3280 + hash: "480ee71d2407d729814a2e19d4320c59" + } + Frame { + msec: 3296 + hash: "b8cf02a1ad96d5c3354f2b658085ed28" + } + Frame { + msec: 3312 + hash: "80fc0f57f58250f63a77b1988a9e1d2e" + } + Frame { + msec: 3328 + hash: "bc283b5d7c5b88ef447be5992a77b6a9" + } + Frame { + msec: 3344 + hash: "89c86df88dc1a3188d52c1f75b80ccf1" + } + Frame { + msec: 3360 + hash: "84148139d89b45949561321bd6f6c835" + } + Frame { + msec: 3376 + hash: "9118d6933b3f77e0b5b8da2d630152e8" + } + Frame { + msec: 3392 + hash: "2b5f746225053778fb07a606ff113e64" + } + Frame { + msec: 3408 + hash: "0a1ed1bea6ed674826d0a2c3146a1c31" + } + Frame { + msec: 3424 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3440 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3456 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3472 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3488 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3504 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3520 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3536 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3552 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3568 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3584 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3600 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3616 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3632 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3648 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Key { + type: 6 + key: 16777249 + modifiers: 67108864 + text: "" + autorep: false + count: 1 + } + Frame { + msec: 3664 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3680 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3696 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3712 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3728 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3744 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3760 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3776 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3792 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3808 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3824 + hash: "b3bfd7a06d3e246f4256ab5a267360b0" + } + Frame { + msec: 3840 + image: "parentAnimation2.3.png" + } +} diff --git a/tests/auto/declarative/qmlvisual/animation/parentAnimation2/parentAnimation2.qml b/tests/auto/declarative/qmlvisual/animation/parentAnimation2/parentAnimation2.qml new file mode 100644 index 0000000..dfab108 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/animation/parentAnimation2/parentAnimation2.qml @@ -0,0 +1,64 @@ +import Qt 4.7 + +/* +Blue rect fills (with 10px margin) screen, then red, then green, then screen again. +*/ + +Rectangle { + id: whiteRect + width: 640; height: 480; + + Rectangle { + id: redRect + x: 400; y: 50 + width: 100; height: 100 + color: "red" + } + + Rectangle { + id: greenRect + x: 100; y: 150 + width: 200; height: 300 + color: "green" + } + + Rectangle { + id: blueRect + x: 5; y: 5 + width: parent.width-10 + height: parent.height-10 + color: "lightblue" + + //Text { text: "Click me!"; anchors.centerIn: parent } + + MouseArea { + anchors.fill: parent + onClicked: { + switch(blueRect.state) { + case "": blueRect.state = "inRed"; break; + case "inRed": blueRect.state = "inGreen"; break; + case "inGreen": blueRect.state = ""; break; + } + } + } + + states: [ + State { + name: "inRed" + ParentChange { target: blueRect; parent: redRect; x: 5; y: 5; width: parent.width-10; height: parent.height-10 } + PropertyChanges { target: redRect; z: 1 } + }, + State { + name: "inGreen" + ParentChange { target: blueRect; parent: greenRect; x: 5; y: 5; width: parent.width-10; height: parent.height-10 } + PropertyChanges { target: greenRect; z: 1 } + } + ] + + transitions: Transition { + ParentAnimation { target: blueRect; //via: whiteRect; + NumberAnimation { properties: "x, y, width, height"; duration: 500 } + } + } + } +} diff --git a/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp b/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp index 4aad29b..f105692 100644 --- a/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp +++ b/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp @@ -105,6 +105,7 @@ void tst_qmlvisual::visual_data() files << QT_TEST_SOURCE_DIR "/qdeclarativeborderimage/animated.qml"; files << QT_TEST_SOURCE_DIR "/qdeclarativeflipable/test-flipable.qml"; files << QT_TEST_SOURCE_DIR "/qdeclarativepositioners/usingRepeater.qml"; + files << QT_TEST_SOURCE_DIR "/animation/parentAnimation2/parentAnimation2.qml"; //these are tests we think are stable and useful enough to be run by the CI system files << QT_TEST_SOURCE_DIR "/animation/bindinganimation/bindinganimation.qml"; 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 = "<sup>*</sup>" macro.rarrow.HTML = "→" diff --git a/tools/qml/content/Browser.qml b/tools/qml/content/Browser.qml index c3a2cc0..7238203 100644 --- a/tools/qml/content/Browser.qml +++ b/tools/qml/content/Browser.qml @@ -1,4 +1,5 @@ import Qt 4.7 +import Qt.labs.folderlistmodel 1.0 Rectangle { id: root @@ -12,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 } @@ -62,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 380f5cc..0cce1cc 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -50,7 +50,6 @@ #include <QDebug> #include <QMessageBox> #include "qdeclarativetester.h" -#include "qdeclarativefolderlistmodel.h" QT_USE_NAMESPACE @@ -86,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); } } @@ -111,14 +110,14 @@ void myMessageOutput(QtMsgType type, const char *msg) void usage() { - qWarning("Usage: qml [options] <filename>"); + qWarning("Usage: qmlviewer [options] <filename>"); qWarning(" "); qWarning(" options:"); qWarning(" -v, -version ............................. display version"); 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"); @@ -149,7 +148,7 @@ void usage() void scriptOptsUsage() { - qWarning("Usage: qml -scriptopts <option>[,<option>...] ..."); + qWarning("Usage: qmlviewer -scriptopts <option>[,<option>...] ..."); qWarning(" options:"); qWarning(" record ................................... record a new script"); qWarning(" play ..................................... playback an existing script"); @@ -157,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); @@ -181,7 +180,7 @@ int main(int argc, char ** argv) atexit(showWarnings); #endif -#if defined (Q_WS_X11) +#if defined (Q_WS_X11) || defined (Q_WS_MAC) //### default to using raster graphics backend for now bool gsSpecified = false; for (int i = 0; i < argc; ++i) { @@ -197,13 +196,12 @@ int main(int argc, char ** argv) #endif QApplication app(argc, argv); - app.setApplicationName("QtQmlLauncher"); + app.setApplicationName("QtQmlViewer"); app.setOrganizationName("Nokia"); app.setOrganizationDomain("nokia.com"); QDeclarativeViewer::registerTypes(); QDeclarativeTester::registerTypes(); - QDeclarativeFolderListModel::registerTypes(); bool frameless = false; QString fileName; @@ -236,6 +234,10 @@ int main(int argc, char ** argv) useNativeFileBrowser = false; #endif +#if defined(Q_WS_MAC) + useGL = true; +#endif + for (int i = 1; i < argc; ++i) { bool lastArg = (i == argc - 1); QString arg = argv[i]; @@ -275,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.pri b/tools/qml/qml.pri index a2058c7..5e3e74b 100644 --- a/tools/qml/qml.pri +++ b/tools/qml/qml.pri @@ -10,12 +10,10 @@ HEADERS += $$PWD/qmlruntime.h \ $$PWD/proxysettings.h \ $$PWD/qdeclarativetester.h \ $$PWD/deviceorientation.h \ - $$PWD/qdeclarativefolderlistmodel.h \ $$PWD/loggerwidget.h SOURCES += $$PWD/qmlruntime.cpp \ $$PWD/proxysettings.cpp \ $$PWD/qdeclarativetester.cpp \ - $$PWD/qdeclarativefolderlistmodel.cpp \ $$PWD/loggerwidget.cpp RESOURCES = $$PWD/qmlruntime.qrc diff --git a/tools/qml/qml.pro b/tools/qml/qml.pro index 6129639..9cdec77 100644 --- a/tools/qml/qml.pro +++ b/tools/qml/qml.pro @@ -37,6 +37,8 @@ symbian { } mac { QMAKE_INFO_PLIST=Info_mac.plist - TARGET="QML Launcher" + TARGET=QMLViewer ICON=qml.icns +} else { + TARGET=qmlviewer } diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index 9700090..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,17 +895,18 @@ 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()); QString fileName = url.toLocalFile(); if (!fileName.isEmpty()) { + fi.setFile(fileName); if (fi.exists()) { if (fi.suffix().toLower() != QLatin1String("qml")) { qWarning() << "qml cannot open non-QML file" << fileName; |