summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-05-12 02:48:44 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-05-12 02:48:44 (GMT)
commitffb4e551ed9316a3d16b9add3c8e5a7f47b75886 (patch)
tree6f923f212815dac96a2f99bdcacfcc5dd14a0c11
parent779c414bb96ab501e839261a4e9f2c94b9d21aa9 (diff)
parent8d90fe1e4a3d50b64cff84ac10bfa2e6a17a35b9 (diff)
downloadQt-ffb4e551ed9316a3d16b9add3c8e5a7f47b75886.zip
Qt-ffb4e551ed9316a3d16b9add3c8e5a7f47b75886.tar.gz
Qt-ffb4e551ed9316a3d16b9add3c8e5a7f47b75886.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--demos/declarative/flickr/content/ImageDetails.qml33
-rw-r--r--demos/declarative/flickr/content/Slider.qml10
-rw-r--r--demos/declarative/flickr/flickr.qml2
-rw-r--r--examples/declarative/dial/DialLibrary/Dial.qml24
-rw-r--r--examples/declarative/dial/dial.qml34
-rw-r--r--examples/declarative/mouseregion/mouse.qml20
-rw-r--r--examples/declarative/scrollbar/ScrollBar.qml3
-rw-r--r--examples/declarative/slideswitch/Switch.qml55
-rw-r--r--examples/declarative/states/states.qml73
-rw-r--r--examples/declarative/states/transitions.qml105
-rw-r--r--src/declarative/fx/qfxflickable.cpp16
-rw-r--r--src/declarative/qml/qmlcompiler.cpp2
-rw-r--r--src/declarative/qml/qmlcompositetypemanager.cpp14
-rw-r--r--src/declarative/qml/qmlcompositetypemanager_p.h6
-rw-r--r--src/declarative/qml/qmlvme.cpp7
-rw-r--r--tests/auto/declarative/qmlparser/assignObjectToSignal.txt3
-rw-r--r--tests/auto/declarative/qmlparser/duplicateIDs.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/duplicateIDs.txt5
-rw-r--r--tests/auto/declarative/qmlparser/empty.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/empty.txt0
-rw-r--r--tests/auto/declarative/qmlparser/fakeDotProperty.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/fakeDotProperty.txt3
-rw-r--r--tests/auto/declarative/qmlparser/interfaceProperty.txt3
-rw-r--r--tests/auto/declarative/qmlparser/interfaceQList.txt6
-rw-r--r--tests/auto/declarative/qmlparser/interfaceQmlList.txt6
-rw-r--r--tests/auto/declarative/qmlparser/invalidID.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/invalidID.txt3
-rw-r--r--tests/auto/declarative/qmlparser/missingObject.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/missingObject.txt1
-rw-r--r--tests/auto/declarative/qmlparser/nonexistantProperty.1.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/nonexistantProperty.1.txt1
-rw-r--r--tests/auto/declarative/qmlparser/nonexistantProperty.2.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/nonexistantProperty.2.txt3
-rw-r--r--tests/auto/declarative/qmlparser/nonexistantProperty.3.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/nonexistantProperty.3.txt3
-rw-r--r--tests/auto/declarative/qmlparser/nonexistantProperty.4.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/nonexistantProperty.4.txt3
-rw-r--r--tests/auto/declarative/qmlparser/nonexistantProperty.5.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/nonexistantProperty.5.txt3
-rw-r--r--tests/auto/declarative/qmlparser/nonexistantProperty.6.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/nonexistantProperty.6.txt3
-rw-r--r--tests/auto/declarative/qmlparser/nullDotProperty.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/nullDotProperty.txt3
-rw-r--r--tests/auto/declarative/qmlparser/qmlparser.pro1
-rw-r--r--tests/auto/declarative/qmlparser/readOnly.1.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/readOnly.1.txt3
-rw-r--r--tests/auto/declarative/qmlparser/readOnly.2.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/readOnly.2.txt3
-rw-r--r--tests/auto/declarative/qmlparser/simpleContainer.txt4
-rw-r--r--tests/auto/declarative/qmlparser/simpleObject.txt1
-rw-r--r--tests/auto/declarative/qmlparser/tst_qmlparser.cpp309
-rw-r--r--tests/auto/declarative/qmlparser/unregisteredObject.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/unregisteredObject.txt1
-rw-r--r--tests/auto/declarative/qmlparser/unsupportedProperty.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/unsupportedProperty.txt3
-rw-r--r--tests/auto/declarative/qmlparser/wrongType.1.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/wrongType.1.txt3
-rw-r--r--tests/auto/declarative/qmlparser/wrongType.2.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/wrongType.2.txt3
-rw-r--r--tests/auto/declarative/qmlparser/wrongType.3.errors.txt1
-rw-r--r--tests/auto/declarative/qmlparser/wrongType.3.txt3
61 files changed, 316 insertions, 490 deletions
diff --git a/demos/declarative/flickr/content/ImageDetails.qml b/demos/declarative/flickr/content/ImageDetails.qml
index 5c2d885..d575be9 100644
--- a/demos/declarative/flickr/content/ImageDetails.qml
+++ b/demos/declarative/flickr/content/ImageDetails.qml
@@ -2,8 +2,6 @@ Flipable {
id: Container
property var frontContainer: ContainerFront
- property var flickableArea: Flickable
- property var slider: Slider
property string photoTitle: ""
property string photoDescription: ""
property string photoTags: ""
@@ -77,13 +75,28 @@ Flipable {
Progress { anchors.centeredIn: parent; width: 200; height: 18; progress: BigImage.progress; visible: BigImage.status }
Flickable {
id: Flick; width: Container.width - 10; height: Container.height - 10
- x: 5; y: 5; clip: true; viewportWidth: (BigImage.width * BigImage.scale) + BigImage.x;
- viewportHeight: BigImage.height * BigImage.scale
-
- Image {
- id: BigImage; source: Container.photoUrl; scale: Slider.value
- x:Math.max(0, ((Flick.width/2)-(width * scale / 2)));
- y:Math.max(0, (Flick.height/2)-(height * scale / 2));
+ x: 5; y: 5; clip: true;
+ viewportWidth: ImageContainer.width; viewportHeight: ImageContainer.height
+
+ Item {
+ id: ImageContainer
+ width: Math.max(BigImage.width * BigImage.scale, Flick.width);
+ height: Math.max(BigImage.height * BigImage.scale, Flick.height);
+
+ Image {
+ id: BigImage; source: Container.photoUrl; scale: Slider.value
+ // Center image if it is smaller than the flickable area.
+ x: ImageContainer.width > width*scale ? (ImageContainer.width - width*scale) / 2 : 0
+ y: ImageContainer.height > height*scale ? (ImageContainer.height - height*scale) / 2 : 0
+ anchors.centeredIn: parent
+ onStatusChanged : {
+ // Default scale shows the entire image.
+ if (status == 0 && width != 0) {
+ Slider.minimum = Math.min(Flick.width / width, Flick.height / height);
+ Slider.value = Math.min(Slider.minimum, 1);
+ }
+ }
+ }
}
}
@@ -96,7 +109,7 @@ Flipable {
anchors.centeredIn: parent; color: "white"; font.bold: true
}
- Slider { id: Slider; x: 25; y: 374; visible: BigImage.status == 0; imageWidth: Container.photoWidth; imageHeight: Container.photoHeight }
+ Slider { id: Slider; x: 25; y: 374; visible: { BigImage.status == 0 && maximum > minimum } }
}
states: [
diff --git a/demos/declarative/flickr/content/Slider.qml b/demos/declarative/flickr/content/Slider.qml
index c6a3e5e..92f4993 100644
--- a/demos/declarative/flickr/content/Slider.qml
+++ b/demos/declarative/flickr/content/Slider.qml
@@ -1,11 +1,12 @@
Item {
id: Slider; width: 400; height: 16
- property var value: Handle.x / Slider.xMax
+ // value is read/write.
+ property real value
+ onValueChanged: { Handle.x = (value - minimum) * Slider.xMax / (maximum - minimum); }
+ property real maximum: 1
+ property real minimum: 1
property int xMax: Slider.width - Handle.width - 2
- property var handle: Handle
- property int imageWidth
- property int imageHeight
Rect {
id: Container; anchors.fill: parent; gradientColor: "#66000000";
@@ -20,6 +21,7 @@ Item {
MouseRegion {
anchors.fill: parent; drag.target: parent
drag.axis: "x"; drag.xmin: 2; drag.xmax: Slider.xMax
+ onPositionChanged: { value = (maximum - minimum) * Handle.x / Slider.xMax + minimum; }
}
}
}
diff --git a/demos/declarative/flickr/flickr.qml b/demos/declarative/flickr/flickr.qml
index 829f568..8d294f8 100644
--- a/demos/declarative/flickr/flickr.qml
+++ b/demos/declarative/flickr/flickr.qml
@@ -48,7 +48,6 @@ Item {
Script {
function photoClicked() {
ImageDetails.photoTitle = title;
- ImageDetails.flickableArea.yPosition = 0;
ImageDetails.photoDescription = description;
ImageDetails.photoTags = tags;
ImageDetails.photoWidth = photoWidth;
@@ -58,7 +57,6 @@ Item {
ImageDetails.photoDate = photoDate;
ImageDetails.photoUrl = url;
ImageDetails.rating = 0;
- ImageDetails.slider.handle.x = ImageDetails.slider.xMax;
Wrapper.state = "Details";
}
}
diff --git a/examples/declarative/dial/DialLibrary/Dial.qml b/examples/declarative/dial/DialLibrary/Dial.qml
index 485188a..2e214a8 100644
--- a/examples/declarative/dial/DialLibrary/Dial.qml
+++ b/examples/declarative/dial/DialLibrary/Dial.qml
@@ -1,27 +1,20 @@
Item {
property real value : 0
- width: 210
- height: 210
+ width: 210; height: 210
- Image {
- id: Background
- source: "background.svg"
- }
+ Image { id: Background; source: "background.svg" }
Item {
- x: 104
- y: 102
+ x: 104; y: 102
rotation: Needle.rotation
Image {
source: "needle_shadow.svg"
- x: -104
- y: -102
+ x: -104; y: -102
}
}
Item {
id: Needle
- x: 102
- y: 98
+ x: 102; y: 98
rotation: -130
rotation: Follow {
spring: 1.4
@@ -30,11 +23,8 @@ Item {
}
Image {
source: "needle.svg"
- x: -102
- y: -98
+ x: -102; y: -98
}
}
- Image {
- source: "overlay.svg"
- }
+ Image { source: "overlay.svg" }
}
diff --git a/examples/declarative/dial/dial.qml b/examples/declarative/dial/dial.qml
index fa11d79..5e09171 100644
--- a/examples/declarative/dial/dial.qml
+++ b/examples/declarative/dial/dial.qml
@@ -1,37 +1,23 @@
import "DialLibrary"
Rect {
color: "white"
- width: 210
- height: 240
+ width: 210; height: 240
+
// Dial with a slider to adjust it
- Dial {
- id: Dial
- value: Slider.x-2
- }
+ Dial { id: Dial; value: Slider.x-2 }
+
Rect {
anchors.top: Dial.bottom
- x: 20
- width: 160
- height: 16
- color: "steelblue"
- gradientColor: "lightsteelblue"
- radius: 8
- opacity: 0.7
+ x: 20; width: 160; height: 16
+ color: "steelblue"; gradientColor: "lightsteelblue"
+ radius: 8; opacity: 0.7
Rect {
id: Slider
- x: 2
- y: 2
- width: 30
- height: 12
- color: "lightgray"
- gradientColor: "gray"
- radius: 6
+ x: 2; y: 2; width: 30; height: 12
+ color: "lightgray"; gradientColor: "gray"; radius: 6
MouseRegion {
anchors.fill: parent
- drag.target: parent
- drag.axis: "x"
- drag.xmin: 2
- drag.xmax: 128
+ drag.target: parent; drag.axis: "x"; drag.xmin: 2; drag.xmax: 128
}
}
}
diff --git a/examples/declarative/mouseregion/mouse.qml b/examples/declarative/mouseregion/mouse.qml
index 6d10425..471874d 100644
--- a/examples/declarative/mouseregion/mouse.qml
+++ b/examples/declarative/mouseregion/mouse.qml
@@ -1,15 +1,10 @@
Rect {
color: "white"
- width: 200
- height: 200
+ width: 200; height: 200
Rect {
- width: 50
- height: 50
+ width: 50; height: 50
color: "red"
- Text {
- text: "Click"
- anchors.centeredIn: parent
- }
+ Text { text: "Click"; anchors.centeredIn: parent }
MouseRegion {
onPressed: { print('press (x: ' + mouse.x + ' y: ' + mouse.y + ' button: ' + (mouse.button == Qt.RightButton ? 'right' : 'left') + ' Shift: ' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')') }
onReleased: { print('release (x: ' + mouse.x + ' y: ' + mouse.y + ' isClick: ' + mouse.isClick + ' wasHeld: ' + mouse.wasHeld + ')') }
@@ -22,14 +17,9 @@ Rect {
}
}
Rect {
- y: 100
- width: 50
- height: 50
+ y: 100; width: 50; height: 50
color: "blue"
- Text {
- text: "Drag"
- anchors.centeredIn: parent
- }
+ Text { text: "Drag"; anchors.centeredIn: parent }
MouseRegion {
drag.target: parent
drag.axis: "x"
diff --git a/examples/declarative/scrollbar/ScrollBar.qml b/examples/declarative/scrollbar/ScrollBar.qml
index 929c72a..8020d62 100644
--- a/examples/declarative/scrollbar/ScrollBar.qml
+++ b/examples/declarative/scrollbar/ScrollBar.qml
@@ -13,8 +13,7 @@ Item {
Rect {
id: Background
radius: orientation == 'Vertical' ? (width/2) : (height/2)
- color: "white"
- opacity: 0.3
+ color: "white"; opacity: 0.3
anchors.fill: parent
}
// Size the bar to the required size, depending upon the orientation.
diff --git a/examples/declarative/slideswitch/Switch.qml b/examples/declarative/slideswitch/Switch.qml
index 6777277..8bc88e4 100644
--- a/examples/declarative/slideswitch/Switch.qml
+++ b/examples/declarative/slideswitch/Switch.qml
@@ -1,7 +1,6 @@
Item {
id: Switch
- width: Groove.width
- height: Groove.height
+ width: Groove.width; height: Groove.height
property var on
@@ -28,64 +27,30 @@ Item {
}
}
- Image {
- id: Groove
- source: "background.svg"
- }
- MouseRegion {
- anchors.fill: Groove
- onClicked: { toggle() }
- }
- Image {
- id: Knob
- source: "knob.svg"
- x: 1
- y: 2
- }
+ Image { id: Groove; source: "background.svg" }
+ MouseRegion { anchors.fill: Groove; onClicked: { toggle() } }
+ Image { id: Knob; source: "knob.svg"; x: 1; y: 2 }
MouseRegion {
anchors.fill: Knob
onClicked: { toggle() }
onReleased: { dorelease() }
- drag.target: Knob
- drag.axis: "x"
- drag.xmin: 1
- drag.xmax: 78
+ drag.target: Knob; drag.axis: "x"; drag.xmin: 1; drag.xmax: 78
}
states: [
State {
name: "On"
- SetProperty {
- target: Knob
- property: "x"
- value: 78
- }
- SetProperty {
- target: Switch
- property: "on"
- value: true
- }
+ SetProperty { target: Knob; property: "x"; value: 78 }
+ SetProperty { target: Switch; property: "on"; value: true }
},
State {
name: "Off"
- SetProperty {
- target: Knob
- property: "x"
- value: 1
- }
- SetProperty {
- target: Switch
- property: "on"
- value: false
- }
+ SetProperty { target: Knob; property: "x"; value: 1 }
+ SetProperty { target: Switch; property: "on"; value: false }
}
]
transitions: [
Transition {
- NumericAnimation {
- properties: "x"
- easing: "easeInOutQuad"
- duration: 200
- }
+ NumericAnimation { properties: "x"; easing: "easeInOutQuad"; duration: 200 }
}
]
}
diff --git a/examples/declarative/states/states.qml b/examples/declarative/states/states.qml
index 0c27637..bcde20c 100644
--- a/examples/declarative/states/states.qml
+++ b/examples/declarative/states/states.qml
@@ -1,79 +1,40 @@
Rect {
id: Page
- width: 300
- height: 300
- color: "white"
+ width: 300; height: 300; color: "white"
// A target region. Clicking in here sets the state to '' - the default state
Rect {
- width: 50
- height: 50
- x: 0
- y: 0
- color: "transparent"
- pen.color: "black"
- MouseRegion {
- anchors.fill: parent
- onClicked: { Page.state='' }
- }
+ x: 0; y: 0; width: 50; height: 50
+ color: "transparent"; pen.color: "black"
+ MouseRegion { anchors.fill: parent; onClicked: { Page.state='' } }
}
// Another target region. Clicking in here sets the state to 'Position1'
Rect {
- width: 50
- height: 50
- x: 150
- y: 50
- color: "transparent"
- pen.color: "black"
- MouseRegion {
- anchors.fill: parent
- onClicked: { Page.state='Position1' }
- }
+ x: 150; y: 50; width: 50; height: 50
+ color: "transparent"; pen.color: "black"
+ MouseRegion { anchors.fill: parent; onClicked: { Page.state='Position1' } }
}
// Another target region. Clicking in here sets the state to 'Position2'
Rect {
- width: 50
- height: 50
- x: 0
- y: 200
- color: "transparent"
- pen.color: "black"
- MouseRegion {
- anchors.fill: parent
- onClicked: { Page.state='Position2' }
- }
+ x: 0; y: 200; width: 50; height: 50
+ color: "transparent"; pen.color: "black"
+ MouseRegion { anchors.fill: parent; onClicked: { Page.state='Position2' } }
}
// Rect which will be moved when my state changes
- Rect {
- id: myrect
- width: 50
- height: 50
- color: "red"
- }
+ Rect { id: myrect; width: 50; height: 50; color: "red" }
+
states: [
// In state 'Position1', change the 'myrect' item x, y to 150, 50.
State {
name: "Position1"
- SetProperty {
- target: myrect
- property: "x"
- value: 150
- }
- SetProperty {
- target: myrect
- property: "y"
- value: 50
- }
- } // In state 'Position2', change y to 100. We do not specify 'x' here -
+ SetProperty { target: myrect; property: "x"; value: 150 }
+ SetProperty { target: myrect; property: "y"; value: 50 }
+ },
+ // In state 'Position2', change y to 100. We do not specify 'x' here -
// it will therefore be restored to its default value of 0, if it
// had been changed.
-,
State {
name: "Position2"
- SetProperty {
- target: myrect
- property: "y"
- value: 200
- }
+ SetProperty { target: myrect; property: "y"; value: 200 }
}
]
}
diff --git a/examples/declarative/states/transitions.qml b/examples/declarative/states/transitions.qml
index c7fc656..4c1dceb 100644
--- a/examples/declarative/states/transitions.qml
+++ b/examples/declarative/states/transitions.qml
@@ -1,111 +1,60 @@
Rect {
id: Page
- width: 300
- height: 300
- color: "white"
+ width: 300; height: 300; color: "white"
// A target region. Clicking in here sets the state to '' - the default state
Rect {
- width: 50
- height: 50
- x: 0
- y: 0
- color: "transparent"
- pen.color: "black"
- MouseRegion {
- anchors.fill: parent
- onClicked: { Page.state='' }
- }
+ x: 0; y: 0; width: 50; height: 50
+ color: "transparent"; pen.color: "black"
+ MouseRegion { anchors.fill: parent; onClicked: { Page.state='' } }
}
// Another target region. Clicking in here sets the state to 'Position1'
Rect {
- width: 50
- height: 50
- x: 150
- y: 50
- color: "transparent"
- pen.color: "black"
- MouseRegion {
- anchors.fill: parent
- onClicked: { Page.state='Position1' }
- }
+ x: 150; y: 50; width: 50; height: 50
+ color: "transparent"; pen.color: "black"
+ MouseRegion { anchors.fill: parent; onClicked: { Page.state='Position1' } }
}
// Another target region. Clicking in here sets the state to 'Position2'
Rect {
- width: 50
- height: 50
- x: 0
- y: 200
- color: "transparent"
- pen.color: "black"
- MouseRegion {
- anchors.fill: parent
- onClicked: { Page.state='Position2' }
- }
+ x: 0; y: 200; width: 50; height: 50
+ color: "transparent"; pen.color: "black"
+ MouseRegion { anchors.fill: parent; onClicked: { Page.state='Position2' } }
}
// Rect which will be moved when my state changes
- Rect {
- id: myrect
- width: 50
- height: 50
- color: "red"
- }
+ Rect { id: myrect; width: 50; height: 50; color: "red" }
+
states: [
// In state 'Position1', change the 'myrect' item x, y to 150, 50.
State {
name: "Position1"
- SetProperty {
- target: myrect
- property: "x"
- value: 150
- }
- SetProperty {
- target: myrect
- property: "y"
- value: 50
- }
- } // In state 'Position2', change y to 100. We do not specify 'x' here -
+ SetProperty { target: myrect; property: "x"; value: 150 }
+ SetProperty { target: myrect; property: "y"; value: 50 }
+ },
+ // In state 'Position2', change y to 100. We do not specify 'x' here -
// it will therefore be restored to its default value of 0, if it
// had been changed.
-,
State {
name: "Position2"
- SetProperty {
- target: myrect
- property: "y"
- value: 200
- }
+ SetProperty { target: myrect; property: "y"; value: 200 }
}
]
+
// transitions define how the properties change.
transitions: [
// When transitioning to 'Position1' move x,y over a duration of 1 second,
// with easeOutBounce easing function.
Transition {
- fromState: "*"
- toState: "Position1"
- NumericAnimation {
- properties: "x,y"
- easing: "easeOutBounce"
- duration: 1000
- }
- } // When transitioning to 'Position2' move x,y over a duration of 2 seconds,
+ fromState: "*"; toState: "Position1"
+ NumericAnimation { properties: "x,y"; easing: "easeOutBounce"; duration: 1000 }
+ },
+ // When transitioning to 'Position2' move x,y over a duration of 2 seconds,
// with easeInOutQuad easing function.
-,
Transition {
- fromState: "*"
- toState: "Position2"
- NumericAnimation {
- properties: "x,y"
- easing: "easeInOutQuad"
- duration: 2000
- }
- } // For any other state changes move x,y linearly over duration of 200ms.
-,
+ fromState: "*"; toState: "Position2"
+ NumericAnimation { properties: "x,y"; easing: "easeInOutQuad"; duration: 2000 }
+ },
+ // For any other state changes move x,y linearly over duration of 200ms.
Transition {
- NumericAnimation {
- properties: "x,y"
- duration: 200
- }
+ NumericAnimation { properties: "x,y"; duration: 200 }
}
]
}
diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp
index 4ace811..4248ebb 100644
--- a/src/declarative/fx/qfxflickable.cpp
+++ b/src/declarative/fx/qfxflickable.cpp
@@ -916,6 +916,14 @@ void QFxFlickable::setViewportWidth(int w)
d->_flick->setWidth(width());
else
d->_flick->setWidth(w);
+ // Make sure that we're entirely in view.
+ if (d->_moveX.value() > minXExtent() || maxXExtent() > 0) {
+ d->_tl.clear();
+ d->_moveX.setValue(minXExtent());
+ } else if (d->_moveX.value() < maxXExtent()) {
+ d->_tl.clear();
+ d->_moveX.setValue(maxXExtent());
+ }
emit viewportWidthChanged();
d->updateBeginningEnd();
}
@@ -960,6 +968,14 @@ void QFxFlickable::setViewportHeight(int h)
d->_flick->setHeight(height());
else
d->_flick->setHeight(h);
+ // Make sure that we're entirely in view.
+ if (d->_moveY.value() > minYExtent() || maxYExtent() > 0) {
+ d->_tl.clear();
+ d->_moveY.setValue(minYExtent());
+ } else if (d->_moveY.value() < maxYExtent()) {
+ d->_tl.clear();
+ d->_moveY.setValue(maxYExtent());
+ }
emit viewportHeightChanged();
d->updateBeginningEnd();
}
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index 8e279a5..f17b50d 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -445,6 +445,7 @@ void QmlCompiler::reset(QmlCompiledComponent *cc, bool deleteMemory)
exceptionColumn = token->location.start.column; \
QDebug d(&exceptionDescription); \
d << desc; \
+ exceptionDescription = exceptionDescription.trimmed(); \
return false; \
}
@@ -454,6 +455,7 @@ void QmlCompiler::reset(QmlCompiledComponent *cc, bool deleteMemory)
exceptionColumn = obj->location.start.column; \
QDebug d(&exceptionDescription); \
d << desc; \
+ exceptionDescription = exceptionDescription.trimmed(); \
return false; \
}
diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp
index fbe40bf..f646ca9 100644
--- a/src/declarative/qml/qmlcompositetypemanager.cpp
+++ b/src/declarative/qml/qmlcompositetypemanager.cpp
@@ -51,7 +51,7 @@
#include <private/qmlcomponent_p.h>
QmlCompositeTypeData::QmlCompositeTypeData()
-: status(Invalid), component(0), compiledComponent(0)
+: status(Invalid), errorType(NoError), component(0), compiledComponent(0)
{
}
@@ -190,6 +190,7 @@ void QmlCompositeTypeManager::replyFinished()
// ### FIXME
QmlError error;
error.setDescription(errorDescription);
+ unit->errorType = QmlCompositeTypeData::AccessError;
unit->errors << error;
doComplete(unit);
@@ -220,6 +221,7 @@ void QmlCompositeTypeManager::loadSource(QmlCompositeTypeData *unit)
// ### FIXME
QmlError error;
error.setDescription(errorDescription);
+ unit->errorType = QmlCompositeTypeData::AccessError;
unit->errors << error;
doComplete(unit);
}
@@ -239,6 +241,7 @@ void QmlCompositeTypeManager::setData(QmlCompositeTypeData *unit,
if (!unit->data.parse(data, url)) {
unit->status = QmlCompositeTypeData::Error;
+ unit->errorType = QmlCompositeTypeData::GeneralError;
unit->errors << unit->data.errors();
doComplete(unit);
@@ -339,7 +342,14 @@ void QmlCompositeTypeManager::compile(QmlCompositeTypeData *unit)
case QmlCompositeTypeData::Invalid:
case QmlCompositeTypeData::Error:
unit->status = QmlCompositeTypeData::Error;
- unit->errors = urlUnit->errors;
+ {
+ QmlError error;
+ error.setUrl(unit->url);
+ error.setDescription("Type " + type + " unavailable");
+ unit->errors << error;
+ }
+ if (urlUnit->errorType != QmlCompositeTypeData::AccessError)
+ unit->errors << urlUnit->errors;
doComplete(unit);
return;
diff --git a/src/declarative/qml/qmlcompositetypemanager_p.h b/src/declarative/qml/qmlcompositetypemanager_p.h
index e4028d5..c12dedc 100644
--- a/src/declarative/qml/qmlcompositetypemanager_p.h
+++ b/src/declarative/qml/qmlcompositetypemanager_p.h
@@ -66,6 +66,12 @@ struct QmlCompositeTypeData : public QmlRefCount
Waiting
};
Status status;
+ enum ErrorType {
+ NoError,
+ AccessError,
+ GeneralError
+ };
+ ErrorType errorType;
QList<QmlError> errors;
diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp
index 5e0f257..794c836 100644
--- a/src/declarative/qml/qmlvme.cpp
+++ b/src/declarative/qml/qmlvme.cpp
@@ -181,6 +181,7 @@ QmlVME::QmlVME()
QString str; \
QDebug d(&str); \
d << desc; \
+ str = str.trimmed(); \
QmlError error; \
error.setDescription(str); \
error.setLine(instr.line); \
@@ -860,7 +861,11 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in
} else {
- VME_EXCEPTION("Cannot assign to non-existant property" << property);
+ if (instr.assignObject.property == -1) {
+ VME_EXCEPTION("Cannot assign to default property");
+ } else {
+ VME_EXCEPTION("Cannot assign to non-existant property" << property);
+ }
}
}
diff --git a/tests/auto/declarative/qmlparser/assignObjectToSignal.txt b/tests/auto/declarative/qmlparser/assignObjectToSignal.txt
new file mode 100644
index 0000000..0d6bc4e
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/assignObjectToSignal.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ onBasicSignal: MyQmlObject {}
+}
diff --git a/tests/auto/declarative/qmlparser/duplicateIDs.errors.txt b/tests/auto/declarative/qmlparser/duplicateIDs.errors.txt
new file mode 100644
index 0000000..b03f735
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/duplicateIDs.errors.txt
@@ -0,0 +1 @@
+3:5:id is not unique
diff --git a/tests/auto/declarative/qmlparser/duplicateIDs.txt b/tests/auto/declarative/qmlparser/duplicateIDs.txt
new file mode 100644
index 0000000..e76ee21
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/duplicateIDs.txt
@@ -0,0 +1,5 @@
+MyContainer {
+ MyQmlObject { id: MyID }
+ MyQmlObject { id: MyID }
+}
+
diff --git a/tests/auto/declarative/qmlparser/empty.errors.txt b/tests/auto/declarative/qmlparser/empty.errors.txt
new file mode 100644
index 0000000..101b6a2
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/empty.errors.txt
@@ -0,0 +1 @@
+0:0:Syntax error
diff --git a/tests/auto/declarative/qmlparser/empty.txt b/tests/auto/declarative/qmlparser/empty.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/empty.txt
diff --git a/tests/auto/declarative/qmlparser/fakeDotProperty.errors.txt b/tests/auto/declarative/qmlparser/fakeDotProperty.errors.txt
new file mode 100644
index 0000000..6c42157
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/fakeDotProperty.errors.txt
@@ -0,0 +1 @@
+2:-1:Cannot set properties on value as it is of unknown type
diff --git a/tests/auto/declarative/qmlparser/fakeDotProperty.txt b/tests/auto/declarative/qmlparser/fakeDotProperty.txt
new file mode 100644
index 0000000..28eb9dc
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/fakeDotProperty.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ value.something: "hello"
+}
diff --git a/tests/auto/declarative/qmlparser/interfaceProperty.txt b/tests/auto/declarative/qmlparser/interfaceProperty.txt
new file mode 100644
index 0000000..cbad7f1
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/interfaceProperty.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ interface: MyQmlObject {}
+}
diff --git a/tests/auto/declarative/qmlparser/interfaceQList.txt b/tests/auto/declarative/qmlparser/interfaceQList.txt
new file mode 100644
index 0000000..6c6ab4b
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/interfaceQList.txt
@@ -0,0 +1,6 @@
+MyContainer {
+ qlistInterfaces: [
+ MyQmlObject {},
+ MyQmlObject {}
+ ]
+}
diff --git a/tests/auto/declarative/qmlparser/interfaceQmlList.txt b/tests/auto/declarative/qmlparser/interfaceQmlList.txt
new file mode 100644
index 0000000..f41c105
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/interfaceQmlList.txt
@@ -0,0 +1,6 @@
+MyContainer {
+ qmllistInterfaces: [
+ MyQmlObject {},
+ MyQmlObject {}
+ ]
+}
diff --git a/tests/auto/declarative/qmlparser/invalidID.errors.txt b/tests/auto/declarative/qmlparser/invalidID.errors.txt
new file mode 100644
index 0000000..eed1869
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/invalidID.errors.txt
@@ -0,0 +1 @@
+1:1:"1" is not a valid id
diff --git a/tests/auto/declarative/qmlparser/invalidID.txt b/tests/auto/declarative/qmlparser/invalidID.txt
new file mode 100644
index 0000000..f91e8c4
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/invalidID.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ id: 1
+}
diff --git a/tests/auto/declarative/qmlparser/missingObject.errors.txt b/tests/auto/declarative/qmlparser/missingObject.errors.txt
new file mode 100644
index 0000000..8438b9e
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/missingObject.errors.txt
@@ -0,0 +1 @@
+1:10:Syntax error
diff --git a/tests/auto/declarative/qmlparser/missingObject.txt b/tests/auto/declarative/qmlparser/missingObject.txt
new file mode 100644
index 0000000..2f17045
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/missingObject.txt
@@ -0,0 +1 @@
+something: 24
diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.1.errors.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.1.errors.txt
new file mode 100644
index 0000000..406ad83
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nonexistantProperty.1.errors.txt
@@ -0,0 +1 @@
+1:-1:Unknown property "something"
diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.1.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.1.txt
new file mode 100644
index 0000000..5023b38
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nonexistantProperty.1.txt
@@ -0,0 +1 @@
+MyQmlObject { something: 24 }
diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.2.errors.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.2.errors.txt
new file mode 100644
index 0000000..b371a0f
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nonexistantProperty.2.errors.txt
@@ -0,0 +1 @@
+2:-1:Unknown property "something"
diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.2.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.2.txt
new file mode 100644
index 0000000..3b6cfa6
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nonexistantProperty.2.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ something: 24
+}
diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.3.errors.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.3.errors.txt
new file mode 100644
index 0000000..b371a0f
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nonexistantProperty.3.errors.txt
@@ -0,0 +1 @@
+2:-1:Unknown property "something"
diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.3.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.3.txt
new file mode 100644
index 0000000..61f3625
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nonexistantProperty.3.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ something: 1 + 1
+}
diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.4.errors.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.4.errors.txt
new file mode 100644
index 0000000..b371a0f
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nonexistantProperty.4.errors.txt
@@ -0,0 +1 @@
+2:-1:Unknown property "something"
diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.4.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.4.txt
new file mode 100644
index 0000000..5ee1d3a
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nonexistantProperty.4.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ something: ;
+}
diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.5.errors.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.5.errors.txt
new file mode 100644
index 0000000..4234fca4
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nonexistantProperty.5.errors.txt
@@ -0,0 +1 @@
+2:5:Unexpected token `numeric literal'
diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.5.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.5.txt
new file mode 100644
index 0000000..1dc6985
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nonexistantProperty.5.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ 24
+}
diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.6.errors.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.6.errors.txt
new file mode 100644
index 0000000..3183b6d
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nonexistantProperty.6.errors.txt
@@ -0,0 +1 @@
+2:-1:Cannot assign to default property
diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.6.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.6.txt
new file mode 100644
index 0000000..4940833
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nonexistantProperty.6.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ MyQmlObject {}
+}
diff --git a/tests/auto/declarative/qmlparser/nullDotProperty.errors.txt b/tests/auto/declarative/qmlparser/nullDotProperty.errors.txt
new file mode 100644
index 0000000..8482634
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nullDotProperty.errors.txt
@@ -0,0 +1 @@
+2:-1:Cannot set properties on obj as it is null
diff --git a/tests/auto/declarative/qmlparser/nullDotProperty.txt b/tests/auto/declarative/qmlparser/nullDotProperty.txt
new file mode 100644
index 0000000..5c60c5b
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/nullDotProperty.txt
@@ -0,0 +1,3 @@
+MyDotPropertyObject {
+ obj.value: 1
+}
diff --git a/tests/auto/declarative/qmlparser/qmlparser.pro b/tests/auto/declarative/qmlparser/qmlparser.pro
index 3e0b6ea..43e5309 100644
--- a/tests/auto/declarative/qmlparser/qmlparser.pro
+++ b/tests/auto/declarative/qmlparser/qmlparser.pro
@@ -1,3 +1,4 @@
load(qttest_p4)
contains(QT_CONFIG,declarative): QT += declarative
SOURCES += tst_qmlparser.cpp
+macx:CONFIG -= app_bundle
diff --git a/tests/auto/declarative/qmlparser/readOnly.1.errors.txt b/tests/auto/declarative/qmlparser/readOnly.1.errors.txt
new file mode 100644
index 0000000..89009ce
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/readOnly.1.errors.txt
@@ -0,0 +1 @@
+2:21:Cannot assign value "Hello World" to the read-only property readOnlyString
diff --git a/tests/auto/declarative/qmlparser/readOnly.1.txt b/tests/auto/declarative/qmlparser/readOnly.1.txt
new file mode 100644
index 0000000..c47fdf3
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/readOnly.1.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ readOnlyString: "Hello World"
+}
diff --git a/tests/auto/declarative/qmlparser/readOnly.2.errors.txt b/tests/auto/declarative/qmlparser/readOnly.2.errors.txt
new file mode 100644
index 0000000..ab27946
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/readOnly.2.errors.txt
@@ -0,0 +1 @@
+2:-1:Cannot assign a binding to read-only property "readOnlyString"
diff --git a/tests/auto/declarative/qmlparser/readOnly.2.txt b/tests/auto/declarative/qmlparser/readOnly.2.txt
new file mode 100644
index 0000000..2b6f733
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/readOnly.2.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ readOnlyString: "Hello" + "World"
+}
diff --git a/tests/auto/declarative/qmlparser/simpleContainer.txt b/tests/auto/declarative/qmlparser/simpleContainer.txt
new file mode 100644
index 0000000..8b30ed9
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/simpleContainer.txt
@@ -0,0 +1,4 @@
+MyContainer {
+ MyQmlObject {}
+ MyQmlObject {}
+}
diff --git a/tests/auto/declarative/qmlparser/simpleObject.txt b/tests/auto/declarative/qmlparser/simpleObject.txt
new file mode 100644
index 0000000..05ed87a
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/simpleObject.txt
@@ -0,0 +1 @@
+MyQmlObject {}
diff --git a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
index efd45d3..f17583a 100644
--- a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
+++ b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp
@@ -1,6 +1,8 @@
#include <qtest.h>
#include <QtDeclarative/qmlengine.h>
#include <QtDeclarative/qmlcomponent.h>
+#include <QtCore/qfile.h>
+#include <QtCore/qdebug.h>
class MyInterface
{
@@ -43,7 +45,7 @@ public:
MyInterface *interface() const { return m_interface; }
void setInterface(MyInterface *iface) { m_interface = iface; }
- Q_CLASSINFO("defaultMethod", "basicSlot()");
+ Q_CLASSINFO("DefaultMethod", "basicSlot()");
public slots:
void basicSlot() { qWarning("MyQmlObject::basicSlot"); }
@@ -133,27 +135,16 @@ public:
tst_qmlparser() {}
private slots:
+
+ void errors_data();
+ void errors();
+
void simpleObject();
void simpleContainer();
- void unregisteredObject();
- void nonexistantProperty();
- void unsupportedProperty();
- //void setProperties();
- void wrongType();
- void readOnly();
- //void dotProperties();
- void nullDotProperty();
- void fakeDotProperty();
- //void readWriteDotProperty();
- void emptyInput();
- void missingObject();
- //void invalidXML();
- void duplicateIDs();
- void invalidID();
void interfaceProperty();
void interfaceQmlList();
void interfaceQList();
- //void cannotAssignBindingToSignal();
+
void assignObjectToSignal();
// regression tests for crashes
@@ -163,242 +154,101 @@ private:
QmlEngine engine;
};
-void tst_qmlparser::simpleObject()
-{
- QmlComponent component(&engine, "MyQmlObject {}");
- QObject *object = component.create();
- QVERIFY(object != 0);
-}
+#define VERIFY_ERRORS(errorfile) \
+ if (!errorfile) { \
+ QVERIFY(!component.isError()); \
+ QVERIFY(component.errors().isEmpty()); \
+ } else { \
+ QFile file(errorfile); \
+ QVERIFY(file.open(QIODevice::ReadOnly)); \
+ QByteArray data = file.readAll(); \
+ QList<QByteArray> expected = data.split('\n'); \
+ expected.removeAll(QByteArray("")); \
+ QList<QmlError> errors = component.errors(); \
+ QList<QByteArray> actual; \
+ for (int ii = 0; ii < errors.count(); ++ii) { \
+ const QmlError &error = errors.at(ii); \
+ QByteArray errorStr = QByteArray::number(error.line()) + ":" + \
+ QByteArray::number(error.column()) + ":" + \
+ error.description().toUtf8(); \
+ actual << errorStr; \
+ } \
+ if (qgetenv("DEBUG") != "") \
+ qWarning() << expected << actual; \
+ QCOMPARE(expected, actual); \
+ }
-void tst_qmlparser::simpleContainer()
-{
- QmlComponent component(&engine, "MyContainer {\nMyQmlObject{}\nMyQmlObject{}\n}");
- MyContainer *container= qobject_cast<MyContainer*>(component.create());
- QVERIFY(container != 0);
- QCOMPARE(container->children()->count(),2);
-}
+#define TEST_FILE(filename) \
+ QUrl::fromLocalFile(QApplication::applicationDirPath() + "/" + filename)
-void tst_qmlparser::unregisteredObject()
+void tst_qmlparser::errors_data()
{
- QmlComponent component(&engine, "UnRegisteredObject {}", QUrl("myprogram.qml"));
- QTest::ignoreMessage(QtWarningMsg, "Unable to create object of type 'UnRegisteredObject' @myprogram.qml:1");
- QObject *object = component.create();
- QVERIFY(object == 0);
-}
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("errorFile");
+ QTest::addColumn<bool>("create");
-void tst_qmlparser::nonexistantProperty()
-{
- //NOTE: these first 3 should all have the same error message
- {
- QmlComponent component(&engine, "MyQmlObject { something: 24 }");
- QTest::ignoreMessage(QtWarningMsg, "Unknown property 'something' @<unspecified file>:1");
- QObject *object = component.create();
- QVERIFY(object == 0);
- }
+ QTest::newRow("nonExistantProperty.1") << "nonexistantProperty.1.txt" << "nonexistantProperty.1.errors.txt" << true;
+ QTest::newRow("nonExistantProperty.2") << "nonexistantProperty.2.txt" << "nonexistantProperty.2.errors.txt" << true;
+ QTest::newRow("nonExistantProperty.3") << "nonexistantProperty.3.txt" << "nonexistantProperty.3.errors.txt" << true;
+ QTest::newRow("nonExistantProperty.4") << "nonexistantProperty.4.txt" << "nonexistantProperty.4.errors.txt" << true;
+ QTest::newRow("nonExistantProperty.5") << "nonexistantProperty.5.txt" << "nonexistantProperty.5.errors.txt" << false;
+ QTest::newRow("nonExistantProperty.6") << "nonexistantProperty.6.txt" << "nonexistantProperty.6.errors.txt" << true;
- {
- QmlComponent component(&engine, "MyQmlObject {\n something: 24\n}");
- QTest::ignoreMessage(QtWarningMsg, "Unknown property 'something' @<unspecified file>:2");
- QObject *object = component.create();
- QVERIFY(object == 0);
- }
- //non-existant using binding
- {
- QmlComponent component(&engine, "MyQmlObject { something: 1 + 1 }");
- QTest::ignoreMessage(QtWarningMsg, "Unknown property 'something' @<unspecified file>:1");
- QObject *object = component.create();
- QVERIFY(object == 0);
- }
+ QTest::newRow("wrongType (string for int)") << "wrongType.1.txt" << "wrongType.1.errors.txt" << false;
+ QTest::newRow("wrongType (int for bool)") << "wrongType.2.txt" << "wrongType.2.errors.txt" << false;
+ QTest::newRow("wrongType (bad rect)") << "wrongType.3.txt" << "wrongType.3.errors.txt" << false;
- {
- QmlComponent component(&engine, "MyQmlObject { something: }");
- QObject *object = component.create();
- QVERIFY(object != 0);
- }
- //non-existant value-type default property
- {
- QmlComponent component(&engine, "MyQmlObject {\n24\n}");
- QTest::ignoreMessage(QtWarningMsg, "Unable to resolve default property @<unspecified file>:3");
- // XXX would 2 be a better line number in this case? Message should also be improved.
- QObject *object = component.create();
- QVERIFY(object == 0);
- }
+ QTest::newRow("nonExistantProperty.1") << "readOnly.1.txt" << "readOnly.1.errors.txt" << false;
+ QTest::newRow("nonExistantProperty.2") << "readOnly.2.txt" << "readOnly.2.errors.txt" << true;
- //non-existant object-type default property
- {
- QmlComponent component(&engine, "MyQmlObject {\nMyQmlObject{}\n}");
- QTest::ignoreMessage(QtWarningMsg, "Unable to assign to non-existant property @<unspecified file>:2");
- // XXX Message needs to be improved (and should be closer to value-type message).
- QObject *object = component.create();
- QVERIFY(object == 0);
- }
-}
-void tst_qmlparser::unsupportedProperty()
-{
- QTest::ignoreMessage(QtWarningMsg, "Property 'matrix' is of an unknown type @<unspecified file>:1");
- QmlComponent component(&engine, "MyQmlObject { matrix: \"1,0,0,0,1,0,0,0,1\" }");
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object == 0);
+ QTest::newRow("unsupportedProperty") << "unsupportedProperty.txt" << "unsupportedProperty.errors.txt" << true;
+ QTest::newRow("nullDotProperty") << "nullDotProperty.txt" << "nullDotProperty.errors.txt" << true;
+ QTest::newRow("fakeDotProperty") << "fakeDotProperty.txt" << "fakeDotProperty.errors.txt" << true;
+ QTest::newRow("duplicateIDs") << "duplicateIDs.txt" << "duplicateIDs.errors.txt" << false;
+ QTest::newRow("invalidID") << "invalidID.txt" << "invalidID.errors.txt" << false;
+ QTest::newRow("unregisteredObject") << "unregisteredObject.txt" << "unregisteredObject.errors.txt" << false;
+ QTest::newRow("empty") << "empty.txt" << "empty.errors.txt" << false;
+ QTest::newRow("missingObject") << "missingObject.txt" << "missingObject.errors.txt" << false;
}
-void tst_qmlparser::wrongType()
+void tst_qmlparser::errors()
{
- //string for int
- {
- QTest::ignoreMessage(QtWarningMsg, "Can't assign value 'hello' to property 'value' @<unspecified file>:1");
- QmlComponent component(&engine, "MyQmlObject { value: \"hello\" }");
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object == 0);
- }
-
- //int for bool
- {
- QTest::ignoreMessage(QtWarningMsg, "Can't assign value '5' to property 'enabled' @<unspecified file>:1");
- QmlComponent component(&engine, "MyQmlObject { enabled: 5 }");
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object == 0);
- }
+ QFETCH(QString, file);
+ QFETCH(QString, errorFile);
+ QFETCH(bool, create);
- //bad format for rect
- {
- QTest::ignoreMessage(QtWarningMsg, "Can't assign value '5,5x10' to property 'rect' @<unspecified file>:1");
- QmlComponent component(&engine, "MyQmlObject { rect: \"5,5x10\" }");
- MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
- QVERIFY(object == 0);
- }
-
- //TODO: more types (including float-to-int, complex types, etc)
-}
-
-void tst_qmlparser::readOnly()
-{
- {
- QTest::ignoreMessage(QtWarningMsg, "Can't assign value 'hello' to property 'readOnlyString' because 'readOnlyString' is read-only @<unspecified file>:1");
- QmlComponent component(&engine, "MyQmlObject { readOnlyString: \"hello\" }");
- QObject *object = component.create();
- QVERIFY(object == 0);
- }
+ QmlComponent component(&engine, TEST_FILE(file));
- {
- QTest::ignoreMessage(QtWarningMsg, "Can't assign a binding to property 'readOnlyString' because 'readOnlyString' is read-only @<unspecified file>:1");
- QmlComponent component(&engine, "MyQmlObject { readOnlyString: {'hello'} }");
+ if(create) {
QObject *object = component.create();
QVERIFY(object == 0);
}
-}
-void tst_qmlparser::nullDotProperty()
-{
- QTest::ignoreMessage(QtWarningMsg, "Can't set properties on 'obj' because it is null @<unspecified file>:1");
- QmlComponent component(&engine, "MyDotPropertyObject { obj.value: 1 }");
- QObject *object = component.create();
- QVERIFY(object == 0);
+ VERIFY_ERRORS(errorFile.toLatin1().constData());
}
-void tst_qmlparser::fakeDotProperty()
+void tst_qmlparser::simpleObject()
{
- QTest::ignoreMessage(QtWarningMsg, "Can't set properties on 'value' because it isn't a known object type @<unspecified file>:1");
- QmlComponent component(&engine, "MyQmlObject { value.something: \"hello\" }");
+ QmlComponent component(&engine, TEST_FILE("simpleObject.txt"));
+ VERIFY_ERRORS(0);
QObject *object = component.create();
- QVERIFY(object == 0);
-}
-
-//XXX need to define correct behavior first
-/*void tst_qmlparser::readWriteDotProperty()
-{
- QmlComponent component(&engine, "MyDotPropertyObject { readWriteObj.value: 1 }");
- MyDotPropertyObject *object = qobject_cast<MyDotPropertyObject*>(component.create());
QVERIFY(object != 0);
- QCOMPARE(object->readWriteObj()->value(),1);
-
- {
- QmlComponent component(&engine, "MyContainer { MyQmlObject { id: Obj value: 1 } MyDotPropertyObject { readWriteObj: Obj } }");
- MyContainer *object = qobject_cast<MyContainer*>(component.create());
- QVERIFY(object != 0);
- MyDotPropertyObject *dpo = qobject_cast<MyDotPropertyObject *>(object->children()->at(1));
- QCOMPARE(dpo->readWriteObj()->value(),1);
- }
-}*/
-
-void tst_qmlparser::emptyInput()
-{
- QTest::ignoreMessage(QtCriticalMsg, "No Qml was specified for parsing.");
- QTest::ignoreMessage(QtWarningMsg, "Can't compile because of earlier errors @<unspecified file>:-1");
- QmlComponent component(&engine, "");
- QObject *object = component.create();
- QVERIFY(object == 0);
-}
-
-void tst_qmlparser::missingObject()
-{
- QTest::ignoreMessage(QtCriticalMsg, "Can't have a property with no object @<unspecified file>:1");
- QTest::ignoreMessage(QtWarningMsg, "Can't compile because of earlier errors @<unspecified file>:-1");
- QmlComponent component(&engine, "something:");
- QObject *object = component.create();
- QVERIFY(object == 0);
-}
-
-
-/*void tst_qmlparser::invalidXML()
-{
- //extra stuff on end
- {
- QTest::ignoreMessage(QtCriticalMsg, "Extra content at end of document. @myprogram.qml:1");
- QTest::ignoreMessage(QtWarningMsg, "Can't compile because of earlier errors @myprogram.qml:-1");
- QmlComponent component(&engine, "<MyQmlObject/><something/>", QUrl("myprogram.qml"));
- QObject *object = component.create();
- QVERIFY(object == 0);
- }
-
- //mismatched tags
- {
- QTest::ignoreMessage(QtCriticalMsg, "Opening and ending tag mismatch. @myprogram.qml:2");
- QTest::ignoreMessage(QtWarningMsg, "Can't compile because of earlier errors @myprogram.qml:-1");
- QmlComponent component(&engine, "<MyQmlObject>\n</MyContainer>", QUrl("myprogram.qml"));
- QObject *object = component.create();
- QVERIFY(object == 0);
- }
-
- {
- QTest::ignoreMessage(QtCriticalMsg, "Expected '>' or '/', but got '<'. @myprogram.qml:1");
- QTest::ignoreMessage(QtWarningMsg, "Can't compile because of earlier errors @myprogram.qml:-1");
- QmlComponent component(&engine, "<MyQmlObject < />", QUrl("myprogram.qml"));
- QObject *object = component.create();
- QVERIFY(object == 0);
- }
-
- {
- QTest::ignoreMessage(QtCriticalMsg, "Premature end of document. @myprogram.qml:1");
- QTest::ignoreMessage(QtWarningMsg, "Can't compile because of earlier errors @myprogram.qml:-1");
- QmlComponent component(&engine, "<MyQmlObject something=\" />", QUrl("myprogram.qml"));
- QObject *object = component.create();
- QVERIFY(object == 0);
- }
-
-}*/
-
-void tst_qmlparser::duplicateIDs()
-{
- QTest::ignoreMessage(QtWarningMsg, "An id (\"MyID\") is not unique within its scope. @<unspecified file>:3");
- QmlComponent component(&engine, "MyContainer {\nMyQmlObject { id: MyID }\nMyQmlObject { id: MyID }\n}");
- QObject *object = component.create();
- QVERIFY(object == 0);
}
-void tst_qmlparser::invalidID()
+void tst_qmlparser::simpleContainer()
{
- QTest::ignoreMessage(QtWarningMsg, "'1' is not a valid id @<unspecified file>:1");
- QmlComponent component(&engine, "MyQmlObject { id: 1 }");
- QObject *object = component.create();
- QVERIFY(object == 0);
+ QmlComponent component(&engine, TEST_FILE("simpleContainer.txt"));
+ MyContainer *container= qobject_cast<MyContainer*>(component.create());
+ QVERIFY(container != 0);
+ QCOMPARE(container->children()->count(),2);
}
void tst_qmlparser::interfaceProperty()
{
- QmlComponent component(&engine, "MyQmlObject { interface: MyQmlObject }");
+ QmlComponent component(&engine, TEST_FILE("interfaceProperty.txt"));
MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
QVERIFY(object != 0);
QVERIFY(object->interface());
@@ -407,7 +257,7 @@ void tst_qmlparser::interfaceProperty()
void tst_qmlparser::interfaceQmlList()
{
- QmlComponent component(&engine, "MyContainer { qmllistInterfaces: MyQmlObject {} }");
+ QmlComponent component(&engine, TEST_FILE("interfaceQmlList.txt"));
MyContainer *container= qobject_cast<MyContainer*>(component.create());
QVERIFY(container != 0);
QVERIFY(container->qmllistAccessor().count() == 2);
@@ -417,7 +267,7 @@ void tst_qmlparser::interfaceQmlList()
void tst_qmlparser::interfaceQList()
{
- QmlComponent component(&engine, "MyContainer { qlistInterfaces: MyQmlObject {} }");
+ QmlComponent component(&engine, TEST_FILE("interfaceQList.txt"));
MyContainer *container= qobject_cast<MyContainer*>(component.create());
QVERIFY(container != 0);
QVERIFY(container->qlistInterfaces()->count() == 2);
@@ -425,17 +275,9 @@ void tst_qmlparser::interfaceQList()
QVERIFY(container->qlistInterfaces()->at(ii)->id == 913);
}
-/*void tst_qmlparser::cannotAssignBindingToSignal()
-{
- QTest::ignoreMessage(QtWarningMsg, "Cannot assign binding to signal property @<unspecified file>:1");
- QmlComponent component(&engine, "<MyQmlObject onBasicSignal=\"{print(1921)}\" />");
- MyContainer *container= qobject_cast<MyContainer*>(component.create());
- QVERIFY(container == 0);
-}*/
-
void tst_qmlparser::assignObjectToSignal()
{
- QmlComponent component(&engine, "MyQmlObject { onBasicSignal: MyQmlObject {} }");
+ QmlComponent component(&engine, TEST_FILE("assignObjectToSignal.txt"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot");
@@ -445,7 +287,6 @@ void tst_qmlparser::assignObjectToSignal()
void tst_qmlparser::crash1()
{
QmlComponent component(&engine, "Component {}");
- MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
}
QTEST_MAIN(tst_qmlparser)
diff --git a/tests/auto/declarative/qmlparser/unregisteredObject.errors.txt b/tests/auto/declarative/qmlparser/unregisteredObject.errors.txt
new file mode 100644
index 0000000..11e4e16
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/unregisteredObject.errors.txt
@@ -0,0 +1 @@
+-1:-1:Type UnregisteredObject unavailable
diff --git a/tests/auto/declarative/qmlparser/unregisteredObject.txt b/tests/auto/declarative/qmlparser/unregisteredObject.txt
new file mode 100644
index 0000000..ff46457
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/unregisteredObject.txt
@@ -0,0 +1 @@
+UnregisteredObject {}
diff --git a/tests/auto/declarative/qmlparser/unsupportedProperty.errors.txt b/tests/auto/declarative/qmlparser/unsupportedProperty.errors.txt
new file mode 100644
index 0000000..f396e7e
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/unsupportedProperty.errors.txt
@@ -0,0 +1 @@
+2:-1:Property matrix is of an unknown type
diff --git a/tests/auto/declarative/qmlparser/unsupportedProperty.txt b/tests/auto/declarative/qmlparser/unsupportedProperty.txt
new file mode 100644
index 0000000..bbbd31d
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/unsupportedProperty.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ matrix: "1,0,0,0,1,0,0,0,1"
+}
diff --git a/tests/auto/declarative/qmlparser/wrongType.1.errors.txt b/tests/auto/declarative/qmlparser/wrongType.1.errors.txt
new file mode 100644
index 0000000..8976ee1
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/wrongType.1.errors.txt
@@ -0,0 +1 @@
+2:12:Cannot assign value "hello" to property value
diff --git a/tests/auto/declarative/qmlparser/wrongType.1.txt b/tests/auto/declarative/qmlparser/wrongType.1.txt
new file mode 100644
index 0000000..281a227
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/wrongType.1.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ value: "hello"
+}
diff --git a/tests/auto/declarative/qmlparser/wrongType.2.errors.txt b/tests/auto/declarative/qmlparser/wrongType.2.errors.txt
new file mode 100644
index 0000000..301d258
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/wrongType.2.errors.txt
@@ -0,0 +1 @@
+2:14:Cannot assign value "5" to property enabled
diff --git a/tests/auto/declarative/qmlparser/wrongType.2.txt b/tests/auto/declarative/qmlparser/wrongType.2.txt
new file mode 100644
index 0000000..cdedf8c
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/wrongType.2.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ enabled: 5
+}
diff --git a/tests/auto/declarative/qmlparser/wrongType.3.errors.txt b/tests/auto/declarative/qmlparser/wrongType.3.errors.txt
new file mode 100644
index 0000000..3afcc2b
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/wrongType.3.errors.txt
@@ -0,0 +1 @@
+2:11:Cannot assign value "5,5x10" to property rect
diff --git a/tests/auto/declarative/qmlparser/wrongType.3.txt b/tests/auto/declarative/qmlparser/wrongType.3.txt
new file mode 100644
index 0000000..839e0c7
--- /dev/null
+++ b/tests/auto/declarative/qmlparser/wrongType.3.txt
@@ -0,0 +1,3 @@
+MyQmlObject {
+ rect: "5,5x10"
+}