Core: replace QRegExp with QRegularExpression

This commit is contained in:
wmayer
2022-10-06 13:54:20 +02:00
parent 4ca1b838a9
commit 75bfb8f48f
11 changed files with 99 additions and 62 deletions

View File

@@ -25,12 +25,13 @@
#ifndef _PreComp_
# include <boost_signals2.hpp>
# include <QApplication>
# include <QRegExp>
# include <QEvent>
# include <QCloseEvent>
# include <QMdiSubWindow>
# include <QPrinter>
# include <QPrinterInfo>
# include <QRegularExpression>
# include <QRegularExpressionMatch>
#endif
#include <Base/Interpreter.h>
@@ -144,16 +145,17 @@ void MDIView::onRelabel(Gui::Document *pDoc)
// Try to separate document name and view number if there is one
QString cap = windowTitle();
// Either with dirty flag ...
QRegExp rx(QLatin1String("(\\s\\:\\s\\d+\\[\\*\\])$"));
int pos = rx.lastIndexIn(cap);
if (pos == -1) {
QRegularExpression rx(QLatin1String("(\\s\\:\\s\\d+\\[\\*\\])$"));
QRegularExpressionMatch match;
int pos = cap.lastIndexOf(rx, -1, &match);
if (!match.hasMatch()) {
// ... or not
rx.setPattern(QLatin1String("(\\s\\:\\s\\d+)$"));
pos = rx.lastIndexIn(cap);
pos = cap.lastIndexOf(rx, -1, &match);
}
if (pos != -1) {
if (match.hasMatch()) {
cap = QString::fromUtf8(pDoc->getDocument()->Label.getValue());
cap += rx.cap();
cap += match.captured();
setWindowTitle(cap);
}
else {