Add const and std::as_const

This commit is contained in:
Jonas Kvinge 2024-04-23 17:15:42 +02:00
parent 24c8d06d41
commit 426de61525
67 changed files with 273 additions and 192 deletions

View File

@ -23,6 +23,7 @@
#include <cstdio>
#include <cstddef>
#include <utility>
#include <QtGlobal>
#include <QObject>
@ -250,7 +251,7 @@ void WorkerPool<HandlerType>::DoStart() {
search_path << QDir::cleanPath(QCoreApplication::applicationDirPath() + QStringLiteral("/../PlugIns"));
#endif
for (const QString &path_prefix : search_path) {
for (const QString &path_prefix : std::as_const(search_path)) {
const QString executable_path = path_prefix + QLatin1Char('/') + executable_name_;
if (QFile::exists(executable_path)) {
executable_path_ = executable_path;

View File

@ -22,6 +22,7 @@
#include "config.h"
#include <optional>
#include <utility>
#include <QtGlobal>
#include <QObject>
@ -155,7 +156,7 @@ void CollectionBackend::ResetPlayStatisticsAsync(const QList<int> &id_list, cons
void CollectionBackend::LoadDirectories() {
CollectionDirectoryList dirs = GetAllDirectories();
const CollectionDirectoryList dirs = GetAllDirectories();
QMutexLocker l(db_->Mutex());
QSqlDatabase db(db_->Connect());
@ -740,7 +741,7 @@ void CollectionBackend::UpdateSongsBySongID(const SongMap &new_songs) {
}
// Add or update songs.
QList new_songs_list = new_songs.values();
const QList new_songs_list = new_songs.values();
for (const Song &new_song : new_songs_list) {
if (old_songs.contains(new_song.song_id())) {
@ -811,7 +812,7 @@ void CollectionBackend::UpdateSongsBySongID(const SongMap &new_songs) {
}
// Delete songs
QList old_songs_list = old_songs.values();
const QList old_songs_list = old_songs.values();
for (const Song &old_song : old_songs_list) {
if (!new_songs.contains(old_song.song_id())) {
{
@ -2097,7 +2098,7 @@ SongList CollectionBackend::GetSongsBy(const QString &artist, const QString &alb
void CollectionBackend::UpdateLastPlayed(const QString &artist, const QString &album, const QString &title, const qint64 lastplayed) {
SongList songs = GetSongsBy(artist, album, title);
const SongList songs = GetSongsBy(artist, album, title);
if (songs.isEmpty()) {
qLog(Debug) << "Could not find a matching song in the database for" << artist << album << title;
return;
@ -2126,7 +2127,7 @@ void CollectionBackend::UpdateLastPlayed(const QString &artist, const QString &a
void CollectionBackend::UpdatePlayCount(const QString &artist, const QString &title, const int playcount, const bool save_tags) {
SongList songs = GetSongsBy(artist, QString(), title);
const SongList songs = GetSongsBy(artist, QString(), title);
if (songs.isEmpty()) {
qLog(Debug) << "Could not find a matching song in the database for" << artist << title;
return;

View File

@ -21,6 +21,7 @@
#include "config.h"
#include <utility>
#include <memory>
#include <QApplication>
@ -161,7 +162,7 @@ void CollectionFilterWidget::Init(CollectionModel *model) {
QObject::disconnect(model_, nullptr, this, nullptr);
QObject::disconnect(model_, nullptr, group_by_dialog_, nullptr);
QObject::disconnect(group_by_dialog_, nullptr, model_, nullptr);
QList<QAction*> filter_ages = filter_ages_.keys();
const QList<QAction*> filter_ages = filter_ages_.keys();
for (QAction *action : filter_ages) {
QObject::disconnect(action, &QAction::triggered, model_, nullptr);
}
@ -174,7 +175,7 @@ void CollectionFilterWidget::Init(CollectionModel *model) {
QObject::connect(model_, &CollectionModel::GroupingChanged, this, &CollectionFilterWidget::GroupingChanged);
QObject::connect(group_by_dialog_, &GroupByDialog::Accepted, model_, &CollectionModel::SetGroupBy);
QList<QAction*> filter_ages = filter_ages_.keys();
const QList<QAction*> filter_ages = filter_ages_.keys();
for (QAction *action : filter_ages) {
int age = filter_ages_[action];
QObject::connect(action, &QAction::triggered, this, [this, age]() { model_->SetFilterAge(age); } );
@ -447,7 +448,8 @@ void CollectionFilterWidget::CheckCurrentGrouping(const CollectionModel::Groupin
UpdateGroupByActions();
}
for (QAction *action : group_by_group_->actions()) {
const QList<QAction*> actions = group_by_group_->actions();
for (QAction *action : actions) {
if (action->property("group_by").isNull()) continue;
if (g == action->property("group_by").value<CollectionModel::Grouping>()) {
@ -457,7 +459,6 @@ void CollectionFilterWidget::CheckCurrentGrouping(const CollectionModel::Groupin
}
// Check the advanced action
QList<QAction*> actions = group_by_group_->actions();
QAction *action = actions.last();
action->setChecked(true);

View File

@ -21,6 +21,7 @@
#include "config.h"
#include <utility>
#include <memory>
#include <QtGlobal>
@ -414,7 +415,7 @@ void CollectionView::contextMenuEvent(QContextMenuEvent *e) {
context_menu_index_ = qobject_cast<QSortFilterProxyModel*>(model())->mapToSource(context_menu_index_);
QModelIndexList selected_indexes = qobject_cast<QSortFilterProxyModel*>(model())->mapSelectionToSource(selectionModel()->selection()).indexes();
const QModelIndexList selected_indexes = qobject_cast<QSortFilterProxyModel*>(model())->mapSelectionToSource(selectionModel()->selection()).indexes();
int regular_elements = 0;
int regular_editable = 0;
@ -485,7 +486,8 @@ void CollectionView::SetShowInVarious(const bool on) {
// We put through "Various Artists" changes one album at a time,
// to make sure the old album node gets removed (due to all children removed), before the new one gets added
QMultiMap<QString, QString> albums;
for (const Song &song : GetSelectedSongs()) {
const SongList songs = GetSelectedSongs();
for (const Song &song : songs) {
if (albums.find(song.album(), song.artist()) == albums.end())
albums.insert(song.album(), song.artist());
}
@ -495,7 +497,7 @@ void CollectionView::SetShowInVarious(const bool on) {
if (on && albums.keys().count() == 1) {
const QStringList albums_list = albums.keys();
const QString album = albums_list.first();
SongList all_of_album = app_->collection_backend()->GetSongsByAlbum(album);
const SongList all_of_album = app_->collection_backend()->GetSongsByAlbum(album);
QSet<QString> other_artists;
for (const Song &s : all_of_album) {
if (!albums.contains(album, s.artist()) && !other_artists.contains(s.artist())) {
@ -512,9 +514,9 @@ void CollectionView::SetShowInVarious(const bool on) {
}
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QSet<QString> albums_set = QSet<QString>(albums.keyBegin(), albums.keyEnd());
const QSet<QString> albums_set = QSet<QString>(albums.keyBegin(), albums.keyEnd());
#else
QSet<QString> albums_set = QSet<QString>::fromList(albums.keys());
const QSet<QString> albums_set = QSet<QString>::fromList(albums.keys());
#endif
for (const QString &album : albums_set) {
app_->collection_backend()->ForceCompilation(album, albums.values(album), on);
@ -763,7 +765,7 @@ void CollectionView::FilterReturnPressed() {
void CollectionView::ShowInBrowser() const {
SongList songs = GetSelectedSongs();
const SongList songs = GetSelectedSongs();
QList<QUrl> urls;
urls.reserve(songs.count());
for (const Song &song : songs) {
@ -788,7 +790,7 @@ void CollectionView::Delete() {
if (!delete_files_) return;
SongList selected_songs = GetSelectedSongs();
const SongList selected_songs = GetSelectedSongs();
SongList songs;
QStringList files;

View File

@ -106,7 +106,7 @@ CollectionWatcher::CollectionWatcher(Song::Source source, QObject *parent)
periodic_scan_timer_->setInterval(86400 * kMsecPerSec);
periodic_scan_timer_->setSingleShot(false);
QStringList image_formats = ImageUtils::SupportedImageFormats();
const QStringList image_formats = ImageUtils::SupportedImageFormats();
for (const QString &format : image_formats) {
if (!sValidImages.contains(format)) {
sValidImages.append(format);
@ -155,7 +155,7 @@ void CollectionWatcher::ReloadSettings() {
s.beginGroup(CollectionSettingsPage::kSettingsGroup);
scan_on_startup_ = s.value("startup_scan", true).toBool();
monitor_ = s.value("monitor", true).toBool();
QStringList filters = s.value("cover_art_patterns", QStringList() << QStringLiteral("front") << QStringLiteral("cover")).toStringList();
const QStringList filters = s.value("cover_art_patterns", QStringList() << QStringLiteral("front") << QStringLiteral("cover")).toStringList();
if (source_ == Song::Source::Collection) {
song_tracking_ = s.value("song_tracking", false).toBool();
song_ebur128_loudness_analysis_ = s.value("song_ebur128_loudness_analysis", false).toBool();
@ -183,7 +183,7 @@ void CollectionWatcher::ReloadSettings() {
else if (monitor_ && !was_monitoring_before) {
// Add all directories to all QFileSystemWatchers again
for (const CollectionDirectory &dir : std::as_const(watched_dirs_)) {
CollectionSubdirectoryList subdirs = backend_->SubdirsInDirectory(dir.id);
const CollectionSubdirectoryList subdirs = backend_->SubdirsInDirectory(dir.id);
for (const CollectionSubdirectory &subdir : subdirs) {
AddWatch(dir, subdir.path);
}
@ -288,7 +288,7 @@ void CollectionWatcher::ScanTransaction::CommitNewOrUpdatedSongs() {
touched_subdirs.clear();
}
for (const CollectionSubdirectory &subdir : deleted_subdirs) {
for (const CollectionSubdirectory &subdir : std::as_const(deleted_subdirs)) {
if (watcher_->watched_dirs_.contains(dir_)) {
watcher_->RemoveWatch(watcher_->watched_dirs_[dir_], subdir);
}
@ -297,7 +297,7 @@ void CollectionWatcher::ScanTransaction::CommitNewOrUpdatedSongs() {
if (watcher_->monitor_) {
// Watch the new subdirectories
for (const CollectionSubdirectory &subdir : new_subdirs) {
for (const CollectionSubdirectory &subdir : std::as_const(new_subdirs)) {
if (watcher_->watched_dirs_.contains(dir_)) {
watcher_->AddWatch(watcher_->watched_dirs_[dir_], subdir.path);
}
@ -384,7 +384,7 @@ CollectionSubdirectoryList CollectionWatcher::ScanTransaction::GetImmediateSubdi
}
CollectionSubdirectoryList ret;
for (const CollectionSubdirectory &subdir : known_subdirs_) {
for (const CollectionSubdirectory &subdir : std::as_const(known_subdirs_)) {
if (subdir.path.left(subdir.path.lastIndexOf(QDir::separator())) == path && subdir.mtime != 0) {
ret << subdir;
}
@ -481,7 +481,7 @@ void CollectionWatcher::ScanSubdirectory(const QString &path, const CollectionSu
// If a directory is moved then only its parent gets a changed notification, so we need to look and see if any of our children don't exist anymore.
// If one has been removed, "rescan" it to get the deleted songs
CollectionSubdirectoryList previous_subdirs = t->GetImmediateSubdirs(path);
const CollectionSubdirectoryList previous_subdirs = t->GetImmediateSubdirs(path);
for (const CollectionSubdirectory &prev_subdir : previous_subdirs) {
if (!QFile::exists(prev_subdir.path) && prev_subdir.path != path) {
ScanSubdirectory(prev_subdir.path, prev_subdir, 0, t, true);
@ -658,7 +658,7 @@ void CollectionWatcher::ScanSubdirectory(const QString &path, const CollectionSu
// Make sure the songs aren't deleted, as they still exist elsewhere with a different file path.
bool matching_songs_has_cue = false;
for (const Song &matching_song : matching_songs) {
for (const Song &matching_song : std::as_const(matching_songs)) {
QString matching_filename = matching_song.url().toLocalFile();
if (!t->files_changed_path_.contains(matching_filename)) {
t->files_changed_path_ << matching_filename;
@ -691,7 +691,7 @@ void CollectionWatcher::ScanSubdirectory(const QString &path, const CollectionSu
}
else { // The song is on disk but not in the DB
SongList songs = ScanNewFile(file, path, fingerprint, new_cue, &cues_processed);
const SongList songs = ScanNewFile(file, path, fingerprint, new_cue, &cues_processed);
if (songs.isEmpty()) {
t->AddToProgress(1);
continue;
@ -713,7 +713,7 @@ void CollectionWatcher::ScanSubdirectory(const QString &path, const CollectionSu
}
// Look for deleted songs
for (const Song &song : songs_in_db) {
for (const Song &song : std::as_const(songs_in_db)) {
QString file = song.url().toLocalFile();
if (!song.unavailable() && !files_on_disk.contains(file) && !t->files_changed_path_.contains(file)) {
qLog(Debug) << "Song deleted from disk:" << file;
@ -739,7 +739,7 @@ void CollectionWatcher::ScanSubdirectory(const QString &path, const CollectionSu
}
// Recurse into the new subdirs that we found
for (const CollectionSubdirectory &my_new_subdir : my_new_subdirs) {
for (const CollectionSubdirectory &my_new_subdir : std::as_const(my_new_subdirs)) {
if (stop_requested_ || abort_requested_) return;
ScanSubdirectory(my_new_subdir.path, my_new_subdir, 0, t, true);
}
@ -991,7 +991,7 @@ void CollectionWatcher::AddWatch(const CollectionDirectory &dir, const QString &
void CollectionWatcher::RemoveWatch(const CollectionDirectory &dir, const CollectionSubdirectory &subdir) {
QStringList subdir_paths = subdir_mapping_.keys(dir);
const QStringList subdir_paths = subdir_mapping_.keys(dir);
for (const QString &subdir_path : subdir_paths) {
if (subdir_path != subdir.path) continue;
fs_watcher_->RemovePath(subdir_path);
@ -1008,7 +1008,7 @@ void CollectionWatcher::RemoveDirectory(const CollectionDirectory &dir) {
// Stop watching the directory's subdirectories
QStringList subdir_paths = subdir_mapping_.keys(dir);
for (const QString &subdir_path : subdir_paths) {
for (const QString &subdir_path : std::as_const(subdir_paths)) {
fs_watcher_->RemovePath(subdir_path);
subdir_mapping_.remove(subdir_path);
}
@ -1030,7 +1030,7 @@ bool CollectionWatcher::FindSongsByPath(const SongList &songs, const QString &pa
bool CollectionWatcher::FindSongsByFingerprint(const QString &file, const QString &fingerprint, SongList *out) {
SongList songs = backend_->GetSongsByFingerprint(fingerprint);
for (const Song &song : songs) {
for (const Song &song : std::as_const(songs)) {
QString filename = song.url().toLocalFile();
QFileInfo info(filename);
// Allow mulitiple songs in different directories with the same fingerprint.
@ -1078,19 +1078,21 @@ void CollectionWatcher::DirectoryChanged(const QString &subdir) {
void CollectionWatcher::RescanPathsNow() {
QList<int> dirs = rescan_queue_.keys();
const QList<int> dirs = rescan_queue_.keys();
for (const int dir : dirs) {
if (stop_requested_ || abort_requested_) break;
ScanTransaction transaction(this, dir, false, false, mark_songs_unavailable_);
const QStringList paths = rescan_queue_[dir];
QMap<QString, quint64> subdir_files_count;
for (const QString &path : rescan_queue_[dir]) {
for (const QString &path : paths) {
quint64 files_count = FilesCountForPath(&transaction, path);
subdir_files_count[path] = files_count;
transaction.AddToProgressMax(files_count);
}
for (const QString &path : rescan_queue_[dir]) {
for (const QString &path : paths) {
if (stop_requested_ || abort_requested_) break;
CollectionSubdirectory subdir;
subdir.directory_id = dir;
@ -1113,7 +1115,7 @@ QString CollectionWatcher::PickBestArt(const QStringList &art_automatic_list) {
QStringList filtered;
for (const QString &filter_text : best_art_filters_) {
for (const QString &filter_text : std::as_const(best_art_filters_)) {
// The images in the images list are represented by a full path, so we need to isolate just the filename
for (const QString &art_automatic : art_automatic_list) {
QFileInfo fileinfo(art_automatic);
@ -1135,7 +1137,7 @@ QString CollectionWatcher::PickBestArt(const QStringList &art_automatic_list) {
int biggest_size = 0;
QString biggest_path;
for (const QString &path : filtered) {
for (const QString &path : std::as_const(filtered)) {
if (stop_requested_ || abort_requested_) break;
QImage image(path);
@ -1233,7 +1235,7 @@ void CollectionWatcher::PerformScan(const bool incremental, const bool ignore_mt
quint64 files_count = FilesCountForSubdirs(&transaction, subdirs, subdir_files_count);
transaction.AddToProgressMax(files_count);
for (const CollectionSubdirectory &subdir : subdirs) {
for (const CollectionSubdirectory &subdir : std::as_const(subdirs)) {
if (stop_requested_ || abort_requested_) break;
ScanSubdirectory(subdir.path, subdir, subdir_files_count[subdir.path], &transaction);
}
@ -1312,7 +1314,7 @@ void CollectionWatcher::RescanSongs(const SongList &songs) {
const QString song_path = song.url().toLocalFile().section(QLatin1Char('/'), 0, -2);
if (scanned_paths.contains(song_path)) continue;
ScanTransaction transaction(this, song.directory_id(), false, true, mark_songs_unavailable_);
CollectionSubdirectoryList subdirs(transaction.GetAllSubdirs());
const CollectionSubdirectoryList subdirs = transaction.GetAllSubdirs();
for (const CollectionSubdirectory &subdir : subdirs) {
if (stop_requested_ || abort_requested_) break;
if (subdir.path != song_path) continue;

View File

@ -21,6 +21,8 @@
#include "config.h"
#include <utility>
#include <QDialog>
#include <QStandardItemModel>
#include <QItemSelectionModel>
@ -195,7 +197,8 @@ void SavedGroupingManager::Remove() {
if (ui_->list->selectionModel()->hasSelection()) {
Settings s;
s.beginGroup(saved_groupings_settings_group_);
for (const QModelIndex &idx : ui_->list->selectionModel()->selectedRows()) {
const QModelIndexList indexes = ui_->list->selectionModel()->selectedRows();
for (const QModelIndex &idx : indexes) {
if (idx.isValid()) {
qLog(Debug) << "Remove saved grouping: " << model_->item(idx.row(), 0)->text();
s.remove(model_->item(idx.row(), 0)->text());

View File

@ -21,6 +21,8 @@
#include "config.h"
#include <utility>
#include <sqlite3.h>
#include <QObject>
@ -87,7 +89,8 @@ Database::~Database() {
QMutexLocker l(&connect_mutex_);
for (const QString &connection_id : QSqlDatabase::connectionNames()) {
const QStringList connection_names = QSqlDatabase::connectionNames();
for (const QString &connection_id : connection_names) {
qLog(Error) << "Connection" << connection_id << "is still open!";
}
@ -157,7 +160,7 @@ QSqlDatabase Database::Connect() {
// Attach external databases
QStringList keys = attached_databases_.keys();
for (const QString &key : keys) {
for (const QString &key : std::as_const(keys)) {
QString filename = attached_databases_[key].filename_;
if (!injected_database_name_.isNull()) filename = injected_database_name_;
@ -178,7 +181,7 @@ QSqlDatabase Database::Connect() {
// We might have to initialize the schema in some attached databases now, if they were deleted and don't match up with the main schema version.
keys = attached_databases_.keys();
for (const QString &key : keys) {
for (const QString &key : std::as_const(keys)) {
if (attached_databases_[key].is_temporary_ && attached_databases_[key].schema_.isEmpty()) {
continue;
}
@ -276,7 +279,8 @@ void Database::RecreateAttachedDb(const QString &database_name) {
// We can't just re-attach the database now because it needs to be done for each thread.
// Close all the database connections, so each thread will re-attach it when they next connect.
for (const QString &name : QSqlDatabase::connectionNames()) {
const QStringList connection_names = QSqlDatabase::connectionNames();
for (const QString &name : connection_names) {
QSqlDatabase::removeDatabase(name);
}
@ -384,8 +388,7 @@ void Database::ExecSchemaCommandsFromFile(QSqlDatabase &db, const QString &filen
void Database::ExecSchemaCommands(QSqlDatabase &db, const QString &schema, int schema_version, bool in_transaction) {
// Run each command
QStringList commands;
commands = schema.split(QRegularExpression(QStringLiteral("; *\n\n")));
QStringList commands = schema.split(QRegularExpression(QStringLiteral("; *\n\n")));
// We don't want this list to reflect possible DB schema changes, so we initialize it before executing any statements.
// If no outer transaction is provided the song tables need to be queried before beginning an inner transaction!
@ -445,12 +448,13 @@ QStringList Database::SongsTables(QSqlDatabase &db, const int schema_version) {
QStringList ret;
// look for the tables in the main db
for (const QString &table : db.tables()) {
const QStringList &tables = db.tables();
for (const QString &table : tables) {
if (table == QStringLiteral("songs") || table.endsWith(QLatin1String("_songs"))) ret << table;
}
// look for the tables in attached dbs
QStringList keys = attached_databases_.keys();
const QStringList keys = attached_databases_.keys();
for (const QString &key : keys) {
SqlQuery q(db);
q.prepare(QStringLiteral("SELECT NAME FROM %1.sqlite_master WHERE type='table' AND name='songs' OR name LIKE '%songs'").arg(key));

View File

@ -19,6 +19,8 @@
#include "config.h"
#include <utility>
#include <QDir>
#include <QFile>
#include <QList>
@ -80,7 +82,8 @@ QIcon IconLoader::Load(const QString &name, const bool system_icon, const int fi
if (icon_prop.allow_system_icon) {
ret = QIcon::fromTheme(name);
if (ret.isNull()) {
for (const QString &alt_name : icon_prop.names) {
const QStringList alt_names = icon_prop.names;
for (const QString &alt_name : alt_names) {
ret = QIcon::fromTheme(alt_name);
if (!ret.isNull()) break;
}
@ -96,7 +99,8 @@ QIcon IconLoader::Load(const QString &name, const bool system_icon, const int fi
else {
int size_smallest = 0;
int size_largest = 0;
for (const QSize &s : ret.availableSizes()) {
const QList<QSize> available_sizes = ret.availableSizes();
for (const QSize &s : available_sizes) {
if (s.width() != s.height()) {
qLog(Warning) << "Can't use system icon for" << name << "icon is not proportional.";
ret = QIcon();
@ -120,7 +124,7 @@ QIcon IconLoader::Load(const QString &name, const bool system_icon, const int fi
if (custom_icons_) {
QString custom_icon_path = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + QStringLiteral("/icons/%1x%2/%3.png");
for (int s : sizes) {
for (int s : std::as_const(sizes)) {
QString filename(custom_icon_path.arg(s).arg(s).arg(name));
if (QFile::exists(filename)) ret.addFile(filename, QSize(s, s));
}
@ -129,7 +133,7 @@ QIcon IconLoader::Load(const QString &name, const bool system_icon, const int fi
}
const QString path(QStringLiteral(":/icons/%1x%2/%3.png"));
for (int s : sizes) {
for (int s : std::as_const(sizes)) {
QString filename(path.arg(s).arg(s).arg(name));
if (QFile::exists(filename)) ret.addFile(filename, QSize(s, s));
}

View File

@ -424,7 +424,7 @@ QStringList MergedProxyModel::mimeTypes() const {
QStringList ret;
ret << sourceModel()->mimeTypes();
QList<QAbstractItemModel*> models = merge_points_.keys();
const QList<QAbstractItemModel*> models = merge_points_.keys();
for (const QAbstractItemModel *model : models) {
ret << model->mimeTypes();
}
@ -506,7 +506,7 @@ QAbstractItemModel *MergedProxyModel::GetModel(const QModelIndex &source_index)
// This is essentially const_cast<QAbstractItemModel*>(source_index.model()), but without the const_cast
const QAbstractItemModel *const_model = source_index.model();
if (const_model == sourceModel()) return sourceModel();
QList<QAbstractItemModel*> submodels = merge_points_.keys();
const QList<QAbstractItemModel*> submodels = merge_points_.keys();
for (QAbstractItemModel *submodel : submodels) {
if (submodel == const_model) return submodel;
}
@ -522,7 +522,7 @@ void MergedProxyModel::DataChanged(const QModelIndex &top_left, const QModelInde
void MergedProxyModel::LayoutAboutToBeChanged() {
old_merge_points_.clear();
QList<QAbstractItemModel*> models = merge_points_.keys();
const QList<QAbstractItemModel*> models = merge_points_.keys();
for (QAbstractItemModel *model : models) {
old_merge_points_[model] = merge_points_.value(model);
}
@ -531,7 +531,7 @@ void MergedProxyModel::LayoutAboutToBeChanged() {
void MergedProxyModel::LayoutChanged() {
QList<QAbstractItemModel*> models = merge_points_.keys();
const QList<QAbstractItemModel*> models = merge_points_.keys();
for (QAbstractItemModel *model : models) {
if (!old_merge_points_.contains(model)) continue;

View File

@ -44,11 +44,10 @@ NetworkProxyFactory::NetworkProxyFactory()
#ifdef Q_OS_LINUX
// Linux uses environment variables to pass proxy configuration information, which systemProxyForQuery doesn't support for some reason.
QStringList urls;
urls << QString::fromLocal8Bit(qgetenv("HTTP_PROXY"));
urls << QString::fromLocal8Bit(qgetenv("http_proxy"));
urls << QString::fromLocal8Bit(qgetenv("ALL_PROXY"));
urls << QString::fromLocal8Bit(qgetenv("all_proxy"));
const QStringList urls = QStringList() << QString::fromLocal8Bit(qgetenv("HTTP_PROXY"))
<< QString::fromLocal8Bit(qgetenv("http_proxy"))
<< QString::fromLocal8Bit(qgetenv("ALL_PROXY"))
<< QString::fromLocal8Bit(qgetenv("all_proxy"));
qLog(Debug) << "Detected system proxy URLs:" << urls;

View File

@ -437,7 +437,8 @@ void Player::PlayPlaylistInternal(const EngineBase::TrackChangeFlags change, con
play_offset_nanosec_ = 0;
Playlist *playlist = nullptr;
for (Playlist *p : app_->playlist_manager()->GetAllPlaylists()) {
const QList<Playlist*> playlists = app_->playlist_manager()->GetAllPlaylists();
for (Playlist *p : playlists) {
if (playlist_name == app_->playlist_manager()->GetPlaylistName(p->id())) {
playlist = p;
break;

View File

@ -176,7 +176,8 @@ void StyleHelper::setBaseColor(const QColor &newcolor) {
if (color.isValid() && color != m_baseColor) {
m_baseColor = color;
for (QWidget *w : QApplication::topLevelWidgets()) {
const QList<QWidget*> widgets = QApplication::topLevelWidgets();
for (QWidget *w : widgets) {
w->update();
}
}

View File

@ -19,6 +19,8 @@
#include "config.h"
#include <utility>
#include <QCoreApplication>
#include <QTranslator>
#include <QString>
@ -29,7 +31,7 @@
Translations::Translations(QObject *parent) : QObject(parent) {}
Translations::~Translations() {
for (QTranslator *t : translations_) {
for (QTranslator *t : std::as_const(translations_)) {
QCoreApplication::removeTranslator(t);
delete t;
}

View File

@ -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();

View File

@ -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();
}

View File

@ -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()) {

View File

@ -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;
}

View File

@ -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];
}

View File

@ -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]));
}

View File

@ -21,6 +21,8 @@
#include "config.h"
#include <utility>
#include <QObject>
#include <QThread>
#include <QMutex>
@ -105,7 +107,7 @@ DeviceDatabaseBackend::DeviceList DeviceDatabaseBackend::GetAllDevices() {
}
}
for (const Device &dev : old_devices) {
for (const Device &dev : std::as_const(old_devices)) {
RemoveDevice(dev.id_);
}

View File

@ -64,7 +64,7 @@ void DeviceInfo::InitFromDb(const DeviceDatabaseBackend::Device &dev) {
transcode_format_ = dev.transcode_format_;
icon_name_ = dev.icon_name_;
QStringList unique_ids = dev.unique_id_.split(QLatin1Char(','));
const QStringList unique_ids = dev.unique_id_.split(QLatin1Char(','));
for (const QString &id : unique_ids) {
backends_ << Backend(nullptr, id);
}

View File

@ -22,6 +22,7 @@
#include "config.h"
#include <functional>
#include <utility>
#include <QtGlobal>
#include <QWidget>
@ -88,14 +89,13 @@ void DeviceProperties::ShowDevice(const QModelIndex &idx) {
if (ui_->icon->count() == 0) {
// Only load the icons the first time the dialog is shown
QStringList icon_names = QStringList()
<< QStringLiteral("device")
<< QStringLiteral("device-usb-drive")
<< QStringLiteral("device-usb-flash")
<< QStringLiteral("media-optical")
<< QStringLiteral("device-ipod")
<< QStringLiteral("device-ipod-nano")
<< QStringLiteral("device-phone");
const QStringList icon_names = QStringList() << QStringLiteral("device")
<< QStringLiteral("device-usb-drive")
<< QStringLiteral("device-usb-flash")
<< QStringLiteral("media-optical")
<< QStringLiteral("device-ipod")
<< QStringLiteral("device-ipod-nano")
<< QStringLiteral("device-phone");
for (const QString &icon_name : icon_names) {
@ -105,7 +105,8 @@ void DeviceProperties::ShowDevice(const QModelIndex &idx) {
#ifdef HAVE_GSTREAMER
// Load the transcode formats the first time the dialog is shown
for (const TranscoderPreset &preset : Transcoder::GetAllPresets()) {
const QList<TranscoderPreset> presets = Transcoder::GetAllPresets();
for (const TranscoderPreset &preset : presets) {
ui_->transcode_format->addItem(preset.name_, QVariant::fromValue(preset.filetype_));
}
ui_->transcode_format->model()->sort(0);
@ -161,7 +162,7 @@ void DeviceProperties::UpdateHardwareInfo() {
// Remove empty items
QStringList keys = info.keys();
for (const QString &key : keys) {
for (const QString &key : std::as_const(keys)) {
if (info[key].isNull() || info[key].toString().isEmpty())
info.remove(key);
}
@ -174,7 +175,7 @@ void DeviceProperties::UpdateHardwareInfo() {
AddHardwareInfo(row++, tr("Model"), lister->DeviceModel(id));
AddHardwareInfo(row++, tr("Manufacturer"), lister->DeviceManufacturer(id));
keys = info.keys();
for (const QString &key : keys) {
for (const QString &key : std::as_const(keys)) {
AddHardwareInfo(row++, key, info[key].toString());
}
@ -307,7 +308,7 @@ void DeviceProperties::UpdateFormatsFinished() {
// Populate supported types list
ui_->supported_formats->clear();
for (Song::FileType type : supported_formats_) {
for (Song::FileType type : std::as_const(supported_formats_)) {
QListWidgetItem *item = new QListWidgetItem(Song::TextForFiletype(type));
ui_->supported_formats->addItem(item);
}

View File

@ -377,7 +377,7 @@ void DeviceView::mouseDoubleClickEvent(QMouseEvent *e) {
SongList DeviceView::GetSelectedSongs() const {
QModelIndexList selected_merged_indexes = selectionModel()->selectedRows();
const QModelIndexList selected_merged_indexes = selectionModel()->selectedRows();
SongList songs;
for (const QModelIndex &merged_index : selected_merged_indexes) {
QModelIndex collection_index = MapToCollection(merged_index);

View File

@ -22,6 +22,7 @@
#include "config.h"
#include <functional>
#include <utility>
#include <glib.h>
#include <glib-object.h>
@ -128,7 +129,7 @@ bool GioLister::Init() {
}
GioLister::~GioLister() {
for (gulong signal : signals_) {
for (gulong signal : std::as_const(signals_)) {
g_signal_handler_disconnect(monitor_, signal);
}
}
@ -222,7 +223,7 @@ QList<QUrl> GioLister::MakeDeviceUrls(const QString &id) {
QList<QUrl> ret;
for (QString uri : uris) {
for (QString uri : std::as_const(uris)) {
// gphoto2 gives invalid hostnames with []:, characters in
uri.replace(QRegularExpression(QStringLiteral("//\\[usb:(\\d+),(\\d+)\\]")), QStringLiteral("//usb-\\1-\\2"));
@ -355,7 +356,7 @@ void GioLister::MountAdded(GMount *mount) {
QMutexLocker l(&mutex_);
// The volume might already exist - either mounted or unmounted.
QStringList ids = devices_.keys();
const QStringList ids = devices_.keys();
for (const QString &id : ids) {
if (devices_[id].volume_ptr == info.volume_ptr) {
old_id = id;

View File

@ -20,6 +20,8 @@
#include "config.h"
#include <utility>
#include <QWidget>
#include <QString>
#include <QIcon>
@ -79,7 +81,7 @@ void ErrorDialog::closeEvent(QCloseEvent *e) {
void ErrorDialog::UpdateContent() {
QString html;
for (const QString &message : current_messages_) {
for (const QString &message : std::as_const(current_messages_)) {
if (!html.isEmpty()) {
html += QLatin1String("<hr/>");
}

View File

@ -21,6 +21,8 @@
#include "config.h"
#include <utility>
#include <QtConcurrentRun>
#include <QWidget>
#include <QDialog>
@ -299,7 +301,7 @@ void TrackSelectionDialog::accept() {
QDialog::accept();
for (const Data &tag_data : data_) {
for (const Data &tag_data : std::as_const(data_)) {
if (tag_data.pending_ || tag_data.results_.isEmpty() || tag_data.selected_result_ == -1) {
continue;
}

View File

@ -25,6 +25,7 @@
#include <cmath>
#include <algorithm>
#include <optional>
#include <utility>
#include <memory>
#include <glib.h>
@ -815,7 +816,7 @@ SharedPtr<GstEnginePipeline> GstEngine::CreatePipeline() {
ret->set_fading_enabled(fadeout_enabled_ || autocrossfade_enabled_ || fadeout_pause_enabled_);
ret->AddBufferConsumer(this);
for (GstBufferConsumer *consumer : buffer_consumers_) {
for (GstBufferConsumer *consumer : std::as_const(buffer_consumers_)) {
ret->AddBufferConsumer(consumer);
}

View File

@ -55,7 +55,7 @@ bool GlobalShortcutsBackendX11::DoRegister() {
if (!gshortcut_init_) gshortcut_init_ = new GlobalShortcut(this);
QList<GlobalShortcutsManager::Shortcut> shortcuts = manager_->shortcuts().values();
const QList<GlobalShortcutsManager::Shortcut> shortcuts = manager_->shortcuts().values();
for (const GlobalShortcutsManager::Shortcut &shortcut : shortcuts) {
AddShortcut(shortcut.action);
}

View File

@ -22,6 +22,7 @@
#include "config.h"
#include <functional>
#include <utility>
#include <QApplication>
#include <QWidget>
@ -197,7 +198,7 @@ bool GlobalShortcutsManager::IsX11Available() {
bool GlobalShortcutsManager::Register() {
for (GlobalShortcutsBackend *backend : backends_) {
for (GlobalShortcutsBackend *backend : std::as_const(backends_)) {
if (backend->IsAvailable() && backends_enabled_.contains(backend->type())) {
return backend->Register();
}
@ -211,7 +212,7 @@ bool GlobalShortcutsManager::Register() {
void GlobalShortcutsManager::Unregister() {
for (GlobalShortcutsBackend *backend : backends_) {
for (GlobalShortcutsBackend *backend : std::as_const(backends_)) {
if (backend->is_active()) {
backend->Unregister();
}

View File

@ -21,6 +21,8 @@
#include "config.h"
#include <utility>
#include <QWidget>
#include <QTreeView>
#include <QSortFilterProxyModel>
@ -180,7 +182,7 @@ bool InternetCollectionView::RestoreLevelFocus(const QModelIndex &parent) {
case CollectionItem::Type_Song:
if (!last_selected_song_.url().isEmpty()) {
QModelIndex idx = qobject_cast<QSortFilterProxyModel*>(model())->mapToSource(current);
SongList songs = collection_model_->GetChildSongs(idx);
const SongList songs = collection_model_->GetChildSongs(idx);
for (const Song &song : songs) {
if (song == last_selected_song_) {
setCurrentIndex(current);

View File

@ -349,7 +349,7 @@ bool InternetSearchView::ResultsContextMenuEvent(QContextMenuEvent *e) {
const bool enable_context_actions = ui_->results->selectionModel() && ui_->results->selectionModel()->hasSelection();
for (QAction *action : context_actions_) {
for (QAction *action : std::as_const(context_actions_)) {
action->setEnabled(enable_context_actions);
}
@ -607,7 +607,7 @@ MimeData *InternetSearchView::SelectedMimeData() {
// Get items for these indexes
QList<QStandardItem*> items;
for (const QModelIndex &idx : indexes) {
for (const QModelIndex &idx : std::as_const(indexes)) {
items << (front_model_->itemFromIndex(front_proxy_->mapToSource(idx))); // clazy:exclude=reserve-candidates
}
@ -715,7 +715,8 @@ void InternetSearchView::SetGroupBy(const CollectionModel::Grouping g) {
s.endGroup();
// Make sure the correct action is checked.
for (QAction *action : group_by_actions_->actions()) {
const QList<QAction*> actions = group_by_actions_->actions();
for (QAction *action : actions) {
if (action->property("group_by").isNull()) continue;
if (g == action->property("group_by").value<CollectionModel::Grouping>()) {
@ -725,7 +726,6 @@ void InternetSearchView::SetGroupBy(const CollectionModel::Grouping g) {
}
// Check the advanced action
QList<QAction*> actions = group_by_actions_->actions();
actions.last()->setChecked(true);
}

View File

@ -69,7 +69,7 @@ InternetServicePtr InternetServices::ServiceBySource(const Song::Source source)
void InternetServices::ReloadSettings() {
QList<InternetServicePtr> services = services_.values();
const QList<InternetServicePtr> services = services_.values();
for (InternetServicePtr service : services) {
service->ReloadSettings();
}
@ -78,7 +78,7 @@ void InternetServices::ReloadSettings() {
void InternetServices::Exit() {
QList<InternetServicePtr> services = services_.values();
const QList<InternetServicePtr> services = services_.values();
for (InternetServicePtr service : services) {
wait_for_exit_ << &*service;
QObject::connect(&*service, &InternetService::ExitFinished, this, &InternetServices::ExitReceived);

View File

@ -79,7 +79,7 @@ void LyricsFetcher::Clear() {
queued_requests_.clear();
QList<LyricsFetcherSearch*> searches = active_requests_.values();
const QList<LyricsFetcherSearch*> searches = active_requests_.values();
for (LyricsFetcherSearch *search : searches) {
search->Cancel();
search->deleteLater();

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <algorithm>
#include <utility>
#include <QObject>
#include <QTimer>
@ -49,7 +50,7 @@ LyricsFetcherSearch::LyricsFetcherSearch(const quint64 id, const LyricsSearchReq
void LyricsFetcherSearch::TerminateSearch() {
QList<int> keys = pending_requests_.keys();
const QList<int> keys = pending_requests_.keys();
for (const int id : keys) {
pending_requests_.take(id)->CancelSearch(id);
}
@ -68,7 +69,7 @@ void LyricsFetcherSearch::Start(SharedPtr<LyricsProviders> lyrics_providers) {
QList<LyricsProvider*> lyrics_providers_sorted = lyrics_providers->List();
std::stable_sort(lyrics_providers_sorted.begin(), lyrics_providers_sorted.end(), ProviderCompareOrder);
for (LyricsProvider *provider : lyrics_providers_sorted) {
for (LyricsProvider *provider : std::as_const(lyrics_providers_sorted)) {
if (!provider->is_enabled() || !provider->IsAuthenticated()) continue;
QObject::connect(provider, &LyricsProvider::SearchFinished, this, &LyricsFetcherSearch::ProviderSearchFinished);
const int id = lyrics_providers->NextId();

View File

@ -19,6 +19,8 @@
#include "config.h"
#include <utility>
#include <QObject>
#include <QMutex>
#include <QList>
@ -51,14 +53,14 @@ void LyricsProviders::ReloadSettings() {
QMap<int, QString> all_providers;
QList<LyricsProvider*> old_providers = lyrics_providers_.keys();
for (LyricsProvider *provider : old_providers) {
for (LyricsProvider *provider : std::as_const(old_providers)) {
if (!provider->is_enabled()) continue;
all_providers.insert(provider->order(), provider->name());
}
Settings s;
s.beginGroup(LyricsSettingsPage::kSettingsGroup);
QStringList providers_enabled = s.value("providers", QStringList() << all_providers.values()).toStringList();
const QStringList providers_enabled = s.value("providers", QStringList() << all_providers.values()).toStringList();
s.endGroup();
int i = 0;
@ -73,7 +75,7 @@ void LyricsProviders::ReloadSettings() {
}
old_providers = lyrics_providers_.keys();
for (LyricsProvider *provider : old_providers) {
for (LyricsProvider *provider : std::as_const(old_providers)) {
if (!new_providers.contains(provider)) {
provider->set_enabled(false);
provider->set_order(++i);
@ -84,7 +86,7 @@ void LyricsProviders::ReloadSettings() {
LyricsProvider *LyricsProviders::ProviderByName(const QString &name) const {
QList<LyricsProvider*> providers = lyrics_providers_.keys();
const QList<LyricsProvider*> providers = lyrics_providers_.keys();
for (LyricsProvider *provider : providers) {
if (provider->name() == name) return provider;
}

View File

@ -88,6 +88,8 @@ void MoodbarBuilder::AddFrame(const double *magnitudes, int size) {
void MoodbarBuilder::Normalize(QList<Rgb> *vals, double Rgb::*member) {
const QList<Rgb> rgb_vals = *vals;
double mini = vals->at(0).*member;
double maxi = vals->at(0).*member;
for (int i = 1; i < vals->count(); i++) {
@ -101,7 +103,7 @@ void MoodbarBuilder::Normalize(QList<Rgb> *vals, double Rgb::*member) {
}
double avg = 0;
for (const Rgb &rgb : *vals) {
for (const Rgb &rgb : rgb_vals) {
const double value = rgb.*member;
if (value != mini && value != maxi) {
avg += value / static_cast<double>(vals->count());
@ -112,7 +114,7 @@ void MoodbarBuilder::Normalize(QList<Rgb> *vals, double Rgb::*member) {
double tb = 0;
double avgu = 0;
double avgb = 0;
for (const Rgb &rgb : *vals) {
for (const Rgb &rgb : rgb_vals) {
const double value = rgb.*member;
if (value != mini && value != maxi) {
if (value > avg) {
@ -132,7 +134,7 @@ void MoodbarBuilder::Normalize(QList<Rgb> *vals, double Rgb::*member) {
tb = 0;
double avguu = 0;
double avgbb = 0;
for (const Rgb &rgb : *vals) {
for (const Rgb &rgb : rgb_vals) {
const double value = rgb.*member;
if (value != mini && value != maxi) {
if (value > avgu) {

View File

@ -16,6 +16,7 @@
*/
#include <algorithm>
#include <utility>
#include <QApplication>
#include <QtConcurrentRun>
@ -177,7 +178,8 @@ bool MoodbarItemDelegate::RemoveFromCacheIfIndexesInvalid(const QUrl &url, Data
void MoodbarItemDelegate::ReloadAllColors() {
for (const QUrl &url : data_.keys()) {
const QList<QUrl> urls = data_.keys();
for (const QUrl &url : urls) {
Data *data = data_[url];
if (data->state_ == Data::State::Loaded) {

View File

@ -114,7 +114,8 @@ MoodbarLoader::Result MoodbarLoader::Load(const QUrl &url, const bool has_cue, Q
// Check if a mood file exists for this file already
const QString filename(url.toLocalFile());
for (const QString &possible_mood_file : MoodFilenames(filename)) {
const QStringList possible_mood_files = MoodFilenames(filename);
for (const QString &possible_mood_file : possible_mood_files) {
QFile f(possible_mood_file);
if (f.exists()) {
if (f.open(QIODevice::ReadOnly)) {

View File

@ -391,7 +391,8 @@ void MoodbarProxyStyle::ShowContextMenu(const QPoint pos) {
}
// Update the currently selected style
for (QAction *action : style_action_group_->actions()) {
const QList<QAction*> actions = style_action_group_->actions();
for (QAction *action : actions) {
if (static_cast<MoodbarRenderer::MoodbarStyle>(action->data().toInt()) == moodbar_style_) {
action->setChecked(true);
break;

View File

@ -22,6 +22,7 @@
#include "config.h"
#include <algorithm>
#include <utility>
#include <QObject>
#include <QtConcurrentMap>
@ -75,7 +76,7 @@ void TagFetcher::StartFetch(const SongList &songs) {
fingerprint_watcher_ = new QFutureWatcher<QString>(this);
QObject::connect(fingerprint_watcher_, &QFutureWatcher<QString>::resultReadyAt, this, &TagFetcher::FingerprintFound);
fingerprint_watcher_->setFuture(future);
for (const Song &song : songs_) {
for (const Song &song : std::as_const(songs_)) {
emit Progress(song, tr("Fingerprinting song"));
}
}

View File

@ -22,6 +22,7 @@
#include <QtGlobal>
#include <functional>
#include <utility>
#include <chrono>
#include <QThread>
@ -125,7 +126,7 @@ void Organize::ProcessSomeFiles() {
if (!started_) {
if (!destination_->StartCopy(&supported_filetypes_)) {
// Failed to start - mark everything as failed :(
for (const Task &task : tasks_pending_) {
for (const Task &task : std::as_const(tasks_pending_)) {
files_with_errors_ << task.song_info_.song_.url().toLocalFile();
}
tasks_pending_.clear();
@ -329,7 +330,7 @@ void Organize::UpdateProgress() {
#ifdef HAVE_GSTREAMER
// Update transcoding progress
QMap<QString, float> transcode_progress = transcoder_->GetProgress();
QStringList filenames = transcode_progress.keys();
const QStringList filenames = transcode_progress.keys();
for (const QString &filename : filenames) {
if (!tasks_transcoding_.contains(filename)) continue;
tasks_transcoding_[filename].transcode_progress_ = transcode_progress[filename];
@ -340,11 +341,11 @@ void Organize::UpdateProgress() {
// Files that need transcoding total 50 for the transcode and 50 for the copy, files that only need to be copied total 100.
int progress = tasks_complete_ * 100;
for (const Task &task : tasks_pending_) {
for (const Task &task : std::as_const(tasks_pending_)) {
progress += qBound(0, static_cast<int>(task.transcode_progress_ * 50), 50);
}
#ifdef HAVE_GSTREAMER
QList<Task> tasks_transcoding = tasks_transcoding_.values();
const QList<Task> tasks_transcoding = tasks_transcoding_.values();
for (const Task &task : tasks_transcoding) {
progress += qBound(0, static_cast<int>(task.transcode_progress_ * 50), 50);
}

View File

@ -165,7 +165,8 @@ OSDPretty::~OSDPretty() {
void OSDPretty::showEvent(QShowEvent *e) {
screens_.clear();
for (QScreen *screen : QGuiApplication::screens()) {
const QList<QScreen*> screens = QGuiApplication::screens();
for (QScreen *screen : screens) {
screens_.insert(screen->name(), screen);
}

View File

@ -21,6 +21,7 @@
#include "config.h"
#include <utility>
#include <memory>
#include <QObject>
@ -307,7 +308,7 @@ PlaylistItemPtr PlaylistBackend::RestoreCueData(PlaylistItemPtr item, SharedPtr<
}
}
for (const Song &from_list : song_list) {
for (const Song &from_list : std::as_const(song_list)) {
if (from_list.url().toEncoded() == song.url().toEncoded() && from_list.beginning_nanosec() == song.beginning_nanosec()) {
// We found a matching section; replace the input item with a new one containing CUE metadata
return make_shared<SongPlaylistItem>(from_list);

View File

@ -141,7 +141,8 @@ void PlaylistListContainer::SetApplication(Application *app) {
QObject::connect(player, &Player::Stopped, this, &PlaylistListContainer::ActiveStopped);
// Get all playlists, even ones that are hidden in the UI.
for (const PlaylistBackend::Playlist &p : app->playlist_backend()->GetAllFavoritePlaylists()) {
const QList<PlaylistBackend::Playlist> playlists = app->playlist_backend()->GetAllFavoritePlaylists();
for (const PlaylistBackend::Playlist &p : playlists) {
QStandardItem *playlist_item = model_->NewPlaylist(p.name, p.id);
QStandardItem *parent_folder = model_->FolderByPath(p.ui_path);
parent_folder->appendRow(playlist_item);
@ -407,7 +408,8 @@ void PlaylistListContainer::Delete() {
QSet<int> ids;
QList<QPersistentModelIndex> folders_to_delete;
for (const QModelIndex &proxy_index : ui_->tree->selectionModel()->selectedRows()) {
const QModelIndexList proxy_indexes = ui_->tree->selectionModel()->selectedRows();
for (const QModelIndex &proxy_index : proxy_indexes) {
const QModelIndex idx = proxy_->mapToSource(proxy_index);
// Is it a playlist?
@ -439,7 +441,7 @@ void PlaylistListContainer::Delete() {
}
// Delete the top-level folders.
for (const QPersistentModelIndex &idx : folders_to_delete) {
for (const QPersistentModelIndex &idx : std::as_const(folders_to_delete)) {
if (idx.isValid()) {
model_->removeRow(idx.row(), idx.parent());
}

View File

@ -20,6 +20,8 @@
#include "config.h"
#include <utility>
#include <QtGlobal>
#include <QList>
#include <QUndoStack>
@ -92,7 +94,7 @@ bool RemoveItems::mergeWith(const QUndoCommand *other) {
ranges_.append(remove_command->ranges_);
int sum = 0;
for (const Range &range : ranges_) sum += range.count_;
for (const Range &range : std::as_const(ranges_)) sum += range.count_;
setText(tr("remove %n songs", "", sum));
return true;

View File

@ -865,7 +865,8 @@ void PlaylistView::mousePressEvent(QMouseEvent *event) {
if (selectedIndexes().contains(idx)) {
// Update all the selected item ratings
QModelIndexList src_index_list;
for (const QModelIndex &i : selectedIndexes()) {
const QModelIndexList indexes = selectedIndexes();
for (const QModelIndex &i : indexes) {
if (i.data(Playlist::Role_CanSetRating).toBool()) {
src_index_list << playlist_->filter()->mapToSource(i);
}
@ -1548,7 +1549,8 @@ void PlaylistView::RatingHoverIn(const QModelIndex &idx, const QPoint pos) {
update(idx);
update(old_index);
for (const QModelIndex &i : selectedIndexes()) {
const QModelIndexList indexes = selectedIndexes();
for (const QModelIndex &i : indexes) {
if (i.column() == Playlist::Column_Rating) update(i);
}
@ -1569,7 +1571,8 @@ void PlaylistView::RatingHoverOut() {
setCursor(QCursor());
update(old_index);
for (const QModelIndex &i : selectedIndexes()) {
const QModelIndexList indexes = selectedIndexes();
for (const QModelIndex &i : indexes) {
if (i.column() == Playlist::Column_Rating) {
update(i);
}

View File

@ -402,8 +402,8 @@ bool CueParser::TryMagic(const QByteArray &data) const {
QString CueParser::FindCueFilename(const QString &filename) {
QStringList cue_files = QStringList() << filename + QStringLiteral(".cue")
<< filename.section(QLatin1Char('.'), 0, -2) + QStringLiteral(".cue");
const QStringList cue_files = QStringList() << filename + QStringLiteral(".cue")
<< filename.section(QLatin1Char('.'), 0, -2) + QStringLiteral(".cue");
for (const QString &cuefile : cue_files) {
if (QFileInfo::exists(cuefile)) return cuefile;

View File

@ -22,6 +22,7 @@
#include "config.h"
#include <algorithm>
#include <utility>
#include <QObject>
#include <QIODevice>
@ -230,7 +231,7 @@ void Queue::UpdateTotalLength() {
quint64 total = 0;
for (const QPersistentModelIndex &row : source_indexes_) {
for (const QPersistentModelIndex &row : std::as_const(source_indexes_)) {
int id = row.row();
Q_ASSERT(playlist_->has_item_at(id));
@ -292,7 +293,8 @@ void Queue::Move(const QList<int> &proxy_rows, int pos) {
}
// Update persistent indexes
for (const QModelIndex &pidx : persistentIndexList()) {
const QModelIndexList pindexes = persistentIndexList();
for (const QModelIndex &pidx : pindexes) {
const int dest_offset = static_cast<int>(proxy_rows.indexOf(pidx.row()));
if (dest_offset != -1) {
// This index was moved
@ -379,7 +381,7 @@ bool Queue::dropMimeData(const QMimeData *data, Qt::DropAction action, int row,
stream >> source_rows;
QModelIndexList source_indexes;
for (int source_row : source_rows) {
for (int source_row : std::as_const(source_rows)) {
const QModelIndex source_index = sourceModel()->index(source_row, 0);
const QModelIndex proxy_index = mapFromSource(source_index);
if (proxy_index.isValid()) {

View File

@ -22,6 +22,7 @@
#include "config.h"
#include <algorithm>
#include <utility>
#include <QWidget>
#include <QAbstractItemModel>
@ -133,7 +134,7 @@ void QueueView::MoveUp() {
if (indexes.isEmpty() || indexes.first().row() == 0) return;
for (const QModelIndex &idx : indexes) {
for (const QModelIndex &idx : std::as_const(indexes)) {
current_playlist_->queue()->MoveUp(idx.row());
}
@ -162,7 +163,8 @@ void QueueView::Remove() {
// collect the rows to be removed
QList<int> row_list;
for (const QModelIndex &idx : ui_->list->selectionModel()->selectedRows()) {
const QModelIndexList indexes = ui_->list->selectionModel()->selectedRows();
for (const QModelIndex &idx : indexes) {
if (idx.isValid()) row_list << idx.row();
}

View File

@ -58,7 +58,7 @@ void ScrobblerSettings::ReloadSettings() {
prefer_albumartist_ = s.value("albumartist", false).toBool();
show_error_dialog_ = s.value("show_error_dialog", true).toBool();
strip_remastered_ = s.value("strip_remastered", true).toBool();
QStringList sources = s.value("sources").toStringList();
const QStringList sources = s.value("sources").toStringList();
s.endGroup();
sources_.clear();

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <algorithm>
#include <utility>
#include <QObject>
#include <QList>
@ -101,7 +102,7 @@ void CoversSettingsPage::Load() {
QList<CoverProvider*> cover_providers_sorted = dialog()->app()->cover_providers()->List();
std::stable_sort(cover_providers_sorted.begin(), cover_providers_sorted.end(), ProviderCompareOrder);
for (CoverProvider *provider : cover_providers_sorted) {
for (CoverProvider *provider : std::as_const(cover_providers_sorted)) {
QListWidgetItem *item = new QListWidgetItem(ui_->providers);
item->setText(provider->name());
item->setCheckState(provider->is_enabled() ? Qt::Checked : Qt::Unchecked);

View File

@ -153,7 +153,7 @@ void GlobalShortcutsSettingsPage::Load() {
}
#endif // HAVE_X11_GLOBALSHORTCUTS
QList<GlobalShortcutsManager::Shortcut> shortcuts = manager->shortcuts().values();
const QList<GlobalShortcutsManager::Shortcut> shortcuts = manager->shortcuts().values();
for (const GlobalShortcutsManager::Shortcut &i : shortcuts) {
Shortcut shortcut;
shortcut.s = i;
@ -167,7 +167,7 @@ void GlobalShortcutsSettingsPage::Load() {
ItemClicked(ui_->list->topLevelItem(0));
}
QList<Shortcut> shortcuts = shortcuts_.values();
const QList<Shortcut> shortcuts = shortcuts_.values();
for (const Shortcut &shortcut : shortcuts) {
SetShortcut(shortcut.s.id, shortcut.s.action->shortcut());
}
@ -215,7 +215,7 @@ void GlobalShortcutsSettingsPage::Save() {
Settings s;
s.beginGroup(kSettingsGroup);
QList<Shortcut> shortcuts = shortcuts_.values();
const QList<Shortcut> shortcuts = shortcuts_.values();
for (const Shortcut &shortcut : shortcuts) {
shortcut.s.action->setShortcut(shortcut.key);
shortcut.s.shortcut->setKey(shortcut.key);
@ -330,7 +330,7 @@ void GlobalShortcutsSettingsPage::ChangeClicked() {
if (key.isEmpty()) return;
// Check if this key sequence is used by any other actions
QStringList ids = shortcuts_.keys();
const QStringList ids = shortcuts_.keys();
for (const QString &id : ids) {
if (shortcuts_[id].key == key) SetShortcut(id, QKeySequence());
}

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <algorithm>
#include <utility>
#include <QObject>
#include <QList>
@ -81,7 +82,7 @@ void LyricsSettingsPage::Load() {
QList<LyricsProvider*> lyrics_providers_sorted = dialog()->app()->lyrics_providers()->List();
std::stable_sort(lyrics_providers_sorted.begin(), lyrics_providers_sorted.end(), ProviderCompareOrder);
for (LyricsProvider *provider : lyrics_providers_sorted) {
for (LyricsProvider *provider : std::as_const(lyrics_providers_sorted)) {
QListWidgetItem *item = new QListWidgetItem(ui_->providers);
item->setText(provider->name());
item->setCheckState(provider->is_enabled() ? Qt::Checked : Qt::Unchecked);

View File

@ -192,7 +192,7 @@ void SettingsDialog::showEvent(QShowEvent *e) {
LoadGeometry();
// Load settings
loading_settings_ = true;
QList<PageData> pages = pages_.values();
const QList<PageData> pages = pages_.values();
for (const PageData &page : pages) {
page.page_->Load();
}
@ -211,7 +211,7 @@ void SettingsDialog::closeEvent(QCloseEvent*) {
void SettingsDialog::accept() {
QList<PageData> pages = pages_.values();
const QList<PageData> pages = pages_.values();
for (const PageData &page : pages) {
page.page_->Accept();
}
@ -226,7 +226,7 @@ void SettingsDialog::accept() {
void SettingsDialog::reject() {
// Notify each page that user clicks on Cancel
QList<PageData> pages = pages_.values();
const QList<PageData> pages = pages_.values();
for (const PageData &page : pages) {
page.page_->Reject();
}
@ -314,7 +314,7 @@ void SettingsDialog::AddPage(const Page id, SettingsPage *page, QTreeWidgetItem
void SettingsDialog::Save() {
QList<PageData> pages = pages_.values();
const QList<PageData> pages = pages_.values();
for (const PageData &page : pages) {
page.page_->Apply();
}
@ -327,7 +327,7 @@ void SettingsDialog::DialogButtonClicked(QAbstractButton *button) {
// While we only connect Apply at the moment, this might change in the future
if (ui_->buttonBox->button(QDialogButtonBox::Apply) == button) {
QList<PageData> pages = pages_.values();
const QList<PageData> pages = pages_.values();
for (const PageData &page : pages) {
page.page_->Apply();
}
@ -357,7 +357,7 @@ void SettingsDialog::CurrentItemChanged(QTreeWidgetItem *item) {
ui_->title->setText(QStringLiteral("<b>") + item->text(0) + QStringLiteral("</b>"));
// Display the right page
QList<PageData> pages = pages_.values();
const QList<PageData> pages = pages_.values();
for (const PageData &page : pages) {
if (page.item_ == item) {
ui_->stacked_widget->setCurrentWidget(page.scroll_area_);

View File

@ -88,7 +88,7 @@ PlaylistItemPtrList PlaylistQueryGenerator::GenerateMore(const int count) {
current_pos_ += search_copy.limit_;
}
SongList songs = collection_backend_->SmartPlaylistsFindSongs(search_copy);
const SongList songs = collection_backend_->SmartPlaylistsFindSongs(search_copy);
PlaylistItemPtrList items;
items.reserve(songs.count());
for (const Song &song : songs) {

View File

@ -21,6 +21,8 @@
#include "config.h"
#include <utility>
#include <QAbstractListModel>
#include <QVariant>
#include <QStringList>
@ -136,7 +138,7 @@ void SmartPlaylistsModel::Init() {
// Append the new ones
s.beginWriteArray(collection_backend_->songs_table(), playlist_index + unwritten_defaults);
for (; version < default_smart_playlists_.count(); ++version) {
for (PlaylistGeneratorPtr gen : default_smart_playlists_[version]) { // clazy:exclude=range-loop-reference
for (PlaylistGeneratorPtr gen : std::as_const(default_smart_playlists_[version])) {
SaveGenerator(&s, playlist_index++, gen);
}
}
@ -231,7 +233,8 @@ void SmartPlaylistsModel::DeleteGenerator(const QModelIndex &idx) {
// Rewrite all the items to the settings
s.beginWriteArray(collection_backend_->songs_table(), static_cast<int>(root_->children.count()));
int i = 0;
for (SmartPlaylistsItem *item : root_->children) {
const QList<SmartPlaylistsItem*> children = root_->children;
for (SmartPlaylistsItem *item : children) {
s.setArrayIndex(i++);
s.setValue("name", item->display_text);
s.setValue("type", static_cast<int>(item->smart_playlist_type));

View File

@ -22,6 +22,7 @@
#include "config.h"
#include <algorithm>
#include <utility>
#include <QtGlobal>
#include <QWidget>
@ -106,7 +107,7 @@ TranscodeDialog::TranscodeDialog(QMainWindow *mainwindow, QWidget *parent)
// Get presets
QList<TranscoderPreset> presets = Transcoder::GetAllPresets();
std::sort(presets.begin(), presets.end(), ComparePresetsByName);
for (const TranscoderPreset &preset : presets) {
for (const TranscoderPreset &preset : std::as_const(presets)) {
ui_->format->addItem(QStringLiteral("%1 (.%2)").arg(preset.name_, preset.extension_), QVariant::fromValue(preset));
}
@ -289,7 +290,7 @@ void TranscodeDialog::UpdateProgress() {
int progress = (finished_success_ + finished_failed_) * 100;
QMap<QString, float> current_jobs = transcoder_->GetProgress();
QList<float> values = current_jobs.values();
const QList<float> values = current_jobs.values();
for (const float value : values) {
progress += qBound(0, static_cast<int>(value * 100), 99);
}

View File

@ -279,11 +279,7 @@ Song::FileType Transcoder::PickBestFormat(const QList<Song::FileType> &supported
if (supported.isEmpty()) return Song::FileType::Unknown;
QList<Song::FileType> best_formats;
best_formats << Song::FileType::FLAC;
best_formats << Song::FileType::OggFlac;
best_formats << Song::FileType::WavPack;
const QList<Song::FileType> best_formats = QList<Song::FileType>() << Song::FileType::FLAC << Song::FileType::OggFlac << Song::FileType::WavPack;
for (Song::FileType type : best_formats) {
if (supported.contains(type)) return type;
}

View File

@ -54,7 +54,7 @@ void OpenInFileManager(const QString &path, const QUrl &url) {
if (xdg_data_dirs.isEmpty()) {
xdg_data_dirs = QStringLiteral("/usr/local/share/:/usr/share/");
}
QStringList data_dirs = xdg_data_dirs.split(QStringLiteral(":"));
const QStringList data_dirs = xdg_data_dirs.split(QStringLiteral(":"));
QString command;
QStringList command_params;

View File

@ -91,19 +91,22 @@ bool CopyRecursive(const QString &source, const QString &destination) {
QDir().mkpath(dest_path);
QDir dir(source);
for (const QString &child : dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs)) {
const QStringList children_dirs = dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs);
for (const QString &child : children_dirs) {
if (!CopyRecursive(source + QLatin1Char('/') + child, dest_path)) {
qLog(Warning) << "Failed to copy dir" << source + QLatin1Char('/') + child << "to" << dest_path;
return false;
}
}
for (const QString &child : dir.entryList(QDir::NoDotAndDotDot | QDir::Files)) {
const QStringList children_files = dir.entryList(QDir::NoDotAndDotDot | QDir::Files);
for (const QString &child : children_files) {
if (!QFile::copy(source + QLatin1Char('/') + child, dest_path + QLatin1Char('/') + child)) {
qLog(Warning) << "Failed to copy file" << source + QLatin1Char('/') + child << "to" << dest_path;
return false;
}
}
return true;
}
@ -111,13 +114,15 @@ bool CopyRecursive(const QString &source, const QString &destination) {
bool RemoveRecursive(const QString &path) {
QDir dir(path);
for (const QString &child : dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Hidden)) {
const QStringList children_dirs = dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Hidden);
for (const QString &child : children_dirs) {
if (!RemoveRecursive(path + QLatin1Char('/') + child)) {
return false;
}
}
for (const QString &child : dir.entryList(QDir::NoDotAndDotDot | QDir::Files | QDir::Hidden)) {
const QStringList children_files = dir.entryList(QDir::NoDotAndDotDot | QDir::Files | QDir::Hidden);
for (const QString &child : children_files) {
if (!QFile::remove(path + QLatin1Char('/') + child)) {
return false;
}

View File

@ -187,7 +187,7 @@ class FancyTabBar : public QTabBar { // clazy:exclude=missing-qobject-macro
// if LargeSidebar, restore spacers
if (tabWidget->mode() == FancyTabWidget::Mode::LargeSidebar && spacers.count() > 0) {
QList<int> keys = spacers.keys();
const QList<int> keys = spacers.keys();
for (const int index : keys) {
tabWidget->insertTab(index, spacers[index], QIcon(), QString());
tabWidget->setTabEnabled(index, false);

View File

@ -19,6 +19,7 @@
*/
#include <algorithm>
#include <utility>
#include <QWidget>
#include <QAbstractItemModel>
@ -81,7 +82,7 @@ QList<QUrl> FileViewList::UrlListFromSelection() const {
QList<QUrl> urls;
urls.reserve(filenames.count());
for (const QString &filename : filenames) {
for (const QString &filename : std::as_const(filenames)) {
urls << QUrl::fromLocalFile(filename);
}

View File

@ -18,6 +18,8 @@
*
*/
#include <utility>
#include <QtGlobal>
#include <QWidget>
#include <QList>
@ -195,7 +197,7 @@ void FreeSpaceBar::DrawText(QPainter *p, const QRect r) {
labels << Label(TextForSize(free_text_, free_ - additional_), kColorBg2);
int text_width = 0;
for (const Label &label : labels) {
for (const Label &label : std::as_const(labels)) {
text_width += kLabelBoxSize + kLabelBoxPadding + kLabelSpacing + small_metrics.horizontalAdvance(label.text);
}
@ -203,7 +205,7 @@ void FreeSpaceBar::DrawText(QPainter *p, const QRect r) {
int x = (r.width() - text_width) / 2;
p->setRenderHint(QPainter::Antialiasing, false);
for (const Label &label : labels) {
for (const Label &label : std::as_const(labels)) {
const bool light = palette().color(QPalette::Base).value() > 128;
QRect box(x, r.top() + (r.height() - kLabelBoxSize) / 2, kLabelBoxSize, kLabelBoxSize);

View File

@ -18,6 +18,8 @@
*
*/
#include <utility>
#include <QWidget>
#include <QListView>
#include <QAbstractItemModel>
@ -305,7 +307,7 @@ void GroupedIconView::paintEvent(QPaintEvent *e) {
}
// Draw headers
for (const Header &header : headers_) {
for (const Header &header : std::as_const(headers_)) {
const QRect header_rect = QRect(header_indent_, header.y, viewport()->width() - header_indent_ * 2, header_height());
// Is this header contained in the area we're drawing?
@ -325,7 +327,7 @@ void GroupedIconView::paintEvent(QPaintEvent *e) {
void GroupedIconView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) {
QVector<QModelIndex> indexes(IntersectingItems(rect.translated(horizontalOffset(), verticalOffset())));
const QVector<QModelIndex> indexes(IntersectingItems(rect.translated(horizontalOffset(), verticalOffset())));
QItemSelection selection;
selection.reserve(indexes.count());
@ -356,7 +358,8 @@ QVector<QModelIndex> GroupedIconView::IntersectingItems(const QRect rect) const
QRegion GroupedIconView::visualRegionForSelection(const QItemSelection &selection) const {
QRegion ret;
for (const QModelIndex &idx : selection.indexes()) {
const QModelIndexList indexes = selection.indexes();
for (const QModelIndex &idx : indexes) {
ret += visual_rects_[idx.row()];
}
return ret;

View File

@ -22,6 +22,8 @@
#include "ui_loginstatewidget.h"
#include "core/iconloader.h"
#include <utility>
#include <QWidget>
#include <QLocale>
#include <QDate>
@ -82,7 +84,7 @@ void LoginStateWidget::SetLoggedIn(const State state, const QString &account_nam
if (account_name.isEmpty()) ui_->signed_in_label->setText(QStringLiteral("<b>") + tr("You are signed in.") + QStringLiteral("</b>"));
else ui_->signed_in_label->setText(tr("You are signed in as %1.").arg(QStringLiteral("<b>") + account_name + QStringLiteral("</b>")));
for (QWidget *widget : credential_groups_) {
for (QWidget *widget : std::as_const(credential_groups_)) {
widget->setVisible(state != State::LoggedIn);
widget->setEnabled(state != State::LoginInProgress);
}

View File

@ -66,7 +66,7 @@ void MultiLoadingIndicator::SetTaskManager(SharedPtr<TaskManager> task_manager)
void MultiLoadingIndicator::UpdateText() {
QList<TaskManager::Task> tasks = task_manager_->GetTasks();
const QList<TaskManager::Task> tasks = task_manager_->GetTasks();
QStringList strings;
strings.reserve(tasks.count());

View File

@ -365,7 +365,7 @@ TEST_F(TestUrls, TestUrls) {
<< QStringLiteral("file:///mnt/music/03 - Vazelina Bilopphøggers - Bomull i øra.flac")
<< QStringLiteral("file:///mnt/music/Test !#$%&'()-@^_`{}~..flac");
QList<QUrl> urls = QUrl::fromStringList(strings);
const QList<QUrl> urls = QUrl::fromStringList(strings);
SongList songs;
songs.reserve(urls.count());
for (const QUrl &url : urls) {
@ -441,12 +441,12 @@ class UpdateSongsBySongID : public CollectionBackendTest {
TEST_F(UpdateSongsBySongID, UpdateSongsBySongID) {
QStringList song_ids = QStringList() << QStringLiteral("song1")
<< QStringLiteral("song2")
<< QStringLiteral("song3")
<< QStringLiteral("song4")
<< QStringLiteral("song5")
<< QStringLiteral("song6");
const QStringList song_ids = QStringList() << QStringLiteral("song1")
<< QStringLiteral("song2")
<< QStringLiteral("song3")
<< QStringLiteral("song4")
<< QStringLiteral("song5")
<< QStringLiteral("song6");
{ // Add songs
SongMap songs;
@ -517,10 +517,10 @@ TEST_F(UpdateSongsBySongID, UpdateSongsBySongID) {
SongMap songs;
QStringList song_ids2 = QStringList() << QStringLiteral("song1")
<< QStringLiteral("song4")
<< QStringLiteral("song5")
<< QStringLiteral("song6");
const QStringList song_ids2 = QStringList() << QStringLiteral("song1")
<< QStringLiteral("song4")
<< QStringLiteral("song5")
<< QStringLiteral("song6");
for (const QString &song_id : song_ids2) {
@ -562,10 +562,10 @@ TEST_F(UpdateSongsBySongID, UpdateSongsBySongID) {
SongMap songs;
QStringList song_ids2 = QStringList() << QStringLiteral("song1")
<< QStringLiteral("song4")
<< QStringLiteral("song5")
<< QStringLiteral("song6");
const QStringList song_ids2 = QStringList() << QStringLiteral("song1")
<< QStringLiteral("song4")
<< QStringLiteral("song5")
<< QStringLiteral("song6");
for (const QString &song_id : song_ids2) {