mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
Remove upcoming tracks not from selected but from playing item
This commit is contained in:
@@ -400,12 +400,26 @@ void
|
|||||||
DynamicWidget::steeringChanged()
|
DynamicWidget::steeringChanged()
|
||||||
{
|
{
|
||||||
// When steering changes, toss all the tracks that are upcoming, and re-fetch.
|
// When steering changes, toss all the tracks that are upcoming, and re-fetch.
|
||||||
QModelIndex cur = m_view->currentIndex();
|
// We have to find the currently playing item
|
||||||
const int upcoming = m_view->proxyModel()->rowCount( QModelIndex() ) - 1 - cur.row();
|
QModelIndex playing;
|
||||||
|
for ( int i = 0; i < m_view->proxyModel()->rowCount( QModelIndex() ); ++i )
|
||||||
|
{
|
||||||
|
const QModelIndex cur = m_view->proxyModel()->index( i, 0, QModelIndex() );
|
||||||
|
TrackModelItem* item = m_view->proxyModel()->itemFromIndex( m_view->proxyModel()->mapToSource( cur ) );
|
||||||
|
if ( item && item->isPlaying() )
|
||||||
|
{
|
||||||
|
playing = cur;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( !playing.isValid() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
const int upcoming = m_view->proxyModel()->rowCount( QModelIndex() ) - 1 - playing.row();
|
||||||
tDebug() << "Removing tracks after current in station, found" << upcoming;
|
tDebug() << "Removing tracks after current in station, found" << upcoming;
|
||||||
|
|
||||||
QModelIndexList toRemove;
|
QModelIndexList toRemove;
|
||||||
for ( int i = cur.row() + 1; i < m_view->proxyModel()->rowCount( QModelIndex() ); i++ )
|
for ( int i = playing.row() + 1; i < m_view->proxyModel()->rowCount( QModelIndex() ); i++ )
|
||||||
{
|
{
|
||||||
toRemove << m_view->proxyModel()->index( i, 0, QModelIndex() );
|
toRemove << m_view->proxyModel()->index( i, 0, QModelIndex() );
|
||||||
}
|
}
|
||||||
|
@@ -47,6 +47,7 @@ TrackModelItem::TrackModelItem( TrackModelItem* parent, QAbstractItemModel* mode
|
|||||||
this->model = model;
|
this->model = model;
|
||||||
childCount = 0;
|
childCount = 0;
|
||||||
toberemoved = false;
|
toberemoved = false;
|
||||||
|
m_isPlaying = false;
|
||||||
|
|
||||||
if ( parent )
|
if ( parent )
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user