Add qml/VerticalList.qml
This commit is contained in:
parent
26b94cc715
commit
bad6e08cee
39
qml/VerticalList.qml
Normal file
39
qml/VerticalList.qml
Normal file
@ -0,0 +1,39 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
Item {
|
||||
id: vl
|
||||
property var itemsModel: []
|
||||
property int currentIndex: 0
|
||||
signal activated(int idx)
|
||||
signal triggered(var entryObj)
|
||||
|
||||
readonly property int count: lv.count
|
||||
|
||||
function positionViewAtIndex(i, mode) { lv.positionViewAtIndex(i, mode) }
|
||||
function triggerCurrent() {
|
||||
if (lv.currentItem && lv.currentItem.entryObj) triggered(lv.currentItem.entryObj)
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: lv
|
||||
anchors.fill: parent
|
||||
model: vl.itemsModel
|
||||
spacing: 10
|
||||
currentIndex: vl.currentIndex
|
||||
clip: true
|
||||
boundsBehavior: Flickable.StopAtBounds
|
||||
|
||||
delegate: XmbItemDelegate {
|
||||
width: lv.width
|
||||
entryObj: modelData
|
||||
focused: (index === lv.currentIndex)
|
||||
onClicked: {
|
||||
vl.activated(index)
|
||||
vl.triggered(entryObj)
|
||||
}
|
||||
}
|
||||
|
||||
onCurrentIndexChanged: vl.activated(currentIndex)
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user