[vlc-devel] [RFC 0/8] qt: playlist: refactor item selection/move

Romain Vimont rom1v at videolabs.io
Tue Jul 9 18:30:24 CEST 2019


The Qt UI uses a Qml DelegateModel to handle selection:
<https://doc.qt.io/qt-5/qml-qtqml-models-delegatemodel.html>

This Qml overlay adds a lot of complexity (IMO), because it forces to store
selected indexes in a separate list (or "group"), in Qml:
<https://doc.qt.io/qt-5/qml-qtqml-models-delegatemodel.html#groups-prop>

As a consequence, we must write the code to keep the selection list up to date
with playlist changes manually in Qml, or glitches may appear (#22490):
<https://trac.videolan.org/vlc/ticket/22490>

(Moreover, it seems DelegateModel calls the underlying model methods way too
often.)

The (main) purpose of this patchset is to store the selection in (a subclass of)
QAbstractListModel (which is "the model of the view") directly, expose the item
selection as a "role", and get rid of DelegateModel (for the playlist only for
now, other components still use it).

The last patch also propose something to fix #22491:
<https://trac.videolan.org/vlc/ticket/22491>
(It is probably not the best solution though, because when some items are
selected and we try to select one more, if we move by 1 pixel it starts
dragging and resets the selection.)

Romain Vimont (8):
  qt: playlist: refactor "move items"
  qt: introduce SelectableListModel
  qt: playlist: make PlaylistListModel selectable
  qt: playlist: expose count as a property
  qt: playlist: update drag&drop count on drag
  qt: playlist: replace DelegateModel
  qt: playlist: use distinct colors for states [DO NOT MERGE]
  qt: playlist: select on drag

 modules/gui/qt/Makefile.am                    |   3 +
 .../qt/components/playlist/playlist_item.cpp  |  10 +
 .../qt/components/playlist/playlist_item.hpp  |   5 +
 .../qt/components/playlist/playlist_model.cpp | 105 +++++--
 .../qt/components/playlist/playlist_model.hpp |  19 +-
 .../qt/components/selectable_list_model.cpp   | 119 ++++++++
 .../qt/components/selectable_list_model.hpp   |  52 ++++
 modules/gui/qt/qml/playlist/PLItem.qml        |   8 +-
 .../gui/qt/qml/playlist/PlaylistListView.qml  | 289 +++++++++---------
 modules/gui/qt/qml/style/VLCColors.qml        |   2 +-
 modules/gui/qt/qml/utils/DNDLabel.qml         |   4 +-
 11 files changed, 435 insertions(+), 181 deletions(-)
 create mode 100644 modules/gui/qt/components/selectable_list_model.cpp
 create mode 100644 modules/gui/qt/components/selectable_list_model.hpp

-- 
2.20.1



More information about the vlc-devel mailing list