mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-31 11:35:24 +01:00
Add or load *all* selected library items, not just the one that you right clicked on. Fixes issue #366
This commit is contained in:
parent
5f92d652a9
commit
9b713c2ed9
@ -730,18 +730,21 @@ void LibraryModel::GetChildSongs(LibraryItem* item, QList<QUrl>* urls,
|
||||
}
|
||||
}
|
||||
|
||||
SongList LibraryModel::GetChildSongs(const QModelIndex& index) const {
|
||||
SongList LibraryModel::GetChildSongs(const QModelIndexList& indexes) const {
|
||||
QList<QUrl> dontcare;
|
||||
SongList ret;
|
||||
QSet<int> song_ids;
|
||||
|
||||
if (!index.isValid())
|
||||
return SongList();
|
||||
|
||||
GetChildSongs(IndexToItem(index), &dontcare, &ret, &song_ids);
|
||||
foreach (const QModelIndex& index, indexes) {
|
||||
GetChildSongs(IndexToItem(index), &dontcare, &ret, &song_ids);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
SongList LibraryModel::GetChildSongs(const QModelIndex &index) const {
|
||||
return GetChildSongs(QModelIndexList() << index);
|
||||
}
|
||||
|
||||
void LibraryModel::SetFilterAge(int age) {
|
||||
query_options_.max_age = age;
|
||||
Reset();
|
||||
|
@ -87,6 +87,7 @@ class LibraryModel : public SimpleTreeModel<LibraryItem> {
|
||||
void GetChildSongs(LibraryItem* item, QList<QUrl>* urls, SongList* songs,
|
||||
QSet<int>* song_ids) const;
|
||||
SongList GetChildSongs(const QModelIndex& index) const;
|
||||
SongList GetChildSongs(const QModelIndexList& indexes) const;
|
||||
|
||||
// QAbstractItemModel
|
||||
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
|
||||
|
@ -200,14 +200,14 @@ void LibraryView::Load() {
|
||||
if (!context_menu_index_.isValid())
|
||||
return;
|
||||
|
||||
emit Load(context_menu_index_);
|
||||
emit Load(selectedIndexes());
|
||||
}
|
||||
|
||||
void LibraryView::AddToPlaylist() {
|
||||
if (!context_menu_index_.isValid())
|
||||
return;
|
||||
|
||||
emit AddToPlaylist(context_menu_index_);
|
||||
emit AddToPlaylist(selectedIndexes());
|
||||
}
|
||||
|
||||
void LibraryView::keyboardSearch(const QString &search) {
|
||||
|
@ -49,8 +49,8 @@ class LibraryView : public AutoExpandingTreeView {
|
||||
|
||||
signals:
|
||||
void ShowConfigDialog();
|
||||
void Load(const QModelIndex& index);
|
||||
void AddToPlaylist(const QModelIndex& index);
|
||||
void Load(const QModelIndexList& indexes);
|
||||
void AddToPlaylist(const QModelIndexList& indexes);
|
||||
|
||||
protected:
|
||||
// QWidget
|
||||
|
@ -307,8 +307,8 @@ MainWindow::MainWindow(NetworkAccessManager* network, Engine::Type engine, QWidg
|
||||
|
||||
// Library connections
|
||||
connect(ui_->library_view, SIGNAL(doubleClicked(QModelIndex)), SLOT(LibraryItemDoubleClicked(QModelIndex)));
|
||||
connect(ui_->library_view, SIGNAL(Load(QModelIndex)), SLOT(LoadLibraryItemToPlaylist(QModelIndex)));
|
||||
connect(ui_->library_view, SIGNAL(AddToPlaylist(QModelIndex)), SLOT(AddLibraryItemToPlaylist(QModelIndex)));
|
||||
connect(ui_->library_view, SIGNAL(Load(QModelIndexList)), SLOT(LoadLibraryItemToPlaylist(QModelIndexList)));
|
||||
connect(ui_->library_view, SIGNAL(AddToPlaylist(QModelIndexList)), SLOT(AddLibraryItemToPlaylist(QModelIndexList)));
|
||||
connect(ui_->library_view, SIGNAL(ShowConfigDialog()), SLOT(ShowLibraryConfig()));
|
||||
connect(library_->model(), SIGNAL(TotalSongCountUpdated(int)), ui_->library_view, SLOT(TotalSongCountUpdated(int)));
|
||||
connect(library_, SIGNAL(ScanStarted()), SLOT(LibraryScanStarted()));
|
||||
@ -623,28 +623,32 @@ void MainWindow::PlayIndex(const QModelIndex& index) {
|
||||
player_->PlayAt(row, Engine::Manual, true);
|
||||
}
|
||||
|
||||
void MainWindow::LoadLibraryItemToPlaylist(const QModelIndex& index) {
|
||||
AddLibraryItemToPlaylist(true, index);
|
||||
void MainWindow::LoadLibraryItemToPlaylist(const QModelIndexList& indexes) {
|
||||
AddLibraryItemToPlaylist(true, indexes);
|
||||
}
|
||||
|
||||
void MainWindow::AddLibraryItemToPlaylist(const QModelIndex& index) {
|
||||
AddLibraryItemToPlaylist(false, index);
|
||||
void MainWindow::AddLibraryItemToPlaylist(const QModelIndexList& indexes) {
|
||||
AddLibraryItemToPlaylist(false, indexes);
|
||||
}
|
||||
|
||||
void MainWindow::LibraryItemDoubleClicked(const QModelIndex &index) {
|
||||
AddLibraryItemToPlaylist(autoclear_playlist_, index);
|
||||
AddLibraryItemToPlaylist(autoclear_playlist_, QModelIndexList() << index);
|
||||
}
|
||||
|
||||
void MainWindow::AddLibraryItemToPlaylist(bool clear_first, const QModelIndex& index) {
|
||||
QModelIndex idx = index;
|
||||
if (idx.model() == library_sort_model_)
|
||||
idx = library_sort_model_->mapToSource(idx);
|
||||
void MainWindow::AddLibraryItemToPlaylist(bool clear_first, const QModelIndexList& indexes) {
|
||||
QModelIndexList source_indexes;
|
||||
foreach (const QModelIndex& index, indexes) {
|
||||
if (index.model() == library_sort_model_)
|
||||
source_indexes << library_sort_model_->mapToSource(index);
|
||||
else
|
||||
source_indexes << index;
|
||||
}
|
||||
|
||||
if (clear_first)
|
||||
playlists_->ClearCurrent();
|
||||
|
||||
QModelIndex first_song = playlists_->current()->InsertLibraryItems(
|
||||
library_->model()->GetChildSongs(idx));
|
||||
library_->model()->GetChildSongs(source_indexes));
|
||||
|
||||
if (!playlists_->current()->proxy()->mapFromSource(first_song).isValid()) {
|
||||
// The first song doesn't match the filter, so don't play it
|
||||
|
@ -109,8 +109,8 @@ class MainWindow : public QMainWindow {
|
||||
void PlayIndex(const QModelIndex& index);
|
||||
void StopAfterCurrent();
|
||||
|
||||
void LoadLibraryItemToPlaylist(const QModelIndex& index);
|
||||
void AddLibraryItemToPlaylist(const QModelIndex& index);
|
||||
void LoadLibraryItemToPlaylist(const QModelIndexList& indexes);
|
||||
void AddLibraryItemToPlaylist(const QModelIndexList& indexes);
|
||||
void LibraryItemDoubleClicked(const QModelIndex& index);
|
||||
|
||||
void LoadFilesToPlaylist(const QList<QUrl>& urls);
|
||||
@ -147,7 +147,7 @@ class MainWindow : public QMainWindow {
|
||||
private:
|
||||
void SaveGeometry();
|
||||
void AddFilesToPlaylist(bool clear_first, const QList<QUrl>& urls);
|
||||
void AddLibraryItemToPlaylist(bool clear_first, const QModelIndex& index);
|
||||
void AddLibraryItemToPlaylist(bool clear_first, const QModelIndexList& indexes);
|
||||
|
||||
private:
|
||||
static const int kStateVersion;
|
||||
|
Loading…
x
Reference in New Issue
Block a user