Remove use of QRegExp

QRegexp has been replaced with QRegularExpression in Qt5. Now that we
have dropped support for Qt4, there is no need for keeping it around.
This commit is contained in:
Jean-Marc Lasgouttes 2023-02-20 17:38:59 +01:00
parent 88c1ed9e32
commit 263da2fa20
14 changed files with 8 additions and 243 deletions

View File

@ -34,9 +34,6 @@
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QTextFrame> #include <QTextFrame>
#if QT_VERSION >= 0x060000
#include <QtCore5Compat/QRegExp>
#endif
using namespace lyx::support; using namespace lyx::support;
@ -273,11 +270,7 @@ QString CCItemDelegate::underlineFilter(QString const & s) const
if (f.isEmpty()) if (f.isEmpty())
return s; return s;
QString r(s); QString r(s);
#if QT_VERSION < 0x060000
QRegExp pattern(charFilterRegExpC(f));
#else
QRegularExpression pattern(charFilterRegExpC(f)); QRegularExpression pattern(charFilterRegExpC(f));
#endif
r.replace(pattern, "<u><b>\\1</b></u>"); r.replace(pattern, "<u><b>\\1</b></u>");
return r; return r;
} }

View File

@ -127,13 +127,8 @@ static QString release_notes()
continue; continue;
// detect links to the tracker // detect links to the tracker
#if QT_VERSION < 0x060000
line.replace(QRegExp("(bug )(\\#)(\\d+)*"),
"<a href=\"http://www.lyx.org/trac/ticket/\\3\">\\1\\3</a>");
#else
line.replace(QRegularExpression("(bug )(\\#)(\\d+)*"), line.replace(QRegularExpression("(bug )(\\#)(\\d+)*"),
"<a href=\"http://www.lyx.org/trac/ticket/\\3\">\\1\\3</a>"); "<a href=\"http://www.lyx.org/trac/ticket/\\3\">\\1\\3</a>");
#endif
// headings // headings
if (line.startsWith("!!!")) { if (line.startsWith("!!!")) {

View File

@ -111,7 +111,6 @@
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
#include <QRandomGenerator> #include <QRandomGenerator>
#endif #endif
#include <QRegExp>
#include <QSessionManager> #include <QSessionManager>
#include <QSettings> #include <QSettings>
#include <QSocketNotifier> #include <QSocketNotifier>
@ -2623,16 +2622,6 @@ void GuiApplication::createView(QString const & geometry_arg, bool autoShow,
int x, y; int x, y;
int w, h; int w, h;
QChar sx, sy; QChar sx, sy;
#if QT_VERSION < 0x060000
QRegExp re( "[=]*(?:([0-9]+)[xX]([0-9]+)){0,1}[ ]*(?:([+-][0-9]*)){0,1}(?:([+-][0-9]*)){0,1}" );
re.indexIn(geometry_arg);
w = re.cap(1).toInt();
h = re.cap(2).toInt();
x = re.cap(3).toInt();
y = re.cap(4).toInt();
sx = re.cap(3).isEmpty() ? '+' : re.cap(3).at(0);
sy = re.cap(4).isEmpty() ? '+' : re.cap(4).at(0);
#else
QRegularExpression re( "[=]*(?:([0-9]+)[xX]([0-9]+)){0,1}[ ]*(?:([+-][0-9]*)){0,1}(?:([+-][0-9]*)){0,1}" ); QRegularExpression re( "[=]*(?:([0-9]+)[xX]([0-9]+)){0,1}[ ]*(?:([+-][0-9]*)){0,1}(?:([+-][0-9]*)){0,1}" );
QRegularExpressionMatch match = re.match(geometry_arg); QRegularExpressionMatch match = re.match(geometry_arg);
w = match.captured(1).toInt(); w = match.captured(1).toInt();
@ -2641,7 +2630,7 @@ void GuiApplication::createView(QString const & geometry_arg, bool autoShow,
y = match.captured(4).toInt(); y = match.captured(4).toInt();
sx = match.captured(3).isEmpty() ? '+' : match.captured(3).at(0); sx = match.captured(3).isEmpty() ? '+' : match.captured(3).at(0);
sy = match.captured(4).isEmpty() ? '+' : match.captured(4).at(0); sy = match.captured(4).isEmpty() ? '+' : match.captured(4).at(0);
#endif
// Set initial geometry such that we can get the frame size. // Set initial geometry such that we can get the frame size.
view->setGeometry(x, y, w, h); view->setGeometry(x, y, w, h);
int framewidth = view->geometry().x() - view->x(); int framewidth = view->geometry().x() - view->x();

View File

@ -4002,13 +4002,8 @@ void GuiDocument::applyView()
pdf.pagemode.clear(); pdf.pagemode.clear();
pdf.quoted_options = pdf.quoted_options_check( pdf.quoted_options = pdf.quoted_options_check(
fromqstr(pdfSupportModule->optionsTE->toPlainText())); fromqstr(pdfSupportModule->optionsTE->toPlainText()));
#if QT_VERSION < 0x060000
bp_.document_metadata = qstring_to_ucs4(pdfSupportModule->metadataTE->toPlainText()
.trimmed().replace(QRegExp("\n+"), "\n"));
#else
bp_.document_metadata = qstring_to_ucs4(pdfSupportModule->metadataTE->toPlainText() bp_.document_metadata = qstring_to_ucs4(pdfSupportModule->metadataTE->toPlainText()
.trimmed().replace(QRegularExpression("\n+"), "\n")); .trimmed().replace(QRegularExpression("\n+"), "\n"));
#endif
// change tracking // change tracking
bp_.track_changes = changesModule->trackChangesCB->isChecked(); bp_.track_changes = changesModule->trackChangesCB->isChecked();

View File

@ -30,11 +30,7 @@
#include <QLineEdit> #include <QLineEdit>
#include <QPushButton> #include <QPushButton>
#include <QValidator> #include <QValidator>
#if QT_VERSION < 0x060000
#include <QRegExpValidator>
#else
#include <QRegularExpressionValidator> #include <QRegularExpressionValidator>
#endif
using namespace std; using namespace std;
using namespace lyx::support; using namespace lyx::support;
@ -236,11 +232,7 @@ GuiListings::GuiListings(GuiView & lv)
numberStepLE->setValidator(new QIntValidator(0, 1000000, this)); numberStepLE->setValidator(new QIntValidator(0, 1000000, this));
firstlineLE->setValidator(new QIntValidator(0, 1000000, this)); firstlineLE->setValidator(new QIntValidator(0, 1000000, this));
lastlineLE->setValidator(new QIntValidator(0, 1000000, this)); lastlineLE->setValidator(new QIntValidator(0, 1000000, this));
#if QT_VERSION < 0x060000
placementLE->setValidator(new QRegExpValidator(QRegExp("[\\*tbph]*"), this));
#else
placementLE->setValidator(new QRegularExpressionValidator(QRegularExpression("[\\*tbph]*"), this)); placementLE->setValidator(new QRegularExpressionValidator(QRegularExpression("[\\*tbph]*"), this));
#endif
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy); bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
bc().setOK(buttonBox->button(QDialogButtonBox::Ok)); bc().setOK(buttonBox->button(QDialogButtonBox::Ok));

View File

@ -41,21 +41,12 @@ namespace frontend {
// Regular expressions needed at several places // Regular expressions needed at several places
// FIXME: These regexes are incomplete. It would be good if we could collect those used in LaTeX::scanLogFile // FIXME: These regexes are incomplete. It would be good if we could collect those used in LaTeX::scanLogFile
// and LaTeX::scanBlgFile and re-use them here!(spitz, 2013-05-27) // and LaTeX::scanBlgFile and re-use them here!(spitz, 2013-05-27)
#if QT_VERSION < 0x060000
// Information
QRegExp exprInfo("^(Document Class:|LaTeX Font Info:|File:|Package:|Language:|.*> INFO - |\\(|\\\\).*$");
// Warnings
QRegExp exprWarning("^(## Warning|LaTeX Warning|LaTeX Font Warning|Package [\\w\\.]+ Warning|Class \\w+ Warning|Warning--|Underfull|Overfull|.*> WARN - ).*$");
// Errors
QRegExp exprError("^(ERROR: |!|.*---line [0-9]+ of file|.*> FATAL - |.*> ERROR - |Missing character: There is no ).*$");
#else
// Information // Information
QRegularExpression exprInfo("^(Document Class:|LaTeX Font Info:|File:|Package:|Language:|.*> INFO - |\\(|\\\\).*$"); QRegularExpression exprInfo("^(Document Class:|LaTeX Font Info:|File:|Package:|Language:|.*> INFO - |\\(|\\\\).*$");
// Warnings // Warnings
QRegularExpression exprWarning("^(## Warning|LaTeX Warning|LaTeX Font Warning|Package [\\w\\-\\.]+ Warning|Class \\w+ Warning|Warning--|Underfull|Overfull|.*> WARN - ).*$"); QRegularExpression exprWarning("^(## Warning|LaTeX Warning|LaTeX Font Warning|Package [\\w\\-\\.]+ Warning|Class \\w+ Warning|Warning--|Underfull|Overfull|.*> WARN - ).*$");
// Errors // Errors
QRegularExpression exprError("^(ERROR: |!|.*---line [0-9]+ of file|.*> FATAL - |.*> ERROR - |Missing character: There is no ).*$"); QRegularExpression exprError("^(ERROR: |!|.*---line [0-9]+ of file|.*> FATAL - |.*> ERROR - |Missing character: There is no ).*$");
#endif
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
@ -91,29 +82,6 @@ LogHighlighter::LogHighlighter(QTextDocument * parent)
void LogHighlighter::highlightBlock(QString const & text) void LogHighlighter::highlightBlock(QString const & text)
{ {
#if QT_VERSION < 0x060000
// Info
int index = exprInfo.indexIn(text);
while (index >= 0) {
int length = exprInfo.matchedLength();
setFormat(index, length, infoFormat);
index = exprInfo.indexIn(text, index + length);
}
// LaTeX Warning:
index = exprWarning.indexIn(text);
while (index >= 0) {
int length = exprWarning.matchedLength();
setFormat(index, length, warningFormat);
index = exprWarning.indexIn(text, index + length);
}
// ! error
index = exprError.indexIn(text);
while (index >= 0) {
int length = exprError.matchedLength();
setFormat(index, length, errorFormat);
index = exprError.indexIn(text, index + length);
}
#else
// Info // Info
QRegularExpressionMatch match = exprInfo.match(text); QRegularExpressionMatch match = exprInfo.match(text);
int index = match.capturedStart(1); int index = match.capturedStart(1);
@ -141,7 +109,6 @@ void LogHighlighter::highlightBlock(QString const & text)
match = exprError.match(text, index + length); match = exprError.match(text, index + length);
index = match.capturedStart(1); index = match.capturedStart(1);
} }
#endif
} }
@ -234,11 +201,7 @@ void GuiLog::on_openDirPB_clicked()
} }
#if QT_VERSION < 0x060000
void GuiLog::goTo(QRegExp const & exp) const
#else
void GuiLog::goTo(QRegularExpression const & exp) const void GuiLog::goTo(QRegularExpression const & exp) const
#endif
{ {
QTextCursor const newc = QTextCursor const newc =
logTB->document()->find(exp, logTB->textCursor()); logTB->document()->find(exp, logTB->textCursor());
@ -246,11 +209,7 @@ void GuiLog::goTo(QRegularExpression const & exp) const
} }
#if QT_VERSION < 0x060000
bool GuiLog::contains(QRegExp const & exp) const
#else
bool GuiLog::contains(QRegularExpression const & exp) const bool GuiLog::contains(QRegularExpression const & exp) const
#endif
{ {
return !logTB->document()->find(exp, logTB->textCursor()).isNull(); return !logTB->document()->find(exp, logTB->textCursor()).isNull();
} }

