Add const and std::as_const
This commit is contained in:
@@ -52,7 +52,7 @@ AlbumCoverFetcher::AlbumCoverFetcher(SharedPtr<CoverProviders> cover_providers,
|
||||
|
||||
AlbumCoverFetcher::~AlbumCoverFetcher() {
|
||||
|
||||
QList<AlbumCoverFetcherSearch*> searches = active_requests_.values();
|
||||
const QList<AlbumCoverFetcherSearch*> searches = active_requests_.values();
|
||||
for (AlbumCoverFetcherSearch *search : searches) {
|
||||
search->disconnect();
|
||||
search->deleteLater();
|
||||
@@ -105,7 +105,7 @@ void AlbumCoverFetcher::Clear() {
|
||||
|
||||
queued_requests_.clear();
|
||||
|
||||
QList<AlbumCoverFetcherSearch*> searches = active_requests_.values();
|
||||
const QList<AlbumCoverFetcherSearch*> searches = active_requests_.values();
|
||||
for (AlbumCoverFetcherSearch *search : searches) {
|
||||
search->Cancel();
|
||||
search->deleteLater();
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <QWidget>
|
||||
#include <QStringList>
|
||||
#include <QUrl>
|
||||
@@ -57,7 +59,7 @@ QMimeData *AlbumCoverManagerList::mimeData(const QList<QListWidgetItem*> items)
|
||||
// Get URLs from the songs
|
||||
QList<QUrl> urls;
|
||||
urls.reserve(songs.count());
|
||||
for (const Song &song : songs) {
|
||||
for (const Song &song : std::as_const(songs)) {
|
||||
urls << song.url();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <QFile>
|
||||
#include <QSize>
|
||||
#include <QString>
|
||||
@@ -64,7 +66,7 @@ void CoverExportRunnable::ProcessAndExportCover() {
|
||||
QImage image;
|
||||
QString extension;
|
||||
|
||||
for (const AlbumCoverLoaderOptions::Type cover_type : cover_types_) {
|
||||
for (const AlbumCoverLoaderOptions::Type cover_type : std::as_const(cover_types_)) {
|
||||
switch (cover_type) {
|
||||
case AlbumCoverLoaderOptions::Type::Unset:
|
||||
if (song_.art_unset()) {
|
||||
@@ -156,7 +158,7 @@ void CoverExportRunnable::ExportCover() {
|
||||
QString cover_path;
|
||||
bool embedded_cover = false;
|
||||
|
||||
for (const AlbumCoverLoaderOptions::Type cover_type : cover_types_) {
|
||||
for (const AlbumCoverLoaderOptions::Type cover_type : std::as_const(cover_types_)) {
|
||||
switch (cover_type) {
|
||||
case AlbumCoverLoaderOptions::Type::Unset:
|
||||
if (song_.art_unset()) {
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <QObject>
|
||||
#include <QMutex>
|
||||
#include <QList>
|
||||
@@ -52,14 +54,14 @@ void CoverProviders::ReloadSettings() {
|
||||
|
||||
QMap<int, QString> all_providers;
|
||||
QList<CoverProvider*> old_providers = cover_providers_.keys();
|
||||
for (CoverProvider *provider : old_providers) {
|
||||
for (CoverProvider *provider : std::as_const(old_providers)) {
|
||||
if (!provider->is_enabled()) continue;
|
||||
all_providers.insert(provider->order(), provider->name());
|
||||
}
|
||||
|
||||
Settings s;
|
||||
s.beginGroup(CoversSettingsPage::kSettingsGroup);
|
||||
QStringList providers_enabled = s.value(CoversSettingsPage::kProviders, QStringList() << all_providers.values()).toStringList();
|
||||
const QStringList providers_enabled = s.value(CoversSettingsPage::kProviders, QStringList() << all_providers.values()).toStringList();
|
||||
s.endGroup();
|
||||
|
||||
int i = 0;
|
||||
@@ -74,7 +76,7 @@ void CoverProviders::ReloadSettings() {
|
||||
}
|
||||
|
||||
old_providers = cover_providers_.keys();
|
||||
for (CoverProvider *provider : old_providers) {
|
||||
for (CoverProvider *provider : std::as_const(old_providers)) {
|
||||
if (!new_providers.contains(provider)) {
|
||||
provider->set_enabled(false);
|
||||
provider->set_order(++i);
|
||||
@@ -85,7 +87,7 @@ void CoverProviders::ReloadSettings() {
|
||||
|
||||
CoverProvider *CoverProviders::ProviderByName(const QString &name) const {
|
||||
|
||||
QList<CoverProvider*> cover_providers = cover_providers_.keys();
|
||||
const QList<CoverProvider*> cover_providers = cover_providers_.keys();
|
||||
for (CoverProvider *provider : cover_providers) {
|
||||
if (provider->name() == name) return provider;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QString>
|
||||
|
||||
@@ -39,11 +41,11 @@ CoverSearchStatistics &CoverSearchStatistics::operator+=(const CoverSearchStatis
|
||||
bytes_transferred_ += other.bytes_transferred_;
|
||||
|
||||
QStringList keys = other.chosen_images_by_provider_.keys();
|
||||
for (const QString &key : keys) {
|
||||
for (const QString &key : std::as_const(keys)) {
|
||||
chosen_images_by_provider_[key] += other.chosen_images_by_provider_[key];
|
||||
}
|
||||
keys = other.total_images_by_provider_.keys();
|
||||
for (const QString &key : keys) {
|
||||
for (const QString &key : std::as_const(keys)) {
|
||||
total_images_by_provider_[key] += other.total_images_by_provider_[key];
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QWidget>
|
||||
@@ -69,7 +70,7 @@ void CoverSearchStatisticsDialog::Show(const CoverSearchStatistics &statistics)
|
||||
.arg(statistics.chosen_images_ + statistics.missing_images_)
|
||||
.arg(statistics.missing_images_));
|
||||
|
||||
for (const QString &provider : providers) {
|
||||
for (const QString &provider : std::as_const(providers)) {
|
||||
AddLine(tr("Covers from %1").arg(provider), QString::number(statistics.chosen_images_by_provider_[provider]));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user