LyricsFetcher: Change request ID to quint64
This commit is contained in:
parent
8b8e427a2b
commit
67a6d6c1e3
|
@ -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) {
|
||||
lyrics_fetcher_->Clear();
|
||||
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_id_ = -1;
|
||||
if (action_show_lyrics_->isChecked()) {
|
||||
|
|
|
@ -93,7 +93,7 @@ class ContextView : public QWidget {
|
|||
void ActionSearchLyrics();
|
||||
void UpdateNoSong();
|
||||
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:
|
||||
void ReloadSettings();
|
||||
|
@ -171,7 +171,7 @@ class ContextView : public QWidget {
|
|||
Song song_prev_;
|
||||
QImage image_original_;
|
||||
bool lyrics_tried_;
|
||||
int lyrics_id_;
|
||||
qint64 lyrics_id_;
|
||||
QString lyrics_;
|
||||
QString title_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) {
|
||||
|
||||
CoverSearchRequest request;
|
||||
request.id = next_id_++;
|
||||
request.id = ++next_id_;
|
||||
request.artist = artist;
|
||||
request.album = album;
|
||||
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) {
|
||||
|
||||
CoverSearchRequest request;
|
||||
request.id = next_id_++;
|
||||
request.id = ++next_id_;
|
||||
request.artist = artist;
|
||||
request.album = album;
|
||||
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;
|
||||
request.artist = artist;
|
||||
|
@ -53,7 +53,7 @@ int LyricsFetcher::Search(const QString &artist, const QString &album, const QSt
|
|||
request.album.remove(Song::kAlbumRemoveMisc);
|
||||
request.title = title;
|
||||
request.title.remove(Song::kTitleRemoveMisc);
|
||||
request.id = next_id_++;
|
||||
request.id = ++next_id_;
|
||||
AddRequest(request);
|
||||
|
||||
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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ class LyricsFetcherSearch;
|
|||
|
||||
struct LyricsSearchRequest {
|
||||
explicit LyricsSearchRequest() : id(-1) {}
|
||||
int id;
|
||||
quint64 id;
|
||||
QString artist;
|
||||
QString album;
|
||||
QString title;
|
||||
|
@ -65,29 +65,29 @@ class LyricsFetcher : public QObject {
|
|||
explicit LyricsFetcher(LyricsProviders *lyrics_providers, QObject *parent = nullptr);
|
||||
~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();
|
||||
|
||||
private:
|
||||
void AddRequest(const LyricsSearchRequest &req);
|
||||
|
||||
signals:
|
||||
void LyricsFetched(int request_id, QString provider, QString lyrics);
|
||||
void SearchFinished(int request_id, LyricsSearchResults results);
|
||||
void LyricsFetched(quint64 request_id, QString provider, QString lyrics);
|
||||
void SearchFinished(quint64 request_id, LyricsSearchResults results);
|
||||
|
||||
private slots:
|
||||
void SingleSearchFinished(const int request_id, const LyricsSearchResults &results);
|
||||
void SingleLyricsFetched(const int request_id, const QString &provider, const QString &lyrics);
|
||||
void SingleSearchFinished(const quint64 request_id, const LyricsSearchResults &results);
|
||||
void SingleLyricsFetched(const quint64 request_id, const QString &provider, const QString &lyrics);
|
||||
void StartRequests();
|
||||
|
||||
private:
|
||||
static const int kMaxConcurrentRequests;
|
||||
|
||||
LyricsProviders *lyrics_providers_;
|
||||
int next_id_;
|
||||
quint64 next_id_;
|
||||
|
||||
QQueue<LyricsSearchRequest> queued_requests_;
|
||||
QHash<int, LyricsFetcherSearch*> active_requests_;
|
||||
QHash<quint64, LyricsFetcherSearch*> active_requests_;
|
||||
|
||||
QTimer *request_starter_;
|
||||
|
||||
|
|
|
@ -42,8 +42,8 @@ class LyricsFetcherSearch : public QObject {
|
|||
void Cancel();
|
||||
|
||||
signals:
|
||||
void SearchFinished(int, LyricsSearchResults results);
|
||||
void LyricsFetched(int, QString provider, QString lyrics);
|
||||
void SearchFinished(quint64, LyricsSearchResults results);
|
||||
void LyricsFetched(quint64, QString provider, QString lyrics);
|
||||
|
||||
private slots:
|
||||
void ProviderSearchFinished(const int id, const LyricsSearchResults &results);
|
||||
|
|
Loading…
Reference in New Issue