summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demos/declarative/minehunt/minehunt.qml7
-rw-r--r--demos/declarative/samegame/SamegameCore/BoomBlock.qml4
-rw-r--r--demos/declarative/twitter/TwitterCore/AuthView.qml13
-rw-r--r--doc/src/declarative/elements.qdoc10
-rw-r--r--doc/src/declarative/modules.qdoc33
-rw-r--r--doc/src/deployment/qt-conf.qdoc1
-rw-r--r--doc/src/snippets/declarative/listview/highlight.qml2
-rw-r--r--examples/declarative/aspectratio/face_fit_animated.qml4
-rw-r--r--examples/declarative/clocks/content/Clock.qml6
-rw-r--r--examples/declarative/dial/content/Dial.qml2
-rw-r--r--examples/declarative/listview/highlight.qml2
-rw-r--r--examples/declarative/plugins/com/nokia/TimeExample/Clock.qml4
-rw-r--r--examples/declarative/tutorials/samegame/samegame1/Button.qml6
-rw-r--r--examples/declarative/tutorials/samegame/samegame1/samegame.qml2
-rw-r--r--examples/declarative/tutorials/samegame/samegame2/Button.qml6
-rw-r--r--examples/declarative/tutorials/samegame/samegame2/samegame.js32
-rw-r--r--examples/declarative/tutorials/samegame/samegame2/samegame.qml2
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/Button.qml6
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/Dialog.qml8
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/samegame.js108
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/samegame.qml2
-rw-r--r--examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml4
-rw-r--r--examples/declarative/tutorials/samegame/samegame4/content/Button.qml6
-rw-r--r--examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml8
-rwxr-xr-xexamples/declarative/tutorials/samegame/samegame4/content/samegame.js130
-rwxr-xr-xexamples/declarative/tutorials/samegame/samegame4/highscores/scores.php5
-rw-r--r--examples/declarative/tutorials/samegame/samegame4/samegame.qml14
-rw-r--r--examples/declarative/tvtennis/tvtennis.qml6
-rw-r--r--examples/declarative/velocity/Day.qml11
-rw-r--r--examples/declarative/velocity/note-yellow.pngbin0 -> 54559 bytes
-rw-r--r--src/corelib/global/qlibraryinfo.cpp4
-rw-r--r--src/declarative/QmlChanges.txt16
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp39
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview_p.h5
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp49
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview_p.h10
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview.cpp29
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview_p.h5
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview_p_p.h4
-rw-r--r--src/declarative/qml/qdeclarativebinding.cpp8
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp19
-rw-r--r--src/declarative/qml/qdeclarativecompositetypemanager.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp144
-rw-r--r--src/declarative/qml/qdeclarativeengine.h6
-rw-r--r--src/declarative/qml/qdeclarativeengine_p.h5
-rw-r--r--src/declarative/qml/qdeclarativeinstruction.cpp6
-rw-r--r--src/declarative/qml/qdeclarativeinstruction_p.h2
-rw-r--r--src/declarative/qml/qdeclarativestringconverters.cpp8
-rw-r--r--src/declarative/qml/qdeclarativevme.cpp20
-rw-r--r--src/declarative/util/qdeclarativespringfollow.cpp47
-rw-r--r--src/declarative/util/qdeclarativespringfollow_p.h14
-rw-r--r--src/declarative/util/qdeclarativexmllistmodel.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp4
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/deletedEngine.qml11
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/nullObjectBinding.qml8
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/numberAssignment.qml18
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp1
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.h65
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp65
-rw-r--r--tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp20
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml14
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp32
-rw-r--r--tests/auto/declarative/qdeclarativespringfollow/data/springfollow2.qml2
-rw-r--r--tests/auto/declarative/qdeclarativespringfollow/data/springfollow3.qml2
-rw-r--r--tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp6
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.0.pngbin1563 -> 1578 bytes
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.1.pngbin1570 -> 1585 bytes
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.2.pngbin1553 -> 1568 bytes
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.3.pngbin1563 -> 1578 bytes
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.4.pngbin1569 -> 1584 bytes
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.5.pngbin1569 -> 1584 bytes
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.6.pngbin1566 -> 1581 bytes
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.7.pngbin1566 -> 1581 bytes
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.qml8
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativespringfollow/clock.qml6
-rw-r--r--tests/auto/declarative/qmlvisual/qdeclarativespringfollow/follow.qml10
-rw-r--r--tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/BoomBlock.qml4
-rw-r--r--tools/qml/main.cpp35
-rw-r--r--tools/qml/qmlruntime.cpp5
-rw-r--r--tools/qml/qmlruntime.h1
80 files changed, 877 insertions, 328 deletions
diff --git a/demos/declarative/minehunt/minehunt.qml b/demos/declarative/minehunt/minehunt.qml
index 299e722..4e384c0 100644
--- a/demos/declarative/minehunt/minehunt.qml
+++ b/demos/declarative/minehunt/minehunt.qml
@@ -141,4 +141,11 @@ Item {
MouseArea { anchors.fill: parent; onPressed: reset() }
}
+ Text {
+ anchors.fill: parent; wrap: true
+ text: "Minehunt will not run properly if the C++ plugin is not compiled.\nPlease see README."
+ color: "white"; font.bold: true; font.pixelSize: 14
+ visible: tiles == undefined
+ }
+
}
diff --git a/demos/declarative/samegame/SamegameCore/BoomBlock.qml b/demos/declarative/samegame/SamegameCore/BoomBlock.qml
index 838b346..db43182 100644
--- a/demos/declarative/samegame/SamegameCore/BoomBlock.qml
+++ b/demos/declarative/samegame/SamegameCore/BoomBlock.qml
@@ -8,8 +8,8 @@ Item { id:block
property int targetX: 0
property int targetY: 0
- SpringFollow on x { enabled: spawned; source: targetX; spring: 2; damping: 0.2 }
- SpringFollow on y { source: targetY; spring: 2; damping: 0.2 }
+ SpringFollow on x { enabled: spawned; to: targetX; spring: 2; damping: 0.2 }
+ SpringFollow on y { to: targetY; spring: 2; damping: 0.2 }
Image { id: img
source: {
diff --git a/demos/declarative/twitter/TwitterCore/AuthView.qml b/demos/declarative/twitter/TwitterCore/AuthView.qml
index 9d9341a..7986e74 100644
--- a/demos/declarative/twitter/TwitterCore/AuthView.qml
+++ b/demos/declarative/twitter/TwitterCore/AuthView.qml
@@ -24,7 +24,8 @@ Item {
font.pixelSize: 16;
font.bold: true
color: "#151515"; selectionColor: "green"
- KeyNavigation.down: passIn
+ KeyNavigation.tab: passIn
+ KeyNavigation.backtab: guest
focus: true
}
}
@@ -49,8 +50,8 @@ Item {
font.pixelSize: 16;
font.bold: true
color: "#151515"; selectionColor: "green"
- KeyNavigation.down: login
- KeyNavigation.up: nameIn
+ KeyNavigation.tab: login
+ KeyNavigation.backtab: nameIn
}
}
}
@@ -69,7 +70,8 @@ Item {
}
text: "Log in"
KeyNavigation.right: guest
- KeyNavigation.up: passIn
+ KeyNavigation.tab: guest
+ KeyNavigation.backtab: passIn
Keys.onReturnPressed: login.doLogin();
Keys.onSelectPressed: login.doLogin();
Keys.onSpacePressed: login.doLogin();
@@ -88,7 +90,8 @@ Item {
}
text: "Guest"
KeyNavigation.left: login
- KeyNavigation.up: passIn
+ KeyNavigation.tab: nameIn
+ KeyNavigation.backtab: login
Keys.onReturnPressed: guest.doGuest();
Keys.onSelectPressed: guest.doGuest();
Keys.onSpacePressed: guest.doGuest();
diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc
index 1bb739d..4946346 100644
--- a/doc/src/declarative/elements.qdoc
+++ b/doc/src/declarative/elements.qdoc
@@ -88,11 +88,17 @@ The following table lists the QML elements provided by the Qt Declarative module
\o
\list
\o \l Binding
-\o \l ListModel, \l ListElement
+\o \l ListModel
+\list
+\o \l ListElement
+\endlist
\o \l VisualItemModel
\o \l VisualDataModel
\o \l Package
-\o \l XmlListModel and XmlRole
+\o \l XmlListModel
+\list
+\o \l XmlRole
+\endlist
\endlist
\o
diff --git a/doc/src/declarative/modules.qdoc b/doc/src/declarative/modules.qdoc
index 68e58fb..0e332d4 100644
--- a/doc/src/declarative/modules.qdoc
+++ b/doc/src/declarative/modules.qdoc
@@ -86,7 +86,7 @@ The second exception is explained in more detail in the section below on Namespa
\section2 The Import Path
Installed modules are searched for on the import path.
-The \c -L option to the \l {Qt Declarative UI Runtime}{qml} runtime adds paths to the import path.
+The \c -I option to the \l {Qt Declarative UI Runtime}{qml} runtime adds paths to the import path.
From C++, the path is available via \l QDeclarativeEngine::importPathList() and can be prepended to
using \l QDeclarativeEngine::addImportPath().
@@ -114,19 +114,7 @@ Installed files do not need to import the module of which they are a part, as th
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:
-
-\code
-internal <TypeName> <File>
-\endcode
-
-\c plugin <Name> [<Path>] lines are used to add \l{QDeclarativeExtensionPlugin}{QML C++ plugins}
-to the module. <Name> is the
-name of the library. <Path> is an optional argument specifying the full path to the directory
-containing the plugin file; if it is omitted then the directory is assumed to be the same as
-the directory of the \c qmldir file. Note that <Name> is not usually the same as the file name
-of the plugin binary, which is platform dependent; e.g. the library MyAppTypes would produce
-a libMyAppTypes.so on Linux and MyAppTypes.dll on Windows.
+may be marked with the \c internal keyword: \c internal <TypeName> <File>.
The same type can be provided by different files in different versions, in which
case later earlier versions (eg. 1.2) must precede earlier versions (eg. 1.0),
@@ -141,6 +129,23 @@ of installed software, since a versioned import \e only imports types for that v
leaving other identifiers available, even if the actual installed version might otherwise
provide those identifiers.
+\c plugin <Name> [<Path>] lines are used to add \l{QDeclarativeExtensionPlugin}{QML C++ plugins}
+to the module.
+
+<Name> 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 MyAppTypes would produce
+a libMyAppTypes.so on Linux and MyAppTypes.dll on Windows.
+By default the engine searches for the plugin library in the directory containing the \c qmldir
+file. The \c -P option to the \l {Qt Declarative UI Runtime}{qml} runtime adds paths to the
+plugin search path.
+From C++, the path is available via \l QDeclarativeEngine::pluginPathList() and can be prepended to
+using \l QDeclarativeEngine::addPluginPath().
+
+<Path> 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.
+
+
\section2 Namespaces - Named Imports
When importing content it by default imports types into the global namespace.
diff --git a/doc/src/deployment/qt-conf.qdoc b/doc/src/deployment/qt-conf.qdoc
index b195889..298f539 100644
--- a/doc/src/deployment/qt-conf.qdoc
+++ b/doc/src/deployment/qt-conf.qdoc
@@ -87,6 +87,7 @@
\row \o Libraries \o \c lib
\row \o Binaries \o \c bin
\row \o Plugins \o \c plugins
+ \row \o Imports \o \c imports
\row \o Data \o \c .
\row \o Translations \o \c translations
\row \o Settings \o \c .
diff --git a/doc/src/snippets/declarative/listview/highlight.qml b/doc/src/snippets/declarative/listview/highlight.qml
index 6a9d215..fe5cc53 100644
--- a/doc/src/snippets/declarative/listview/highlight.qml
+++ b/doc/src/snippets/declarative/listview/highlight.qml
@@ -45,7 +45,7 @@ Rectangle {
width: 180; height: 40
color: "lightsteelblue"; radius: 5
SpringFollow on y {
- source: list.currentItem.y
+ to: list.currentItem.y
spring: 3
damping: 0.2
}
diff --git a/examples/declarative/aspectratio/face_fit_animated.qml b/examples/declarative/aspectratio/face_fit_animated.qml
index 97f4791..63fc9c6 100644
--- a/examples/declarative/aspectratio/face_fit_animated.qml
+++ b/examples/declarative/aspectratio/face_fit_animated.qml
@@ -19,8 +19,8 @@ Rectangle {
x: (parent.width-width*scale)/2
y: (parent.height-height*scale)/2
SpringFollow on scale {
- source: Math.max(Math.min(face.parent.width/face.width*1.333,face.parent.height/face.height),
- Math.min(face.parent.width/face.width,face.parent.height/face.height*1.333))
+ to: Math.max(Math.min(face.parent.width/face.width*1.333,face.parent.height/face.height),
+ Math.min(face.parent.width/face.width,face.parent.height/face.height*1.333))
spring: 1
damping: 0.05
}
diff --git a/examples/declarative/clocks/content/Clock.qml b/examples/declarative/clocks/content/Clock.qml
index a315ccc..c853174 100644
--- a/examples/declarative/clocks/content/Clock.qml
+++ b/examples/declarative/clocks/content/Clock.qml
@@ -36,7 +36,7 @@ Item {
origin.x: 7.5; origin.y: 73; angle: 0
SpringFollow on angle {
spring: 2; damping: 0.2; modulus: 360
- source: (clock.hours * 30) + (clock.minutes * 0.5)
+ to: (clock.hours * 30) + (clock.minutes * 0.5)
}
}
}
@@ -50,7 +50,7 @@ Item {
origin.x: 6.5; origin.y: 83; angle: 0
SpringFollow on angle {
spring: 2; damping: 0.2; modulus: 360
- source: clock.minutes * 6
+ to: clock.minutes * 6
}
}
}
@@ -64,7 +64,7 @@ Item {
origin.x: 2.5; origin.y: 80; angle: 0
SpringFollow on angle {
spring: 5; damping: 0.25; modulus: 360
- source: clock.seconds * 6
+ to: clock.seconds * 6
}
}
}
diff --git a/examples/declarative/dial/content/Dial.qml b/examples/declarative/dial/content/Dial.qml
index 7fd638a..f9ab3e3 100644
--- a/examples/declarative/dial/content/Dial.qml
+++ b/examples/declarative/dial/content/Dial.qml
@@ -29,7 +29,7 @@ Item {
SpringFollow on angle {
spring: 1.4
damping: .15
- source: Math.min(Math.max(-130, root.value*2.6 - 130), 133)
+ to: Math.min(Math.max(-130, root.value*2.6 - 130), 133)
}
}
}
diff --git a/examples/declarative/listview/highlight.qml b/examples/declarative/listview/highlight.qml
index 5493f99..2b54dd8 100644
--- a/examples/declarative/listview/highlight.qml
+++ b/examples/declarative/listview/highlight.qml
@@ -44,7 +44,7 @@ Rectangle {
id: petHighlight
Rectangle {
width: 200; height: 50; color: "#FFFF88"
- SpringFollow on y { source: list1.currentItem.y; spring: 3; damping: 0.1 }
+ SpringFollow on y { to: list1.currentItem.y; spring: 3; damping: 0.1 }
}
}
ListView {
diff --git a/examples/declarative/plugins/com/nokia/TimeExample/Clock.qml b/examples/declarative/plugins/com/nokia/TimeExample/Clock.qml
index 3ebbeab..ce1dd69 100644
--- a/examples/declarative/plugins/com/nokia/TimeExample/Clock.qml
+++ b/examples/declarative/plugins/com/nokia/TimeExample/Clock.qml
@@ -20,7 +20,7 @@ Rectangle {
origin.x: 7.5; origin.y: 73; angle: 0
SpringFollow on angle {
spring: 2; damping: 0.2; modulus: 360
- source: (clock.hours * 30) + (clock.minutes * 0.5)
+ to: (clock.hours * 30) + (clock.minutes * 0.5)
}
}
}
@@ -34,7 +34,7 @@ Rectangle {
origin.x: 6.5; origin.y: 83; angle: 0
SpringFollow on angle {
spring: 2; damping: 0.2; modulus: 360
- source: clock.minutes * 6
+ to: clock.minutes * 6
}
}
}
diff --git a/examples/declarative/tutorials/samegame/samegame1/Button.qml b/examples/declarative/tutorials/samegame/samegame1/Button.qml
index 8eee2ad..6798c32 100644
--- a/examples/declarative/tutorials/samegame/samegame1/Button.qml
+++ b/examples/declarative/tutorials/samegame/samegame1/Button.qml
@@ -8,12 +8,12 @@ Rectangle {
property string text: "Button"
color: activePalette.button; smooth: true
- width: txtItem.width + 20; height: txtItem.height + 6
+ width: buttonLabel.width + 20; height: buttonLabel.height + 6
border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8;
gradient: Gradient {
GradientStop {
- id: topGrad; position: 0.0
+ position: 0.0
color: if (mouseArea.pressed) { activePalette.dark } else { activePalette.light } }
GradientStop { position: 1.0; color: activePalette.button }
}
@@ -21,7 +21,7 @@ Rectangle {
MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() }
Text {
- id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
+ id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
}
}
//![0]
diff --git a/examples/declarative/tutorials/samegame/samegame1/samegame.qml b/examples/declarative/tutorials/samegame/samegame1/samegame.qml
index 23a25f3..ae881ba 100644
--- a/examples/declarative/tutorials/samegame/samegame1/samegame.qml
+++ b/examples/declarative/tutorials/samegame/samegame1/samegame.qml
@@ -24,7 +24,7 @@ Rectangle {
anchors.bottom: screen.bottom
Button {
- id: btnA; text: "New Game"; onClicked: console.log("Starting a new game...");
+ text: "New Game"; onClicked: console.log("Starting a new game...");
anchors.left: parent.left; anchors.leftMargin: 3
anchors.verticalCenter: parent.verticalCenter
}
diff --git a/examples/declarative/tutorials/samegame/samegame2/Button.qml b/examples/declarative/tutorials/samegame/samegame2/Button.qml
index 64a8a5a..04d1d1f 100644
--- a/examples/declarative/tutorials/samegame/samegame2/Button.qml
+++ b/examples/declarative/tutorials/samegame/samegame2/Button.qml
@@ -7,12 +7,12 @@ Rectangle {
property string text: "Button"
color: activePalette.button; smooth: true
- width: txtItem.width + 20; height: txtItem.height + 6
+ width: buttonLabel.width + 20; height: buttonLabel.height + 6
border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8;
gradient: Gradient {
GradientStop {
- id: topGrad; position: 0.0
+ position: 0.0
color: if (mouseArea.pressed) { activePalette.dark } else { activePalette.light } }
GradientStop { position: 1.0; color: activePalette.button }
}
@@ -20,6 +20,6 @@ Rectangle {
MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() }
Text {
- id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
+ id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
}
}
diff --git a/examples/declarative/tutorials/samegame/samegame2/samegame.js b/examples/declarative/tutorials/samegame/samegame2/samegame.js
index 0ec3a8b..d7cbd8d 100644
--- a/examples/declarative/tutorials/samegame/samegame2/samegame.js
+++ b/examples/declarative/tutorials/samegame/samegame2/samegame.js
@@ -1,16 +1,16 @@
//![0]
//Note that X/Y referred to here are in game coordinates
-var maxX = 10;//Nums are for tileSize 40
-var maxY = 15;
+var maxColumn = 10;//Nums are for tileSize 40
+var maxRow = 15;
var tileSize = 40;
-var maxIndex = maxX*maxY;
+var maxIndex = maxColumn*maxRow;
var board = new Array(maxIndex);
var tileSrc = "Block.qml";
var component;
//Index function used instead of a 2D array
-function index(xIdx,yIdx) {
- return xIdx + (yIdx * maxX);
+function index(column,row) {
+ return column + (row * maxColumn);
}
function initBoard()
@@ -22,21 +22,21 @@ function initBoard()
}
//Calculate board size
- maxX = Math.floor(background.width/tileSize);
- maxY = Math.floor(background.height/tileSize);
- maxIndex = maxY*maxX;
+ maxColumn = Math.floor(background.width/tileSize);
+ maxRow = Math.floor(background.height/tileSize);
+ maxIndex = maxRow*maxColumn;
//Initialize Board
board = new Array(maxIndex);
- for(var xIdx=0; xIdx<maxX; xIdx++){
- for(var yIdx=0; yIdx<maxY; yIdx++){
- board[index(xIdx,yIdx)] = null;
- createBlock(xIdx,yIdx);
+ for(var column=0; column<maxColumn; column++){
+ for(var row=0; row<maxRow; row++){
+ board[index(column,row)] = null;
+ createBlock(column,row);
}
}
}
-function createBlock(xIdx,yIdx){
+function createBlock(column,row){
if(component==null)
component = createComponent(tileSrc);
@@ -52,11 +52,11 @@ function createBlock(xIdx,yIdx){
return false;
}
dynamicObject.parent = background;
- dynamicObject.x = xIdx*tileSize;
- dynamicObject.y = yIdx*tileSize;
+ dynamicObject.x = column*tileSize;
+ dynamicObject.y = row*tileSize;
dynamicObject.width = tileSize;
dynamicObject.height = tileSize;
- board[index(xIdx,yIdx)] = dynamicObject;
+ board[index(column,row)] = dynamicObject;
}else{//isError or isLoading
print("error loading block component");
print(component.errorsString());
diff --git a/examples/declarative/tutorials/samegame/samegame2/samegame.qml b/examples/declarative/tutorials/samegame/samegame2/samegame.qml
index a8a58ba..d98d383 100644
--- a/examples/declarative/tutorials/samegame/samegame2/samegame.qml
+++ b/examples/declarative/tutorials/samegame/samegame2/samegame.qml
@@ -27,7 +27,7 @@ Rectangle {
//![1]
Button {
- id: btnA; text: "New Game"; onClicked: SameGame.initBoard();
+ text: "New Game"; onClicked: SameGame.initBoard();
anchors.left: parent.left; anchors.leftMargin: 3
anchors.verticalCenter: parent.verticalCenter
}
diff --git a/examples/declarative/tutorials/samegame/samegame3/Button.qml b/examples/declarative/tutorials/samegame/samegame3/Button.qml
index 64a8a5a..04d1d1f 100644
--- a/examples/declarative/tutorials/samegame/samegame3/Button.qml
+++ b/examples/declarative/tutorials/samegame/samegame3/Button.qml
@@ -7,12 +7,12 @@ Rectangle {
property string text: "Button"
color: activePalette.button; smooth: true
- width: txtItem.width + 20; height: txtItem.height + 6
+ width: buttonLabel.width + 20; height: buttonLabel.height + 6
border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8;
gradient: Gradient {
GradientStop {
- id: topGrad; position: 0.0
+ position: 0.0
color: if (mouseArea.pressed) { activePalette.dark } else { activePalette.light } }
GradientStop { position: 1.0; color: activePalette.button }
}
@@ -20,6 +20,6 @@ Rectangle {
MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() }
Text {
- id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
+ id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
}
}
diff --git a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml
index 69bae7c..6c358d6 100644
--- a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml
+++ b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml
@@ -8,16 +8,16 @@ Rectangle {
page.opacity = 0;
}
function show(txt) {
- myText.text = txt;
+ dialogText.text = txt;
page.opacity = 1;
}
signal closed();
- color: "white"; border.width: 1; width: myText.width + 20; height: 60;
+ color: "white"; border.width: 1; width: dialogText.width + 20; height: 60;
opacity: 0
Behavior on opacity {
NumberAnimation { duration: 1000 }
}
- Text { id: myText; anchors.centerIn: parent; text: "Hello World!" }
- MouseArea { id: mouseArea; anchors.fill: parent; onClicked: forceClose(); }
+ Text { id: dialogText; anchors.centerIn: parent; text: "Hello World!" }
+ MouseArea { anchors.fill: parent; onClicked: forceClose(); }
}
//![0]
diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.js b/examples/declarative/tutorials/samegame/samegame3/samegame.js
index 33449fa..432e88f 100644
--- a/examples/declarative/tutorials/samegame/samegame3/samegame.js
+++ b/examples/declarative/tutorials/samegame/samegame3/samegame.js
@@ -1,23 +1,23 @@
/* This script file handles the game logic */
//Note that X/Y referred to here are in game coordinates
-var maxX = 10;//Nums are for tileSize 40
-var maxY = 15;
-var maxIndex = maxX*maxY;
+var maxColumn = 10;//Nums are for tileSize 40
+var maxRow = 15;
+var maxIndex = maxColumn*maxRow;
var board = new Array(maxIndex);
var tileSrc = "Block.qml";
var component;
//Index function used instead of a 2D array
-function index(xIdx,yIdx) {
- return xIdx + (yIdx * maxX);
+function index(column,row) {
+ return column + (row * maxColumn);
}
function initBoard()
{
//Calculate board size
- maxX = Math.floor(gameCanvas.width/gameCanvas.tileSize);
- maxY = Math.floor(gameCanvas.height/gameCanvas.tileSize);
- maxIndex = maxY*maxX;
+ maxColumn = Math.floor(gameCanvas.width/gameCanvas.tileSize);
+ maxRow = Math.floor(gameCanvas.height/gameCanvas.tileSize);
+ maxIndex = maxRow*maxColumn;
//Close dialogs
dialog.forceClose();
@@ -25,15 +25,15 @@ function initBoard()
//Initialize Board
board = new Array(maxIndex);
gameCanvas.score = 0;
- for(var xIdx=0; xIdx<maxX; xIdx++){
- for(var yIdx=0; yIdx<maxY; yIdx++){
- board[index(xIdx,yIdx)] = null;
- createBlock(xIdx,yIdx);
+ for(var column=0; column<maxColumn; column++){
+ for(var row=0; row<maxRow; row++){
+ board[index(column,row)] = null;
+ createBlock(column,row);
}
}
}
-function createBlock(xIdx,yIdx){
+function createBlock(column,row){
if(component==null)
component = createComponent(tileSrc);
@@ -50,11 +50,11 @@ function createBlock(xIdx,yIdx){
}
dynamicObject.type = Math.floor(Math.random() * 3);
dynamicObject.parent = gameCanvas;
- dynamicObject.x = xIdx*gameCanvas.tileSize;
- dynamicObject.y = yIdx*gameCanvas.tileSize;
+ dynamicObject.x = column*gameCanvas.tileSize;
+ dynamicObject.y = row*gameCanvas.tileSize;
dynamicObject.width = gameCanvas.tileSize;
dynamicObject.height = gameCanvas.tileSize;
- board[index(xIdx,yIdx)] = dynamicObject;
+ board[index(column,row)] = dynamicObject;
}else{//isError or isLoading
print("error loading block component");
print(component.errorsString());
@@ -69,14 +69,14 @@ var floodBoard;//Set to 1 if the floodFill reaches off that node
//![1]
function handleClick(x,y)
{
- var xIdx = Math.floor(x/gameCanvas.tileSize);
- var yIdx = Math.floor(y/gameCanvas.tileSize);
- if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0)
+ var column = Math.floor(x/gameCanvas.tileSize);
+ var row = Math.floor(y/gameCanvas.tileSize);
+ if(column >= maxColumn || column < 0 || row >= maxRow || row < 0)
return;
- if(board[index(xIdx, yIdx)] == null)
+ if(board[index(column, row)] == null)
return;
//If it's a valid tile, remove it and all connected (does nothing if it's not connected)
- floodFill(xIdx,yIdx, -1);
+ floodFill(column,row, -1);
if(fillFound <= 0)
return;
gameCanvas.score += (fillFound - 1) * (fillFound - 1);
@@ -85,67 +85,67 @@ function handleClick(x,y)
}
//![1]
-function floodFill(xIdx,yIdx,type)
+function floodFill(column,row,type)
{
- if(board[index(xIdx, yIdx)] == null)
+ if(board[index(column, row)] == null)
return;
var first = false;
if(type == -1){
first = true;
- type = board[index(xIdx,yIdx)].type;
+ type = board[index(column,row)].type;
//Flood fill initialization
fillFound = 0;
floodBoard = new Array(maxIndex);
}
- if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0)
+ if(column >= maxColumn || column < 0 || row >= maxRow || row < 0)
return;
- if(floodBoard[index(xIdx, yIdx)] == 1 || (!first && type != board[index(xIdx,yIdx)].type))
+ if(floodBoard[index(column, row)] == 1 || (!first && type != board[index(column,row)].type))
return;
- floodBoard[index(xIdx, yIdx)] = 1;
- floodFill(xIdx+1,yIdx,type);
- floodFill(xIdx-1,yIdx,type);
- floodFill(xIdx,yIdx+1,type);
- floodFill(xIdx,yIdx-1,type);
+ 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 tiles
- board[index(xIdx,yIdx)].opacity = 0;
- board[index(xIdx,yIdx)] = null;
+ board[index(column,row)].opacity = 0;
+ board[index(column,row)] = null;
fillFound += 1;
}
function shuffleDown()
{
//Fall down
- for(var xIdx=0; xIdx<maxX; xIdx++){
+ for(var column=0; column<maxColumn; column++){
var fallDist = 0;
- for(var yIdx=maxY-1; yIdx>=0; yIdx--){
- if(board[index(xIdx,yIdx)] == null){
+ for(var row=maxRow-1; row>=0; row--){
+ if(board[index(column,row)] == null){
fallDist += 1;
}else{
if(fallDist > 0){
- var obj = board[index(xIdx,yIdx)];
+ var obj = board[index(column,row)];
obj.y += fallDist * gameCanvas.tileSize;
- board[index(xIdx,yIdx+fallDist)] = obj;
- board[index(xIdx,yIdx)] = null;
+ board[index(column,row+fallDist)] = obj;
+ board[index(column,row)] = null;
}
}
}
}
//Fall to the left
var fallDist = 0;
- for(var xIdx=0; xIdx<maxX; xIdx++){
- if(board[index(xIdx, maxY - 1)] == null){
+ for(var column=0; column<maxColumn; column++){
+ if(board[index(column, maxRow - 1)] == null){
fallDist += 1;
}else{
if(fallDist > 0){
- for(var yIdx=0; yIdx<maxY; yIdx++){
- var obj = board[index(xIdx,yIdx)];
+ for(var row=0; row<maxRow; row++){
+ var obj = board[index(column,row)];
if(obj == null)
continue;
obj.x -= fallDist * gameCanvas.tileSize;
- board[index(xIdx-fallDist,yIdx)] = obj;
- board[index(xIdx,yIdx)] = null;
+ board[index(column-fallDist,row)] = obj;
+ board[index(column,row)] = null;
}
}
}
@@ -157,27 +157,27 @@ function victoryCheck()
{
//awards bonuses for no tiles left
var deservesBonus = true;
- for(var xIdx=maxX-1; xIdx>=0; xIdx--)
- if(board[index(xIdx, maxY - 1)] != null)
+ for(var column=maxColumn-1; column>=0; column--)
+ if(board[index(column, maxRow - 1)] != null)
deservesBonus = false;
if(deservesBonus)
gameCanvas.score += 500;
//Checks for game over
- if(deservesBonus || !(floodMoveCheck(0,maxY-1, -1)))
+ 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 tiles
-function floodMoveCheck(xIdx, yIdx, type)
+function floodMoveCheck(column, row, type)
{
- if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0)
+ if(column >= maxColumn || column < 0 || row >= maxRow || row < 0)
return false;
- if(board[index(xIdx, yIdx)] == null)
+ if(board[index(column, row)] == null)
return false;
- var myType = board[index(xIdx, yIdx)].type;
+ var myType = board[index(column, row)].type;
if(type == myType)
return true;
- return floodMoveCheck(xIdx + 1, yIdx, myType) ||
- floodMoveCheck(xIdx, yIdx - 1, board[index(xIdx,yIdx)].type);
+ return floodMoveCheck(column + 1, row, myType) ||
+ floodMoveCheck(column, row - 1, board[index(column,row)].type);
}
diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.qml b/examples/declarative/tutorials/samegame/samegame3/samegame.qml
index cd9dca5..9623932 100644
--- a/examples/declarative/tutorials/samegame/samegame3/samegame.qml
+++ b/examples/declarative/tutorials/samegame/samegame3/samegame.qml
@@ -45,7 +45,7 @@ Rectangle {
anchors.bottom: screen.bottom
Button {
- id: btnA; text: "New Game"; onClicked: SameGame.initBoard();
+ text: "New Game"; onClicked: SameGame.initBoard();
anchors.left: parent.left; anchors.leftMargin: 3
anchors.verticalCenter: parent.verticalCenter
}
diff --git a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml
index b598b3f..243df75 100644
--- a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml
+++ b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml
@@ -9,8 +9,8 @@ Item { id:block
property int targetX: 0
property int targetY: 0
- SpringFollow on x { source: targetX; spring: 2; damping: 0.2; enabled: spawned }
- SpringFollow on y { source: targetY; spring: 2; damping: 0.2 }
+ SpringFollow on x { to: targetX; spring: 2; damping: 0.2; enabled: spawned }
+ SpringFollow on y { to: targetY; spring: 2; damping: 0.2 }
//![1]
//![2]
diff --git a/examples/declarative/tutorials/samegame/samegame4/content/Button.qml b/examples/declarative/tutorials/samegame/samegame4/content/Button.qml
index 64a8a5a..04d1d1f 100644
--- a/examples/declarative/tutorials/samegame/samegame4/content/Button.qml
+++ b/examples/declarative/tutorials/samegame/samegame4/content/Button.qml
@@ -7,12 +7,12 @@ Rectangle {
property string text: "Button"
color: activePalette.button; smooth: true
- width: txtItem.width + 20; height: txtItem.height + 6
+ width: buttonLabel.width + 20; height: buttonLabel.height + 6
border.width: 1; border.color: Qt.darker(activePalette.button); radius: 8;
gradient: Gradient {
GradientStop {
- id: topGrad; position: 0.0
+ position: 0.0
color: if (mouseArea.pressed) { activePalette.dark } else { activePalette.light } }
GradientStop { position: 1.0; color: activePalette.button }
}
@@ -20,6 +20,6 @@ Rectangle {
MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() }
Text {
- id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
+ id: buttonLabel; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
}
}
diff --git a/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml b/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml
index 49fd5f6..0716bb3 100644
--- a/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml
+++ b/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml
@@ -7,15 +7,15 @@ Rectangle {
page.opacity = 0;
}
function show(txt) {
- myText.text = txt;
+ dialogText.text = txt;
page.opacity = 1;
}
signal closed();
- color: "white"; border.width: 1; width: myText.width + 20; height: 60;
+ color: "white"; border.width: 1; width: dialogText.width + 20; height: 60;
opacity: 0
Behavior on opacity {
NumberAnimation { duration: 1000 }
}
- Text { id: myText; anchors.centerIn: parent; text: "Hello World!" }
- MouseArea { id: mouseArea; anchors.fill: parent; onClicked: forceClose(); }
+ Text { id: dialogText; anchors.centerIn: parent; text: "Hello World!" }
+ MouseArea { anchors.fill: parent; onClicked: forceClose(); }
}
diff --git a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js
index 2a0d718..a905f7d 100755
--- a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js
+++ b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js
@@ -1,8 +1,8 @@
/* This script file handles the game logic */
//Note that X/Y referred to here are in game coordinates
-var maxX = 10;//Nums are for gameCanvas.tileSize 40
-var maxY = 15;
-var maxIndex = maxX*maxY;
+var maxColumn = 10;//Nums are for gameCanvas.tileSize 40
+var maxRow = 15;
+var maxIndex = maxColumn*maxRow;
var board = new Array(maxIndex);
var tileSrc = "content/BoomBlock.qml";
//var scoresURL = "http://qtfx-nokia.trolltech.com.au/samegame/scores.php";
@@ -11,8 +11,8 @@ var timer;
var component = createComponent(tileSrc);
//Index function used instead of a 2D array
-function index(xIdx,yIdx) {
- return xIdx + (yIdx * maxX);
+function index(column,row) {
+ return column + (row * maxColumn);
}
function timeStr(msecs) {
@@ -22,11 +22,6 @@ function timeStr(msecs) {
return ret;
}
-function getTileSize()
-{
- return tileSize;
-}
-
function initBoard()
{
for(var i = 0; i<maxIndex; i++){
@@ -36,27 +31,25 @@ function initBoard()
}
//Calculate board size
- maxX = Math.floor(gameCanvas.width/gameCanvas.tileSize);
- maxY = Math.floor(gameCanvas.height/gameCanvas.tileSize);
- maxIndex = maxY*maxX;
+ maxColumn = Math.floor(gameCanvas.width/gameCanvas.tileSize);
+ maxRow = Math.floor(gameCanvas.height/gameCanvas.tileSize);
+ maxIndex = maxRow*maxColumn;
//Close dialogs
- scoreName.forceClose();
+ nameInputDialog.forceClose();
dialog.forceClose();
- var a = new Date();
//Initialize Board
board = new Array(maxIndex);
gameCanvas.score = 0;
- for(var xIdx=0; xIdx<maxX; xIdx++){
- for(var yIdx=0; yIdx<maxY; yIdx++){
- board[index(xIdx,yIdx)] = null;
- createBlock(xIdx,yIdx);
+ for(var column=0; column<maxColumn; column++){
+ for(var row=0; row<maxRow; row++){
+ board[index(column,row)] = null;
+ createBlock(column,row);
}
}
- timer = new Date();
- print(timer.valueOf() - a.valueOf());
+ timer = new Date();
}
var fillFound;//Set after a floodFill call to the number of tiles found
@@ -64,14 +57,14 @@ var floodBoard;//Set to 1 if the floodFill reaches off that node
//NOTE: Be careful with vars named x,y, as the calling object's x,y are still in scope
function handleClick(x,y)
{
- var xIdx = Math.floor(x/gameCanvas.tileSize);
- var yIdx = Math.floor(y/gameCanvas.tileSize);
- if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0)
+ var column = Math.floor(x/gameCanvas.tileSize);
+ var row = Math.floor(y/gameCanvas.tileSize);
+ if(column >= maxColumn || column < 0 || row >= maxRow || row < 0)
return;
- if(board[index(xIdx, yIdx)] == null)
+ if(board[index(column, row)] == null)
return;
//If it's a valid tile, remove it and all connected (does nothing if it's not connected)
- floodFill(xIdx,yIdx, -1);
+ floodFill(column,row, -1);
if(fillFound <= 0)
return;
gameCanvas.score += (fillFound - 1) * (fillFound - 1);
@@ -79,67 +72,67 @@ function handleClick(x,y)
victoryCheck();
}
-function floodFill(xIdx,yIdx,type)
+function floodFill(column,row,type)
{
- if(board[index(xIdx, yIdx)] == null)
+ if(board[index(column, row)] == null)
return;
var first = false;
if(type == -1){
first = true;
- type = board[index(xIdx,yIdx)].type;
-
+ type = board[index(column,row)].type;
+
//Flood fill initialization
fillFound = 0;
floodBoard = new Array(maxIndex);
}
- if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0)
+ if(column >= maxColumn || column < 0 || row >= maxRow || row < 0)
return;
- if(floodBoard[index(xIdx, yIdx)] == 1 || (!first && type != board[index(xIdx,yIdx)].type))
+ if(floodBoard[index(column, row)] == 1 || (!first && type != board[index(column,row)].type))
return;
- floodBoard[index(xIdx, yIdx)] = 1;
- floodFill(xIdx+1,yIdx,type);
- floodFill(xIdx-1,yIdx,type);
- floodFill(xIdx,yIdx+1,type);
- floodFill(xIdx,yIdx-1,type);
+ 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 tiles
- board[index(xIdx,yIdx)].dying = true;
- board[index(xIdx,yIdx)] = null;
+ board[index(column,row)].dying = true;
+ board[index(column,row)] = null;
fillFound += 1;
}
function shuffleDown()
{
//Fall down
- for(var xIdx=0; xIdx<maxX; xIdx++){
+ for(var column=0; column<maxColumn; column++){
var fallDist = 0;
- for(var yIdx=maxY-1; yIdx>=0; yIdx--){
- if(board[index(xIdx,yIdx)] == null){
+ for(var row=maxRow-1; row>=0; row--){
+ if(board[index(column,row)] == null){
fallDist += 1;
}else{
if(fallDist > 0){
- var obj = board[index(xIdx,yIdx)];
+ var obj = board[index(column,row)];
obj.targetY += fallDist * gameCanvas.tileSize;
- board[index(xIdx,yIdx+fallDist)] = obj;
- board[index(xIdx,yIdx)] = null;
+ board[index(column,row+fallDist)] = obj;
+ board[index(column,row)] = null;
}
}
}
}
//Fall to the left
fallDist = 0;
- for(xIdx=0; xIdx<maxX; xIdx++){
- if(board[index(xIdx, maxY - 1)] == null){
+ for(column=0; column<maxColumn; column++){
+ if(board[index(column, maxRow - 1)] == null){
fallDist += 1;
}else{
if(fallDist > 0){
- for(yIdx=0; yIdx<maxY; yIdx++){
- obj = board[index(xIdx,yIdx)];
+ for(row=0; row<maxRow; row++){
+ obj = board[index(column,row)];
if(obj == null)
continue;
obj.targetX -= fallDist * gameCanvas.tileSize;
- board[index(xIdx-fallDist,yIdx)] = obj;
- board[index(xIdx,yIdx)] = null;
+ board[index(column-fallDist,row)] = obj;
+ board[index(column,row)] = null;
}
}
}
@@ -150,34 +143,33 @@ function victoryCheck()
{
//awards bonuses for no tiles left
var deservesBonus = true;
- for(var xIdx=maxX-1; xIdx>=0; xIdx--)
- if(board[index(xIdx, maxY - 1)] != null)
+ for(var column=maxColumn-1; column>=0; column--)
+ if(board[index(column, maxRow - 1)] != null)
deservesBonus = false;
if(deservesBonus)
gameCanvas.score += 500;
//Checks for game over
- if(deservesBonus || !(floodMoveCheck(0,maxY-1, -1))){
+ if(deservesBonus || !(floodMoveCheck(0,maxRow-1, -1))){
timer = new Date() - timer;
- scoreName.show("You won! Please enter your name: ");
- //dialog.show("Game Over. Your score is " + gameCanvas.score);
+ nameInputDialog.show("You won! Please enter your name: ");
}
}
//only floods up and right, to see if it can find adjacent same-typed tiles
-function floodMoveCheck(xIdx, yIdx, type)
+function floodMoveCheck(column, row, type)
{
- if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0)
+ if(column >= maxColumn || column < 0 || row >= maxRow || row < 0)
return false;
- if(board[index(xIdx, yIdx)] == null)
+ if(board[index(column, row)] == null)
return false;
- var myType = board[index(xIdx, yIdx)].type;
+ var myType = board[index(column, row)].type;
if(type == myType)
return true;
- return floodMoveCheck(xIdx + 1, yIdx, myType) ||
- floodMoveCheck(xIdx, yIdx - 1, board[index(xIdx,yIdx)].type);
+ return floodMoveCheck(column + 1, row, myType) ||
+ floodMoveCheck(column, row - 1, board[index(column,row)].type);
}
-function createBlock(xIdx,yIdx){
+function createBlock(column,row){
// Note that we don't wait for the component to become ready. This will
// only work if the block QML is a local file. Otherwise the component will
// not be ready immediately. There is a statusChanged signal on the
@@ -191,13 +183,13 @@ function createBlock(xIdx,yIdx){
}
dynamicObject.type = Math.floor(Math.random() * 3);
dynamicObject.parent = gameCanvas;
- dynamicObject.x = xIdx*gameCanvas.tileSize;
- dynamicObject.targetX = xIdx*gameCanvas.tileSize;
- dynamicObject.targetY = yIdx*gameCanvas.tileSize;
+ dynamicObject.x = column*gameCanvas.tileSize;
+ dynamicObject.targetX = column*gameCanvas.tileSize;
+ dynamicObject.targetY = row*gameCanvas.tileSize;
dynamicObject.width = gameCanvas.tileSize;
dynamicObject.height = gameCanvas.tileSize;
dynamicObject.spawned = true;
- board[index(xIdx,yIdx)] = dynamicObject;
+ board[index(column,row)] = dynamicObject;
}else{//isError or isLoading
print("error loading block component");
print(component.errorsString());
@@ -213,7 +205,7 @@ function saveHighScore(name) {
//OfflineStorage
var db = openDatabaseSync("SameGameScores", "1.0", "Local SameGame High Scores",100);
var dataStr = "INSERT INTO Scores VALUES(?, ?, ?, ?)";
- var data = [name, gameCanvas.score, maxX+"x"+maxY ,Math.floor(timer/1000)];
+ var data = [name, gameCanvas.score, maxColumn+"x"+maxRow ,Math.floor(timer/1000)];
db.transaction(
function(tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)');
@@ -236,7 +228,7 @@ function saveHighScore(name) {
function sendHighScore(name) {
var postman = new XMLHttpRequest()
var postData = "name="+name+"&score="+gameCanvas.score
- +"&gridSize="+maxX+"x"+maxY +"&time="+Math.floor(timer/1000);
+ +"&gridSize="+maxColumn+"x"+maxRow +"&time="+Math.floor(timer/1000);
postman.open("POST", scoresURL, true);
postman.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
postman.onreadystatechange = function() {
diff --git a/examples/declarative/tutorials/samegame/samegame4/highscores/scores.php b/examples/declarative/tutorials/samegame/samegame4/highscores/scores.php
index 3cceb2d..daf480e 100755
--- a/examples/declarative/tutorials/samegame/samegame4/highscores/scores.php
+++ b/examples/declarative/tutorials/samegame/samegame4/highscores/scores.php
@@ -8,10 +8,7 @@
$time = $_POST["time"];
if($name == "")
$name = "Anonymous";
- //if($grid != "10x10"){
- //Need a standard, so as to reject others?
- //}
- $file = fopen("score_data.xml", "a"); #It's XML. Happy?
+ $file = fopen("score_data.xml", "a");
$ret = fwrite($file, "<record><score>". $score . "</score><name>"
. $name . "</name><gridSize>" . $grid . "</gridSize><seconds>"
. $time . "</seconds></record>\n");
diff --git a/examples/declarative/tutorials/samegame/samegame4/samegame.qml b/examples/declarative/tutorials/samegame/samegame4/samegame.qml
index 3c66fbf..fe35e3b 100644
--- a/examples/declarative/tutorials/samegame/samegame4/samegame.qml
+++ b/examples/declarative/tutorials/samegame/samegame4/samegame.qml
@@ -23,8 +23,8 @@ Rectangle {
property int tileSize: 40
z: 20; anchors.centerIn: parent
- width: parent.width - (parent.width % getTileSize());
- height: parent.height - (parent.height % getTileSize());
+ width: parent.width - (parent.width % tileSize);
+ height: parent.height - (parent.height % tileSize);
MouseArea {
anchors.fill: parent; onClicked: SameGame.handleClick(mouse.x,mouse.y);
@@ -36,7 +36,7 @@ Rectangle {
//![0]
Dialog {
- id: scoreName; anchors.centerIn: parent; z: 22;
+ id: nameInputDialog; anchors.centerIn: parent; z: 22;
Text {
id: spacer
opacity: 0
@@ -45,9 +45,9 @@ Rectangle {
TextInput {
id: editor
onAccepted: {
- if(scoreName.opacity==1&&editor.text!="")
- saveHighScore(editor.text);
- scoreName.forceClose();
+ if(nameInputDialog.opacity==1&&editor.text!="")
+ SameGame.saveHighScore(editor.text);
+ nameInputDialog.forceClose();
}
anchors.verticalCenter: parent.verticalCenter
width: 72; focus: true
@@ -63,7 +63,7 @@ Rectangle {
anchors.bottom: screen.bottom
Button {
- id: btnA; text: "New Game"; onClicked: {SameGame.initBoard();}
+ text: "New Game"; onClicked: SameGame.initBoard();
anchors.left: parent.left; anchors.leftMargin: 3
anchors.verticalCenter: parent.verticalCenter
}
diff --git a/examples/declarative/tvtennis/tvtennis.qml b/examples/declarative/tvtennis/tvtennis.qml
index 7c98c69..240183f 100644
--- a/examples/declarative/tvtennis/tvtennis.qml
+++ b/examples/declarative/tvtennis/tvtennis.qml
@@ -31,7 +31,7 @@ Rectangle {
}
// Make y follow the target y coordinate, with a velocity of 200
- SpringFollow on y { source: ball.targetY; velocity: 200 }
+ SpringFollow on y { to: ball.targetY; velocity: 200 }
// Detect the ball hitting the top or bottom of the view and bounce it
onYChanged: {
@@ -52,7 +52,7 @@ Rectangle {
color: "Lime"
x: 2; width: 20; height: 90
SpringFollow on y {
- source: ball.y - 45; velocity: 300
+ to: ball.y - 45; velocity: 300
enabled: ball.direction == 'left'
}
}
@@ -61,7 +61,7 @@ Rectangle {
color: "Lime"
x: page.width - 22; width: 20; height: 90
SpringFollow on y {
- source: ball.y-45; velocity: 300
+ to: ball.y-45; velocity: 300
enabled: ball.direction == 'right'
}
}
diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml
index efaaf7a..724fcc8 100644
--- a/examples/declarative/velocity/Day.qml
+++ b/examples/declarative/velocity/Day.qml
@@ -17,7 +17,6 @@ Component {
Repeater {
model: notes
-
Item {
property int randomX: Math.random() * 500 + 100
property int randomY: Math.random() * 200 + 50
@@ -26,7 +25,7 @@ Component {
x: randomX; y: randomY
SpringFollow on rotation {
- source: -flickable.horizontalVelocity / 100
+ to: -flickable.horizontalVelocity / 100
spring: 2.0; damping: 0.15
}
@@ -54,8 +53,12 @@ Component {
id: mouse
onClicked: { myText.focus = true }
anchors.fill: parent
- drag.target: stickyPage; drag.axis: MouseArea.XandYAxis; drag.minimumY: 0; drag.maximumY: page.height - 80
- drag.minimumX: 100; drag.maximumX: page.width - 140
+ drag.target: stickyPage
+ drag.axis: "XandYAxis"
+ drag.minimumY: 0
+ drag.maximumY: page.height - 80
+ drag.minimumX: 100
+ drag.maximumX: page.width - 140
}
}
}
diff --git a/examples/declarative/velocity/note-yellow.png b/examples/declarative/velocity/note-yellow.png
new file mode 100644
index 0000000..8ddecc8
--- /dev/null
+++ b/examples/declarative/velocity/note-yellow.png
Binary files differ
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index 9490225..3515777 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -329,6 +329,10 @@ QLibraryInfo::location(LibraryLocation loc)
key = QLatin1String("Plugins");
defaultValue = QLatin1String("plugins");
break;
+ case ImportsPath:
+ key = QLatin1String("Imports");
+ defaultValue = QLatin1String("imports");
+ break;
case DataPath:
key = QLatin1String("Data");
break;
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt
index d3737b0..079aacb 100644
--- a/src/declarative/QmlChanges.txt
+++ b/src/declarative/QmlChanges.txt
@@ -33,12 +33,20 @@ syntax has been introduced:
Item { Behavior on x {}; NumberAnimation on y {} }
Only the syntax has changed, the behavior is identical.
+EaseFollow renamed to SmoothedFollow
+---------------------------------------
+This element shares the internal implementation with SmoothedAnimation,
+both providing the same easing function, but with SmoothedFollow it's
+easier to set a start value to animate intially and then start to follow,
+while SmoothedAnimation is still convenient for using inside Behaviors
+and Transitions.
+
-EaseFollow changed to SmoothedAnimation
+Add SmoothedAnimation element
---------------------------------------
-EaseFollow was renamed to SmoothedAnimation and now it inherits from
-NumberAnimaton and as a consequence SmoothedAnimation can be used inside
-Behaviors, as PropertySourceValues or in state transitions, like any other animation.
+SmoothedAnimation inherits from NumberAnimaton and as a
+consequence SmoothedAnimation can be used inside Behaviors,
+as PropertySourceValues or in state transitions, like any other animation.
The old EaseFollow properties changed to comply with the other declarative
animations ('source' changed to 'to'), so now 'to' changes are not
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index e44a26d..f832f12 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -106,6 +106,7 @@ public:
, highlightRangeStart(0), highlightRangeEnd(0), highlightRange(QDeclarativeGridView::NoHighlightRange)
, highlightComponent(0), highlight(0), trackedItem(0)
, moveReason(Other), buffer(0), highlightXAnimator(0), highlightYAnimator(0)
+ , highlightMoveDuration(150)
, bufferMode(NoBuffer), snapMode(QDeclarativeGridView::NoSnap)
, ownModel(false), wrap(false), autoHighlight(true)
, fixCurrentVisibility(false), lazyRelease(false), layoutScheduled(false)
@@ -327,6 +328,7 @@ public:
int buffer;
QSmoothedAnimation *highlightXAnimator;
QSmoothedAnimation *highlightYAnimator;
+ int highlightMoveDuration;
enum BufferMode { NoBuffer = 0x00, BufferBefore = 0x01, BufferAfter = 0x02 };
BufferMode bufferMode;
QDeclarativeGridView::SnapMode snapMode;
@@ -669,10 +671,10 @@ void QDeclarativeGridViewPrivate::createHighlight()
highlight = new FxGridItem(item, q);
highlightXAnimator = new QSmoothedAnimation(q);
highlightXAnimator->target = QDeclarativeProperty(highlight->item, QLatin1String("x"));
- highlightXAnimator->userDuration = 150;
+ highlightXAnimator->userDuration = highlightMoveDuration;
highlightYAnimator = new QSmoothedAnimation(q);
highlightYAnimator->target = QDeclarativeProperty(highlight->item, QLatin1String("y"));
- highlightYAnimator->userDuration = 150;
+ highlightYAnimator->userDuration = highlightMoveDuration;
highlightXAnimator->restart();
highlightYAnimator->restart();
changed = true;
@@ -1204,6 +1206,37 @@ void QDeclarativeGridView::setHighlightFollowsCurrentItem(bool autoHighlight)
}
/*!
+ \qmlproperty int 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 QDeclarativeGridView::highlightMoveDuration() const
+{
+ Q_D(const QDeclarativeGridView);
+ return d->highlightMoveDuration;
+}
+
+void QDeclarativeGridView::setHighlightMoveDuration(int duration)
+{
+ Q_D(QDeclarativeGridView);
+ if (d->highlightMoveDuration != duration) {
+ d->highlightMoveDuration = duration;
+ if (d->highlightYAnimator) {
+ d->highlightXAnimator->userDuration = d->highlightMoveDuration;
+ d->highlightYAnimator->userDuration = d->highlightMoveDuration;
+ }
+ emit highlightMoveDurationChanged();
+ }
+}
+
+
+/*!
\qmlproperty real GridView::preferredHighlightBegin
\qmlproperty real GridView::preferredHighlightEnd
\qmlproperty enumeration GridView::highlightRangeMode
@@ -1787,8 +1820,8 @@ void QDeclarativeGridView::componentComplete()
{
Q_D(QDeclarativeGridView);
QDeclarativeFlickable::componentComplete();
+ d->updateGrid();
if (d->isValid()) {
- d->updateGrid();
refill();
if (d->currentIndex < 0)
d->updateCurrent(0);
diff --git a/src/declarative/graphicsitems/qdeclarativegridview_p.h b/src/declarative/graphicsitems/qdeclarativegridview_p.h
index f73f632..5baa1dd 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativegridview_p.h
@@ -66,6 +66,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeGridView : public QDeclarativeFlickable
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)
Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd NOTIFY preferredHighlightEndChanged)
@@ -106,6 +107,9 @@ public:
bool highlightFollowsCurrentItem() const;
void setHighlightFollowsCurrentItem(bool);
+ int highlightMoveDuration() const;
+ void setHighlightMoveDuration(int);
+
enum HighlightRangeMode { NoHighlightRange, ApplyRange, StrictlyEnforceRange };
HighlightRangeMode highlightRangeMode() const;
void setHighlightRangeMode(HighlightRangeMode mode);
@@ -161,6 +165,7 @@ Q_SIGNALS:
void preferredHighlightBeginChanged();
void preferredHighlightEndChanged();
void highlightRangeModeChanged();
+ void highlightMoveDurationChanged();
void modelChanged();
void delegateChanged();
void flowChanged();
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index 31d97f3..b4506ef 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -156,7 +156,8 @@ public:
, highlightComponent(0), highlight(0), trackedItem(0)
, moveReason(Other), buffer(0), highlightPosAnimator(0), highlightSizeAnimator(0)
, sectionCriteria(0), spacing(0.0)
- , highlightMoveSpeed(400), highlightResizeSpeed(400), highlightRange(QDeclarativeListView::NoHighlightRange)
+ , highlightMoveSpeed(400), highlightMoveDuration(-1)
+ , highlightResizeSpeed(400), highlightResizeDuration(-1), highlightRange(QDeclarativeListView::NoHighlightRange)
, snapMode(QDeclarativeListView::NoSnap), overshootDist(0.0)
, footerComponent(0), footer(0), headerComponent(0), header(0)
, bufferMode(NoBuffer)
@@ -464,7 +465,9 @@ public:
QDeclarativeItem *sectionCache[sectionCacheSize];
qreal spacing;
qreal highlightMoveSpeed;
+ int highlightMoveDuration;
qreal highlightResizeSpeed;
+ int highlightResizeDuration;
QDeclarativeListView::HighlightRangeMode highlightRange;
QDeclarativeListView::SnapMode snapMode;
qreal overshootDist;
@@ -835,10 +838,12 @@ void QDeclarativeListViewPrivate::createHighlight()
highlightPosAnimator = new QSmoothedAnimation(q);
highlightPosAnimator->target = QDeclarativeProperty(highlight->item, posProp);
highlightPosAnimator->velocity = highlightMoveSpeed;
+ highlightPosAnimator->userDuration = highlightMoveDuration;
highlightPosAnimator->restart();
const QLatin1String sizeProp(orient == QDeclarativeListView::Vertical ? "height" : "width");
highlightSizeAnimator = new QSmoothedAnimation(q);
highlightSizeAnimator->velocity = highlightResizeSpeed;
+ highlightSizeAnimator->userDuration = highlightResizeDuration;
highlightSizeAnimator->target = QDeclarativeProperty(highlight->item, sizeProp);
highlightSizeAnimator->restart();
changed = true;
@@ -1867,13 +1872,19 @@ QString QDeclarativeListView::currentSection() const
/*!
\qmlproperty real ListView::highlightMoveSpeed
+ \qmlproperty int ListView::highlightMoveDuration
\qmlproperty real ListView::highlightResizeSpeed
+ \qmlproperty int ListView::highlightResizeDuration
These properties hold the move and resize animation speed of the highlight delegate.
highlightFollowsCurrentItem must be true for these properties
to have effect.
- The default value for these properties is 400 pixels/second.
+ 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
*/
@@ -1894,6 +1905,23 @@ void QDeclarativeListView::setHighlightMoveSpeed(qreal speed)
}
}
+int QDeclarativeListView::highlightMoveDuration() const
+{
+ Q_D(const QDeclarativeListView);
+ return d->highlightMoveDuration;
+}
+
+void QDeclarativeListView::setHighlightMoveDuration(int duration)
+{
+ Q_D(QDeclarativeListView);\
+ if (d->highlightMoveDuration != duration) {
+ d->highlightMoveDuration = duration;
+ if (d->highlightPosAnimator)
+ d->highlightPosAnimator->userDuration = d->highlightMoveDuration;
+ emit highlightMoveDurationChanged();
+ }
+}
+
qreal QDeclarativeListView::highlightResizeSpeed() const
{
Q_D(const QDeclarativeListView);\
@@ -1911,6 +1939,23 @@ void QDeclarativeListView::setHighlightResizeSpeed(qreal speed)
}
}
+int QDeclarativeListView::highlightResizeDuration() const
+{
+ Q_D(const QDeclarativeListView);
+ return d->highlightResizeDuration;
+}
+
+void QDeclarativeListView::setHighlightResizeDuration(int duration)
+{
+ Q_D(QDeclarativeListView);\
+ if (d->highlightResizeDuration != duration) {
+ d->highlightResizeDuration = duration;
+ if (d->highlightSizeAnimator)
+ d->highlightSizeAnimator->userDuration = d->highlightResizeDuration;
+ emit highlightResizeDurationChanged();
+ }
+}
+
/*!
\qmlproperty enumeration ListView::snapMode
diff --git a/src/declarative/graphicsitems/qdeclarativelistview_p.h b/src/declarative/graphicsitems/qdeclarativelistview_p.h
index 5810979..9c0b7dd 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativelistview_p.h
@@ -101,7 +101,9 @@ class Q_DECLARATIVE_EXPORT QDeclarativeListView : public QDeclarativeFlickable
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)
Q_PROPERTY(qreal preferredHighlightEnd READ preferredHighlightEnd WRITE setPreferredHighlightEnd NOTIFY preferredHighlightEndChanged)
@@ -176,9 +178,15 @@ public:
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);
@@ -208,7 +216,9 @@ Q_SIGNALS:
void currentIndexChanged();
void currentSectionChanged();
void highlightMoveSpeedChanged();
+ void highlightMoveDurationChanged();
void highlightResizeSpeedChanged();
+ void highlightResizeDurationChanged();
void highlightChanged();
void highlightItemChanged();
void modelChanged();
diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp
index 813b525..5fcac49 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp
@@ -221,7 +221,7 @@ void QDeclarativePathViewPrivate::updateHighlight()
tl.reset(moveHighlight);
moveHighlight.setValue(highlightPosition);
- const int duration = 300;
+ const int duration = highlightMoveDuration;
if (target - highlightPosition > model->count()/2) {
highlightUp = false;
@@ -691,6 +691,31 @@ void QDeclarativePathView::setHighlightRangeMode(HighlightRangeMode mode)
emit highlightRangeModeChanged();
}
+
+/*!
+ \qmlproperty int 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 QDeclarativePathView::highlightMoveDuration() const
+{
+ Q_D(const QDeclarativePathView);
+ return d->highlightMoveDuration;
+}
+
+void QDeclarativePathView::setHighlightMoveDuration(int duration)
+{
+ Q_D(QDeclarativePathView);
+ if (d->highlightMoveDuration == duration)
+ return;
+ d->highlightMoveDuration = duration;
+ emit highlightMoveDurationChanged();
+}
+
/*!
\qmlproperty real PathView::dragMargin
This property holds the maximum distance from the path that initiate mouse dragging.
@@ -1316,7 +1341,7 @@ void QDeclarativePathViewPrivate::snapToCurrent()
tl.reset(moveOffset);
moveOffset.setValue(offset);
- const int duration = 300;
+ const int duration = highlightMoveDuration;
if (targetOffset - offset > model->count()/2) {
qreal distance = model->count() - targetOffset + offset;
diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p.h
index 69770cd..7240578 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepathview_p.h
@@ -68,6 +68,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativePathView : public QDeclarativeItem
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)
@@ -109,6 +110,9 @@ public:
qreal preferredHighlightEnd() const;
void setPreferredHighlightEnd(qreal);
+ int highlightMoveDuration() const;
+ void setHighlightMoveDuration(int);
+
qreal dragMargin() const;
void setDragMargin(qreal margin);
@@ -145,6 +149,7 @@ Q_SIGNALS:
void interactiveChanged();
void highlightChanged();
void highlightItemChanged();
+ void highlightMoveDurationChanged();
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event);
diff --git a/src/declarative/graphicsitems/qdeclarativepathview_p_p.h b/src/declarative/graphicsitems/qdeclarativepathview_p_p.h
index 11712fd..303486f 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativepathview_p_p.h
@@ -85,7 +85,7 @@ public:
, highlightPosition(0)
, highlightRangeStart(0), highlightRangeEnd(0)
, highlightRangeMode(QDeclarativePathView::StrictlyEnforceRange)
- , highlightMoveSpeed(1.0)
+ , highlightMoveDuration(300)
{
}
@@ -160,7 +160,7 @@ public:
qreal highlightRangeStart;
qreal highlightRangeEnd;
QDeclarativePathView::HighlightRangeMode highlightRangeMode;
- qreal highlightMoveSpeed;
+ int highlightMoveDuration;
};
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp
index 9a7a242..6a99855 100644
--- a/src/declarative/qml/qdeclarativebinding.cpp
+++ b/src/declarative/qml/qdeclarativebinding.cpp
@@ -126,7 +126,7 @@ void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags)
QDeclarativeBindingData *data = d->bindingData();
- if (!data->enabled)
+ if (!data->enabled || !data->context() || !data->context()->engine)
return;
data->addref();
@@ -148,8 +148,7 @@ void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags)
idx, a);
} else {
- QDeclarativeEnginePrivate *ep = (data->context() && data->context()->engine)?
- QDeclarativeEnginePrivate::get(data->context()->engine):0;
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(data->context()->engine);
bool isUndefined = false;
QVariant value;
@@ -164,7 +163,8 @@ void QDeclarativeBinding::update(QDeclarativePropertyPrivate::WriteFlags flags)
// 100% reliable, in many cases it gives us better error messages if we
// assign this null-object to an incompatible property
int type = ep->objectClass->objectType(scriptValue);
- value = QVariant(type, (void *)0);
+ QObject *o = 0;
+ value = QVariant(type, (void *)&o);
}
}
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index e34cd66..d2b2024 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -342,9 +342,22 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
switch(type) {
case -1:
{
- instr.type = QDeclarativeInstruction::StoreVariant;
- instr.storeString.propertyIndex = prop.propertyIndex();
- instr.storeString.value = output->indexForString(string);
+ if (v->value.isNumber()) {
+ double n = v->value.asNumber();
+ if (double(int(n)) == n) {
+ instr.type = QDeclarativeInstruction::StoreVariantInteger;
+ instr.storeInteger.propertyIndex = prop.propertyIndex();
+ instr.storeInteger.value = int(n);
+ } else {
+ instr.type = QDeclarativeInstruction::StoreVariantDouble;
+ instr.storeDouble.propertyIndex = prop.propertyIndex();
+ instr.storeDouble.value = n;
+ }
+ } else {
+ instr.type = QDeclarativeInstruction::StoreVariant;
+ instr.storeString.propertyIndex = prop.propertyIndex();
+ instr.storeString.value = output->indexForString(string);
+ }
}
break;
case QVariant::String:
diff --git a/src/declarative/qml/qdeclarativecompositetypemanager.cpp b/src/declarative/qml/qdeclarativecompositetypemanager.cpp
index 61978a4..ccf10c6 100644
--- a/src/declarative/qml/qdeclarativecompositetypemanager.cpp
+++ b/src/declarative/qml/qdeclarativecompositetypemanager.cpp
@@ -634,7 +634,7 @@ int QDeclarativeCompositeTypeManager::resolveTypes(QDeclarativeCompositeTypeData
QDeclarativeError error;
error.setUrl(unit->imports.baseUrl());
QString userTypeName = QString::fromUtf8(typeName);
- userTypeName.replace('/','.');
+ userTypeName.replace(QLatin1Char('/'),QLatin1Char('.'));
if (typeNamespace)
error.setDescription(tr("Namespace %1 cannot be used as a type").arg(userTypeName));
else
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 1bcadf2..68ce953 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -188,6 +188,8 @@ QDeclarativeEnginePrivate::QDeclarativeEnginePrivate(QDeclarativeEngine *e)
fileImportPath += builtinPath;
#endif
+ filePluginPath += QLatin1String(".");
+
}
QUrl QDeclarativeScriptEngine::resolvedUrl(QScriptContext *context, const QUrl& url)
@@ -1497,19 +1499,13 @@ public:
foreach (const QDeclarativeDirParser::Plugin &plugin, qmldirParser.plugins()) {
- QDir pluginDir = dir.absoluteFilePath(plugin.path);
-
- // hack for resources, should probably go away
- if (absoluteFilePath.startsWith(QLatin1Char(':')))
- pluginDir = QDir(QCoreApplication::applicationDirPath());
-
QString resolvedFilePath =
QDeclarativeEnginePrivate::get(engine)
- ->resolvePlugin(pluginDir,
+ ->resolvePlugin(dir, plugin.path,
plugin.name);
if (!resolvedFilePath.isEmpty()) {
- engine->importExtension(resolvedFilePath, uri);
+ engine->importPlugin(resolvedFilePath, uri);
}
}
}
@@ -1804,8 +1800,8 @@ QUrl QDeclarativeEnginePrivate::Imports::baseUrl() const
}
/*!
- Adds \a path as a directory where installed QML components are
- defined in a URL-based directory structure.
+ Adds \a path as a directory where the engine searches for
+ installed modules in a URL-based directory structure.
The newly added \a path will be first in the importPathList().
@@ -1828,7 +1824,7 @@ void QDeclarativeEngine::addImportPath(const QString& path)
/*!
Returns the list of directories where the engine searches for
- installed modules.
+ installed modules in a URL-based directory structure.
For example, if \c /opt/MyApp/lib/imports is in the path, then QML that
imports \c com.mycompany.Feature will cause the QDeclarativeEngine to look
@@ -1849,7 +1845,7 @@ QStringList QDeclarativeEngine::importPathList() const
/*!
Sets the list of directories where the engine searches for
- installed modules.
+ installed modules in a URL-based directory structure.
By default, the list contains the paths specified in the \c QML_IMPORT_PATH environment
variable, then the builtin \c ImportsPath from QLibraryInfo.
@@ -1862,15 +1858,73 @@ void QDeclarativeEngine::setImportPathList(const QStringList &paths)
d->fileImportPath = paths;
}
+
+/*!
+ Adds \a path as a directory where the engine searches for
+ native plugins for imported modules (referenced in the \c qmldir file).
+
+ By default, the list contains only \c ., i.e. the engine searches
+ in the directory of the \c qmldir file itself.
+
+ The newly added \a path will be first in the pluginPathList().
+
+ \sa setPluginPathList()
+*/
+void QDeclarativeEngine::addPluginPath(const QString& path)
+{
+ if (qmlImportTrace())
+ qDebug() << "QDeclarativeEngine::addPluginPath" << path;
+ Q_D(QDeclarativeEngine);
+ QUrl url = QUrl(path);
+ if (url.isRelative() || url.scheme() == QString::fromLocal8Bit("file")) {
+ QDir dir = QDir(path);
+ d->filePluginPath.prepend(dir.canonicalPath());
+ } else {
+ d->filePluginPath.prepend(path);
+ }
+}
+
+
+/*!
+ Returns the list of directories where the engine searches for
+ native plugins for imported modules (referenced in the \c qmldir file).
+
+ By default, the list contains only \c ., i.e. the engine searches
+ in the directory of the \c qmldir file itself.
+
+ \sa addPluginPath() setPluginPathList()
+*/
+QStringList QDeclarativeEngine::pluginPathList() const
+{
+ Q_D(const QDeclarativeEngine);
+ return d->filePluginPath;
+}
+
+/*!
+ Sets the list of directories where the engine searches for
+ native plugins for imported modules (referenced in the \c qmldir file).
+
+ By default, the list contains only \c ., i.e. the engine searches
+ in the directory of the \c qmldir file itself.
+
+ \sa pluginPathList() addPluginPath()
+ */
+void QDeclarativeEngine::setPluginPathList(const QStringList &paths)
+{
+ Q_D(QDeclarativeEngine);
+ d->filePluginPath = paths;
+}
+
+
/*!
- Imports the extension named \a fileName from the \a uri provided.
- Returns true if the extension was successfully imported.
+ Imports the plugin named \a filePath with the \a uri provided.
+ Returns true if the plugin was successfully imported; otherwise returns false.
*/
-bool QDeclarativeEngine::importExtension(const QString &fileName, const QString &uri)
+bool QDeclarativeEngine::importPlugin(const QString &filePath, const QString &uri)
{
if (qmlImportTrace())
- qDebug() << "QDeclarativeEngine::importExtension" << uri << "from" << fileName;
- QFileInfo fileInfo(fileName);
+ qDebug() << "QDeclarativeEngine::importPlugin" << uri << "from" << filePath;
+ QFileInfo fileInfo(filePath);
const QString absoluteFilePath = fileInfo.absoluteFilePath();
QDeclarativeEnginePrivate *d = QDeclarativeEnginePrivate::get(this);
@@ -1943,27 +1997,53 @@ QString QDeclarativeEngine::offlineStoragePath() const
/*!
\internal
- Returns the result of the merge of \a baseName with \a dir, \a suffixes, and \a prefix.
+ Returns the result of the merge of \a baseName with \a path, \a suffixes, and \a prefix.
The \a prefix must contain the dot.
+
+ \a qmldirPath is the location of the qmldir file.
*/
-QString QDeclarativeEnginePrivate::resolvePlugin(const QDir &dir, const QString &baseName,
+QString QDeclarativeEnginePrivate::resolvePlugin(const QDir &qmldirPath, const QString &qmldirPluginPath, const QString &baseName,
const QStringList &suffixes,
const QString &prefix)
{
- foreach (const QString &suffix, suffixes) {
- QString pluginFileName = prefix;
+ QStringList searchPaths = filePluginPath;
+ bool qmldirPluginPathIsRelative = QDir::isRelativePath(qmldirPluginPath);
+ if (!qmldirPluginPathIsRelative)
+ searchPaths.prepend(qmldirPluginPath);
+
+ foreach (const QString &pluginPath, searchPaths) {
+
+ QString resolvedPath;
- pluginFileName += baseName;
- pluginFileName += suffix;
+ if (pluginPath == QLatin1String(".")) {
+ if (qmldirPluginPathIsRelative)
+ resolvedPath = qmldirPath.absoluteFilePath(qmldirPluginPath);
+ else
+ resolvedPath = qmldirPath.absolutePath();
+ } else {
+ resolvedPath = pluginPath;
+ }
+
+ // hack for resources, should probably go away
+ if (resolvedPath.startsWith(QLatin1Char(':')))
+ resolvedPath = QCoreApplication::applicationDirPath();
- QFileInfo fileInfo(dir, pluginFileName);
+ QDir dir(resolvedPath);
+ foreach (const QString &suffix, suffixes) {
+ QString pluginFileName = prefix;
- if (fileInfo.exists())
- return fileInfo.absoluteFilePath();
+ pluginFileName += baseName;
+ pluginFileName += suffix;
+
+ QFileInfo fileInfo(dir, pluginFileName);
+
+ if (fileInfo.exists())
+ return fileInfo.absoluteFilePath();
+ }
}
if (qmlImportTrace())
- qDebug() << "QDeclarativeEngine::resolvePlugin: Could not resolve plugin" << baseName << "in" << dir.absolutePath();
+ qDebug() << "QDeclarativeEngine::resolvePlugin: Could not resolve plugin" << baseName << "in" << qmldirPath.absolutePath();
return QString();
}
@@ -1984,17 +2064,17 @@ QString QDeclarativeEnginePrivate::resolvePlugin(const QDir &dir, const QString
Version number on unix are ignored.
*/
-QString QDeclarativeEnginePrivate::resolvePlugin(const QDir &dir, const QString &baseName)
+QString QDeclarativeEnginePrivate::resolvePlugin(const QDir &qmldirPath, const QString &qmldirPluginPath, const QString &baseName)
{
#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
- return resolvePlugin(dir, baseName,
+ return resolvePlugin(qmldirPath, qmldirPluginPath, baseName,
QStringList()
# ifdef QT_DEBUG
<< QLatin1String("d.dll") // try a qmake-style debug build first
# endif
<< QLatin1String(".dll"));
#elif defined(Q_OS_SYMBIAN)
- return resolvePlugin(dir, baseName,
+ return resolvePlugin(qmldirPath, qmldirPluginPath, baseName,
QStringList()
<< QLatin1String(".dll")
<< QLatin1String(".qtplugin"));
@@ -2002,7 +2082,7 @@ QString QDeclarativeEnginePrivate::resolvePlugin(const QDir &dir, const QString
# if defined(Q_OS_DARWIN)
- return resolvePlugin(dir, baseName,
+ return resolvePlugin(qmldirPath, qmldirPluginPath, baseName,
QStringList()
# ifdef QT_DEBUG
<< QLatin1String("_debug.dylib") // try a qmake-style debug build first
@@ -2036,7 +2116,7 @@ QString QDeclarativeEnginePrivate::resolvePlugin(const QDir &dir, const QString
// Examples of valid library names:
// libfoo.so
- return resolvePlugin(dir, baseName, validSuffixList, QLatin1String("lib"));
+ return resolvePlugin(qmldirPath, qmldirPluginPath, baseName, validSuffixList, QLatin1String("lib"));
# endif
#endif
diff --git a/src/declarative/qml/qdeclarativeengine.h b/src/declarative/qml/qdeclarativeengine.h
index b861c1b..fcaddcf 100644
--- a/src/declarative/qml/qdeclarativeengine.h
+++ b/src/declarative/qml/qdeclarativeengine.h
@@ -81,7 +81,11 @@ public:
void setImportPathList(const QStringList &paths);
void addImportPath(const QString& dir);
- bool importExtension(const QString &fileName, const QString &uri);
+ QStringList pluginPathList() const;
+ void setPluginPathList(const QStringList &paths);
+ void addPluginPath(const QString& dir);
+
+ bool importPlugin(const QString &filePath, const QString &uri);
void setNetworkAccessManagerFactory(QDeclarativeNetworkAccessManagerFactory *);
QDeclarativeNetworkAccessManagerFactory *networkAccessManagerFactory() const;
diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h
index 3f22d61..6bcd0d1 100644
--- a/src/declarative/qml/qdeclarativeengine_p.h
+++ b/src/declarative/qml/qdeclarativeengine_p.h
@@ -231,6 +231,7 @@ public:
QDeclarativeCompositeTypeManager typeManager;
QStringList fileImportPath;
+ QStringList filePluginPath;
QString offlineStoragePath;
mutable quint32 uniqueId;
@@ -274,10 +275,10 @@ public:
QSet<QString> initializedPlugins;
- QString resolvePlugin(const QDir &dir, const QString &baseName,
+ QString resolvePlugin(const QDir &qmldirPath, const QString &qmldirPluginPath, const QString &baseName,
const QStringList &suffixes,
const QString &prefix = QString());
- QString resolvePlugin(const QDir &dir, const QString &baseName);
+ QString resolvePlugin(const QDir &qmldirPath, const QString &qmldirPluginPath, const QString &baseName);
bool addToImport(Imports*, const QDeclarativeDirComponents &qmldircomponentsnetwork,
diff --git a/src/declarative/qml/qdeclarativeinstruction.cpp b/src/declarative/qml/qdeclarativeinstruction.cpp
index 1f8b8af..d88d06a 100644
--- a/src/declarative/qml/qdeclarativeinstruction.cpp
+++ b/src/declarative/qml/qdeclarativeinstruction.cpp
@@ -130,6 +130,12 @@ void QDeclarativeCompiledData::dump(QDeclarativeInstruction *instr, int idx)
case QDeclarativeInstruction::StoreVariant:
qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_VARIANT\t\t" << instr->storeString.propertyIndex << "\t" << instr->storeString.value << "\t\t" << primitives.at(instr->storeString.value);
break;
+ case QDeclarativeInstruction::StoreVariantInteger:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_VARIANT_INTEGER\t\t" << instr->storeInteger.propertyIndex << "\t" << instr->storeInteger.value;
+ break;
+ case QDeclarativeInstruction::StoreVariantDouble:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_VARIANT_DOUBLE\t\t" << instr->storeDouble.propertyIndex << "\t" << instr->storeDouble.value;
+ break;
case QDeclarativeInstruction::StoreObject:
qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_OBJECT\t\t" << instr->storeObject.propertyIndex;
break;
diff --git a/src/declarative/qml/qdeclarativeinstruction_p.h b/src/declarative/qml/qdeclarativeinstruction_p.h
index 1f3c964..e8287c0 100644
--- a/src/declarative/qml/qdeclarativeinstruction_p.h
+++ b/src/declarative/qml/qdeclarativeinstruction_p.h
@@ -114,6 +114,8 @@ public:
StoreRectF, /* storeRect */
StoreVector3D, /* storeVector3D */
StoreVariant, /* storeString */
+ StoreVariantInteger, /* storeInteger */
+ StoreVariantDouble, /* storeDouble */
StoreObject, /* storeObject */
StoreVariantObject, /* storeObject */
StoreInterface, /* storeObject */
diff --git a/src/declarative/qml/qdeclarativestringconverters.cpp b/src/declarative/qml/qdeclarativestringconverters.cpp
index 5c88b9a..bbcc00b 100644
--- a/src/declarative/qml/qdeclarativestringconverters.cpp
+++ b/src/declarative/qml/qdeclarativestringconverters.cpp
@@ -82,10 +82,6 @@ QVariant QDeclarativeStringConverters::variantFromString(const QString &s)
{
if (s.isEmpty())
return QVariant(s);
- if (s.startsWith(QLatin1Char('\'')) && s.endsWith(QLatin1Char('\''))) {
- QString data = s.mid(1, s.length() - 2);
- return QVariant(data);
- }
bool ok = false;
QRectF r = rectFFromString(s, &ok);
if (ok) return QVariant(r);
@@ -104,6 +100,10 @@ QVariant QDeclarativeStringConverters::variantFromString(const QString &s)
QVariant QDeclarativeStringConverters::variantFromString(const QString &s, int preferredType, bool *ok)
{
switch (preferredType) {
+ case QMetaType::Int:
+ return QVariant(int(qRound(s.toDouble(ok))));
+ case QMetaType::UInt:
+ return QVariant(uint(qRound(s.toDouble(ok))));
case QMetaType::QColor:
return QVariant::fromValue(colorFromString(s, ok));
case QMetaType::QDate:
diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp
index 2d1a549..0addfabd 100644
--- a/src/declarative/qml/qdeclarativevme.cpp
+++ b/src/declarative/qml/qdeclarativevme.cpp
@@ -345,6 +345,26 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
}
break;
+ case QDeclarativeInstruction::StoreVariantInteger:
+ {
+ QObject *target = stack.top();
+ QVariant v(instr.storeInteger.value);
+ void *a[] = { &v, 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeString.propertyIndex, a);
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreVariantDouble:
+ {
+ QObject *target = stack.top();
+ QVariant v(instr.storeDouble.value);
+ void *a[] = { &v, 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeString.propertyIndex, a);
+ }
+ break;
+
case QDeclarativeInstruction::StoreString:
{
QObject *target = stack.top();
diff --git a/src/declarative/util/qdeclarativespringfollow.cpp b/src/declarative/util/qdeclarativespringfollow.cpp
index c42261d..7921735 100644
--- a/src/declarative/util/qdeclarativespringfollow.cpp
+++ b/src/declarative/util/qdeclarativespringfollow.cpp
@@ -59,13 +59,13 @@ class QDeclarativeSpringFollowPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QDeclarativeSpringFollow)
public:
QDeclarativeSpringFollowPrivate()
- : currentValue(0), sourceValue(0), maxVelocity(0), lastTime(0)
+ : currentValue(0), to(0), maxVelocity(0), lastTime(0)
, mass(1.0), spring(0.), damping(0.), velocity(0), epsilon(0.01)
, modulus(0.0), useMass(false), haveModulus(false), enabled(true), mode(Track), clock(this) {}
QDeclarativeProperty property;
qreal currentValue;
- qreal sourceValue;
+ qreal to;
qreal maxVelocity;
qreal velocityms;
int lastTime;
@@ -102,7 +102,7 @@ void QDeclarativeSpringFollowPrivate::tick(int time)
int elapsed = time - lastTime;
if (!elapsed)
return;
- qreal srcVal = sourceValue;
+ qreal srcVal = to;
if (haveModulus) {
currentValue = fmod(currentValue, modulus);
srcVal = fmod(srcVal, modulus);
@@ -158,16 +158,16 @@ void QDeclarativeSpringFollowPrivate::tick(int time)
currentValue += moveBy;
if (haveModulus)
currentValue = fmod(currentValue, modulus);
- if (currentValue > sourceValue) {
- currentValue = sourceValue;
+ if (currentValue > to) {
+ currentValue = to;
clock.stop();
}
} else {
currentValue -= moveBy;
if (haveModulus && currentValue < 0.0)
currentValue = fmod(currentValue, modulus) + modulus;
- if (currentValue < sourceValue) {
- currentValue = sourceValue;
+ if (currentValue < to) {
+ currentValue = to;
clock.stop();
}
}
@@ -196,9 +196,9 @@ void QDeclarativeSpringFollowPrivate::start()
Q_Q(QDeclarativeSpringFollow);
if (mode == QDeclarativeSpringFollowPrivate::Track) {
- currentValue = sourceValue;
+ currentValue = to;
property.write(currentValue);
- } else if (sourceValue != currentValue && clock.state() != QAbstractAnimation::Running) {
+ } else if (to != currentValue && clock.state() != QAbstractAnimation::Running) {
lastTime = 0;
currentValue = property.read().toReal();
clock.start(); // infinity??
@@ -239,7 +239,7 @@ void QDeclarativeSpringFollowPrivate::stop()
x: rect1.width
width: 20; height: 20
color: "#ff0000"
- SpringFollow on y { source: rect1.y; velocity: 200 }
+ SpringFollow on y { to: rect1.y; velocity: 200 }
}
\endcode
*/
@@ -260,26 +260,26 @@ void QDeclarativeSpringFollow::setTarget(const QDeclarativeProperty &property)
d->currentValue = property.read().toReal();
}
-qreal QDeclarativeSpringFollow::sourceValue() const
+qreal QDeclarativeSpringFollow::to() const
{
Q_D(const QDeclarativeSpringFollow);
- return d->sourceValue;
+ return d->to;
}
/*!
- \qmlproperty qreal SpringFollow::source
- This property holds the source value which will be tracked.
+ \qmlproperty qreal SpringFollow::to
+ This property holds the target value which will be tracked.
Bind to a property in order to track its changes.
*/
-void QDeclarativeSpringFollow::setSourceValue(qreal value)
+void QDeclarativeSpringFollow::setTo(qreal value)
{
Q_D(QDeclarativeSpringFollow);
- if (d->clock.state() == QAbstractAnimation::Running && d->sourceValue == value)
+ if (d->clock.state() == QAbstractAnimation::Running && d->to == value)
return;
- d->sourceValue = value;
+ d->to = value;
d->start();
}
@@ -307,7 +307,7 @@ void QDeclarativeSpringFollow::setVelocity(qreal velocity)
This property holds the spring constant
The spring constant describes how strongly the target is pulled towards the
- source. Setting spring to 0 turns off spring tracking. Useful values 0 - 5.0
+ source. Setting spring to 0 turns off spring tracking. Useful values 0 - 5.0
When a spring constant is set and the velocity property is greater than 0,
velocity limits the maximum speed.
@@ -417,13 +417,10 @@ void QDeclarativeSpringFollow::setMass(qreal mass)
}
/*!
- \qmlproperty qreal SpringFollow::value
- The current value.
-*/
-
-/*!
\qmlproperty bool SpringFollow::enabled
This property holds whether the target will track the source.
+
+ The default value of this property is 'true'.
*/
bool QDeclarativeSpringFollow::enabled() const
{
@@ -454,6 +451,10 @@ bool QDeclarativeSpringFollow::inSync() const
return d->enabled && d->clock.state() != QAbstractAnimation::Running;
}
+/*!
+ \qmlproperty qreal SpringFollow::value
+ The current value.
+*/
qreal QDeclarativeSpringFollow::value() const
{
Q_D(const QDeclarativeSpringFollow);
diff --git a/src/declarative/util/qdeclarativespringfollow_p.h b/src/declarative/util/qdeclarativespringfollow_p.h
index 2ac0d82..b829c57 100644
--- a/src/declarative/util/qdeclarativespringfollow_p.h
+++ b/src/declarative/util/qdeclarativespringfollow_p.h
@@ -59,7 +59,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeSpringFollow : public QObject,
Q_DECLARE_PRIVATE(QDeclarativeSpringFollow)
Q_INTERFACES(QDeclarativePropertyValueSource)
- Q_PROPERTY(qreal source READ sourceValue WRITE setSourceValue)
+ Q_PROPERTY(qreal to READ to WRITE setTo)
Q_PROPERTY(qreal velocity READ velocity WRITE setVelocity)
Q_PROPERTY(qreal spring READ spring WRITE setSpring)
Q_PROPERTY(qreal damping READ damping WRITE setDamping)
@@ -76,22 +76,30 @@ public:
virtual void setTarget(const QDeclarativeProperty &);
- qreal sourceValue() const;
- void setSourceValue(qreal value);
+ qreal to() const;
+ void setTo(qreal value);
+
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);
+
bool enabled() const;
void setEnabled(bool enabled);
+
bool inSync() const;
qreal value() const;
diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp
index b33af06..7f8b962 100644
--- a/src/declarative/util/qdeclarativexmllistmodel.cpp
+++ b/src/declarative/util/qdeclarativexmllistmodel.cpp
@@ -160,7 +160,7 @@ public:
for (int i=0; i<roleObjects->count(); i++) {
if (!roleObjects->at(i)->isValid()) {
- job.roleQueries << "";
+ job.roleQueries << QString();
continue;
}
job.roleQueries << roleObjects->at(i)->query();
diff --git a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp
index e8bbb86..1cbe2ac 100644
--- a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp
+++ b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp
@@ -274,7 +274,7 @@ void tst_qdeclarativedom::loadComposite()
void tst_qdeclarativedom::testValueSource()
{
QByteArray qml = "import Qt 4.6\n"
- "Rectangle { SpringFollow on height { spring: 1.4; damping: .15; source: Math.min(Math.max(-130, value*2.2 - 130), 133); }}";
+ "Rectangle { SpringFollow on height { spring: 1.4; damping: .15; to: Math.min(Math.max(-130, value*2.2 - 130), 133); }}";
QDeclarativeEngine freshEngine;
QDeclarativeDomDocument document;
@@ -297,7 +297,7 @@ void tst_qdeclarativedom::testValueSource()
QVERIFY(springValue.isLiteral());
QVERIFY(springValue.toLiteral().literal() == "1.4");
- const QDeclarativeDomValue sourceValue = valueSourceObject.property("source").value();
+ const QDeclarativeDomValue sourceValue = valueSourceObject.property("to").value();
QVERIFY(!sourceValue.isInvalid());
QVERIFY(sourceValue.isBinding());
QVERIFY(sourceValue.toBinding().binding() == "Math.min(Math.max(-130, value*2.2 - 130), 133)");
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/deletedEngine.qml b/tests/auto/declarative/qdeclarativeecmascript/data/deletedEngine.qml
new file mode 100644
index 0000000..6c538fe
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/deletedEngine.qml
@@ -0,0 +1,11 @@
+import Qt 4.6
+
+QtObject {
+ function calculate() {
+ return b * 13;
+ }
+
+ property int a: calculate()
+ property int b: 3
+}
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/nullObjectBinding.qml b/tests/auto/declarative/qdeclarativeecmascript/data/nullObjectBinding.qml
new file mode 100644
index 0000000..1bf0b81
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/nullObjectBinding.qml
@@ -0,0 +1,8 @@
+import Qt 4.6
+
+QtObject {
+ property QtObject test
+ test: if (1) model
+ property ListModel model
+}
+
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/numberAssignment.qml b/tests/auto/declarative/qdeclarativeecmascript/data/numberAssignment.qml
new file mode 100644
index 0000000..30a77e8
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/numberAssignment.qml
@@ -0,0 +1,18 @@
+import Qt.test 1.0
+
+NumberAssignment {
+ test1: if (1) 6.7
+ test2: if (1) "6.7"
+ test3: if (1) 6
+ test4: if (1) "6"
+
+ test5: if (1) 6.7
+ test6: if (1) "6.7"
+ test7: if (1) 6
+ test8: if (1) "6"
+
+ test9: if (1) 6.7
+ test10: if (1) "6.7"
+ test11: if (1) 6
+ test12: if (1) "6"
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
index a3bcb6a..0d07055 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp
@@ -80,6 +80,7 @@ void registerTypes()
qmlRegisterExtendedType<MyBaseExtendedObject, BaseExtensionObject>("Qt.test", 1,0, "MyBaseExtendedObject");
qmlRegisterExtendedType<MyExtendedObject, ExtensionObject>("Qt.test", 1,0, "MyExtendedObject");
qmlRegisterType<MyTypeObject>("Qt.test", 1,0, "MyTypeObject");
+ qmlRegisterType<NumberAssignment>("Qt.test", 1,0, "NumberAssignment");
}
#include "testtypes.moc"
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
index faad8b7..4424419 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
+++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
@@ -600,6 +600,71 @@ private:
QVariantList m_actuals;
};
+class NumberAssignment : public QObject
+{
+ Q_OBJECT
+public:
+ Q_PROPERTY(qreal test1 READ test1 WRITE setTest1);
+ qreal _test1;
+ qreal test1() const { return _test1; }
+ void setTest1(qreal v) { _test1 = v; }
+
+ Q_PROPERTY(qreal test2 READ test2 WRITE setTest2);
+ qreal _test2;
+ qreal test2() const { return _test2; }
+ void setTest2(qreal v) { _test2 = v; }
+
+ Q_PROPERTY(qreal test3 READ test3 WRITE setTest3);
+ qreal _test3;
+ qreal test3() const { return _test3; }
+ void setTest3(qreal v) { _test3 = v; }
+
+ Q_PROPERTY(qreal test4 READ test4 WRITE setTest4);
+ qreal _test4;
+ qreal test4() const { return _test4; }
+ void setTest4(qreal v) { _test4 = v; }
+
+ Q_PROPERTY(int test5 READ test5 WRITE setTest5);
+ int _test5;
+ int test5() const { return _test5; }
+ void setTest5(int v) { _test5 = v; }
+
+ Q_PROPERTY(int test6 READ test6 WRITE setTest6);
+ int _test6;
+ int test6() const { return _test6; }
+ void setTest6(int v) { _test6 = v; }
+
+ Q_PROPERTY(int test7 READ test7 WRITE setTest7);
+ int _test7;
+ int test7() const { return _test7; }
+ void setTest7(int v) { _test7 = v; }
+
+ Q_PROPERTY(int test8 READ test8 WRITE setTest8);
+ int _test8;
+ int test8() const { return _test8; }
+ void setTest8(int v) { _test8 = v; }
+
+ Q_PROPERTY(unsigned int test9 READ test9 WRITE setTest9);
+ unsigned int _test9;
+ unsigned int test9() const { return _test9; }
+ void setTest9(unsigned int v) { _test9 = v; }
+
+ Q_PROPERTY(unsigned int test10 READ test10 WRITE setTest10);
+ unsigned int _test10;
+ unsigned int test10() const { return _test10; }
+ void setTest10(unsigned int v) { _test10 = v; }
+
+ Q_PROPERTY(unsigned int test11 READ test11 WRITE setTest11);
+ unsigned int _test11;
+ unsigned int test11() const { return _test11; }
+ void setTest11(unsigned int v) { _test11 = v; }
+
+ Q_PROPERTY(unsigned int test12 READ test12 WRITE setTest12);
+ unsigned int _test12;
+ unsigned int test12() const { return _test12; }
+ void setTest12(unsigned int v) { _test12 = v; }
+};
+
void registerTypes();
#endif // TESTTYPES_H
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 32d407f..72f14f9 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -132,10 +132,13 @@ private slots:
void qlistqobjectMethods();
void strictlyEquals();
void compiled();
+ void numberAssignment();
void bug1();
void dynamicCreationCrash();
void regExpBug();
+ void nullObjectBinding();
+ void deletedEngine();
void callQtInvokables();
private:
@@ -2116,6 +2119,68 @@ void tst_qdeclarativeecmascript::compiled()
delete object;
}
+// Test that numbers assigned in bindings as strings work consistently
+void tst_qdeclarativeecmascript::numberAssignment()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("numberAssignment.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QVERIFY(object->property("test1") == QVariant((qreal)6.7));
+ QVERIFY(object->property("test2") == QVariant((qreal)6.7));
+ QVERIFY(object->property("test3") == QVariant((qreal)6));
+ QVERIFY(object->property("test4") == QVariant((qreal)6));
+
+ QVERIFY(object->property("test5") == QVariant((int)7));
+ QVERIFY(object->property("test6") == QVariant((int)7));
+ QVERIFY(object->property("test7") == QVariant((int)6));
+ QVERIFY(object->property("test8") == QVariant((int)6));
+
+ QVERIFY(object->property("test9") == QVariant((unsigned int)7));
+ QVERIFY(object->property("test10") == QVariant((unsigned int)7));
+ QVERIFY(object->property("test11") == QVariant((unsigned int)6));
+ QVERIFY(object->property("test12") == QVariant((unsigned int)6));
+
+ delete object;
+}
+
+// Test that assigning a null object works
+// Regressed with: df1788b4dbbb2826ae63f26bdf166342595343f4
+void tst_qdeclarativeecmascript::nullObjectBinding()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("nullObjectBinding.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QVERIFY(object->property("test") == QVariant::fromValue((QObject *)0));
+
+ delete object;
+}
+
+// Test that bindings don't evaluate once the engine has been destroyed
+void tst_qdeclarativeecmascript::deletedEngine()
+{
+ QDeclarativeEngine *engine = new QDeclarativeEngine;
+ QDeclarativeComponent component(engine, TEST_FILE("deletedEngine.qml"));
+
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("a").toInt(), 39);
+ object->setProperty("b", QVariant(9));
+ QCOMPARE(object->property("a").toInt(), 117);
+
+ delete engine;
+
+ QCOMPARE(object->property("a").toInt(), 117);
+ object->setProperty("b", QVariant(10));
+ QCOMPARE(object->property("a").toInt(), 117);
+
+ delete object;
+}
+
QTEST_MAIN(tst_qdeclarativeecmascript)
#include "tst_qdeclarativeecmascript.moc"
diff --git a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp
index a1aceb7..f4df130 100644
--- a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp
+++ b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp
@@ -520,6 +520,24 @@ void tst_qdeclarativeinstruction::dump()
data->bytecode << i;
}
+ {
+ QDeclarativeInstruction i;
+ i.line = 51;
+ i.type = QDeclarativeInstruction::StoreVariantInteger;
+ i.storeInteger.value = 11;
+ i.storeInteger.propertyIndex = 32;
+ data->bytecode << i;
+ }
+
+ {
+ QDeclarativeInstruction i;
+ i.line = 52;
+ i.type = QDeclarativeInstruction::StoreVariantDouble;
+ i.storeDouble.value = 33.7;
+ i.storeDouble.propertyIndex = 19;
+ data->bytecode << i;
+ }
+
QStringList expect;
expect
<< "Index\tLine\tOperation\t\tData1\tData2\tData3\tComments"
@@ -575,6 +593,8 @@ void tst_qdeclarativeinstruction::dump()
<< "47\t\tNA\tDEFER\t\t\t7"
<< "48\t\t48\tSTORE_IMPORTED_SCRIPT\t2"
<< "49\t\t50\tXXX UNKOWN INSTRUCTION\t1234"
+ << "50\t\t51\tSTORE_VARIANT_INTEGER\t\t32\t11"
+ << "51\t\t52\tSTORE_VARIANT_DOUBLE\t\t19\t33.7"
<< "-------------------------------------------------------------------------------";
messages = QStringList();
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml
new file mode 100644
index 0000000..a1d33ef
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/assignLiteralToVariant.qml
@@ -0,0 +1,14 @@
+import Qt 4.6
+
+QtObject {
+ property var test1: 1
+ property var test2: 1.7
+ property var test3: "Hello world!"
+ property var test4: "#FF008800"
+ property var test5: "10,10,10x10"
+ property var test6: "10,10"
+ property var test7: "10x10"
+ property var test8: "100,100,100"
+ property var test9: String("#FF008800")
+}
+
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index bf10a01..bfb56ba 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -87,6 +87,7 @@ private slots:
void assignBasicTypes();
void assignTypeExtremes();
void assignCompositeToType();
+ void assignLiteralToVariant();
void customParserTypes();
void rootAsQmlComponent();
void inlineQmlComponents();
@@ -479,6 +480,37 @@ void tst_qdeclarativelanguage::assignCompositeToType()
QVERIFY(object != 0);
}
+// Test that literals are stored correctly in variant properties
+void tst_qdeclarativelanguage::assignLiteralToVariant()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("assignLiteralToVariant.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+
+ QCOMPARE(object->property("test1").userType(), (int)QVariant::Int);
+ QCOMPARE(object->property("test2").userType(), (int)QMetaType::Double);
+ QCOMPARE(object->property("test3").userType(), (int)QVariant::String);
+ QCOMPARE(object->property("test4").userType(), (int)QVariant::Color);
+ QCOMPARE(object->property("test5").userType(), (int)QVariant::RectF);
+ QCOMPARE(object->property("test6").userType(), (int)QVariant::PointF);
+ QCOMPARE(object->property("test7").userType(), (int)QVariant::SizeF);
+ QCOMPARE(object->property("test8").userType(), (int)QVariant::Vector3D);
+ QCOMPARE(object->property("test9").userType(), (int)QVariant::String);
+
+ QVERIFY(object->property("test1") == QVariant(1));
+ QVERIFY(object->property("test2") == QVariant((double)1.7));
+ QVERIFY(object->property("test3") == QVariant(QString(QLatin1String("Hello world!"))));
+ QVERIFY(object->property("test4") == QVariant(QColor::fromRgb(0xFF008800)));
+ QVERIFY(object->property("test5") == QVariant(QRectF(10, 10, 10, 10)));
+ QVERIFY(object->property("test6") == QVariant(QPointF(10, 10)));
+ QVERIFY(object->property("test7") == QVariant(QSizeF(10, 10)));
+ QVERIFY(object->property("test8") == QVariant(QVector3D(100, 100, 100)));
+ QVERIFY(object->property("test9") == QVariant(QString(QLatin1String("#FF008800"))));
+
+ delete object;
+}
+
// Tests that custom parser types can be instantiated
void tst_qdeclarativelanguage::customParserTypes()
{
diff --git a/tests/auto/declarative/qdeclarativespringfollow/data/springfollow2.qml b/tests/auto/declarative/qdeclarativespringfollow/data/springfollow2.qml
index 7c81fb5..ffbf7d5 100644
--- a/tests/auto/declarative/qdeclarativespringfollow/data/springfollow2.qml
+++ b/tests/auto/declarative/qdeclarativespringfollow/data/springfollow2.qml
@@ -1,7 +1,7 @@
import Qt 4.6
SpringFollow {
- source: 1.44; velocity: 0.9
+ to: 1.44; velocity: 0.9
spring: 1.0; damping: 0.5
epsilon: 0.25; modulus: 360.0
mass: 2.0; enabled: true
diff --git a/tests/auto/declarative/qdeclarativespringfollow/data/springfollow3.qml b/tests/auto/declarative/qdeclarativespringfollow/data/springfollow3.qml
index 6fec55b..9a8f6f3 100644
--- a/tests/auto/declarative/qdeclarativespringfollow/data/springfollow3.qml
+++ b/tests/auto/declarative/qdeclarativespringfollow/data/springfollow3.qml
@@ -1,7 +1,7 @@
import Qt 4.6
SpringFollow {
- source: 1.44; velocity: 0.9
+ to: 1.44; velocity: 0.9
spring: 1.0; damping: 0.5
epsilon: 0.25; modulus: 360.0
mass: 2.0; enabled: false
diff --git a/tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp b/tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp
index 7a60e78..8a07d6b 100644
--- a/tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp
+++ b/tests/auto/declarative/qdeclarativespringfollow/tst_qdeclarativespringfollow.cpp
@@ -72,7 +72,7 @@ void tst_qdeclarativespringfollow::defaultValues()
QVERIFY(obj != 0);
- QCOMPARE(obj->sourceValue(), 0.);
+ QCOMPARE(obj->to(), 0.);
QCOMPARE(obj->velocity(), 0.);
QCOMPARE(obj->spring(), 0.);
QCOMPARE(obj->damping(), 0.);
@@ -94,7 +94,7 @@ void tst_qdeclarativespringfollow::values()
QVERIFY(obj != 0);
- QCOMPARE(obj->sourceValue(), 1.44);
+ QCOMPARE(obj->to(), 1.44);
QCOMPARE(obj->velocity(), 0.9);
QCOMPARE(obj->spring(), 1.0);
QCOMPARE(obj->damping(), 0.5);
@@ -117,7 +117,7 @@ void tst_qdeclarativespringfollow::disabled()
QVERIFY(obj != 0);
- QCOMPARE(obj->sourceValue(), 1.44);
+ QCOMPARE(obj->to(), 1.44);
QCOMPARE(obj->velocity(), 0.9);
QCOMPARE(obj->spring(), 1.0);
QCOMPARE(obj->damping(), 0.5);
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.0.png b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.0.png
index cf36d60..5b7b426 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.0.png
+++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.0.png
Binary files differ
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.1.png b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.1.png
index 6069df8..7c27310 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.1.png
+++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.1.png
Binary files differ
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.2.png b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.2.png
index b8bd5f3..cbfdb23 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.2.png
+++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.2.png
Binary files differ
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.3.png b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.3.png
index cf36d60..5b7b426 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.3.png
+++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.3.png
Binary files differ
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.4.png b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.4.png
index 831d6b4..5af705e 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.4.png
+++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.4.png
Binary files differ
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.5.png b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.5.png
index f7079dc..af4395e 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.5.png
+++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.5.png
Binary files differ
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.6.png b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.6.png
index a5f4451..cd12bc9 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.6.png
+++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.6.png
Binary files differ
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.7.png b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.7.png
index e1261d0..471c86b 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.7.png
+++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.7.png
Binary files differ
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.qml b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.qml
index 5a131e9..f3071e4 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.qml
+++ b/tests/auto/declarative/qmlvisual/qdeclarativemousearea/data/drag.qml
@@ -486,7 +486,7 @@ VisualTest {
}
Frame {
msec: 1840
- hash: "b6b4b2c7acddd23609caa9727911b981"
+ hash: "668cc6d9d699b947a7c0f3ff4b26853f"
}
Mouse {
type: 5
@@ -498,7 +498,7 @@ VisualTest {
}
Frame {
msec: 1856
- hash: "b6b4b2c7acddd23609caa9727911b981"
+ hash: "668cc6d9d699b947a7c0f3ff4b26853f"
}
Mouse {
type: 5
@@ -510,7 +510,7 @@ VisualTest {
}
Frame {
msec: 1872
- hash: "022610222cfbcf9e9a8991cdb60c7bbb"
+ hash: "668cc6d9d699b947a7c0f3ff4b26853f"
}
Mouse {
type: 5
@@ -522,7 +522,7 @@ VisualTest {
}
Frame {
msec: 1888
- hash: "9b5201a3201a102b20592d81218b5e74"
+ hash: "668cc6d9d699b947a7c0f3ff4b26853f"
}
Mouse {
type: 5
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/clock.qml b/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/clock.qml
index 21bbc7f..fbab4b7 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/clock.qml
+++ b/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/clock.qml
@@ -25,7 +25,7 @@ Rectangle {
origin.x: 7.5; origin.y: 73; angle: 0
SpringFollow on angle {
spring: 2; damping: 0.2; modulus: 360
- source: (clock.hours * 30) + (clock.minutes * 0.5)
+ to: (clock.hours * 30) + (clock.minutes * 0.5)
}
}
}
@@ -39,7 +39,7 @@ Rectangle {
origin.x: 6.5; origin.y: 83; angle: 0
SpringFollow on angle {
spring: 2; damping: 0.2; modulus: 360
- source: clock.minutes * 6
+ to: clock.minutes * 6
}
}
}
@@ -53,7 +53,7 @@ Rectangle {
origin.x: 2.5; origin.y: 80; angle: 0
SpringFollow on angle {
spring: 5; damping: 0.25; modulus: 360
- source: clock.seconds * 6
+ to: clock.seconds * 6
}
}
}
diff --git a/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/follow.qml b/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/follow.qml
index 1659bb7..5368349 100644
--- a/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/follow.qml
+++ b/tests/auto/declarative/qmlvisual/qdeclarativespringfollow/follow.qml
@@ -26,7 +26,7 @@ Rectangle {
color: "#ff0000"
x: rect.width; width: rect.width; height: 20
y: 200
- SpringFollow on y { source: rect.y; velocity: 200 }
+ SpringFollow on y { to: rect.y; velocity: 200 }
}
// Spring
@@ -34,13 +34,13 @@ Rectangle {
color: "#ff0000"
x: rect.width * 2; width: rect.width/2; height: 20
y: 200
- SpringFollow on y { source: rect.y; spring: 1.0; damping: 0.2 }
+ SpringFollow on y { to: rect.y; spring: 1.0; damping: 0.2 }
}
Rectangle {
color: "#880000"
x: rect.width * 2.5; width: rect.width/2; height: 20
y: 200
- SpringFollow on y { source: rect.y; spring: 1.0; damping: 0.2; mass: 3.0 } // "heavier" object
+ SpringFollow on y { to: rect.y; spring: 1.0; damping: 0.2; mass: 3.0 } // "heavier" object
}
// Follow mouse
@@ -52,8 +52,8 @@ Rectangle {
width: 20; height: 20
radius: 10
color: "#0000ff"
- SpringFollow on x { id: f1; source: mouseRegion.mouseX-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
- SpringFollow on y { id: f2; source: mouseRegion.mouseY-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
+ SpringFollow on x { id: f1; to: mouseRegion.mouseX-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
+ SpringFollow on y { id: f2; to: mouseRegion.mouseY-10; spring: 1.0; damping: 0.05; epsilon: 0.25 }
states: [
State {
name: "following"
diff --git a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/BoomBlock.qml b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/BoomBlock.qml
index b14531d..9b88b53 100644
--- a/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/BoomBlock.qml
+++ b/tests/benchmarks/declarative/qdeclarativecomponent/data/samegame/BoomBlock.qml
@@ -8,8 +8,8 @@ Item { id:block
property int targetX: 0
property int targetY: 0
- SpringFollow on x { enabled: spawned; source: targetX; spring: 2; damping: 0.2 }
- SpringFollow on y { source: targetY; spring: 2; damping: 0.2 }
+ SpringFollow on x { enabled: spawned; to: targetX; spring: 2; damping: 0.2 }
+ SpringFollow on y { to: targetY; spring: 2; damping: 0.2 }
Image { id: img
source: {
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
index 5099e49..01b3912 100644
--- a/tools/qml/main.cpp
+++ b/tools/qml/main.cpp
@@ -101,8 +101,9 @@ void usage()
qWarning(" -dragthreshold <size> .................... set mouse drag threshold size");
qWarning(" -netcache <size> ......................... set disk cache to size bytes");
qWarning(" -translation <translationfile> ........... set the language to run in");
- qWarning(" -L <directory> ........................... prepend to the library search path,");
+ qWarning(" -I <directory> ........................... prepend to the module import search path,");
qWarning(" display path if <directory> is empty");
+ qWarning(" -P <directory> ........................... prepend to the plugin search path");
qWarning(" -opengl .................................. use a QGLWidget for the viewport");
qWarning(" -script <path> ........................... set the script to use");
qWarning(" -scriptopts <options>|help ............... set the script options to use");
@@ -167,7 +168,8 @@ int main(int argc, char ** argv)
QString dither = "none";
QString recordfile;
QStringList recordargs;
- QStringList libraries;
+ QStringList imports;
+ QStringList plugins;
QString skin;
QString script;
QString scriptopts;
@@ -239,14 +241,19 @@ int main(int argc, char ** argv)
useGL = true;
} else if (arg == "-qmlbrowser") {
useNativeFileBrowser = false;
- } else if (arg == "-L") {
+ } else if (arg == "-I" || arg == "-L") {
+ if (arg == "-L")
+ fprintf(stderr, "-L option provided for compatibility only, use -I instead");
if (lastArg) {
QDeclarativeEngine tmpEngine;
QString paths = tmpEngine.importPathList().join(QLatin1String(":"));
fprintf(stderr, "Current search path: %s\n", paths.toLocal8Bit().constData());
return 0;
}
- libraries << QString(argv[++i]);
+ imports << QString(argv[++i]);
+ } else if (arg == "-P") {
+ if (lastArg) usage();
+ plugins << QString(argv[++i]);
} else if (arg == "-script") {
if (lastArg) usage();
script = QString(argv[++i]);
@@ -320,9 +327,12 @@ int main(int argc, char ** argv)
viewer.addLibraryPath(QCoreApplication::applicationDirPath());
- foreach (QString lib, libraries)
+ foreach (QString lib, imports)
viewer.addLibraryPath(lib);
+ foreach (QString plugin, plugins)
+ viewer.addPluginPath(plugin);
+
viewer.setNetworkCacheSize(cache);
viewer.setRecordFile(recordfile);
if (resizeview)
@@ -349,6 +359,21 @@ int main(int argc, char ** argv)
viewer.setUseNativeFileBrowser(useNativeFileBrowser);
if (fullScreen && maximized)
qWarning() << "Both -fullscreen and -maximized specified. Using -fullscreen.";
+
+ if (fileName.isEmpty()) {
+ QFile qmlapp(QLatin1String("qmlapp"));
+ if (qmlapp.exists() && qmlapp.open(QFile::ReadOnly)) {
+ QString content = QString::fromUtf8(qmlapp.readAll());
+ qmlapp.close();
+
+ int newline = content.indexOf(QLatin1Char('\n'));
+ if (newline >= 0)
+ fileName = content.left(newline);
+ else
+ fileName = content;
+ }
+ }
+
if (!fileName.isEmpty()) {
viewer.open(fileName);
fullScreen ? viewer.showFullScreen() : maximized ? viewer.showMaximized() : viewer.show();
diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp
index 1ab528e..c4ebd80 100644
--- a/tools/qml/qmlruntime.cpp
+++ b/tools/qml/qmlruntime.cpp
@@ -870,6 +870,11 @@ void QDeclarativeViewer::addLibraryPath(const QString& lib)
canvas->engine()->addImportPath(lib);
}
+void QDeclarativeViewer::addPluginPath(const QString& plugin)
+{
+ canvas->engine()->addPluginPath(plugin);
+}
+
void QDeclarativeViewer::reload()
{
openQml(currentFileOrUrl);
diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h
index 01777bd..6f1e425 100644
--- a/tools/qml/qmlruntime.h
+++ b/tools/qml/qmlruntime.h
@@ -96,6 +96,7 @@ public:
void setDeviceKeys(bool);
void setNetworkCacheSize(int size);
void addLibraryPath(const QString& lib);
+ void addPluginPath(const QString& plugin);
void setUseGL(bool use);
void setUseNativeFileBrowser(bool);