From a4d0a6562432eaa05f32d5e6d9536f42e1ce4239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Due=C3=B1as?= Date: Sat, 21 Dec 2013 12:58:51 -0600 Subject: [PATCH 1/3] Added ability to quickly display partial results on Song Info and Artist Info Panes. --- src/songinfo/artistinfoview.cpp | 18 ++++++++++-------- src/songinfo/artistinfoview.h | 5 +++++ src/songinfo/songinfobase.cpp | 12 ++++++++++++ src/songinfo/songinfobase.h | 3 +++ src/songinfo/songinfofetcher.cpp | 9 +++++++++ src/songinfo/songinfofetcher.h | 3 +++ src/songinfo/songinfoview.cpp | 15 +++++++-------- src/songinfo/songinfoview.h | 4 +++- 8 files changed, 52 insertions(+), 17 deletions(-) diff --git a/src/songinfo/artistinfoview.cpp b/src/songinfo/artistinfoview.cpp index cdf3879ae..816c49c5c 100644 --- a/src/songinfo/artistinfoview.cpp +++ b/src/songinfo/artistinfoview.cpp @@ -48,13 +48,19 @@ bool ArtistInfoView::NeedsUpdate(const Song& old_metadata, const Song& new_metad return old_metadata.artist() != new_metadata.artist(); } - + +void ArtistInfoView::InfoResultReady (int id, const CollapsibleInfoPane::Data& data) { + if (id != current_request_id_) + return; + + AddSection (new CollapsibleInfoPane(data, this)); + CollapseSections(); +} + void ArtistInfoView::ResultReady(int id, const SongInfoFetcher::Result& result) { if (id != current_request_id_) return; - Clear(); - if (!result.images_.isEmpty()) { // Image view goes at the top PrettyImageView* image_view = new PrettyImageView(network_, this); @@ -64,10 +70,6 @@ void ArtistInfoView::ResultReady(int id, const SongInfoFetcher::Result& result) image_view->AddImage(url); } } - - foreach (const CollapsibleInfoPane::Data& data, result.info_) { - AddSection(new CollapsibleInfoPane(data, this)); - } - CollapseSections(); } + diff --git a/src/songinfo/artistinfoview.h b/src/songinfo/artistinfoview.h index 5272e91bb..bbea97542 100644 --- a/src/songinfo/artistinfoview.h +++ b/src/songinfo/artistinfoview.h @@ -21,6 +21,7 @@ #include "collapsibleinfopane.h" #include "songinfobase.h" #include "songinfofetcher.h" +#include "widgets/prettyimageview.h" class PrettyImageView; @@ -36,10 +37,14 @@ public: ~ArtistInfoView(); protected: + virtual void InfoResultReady (int id, const CollapsibleInfoPane::Data& data); bool NeedsUpdate(const Song& old_metadata, const Song& new_metadata) const; + + PrettyImageView* image_view; protected slots: void ResultReady(int id, const SongInfoFetcher::Result& result); }; #endif // ARTISTINFOVIEW_H + diff --git a/src/songinfo/songinfobase.cpp b/src/songinfo/songinfobase.cpp index 164cb8fea..25a18f7eb 100644 --- a/src/songinfo/songinfobase.cpp +++ b/src/songinfo/songinfobase.cpp @@ -64,6 +64,10 @@ SongInfoBase::SongInfoBase(QWidget* parent) connect(fetcher_, SIGNAL(ResultReady(int,SongInfoFetcher::Result)), SLOT(ResultReady(int,SongInfoFetcher::Result))); + connect(fetcher_, SIGNAL(InfoResultReady(int,CollapsibleInfoPane::Data)), + SLOT(InfoResultReady(int,CollapsibleInfoPane::Data))); + connect(fetcher_, SIGNAL(ImageResultReady(int,QUrl)), + SLOT(ImageResultReady(int,QUrl))); } void SongInfoBase::Clear() { @@ -142,9 +146,16 @@ void SongInfoBase::Update(const Song& metadata) { // Do this after the new pane has been shown otherwise it'll just grab a // black rectangle. + Clear (); QTimer::singleShot(0, fader_, SLOT(StartBlur())); } +void SongInfoBase::ImageResultReady(int id, const QUrl& url) { +} + +void SongInfoBase::InfoResultReady (int id, const CollapsibleInfoPane::Data& data) { +} + void SongInfoBase::ResultReady(int id, const SongInfoFetcher::Result& result) { foreach (const CollapsibleInfoPane::Data& data, result.info_) { delete data.contents_; @@ -225,3 +236,4 @@ void SongInfoBase::ConnectWidget(QWidget* widget) { connect(widget, SIGNAL(DoGlobalSearch(QString)), SIGNAL(DoGlobalSearch(QString))); } } + diff --git a/src/songinfo/songinfobase.h b/src/songinfo/songinfobase.h index 90b4c5e02..c7fe66958 100644 --- a/src/songinfo/songinfobase.h +++ b/src/songinfo/songinfobase.h @@ -63,6 +63,8 @@ protected: void CollapseSections(); protected slots: + virtual void ImageResultReady(int id, const QUrl& url); + virtual void InfoResultReady (int id, const CollapsibleInfoPane::Data& data); virtual void ResultReady(int id, const SongInfoFetcher::Result& result); protected: @@ -94,3 +96,4 @@ private: }; #endif // SONGINFOBASE_H + diff --git a/src/songinfo/songinfofetcher.cpp b/src/songinfo/songinfofetcher.cpp index df395a204..45cc7cfe6 100644 --- a/src/songinfo/songinfofetcher.cpp +++ b/src/songinfo/songinfofetcher.cpp @@ -62,12 +62,20 @@ void SongInfoFetcher::ImageReady(int id, const QUrl& url) { if (!results_.contains(id)) return; results_[id].images_ << url; + + if (!waiting_for_.contains(id)) + return; + emit ImageResultReady (id, url); } void SongInfoFetcher::InfoReady(int id, const CollapsibleInfoPane::Data& data) { if (!results_.contains(id)) return; results_[id].info_ << data; + + if (!waiting_for_.contains(id)) + return; + emit InfoResultReady (id, data); } void SongInfoFetcher::ProviderFinished(int id) { @@ -107,3 +115,4 @@ void SongInfoFetcher::Timeout(int id) { // Remove the timer delete timeout_timers_.take(id); } + diff --git a/src/songinfo/songinfofetcher.h b/src/songinfo/songinfofetcher.h index 399bafb7c..d78b208ca 100644 --- a/src/songinfo/songinfofetcher.h +++ b/src/songinfo/songinfofetcher.h @@ -50,6 +50,8 @@ public: QList providers() const { return providers_; } signals: + void ImageResultReady(int id, const QUrl& url); + void InfoResultReady (int id, const CollapsibleInfoPane::Data& data); void ResultReady(int id, const SongInfoFetcher::Result& result); private slots: @@ -72,3 +74,4 @@ private: }; #endif // SONGINFOFETCHER_H + diff --git a/src/songinfo/songinfoview.cpp b/src/songinfo/songinfoview.cpp index a4c642d5b..a5de1e308 100644 --- a/src/songinfo/songinfoview.cpp +++ b/src/songinfo/songinfoview.cpp @@ -76,19 +76,17 @@ bool SongInfoView::NeedsUpdate(const Song& old_metadata, const Song& new_metadat old_metadata.artist() != new_metadata.artist(); } -void SongInfoView::ResultReady(int id, const SongInfoFetcher::Result& result) { +void SongInfoView::InfoResultReady (int id, const CollapsibleInfoPane::Data& data) { if (id != current_request_id_) return; - - Clear(); - - foreach (const CollapsibleInfoPane::Data& data, result.info_) { - AddSection(new CollapsibleInfoPane(data, this)); - } - + + AddSection (new CollapsibleInfoPane(data, this)); CollapseSections(); } +void SongInfoView::ResultReady(int id, const SongInfoFetcher::Result& result) { +} + void SongInfoView::ReloadSettings() { QSettings s; s.beginGroup(kSettingsGroup); @@ -170,3 +168,4 @@ QList SongInfoView::lyric_providers() const { qSort(ret.begin(), ret.end(), CompareLyricProviders); return ret; } + diff --git a/src/songinfo/songinfoview.h b/src/songinfo/songinfoview.h index 744a4d5c0..887e31242 100644 --- a/src/songinfo/songinfoview.h +++ b/src/songinfo/songinfoview.h @@ -43,7 +43,8 @@ protected: bool NeedsUpdate(const Song& old_metadata, const Song& new_metadata) const; protected slots: - void ResultReady(int id, const SongInfoFetcher::Result& result); + virtual void InfoResultReady (int id, const CollapsibleInfoPane::Data& data); + virtual void ResultReady(int id, const SongInfoFetcher::Result& result); private: SongInfoProvider* ProviderByName(const QString& name) const; @@ -56,3 +57,4 @@ private: }; #endif // SONGINFOVIEW_H + From 5b2938003b0c540d948ee5fbff42fb26cfb9ae2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Due=C3=B1as?= Date: Sun, 29 Dec 2013 14:04:30 -0600 Subject: [PATCH 2/3] Clean up of the last commit --- src/songinfo/artistinfoview.h | 3 --- src/songinfo/songinfobase.cpp | 3 --- src/songinfo/songinfobase.h | 1 - 3 files changed, 7 deletions(-) diff --git a/src/songinfo/artistinfoview.h b/src/songinfo/artistinfoview.h index bbea97542..5a597d11f 100644 --- a/src/songinfo/artistinfoview.h +++ b/src/songinfo/artistinfoview.h @@ -21,7 +21,6 @@ #include "collapsibleinfopane.h" #include "songinfobase.h" #include "songinfofetcher.h" -#include "widgets/prettyimageview.h" class PrettyImageView; @@ -39,8 +38,6 @@ public: protected: virtual void InfoResultReady (int id, const CollapsibleInfoPane::Data& data); bool NeedsUpdate(const Song& old_metadata, const Song& new_metadata) const; - - PrettyImageView* image_view; protected slots: void ResultReady(int id, const SongInfoFetcher::Result& result); diff --git a/src/songinfo/songinfobase.cpp b/src/songinfo/songinfobase.cpp index 25a18f7eb..e2a6675d2 100644 --- a/src/songinfo/songinfobase.cpp +++ b/src/songinfo/songinfobase.cpp @@ -150,9 +150,6 @@ void SongInfoBase::Update(const Song& metadata) { QTimer::singleShot(0, fader_, SLOT(StartBlur())); } -void SongInfoBase::ImageResultReady(int id, const QUrl& url) { -} - void SongInfoBase::InfoResultReady (int id, const CollapsibleInfoPane::Data& data) { } diff --git a/src/songinfo/songinfobase.h b/src/songinfo/songinfobase.h index c7fe66958..ab8c8448c 100644 --- a/src/songinfo/songinfobase.h +++ b/src/songinfo/songinfobase.h @@ -63,7 +63,6 @@ protected: void CollapseSections(); protected slots: - virtual void ImageResultReady(int id, const QUrl& url); virtual void InfoResultReady (int id, const CollapsibleInfoPane::Data& data); virtual void ResultReady(int id, const SongInfoFetcher::Result& result); From 5d2fbfb0418da33b634e057c645e8cf2bd608f9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Due=C3=B1as?= Date: Mon, 30 Dec 2013 00:04:15 -0600 Subject: [PATCH 3/3] Further clean up of the last commit --- src/songinfo/songinfobase.cpp | 2 -- src/songinfo/songinfofetcher.cpp | 4 ---- src/songinfo/songinfofetcher.h | 1 - 3 files changed, 7 deletions(-) diff --git a/src/songinfo/songinfobase.cpp b/src/songinfo/songinfobase.cpp index e2a6675d2..3b36e7649 100644 --- a/src/songinfo/songinfobase.cpp +++ b/src/songinfo/songinfobase.cpp @@ -66,8 +66,6 @@ SongInfoBase::SongInfoBase(QWidget* parent) SLOT(ResultReady(int,SongInfoFetcher::Result))); connect(fetcher_, SIGNAL(InfoResultReady(int,CollapsibleInfoPane::Data)), SLOT(InfoResultReady(int,CollapsibleInfoPane::Data))); - connect(fetcher_, SIGNAL(ImageResultReady(int,QUrl)), - SLOT(ImageResultReady(int,QUrl))); } void SongInfoBase::Clear() { diff --git a/src/songinfo/songinfofetcher.cpp b/src/songinfo/songinfofetcher.cpp index 45cc7cfe6..1497fa994 100644 --- a/src/songinfo/songinfofetcher.cpp +++ b/src/songinfo/songinfofetcher.cpp @@ -62,10 +62,6 @@ void SongInfoFetcher::ImageReady(int id, const QUrl& url) { if (!results_.contains(id)) return; results_[id].images_ << url; - - if (!waiting_for_.contains(id)) - return; - emit ImageResultReady (id, url); } void SongInfoFetcher::InfoReady(int id, const CollapsibleInfoPane::Data& data) { diff --git a/src/songinfo/songinfofetcher.h b/src/songinfo/songinfofetcher.h index d78b208ca..987716a4e 100644 --- a/src/songinfo/songinfofetcher.h +++ b/src/songinfo/songinfofetcher.h @@ -50,7 +50,6 @@ public: QList providers() const { return providers_; } signals: - void ImageResultReady(int id, const QUrl& url); void InfoResultReady (int id, const CollapsibleInfoPane::Data& data); void ResultReady(int id, const SongInfoFetcher::Result& result);