Fix deprecated QRegExp

Use QRegularExpression instead.

https://doc.qt.io/qt-5/qregularexpression.html#notes-for-qregexp-users

This function was introduced in Qt 5
This commit is contained in:
Simon De Backer
2020-09-18 23:05:29 +02:00
parent 93055c6a96
commit 3eca82baad

View File

@@ -28,6 +28,7 @@
#include <iostream> #include <iostream>
#include <QAbstractTextDocumentLayout> #include <QAbstractTextDocumentLayout>
#include <QGraphicsSimpleTextItem> #include <QGraphicsSimpleTextItem>
#include <QRegularExpression>
ElementPictureFactory* ElementPictureFactory::m_factory = nullptr; ElementPictureFactory* ElementPictureFactory::m_factory = nullptr;
@@ -568,11 +569,11 @@ void ElementPictureFactory::setPainterStyle(const QDomElement &dom, QPainter &pa
#pragma message("@TODO remove code for QT 5.14 or later") #pragma message("@TODO remove code for QT 5.14 or later")
const QStringList styles = dom.attribute("style").split(";", Qt::SkipEmptyParts); const QStringList styles = dom.attribute("style").split(";", Qt::SkipEmptyParts);
#endif #endif
QRegExp rx("^\\s*([a-z-]+)\\s*:\\s*([a-zA-Z-]+)\\s*$"); QRegularExpression rx("^\\s*([a-z-]+)\\s*:\\s*([a-zA-Z-]+)\\s*$");
for (QString style : styles) { for (QString style : styles) {
if (rx.exactMatch(style)) { if (rx==QRegularExpression(style)) {
QString style_name = rx.cap(1); QString style_name = rx.namedCaptureGroups().at(1);
QString style_value = rx.cap(2); QString style_value = rx.namedCaptureGroups().at(2);
if (style_name == "line-style") { if (style_name == "line-style") {
if (style_value == "dashed") pen.setStyle(Qt::DashLine); if (style_value == "dashed") pen.setStyle(Qt::DashLine);
else if (style_value == "dotted") pen.setStyle(Qt::DotLine); else if (style_value == "dotted") pen.setStyle(Qt::DotLine);