Make it possible to receive SearchResults before SearchFinished
This commit is contained in:
parent
0ebfa10d32
commit
e3c367984b
@ -101,6 +101,7 @@ void AlbumCoverFetcherSearch::Start(CoverProviders *cover_providers) {
|
||||
continue;
|
||||
}
|
||||
|
||||
connect(provider, SIGNAL(SearchResults(int, CoverSearchResults)), SLOT(ProviderSearchResults(int, CoverSearchResults)));
|
||||
connect(provider, SIGNAL(SearchFinished(int, CoverSearchResults)), SLOT(ProviderSearchFinished(int, CoverSearchResults)));
|
||||
const int id = cover_providers->NextId();
|
||||
const bool success = provider->StartSearch(request_.artist, request_.album, request_.title, id);
|
||||
@ -118,10 +119,15 @@ void AlbumCoverFetcherSearch::Start(CoverProviders *cover_providers) {
|
||||
|
||||
}
|
||||
|
||||
void AlbumCoverFetcherSearch::ProviderSearchFinished(const int id, const CoverSearchResults &results) {
|
||||
void AlbumCoverFetcherSearch::ProviderSearchResults(const int id, const CoverSearchResults &results) {
|
||||
|
||||
if (!pending_requests_.contains(id)) return;
|
||||
CoverProvider *provider = pending_requests_.take(id);
|
||||
CoverProvider *provider = pending_requests_[id];
|
||||
ProviderSearchResults(provider, results);
|
||||
|
||||
}
|
||||
|
||||
void AlbumCoverFetcherSearch::ProviderSearchResults(CoverProvider *provider, const CoverSearchResults &results) {
|
||||
|
||||
CoverSearchResults results_copy(results);
|
||||
for (int i = 0 ; i < results_copy.count() ; ++i) {
|
||||
@ -142,6 +148,15 @@ void AlbumCoverFetcherSearch::ProviderSearchFinished(const int id, const CoverSe
|
||||
results_.append(results_copy);
|
||||
statistics_.total_images_by_provider_[provider->name()]++;
|
||||
|
||||
}
|
||||
|
||||
void AlbumCoverFetcherSearch::ProviderSearchFinished(const int id, const CoverSearchResults &results) {
|
||||
|
||||
if (!pending_requests_.contains(id)) return;
|
||||
|
||||
CoverProvider *provider = pending_requests_.take(id);
|
||||
ProviderSearchResults(provider, results);
|
||||
|
||||
// Do we have more providers left?
|
||||
if (!pending_requests_.isEmpty()) {
|
||||
return;
|
||||
|
@ -66,6 +66,8 @@ class AlbumCoverFetcherSearch : public QObject {
|
||||
void AlbumCoverFetched(const quint64, const QUrl &cover_url, const QImage &cover);
|
||||
|
||||
private slots:
|
||||
void ProviderSearchResults(const int id, const CoverSearchResults &results);
|
||||
void ProviderSearchResults(CoverProvider *provider, const CoverSearchResults &results);
|
||||
void ProviderSearchFinished(const int id, const CoverSearchResults &results);
|
||||
void ProviderCoverFetchFinished(QNetworkReply *reply);
|
||||
void TerminateSearch();
|
||||
|
@ -70,6 +70,7 @@ class CoverProvider : public QObject {
|
||||
void AuthenticationComplete(bool, QStringList = QStringList());
|
||||
void AuthenticationSuccess();
|
||||
void AuthenticationFailure(QStringList);
|
||||
void SearchResults(int, CoverSearchResults);
|
||||
void SearchFinished(int, CoverSearchResults);
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user