[vlc-devel] [PATCH 0/8] Qt: medialib: un-templatize list models

Romain Vimont rom1v at videolabs.io
Thu Dec 3 12:12:04 CET 2020


Many Qt list models inherit MLSlidingWindowModel, which is generic over its
item type.

In practice, this "internal" genericity didn't bring a lot of value (it just
provided a concrete pointer type), but it had disadvantages:
 - since Qt signals/slots are incompatible with templates, the base list model
   was split into two parts (one non-template with signals/slots, inherited by
   another template class);
 - the whole implementation had to be written in the header file, and
   recompiled for every concrete list model, causing huge (re-)compilation
   times.

To solve both problems and simplify, make all item types inherit a common type
(MLItem) and implement the base list model using this type. When necessary, a
static cast is sufficient to convert to the (known) concrete type.

Branch: https://code.videolan.org/rom1v/vlc/commits/untemplatize

Regards

Romain Vimont (8):
  qt: medialib: rename MLParentId to MLItemId
  qt: medialib: define equality operator on MLItemId
  qt: medialib: define a super-type for list items
  qt: medialib: un-templatize MLSlidingWindowModel
  qt: medialib: move implementation to cpp
  qt: medialib: do not depend on ListCache header
  qt: medialib: merge base list models
  qt: medialib: reorder MLBaseModel members

 modules/gui/qt/Makefile.am                    |   1 +
 modules/gui/qt/maininterface/mainui.cpp       |   2 +-
 modules/gui/qt/medialibrary/medialib.cpp      |  12 +-
 modules/gui/qt/medialibrary/medialib.hpp      |   4 +-
 modules/gui/qt/medialibrary/mlalbum.cpp       |   9 +-
 modules/gui/qt/medialibrary/mlalbum.hpp       |   6 +-
 modules/gui/qt/medialibrary/mlalbummodel.cpp  |  12 +-
 modules/gui/qt/medialibrary/mlalbummodel.hpp  |   6 +-
 modules/gui/qt/medialibrary/mlalbumtrack.cpp  |   9 +-
 modules/gui/qt/medialibrary/mlalbumtrack.hpp  |   6 +-
 .../gui/qt/medialibrary/mlalbumtrackmodel.cpp |  10 +-
 .../gui/qt/medialibrary/mlalbumtrackmodel.hpp |   6 +-
 modules/gui/qt/medialibrary/mlartist.cpp      |   9 +-
 modules/gui/qt/medialibrary/mlartist.hpp      |   6 +-
 modules/gui/qt/medialibrary/mlartistmodel.cpp |  12 +-
 modules/gui/qt/medialibrary/mlartistmodel.hpp |   6 +-
 modules/gui/qt/medialibrary/mlbasemodel.cpp   | 176 ++++++++++-
 modules/gui/qt/medialibrary/mlbasemodel.hpp   | 290 ++++--------------
 modules/gui/qt/medialibrary/mlgenre.cpp       |  11 +-
 modules/gui/qt/medialibrary/mlgenre.hpp       |   6 +-
 modules/gui/qt/medialibrary/mlgenremodel.cpp  |  12 +-
 modules/gui/qt/medialibrary/mlgenremodel.hpp  |   6 +-
 modules/gui/qt/medialibrary/mlqmltypes.hpp    |  28 +-
 .../gui/qt/medialibrary/mlrecentsmodel.cpp    |  14 +-
 .../gui/qt/medialibrary/mlrecentsmodel.hpp    |  10 +-
 .../qt/medialibrary/mlrecentsvideomodel.cpp   |  10 +-
 .../qt/medialibrary/mlrecentsvideomodel.hpp   |   6 +-
 modules/gui/qt/medialibrary/mlurlmodel.cpp    |  16 +-
 modules/gui/qt/medialibrary/mlurlmodel.hpp    |  10 +-
 modules/gui/qt/medialibrary/mlvideo.cpp       |  13 +-
 modules/gui/qt/medialibrary/mlvideo.hpp       |   7 +-
 modules/gui/qt/medialibrary/mlvideomodel.cpp  |  12 +-
 modules/gui/qt/medialibrary/mlvideomodel.hpp  |   6 +-
 modules/gui/qt/menus/custom_menus.cpp         |   2 +-
 modules/gui/qt/util/listcache.hpp             |   9 +-
 modules/gui/qt/util/listcacheloader.hpp       |  30 ++
 36 files changed, 388 insertions(+), 402 deletions(-)
 create mode 100644 modules/gui/qt/util/listcacheloader.hpp

-- 
2.29.2



More information about the vlc-devel mailing list