[vlc-commits] [Git][videolan/vlc][master] qt: discontinue hasContent and use isReady property in MLBaseModel
Steve Lhomme (@robUx4)
gitlab at videolan.org
Sun Mar 19 08:33:13 UTC 2023
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
7d70397c by Fatih Uzunoglu at 2023-03-19T08:12:33+00:00
qt: discontinue hasContent and use isReady property in MLBaseModel
- - - - -
9 changed files:
- modules/gui/qt/medialibrary/mlbasemodel.cpp
- modules/gui/qt/medialibrary/mlbasemodel.hpp
- modules/gui/qt/medialibrary/qml/MusicAlbums.qml
- modules/gui/qt/medialibrary/qml/MusicAllArtists.qml
- modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
- modules/gui/qt/medialibrary/qml/MusicGenres.qml
- modules/gui/qt/medialibrary/qml/MusicTracksDisplay.qml
- modules/gui/qt/medialibrary/qml/PlaylistMediaDisplay.qml
- modules/gui/qt/medialibrary/qml/VideoAll.qml
Changes:
=====================================
modules/gui/qt/medialibrary/mlbasemodel.cpp
=====================================
@@ -40,8 +40,8 @@ MLBaseModel::MLBaseModel(QObject *parent)
{
connect( this, &MLBaseModel::resetRequested, this, &MLBaseModel::onResetRequested );
- connect( this, &MLBaseModel::mlChanged, this, &MLBaseModel::hasContentChanged );
- connect( this, &MLBaseModel::countChanged, this, &MLBaseModel::hasContentChanged );
+ connect( this, &MLBaseModel::mlChanged, this, &MLBaseModel::isReadyChanged );
+ connect( this, &MLBaseModel::countChanged, this, &MLBaseModel::isReadyChanged );
}
/* For std::unique_ptr, see Effective Modern C++, Item 22 */
@@ -468,6 +468,8 @@ void MLBaseModel::validateCache() const
this, &MLBaseModel::onCacheBeginMoveRows);
m_cache->initCount();
+
+ emit isReadyChanged();
}
@@ -482,7 +484,10 @@ void MLBaseModel::resetCache()
void MLBaseModel::invalidateCache()
{
if (m_cache)
+ {
m_cache->invalidate();
+ emit isReadyChanged();
+ }
else
validateCache();
}
@@ -624,7 +629,7 @@ MLQueryParams MLBaseModel::BaseLoader::getParams(size_t index, size_t count) con
return { m_searchPattern.toUtf8(), m_sort, m_sort_desc, index, count };
}
-bool MLBaseModel::hasContent() const
+bool MLBaseModel::isReady() const
{
- return m_mediaLib && (getCount() > 0);
+ return (m_mediaLib && m_cache && (m_cache->count() != COUNT_UNINITIALIZED));
}
=====================================
modules/gui/qt/medialibrary/mlbasemodel.hpp
=====================================
@@ -57,7 +57,8 @@ class MLBaseModel : public QAbstractListModel
Q_PROPERTY(unsigned int count READ getCount NOTIFY countChanged FINAL)
- Q_PROPERTY(bool hasContent READ hasContent NOTIFY hasContentChanged FINAL)
+ // isReady is true when ml is not null pointer and cache count is not uninitialized
+ Q_PROPERTY(bool isReady READ isReady NOTIFY isReadyChanged FINAL)
public:
explicit MLBaseModel(QObject *parent = nullptr);
@@ -88,7 +89,7 @@ signals:
void sortOrderChanged();
void sortCriteriaChanged();
void countChanged(unsigned int) const;
- void hasContentChanged();
+ void isReadyChanged() const;
protected slots:
void onResetRequested();
@@ -174,7 +175,7 @@ public:
int rowCount(const QModelIndex &parent = {}) const override;
virtual unsigned int getCount() const;
- bool hasContent() const;
+ bool isReady() const;
private:
void onCacheDataChanged(int first, int last);
=====================================
modules/gui/qt/medialibrary/qml/MusicAlbums.qml
=====================================
@@ -332,7 +332,7 @@ FocusScope {
EmptyLabelButton {
anchors.fill: parent
- visible: !albumModelId.hasContent
+ visible: albumModelId.isReady && (albumModelId.count <= 0)
focus: visible
text: I18n.qtr("No albums found\nPlease try adding sources, by going to the Browse tab")
Navigation.parentItem: root
=====================================
modules/gui/qt/medialibrary/qml/MusicAllArtists.qml
=====================================
@@ -273,7 +273,7 @@ FocusScope {
EmptyLabelButton {
anchors.fill: parent
- visible: !artistModel.hasContent
+ visible: artistModel.isReady && (artistModel.count <= 0)
focus: visible
text: I18n.qtr("No artists found\nPlease try adding sources, by going to the Browse tab")
Navigation.parentItem: root
=====================================
modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
=====================================
@@ -250,7 +250,7 @@ FocusScope {
EmptyLabelButton {
anchors.fill: parent
- visible: !artistModel.hasContent
+ visible: artistModel.isReady && (artistModel.count <= 0)
focus: visible
text: I18n.qtr("No artists found\nPlease try adding sources, by going to the Browse tab")
Navigation.parentItem: root
=====================================
modules/gui/qt/medialibrary/qml/MusicGenres.qml
=====================================
@@ -342,7 +342,7 @@ FocusScope {
EmptyLabelButton {
anchors.fill: parent
- visible: !genreModel.hasContent
+ visible: genreModel.isReady && (genreModel.count <= 0)
focus: visible
text: I18n.qtr("No genres found\nPlease try adding sources, by going to the Browse tab")
Navigation.parentItem: root
=====================================
modules/gui/qt/medialibrary/qml/MusicTracksDisplay.qml
=====================================
@@ -74,7 +74,7 @@ FocusScope {
EmptyLabelButton {
anchors.fill: parent
- visible: !tracklistdisplay_id.model.hasContent
+ visible: tracklistdisplay_id.model.isReady && (tracklistdisplay_id.model.count <= 0)
focus: visible
text: I18n.qtr("No tracks found\nPlease try adding sources, by going to the Browse tab")
Navigation.parentItem: root
=====================================
modules/gui/qt/medialibrary/qml/PlaylistMediaDisplay.qml
=====================================
@@ -197,7 +197,7 @@ FocusScope {
EmptyLabelButton {
anchors.fill: parent
- visible: !model.hasContent
+ visible: model.isReady && (model.count <= 0)
focus: visible
=====================================
modules/gui/qt/medialibrary/qml/VideoAll.qml
=====================================
@@ -379,7 +379,7 @@ FocusScope {
coverWidth : VLCStyle.dp(182, VLCStyle.scale)
coverHeight: VLCStyle.dp(114, VLCStyle.scale)
- visible: !model.hasContent
+ visible: model.isReady && (model.count <= 0)
focus: visible
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/7d70397c7d976677bcf9989c99f636e7cfd383c9
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/7d70397c7d976677bcf9989c99f636e7cfd383c9
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