1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-13 20:39:57 +01:00

Only show the mark as listened action if unlistened tracks are selected.

This commit is contained in:
Teo Mrnjavac 2013-05-29 19:03:45 +02:00
parent 8ebd3d67e8
commit bcd1069d92
3 changed files with 35 additions and 12 deletions

View File

@ -215,7 +215,20 @@ ContextMenu::setQueries( const QList<Tomahawk::query_ptr>& 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 );

View File

@ -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()
{

View File

@ -113,7 +113,9 @@ public:
void startPlaying();
void finishPlaying( int timeElapsed );
void markAsListened();
bool isListened() const;
signals:
void coverChanged();