From bfae053eb406adc386ce345e1ffff0a9775949f6 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 14 Jun 2014 16:22:56 +0200 Subject: [PATCH] + fix a couple of issues with InputField used in property editor --- src/Gui/InputField.cpp | 6 ++++-- src/Gui/propertyeditor/PropertyModel.cpp | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Gui/InputField.cpp b/src/Gui/InputField.cpp index 69acfd99d..41d6e6ce9 100644 --- a/src/Gui/InputField.cpp +++ b/src/Gui/InputField.cpp @@ -111,8 +111,9 @@ QPixmap InputField::getValidationIcon(const char* name, const QSize& size) const void InputField::updateText(const Base::Quantity& quant) { double dFactor; - QString unit; - setText(quant.getUserString(dFactor,unit)); + QString txt = quant.getUserString(dFactor,actUnitStr); + actUnitValue = quant.getValue()/dFactor; + setText(txt); } void InputField::resizeEvent(QResizeEvent *) @@ -517,6 +518,7 @@ void InputField::wheelEvent (QWheelEvent * event) val = Minimum; this->setText(QString::fromUtf8("%L1 %2").arg(val).arg(actUnitStr)); + selectNumber(); event->accept(); } diff --git a/src/Gui/propertyeditor/PropertyModel.cpp b/src/Gui/propertyeditor/PropertyModel.cpp index c1d6dbfad..952d94445 100644 --- a/src/Gui/propertyeditor/PropertyModel.cpp +++ b/src/Gui/propertyeditor/PropertyModel.cpp @@ -89,6 +89,13 @@ bool PropertyModel::setData(const QModelIndex& index, const QVariant & value, in if (fabs(d-v) > FLT_EPSILON) return item->setData(value); } + // Special case handling for quantities + else if (data.canConvert() && value.canConvert()) { + const Base::Quantity& val1 = data.value(); + const Base::Quantity& val2 = value.value(); + if (!(val1 == val2)) + return item->setData(value); + } else if (data != value) return item->setData(value); }