Qt6 port:
* Constructor of QFontDatabase is deprecated, use static functions instead * Fix QuantitySpinBox::selectNumber() * Fix InputField::selectNumber() * Make InputField::fixup() compatible with Qt6 * QFont::setWeight requires an enum now * QInputEvent reuires a pointing device now * QAbstractItemView::viewOptions() has been renamed to QAbstractItemView::initViewItemOption()
This commit is contained in:
@@ -28,6 +28,8 @@
|
||||
# include <QFocusEvent>
|
||||
# include <QFontMetrics>
|
||||
# include <QLineEdit>
|
||||
# include <QRegularExpression>
|
||||
# include <QRegularExpressionMatch>
|
||||
# include <QStyle>
|
||||
# include <QStyleOptionSpinBox>
|
||||
# include <QToolTip>
|
||||
@@ -848,27 +850,16 @@ void QuantitySpinBox::clear()
|
||||
|
||||
void QuantitySpinBox::selectNumber()
|
||||
{
|
||||
QString str = lineEdit()->text();
|
||||
unsigned int i = 0;
|
||||
|
||||
QChar d = locale().decimalPoint();
|
||||
QChar g = locale().groupSeparator();
|
||||
QChar n = locale().negativeSign();
|
||||
|
||||
for (auto it : str) {
|
||||
if (it.isDigit())
|
||||
i++;
|
||||
else if (it == d)
|
||||
i++;
|
||||
else if (it == g)
|
||||
i++;
|
||||
else if (it == n)
|
||||
i++;
|
||||
else // any non-number character
|
||||
break;
|
||||
QString expr = QString::fromLatin1("^([%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());
|
||||
auto rmatch = QRegularExpression(expr).match(lineEdit()->text());
|
||||
if (rmatch.hasMatch()) {
|
||||
lineEdit()->setSelection(0, rmatch.capturedLength());
|
||||
}
|
||||
|
||||
lineEdit()->setSelection(0, i);
|
||||
}
|
||||
|
||||
QString QuantitySpinBox::textFromValue(const Base::Quantity& value) const
|
||||
|
||||
Reference in New Issue
Block a user