tests/auto/declarative/qdeclarativeitem/data/mapCoordinates.qml
author William Roberts <williamr@symbian.org>
Thu, 22 Jul 2010 16:41:55 +0100
branchGCC_SURGE
changeset 31 5daf16870df6
parent 30 5dc02b23752f
permissions -rw-r--r--
Catchup to latest Symbian^4

import Qt 4.7

Item {
    id: root; objectName: "root"
    width: 200; height: 200

    Item { id: itemA; objectName: "itemA"; x: 50; y: 50 }

    Item {
        x: 50; y: 50
        Item { id: itemB; objectName: "itemB"; x: 100; y: 100 }
    }

    function mapAToB(x, y) {
        var pos = itemA.mapToItem(itemB, x, y)
        return Qt.point(pos.x, pos.y)
    }

    function mapAFromB(x, y) {
        var pos = itemA.mapFromItem(itemB, x, y)
        return Qt.point(pos.x, pos.y)
    }

    function mapAToNull(x, y) {
        var pos = itemA.mapToItem(null, x, y)
        return Qt.point(pos.x, pos.y)
    }

    function mapAFromNull(x, y) {
        var pos = itemA.mapFromItem(null, x, y)
        return Qt.point(pos.x, pos.y)
    }

    function checkMapAToInvalid(x, y) {
        var pos = itemA.mapToItem(1122, x, y)
        return pos.x == undefined && pos.y == undefined
    }

    function checkMapAFromInvalid(x, y) {
        var pos = itemA.mapFromItem(1122, x, y)
        return pos.x == undefined && pos.y == undefined
    }
}