From 3a27371ba9afc471ad8f58dc4e58a16efef30d1a Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 26 Sep 2013 15:39:25 +0200 Subject: [PATCH] + Fix gcc build errors/improve whitespaces --- src/Base/Quantity.h | 5 ++-- src/Base/Reader.cpp | 3 ++- src/Gui/propertyeditor/PropertyItem.cpp | 32 +++++++++++-------------- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/Base/Quantity.h b/src/Base/Quantity.h index f1d566598d..724357a4da 100644 --- a/src/Base/Quantity.h +++ b/src/Base/Quantity.h @@ -54,8 +54,9 @@ public: Quantity pow(const Quantity&)const; //@} - /// transfer to user prefered unit/potence - double getUserPrefered(QString &unitString = QString())const; + /// transfer to user prefered unit/potence + double getUserPrefered() const { QString dummy; return getUserPrefered(dummy); } + double getUserPrefered(QString &unitString) const; std::string getUserString(void)const; static Quantity parse(const char* buffer); diff --git a/src/Base/Reader.cpp b/src/Base/Reader.cpp index f3d7b595e5..cc6d862010 100644 --- a/src/Base/Reader.cpp +++ b/src/Base/Reader.cpp @@ -304,7 +304,8 @@ void Base::XMLReader::readFiles(zipios::ZipInputStream &zipstream) const // no file name for the current entry in the zip was registered. if (jt != FileList.end()) { try { - jt->Object->RestoreDocFile(Base::Reader(zipstream,DocumentSchema)); + Base::Reader reader(zipstream,DocumentSchema); + jt->Object->RestoreDocFile(reader); } catch(...) { // For any exception we just continue with the next file. diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index 67516ff65d..a621da597d 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -651,11 +651,11 @@ QVariant PropertyUnitItem::toString(const QVariant& Value) const { double val = Value.toDouble(); - QString unit; + QString unit; const std::vector& prop = getPropertyData(); if (!prop.empty() && prop.front()->getTypeId().isDerivedFrom(App::PropertyQuantity::getClassTypeId())) { - Base::Quantity value = static_cast(prop.front())->getQuantityValue(); - value.getUserPrefered(unit); + Base::Quantity value = static_cast(prop.front())->getQuantityValue(); + value.getUserPrefered(unit); unit.prepend(QLatin1String(" ")); } @@ -663,14 +663,13 @@ QVariant PropertyUnitItem::toString(const QVariant& Value) const return QVariant(data); } + QVariant PropertyUnitItem::value(const App::Property* prop) const { - assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyQuantity::getClassTypeId())); - - Base::Quantity value = static_cast(prop)->getQuantityValue(); - - return QVariant(value.getUserPrefered()); - + assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyQuantity::getClassTypeId())); + Base::Quantity value = static_cast(prop)->getQuantityValue(); + QString unitString; + return QVariant(value.getUserPrefered(unitString)); } void PropertyUnitItem::setValue(const QVariant& value) @@ -679,19 +678,18 @@ void PropertyUnitItem::setValue(const QVariant& value) return; double val = value.toDouble(); - QString unit; + QString unit; const std::vector& prop = getPropertyData(); if (prop.empty()) return; else if (prop.front()->getTypeId().isDerivedFrom(App::PropertyQuantity::getClassTypeId())) { - Base::Quantity value = static_cast(prop.front())->getQuantityValue(); - value.getUserPrefered(unit); + Base::Quantity value = static_cast(prop.front())->getQuantityValue(); + value.getUserPrefered(unit); unit.prepend(QLatin1String(" ")); } QString data = QString::fromAscii("'%1%2'").arg(val,0,'f',decimals()).arg(unit); setPropertyValue(data); - } QWidget* PropertyUnitItem::createEditor(QWidget* parent, const QObject* receiver, const char* method) const @@ -701,7 +699,6 @@ QWidget* PropertyUnitItem::createEditor(QWidget* parent, const QObject* receiver sb->setDecimals(decimals()); QObject::connect(sb, SIGNAL(valueChanged(double)), receiver, method); return sb; - } void PropertyUnitItem::setEditorData(QWidget *editor, const QVariant& data) const @@ -713,9 +710,9 @@ void PropertyUnitItem::setEditorData(QWidget *editor, const QVariant& data) cons if (prop.empty()) return; else if (prop.front()->getTypeId().isDerivedFrom(App::PropertyQuantity::getClassTypeId())) { - Base::Quantity value = static_cast(prop.front())->getQuantityValue(); - QString unitString; - value.getUserPrefered(unitString); + Base::Quantity value = static_cast(prop.front())->getQuantityValue(); + QString unitString; + value.getUserPrefered(unitString); unitString.prepend(QLatin1String(" ")); sb->setSuffix(unitString); } @@ -725,7 +722,6 @@ QVariant PropertyUnitItem::editorData(QWidget *editor) const { QDoubleSpinBox *sb = qobject_cast(editor); return QVariant(sb->value()); - } // --------------------------------------------------------------------