All: Reformat according to new standard

This commit is contained in:
pre-commit-ci[bot]
2025-11-11 13:49:01 +01:00
committed by Kacper Donat
parent eafd18dac0
commit 25c3ba7338
2390 changed files with 154630 additions and 115818 deletions

View File

@@ -20,17 +20,17 @@
* *
***************************************************************************/
# include <limits>
# include <QApplication>
# include <QDebug>
# include <QFocusEvent>
# include <QFontMetrics>
# include <QLineEdit>
# include <QRegularExpression>
# include <QRegularExpressionMatch>
# include <QStyle>
# include <QStyleOptionSpinBox>
# include <QToolTip>
#include <limits>
#include <QApplication>
#include <QDebug>
#include <QFocusEvent>
#include <QFontMetrics>
#include <QLineEdit>
#include <QRegularExpression>
#include <QRegularExpressionMatch>
#include <QStyle>
#include <QStyleOptionSpinBox>
#include <QToolTip>
#include <sstream>
@@ -55,32 +55,33 @@ using namespace Gui;
using namespace App;
using namespace Base;
namespace Gui {
namespace Gui
{
class QuantitySpinBoxPrivate
{
public:
QuantitySpinBoxPrivate(QuantitySpinBox *q) :
validInput(true),
pendingEmit(false),
normalize(true),
checkRangeInExpression(false),
unitValue(0),
maximum(std::numeric_limits<double>::max()),
minimum(-std::numeric_limits<double>::max()),
singleStep(1.0),
q_ptr(q)
{
}
QuantitySpinBoxPrivate(QuantitySpinBox* q)
: validInput(true)
, pendingEmit(false)
, normalize(true)
, checkRangeInExpression(false)
, unitValue(0)
, maximum(std::numeric_limits<double>::max())
, minimum(-std::numeric_limits<double>::max())
, singleStep(1.0)
, q_ptr(q)
{}
~QuantitySpinBoxPrivate() = default;
QString stripped(const QString &t, int *pos) const
QString stripped(const QString& t, int* pos) const
{
QString text = t;
const int s = text.size();
text = text.trimmed();
if (pos)
if (pos) {
(*pos) -= (s - text.size());
}
return text;
}
@@ -90,8 +91,9 @@ public:
// Do not accept empty strings because the parser will consider
// " unit" as "1 unit" which is not the desired behaviour (see #0004104)
if (input.isEmpty())
if (input.isEmpty()) {
return false;
}
bool success = false;
QString tmp = input;
@@ -119,27 +121,35 @@ public:
quantity.setUnit(unit);
result = quantity;
// Now translate the quantity into its string representation using the user-defined unit system
// Now translate the quantity into its string representation using the user-defined
// unit system
input = QString::fromStdString(Base::UnitsApi::schemaTranslate(result));
}
}
return success;
}
bool parseString(const QString& str, Base::Quantity& result, double& value, const App::ObjectIdentifier& path) const
bool parseString(
const QString& str,
Base::Quantity& result,
double& value,
const App::ObjectIdentifier& path
) const
{
App::ObjectIdentifier pathtmp = path;
try {
QString copy = str;
copy.remove(locale.groupSeparator());
//Expression parser
std::shared_ptr<Expression> expr(ExpressionParser::parse(path.getDocumentObject(), copy.toUtf8().constData()));
// Expression parser
std::shared_ptr<Expression> expr(
ExpressionParser::parse(path.getDocumentObject(), copy.toUtf8().constData())
);
if (expr) {
std::unique_ptr<Expression> res(expr->eval());
NumberExpression * n = freecad_cast<NumberExpression*>(res.get());
if (n){
NumberExpression* n = freecad_cast<NumberExpression*>(res.get());
if (n) {
result = n->getQuantity();
value = result.getValue();
return true;
@@ -151,7 +161,11 @@ public:
}
return false;
}
Base::Quantity validateAndInterpret(QString& input, QValidator::State& state, const App::ObjectIdentifier& path) const
Base::Quantity validateAndInterpret(
QString& input,
QValidator::State& state,
const App::ObjectIdentifier& path
) const
{
Base::Quantity res;
const double max = this->maximum;
@@ -163,17 +177,21 @@ public:
QChar plus = QLatin1Char('+'), minus = QLatin1Char('-');
if (locale.negativeSign() != minus)
if (locale.negativeSign() != minus) {
copy.replace(locale.negativeSign(), minus);
if (locale.positiveSign() != plus)
}
if (locale.positiveSign() != plus) {
copy.replace(locale.positiveSign(), plus);
}
QString reverseUnitStr = unitStr;
std::reverse(reverseUnitStr.begin(), reverseUnitStr.end());
//Prep for expression parser
//This regex matches chunks between +,-,$,^ accounting for matching parenthesis.
QRegularExpression chunkRe(QStringLiteral("(?<=^|[\\+\\-])((\\((?>[^()]|(?2))*\\))|[^\\+\\-\n])*(?=$|[\\+\\-])"));
// Prep for expression parser
// This regex matches chunks between +,-,$,^ accounting for matching parenthesis.
QRegularExpression chunkRe(
QStringLiteral("(?<=^|[\\+\\-])((\\((?>[^()]|(?2))*\\))|[^\\+\\-\n])*(?=$|[\\+\\-])")
);
QRegularExpressionMatchIterator expressionChunk = chunkRe.globalMatch(copy);
unsigned int lengthOffset = 0;
while (expressionChunk.hasNext()) {
@@ -182,39 +200,71 @@ public:
QString copyChunk = origionalChunk;
std::reverse(copyChunk.begin(), copyChunk.end());
//Reused regex patterns
static const std::string regexUnits = "sAV|VC|lim|nim|im|hpm|[mf]?bl|°|ged|dar|nog|″||rroT[uµm]?|K[uµm]?|A[mkM]?|F[pnuµm]?|C|S[uµmkM]?|zH[kMGT]?|H[nuµm]?|mhO[kM]?|J[mk]?|Ve[kM]?|V[mk]?|hWk|sW|lack?|N[mkM]?|g[uµmk]?|lm?|(?<=\\b|[^a-zA-Z])m[nuµmcdk]?|uoht|ni|\"|'|dy|dc|bW|T|t|zo|ts|twc|Wk?|aP[kMG]?|is[pk]|h|G|M|tfc|tfqs|tf|s";
static const std::string regexUnitlessFunctions = "soca|nisa|2nata|nata|hsoc|hnis|hnat|soc|nat|nis|pxe|gol|01gol";
// Reused regex patterns
static const std::string regexUnits
= "sAV|VC|lim|nim|im|hpm|[mf]?bl|°|ged|dar|nog|″||rroT[uµm]?|K[uµm]?|A[mkM]?|F["
"pnuµm]?|C|S[uµmkM]?|zH[kMGT]?|H[nuµm]?|mhO[kM]?|J[mk]?|Ve[kM]?|V[mk]?|hWk|sW|"
"lack?|N[mkM]?|g[uµmk]?|lm?|(?<=\\b|[^a-zA-Z])m[nuµmcdk]?|uoht|ni|\"|'|dy|dc|bW|"
"T|t|zo|ts|twc|Wk?|aP[kMG]?|is[pk]|h|G|M|tfc|tfqs|tf|s";
static const std::string regexUnitlessFunctions
= "soca|nisa|2nata|nata|hsoc|hnis|hnat|soc|nat|nis|pxe|gol|01gol";
static const std::string regexConstants = "e|ip|lomm|lom";
static const std::string regexNumber = "\\d+\\s*\\.?\\s*\\d*|\\.\\s*\\d+";
// If expression does not contain /*() or ^, this regex will not find anything
if (copy.contains(QLatin1Char('/')) || copy.contains(QLatin1Char('*')) || copy.contains(QLatin1Char('(')) || copy.contains(QLatin1Char(')')) || copy.contains(QLatin1Char('^'))){
//Find units and replace 1/2mm -> 1/2*(1mm), 1^2mm -> 1^2*(1mm)
QRegularExpression fixUnits(QString::fromStdString("("+regexUnits+")(\\s*\\)|(?:\\*|(?:\\)(?:(?:\\s*(?:"+regexConstants+"|\\)(?:[^()]|(?R))*\\((?:"+regexUnitlessFunctions+")|"+regexNumber+"))|(?R))*\\(|(?:\\s*(?:"+regexConstants+"|\\)(?:[^()]|(?R))*\\((?:"+regexUnitlessFunctions+")|"+regexNumber+"))))+(?:[\\/\\^]|(.*$))(?!("+regexUnits+")))"));
if (copy.contains(QLatin1Char('/')) || copy.contains(QLatin1Char('*'))
|| copy.contains(QLatin1Char('(')) || copy.contains(QLatin1Char(')'))
|| copy.contains(QLatin1Char('^'))) {
// Find units and replace 1/2mm -> 1/2*(1mm), 1^2mm -> 1^2*(1mm)
QRegularExpression fixUnits(
QString::fromStdString(
"(" + regexUnits + ")(\\s*\\)|(?:\\*|(?:\\)(?:(?:\\s*(?:" + regexConstants
+ "|\\)(?:[^()]|(?R))*\\((?:" + regexUnitlessFunctions + ")|" + regexNumber
+ "))|(?R))*\\(|(?:\\s*(?:" + regexConstants
+ "|\\)(?:[^()]|(?R))*\\((?:" + regexUnitlessFunctions + ")|" + regexNumber
+ "))))+(?:[\\/\\^]|(.*$))(?!(" + regexUnits + ")))"
)
);
QRegularExpressionMatch fixUnitsMatch = fixUnits.match(copyChunk);
//3rd capture group being filled indicates regex bailed out; no match.
if (fixUnitsMatch.lastCapturedIndex() == 2 || (fixUnitsMatch.lastCapturedIndex() == 3 && fixUnitsMatch.captured(3).isEmpty())){
// 3rd capture group being filled indicates regex bailed out; no match.
if (fixUnitsMatch.lastCapturedIndex() == 2
|| (fixUnitsMatch.lastCapturedIndex() == 3
&& fixUnitsMatch.captured(3).isEmpty())) {
QString matchUnits = fixUnitsMatch.captured(1);
QString matchNumbers = fixUnitsMatch.captured(2);
copyChunk.replace(matchUnits+matchNumbers, QStringLiteral(")")+matchUnits+QStringLiteral("1(*")+matchNumbers);
copyChunk.replace(
matchUnits + matchNumbers,
QStringLiteral(")") + matchUnits + QStringLiteral("1(*") + matchNumbers
);
}
}
//Add default units to string if none are present
if (!copyChunk.contains(reverseUnitStr)){ // Fast check
QRegularExpression unitsRe(QString::fromStdString("(?<=\\b|[^a-zA-Z])("+regexUnits+")(?=\\b|[^a-zA-Z])|°|||\"|'|\\p{L}\\.\\p{L}|\\[\\p{L}"));
// Add default units to string if none are present
if (!copyChunk.contains(reverseUnitStr)) { // Fast check
QRegularExpression unitsRe(
QString::fromStdString(
"(?<=\\b|[^a-zA-Z])(" + regexUnits
+ ")(?=\\b|[^a-zA-Z])|°|″||\"|'|\\p{L}\\.\\p{L}|\\[\\p{L}"
)
);
QRegularExpressionMatch match = unitsRe.match(copyChunk);
if (!match.hasMatch() && !copyChunk.isEmpty()) //If no units are found, use default units
copyChunk.prepend(QStringLiteral(")")+reverseUnitStr+QStringLiteral("1(*")); // Add units to the end of chunk *(1unit)
if (!match.hasMatch() && !copyChunk.isEmpty()) { // If no units are found, use
// default units
copyChunk.prepend(
QStringLiteral(")") + reverseUnitStr + QStringLiteral("1(*")
); // Add units to the end of chunk *(1unit)
}
}
std::reverse(copyChunk.begin(), copyChunk.end());
copy.replace(matchChunk.capturedStart() + lengthOffset,
matchChunk.capturedEnd() - matchChunk.capturedStart(), copyChunk);
copy.replace(
matchChunk.capturedStart() + lengthOffset,
matchChunk.capturedEnd() - matchChunk.capturedStart(),
copyChunk
);
lengthOffset += copyChunk.length() - origionalChunk.length();
}
@@ -230,9 +280,10 @@ public:
state = QValidator::Intermediate;
}
else if (value >= min && value <= max) {
state = QValidator::Acceptable;
state = QValidator::Acceptable;
}
else if (max == min) { // when max and min is the same the only non-Invalid input is max (or min)
else if (max == min) { // when max and min is the same the only non-Invalid input is max
// (or min)
state = QValidator::Invalid;
}
else {
@@ -264,30 +315,26 @@ public:
double maximum;
double minimum;
double singleStep;
QuantitySpinBox *q_ptr;
QuantitySpinBox* q_ptr;
std::unique_ptr<Base::UnitsSchema> scheme;
Q_DECLARE_PUBLIC(QuantitySpinBox)
};
}
} // namespace Gui
QuantitySpinBox::QuantitySpinBox(QWidget *parent)
: QAbstractSpinBox(parent),
ExpressionSpinBox(this),
d_ptr(new QuantitySpinBoxPrivate(this))
QuantitySpinBox::QuantitySpinBox(QWidget* parent)
: QAbstractSpinBox(parent)
, ExpressionSpinBox(this)
, d_ptr(new QuantitySpinBoxPrivate(this))
{
d_ptr->locale = locale();
this->setContextMenuPolicy(Qt::DefaultContextMenu);
connect(lineEdit(), &QLineEdit::textChanged,
this, &QuantitySpinBox::userInput);
connect(this, &QuantitySpinBox::editingFinished,
this, [&]{
this->handlePendingEmit(true);
});
connect(lineEdit(), &QLineEdit::textChanged, this, &QuantitySpinBox::userInput);
connect(this, &QuantitySpinBox::editingFinished, this, [&] { this->handlePendingEmit(true); });
}
QuantitySpinBox::~QuantitySpinBox() = default;
void QuantitySpinBox::bind(const App::ObjectIdentifier &_path)
void QuantitySpinBox::bind(const App::ObjectIdentifier& _path)
{
ExpressionSpinBox::bind(_path);
}
@@ -312,11 +359,11 @@ QString QuantitySpinBox::boundToName() const
* An identifier is written as document#documentobject.property.subproperty1...subpropertyN
* document# may be dropped, in this case the active document is used.
*/
void QuantitySpinBox::setBoundToByName(const QString &name)
void QuantitySpinBox::setBoundToByName(const QString& name)
{
try {
// get document
App::Document *doc = App::GetApplication().getActiveDocument();
App::Document* doc = App::GetApplication().getActiveDocument();
QStringList list = name.split(QLatin1Char('#'));
if (list.size() > 1) {
doc = App::GetApplication().getDocument(list.front().toLatin1());
@@ -344,12 +391,13 @@ void QuantitySpinBox::setBoundToByName(const QString &name)
path.setDocumentName(std::string(doc->getName()), true);
path.setDocumentObjectName(std::string(obj->getNameInDocument()), true);
for (const auto & it : list) {
for (const auto& it : list) {
path << App::ObjectIdentifier::Component::SimpleComponent(it.toLatin1().constData());
}
if (path.getProperty())
if (path.getProperty()) {
bind(path);
}
}
catch (const Base::Exception& e) {
qDebug() << e.what();
@@ -382,7 +430,7 @@ void Gui::QuantitySpinBox::setNumberExpression(App::NumberExpression* expr)
handlePendingEmit();
}
bool QuantitySpinBox::apply(const std::string & propName)
bool QuantitySpinBox::apply(const std::string& propName)
{
if (!ExpressionBinding::apply(propName)) {
double dValue = value().getValue();
@@ -392,7 +440,7 @@ bool QuantitySpinBox::apply(const std::string & propName)
return false;
}
void QuantitySpinBox::resizeEvent(QResizeEvent * event)
void QuantitySpinBox::resizeEvent(QResizeEvent* event)
{
QAbstractSpinBox::resizeEvent(event);
resizeWidget();
@@ -425,13 +473,13 @@ void Gui::QuantitySpinBox::paintEvent(QPaintEvent*)
drawControl(opt);
}
void QuantitySpinBox::updateText(const Quantity &quant)
void QuantitySpinBox::updateText(const Quantity& quant)
{
Q_D(QuantitySpinBox);
double dFactor;
QString txt = getUserString(quant, dFactor, d->unitStr);
d->unitValue = quant.getValue()/dFactor;
d->unitValue = quant.getValue() / dFactor;
updateEdit(txt);
handlePendingEmit();
}
@@ -463,7 +511,7 @@ void QuantitySpinBox::validateInput()
QValidator::State state;
QString text = lineEdit()->text();
const App::ObjectIdentifier & path = getPath();
const App::ObjectIdentifier& path = getPath();
d->validateAndInterpret(text, state, path);
if (state != QValidator::Acceptable) {
updateEdit(d->validStr);
@@ -495,8 +543,10 @@ void QuantitySpinBox::normalize()
bool QuantitySpinBox::isNormalized()
{
static const QRegularExpression operators(QStringLiteral("[+\\-/*]"),
QRegularExpression::CaseInsensitiveOption);
static const QRegularExpression operators(
QStringLiteral("[+\\-/*]"),
QRegularExpression::CaseInsensitiveOption
);
Q_D(const QuantitySpinBox);
@@ -513,10 +563,12 @@ void QuantitySpinBox::setValue(const Base::Quantity& value)
Q_D(QuantitySpinBox);
d->quantity = value;
// check limits
if (d->quantity.getValue() > d->maximum)
if (d->quantity.getValue() > d->maximum) {
d->quantity.setValue(d->maximum);
if (d->quantity.getValue() < d->minimum)
}
if (d->quantity.getValue() < d->minimum) {
d->quantity.setValue(d->minimum);
}
d->unit = value.getUnit();
@@ -553,7 +605,7 @@ bool QuantitySpinBox::hasValidInput() const
}
// Gets called after call of 'validateAndInterpret'
void QuantitySpinBox::userInput(const QString & text)
void QuantitySpinBox::userInput(const QString& text)
{
Q_D(QuantitySpinBox);
@@ -561,7 +613,7 @@ void QuantitySpinBox::userInput(const QString & text)
QString tmp = text;
Base::Quantity res;
const App::ObjectIdentifier & path = getPath();
const App::ObjectIdentifier& path = getPath();
if (d->validate(tmp, res, path)) {
d->validStr = tmp;
d->validInput = true;
@@ -602,10 +654,12 @@ void QuantitySpinBox::openFormulaDialog()
box->setRange(d->minimum, d->maximum);
}
QObject::connect(box, &Gui::Dialog::DlgExpressionInput::finished, [this, box]() {
if (box->result() == QDialog::Accepted)
if (box->result() == QDialog::Accepted) {
setExpression(box->getExpression());
else if (box->discardedFormula())
}
else if (box->discardedFormula()) {
setExpression(std::shared_ptr<Expression>());
}
updateExpression();
box->deleteLater();
@@ -613,8 +667,8 @@ void QuantitySpinBox::openFormulaDialog()
});
box->show();
QPoint pos = mapToGlobal(QPoint(0,0));
box->move(pos-box->expressionPosition());
QPoint pos = mapToGlobal(QPoint(0, 0));
box->move(pos - box->expressionPosition());
Gui::adjustDialogPosition(box);
Q_EMIT showFormulaDialog(true);
@@ -652,7 +706,7 @@ Base::Unit QuantitySpinBox::unit() const
return d->unit;
}
void QuantitySpinBox::setUnit(const Base::Unit &unit)
void QuantitySpinBox::setUnit(const Base::Unit& unit)
{
Q_D(QuantitySpinBox);
@@ -770,7 +824,7 @@ QString QuantitySpinBox::getUserString(const Base::Quantity& val, double& factor
Q_D(const QuantitySpinBox);
std::string unitStr;
const std::string str = d->scheme ? val.getUserString(d->scheme.get(), factor, unitStr)
: val.getUserString(factor, unitStr);
: val.getUserString(factor, unitStr);
unitString = QString::fromStdString(unitStr);
return QString::fromStdString(str);
}
@@ -798,10 +852,12 @@ void QuantitySpinBox::setExpression(std::shared_ptr<Expression> expr)
QAbstractSpinBox::StepEnabled QuantitySpinBox::stepEnabled() const
{
Q_D(const QuantitySpinBox);
if (isReadOnly()/* || !d->validInput*/)
if (isReadOnly() /* || !d->validInput*/) {
return StepNone;
if (wrapping())
}
if (wrapping()) {
return StepEnabled(StepUpEnabled | StepDownEnabled);
}
StepEnabled ret = StepNone;
if (d->quantity.getValue() < d->maximum) {
ret |= StepUpEnabled;
@@ -819,10 +875,12 @@ void QuantitySpinBox::stepBy(int steps)
double step = d->singleStep * steps;
double val = d->unitValue + step;
if (val > d->maximum)
if (val > d->maximum) {
val = d->maximum;
else if (val < d->minimum)
}
else if (val < d->minimum) {
val = d->minimum;
}
Quantity quant(val, d->unitStr.toStdString());
updateText(quant);
@@ -837,7 +895,7 @@ QSize QuantitySpinBox::sizeForText(const QString& txt) const
int h = lineEdit()->sizeHint().height();
int w = QtTools::horizontalAdvance(fm, txt);
w += 2; // cursor blinking space
w += 2; // cursor blinking space
w += iconHeight;
QStyleOptionSpinBox opt;
@@ -876,7 +934,7 @@ QSize QuantitySpinBox::sizeHintCalculator(int h) const
s += fixedContent;
w = qMax(w, QtTools::horizontalAdvance(fm, s));
w += 2; // cursor blinking space
w += 2; // cursor blinking space
w += iconHeight;
QStyleOptionSpinBox opt;
@@ -887,7 +945,7 @@ QSize QuantitySpinBox::sizeHintCalculator(int h) const
return size;
}
void QuantitySpinBox::showEvent(QShowEvent * event)
void QuantitySpinBox::showEvent(QShowEvent* event)
{
Q_D(QuantitySpinBox);
@@ -895,49 +953,54 @@ void QuantitySpinBox::showEvent(QShowEvent * event)
bool selected = lineEdit()->hasSelectedText();
updateText(d->quantity);
if (selected)
if (selected) {
selectNumber();
}
}
void QuantitySpinBox::hideEvent(QHideEvent * event)
void QuantitySpinBox::hideEvent(QHideEvent* event)
{
handlePendingEmit();
QAbstractSpinBox::hideEvent(event);
}
void QuantitySpinBox::closeEvent(QCloseEvent * event)
void QuantitySpinBox::closeEvent(QCloseEvent* event)
{
handlePendingEmit();
QAbstractSpinBox::closeEvent(event);
}
bool QuantitySpinBox::event(QEvent * event)
bool QuantitySpinBox::event(QEvent* event)
{
return QAbstractSpinBox::event(event);
}
void QuantitySpinBox::focusInEvent(QFocusEvent * event)
void QuantitySpinBox::focusInEvent(QFocusEvent* event)
{
bool hasSel = lineEdit()->hasSelectedText();
QAbstractSpinBox::focusInEvent(event);
if (event->reason() == Qt::TabFocusReason ||
event->reason() == Qt::BacktabFocusReason ||
event->reason() == Qt::ShortcutFocusReason) {
if (event->reason() == Qt::TabFocusReason || event->reason() == Qt::BacktabFocusReason
|| event->reason() == Qt::ShortcutFocusReason) {
if (isBound() && getExpression() && lineEdit()->isReadOnly()) {
auto helpEvent = new QHelpEvent(QEvent::ToolTip, QPoint( 0, rect().height() ), mapToGlobal( QPoint( 0, rect().height() ) ));
auto helpEvent = new QHelpEvent(
QEvent::ToolTip,
QPoint(0, rect().height()),
mapToGlobal(QPoint(0, rect().height()))
);
QApplication::postEvent(this, helpEvent);
lineEdit()->setSelection(0, 0);
}
else {
if (!hasSel)
if (!hasSel) {
selectNumber();
}
}
}
}
void QuantitySpinBox::focusOutEvent(QFocusEvent * event)
void QuantitySpinBox::focusOutEvent(QFocusEvent* event)
{
Q_D(const QuantitySpinBox);
@@ -959,11 +1022,11 @@ void QuantitySpinBox::clear()
void QuantitySpinBox::selectNumber()
{
QString expr = QStringLiteral("^([%1%2]?[0-9\\%3]*)\\%4?([0-9]+(%5[%1%2]?[0-9]+)?)")
.arg(locale().negativeSign())
.arg(locale().positiveSign())
.arg(locale().groupSeparator())
.arg(locale().decimalPoint())
.arg(locale().exponential());
.arg(locale().negativeSign())
.arg(locale().positiveSign())
.arg(locale().groupSeparator())
.arg(locale().decimalPoint())
.arg(locale().exponential());
auto rmatch = QRegularExpression(expr).match(lineEdit()->text());
if (rmatch.hasMatch()) {
lineEdit()->setSelection(0, rmatch.capturedLength());
@@ -979,13 +1042,13 @@ QString QuantitySpinBox::textFromValue(const Base::Quantity& value) const
return str;
}
Base::Quantity QuantitySpinBox::valueFromText(const QString &text) const
Base::Quantity QuantitySpinBox::valueFromText(const QString& text) const
{
Q_D(const QuantitySpinBox);
QString copy = text;
QValidator::State state = QValidator::Acceptable;
const App::ObjectIdentifier & path = getPath();
const App::ObjectIdentifier& path = getPath();
Base::Quantity quant = d->validateAndInterpret(copy, state, path);
if (state != QValidator::Acceptable) {
fixup(copy);
@@ -995,18 +1058,18 @@ Base::Quantity QuantitySpinBox::valueFromText(const QString &text) const
return quant;
}
QValidator::State QuantitySpinBox::validate(QString &text, int &pos) const
QValidator::State QuantitySpinBox::validate(QString& text, int& pos) const
{
Q_D(const QuantitySpinBox);
Q_UNUSED(pos)
QValidator::State state;
const App::ObjectIdentifier & path = getPath();
const App::ObjectIdentifier& path = getPath();
d->validateAndInterpret(text, state, path);
return state;
}
void QuantitySpinBox::fixup(QString &input) const
void QuantitySpinBox::fixup(QString& input) const
{
input.remove(locale().groupSeparator());
}