LyricsFetcher: Change request ID to quint64
This commit is contained in:
@@ -431,7 +431,7 @@ void ContextView::SearchLyrics() {
|
|||||||
if (lyrics_.isEmpty() && action_show_lyrics_->isChecked() && action_search_lyrics_->isChecked() && !song_playing_.artist().isEmpty() && !song_playing_.title().isEmpty() && !lyrics_tried_ && lyrics_id_ == -1) {
|
if (lyrics_.isEmpty() && action_show_lyrics_->isChecked() && action_search_lyrics_->isChecked() && !song_playing_.artist().isEmpty() && !song_playing_.title().isEmpty() && !lyrics_tried_ && lyrics_id_ == -1) {
|
||||||
lyrics_fetcher_->Clear();
|
lyrics_fetcher_->Clear();
|
||||||
lyrics_tried_ = true;
|
lyrics_tried_ = true;
|
||||||
lyrics_id_ = lyrics_fetcher_->Search(song_playing_.effective_albumartist(), song_playing_.album(), song_playing_.title());
|
lyrics_id_ = static_cast<qint64>(lyrics_fetcher_->Search(song_playing_.effective_albumartist(), song_playing_.album(), song_playing_.title()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -715,9 +715,9 @@ void ContextView::ResetSong() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextView::UpdateLyrics(const int id, const QString &provider, const QString &lyrics) {
|
void ContextView::UpdateLyrics(const quint64 id, const QString &provider, const QString &lyrics) {
|
||||||
|
|
||||||
if (id != lyrics_id_) return;
|
if (static_cast<qint64>(id) != lyrics_id_) return;
|
||||||
lyrics_ = lyrics + "\n\n(Lyrics from " + provider + ")\n";
|
lyrics_ = lyrics + "\n\n(Lyrics from " + provider + ")\n";
|
||||||
lyrics_id_ = -1;
|
lyrics_id_ = -1;
|
||||||
if (action_show_lyrics_->isChecked()) {
|
if (action_show_lyrics_->isChecked()) {
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ class ContextView : public QWidget {
|
|||||||
void ActionSearchLyrics();
|
void ActionSearchLyrics();
|
||||||
void UpdateNoSong();
|
void UpdateNoSong();
|
||||||
void FadeStopFinished();
|
void FadeStopFinished();
|
||||||
void UpdateLyrics(const int id, const QString &provider, const QString &lyrics);
|
void UpdateLyrics(const quint64 id, const QString &provider, const QString &lyrics);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void ReloadSettings();
|
void ReloadSettings();
|
||||||
@@ -171,7 +171,7 @@ class ContextView : public QWidget {
|
|||||||
Song song_prev_;
|
Song song_prev_;
|
||||||
QImage image_original_;
|
QImage image_original_;
|
||||||
bool lyrics_tried_;
|
bool lyrics_tried_;
|
||||||
int lyrics_id_;
|
qint64 lyrics_id_;
|
||||||
QString lyrics_;
|
QString lyrics_;
|
||||||
QString title_fmt_;
|
QString title_fmt_;
|
||||||
QString summary_fmt_;
|
QString summary_fmt_;
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ AlbumCoverFetcher::~AlbumCoverFetcher() {
|
|||||||
quint64 AlbumCoverFetcher::FetchAlbumCover(const QString &artist, const QString &album, const QString &title, const bool batch) {
|
quint64 AlbumCoverFetcher::FetchAlbumCover(const QString &artist, const QString &album, const QString &title, const bool batch) {
|
||||||
|
|
||||||
CoverSearchRequest request;
|
CoverSearchRequest request;
|
||||||
request.id = next_id_++;
|
request.id = ++next_id_;
|
||||||
request.artist = artist;
|
request.artist = artist;
|
||||||
request.album = album;
|
request.album = album;
|
||||||
request.album = request.album.remove(Song::kAlbumRemoveDisc);
|
request.album = request.album.remove(Song::kAlbumRemoveDisc);
|
||||||
@@ -81,7 +81,7 @@ quint64 AlbumCoverFetcher::FetchAlbumCover(const QString &artist, const QString
|
|||||||
quint64 AlbumCoverFetcher::SearchForCovers(const QString &artist, const QString &album, const QString &title) {
|
quint64 AlbumCoverFetcher::SearchForCovers(const QString &artist, const QString &album, const QString &title) {
|
||||||
|
|
||||||
CoverSearchRequest request;
|
CoverSearchRequest request;
|
||||||
request.id = next_id_++;
|
request.id = ++next_id_;
|
||||||
request.artist = artist;
|
request.artist = artist;
|
||||||
request.album = album;
|
request.album = album;
|
||||||
request.album = request.album.remove(Song::kAlbumRemoveDisc);
|
request.album = request.album.remove(Song::kAlbumRemoveDisc);
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ LyricsFetcher::LyricsFetcher(LyricsProviders *lyrics_providers, QObject *parent)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int LyricsFetcher::Search(const QString &artist, const QString &album, const QString &title) {
|
quint64 LyricsFetcher::Search(const QString &artist, const QString &album, const QString &title) {
|
||||||
|
|
||||||
LyricsSearchRequest request;
|
LyricsSearchRequest request;
|
||||||
request.artist = artist;
|
request.artist = artist;
|
||||||
@@ -53,7 +53,7 @@ int LyricsFetcher::Search(const QString &artist, const QString &album, const QSt
|
|||||||
request.album.remove(Song::kAlbumRemoveMisc);
|
request.album.remove(Song::kAlbumRemoveMisc);
|
||||||
request.title = title;
|
request.title = title;
|
||||||
request.title.remove(Song::kTitleRemoveMisc);
|
request.title.remove(Song::kTitleRemoveMisc);
|
||||||
request.id = next_id_++;
|
request.id = ++next_id_;
|
||||||
AddRequest(request);
|
AddRequest(request);
|
||||||
|
|
||||||
return request.id;
|
return request.id;
|
||||||
@@ -105,7 +105,7 @@ void LyricsFetcher::StartRequests() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LyricsFetcher::SingleSearchFinished(const int request_id, const LyricsSearchResults &results) {
|
void LyricsFetcher::SingleSearchFinished(const quint64 request_id, const LyricsSearchResults &results) {
|
||||||
|
|
||||||
if (!active_requests_.contains(request_id)) return;
|
if (!active_requests_.contains(request_id)) return;
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ void LyricsFetcher::SingleSearchFinished(const int request_id, const LyricsSearc
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LyricsFetcher::SingleLyricsFetched(const int request_id, const QString &provider, const QString &lyrics) {
|
void LyricsFetcher::SingleLyricsFetched(const quint64 request_id, const QString &provider, const QString &lyrics) {
|
||||||
|
|
||||||
if (!active_requests_.contains(request_id)) return;
|
if (!active_requests_.contains(request_id)) return;
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class LyricsFetcherSearch;
|
|||||||
|
|
||||||
struct LyricsSearchRequest {
|
struct LyricsSearchRequest {
|
||||||
explicit LyricsSearchRequest() : id(-1) {}
|
explicit LyricsSearchRequest() : id(-1) {}
|
||||||
int id;
|
quint64 id;
|
||||||
QString artist;
|
QString artist;
|
||||||
QString album;
|
QString album;
|
||||||
QString title;
|
QString title;
|
||||||
@@ -65,29 +65,29 @@ class LyricsFetcher : public QObject {
|
|||||||
explicit LyricsFetcher(LyricsProviders *lyrics_providers, QObject *parent = nullptr);
|
explicit LyricsFetcher(LyricsProviders *lyrics_providers, QObject *parent = nullptr);
|
||||||
~LyricsFetcher() override {}
|
~LyricsFetcher() override {}
|
||||||
|
|
||||||
int Search(const QString &artist, const QString &album, const QString &title);
|
quint64 Search(const QString &artist, const QString &album, const QString &title);
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void AddRequest(const LyricsSearchRequest &req);
|
void AddRequest(const LyricsSearchRequest &req);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void LyricsFetched(int request_id, QString provider, QString lyrics);
|
void LyricsFetched(quint64 request_id, QString provider, QString lyrics);
|
||||||
void SearchFinished(int request_id, LyricsSearchResults results);
|
void SearchFinished(quint64 request_id, LyricsSearchResults results);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void SingleSearchFinished(const int request_id, const LyricsSearchResults &results);
|
void SingleSearchFinished(const quint64 request_id, const LyricsSearchResults &results);
|
||||||
void SingleLyricsFetched(const int request_id, const QString &provider, const QString &lyrics);
|
void SingleLyricsFetched(const quint64 request_id, const QString &provider, const QString &lyrics);
|
||||||
void StartRequests();
|
void StartRequests();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int kMaxConcurrentRequests;
|
static const int kMaxConcurrentRequests;
|
||||||
|
|
||||||
LyricsProviders *lyrics_providers_;
|
LyricsProviders *lyrics_providers_;
|
||||||
int next_id_;
|
quint64 next_id_;
|
||||||
|
|
||||||
QQueue<LyricsSearchRequest> queued_requests_;
|
QQueue<LyricsSearchRequest> queued_requests_;
|
||||||
QHash<int, LyricsFetcherSearch*> active_requests_;
|
QHash<quint64, LyricsFetcherSearch*> active_requests_;
|
||||||
|
|
||||||
QTimer *request_starter_;
|
QTimer *request_starter_;
|
||||||
|
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ class LyricsFetcherSearch : public QObject {
|
|||||||
void Cancel();
|
void Cancel();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void SearchFinished(int, LyricsSearchResults results);
|
void SearchFinished(quint64, LyricsSearchResults results);
|
||||||
void LyricsFetched(int, QString provider, QString lyrics);
|
void LyricsFetched(quint64, QString provider, QString lyrics);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void ProviderSearchFinished(const int id, const LyricsSearchResults &results);
|
void ProviderSearchFinished(const int id, const LyricsSearchResults &results);
|
||||||
|
|||||||
Reference in New Issue
Block a user