diff --git a/src/ui/conf/firewallconf.cpp b/src/ui/conf/firewallconf.cpp index 2c6961f2..60fa08b0 100644 --- a/src/ui/conf/firewallconf.cpp +++ b/src/ui/conf/firewallconf.cpp @@ -202,7 +202,7 @@ quint32 FirewallConf::appGroupBits() const { quint32 groupBits = 0; int i = 0; - foreach (const AppGroup *appGroup, appGroupsList()) { + for (const AppGroup *appGroup : appGroupsList()) { if (appGroup->enabled()) { groupBits |= (1 << i); } @@ -214,7 +214,7 @@ quint32 FirewallConf::appGroupBits() const void FirewallConf::setAppGroupBits(quint32 groupBits) { int i = 0; - foreach (AppGroup *appGroup, appGroupsList()) { + for (AppGroup *appGroup : appGroupsList()) { appGroup->setEnabled(groupBits & (1 << i)); ++i; } @@ -227,7 +227,7 @@ QQmlListProperty FirewallConf::addressGroups() AppGroup *FirewallConf::appGroupByName(const QString &name) const { - foreach (AppGroup *appGroup, appGroupsList()) { + for (AppGroup *appGroup : appGroupsList()) { if (appGroup->name() == name) return appGroup; } @@ -317,13 +317,13 @@ QVariant FirewallConf::toVariant() const map["passwordHash"] = m_passwordHash; QVariantList addresses; - foreach (const AddressGroup *addressGroup, addressGroupsList()) { + for (const AddressGroup *addressGroup : addressGroupsList()) { addresses.append(addressGroup->toVariant()); } map["addressGroups"] = addresses; QVariantList groups; - foreach (const AppGroup *appGroup, appGroupsList()) { + for (const AppGroup *appGroup : appGroupsList()) { groups.append(appGroup->toVariant()); } map["appGroups"] = groups; @@ -339,13 +339,13 @@ void FirewallConf::fromVariant(const QVariant &v) const QVariantList addresses = map["addressGroups"].toList(); int addrGroupIndex = 0; - foreach (const QVariant &av, addresses) { + for (const QVariant &av : addresses) { AddressGroup *addressGroup = m_addressGroups.at(addrGroupIndex++); addressGroup->fromVariant(av); } const QVariantList groups = map["appGroups"].toList(); - foreach (const QVariant &gv, groups) { + for (const QVariant &gv : groups) { auto appGroup = new AppGroup(); appGroup->fromVariant(gv); addAppGroup(appGroup); diff --git a/src/ui/fortmanager.cpp b/src/ui/fortmanager.cpp index 24fb17b8..298c7d82 100644 --- a/src/ui/fortmanager.cpp +++ b/src/ui/fortmanager.cpp @@ -599,7 +599,7 @@ void FortManager::saveTrayFlags() m_firewallConf->setStopInetTraffic(m_stopInetTrafficAction->isChecked()); int i = 0; - foreach (AppGroup *appGroup, m_firewallConf->appGroupsList()) { + for (AppGroup *appGroup : m_firewallConf->appGroupsList()) { const QAction *action = m_appGroupActions.at(i); appGroup->setEnabled(action->isChecked()); ++i; @@ -712,7 +712,7 @@ void FortManager::updateTrayMenu() menu->addSeparator(); m_appGroupActions.clear(); int appGroupIndex = 0; - foreach (const AppGroup *appGroup, conf.appGroupsList()) { + for (const AppGroup *appGroup : conf.appGroupsList()) { QAction *a = addAction( menu, QIcon(":/images/application_double.png"), appGroup->label(), this, SLOT(saveTrayFlags()), diff --git a/src/ui/fortsettings.cpp b/src/ui/fortsettings.cpp index f82af8e9..9181f041 100644 --- a/src/ui/fortsettings.cpp +++ b/src/ui/fortsettings.cpp @@ -127,7 +127,7 @@ TasksMap FortSettings::tasks() const TasksMap map; const QString tasksPrefix("tasks"); - foreach (const QString &taskName, iniChildKeys(tasksPrefix)) { + for (const QString &taskName : iniChildKeys(tasksPrefix)) { const QString taskKey(tasksPrefix + '/' + taskName); map.insert(taskName, iniValue(taskKey).toByteArray()); } diff --git a/src/ui/task/taskmanager.cpp b/src/ui/task/taskmanager.cpp index 14af126c..74860819 100644 --- a/src/ui/task/taskmanager.cpp +++ b/src/ui/task/taskmanager.cpp @@ -42,7 +42,7 @@ void TaskManager::loadSettings(const FortSettings *fortSettings) { const TasksMap tasksMap = fortSettings->tasks(); - foreach (TaskInfo *taskInfo, m_taskInfos) { + for (TaskInfo *taskInfo : m_taskInfos) { const QString taskName = TaskInfo::typeToString(taskInfo->type()); const QByteArray taskData = tasksMap.value(taskName); @@ -59,7 +59,7 @@ bool TaskManager::saveSettings(FortSettings *fortSettings) TasksMap tasksMap; QByteArray taskData; - foreach (const TaskInfo *taskInfo, m_taskInfos) { + for (const TaskInfo *taskInfo : m_taskInfos) { const QString taskName = TaskInfo::typeToString(taskInfo->type()); taskData.clear(); @@ -90,7 +90,7 @@ void TaskManager::runExpiredTasks() const QDateTime now = DateUtil::now(); bool enabledTaskExists = false; - foreach (TaskInfo *taskInfo, m_taskInfos) { + for (TaskInfo *taskInfo : m_taskInfos) { if (!taskInfo->enabled()) continue; diff --git a/src/ui/task/tasktasix.cpp b/src/ui/task/tasktasix.cpp index 541e29fb..66a18b5a 100644 --- a/src/ui/task/tasktasix.cpp +++ b/src/ui/task/tasktasix.cpp @@ -73,7 +73,7 @@ QStringList TaskTasix::parseTasixBuffer(const QByteArray &buffer) // Parse lines const QString text = QString::fromLatin1(buffer); - foreach (const QStringRef &line, text.splitRef( + for (const QStringRef &line : text.splitRef( '\n', QString::SkipEmptyParts)) { if (!line.startsWith('*')) continue; diff --git a/src/ui/translationmanager.cpp b/src/ui/translationmanager.cpp index 1af9fb27..002b8cac 100644 --- a/src/ui/translationmanager.cpp +++ b/src/ui/translationmanager.cpp @@ -39,7 +39,7 @@ void TranslationManager::setupTranslation() m_locales.append(QLocale(QLocale::English, QLocale::UnitedStates)); - foreach (const QFileInfo &fileInfo, QDir(i18nDir()) + for (const QFileInfo &fileInfo : QDir(i18nDir()) .entryInfoList(QStringList() << ("*" TRANSLATION_FILE_SUFFIX))) { const QString localeName = fileInfo.completeBaseName().mid(prefixLen); const QLocale locale(localeName); @@ -57,7 +57,7 @@ QStringList TranslationManager::naturalLabels() const QStringList list; list.reserve(m_locales.size()); - foreach (const QLocale &locale, m_locales) { + for (const QLocale &locale : m_locales) { list.append(StringUtil::capitalize( locale.nativeLanguageName())); } @@ -67,7 +67,7 @@ QStringList TranslationManager::naturalLabels() const int TranslationManager::getLanguageByName(const QString &localeName) const { int index = 0; - foreach (const QLocale &locale, m_locales) { + for (const QLocale &locale : m_locales) { if (localeName == locale.name()) { return index; } diff --git a/src/ui/util/conf/confutil.cpp b/src/ui/util/conf/confutil.cpp index e8c723ac..031448c3 100644 --- a/src/ui/util/conf/confutil.cpp +++ b/src/ui/util/conf/confutil.cpp @@ -246,7 +246,7 @@ bool ConfUtil::parseApps(const QString &text, bool blocked, appgroups_map_t &appGroupIndexes, int groupOffset) { - foreach (const QStringRef &line, + for (const QStringRef &line : text.splitRef(QLatin1Char('\n'))) { const QStringRef lineTrimmed = line.trimmed(); if (lineTrimmed.isEmpty() @@ -373,7 +373,7 @@ void ConfUtil::writeFragmentBits(quint16 *fragmentBits, { *fragmentBits = 0; int i = 0; - foreach (const AppGroup *appGroup, conf.appGroupsList()) { + for (const AppGroup *appGroup : conf.appGroupsList()) { if (appGroup->fragmentPacket()) { *fragmentBits |= (1 << i); } @@ -485,7 +485,7 @@ void ConfUtil::writeStrings(char **data, const QStringList &list) *offp++ = 0; - foreach (const QString &s, list) { + for (const QString &s : list) { const quint32 len = s.toWCharArray((wchar_t *) p) * sizeof(wchar_t); diff --git a/src/ui/util/fileutil.cpp b/src/ui/util/fileutil.cpp index a241cc5f..1a216f3b 100644 --- a/src/ui/util/fileutil.cpp +++ b/src/ui/util/fileutil.cpp @@ -19,7 +19,7 @@ QString FileUtil::kernelNameToDrive(const QString &kernelName) { const QString kernelNameLower = kernelName.toLower(); - foreach (const QFileInfo &fi, QDir::drives()) { + for (const QFileInfo &fi : QDir::drives()) { const QString driveName = fi.path().left(2); const QString driveKernelName = driveToKernelName(driveName); diff --git a/src/ui/util/logger.cpp b/src/ui/util/logger.cpp index 5d29cbdf..bfd8af46 100644 --- a/src/ui/util/logger.cpp +++ b/src/ui/util/logger.cpp @@ -147,7 +147,7 @@ void Logger::checkLogFiles() int count = LOGGER_KEEP_FILES; // Remove old files - foreach (const QString &fileName, m_dir.entryList( + for (const QString &fileName : m_dir.entryList( QStringList() << (QLatin1String(LOGGER_FILE_PREFIX) + '*' + QLatin1String(LOGGER_FILE_SUFFIX)), QDir::Files, QDir::Time)) { diff --git a/src/ui/util/nativeeventfilter.cpp b/src/ui/util/nativeeventfilter.cpp index daf2cea5..b5a7548a 100644 --- a/src/ui/util/nativeeventfilter.cpp +++ b/src/ui/util/nativeeventfilter.cpp @@ -56,7 +56,7 @@ void NativeEventFilter::unregisterHotKey(int hotKeyId) void NativeEventFilter::unregisterHotKeys() { - foreach (int hotKeyId, m_keyIdMap) { + for (const int hotKeyId : m_keyIdMap) { UnregisterHotKey(nullptr, hotKeyId); } diff --git a/src/ui/util/net/ip4range.cpp b/src/ui/util/net/ip4range.cpp index f9a455a1..35b0fd7c 100644 --- a/src/ui/util/net/ip4range.cpp +++ b/src/ui/util/net/ip4range.cpp @@ -66,7 +66,7 @@ bool Ip4Range::fromText(const QString &text) ip4range_map_t ipRangeMap; int lineNo = 0; - foreach (const QStringRef &line, + for (const QStringRef &line : text.splitRef(QLatin1Char('\n'))) { ++lineNo;