From fa0eaee3c8e3fc0215563fa2745952204f2ecb5d Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Tue, 4 Dec 2012 03:13:46 +0100 Subject: [PATCH] * Prev/next check is now provided by PlaylistInterface. --- .../PlayableProxyModelPlaylistInterface.cpp | 56 ++----------------- .../PlayableProxyModelPlaylistInterface.h | 6 -- 2 files changed, 5 insertions(+), 57 deletions(-) diff --git a/src/libtomahawk/playlist/PlayableProxyModelPlaylistInterface.cpp b/src/libtomahawk/playlist/PlayableProxyModelPlaylistInterface.cpp index 02e5f6772..369fd30b8 100644 --- a/src/libtomahawk/playlist/PlayableProxyModelPlaylistInterface.cpp +++ b/src/libtomahawk/playlist/PlayableProxyModelPlaylistInterface.cpp @@ -35,13 +35,10 @@ PlayableProxyModelPlaylistInterface::PlayableProxyModelPlaylistInterface( Playab , m_proxyModel( proxyModel ) , m_repeatMode( PlaylistModes::NoRepeat ) , m_shuffled( false ) - , m_prevAvail( false ) - , m_nextAvail( false ) { - connect( proxyModel, SIGNAL( currentIndexChanged() ), SLOT( onModelChanged() ) ); - connect( proxyModel, SIGNAL( indexPlayable( QModelIndex ) ), SLOT( onModelChanged() ) ); - connect( proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onModelChanged() ) ); - connect( proxyModel, SIGNAL( itemCountChanged( unsigned int ) ), SLOT( onModelChanged() ) ); + connect( proxyModel, SIGNAL( indexPlayable( QModelIndex ) ), SLOT( onItemsChanged() ) ); + connect( proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onItemsChanged() ) ); + connect( proxyModel, SIGNAL( itemCountChanged( unsigned int ) ), SLOT( onItemsChanged() ) ); } @@ -66,51 +63,6 @@ PlayableProxyModelPlaylistInterface::filter() const } -void -PlayableProxyModelPlaylistInterface::onModelChanged() -{ - if ( QThread::currentThread() != thread() ) - { - tDebug() << Q_FUNC_INFO << "Reinvoking in correct thread!"; - QMetaObject::invokeMethod( this, "onModelChanged", Qt::QueuedConnection ); - return; - } - - Tomahawk::result_ptr prevResult = siblingResult( -1 ); - Tomahawk::result_ptr nextResult = siblingResult( 1 ); - - if ( prevResult ) - { - bool avail = prevResult->toQuery()->playable(); - if ( avail != m_prevAvail ) - { - m_prevAvail = avail; - emit previousTrackAvailable(); - } - } - else if ( m_prevAvail ) - { - m_prevAvail = false; - emit previousTrackAvailable(); - } - - if ( nextResult ) - { - bool avail = nextResult->toQuery()->playable(); - if ( avail != m_nextAvail ) - { - m_nextAvail = avail; - emit nextTrackAvailable(); - } - } - else if ( m_nextAvail ) - { - m_nextAvail = false; - emit nextTrackAvailable(); - } -} - - QList< Tomahawk::query_ptr > PlayableProxyModelPlaylistInterface::tracks() const { @@ -138,6 +90,8 @@ PlayableProxyModelPlaylistInterface::setCurrentIndex( qint64 index ) if ( m_proxyModel.isNull() ) return; + PlaylistInterface::setCurrentIndex( index ); + PlayableItem* item = static_cast( (void*)index ); if ( index < 0 || !item ) { diff --git a/src/libtomahawk/playlist/PlayableProxyModelPlaylistInterface.h b/src/libtomahawk/playlist/PlayableProxyModelPlaylistInterface.h index e3f51bc83..7b6d50d11 100644 --- a/src/libtomahawk/playlist/PlayableProxyModelPlaylistInterface.h +++ b/src/libtomahawk/playlist/PlayableProxyModelPlaylistInterface.h @@ -65,9 +65,6 @@ signals: void previousTrackAvailable(); void nextTrackAvailable(); -private slots: - virtual void onModelChanged(); - protected: QWeakPointer< PlayableProxyModel > m_proxyModel; @@ -75,9 +72,6 @@ protected: bool m_shuffled; mutable QList< Tomahawk::query_ptr > m_shuffleHistory; mutable QPersistentModelIndex m_shuffleCache; - - mutable bool m_prevAvail; - mutable bool m_nextAvail; }; } //ns