diff --git a/src/libtomahawk/ContextMenu.cpp b/src/libtomahawk/ContextMenu.cpp index 6945b878e..f62e272cd 100644 --- a/src/libtomahawk/ContextMenu.cpp +++ b/src/libtomahawk/ContextMenu.cpp @@ -215,7 +215,20 @@ ContextMenu::setQueries( const QList& queries ) addSeparator(); if ( m_supportedActions & ActionMarkListened ) - m_sigmap->setMapping( addAction( tr( "Mark as &Listened" ) ), ActionMarkListened ); + { + bool thereAreUnlistenedTracks = false; + foreach ( const Tomahawk::query_ptr& query, m_queries ) + { + if ( !query->queryTrack()->isListened() ) + { + thereAreUnlistenedTracks = true; + break; + } + } + + if ( thereAreUnlistenedTracks ) + m_sigmap->setMapping( addAction( tr( "Mark as &Listened" ) ), ActionMarkListened ); + } if ( m_supportedActions & ActionDelete ) m_sigmap->setMapping( addAction( queries.count() > 1 ? tr( "&Remove Items" ) : tr( "&Remove Item" ) ), ActionDelete ); diff --git a/src/libtomahawk/Track.cpp b/src/libtomahawk/Track.cpp index eefb1d209..68dedd118 100644 --- a/src/libtomahawk/Track.cpp +++ b/src/libtomahawk/Track.cpp @@ -189,17 +189,7 @@ Track::finishPlaying( int timeElapsed ) void Track::markAsListened() { - bool isUnlistened = false; - foreach ( Tomahawk::SocialAction action, allSocialActions() ) - { - if ( action.action == "Inbox" && action.value.toBool() == true ) - { - isUnlistened = true; - break; - } - } - - if ( isUnlistened ) + if ( !isListened() ) { DatabaseCommand_ModifyInboxEntry* cmd = new DatabaseCommand_ModifyInboxEntry( toQuery(), false ); Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) ); @@ -214,11 +204,29 @@ Track::markAsListened() it->value = false; //listened! } } + m_trackData->blockSignals( true ); m_trackData->setAllSocialActions( actions ); //emits socialActionsLoaded which gets propagated here + m_trackData->blockSignals( false ); } } +bool +Track::isListened() const +{ + bool isUnlistened = false; + foreach ( Tomahawk::SocialAction action, allSocialActions() ) + { + if ( action.action == "Inbox" && action.value.toBool() == true ) + { + isUnlistened = true; + break; + } + } + return !isUnlistened; +} + + void Track::updateSortNames() { diff --git a/src/libtomahawk/Track.h b/src/libtomahawk/Track.h index ac01a2933..324f2714a 100644 --- a/src/libtomahawk/Track.h +++ b/src/libtomahawk/Track.h @@ -114,7 +114,9 @@ public: void startPlaying(); void finishPlaying( int timeElapsed ); + void markAsListened(); + bool isListened() const; signals: void coverChanged();