Replace old for-loops with range-based for-loops

This commit is contained in:
Gianluca Recchia 2018-10-27 23:54:57 +02:00
parent 4876beabed
commit 4ac1601696
No known key found for this signature in database
GPG Key ID: 3C2B4128D9A1F218
4 changed files with 8 additions and 9 deletions

View File

@ -121,8 +121,8 @@ QString imageReaderFilter()
QStringList formatsStringList;
for (const QByteArray& format : formats) {
for (int i = 0; i < format.size(); i++) {
if (!QChar(format.at(i)).isLetterOrNumber()) {
for (char codePoint : format) {
if (!QChar(codePoint).isLetterOrNumber()) {
continue;
}
}

View File

@ -146,8 +146,8 @@ void ApplicationSettingsWidget::loadSettings()
m_generalUi->languageComboBox->clear();
QList<QPair<QString, QString>> languages = Translator::availableLanguages();
for (int i = 0; i < languages.size(); i++) {
m_generalUi->languageComboBox->addItem(languages[i].second, languages[i].first);
for (const auto& language : languages) {
m_generalUi->languageComboBox->addItem(language.second, language.first);
}
int defaultIndex = m_generalUi->languageComboBox->findData(config()->get("GUI/Language"));
if (defaultIndex > 0) {

View File

@ -71,8 +71,7 @@ bool DialogyWidget::clickButton(QDialogButtonBox::StandardButton standardButton)
}
QList<QDialogButtonBox*> buttonBoxes = findChildren<QDialogButtonBox*>();
for (int i = 0; i < buttonBoxes.size(); ++i) {
QDialogButtonBox* buttonBox = buttonBoxes.at(i);
for (auto buttonBox : buttonBoxes) {
pb = buttonBox->button(standardButton);
if (pb && pb->isVisible() && pb->isEnabled()) {
pb->click();

View File

@ -208,12 +208,12 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
case Attachments: {
// Display comma-separated list of attachments
QList<QString> attachments = entry->attachments()->keys();
for (int i = 0; i < attachments.size(); ++i) {
for (const auto& attachment : attachments) {
if (result.isEmpty()) {
result.append(attachments.at(i));
result.append(attachment);
continue;
}
result.append(QString(", ") + attachments.at(i));
result.append(QString(", ") + attachment);
}
return result;
}