From 7a6f2581e8df9c65bcca278bb8432749af22c301 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 25 Oct 2021 16:38:31 -0700 Subject: [PATCH] cleanup: replace QRegExp with QRegularExpression Qt 6 will drop support for QRegExp. Use QRegularExpression instead. The syntax for matches and captures has changed and needed to be adjusted. Signed-off-by: Dirk Hohndel --- desktop-widgets/divelogimportdialog.cpp | 27 ++++++++++++++++--------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/desktop-widgets/divelogimportdialog.cpp b/desktop-widgets/divelogimportdialog.cpp index cd1df5bc7..bb6c7650c 100644 --- a/desktop-widgets/divelogimportdialog.cpp +++ b/desktop-widgets/divelogimportdialog.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include "core/filterpreset.h" @@ -121,7 +121,7 @@ int ColumnNameProvider::rowCount(const QModelIndex&) const int ColumnNameProvider::mymatch(QString value) const { QString searchString = value.toLower(); - QRegExp re(" \\(.*\\)"); + QRegularExpression re(" \\(.*\\)"); searchString.replace("\"", "").replace(re, "").replace(" ", "").replace(".", "").replace("\n",""); for (int i = 0; i < columnNames.count(); i++) { @@ -894,12 +894,15 @@ void DiveLogImportDialog::on_buttonBox_accepted() } else { xml_params params; - QRegExp apdRe("^.*[/\\][0-9a-zA-Z]*_([0-9]{6})_([0-9]{6})\\.apd"); if (txtLog) { parseTxtHeader(fileNames[i], params); - } else if (apdRe.exactMatch(fileNames[i])) { - xml_params_add(¶ms, "date", qPrintable("20" + apdRe.cap(1))); - xml_params_add(¶ms, "time", qPrintable("1" + apdRe.cap(2))); + } else { + QRegularExpression apdRe("^.*[/\\][0-9a-zA-Z]*_([0-9]{6})_([0-9]{6})\\.apd\\z"); + QRegularExpressionMatch match = apdRe.match(fileNames[i]); + if (match.hasMatch()) { + xml_params_add(¶ms, "date", qPrintable("20" + match.captured(1))); + xml_params_add(¶ms, "time", qPrintable("1" + match.captured(2))); + } } setup_csv_params(r, params); parse_csv_file(qPrintable(fileNames[i]), ¶ms, @@ -944,12 +947,16 @@ void DiveLogImportDialog::on_buttonBox_accepted() } else { xml_params params; - QRegExp apdRe("^.*[/\\][0-9a-zA-Z]*_([0-9]{6})_([0-9]{6})\\.apd"); if (txtLog) { parseTxtHeader(fileNames[i], params); - } else if (apdRe.exactMatch(fileNames[i])) { - xml_params_add(¶ms, "date", qPrintable("20" + apdRe.cap(1))); - xml_params_add(¶ms, "time", qPrintable("1" + apdRe.cap(2))); + } else { + QRegularExpression apdRe("\\A^.*[/\\][0-9a-zA-Z]*_([0-9]{6})_([0-9]{6})\\.apd\\z"); + QRegularExpressionMatch match = apdRe.match(fileNames[i]); + if (match.hasMatch()) { + xml_params_add(¶ms, "date", qPrintable("20" + match.captured(1))); + xml_params_add(¶ms, "time", qPrintable("1" + match.captured(2))); + } + } setup_csv_params(r, params); parse_csv_file(qPrintable(fileNames[i]), ¶ms,