diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -344,8 +344,8 @@ ../src/musicartist.cpp ../src/musicalbum.cpp ../src/musicaudiotrack.cpp - ../src/allalbumsmodel.cpp - ../src/albummodel.cpp + ../src/models/allalbumsmodel.cpp + ../src/models/albummodel.cpp allalbumsmodeltest.cpp ) @@ -360,7 +360,7 @@ ../src/musicartist.cpp ../src/musicalbum.cpp ../src/musicaudiotrack.cpp - ../src/albummodel.cpp + ../src/models/albummodel.cpp albummodeltest.cpp ) @@ -375,7 +375,7 @@ ../src/musicartist.cpp ../src/musicalbum.cpp ../src/musicaudiotrack.cpp - ../src/allartistsmodel.cpp + ../src/models/allartistsmodel.cpp allartistsmodeltest.cpp ) @@ -390,7 +390,7 @@ ../src/musicartist.cpp ../src/musicalbum.cpp ../src/musicaudiotrack.cpp - ../src/alltracksmodel.cpp + ../src/models/alltracksmodel.cpp alltracksmodeltest.cpp ) diff --git a/autotests/albummodeltest.cpp b/autotests/albummodeltest.cpp --- a/autotests/albummodeltest.cpp +++ b/autotests/albummodeltest.cpp @@ -20,7 +20,7 @@ #include "musicalbum.h" #include "musicaudiotrack.h" #include "databaseinterface.h" -#include "albummodel.h" +#include "models/albummodel.h" #include #include diff --git a/autotests/allalbumsmodeltest.cpp b/autotests/allalbumsmodeltest.cpp --- a/autotests/allalbumsmodeltest.cpp +++ b/autotests/allalbumsmodeltest.cpp @@ -20,7 +20,7 @@ #include "musicalbum.h" #include "musicaudiotrack.h" #include "databaseinterface.h" -#include "allalbumsmodel.h" +#include "models/allalbumsmodel.h" #include #include diff --git a/autotests/allartistsmodeltest.cpp b/autotests/allartistsmodeltest.cpp --- a/autotests/allartistsmodeltest.cpp +++ b/autotests/allartistsmodeltest.cpp @@ -20,7 +20,7 @@ #include "musicalbum.h" #include "musicaudiotrack.h" #include "databaseinterface.h" -#include "allartistsmodel.h" +#include "models/allartistsmodel.h" #include #include diff --git a/autotests/alltracksmodeltest.cpp b/autotests/alltracksmodeltest.cpp --- a/autotests/alltracksmodeltest.cpp +++ b/autotests/alltracksmodeltest.cpp @@ -20,7 +20,7 @@ #include "musicalbum.h" #include "musicaudiotrack.h" #include "databaseinterface.h" -#include "alltracksmodel.h" +#include "models/alltracksmodel.h" #include #include diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,26 +9,32 @@ musicaudiotrack.cpp musicartist.cpp progressindicator.cpp - albummodel.cpp - allalbumsmodel.cpp - allartistsmodel.cpp databaseinterface.cpp musiclistenersmanager.cpp managemediaplayercontrol.cpp manageheaderbar.cpp manageaudioplayer.cpp - albumfilterproxymodel.cpp trackslistener.cpp elisaapplication.cpp audiowrapper.cpp - alltracksmodel.cpp notificationitem.cpp topnotificationmanager.cpp elisautils.cpp abstractfile/abstractfilelistener.cpp abstractfile/abstractfilelisting.cpp file/filelistener.cpp file/localfilelisting.cpp + models/albummodel.cpp + models/allalbumsmodel.cpp + models/allartistsmodel.cpp + models/alltracksmodel.cpp + models/abstractmediaproxymodel.cpp + models/allalbumsproxymodel.cpp + models/allartistsproxymodel.cpp + models/alltracksproxymodel.cpp + models/singleartistproxymodel.cpp + models/singlealbumproxymodel.cpp + qml/ElisaMainWindow.qml qml/Theme.qml @@ -53,9 +59,9 @@ qml/HeaderBar.qml qml/NavigationActionBar.qml - qml/FilterBar.qml qml/MediaPlayerControl.qml qml/ContextView.qml + qml/ViewSelector.qml qml/MediaPlayListView.qml qml/MediaAlbumView.qml @@ -65,8 +71,6 @@ qml/MediaTrackMetadataView.qml qml/GridBrowserView.qml qml/GridBrowserDelegate.qml - - qml/ViewSelector.qml ) if (KF5Baloo_FOUND) diff --git a/src/main.cpp b/src/main.cpp --- a/src/main.cpp +++ b/src/main.cpp @@ -43,15 +43,19 @@ #include "manageheaderbar.h" #include "manageaudioplayer.h" #include "musicstatistics.h" -#include "allalbumsmodel.h" -#include "albummodel.h" -#include "allartistsmodel.h" #include "musicaudiotrack.h" #include "musiclistenersmanager.h" -#include "albumfilterproxymodel.h" +#include "models/allalbumsmodel.h" +#include "models/albummodel.h" +#include "models/allartistsmodel.h" +#include "models/alltracksmodel.h" +#include "models/allalbumsproxymodel.h" +#include "models/alltracksproxymodel.h" +#include "models/allartistsproxymodel.h" +#include "models/singleartistproxymodel.h" +#include "models/singlealbumproxymodel.h" #include "elisaapplication.h" #include "audiowrapper.h" -#include "alltracksmodel.h" #include "notificationitem.h" #include "topnotificationmanager.h" #include "elisa_settings.h" @@ -150,8 +154,11 @@ qmlRegisterType("org.kde.elisa", 1, 0, "AlbumModel"); qmlRegisterType("org.kde.elisa", 1, 0, "AllTracksModel"); qmlRegisterType("org.kde.elisa", 1, 0, "MusicListenersManager"); - qmlRegisterType("org.kde.elisa", 1, 0, "SortFilterProxyModel"); - qmlRegisterType("org.kde.elisa", 1, 0, "AlbumFilterProxyModel"); + qmlRegisterType("org.kde.elisa", 1, 0, "AllAlbumsProxyModel"); + qmlRegisterType("org.kde.elisa", 1, 0, "AllArtistsProxyModel"); + qmlRegisterType("org.kde.elisa", 1, 0, "AllTracksProxyModel"); + qmlRegisterType("org.kde.elisa", 1, 0, "SingleAlbumProxyModel"); + qmlRegisterType("org.kde.elisa", 1, 0, "SingleArtistProxyModel"); qmlRegisterType("org.kde.elisa", 1, 0, "AudioWrapper"); qmlRegisterType("org.kde.elisa", 1, 0, "TopNotificationManager"); diff --git a/src/albumfilterproxymodel.h b/src/models/abstractmediaproxymodel.h rename from src/albumfilterproxymodel.h rename to src/models/abstractmediaproxymodel.h --- a/src/albumfilterproxymodel.h +++ b/src/models/abstractmediaproxymodel.h @@ -1,5 +1,6 @@ /* - * Copyright 2016 Matthieu Gallien + * Copyright 2016-2017 Matthieu Gallien + * Copyright 2017 Alexander Stippich * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -17,13 +18,17 @@ * Boston, MA 02110-1301, USA. */ -#ifndef ALBUMFILTERPROXYMODEL_H -#define ALBUMFILTERPROXYMODEL_H +#ifndef ABSTRACTMEDIAPROXYMODEL_H +#define ABSTRACTMEDIAPROXYMODEL_H #include #include -class AlbumFilterProxyModel : public QSortFilterProxyModel +#include "mediaplaylist.h" + +class MediaPlayList; + +class AbstractMediaProxyModel : public QSortFilterProxyModel { Q_OBJECT @@ -40,9 +45,9 @@ public: - explicit AlbumFilterProxyModel(QObject *parent = nullptr); + explicit AbstractMediaProxyModel(QObject *parent = nullptr); - ~AlbumFilterProxyModel() override; + ~AbstractMediaProxyModel() override; QString filterText() const; @@ -54,17 +59,17 @@ void setFilterRating(int filterRating); + virtual void enqueueToPlayList(MediaPlayList *playList) = 0; + Q_SIGNALS: void filterTextChanged(const QString &filterText); void filterRatingChanged(int filterRating); protected: - bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; - -private: + virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override = 0; QString mFilterText; @@ -74,4 +79,4 @@ }; -#endif // ALBUMFILTERPROXYMODEL_H +#endif // ABSTRACTMEDIAPROXYMODEL_H diff --git a/src/models/abstractmediaproxymodel.cpp b/src/models/abstractmediaproxymodel.cpp new file mode 100644 --- /dev/null +++ b/src/models/abstractmediaproxymodel.cpp @@ -0,0 +1,70 @@ +/* + * Copyright 2016-2017 Matthieu Gallien + * Copyright 2017 Alexander Stippich + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "abstractmediaproxymodel.h" + +AbstractMediaProxyModel::AbstractMediaProxyModel(QObject *parent) : QSortFilterProxyModel(parent), mFilterText() +{ + setFilterCaseSensitivity(Qt::CaseInsensitive); +} + +AbstractMediaProxyModel::~AbstractMediaProxyModel() += default; + +QString AbstractMediaProxyModel::filterText() const +{ + return mFilterText; +} + +int AbstractMediaProxyModel::filterRating() const +{ + return mFilterRating; +} + +void AbstractMediaProxyModel::setFilterText(const QString &filterText) +{ + if (mFilterText == filterText) + return; + + mFilterText = filterText; + + mFilterExpression.setPattern(mFilterText); + mFilterExpression.setPatternOptions(QRegularExpression::CaseInsensitiveOption); + mFilterExpression.optimize(); + + invalidate(); + + Q_EMIT filterTextChanged(mFilterText); +} + +void AbstractMediaProxyModel::setFilterRating(int filterRating) +{ + if (mFilterRating == filterRating) { + return; + } + + mFilterRating = filterRating; + + invalidate(); + + Q_EMIT filterRatingChanged(filterRating); +} + +#include "moc_abstractmediaproxymodel.cpp" diff --git a/src/albummodel.h b/src/models/albummodel.h rename from src/albummodel.h rename to src/models/albummodel.h diff --git a/src/albummodel.cpp b/src/models/albummodel.cpp rename from src/albummodel.cpp rename to src/models/albummodel.cpp diff --git a/src/allalbumsmodel.h b/src/models/allalbumsmodel.h rename from src/allalbumsmodel.h rename to src/models/allalbumsmodel.h diff --git a/src/allalbumsmodel.cpp b/src/models/allalbumsmodel.cpp rename from src/allalbumsmodel.cpp rename to src/models/allalbumsmodel.cpp diff --git a/src/models/allalbumsproxymodel.h b/src/models/allalbumsproxymodel.h new file mode 100644 --- /dev/null +++ b/src/models/allalbumsproxymodel.h @@ -0,0 +1,40 @@ +/* + * Copyright 2016-2017 Matthieu Gallien + * Copyright 2017 Alexander Stippich + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef ALLALBUMSPROXYMODEL_H +#define ALLALBUMSPROXYMODEL_H + +#include "abstractmediaproxymodel.h" + +class AllAlbumsProxyModel : public AbstractMediaProxyModel +{ + Q_OBJECT + +public Q_SLOTS: + + void enqueueToPlayList(MediaPlayList *playList) override; + +protected: + + bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; + +}; + +#endif // ALLALBUMSPROXYMODEL_H diff --git a/src/albumfilterproxymodel.cpp b/src/models/allalbumsproxymodel.cpp rename from src/albumfilterproxymodel.cpp rename to src/models/allalbumsproxymodel.cpp --- a/src/albumfilterproxymodel.cpp +++ b/src/models/allalbumsproxymodel.cpp @@ -1,5 +1,6 @@ /* - * Copyright 2016 Matthieu Gallien + * Copyright 2016-2017 Matthieu Gallien + * Copyright 2017 Alexander Stippich * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -17,59 +18,11 @@ * Boston, MA 02110-1301, USA. */ -#include "albumfilterproxymodel.h" +#include "allalbumsproxymodel.h" #include "allalbumsmodel.h" -#include "allartistsmodel.h" -AlbumFilterProxyModel::AlbumFilterProxyModel(QObject *parent) : QSortFilterProxyModel(parent), mFilterText() -{ - setFilterCaseSensitivity(Qt::CaseInsensitive); -} - -AlbumFilterProxyModel::~AlbumFilterProxyModel() -= default; - -QString AlbumFilterProxyModel::filterText() const -{ - return mFilterText; -} - -int AlbumFilterProxyModel::filterRating() const -{ - return mFilterRating; -} - -void AlbumFilterProxyModel::setFilterText(const QString &filterText) -{ - if (mFilterText == filterText) - return; - - mFilterText = filterText; - - mFilterExpression.setPattern(mFilterText); - mFilterExpression.setPatternOptions(QRegularExpression::CaseInsensitiveOption); - mFilterExpression.optimize(); - - invalidate(); - - Q_EMIT filterTextChanged(mFilterText); -} - -void AlbumFilterProxyModel::setFilterRating(int filterRating) -{ - if (mFilterRating == filterRating) { - return; - } - - mFilterRating = filterRating; - - invalidate(); - - Q_EMIT filterRatingChanged(filterRating); -} - -bool AlbumFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const +bool AllAlbumsProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { bool result = false; @@ -115,5 +68,15 @@ return result; } +void AllAlbumsProxyModel::enqueueToPlayList(MediaPlayList *playList) +{ + for (int columnIndex = 0, columnCount = this->columnCount(); columnIndex < columnCount; ++columnIndex) { + for (int rowIndex = 0, rowCount = this->rowCount(); rowIndex < rowCount; ++rowIndex) { + auto currentIndex = this->index(rowIndex, columnIndex); + playList->enqueue(this->data(currentIndex,AllAlbumsModel::AlbumDataRole).value()); + } + } + +} -#include "moc_albumfilterproxymodel.cpp" +#include "moc_allalbumsproxymodel.cpp" diff --git a/src/allartistsmodel.h b/src/models/allartistsmodel.h rename from src/allartistsmodel.h rename to src/models/allartistsmodel.h --- a/src/allartistsmodel.h +++ b/src/models/allartistsmodel.h @@ -79,8 +79,6 @@ AllAlbumsModel* allAlbums() const; - Q_INVOKABLE QAbstractItemModel* itemModelForName(const QString &name) const; - Q_SIGNALS: void allAlbumsChanged(); diff --git a/src/allartistsmodel.cpp b/src/models/allartistsmodel.cpp rename from src/allartistsmodel.cpp rename to src/models/allartistsmodel.cpp --- a/src/allartistsmodel.cpp +++ b/src/models/allartistsmodel.cpp @@ -26,7 +26,6 @@ #include #include #include -#include class AllArtistsModelPrivate { @@ -151,15 +150,8 @@ result = QVariant::fromValue(d->mAllArtists[index.row()]); break; case ColumnsRoles::ChildModelRole: - { - auto newModel = new QSortFilterProxyModel; - newModel->setSourceModel(d->mAllAlbumsModel); - newModel->setFilterRole(AllAlbumsModel::AllArtistsRole); - newModel->setFilterRegExp(QRegExp(QStringLiteral(".*") + d->mAllArtists[index.row()].name() + QStringLiteral(".*"), - Qt::CaseInsensitive)); - result = QVariant::fromValue(newModel); + result = d->mAllArtists[index.row()].name(); break; - } case ColumnsRoles::IsTracksContainerRole: result = false; break; @@ -206,17 +198,6 @@ return d->mAllAlbumsModel; } -QAbstractItemModel *AllArtistsModel::itemModelForName(const QString &name) const -{ - auto newModel = new QSortFilterProxyModel; - newModel->setSourceModel(d->mAllAlbumsModel); - newModel->setFilterRole(AllAlbumsModel::AllArtistsRole); - newModel->setFilterRegExp(QRegExp(QStringLiteral(".*") + name + QStringLiteral(".*"), - Qt::CaseInsensitive)); - - return newModel; -} - void AllArtistsModel::artistAdded(const MusicArtist &newArtist) { if (newArtist.isValid()) { diff --git a/src/models/allartistsproxymodel.h b/src/models/allartistsproxymodel.h new file mode 100644 --- /dev/null +++ b/src/models/allartistsproxymodel.h @@ -0,0 +1,38 @@ +/* + * Copyright 2017 Alexander Stippich + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef ALLARTISTSPROXYMODEL_H +#define ALLARTISTSPROXYMODEL_H + +#include "abstractmediaproxymodel.h" + +class AllArtistsProxyModel : public AbstractMediaProxyModel +{ + Q_OBJECT + +public Q_SLOTS: + + void enqueueToPlayList(MediaPlayList *playList) override; + +protected: + + bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; + +}; +#endif // ALLARTISTSPROXYMODEL_H diff --git a/src/models/allartistsproxymodel.cpp b/src/models/allartistsproxymodel.cpp new file mode 100644 --- /dev/null +++ b/src/models/allartistsproxymodel.cpp @@ -0,0 +1,61 @@ +/* + * Copyright 2017 Alexander Stippich + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "allartistsproxymodel.h" + +#include "allartistsmodel.h" + +bool AllArtistsProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const +{ + bool result = false; + + for (int column = 0, columnCount = sourceModel()->columnCount(source_parent); column < columnCount; ++column) { + auto currentIndex = sourceModel()->index(source_row, column, source_parent); + + const auto &artistValue = sourceModel()->data(currentIndex, AllArtistsModel::NameRole).toString(); + + if (mFilterExpression.match(artistValue).hasMatch()) { + result = true; + continue; + } + + if (result) { + continue; + } + + if (!result) { + break; + } + } + + return result; +} + +void AllArtistsProxyModel::enqueueToPlayList(MediaPlayList *playList) +{ + for (int columnIndex = 0, columnCount = this->columnCount(); columnIndex < columnCount; ++columnIndex) { + for (int rowIndex = 0, rowCount = this->rowCount(); rowIndex < rowCount; ++rowIndex) { + auto currentIndex = this->index(rowIndex, columnIndex); + playList->enqueue(this->data(currentIndex,AllArtistsModel::NameRole).toString()); + } + } +} + + +#include "moc_allartistsproxymodel.cpp" diff --git a/src/alltracksmodel.h b/src/models/alltracksmodel.h rename from src/alltracksmodel.h rename to src/models/alltracksmodel.h diff --git a/src/alltracksmodel.cpp b/src/models/alltracksmodel.cpp rename from src/alltracksmodel.cpp rename to src/models/alltracksmodel.cpp diff --git a/src/models/alltracksproxymodel.h b/src/models/alltracksproxymodel.h new file mode 100644 --- /dev/null +++ b/src/models/alltracksproxymodel.h @@ -0,0 +1,39 @@ +/* + * Copyright 2017 Alexander Stippich + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef ALLTRACKSPROXYMODEL_H +#define ALLTRACKSPROXYMODEL_H + +#include "abstractmediaproxymodel.h" + +class AllTracksProxyModel : public AbstractMediaProxyModel +{ + Q_OBJECT + +public Q_SLOTS: + + void enqueueToPlayList(MediaPlayList *playList) override; + +protected: + + bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; + +}; + +#endif // ALLTRACKSPROXYMODEL_H diff --git a/src/models/alltracksproxymodel.cpp b/src/models/alltracksproxymodel.cpp new file mode 100644 --- /dev/null +++ b/src/models/alltracksproxymodel.cpp @@ -0,0 +1,71 @@ +/* + * Copyright 2017 Alexander Stippich + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "alltracksproxymodel.h" + +#include "alltracksmodel.h" + +bool AllTracksProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const +{ + bool result = false; + + for (int column = 0, columnCount = sourceModel()->columnCount(source_parent); column < columnCount; ++column) { + auto currentIndex = sourceModel()->index(source_row, column, source_parent); + + const auto &titleValue = sourceModel()->data(currentIndex, AllTracksModel::TitleRole).toString(); + const auto &artistValue = sourceModel()->data(currentIndex, AllTracksModel::ArtistRole).toString(); + const auto maximumRatingValue = sourceModel()->data(currentIndex, AllTracksModel::RatingRole).toInt(); + + if (maximumRatingValue < mFilterRating) { + result = false; + continue; + } + + if (mFilterExpression.match(titleValue).hasMatch()) { + result = true; + continue; + } + + if (mFilterExpression.match(artistValue).hasMatch()) { + result = true; + continue; + } + + if (result) { + continue; + } + + if (!result) { + break; + } + } + + return result; +} + +void AllTracksProxyModel::enqueueToPlayList(MediaPlayList *playList) +{ + for (int columnIndex = 0, columnCount = this->columnCount(); columnIndex < columnCount; ++columnIndex) { + for (int rowIndex = 0, rowCount = this->rowCount(); rowIndex < rowCount; ++rowIndex) { + auto currentIndex = this->index(rowIndex, columnIndex); + playList->enqueue(this->data(currentIndex,AllTracksModel::DatabaseIdRole).toULongLong()); + } + } +} +#include "moc_alltracksproxymodel.cpp" diff --git a/src/models/singlealbumproxymodel.h b/src/models/singlealbumproxymodel.h new file mode 100644 --- /dev/null +++ b/src/models/singlealbumproxymodel.h @@ -0,0 +1,39 @@ +/* + * Copyright 2017 Alexander Stippich + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef SINGELALBUMPROXYMODEL_H +#define SINGELALBUMPROXYMODEL_H + +#include "abstractmediaproxymodel.h" + +class SingleAlbumProxyModel : public AbstractMediaProxyModel +{ + Q_OBJECT + +public Q_SLOTS: + + void enqueueToPlayList(MediaPlayList *playList) override; + +protected: + + bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; + +}; + +#endif // SINGELALBUMPROXYMODEL_H diff --git a/src/models/singlealbumproxymodel.cpp b/src/models/singlealbumproxymodel.cpp new file mode 100644 --- /dev/null +++ b/src/models/singlealbumproxymodel.cpp @@ -0,0 +1,66 @@ +/* + * Copyright 2017 Alexander Stippich + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "singlealbumproxymodel.h" + +#include "albummodel.h" + +bool SingleAlbumProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const +{ + bool result = false; + + for (int column = 0, columnCount = sourceModel()->columnCount(source_parent); column < columnCount; ++column) { + auto currentIndex = sourceModel()->index(source_row, column, source_parent); + + const auto &titleValue = sourceModel()->data(currentIndex, AlbumModel::TitleRole).toString(); + const auto maximumRatingValue = sourceModel()->data(currentIndex, AlbumModel::RatingRole).toInt(); + + if (maximumRatingValue < mFilterRating) { + result = false; + continue; + } + + if (mFilterExpression.match(titleValue).hasMatch()) { + result = true; + continue; + } + + if (result) { + continue; + } + + if (!result) { + break; + } + } + + return result; +} + +void SingleAlbumProxyModel::enqueueToPlayList(MediaPlayList *playList) +{ + for (int columnIndex = 0, columnCount = this->columnCount(); columnIndex < columnCount; ++columnIndex) { + for (int rowIndex = 0, rowCount = this->rowCount(); rowIndex < rowCount; ++rowIndex) { + auto currentIndex = this->index(rowIndex, columnIndex); + playList->enqueue(this->data(currentIndex,AlbumModel::DatabaseIdRole).toULongLong()); + } + } +} + +#include "moc_singlealbumproxymodel.cpp" diff --git a/src/models/singleartistproxymodel.h b/src/models/singleartistproxymodel.h new file mode 100644 --- /dev/null +++ b/src/models/singleartistproxymodel.h @@ -0,0 +1,58 @@ +/* + * Copyright 2016-2017 Matthieu Gallien + * Copyright 2017 Alexander Stippich + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef SINGLEARTISTPROXYMODEL_H +#define SINGLEARTISTPROXYMODEL_H + +#include "abstractmediaproxymodel.h" + +class SingleArtistProxyModel : public AbstractMediaProxyModel +{ + Q_OBJECT + + Q_PROPERTY(QString artistFilter + READ artistFilter + WRITE setArtistFilterText + NOTIFY artistFilterTextChanged) + +public: + QString artistFilter() const; + +public Q_SLOTS: + + void enqueueToPlayList(MediaPlayList *playList) override; + + void setArtistFilterText(const QString &filterText); + +Q_SIGNALS: + + void artistFilterTextChanged(const QString &filterText); + +protected: + + bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; + + QString mArtistFilter; + + QRegularExpression mArtistExpression; + +}; + +#endif // SINGLEARTISTPROXYMODEL_H diff --git a/src/albumfilterproxymodel.cpp b/src/models/singleartistproxymodel.cpp rename from src/albumfilterproxymodel.cpp rename to src/models/singleartistproxymodel.cpp --- a/src/albumfilterproxymodel.cpp +++ b/src/models/singleartistproxymodel.cpp @@ -1,5 +1,6 @@ /* - * Copyright 2016 Matthieu Gallien + * Copyright 2016-2017 Matthieu Gallien + * Copyright 2017 Alexander Stippich * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -17,90 +18,54 @@ * Boston, MA 02110-1301, USA. */ -#include "albumfilterproxymodel.h" +#include "singleartistproxymodel.h" #include "allalbumsmodel.h" -#include "allartistsmodel.h" -AlbumFilterProxyModel::AlbumFilterProxyModel(QObject *parent) : QSortFilterProxyModel(parent), mFilterText() +QString SingleArtistProxyModel::artistFilter() const { - setFilterCaseSensitivity(Qt::CaseInsensitive); + return mArtistFilter; } -AlbumFilterProxyModel::~AlbumFilterProxyModel() -= default; -QString AlbumFilterProxyModel::filterText() const +void SingleArtistProxyModel::setArtistFilterText(const QString &filterText) { - return mFilterText; -} - -int AlbumFilterProxyModel::filterRating() const -{ - return mFilterRating; -} - -void AlbumFilterProxyModel::setFilterText(const QString &filterText) -{ - if (mFilterText == filterText) + if (mArtistFilter == filterText) return; - mFilterText = filterText; + mArtistFilter = filterText; - mFilterExpression.setPattern(mFilterText); - mFilterExpression.setPatternOptions(QRegularExpression::CaseInsensitiveOption); - mFilterExpression.optimize(); + mArtistExpression.setPattern(QStringLiteral(".*") + mArtistFilter + QStringLiteral(".*")); + mArtistExpression.setPatternOptions(QRegularExpression::CaseInsensitiveOption); + mArtistExpression.optimize(); invalidate(); - Q_EMIT filterTextChanged(mFilterText); + Q_EMIT artistFilterTextChanged(mArtistFilter); } -void AlbumFilterProxyModel::setFilterRating(int filterRating) -{ - if (mFilterRating == filterRating) { - return; - } - - mFilterRating = filterRating; - - invalidate(); - - Q_EMIT filterRatingChanged(filterRating); -} - -bool AlbumFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const +bool SingleArtistProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { bool result = false; for (int column = 0, columnCount = sourceModel()->columnCount(source_parent); column < columnCount; ++column) { auto currentIndex = sourceModel()->index(source_row, column, source_parent); const auto &titleValue = sourceModel()->data(currentIndex, AllAlbumsModel::TitleRole).toString(); - const auto &artistValue = sourceModel()->data(currentIndex, AllAlbumsModel::ArtistRole).toString(); - const auto &allArtistsValue = sourceModel()->data(currentIndex, AllAlbumsModel::AllArtistsRole).toStringList(); + const auto &artistValue = sourceModel()->data(currentIndex, AllAlbumsModel::AllArtistsRole).toString(); const auto maximumRatingValue = sourceModel()->data(currentIndex, AllAlbumsModel::HighestTrackRating).toInt(); if (maximumRatingValue < mFilterRating) { result = false; continue; } - if (mFilterExpression.match(titleValue).hasMatch()) { - result = true; - continue; - } - - if (mFilterExpression.match(artistValue).hasMatch()) { - result = true; - continue; - } - - for (const auto &oneArtist : allArtistsValue) { - if (mFilterExpression.match(oneArtist).hasMatch()) { + if (mArtistExpression.match(artistValue).hasMatch()) { + if (mFilterExpression.match(titleValue).hasMatch()) { result = true; - break; + continue; } + } if (result) { @@ -115,5 +80,15 @@ return result; } +void SingleArtistProxyModel::enqueueToPlayList(MediaPlayList *playList) +{ + for (int columnIndex = 0, columnCount = this->columnCount(); columnIndex < columnCount; ++columnIndex) { + for (int rowIndex = 0, rowCount = this->rowCount(); rowIndex < rowCount; ++rowIndex) { + auto currentIndex = this->index(rowIndex, columnIndex); + playList->enqueue(this->data(currentIndex,AllAlbumsModel::AlbumDataRole).value()); + } + } + +} -#include "moc_albumfilterproxymodel.cpp" +#include "moc_singleartistproxymodel.cpp" diff --git a/src/qml/ElisaMainWindow.qml b/src/qml/ElisaMainWindow.qml --- a/src/qml/ElisaMainWindow.qml +++ b/src/qml/ElisaMainWindow.qml @@ -601,14 +601,16 @@ firstPage: GridBrowserView { id: allAlbumsView - focus: true + tempMediaPlayList: playListModelItem + tempMediaControl: manageAudioPlayer - isFirstPage: true + focus: true - model: AlbumFilterProxyModel { + model: AllAlbumsProxyModel { sourceModel: allAlbumsModel } + image: elisaTheme.albumIcon mainTitle: i18nc("Title of the view of all albums", "Albums") onEnqueue: playListModelItem.enqueue(data) @@ -646,15 +648,17 @@ firstPage: GridBrowserView { id: allArtistsView focus: true + tempMediaPlayList: playListModelItem + tempMediaControl: manageAudioPlayer - isFirstPage: true showRating: false delegateDisplaySecondaryText: false - model: AlbumFilterProxyModel { + model: AllArtistsProxyModel { sourceModel: allArtistsModel } + image: elisaTheme.artistIcon mainTitle: i18nc("Title of the view of all artists", "Artists") onEnqueue: playListModelItem.enqueue(data) @@ -664,12 +668,13 @@ } onOpen: { localArtists.stackView.push(innerAlbumView, { - model: innerModel, + model: artistAlbumProxyModel, mainTitle: innerMainTitle, secondaryTitle: innerSecondaryTitle, image: innerImage, stackView: localArtists.stackView }) + artistAlbumProxyModel.setArtistFilterText(innerModel) } onGoBack: localArtists.stackView.pop() } @@ -691,9 +696,11 @@ firstPage: MediaAllTracksView { focus: true - + tempMediaPlayList: playListModelItem + tempMediaControl: manageAudioPlayer stackView: localTracks.stackView - model: AlbumFilterProxyModel { + + model: AllTracksProxyModel { sourceModel: allTracksModel } @@ -1016,17 +1023,26 @@ } } + SingleArtistProxyModel { + id: artistAlbumProxyModel + sourceModel: allAlbumsModel + } + Component { id: innerAlbumView GridBrowserView { property var stackView + tempMediaPlayList: playListModelItem + tempMediaControl: manageAudioPlayer + isSubPage: true onEnqueue: playListModelItem.enqueue(data) onReplaceAndPlay: { playListModelItem.clearAndEnqueue(data) manageAudioPlayer.ensurePlay() } + onOpen: { localArtists.stackView.push(albumView, { stackView: localArtists.stackView, @@ -1045,6 +1061,8 @@ MediaAlbumView { property var stackView + tempMediaPlayList: playListModelItem + tempMediaControl: manageAudioPlayer onEnqueue: playListModelItem.enqueue(data) @@ -1066,8 +1084,7 @@ localArtists.stackView.pop() } } - - allArtistsView.open(allArtistsModel.itemModelForName(name), name, '', elisaTheme.defaultArtistImage, '') + allArtistsView.open(name, name, '', elisaTheme.defaultArtistImage, '') } onGoBack: stackView.pop() diff --git a/src/qml/FilterBar.qml b/src/qml/FilterBar.qml deleted file mode 100644 --- a/src/qml/FilterBar.qml +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright 2016-2017 Matthieu Gallien - * Copyright 2017 Alexander Stippich - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - - -import QtQuick 2.7 -import QtQuick.Controls 1.2 -import QtQuick.Layouts 1.2 - -FocusScope { - id: filterBar - - property string labelText - property bool showRating: true - property alias filterText: filterTextInput.text - property alias filterRating: ratingFilter.starRating - - ColumnLayout { - anchors.fill: parent - spacing: 0 - - TextMetrics { - id: titleHeight - text: viewTitleHeight.text - font - { - pixelSize: viewTitleHeight.font.pixelSize - bold: viewTitleHeight.font.bold - } - } - - LabelWithToolTip { - id: viewTitleHeight - text: labelText - - color: myPalette.text - font.pixelSize: elisaTheme.defaultFontPixelSize * 2 - - Layout.preferredHeight: implicitHeight - Layout.leftMargin: elisaTheme.layoutHorizontalMargin - Layout.rightMargin: elisaTheme.layoutHorizontalMargin - Layout.topMargin: elisaTheme.layoutVerticalMargin - Layout.bottomMargin: elisaTheme.layoutVerticalMargin - } - - Item { - Layout.fillHeight: true - } - - RowLayout { - id: filterRow - - spacing: 0 - - Layout.fillWidth: true - Layout.bottomMargin: elisaTheme.layoutVerticalMargin - Layout.leftMargin: !LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin : 0 - Layout.rightMargin: LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin : 0 - - LabelWithToolTip { - text: i18nc("before the TextField input of the filter", "Filter: ") - - font.bold: true - - Layout.bottomMargin: 0 - - color: myPalette.text - } - - TextField { - id: filterTextInput - - horizontalAlignment: TextInput.AlignLeft - - placeholderText: i18nc("Placeholder text in the filter text box", "Filter") - - Layout.bottomMargin: 0 - Layout.preferredWidth: filterBar.width / 2 - - Image { - anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.right: parent.right - anchors.margins: elisaTheme.filterClearButtonMargin - id: clearText - fillMode: Image.PreserveAspectFit - smooth: true - visible: parent.text - source: Qt.resolvedUrl(elisaTheme.clearIcon) - height: parent.height - width: parent.height - sourceSize.width: parent.height - sourceSize.height: parent.height - mirror: LayoutMirroring.enabled - - MouseArea { - id: clear - anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter } - height: parent.parent.height - width: parent.parent.height - onClicked: { - parent.parent.text = "" - parent.parent.forceActiveFocus() - } - } - } - } - - LabelWithToolTip { - text: i18nc("before the Rating widget input of the filter", "Rating: ") - - visible: showRating - - font.bold: true - - color: myPalette.text - - Layout.bottomMargin: 0 - Layout.leftMargin: !LayoutMirroring.enabled ? (elisaTheme.layoutHorizontalMargin * 2) : 0 - Layout.rightMargin: LayoutMirroring.enabled ? (elisaTheme.layoutHorizontalMargin * 2) : 0 - } - - RatingStar { - id: ratingFilter - - visible: showRating - - readOnly: false - - starSize: elisaTheme.ratingStarSize - - Layout.bottomMargin: 0 - } - } - } -} diff --git a/src/qml/GridBrowserView.qml b/src/qml/GridBrowserView.qml --- a/src/qml/GridBrowserView.qml +++ b/src/qml/GridBrowserView.qml @@ -30,14 +30,17 @@ FocusScope { id: gridView - property bool isFirstPage: false + property bool isSubPage: false property string mainTitle property string secondaryTitle property url image property alias model: proxyModel.model property bool showRating: true property bool delegateDisplaySecondaryText: true + property var tempMediaPlayList + property var tempMediaControl + signal enqueue(var data) signal replaceAndPlay(var data) signal open(var innerModel, var innerMainTitle, var innerSecondaryTitle, var innerImage, var databaseId) @@ -56,63 +59,37 @@ anchors.fill: parent spacing: 0 - Loader { - sourceComponent: FilterBar { - id: filterBar - - labelText: mainTitle - showRating: gridView.showRating - - anchors.fill: parent - - Binding { - target: model - property: 'filterText' - value: filterBar.filterText - when: isFirstPage - } - - Binding { - target: model - property: 'filterRating' - value: filterBar.filterRating - when: isFirstPage - } - } + NavigationActionBar { + id: navigationBar + enableGoBack: isSubPage + mainTitle: gridView.mainTitle + secondaryTitle: gridView.secondaryTitle + image: gridView.image height: elisaTheme.navigationBarHeight Layout.preferredHeight: height Layout.minimumHeight: height Layout.maximumHeight: height Layout.fillWidth: true - - active: isFirstPage - visible: isFirstPage - } - - Loader { - sourceComponent: NavigationActionBar { - id: navigationBar - - mainTitle: gridView.mainTitle - secondaryTitle: gridView.secondaryTitle - image: gridView.image - - anchors.fill: parent - - onEnqueue: gridView.enqueue(mainTitle) - onReplaceAndPlay: gridView.replaceAndPlay(mainTitle) - onGoBack: gridView.goBack() + onEnqueue: proxyModel.model.enqueueToPlayList(tempMediaPlayList) + onReplaceAndPlay: { + tempMediaPlayList.clearPlayList() + proxyModel.model.enqueueToPlayList(tempMediaPlayList) + tempMediaControl.ensurePlay() } + onGoBack: gridView.goBack() - height: elisaTheme.navigationBarHeight - Layout.preferredHeight: height - Layout.minimumHeight: height - Layout.maximumHeight: height - Layout.fillWidth: true + Binding { + target: model + property: 'filterText' + value: navigationBar.filterText + } - active: !isFirstPage - visible: !isFirstPage + Binding { + target: model + property: 'filterRating' + value: navigationBar.filterRating + } } Rectangle { diff --git a/src/qml/MediaAlbumView.qml b/src/qml/MediaAlbumView.qml --- a/src/qml/MediaAlbumView.qml +++ b/src/qml/MediaAlbumView.qml @@ -32,7 +32,10 @@ property var albumArtUrl property bool isSingleDiscAlbum property var albumId - property alias albumModel: contentDirectoryView.model + property alias albumModel: proxyModel.sourceModel + + property var tempMediaPlayList + property var tempMediaControl signal showArtist(var name) signal enqueue(var data) @@ -48,6 +51,10 @@ id: elisaTheme } + SingleAlbumProxyModel { + id: proxyModel + } + function removeAlbum(removedAlbum) { albumModel.albumRemoved(removedAlbum) } @@ -62,7 +69,7 @@ spacing: 0 NavigationActionBar { - id: navBar + id: navigationBar height: elisaTheme.navigationBarHeight @@ -76,10 +83,23 @@ image: (topListing.albumArtUrl ? topListing.albumArtUrl : elisaTheme.defaultAlbumImage) allowArtistNavigation: true - onEnqueue: topListing.enqueue(albumModel.albumData) - + onEnqueue: proxyModel.enqueueToPlayList(tempMediaPlayList) onReplaceAndPlay: { - topListing.replaceAndPlay(albumModel.albumData) + tempMediaPlayList.clearPlayList() + proxyModel.enqueueToPlayList(tempMediaPlayList) + tempMediaControl.ensurePlay() + } + + Binding { + target: proxyModel + property: 'filterText' + value: navigationBar.filterText + } + + Binding { + target: proxyModel + property: 'filterRating' + value: navigationBar.filterRating } onGoBack: topListing.goBack() @@ -96,6 +116,7 @@ ListView { id: contentDirectoryView + model: proxyModel focus: true diff --git a/src/qml/MediaAllTracksView.qml b/src/qml/MediaAllTracksView.qml --- a/src/qml/MediaAllTracksView.qml +++ b/src/qml/MediaAllTracksView.qml @@ -33,6 +33,9 @@ property var stackView property alias model: proxyModel.model + property var tempMediaPlayList + property var tempMediaControl + signal enqueue(var data) signal replaceAndPlay(var data) @@ -49,9 +52,11 @@ anchors.fill: parent spacing: 0 - FilterBar { - id: filterBar - labelText: i18nc("Title of the view of all tracks", "Tracks") + NavigationActionBar { + id: navigationBar + mainTitle: i18nc("Title of the view of all tracks", "Tracks") + image: elisaTheme.tracksIcon + enableGoBack: false height: elisaTheme.navigationBarHeight Layout.preferredHeight: height @@ -62,13 +67,19 @@ Binding { target: model property: 'filterText' - value: filterBar.filterText + value: navigationBar.filterText } Binding { target: model property: 'filterRating' - value: filterBar.filterRating + value: navigationBar.filterRating + } + onEnqueue: proxyModel.model.enqueueToPlayList(tempMediaPlayList) + onReplaceAndPlay: { + tempMediaPlayList.clearPlayList() + proxyModel.model.enqueueToPlayList(tempMediaPlayList) + tempMediaControl.ensurePlay() } } diff --git a/src/qml/NavigationActionBar.qml b/src/qml/NavigationActionBar.qml --- a/src/qml/NavigationActionBar.qml +++ b/src/qml/NavigationActionBar.qml @@ -23,14 +23,20 @@ import QtQuick.Controls 1.4 import QtQuick.Window 2.0 -Item { +FocusScope { id: navigationBar property string mainTitle property string secondaryTitle property url image property bool allowArtistNavigation: false + property string labelText + property bool showRating: true + property alias filterText: filterTextInput.text + property alias filterRating: ratingFilter.starRating + property bool enableGoBack: true + signal enqueue(); signal replaceAndPlay(); signal goBack(); @@ -43,149 +49,279 @@ onTriggered: goBack() } - RowLayout { + Action { + id: showFilterAction + text: navigationBar.state === "" ? i18nc("Show filters in the navigation bar", "Show Filter") : i18nc("Hide filters in the navigation bar", "Hide Filter") + iconName: navigationBar.state === "" ? "go-down-search" : "go-up-search" + onTriggered: navigationBar.state === "" ? navigationBar.state = 'expanded' : navigationBar.state = "" + } + + ColumnLayout { anchors.fill: parent anchors.margins: { top: elisaTheme.layoutVerticalMargin bottom: elisaTheme.layoutVerticalMargin } - spacing: 0 + RowLayout { - ToolButton { - action: goPreviousAction - Layout.leftMargin: !LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin : 0 - Layout.rightMargin: LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin : 0 - } + ToolButton { + action: goPreviousAction + Layout.leftMargin: !LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin : 0 + Layout.rightMargin: LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin : 0 + visible: enableGoBack + } - Image { - id: mainIcon - source: image + Image { + id: mainIcon + source: image - asynchronous: true + asynchronous: true - sourceSize.height: elisaTheme.coverImageSize / 2 - sourceSize.width: elisaTheme.coverImageSize / 2 + sourceSize.height: elisaTheme.coverImageSize / 2 + sourceSize.width: elisaTheme.coverImageSize / 2 - fillMode: Image.PreserveAspectFit + fillMode: Image.PreserveAspectFit - Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft + Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft - Layout.preferredHeight: elisaTheme.coverImageSize / 2 - Layout.minimumHeight: elisaTheme.coverImageSize / 2 - Layout.maximumHeight: elisaTheme.coverImageSize / 2 - Layout.preferredWidth: elisaTheme.coverImageSize / 2 - Layout.minimumWidth: elisaTheme.coverImageSize / 2 - Layout.maximumWidth: elisaTheme.coverImageSize / 2 - Layout.leftMargin: !LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin : 0 - Layout.rightMargin: LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin : 0 - } + Layout.preferredHeight: elisaTheme.coverImageSize / 2 + Layout.minimumHeight: elisaTheme.coverImageSize / 2 + Layout.maximumHeight: elisaTheme.coverImageSize / 2 + Layout.preferredWidth: elisaTheme.coverImageSize / 2 + Layout.minimumWidth: elisaTheme.coverImageSize / 2 + Layout.maximumWidth: elisaTheme.coverImageSize / 2 + Layout.leftMargin: !LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin : 0 + Layout.rightMargin: LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin : 0 + } - ColumnLayout { - Layout.fillHeight: true + ColumnLayout { + Layout.fillHeight: true - spacing: 0 + spacing: 0 - Layout.fillWidth: true - Layout.leftMargin: !LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin : 0 - Layout.rightMargin: LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin : 0 + Layout.fillWidth: true + Layout.leftMargin: !LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin : 0 + Layout.rightMargin: LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin : 0 + + TextMetrics { + id: albumTextSize + text: albumLabel.text + font.pixelSize: albumLabel.font.pixelSize + font.bold: albumLabel.font.bold + } - TextMetrics { - id: albumTextSize - text: albumLabel.text - font.pixelSize: albumLabel.font.pixelSize - font.bold: albumLabel.font.bold - } + LabelWithToolTip { + id: albumLabel - LabelWithToolTip { - id: albumLabel + text: secondaryTitle - text: secondaryTitle + Layout.fillWidth: true + Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter - Layout.fillWidth: true - Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter + elide: Text.ElideRight - elide: Text.ElideRight + color: myPalette.text - color: myPalette.text + font { + pixelSize: elisaTheme.defaultFontPixelSize * 2 + } - font { - pixelSize: elisaTheme.defaultFontPixelSize * 1.5 + visible: secondaryTitle !== "" } - visible: secondaryTitle !== "" - } + TextMetrics { + id: authorTextSize + text: authorLabel.text + font.pixelSize: authorLabel.font.pixelSize + font.bold: authorLabel.font.bold + } - TextMetrics { - id: authorTextSize - text: authorLabel.text - font.pixelSize: authorLabel.font.pixelSize - font.bold: authorLabel.font.bold - } + LabelWithToolTip { + id: authorLabel - LabelWithToolTip { - id: authorLabel + text: mainTitle - text: mainTitle + color: myPalette.text - color: myPalette.text + Layout.fillWidth: true + Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter - Layout.fillWidth: true - Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter + font { + pixelSize: (secondaryTitle !== "" ? elisaTheme.defaultFontPixelSize : elisaTheme.defaultFontPixelSize * 2) + } - font { - pixelSize: (secondaryTitle !== "" ? elisaTheme.defaultFontPixelSize : elisaTheme.defaultFontPixelSize * 1.5) + elide: Text.ElideRight } - elide: Text.ElideRight - } + Item { + id: emptyBottomFiller - Item { - id: emptyBottomFiller + Layout.fillWidth: true + Layout.fillHeight: true + } - Layout.fillWidth: true - Layout.fillHeight: true - } + RowLayout { + Layout.fillWidth: true + spacing: 0 - RowLayout { - Layout.fillWidth: true - spacing: 0 + Button { + text: i18nc("Add current list to playlist", "Enqueue") + iconName: "media-track-add-amarok" - Button { - text: i18nc("Add current list to playlist", "Enqueue") - iconName: "media-track-add-amarok" + onClicked: enqueue() - onClicked: enqueue() + Layout.leftMargin: 0 + Layout.rightMargin: 0 + } - Layout.leftMargin: 0 - Layout.rightMargin: 0 - } + Button { + text: i18nc("Clear playlist and play", "Replace and Play") + tooltip: i18nc("Clear playlist and add current list to it", "Replace PlayList and Play Now") + iconName: "media-playback-start" + + onClicked: replaceAndPlay() - Button { - text: i18nc("Clear playlist and play", "Replace and Play") - tooltip: i18nc("Clear playlist and add current list to it", "Replace PlayList and Play Now") - iconName: "media-playback-start" + Layout.leftMargin: !LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin : 0 + Layout.rightMargin: LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin : 0 + } - onClicked: replaceAndPlay() + Button { + id: showArtistButton - Layout.leftMargin: !LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin : 0 - Layout.rightMargin: LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin : 0 + visible: allowArtistNavigation + text: i18nc("Button to navigate to the artist of the album", "Display Artist") + iconName: "view-media-artist" + + onClicked: showArtist() + + Layout.leftMargin: !LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin : 0 + Layout.rightMargin: LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin : 0 + } + + Item { + Layout.fillWidth: true + } + + ToolButton { + action: showFilterAction + + Layout.alignment: Qt.AlignRight + Layout.leftMargin: !LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin : 0 + Layout.rightMargin: LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin : 0 + } } + } + } - Button { - id: showArtistButton + RowLayout { + id: filterRow - visible: allowArtistNavigation - text: i18nc("Button to navigate to the artist of the album", "Display Artist") - iconName: "view-media-artist" + spacing: 0 - onClicked: showArtist() + Layout.fillWidth: true + Layout.leftMargin: !LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin : 0 + Layout.rightMargin: LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin : 0 + + LabelWithToolTip { + text: i18nc("before the TextField input of the filter", "Filter: ") + + font.bold: true + + Layout.bottomMargin: 0 - Layout.leftMargin: !LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin : 0 - Layout.rightMargin: LayoutMirroring.enabled ? elisaTheme.layoutHorizontalMargin : 0 + color: myPalette.text + } + + TextField { + id: filterTextInput + + horizontalAlignment: TextInput.AlignLeft + + placeholderText: i18nc("Placeholder text in the filter text box", "Filter") + + Layout.bottomMargin: 0 + Layout.preferredWidth: navigationBar.width / 2 + + Image { + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.right: parent.right + anchors.margins: elisaTheme.filterClearButtonMargin + id: clearText + fillMode: Image.PreserveAspectFit + smooth: true + visible: parent.text + source: Qt.resolvedUrl(elisaTheme.clearIcon) + height: parent.height + width: parent.height + sourceSize.width: parent.height + sourceSize.height: parent.height + mirror: LayoutMirroring.enabled + + MouseArea { + id: clear + anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter } + height: parent.parent.height + width: parent.parent.height + onClicked: { + parent.parent.text = "" + parent.parent.forceActiveFocus() + } + } } } + + LabelWithToolTip { + text: i18nc("before the Rating widget input of the filter", "Rating: ") + + visible: showRating + + font.bold: true + + color: myPalette.text + + Layout.bottomMargin: 0 + Layout.leftMargin: !LayoutMirroring.enabled ? (elisaTheme.layoutHorizontalMargin * 2) : 0 + Layout.rightMargin: LayoutMirroring.enabled ? (elisaTheme.layoutHorizontalMargin * 2) : 0 + } + + RatingStar { + id: ratingFilter + + visible: showRating + + readOnly: false + + starSize: elisaTheme.ratingStarSize + + Layout.bottomMargin: 0 + } + } + } + + states: [ + State { + name: "" + PropertyChanges { + target: navigationBar + height: elisaTheme.navigationBarHeight + } + }, + State { + name: 'expanded' + PropertyChanges { + target: navigationBar + height: elisaTheme.navigationBarHeight + elisaTheme.navigationBarFilterHeight + } + } + ] + transitions: Transition { + NumberAnimation { + properties: "height" + easing.type: Easing.Linear + duration: 250 } } } diff --git a/src/qml/Theme.qml b/src/qml/Theme.qml --- a/src/qml/Theme.qml +++ b/src/qml/Theme.qml @@ -46,7 +46,7 @@ property int delegateWithHeaderHeight: 68 property int trackDelegateHeight: 45 - property int coverImageSize: 180 + property int coverImageSize: 186 property int smallImageSize: 32 property int trackMetadataWidth: 360 @@ -68,6 +68,7 @@ property int dragDropPlaceholderHeight: 28 property int navigationBarHeight: 100 + property int navigationBarFilterHeight: 40 property int gridDelegateHeight: 100 + layoutVerticalMargin + fontSize.height * 2 property int gridDelegateWidth: 100 diff --git a/src/resources.qrc b/src/resources.qrc --- a/src/resources.qrc +++ b/src/resources.qrc @@ -20,7 +20,6 @@ qml/TrackImportNotification.qml qml/TopNotificationItem.qml qml/ViewSelector.qml - qml/FilterBar.qml qml/MediaTrackDelegate.qml qml/MediaAlbumTrackDelegate.qml qml/MediaTrackMetadataView.qml diff --git a/src/windows/WindowsTheme.qml b/src/windows/WindowsTheme.qml --- a/src/windows/WindowsTheme.qml +++ b/src/windows/WindowsTheme.qml @@ -46,7 +46,7 @@ property int delegateWithHeaderHeight: 68 property int trackDelegateHeight: 45 - property int coverImageSize: 180 + property int coverImageSize: 186 property int smallImageSize: 32 property int trackMetadataWidth: 360 @@ -68,6 +68,7 @@ property int dragDropPlaceholderHeight: 28 property int navigationBarHeight: 100 + property int navigationBarFilterHeight: 40 property int gridDelegateHeight: 100 + layoutVerticalMargin + fontSize.height * 2 property int gridDelegateWidth: 100