Add missing const

This commit is contained in:
Jonas Kvinge 2024-08-12 18:12:26 +02:00
parent 8d9c135498
commit bdca60c0ad
69 changed files with 413 additions and 300 deletions

View File

@ -24,7 +24,9 @@
#include <cstring>
#include <iostream>
#include <utility>
#include <memory>
#include <chrono>
#ifndef _MSC_VER
# include <cxxabi.h>
@ -157,7 +159,8 @@ static void MessageHandler(QtMsgType type, const QMessageLogContext&, const QStr
break;
}
for (const QString &line : message.split(QLatin1Char('\n'))) {
const QStringList lines = message.split(QLatin1Char('\n'));
for (const QString &line : lines) {
BufferedDebug d = CreateLogger<BufferedDebug>(level, QStringLiteral("unknown"), -1, nullptr);
d << line.toLocal8Bit().constData();
if (d.buf_) {
@ -193,7 +196,8 @@ void SetLevels(const QString &levels) {
if (!sClassLevels) return;
for (const QString &item : levels.split(QLatin1Char(','))) {
const QStringList items = levels.split(QLatin1Char(','));
for (const QString &item : items) {
const QStringList class_level = item.split(QLatin1Char(':'));
QString class_name;

View File

@ -18,6 +18,7 @@
#include "config.h"
#include <utility>
#include <memory>
#include <string>
@ -73,7 +74,7 @@ void TagReaderWorker::DeviceClosed() {
void TagReaderWorker::HandleMessage(const spb::tagreader::Message &message, spb::tagreader::Message &reply) {
for (shared_ptr<TagReaderBase> reader : tagreaders_) {
for (shared_ptr<TagReaderBase> reader : std::as_const(tagreaders_)) {
if (message.has_is_media_file_request()) {
const QString filename = QString::fromStdString(message.is_media_file_request().filename());

View File

@ -629,7 +629,7 @@ void CollectionModel::UpdateSongsInternal(const SongList &songs) {
}
}
for (CollectionItem *item : album_parents) {
for (CollectionItem *item : std::as_const(album_parents)) {
ClearItemPixmapCache(item);
const QModelIndex idx = ItemToIndex(item);
if (idx.isValid()) {

View File

@ -21,6 +21,8 @@
#include "config.h"
#include <utility>
#include <QtGlobal>
#include <QMetaType>
#include <QDateTime>
@ -65,7 +67,7 @@ void CollectionQuery::AddWhere(const QString &column, const QVariant &value, con
QStringList values = value.toStringList();
QStringList final_values;
final_values.reserve(values.count());
for (const QString &single_value : values) {
for (const QString &single_value : std::as_const(values)) {
final_values.append(QStringLiteral("?"));
bound_values_ << single_value;
}
@ -134,7 +136,7 @@ bool CollectionQuery::Exec() {
if (!QSqlQuery::prepare(sql)) return false;
// Bind values
for (const QVariant &value : bound_values_) {
for (const QVariant &value : std::as_const(bound_values_)) {
QSqlQuery::addBindValue(value);
}

View File

@ -19,6 +19,7 @@
#include "config.h"
#include <utility>
#include <memory>
#include <QtGlobal>
@ -202,7 +203,7 @@ void ContextAlbum::DrawSpinner(QPainter *p) {
void ContextAlbum::DrawPreviousCovers(QPainter *p) {
for (SharedPtr<PreviousCover> previous_cover : previous_covers_) {
for (SharedPtr<PreviousCover> previous_cover : std::as_const(previous_covers_)) {
DrawImage(p, previous_cover->pixmap, previous_cover->opacity);
}
@ -254,7 +255,7 @@ void ContextAlbum::ScaleCover() {
void ContextAlbum::ScalePreviousCovers() {
for (SharedPtr<PreviousCover> previous_cover : previous_covers_) {
for (SharedPtr<PreviousCover> previous_cover : std::as_const(previous_covers_)) {
QImage image = ImageUtils::ScaleImage(previous_cover->image, QSize(desired_height_, desired_height_), devicePixelRatioF(), true);
if (image.isNull()) {
previous_cover->pixmap = QPixmap();

View File

@ -19,6 +19,8 @@
#include "config.h"
#include <utility>
#include <QtGlobal>
#include <QObject>
#include <QWidget>
@ -429,10 +431,10 @@ void ContextView::NoSong() {
void ContextView::UpdateFonts() {
for (QLabel *l : labels_play_all_) {
for (QLabel *l : std::as_const(labels_play_all_)) {
l->setFont(font_normal_);
}
for (QTextEdit *e : textedit_play_) {
for (QTextEdit *e : std::as_const(textedit_play_)) {
e->setFont(font_normal_);
}
@ -620,11 +622,11 @@ void ContextView::UpdateSong(const Song &song) {
void ContextView::ResetSong() {
for (QLabel *l : labels_play_data_) {
for (QLabel *l : std::as_const(labels_play_data_)) {
l->clear();
}
for (QTextEdit *l : textedit_play_) {
for (QTextEdit *l : std::as_const(textedit_play_)) {
l->clear();
}

View File

@ -24,6 +24,7 @@
#include "application.h"
#include <utility>
#include <functional>
#include <chrono>
@ -257,11 +258,11 @@ Application::~Application() {
qLog(Debug) << "Terminating application";
for (QThread *thread : threads_) {
for (QThread *thread : std::as_const(threads_)) {
thread->quit();
}
for (QThread *thread : threads_) {
for (QThread *thread : std::as_const(threads_)) {
thread->wait();
thread->deleteLater();
}

View File

@ -23,8 +23,9 @@
#include "version.h"
#include <cmath>
#include <functional>
#include <algorithm>
#include <utility>
#include <functional>
#include <chrono>
#include <memory>
@ -1907,7 +1908,8 @@ void MainWindow::AddToPlaylistFromAction(QAction *action) {
SongList songs;
// Get the selected playlist items
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
const QModelIndexList proxy_indexes = ui_->playlist->view()->selectionModel()->selectedRows();
for (const QModelIndex &proxy_index : proxy_indexes) {
const QModelIndex source_index = app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
if (!source_index.isValid()) continue;
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_index.row());
@ -1974,7 +1976,7 @@ void MainWindow::PlaylistRightClick(const QPoint global_pos, const QModelIndex &
playlist_stop_after_->setEnabled(source_index.isValid());
// Are any of the selected songs editable or queued?
QModelIndexList selection = ui_->playlist->view()->selectionModel()->selectedRows();
const QModelIndexList selection = ui_->playlist->view()->selectionModel()->selectedRows();
bool cue_selected = false;
qint64 selected = ui_->playlist->view()->selectionModel()->selectedRows().count();
int editable = 0;
@ -2121,7 +2123,7 @@ void MainWindow::PlaylistRightClick(const QPoint global_pos, const QModelIndex &
#endif
// Remove old item actions, if any.
for (QAction *action : playlistitem_actions_) {
for (QAction *action : std::as_const(playlistitem_actions_)) {
playlist_menu_->removeAction(action);
}
@ -2143,7 +2145,8 @@ void MainWindow::PlaylistRightClick(const QPoint global_pos, const QModelIndex &
QMenu *add_to_another_menu = new QMenu(tr("Add to another playlist"), this);
add_to_another_menu->setIcon(IconLoader::Load(QStringLiteral("list-add")));
for (const PlaylistBackend::Playlist &playlist : app_->playlist_backend()->GetAllOpenPlaylists()) {
const PlaylistBackend::PlaylistList playlists = app_->playlist_backend()->GetAllOpenPlaylists();
for (const PlaylistBackend::Playlist &playlist : playlists) {
// don't add the current playlist
if (playlist.id != app_->playlist_manager()->current()->id()) {
QAction *existing_playlist = new QAction(this);
@ -2188,7 +2191,8 @@ void MainWindow::RescanSongs() {
SongList songs;
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
const QModelIndexList proxy_indexes = ui_->playlist->view()->selectionModel()->selectedRows();
for (const QModelIndex &proxy_index : proxy_indexes) {
const QModelIndex source_index = app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
if (!source_index.isValid()) continue;
PlaylistItemPtr item(app_->playlist_manager()->current()->item_at(source_index.row()));
@ -2213,7 +2217,8 @@ void MainWindow::EditTracks() {
SongList songs;
PlaylistItemPtrList items;
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
const QModelIndexList proxy_indexes = ui_->playlist->view()->selectionModel()->selectedRows();
for (const QModelIndex &proxy_index : proxy_indexes) {
const QModelIndex source_index = app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
if (!source_index.isValid()) continue;
PlaylistItemPtr item(app_->playlist_manager()->current()->item_at(source_index.row()));
@ -2235,7 +2240,8 @@ void MainWindow::EditTracks() {
void MainWindow::EditTagDialogAccepted() {
for (PlaylistItemPtr item : edit_tag_dialog_->playlist_items()) {
const PlaylistItemPtrList items = edit_tag_dialog_->playlist_items();
for (PlaylistItemPtr item : items) {
item->Reload();
}
@ -2260,7 +2266,7 @@ void MainWindow::RenumberTracks() {
if (first_song.track() > 0) track = first_song.track();
}
for (const QModelIndex &proxy_index : indexes) {
for (const QModelIndex &proxy_index : std::as_const(indexes)) {
const QModelIndex source_index = app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
if (!source_index.isValid()) continue;
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_index.row());
@ -2291,7 +2297,8 @@ void MainWindow::SelectionSetValue() {
Playlist::Column column = static_cast<Playlist::Column>(playlist_menu_index_.column());
QVariant column_value = app_->playlist_manager()->current()->data(playlist_menu_index_);
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
const QModelIndexList proxy_indexes = ui_->playlist->view()->selectionModel()->selectedRows();
for (const QModelIndex &proxy_index : proxy_indexes) {
const QModelIndex source_index = app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
if (!source_index.isValid()) continue;
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_index.row());
@ -2338,7 +2345,7 @@ void MainWindow::AddFile() {
PlaylistParser parser(app_->collection_backend());
// Show dialog
QStringList filenames = QFileDialog::getOpenFileNames(this, tr("Add file"), directory, QStringLiteral("%1 (%2);;%3;;%4").arg(tr("Music"), QLatin1String(FileView::kFileFilter), parser.filters(PlaylistParser::Type::Load), tr(kAllFilesFilterSpec)));
const QStringList filenames = QFileDialog::getOpenFileNames(this, tr("Add file"), directory, QStringLiteral("%1 (%2);;%3;;%4").arg(tr("Music"), QLatin1String(FileView::kFileFilter), parser.filters(PlaylistParser::Type::Load), tr(kAllFilesFilterSpec)));
if (filenames.isEmpty()) return;
@ -2405,7 +2412,8 @@ void MainWindow::ShowInCollection() {
// Show the first valid selected track artist/album in CollectionView
SongList songs;
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
const QModelIndexList proxy_indexes = ui_->playlist->view()->selectionModel()->selectedRows();
for (const QModelIndex &proxy_index : proxy_indexes) {
const QModelIndex source_index = app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
if (!source_index.isValid()) continue;
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_index.row());
@ -2549,7 +2557,8 @@ void MainWindow::CommandlineOptionsReceived(const CommandlineOptions &options) {
if (!options.urls().empty()) {
#ifdef HAVE_TIDAL
for (const QUrl &url : options.urls()) {
const QList<QUrl> urls = options.urls();
for (const QUrl &url : urls) {
if (url.scheme() == QLatin1String("tidal") && url.host() == QLatin1String("login")) {
emit AuthorizationUrlReceived(url);
return;
@ -2652,7 +2661,8 @@ void MainWindow::AddFilesToTranscoder() {
QStringList filenames;
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
const QModelIndexList proxy_indexes = ui_->playlist->view()->selectionModel()->selectedRows();
for (const QModelIndex &proxy_index : proxy_indexes) {
const QModelIndex source_index = app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
if (!source_index.isValid()) continue;
PlaylistItemPtr item(app_->playlist_manager()->current()->item_at(source_index.row()));
@ -2764,7 +2774,8 @@ void MainWindow::PlaylistMoveToCollection() {
void MainWindow::PlaylistOrganizeSelected(const bool copy) {
SongList songs;
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
const QModelIndexList proxy_indexes = ui_->playlist->view()->selectionModel()->selectedRows();
for (const QModelIndex &proxy_index : proxy_indexes) {
const QModelIndex source_index = app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
if (!source_index.isValid()) continue;
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_index.row());
@ -2786,7 +2797,8 @@ void MainWindow::PlaylistOrganizeSelected(const bool copy) {
void MainWindow::PlaylistOpenInBrowser() {
QList<QUrl> urls;
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
const QModelIndexList proxy_indexes = ui_->playlist->view()->selectionModel()->selectedRows();
for (const QModelIndex &proxy_index : proxy_indexes) {
const QModelIndex source_index = app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
if (!source_index.isValid()) continue;
urls << QUrl(source_index.sibling(source_index.row(), static_cast<int>(Playlist::Column::Filename)).data().toString());
@ -2799,7 +2811,8 @@ void MainWindow::PlaylistOpenInBrowser() {
void MainWindow::PlaylistCopyUrl() {
QList<QUrl> urls;
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
const QModelIndexList proxy_indexes = ui_->playlist->view()->selectionModel()->selectedRows();
for (const QModelIndex &proxy_index : proxy_indexes) {
const QModelIndex source_index = app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
if (!source_index.isValid()) continue;
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_index.row());
@ -2830,7 +2843,7 @@ void MainWindow::PlaylistQueue() {
void MainWindow::PlaylistQueuePlayNext() {
QModelIndexList selected_rows = ui_->playlist->view()->selectionModel()->selectedRows();
const QModelIndexList selected_rows = ui_->playlist->view()->selectionModel()->selectedRows();
QModelIndexList indexes;
indexes.reserve(selected_rows.count());
for (const QModelIndex &proxy_index : selected_rows) {
@ -2860,7 +2873,8 @@ void MainWindow::PlaylistCopyToDevice() {
SongList songs;
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
const QModelIndexList proxy_indexes = ui_->playlist->view()->selectionModel()->selectedRows();
for (const QModelIndex &proxy_index : proxy_indexes) {
const QModelIndex source_index = app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
if (!source_index.isValid()) continue;
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_index.row());
@ -3061,7 +3075,8 @@ void MainWindow::AutoCompleteTags() {
// Get the selected songs and start fetching tags for them
SongList songs;
for (const QModelIndex &proxy_index : ui_->playlist->view()->selectionModel()->selectedRows()) {
const QModelIndexList proxy_indexes = ui_->playlist->view()->selectionModel()->selectedRows();
for (const QModelIndex &proxy_index : proxy_indexes) {
const QModelIndex source_index = app_->playlist_manager()->current()->filter()->mapToSource(proxy_index);
if (!source_index.isValid()) continue;
PlaylistItemPtr item(app_->playlist_manager()->current()->item_at(source_index.row()));
@ -3086,7 +3101,7 @@ void MainWindow::AutoCompleteTags() {
void MainWindow::AutoCompleteTagsAccepted() {
for (PlaylistItemPtr item : autocomplete_tag_items_) {
for (PlaylistItemPtr item : std::as_const(autocomplete_tag_items_)) {
item->Reload();
}
autocomplete_tag_items_.clear();
@ -3278,7 +3293,8 @@ void MainWindow::PlaylistDelete() {
SongList selected_songs;
QStringList files;
bool is_current_item = false;
for (const QModelIndex &proxy_idx : ui_->playlist->view()->selectionModel()->selectedRows()) {
const QModelIndexList proxy_indexes = ui_->playlist->view()->selectionModel()->selectedRows();
for (const QModelIndex &proxy_idx : proxy_indexes) {
QModelIndex source_idx = app_->playlist_manager()->current()->filter()->mapToSource(proxy_idx);
PlaylistItemPtr item = app_->playlist_manager()->current()->item_at(source_idx.row());
if (!item || !item->Metadata().url().isLocalFile()) continue;

View File

@ -22,6 +22,7 @@
#include "config.h"
#include <algorithm>
#include <utility>
#include <cmath>
#include <QApplication>
@ -141,7 +142,7 @@ Mpris2::Mpris2(Application *app, QObject *parent)
data_dirs.append(QStringLiteral("/usr/share"));
}
for (const QString &data_dir : data_dirs) {
for (const QString &data_dir : std::as_const(data_dirs)) {
const QString desktopfilepath = QStringLiteral("%1/applications/%2.desktop").arg(data_dir, QGuiApplication::desktopFileName());
if (QFile::exists(desktopfilepath)) {
desktopfilepath_ = desktopfilepath;
@ -618,7 +619,7 @@ MprisPlaylistList Mpris2::GetPlaylists(quint32 index, quint32 max_count, const Q
Q_UNUSED(order);
QList<Playlist*> playlists = app_->playlist_manager()->GetAllPlaylists();
const QList<Playlist*> playlists = app_->playlist_manager()->GetAllPlaylists();
MprisPlaylistList ret;
ret.reserve(playlists.count());
for (Playlist *p : playlists) {

View File

@ -21,6 +21,8 @@
#include "config.h"
#include <utility>
#include <QtGlobal>
#include <QGuiApplication>
#include <QtConcurrentRun>
@ -421,7 +423,7 @@ void AlbumCoverChoiceController::ShowCover(const Song &song, const QImage &image
}
}
for (const AlbumCoverLoaderOptions::Type type : cover_types_) {
for (const AlbumCoverLoaderOptions::Type type : std::as_const(cover_types_)) {
switch (type) {
case AlbumCoverLoaderOptions::Type::Unset:{
if (song.art_unset()) {
@ -757,7 +759,8 @@ bool AlbumCoverChoiceController::IsKnownImageExtension(const QString &suffix) {
bool AlbumCoverChoiceController::CanAcceptDrag(const QDragEnterEvent *e) {
for (const QUrl &url : e->mimeData()->urls()) {
const QList<QUrl> urls = e->mimeData()->urls();
for (const QUrl &url : urls) {
const QString suffix = QFileInfo(url.toLocalFile()).suffix().toLower();
if (IsKnownImageExtension(suffix)) return true;
}
@ -767,7 +770,8 @@ bool AlbumCoverChoiceController::CanAcceptDrag(const QDragEnterEvent *e) {
void AlbumCoverChoiceController::SaveCover(Song *song, const QDropEvent *e) {
for (const QUrl &url : e->mimeData()->urls()) {
const QList<QUrl> urls = e->mimeData()->urls();
for (const QUrl &url : urls) {
const QString filename = url.toLocalFile();
const QString suffix = QFileInfo(filename).suffix().toLower();

View File

@ -23,6 +23,7 @@
#include <cmath>
#include <algorithm>
#include <utility>
#include <QObject>
#include <QCoreApplication>
@ -73,7 +74,7 @@ AlbumCoverFetcherSearch::~AlbumCoverFetcherSearch() {
void AlbumCoverFetcherSearch::TerminateSearch() {
QList<int> ids = pending_requests_.keys();
const QList<int> ids = pending_requests_.keys();
for (const int id : ids) {
pending_requests_.take(id)->CancelSearch(id);
}
@ -93,7 +94,7 @@ void AlbumCoverFetcherSearch::Start(SharedPtr<CoverProviders> cover_providers) {
QList<CoverProvider*> cover_providers_sorted = 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)) {
if (!provider->is_enabled()) continue;
@ -413,7 +414,7 @@ void AlbumCoverFetcherSearch::Cancel() {
TerminateSearch();
}
else if (!pending_image_loads_.isEmpty()) {
QList<QNetworkReply*> replies = pending_image_loads_.keys();
const QList<QNetworkReply*> replies = pending_image_loads_.keys();
for (QNetworkReply *reply : replies) {
QObject::disconnect(reply, &QNetworkReply::finished, this, nullptr);
reply->abort();

View File

@ -22,6 +22,7 @@
#include "config.h"
#include <algorithm>
#include <utility>
#include <QObject>
#include <QMainWindow>
@ -351,7 +352,7 @@ void AlbumCoverManager::Reset() {
QStringList artists(collection_backend_->GetAllArtistsWithAlbums());
std::stable_sort(artists.begin(), artists.end(), CompareNocase);
for (const QString &artist : artists) {
for (const QString &artist : std::as_const(artists)) {
if (artist.isEmpty()) continue;
new QListWidgetItem(artist_icon_, artist, ui_->artists, Specific_Artist);
}
@ -388,7 +389,7 @@ void AlbumCoverManager::ArtistChanged(QListWidgetItem *current) {
// Sort by album name. The list is already sorted by sqlite but it was done case sensitively.
std::stable_sort(albums.begin(), albums.end(), CompareAlbumNameNocase);
for (const CollectionBackend::Album &album_info : albums) {
for (const CollectionBackend::Album &album_info : std::as_const(albums)) {
// Don't show songs without an album, obviously
if (album_info.album.isEmpty()) continue;
@ -499,7 +500,7 @@ bool AlbumCoverManager::ShouldHide(const AlbumItem &album_item, const QString &f
return false;
}
QStringList query = filter.split(QLatin1Char(' '));
const QStringList query = filter.split(QLatin1Char(' '));
for (const QString &s : query) {
bool in_text = album_item.text().contains(s, Qt::CaseInsensitive);
bool in_albumartist = album_item.data(Role_AlbumArtist).toString().contains(s, Qt::CaseInsensitive);
@ -590,7 +591,7 @@ bool AlbumCoverManager::eventFilter(QObject *obj, QEvent *e) {
bool some_unset = false;
bool some_clear = false;
for (QListWidgetItem *list_widget_item : context_menu_items_) {
for (QListWidgetItem *list_widget_item : std::as_const(context_menu_items_)) {
AlbumItem *album_item = static_cast<AlbumItem*>(list_widget_item);
if (ItemHasCover(*album_item)) some_with_covers = true;
if (album_item->data(Role_ArtUnset).toBool()) {
@ -672,7 +673,7 @@ void AlbumCoverManager::ShowCover() {
void AlbumCoverManager::FetchSingleCover() {
for (QListWidgetItem *list_widget_item : context_menu_items_) {
for (QListWidgetItem *list_widget_item : std::as_const(context_menu_items_)) {
AlbumItem *album_item = static_cast<AlbumItem*>(list_widget_item);
quint64 id = cover_fetcher_->FetchAlbumCover(album_item->data(Role_AlbumArtist).toString(), album_item->data(Role_Album).toString(), QString(), false);
cover_fetching_tasks_[id] = album_item;
@ -713,7 +714,7 @@ void AlbumCoverManager::SaveCoverToFile() {
// Load the image from disk
AlbumCoverImageResult result;
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:
return;
@ -793,7 +794,7 @@ void AlbumCoverManager::SaveImageToAlbums(Song *song, const AlbumCoverImageResul
// Force the found cover on all of the selected items
QList<QUrl> urls;
QList<AlbumItem*> album_items;
for (QListWidgetItem *list_widget_item : context_menu_items_) {
for (QListWidgetItem *list_widget_item : std::as_const(context_menu_items_)) {
AlbumItem *album_item = static_cast<AlbumItem*>(list_widget_item);
switch (album_cover_choice_controller_->get_save_album_cover_type()) {
case CoverOptions::CoverType::Cache:
@ -804,7 +805,7 @@ void AlbumCoverManager::SaveImageToAlbums(Song *song, const AlbumCoverImageResul
break;
}
case CoverOptions::CoverType::Embedded:{
for (const QUrl &url : album_item->urls) {
for (const QUrl &url : std::as_const(album_item->urls)) {
const bool art_embedded = !result.image_data.isEmpty();
TagReaderReply *reply = app_->tag_reader_client()->SaveEmbeddedArt(url.toLocalFile(), TagReaderClient::SaveCoverOptions(result.image_data, result.mime_type));
QObject::connect(reply, &TagReaderReply::Finished, this, [this, reply, album_item, url, art_embedded]() {
@ -826,7 +827,7 @@ void AlbumCoverManager::UnsetCover() {
if (context_menu_items_.isEmpty()) return;
// Force the 'none' cover on all of the selected items
for (QListWidgetItem *list_widget_item : context_menu_items_) {
for (QListWidgetItem *list_widget_item : std::as_const(context_menu_items_)) {
AlbumItem *album_item = static_cast<AlbumItem*>(list_widget_item);
album_item->setIcon(icon_nocover_item_);
album_item->setData(Role_ArtEmbedded, false);
@ -845,7 +846,7 @@ void AlbumCoverManager::ClearCover() {
if (context_menu_items_.isEmpty()) return;
// Force the 'none' cover on all of the selected items
for (QListWidgetItem *list_widget_item : context_menu_items_) {
for (QListWidgetItem *list_widget_item : std::as_const(context_menu_items_)) {
AlbumItem *album_item = static_cast<AlbumItem*>(list_widget_item);
album_item->setIcon(icon_nocover_item_);
album_item->setData(Role_ArtEmbedded, false);
@ -861,7 +862,7 @@ void AlbumCoverManager::ClearCover() {
void AlbumCoverManager::DeleteCover() {
for (QListWidgetItem *list_widget_item : context_menu_items_) {
for (QListWidgetItem *list_widget_item : std::as_const(context_menu_items_)) {
AlbumItem *album_item = static_cast<AlbumItem*>(list_widget_item);
Song song = AlbumItemAsSong(album_item);
album_cover_choice_controller_->DeleteCover(&song);

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <algorithm>
#include <utility>
#include <QtGlobal>
#include <QObject>
@ -214,7 +215,7 @@ void DeezerCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id)
QMap<QUrl, CoverProviderSearchResult> results;
int i = 0;
for (const QJsonValueRef json_value : array_data) {
for (const QJsonValue &json_value : std::as_const(array_data)) {
if (!json_value.isObject()) {
Error(QStringLiteral("Invalid Json reply, data array value is not a object."));
@ -272,8 +273,8 @@ void DeezerCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id)
cover_result.album = Song::AlbumRemoveDiscMisc(album);
bool have_cover = false;
QList<QPair<QString, QSize>> cover_sizes = QList<QPair<QString, QSize>>() << qMakePair(QStringLiteral("cover_xl"), QSize(1000, 1000))
<< qMakePair(QStringLiteral("cover_big"), QSize(500, 500));
const QList<QPair<QString, QSize>> cover_sizes = QList<QPair<QString, QSize>>() << qMakePair(QStringLiteral("cover_xl"), QSize(1000, 1000))
<< qMakePair(QStringLiteral("cover_big"), QSize(500, 500));
for (const QPair<QString, QSize> &cover_size : cover_sizes) {
if (!obj_album.contains(cover_size.first)) continue;
QString cover = obj_album[cover_size.first].toString();

View File

@ -146,9 +146,9 @@ void DiscogsCoverProvider::SendSearchRequest(SharedPtr<DiscogsCoverSearchContext
QNetworkReply *DiscogsCoverProvider::CreateRequest(QUrl url, const ParamList &params_provided) {
ParamList params = ParamList() << Param(QStringLiteral("key"), QString::fromLatin1(QByteArray::fromBase64(kAccessKeyB64)))
<< Param(QStringLiteral("secret"), QString::fromLatin1(QByteArray::fromBase64(kSecretKeyB64)))
<< params_provided;
const ParamList params = ParamList() << Param(QStringLiteral("key"), QString::fromLatin1(QByteArray::fromBase64(kAccessKeyB64)))
<< Param(QStringLiteral("secret"), QString::fromLatin1(QByteArray::fromBase64(kSecretKeyB64)))
<< params_provided;
QUrlQuery url_query;
QStringList query_items;
@ -266,8 +266,8 @@ void DiscogsCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id)
return;
}
QJsonArray array_results = value_results.toArray();
for (QJsonValueRef value_result : array_results) {
const QJsonArray array_results = value_results.toArray();
for (const QJsonValue &value_result : array_results) {
if (!value_result.isObject()) {
Error(QStringLiteral("Invalid Json reply, results value is not a object."));
@ -371,10 +371,10 @@ void DiscogsCoverProvider::HandleReleaseReply(QNetworkReply *reply, const int se
EndSearch(search, release.id);
return;
}
QJsonArray array_artists = value_artists.toArray();
const QJsonArray array_artists = value_artists.toArray();
int i = 0;
QString artist;
for (const QJsonValueRef value_artist : array_artists) {
for (const QJsonValue &value_artist : array_artists) {
if (!value_artist.isObject()) {
Error(QStringLiteral("Invalid Json reply, atists array value is not a object."));
continue;
@ -407,7 +407,7 @@ void DiscogsCoverProvider::HandleReleaseReply(QNetworkReply *reply, const int se
EndSearch(search, release.id);
return;
}
QJsonArray array_images = value_images.toArray();
const QJsonArray array_images = value_images.toArray();
if (array_images.isEmpty()) {
Error(QStringLiteral("Invalid Json reply, images array is empty."));
@ -415,7 +415,7 @@ void DiscogsCoverProvider::HandleReleaseReply(QNetworkReply *reply, const int se
return;
}
for (const QJsonValueRef value_image : array_images) {
for (const QJsonValue &value_image : array_images) {
if (!value_image.isObject()) {
Error(QStringLiteral("Invalid Json reply, images array value is not an object."));

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <algorithm>
#include <utility>
#include <QObject>
#include <QLocale>
@ -97,7 +98,7 @@ bool LastFmCoverProvider::StartSearch(const QString &artist, const QString &albu
QUrlQuery url_query;
QString data_to_sign;
for (const Param &param : params) {
for (const Param &param : std::as_const(params)) {
url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(param.first)), QString::fromLatin1(QUrl::toPercentEncoding(param.second)));
data_to_sign += param.first + param.second;
}
@ -221,9 +222,9 @@ void LastFmCoverProvider::QueryFinished(QNetworkReply *reply, const int id, cons
emit SearchFinished(id, results);
return;
}
QJsonArray array_type = value_type.toArray();
const QJsonArray array_type = value_type.toArray();
for (const QJsonValueRef value : array_type) {
for (const QJsonValue &value : array_type) {
if (!value.isObject()) {
Error(QStringLiteral("Invalid Json reply, value in albummatches/trackmatches array is not a object."));
@ -245,10 +246,10 @@ void LastFmCoverProvider::QueryFinished(QNetworkReply *reply, const int id, cons
Error(QStringLiteral("Invalid Json reply, album image is not a array."), json_image);
continue;
}
QJsonArray array_image = json_image.toArray();
const QJsonArray array_image = json_image.toArray();
QString image_url_use;
LastFmImageSize image_size_use(LastFmImageSize::Unknown);
for (const QJsonValueRef value_image : array_image) {
LastFmImageSize image_size_use = LastFmImageSize::Unknown;
for (const QJsonValue value_image : array_image) {
if (!value_image.isObject()) {
Error(QStringLiteral("Invalid Json reply, album image value is not an object."));
continue;

View File

@ -158,14 +158,14 @@ void MusicbrainzCoverProvider::HandleSearchReply(QNetworkReply *reply, const int
emit SearchFinished(search_id, results);
return;
}
QJsonArray array_releases = value_releases.toArray();
const QJsonArray array_releases = value_releases.toArray();
if (array_releases.isEmpty()) {
emit SearchFinished(search_id, results);
return;
}
for (const QJsonValueRef value_release : array_releases) {
for (const QJsonValue &value_release : array_releases) {
if (!value_release.isObject()) {
Error(QStringLiteral("Invalid Json reply, releases array value is not an object."));
@ -182,10 +182,10 @@ void MusicbrainzCoverProvider::HandleSearchReply(QNetworkReply *reply, const int
Error(QStringLiteral("Invalid Json reply, artist-credit is not a array."), json_artists);
continue;
}
QJsonArray array_artists = json_artists.toArray();
const QJsonArray array_artists = json_artists.toArray();
int i = 0;
QString artist;
for (const QJsonValueRef value_artist : array_artists) {
for (const QJsonValue value_artist : array_artists) {
if (!value_artist.isObject()) {
Error(QStringLiteral("Invalid Json reply, artist is not a object."));
continue;

View File

@ -209,9 +209,9 @@ void MusixmatchCoverProvider::HandleSearchReply(QNetworkReply *reply, const int
return;
}
QList<QPair<QString, QSize>> cover_sizes = QList<QPair<QString, QSize>>() << qMakePair(QStringLiteral("coverImage800x800"), QSize(800, 800))
<< qMakePair(QStringLiteral("coverImage500x500"), QSize(500, 500))
<< qMakePair(QStringLiteral("coverImage350x350"), QSize(350, 350));
const QList<QPair<QString, QSize>> cover_sizes = QList<QPair<QString, QSize>>() << qMakePair(QStringLiteral("coverImage800x800"), QSize(800, 800))
<< qMakePair(QStringLiteral("coverImage500x500"), QSize(500, 500))
<< qMakePair(QStringLiteral("coverImage350x350"), QSize(350, 350));
for (const QPair<QString, QSize> &cover_size : cover_sizes) {
if (!obj_data.contains(cover_size.first)) continue;

View File

@ -19,6 +19,8 @@
#include "config.h"
#include <utility>
#include <QtGlobal>
#include <QObject>
#include <QList>
@ -284,7 +286,7 @@ QJsonObject OpenTidalCoverProvider::GetJsonObject(QNetworkReply *reply) {
}
QJsonObject json_obj = ExtractJsonObj(data);
if (json_obj.contains(QLatin1String("errors")) && json_obj[QLatin1String("errors")].isArray()) {
QJsonArray array = json_obj[QLatin1String("errors")].toArray();
const QJsonArray array = json_obj[QLatin1String("errors")].toArray();
for (const QJsonValue &value : array) {
if (!value.isObject()) continue;
QJsonObject obj = value.toObject();
@ -367,7 +369,7 @@ void OpenTidalCoverProvider::HandleSearchReply(QNetworkReply *reply, SearchReque
return;
}
QJsonArray array_albums = json_obj[QLatin1String("albums")].toArray();
const QJsonArray array_albums = json_obj[QLatin1String("albums")].toArray();
if (array_albums.isEmpty()) {
emit SearchFinished(search_request->id, CoverProviderSearchResults());
return;
@ -375,7 +377,7 @@ void OpenTidalCoverProvider::HandleSearchReply(QNetworkReply *reply, SearchReque
CoverProviderSearchResults results;
int i = 0;
for (const QJsonValueRef value_album : array_albums) {
for (const QJsonValue &value_album : array_albums) {
if (!value_album.isObject()) {
qLog(Debug) << "OpenTidal: Invalid Json reply: Albums array value is not a object.";
@ -407,8 +409,8 @@ void OpenTidalCoverProvider::HandleSearchReply(QNetworkReply *reply, SearchReque
QString artist;
const QString album = obj_resource[QLatin1String("title")].toString();
QJsonArray array_artists = obj_resource[QLatin1String("artists")].toArray();
for (const QJsonValueRef value_artist : array_artists) {
const QJsonArray array_artists = obj_resource[QLatin1String("artists")].toArray();
for (const QJsonValue &value_artist : array_artists) {
if (!value_artist.isObject()) {
continue;
}
@ -420,8 +422,8 @@ void OpenTidalCoverProvider::HandleSearchReply(QNetworkReply *reply, SearchReque
break;
}
QJsonArray array_covers = obj_resource[QLatin1String("imageCover")].toArray();
for (const QJsonValueRef value_cover : array_covers) {
const QJsonArray array_covers = obj_resource[QLatin1String("imageCover")].toArray();
for (const QJsonValue &value_cover : array_covers) {
if (!value_cover.isObject()) {
continue;
}

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <algorithm>
#include <utility>
#include <QtGlobal>
#include <QObject>
@ -91,7 +92,7 @@ bool QobuzCoverProvider::StartSearch(const QString &artist, const QString &album
std::sort(params.begin(), params.end());
QUrlQuery url_query;
for (const Param &param : params) {
for (const Param &param : std::as_const(params)) {
url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(param.first)), QString::fromLatin1(QUrl::toPercentEncoding(param.second)));
}
@ -209,9 +210,9 @@ void QobuzCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id) {
emit SearchFinished(id, results);
return;
}
QJsonArray array_items = value_items.toArray();
const QJsonArray array_items = value_items.toArray();
for (const QJsonValueRef value : array_items) {
for (const QJsonValue &value : array_items) {
if (!value.isObject()) {
Error(QStringLiteral("Invalid Json reply, value in items is not a object."));

View File

@ -96,9 +96,9 @@ bool SpotifyCoverProvider::StartSearch(const QString &artist, const QString &alb
}
}
ParamList params = ParamList() << Param(QStringLiteral("q"), query)
<< Param(QStringLiteral("type"), type)
<< Param(QStringLiteral("limit"), QString::number(kLimit));
const ParamList params = ParamList() << Param(QStringLiteral("q"), query)
<< Param(QStringLiteral("type"), type)
<< Param(QStringLiteral("limit"), QString::number(kLimit));
QUrlQuery url_query;
for (const Param &param : params) {
@ -201,14 +201,14 @@ void SpotifyCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id,
return;
}
QJsonArray array_items = json_obj[QLatin1String("items")].toArray();
const QJsonArray array_items = json_obj[QLatin1String("items")].toArray();
if (array_items.isEmpty()) {
emit SearchFinished(id, CoverProviderSearchResults());
return;
}
CoverProviderSearchResults results;
for (const QJsonValueRef value_item : array_items) {
for (const QJsonValue &value_item : array_items) {
if (!value_item.isObject()) {
continue;
@ -223,19 +223,19 @@ void SpotifyCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id,
if (!obj_album.contains(QLatin1String("artists")) || !obj_album.contains(QLatin1String("name")) || !obj_album.contains(QLatin1String("images")) || !obj_album[QLatin1String("artists")].isArray() || !obj_album[QLatin1String("images")].isArray()) {
continue;
}
QJsonArray array_artists = obj_album[QLatin1String("artists")].toArray();
QJsonArray array_images = obj_album[QLatin1String("images")].toArray();
const QJsonArray array_artists = obj_album[QLatin1String("artists")].toArray();
const QJsonArray array_images = obj_album[QLatin1String("images")].toArray();
QString album = obj_album[QLatin1String("name")].toString();
QStringList artists;
for (const QJsonValueRef value_artist : array_artists) {
for (const QJsonValue &value_artist : array_artists) {
if (!value_artist.isObject()) continue;
QJsonObject obj_artist = value_artist.toObject();
if (!obj_artist.contains(QLatin1String("name"))) continue;
artists << obj_artist[QLatin1String("name")].toString();
}
for (const QJsonValueRef value_image : array_images) {
for (const QJsonValue &value_image : array_images) {
if (!value_image.isObject()) continue;
QJsonObject obj_image = value_image.toObject();
if (!obj_image.contains(QLatin1String("url")) || !obj_image.contains(QLatin1String("width")) || !obj_image.contains(QLatin1String("height"))) continue;

View File

@ -85,9 +85,9 @@ bool TidalCoverProvider::StartSearch(const QString &artist, const QString &album
}
}
ParamList params = ParamList() << Param(QStringLiteral("query"), query)
<< Param(QStringLiteral("limit"), QString::number(kLimit))
<< Param(QStringLiteral("countryCode"), service_->country_code());
const ParamList params = ParamList() << Param(QStringLiteral("query"), query)
<< Param(QStringLiteral("limit"), QString::number(kLimit))
<< Param(QStringLiteral("countryCode"), service_->country_code());
QUrlQuery url_query;
for (const Param &param : params) {
@ -191,7 +191,7 @@ void TidalCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id) {
emit SearchFinished(id, CoverProviderSearchResults());
return;
}
QJsonArray array_items = value_items.toArray();
const QJsonArray array_items = value_items.toArray();
if (array_items.isEmpty()) {
emit SearchFinished(id, CoverProviderSearchResults());
return;
@ -199,7 +199,7 @@ void TidalCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id) {
CoverProviderSearchResults results;
int i = 0;
for (const QJsonValueRef value_item : array_items) {
for (const QJsonValue &value_item : array_items) {
if (!value_item.isObject()) {
Error(QStringLiteral("Invalid Json reply, items array item is not a object."));
@ -250,9 +250,9 @@ void TidalCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id) {
cover_result.album = Song::AlbumRemoveDiscMisc(album);
cover_result.number = ++i;
QList<QPair<QString, QSize>> cover_sizes = QList<QPair<QString, QSize>>() << qMakePair(QStringLiteral("1280x1280"), QSize(1280, 1280))
<< qMakePair(QStringLiteral("750x750"), QSize(750, 750))
<< qMakePair(QStringLiteral("640x640"), QSize(640, 640));
const QList<QPair<QString, QSize>> cover_sizes = QList<QPair<QString, QSize>>() << qMakePair(QStringLiteral("1280x1280"), QSize(1280, 1280))
<< qMakePair(QStringLiteral("750x750"), QSize(750, 750))
<< qMakePair(QStringLiteral("640x640"), QSize(640, 640));
for (const QPair<QString, QSize> &cover_size : cover_sizes) {
QUrl cover_url(QStringLiteral("%1/images/%2/%3.jpg").arg(QLatin1String(TidalService::kResourcesUrl), cover).arg(cover_size.first));
cover_result.image_url = cover_url;

View File

@ -21,6 +21,7 @@
#include "config.h"
#include <utility>
#include <functional>
#include <memory>
@ -146,7 +147,7 @@ DeviceManager::DeviceManager(Application *app, QObject *parent)
DeviceManager::~DeviceManager() {
for (DeviceLister *lister : listers_) {
for (DeviceLister *lister : std::as_const(listers_)) {
lister->ShutDown();
delete lister;
}
@ -163,7 +164,7 @@ void DeviceManager::Exit() {
void DeviceManager::CloseDevices() {
for (DeviceInfo *info : devices_) {
for (DeviceInfo *info : std::as_const(devices_)) {
if (!info->device_) continue;
if (wait_for_exit_.contains(&*info->device_)) continue;
wait_for_exit_ << &*info->device_;
@ -176,7 +177,7 @@ void DeviceManager::CloseDevices() {
void DeviceManager::CloseListers() {
for (DeviceLister *lister : listers_) {
for (DeviceLister *lister : std::as_const(listers_)) {
if (wait_for_exit_.contains(lister)) continue;
wait_for_exit_ << lister;
QObject::connect(lister, &DeviceLister::ExitFinished, this, &DeviceManager::ListerClosed);
@ -231,7 +232,7 @@ void DeviceManager::LoadAllDevices() {
Q_ASSERT(QThread::currentThread() != qApp->thread());
DeviceDatabaseBackend::DeviceList devices = backend_->GetAllDevices();
const DeviceDatabaseBackend::DeviceList devices = backend_->GetAllDevices();
for (const DeviceDatabaseBackend::Device &device : devices) {
DeviceInfo *info = new DeviceInfo(DeviceInfo::Type::Device, root_);
info->InitFromDb(device);
@ -245,7 +246,7 @@ void DeviceManager::LoadAllDevices() {
void DeviceManager::AddDeviceFromDB(DeviceInfo *info) {
QStringList icon_names = info->icon_name_.split(QLatin1Char(','));
const QStringList icon_names = info->icon_name_.split(QLatin1Char(','));
QVariantList icons;
icons.reserve(icon_names.count());
for (const QString &icon_name : icon_names) {
@ -404,7 +405,7 @@ void DeviceManager::AddLister(DeviceLister *lister) {
DeviceInfo *DeviceManager::FindDeviceById(const QString &id) const {
for (int i = 0; i < devices_.count(); ++i) {
for (const DeviceInfo::Backend &backend : devices_[i]->backends_) {
for (const DeviceInfo::Backend &backend : std::as_const(devices_[i]->backends_)) {
if (backend.unique_id_ == id) return devices_[i];
}
}
@ -418,10 +419,10 @@ DeviceInfo *DeviceManager::FindDeviceByUrl(const QList<QUrl> &urls) const {
if (urls.isEmpty()) return nullptr;
for (int i = 0; i < devices_.count(); ++i) {
for (const DeviceInfo::Backend &backend : devices_[i]->backends_) {
for (const DeviceInfo::Backend &backend : std::as_const(devices_[i]->backends_)) {
if (!backend.lister_) continue;
QList<QUrl> device_urls = backend.lister_->MakeDeviceUrls(backend.unique_id_);
const QList<QUrl> device_urls = backend.lister_->MakeDeviceUrls(backend.unique_id_);
for (const QUrl &url : device_urls) {
if (urls.contains(url)) return devices_[i];
}
@ -434,7 +435,7 @@ DeviceInfo *DeviceManager::FindDeviceByUrl(const QList<QUrl> &urls) const {
DeviceInfo *DeviceManager::FindEquivalentDevice(DeviceInfo *info) const {
for (const DeviceInfo::Backend &backend : info->backends_) {
for (const DeviceInfo::Backend &backend : std::as_const(info->backends_)) {
DeviceInfo *match = FindDeviceById(backend.unique_id_);
if (match) return match;
}
@ -588,7 +589,7 @@ SharedPtr<ConnectedDevice> DeviceManager::Connect(DeviceInfo *info) {
}
// Get the device URLs
QList<QUrl> urls = info->BestBackend()->lister_->MakeDeviceUrls(info->BestBackend()->unique_id_);
const QList<QUrl> urls = info->BestBackend()->lister_->MakeDeviceUrls(info->BestBackend()->unique_id_);
if (urls.isEmpty()) return ret;
// Take the first URL that we have a handler for
@ -844,13 +845,13 @@ void DeviceManager::DeviceTaskStarted(const int id) {
void DeviceManager::TasksChanged() {
QList<TaskManager::Task> tasks = app_->task_manager()->GetTasks();
const QList<TaskManager::Task> tasks = app_->task_manager()->GetTasks();
QList<QPersistentModelIndex> finished_tasks = active_tasks_.values();
for (const TaskManager::Task &task : tasks) {
if (!active_tasks_.contains(task.id)) continue;
QPersistentModelIndex idx = active_tasks_[task.id];
const QPersistentModelIndex idx = active_tasks_[task.id];
if (!idx.isValid()) continue;
DeviceInfo *info = IndexToItem(idx);
@ -866,7 +867,7 @@ void DeviceManager::TasksChanged() {
}
for (const QPersistentModelIndex &idx : finished_tasks) {
for (const QPersistentModelIndex &idx : std::as_const(finished_tasks)) {
if (!idx.isValid()) continue;

View File

@ -21,8 +21,8 @@
#include "config.h"
#include <memory>
#include <utility>
#include <memory>
#include <QtGlobal>
#include <QMutex>
@ -200,7 +200,7 @@ bool Udisks2Lister::Init() {
return false;
}
QList<QDBusObjectPath> paths = reply.value().keys();
const QList<QDBusObjectPath> paths = reply.value().keys();
for (const QDBusObjectPath &path : paths) {
PartitionData partition_data = ReadPartitionData(path);
@ -210,7 +210,7 @@ bool Udisks2Lister::Init() {
}
}
QStringList ids = device_data_.keys();
const QStringList ids = device_data_.keys();
for (const QString &id : ids) {
emit DeviceAdded(id);
}
@ -326,7 +326,7 @@ void Udisks2Lister::JobCompleted(const bool success, const QString &message) {
qLog(Debug) << "Pending Job Completed | Path = " << job->path() << " | Mount? = " << mounting_jobs_[jobPath].is_mount << " | Success = " << success;
for (const auto &mounted_object : mounting_jobs_[jobPath].mounted_partitions) {
for (const auto &mounted_object : std::as_const(mounting_jobs_[jobPath].mounted_partitions)) {
auto partition_data = ReadPartitionData(mounted_object);
if (partition_data.dbus_path.isEmpty()) continue;
@ -394,7 +394,8 @@ Udisks2Lister::PartitionData Udisks2Lister::ReadPartitionData(const QDBusObjectP
result.friendly_name = result.label;
}
for (const QByteArray &p : filesystem.mountPoints()) {
const QList<QByteArray> mountpoints = filesystem.mountPoints();
for (const QByteArray &p : mountpoints) {
const QString mountpoint = QString::fromUtf8(p.data(), static_cast<qint64>(qstrlen(p.data())));
result.mount_paths.push_back(mountpoint);
}

View File

@ -21,8 +21,9 @@
#include "config.h"
#include <functional>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <limits>
@ -152,7 +153,8 @@ EditTagDialog::EditTagDialog(Application *app, QWidget *parent)
// An editable field is one that has a label as a buddy.
// The label is important because it gets turned bold when the field is changed.
for (QLabel *label : findChildren<QLabel*>()) {
QList<QLabel*> labels = findChildren<QLabel*>();
for (QLabel *label : std::as_const(labels)) {
QWidget *widget = label->buddy();
if (widget) {
// Store information about the field
@ -191,7 +193,8 @@ EditTagDialog::EditTagDialog(Application *app, QWidget *parent)
QPalette summary_label_palette(palette());
summary_label_palette.setColor(QPalette::WindowText, light ? color.lighter(150) : color.darker(150));
for (QLabel *label : ui_->tab_summary->findChildren<QLabel*>()) {
labels = ui_->tab_summary->findChildren<QLabel*>();
for (QLabel *label : std::as_const(labels)) {
if (label->property("field_label").toBool()) {
label->setPalette(summary_label_palette);
}
@ -453,7 +456,7 @@ void EditTagDialog::SetSongsFinished() {
}
// Add the filenames to the list
for (const Data &tag_data : data_) {
for (const Data &tag_data : std::as_const(data_)) {
ui_->song_list->addItem(tag_data.current_.basefilename());
}
@ -757,7 +760,7 @@ void EditTagDialog::SelectionChanged() {
void EditTagDialog::UpdateUI(const QModelIndexList &indexes) {
ignore_edits_ = true;
for (const FieldData &field : fields_) {
for (const FieldData &field : std::as_const(fields_)) {
InitFieldValue(field, indexes);
}
ignore_edits_ = false;
@ -926,7 +929,8 @@ void EditTagDialog::AlbumCoverLoaded(const quint64 id, const AlbumCoverLoaderRes
}
Song first_song;
UpdateCoverAction cover_action = UpdateCoverAction::None;
for (const QModelIndex &idx : ui_->song_list->selectionModel()->selectedIndexes()) {
const QModelIndexList indexes = ui_->song_list->selectionModel()->selectedIndexes();
for (const QModelIndex &idx : indexes) {
data_[idx.row()].cover_result_ = result.album_cover;
if (!first_song.is_valid()) {
first_song = data_[idx.row()].current_;
@ -967,7 +971,7 @@ void EditTagDialog::FieldValueEdited() {
QWidget *w = qobject_cast<QWidget*>(sender());
// Find the field
for (const FieldData &field : fields_) {
for (const FieldData &field : std::as_const(fields_)) {
if (field.editor_ == w) {
UpdateFieldValue(field, sel);
return;
@ -986,7 +990,7 @@ void EditTagDialog::ResetField() {
QWidget *w = qobject_cast<QWidget*>(sender());
// Find the field
for (const FieldData &field : fields_) {
for (const FieldData &field : std::as_const(fields_)) {
if (field.editor_ == w) {
ignore_edits_ = true;
ResetFieldValue(field, sel);

View File

@ -329,7 +329,7 @@ void Equalizer::Save() {
// Presets
s.beginWriteArray("presets", static_cast<int>(presets_.count()));
int i = 0;
QStringList presets = presets_.keys();
const QStringList presets = presets_.keys();
for (const QString &name : presets) {
s.setArrayIndex(i++);
s.setValue("name", name);

View File

@ -17,6 +17,8 @@
*
*/
#include <utility>
#include <QCoreApplication>
#include <QList>
#include <QString>
@ -83,7 +85,7 @@ bool GlobalShortcutsBackendKDE::DoRegister() {
interface_ = new OrgKdeKGlobalAccelInterface(QLatin1String(kKdeService), QLatin1String(kKdePath), QDBusConnection::sessionBus(), this);
}
QList<GlobalShortcutsManager::Shortcut> shortcuts = manager_->shortcuts().values();
const QList<GlobalShortcutsManager::Shortcut> shortcuts = manager_->shortcuts().values();
for (const GlobalShortcutsManager::Shortcut &shortcut : shortcuts) {
RegisterShortcut(shortcut);
}
@ -129,7 +131,7 @@ void GlobalShortcutsBackendKDE::DoUnregister() {
qLog(Debug) << "Unregistering";
QMap<QString, GlobalShortcutsManager::Shortcut> shortcuts = manager_->shortcuts();
const QMap<QString, GlobalShortcutsManager::Shortcut> shortcuts = manager_->shortcuts();
for (const GlobalShortcutsManager::Shortcut &shortcut : shortcuts) {
if (actions_.contains(shortcut.id)) {
interface_->unRegister(GetActionId(shortcut.id, shortcut.action));
@ -214,7 +216,8 @@ QList<QKeySequence> GlobalShortcutsBackendKDE::ToKeySequenceList(const QList<int
void GlobalShortcutsBackendKDE::GlobalShortcutPressed(const QString &component_unique, const QString &shortcut_unique, qint64) {
if (QCoreApplication::applicationName() == component_unique && actions_.contains(shortcut_unique)) {
for (QAction *action : actions_.values(shortcut_unique)) {
const QList<QAction*> actions = actions_.values(shortcut_unique);
for (QAction *action : actions) {
qLog(Debug) << "Key" << action->shortcut() << "pressed.";
if (action->isEnabled()) action->trigger();
}

View File

@ -19,6 +19,7 @@
#include "config.h"
#include <utility>
#include <memory>
#include <QObject>
@ -382,9 +383,9 @@ void GeniusLyricsProvider::HandleSearchReply(QNetworkReply *reply, const int id)
EndSearch(search);
return;
}
QJsonArray array_hits = obj_response[QLatin1String("hits")].toArray();
const QJsonArray array_hits = obj_response[QLatin1String("hits")].toArray();
for (const QJsonValueRef value_hit : array_hits) {
for (const QJsonValue &value_hit : array_hits) {
if (!value_hit.isObject()) {
continue;
}
@ -491,7 +492,7 @@ void GeniusLyricsProvider::AuthError(const QString &error, const QVariant &debug
if (!error.isEmpty()) login_errors_ << error;
for (const QString &e : login_errors_) Error(e);
for (const QString &e : std::as_const(login_errors_)) Error(e);
if (debug.isValid()) qLog(Debug) << debug;
emit AuthenticationFailure(login_errors_);

View File

@ -19,6 +19,7 @@
#include "config.h"
#include <utility>
#include <memory>
#include <QObject>
@ -189,9 +190,9 @@ void MusixmatchLyricsProvider::HandleSearchReply(QNetworkReply *reply, LyricsSea
EndSearch(search);
return;
}
QJsonArray array_tracklist = obj_body[QLatin1String("track_list")].toArray();
const QJsonArray array_tracklist = obj_body[QLatin1String("track_list")].toArray();
for (const QJsonValueRef value_track : array_tracklist) {
for (const QJsonValue &value_track : array_tracklist) {
if (!value_track.isObject()) {
continue;
}
@ -235,7 +236,7 @@ void MusixmatchLyricsProvider::HandleSearchReply(QNetworkReply *reply, LyricsSea
EndSearch(search);
}
else {
for (const QUrl &url : search->requests_lyrics_) {
for (const QUrl &url : std::as_const(search->requests_lyrics_)) {
SendLyricsRequest(search, url);
}
}

View File

@ -22,6 +22,7 @@
#include "config.h"
#include <algorithm>
#include <utility>
#include <QtGlobal>
#include <QObject>
@ -161,16 +162,16 @@ void AcoustidClient::RequestFinished(QNetworkReply *reply, const int request_id)
// -then sort results by number of sources (the results are originally
// unsorted but results with more sources are likely to be more accurate)
// -keep only the ids, as sources where useful only to sort the results
QJsonArray json_results = json_object[QLatin1String("results")].toArray();
const QJsonArray json_results = json_object[QLatin1String("results")].toArray();
// List of <id, nb of sources> pairs
QList<IdSource> id_source_list;
for (const QJsonValueRef v : json_results) {
for (const QJsonValue &v : json_results) {
QJsonObject r = v.toObject();
if (!r[QLatin1String("recordings")].isUndefined()) {
QJsonArray json_recordings = r[QLatin1String("recordings")].toArray();
for (const QJsonValueRef recording : json_recordings) {
const QJsonArray json_recordings = r[QLatin1String("recordings")].toArray();
for (const QJsonValue &recording : json_recordings) {
QJsonObject o = recording.toObject();
if (!o[QLatin1String("id")].isUndefined()) {
id_source_list << IdSource(o[QLatin1String("id")].toString(), o[QLatin1String("sources")].toInt());
@ -183,11 +184,10 @@ void AcoustidClient::RequestFinished(QNetworkReply *reply, const int request_id)
QStringList id_list;
id_list.reserve(id_source_list.count());
for (const IdSource &is : id_source_list) {
for (const IdSource &is : std::as_const(id_source_list)) {
id_list << is.id_;
}
emit Finished(request_id, id_list);
}

View File

@ -22,6 +22,7 @@
#include "config.h"
#include <algorithm>
#include <utility>
#include <QObject>
#include <QSet>
@ -213,7 +214,7 @@ void MusicBrainzClient::RequestFinished(QNetworkReply *reply, const int id, cons
ResultList res;
while (!reader.atEnd()) {
if (reader.readNext() == QXmlStreamReader::StartElement && reader.name().toString() == QLatin1String("recording")) {
ResultList tracks = ParseTrack(&reader);
const ResultList tracks = ParseTrack(&reader);
for (const Result &track : tracks) {
if (!track.title_.isEmpty()) {
res << track;
@ -230,7 +231,7 @@ void MusicBrainzClient::RequestFinished(QNetworkReply *reply, const int id, cons
ResultList ret;
QList<PendingResults> result_list_list = pending_results_.take(id);
std::sort(result_list_list.begin(), result_list_list.end());
for (const PendingResults &result_list : result_list_list) {
for (const PendingResults &result_list : std::as_const(result_list_list)) {
ret << result_list.results_;
}
emit Finished(id, UniqueResults(ret, UniqueResultsSortOption::KeepOriginalOrder), error);
@ -292,7 +293,7 @@ void MusicBrainzClient::DiscIdRequestFinished(const QString &discid, QNetworkRep
if (token == QXmlStreamReader::StartElement && name == QLatin1String("medium")) {
// Get the medium with a matching discid.
if (MediumHasDiscid(discid, &reader)) {
ResultList tracks = ParseMedium(&reader);
const ResultList tracks = ParseMedium(&reader);
for (const Result &track : tracks) {
if (!track.title_.isEmpty()) {
ret << track;
@ -387,6 +388,7 @@ MusicBrainzClient::Result MusicBrainzClient::ParseTrackFromDisc(QXmlStreamReader
}
return result;
}
MusicBrainzClient::ResultList MusicBrainzClient::ParseTrack(QXmlStreamReader *reader) {
@ -426,11 +428,13 @@ MusicBrainzClient::ResultList MusicBrainzClient::ParseTrack(QXmlStreamReader *re
else {
std::stable_sort(releases.begin(), releases.end());
ret.reserve(releases.count());
for (const Release &release : releases) {
for (const Release &release : std::as_const(releases)) {
ret << release.CopyAndMergeInto(result);
}
}
return ret;
}
// Parse the artist. Multiple artists are joined together with the joinphrase from musicbrainz.

View File

@ -154,4 +154,3 @@ void TagFetcher::TagsFetched(const int index, const MusicBrainzClient::ResultLis
emit ResultAvailable(original_song, songs_guessed, error);
}

View File

@ -21,8 +21,9 @@
#include "config.h"
#include <functional>
#include <algorithm>
#include <utility>
#include <functional>
#include <memory>
#include <QtGlobal>
@ -141,7 +142,7 @@ OrganizeDialog::OrganizeDialog(SharedPtr<TaskManager> task_manager, SharedPtr<Co
// Build the insert menu
QMenu *tag_menu = new QMenu(this);
for (const QString &title : tag_titles) {
for (const QString &title : std::as_const(tag_titles)) {
QAction *action = tag_menu->addAction(title);
QString tag = tags[title];
QObject::connect(action, &QAction::triggered, this, [this, tag]() { InsertTag(tag); });
@ -409,7 +410,8 @@ SongList OrganizeDialog::LoadSongsBlocking(const QStringList &filenames) {
// If it's a directory, add all the files inside.
if (QFileInfo(filename).isDir()) {
const QDir dir(filename);
for (const QString &entry : dir.entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot | QDir::Readable)) {
const QStringList entries = dir.entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot | QDir::Readable);
for (const QString &entry : entries) {
filenames_copy << dir.filePath(entry);
}
continue;
@ -535,7 +537,7 @@ void OrganizeDialog::UpdatePreviews() {
ui_->groupbox_preview->setVisible(has_local_destination);
ui_->groupbox_naming->setVisible(has_local_destination);
if (has_local_destination) {
for (const Organize::NewSongInfo &song_info : new_songs_info_) {
for (const Organize::NewSongInfo &song_info : std::as_const(new_songs_info_)) {
QString filename = storage->LocalPath() + QLatin1Char('/') + song_info.new_filename_;
QListWidgetItem *item = new QListWidgetItem(song_info.unique_filename_ ? IconLoader::Load(QStringLiteral("dialog-ok-apply")) : IconLoader::Load(QStringLiteral("dialog-warning")), QDir::toNativeSeparators(filename), ui_->preview);
ui_->preview->addItem(item);

View File

@ -22,9 +22,9 @@
#include "config.h"
#include <cstdlib>
#include <memory>
#include <utility>
#include <algorithm>
#include <utility>
#include <memory>
#include <functional>
#include <unordered_map>
#include <random>
@ -861,7 +861,7 @@ bool Playlist::dropMimeData(const QMimeData *data, Qt::DropAction action, const
// Drag from a different playlist
PlaylistItemPtrList items;
items.reserve(source_rows.count());
for (const int i : source_rows) items << source_playlist->item_at(i);
for (const int i : std::as_const(source_rows)) items << source_playlist->item_at(i);
if (items.count() > kUndoItemLimit) {
// Too big to keep in the undo stack. Also clear the stack because it might have been invalidated.
@ -874,7 +874,7 @@ bool Playlist::dropMimeData(const QMimeData *data, Qt::DropAction action, const
// Remove the items from the source playlist if it was a move event
if (action == Qt::MoveAction) {
for (const int i : source_rows) {
for (const int i : std::as_const(source_rows)) {
source_playlist->undo_stack()->push(new PlaylistUndoCommands::RemoveItems(source_playlist, i, 1));
}
}
@ -965,7 +965,8 @@ void Playlist::MoveItemsWithoutUndo(const QList<int> &source_rows, int pos) {
}
// Update persistent indexes
for (const QModelIndex &pidx : persistentIndexList()) {
const QModelIndexList pidx_list = persistentIndexList();
for (const QModelIndex &pidx : pidx_list) {
const int dest_offset = static_cast<int>(source_rows.indexOf(pidx.row()));
if (dest_offset != -1) {
// This index was moved
@ -1034,7 +1035,8 @@ void Playlist::MoveItemsWithoutUndo(int start, const QList<int> &dest_rows) {
}
// Update persistent indexes
for (const QModelIndex &pidx : persistentIndexList()) {
const QModelIndexList pidx_list = persistentIndexList();
for (const QModelIndex &pidx : pidx_list) {
if (pidx.row() >= start && pidx.row() < start + dest_rows.count()) {
// This index was moved
const int i = pidx.row() - start;
@ -1494,7 +1496,8 @@ void Playlist::ReOrderWithoutUndo(const PlaylistItemPtrList &new_items) {
new_rows[&*new_items[i]] = i;
}
for (const QModelIndex &idx : persistentIndexList()) {
const QModelIndexList indexes = persistentIndexList();
for (const QModelIndex &idx : indexes) {
const PlaylistItem *item = &*old_items[idx.row()];
changePersistentIndex(idx, index(new_rows[item], idx.column(), idx.parent()));
}
@ -2097,7 +2100,7 @@ void Playlist::TracksAboutToBeDequeued(const QModelIndex&, const int begin, cons
void Playlist::TracksDequeued() {
for (const QModelIndex &idx : temp_dequeue_change_indexes_) {
for (const QModelIndex &idx : std::as_const(temp_dequeue_change_indexes_)) {
emit dataChanged(idx, idx);
}
temp_dequeue_change_indexes_.clear();

View File

@ -83,7 +83,7 @@ PlaylistManager::PlaylistManager(Application *app, QObject *parent)
PlaylistManager::~PlaylistManager() {
QList<Data> datas = playlists_.values();
const QList<Data> datas = playlists_.values();
for (const Data &data : datas) delete data.p;
}
@ -102,7 +102,8 @@ void PlaylistManager::Init(SharedPtr<CollectionBackend> collection_backend, Shar
QObject::connect(parser_, &PlaylistParser::Error, this, &PlaylistManager::Error);
for (const PlaylistBackend::Playlist &p : playlist_backend->GetAllOpenPlaylists()) {
const PlaylistBackend::PlaylistList playlists = playlist_backend->GetAllOpenPlaylists();
for (const PlaylistBackend::Playlist &p : playlists) {
++playlists_loading_;
Playlist *ret = AddPlaylist(p.id, p.name, p.special_type, p.ui_path, p.favorite);
QObject::connect(ret, &Playlist::PlaylistLoaded, this, &PlaylistManager::PlaylistLoaded);
@ -131,7 +132,7 @@ QList<Playlist*> PlaylistManager::GetAllPlaylists() const {
QList<Playlist*> result;
QList<Data> datas = playlists_.values();
const QList<Data> datas = playlists_.values();
result.reserve(datas.count());
for (const Data &data : datas) {
result.append(data.p);
@ -318,7 +319,7 @@ bool PlaylistManager::Close(const int id) {
if (playlists_.count() <= 1 || !playlists_.contains(id)) return false;
int next_id = -1;
QList<int> playlist_ids = playlists_.keys();
const QList<int> playlist_ids = playlists_.keys();
for (const int possible_next_id : playlist_ids) {
if (possible_next_id != id) {
next_id = possible_next_id;
@ -430,7 +431,7 @@ void PlaylistManager::UpdateSummaryText() {
int selected = 0;
// Get the length of the selected tracks
for (const QItemSelectionRange &range : playlists_[current_id()].selection) {
for (const QItemSelectionRange &range : std::as_const(playlists_[current_id()].selection)) {
if (!range.isValid()) continue;
selected += range.bottom() - range.top() + 1;
@ -471,7 +472,7 @@ void PlaylistManager::UpdateCollectionSongs(const SongList &songs) {
for (const Song &song : songs) {
for (const Data &data : std::as_const(playlists_)) {
PlaylistItemPtrList items = data.p->collection_items_by_id(song.id());
const PlaylistItemPtrList items = data.p->collection_items_by_id(song.id());
for (PlaylistItemPtr item : items) {
if (item->Metadata().directory_id() != song.directory_id()) continue;
data.p->UpdateItemMetadata(item, song, false);
@ -484,7 +485,8 @@ void PlaylistManager::UpdateCollectionSongs(const SongList &songs) {
// When Player has processed the new song chosen by the user...
void PlaylistManager::SongChangeRequestProcessed(const QUrl &url, const bool valid) {
for (Playlist *playlist : GetAllPlaylists()) {
const QList<Playlist*> playlists = GetAllPlaylists();
for (Playlist *playlist : playlists) {
if (playlist->ApplyValidityOnCurrentSong(url, valid)) {
return;
}
@ -521,14 +523,18 @@ void PlaylistManager::RemoveCurrentSong() const {
}
void PlaylistManager::InvalidateDeletedSongs() {
for (Playlist *playlist : GetAllPlaylists()) {
const QList<Playlist*> playlists = GetAllPlaylists();
for (Playlist *playlist : playlists) {
playlist->InvalidateDeletedSongs();
}
}
void PlaylistManager::RemoveDeletedSongs() {
for (Playlist *playlist : GetAllPlaylists()) {
const QList<Playlist*> playlists = GetAllPlaylists();
for (Playlist *playlist : playlists) {
playlist->RemoveDeletedSongs();
}

View File

@ -21,6 +21,8 @@
#include "config.h"
#include <utility>
#include <QWidget>
#include <QVariant>
#include <QIcon>
@ -113,7 +115,8 @@ void PlaylistSequence::Save() {
QIcon PlaylistSequence::AddDesaturatedIcon(const QIcon &icon) {
QIcon ret;
for (const QSize &size : icon.availableSizes()) {
const QList<QSize> sizes = icon.availableSizes();
for (const QSize &size : sizes) {
QPixmap on(icon.pixmap(size));
QPixmap off(DesaturatedPixmap(on));

View File

@ -21,6 +21,8 @@
#include "config.h"
#include <utility>
#include <QtConcurrent>
#include <QtAlgorithms>
#include <QList>
@ -72,7 +74,8 @@ void SongLoaderInserter::Load(Playlist *destination, int row, bool play_now, boo
songs_ << loader->songs();
}
else {
for (const QString &error : loader->errors()) {
const QStringList errors = loader->errors();
for (const QString &error : errors) {
emit Error(error);
}
}
@ -113,7 +116,8 @@ void SongLoaderInserter::LoadAudioCD(Playlist *destination, int row, bool play_n
if (loader->errors().isEmpty())
emit Error(tr("Error while loading audio CD."));
else {
for (const QString &error : loader->errors()) {
const QStringList errors = loader->errors();
for (const QString &error : errors) {
emit Error(error);
}
}
@ -129,7 +133,8 @@ void SongLoaderInserter::AudioCDTracksLoadFinished(SongLoader *loader) {
songs_ = loader->songs();
if (songs_.isEmpty()) {
for (const QString &error : loader->errors()) {
const QStringList errors = loader->errors();
for (const QString &error : errors) {
emit Error(error);
}
}
@ -177,7 +182,8 @@ void SongLoaderInserter::AsyncLoad() {
task_manager_->SetTaskProgress(async_load_id, ++async_progress);
if (res == SongLoader::Result::Error) {
for (const QString &error : loader->errors()) {
const QStringList errors = loader->errors();
for (const QString &error : errors) {
emit Error(error);
}
continue;

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <algorithm>
#include <utility>
#include <QObject>
#include <QByteArray>
@ -57,7 +58,7 @@ QNetworkReply *QobuzBaseRequest::CreateRequest(const QString &ressource_name, co
std::sort(params.begin(), params.end());
QUrlQuery url_query;
for (const Param &param : params) {
for (const Param &param : std::as_const(params)) {
url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(param.first)), QString::fromLatin1(QUrl::toPercentEncoding(param.second)));
}

View File

@ -132,9 +132,9 @@ void QobuzFavoriteRequest::AddFavorites(const FavoriteType type, const SongList
void QobuzFavoriteRequest::AddFavoritesRequest(const FavoriteType type, const QStringList &ids_list, const SongList &songs) {
ParamList params = ParamList() << Param(QStringLiteral("app_id"), app_id())
<< Param(QStringLiteral("user_auth_token"), user_auth_token())
<< Param(FavoriteMethod(type), ids_list.join(QLatin1Char(',')));
const ParamList params = ParamList() << Param(QStringLiteral("app_id"), app_id())
<< Param(QStringLiteral("user_auth_token"), user_auth_token())
<< Param(FavoriteMethod(type), ids_list.join(QLatin1Char(',')));
QUrlQuery url_query;
for (const Param &param : params) {
@ -227,9 +227,9 @@ void QobuzFavoriteRequest::RemoveFavorites(const FavoriteType type, const SongLi
void QobuzFavoriteRequest::RemoveFavoritesRequest(const FavoriteType type, const QStringList &ids_list, const SongList &songs) {
ParamList params = ParamList() << Param(QStringLiteral("app_id"), app_id())
<< Param(QStringLiteral("user_auth_token"), user_auth_token())
<< Param(FavoriteMethod(type), ids_list.join(QLatin1Char(',')));
const ParamList params = ParamList() << Param(QStringLiteral("app_id"), app_id())
<< Param(QStringLiteral("user_auth_token"), user_auth_token())
<< Param(FavoriteMethod(type), ids_list.join(QLatin1Char(',')));
QUrlQuery url_query;
for (const Param &param : params) {

View File

@ -19,6 +19,8 @@
#include "config.h"
#include <utility>
#include <QObject>
#include <QList>
#include <QByteArray>
@ -471,7 +473,7 @@ void QobuzRequest::ArtistsReplyReceived(QNetworkReply *reply, const int limit_re
return;
}
QJsonArray array_items = value_items.toArray();
const QJsonArray array_items = value_items.toArray();
if (array_items.isEmpty()) { // Empty array means no results
if (offset_requested == 0) no_results_ = true;
ArtistsFinishCheck();
@ -479,7 +481,7 @@ void QobuzRequest::ArtistsReplyReceived(QNetworkReply *reply, const int limit_re
}
int artists_received = 0;
for (const QJsonValueRef value_item : array_items) {
for (const QJsonValue &value_item : array_items) {
++artists_received;
@ -542,7 +544,7 @@ void QobuzRequest::ArtistsFinishCheck(const int limit, const int offset, const i
if (artists_requests_queue_.isEmpty() && artists_requests_active_ <= 0) { // Artist query is finished, get all albums for all artists.
// Get artist albums
QList<ArtistAlbumsRequest> requests = artist_albums_requests_pending_.values();
const QList<ArtistAlbumsRequest> requests = artist_albums_requests_pending_.values();
for (const ArtistAlbumsRequest &request : requests) {
AddArtistAlbumsRequest(request.artist);
}
@ -687,7 +689,7 @@ void QobuzRequest::AlbumsReceived(QNetworkReply *reply, const Artist &artist_req
AlbumsFinishCheck(artist_requested);
return;
}
QJsonArray array_items = value_items.toArray();
const QJsonArray array_items = value_items.toArray();
if (array_items.isEmpty()) {
if ((query_type_ == Type::FavouriteAlbums || query_type_ == Type::SearchAlbums) && offset_requested == 0) {
no_results_ = true;
@ -697,7 +699,7 @@ void QobuzRequest::AlbumsReceived(QNetworkReply *reply, const Artist &artist_req
}
int albums_received = 0;
for (const QJsonValueRef value_item : array_items) {
for (const QJsonValue &value_item : array_items) {
++albums_received;
@ -982,7 +984,7 @@ void QobuzRequest::SongsReceived(QNetworkReply *reply, const Artist &artist_requ
return;
}
QJsonArray array_items = value_items.toArray();
const QJsonArray array_items = value_items.toArray();
if (array_items.isEmpty()) {
if ((query_type_ == Type::FavouriteSongs || query_type_ == Type::SearchSongs) && offset_requested == 0) {
no_results_ = true;
@ -995,7 +997,7 @@ void QobuzRequest::SongsReceived(QNetworkReply *reply, const Artist &artist_requ
bool multidisc = false;
SongList songs;
int songs_received = 0;
for (const QJsonValueRef value_item : array_items) {
for (const QJsonValue &value_item : array_items) {
if (!value_item.isObject()) {
Error(QStringLiteral("Invalid Json reply, track is not a object."));
@ -1012,7 +1014,7 @@ void QobuzRequest::SongsReceived(QNetworkReply *reply, const Artist &artist_requ
songs << song;
}
for (Song song : songs) {
for (Song song : std::as_const(songs)) {
if (compilation) song.set_compilation_detected(true);
if (!multidisc) song.set_disc(0);
songs_.insert(song.song_id(), song);

View File

@ -19,6 +19,7 @@
#include "config.h"
#include <utility>
#include <memory>
#include <QObject>
@ -763,7 +764,7 @@ void QobuzService::LoginError(const QString &error, const QVariant &debug) {
if (!error.isEmpty()) login_errors_ << error;
QString error_html;
for (const QString &e : login_errors_) {
for (const QString &e : std::as_const(login_errors_)) {
qLog(Error) << "Qobuz:" << e;
error_html += e + QStringLiteral("<br />");
}

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <algorithm>
#include <utility>
#include <QObject>
#include <QMimeDatabase>
@ -122,7 +123,7 @@ void QobuzStreamURLRequest::GetStreamURL() {
QString data_to_sign;
data_to_sign += QLatin1String("trackgetFileUrl");
for (const Param &param : params_to_sign) {
for (const Param &param : std::as_const(params_to_sign)) {
data_to_sign += param.first + param.second;
}
data_to_sign += QString::number(timestamp);
@ -192,7 +193,7 @@ void QobuzStreamURLRequest::StreamURLReceived() {
Song::FileType filetype(Song::FileType::Unknown);
QMimeDatabase mimedb;
QStringList suffixes = mimedb.mimeTypeForName(mimetype).suffixes();
const QStringList suffixes = mimedb.mimeTypeForName(mimetype).suffixes();
for (const QString &suffix : suffixes) {
filetype = Song::FiletypeByExtension(suffix);
if (filetype != Song::FileType::Unknown) break;

View File

@ -86,10 +86,10 @@ void RadioParadiseService::GetChannelsReply(QNetworkReply *reply, const int task
emit NewChannels();
return;
}
QJsonArray array_channels = object[QLatin1String("channels")].toArray();
const QJsonArray array_channels = object[QLatin1String("channels")].toArray();
RadioChannelList channels;
for (const QJsonValueRef value_channel : array_channels) {
for (const QJsonValue &value_channel : array_channels) {
if (!value_channel.isObject()) continue;
QJsonObject obj_channel = value_channel.toObject();
if (!obj_channel.contains(QLatin1String("chan_name")) || !obj_channel.contains(QLatin1String("streams"))) {
@ -100,8 +100,8 @@ void RadioParadiseService::GetChannelsReply(QNetworkReply *reply, const int task
if (!value_streams.isArray()) {
continue;
}
QJsonArray array_streams = obj_channel[QLatin1String("streams")].toArray();
for (const QJsonValueRef value_stream : array_streams) {
const QJsonArray array_streams = obj_channel[QLatin1String("streams")].toArray();
for (const QJsonValue &value_stream : array_streams) {
if (!value_stream.isObject()) continue;
QJsonObject obj_stream = value_stream.toObject();
if (!obj_stream.contains(QLatin1String("label")) || !obj_stream.contains(QLatin1String("url"))) {

View File

@ -96,7 +96,7 @@ RadioService *RadioServices::ServiceBySource(const Song::Source source) const {
void RadioServices::ReloadSettings() {
QList<RadioService*> services = services_.values();
const QList<RadioService*> services = services_.values();
for (RadioService *service : services) {
service->ReloadSettings();
}
@ -116,7 +116,7 @@ void RadioServices::RefreshChannels() {
model_->Reset();
backend_->DeleteChannelsAsync();
QList<RadioService*> services = services_.values();
const QList<RadioService*> services = services_.values();
for (RadioService *service : services) {
service->GetChannels();
}

View File

@ -17,6 +17,8 @@
*
*/
#include <utility>
#include <QWidget>
#include <QMimeData>
#include <QDesktopServices>
@ -154,7 +156,7 @@ void RadioView::Homepage() {
}
}
for (const QUrl &url : urls) {
for (const QUrl &url : std::as_const(urls)) {
QDesktopServices::openUrl(url);
}
@ -173,7 +175,7 @@ void RadioView::Donate() {
}
}
for (const QUrl &url : urls) {
for (const QUrl &url : std::as_const(urls)) {
QDesktopServices::openUrl(url);
}

View File

@ -17,6 +17,8 @@
*
*/
#include <utility>
#include <QObject>
#include <QString>
#include <QUrl>
@ -92,10 +94,10 @@ void SomaFMService::GetChannelsReply(QNetworkReply *reply, const int task_id) {
emit NewChannels();
return;
}
QJsonArray array_channels = object[QLatin1String("channels")].toArray();
const QJsonArray array_channels = object[QLatin1String("channels")].toArray();
RadioChannelList channels;
for (const QJsonValueRef value_channel : array_channels) {
for (const QJsonValue &value_channel : array_channels) {
if (!value_channel.isObject()) continue;
QJsonObject obj_channel = value_channel.toObject();
if (!obj_channel.contains(QLatin1String("title")) || !obj_channel.contains(QLatin1String("image"))) {
@ -103,8 +105,8 @@ void SomaFMService::GetChannelsReply(QNetworkReply *reply, const int task_id) {
}
QString name = obj_channel[QLatin1String("title")].toString();
QString image = obj_channel[QLatin1String("image")].toString();
QJsonArray playlists = obj_channel[QLatin1String("playlists")].toArray();
for (const QJsonValueRef playlist : playlists) {
const QJsonArray playlists = obj_channel[QLatin1String("playlists")].toArray();
for (const QJsonValue &playlist : playlists) {
if (!playlist.isObject()) continue;
QJsonObject obj_playlist = playlist.toObject();
if (!obj_playlist.contains(QLatin1String("url")) || !obj_playlist.contains(QLatin1String("quality"))) {
@ -129,7 +131,7 @@ void SomaFMService::GetChannelsReply(QNetworkReply *reply, const int task_id) {
emit NewChannels();
}
else {
for (const RadioChannel &channel : channels) {
for (const RadioChannel &channel : std::as_const(channels)) {
GetStreamUrl(task_id, channel);
}
}

View File

@ -19,6 +19,7 @@
#include "config.h"
#include <utility>
#include <memory>
#include <QList>
@ -98,8 +99,8 @@ void AudioScrobbler::ReloadSettings() {
settings_->ReloadSettings();
QList<ScrobblerServicePtr> services = services_.values();
for (ScrobblerServicePtr service : services) {
const QList<ScrobblerServicePtr> services = services_.values();
for (ScrobblerServicePtr service : std::as_const(services)) {
service->ReloadSettings();
}
@ -131,7 +132,7 @@ void AudioScrobbler::UpdateNowPlaying(const Song &song) {
qLog(Debug) << "Sending now playing for song" << song.artist() << song.album() << song.title();
QList<ScrobblerServicePtr> services = GetAll();
const QList<ScrobblerServicePtr> services = GetAll();
for (ScrobblerServicePtr service : services) {
if (!service->enabled()) continue;
service->UpdateNowPlaying(song);
@ -141,7 +142,7 @@ void AudioScrobbler::UpdateNowPlaying(const Song &song) {
void AudioScrobbler::ClearPlaying() {
QList<ScrobblerServicePtr> services = GetAll();
const QList<ScrobblerServicePtr> services = GetAll();
for (ScrobblerServicePtr service : services) {
if (!service->enabled()) continue;
service->ClearPlaying();
@ -155,7 +156,7 @@ void AudioScrobbler::Scrobble(const Song &song, const qint64 scrobble_point) {
qLog(Debug) << "Scrobbling song" << song.artist() << song.album() << song.title() << "at" << scrobble_point;
QList<ScrobblerServicePtr> services = GetAll();
const QList<ScrobblerServicePtr> services = GetAll();
for (ScrobblerServicePtr service : services) {
if (!service->enabled()) continue;
service->Scrobble(song);
@ -165,7 +166,7 @@ void AudioScrobbler::Scrobble(const Song &song, const qint64 scrobble_point) {
void AudioScrobbler::Love() {
QList<ScrobblerServicePtr> services = GetAll();
const QList<ScrobblerServicePtr> services = GetAll();
for (ScrobblerServicePtr service : services) {
if (!service->enabled() || !service->authenticated()) continue;
service->Love();
@ -175,7 +176,7 @@ void AudioScrobbler::Love() {
void AudioScrobbler::Submit() {
QList<ScrobblerServicePtr> services = GetAll();
const QList<ScrobblerServicePtr> services = GetAll();
for (ScrobblerServicePtr service : services) {
if (!service->enabled() || !service->authenticated() || service->submitted()) continue;
service->StartSubmit();
@ -185,7 +186,7 @@ void AudioScrobbler::Submit() {
void AudioScrobbler::WriteCache() {
QList<ScrobblerServicePtr> services = GetAll();
const QList<ScrobblerServicePtr> services = GetAll();
for (ScrobblerServicePtr service : services) {
if (!service->enabled()) continue;
service->WriteCache();

View File

@ -116,7 +116,7 @@ QNetworkReply *LastFMImport::CreateRequest(const ParamList &request_params) {
std::sort(params.begin(), params.end());
QUrlQuery url_query;
for (const Param &param : params) {
for (const Param &param : std::as_const(params)) {
url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(param.first)), QString::fromLatin1(QUrl::toPercentEncoding(param.second)));
}
@ -351,9 +351,9 @@ void LastFMImport::GetRecentTracksRequestFinished(QNetworkReply *reply, const in
}
else {
QJsonArray array_track = json_obj[QLatin1String("track")].toArray();
const QJsonArray array_track = json_obj[QLatin1String("track")].toArray();
for (const QJsonValueRef value_track : array_track) {
for (const QJsonValue &value_track : array_track) {
++lastplayed_received_;

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <algorithm>
#include <utility>
#include <QCoreApplication>
#include <QtGlobal>
@ -289,7 +290,7 @@ void ListenBrainzScrobbler::RequestAccessToken(const QUrl &redirect_url, const Q
}
QUrlQuery url_query;
for (const Param &param : params) {
for (const Param &param : std::as_const(params)) {
url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(param.first)), QString::fromLatin1(QUrl::toPercentEncoding(param.second)));
}
@ -412,7 +413,7 @@ QJsonObject ListenBrainzScrobbler::JsonTrackMetadata(const ScrobbleMetadata &met
}
if (!artist_mbids_list.isEmpty()) {
QJsonArray artist_mbids_array;
for (const QString &musicbrainz_artist_id : artist_mbids_list) {
for (const QString &musicbrainz_artist_id : std::as_const(artist_mbids_list)) {
if (!musicbrainz_artist_id.isEmpty() && !artist_mbids_array.contains(musicbrainz_artist_id)) {
artist_mbids_array.append(musicbrainz_artist_id);
}
@ -545,7 +546,7 @@ void ListenBrainzScrobbler::Submit() {
QJsonArray array;
ScrobblerCacheItemPtrList cache_items_sent;
ScrobblerCacheItemPtrList all_cache_items = cache_->List();
const ScrobblerCacheItemPtrList all_cache_items = cache_->List();
for (ScrobblerCacheItemPtr cache_item : all_cache_items) {
if (cache_item->sent) continue;
if (cache_item->error && cache_items_sent.count() > 0) break;

View File

@ -19,6 +19,7 @@
#include "config.h"
#include <utility>
#include <functional>
#include <chrono>
#include <memory>
@ -108,12 +109,12 @@ void ScrobblerCache::ReadCache() {
qLog(Error) << "Scrobbler cache JSON tracks is not an array.";
return;
}
QJsonArray json_array = json_tracks.toArray();
const QJsonArray json_array = json_tracks.toArray();
if (json_array.isEmpty()) {
return;
}
for (const QJsonValueRef value : json_array) {
for (const QJsonValue &value : json_array) {
if (!value.isObject()) {
qLog(Error) << "Scrobbler cache JSON tracks array value is not an object.";
qLog(Debug) << value;
@ -203,7 +204,7 @@ void ScrobblerCache::WriteCache() {
}
QJsonArray array;
for (ScrobblerCacheItemPtr cache_item : scrobbler_cache_) {
for (ScrobblerCacheItemPtr cache_item : std::as_const(scrobbler_cache_)) {
QJsonObject object;
object.insert(QLatin1String("timestamp"), QJsonValue::fromVariant(cache_item->timestamp));
object.insert(QLatin1String("artist"), QJsonValue::fromVariant(cache_item->metadata.artist));

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <algorithm>
#include <utility>
#include <QApplication>
#include <QDesktopServices>
@ -279,7 +280,8 @@ void ScrobblingAPI20::RequestSession(const QString &token) {
session_url_query.addQueryItem(QStringLiteral("method"), QStringLiteral("auth.getSession"));
session_url_query.addQueryItem(QStringLiteral("token"), token);
QString data_to_sign;
for (const Param &param : session_url_query.queryItems()) {
const ParamList params = session_url_query.queryItems();
for (const Param &param : params) {
data_to_sign += param.first + param.second;
}
data_to_sign += QLatin1String(kSecret);
@ -360,7 +362,7 @@ QNetworkReply *ScrobblingAPI20::CreateRequest(const ParamList &request_params) {
QUrlQuery url_query;
QString data_to_sign;
for (const Param &param : params) {
for (const Param &param : std::as_const(params)) {
EncodedParam encoded_param(QUrl::toPercentEncoding(param.first), QUrl::toPercentEncoding(param.second));
url_query.addQueryItem(QString::fromLatin1(encoded_param.first), QString::fromLatin1(encoded_param.second));
data_to_sign += param.first + param.second;
@ -493,7 +495,7 @@ void ScrobblingAPI20::Submit() {
ParamList params = ParamList() << Param(QStringLiteral("method"), QStringLiteral("track.scrobble"));
int i = 0;
ScrobblerCacheItemPtrList all_cache_items = cache_->List();
const ScrobblerCacheItemPtrList all_cache_items = cache_->List();
ScrobblerCacheItemPtrList cache_items_sent;
for (ScrobblerCacheItemPtr cache_item : all_cache_items) {
if (cache_item->sent) continue;
@ -623,7 +625,7 @@ void ScrobblingAPI20::ScrobbleRequestFinished(QNetworkReply *reply, ScrobblerCac
return;
}
for (const QJsonValueRef value : array_scrobble) {
for (const QJsonValue &value : std::as_const(array_scrobble)) {
if (!value.isObject()) {
Error(QStringLiteral("Json scrobbles scrobble array value is not an object."));

View File

@ -21,6 +21,8 @@
#include "config.h"
#include <utility>
#include <QApplication>
#include <QWidget>
#include <QStyleFactory>
@ -91,7 +93,8 @@ AppearanceSettingsPage::AppearanceSettingsPage(SettingsDialog *dialog, QWidget *
setWindowIcon(IconLoader::Load(QStringLiteral("view-media-visualization"), true, 0, 32));
ui_->combobox_style->addItem(QStringLiteral("default"), QStringLiteral("default"));
for (const QString &style : QStyleFactory::keys()) {
const QStringList styles = QStyleFactory::keys();
for (const QString &style : styles) {
ui_->combobox_style->addItem(style, style);
}

View File

@ -19,6 +19,8 @@
#include "config.h"
#include <utility>
#include <QtGlobal>
#include <QWidget>
#include <QSettings>
@ -308,7 +310,8 @@ void BackendSettingsPage::Load_Output(QString output, QVariant device) {
if (output.isEmpty()) output = engine()->DefaultOutput();
ui_->combobox_output->clear();
for (const EngineBase::OutputDetails &o : engine()->GetOutputsList()) {
const EngineBase::OutputDetailsList outputs = engine()->GetOutputsList();
for (const EngineBase::OutputDetails &o : outputs) {
ui_->combobox_output->addItem(IconLoader::Load(o.iconname), o.description, QVariant::fromValue(o));
}
if (ui_->combobox_output->count() > 1) ui_->combobox_output->setEnabled(true);
@ -370,9 +373,11 @@ void BackendSettingsPage::Load_Device(const QString &output, const QVariant &dev
#endif
ui_->combobox_device->addItem(IconLoader::Load(QStringLiteral("soundcard")), QLatin1String(kOutputAutomaticallySelect), QVariant());
for (DeviceFinder *f : dialog()->app()->device_finders()->ListFinders()) {
const QList<DeviceFinder*> device_finders = dialog()->app()->device_finders()->ListFinders();
for (DeviceFinder *f : device_finders) {
if (!f->outputs().contains(output)) continue;
for (const EngineDevice &d : f->ListDevices()) {
const EngineDeviceList engine_devices = f->ListDevices();
for (const EngineDevice &d : engine_devices) {
devices++;
ui_->combobox_device->addItem(IconLoader::Load(d.iconname), d.description, d.value);
if (d.value == device) { df_device = d; }

View File

@ -22,6 +22,7 @@
#include "config.h"
#include <algorithm>
#include <utility>
#include <QVariant>
#include <QString>
@ -80,12 +81,12 @@ BehaviourSettingsPage::BehaviourSettingsPage(SettingsDialog *dialog, QWidget *pa
// Populate the language combo box. We do this by looking at all the compiled in translations.
QDir dir1(QStringLiteral(":/translations/"));
QDir dir2(QStringLiteral(TRANSLATIONS_DIR));
QStringList codes(dir1.entryList(QStringList() << QStringLiteral("*.qm")));
QStringList codes = dir1.entryList(QStringList() << QStringLiteral("*.qm"));
if (dir2.exists()) {
codes << dir2.entryList(QStringList() << QStringLiteral("*.qm"));
}
QRegularExpression lang_re(QStringLiteral("^strawberry_(.*).qm$"));
for (const QString &filename : codes) {
for (const QString &filename : std::as_const(codes)) {
QRegularExpressionMatch re_match = lang_re.match(filename);

View File

@ -21,6 +21,7 @@
#include "config.h"
#include <utility>
#include <limits>
#include <QStandardPaths>
@ -136,7 +137,8 @@ void CollectionSettingsPage::Load() {
}
ui_->list->model()->removeRows(0, ui_->list->model()->rowCount());
for (const QString &path : collection_directory_model_->paths()) {
const QStringList paths = collection_directory_model_->paths();
for (const QString &path : paths) {
collectionsettings_directory_model_->AddDirectory(path);
}
@ -229,13 +231,15 @@ void CollectionSettingsPage::Save() {
s.endGroup();
for (const CollectionDirectory &dir : collection_directory_model_->directories()) {
const QMap<int, CollectionDirectory> dirs = collection_directory_model_->directories();
for (const CollectionDirectory &dir : dirs) {
if (!collectionsettings_directory_model_->paths().contains(dir.path)) {
collection_backend_->RemoveDirectoryAsync(dir);
}
}
for (const QString &path : collectionsettings_directory_model_->paths()) {
const QStringList paths = collectionsettings_directory_model_->paths();
for (const QString &path : paths) {
if (!collection_directory_model_->paths().contains(path)) {
collection_backend_->AddDirectoryAsync(path);
}

View File

@ -56,7 +56,7 @@ void SettingsPage::Init(QWidget *ui_widget) {
sliders_.clear();
lineedits_.clear();
QList<QWidget*> list = ui_widget_->findChildren<QWidget*>(QString(), Qt::FindChildrenRecursively);
const QList<QWidget*> list = ui_widget_->findChildren<QWidget*>(QString(), Qt::FindChildrenRecursively);
for (QWidget *w : list) {
if (QCheckBox *checkbox = qobject_cast<QCheckBox*>(w)) {
checkboxes_ << qMakePair(checkbox, checkbox->checkState());

View File

@ -21,6 +21,7 @@
#include "config.h"
#include <algorithm>
#include <utility>
#include <memory>
#include <QWizardPage>
@ -183,7 +184,7 @@ void SmartPlaylistQueryWizardPlugin::SetGenerator(PlaylistGeneratorPtr g) {
qDeleteAll(search_page_->terms_);
search_page_->terms_.clear();
for (const SmartPlaylistSearchTerm &term : search.terms_) {
for (const SmartPlaylistSearchTerm &term : std::as_const(search.terms_)) {
AddSearchTerm();
search_page_->terms_.last()->SetTerm(term);
}
@ -290,7 +291,7 @@ SmartPlaylistSearch SmartPlaylistQueryWizardPlugin::MakeSearch() const {
ret.search_type_ = static_cast<SmartPlaylistSearch::SearchType>(search_page_->ui_->type->currentIndex());
// Search terms
for (SmartPlaylistSearchTermWidget *widget : search_page_->terms_) {
for (SmartPlaylistSearchTermWidget *widget : std::as_const(search_page_->terms_)) {
SmartPlaylistSearchTerm term = widget->Term();
if (term.is_valid()) ret.terms_ << term;
}

View File

@ -149,7 +149,8 @@ void SmartPlaylistSearchTermWidget::FieldChanged(int index) {
// Populate the operator combo box
if (type != current_field_type_) {
ui_->op->clear();
for (const SmartPlaylistSearchTerm::Operator op : SmartPlaylistSearchTerm::OperatorsForType(type)) {
const SmartPlaylistSearchTerm::OperatorList operators = SmartPlaylistSearchTerm::OperatorsForType(type);
for (const SmartPlaylistSearchTerm::Operator op : operators) {
const int i = ui_->op->count();
ui_->op->addItem(SmartPlaylistSearchTerm::OperatorText(type, op));
ui_->op->setItemData(i, QVariant::fromValue(op));

View File

@ -46,10 +46,8 @@ SpotifyBaseRequest::SpotifyBaseRequest(SpotifyService *service, NetworkAccessMan
QNetworkReply *SpotifyBaseRequest::CreateRequest(const QString &ressource_name, const ParamList &params_provided) {
ParamList params = ParamList() << params_provided;
QUrlQuery url_query;
for (const Param &param : params) {
for (const Param &param : params_provided) {
url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(param.first)), QString::fromLatin1(QUrl::toPercentEncoding(param.second)));
}

View File

@ -19,6 +19,8 @@
#include "config.h"
#include <utility>
#include <QObject>
#include <QByteArray>
#include <QString>
@ -481,7 +483,7 @@ void SpotifyRequest::ArtistsReplyReceived(QNetworkReply *reply, const int limit_
return;
}
QJsonArray array_items = value_items.toArray();
const QJsonArray array_items = value_items.toArray();
if (array_items.isEmpty()) { // Empty array means no results
if (offset_requested == 0) no_results_ = true;
ArtistsFinishCheck();
@ -489,7 +491,7 @@ void SpotifyRequest::ArtistsReplyReceived(QNetworkReply *reply, const int limit_
}
int artists_received = 0;
for (const QJsonValueRef value_item : array_items) {
for (const QJsonValue &value_item : array_items) {
++artists_received;
@ -547,7 +549,7 @@ void SpotifyRequest::ArtistsFinishCheck(const int limit, const int offset, const
if (artists_requests_queue_.isEmpty() && artists_requests_active_ <= 0) { // Artist query is finished, get all albums for all artists.
// Get artist albums
QList<ArtistAlbumsRequest> requests = artist_albums_requests_pending_.values();
const QList<ArtistAlbumsRequest> requests = artist_albums_requests_pending_.values();
for (const ArtistAlbumsRequest &request : requests) {
AddArtistAlbumsRequest(request.artist);
}
@ -670,7 +672,7 @@ void SpotifyRequest::AlbumsReceived(QNetworkReply *reply, const Artist &artist_a
AlbumsFinishCheck(artist_artist);
return;
}
QJsonArray array_items = value_items.toArray();
const QJsonArray array_items = value_items.toArray();
if (array_items.isEmpty()) {
if ((type_ == Type::FavouriteAlbums || type_ == Type::SearchAlbums || (type_ == Type::SearchSongs && fetchalbums_)) && offset_requested == 0) {
no_results_ = true;
@ -680,7 +682,7 @@ void SpotifyRequest::AlbumsReceived(QNetworkReply *reply, const Artist &artist_a
}
int albums_received = 0;
for (const QJsonValueRef value_item : array_items) {
for (const QJsonValue &value_item : array_items) {
++albums_received;
@ -727,9 +729,9 @@ void SpotifyRequest::AlbumsReceived(QNetworkReply *reply, const Artist &artist_a
album.album = obj_item[QLatin1String("name")].toString();
if (obj_item.contains(QLatin1String("artists")) && obj_item[QLatin1String("artists")].isArray()) {
QJsonArray array_artists = obj_item[QLatin1String("artists")].toArray();
const QJsonArray array_artists = obj_item[QLatin1String("artists")].toArray();
bool artist_matches = false;
for (const QJsonValueRef value : array_artists) {
for (const QJsonValue &value : array_artists) {
if (!value.isObject()) {
continue;
}
@ -755,8 +757,8 @@ void SpotifyRequest::AlbumsReceived(QNetworkReply *reply, const Artist &artist_a
}
if (obj_item.contains(QLatin1String("images")) && obj_item[QLatin1String("images")].isArray()) {
QJsonArray array_images = obj_item[QLatin1String("images")].toArray();
for (const QJsonValueRef value : array_images) {
const QJsonArray array_images = obj_item[QLatin1String("images")].toArray();
for (const QJsonValue &value : array_images) {
if (!value.isObject()) {
continue;
}
@ -774,11 +776,11 @@ void SpotifyRequest::AlbumsReceived(QNetworkReply *reply, const Artist &artist_a
if (obj_item.contains(QLatin1String("tracks")) && obj_item[QLatin1String("tracks")].isObject()) {
QJsonObject obj_tracks = obj_item[QLatin1String("tracks")].toObject();
if (obj_tracks.contains(QLatin1String("items")) && obj_tracks[QLatin1String("items")].isArray()) {
QJsonArray array_tracks = obj_tracks[QLatin1String("items")].toArray();
const QJsonArray array_tracks = obj_tracks[QLatin1String("items")].toArray();
bool compilation = false;
bool multidisc = false;
SongList songs;
for (const QJsonValueRef value : array_tracks) {
for (const QJsonValue &value : array_tracks) {
if (!value.isObject()) {
continue;
}
@ -793,7 +795,7 @@ void SpotifyRequest::AlbumsReceived(QNetworkReply *reply, const Artist &artist_a
if (song.is_compilation()) compilation = true;
songs << song;
}
for (Song song : songs) {
for (Song song : std::as_const(songs)) {
if (compilation) song.set_compilation_detected(true);
if (!multidisc) song.set_disc(0);
songs_.insert(song.song_id(), song);
@ -980,7 +982,7 @@ void SpotifyRequest::SongsReceived(QNetworkReply *reply, const Artist &artist, c
return;
}
QJsonArray array_items = json_value.toArray();
const QJsonArray array_items = json_value.toArray();
if (array_items.isEmpty()) {
if ((type_ == Type::FavouriteSongs || type_ == Type::SearchSongs) && offset_requested == 0) {
no_results_ = true;
@ -993,7 +995,7 @@ void SpotifyRequest::SongsReceived(QNetworkReply *reply, const Artist &artist, c
bool multidisc = false;
SongList songs;
int songs_received = 0;
for (const QJsonValueRef value_item : array_items) {
for (const QJsonValue &value_item : array_items) {
if (!value_item.isObject()) {
Error(QStringLiteral("Invalid Json reply, track is not a object."));
@ -1018,7 +1020,7 @@ void SpotifyRequest::SongsReceived(QNetworkReply *reply, const Artist &artist, c
songs << song;
}
for (Song song : songs) {
for (Song song : std::as_const(songs)) {
if (compilation) song.set_compilation_detected(true);
if (!multidisc) song.set_disc(0);
songs_.insert(song.song_id(), song);
@ -1087,8 +1089,8 @@ void SpotifyRequest::ParseSong(Song &song, const QJsonObject &json_obj, const Ar
QString artist_id;
QString artist_title;
if (json_obj.contains(QLatin1String("artists")) && json_obj[QLatin1String("artists")].isArray()) {
QJsonArray array_artists = json_obj[QLatin1String("artists")].toArray();
for (const QJsonValueRef value_artist : array_artists) {
const QJsonArray array_artists = json_obj[QLatin1String("artists")].toArray();
for (const QJsonValue &value_artist : array_artists) {
if (!value_artist.isObject()) continue;
QJsonObject obj_artist = value_artist.toObject();
if (!obj_artist.contains(QLatin1String("type")) || !obj_artist.contains(QLatin1String("id")) || !obj_artist.contains(QLatin1String("name"))) {
@ -1109,8 +1111,8 @@ void SpotifyRequest::ParseSong(Song &song, const QJsonObject &json_obj, const Ar
album_id = obj_album[QLatin1String("id")].toString();
album_title = obj_album[QLatin1String("name")].toString();
if (obj_album.contains(QLatin1String("images")) && obj_album[QLatin1String("images")].isArray()) {
QJsonArray array_images = obj_album[QLatin1String("images")].toArray();
for (const QJsonValueRef value : array_images) {
const QJsonArray array_images = obj_album[QLatin1String("images")].toArray();
for (const QJsonValue &value : array_images) {
if (!value.isObject()) {
continue;
}

View File

@ -19,6 +19,7 @@
#include "config.h"
#include <utility>
#include <memory>
#include <chrono>
@ -375,7 +376,7 @@ void SpotifyService::RequestAccessToken(const QString &code, const QUrl &redirec
}
QUrlQuery url_query;
for (const Param &param : params) {
for (const Param &param : std::as_const(params)) {
url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(param.first)), QString::fromLatin1(QUrl::toPercentEncoding(param.second)));
}
@ -735,7 +736,7 @@ void SpotifyService::LoginError(const QString &error, const QVariant &debug) {
if (!error.isEmpty()) login_errors_ << error;
QString error_html;
for (const QString &e : login_errors_) {
for (const QString &e : std::as_const(login_errors_)) {
qLog(Error) << "Spotify:" << e;
error_html += e + QLatin1String("<br />");
}

View File

@ -19,6 +19,8 @@
#include "config.h"
#include <utility>
#include <QtGlobal>
#include <QObject>
#include <QByteArray>
@ -73,7 +75,7 @@ QUrl SubsonicBaseRequest::CreateUrl(const QUrl &server_url, const SubsonicSettin
}
QUrlQuery url_query;
for (const Param &param : params) {
for (const Param &param : std::as_const(params)) {
url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(param.first)), QString::fromLatin1(QUrl::toPercentEncoding(param.second)));
}

View File

@ -239,7 +239,7 @@ void SubsonicRequest::AlbumsReplyReceived(QNetworkReply *reply, const int offset
Error(QStringLiteral("Json album is not an array."), json_album);
AlbumsFinishCheck(offset_requested, size_requested);
}
QJsonArray array_albums = json_album.toArray();
const QJsonArray array_albums = json_album.toArray();
if (array_albums.isEmpty()) {
if (offset_requested == 0) no_results_ = true;
@ -248,7 +248,7 @@ void SubsonicRequest::AlbumsReplyReceived(QNetworkReply *reply, const int offset
}
int albums_received = 0;
for (const QJsonValueRef value_album : array_albums) {
for (const QJsonValue &value_album : array_albums) {
++albums_received;
@ -425,7 +425,7 @@ void SubsonicRequest::AlbumSongsReplyReceived(QNetworkReply *reply, const QStrin
SongsFinishCheck();
return;
}
QJsonArray array_songs = json_song.toArray();
const QJsonArray array_songs = json_song.toArray();
qint64 created = 0;
if (obj_album.contains(QLatin1String("created"))) {
@ -435,7 +435,7 @@ void SubsonicRequest::AlbumSongsReplyReceived(QNetworkReply *reply, const QStrin
bool compilation = false;
bool multidisc = false;
SongList songs;
for (const QJsonValueRef value_song : array_songs) {
for (const QJsonValue &value_song : array_songs) {
if (!value_song.isObject()) {
Error(QStringLiteral("Invalid Json reply, track is not a object."));
@ -451,7 +451,7 @@ void SubsonicRequest::AlbumSongsReplyReceived(QNetworkReply *reply, const QStrin
songs << song;
}
for (Song song : songs) {
for (Song song : std::as_const(songs)) {
if (compilation) song.set_compilation_detected(true);
if (!multidisc) {
song.set_disc(0);
@ -641,7 +641,7 @@ QString SubsonicRequest::ParseSong(Song &song, const QJsonObject &json_obj, cons
Song::FileType filetype(Song::FileType::Stream);
if (!mimetype.isEmpty()) {
QMimeDatabase mimedb;
QStringList suffixes = mimedb.mimeTypeForName(mimetype).suffixes();
const QStringList suffixes = mimedb.mimeTypeForName(mimetype).suffixes();
for (const QString &suffix : suffixes) {
filetype = Song::FiletypeByExtension(suffix);
if (filetype != Song::FileType::Unknown) break;

View File

@ -19,6 +19,7 @@
#include "config.h"
#include <utility>
#include <memory>
#include <QtGlobal>
@ -169,7 +170,7 @@ void SubsonicService::SendPingWithCredentials(QUrl url, const QString &username,
}
QUrlQuery url_query(url.query());
for (const Param &param : params) {
for (const Param &param : std::as_const(params)) {
url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(param.first)), QString::fromLatin1(QUrl::toPercentEncoding(param.second)));
}
@ -449,7 +450,7 @@ void SubsonicService::PingError(const QString &error, const QVariant &debug) {
if (!error.isEmpty()) errors_ << error;
QString error_html;
for (const QString &e : errors_) {
for (const QString &e : std::as_const(errors_)) {
qLog(Error) << "Subsonic:" << e;
error_html += e + QLatin1String("<br />");
}

View File

@ -47,8 +47,8 @@ TidalBaseRequest::TidalBaseRequest(TidalService *service, SharedPtr<NetworkAcces
QNetworkReply *TidalBaseRequest::CreateRequest(const QString &ressource_name, const ParamList &params_provided) {
ParamList params = ParamList() << params_provided
<< Param(QStringLiteral("countryCode"), country_code());
const ParamList params = ParamList() << params_provided
<< Param(QStringLiteral("countryCode"), country_code());
QUrlQuery url_query;
for (const Param &param : params) {

View File

@ -134,8 +134,8 @@ void TidalFavoriteRequest::AddFavorites(const FavoriteType type, const SongList
void TidalFavoriteRequest::AddFavoritesRequest(const FavoriteType type, const QStringList &id_list, const SongList &songs) {
ParamList params = ParamList() << Param(QStringLiteral("countryCode"), country_code())
<< Param(FavoriteMethod(type), id_list.join(QLatin1Char(',')));
const ParamList params = ParamList() << Param(QStringLiteral("countryCode"), country_code())
<< Param(FavoriteMethod(type), id_list.join(QLatin1Char(',')));
QUrlQuery url_query;
for (const Param &param : params) {
@ -204,7 +204,7 @@ void TidalFavoriteRequest::RemoveSongs(const SongList &songs) {
void TidalFavoriteRequest::RemoveSongs(const SongMap &songs) {
SongList songs_list = songs.values();
const SongList songs_list = songs.values();
for (const Song &song : songs_list) {
RemoveFavoritesRequest(FavoriteType::Songs, song.song_id(), SongList() << song);
}
@ -235,7 +235,7 @@ void TidalFavoriteRequest::RemoveFavorites(const FavoriteType type, const SongLi
}
}
QStringList ids = songs_map.uniqueKeys();
const QStringList ids = songs_map.uniqueKeys();
for (const QString &id : ids) {
RemoveFavoritesRequest(type, id, songs_map.values(id));
}
@ -244,7 +244,7 @@ void TidalFavoriteRequest::RemoveFavorites(const FavoriteType type, const SongLi
void TidalFavoriteRequest::RemoveFavoritesRequest(const FavoriteType type, const QString &id, const SongList &songs) {
ParamList params = ParamList() << Param(QStringLiteral("countryCode"), country_code());
const ParamList params = ParamList() << Param(QStringLiteral("countryCode"), country_code());
QUrlQuery url_query;
for (const Param &param : params) {

View File

@ -19,6 +19,8 @@
#include "config.h"
#include <utility>
#include <QObject>
#include <QList>
#include <QByteArray>
@ -470,14 +472,14 @@ void TidalRequest::ArtistsReplyReceived(QNetworkReply *reply, const int limit_re
return;
}
QJsonArray array_items = value_items.toArray();
const QJsonArray array_items = value_items.toArray();
if (array_items.isEmpty()) { // Empty array means no results
ArtistsFinishCheck();
return;
}
int artists_received = 0;
for (const QJsonValueRef value_item : array_items) {
for (const QJsonValue &value_item : array_items) {
++artists_received;
@ -540,7 +542,7 @@ void TidalRequest::ArtistsFinishCheck(const int limit, const int offset, const i
if (artists_requests_queue_.isEmpty() && artists_requests_active_ <= 0) { // Artist query is finished, get all albums for all artists.
// Get artist albums
QList<ArtistAlbumsRequest> requests = artist_albums_requests_pending_.values();
const QList<ArtistAlbumsRequest> requests = artist_albums_requests_pending_.values();
for (const ArtistAlbumsRequest &request : requests) {
AddArtistAlbumsRequest(request.artist);
}
@ -652,14 +654,14 @@ void TidalRequest::AlbumsReceived(QNetworkReply *reply, const Artist &artist_req
AlbumsFinishCheck(artist_requested);
return;
}
QJsonArray array_items = value_items.toArray();
const QJsonArray array_items = value_items.toArray();
if (array_items.isEmpty()) {
AlbumsFinishCheck(artist_requested);
return;
}
int albums_received = 0;
for (const QJsonValueRef value_item : array_items) {
for (const QJsonValue &value_item : array_items) {
++albums_received;
@ -930,7 +932,7 @@ void TidalRequest::SongsReceived(QNetworkReply *reply, const Artist &artist, con
return;
}
QJsonArray array_items = json_value.toArray();
const QJsonArray array_items = json_value.toArray();
if (array_items.isEmpty()) {
SongsFinishCheck(artist, album, limit_requested, offset_requested, songs_total, 0);
return;
@ -940,7 +942,7 @@ void TidalRequest::SongsReceived(QNetworkReply *reply, const Artist &artist, con
bool multidisc = false;
SongList songs;
int songs_received = 0;
for (const QJsonValueRef value_item : array_items) {
for (const QJsonValue &value_item : array_items) {
if (!value_item.isObject()) {
Error(QStringLiteral("Invalid Json reply, track is not a object."));
@ -966,7 +968,7 @@ void TidalRequest::SongsReceived(QNetworkReply *reply, const Artist &artist, con
songs << song;
}
for (Song song : songs) {
for (Song song : std::as_const(songs)) {
if (compilation) song.set_compilation_detected(true);
if (!multidisc) song.set_disc(0);
songs_.insert(song.song_id(), song);

View File

@ -19,6 +19,7 @@
#include "config.h"
#include <utility>
#include <chrono>
#include <memory>
@ -379,7 +380,7 @@ void TidalService::RequestAccessToken(const QString &code) {
}
QUrlQuery url_query;
for (const Param &param : params) {
for (const Param &param : std::as_const(params)) {
url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(param.first)), QString::fromLatin1(QUrl::toPercentEncoding(param.second)));
}
@ -1006,7 +1007,7 @@ void TidalService::LoginError(const QString &error, const QVariant &debug) {
if (!error.isEmpty()) login_errors_ << error;
QString error_html;
for (const QString &e : login_errors_) {
for (const QString &e : std::as_const(login_errors_)) {
qLog(Error) << "Tidal:" << e;
error_html += e + QLatin1String("<br />");
}

View File

@ -233,7 +233,7 @@ void TidalStreamURLRequest::StreamURLReceived() {
QString mimetype = json_obj[QLatin1String("mimeType")].toString();
QMimeDatabase mimedb;
QStringList suffixes = mimedb.mimeTypeForName(mimetype).suffixes();
const QStringList suffixes = mimedb.mimeTypeForName(mimetype).suffixes();
for (const QString &suffix : suffixes) {
filetype = Song::FiletypeByExtension(suffix);
if (filetype != Song::FileType::Unknown) break;
@ -253,9 +253,9 @@ void TidalStreamURLRequest::StreamURLReceived() {
emit StreamURLFailure(id_, media_url_, errors_.first());
return;
}
QJsonArray json_array_urls = json_urls.toArray();
const QJsonArray json_array_urls = json_urls.toArray();
urls.reserve(json_array_urls.count());
for (const QJsonValueRef value : json_array_urls) {
for (const QJsonValue &value : json_array_urls) {
urls << QUrl(value.toString());
}
}

View File

@ -17,6 +17,8 @@
*
*/
#include <utility>
#include <QByteArray>
#include <QString>
#include <QStringList>
@ -37,7 +39,8 @@ QStringList ImageUtils::kSupportedImageFormats;
QStringList ImageUtils::SupportedImageMimeTypes() {
if (kSupportedImageMimeTypes.isEmpty()) {
for (const QByteArray &mimetype : QImageReader::supportedMimeTypes()) {
const QList<QByteArray> supported_mimetypes = QImageReader::supportedMimeTypes();
for (const QByteArray &mimetype : supported_mimetypes) {
kSupportedImageMimeTypes << QString::fromUtf8(mimetype);
}
}
@ -49,7 +52,8 @@ QStringList ImageUtils::SupportedImageMimeTypes() {
QStringList ImageUtils::SupportedImageFormats() {
if (kSupportedImageFormats.isEmpty()) {
for (const QByteArray &filetype : QImageReader::supportedImageFormats()) {
const QList<QByteArray> image_formats = QImageReader::supportedImageFormats();
for (const QByteArray &filetype : image_formats) {
kSupportedImageFormats << QString::fromUtf8(filetype);
}
}