1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-07 14:46:33 +02: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(); addSeparator();
if ( m_supportedActions & ActionMarkListened ) 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 ) if ( m_supportedActions & ActionDelete )
m_sigmap->setMapping( addAction( queries.count() > 1 ? tr( "&Remove Items" ) : tr( "&Remove Item" ) ), 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 void
Track::markAsListened() Track::markAsListened()
{ {
bool isUnlistened = false; if ( !isListened() )
foreach ( Tomahawk::SocialAction action, allSocialActions() )
{
if ( action.action == "Inbox" && action.value.toBool() == true )
{
isUnlistened = true;
break;
}
}
if ( isUnlistened )
{ {
DatabaseCommand_ModifyInboxEntry* cmd = new DatabaseCommand_ModifyInboxEntry( toQuery(), false ); DatabaseCommand_ModifyInboxEntry* cmd = new DatabaseCommand_ModifyInboxEntry( toQuery(), false );
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) ); Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
@@ -214,11 +204,29 @@ Track::markAsListened()
it->value = false; //listened! it->value = false; //listened!
} }
} }
m_trackData->blockSignals( true );
m_trackData->setAllSocialActions( actions ); //emits socialActionsLoaded which gets propagated here 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 void
Track::updateSortNames() Track::updateSortNames()
{ {

View File

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