Use anonymous namespace instead of static for constants

This commit is contained in:
Jonas Kvinge 2024-07-28 01:24:56 +02:00
parent 6c1ec51fab
commit 70fdd5b0b3
10 changed files with 25 additions and 35 deletions

View File

@ -29,7 +29,9 @@
#include "albumcoverexporter.h" #include "albumcoverexporter.h"
#include "coverexportrunnable.h" #include "coverexportrunnable.h"
const int AlbumCoverExporter::kMaxConcurrentRequests = 3; namespace {
constexpr int kMaxConcurrentRequests = 3;
}
AlbumCoverExporter::AlbumCoverExporter(QObject *parent) AlbumCoverExporter::AlbumCoverExporter(QObject *parent)
: QObject(parent), : QObject(parent),

View File

@ -40,8 +40,6 @@ class AlbumCoverExporter : public QObject {
public: public:
explicit AlbumCoverExporter(QObject *parent = nullptr); explicit AlbumCoverExporter(QObject *parent = nullptr);
static const int kMaxConcurrentRequests;
void SetDialogResult(const AlbumCoverExport::DialogResult &dialog_result); void SetDialogResult(const AlbumCoverExport::DialogResult &dialog_result);
void SetCoverTypes(const AlbumCoverLoaderOptions::Types &cover_types); void SetCoverTypes(const AlbumCoverLoaderOptions::Types &cover_types);
void AddExportRequest(const Song &song); void AddExportRequest(const Song &song);

View File

@ -36,7 +36,9 @@
using namespace std::chrono_literals; using namespace std::chrono_literals;
const int AlbumCoverFetcher::kMaxConcurrentRequests = 5; namespace {
constexpr int kMaxConcurrentRequests = 5;
}
AlbumCoverFetcher::AlbumCoverFetcher(SharedPtr<CoverProviders> cover_providers, SharedPtr<NetworkAccessManager> network, QObject *parent) AlbumCoverFetcher::AlbumCoverFetcher(SharedPtr<CoverProviders> cover_providers, SharedPtr<NetworkAccessManager> network, QObject *parent)
: QObject(parent), : QObject(parent),

View File

@ -112,8 +112,6 @@ class AlbumCoverFetcher : public QObject {
explicit AlbumCoverFetcher(SharedPtr<CoverProviders> cover_providers, SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr); explicit AlbumCoverFetcher(SharedPtr<CoverProviders> cover_providers, SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
~AlbumCoverFetcher() override; ~AlbumCoverFetcher() override;
static const int kMaxConcurrentRequests;
quint64 SearchForCovers(const QString &artist, const QString &album, const QString &title = QString()); quint64 SearchForCovers(const QString &artist, const QString &album, const QString &title = QString());
quint64 FetchAlbumCover(const QString &artist, const QString &album, const QString &title, const bool batch); quint64 FetchAlbumCover(const QString &artist, const QString &album, const QString &title, const bool batch);

View File

@ -47,10 +47,12 @@
#include "coverproviders.h" #include "coverproviders.h"
#include "albumcoverimageresult.h" #include "albumcoverimageresult.h"
const int AlbumCoverFetcherSearch::kSearchTimeoutMs = 20000; namespace {
const int AlbumCoverFetcherSearch::kImageLoadTimeoutMs = 6000; constexpr int kSearchTimeoutMs = 20000;
const int AlbumCoverFetcherSearch::kTargetSize = 500; constexpr int kImageLoadTimeoutMs = 6000;
const float AlbumCoverFetcherSearch::kGoodScore = 4.0; constexpr int kTargetSize = 500;
constexpr float kGoodScore = 4.0;
} // namespace
AlbumCoverFetcherSearch::AlbumCoverFetcherSearch(const CoverSearchRequest &request, SharedPtr<NetworkAccessManager> network, QObject *parent) AlbumCoverFetcherSearch::AlbumCoverFetcherSearch(const CoverSearchRequest &request, SharedPtr<NetworkAccessManager> network, QObject *parent)
: QObject(parent), : QObject(parent),

View File

@ -90,11 +90,6 @@ class AlbumCoverFetcherSearch : public QObject {
static bool CoverProviderSearchResultCompareScore(const CoverProviderSearchResult &a, const CoverProviderSearchResult &b); static bool CoverProviderSearchResultCompareScore(const CoverProviderSearchResult &a, const CoverProviderSearchResult &b);
private: private:
static const int kSearchTimeoutMs;
static const int kImageLoadTimeoutMs;
static const int kTargetSize;
static const float kGoodScore;
CoverSearchStatistics statistics_; CoverSearchStatistics statistics_;
// Search request encapsulated by this AlbumCoverFetcherSearch. // Search request encapsulated by this AlbumCoverFetcherSearch.

View File

@ -95,8 +95,10 @@
#include "ui_albumcovermanager.h" #include "ui_albumcovermanager.h"
const char *AlbumCoverManager::kSettingsGroup = "CoverManager"; namespace {
constexpr int AlbumCoverManager::kThumbnailSize = 120; constexpr char kSettingsGroup[] = "CoverManager";
constexpr int kThumbnailSize = 120;
}
AlbumCoverManager::AlbumCoverManager(Application *app, SharedPtr<CollectionBackend> collection_backend, QMainWindow *mainwindow, QWidget *parent) AlbumCoverManager::AlbumCoverManager(Application *app, SharedPtr<CollectionBackend> collection_backend, QMainWindow *mainwindow, QWidget *parent)
: QMainWindow(parent), : QMainWindow(parent),

View File

@ -185,9 +185,6 @@ class AlbumCoverManager : public QMainWindow {
void SaveEmbeddedCoverFinished(TagReaderReply *reply, AlbumItem *album_item, const QUrl &url, const bool art_embedded); void SaveEmbeddedCoverFinished(TagReaderReply *reply, AlbumItem *album_item, const QUrl &url, const bool art_embedded);
private: private:
static const char *kSettingsGroup;
static const int kThumbnailSize;
Ui_CoverManager *ui_; Ui_CoverManager *ui_;
QMainWindow *mainwindow_; QMainWindow *mainwindow_;
Application *app_; Application *app_;

View File

@ -62,13 +62,15 @@
#include "albumcoverimageresult.h" #include "albumcoverimageresult.h"
#include "ui_albumcoversearcher.h" #include "ui_albumcoversearcher.h"
const int SizeOverlayDelegate::kMargin = 4; namespace {
const int SizeOverlayDelegate::kPaddingX = 3; constexpr int kMargin = 4;
const int SizeOverlayDelegate::kPaddingY = 1; constexpr int kPaddingX = 3;
const qreal SizeOverlayDelegate::kBorder = 5.0; constexpr int kPaddingY = 1;
const qreal SizeOverlayDelegate::kFontPointSize = 7.5; constexpr qreal kBorder = 5.0;
const int SizeOverlayDelegate::kBorderAlpha = 200; constexpr qreal kFontPointSize = 7.5;
const int SizeOverlayDelegate::kBackgroundAlpha = 175; constexpr int kBorderAlpha = 200;
constexpr int kBackgroundAlpha = 175;
} // namespace
SizeOverlayDelegate::SizeOverlayDelegate(QObject *parent) SizeOverlayDelegate::SizeOverlayDelegate(QObject *parent)
: QStyledItemDelegate(parent) {} : QStyledItemDelegate(parent) {}

View File

@ -55,14 +55,6 @@ class SizeOverlayDelegate : public QStyledItemDelegate {
Q_OBJECT Q_OBJECT
public: public:
static const int kMargin;
static const int kPaddingX;
static const int kPaddingY;
static const qreal kBorder;
static const qreal kFontPointSize;
static const int kBorderAlpha;
static const int kBackgroundAlpha;
explicit SizeOverlayDelegate(QObject *parent = nullptr); explicit SizeOverlayDelegate(QObject *parent = nullptr);
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const override; void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &idx) const override;