From 3323c2d094e309f519af1147f33613ee43aee8c3 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Mon, 10 Feb 2014 14:29:07 +0100 Subject: [PATCH] Convert all instances of foreach() to a C++11 for find ext src -name '*.cpp' -exec \ sed -i -e 's/foreach(\([^,]\+\),/for (\1 :/' {} \; --- ext/clementine-spotifyblob/spotifyclient.cpp | 12 +-- ext/libclementine-common/core/logging.cpp | 4 +- .../core/messagehandler.h | 4 +- ext/libclementine-common/core/workerpool.h | 8 +- ext/libclementine-tagreader/cloudstream.cpp | 2 +- src/core/application.cpp | 12 ++- src/core/backgroundstreams.cpp | 4 +- src/core/deletefiles.cpp | 2 +- src/core/gnomeglobalshortcutbackend.cpp | 4 +- src/core/mergedproxymodel.cpp | 14 ++-- src/core/mpris2.cpp | 4 +- src/core/multisortfilterproxy.cpp | 2 +- src/core/networkproxyfactory.cpp | 2 +- src/core/qxtglobalshortcutbackend.cpp | 4 +- src/core/simpletreeitem.h | 2 +- src/core/songloader.cpp | 4 +- src/core/tagreaderclient.cpp | 4 +- src/core/taskmanager.cpp | 2 +- src/core/utilities.cpp | 22 +++--- src/covers/albumcoverfetcher.cpp | 2 +- src/covers/albumcoverfetchersearch.cpp | 6 +- src/covers/amazoncoverprovider.cpp | 2 +- src/covers/coversearchstatistics.cpp | 4 +- src/covers/coversearchstatisticsdialog.cpp | 2 +- src/covers/discogscoverprovider.cpp | 4 +- src/covers/lastfmcoverprovider.cpp | 2 +- src/covers/musicbrainzcoverprovider.cpp | 6 +- src/devices/cddadevice.cpp | 2 +- src/devices/devicekitlister.cpp | 8 +- src/devices/devicemanager.cpp | 38 ++++++---- src/devices/devicemanager.h | 2 +- src/devices/deviceproperties.cpp | 10 +-- src/devices/deviceview.cpp | 6 +- src/devices/giolister.cpp | 6 +- src/engines/gstengine.cpp | 2 +- src/engines/gstenginepipeline.cpp | 2 +- .../digitallyimportedsearchprovider.cpp | 2 +- src/globalsearch/globalsearch.cpp | 18 +++-- src/globalsearch/globalsearchmodel.cpp | 10 ++- src/globalsearch/globalsearchsettingspage.cpp | 7 +- src/globalsearch/globalsearchview.cpp | 8 +- .../groovesharksearchprovider.cpp | 6 +- src/globalsearch/icecastsearchprovider.cpp | 2 +- src/globalsearch/lastfmsearchprovider.cpp | 6 +- src/globalsearch/savedradiosearchprovider.cpp | 2 +- src/globalsearch/searchprovider.cpp | 10 ++- src/globalsearch/simplesearchprovider.cpp | 4 +- src/globalsearch/somafmsearchprovider.cpp | 2 +- src/globalsearch/soundcloudsearchprovider.cpp | 2 +- src/internet/boxservice.cpp | 4 +- src/internet/digitallyimportedclient.cpp | 4 +- src/internet/digitallyimportedservicebase.cpp | 2 +- src/internet/dropboxauthenticator.cpp | 4 +- src/internet/dropboxservice.cpp | 2 +- src/internet/googledriveclient.cpp | 4 +- src/internet/googledriveservice.cpp | 10 +-- src/internet/groovesharkservice.cpp | 56 +++++++------- src/internet/icecastbackend.cpp | 6 +- src/internet/icecastmodel.cpp | 6 +- src/internet/icecastservice.cpp | 8 +- src/internet/internetmodel.cpp | 6 +- src/internet/internetviewcontainer.cpp | 2 +- src/internet/jamendodynamicplaylist.cpp | 2 +- src/internet/jamendoservice.cpp | 2 +- src/internet/lastfmservice.cpp | 12 +-- src/internet/magnatunedownloaddialog.cpp | 2 +- src/internet/oauthenticator.cpp | 4 +- src/internet/savedradio.cpp | 3 +- src/internet/skydriveservice.cpp | 2 +- src/internet/somafmservice.cpp | 2 +- src/internet/soundcloudservice.cpp | 6 +- src/internet/spotifyblobdownloader.cpp | 14 ++-- src/internet/spotifyserver.cpp | 4 +- src/internet/spotifyservice.cpp | 6 +- src/internet/ubuntuoneauthenticator.cpp | 4 +- src/internet/ubuntuoneservice.cpp | 4 +- src/library/library.cpp | 2 +- src/library/librarybackend.cpp | 18 +++-- src/library/libraryfilterwidget.cpp | 2 +- src/library/librarymodel.cpp | 30 ++++---- src/library/libraryquery.cpp | 8 +- src/library/libraryview.cpp | 18 +++-- src/library/librarywatcher.cpp | 59 ++++++++------- src/moodbar/moodbaritemdelegate.cpp | 6 +- src/moodbar/moodbarloader.cpp | 2 +- src/moodbar/moodbarproxystyle.cpp | 2 +- src/musicbrainz/acoustidclient.cpp | 4 +- src/musicbrainz/musicbrainzclient.cpp | 6 +- src/musicbrainz/tagfetcher.cpp | 4 +- src/networkremote/outgoingdatacreator.cpp | 25 +++---- src/networkremote/tinysvcmdns.cpp | 12 +-- src/networkremote/zeroconf.cpp | 2 +- src/playlist/playlist.cpp | 69 +++++++++-------- src/playlist/playlist.h | 2 +- src/playlist/playlistbackend.cpp | 4 +- src/playlist/playlistfilterparser.cpp | 8 +- src/playlist/playlistitem.cpp | 8 +- src/playlist/playlistlistcontainer.cpp | 14 ++-- src/playlist/playlistlistmodel.cpp | 2 +- src/playlist/playlistmanager.cpp | 31 ++++---- src/playlist/playlistsequence.cpp | 2 +- src/playlist/playlistundocommands.cpp | 3 +- src/playlist/playlistview.cpp | 8 +- src/playlist/queue.cpp | 14 ++-- src/playlist/queuemanager.cpp | 5 +- src/playlist/songloaderinserter.cpp | 4 +- src/playlistparsers/asxiniparser.cpp | 2 +- src/playlistparsers/asxparser.cpp | 2 +- src/playlistparsers/m3uparser.cpp | 2 +- src/playlistparsers/playlistparser.cpp | 14 ++-- src/playlistparsers/plsparser.cpp | 2 +- src/playlistparsers/wplparser.cpp | 2 +- src/playlistparsers/xspfparser.cpp | 2 +- src/podcasts/addpodcastbyurl.cpp | 8 +- src/podcasts/fixedopmlpage.cpp | 2 +- src/podcasts/gpoddersearchpage.cpp | 2 +- src/podcasts/gpoddersync.cpp | 16 ++-- src/podcasts/gpoddertoptagsmodel.cpp | 2 +- src/podcasts/gpoddertoptagspage.cpp | 2 +- src/podcasts/itunessearchpage.cpp | 2 +- src/podcasts/podcastdiscoverymodel.cpp | 4 +- src/podcasts/podcastinfowidget.cpp | 2 +- src/podcasts/podcastparser.cpp | 2 +- src/podcasts/podcastservicemodel.cpp | 2 +- src/podcasts/podcastupdater.cpp | 12 +-- src/smartplaylists/querygenerator.cpp | 2 +- src/smartplaylists/querywizardplugin.cpp | 6 +- src/smartplaylists/search.cpp | 4 +- src/smartplaylists/searchtermwidget.cpp | 2 +- src/songinfo/artistinfoview.cpp | 4 +- src/songinfo/echonestimages.cpp | 2 +- src/songinfo/echonestsimilarartists.cpp | 2 +- src/songinfo/lastfmtrackinfoprovider.cpp | 2 +- src/songinfo/songinfobase.cpp | 10 +-- src/songinfo/songinfofetcher.cpp | 4 +- src/songinfo/songinfosettingspage.cpp | 2 +- src/songinfo/songinfoview.cpp | 12 +-- src/songinfo/songkickconcerts.cpp | 4 +- src/songinfo/songplaystats.cpp | 2 +- src/songinfo/ultimatelyricsprovider.cpp | 16 ++-- src/transcoder/transcodedialog.cpp | 6 +- src/transcoder/transcoder.cpp | 2 +- src/ui/about.cpp | 6 +- src/ui/albumcoverchoicecontroller.cpp | 6 +- src/ui/albumcovermanager.cpp | 18 +++-- src/ui/albumcovermanagerlist.cpp | 6 +- src/ui/albumcoversearcher.cpp | 2 +- src/ui/backgroundstreamssettingspage.cpp | 2 +- src/ui/behavioursettingspage.cpp | 2 +- src/ui/edittagdialog.cpp | 26 ++++--- src/ui/equalizer.cpp | 2 +- src/ui/flowlayout.cpp | 8 +- src/ui/globalshortcutssettingspage.cpp | 9 +-- src/ui/iconloader.cpp | 2 +- src/ui/mainwindow.cpp | 74 +++++++++++-------- src/ui/networkremotesettingspage.cpp | 2 +- src/ui/organiseerrordialog.cpp | 2 +- src/ui/playbacksettingspage.cpp | 2 +- src/ui/ripcd.cpp | 6 +- src/ui/settingsdialog.cpp | 14 +++- src/ui/trackselectiondialog.cpp | 6 +- src/ui/windows7thumbbar.cpp | 2 +- src/visualisations/projectmpresetmodel.cpp | 2 +- src/visualisations/projectmvisualisation.cpp | 10 +-- src/widgets/errordialog.cpp | 2 +- src/widgets/fancytabwidget.cpp | 4 +- src/widgets/fileviewlist.cpp | 4 +- src/widgets/freespacebar.cpp | 8 +- src/widgets/groupediconview.cpp | 6 +- src/widgets/loginstatewidget.cpp | 2 +- src/widgets/multiloadingindicator.cpp | 2 +- src/widgets/stylehelper.cpp | 3 +- src/wiimotedev/shortcuts.cpp | 2 +- src/wiimotedev/wiimotesettingspage.cpp | 8 +- src/wiimotedev/wiimoteshortcutgrabber.cpp | 4 +- 175 files changed, 672 insertions(+), 596 deletions(-) diff --git a/ext/clementine-spotifyblob/spotifyclient.cpp b/ext/clementine-spotifyblob/spotifyclient.cpp index e157d07d9..1e24f08ab 100644 --- a/ext/clementine-spotifyblob/spotifyclient.cpp +++ b/ext/clementine-spotifyblob/spotifyclient.cpp @@ -245,7 +245,7 @@ void SpotifyClient::SendSearchResponse(sp_search* result) { // Get the albums from the search. All these should be resolved by now. QList browses = pending_search_album_browses_.take(result); - foreach(sp_albumbrowse * browse, browses) { + for (sp_albumbrowse* browse : browses) { sp_album* album = sp_albumbrowse_album(browse); pb::spotify::Album* msg = response->add_album(); @@ -548,7 +548,7 @@ void SpotifyClient::PlaylistStateChangedForLoadPlaylist(sp_playlist* pl, } // If any of the tracks aren't loaded yet we have to wait - foreach(sp_track * track, pending_load->tracks_) { + for (sp_track* track : pending_load->tracks_) { if (!sp_track_is_loaded(track)) { qLog(Debug) << "One or more tracks aren't loaded yet, waiting"; return; @@ -567,7 +567,7 @@ void SpotifyClient::PlaylistStateChangedForLoadPlaylist(sp_playlist* pl, } *response->mutable_request() = pending_load->request_; - foreach(sp_track * track, pending_load->tracks_) { + for (sp_track* track : pending_load->tracks_) { me->ConvertTrack(track, response->add_track()); sp_track_release(track); } @@ -660,11 +660,11 @@ void SpotifyClient::MetadataUpdatedCallback(sp_session* session) { SpotifyClient* me = reinterpret_cast(sp_session_userdata(session)); - foreach(const PendingLoadPlaylist & load, me->pending_load_playlists_) { + for (const PendingLoadPlaylist& load : me->pending_load_playlists_) { PlaylistStateChangedForLoadPlaylist(load.playlist_, me); } - foreach(const PendingPlaybackRequest & playback, - me->pending_playback_requests_) { + for (const PendingPlaybackRequest& playback : + me->pending_playback_requests_) { me->TryPlaybackAgain(playback); } } diff --git a/ext/libclementine-common/core/logging.cpp b/ext/libclementine-common/core/logging.cpp index 414615a15..acbc0e2f0 100644 --- a/ext/libclementine-common/core/logging.cpp +++ b/ext/libclementine-common/core/logging.cpp @@ -88,7 +88,7 @@ static void MessageHandler(QtMsgType type, const char* message) { break; } - foreach(const QString & line, QString::fromLocal8Bit(message).split('\n')) { + for (const QString& line : QString::fromLocal8Bit(message).split('\n')) { CreateLogger(level, "unknown", -1) << line.toLocal8Bit().constData(); } @@ -113,7 +113,7 @@ void Init() { void SetLevels(const QString& levels) { if (!sClassLevels) return; - foreach(const QString & item, levels.split(',')) { + for (const QString& item : levels.split(',')) { const QStringList class_level = item.split(':'); QString class_name; diff --git a/ext/libclementine-common/core/messagehandler.h b/ext/libclementine-common/core/messagehandler.h index 405334147..5a7f8f2c8 100644 --- a/ext/libclementine-common/core/messagehandler.h +++ b/ext/libclementine-common/core/messagehandler.h @@ -175,7 +175,9 @@ bool AbstractMessageHandler::RawMessageArrived(const QByteArray& data) { template void AbstractMessageHandler::AbortAll() { - foreach(ReplyType * reply, pending_replies_) { reply->Abort(); } + for (ReplyType* reply : pending_replies_) { + reply->Abort(); + } pending_replies_.clear(); } diff --git a/ext/libclementine-common/core/workerpool.h b/ext/libclementine-common/core/workerpool.h index 598f47f13..343e31c1d 100644 --- a/ext/libclementine-common/core/workerpool.h +++ b/ext/libclementine-common/core/workerpool.h @@ -167,7 +167,7 @@ WorkerPool::WorkerPool(QObject* parent) template WorkerPool::~WorkerPool() { - foreach(const Worker & worker, workers_) { + for (const Worker& worker : workers_) { if (worker.local_socket_ && worker.process_) { disconnect(worker.process_, SIGNAL(error(QProcess::ProcessError)), this, SLOT(ProcessError(QProcess::ProcessError))); @@ -188,7 +188,9 @@ WorkerPool::~WorkerPool() { } } - foreach(ReplyType * reply, message_queue_) { reply->Abort(); } + for (ReplyType* reply : message_queue_) { + reply->Abort(); + } } template @@ -231,7 +233,7 @@ void WorkerPool::DoStart() { search_path << qApp->applicationDirPath() + "/../PlugIns"; #endif - foreach(const QString & path_prefix, search_path) { + for (const QString& path_prefix : search_path) { const QString executable_path = path_prefix + "/" + executable_name_; if (QFile::exists(executable_path)) { executable_path_ = executable_path; diff --git a/ext/libclementine-tagreader/cloudstream.cpp b/ext/libclementine-tagreader/cloudstream.cpp index 253c14c95..e6dd26f8b 100644 --- a/ext/libclementine-tagreader/cloudstream.cpp +++ b/ext/libclementine-tagreader/cloudstream.cpp @@ -191,7 +191,7 @@ void CloudStream::truncate(long) { } void CloudStream::SSLErrors(const QList& errors) { - foreach(const QSslError & error, errors) { + for (const QSslError& error : errors) { qLog(Debug) << error.error() << error.errorString(); qLog(Debug) << error.certificate(); } diff --git a/src/core/application.cpp b/src/core/application.cpp index c8bf62d50..4201d2d1a 100644 --- a/src/core/application.cpp +++ b/src/core/application.cpp @@ -128,11 +128,17 @@ Application::~Application() { delete device_manager_; device_manager_ = nullptr; - foreach(QObject * object, objects_in_threads_) { object->deleteLater(); } + for (QObject* object : objects_in_threads_) { + object->deleteLater(); + } - foreach(QThread * thread, threads_) { thread->quit(); } + for (QThread* thread : threads_) { + thread->quit(); + } - foreach(QThread * thread, threads_) { thread->wait(); } + for (QThread* thread : threads_) { + thread->wait(); + } } void Application::MoveToNewThread(QObject* object) { diff --git a/src/core/backgroundstreams.cpp b/src/core/backgroundstreams.cpp index 7e79df4bd..8fd961582 100644 --- a/src/core/backgroundstreams.cpp +++ b/src/core/backgroundstreams.cpp @@ -152,7 +152,7 @@ void BackgroundStreams::StreamActionDestroyed() { return; } - foreach(Stream * stream, streams_.values()) { + for (Stream* stream : streams_.values()) { if (stream->action == action) { stream->action = nullptr; } @@ -165,7 +165,7 @@ void BackgroundStreams::StreamActionToggled(bool checked) { return; } - foreach(Stream * stream, streams_.values()) { + for (Stream* stream : streams_.values()) { if (stream->action == action) { EnableStream(stream->name, checked); } diff --git a/src/core/deletefiles.cpp b/src/core/deletefiles.cpp index 46d8e29f5..3793ef01f 100644 --- a/src/core/deletefiles.cpp +++ b/src/core/deletefiles.cpp @@ -57,7 +57,7 @@ void DeleteFiles::Start(const SongList& songs) { void DeleteFiles::Start(const QStringList& filenames) { SongList songs; - foreach(const QString & filename, filenames) { + for (const QString& filename : filenames) { Song song; song.set_url(QUrl::fromLocalFile(filename)); songs << song; diff --git a/src/core/gnomeglobalshortcutbackend.cpp b/src/core/gnomeglobalshortcutbackend.cpp index 09675998d..46f924516 100644 --- a/src/core/gnomeglobalshortcutbackend.cpp +++ b/src/core/gnomeglobalshortcutbackend.cpp @@ -50,7 +50,7 @@ bool GnomeGlobalShortcutBackend::DoRegister() { qLog(Debug) << "registering"; // Check if the GSD service is available if (!QDBusConnection::sessionBus().interface()->isServiceRegistered( - kGsdService)) { + kGsdService)) { qLog(Warning) << "gnome settings daemon not registered"; return false; } @@ -100,7 +100,7 @@ void GnomeGlobalShortcutBackend::DoUnregister() { #ifdef QT_DBUS_LIB // Check if the GSD service is available if (!QDBusConnection::sessionBus().interface()->isServiceRegistered( - kGsdService)) + kGsdService)) return; if (!interface_ || !is_connected_) return; diff --git a/src/core/mergedproxymodel.cpp b/src/core/mergedproxymodel.cpp index fd3b77fe9..4a090776f 100644 --- a/src/core/mergedproxymodel.cpp +++ b/src/core/mergedproxymodel.cpp @@ -397,7 +397,7 @@ QStringList MergedProxyModel::mimeTypes() const { QStringList ret; ret << sourceModel()->mimeTypes(); - foreach(const QAbstractItemModel * model, merge_points_.keys()) { + for (const QAbstractItemModel* model : merge_points_.keys()) { ret << model->mimeTypes(); } @@ -416,7 +416,7 @@ QMimeData* MergedProxyModel::mimeData(const QModelIndexList& indexes) const { // Only ask about the indexes that are actually in that model QModelIndexList indexes_in_model; - foreach(const QModelIndex & proxy_index, indexes) { + for (const QModelIndex& proxy_index : indexes) { QModelIndex source_index = mapToSource(proxy_index); if (source_index.model() != model) continue; indexes_in_model << source_index; @@ -467,7 +467,7 @@ QAbstractItemModel* MergedProxyModel::GetModel(const QModelIndex& source_index) // but without the const_cast const QAbstractItemModel* const_model = source_index.model(); if (const_model == sourceModel()) return sourceModel(); - foreach(QAbstractItemModel * submodel, merge_points_.keys()) { + for (QAbstractItemModel* submodel : merge_points_.keys()) { if (submodel == const_model) return submodel; } return nullptr; @@ -480,13 +480,13 @@ void MergedProxyModel::DataChanged(const QModelIndex& top_left, void MergedProxyModel::LayoutAboutToBeChanged() { old_merge_points_.clear(); - foreach(QAbstractItemModel * key, merge_points_.keys()) { + for (QAbstractItemModel* key : merge_points_.keys()) { old_merge_points_[key] = merge_points_.value(key); } } void MergedProxyModel::LayoutChanged() { - foreach(QAbstractItemModel * key, merge_points_.keys()) { + for (QAbstractItemModel* key : merge_points_.keys()) { if (!old_merge_points_.contains(key)) continue; const int old_row = old_merge_points_[key].row(); @@ -509,7 +509,7 @@ bool MergedProxyModel::IsKnownModel(const QAbstractItemModel* model) const { QModelIndexList MergedProxyModel::mapFromSource( const QModelIndexList& source_indexes) const { QModelIndexList ret; - foreach(const QModelIndex & index, source_indexes) { + for (const QModelIndex& index : source_indexes) { ret << mapFromSource(index); } return ret; @@ -518,7 +518,7 @@ QModelIndexList MergedProxyModel::mapFromSource( QModelIndexList MergedProxyModel::mapToSource( const QModelIndexList& proxy_indexes) const { QModelIndexList ret; - foreach(const QModelIndex & index, proxy_indexes) { + for (const QModelIndex& index : proxy_indexes) { ret << mapToSource(index); } return ret; diff --git a/src/core/mpris2.cpp b/src/core/mpris2.cpp index 3b2c46c11..4b2145969 100644 --- a/src/core/mpris2.cpp +++ b/src/core/mpris2.cpp @@ -184,7 +184,7 @@ QString Mpris2::DesktopEntryAbsolutePath() const { xdg_data_dirs.append("/usr/local/share/"); xdg_data_dirs.append("/usr/share/"); - foreach(const QString & directory, xdg_data_dirs) { + for (const QString& directory : xdg_data_dirs) { QString path = QString("%1/applications/%2.desktop").arg( directory, QApplication::applicationName().toLower()); if (QFile::exists(path)) return path; @@ -534,7 +534,7 @@ MprisPlaylistList Mpris2::GetPlaylists(quint32 index, quint32 max_count, const QString& order, bool reverse_order) { MprisPlaylistList ret; - foreach(Playlist * p, app_->playlist_manager()->GetAllPlaylists()) { + for (Playlist* p : app_->playlist_manager()->GetAllPlaylists()) { MprisPlaylist mpris_playlist; mpris_playlist.id = MakePlaylistPath(p->id()); mpris_playlist.name = app_->playlist_manager()->GetPlaylistName(p->id()); diff --git a/src/core/multisortfilterproxy.cpp b/src/core/multisortfilterproxy.cpp index 1fb1d92d7..b87ca12ab 100644 --- a/src/core/multisortfilterproxy.cpp +++ b/src/core/multisortfilterproxy.cpp @@ -14,7 +14,7 @@ void MultiSortFilterProxy::AddSortSpec(int role, Qt::SortOrder order) { bool MultiSortFilterProxy::lessThan(const QModelIndex& left, const QModelIndex& right) const { - foreach(const SortSpec & spec, sorting_) { + for (const SortSpec& spec : sorting_) { const int ret = Compare(left.data(spec.first), right.data(spec.first)); if (ret < 0) { diff --git a/src/core/networkproxyfactory.cpp b/src/core/networkproxyfactory.cpp index 518029f7a..7ffde1c94 100644 --- a/src/core/networkproxyfactory.cpp +++ b/src/core/networkproxyfactory.cpp @@ -28,7 +28,7 @@ NetworkProxyFactory::NetworkProxyFactory() qLog(Debug) << "Detected system proxy URLs:" << urls; - foreach(const QString & url_str, urls) { + for (const QString& url_str : urls) { if (url_str.isEmpty()) continue; env_url_ = QUrl(url_str); diff --git a/src/core/qxtglobalshortcutbackend.cpp b/src/core/qxtglobalshortcutbackend.cpp index 08f048b35..3f1013ea9 100644 --- a/src/core/qxtglobalshortcutbackend.cpp +++ b/src/core/qxtglobalshortcutbackend.cpp @@ -28,8 +28,8 @@ QxtGlobalShortcutBackend::QxtGlobalShortcutBackend(GlobalShortcuts* parent) bool QxtGlobalShortcutBackend::DoRegister() { qLog(Debug) << "registering"; - foreach(const GlobalShortcuts::Shortcut & shortcut, - manager_->shortcuts().values()) { + for (const GlobalShortcuts::Shortcut& shortcut : + manager_->shortcuts().values()) { AddShortcut(shortcut.action); } diff --git a/src/core/simpletreeitem.h b/src/core/simpletreeitem.h index 95263f3a1..c6ac66135 100644 --- a/src/core/simpletreeitem.h +++ b/src/core/simpletreeitem.h @@ -148,7 +148,7 @@ void SimpleTreeItem::Delete(int child_row) { template T* SimpleTreeItem::ChildByKey(const QString& key) const { - foreach(T * child, children) { + for (T* child : children) { if (child->key == key) return child; } return NULL; diff --git a/src/core/songloader.cpp b/src/core/songloader.cpp index 209b21902..39255c7ed 100644 --- a/src/core/songloader.cpp +++ b/src/core/songloader.cpp @@ -225,7 +225,7 @@ void SongLoader::AudioCDTagsLoaded( // and that we are going to fill it with new (more complete) ones songs_.clear(); int track_number = 1; - foreach(const MusicBrainzClient::Result & ret, results) { + for (const MusicBrainzClient::Result& ret : results) { Song song; song.set_artist(artist); song.set_album(album); @@ -313,7 +313,7 @@ SongLoader::Result SongLoader::LoadLocal(const QString& filename) { } } - foreach(const Song & song, song_list) { + for (const Song& song : song_list) { if (song.is_valid()) { songs_ << song; } diff --git a/src/core/tagreaderclient.cpp b/src/core/tagreaderclient.cpp index 66bcfd0c4..cfeca3d80 100644 --- a/src/core/tagreaderclient.cpp +++ b/src/core/tagreaderclient.cpp @@ -77,7 +77,7 @@ TagReaderReply* TagReaderClient::UpdateSongStatistics(const Song& metadata) { } void TagReaderClient::UpdateSongsStatistics(const SongList& songs) { - foreach(const Song & song, songs) { + for (const Song& song : songs) { TagReaderReply* reply = UpdateSongStatistics(song); connect(reply, SIGNAL(Finished(bool)), reply, SLOT(deleteLater())); } @@ -95,7 +95,7 @@ TagReaderReply* TagReaderClient::UpdateSongRating(const Song& metadata) { } void TagReaderClient::UpdateSongsRating(const SongList& songs) { - foreach(const Song & song, songs) { + for (const Song& song : songs) { TagReaderReply* reply = UpdateSongRating(song); connect(reply, SIGNAL(Finished(bool)), reply, SLOT(deleteLater())); } diff --git a/src/core/taskmanager.cpp b/src/core/taskmanager.cpp index 0ab5ff3d2..e9b0a4d9c 100644 --- a/src/core/taskmanager.cpp +++ b/src/core/taskmanager.cpp @@ -95,7 +95,7 @@ void TaskManager::SetTaskFinished(int id) { if (tasks_[id].blocks_library_scans) { resume_library_watchers = true; - foreach(const Task & task, tasks_.values()) { + for (const Task& task : tasks_.values()) { if (task.id != id && task.blocks_library_scans) { resume_library_watchers = false; break; diff --git a/src/core/utilities.cpp b/src/core/utilities.cpp index f8f149f33..5d3311a54 100644 --- a/src/core/utilities.cpp +++ b/src/core/utilities.cpp @@ -221,13 +221,13 @@ QString GetTemporaryFileName() { void RemoveRecursive(const QString& path) { QDir dir(path); - foreach(const QString & child, - dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Hidden)) - RemoveRecursive(path + "/" + child); + for (const QString& child : + dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Hidden)) + RemoveRecursive(path + "/" + child); - foreach(const QString & child, - dir.entryList(QDir::NoDotAndDotDot | QDir::Files | QDir::Hidden)) - QFile::remove(path + "/" + child); + for (const QString& child : + dir.entryList(QDir::NoDotAndDotDot | QDir::Files | QDir::Hidden)) + QFile::remove(path + "/" + child); dir.rmdir(path); } @@ -239,8 +239,8 @@ bool CopyRecursive(const QString& source, const QString& destination) { QDir().mkpath(dest_path); QDir dir(source); - foreach(const QString & child, - dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs)) { + for (const QString& child : + dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs)) { if (!CopyRecursive(source + "/" + child, dest_path)) { qLog(Warning) << "Failed to copy dir" << source + "/" + child << "to" << dest_path; @@ -248,8 +248,8 @@ bool CopyRecursive(const QString& source, const QString& destination) { } } - foreach(const QString & child, - dir.entryList(QDir::NoDotAndDotDot | QDir::Files)) { + for (const QString& child : + dir.entryList(QDir::NoDotAndDotDot | QDir::Files)) { if (!QFile::copy(source + "/" + child, dest_path + "/" + child)) { qLog(Warning) << "Failed to copy file" << source + "/" + child << "to" << dest_path; @@ -382,7 +382,7 @@ void ShowFileInExplorer(QString const& path) { void OpenInFileBrowser(const QList& urls) { QSet dirs; - foreach(const QUrl & url, urls) { + for (const QUrl& url : urls) { if (url.scheme() != "file") { continue; } diff --git a/src/covers/albumcoverfetcher.cpp b/src/covers/albumcoverfetcher.cpp index 0600d17d2..430946d7f 100644 --- a/src/covers/albumcoverfetcher.cpp +++ b/src/covers/albumcoverfetcher.cpp @@ -70,7 +70,7 @@ void AlbumCoverFetcher::AddRequest(const CoverSearchRequest& req) { void AlbumCoverFetcher::Clear() { queued_requests_.clear(); - foreach(AlbumCoverFetcherSearch * search, active_requests_.values()) { + for (AlbumCoverFetcherSearch* search : active_requests_.values()) { search->Cancel(); search->deleteLater(); } diff --git a/src/covers/albumcoverfetchersearch.cpp b/src/covers/albumcoverfetchersearch.cpp index d2c2d16ea..b91003348 100644 --- a/src/covers/albumcoverfetchersearch.cpp +++ b/src/covers/albumcoverfetchersearch.cpp @@ -51,7 +51,7 @@ AlbumCoverFetcherSearch::AlbumCoverFetcherSearch( } void AlbumCoverFetcherSearch::TerminateSearch() { - foreach(int id, pending_requests_.keys()) { + for (int id : pending_requests_.keys()) { pending_requests_.take(id)->CancelSearch(id); } @@ -59,7 +59,7 @@ void AlbumCoverFetcherSearch::TerminateSearch() { } void AlbumCoverFetcherSearch::Start(CoverProviders* cover_providers) { - foreach(CoverProvider * provider, cover_providers->List()) { + for (CoverProvider* provider : cover_providers->List()) { connect(provider, SIGNAL(SearchFinished(int, QList)), SLOT(ProviderSearchFinished(int, QList))); const int id = cover_providers->NextId(); @@ -248,7 +248,7 @@ void AlbumCoverFetcherSearch::Cancel() { if (!pending_requests_.isEmpty()) { TerminateSearch(); } else if (!pending_image_loads_.isEmpty()) { - foreach(RedirectFollower * reply, pending_image_loads_.keys()) { + for (RedirectFollower* reply : pending_image_loads_.keys()) { reply->abort(); } pending_image_loads_.clear(); diff --git a/src/covers/amazoncoverprovider.cpp b/src/covers/amazoncoverprovider.cpp index 0ce4c064c..c861ebf9b 100644 --- a/src/covers/amazoncoverprovider.cpp +++ b/src/covers/amazoncoverprovider.cpp @@ -62,7 +62,7 @@ bool AmazonCoverProvider::StartSearch(const QString& artist, QStringList query_items; // Encode the arguments - foreach(const Arg & arg, args) { + for (const Arg& arg : args) { EncodedArg encoded_arg(QUrl::toPercentEncoding(arg.first), QUrl::toPercentEncoding(arg.second)); encoded_args << encoded_arg; diff --git a/src/covers/coversearchstatistics.cpp b/src/covers/coversearchstatistics.cpp index bcd428d5a..93dbf4534 100644 --- a/src/covers/coversearchstatistics.cpp +++ b/src/covers/coversearchstatistics.cpp @@ -30,10 +30,10 @@ CoverSearchStatistics& CoverSearchStatistics::operator+=( network_requests_made_ += other.network_requests_made_; bytes_transferred_ += other.bytes_transferred_; - foreach(const QString & key, other.chosen_images_by_provider_.keys()) { + for (const QString& key : other.chosen_images_by_provider_.keys()) { chosen_images_by_provider_[key] += other.chosen_images_by_provider_[key]; } - foreach(const QString & key, other.total_images_by_provider_.keys()) { + for (const QString& key : other.total_images_by_provider_.keys()) { total_images_by_provider_[key] += other.total_images_by_provider_[key]; } diff --git a/src/covers/coversearchstatisticsdialog.cpp b/src/covers/coversearchstatisticsdialog.cpp index f85cfe1fb..c2d09fa26 100644 --- a/src/covers/coversearchstatisticsdialog.cpp +++ b/src/covers/coversearchstatisticsdialog.cpp @@ -53,7 +53,7 @@ void CoverSearchStatisticsDialog::Show( .arg(statistics.chosen_images_ + statistics.missing_images_) .arg(statistics.missing_images_)); - foreach(const QString & provider, providers) { + for (const QString& provider : providers) { AddLine(tr("Covers from %1").arg(provider), QString::number(statistics.chosen_images_by_provider_[provider])); } diff --git a/src/covers/discogscoverprovider.cpp b/src/covers/discogscoverprovider.cpp index 1d29ed47f..0498de3ca 100644 --- a/src/covers/discogscoverprovider.cpp +++ b/src/covers/discogscoverprovider.cpp @@ -85,7 +85,7 @@ void DiscogsCoverProvider::SendSearchRequest(DiscogsCoverSearchContext* ctx) { EncodedArgList encoded_args; - foreach(const Arg & arg, args) { + for (const Arg& arg : args) { EncodedArg encoded_arg(QUrl::toPercentEncoding(arg.first), QUrl::toPercentEncoding(arg.second)); encoded_args << encoded_arg; @@ -126,7 +126,7 @@ void DiscogsCoverProvider::HandleSearchReply(QNetworkReply* reply, int id) { QVariantList results = reply_map["results"].toList(); - foreach(const QVariant & result, results) { + for (const QVariant& result : results) { QVariantMap result_map = result.toMap(); // In order to use less round-trips, we cheat here. Instead of // following the "resource_url", and then scan all images in the diff --git a/src/covers/lastfmcoverprovider.cpp b/src/covers/lastfmcoverprovider.cpp index 1ab2078db..1eef40ad9 100644 --- a/src/covers/lastfmcoverprovider.cpp +++ b/src/covers/lastfmcoverprovider.cpp @@ -51,7 +51,7 @@ void LastFmCoverProvider::QueryFinished(QNetworkReply* reply, int id) { QList elements = query["results"]["albummatches"].children("album"); - foreach(const lastfm::XmlQuery & element, elements) { + for (const lastfm::XmlQuery& element : elements) { CoverSearchResult result; result.description = element["artist"].text() + " - " + element["name"].text(); diff --git a/src/covers/musicbrainzcoverprovider.cpp b/src/covers/musicbrainzcoverprovider.cpp index 2cacb20bd..af5ac2dc1 100644 --- a/src/covers/musicbrainzcoverprovider.cpp +++ b/src/covers/musicbrainzcoverprovider.cpp @@ -74,7 +74,7 @@ void MusicbrainzCoverProvider::ReleaseSearchFinished(QNetworkReply* reply, } } - foreach(const QString & release_id, releases) { + for (const QString& release_id : releases) { QUrl url(QString(kAlbumCoverUrl).arg(release_id)); QNetworkReply* reply = network_->head(QNetworkRequest(url)); image_checks_.insert(id, reply); @@ -90,7 +90,7 @@ void MusicbrainzCoverProvider::ImageCheckFinished(int id) { if (finished_count == replies.size()) { QString cover_name = cover_names_.take(id); QList results; - foreach(QNetworkReply * reply, replies) { + for (QNetworkReply* reply : replies) { reply->deleteLater(); if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() < 400) { @@ -107,7 +107,7 @@ void MusicbrainzCoverProvider::ImageCheckFinished(int id) { void MusicbrainzCoverProvider::CancelSearch(int id) { QList replies = image_checks_.values(id); - foreach(QNetworkReply * reply, replies) { + for (QNetworkReply* reply : replies) { reply->abort(); reply->deleteLater(); } diff --git a/src/devices/cddadevice.cpp b/src/devices/cddadevice.cpp index edb0049e2..c2cdb7382 100644 --- a/src/devices/cddadevice.cpp +++ b/src/devices/cddadevice.cpp @@ -144,7 +144,7 @@ void CddaDevice::AudioCDTagsLoaded( int track_number = 1; if (results.size() == 0) return; model_->Reset(); - foreach(const MusicBrainzClient::Result & ret, results) { + for (const MusicBrainzClient::Result& ret : results) { Song song; song.set_artist(artist); song.set_album(album); diff --git a/src/devices/devicekitlister.cpp b/src/devices/devicekitlister.cpp index 0db3c2b54..c8e1d9c66 100644 --- a/src/devices/devicekitlister.cpp +++ b/src/devices/devicekitlister.cpp @@ -68,7 +68,7 @@ void DeviceKitLister::Init() { // Get information about each one QMap device_data; - foreach(const QDBusObjectPath & path, reply.value()) { + for (const QDBusObjectPath& path : reply.value()) { DeviceData data = ReadDeviceData(path); if (data.suitable) device_data[data.unique_id()] = data; } @@ -80,7 +80,9 @@ void DeviceKitLister::Init() { } // Notify about the changes - foreach(const QString & id, device_data.keys()) { emit DeviceAdded(id); } + for (const QString& id : device_data.keys()) { + emit DeviceAdded(id); + } } QStringList DeviceKitLister::DeviceUniqueIDs() { @@ -225,7 +227,7 @@ void DeviceKitLister::DBusDeviceChanged(const QDBusObjectPath& path) { } QString DeviceKitLister::FindUniqueIdByPath(const QDBusObjectPath& path) const { - foreach(const DeviceData & data, device_data_) { + for (const DeviceData& data : device_data_) { if (data.dbus_path == path.path()) return data.unique_id(); } return QString(); diff --git a/src/devices/devicemanager.cpp b/src/devices/devicemanager.cpp index ffab803d7..52a532ac9 100644 --- a/src/devices/devicemanager.cpp +++ b/src/devices/devicemanager.cpp @@ -81,7 +81,7 @@ DeviceDatabaseBackend::Device DeviceManager::DeviceInfo::SaveToDb() const { ret.transcode_format_ = transcode_format_; QStringList unique_ids; - foreach(const Backend & backend, backends_) { + for (const Backend& backend : backends_) { unique_ids << backend.unique_id_; } ret.unique_id_ = unique_ids.join(","); @@ -99,12 +99,16 @@ void DeviceManager::DeviceInfo::InitFromDb( QStringList icon_names = dev.icon_name_.split(','); QVariantList icons; - foreach(const QString & icon_name, icon_names) { icons << icon_name; } + for (const QString& icon_name : icon_names) { + icons << icon_name; + } LoadIcon(icons, friendly_name_); QStringList unique_ids = dev.unique_id_.split(','); - foreach(const QString & id, unique_ids) { backends_ << Backend(nullptr, id); } + for (const QString& id : unique_ids) { + backends_ << Backend(nullptr, id); + } } void DeviceManager::DeviceInfo::LoadIcon(const QVariantList& icons, @@ -116,7 +120,7 @@ void DeviceManager::DeviceInfo::LoadIcon(const QVariantList& icons, } // Try to load the icon with that exact name first - foreach(const QVariant & icon, icons) { + for (const QVariant& icon : icons) { if (!icon.value().isNull()) { icon_ = QIcon(icon.value()); return; @@ -210,7 +214,7 @@ DeviceManager::DeviceManager(Application* app, QObject* parent) } DeviceManager::~DeviceManager() { - foreach(DeviceLister * lister, listers_) { + for (DeviceLister* lister : listers_) { lister->ShutDown(); delete lister; } @@ -221,7 +225,7 @@ DeviceManager::~DeviceManager() { void DeviceManager::LoadAllDevices() { Q_ASSERT(QThread::currentThread() != qApp->thread()); DeviceDatabaseBackend::DeviceList devices = backend_->GetAllDevices(); - foreach(const DeviceDatabaseBackend::Device & device, devices) { + for (const DeviceDatabaseBackend::Device& device : devices) { DeviceInfo info; info.InitFromDb(device); devices_ << info; @@ -309,7 +313,7 @@ QVariant DeviceManager::data(const QModelIndex& index, int role) const { if (!info.device_) { if (info.database_id_ == -1 && !info.BestBackend()->lister_->DeviceNeedsMount( - info.BestBackend()->unique_id_)) { + info.BestBackend()->unique_id_)) { if (info.BestBackend()->lister_->AskForScan( info.BestBackend()->unique_id_)) { @@ -371,7 +375,7 @@ void DeviceManager::AddLister(DeviceLister* lister) { int DeviceManager::FindDeviceById(const QString& id) const { for (int i = 0; i < devices_.count(); ++i) { - foreach(const DeviceInfo::Backend & backend, devices_[i].backends_) { + for (const DeviceInfo::Backend& backend : devices_[i].backends_) { if (backend.unique_id_ == id) return i; } } @@ -382,12 +386,12 @@ int DeviceManager::FindDeviceByUrl(const QList& urls) const { if (urls.isEmpty()) return -1; for (int i = 0; i < devices_.count(); ++i) { - foreach(const DeviceInfo::Backend & backend, devices_[i].backends_) { + for (const DeviceInfo::Backend& backend : devices_[i].backends_) { if (!backend.lister_) continue; QList device_urls = backend.lister_->MakeDeviceUrls(backend.unique_id_); - foreach(const QUrl & url, device_urls) { + for (const QUrl& url : device_urls) { if (urls.contains(url)) return i; } } @@ -487,7 +491,7 @@ void DeviceManager::PhysicalDeviceRemoved(const QString& id) { beginRemoveRows(QModelIndex(), i, i); devices_.removeAt(i); - foreach(const QModelIndex & idx, persistentIndexList()) { + for (const QModelIndex& idx : persistentIndexList()) { if (idx.row() == i) changePersistentIndex(idx, QModelIndex()); else if (idx.row() > i) @@ -542,7 +546,7 @@ std::shared_ptr DeviceManager::Connect(int row) { // Take the first URL that we have a handler for QUrl device_url; - foreach(const QUrl & url, urls) { + for (const QUrl& url : urls) { qLog(Info) << "Connecting" << url; // Find a device class for this URL's scheme @@ -580,7 +584,9 @@ std::shared_ptr DeviceManager::Connect(int row) { if (device_url.isEmpty()) { // Munge the URL list into a string list QStringList url_strings; - foreach(const QUrl & url, urls) { url_strings << url.toString(); } + for (const QUrl& url : urls) { + url_strings << url.toString(); + } app_->AddError(tr("This type of device is not supported: %1") .arg(url_strings.join(", "))); @@ -651,7 +657,7 @@ void DeviceManager::Forget(int row) { beginRemoveRows(QModelIndex(), row, row); devices_.removeAt(row); - foreach(const QModelIndex & idx, persistentIndexList()) { + for (const QModelIndex& idx : persistentIndexList()) { if (idx.row() == row) changePersistentIndex(idx, QModelIndex()); else if (idx.row() > row) @@ -708,7 +714,7 @@ void DeviceManager::TasksChanged() { QList tasks = app_->task_manager()->GetTasks(); QList finished_tasks = active_tasks_.values(); - foreach(const TaskManager::Task & task, tasks) { + for (const TaskManager::Task& task : tasks) { if (!active_tasks_.contains(task.id)) continue; QPersistentModelIndex index = active_tasks_[task.id]; @@ -723,7 +729,7 @@ void DeviceManager::TasksChanged() { finished_tasks.removeAll(index); } - foreach(const QPersistentModelIndex & index, finished_tasks) { + for (const QPersistentModelIndex& index : finished_tasks) { if (!index.isValid()) continue; DeviceInfo& info = devices_[index.row()]; diff --git a/src/devices/devicemanager.h b/src/devices/devicemanager.h index 39b70aa3a..720e794a7 100644 --- a/src/devices/devicemanager.h +++ b/src/devices/devicemanager.h @@ -192,7 +192,7 @@ void DeviceManager::AddDeviceClass() { QStringList schemes = T::url_schemes(); QMetaObject obj = T::staticMetaObject; - foreach(const QString & scheme, schemes) { + for (const QString& scheme : schemes) { device_classes_.insert(scheme, obj); } } diff --git a/src/devices/deviceproperties.cpp b/src/devices/deviceproperties.cpp index 3dd1a8323..cc8f85067 100644 --- a/src/devices/deviceproperties.cpp +++ b/src/devices/deviceproperties.cpp @@ -85,14 +85,14 @@ void DeviceProperties::ShowDevice(int row) { << "phone-nokia-n900" << "phone-palm-pre"; - foreach(const QString & icon_name, icon_names) { + for (const QString& icon_name : icon_names) { QListWidgetItem* item = new QListWidgetItem(IconLoader::Load(icon_name), QString(), ui_->icon); item->setData(Qt::UserRole, icon_name); } // Load the transcode formats the first time the dialog is shown - foreach(const TranscoderPreset & preset, Transcoder::GetAllPresets()) { + for (const TranscoderPreset& preset : Transcoder::GetAllPresets()) { ui_->transcode_format->addItem(preset.name_, preset.type_); } ui_->transcode_format->model()->sort(0); @@ -142,7 +142,7 @@ void DeviceProperties::UpdateHardwareInfo() { QVariantMap info = lister->DeviceHardwareInfo(id); // Remove empty items - foreach(const QString & key, info.keys()) { + for (const QString& key : info.keys()) { if (info[key].isNull() || info[key].toString().isEmpty()) info.remove(key); } @@ -154,7 +154,7 @@ void DeviceProperties::UpdateHardwareInfo() { int row = 0; AddHardwareInfo(row++, tr("Model"), lister->DeviceModel(id)); AddHardwareInfo(row++, tr("Manufacturer"), lister->DeviceManufacturer(id)); - foreach(const QString & key, info.keys()) { + for (const QString& key : info.keys()) { AddHardwareInfo(row++, tr(key.toAscii()), info[key].toString()); } @@ -278,7 +278,7 @@ void DeviceProperties::UpdateFormatsFinished() { // Populate supported types list ui_->supported_formats->clear(); - foreach(Song::FileType type, supported_formats_) { + for (Song::FileType type : supported_formats_) { QListWidgetItem* item = new QListWidgetItem(Song::TextForFiletype(type)); ui_->supported_formats->addItem(item); } diff --git a/src/devices/deviceview.cpp b/src/devices/deviceview.cpp index 8fa2b9220..36592a7df 100644 --- a/src/devices/deviceview.cpp +++ b/src/devices/deviceview.cpp @@ -361,7 +361,7 @@ void DeviceView::mouseDoubleClickEvent(QMouseEvent* event) { SongList DeviceView::GetSelectedSongs() const { QModelIndexList selected_merged_indexes = selectionModel()->selectedRows(); SongList songs; - foreach(const QModelIndex & merged_index, selected_merged_indexes) { + for (const QModelIndex& merged_index : selected_merged_indexes) { QModelIndex library_index = MapToLibrary(merged_index); if (!library_index.isValid()) continue; @@ -421,7 +421,9 @@ void DeviceView::Delete() { void DeviceView::Organise() { SongList songs = GetSelectedSongs(); QStringList filenames; - foreach(const Song & song, songs) { filenames << song.url().toLocalFile(); } + for (const Song& song : songs) { + filenames << song.url().toLocalFile(); + } organise_dialog_->SetCopy(true); organise_dialog_->SetFilenames(filenames); diff --git a/src/devices/giolister.cpp b/src/devices/giolister.cpp index 2f07a25da..1979f189c 100644 --- a/src/devices/giolister.cpp +++ b/src/devices/giolister.cpp @@ -260,7 +260,7 @@ void GioLister::MountAdded(GMount* mount) { QMutexLocker l(&mutex_); // The volume might already exist - either mounted or unmounted. - foreach(const QString & id, devices_.keys()) { + for (const QString& id : devices_.keys()) { if (devices_[id].volume == info.volume) { old_id = id; break; @@ -430,14 +430,14 @@ void GioLister::DeviceInfo::ReadDriveInfo(GDrive* drive) { } QString GioLister::FindUniqueIdByMount(GMount* mount) const { - foreach(const DeviceInfo & info, devices_) { + for (const DeviceInfo& info : devices_) { if (info.mount == mount) return info.unique_id(); } return QString(); } QString GioLister::FindUniqueIdByVolume(GVolume* volume) const { - foreach(const DeviceInfo & info, devices_) { + for (const DeviceInfo& info : devices_) { if (info.volume == volume) return info.unique_id(); } return QString(); diff --git a/src/engines/gstengine.cpp b/src/engines/gstengine.cpp index 4b6d40113..c4bb229e8 100644 --- a/src/engines/gstengine.cpp +++ b/src/engines/gstengine.cpp @@ -659,7 +659,7 @@ shared_ptr GstEngine::CreatePipeline() { ret->set_mono_playback(mono_playback_); ret->AddBufferConsumer(this); - foreach(BufferConsumer * consumer, buffer_consumers_) { + for (BufferConsumer* consumer : buffer_consumers_) { ret->AddBufferConsumer(consumer); } diff --git a/src/engines/gstenginepipeline.cpp b/src/engines/gstenginepipeline.cpp index 8936e4d66..ec8c0bbec 100644 --- a/src/engines/gstenginepipeline.cpp +++ b/src/engines/gstenginepipeline.cpp @@ -694,7 +694,7 @@ bool GstEnginePipeline::HandoffCallback(GstPad*, GstBuffer* buf, consumers = instance->buffer_consumers_; } - foreach(BufferConsumer * consumer, consumers) { + for (BufferConsumer* consumer : consumers) { gst_buffer_ref(buf); consumer->ConsumeBuffer(buf, instance->id()); } diff --git a/src/globalsearch/digitallyimportedsearchprovider.cpp b/src/globalsearch/digitallyimportedsearchprovider.cpp index 26046ed85..e777ef1c7 100644 --- a/src/globalsearch/digitallyimportedsearchprovider.cpp +++ b/src/globalsearch/digitallyimportedsearchprovider.cpp @@ -44,7 +44,7 @@ void DigitallyImportedSearchProvider::RecreateItems() { DigitallyImportedClient::ChannelList channels = service_->Channels(); - foreach(const DigitallyImportedClient::Channel & channel, channels) { + for (const DigitallyImportedClient::Channel& channel : channels) { Song song; service_->SongFromChannel(channel, &song); items << Item(song); diff --git a/src/globalsearch/globalsearch.cpp b/src/globalsearch/globalsearch.cpp index 7330b336f..59a4743ea 100644 --- a/src/globalsearch/globalsearch.cpp +++ b/src/globalsearch/globalsearch.cpp @@ -89,7 +89,7 @@ int GlobalSearch::SearchAsync(const QString& query) { if (url_provider_->LooksLikeUrl(query)) { url_provider_->SearchAsync(id, query); } else { - foreach(SearchProvider * provider, providers_.keys()) { + for (SearchProvider* provider : providers_.keys()) { if (!is_provider_usable(provider)) continue; pending_search_providers_[id]++; @@ -124,7 +124,7 @@ void GlobalSearch::CancelSearch(int id) { void GlobalSearch::timerEvent(QTimerEvent* e) { QMap::iterator it = delayed_searches_.find(e->timerId()); if (it != delayed_searches_.end()) { - foreach(SearchProvider * provider, it.value().providers_) { + for (SearchProvider* provider : it.value().providers_) { provider->SearchAsync(it.value().id_, it.value().query_); } delayed_searches_.erase(it); @@ -184,7 +184,9 @@ void GlobalSearch::ProviderDestroyedSlot(QObject* object) { // We have to abort any pending searches since we can't tell whether they // were on this provider. - foreach(int id, pending_search_providers_.keys()) { emit SearchFinished(id); } + for (int id : pending_search_providers_.keys()) { + emit SearchFinished(id); + } pending_search_providers_.clear(); } @@ -279,7 +281,7 @@ MimeData* GlobalSearch::LoadTracks(const SearchProvider::ResultList& results) { SearchProvider* first_provider = results[0].provider_; SearchProvider::ResultList results_copy; - foreach(const SearchProvider::Result & result, results) { + for (const SearchProvider::Result& result : results) { if (result.provider_ == first_provider) { results_copy << result; } @@ -325,7 +327,7 @@ void GlobalSearch::ReloadSettings() { QSettings s; s.beginGroup(kSettingsGroup); - foreach(SearchProvider * provider, providers_.keys()) { + for (SearchProvider* provider : providers_.keys()) { QVariant value = s.value("enabled_" + provider->id()); if (!value.isValid()) continue; const bool enabled = value.toBool(); @@ -340,7 +342,7 @@ void GlobalSearch::ReloadSettings() { void GlobalSearch::SaveProvidersSettings() { QSettings s; s.beginGroup(kSettingsGroup); - foreach(SearchProvider * provider, providers_.keys()) { + for (SearchProvider* provider : providers_.keys()) { s.setValue("enabled_" + provider->id(), providers_[provider].enabled_); } } @@ -349,9 +351,9 @@ QStringList GlobalSearch::GetSuggestions(int count) { QStringList ret; // Get count suggestions from each provider - foreach(SearchProvider * provider, providers_.keys()) { + for (SearchProvider* provider : providers_.keys()) { if (is_provider_enabled(provider) && provider->can_give_suggestions()) { - foreach(QString suggestion, provider->GetSuggestions(count)) { + for (QString suggestion : provider->GetSuggestions(count)) { suggestion = suggestion.trimmed().toLower(); if (!suggestion.isEmpty()) { diff --git a/src/globalsearch/globalsearchmodel.cpp b/src/globalsearch/globalsearchmodel.cpp index 3fa1611d8..0ff0b4655 100644 --- a/src/globalsearch/globalsearchmodel.cpp +++ b/src/globalsearch/globalsearchmodel.cpp @@ -64,7 +64,7 @@ void GlobalSearchModel::AddResults(const SearchProvider::ResultList& results) { sort_index = provider_sort_indices_[provider]; } - foreach(const SearchProvider::Result & result, results) { + for (const SearchProvider::Result& result : results) { QStandardItem* parent = invisibleRootItem(); // Find (or create) the container nodes for this result if we can. @@ -198,7 +198,9 @@ void GlobalSearchModel::Clear() { SearchProvider::ResultList GlobalSearchModel::GetChildResults( const QModelIndexList& indexes) const { QList items; - foreach(const QModelIndex & index, indexes) { items << itemFromIndex(index); } + for (const QModelIndex& index : indexes) { + items << itemFromIndex(index); + } return GetChildResults(items); } @@ -207,7 +209,7 @@ SearchProvider::ResultList GlobalSearchModel::GetChildResults( SearchProvider::ResultList results; QSet visited; - foreach(QStandardItem * item, items) { + for (QStandardItem* item : items) { GetChildResults(item, &results, &visited); } @@ -272,7 +274,7 @@ void GlobalSearchModel::SetGroupBy(const LibraryModel::Grouping& grouping, // Reset the model and re-add all the results using the new grouping. Clear(); - foreach(const SearchProvider::ResultList & result_list, results) { + for (const SearchProvider::ResultList& result_list : results) { AddResults(result_list); } } diff --git a/src/globalsearch/globalsearchsettingspage.cpp b/src/globalsearch/globalsearchsettingspage.cpp index ba32bd8e3..460d63a81 100644 --- a/src/globalsearch/globalsearchsettingspage.cpp +++ b/src/globalsearch/globalsearchsettingspage.cpp @@ -60,9 +60,8 @@ void GlobalSearchSettingsPage::Load() { // Add the ones in the configured list first ui_->sources->clear(); - foreach( - const QString & id, - s.value("provider_order", QStringList() << "library").toStringList()) { + for (const QString& id : + s.value("provider_order", QStringList() << "library").toStringList()) { // Find a matching provider for this id for (QList::iterator it = providers.begin(); it != providers.end(); ++it) { @@ -75,7 +74,7 @@ void GlobalSearchSettingsPage::Load() { } // Now add any others that are remaining - foreach(SearchProvider * provider, providers) { + for (SearchProvider* provider : providers) { AddProviderItem(engine, provider); } diff --git a/src/globalsearch/globalsearchview.cpp b/src/globalsearch/globalsearchview.cpp index 9302f2c33..9d6231c1f 100644 --- a/src/globalsearch/globalsearchview.cpp +++ b/src/globalsearch/globalsearchview.cpp @@ -225,7 +225,7 @@ void GlobalSearchView::ReloadSettings() { bool any_disabled = false; - foreach(SearchProvider * provider, providers) { + for (SearchProvider* provider : providers) { QWidget* parent = ui_->enabled_list; if (!engine_->is_provider_usable(provider)) { parent = ui_->disabled_list; @@ -389,7 +389,7 @@ MimeData* GlobalSearchView::SelectedMimeData() { // Get items for these indexes QList items; - foreach(const QModelIndex & index, indexes) { + for (const QModelIndex& index : indexes) { items << (front_model_->itemFromIndex(front_proxy_->mapToSource(index))); } @@ -471,7 +471,7 @@ bool GlobalSearchView::ResultsContextMenuEvent(QContextMenuEvent* event) { ui_->results->selectionModel() && ui_->results->selectionModel()->hasSelection(); - foreach(QAction * action, context_actions_) { + for (QAction* action : context_actions_) { action->setEnabled(enable_context_actions); } @@ -565,7 +565,7 @@ void GlobalSearchView::SetGroupBy(const LibraryModel::Grouping& g) { s.setValue("group_by3", int(g.third)); // Make sure the correct action is checked. - foreach(QAction * action, group_by_actions_->actions()) { + for (QAction* action : group_by_actions_->actions()) { if (action->property("group_by").isNull()) continue; if (g == action->property("group_by").value()) { diff --git a/src/globalsearch/groovesharksearchprovider.cpp b/src/globalsearch/groovesharksearchprovider.cpp index 24b9206fd..522e7db33 100644 --- a/src/globalsearch/groovesharksearchprovider.cpp +++ b/src/globalsearch/groovesharksearchprovider.cpp @@ -64,7 +64,7 @@ void GroovesharkSearchProvider::SearchDone(int id, const SongList& songs) { const int global_search_id = state.orig_id_; ResultList ret; - foreach(const Song & song, songs) { + for (const Song& song : songs) { Result result(this); result.metadata_ = song; @@ -84,7 +84,7 @@ void GroovesharkSearchProvider::AlbumSearchResult( MaybeSearchFinished(global_search_id); return; } - foreach(const quint64 album_id, albums_ids) { + for (const quint64 album_id : albums_ids) { pending_searches_[album_id] = PendingState(global_search_id, QStringList()); } } @@ -121,7 +121,7 @@ void GroovesharkSearchProvider::AlbumSongsLoaded(quint64 id, const PendingState state = pending_searches_.take(id); const int global_search_id = state.orig_id_; ResultList ret; - foreach(const Song & s, songs) { + for (const Song& s : songs) { Result result(this); result.metadata_ = s; ret << result; diff --git a/src/globalsearch/icecastsearchprovider.cpp b/src/globalsearch/icecastsearchprovider.cpp index a0ad688e7..ab78db194 100644 --- a/src/globalsearch/icecastsearchprovider.cpp +++ b/src/globalsearch/icecastsearchprovider.cpp @@ -30,7 +30,7 @@ SearchProvider::ResultList IcecastSearchProvider::Search(int id, IcecastBackend::StationList stations = backend_->GetStations(query); ResultList ret; - foreach(const IcecastBackend::Station & station, stations) { + for (const IcecastBackend::Station& station : stations) { if (ret.count() > 3) break; Result result(this); diff --git a/src/globalsearch/lastfmsearchprovider.cpp b/src/globalsearch/lastfmsearchprovider.cpp index 4634918aa..b1e2b9fcf 100644 --- a/src/globalsearch/lastfmsearchprovider.cpp +++ b/src/globalsearch/lastfmsearchprovider.cpp @@ -59,17 +59,17 @@ void LastFMSearchProvider::RecreateItems() { const QStringList tags = service_->SavedTagRadioNames(); const QStringList friends = service_->FriendNames(); - foreach(const QString & name, artists) { + for (const QString& name : artists) { items << Item(tr(LastFMService::kTitleArtist).arg(name), QUrl(QString(LastFMService::kUrlArtist).arg(name)), name); } - foreach(const QString & name, tags) { + for (const QString& name : tags) { items << Item(tr(LastFMService::kTitleTag).arg(name), QUrl(QString(LastFMService::kUrlTag).arg(name)), name); } - foreach(const QString & name, friends) { + for (const QString& name : friends) { items << Item(tr("Last.fm Radio Station - %1").arg(name), QUrl("lastfm://user/" + name + "/library"), name); items << Item(tr("Last.fm Mix Radio - %1").arg(name), diff --git a/src/globalsearch/savedradiosearchprovider.cpp b/src/globalsearch/savedradiosearchprovider.cpp index 8c1590442..8ceffeae8 100644 --- a/src/globalsearch/savedradiosearchprovider.cpp +++ b/src/globalsearch/savedradiosearchprovider.cpp @@ -37,7 +37,7 @@ SavedRadioSearchProvider::SavedRadioSearchProvider(SavedRadio* service, void SavedRadioSearchProvider::RecreateItems() { QList items; - foreach(const SavedRadio::Stream & stream, service_->Streams()) { + for (const SavedRadio::Stream& stream : service_->Streams()) { Item item; item.metadata_.set_title(stream.name_); item.metadata_.set_url(stream.url_); diff --git a/src/globalsearch/searchprovider.cpp b/src/globalsearch/searchprovider.cpp index 4398251f9..17d2e4c03 100644 --- a/src/globalsearch/searchprovider.cpp +++ b/src/globalsearch/searchprovider.cpp @@ -55,7 +55,7 @@ QStringList SearchProvider::TokenizeQuery(const QString& query) { } bool SearchProvider::Matches(const QStringList& tokens, const QString& string) { - foreach(const QString & token, tokens) { + for (const QString& token : tokens) { if (!string.contains(token, Qt::CaseInsensitive)) { return false; } @@ -125,7 +125,9 @@ MimeData* SearchProvider::LoadTracks(const ResultList& results) { mime_data = new MimeData; } else { SongList songs; - foreach(const Result & result, results) { songs << result.metadata_; } + for (const Result& result : results) { + songs << result.metadata_; + } if (internet_service()) { InternetSongMimeData* internet_song_mime_data = @@ -140,7 +142,9 @@ MimeData* SearchProvider::LoadTracks(const ResultList& results) { } QList urls; - foreach(const Result & result, results) { urls << result.metadata_.url(); } + for (const Result& result : results) { + urls << result.metadata_.url(); + } mime_data->setUrls(urls); return mime_data; diff --git a/src/globalsearch/simplesearchprovider.cpp b/src/globalsearch/simplesearchprovider.cpp index daa5db966..ff7784848 100644 --- a/src/globalsearch/simplesearchprovider.cpp +++ b/src/globalsearch/simplesearchprovider.cpp @@ -61,9 +61,9 @@ SearchProvider::ResultList SimpleSearchProvider::Search(int id, const QStringList tokens = TokenizeQuery(query); QMutexLocker l(&items_mutex_); - foreach(const Item & item, items_) { + for (const Item& item : items_) { bool matched = true; - foreach(const QString & token, tokens) { + for (const QString& token : tokens) { if (!item.keyword_.contains(token, Qt::CaseInsensitive) && !item.metadata_.title().contains(token, Qt::CaseInsensitive) && !safe_words_.contains(token, Qt::CaseInsensitive)) { diff --git a/src/globalsearch/somafmsearchprovider.cpp b/src/globalsearch/somafmsearchprovider.cpp index a1680300e..80833d8dd 100644 --- a/src/globalsearch/somafmsearchprovider.cpp +++ b/src/globalsearch/somafmsearchprovider.cpp @@ -42,7 +42,7 @@ void SomaFMSearchProvider::LoadArtAsync(int id, const Result& result) { void SomaFMSearchProvider::RecreateItems() { QList items; - foreach(const SomaFMService::Stream & stream, service_->Streams()) { + for (const SomaFMService::Stream& stream : service_->Streams()) { Item item; item.metadata_ = stream.ToSong(service_->name()); item.keyword_ = stream.title_; diff --git a/src/globalsearch/soundcloudsearchprovider.cpp b/src/globalsearch/soundcloudsearchprovider.cpp index 1c9966402..296c0c4d3 100644 --- a/src/globalsearch/soundcloudsearchprovider.cpp +++ b/src/globalsearch/soundcloudsearchprovider.cpp @@ -57,7 +57,7 @@ void SoundCloudSearchProvider::SearchDone(int id, const SongList& songs) { const int global_search_id = state.orig_id_; ResultList ret; - foreach(const Song & song, songs) { + for (const Song& song : songs) { Result result(this); result.metadata_ = song; diff --git a/src/internet/boxservice.cpp b/src/internet/boxservice.cpp index d1cd91e82..56b19ef46 100644 --- a/src/internet/boxservice.cpp +++ b/src/internet/boxservice.cpp @@ -199,7 +199,7 @@ void BoxService::FetchFolderItemsFinished(QNetworkReply* reply, FetchRecursiveFolderItems(folder_id, offset + entries.size()); } - foreach(const QVariant & e, entries) { + for (const QVariant& e : entries) { QVariantMap entry = e.toMap(); if (entry["type"].toString() == "folder") { FetchRecursiveFolderItems(entry["id"].toInt()); @@ -273,7 +273,7 @@ void BoxService::FetchEventsFinished(QNetworkReply* reply) { s.setValue("cursor", response["next_stream_position"]); QVariantList entries = response["entries"].toList(); - foreach(const QVariant & e, entries) { + for (const QVariant& e : entries) { QVariantMap event = e.toMap(); QString type = event["event_type"].toString(); QVariantMap source = event["source"].toMap(); diff --git a/src/internet/digitallyimportedclient.cpp b/src/internet/digitallyimportedclient.cpp index a4b4c056f..1a9d256b3 100644 --- a/src/internet/digitallyimportedclient.cpp +++ b/src/internet/digitallyimportedclient.cpp @@ -127,7 +127,7 @@ DigitallyImportedClient::ChannelList DigitallyImportedClient::ParseChannelList( QVariantList filters = data["channel_filters"].toList(); - foreach(const QVariant & filter, filters) { + for (const QVariant& filter : filters) { // Find the filter called "All" QVariantMap filter_map = filter.toMap(); if (filter_map.value("name", QString()).toString() != "All") continue; @@ -135,7 +135,7 @@ DigitallyImportedClient::ChannelList DigitallyImportedClient::ParseChannelList( // Add all its stations to the result QVariantList channels = filter_map.value("channels", QVariantList()).toList(); - foreach(const QVariant & channel_var, channels) { + for (const QVariant& channel_var : channels) { QVariantMap channel_map = channel_var.toMap(); Channel channel; diff --git a/src/internet/digitallyimportedservicebase.cpp b/src/internet/digitallyimportedservicebase.cpp index 025b72d28..a5a918b3f 100644 --- a/src/internet/digitallyimportedservicebase.cpp +++ b/src/internet/digitallyimportedservicebase.cpp @@ -127,7 +127,7 @@ void DigitallyImportedServiceBase::PopulateStreams() { if (root_->hasChildren()) root_->removeRows(0, root_->rowCount()); // Add each stream to the model - foreach(const DigitallyImportedClient::Channel & channel, saved_channels_) { + for (const DigitallyImportedClient::Channel& channel : saved_channels_) { Song song; SongFromChannel(channel, &song); diff --git a/src/internet/dropboxauthenticator.cpp b/src/internet/dropboxauthenticator.cpp index e5e8eac56..b4378ad30 100644 --- a/src/internet/dropboxauthenticator.cpp +++ b/src/internet/dropboxauthenticator.cpp @@ -52,7 +52,7 @@ namespace { QMap ParseParamList(const QString& params) { QMap ret; QStringList components = params.split("&"); - foreach(const QString & component, components) { + for (const QString& component : components) { QStringList pairs = component.split("="); if (pairs.size() != 2) { continue; @@ -136,7 +136,7 @@ QByteArray DropboxAuthenticator::GenerateAuthorisationHeader( params << Param("oauth_token", token); } QStringList encoded_params; - foreach(const Param & p, params) { + for (const Param& p : params) { encoded_params << QString("%1=\"%2\"").arg(p.first, p.second); } QString authorisation_header = QString("OAuth ") + encoded_params.join(", "); diff --git a/src/internet/dropboxservice.cpp b/src/internet/dropboxservice.cpp index b6863b7cc..f96b58cc6 100644 --- a/src/internet/dropboxservice.cpp +++ b/src/internet/dropboxservice.cpp @@ -111,7 +111,7 @@ void DropboxService::RequestFileListFinished(QNetworkReply* reply) { QVariantList contents = response["entries"].toList(); qLog(Debug) << "Delta found:" << contents.size(); - foreach(const QVariant & c, contents) { + for (const QVariant& c : contents) { QVariantList item = c.toList(); QString path = item[0].toString(); diff --git a/src/internet/googledriveclient.cpp b/src/internet/googledriveclient.cpp index a0b2b543a..1beeecb51 100644 --- a/src/internet/googledriveclient.cpp +++ b/src/internet/googledriveclient.cpp @@ -49,7 +49,7 @@ static const char* kClientSecret = "l3cWb8efUZsrBI4wmY3uKl6i"; QStringList File::parent_ids() const { QStringList ret; - foreach(const QVariant & var, data_["parents"].toList()) { + for (const QVariant& var : data_["parents"].toList()) { QVariantMap map(var.toMap()); if (map["isRoot"].toBool()) { @@ -216,7 +216,7 @@ void Client::ListChangesFinished(ListChangesResponse* response, // Emit the FilesFound signal for the files in the response. FileList files; QList files_deleted; - foreach(const QVariant & v, result["items"].toList()) { + for (const QVariant& v : result["items"].toList()) { QVariantMap change = v.toMap(); if (!change["deleted"].toBool()) { files << File(change["file"].toMap()); diff --git a/src/internet/googledriveservice.cpp b/src/internet/googledriveservice.cpp index b8312eaaa..952a66cf9 100644 --- a/src/internet/googledriveservice.cpp +++ b/src/internet/googledriveservice.cpp @@ -119,7 +119,7 @@ void GoogleDriveService::EnsureConnected() { } void GoogleDriveService::FilesFound(const QList& files) { - foreach(const google_drive::File & file, files) { + for (const google_drive::File& file : files) { if (!IsSupportedMimeType(file.mime_type())) { continue; } @@ -149,7 +149,7 @@ void GoogleDriveService::FilesFound(const QList& files) { } void GoogleDriveService::FilesDeleted(const QList& files) { - foreach(const QUrl & url, files) { + for (const QUrl& url : files) { Song song = library_backend_->GetSongByUrl(url); qLog(Debug) << "Deleting:" << url << song.title(); if (song.is_valid()) { @@ -187,7 +187,7 @@ void GoogleDriveService::ShowContextMenu(const QPoint& global_pos) { // Only show some actions if there are real songs selected bool songs_selected = false; - foreach(const QModelIndex & index, model()->selected_indexes()) { + for (const QModelIndex& index : model()->selected_indexes()) { const int type = index.data(LibraryModel::Role_Type).toInt(); if (type == LibraryItem::Type_Song || type == LibraryItem::Type_Container) { songs_selected = true; @@ -203,14 +203,14 @@ void GoogleDriveService::ShowContextMenu(const QPoint& global_pos) { void GoogleDriveService::OpenWithDrive() { // Map indexes to the actual library model. QModelIndexList library_indexes; - foreach(const QModelIndex & index, model()->selected_indexes()) { + for (const QModelIndex& index : model()->selected_indexes()) { if (index.model() == library_sort_model_) { library_indexes << library_sort_model_->mapToSource(index); } } // Ask the library for the songs for these indexes. - foreach(const Song & song, library_model_->GetChildSongs(library_indexes)) { + for (const Song& song : library_model_->GetChildSongs(library_indexes)) { QDesktopServices::openUrl( QUrl(QString(kDriveEditFileUrl).arg(song.url().path()))); } diff --git a/src/internet/groovesharkservice.cpp b/src/internet/groovesharkservice.cpp index ff02b3cf7..11722411d 100644 --- a/src/internet/groovesharkservice.cpp +++ b/src/internet/groovesharkservice.cpp @@ -237,7 +237,7 @@ void GroovesharkService::SearchAlbumsFinished(QNetworkReply* reply, int id) { QVariantList albums = result["albums"].toList(); QList ret; - foreach(const QVariant & v, albums) { + for (const QVariant& v : albums) { quint64 album_id = v.toMap()["AlbumID"].toULongLong(); GetAlbumSongs(album_id); ret << album_id; @@ -292,7 +292,7 @@ void GroovesharkService::SearchSongsFinished(QNetworkReply* reply) { task_search_id_ = 0; // Fill results list - foreach(const Song & song, songs) { + for (const Song& song : songs) { QStandardItem* child = CreateSongItem(song); search_->appendRow(child); } @@ -692,7 +692,7 @@ void GroovesharkService::UserPlaylistsRetrieved(QNetworkReply* reply) { QVariantMap result = ExtractResult(reply); QList playlists = ExtractPlaylistInfo(result); - foreach(const PlaylistInfo & playlist_info, playlists) { + for (const PlaylistInfo& playlist_info : playlists) { int playlist_id = playlist_info.id_; const QString& playlist_name = playlist_info.name_; QStandardItem* playlist_item = @@ -725,7 +725,7 @@ void GroovesharkService::PlaylistSongsRetrieved(QNetworkReply* reply, SongList songs = ExtractSongs(result); Song::SortSongsListAlphabetically(&songs); - foreach(const Song & song, songs) { + for (const Song& song : songs) { QStandardItem* child = CreateSongItem(song); child->setData(playlist_info->id_, Role_UserPlaylistId); child->setData(true, InternetModel::Role_CanBeModified); @@ -766,7 +766,7 @@ void GroovesharkService::UserFavoritesRetrieved(QNetworkReply* reply, SongList songs = ExtractSongs(result); Song::SortSongsListAlphabetically(&songs); - foreach(const Song & song, songs) { + for (const Song& song : songs) { QStandardItem* child = CreateSongItem(song); child->setData(true, InternetModel::Role_CanBeModified); @@ -800,7 +800,7 @@ void GroovesharkService::UserLibrarySongsRetrieved(QNetworkReply* reply, SongList songs = ExtractSongs(result); Song::SortSongsListAlphabetically(&songs); - foreach(const Song & song, songs) { + for (const Song& song : songs) { QStandardItem* child = CreateSongItem(song); child->setData(true, InternetModel::Role_CanBeModified); @@ -835,7 +835,7 @@ void GroovesharkService::PopularSongsMonthRetrieved(QNetworkReply* reply) { if (!popular_month_) return; - foreach(const Song & song, songs) { + for (const Song& song : songs) { QStandardItem* child = CreateSongItem(song); popular_month_->appendRow(child); } @@ -861,7 +861,7 @@ void GroovesharkService::PopularSongsTodayRetrieved(QNetworkReply* reply) { if (!popular_today_) return; - foreach(const Song & song, songs) { + for (const Song& song : songs) { QStandardItem* child = CreateSongItem(song); popular_today_->appendRow(child); } @@ -880,7 +880,7 @@ void GroovesharkService::SubscribedPlaylistsRetrieved(QNetworkReply* reply) { QVariantMap result = ExtractResult(reply); QList playlists = ExtractPlaylistInfo(result); - foreach(const PlaylistInfo & playlist_info, playlists) { + for (const PlaylistInfo& playlist_info : playlists) { int playlist_id = playlist_info.id_; const QString& playlist_name = playlist_info.name_; @@ -947,11 +947,11 @@ Song GroovesharkService::StartAutoplayTag(int tag_id, Song GroovesharkService::StartAutoplay(QVariantMap& autoplay_state) { QList parameters; QVariantList artists_ids_qvariant; - foreach(int artist_id, last_artists_ids_) { + for (int artist_id : last_artists_ids_) { artists_ids_qvariant << QVariant(artist_id); } QVariantList songs_ids_qvariant; - foreach(int song_id, last_songs_ids_) { + for (int song_id : last_songs_ids_) { songs_ids_qvariant << QVariant(song_id); } parameters << Param("artistIDs", artists_ids_qvariant) @@ -1071,7 +1071,9 @@ void GroovesharkService::DropMimeData(const QMimeData* data, // If dropped on Favorites list if (playlist_type == UserFavorites || parent_playlist_type == UserFavorites) { - foreach(int song_id, data_songs_ids) { AddUserFavoriteSong(song_id); } + for (int song_id : data_songs_ids) { + AddUserFavoriteSong(song_id); + } } else if (playlist_type == UserLibrary || parent_playlist_type == UserLibrary) { // FIXME: Adding songs to user libray doesn't work atm, but the problem @@ -1123,7 +1125,7 @@ QList GroovesharkService::playlistitem_actions(const Song& song) { QAction* add_to_playlists = new QAction( IconLoader::Load("list-add"), tr("Add to Grooveshark playlists"), this); QMenu* playlists_menu = new QMenu(); - foreach(PlaylistInfo playlist_info, playlists_.values()) { + for (PlaylistInfo playlist_info : playlists_.values()) { QAction* add_to_playlist = new QAction(playlist_info.name_, this); add_to_playlist->setData(playlist_info.id_); playlists_menu->addAction(add_to_playlist); @@ -1229,7 +1231,9 @@ void GroovesharkService::SetPlaylistSongs(int playlist_id, // Convert song ids to QVariant QVariantList songs_ids_qvariant; - foreach(int song_id, songs_ids) { songs_ids_qvariant << QVariant(song_id); } + for (int song_id : songs_ids) { + songs_ids_qvariant << QVariant(song_id); + } parameters << Param("playlistID", playlist_id) << Param("songIDs", songs_ids_qvariant); @@ -1421,7 +1425,9 @@ void GroovesharkService::AddUserLibrarySongs(const QList& songs_ids) { // Convert songs ids to QVariant QVariantList songs_ids_qvariant; - foreach(int song_id, songs_ids) { songs_ids_qvariant << QVariant(song_id); } + for (int song_id : songs_ids) { + songs_ids_qvariant << QVariant(song_id); + } QVariantList albums_ids_qvariant; QVariantList artists_ids_qvariant; @@ -1452,7 +1458,7 @@ void GroovesharkService::UserLibrarySongAdded(QNetworkReply* reply, void GroovesharkService::RemoveCurrentFromPlaylist() { const QModelIndexList& indexes(model()->selected_indexes()); QMap > playlists_songs_ids; - foreach(const QModelIndex & index, indexes) { + for (const QModelIndex& index : indexes) { if (index.parent().data(InternetModel::Role_Type).toInt() != InternetModel::Type_UserPlaylist) { @@ -1480,7 +1486,7 @@ void GroovesharkService::RemoveFromPlaylist( } QList songs_ids = playlists_[playlist_id].songs_ids_; - foreach(const int song_id, songs_ids_to_remove) { + for (const int song_id : songs_ids_to_remove) { songs_ids.removeOne(song_id); } @@ -1490,7 +1496,7 @@ void GroovesharkService::RemoveFromPlaylist( void GroovesharkService::RemoveCurrentFromFavorites() { const QModelIndexList& indexes(model()->selected_indexes()); QList songs_ids; - foreach(const QModelIndex & index, indexes) { + for (const QModelIndex& index : indexes) { if (index.parent().data(Role_PlaylistType).toInt() != UserFavorites) { continue; @@ -1515,7 +1521,7 @@ void GroovesharkService::RemoveFromFavorites( // Convert song ids to QVariant QVariantList songs_ids_qvariant; - foreach(const int song_id, songs_ids_to_remove) { + for (const int song_id : songs_ids_to_remove) { songs_ids_qvariant << QVariant(song_id); } @@ -1543,7 +1549,7 @@ void GroovesharkService::RemoveCurrentFromLibrary() { const QModelIndexList& indexes(model()->selected_indexes()); QList songs_ids; - foreach(const QModelIndex & index, indexes) { + for (const QModelIndex& index : indexes) { if (index.parent().data(Role_PlaylistType).toInt() != UserLibrary) { continue; @@ -1568,7 +1574,7 @@ void GroovesharkService::RemoveFromLibrary( // Convert song ids to QVariant QVariantList songs_ids_qvariant; - foreach(const int song_id, songs_ids_to_remove) { + for (const int song_id : songs_ids_to_remove) { songs_ids_qvariant << QVariant(song_id); } QVariantList albums_ids_qvariant; @@ -1620,7 +1626,7 @@ QNetworkReply* GroovesharkService::CreateRequest(const QString& method_name, request_params.insert("header", header); QVariantMap parameters; - foreach(const Param & param, params) { + for (const Param& param : params) { parameters.insert(param.first, param.second); } request_params.insert("parameters", parameters); @@ -1650,7 +1656,7 @@ QNetworkReply* GroovesharkService::CreateRequest(const QString& method_name, void GroovesharkService::RequestSslErrors(const QList& errors) { QNetworkReply* reply = qobject_cast(sender()); - foreach(const QSslError & error, errors) { + for (const QSslError& error : errors) { emit StreamError("SSL error occurred in Grooveshark request for " + reply->url().toString() + ": " + error.errorString()); } @@ -1760,7 +1766,7 @@ QList GroovesharkService::ExtractSongsIds(const QVariantMap& result) { QList GroovesharkService::ExtractSongsIds(const QList& urls) { QList songs_ids; - foreach(const QUrl & url, urls) { + for (const QUrl& url : urls) { int song_id = ExtractSongId(url); if (song_id) { songs_ids << song_id; @@ -1786,7 +1792,7 @@ QList GroovesharkService::ExtractPlaylistInfo( QList playlists; // Get playlists info - foreach(const QVariant & playlist_qvariant, playlists_qvariant) { + for (const QVariant& playlist_qvariant : playlists_qvariant) { QVariantMap playlist = playlist_qvariant.toMap(); int playlist_id = playlist["PlaylistID"].toInt(); QString playlist_name = playlist["PlaylistName"].toString(); diff --git a/src/internet/icecastbackend.cpp b/src/internet/icecastbackend.cpp index 2d19e352c..c449d8cf2 100644 --- a/src/internet/icecastbackend.cpp +++ b/src/internet/icecastbackend.cpp @@ -105,7 +105,9 @@ IcecastBackend::StationList IcecastBackend::GetStations(const QString& filter, sql += " WHERE " + where_clauses.join(" AND "); } QSqlQuery q(sql, db); - foreach(const QString & value, bound_items) { q.addBindValue(value); } + for (const QString& value : bound_items) { + q.addBindValue(value); + } q.exec(); if (db_->CheckErrors(q)) return ret; @@ -152,7 +154,7 @@ void IcecastBackend::ClearAndAddStations(const StationList& stations) { db); // Add these ones - foreach(const Station & station, stations) { + for (const Station& station : stations) { q.bindValue(":name", station.name); q.bindValue(":url", station.url); q.bindValue(":mime_type", station.mime_type); diff --git a/src/internet/icecastmodel.cpp b/src/internet/icecastmodel.cpp index 70e78b7b0..c6d0e133a 100644 --- a/src/internet/icecastmodel.cpp +++ b/src/internet/icecastmodel.cpp @@ -81,7 +81,7 @@ void IcecastModel::PopulateGenre(IcecastItem* parent, const QString& genre, QChar last_divider; IcecastBackend::StationList stations = backend_->GetStations(filter_, genre); - foreach(const IcecastBackend::Station & station, stations) { + for (const IcecastBackend::Station& station : stations) { QChar divider_char = DividerKey(station.name); if (create_dividers && !divider_char.isNull() && divider_char != last_divider) { @@ -104,7 +104,7 @@ void IcecastModel::PopulateGenre(IcecastItem* parent, const QString& genre, void IcecastModel::AddGenres(const QStringList& genres, bool create_dividers) { QChar last_divider; - foreach(const QString & genre, genres) { + for (const QString& genre : genres) { QChar divider_char = DividerKey(genre); if (create_dividers && divider_char != last_divider) { last_divider = divider_char; @@ -196,7 +196,7 @@ QMimeData* IcecastModel::mimeData(const QModelIndexList& indexes) const { SongMimeData* data = new SongMimeData; QList urls; - foreach(const QModelIndex & index, indexes) { + for (const QModelIndex& index : indexes) { IcecastItem* item = IndexToItem(index); if (!item || item->type != IcecastItem::Type_Station) continue; diff --git a/src/internet/icecastservice.cpp b/src/internet/icecastservice.cpp index d5a76f55b..e8a8df534 100644 --- a/src/internet/icecastservice.cpp +++ b/src/internet/icecastservice.cpp @@ -165,7 +165,7 @@ struct StationEquality { QStringList FilterGenres(const QStringList& genres) { QStringList ret; - foreach(const QString & genre, genres) { + for (const QString& genre : genres) { if (genre.length() < 2) continue; if (genre.contains("ÃÂ")) continue; // Broken unicode. if (genre.contains(QRegExp("^#x[0-9a-f][0-9a-f]"))) @@ -210,10 +210,12 @@ void IcecastService::ParseDirectoryFinished( QSet genre_set = genres.keys().toSet(); // Merge genres with only 1 or 2 stations into "Other". - foreach(const QString & genre, genre_set) { + for (const QString& genre : genre_set) { if (genres.count(genre) < 3) { const QList& small_genre = genres.values(genre); - foreach(IcecastBackend::Station * s, small_genre) { s->genre = "Other"; } + for (IcecastBackend::Station* s : small_genre) { + s->genre = "Other"; + } } } diff --git a/src/internet/internetmodel.cpp b/src/internet/internetmodel.cpp index 93a59664e..1a35f1e07 100644 --- a/src/internet/internetmodel.cpp +++ b/src/internet/internetmodel.cpp @@ -249,7 +249,7 @@ QMimeData* InternetModel::mimeData(const QModelIndexList& indexes) const { QModelIndexList new_indexes; QModelIndex last_valid_index; - foreach(const QModelIndex & index, indexes) { + for (const QModelIndex& index : indexes) { if (!IsPlayable(index)) continue; last_valid_index = index; @@ -299,7 +299,7 @@ void InternetModel::ShowContextMenu( current_index_ = merged_model_->mapToSource(current_merged_model_index); selected_indexes_.clear(); - foreach(const QModelIndex & index, selected_merged_model_indexes) { + for (const QModelIndex& index : selected_merged_model_indexes) { selected_indexes_ << merged_model_->mapToSource(index); } @@ -308,7 +308,7 @@ void InternetModel::ShowContextMenu( } void InternetModel::ReloadSettings() { - foreach(InternetService * service, sServices->values()) { + for (InternetService* service : sServices->values()) { service->ReloadSettings(); } } diff --git a/src/internet/internetviewcontainer.cpp b/src/internet/internetviewcontainer.cpp index d632d6974..c9beec672 100644 --- a/src/internet/internetviewcontainer.cpp +++ b/src/internet/internetviewcontainer.cpp @@ -133,7 +133,7 @@ void InternetViewContainer::FocusOnFilter(QKeyEvent* event) { void InternetViewContainer::SetHeaderHeight(int height) { QTimeLine* animation = qobject_cast(sender()); QWidget* header = nullptr; - foreach(QWidget * h, headers_.keys()) { + for (QWidget* h : headers_.keys()) { if (headers_[h].animation_ == animation) { header = h; break; diff --git a/src/internet/jamendodynamicplaylist.cpp b/src/internet/jamendodynamicplaylist.cpp index 4109b9e56..b6daa0712 100644 --- a/src/internet/jamendodynamicplaylist.cpp +++ b/src/internet/jamendodynamicplaylist.cpp @@ -156,7 +156,7 @@ void JamendoDynamicPlaylist::Fetch() { } current_items_.clear(); - foreach(const Song & song, songs) { + for (const Song& song : songs) { if (song.is_valid()) current_items_ << PlaylistItemPtr(new JamendoPlaylistItem(song)); } diff --git a/src/internet/jamendoservice.cpp b/src/internet/jamendoservice.cpp index 3661a6379..99d50d131 100644 --- a/src/internet/jamendoservice.cpp +++ b/src/internet/jamendoservice.cpp @@ -287,7 +287,7 @@ void JamendoService::InsertTrackIds(const TrackIdList& ids) const { .arg(kTrackIdsTable, kTrackIdsColumn), db); - foreach(int id, ids) { + for (int id : ids) { insert.bindValue(":id", id); if (!insert.exec()) { qLog(Warning) << "Query failed" << insert.lastQuery(); diff --git a/src/internet/lastfmservice.cpp b/src/internet/lastfmservice.cpp index 2f594817a..0647b00f8 100644 --- a/src/internet/lastfmservice.cpp +++ b/src/internet/lastfmservice.cpp @@ -706,7 +706,9 @@ void LastFMService::RefreshFriendsFinished(QNetworkReply* reply) { } QStringList names; - foreach(const lastfm::User & f, friends) { names << f.name(); } + for (const lastfm::User& f : friends) { + names << f.name(); + } friend_names_.Update(names); @@ -718,7 +720,7 @@ void LastFMService::PopulateFriendsList() { if (friends_list_->hasChildren()) friends_list_->removeRows(0, friends_list_->rowCount()); - foreach(const QString & name, friend_names_) { + for (const QString& name : friend_names_) { Song song; song.set_url(QUrl("lastfm://user/" + name + "/library")); song.set_title(tr("Last.fm Library - %1").arg(name)); @@ -743,7 +745,7 @@ void LastFMService::RefreshNeighboursFinished(QNetworkReply* reply) { if (neighbours_list_->hasChildren()) neighbours_list_->removeRows(0, neighbours_list_->rowCount()); - foreach(const lastfm::User & n, neighbours) { + for (const lastfm::User& n : neighbours) { Song song; song.set_url(QUrl("lastfm://user/" + n.name() + "/library")); song.set_title(tr("Last.fm Library - %1").arg(n.name())); @@ -829,7 +831,7 @@ void LastFMService::RestoreList(const QString& name, const QString& url_pattern, const QStringList keys = SavedArtistOrTagRadioNames(name); - foreach(const QString & key, keys) { + for (const QString& key : keys) { QString url; if (name == "custom" && key.startsWith("lastfm://")) { url = key; @@ -883,7 +885,7 @@ void LastFMService::FetchMoreTracksFinished(QNetworkReply* reply) { lastfm::XmlQuery query(lastfm::compat::EmptyXmlQuery()); if (lastfm::compat::ParseQuery(reply->readAll(), &query)) { const XmlQuery& playlist = query["playlist"]; - foreach(const XmlQuery & q, playlist["trackList"].children("track")) { + for (const XmlQuery& q : playlist["trackList"].children("track")) { lastfm::MutableTrack t; t.setUrl(QUrl(q["location"].text())); t.setExtra("trackauth", q["extension"]["trackauth"].text()); diff --git a/src/internet/magnatunedownloaddialog.cpp b/src/internet/magnatunedownloaddialog.cpp index 69ed878e0..5a171a7af 100644 --- a/src/internet/magnatunedownloaddialog.cpp +++ b/src/internet/magnatunedownloaddialog.cpp @@ -70,7 +70,7 @@ void MagnatuneDownloadDialog::Show(const SongList& songs) { ui_->albums->clear(); QSet sku_codes; - foreach(const Song & song, songs) { + for (const Song& song : songs) { if (!sku_codes.contains(song.comment())) { sku_codes.insert(song.comment()); diff --git a/src/internet/oauthenticator.cpp b/src/internet/oauthenticator.cpp index f92338890..664225dbb 100644 --- a/src/internet/oauthenticator.cpp +++ b/src/internet/oauthenticator.cpp @@ -74,7 +74,7 @@ void OAuthenticator::RequestAccessToken(const QByteArray& code, << Param("redirect_uri", url.toString()); QStringList params; - foreach(const Param & p, parameters) { + for (const Param& p : parameters) { params.append(QString("%1=%2").arg( p.first, QString(QUrl::toPercentEncoding(p.second)))); } @@ -128,7 +128,7 @@ void OAuthenticator::RefreshAuthorisation(const QString& token_endpoint, << Param("grant_type", "refresh_token") << Param("refresh_token", refresh_token); QStringList params; - foreach(const Param & p, parameters) { + for (const Param& p : parameters) { params.append(QString("%1=%2").arg( p.first, QString(QUrl::toPercentEncoding(p.second)))); } diff --git a/src/internet/savedradio.cpp b/src/internet/savedradio.cpp index ce5d409b5..b3bd08b78 100644 --- a/src/internet/savedradio.cpp +++ b/src/internet/savedradio.cpp @@ -52,8 +52,7 @@ QStandardItem* SavedRadio::CreateRootItem() { void SavedRadio::LazyPopulate(QStandardItem* item) { switch (item->data(InternetModel::Role_Type).toInt()) { case InternetModel::Type_Service: - foreach(const Stream & stream, streams_) - AddStreamToList(stream, root_); + for (const Stream& stream : streams_) AddStreamToList(stream, root_); break; diff --git a/src/internet/skydriveservice.cpp b/src/internet/skydriveservice.cpp index 87431fd0c..435051a65 100644 --- a/src/internet/skydriveservice.cpp +++ b/src/internet/skydriveservice.cpp @@ -115,7 +115,7 @@ void SkydriveService::ListFilesFinished(QNetworkReply* reply) { qLog(Debug) << response; QVariantList files = response["data"].toList(); - foreach(const QVariant & f, files) { + for (const QVariant& f : files) { QVariantMap file = f.toMap(); if (file["type"].toString() == "audio") { QString mime_type = GuessMimeTypeForFile(file["name"].toString()); diff --git a/src/internet/somafmservice.cpp b/src/internet/somafmservice.cpp index f29377ba1..8d7db7a30 100644 --- a/src/internet/somafmservice.cpp +++ b/src/internet/somafmservice.cpp @@ -226,7 +226,7 @@ void SomaFMServiceBase::RefreshStreams() { void SomaFMServiceBase::PopulateStreams() { if (root_->hasChildren()) root_->removeRows(0, root_->rowCount()); - foreach(const Stream & stream, streams_) { + for (const Stream& stream : streams_) { QStandardItem* item = new QStandardItem(QIcon(":last.fm/icon_radio.png"), QString()); item->setText(stream.title_); diff --git a/src/internet/soundcloudservice.cpp b/src/internet/soundcloudservice.cpp index 1a4a3f79b..c7bdb6075 100644 --- a/src/internet/soundcloudservice.cpp +++ b/src/internet/soundcloudservice.cpp @@ -151,7 +151,7 @@ void SoundCloudService::SearchFinished(QNetworkReply* reply, int task_id) { SongList songs = ExtractSongs(ExtractResult(reply)); // Fill results list - foreach(const Song & song, songs) { + for (const Song& song : songs) { QStandardItem* child = CreateSongItem(song); search_->appendRow(child); } @@ -206,7 +206,7 @@ QNetworkReply* SoundCloudService::CreateRequest(const QString& ressource_name, url.setPath(ressource_name); url.addQueryItem("client_id", kApiClientId); - foreach(const Param & param, params) { + for (const Param& param : params) { url.addQueryItem(param.first, param.second); } @@ -232,7 +232,7 @@ SongList SoundCloudService::ExtractSongs(const QVariant& result) { SongList songs; QVariantList q_variant_list = result.toList(); - foreach(const QVariant & q, q_variant_list) { + for (const QVariant& q : q_variant_list) { Song song = ExtractSong(q.toMap()); if (song.is_valid()) { songs << song; diff --git a/src/internet/spotifyblobdownloader.cpp b/src/internet/spotifyblobdownloader.cpp index b19e3a17b..b51c63ef7 100644 --- a/src/internet/spotifyblobdownloader.cpp +++ b/src/internet/spotifyblobdownloader.cpp @@ -78,7 +78,7 @@ void SpotifyBlobDownloader::Start() { << "libspotify.so.12.1.45" << "libspotify.so.12.1.45" + QString(kSignatureSuffix); - foreach(const QString & filename, filenames) { + for (const QString& filename : filenames) { const QUrl url(SpotifyService::kBlobDownloadUrl + version_ + "/" + filename); qLog(Info) << "Downloading" << url; @@ -103,7 +103,7 @@ void SpotifyBlobDownloader::ReplyFinished() { } // Is everything finished? - foreach(QNetworkReply * reply, replies_) { + for (QNetworkReply* reply : replies_) { if (!reply->isFinished()) { return; } @@ -113,7 +113,7 @@ void SpotifyBlobDownloader::ReplyFinished() { QMap file_data; QStringList signature_filenames; - foreach(QNetworkReply * reply, replies_) { + for (QNetworkReply* reply : replies_) { const QString filename = reply->url().path().section('/', -1, -1); if (filename.endsWith(kSignatureSuffix)) { @@ -134,7 +134,7 @@ void SpotifyBlobDownloader::ReplyFinished() { } // Verify signatures - foreach(const QString & signature_filename, signature_filenames) { + for (const QString& signature_filename : signature_filenames) { QString actual_filename = signature_filename; actual_filename.remove(kSignatureSuffix); @@ -152,7 +152,7 @@ void SpotifyBlobDownloader::ReplyFinished() { // Make the destination directory and write the files into it QDir().mkpath(path_); - foreach(const QString & filename, file_data.keys()) { + for (const QString& filename : file_data.keys()) { const QString dest_path = path_ + "/" + filename; if (filename.endsWith(kSignatureSuffix)) continue; @@ -197,7 +197,7 @@ void SpotifyBlobDownloader::ReplyProgress() { int progress = 0; int total = 0; - foreach(QNetworkReply * reply, replies_) { + for (QNetworkReply* reply : replies_) { progress += reply->bytesAvailable(); total += reply->rawHeader("Content-Length").toInt(); } @@ -211,7 +211,7 @@ void SpotifyBlobDownloader::Cancel() { deleteLater(); } void SpotifyBlobDownloader::ShowError(const QString& message) { // Stop any remaining replies before showing the dialog so they don't // carry on in the background - foreach(QNetworkReply * reply, replies_) { + for (QNetworkReply* reply : replies_) { disconnect(reply, 0, this, 0); reply->abort(); } diff --git a/src/internet/spotifyserver.cpp b/src/internet/spotifyserver.cpp index 566d6cd24..ec2b56e69 100644 --- a/src/internet/spotifyserver.cpp +++ b/src/internet/spotifyserver.cpp @@ -47,7 +47,7 @@ void SpotifyServer::NewConnection() { qLog(Info) << "Connection from port" << socket->peerPort(); // Send any login messages that were queued before the client connected - foreach(const pb::spotify::Message & message, queued_login_messages_) { + for (const pb::spotify::Message& message : queued_login_messages_) { SendOrQueueMessage(message); } queued_login_messages_.clear(); @@ -105,7 +105,7 @@ void SpotifyServer::MessageArrived(const pb::spotify::Message& message) { if (response.success()) { // Send any messages that were queued before the client logged in - foreach(const pb::spotify::Message & message, queued_messages_) { + for (const pb::spotify::Message& message : queued_messages_) { SendOrQueueMessage(message); } queued_messages_.clear(); diff --git a/src/internet/spotifyservice.cpp b/src/internet/spotifyservice.cpp index 82ef17648..ad86edb56 100644 --- a/src/internet/spotifyservice.cpp +++ b/src/internet/spotifyservice.cpp @@ -393,7 +393,7 @@ void SpotifyService::PlaylistsUpdated(const pb::spotify::Playlists& response) { } // Remove and recreate the other playlists - foreach(QStandardItem * item, playlists_) { + for (QStandardItem* item : playlists_) { item->parent()->removeRow(item->row()); } playlists_.clear(); @@ -460,7 +460,7 @@ void SpotifyService::ToplistLoaded( } QStandardItem* SpotifyService::PlaylistBySpotifyIndex(int index) const { - foreach(QStandardItem * item, playlists_) { + for (QStandardItem* item : playlists_) { if (item->data(Role_UserPlaylistIndex).toInt() == index) { return item; } @@ -637,7 +637,7 @@ void SpotifyService::SearchResults( ClearSearchResults(); // Fill results list - foreach(const Song & song, songs) { + for (const Song& song : songs) { QStandardItem* child = CreateSongItem(song); search_->appendRow(child); } diff --git a/src/internet/ubuntuoneauthenticator.cpp b/src/internet/ubuntuoneauthenticator.cpp index 74be05984..da957f81b 100644 --- a/src/internet/ubuntuoneauthenticator.cpp +++ b/src/internet/ubuntuoneauthenticator.cpp @@ -92,7 +92,7 @@ QByteArray UbuntuOneAuthenticator::GenerateAuthorisationHeader( << Param("oauth_signature_method", "PLAINTEXT"); qSort(parameters.begin(), parameters.end()); QStringList encoded_params; - foreach(const Param & p, parameters) { + for (const Param& p : parameters) { encoded_params << QString("%1=%2").arg(p.first, p.second); } @@ -102,7 +102,7 @@ QByteArray UbuntuOneAuthenticator::GenerateAuthorisationHeader( // Construct authorisation header parameters << Param("oauth_signature", signature); QStringList header_params; - foreach(const Param & p, parameters) { + for (const Param& p : parameters) { header_params << QString("%1=\"%2\"").arg(p.first, p.second); } QString authorisation_header = header_params.join(", "); diff --git a/src/internet/ubuntuoneservice.cpp b/src/internet/ubuntuoneservice.cpp index 7ee16461a..9ee1e2e03 100644 --- a/src/internet/ubuntuoneservice.cpp +++ b/src/internet/ubuntuoneservice.cpp @@ -111,7 +111,7 @@ void UbuntuOneService::VolumeListRequestFinished(QNetworkReply* reply) { QJson::Parser parser; QVariantList result = parser.parse(reply).toList(); - foreach(const QVariant & v, result) { + for (const QVariant& v : result) { RequestFileList(v.toMap()["node_path"].toString()); } } @@ -132,7 +132,7 @@ void UbuntuOneService::FileListRequestFinished(QNetworkReply* reply) { QVariantMap result = parser.parse(reply).toMap(); QVariantList children = result["children"].toList(); - foreach(const QVariant & c, children) { + for (const QVariant& c : children) { QVariantMap child = c.toMap(); if (child["kind"].toString() == "file") { QString content_path = child["content_path"].toString(); diff --git a/src/library/library.cpp b/src/library/library.cpp index ae827c5e2..570817c58 100644 --- a/src/library/library.cpp +++ b/src/library/library.cpp @@ -179,7 +179,7 @@ void Library::WriteAllSongsStatisticsToFiles() { const int nb_songs = all_songs.size(); int i = 0; - foreach(const Song & song, all_songs) { + for (const Song& song : all_songs) { TagReaderClient::Instance()->UpdateSongStatisticsBlocking(song); TagReaderClient::Instance()->UpdateSongRatingBlocking(song); app_->task_manager()->SetTaskProgress(task_id, ++i, nb_songs); diff --git a/src/library/librarybackend.cpp b/src/library/librarybackend.cpp index d1f9bb37f..372aab3d7 100644 --- a/src/library/librarybackend.cpp +++ b/src/library/librarybackend.cpp @@ -93,7 +93,7 @@ void LibraryBackend::LoadDirectories() { QMutexLocker l(db_->Mutex()); QSqlDatabase db(db_->Connect()); - foreach(const Directory & dir, dirs) { + for (const Directory& dir : dirs) { emit DirectoryDiscovered(dir, SubdirsInDirectory(dir.id, db)); } } @@ -307,7 +307,7 @@ void LibraryBackend::AddOrUpdateSubdirs(const SubdirectoryList& subdirs) { db); ScopedTransaction transaction(&db); - foreach(const Subdirectory & subdir, subdirs) { + for (const Subdirectory& subdir : subdirs) { if (subdir.mtime == 0) { // Delete the subdirectory delete_query.bindValue(":id", subdir.directory_id); @@ -368,7 +368,7 @@ void LibraryBackend::AddOrUpdateSongs(const SongList& songs) { SongList added_songs; SongList deleted_songs; - foreach(const Song & song, songs) { + for (const Song& song : songs) { // Do a sanity check first - make sure the song's directory still exists // This is to fix a possible race condition when a directory is removed // while LibraryWatcher is scanning it. @@ -439,7 +439,7 @@ void LibraryBackend::UpdateMTimesOnly(const SongList& songs) { db); ScopedTransaction transaction(&db); - foreach(const Song & song, songs) { + for (const Song& song : songs) { q.bindValue(":mtime", song.mtime()); q.bindValue(":id", song.id()); q.exec(); @@ -458,7 +458,7 @@ void LibraryBackend::DeleteSongs(const SongList& songs) { QString("DELETE FROM %1 WHERE ROWID = :id").arg(fts_table_), db); ScopedTransaction transaction(&db); - foreach(const Song & song, songs) { + for (const Song& song : songs) { remove.bindValue(":id", song.id()); remove.exec(); db_->CheckErrors(remove); @@ -485,7 +485,7 @@ void LibraryBackend::MarkSongsUnavailable(const SongList& songs, db); ScopedTransaction transaction(&db); - foreach(const Song & song, songs) { + for (const Song& song : songs) { remove.bindValue(":id", song.id()); remove.exec(); db_->CheckErrors(remove); @@ -584,7 +584,9 @@ SongList LibraryBackend::GetSongsById(const QList& ids) { QSqlDatabase db(db_->Connect()); QStringList str_ids; - foreach(int id, ids) { str_ids << QString::number(id); } + for (int id : ids) { + str_ids << QString::number(id); + } return GetSongsById(str_ids, db); } @@ -954,7 +956,7 @@ void LibraryBackend::ForceCompilation(const QString& album, QSqlDatabase db(db_->Connect()); SongList deleted_songs, added_songs; - foreach(const QString & artist, artists) { + for (const QString& artist : artists) { // Get the songs before they're updated LibraryQuery query; query.SetColumnSpec("ROWID, " + Song::kColumnSpec); diff --git a/src/library/libraryfilterwidget.cpp b/src/library/libraryfilterwidget.cpp index 11f0287cf..cb61b659b 100644 --- a/src/library/libraryfilterwidget.cpp +++ b/src/library/libraryfilterwidget.cpp @@ -211,7 +211,7 @@ void LibraryFilterWidget::GroupingChanged(const LibraryModel::Grouping& g) { } // Now make sure the correct action is checked - foreach(QAction * action, group_by_group_->actions()) { + for (QAction* action : group_by_group_->actions()) { if (action->property("group_by").isNull()) continue; if (g == action->property("group_by").value()) { diff --git a/src/library/librarymodel.cpp b/src/library/librarymodel.cpp index cc0ef0560..1e1a9ece8 100644 --- a/src/library/librarymodel.cpp +++ b/src/library/librarymodel.cpp @@ -154,7 +154,7 @@ void LibraryModel::Init(bool async) { } void LibraryModel::SongsDiscovered(const SongList& songs) { - foreach(const Song & song, songs) { + for (const Song& song : songs) { // Sanity check to make sure we don't add songs that are outside the user's // filter if (!query_options_.Matches(song)) continue; @@ -250,7 +250,7 @@ void LibraryModel::SongsSlightlyChanged(const SongList& songs) { // This is called if there was a minor change to the songs that will not // normally require the library to be restructured. We can just update our // internal cache of Song objects without worrying about resetting the model. - foreach(const Song & song, songs) { + for (const Song& song : songs) { if (song_nodes_.contains(song.id())) { song_nodes_[song.id()]->metadata = song; } @@ -356,7 +356,7 @@ void LibraryModel::SongsDeleted(const SongList& songs) { // Delete the actual song nodes first, keeping track of each parent so we // might check to see if they're empty later. QSet parents; - foreach(const Song & song, songs) { + for (const Song& song : songs) { if (song_nodes_.contains(song.id())) { LibraryItem* node = song_nodes_[song.id()]; @@ -380,7 +380,7 @@ void LibraryModel::SongsDeleted(const SongList& songs) { // Now delete empty parents QSet divider_keys; while (!parents.isEmpty()) { - foreach(LibraryItem * node, parents) { + for (LibraryItem* node : parents) { parents.remove(node); if (node->children.count() != 0) continue; @@ -405,12 +405,12 @@ void LibraryModel::SongsDeleted(const SongList& songs) { } // Delete empty dividers - foreach(const QString & divider_key, divider_keys) { + for (const QString& divider_key : divider_keys) { if (!divider_nodes_.contains(divider_key)) continue; // Look to see if there are any other items still under this divider bool found = false; - foreach(LibraryItem * node, container_nodes_[0].values()) { + for (LibraryItem* node : container_nodes_[0].values()) { if (DividerKey(group_by_[0], node) == divider_key) { found = true; break; @@ -571,7 +571,7 @@ QVariant LibraryModel::data(const LibraryItem* item, int role) const { // if we have even one non editable item as a child, we ourselves // are not available for edit if (!item->children.isEmpty()) { - foreach(LibraryItem * child, item->children) { + for (LibraryItem* child : item->children) { if (!data(child, role).toBool()) { return false; } @@ -655,7 +655,7 @@ void LibraryModel::PostQuery(LibraryItem* parent, } // Step through the results - foreach(const SqlRow & row, result.rows) { + for (const SqlRow& row : result.rows) { // Create the item - it will get inserted into the model here LibraryItem* item = ItemFromQuery(child_type, signal, child_level == 0, parent, row, child_level); @@ -1098,7 +1098,7 @@ QMimeData* LibraryModel::mimeData(const QModelIndexList& indexes) const { data->backend = backend_; - foreach(const QModelIndex & index, indexes) { + for (const QModelIndex& index : indexes) { GetChildSongs(IndexToItem(index), &urls, &data->songs, &song_ids); } @@ -1128,8 +1128,8 @@ void LibraryModel::GetChildSongs(LibraryItem* item, QList* urls, qSort(children.begin(), children.end(), std::bind(&LibraryModel::CompareItems, this, _1, _2)); - foreach(LibraryItem * child, children) - GetChildSongs(child, urls, songs, song_ids); + for (LibraryItem* child : children) + GetChildSongs(child, urls, songs, song_ids); break; } @@ -1151,7 +1151,7 @@ SongList LibraryModel::GetChildSongs(const QModelIndexList& indexes) const { SongList ret; QSet song_ids; - foreach(const QModelIndex & index, indexes) { + for (const QModelIndex& index : indexes) { GetChildSongs(IndexToItem(index), &dontcare, &ret, &song_ids); } return ret; @@ -1244,8 +1244,8 @@ void LibraryModel::CreateSmartPlaylists() { s.beginWriteArray(backend_->songs_table(), playlist_index + unwritten_defaults); for (; version < default_smart_playlists_.count(); ++version) { - foreach(smart_playlists::GeneratorPtr gen, - default_smart_playlists_[version]) { + for (smart_playlists::GeneratorPtr gen : + default_smart_playlists_[version]) { SaveGenerator(&s, playlist_index++, gen); } } @@ -1329,7 +1329,7 @@ void LibraryModel::DeleteGenerator(const QModelIndex& index) { s.beginWriteArray(backend_->songs_table(), smart_playlist_node_->children.count()); int i = 0; - foreach(LibraryItem * item, smart_playlist_node_->children) { + for (LibraryItem* item : smart_playlist_node_->children) { s.setArrayIndex(i++); s.setValue("name", item->display_text); s.setValue("type", item->key); diff --git a/src/library/libraryquery.cpp b/src/library/libraryquery.cpp index ec7f0e5ad..cbdc8f99a 100644 --- a/src/library/libraryquery.cpp +++ b/src/library/libraryquery.cpp @@ -37,7 +37,7 @@ LibraryQuery::LibraryQuery(const QueryOptions& options) QStringList tokens( options.filter().split(QRegExp("\\s+"), QString::SkipEmptyParts)); QString query; - foreach(QString token, tokens) { + for (QString token : tokens) { token.remove('('); token.remove(')'); token.remove('"'); @@ -109,7 +109,7 @@ void LibraryQuery::AddWhere(const QString& column, const QVariant& value, // ignore 'literal' for IN if (!op.compare("IN", Qt::CaseInsensitive)) { QStringList final; - foreach(const QString & single_value, value.toStringList()) { + for (const QString& single_value : value.toStringList()) { final.append("?"); bound_values_ << single_value; } @@ -163,7 +163,9 @@ QSqlQuery LibraryQuery::Exec(QSqlDatabase db, const QString& songs_table, query_ = QSqlQuery(sql, db); // Bind values - foreach(const QVariant & value, bound_values_) { query_.addBindValue(value); } + for (const QVariant& value : bound_values_) { + query_.addBindValue(value); + } query_.exec(); return query_; diff --git a/src/library/libraryview.cpp b/src/library/libraryview.cpp index fe4cf2f41..471f65b64 100644 --- a/src/library/libraryview.cpp +++ b/src/library/libraryview.cpp @@ -256,7 +256,7 @@ bool LibraryView::RestoreLevelFocus(const QModelIndex& parent) { QModelIndex index = qobject_cast(model()) ->mapToSource(current); SongList songs = app_->library_model()->GetChildSongs(index); - foreach(const Song & song, songs) { + for (const Song& song : songs) { if (song == last_selected_song_) { setCurrentIndex(current); return true; @@ -450,7 +450,7 @@ void LibraryView::contextMenuEvent(QContextMenuEvent* e) { // number of editable non smart playlists selected int regular_editable = 0; - foreach(const QModelIndex & index, selected_indexes) { + for (const QModelIndex& index : selected_indexes) { int type = app_->library_model()->data(index, LibraryModel::Role_Type).toInt(); @@ -530,7 +530,7 @@ void LibraryView::ShowInVarious(bool on) { // node gets removed (due to all children removed), before the new one gets // added QMultiMap albums; - foreach(const Song & song, GetSelectedSongs()) { + for (const Song& song : GetSelectedSongs()) { if (albums.find(song.album(), song.artist()) == albums.end()) albums.insert(song.album(), song.artist()); } @@ -543,7 +543,7 @@ void LibraryView::ShowInVarious(bool on) { const QString album = albums.keys().first(); QList all_of_album = app_->library_backend()->GetSongsByAlbum(album); QSet other_artists; - foreach(const Song & s, all_of_album) { + for (const Song& s : all_of_album) { if (!albums.contains(album, s.artist()) && !other_artists.contains(s.artist())) { other_artists.insert(s.artist()); @@ -555,12 +555,14 @@ void LibraryView::ShowInVarious(bool on) { "this album to Various Artists as well?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes) { - foreach(const QString & s, other_artists) { albums.insert(album, s); } + for (const QString& s : other_artists) { + albums.insert(album, s); + } } } } - foreach(const QString & album, QSet::fromList(albums.keys())) { + for (const QString& album : QSet::fromList(albums.keys())) { app_->library_backend()->ForceCompilation(album, albums.values(album), on); } } @@ -733,7 +735,9 @@ void LibraryView::EditSmartPlaylistFinished() { void LibraryView::ShowInBrowser() { QList urls; - foreach(const Song & song, GetSelectedSongs()) { urls << song.url(); } + for (const Song& song : GetSelectedSongs()) { + urls << song.url(); + } Utilities::OpenInFileBrowser(urls); } diff --git a/src/library/librarywatcher.cpp b/src/library/librarywatcher.cpp index 8944664c4..7dd7cd6db 100644 --- a/src/library/librarywatcher.cpp +++ b/src/library/librarywatcher.cpp @@ -118,7 +118,7 @@ LibraryWatcher::ScanTransaction::~ScanTransaction() { if (watcher_->monitor_) { // Watch the new subdirectories - foreach(const Subdirectory & subdir, new_subdirs) { + for (const Subdirectory& subdir : new_subdirs) { watcher_->AddWatch(watcher_->watched_dirs_[dir_], subdir.path); } } @@ -143,7 +143,7 @@ SongList LibraryWatcher::ScanTransaction::FindSongsInSubdirectory( // TODO: Make this faster SongList ret; - foreach(const Song & song, cached_songs_) { + for (const Song& song : cached_songs_) { if (song.url().toLocalFile().section('/', 0, -2) == path) ret << song; } return ret; @@ -159,7 +159,7 @@ bool LibraryWatcher::ScanTransaction::HasSeenSubdir(const QString& path) { if (known_subdirs_dirty_) SetKnownSubdirs(watcher_->backend_->SubdirsInDirectory(dir_)); - foreach(const Subdirectory & subdir, known_subdirs_) { + for (const Subdirectory& subdir : known_subdirs_) { if (subdir.path == path && subdir.mtime != 0) return true; } return false; @@ -171,7 +171,7 @@ SubdirectoryList LibraryWatcher::ScanTransaction::GetImmediateSubdirs( SetKnownSubdirs(watcher_->backend_->SubdirsInDirectory(dir_)); SubdirectoryList ret; - foreach(const Subdirectory & subdir, known_subdirs_) { + for (const Subdirectory& subdir : known_subdirs_) { if (subdir.path.left(subdir.path.lastIndexOf(QDir::separator())) == path && subdir.mtime != 0) { ret << subdir; @@ -204,7 +204,7 @@ void LibraryWatcher::AddDirectory(const Directory& dir, ScanTransaction transaction(this, dir.id, true); transaction.SetKnownSubdirs(subdirs); transaction.AddToProgressMax(subdirs.count()); - foreach(const Subdirectory & subdir, subdirs) { + for (const Subdirectory& subdir : subdirs) { if (stop_requested_) return; if (scan_on_startup_) ScanSubdirectory(subdir.path, subdir, &transaction); @@ -225,7 +225,7 @@ void LibraryWatcher::ScanSubdirectory(const QString& path, // Do not scan symlinked dirs that are already in collection if (path_info.isSymLink()) { QString real_path = path_info.symLinkTarget(); - foreach(const Directory & dir, watched_dirs_) { + for (const Directory& dir : watched_dirs_) { if (real_path.startsWith(dir.path)) { t->AddToProgress(1); return; @@ -248,7 +248,7 @@ void LibraryWatcher::ScanSubdirectory(const QString& path, // so we need to look and see if any of our children don't exist any more. // If one has been removed, "rescan" it to get the deleted songs SubdirectoryList previous_subdirs = t->GetImmediateSubdirs(path); - foreach(const Subdirectory & subdir, previous_subdirs) { + for (const Subdirectory& subdir : previous_subdirs) { if (!QFile::exists(subdir.path) && subdir.path != path) { t->AddToProgressMax(1); ScanSubdirectory(subdir.path, subdir, t, true); @@ -296,7 +296,7 @@ void LibraryWatcher::ScanSubdirectory(const QString& path, QSet cues_processed; // Now compare the list from the database with the list of files on disk - foreach(const QString & file, files_on_disk) { + for (const QString& file : files_on_disk) { if (stop_requested_) return; // associated cue @@ -370,7 +370,7 @@ void LibraryWatcher::ScanSubdirectory(const QString& path, // choose an image for the song(s) QString image = ImageForSong(file, album_art); - foreach(Song song, song_list) { + for (Song song : song_list) { song.set_directory_id(t->dir()); if (song.art_automatic().isEmpty()) song.set_art_automatic(image); @@ -380,7 +380,7 @@ void LibraryWatcher::ScanSubdirectory(const QString& path, } // Look for deleted songs - foreach(const Song & song, songs_in_db) { + for (const Song& song : songs_in_db) { if (!song.is_unavailable() && !files_on_disk.contains(song.url().toLocalFile())) { qLog(Debug) << "Song deleted from disk:" << song.url().toLocalFile(); @@ -404,7 +404,7 @@ void LibraryWatcher::ScanSubdirectory(const QString& path, // Recurse into the new subdirs that we found t->AddToProgressMax(my_new_subdirs.count()); - foreach(const Subdirectory & my_new_subdir, my_new_subdirs) { + for (const Subdirectory& my_new_subdir : my_new_subdirs) { if (stop_requested_) return; ScanSubdirectory(my_new_subdir.path, my_new_subdir, t, true); } @@ -421,14 +421,14 @@ void LibraryWatcher::UpdateCueAssociatedSongs(const QString& file, SongList old_sections = backend_->GetSongsByUrl(QUrl::fromLocalFile(file)); QHash sections_map; - foreach(const Song & song, old_sections) { + for (const Song& song : old_sections) { sections_map[song.beginning_nanosec()] = song; } QSet used_ids; // update every song that's in the cue and library - foreach(Song cue_song, cue_parser_->Load(&cue, matching_cue, path)) { + for (Song cue_song : cue_parser_->Load(&cue, matching_cue, path)) { cue_song.set_directory_id(t->dir()); Song matching = sections_map[cue_song.beginning_nanosec()]; @@ -443,7 +443,7 @@ void LibraryWatcher::UpdateCueAssociatedSongs(const QString& file, } // sections that are now missing - foreach(const Song & matching, old_sections) { + for (const Song& matching : old_sections) { if (!used_ids.contains(matching.id())) { t->deleted_songs << matching; } @@ -459,8 +459,8 @@ void LibraryWatcher::UpdateNonCueAssociatedSong(const QString& file, // 'raw' (cueless) song and we just remove the rest of the sections // from the library if (cue_deleted) { - foreach(const Song & song, - backend_->GetSongsByUrl(QUrl::fromLocalFile(file))) { + for (const Song& song : + backend_->GetSongsByUrl(QUrl::fromLocalFile(file))) { if (!song.IsMetadataEqual(matching_song)) { t->deleted_songs << song; } @@ -493,8 +493,7 @@ SongList LibraryWatcher::ScanNewFile(const QString& file, const QString& path, // Ignore FILEs pointing to other media files. Also, watch out for incorrect // media files. Playlist parser for CUEs considers every entry in sheet // valid and we don't want invalid media getting into library! - foreach(const Song & cue_song, - cue_parser_->Load(&cue, matching_cue, path)) { + for (const Song& cue_song : cue_parser_->Load(&cue, matching_cue, path)) { if (cue_song.url().toLocalFile() == file) { if (TagReaderClient::Instance()->IsMediaFileBlocking(file)) { song_list << cue_song; @@ -579,7 +578,7 @@ void LibraryWatcher::RemoveDirectory(const Directory& dir) { watched_dirs_.remove(dir.id); // Stop watching the directory's subdirectories - foreach(const QString & subdir_path, subdir_mapping_.keys(dir)) { + for (const QString& subdir_path : subdir_mapping_.keys(dir)) { fs_watcher_->RemovePath(subdir_path); subdir_mapping_.remove(subdir_path); } @@ -588,7 +587,7 @@ void LibraryWatcher::RemoveDirectory(const Directory& dir) { bool LibraryWatcher::FindSongByPath(const SongList& list, const QString& path, Song* out) { // TODO: Make this faster - foreach(const Song & song, list) { + for (const Song& song : list) { if (song.url().toLocalFile() == path) { *out = song; return true; @@ -616,12 +615,12 @@ void LibraryWatcher::DirectoryChanged(const QString& subdir) { } void LibraryWatcher::RescanPathsNow() { - foreach(int dir, rescan_queue_.keys()) { + for (int dir : rescan_queue_.keys()) { if (stop_requested_) return; ScanTransaction transaction(this, dir, false); transaction.AddToProgressMax(rescan_queue_[dir].count()); - foreach(const QString & path, rescan_queue_[dir]) { + for (const QString& path : rescan_queue_[dir]) { if (stop_requested_) return; Subdirectory subdir; subdir.directory_id = dir; @@ -643,10 +642,10 @@ QString LibraryWatcher::PickBestImage(const QStringList& images) { QStringList filtered; - foreach(const QString & filter_text, best_image_filters_) { + for (const QString& filter_text : best_image_filters_) { // the images in the images list are represented by a full path, // so we need to isolate just the filename - foreach(const QString & image, images) { + for (const QString& image : images) { QFileInfo file_info(image); QString filename(file_info.fileName()); if (filename.contains(filter_text, Qt::CaseInsensitive)) @@ -667,7 +666,7 @@ QString LibraryWatcher::PickBestImage(const QStringList& images) { int biggest_size = 0; QString biggest_path; - foreach(const QString & path, filtered) { + for (const QString& path : filtered) { QImage image(path); if (image.isNull()) continue; @@ -713,7 +712,7 @@ void LibraryWatcher::ReloadSettings() { QStringList filters = s.value("cover_art_patterns", QStringList() << "front" << "cover").toStringList(); - foreach(const QString & filter, filters) { + for (const QString& filter : filters) { QString s = filter.trimmed(); if (!s.isEmpty()) best_image_filters_ << s; } @@ -722,9 +721,9 @@ void LibraryWatcher::ReloadSettings() { fs_watcher_->Clear(); } else if (monitor_ && !was_monitoring_before) { // Add all directories to all QFileSystemWatchers again - foreach(const Directory & dir, watched_dirs_.values()) { + for (const Directory& dir : watched_dirs_.values()) { SubdirectoryList subdirs = backend_->SubdirsInDirectory(dir.id); - foreach(const Subdirectory & subdir, subdirs) { + for (const Subdirectory& subdir : subdirs) { AddWatch(dir, subdir.path); } } @@ -754,12 +753,12 @@ void LibraryWatcher::IncrementalScanNow() { PerformScan(true, false); } void LibraryWatcher::FullScanNow() { PerformScan(false, true); } void LibraryWatcher::PerformScan(bool incremental, bool ignore_mtimes) { - foreach(const Directory & dir, watched_dirs_.values()) { + for (const Directory& dir : watched_dirs_.values()) { ScanTransaction transaction(this, dir.id, incremental, ignore_mtimes); SubdirectoryList subdirs(transaction.GetAllSubdirs()); transaction.AddToProgressMax(subdirs.count()); - foreach(const Subdirectory & subdir, subdirs) { + for (const Subdirectory& subdir : subdirs) { if (stop_requested_) return; ScanSubdirectory(subdir.path, subdir, &transaction); diff --git a/src/moodbar/moodbaritemdelegate.cpp b/src/moodbar/moodbaritemdelegate.cpp index 5acd0648d..c3a20ff87 100644 --- a/src/moodbar/moodbaritemdelegate.cpp +++ b/src/moodbar/moodbaritemdelegate.cpp @@ -137,7 +137,7 @@ void MoodbarItemDelegate::StartLoadingData(const QUrl& url, Data* data) { bool MoodbarItemDelegate::RemoveFromCacheIfIndexesInvalid(const QUrl& url, Data* data) { - foreach(const QPersistentModelIndex & index, data->indexes_) { + for (const QPersistentModelIndex& index : data->indexes_) { if (index.isValid()) { return false; } @@ -148,7 +148,7 @@ bool MoodbarItemDelegate::RemoveFromCacheIfIndexesInvalid(const QUrl& url, } void MoodbarItemDelegate::ReloadAllColors() { - foreach(const QUrl & url, data_.keys()) { + for (const QUrl& url : data_.keys()) { Data* data = data_[url]; if (data->state_ == Data::State_Loaded) { @@ -252,7 +252,7 @@ void MoodbarItemDelegate::ImageLoaded(const QUrl& url, const QSortFilterProxyModel* filter = playlist->proxy(); // Update all the indices with the new pixmap. - foreach(const QPersistentModelIndex & index, data->indexes_) { + for (const QPersistentModelIndex& index : data->indexes_) { if (index.isValid() && index.sibling(index.row(), Playlist::Column_Filename).data().toUrl() == url) { diff --git a/src/moodbar/moodbarloader.cpp b/src/moodbar/moodbarloader.cpp index f81bd00c2..adef8c813 100644 --- a/src/moodbar/moodbarloader.cpp +++ b/src/moodbar/moodbarloader.cpp @@ -93,7 +93,7 @@ MoodbarLoader::Result MoodbarLoader::Load(const QUrl& url, QByteArray* data, // Check if a mood file exists for this file already const QString filename(url.toLocalFile()); - foreach(const QString & possible_mood_file, MoodFilenames(filename)) { + for (const QString& possible_mood_file : MoodFilenames(filename)) { QFile f(possible_mood_file); if (f.open(QIODevice::ReadOnly)) { qLog(Info) << "Loading moodbar data from" << possible_mood_file; diff --git a/src/moodbar/moodbarproxystyle.cpp b/src/moodbar/moodbarproxystyle.cpp index b24ff1cd0..83cd7ab2a 100644 --- a/src/moodbar/moodbarproxystyle.cpp +++ b/src/moodbar/moodbarproxystyle.cpp @@ -362,7 +362,7 @@ void MoodbarProxyStyle::ShowContextMenu(const QPoint& pos) { } // Update the currently selected style - foreach(QAction * action, style_action_group_->actions()) { + for (QAction* action : style_action_group_->actions()) { if (MoodbarRenderer::MoodbarStyle(action->data().toInt()) == moodbar_style_) { action->setChecked(true); diff --git a/src/musicbrainz/acoustidclient.cpp b/src/musicbrainz/acoustidclient.cpp index 2e9351631..c98d2de5a 100644 --- a/src/musicbrainz/acoustidclient.cpp +++ b/src/musicbrainz/acoustidclient.cpp @@ -91,11 +91,11 @@ void AcoustidClient::RequestFinished(QNetworkReply* reply, int id) { return; } QVariantList results = result["results"].toList(); - foreach(const QVariant & v, results) { + for (const QVariant& v : results) { QVariantMap r = v.toMap(); if (r.contains("recordings")) { QVariantList recordings = r["recordings"].toList(); - foreach(const QVariant & recording, recordings) { + for (const QVariant& recording : recordings) { QVariantMap o = recording.toMap(); if (o.contains("id")) { emit Finished(id, o["id"].toString()); diff --git a/src/musicbrainz/musicbrainzclient.cpp b/src/musicbrainz/musicbrainzclient.cpp index f8edfc9ba..a82279cc1 100644 --- a/src/musicbrainz/musicbrainzclient.cpp +++ b/src/musicbrainz/musicbrainzclient.cpp @@ -118,7 +118,7 @@ void MusicBrainzClient::DiscIdRequestFinished(QNetworkReply* reply) { if (token == QXmlStreamReader::StartElement && reader.name() == "recording") { ResultList tracks = ParseTrack(&reader); - foreach(const Result & track, tracks) { + for (const Result& track : tracks) { if (!track.title_.isEmpty()) { ret << track; } @@ -148,7 +148,7 @@ void MusicBrainzClient::RequestFinished(QNetworkReply* reply, int id) { if (reader.readNext() == QXmlStreamReader::StartElement && reader.name() == "recording") { ResultList tracks = ParseTrack(&reader); - foreach(const Result & track, tracks) { + for (const Result& track : tracks) { if (!track.title_.isEmpty()) { ret << track; } @@ -190,7 +190,7 @@ MusicBrainzClient::ResultList MusicBrainzClient::ParseTrack( if (releases.isEmpty()) { ret << result; } else { - foreach(const Release & release, releases) { + for (const Release& release : releases) { ret << release.CopyAndMergeInto(result); } } diff --git a/src/musicbrainz/tagfetcher.cpp b/src/musicbrainz/tagfetcher.cpp index 6836e98e3..17309ca4f 100644 --- a/src/musicbrainz/tagfetcher.cpp +++ b/src/musicbrainz/tagfetcher.cpp @@ -54,7 +54,7 @@ void TagFetcher::StartFetch(const SongList& songs) { connect(fingerprint_watcher_, SIGNAL(resultReadyAt(int)), SLOT(FingerprintFound(int))); - foreach(const Song & song, songs) { + for (const Song& song : songs) { emit Progress(song, tr("Fingerprinting song")); } } @@ -117,7 +117,7 @@ void TagFetcher::TagsFetched(int index, const Song& original_song = songs_[index]; SongList songs_guessed; - foreach(const MusicBrainzClient::Result & result, results) { + for (const MusicBrainzClient::Result& result : results) { Song song; song.Init(result.title_, result.artist_, result.album_, result.duration_msec_ * kNsecPerMsec); diff --git a/src/networkremote/outgoingdatacreator.cpp b/src/networkremote/outgoingdatacreator.cpp index 61347095e..3907b28fc 100644 --- a/src/networkremote/outgoingdatacreator.cpp +++ b/src/networkremote/outgoingdatacreator.cpp @@ -63,7 +63,7 @@ void OutgoingDataCreator::SetClients(QList* clients) { connect(fetcher_, SIGNAL(ResultReady(int, SongInfoFetcher::Result)), SLOT(SendLyrics(int, SongInfoFetcher::Result))); - foreach(SongInfoProvider * provider, provider_list_) { + for (SongInfoProvider* provider : provider_list_) { fetcher_->AddProvider(provider); } @@ -98,21 +98,21 @@ void OutgoingDataCreator::CheckEnabledProviders() { << "darklyrics.com"; QVariant saved_order = s.value("search_order", default_order); - foreach(const QVariant & name, saved_order.toList()) { + for (const QVariant& name : saved_order.toList()) { SongInfoProvider* provider = ProviderByName(name.toString()); if (provider) ordered_providers << provider; } // Enable all the providers in the list and rank them int relevance = 100; - foreach(SongInfoProvider * provider, ordered_providers) { + for (SongInfoProvider* provider : ordered_providers) { provider->set_enabled(true); qobject_cast(provider)->set_relevance(relevance--); } // Any lyric providers we don't have in ordered_providers are considered // disabled - foreach(SongInfoProvider * provider, fetcher_->providers()) { + for (SongInfoProvider* provider : fetcher_->providers()) { if (qobject_cast(provider) && !ordered_providers.contains(provider)) { provider->set_enabled(false); @@ -122,7 +122,7 @@ void OutgoingDataCreator::CheckEnabledProviders() { SongInfoProvider* OutgoingDataCreator::ProviderByName(const QString& name) const { - foreach(SongInfoProvider * provider, fetcher_->providers()) { + for (SongInfoProvider* provider : fetcher_->providers()) { if (UltimateLyricsProvider* lyrics = qobject_cast(provider)) { if (lyrics->name() == name) return provider; @@ -137,8 +137,7 @@ void OutgoingDataCreator::SendDataToClients(pb::remote::Message* msg) { return; } - RemoteClient* client; - foreach(client, *clients_) { + for (RemoteClient* client : *clients_) { // Do not send data to downloaders if (client->isDownloader()) { if (client->State() != QTcpSocket::ConnectedState) { @@ -207,8 +206,8 @@ void OutgoingDataCreator::SendAllPlaylists() { pb::remote::ResponsePlaylists* playlists = msg.mutable_response_playlists(); // Get all playlists, even ones that are hidden in the UI. - foreach(const PlaylistBackend::Playlist & p, - app_->playlist_backend()->GetAllPlaylists()) { + for (const PlaylistBackend::Playlist& p : + app_->playlist_backend()->GetAllPlaylists()) { bool playlist_open = app_->playlist_manager()->IsPlaylistOpen(p.id); int item_count = playlist_open ? app_playlists.at(p.id)->rowCount() : 0; @@ -553,7 +552,7 @@ void OutgoingDataCreator::SendLyrics(int id, msg.set_type(pb::remote::LYRICS); pb::remote::ResponseLyrics* response = msg.mutable_response_lyrics(); - foreach(const CollapsibleInfoPane::Data & data, result.info_) { + for (const CollapsibleInfoPane::Data& data : result.info_) { // If the size is zero, do not send the provider UltimateLyricsLyric* editor = qobject_cast(data.content_object_); @@ -707,7 +706,7 @@ void OutgoingDataCreator::SendAlbum(RemoteClient* client, const Song& song) { SongList album = app_->library_backend()->GetSongsByAlbum(song.album()); - foreach(Song s, album) { + for (Song s : album) { DownloadItem item(s, album.indexOf(s) + 1, album.size()); download_queue_[client].append(item); } @@ -723,13 +722,13 @@ void OutgoingDataCreator::SendPlaylist(RemoteClient* client, int playlist_id) { // Count the local songs int count = 0; - foreach(Song s, song_list) { + for (Song s : song_list) { if (s.url().scheme() == "file") { count++; } } - foreach(Song s, song_list) { + for (Song s : song_list) { // Only local files! if (s.url().scheme() == "file") { DownloadItem item(s, song_list.indexOf(s) + 1, count); diff --git a/src/networkremote/tinysvcmdns.cpp b/src/networkremote/tinysvcmdns.cpp index 2b102e5cc..b4e70b858 100644 --- a/src/networkremote/tinysvcmdns.cpp +++ b/src/networkremote/tinysvcmdns.cpp @@ -29,7 +29,7 @@ TinySVCMDNS::TinySVCMDNS() { // Get all network interfaces QList network_interfaces = QNetworkInterface::allInterfaces(); - foreach(QNetworkInterface network_interface, network_interfaces) { + for (QNetworkInterface network_interface : network_interfaces) { // Only use up and non loopback interfaces if (network_interface.flags().testFlag(network_interface.IsUp) && !network_interface.flags().testFlag(network_interface.IsLoopBack)) { @@ -42,8 +42,8 @@ TinySVCMDNS::TinySVCMDNS() { QList network_address_entries = network_interface.addressEntries(); - foreach(QNetworkAddressEntry network_address_entry, - network_address_entries) { + for (QNetworkAddressEntry network_address_entry : + network_address_entries) { QHostAddress host_address = network_address_entry.ip(); if (host_address.protocol() == QAbstractSocket::IPv4Protocol) { ipv4 = qToBigEndian(host_address.toIPv4Address()); @@ -61,7 +61,9 @@ TinySVCMDNS::TinySVCMDNS() { } TinySVCMDNS::~TinySVCMDNS() { - foreach(mdnsd * mdnsd, mdnsd_) { mdnsd_stop(mdnsd); } + for (mdnsd* mdnsd : mdnsd_) { + mdnsd_stop(mdnsd); + } } void TinySVCMDNS::PublishInternal(const QString& domain, const QString& type, @@ -70,7 +72,7 @@ void TinySVCMDNS::PublishInternal(const QString& domain, const QString& type, // Some pointless text, so tinymDNS publishes the service correctly. const char* txt[] = {"cat=nyan", nullptr}; - foreach(mdnsd * mdnsd, mdnsd_) { + for (mdnsd* mdnsd : mdnsd_) { mdnsd_register_svc(mdnsd, name.constData(), QString(type + ".local").toUtf8().constData(), port, nullptr, txt); diff --git a/src/networkremote/zeroconf.cpp b/src/networkremote/zeroconf.cpp index f46b73d79..f817a1766 100644 --- a/src/networkremote/zeroconf.cpp +++ b/src/networkremote/zeroconf.cpp @@ -39,7 +39,7 @@ Zeroconf* Zeroconf::GetZeroconf() { QByteArray Zeroconf::TruncateName(const QString& name) { QTextCodec* codec = QTextCodec::codecForName("UTF-8"); QByteArray truncated_utf8; - foreach(QChar c, name) { + for (QChar c : name) { QByteArray rendered = codec->fromUnicode(&c, 1, nullptr); if (truncated_utf8.size() + rendered.size() >= 63) { break; diff --git a/src/playlist/playlist.cpp b/src/playlist/playlist.cpp index 02049b80d..2d1d9cb01 100644 --- a/src/playlist/playlist.cpp +++ b/src/playlist/playlist.cpp @@ -149,7 +149,9 @@ void Playlist::InsertSongItems(const SongList& songs, int pos, bool play_now, bool enqueue) { PlaylistItemList items; - foreach(const Song & song, songs) { items << PlaylistItemPtr(new T(song)); } + for (const Song& song : songs) { + items << PlaylistItemPtr(new T(song)); + } InsertItems(items, pos, play_now, enqueue); } @@ -473,7 +475,8 @@ int Playlist::NextVirtualIndex(int i, bool ignore_repeat_track) const { // Advance i until we find any track that is in the filter, skipping // the selected to be skipped while (i < virtual_items_.count() && - (!FilterContainsVirtualIndex(i) || item_at(virtual_items_[i])->GetShouldSkip())) { + (!FilterContainsVirtualIndex(i) || + item_at(virtual_items_[i])->GetShouldSkip())) { ++i; } return i; @@ -481,7 +484,7 @@ int Playlist::NextVirtualIndex(int i, bool ignore_repeat_track) const { // We need to advance i until we get something else on the same album Song last_song = current_item_metadata(); - for (int j=i+1 ; jGetShouldSkip()) { continue; } @@ -517,14 +520,15 @@ int Playlist::PreviousVirtualIndex(int i, bool ignore_repeat_track) const { --i; // Decrement i until we find any track that is in the filter - while (i>=0 && (!FilterContainsVirtualIndex(i) || item_at(virtual_items_[i])->GetShouldSkip())) + while (i >= 0 && (!FilterContainsVirtualIndex(i) || + item_at(virtual_items_[i])->GetShouldSkip())) --i; return i; } // We need to decrement i until we get something else on the same album Song last_song = current_item_metadata(); - for (int j=i-1 ; j>=0; --j) { + for (int j = i - 1; j >= 0; --j) { if (item_at(virtual_items_[j])->GetShouldSkip()) { continue; } @@ -793,8 +797,7 @@ bool Playlist::dropMimeData(const QMimeData* data, Qt::DropAction action, } else if (pid == own_pid) { // Drag from a different playlist PlaylistItemList items; - foreach(int row, source_rows) - items << source_playlist->item_at(row); + for (int row : source_rows) items << source_playlist->item_at(row); if (items.count() > kUndoItemLimit) { // Too big to keep in the undo stack. Also clear the stack because it @@ -808,7 +811,7 @@ bool Playlist::dropMimeData(const QMimeData* data, Qt::DropAction action, // Remove the items from the source playlist if it was a move event if (action == Qt::MoveAction) { - foreach(int row, source_rows) { + for (int row : source_rows) { source_playlist->undo_stack()->push( new PlaylistUndoCommands::RemoveItems(source_playlist, row, 1)); } @@ -878,7 +881,7 @@ void Playlist::MoveItemsWithoutUndo(const QList& source_rows, int pos) { // insertion point changes int offset = 0; int start = pos; - foreach(int source_row, source_rows) { + for (int source_row : source_rows) { moved_items << items_.takeAt(source_row - offset); if (pos > source_row) { start--; @@ -893,7 +896,7 @@ void Playlist::MoveItemsWithoutUndo(const QList& source_rows, int pos) { } // Update persistent indexes - foreach(const QModelIndex & pidx, persistentIndexList()) { + for (const QModelIndex& pidx : persistentIndexList()) { const int dest_offset = source_rows.indexOf(pidx.row()); if (dest_offset != -1) { // This index was moved @@ -901,7 +904,7 @@ void Playlist::MoveItemsWithoutUndo(const QList& source_rows, int pos) { pidx, index(start + dest_offset, pidx.column(), QModelIndex())); } else { int d = 0; - foreach(int source_row, source_rows) { + for (int source_row : source_rows) { if (pidx.row() > source_row) d--; } if (pidx.row() + d >= start) d += source_rows.count(); @@ -921,7 +924,7 @@ void Playlist::MoveItemsWithoutUndo(int start, const QList& dest_rows) { PlaylistItemList moved_items; int pos = start; - foreach(int dest_row, dest_rows) { + for (int dest_row : dest_rows) { if (dest_row < pos) start--; } @@ -935,13 +938,13 @@ void Playlist::MoveItemsWithoutUndo(int start, const QList& dest_rows) { // Put the items back in int offset = 0; - foreach(int dest_row, dest_rows) { + for (int dest_row : dest_rows) { items_.insert(dest_row, moved_items[offset]); offset++; } // Update persistent indexes - foreach(const QModelIndex & pidx, persistentIndexList()) { + for (const QModelIndex& pidx : persistentIndexList()) { if (pidx.row() >= start && pidx.row() < start + dest_rows.count()) { // This index was moved const int i = pidx.row() - start; @@ -951,7 +954,7 @@ void Playlist::MoveItemsWithoutUndo(int start, const QList& dest_rows) { int d = 0; if (pidx.row() >= start + dest_rows.count()) d -= dest_rows.count(); - foreach(int dest_row, dest_rows) { + for (int dest_row : dest_rows) { if (pidx.row() + d > dest_row) d++; } @@ -974,13 +977,15 @@ void Playlist::InsertItems(const PlaylistItemList& itemsIn, int pos, // exercise vetoes SongList songs; - foreach(PlaylistItemPtr item, items) { songs << item->Metadata(); } + for (PlaylistItemPtr item : items) { + songs << item->Metadata(); + } const int song_count = songs.length(); QSet vetoed; - foreach(SongInsertVetoListener * listener, veto_listeners_) { - foreach(const Song & song, - listener->AboutToInsertSongs(GetAllSongs(), songs)) { + for (SongInsertVetoListener* listener : veto_listeners_) { + for (const Song& song : + listener->AboutToInsertSongs(GetAllSongs(), songs)) { // avoid veto-ing a song multiple times vetoed.insert(song); } @@ -1077,7 +1082,7 @@ void Playlist::InsertSongs(const SongList& songs, int pos, bool play_now, void Playlist::InsertSongsOrLibraryItems(const SongList& songs, int pos, bool play_now, bool enqueue) { PlaylistItemList items; - foreach(const Song & song, songs) { + for (const Song& song : songs) { if (song.id() == -1) items << PlaylistItemPtr(new SongPlaylistItem(song)); else @@ -1092,7 +1097,7 @@ void Playlist::InsertInternetItems(const InternetModel* model, PlaylistItemList playlist_items; QList song_urls; - foreach(const QModelIndex & item, items) { + for (const QModelIndex& item : items) { switch (item.data(InternetModel::Role_PlayBehaviour).toInt()) { case InternetModel::PlayBehaviour_SingleItem: playlist_items << shared_ptr(new InternetPlaylistItem( @@ -1119,7 +1124,7 @@ void Playlist::InsertInternetItems(InternetService* service, const SongList& songs, int pos, bool play_now, bool enqueue) { PlaylistItemList playlist_items; - foreach(const Song & song, songs) { + for (const Song& song : songs) { playlist_items << shared_ptr( new InternetPlaylistItem(service, song)); } @@ -1137,7 +1142,7 @@ void Playlist::UpdateItems(const SongList& songs) { // our list because we will not need to check it again. // And we also update undo actions. QLinkedList songs_list; - foreach(const Song & song, songs) songs_list.append(song); + for (const Song& song : songs) songs_list.append(song); for (int i = 0; i < items_.size(); i++) { // Update current items list @@ -1188,7 +1193,7 @@ QMimeData* Playlist::mimeData(const QModelIndexList& indexes) const { QList urls; QList rows; - foreach(const QModelIndex & index, indexes) { + for (const QModelIndex& index : indexes) { if (index.column() != first_column) continue; urls << items_[index.row()]->Url(); @@ -1395,7 +1400,7 @@ void Playlist::ReOrderWithoutUndo(const PlaylistItemList& new_items) { // This is a slow and nasty way to keep the persistent indices QMap > old_persistent_mappings; - foreach(const QModelIndex & index, persistentIndexList()) { + for (const QModelIndex& index : persistentIndexList()) { old_persistent_mappings[index.row()] = items_[index.row()]; } @@ -1783,7 +1788,7 @@ void Playlist::RemoveItemsNotInQueue() { } void Playlist::ReloadItems(const QList& rows) { - foreach(int row, rows) { + for (int row : rows) { PlaylistItemPtr item = item_at(row); item->Reload(); @@ -1938,7 +1943,9 @@ QSortFilterProxyModel* Playlist::proxy() const { return proxy_; } SongList Playlist::GetAllSongs() const { SongList ret; - foreach(PlaylistItemPtr item, items_) { ret << item->Metadata(); } + for (PlaylistItemPtr item : items_) { + ret << item->Metadata(); + } return ret; } @@ -1946,7 +1953,7 @@ PlaylistItemList Playlist::GetAllItems() const { return items_; } quint64 Playlist::GetTotalLength() const { quint64 ret = 0; - foreach(PlaylistItemPtr item, items_) { + for (PlaylistItemPtr item : items_) { quint64 length = item->Metadata().length_nanosec(); if (length > 0) ret += length; } @@ -1965,7 +1972,7 @@ void Playlist::TracksAboutToBeDequeued(const QModelIndex&, int begin, int end) { } void Playlist::TracksDequeued() { - foreach(const QModelIndex & index, temp_dequeue_change_indexes_) { + for (const QModelIndex& index : temp_dequeue_change_indexes_) { emit dataChanged(index, index); } temp_dequeue_change_indexes_.clear(); @@ -2117,8 +2124,8 @@ void Playlist::SetColumnAlignment(const ColumnAlignmentMap& alignment) { column_alignments_ = alignment; } -void Playlist::SkipTracks(const QModelIndexList &source_indexes) { - foreach (const QModelIndex& source_index, source_indexes) { +void Playlist::SkipTracks(const QModelIndexList& source_indexes) { + for (const QModelIndex& source_index : source_indexes) { PlaylistItemPtr track_to_skip = item_at(source_index.row()); track_to_skip->SetShouldSkip(!((track_to_skip)->GetShouldSkip())); } diff --git a/src/playlist/playlist.h b/src/playlist/playlist.h index 004964824..5ff8fc1b1 100644 --- a/src/playlist/playlist.h +++ b/src/playlist/playlist.h @@ -81,7 +81,7 @@ class Playlist : public QAbstractListModel { QObject* parent = 0); ~Playlist(); - void SkipTracks(const QModelIndexList &source_indexes); + void SkipTracks(const QModelIndexList& source_indexes); // Always add new columns to the end of this enum - the values are persisted enum Column { diff --git a/src/playlist/playlistbackend.cpp b/src/playlist/playlistbackend.cpp index 5b63d295d..93c5d62cd 100644 --- a/src/playlist/playlistbackend.cpp +++ b/src/playlist/playlistbackend.cpp @@ -259,7 +259,7 @@ PlaylistItemPtr PlaylistBackend::RestoreCueData( } } - foreach(const Song & from_list, song_list) { + for (const Song& from_list : song_list) { if (from_list.url().toEncoded() == song.url().toEncoded() && from_list.beginning_nanosec() == song.beginning_nanosec()) { // we found a matching section; replace the input @@ -313,7 +313,7 @@ void PlaylistBackend::SavePlaylist(int playlist, const PlaylistItemList& items, if (db_->CheckErrors(clear)) return; // Save the new ones - foreach(PlaylistItemPtr item, items) { + for (PlaylistItemPtr item : items) { insert.bindValue(":playlist", playlist); item->BindToQuery(&insert); diff --git a/src/playlist/playlistfilterparser.cpp b/src/playlist/playlistfilterparser.cpp index b5628524c..29823ff8b 100644 --- a/src/playlist/playlistfilterparser.cpp +++ b/src/playlist/playlistfilterparser.cpp @@ -190,7 +190,7 @@ class FilterTerm : public FilterTree { virtual bool accept(int row, const QModelIndex& parent, const QAbstractItemModel* const model) const { - foreach(int i, columns_) { + for (int i : columns_) { QModelIndex idx(model->index(row, i, parent)); if (cmp_->Matches(idx.data().toString().toLower())) return true; } @@ -242,7 +242,7 @@ class OrFilter : public FilterTree { virtual void add(FilterTree* child) { children_.append(child); } virtual bool accept(int row, const QModelIndex& parent, const QAbstractItemModel* const model) const { - foreach(FilterTree * child, children_) { + for (FilterTree* child : children_) { if (child->accept(row, parent, model)) return true; } return false; @@ -259,7 +259,7 @@ class AndFilter : public FilterTree { virtual void add(FilterTree* child) { children_.append(child); } virtual bool accept(int row, const QModelIndex& parent, const QAbstractItemModel* const model) const { - foreach(FilterTree * child, children_) { + for (FilterTree* child : children_) { if (!child->accept(row, parent, model)) return false; } return true; @@ -523,7 +523,7 @@ int FilterParser::parseTime(const QString& time_str) const { int seconds = 0; int accum = 0; int colon_count = 0; - foreach(const QChar & c, time_str) { + for (const QChar& c : time_str) { if (c.isDigit()) { accum = accum * 10 + c.digitValue(); } else if (c == ':') { diff --git a/src/playlist/playlistitem.cpp b/src/playlist/playlistitem.cpp index bbba2214d..fa42cd4f1 100644 --- a/src/playlist/playlistitem.cpp +++ b/src/playlist/playlistitem.cpp @@ -113,9 +113,5 @@ QColor PlaylistItem::GetCurrentForegroundColor() const { bool PlaylistItem::HasCurrentForegroundColor() const { return !foreground_colors_.isEmpty(); } -void PlaylistItem::SetShouldSkip(bool val) { - should_skip_ = val; -} -bool PlaylistItem::GetShouldSkip() const { - return should_skip_; -} +void PlaylistItem::SetShouldSkip(bool val) { should_skip_ = val; } +bool PlaylistItem::GetShouldSkip() const { return should_skip_; } diff --git a/src/playlist/playlistlistcontainer.cpp b/src/playlist/playlistlistcontainer.cpp index 42bc73a5c..659ad9887 100644 --- a/src/playlist/playlistlistcontainer.cpp +++ b/src/playlist/playlistlistcontainer.cpp @@ -156,8 +156,8 @@ void PlaylistListContainer::SetApplication(Application* app) { connect(player, SIGNAL(Stopped()), SLOT(ActiveStopped())); // Get all playlists, even ones that are hidden in the UI. - foreach(const PlaylistBackend::Playlist & p, - app->playlist_backend()->GetAllFavoritePlaylists()) { + for (const PlaylistBackend::Playlist& p : + app->playlist_backend()->GetAllFavoritePlaylists()) { QStandardItem* playlist_item = model_->NewPlaylist(p.name, p.id); QStandardItem* parent_folder = model_->FolderByPath(p.ui_path); parent_folder->appendRow(playlist_item); @@ -293,8 +293,8 @@ void PlaylistListContainer::DeleteClicked() { QSet ids; QList folders_to_delete; - foreach(const QModelIndex & proxy_index, - ui_->tree->selectionModel()->selectedRows(0)) { + for (const QModelIndex& proxy_index : + ui_->tree->selectionModel()->selectedRows(0)) { const QModelIndex& index = proxy_->mapToSource(proxy_index); // Is it a playlist? @@ -325,10 +325,12 @@ void PlaylistListContainer::DeleteClicked() { } // Unfavorite the playlists - foreach(int id, ids) { app_->playlist_manager()->Favorite(id, false); } + for (int id : ids) { + app_->playlist_manager()->Favorite(id, false); + } // Delete the top-level folders. - foreach(const QPersistentModelIndex & index, folders_to_delete) { + for (const QPersistentModelIndex& index : folders_to_delete) { if (index.isValid()) { model_->removeRow(index.row(), index.parent()); } diff --git a/src/playlist/playlistlistmodel.cpp b/src/playlist/playlistlistmodel.cpp index dced9a74d..89a5326d9 100644 --- a/src/playlist/playlistlistmodel.cpp +++ b/src/playlist/playlistlistmodel.cpp @@ -126,7 +126,7 @@ QStandardItem* PlaylistListModel::FolderByPath(const QString& path) { QStandardItem* parent = invisibleRootItem(); const QStringList parts = path.split('/', QString::SkipEmptyParts); - foreach(const QString & part, parts) { + for (const QString& part : parts) { QStandardItem* matching_child = nullptr; const int child_count = parent->rowCount(); diff --git a/src/playlist/playlistmanager.cpp b/src/playlist/playlistmanager.cpp index 1c0dbd25d..3ef00a1fa 100644 --- a/src/playlist/playlistmanager.cpp +++ b/src/playlist/playlistmanager.cpp @@ -55,7 +55,9 @@ PlaylistManager::PlaylistManager(Application* app, QObject* parent) } PlaylistManager::~PlaylistManager() { - foreach(const Data & data, playlists_.values()) { delete data.p; } + for (const Data& data : playlists_.values()) { + delete data.p; + } } void PlaylistManager::Init(LibraryBackend* library_backend, @@ -75,8 +77,8 @@ void PlaylistManager::Init(LibraryBackend* library_backend, connect(library_backend_, SIGNAL(SongsRatingChanged(SongList)), SLOT(SongsDiscovered(SongList))); - foreach(const PlaylistBackend::Playlist & p, - playlist_backend->GetAllOpenPlaylists()) { + for (const PlaylistBackend::Playlist& p : + playlist_backend->GetAllOpenPlaylists()) { AddPlaylist(p.id, p.name, p.special_type, p.ui_path, p.favorite); } @@ -89,7 +91,9 @@ void PlaylistManager::Init(LibraryBackend* library_backend, QList PlaylistManager::GetAllPlaylists() const { QList result; - foreach(const Data & data, playlists_.values()) { result.append(data.p); } + for (const Data& data : playlists_.values()) { + result.append(data.p); + } return result; } @@ -276,7 +280,7 @@ bool PlaylistManager::Close(int id) { if (playlists_.count() <= 1 || !playlists_.contains(id)) return false; int next_id = -1; - foreach(int possible_next_id, playlists_.keys()) { + for (int possible_next_id : playlists_.keys()) { if (possible_next_id != id) { next_id = possible_next_id; break; @@ -379,8 +383,7 @@ void PlaylistManager::UpdateSummaryText() { int selected = 0; // Get the length of the selected tracks - foreach(const QItemSelectionRange & range, - playlists_[current_id()].selection) { + for (const QItemSelectionRange& range : playlists_[current_id()].selection) { if (!range.isValid()) continue; selected += range.bottom() - range.top() + 1; @@ -416,10 +419,10 @@ void PlaylistManager::SongsDiscovered(const SongList& songs) { // Some songs might've changed in the library, let's update any playlist // items we have that match those songs - foreach(const Song & song, songs) { - foreach(const Data & data, playlists_) { + for (const Song& song : songs) { + for (const Data& data : playlists_) { PlaylistItemList items = data.p->library_items_by_id(song.id()); - foreach(PlaylistItemPtr item, items) { + for (PlaylistItemPtr item : items) { if (item->Metadata().directory_id() != song.directory_id()) continue; static_cast(item.get())->SetMetadata(song); data.p->ItemChanged(item); @@ -443,7 +446,7 @@ void PlaylistManager::PlaySmartPlaylist(GeneratorPtr generator, bool as_new, // When Player has processed the new song chosen by the user... void PlaylistManager::SongChangeRequestProcessed(const QUrl& url, bool valid) { - foreach(Playlist * playlist, GetAllPlaylists()) { + for (Playlist* playlist : GetAllPlaylists()) { if (playlist->ApplyValidityOnCurrentSong(url, valid)) { return; } @@ -465,13 +468,13 @@ void PlaylistManager::RemoveItemsWithoutUndo(int id, } void PlaylistManager::InvalidateDeletedSongs() { - foreach(Playlist * playlist, GetAllPlaylists()) { + for (Playlist* playlist : GetAllPlaylists()) { playlist->InvalidateDeletedSongs(); } } void PlaylistManager::RemoveDeletedSongs() { - foreach(Playlist * playlist, GetAllPlaylists()) { + for (Playlist* playlist : GetAllPlaylists()) { playlist->RemoveDeletedSongs(); } } @@ -484,7 +487,7 @@ QString PlaylistManager::GetNameForNewPlaylist(const SongList& songs) { QSet artists; QSet albums; - foreach(const Song & song, songs) { + for (const Song& song : songs) { artists << (song.artist().isEmpty() ? tr("Unknown") : song.artist()); albums << (song.album().isEmpty() ? tr("Unknown") : song.album()); diff --git a/src/playlist/playlistsequence.cpp b/src/playlist/playlistsequence.cpp index 5cf1986da..d93c43b40 100644 --- a/src/playlist/playlistsequence.cpp +++ b/src/playlist/playlistsequence.cpp @@ -91,7 +91,7 @@ void PlaylistSequence::Save() { QIcon PlaylistSequence::AddDesaturatedIcon(const QIcon& icon) { QIcon ret; - foreach(const QSize & size, icon.availableSizes()) { + for (const QSize& size : icon.availableSizes()) { QPixmap on(icon.pixmap(size)); QPixmap off(DesaturatedPixmap(on)); diff --git a/src/playlist/playlistundocommands.cpp b/src/playlist/playlistundocommands.cpp index 57c6f917f..8e70ef4c3 100644 --- a/src/playlist/playlistundocommands.cpp +++ b/src/playlist/playlistundocommands.cpp @@ -71,8 +71,7 @@ bool RemoveItems::mergeWith(const QUndoCommand* other) { ranges_.append(remove_command->ranges_); int sum = 0; - foreach(const Range & range, ranges_) - sum += range.count_; + for (const Range& range : ranges_) sum += range.count_; setText(tr("remove %n songs", "", sum)); return true; diff --git a/src/playlist/playlistview.cpp b/src/playlist/playlistview.cpp index 5d459c272..dcd2b6f4b 100644 --- a/src/playlist/playlistview.cpp +++ b/src/playlist/playlistview.cpp @@ -622,7 +622,7 @@ void PlaylistView::RemoveSelected() { // Store the last selected row, which is the first in the list int last_row = selection.first().bottom(); - foreach(const QItemSelectionRange & range, selection) { + for (const QItemSelectionRange& range : selection) { rows_removed += range.height(); model()->removeRows(range.top(), range.height(), range.parent()); } @@ -742,7 +742,7 @@ void PlaylistView::RatingHoverIn(const QModelIndex& index, const QPoint& pos) { update(index); update(old_index); - foreach(const QModelIndex & index, selectedIndexes()) { + for (const QModelIndex& index : selectedIndexes()) { if (index.column() == Playlist::Column_Rating) { update(index); } @@ -764,7 +764,7 @@ void PlaylistView::RatingHoverOut() { setCursor(QCursor()); update(old_index); - foreach(const QModelIndex & index, selectedIndexes()) { + for (const QModelIndex& index : selectedIndexes()) { if (index.column() == Playlist::Column_Rating) { update(index); } @@ -790,7 +790,7 @@ void PlaylistView::mousePressEvent(QMouseEvent* event) { if (selectedIndexes().contains(index)) { // Update all the selected items - foreach(const QModelIndex & index, selectedIndexes()) { + for (const QModelIndex& index : selectedIndexes()) { if (index.data(Playlist::Role_CanSetRating).toBool()) { playlist_->RateSong(playlist_->proxy()->mapToSource(index), new_rating); diff --git a/src/playlist/queue.cpp b/src/playlist/queue.cpp index 167937c67..76d620a73 100644 --- a/src/playlist/queue.cpp +++ b/src/playlist/queue.cpp @@ -133,7 +133,7 @@ QVariant Queue::data(const QModelIndex& proxy_index, int role) const { } void Queue::ToggleTracks(const QModelIndexList& source_indexes) { - foreach(const QModelIndex & source_index, source_indexes) { + for (const QModelIndex& source_index : source_indexes) { QModelIndex proxy_index = mapFromSource(source_index); if (proxy_index.isValid()) { // Dequeue the track @@ -172,7 +172,7 @@ void Queue::Move(const QList& proxy_rows, int pos) { // Take the items out of the list first, keeping track of whether the // insertion point changes int offset = 0; - foreach(int row, proxy_rows) { + for (int row : proxy_rows) { moved_items << source_indexes_.takeAt(row - offset); if (pos != -1 && pos >= row) pos--; offset++; @@ -185,7 +185,7 @@ void Queue::Move(const QList& proxy_rows, int pos) { } // Update persistent indexes - foreach(const QModelIndex & pidx, persistentIndexList()) { + for (const QModelIndex& pidx : persistentIndexList()) { const int dest_offset = proxy_rows.indexOf(pidx.row()); if (dest_offset != -1) { // This index was moved @@ -193,7 +193,7 @@ void Queue::Move(const QList& proxy_rows, int pos) { pidx, index(start + dest_offset, pidx.column(), QModelIndex())); } else { int d = 0; - foreach(int row, proxy_rows) { + for (int row : proxy_rows) { if (pidx.row() > row) d--; } if (pidx.row() + d >= start) d += proxy_rows.count(); @@ -222,7 +222,7 @@ QMimeData* Queue::mimeData(const QModelIndexList& indexes) const { QMimeData* data = new QMimeData; QList rows; - foreach(const QModelIndex & index, indexes) { + for (const QModelIndex& index : indexes) { if (index.column() != 0) continue; rows << index.row(); @@ -262,7 +262,7 @@ bool Queue::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, stream >> source_rows; QModelIndexList source_indexes; - foreach(int source_row, source_rows) { + for (int source_row : source_rows) { const QModelIndex source_index = sourceModel()->index(source_row, 0); const QModelIndex proxy_index = mapFromSource(source_index); if (proxy_index.isValid()) { @@ -326,7 +326,7 @@ void Queue::Remove(QList& proxy_rows) { layoutAboutToBeChanged(); int removed_rows = 0; - foreach(int row, proxy_rows) { + for (int row : proxy_rows) { // after the first row, the row number needs to be updated const int real_row = row - removed_rows; beginRemoveRows(QModelIndex(), real_row, real_row); diff --git a/src/playlist/queuemanager.cpp b/src/playlist/queuemanager.cpp index 00e601cd5..7462a2ec6 100644 --- a/src/playlist/queuemanager.cpp +++ b/src/playlist/queuemanager.cpp @@ -103,7 +103,7 @@ void QueueManager::MoveUp() { if (indexes.isEmpty() || indexes.first().row() == 0) return; - foreach(const QModelIndex & index, indexes) { + for (const QModelIndex& index : indexes) { current_playlist_->queue()->MoveUp(index.row()); } } @@ -126,8 +126,7 @@ void QueueManager::Clear() { current_playlist_->queue()->Clear(); } void QueueManager::Remove() { // collect the rows to be removed QList row_list; - foreach(const QModelIndex & index, - ui_->list->selectionModel()->selectedRows()) { + for (const QModelIndex& index : ui_->list->selectionModel()->selectedRows()) { if (index.isValid()) row_list << index.row(); } diff --git a/src/playlist/songloaderinserter.cpp b/src/playlist/songloaderinserter.cpp index 01d115533..cc5ef789a 100644 --- a/src/playlist/songloaderinserter.cpp +++ b/src/playlist/songloaderinserter.cpp @@ -52,7 +52,7 @@ void SongLoaderInserter::Load(Playlist* destination, int row, bool play_now, connect(this, SIGNAL(EffectiveLoadFinished(const SongList&)), destination, SLOT(UpdateItems(const SongList&))); - foreach(const QUrl & url, urls) { + for (const QUrl& url : urls) { SongLoader* loader = new SongLoader(library_, player_, this); // we're connecting this before we're even sure if this is an async load @@ -151,7 +151,7 @@ void SongLoaderInserter::PartiallyFinished() { } void SongLoaderInserter::EffectiveLoad() { - foreach(SongLoader * loader, pending_async_) { + for (SongLoader* loader : pending_async_) { loader->EffectiveSongsLoad(); task_manager_->SetTaskProgress(async_load_id_, ++async_progress_); emit EffectiveLoadFinished(loader->songs()); diff --git a/src/playlistparsers/asxiniparser.cpp b/src/playlistparsers/asxiniparser.cpp index 081d7b535..343ae1310 100644 --- a/src/playlistparsers/asxiniparser.cpp +++ b/src/playlistparsers/asxiniparser.cpp @@ -55,7 +55,7 @@ void AsxIniParser::Save(const SongList& songs, QIODevice* device, s << "[Reference]" << endl; int n = 1; - foreach(const Song & song, songs) { + for (const Song& song : songs) { s << "Ref" << n << "=" << URLOrRelativeFilename(song.url(), dir) << endl; ++n; } diff --git a/src/playlistparsers/asxparser.cpp b/src/playlistparsers/asxparser.cpp index 846533e94..eb99e2082 100644 --- a/src/playlistparsers/asxparser.cpp +++ b/src/playlistparsers/asxparser.cpp @@ -126,7 +126,7 @@ void ASXParser::Save(const SongList& songs, QIODevice* device, { StreamElement asx("asx", &writer); writer.writeAttribute("version", "3.0"); - foreach(const Song & song, songs) { + for (const Song& song : songs) { StreamElement entry("entry", &writer); writer.writeTextElement("title", song.title()); { diff --git a/src/playlistparsers/m3uparser.cpp b/src/playlistparsers/m3uparser.cpp index 827753b88..fd2bf753b 100644 --- a/src/playlistparsers/m3uparser.cpp +++ b/src/playlistparsers/m3uparser.cpp @@ -105,7 +105,7 @@ bool M3UParser::ParseMetadata(const QString& line, void M3UParser::Save(const SongList& songs, QIODevice* device, const QDir& dir) const { device->write("#EXTM3U\n"); - foreach(const Song & song, songs) { + for (const Song& song : songs) { if (song.url().isEmpty()) { continue; } diff --git a/src/playlistparsers/playlistparser.cpp b/src/playlistparsers/playlistparser.cpp index 46d319d7d..77d4573f7 100644 --- a/src/playlistparsers/playlistparser.cpp +++ b/src/playlistparsers/playlistparser.cpp @@ -45,7 +45,9 @@ PlaylistParser::PlaylistParser(LibraryBackendInterface* library, QStringList PlaylistParser::file_extensions() const { QStringList ret; - foreach(ParserBase * parser, parsers_) { ret << parser->file_extensions(); } + for (ParserBase* parser : parsers_) { + ret << parser->file_extensions(); + } qStableSort(ret); return ret; @@ -54,7 +56,7 @@ QStringList PlaylistParser::file_extensions() const { QString PlaylistParser::filters() const { QStringList filters; QStringList all_extensions; - foreach(ParserBase * parser, parsers_) { + for (ParserBase* parser : parsers_) { filters << FilterForParser(parser, &all_extensions); } @@ -66,8 +68,8 @@ QString PlaylistParser::filters() const { QString PlaylistParser::FilterForParser(const ParserBase* parser, QStringList* all_extensions) const { QStringList extensions; - foreach(const QString & extension, parser->file_extensions()) - extensions << "*." + extension; + for (const QString& extension : parser->file_extensions()) + extensions << "*." + extension; if (all_extensions) *all_extensions << extensions; @@ -83,7 +85,7 @@ QString PlaylistParser::default_filter() const { } ParserBase* PlaylistParser::ParserForExtension(const QString& suffix) const { - foreach(ParserBase * p, parsers_) { + for (ParserBase* p : parsers_) { if (p->file_extensions().contains(suffix)) return p; } return nullptr; @@ -91,7 +93,7 @@ ParserBase* PlaylistParser::ParserForExtension(const QString& suffix) const { ParserBase* PlaylistParser::ParserForMagic(const QByteArray& data, const QString& mime_type) const { - foreach(ParserBase * p, parsers_) { + for (ParserBase* p : parsers_) { if ((!mime_type.isEmpty() && mime_type == p->mime_type()) || p->TryMagic(data)) return p; diff --git a/src/playlistparsers/plsparser.cpp b/src/playlistparsers/plsparser.cpp index dd87927c9..f5eb2ce4c 100644 --- a/src/playlistparsers/plsparser.cpp +++ b/src/playlistparsers/plsparser.cpp @@ -69,7 +69,7 @@ void PLSParser::Save(const SongList& songs, QIODevice* device, s << "NumberOfEntries=" << songs.count() << endl; int n = 1; - foreach(const Song & song, songs) { + for (const Song& song : songs) { s << "File" << n << "=" << URLOrRelativeFilename(song.url(), dir) << endl; s << "Title" << n << "=" << song.title() << endl; s << "Length" << n << "=" << song.length_nanosec() / kNsecPerSec << endl; diff --git a/src/playlistparsers/wplparser.cpp b/src/playlistparsers/wplparser.cpp index 3b72424e3..d4b9ea351 100644 --- a/src/playlistparsers/wplparser.cpp +++ b/src/playlistparsers/wplparser.cpp @@ -96,7 +96,7 @@ void WplParser::Save(const SongList& songs, QIODevice* device, StreamElement body("body", &writer); { StreamElement seq("seq", &writer); - foreach(const Song & song, songs) { + for (const Song& song : songs) { writer.writeStartElement("media"); writer.writeAttribute("src", URLOrRelativeFilename(song.url(), dir)); writer.writeEndElement(); diff --git a/src/playlistparsers/xspfparser.cpp b/src/playlistparsers/xspfparser.cpp index 526b0794f..3a5dbbf3d 100644 --- a/src/playlistparsers/xspfparser.cpp +++ b/src/playlistparsers/xspfparser.cpp @@ -111,7 +111,7 @@ void XSPFParser::Save(const SongList& songs, QIODevice* device, writer.writeDefaultNamespace("http://xspf.org/ns/0/"); StreamElement tracklist("trackList", &writer); - foreach(const Song & song, songs) { + for (const Song& song : songs) { StreamElement track("track", &writer); writer.writeTextElement("location", song.url().toString()); writer.writeTextElement("title", song.title()); diff --git a/src/podcasts/addpodcastbyurl.cpp b/src/podcasts/addpodcastbyurl.cpp index 07f4b0b40..9da68a67f 100644 --- a/src/podcasts/addpodcastbyurl.cpp +++ b/src/podcasts/addpodcastbyurl.cpp @@ -70,7 +70,7 @@ void AddPodcastByUrl::RequestFinished(PodcastUrlLoaderReply* reply) { switch (reply->result_type()) { case PodcastUrlLoaderReply::Type_Podcast: - foreach(const Podcast & podcast, reply->podcast_results()) { + for (const Podcast& podcast : reply->podcast_results()) { model()->appendRow(model()->CreatePodcastItem(podcast)); } break; @@ -89,9 +89,9 @@ void AddPodcastByUrl::Show() { } const QClipboard* clipboard = QApplication::clipboard(); - foreach(const QString & contents, - QStringList() << clipboard->text(QClipboard::Clipboard) - << clipboard->text(QClipboard::Selection)) { + for (const QString& contents : QStringList() + << clipboard->text(QClipboard::Clipboard) + << clipboard->text(QClipboard::Selection)) { if (contents.contains("://")) { ui_->url->setText(contents); return; diff --git a/src/podcasts/fixedopmlpage.cpp b/src/podcasts/fixedopmlpage.cpp index 9c4c78341..df750d9a6 100644 --- a/src/podcasts/fixedopmlpage.cpp +++ b/src/podcasts/fixedopmlpage.cpp @@ -56,7 +56,7 @@ void FixedOpmlPage::LoadFinished(PodcastUrlLoaderReply* reply) { switch (reply->result_type()) { case PodcastUrlLoaderReply::Type_Podcast: - foreach(const Podcast & podcast, reply->podcast_results()) { + for (const Podcast& podcast : reply->podcast_results()) { model()->appendRow(model()->CreatePodcastItem(podcast)); } break; diff --git a/src/podcasts/gpoddersearchpage.cpp b/src/podcasts/gpoddersearchpage.cpp index e862c9659..58e75eedc 100644 --- a/src/podcasts/gpoddersearchpage.cpp +++ b/src/podcasts/gpoddersearchpage.cpp @@ -55,7 +55,7 @@ void GPodderSearchPage::SearchFinished(mygpo::PodcastListPtr list) { model()->clear(); - foreach(mygpo::PodcastPtr gpo_podcast, list->list()) { + for (mygpo::PodcastPtr gpo_podcast : list->list()) { Podcast podcast; podcast.InitFromGpo(gpo_podcast.data()); diff --git a/src/podcasts/gpoddersync.cpp b/src/podcasts/gpoddersync.cpp index 6dfcd9dad..8f9725cad 100644 --- a/src/podcasts/gpoddersync.cpp +++ b/src/podcasts/gpoddersync.cpp @@ -168,11 +168,11 @@ void GPodderSync::DeviceUpdatesFinished(mygpo::DeviceUpdatesPtr reply) { // Remember episode actions for each podcast, so when we add a new podcast // we can apply the actions immediately. QMap > episodes_by_podcast; - foreach(mygpo::EpisodePtr episode, reply->updateList()) { + for (mygpo::EpisodePtr episode : reply->updateList()) { episodes_by_podcast[episode->podcastUrl()].append(episode); } - foreach(mygpo::PodcastPtr podcast, reply->addList()) { + for (mygpo::PodcastPtr podcast : reply->addList()) { const QUrl url(podcast->url()); // Are we subscribed to this podcast already? @@ -195,7 +195,7 @@ void GPodderSync::DeviceUpdatesFinished(mygpo::DeviceUpdatesPtr reply) { } // Unsubscribe from podcasts that were removed. - foreach(const QUrl & url, reply->removeList()) { + for (const QUrl& url : reply->removeList()) { backend_->Unsubscribe(backend_->GetSubscriptionByUrl(url)); } @@ -223,7 +223,7 @@ void GPodderSync::NewPodcastLoaded(PodcastUrlLoaderReply* reply, } // Apply the actions to the episodes in the podcast. - foreach(Podcast podcast, reply->podcast_results()) { + for (Podcast podcast : reply->podcast_results()) { ApplyActions(actions, podcast.mutable_episodes()); // Add the subscription @@ -237,7 +237,7 @@ void GPodderSync::ApplyActions( for (PodcastEpisodeList::iterator it = episodes->begin(); it != episodes->end(); ++it) { // Find an action for this episode - foreach(mygpo::EpisodePtr action, actions) { + for (mygpo::EpisodePtr action : actions) { if (action->url() != it->url()) continue; switch (action->status()) { @@ -284,7 +284,7 @@ void WriteContainer(const T& container, QSettings* s, const char* array_name, const char* item_name) { s->beginWriteArray(array_name, container.count()); int index = 0; - foreach(const typename T::value_type & item, container) { + for (const typename T::value_type& item : container) { s->setArrayIndex(index++); s->setValue(item_name, item); } @@ -357,7 +357,7 @@ void GPodderSync::AddRemoveFinished(mygpo::AddRemoveResultPtr reply, flushing_queue_ = false; // Remove the URLs from the queue. - foreach(const QUrl & url, affected_urls) { + for (const QUrl& url : affected_urls) { queued_add_subscriptions_.remove(url); queued_remove_subscriptions_.remove(url); } @@ -379,7 +379,7 @@ void GPodderSync::DoInitialSync() { // Send our complete list of subscriptions queued_remove_subscriptions_.clear(); queued_add_subscriptions_.clear(); - foreach(const Podcast & podcast, backend_->GetAllSubscriptions()) { + for (const Podcast& podcast : backend_->GetAllSubscriptions()) { queued_add_subscriptions_.insert(podcast.url()); } diff --git a/src/podcasts/gpoddertoptagsmodel.cpp b/src/podcasts/gpoddertoptagsmodel.cpp index a42277cfd..ddaccac4c 100644 --- a/src/podcasts/gpoddertoptagsmodel.cpp +++ b/src/podcasts/gpoddertoptagsmodel.cpp @@ -79,7 +79,7 @@ void GPodderTopTagsModel::PodcastsOfTagFinished(const QModelIndex& parent, parent_item->removeRow(0); } - foreach(mygpo::PodcastPtr gpo_podcast, list->list()) { + for (mygpo::PodcastPtr gpo_podcast : list->list()) { Podcast podcast; podcast.InitFromGpo(gpo_podcast.data()); diff --git a/src/podcasts/gpoddertoptagspage.cpp b/src/podcasts/gpoddertoptagspage.cpp index 0936a14f7..699683437 100644 --- a/src/podcasts/gpoddertoptagspage.cpp +++ b/src/podcasts/gpoddertoptagspage.cpp @@ -56,7 +56,7 @@ void GPodderTopTagsPage::Show() { void GPodderTopTagsPage::TagListLoaded(mygpo::TagListPtr tag_list) { emit Busy(false); - foreach(mygpo::TagPtr tag, tag_list->list()) { + for (mygpo::TagPtr tag : tag_list->list()) { model()->appendRow(model()->CreateFolder(tag->tag())); } } diff --git a/src/podcasts/itunessearchpage.cpp b/src/podcasts/itunessearchpage.cpp index 945c14c6a..d5d24d542 100644 --- a/src/podcasts/itunessearchpage.cpp +++ b/src/podcasts/itunessearchpage.cpp @@ -83,7 +83,7 @@ void ITunesSearchPage::SearchFinished(QNetworkReply* reply) { return; } - foreach(const QVariant & result_variant, data.toMap()["results"].toList()) { + for (const QVariant& result_variant : data.toMap()["results"].toList()) { QVariantMap result(result_variant.toMap()); if (result["kind"].toString() != "podcast") { continue; diff --git a/src/podcasts/podcastdiscoverymodel.cpp b/src/podcasts/podcastdiscoverymodel.cpp index b16b9ef01..9d9fe2f38 100644 --- a/src/podcasts/podcastdiscoverymodel.cpp +++ b/src/podcasts/podcastdiscoverymodel.cpp @@ -79,12 +79,12 @@ QStandardItem* PodcastDiscoveryModel::CreateOpmlContainerItem( void PodcastDiscoveryModel::CreateOpmlContainerItems( const OpmlContainer& container, QStandardItem* parent) { - foreach(const OpmlContainer & child, container.containers) { + for (const OpmlContainer& child : container.containers) { QStandardItem* child_item = CreateOpmlContainerItem(child); parent->appendRow(child_item); } - foreach(const Podcast & child, container.feeds) { + for (const Podcast& child : container.feeds) { QStandardItem* child_item = CreatePodcastItem(child); parent->appendRow(child_item); } diff --git a/src/podcasts/podcastinfowidget.cpp b/src/podcasts/podcastinfowidget.cpp index 8331ed38c..8b8d5f936 100644 --- a/src/podcasts/podcastinfowidget.cpp +++ b/src/podcasts/podcastinfowidget.cpp @@ -38,7 +38,7 @@ PodcastInfoWidget::PodcastInfoWidget(QWidget* parent) label_palette.setColor(QPalette::WindowText, light ? color.darker(150) : color.lighter(125)); - foreach(QLabel * label, findChildren()) { + for (QLabel* label : findChildren()) { if (label->property("field_label").toBool()) { label->setPalette(label_palette); } diff --git a/src/podcasts/podcastparser.cpp b/src/podcasts/podcastparser.cpp index 06e570d3f..a0333b0ec 100644 --- a/src/podcasts/podcastparser.cpp +++ b/src/podcasts/podcastparser.cpp @@ -40,7 +40,7 @@ bool PodcastParser::SupportsContentType(const QString& content_type) const { return true; } - foreach(const QString & mime_type, supported_mime_types()) { + for (const QString& mime_type : supported_mime_types()) { if (content_type.contains(mime_type)) { return true; } diff --git a/src/podcasts/podcastservicemodel.cpp b/src/podcasts/podcastservicemodel.cpp index 5bd7ecb6b..1110b4b4e 100644 --- a/src/podcasts/podcastservicemodel.cpp +++ b/src/podcasts/podcastservicemodel.cpp @@ -26,7 +26,7 @@ QMimeData* PodcastServiceModel::mimeData(const QModelIndexList& indexes) const { SongMimeData* data = new SongMimeData; QList urls; - foreach(const QModelIndex & index, indexes) { + for (const QModelIndex& index : indexes) { switch (index.data(InternetModel::Role_Type).toInt()) { case PodcastService::Type_Episode: MimeDataForEpisode(index, data, &urls); diff --git a/src/podcasts/podcastupdater.cpp b/src/podcasts/podcastupdater.cpp index 1720714d2..2406ce8d0 100644 --- a/src/podcasts/podcastupdater.cpp +++ b/src/podcasts/podcastupdater.cpp @@ -112,8 +112,8 @@ void PodcastUpdater::UpdatePodcastNow(const Podcast& podcast) { } void PodcastUpdater::UpdateAllPodcastsNow() { - foreach(const Podcast & podcast, - app_->podcast_backend()->GetAllSubscriptions()) { + for (const Podcast& podcast : + app_->podcast_backend()->GetAllSubscriptions()) { PodcastUrlLoaderReply* reply = loader_->Load(podcast.url()); NewClosure(reply, SIGNAL(Finished(bool)), this, SLOT(PodcastLoaded(PodcastUrlLoaderReply*, Podcast, bool)), @@ -151,15 +151,15 @@ void PodcastUpdater::PodcastLoaded(PodcastUrlLoaderReply* reply, // Get the episode URLs we had for this podcast already. QSet existing_urls; - foreach(const PodcastEpisode & episode, - app_->podcast_backend()->GetEpisodes(podcast.database_id())) { + for (const PodcastEpisode& episode : + app_->podcast_backend()->GetEpisodes(podcast.database_id())) { existing_urls.insert(episode.url()); } // Add any new episodes PodcastEpisodeList new_episodes; - foreach(const Podcast & reply_podcast, reply->podcast_results()) { - foreach(const PodcastEpisode & episode, reply_podcast.episodes()) { + for (const Podcast& reply_podcast : reply->podcast_results()) { + for (const PodcastEpisode& episode : reply_podcast.episodes()) { if (!existing_urls.contains(episode.url())) { PodcastEpisode episode_copy(episode); episode_copy.set_podcast_database_id(podcast.database_id()); diff --git a/src/smartplaylists/querygenerator.cpp b/src/smartplaylists/querygenerator.cpp index f98a1e573..4506a8f7c 100644 --- a/src/smartplaylists/querygenerator.cpp +++ b/src/smartplaylists/querygenerator.cpp @@ -71,7 +71,7 @@ PlaylistItemList QueryGenerator::GenerateMore(int count) { SongList songs = backend_->FindSongs(search_copy); PlaylistItemList items; - foreach(const Song & song, songs) { + for (const Song& song : songs) { items << PlaylistItemPtr(PlaylistItem::NewFromSongsTable( backend_->songs_table(), song)); previous_ids_ << song.id(); diff --git a/src/smartplaylists/querywizardplugin.cpp b/src/smartplaylists/querywizardplugin.cpp index 242245175..3941ebeb2 100644 --- a/src/smartplaylists/querywizardplugin.cpp +++ b/src/smartplaylists/querywizardplugin.cpp @@ -40,7 +40,7 @@ class QueryWizardPlugin::SearchPage : public QWizardPage { if (ui_->type->currentIndex() == 2) // All songs return true; - foreach(SearchTermWidget * widget, terms_) { + for (SearchTermWidget* widget : terms_) { if (!widget->Term().is_valid()) return false; } return true; @@ -179,7 +179,7 @@ void QueryWizardPlugin::SetGenerator(GeneratorPtr g) { qDeleteAll(search_page_->terms_); search_page_->terms_.clear(); - foreach(const SearchTerm & term, search.terms_) { + for (const SearchTerm& term : search.terms_) { AddSearchTerm(); search_page_->terms_.last()->SetTerm(term); } @@ -273,7 +273,7 @@ Search QueryWizardPlugin::MakeSearch() const { Search::SearchType(search_page_->ui_->type->currentIndex()); // Search terms - foreach(SearchTermWidget * widget, search_page_->terms_) { + for (SearchTermWidget* widget : search_page_->terms_) { SearchTerm term = widget->Term(); if (term.is_valid()) ret.terms_ << term; } diff --git a/src/smartplaylists/search.cpp b/src/smartplaylists/search.cpp index c868c7b32..cde48d7f8 100644 --- a/src/smartplaylists/search.cpp +++ b/src/smartplaylists/search.cpp @@ -49,7 +49,7 @@ QString Search::ToSql(const QString& songs_table) const { // Add search terms QStringList where_clauses; QStringList term_where_clauses; - foreach(const SearchTerm & term, terms_) { + for (const SearchTerm& term : terms_) { term_where_clauses << term.ToSql(); } @@ -61,7 +61,7 @@ QString Search::ToSql(const QString& songs_table) const { // Restrict the IDs of songs if we're making a dynamic playlist if (!id_not_in_.isEmpty()) { QString numbers; - foreach(int id, id_not_in_) { + for (int id : id_not_in_) { numbers += (numbers.isEmpty() ? "" : ",") + QString::number(id); } where_clauses << "(ROWID NOT IN (" + numbers + "))"; diff --git a/src/smartplaylists/searchtermwidget.cpp b/src/smartplaylists/searchtermwidget.cpp index 23949b00c..74bf64b07 100644 --- a/src/smartplaylists/searchtermwidget.cpp +++ b/src/smartplaylists/searchtermwidget.cpp @@ -137,7 +137,7 @@ void SearchTermWidget::FieldChanged(int index) { // Populate the operator combo box if (type != current_field_type_) { ui_->op->clear(); - foreach(SearchTerm::Operator op, SearchTerm::OperatorsForType(type)) { + for (SearchTerm::Operator op : SearchTerm::OperatorsForType(type)) { const int i = ui_->op->count(); ui_->op->addItem(SearchTerm::OperatorText(type, op)); ui_->op->setItemData(i, op); diff --git a/src/songinfo/artistinfoview.cpp b/src/songinfo/artistinfoview.cpp index 131c81142..5acfac3d4 100644 --- a/src/songinfo/artistinfoview.cpp +++ b/src/songinfo/artistinfoview.cpp @@ -63,7 +63,9 @@ void ArtistInfoView::ResultReady(int id, PrettyImageView* image_view = new PrettyImageView(network_, this); AddWidget(image_view); - foreach(const QUrl & url, result.images_) { image_view->AddImage(url); } + for (const QUrl& url : result.images_) { + image_view->AddImage(url); + } } CollapseSections(); } diff --git a/src/songinfo/echonestimages.cpp b/src/songinfo/echonestimages.cpp index 4cc7ff62e..08256e3e5 100644 --- a/src/songinfo/echonestimages.cpp +++ b/src/songinfo/echonestimages.cpp @@ -54,7 +54,7 @@ void EchoNestImages::RequestFinished() { << e.what(); } - foreach(const Echonest::ArtistImage & image, request->artist_->images()) { + for (const Echonest::ArtistImage& image : request->artist_->images()) { emit ImageReady(request->id_, image.url()); } diff --git a/src/songinfo/echonestsimilarartists.cpp b/src/songinfo/echonestsimilarartists.cpp index 4c394ba21..b481d4c32 100644 --- a/src/songinfo/echonestsimilarartists.cpp +++ b/src/songinfo/echonestsimilarartists.cpp @@ -64,7 +64,7 @@ void EchoNestSimilarArtists::RequestFinished() { widget->SetIcon(QIcon(":/icons/22x22/x-clementine-artist.png")); - foreach(const Echonest::Artist & artist, artists) { + for (const Echonest::Artist& artist : artists) { widget->AddTag(artist.name()); if (widget->count() >= 10) break; } diff --git a/src/songinfo/lastfmtrackinfoprovider.cpp b/src/songinfo/lastfmtrackinfoprovider.cpp index 99956a9ae..72bbbccb3 100644 --- a/src/songinfo/lastfmtrackinfoprovider.cpp +++ b/src/songinfo/lastfmtrackinfoprovider.cpp @@ -136,7 +136,7 @@ void LastfmTrackInfoProvider::GetTags(int id, const lastfm::XmlQuery& q) { widget->SetIcon(data.icon_); - foreach(const lastfm::XmlQuery & e, q["track"]["toptags"].children("tag")) { + for (const lastfm::XmlQuery& e : q["track"]["toptags"].children("tag")) { widget->AddTag(e["name"].text()); } diff --git a/src/songinfo/songinfobase.cpp b/src/songinfo/songinfobase.cpp index 8d84618ac..35bd0c517 100644 --- a/src/songinfo/songinfobase.cpp +++ b/src/songinfo/songinfobase.cpp @@ -150,7 +150,7 @@ void SongInfoBase::InfoResultReady(int id, const CollapsibleInfoPane::Data& data) {} void SongInfoBase::ResultReady(int id, const SongInfoFetcher::Result& result) { - foreach(const CollapsibleInfoPane::Data & data, result.info_) { + for (const CollapsibleInfoPane::Data& data : result.info_) { delete data.contents_; } } @@ -169,7 +169,7 @@ void SongInfoBase::CollapseSections() { QMap types_; QSet has_user_preference_; - foreach(CollapsibleInfoPane * pane, sections_) { + for (CollapsibleInfoPane* pane : sections_) { const CollapsibleInfoPane::Data::Type type = pane->data().type_; types_.insertMulti(type, pane); @@ -182,14 +182,14 @@ void SongInfoBase::CollapseSections() { } } - foreach(CollapsibleInfoPane::Data::Type type, types_.keys()) { + for (CollapsibleInfoPane::Data::Type type : types_.keys()) { if (!has_user_preference_.contains(type)) { // Expand the first one types_.values(type).last()->Expand(); } } - foreach(CollapsibleInfoPane * pane, sections_) { + for (CollapsibleInfoPane* pane : sections_) { connect(pane, SIGNAL(Toggled(bool)), SLOT(SectionToggled(bool))); } } @@ -204,7 +204,7 @@ void SongInfoBase::SectionToggled(bool value) { } void SongInfoBase::ReloadSettings() { - foreach(CollapsibleInfoPane * pane, sections_) { + for (CollapsibleInfoPane* pane : sections_) { QWidget* contents = pane->data().contents_; if (!contents) continue; diff --git a/src/songinfo/songinfofetcher.cpp b/src/songinfo/songinfofetcher.cpp index f581ea11e..f9a6f0463 100644 --- a/src/songinfo/songinfofetcher.cpp +++ b/src/songinfo/songinfofetcher.cpp @@ -50,7 +50,7 @@ int SongInfoFetcher::FetchInfo(const Song& metadata) { connect(timeout_timers_[id], SIGNAL(timeout()), timeout_timer_mapper_, SLOT(map())); - foreach(SongInfoProvider * provider, providers_) { + for (SongInfoProvider* provider : providers_) { if (provider->is_enabled()) { waiting_for_[id].append(provider); provider->FetchInfo(id, metadata); @@ -95,7 +95,7 @@ void SongInfoFetcher::Timeout(int id) { emit ResultReady(id, results_.take(id)); // Cancel any providers that we're still waiting for - foreach(SongInfoProvider * provider, waiting_for_[id]) { + for (SongInfoProvider* provider : waiting_for_[id]) { qLog(Info) << "Request timed out from info provider" << provider->name(); provider->Cancel(id); } diff --git a/src/songinfo/songinfosettingspage.cpp b/src/songinfo/songinfosettingspage.cpp index 778b34f4d..deabaaa69 100644 --- a/src/songinfo/songinfosettingspage.cpp +++ b/src/songinfo/songinfosettingspage.cpp @@ -63,7 +63,7 @@ void SongInfoSettingsPage::Load() { dialog()->song_info_view()->lyric_providers(); ui_->providers->clear(); - foreach(const UltimateLyricsProvider * provider, providers) { + for (const UltimateLyricsProvider* provider : providers) { QListWidgetItem* item = new QListWidgetItem(ui_->providers); item->setText(provider->name()); item->setCheckState(provider->is_enabled() ? Qt::Checked : Qt::Unchecked); diff --git a/src/songinfo/songinfoview.cpp b/src/songinfo/songinfoview.cpp index 0541b99bb..076512ae0 100644 --- a/src/songinfo/songinfoview.cpp +++ b/src/songinfo/songinfoview.cpp @@ -56,7 +56,7 @@ void SongInfoView::UltimateLyricsParsed() { QFutureWatcher* watcher = static_cast*>(sender()); - foreach(SongInfoProvider * provider, watcher->result()) { + for (SongInfoProvider* provider : watcher->result()) { fetcher_->AddProvider(provider); } @@ -113,21 +113,21 @@ void SongInfoView::ReloadSettings() { << "darklyrics.com"; QVariant saved_order = s.value("search_order", default_order); - foreach(const QVariant & name, saved_order.toList()) { + for (const QVariant& name : saved_order.toList()) { SongInfoProvider* provider = ProviderByName(name.toString()); if (provider) ordered_providers << provider; } // Enable all the providers in the list and rank them int relevance = 100; - foreach(SongInfoProvider * provider, ordered_providers) { + for (SongInfoProvider* provider : ordered_providers) { provider->set_enabled(true); qobject_cast(provider)->set_relevance(relevance--); } // Any lyric providers we don't have in ordered_providers are considered // disabled - foreach(SongInfoProvider * provider, fetcher_->providers()) { + for (SongInfoProvider* provider : fetcher_->providers()) { if (qobject_cast(provider) && !ordered_providers.contains(provider)) { provider->set_enabled(false); @@ -138,7 +138,7 @@ void SongInfoView::ReloadSettings() { } SongInfoProvider* SongInfoView::ProviderByName(const QString& name) const { - foreach(SongInfoProvider * provider, fetcher_->providers()) { + for (SongInfoProvider* provider : fetcher_->providers()) { if (UltimateLyricsProvider* lyrics = qobject_cast(provider)) { if (lyrics->name() == name) return provider; @@ -158,7 +158,7 @@ bool CompareLyricProviders(const UltimateLyricsProvider* a, QList SongInfoView::lyric_providers() const { QList ret; - foreach(SongInfoProvider * provider, fetcher_->providers()) { + for (SongInfoProvider* provider : fetcher_->providers()) { if (UltimateLyricsProvider* lyrics = qobject_cast(provider)) { ret << lyrics; diff --git a/src/songinfo/songkickconcerts.cpp b/src/songinfo/songkickconcerts.cpp index feb9ec77d..1b36e420e 100644 --- a/src/songinfo/songkickconcerts.cpp +++ b/src/songinfo/songkickconcerts.cpp @@ -70,7 +70,7 @@ void SongkickConcerts::ArtistSearchFinished(QNetworkReply* reply, int id) { const Echonest::Artist& artist = artists[0]; const Echonest::ForeignIds& foreign_ids = artist.foreignIds(); QString songkick_id; - foreach(const Echonest::ForeignId & id, foreign_ids) { + for (const Echonest::ForeignId& id : foreign_ids) { if (id.catalog == "songkick") { songkick_id = id.foreign_id; break; @@ -130,7 +130,7 @@ void SongkickConcerts::CalendarRequestFinished(QNetworkReply* reply, int id) { QWidget* container = new QWidget; QVBoxLayout* layout = new QVBoxLayout(container); - foreach(const QVariant & v, events) { + for (const QVariant& v : events) { QVariantMap event = v.toMap(); QString display_name = event["displayName"].toString(); QString start_date = event["start"].toMap()["date"].toString(); diff --git a/src/songinfo/songplaystats.cpp b/src/songinfo/songplaystats.cpp index 48a23aff2..0c6b4c061 100644 --- a/src/songinfo/songplaystats.cpp +++ b/src/songinfo/songplaystats.cpp @@ -44,7 +44,7 @@ void SongPlayStats::paintEvent(QPaintEvent*) { QPainter p(this); int y = kMargin; - foreach(const Item & item, items_) { + for (const Item& item : items_) { const QRect line(kMargin, y, width() - kMargin * 2, kIconSize); const QRect icon_rect(line.topLeft(), QSize(kIconSize, kIconSize)); const QRect text_rect( diff --git a/src/songinfo/ultimatelyricsprovider.cpp b/src/songinfo/ultimatelyricsprovider.cpp index 0238df0f8..586e5d239 100644 --- a/src/songinfo/ultimatelyricsprovider.cpp +++ b/src/songinfo/ultimatelyricsprovider.cpp @@ -105,7 +105,7 @@ void UltimateLyricsProvider::LyricsFetched() { QString lyrics; // Check for invalid indicators - foreach(const QString & indicator, invalid_indicators_) { + for (const QString& indicator : invalid_indicators_) { if (original_content.contains(indicator)) { qLog(Debug) << "Found invalid indicator" << indicator; url_hop_ = false; @@ -116,7 +116,7 @@ void UltimateLyricsProvider::LyricsFetched() { if (!url_hop_) { // Apply extract rules - foreach(const Rule & rule, extract_rules_) { + for (const Rule& rule : extract_rules_) { // Modify the rule for this request's metadata Rule rule_copy(rule); for (Rule::iterator it = rule_copy.begin(); it != rule_copy.end(); ++it) { @@ -135,7 +135,7 @@ void UltimateLyricsProvider::LyricsFetched() { } // Apply exclude rules - foreach(const Rule & rule, exclude_rules_) { + for (const Rule& rule : exclude_rules_) { ApplyExcludeRule(rule, &content); } @@ -173,7 +173,7 @@ void UltimateLyricsProvider::LyricsFetched() { bool UltimateLyricsProvider::ApplyExtractRule(const Rule& rule, QString* content) const { - foreach(const RuleItem & item, rule) { + for (const RuleItem& item : rule) { if (item.second.isNull()) { if (item.first.startsWith("http://") && item.second.isNull()) { *content = ExtractUrl(*content, rule); @@ -193,7 +193,7 @@ QString UltimateLyricsProvider::ExtractUrl(const QString& source, QString url; QString id; - foreach(const RuleItem & item, rule) { + for (const RuleItem& item : rule) { if (item.first.startsWith("http://") && item.second.isNull()) url = item.first; else @@ -228,7 +228,7 @@ QString UltimateLyricsProvider::Extract(const QString& source, void UltimateLyricsProvider::ApplyExcludeRule(const Rule& rule, QString* content) const { - foreach(const RuleItem & item, rule) { + for (const RuleItem& item : rule) { if (item.second.isNull()) { *content = ExcludeXmlTag(*content, item.first); } else { @@ -288,7 +288,7 @@ void UltimateLyricsProvider::ReplaceField(const QString& tag, // Apply URL character replacement QString value_copy(value); - foreach(const UrlFormat & format, url_formats_) { + for (const UrlFormat& format : url_formats_) { QRegExp re("[" + QRegExp::escape(format.first) + "]"); value_copy.replace(re, format.second); } @@ -323,7 +323,7 @@ QString UltimateLyricsProvider::NoSpace(const QString& text) { // TODO: handle special characters (e.g. ® á) bool UltimateLyricsProvider::HTMLHasAlphaNumeric(const QString& html) { bool in_tag = false; - foreach(const QChar & c, html) { + for (const QChar& c : html) { if (!in_tag and c.isLetterOrNumber()) return true; else if (c == QChar('<')) diff --git a/src/transcoder/transcodedialog.cpp b/src/transcoder/transcodedialog.cpp index 1836455db..72948b08b 100644 --- a/src/transcoder/transcodedialog.cpp +++ b/src/transcoder/transcodedialog.cpp @@ -63,7 +63,7 @@ TranscodeDialog::TranscodeDialog(QWidget* parent) // Get presets QList presets = Transcoder::GetAllPresets(); qSort(presets.begin(), presets.end(), ComparePresetsByName); - foreach(const TranscoderPreset & preset, presets) { + for (const TranscoderPreset& preset : presets) { ui_->format->addItem( QString("%1 (.%2)").arg(preset.name_, preset.extension_), QVariant::fromValue(preset)); @@ -180,7 +180,7 @@ void TranscodeDialog::UpdateProgress() { int progress = (finished_success_ + finished_failed_) * 100; QMap current_jobs = transcoder_->GetProgress(); - foreach(float value, current_jobs.values()) { + for (float value : current_jobs.values()) { progress += qBound(0, int(value * 100), 99); } @@ -227,7 +227,7 @@ void TranscodeDialog::Add() { } void TranscodeDialog::SetFilenames(const QStringList& filenames) { - foreach(const QString & filename, filenames) { + for (const QString& filename : filenames) { QString name = filename.section('/', -1, -1); QString path = filename.section('/', 0, -2); diff --git a/src/transcoder/transcoder.cpp b/src/transcoder/transcoder.cpp index 3d0be8187..5a9696b97 100644 --- a/src/transcoder/transcoder.cpp +++ b/src/transcoder/transcoder.cpp @@ -265,7 +265,7 @@ Song::FileType Transcoder::PickBestFormat(QList supported) { best_formats << Song::Type_OggVorbis; best_formats << Song::Type_Asf; - foreach(Song::FileType type, best_formats) { + for (Song::FileType type : best_formats) { if (supported.isEmpty() || supported.contains(type)) return type; } diff --git a/src/ui/about.cpp b/src/ui/about.cpp index 4ae16b376..ca50978e7 100644 --- a/src/ui/about.cpp +++ b/src/ui/about.cpp @@ -66,13 +66,11 @@ QString About::MakeHtml() const { "

%2

" "

%3:").arg(kUrl, kUrl, tr("Authors")); - foreach(const Person & person, authors_) - ret += "
" + MakeHtml(person); + for (const Person& person : authors_) ret += "
" + MakeHtml(person); ret += QString("

%3:").arg(tr("Thanks to")); - foreach(const Person & person, thanks_to_) - ret += "
" + MakeHtml(person); + for (const Person& person : thanks_to_) ret += "
" + MakeHtml(person); ret += QString( "
" + tr("All the translators") + " <" diff --git a/src/ui/albumcoverchoicecontroller.cpp b/src/ui/albumcoverchoicecontroller.cpp index 911653733..d25918120 100644 --- a/src/ui/albumcoverchoicecontroller.cpp +++ b/src/ui/albumcoverchoicecontroller.cpp @@ -132,7 +132,7 @@ void AlbumCoverChoiceController::SaveCoverToFile(const Song& song, QString extension = save_filename.right(4); if (!extension.startsWith('.') || !QImageWriter::supportedImageFormats().contains( - extension.right(3).toUtf8())) { + extension.right(3).toUtf8())) { save_filename.append(".jpg"); } @@ -284,7 +284,7 @@ bool AlbumCoverChoiceController::IsKnownImageExtension(const QString& suffix) { } bool AlbumCoverChoiceController::CanAcceptDrag(const QDragEnterEvent* e) { - foreach(const QUrl & url, e->mimeData()->urls()) { + for (const QUrl& url : e->mimeData()->urls()) { const QString suffix = QFileInfo(url.toLocalFile()).suffix().toLower(); if (IsKnownImageExtension(suffix)) return true; } @@ -295,7 +295,7 @@ bool AlbumCoverChoiceController::CanAcceptDrag(const QDragEnterEvent* e) { } QString AlbumCoverChoiceController::SaveCover(Song* song, const QDropEvent* e) { - foreach(const QUrl & url, e->mimeData()->urls()) { + for (const QUrl& url : e->mimeData()->urls()) { const QString filename = url.toLocalFile(); const QString suffix = QFileInfo(filename).suffix().toLower(); diff --git a/src/ui/albumcovermanager.cpp b/src/ui/albumcovermanager.cpp index ddef4cfb0..575c53fd8 100644 --- a/src/ui/albumcovermanager.cpp +++ b/src/ui/albumcovermanager.cpp @@ -273,7 +273,7 @@ void AlbumCoverManager::Reset() { QStringList artists(library_backend_->GetAllArtistsWithAlbums()); qStableSort(artists.begin(), artists.end(), CompareNocase); - foreach(const QString & artist, artists) { + for (const QString& artist : artists) { if (artist.isEmpty()) continue; new QListWidgetItem(artist_icon_, artist, ui_->artists, Specific_Artist); @@ -320,7 +320,7 @@ void AlbumCoverManager::ArtistChanged(QListWidgetItem* current) { // case sensitively. qStableSort(albums.begin(), albums.end(), CompareAlbumNameNocase); - foreach(const LibraryBackend::Album & info, albums) { + for (const LibraryBackend::Album& info : albums) { // Don't show songs without an album, obviously if (info.album_name.isEmpty()) continue; @@ -406,7 +406,7 @@ bool AlbumCoverManager::ShouldHide(const QListWidgetItem& item, } QStringList query = filter.split(' '); - foreach(const QString & s, query) { + for (const QString& s : query) { if (!item.text().contains(s, Qt::CaseInsensitive) && !item.data(Role_ArtistName).toString().contains(s, Qt::CaseInsensitive)) { @@ -491,7 +491,7 @@ bool AlbumCoverManager::eventFilter(QObject* obj, QEvent* event) { bool some_with_covers = false; - foreach(QListWidgetItem * item, context_menu_items_) { + for (QListWidgetItem* item : context_menu_items_) { if (item->icon().cacheKey() != no_cover_icon_.cacheKey()) some_with_covers = true; } @@ -556,7 +556,7 @@ void AlbumCoverManager::ShowCover() { } void AlbumCoverManager::FetchSingleCover() { - foreach(QListWidgetItem * item, context_menu_items_) { + for (QListWidgetItem* item : context_menu_items_) { quint64 id = cover_fetcher_->FetchAlbumCover(item->data(Role_ArtistName).toString(), item->data(Role_AlbumName).toString()); @@ -637,7 +637,7 @@ void AlbumCoverManager::SearchForCover() { if (cover.isEmpty()) return; // force the found cover on all of the selected items - foreach(QListWidgetItem * current, context_menu_items_) { + for (QListWidgetItem* current : context_menu_items_) { // don't save the first one twice if (current != item) { Song current_song = ItemAsSong(current); @@ -657,7 +657,7 @@ void AlbumCoverManager::UnsetCover() { QString cover = album_cover_choice_controller_->UnsetCover(&song); // force the 'none' cover on all of the selected items - foreach(QListWidgetItem * current, context_menu_items_) { + for (QListWidgetItem* current : context_menu_items_) { current->setIcon(no_cover_icon_); current->setData(Role_PathManual, cover); @@ -694,7 +694,9 @@ SongList AlbumCoverManager::GetSongsInAlbum(const QModelIndex& index) const { SongList AlbumCoverManager::GetSongsInAlbums(const QModelIndexList& indexes) const { SongList ret; - foreach(const QModelIndex & index, indexes) { ret << GetSongsInAlbum(index); } + for (const QModelIndex& index : indexes) { + ret << GetSongsInAlbum(index); + } return ret; } diff --git a/src/ui/albumcovermanagerlist.cpp b/src/ui/albumcovermanagerlist.cpp index 7a7f83b86..8d49b3249 100644 --- a/src/ui/albumcovermanagerlist.cpp +++ b/src/ui/albumcovermanagerlist.cpp @@ -33,7 +33,7 @@ QMimeData* AlbumCoverManagerList::mimeData(const QList items) const { // Get songs SongList songs; - foreach(QListWidgetItem * item, items) { + for (QListWidgetItem* item : items) { songs << manager_->GetSongsInAlbum(indexFromItem(item)); } @@ -41,7 +41,9 @@ QMimeData* AlbumCoverManagerList::mimeData(const QList items) // Get URLs from the songs QList urls; - foreach(const Song & song, songs) { urls << song.url(); } + for (const Song& song : songs) { + urls << song.url(); + } // Get the QAbstractItemModel data so the picture works std::unique_ptr orig_data(QListWidget::mimeData(items)); diff --git a/src/ui/albumcoversearcher.cpp b/src/ui/albumcoversearcher.cpp index 8421af66d..f46fa5383 100644 --- a/src/ui/albumcoversearcher.cpp +++ b/src/ui/albumcoversearcher.cpp @@ -182,7 +182,7 @@ void AlbumCoverSearcher::SearchFinished(quint64 id, ui_->search->setText(tr("Search")); id_ = 0; - foreach(const CoverSearchResult & result, results) { + for (const CoverSearchResult& result : results) { if (result.image_url.isEmpty()) continue; quint64 id = app_->album_cover_loader()->LoadImageAsync( diff --git a/src/ui/backgroundstreamssettingspage.cpp b/src/ui/backgroundstreamssettingspage.cpp index 105b661bd..5d7d83cb9 100644 --- a/src/ui/backgroundstreamssettingspage.cpp +++ b/src/ui/backgroundstreamssettingspage.cpp @@ -30,7 +30,7 @@ BackgroundStreamsSettingsPage::BackgroundStreamsSettingsPage( ui_->setupUi(this); setWindowIcon(QIcon(":/icons/32x32/weather-showers-scattered.png")); - foreach(const QString & name, dialog->background_streams()->streams()) { + for (const QString& name : dialog->background_streams()->streams()) { AddStream(name); } } diff --git a/src/ui/behavioursettingspage.cpp b/src/ui/behavioursettingspage.cpp index d19be32b8..cdcadb2ac 100644 --- a/src/ui/behavioursettingspage.cpp +++ b/src/ui/behavioursettingspage.cpp @@ -55,7 +55,7 @@ BehaviourSettingsPage::BehaviourSettingsPage(SettingsDialog* dialog) QDir dir(":/translations/"); QStringList codes(dir.entryList(QStringList() << "*.qm")); QRegExp lang_re("^clementine_(.*).qm$"); - foreach(const QString & filename, codes) { + for (const QString& filename : codes) { // The regex captures the "ru" from "clementine_ru.qm" if (!lang_re.exactMatch(filename)) continue; diff --git a/src/ui/edittagdialog.cpp b/src/ui/edittagdialog.cpp index e8bcfc45c..08138e8e7 100644 --- a/src/ui/edittagdialog.cpp +++ b/src/ui/edittagdialog.cpp @@ -84,7 +84,7 @@ 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. - foreach(QLabel * label, findChildren()) { + for (QLabel* label : findChildren()) { QWidget* widget = label->buddy(); if (widget) { // Store information about the field @@ -113,7 +113,7 @@ EditTagDialog::EditTagDialog(Application* app, QWidget* parent) summary_label_palette.setColor( QPalette::WindowText, light ? color.darker(150) : color.lighter(125)); - foreach(QLabel * label, ui_->summary_tab->findChildren()) { + for (QLabel* label : ui_->summary_tab->findChildren()) { if (label->property("field_label").toBool()) { label->setPalette(summary_label_palette); } @@ -220,7 +220,7 @@ QList EditTagDialog::LoadData(const SongList& songs) const { QList ret; - foreach(const Song & song, songs) { + for (const Song& song : songs) { if (song.IsEditable()) { // Try reloading the tags from file Song copy(song); @@ -277,7 +277,7 @@ void EditTagDialog::SetSongsFinished() { } // Add the filenames to the list - foreach(const Data & data, data_) { + for (const Data& data : data_) { ui_->song_list->addItem(data.current_.basefilename()); } @@ -338,7 +338,7 @@ bool EditTagDialog::DoesValueVary(const QModelIndexList& sel, bool EditTagDialog::IsValueModified(const QModelIndexList& sel, const QString& id) const { - foreach(const QModelIndex & i, sel) { + for (const QModelIndex& i : sel) { if (data_[i.row()].original_value(id) != data_[i.row()].current_value(id)) return true; } @@ -380,7 +380,7 @@ void EditTagDialog::UpdateFieldValue(const FieldData& field, } // Set it in each selected song - foreach(const QModelIndex & i, sel) { + for (const QModelIndex& i : sel) { data_[i.row()].set_value(field.id_, value); } @@ -396,7 +396,7 @@ void EditTagDialog::UpdateFieldValue(const FieldData& field, void EditTagDialog::ResetFieldValue(const FieldData& field, const QModelIndexList& sel) { // Reset each selected song - foreach(const QModelIndex & i, sel) { + for (const QModelIndex& i : sel) { Data& data = data_[i.row()]; data.set_value(field.id_, data.original_value(field.id_)); } @@ -412,7 +412,9 @@ void EditTagDialog::SelectionChanged() { // Set the editable fields ignore_edits_ = true; - foreach(const FieldData & field, fields_) { InitFieldValue(field, sel); } + for (const FieldData& field : fields_) { + InitFieldValue(field, sel); + } ignore_edits_ = false; // If we're editing multiple songs then we have to disable certain tabs @@ -525,7 +527,7 @@ void EditTagDialog::FieldValueEdited() { QWidget* w = qobject_cast(sender()); // Find the field - foreach(const FieldData & field, fields_) { + for (const FieldData& field : fields_) { if (field.editor_ == w) { UpdateFieldValue(field, sel); return; @@ -541,7 +543,7 @@ void EditTagDialog::ResetField() { QWidget* w = qobject_cast(sender()); // Find the field - foreach(const FieldData & field, fields_) { + for (const FieldData& field : fields_) { if (field.editor_ == w) { ignore_edits_ = true; ResetFieldValue(field, sel); @@ -673,7 +675,7 @@ void EditTagDialog::SaveData(const QList& data) { if (ref.current_.IsMetadataEqual(ref.original_)) continue; if (!TagReaderClient::Instance()->SaveFileBlocking( - ref.current_.url().toLocalFile(), ref.current_)) { + ref.current_.url().toLocalFile(), ref.current_)) { emit Error(tr("An error occurred writing metadata to '%1'") .arg(ref.current_.url().toLocalFile())); } @@ -799,7 +801,7 @@ void EditTagDialog::FetchTag() { SongList songs; - foreach(const QModelIndex & index, sel) { + for (const QModelIndex& index : sel) { Song song = data_[index.row()].original_; if (!song.is_valid()) { continue; diff --git a/src/ui/equalizer.cpp b/src/ui/equalizer.cpp index 511630ff2..7628ee809 100644 --- a/src/ui/equalizer.cpp +++ b/src/ui/equalizer.cpp @@ -270,7 +270,7 @@ void Equalizer::Save() { // Presets s.beginWriteArray("presets", presets_.count()); int i = 0; - foreach(const QString & name, presets_.keys()) { + for (const QString& name : presets_.keys()) { s.setArrayIndex(i++); s.setValue("name", name); s.setValue("params", QVariant::fromValue(presets_[name])); diff --git a/src/ui/flowlayout.cpp b/src/ui/flowlayout.cpp index d75d9fdcb..cccb1a1c4 100644 --- a/src/ui/flowlayout.cpp +++ b/src/ui/flowlayout.cpp @@ -120,9 +120,8 @@ QSize FlowLayout::sizeHint() const { return minimumSize(); } QSize FlowLayout::minimumSize() const { QSize size; - QLayoutItem* item; - foreach(item, itemList) - size = size.expandedTo(item->minimumSize()); + for (QLayoutItem* item : itemList) + size = size.expandedTo(item->minimumSize()); size += QSize(2 * margin(), 2 * margin()); return size; @@ -140,8 +139,7 @@ int FlowLayout::doLayout(const QRect& rect, bool testOnly) const { //! [9] //! [10] - QLayoutItem* item; - foreach(item, itemList) { + for (QLayoutItem* item : itemList) { QWidget* wid = item->widget(); int spaceX = horizontalSpacing(); if (spaceX == -1) diff --git a/src/ui/globalshortcutssettingspage.cpp b/src/ui/globalshortcutssettingspage.cpp index e422f1e2c..410c74e4f 100644 --- a/src/ui/globalshortcutssettingspage.cpp +++ b/src/ui/globalshortcutssettingspage.cpp @@ -81,8 +81,7 @@ void GlobalShortcutsSettingsPage::Load() { ui_->gnome_container->hide(); } - foreach(const GlobalShortcuts::Shortcut & s, - manager->shortcuts().values()) { + for (const GlobalShortcuts::Shortcut& s : manager->shortcuts().values()) { Shortcut shortcut; shortcut.s = s; shortcut.key = s.action->shortcut(); @@ -98,7 +97,7 @@ void GlobalShortcutsSettingsPage::Load() { ItemClicked(ui_->list->topLevelItem(0)); } - foreach(const Shortcut & s, shortcuts_.values()) { + for (const Shortcut& s : shortcuts_.values()) { SetShortcut(s.s.id, s.s.action->shortcut()); } @@ -119,7 +118,7 @@ void GlobalShortcutsSettingsPage::SetShortcut(const QString& id, } void GlobalShortcutsSettingsPage::Save() { - foreach(const Shortcut & s, shortcuts_.values()) { + for (const Shortcut& s : shortcuts_.values()) { s.s.action->setShortcut(s.key); s.s.shortcut->setKey(s.key); settings_.setValue(s.s.id, s.key.toString()); @@ -164,7 +163,7 @@ void GlobalShortcutsSettingsPage::ChangeClicked() { if (key.isEmpty()) return; // Check if this key sequence is used by any other actions - foreach(const QString & id, shortcuts_.keys()) { + for (const QString& id : shortcuts_.keys()) { if (shortcuts_[id].key == key) SetShortcut(id, QKeySequence()); } diff --git a/src/ui/iconloader.cpp b/src/ui/iconloader.cpp index cf05ca22a..7f0422a88 100644 --- a/src/ui/iconloader.cpp +++ b/src/ui/iconloader.cpp @@ -41,7 +41,7 @@ QIcon IconLoader::Load(const QString& name) { // Otherwise use our fallback theme const QString path(":/icons/%1x%2/%3.png"); - foreach(int size, sizes_) { + for (int size : sizes_) { QString filename(path.arg(size).arg(size).arg(name)); if (QFile::exists(filename)) ret.addFile(filename, QSize(size, size)); diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index c15f76820..3472d6818 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -859,7 +859,7 @@ MainWindow::MainWindow(Application* app, SystemTrayIcon* tray_icon, OSD* osd, restoreGeometry(settings_.value("geometry").toByteArray()); if (!ui_->splitter->restoreState( - settings_.value("splitter_state").toByteArray())) { + settings_.value("splitter_state").toByteArray())) { ui_->splitter->setSizes(QList() << 300 << width() - 300); } ui_->tabs->SetCurrentIndex( @@ -1421,8 +1421,10 @@ void MainWindow::AddToPlaylist(QAction* action) { PlaylistItemList items; // get the selected playlist items - foreach(const QModelIndex & index, - ui_->playlist->view()->selectionModel()->selection().indexes()) { + for (const QModelIndex& index : ui_->playlist->view() + ->selectionModel() + ->selection() + .indexes()) { if (index.column() != 0) continue; int row = app_->playlist_manager()->current()->proxy()->mapToSource(index).row(); @@ -1430,7 +1432,9 @@ void MainWindow::AddToPlaylist(QAction* action) { } SongList songs; - foreach(PlaylistItemPtr item, items) { songs << item->Metadata(); } + for (PlaylistItemPtr item : items) { + songs << item->Metadata(); + } // we're creating a new playlist if (destination == -1) { @@ -1495,7 +1499,7 @@ void MainWindow::PlaylistRightClick(const QPoint& global_pos, int not_in_queue = 0; int in_skipped = 0; int not_in_skipped = 0; - foreach(const QModelIndex & index, selection) { + for (const QModelIndex& index : selection) { if (index.column() != 0) continue; PlaylistItemPtr item = @@ -1612,7 +1616,7 @@ void MainWindow::PlaylistRightClick(const QPoint& global_pos, playlist_copy_to_device_->setVisible(editable); // Remove old item actions, if any. - foreach(QAction * action, playlistitem_actions_) { + for (QAction* action : playlistitem_actions_) { playlist_menu_->removeAction(action); } @@ -1635,8 +1639,8 @@ void MainWindow::PlaylistRightClick(const QPoint& global_pos, QMenu* add_to_another_menu = new QMenu(tr("Add to another playlist"), this); add_to_another_menu->setIcon(IconLoader::Load("list-add")); - PlaylistBackend::Playlist playlist; - foreach(playlist, app_->playlist_backend()->GetAllOpenPlaylists()) { + for (PlaylistBackend::Playlist playlist : + app_->playlist_backend()->GetAllOpenPlaylists()) { // don't add the current playlist if (playlist.id != app_->playlist_manager()->current()->id()) { QAction* existing_playlist = new QAction(this); @@ -1678,8 +1682,10 @@ void MainWindow::EditTracks() { SongList songs; PlaylistItemList items; - foreach(const QModelIndex & index, - ui_->playlist->view()->selectionModel()->selection().indexes()) { + for (const QModelIndex& index : ui_->playlist->view() + ->selectionModel() + ->selection() + .indexes()) { if (index.column() != 0) continue; int row = app_->playlist_manager()->current()->proxy()->mapToSource(index).row(); @@ -1698,7 +1704,7 @@ void MainWindow::EditTracks() { } void MainWindow::EditTagDialogAccepted() { - foreach(PlaylistItemPtr item, edit_tag_dialog_->playlist_items()) { + for (PlaylistItemPtr item : edit_tag_dialog_->playlist_items()) { item->Reload(); } @@ -1726,7 +1732,7 @@ void MainWindow::RenumberTracks() { if (first_song.track() > 0) track = first_song.track(); } - foreach(const QModelIndex & index, indexes) { + for (const QModelIndex& index : indexes) { if (index.column() != 0) continue; const QModelIndex source_index = @@ -1764,7 +1770,7 @@ void MainWindow::SelectionSetValue() { QModelIndexList indexes = ui_->playlist->view()->selectionModel()->selection().indexes(); - foreach(const QModelIndex & index, indexes) { + for (const QModelIndex& index : indexes) { if (index.column() != 0) continue; const QModelIndex source_index = @@ -1822,7 +1828,7 @@ void MainWindow::AddFile() { // Convert to URLs QList urls; - foreach(const QString & path, file_names) { + for (const QString& path : file_names) { urls << QUrl::fromLocalFile(QFileInfo(path).canonicalFilePath()); } @@ -1899,7 +1905,7 @@ void MainWindow::ShowInLibrary() { ui_->playlist->view()->selectionModel()->selectedRows(); SongList songs; - foreach(const QModelIndex & proxy_index, proxy_indexes) { + for (const QModelIndex& proxy_index : proxy_indexes) { QModelIndex index = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index); if (app_->playlist_manager() @@ -2061,8 +2067,10 @@ void MainWindow::AddFilesToTranscoder() { QStringList filenames; - foreach(const QModelIndex & index, - ui_->playlist->view()->selectionModel()->selection().indexes()) { + for (const QModelIndex& index : ui_->playlist->view() + ->selectionModel() + ->selection() + .indexes()) { if (index.column() != 0) continue; int row = app_->playlist_manager()->current()->proxy()->mapToSource(index).row(); @@ -2133,7 +2141,7 @@ void MainWindow::EditFileTags(const QList& urls) { EnsureEditTagDialogCreated(); SongList songs; - foreach(const QUrl & url, urls) { + for (const QUrl& url : urls) { Song song; song.set_url(url); song.set_valid(true); @@ -2154,7 +2162,7 @@ void MainWindow::PlaylistOrganiseSelected(bool copy) { ui_->playlist->view()->selectionModel()->selectedRows(); SongList songs; - foreach(const QModelIndex & proxy_index, proxy_indexes) { + for (const QModelIndex& proxy_index : proxy_indexes) { QModelIndex index = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index); @@ -2187,7 +2195,7 @@ void MainWindow::PlaylistDelete() { SongList selected_songs; QModelIndexList proxy_indexes = ui_->playlist->view()->selectionModel()->selectedRows(); - foreach(const QModelIndex & proxy_index, proxy_indexes) { + for (const QModelIndex& proxy_index : proxy_indexes) { QModelIndex index = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index); selected_songs << app_->playlist_manager() @@ -2209,7 +2217,7 @@ void MainWindow::PlaylistOpenInBrowser() { QModelIndexList proxy_indexes = ui_->playlist->view()->selectionModel()->selectedRows(); - foreach(const QModelIndex & proxy_index, proxy_indexes) { + for (const QModelIndex& proxy_index : proxy_indexes) { const QModelIndex index = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index); urls << QUrl(index.sibling(index.row(), Playlist::Column_Filename) @@ -2230,8 +2238,9 @@ void MainWindow::DeleteFinished(const SongList& songs_with_errors) { void MainWindow::PlaylistQueue() { QModelIndexList indexes; - foreach(const QModelIndex & proxy_index, - ui_->playlist->view()->selectionModel()->selectedRows()) { + for (const QModelIndex& proxy_index : ui_->playlist->view() + ->selectionModel() + ->selectedRows()) { indexes << app_->playlist_manager()->current()->proxy()->mapToSource( proxy_index); } @@ -2241,8 +2250,9 @@ void MainWindow::PlaylistQueue() { void MainWindow::PlaylistSkip() { QModelIndexList indexes; - foreach(const QModelIndex & proxy_index, - ui_->playlist->view()->selectionModel()->selectedRows()) { + for (const QModelIndex& proxy_index : ui_->playlist->view() + ->selectionModel() + ->selectedRows()) { indexes << app_->playlist_manager()->current()->proxy()->mapToSource( proxy_index); } @@ -2255,7 +2265,7 @@ void MainWindow::PlaylistCopyToDevice() { ui_->playlist->view()->selectionModel()->selectedRows(); SongList songs; - foreach(const QModelIndex & proxy_index, proxy_indexes) { + for (const QModelIndex& proxy_index : proxy_indexes) { QModelIndex index = app_->playlist_manager()->current()->proxy()->mapToSource(proxy_index); @@ -2391,7 +2401,7 @@ void MainWindow::CheckFullRescanRevisions() { "requires a full library rescan " "because of the new features listed below:") + "

" + tr("Would you like to run a full rescan right now?"); @@ -2524,8 +2534,10 @@ void MainWindow::AutoCompleteTags() { // Get the selected songs and start fetching tags for them SongList songs; autocomplete_tag_items_.clear(); - foreach(const QModelIndex & index, - ui_->playlist->view()->selectionModel()->selection().indexes()) { + for (const QModelIndex& index : ui_->playlist->view() + ->selectionModel() + ->selection() + .indexes()) { if (index.column() != 0) continue; int row = app_->playlist_manager()->current()->proxy()->mapToSource(index).row(); @@ -2545,7 +2557,9 @@ void MainWindow::AutoCompleteTags() { } void MainWindow::AutoCompleteTagsAccepted() { - foreach(PlaylistItemPtr item, autocomplete_tag_items_) { item->Reload(); } + for (PlaylistItemPtr item : autocomplete_tag_items_) { + item->Reload(); + } // This is really lame but we don't know what rows have changed ui_->playlist->view()->update(); diff --git a/src/ui/networkremotesettingspage.cpp b/src/ui/networkremotesettingspage.cpp index 57debe8e4..01c59b8db 100644 --- a/src/ui/networkremotesettingspage.cpp +++ b/src/ui/networkremotesettingspage.cpp @@ -71,7 +71,7 @@ void NetworkRemoteSettingsPage::Load() { // Get local ip addresses QString ip_addresses; QList addresses = QNetworkInterface::allAddresses(); - foreach(const QHostAddress & address, addresses) { + for (const QHostAddress& address : addresses) { // TODO: Add ipv6 support to tinysvcmdns. if (address.protocol() == QAbstractSocket::IPv4Protocol && !address.isInSubnet(QHostAddress::parseSubnet("127.0.0.1/8"))) { diff --git a/src/ui/organiseerrordialog.cpp b/src/ui/organiseerrordialog.cpp index 24fec04cf..e40167135 100644 --- a/src/ui/organiseerrordialog.cpp +++ b/src/ui/organiseerrordialog.cpp @@ -36,7 +36,7 @@ OrganiseErrorDialog::~OrganiseErrorDialog() { delete ui_; } void OrganiseErrorDialog::Show(OperationType type, const SongList& songs_with_errors) { QStringList files; - foreach(const Song & song, songs_with_errors) { + for (const Song& song : songs_with_errors) { files << song.url().toLocalFile(); } Show(type, files); diff --git a/src/ui/playbacksettingspage.cpp b/src/ui/playbacksettingspage.cpp index f601beb2e..bf87a2271 100644 --- a/src/ui/playbacksettingspage.cpp +++ b/src/ui/playbacksettingspage.cpp @@ -51,7 +51,7 @@ void PlaybackSettingsPage::Load() { GstEngine::PluginDetailsList list = engine->GetOutputsList(); ui_->gst_plugin->setItemData(0, GstEngine::kAutoSink); - foreach(const GstEngine::PluginDetails & details, list) { + for (const GstEngine::PluginDetails& details : list) { if (details.name == "autoaudiosink") continue; ui_->gst_plugin->addItem(details.long_name, details.name); diff --git a/src/ui/ripcd.cpp b/src/ui/ripcd.cpp index 7bfada2d5..6b3b0de90 100644 --- a/src/ui/ripcd.cpp +++ b/src/ui/ripcd.cpp @@ -429,19 +429,19 @@ void RipCD::SetWorking(bool working) { } void RipCD::SelectAll() { - foreach(QCheckBox * checkbox, checkboxes_) { + for (QCheckBox* checkbox : checkboxes_) { checkbox->setCheckState(Qt::Checked); } } void RipCD::SelectNone() { - foreach(QCheckBox * checkbox, checkboxes_) { + for (QCheckBox* checkbox : checkboxes_) { checkbox->setCheckState(Qt::Unchecked); } } void RipCD::InvertSelection() { - foreach(QCheckBox * checkbox, checkboxes_) { + for (QCheckBox* checkbox : checkboxes_) { if (checkbox->isChecked()) { checkbox->setCheckState(Qt::Unchecked); } else { diff --git a/src/ui/settingsdialog.cpp b/src/ui/settingsdialog.cpp index 2dc3016cd..dfce3317d 100644 --- a/src/ui/settingsdialog.cpp +++ b/src/ui/settingsdialog.cpp @@ -251,7 +251,9 @@ void SettingsDialog::AddPage(Page id, SettingsPage* page, } void SettingsDialog::Save() { - foreach(const PageData & data, pages_.values()) { data.page_->Save(); } + for (const PageData& data : pages_.values()) { + data.page_->Save(); + } } void SettingsDialog::accept() { @@ -261,7 +263,9 @@ void SettingsDialog::accept() { void SettingsDialog::reject() { // Notify each page that user clicks on Cancel - foreach(const PageData & data, pages_.values()) { data.page_->Cancel(); } + for (const PageData& data : pages_.values()) { + data.page_->Cancel(); + } QDialog::reject(); } @@ -276,7 +280,9 @@ void SettingsDialog::DialogButtonClicked(QAbstractButton* button) { void SettingsDialog::showEvent(QShowEvent* e) { // Load settings loading_settings_ = true; - foreach(const PageData & data, pages_.values()) { data.page_->Load(); } + for (const PageData& data : pages_.values()) { + data.page_->Load(); + } loading_settings_ = false; // Resize the dialog if it's too big @@ -307,7 +313,7 @@ void SettingsDialog::CurrentItemChanged(QTreeWidgetItem* item) { ui_->title->setText("" + item->text(0) + ""); // Display the right page - foreach(const PageData & data, pages_.values()) { + for (const PageData& data : pages_.values()) { if (data.item_ == item) { ui_->stacked_widget->setCurrentWidget(data.scroll_area_); break; diff --git a/src/ui/trackselectiondialog.cpp b/src/ui/trackselectiondialog.cpp index 3423ca0c6..162489b58 100644 --- a/src/ui/trackselectiondialog.cpp +++ b/src/ui/trackselectiondialog.cpp @@ -74,7 +74,7 @@ void TrackSelectionDialog::Init(const SongList& songs) { ui_->stack->setCurrentWidget(ui_->loading_page); data_.clear(); - foreach(const Song & song, songs) { + for (const Song& song : songs) { Data data; data.original_song_ = song; data_ << data; @@ -166,7 +166,7 @@ void TrackSelectionDialog::UpdateStack() { AddDivider(tr("Suggested tags"), ui_->results); int song_index = 0; - foreach(const Song & song, data.results_) { + for (const Song& song : data.results_) { AddSong(song, song_index++, ui_->results); } @@ -265,7 +265,7 @@ void TrackSelectionDialog::accept() { QDialog::accept(); - foreach(const Data & data, data_) { + for (const Data& data : data_) { if (data.pending_ || data.results_.isEmpty() || data.selected_result_ == -1) continue; diff --git a/src/ui/windows7thumbbar.cpp b/src/ui/windows7thumbbar.cpp index 0dc01ea78..4eb754e40 100644 --- a/src/ui/windows7thumbbar.cpp +++ b/src/ui/windows7thumbbar.cpp @@ -43,7 +43,7 @@ void Windows7ThumbBar::SetActions(const QList& actions) { Q_ASSERT(actions.count() <= kMaxButtonCount); actions_ = actions; - foreach(QAction * action, actions) { + for (QAction* action : actions) { if (action) { connect(action, SIGNAL(changed()), SLOT(ActionChanged())); } diff --git a/src/visualisations/projectmpresetmodel.cpp b/src/visualisations/projectmpresetmodel.cpp index 7065c43d0..a9cadfadd 100644 --- a/src/visualisations/projectmpresetmodel.cpp +++ b/src/visualisations/projectmpresetmodel.cpp @@ -39,7 +39,7 @@ ProjectMPresetModel::ProjectMPresetModel(ProjectMVisualisation* vis, QDir::Files | QDir::NoDotAndDotDot | QDir::Readable, QDir::Name | QDir::IgnoreCase)); - foreach(const QString & filename, presets) { + for (const QString& filename : presets) { all_presets_ << Preset(preset_dir.absoluteFilePath(filename), filename, false); } diff --git a/src/visualisations/projectmvisualisation.cpp b/src/visualisations/projectmvisualisation.cpp index 3ef229d40..4f45c5d38 100644 --- a/src/visualisations/projectmvisualisation.cpp +++ b/src/visualisations/projectmvisualisation.cpp @@ -81,7 +81,7 @@ void ProjectMVisualisation::InitProjectM() { #endif QString preset_path; - foreach(const QString & path, paths) { + for (const QString& path : paths) { if (!QFile::exists(path)) continue; // Don't use empty directories @@ -175,7 +175,7 @@ void ProjectMVisualisation::ConsumeBuffer(GstBuffer* buffer, int) { void ProjectMVisualisation::SetSelected(const QStringList& paths, bool selected) { - foreach(const QString & path, paths) { + for (const QString& path : paths) { int index = IndexOfPreset(path); if (selected && index == -1) { projectm_->addPresetURL(path.toStdString(), std::string(), @@ -220,7 +220,7 @@ void ProjectMVisualisation::Load() { case FromList: { QStringList paths(s.value("preset_paths").toStringList()); - foreach(const QString & path, paths) { + for (const QString& path : paths) { projectm_->addPresetURL(path.toStdString(), std::string(), default_rating_list_); preset_model_->MarkSelected(path, true); @@ -232,8 +232,8 @@ void ProjectMVisualisation::Load() { void ProjectMVisualisation::Save() { QStringList paths; - foreach(const ProjectMPresetModel::Preset & preset, - preset_model_->all_presets_) { + for (const ProjectMPresetModel::Preset& preset : + preset_model_->all_presets_) { if (preset.selected_) paths << preset.path_; } diff --git a/src/widgets/errordialog.cpp b/src/widgets/errordialog.cpp index 6b34aabba..eb6e0bef8 100644 --- a/src/widgets/errordialog.cpp +++ b/src/widgets/errordialog.cpp @@ -51,7 +51,7 @@ void ErrorDialog::hideEvent(QHideEvent*) { void ErrorDialog::UpdateContent() { QString html; - foreach(const QString & message, current_messages_) { + for (const QString& message : current_messages_) { if (!html.isEmpty()) html += "
"; html += Qt::escape(message); } diff --git a/src/widgets/fancytabwidget.cpp b/src/widgets/fancytabwidget.cpp index d28483db9..c61d3fe83 100644 --- a/src/widgets/fancytabwidget.cpp +++ b/src/widgets/fancytabwidget.cpp @@ -613,7 +613,7 @@ void FancyTabWidget::SetMode(Mode mode) { side_layout_->insertWidget(0, bar); tab_bar_ = bar; - foreach(const Item & item, items_) { + for (const Item& item : items_) { if (item.type_ == Item::Type_Spacer) bar->addSpacer(item.spacer_size_); else @@ -703,7 +703,7 @@ void FancyTabWidget::MakeTabBar(QTabBar::Shape shape, bool text, bool icons, else side_layout_->insertWidget(0, bar); - foreach(const Item & item, items_) { + for (const Item& item : items_) { if (item.type_ != Item::Type_Tab) continue; QString label = item.tab_label_; diff --git a/src/widgets/fileviewlist.cpp b/src/widgets/fileviewlist.cpp index 841113b84..27ff164a2 100644 --- a/src/widgets/fileviewlist.cpp +++ b/src/widgets/fileviewlist.cpp @@ -62,7 +62,7 @@ void FileViewList::contextMenuEvent(QContextMenuEvent* e) { QList FileViewList::UrlListFromSelection() const { QList urls; - foreach(const QModelIndex & index, menu_selection_.indexes()) { + for (const QModelIndex& index : menu_selection_.indexes()) { if (index.column() == 0) urls << QUrl::fromLocalFile(static_cast(model()) ->fileInfo(index) @@ -90,7 +90,7 @@ MimeData* FileViewList::MimeDataFromSelection() const { QStringList FileViewList::FilenamesFromSelection() const { QStringList filenames; - foreach(const QModelIndex & index, menu_selection_.indexes()) { + for (const QModelIndex& index : menu_selection_.indexes()) { if (index.column() == 0) filenames << static_cast(model())->filePath(index); } diff --git a/src/widgets/freespacebar.cpp b/src/widgets/freespacebar.cpp index 1f25c04d5..763e56cbe 100644 --- a/src/widgets/freespacebar.cpp +++ b/src/widgets/freespacebar.cpp @@ -171,15 +171,15 @@ void FreeSpaceBar::DrawText(QPainter* p, const QRect& r) { labels << Label(TextForSize(free_text_, free_ - additional_), kColorBg2); int text_width = 0; - foreach(const Label & label, labels) - text_width += kLabelBoxSize + kLabelBoxPadding + kLabelSpacing + - small_metrics.width(label.text); + for (const Label& label : labels) + text_width += kLabelBoxSize + kLabelBoxPadding + kLabelSpacing + + small_metrics.width(label.text); // Draw the text int x = (r.width() - text_width) / 2; p->setRenderHint(QPainter::Antialiasing, false); - foreach(const Label & label, labels) { + for (const Label& label : labels) { const bool light = palette().color(QPalette::Base).value() > 128; QRect box(x, r.top() + (r.height() - kLabelBoxSize) / 2, kLabelBoxSize, diff --git a/src/widgets/groupediconview.cpp b/src/widgets/groupediconview.cpp index 32f41c4ef..ba0fef26b 100644 --- a/src/widgets/groupediconview.cpp +++ b/src/widgets/groupediconview.cpp @@ -270,7 +270,7 @@ void GroupedIconView::paintEvent(QPaintEvent* e) { } // Draw headers - foreach(const Header & header, headers_) { + for (const Header& header : headers_) { const QRect header_rect = QRect(header_indent_, header.y, viewport()->width() - header_indent_ * 2, header_height()); @@ -294,7 +294,7 @@ void GroupedIconView::setSelection( IntersectingItems(rect.translated(horizontalOffset(), verticalOffset()))); QItemSelection selection; - foreach(const QModelIndex & index, indexes) { + for (const QModelIndex& index : indexes) { selection << QItemSelectionRange(index); } @@ -318,7 +318,7 @@ QVector GroupedIconView::IntersectingItems(const QRect& rect) QRegion GroupedIconView::visualRegionForSelection( const QItemSelection& selection) const { QRegion ret; - foreach(const QModelIndex & index, selection.indexes()) { + for (const QModelIndex& index : selection.indexes()) { ret += visual_rects_[index.row()]; } return ret; diff --git a/src/widgets/loginstatewidget.cpp b/src/widgets/loginstatewidget.cpp index 8abbbc87c..5019fda76 100644 --- a/src/widgets/loginstatewidget.cpp +++ b/src/widgets/loginstatewidget.cpp @@ -70,7 +70,7 @@ void LoginStateWidget::SetLoggedIn(State state, const QString& account_name) { ui_->signed_in_label->setText( tr("You are signed in as %1.").arg("" + account_name + "")); - foreach(QWidget * widget, credential_groups_) { + for (QWidget* widget : credential_groups_) { widget->setVisible(state != LoggedIn); widget->setEnabled(state != LoginInProgress); } diff --git a/src/widgets/multiloadingindicator.cpp b/src/widgets/multiloadingindicator.cpp index cf048ce5f..1f40df53e 100644 --- a/src/widgets/multiloadingindicator.cpp +++ b/src/widgets/multiloadingindicator.cpp @@ -50,7 +50,7 @@ void MultiLoadingIndicator::UpdateText() { QList tasks = task_manager_->GetTasks(); QStringList strings; - foreach(const TaskManager::Task & task, tasks) { + for (const TaskManager::Task& task : tasks) { QString task_text(task.name); task_text[0] = task_text[0].toLower(); diff --git a/src/widgets/stylehelper.cpp b/src/widgets/stylehelper.cpp index cc9b98aec..25dc1f128 100644 --- a/src/widgets/stylehelper.cpp +++ b/src/widgets/stylehelper.cpp @@ -108,8 +108,7 @@ void StyleHelper::setBaseColor(const QColor& newcolor) { if (color.isValid() && color != m_baseColor) { m_baseColor = color; - foreach(QWidget * w, QApplication::topLevelWidgets()) - w->update(); + for (QWidget* w : QApplication::topLevelWidgets()) w->update(); } } diff --git a/src/wiimotedev/shortcuts.cpp b/src/wiimotedev/shortcuts.cpp index 761ba53d8..d002d048c 100644 --- a/src/wiimotedev/shortcuts.cpp +++ b/src/wiimotedev/shortcuts.cpp @@ -92,7 +92,7 @@ void WiimotedevShortcuts::ReloadSettings() { quint64 fvalue, svalue; bool fvalid, svalid; - foreach(const QString & str, settings_.allKeys()) { + for (const QString& str : settings_.allKeys()) { fvalue = str.toULongLong(&fvalid, 10); svalue = settings_.value(str, 0).toULongLong(&svalid); if (fvalid && svalid) actions_[fvalue] = svalue; diff --git a/src/wiimotedev/wiimotesettingspage.cpp b/src/wiimotedev/wiimotesettingspage.cpp index 9fe00dbed..3c9adfcf3 100644 --- a/src/wiimotedev/wiimotesettingspage.cpp +++ b/src/wiimotedev/wiimotesettingspage.cpp @@ -127,7 +127,7 @@ WiimoteSettingsPage::WiimoteSettingsPage(SettingsDialog* dialog) } void WiimoteSettingsPage::AddShortcut(quint64 button, quint32 action) { - foreach(const Shortcut & shortcut, actions_) { + for (const Shortcut& shortcut : actions_) { if (shortcut.button == button) { QMessageBox::information(this, tr("Information"), QString(tr("Shortcut for %1 already exists")) @@ -172,7 +172,7 @@ void WiimoteSettingsPage::Load() { quint64 fvalue, svalue; bool fvalid, svalid; - foreach(const QString & str, s.allKeys()) { + for (const QString& str : s.allKeys()) { fvalue = str.toULongLong(&fvalid, 10); svalue = s.value(str, 0).toULongLong(&svalid); if (fvalid && svalid) AddShortcut(fvalue, svalue); @@ -187,8 +187,8 @@ void WiimoteSettingsPage::Save() { s.beginGroup(WiimotedevShortcuts::kActionsGroup); s.remove(""); - foreach(const Shortcut & shortcut, actions_) - s.setValue(QString::number(shortcut.button), shortcut.action); + for (const Shortcut& shortcut : actions_) + s.setValue(QString::number(shortcut.button), shortcut.action); s.endGroup(); s.beginGroup(WiimotedevShortcuts::kSettingsGroup); diff --git a/src/wiimotedev/wiimoteshortcutgrabber.cpp b/src/wiimotedev/wiimoteshortcutgrabber.cpp index d712681b2..6e2259fa0 100644 --- a/src/wiimotedev/wiimoteshortcutgrabber.cpp +++ b/src/wiimotedev/wiimoteshortcutgrabber.cpp @@ -41,8 +41,8 @@ WiimoteShortcutGrabber::WiimoteShortcutGrabber(quint32 action, quint32 device, SLOT(DbusWiimoteGeneralButtons(uint, qulonglong))); } - foreach(const QString & name, config_->TextActions()) - ui_->comboBox->addItem(name); + for (const QString& name : config_->TextActions()) + ui_->comboBox->addItem(name); ui_->comboBox->setCurrentIndex(pref_action_); ui_->keep_label->setVisible(false);