1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 11:20:22 +02:00

add resolved tracks as we get them when previewing, and stop previewing if we're running

This commit is contained in:
Leo Franchi
2011-05-06 11:02:21 -04:00
parent 3a6abc3f5e
commit 8c3745896c

View File

@@ -191,6 +191,14 @@ DynamicModel::filteringTrackResolved( bool successful )
Query* q = qobject_cast< Query* >( sender() );
Q_ASSERT( q );
// if meantime the user began the station, abort
if( m_onDemandRunning ) {
m_toResolveList.clear();
m_resolvedList.clear();
return;
}
query_ptr realptr;
foreach( const query_ptr& qptr, m_toResolveList ) {
if( qptr.data() == q ) {
@@ -203,21 +211,22 @@ DynamicModel::filteringTrackResolved( bool successful )
m_toResolveList.removeAll( realptr );
if( successful )
if( successful ) {
m_resolvedList << realptr;
if( m_toResolveList.isEmpty() || m_resolvedList.size() == m_limitResolvedTo ) { // done, add to playlist
if( m_limitResolvedTo < m_resolvedList.count() ) // limit to how many we were asked for
m_resolvedList = m_resolvedList.mid( 0, m_limitResolvedTo );
addToPlaylist( m_resolvedList, true );
m_toResolveList.clear();
m_resolvedList.clear();
// append and update internal lastResolvedRow
addToPlaylist( QList< query_ptr >() << realptr, false );
if( m_playlist->mode() == OnDemand ) {
m_lastResolvedRow = rowCount( QModelIndex() );
}
if( m_toResolveList.isEmpty() || m_resolvedList.size() == m_limitResolvedTo ) { // done
m_toResolveList.clear();
m_resolvedList.clear();
}
}
if( m_toResolveList.isEmpty() && rowCount( QModelIndex() ) == 0 ) // we failed
emit trackGenerationFailure( tr( "Could not find a playable track.\n\nPlease change the filters or try again." ) );
}