changeset 31599:50a225732661 stable

use initializer lists instead of insertion operators * gui-preferences-cs.h, gui-preferences-ed.h, gui-preferences-global.h, gui-preferences-ve.h, gui-preferences-ws.h, main-window.cc: Where possible, use initializer lists ({ a, b, ... }) instead of insertion operators (QStringList () << a << b << ...).
author John W. Eaton <jwe@octave.org>
date Thu, 01 Dec 2022 12:50:48 -0500
parents e03694e047fa
children cd47350ec1af 132547cc1ab2
files libgui/src/gui-preferences-cs.h libgui/src/gui-preferences-ed.h libgui/src/gui-preferences-global.h libgui/src/gui-preferences-ve.h libgui/src/gui-preferences-ws.h libgui/src/main-window.cc
diffstat 6 files changed, 112 insertions(+), 94 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/gui-preferences-cs.h	Wed Nov 30 08:02:24 2022 -0500
+++ b/libgui/src/gui-preferences-cs.h	Thu Dec 01 12:50:48 2022 -0500
@@ -72,11 +72,12 @@
   {"terminal/color_c" + settings_color_modes_ext[1], QVariant ()}  // default colors in light mode
 };
 const QStringList
-cs_color_names (QStringList ()
-                << QT_TRANSLATE_NOOP ("octave::settings_dialog", "foreground")
-                << QT_TRANSLATE_NOOP ("octave::settings_dialog", "background")
-                << QT_TRANSLATE_NOOP ("octave::settings_dialog", "selection")
-                << QT_TRANSLATE_NOOP ("octave::settings_dialog", "cursor"));
+cs_color_names = {
+  QT_TRANSLATE_NOOP ("octave::settings_dialog", "foreground"),
+  QT_TRANSLATE_NOOP ("octave::settings_dialog", "background"),
+  QT_TRANSLATE_NOOP ("octave::settings_dialog", "selection"),
+  QT_TRANSLATE_NOOP ("octave::settings_dialog", "cursor")
+};
 
 const gui_pref
 cs_focus_cmd ("terminal/focus_after_command", QVariant (false));
--- a/libgui/src/gui-preferences-ed.h	Wed Nov 30 08:02:24 2022 -0500
+++ b/libgui/src/gui-preferences-ed.h	Thu Dec 01 12:50:48 2022 -0500
@@ -180,7 +180,13 @@
 ed_last_comment_str ("editor/oct_last_comment_str");
 
 const QStringList
-ed_comment_strings (QStringList () << "##" << "#" << "%"<< "%%" << "%!");
+ed_comment_strings = {
+  "##",
+  "#",
+  "%",
+  "%%",
+  "%!"
+};
 
 const int ed_comment_strings_count = 5;
 
@@ -206,11 +212,12 @@
 
 // Tabs
 const QStringList
-ed_tab_position_names (QStringList ()
-                       << QT_TRANSLATE_NOOP ("octave::settings_dialog", "Top")
-                       << QT_TRANSLATE_NOOP ("octave::settings_dialog", "Bottom")
-                       << QT_TRANSLATE_NOOP ("octave::settings_dialog", "Left")
-                       << QT_TRANSLATE_NOOP ("octave::settings_dialog", "Right"));
+ed_tab_position_names = {
+  QT_TRANSLATE_NOOP ("octave::settings_dialog", "Top"),
+  QT_TRANSLATE_NOOP ("octave::settings_dialog", "Bottom"),
+  QT_TRANSLATE_NOOP ("octave::settings_dialog", "Left"),
+  QT_TRANSLATE_NOOP ("octave::settings_dialog", "Right")
+};
 
 const gui_pref
 ed_tab_position ("editor/tab_position", QVariant (QTabWidget::North));
--- a/libgui/src/gui-preferences-global.h	Wed Nov 30 08:02:24 2022 -0500
+++ b/libgui/src/gui-preferences-global.h	Thu Dec 01 12:50:48 2022 -0500
@@ -93,26 +93,29 @@
 }  ;
 
 const QStringList
-global_icon_paths (QStringList ()
-                        << ""
-                        << ":/icons/octave/128x128/"
-                        << ":/icons/tango/128x128/"
-                        << ":/icons/cursors/"
-                       );
+global_icon_paths = {
+  "",
+  ":/icons/octave/128x128/",
+  ":/icons/tango/128x128/",
+  ":/icons/cursors/"
+};
 
 const gui_pref
 global_icon_theme_index ("icon_theme", QVariant (ICON_THEME_SYSTEM));
 const QStringList
