summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demos/qtdemo/menumanager.cpp6
-rw-r--r--demos/qtdemo/qmlShell.qml4
-rw-r--r--doc/src/images/qml-focus-example.pngbin43921 -> 31370 bytes
-rw-r--r--doc/src/images/qml-xmlhttprequest-example.pngbin21311 -> 20934 bytes
-rw-r--r--examples/declarative/animation/behaviors/behavior-example.qml2
-rw-r--r--examples/declarative/cppextensions/cppextensions.qmlproject2
-rw-r--r--examples/declarative/keyinteraction/focus/Core/GridMenu.qml7
-rw-r--r--examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml17
-rw-r--r--examples/declarative/keyinteraction/focus/Core/ListViews.qml4
-rw-r--r--examples/declarative/keyinteraction/focus/focus.qml5
-rw-r--r--examples/declarative/ui-components/progressbar/content/ProgressBar.qml2
-rw-r--r--examples/declarative/ui-components/searchbox/SearchBox.qml2
-rw-r--r--examples/declarative/ui-components/tabwidget/main.qml6
-rw-r--r--src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable.cpp52
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable_p.h7
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflickable_p_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp68
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview_p.h3
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage.cpp5
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp84
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview_p.h3
-rw-r--r--src/declarative/graphicsitems/qdeclarativeloader.cpp10
-rw-r--r--src/declarative/graphicsitems/qdeclarativepainteditem.cpp4
-rw-r--r--src/declarative/graphicsitems/qdeclarativepathview.cpp4
-rw-r--r--src/declarative/graphicsitems/qdeclarativerectangle.cpp1
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext.cpp142
-rw-r--r--src/declarative/graphicsitems/qdeclarativetext_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp28
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit_p.h2
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp2
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp33
-rw-r--r--src/declarative/qml/qdeclarativecompiler_p.h1
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp4
-rw-r--r--src/declarative/qml/qdeclarativecustomparser.cpp10
-rw-r--r--src/declarative/qml/qdeclarativecustomparser_p.h14
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp24
-rw-r--r--src/declarative/qml/qdeclarativeengine_p.h1
-rw-r--r--src/declarative/qml/qdeclarativeglobalscriptclass.cpp28
-rw-r--r--src/declarative/qml/qdeclarativeglobalscriptclass_p.h5
-rw-r--r--src/declarative/qml/qdeclarativeobjectscriptclass.cpp24
-rw-r--r--src/declarative/qml/qdeclarativeobjectscriptclass_p.h2
-rw-r--r--src/declarative/qml/qdeclarativetypenamescriptclass.cpp4
-rw-r--r--src/declarative/util/qdeclarativeanimation.cpp2
-rw-r--r--src/declarative/util/qdeclarativelistmodel.cpp11
-rw-r--r--src/declarative/util/qdeclarativelistmodel_p.h2
-rw-r--r--src/declarative/util/qdeclarativepixmapcache.cpp6
-rw-r--r--src/declarative/util/qdeclarativepropertychanges_p.h3
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/data/runningTrueBug.qml30
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp15
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/eval.qml6
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/function.qml6
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.js1
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.qml8
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11606.qml12
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml4
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml2
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/testtypes.h6
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp41
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml6
-rw-r--r--tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp4
-rw-r--r--tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml2
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp231
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.errors.txt1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.qml5
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp1
-rw-r--r--tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp12
-rw-r--r--tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml2
-rw-r--r--tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp274
-rw-r--r--tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp9
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.js4
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml2
-rw-r--r--tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp6
-rw-r--r--tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp1
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments.qml41
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_cb.pngbin0 -> 496 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_cc.pngbin0 -> 556 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_ct.pngbin0 -> 533 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_lb.pngbin0 -> 496 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_lc.pngbin0 -> 535 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_lt.pngbin0 -> 514 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_rb.pngbin0 -> 505 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_rc.pngbin0 -> 559 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/data/alignments_rt.pngbin0 -> 539 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp73
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments.qml41
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_cb.pngbin0 -> 496 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_cc.pngbin0 -> 556 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_ct.pngbin0 -> 533 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_lb.pngbin0 -> 496 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_lc.pngbin0 -> 535 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_lt.pngbin0 -> 514 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_rb.pngbin0 -> 505 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_rc.pngbin0 -> 559 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/data/alignments_rt.pngbin0 -> 539 bytes
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp61
-rw-r--r--tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp32
-rw-r--r--tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp6
-rw-r--r--tests/benchmarks/declarative/script/data/block.qml6
-rw-r--r--tests/benchmarks/declarative/script/data/global.js54
-rw-r--r--tests/benchmarks/declarative/script/data/global_prop.qml53
-rw-r--r--tests/benchmarks/declarative/script/tst_script.cpp75
-rw-r--r--tools/linguist/lupdate/qdeclarative.cpp84
-rw-r--r--tools/qml/deviceorientation_maemo5.cpp (renamed from tools/qml/deviceorientation_maemo.cpp)2
-rw-r--r--tools/qml/loggerwidget.cpp25
-rw-r--r--tools/qml/loggerwidget.h12
-rw-r--r--tools/qml/proxysettings.cpp5
-rw-r--r--tools/qml/proxysettings.h4
-rw-r--r--tools/qml/proxysettings_maemo5.ui177
-rw-r--r--tools/qml/qml.pri10
-rw-r--r--tools/qml/qml.pro3
-rw-r--r--tools/qml/qmlruntime.cpp479
-rw-r--r--tools/qml/qmlruntime.h23
-rw-r--r--tools/qml/recopts_maemo5.ui254
-rw-r--r--tools/qml/texteditautoresizer_maemo5.h113
115 files changed, 2289 insertions, 687 deletions
diff --git a/demos/qtdemo/menumanager.cpp b/demos/qtdemo/menumanager.cpp
index a2ceb0e..15561ab 100644
--- a/demos/qtdemo/menumanager.cpp
+++ b/demos/qtdemo/menumanager.cpp
@@ -369,10 +369,10 @@ void MenuManager::launchQmlExample(const QString &name)
dir = QDir(QLibraryInfo::location(QLibraryInfo::DemosPath));
else
dir = QDir(QLibraryInfo::location(QLibraryInfo::ExamplesPath));
- QFile file(dir.path() + "/" + dirName + "/" + fileName + "/" + fileName.split('/').last() + ".qml");
+ QFile file(dir.path() + "/" + dirName + "/" + fileName + "/" + "main.qml");
if(!file.exists()){
- //try main.qml as well
- file.setFileName(dir.path() + "/" + dirName + "/" + fileName + "/" + "main.qml");
+ //try dirname.qml as well
+ file.setFileName(dir.path() + "/" + dirName + "/" + fileName + "/" + fileName.split('/').last() + ".qml");
if(!file.exists()){
exampleError(QProcess::UnknownError);
return;
diff --git a/demos/qtdemo/qmlShell.qml b/demos/qtdemo/qmlShell.qml
index 5c5f96c..e15d33c 100644
--- a/demos/qtdemo/qmlShell.qml
+++ b/demos/qtdemo/qmlShell.qml
@@ -99,6 +99,7 @@ Item {
}
MouseArea{
anchors.fill: parent
+ acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
onClicked: loader.focus=true;/* and don't propogate to the 'exit' area*/
}
@@ -130,7 +131,7 @@ Item {
textFormat: Text.RichText
//Note that if loader is Error, it is because the file was found but there was an error creating the component
//This means either we have a bug in our demos, or the required modules (which ship with Qt) did not deploy correctly
- text: "The example has failed to load.<br />If you installed Qt's QML modules this is a bug!<br />"
+ text: "The example has failed to load.<br />If you installed all Qt's C++ and QML modules then this is a bug!<br />"
+ 'Report it at <a href="http://bugreports.qt.nokia.com">http://bugreports.qt.nokia.com</a>';
onLinkActivated: Qt.openUrlExternally(link);
}
@@ -145,6 +146,7 @@ Item {
z: 8
enabled: main.show
hoverEnabled: main.show //To steal focus from the buttons
+ acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
anchors.fill: parent
onClicked: main.show=false;
}
diff --git a/doc/src/images/qml-focus-example.png b/doc/src/images/qml-focus-example.png
index 0ec2bff..107d2cb 100644
--- a/doc/src/images/qml-focus-example.png
+++ b/doc/src/images/qml-focus-example.png
Binary files differ
diff --git a/doc/src/images/qml-xmlhttprequest-example.png b/doc/src/images/qml-xmlhttprequest-example.png
index 68e7d27..f585613 100644
--- a/doc/src/images/qml-xmlhttprequest-example.png
+++ b/doc/src/images/qml-xmlhttprequest-example.png
Binary files differ
diff --git a/examples/declarative/animation/behaviors/behavior-example.qml b/examples/declarative/animation/behaviors/behavior-example.qml
index d187fbf..adefb9e 100644
--- a/examples/declarative/animation/behaviors/behavior-example.qml
+++ b/examples/declarative/animation/behaviors/behavior-example.qml
@@ -82,7 +82,7 @@ Rectangle {
property string text
- x: 62.5; y: 75; width: 75; height: 50
+ x: 62; y: 75; width: 75; height: 50
radius: 6
border.width: 4; border.color: "white"
color: "firebrick"
diff --git a/examples/declarative/cppextensions/cppextensions.qmlproject b/examples/declarative/cppextensions/cppextensions.qmlproject
index d4909f8..6b36284 100644
--- a/examples/declarative/cppextensions/cppextensions.qmlproject
+++ b/examples/declarative/cppextensions/cppextensions.qmlproject
@@ -12,5 +12,5 @@ Project {
directory: "."
}
/* List of plugin directories passed to QML runtime */
- // importPaths: [ " ../exampleplugin " ]
+ importPaths: [ "plugins" ]
}
diff --git a/examples/declarative/keyinteraction/focus/Core/GridMenu.qml b/examples/declarative/keyinteraction/focus/Core/GridMenu.qml
index d0b45f5..9a8d3f3 100644
--- a/examples/declarative/keyinteraction/focus/Core/GridMenu.qml
+++ b/examples/declarative/keyinteraction/focus/Core/GridMenu.qml
@@ -55,10 +55,11 @@ FocusScope {
GridView {
id: gridView
- x: 20; width: parent.width - 40; height: parent.height
+ anchors.fill: parent; anchors.leftMargin: 20; anchors.rightMargin: 20
cellWidth: 152; cellHeight: 152
focus: true
model: 12
+
KeyNavigation.down: listViews
KeyNavigation.left: contextMenu
@@ -70,9 +71,9 @@ FocusScope {
id: content
color: "transparent"
smooth: true
- anchors.centerIn: parent; width: container.width - 40; height: container.height - 40; radius: 10
+ anchors.fill: parent; anchors.margins: 20; radius: 10
- Rectangle { color: "#91AA9D"; x: 3; y: 3; width: parent.width - 6; height: parent.height - 6; radius: 8 }
+ Rectangle { color: "#91AA9D"; anchors.fill: parent; anchors.margins: 3; radius: 8; smooth: true }
Image { source: "images/qt-logo.png"; anchors.centerIn: parent; smooth: true }
}
diff --git a/examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml b/examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml
index fba9b05..cc13637 100644
--- a/examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml
+++ b/examples/declarative/keyinteraction/focus/Core/ListViewDelegate.qml
@@ -42,7 +42,7 @@ import Qt 4.7
Item {
id: container
- x: 5; width: ListView.view.width - 10; height: 60
+ width: ListView.view.width; height: 60; anchors.leftMargin: 10; anchors.rightMargin: 10
Rectangle {
id: content
@@ -51,11 +51,15 @@ Item {
smooth: true
radius: 10
- Rectangle { color: "#91AA9D"; x: 3; y: 3; width: parent.width - 6; height: parent.height - 6; radius: 8 }
- Text {
- text: "List element " + (index + 1); color: "#193441"; font.bold: false; anchors.centerIn: parent
- font.pixelSize: 14
- }
+ Rectangle { anchors.fill: parent; anchors.margins: 3; color: "#91AA9D"; smooth: true; radius: 8 }
+ }
+
+ Text {
+ id: label
+ anchors.centerIn: content
+ text: "List element " + (index + 1)
+ color: "#193441"
+ font.pixelSize: 14
}
MouseArea {
@@ -72,6 +76,7 @@ Item {
states: State {
name: "active"; when: container.focus == true
PropertyChanges { target: content; color: "#FCFFF5"; scale: 1.1 }
+ PropertyChanges { target: label; font.pixelSize: 16 }
}
transitions: Transition {
diff --git a/examples/declarative/keyinteraction/focus/Core/ListViews.qml b/examples/declarative/keyinteraction/focus/Core/ListViews.qml
index 670a3fa..6f9ceb4 100644
--- a/examples/declarative/keyinteraction/focus/Core/ListViews.qml
+++ b/examples/declarative/keyinteraction/focus/Core/ListViews.qml
@@ -60,7 +60,7 @@ FocusScope {
ListView {
id: list2
- y: wantsFocus ? 10 : 40; x: parent.width / 3; width: parent.width / 3; height: parent.height - 20
+ y: wantsFocus ? 10 : 40; x: parseInt(parent.width / 3); width: parent.width / 3; height: parent.height - 20
KeyNavigation.up: gridMenu; KeyNavigation.left: list1; KeyNavigation.right: list3
model: 10; cacheBuffer: 200
delegate: ListViewDelegate {}
@@ -72,7 +72,7 @@ FocusScope {
ListView {
id: list3
- y: wantsFocus ? 10 : 40; x: 2 * parent.width / 3; width: parent.width / 3; height: parent.height - 20
+ y: wantsFocus ? 10 : 40; x: parseInt(2 * parent.width / 3); width: parent.width / 3; height: parent.height - 20
KeyNavigation.up: gridMenu; KeyNavigation.left: list2
model: 10; cacheBuffer: 200
delegate: ListViewDelegate {}
diff --git a/examples/declarative/keyinteraction/focus/focus.qml b/examples/declarative/keyinteraction/focus/focus.qml
index 068ba1d..8b2af70 100644
--- a/examples/declarative/keyinteraction/focus/focus.qml
+++ b/examples/declarative/keyinteraction/focus/focus.qml
@@ -68,7 +68,8 @@ Rectangle {
Rectangle {
id: shade
- color: "black"; opacity: 0; anchors.fill: parent
+ anchors.fill: parent
+ color: "black"; opacity: 0
}
states: State {
@@ -88,7 +89,7 @@ Rectangle {
anchors.verticalCenter: parent.verticalCenter
MouseArea {
- anchors { fill: parent; leftMargin: -10; topMargin: -10; rightMargin: -10; bottomMargin: -10 }
+ anchors.fill: parent; anchors.margins: -10
onClicked: window.state = "contextMenuOpen"
}
}
diff --git a/examples/declarative/ui-components/progressbar/content/ProgressBar.qml b/examples/declarative/ui-components/progressbar/content/ProgressBar.qml
index 829ab9b..6aa6765 100644
--- a/examples/declarative/ui-components/progressbar/content/ProgressBar.qml
+++ b/examples/declarative/ui-components/progressbar/content/ProgressBar.qml
@@ -66,7 +66,7 @@ Item {
width: highlight.widthDest
Behavior on width { SmoothedAnimation { velocity: 1200 } }
- anchors { left: parent.left; top: parent.top; bottom: parent.bottom; leftMargin: 3; topMargin: 3; bottomMargin: 3 }
+ anchors { left: parent.left; top: parent.top; bottom: parent.bottom; margins: 3 }
radius: 1
gradient: Gradient {
GradientStop { id: gradient1; position: 0.0 }
diff --git a/examples/declarative/ui-components/searchbox/SearchBox.qml b/examples/declarative/ui-components/searchbox/SearchBox.qml
index e6b9c8f..6d87837 100644
--- a/examples/declarative/ui-components/searchbox/SearchBox.qml
+++ b/examples/declarative/ui-components/searchbox/SearchBox.qml
@@ -73,7 +73,7 @@ FocusScope {
TextInput {
id: textInput
- anchors { left: parent.left; leftMargin: 8; verticalCenter: parent.verticalCenter }
+ anchors { left: parent.left; leftMargin: 8; right: clear.left; rightMargin: 8; verticalCenter: parent.verticalCenter }
focus: true
}
diff --git a/examples/declarative/ui-components/tabwidget/main.qml b/examples/declarative/ui-components/tabwidget/main.qml
index e11902a..4a27806 100644
--- a/examples/declarative/ui-components/tabwidget/main.qml
+++ b/examples/declarative/ui-components/tabwidget/main.qml
@@ -50,7 +50,7 @@ TabWidget {
color: "#e3e3e3"
Rectangle {
- anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 }
+ anchors.fill: parent; anchors.margins: 20
color: "#ff7f7f"
Text {
width: parent.width - 20
@@ -68,7 +68,7 @@ TabWidget {
color: "#e3e3e3"
Rectangle {
- anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 }
+ anchors.fill: parent; anchors.margins: 20
color: "#7fff7f"
Text {
width: parent.width - 20
@@ -85,7 +85,7 @@ TabWidget {
anchors.fill: parent; color: "#e3e3e3"
Rectangle {
- anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 }
+ anchors.fill: parent; anchors.margins: 20
color: "#7f7fff"
Text {
width: parent.width - 20
diff --git a/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp b/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp
index a349bec..0342c9f 100644
--- a/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp
@@ -180,6 +180,8 @@ void GraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
When this item has keyboard focus, all keyboard input will be sent directly to the
web page within.
+
+ \sa {declarative/modelviews/webview}{WebView example}, {demos/declarative/webbrowser}{Web Browser demo}
*/
/*!
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
index 3f681b7..65bc233 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp
@@ -122,7 +122,7 @@ void QDeclarativeFlickableVisibleArea::updateVisible()
QDeclarativeFlickablePrivate::QDeclarativeFlickablePrivate()
- : viewport(new QDeclarativeItem)
+ : contentItem(new QDeclarativeItem)
, hData(this, &QDeclarativeFlickablePrivate::setRoundedViewportX)
, vData(this, &QDeclarativeFlickablePrivate::setRoundedViewportY)
, flickingHorizontally(false), flickingVertically(false)
@@ -140,8 +140,8 @@ QDeclarativeFlickablePrivate::QDeclarativeFlickablePrivate()
void QDeclarativeFlickablePrivate::init()
{
Q_Q(QDeclarativeFlickable);
- QDeclarative_setParent_noEvent(viewport, q);
- viewport->setParentItem(q);
+ QDeclarative_setParent_noEvent(contentItem, q);
+ contentItem->setParentItem(q);
static int timelineUpdatedIdx = -1;
static int timelineCompletedIdx = -1;
static int flickableTickedIdx = -1;
@@ -158,7 +158,7 @@ void QDeclarativeFlickablePrivate::init()
q, flickableMovementEndingIdx, Qt::DirectConnection);
q->setAcceptedMouseButtons(Qt::LeftButton);
q->setFiltersChildEvents(true);
- QDeclarativeItemPrivate *viewportPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(viewport));
+ QDeclarativeItemPrivate *viewportPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(contentItem));
viewportPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
lastPosTime.invalidate();
}
@@ -182,7 +182,7 @@ qreal QDeclarativeFlickablePrivate::overShootDistance(qreal velocity, qreal size
void QDeclarativeFlickablePrivate::itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeom, const QRectF &oldGeom)
{
Q_Q(QDeclarativeFlickable);
- if (item == viewport) {
+ if (item == contentItem) {
if (newGeom.x() != oldGeom.x())
emit q->contentXChanged();
if (newGeom.y() != oldGeom.y())
@@ -579,10 +579,28 @@ void QDeclarativeFlickable::ticked()
viewportMoved();
}
-QDeclarativeItem *QDeclarativeFlickable::viewport()
+/*!
+ \qmlproperty Item Flickable::contentItem
+
+ The internal item that contains the Items to be moved in the Flickable.
+
+ Items declared as children of a Flickable are automatically parented to the Flickable's contentItem.
+
+ Items created dynamically need to be explicitly parented to the \e contentItem:
+ \code
+ Flickable {
+ id: myFlickable
+ function addItem(file) {
+ var component = Qt.createComponent(file)
+ component.createObject(myFlickable.contentItem);
+ }
+ }
+ \endcode
+*/
+QDeclarativeItem *QDeclarativeFlickable::contentItem()
{
Q_D(QDeclarativeFlickable);
- return d->viewport;
+ return d->contentItem;
}
QDeclarativeFlickableVisibleArea *QDeclarativeFlickable::visibleArea()
@@ -899,12 +917,12 @@ void QDeclarativeFlickablePrivate::clearDelayedPress()
void QDeclarativeFlickablePrivate::setRoundedViewportX(qreal x)
{
- viewport->setX(qRound(x));
+ contentItem->setX(qRound(x));
}
void QDeclarativeFlickablePrivate::setRoundedViewportY(qreal y)
{
- viewport->setY(qRound(y));
+ contentItem->setY(qRound(y));
}
void QDeclarativeFlickable::timerEvent(QTimerEvent *event)
@@ -991,13 +1009,13 @@ void QDeclarativeFlickable::geometryChanged(const QRectF &newGeometry,
bool changed = false;
if (newGeometry.width() != oldGeometry.width()) {
if (d->hData.viewSize < 0) {
- d->viewport->setWidth(width());
+ d->contentItem->setWidth(width());
emit contentWidthChanged();
}
}
if (newGeometry.height() != oldGeometry.height()) {
if (d->vData.viewSize < 0) {
- d->viewport->setHeight(height());
+ d->contentItem->setHeight(height());
emit contentHeightChanged();
}
}
@@ -1018,7 +1036,7 @@ void QDeclarativeFlickablePrivate::data_append(QDeclarativeListProperty<QObject>
{
QDeclarativeItem *i = qobject_cast<QDeclarativeItem *>(o);
if (i)
- i->setParentItem(static_cast<QDeclarativeFlickablePrivate*>(prop->data)->viewport);
+ i->setParentItem(static_cast<QDeclarativeFlickablePrivate*>(prop->data)->contentItem);
else
o->setParent(prop->object);
}
@@ -1032,7 +1050,7 @@ QDeclarativeListProperty<QObject> QDeclarativeFlickable::flickableData()
QDeclarativeListProperty<QGraphicsObject> QDeclarativeFlickable::flickableChildren()
{
Q_D(QDeclarativeFlickable);
- return QGraphicsItemPrivate::get(d->viewport)->childrenList();
+ return QGraphicsItemPrivate::get(d->contentItem)->childrenList();
}
/*!
@@ -1102,9 +1120,9 @@ void QDeclarativeFlickable::setContentWidth(qreal w)
return;
d->hData.viewSize = w;
if (w < 0)
- d->viewport->setWidth(width());
+ d->contentItem->setWidth(width());
else
- d->viewport->setWidth(w);
+ d->contentItem->setWidth(w);
// Make sure that we're entirely in view.
if (!d->pressed && !d->movingHorizontally && !d->movingVertically) {
int oldDuration = d->fixupDuration;
@@ -1129,9 +1147,9 @@ void QDeclarativeFlickable::setContentHeight(qreal h)
return;
d->vData.viewSize = h;
if (h < 0)
- d->viewport->setHeight(height());
+ d->contentItem->setHeight(height());
else
- d->viewport->setHeight(h);
+ d->contentItem->setHeight(h);
// Make sure that we're entirely in view.
if (!d->pressed && !d->movingHorizontally && !d->movingVertically) {
int oldDuration = d->fixupDuration;
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p.h
index d40a0dc..eb738d9 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeflickable_p.h
@@ -60,6 +60,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeFlickable : public QDeclarativeItem
Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged)
Q_PROPERTY(qreal contentX READ contentX WRITE setContentX NOTIFY contentXChanged)
Q_PROPERTY(qreal contentY READ contentY WRITE setContentY NOTIFY contentYChanged)
+ Q_PROPERTY(QDeclarativeItem *contentItem READ contentItem CONSTANT)
Q_PROPERTY(qreal horizontalVelocity READ horizontalVelocity NOTIFY horizontalVelocityChanged)
Q_PROPERTY(qreal verticalVelocity READ verticalVelocity NOTIFY verticalVelocityChanged)
@@ -111,10 +112,10 @@ public:
void setContentHeight(qreal);
qreal contentX() const;
- void setContentX(qreal pos);
+ virtual void setContentX(qreal pos);
qreal contentY() const;
- void setContentY(qreal pos);
+ virtual void setContentY(qreal pos);
bool isMoving() const;
bool isMovingHorizontally() const;
@@ -143,7 +144,7 @@ public:
bool isAtYEnd() const;
bool isAtYBeginning() const;
- QDeclarativeItem *viewport();
+ QDeclarativeItem *contentItem();
enum FlickableDirection { AutoFlickDirection=0x00, HorizontalFlick=0x01, VerticalFlick=0x02, HorizontalAndVerticalFlick=0x03 };
FlickableDirection flickDirection() const; // deprecated
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
index 66d2678..b919e1b 100644
--- a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h
@@ -125,7 +125,7 @@ public:
void itemGeometryChanged(QDeclarativeItem *, const QRectF &, const QRectF &);
public:
- QDeclarativeItem *viewport;
+ QDeclarativeItem *contentItem;
AxisData hData;
AxisData vData;
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index 3792595..dda1efb 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -151,9 +151,9 @@ public:
void setPosition(qreal pos) {
Q_Q(QDeclarativeGridView);
if (flow == QDeclarativeGridView::LeftToRight)
- q->setContentY(pos);
+ q->QDeclarativeFlickable::setContentY(pos);
else
- q->setContentX(pos);
+ q->QDeclarativeFlickable::setContentX(pos);
}
int size() const {
Q_Q(const QDeclarativeGridView);
@@ -421,10 +421,10 @@ FxGridItem *QDeclarativeGridViewPrivate::createItem(int modelIndex)
if (model->completePending()) {
// complete
listItem->item->setZValue(1);
- listItem->item->setParentItem(q->viewport());
+ listItem->item->setParentItem(q->contentItem());
model->completeItem();
} else {
- listItem->item->setParentItem(q->viewport());
+ listItem->item->setParentItem(q->contentItem());
}
unrequestedItems.remove(listItem->item);
}
@@ -716,12 +716,12 @@ void QDeclarativeGridViewPrivate::createHighlight()
}
} else {
item = new QDeclarativeItem;
- QDeclarative_setParent_noEvent(item, q->viewport());
- item->setParentItem(q->viewport());
+ QDeclarative_setParent_noEvent(item, q->contentItem());
+ item->setParentItem(q->contentItem());
}
if (item) {
- QDeclarative_setParent_noEvent(item, q->viewport());
- item->setParentItem(q->viewport());
+ QDeclarative_setParent_noEvent(item, q->contentItem());
+ item->setParentItem(q->contentItem());
highlight = new FxGridItem(item, q);
highlightXAnimator = new QSmoothedAnimation(q);
highlightXAnimator->target = QDeclarativeProperty(highlight->item, QLatin1String("x"));
@@ -808,8 +808,8 @@ void QDeclarativeGridViewPrivate::updateFooter()
delete context;
}
if (item) {
- QDeclarative_setParent_noEvent(item, q->viewport());
- item->setParentItem(q->viewport());
+ QDeclarative_setParent_noEvent(item, q->contentItem());
+ item->setParentItem(q->contentItem());
item->setZValue(1);
QDeclarativeItemPrivate *itemPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(item));
itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
@@ -854,8 +854,8 @@ void QDeclarativeGridViewPrivate::updateHeader()
delete context;
}
if (item) {
- QDeclarative_setParent_noEvent(item, q->viewport());
- item->setParentItem(q->viewport());
+ QDeclarative_setParent_noEvent(item, q->contentItem());
+ item->setParentItem(q->contentItem());
item->setZValue(1);
QDeclarativeItemPrivate *itemPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(item));
itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
@@ -1742,6 +1742,22 @@ void QDeclarativeGridView::setHeader(QDeclarativeComponent *header)
}
}
+void QDeclarativeGridView::setContentX(qreal pos)
+{
+ Q_D(QDeclarativeGridView);
+ // Positioning the view manually should override any current movement state
+ d->moveReason = QDeclarativeGridViewPrivate::Other;
+ QDeclarativeFlickable::setContentX(pos);
+}
+
+void QDeclarativeGridView::setContentY(qreal pos)
+{
+ Q_D(QDeclarativeGridView);
+ // Positioning the view manually should override any current movement state
+ d->moveReason = QDeclarativeGridViewPrivate::Other;
+ QDeclarativeFlickable::setContentY(pos);
+}
+
bool QDeclarativeGridView::event(QEvent *event)
{
Q_D(QDeclarativeGridView);
@@ -1919,6 +1935,8 @@ void QDeclarativeGridView::keyPressEvent(QKeyEvent *event)
Move the currentIndex up one item in the view.
The current index will wrap if keyNavigationWraps is true and it
is currently at the end.
+
+ \bold Note: methods should only be called after the Component has completed.
*/
void QDeclarativeGridView::moveCurrentIndexUp()
{
@@ -1942,6 +1960,8 @@ void QDeclarativeGridView::moveCurrentIndexUp()
Move the currentIndex down one item in the view.
The current index will wrap if keyNavigationWraps is true and it
is currently at the end.
+
+ \bold Note: methods should only be called after the Component has completed.
*/
void QDeclarativeGridView::moveCurrentIndexDown()
{
@@ -1965,6 +1985,8 @@ void QDeclarativeGridView::moveCurrentIndexDown()
Move the currentIndex left one item in the view.
The current index will wrap if keyNavigationWraps is true and it
is currently at the end.
+
+ \bold Note: methods should only be called after the Component has completed.
*/
void QDeclarativeGridView::moveCurrentIndexLeft()
{
@@ -1988,6 +2010,8 @@ void QDeclarativeGridView::moveCurrentIndexLeft()
Move the currentIndex right one item in the view.
The current index will wrap if keyNavigationWraps is true and it
is currently at the end.
+
+ \bold Note: methods should only be called after the Component has completed.
*/
void QDeclarativeGridView::moveCurrentIndexRight()
{
@@ -2028,6 +2052,14 @@ void QDeclarativeGridView::moveCurrentIndexRight()
at a particular index. This is unreliable since removing items from the start
of the view does not cause all other items to be repositioned.
The correct way to bring an item into view is with \c positionViewAtIndex.
+
+ \bold Note: methods should only be called after the Component has completed. To position
+ the view at startup, this method should be called by Component.onCompleted. For
+ example, to position the view at the end:
+
+ \code
+ Component.onCompleted: positionViewAtIndex(count - 1, GridView.Beginning)
+ \endcode
*/
void QDeclarativeGridView::positionViewAtIndex(int index, int mode)
{
@@ -2037,6 +2069,8 @@ void QDeclarativeGridView::positionViewAtIndex(int index, int mode)
if (mode < Beginning || mode > Contain)
return;
+ if (d->layoutScheduled)
+ d->layout();
qreal pos = d->position();
FxGridItem *item = d->visibleItem(index);
if (!item) {
@@ -2079,6 +2113,8 @@ void QDeclarativeGridView::positionViewAtIndex(int index, int mode)
pos = qMin(pos, maxExtent);
qreal minExtent = d->flow == QDeclarativeGridView::LeftToRight ? -minYExtent() : -minXExtent();
pos = qMax(pos, minExtent);
+ d->moveReason = QDeclarativeGridViewPrivate::Other;
+ cancelFlick();
d->setPosition(pos);
}
d->fixupPosition();
@@ -2093,6 +2129,8 @@ void QDeclarativeGridView::positionViewAtIndex(int index, int mode)
If the item is outside the visible area, -1 is returned, regardless of
whether an item will exist at that point when scrolled into view.
+
+ \bold Note: methods should only be called after the Component has completed.
*/
int QDeclarativeGridView::indexAt(int x, int y) const
{
@@ -2113,10 +2151,16 @@ void QDeclarativeGridView::componentComplete()
d->updateGrid();
if (d->isValid()) {
refill();
+ d->moveReason = QDeclarativeGridViewPrivate::SetIndex;
if (d->currentIndex < 0)
d->updateCurrent(0);
else
d->updateCurrent(d->currentIndex);
+ if (d->highlight) {
+ d->highlight->setPosition(d->currentItem->colPos(), d->currentItem->rowPos());
+ d->updateTrackedItem();
+ }
+ d->moveReason = QDeclarativeGridViewPrivate::Other;
d->fixupPosition();
}
}
diff --git a/src/declarative/graphicsitems/qdeclarativegridview_p.h b/src/declarative/graphicsitems/qdeclarativegridview_p.h
index 021aad9..64b91d8 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativegridview_p.h
@@ -151,6 +151,9 @@ public:
QDeclarativeComponent *header() const;
void setHeader(QDeclarativeComponent *);
+ virtual void setContentX(qreal pos);
+ virtual void setContentY(qreal pos);
+
enum PositionMode { Beginning, Center, End, Visible, Contain };
Q_INVOKABLE void positionViewAtIndex(int index, int mode);
diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp
index ec08517..ff61302 100644
--- a/src/declarative/graphicsitems/qdeclarativeimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp
@@ -199,6 +199,7 @@ void QDeclarativeImagePrivate::setPixmap(const QPixmap &pixmap)
fillMode: Image.PreserveAspectCrop
smooth: true
source: "qtlogo.png"
+ clip: true
}
\endqml
@@ -220,6 +221,7 @@ void QDeclarativeImagePrivate::setPixmap(const QPixmap &pixmap)
Image {
width: 120; height: 120
fillMode: Image.TileVertically
+ smooth: true
source: "qtlogo.png"
}
\endqml
@@ -231,11 +233,14 @@ void QDeclarativeImagePrivate::setPixmap(const QPixmap &pixmap)
Image {
width: 120; height: 120
fillMode: Image.TileHorizontally
+ smooth: true
source: "qtlogo.png"
}
\endqml
\endtable
+
+ \sa {declarative/imageelements/image}{Image example}
*/
QDeclarativeImage::FillMode QDeclarativeImage::fillMode() const
{
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index 06a3239..a69fc3f 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -105,7 +105,7 @@ public:
else
return (view->orientation() == QDeclarativeListView::Vertical ? item->y() : item->x());
}
- int size() const {
+ qreal size() const {
if (section)
return (view->orientation() == QDeclarativeListView::Vertical ? item->height()+section->height() : item->width()+section->height());
else
@@ -216,9 +216,9 @@ public:
void setPosition(qreal pos) {
Q_Q(QDeclarativeListView);
if (orient == QDeclarativeListView::Vertical)
- q->setContentY(pos);
+ q->QDeclarativeFlickable::setContentY(pos);
else
- q->setContentX(pos);
+ q->QDeclarativeFlickable::setContentX(pos);
}
qreal size() const {
Q_Q(const QDeclarativeListView);
@@ -421,7 +421,7 @@ public:
void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry) {
Q_Q(QDeclarativeListView);
QDeclarativeFlickablePrivate::itemGeometryChanged(item, newGeometry, oldGeometry);
- if (item != viewport && (!highlight || item != highlight->item)) {
+ if (item != contentItem && (!highlight || item != highlight->item)) {
if ((orient == QDeclarativeListView::Vertical && newGeometry.height() != oldGeometry.height())
|| (orient == QDeclarativeListView::Horizontal && newGeometry.width() != oldGeometry.width())) {
scheduleLayout();
@@ -476,7 +476,7 @@ public:
QHash<QDeclarativeItem*,int> unrequestedItems;
FxListItem *currentItem;
QDeclarativeListView::Orientation orient;
- int visiblePos;
+ qreal visiblePos;
int visibleIndex;
qreal averageSize;
int currentIndex;
@@ -580,10 +580,10 @@ FxListItem *QDeclarativeListViewPrivate::createItem(int modelIndex)
if (model->completePending()) {
// complete
listItem->item->setZValue(1);
- listItem->item->setParentItem(q->viewport());
+ listItem->item->setParentItem(q->contentItem());
model->completeItem();
} else {
- listItem->item->setParentItem(q->viewport());
+ listItem->item->setParentItem(q->contentItem());
}
QDeclarativeItemPrivate *itemPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(item));
itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
@@ -655,7 +655,7 @@ void QDeclarativeListViewPrivate::refill(qreal from, qreal to, bool doBuffer)
bool changed = false;
FxListItem *item = 0;
- int pos = itemEnd + 1;
+ qreal pos = itemEnd + 1;
while (modelIndex < model->count() && pos <= fillTo) {
// qDebug() << "refill: append item" << modelIndex << "pos" << pos;
if (!(item = createItem(modelIndex)))
@@ -744,8 +744,8 @@ void QDeclarativeListViewPrivate::layout()
}
updateSections();
if (!visibleItems.isEmpty()) {
- int oldEnd = visibleItems.last()->endPosition();
- int pos = visibleItems.first()->endPosition() + spacing + 1;
+ qreal oldEnd = visibleItems.last()->endPosition();
+ qreal pos = visibleItems.first()->endPosition() + spacing + 1;
for (int i=1; i < visibleItems.count(); ++i) {
FxListItem *item = visibleItems.at(i);
item->setPosition(pos);
@@ -840,8 +840,8 @@ void QDeclarativeListViewPrivate::createHighlight()
item = new QDeclarativeItem;
}
if (item) {
- QDeclarative_setParent_noEvent(item, q->viewport());
- item->setParentItem(q->viewport());
+ QDeclarative_setParent_noEvent(item, q->contentItem());
+ item->setParentItem(q->contentItem());
highlight = new FxListItem(item, q);
if (currentItem && autoHighlight) {
if (orient == QDeclarativeListView::Vertical) {
@@ -921,8 +921,8 @@ void QDeclarativeListViewPrivate::createSection(FxListItem *listItem)
delete nobj;
} else {
listItem->section->setZValue(1);
- QDeclarative_setParent_noEvent(listItem->section, q->viewport());
- listItem->section->setParentItem(q->viewport());
+ QDeclarative_setParent_noEvent(listItem->section, q->contentItem());
+ listItem->section->setParentItem(q->contentItem());
}
} else {
delete context;
@@ -1027,7 +1027,7 @@ void QDeclarativeListViewPrivate::updateAverage()
qreal sum = 0.0;
for (int i = 0; i < visibleItems.count(); ++i)
sum += visibleItems.at(i)->size();
- averageSize = sum / visibleItems.count();
+ averageSize = qRound(sum / visibleItems.count());
}
void QDeclarativeListViewPrivate::updateFooter()
@@ -1046,8 +1046,8 @@ void QDeclarativeListViewPrivate::updateFooter()
delete context;
}
if (item) {
- QDeclarative_setParent_noEvent(item, q->viewport());
- item->setParentItem(q->viewport());
+ QDeclarative_setParent_noEvent(item, q->contentItem());
+ item->setParentItem(q->contentItem());
item->setZValue(1);
QDeclarativeItemPrivate *itemPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(item));
itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
@@ -1086,8 +1086,8 @@ void QDeclarativeListViewPrivate::updateHeader()
delete context;
}
if (item) {
- QDeclarative_setParent_noEvent(item, q->viewport());
- item->setParentItem(q->viewport());
+ QDeclarative_setParent_noEvent(item, q->contentItem());
+ item->setParentItem(q->contentItem());
item->setZValue(1);
QDeclarativeItemPrivate *itemPrivate = static_cast<QDeclarativeItemPrivate*>(QGraphicsItemPrivate::get(item));
itemPrivate->addItemChangeListener(this, QDeclarativeItemPrivate::Geometry);
@@ -1547,9 +1547,12 @@ void QDeclarativeListView::setModel(const QVariant &model)
that is not needed for the normal display of the delegate in a \l Loader which
can load additional elements when needed.
- Tthe ListView will lay out the items based on the size of the root item
+ The ListView will lay out the items based on the size of the root item
in the delegate.
+ It is recommended that the delagate's size be a whole number to avoid sub-pixel
+ alignment of items.
+
\note Delegates are instantiated as needed and may be destroyed at any time.
State should \e never be stored in a delegate.
*/
@@ -2182,6 +2185,22 @@ void QDeclarativeListView::setHeader(QDeclarativeComponent *header)
}
}
+void QDeclarativeListView::setContentX(qreal pos)
+{
+ Q_D(QDeclarativeListView);
+ // Positioning the view manually should override any current movement state
+ d->moveReason = QDeclarativeListViewPrivate::Other;
+ QDeclarativeFlickable::setContentX(pos);
+}
+
+void QDeclarativeListView::setContentY(qreal pos)
+{
+ Q_D(QDeclarativeListView);
+ // Positioning the view manually should override any current movement state
+ d->moveReason = QDeclarativeListViewPrivate::Other;
+ QDeclarativeFlickable::setContentY(pos);
+}
+
bool QDeclarativeListView::event(QEvent *event)
{
Q_D(QDeclarativeListView);
@@ -2386,6 +2405,8 @@ void QDeclarativeListView::keyPressEvent(QKeyEvent *event)
Increments the current index. The current index will wrap
if keyNavigationWraps is true and it is currently at the end.
+
+ \bold Note: methods should only be called after the Component has completed.
*/
void QDeclarativeListView::incrementCurrentIndex()
{
@@ -2403,6 +2424,8 @@ void QDeclarativeListView::incrementCurrentIndex()
Decrements the current index. The current index will wrap
if keyNavigationWraps is true and it is currently at the beginning.
+
+ \bold Note: methods should only be called after the Component has completed.
*/
void QDeclarativeListView::decrementCurrentIndex()
{
@@ -2439,6 +2462,14 @@ void QDeclarativeListView::decrementCurrentIndex()
of the list does not cause all other items to be repositioned, and because
the actual start of the view can vary based on the size of the delegates.
The correct way to bring an item into view is with \c positionViewAtIndex.
+
+ \bold Note: methods should only be called after the Component has completed. To position
+ the view at startup, this method should be called by Component.onCompleted. For
+ example, to position the view at the end:
+
+ \code
+ Component.onCompleted: positionViewAtIndex(count - 1, ListView.Beginning)
+ \endcode
*/
void QDeclarativeListView::positionViewAtIndex(int index, int mode)
{
@@ -2448,6 +2479,8 @@ void QDeclarativeListView::positionViewAtIndex(int index, int mode)
if (mode < Beginning || mode > Contain)
return;
+ if (d->layoutScheduled)
+ d->layout();
qreal pos = d->position();
FxListItem *item = d->visibleItem(index);
if (!item) {
@@ -2491,6 +2524,8 @@ void QDeclarativeListView::positionViewAtIndex(int index, int mode)
pos = qMin(pos, maxExtent);
qreal minExtent = d->orient == QDeclarativeListView::Vertical ? -minYExtent() : -minXExtent();
pos = qMax(pos, minExtent);
+ d->moveReason = QDeclarativeListViewPrivate::Other;
+ cancelFlick();
d->setPosition(pos);
}
d->fixupPosition();
@@ -2505,6 +2540,8 @@ void QDeclarativeListView::positionViewAtIndex(int index, int mode)
If the item is outside the visible area, -1 is returned, regardless of
whether an item will exist at that point when scrolled into view.
+
+ \bold Note: methods should only be called after the Component has completed.
*/
int QDeclarativeListView::indexAt(int x, int y) const
{
@@ -2529,6 +2566,11 @@ void QDeclarativeListView::componentComplete()
d->updateCurrent(0);
else
d->updateCurrent(d->currentIndex);
+ if (d->highlight) {
+ d->highlight->setPosition(d->currentItem->position());
+ d->updateTrackedItem();
+ }
+ d->moveReason = QDeclarativeListViewPrivate::Other;
d->fixupPosition();
}
}
@@ -2961,7 +3003,7 @@ void QDeclarativeListView::createdItem(int index, QDeclarativeItem *item)
{
Q_D(QDeclarativeListView);
if (d->requestedIndex != index) {
- item->setParentItem(viewport());
+ item->setParentItem(contentItem());
d->unrequestedItems.insert(item, index);
if (d->orient == QDeclarativeListView::Vertical)
item->setY(d->positionAt(index));
diff --git a/src/declarative/graphicsitems/qdeclarativelistview_p.h b/src/declarative/graphicsitems/qdeclarativelistview_p.h
index d6e8023..505f659 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview_p.h
+++ b/src/declarative/graphicsitems/qdeclarativelistview_p.h
@@ -198,6 +198,9 @@ public:
QDeclarativeComponent *header() const;
void setHeader(QDeclarativeComponent *);
+ virtual void setContentX(qreal pos);
+ virtual void setContentY(qreal pos);
+
static QDeclarativeListViewAttached *qmlAttachedProperties(QObject *);
enum PositionMode { Beginning, Center, End, Visible, Contain };
diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp
index 25b1119..c8c9e44 100644
--- a/src/declarative/graphicsitems/qdeclarativeloader.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp
@@ -174,7 +174,7 @@ void QDeclarativeLoaderPrivate::initResize()
QDeclarativeLoader::QDeclarativeLoader(QDeclarativeItem *parent)
: QDeclarativeItem(*(new QDeclarativeLoaderPrivate), parent)
{
- Q_D(QDeclarativeItem);
+ Q_D(QDeclarativeLoader);
d->flags |= QGraphicsItem::ItemIsFocusScope;
}
@@ -183,6 +183,14 @@ QDeclarativeLoader::QDeclarativeLoader(QDeclarativeItem *parent)
*/
QDeclarativeLoader::~QDeclarativeLoader()
{
+ Q_D(QDeclarativeLoader);
+ if (d->item) {
+ if (QDeclarativeItem *qmlItem = qobject_cast<QDeclarativeItem*>(d->item)) {
+ QDeclarativeItemPrivate *p =
+ static_cast<QDeclarativeItemPrivate *>(QGraphicsItemPrivate::get(qmlItem));
+ p->removeItemChangeListener(d, QDeclarativeItemPrivate::Geometry);
+ }
+ }
}
/*!
diff --git a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp
index 13d1b61..3b9b8df 100644
--- a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp
@@ -151,6 +151,7 @@ void QDeclarativePaintedItem::setContentsSize(const QSize &size)
{
Q_D(QDeclarativePaintedItem);
if (d->contentsSize == size) return;
+ prepareGeometryChange();
d->contentsSize = size;
clearCache();
update();
@@ -247,8 +248,7 @@ QRectF QDeclarativePaintedItem::boundingRect() const
void QDeclarativePaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
{
Q_D(QDeclarativePaintedItem);
- const QRect content(0,0,qCeil(d->contentsSize.width()*d->contentsScale),
- qCeil(d->contentsSize.height()*d->contentsScale));
+ const QRect content = boundingRect().toRect();
if (content.width() <= 0 || content.height() <= 0)
return;
diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp
index 0c2d249..0e980b3 100644
--- a/src/declarative/graphicsitems/qdeclarativepathview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp
@@ -552,6 +552,8 @@ void QDeclarativePathView::setCurrentIndex(int idx)
\qmlmethod PathView::incrementCurrentIndex()
Increments the current index.
+
+ \bold Note: methods should only be called after the Component has completed.
*/
void QDeclarativePathView::incrementCurrentIndex()
{
@@ -563,6 +565,8 @@ void QDeclarativePathView::incrementCurrentIndex()
\qmlmethod PathView::decrementCurrentIndex()
Decrements the current index.
+
+ \bold Note: methods should only be called after the Component has completed.
*/
void QDeclarativePathView::decrementCurrentIndex()
{
diff --git a/src/declarative/graphicsitems/qdeclarativerectangle.cpp b/src/declarative/graphicsitems/qdeclarativerectangle.cpp
index 2756877..c49be46 100644
--- a/src/declarative/graphicsitems/qdeclarativerectangle.cpp
+++ b/src/declarative/graphicsitems/qdeclarativerectangle.cpp
@@ -446,6 +446,7 @@ void QDeclarativeRectangle::drawRect(QPainter &p)
p.setRenderHint(QPainter::Antialiasing);
if (d->pen && d->pen->isValid()) {
QPen pn(QColor(d->pen->color()), d->pen->width());
+ pn.setJoinStyle(Qt::MiterJoin);
p.setPen(pn);
} else {
p.setPen(Qt::NoPen);
diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp
index c2e0d67..2ba680d 100644
--- a/src/declarative/graphicsitems/qdeclarativetext.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetext.cpp
@@ -663,6 +663,71 @@ void QDeclarativeText::setElideMode(QDeclarativeText::TextElideMode mode)
emit elideModeChanged(d->elideMode);
}
+QRectF QDeclarativeText::boundingRect() const
+{
+ Q_D(const QDeclarativeText);
+
+ int w = width();
+ int h = height();
+
+ int x = 0;
+ int y = 0;
+
+ if (d->cache || d->style != Normal) {
+ switch (d->hAlign) {
+ case AlignLeft:
+ x = 0;
+ break;
+ case AlignRight:
+ x = w - d->imgCache.width();
+ break;
+ case AlignHCenter:
+ x = (w - d->imgCache.width()) / 2;
+ break;
+ }
+
+ switch (d->vAlign) {
+ case AlignTop:
+ y = 0;
+ break;
+ case AlignBottom:
+ y = h - d->imgCache.height();
+ break;
+ case AlignVCenter:
+ y = (h - d->imgCache.height()) / 2;
+ break;
+ }
+
+ return QRectF(x,y,d->imgCache.width(),d->imgCache.height());
+ } else {
+ switch (d->hAlign) {
+ case AlignLeft:
+ x = 0;
+ break;
+ case AlignRight:
+ x = w - d->cachedLayoutSize.width();
+ break;
+ case AlignHCenter:
+ x = (w - d->cachedLayoutSize.width()) / 2;
+ break;
+ }
+
+ switch (d->vAlign) {
+ case AlignTop:
+ y = 0;
+ break;
+ case AlignBottom:
+ y = h - d->cachedLayoutSize.height();
+ break;
+ case AlignVCenter:
+ y = (h - d->cachedLayoutSize.height()) / 2;
+ break;
+ }
+
+ return QRectF(x,y,d->cachedLayoutSize.width(),d->cachedLayoutSize.height());
+ }
+}
+
void QDeclarativeText::geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry)
{
@@ -713,6 +778,7 @@ void QDeclarativeTextPrivate::updateLayout()
}
}
+
void QDeclarativeTextPrivate::updateSize()
{
Q_Q(QDeclarativeText);
@@ -730,7 +796,10 @@ void QDeclarativeTextPrivate::updateSize()
//setup instance of QTextLayout for all cases other than richtext
if (!richText) {
size = setupTextLayout(&layout);
- cachedLayoutSize = size;
+ if (cachedLayoutSize != size) {
+ q->prepareGeometryChange();
+ cachedLayoutSize = size;
+ }
dy -= size.height();
} else {
singleline = false; // richtext can't elide or be optimized for single-line case
@@ -744,7 +813,13 @@ void QDeclarativeTextPrivate::updateSize()
else
doc->setTextWidth(doc->idealWidth()); // ### Text does not align if width is not set (QTextDoc bug)
dy -= (int)doc->size().height();
- cachedLayoutSize = doc->size().toSize();
+ q->prepareGeometryChange();
+ QSize dsize = doc->size().toSize();
+ if (dsize != cachedLayoutSize) {
+ q->prepareGeometryChange();
+ cachedLayoutSize = dsize;
+ }
+ size = QSize(int(doc->idealWidth()),dsize.height());
}
int yoff = 0;
@@ -757,8 +832,8 @@ void QDeclarativeTextPrivate::updateSize()
q->setBaselineOffset(fm.ascent() + yoff);
//### need to comfirm cost of always setting these for richText
- q->setImplicitWidth(richText ? (int)doc->idealWidth() : size.width());
- q->setImplicitHeight(richText ? (int)doc->size().height() : size.height());
+ q->setImplicitWidth(size.width());
+ q->setImplicitHeight(size.height());
emit q->paintedSizeChanged();
} else {
dirty = true;
@@ -813,6 +888,8 @@ void QDeclarativeTextPrivate::drawOutline()
ppm.drawPixmap(pos, imgCache);
ppm.end();
+ if (imgCache.size() != img.size())
+ q_func()->prepareGeometryChange();
imgCache = img;
}
@@ -831,6 +908,8 @@ void QDeclarativeTextPrivate::drawOutline(int yOffset)
ppm.drawPixmap(pos, imgCache);
ppm.end();
+ if (imgCache.size() != img.size())
+ q_func()->prepareGeometryChange();
imgCache = img;
}
@@ -955,18 +1034,21 @@ void QDeclarativeTextPrivate::checkImgCache()
return;
bool empty = text.isEmpty();
+ QPixmap newImgCache;
if (empty) {
- imgCache = QPixmap();
imgStyleCache = QPixmap();
} else if (richText) {
- imgCache = richTextImage(false);
+ newImgCache = richTextImage(false);
if (style != QDeclarativeText::Normal)
imgStyleCache = richTextImage(true); //### should use styleColor
} else {
- imgCache = wrappedTextImage(false);
+ newImgCache = wrappedTextImage(false);
if (style != QDeclarativeText::Normal)
imgStyleCache = wrappedTextImage(true); //### should use styleColor
}
+ if (imgCache.size() != newImgCache.size())
+ q_func()->prepareGeometryChange();
+ imgCache = newImgCache;
if (!empty)
switch (style) {
case QDeclarativeText::Outline:
@@ -1031,35 +1113,7 @@ void QDeclarativeText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWid
if (d->smooth)
p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
- int w = width();
- int h = height();
-
- int x = 0;
- int y = 0;
-
- switch (d->hAlign) {
- case AlignLeft:
- x = 0;
- break;
- case AlignRight:
- x = w - d->imgCache.width();
- break;
- case AlignHCenter:
- x = (w - d->imgCache.width()) / 2;
- break;
- }
-
- switch (d->vAlign) {
- case AlignTop:
- y = 0;
- break;
- case AlignBottom:
- y = h - d->imgCache.height();
- break;
- case AlignVCenter:
- y = (h - d->imgCache.height()) / 2;
- break;
- }
+ QRect br = boundingRect().toRect();
bool needClip = clip() && (d->imgCache.width() > width() ||
d->imgCache.height() > height());
@@ -1068,7 +1122,7 @@ void QDeclarativeText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWid
p->save();
p->setClipRect(boundingRect(), Qt::IntersectClip);
}
- p->drawPixmap(x, y, d->imgCache);
+ p->drawPixmap(br.x(), br.y(), d->imgCache);
if (needClip)
p->restore();
@@ -1077,20 +1131,8 @@ void QDeclarativeText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWid
p->setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth);
}
} else {
- int h = height();
- int y = 0;
+ qreal y = boundingRect().y();
- switch (d->vAlign) {
- case AlignTop:
- y = 0;
- break;
- case AlignBottom:
- y = h - d->cachedLayoutSize.height();
- break;
- case AlignVCenter:
- y = (h - d->cachedLayoutSize.height()) / 2;
- break;
- }
bool needClip = !clip() && (d->cachedLayoutSize.width() > width() ||
d->cachedLayoutSize.height() > height());
diff --git a/src/declarative/graphicsitems/qdeclarativetext_p.h b/src/declarative/graphicsitems/qdeclarativetext_p.h
index db21140..cd97df3 100644
--- a/src/declarative/graphicsitems/qdeclarativetext_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetext_p.h
@@ -143,6 +143,8 @@ public:
qreal paintedWidth() const;
qreal paintedHeight() const;
+ QRectF boundingRect() const;
+
Q_SIGNALS:
void textChanged(const QString &text);
void linkActivated(const QString &link);
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
index 3106daf..7db21f2 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp
+++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp
@@ -1231,8 +1231,13 @@ void QDeclarativeTextEdit::updateImgCache(const QRectF &rf)
r = QRect(0,0,INT_MAX,INT_MAX);
} else {
r = rf.toRect();
- if (r != QRect(0,0,INT_MAX,INT_MAX)) // Don't translate "everything"
+ if (r.height() > INT_MAX/2) {
+ // Take care of overflow when translating "everything"
+ r.setTop(r.y() + d->yoff);
+ r.setBottom(INT_MAX/2);
+ } else {
r = r.translated(0,d->yoff);
+ }
}
dirtyCache(r);
emit update();
@@ -1327,6 +1332,14 @@ void QDeclarativeTextEdit::updateSelectionMarkers()
}
}
+QRectF QDeclarativeTextEdit::boundingRect() const
+{
+ Q_D(const QDeclarativeTextEdit);
+ QRectF r = QDeclarativePaintedItem::boundingRect();
+ return r.translated(0,d->yoff);
+}
+
+
//### we should perhaps be a bit smarter here -- depending on what has changed, we shouldn't
// need to do all the calculations each time
void QDeclarativeTextEdit::updateSize()
@@ -1341,13 +1354,20 @@ void QDeclarativeTextEdit::updateSize()
d->document->setTextWidth(width());
dy -= (int)d->document->size().height();
+ int nyoff;
if (heightValid()) {
if (d->vAlign == AlignBottom)
- d->yoff = dy;
+ nyoff = dy;
else if (d->vAlign == AlignVCenter)
- d->yoff = dy/2;
+ nyoff = dy/2;
+ else
+ nyoff = 0;
} else {
- d->yoff = 0;
+ nyoff = 0;
+ }
+ if (nyoff != d->yoff) {
+ prepareGeometryChange();
+ d->yoff = nyoff;
}
setBaselineOffset(fm.ascent() + d->yoff + d->textMargin);
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit_p.h b/src/declarative/graphicsitems/qdeclarativetextedit_p.h
index d08f607..a6dd4a4 100644
--- a/src/declarative/graphicsitems/qdeclarativetextedit_p.h
+++ b/src/declarative/graphicsitems/qdeclarativetextedit_p.h
@@ -195,6 +195,8 @@ public:
Q_INVOKABLE int positionAt(int x, int y) const;
Q_INVOKABLE void moveCursorSelection(int pos);
+ QRectF boundingRect() const;
+
Q_SIGNALS:
void textChanged(const QString &);
void paintedSizeChanged();
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
index 5092349..8071d7a 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
@@ -283,7 +283,7 @@ public:
if (m_roles.count() == 1)
m_roleNames.insert("modelData", m_roles.at(0));
if (m_roles.count())
- m_roleNames.insert("hasModelChildren", 0);
+ m_roleNames.insert("hasModelChildren", -1);
} else if (m_listAccessor) {
m_roleNames.insert("modelData", 0);
if (m_listAccessor->type() == QDeclarativeListAccessor::Instance) {
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index 80a1093..623e3df 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -815,6 +815,10 @@ bool QDeclarativeCompiler::buildObject(Object *obj, const BindingContext &ctxt)
}
}
+ QDeclarativeCustomParser *cp = 0;
+ if (isCustomParser)
+ cp = output->types.at(obj->type).type->customParser();
+
// Build all explicit properties specified
foreach(Property *prop, obj->properties) {
@@ -825,7 +829,9 @@ bool QDeclarativeCompiler::buildObject(Object *obj, const BindingContext &ctxt)
bool canDefer = false;
if (isCustomParser) {
- if (doesPropertyExist(prop, obj)) {
+ if (doesPropertyExist(prop, obj) &&
+ (!(cp->flags() & QDeclarativeCustomParser::AcceptsAttachedProperties) ||
+ !isAttachedPropertyName(prop->name))) {
int ids = compileState.ids.count();
COMPILE_CHECK(buildProperty(prop, obj, objCtxt));
canDefer = ids == compileState.ids.count();
@@ -876,8 +882,7 @@ bool QDeclarativeCompiler::buildObject(Object *obj, const BindingContext &ctxt)
defaultProperty->release();
// Compile custom parser parts
- if (isCustomParser/* && !customProps.isEmpty()*/) {
- QDeclarativeCustomParser *cp = output->types.at(obj->type).type->customParser();
+ if (isCustomParser && !customProps.isEmpty()) {
cp->clearErrors();
cp->compiler = this;
cp->object = obj;
@@ -1356,7 +1361,7 @@ bool QDeclarativeCompiler::buildSignal(QDeclarativeParser::Property *prop, QDecl
Returns true if (value) property \a prop exists on obj, false otherwise.
*/
bool QDeclarativeCompiler::doesPropertyExist(QDeclarativeParser::Property *prop,
- QDeclarativeParser::Object *obj)
+ QDeclarativeParser::Object *obj)
{
if(isAttachedPropertyName(prop->name) || prop->name == "id")
return true;
@@ -2176,6 +2181,18 @@ int QDeclarativeCompiler::evaluateEnum(const QByteArray& script) const
return -1;
}
+const QMetaObject *QDeclarativeCompiler::resolveType(const QByteArray& name) const
+{
+ QDeclarativeType *qmltype = 0;
+ if (!enginePrivate->importDatabase.resolveType(unit->imports, name, &qmltype,
+ 0, 0, 0, 0))
+ return 0;
+ if (!qmltype)
+ return 0;
+ return qmltype->metaObject();
+}
+
+
// Ensures that the dynamic meta specification on obj is valid
bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeParser::Object *obj)
{
@@ -2199,6 +2216,10 @@ bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeParser::Object *obj)
if (QString::fromUtf8(prop.name).at(0).isUpper())
COMPILE_EXCEPTION(&prop, tr("Property names cannot begin with an upper case letter"));
+
+ if (QDeclarativeEnginePrivate::get(engine)->globalClass->illegalNames().contains(prop.name))
+ COMPILE_EXCEPTION(&prop, tr("Illegal property name"));
+
propNames.insert(prop.name);
}
@@ -2208,6 +2229,8 @@ bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeParser::Object *obj)
COMPILE_EXCEPTION(obj, tr("Duplicate signal name"));
if (QString::fromUtf8(name).at(0).isUpper())
COMPILE_EXCEPTION(obj, tr("Signal names cannot begin with an upper case letter"));
+ if (QDeclarativeEnginePrivate::get(engine)->globalClass->illegalNames().contains(name))
+ COMPILE_EXCEPTION(obj, tr("Illegal signal name"));
methodNames.insert(name);
}
for (int ii = 0; ii < obj->dynamicSlots.count(); ++ii) {
@@ -2216,6 +2239,8 @@ bool QDeclarativeCompiler::checkDynamicMeta(QDeclarativeParser::Object *obj)
COMPILE_EXCEPTION(obj, tr("Duplicate method name"));
if (QString::fromUtf8(name).at(0).isUpper())
COMPILE_EXCEPTION(obj, tr("Method names cannot begin with an upper case letter"));
+ if (QDeclarativeEnginePrivate::get(engine)->globalClass->illegalNames().contains(name))
+ COMPILE_EXCEPTION(obj, tr("Illegal method name"));
methodNames.insert(name);
}
diff --git a/src/declarative/qml/qdeclarativecompiler_p.h b/src/declarative/qml/qdeclarativecompiler_p.h
index 908c703..caad376 100644
--- a/src/declarative/qml/qdeclarativecompiler_p.h
+++ b/src/declarative/qml/qdeclarativecompiler_p.h
@@ -161,6 +161,7 @@ public:
static bool isSignalPropertyName(const QByteArray &);
int evaluateEnum(const QByteArray& script) const; // for QDeclarativeCustomParser::evaluateEnum
+ const QMetaObject *resolveType(const QByteArray& name) const; // for QDeclarativeCustomParser::resolveType
private:
static void reset(QDeclarativeCompiledData *);
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index b4919ff..9d3032c 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -572,7 +572,9 @@ QScriptValue QDeclarativeComponent::createObject(QObject* parent)
{
Q_D(QDeclarativeComponent);
QDeclarativeContext* ctxt = creationContext();
- if(!ctxt)
+ if(!ctxt && d->engine)
+ ctxt = d->engine->rootContext();
+ if (!ctxt)
return QScriptValue(QScriptValue::NullValue);
QObject* ret = create(ctxt);
if (!ret)
diff --git a/src/declarative/qml/qdeclarativecustomparser.cpp b/src/declarative/qml/qdeclarativecustomparser.cpp
index 472a883..97a6a00 100644
--- a/src/declarative/qml/qdeclarativecustomparser.cpp
+++ b/src/declarative/qml/qdeclarativecustomparser.cpp
@@ -295,4 +295,14 @@ int QDeclarativeCustomParser::evaluateEnum(const QByteArray& script) const
return compiler->evaluateEnum(script);
}
+/*!
+ Resolves \a name to a type, or 0 if it is not a type. This can be used
+ to type-check object nodes.
+*/
+const QMetaObject *QDeclarativeCustomParser::resolveType(const QByteArray& name) const
+{
+ return compiler->resolveType(name);
+}
+
+
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativecustomparser_p.h b/src/declarative/qml/qdeclarativecustomparser_p.h
index 0e397c5..509e30a 100644
--- a/src/declarative/qml/qdeclarativecustomparser_p.h
+++ b/src/declarative/qml/qdeclarativecustomparser_p.h
@@ -113,10 +113,18 @@ private:
class Q_DECLARATIVE_EXPORT QDeclarativeCustomParser
{
public:
- QDeclarativeCustomParser() : compiler(0), object(0) {}
+ enum Flag {
+ NoFlag = 0x00000000,
+ AcceptsAttachedProperties = 0x00000001
+ };
+ Q_DECLARE_FLAGS(Flags, Flag);
+
+ QDeclarativeCustomParser() : compiler(0), object(0), m_flags(NoFlag) {}
+ QDeclarativeCustomParser(Flags f) : compiler(0), object(0), m_flags(f) {}
virtual ~QDeclarativeCustomParser() {}
void clearErrors();
+ Flags flags() const { return m_flags; }
virtual QByteArray compile(const QList<QDeclarativeCustomParserProperty> &)=0;
virtual void setCustomData(QObject *, const QByteArray &)=0;
@@ -130,12 +138,16 @@ protected:
int evaluateEnum(const QByteArray&) const;
+ const QMetaObject *resolveType(const QByteArray&) const;
+
private:
QList<QDeclarativeError> exceptions;
QDeclarativeCompiler *compiler;
QDeclarativeParser::Object *object;
+ Flags m_flags;
friend class QDeclarativeCompiler;
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativeCustomParser::Flags);
#if 0
#define QML_REGISTER_CUSTOM_TYPE(URI, VERSION_MAJ, VERSION_MIN, NAME, TYPE, CUSTOMTYPE) \
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 86053c4..8b15ae9 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -1033,6 +1033,17 @@ QDeclarativeContextData *QDeclarativeEnginePrivate::getContext(QScriptContext *c
return contextClass->contextFromValue(scopeNode);
}
+/*!
+ Returns the QUrl associated with the script \a ctxt for the case that there is
+ no QDeclarativeContext.
+*/
+QUrl QDeclarativeEnginePrivate::getUrl(QScriptContext *ctxt)
+{
+ QScriptValue scopeNode = QScriptDeclarativeClass::scopeChainValue(ctxt, -3);
+ Q_ASSERT(scopeNode.isValid());
+ Q_ASSERT(QScriptDeclarativeClass::scriptClass(scopeNode) == contextClass);
+ return contextClass->urlFromValue(scopeNode);
+}
QString QDeclarativeEnginePrivate::urlToLocalFileOrQrc(const QUrl& url)
{
@@ -1075,16 +1086,19 @@ QScriptValue QDeclarativeEnginePrivate::createComponent(QScriptContext *ctxt, QS
static_cast<QDeclarativeScriptEngine*>(engine)->p;
QDeclarativeEngine* activeEngine = activeEnginePriv->q_func();
- QDeclarativeContextData* context = activeEnginePriv->getContext(ctxt);
- Q_ASSERT(context);
-
if(ctxt->argumentCount() != 1) {
return ctxt->throwError(QLatin1String("Qt.createComponent(): Invalid arguments"));
- }else{
+ } else {
+
QString arg = ctxt->argument(0).toString();
if (arg.isEmpty())
return engine->nullValue();
- QUrl url = QUrl(context->resolvedUrl(QUrl(arg)));
+ QUrl url;
+ QDeclarativeContextData* context = activeEnginePriv->getContext(ctxt);
+ if (context)
+ url = QUrl(context->resolvedUrl(QUrl(arg)));
+ else
+ url = activeEnginePriv->getUrl(ctxt).resolved(QUrl(arg));
QDeclarativeComponent *c = new QDeclarativeComponent(activeEngine, url, activeEngine);
QDeclarativeComponentPrivate::get(c)->creationContext = context;
QDeclarativeData::get(c, true)->setImplicitDestructible();
diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h
index 3269e98..cfa9d73 100644
--- a/src/declarative/qml/qdeclarativeengine_p.h
+++ b/src/declarative/qml/qdeclarativeengine_p.h
@@ -315,6 +315,7 @@ public:
static QDeclarativeEnginePrivate *get(QScriptEngine *e) { return static_cast<QDeclarativeScriptEngine*>(e)->p; }
static QDeclarativeEngine *get(QDeclarativeEnginePrivate *p) { return p->q_func(); }
QDeclarativeContextData *getContext(QScriptContext *);
+ QUrl getUrl(QScriptContext *);
static QString urlToLocalFileOrQrc(const QUrl& url);
diff --git a/src/declarative/qml/qdeclarativeglobalscriptclass.cpp b/src/declarative/qml/qdeclarativeglobalscriptclass.cpp
index 39ea101..d43443d 100644
--- a/src/declarative/qml/qdeclarativeglobalscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativeglobalscriptclass.cpp
@@ -41,6 +41,7 @@
#include "private/qdeclarativeglobalscriptclass_p.h"
+#include <QtCore/qstringlist.h>
#include <QtCore/qvector.h>
#include <QtScript/qscriptstring.h>
#include <QtScript/qscriptengine.h>
@@ -57,6 +58,7 @@ QDeclarativeGlobalScriptClass::QDeclarativeGlobalScriptClass(QScriptEngine *engi
: QScriptClass(engine)
{
QString eval = QLatin1String("eval");
+ QString version = QLatin1String("version");
QScriptValue originalGlobalObject = engine->globalObject();
@@ -72,6 +74,9 @@ QDeclarativeGlobalScriptClass::QDeclarativeGlobalScriptClass(QScriptEngine *engi
QString name = iter.name();
+ if (name == version)
+ continue;
+
if (name != eval) {
names.append(name);
values.append(iter.value());
@@ -98,18 +103,7 @@ QDeclarativeGlobalScriptClass::queryProperty(const QScriptValue &object,
Q_UNUSED(name);
Q_UNUSED(flags);
Q_UNUSED(id);
- return HandlesReadAccess | HandlesWriteAccess;
-}
-
-QScriptValue
-QDeclarativeGlobalScriptClass::property(const QScriptValue &object,
- const QScriptString &name,
- uint id)
-{
- Q_UNUSED(object);
- Q_UNUSED(name);
- Q_UNUSED(id);
- return engine()->undefinedValue();
+ return HandlesWriteAccess;
}
void QDeclarativeGlobalScriptClass::setProperty(QScriptValue &object,
@@ -125,8 +119,9 @@ void QDeclarativeGlobalScriptClass::setProperty(QScriptValue &object,
}
/* This method is for the use of tst_qdeclarativeecmascript::callQtInvokables() only */
-void QDeclarativeGlobalScriptClass::explicitSetProperty(const QString &name, const QScriptValue &value)
+void QDeclarativeGlobalScriptClass::explicitSetProperty(const QStringList &names, const QList<QScriptValue> &values)
{
+ Q_ASSERT(names.count() == values.count());
QScriptValue globalObject = engine()->globalObject();
QScriptValue v = engine()->newObject();
@@ -137,7 +132,12 @@ void QDeclarativeGlobalScriptClass::explicitSetProperty(const QString &name, con
v.setProperty(iter.scriptName(), iter.value());
}
- v.setProperty(name, value);
+ for (int ii = 0; ii < names.count(); ++ii) {
+ const QString &name = names.at(ii);
+ const QScriptValue &value = values.at(ii);
+ v.setProperty(name, value);
+ }
+
v.setScriptClass(this);
engine()->setGlobalObject(v);
diff --git a/src/declarative/qml/qdeclarativeglobalscriptclass_p.h b/src/declarative/qml/qdeclarativeglobalscriptclass_p.h
index 414bf02..b42b7bd 100644
--- a/src/declarative/qml/qdeclarativeglobalscriptclass_p.h
+++ b/src/declarative/qml/qdeclarativeglobalscriptclass_p.h
@@ -67,13 +67,10 @@ public:
const QScriptString &name,
QueryFlags flags, uint *id);
- virtual QScriptValue property(const QScriptValue &object,
- const QScriptString &name, uint id);
-
virtual void setProperty(QScriptValue &object, const QScriptString &name,
uint id, const QScriptValue &value);
- void explicitSetProperty(const QString &, const QScriptValue &);
+ void explicitSetProperty(const QStringList &, const QList<QScriptValue> &);
const QScriptValue &staticGlobalObject() const { return m_staticGlobalObject; }
diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
index aca01b2..3af892d 100644
--- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
+++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp
@@ -797,6 +797,26 @@ QScriptDeclarativeClass::Value MetaCallArgument::toValue(QDeclarativeEngine *e)
}
}
+int QDeclarativeObjectMethodScriptClass::enumType(const QMetaObject *meta, const QString &strname)
+{
+ QByteArray str = strname.toUtf8();
+ QByteArray scope;
+ QByteArray name;
+ int scopeIdx = str.lastIndexOf("::");
+ if (scopeIdx != -1) {
+ scope = str.left(scopeIdx);
+ name = str.mid(scopeIdx + 2);
+ } else {
+ name = str;
+ }
+ for (int i = meta->enumeratorCount() - 1; i >= 0; --i) {
+ QMetaEnum m = meta->enumerator(i);
+ if ((m.name() == name) && (scope.isEmpty() || (m.scope() == scope)))
+ return QVariant::Int;
+ }
+ return QVariant::Invalid;
+}
+
QDeclarativeObjectMethodScriptClass::Value QDeclarativeObjectMethodScriptClass::call(Object *o, QScriptContext *ctxt)
{
MethodData *method = static_cast<MethodData *>(o);
@@ -810,7 +830,9 @@ QDeclarativeObjectMethodScriptClass::Value QDeclarativeObjectMethodScriptClass::
// ### Cache
for (int ii = 0; ii < argTypeNames.count(); ++ii) {
argTypes[ii] = QMetaType::type(argTypeNames.at(ii));
- if (argTypes[ii] == QVariant::Invalid)
+ if (argTypes[ii] == QVariant::Invalid)
+ argTypes[ii] = enumType(method->object->metaObject(), argTypeNames.at(ii));
+ if (argTypes[ii] == QVariant::Invalid)
return Value(ctxt, ctxt->throwError(QString::fromLatin1("Unknown method parameter type: %1").arg(QLatin1String(argTypeNames.at(ii)))));
}
diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass_p.h b/src/declarative/qml/qdeclarativeobjectscriptclass_p.h
index 4b27e53..75e384c 100644
--- a/src/declarative/qml/qdeclarativeobjectscriptclass_p.h
+++ b/src/declarative/qml/qdeclarativeobjectscriptclass_p.h
@@ -80,6 +80,8 @@ protected:
virtual Value property(Object *, const Identifier &);
private:
+ int enumType(const QMetaObject *, const QString &);
+
PersistentIdentifier m_connectId;
PersistentIdentifier m_disconnectId;
QScriptValue m_connect;
diff --git a/src/declarative/qml/qdeclarativetypenamescriptclass.cpp b/src/declarative/qml/qdeclarativetypenamescriptclass.cpp
index 2a3417a..764a8db 100644
--- a/src/declarative/qml/qdeclarativetypenamescriptclass.cpp
+++ b/src/declarative/qml/qdeclarativetypenamescriptclass.cpp
@@ -107,8 +107,7 @@ QDeclarativeTypeNameScriptClass::queryProperty(Object *obj, const Identifier &na
return 0;
}
- } else {
- Q_ASSERT(data->type);
+ } else if (data->type) {
QString strName = toString(name);
@@ -134,6 +133,7 @@ QDeclarativeTypeNameScriptClass::queryProperty(Object *obj, const Identifier &na
if (!object) return 0;
return ep->objectClass->queryProperty(object, name, flags, 0);
}
+
}
return 0;
diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp
index f807866..add27f3 100644
--- a/src/declarative/util/qdeclarativeanimation.cpp
+++ b/src/declarative/util/qdeclarativeanimation.cpp
@@ -176,6 +176,8 @@ void QDeclarativeAbstractAnimation::setRunning(bool r)
{
Q_D(QDeclarativeAbstractAnimation);
if (!d->componentComplete) {
+ if (d->running && r == d->running) //don't re-register
+ return;
d->running = r;
if (r == false)
d->avoidPropertyValueSourceStart = true;
diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp
index 9ed21a6..deb835d 100644
--- a/src/declarative/util/qdeclarativelistmodel.cpp
+++ b/src/declarative/util/qdeclarativelistmodel.cpp
@@ -551,9 +551,13 @@ bool QDeclarativeListModelParser::compileProperty(const QDeclarativeCustomParser
QDeclarativeCustomParserNode node =
qvariant_cast<QDeclarativeCustomParserNode>(value);
- if (node.name() != "ListElement") {
- error(node, QDeclarativeListModel::tr("ListElement: cannot contain nested elements"));
- return false;
+ if (node.name() != listElementTypeName) {
+ const QMetaObject *mo = resolveType(node.name());
+ if (mo != &QDeclarativeListElement::staticMetaObject) {
+ error(node, QDeclarativeListModel::tr("ListElement: cannot contain nested elements"));
+ return false;
+ }
+ listElementTypeName = node.name(); // cache right name for next time
}
{
@@ -650,6 +654,7 @@ QByteArray QDeclarativeListModelParser::compile(const QList<QDeclarativeCustomPa
{
QList<ListInstruction> instr;
QByteArray data;
+ listElementTypeName = QByteArray(); // unknown
for(int ii = 0; ii < customProps.count(); ++ii) {
const QDeclarativeCustomParserProperty &prop = customProps.at(ii);
diff --git a/src/declarative/util/qdeclarativelistmodel_p.h b/src/declarative/util/qdeclarativelistmodel_p.h
index d09062e..6aff9c6 100644
--- a/src/declarative/util/qdeclarativelistmodel_p.h
+++ b/src/declarative/util/qdeclarativelistmodel_p.h
@@ -135,6 +135,8 @@ private:
bool compileProperty(const QDeclarativeCustomParserProperty &prop, QList<ListInstruction> &instr, QByteArray &data);
bool definesEmptyList(const QString &);
+
+ QByteArray listElementTypeName;
};
diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp
index a4ddf46..0a14462 100644
--- a/src/declarative/util/qdeclarativepixmapcache.cpp
+++ b/src/declarative/util/qdeclarativepixmapcache.cpp
@@ -510,6 +510,12 @@ bool QDeclarativePixmapReply::event(QEvent *event)
else
d->errorString = de->errorString;
QByteArray key = d->url.toEncoded(QUrl::FormattingOption(0x100));
+ if (d->forced_width > 0 || d->forced_height > 0) {
+ key += ':';
+ key += QByteArray::number(d->forced_width);
+ key += 'x';
+ key += QByteArray::number(d->forced_height);
+ }
QString strKey = QString::fromLatin1(key.constData(), key.count());
QPixmapCache::insert(strKey, d->pixmap); // note: may fail (returns false)
emit finished();
diff --git a/src/declarative/util/qdeclarativepropertychanges_p.h b/src/declarative/util/qdeclarativepropertychanges_p.h
index c2ed466..bb0f944 100644
--- a/src/declarative/util/qdeclarativepropertychanges_p.h
+++ b/src/declarative/util/qdeclarativepropertychanges_p.h
@@ -79,6 +79,9 @@ public:
class QDeclarativePropertyChangesParser : public QDeclarativeCustomParser
{
public:
+ QDeclarativePropertyChangesParser()
+ : QDeclarativeCustomParser(AcceptsAttachedProperties) {}
+
void compileList(QList<QPair<QByteArray, QVariant> > &list, const QByteArray &pre, const QDeclarativeCustomParserProperty &prop);
virtual QByteArray compile(const QList<QDeclarativeCustomParserProperty> &);
diff --git a/tests/auto/declarative/qdeclarativeanimations/data/runningTrueBug.qml b/tests/auto/declarative/qdeclarativeanimations/data/runningTrueBug.qml
new file mode 100644
index 0000000..2c5207e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeanimations/data/runningTrueBug.qml
@@ -0,0 +1,30 @@
+import Qt 4.7
+Rectangle {
+ color: "skyblue"
+ width: 500
+ height: 200
+ Rectangle {
+ objectName: "cloud"
+ color: "white"
+ y: 50
+ width: 100
+ height: 100
+
+ SequentialAnimation on x {
+ loops: Animation.Infinite
+ running: true
+ NumberAnimation {
+ id: firstAnimation
+ from: 0
+ to: 500
+ duration: 5000
+ }
+ NumberAnimation {
+ id: secondAnimation
+ from: -100
+ to: 0
+ duration: 1000
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
index 5cf4c23..a965ef3 100644
--- a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
+++ b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
@@ -81,6 +81,7 @@ private slots:
void dontStart();
void easingProperties();
void rotation();
+ void runningTrueBug();
};
#define QTIMED_COMPARE(lhs, rhs) do { \
@@ -733,6 +734,20 @@ void tst_qdeclarativeanimations::rotation()
QTIMED_COMPARE(rr->rotation() + rr2->rotation() + rr3->rotation() + rr4->rotation(), qreal(370*4));
}
+void tst_qdeclarativeanimations::runningTrueBug()
+{
+ //ensure we start correctly when "running: true" is explicitly set
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/runningTrueBug.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *cloud = rect->findChild<QDeclarativeRectangle*>("cloud");
+ QVERIFY(cloud);
+ QTest::qWait(1000);
+ QVERIFY(cloud->x() > qreal(0));
+}
+
QTEST_MAIN(tst_qdeclarativeanimations)
#include "tst_qdeclarativeanimations.moc"
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml b/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml
index bc2df98..aab39be 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/eval.qml
@@ -16,7 +16,11 @@ QtObject {
test1 = (eval("a") == 7);
test2 = (eval("b") == 9);
- test3 = (eval("c") == undefined);
+ try {
+ eval("c");
+ } catch(e) {
+ test3 = true;
+ }
test4 = (eval("console") == console);
test5 = (eval("Qt") == Qt);
}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/function.qml b/tests/auto/declarative/qdeclarativeecmascript/data/function.qml
index b435f58..80d6ef4 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/function.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/function.qml
@@ -14,6 +14,10 @@ QtObject {
test1 = (func1(4) == 11);
test2 = (func2("Hello World!") == Qt.atob("Hello World!"));
- test3 = (func3() == undefined);
+ try {
+ func3();
+ } catch(e) {
+ test3 = true;
+ }
}
}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.js b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.js
new file mode 100644
index 0000000..092bc2b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.js
@@ -0,0 +1 @@
+;
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.qml
new file mode 100644
index 0000000..56e7885
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11600.qml
@@ -0,0 +1,8 @@
+import Qt 4.7
+import "qtbug_11600.js" as Test
+
+QtObject {
+ id: goo
+
+ property bool test: undefined == goo.Test.foo
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11606.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11606.qml
new file mode 100644
index 0000000..6efb9c1
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/qtbug_11606.qml
@@ -0,0 +1,12 @@
+import Qt 4.7
+
+QtObject {
+ property bool test: false
+ Component.onCompleted: {
+ try {
+ console.log(sorryNoSuchProperty);
+ } catch (e) {
+ test = true;
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml
index 4395ba3..2548005 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/scope.3.qml
@@ -1,10 +1,10 @@
import Qt 4.7
+import Qt.test 1.0
-Item {
+MyQmlObject {
id: root
property int foo: 12
- property int console: 11
property bool test1: foo == 12
property bool test2: console != 11
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml b/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml
index e8f7b62..f601f49 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/scriptErrors.qml
@@ -4,7 +4,7 @@ import "scriptErrors.js" as Script
MyQmlObject {
property int t: a.value
property int w: Script.getValue();
- property int x: undefinedObject
+ property int x: undefined
property int y: (a.value, undefinedObject)
onBasicSignal: { console.log(a.value); }
diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
index 7bb8a8e..849879e 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
+++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h
@@ -86,6 +86,7 @@ class MyQmlObject : public QObject
Q_PROPERTY(bool trueProperty READ trueProperty CONSTANT)
Q_PROPERTY(bool falseProperty READ falseProperty CONSTANT)
Q_PROPERTY(int value READ value WRITE setValue)
+ Q_PROPERTY(int console READ console CONSTANT)
Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged)
Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectChanged)
Q_PROPERTY(QDeclarativeListProperty<QObject> objectListProperty READ objectListProperty CONSTANT)
@@ -142,6 +143,7 @@ public:
QRegExp regExp() { return m_regExp; }
void setRegExp(const QRegExp &regExp) { m_regExp = regExp; }
+ int console() const { return 11; }
signals:
void basicSignal();
void argumentSignal(int a, QString b, qreal c);
@@ -555,7 +557,9 @@ Q_DECLARE_METATYPE(QScriptValue);
class MyInvokableObject : public QObject
{
Q_OBJECT
+ Q_ENUMS(TestEnum)
public:
+ enum TestEnum { EnumValue1, EnumValue2 };
MyInvokableObject() { reset(); }
int invoked() const { return m_invoked; }
@@ -587,6 +591,8 @@ public:
Q_INVOKABLE void method_overload(int a) { invoke(16); m_actuals << a; }
Q_INVOKABLE void method_overload(int a, int b) { invoke(17); m_actuals << a << b; }
+ Q_INVOKABLE void method_with_enum(TestEnum e) { invoke(18); m_actuals << (int)e; }
+
private:
void invoke(int idx) { if (m_invoked != -1) m_invokedError = true; m_invoked = idx;}
int m_invoked;
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index 16e7ec5..43900ae 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -155,6 +155,8 @@ private slots:
void eval();
void function();
void qtbug_10696();
+ void qtbug_11606();
+ void qtbug_11600();
void include();
@@ -1002,10 +1004,10 @@ void tst_qdeclarativeecmascript::scriptErrors()
QString url = component.url().toString();
QString warning1 = url.left(url.length() - 3) + "js:2: Error: Invalid write to global property \"a\"";
- QString warning2 = url + ":5: TypeError: Result of expression 'a' [undefined] is not an object.";
+ QString warning2 = url + ":5: ReferenceError: Can't find variable: a";
QString warning3 = url.left(url.length() - 3) + "js:4: Error: Invalid write to global property \"a\"";
- QString warning4 = url + ":10: TypeError: Result of expression 'a' [undefined] is not an object.";
- QString warning5 = url + ":8: TypeError: Result of expression 'a' [undefined] is not an object.";
+ QString warning4 = url + ":10: ReferenceError: Can't find variable: a";
+ QString warning5 = url + ":8: ReferenceError: Can't find variable: a";
QString warning6 = url + ":7: Unable to assign [undefined] to int x";
QString warning7 = url + ":12: Error: Cannot assign to read-only property \"trueProperty\"";
QString warning8 = url + ":13: Error: Cannot assign to non-existent property \"fakeProperty\"";
@@ -1322,7 +1324,12 @@ void tst_qdeclarativeecmascript::callQtInvokables()
QDeclarativeEngine qmlengine;
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(&qmlengine);
QScriptEngine *engine = &ep->scriptEngine;
- ep->globalClass->explicitSetProperty("object", ep->objectClass->newQObject(&o));
+
+ QStringList names; QList<QScriptValue> values;
+ names << QLatin1String("object"); values << ep->objectClass->newQObject(&o);
+ names << QLatin1String("undefined"); values << engine->undefinedValue();
+
+ ep->globalClass->explicitSetProperty(names, values);
// Non-existent methods
o.reset();
@@ -1714,6 +1721,13 @@ void tst_qdeclarativeecmascript::callQtInvokables()
QCOMPARE(o.actuals().count(), 2);
QCOMPARE(o.actuals().at(0), QVariant(10));
QCOMPARE(o.actuals().at(1), QVariant(11));
+
+ o.reset();
+ QCOMPARE(engine->evaluate("object.method_with_enum(9)").isUndefined(), true);
+ QCOMPARE(o.error(), false);
+ QCOMPARE(o.invoked(), 18);
+ QCOMPARE(o.actuals().count(), 1);
+ QCOMPARE(o.actuals().at(0), QVariant(9));
}
// QTBUG-5675
@@ -2498,6 +2512,25 @@ void tst_qdeclarativeecmascript::qtbug_10696()
delete o;
}
+void tst_qdeclarativeecmascript::qtbug_11606()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("qtbug_11606.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test").toBool(), true);
+ delete o;
+}
+
+void tst_qdeclarativeecmascript::qtbug_11600()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("qtbug_11600.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+ QCOMPARE(o->property("test").toBool(), true);
+ delete o;
+}
+
+
QTEST_MAIN(tst_qdeclarativeecmascript)
#include "tst_qdeclarativeecmascript.moc"
diff --git a/tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml b/tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml
index aa156ed..a840a01 100644
--- a/tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml
+++ b/tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml
@@ -1,6 +1,12 @@
import Qt 4.7
Flickable {
+ property bool ok: false
+ function check() {
+ if (column.parent == contentItem)
+ ok = true;
+ }
+
width: 100; height: 100
contentWidth: column.width; contentHeight: column.height
pressDelay: 200; boundsBehavior: Flickable.StopAtBounds; interactive: false
diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
index 2ba5574..678996b 100644
--- a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
+++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp
@@ -147,6 +147,10 @@ void tst_qdeclarativeflickable::properties()
QCOMPARE(obj->pressDelay(), 200);
QCOMPARE(obj->maximumFlickVelocity(), 2000.);
+ QVERIFY(obj->property("ok").toBool() == false);
+ QMetaObject::invokeMethod(obj, "check");
+ QVERIFY(obj->property("ok").toBool() == true);
+
delete obj;
}
diff --git a/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml b/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml
index 9331243..a5d651d 100644
--- a/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml
+++ b/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml
@@ -43,7 +43,7 @@ Rectangle {
focus: true
width: 240
height: 320
- currentIndex: 5
+ currentIndex: 35
cellWidth: 80
cellHeight: 60
delegate: myDelegate
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index 4e35bc0..a67c56f 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -178,17 +178,17 @@ void tst_QDeclarativeGridView::items()
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
QTRY_VERIFY(gridview != 0);
- QDeclarativeItem *viewport = gridview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
QTRY_COMPARE(gridview->count(), model.count());
- QTRY_COMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+ QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
for (int i = 0; i < model.count(); ++i) {
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", i);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", i);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(i));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", i);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(i));
}
@@ -197,7 +197,7 @@ void tst_QDeclarativeGridView::items()
TestModel model2;
ctxt->setContextProperty("testModel", &model2);
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
QTRY_VERIFY(itemCount == 0);
delete canvas;
@@ -226,14 +226,14 @@ void tst_QDeclarativeGridView::changed()
QDeclarativeFlickable *gridview = findItem<QDeclarativeFlickable>(canvas->rootObject(), "grid");
QTRY_VERIFY(gridview != 0);
- QDeclarativeItem *viewport = gridview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
model.modifyItem(1, "Will", "9876");
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(1));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 1);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(1));
@@ -259,17 +259,17 @@ void tst_QDeclarativeGridView::inserted()
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
QTRY_VERIFY(gridview != 0);
- QDeclarativeItem *viewport = gridview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
model.insertItem(1, "Will", "9876");
- QTRY_COMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+ QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(1));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 1);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(1));
@@ -279,19 +279,19 @@ void tst_QDeclarativeGridView::inserted()
// Confirm items positioned correctly
for (int i = 0; i < model.count(); ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
QTRY_COMPARE(item->x(), (i%3)*80.0);
QTRY_COMPARE(item->y(), (i/3)*60.0);
}
model.insertItem(0, "Foo", "1111"); // zero index, and current item
- QTRY_COMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+ QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
- name = findItem<QDeclarativeText>(viewport, "textName", 0);
+ name = findItem<QDeclarativeText>(contentItem, "textName", 0);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(0));
- number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
+ number = findItem<QDeclarativeText>(contentItem, "textNumber", 0);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(0));
@@ -299,7 +299,7 @@ void tst_QDeclarativeGridView::inserted()
// Confirm items positioned correctly
for (int i = 0; i < model.count(); ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
QTRY_VERIFY(item->x() == (i%3)*80);
QTRY_VERIFY(item->y() == (i/3)*60);
}
@@ -335,15 +335,15 @@ void tst_QDeclarativeGridView::removed()
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
QTRY_VERIFY(gridview != 0);
- QDeclarativeItem *viewport = gridview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
model.removeItem(1);
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(1));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 1);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(1));
@@ -352,9 +352,9 @@ void tst_QDeclarativeGridView::removed()
QTRY_COMPARE(removed, QString("Item1"));
// Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->x() == (i%3)*80);
@@ -364,17 +364,17 @@ void tst_QDeclarativeGridView::removed()
// Remove first item (which is the current item);
model.removeItem(0);
- name = findItem<QDeclarativeText>(viewport, "textName", 0);
+ name = findItem<QDeclarativeText>(contentItem, "textName", 0);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(0));
- number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
+ number = findItem<QDeclarativeText>(contentItem, "textNumber", 0);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(0));
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->x() == (i%3)*80);
@@ -385,9 +385,9 @@ void tst_QDeclarativeGridView::removed()
model.removeItem(25);
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->x() == (i%3)*80);
@@ -405,7 +405,7 @@ void tst_QDeclarativeGridView::removed()
// Confirm items positioned correctly
for (int i = 6; i < 18; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->x() == (i%3)*80);
@@ -424,9 +424,9 @@ void tst_QDeclarativeGridView::removed()
QTest::qWait(100);
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->x() == (i%3)*80);
@@ -478,29 +478,29 @@ void tst_QDeclarativeGridView::moved()
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
QTRY_VERIFY(gridview != 0);
- QDeclarativeItem *viewport = gridview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
model.moveItem(1, 8);
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(1));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 1);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(1));
- name = findItem<QDeclarativeText>(viewport, "textName", 8);
+ name = findItem<QDeclarativeText>(contentItem, "textName", 8);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(8));
- number = findItem<QDeclarativeText>(viewport, "textNumber", 8);
+ number = findItem<QDeclarativeText>(contentItem, "textNumber", 8);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(8));
// Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->x() == (i%3)*80);
@@ -513,17 +513,17 @@ void tst_QDeclarativeGridView::moved()
model.moveItem(1, 25);
// Confirm items positioned correctly and indexes correct
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count()-1;
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count()-1;
for (int i = 6; i < model.count()-6 && i < itemCount+6; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->x(), qreal((i%3)*80));
QTRY_COMPARE(item->y(), qreal((i/3)*60));
- name = findItem<QDeclarativeText>(viewport, "textName", i);
+ name = findItem<QDeclarativeText>(contentItem, "textName", i);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(i));
- number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ number = findItem<QDeclarativeText>(contentItem, "textNumber", i);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(i));
}
@@ -533,15 +533,15 @@ void tst_QDeclarativeGridView::moved()
// Confirm items positioned correctly and indexes correct
for (int i = 6; i < model.count()-6 && i < itemCount+6; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->x() == (i%3)*80);
QTRY_VERIFY(item->y() == (i/3)*60);
- name = findItem<QDeclarativeText>(viewport, "textName", i);
+ name = findItem<QDeclarativeText>(contentItem, "textName", i);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(i));
- number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ number = findItem<QDeclarativeText>(contentItem, "textNumber", i);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(i));
}
@@ -557,7 +557,7 @@ void tst_QDeclarativeGridView::moved()
void tst_QDeclarativeGridView::currentIndex()
{
TestModel model;
- for (int i = 0; i < 30; i++)
+ for (int i = 0; i < 60; i++)
model.addItem("Item" + QString::number(i), QString::number(i));
QDeclarativeView *canvas = new QDeclarativeView(0);
@@ -572,57 +572,58 @@ void tst_QDeclarativeGridView::currentIndex()
qApp->processEvents();
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
+ QVERIFY(gridview != 0);
- QDeclarativeItem *viewport = gridview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QVERIFY(contentItem != 0);
// current item should be third item
- QTRY_COMPARE(gridview->currentIndex(), 5);
- QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 5));
- QTRY_COMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y());
+ QCOMPARE(gridview->currentIndex(), 35);
+ QCOMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 35));
+ QCOMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y());
+ QCOMPARE(gridview->contentY(), 399.0);
gridview->moveCurrentIndexRight();
- QTRY_COMPARE(gridview->currentIndex(), 6);
+ QCOMPARE(gridview->currentIndex(), 36);
gridview->moveCurrentIndexDown();
- QTRY_COMPARE(gridview->currentIndex(), 9);
+ QCOMPARE(gridview->currentIndex(), 39);
gridview->moveCurrentIndexUp();
- QTRY_COMPARE(gridview->currentIndex(), 6);
+ QCOMPARE(gridview->currentIndex(), 36);
gridview->moveCurrentIndexLeft();
- QTRY_COMPARE(gridview->currentIndex(), 5);
+ QCOMPARE(gridview->currentIndex(), 35);
// no wrap
gridview->setCurrentIndex(0);
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
gridview->moveCurrentIndexUp();
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
gridview->moveCurrentIndexLeft();
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
gridview->setCurrentIndex(model.count()-1);
- QTRY_COMPARE(gridview->currentIndex(), model.count()-1);
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
gridview->moveCurrentIndexRight();
- QTRY_COMPARE(gridview->currentIndex(), model.count()-1);
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
gridview->moveCurrentIndexDown();
- QTRY_COMPARE(gridview->currentIndex(), model.count()-1);
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
// with wrap
gridview->setWrapEnabled(true);
gridview->setCurrentIndex(0);
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
gridview->moveCurrentIndexLeft();
- QTRY_COMPARE(gridview->currentIndex(), model.count()-1);
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
- QTRY_COMPARE(gridview->contentY(), 279.0);
+ QTRY_COMPARE(gridview->contentY(), 879.0);
gridview->moveCurrentIndexRight();
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
QTRY_COMPARE(gridview->contentY(), 0.0);
@@ -638,30 +639,30 @@ void tst_QDeclarativeGridView::currentIndex()
qApp->processEvents();
QTest::keyClick(canvas, Qt::Key_Down);
- QTRY_COMPARE(gridview->currentIndex(), 3);
+ QCOMPARE(gridview->currentIndex(), 3);
QTest::keyClick(canvas, Qt::Key_Up);
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
gridview->setFlow(QDeclarativeGridView::TopToBottom);
QTest::keyClick(canvas, Qt::Key_Right);
- QTRY_COMPARE(gridview->currentIndex(), 5);
+ QCOMPARE(gridview->currentIndex(), 5);
QTest::keyClick(canvas, Qt::Key_Left);
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
QTest::keyClick(canvas, Qt::Key_Down);
- QTRY_COMPARE(gridview->currentIndex(), 1);
+ QCOMPARE(gridview->currentIndex(), 1);
QTest::keyClick(canvas, Qt::Key_Up);
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
// turn off auto highlight
gridview->setHighlightFollowsCurrentItem(false);
- QTRY_VERIFY(gridview->highlightFollowsCurrentItem() == false);
- QTRY_VERIFY(gridview->highlightItem());
+ QVERIFY(gridview->highlightFollowsCurrentItem() == false);
+ QVERIFY(gridview->highlightItem());
qreal hlPosX = gridview->highlightItem()->x();
qreal hlPosY = gridview->highlightItem()->y();
@@ -695,21 +696,21 @@ void tst_QDeclarativeGridView::changeFlow()
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
QTRY_VERIFY(gridview != 0);
- QDeclarativeItem *viewport = gridview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
// Confirm items positioned correctly and indexes correct
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->x(), qreal((i%3)*80));
QTRY_COMPARE(item->y(), qreal((i/3)*60));
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", i);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", i);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(i));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", i);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(i));
}
@@ -717,17 +718,17 @@ void tst_QDeclarativeGridView::changeFlow()
ctxt->setContextProperty("testTopToBottom", QVariant(true));
// Confirm items positioned correctly and indexes correct
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->x(), qreal((i/5)*80));
QTRY_COMPARE(item->y(), qreal((i%5)*60));
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", i);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", i);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(i));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", i);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(i));
}
@@ -913,13 +914,13 @@ void tst_QDeclarativeGridView::positionViewAtIndex()
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
QTRY_VERIFY(gridview != 0);
- QDeclarativeItem *viewport = gridview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
// Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->x(), (i%3)*80.);
@@ -931,9 +932,9 @@ void tst_QDeclarativeGridView::positionViewAtIndex()
QTRY_COMPARE(gridview->contentY(), 60.);
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->x(), (i%3)*80.);
@@ -945,9 +946,9 @@ void tst_QDeclarativeGridView::positionViewAtIndex()
QTRY_COMPARE(gridview->contentY(), 420.);
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->x(), (i%3)*80.);
@@ -959,9 +960,9 @@ void tst_QDeclarativeGridView::positionViewAtIndex()
QTRY_COMPARE(gridview->contentY(), 520.);
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->x(), (i%3)*80.);
@@ -973,9 +974,9 @@ void tst_QDeclarativeGridView::positionViewAtIndex()
QTRY_COMPARE(gridview->contentY(), 0.);
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->x(), (i%3)*80.);
@@ -1043,13 +1044,13 @@ void tst_QDeclarativeGridView::resetModel()
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
QTRY_VERIFY(gridview != 0);
- QDeclarativeItem *viewport = gridview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
QTRY_COMPARE(gridview->count(), model.rowCount());
for (int i = 0; i < model.rowCount(); ++i) {
- QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i);
+ QDeclarativeText *display = findItem<QDeclarativeText>(contentItem, "displayText", i);
QTRY_VERIFY(display != 0);
QTRY_COMPARE(display->text(), strings.at(i));
}
@@ -1061,7 +1062,7 @@ void tst_QDeclarativeGridView::resetModel()
QTRY_COMPARE(gridview->count(), model.rowCount());
for (int i = 0; i < model.rowCount(); ++i) {
- QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i);
+ QDeclarativeText *display = findItem<QDeclarativeText>(contentItem, "displayText", i);
QTRY_VERIFY(display != 0);
QTRY_COMPARE(display->text(), strings.at(i));
}
@@ -1088,22 +1089,22 @@ void tst_QDeclarativeGridView::enforceRange()
QTRY_COMPARE(gridview->preferredHighlightEnd(), 100.0);
QTRY_COMPARE(gridview->highlightRangeMode(), QDeclarativeGridView::StrictlyEnforceRange);
- QDeclarativeItem *viewport = gridview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
// view should be positioned at the top of the range.
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", 0);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", 0);
QTRY_VERIFY(item);
QTRY_COMPARE(gridview->contentY(), -100.0);
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 0);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 0);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(0));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 0);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(0));
- // Check currentIndex is updated when viewport moves
+ // Check currentIndex is updated when contentItem moves
gridview->setContentY(0);
QTRY_COMPARE(gridview->currentIndex(), 2);
@@ -1145,18 +1146,18 @@ void tst_QDeclarativeGridView::manualHighlight()
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
QTRY_VERIFY(gridview != 0);
- QDeclarativeItem *viewport = gridview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
QTRY_COMPARE(gridview->currentIndex(), 0);
- QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 0));
+ QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 0));
QTRY_COMPARE(gridview->highlightItem()->y(), gridview->currentItem()->y());
QTRY_COMPARE(gridview->highlightItem()->x(), gridview->currentItem()->x());
gridview->setCurrentIndex(2);
QTRY_COMPARE(gridview->currentIndex(), 2);
- QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 2));
+ QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 2));
QTRY_COMPARE(gridview->highlightItem()->y(), gridview->currentItem()->y());
QTRY_COMPARE(gridview->highlightItem()->x(), gridview->currentItem()->x());
}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.errors.txt
new file mode 100644
index 0000000..c83e5ae
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.errors.txt
@@ -0,0 +1 @@
+4:5:Illegal property name
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.qml
new file mode 100644
index 0000000..6077de4
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidProperty.qml
@@ -0,0 +1,5 @@
+import Qt 4.7
+
+QtObject {
+ property int parseInt
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index 413843a..3ce356e 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -370,6 +370,7 @@ void tst_qdeclarativelanguage::errors_data()
QTest::newRow("destroyedSignal") << "destroyedSignal.qml" << "destroyedSignal.errors.txt" << false;
QTest::newRow("assignToNamespace") << "assignToNamespace.qml" << "assignToNamespace.errors.txt" << false;
QTest::newRow("invalidOn") << "invalidOn.qml" << "invalidOn.errors.txt" << false;
+ QTest::newRow("invalidProperty") << "invalidProperty.qml" << "invalidProperty.errors.txt" << false;
}
diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
index 3d66733..f15ac8f 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
+++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
@@ -559,6 +559,18 @@ void tst_qdeclarativelistmodel::error_data()
QTest::newRow("QML elements not allowed in ListElement")
<< "import Qt 4.7\nListModel { ListElement { a: Item { } } }"
<< "ListElement: cannot contain nested elements";
+
+ QTest::newRow("qualified ListElement supported")
+ << "import Qt 4.7 as Foo\nFoo.ListModel { Foo.ListElement { a: 123 } }"
+ << "";
+
+ QTest::newRow("qualified ListElement required")
+ << "import Qt 4.7 as Foo\nFoo.ListModel { ListElement { a: 123 } }"
+ << "ListElement is not a type";
+
+ QTest::newRow("unknown qualified ListElement not allowed")
+ << "import Qt 4.7\nListModel { Foo.ListElement { a: 123 } }"
+ << "Foo.ListElement - Foo is not a namespace";
}
void tst_qdeclarativelistmodel::error()
diff --git a/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml b/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml
index 0599ddd..f3c2910 100644
--- a/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml
+++ b/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml
@@ -40,7 +40,7 @@ Rectangle {
id: list
objectName: "list"
focus: true
- currentIndex: 3
+ currentIndex: 20
width: 240
height: 320
keyNavigationWraps: testWrap
diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
index cd42b63..048f0f3 100644
--- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
+++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp
@@ -336,24 +336,24 @@ void tst_QDeclarativeListView::items()
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties");
QTRY_VERIFY(testObject->error() == false);
QTRY_VERIFY(listview->highlightItem() != 0);
QTRY_COMPARE(listview->count(), model.count());
- QTRY_COMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+ QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
// current item should be first item
- QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 0));
+ QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 0));
for (int i = 0; i < model.count(); ++i) {
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", i);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", i);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(i));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", i);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(i));
}
@@ -382,7 +382,7 @@ void tst_QDeclarativeListView::items()
T model2;
ctxt->setContextProperty("testModel", &model2);
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
QTRY_VERIFY(itemCount == 0);
QTRY_COMPARE(listview->highlightResizeSpeed(), 1000.0);
@@ -414,14 +414,14 @@ void tst_QDeclarativeListView::changed()
QDeclarativeFlickable *listview = findItem<QDeclarativeFlickable>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
model.modifyItem(1, "Will", "9876");
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(1));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 1);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(1));
@@ -450,34 +450,34 @@ void tst_QDeclarativeListView::inserted()
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
model.insertItem(1, "Will", "9876");
- QTRY_COMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+ QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(1));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 1);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(1));
// Confirm items positioned correctly
for (int i = 0; i < model.count(); ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
QTRY_COMPARE(item->y(), i*20.0);
}
model.insertItem(0, "Foo", "1111"); // zero index, and current item
- QTRY_COMPARE(viewport->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
+ QTRY_COMPARE(contentItem->childItems().count(), model.count()+1); // assumes all are visible, +1 for the (default) highlight item
- name = findItem<QDeclarativeText>(viewport, "textName", 0);
+ name = findItem<QDeclarativeText>(contentItem, "textName", 0);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(0));
- number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
+ number = findItem<QDeclarativeText>(contentItem, "textNumber", 0);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(0));
@@ -485,7 +485,7 @@ void tst_QDeclarativeListView::inserted()
// Confirm items positioned correctly
for (int i = 0; i < model.count(); ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
QTRY_COMPARE(item->y(), i*20.0);
}
@@ -501,13 +501,13 @@ void tst_QDeclarativeListView::inserted()
// Confirm items positioned correctly
for (int i = 5; i < 5+15; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(), i*20.0 - 20.0);
}
-// QTRY_COMPARE(listview->viewportHeight(), model.count() * 20.0);
+// QTRY_COMPARE(listview->contentItemHeight(), model.count() * 20.0);
delete canvas;
}
@@ -534,22 +534,22 @@ void tst_QDeclarativeListView::removed(bool animated)
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
model.removeItem(1);
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(1));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 1);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(1));
// Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->y() == i*20);
@@ -560,17 +560,17 @@ void tst_QDeclarativeListView::removed(bool animated)
QTest::qWait(300);
- name = findItem<QDeclarativeText>(viewport, "textName", 0);
+ name = findItem<QDeclarativeText>(contentItem, "textName", 0);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(0));
- number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
+ number = findItem<QDeclarativeText>(contentItem, "textNumber", 0);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(0));
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(),i*20.0 + 20.0);
@@ -581,9 +581,9 @@ void tst_QDeclarativeListView::removed(bool animated)
qApp->processEvents();
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(),i*20.0+20.0);
@@ -598,7 +598,7 @@ void tst_QDeclarativeListView::removed(bool animated)
// Confirm items positioned correctly
for (int i = 2; i < 18; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(),40+i*20.0);
@@ -617,9 +617,9 @@ void tst_QDeclarativeListView::removed(bool animated)
QTest::qWait(300);
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(),40+i*20.0);
@@ -665,8 +665,8 @@ void tst_QDeclarativeListView::clear()
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
model.clear();
@@ -699,29 +699,29 @@ void tst_QDeclarativeListView::moved()
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
model.moveItem(1, 4);
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 1);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 1);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(1));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 1);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 1);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(1));
- name = findItem<QDeclarativeText>(viewport, "textName", 4);
+ name = findItem<QDeclarativeText>(contentItem, "textName", 4);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(4));
- number = findItem<QDeclarativeText>(viewport, "textNumber", 4);
+ number = findItem<QDeclarativeText>(contentItem, "textNumber", 4);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(4));
// Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->y() == i*20);
@@ -734,14 +734,14 @@ void tst_QDeclarativeListView::moved()
// Confirm items positioned correctly and indexes correct
for (int i = 3; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(), i*20.0 + 20);
- name = findItem<QDeclarativeText>(viewport, "textName", i);
+ name = findItem<QDeclarativeText>(contentItem, "textName", i);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(i));
- number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ number = findItem<QDeclarativeText>(contentItem, "textNumber", i);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(i));
}
@@ -751,14 +751,14 @@ void tst_QDeclarativeListView::moved()
// Confirm items positioned correctly and indexes correct
for (int i = 3; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(), i*20.0 + 20);
- name = findItem<QDeclarativeText>(viewport, "textName", i);
+ name = findItem<QDeclarativeText>(contentItem, "textName", i);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(i));
- number = findItem<QDeclarativeText>(viewport, "textNumber", i);
+ number = findItem<QDeclarativeText>(contentItem, "textNumber", i);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(i));
}
@@ -787,22 +787,22 @@ void tst_QDeclarativeListView::enforceRange()
QTRY_COMPARE(listview->preferredHighlightEnd(), 100.0);
QTRY_COMPARE(listview->highlightRangeMode(), QDeclarativeListView::StrictlyEnforceRange);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
// view should be positioned at the top of the range.
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", 0);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", 0);
QTRY_VERIFY(item);
QTRY_COMPARE(listview->contentY(), -100.0);
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "textName", 0);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "textName", 0);
QTRY_VERIFY(name != 0);
QTRY_COMPARE(name->text(), model.name(0));
- QDeclarativeText *number = findItem<QDeclarativeText>(viewport, "textNumber", 0);
+ QDeclarativeText *number = findItem<QDeclarativeText>(contentItem, "textNumber", 0);
QTRY_VERIFY(number != 0);
QTRY_COMPARE(number->text(), model.number(0));
- // Check currentIndex is updated when viewport moves
+ // Check currentIndex is updated when contentItem moves
listview->setContentY(20);
QTRY_COMPARE(listview->currentIndex(), 6);
@@ -838,13 +838,13 @@ void tst_QDeclarativeListView::spacing()
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
// Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->y() == i*20);
@@ -854,9 +854,9 @@ void tst_QDeclarativeListView::spacing()
QTRY_VERIFY(listview->spacing() == 10);
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->y() == i*30);
@@ -865,9 +865,9 @@ void tst_QDeclarativeListView::spacing()
listview->setSpacing(0);
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(), i*20.0);
@@ -893,13 +893,13 @@ void tst_QDeclarativeListView::sections()
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
// Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(), qreal(i*20 + ((i+4)/5) * 20));
}
@@ -908,29 +908,29 @@ void tst_QDeclarativeListView::sections()
model.removeItem(5);
// New section header created
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", 5);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", 5);
QTRY_VERIFY(item);
QTRY_COMPARE(item->height(), 40.0);
model.insertItem(3, "New Item", "0");
// Section header moved
- item = findItem<QDeclarativeItem>(viewport, "wrapper", 5);
+ item = findItem<QDeclarativeItem>(contentItem, "wrapper", 5);
QTRY_VERIFY(item);
QTRY_COMPARE(item->height(), 20.0);
- item = findItem<QDeclarativeItem>(viewport, "wrapper", 6);
+ item = findItem<QDeclarativeItem>(contentItem, "wrapper", 6);
QTRY_VERIFY(item);
QTRY_COMPARE(item->height(), 40.0);
// insert item which will become a section header
model.insertItem(6, "Replace header", "1");
- item = findItem<QDeclarativeItem>(viewport, "wrapper", 6);
+ item = findItem<QDeclarativeItem>(contentItem, "wrapper", 6);
QTRY_VERIFY(item);
QTRY_COMPARE(item->height(), 40.0);
- item = findItem<QDeclarativeItem>(viewport, "wrapper", 7);
+ item = findItem<QDeclarativeItem>(contentItem, "wrapper", 7);
QTRY_VERIFY(item);
QTRY_COMPARE(item->height(), 20.0);
@@ -942,7 +942,7 @@ void tst_QDeclarativeListView::sections()
listview->setContentY(20);
QTRY_COMPARE(listview->currentSection(), QString("0"));
- item = findItem<QDeclarativeItem>(viewport, "wrapper", 1);
+ item = findItem<QDeclarativeItem>(contentItem, "wrapper", 1);
QTRY_VERIFY(item);
QTRY_COMPARE(item->height(), 20.0);
@@ -970,37 +970,39 @@ void tst_QDeclarativeListView::currentIndex()
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
- // current item should be third item
- QTRY_COMPARE(listview->currentIndex(), 3);
- QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 3));
- QTRY_COMPARE(listview->highlightItem()->y(), listview->currentItem()->y());
+ // current item should be 20th item at startup
+ // and current item should be in view
+ QCOMPARE(listview->currentIndex(), 20);
+ QCOMPARE(listview->contentY(), 99.0);
+ QCOMPARE(listview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 20));
+ QCOMPARE(listview->highlightItem()->y(), listview->currentItem()->y());
// no wrap
listview->setCurrentIndex(0);
- QTRY_COMPARE(listview->currentIndex(), 0);
+ QCOMPARE(listview->currentIndex(), 0);
listview->incrementCurrentIndex();
- QTRY_COMPARE(listview->currentIndex(), 1);
+ QCOMPARE(listview->currentIndex(), 1);
listview->decrementCurrentIndex();
- QTRY_COMPARE(listview->currentIndex(), 0);
+ QCOMPARE(listview->currentIndex(), 0);
listview->decrementCurrentIndex();
- QTRY_COMPARE(listview->currentIndex(), 0);
+ QCOMPARE(listview->currentIndex(), 0);
// with wrap
ctxt->setContextProperty("testWrap", QVariant(true));
- QTRY_VERIFY(listview->isWrapEnabled());
+ QVERIFY(listview->isWrapEnabled());
listview->decrementCurrentIndex();
- QTRY_COMPARE(listview->currentIndex(), model.count()-1);
+ QCOMPARE(listview->currentIndex(), model.count()-1);
QTRY_COMPARE(listview->contentY(), 279.0);
listview->incrementCurrentIndex();
- QTRY_COMPARE(listview->currentIndex(), 0);
+ QCOMPARE(listview->currentIndex(), 0);
QTRY_COMPARE(listview->contentY(), 0.0);
@@ -1016,16 +1018,16 @@ void tst_QDeclarativeListView::currentIndex()
qApp->processEvents();
QTest::keyClick(canvas, Qt::Key_Down);
- QTRY_COMPARE(listview->currentIndex(), 1);
+ QCOMPARE(listview->currentIndex(), 1);
QTest::keyClick(canvas, Qt::Key_Up);
- QTRY_COMPARE(listview->currentIndex(), 0);
+ QCOMPARE(listview->currentIndex(), 0);
// turn off auto highlight
listview->setHighlightFollowsCurrentItem(false);
- QTRY_VERIFY(listview->highlightFollowsCurrentItem() == false);
+ QVERIFY(listview->highlightFollowsCurrentItem() == false);
- QTRY_VERIFY(listview->highlightItem());
+ QVERIFY(listview->highlightItem());
qreal hlPos = listview->highlightItem()->y();
listview->setCurrentIndex(4);
@@ -1049,8 +1051,8 @@ void tst_QDeclarativeListView::itemList()
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "view");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
QDeclarativeVisualItemModel *model = canvas->rootObject()->findChild<QDeclarativeVisualItemModel*>("itemModel");
QTRY_VERIFY(model != 0);
@@ -1058,21 +1060,21 @@ void tst_QDeclarativeListView::itemList()
QTRY_VERIFY(model->count() == 3);
QTRY_COMPARE(listview->currentIndex(), 0);
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "item1");
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "item1");
QTRY_VERIFY(item);
QTRY_COMPARE(item->x(), 0.0);
- QDeclarativeText *text = findItem<QDeclarativeText>(viewport, "text1");
+ QDeclarativeText *text = findItem<QDeclarativeText>(contentItem, "text1");
QTRY_VERIFY(text);
QTRY_COMPARE(text->text(), QLatin1String("index: 0"));
listview->setCurrentIndex(2);
- item = findItem<QDeclarativeItem>(viewport, "item3");
+ item = findItem<QDeclarativeItem>(contentItem, "item3");
QTRY_VERIFY(item);
QTRY_COMPARE(item->x(), 480.0);
- text = findItem<QDeclarativeText>(viewport, "text3");
+ text = findItem<QDeclarativeText>(contentItem, "text3");
QTRY_VERIFY(text);
QTRY_COMPARE(text->text(), QLatin1String("index: 2"));
@@ -1099,16 +1101,16 @@ void tst_QDeclarativeListView::cacheBuffer()
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
QTRY_VERIFY(listview->delegate() != 0);
QTRY_VERIFY(listview->model() != 0);
QTRY_VERIFY(listview->highlight() != 0);
// Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->y() == i*20);
@@ -1117,12 +1119,12 @@ void tst_QDeclarativeListView::cacheBuffer()
testObject->setCacheBuffer(400);
QTRY_VERIFY(listview->cacheBuffer() == 400);
- int newItemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int newItemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
QTRY_VERIFY(newItemCount > itemCount);
// Confirm items positioned correctly
for (int i = 0; i < model.count() && i < newItemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->y() == i*20);
@@ -1151,13 +1153,13 @@ void tst_QDeclarativeListView::positionViewAtIndex()
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
// Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(), i*20.);
@@ -1168,9 +1170,9 @@ void tst_QDeclarativeListView::positionViewAtIndex()
QTRY_COMPARE(listview->contentY(), 60.);
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 3; i < model.count() && i < itemCount-3-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(), i*20.);
@@ -1181,9 +1183,9 @@ void tst_QDeclarativeListView::positionViewAtIndex()
QTRY_COMPARE(listview->contentY(), 440.);
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 22; i < model.count() && i < itemCount-22-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(), i*20.);
@@ -1194,9 +1196,9 @@ void tst_QDeclarativeListView::positionViewAtIndex()
QTRY_COMPARE(listview->contentY(), 480.);
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 24; i < model.count() && i < itemCount-24-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(), i*20.);
@@ -1207,9 +1209,9 @@ void tst_QDeclarativeListView::positionViewAtIndex()
QTRY_COMPARE(listview->contentY(), 0.);
// Confirm items positioned correctly
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount-1; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->y(), i*20.);
@@ -1276,13 +1278,13 @@ void tst_QDeclarativeListView::resetModel()
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
QTRY_COMPARE(listview->count(), model.rowCount());
for (int i = 0; i < model.rowCount(); ++i) {
- QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i);
+ QDeclarativeText *display = findItem<QDeclarativeText>(contentItem, "displayText", i);
QTRY_VERIFY(display != 0);
QTRY_COMPARE(display->text(), strings.at(i));
}
@@ -1294,7 +1296,7 @@ void tst_QDeclarativeListView::resetModel()
QTRY_COMPARE(listview->count(), model.rowCount());
for (int i = 0; i < model.rowCount(); ++i) {
- QDeclarativeText *display = findItem<QDeclarativeText>(viewport, "displayText", i);
+ QDeclarativeText *display = findItem<QDeclarativeText>(contentItem, "displayText", i);
QTRY_VERIFY(display != 0);
QTRY_COMPARE(display->text(), strings.at(i));
}
@@ -1453,8 +1455,8 @@ void tst_QDeclarativeListView::QTBUG_9791()
QDeclarativeListView *listview = qobject_cast<QDeclarativeListView*>(canvas->rootObject());
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
QTRY_VERIFY(listview->delegate() != 0);
QTRY_VERIFY(listview->model() != 0);
@@ -1462,11 +1464,11 @@ void tst_QDeclarativeListView::QTBUG_9791()
qApp->processEvents();
// Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
QVERIFY(itemCount == 3);
for (int i = 0; i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_COMPARE(item->x(), i*300.0);
@@ -1493,17 +1495,17 @@ void tst_QDeclarativeListView::manualHighlight()
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
QTRY_COMPARE(listview->currentIndex(), 0);
- QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 0));
+ QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 0));
QTRY_COMPARE(listview->highlightItem()->y(), listview->currentItem()->y());
listview->setCurrentIndex(2);
QTRY_COMPARE(listview->currentIndex(), 2);
- QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 2));
+ QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(contentItem, "wrapper", 2));
QTRY_COMPARE(listview->highlightItem()->y(), listview->currentItem()->y());
}
@@ -1527,13 +1529,13 @@ void tst_QDeclarativeListView::QTBUG_11105()
QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
// Confirm items positioned correctly
- int itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ int itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
for (int i = 0; i < model.count() && i < itemCount; ++i) {
- QDeclarativeItem *item = findItem<QDeclarativeItem>(viewport, "wrapper", i);
+ QDeclarativeItem *item = findItem<QDeclarativeItem>(contentItem, "wrapper", i);
if (!item) qWarning() << "Item" << i << "not found";
QTRY_VERIFY(item);
QTRY_VERIFY(item->y() == i*20);
@@ -1548,7 +1550,7 @@ void tst_QDeclarativeListView::QTBUG_11105()
ctxt->setContextProperty("testModel", &model2);
- itemCount = findItems<QDeclarativeItem>(viewport, "wrapper").count();
+ itemCount = findItems<QDeclarativeItem>(contentItem, "wrapper").count();
QCOMPARE(itemCount, 5);
delete canvas;
diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp
index d047a2a..b0b7a3b 100644
--- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp
+++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp
@@ -47,6 +47,7 @@
#include <QtDeclarative/qdeclarativecomponent.h>
#include <private/qdeclarativeloader_p.h>
#include "testhttpserver.h"
+#include "../../../shared/util.h"
#define SERVER_PORT 14450
@@ -176,9 +177,7 @@ void tst_QDeclarativeLoader::clear()
QCOMPARE(loader->progress(), 1.0);
QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
- QTest::qWait(500);
-
- QVERIFY(loader->item() == 0);
+ QTRY_VERIFY(loader->item() == 0);
QCOMPARE(loader->progress(), 0.0);
QCOMPARE(loader->status(), QDeclarativeLoader::Null);
QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 0);
@@ -239,8 +238,8 @@ void tst_QDeclarativeLoader::urlToComponent()
"}" )
, TEST_FILE(""));
QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create());
- QTest::qWait(500);
- QVERIFY(loader != 0);
+ QTest::qWait(200);
+ QTRY_VERIFY(loader != 0);
QVERIFY(loader->item());
QCOMPARE(loader->progress(), 1.0);
QCOMPARE(static_cast<QGraphicsItem*>(loader)->children().count(), 1);
diff --git a/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.js b/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.js
index c165e29..30499e9 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.js
+++ b/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.js
@@ -5,3 +5,7 @@ function loadComponent() {
return component.status;
}
+function createComponent() {
+ var component = Qt.createComponent("createComponentData.qml");
+ return component.createObject(null);
+}
diff --git a/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml b/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml
index aae7a91..33203c7 100644
--- a/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml
+++ b/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml
@@ -3,8 +3,10 @@ import "createComponent_lib.js" as Test
Item {
property int status: Component.Null
+ property int readValue: 0
Component.onCompleted: {
status = Test.loadComponent()
+ readValue = Test.createComponent().test;
}
}
diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
index fb100a5..895ee6c 100644
--- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
+++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
@@ -365,14 +365,12 @@ void tst_qdeclarativeqt::createComponent()
void tst_qdeclarativeqt::createComponent_pragmaLibrary()
{
// Currently, just loading createComponent_lib.qml causes crash on some platforms
- /*
QDeclarativeComponent component(&engine, TEST_FILE("createComponent_lib.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
-
- QEXPECT_FAIL("", "QTBUG-11507", Continue);
QCOMPARE(object->property("status").toInt(), int(QDeclarativeComponent::Ready));
- */
+ QCOMPARE(object->property("readValue").toInt(), int(1913));
+ delete object;
}
void tst_qdeclarativeqt::createQmlObject()
diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
index 2913ddd..639b2f3 100644
--- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
+++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
@@ -263,7 +263,6 @@ void tst_qdeclarativestates::attachedPropertyChanges()
MyAttached *att = qobject_cast<MyAttached*>(attObj);
QVERIFY(att);
- QEXPECT_FAIL("", "QTBUG-11283", Abort);
QCOMPARE(att->foo(), 1);
}
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments.qml b/tests/auto/declarative/qdeclarativetext/data/alignments.qml
new file mode 100644
index 0000000..b1f701b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments.qml
@@ -0,0 +1,41 @@
+import Qt 4.7
+
+Rectangle {
+ id: top
+ width: 70; height: 70;
+
+ property alias horizontalAlignment: t.horizontalAlignment
+ property alias verticalAlignment: t.verticalAlignment
+ property alias wrapMode: t.wrapMode
+ property alias running: timer.running
+ property string txt: "Test"
+
+ Rectangle {
+ anchors.centerIn: parent
+ width: 40
+ height: 40
+ color: "green"
+
+ Text {
+ id: t
+
+ anchors.fill: parent
+ horizontalAlignment: TextEdit.AlignRight
+ verticalAlignment: TextEdit.AlignBottom
+ wrapMode: TextEdit.WordWrap
+ text: top.txt
+ }
+ Timer {
+ id: timer
+
+ interval: 1
+ running: true
+ repeat: true
+ onTriggered: {
+ top.txt = top.txt + "<br>more " + top.txt.length;
+ if (top.txt.length > 50)
+ running = false
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_cb.png b/tests/auto/declarative/qdeclarativetext/data/alignments_cb.png
new file mode 100644
index 0000000..99de219
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_cb.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png b/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png
new file mode 100644
index 0000000..cb85251
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png b/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png
new file mode 100644
index 0000000..ddca549
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_lb.png b/tests/auto/declarative/qdeclarativetext/data/alignments_lb.png
new file mode 100644
index 0000000..1b50a81
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_lb.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_lc.png b/tests/auto/declarative/qdeclarativetext/data/alignments_lc.png
new file mode 100644
index 0000000..f041b86
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_lc.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_lt.png b/tests/auto/declarative/qdeclarativetext/data/alignments_lt.png
new file mode 100644
index 0000000..c75e0d1
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_lt.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_rb.png b/tests/auto/declarative/qdeclarativetext/data/alignments_rb.png
new file mode 100644
index 0000000..b06a5da
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_rb.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_rc.png b/tests/auto/declarative/qdeclarativetext/data/alignments_rc.png
new file mode 100644
index 0000000..e468857
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_rc.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_rt.png b/tests/auto/declarative/qdeclarativetext/data/alignments_rt.png
new file mode 100644
index 0000000..576715f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetext/data/alignments_rt.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
index 01120b1..8a4f152 100644
--- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
+++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp
@@ -47,6 +47,7 @@
#include <QFontMetrics>
#include <QGraphicsSceneMouseEvent>
#include <qmath.h>
+#include <QDeclarativeView>
#include "../../../shared/util.h"
#include "testhttpserver.h"
@@ -70,6 +71,9 @@ private slots:
void elide();
void textFormat();
+ void alignments_data();
+ void alignments();
+
void embeddedImages_data();
void embeddedImages();
@@ -108,6 +112,8 @@ private:
QStringList colorStrings;
QDeclarativeEngine engine;
+
+ QDeclarativeView *createView(const QString &filename);
};
tst_qdeclarativetext::tst_qdeclarativetext()
@@ -163,6 +169,14 @@ tst_qdeclarativetext::tst_qdeclarativetext()
//
}
+QDeclarativeView *tst_qdeclarativetext::createView(const QString &filename)
+{
+ QDeclarativeView *canvas = new QDeclarativeView(0);
+
+ canvas->setSource(QUrl::fromLocalFile(filename));
+ return canvas;
+}
+
void tst_qdeclarativetext::text()
{
{
@@ -383,6 +397,65 @@ void tst_qdeclarativetext::textFormat()
}
}
+
+void tst_qdeclarativetext::alignments_data()
+{
+ QTest::addColumn<int>("hAlign");
+ QTest::addColumn<int>("vAlign");
+ QTest::addColumn<QString>("expectfile");
+
+ QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << SRCDIR "/data/alignments_lt.png";
+ QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << SRCDIR "/data/alignments_rt.png";
+ QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << SRCDIR "/data/alignments_ct.png";
+
+ QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_lb.png";
+ QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_rb.png";
+ QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_cb.png";
+
+ QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_lc.png";
+ QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_rc.png";
+ QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_cc.png";
+}
+
+
+void tst_qdeclarativetext::alignments()
+{
+ QFETCH(int, hAlign);
+ QFETCH(int, vAlign);
+ QFETCH(QString, expectfile);
+
+#ifdef Q_WS_X11
+ // Font-specific, but not likely platform-specific, so only test on one platform
+ QFont fn;
+ fn.setRawName("-misc-fixed-medium-r-*-*-8-*-*-*-*-*-*-*");
+ QApplication::setFont(fn);
+#endif
+
+ QDeclarativeView *canvas = createView(SRCDIR "/data/alignments.qml");
+
+ canvas->show();
+ QApplication::setActiveWindow(canvas);
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
+
+ QObject *ob = canvas->rootObject();
+ QVERIFY(ob != 0);
+ ob->setProperty("horizontalAlignment",hAlign);
+ ob->setProperty("verticalAlignment",vAlign);
+ QTRY_COMPARE(ob->property("running").toBool(),false);
+ QImage actual(canvas->width(), canvas->height(), QImage::Format_RGB32);
+ actual.fill(qRgb(255,255,255));
+ QPainter p(&actual);
+ canvas->render(&p);
+
+ QImage expect(expectfile);
+
+#ifdef Q_WS_X11
+ // Font-specific, but not likely platform-specific, so only test on one platform
+ QCOMPARE(actual,expect);
+#endif
+}
+
//the alignment tests may be trivial o.oa
void tst_qdeclarativetext::horizontalAlignment()
{
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments.qml b/tests/auto/declarative/qdeclarativetextedit/data/alignments.qml
new file mode 100644
index 0000000..b1f701b
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments.qml
@@ -0,0 +1,41 @@
+import Qt 4.7
+
+Rectangle {
+ id: top
+ width: 70; height: 70;
+
+ property alias horizontalAlignment: t.horizontalAlignment
+ property alias verticalAlignment: t.verticalAlignment
+ property alias wrapMode: t.wrapMode
+ property alias running: timer.running
+ property string txt: "Test"
+
+ Rectangle {
+ anchors.centerIn: parent
+ width: 40
+ height: 40
+ color: "green"
+
+ Text {
+ id: t
+
+ anchors.fill: parent
+ horizontalAlignment: TextEdit.AlignRight
+ verticalAlignment: TextEdit.AlignBottom
+ wrapMode: TextEdit.WordWrap
+ text: top.txt
+ }
+ Timer {
+ id: timer
+
+ interval: 1
+ running: true
+ repeat: true
+ onTriggered: {
+ top.txt = top.txt + "<br>more " + top.txt.length;
+ if (top.txt.length > 50)
+ running = false
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_cb.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_cb.png
new file mode 100644
index 0000000..99de219
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_cb.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_cc.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_cc.png
new file mode 100644
index 0000000..cb85251
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_cc.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_ct.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_ct.png
new file mode 100644
index 0000000..ddca549
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_ct.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_lb.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lb.png
new file mode 100644
index 0000000..1b50a81
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lb.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_lc.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lc.png
new file mode 100644
index 0000000..f041b86
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lc.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_lt.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lt.png
new file mode 100644
index 0000000..c75e0d1
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_lt.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_rb.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rb.png
new file mode 100644
index 0000000..b06a5da
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rb.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_rc.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rc.png
new file mode 100644
index 0000000..e468857
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rc.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetextedit/data/alignments_rt.png b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rt.png
new file mode 100644
index 0000000..576715f
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativetextedit/data/alignments_rt.png
Binary files differ
diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
index f7ba7a1..f1a367f 100644
--- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
+++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp
@@ -73,6 +73,8 @@ private slots:
void width();
void wrap();
void textFormat();
+ void alignments();
+ void alignments_data();
// ### these tests may be trivial
void hAlign();
@@ -297,6 +299,65 @@ void tst_qdeclarativetextedit::textFormat()
}
}
+void tst_qdeclarativetextedit::alignments_data()
+{
+ QTest::addColumn<int>("hAlign");
+ QTest::addColumn<int>("vAlign");
+ QTest::addColumn<QString>("expectfile");
+
+ QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << SRCDIR "/data/alignments_lt.png";
+ QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << SRCDIR "/data/alignments_rt.png";
+ QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << SRCDIR "/data/alignments_ct.png";
+
+ QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_lb.png";
+ QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_rb.png";
+ QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << SRCDIR "/data/alignments_cb.png";
+
+ QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_lc.png";
+ QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_rc.png";
+ QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << SRCDIR "/data/alignments_cc.png";
+}
+
+
+void tst_qdeclarativetextedit::alignments()
+{
+ QFETCH(int, hAlign);
+ QFETCH(int, vAlign);
+ QFETCH(QString, expectfile);
+
+#ifdef Q_WS_X11
+ // Font-specific, but not likely platform-specific, so only test on one platform
+ QFont fn;
+ fn.setRawName("-misc-fixed-medium-r-*-*-8-*-*-*-*-*-*-*");
+ QApplication::setFont(fn);
+#endif
+
+ QDeclarativeView *canvas = createView(SRCDIR "/data/alignments.qml");
+
+ canvas->show();
+ QApplication::setActiveWindow(canvas);
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
+
+ QObject *ob = canvas->rootObject();
+ QVERIFY(ob != 0);
+ ob->setProperty("horizontalAlignment",hAlign);
+ ob->setProperty("verticalAlignment",vAlign);
+ QTRY_COMPARE(ob->property("running").toBool(),false);
+ QImage actual(canvas->width(), canvas->height(), QImage::Format_RGB32);
+ actual.fill(qRgb(255,255,255));
+ QPainter p(&actual);
+ canvas->render(&p);
+
+ QImage expect(expectfile);
+
+#ifdef Q_WS_X11
+ // Font-specific, but not likely platform-specific, so only test on one platform
+ QCOMPARE(actual,expect);
+#endif
+}
+
+
//the alignment tests may be trivial o.oa
void tst_qdeclarativetextedit::hAlign()
{
diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
index f30f758..576f721 100644
--- a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
+++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp
@@ -43,6 +43,7 @@
#include <QtDeclarative/qdeclarativeengine.h>
#include <QtDeclarative/qdeclarativeview.h>
#include <QtDeclarative/qdeclarativeitem.h>
+#include <QtGui/qmenubar.h>
#include "../../../shared/util.h"
#include "qmlruntime.h"
#include "../../../shared/util.h"
@@ -52,6 +53,12 @@
#define SRCDIR "."
#endif
+#if defined(Q_OS_MAC) || defined(Q_WS_MAEMO_5) || defined(Q_WS_S60)
+# define MENUBAR_HEIGHT(mw) 0
+#else
+# define MENUBAR_HEIGHT(mw) (mw->menuBar()->height())
+#endif
+
class tst_QDeclarativeViewer : public QObject
{
@@ -77,45 +84,46 @@ tst_QDeclarativeViewer::tst_QDeclarativeViewer()
void tst_QDeclarativeViewer::orientation()
{
- QWidget window;
- QDeclarativeViewer *viewer = new QDeclarativeViewer(&window);
+ QDeclarativeViewer *viewer = new QDeclarativeViewer();
QVERIFY(viewer);
viewer->open(SRCDIR "/data/orientation.qml");
QVERIFY(viewer->view());
QVERIFY(viewer->menuBar());
QDeclarativeItem* rootItem = qobject_cast<QDeclarativeItem*>(viewer->view()->rootObject());
QVERIFY(rootItem);
- window.show();
+ viewer->show();
- QApplication::setActiveWindow(&window);
- QTest::qWaitForWindowShown(&window);
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&window));
+ QApplication::setActiveWindow(viewer);
+ QTest::qWaitForWindowShown(viewer);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(viewer));
QCOMPARE(rootItem->width(), 200.0);
QCOMPARE(rootItem->height(), 300.0);
QTRY_COMPARE(viewer->view()->size(), QSize(200, 300));
QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300));
- QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height()));
+ QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer)));
QCOMPARE(viewer->size(), viewer->sizeHint());
viewer->rotateOrientation();
qApp->processEvents();
+ qApp->processEvents(); // one extra round for the delayed updateSizeHints() call
QCOMPARE(rootItem->width(), 300.0);
QCOMPARE(rootItem->height(), 200.0);
QTRY_COMPARE(viewer->view()->size(), QSize(300, 200));
QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(300, 200));
- QCOMPARE(viewer->size(), QSize(300, 200+viewer->menuBar()->height()));
+ QCOMPARE(viewer->size(), QSize(300, 200 + MENUBAR_HEIGHT(viewer)));
QCOMPARE(viewer->size(), viewer->sizeHint());
viewer->rotateOrientation();
qApp->processEvents();
+ qApp->processEvents(); // one extra round for the delayed updateSizeHints() call
QCOMPARE(rootItem->width(), 200.0);
QCOMPARE(rootItem->height(), 300.0);
QTRY_COMPARE(viewer->view()->size(), QSize(200, 300));
QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300));
- QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height()));
+ QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer)));
QCOMPARE(viewer->size(), viewer->sizeHint());
}
@@ -249,7 +257,7 @@ void tst_QDeclarativeViewer::resizing()
QCOMPARE(viewer->view()->size(), QSize(200, 300));
QCOMPARE(viewer->view()->initialSize(), QSize(200, 300));
QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(200, 300));
- QCOMPARE(viewer->size(), QSize(200, 300+viewer->menuBar()->height()));
+ QCOMPARE(viewer->size(), QSize(200, 300 + MENUBAR_HEIGHT(viewer)));
QCOMPARE(viewer->size(), viewer->sizeHint());
viewer->setSizeToView(false);
@@ -261,7 +269,7 @@ void tst_QDeclarativeViewer::resizing()
QCOMPARE(rootItem->width(), 150.0);
QCOMPARE(rootItem->height(), 200.0);
- QCOMPARE(viewer->view()->size(), QSize(150, 200));
+ QTRY_COMPARE(viewer->view()->size(), QSize(150, 200));
QCOMPARE(viewer->view()->initialSize(), QSize(200, 300));
QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(150, 200));
QCOMPARE(viewer->size(), QSize(150, 200+viewer->menuBar()->height()));
@@ -279,7 +287,7 @@ void tst_QDeclarativeViewer::resizing()
QTRY_COMPARE(rootItem->width(), 250.0);
QTRY_COMPARE(rootItem->height(), 350.0-viewer->menuBar()->height());
- QCOMPARE(viewer->view()->size(), QSize(250, 350-viewer->menuBar()->height()));
+ QTRY_COMPARE(viewer->view()->size(), QSize(250, 350-viewer->menuBar()->height()));
QCOMPARE(viewer->view()->initialSize(), QSize(200, 300));
QCOMPARE(viewer->view()->sceneRect().size(), QSizeF(250, 350-viewer->menuBar()->height()));
QCOMPARE(viewer->size(), QSize(250, 350));
diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
index 90c9c6f..43d4d06 100644
--- a/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
+++ b/tests/auto/declarative/qdeclarativevisualdatamodel/tst_qdeclarativevisualdatamodel.cpp
@@ -173,10 +173,10 @@ void tst_qdeclarativevisualdatamodel::objectListModel()
QDeclarativeListView *listview = qobject_cast<QDeclarativeListView*>(view.rootObject());
QVERIFY(listview != 0);
- QDeclarativeItem *viewport = listview->viewport();
- QVERIFY(viewport != 0);
+ QDeclarativeItem *contentItem = listview->contentItem();
+ QVERIFY(contentItem != 0);
- QDeclarativeText *name = findItem<QDeclarativeText>(viewport, "name", 0);
+ QDeclarativeText *name = findItem<QDeclarativeText>(contentItem, "name", 0);
QCOMPARE(name->text(), QString("Item 1"));
dataList[0]->setProperty("name", QLatin1String("Changed"));
diff --git a/tests/benchmarks/declarative/script/data/block.qml b/tests/benchmarks/declarative/script/data/block.qml
index 4e5006e..f7b2ab3 100644
--- a/tests/benchmarks/declarative/script/data/block.qml
+++ b/tests/benchmarks/declarative/script/data/block.qml
@@ -47,7 +47,7 @@ Rectangle {
function doSomethingDirect() {
theObject.prop1 = 0;
- for (var i = 0; i < 60; ++i)
+ for (var i = 0; i < 1000; ++i)
theObject.prop1 += theObject.prop2;
theObject.prop3 = theObject.prop1;
@@ -57,7 +57,7 @@ Rectangle {
theObject.prop1 = 0;
var incrementObj = theObject;
- for (var i = 0; i < 60; ++i)
+ for (var i = 0; i < 1000; ++i)
incrementObj.prop1 += incrementObj.prop2;
incrementObj.prop3 = incrementObj.prop1;
@@ -67,7 +67,7 @@ Rectangle {
theObject.prop1 = 0;
var increment = theObject.prop2;
- for (var i = 0; i < 60; ++i)
+ for (var i = 0; i < 1000; ++i)
theObject.prop1 += increment;
theObject.prop3 = theObject.prop1;
diff --git a/tests/benchmarks/declarative/script/data/global.js b/tests/benchmarks/declarative/script/data/global.js
new file mode 100644
index 0000000..5b86b4d
--- /dev/null
+++ b/tests/benchmarks/declarative/script/data/global.js
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+var incVar = 1;
+var total;
+
+function doSomething() {
+ for (var i = 0; i < 10000; ++i)
+ Math.sin(90);
+}
+
+function doIncrement() {
+ total = 0;
+ for (var i = 0; i < 100000; ++i)
+ total += incVar;
+}
diff --git a/tests/benchmarks/declarative/script/data/global_prop.qml b/tests/benchmarks/declarative/script/data/global_prop.qml
new file mode 100644
index 0000000..4fb7ee7
--- /dev/null
+++ b/tests/benchmarks/declarative/script/data/global_prop.qml
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt 4.7
+import "global.js" as Program
+
+Rectangle {
+ width: 200; height: 200
+
+ signal triggered
+ signal incrementTriggered
+
+ onTriggered: Program.doSomething();
+ onIncrementTriggered: Program.doIncrement();
+}
diff --git a/tests/benchmarks/declarative/script/tst_script.cpp b/tests/benchmarks/declarative/script/tst_script.cpp
index 99f294c..5a7e151 100644
--- a/tests/benchmarks/declarative/script/tst_script.cpp
+++ b/tests/benchmarks/declarative/script/tst_script.cpp
@@ -92,7 +92,12 @@ private slots:
void block_data();
void block();
-private:
+
+ void global_property_js();
+ void global_property_qml();
+ void global_property_qml_js();
+
+ void scriptfile_property();
};
inline QUrl TEST_FILE(const QString &filename)
@@ -625,6 +630,74 @@ void tst_script::block()
delete rect;
}
+#define GLOBALPROPERTY_PROGRAM \
+ "(function() { " \
+ " for (var ii = 0; ii < 10000; ++ii) { " \
+ " Math.sin(90); " \
+ " } " \
+ "})"
+
+void tst_script::global_property_js()
+{
+ QScriptEngine engine;
+
+ QScriptValue prog = engine.evaluate(GLOBALPROPERTY_PROGRAM);
+ prog.call();
+
+ QBENCHMARK {
+ prog.call();
+ }
+}
+
+void tst_script::global_property_qml()
+{
+ QDeclarativeEngine qmlengine;
+
+ QScriptEngine *engine = QDeclarativeEnginePrivate::getScriptEngine(&qmlengine);
+ QScriptValue prog = engine->evaluate(GLOBALPROPERTY_PROGRAM);
+ prog.call();
+
+ QBENCHMARK {
+ prog.call();
+ }
+}
+
+void tst_script::global_property_qml_js()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, TEST_FILE("global_prop.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle *>(component.create());
+ QVERIFY(rect != 0);
+
+ int index = rect->metaObject()->indexOfMethod("triggered()");
+ QVERIFY(index != -1);
+ QMetaMethod method = rect->metaObject()->method(index);
+
+ QBENCHMARK {
+ method.invoke(rect, Qt::DirectConnection);
+ }
+
+ delete rect;
+}
+
+void tst_script::scriptfile_property()
+{
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine, TEST_FILE("global_prop.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle *>(component.create());
+ QVERIFY(rect != 0);
+
+ int index = rect->metaObject()->indexOfMethod("incrementTriggered()");
+ QVERIFY(index != -1);
+ QMetaMethod method = rect->metaObject()->method(index);
+
+ QBENCHMARK {
+ method.invoke(rect, Qt::DirectConnection);
+ }
+
+ delete rect;
+}
+
QTEST_MAIN(tst_script)
#include "tst_script.moc"
diff --git a/tools/linguist/lupdate/qdeclarative.cpp b/tools/linguist/lupdate/qdeclarative.cpp
index a734e99..2377416 100644
--- a/tools/linguist/lupdate/qdeclarative.cpp
+++ b/tools/linguist/lupdate/qdeclarative.cpp
@@ -87,27 +87,31 @@ protected:
virtual void endVisit(AST::CallExpression *node)
{
+ m_bSource.clear();
if (AST::IdentifierExpression *idExpr = AST::cast<AST::IdentifierExpression *>(node->base)) {
if (idExpr->name->asString() == QLatin1String("qsTr") ||
idExpr->name->asString() == QLatin1String("QT_TR_NOOP")) {
- if (node->arguments && AST::cast<AST::StringLiteral *>(node->arguments->expression)) {
- AST::StringLiteral *literal = AST::cast<AST::StringLiteral *>(node->arguments->expression);
- const QString source = literal->value->asString();
+ if (!node->arguments)
+ return;
+ AST::BinaryExpression *binary = AST::cast<AST::BinaryExpression *>(node->arguments->expression);
+ if (binary) {
+ if (!createString(binary))
+ m_bSource.clear();
+ }
+ AST::StringLiteral *literal = AST::cast<AST::StringLiteral *>(node->arguments->expression);
+ if (literal || !m_bSource.isEmpty()) {
+ const QString source = literal ? literal->value->asString() : m_bSource;
QString comment;
bool plural = false;
AST::ArgumentList *commentNode = node->arguments->next;
- if (commentNode) {
+ if (commentNode && AST::cast<AST::StringLiteral *>(commentNode->expression)) {
literal = AST::cast<AST::StringLiteral *>(commentNode->expression);
comment = literal->value->asString();
AST::ArgumentList *nNode = commentNode->next;
- if (nNode) {
- AST::NumericLiteral *numLiteral = AST::cast<AST::NumericLiteral *>(nNode->expression);
- if (numLiteral) {
- plural = true;
- }
- }
+ if (nNode)
+ plural = true;
}
TranslatorMessage msg(m_component, source,
@@ -126,22 +130,25 @@ protected:
QString comment;
bool plural = false;
AST::ArgumentList *sourceNode = node->arguments->next;
- if (sourceNode) {
- literal = AST::cast<AST::StringLiteral *>(sourceNode->expression);
- source = literal->value->asString();
- AST::ArgumentList *commentNode = sourceNode->next;
- if (commentNode) {
- literal = AST::cast<AST::StringLiteral *>(commentNode->expression);
- comment = literal->value->asString();
-
- AST::ArgumentList *nNode = commentNode->next;
- if (nNode) {
- AST::NumericLiteral *numLiteral = AST::cast<AST::NumericLiteral *>(nNode->expression);
- if (numLiteral) {
- plural = true;
- }
- }
- }
+ if (!sourceNode)
+ return;
+ literal = AST::cast<AST::StringLiteral *>(sourceNode->expression);
+ AST::BinaryExpression *binary = AST::cast<AST::BinaryExpression *>(sourceNode->expression);
+ if (binary) {
+ if (!createString(binary))
+ m_bSource.clear();
+ }
+ if (!literal && m_bSource.isEmpty())
+ return;
+ source = literal ? literal->value->asString() : m_bSource;
+ AST::ArgumentList *commentNode = sourceNode->next;
+ if (commentNode && AST::cast<AST::StringLiteral *>(commentNode->expression)) {
+ literal = AST::cast<AST::StringLiteral *>(commentNode->expression);
+ comment = literal->value->asString();
+
+ AST::ArgumentList *nNode = commentNode->next;
+ if (nNode)
+ plural = true;
}
TranslatorMessage msg(context, source,
@@ -156,9 +163,34 @@ protected:
}
private:
+ bool createString(AST::BinaryExpression *b) {
+ if (!b || b->op != 0)
+ return false;
+ AST::BinaryExpression *l = AST::cast<AST::BinaryExpression *>(b->left);
+ AST::BinaryExpression *r = AST::cast<AST::BinaryExpression *>(b->right);
+ AST::StringLiteral *ls = AST::cast<AST::StringLiteral *>(b->left);
+ AST::StringLiteral *rs = AST::cast<AST::StringLiteral *>(b->right);
+ if ((!l && !ls) || (!r && !rs))
+ return false;
+ if (l) {
+ if (!createString(l))
+ return false;
+ } else
+ m_bSource.prepend(ls->value->asString());
+
+ if (r) {
+ if (!createString(r))
+ return false;
+ } else
+ m_bSource.append(rs->value->asString());
+
+ return true;
+ }
+
Translator *m_translator;
QString m_fileName;
QString m_component;
+ QString m_bSource;
};
QString createErrorString(const QString &filename, const QString &code, Parser &parser)
diff --git a/tools/qml/deviceorientation_maemo.cpp b/tools/qml/deviceorientation_maemo5.cpp
index 443edc8..e942579 100644
--- a/tools/qml/deviceorientation_maemo.cpp
+++ b/tools/qml/deviceorientation_maemo5.cpp
@@ -124,4 +124,4 @@ DeviceOrientation* DeviceOrientation::instance()
return o;
}
-#include "deviceorientation_maemo.moc"
+#include "deviceorientation_maemo5.moc"
diff --git a/tools/qml/loggerwidget.cpp b/tools/qml/loggerwidget.cpp
index 3ae2b5e..8aa029f 100644
--- a/tools/qml/loggerwidget.cpp
+++ b/tools/qml/loggerwidget.cpp
@@ -39,29 +39,48 @@
**
****************************************************************************/
-#include "loggerwidget.h"
#include <qglobal.h>
#include <QDebug>
#include <QSettings>
#include <QActionGroup>
#include <QMenu>
+#include <QPlainTextEdit>
+#ifdef Q_WS_MAEMO_5
+# include <QScrollArea>
+# include <QVBoxLayout>
+# include "texteditautoresizer_maemo5.h"
+#endif
+
+#include "loggerwidget.h"
QT_BEGIN_NAMESPACE
LoggerWidget::LoggerWidget(QWidget *parent) :
- QPlainTextEdit(parent),
+ QMainWindow(parent),
m_visibilityOrigin(SettingsOrigin)
{
setAttribute(Qt::WA_QuitOnClose, false);
setWindowTitle(tr("Warnings"));
+ m_plainTextEdit = new QPlainTextEdit();
+
+#ifdef Q_WS_MAEMO_5
+ new TextEditAutoResizer(m_plainTextEdit);
+ setAttribute(Qt::WA_Maemo5StackedWindow);
+ QScrollArea *area = new QScrollArea();
+ area->setWidget(m_plainTextEdit);
+ area->setWidgetResizable(true);
+ setCentralWidget(area);
+#else
+ setCentralWidget(m_plainTextEdit);
+#endif
readSettings();
setupPreferencesMenu();
}
void LoggerWidget::append(const QString &msg)
{
- appendPlainText(msg);
+ m_plainTextEdit->appendPlainText(msg);
if (!isVisible() && (defaultVisibility() == AutoShowWarnings))
setVisible(true);
diff --git a/tools/qml/loggerwidget.h b/tools/qml/loggerwidget.h
index fd20c41..13c319f 100644
--- a/tools/qml/loggerwidget.h
+++ b/tools/qml/loggerwidget.h
@@ -42,12 +42,17 @@
#ifndef LOGGERWIDGET_H
#define LOGGERWIDGET_H
-#include <QPlainTextEdit>
+#include <QMainWindow>
+#include <QMetaType>
QT_BEGIN_NAMESPACE
-class LoggerWidget : public QPlainTextEdit {
-Q_OBJECT
+class QPlainTextEdit;
+class QMenu;
+class QAction;
+
+class LoggerWidget : public QMainWindow {
+ Q_OBJECT
public:
LoggerWidget(QWidget *parent=0);
@@ -80,6 +85,7 @@ private:
QMenu *m_preferencesMenu;
QAction *m_showWidgetAction;
+ QPlainTextEdit *m_plainTextEdit;
enum ConfigOrigin { CommandLineOrigin, SettingsOrigin };
ConfigOrigin m_visibilityOrigin;
diff --git a/tools/qml/proxysettings.cpp b/tools/qml/proxysettings.cpp
index 3255e42..ffaa4c0 100644
--- a/tools/qml/proxysettings.cpp
+++ b/tools/qml/proxysettings.cpp
@@ -48,11 +48,14 @@
QT_BEGIN_NAMESPACE
ProxySettings::ProxySettings (QWidget * parent)
- : QDialog (parent), Ui::ProxySettings()
+ : QDialog (parent), Ui::ProxySettings()
{
setupUi (this);
+#if !defined Q_WS_MAEMO_5
+ // the onscreen keyboard can't cope with masks
proxyServerEdit->setInputMask ("000.000.000.000;_");
+#endif
QIntValidator *validator = new QIntValidator (0, 9999, this);
proxyPortEdit->setValidator (validator);
diff --git a/tools/qml/proxysettings.h b/tools/qml/proxysettings.h
index 325929a..5d4d137 100644
--- a/tools/qml/proxysettings.h
+++ b/tools/qml/proxysettings.h
@@ -44,7 +44,11 @@
#include <QDialog>
#include <QNetworkProxy>
+#ifdef Q_WS_MAEMO_5
+#include "ui_proxysettings_maemo5.h"
+#else
#include "ui_proxysettings.h"
+#endif
QT_BEGIN_NAMESPACE
/**
diff --git a/tools/qml/proxysettings_maemo5.ui b/tools/qml/proxysettings_maemo5.ui
new file mode 100644
index 0000000..83f0c2a
--- /dev/null
+++ b/tools/qml/proxysettings_maemo5.ui
@@ -0,0 +1,177 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ProxySettings</class>
+ <widget class="QDialog" name="ProxySettings">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>449</width>
+ <height>164</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>HTTP Proxy</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <property name="leftMargin">
+ <number>16</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>16</number>
+ </property>
+ <property name="bottomMargin">
+ <number>8</number>
+ </property>
+ <property name="horizontalSpacing">
+ <number>16</number>
+ </property>
+ <property name="verticalSpacing">
+ <number>0</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QCheckBox" name="proxyCheckBox">
+ <property name="text">
+ <string>Use HTTP Proxy</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" rowspan="2">
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="0" rowspan="2">
+ <widget class="QWidget" name="widget" native="true">
+ <layout class="QGridLayout" name="gridLayout">
+ <property name="horizontalSpacing">
+ <number>16</number>
+ </property>
+ <property name="verticalSpacing">
+ <number>0</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="serverAddressLabel">
+ <property name="text">
+ <string>Server</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="proxyServerEdit">
+ <property name="placeholderText">
+ <string>Name or IP</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Port</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="proxyPortEdit">
+ <property name="text">
+ <string>8080</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="usernameLabel">
+ <property name="text">
+ <string>Username</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLineEdit" name="usernameEdit"/>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="passwordLabel">
+ <property name="text">
+ <string>Password</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QLineEdit" name="passwordEdit">
+ <property name="echoMode">
+ <enum>QLineEdit::Password</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <tabstops>
+ <tabstop>proxyCheckBox</tabstop>
+ <tabstop>proxyServerEdit</tabstop>
+ <tabstop>proxyPortEdit</tabstop>
+ <tabstop>usernameEdit</tabstop>
+ <tabstop>passwordEdit</tabstop>
+ <tabstop>buttonBox</tabstop>
+ </tabstops>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>ProxySettings</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>318</x>
+ <y>100</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>116</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>ProxySettings</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>318</x>
+ <y>100</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>116</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/tools/qml/qml.pri b/tools/qml/qml.pri
index 58d8cc1..3e5a88b 100644
--- a/tools/qml/qml.pri
+++ b/tools/qml/qml.pri
@@ -19,10 +19,12 @@ SOURCES += $$PWD/qmlruntime.cpp \
RESOURCES = $$PWD/qmlruntime.qrc
maemo5 {
QT += dbus
- SOURCES += $$PWD/deviceorientation_maemo.cpp
+ HEADERS += $$PWD/texteditautoresizer_maemo5.h
+ SOURCES += $$PWD/deviceorientation_maemo5.cpp
+ FORMS = $$PWD/recopts_maemo5.ui \
+ $$PWD/proxysettings_maemo5.ui
} else {
SOURCES += $$PWD/deviceorientation.cpp
+ FORMS = $$PWD/recopts.ui \
+ $$PWD/proxysettings.ui
}
-
-FORMS = $$PWD/recopts.ui \
- $$PWD/proxysettings.ui
diff --git a/tools/qml/qml.pro b/tools/qml/qml.pro
index 9cdec77..63efff1 100644
--- a/tools/qml/qml.pro
+++ b/tools/qml/qml.pro
@@ -29,6 +29,9 @@ wince* {
QT += webkit
}
}
+maemo5 {
+ QT += maemo5
+}
symbian {
TARGET.UID3 = 0x20021317
include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri)
diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp
index 676881d..2cca262 100644
--- a/tools/qml/qmlruntime.cpp
+++ b/tools/qml/qmlruntime.cpp
@@ -44,7 +44,15 @@
#ifdef hz
#undef hz
#endif
-#include "ui_recopts.h"
+#ifdef Q_WS_MAEMO_5
+# include <QMaemo5ValueButton>
+# include <QMaemo5ListPickSelector>
+# include <QWidgetAction>
+# include <QStringListModel>
+# include "ui_recopts_maemo5.h"
+#else
+# include "ui_recopts.h"
+#endif
#include "qmlruntime.h"
#include <qdeclarativecontext.h>
@@ -136,24 +144,59 @@ private:
};
-class SizedMenuBar : public QMenuBar
-{
+
+#if defined(Q_WS_MAEMO_5)
+
+class Maemo5PickerAction : public QWidgetAction {
Q_OBJECT
public:
- SizedMenuBar(QWidget *parent, QWidget *referenceWidget)
- : QMenuBar(parent), refWidget(referenceWidget)
+ Maemo5PickerAction(const QString &text, QActionGroup *actions, QObject *parent)
+ : QWidgetAction(parent), m_text(text), m_actions(actions)
+ { }
+
+ QWidget *createWidget(QWidget *parent)
{
+ QMaemo5ValueButton *button = new QMaemo5ValueButton(m_text, parent);
+ button->setValueLayout(QMaemo5ValueButton::ValueUnderTextCentered);
+ QMaemo5ListPickSelector *pick = new QMaemo5ListPickSelector(button);
+ button->setPickSelector(pick);
+ if (m_actions) {
+ QStringList sl;
+ int curIdx = -1, idx = 0;
+ foreach (QAction *a, m_actions->actions()) {
+ sl << a->text();
+ if (a->isChecked())
+ curIdx = idx;
+ idx++;
+ }
+ pick->setModel(new QStringListModel(sl));
+ pick->setCurrentIndex(curIdx);
+ } else {
+ button->setEnabled(false);
+ }
+ connect(pick, SIGNAL(selected(QString)), this, SLOT(emitTriggered()));
+ return button;
}
- virtual QSize sizeHint() const
+private slots:
+ void emitTriggered()
{
- return QSize(refWidget->sizeHint().width(), QMenuBar::sizeHint().height());
+ QMaemo5ListPickSelector *pick = qobject_cast<QMaemo5ListPickSelector *>(sender());
+ if (!pick)
+ return;
+ int idx = pick->currentIndex();
+
+ if (m_actions && idx >= 0 && idx < m_actions->actions().count())
+ m_actions->actions().at(idx)->trigger();
}
private:
- QWidget *refWidget;
+ QString m_text;
+ QPointer<QActionGroup> m_actions;
};
+#endif // Q_WS_MAEMO_5
+
static struct { const char *name, *args; } ffmpegprofiles[] = {
{"Maximum Quality", "-sameq"},
{"High Quality", "-qmax 2"},
@@ -170,7 +213,9 @@ public:
RecordingDialog(QWidget *parent) : QDialog(parent)
{
setupUi(this);
+#ifndef Q_WS_MAEMO_5
hz->setValidator(new QDoubleValidator(hz));
+#endif
for (int i=0; ffmpegprofiles[i].name; ++i) {
profile->addItem(ffmpegprofiles[i].name);
}
@@ -197,6 +242,132 @@ public:
return ffmpegprofiles[i].args[0] ? QLatin1String(ffmpegprofiles[i].args) : customargs;
}
+ void setOriginalSize(const QSize &s)
+ {
+ QString str = tr("Original (%1x%2)").arg(s.width()).arg(s.height());
+
+#ifdef Q_WS_MAEMO_5
+ sizeCombo->setItemText(0, str);
+#else
+ sizeOriginal->setText(str);
+ if (sizeWidth->value()<=1) {
+ sizeWidth->setValue(s.width());
+ sizeHeight->setValue(s.height());
+ }
+#endif
+ }
+
+ void showffmpegOptions(bool b)
+ {
+#ifdef Q_WS_MAEMO_5
+ profileLabel->setVisible(b);
+ profile->setVisible(b);
+ ffmpegHelp->setVisible(b);
+ args->setVisible(b);
+#else
+ ffmpegOptions->setVisible(b);
+#endif
+ }
+
+ void showRateOptions(bool b)
+ {
+#ifdef Q_WS_MAEMO_5
+ rateLabel->setVisible(b);
+ rateCombo->setVisible(b);
+#else
+ rateOptions->setVisible(b);
+#endif
+ }
+
+ void setVideoRate(int rate)
+ {
+#ifdef Q_WS_MAEMO_5
+ int idx;
+ if (rate >= 60)
+ idx = 0;
+ else if (rate >= 50)
+ idx = 2;
+ else if (rate >= 25)
+ idx = 3;
+ else if (rate >= 24)
+ idx = 4;
+ else if (rate >= 20)
+ idx = 5;
+ else if (rate >= 15)
+ idx = 6;
+ else
+ idx = 7;
+ rateCombo->setCurrentIndex(idx);
+#else
+ if (rate == 24)
+ hz24->setChecked(true);
+ else if (rate == 25)
+ hz25->setChecked(true);
+ else if (rate == 50)
+ hz50->setChecked(true);
+ else if (rate == 60)
+ hz60->setChecked(true);
+ else {
+ hzCustom->setChecked(true);
+ hz->setText(QString::number(rate));
+ }
+#endif
+ }
+
+ int videoRate() const
+ {
+#ifdef Q_WS_MAEMO_5
+ switch (rateCombo->currentIndex()) {
+ case 0: return 60;
+ case 1: return 50;
+ case 2: return 25;
+ case 3: return 24;
+ case 4: return 20;
+ case 5: return 15;
+ case 7: return 10;
+ default: return 60;
+ }
+#else
+ if (hz24->isChecked())
+ return 24;
+ else if (hz25->isChecked())
+ return 25;
+ else if (hz50->isChecked())
+ return 50;
+ else if (hz60->isChecked())
+ return 60;
+ else {
+ return hz->text().toInt();
+ }
+#endif
+ }
+
+ QSize videoSize() const
+ {
+#ifdef Q_WS_MAEMO_5
+ switch (sizeCombo->currentIndex()) {
+ case 0: return QSize();
+ case 1: return QSize(640,480);
+ case 2: return QSize(320,240);
+ case 3: return QSize(1280,720);
+ default: return QSize();
+ }
+#else
+ if (sizeOriginal->isChecked())
+ return QSize();
+ else if (size720p->isChecked())
+ return QSize(1280,720);
+ else if (sizeVGA->isChecked())
+ return QSize(640,480);
+ else if (sizeQVGA->isChecked())
+ return QSize(320,240);
+ else
+ return QSize(sizeWidth->value(), sizeHeight->value());
+#endif
+ }
+
+
+
private slots:
void pickProfile(int i)
{
@@ -363,15 +534,10 @@ QString QDeclarativeViewer::getVideoFileName()
return QFileDialog::getSaveFileName(this, title, "", types.join(";; "));
}
-
QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
-#if defined(Q_OS_SYMBIAN)
: QMainWindow(parent, flags)
-#else
- : QWidget(parent, flags)
-#endif
- , loggerWindow(new LoggerWidget())
- , frame_stream(0), mb(0)
+ , loggerWindow(new LoggerWidget(this))
+ , frame_stream(0)
, orientation(0)
, showWarningsWindow(0)
, m_scriptOptions(0)
@@ -381,6 +547,10 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
{
QDeclarativeViewer::registerTypes();
setWindowTitle(tr("Qt QML Viewer"));
+#ifdef Q_WS_MAEMO_5
+ setAttribute(Qt::WA_Maemo5StackedWindow);
+// setPalette(QApplication::palette("QLabel"));
+#endif
devicemode = false;
canvas = 0;
@@ -393,9 +563,9 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
senseFfmpeg();
senseImageMagick();
if (!ffmpegAvailable)
- recdlg->ffmpegOptions->hide();
+ recdlg->showffmpegOptions(false);
if (!ffmpegAvailable && !convertAvailable)
- recdlg->rateOptions->hide();
+ recdlg->showRateOptions(false);
QString warn;
if (!ffmpegAvailable) {
if (!convertAvailable)
@@ -422,21 +592,14 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
QObject::connect(warningsWidget(), SIGNAL(closed()), this, SLOT(warningsWidgetClosed()));
if (!(flags & Qt::FramelessWindowHint)) {
- createMenu(menuBar(),0);
+ createMenu();
changeOrientation(orientation->actions().value(0));
+ } else {
+ setMenuBar(0);
}
-#if !defined(Q_OS_SYMBIAN)
- QVBoxLayout *layout = new QVBoxLayout;
- layout->setMargin(0);
- layout->setSpacing(0);
- setLayout(layout);
- if (mb)
- layout->addWidget(mb);
- layout->addWidget(canvas);
-#else
setCentralWidget(canvas);
-#endif
+
namFactory = new NetworkAccessManagerFactory;
canvas->engine()->setNetworkAccessManagerFactory(namFactory);
@@ -449,6 +612,8 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
autoStopTimer.setRunning(false);
recordTimer.setRunning(false);
recordTimer.setRepeating(true);
+
+ QObject::connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(appAboutToQuit()));
}
QDeclarativeViewer::~QDeclarativeViewer()
@@ -468,26 +633,6 @@ void QDeclarativeViewer::enableExperimentalGestures()
canvas->viewport()->setAttribute(Qt::WA_AcceptTouchEvents);
}
-int QDeclarativeViewer::menuBarHeight() const
-{
- if (!(windowFlags() & Qt::FramelessWindowHint))
- return menuBar()->height();
- else
- return 0; // don't create menu
-}
-
-QMenuBar *QDeclarativeViewer::menuBar() const
-{
-#if !defined(Q_OS_SYMBIAN)
- if (!mb)
- mb = new SizedMenuBar((QWidget*)this, canvas);
-#else
- mb = QMainWindow::menuBar();
-#endif
-
- return mb;
-}
-
QDeclarativeView *QDeclarativeViewer::view() const
{
return canvas;
@@ -498,120 +643,128 @@ LoggerWidget *QDeclarativeViewer::warningsWidget() const
return loggerWindow;
}
-void QDeclarativeViewer::createMenu(QMenuBar *menu, QMenu *flatmenu)
+void QDeclarativeViewer::createMenu()
{
- QObject *parent = flatmenu ? (QObject*)flatmenu : (QObject*)menu;
-
- QMenu *fileMenu = flatmenu ? flatmenu : menu->addMenu(tr("&File"));
-
- QAction *openAction = new QAction(tr("&Open..."), parent);
+ QAction *openAction = new QAction(tr("&Open..."), this);
openAction->setShortcut(QKeySequence("Ctrl+O"));
connect(openAction, SIGNAL(triggered()), this, SLOT(openFile()));
- fileMenu->addAction(openAction);
- QAction *reloadAction = new QAction(tr("&Reload"), parent);
+ QAction *reloadAction = new QAction(tr("&Reload"), this);
reloadAction->setShortcut(QKeySequence("Ctrl+R"));
connect(reloadAction, SIGNAL(triggered()), this, SLOT(reload()));
- fileMenu->addAction(reloadAction);
-
-#if !defined(Q_OS_SYMBIAN)
- if (flatmenu) flatmenu->addSeparator();
- QMenu *recordMenu = flatmenu ? flatmenu : menu->addMenu(tr("&Recording"));
-
- QAction *snapshotAction = new QAction(tr("&Take Snapshot\tF3"), parent);
+ QAction *snapshotAction = new QAction(tr("&Take Snapshot"), this);
+ snapshotAction->setShortcut(QKeySequence("F3"));
connect(snapshotAction, SIGNAL(triggered()), this, SLOT(takeSnapShot()));
- recordMenu->addAction(snapshotAction);
- recordAction = new QAction(tr("Start Recording &Video\tF9"), parent);
+ recordAction = new QAction(tr("Start Recording &Video"), this);
+ recordAction->setShortcut(QKeySequence("F9"));
connect(recordAction, SIGNAL(triggered()), this, SLOT(toggleRecordingWithSelection()));
- recordMenu->addAction(recordAction);
- QAction *recordOptions = new QAction(tr("Video &Options..."), parent);
+ QAction *recordOptions = new QAction(tr("Video &Options..."), this);
connect(recordOptions, SIGNAL(triggered()), this, SLOT(chooseRecordingOptions()));
- if (flatmenu)
- flatmenu->addAction(recordOptions);
-
- if (flatmenu) flatmenu->addSeparator();
-
- QMenu *debugMenu = flatmenu ? flatmenu->addMenu(tr("&Debugging")) : menu->addMenu(tr("&Debugging"));
-
- QAction *slowAction = new QAction(tr("&Slow Down Animations"), parent);
+ QAction *slowAction = new QAction(tr("&Slow Down Animations"), this);
slowAction->setShortcut(QKeySequence("Ctrl+."));
slowAction->setCheckable(true);
connect(slowAction, SIGNAL(triggered(bool)), this, SLOT(setSlowMode(bool)));
- debugMenu->addAction(slowAction);
- showWarningsWindow = new QAction(tr("Show Warnings"), parent);
+ showWarningsWindow = new QAction(tr("Show Warnings"), this);
showWarningsWindow->setCheckable((true));
showWarningsWindow->setChecked(loggerWindow->isVisible());
connect(showWarningsWindow, SIGNAL(triggered(bool)), this, SLOT(showWarnings(bool)));
-#if !defined(Q_OS_SYMBIAN)
- debugMenu->addAction(showWarningsWindow);
-#endif
-
- if (flatmenu) flatmenu->addSeparator();
-
-#endif // Q_OS_SYMBIAN
-
- QMenu *settingsMenu = flatmenu ? flatmenu : menu->addMenu(tr("S&ettings"));
- QAction *proxyAction = new QAction(tr("Http &proxy..."), parent);
+ QAction *proxyAction = new QAction(tr("HTTP &Proxy..."), this);
connect(proxyAction, SIGNAL(triggered()), this, SLOT(showProxySettings()));
- settingsMenu->addAction(proxyAction);
-#if !defined(Q_OS_SYMBIAN)
- if (!flatmenu)
- settingsMenu->addAction(recordOptions);
- settingsMenu->addMenu(loggerWindow->preferencesMenu());
-#else
- QAction *fullscreenAction = new QAction(tr("Full Screen"), parent);
+ QAction *fullscreenAction = new QAction(tr("Full Screen"), this);
fullscreenAction->setCheckable(true);
connect(fullscreenAction, SIGNAL(triggered()), this, SLOT(toggleFullScreen()));
- settingsMenu->addAction(fullscreenAction);
-#endif
-
- if (flatmenu) flatmenu->addSeparator();
-
- QMenu *propertiesMenu = settingsMenu->addMenu(tr("Properties"));
- orientation = new QActionGroup(parent);
-
- QAction *rotateOrientation = new QAction(tr("Rotate orientation"), parent);
+ QAction *rotateOrientation = new QAction(tr("Rotate orientation"), this);
rotateOrientation->setShortcut(QKeySequence("Ctrl+T"));
- settingsMenu->addAction(rotateOrientation);
connect(rotateOrientation, SIGNAL(triggered()), this, SLOT(rotateOrientation()));
+ orientation = new QActionGroup(this);
orientation->setExclusive(true);
connect(orientation, SIGNAL(triggered(QAction*)), this, SLOT(changeOrientation(QAction*)));
- orientation->addAction(tr("orientation: Portrait"));
- orientation->addAction(tr("orientation: Landscape"));
- orientation->addAction(tr("orientation: Portrait (Inverted)"));
- orientation->addAction(tr("orientation: Landscape (Inverted)"));
- QList<QAction *> actions = orientation->actions();
- for (int i=0; i<actions.count(); i++) {
- propertiesMenu->addAction(actions[i]);
- actions[i]->setCheckable(true);
- }
-
- if (flatmenu) flatmenu->addSeparator();
+ QAction *portraitAction = new QAction(tr("Portrait"), this);
+ portraitAction->setCheckable(true);
+ QAction *landscapeAction = new QAction(tr("Landscape"), this);
+ landscapeAction->setCheckable(true);
+ QAction *portraitInvAction = new QAction(tr("Portrait (inverted)"), this);
+ portraitInvAction->setCheckable(true);
+ QAction *landscapeInvAction = new QAction(tr("Landscape (inverted)"), this);
+ landscapeInvAction->setCheckable(true);
- QMenu *helpMenu = flatmenu ? flatmenu : menu->addMenu(tr("&Help"));
- QAction *aboutAction = new QAction(tr("&About Qt..."), parent);
+ QAction *aboutAction = new QAction(tr("&About Qt..."), this);
connect(aboutAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
- helpMenu->addAction(aboutAction);
- QAction *quitAction = new QAction(tr("&Quit"), parent);
+ QAction *quitAction = new QAction(tr("&Quit"), this);
quitAction->setShortcut(QKeySequence("Ctrl+Q"));
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
+
+ QMenuBar *menu = menuBar();
+ if (!menu)
+ return;
+
+#if defined(Q_WS_MAEMO_5)
+ menu->addAction(openAction);
+ menu->addAction(reloadAction);
+
+ menu->addAction(snapshotAction);
+ menu->addAction(recordAction);
+
+ menu->addAction(recordOptions);
+ menu->addAction(proxyAction);
+
+ menu->addAction(slowAction);
+ menu->addAction(showWarningsWindow);
+
+ orientation->addAction(landscapeAction);
+ orientation->addAction(portraitAction);
+ menu->addAction(new Maemo5PickerAction(tr("Set orientation"), orientation, this));
+ menu->addAction(fullscreenAction);
+ return;
+#endif // Q_WS_MAEMO_5
+
+ QMenu *fileMenu = menu->addMenu(tr("&File"));
+ fileMenu->addAction(openAction);
+ fileMenu->addAction(reloadAction);
fileMenu->addSeparator();
fileMenu->addAction(quitAction);
- if (menu) {
- menu->setFixedHeight(menu->sizeHint().height());
- menu->setMinimumWidth(10);
- }
+
+#if !defined(Q_OS_SYMBIAN)
+ QMenu *recordMenu = menu->addMenu(tr("&Recording"));
+ recordMenu->addAction(snapshotAction);
+ recordMenu->addAction(recordAction);
+
+ QMenu *debugMenu = menu->addMenu(tr("&Debugging"));
+ debugMenu->addAction(slowAction);
+ debugMenu->addAction(showWarningsWindow);
+#endif // ! Q_OS_SYMBIAN
+
+ QMenu *settingsMenu = menu->addMenu(tr("S&ettings"));
+ settingsMenu->addAction(proxyAction);
+#if !defined(Q_OS_SYMBIAN)
+ settingsMenu->addAction(recordOptions);
+ settingsMenu->addMenu(loggerWindow->preferencesMenu());
+#else // ! Q_OS_SYMBIAN
+ settingsMenu->addAction(fullscreenAction);
+#endif // Q_OS_SYMBIAN
+ settingsMenu->addAction(rotateOrientation);
+
+ QMenu *propertiesMenu = settingsMenu->addMenu(tr("Properties"));
+
+ orientation->addAction(portraitAction);
+ orientation->addAction(landscapeAction);
+ orientation->addAction(portraitInvAction);
+ orientation->addAction(landscapeInvAction);
+ propertiesMenu->addActions(orientation->actions());
+
+ QMenu *helpMenu = menu->addMenu(tr("&Help"));
+ helpMenu->addAction(aboutAction);
}
void QDeclarativeViewer::showProxySettings()
@@ -685,25 +838,11 @@ void QDeclarativeViewer::chooseRecordingOptions()
recdlg->file->setText(record_file);
// Size
- recdlg->sizeOriginal->setText(tr("Original (%1x%2)").arg(canvas->width()).arg(canvas->height()));
- if (recdlg->sizeWidth->value()<=1) {
- recdlg->sizeWidth->setValue(canvas->width());
- recdlg->sizeHeight->setValue(canvas->height());
- }
+ recdlg->setOriginalSize(canvas->size());
// Rate
- if (record_rate == 24)
- recdlg->hz24->setChecked(true);
- else if (record_rate == 25)
- recdlg->hz25->setChecked(true);
- else if (record_rate == 50)
- recdlg->hz50->setChecked(true);
- else if (record_rate == 60)
- recdlg->hz60->setChecked(true);
- else {
- recdlg->hzCustom->setChecked(true);
- recdlg->hz->setText(QString::number(record_rate));
- }
+ recdlg->setVideoRate(record_rate);
+
// Profile
recdlg->setArguments(record_args.join(" "));
@@ -711,28 +850,9 @@ void QDeclarativeViewer::chooseRecordingOptions()
// File
record_file = recdlg->file->text();
// Size
- if (recdlg->sizeOriginal->isChecked())
- record_outsize = QSize();
- else if (recdlg->size720p->isChecked())
- record_outsize = QSize(1280,720);
- else if (recdlg->sizeVGA->isChecked())
- record_outsize = QSize(640,480);
- else if (recdlg->sizeQVGA->isChecked())
- record_outsize = QSize(320,240);
- else
- record_outsize = QSize(recdlg->sizeWidth->value(),recdlg->sizeHeight->value());
+ record_outsize = recdlg->videoSize();
// Rate
- if (recdlg->hz24->isChecked())
- record_rate = 24;
- else if (recdlg->hz25->isChecked())
- record_rate = 25;
- else if (recdlg->hz50->isChecked())
- record_rate = 50;
- else if (recdlg->hz60->isChecked())
- record_rate = 60;
- else {
- record_rate = recdlg->hz->text().toDouble();
- }
+ record_rate = recdlg->videoRate();
// Profile
record_args = recdlg->arguments().split(" ",QString::SkipEmptyParts);
}
@@ -807,8 +927,9 @@ void QDeclarativeViewer::statusChanged()
initialSize = canvas->initialSize();
if (canvas->resizeMode() == QDeclarativeView::SizeRootObjectToView) {
if (!isFullScreen() && !isMaximized()) {
- resize(QSize(initialSize.width(), initialSize.height()+menuBarHeight()));
- updateSizeHints();
+ canvas->setFixedSize(initialSize);
+ resize(1, 1); // workaround for QMainWindowLayout NOT shrinking the window if the centralWidget() shrink
+ QTimer::singleShot(0, this, SLOT(updateSizeHints()));
}
}
}
@@ -1147,6 +1268,16 @@ void QDeclarativeViewer::ffmpegFinished(int code)
qDebug() << "ffmpeg returned" << code << frame_stream->readAllStandardError();
}
+void QDeclarativeViewer::appAboutToQuit()
+{
+ // avoid QGLContext errors about invalid contexts on exit
+ canvas->setViewport(0);
+
+ // avoid crashes if messages are received after app has closed
+ delete loggerWindow;
+ loggerWindow = 0;
+}
+
void QDeclarativeViewer::autoStartRecording()
{
setRecording(true);
@@ -1181,14 +1312,14 @@ void QDeclarativeViewer::changeOrientation(QAction *action)
return;
action->setChecked(true);
- QString o = action->text().split(QLatin1Char(':')).value(1).trimmed();
+ QString o = action->text();
if (o == QLatin1String("Portrait"))
DeviceOrientation::instance()->setOrientation(DeviceOrientation::Portrait);
else if (o == QLatin1String("Landscape"))
DeviceOrientation::instance()->setOrientation(DeviceOrientation::Landscape);
- else if (o == QLatin1String("Portrait (Inverted)"))
+ else if (o == QLatin1String("Portrait (inverted)"))
DeviceOrientation::instance()->setOrientation(DeviceOrientation::PortraitInverted);
- else if (o == QLatin1String("Landscape (Inverted)"))
+ else if (o == QLatin1String("Landscape (inverted)"))
DeviceOrientation::instance()->setOrientation(DeviceOrientation::LandscapeInverted);
}
@@ -1197,9 +1328,10 @@ void QDeclarativeViewer::orientationChanged()
if (canvas->resizeMode() == QDeclarativeView::SizeRootObjectToView) {
if (canvas->rootObject()) {
QSizeF rootObjectSize = canvas->rootObject()->boundingRect().size();
- QSize newSize(rootObjectSize.width(), rootObjectSize.height()+menuBarHeight());
- if (size() != newSize) {
- resize(newSize);
+ if (size() != rootObjectSize.toSize()) {
+ canvas->setMinimumSize(rootObjectSize.toSize());
+ canvas->resize(rootObjectSize.toSize());
+ resize(1, 1); // workaround for QMainWindowLayout NOT shrinking the window if the centralWidget() shrinks
}
}
}
@@ -1253,16 +1385,15 @@ void QDeclarativeViewer::updateSizeHints()
{
if (canvas->resizeMode() == QDeclarativeView::SizeViewToRootObject) {
QSize newWindowSize = canvas->sizeHint();
- newWindowSize.setHeight(newWindowSize.height()+menuBarHeight());
if (!isFullScreen() && !isMaximized()) {
- resize(newWindowSize);
- setFixedSize(newWindowSize);
+ canvas->setMinimumSize(newWindowSize);
+ canvas->resize(newWindowSize);
+ resize(1, 1); // workaround for QMainWindowLayout NOT shrinking the window if the centralWidget() shrinks
+ canvas->setMinimumSize(QSize(0, 0));
}
} else { // QDeclarativeView::SizeRootObjectToView
canvas->setMinimumSize(QSize(0,0));
canvas->setMaximumSize(QSize(16777215,16777215));
- setMinimumSize(QSize(0,0));
- setMaximumSize(QSize(16777215,16777215));
}
}
diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h
index 27bd217..a3a9fb3 100644
--- a/tools/qml/qmlruntime.h
+++ b/tools/qml/qmlruntime.h
@@ -43,7 +43,6 @@
#define QDECLARATIVEVIEWER_H
#include <QMainWindow>
-#include <QMenuBar>
#include <private/qdeclarativetimer_p.h>
#include <QTime>
#include <QList>
@@ -62,17 +61,16 @@ class QNetworkReply;
class QNetworkCookieJar;
class NetworkAccessManagerFactory;
class QTranslator;
+class QActionGroup;
+class QMenuBar;
class QDeclarativeViewer
-#if defined(Q_OS_SYMBIAN)
: public QMainWindow
-#else
- : public QWidget
-#endif
{
-Q_OBJECT
+ Q_OBJECT
+
public:
- QDeclarativeViewer(QWidget *parent=0, Qt::WindowFlags flags=0);
+ QDeclarativeViewer(QWidget *parent = 0, Qt::WindowFlags flags = 0);
~QDeclarativeViewer();
static void registerTypes();
@@ -103,11 +101,8 @@ public:
void addPluginPath(const QString& plugin);
void setUseGL(bool use);
void setUseNativeFileBrowser(bool);
- void updateSizeHints();
void setSizeToView(bool sizeToView);
- QMenuBar *menuBar() const;
-
QDeclarativeView *view() const;
LoggerWidget *warningsWidget() const;
@@ -132,9 +127,11 @@ public slots:
protected:
virtual void keyPressEvent(QKeyEvent *);
virtual bool event(QEvent *);
- void createMenu(QMenuBar *menu, QMenu *flatmenu);
+ void createMenu();
private slots:
+ void appAboutToQuit();
+
void autoStartRecording();
void autoStopRecording();
void recordFrame();
@@ -148,9 +145,10 @@ private slots:
void warningsWidgetOpened();
void warningsWidgetClosed();
+ void updateSizeHints();
+
private:
QString getVideoFileName();
- int menuBarHeight() const;
LoggerWidget *loggerWindow;
QDeclarativeView *canvas;
@@ -173,7 +171,6 @@ private:
QAction *recordAction;
QString currentSkin;
bool scaleSkin;
- mutable QMenuBar *mb;
RecordingDialog *recdlg;
void senseImageMagick();
diff --git a/tools/qml/recopts_maemo5.ui b/tools/qml/recopts_maemo5.ui
new file mode 100644
index 0000000..3bb5eca
--- /dev/null
+++ b/tools/qml/recopts_maemo5.ui
@@ -0,0 +1,254 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>RecordingOptions</class>
+ <widget class="QDialog" name="RecordingOptions">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>469</width>
+ <height>142</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Video options</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout" columnstretch="0,2,0">
+ <property name="sizeConstraint">
+ <enum>QLayout::SetMinAndMaxSize</enum>
+ </property>
+ <property name="leftMargin">
+ <number>16</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>16</number>
+ </property>
+ <property name="bottomMargin">
+ <number>8</number>
+ </property>
+ <property name="horizontalSpacing">
+ <number>16</number>
+ </property>
+ <property name="verticalSpacing">
+ <number>0</number>
+ </property>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="file"/>
+ </item>
+ <item row="0" column="2" rowspan="3">
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>72</width>
+ <height>56</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Size</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QComboBox" name="sizeCombo">
+ <item>
+ <property name="text">
+ <string/>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>VGA</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>QVGA</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>720p</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="2" column="0" rowspan="2">
+ <widget class="QLabel" name="rateLabel">
+ <property name="text">
+ <string>Rate</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" rowspan="2">
+ <widget class="QComboBox" name="rateCombo">
+ <item>
+ <property name="text">
+ <string>60 Hz</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>50 Hz</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>25 Hz</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>24 Hz</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>20 Hz</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>15 Hz</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>10 Hz</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <widget class="QLineEdit" name="args"/>
+ </item>
+ <item row="4" column="1">
+ <widget class="QComboBox" name="profile"/>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="profileLabel">
+ <property name="text">
+ <string>Profile</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0" colspan="2">
+ <widget class="QLabel" name="warning">
+ <property name="text">
+ <string notr="true">warning</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="2" rowspan="3">
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QPushButton" name="pickfile">
+ <property name="text">
+ <string>File</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0">
+ <widget class="QPushButton" name="ffmpegHelp">
+ <property name="text">
+ <string>Options</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>RecordingOptions</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>258</x>
+ <y>424</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>60</x>
+ <y>219</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>RecordingOptions</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>258</x>
+ <y>424</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>92</x>
+ <y>219</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>profile</sender>
+ <signal>activated(int)</signal>
+ <receiver>RecordingOptions</receiver>
+ <slot>pickProfile(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>92</x>
+ <y>329</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>48</x>
+ <y>194</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>args</sender>
+ <signal>textEdited(QString)</signal>
+ <receiver>RecordingOptions</receiver>
+ <slot>storeCustomArgs(QString)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>128</x>
+ <y>357</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>102</x>
+ <y>189</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+ <slots>
+ <signal>filePicked(QString)</signal>
+ <signal>argumentsPicked(QString)</signal>
+ <slot>pickFile()</slot>
+ <slot>pickProfile(int)</slot>
+ <slot>storeCustomArgs(QString)</slot>
+ </slots>
+</ui>
diff --git a/tools/qml/texteditautoresizer_maemo5.h b/tools/qml/texteditautoresizer_maemo5.h
new file mode 100644
index 0000000..bb5567a
--- /dev/null
+++ b/tools/qml/texteditautoresizer_maemo5.h
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/qplaintextedit.h>
+#include <QtGui/qtextedit.h>
+#include <QtGui/qabstractkineticscroller.h>
+#include <QtGui/qscrollarea.h>
+#include <QtDebug>
+
+#ifndef TEXTEDITAUTORESIZER_H
+#define TEXTEDITAUTORESIZER_H
+
+class TextEditAutoResizer : public QObject
+{
+ Q_OBJECT
+public:
+ TextEditAutoResizer(QWidget *parent)
+ : QObject(parent), plainTextEdit(qobject_cast<QPlainTextEdit *>(parent)),
+ textEdit(qobject_cast<QTextEdit *>(parent)), edit(qobject_cast<QFrame *>(parent))
+ {
+ // parent must either inherit QPlainTextEdit or QTextEdit!
+ Q_ASSERT(plainTextEdit || textEdit);
+
+ connect(parent, SIGNAL(textChanged()), this, SLOT(textEditChanged()));
+ connect(parent, SIGNAL(cursorPositionChanged()), this, SLOT(textEditChanged()));
+
+ textEditChanged();
+ }
+
+private Q_SLOTS:
+ inline void textEditChanged();
+
+private:
+ QPlainTextEdit *plainTextEdit;
+ QTextEdit *textEdit;
+ QFrame *edit;
+};
+
+void TextEditAutoResizer::textEditChanged()
+{
+ QTextDocument *doc = textEdit ? textEdit->document() : plainTextEdit->document();
+ QRect cursor = textEdit ? textEdit->cursorRect() : plainTextEdit->cursorRect();
+
+ QSize s = doc->size().toSize();
+ if (plainTextEdit)
+ s.setHeight((s.height() + 2) * edit->fontMetrics().lineSpacing());
+
+ const QRect fr = edit->frameRect();
+ const QRect cr = edit->contentsRect();
+
+ edit->setMinimumHeight(qMax(70, s.height() + (fr.height() - cr.height() - 1)));
+
+ // make sure the cursor is visible in case we have a QAbstractScrollArea parent
+ QPoint pos = edit->pos();
+ QWidget *pw = edit->parentWidget();
+ while (pw) {
+ if (qobject_cast<QScrollArea *>(pw))
+ break;
+ pw = pw->parentWidget();
+ }
+
+ if (pw) {
+ QScrollArea *area = static_cast<QScrollArea *>(pw);
+ QPoint scrollto = area->widget()->mapFrom(edit, cursor.center());
+ QPoint margin(10 + cursor.width(), 2 * cursor.height());
+
+ if (QAbstractKineticScroller *scroller = area->property("kineticScroller").value<QAbstractKineticScroller *>()) {
+ scroller->ensureVisible(scrollto, margin.x(), margin.y());
+ } else {
+ area->ensureVisible(scrollto.x(), scrollto.y(), margin.x(), margin.y());
+ }
+ }
+}
+
+#endif