diff --git a/src/playlist/playlistcontainer.cpp b/src/playlist/playlistcontainer.cpp index 8287db396..adf68e844 100644 --- a/src/playlist/playlistcontainer.cpp +++ b/src/playlist/playlistcontainer.cpp @@ -158,6 +158,7 @@ void PlaylistContainer::SetViewModel(Playlist* playlist) { view()->setModel(playlist->proxy()); view()->SetItemDelegates(manager_->library_backend()); view()->SetPlaylist(playlist); + view()->selectionModel()->select(manager_->current_selection(), QItemSelectionModel::ClearAndSelect); playlist->IgnoreSorting(false); connect(view()->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), diff --git a/src/playlist/playlistmanager.cpp b/src/playlist/playlistmanager.cpp index 97432157b..578a758b5 100644 --- a/src/playlist/playlistmanager.cpp +++ b/src/playlist/playlistmanager.cpp @@ -223,7 +223,7 @@ void PlaylistManager::UpdateSummaryText() { int selected = 0; // Get the length of the selected tracks - foreach (const QItemSelectionRange& range, current_selection_) { + foreach (const QItemSelectionRange& range, playlists_[current_id()].selection) { if (!range.isValid()) continue; @@ -251,8 +251,8 @@ void PlaylistManager::UpdateSummaryText() { emit SummaryTextChanged(summary); } -void PlaylistManager::SelectionChanged(const QItemSelection &selection) { - current_selection_ = selection; +void PlaylistManager::SelectionChanged(const QItemSelection& selection) { + playlists_[current_id()].selection = selection; UpdateSummaryText(); } diff --git a/src/playlist/playlistmanager.h b/src/playlist/playlistmanager.h index 4775a369a..050d23b31 100644 --- a/src/playlist/playlistmanager.h +++ b/src/playlist/playlistmanager.h @@ -47,6 +47,10 @@ public: Playlist* current() const { return playlist(current_id()); } Playlist* active() const { return playlist(active_id()); } + const QItemSelection& selection(int id) const { return playlists_[id].selection; } + const QItemSelection& current_selection() const { return selection(current_id()); } + const QItemSelection& active_selection() const { return selection(active_id()); } + QString name(int index) const { return playlists_[index].name; } void Init(LibraryBackend* library_backend, PlaylistBackend* playlist_backend, @@ -109,6 +113,7 @@ private: Data(Playlist* _p = NULL, const QString& _name = QString()) : p(_p), name(_name) {} Playlist* p; QString name; + QItemSelection selection; }; TaskManager* task_manager_; @@ -117,8 +122,6 @@ private: PlaylistSequence* sequence_; PlaylistParser* parser_; - QItemSelection current_selection_; - // key = id QMap playlists_;