diff libgui/src/files-dock-widget.cc @ 31803:e25bf4beb488

Replace various iterators with range-based loops (bug #63738) Replace various iterator-based loops with range-based loops where possible, for brevity. * libgui/src/documentation-bookmarks.cc: Use range-based loop * libgui/src/documentation.cc: Use range-based loop * libgui/src/files-dock-widget.cc: Use range-based loop * libgui/src/history-dock-widget.cc: Use range-based loop * libinterp/corefcn/gl-render.cc: Use range-based loop * libinterp/corefcn/gl2ps-print.cc: Use range-based loop * libinterp/corefcn/graphics.cc: Use range-based loop * libinterp/corefcn/sysdep.cc: Use range-based loop * libinterp/dldfcn/__init_fltk__.cc: Use range-based loop * libinterp/octave-value/cdef-class.cc: Use range-based loop * libinterp/octave-value/cdef-package.cc: Use range-based loop * libgui/src/find-files-model.cc: Add FIXME to note sorted insertion. * src/octave-svgconvert.cc: Use range-based loop, add FIXME to note duplicate code, eliminate loop with call to 2-argument constructor.
author Arun Giridhar <arungiridhar@gmail.com>
date Thu, 02 Feb 2023 11:41:24 -0500
parents 21f9b34eb893
children 90621682cc03
line wrap: on
line diff
--- a/libgui/src/files-dock-widget.cc	Wed Feb 01 16:10:44 2023 -0500
+++ b/libgui/src/files-dock-widget.cc	Thu Feb 02 11:41:24 2023 -0500
@@ -726,9 +726,9 @@
     QItemSelectionModel *m = m_file_tree_view->selectionModel ();
     QModelIndexList rows = m->selectedRows ();
 
-    for (auto it = rows.begin (); it != rows.end (); it++)
+    for (const auto& it : rows)
       {
-        QFileInfo file = m_file_system_model->fileInfo (*it);
+        QFileInfo file = m_file_system_model->fileInfo (it);
         if (file.exists ())
           display_directory (file.absoluteFilePath ());
       }
@@ -740,9 +740,9 @@
     QItemSelectionModel *m = m_file_tree_view->selectionModel ();
     QModelIndexList rows = m->selectedRows ();
 
-    for (auto it = rows.begin (); it != rows.end (); it++)
+    for (const auto& it : rows)
       {
-        QFileInfo file = m_file_system_model->fileInfo (*it);
+        QFileInfo file = m_file_system_model->fileInfo (it);
         if (file.exists ())
           emit open_file (file.absoluteFilePath ());
       }
@@ -753,8 +753,8 @@
     QItemSelectionModel *m = m_file_tree_view->selectionModel ();
     QModelIndexList rows = m->selectedRows ();
 
-    for (auto it = rows.begin (); it != rows.end (); it++)
-      open_item_in_app (*it);
+    for (const auto& it : rows)
+      open_item_in_app (it);
   }
 
   void files_dock_widget::contextmenu_copy_selection (bool)
@@ -764,10 +764,9 @@
 
     QStringList selection;
 
-    for (auto it = rows.begin (); it != rows.end (); it++)
+    for (const auto& it : rows)
       {
-        QFileInfo info = m_file_system_model->fileInfo (*it);
-
+        QFileInfo info = m_file_system_model->fileInfo (it);
         selection << info.fileName ();
       }
 
@@ -899,11 +898,9 @@
 
     QList<QFileInfo> infos;
 
-    for (auto it = rows.begin (); it != rows.end (); it++)
+    for (const auto& idx : rows)
       {
-        QModelIndex index = *it;
-
-        QFileInfo info = m_file_system_model->fileInfo (index);
+        QFileInfo info = m_file_system_model->fileInfo (idx);
 
         if (info.exists () &&
             ((dir & info.isDir ()) || (! dir && info.isFile ())))