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

* Prev/next check is now provided by PlaylistInterface.

This commit is contained in:
Christian Muehlhaeuser 2012-12-04 03:13:46 +01:00
parent e4c66de0fd
commit fa0eaee3c8
2 changed files with 5 additions and 57 deletions

View File

@ -35,13 +35,10 @@ PlayableProxyModelPlaylistInterface::PlayableProxyModelPlaylistInterface( Playab
, m_proxyModel( proxyModel )
, m_repeatMode( PlaylistModes::NoRepeat )
, m_shuffled( false )
, m_prevAvail( false )
, m_nextAvail( false )
{
connect( proxyModel, SIGNAL( currentIndexChanged() ), SLOT( onModelChanged() ) );
connect( proxyModel, SIGNAL( indexPlayable( QModelIndex ) ), SLOT( onModelChanged() ) );
connect( proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onModelChanged() ) );
connect( proxyModel, SIGNAL( itemCountChanged( unsigned int ) ), SLOT( onModelChanged() ) );
connect( proxyModel, SIGNAL( indexPlayable( QModelIndex ) ), SLOT( onItemsChanged() ) );
connect( proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onItemsChanged() ) );
connect( proxyModel, SIGNAL( itemCountChanged( unsigned int ) ), SLOT( onItemsChanged() ) );
}
@ -66,51 +63,6 @@ PlayableProxyModelPlaylistInterface::filter() const
}
void
PlayableProxyModelPlaylistInterface::onModelChanged()
{
if ( QThread::currentThread() != thread() )
{
tDebug() << Q_FUNC_INFO << "Reinvoking in correct thread!";
QMetaObject::invokeMethod( this, "onModelChanged", Qt::QueuedConnection );
return;
}
Tomahawk::result_ptr prevResult = siblingResult( -1 );
Tomahawk::result_ptr nextResult = siblingResult( 1 );
if ( prevResult )
{
bool avail = prevResult->toQuery()->playable();
if ( avail != m_prevAvail )
{
m_prevAvail = avail;
emit previousTrackAvailable();
}
}
else if ( m_prevAvail )
{
m_prevAvail = false;
emit previousTrackAvailable();
}
if ( nextResult )
{
bool avail = nextResult->toQuery()->playable();
if ( avail != m_nextAvail )
{
m_nextAvail = avail;
emit nextTrackAvailable();
}
}
else if ( m_nextAvail )
{
m_nextAvail = false;
emit nextTrackAvailable();
}
}
QList< Tomahawk::query_ptr >
PlayableProxyModelPlaylistInterface::tracks() const
{
@ -138,6 +90,8 @@ PlayableProxyModelPlaylistInterface::setCurrentIndex( qint64 index )
if ( m_proxyModel.isNull() )
return;
PlaylistInterface::setCurrentIndex( index );
PlayableItem* item = static_cast<PlayableItem*>( (void*)index );
if ( index < 0 || !item )
{

View File

@ -65,9 +65,6 @@ signals:
void previousTrackAvailable();
void nextTrackAvailable();
private slots:
virtual void onModelChanged();
protected:
QWeakPointer< PlayableProxyModel > m_proxyModel;
@ -75,9 +72,6 @@ protected:
bool m_shuffled;
mutable QList< Tomahawk::query_ptr > m_shuffleHistory;
mutable QPersistentModelIndex m_shuffleCache;
mutable bool m_prevAvail;
mutable bool m_nextAvail;
};
} //ns