Commit 380c2d87 authored by Matthieu Gallien's avatar Matthieu Gallien 🎵

basic navigation inside $HOME is working

parent 684c62fe
......@@ -72,7 +72,7 @@ private Q_SLOTS:
QCOMPARE(endRemoveRowsSpy.count(), 0);
QCOMPARE(dataChangedSpy.count(), 0);
tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::NoFilter, {}, {}, 0);
tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::NoFilter, {}, {}, 0, {});
QCOMPARE(beginInsertRowsSpy.count(), 0);
QCOMPARE(endInsertRowsSpy.count(), 0);
......@@ -136,7 +136,7 @@ private Q_SLOTS:
QCOMPARE(endRemoveRowsSpy.count(), 0);
QCOMPARE(dataChangedSpy.count(), 0);
tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::NoFilter, {}, {}, 0);
tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::NoFilter, {}, {}, 0, {});
QCOMPARE(beginInsertRowsSpy.count(), 0);
QCOMPARE(endInsertRowsSpy.count(), 0);
......@@ -208,7 +208,7 @@ private Q_SLOTS:
QCOMPARE(endRemoveRowsSpy.count(), 0);
QCOMPARE(dataChangedSpy.count(), 0);
tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::NoFilter, {}, {}, 0);
tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::NoFilter, {}, {}, 0, {});
QCOMPARE(beginInsertRowsSpy.count(), 0);
QCOMPARE(endInsertRowsSpy.count(), 0);
......@@ -276,7 +276,7 @@ private Q_SLOTS:
QCOMPARE(endRemoveRowsSpy.count(), 0);
QCOMPARE(dataChangedSpy.count(), 0);
tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::NoFilter, {}, {}, 0);
tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::NoFilter, {}, {}, 0, {});
QCOMPARE(beginInsertRowsSpy.count(), 0);
QCOMPARE(endInsertRowsSpy.count(), 0);
......@@ -359,7 +359,7 @@ private Q_SLOTS:
QCOMPARE(endRemoveRowsSpy.count(), 0);
QCOMPARE(dataChangedSpy.count(), 0);
tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::NoFilter, {}, {}, 0);
tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::NoFilter, {}, {}, 0, {});
QCOMPARE(beginInsertRowsSpy.count(), 0);
QCOMPARE(endInsertRowsSpy.count(), 0);
......@@ -468,7 +468,7 @@ private Q_SLOTS:
QCOMPARE(endRemoveRowsSpy.count(), 0);
QCOMPARE(dataChangedSpy.count(), 0);
tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::NoFilter, {}, {}, 0);
tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::NoFilter, {}, {}, 0, {});
QCOMPARE(beginInsertRowsSpy.count(), 0);
QCOMPARE(endInsertRowsSpy.count(), 0);
......
......@@ -79,7 +79,7 @@ private Q_SLOTS:
QCOMPARE(dataChangedSpy.count(), 0);
albumsModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::FilterById, {}, {},
musicDb.albumIdFromTitleAndArtist(QStringLiteral("album1"), QStringLiteral("Various Artists"), QStringLiteral("/")));
musicDb.albumIdFromTitleAndArtist(QStringLiteral("album1"), QStringLiteral("Various Artists"), QStringLiteral("/")), {});
QCOMPARE(beginInsertRowsSpy.count(), 0);
QCOMPARE(endInsertRowsSpy.count(), 0);
......@@ -146,7 +146,7 @@ private Q_SLOTS:
QCOMPARE(dataChangedSpy.count(), 0);
albumsModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::FilterById, {}, {},
musicDb.albumIdFromTitleAndArtist(QStringLiteral("album3"), QStringLiteral("artist2"), QStringLiteral("/")));
musicDb.albumIdFromTitleAndArtist(QStringLiteral("album3"), QStringLiteral("artist2"), QStringLiteral("/")), {});
QCOMPARE(beginInsertRowsSpy.count(), 0);
QCOMPARE(endInsertRowsSpy.count(), 0);
......@@ -227,7 +227,7 @@ private Q_SLOTS:
QCOMPARE(dataChangedSpy.count(), 0);
albumsModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::FilterById, {}, {},
musicDb.albumIdFromTitleAndArtist(QStringLiteral("album1"), QStringLiteral("Various Artists"), QStringLiteral("/")));
musicDb.albumIdFromTitleAndArtist(QStringLiteral("album1"), QStringLiteral("Various Artists"), QStringLiteral("/")), {});
QCOMPARE(beginInsertRowsSpy.count(), 0);
QCOMPARE(endInsertRowsSpy.count(), 0);
......@@ -343,7 +343,7 @@ private Q_SLOTS:
QCOMPARE(dataChangedSpy.count(), 0);
albumsModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::FilterById, {}, {},
musicDb.albumIdFromTitleAndArtist(QStringLiteral("album1"), QStringLiteral("Various Artists"), QStringLiteral("/")));
musicDb.albumIdFromTitleAndArtist(QStringLiteral("album1"), QStringLiteral("Various Artists"), QStringLiteral("/")), {});
QCOMPARE(beginInsertRowsSpy.count(), 0);
QCOMPARE(endInsertRowsSpy.count(), 0);
......@@ -411,7 +411,7 @@ private Q_SLOTS:
QCOMPARE(endRemoveRowsSpy.count(), 0);
QCOMPARE(dataChangedSpy.count(), 0);
tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::NoFilter, {}, {}, 0);
tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::NoFilter, {}, {}, 0, {});
QCOMPARE(beginInsertRowsSpy.count(), 0);
QCOMPARE(endInsertRowsSpy.count(), 0);
......@@ -472,7 +472,7 @@ private Q_SLOTS:
QCOMPARE(endRemoveRowsSpy.count(), 0);
QCOMPARE(dataChangedSpy.count(), 0);
tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::NoFilter, {}, {}, 0);
tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::NoFilter, {}, {}, 0, {});
QCOMPARE(beginInsertRowsSpy.count(), 0);
QCOMPARE(endInsertRowsSpy.count(), 0);
......@@ -540,7 +540,7 @@ private Q_SLOTS:
QCOMPARE(endRemoveRowsSpy.count(), 0);
QCOMPARE(dataChangedSpy.count(), 0);
tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::NoFilter, {}, {}, 0);
tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::NoFilter, {}, {}, 0, {});
QCOMPARE(beginInsertRowsSpy.count(), 0);
QCOMPARE(endInsertRowsSpy.count(), 0);
......@@ -605,7 +605,7 @@ private Q_SLOTS:
QCOMPARE(endRemoveRowsSpy.count(), 0);
QCOMPARE(dataChangedSpy.count(), 0);
tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::NoFilter, {}, {}, 0);
tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::NoFilter, {}, {}, 0, {});
QCOMPARE(beginInsertRowsSpy.count(), 0);
QCOMPARE(endInsertRowsSpy.count(), 0);
......@@ -685,7 +685,7 @@ private Q_SLOTS:
QCOMPARE(endRemoveRowsSpy.count(), 0);
QCOMPARE(dataChangedSpy.count(), 0);
tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::NoFilter, {}, {}, 0);
tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::NoFilter, {}, {}, 0, {});
QCOMPARE(beginInsertRowsSpy.count(), 0);
QCOMPARE(endInsertRowsSpy.count(), 0);
......@@ -789,7 +789,7 @@ private Q_SLOTS:
QCOMPARE(endRemoveRowsSpy.count(), 0);
QCOMPARE(dataChangedSpy.count(), 0);
tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::NoFilter, {}, {}, 0);
tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::NoFilter, {}, {}, 0, {});
QCOMPARE(beginInsertRowsSpy.count(), 0);
QCOMPARE(endInsertRowsSpy.count(), 0);
......@@ -855,7 +855,7 @@ private Q_SLOTS:
QCOMPARE(endRemoveRowsSpy.count(), 0);
QCOMPARE(dataChangedSpy.count(), 0);
albumsModel.initialize(nullptr, nullptr, ElisaUtils::Album, ElisaUtils::NoFilter, {}, {}, 0);
albumsModel.initialize(nullptr, nullptr, ElisaUtils::Album, ElisaUtils::NoFilter, {}, {}, 0, {});
QCOMPARE(beginInsertRowsSpy.count(), 0);
QCOMPARE(endInsertRowsSpy.count(), 0);
......@@ -916,7 +916,7 @@ private Q_SLOTS:
QCOMPARE(endRemoveRowsSpy.count(), 0);
QCOMPARE(dataChangedSpy.count(), 0);
albumsModel.initialize(nullptr, nullptr, ElisaUtils::Album, ElisaUtils::NoFilter, {}, {}, 0);
albumsModel.initialize(nullptr, nullptr, ElisaUtils::Album, ElisaUtils::NoFilter, {}, {}, 0, {});
QCOMPARE(beginInsertRowsSpy.count(), 0);
QCOMPARE(endInsertRowsSpy.count(), 0);
......@@ -982,7 +982,7 @@ private Q_SLOTS:
QCOMPARE(endRemoveRowsSpy.count(), 0);
QCOMPARE(dataChangedSpy.count(), 0);
albumsModel.initialize(nullptr, nullptr, ElisaUtils::Album, ElisaUtils::NoFilter, {}, {}, 0);
albumsModel.initialize(nullptr, nullptr, ElisaUtils::Album, ElisaUtils::NoFilter, {}, {}, 0, {});
QCOMPARE(beginInsertRowsSpy.count(), 0);
QCOMPARE(endInsertRowsSpy.count(), 0);
......@@ -1043,7 +1043,7 @@ private Q_SLOTS:
QCOMPARE(endRemoveRowsSpy.count(), 0);
QCOMPARE(dataChangedSpy.count(), 0);
albumsModel.initialize(nullptr, nullptr, ElisaUtils::Album, ElisaUtils::NoFilter, {}, {}, 0);
albumsModel.initialize(nullptr, nullptr, ElisaUtils::Album, ElisaUtils::NoFilter, {}, {}, 0, {});
QCOMPARE(beginInsertRowsSpy.count(), 0);
QCOMPARE(endInsertRowsSpy.count(), 0);
......@@ -1108,7 +1108,7 @@ private Q_SLOTS:
QCOMPARE(endRemoveRowsSpy.count(), 0);
QCOMPARE(dataChangedSpy.count(), 0);
artistsModel.initialize(nullptr, &musicDb, ElisaUtils::Artist, ElisaUtils::NoFilter, {}, {}, 0);
artistsModel.initialize(nullptr, &musicDb, ElisaUtils::Artist, ElisaUtils::NoFilter, {}, {}, 0, {});
QCOMPARE(artistsModel.rowCount(), 0);
QCOMPARE(beginInsertRowsSpy.count(), 0);
......@@ -1167,7 +1167,7 @@ private Q_SLOTS:
QCOMPARE(endRemoveRowsSpy.count(), 0);
QCOMPARE(dataChangedSpy.count(), 0);
artistsModel.initialize(nullptr, &musicDb, ElisaUtils::Artist, ElisaUtils::NoFilter, {}, {}, 0);
artistsModel.initialize(nullptr, &musicDb, ElisaUtils::Artist, ElisaUtils::NoFilter, {}, {}, 0, {});
QCOMPARE(artistsModel.rowCount(), 0);
QCOMPARE(beginInsertRowsSpy.count(), 0);
......@@ -1245,7 +1245,7 @@ private Q_SLOTS:
QCOMPARE(modelResetSpy.count(), 0);
QCOMPARE(dataChangedSpy.count(), 0);
artistsModel.initialize(nullptr, &musicDb, ElisaUtils::Album, ElisaUtils::FilterByArtist, {}, QStringLiteral("artist1"), 0);
artistsModel.initialize(nullptr, &musicDb, ElisaUtils::Album, ElisaUtils::FilterByArtist, {}, QStringLiteral("artist1"), 0, {});
QCOMPARE(artistsModel.rowCount(), 0);
QCOMPARE(beginInsertRowsSpy.count(), 0);
......@@ -1304,7 +1304,7 @@ private Q_SLOTS:
QCOMPARE(modelResetSpy.count(), 0);
QCOMPARE(dataChangedSpy.count(), 0);
artistsModel.initialize(nullptr, &musicDb, ElisaUtils::Artist, ElisaUtils::FilterByGenre, QStringLiteral("genre1"), {}, 0);
artistsModel.initialize(nullptr, &musicDb, ElisaUtils::Artist, ElisaUtils::FilterByGenre, QStringLiteral("genre1"), {}, 0, {});
QCOMPARE(artistsModel.rowCount(), 0);
QCOMPARE(beginInsertRowsSpy.count(), 0);
......@@ -1364,7 +1364,7 @@ private Q_SLOTS:
QCOMPARE(dataChangedSpy.count(), 0);
artistsModel.initialize(nullptr, &musicDb, ElisaUtils::Album, ElisaUtils::FilterByGenreAndArtist,
QStringLiteral("genre3"), QStringLiteral("artist2"), 0);
QStringLiteral("genre3"), QStringLiteral("artist2"), 0, {});
QCOMPARE(artistsModel.rowCount(), 0);
QCOMPARE(beginInsertRowsSpy.count(), 0);
......@@ -1440,7 +1440,7 @@ private Q_SLOTS:
QVERIFY(albumId != 0);
artistsModel.initialize(nullptr, &musicDb, ElisaUtils::Track, ElisaUtils::FilterById, {}, {}, albumId);
artistsModel.initialize(nullptr, &musicDb, ElisaUtils::Track, ElisaUtils::FilterById, {}, {}, albumId, {});
QCOMPARE(artistsModel.rowCount(), 4);
QCOMPARE(beginInsertRowsSpy.count(), 1);
......@@ -1526,7 +1526,7 @@ private Q_SLOTS:
QCOMPARE(dataChangedSpy.count(), 0);
albumsModel.initialize(nullptr, nullptr, ElisaUtils::Track, ElisaUtils::FilterById, {}, {},
musicDb.albumIdFromTitleAndArtist(QStringLiteral("album1"), QStringLiteral("Various Artists"), QStringLiteral("/")));
musicDb.albumIdFromTitleAndArtist(QStringLiteral("album1"), QStringLiteral("Various Artists"), QStringLiteral("/")), {});
QCOMPARE(beginInsertRowsSpy.count(), 0);
QCOMPARE(endInsertRowsSpy.count(), 0);
......
......@@ -68,6 +68,8 @@ public:
ElementTypeRole,
LyricsRole,
FullDataRole,
IsDirectoryRole,
IsPlayListRole,
};
Q_ENUM(ColumnsRoles)
......
......@@ -40,6 +40,7 @@ enum PlayListEntryType {
Composer,
Track,
FileName,
Container,
Radio,
Unknown,
};
......@@ -55,6 +56,7 @@ enum FilterType {
FilterByGenreAndArtist,
FilterByRecentlyPlayed,
FilterByFrequentlyPlayed,
FilterByPath,
};
Q_ENUM_NS(FilterType)
......
......@@ -355,8 +355,11 @@ bool DataModel::isBusy() const
void DataModel::initialize(MusicListenersManager *manager, DatabaseInterface *database,
ElisaUtils::PlayListEntryType modelType, ElisaUtils::FilterType filter,
const QString &genre, const QString &artist, qulonglong databaseId)
const QString &genre, const QString &artist, qulonglong databaseId,
const QUrl &pathFilter)
{
Q_UNUSED(pathFilter)
qCDebug(orgKdeElisaModel()) << "DataModel::initialize" << modelType << filter << genre << artist << databaseId;
d->mDatabaseId = databaseId;
......
......@@ -129,7 +129,8 @@ public Q_SLOTS:
void initialize(MusicListenersManager *manager, DatabaseInterface *database,
ElisaUtils::PlayListEntryType modelType, ElisaUtils::FilterType filter,
const QString &genre, const QString &artist, qulonglong databaseId);
const QString &genre, const QString &artist, qulonglong databaseId,
const QUrl &pathFilter);
private Q_SLOTS:
......
......@@ -11,6 +11,8 @@
#include <QMimeDatabase>
#include <KIOWidgets/KDirLister>
#include "models/modelLogging.h"
FileBrowserModel::FileBrowserModel(QObject *parent) : KDirModel(parent)
{
QMimeDatabase db;
......@@ -80,6 +82,9 @@ QHash<int, QByteArray> FileBrowserModel::roleNames() const
roles[static_cast<int>(DataTypes::ColumnsRoles::IsSingleDiscAlbumRole)] = "isSingleDiscAlbum";
roles[static_cast<int>(DataTypes::ColumnsRoles::FullDataRole)] = "fullData";
roles[static_cast<int>(DataTypes::ColumnsRoles::IsDirectoryRole)] = "isDirectory";
roles[static_cast<int>(DataTypes::ColumnsRoles::IsPlayListRole)] = "isPlaylist";
return roles;
}
......@@ -87,25 +92,17 @@ QVariant FileBrowserModel::data(const QModelIndex &index, int role) const
{
auto result = QVariant();
if (role < ColumnsRoles::NameRole) {
result = KDirModel::data(index,role);
}
qCDebug(orgKdeElisaModel()) << "FileBrowserModel::data" << index << role;
switch(role)
{
case ColumnsRoles::NameRole:
{
KFileItem item = itemForIndex(index);
result = item.name();
break;
}
case ColumnsRoles::FileUrlRole:
case DataTypes::ColumnsRoles::ResourceRole:
{
KFileItem item = itemForIndex(index);
result = item.url();
break;
}
case ColumnsRoles::ImageUrlRole:
case DataTypes::ColumnsRoles::ImageUrlRole:
{
KFileItem item = itemForIndex(index);
if (item.isDir()) {
......@@ -115,27 +112,39 @@ QVariant FileBrowserModel::data(const QModelIndex &index, int role) const
}
break;
}
case ColumnsRoles::IsDirectoryRole:
case DataTypes::ColumnsRoles::IsDirectoryRole:
{
KFileItem item = itemForIndex(index);
result = item.isDir();
break;
}
case ColumnsRoles::IsPlayListRole:
case DataTypes::ColumnsRoles::IsPlayListRole:
{
KFileItem item = itemForIndex(index);
result = (item.currentMimeType().inherits(QStringLiteral("audio/x-mpegurl")));
break;
}
case DataTypes::ColumnsRoles::ElementTypeRole:
{
KFileItem item = itemForIndex(index);
result = (item.isDir() ? ElisaUtils::Container : ElisaUtils::FileName);
break;
}
default:
result = KDirModel::data(index,role);
}
qCDebug(orgKdeElisaModel()) << "FileBrowserModel::data" << index << role << result;
return result;
}
void FileBrowserModel::initialize(MusicListenersManager *manager, DatabaseInterface *database,
ElisaUtils::PlayListEntryType modelType, ElisaUtils::FilterType filter,
const QString &genre, const QString &artist, qulonglong databaseId)
const QString &genre, const QString &artist, qulonglong databaseId,
const QUrl &pathFilter)
{
setUrl(pathFilter.toLocalFile());
}
......
......@@ -24,16 +24,6 @@ class ELISALIB_EXPORT FileBrowserModel : public KDirModel
public:
enum ColumnsRoles {
NameRole = Qt::UserRole + 1,
FileUrlRole = Qt::UserRole + 2,
ImageUrlRole = Qt::UserRole + 3,
IsDirectoryRole = Qt::UserRole + 4,
IsPlayListRole = Qt::UserRole + 5
};
Q_ENUM(ColumnsRoles)
explicit FileBrowserModel(QObject *parent = nullptr);
~FileBrowserModel() override;
......@@ -58,7 +48,8 @@ public Q_SLOTS:
void initialize(MusicListenersManager *manager, DatabaseInterface *database,
ElisaUtils::PlayListEntryType modelType, ElisaUtils::FilterType filter,
const QString &genre, const QString &artist, qulonglong databaseId);
const QString &genre, const QString &artist, qulonglong databaseId,
const QUrl &pathFilter);
};
......
......@@ -57,7 +57,7 @@ bool FileBrowserProxyModel::filterAcceptsRow(int source_row, const QModelIndex &
for (int column = 0, columnCount = sourceModel()->columnCount(source_parent); column < columnCount; ++column) {
auto currentIndex = sourceModel()->index(source_row, column, source_parent);
const auto &nameValue = sourceModel()->data(currentIndex, FileBrowserModel::NameRole).toString();
const auto &nameValue = sourceModel()->data(currentIndex, DataTypes::TitleRole).toString();
if (mFilterExpression.match(nameValue).hasMatch()) {
result = true;
......@@ -85,9 +85,8 @@ void FileBrowserProxyModel::genericEnqueueToPlayList(QModelIndex rootIndex,
auto allTrackUrls = DataTypes::EntryDataList{};
for (int rowIndex = 0, maxRowCount = rowCount(); rowIndex < maxRowCount; ++rowIndex) {
auto currentIndex = index(rowIndex, 0, rootIndex);
if (!data(currentIndex, FileBrowserModel::IsDirectoryRole).toBool()) {
allTrackUrls.push_back({{{DataTypes::ElementTypeRole, ElisaUtils::Track},
{DataTypes::ResourceRole, data(currentIndex, FileBrowserModel::FileUrlRole).toUrl()}}, {}, {}});
if (!data(currentIndex, DataTypes::IsDirectoryRole).toBool()) {
allTrackUrls.push_back({{}, {}, data(currentIndex, DataTypes::ResourceRole).toUrl()});
}
}
Q_EMIT entriesToEnqueue(allTrackUrls, enqueueMode, triggerPlay);
......
......@@ -63,6 +63,7 @@ RowLayout {
delegateDisplaySecondaryText: viewDelegateDisplaySecondaryText,
genreFilterText: genreNameFilter,
artistFilter: artistNameFilter,
pathFilter: targetPathFilter,
isSubPage: (browseStackView.depth >= 2),
haveTreeModel: isTreeModel,
stackView: browseStackView,
......@@ -85,6 +86,7 @@ RowLayout {
mainTitle: mainTitle,
secondaryTitle: secondaryTitle,
databaseId: databaseId,
pathFilter: targetPathFilter,
image: imageUrl,
modelType: dataType,
realModel: model,
......
......@@ -27,6 +27,7 @@ FocusScope {
property alias haveTreeModel: gridView.haveTreeModel
property string genreFilterText
property string artistFilter
property url pathFilter
property bool modelIsInitialized: false
focus: true
......@@ -58,7 +59,8 @@ FocusScope {
gridView.contentModel = proxyModel
realModel.initialize(elisa.musicManager, elisa.musicManager.viewDatabase,
modelType, filterType, genreFilterText, artistFilter, 0)
modelType, filterType, genreFilterText, artistFilter, 0,
pathFilter)
modelIsInitialized = true
}
......
......@@ -16,6 +16,7 @@ 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
......@@ -88,7 +89,8 @@ FocusScope {
}
realModel.initialize(elisa.musicManager, elisa.musicManager.viewDatabase,
modelType, filterType, mainTitle, secondaryTitle, databaseId)
modelType, filterType, mainTitle, secondaryTitle, databaseId,
pathFilter)
}
function goToBack() {
......
......@@ -54,6 +54,16 @@ public:
ViewManager::DelegateWithSecondaryText,
ViewManager::ViewShowRating,
ViewManager::IsFlatModel}},
{ElisaUtils::Container, {{},
QUrl{QStringLiteral("image://icon/folder")},
ViewManager::GridView,
ViewManager::FileBrowserModel,
ElisaUtils::FilterByPath,
ElisaUtils::FileName,
QUrl{QStringLiteral("image://icon/folder")},
ViewManager::DelegateWithoutSecondaryText,
ViewManager::ViewHideRating,
ViewManager::IsFlatModel}},
};
int mViewIndex = 0;
......@@ -148,6 +158,9 @@ void ViewManager::openChildView(const QString &innerMainTitle, const QString & i
case ElisaUtils::FilterByArtist:
nextViewParameters.mArtistNameFilter = innerMainTitle;
break;
case ElisaUtils::FilterByPath:
nextViewParameters.mPathFilter = QUrl::fromLocalFile(lastView.mPathFilter.toLocalFile() + QStringLiteral("/") + innerMainTitle);
break;
}
d->mNextViewParameters = nextViewParameters;
......@@ -201,14 +214,18 @@ void ViewManager::openViewFromData(const ViewParameters &viewParamaters)
switch (viewParamaters.mModelType)
{
case FileBrowserModel:
{
newModel = new ::FileBrowserModel;
proxyModel = new FileBrowserProxyModel;
auto *realProxyModel = new FileBrowserProxyModel;
proxyModel = realProxyModel;
break;
}
case GenericDataModel:
newModel = new DataModel;
proxyModel = new GridViewProxyModel;
break;
case UnknownModelType:
qCDebug(orgKdeElisaViews()) << "ViewManager::openViewFromData" << "unknown model type";
break;
}
......@@ -223,13 +240,13 @@ void ViewManager::openViewFromData(const ViewParameters &viewParamaters)
<< viewParamaters.mModelType << viewParamaters.mFallbackItemIcon
<< viewParamaters.mGenreNameFilter << viewParamaters.mArtistNameFilter
<< viewParamaters.mViewCanBeRated << viewParamaters.mShowSecondaryTextOnDelegates
<< viewParamaters.mIsTreeModel;
<< viewParamaters.mIsTreeModel << viewParamaters.mPathFilter;
Q_EMIT openGridView(viewParamaters.mFilterType, viewParamaters.mDepth,
viewParamaters.mMainTitle, viewParamaters.mSecondaryTitle, viewParamaters.mMainImage,
viewParamaters.mDataType, newModel, proxyModel, viewParamaters.mFallbackItemIcon,
viewParamaters.mGenreNameFilter, viewParamaters.mArtistNameFilter,
viewParamaters.mViewCanBeRated, viewParamaters.mShowSecondaryTextOnDelegates,
viewParamaters.mIsTreeModel);
viewParamaters.mIsTreeModel, viewParamaters.mPathFilter);
break;
case ViewPresentationType::ListView:
qCDebug(orgKdeElisaViews()) << "ViewManager::openViewFromData" << viewParamaters.mFilterType
......@@ -238,12 +255,12 @@ void ViewManager::openViewFromData(const ViewParameters &viewParamaters)
<< viewParamaters.mModelType << viewParamaters.mDataType
<< viewParamaters.mSortRole << viewParamaters.mSortOrder << viewParamaters.mAlbumCardinality
<< viewParamaters.mAlbumViewStyle << viewParamaters.mRadioSpecificStyle
<< viewParamaters.mIsTreeModel;
<< viewParamaters.mIsTreeModel << viewParamaters.mPathFilter;
Q_EMIT openListView(viewParamaters.mFilterType, viewParamaters.mDepth, viewParamaters.mMainTitle, viewParamaters.mSecondaryTitle,
viewParamaters.mDatabaseIdFilter, viewParamaters.mMainImage, viewParamaters.mDataType,
newModel, proxyModel, viewParamaters.mSortRole, viewParamaters.mSortOrder,
viewParamaters.mAlbumCardinality, viewParamaters.mAlbumViewStyle, viewParamaters.mRadioSpecificStyle,
viewParamaters.mIsTreeModel);
viewParamaters.mIsTreeModel, viewParamaters.mPathFilter);
break;
case ViewPresentationType::FileBrowserView:
qCDebug(orgKdeElisaViews()) << "ViewManager::openViewFromData" << viewParamaters.mViewPresentationType
......@@ -258,6 +275,7 @@ void ViewManager::openViewFromData(const ViewParameters &viewParamaters)
Q_EMIT switchContextView(viewParamaters.mDepth, viewParamaters.mMainTitle, viewParamaters.mMainImage);
break;
case UnknownViewPresentation:
qCDebug(orgKdeElisaViews()) << "ViewManager::openViewFromData" << "unknown view type";
break;
}
}
......@@ -268,10 +286,12 @@ void ViewManager::goBack()
Q_EMIT popOneView();
if (d->mViewParametersStack.size() > 2) {
if (d->mViewParametersStack.size() > 1) {
d->mViewParametersStack.pop_back();
d->mNextViewParameters = {};
}
qCDebug(orgKdeElisaViews()) << "ViewManager::goBack" << d->mViewParametersStack.size();
}
void ViewManager::setViewsData(ViewsListData *viewsData)
......
......@@ -111,7 +111,7 @@ Q_SIGNALS:
QAbstractProxyModel *associatedProxyModel, const QUrl &viewDefaultIcon, const QString &genreNameFilter,
const QString &artistNameFilter, ViewManager::ViewCanBeRated viewShowRating,
ViewManager::DelegateUseSecondaryText viewDelegateDisplaySecondaryText,
ViewManager::IsTreeModelType isTreeModel);
ViewManager::IsTreeModelType isTreeModel, const QUrl &targetPathFilter);
void openListView(ElisaUtils::FilterType filterType, int expectedDepth,
const QString &mainTitle, const QString &secondaryTitle, qulonglong databaseId,
......@@ -119,7 +119,7 @@ Q_SIGNALS:
QAbstractProxyModel *associatedProxyModel, const QVariant &sortRole,
Qt::SortOrder sortOrder, ViewManager::AlbumCardinality displaySingleAlbum,
ViewManager::AlbumViewStyle showDiscHeaders, ViewManager::RadioSpecificStyle radioCase,
ViewManager::IsTreeModelType isTreeModel);
ViewManager::IsTreeModelType isTreeModel, const QUrl &targetPathFilter);
void switchFilesBrowserView(int expectedDepth, const QString &mainTitle, const QUrl &imageUrl);
......
......@@ -9,6 +9,7 @@
#include <KI18n/KLocalizedString>
#include <QUrl>
#include <QStandardPaths>
class ViewsListDataPrivate
{
......@@ -83,15 +84,16 @@ public:
ViewManager::ViewHideRating,
ViewManager::IsFlatModel},
{{i18nc("Title of the file browser view", "Files")},
QUrl{QStringLiteral("image://icon/document-open-folder")},
QUrl{QStringLiteral("image://icon/folder")},
ViewManager::GridView,
ViewManager::FileBrowserModel,
ElisaUtils::NoFilter,
ElisaUtils::FileName,
QUrl{QStringLiteral("image://icon/view-media-genre")},
QUrl{QStringLiteral("image://icon/folder")},
ViewManager::DelegateWithoutSecondaryText,
ViewManager::ViewHideRating,
ViewManager::IsTreeModel
ViewManager::IsFlatModel,
QUrl::fromLocalFile(QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first())
},
{{i18nc("Title of the file radios browser view", "Radios")},
QUrl{QStringLiteral("image://icon/radio")},
......
......@@ -72,6 +72,32 @@ public:
{
}
ViewParameters(QString mainTitle,
QUrl mainImage,
ViewManager::ViewPresentationType viewPresentationType,
ViewManager::ModelType modelType,
ElisaUtils::FilterType filterType,