# HG changeset patch # User Markus Mützel # Date 1681293745 -7200 # Node ID 2f451ad8b410afa5bc4b0fb75eb26cb5b0e20b87 # Parent 49d21a7b25a83611f73a1ce0c2d0c727463e1444 Replace deprecated QRegExp by QRegularExpression in libgui/src. * libgui/src/dialog.cc (QUIWidgetCreator::rm_amp), libgui/src/documentation.cc (documentation::global_search, documentation::title_and_anchor), libgui/src/external-editor-interface.cc (external_editor_interface::call_custom_editor), libgui/src/qt-interpreter-events.cc (make_filter_list, qt_interpreter_events::gui_preference_adjust), libgui/src/variable-editor.cc (variable_editor_stack::levelUp): Replace deprecated QRegExp by QRegularExpression. diff -r 49d21a7b25a8 -r 2f451ad8b410 libgui/src/dialog.cc --- a/libgui/src/dialog.cc Wed Apr 12 11:21:28 2023 +0200 +++ b/libgui/src/dialog.cc Wed Apr 12 12:02:25 2023 +0200 @@ -39,6 +39,7 @@ #include #include #include +#include #include #include "dialog.h" @@ -67,7 +68,7 @@ QString QUIWidgetCreator::rm_amp (const QString& text) { QString text_wo_amp = text; - text_wo_amp.replace (QRegExp ("&(\\w)"), "\\1"); + text_wo_amp.replace (QRegularExpression {"&(\\w)"}, "\\1"); return text_wo_amp; } diff -r 49d21a7b25a8 -r 2f451ad8b410 libgui/src/documentation.cc --- a/libgui/src/documentation.cc Wed Apr 12 11:21:28 2023 +0200 +++ b/libgui/src/documentation.cc Wed Apr 12 12:02:25 2023 +0200 @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -461,9 +462,10 @@ return; // Get quoted search strings first, then take first string as fall back - QRegExp rx ("\"([^\"]*)\""); - if (rx.indexIn (query_string, 0) != -1) - m_internal_search = rx.cap (1); + QRegularExpression rx {"\"([^\"]*)\""}; + QRegularExpressionMatch match = rx.match (query_string); + if (match.hasMatch ()) + m_internal_search = match.captured (1); else #if defined (HAVE_QT_SPLITBEHAVIOR_ENUM) m_internal_search = query_string.split (" ", Qt::SkipEmptyParts).first (); @@ -954,7 +956,7 @@ QString retval = title; QString u = url.toString (); - retval.remove (QRegExp ("\\s*\\(*GNU Octave \\(version [^\\)]*\\)[: \\)]*")); + retval.remove (QRegularExpression {"\\s*\\(*GNU Octave \\(version [^\\)]*\\)[: \\)]*"}); // Since the title only contains the section name and not the // specific anchor, extract the latter from the url and append @@ -964,19 +966,22 @@ // Get the anchor from the url QString anchor = u.split ('#').last (); // Remove internal string parts - anchor.remove (QRegExp ("^index-")); - anchor.remove (QRegExp ("^SEC_")); - anchor.remove (QRegExp ("^XREF")); + anchor.remove (QRegularExpression {"^index-"}); + anchor.remove (QRegularExpression {"^SEC_"}); + anchor.remove (QRegularExpression {"^XREF"}); anchor.remove ("Concept-Index_cp_letter-"); anchor.replace ("-", " "); // replace encoded special chars by their unencoded versions - QRegExp rx = QRegExp ("_00([0-7][0-9a-f])"); + QRegularExpression rx {"_00([0-7][0-9a-f])"}; + QRegularExpressionMatch match = rx.match (anchor, 0); int pos = 0; - while ((pos = rx.indexIn(anchor, pos)) != -1) + while (match.hasMatch ()) { - anchor.replace ("_00"+rx.cap (1), QChar (rx.cap (1).toInt (nullptr, 16))); - pos += rx.matchedLength(); + anchor.replace ("_00" + match.captured (1), + QChar (match.captured (1).toInt (nullptr, 16))); + pos += match.capturedLength (); + match = rx.match (anchor, pos); } if (retval != anchor) diff -r 49d21a7b25a8 -r 2f451ad8b410 libgui/src/external-editor-interface.cc --- a/libgui/src/external-editor-interface.cc Wed Apr 12 11:21:28 2023 +0200 +++ b/libgui/src/external-editor-interface.cc Wed Apr 12 12:02:25 2023 +0200 @@ -29,6 +29,7 @@ #include #include +#include #include "external-editor-interface.h" #include "gui-settings.h" @@ -55,7 +56,7 @@ editor.replace ("%f", file); editor.replace ("%l", QString::number (line)); - QStringList arguments = editor.split (QRegExp("\\s+")); + QStringList arguments = editor.split (QRegularExpression {"\\s+"}); editor = arguments.takeFirst (); // start the process and check for success diff -r 49d21a7b25a8 -r 2f451ad8b410 libgui/src/qt-interpreter-events.cc --- a/libgui/src/qt-interpreter-events.cc Wed Apr 12 11:21:28 2023 +0200 +++ b/libgui/src/qt-interpreter-events.cc Wed Apr 12 12:02:25 2023 +0200 @@ -35,6 +35,7 @@ #include #include #include +#include #include #include "dialog.h" @@ -93,7 +94,7 @@ // Strip out extensions from name and replace ';' with spaces in list. - name.replace (QRegExp (R"(\(.*\))"), ""); + name.replace (QRegularExpression {R"(\(.*\))"}, ""); ext.replace (";", " "); if (name.isEmpty ()) @@ -728,19 +729,20 @@ QStringList codecs; settings.get_codecs (&codecs); - QRegExp re ("^CP(\\d+)$"); + QRegularExpression re {"^CP(\\d+)$"}; + QRegularExpressionMatch match = re.match (adjusted_value); if (adjusted_value == "SYSTEM") adjusted_value = QString ("SYSTEM (") + QString (octave_locale_charset_wrapper ()).toUpper () + QString (")"); - else if (re.indexIn (adjusted_value) > -1) + else if (match.hasMatch ()) { - if (codecs.contains ("IBM" + re.cap (1))) - adjusted_value = "IBM" + re.cap (1); - else if (codecs.contains ("WINDOWS-" + re.cap (1))) - adjusted_value = "WINDOWS-" + re.cap (1); + if (codecs.contains ("IBM" + match.captured (1))) + adjusted_value = "IBM" + match.captured (1); + else if (codecs.contains ("WINDOWS-" + match.captured (1))) + adjusted_value = "WINDOWS-" + match.captured (1); else adjusted_value.clear (); } diff -r 49d21a7b25a8 -r 2f451ad8b410 libgui/src/variable-editor.cc --- a/libgui/src/variable-editor.cc Wed Apr 12 11:21:28 2023 +0200 +++ b/libgui/src/variable-editor.cc Wed Apr 12 12:02:25 2023 +0200 @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -434,7 +435,7 @@ if (name.endsWith (')') || name.endsWith ('}')) { - name.remove ( QRegExp ("[({][^({]*[)}]$)") ); + name.remove (QRegularExpression {"[({][^({]*[)}]$)"}); emit edit_variable_signal (name, octave_value ()); } }