summaryrefslogtreecommitdiff
path: root/examples/location/places/views/CategoryDelegate.qml
blob: ef013de8d87d32c9cb987b1f76bf0dd6cda9694a (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
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtQuick.Controls
import QtLocation

Item {
    id: root

    property alias text: labelItem.text
    property bool checked: false
    signal searchCategory()
    signal showSubcategories()

    height: Math.max(icon.height, labelItem.height * 2)

    Image {
        id: icon
        anchors.left: parent.left
        anchors.leftMargin: 30
        anchors.verticalCenter: parent.verticalCenter
        source: category.icon.url()
    }

    Rectangle {
        anchors.fill: parent
        color: "#44ffffff"
        visible: mouse.pressed
    }

    //! [CategoryModel delegate text]
    Label {
        id: labelItem
        text: category.name
        anchors.left: icon.right
        anchors.verticalCenter: parent.verticalCenter
        anchors.right: arrow.left
    }

    MouseArea {
        id: mouse
        anchors.fill: parent
        onClicked: root.searchCategory()
    }
    //! [CategoryModel delegate text]

    Rectangle {
        anchors.left: parent.left
        anchors.right: parent.right
        anchors.margins: 15
        height: 1
        color: "#46a2da"
    }
    //! [CategoryModel delegate arrow]
    ToolButton {
        id: arrow
        anchors.right: parent.right
        anchors.verticalCenter: parent.verticalCenter
        anchors.rightMargin: 15
        visible: model.hasModelChildren
        icon.source: Qt.resolvedUrl("../resources/right.png")
        onClicked: root.showSubcategories()
    }
    //! [CategoryModel delegate arrow]
}