Initial import from the monolithic Qt.
[profile/ivi/qtdeclarative.git] / tests / auto / declarative / qdeclarativeitem / data / mapCoordinates.qml
1 import QtQuick 1.0
2
3 Item {
4     id: root; objectName: "root"
5     width: 200; height: 200
6
7     Item { id: itemA; objectName: "itemA"; x: 50; y: 50 }
8
9     Item {
10         x: 50; y: 50
11         Item { id: itemB; objectName: "itemB"; x: 100; y: 100 }
12     }
13
14     function mapAToB(x, y) {
15         var pos = itemA.mapToItem(itemB, x, y)
16         return Qt.point(pos.x, pos.y)
17     }
18
19     function mapAFromB(x, y) {
20         var pos = itemA.mapFromItem(itemB, x, y)
21         return Qt.point(pos.x, pos.y)
22     }
23
24     function mapAToNull(x, y) {
25         var pos = itemA.mapToItem(null, x, y)
26         return Qt.point(pos.x, pos.y)
27     }
28
29     function mapAFromNull(x, y) {
30         var pos = itemA.mapFromItem(null, x, y)
31         return Qt.point(pos.x, pos.y)
32     }
33
34     function checkMapAToInvalid(x, y) {
35         var pos = itemA.mapToItem(1122, x, y)
36         return pos.x == undefined && pos.y == undefined
37     }
38
39     function checkMapAFromInvalid(x, y) {
40         var pos = itemA.mapFromItem(1122, x, y)
41         return pos.x == undefined && pos.y == undefined
42     }
43 }