Implement Every & Some aggregate types using attached properties
Could be useful with for a group of delegates which are all instantiated at once without having to modify the model or to implement a proxy model on top. Not quite suitable for item views where delegates are only partially instantiated though.
Sample usage:
aggregate-hovered.qml
pragma ComponentBehavior: Bound
import QtQuick
import org.kde.kitemmodels as KItemModels
Rectangle {
id: root
width: 550
height: 500
color: "#000" // elevation 0
palette.highlight: "#1570A7"
KItemModels.KAggregateSome {
id: aggregate
}
Rectangle {
anchors.fill: parent
anchors.margins: 20
color: "#212121" // elevation 1
border.color: palette.highlight
border.width: hoverHandler.hovered && !aggregate.value ? 3 : 0
radius: 5
HoverHandler {
id: hoverHandler
}
Flow {
anchors.fill: parent
anchors.margins: 10
Repeater {
model: 10
Item {
implicitWidth: 150
implicitHeight: 100
Rectangle {
anchors.fill: parent
anchors.margins: 10
color: "#303030" // elevation 3
border.color: palette.highlight
border.width: hoverHandler.hovered ? 3 : 0
radius: 5
NumberAnimation on radius {}
}
HoverHandler {
id: hoverHandler
KItemModels.KAggregateSome.group: aggregate
KItemModels.KAggregateSome.value: hovered
}
}
}
}
}
}