From 9b5314bd8750f299c89ea1ae9f35d6665b78ee64 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 15 Aug 2023 12:57:12 +0200 Subject: [PATCH] Start: modernize C++: use range-based for loop --- src/Mod/Start/Gui/DlgStartPreferencesImp.cpp | 18 ++++++++++-------- src/Mod/Start/Gui/Workbench.cpp | 9 +++++---- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/Mod/Start/Gui/DlgStartPreferencesImp.cpp b/src/Mod/Start/Gui/DlgStartPreferencesImp.cpp index 013fe78e3a..6e98ed2845 100644 --- a/src/Mod/Start/Gui/DlgStartPreferencesImp.cpp +++ b/src/Mod/Start/Gui/DlgStartPreferencesImp.cpp @@ -50,19 +50,21 @@ DlgStartPreferencesImp::DlgStartPreferencesImp( QWidget* parent ) // sorted by their menu text QStringList work = Gui::Application::Instance->workbenches(); QMap menuText; - for (QStringList::Iterator it = work.begin(); it != work.end(); ++it) { - QString text = Gui::Application::Instance->workbenchMenuText(*it); - menuText[text] = *it; + for (const auto& it : work) { + QString text = Gui::Application::Instance->workbenchMenuText(it); + menuText[text] = it; } { // add special workbench to selection QPixmap px = Gui::Application::Instance->workbenchIcon(QString::fromLatin1("NoneWorkbench")); QString key = QString::fromLatin1(""); QString value = QString::fromLatin1("$LastModule"); - if (px.isNull()) + if (px.isNull()) { ui->AutoloadModuleCombo->addItem(key, QVariant(value)); - else + } + else { ui->AutoloadModuleCombo->addItem(px, key, QVariant(value)); + } } for (QMap::Iterator it = menuText.begin(); it != menuText.end(); ++it) { @@ -150,13 +152,13 @@ void DlgStartPreferencesImp::loadSettings() /** * Sets the strings of the subwidgets using the current language. */ -void DlgStartPreferencesImp::changeEvent(QEvent *e) +void DlgStartPreferencesImp::changeEvent(QEvent *ev) { - if (e->type() == QEvent::LanguageChange) { + if (ev->type() == QEvent::LanguageChange) { ui->retranslateUi(this); } else { - QWidget::changeEvent(e); + Gui::Dialog::PreferencePage::changeEvent(ev); } } diff --git a/src/Mod/Start/Gui/Workbench.cpp b/src/Mod/Start/Gui/Workbench.cpp index e21dedf762..34756a75b3 100644 --- a/src/Mod/Start/Gui/Workbench.cpp +++ b/src/Mod/Start/Gui/Workbench.cpp @@ -65,11 +65,12 @@ void StartGui::Workbench::loadStartPage() // Ensure that we don't open the Start page multiple times QString title = QCoreApplication::translate("Workbench", "Start page"); QList ch = Gui::getMainWindow()->windows(); - for (QList::const_iterator c = ch.cbegin(); c != ch.cend(); ++c) { - if ((*c)->windowTitle() == title) { - Gui::MDIView* mdi = qobject_cast((*c)); - if (mdi) + for (auto c : ch) { + if (c->windowTitle() == title) { + Gui::MDIView* mdi = qobject_cast(c); + if (mdi) { Gui::getMainWindow()->setActiveWindow(mdi); + } return; } }