-global_all_icon_themes (QStringList ()
-                        << ""
-                        << "octave"
-                        << "tango"
-                        << "cursors");
+global_all_icon_themes = {
+  "",
+  "octave",
+  "tango",
+  "cursors"
+};
+
 const QStringList
-global_all_icon_theme_names (QStringList ()
-                        << "System"
-                        << "Octave"
-                        << "Tango");
+global_all_icon_theme_names = {
+  "System",
+  "Octave",
+  "Tango"
+};
 
 const gui_pref
 global_status_bar ("show_status_bar", QVariant (true));
@@ -123,8 +126,9 @@
   EXTRA_STYLE_FUSION_DARK = 0
 }  ;
 const QStringList
-global_extra_styles (QStringList ()
-                        << "Fusion-Dark");
+global_extra_styles = {
+  "Fusion-Dark"
+};
 
 #if defined (Q_OS_MAC)
 // prevent native file dialogs on MAC by setting the default "false" and
@@ -180,12 +184,12 @@
 global_proxy_pass ("proxyPassword", QVariant (QString ()));
 
 const QStringList
-global_proxy_all_types (QStringList ()
-                        << "HttpProxy"
-                        << "Socks5Proxy"
-                        << QT_TRANSLATE_NOOP ("octave::settings_dialog", "Environment Variables")
-                       );
-const QList<int>
-global_proxy_manual_types (QList<int> () << 0 << 1);
+global_proxy_all_types = {
+  "HttpProxy",
+  "Socks5Proxy",
+  QT_TRANSLATE_NOOP ("octave::settings_dialog", "Environment Variables")
+};
+
+const QList<int> global_proxy_manual_types = { 0, 1 };
 
 #endif
--- a/libgui/src/gui-preferences-ve.h	Wed Nov 30 08:02:24 2022 -0500
+++ b/libgui/src/gui-preferences-ve.h	Thu Dec 01 12:50:48 2022 -0500
@@ -70,44 +70,46 @@
   {"variable_editor/color_a" + settings_color_modes_ext[1], QVariant ()}
 };
 
-const QStringList ve_color_names (QStringList ()
-    << QT_TRANSLATE_NOOP ("octave::settings_dialog", "Foreground")
-    << QT_TRANSLATE_NOOP ("octave::settings_dialog", "Background")
-    << QT_TRANSLATE_NOOP ("octave::settings_dialog", "Selected Foreground")
-    << QT_TRANSLATE_NOOP ("octave::settings_dialog", "Selected Background")
-    << QT_TRANSLATE_NOOP ("octave::settings_dialog", "Alternate Background"));
+const QStringList ve_color_names = {
+  QT_TRANSLATE_NOOP ("octave::settings_dialog", "Foreground"),
+  QT_TRANSLATE_NOOP ("octave::settings_dialog", "Background"),
+  QT_TRANSLATE_NOOP ("octave::settings_dialog", "Selected Foreground"),
+  QT_TRANSLATE_NOOP ("octave::settings_dialog", "Selected Background"),
+  QT_TRANSLATE_NOOP ("octave::settings_dialog", "Alternate Background")
+};
 
-const QStringList ve_save_formats (QStringList ()
-                << "ascii"
-                << "binary"
-                << "float-binary"
-                << "hdf5"
-                << "float-hdf5"
-                << "text"
-                << "mat7-binary"
-                << "mat-binary"
-                << "mat4-binary"
-                << "zip");
+const QStringList ve_save_formats = {
+  "ascii",
+  "binary",
+  "float-binary",
+  "hdf5",
+  "float-hdf5",
+  "text",
+  "mat7-binary",
+  "mat-binary",
+  "mat4-binary",
+  "zip"
+};
 
 // The following list is a relation between save format and fiel extension.
 // The format string are case insensitive.
