[vlc-devel] [PATCH 04/17] qml: show separators between items in KeyNavigableTableView
Prince Gupta
guptaprince8832 at gmail.com
Fri Jun 19 16:06:17 CEST 2020
---
.../qt/widgets/qml/KeyNavigableListView.qml | 4 ++++
.../qt/widgets/qml/KeyNavigableTableView.qml | 21 +++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/modules/gui/qt/widgets/qml/KeyNavigableListView.qml b/modules/gui/qt/widgets/qml/KeyNavigableListView.qml
index 6b7606a998..d1a966f01e 100644
--- a/modules/gui/qt/widgets/qml/KeyNavigableListView.qml
+++ b/modules/gui/qt/widgets/qml/KeyNavigableListView.qml
@@ -75,6 +75,10 @@ NavigableFocusScope {
view.positionViewAtIndex(index, mode)
}
+ function itemAtIndex(index) {
+ return view.itemAtIndex(index)
+ }
+
Component {
id: sectionHeading
diff --git a/modules/gui/qt/widgets/qml/KeyNavigableTableView.qml b/modules/gui/qt/widgets/qml/KeyNavigableTableView.qml
index 75de47e522..4eb8e27991 100644
--- a/modules/gui/qt/widgets/qml/KeyNavigableTableView.qml
+++ b/modules/gui/qt/widgets/qml/KeyNavigableTableView.qml
@@ -170,12 +170,20 @@ NavigableFocusScope {
property var rowModel: model
property bool selected: selectionModel.isSelected(root.model.index(index, 0))
+ property alias showSeparator: separator.visible
readonly property bool highlighted: selected || hoverArea.containsMouse || activeFocus
width: view.width
height: root.rowHeight
color: highlighted ? VLCStyle.colors.bgHover : "transparent"
+ onHighlightedChanged: {
+ showSeparator = !highlighted
+ var nextItem = view.itemAtIndex(index + 1)
+ if ( nextItem && lineView.ListView.nextSection === lineView.ListView.section)
+ nextItem.showSeparator = !highlighted && !nextItem.highlighted
+ }
+
Connections {
target: selectionModel
onSelectionChanged: lineView.selected = selectionModel.isSelected(root.model.index(index, 0))
@@ -202,7 +210,20 @@ NavigableFocusScope {
actionForSelection(selectionModel.selectedIndexes)
}
+ Rectangle {
+ id: separator
+
+ anchors.top: parent.top
+ anchors.right: content.right
+ width: content.width + (lineView.ListView.previousSection !== lineView.ListView.section
+ ? VLCStyle.table_section_width : 0)
+ height: VLCStyle.heightBar_xxxsmall
+ color: VLCStyle.colors.separator
+ }
+
Row {
+ id: content
+
anchors {
topMargin: VLCStyle.margin_xxsmall
bottomMargin: VLCStyle.margin_xxsmall
--
2.25.1
More information about the vlc-devel
mailing list