[vlc-commits] [Git][videolan/vlc][master] 3 commits: qt: add `MainCtx::setItemFlag()`

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Sat Apr 4 17:10:42 UTC 2026



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
5257c6be by Fatih Uzunoglu at 2026-04-04T18:48:24+02:00
qt: add `MainCtx::setItemFlag()`

- - - - -
88050643 by Fatih Uzunoglu at 2026-04-04T18:48:24+02:00
qml: fix column spacing calculation in `TableViewExt`

Spacing should be based on (element size - 1).

- - - - -
37c6fecd by Fatih Uzunoglu at 2026-04-04T18:48:24+02:00
qml: use inheritance instead of aggregation in `TableViewExt`

... by deriving from `ListViewExt`.

Note that this is supposed to be a drop in change unless you
are using one of these:

- `{left,right,top,bottom}Margin` is now managed by `Flickable`,
  this is currently not used anywhere as far as I see but I
  tried to make sure it works.
- `listView` or `view`. I could keep these as alias to `root`,
  but decided to just get rid of them. You should now refer to
  the root directly.
- `header` and `headerItem`. These are now managed by `ListView`,
  you should use `preferredHeader` and `preferredHeaderItem`, but
  there is no restriction whatsoever on overriding the `header`
  component.

I already made the adjustments where `TableViewExt` is used,
these should be considered if you have pending work that uses
`TableViewExt`.

- - - - -


15 changed files:

- modules/gui/qt/maininterface/mainctx.hpp
- modules/gui/qt/medialibrary/qml/MediaView.qml
- modules/gui/qt/medialibrary/qml/MusicAlbums.qml
- modules/gui/qt/medialibrary/qml/MusicAlbumsGridExpandDelegate.qml
- modules/gui/qt/medialibrary/qml/MusicAllArtists.qml
- modules/gui/qt/medialibrary/qml/MusicArtist.qml
- modules/gui/qt/medialibrary/qml/MusicGenres.qml
- modules/gui/qt/medialibrary/qml/MusicTracksDisplay.qml
- modules/gui/qt/medialibrary/qml/PlaylistMedia.qml
- modules/gui/qt/medialibrary/qml/PlaylistMediaDisplay.qml
- modules/gui/qt/medialibrary/qml/PlaylistMediaList.qml
- modules/gui/qt/medialibrary/qml/VideoAll.qml
- modules/gui/qt/network/qml/BrowseDeviceView.qml
- modules/gui/qt/network/qml/BrowseTreeDisplay.qml
- modules/gui/qt/widgets/qml/TableViewExt.qml


Changes:

=====================================
modules/gui/qt/maininterface/mainctx.hpp
=====================================
@@ -290,6 +290,12 @@ public:
         item->setFiltersChildMouseEvents(enable);
     }
 
