Use more auto in for statements

This commit is contained in:
Krzysztof A. Sobiecki 2014-01-25 14:03:09 +01:00
parent df992a4b4b
commit b0a97de603
3 changed files with 13 additions and 13 deletions

View File

@ -53,7 +53,7 @@ Organise::Organise(TaskManager* task_manager,
{
original_thread_ = thread();
for (const Song& song : songs) {
for (const auto& song : songs) {
tasks_pending_ << Task(song);
}
}
@ -79,7 +79,7 @@ void Organise::ProcessSomeFiles() {
if (!destination_->StartCopy(&supported_filetypes_)) {
// Failed to start - mark everything as failed :(
for (const Task& task : tasks_pending_)
for (const auto& task : tasks_pending_)
files_with_errors_ << task.song_.url().toLocalFile();
tasks_pending_.clear();
}
@ -237,7 +237,7 @@ void Organise::UpdateProgress() {
// Update transcoding progress
QMap<QString, float> transcode_progress = transcoder_->GetProgress();
for (const QString& filename : transcode_progress.keys()) {
for (const auto& filename : transcode_progress.keys()) {
if (!tasks_transcoding_.contains(filename))
continue;
tasks_transcoding_[filename].transcode_progress_ = transcode_progress[filename];
@ -248,10 +248,10 @@ void Organise::UpdateProgress() {
// only need to be copied total 100.
int progress = tasks_complete_ * 100;
for (const Task& task : tasks_pending_) {
for (const auto& task : tasks_pending_) {
progress += qBound(0, static_cast<int>(task.transcode_progress_ * 50), 50);
}
for (const Task& task : tasks_transcoding_.values()) {
for (const auto& task : tasks_transcoding_.values()) {
progress += qBound(0, static_cast<int>(task.transcode_progress_ * 50), 50);
}

View File

@ -62,7 +62,7 @@ void PodcastBackend::Subscribe(Podcast* podcast) {
// Update the IDs of any episodes.
PodcastEpisodeList* episodes = podcast->mutable_episodes();
for (PodcastEpisodeList::iterator it = episodes->begin() ; it != episodes->end() ; ++it) {
for (auto it = episodes->begin() ; it != episodes->end() ; ++it) {
it->set_podcast_database_id(database_id);
}
@ -107,7 +107,7 @@ void PodcastBackend::AddEpisodes(PodcastEpisodeList* episodes, QSqlDatabase* db)
QSqlQuery q("INSERT INTO podcast_episodes (" + PodcastEpisode::kColumnSpec + ")"
" VALUES (" + PodcastEpisode::kBindSpec + ")", *db);
for (PodcastEpisodeList::iterator it = episodes->begin() ; it != episodes->end() ; ++it) {
for (auto it = episodes->begin() ; it != episodes->end() ; ++it) {
it->BindToQuery(&q);
q.exec();
if (db_->CheckErrors(q))
@ -141,7 +141,7 @@ void PodcastBackend::UpdateEpisodes(const PodcastEpisodeList& episodes) {
" local_url = :local_url"
" WHERE ROWID = :id", db);
for (const PodcastEpisode& episode : episodes) {
for (const auto& episode : episodes) {
q.bindValue(":listened", episode.listened());
q.bindValue(":listened_date", episode.listened_date().toTime_t());
q.bindValue(":downloaded", episode.downloaded());

View File

@ -85,7 +85,7 @@ OrganiseDialog::OrganiseDialog(TaskManager* task_manager, QWidget *parent)
// Build the insert menu
QMenu* tag_menu = new QMenu(this);
QSignalMapper* tag_mapper = new QSignalMapper(this);
for (const QString& title : tag_titles) {
for (const auto& title : tag_titles) {
QAction* action = tag_menu->addAction(title, tag_mapper, SLOT(map()));
tag_mapper->setMapping(action, tags[title]);
}
@ -108,7 +108,7 @@ int OrganiseDialog::SetSongs(const SongList& songs) {
total_size_ = 0;
songs_.clear();
for (const Song& song : songs) {
for (const auto& song : songs) {
if (song.url().scheme() != "file") {
continue;
}
@ -130,7 +130,7 @@ int OrganiseDialog::SetUrls(const QList<QUrl> &urls, quint64 total_size) {
Song song;
// Only add file:// URLs
for (const QUrl& url : urls) {
for (const auto& url : urls) {
if (url.scheme() != "file")
continue;
TagReaderClient::Instance()->ReadFileBlocking(url.toLocalFile(), &song);
@ -146,7 +146,7 @@ int OrganiseDialog::SetFilenames(const QStringList& filenames, quint64 total_siz
Song song;
// Load some of the songs to show in the preview
for (const QString& filename : filenames) {
for (const auto& filename : filenames) {
TagReaderClient::Instance()->ReadFileBlocking(song.basefilename(), &song);
if (song.is_valid())
songs << song;
@ -210,7 +210,7 @@ void OrganiseDialog::UpdatePreviews() {
ui_->preview_group->setVisible(has_local_destination);
ui_->naming_group->setVisible(has_local_destination);
if (has_local_destination) {
for (const Song& song : songs_) {
for (const auto& song : songs_) {
QString filename = storage->LocalPath() + "/" +
format_.GetFilenameForSong(song);
ui_->preview->addItem(QDir::toNativeSeparators(filename));