Browse Source

qt: rename mlbasemodel property

pull/162/head
Prince Gupta 3 years ago
committed by Jean-Baptiste Kempf
parent
commit
c177d489ea
  1. 2
      modules/gui/qt/maininterface/qml/MainViewLoader.qml
  2. 12
      modules/gui/qt/medialibrary/mlbasemodel.cpp
  3. 11
      modules/gui/qt/medialibrary/mlbasemodel.hpp
  4. 2
      modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml
  5. 2
      modules/gui/qt/medialibrary/qml/MusicTracksDisplay.qml
  6. 2
      modules/gui/qt/medialibrary/qml/PlaylistMediaDisplay.qml

2
modules/gui/qt/maininterface/qml/MainViewLoader.qml

@ -70,7 +70,7 @@ Widgets.StackViewExt {
}
property var currentComponent: {
if (typeof model === "undefined" || !model || !Helpers.get(model, "isReady", true))
if (typeof model === "undefined" || !model || Helpers.get(model, "loading", true))
return null // invalid state
if (model.count === 0)
return emptyLabel

12
modules/gui/qt/medialibrary/mlbasemodel.cpp

@ -39,8 +39,8 @@ MLBaseModel::MLBaseModel(QObject *parent)
{
connect( this, &MLBaseModel::resetRequested, this, &MLBaseModel::onResetRequested );
connect( this, &MLBaseModel::mlChanged, this, &MLBaseModel::isReadyChanged );
connect( this, &MLBaseModel::countChanged, this, &MLBaseModel::isReadyChanged );
connect( this, &MLBaseModel::mlChanged, this, &MLBaseModel::loadingChanged );
connect( this, &MLBaseModel::countChanged, this, &MLBaseModel::loadingChanged );
}
/* For std::unique_ptr, see Effective Modern C++, Item 22 */
@ -485,7 +485,7 @@ void MLBaseModel::validateCache() const
m_cache->initCount();
emit isReadyChanged();
emit loadingChanged();
}
@ -502,7 +502,7 @@ void MLBaseModel::invalidateCache()
if (m_cache)
{
m_cache->invalidate();
emit isReadyChanged();
emit loadingChanged();
}
else
validateCache();
@ -645,7 +645,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::isReady() const
bool MLBaseModel::loading() const
{
return (m_mediaLib && m_cache && (m_cache->count() != COUNT_UNINITIALIZED));
return !(m_mediaLib && m_cache && (m_cache->count() != COUNT_UNINITIALIZED));
}

11
modules/gui/qt/medialibrary/mlbasemodel.hpp

@ -60,8 +60,11 @@ class MLBaseModel : public QAbstractListModel, public QQmlParserStatus
Q_PROPERTY(unsigned int count READ getCount NOTIFY countChanged FINAL)
// isReady is true when the ml object is not null and the cache count is initialized
Q_PROPERTY(bool isReady READ isReady NOTIFY isReadyChanged FINAL)
/**
* @brief loading
* @return true till no data is available
*/
Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged FINAL)
public:
explicit MLBaseModel(QObject *parent = nullptr);
@ -92,7 +95,7 @@ signals:
void sortOrderChanged();
void sortCriteriaChanged();
void countChanged(unsigned int) const;
void isReadyChanged() const;
void loadingChanged() const;
protected slots:
void onResetRequested();
@ -181,7 +184,7 @@ public:
int rowCount(const QModelIndex &parent = {}) const override;
virtual unsigned int getCount() const;
bool isReady() const;
bool loading() const;
private:
void onCacheDataChanged(int first, int last);

2
modules/gui/qt/medialibrary/qml/MusicArtistsAlbums.qml

@ -250,7 +250,7 @@ FocusScope {
Widgets.EmptyLabelButton {
anchors.fill: parent
visible: artistModel.isReady && (artistModel.count <= 0)
visible: !artistModel.loading && (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/MusicTracksDisplay.qml

@ -74,7 +74,7 @@ FocusScope {
Widgets.EmptyLabelButton {
anchors.fill: parent
visible: tracklistdisplay_id.model.isReady && (tracklistdisplay_id.model.count <= 0)
visible: !tracklistdisplay_id.model.loading && (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

@ -199,7 +199,7 @@ FocusScope {
Widgets.EmptyLabelButton {
anchors.fill: parent
visible: model.isReady && (model.count <= 0)
visible: !model.loading && (model.count <= 0)
focus: visible

Loading…
Cancel
Save