From f0f9e6847b936ffa516b2aa4b2d3ebc5e2e3881b Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser <muesli@gmail.com> Date: Sat, 31 Mar 2012 06:38:38 +0200 Subject: [PATCH] * Make stop-after-track better. --- src/audiocontrols.cpp | 2 +- src/libtomahawk/audio/audioengine.cpp | 4 ++-- src/libtomahawk/contextmenu.cpp | 3 ++- src/libtomahawk/query.cpp | 13 ++++++++++++- src/libtomahawk/query.h | 2 ++ src/libtomahawk/result.h | 1 - 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/audiocontrols.cpp b/src/audiocontrols.cpp index ce907a11e..9b3807a0a 100644 --- a/src/audiocontrols.cpp +++ b/src/audiocontrols.cpp @@ -278,7 +278,7 @@ void AudioControls::onSocialActionsLoaded() { Query* query = qobject_cast< Query* >( sender() ); - if ( !query || !m_currentTrack || query != m_currentTrack->toQuery().data() ) + if ( !query || !m_currentTrack || !query->equals( m_currentTrack->toQuery() ) ) return; setSocialActions(); diff --git a/src/libtomahawk/audio/audioengine.cpp b/src/libtomahawk/audio/audioengine.cpp index 385891a0c..492c112bb 100644 --- a/src/libtomahawk/audio/audioengine.cpp +++ b/src/libtomahawk/audio/audioengine.cpp @@ -516,9 +516,9 @@ AudioEngine::loadNextTrack() Tomahawk::result_ptr result; - if ( !m_stopAfterTrack.isNull() && !m_currentTrack.isNull() ) + if ( !m_stopAfterTrack.isNull() ) { - if ( m_stopAfterTrack.data() == m_currentTrack->toQuery().data() ) + if ( m_stopAfterTrack->equals( m_currentTrack->toQuery() ) ) { m_stopAfterTrack.clear(); stop(); diff --git a/src/libtomahawk/contextmenu.cpp b/src/libtomahawk/contextmenu.cpp index b64dca517..fcba90360 100644 --- a/src/libtomahawk/contextmenu.cpp +++ b/src/libtomahawk/contextmenu.cpp @@ -1,3 +1,4 @@ + /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> === * * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org> @@ -220,7 +221,7 @@ ContextMenu::onTriggered( int action ) break; case ActionStopAfter: - if ( AudioEngine::instance()->stopAfterTrack() == m_queries.first() ) + if ( m_queries.first()->equals( AudioEngine::instance()->stopAfterTrack() ) ) AudioEngine::instance()->setStopAfterTrack( query_ptr() ); else AudioEngine::instance()->setStopAfterTrack( m_queries.first() ); diff --git a/src/libtomahawk/query.cpp b/src/libtomahawk/query.cpp index a381fc343..bd2310ee7 100644 --- a/src/libtomahawk/query.cpp +++ b/src/libtomahawk/query.cpp @@ -168,7 +168,6 @@ Query::addResults( const QList< Tomahawk::result_ptr >& newresults ) // hook up signals, and check solved status foreach( const result_ptr& rp, newresults ) { - rp->setQuery( q ); connect( rp.data(), SIGNAL( statusChanged() ), SLOT( onResultStatusChanged() ) ); } } @@ -413,6 +412,18 @@ Query::checkResults() } +bool +Query::equals( const Tomahawk::query_ptr& other ) const +{ + if ( other.isNull() ) + return false; + + return ( artist() == other->artist() && + album() == other->album() && + track() == other->track() ); +} + + QVariant Query::toVariant() const { diff --git a/src/libtomahawk/query.h b/src/libtomahawk/query.h index 0d8c6d1ce..724e53529 100644 --- a/src/libtomahawk/query.h +++ b/src/libtomahawk/query.h @@ -91,6 +91,8 @@ public: void setAlbumPos( unsigned int albumpos ) { m_albumpos = albumpos; } void setDiscNumber( unsigned int discnumber ) { m_discnumber = discnumber; } + bool equals( const Tomahawk::query_ptr& other ) const; + QVariant toVariant() const; QString toString() const; diff --git a/src/libtomahawk/result.h b/src/libtomahawk/result.h index 7c8d3925a..b15245342 100644 --- a/src/libtomahawk/result.h +++ b/src/libtomahawk/result.h @@ -85,7 +85,6 @@ public: int year() const { return m_year; } unsigned int discnumber() const { return m_discnumber; } - void setQuery( const Tomahawk::query_ptr& query ) { m_query = query; } void setScore( float score ) { m_score = score; } void setTrackId( unsigned int id ) { m_trackId = id; } void setFileId( unsigned int id ) { m_fileId = id; }