use C++11 foreach loop consistently (instead of Qt foreach macro)

This commit is contained in:
Martchus 2016-03-05 17:12:16 +01:00
parent 283c1f1f71
commit 0adb77fd58
7 changed files with 25 additions and 25 deletions

View File

@ -15,7 +15,7 @@ JavaScriptHighlighter::JavaScriptHighlighter(QTextDocument *parent)
<< "\\belse\\b" << "\\bfor\\b" << "\\bswitch\\b"
<< "\\bcase\\b" << "\\bbreak\\b" << "\\bwhile\\b"
<< "\\bundefined\\b" << "\\continue\\b";
foreach (const QString &pattern, keywordPatterns) {
for(const QString &pattern : keywordPatterns) {
rule.pattern = QRegExp(pattern);
rule.format = m_keywordFormat;
m_highlightingRules.append(rule);
@ -45,7 +45,7 @@ JavaScriptHighlighter::JavaScriptHighlighter(QTextDocument *parent)
void JavaScriptHighlighter::highlightBlock(const QString &text)
{
foreach (const HighlightingRule &rule, m_highlightingRules) {
for(const HighlightingRule &rule : m_highlightingRules) {
QRegExp expression(rule.pattern);
int index = expression.indexIn(text);
while (index >= 0) {

View File

@ -259,7 +259,7 @@ void RenameFilesDialog::currentItemSelected(const QItemSelection &, const QItemS
if(!m_changingSelection) {
m_changingSelection = true;
m_ui->previewTreeView->selectionModel()->clear();
foreach(const QModelIndex &row, m_ui->currentTreeView->selectionModel()->selectedRows()) {
for(const QModelIndex &row : m_ui->currentTreeView->selectionModel()->selectedRows()) {
QModelIndex currentIndex = m_engine->currentModel()->mapToSource(row);
QModelIndex counterpartIndex = m_engine->model()->counterpart(
currentIndex, 1);
@ -285,7 +285,7 @@ void RenameFilesDialog::previewItemSelected(const QItemSelection &, const QItemS
if(!m_changingSelection) {
m_changingSelection = true;
m_ui->currentTreeView->selectionModel()->clear();
foreach(const QModelIndex &row, m_ui->previewTreeView->selectionModel()->selectedRows()) {
for(const QModelIndex &row : m_ui->previewTreeView->selectionModel()->selectedRows()) {
QModelIndex previewIndex = m_engine->previewModel()->mapToSource(row);
QModelIndex counterpartIndex = m_engine->model()->counterpart(
previewIndex, 0);

View File

@ -114,7 +114,7 @@ bool TagEdit::setValue(KnownField field, const Media::TagValue &value, PreviousV
*/
bool TagEdit::hasField(KnownField field) const
{
foreach(Tag *tag, m_tags) {
for(Tag *tag : m_tags) {
if(tag->supportsField(field)) {
return true;
}
@ -133,7 +133,7 @@ QString TagEdit::generateLabel() const
TagTarget target = m_tags.at(0)->target();
bool differentTargets = false;
QStringList tagNames;
foreach(Tag *tag, m_tags) {
for(Tag *tag : m_tags) {
tagNames << QString::fromLocal8Bit(tag->typeName());
if(!differentTargets && !(target == tag->target())) {
differentTargets = true;
@ -157,7 +157,7 @@ QString TagEdit::generateLabel() const
*/
void TagEdit::clear()
{
foreach(TagFieldEdit *edit, m_widgets) {
for(TagFieldEdit *edit : m_widgets) {
edit->clear();
}
}
@ -167,7 +167,7 @@ void TagEdit::clear()
*/
void TagEdit::restore()
{
foreach(TagFieldEdit *edit, m_widgets) {
for(TagFieldEdit *edit : m_widgets) {
edit->restore();
}
}
@ -181,14 +181,14 @@ void TagEdit::apply()
case Settings::UnsupportedFieldHandling::Discard:
// remove all old fields of all tags to discard
// all unsupported values
foreach(Tag *tag, m_tags) {
for(Tag *tag : m_tags) {
tag->removeAllFields();
}
break;
default:
;
}
foreach(TagFieldEdit *edit, m_widgets) {
for(TagFieldEdit *edit : m_widgets) {
edit->apply();
}
}
@ -202,7 +202,7 @@ void TagEdit::apply()
void TagEdit::invalidate()
{
// remove current widgets
foreach(QWidget *edit, m_widgets) {
for(QWidget *edit : m_widgets) {
removeEdit(edit);
edit->deleteLater();
}
@ -219,7 +219,7 @@ void TagEdit::setupUi()
setUpdatesEnabled(false);
if(!m_tags.size()) {
// there are no tags assigned -> remove all editing controls
foreach(QWidget *edit, m_widgets) {
for(QWidget *edit : m_widgets) {
removeEdit(edit);
edit->deleteLater();
}
@ -335,7 +335,7 @@ void TagEdit::removeEdit(QWidget *edit)
*/
void TagEdit::assignTags()
{
foreach(TagFieldEdit *edit, m_widgets) {
for(TagFieldEdit *edit : m_widgets) {
edit->setTagField(m_tags, edit->field(), m_previousValueHandling, true);
}
}

View File

@ -174,7 +174,7 @@ bool TagFieldEdit::setValue(const TagValue &value, PreviousValueHandling previou
*/
bool TagFieldEdit::hasDescription() const
{
foreach(Tag *tag, tags()) {
for(Tag *tag : tags()) {
if(tag->supportsDescription(m_field)) {
return true;
}
@ -187,7 +187,7 @@ bool TagFieldEdit::hasDescription() const
*/
bool TagFieldEdit::canApply(KnownField field) const
{
foreach(Tag *tag, tags()) {
for(Tag *tag : tags()) {
switch(tag->type()) {
case TagType::Id3v1Tag:
if(Settings::id3v1usage() == TagUsage::Never) {
@ -215,7 +215,7 @@ bool TagFieldEdit::canApply(KnownField field) const
TagDataType TagFieldEdit::determineDataType()
{
TagDataType proposedDataType = TagDataType::Undefined;
foreach(Tag *tag, tags()) {
for(Tag *tag : tags()) {
TagDataType type = tag->proposedDataType(m_field);
if(proposedDataType == TagDataType::Undefined) {
proposedDataType = type;
@ -923,7 +923,7 @@ void TagFieldEdit::clear()
*/
void TagFieldEdit::apply()
{
foreach(Tag *tag, *m_tags) {
for(Tag *tag : *m_tags) {
if(m_dataType == TagDataType::Picture) {
if(m_pictureSelection) {
m_pictureSelection->apply();
@ -977,7 +977,7 @@ void TagFieldEdit::handleRestoreButtonClicked()
if(tags().size()) {
QMenu menu;
int i = 0;
foreach(Tag *tag, tags()) {
for(Tag *tag : tags()) {
++i;
QAction *action = menu.addAction(tr("restore to value from %1 (%2)").arg(tag->typeName()).arg(i));
connect(action, &QAction::triggered, std::bind(static_cast<void (TagFieldEdit::*) (Tag *, PreviousValueHandling)>(&TagFieldEdit::updateValue), this, tag, PreviousValueHandling::Clear));

View File

@ -33,7 +33,7 @@ FileSystemItem::FileSystemItem(ItemStatus status, ItemType type, const QString &
FileSystemItem::~FileSystemItem()
{
foreach(FileSystemItem *child, m_children) {
for(FileSystemItem *child : m_children) {
child->m_parent = nullptr;
delete child;
}
@ -128,7 +128,7 @@ bool FileSystemItem::setNewName(const QString &newName)
FileSystemItem *FileSystemItem::findChild(const QString &name) const
{
foreach(FileSystemItem *child, m_children) {
for(FileSystemItem *child : m_children) {
if(child->name() == name) {
return child;
}
@ -138,7 +138,7 @@ FileSystemItem *FileSystemItem::findChild(const QString &name) const
FileSystemItem *FileSystemItem::findChild(const QString &name, const FileSystemItem *exclude) const
{
foreach(FileSystemItem *child, m_children) {
for(FileSystemItem *child : m_children) {
if(child != exclude && child->name() == name) {
return child;
}
@ -150,7 +150,7 @@ FileSystemItem *FileSystemItem::makeChildAvailable(const QString &relativePath)
{
QStringList dirs = relativePath.split(QDir::separator(), QString::SkipEmptyParts);
FileSystemItem *parent = this;
foreach(const QString &dir, dirs) {
for(const QString &dir : dirs) {
FileSystemItem *child = parent->findChild(dir);
if(!child) {
child = new FileSystemItem(ItemStatus::New, ItemType::Dir, dir);
@ -197,7 +197,7 @@ bool FileSystemItem::hasSibling(const QString &name) const
{
if(m_parent) {
const QList<FileSystemItem *> &siblings = m_parent->children();
foreach(FileSystemItem *siblingItem, siblings) {
for(FileSystemItem *siblingItem : siblings) {
if(siblingItem == this) {
continue;
}

View File

@ -218,7 +218,7 @@ unique_ptr<FileSystemItem> RemamingEngine::generatePreview(const QDir &dir, File
void RemamingEngine::applyChangings(FileSystemItem *parentItem)
{
foreach(FileSystemItem *item, parentItem->children()) {
for(FileSystemItem *item : parentItem->children()) {
if(!item->applied() && !item->errorOccured()) {
switch(item->status()) {
case ItemStatus::New: {

View File

@ -203,7 +203,7 @@ TAGEDITOR_JS_VALUE TagEditorObject::allFiles(const QString &dirName)
QStringList files = dir.entryList(QDir::Files);
auto entriesObj = m_engine->newArray(files.length());
quint32 counter = 0;
foreach(const QString &file, files) {
for(const QString &file : files) {
entriesObj.setProperty(counter, file TAGEDITOR_JS_READONLY);
++counter;
}