From 41769da56724f2d9f75be2080ee84ff29972322f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20=C3=96nnerby?= Date: Thu, 14 Aug 2008 09:12:18 +0000 Subject: [PATCH] Started testing highlight of current position in tracklists. --- src/core/tracklist/IRandomAccess.h | 3 +++ src/core/tracklist/Standard.cpp | 4 ++++ src/cube/TracklistModel.cpp | 25 ++++++++++++++++++++++--- src/cube/TracklistModel.hpp | 3 +++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/core/tracklist/IRandomAccess.h b/src/core/tracklist/IRandomAccess.h index a7e22035f..f8c6110dd 100644 --- a/src/core/tracklist/IRandomAccess.h +++ b/src/core/tracklist/IRandomAccess.h @@ -94,6 +94,9 @@ namespace musik{ namespace core{ typedef sigslot::signal1&> TrackMetaEvent; TrackMetaEvent TrackMetaUpdated; + + typedef sigslot::signal2 PositionChangedEvent; + PositionChangedEvent PositionChanged; }; typedef boost::shared_ptr Ptr; diff --git a/src/core/tracklist/Standard.cpp b/src/core/tracklist/Standard.cpp index 30dc4775c..3bb4ccc3e 100644 --- a/src/core/tracklist/Standard.cpp +++ b/src/core/tracklist/Standard.cpp @@ -93,6 +93,7 @@ int Standard::Size(){ void Standard::SetCurrentPosition(int position){ + int lastPosition(this->currentPosition); if(position<-1){ this->currentPosition = -1; }else{ @@ -102,6 +103,9 @@ void Standard::SetCurrentPosition(int position){ this->currentPosition = position; } } + if(this->currentPosition!=lastPosition){ + this->PositionChanged(this->currentPosition,lastPosition); + } } diff --git a/src/cube/TracklistModel.cpp b/src/cube/TracklistModel.cpp index 944553ee9..546c3233e 100644 --- a/src/cube/TracklistModel.cpp +++ b/src/cube/TracklistModel.cpp @@ -45,12 +45,12 @@ #include #include +#include #include #include #include -#include - +#include using namespace musik::cube; @@ -58,6 +58,7 @@ using namespace musik::cube; ////////////////////////////////////////////////////////////////////////////// /*ctor*/ TracklistModel::TracklistModel(musik::core::Query::ListBase *connectedQuery,musik::core::tracklist::Ptr setTracklist) +: currentPosition(-1) { this->tracklist = setTracklist; @@ -66,7 +67,7 @@ using namespace musik::cube; this->tracklist->TracksUpdated.connect(this,&TracklistModel::OnTracks); this->tracklist->TrackMetaUpdated.connect(this,&TracklistModel::OnTrackMeta); -// this->tracklist->SetLibrary(musik::core::LibraryFactory::GetCurrentLibrary()); + this->tracklist->PositionChanged.connect(this,&TracklistModel::OnPositionChanged); this->ConnectToQuery(connectedQuery); } @@ -100,6 +101,9 @@ uistring TracklistModel::CellValueToString(int rowIndex, ColumnRef co result += boost::lexical_cast(duration); return win32cpp::Escape(result); break; + } + if(rowIndex==this->currentPosition){ + return win32cpp::Escape(value)+_T("***"); } return win32cpp::Escape(value); } @@ -131,3 +135,18 @@ void TracklistModel::ConnectToQuery(musik::core::Query::ListBase *connectedQuery this->tracklist->ConnectToQuery(*connectedQuery); } } + +void TracklistModel::OnPositionChanged(int activeRow,int oldActiveRow){ + if(!win32cpp::ApplicationThread::InMainThread()){ + win32cpp::ApplicationThread::Call2(this,&TracklistModel::OnPositionChanged,activeRow,oldActiveRow); + return; + } + + if(activeRow!=-1){ + this->InvalidateData(activeRow); + } + if(oldActiveRow!=-1){ + this->InvalidateData(oldActiveRow); + } + this->currentPosition = activeRow; +} diff --git a/src/cube/TracklistModel.hpp b/src/cube/TracklistModel.hpp index d8ea2249e..bcf19261b 100644 --- a/src/cube/TracklistModel.hpp +++ b/src/cube/TracklistModel.hpp @@ -79,6 +79,9 @@ public: virtual uistring CellValueToString(int rowIndex, ColumnRef column); // instance data protected: void OnTrackMeta(std::vector &trackPositions); protected: void OnTracks(bool cleared); +protected: void OnPositionChanged(int activeRow,int oldActiveRow); +protected: int currentPosition; + public: musik::core::tracklist::Ptr tracklist; // FIXME: no public fields! };