From cd328eca08d3d82c8438ecc8cec25c8b75fc424e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20=C3=96nnerby?= Date: Fri, 18 Apr 2008 12:55:37 +0000 Subject: [PATCH] "Now Playing" playlist (visual) working. --- src/core/PlaybackQueue.cpp | 2 +- src/core/PlaybackQueue.h | 4 ++-- src/core/tracklist/IRandomAccess.h | 1 + src/core/tracklist/Standard.cpp | 18 ++++++++++++------ src/core/tracklist/Standard.h | 14 ++++++-------- src/cube/SourcesModel.cpp | 4 +++- src/cube/TracklistController.cpp | 4 ++-- src/cube/TracklistController.hpp | 3 ++- src/cube/TracklistModel.cpp | 9 +++++++-- src/cube/TracklistModel.hpp | 2 +- 10 files changed, 37 insertions(+), 24 deletions(-) diff --git a/src/core/PlaybackQueue.cpp b/src/core/PlaybackQueue.cpp index 3e90c84ff..661f1cfdf 100644 --- a/src/core/PlaybackQueue.cpp +++ b/src/core/PlaybackQueue.cpp @@ -65,7 +65,7 @@ void PlaybackQueue::OnPlaybackEndOrFail(){ } } -tracklist::IRandomAccessPtr PlaybackQueue::NowPlayingTracklist(){ +tracklist::Standard::Ptr PlaybackQueue::NowPlayingTracklist(){ return this->nowPlaying; } diff --git a/src/core/PlaybackQueue.h b/src/core/PlaybackQueue.h index fa55af649..a13e60c74 100644 --- a/src/core/PlaybackQueue.h +++ b/src/core/PlaybackQueue.h @@ -52,7 +52,7 @@ class PlaybackQueue : public sigslot::has_slots<>{ static PlaybackQueue sInstance; audio::Transport transport; - tracklist::IRandomAccessPtr nowPlaying; + tracklist::Standard::Ptr nowPlaying; bool playing; @@ -61,7 +61,7 @@ class PlaybackQueue : public sigslot::has_slots<>{ static PlaybackQueue& Instance(){ return sInstance; }; // Now Playing control - tracklist::IRandomAccessPtr NowPlayingTracklist(); + tracklist::Standard::Ptr NowPlayingTracklist(); void Play(tracklist::IRandomAccess &tracklist); void Append(tracklist::IRandomAccess &tracklist); diff --git a/src/core/tracklist/IRandomAccess.h b/src/core/tracklist/IRandomAccess.h index d52c69d9a..c1b643c25 100644 --- a/src/core/tracklist/IRandomAccess.h +++ b/src/core/tracklist/IRandomAccess.h @@ -57,6 +57,7 @@ namespace musik{ namespace core{ virtual void AppendTracks(musik::core::tracklist::IRandomAccess &tracklist) = 0; virtual musik::core::TrackPtr Track(int position)=0; + }; typedef boost::shared_ptr IRandomAccessPtr; diff --git a/src/core/tracklist/Standard.cpp b/src/core/tracklist/Standard.cpp index b01254449..617802836 100644 --- a/src/core/tracklist/Standard.cpp +++ b/src/core/tracklist/Standard.cpp @@ -223,13 +223,17 @@ void Standard::RemoveRequestedMetakey(const char* metakey){ } void Standard::CopyTracks(musik::core::tracklist::IRandomAccess &tracklist){ - this->SetLibrary(tracklist.Library()); - this->tracks.clear(); - this->tracks.reserve(tracklist.Size()); - for(int i(0);itracks.push_back(tracklist.Track(i)->Copy()); + if(this!=&tracklist){ // Do not copy to itself + this->SetLibrary(tracklist.Library()); + this->tracks.clear(); + this->tracks.reserve(tracklist.Size()); + for(int i(0);itracks.push_back(tracklist.Track(i)->Copy()); + } + this->SetCurrentPosition(tracklist.CurrentPosition()); + + this->OnTracks(true); } - this->SetCurrentPosition(tracklist.CurrentPosition()); } void Standard::AppendTracks(musik::core::tracklist::IRandomAccess &tracklist){ @@ -242,6 +246,8 @@ void Standard::AppendTracks(musik::core::tracklist::IRandomAccess &tracklist){ for(int i(0);itracks.push_back(tracklist.Track(i)->Copy()); } + + this->OnTracks(false); } diff --git a/src/core/tracklist/Standard.h b/src/core/tracklist/Standard.h index 6e86ece8a..1ac548a8f 100644 --- a/src/core/tracklist/Standard.h +++ b/src/core/tracklist/Standard.h @@ -79,14 +79,6 @@ namespace musik{ namespace core{ void SetLibrary(musik::core::LibraryPtr setLibrary); musik::core::LibraryPtr Library(); - - typedef sigslot::signal1 TracksEvent; - TracksEvent OnTracks; - - typedef sigslot::signal1&> TrackMetaEvent; - TrackMetaEvent OnTrackMeta; - - void HintNumberOfRows(int rows); void AddRequestedMetakey(const char* metakey); @@ -94,6 +86,12 @@ namespace musik{ namespace core{ void CopyTracks(musik::core::tracklist::IRandomAccess &tracklist); void AppendTracks(musik::core::tracklist::IRandomAccess &tracklist); + + typedef sigslot::signal1 TracksEvent; + TracksEvent OnTracks; + typedef sigslot::signal1&> TrackMetaEvent; + TrackMetaEvent OnTrackMeta; + protected: musik::core::TrackPtr Track(int position); diff --git a/src/cube/SourcesModel.cpp b/src/cube/SourcesModel.cpp index 5b9c781b6..b6315d3cd 100644 --- a/src/cube/SourcesModel.cpp +++ b/src/cube/SourcesModel.cpp @@ -43,6 +43,8 @@ #include #include +#include + using namespace musik::cube; ////////////////////////////////////////////////////////////////////////////// @@ -110,7 +112,7 @@ private: BrowseController controller; class NowPlayingItem: public SourcesItem { private: /*ctor*/ NowPlayingItem() - : controller(view) + : controller(view,NULL,musik::core::PlaybackQueue::Instance().NowPlayingTracklist()) { } diff --git a/src/cube/TracklistController.cpp b/src/cube/TracklistController.cpp index 9a336efd9..15806502a 100644 --- a/src/cube/TracklistController.cpp +++ b/src/cube/TracklistController.cpp @@ -47,9 +47,9 @@ using namespace musik::cube; ////////////////////////////////////////////////////////////////////////////// -/*ctor*/ TracklistController::TracklistController(TracklistView& view,musik::core::Query::ListBase *connectedQuery) +/*ctor*/ TracklistController::TracklistController(TracklistView& view,musik::core::Query::ListBase *connectedQuery,musik::core::tracklist::Standard::Ptr tracklist) : view(view) -, model(new TracklistModel(connectedQuery)) +, model(new TracklistModel(connectedQuery,tracklist)) { this->view.Handle() ? this->OnViewCreated() diff --git a/src/cube/TracklistController.hpp b/src/cube/TracklistController.hpp index e41e07f88..b1014463f 100644 --- a/src/cube/TracklistController.hpp +++ b/src/cube/TracklistController.hpp @@ -45,6 +45,7 @@ #include #include #include +#include ////////////////////////////////////////////////////////////////////////////// @@ -62,7 +63,7 @@ private: typedef ListView::ColumnRef ColumnRef; private: typedef std::vector ColumnList; private: typedef ListView::ModelRef ModelRef; -public: /*ctor*/ TracklistController(TracklistView& listView,musik::core::Query::ListBase *connectedQuery=NULL); +public: /*ctor*/ TracklistController(TracklistView& listView,musik::core::Query::ListBase *connectedQuery=NULL,musik::core::tracklist::Standard::Ptr tracklist=musik::core::tracklist::Standard::Ptr() ); protected: void OnViewCreated(); protected: void OnResized(Size size); diff --git a/src/cube/TracklistModel.cpp b/src/cube/TracklistModel.cpp index 41ad4b98d..07cf4a9e8 100644 --- a/src/cube/TracklistModel.cpp +++ b/src/cube/TracklistModel.cpp @@ -52,9 +52,14 @@ using namespace musik::cube; ////////////////////////////////////////////////////////////////////////////// -/*ctor*/ TracklistModel::TracklistModel(musik::core::Query::ListBase *connectedQuery) : - tracklist(new musik::core::tracklist::Standard()) +/*ctor*/ TracklistModel::TracklistModel(musik::core::Query::ListBase *connectedQuery,musik::core::tracklist::Standard::Ptr setTracklist) { + if(setTracklist){ + this->tracklist = setTracklist; + }else{ + this->tracklist.reset( new musik::core::tracklist::Standard() ); + } + this->SetRowCount(0); this->tracklist->OnTracks.connect(this,&TracklistModel::OnTracks); diff --git a/src/cube/TracklistModel.hpp b/src/cube/TracklistModel.hpp index 98c3bf2a3..aa5b0405a 100644 --- a/src/cube/TracklistModel.hpp +++ b/src/cube/TracklistModel.hpp @@ -59,7 +59,7 @@ public: typedef ListView::CellRendererRef CellRendererRef; public: typedef ListView::ColumnRef ColumnRef; // public API -public: /*ctor*/ TracklistModel(musik::core::Query::ListBase *connectedQuery); +public: /*ctor*/ TracklistModel(musik::core::Query::ListBase *connectedQuery,musik::core::tracklist::Standard::Ptr setTracklist); // ListView::Model implementation public: virtual uistring CellValueToString(int rowIndex, ColumnRef column);