From 792211368b415655d8b0bdcd48fbd2f7a19bef26 Mon Sep 17 00:00:00 2001 From: emeric Date: Thu, 20 Nov 2014 23:09:22 +0100 Subject: [PATCH] PlayQueue: play/add the whole track list if no selection performed --- src/ui/audio/Audio.cpp | 8 ++++++++ src/ui/audio/PlayQueue.cpp | 2 +- src/ui/audio/TrackView.cpp | 18 ++++++++++++++++++ src/ui/audio/TrackView.hpp | 5 ++++- 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/ui/audio/Audio.cpp b/src/ui/audio/Audio.cpp index ec6e4b6e..779fde0f 100644 --- a/src/ui/audio/Audio.cpp +++ b/src/ui/audio/Audio.cpp @@ -140,6 +140,10 @@ _mediaPlayer(nullptr) std::vector trackIds; trackView->getSelectedTracks(trackIds); + // If nothing is selected, get the whole track list + if (trackIds.empty()) + trackView->getTracks(trackIds); + playQueue->clear(); playQueue->addTracks(trackIds); @@ -153,6 +157,10 @@ _mediaPlayer(nullptr) std::vector trackIds; trackView->getSelectedTracks(trackIds); + // If nothing is selected, get the whole track list + if (trackIds.empty()) + trackView->getTracks(trackIds); + playQueue->addTracks(trackIds); })); diff --git a/src/ui/audio/PlayQueue.cpp b/src/ui/audio/PlayQueue.cpp index 53c5ab96..eed0f68e 100644 --- a/src/ui/audio/PlayQueue.cpp +++ b/src/ui/audio/PlayQueue.cpp @@ -87,7 +87,7 @@ PlayQueue::addTracks(const std::vector& trackIds) _model->setData(dataRow, 0, track.id()); _model->setData(dataRow, 1, dataRow + 1); - _model->setData(dataRow, 2, track->getName()); + _model->setData(dataRow, 2, track->getArtist()->getName() + " - " + track->getName()); _model->setData(dataRow, 3, track->getDuration()); } } diff --git a/src/ui/audio/TrackView.cpp b/src/ui/audio/TrackView.cpp index a19ef372..93a6a89d 100644 --- a/src/ui/audio/TrackView.cpp +++ b/src/ui/audio/TrackView.cpp @@ -171,5 +171,23 @@ TrackView::getSelectedTracks(std::vector& track_ids) LMS_LOG(MOD_UI, SEV_DEBUG) << "Getting all selected tracks DONE..."; } +void +TrackView::getTracks(std::vector& trackIds) +{ + LMS_LOG(MOD_UI, SEV_DEBUG) << "Getting all tracks..."; + + for (int i = 0; i < _queryModel.rowCount(); ++i) + { + const ResultType& result = _queryModel.resultRow( i ); + + // Get the track part + Wt::Dbo::ptr track ( result.get<0>() ); + + trackIds.push_back(track.id()); + } + + LMS_LOG(MOD_UI, SEV_DEBUG) << "Getting all tracks done!"; +} + } // namespace UserInterface diff --git a/src/ui/audio/TrackView.hpp b/src/ui/audio/TrackView.hpp index fc662dff..0c0ca203 100644 --- a/src/ui/audio/TrackView.hpp +++ b/src/ui/audio/TrackView.hpp @@ -44,9 +44,12 @@ class TrackView : public Wt::WTableView, public Filter void getConstraint(Constraint& constraint) {} - // Get all the tracks that are currently displayed + // Get all the tracks that are currently selected void getSelectedTracks(std::vector& track_ids); + // Get all the tracks + void getTracks(std::vector& track_ids); + typedef Wt::Signal SigTrackDoubleClicked; SigTrackDoubleClicked& trackDoubleClicked() { return _sigTrackDoubleClicked; }