qt: medialib: implement separate data loaders
commitfb003150f5bc55ec4aa04285d3b0fa1b531b445b
authorRomain Vimont <rom1v@videolabs.io>
Tue, 17 Nov 2020 15:34:02 +0000 (17 16:34 +0100)
committerPierre Lamot <pierre@videolabs.io>
Wed, 2 Dec 2020 17:25:41 +0000 (2 18:25 +0100)
treef457cb0dba8c87e20ee582fdd7f4d81c07709484
parent2e44710d0e3e344046e1a64142968d4b8e53da06
qt: medialib: implement separate data loaders

When the database queries are executed asynchronously, we must still be
able to delete a list model from the main thread without blocking. As a
consequence, the data loader must be able to outlive the list model
instance; this implies that loading data must not involve calling
methods on the list model itself (fetch() and countTotalElements()).

Nevertheless, the actual data to load depends on the list model (the
content is not the same between a list of videos and a list of albums).

To be able to detach the lifetime of the data loader from the one of the
list model, make the list models provide loader instances on demand,
instead of implementing the loading methods directly.

Signed-off-by: Pierre Lamot <pierre@videolabs.io>
17 files changed:
modules/gui/qt/medialibrary/mlalbummodel.cpp
modules/gui/qt/medialibrary/mlalbummodel.hpp
modules/gui/qt/medialibrary/mlalbumtrackmodel.cpp
modules/gui/qt/medialibrary/mlalbumtrackmodel.hpp
modules/gui/qt/medialibrary/mlartistmodel.cpp
modules/gui/qt/medialibrary/mlartistmodel.hpp
modules/gui/qt/medialibrary/mlbasemodel.hpp
modules/gui/qt/medialibrary/mlgenremodel.cpp
modules/gui/qt/medialibrary/mlgenremodel.hpp
modules/gui/qt/medialibrary/mlrecentsmodel.cpp
modules/gui/qt/medialibrary/mlrecentsmodel.hpp
modules/gui/qt/medialibrary/mlrecentsvideomodel.cpp
modules/gui/qt/medialibrary/mlrecentsvideomodel.hpp
modules/gui/qt/medialibrary/mlurlmodel.cpp
modules/gui/qt/medialibrary/mlurlmodel.hpp
modules/gui/qt/medialibrary/mlvideomodel.cpp
modules/gui/qt/medialibrary/mlvideomodel.hpp