1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 14:16:32 +02:00

TWK-712: Don't emit track number changed when they really haven't, thus masking other errors

This commit is contained in:
Leo Franchi
2012-03-01 22:11:02 -05:00
parent 4889ed6a33
commit f7f2c51d4e
4 changed files with 70 additions and 45 deletions

View File

@@ -54,9 +54,12 @@ DynamicModel::loadPlaylist( const Tomahawk::dynplaylist_ptr& playlist, bool load
{
Q_UNUSED( loadEntries );
if( !m_playlist.isNull() ) {
if ( !m_playlist.isNull() )
{
disconnect( m_playlist->generator().data(), SIGNAL( nextTrackGenerated( Tomahawk::query_ptr ) ), this, SLOT( newTrackGenerated( Tomahawk::query_ptr ) ) );
}
const int oldCount = rowCount( QModelIndex() );
m_playlist = playlist;
m_deduper.clear();
@@ -66,7 +69,7 @@ DynamicModel::loadPlaylist( const Tomahawk::dynplaylist_ptr& playlist, bool load
connect( m_playlist->generator().data(), SIGNAL( nextTrackGenerated( Tomahawk::query_ptr ) ), this, SLOT( newTrackGenerated( Tomahawk::query_ptr ) ) );
PlaylistModel::loadPlaylist( m_playlist, m_playlist->mode() == Static );
if( m_playlist->mode() == OnDemand )
if ( m_playlist->mode() == OnDemand && oldCount != rowCount( QModelIndex() ) )
emit trackCountChanged( rowCount( QModelIndex() ) );
}
@@ -95,7 +98,8 @@ DynamicModel::startOnDemand()
void
DynamicModel::newTrackGenerated( const Tomahawk::query_ptr& query )
{
if( m_onDemandRunning ) {
if ( m_onDemandRunning )
{
bool isDuplicate = false;
for ( int i = 0; i < m_deduper.size(); i++ )
{
@@ -188,11 +192,14 @@ void
DynamicModel::newTrackLoading()
{
qDebug() << "Got NEW TRACK LOADING signal";
if( m_changeOnNext ) { // reset instead of getting the next one
if ( m_changeOnNext )
{ // reset instead of getting the next one
m_lastResolvedRow = rowCount( QModelIndex() );
m_searchingForNext = true;
m_playlist->generator()->startOnDemand();
} else if( m_onDemandRunning && m_currentAttempts == 0 && !m_searchingForNext ) { // if we're in dynamic mode and we're also currently idle
}
else if ( m_onDemandRunning && m_currentAttempts == 0 && !m_searchingForNext )
{ // if we're in dynamic mode and we're also currently idle
m_lastResolvedRow = rowCount( QModelIndex() );
m_searchingForNext = true;
qDebug() << "IDLE fetching new track!";
@@ -204,13 +211,17 @@ DynamicModel::newTrackLoading()
void
DynamicModel::tracksGenerated( const QList< query_ptr > entries, int limitResolvedTo )
{
if( m_filterUnresolvable && m_playlist->mode() == OnDemand ) { // wait till we get them resolved (for previewing stations)
if ( m_filterUnresolvable && m_playlist->mode() == OnDemand )
{ // wait till we get them resolved (for previewing stations)
m_limitResolvedTo = limitResolvedTo;
filterUnresolved( entries );
} else {
}
else
{
addToPlaylist( entries, m_playlist->mode() == OnDemand ); // if ondemand, we're previewing, so clear old
if( m_playlist->mode() == OnDemand ) {
if ( m_playlist->mode() == OnDemand )
{
m_lastResolvedRow = rowCount( QModelIndex() );
}
}
@@ -224,9 +235,9 @@ DynamicModel::filterUnresolved( const QList< query_ptr >& entries )
{
m_toResolveList = entries;
foreach( const query_ptr& q, entries ) {
foreach ( const query_ptr& q, entries )
connect( q.data(), SIGNAL( resolvingFinished( bool ) ), this, SLOT( filteringTrackResolved( bool ) ) );
}
Pipeline::instance()->resolve( entries, true );
}
@@ -240,7 +251,8 @@ DynamicModel::filteringTrackResolved( bool successful )
// 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 ) {
if ( m_onDemandRunning )
{
m_toResolveList.clear();
m_resolvedList.clear();
@@ -248,8 +260,10 @@ DynamicModel::filteringTrackResolved( bool successful )
}
query_ptr realptr;
foreach( const query_ptr& qptr, m_toResolveList ) {
if( qptr.data() == q ) {
foreach ( const query_ptr& qptr, m_toResolveList )
{
if ( qptr.data() == q )
{
realptr = qptr;
break;
}
@@ -259,21 +273,26 @@ DynamicModel::filteringTrackResolved( bool successful )
m_toResolveList.removeAll( realptr );
if( realptr->playable() ) {
if ( realptr->playable() )
{
m_resolvedList << realptr;
// append and update internal lastResolvedRow
addToPlaylist( QList< query_ptr >() << realptr, false );
if( m_playlist->mode() == OnDemand ) {
if ( m_playlist->mode() == OnDemand )
{
m_lastResolvedRow = rowCount( QModelIndex() );
}
if( m_toResolveList.isEmpty() || m_resolvedList.size() == m_limitResolvedTo ) { // done
if ( m_toResolveList.isEmpty() || m_resolvedList.size() == m_limitResolvedTo )
{ // done
m_toResolveList.clear();
m_resolvedList.clear();
}
} else {
}
else
{
qDebug() << "Got unsuccessful resolve request for this track" << realptr->track() << realptr->artist();
}
@@ -291,10 +310,14 @@ DynamicModel::addToPlaylist( const QList< query_ptr >& entries, bool clearFirst
foreach ( const query_ptr& q, entries )
m_deduper.append( QPair< QString, QString >( q->track(), q->artist() ) );
if( m_playlist->author()->isLocal() && m_playlist->mode() == Static ) {
if ( m_playlist->author()->isLocal() && m_playlist->mode() == Static )
{
m_playlist->addEntries( entries, m_playlist->currentrevision() );
} else { // read-only, so add tracks only in the GUI, not to the playlist itself
foreach( const query_ptr& query, entries ) {
}
else
{ // read-only, so add tracks only in the GUI, not to the playlist itself
foreach ( const query_ptr& query, entries )
{
append( query );
}
}
@@ -310,12 +333,15 @@ DynamicModel::remove(const QModelIndex& idx, bool moreToCome)
return;
qDebug() << Q_FUNC_INFO << "DYNAMIC MODEL REMOVIN!" << moreToCome << ( idx == index( rowCount( QModelIndex() ) - 1, 0, QModelIndex() ) );
if( m_playlist->mode() == OnDemand ) {
if( !moreToCome && idx == index( rowCount( QModelIndex() ) - 1, 0, QModelIndex() ) ) { // if the user is manually removing the last one, re-add as we're a station
if ( m_playlist->mode() == OnDemand )
{
if ( !moreToCome && idx == index( rowCount( QModelIndex() ) - 1, 0, QModelIndex() ) )
{ // if the user is manually removing the last one, re-add as we're a station
newTrackLoading();
}
TrackModel::remove( idx );
} else
}
else
PlaylistModel::remove( idx, moreToCome );
// don't call onPlaylistChanged.

View File

@@ -1,6 +1,6 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -443,8 +443,7 @@ DynamicWidget::steeringChanged()
void
DynamicWidget::showPreview()
{
if ( m_playlist->mode() == OnDemand &&
!m_runningOnDemand )
if ( m_playlist->mode() == OnDemand && !m_runningOnDemand )
{
// if this is a not running station, preview matching tracks
m_model->clear();