Fix minor code issues
This commit is contained in:
@@ -318,6 +318,8 @@ void AlbumCoverChoiceController::SearchCoverAutomatically(const Song &song) {
|
||||
|
||||
void AlbumCoverChoiceController::AlbumCoverFetched(const quint64 id, const QUrl &cover_url, const QImage &image, const CoverSearchStatistics &statistics) {
|
||||
|
||||
Q_UNUSED(statistics);
|
||||
|
||||
Song song;
|
||||
if (cover_fetching_tasks_.contains(id)) {
|
||||
song = cover_fetching_tasks_.take(id);
|
||||
|
||||
@@ -78,11 +78,11 @@ struct CoverSearchResult {
|
||||
float score;
|
||||
|
||||
};
|
||||
Q_DECLARE_METATYPE(CoverSearchResult);
|
||||
Q_DECLARE_METATYPE(CoverSearchResult)
|
||||
|
||||
// This is a complete result of a single search request (a list of results, each describing one image, actually).
|
||||
typedef QList<CoverSearchResult> CoverSearchResults;
|
||||
Q_DECLARE_METATYPE(QList<CoverSearchResult>);
|
||||
Q_DECLARE_METATYPE(QList<CoverSearchResult>)
|
||||
|
||||
// This class searches for album covers for a given query or artist/album and returns URLs. It's NOT thread-safe.
|
||||
class AlbumCoverFetcher : public QObject {
|
||||
|
||||
@@ -359,6 +359,8 @@ void AlbumCoverManager::ArtistChanged(QListWidgetItem *current) {
|
||||
|
||||
void AlbumCoverManager::CoverImageLoaded(const quint64 id, const QUrl &cover_url, const QImage &image) {
|
||||
|
||||
Q_UNUSED(cover_url);
|
||||
|
||||
if (!cover_loading_tasks_.contains(id)) return;
|
||||
|
||||
QListWidgetItem *item = cover_loading_tasks_.take(id);
|
||||
|
||||
@@ -238,6 +238,8 @@ void AlbumCoverSearcher::SearchFinished(const quint64 id, const CoverSearchResul
|
||||
|
||||
void AlbumCoverSearcher::ImageLoaded(const quint64 id, const QUrl &cover_url, const QImage &image) {
|
||||
|
||||
Q_UNUSED(cover_url);
|
||||
|
||||
if (!cover_loading_tasks_.contains(id)) return;
|
||||
QStandardItem *item = cover_loading_tasks_.take(id);
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ class CoverProvider : public QObject {
|
||||
// The provider should remember the ID and emit it along with the result when it finishes.
|
||||
virtual bool StartSearch(const QString &artist, const QString &album, int id) = 0;
|
||||
|
||||
virtual void CancelSearch(int id) {}
|
||||
virtual void CancelSearch(int id) { Q_UNUSED(id); }
|
||||
|
||||
signals:
|
||||
void SearchFinished(int id, const CoverSearchResults& results);
|
||||
|
||||
@@ -60,7 +60,7 @@ class CoverProviders : public QObject {
|
||||
void ProviderDestroyed();
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(CoverProviders);
|
||||
Q_DISABLE_COPY(CoverProviders)
|
||||
|
||||
QMap<CoverProvider*, QString> cover_providers_;
|
||||
QMutex mutex_;
|
||||
|
||||
@@ -64,6 +64,8 @@ void CurrentAlbumCoverLoader::LoadAlbumCover(const Song &song) {
|
||||
|
||||
void CurrentAlbumCoverLoader::TempAlbumCoverLoaded(const quint64 id, const QUrl &remote_url, const QImage &image) {
|
||||
|
||||
Q_UNUSED(remote_url);
|
||||
|
||||
if (id != id_) return;
|
||||
id_ = 0;
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ const int DeezerCoverProvider::kLimit = 10;
|
||||
|
||||
DeezerCoverProvider::DeezerCoverProvider(Application *app, QObject *parent): CoverProvider("Deezer", 2.0, true, app, parent), network_(new NetworkAccessManager(this)) {}
|
||||
|
||||
bool DeezerCoverProvider::StartSearch(const QString &artist, const QString &album, int id) {
|
||||
bool DeezerCoverProvider::StartSearch(const QString &artist, const QString &album, const int id) {
|
||||
|
||||
typedef QPair<QString, QString> Param;
|
||||
typedef QList<Param> Params;
|
||||
@@ -80,7 +80,7 @@ bool DeezerCoverProvider::StartSearch(const QString &artist, const QString &albu
|
||||
|
||||
}
|
||||
|
||||
void DeezerCoverProvider::CancelSearch(int id) {}
|
||||
void DeezerCoverProvider::CancelSearch(const int id) { Q_UNUSED(id); }
|
||||
|
||||
QByteArray DeezerCoverProvider::GetReplyData(QNetworkReply *reply) {
|
||||
|
||||
@@ -131,7 +131,7 @@ QByteArray DeezerCoverProvider::GetReplyData(QNetworkReply *reply) {
|
||||
|
||||
}
|
||||
|
||||
QJsonObject DeezerCoverProvider::ExtractJsonObj(QByteArray &data) {
|
||||
QJsonObject DeezerCoverProvider::ExtractJsonObj(const QByteArray &data) {
|
||||
|
||||
QJsonParseError error;
|
||||
QJsonDocument json_doc = QJsonDocument::fromJson(data, &error);
|
||||
@@ -161,7 +161,7 @@ QJsonObject DeezerCoverProvider::ExtractJsonObj(QByteArray &data) {
|
||||
|
||||
}
|
||||
|
||||
QJsonValue DeezerCoverProvider::ExtractData(QByteArray &data) {
|
||||
QJsonValue DeezerCoverProvider::ExtractData(const QByteArray &data) {
|
||||
|
||||
QJsonObject json_obj = ExtractJsonObj(data);
|
||||
if (json_obj.isEmpty()) return QJsonObject();
|
||||
@@ -193,7 +193,7 @@ QJsonValue DeezerCoverProvider::ExtractData(QByteArray &data) {
|
||||
|
||||
}
|
||||
|
||||
void DeezerCoverProvider::HandleSearchReply(QNetworkReply *reply, int id) {
|
||||
void DeezerCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id) {
|
||||
|
||||
reply->deleteLater();
|
||||
|
||||
@@ -292,7 +292,7 @@ void DeezerCoverProvider::HandleSearchReply(QNetworkReply *reply, int id) {
|
||||
|
||||
}
|
||||
|
||||
void DeezerCoverProvider::Error(QString error, QVariant debug) {
|
||||
void DeezerCoverProvider::Error(const QString &error, const QVariant &debug) {
|
||||
qLog(Error) << "Deezer:" << error;
|
||||
if (debug.isValid()) qLog(Debug) << debug;
|
||||
}
|
||||
|
||||
@@ -43,20 +43,20 @@ class DeezerCoverProvider : public CoverProvider {
|
||||
|
||||
public:
|
||||
explicit DeezerCoverProvider(Application *app, QObject *parent = nullptr);
|
||||
bool StartSearch(const QString &artist, const QString &album, int id);
|
||||
void CancelSearch(int id);
|
||||
bool StartSearch(const QString &artist, const QString &album, const int id);
|
||||
void CancelSearch(const int id);
|
||||
|
||||
private slots:
|
||||
void HandleSearchReply(QNetworkReply *reply, int id);
|
||||
void HandleSearchReply(QNetworkReply *reply, const int id);
|
||||
|
||||
private:
|
||||
static const char *kApiUrl;
|
||||
static const int kLimit;
|
||||
|
||||
QByteArray GetReplyData(QNetworkReply *reply);
|
||||
QJsonObject ExtractJsonObj(QByteArray &data);
|
||||
QJsonValue ExtractData(QByteArray &data);
|
||||
void Error(QString error, QVariant debug = QVariant());
|
||||
QJsonObject ExtractJsonObj(const QByteArray &data);
|
||||
QJsonValue ExtractData(const QByteArray &data);
|
||||
void Error(const QString &error, const QVariant &debug = QVariant());
|
||||
|
||||
QNetworkAccessManager *network_;
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ const char *DiscogsCoverProvider::kSecretKeyB64 = "ZkFIcmlaSER4aHhRSlF2U3d0bm5ZV
|
||||
|
||||
DiscogsCoverProvider::DiscogsCoverProvider(Application *app, QObject *parent) : CoverProvider("Discogs", 0.0, false, app, parent), network_(new NetworkAccessManager(this)) {}
|
||||
|
||||
bool DiscogsCoverProvider::StartSearch(const QString &artist, const QString &album, int s_id) {
|
||||
bool DiscogsCoverProvider::StartSearch(const QString &artist, const QString &album, const int s_id) {
|
||||
|
||||
DiscogsCoverSearchContext *s_ctx = new DiscogsCoverSearchContext;
|
||||
|
||||
@@ -71,12 +71,12 @@ bool DiscogsCoverProvider::StartSearch(const QString &artist, const QString &alb
|
||||
|
||||
}
|
||||
|
||||
void DiscogsCoverProvider::CancelSearch(int id) {
|
||||
void DiscogsCoverProvider::CancelSearch(const int id) {
|
||||
delete requests_search_.take(id);
|
||||
}
|
||||
|
||||
|
||||
bool DiscogsCoverProvider::StartRelease(DiscogsCoverSearchContext *s_ctx, int r_id, QString &resource_url) {
|
||||
bool DiscogsCoverProvider::StartRelease(DiscogsCoverSearchContext *s_ctx, const int r_id, const QString &resource_url) {
|
||||
|
||||
DiscogsCoverReleaseContext *r_ctx = new DiscogsCoverReleaseContext;
|
||||
|
||||
@@ -249,7 +249,7 @@ QJsonObject DiscogsCoverProvider::ExtractJsonObj(const QByteArray &data) {
|
||||
|
||||
}
|
||||
|
||||
QJsonValue DiscogsCoverProvider::ExtractData(const QByteArray &data, const QString name, const bool silent) {
|
||||
QJsonValue DiscogsCoverProvider::ExtractData(const QByteArray &data, const QString &name, const bool silent) {
|
||||
|
||||
QJsonObject json_obj = ExtractJsonObj(data);
|
||||
if (json_obj.isEmpty()) return QJsonObject();
|
||||
@@ -323,7 +323,7 @@ void DiscogsCoverProvider::HandleSearchReply(QNetworkReply *reply, int s_id) {
|
||||
|
||||
}
|
||||
|
||||
void DiscogsCoverProvider::HandleReleaseReply(QNetworkReply *reply, int s_id, int r_id) {
|
||||
void DiscogsCoverProvider::HandleReleaseReply(QNetworkReply *reply, const int s_id, const int r_id) {
|
||||
|
||||
reply->deleteLater();
|
||||
|
||||
@@ -464,7 +464,7 @@ void DiscogsCoverProvider::EndSearch(DiscogsCoverReleaseContext *r_ctx) {
|
||||
delete requests_release_.take(r_ctx->id);
|
||||
}
|
||||
|
||||
void DiscogsCoverProvider::Error(QString error, QVariant debug) {
|
||||
void DiscogsCoverProvider::Error(const QString &error, const QVariant &debug) {
|
||||
qLog(Error) << "Discogs:" << error;
|
||||
if (debug.isValid()) qLog(Debug) << debug;
|
||||
}
|
||||
|
||||
@@ -71,13 +71,13 @@ class DiscogsCoverProvider : public CoverProvider {
|
||||
public:
|
||||
explicit DiscogsCoverProvider(Application *app, QObject *parent = nullptr);
|
||||
|
||||
bool StartSearch(const QString &artist, const QString &album, int s_id);
|
||||
bool StartSearch(const QString &artist, const QString &album, const int s_id);
|
||||
|
||||
void CancelSearch(int id);
|
||||
void CancelSearch(const int id);
|
||||
|
||||
private slots:
|
||||
void HandleSearchReply(QNetworkReply *reply, int s_id);
|
||||
void HandleReleaseReply(QNetworkReply *reply, int s_id, int r_id);
|
||||
void HandleSearchReply(QNetworkReply *reply, const int s_id);
|
||||
void HandleReleaseReply(QNetworkReply *reply, const int s_id, const int r_id);
|
||||
|
||||
private:
|
||||
static const char *kUrlSearch;
|
||||
@@ -89,17 +89,17 @@ class DiscogsCoverProvider : public CoverProvider {
|
||||
QHash<int, DiscogsCoverSearchContext*> requests_search_;
|
||||
QHash<int, DiscogsCoverReleaseContext*> requests_release_;
|
||||
|
||||
bool StartRelease(DiscogsCoverSearchContext *s_ctx, int r_id, QString &resource_url);
|
||||
bool StartRelease(DiscogsCoverSearchContext *s_ctx, const int r_id, const QString &resource_url);
|
||||
|
||||
void SendSearchRequest(DiscogsCoverSearchContext *s_ctx);
|
||||
void SendReleaseRequest(DiscogsCoverSearchContext *s_ctx, DiscogsCoverReleaseContext *r_ctx);
|
||||
QByteArray GetReplyData(QNetworkReply *reply);
|
||||
QJsonObject ExtractJsonObj(const QByteArray &data);
|
||||
QJsonValue ExtractData(const QByteArray &data, const QString name, const bool silent = false);
|
||||
QJsonValue ExtractData(const QByteArray &data, const QString &name, const bool silent = false);
|
||||
void EndSearch(DiscogsCoverSearchContext *s_ctx, DiscogsCoverReleaseContext *r_ctx);
|
||||
void EndSearch(DiscogsCoverSearchContext *s_ctx);
|
||||
void EndSearch(DiscogsCoverReleaseContext *r_ctx);
|
||||
void Error(QString error, QVariant debug = QVariant());
|
||||
void Error(const QString &error, const QVariant &debug = QVariant());
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ const char *LastFmCoverProvider::kSecret = "80fd738f49596e9709b1bf9319c444a8";
|
||||
|
||||
LastFmCoverProvider::LastFmCoverProvider(Application *app, QObject *parent) : CoverProvider("last.fm", 1.0, true, app, parent), network_(new NetworkAccessManager(this)) {}
|
||||
|
||||
bool LastFmCoverProvider::StartSearch(const QString &artist, const QString &album, int id) {
|
||||
bool LastFmCoverProvider::StartSearch(const QString &artist, const QString &album, const int id) {
|
||||
|
||||
typedef QPair<QString, QString> Param;
|
||||
typedef QPair<QByteArray, QByteArray> EncodedParam;
|
||||
@@ -90,7 +90,7 @@ bool LastFmCoverProvider::StartSearch(const QString &artist, const QString &albu
|
||||
|
||||
}
|
||||
|
||||
void LastFmCoverProvider::QueryFinished(QNetworkReply *reply, int id) {
|
||||
void LastFmCoverProvider::QueryFinished(QNetworkReply *reply, const int id) {
|
||||
|
||||
reply->deleteLater();
|
||||
|
||||
@@ -290,12 +290,12 @@ QJsonValue LastFmCoverProvider::ExtractResults(const QByteArray &data) {
|
||||
|
||||
}
|
||||
|
||||
void LastFmCoverProvider::Error(QString error, QVariant debug) {
|
||||
void LastFmCoverProvider::Error(const QString &error, const QVariant &debug) {
|
||||
qLog(Error) << "LastFm:" << error;
|
||||
if (debug.isValid()) qLog(Debug) << debug;
|
||||
}
|
||||
|
||||
LastFmCoverProvider::LastFmImageSize LastFmCoverProvider::ImageSizeFromString(const QString size) {
|
||||
LastFmCoverProvider::LastFmImageSize LastFmCoverProvider::ImageSizeFromString(const QString &size) {
|
||||
if (size == "small") return LastFmImageSize::Small;
|
||||
else if (size == "medium") return LastFmImageSize::Medium;
|
||||
else if (size == "large") return LastFmImageSize::Large;
|
||||
|
||||
@@ -43,10 +43,10 @@ class LastFmCoverProvider : public CoverProvider {
|
||||
|
||||
public:
|
||||
explicit LastFmCoverProvider(Application *app, QObject *parent = nullptr);
|
||||
bool StartSearch(const QString &artist, const QString &album, int id);
|
||||
bool StartSearch(const QString &artist, const QString &album, const int id);
|
||||
|
||||
private slots:
|
||||
void QueryFinished(QNetworkReply *reply, int id);
|
||||
void QueryFinished(QNetworkReply *reply, const int id);
|
||||
|
||||
private:
|
||||
static const char *kUrl;
|
||||
@@ -62,12 +62,11 @@ class LastFmCoverProvider : public CoverProvider {
|
||||
QByteArray GetReplyData(QNetworkReply *reply);
|
||||
QJsonObject ExtractJsonObj(const QByteArray &data);
|
||||
QJsonValue ExtractResults(const QByteArray &data);
|
||||
LastFmImageSize ImageSizeFromString(const QString size);
|
||||
void Error(QString error, QVariant debug = QVariant());
|
||||
LastFmImageSize ImageSizeFromString(const QString &size);
|
||||
void Error(const QString &error, const QVariant &debug = QVariant());
|
||||
|
||||
QNetworkAccessManager *network_;
|
||||
|
||||
};
|
||||
|
||||
#endif // LASTFMCOVERPROVIDER_H
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ const int MusicbrainzCoverProvider::kLimit = 8;
|
||||
|
||||
MusicbrainzCoverProvider::MusicbrainzCoverProvider(Application *app, QObject *parent): CoverProvider("MusicBrainz", 1.5, true, app, parent), network_(new NetworkAccessManager(this)) {}
|
||||
|
||||
bool MusicbrainzCoverProvider::StartSearch(const QString &artist, const QString &album, int id) {
|
||||
bool MusicbrainzCoverProvider::StartSearch(const QString &artist, const QString &album, const int id) {
|
||||
|
||||
QString query = QString("release:\"%1\" AND artist:\"%2\"").arg(album.trimmed().replace('"', "\\\"")).arg(artist.trimmed().replace('"', "\\\""));
|
||||
|
||||
@@ -73,9 +73,9 @@ bool MusicbrainzCoverProvider::StartSearch(const QString &artist, const QString
|
||||
|
||||
}
|
||||
|
||||
void MusicbrainzCoverProvider::CancelSearch(int id) {}
|
||||
void MusicbrainzCoverProvider::CancelSearch(const int id) { Q_UNUSED(id); }
|
||||
|
||||
void MusicbrainzCoverProvider::HandleSearchReply(QNetworkReply *reply, int search_id) {
|
||||
void MusicbrainzCoverProvider::HandleSearchReply(QNetworkReply *reply, const int search_id) {
|
||||
|
||||
reply->deleteLater();
|
||||
|
||||
|
||||
@@ -42,11 +42,11 @@ class MusicbrainzCoverProvider : public CoverProvider {
|
||||
public:
|
||||
explicit MusicbrainzCoverProvider(Application *app, QObject *parent = nullptr);
|
||||
|
||||
bool StartSearch(const QString &artist, const QString &album, int id);
|
||||
void CancelSearch(int id);
|
||||
bool StartSearch(const QString &artist, const QString &album, const int id);
|
||||
void CancelSearch(const int id);
|
||||
|
||||
private slots:
|
||||
void HandleSearchReply(QNetworkReply *reply, int search_id);
|
||||
void HandleSearchReply(QNetworkReply *reply, const int search_id);
|
||||
|
||||
private:
|
||||
QByteArray GetReplyData(QNetworkReply *reply);
|
||||
|
||||
@@ -71,7 +71,7 @@ bool TidalCoverProvider::StartSearch(const QString &artist, const QString &album
|
||||
|
||||
}
|
||||
|
||||
void TidalCoverProvider::CancelSearch(int id) {}
|
||||
void TidalCoverProvider::CancelSearch(int id) { Q_UNUSED(id); }
|
||||
|
||||
QNetworkReply *TidalCoverProvider::CreateRequest(const QString &ressource_name, const ParamList ¶ms_supplied) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user