mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-07 22:56:42 +02:00
Clear upcoming station tracks when steering, and re-fetch two
This commit is contained in:
@@ -102,6 +102,10 @@ public:
|
|||||||
* If this generator doesn't support this (and returns false for
|
* If this generator doesn't support this (and returns false for
|
||||||
* \c onDemandSteerable) this will be null. The generator is responsible
|
* \c onDemandSteerable) this will be null. The generator is responsible
|
||||||
* for reacting to changes in the widget.
|
* 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; }
|
virtual QWidget* steeringWidget() { return 0; }
|
||||||
|
|
||||||
|
@@ -218,6 +218,8 @@ EchonestSteerer::applySteering()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit steeringChanged();
|
||||||
|
|
||||||
resetSteering( true );
|
resetSteering( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -57,6 +57,9 @@ signals:
|
|||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
void resized();
|
void resized();
|
||||||
|
|
||||||
|
// interface to DynamicWidget
|
||||||
|
void steeringChanged();
|
||||||
private slots:
|
private slots:
|
||||||
void changed();
|
void changed();
|
||||||
|
|
||||||
|
@@ -324,6 +324,8 @@ DynamicWidget::startStation()
|
|||||||
m_steering = m_playlist->generator()->steeringWidget();
|
m_steering = m_playlist->generator()->steeringWidget();
|
||||||
Q_ASSERT( m_steering );
|
Q_ASSERT( m_steering );
|
||||||
|
|
||||||
|
connect( m_steering, SIGNAL( steeringChanged() ), this, SLOT( steeringChanged() ) );
|
||||||
|
|
||||||
int x = ( width() / 2 ) - ( m_steering->size().width() / 2 );
|
int x = ( width() / 2 ) - ( m_steering->size().width() / 2 );
|
||||||
int y = height() - m_steering->size().height() - 40; // padding
|
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() );
|
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
|
void
|
||||||
DynamicWidget::showPreview()
|
DynamicWidget::showPreview()
|
||||||
|
@@ -103,6 +103,7 @@ private slots:
|
|||||||
|
|
||||||
void controlsChanged( bool added );
|
void controlsChanged( bool added );
|
||||||
void controlChanged( const Tomahawk::dyncontrol_ptr& control );
|
void controlChanged( const Tomahawk::dyncontrol_ptr& control );
|
||||||
|
void steeringChanged();
|
||||||
void showPreview();
|
void showPreview();
|
||||||
|
|
||||||
void layoutFloatingWidgets();
|
void layoutFloatingWidgets();
|
||||||
|
Reference in New Issue
Block a user