From 6ea6628ff0f1a216b2701273b5680d6e24b28766 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Thu, 13 Jun 2013 10:23:19 +0200 Subject: [PATCH] * Implemented Flexible(Tree)View's isBeingPlayed(). --- src/libtomahawk/playlist/FlexibleTreeView.cpp | 19 +++++++++++++++++++ src/libtomahawk/playlist/FlexibleTreeView.h | 1 + src/libtomahawk/playlist/FlexibleView.cpp | 17 +++++++++++++++++ src/libtomahawk/playlist/FlexibleView.h | 1 + 4 files changed, 38 insertions(+) diff --git a/src/libtomahawk/playlist/FlexibleTreeView.cpp b/src/libtomahawk/playlist/FlexibleTreeView.cpp index 58163ea4f..da0dc0c43 100644 --- a/src/libtomahawk/playlist/FlexibleTreeView.cpp +++ b/src/libtomahawk/playlist/FlexibleTreeView.cpp @@ -22,6 +22,7 @@ #include #include +#include "audio/AudioEngine.h" #include "widgets/FilterHeader.h" #include "playlist/TreeModel.h" #include "playlist/ColumnView.h" @@ -53,6 +54,8 @@ FlexibleTreeView::FlexibleTreeView( QWidget* parent, QWidget* extraHeader ) m_treeView->proxyModel()->setStyle( PlayableProxyModel::Collection ); + m_treeView->proxyModel()->setPlaylistInterface( m_columnView->proxyModel()->playlistInterface() ); + // m_trackView->setPlaylistInterface( m_playlistInterface ); // m_columnView->setPlaylistInterface( m_trackView->proxyModel()->playlistInterface() ); // m_gridView->setPlaylistInterface( m_trackView->proxyModel()->playlistInterface() ); @@ -332,3 +335,19 @@ FlexibleTreeView::setTemporaryPage( bool b ) { m_temporary = b; } + + +bool +FlexibleTreeView::isBeingPlayed() const +{ + if ( !playlistInterface() ) + return false; + + if ( playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() ) + return true; + + if ( playlistInterface()->hasChildInterface( AudioEngine::instance()->currentTrackPlaylist() ) ) + return true; + + return false; +} diff --git a/src/libtomahawk/playlist/FlexibleTreeView.h b/src/libtomahawk/playlist/FlexibleTreeView.h index 1e1ec9471..2c671ae01 100644 --- a/src/libtomahawk/playlist/FlexibleTreeView.h +++ b/src/libtomahawk/playlist/FlexibleTreeView.h @@ -55,6 +55,7 @@ public: virtual bool showInfoBar() const { return false; } virtual bool jumpToCurrentTrack(); virtual bool isTemporaryPage() const; + virtual bool isBeingPlayed() const; void setTemporaryPage( bool b ); ColumnView* columnView() const { return m_columnView; } diff --git a/src/libtomahawk/playlist/FlexibleView.cpp b/src/libtomahawk/playlist/FlexibleView.cpp index 0be8861bd..24c7f8fc2 100644 --- a/src/libtomahawk/playlist/FlexibleView.cpp +++ b/src/libtomahawk/playlist/FlexibleView.cpp @@ -22,6 +22,7 @@ #include #include +#include "audio/AudioEngine.h" #include "widgets/FilterHeader.h" #include "playlist/ModeHeader.h" #include "playlist/PlayableModel.h" @@ -338,3 +339,19 @@ FlexibleView::setTemporaryPage( bool b ) { m_temporary = b; } + + +bool +FlexibleView::isBeingPlayed() const +{ + if ( !playlistInterface() ) + return false; + + if ( playlistInterface() == AudioEngine::instance()->currentTrackPlaylist() ) + return true; + + if ( playlistInterface()->hasChildInterface( AudioEngine::instance()->currentTrackPlaylist() ) ) + return true; + + return false; +} diff --git a/src/libtomahawk/playlist/FlexibleView.h b/src/libtomahawk/playlist/FlexibleView.h index bc367265b..ff78a03c9 100644 --- a/src/libtomahawk/playlist/FlexibleView.h +++ b/src/libtomahawk/playlist/FlexibleView.h @@ -53,6 +53,7 @@ public: virtual bool showInfoBar() const { return false; } virtual bool jumpToCurrentTrack(); virtual bool isTemporaryPage() const; + virtual bool isBeingPlayed() const; void setTemporaryPage( bool b ); TrackView* trackView() const { return m_trackView; }