From 30e5321e7680659ef2412a3b9aaffe28d0cc1efd Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 12 May 2014 14:14:23 +0200 Subject: [PATCH] + fix whitespaces and a few minor things --- src/App/PropertyUnits.cpp | 10 +++++----- src/Gui/InputField.cpp | 12 ++++++------ src/Gui/InputField.h | 8 ++++---- src/Gui/Placement.cpp | 18 +++++++++--------- src/Gui/propertyeditor/PropertyItem.cpp | 16 ++++++++-------- src/Gui/propertyeditor/PropertyItem.h | 3 +-- 6 files changed, 33 insertions(+), 34 deletions(-) diff --git a/src/App/PropertyUnits.cpp b/src/App/PropertyUnits.cpp index 2cb23b442..04a4ca268 100644 --- a/src/App/PropertyUnits.cpp +++ b/src/App/PropertyUnits.cpp @@ -46,8 +46,8 @@ using namespace Base; using namespace std; -const PropertyQuantityConstraint::Constraints LengthStandart = {0.0,(double)INT_MAX,1.0}; -const PropertyQuantityConstraint::Constraints AngleStandart = {-360,360,1.0}; +const PropertyQuantityConstraint::Constraints LengthStandard = {0.0,(double)INT_MAX,1.0}; +const PropertyQuantityConstraint::Constraints AngleStandard = {-360,360,1.0}; //************************************************************************** //************************************************************************** @@ -63,7 +63,7 @@ Base::Quantity PropertyQuantity::getQuantityValue(void) const const char* PropertyQuantity::getEditorName(void) const { - return "Gui::PropertyEditor::PropertyUnitItem"; + return "Gui::PropertyEditor::PropertyUnitItem"; } PyObject *PropertyQuantity::getPyObject(void) @@ -210,7 +210,7 @@ TYPESYSTEM_SOURCE(App::PropertyLength, App::PropertyQuantityConstraint); PropertyLength::PropertyLength() { setUnit(Base::Unit::Length); - setConstraints( &LengthStandart ); + setConstraints(&LengthStandard); } //************************************************************************** @@ -223,7 +223,7 @@ TYPESYSTEM_SOURCE(App::PropertyAngle, App::PropertyQuantityConstraint); PropertyAngle::PropertyAngle() { setUnit(Base::Unit::Angle); - setConstraints( &AngleStandart ); + setConstraints(&AngleStandard); } //************************************************************************** diff --git a/src/Gui/InputField.cpp b/src/Gui/InputField.cpp index 27f4215ae..d47d68f88 100644 --- a/src/Gui/InputField.cpp +++ b/src/Gui/InputField.cpp @@ -160,17 +160,17 @@ void InputField::newInput(const QString & text) QPixmap pixmap = BitmapFactory().pixmapFromSvg(":/icons/button_invalid.svg", QSize(sizeHint().height(),sizeHint().height())); iconLabel->setPixmap(pixmap); parseError(QString::fromAscii(ErrorText.c_str())); - validInput = false; + validInput = false; return; } - // check if unit fits! - if(!actUnit.isEmpty() && !res.getUnit().isEmpty() && actUnit != res.getUnit()){ - this->setToolTip(QString::fromAscii("Wrong unit")); + // check if unit fits! + if(!actUnit.isEmpty() && !res.getUnit().isEmpty() && actUnit != res.getUnit()){ + this->setToolTip(QString::fromAscii("Wrong unit")); QPixmap pixmap = BitmapFactory().pixmapFromSvg(":/icons/button_invalid.svg", QSize(sizeHint().height(),sizeHint().height())); iconLabel->setPixmap(pixmap); parseError(QString::fromAscii("Wrong unit")); - validInput = false; + validInput = false; return; } @@ -342,7 +342,7 @@ void InputField::setUnit(const Base::Unit& unit) actUnit = unit; } -Base::Unit InputField::getUnit() +const Base::Unit& InputField::getUnit() const { return actUnit; } diff --git a/src/Gui/InputField.h b/src/Gui/InputField.h index 8c805cab2..7bd3b917b 100644 --- a/src/Gui/InputField.h +++ b/src/Gui/InputField.h @@ -69,15 +69,15 @@ public: void setValue(const Base::Quantity&); //set a numerical value which gets converted to a quantity with the currently set unit type void setValue(const double&); - + /// get the current value Base::Quantity getQuantity(void)const{return this->actQuantity;} - + /// gives the current state of the user input, gives true if it is a valid input with correct quantity /// (shown by the green pixmap), returns false if the input is a unparsable string or has a wrong unit /// (shown by the red pixmap in the gui) bool hasValidInput() { return validInput;}; - + /** sets the Unit this field is working with. * After setting the Unit the field will only accept * user input with this unit type. Or if the user input @@ -85,7 +85,7 @@ public: * Quantity. */ void setUnit(const Base::Unit&); - Base::Unit getUnit(); + const Base::Unit& getUnit() const; /// set the input field to the last used value (works only if the setParamGrpPath() was called) void setToLastUsedValue(void); diff --git a/src/Gui/Placement.cpp b/src/Gui/Placement.cpp index 720eadb27..b7de0d01c 100644 --- a/src/Gui/Placement.cpp +++ b/src/Gui/Placement.cpp @@ -82,7 +82,7 @@ Placement::Placement(QWidget* parent, Qt::WFlags fl) propertyName = "Placement"; // default name ui = new Ui_PlacementComp(this); ui->applyPlacementChange->hide(); - + ui->xPos->setUnit(Base::Unit::Length); ui->yPos->setUnit(Base::Unit::Length); ui->zPos->setUnit(Base::Unit::Length); @@ -137,7 +137,7 @@ bool Placement::hasValidInputs() QList sb = this->findChildren(); for (QList::iterator it = sb.begin(); it != sb.end(); ++it) { if(!(*it)->hasValidInput()) - return false; + return false; } return true; } @@ -298,14 +298,14 @@ void Placement::accept() void Placement::on_applyButton_clicked() { //only process things when we have valid inputs! - if(!hasValidInputs()) { - QMessageBox msg; - msg.setIcon(QMessageBox::Critical); - msg.setText(QString::fromAscii("There are input fields with incorrect input, please ensure valid placement values!")); - msg.exec(); - return; + if (!hasValidInputs()) { + QMessageBox msg; + msg.setIcon(QMessageBox::Critical); + msg.setText(tr("There are input fields with incorrect input, please ensure valid placement values!")); + msg.exec(); + return; } - + // If there are listeners to the 'placementChanged' signal we rely // on that the listener updates any placement. If no listeners // are connected the placement is applied to all selected objects diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index cccc19b63..7fbe75703 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -654,16 +654,16 @@ TYPESYSTEM_SOURCE(Gui::PropertyEditor::PropertyUnitConstraintItem, Gui::Property PropertyUnitConstraintItem::PropertyUnitConstraintItem() { - + } void PropertyUnitConstraintItem::setEditorData(QWidget *editor, const QVariant& data) const { const Base::Quantity& value = data.value(); - + Gui::InputField *infield = qobject_cast(editor); infield->setValue(value); - + const std::vector& items = getPropertyData(); App::PropertyQuantityConstraint* prop = (App::PropertyQuantityConstraint*)items[0]; @@ -966,9 +966,9 @@ QVariant PropertyVectorDistanceItem::toString(const QVariant& prop) const { const Base::Vector3d& value = prop.value(); QString data = QString::fromAscii("[") + - Base::Quantity(value.x, Base::Unit::Length).getUserString() + QString::fromAscii(" ") + - Base::Quantity(value.y, Base::Unit::Length).getUserString() + QString::fromAscii(" ") + - Base::Quantity(value.z, Base::Unit::Length).getUserString() + QString::fromAscii("]"); + Base::Quantity(value.x, Base::Unit::Length).getUserString() + QString::fromAscii(" ") + + Base::Quantity(value.y, Base::Unit::Length).getUserString() + QString::fromAscii(" ") + + Base::Quantity(value.z, Base::Unit::Length).getUserString() + QString::fromAscii("]"); return QVariant(data); } @@ -986,14 +986,14 @@ void PropertyVectorDistanceItem::setValue(const QVariant& variant) if (!variant.canConvert()) return; const Base::Vector3d& value = variant.value(); - + Base::Quantity q = Base::Quantity(value.x, Base::Unit::Length); QString unit = QString::fromLatin1("('%1 %2'").arg(q.getValue()).arg(q.getUnit().getString()); q = Base::Quantity(value.y, Base::Unit::Length); unit + QString::fromLatin1("'%1 %2'").arg(q.getValue()).arg(q.getUnit().getString()); q = Base::Quantity(value.z, Base::Unit::Length); QString::fromLatin1("'%1 %2')").arg(q.getValue()).arg(q.getUnit().getString()); - + setPropertyValue(unit); } diff --git a/src/Gui/propertyeditor/PropertyItem.h b/src/Gui/propertyeditor/PropertyItem.h index f8114960f..d18587dbe 100644 --- a/src/Gui/propertyeditor/PropertyItem.h +++ b/src/Gui/propertyeditor/PropertyItem.h @@ -373,13 +373,12 @@ class GuiExport PropertyVectorDistanceItem: public PropertyItem void setY(Base::Quantity y); Base::Quantity z() const; void setZ(Base::Quantity z); - + protected: virtual QVariant toString(const QVariant&) const; virtual QVariant value(const App::Property*) const; virtual void setValue(const QVariant&); - PropertyVectorDistanceItem(); private: