Debian Codegraph @

tests/auto/qml/qqmlqt/data/TestComponent.3.qml

raw
1 import QtQuick 2.0
2
3 Item {
4 id: root
5 objectName: "root"
6 property int zero: 0
7 property int one: 1
8
9 Item {
10 id: c1
11 objectName: "c1"
12 property int one: zero + parent.one
13
14 Item {
15 id: c1c1
16 objectName: "c1c1"
17 property bool two: c2c1c1.two
18 }
19
20 Item {
21 id: c1c2
22 objectName: "c1c2"
23 property string three: "three"
24
25 Rectangle {
26 id: c1c2c3
27 objectName: "c1c2c3"
28 property alias othercolor: c2c1.color
29 color: if (c2c1.color == Qt.rgba(0,0,1)) Qt.rgba(1,0,0); else Qt.rgba(0,1,0);
30 }
31 }
32 }
33
34 Item {
35 id: c2
36 objectName: "c2"
37 property string two: "two"
38
39 Rectangle {
40 id: c2c1
41 objectName: "c2c1"
42 property string three: "2" + c1c2.three
43 color: "blue"
44
45 MouseArea {
46 id: c2c1c1
47 objectName: "c2c1c1"
48 property bool two: false
49 onClicked: two = !two
50 }
51
52 Item {
53 id: c2c1c2
54 objectName: "c2c1c2"
55 property string three: "1" + parent.three
56 }
57 }
58 }
59
60 property alias c1one: c1.one
61 property bool success: true
62 Component.onCompleted: {
63 // test state after initial bindings evaluation
64 if (zero != 0) success = false;
65 if (c1.one != 1) success = false;
66 if (c1c1.two != false) success = false;
67 if (c1c2.three != "three") success = false;
68 if (c1c2c3.color != Qt.rgba(1,0,0)) success = false;
69 if (c2.two != "two") success = false;
70 if (c2c1.three != "2three") success = false;
71 if (c2c1.color != Qt.rgba(0,0,1)) success = false;
72 if (c2c1c1.two != false) success = false;
73 if (c2c1c2.three != "12three") success = false;
74
75 // now retrigger bindings evaluation
76 root.zero = 5;
77 if (c1.one != 6) success = false;
78 root.one = 50;
79 if (c1.one != 55) success = false;
80 c2c1c1.two = true;
81 if (c1c1.two != true) success = false;
82 c1c2.three = "3";
83 if (c2c1.three != "23") success = false;
84 if (c2c1c2.three != "123") success = false;
85 c2c1.color = Qt.rgba(1,0,0);
86 if (c1c2c3.color != Qt.rgba(0,1,0)) success = false;
87 if (c1c2c3.othercolor != Qt.rgba(1,0,0)) success = false;
88 }
89 }