Use PlaylistFilter directly
This commit is contained in:
parent
553d4cce93
commit
acb6c0fc83
@ -135,6 +135,7 @@
|
|||||||
#include "playlist/playlistmanager.h"
|
#include "playlist/playlistmanager.h"
|
||||||
#include "playlist/playlistsequence.h"
|
#include "playlist/playlistsequence.h"
|
||||||
#include "playlist/playlistview.h"
|
#include "playlist/playlistview.h"
|
||||||
|
#include "playlist/playlistfilter.h"
|
||||||
#include "queue/queue.h"
|
#include "queue/queue.h"
|
||||||
#include "queue/queueview.h"
|
#include "queue/queueview.h"
|
||||||
#include "playlistparsers/playlistparser.h"
|
#include "playlistparsers/playlistparser.h"
|
||||||
@ -1509,9 +1510,9 @@ void MainWindow::PlayIndex(const QModelIndex &idx, Playlist::AutoScroll autoscro
|
|||||||
if (!idx.isValid()) return;
|
if (!idx.isValid()) return;
|
||||||
|
|
||||||
int row = idx.row();
|
int row = idx.row();
|
||||||
if (idx.model() == app_->playlist_manager()->current()->proxy()) {
|
if (idx.model() == app_->playlist_manager()->current()->filter()) {
|
||||||
// The index was in the proxy model (might've been filtered), so we need to get the actual row in the source model.
|
// The index was in the proxy model (might've been filtered), so we need to get the actual row in the source model.
|
||||||
row = app_->playlist_manager()->current()->proxy()->mapToSource(idx).row();
|
row = app_->playlist_manager()->current()->filter()->mapToSource(idx).row();
|
||||||
}
|
}
|
||||||
|
|
||||||
app_->playlist_manager()->SetActiveToCurrent();
|
app_->playlist_manager()->SetActiveToCurrent();
|
||||||
@ -1524,9 +1525,9 @@ void MainWindow::PlaylistDoubleClick(const QModelIndex &idx) {
|
|||||||
if (!idx.isValid()) return;
|
if (!idx.isValid()) return;
|
||||||
|
|
||||||
QModelIndex source_idx = idx;
|
QModelIndex source_idx = idx;
|
||||||
if (idx.model() == app_->playlist_manager()->current()->proxy()) {
|
if (idx.model() == app_->playlist_manager()->current()->filter()) {
|
||||||
// The index was in the proxy model (might've been filtered), so we need to get the actual row in the source model.
|
// The index was in the proxy model (might've been filtered), so we need to get the actual row in the source model.
|
||||||
source_idx = app_->playlist_manager()->current()->proxy()->mapToSource(idx);
|
source_idx = app_->playlist_manager()->current()->filter()->mapToSource(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (doubleclick_playlist_addmode_) {
|
switch (doubleclick_playlist_addmode_) {
|
||||||
@ -1765,7 +1766,7 @@ void MainWindow::AddToPlaylistFromAction(QAction *action) {
|
|||||||
|
|
||||||
// Get the selected playlist items
|
// Get the selected playlist items
|
||||||
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
||||||
const QModelIndex source_index = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index);
|
const QModelIndex source_index = app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
|
||||||
if (!source_index.isValid()) continue;
|
if (!source_index.isValid()) continue;
|
||||||
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_index.row());
|
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_index.row());
|
||||||
if (!item) continue;
|
if (!item) continue;
|
||||||
@ -1804,8 +1805,8 @@ void MainWindow::PlaylistMenuHidden() {
|
|||||||
void MainWindow::PlaylistRightClick(const QPoint global_pos, const QModelIndex &index) {
|
void MainWindow::PlaylistRightClick(const QPoint global_pos, const QModelIndex &index) {
|
||||||
|
|
||||||
QModelIndex source_index = index;
|
QModelIndex source_index = index;
|
||||||
if (index.model() == app_->playlist_manager()->current()->proxy()) {
|
if (index.model() == app_->playlist_manager()->current()->filter()) {
|
||||||
source_index = app_->playlist_manager()->current()->proxy()->mapToSource(index);
|
source_index = app_->playlist_manager()->current()->filter()->mapToSource(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
playlist_menu_index_ = source_index;
|
playlist_menu_index_ = source_index;
|
||||||
@ -1844,7 +1845,7 @@ void MainWindow::PlaylistRightClick(const QPoint global_pos, const QModelIndex &
|
|||||||
|
|
||||||
for (const QModelIndex &idx : selection) {
|
for (const QModelIndex &idx : selection) {
|
||||||
|
|
||||||
const QModelIndex src_idx = app_->playlist_manager()->current()->proxy()->mapToSource(idx);
|
const QModelIndex src_idx = app_->playlist_manager()->current()->filter()->mapToSource(idx);
|
||||||
if (!src_idx.isValid()) continue;
|
if (!src_idx.isValid()) continue;
|
||||||
|
|
||||||
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(src_idx.row());
|
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(src_idx.row());
|
||||||
@ -2048,7 +2049,7 @@ void MainWindow::RescanSongs() {
|
|||||||
SongList songs;
|
SongList songs;
|
||||||
|
|
||||||
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
||||||
const QModelIndex source_index = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index);
|
const QModelIndex source_index = app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
|
||||||
if (!source_index.isValid()) continue;
|
if (!source_index.isValid()) continue;
|
||||||
PlaylistItemPtr item(app_->playlist_manager()->current()->item_at(source_index.row()));
|
PlaylistItemPtr item(app_->playlist_manager()->current()->item_at(source_index.row()));
|
||||||
if (!item) continue;
|
if (!item) continue;
|
||||||
@ -2073,7 +2074,7 @@ void MainWindow::EditTracks() {
|
|||||||
PlaylistItemList items;
|
PlaylistItemList items;
|
||||||
|
|
||||||
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
||||||
const QModelIndex source_index = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index);
|
const QModelIndex source_index = app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
|
||||||
if (!source_index.isValid()) continue;
|
if (!source_index.isValid()) continue;
|
||||||
PlaylistItemPtr item(app_->playlist_manager()->current()->item_at(source_index.row()));
|
PlaylistItemPtr item(app_->playlist_manager()->current()->item_at(source_index.row()));
|
||||||
if (!item) continue;
|
if (!item) continue;
|
||||||
@ -2120,7 +2121,7 @@ void MainWindow::RenumberTracks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const QModelIndex &proxy_index : indexes) {
|
for (const QModelIndex &proxy_index : indexes) {
|
||||||
const QModelIndex source_index = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index);
|
const QModelIndex source_index = app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
|
||||||
if (!source_index.isValid()) continue;
|
if (!source_index.isValid()) continue;
|
||||||
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_index.row());
|
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_index.row());
|
||||||
if (!item) continue;
|
if (!item) continue;
|
||||||
@ -2151,7 +2152,7 @@ void MainWindow::SelectionSetValue() {
|
|||||||
QVariant column_value = app_->playlist_manager()->current()->data(playlist_menu_index_);
|
QVariant column_value = app_->playlist_manager()->current()->data(playlist_menu_index_);
|
||||||
|
|
||||||
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
||||||
const QModelIndex source_index = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index);
|
const QModelIndex source_index = app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
|
||||||
if (!source_index.isValid()) continue;
|
if (!source_index.isValid()) continue;
|
||||||
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_index.row());
|
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_index.row());
|
||||||
if (!item) continue;
|
if (!item) continue;
|
||||||
@ -2265,7 +2266,7 @@ void MainWindow::ShowInCollection() {
|
|||||||
|
|
||||||
SongList songs;
|
SongList songs;
|
||||||
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
||||||
const QModelIndex source_index = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index);
|
const QModelIndex source_index = app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
|
||||||
if (!source_index.isValid()) continue;
|
if (!source_index.isValid()) continue;
|
||||||
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_index.row());
|
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_index.row());
|
||||||
if (item && item->IsLocalCollectionItem()) {
|
if (item && item->IsLocalCollectionItem()) {
|
||||||
@ -2518,7 +2519,7 @@ void MainWindow::AddFilesToTranscoder() {
|
|||||||
QStringList filenames;
|
QStringList filenames;
|
||||||
|
|
||||||
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
||||||
const QModelIndex source_index = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index);
|
const QModelIndex source_index = app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
|
||||||
if (!source_index.isValid()) continue;
|
if (!source_index.isValid()) continue;
|
||||||
PlaylistItemPtr item(app_->playlist_manager()->current()->item_at(source_index.row()));
|
PlaylistItemPtr item(app_->playlist_manager()->current()->item_at(source_index.row()));
|
||||||
if (!item) continue;
|
if (!item) continue;
|
||||||
@ -2630,7 +2631,7 @@ void MainWindow::PlaylistOrganizeSelected(const bool copy) {
|
|||||||
|
|
||||||
SongList songs;
|
SongList songs;
|
||||||
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
||||||
const QModelIndex source_index = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index);
|
const QModelIndex source_index = app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
|
||||||
if (!source_index.isValid()) continue;
|
if (!source_index.isValid()) continue;
|
||||||
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_index.row());
|
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_index.row());
|
||||||
if (!item) continue;
|
if (!item) continue;
|
||||||
@ -2652,7 +2653,7 @@ void MainWindow::PlaylistOpenInBrowser() {
|
|||||||
|
|
||||||
QList<QUrl> urls;
|
QList<QUrl> urls;
|
||||||
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
||||||
const QModelIndex source_index = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index);
|
const QModelIndex source_index = app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
|
||||||
if (!source_index.isValid()) continue;
|
if (!source_index.isValid()) continue;
|
||||||
urls << QUrl(source_index.sibling(source_index.row(), Playlist::Column_Filename).data().toString());
|
urls << QUrl(source_index.sibling(source_index.row(), Playlist::Column_Filename).data().toString());
|
||||||
}
|
}
|
||||||
@ -2665,7 +2666,7 @@ void MainWindow::PlaylistCopyUrl() {
|
|||||||
|
|
||||||
QList<QUrl> urls;
|
QList<QUrl> urls;
|
||||||
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
||||||
const QModelIndex source_index = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index);
|
const QModelIndex source_index = app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
|
||||||
if (!source_index.isValid()) continue;
|
if (!source_index.isValid()) continue;
|
||||||
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_index.row());
|
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_index.row());
|
||||||
if (!item) continue;
|
if (!item) continue;
|
||||||
@ -2686,7 +2687,7 @@ void MainWindow::PlaylistQueue() {
|
|||||||
QModelIndexList indexes;
|
QModelIndexList indexes;
|
||||||
indexes.reserve(selected_rows.count());
|
indexes.reserve(selected_rows.count());
|
||||||
for (const QModelIndex &proxy_index : selected_rows) {
|
for (const QModelIndex &proxy_index : selected_rows) {
|
||||||
indexes << app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index);
|
indexes << app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
app_->playlist_manager()->current()->queue()->ToggleTracks(indexes);
|
app_->playlist_manager()->current()->queue()->ToggleTracks(indexes);
|
||||||
@ -2699,7 +2700,7 @@ void MainWindow::PlaylistQueuePlayNext() {
|
|||||||
QModelIndexList indexes;
|
QModelIndexList indexes;
|
||||||
indexes.reserve(selected_rows.count());
|
indexes.reserve(selected_rows.count());
|
||||||
for (const QModelIndex &proxy_index : selected_rows) {
|
for (const QModelIndex &proxy_index : selected_rows) {
|
||||||
indexes << app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index);
|
indexes << app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
app_->playlist_manager()->current()->queue()->InsertFirst(indexes);
|
app_->playlist_manager()->current()->queue()->InsertFirst(indexes);
|
||||||
@ -2712,7 +2713,7 @@ void MainWindow::PlaylistSkip() {
|
|||||||
QModelIndexList indexes;
|
QModelIndexList indexes;
|
||||||
indexes.reserve(selected_rows.count());
|
indexes.reserve(selected_rows.count());
|
||||||
for (const QModelIndex &proxy_index : selected_rows) {
|
for (const QModelIndex &proxy_index : selected_rows) {
|
||||||
indexes << app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index);
|
indexes << app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
app_->playlist_manager()->current()->SkipTracks(indexes);
|
app_->playlist_manager()->current()->SkipTracks(indexes);
|
||||||
@ -2726,7 +2727,7 @@ void MainWindow::PlaylistCopyToDevice() {
|
|||||||
SongList songs;
|
SongList songs;
|
||||||
|
|
||||||
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
||||||
const QModelIndex source_index = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index);
|
const QModelIndex source_index = app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
|
||||||
if (!source_index.isValid()) continue;
|
if (!source_index.isValid()) continue;
|
||||||
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_index.row());
|
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_index.row());
|
||||||
if (!item) continue;
|
if (!item) continue;
|
||||||
@ -2875,7 +2876,7 @@ void MainWindow::PlaylistViewSelectionModelChanged() {
|
|||||||
|
|
||||||
void MainWindow::PlaylistCurrentChanged(const QModelIndex &proxy_current) {
|
void MainWindow::PlaylistCurrentChanged(const QModelIndex &proxy_current) {
|
||||||
|
|
||||||
const QModelIndex source_current = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_current);
|
const QModelIndex source_current = app_->playlist_manager()->current()->filter()->mapToSource(proxy_current);
|
||||||
|
|
||||||
// If the user moves the current index using the keyboard and then presses
|
// If the user moves the current index using the keyboard and then presses
|
||||||
// F2, we don't want that editing the last column that was right clicked on.
|
// F2, we don't want that editing the last column that was right clicked on.
|
||||||
@ -2927,7 +2928,7 @@ void MainWindow::AutoCompleteTags() {
|
|||||||
// Get the selected songs and start fetching tags for them
|
// Get the selected songs and start fetching tags for them
|
||||||
SongList songs;
|
SongList songs;
|
||||||
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
||||||
const QModelIndex source_index = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index);
|
const QModelIndex source_index = app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
|
||||||
if (!source_index.isValid()) continue;
|
if (!source_index.isValid()) continue;
|
||||||
PlaylistItemPtr item(app_->playlist_manager()->current()->item_at(source_index.row()));
|
PlaylistItemPtr item(app_->playlist_manager()->current()->item_at(source_index.row()));
|
||||||
if (!item) continue;
|
if (!item) continue;
|
||||||
@ -3144,7 +3145,7 @@ void MainWindow::PlaylistDelete() {
|
|||||||
QStringList files;
|
QStringList files;
|
||||||
bool is_current_item = false;
|
bool is_current_item = false;
|
||||||
for (const QModelIndex &proxy_idx : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
for (const QModelIndex &proxy_idx : ui_->playlist->view()->selectionModel()->selectedRows()) {
|
||||||
QModelIndex source_idx = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_idx);
|
QModelIndex source_idx = app_->playlist_manager()->current()->filter()->mapToSource(proxy_idx);
|
||||||
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_idx.row());
|
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_idx.row());
|
||||||
if (!item || !item->Metadata().url().isLocalFile()) continue;
|
if (!item || !item->Metadata().url().isLocalFile()) continue;
|
||||||
QString filename = item->Metadata().url().toLocalFile();
|
QString filename = item->Metadata().url().toLocalFile();
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSortFilterProxyModel>
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
@ -58,6 +57,7 @@
|
|||||||
|
|
||||||
#include "collection/collectionbackend.h"
|
#include "collection/collectionbackend.h"
|
||||||
#include "playlist/playlist.h"
|
#include "playlist/playlist.h"
|
||||||
|
#include "playlist/playlistfilter.h"
|
||||||
#include "playlist/playlistitem.h"
|
#include "playlist/playlistitem.h"
|
||||||
#include "playlist/playlistmanager.h"
|
#include "playlist/playlistmanager.h"
|
||||||
#include "playlist/playlistsequence.h"
|
#include "playlist/playlistsequence.h"
|
||||||
@ -385,7 +385,7 @@ void Player::NextItem(const Engine::TrackChangeFlags change, const Playlist::Aut
|
|||||||
if (change == Engine::Auto) {
|
if (change == Engine::Auto) {
|
||||||
const PlaylistSequence::RepeatMode repeat_mode = active_playlist->sequence()->repeat_mode();
|
const PlaylistSequence::RepeatMode repeat_mode = active_playlist->sequence()->repeat_mode();
|
||||||
if (repeat_mode != PlaylistSequence::Repeat_Off) {
|
if (repeat_mode != PlaylistSequence::Repeat_Off) {
|
||||||
if ((repeat_mode == PlaylistSequence::Repeat_Track && nb_errors_received_ >= 3) || (nb_errors_received_ >= app_->playlist_manager()->active()->proxy()->rowCount())) {
|
if ((repeat_mode == PlaylistSequence::Repeat_Track && nb_errors_received_ >= 3) || (nb_errors_received_ >= app_->playlist_manager()->active()->filter()->rowCount())) {
|
||||||
// We received too many "Error" state changes: probably looping over a playlist which contains only unavailable elements: stop now.
|
// We received too many "Error" state changes: probably looping over a playlist which contains only unavailable elements: stop now.
|
||||||
nb_errors_received_ = 0;
|
nb_errors_received_ = 0;
|
||||||
Stop();
|
Stop();
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
#include <QFuture>
|
#include <QFuture>
|
||||||
#include <QFutureWatcher>
|
#include <QFutureWatcher>
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
#include <QSortFilterProxyModel>
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QItemDelegate>
|
#include <QItemDelegate>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
@ -39,6 +38,7 @@
|
|||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "playlist/playlist.h"
|
#include "playlist/playlist.h"
|
||||||
#include "playlist/playlistview.h"
|
#include "playlist/playlistview.h"
|
||||||
|
#include "playlist/playlistfilter.h"
|
||||||
|
|
||||||
#include "moodbaritemdelegate.h"
|
#include "moodbaritemdelegate.h"
|
||||||
#include "moodbarloader.h"
|
#include "moodbarloader.h"
|
||||||
@ -276,7 +276,7 @@ void MoodbarItemDelegate::ImageLoaded(const QUrl &url, const QImage &image) {
|
|||||||
data->state_ = Data::State_Loaded;
|
data->state_ = Data::State_Loaded;
|
||||||
|
|
||||||
Playlist *playlist = view_->playlist();
|
Playlist *playlist = view_->playlist();
|
||||||
const QSortFilterProxyModel *filter = playlist->proxy();
|
const PlaylistFilter *filter = playlist->filter();
|
||||||
|
|
||||||
// Update all the indices with the new pixmap.
|
// Update all the indices with the new pixmap.
|
||||||
for (const QPersistentModelIndex &idx : std::as_const(data->indexes_)) {
|
for (const QPersistentModelIndex &idx : std::as_const(data->indexes_)) {
|
||||||
|
@ -120,7 +120,7 @@ const qint64 Playlist::kMaxScrobblePointNsecs = 240LL * kNsecPerSec;
|
|||||||
Playlist::Playlist(PlaylistBackend *backend, TaskManager *task_manager, CollectionBackend *collection, const int id, const QString &special_type, const bool favorite, QObject *parent)
|
Playlist::Playlist(PlaylistBackend *backend, TaskManager *task_manager, CollectionBackend *collection, const int id, const QString &special_type, const bool favorite, QObject *parent)
|
||||||
: QAbstractListModel(parent),
|
: QAbstractListModel(parent),
|
||||||
is_loading_(false),
|
is_loading_(false),
|
||||||
proxy_(new PlaylistFilter(this)),
|
filter_(new PlaylistFilter(this)),
|
||||||
queue_(new Queue(this, this)),
|
queue_(new Queue(this, this)),
|
||||||
timer_save_(new QTimer(this)),
|
timer_save_(new QTimer(this)),
|
||||||
backend_(backend),
|
backend_(backend),
|
||||||
@ -150,7 +150,7 @@ Playlist::Playlist(PlaylistBackend *backend, TaskManager *task_manager, Collecti
|
|||||||
|
|
||||||
Restore();
|
Restore();
|
||||||
|
|
||||||
proxy_->setSourceModel(this);
|
filter_->setSourceModel(this);
|
||||||
queue_->setSourceModel(this);
|
queue_->setSourceModel(this);
|
||||||
|
|
||||||
QObject::connect(queue_, &Queue::rowsAboutToBeRemoved, this, &Playlist::TracksAboutToBeDequeued);
|
QObject::connect(queue_, &Queue::rowsAboutToBeRemoved, this, &Playlist::TracksAboutToBeDequeued);
|
||||||
@ -491,7 +491,7 @@ void Playlist::ShuffleModeChanged(const PlaylistSequence::ShuffleMode mode) {
|
|||||||
bool Playlist::FilterContainsVirtualIndex(const int i) const {
|
bool Playlist::FilterContainsVirtualIndex(const int i) const {
|
||||||
if (i < 0 || i >= virtual_items_.count()) return false;
|
if (i < 0 || i >= virtual_items_.count()) return false;
|
||||||
|
|
||||||
return proxy_->filterAcceptsRow(virtual_items_[i], QModelIndex());
|
return filter_->filterAcceptsRow(virtual_items_[i], QModelIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
int Playlist::NextVirtualIndex(int i, const bool ignore_repeat_track) const {
|
int Playlist::NextVirtualIndex(int i, const bool ignore_repeat_track) const {
|
||||||
@ -2013,7 +2013,7 @@ void Playlist::set_sequence(PlaylistSequence *v) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QSortFilterProxyModel *Playlist::proxy() const { return proxy_; }
|
PlaylistFilter *Playlist::filter() const { return filter_; }
|
||||||
|
|
||||||
SongList Playlist::GetAllSongs() const {
|
SongList Playlist::GetAllSongs() const {
|
||||||
|
|
||||||
|
@ -49,7 +49,6 @@
|
|||||||
#include "smartplaylists/playlistgenerator_fwd.h"
|
#include "smartplaylists/playlistgenerator_fwd.h"
|
||||||
|
|
||||||
class QMimeData;
|
class QMimeData;
|
||||||
class QSortFilterProxyModel;
|
|
||||||
class QUndoStack;
|
class QUndoStack;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
|
|
||||||
@ -180,7 +179,7 @@ class Playlist : public QAbstractListModel {
|
|||||||
void ScheduleSaveAsync();
|
void ScheduleSaveAsync();
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
QSortFilterProxyModel *proxy() const;
|
PlaylistFilter *filter() const;
|
||||||
Queue *queue() const { return queue_; }
|
Queue *queue() const { return queue_; }
|
||||||
|
|
||||||
int id() const { return id_; }
|
int id() const { return id_; }
|
||||||
@ -380,7 +379,7 @@ class Playlist : public QAbstractListModel {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool is_loading_;
|
bool is_loading_;
|
||||||
PlaylistFilter *proxy_;
|
PlaylistFilter *filter_;
|
||||||
Queue *queue_;
|
Queue *queue_;
|
||||||
QTimer *timer_save_;
|
QTimer *timer_save_;
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@
|
|||||||
#include "playlistview.h"
|
#include "playlistview.h"
|
||||||
#include "playlistcontainer.h"
|
#include "playlistcontainer.h"
|
||||||
#include "playlistmanager.h"
|
#include "playlistmanager.h"
|
||||||
|
#include "playlistfilter.h"
|
||||||
#include "playlistparsers/playlistparser.h"
|
#include "playlistparsers/playlistparser.h"
|
||||||
#include "ui_playlistcontainer.h"
|
#include "ui_playlistcontainer.h"
|
||||||
#include "widgets/qsearchfield.h"
|
#include "widgets/qsearchfield.h"
|
||||||
@ -120,9 +121,9 @@ PlaylistContainer::PlaylistContainer(QWidget *parent)
|
|||||||
QObject::connect(filter_timer_, &QTimer::timeout, this, &PlaylistContainer::UpdateFilter);
|
QObject::connect(filter_timer_, &QTimer::timeout, this, &PlaylistContainer::UpdateFilter);
|
||||||
|
|
||||||
// Replace playlist search filter with native search box.
|
// Replace playlist search filter with native search box.
|
||||||
QObject::connect(ui_->filter, &QSearchField::textChanged, this, &PlaylistContainer::MaybeUpdateFilter);
|
QObject::connect(ui_->search_field, &QSearchField::textChanged, this, &PlaylistContainer::MaybeUpdateFilter);
|
||||||
QObject::connect(ui_->playlist, &PlaylistView::FocusOnFilterSignal, this, &PlaylistContainer::FocusOnFilter);
|
QObject::connect(ui_->playlist, &PlaylistView::FocusOnFilterSignal, this, &PlaylistContainer::FocusOnFilter);
|
||||||
ui_->filter->installEventFilter(this);
|
ui_->search_field->installEventFilter(this);
|
||||||
|
|
||||||
ReloadSettings();
|
ReloadSettings();
|
||||||
|
|
||||||
@ -177,10 +178,10 @@ void PlaylistContainer::SetViewModel(Playlist *playlist, const int scroll_positi
|
|||||||
if (view()->selectionModel()) {
|
if (view()->selectionModel()) {
|
||||||
QObject::disconnect(view()->selectionModel(), &QItemSelectionModel::selectionChanged, this, &PlaylistContainer::SelectionChanged);
|
QObject::disconnect(view()->selectionModel(), &QItemSelectionModel::selectionChanged, this, &PlaylistContainer::SelectionChanged);
|
||||||
}
|
}
|
||||||
if (playlist_ && playlist_->proxy()) {
|
if (playlist_ && playlist_->filter()) {
|
||||||
QObject::disconnect(playlist_->proxy(), &QSortFilterProxyModel::modelReset, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
QObject::disconnect(playlist_->filter(), &QSortFilterProxyModel::modelReset, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
||||||
QObject::disconnect(playlist_->proxy(), &QSortFilterProxyModel::rowsInserted, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
QObject::disconnect(playlist_->filter(), &QSortFilterProxyModel::rowsInserted, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
||||||
QObject::disconnect(playlist_->proxy(), &QSortFilterProxyModel::rowsRemoved, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
QObject::disconnect(playlist_->filter(), &QSortFilterProxyModel::rowsRemoved, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
||||||
}
|
}
|
||||||
if (playlist_) {
|
if (playlist_) {
|
||||||
QObject::disconnect(playlist_, &Playlist::modelReset, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
QObject::disconnect(playlist_, &Playlist::modelReset, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
||||||
@ -192,7 +193,7 @@ void PlaylistContainer::SetViewModel(Playlist *playlist, const int scroll_positi
|
|||||||
|
|
||||||
// Set the view
|
// Set the view
|
||||||
playlist->IgnoreSorting(true);
|
playlist->IgnoreSorting(true);
|
||||||
view()->setModel(playlist->proxy());
|
view()->setModel(playlist->filter());
|
||||||
view()->SetPlaylist(playlist);
|
view()->SetPlaylist(playlist);
|
||||||
view()->selectionModel()->select(manager_->current_selection(), QItemSelectionModel::ClearAndSelect);
|
view()->selectionModel()->select(manager_->current_selection(), QItemSelectionModel::ClearAndSelect);
|
||||||
if (scroll_position != 0) view()->verticalScrollBar()->setValue(scroll_position);
|
if (scroll_position != 0) view()->verticalScrollBar()->setValue(scroll_position);
|
||||||
@ -202,16 +203,12 @@ void PlaylistContainer::SetViewModel(Playlist *playlist, const int scroll_positi
|
|||||||
emit ViewSelectionModelChanged();
|
emit ViewSelectionModelChanged();
|
||||||
|
|
||||||
// Update filter
|
// Update filter
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
ui_->search_field->setText(playlist->filter()->filter_text());
|
||||||
ui_->filter->setText(playlist->proxy()->filterRegularExpression().pattern().remove('\\'));
|
|
||||||
#else
|
|
||||||
ui_->filter->setText(playlist->proxy()->filterRegExp().pattern());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Update the no matches label
|
// Update the no matches label
|
||||||
QObject::connect(playlist_->proxy(), &QSortFilterProxyModel::modelReset, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
QObject::connect(playlist_->filter(), &QSortFilterProxyModel::modelReset, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
||||||
QObject::connect(playlist_->proxy(), &QSortFilterProxyModel::rowsInserted, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
QObject::connect(playlist_->filter(), &QSortFilterProxyModel::rowsInserted, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
||||||
QObject::connect(playlist_->proxy(), &QSortFilterProxyModel::rowsRemoved, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
QObject::connect(playlist_->filter(), &QSortFilterProxyModel::rowsRemoved, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
||||||
QObject::connect(playlist_, &Playlist::modelReset, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
QObject::connect(playlist_, &Playlist::modelReset, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
||||||
QObject::connect(playlist_, &Playlist::rowsInserted, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
QObject::connect(playlist_, &Playlist::rowsInserted, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
||||||
QObject::connect(playlist_, &Playlist::rowsRemoved, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
QObject::connect(playlist_, &Playlist::rowsRemoved, this, &PlaylistContainer::UpdateNoMatchesLabel);
|
||||||
@ -252,7 +249,7 @@ void PlaylistContainer::ReloadSettings() {
|
|||||||
ui_->clear->setIconSize(QSize(iconsize, iconsize));
|
ui_->clear->setIconSize(QSize(iconsize, iconsize));
|
||||||
ui_->undo->setIconSize(QSize(iconsize, iconsize));
|
ui_->undo->setIconSize(QSize(iconsize, iconsize));
|
||||||
ui_->redo->setIconSize(QSize(iconsize, iconsize));
|
ui_->redo->setIconSize(QSize(iconsize, iconsize));
|
||||||
ui_->filter->setIconSize(iconsize);
|
ui_->search_field->setIconSize(iconsize);
|
||||||
|
|
||||||
bool playlist_clear = settings_.value("playlist_clear", true).toBool();
|
bool playlist_clear = settings_.value("playlist_clear", true).toBool();
|
||||||
if (playlist_clear) {
|
if (playlist_clear) {
|
||||||
@ -265,16 +262,16 @@ void PlaylistContainer::ReloadSettings() {
|
|||||||
bool show_toolbar = settings_.value("show_toolbar", true).toBool();
|
bool show_toolbar = settings_.value("show_toolbar", true).toBool();
|
||||||
ui_->toolbar->setVisible(show_toolbar);
|
ui_->toolbar->setVisible(show_toolbar);
|
||||||
|
|
||||||
if (!show_toolbar) ui_->filter->clear();
|
if (!show_toolbar) ui_->search_field->clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlaylistContainer::SearchFieldHasFocus() const {
|
bool PlaylistContainer::SearchFieldHasFocus() const {
|
||||||
return ui_->filter->hasFocus();
|
return ui_->search_field->hasFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaylistContainer::FocusSearchField() {
|
void PlaylistContainer::FocusSearchField() {
|
||||||
if (ui_->toolbar->isVisible()) ui_->filter->setFocus();
|
if (ui_->toolbar->isVisible()) ui_->search_field->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaylistContainer::ActivePlaying() {
|
void PlaylistContainer::ActivePlaying() {
|
||||||
@ -409,7 +406,7 @@ void PlaylistContainer::SetTabBarHeight(const int height) {
|
|||||||
void PlaylistContainer::MaybeUpdateFilter() {
|
void PlaylistContainer::MaybeUpdateFilter() {
|
||||||
|
|
||||||
// delaying the filter update on small playlists is undesirable and an empty filter applies very quickly, too
|
// delaying the filter update on small playlists is undesirable and an empty filter applies very quickly, too
|
||||||
if (manager_->current()->rowCount() < kFilterDelayPlaylistSizeThreshold || ui_->filter->text().isEmpty()) {
|
if (manager_->current()->rowCount() < kFilterDelayPlaylistSizeThreshold || ui_->search_field->text().isEmpty()) {
|
||||||
UpdateFilter();
|
UpdateFilter();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -420,7 +417,7 @@ void PlaylistContainer::MaybeUpdateFilter() {
|
|||||||
|
|
||||||
void PlaylistContainer::UpdateFilter() {
|
void PlaylistContainer::UpdateFilter() {
|
||||||
|
|
||||||
manager_->current()->proxy()->setFilterFixedString(ui_->filter->text());
|
manager_->current()->filter()->SetFilterText(ui_->search_field->text());
|
||||||
ui_->playlist->JumpToCurrentlyPlayingTrack();
|
ui_->playlist->JumpToCurrentlyPlayingTrack();
|
||||||
|
|
||||||
UpdateNoMatchesLabel();
|
UpdateNoMatchesLabel();
|
||||||
@ -431,7 +428,7 @@ void PlaylistContainer::UpdateNoMatchesLabel() {
|
|||||||
|
|
||||||
Playlist *playlist = manager_->current();
|
Playlist *playlist = manager_->current();
|
||||||
const bool has_rows = playlist->rowCount() != 0;
|
const bool has_rows = playlist->rowCount() != 0;
|
||||||
const bool has_results = playlist->proxy()->rowCount() != 0;
|
const bool has_results = playlist->filter()->rowCount() != 0;
|
||||||
|
|
||||||
QString text;
|
QString text;
|
||||||
if (has_rows && !has_results) {
|
if (has_rows && !has_results) {
|
||||||
@ -457,15 +454,15 @@ void PlaylistContainer::resizeEvent(QResizeEvent *e) {
|
|||||||
void PlaylistContainer::FocusOnFilter(QKeyEvent *event) {
|
void PlaylistContainer::FocusOnFilter(QKeyEvent *event) {
|
||||||
|
|
||||||
if (ui_->toolbar->isVisible()) {
|
if (ui_->toolbar->isVisible()) {
|
||||||
ui_->filter->setFocus();
|
ui_->search_field->setFocus();
|
||||||
switch (event->key()) {
|
switch (event->key()) {
|
||||||
case Qt::Key_Backspace:
|
case Qt::Key_Backspace:
|
||||||
break;
|
break;
|
||||||
case Qt::Key_Escape:
|
case Qt::Key_Escape:
|
||||||
ui_->filter->clear();
|
ui_->search_field->clear();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ui_->filter->setText(ui_->filter->text() + event->text());
|
ui_->search_field->setText(ui_->search_field->text() + event->text());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -494,7 +491,7 @@ void PlaylistContainer::SelectionChanged() {
|
|||||||
|
|
||||||
bool PlaylistContainer::eventFilter(QObject *objectWatched, QEvent *event) {
|
bool PlaylistContainer::eventFilter(QObject *objectWatched, QEvent *event) {
|
||||||
|
|
||||||
if (objectWatched == ui_->filter) {
|
if (objectWatched == ui_->search_field) {
|
||||||
if (event->type() == QEvent::KeyPress) {
|
if (event->type() == QEvent::KeyPress) {
|
||||||
QKeyEvent *e = static_cast<QKeyEvent*>(event);
|
QKeyEvent *e = static_cast<QKeyEvent*>(event);
|
||||||
switch (e->key()) {
|
switch (e->key()) {
|
||||||
@ -508,7 +505,7 @@ bool PlaylistContainer::eventFilter(QObject *objectWatched, QEvent *event) {
|
|||||||
QApplication::sendEvent(ui_->playlist, event);
|
QApplication::sendEvent(ui_->playlist, event);
|
||||||
return true;
|
return true;
|
||||||
case Qt::Key_Escape:
|
case Qt::Key_Escape:
|
||||||
ui_->filter->clear();
|
ui_->search_field->clear();
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -143,7 +143,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QSearchField" name="filter" native="true"/>
|
<widget class="QSearchField" name="search_field" native="true"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QRegularExpression>
|
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
@ -66,6 +65,7 @@ PlaylistFilter::PlaylistFilter(QObject *parent)
|
|||||||
<< Playlist::Column_Samplerate
|
<< Playlist::Column_Samplerate
|
||||||
<< Playlist::Column_Bitdepth
|
<< Playlist::Column_Bitdepth
|
||||||
<< Playlist::Column_Bitrate;
|
<< Playlist::Column_Bitrate;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PlaylistFilter::~PlaylistFilter() = default;
|
PlaylistFilter::~PlaylistFilter() = default;
|
||||||
@ -78,19 +78,13 @@ void PlaylistFilter::sort(int column, Qt::SortOrder order) {
|
|||||||
bool PlaylistFilter::filterAcceptsRow(int row, const QModelIndex &parent) const {
|
bool PlaylistFilter::filterAcceptsRow(int row, const QModelIndex &parent) const {
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
QString filter = filterRegularExpression().pattern().remove('\\');
|
size_t hash = qHash(filter_text_);
|
||||||
#else
|
#else
|
||||||
QString filter = filterRegExp().pattern();
|
uint hash = qHash(filter_text_);
|
||||||
#endif
|
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
size_t hash = qHash(filter);
|
|
||||||
#else
|
|
||||||
uint hash = qHash(filter);
|
|
||||||
#endif
|
#endif
|
||||||
if (hash != query_hash_) {
|
if (hash != query_hash_) {
|
||||||
// Parse the query
|
// Parse the query
|
||||||
FilterParser p(filter, column_names_, numerical_columns_);
|
FilterParser p(filter_text_, column_names_, numerical_columns_);
|
||||||
filter_tree_.reset(p.parse());
|
filter_tree_.reset(p.parse());
|
||||||
|
|
||||||
query_hash_ = hash;
|
query_hash_ = hash;
|
||||||
@ -100,3 +94,10 @@ bool PlaylistFilter::filterAcceptsRow(int row, const QModelIndex &parent) const
|
|||||||
return filter_tree_->accept(row, parent, sourceModel());
|
return filter_tree_->accept(row, parent, sourceModel());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlaylistFilter::SetFilterText(const QString &filter_text) {
|
||||||
|
|
||||||
|
filter_text_ = filter_text;
|
||||||
|
setFilterFixedString(filter_text);
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -48,6 +48,10 @@ class PlaylistFilter : public QSortFilterProxyModel {
|
|||||||
// public so Playlist::NextVirtualIndex and friends can get at it
|
// public so Playlist::NextVirtualIndex and friends can get at it
|
||||||
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
|
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
|
||||||
|
|
||||||
|
void SetFilterText(const QString &filter_text);
|
||||||
|
|
||||||
|
QString filter_text() const { return filter_text_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Mutable because they're modified from filterAcceptsRow() const
|
// Mutable because they're modified from filterAcceptsRow() const
|
||||||
mutable QScopedPointer<FilterTree> filter_tree_;
|
mutable QScopedPointer<FilterTree> filter_tree_;
|
||||||
@ -59,6 +63,7 @@ class PlaylistFilter : public QSortFilterProxyModel {
|
|||||||
|
|
||||||
QMap<QString, int> column_names_;
|
QMap<QString, int> column_names_;
|
||||||
QSet<int> numerical_columns_;
|
QSet<int> numerical_columns_;
|
||||||
|
QString filter_text_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PLAYLISTFILTER_H
|
#endif // PLAYLISTFILTER_H
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QAbstractItemView>
|
#include <QAbstractItemView>
|
||||||
#include <QItemSelectionModel>
|
#include <QItemSelectionModel>
|
||||||
#include <QSortFilterProxyModel>
|
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
@ -75,6 +74,7 @@
|
|||||||
#include "playlistdelegates.h"
|
#include "playlistdelegates.h"
|
||||||
#include "playlistheader.h"
|
#include "playlistheader.h"
|
||||||
#include "playlistview.h"
|
#include "playlistview.h"
|
||||||
|
#include "playlistfilter.h"
|
||||||
#include "covermanager/currentalbumcoverloader.h"
|
#include "covermanager/currentalbumcoverloader.h"
|
||||||
#include "covermanager/albumcoverloaderresult.h"
|
#include "covermanager/albumcoverloaderresult.h"
|
||||||
#include "settings/appearancesettingspage.h"
|
#include "settings/appearancesettingspage.h"
|
||||||
@ -903,7 +903,7 @@ void PlaylistView::mousePressEvent(QMouseEvent *event) {
|
|||||||
QModelIndexList src_index_list;
|
QModelIndexList src_index_list;
|
||||||
for (const QModelIndex &i : selectedIndexes()) {
|
for (const QModelIndex &i : selectedIndexes()) {
|
||||||
if (i.data(Playlist::Role_CanSetRating).toBool()) {
|
if (i.data(Playlist::Role_CanSetRating).toBool()) {
|
||||||
src_index_list << playlist_->proxy()->mapToSource(i);
|
src_index_list << playlist_->filter()->mapToSource(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!src_index_list.isEmpty()) {
|
if (!src_index_list.isEmpty()) {
|
||||||
@ -912,7 +912,7 @@ void PlaylistView::mousePressEvent(QMouseEvent *event) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Update only this item rating
|
// Update only this item rating
|
||||||
playlist_->RateSong(playlist_->proxy()->mapToSource(idx), new_rating);
|
playlist_->RateSong(playlist_->filter()->mapToSource(idx), new_rating);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -965,7 +965,7 @@ void PlaylistView::JumpToCurrentlyPlayingTrack() {
|
|||||||
|
|
||||||
if (playlist_->current_row() == -1) return;
|
if (playlist_->current_row() == -1) return;
|
||||||
|
|
||||||
QModelIndex current = playlist_->proxy()->mapFromSource(playlist_->index(playlist_->current_row(), 0));
|
QModelIndex current = playlist_->filter()->mapFromSource(playlist_->index(playlist_->current_row(), 0));
|
||||||
if (!current.isValid()) return;
|
if (!current.isValid()) return;
|
||||||
|
|
||||||
if (visibleRegion().boundingRect().contains(visualRect(current))) return;
|
if (visibleRegion().boundingRect().contains(visualRect(current))) return;
|
||||||
@ -986,7 +986,7 @@ void PlaylistView::JumpToLastPlayedTrack() {
|
|||||||
|
|
||||||
if (playlist_->last_played_row() == -1) return;
|
if (playlist_->last_played_row() == -1) return;
|
||||||
|
|
||||||
QModelIndex last_played = playlist_->proxy()->mapFromSource(playlist_->index(playlist_->last_played_row(), 0));
|
QModelIndex last_played = playlist_->filter()->mapFromSource(playlist_->index(playlist_->last_played_row(), 0));
|
||||||
if (!last_played.isValid()) return;
|
if (!last_played.isValid()) return;
|
||||||
|
|
||||||
// Select last played song
|
// Select last played song
|
||||||
|
Loading…
x
Reference in New Issue
Block a user