Added ability to quickly display partial results on Song Info and Artist Info Panes.

This commit is contained in:
Hugo Dueñas 2013-12-21 12:58:51 -06:00
parent fde4586773
commit a4d0a65624
8 changed files with 52 additions and 17 deletions

View File

@ -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();
}

View File

@ -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

View File

@ -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)));
}
}

View File

@ -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

View File

@ -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);
}

View File

@ -50,6 +50,8 @@ public:
QList<SongInfoProvider*> 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

View File

@ -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<const UltimateLyricsProvider*> SongInfoView::lyric_providers() const {
qSort(ret.begin(), ret.end(), CompareLyricProviders);
return ret;
}

View File

@ -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