mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-19 07:19:42 +01:00
Remove upcoming tracks not from selected but from playing item
This commit is contained in:
parent
f9b18a9c26
commit
ba80899ee5
@ -400,12 +400,26 @@ void
|
||||
DynamicWidget::steeringChanged()
|
||||
{
|
||||
// When steering changes, toss all the tracks that are upcoming, and re-fetch.
|
||||
QModelIndex cur = m_view->currentIndex();
|
||||
const int upcoming = m_view->proxyModel()->rowCount( QModelIndex() ) - 1 - cur.row();
|
||||
// We have to find the currently playing item
|
||||
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;
|
||||
|
||||
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() );
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ TrackModelItem::TrackModelItem( TrackModelItem* parent, QAbstractItemModel* mode
|
||||
this->model = model;
|
||||
childCount = 0;
|
||||
toberemoved = false;
|
||||
m_isPlaying = false;
|
||||
|
||||
if ( parent )
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user