CategoryDelegate.qml Example File
places/views/CategoryDelegate.qml
import QtQuick 2.5
import QtQuick.Controls 1.4
import QtLocation 5.6
Item {
id: root
property alias text: labelItem.text
property bool checked: false
signal searchCategory()
signal showSubcategories()
width: parent.width
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
}
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()
}
Rectangle {
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: 15
height: 1
color: "#46a2da"
}
ToolButton {
id: arrow
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.rightMargin: 15
visible: model.hasModelChildren
iconSource: "../../resources/right.png"
onClicked: root.showSubcategories()
}
}