+    Q_INVOKABLE static void setItemFlag(QQuickItem *item, QQuickItem::Flag flag, bool enabled = true)
+    {
+        assert(item);
+        item->setFlag(flag, enabled);
+    }
+
     Q_INVOKABLE qreal effectiveDevicePixelRatio(const QQuickWindow* window) {
         if (window)
             return window->effectiveDevicePixelRatio();


=====================================
modules/gui/qt/medialibrary/qml/MediaView.qml
=====================================
@@ -282,7 +282,7 @@ MainViewLoader {
 
             sortModel: _availableRowWidth >= VLCStyle.colWidth(4) ? _sortModelLarge : _sortModelSmall
 
-            header: headerComponent
+            preferredHeader: headerComponent
 
             headerPositioning: root.listHeaderPositioning
 


=====================================
modules/gui/qt/medialibrary/qml/MusicAlbums.qml
=====================================
@@ -249,7 +249,7 @@ MainViewLoader {
             onActionForSelection: (selection) => _actionAtIndex(selection[0])
             Navigation.parentItem: root
             section.property: "title_first_symbol"
-            header: root.header
+            preferredHeader: root.header
             dragItem: albumDragItem
             rowHeight: VLCStyle.tableCoverRow_height
 


=====================================
modules/gui/qt/medialibrary/qml/MusicAlbumsGridExpandDelegate.qml
=====================================
@@ -420,7 +420,7 @@ FocusScope {
 
             fadingEdge.backgroundColor: background.color
 
-            header: Loader {
+            preferredHeader: Loader {
                 sourceComponent: VLCStyle.isScreenSmall
                                  ? header_small
                                  : header_common


=====================================
modules/gui/qt/medialibrary/qml/MusicAllArtists.qml
=====================================
@@ -222,7 +222,7 @@ MainViewLoader {
             fadingEdge.enableBeginningFade: root.enableBeginningFade
             fadingEdge.enableEndFade: root.enableEndFade
 
-            header: root.header
+            preferredHeader: root.header
             Navigation.parentItem: root
 
             onActionForSelection: (selection) => {


=====================================
modules/gui/qt/medialibrary/qml/MusicArtist.qml
=====================================
@@ -403,7 +403,7 @@ FocusScope {
         if (initialIndex >= albumModel.count)
             initialIndex = 0
         albumSelectionModel.select(initialIndex, ItemSelectionModel.ClearAndSelect)
-        const albumsListView = MainCtx.gridView ? _currentView : headerItem.albumsListView
+        const albumsListView = MainCtx.gridView ? _currentView : _currentView?.preferredHeaderItem?.albumsListView
         if (albumsListView) {
             albumsListView.currentIndex = initialIndex
             albumsListView.positionViewAtIndex(initialIndex, ItemView.Contain)
@@ -482,7 +482,7 @@ FocusScope {
     Widgets.MLDragItem {
         id: albumDragItem
 
-        view: (root._currentView instanceof Widgets.TableViewExt) ? (root._currentView?.headerItem?.albumsListView ?? null)
+        view: (root._currentView instanceof Widgets.TableViewExt) ? (root._currentView?.preferredHeaderItem?.albumsListView ?? null)
                                                                   : root._currentView
         indexes: indexesFlat ? albumSelectionModel.selectedIndexesFlat
                              : albumSelectionModel.selectedIndexes
@@ -626,7 +626,7 @@ FocusScope {
                 model.addAndPlay(selection)
             }
 
-            header: root.header
+            preferredHeader: root.header
             rowHeight: VLCStyle.tableCoverRow_height
 
             property bool albumSections: true
@@ -646,7 +646,7 @@ FocusScope {
                 }
             }
 
-            Binding on listView.cacheBuffer {
+            Binding on cacheBuffer {
                 // FIXME
                 // https://doc.qt.io/qt-6/qml-qtquick-listview.html#variable-delegate-size-and-section-labels
                 when: tableView_id.albumSections
@@ -719,7 +719,7 @@ FocusScope {
                     }
 
                     Connections {
-                        target: tableView_id.headerItem
+                        target: tableView_id.preferredHeaderItem
 
                         function onChangeToPreviousSectionRequested() {
                             if (tableView_id.currentSection === musicAlbumSectionDelegate.section)
@@ -966,7 +966,7 @@ FocusScope {
 
             onDragItemChanged: console.assert(tableView_id.dragItem === tableDragItem)
 
-            Behavior on listView.contentY {
+            Behavior on contentY {
                 id: contentYBehavior
 
                 enabled: false


=====================================
modules/gui/qt/medialibrary/qml/MusicGenres.qml
=====================================
@@ -280,7 +280,7 @@ MainViewLoader {
             fadingEdge.enableBeginningFade: root.enableBeginningFade
             fadingEdge.enableEndFade: root.enableEndFade
 
-            header: root.header
+            preferredHeader: root.header
 
             rowContextMenu: contextMenu
 


=====================================
modules/gui/qt/medialibrary/qml/MusicTracksDisplay.qml
=====================================
@@ -68,7 +68,7 @@ FocusScope {
         visible: model.count > 0
         focus: model.count > 0
 
-        header: Widgets.ViewHeader {
+        preferredHeader: Widgets.ViewHeader {
             view: tracklistdisplay_id
 
             visible: view.count > 0


=====================================
modules/gui/qt/medialibrary/qml/PlaylistMedia.qml
=====================================
@@ -102,7 +102,7 @@ Widgets.TableViewExt {
                                                            : _modelMedium
 
 
-    listView.acceptDropFunc: function(index, drop) {
+    acceptDropFunc: function(index, drop) {
         // FIXME: The DnD API seems quite poorly designed in this file.
         //        Why does it ask for both index and "before"
         //        When index + 1 is essentially the same as
@@ -124,7 +124,7 @@ Widgets.TableViewExt {
     //---------------------------------------------------------------------------------------------
     // Drop interface
 
-    listView.isDropAcceptableFunc: function(drop, index) {
+    isDropAcceptableFunc: function(drop, index) {
         if (drop.source === dragItem) {
             return Helpers.itemsMovable(selectionModel.sortedSelectedIndexesFlat, index)
         } else if (Helpers.isValidInstanceOf(drop.source, Widgets.DragItem)) {
@@ -137,7 +137,7 @@ Widgets.TableViewExt {
     }
 
     function applyDrop(drop, index, delegate, before) {
-        if (listView.isDropAcceptableFunc(drop, index + (before ? 0 : 1)) === false) {
+        if (isDropAcceptableFunc(drop, index + (before ? 0 : 1)) === false) {
             drop.accepted = false
             return Promise.resolve()
         }


=====================================
modules/gui/qt/medialibrary/qml/PlaylistMediaDisplay.qml
=====================================
@@ -219,7 +219,7 @@ FocusScope {
 
         isMusic: root.isMusic
 
-        header: Widgets.ViewHeader {
+        preferredHeader: Widgets.ViewHeader {
             view: root.playlistView
 
             visible: view.count > 0


=====================================
modules/gui/qt/medialibrary/qml/PlaylistMediaList.qml
=====================================
@@ -458,7 +458,7 @@ MainViewLoader {
 
             dragItem: dragItemPlaylist
 
-            header: root.header
+            preferredHeader: root.header
 
             rowContextMenu: contextMenu
 
@@ -468,16 +468,16 @@ MainViewLoader {
             fadingEdge.enableBeginningFade: root.enableBeginningFade
             fadingEdge.enableEndFade: root.enableEndFade
 
-            listView.isDropAcceptableFunc: function(drag, index) {
+            isDropAcceptableFunc: function(drag, index) {
                 root._adjustDragAccepted(drag)
                 return drag.accepted
             }
 
-            listView.acceptDropFunc: function(index, drop) {
+            acceptDropFunc: function(index, drop) {
                 return root._dropAction(drop, listView.itemContainsDrag?.index)
             }
 
-            listView.dropIndicator: null
+            dropIndicator: null
 
             Navigation.parentItem: root
 


=====================================
modules/gui/qt/medialibrary/qml/VideoAll.qml
=====================================
@@ -201,7 +201,7 @@ MainViewLoader {
 
             dragItem: root.dragItem
 
-            header: root.header
+            preferredHeader: root.header
 
             headerPositioning: root.headerPositioning
 


=====================================
modules/gui/qt/network/qml/BrowseDeviceView.qml
=====================================
@@ -308,7 +308,7 @@ FocusScope {
             sortModel: (_availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
                                                                    : _modelMedium
 
-            header: root.header
+            preferredHeader: root.header
 
             selectionModel: modelSelect
 


=====================================
modules/gui/qt/network/qml/BrowseTreeDisplay.qml
=====================================
@@ -299,7 +299,7 @@ MainViewLoader {
             fadingEdge.enableBeginningFade: root.enableBeginningFade
             fadingEdge.enableEndFade: root.enableEndFade
 
-            header: BrowseTreeHeader {
+            preferredHeader: BrowseTreeHeader {
                 providerModel: root.model
 
                 leftPadding: root.headerLeftPadding


=====================================
modules/gui/qt/widgets/qml/TableViewExt.qml
=====================================
@@ -25,12 +25,9 @@ import VLC.Util
 import VLC.Widgets as Widgets
 import VLC.Style
 
-// FIXME: Maybe we could inherit from KeyNavigableListView directly.
-FocusScope {
+ListViewExt {
     id: root
 
-    // Properties
-
     property var sortModel: []
 
     property Component tableHeaderDelegate:  TableHeaderDelegate {
@@ -74,17 +71,22 @@ FocusScope {
     // NOTE: We want edge to edge backgrounds in our delegate and header, so we implement our own
     //       margins implementation like in ExpandGridView. The default values should be the same
     //       than ExpandGridView to respect the grid parti pris.
-    property int leftMargin: VLCStyle.layout_left_margin + leftPadding
-    property int rightMargin: VLCStyle.layout_right_margin + rightPadding
 
     property int leftPadding: 0
     property int rightPadding: 0
 
-    readonly property int extraMargin: VLCStyle.dynamicAppMargins(width)
+    readonly property real _extraPadding: VLCStyle.dynamicAppMargins(width)
+    property real contentLeftPadding: _extraPadding + leftPadding + VLCStyle.layout_left_margin
+    property real contentRightPadding: _extraPadding + rightPadding + VLCStyle.layout_right_margin
+
+    // These are "extra" margins because `ListView`'s own `margins` is also considered for the header.
+    property real defaultHeaderExtraLeftMargin: contentLeftPadding
+    property real defaultHeaderExtraRightMargin: contentRightPadding
 
+    // FIXME: Get rid of `contentLeftMargin` and `contentRightMargin`:
     // NOTE: The list margins for the item(s) horizontal positioning.
-    readonly property int contentLeftMargin: extraMargin + leftMargin
-    readonly property int contentRightMargin: extraMargin + rightMargin
+    readonly property int contentLeftMargin: contentLeftPadding
+    readonly property int contentRightMargin: contentRightPadding
 
     property real baseColumnWidth: VLCStyle.column_width
 
@@ -108,10 +110,11 @@ FocusScope {
     readonly property int _availableSpaceForWeightedColumns: (_availableRowWidth - ( _totalSpacerSize + _fixedColumnSize))
     readonly property int _weightedColumnsSize: _availableSpaceForWeightedColumns / _totalColumnWeights
 
-    readonly property int _totalSpacerSize: VLCStyle.column_spacing * sortModel.length
+    readonly property int _totalSpacerSize: VLCStyle.column_spacing * Math.max(0, (sortModel.length - 1))
+
+    property Component preferredHeader
+    readonly property Item preferredHeaderItem: headerItem?.loadedHeader ?? null
 
-    property Component header: null
-    property Item headerItem: view.headerItem?.loadedHeader ?? null
     // NOTE: Clipping is not used, so if header is not inline, it should have background to not expose the content.
     // TODO: Investigate using clipping here, which makes more sense in general for views. Not using clipping
     //       makes this view not suitable for using it in auxiliary places (non-main, which is not naturally
@@ -123,347 +126,263 @@ FocusScope {
     property color headerColor: (interactive && (headerPositioning !== ListView.InlineHeader)) ? colorContext.bg.primary : "transparent"
     property int headerTopPadding: 0
 
-
     property real rowHeight: VLCStyle.tableRow_height
 
     property real _availableRowWidth: 0
 
     // FIXME: Layouting should not be done asynchronously, investigate if getting rid of this is feasible.
     Binding on _availableRowWidth {
-        when: root._ready
         delayed: true
         value: root._currentAvailableRowWidth
     }
 
     property Widgets.DragItem dragItem: null
 
-    property bool _ready: false
-
-    property real _availabeRowWidthLastUpdateTime: Date.now()
-
-    readonly property real _currentAvailableRowWidth: width - leftMargin - rightMargin
+    readonly property real _currentAvailableRowWidth: width - leftMargin - contentLeftPadding - rightMargin - contentRightPadding
                                                       // contextButton is implemented as fixed column
                                                       - VLCStyle.contextButton_width - (VLCStyle.contextButton_margin * 2)
 
     property bool sortingFromHeader: true
     property bool useCurrentSectionLabel: true
 
-    // Aliases
-
-    property alias topMargin: view.topMargin
-    property alias bottomMargin: view.bottomMargin
-
-    property alias spacing: view.spacing
-
-    property alias model: view.model
-    property alias selectionModel: view.selectionModel
-
-    property alias delegate: view.delegate
-
-    property alias contentItem: view.contentItem
-
-    property alias contentY     : view.contentY
-    property alias contentHeight: view.contentHeight
-
-    property alias originX: view.originX
-    property alias originY: view.originY
-
-    property alias interactive: view.interactive
-
-    property alias section: view.section
-
-    property alias currentIndex: view.currentIndex
-    property alias currentItem: view.currentItem
-
-    property alias headerPositioning: view.headerPositioning
-
-    property alias tableHeaderItem: view.headerItem
-
-    property alias footerItem: view.footerItem
-    property alias footer: view.footer
-
-    property alias fadingEdge: view.fadingEdge
-
-    property alias add:       view.add
-    property alias displaced: view.displaced
-
-    property alias listView: view
-
-    property alias displayMarginBeginning: view.displayMarginBeginning
-    property alias displayMarginEnd: view.displayMarginEnd
-
-    property alias count: view.count
-
-    property alias colorContext: view.colorContext
-
-    property alias reuseItems: view.reuseItems
-
-    readonly property var itemAtIndex: view.itemAtIndex
-
-    property alias currentSection: view.currentSection
-
-    // Signals
-
-    //forwarded from subview
     signal actionForSelection( var selection )
     signal rightClick(Item menuParent, var menuModel, point globalMousePos)
     signal itemDoubleClicked(var index, var model)
 
-    // Events
-
     Component.onCompleted: {
-        _ready = true
+        // This is a remnant from the time `TableViewExt` derived from `FocusScope`:
+        MainCtx.setItemFlag(this, Item.ItemIsFocusScope)
     }
 
-    // Functions
+    function getItemY(index) {
+        let size = index * rowHeight + topMargin
 
-    function setCurrentItem(index) {
-        view.setCurrentItem(index)
-    }
+        if (headerItem)
+            size += headerItem.height
 
-    function setCurrentItemFocus(reason) {
-        view.setCurrentItemFocus(reason);
+        return size
     }
 
-    function positionViewAtIndex(index, mode) {
-        view.positionViewAtIndex(index, mode)
-    }
+    headerPositioning: ListView.OverlayHeader
 
-    function positionViewAtBeginning() {
-        view.positionViewAtBeginning()
-    }
+    flickableDirection: Flickable.AutoFlickDirection
 
-    function getItemY(index) {
-        let size = index * rowHeight + topMargin
+    Navigation.parentItem: root
 
-        if (tableHeaderItem)
-            size += tableHeaderItem.height
+    onActionAtIndex: (index) => { root.actionForSelection( selectionModel.selectedIndexes ) }
 
-        return size
+    onShowContextMenu: (globalPos) => {
+        if (selectionModel.hasSelection)
+            root.rightClick(null, null, globalPos);
     }
 
-    // Private
-
-    // Childs
+    header: Rectangle {
+        property alias loadedHeader: headerLoader.item
 
-    ListViewExt {
-        id: view
+        width: root.width
+        height: col.height
+        z: 3
+        color: root.headerColor
 
-        anchors.fill: parent
-        focus: true
+        // with inline header positioning and for `root.header` which changes it's height after loading,
+        // in such cases after `root.header` completes, the ListView will try to maintain the relative contentY,
+        // and hide the completed `root.header`, try to show the `root.header` in such cases by manually
+        // positiing view at beginning
+        onHeightChanged: if (root.contentY < 0) root.positionViewAtBeginning()
 
-        headerPositioning: ListView.OverlayHeader
+        Navigation.parentItem: root
+        Navigation.upItem: loadedHeader
+        Navigation.downItem: loadedHeader
+        Navigation.leftItem: loadedHeader
+        Navigation.rightItem: loadedHeader
+        Navigation.navigable: false
 
-        flickableDirection: Flickable.AutoFlickDirection
+        readonly property var setCurrentItemFocus: loadedHeader?.setCurrentItemFocus
 
-        Navigation.parentItem: root
+        Widgets.ListLabel {
+            // NOTE: We want the section label to be slightly shifted to the left.
+            x: row.x - VLCStyle.margin_small
+            y: row.y + root.headerTopPadding
 
-        onActionAtIndex: (index) => { root.actionForSelection( selectionModel.selectedIndexes ) }
+            height: VLCStyle.tableHeaderText_height
+            verticalAlignment: Text.AlignVCenter
 
-        onShowContextMenu: (globalPos) => {
-            if (selectionModel.hasSelection)
-                root.rightClick(null, null, globalPos);
+            text: root.currentSection
+            color: root.colorContext.accent
+            visible: root.useCurrentSectionLabel
+                     && root.headerPositioning === ListView.OverlayHeader
+                     && text !== ""
+                     && root.contentY > (row.height - col.height - row.topPadding)
+                     && row.visible
         }
 
-        header: Rectangle {
-            property alias loadedHeader: headerLoader.item
-
-            width: view.width
-            height: col.height
-            z: 3
-            color: root.headerColor
-
-            // with inline header positioning and for `root.header` which changes it's height after loading,
-            // in such cases after `root.header` completes, the ListView will try to maintain the relative contentY,
-            // and hide the completed `root.header`, try to show the `root.header` in such cases by manually
-            // positiing view at beginning
-            onHeightChanged: if (root.contentY < 0) root.positionViewAtBeginning()
-
-            Widgets.ListLabel {
-                // NOTE: We want the section label to be slightly shifted to the left.
-                x: row.x - VLCStyle.margin_small
-                y: row.y + root.headerTopPadding
-
-                height: VLCStyle.tableHeaderText_height
-                verticalAlignment: Text.AlignVCenter
-
-                text: view.currentSection
-                color: view.colorContext.accent
-                visible: root.useCurrentSectionLabel
-                         && view.headerPositioning === ListView.OverlayHeader
-                         && text !== ""
-                         && view.contentY > (row.height - col.height - row.topPadding)
-                         && row.visible
+        Column {
+            id: col
+
+            anchors.left: parent.left
+            anchors.right: parent.right
+
+            Loader {
+                id: headerLoader
+
+                sourceComponent: root.preferredHeader
             }
 
-            Column {
-                id: col
+            Row {
+                id: row
 
                 anchors.left: parent.left
                 anchors.right: parent.right
 
-                Loader {
-                    id: headerLoader
+                anchors.leftMargin: root.defaultHeaderExtraLeftMargin
+                anchors.rightMargin: root.defaultHeaderExtraRightMargin
 
-                    sourceComponent: root.header
-                }
-
-                Row {
-                    id: row
-
-                    anchors.left: parent.left
-                    anchors.right: parent.right
+                topPadding: root.headerTopPadding
+                bottomPadding: VLCStyle.margin_xsmall
 
-                    anchors.leftMargin: root.contentLeftMargin
-                    anchors.rightMargin: root.contentRightMargin
+                spacing: VLCStyle.column_spacing
 
-                    topPadding: root.headerTopPadding
-                    bottomPadding: VLCStyle.margin_xsmall
+                // If there is a specific header, obey to its visibility otherwise hide the header if model is empty:
+                visible: headerLoader.item ? headerLoader.item.visible : (root.count > 0)
 
-                    spacing: VLCStyle.column_spacing
+                Repeater {
+                    model: sortModel
+                    Item {
+                        id: headerCell
 
-                    // If there is a specific header, obey to its visibility otherwise hide the header if model is empty:
-                    visible: headerLoader.item ? headerLoader.item.visible : (view.count > 0)
+                        required property var modelData
+                        property TableHeaderDelegate _item: null
 
-                    Repeater {
-                        model: sortModel
-                        Item {
-                            id: headerCell
+                        TableHeaderDelegate.CellModel {
+                            id: cellModel
+                            colorContext:  root.colorContext
+                            colModel: modelData.model
+                        }
 
-                            required property var modelData
-                            property TableHeaderDelegate _item: null
+                        height: VLCStyle.tableHeaderText_height
+                        width: {
+                            if (!!modelData.size)
+                                return modelData.size * root.baseColumnWidth
+                            else if (!!modelData.weight)
+                                return modelData.weight * root._weightedColumnsSize
+                            else
+                                return 0
+                        }
+                        Accessible.role: Accessible.ColumnHeader
+                        Accessible.name: modelData.model.text
+
+                        //Using a Loader is unable to pass the initial/required properties
+                        Component.onCompleted: {
+                            const comp = modelData.model.headerDelegate || root.tableHeaderDelegate
+                            headerCell._item = comp.createObject(headerCell, {
+                                width:  Qt.binding(() => headerCell.width),
+                                height:  Qt.binding(() => headerCell.height),
+                                cellModel: cellModel,
+                            })
+                        }
 
-                            TableHeaderDelegate.CellModel {
-                                id: cellModel
-                                colorContext:  view.colorContext
-                                colModel: modelData.model
+                        Text {
+                            text: (root.model.sortOrder === Qt.AscendingOrder) ? "▼" : "▲"
+                            visible: root.model.sortCriteria === modelData.model.criteria
+                            font.pixelSize: VLCStyle.fontSize_normal
+                            color: root.colorContext.accent
+
+                            anchors {
+                                top: parent.top
+                                bottom: parent.bottom
+                                right: parent.right
+                                leftMargin: VLCStyle.margin_xsmall
+                                rightMargin: VLCStyle.margin_xsmall
                             }
+                        }
 
-                            height: VLCStyle.tableHeaderText_height
-                            width: {
-                                if (!!modelData.size)
-                                    return modelData.size * root.baseColumnWidth
-                                else if (!!modelData.weight)
-                                    return modelData.weight * root._weightedColumnsSize
+                        TapHandler {
+                            onTapped: (eventPoint, button) => {
+                                if (!root.sortingFromHeader)
+                                    return
+                                if (!(modelData.model.isSortable ?? true))
+                                    return
+                                else if (root.model.sortCriteria !== modelData.model.criteria)
+                                    root.model.sortCriteria = modelData.model.criteria
                                 else
-                                    return 0
-                            }
-                            Accessible.role: Accessible.ColumnHeader
-                            Accessible.name: modelData.model.text
-
-                            //Using a Loader is unable to pass the initial/required properties
-                            Component.onCompleted: {
-                                const comp = modelData.model.headerDelegate || root.tableHeaderDelegate
-                                headerCell._item = comp.createObject(headerCell, {
-                                    width:  Qt.binding(() => headerCell.width),
-                                    height:  Qt.binding(() => headerCell.height),
-                                    cellModel: cellModel,
-                                })
-                            }
-
-                            Text {
-                                text: (root.model.sortOrder === Qt.AscendingOrder) ? "▼" : "▲"
-                                visible: root.model.sortCriteria === modelData.model.criteria
-                                font.pixelSize: VLCStyle.fontSize_normal
-                                color: root.colorContext.accent
-
-                                anchors {
-                                    top: parent.top
-                                    bottom: parent.bottom
-                                    right: parent.right
-                                    leftMargin: VLCStyle.margin_xsmall
-                                    rightMargin: VLCStyle.margin_xsmall
-                                }
-                            }
-
-                            TapHandler {
-                                onTapped: (eventPoint, button) => {
-                                    if (!root.sortingFromHeader)
-                                        return
-                                    if (!(modelData.model.isSortable ?? true))
-                                        return
-                                    else if (root.model.sortCriteria !== modelData.model.criteria)
-                                        root.model.sortCriteria = modelData.model.criteria
-                                    else
-                                        root.model.sortOrder = (root.model.sortOrder === Qt.AscendingOrder) ? Qt.DescendingOrder : Qt.AscendingOrder
-                                }
+                                    root.model.sortOrder = (root.model.sortOrder === Qt.AscendingOrder) ? Qt.DescendingOrder : Qt.AscendingOrder
                             }
                         }
                     }
+                }
 
-                    Item {
-                        // placeholder for context button
+                Item {
+                    // placeholder for context button
 
-                        width: VLCStyle.icon_normal
+                    width: VLCStyle.icon_normal
 
-                        height: 1
-                    }
+                    height: 1
                 }
             }
         }
+    }
 
-        section.delegate: Widgets.ListLabel {
-            // NOTE: We want the section label to be slightly shifted to the left.
-            leftPadding: root.contentLeftMargin - VLCStyle.margin_small
+    section.delegate: Widgets.ListLabel {
+        // NOTE: We want the section label to be slightly shifted to the left.
+        leftPadding: root.contentLeftPadding - VLCStyle.margin_small
 
-            topPadding: VLCStyle.margin_xsmall
+        topPadding: VLCStyle.margin_xsmall
 
-            text: section
-            color: root.colorContext.accent
-        }
+        text: section
+        color: root.colorContext.accent
+    }
 
-        delegate: Widgets.TableViewDelegateExt {
-            id: tableDelegate
+    delegate: Widgets.TableViewDelegateExt {
+        id: tableDelegate
 
-            required property var model
+        required property var model
 
-            width: view.width
-            height: Math.round(root.rowHeight)
+        width: root.width
+        height: Math.round(root.rowHeight)
 
-            fixedColumnWidth: root.baseColumnWidth
-            weightedColumnWidth: root._weightedColumnsSize
+        fixedColumnWidth: root.baseColumnWidth
+        weightedColumnWidth: root._weightedColumnsSize
 
-            leftPadding: root.contentLeftMargin
-            rightPadding: root.contentRightMargin
+        leftPadding: root.contentLeftPadding
+        rightPadding: root.contentRightPadding
 
-            dragItem: root.dragItem
+        dragItem: root.dragItem
 
-            contextMenu: root.rowContextMenu
+        contextMenu: root.rowContextMenu
 
-            rowModel: model
-            sortModel: root.sortModel
+        rowModel: model
+        sortModel: root.sortModel
 
-            selected: selectionModel.selectedIndexesFlat.includes(index)
+        selected: selectionModel.selectedIndexesFlat.includes(index)
 
-            onRightClick: (menuParent, menuModel, globalMousePos) => {
-                root.rightClick(menuParent, menuModel, globalMousePos)
-            }
-            onItemDoubleClicked: (index, model) => {
-                root.itemDoubleClicked(index, model)
-            }
+        onRightClick: (menuParent, menuModel, globalMousePos) => {
+            root.rightClick(menuParent, menuModel, globalMousePos)
+        }
+        onItemDoubleClicked: (index, model) => {
+            root.itemDoubleClicked(index, model)
+        }
 
-            isDropAcceptable: view.isDropAcceptableFunc
-            acceptDrop: view.acceptDropFunc
+        isDropAcceptable: root.isDropAcceptableFunc
+        acceptDrop: root.acceptDropFunc
 
-            onSelectAndFocus: (modifiers, focusReason) => {
-                selectionModel.updateSelection(modifiers, view.currentIndex, index)
+        onSelectAndFocus: (modifiers, focusReason) => {
+            selectionModel.updateSelection(modifiers, root.currentIndex, index)
 
-                view.currentIndex = index
-                view.positionViewAtIndex(index, ListView.Contain)
+            root.currentIndex = index
+            root.positionViewAtIndex(index, ListView.Contain)
 
-                tableDelegate.forceActiveFocus(focusReason)
-            }
+            tableDelegate.forceActiveFocus(focusReason)
+        }
 
-            onContainsDragChanged: view.updateItemContainsDrag(this, containsDrag)
+        onContainsDragChanged: root.updateItemContainsDrag(this, containsDrag)
 
-            Connections {
-                target: selectionModel
+        Connections {
+            target: selectionModel
 
-                function onSelectionChanged() {
-                    tableDelegate.selected = Qt.binding(function() {
-                      return root.selectionModel.selectedIndexesFlat.includes(index)
-                    })
-                }
+            function onSelectionChanged() {
+                tableDelegate.selected = Qt.binding(function() {
+                  return root.selectionModel.selectedIndexesFlat.includes(index)
+                })
             }
         }
     }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/35320bff96df2ef160874ff65dc3688973b1b9c3...37c6fecd12d04160a41aa06b1213c09418a67eb7

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/35320bff96df2ef160874ff65dc3688973b1b9c3...37c6fecd12d04160a41aa06b1213c09418a67eb7
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list