Browse Source

qt: discontinue hasContent and use isReady property in MLBaseModel

pull/144/head
Fatih Uzunoglu 3 years ago
committed by Steve Lhomme
parent
commit
7d70397c7d
  1. 13
      modules/gui/qt/medialibrary/mlbasemodel.cpp
  2. 7
      modules/gui/qt/medialibrary/mlbasemodel.hpp
  3. 2
      modules/gui/qt/medialibrary/qml/MusicAlbums.qml
  4. 2
      modules/gui/qt/medialibrary/qml/MusicAllArtists.qml
  5. 2
      modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
  6. 2
      modules/gui/qt/medialibrary/qml/MusicGenres.qml
  7. 2
      modules/gui/qt/medialibrary/qml/MusicTracksDisplay.qml
  8. 2
      modules/gui/qt/medialibrary/qml/PlaylistMediaDisplay.qml
  9. 2
      modules/gui/qt/medialibrary/qml/VideoAll.qml

13
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));
}

7
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);

2
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

2
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

2
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

2
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

2
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

2
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

2
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

Loading…
Cancel
Save