Esempio n. 1
0
void
DynamicModel::trackResolveFinished( bool success )
{
    Q_UNUSED( success );

    Query* q = qobject_cast<Query*>( sender() );

    tDebug() << "Got resolveFinished in DynamicModel" << q->track() << q->artist();
    if ( !m_waitingFor.contains( q ) )
        return;

    if ( !q->playable() )
    {
        tDebug() << "Got not playable or resolved track:" << q->track() << q->artist() << m_lastResolvedRow << m_currentAttempts;
        m_currentAttempts++;

        int curAttempts = m_startingAfterFailed ? m_currentAttempts - 20 : m_currentAttempts; // if we just failed, m_currentAttempts includes those failures
        if( curAttempts < 20 ) {
            qDebug() << "FETCHING MORE!";
            m_playlist->generator()->fetchNext();
        } else {
            m_startingAfterFailed = true;
            emit trackGenerationFailure( tr( "Could not find a playable track.\n\nPlease change the filters or try again." ) );
        }
    }
    else
    {
        qDebug() << "Got successful resolved track:" << q->track() << q->artist() << m_lastResolvedRow << m_currentAttempts;

        if ( m_currentAttempts > 0 ) {
            qDebug() << "EMITTING AN ASK FOR COLLAPSE:" << m_lastResolvedRow << m_currentAttempts;
            emit collapseFromTo( m_lastResolvedRow, m_currentAttempts );
        }
        m_currentAttempts = 0;
        m_searchingForNext = false;

        emit checkForOverflow();
    }
    m_waitingFor.removeAll( q );
}
Esempio n. 2
0
void
DynamicModel::filteringTrackResolved( bool successful )
{
    // arg, we don't have the query_ptr, just the Query
    Query* q = qobject_cast< Query* >( sender() );
    Q_ASSERT( q );

    // if meantime the user began the station, abort
    qDebug() << "Got filtering resolved finished for track, was it successful?:" << q->track() << q->artist() << successful << q->playable();
    if ( m_onDemandRunning )
    {
        m_toResolveList.clear();
        m_resolvedList.clear();

        return;
    }

    query_ptr realptr;
    foreach ( const query_ptr& qptr, m_toResolveList )
    {
        if ( qptr.data() == q )
        {
            realptr = qptr;
            break;
        }
    }
    if( realptr.isNull() ) // we already finished
        return;

    m_toResolveList.removeAll( realptr );

    if ( realptr->playable() )
    {
        m_resolvedList << realptr;

        // 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();

        }
    }
    else
    {
        qDebug() << "Got unsuccessful resolve request for this track" << realptr->track() << realptr->artist();
    }

    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." ) );
}