From b34037f26f33304e3aed3909f587d27848f24024 Mon Sep 17 00:00:00 2001 From: Leo Franchi <lfranchi@kde.org> Date: Tue, 18 Oct 2011 08:05:38 -0400 Subject: [PATCH] Don't send multiple infosystem requests if one is queued --- src/libtomahawk/widgets/whatshotwidget.cpp | 13 ++++++++++--- src/libtomahawk/widgets/whatshotwidget.h | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/libtomahawk/widgets/whatshotwidget.cpp b/src/libtomahawk/widgets/whatshotwidget.cpp index f4550d872..2b8ba4612 100644 --- a/src/libtomahawk/widgets/whatshotwidget.cpp +++ b/src/libtomahawk/widgets/whatshotwidget.cpp @@ -166,7 +166,9 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat if( !returnedData.contains(type) ) break; const QString side = requestData.customData["whatshot_side"].toString(); + const QString chartId = requestData.input.value< Tomahawk::InfoSystem::InfoCriteriaHash >().value( "chart_id" ); + m_queuedFetches.remove( chartId ); tDebug( LOGVERBOSE ) << "WhatsHot: got chart! " << type << " on " << side; if( type == "artists" ) { @@ -182,7 +184,7 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat artistPtr = Artist::get( 0, artist ); artistsModel->addArtists( artistPtr ); } - const QString chartId = requestData.input.value< Tomahawk::InfoSystem::InfoCriteriaHash >().value( "chart_id" ); + m_artistModels[ chartId ] = artistsModel; setLeftViewArtists( artistsModel ); @@ -209,7 +211,6 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat qDebug() << "Adding albums to model"; albumModel->addAlbums( al ); - const QString chartId = requestData.input.value< Tomahawk::InfoSystem::InfoCriteriaHash >().value( "chart_id" ); m_albumModels[ chartId ] = albumModel; setLeftViewAlbums( albumModel ); } @@ -229,7 +230,6 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat Pipeline::instance()->resolve( tracklist ); trackModel->append( tracklist ); - const QString chartId = requestData.input.value< Tomahawk::InfoSystem::InfoCriteriaHash >().value( "chart_id" ); m_trackModels[ chartId ] = trackModel; setLeftViewTracks( trackModel ); } @@ -290,6 +290,11 @@ WhatsHotWidget::leftCrumbIndexChanged( QModelIndex index ) return; } + if ( m_queuedFetches.contains( chartId ) ) + { + return; + } + Tomahawk::InfoSystem::InfoCriteriaHash criteria; criteria.insert( "chart_id", chartId ); /// Remember to lower the source! @@ -306,6 +311,8 @@ WhatsHotWidget::leftCrumbIndexChanged( QModelIndex index ) qDebug() << "Making infosystem request for chart of type:" <<chartId; Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData, 20000, true ); + + m_queuedFetches.insert( chartId ); } diff --git a/src/libtomahawk/widgets/whatshotwidget.h b/src/libtomahawk/widgets/whatshotwidget.h index 12bb1b200..14286521e 100644 --- a/src/libtomahawk/widgets/whatshotwidget.h +++ b/src/libtomahawk/widgets/whatshotwidget.h @@ -96,6 +96,7 @@ private: QHash< QString, AlbumModel* > m_albumModels; QHash< QString, TreeModel* > m_artistModels; QHash< QString, PlaylistModel* > m_trackModels; + QSet< QString > m_queuedFetches; QTimer* m_timer; };