Commit e0842805 authored by Matthieu Gallien's avatar Matthieu Gallien 🎵
Browse files

allow to reopen a view from an item embedded in view selector

allow to reopen the artist or album or genre open dirrectly from the
view selector
parent 41b4529c
......@@ -125,7 +125,7 @@ void ViewManager::openView(int viewIndex)
{
qCDebug(orgKdeElisaViews()) << "ViewManager::openView" << viewIndex << d->mViewParametersStack.size() << d->mViewsListData;
if (!d->mViewsListData || d->mViewsListData->isEmpty()) {
if (!d->mViewsListData || d->mViewsListData->isEmpty() || !d->mViewsListData->isFullyInitialized()) {
return;
}
......@@ -164,7 +164,7 @@ void ViewManager::openChildView(const DataTypes::MusicDataType &fullData)
return;
}
if (!d->mViewsListData) {
if (!d->mViewsListData || d->mViewsListData->isEmpty() || !d->mViewsListData->isFullyInitialized()) {
return;
}
......@@ -500,9 +500,14 @@ void ViewManager::setViewsData(ViewsListData *viewsData)
d->mViewIndex = d->mInitialIndex;
}
if (d->mViewsListData && d->mViewIndex >= 0 && d->mViewIndex < d->mViewsListData->count()) {
if (d->mViewsListData && d->mViewIndex >= 0 && d->mViewIndex < d->mViewsListData->count() && d->mViewsListData->isFullyInitialized()) {
openView(d->mViewIndex);
}
if (d->mViewsListData) {
connect(d->mViewsListData, &ViewsListData::isFullyInitializedChanged,
this, &ViewManager::openInitialView);
}
}
void ViewManager::setInitialIndex(int newIndex)
......@@ -518,11 +523,16 @@ void ViewManager::setInitialIndex(int newIndex)
d->mViewIndex = d->mInitialIndex;
}
if (d->mViewsListData && d->mViewIndex >= 0 && d->mViewIndex < d->mViewsListData->count()) {
if (d->mViewsListData && d->mViewIndex >= 0 && d->mViewIndex < d->mViewsListData->count() && d->mViewsListData->isFullyInitialized()) {
openView(d->mViewIndex);
}
}
void ViewManager::openInitialView()
{
openView(d->mInitialIndex);
}
void ViewManager::sortOrderChanged(Qt::SortOrder sortOrder)
{
auto currentSortOrderPreferences = Elisa::ElisaConfiguration::sortOrderPreferences();
......
......@@ -151,6 +151,10 @@ public Q_SLOTS:
void setInitialIndex(int newIndex);
private Q_SLOTS:
void openInitialView();
private:
void openViewFromData(const ViewParameters &viewParamaters);
......
......@@ -158,6 +158,8 @@ public:
MusicListenersManager *mManager = nullptr;
DatabaseInterface *mDatabase = nullptr;
bool mIsFullyInitialized = true;
};
ViewsListData::ViewsListData(QObject *parent) : QObject(parent), d(std::make_unique<ViewsListDataPrivate>())
......@@ -259,6 +261,23 @@ void ViewsListData::setEmbeddedCategory(ElisaUtils::PlayListEntryType aEmbeddedV
Q_EMIT embeddedCategoryChanged();
refreshEmbeddedCategory();
switch (d->mEmbeddedCategory) {
case ElisaUtils::Composer:
case ElisaUtils::Container:
case ElisaUtils::FileName:
case ElisaUtils::Lyricist:
case ElisaUtils::Radio:
case ElisaUtils::Track:
case ElisaUtils::Unknown:
d->mIsFullyInitialized = true;
Q_EMIT isFullyInitializedChanged();
break;
case ElisaUtils::Album:
case ElisaUtils::Artist:
case ElisaUtils::Genre:
break;
}
}
}
......@@ -287,6 +306,9 @@ void ViewsListData::genresAdded(DataTypes::ListGenreDataType newData)
ViewManager::ViewHideRating});
}
Q_EMIT dataAdded();
d->mIsFullyInitialized = true;
Q_EMIT isFullyInitializedChanged();
}
void ViewsListData::artistsAdded(DataTypes::ListArtistDataType newData)
......@@ -314,6 +336,9 @@ void ViewsListData::artistsAdded(DataTypes::ListArtistDataType newData)
ViewManager::ViewShowRating});
}
Q_EMIT dataAdded();
d->mIsFullyInitialized = true;
Q_EMIT isFullyInitializedChanged();
}
void ViewsListData::artistRemoved(qulonglong removedDatabaseId)
......@@ -372,6 +397,9 @@ void ViewsListData::albumsAdded(DataTypes::ListAlbumDataType newData)
useColorOverlay});
}
Q_EMIT dataAdded();
d->mIsFullyInitialized = true;
Q_EMIT isFullyInitializedChanged();
}
void ViewsListData::albumRemoved(qulonglong removedDatabaseId)
......@@ -613,6 +641,11 @@ DatabaseInterface* ViewsListData::database() const
return d->mDatabase;
}
bool ViewsListData::isFullyInitialized() const
{
return d->mIsFullyInitialized;
}
void ViewsListData::setDatabase(DatabaseInterface *aDatabase)
{
if (d->mDatabase != aDatabase) {
......
......@@ -295,6 +295,10 @@ class ELISALIB_EXPORT ViewsListData : public QObject
WRITE setDatabase
NOTIFY databaseChanged)
Q_PROPERTY(bool isFullyInitialized
READ isFullyInitialized
NOTIFY isFullyInitializedChanged)
public:
explicit ViewsListData(QObject *parent = nullptr);
......@@ -330,6 +334,8 @@ public:
DatabaseInterface* database() const;
bool isFullyInitialized() const;
Q_SIGNALS:
void embeddedCategoryChanged();
......@@ -354,6 +360,8 @@ Q_SIGNALS:
void dataReset();
void isFullyInitializedChanged();
public Q_SLOTS:
void setEmbeddedCategory(ElisaUtils::PlayListEntryType aEmbeddedView);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment