From cebed8eb2cb0a89b746d878f6b5e769d727d4530 Mon Sep 17 00:00:00 2001 From: peri4 Date: Fri, 5 Mar 2021 18:38:52 +0300 Subject: [PATCH] evalspinbox wheel --- libs/graphic/graphic.cpp | 2 ++ libs/graphic/graphic.ui | 3 +++ libs/widgets/evalspinbox.cpp | 16 +++++++++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/libs/graphic/graphic.cpp b/libs/graphic/graphic.cpp index dad4a7b..0ead8d8 100644 --- a/libs/graphic/graphic.cpp +++ b/libs/graphic/graphic.cpp @@ -820,6 +820,7 @@ void Graphic::exportGraphics(QString filename) { QMessageBox::critical(this, tr("Export graphics"), tr("Can`t open file \"%1\"!").arg(filename)); return; } + QApplication::setOverrideCursor(Qt::WaitCursor); f.resize(0); QTextStream ts(&f); ts << "#"; @@ -854,6 +855,7 @@ void Graphic::exportGraphics(QString filename) { if (has_data) ts << line; } + QApplication::restoreOverrideCursor(); } diff --git a/libs/graphic/graphic.ui b/libs/graphic/graphic.ui index 5cc6b8a..7a3f710 100644 --- a/libs/graphic/graphic.ui +++ b/libs/graphic/graphic.ui @@ -395,6 +395,9 @@ 4 + + 2 + diff --git a/libs/widgets/evalspinbox.cpp b/libs/widgets/evalspinbox.cpp index b0ad5bb..d9e7193 100644 --- a/libs/widgets/evalspinbox.cpp +++ b/libs/widgets/evalspinbox.cpp @@ -315,7 +315,7 @@ void EvalSpinBox::stepByDouble(double steps) { if (eval->check(t)) { t = eval->expression(); #if QT_VERSION_MAJOR <= 5 -/* QRegExp re("[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)"); + QRegExp re("[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)"); int pos = 0; if ((pos = re.indexIn(t)) != -1) { double v = t.mid(pos, re.matchedLength()).toDouble(); @@ -326,9 +326,19 @@ void EvalSpinBox::stepByDouble(double steps) { double v = steps; t = QString::number(v) + t; } -#else*/ +#else QRegularExpression re("[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)"); - /// TODO andrey + QRegularExpressionMatchIterator i = re.globalMatch(t); + if (i.hasNext()) { + QRegularExpressionMatch match = i.next(); + double v = t.mid(match.capturedStart(), match.capturedLength()).toDouble(); + v += steps; + t.remove(match.capturedStart(), match.capturedLength()); + t.insert(match.capturedStart(), QString::number(v)); + } else { + double v = steps; + t = QString::number(v) + t; + } #endif eval->check(t); lineEdit()->setText(eval->expression());