[vlc-commits] [Git][videolan/vlc][master] qml: use delayed binding instead of timer to update row width in `TableViewExt`
Steve Lhomme (@robUx4)
gitlab at videolan.org
Sat Mar 14 10:55:06 UTC 2026
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
3831f94b by Fatih Uzunoglu at 2026-03-14T10:39:50+00:00
qml: use delayed binding instead of timer to update row width in `TableViewExt`
This fixes row width getting updated too infrequently, which can be observed
easily. Normally layouting should not be delayed at all, but in order to
respect what the comment says, we prefer to update the width asynchronously,
at least for now.
This amends 929c1b26.
- - - - -
12 changed files:
- modules/gui/qt/medialibrary/qml/MediaView.qml
- modules/gui/qt/medialibrary/qml/MusicAlbums.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/MusicTrackListDisplay.qml
- modules/gui/qt/medialibrary/qml/PlaylistMedia.qml
- modules/gui/qt/medialibrary/qml/PlaylistMediaList.qml
- modules/gui/qt/medialibrary/qml/VideoListDisplay.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/medialibrary/qml/MediaView.qml
=====================================
@@ -280,7 +280,7 @@ MainViewLoader {
selectionModel: root.selectionModel
- sortModel: availableRowWidth >= VLCStyle.colWidth(4) ? _sortModelLarge : _sortModelSmall
+ sortModel: _availableRowWidth >= VLCStyle.colWidth(4) ? _sortModelLarge : _sortModelSmall
header: headerComponent
=====================================
modules/gui/qt/medialibrary/qml/MusicAlbums.qml
=====================================
@@ -255,8 +255,8 @@ MainViewLoader {
rowContextMenu: contextMenu
- sortModel: (availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
- : _modelMedium
+ sortModel: (_availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
+ : _modelMedium
displayMarginBeginning: root.displayMarginBeginning
displayMarginEnd: root.displayMarginEnd
=====================================
modules/gui/qt/medialibrary/qml/MusicAllArtists.qml
=====================================
@@ -231,8 +231,8 @@ MainViewLoader {
requestArtistAlbumView(Qt.TabFocusReason)
}
- sortModel: (availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
- : _modelMedium
+ sortModel: (_availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
+ : _modelMedium
onItemDoubleClicked: function(index, model) {
root.requestArtistAlbumView(Qt.MouseFocusReason, model.id)
=====================================
modules/gui/qt/medialibrary/qml/MusicArtist.qml
=====================================
@@ -946,8 +946,8 @@ FocusScope {
}
}]
- sortModel: (availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
- : _modelMedium
+ sortModel: (_availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
+ : _modelMedium
dragItem: tableDragItem
=====================================
modules/gui/qt/medialibrary/qml/MusicGenres.qml
=====================================
@@ -264,8 +264,8 @@ MainViewLoader {
model: genreModel
- sortModel: (availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
- : _modelMedium
+ sortModel: (_availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
+ : _modelMedium
selectionModel: root.selectionModel
focus: true
=====================================
modules/gui/qt/medialibrary/qml/MusicTrackListDisplay.qml
=====================================
@@ -163,9 +163,9 @@ Widgets.TableViewExt {
// Settings
sortModel: {
- if (availableRowWidth < VLCStyle.colWidth(4))
+ if (_availableRowWidth < VLCStyle.colWidth(4))
return _modelSmall
- else if (availableRowWidth < VLCStyle.colWidth(9))
+ else if (_availableRowWidth < VLCStyle.colWidth(9))
return _modelMedium
else
return _modelLarge
=====================================
modules/gui/qt/medialibrary/qml/PlaylistMedia.qml
=====================================
@@ -98,8 +98,8 @@ Widgets.TableViewExt {
rowHeight: VLCStyle.tableCoverRow_height
- sortModel: (availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
- : _modelMedium
+ sortModel: (_availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
+ : _modelMedium
listView.acceptDropFunc: function(index, drop) {
=====================================
modules/gui/qt/medialibrary/qml/PlaylistMediaList.qml
=====================================
@@ -443,8 +443,8 @@ MainViewLoader {
model: root.model
- sortModel: (availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
- : _modelMedium
+ sortModel: (_availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
+ : _modelMedium
selectionModel: root.selectionModel
=====================================
modules/gui/qt/medialibrary/qml/VideoListDisplay.qml
=====================================
@@ -93,8 +93,8 @@ Widgets.TableViewExt {
// Settings
- sortModel: (availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
- : _modelMedium
+ sortModel: (_availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
+ : _modelMedium
section.property: "title_first_symbol"
=====================================
modules/gui/qt/network/qml/BrowseDeviceView.qml
=====================================
@@ -305,8 +305,8 @@ FocusScope {
model: root.model
- sortModel: (availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
- : _modelMedium
+ sortModel: (_availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
+ : _modelMedium
header: root.header
=====================================
modules/gui/qt/network/qml/BrowseTreeDisplay.qml
=====================================
@@ -282,8 +282,8 @@ MainViewLoader {
model: root.model
- sortModel: (availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
- : _modelMedium
+ sortModel: (_availableRowWidth < VLCStyle.colWidth(4)) ? _modelSmall
+ : _modelMedium
selectionModel: root.selectionModel
focus: true
=====================================
modules/gui/qt/widgets/qml/TableViewExt.qml
=====================================
@@ -105,7 +105,7 @@ FocusScope {
return count
}
- readonly property int _availableSpaceForWeightedColumns: (availableRowWidth - ( _totalSpacerSize + _fixedColumnSize))
+ readonly property int _availableSpaceForWeightedColumns: (_availableRowWidth - ( _totalSpacerSize + _fixedColumnSize))
readonly property int _weightedColumnsSize: _availableSpaceForWeightedColumns / _totalColumnWeights
readonly property int _totalSpacerSize: VLCStyle.column_spacing * sortModel.length
@@ -126,11 +126,16 @@ FocusScope {
property real rowHeight: VLCStyle.tableRow_height
- property real availableRowWidth: 0
+ property real _availableRowWidth: 0
- property Widgets.DragItem dragItem: null
+ // 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
+ }
- // Private
+ property Widgets.DragItem dragItem: null
property bool _ready: false
@@ -208,12 +213,8 @@ FocusScope {
Component.onCompleted: {
_ready = true
-
- availableRowWidthUpdater.enqueueUpdate()
}
- on_CurrentAvailableRowWidthChanged: if (_ready) availableRowWidthUpdater.enqueueUpdate()
-
// Functions
function setCurrentItem(index) {
@@ -245,35 +246,6 @@ FocusScope {
// Childs
- Timer {
- id: availableRowWidthUpdater
-
- interval: 100
- triggeredOnStart: false
- repeat: false
- onTriggered: {
- _update()
- }
-
- function _update() {
- root.availableRowWidth = root._currentAvailableRowWidth
- root._availabeRowWidthLastUpdateTime = Date.now()
- }
-
- function enqueueUpdate() {
- // updating availableRowWidth is expensive because of property bindings in sortModel
- // and availableRowWidth is dependent on root.width which can update in a burst
- // so try to maintain a minimum time gap between subsequent availableRowWidth updates
- const sinceLastUpdate = Date.now() - root._availabeRowWidthLastUpdateTime
- if ((root.availableRowWidth === 0) || (sinceLastUpdate > 128 && !availableRowWidthUpdater.running)) {
- _update()
- } else if (!availableRowWidthUpdater.running) {
- availableRowWidthUpdater.interval = Math.max(128 - sinceLastUpdate, 32)
- availableRowWidthUpdater.start()
- }
- }
- }
-
ListViewExt {
id: view
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/3831f94ba20af2d3c8ba5b4545ab33d10f505be1
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/3831f94ba20af2d3c8ba5b4545ab33d10f505be1
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list