View File

@ -66,17 +66,10 @@ private:
docstring title() const; docstring title() const;
/// put the log file into the ostream /// put the log file into the ostream
void getContents(std::ostream & ss) const; void getContents(std::ostream & ss) const;
#if QT_VERSION < 0x060000
/// go to the next occurrence of the RegExp
void goTo(QRegExp const & exp) const;
/// does the document after cursor position contain the RegExp?
bool contains(QRegExp const & exp) const;
#else
/// go to the next occurrence of the RegExp /// go to the next occurrence of the RegExp
void goTo(QRegularExpression const & exp) const; void goTo(QRegularExpression const & exp) const;
/// does the document after cursor position contain the RegExp? /// does the document after cursor position contain the RegExp?
bool contains(QRegularExpression const & exp) const; bool contains(QRegularExpression const & exp) const;
#endif
private: private:
/// Recognized log file-types /// Recognized log file-types

View File

@ -189,11 +189,7 @@ QString browseRelToSub(QString const & filename, QString const & relpath,
toqstr(makeRelPath(qstring_to_ucs4(outname), qstring_to_ucs4(relpath))); toqstr(makeRelPath(qstring_to_ucs4(outname), qstring_to_ucs4(relpath)));
QString testname = reloutname; QString testname = reloutname;
#if QT_VERSION < 0x060000
testname.remove(QRegExp("^(\\.\\./)+"));
#else
testname.remove(QRegularExpression("^(\\.\\./)+")); testname.remove(QRegularExpression("^(\\.\\./)+"));
#endif
if (testname.contains("/")) if (testname.contains("/"))
return outname; return outname;
@ -2469,11 +2465,7 @@ PrefLanguage::PrefLanguage(GuiPreferences * form)
startCommandED->setValidator(new NoNewLineValidator(startCommandED)); startCommandED->setValidator(new NoNewLineValidator(startCommandED));
endCommandED->setValidator(new NoNewLineValidator(endCommandED)); endCommandED->setValidator(new NoNewLineValidator(endCommandED));
#if QT_VERSION < 0x060000
defaultDecimalSepED->setValidator(new QRegExpValidator(QRegExp("\\S"), this));
#else
defaultDecimalSepED->setValidator(new QRegularExpressionValidator(QRegularExpression("\\S"), this)); defaultDecimalSepED->setValidator(new QRegularExpressionValidator(QRegularExpression("\\S"), this));
#endif
defaultDecimalSepED->setMaxLength(1); defaultDecimalSepED->setMaxLength(1);
defaultLengthUnitCO->addItem(lyx::qt_(unit_name_gui[Length::CM]), Length::CM); defaultLengthUnitCO->addItem(lyx::qt_(unit_name_gui[Length::CM]), Length::CM);

View File

@ -178,11 +178,7 @@ GuiTabular::GuiTabular(QWidget * parent)
connect(tabularWidthED, SIGNAL(textEdited(const QString &)), connect(tabularWidthED, SIGNAL(textEdited(const QString &)),
this, SLOT(checkEnabled())); this, SLOT(checkEnabled()));
#if QT_VERSION < 0x060000
decimalPointED->setValidator(new QRegExpValidator(QRegExp("\\S"), this));
#else
decimalPointED->setValidator(new QRegularExpressionValidator(QRegularExpression("\\S"), this)); decimalPointED->setValidator(new QRegularExpressionValidator(QRegularExpression("\\S"), this));
#endif
decimalPointED->setMaxLength(1); decimalPointED->setMaxLength(1);
// initialize the length validator // initialize the length validator

View File

@ -124,22 +124,9 @@ void GuiThesaurus::selectionChanged()
QString item = meaningsTV->currentItem()->text(col); QString item = meaningsTV->currentItem()->text(col);
// cut out the classification in brackets: // cut out the classification in brackets:
// "hominid (generic term)" -> "hominid" // "hominid (generic term)" -> "hominid"
#if QT_VERSION < 0x060000
QRegExp re("^([^\\(\\)]+)\\b\\(?.*\\)?.*$");
#else
QRegularExpression re("^([^\\(\\)]+)\\b\\(?.*\\)?.*$"); QRegularExpression re("^([^\\(\\)]+)\\b\\(?.*\\)?.*$");
#endif
// This is for items with classifications at the beginning: // This is for items with classifications at the beginning:
// "(noun) man" -> "man"; "(noun) male (generic term)" -> "male" // "(noun) man" -> "man"; "(noun) male (generic term)" -> "male"
#if QT_VERSION < 0x060000
QRegExp rex("^(\\(.+\\))\\s*([^\\(\\)]+)\\s*\\(?.*\\)?.*$");
int pos = re.indexIn(item);
if (pos > -1)
item = re.cap(1).trimmed();
pos = rex.indexIn(item);
if (pos > -1)
item = rex.cap(2).trimmed();
#else
QRegularExpression rex("^(\\(.+\\))\\s*([^\\(\\)]+)\\s*\\(?.*\\)?.*$"); QRegularExpression rex("^(\\(.+\\))\\s*([^\\(\\)]+)\\s*\\(?.*\\)?.*$");
QRegularExpressionMatch match = re.match(item); QRegularExpressionMatch match = re.match(item);
if (match.hasMatch()) if (match.hasMatch())
@ -147,7 +134,6 @@ void GuiThesaurus::selectionChanged()
match = rex.match(item); match = rex.match(item);
if (match.hasMatch()) if (match.hasMatch())
item = match.captured(2).trimmed(); item = match.captured(2).trimmed();
#endif
replaceED->setText(item); replaceED->setText(item);
replacePB->setEnabled(!isBufferReadonly()); replacePB->setEnabled(!isBufferReadonly());
changed(); changed();
@ -165,22 +151,9 @@ void GuiThesaurus::selectionClicked(QTreeWidgetItem * item, int col)
QString str = item->text(col); QString str = item->text(col);
// cut out the classification in brackets: // cut out the classification in brackets:
// "hominid (generic term)" -> "hominid" // "hominid (generic term)" -> "hominid"
#if QT_VERSION < 0x060000
QRegExp re("^([^\\(\\)]+)\\b\\(?.*\\)?.*$");
#else
QRegularExpression re("^([^\\(\\)]+)\\b\\(?.*\\)?.*$"); QRegularExpression re("^([^\\(\\)]+)\\b\\(?.*\\)?.*$");
#endif
// This is for items with classifications at the beginning: // This is for items with classifications at the beginning:
// "(noun) man" -> "man"; "(noun) male (generic term)" -> "male" // "(noun) man" -> "man"; "(noun) male (generic term)" -> "male"
#if QT_VERSION < 0x060000
QRegExp rex("^(\\(.+\\))\\s*([^\\(\\)]+)\\s*\\(?.*\\)?.*$");
int pos = re.indexIn(str);
if (pos > -1)
str = re.cap(1).trimmed();
pos = rex.indexIn(str);
if (pos > -1)
str = rex.cap(2).trimmed();
#else
QRegularExpression rex("^(\\(.+\\))\\s*([^\\(\\)]+)\\s*\\(?.*\\)?.*$"); QRegularExpression rex("^(\\(.+\\))\\s*([^\\(\\)]+)\\s*\\(?.*\\)?.*$");
QRegularExpressionMatch match = re.match(str); QRegularExpressionMatch match = re.match(str);
if (match.hasMatch()) if (match.hasMatch())
@ -188,7 +161,6 @@ void GuiThesaurus::selectionClicked(QTreeWidgetItem * item, int col)
match = rex.match(str); match = rex.match(str);
if (match.hasMatch()) if (match.hasMatch())
str = match.captured(2).trimmed(); str = match.captured(2).trimmed();
#endif
entryCO->insertItem(0, str); entryCO->insertItem(0, str);
entryCO->setCurrentIndex(0); entryCO->setCurrentIndex(0);

View File

@ -46,109 +46,6 @@ LaTeXHighlighter::LaTeXHighlighter(QTextDocument * parent, bool at_letter, bool
void LaTeXHighlighter::highlightBlock(QString const & text) void LaTeXHighlighter::highlightBlock(QString const & text)
{ {
#if QT_VERSION < 0x060000
// keyval
if (keyval_) {
// Highlight key-val options. Used in some option widgets.
static const QRegExp exprKeyvalkey("[^=,]+");
static const QRegExp exprKeyvalval("[^,]+");
int kvindex = exprKeyvalkey.indexIn(text);
while (kvindex >= 0) {
int length = exprKeyvalkey.matchedLength();
setFormat(kvindex, length, keyFormat);
int kvvindex = exprKeyvalval.indexIn(text, kvindex + length);
if (kvvindex > 0) {
length += exprKeyvalval.matchedLength();
setFormat(kvvindex, length, valFormat);
}
kvindex = exprKeyvalkey.indexIn(text, kvindex + length);
}
}
// $ $
static const QRegExp exprMath("\\$[^\\$]*\\$");
int index = exprMath.indexIn(text);
while (index >= 0) {
int length = exprMath.matchedLength();
setFormat(index, length, mathFormat);
index = exprMath.indexIn(text, index + length);
}
// [ ]
static const QRegExp exprStartDispMath("(\\\\\\[|"
"\\\\begin\\{equation\\**\\}|"
"\\\\begin\\{eqnarray\\**\\}|"
"\\\\begin\\{align(ed|at)*\\**\\}|"
"\\\\begin\\{flalign\\**\\}|"
"\\\\begin\\{gather\\**\\}|"
"\\\\begin\\{multline\\**\\}|"
"\\\\begin\\{array\\**\\}|"
"\\\\begin\\{cases\\**\\}"
")");
static const QRegExp exprEndDispMath("(\\\\\\]|"
"\\\\end\\{equation\\**\\}|"
"\\\\end\\{eqnarray\\**\\}|"
"\\\\end\\{align(ed|at)*\\**\\}|"
"\\\\end\\{flalign\\**\\}|"
"\\\\end\\{gather\\**\\}|"
"\\\\end\\{multline\\**\\}|"
"\\\\end\\{array\\**\\}|"
"\\\\end\\{cases\\**\\}"
")");
int startIndex = 0;
// if previous block was in 'disp math'
// start search from 0 (for end disp math)
// otherwise, start search from 'begin disp math'
if (previousBlockState() != 1)
startIndex = exprStartDispMath.indexIn(text);
while (startIndex >= 0) {
int endIndex = exprEndDispMath.indexIn(text, startIndex);
int length;
if (endIndex == -1) {
setCurrentBlockState(1);
length = text.length() - startIndex;
} else {
length = endIndex - startIndex + exprEndDispMath.matchedLength();
}
setFormat(startIndex, length, mathFormat);
startIndex = exprStartDispMath.indexIn(text, startIndex + length);
}
// \whatever
static const QRegExp exprKeywordAtOther("\\\\[A-Za-z]+");
// \wh@tever
static const QRegExp exprKeywordAtLetter("\\\\[A-Za-z@]+");
QRegExp const & exprKeyword = at_letter_ ? exprKeywordAtLetter
: exprKeywordAtOther;
index = exprKeyword.indexIn(text);
while (index >= 0) {
int length = exprKeyword.matchedLength();
setFormat(index, length, keywordFormat);
index = exprKeyword.indexIn(text, index + length);
}
// %comment
// Treat a line as a comment starting at a percent sign
// * that is the first character in a line
// * that is preceded by
// ** an even number of backslashes
// ** any character other than a backslash
QRegExp exprComment("(?:^|[^\\\\])(?:\\\\\\\\)*(%).*$");
exprComment.indexIn(text);
index = exprComment.pos(1);
while (index >= 0) {
int const length = exprComment.matchedLength()
- (index - exprComment.pos(0));
setFormat(index, length, commentFormat);
exprComment.indexIn(text, index + length);
index = exprComment.pos(1);
}
// <LyX Warning: ...>
QString lyxwarn = qt_("LyX Warning: ");
QRegExp exprWarning("<" + lyxwarn + "[^<]*>");
index = exprWarning.indexIn(text);
while (index >= 0) {
int length = exprWarning.matchedLength();
setFormat(index, length, warningFormat);
index = exprWarning.indexIn(text, index + length);
}
#else
// keyval // keyval
if (keyval_) { if (keyval_) {
// Highlight key-val options. Used in some option widgets. // Highlight key-val options. Used in some option widgets.
@ -264,7 +161,6 @@ void LaTeXHighlighter::highlightBlock(QString const & text)
match = exprWarning.match(text, index + length); match = exprWarning.match(text, index + length);
index = match.capturedStart(0); index = match.capturedStart(0);
} }
#endif
} }
} // namespace frontend } // namespace frontend

View File

@ -43,7 +43,6 @@
#include <QHeaderView> #include <QHeaderView>
#include <QItemDelegate> #include <QItemDelegate>
#include <QPainter> #include <QPainter>
#include <QRegExp>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QTextFrame> #include <QTextFrame>
@ -300,11 +299,7 @@ QString LayoutItemDelegate::underlineFilter(QString const & s) const
if (f.isEmpty()) if (f.isEmpty())
return s; return s;
QString r(s); QString r(s);
#if QT_VERSION < 0x060000
QRegExp pattern(charFilterRegExpC(f));
#else
QRegularExpression pattern(charFilterRegExpC(f)); QRegularExpression pattern(charFilterRegExpC(f));
#endif
r.replace(pattern, "<u><b>\\1</b></u>"); r.replace(pattern, "<u><b>\\1</b></u>");
return r; return r;
} }

