1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-20 07:49:42 +01:00

Better handling of sourcepli

This commit is contained in:
Leo Franchi 2011-09-20 11:09:28 -04:00
parent 6c9c3ce7ec
commit 337be1f989
2 changed files with 22 additions and 7 deletions

View File

@ -372,13 +372,31 @@ SourceTreeView::latchOn()
void
SourceTreeView::playlistChanged( PlaylistInterface* newInterface )
{
const PlaylistInterface* pi = AudioEngine::instance()->playlist();
bool listeningAlong = false;
source_ptr newSource;
if ( pi && dynamic_cast< const SourcePlaylistInterface* >( pi ) )
{
const SourcePlaylistInterface* sourcepi = dynamic_cast< const SourcePlaylistInterface* >( pi );
if ( !AudioEngine::instance()->state() == AudioEngine::Stopped )
{
listeningAlong = true;
newSource = sourcepi->source();
}
}
// If we were latched on and changed, send the listening along stop
if ( !m_latch.isNull() )
{
SourcePlaylistInterface* sourcepi = dynamic_cast< SourcePlaylistInterface* >( m_latch.data() );
Q_ASSERT( sourcepi );
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 ( listeningAlong && ( !origsourcepi->source().isNull() && origsourcepi->source()->id() == newSource->id() ) )
return;
const source_ptr source = sourcepi->source();
DatabaseCommand_SocialAction* cmd = new DatabaseCommand_SocialAction();
cmd->setSource( SourceList::instance()->getLocal() );
cmd->setAction( "latchOff");

View File

@ -20,14 +20,11 @@
#define SOURCETREEVIEW_H
#include "typedefs.h"
#include "sourceplaylistinterface.h"
#include <QTreeView>
#include <QMenu>
namespace Tomahawk {
class PlaylistInterface;
}
class CollectionModel;
class PlaylistModel;
class SourcesModel;