diff options
author | Uwe Klotz <uklotz@mixxx.org> | 2019-11-04 09:58:10 +0100 |
---|---|---|
committer | Uwe Klotz <uklotz@mixxx.org> | 2019-11-21 11:27:42 +0100 |
commit | d55f535662e48c40cce379623ed08c8f336d7d3e (patch) | |
tree | 5f2a9ac78191d27bba5ab112857f3e6c7ae63708 /src/library | |
parent | ad910a10e43b8354e6a9ca01f5a871e94e8ca701 (diff) |
Fix naming conflict(?) and minor issues in DlgTagFetcher
AppVeyor build on Windows with VS 2017 failed.
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/dlgtagfetcher.cpp | 31 | ||||
-rw-r--r-- | src/library/dlgtagfetcher.h | 37 |
2 files changed, 32 insertions, 36 deletions
diff --git a/src/library/dlgtagfetcher.cpp b/src/library/dlgtagfetcher.cpp index 6909ef80eb..ad85ddc736 100644 --- a/src/library/dlgtagfetcher.cpp +++ b/src/library/dlgtagfetcher.cpp @@ -5,14 +5,11 @@ DlgTagFetcher::DlgTagFetcher(QWidget *parent) : QDialog(parent), - m_TagFetcher(parent), - m_networkError(NOERROR) { + m_tagFetcher(parent), + m_networkResult(NetworkResult::Ok) { init(); } -DlgTagFetcher::~DlgTagFetcher() { -} - void DlgTagFetcher::init() { setupUi(this); @@ -27,12 +24,12 @@ void DlgTagFetcher::init() { connect(results, &QTreeWidget::currentItemChanged, this, &DlgTagFetcher::resultSelected); - connect(&m_TagFetcher, &TagFetcher::resultAvailable, + connect(&m_tagFetcher, &TagFetcher::resultAvailable, this, &DlgTagFetcher::fetchTagFinished); - connect(&m_TagFetcher, &TagFetcher::fetchProgress, + connect(&m_tagFetcher, &TagFetcher::fetchProgress, this, &DlgTagFetcher::fetchTagProgress); - connect(&m_TagFetcher, &TagFetcher::networkError, - this, &DlgTagFetcher::slotNetworkError); + connect(&m_tagFetcher, &TagFetcher::networkError, + this, &DlgTagFetcher::slotNetworkResult); // Resize columns, this can't be set in the ui file results->setColumnWidth(0, 50); // Track column @@ -42,7 +39,7 @@ void DlgTagFetcher::init() { results->setColumnWidth(4, 160); // Album column } -void DlgTagFetcher::loadTrack(const TrackPointer track) { +void DlgTagFetcher::loadTrack(const TrackPointer& track) { if (track == NULL) { return; } @@ -52,8 +49,8 @@ void DlgTagFetcher::loadTrack(const TrackPointer track) { m_track = track; m_data = Data(); - m_networkError = NOERROR; - m_TagFetcher.startFetch(m_track); + m_networkResult = NetworkResult::Ok; + m_tagFetcher.startFetch(m_track); connect(track.get(), &Track::changed, this, &DlgTagFetcher::updateTrackMetadata); @@ -90,7 +87,7 @@ void DlgTagFetcher::apply() { } void DlgTagFetcher::quit() { - m_TagFetcher.cancel(); + m_tagFetcher.cancel(); accept(); } @@ -112,8 +109,8 @@ void DlgTagFetcher::fetchTagFinished(const TrackPointer track, updateStack(); } -void DlgTagFetcher::slotNetworkError(int httpError, QString app, QString message, int code) { - m_networkError = httpError == 0 ? FTWERROR : HTTPERROR; +void DlgTagFetcher::slotNetworkResult(int httpError, QString app, QString message, int code) { + m_networkResult = httpError == 0 ? NetworkResult::UnknownError : NetworkResult::HttpError; m_data.m_pending = false; QString strError = tr("HTTP Status: %1"); QString strCode = tr("Code: %1"); @@ -129,10 +126,10 @@ void DlgTagFetcher::updateStack() { if (m_data.m_pending) { stack->setCurrentWidget(loading_page); return; - } else if (m_networkError == HTTPERROR) { + } else if (m_networkResult == NetworkResult::HttpError) { stack->setCurrentWidget(networkError_page); return; - } else if (m_networkError == FTWERROR) { + } else if (m_networkResult == NetworkResult::UnknownError) { stack->setCurrentWidget(generalnetworkError_page); return; } else if (m_data.m_results.isEmpty()) { diff --git a/src/library/dlgtagfetcher.h b/src/library/dlgtagfetcher.h index 714e7b6507..537a1bc4c6 100644 --- a/src/library/dlgtagfetcher.h +++ b/src/library/dlgtagfetcher.h @@ -1,7 +1,7 @@ -#ifndef DLGTAGFETCHER_H -#define DLGTAGFETCHER_H +#pragma once #include <QDialog> +#include <QList> #include <QTreeWidget> #include "library/ui_dlgtagfetcher.h" @@ -12,19 +12,13 @@ class DlgTagFetcher : public QDialog, public Ui::DlgTagFetcher { Q_OBJECT public: - DlgTagFetcher(QWidget *parent); - virtual ~DlgTagFetcher(); + explicit DlgTagFetcher(QWidget *parent); + ~DlgTagFetcher() override = default; void init(); - enum networkError { - NOERROR, - HTTPERROR, - FTWERROR - }; - public slots: - void loadTrack(const TrackPointer track); + void loadTrack(const TrackPointer& track); void updateTrackMetadata(Track* pTIO); signals: @@ -35,7 +29,7 @@ class DlgTagFetcher : public QDialog, public Ui::DlgTagFetcher { void fetchTagFinished(const TrackPointer,const QList<TrackPointer>& tracks); void resultSelected(); void fetchTagProgress(QString); - void slotNetworkError(int httpStatus, QString app, QString message, int code); + void slotNetworkResult(int httpStatus, QString app, QString message, int code); void apply(); void quit(); @@ -44,6 +38,11 @@ class DlgTagFetcher : public QDialog, public Ui::DlgTagFetcher { void addDivider(const QString& text, QTreeWidget* parent) const; void addTrack(const TrackPointer track, int resultIndex, QTreeWidget* parent) const; + + TagFetcher m_tagFetcher; + + TrackPointer m_track; + struct Data { Data() : m_pending(true), m_selectedResult(-1) {} @@ -51,12 +50,12 @@ class DlgTagFetcher : public QDialog, public Ui::DlgTagFetcher { int m_selectedResult; QList<TrackPointer> m_results; }; - - TrackPointer m_track; Data m_data; - QString m_progress; - TagFetcher m_TagFetcher; - networkError m_networkError; -}; -#endif // DLGTAGFETCHER_H + enum class NetworkResult { + Ok, + HttpError, + UnknownError, + }; + NetworkResult m_networkResult; +}; |