Change to const references, make search progress and status pass search id
This commit is contained in:
@@ -61,14 +61,13 @@ InternetSearch::InternetSearch(Application *app, Song::Source source, QObject *p
|
||||
cover_loader_options_.pad_output_image_ = true;
|
||||
cover_loader_options_.scale_output_image_ = true;
|
||||
|
||||
connect(app_->album_cover_loader(), SIGNAL(ImageLoaded(quint64, QImage)), SLOT(AlbumArtLoaded(quint64, QImage)));
|
||||
connect(this, SIGNAL(SearchAsyncSig(int, QString, SearchType)), this, SLOT(DoSearchAsync(int, QString, SearchType)));
|
||||
connect(app_->album_cover_loader(), SIGNAL(ImageLoaded(quint64, QImage)), SLOT(AlbumArtLoaded(const quint64, const QImage&)));
|
||||
connect(this, SIGNAL(SearchAsyncSig(const int, const QString&, const SearchType)), this, SLOT(DoSearchAsync(const int, const QString&, const SearchType)));
|
||||
|
||||
connect(service_, SIGNAL(SearchUpdateStatus(QString)), SLOT(UpdateStatusSlot(QString)));
|
||||
connect(service_, SIGNAL(SearchProgressSetMaximum(int)), SLOT(ProgressSetMaximumSlot(int)));
|
||||
connect(service_, SIGNAL(SearchUpdateProgress(int)), SLOT(UpdateProgressSlot(int)));
|
||||
connect(service_, SIGNAL(SearchResults(int, SongList)), SLOT(SearchDone(int, SongList)));
|
||||
connect(service_, SIGNAL(SearchError(int, QString)), SLOT(HandleError(int, QString)));
|
||||
connect(service_, SIGNAL(SearchUpdateStatus(const int, const QString&)), SLOT(UpdateStatusSlot(const int, const QString&)));
|
||||
connect(service_, SIGNAL(SearchProgressSetMaximum(const int, const int)), SLOT(ProgressSetMaximumSlot(const int, const int)));
|
||||
connect(service_, SIGNAL(SearchUpdateProgress(const int, const int)), SLOT(UpdateProgressSlot(const int, const int)));
|
||||
connect(service_, SIGNAL(SearchResults(const int, const SongList&, const QString&)), SLOT(SearchDone(const int, const SongList&, const QString&)));
|
||||
|
||||
}
|
||||
|
||||
@@ -105,7 +104,7 @@ bool InternetSearch::Matches(const QStringList &tokens, const QString &string) {
|
||||
|
||||
}
|
||||
|
||||
int InternetSearch::SearchAsync(const QString &query, SearchType type) {
|
||||
int InternetSearch::SearchAsync(const QString &query, const SearchType type) {
|
||||
|
||||
const int id = searches_next_id_++;
|
||||
|
||||
@@ -115,14 +114,14 @@ int InternetSearch::SearchAsync(const QString &query, SearchType type) {
|
||||
|
||||
}
|
||||
|
||||
void InternetSearch::SearchAsync(int id, const QString &query, SearchType type) {
|
||||
void InternetSearch::SearchAsync(const int id, const QString &query, const SearchType type) {
|
||||
|
||||
const int service_id = service_->Search(query, type);
|
||||
pending_searches_[service_id] = PendingState(id, TokenizeQuery(query));
|
||||
|
||||
}
|
||||
|
||||
void InternetSearch::DoSearchAsync(int id, const QString &query, SearchType type) {
|
||||
void InternetSearch::DoSearchAsync(const int id, const QString &query, const SearchType type) {
|
||||
|
||||
int timer_id = startTimer(kDelayedSearchTimeoutMs);
|
||||
delayed_searches_[timer_id].id_ = id;
|
||||
@@ -131,12 +130,19 @@ void InternetSearch::DoSearchAsync(int id, const QString &query, SearchType type
|
||||
|
||||
}
|
||||
|
||||
void InternetSearch::SearchDone(int service_id, const SongList &songs) {
|
||||
void InternetSearch::SearchDone(const int service_id, const SongList &songs, const QString &error) {
|
||||
|
||||
if (!pending_searches_.contains(service_id)) return;
|
||||
|
||||
// Map back to the original id.
|
||||
const PendingState state = pending_searches_.take(service_id);
|
||||
const int search_id = state.orig_id_;
|
||||
|
||||
if (songs.isEmpty()) {
|
||||
emit SearchError(search_id, error);
|
||||
return;
|
||||
}
|
||||
|
||||
ResultList results;
|
||||
for (const Song &song : songs) {
|
||||
Result result;
|
||||
@@ -157,13 +163,7 @@ void InternetSearch::SearchDone(int service_id, const SongList &songs) {
|
||||
|
||||
}
|
||||
|
||||
void InternetSearch::HandleError(const int id, const QString error) {
|
||||
|
||||
emit SearchError(id, error);
|
||||
|
||||
}
|
||||
|
||||
void InternetSearch::MaybeSearchFinished(int id) {
|
||||
void InternetSearch::MaybeSearchFinished(const int id) {
|
||||
|
||||
if (pending_searches_.keys(PendingState(id, QStringList())).isEmpty()) {
|
||||
emit SearchFinished(id);
|
||||
@@ -171,7 +171,7 @@ void InternetSearch::MaybeSearchFinished(int id) {
|
||||
|
||||
}
|
||||
|
||||
void InternetSearch::CancelSearch(int id) {
|
||||
void InternetSearch::CancelSearch(const int id) {
|
||||
|
||||
QMap<int, DelayedSearch>::iterator it;
|
||||
for (it = delayed_searches_.begin(); it != delayed_searches_.end(); ++it) {
|
||||
@@ -219,7 +219,7 @@ int InternetSearch::LoadArtAsync(const InternetSearch::Result &result) {
|
||||
|
||||
}
|
||||
|
||||
void InternetSearch::AlbumArtLoaded(quint64 id, const QImage &image) {
|
||||
void InternetSearch::AlbumArtLoaded(const quint64 id, const QImage &image) {
|
||||
|
||||
if (!cover_loader_tasks_.contains(id)) return;
|
||||
int orig_id = cover_loader_tasks_.take(id);
|
||||
@@ -289,14 +289,29 @@ MimeData *InternetSearch::LoadTracks(const ResultList &results) {
|
||||
|
||||
}
|
||||
|
||||
void InternetSearch::UpdateStatusSlot(QString text) {
|
||||
emit UpdateStatus(text);
|
||||
void InternetSearch::UpdateStatusSlot(const int service_id, const QString &text) {
|
||||
|
||||
if (!pending_searches_.contains(service_id)) return;
|
||||
const PendingState state = pending_searches_[service_id];
|
||||
const int search_id = state.orig_id_;
|
||||
emit UpdateStatus(search_id, text);
|
||||
|
||||
}
|
||||
|
||||
void InternetSearch::ProgressSetMaximumSlot(int max) {
|
||||
emit ProgressSetMaximum(max);
|
||||
void InternetSearch::ProgressSetMaximumSlot(const int service_id, const int max) {
|
||||
|
||||
if (!pending_searches_.contains(service_id)) return;
|
||||
const PendingState state = pending_searches_[service_id];
|
||||
const int search_id = state.orig_id_;
|
||||
emit ProgressSetMaximum(search_id, max);
|
||||
|
||||
}
|
||||
|
||||
void InternetSearch::UpdateProgressSlot(int progress) {
|
||||
emit UpdateProgress(progress);
|
||||
void InternetSearch::UpdateProgressSlot(const int service_id, const int progress) {
|
||||
|
||||
if (!pending_searches_.contains(service_id)) return;
|
||||
const PendingState state = pending_searches_[service_id];
|
||||
const int search_id = state.orig_id_;
|
||||
emit UpdateProgress(search_id, progress);
|
||||
|
||||
}
|
||||
|
||||
@@ -69,24 +69,24 @@ class InternetSearch : public QObject {
|
||||
int SearchAsync(const QString &query, SearchType type);
|
||||
int LoadArtAsync(const InternetSearch::Result &result);
|
||||
|
||||
void CancelSearch(int id);
|
||||
void CancelArt(int id);
|
||||
void CancelSearch(const int id);
|
||||
void CancelArt(const int id);
|
||||
|
||||
// Loads tracks for results that were previously emitted by ResultsAvailable.
|
||||
// The implementation creates a SongMimeData with one Song for each Result.
|
||||
MimeData *LoadTracks(const ResultList &results);
|
||||
|
||||
signals:
|
||||
void SearchAsyncSig(int id, const QString &query, SearchType type);
|
||||
void ResultsAvailable(int id, const InternetSearch::ResultList &results);
|
||||
void AddResults(int id, const InternetSearch::ResultList &results);
|
||||
void SearchError(const int id, const QString error);
|
||||
void SearchFinished(int id);
|
||||
void UpdateStatus(QString text);
|
||||
void ProgressSetMaximum(int progress);
|
||||
void UpdateProgress(int max);
|
||||
void SearchAsyncSig(const int id, const QString &query, const SearchType type);
|
||||
void ResultsAvailable(const int id, const InternetSearch::ResultList &results);
|
||||
void AddResults(const int id, const InternetSearch::ResultList &results);
|
||||
void SearchError(const int id, const QString &error);
|
||||
void SearchFinished(const int id);
|
||||
void UpdateStatus(const int id, const QString &text);
|
||||
void ProgressSetMaximum(const int id, const int progress);
|
||||
void UpdateProgress(const int id, const int max);
|
||||
|
||||
void ArtLoaded(int id, const QPixmap &pixmap);
|
||||
void ArtLoaded(const int id, const QPixmap &pixmap);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -114,22 +114,20 @@ class InternetSearch : public QObject {
|
||||
static bool Matches(const QStringList &tokens, const QString &string);
|
||||
|
||||
private slots:
|
||||
void DoSearchAsync(int id, const QString &query, SearchType type);
|
||||
void SearchDone(int id, const SongList &songs);
|
||||
void HandleError(const int id, const QString error);
|
||||
void DoSearchAsync(const int id, const QString &query, const SearchType type);
|
||||
void SearchDone(const int service_id, const SongList &songs, const QString &error);
|
||||
|
||||
void AlbumArtLoaded(quint64 id, const QImage &image);
|
||||
void AlbumArtLoaded(const quint64 id, const QImage &image);
|
||||
|
||||
void UpdateStatusSlot(QString text);
|
||||
void ProgressSetMaximumSlot(int progress);
|
||||
void UpdateProgressSlot(int max);
|
||||
void UpdateStatusSlot(const int id, const QString &text);
|
||||
void ProgressSetMaximumSlot(const int id, const int progress);
|
||||
void UpdateProgressSlot(const int id, const int max);
|
||||
|
||||
private:
|
||||
void SearchAsync(int id, const QString &query, SearchType type);
|
||||
void HandleLoadedArt(int id, const QImage &image);
|
||||
void SearchAsync(const int id, const QString &query, const SearchType type);
|
||||
bool FindCachedPixmap(const InternetSearch::Result &result, QPixmap *pixmap) const;
|
||||
QString PixmapCacheKey(const InternetSearch::Result &result) const;
|
||||
void MaybeSearchFinished(int id);
|
||||
void MaybeSearchFinished(const int id);
|
||||
void ShowConfig() {}
|
||||
static QImage ScaleAndPad(const QImage &image);
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ InternetSearchView::InternetSearchView(QWidget *parent)
|
||||
|
||||
InternetSearchView::~InternetSearchView() { delete ui_; }
|
||||
|
||||
void InternetSearchView::Init(Application *app, InternetSearch *engine, QString settings_group, SettingsDialog::Page settings_page, const bool artists, const bool albums, const bool songs) {
|
||||
void InternetSearchView::Init(Application *app, InternetSearch *engine, const QString &settings_group, const SettingsDialog::Page settings_page, const bool artists, const bool albums, const bool songs) {
|
||||
|
||||
app_ = app;
|
||||
engine_ = engine;
|
||||
@@ -167,13 +167,13 @@ void InternetSearchView::Init(Application *app, InternetSearch *engine, QString
|
||||
|
||||
// These have to be queued connections because they may get emitted before our call to Search() (or whatever) returns and we add the ID to the map.
|
||||
|
||||
connect(engine_, SIGNAL(UpdateStatus(QString)), SLOT(UpdateStatus(QString)));
|
||||
connect(engine_, SIGNAL(ProgressSetMaximum(int)), SLOT(ProgressSetMaximum(int)), Qt::QueuedConnection);
|
||||
connect(engine_, SIGNAL(UpdateProgress(int)), SLOT(UpdateProgress(int)), Qt::QueuedConnection);
|
||||
connect(engine_, SIGNAL(UpdateStatus(const int, const QString&)), SLOT(UpdateStatus(const int, const QString&)));
|
||||
connect(engine_, SIGNAL(ProgressSetMaximum(const int, const int)), SLOT(ProgressSetMaximum(const int, const int)), Qt::QueuedConnection);
|
||||
connect(engine_, SIGNAL(UpdateProgress(const int, const int)), SLOT(UpdateProgress(const int, const int)), Qt::QueuedConnection);
|
||||
|
||||
connect(engine_, SIGNAL(AddResults(int, InternetSearch::ResultList)), SLOT(AddResults(int, InternetSearch::ResultList)), Qt::QueuedConnection);
|
||||
connect(engine_, SIGNAL(SearchError(int, QString)), SLOT(SearchError(int, QString)), Qt::QueuedConnection);
|
||||
connect(engine_, SIGNAL(ArtLoaded(int, QPixmap)), SLOT(ArtLoaded(int, QPixmap)), Qt::QueuedConnection);
|
||||
connect(engine_, SIGNAL(AddResults(const int, InternetSearch::ResultList)), SLOT(AddResults(const int, const InternetSearch::ResultList)), Qt::QueuedConnection);
|
||||
connect(engine_, SIGNAL(SearchError(const int, const QString&)), SLOT(SearchError(const int, const QString&)), Qt::QueuedConnection);
|
||||
connect(engine_, SIGNAL(ArtLoaded(const int, const QPixmap&)), SLOT(ArtLoaded(const int, const QPixmap&)), Qt::QueuedConnection);
|
||||
|
||||
ReloadSettings();
|
||||
|
||||
@@ -253,7 +253,7 @@ void InternetSearchView::TextEdited(const QString &text) {
|
||||
|
||||
}
|
||||
|
||||
void InternetSearchView::AddResults(int id, const InternetSearch::ResultList &results) {
|
||||
void InternetSearchView::AddResults(const int id, const InternetSearch::ResultList &results) {
|
||||
|
||||
if (id != last_search_id_) return;
|
||||
if (results.isEmpty()) return;
|
||||
@@ -264,8 +264,9 @@ void InternetSearchView::AddResults(int id, const InternetSearch::ResultList &re
|
||||
|
||||
}
|
||||
|
||||
void InternetSearchView::SearchError(const int id, const QString error) {
|
||||
void InternetSearchView::SearchError(const int id, const QString &error) {
|
||||
|
||||
if (id != last_search_id_) return;
|
||||
error_ = true;
|
||||
ui_->label_helptext->setText(error);
|
||||
ui_->label_status->clear();
|
||||
@@ -594,17 +595,26 @@ void InternetSearchView::SetSearchType(InternetSearch::SearchType type) {
|
||||
TextEdited(ui_->search->text());
|
||||
}
|
||||
|
||||
void InternetSearchView::UpdateStatus(QString text) {
|
||||
void InternetSearchView::UpdateStatus(const int id, const QString &text) {
|
||||
|
||||
if (id != last_search_id_) return;
|
||||
ui_->progressbar->show();
|
||||
ui_->label_status->setText(text);
|
||||
|
||||
}
|
||||
|
||||
void InternetSearchView::ProgressSetMaximum(int max) {
|
||||
void InternetSearchView::ProgressSetMaximum(const int id, const int max) {
|
||||
|
||||
if (id != last_search_id_) return;
|
||||
ui_->progressbar->setMaximum(max);
|
||||
|
||||
}
|
||||
|
||||
void InternetSearchView::UpdateProgress(int progress) {
|
||||
void InternetSearchView::UpdateProgress(const int id, const int progress) {
|
||||
|
||||
if (id != last_search_id_) return;
|
||||
ui_->progressbar->setValue(progress);
|
||||
|
||||
}
|
||||
|
||||
void InternetSearchView::AddArtists() {
|
||||
|
||||
@@ -59,7 +59,7 @@ class InternetSearchView : public QWidget {
|
||||
InternetSearchView(QWidget *parent = nullptr);
|
||||
~InternetSearchView();
|
||||
|
||||
void Init(Application *app, InternetSearch *engine, QString settings_group, SettingsDialog::Page settings_page, const bool artists = false, const bool albums = false, const bool songs = false);
|
||||
void Init(Application *app, InternetSearch *engine, const QString &settings_group, const SettingsDialog::Page settings_page, const bool artists = false, const bool albums = false, const bool songs = false);
|
||||
|
||||
static const int kSwapModelsTimeoutMsec;
|
||||
|
||||
@@ -84,12 +84,12 @@ class InternetSearchView : public QWidget {
|
||||
private slots:
|
||||
void SwapModels();
|
||||
void TextEdited(const QString &text);
|
||||
void UpdateStatus(QString text);
|
||||
void ProgressSetMaximum(int progress);
|
||||
void UpdateProgress(int max);
|
||||
void AddResults(int id, const InternetSearch::ResultList &results);
|
||||
void SearchError(const int id, const QString error);
|
||||
void ArtLoaded(int id, const QPixmap &pixmap);
|
||||
void UpdateStatus(const int id, const QString &text);
|
||||
void ProgressSetMaximum(const int id, const int progress);
|
||||
void UpdateProgress(const int id, const int max);
|
||||
void AddResults(const int id, const InternetSearch::ResultList &results);
|
||||
void SearchError(const int id, const QString &error);
|
||||
void ArtLoaded(const int id, const QPixmap &pixmap);
|
||||
|
||||
void FocusOnFilter(QKeyEvent *event);
|
||||
|
||||
|
||||
@@ -87,35 +87,31 @@ class InternetService : public QObject {
|
||||
void TestFailure(QString failure_reason);
|
||||
void TestComplete(bool success, QString error = QString());
|
||||
|
||||
void Error(QString message);
|
||||
void Results(SongList songs);
|
||||
void UpdateStatus(QString text);
|
||||
void ProgressSetMaximum(int max);
|
||||
void UpdateProgress(int max);
|
||||
void Error(const QString &error);
|
||||
void Results(const SongList &songs, const QString &error);
|
||||
void UpdateStatus(const QString &text);
|
||||
void ProgressSetMaximum(const int max);
|
||||
void UpdateProgress(const int max);
|
||||
|
||||
void ArtistsError(QString message);
|
||||
void ArtistsResults(SongList songs);
|
||||
void ArtistsUpdateStatus(QString text);
|
||||
void ArtistsProgressSetMaximum(int max);
|
||||
void ArtistsUpdateProgress(int max);
|
||||
void ArtistsResults(const SongList &songs, const QString &error);
|
||||
void ArtistsUpdateStatus(const QString &text);
|
||||
void ArtistsProgressSetMaximum(const int max);
|
||||
void ArtistsUpdateProgress(const int max);
|
||||
|
||||
void AlbumsError(QString message);
|
||||
void AlbumsResults(SongList songs);
|
||||
void AlbumsUpdateStatus(QString text);
|
||||
void AlbumsProgressSetMaximum(int max);
|
||||
void AlbumsUpdateProgress(int max);
|
||||
void AlbumsResults(const SongList &songs, const QString &error);
|
||||
void AlbumsUpdateStatus(const QString &text);
|
||||
void AlbumsProgressSetMaximum(const int max);
|
||||
void AlbumsUpdateProgress(const int max);
|
||||
|
||||
void SongsError(QString message);
|
||||
void SongsResults(SongList songs);
|
||||
void SongsUpdateStatus(QString text);
|
||||
void SongsProgressSetMaximum(int max);
|
||||
void SongsUpdateProgress(int max);
|
||||
void SongsResults(const SongList &songs, const QString &error);
|
||||
void SongsUpdateStatus(const QString &text);
|
||||
void SongsProgressSetMaximum(const int max);
|
||||
void SongsUpdateProgress(const int max);
|
||||
|
||||
void SearchResults(int id, SongList songs);
|
||||
void SearchError(int id, QString message);
|
||||
void SearchUpdateStatus(QString text);
|
||||
void SearchProgressSetMaximum(int max);
|
||||
void SearchUpdateProgress(int max);
|
||||
void SearchResults(const int id, const SongList &songs, const QString &error);
|
||||
void SearchUpdateStatus(const int id, const QString &text);
|
||||
void SearchProgressSetMaximum(const int id, const int max);
|
||||
void SearchUpdateProgress(const int id, const int max);
|
||||
|
||||
void AddArtists(const SongList& songs);
|
||||
void AddAlbums(const SongList& songs);
|
||||
|
||||
@@ -57,11 +57,10 @@ InternetSongsView::InternetSongsView(Application *app, InternetService *service,
|
||||
connect(ui_->refresh, SIGNAL(clicked()), SLOT(GetSongs()));
|
||||
connect(ui_->close, SIGNAL(clicked()), SLOT(AbortGetSongs()));
|
||||
connect(ui_->abort, SIGNAL(clicked()), SLOT(AbortGetSongs()));
|
||||
connect(service_, SIGNAL(SongsResults(SongList)), SLOT(SongsFinished(SongList)));
|
||||
connect(service_, SIGNAL(SongsError(QString)), SLOT(SongsError(QString)));
|
||||
connect(service_, SIGNAL(SongsUpdateStatus(QString)), ui_->status, SLOT(setText(QString)));
|
||||
connect(service_, SIGNAL(SongsProgressSetMaximum(int)), ui_->progressbar, SLOT(setMaximum(int)));
|
||||
connect(service_, SIGNAL(SongsUpdateProgress(int)), ui_->progressbar, SLOT(setValue(int)));
|
||||
connect(service_, SIGNAL(SongsResults(const SongList&, const QString&)), SLOT(SongsFinished(const SongList&, const QString&)));
|
||||
connect(service_, SIGNAL(SongsUpdateStatus(const QString&)), ui_->status, SLOT(setText(const QString&)));
|
||||
connect(service_, SIGNAL(SongsProgressSetMaximum(const int)), ui_->progressbar, SLOT(setMaximum(const int)));
|
||||
connect(service_, SIGNAL(SongsUpdateProgress(const int)), ui_->progressbar, SLOT(setValue(const int)));
|
||||
|
||||
connect(service_->songs_collection_model(), SIGNAL(TotalArtistCountUpdated(int)), ui_->view, SLOT(TotalArtistCountUpdated(int)));
|
||||
connect(service_->songs_collection_model(), SIGNAL(TotalAlbumCountUpdated(int)), ui_->view, SLOT(TotalAlbumCountUpdated(int)));
|
||||
@@ -104,21 +103,20 @@ void InternetSongsView::AbortGetSongs() {
|
||||
|
||||
}
|
||||
|
||||
void InternetSongsView::SongsError(QString error) {
|
||||
void InternetSongsView::SongsFinished(const SongList &songs, const QString &error) {
|
||||
|
||||
ui_->status->setText(error);
|
||||
ui_->progressbar->setValue(0);
|
||||
ui_->progressbar->hide();
|
||||
ui_->abort->hide();
|
||||
ui_->close->show();
|
||||
|
||||
}
|
||||
|
||||
void InternetSongsView::SongsFinished(SongList songs) {
|
||||
|
||||
service_->songs_collection_backend()->DeleteAll();
|
||||
ui_->stacked->setCurrentWidget(ui_->internetcollection_page);
|
||||
ui_->status->clear();
|
||||
service_->songs_collection_backend()->AddOrUpdateSongs(songs);
|
||||
if (songs.isEmpty() && !error.isEmpty()) {
|
||||
ui_->status->setText(error);
|
||||
ui_->progressbar->setValue(0);
|
||||
ui_->progressbar->hide();
|
||||
ui_->abort->hide();
|
||||
ui_->close->show();
|
||||
}
|
||||
else {
|
||||
service_->songs_collection_backend()->DeleteAll();
|
||||
ui_->stacked->setCurrentWidget(ui_->internetcollection_page);
|
||||
ui_->status->clear();
|
||||
service_->songs_collection_backend()->AddOrUpdateSongs(songs);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,8 +52,7 @@ class InternetSongsView : public QWidget {
|
||||
void contextMenuEvent(QContextMenuEvent *e);
|
||||
void GetSongs();
|
||||
void AbortGetSongs();;
|
||||
void SongsError(QString error);
|
||||
void SongsFinished(SongList songs);
|
||||
void SongsFinished(const SongList &songs, const QString &error);
|
||||
|
||||
private:
|
||||
Application *app_;
|
||||
|
||||
@@ -65,11 +65,10 @@ InternetTabsView::InternetTabsView(Application *app, InternetService *service, I
|
||||
connect(ui_->artists_collection->button_refresh(), SIGNAL(clicked()), SLOT(GetArtists()));
|
||||
connect(ui_->artists_collection->button_close(), SIGNAL(clicked()), SLOT(AbortGetArtists()));
|
||||
connect(ui_->artists_collection->button_abort(), SIGNAL(clicked()), SLOT(AbortGetArtists()));
|
||||
connect(service_, SIGNAL(ArtistsResults(SongList)), SLOT(ArtistsFinished(SongList)));
|
||||
connect(service_, SIGNAL(ArtistsError(QString)), SLOT(ArtistsError(QString)));
|
||||
connect(service_, SIGNAL(ArtistsUpdateStatus(QString)), ui_->artists_collection->status(), SLOT(setText(QString)));
|
||||
connect(service_, SIGNAL(ArtistsProgressSetMaximum(int)), ui_->artists_collection->progressbar(), SLOT(setMaximum(int)));
|
||||
connect(service_, SIGNAL(ArtistsUpdateProgress(int)), ui_->artists_collection->progressbar(), SLOT(setValue(int)));
|
||||
connect(service_, SIGNAL(ArtistsResults(const SongList&, const QString&)), SLOT(ArtistsFinished(const SongList&, const QString&)));
|
||||
connect(service_, SIGNAL(ArtistsUpdateStatus(const QString&)), ui_->artists_collection->status(), SLOT(setText(const QString&)));
|
||||
connect(service_, SIGNAL(ArtistsProgressSetMaximum(const int)), ui_->artists_collection->progressbar(), SLOT(setMaximum(const int)));
|
||||
connect(service_, SIGNAL(ArtistsUpdateProgress(const int)), ui_->artists_collection->progressbar(), SLOT(setValue(const int)));
|
||||
|
||||
connect(service_->artists_collection_model(), SIGNAL(TotalArtistCountUpdated(int)), ui_->artists_collection->view(), SLOT(TotalArtistCountUpdated(int)));
|
||||
connect(service_->artists_collection_model(), SIGNAL(TotalAlbumCountUpdated(int)), ui_->artists_collection->view(), SLOT(TotalAlbumCountUpdated(int)));
|
||||
@@ -97,11 +96,10 @@ InternetTabsView::InternetTabsView(Application *app, InternetService *service, I
|
||||
connect(ui_->albums_collection->button_refresh(), SIGNAL(clicked()), SLOT(GetAlbums()));
|
||||
connect(ui_->albums_collection->button_close(), SIGNAL(clicked()), SLOT(AbortGetAlbums()));
|
||||
connect(ui_->albums_collection->button_abort(), SIGNAL(clicked()), SLOT(AbortGetAlbums()));
|
||||
connect(service_, SIGNAL(AlbumsResults(SongList)), SLOT(AlbumsFinished(SongList)));
|
||||
connect(service_, SIGNAL(AlbumsError(QString)), SLOT(AlbumsError(QString)));
|
||||
connect(service_, SIGNAL(AlbumsUpdateStatus(QString)), ui_->albums_collection->status(), SLOT(setText(QString)));
|
||||
connect(service_, SIGNAL(AlbumsProgressSetMaximum(int)), ui_->albums_collection->progressbar(), SLOT(setMaximum(int)));
|
||||
connect(service_, SIGNAL(AlbumsUpdateProgress(int)), ui_->albums_collection->progressbar(), SLOT(setValue(int)));
|
||||
connect(service_, SIGNAL(AlbumsResults(const SongList&, const QString&)), SLOT(AlbumsFinished(const SongList&, const QString&)));
|
||||
connect(service_, SIGNAL(AlbumsUpdateStatus(const QString&)), ui_->albums_collection->status(), SLOT(setText(const QString&)));
|
||||
connect(service_, SIGNAL(AlbumsProgressSetMaximum(const int)), ui_->albums_collection->progressbar(), SLOT(setMaximum(const int)));
|
||||
connect(service_, SIGNAL(AlbumsUpdateProgress(const int)), ui_->albums_collection->progressbar(), SLOT(setValue(const int)));
|
||||
|
||||
connect(service_->albums_collection_model(), SIGNAL(TotalArtistCountUpdated(int)), ui_->albums_collection->view(), SLOT(TotalArtistCountUpdated(int)));
|
||||
connect(service_->albums_collection_model(), SIGNAL(TotalAlbumCountUpdated(int)), ui_->albums_collection->view(), SLOT(TotalAlbumCountUpdated(int)));
|
||||
@@ -129,11 +127,10 @@ InternetTabsView::InternetTabsView(Application *app, InternetService *service, I
|
||||
connect(ui_->songs_collection->button_refresh(), SIGNAL(clicked()), SLOT(GetSongs()));
|
||||
connect(ui_->songs_collection->button_close(), SIGNAL(clicked()), SLOT(AbortGetSongs()));
|
||||
connect(ui_->songs_collection->button_abort(), SIGNAL(clicked()), SLOT(AbortGetSongs()));
|
||||
connect(service_, SIGNAL(SongsResults(SongList)), SLOT(SongsFinished(SongList)));
|
||||
connect(service_, SIGNAL(SongsError(QString)), SLOT(SongsError(QString)));
|
||||
connect(service_, SIGNAL(SongsUpdateStatus(QString)), ui_->songs_collection->status(), SLOT(setText(QString)));
|
||||
connect(service_, SIGNAL(SongsProgressSetMaximum(int)), ui_->songs_collection->progressbar(), SLOT(setMaximum(int)));
|
||||
connect(service_, SIGNAL(SongsUpdateProgress(int)), ui_->songs_collection->progressbar(), SLOT(setValue(int)));
|
||||
connect(service_, SIGNAL(SongsResults(const SongList&, const QString&)), SLOT(SongsFinished(const SongList&, const QString&)));
|
||||
connect(service_, SIGNAL(SongsUpdateStatus(const QString&)), ui_->songs_collection->status(), SLOT(setText(const QString&)));
|
||||
connect(service_, SIGNAL(SongsProgressSetMaximum(const int)), ui_->songs_collection->progressbar(), SLOT(setMaximum(const int)));
|
||||
connect(service_, SIGNAL(SongsUpdateProgress(const int)), ui_->songs_collection->progressbar(), SLOT(setValue(const int)));
|
||||
|
||||
connect(service_->songs_collection_model(), SIGNAL(TotalArtistCountUpdated(int)), ui_->songs_collection->view(), SLOT(TotalArtistCountUpdated(int)));
|
||||
connect(service_->songs_collection_model(), SIGNAL(TotalAlbumCountUpdated(int)), ui_->songs_collection->view(), SLOT(TotalAlbumCountUpdated(int)));
|
||||
@@ -208,22 +205,21 @@ void InternetTabsView::AbortGetArtists() {
|
||||
|
||||
}
|
||||
|
||||
void InternetTabsView::ArtistsError(QString error) {
|
||||
void InternetTabsView::ArtistsFinished(const SongList &songs, const QString &error) {
|
||||
|
||||
ui_->artists_collection->status()->setText(error);
|
||||
ui_->artists_collection->progressbar()->setValue(0);
|
||||
ui_->artists_collection->progressbar()->hide();
|
||||
ui_->artists_collection->button_abort()->hide();
|
||||
ui_->artists_collection->button_close()->show();
|
||||
|
||||
}
|
||||
|
||||
void InternetTabsView::ArtistsFinished(SongList songs) {
|
||||
|
||||
service_->artists_collection_backend()->DeleteAll();
|
||||
ui_->artists_collection->stacked()->setCurrentWidget(ui_->artists_collection->internetcollection_page());
|
||||
ui_->artists_collection->status()->clear();
|
||||
service_->artists_collection_backend()->AddOrUpdateSongs(songs);
|
||||
if (songs.isEmpty() && !error.isEmpty()) {
|
||||
ui_->artists_collection->status()->setText(error);
|
||||
ui_->artists_collection->progressbar()->setValue(0);
|
||||
ui_->artists_collection->progressbar()->hide();
|
||||
ui_->artists_collection->button_abort()->hide();
|
||||
ui_->artists_collection->button_close()->show();
|
||||
}
|
||||
else {
|
||||
service_->artists_collection_backend()->DeleteAll();
|
||||
ui_->artists_collection->stacked()->setCurrentWidget(ui_->artists_collection->internetcollection_page());
|
||||
ui_->artists_collection->status()->clear();
|
||||
service_->artists_collection_backend()->AddOrUpdateSongs(songs);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -252,22 +248,21 @@ void InternetTabsView::AbortGetAlbums() {
|
||||
|
||||
}
|
||||
|
||||
void InternetTabsView::AlbumsError(QString error) {
|
||||
void InternetTabsView::AlbumsFinished(const SongList &songs, const QString &error) {
|
||||
|
||||
ui_->albums_collection->status()->setText(error);
|
||||
ui_->albums_collection->progressbar()->setValue(0);
|
||||
ui_->albums_collection->progressbar()->hide();
|
||||
ui_->albums_collection->button_abort()->hide();
|
||||
ui_->albums_collection->button_close()->show();
|
||||
|
||||
}
|
||||
|
||||
void InternetTabsView::AlbumsFinished(SongList songs) {
|
||||
|
||||
service_->albums_collection_backend()->DeleteAll();
|
||||
ui_->albums_collection->stacked()->setCurrentWidget(ui_->albums_collection->internetcollection_page());
|
||||
ui_->albums_collection->status()->clear();
|
||||
service_->albums_collection_backend()->AddOrUpdateSongs(songs);
|
||||
if (songs.isEmpty() && !error.isEmpty()) {
|
||||
ui_->albums_collection->status()->setText(error);
|
||||
ui_->albums_collection->progressbar()->setValue(0);
|
||||
ui_->albums_collection->progressbar()->hide();
|
||||
ui_->albums_collection->button_abort()->hide();
|
||||
ui_->albums_collection->button_close()->show();
|
||||
}
|
||||
else {
|
||||
service_->albums_collection_backend()->DeleteAll();
|
||||
ui_->albums_collection->stacked()->setCurrentWidget(ui_->albums_collection->internetcollection_page());
|
||||
ui_->albums_collection->status()->clear();
|
||||
service_->albums_collection_backend()->AddOrUpdateSongs(songs);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -296,21 +291,20 @@ void InternetTabsView::AbortGetSongs() {
|
||||
|
||||
}
|
||||
|
||||
void InternetTabsView::SongsError(QString error) {
|
||||
void InternetTabsView::SongsFinished(const SongList &songs, const QString &error) {
|
||||
|
||||
ui_->songs_collection->status()->setText(error);
|
||||
ui_->songs_collection->progressbar()->setValue(0);
|
||||
ui_->songs_collection->progressbar()->hide();
|
||||
ui_->songs_collection->button_abort()->hide();
|
||||
ui_->songs_collection->button_close()->show();
|
||||
|
||||
}
|
||||
|
||||
void InternetTabsView::SongsFinished(SongList songs) {
|
||||
|
||||
service_->songs_collection_backend()->DeleteAll();
|
||||
ui_->songs_collection->stacked()->setCurrentWidget(ui_->songs_collection->internetcollection_page());
|
||||
ui_->songs_collection->status()->clear();
|
||||
service_->songs_collection_backend()->AddOrUpdateSongs(songs);
|
||||
if (songs.isEmpty() && !error.isEmpty()) {
|
||||
ui_->songs_collection->status()->setText(error);
|
||||
ui_->songs_collection->progressbar()->setValue(0);
|
||||
ui_->songs_collection->progressbar()->hide();
|
||||
ui_->songs_collection->button_abort()->hide();
|
||||
ui_->songs_collection->button_close()->show();
|
||||
}
|
||||
else {
|
||||
service_->songs_collection_backend()->DeleteAll();
|
||||
ui_->songs_collection->stacked()->setCurrentWidget(ui_->songs_collection->internetcollection_page());
|
||||
ui_->songs_collection->status()->clear();
|
||||
service_->songs_collection_backend()->AddOrUpdateSongs(songs);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -62,12 +62,9 @@ class InternetTabsView : public QWidget {
|
||||
void AbortGetArtists();
|
||||
void AbortGetAlbums();
|
||||
void AbortGetSongs();
|
||||
void ArtistsError(QString error);
|
||||
void AlbumsError(QString error);
|
||||
void SongsError(QString error);
|
||||
void ArtistsFinished(SongList songs);
|
||||
void AlbumsFinished(SongList songs);
|
||||
void SongsFinished(SongList songs);
|
||||
void ArtistsFinished(const SongList &songs, const QString &error);
|
||||
void AlbumsFinished(const SongList &songs, const QString &error);
|
||||
void SongsFinished(const SongList &songs, const QString &error);
|
||||
|
||||
private:
|
||||
Application *app_;
|
||||
|
||||
Reference in New Issue
Block a user