changeset 31802:142dc0aaa98c

dialog.cc: Minor refactoring, remove FIXME. libgui/src/dialog.cc: Remove FIXME about a #define, eliminate a decision inside a for-loop, merge two iterator variables `i` and `it` into one.
author Arun Giridhar <arungiridhar@gmail.com>
date Wed, 01 Feb 2023 16:10:44 -0500
parents 238add261dd5
children e25bf4beb488
files libgui/src/dialog.cc
diffstat 1 files changed, 7 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/dialog.cc	Wed Feb 01 16:44:58 2023 +0100
+++ b/libgui/src/dialog.cc	Wed Feb 01 16:10:44 2023 -0500
@@ -405,10 +405,9 @@
       view->setSelectionMode (QAbstractItemView::NoSelection);
 
     selector = view->selectionModel ();
-    int i = 0;
-    for (auto it = initial.begin (); it != initial.end (); it++)
+    for (int i = 0; i < initial.count(); i++)
       {
-        QModelIndex idx = m_model->index (initial.value (i++) - 1, 0,
+        QModelIndex idx = m_model->index (initial.value (i) - 1, 0,
                                           QModelIndex ());
         selector->select (idx, QItemSelectionModel::Select);
       }
@@ -425,26 +424,17 @@
     QVBoxLayout *listLayout = new QVBoxLayout;
     if (! prompt.isEmpty ())
       {
-        // For now, assume html-like Rich Text.  May be incompatible
-        // with something down the road, but just testing capability.
+        // Note: Assume html-like Rich Text.
+        // Check for future incompatibilities if any.
         QString prompt_string;
-        for (int j = 0; j < prompt.length (); j++)
+        prompt_string.append (prompt.at (0));
+        for (int j = 1; j < prompt.length (); j++)
           {
-            if (j > 0)
-              // FIXME: Why define and then immediately test value?
-#define RICH_TEXT 1
-#if RICH_TEXT
-              prompt_string.append ("<br>");
-#else
-              prompt_string.append ("\n");
-#endif
+            prompt_string.append ("<br>");
             prompt_string.append (prompt.at (j));
           }
         QLabel *plabel = new QLabel (prompt_string);
-#if RICH_TEXT
         plabel->setTextFormat (Qt::RichText);
-#endif
-#undef RICH_TEXT
         listLayout->addWidget (plabel);
       }
     listLayout->addWidget (view);