1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-07 06:36:55 +02:00

Clear upcoming station tracks when steering, and re-fetch two

This commit is contained in:
Leo Franchi
2011-11-20 20:06:51 -05:00
parent eb7845092a
commit 0dda262c18
5 changed files with 31 additions and 0 deletions

View File

@@ -102,6 +102,10 @@ public:
* If this generator doesn't support this (and returns false for
* \c onDemandSteerable) this will be null. The generator is responsible
* for reacting to changes in the widget.
*
* Steering widgets may emit a \c steeringChanged() signal, which will cause the model to toss any
* upcoming tracks and re-fetch them.
*
*/
virtual QWidget* steeringWidget() { return 0; }

View File

@@ -218,6 +218,8 @@ EchonestSteerer::applySteering()
}
}
emit steeringChanged();
resetSteering( true );
}

View File

@@ -57,6 +57,9 @@ signals:
void reset();
void resized();
// interface to DynamicWidget
void steeringChanged();
private slots:
void changed();

View File

@@ -324,6 +324,8 @@ DynamicWidget::startStation()
m_steering = m_playlist->generator()->steeringWidget();
Q_ASSERT( m_steering );
connect( m_steering, SIGNAL( steeringChanged() ), this, SLOT( steeringChanged() ) );
int x = ( width() / 2 ) - ( m_steering->size().width() / 2 );
int y = height() - m_steering->size().height() - 40; // padding
@@ -394,6 +396,25 @@ DynamicWidget::controlChanged( const Tomahawk::dyncontrol_ptr& control )
emit descriptionChanged( m_playlist->generator()->sentenceSummary() );
}
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();
tDebug() << "Removing tracks after current in station, found" << upcoming;
QModelIndexList toRemove;
for ( int i = cur.row() + 1; i < m_view->proxyModel()->rowCount( QModelIndex() ); i++ )
{
toRemove << m_view->proxyModel()->index( i, 0, QModelIndex() );
}
m_view->proxyModel()->removeIndexes( toRemove );
m_playlist->generator()->fetchNext();
}
void
DynamicWidget::showPreview()

View File

@@ -103,6 +103,7 @@ private slots:
void controlsChanged( bool added );
void controlChanged( const Tomahawk::dyncontrol_ptr& control );
void steeringChanged();
void showPreview();
void layoutFloatingWidgets();