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;
|
QList<QUrl> dontcare;
|
||||||
SongList ret;
|
SongList ret;
|
||||||
QSet<int> song_ids;
|
QSet<int> song_ids;
|
||||||
|
|
||||||
if (!index.isValid())
|
foreach (const QModelIndex& index, indexes) {
|
||||||
return SongList();
|
|
||||||
|
|
||||||
GetChildSongs(IndexToItem(index), &dontcare, &ret, &song_ids);
|
GetChildSongs(IndexToItem(index), &dontcare, &ret, &song_ids);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SongList LibraryModel::GetChildSongs(const QModelIndex &index) const {
|
||||||
|
return GetChildSongs(QModelIndexList() << index);
|
||||||
|
}
|
||||||
|
|
||||||
void LibraryModel::SetFilterAge(int age) {
|
void LibraryModel::SetFilterAge(int age) {
|
||||||
query_options_.max_age = age;
|
query_options_.max_age = age;
|
||||||
Reset();
|
Reset();
|
||||||
|
@ -87,6 +87,7 @@ class LibraryModel : public SimpleTreeModel<LibraryItem> {
|
|||||||
void GetChildSongs(LibraryItem* item, QList<QUrl>* urls, SongList* songs,
|
void GetChildSongs(LibraryItem* item, QList<QUrl>* urls, SongList* songs,
|
||||||
QSet<int>* song_ids) const;
|
QSet<int>* song_ids) const;
|
||||||
SongList GetChildSongs(const QModelIndex& index) const;
|
SongList GetChildSongs(const QModelIndex& index) const;
|
||||||
|
SongList GetChildSongs(const QModelIndexList& indexes) const;
|
||||||
|
|
||||||
// QAbstractItemModel
|
// QAbstractItemModel
|
||||||
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
|
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
|
||||||
|
@ -200,14 +200,14 @@ void LibraryView::Load() {
|
|||||||
if (!context_menu_index_.isValid())
|
if (!context_menu_index_.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
emit Load(context_menu_index_);
|
emit Load(selectedIndexes());
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryView::AddToPlaylist() {
|
void LibraryView::AddToPlaylist() {
|
||||||
if (!context_menu_index_.isValid())
|
if (!context_menu_index_.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
emit AddToPlaylist(context_menu_index_);
|
emit AddToPlaylist(selectedIndexes());
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryView::keyboardSearch(const QString &search) {
|
void LibraryView::keyboardSearch(const QString &search) {
|
||||||
|
@ -49,8 +49,8 @@ class LibraryView : public AutoExpandingTreeView {
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void ShowConfigDialog();
|
void ShowConfigDialog();
|
||||||
void Load(const QModelIndex& index);
|
void Load(const QModelIndexList& indexes);
|
||||||
void AddToPlaylist(const QModelIndex& index);
|
void AddToPlaylist(const QModelIndexList& indexes);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// QWidget
|
// QWidget
|
||||||
|
@ -307,8 +307,8 @@ MainWindow::MainWindow(NetworkAccessManager* network, Engine::Type engine, QWidg
|
|||||||
|
|
||||||
// Library connections
|
// Library connections
|
||||||
connect(ui_->library_view, SIGNAL(doubleClicked(QModelIndex)), SLOT(LibraryItemDoubleClicked(QModelIndex)));
|
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(Load(QModelIndexList)), SLOT(LoadLibraryItemToPlaylist(QModelIndexList)));
|
||||||
connect(ui_->library_view, SIGNAL(AddToPlaylist(QModelIndex)), SLOT(AddLibraryItemToPlaylist(QModelIndex)));
|
connect(ui_->library_view, SIGNAL(AddToPlaylist(QModelIndexList)), SLOT(AddLibraryItemToPlaylist(QModelIndexList)));
|
||||||
connect(ui_->library_view, SIGNAL(ShowConfigDialog()), SLOT(ShowLibraryConfig()));
|
connect(ui_->library_view, SIGNAL(ShowConfigDialog()), SLOT(ShowLibraryConfig()));
|
||||||
connect(library_->model(), SIGNAL(TotalSongCountUpdated(int)), ui_->library_view, SLOT(TotalSongCountUpdated(int)));
|
connect(library_->model(), SIGNAL(TotalSongCountUpdated(int)), ui_->library_view, SLOT(TotalSongCountUpdated(int)));
|
||||||
connect(library_, SIGNAL(ScanStarted()), SLOT(LibraryScanStarted()));
|
connect(library_, SIGNAL(ScanStarted()), SLOT(LibraryScanStarted()));
|
||||||
@ -623,28 +623,32 @@ void MainWindow::PlayIndex(const QModelIndex& index) {
|
|||||||
player_->PlayAt(row, Engine::Manual, true);
|
player_->PlayAt(row, Engine::Manual, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::LoadLibraryItemToPlaylist(const QModelIndex& index) {
|
void MainWindow::LoadLibraryItemToPlaylist(const QModelIndexList& indexes) {
|
||||||
AddLibraryItemToPlaylist(true, index);
|
AddLibraryItemToPlaylist(true, indexes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::AddLibraryItemToPlaylist(const QModelIndex& index) {
|
void MainWindow::AddLibraryItemToPlaylist(const QModelIndexList& indexes) {
|
||||||
AddLibraryItemToPlaylist(false, index);
|
AddLibraryItemToPlaylist(false, indexes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::LibraryItemDoubleClicked(const QModelIndex &index) {
|
void MainWindow::LibraryItemDoubleClicked(const QModelIndex &index) {
|
||||||
AddLibraryItemToPlaylist(autoclear_playlist_, index);
|
AddLibraryItemToPlaylist(autoclear_playlist_, QModelIndexList() << index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::AddLibraryItemToPlaylist(bool clear_first, const QModelIndex& index) {
|
void MainWindow::AddLibraryItemToPlaylist(bool clear_first, const QModelIndexList& indexes) {
|
||||||
QModelIndex idx = index;
|
QModelIndexList source_indexes;
|
||||||
if (idx.model() == library_sort_model_)
|
foreach (const QModelIndex& index, indexes) {
|
||||||
idx = library_sort_model_->mapToSource(idx);
|
if (index.model() == library_sort_model_)
|
||||||
|
source_indexes << library_sort_model_->mapToSource(index);
|
||||||
|
else
|
||||||
|
source_indexes << index;
|
||||||
|
}
|
||||||
|
|
||||||
if (clear_first)
|
if (clear_first)
|
||||||
playlists_->ClearCurrent();
|
playlists_->ClearCurrent();
|
||||||
|
|
||||||
QModelIndex first_song = playlists_->current()->InsertLibraryItems(
|
QModelIndex first_song = playlists_->current()->InsertLibraryItems(
|
||||||
library_->model()->GetChildSongs(idx));
|
library_->model()->GetChildSongs(source_indexes));
|
||||||
|
|
||||||
if (!playlists_->current()->proxy()->mapFromSource(first_song).isValid()) {
|
if (!playlists_->current()->proxy()->mapFromSource(first_song).isValid()) {
|
||||||
// The first song doesn't match the filter, so don't play it
|
// 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 PlayIndex(const QModelIndex& index);
|
||||||
void StopAfterCurrent();
|
void StopAfterCurrent();
|
||||||
|
|
||||||
void LoadLibraryItemToPlaylist(const QModelIndex& index);
|
void LoadLibraryItemToPlaylist(const QModelIndexList& indexes);
|
||||||
void AddLibraryItemToPlaylist(const QModelIndex& index);
|
void AddLibraryItemToPlaylist(const QModelIndexList& indexes);
|
||||||
void LibraryItemDoubleClicked(const QModelIndex& index);
|
void LibraryItemDoubleClicked(const QModelIndex& index);
|
||||||
|
|
||||||
void LoadFilesToPlaylist(const QList<QUrl>& urls);
|
void LoadFilesToPlaylist(const QList<QUrl>& urls);
|
||||||
@ -147,7 +147,7 @@ class MainWindow : public QMainWindow {
|
|||||||
private:
|
private:
|
||||||
void SaveGeometry();
|
void SaveGeometry();
|
||||||
void AddFilesToPlaylist(bool clear_first, const QList<QUrl>& urls);
|
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:
|
private:
|
||||||
static const int kStateVersion;
|
static const int kStateVersion;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user