Commit 61011bbf authored by Matthieu Gallien's avatar Matthieu Gallien 🎵

let navigation to child view use a generic container for filter data

will allow to get any amount of data including not visible ones

remove use of explicit path filters in ViewManager

use only generic data filters for paths

remove locale file only logic in favor of generic URL handling
parent 4bd1fad0
This diff is collapsed.
......@@ -34,6 +34,7 @@ set(elisaLib_SOURCES
models/trackcontextmetadatamodel.cpp
models/viewsmodel.cpp
viewslistdata.cpp
viewconfigurationdata.cpp
localFileConfiguration/elisaconfigurationdialog.cpp
)
......
......@@ -70,12 +70,11 @@ public:
FullDataRole,
IsDirectoryRole,
IsPlayListRole,
FilePathRole,
};
Q_ENUM(ColumnsRoles)
private:
using DataType = QMap<ColumnsRoles, QVariant>;
public:
......
......@@ -34,6 +34,7 @@
#include "trackslistener.h"
#include "viewmanager.h"
#include "viewslistdata.h"
#include "viewconfigurationdata.h"
#include "databaseinterface.h"
#include "datatypes.h"
#include "models/datamodel.h"
......@@ -115,6 +116,7 @@ void ElisaQmlTestPlugin::registerTypes(const char *uri)
qmlRegisterType<MusicListenersManager>(uri, 1, 0, "MusicListenersManager");
qmlRegisterType<ViewManager>(uri, 1, 0, "ViewManager");
qmlRegisterType<ViewsListData>(uri, 1, 0, "ViewsListData");
qmlRegisterType<ViewConfigurationData>(uri, 1, 0, "ViewConfigurationData");
qmlRegisterType<DataModel>(uri, 1, 0, "DataModel");
qmlRegisterType<TrackMetadataModel>(uri, 1, 0, "TrackMetadataModel");
qmlRegisterType<TrackContextMetaDataModel>(uri, 1, 0, "TrackContextMetaDataModel");
......@@ -170,6 +172,8 @@ void ElisaQmlTestPlugin::registerTypes(const char *uri)
qRegisterMetaType<DataTypes::ColumnsRoles>("DataTypes::ColumnsRoles");
qRegisterMetaType<ModelDataLoader::TrackDataType>("ModelDataLoader::TrackDataType");
qRegisterMetaType<TracksListener::TrackDataType>("TracksListener::TrackDataType");
qRegisterMetaType<ViewManager::IsTreeModelType>("ViewManager::IsTreeModelType");
qRegisterMetaType<DataTypes::DataType>("DataTypes::DataType");
qmlRegisterUncreatableType<ElisaConfigurationDialog>(uri, 1, 0, "ElisaConfigurationDialog", QStringLiteral("only one and done in c++"));
qmlRegisterUncreatableType<ElisaApplication>(uri, 1, 0, "ElisaApplication", QStringLiteral("only one and done in c++"));
......
......@@ -71,6 +71,9 @@ public:
ElementTypeRole,
LyricsRole,
FullDataRole,
IsDirectoryRole,
IsPlayListRole,
FilePathRole,
IsValidRole,
CountRole,
IsPlayingRole,
......
......@@ -360,18 +360,15 @@ bool DataModel::isBusy() const
return d->mIsBusy;
}
void DataModel::initialize(MusicListenersManager *manager, DatabaseInterface *database,
ElisaUtils::PlayListEntryType modelType, ElisaUtils::FilterType filter,
const QString &genre, const QString &artist, qulonglong databaseId,
const QUrl &pathFilter)
void DataModel::initializeByData(MusicListenersManager *manager, DatabaseInterface *database,
ElisaUtils::PlayListEntryType modelType, ElisaUtils::FilterType filter,
const DataTypes::DataType &dataFilter)
{
Q_UNUSED(pathFilter)
qCDebug(orgKdeElisaModel()) << "DataModel::initialize" << modelType << filter << dataFilter;
qCDebug(orgKdeElisaModel()) << "DataModel::initialize" << modelType << filter << genre << artist << databaseId;
d->mDatabaseId = databaseId;
d->mGenre = genre;
d->mArtist = artist;
d->mDatabaseId = dataFilter[DataTypes::DatabaseIdRole].toULongLong();
d->mGenre = dataFilter[DataTypes::GenreRole].toString();
d->mArtist = dataFilter[DataTypes::ArtistRole].toString();
initializeModel(manager, database, modelType, filter);
}
......@@ -920,6 +917,20 @@ void DataModel::albumModified(const DataModel::AlbumDataType &modifiedAlbum)
Q_EMIT dataChanged(index(albumIndex, 0), index(albumIndex, 0));
}
void DataModel::initialize(MusicListenersManager *manager, DatabaseInterface *database,
ElisaUtils::PlayListEntryType modelType, ElisaUtils::FilterType filter,
const QString &genre, const QString &artist, qulonglong databaseId,
const QUrl &pathFilter)
{
qCDebug(orgKdeElisaModel()) << "DataModel::initialize" << modelType << filter << databaseId << genre << artist;
d->mDatabaseId = databaseId;
d->mGenre = genre;
d->mArtist = artist;
initializeModel(manager, database, modelType, filter);
}
void DataModel::cleanedDatabase()
{
beginResetModel();
......
......@@ -132,6 +132,10 @@ public Q_SLOTS:
const QString &genre, const QString &artist, qulonglong databaseId,
const QUrl &pathFilter);
void initializeByData(MusicListenersManager *manager, DatabaseInterface *database,
ElisaUtils::PlayListEntryType modelType, ElisaUtils::FilterType filter,
const DataTypes::DataType &dataFilter);
private Q_SLOTS:
void cleanedDatabase();
......
......@@ -124,6 +124,8 @@ QVariant FileBrowserModel::data(const QModelIndex &index, int role) const
{
KFileItem item = itemForIndex(index);
if (item.isDir()) {
result = QVariant::fromValue(DataTypes::MusicDataType{{DataTypes::ColumnsRoles::FilePathRole, item.url()},
{DataTypes::ColumnsRoles::ElementTypeRole, ElisaUtils::Container}});
} else {
if (item.currentMimeType().inherits(QStringLiteral("audio/x-mpegurl"))) {
} else {
......@@ -156,5 +158,17 @@ void FileBrowserModel::initialize(MusicListenersManager *manager, DatabaseInterf
setUrl(pathFilter);
}
void FileBrowserModel::initializeByData(MusicListenersManager *manager, DatabaseInterface *database,
ElisaUtils::PlayListEntryType modelType, ElisaUtils::FilterType filter,
const DataTypes::DataType &dataFilter)
{
Q_UNUSED(manager)
Q_UNUSED(database)
Q_UNUSED(modelType)
Q_UNUSED(filter)
setUrl(dataFilter[DataTypes::FilePathRole].toUrl());
}
#include "moc_filebrowsermodel.cpp"
......@@ -10,6 +10,7 @@
#include "elisaLib_export.h"
#include "elisautils.h"
#include "datatypes.h"
#include <KIOWidgets/KDirModel>
......@@ -46,6 +47,10 @@ public Q_SLOTS:
ElisaUtils::PlayListEntryType modelType, ElisaUtils::FilterType filter,
const QString &genre, const QString &artist, qulonglong databaseId,
const QUrl &pathFilter);
void initializeByData(MusicListenersManager *manager, DatabaseInterface *database,
ElisaUtils::PlayListEntryType modelType, ElisaUtils::FilterType filter,
const DataTypes::DataType &dataFilter);
};
......
......@@ -24,12 +24,12 @@ RowLayout {
}
function openArtist(name) {
viewManager.openChildView(name, '', elisaTheme.artistIcon, 0, ElisaUtils.Artist)
viewManager.openArtistView(name)
}
function openAlbum(album, artist, image, albumID) {
image = !image ? elisaTheme.defaultAlbumImage : image;
viewManager.openChildView(album, artist, image, albumID, ElisaUtils.Album);
viewManager.openAlbumView(album, artist, albumID, image);
}
function openNowPlaying() {
......@@ -42,63 +42,60 @@ RowLayout {
viewsData: viewsData
onOpenGridView: {
if (expectedDepth === 1) {
if (configurationData.expectedDepth === 1) {
listViews.setCurrentIndex(viewManager.viewIndex)
}
while(browseStackView.depth > expectedDepth) {
while(browseStackView.depth > configurationData.expectedDepth) {
browseStackView.pop()
}
browseStackView.push(dataGridView, {
filterType: filterType,
mainTitle: mainTitle,
secondaryTitle: secondaryTitle,
image: imageUrl,
modelType: dataType,
realModel: model,
proxyModel: associatedProxyModel,
defaultIcon: viewDefaultIcon,
showRating: viewShowRating,
delegateDisplaySecondaryText: viewDelegateDisplaySecondaryText,
genreFilterText: genreNameFilter,
artistFilter: artistNameFilter,
pathFilter: targetPathFilter,
filterType: configurationData.filterType,
mainTitle: configurationData.mainTitle,
secondaryTitle: configurationData.secondaryTitle,
image: configurationData.imageUrl,
modelType: configurationData.dataType,
realModel: configurationData.model,
proxyModel: configurationData.associatedProxyModel,
defaultIcon: configurationData.viewDefaultIcon,
showRating: configurationData.viewShowRating,
delegateDisplaySecondaryText: configurationData.viewDelegateDisplaySecondaryText,
filter: configurationData.dataFilter,
isSubPage: (browseStackView.depth >= 2),
haveTreeModel: isTreeModel,
stackView: browseStackView,
haveTreeModel: configurationData.isTreeModel,
stackView: configurationData.browseStackView,
opacity: 0,
})
}
onOpenListView: {
if (expectedDepth === 1) {
if (configurationData.expectedDepth === 1) {
listViews.setCurrentIndex(viewManager.viewIndex)
}
while(browseStackView.depth > expectedDepth) {
while(browseStackView.depth > configurationData.expectedDepth) {
browseStackView.pop()
}
browseStackView.push(dataListView, {
filterType: filterType,
isSubPage: expectedDepth > 1,
mainTitle: mainTitle,
secondaryTitle: secondaryTitle,
databaseId: databaseId,
pathFilter: targetPathFilter,
image: imageUrl,
modelType: dataType,
realModel: model,
proxyModel: associatedProxyModel,
sortRole: sortRole,
sortAscending: sortOrder,
filterType: configurationData.filterType,
isSubPage: configurationData.expectedDepth > 1,
mainTitle: configurationData.mainTitle,
secondaryTitle: configurationData.secondaryTitle,
filter: configurationData.dataFilter,
image: configurationData.imageUrl,
modelType: configurationData.dataType,
realModel: configurationData.model,
proxyModel: configurationData.associatedProxyModel,
sortRole: configurationData.sortRole,
sortAscending: configurationData.sortOrder,
stackView: browseStackView,
displaySingleAlbum: displaySingleAlbum,
showSection: showDiscHeaders,
displaySingleAlbum: configurationData.displaySingleAlbum,
showSection: configurationData.showDiscHeaders,
opacity: 0,
radioCase: radioCase,
haveTreeModel: isTreeModel,
radioCase: configurationData.radioCase,
haveTreeModel: configurationData.isTreeModel,
})
}
......
......@@ -25,9 +25,7 @@ FocusScope {
property alias isSubPage: gridView.isSubPage
property alias expandedFilterView: gridView.expandedFilterView
property alias haveTreeModel: gridView.haveTreeModel
property string genreFilterText
property string artistFilter
property url pathFilter
property var filter
property bool modelIsInitialized: false
focus: true
......@@ -58,9 +56,8 @@ FocusScope {
proxyModel.playList = elisa.mediaPlayListProxyModel
gridView.contentModel = proxyModel
realModel.initialize(elisa.musicManager, elisa.musicManager.viewDatabase,
modelType, filterType, genreFilterText, artistFilter, 0,
pathFilter)
realModel.initializeByData(elisa.musicManager, elisa.musicManager.viewDatabase,
modelType, filterType, filter)
modelIsInitialized = true
}
......@@ -77,14 +74,14 @@ FocusScope {
anchors.fill: parent
onEnqueue: elisa.mediaPlayListProxyModel.enqueue(fullData, name,
ElisaUtils.AppendPlayList,
ElisaUtils.DoNotTriggerPlay)
ElisaUtils.AppendPlayList,
ElisaUtils.DoNotTriggerPlay)
onReplaceAndPlay: elisa.mediaPlayListProxyModel.enqueue(fullData, name,
ElisaUtils.ReplacePlayList,
ElisaUtils.TriggerPlay)
ElisaUtils.ReplacePlayList,
ElisaUtils.TriggerPlay)
onOpen: viewManager.openChildView(innerMainTitle, innerSecondaryTitle, innerImage, databaseId, dataType)
onOpen: viewManager.openChildView(fullData)
onGoBackRequested: {
viewManager.goBack()
......
......@@ -16,11 +16,10 @@ FocusScope {
property alias isSubPage: listView.isSubPage
property alias mainTitle: listView.mainTitle
property alias secondaryTitle: listView.secondaryTitle
property url pathFilter
property int databaseId
property alias showSection: listView.showSection
property alias expandedFilterView: listView.expandedFilterView
property alias haveTreeModel: listView.haveTreeModel
property var filter
property alias image: listView.image
property var modelType
property AbstractItemModel realModel
......@@ -88,9 +87,8 @@ FocusScope {
proxyModel.sortModel(sortAscending)
}
realModel.initialize(elisa.musicManager, elisa.musicManager.viewDatabase,
modelType, filterType, mainTitle, secondaryTitle, databaseId,
pathFilter)
realModel.initializeByData(elisa.musicManager, elisa.musicManager.viewDatabase,
modelType, filterType, filter)
}
function goToBack() {
......@@ -214,7 +212,7 @@ FocusScope {
showEnqueueButton: modelType !== ElisaUtils.Radio
onShowArtist: {
viewManager.openChildView(secondaryTitle, '', elisaTheme.artistIcon, 0, ElisaUtils.Artist)
viewManager.openArtistView(secondaryTitle)
}
onGoBackRequested: viewManager.goBack()
......
......@@ -31,7 +31,7 @@ FocusScope {
signal enqueue(var fullData, string name)
signal replaceAndPlay(var fullData, string name)
signal open(string innerMainTitle, string innerSecondaryTitle, url innerImage, int databaseId, var dataType)
signal open(var fullData)
signal goBackRequested()
function goToBack() {
......@@ -126,9 +126,7 @@ FocusScope {
delegateModel.rootIndex = delegateModel.modelIndex(model.index)
++depth
} else {
gridView.open(model.display, model.secondaryText,
(model && model.imageUrl && model.imageUrl.toString() !== "" ? model.imageUrl : defaultIcon),
model.databaseId, model.dataType)
gridView.open(model.fullData)
}
}
onSelected: {
......
/*
SPDX-FileCopyrightText: 2020 (c) Matthieu Gallien <matthieu_gallien@yahoo.fr>
SPDX-License-Identifier: LGPL-3.0-or-later
*/
#include "viewconfigurationdata.h"
class ViewConfigurationDataPrivate
{
public:
ViewConfigurationDataPrivate()
{
}
ViewConfigurationDataPrivate(ElisaUtils::FilterType filterType, int expectedDepth,
QString mainTitle, QString secondaryTitle,
QUrl imageUrl, ElisaUtils::PlayListEntryType dataType,
QAbstractItemModel *model, QAbstractProxyModel *associatedProxyModel,
QUrl viewDefaultIcon, DataTypes::DataType dataFilter,
ViewManager::ViewCanBeRated viewShowRating,
ViewManager::DelegateUseSecondaryText viewDelegateDisplaySecondaryText,
ViewManager::IsTreeModelType isTreeModel)
: mFilterType(filterType)
, mExpectedDepth(expectedDepth)
, mMainTitle(std::move(mainTitle))
, mSecondaryTitle(std::move(secondaryTitle))
, mImageUrl(std::move(imageUrl))
, mDataType(dataType)
, mModel(model)
, mAssociatedProxyModel(associatedProxyModel)
, mViewDefaultIcon(std::move(viewDefaultIcon))
, mDataFilter(std::move(dataFilter))
, mViewShowRating(viewShowRating)
, mViewDelegateDisplaySecondaryText(viewDelegateDisplaySecondaryText)
, mIsTreeModel(isTreeModel)
{
}
ViewConfigurationDataPrivate(ElisaUtils::FilterType filterType, int expectedDepth,
QString mainTitle, QString secondaryTitle,
QUrl imageUrl, ElisaUtils::PlayListEntryType dataType,
QAbstractItemModel *model, QAbstractProxyModel *associatedProxyModel,
DataTypes::DataType dataFilter, int sortRole, Qt::SortOrder sortOrder,
ViewManager::AlbumCardinality displaySingleAlbum,
ViewManager::AlbumViewStyle showDiscHeaders,
ViewManager::RadioSpecificStyle radioCase,
ViewManager::IsTreeModelType isTreeModel)
: mFilterType(filterType)
, mExpectedDepth(expectedDepth)
, mMainTitle(std::move(mainTitle))
, mSecondaryTitle(std::move(secondaryTitle))
, mImageUrl(std::move(imageUrl))
, mDataType(dataType)
, mModel(model)
, mAssociatedProxyModel(associatedProxyModel)
, mDataFilter(std::move(dataFilter))
, mIsTreeModel(isTreeModel)
, mSortRole(sortRole)
, mSortOrder(sortOrder)
, mDisplaySingleAlbum(displaySingleAlbum)
, mShowDiscHeaders(showDiscHeaders)
, mRadioCase(radioCase)
{
}
ElisaUtils::FilterType mFilterType;
int mExpectedDepth;
QString mMainTitle;
QString mSecondaryTitle;
QUrl mImageUrl;
ElisaUtils::PlayListEntryType mDataType;
QAbstractItemModel * mModel;
QAbstractProxyModel * mAssociatedProxyModel;
QUrl mViewDefaultIcon;
DataTypes::DataType mDataFilter;
ViewManager::ViewCanBeRated mViewShowRating;
ViewManager::DelegateUseSecondaryText mViewDelegateDisplaySecondaryText;
ViewManager::IsTreeModelType mIsTreeModel;
int mSortRole;
Qt::SortOrder mSortOrder;
ViewManager::AlbumCardinality mDisplaySingleAlbum;
ViewManager::AlbumViewStyle mShowDiscHeaders;
ViewManager::RadioSpecificStyle mRadioCase;
};
ViewConfigurationData::ViewConfigurationData(QObject *parent)
: QObject(parent)
, d(std::make_unique<ViewConfigurationDataPrivate>())
{
}
ViewConfigurationData::ViewConfigurationData(ElisaUtils::FilterType filterType, int expectedDepth,
QString mainTitle, QString secondaryTitle,
QUrl imageUrl, ElisaUtils::PlayListEntryType dataType,
QAbstractItemModel *model, QAbstractProxyModel *associatedProxyModel,
QUrl viewDefaultIcon, DataTypes::DataType dataFilter,
ViewManager::ViewCanBeRated viewShowRating,
ViewManager::DelegateUseSecondaryText viewDelegateDisplaySecondaryText,
ViewManager::IsTreeModelType isTreeModel, QObject *parent)
: QObject(parent)
, d(std::make_unique<ViewConfigurationDataPrivate>(filterType, expectedDepth, std::move(mainTitle),
std::move(secondaryTitle), std::move(imageUrl),
dataType, model, associatedProxyModel,
std::move(viewDefaultIcon), std::move(dataFilter),
viewShowRating,viewDelegateDisplaySecondaryText,
isTreeModel))
{
}
ViewConfigurationData::ViewConfigurationData(ElisaUtils::FilterType filterType, int expectedDepth,
QString mainTitle, QString secondaryTitle,
QUrl imageUrl, ElisaUtils::PlayListEntryType dataType,
QAbstractItemModel *model, QAbstractProxyModel *associatedProxyModel,
DataTypes::DataType dataFilter, int sortRole, Qt::SortOrder sortOrder,
ViewManager::AlbumCardinality displaySingleAlbum,
ViewManager::AlbumViewStyle showDiscHeaders,
ViewManager::RadioSpecificStyle radioCase,
ViewManager::IsTreeModelType isTreeModel, QObject *parent)
: QObject(parent)
, d(std::make_unique<ViewConfigurationDataPrivate>(filterType, expectedDepth, std::move(mainTitle),
std::move(secondaryTitle), std::move(imageUrl),
dataType, model, associatedProxyModel, std::move(dataFilter),
sortRole, sortOrder, displaySingleAlbum, showDiscHeaders,
radioCase, isTreeModel))
{
}
ElisaUtils::FilterType ViewConfigurationData::filterType() const
{
return d->mFilterType;
}
int ViewConfigurationData::expectedDepth() const
{
return d->mExpectedDepth;
}
QString ViewConfigurationData::mainTitle() const
{
return d->mMainTitle;
}
QString ViewConfigurationData::secondaryTitle() const
{
return d->mSecondaryTitle;
}
QUrl ViewConfigurationData::imageUrl() const
{
return d->mImageUrl;
}
ElisaUtils::PlayListEntryType ViewConfigurationData::dataType() const
{
return d->mDataType;
}
QAbstractItemModel *ViewConfigurationData::model() const
{
return d->mModel;
}
QAbstractProxyModel *ViewConfigurationData::associatedProxyModel() const
{
return d->mAssociatedProxyModel;
}
QUrl ViewConfigurationData::viewDefaultIcon() const
{
return d->mViewDefaultIcon;
}
DataTypes::DataType ViewConfigurationData::dataFilter() const
{
return d->mDataFilter;
}
ViewManager::ViewCanBeRated ViewConfigurationData::viewShowRating() const
{
return d->mViewShowRating;
}
ViewManager::DelegateUseSecondaryText ViewConfigurationData::viewDelegateDisplaySecondaryText() const
{
return d->mViewDelegateDisplaySecondaryText;
}
ViewManager::IsTreeModelType ViewConfigurationData::isTreeModel() const
{
return d->mIsTreeModel;
}
int ViewConfigurationData::sortRole() const
{
return d->mSortRole;
}
Qt::SortOrder ViewConfigurationData::sortOrder() const
{
return d->mSortOrder;
}
ViewManager::AlbumCardinality ViewConfigurationData::displaySingleAlbum() const
{
return d->mDisplaySingleAlbum;
}
ViewManager::AlbumViewStyle ViewConfigurationData::showDiscHeaders() const
{
return d->mShowDiscHeaders;
}
ViewManager::RadioSpecificStyle ViewConfigurationData::radioCase() const
{
return d->mRadioCase;
}
ViewConfigurationData::~ViewConfigurationData() = default;
#include "moc_viewconfigurationdata.cpp"
/*
SPDX-FileCopyrightText: 2020 (c) Matthieu Gallien <matthieu_gallien@yahoo.fr>
SPDX-License-Identifier: LGPL-3.0-or-later
*/
#ifndef VIEWCONFIGURATIONDATA_H
#define VIEWCONFIGURATIONDATA_H
#include "elisaLib_export.h"
#include "elisautils.h"
#include "datatypes.h"
#include "viewmanager.h"
#include <QObject>
#include <QString>
#include <QUrl>
#include <memory>