Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
2212ef87 by Pierre Lamot at 2024-04-30T05:41:15+00:00
qt: ensure network models arent as cachable too early
most network models are loaded asynchronously, if the cache is built right after
the model initialisation, data isnt loaded yet and the first model version
is
built on an empty list, which can lead to a transitory state where the view
assumes its not loading anymore and that no data is present
- - - - -
8 changed files:
- modules/gui/qt/Makefile.am
- modules/gui/qt/meson.build
- modules/gui/qt/network/networkdevicemodel.cpp
- modules/gui/qt/network/networkmediamodel.cpp
- modules/gui/qt/network/networksourcesmodel.cpp
- modules/gui/qt/network/servicesdiscoverymodel.cpp
- modules/gui/qt/network/standardpathmodel.cpp
- + modules/gui/qt/util/locallistbasemodel.hpp
Changes:
=
modules/gui/qt/Makefile.am
=
@@ -308,6 +308,7 @@ libqt_plugin_la_SOURCES = \
util/listcache.hxx util/listcache.hpp \
util/listcacheloader.hpp \
util/locallistcacheloader.hpp \
+ util/locallistbasemodel.hpp \
util/navigation_history.cpp util/navigation_history.hpp \
util/item_key_event_filter.cpp \
util/item_key_event_filter.hpp \
=
modules/gui/qt/meson.build
=
@@ -129,6 +129,7 @@ moc_headers = files(
'util/keyhelper.hpp',
'util/listcache.hpp',
'util/locallistcacheloader.hpp',
+'util/locallistbasemodel.hpp',
'util/navigation_history.hpp',
'util/item_key_event_filter.hpp',
'util/effects_image_provider.hpp',
@@ -692,4 +693,3 @@ if qt6_dep.found()
'dependencies': [qt6_dep, qt_extra_deps],
}
endif
-
=
modules/gui/qt/network/networkdevicemodel.cpp
=
@@ -28,8 +28,7 @@
#include "playlist/playlist_controller.hpp"
#include "util/shared_input_item.hpp"
-#include "util/base_model_p.hpp"
-#include "util/locallistcacheloader.hpp"
+#include "util/locallistbasemodel.hpp"
namespace
{
@@ -158,17 +157,16 @@ bool ListCache::compareItems(const
NetworkDeviceItemPtr& a
// NetworkDeviceModelPrivate
class NetworkDeviceModelPrivate
-: public BaseModelPrivateT
-, public LocalListCacheLoader::ModelSource
+: public LocalListBaseModelPrivate
{
Q_DECLARE_PUBLIC(NetworkDeviceModel)
public:
NetworkDeviceModelPrivate(NetworkDeviceModel * pub)
-: BaseModelPrivateT(pub)
+: LocalListBaseModelPrivate(pub)
, m_items(0, NetworkDeviceItemHash{}, NetworkDeviceItemEqual{})
{}
-NetworkDeviceModelLoader::ItemCompare getSortFunction() const
+NetworkDeviceModelLoader::ItemCompare getSortFunction() const override
{
if (m_sortCriteria == "mrl")
{
@@ -186,13 +184,6 @@ public:
}
}
-std::unique_ptr> createLoader()
const override
-{
-return std::make_unique(
-this, m_searchPattern,
-getSortFunction());
-}
-
bool initializeModel() override
{
Q_Q(NetworkDeviceModel);
@@ -240,6 +231,11 @@ public:
return false;
m_listeners.push_back( std::move( l ) );
}
+
+//service discovery don't notify preparse end
+m_loading = false;
+emit q->loadingChanged();
+
return m_listeners.empty() == false;
}
@@ -293,7 +289,7 @@ public:
if (dataChanged)
{
-m_modelRevision += 1;
+m_revision += 1;
invalidateCache();
}
}
@@ -336,17 +332,12 @@ public:
}
if (dataChanged)
{
-m_modelRevision += 1;
+m_revision += 1;
invalidateCache();
}
}
public: //LocalListCacheLoader::ModelSource
-size_t getModelRevision() const override
-{
-return m_modelRevision;
-}
-
std::vector getModelData(const QString& pattern)
const override
{
std::vector items;
@@ -369,7 +360,6 @@ public: //LocalListCacheLoader::ModelSource
}
public:
-size_t m_modelRevision = 0;
NetworkDeviceItemSet m_items;
std::vector> m_listeners;
};
=
modules/gui/qt/network/networkmediamodel.cpp
=
@@ -21,8 +21,7 @@
#include "maininterface/mainctx.hpp"
-#include "util/base_model_p.hpp"
-#include "util/locallistcacheloader.hpp"
+#include "util/locallistbasemodel.hpp"
#include "playlist/media.hpp"
#include "playlist/playlist_controller.hpp"
@@ -75,14 +74,13 @@ bool ListCache::compareItems(const
NetworkMediaItemPtr& a,
// NetworkMediaModelPrivate
class NetworkMediaModelPrivate
-: public BaseModelPrivateT
-, public LocalListCacheLoader::ModelSource
+: public LocalListBaseModelPrivate
{