mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-09 23:57:34 +02:00
* Prev/next check is now provided by PlaylistInterface.
This commit is contained in:
@@ -35,13 +35,10 @@ PlayableProxyModelPlaylistInterface::PlayableProxyModelPlaylistInterface( Playab
|
|||||||
, m_proxyModel( proxyModel )
|
, m_proxyModel( proxyModel )
|
||||||
, m_repeatMode( PlaylistModes::NoRepeat )
|
, m_repeatMode( PlaylistModes::NoRepeat )
|
||||||
, m_shuffled( false )
|
, m_shuffled( false )
|
||||||
, m_prevAvail( false )
|
|
||||||
, m_nextAvail( false )
|
|
||||||
{
|
{
|
||||||
connect( proxyModel, SIGNAL( currentIndexChanged() ), SLOT( onModelChanged() ) );
|
connect( proxyModel, SIGNAL( indexPlayable( QModelIndex ) ), SLOT( onItemsChanged() ) );
|
||||||
connect( proxyModel, SIGNAL( indexPlayable( QModelIndex ) ), SLOT( onModelChanged() ) );
|
connect( proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onItemsChanged() ) );
|
||||||
connect( proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onModelChanged() ) );
|
connect( proxyModel, SIGNAL( itemCountChanged( unsigned int ) ), SLOT( onItemsChanged() ) );
|
||||||
connect( proxyModel, SIGNAL( itemCountChanged( unsigned int ) ), SLOT( onModelChanged() ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -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 >
|
QList< Tomahawk::query_ptr >
|
||||||
PlayableProxyModelPlaylistInterface::tracks() const
|
PlayableProxyModelPlaylistInterface::tracks() const
|
||||||
{
|
{
|
||||||
@@ -138,6 +90,8 @@ PlayableProxyModelPlaylistInterface::setCurrentIndex( qint64 index )
|
|||||||
if ( m_proxyModel.isNull() )
|
if ( m_proxyModel.isNull() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
PlaylistInterface::setCurrentIndex( index );
|
||||||
|
|
||||||
PlayableItem* item = static_cast<PlayableItem*>( (void*)index );
|
PlayableItem* item = static_cast<PlayableItem*>( (void*)index );
|
||||||
if ( index < 0 || !item )
|
if ( index < 0 || !item )
|
||||||
{
|
{
|
||||||
|
@@ -65,9 +65,6 @@ signals:
|
|||||||
void previousTrackAvailable();
|
void previousTrackAvailable();
|
||||||
void nextTrackAvailable();
|
void nextTrackAvailable();
|
||||||
|
|
||||||
private slots:
|
|
||||||
virtual void onModelChanged();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QWeakPointer< PlayableProxyModel > m_proxyModel;
|
QWeakPointer< PlayableProxyModel > m_proxyModel;
|
||||||
|
|
||||||
@@ -75,9 +72,6 @@ protected:
|
|||||||
bool m_shuffled;
|
bool m_shuffled;
|
||||||
mutable QList< Tomahawk::query_ptr > m_shuffleHistory;
|
mutable QList< Tomahawk::query_ptr > m_shuffleHistory;
|
||||||
mutable QPersistentModelIndex m_shuffleCache;
|
mutable QPersistentModelIndex m_shuffleCache;
|
||||||
|
|
||||||
mutable bool m_prevAvail;
|
|
||||||
mutable bool m_nextAvail;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} //ns
|
} //ns
|
||||||
|
Reference in New Issue
Block a user