Mercurial > octave
changeset 27676:ea7d36e9f197
use standard C++ range-based for loops instead of Qt foreach macro
* documentation.cc, file-editor.cc, octave-qscintilla.cc,
main-window.cc, resource-manager.cc, variable-editor.cc: Replace uses
of Qt foreach macros with standard C++ range-based for loops.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 12 Nov 2019 13:51:22 -0500 |
parents | fb2724126950 |
children | 92fea2cd024f |
files | libgui/src/documentation.cc libgui/src/m-editor/file-editor.cc libgui/src/m-editor/octave-qscintilla.cc libgui/src/main-window.cc libgui/src/resource-manager.cc libgui/src/variable-editor.cc |
diffstat | 6 files changed, 16 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/documentation.cc Tue Nov 12 13:35:44 2019 -0500 +++ b/libgui/src/documentation.cc Tue Nov 12 13:51:22 2019 -0500 @@ -285,7 +285,7 @@ dir.setFilter (QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden); QStringList namefilter; namefilter.append ("*" + bname + "*"); - foreach (QFileInfo fi, dir.entryInfoList (namefilter)) + for (const auto& fi : dir.entryInfoList (namefilter)) { std::string file_name = fi.absoluteFilePath ().toStdString (); sys::recursive_rmdir (file_name);
--- a/libgui/src/m-editor/file-editor.cc Tue Nov 12 13:35:44 2019 -0500 +++ b/libgui/src/m-editor/file-editor.cc Tue Nov 12 13:51:22 2019 -0500 @@ -1631,9 +1631,8 @@ { // remove all standard actions from scintilla QList<QAction *> all_actions = menu->actions (); - QAction *a; - - foreach (a, all_actions) + + for (auto *a : all_actions) menu->removeAction (a); // add editor's actions with icons and customized shortcuts @@ -1701,7 +1700,7 @@ { if (e->mimeData ()->hasUrls ()) { - foreach (QUrl url, e->mimeData ()->urls ()) + for (const auto& url : e->mimeData ()->urls ()) request_open_file (url.toLocalFile ()); } }
--- a/libgui/src/m-editor/octave-qscintilla.cc Tue Nov 12 13:35:44 2019 -0500 +++ b/libgui/src/m-editor/octave-qscintilla.cc Tue Nov 12 13:51:22 2019 -0500 @@ -303,14 +303,14 @@ { // remove all standard actions from scintilla QList<QAction *> all_actions = context_menu->actions (); - QAction *a; - foreach (a, all_actions) + for (auto *a : all_actions) context_menu->removeAction (a); - a = context_menu->addAction (tr ("dbstop if ..."), this, + QAction *act + = context_menu->addAction (tr ("dbstop if ..."), this, SLOT (contextmenu_break_condition (bool))); - a->setData (local_pos); + act->setData (local_pos); } #endif
--- a/libgui/src/main-window.cc Tue Nov 12 13:35:44 2019 -0500 +++ b/libgui/src/main-window.cc Tue Nov 12 13:51:22 2019 -0500 @@ -322,7 +322,7 @@ { // Go through all dock widgets and check whether the current widget // widget with focus is a child of one of it - foreach (octave_dock_widget *w, w_list) + for (auto w : w_list) { if (w->isAncestorOf (w_new)) dock = w; @@ -867,7 +867,7 @@ } QString icon; - foreach (octave_dock_widget *widget, dock_widget_list ()) + for (auto *widget : dock_widget_list ()) { QString name = widget->objectName (); if (! name.isEmpty ()) @@ -1478,7 +1478,7 @@ } // Restore the geometry of all dock-widgets - foreach (octave_dock_widget *widget, dock_widget_list ()) + for (auto *widget : dock_widget_list ()) { QString name = widget->objectName (); @@ -1564,7 +1564,7 @@ // This has to be done after the window is shown (see octave-gui.cc) void main_window::connect_visibility_changed (void) { - foreach (octave_dock_widget *widget, dock_widget_list ()) + for (auto *widget : dock_widget_list ()) widget->connect_visibility_changed (); #if defined (HAVE_QSCINTILLA)
--- a/libgui/src/resource-manager.cc Tue Nov 12 13:35:44 2019 -0500 +++ b/libgui/src/resource-manager.cc Tue Nov 12 13:51:22 2019 -0500 @@ -382,7 +382,7 @@ { // get the codec name for each mib QList<int> all_mibs = QTextCodec::availableMibs (); - foreach (int mib, all_mibs) + for (auto mib : all_mibs) { QTextCodec *c = QTextCodec::codecForMib (mib); codecs->append (c->name ().toUpper ()); @@ -433,7 +433,7 @@ } // fill the combo box - foreach (QString c, all_codecs) + for (const auto& c : all_codecs) combo->addItem (c); // prepend the default item
--- a/libgui/src/variable-editor.cc Tue Nov 12 13:35:44 2019 -0500 +++ b/libgui/src/variable-editor.cc Tue Nov 12 13:51:22 2019 -0500 @@ -848,7 +848,7 @@ QModelIndex previous = indices.first (); QString copy = mod->data (previous).toString (); indices.removeFirst (); - foreach (QModelIndex idx, indices) + for (auto idx : indices) { copy.push_back (previous.row () != idx.row () ? '\n' : '\t'); copy.append (mod->data (idx).toString ()); @@ -1324,7 +1324,7 @@ QList<QTabBar *> barlist = main_win ()->findChildren<QTabBar *> (); QVariant this_value (reinterpret_cast<quintptr> (this)); - foreach (QTabBar *tbar, barlist) + for (auto *tbar : barlist) for (int i = 0; i < tbar->count (); i++) if (tbar->tabData (i) == this_value) {