View File

@ -192,11 +192,7 @@ NoNewLineValidator::NoNewLineValidator(QWidget * parent)
QValidator::State NoNewLineValidator::validate(QString & qtext, int &) const QValidator::State NoNewLineValidator::validate(QString & qtext, int &) const
{ {
#if QT_VERSION < 0x060000
qtext.remove(QRegExp("[\\n\\r]"));
#else
qtext.remove(QRegularExpression("[\\n\\r]")); qtext.remove(QRegularExpression("[\\n\\r]"));
#endif
return QValidator::Acceptable; return QValidator::Acceptable;
} }

View File

@ -18,7 +18,7 @@
#include "support/docstring.h" #include "support/docstring.h"
#include "support/qstring_helpers.h" #include "support/qstring_helpers.h"
#include <QRegExp> #include <QRegularExpression>
#include <QLocale> #include <QLocale>
#include <QString> #include <QString>
#include <QVector> #include <QVector>
@ -83,9 +83,10 @@ QString charFilterRegExp(QString const & filter)
QString re = ".*"; QString re = ".*";
for (QChar const & c : filter) { for (QChar const & c : filter) {
if (c.isLower()) if (c.isLower())
re += "["+ QRegExp::escape(c) + QRegExp::escape(c.toUpper()) + "]"; re += "[" + QRegularExpression::escape(c)
+ QRegularExpression::escape(c.toUpper()) + "]";
else else
re += QRegExp::escape(c); re += QRegularExpression::escape(c);
} }
return re; return re;
} }
@ -95,9 +96,10 @@ QString charFilterRegExpC(QString const & filter)
QString re = "("; QString re = "(";
for (QChar const & c : filter) { for (QChar const & c : filter) {
if (c.isLower()) if (c.isLower())
re += "["+ QRegExp::escape(c) + QRegExp::escape(c.toUpper()) + "]"; re += "[" + QRegularExpression::escape(c)
+ QRegularExpression::escape(c.toUpper()) + "]";
else else
re += QRegExp::escape(c); re += QRegularExpression::escape(c);
} }
return re + ")"; return re + ")";
} }