summaryrefslogtreecommitdiff
path: root/examples/declarative/qmlplaces/CategoryDelegate.qml
blob: 80fc308c5275e470bd74271c61d4b94499891c7f (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
import QtQuick 2.0
import Qt.location 5.0

Rectangle {
    id: root

    property Category category
    property bool hasSubCategories: false

    signal clicked()
    signal displaySubCategories()

    width: parent.width
    height: c.height + 10

    radius: 10
    gradient: Gradient {
        GradientStop { position: 0.0; color: "lightgray" }
        GradientStop { position: 1.0; color: "gray" }
    }

    Text {
        id: c

        anchors.left: parent.left
        anchors.leftMargin: 5
        anchors.right: line.left
        anchors.rightMargin: 5

        y: 5
        x: 5
        width: parent.width - 10

        text: category.name
        font.pixelSize: 16
        wrapMode: Text.WordWrap

        MouseArea {
            anchors.fill: parent
            onClicked: root.clicked()
        }
    }

    Rectangle {
        id: line

        color: "black"
        width: 1
        y: 2
        height: parent.height - 4
        anchors.right: sub.left
        anchors.rightMargin: 5

        visible: hasSubCategories
    }

    Text {
        id: sub

        anchors.top: c.top
        anchors.bottom: c.bottom
        anchors.right: parent.right
        anchors.rightMargin: 5

        verticalAlignment: Text.AlignVCenter
        horizontalAlignment: Text.AlignRight

        text: ">"
        font.pixelSize: 32

        visible: hasSubCategories

        MouseArea {
            anchors.fill: parent
            onClicked: root.displaySubCategories()
        }
    }
}