From 885c52a0423eedc3c2f31f2e54247595195f340a Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Sun, 15 Jul 2012 13:18:37 +0200 Subject: [PATCH] only fetch more track if they are finished resolving and there are not enough tracks available yet --- data/qml/TagCloud.qml | 2 +- .../dynamic/widgets/DynamicQmlWidget.cpp | 19 +++++++++++++------ .../dynamic/widgets/DynamicQmlWidget.h | 2 ++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/data/qml/TagCloud.qml b/data/qml/TagCloud.qml index 960204e17..3226b5293 100644 --- a/data/qml/TagCloud.qml +++ b/data/qml/TagCloud.qml @@ -50,7 +50,7 @@ Item { id: delegateText color: "white" //text: controlModel.controlAt( index ).summary - text: "bla" + modelData + text: modelData font.pixelSize: 28 anchors.verticalCenter: parent.verticalCenter anchors.verticalCenterOffset: tagCloud.randomNumber(0, 15) diff --git a/src/libtomahawk/playlist/dynamic/widgets/DynamicQmlWidget.cpp b/src/libtomahawk/playlist/dynamic/widgets/DynamicQmlWidget.cpp index 58926d08b..df58e448d 100644 --- a/src/libtomahawk/playlist/dynamic/widgets/DynamicQmlWidget.cpp +++ b/src/libtomahawk/playlist/dynamic/widgets/DynamicQmlWidget.cpp @@ -146,18 +146,15 @@ void DynamicQmlWidget::nextTrackGenerated(const query_ptr &track) m_model->tracksGenerated( QList() << track ); m_playlist->resolve(); - qDebug() << "next track generated" << m_proxyModel->rowCount() << m_proxyModel->currentIndex().row(); - if( m_proxyModel->rowCount() <= m_proxyModel->currentIndex().row() + 8 ) { - qDebug() << "fetching next one"; - m_playlist->generator()->fetchNext(); - } + connect( track.data(), SIGNAL( resolvingFinished( bool )), SLOT( resolvingFinished( bool ) ) ); + } void DynamicQmlWidget::error(const QString &title, const QString &body) { qDebug() << "got a generator error:" << title << body; - m_playlist->generator()->fetchNext(); +// m_playlist->generator()->fetchNext(); } @@ -166,4 +163,14 @@ void DynamicQmlWidget::onRevisionLoaded(DynamicPlaylistRevision) m_playlist->resolve(); } +void DynamicQmlWidget::resolvingFinished(bool hasResults) +{ + Q_UNUSED(hasResults) + qDebug() << "next track generated" << m_proxyModel->rowCount() << m_proxyModel->currentIndex().row(); + if( m_proxyModel->rowCount() <= m_proxyModel->currentIndex().row() + 8 ) { + qDebug() << "fetching next one"; + m_playlist->generator()->fetchNext(); + } +} + } diff --git a/src/libtomahawk/playlist/dynamic/widgets/DynamicQmlWidget.h b/src/libtomahawk/playlist/dynamic/widgets/DynamicQmlWidget.h index dd0a24db9..d53562227 100644 --- a/src/libtomahawk/playlist/dynamic/widgets/DynamicQmlWidget.h +++ b/src/libtomahawk/playlist/dynamic/widgets/DynamicQmlWidget.h @@ -59,6 +59,8 @@ private slots: void error( const QString& title, const QString& body); void onRevisionLoaded( Tomahawk::DynamicPlaylistRevision ); + + void resolvingFinished( bool hasResults ); private: DynamicModel* m_model; PlayableProxyModel* m_proxyModel;