summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Gaist <samuel.gaist@edeltech.ch>2018-06-17 23:53:43 +0200
committerSamuel Gaist <samuel.gaist@edeltech.ch>2018-06-19 08:13:43 +0000
commit824b330e2eaab100f0e2a8bb7d60642674b297d9 (patch)
tree2b647561f69a12e20b8275a16c157ffc2edd5741
parentff0281ec6a103e2d87fcb3229c682f9c1e456bc5 (diff)
Migrate ChartAxisElement to QRegularExpression
This patch updates the ChartAxisElement to use QRegularExpression in place of QRegExp which is to be considered deprecated. Change-Id: I9f028e69c8337e5aad59351c9cccf222169df849 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/charts/axis/chartaxiselement.cpp49
1 files changed, 27 insertions, 22 deletions
diff --git a/src/charts/axis/chartaxiselement.cpp b/src/charts/axis/chartaxiselement.cpp
index 5282ee36..a090582f 100644
--- a/src/charts/axis/chartaxiselement.cpp
+++ b/src/charts/axis/chartaxiselement.cpp
@@ -34,6 +34,7 @@
#include <QtCharts/QCategoryAxis>
#include <QtCore/QtMath>
#include <QtCore/QDateTime>
+#include <QtCore/QRegularExpression>
#include <QtGui/QTextDocument>
#include <cmath>
@@ -41,8 +42,8 @@ QT_CHARTS_BEGIN_NAMESPACE
static const char *labelFormatMatchString = "%[\\-\\+#\\s\\d\\.\\'lhjztL]*([dicuoxfegXFEG])";
static const char *labelFormatMatchLocalizedString = "^([^%]*)%\\.(\\d+)([defgiEG])(.*)$";
-static QRegExp *labelFormatMatcher = 0;
-static QRegExp *labelFormatMatcherLocalized = 0;
+static QRegularExpression *labelFormatMatcher = 0;
+static QRegularExpression *labelFormatMatcherLocalized = 0;
class StaticLabelFormatMatcherDeleter
{
public:
@@ -358,19 +359,21 @@ QStringList ChartAxisElement::createValueLabels(qreal min, qreal max, int ticks,
if (presenter()->localizeNumbers()) {
if (!labelFormatMatcherLocalized)
labelFormatMatcherLocalized
- = new QRegExp(QString::fromLatin1(labelFormatMatchLocalizedString));
- if (labelFormatMatcherLocalized->indexIn(format, 0) != -1) {
- preStr = labelFormatMatcherLocalized->cap(1);
- if (!labelFormatMatcherLocalized->cap(2).isEmpty())
- precision = labelFormatMatcherLocalized->cap(2).toInt();
- formatSpec = labelFormatMatcherLocalized->cap(3);
- postStr = labelFormatMatcherLocalized->cap(4);
+ = new QRegularExpression(QString::fromLatin1(labelFormatMatchLocalizedString));
+ QRegularExpressionMatch rmatch;
+ if (format.indexOf(*labelFormatMatcherLocalized, 0, &rmatch) != -1) {
+ preStr = rmatch.captured(1);
+ if (!rmatch.captured(2).isEmpty())
+ precision = rmatch.captured(2).toInt();
+ formatSpec = rmatch.captured(3);
+ postStr = rmatch.captured(4);
}
} else {
if (!labelFormatMatcher)
- labelFormatMatcher = new QRegExp(QString::fromLatin1(labelFormatMatchString));
- if (labelFormatMatcher->indexIn(format, 0) != -1)
- formatSpec = labelFormatMatcher->cap(1);
+ labelFormatMatcher = new QRegularExpression(QString::fromLatin1(labelFormatMatchString));
+ QRegularExpressionMatch rmatch;
+ if (format.indexOf(*labelFormatMatcher, 0, &rmatch) != -1)
+ formatSpec = rmatch.captured(1);
}
for (int i = 0; i < ticks; i++) {
qreal value = min + (i * (max - min) / (ticks - 1));
@@ -413,19 +416,21 @@ QStringList ChartAxisElement::createLogValueLabels(qreal min, qreal max, qreal b
if (presenter()->localizeNumbers()) {
if (!labelFormatMatcherLocalized)
labelFormatMatcherLocalized =
- new QRegExp(QString::fromLatin1(labelFormatMatchLocalizedString));
- if (labelFormatMatcherLocalized->indexIn(format, 0) != -1) {
- preStr = labelFormatMatcherLocalized->cap(1);
- if (!labelFormatMatcherLocalized->cap(2).isEmpty())
- precision = labelFormatMatcherLocalized->cap(2).toInt();
- formatSpec = labelFormatMatcherLocalized->cap(3);
- postStr = labelFormatMatcherLocalized->cap(4);
+ new QRegularExpression(QString::fromLatin1(labelFormatMatchLocalizedString));
+ QRegularExpressionMatch rmatch;
+ if (format.indexOf(*labelFormatMatcherLocalized, 0, &rmatch) != -1) {
+ preStr = rmatch.captured(1);
+ if (!rmatch.captured(2).isEmpty())
+ precision = rmatch.captured(2).toInt();
+ formatSpec = rmatch.captured(3);
+ postStr = rmatch.captured(4);
}
} else {
if (!labelFormatMatcher)
- labelFormatMatcher = new QRegExp(QString::fromLatin1(labelFormatMatchString));
- if (labelFormatMatcher->indexIn(format, 0) != -1)
- formatSpec = labelFormatMatcher->cap(1);
+ labelFormatMatcher = new QRegularExpression(QString::fromLatin1(labelFormatMatchString));
+ QRegularExpressionMatch rmatch;
+ if (format.indexOf(*labelFormatMatcher, 0, &rmatch) != -1)
+ formatSpec = rmatch.captured(1);
}
for (int i = firstTick; i < ticks + firstTick; i++) {
qreal value = qPow(base, i);