Add missing const
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user