[vlc-commits] qml: show separators between items in KeyNavigableTableView

Prince Gupta git at videolan.org
Wed Jun 24 17:41:52 CEST 2020


vlc | branch: master | Prince Gupta <guptaprince8832 at gmail.com> | Wed Jun  3 17:02:59 2020 +0530| [fc47af42e89b338d0ee0edddca89e2a49e1efab7] | committer: Pierre Lamot

qml: show separators between items in KeyNavigableTableView

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fc47af42e89b338d0ee0edddca89e2a49e1efab7
---

 modules/gui/qt/widgets/qml/KeyNavigableListView.qml |  4 ++++
 .../gui/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



More information about the vlc-commits mailing list