2019-08-21 18:39:07 +10:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
|
|
|
|
HButton {
|
|
|
|
id: tile
|
|
|
|
|
|
|
|
signal activated()
|
|
|
|
|
2019-08-21 20:02:00 +10:00
|
|
|
property HListView view: ListView.view
|
|
|
|
property bool shouldBeCurrent: false
|
2019-08-21 18:39:07 +10:00
|
|
|
|
|
|
|
readonly property var delegateModel: model
|
|
|
|
|
|
|
|
default property var additionalItems: []
|
|
|
|
|
|
|
|
readonly property alias title: title
|
|
|
|
readonly property alias additionalInfo: additionalInfo
|
|
|
|
readonly property alias rightInfo: rightInfo
|
|
|
|
readonly property alias subtitle: subtitle
|
2019-08-24 00:53:54 +10:00
|
|
|
readonly property alias setCurrentTimer: setCurrentTimer
|
2019-08-21 18:39:07 +10:00
|
|
|
|
2019-08-22 04:58:57 +10:00
|
|
|
property HMenu contextMenu: HMenu {}
|
|
|
|
|
2019-08-21 18:39:07 +10:00
|
|
|
property Item image
|
|
|
|
|
|
|
|
property Item details: HColumnLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
HRowLayout {
|
|
|
|
spacing: tile.spacing
|
|
|
|
|
|
|
|
HLabel {
|
|
|
|
id: title
|
2019-08-21 20:02:00 +10:00
|
|
|
text: "Missing title"
|
2019-08-21 18:39:07 +10:00
|
|
|
elide: Text.ElideRight
|
|
|
|
verticalAlignment: Qt.AlignVCenter
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
|
|
|
HRowLayout {
|
|
|
|
id: additionalInfo
|
|
|
|
}
|
|
|
|
|
|
|
|
HLabel {
|
|
|
|
id: rightInfo
|
|
|
|
font.pixelSize: theme.fontSize.small
|
|
|
|
|
|
|
|
visible: Layout.maximumWidth > 0
|
|
|
|
Layout.maximumWidth:
|
|
|
|
text && tile.width >= 200 ? implicitWidth : 0
|
|
|
|
|
|
|
|
Behavior on Layout.maximumWidth { HNumberAnimation {} }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HRichLabel {
|
|
|
|
id: subtitle
|
|
|
|
textFormat: Text.StyledText
|
|
|
|
font.pixelSize: theme.fontSize.small
|
|
|
|
elide: Text.ElideRight
|
|
|
|
|
|
|
|
visible: Layout.maximumHeight > 0
|
|
|
|
Layout.maximumHeight: text ? implicitWidth : 0
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
Behavior on Layout.maximumHeight { HNumberAnimation {} }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
contentItem: HRowLayout {
|
|
|
|
spacing: tile.spacing
|
|
|
|
children: [image, details].concat(additionalItems)
|
|
|
|
}
|
|
|
|
|
2019-08-21 20:02:00 +10:00
|
|
|
onActivated: view.currentIndex = model.index
|
2019-08-21 18:39:07 +10:00
|
|
|
|
|
|
|
|
|
|
|
Timer {
|
2019-08-24 00:53:54 +10:00
|
|
|
id: setCurrentTimer
|
2019-08-21 18:39:07 +10:00
|
|
|
interval: 100
|
|
|
|
repeat: true
|
2019-08-24 00:53:54 +10:00
|
|
|
running: true
|
2019-08-21 18:39:07 +10:00
|
|
|
// Component.onCompleted won't work for this
|
2019-08-21 20:02:00 +10:00
|
|
|
onTriggered: if (shouldBeCurrent) view.currentIndex = model.index
|
2019-08-21 18:39:07 +10:00
|
|
|
}
|
2019-08-22 04:58:57 +10:00
|
|
|
|
|
|
|
TapHandler {
|
|
|
|
acceptedButtons: Qt.LeftButton
|
|
|
|
onTapped: {
|
|
|
|
view.highlightRangeMode = ListView.NoHighlightRange
|
|
|
|
view.highlightMoveDuration = 0
|
|
|
|
activated()
|
|
|
|
view.highlightRangeMode = ListView.ApplyRange
|
|
|
|
view.highlightMoveDuration = theme.animationDuration
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TapHandler {
|
|
|
|
acceptedButtons: Qt.RightButton
|
|
|
|
onTapped: if (contextMenu.count > 0) contextMenu.popup()
|
|
|
|
}
|
|
|
|
|
|
|
|
TapHandler {
|
|
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
|
|
onLongPressed: if (contextMenu.count > 0) contextMenu.popup()
|
|
|
|
}
|
2019-08-21 18:39:07 +10:00
|
|
|
}
|