diff --git a/src/languagehelper.cpp b/src/languagehelper.cpp index 734e0c5..87e02f9 100644 --- a/src/languagehelper.cpp +++ b/src/languagehelper.cpp @@ -11,7 +11,7 @@ LanguageHelper::LanguageHelper () { QStringList LanguageHelper::availableOcrLanguagesUi () const { QStringList uiItems; - foreach (const QString &item, availableOcrLanguages_) { + for (const QString &item: availableOcrLanguages_) { uiItems << ocrCodeToUi (item); } uiItems.sort (); @@ -29,7 +29,7 @@ QStringList LanguageHelper::availableOcrLanguages (const QString &path) const { } QStringList items; QStringList files = dir.entryList ({"*.traineddata"}, QDir::Files); - foreach (const QString &file, files) { + for (const QString &file: files) { QString lang = file.left (file.indexOf (".")); items << lang; } @@ -39,7 +39,7 @@ QStringList LanguageHelper::availableOcrLanguages (const QString &path) const { QStringList LanguageHelper::availableOcrLanguagesUi (const QString &path) const { QStringList uiItems, items; items = availableOcrLanguages (path); - foreach (const QString &item, items) { + for (const QString &item: items) { uiItems << ocrCodeToUi (item); } uiItems.sort (); @@ -113,7 +113,7 @@ void LanguageHelper::updateMenu (QMenu *menu, const QStringList &languages, int } if (languages.size () <= groupSize) { - foreach (const QString &language, languages) { + for (const QString &language: languages) { menu->addAction (language); } } @@ -121,7 +121,7 @@ void LanguageHelper::updateMenu (QMenu *menu, const QStringList &languages, int int subIndex = groupSize; QMenu *subMenu = NULL; QString prevLetter; - foreach (const QString &language, languages) { + for (const QString &language: languages) { QString curLetter = language.left (1); if (++subIndex >= groupSize && prevLetter != curLetter) { if (subMenu != NULL) { diff --git a/src/manager.cpp b/src/manager.cpp index 9dc967d..ba1a099 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -117,7 +117,7 @@ void Manager::updateActionsState (bool isEnabled) { QList actions; actions << captureAction_ << repeatCaptureAction_ << repeatAction_ << clipboardAction_; QList states; - foreach (const QAction * action, actions) { + for (const QAction *action: actions) { states << action->isEnabled (); } #endif @@ -230,13 +230,13 @@ void Manager::checkForUpdates () { } Manager::~Manager () { - foreach (SelectionDialog * selection, selections_.values ()) { + for (SelectionDialog *selection: selections_.values ()) { selection->hide (); delete selection; } trayIcon_->hide (); delete trayIcon_->contextMenu (); - foreach (QThread * thread, threads_) { + for (QThread *thread: threads_) { thread->quit (); thread->wait (1000000); } @@ -244,7 +244,7 @@ Manager::~Manager () { void Manager::capture () { QList screens = QApplication::screens (); - foreach (QScreen * screen, screens) { + for (QScreen *screen: screens) { QRect geometry = screen->availableGeometry (); #if QT_VERSION >= QT_VERSION_CHECK (5,10,0) QPixmap pixmap = screen->grabWindow (0, 0, 0, @@ -309,7 +309,7 @@ void Manager::repeatCapture () { return; } QList screens = QApplication::screens (); - foreach (QScreen * screen, screens) { + for (QScreen *screen: screens) { QString name = screen->name (); if (!selections_.contains (name)) { continue; diff --git a/src/recognizerhelper.cpp b/src/recognizerhelper.cpp index 2ddde69..d34de3d 100644 --- a/src/recognizerhelper.cpp +++ b/src/recognizerhelper.cpp @@ -25,7 +25,7 @@ void RecognizerHelper::load () { QByteArray data = f.readAll (); f.close (); QStringList lines = QString::fromUtf8 (data).split ('\n', QString::SkipEmptyParts); - foreach (const QString &line, lines) { + for (const QString &line: lines) { QStringList parts = line.mid (1, line.size () - 2).split ("\",\""); // remove " if (parts.size () < 3) { continue; @@ -39,7 +39,7 @@ void RecognizerHelper::save () { if (!f.open (QFile::WriteOnly)) { return; } - foreach (const Sub &sub, subs_) { + for (const Sub &sub: subs_) { QStringList parts = QStringList () << sub.language << sub.source << sub.target; QString line = "\"" + parts.join ("\",\"") + "\"\n"; f.write (line.toUtf8 ()); @@ -53,7 +53,7 @@ QString RecognizerHelper::substitute (const QString &source, const QString &lang int bestMatchIndex = -1; int bestMatchLen = 0; int index = -1; - foreach (const Sub &sub, subs_) { + for (const Sub &sub: subs_) { ++index; if (sub.language != language || !result.contains (sub.source)) { continue; diff --git a/src/settingseditor.cpp b/src/settingseditor.cpp index c24fa45..2ebd8f4 100644 --- a/src/settingseditor.cpp +++ b/src/settingseditor.cpp @@ -43,7 +43,7 @@ SettingsEditor::SettingsEditor (const LanguageHelper &dictionary, QWidget *paren proxyTypeNames.insert (QNetworkProxy::Socks5Proxy, tr ("SOCKS 5")); proxyTypeNames.insert (QNetworkProxy::HttpProxy, tr ("HTTP")); QList proxyOrder = proxyTypeOrder (); - foreach (int type, proxyOrder) { + for (int type: proxyOrder) { ui->proxyTypeCombo->addItem (proxyTypeNames.value (QNetworkProxy::ProxyType (type))); } @@ -196,7 +196,7 @@ void SettingsEditor::loadSettings () { RecognizerHelper::Subs subs = recognizerHelper_->subs (); ui->recognizerFixTable->setRowCount (subs.size ()); int row = 0; - foreach (const RecognizerHelper::Sub &sub, subs) { + for (const RecognizerHelper::Sub &sub: subs) { if (!initSubsTableRow (row, sub.language)) { continue; } diff --git a/src/translatorhelper.cpp b/src/translatorhelper.cpp index eb0bb92..95800b7 100644 --- a/src/translatorhelper.cpp +++ b/src/translatorhelper.cpp @@ -42,7 +42,7 @@ QStringList TranslatorHelper::enabledTranslatorScripts () const { QStringList enabled; possibleTranslators (enabled); QStringList scripts; - foreach (const QString &name, enabled) { + for (const QString &name: enabled) { QFile f (translatorsDir_ + QDir::separator () + name); if (f.open (QFile::ReadOnly)) { QString script = QString::fromUtf8 (f.readAll ()); diff --git a/src/updater.cpp b/src/updater.cpp index 31ae2c3..fbe15de 100644 --- a/src/updater.cpp +++ b/src/updater.cpp @@ -94,7 +94,7 @@ void Updater::updateCurrentVersion () { } QJsonObject updated = QJsonDocument::fromJson (f.readAll ()).object (); f.close (); - foreach (const QString &component, updated.keys ()) { + for (const QString &component: updated.keys ()) { QJsonObject current = currentVersion_[component].toObject (); int updatedVersion = updated[component].toInt (); if (current[_built_in].toBool () || current[_version].toInt () >= updatedVersion) { @@ -140,7 +140,7 @@ void Updater::parseAvailableVersion () { QStringList inaccessible, incompatible; QStringList updateList; QDir currentDir; - foreach (const QString &component, availableVersion_.keys ()) { + for (const QString &component: availableVersion_.keys ()) { QJsonObject available = availableVersion_[component].toObject (); QJsonObject current = currentVersion_[component].toObject (); QString path = versionField (available, _path); @@ -190,7 +190,7 @@ void Updater::parseAvailableVersion () { int result = QMessageBox::question (NULL, tr ("Обновление"), message, buttons); if (result == QMessageBox::Yes) { componentsUpdating_ = updateList.size (); - foreach (const QString &component, updateList) { + for (const QString &component: updateList) { getComponent (component); } }