Gui: don't make QuantitySpinBox dependent on implementation details of its base class
This commit is contained in:
@@ -743,15 +743,7 @@ QString QuantitySpinBox::getUserString(const Base::Quantity& val) const
|
||||
|
||||
void QuantitySpinBox::setExpression(std::shared_ptr<Expression> expr)
|
||||
{
|
||||
Q_ASSERT(isBound());
|
||||
|
||||
try {
|
||||
ExpressionBinding::setExpression(expr);
|
||||
validateInput();
|
||||
}
|
||||
catch (const Base::Exception & e) {
|
||||
showInvalidExpression(QString::fromLatin1(e.what()));
|
||||
}
|
||||
ExpressionSpinBox::setExpression(expr);
|
||||
}
|
||||
|
||||
QAbstractSpinBox::StepEnabled QuantitySpinBox::stepEnabled() const
|
||||
|
||||
@@ -157,7 +157,7 @@ protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
private:
|
||||
void validateInput();
|
||||
void validateInput() override;
|
||||
void updateText(const Base::Quantity&);
|
||||
void updateFromCache(bool notify, bool updateUnit = true);
|
||||
QString getUserString(const Base::Quantity& val, double& factor, QString& unitString) const;
|
||||
|
||||
@@ -76,6 +76,10 @@ void ExpressionSpinBox::showIcon()
|
||||
iconLabel->show();
|
||||
}
|
||||
|
||||
void ExpressionSpinBox::validateInput()
|
||||
{
|
||||
}
|
||||
|
||||
void ExpressionSpinBox::showInvalidExpression(const QString& tip)
|
||||
{
|
||||
spinbox->setReadOnly(true);
|
||||
@@ -142,6 +146,7 @@ void ExpressionSpinBox::setExpression(std::shared_ptr<Expression> expr)
|
||||
|
||||
try {
|
||||
ExpressionBinding::setExpression(expr);
|
||||
validateInput();
|
||||
}
|
||||
catch (const Base::Exception & e) {
|
||||
showInvalidExpression(QString::fromLatin1(e.what()));
|
||||
|
||||
@@ -61,6 +61,7 @@ protected:
|
||||
void onChange() override;
|
||||
virtual void setNumberExpression(App::NumberExpression*) = 0;
|
||||
virtual void showIcon();
|
||||
virtual void validateInput();
|
||||
void resizeWidget();
|
||||
|
||||
bool handleKeyEvent(const QString&);
|
||||
|
||||
Reference in New Issue
Block a user