-const QStringList ve_save_formats_ext (QStringList ()
-                << "-ascii"         << "dat"
-                << "-hdf5"          << "h5"
-                << "-text"          << "txt"
-                << "-v7.3"          << "mat"
-                << "-7.3"           << "mat"
-                << "-v7"            << "mat"
-                << "-7"             << "mat"
-                << "-mat7-binary"   << "mat"
-                << "-v6"            << "mat"
-                << "-6"             << "mat"
-                << "-mat-binary"    << "mat"
-                << "-v4"            << "mat"
-                << "-4"             << "mat"
-                << "-mat4-binary"   << "mat"
-                << "-binary"        << "bin"    // after other fmt incl. "-binary"
-                << "-z"             << "txt.gz" // gzipped -text
-              );
+const QStringList ve_save_formats_ext = {
+  "-ascii",       "dat",
+  "-hdf5",        "h5",
+  "-text",        "txt",
+  "-v7.3",        "mat",
+  "-7.3",         "mat",
+  "-v7",          "mat",
+  "-7",           "mat",
+  "-mat7-binary", "mat",
+  "-v6",          "mat",
+  "-6",           "mat",
+  "-mat-binary",  "mat",
+  "-v4",          "mat",
+  "-4",           "mat",
+  "-mat4-binary", "mat",
+  "-binary",      "bin",   // after other fmt incl. "-binary"
+  "-z",           "txt.gz" // gzipped -text
+};
 
 #endif
--- a/libgui/src/gui-preferences-ws.h	Wed Nov 30 08:02:24 2022 -0500
+++ b/libgui/src/gui-preferences-ws.h	Thu Dec 01 12:50:48 2022 -0500
@@ -55,17 +55,19 @@
 const gui_pref
 ws_mru_list ("workspaceview/mru_list", QVariant ());
 
-const QStringList ws_columns_shown (QStringList ()
-    << QT_TRANSLATE_NOOP ("octave::workspace_view", "Class")
-    << QT_TRANSLATE_NOOP ("octave::workspace_view", "Dimension")
-    << QT_TRANSLATE_NOOP ("octave::workspace_view", "Value")
-    << QT_TRANSLATE_NOOP ("octave::workspace_view", "Attribute"));
+const QStringList ws_columns_shown = {
+  QT_TRANSLATE_NOOP ("octave::workspace_view", "Class"),
+  QT_TRANSLATE_NOOP ("octave::workspace_view", "Dimension"),
+  QT_TRANSLATE_NOOP ("octave::workspace_view", "Value"),
+  QT_TRANSLATE_NOOP ("octave::workspace_view", "Attribute")
+};
 
-const QStringList ws_columns_shown_keys (QStringList ()
-    << "workspaceview/show_class"
-    << "workspaceview/show_dimension"
-    << "workspaceview/show_value"
-    << "workspaceview/show_attribute");
+const QStringList ws_columns_shown_keys = {
+  "workspaceview/show_class",
+  "workspaceview/show_dimension",
+  "workspaceview/show_value",
+  "workspaceview/show_attribute"
+};
 
 const gui_pref
 ws_max_filter_history ("workspaceview/max_filter_history", QVariant (10));
@@ -87,9 +89,10 @@
 const QString ws_class_chars ("agp");
 
 const QStringList
-ws_color_names (QStringList ()
-             << QT_TRANSLATE_NOOP ("octave::settings_dialog", "argument")
-             << QT_TRANSLATE_NOOP ("octave::settings_dialog", "global")
-             << QT_TRANSLATE_NOOP ("octave::settings_dialog", "persistent"));
+ws_color_names = {
+  QT_TRANSLATE_NOOP ("octave::settings_dialog", "argument"),
+  QT_TRANSLATE_NOOP ("octave::settings_dialog", "global"),
+  QT_TRANSLATE_NOOP ("octave::settings_dialog", "persistent")
+};
 
 #endif
--- a/libgui/src/main-window.cc	Wed Nov 30 08:02:24 2022 -0500
+++ b/libgui/src/main-window.cc	Thu Dec 01 12:50:48 2022 -0500
@@ -2170,7 +2170,7 @@
     base_name.replace ("___octave_amp_replacement___", "&&");
 
     // remember names with and without shortcut
-    m_hash_menu_text[menu] = QStringList () << name << base_name;
+    m_hash_menu_text[menu] = QStringList ({ name, base_name });
 
     return menu;
   }
@@ -2196,15 +2196,16 @@
 #if defined (HAVE_QSCINTILLA)
     // call the editor to add actions which should also be available in the
     // editor's menu and tool bar
-    QList<QAction *> shared_actions;
-    shared_actions << m_new_script_action
-                   << m_new_function_action
-                   << m_open_action
-                   << m_find_files_action
-                   << m_undo_action
-                   << m_copy_action
-                   << m_paste_action
-                   << m_select_all_action;
+    QList<QAction *> shared_actions = {
+      m_new_script_action,
+      m_new_function_action,
+      m_open_action,
+      m_find_files_action,
+      m_undo_action,
+      m_copy_action,
+      m_paste_action,
+      m_select_all_action
+    };
     m_editor_window->insert_global_actions (shared_actions);
 #endif
   }