aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickpathview/data/qtbug42716.qml
blob: 81d52d5ea34237de9937728773316572aa8a7384 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import QtQuick 2.0

Rectangle {
    //Note that this file was originally the manual reproduction, MouseAreas were left in.
    id: qmlBrowser

    width: 500
    height: 350

    ListModel {
        id: myModel
        ListElement {
            name: "Bill Jones 0"
        }
        ListElement {
            name: "Jane Doe 1"
        }
        ListElement {
            name: "John Smith 2"
        }
        ListElement {
            name: "Bill Jones 3"
        }
        ListElement {
            name: "Jane Doe 4"
        }
        ListElement {
            name: "John Smith 5"
        }
        ListElement {
            name: "John Smith 6"
        }
        ListElement {
            name: "John Smith 7"
        }
    }

    Component {
        id: delegate

        Text {
            id: nameText
            height: 33
            width: parent.width
            objectName: "delegate"+index

            text: "index: " + index + "   text: " + name
            font.pointSize: 16
            color: PathView.isCurrentItem ? "red" : "black"
        }
    }

    PathView {
        id: contentList
        objectName: "pathView"
        anchors.fill: parent

        property int maxPathItemCount: 7
        property real itemHeight: 34

        delegate: delegate
        model: myModel
        currentIndex: 5
        pathItemCount: maxPathItemCount
        highlightMoveDuration: 0

        path: Path {
            startX: 30 + contentList.width / 2
            startY: 30
            PathLine {
                relativeX: 0
                relativeY: contentList.itemHeight * contentList.maxPathItemCount
            }
        }

        focus: true
        Keys.onLeftPressed: decrementCurrentIndex()
        Keys.onRightPressed: incrementCurrentIndex()
    }

    Column {
        anchors.right: parent.right
        Text {
            text: "Go 1"
            font.weight: Font.Bold
            font.pixelSize: 24
            MouseArea {
                anchors.fill: parent
                onClicked:  contentList.offset = 2.55882
            }
        }
        Text {
            text: "Go 2"
            font.weight: Font.Bold
            font.pixelSize: 24
            MouseArea {
                anchors.fill: parent
                onClicked:  contentList.offset = 0.0882353
            }
        }
        Text {
            text: "Go 3"
            font.weight: Font.Bold
            font.pixelSize: 24
            MouseArea {
                anchors.fill: parent
                onClicked:  contentList.offset = 0.99987
            }
        }
    }
}