Change to const references, make search progress and status pass search id

This commit is contained in:
Jonas Kvinge
2019-06-20 16:33:28 +02:00
parent 9d222e2c57
commit bf4001968e
22 changed files with 499 additions and 482 deletions

View File

@@ -722,15 +722,8 @@ void SubsonicRequest::FinishCheck() {
album_covers_received_ >= album_covers_requested_
) {
finished_ = true;
if (songs_.isEmpty()) {
if (no_results_) emit Results(songs_);
else if (errors_.isEmpty()) emit ErrorSignal(tr("Unknown error"));
else emit ErrorSignal(errors_);
}
else {
emit Results(songs_);
}
if (no_results_) emit Results(SongList(), QString());
else emit Results(songs_, errors_);
}
}

View File

@@ -58,12 +58,10 @@ class SubsonicRequest : public SubsonicBaseRequest {
void Reset();
signals:
void Results(SongList songs);
void ErrorSignal(QString message);
void ErrorSignal(int id, QString message);
void UpdateStatus(QString text);
void ProgressSetMaximum(int max);
void UpdateProgress(int max);
void Results(const SongList &songs, const QString &error);
void UpdateStatus(const QString &text);
void ProgressSetMaximum(const int max);
void UpdateProgress(const int max);
private slots:

View File

@@ -321,25 +321,18 @@ void SubsonicService::GetSongs() {
ResetSongsRequest();
songs_request_.reset(new SubsonicRequest(this, url_handler_, network_, this));
connect(songs_request_.get(), SIGNAL(ErrorSignal(QString)), SLOT(SongsErrorReceived(QString)));
connect(songs_request_.get(), SIGNAL(Results(SongList)), SLOT(SongsResultsReceived(SongList)));
connect(songs_request_.get(), SIGNAL(UpdateStatus(QString)), SIGNAL(SongsUpdateStatus(QString)));
connect(songs_request_.get(), SIGNAL(ProgressSetMaximum(int)), SIGNAL(SongsProgressSetMaximum(int)));
connect(songs_request_.get(), SIGNAL(UpdateProgress(int)), SIGNAL(SongsUpdateProgress(int)));
connect(songs_request_.get(), SIGNAL(Results(const SongList&, const QString&)), SLOT(SongsResultsReceived(const SongList&, const QString&)));
connect(songs_request_.get(), SIGNAL(UpdateStatus(const QString&)), SIGNAL(SongsUpdateStatus(const QString&)));
connect(songs_request_.get(), SIGNAL(ProgressSetMaximum(const int)), SIGNAL(SongsProgressSetMaximum(const int)));
connect(songs_request_.get(), SIGNAL(UpdateProgress(const int)), SIGNAL(SongsUpdateProgress(const int)));
songs_request_->GetAlbums();
}
void SubsonicService::SongsResultsReceived(SongList songs) {
void SubsonicService::SongsResultsReceived(const SongList &songs, const QString &error) {
emit SongsResults(songs);
}
void SubsonicService::SongsErrorReceived(QString error) {
emit SongsError(error);
emit SongsResults(songs, error);
}

View File

@@ -90,8 +90,7 @@ class SubsonicService : public InternetService {
private slots:
void HandlePingReply(QNetworkReply *reply);
void SongsResultsReceived(SongList songs);
void SongsErrorReceived(QString error);
void SongsResultsReceived(const SongList &songs, const QString &error);
private:
typedef QPair<QString, QString> Param;