mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 21:57:41 +02:00
CLean up some logic
This commit is contained in:
@@ -372,6 +372,10 @@ SourceTreeView::latchOn()
|
|||||||
void
|
void
|
||||||
SourceTreeView::playlistChanged( PlaylistInterface* newInterface )
|
SourceTreeView::playlistChanged( PlaylistInterface* newInterface )
|
||||||
{
|
{
|
||||||
|
// If we were latched on and changed, send the listening along stop
|
||||||
|
if ( m_latch.isNull() )
|
||||||
|
return;
|
||||||
|
|
||||||
const PlaylistInterface* pi = AudioEngine::instance()->playlist();
|
const PlaylistInterface* pi = AudioEngine::instance()->playlist();
|
||||||
bool listeningAlong = false;
|
bool listeningAlong = false;
|
||||||
source_ptr newSource;
|
source_ptr newSource;
|
||||||
@@ -386,26 +390,22 @@ SourceTreeView::playlistChanged( PlaylistInterface* newInterface )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we were latched on and changed, send the listening along stop
|
SourcePlaylistInterface* origsourcepi = dynamic_cast< SourcePlaylistInterface* >( m_latch.data() );
|
||||||
if ( !m_latch.isNull() )
|
Q_ASSERT( origsourcepi );
|
||||||
{
|
const source_ptr source = origsourcepi->source();
|
||||||
SourcePlaylistInterface* origsourcepi = dynamic_cast< SourcePlaylistInterface* >( m_latch.data() );
|
|
||||||
Q_ASSERT( origsourcepi );
|
|
||||||
const source_ptr source = origsourcepi->source();
|
|
||||||
|
|
||||||
// if we're currently listening along to the same source, no change
|
// if we're currently listening along to the same source, no change
|
||||||
if ( listeningAlong && ( !origsourcepi->source().isNull() && origsourcepi->source()->id() == newSource->id() ) )
|
if ( listeningAlong && ( !origsourcepi->source().isNull() && origsourcepi->source()->id() == newSource->id() ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DatabaseCommand_SocialAction* cmd = new DatabaseCommand_SocialAction();
|
DatabaseCommand_SocialAction* cmd = new DatabaseCommand_SocialAction();
|
||||||
cmd->setSource( SourceList::instance()->getLocal() );
|
cmd->setSource( SourceList::instance()->getLocal() );
|
||||||
cmd->setAction( "latchOff");
|
cmd->setAction( "latchOff");
|
||||||
cmd->setComment( source->userName() );
|
cmd->setComment( source->userName() );
|
||||||
cmd->setTimestamp( QDateTime::currentDateTime().toTime_t() );
|
cmd->setTimestamp( QDateTime::currentDateTime().toTime_t() );
|
||||||
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
||||||
|
|
||||||
m_latch.clear();
|
m_latch.clear();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Reference in New Issue
Block a user