diff --git a/sources/conductorproperties.cpp b/sources/conductorproperties.cpp index 22d047a43..f33e6d07b 100644 --- a/sources/conductorproperties.cpp +++ b/sources/conductorproperties.cpp @@ -369,9 +369,9 @@ bool ConductorProperties::fromXml(const QDomElement &e) QMetaEnum me = QMetaEnum::fromType(); QString alinment_temp; - if (propertyString(e, "horizontal-alignment", &alinment_temp, "AlignBottom") == PropertyFlags::Success) + if (propertyString(e, "horizontal-alignment", &alinment_temp) == PropertyFlags::Success) m_horizontal_alignment = Qt::Alignment(me.keyToValue(alinment_temp.toStdString().data())); - if (propertyString(e, "vertical-alignment", &alinment_temp, "AlignRight") == PropertyFlags::Success) + if (propertyString(e, "vertical-alignment", &alinment_temp) == PropertyFlags::Success) m_vertical_alignment = Qt::Alignment(me.keyToValue(alinment_temp.toStdString().data())); return true; diff --git a/sources/editor/graphicspart/partarc.cpp b/sources/editor/graphicspart/partarc.cpp index 87a23a411..a9b083a3b 100644 --- a/sources/editor/graphicspart/partarc.cpp +++ b/sources/editor/graphicspart/partarc.cpp @@ -121,11 +121,11 @@ QDomElement PartArc::toXml(QDomDocument &xml_document) const { bool PartArc::fromXml(const QDomElement &qde) { stylesFromXml(qde); - double x, y, w, h; - if (propertyDouble(qde, "x", &x, true, 0) == PropertyFlags::NoValidConversion || - propertyDouble(qde, "y", &y, true, 0) == PropertyFlags::NoValidConversion || - propertyDouble(qde, "width", &w, true, 0) == PropertyFlags::NoValidConversion || - propertyDouble(qde, "height", &h, true, 0) == PropertyFlags::NoValidConversion) + double x=0, y=0, w=0, h=0; + if (propertyDouble(qde, "x", &x) == PropertyFlags::NoValidConversion || + propertyDouble(qde, "y", &y) == PropertyFlags::NoValidConversion || + propertyDouble(qde, "width", &w) == PropertyFlags::NoValidConversion || + propertyDouble(qde, "height", &h) == PropertyFlags::NoValidConversion) return false; m_rect = QRectF(mapFromScene(x, y), QSizeF(w, h) ); diff --git a/sources/editor/graphicspart/partdynamictextfield.cpp b/sources/editor/graphicspart/partdynamictextfield.cpp index b044d2a12..025baf5a1 100644 --- a/sources/editor/graphicspart/partdynamictextfield.cpp +++ b/sources/editor/graphicspart/partdynamictextfield.cpp @@ -186,8 +186,8 @@ bool PartDynamicTextField::fromXml(const QDomElement &dom_elmt) bool frame; propertyBool(dom_elmt, "frame", &frame); - double text_width; - propertyDouble(dom_elmt, "text_width", &text_width, true, -1); + double text_width=-1; + propertyDouble(dom_elmt, "text_width", &text_width); setTextWidth(text_width); QMetaEnum me = DynamicElementTextItem::textFromMetaEnum(); diff --git a/sources/editor/graphicspart/partellipse.cpp b/sources/editor/graphicspart/partellipse.cpp index f29358469..6163e241f 100644 --- a/sources/editor/graphicspart/partellipse.cpp +++ b/sources/editor/graphicspart/partellipse.cpp @@ -108,23 +108,23 @@ QDomElement PartEllipse::toXml(QDomDocument &xml_document) const bool PartEllipse::fromXml(const QDomElement &qde) { stylesFromXml(qde); - double x, y, width, height; + double x=0, y=0, width=0, height=0; if (qde.tagName() == "ellipse") { - if (propertyDouble(qde, "width", &width, true, 0) == PropertyFlags::NoValidConversion || - propertyDouble(qde, "height", &height, true, 0) == PropertyFlags::NoValidConversion) + if (propertyDouble(qde, "width", &width) == PropertyFlags::NoValidConversion || + propertyDouble(qde, "height", &height) == PropertyFlags::NoValidConversion) return false; } else { - if (propertyDouble(qde, "diameter", &width, true, 0) == PropertyFlags::NoValidConversion) + if (propertyDouble(qde, "diameter", &width) == PropertyFlags::NoValidConversion) return false; height = width; } - if (propertyDouble(qde, "x", &x, true, 0) == PropertyFlags::NoValidConversion || - propertyDouble(qde, "y", &y, true, 0) == PropertyFlags::NoValidConversion) + if (propertyDouble(qde, "x", &x) == PropertyFlags::NoValidConversion || + propertyDouble(qde, "y", &y) == PropertyFlags::NoValidConversion) return false; m_rect = QRectF(mapFromScene(x, y), QSizeF(width, height)); diff --git a/sources/editor/graphicspart/partrectangle.cpp b/sources/editor/graphicspart/partrectangle.cpp index 85c44032e..ce0ca222b 100644 --- a/sources/editor/graphicspart/partrectangle.cpp +++ b/sources/editor/graphicspart/partrectangle.cpp @@ -116,23 +116,23 @@ bool PartRectangle::fromXml(const QDomElement &qde) { stylesFromXml(qde); - double x, y, w, h, rx, ry; - if (propertyDouble(qde, "x", &x, true, 0) == PropertyFlags::NoValidConversion || - propertyDouble(qde, "y", &y, true, 0) == PropertyFlags::NoValidConversion) + double x=0, y=0, w=0, h=0, rx=0, ry=0; + if (propertyDouble(qde, "x", &x) == PropertyFlags::NoValidConversion || + propertyDouble(qde, "y", &y) == PropertyFlags::NoValidConversion) return false; setPos(mapFromScene(x, y)); - if (propertyDouble(qde, "width", &w, true, 0) == PropertyFlags::NoValidConversion || - propertyDouble(qde, "width", &h, true, 0) == PropertyFlags::NoValidConversion) + if (propertyDouble(qde, "width", &w) == PropertyFlags::NoValidConversion || + propertyDouble(qde, "width", &h) == PropertyFlags::NoValidConversion) return false; QRectF rect(QPointF(x,y), QSizeF(w, h)); setRect(rect.normalized()); - if (propertyDouble(qde, "rx", &rx, true, 0) == PropertyFlags::NoValidConversion || - propertyDouble(qde, "ry", &ry, true, 0) == PropertyFlags::NoValidConversion) + if (propertyDouble(qde, "rx", &rx) == PropertyFlags::NoValidConversion || + propertyDouble(qde, "ry", &ry) == PropertyFlags::NoValidConversion) return false; setXRadius(rx); diff --git a/sources/editor/graphicspart/parttext.cpp b/sources/editor/graphicspart/parttext.cpp index b76666b0b..dbaf3df39 100644 --- a/sources/editor/graphicspart/parttext.cpp +++ b/sources/editor/graphicspart/parttext.cpp @@ -87,13 +87,13 @@ bool PartText::fromXml(const QDomElement &xml_element) propertyString(xml_element, "text", &text); setPlainText(text); - double x, y, rot; - if (propertyDouble(xml_element, "x", &x, true, 0) == PropertyFlags::NoValidConversion || - propertyDouble(xml_element, "y", &y, true, 0) == PropertyFlags::NoValidConversion) + double x=0, y=0, rot=0; + if (propertyDouble(xml_element, "x", &x) == PropertyFlags::NoValidConversion || + propertyDouble(xml_element, "y", &y) == PropertyFlags::NoValidConversion) return false; setPos(x, y); - if (propertyDouble(xml_element, "rotation", &rot, true, 0) == PropertyFlags::NoValidConversion) + if (propertyDouble(xml_element, "rotation", &rot) == PropertyFlags::NoValidConversion) return false; setRotation(rot); diff --git a/sources/properties/propertiesinterface.cpp b/sources/properties/propertiesinterface.cpp index 7d96e8513..af8354a9c 100644 --- a/sources/properties/propertiesinterface.cpp +++ b/sources/properties/propertiesinterface.cpp @@ -150,13 +150,11 @@ bool PropertiesInterface::attribute(const QDomElement& e, const QString& attribu * \return True if reading an integer was successful, else False. If the attribute was not found, * \p entier is not valid and the return value is False */ -PropertiesInterface::PropertyFlags PropertiesInterface::propertyInteger(const QDomElement &e, const QString& attribute_name, int* entier, bool setDefaultValue, int defaultValue) { +PropertiesInterface::PropertyFlags PropertiesInterface::propertyInteger(const QDomElement &e, const QString& attribute_name, int* entier) { QString attr; if (!attribute(e, attribute_name, integerS, &attr)) { - if (entier && setDefaultValue) - *entier = defaultValue; return PropertyFlags::NotFound; } @@ -174,13 +172,11 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyInteger(const QD return PropertyFlags::Success; } -PropertiesInterface::PropertyFlags PropertiesInterface::propertyDouble(const QDomElement &e, const QString& attribute_name, double* reel, bool setDefaultValue, double defaultValue) { +PropertiesInterface::PropertyFlags PropertiesInterface::propertyDouble(const QDomElement &e, const QString& attribute_name, double* reel) { QString attr; if (!attribute(e, attribute_name, doubleS, &attr)) { - if (reel && setDefaultValue) - *reel = defaultValue; return PropertyFlags::NotFound; } @@ -198,13 +194,11 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyDouble(const QDo return PropertyFlags::Success; } -PropertiesInterface::PropertyFlags PropertiesInterface::propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean, bool setDefaultValue, bool defaultValue) { +PropertiesInterface::PropertyFlags PropertiesInterface::propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean) { QString attr; if (!attribute(e, attribute_name, boolS, &attr)) { - if (boolean && setDefaultValue) - *boolean = defaultValue; return PropertyFlags::NotFound; } @@ -228,13 +222,11 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyBool(const QDomE return PropertyFlags::Success; } -PropertiesInterface::PropertyFlags PropertiesInterface::propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color, bool setDefaultValue, QColor defaultValue) { +PropertiesInterface::PropertyFlags PropertiesInterface::propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color) { QString attr; if (!attribute(e, attribute_name, colorS, &attr)) { - if (color && setDefaultValue) - *color = defaultValue; return PropertyFlags::NotFound; } @@ -251,12 +243,10 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyColor(const QDom return PropertyFlags::Success; } -PropertiesInterface::PropertyFlags PropertiesInterface::propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid, bool setDefaultValue, QUuid defaultValue) { +PropertiesInterface::PropertyFlags PropertiesInterface::propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid) { QString attr; if (!attribute(e, attribute_name, uuidS, &attr)) { - if (uuid && setDefaultValue) - *uuid = defaultValue; return PropertyFlags::NotFound; } @@ -272,12 +262,10 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyUuid(const QDomE return PropertyFlags::Success; } -PropertiesInterface::PropertyFlags PropertiesInterface::propertyString(const QDomElement& e, const QString& attribute_name, QString* string, bool setDefaultValue, QString defaultValue) { +PropertiesInterface::PropertyFlags PropertiesInterface::propertyString(const QDomElement& e, const QString& attribute_name, QString* string) { QString attr; if (!attribute(e, attribute_name, stringS, &attr)) { - if (string && setDefaultValue) - *string = defaultValue; return PropertyFlags::NotFound; } diff --git a/sources/properties/propertiesinterface.h b/sources/properties/propertiesinterface.h index e75d5f43e..f02d9e24a 100644 --- a/sources/properties/propertiesinterface.h +++ b/sources/properties/propertiesinterface.h @@ -66,12 +66,12 @@ class PropertiesInterface /*! * Try not using the default Value feature. It is better to initialize the class members in the class definition! */ - static PropertyFlags propertyInteger(const QDomElement &e, const QString& attribute_name, int *entier = nullptr, bool setDefaultValue = false, int defaultValue = std::numeric_limits::quiet_NaN()); - static PropertyFlags propertyDouble(const QDomElement &e, const QString& attribute_name, double *reel = nullptr, bool setDefaultValue = false, double defaultValue = std::numeric_limits::quiet_NaN()); - static PropertyFlags propertyString(const QDomElement& e, const QString& attribute_name, QString* string = nullptr, bool setDefaultValue = false, QString defaultValue = QString()); - static PropertyFlags propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean = nullptr, bool setDefaultValue = false, bool defaultValue = false); - static PropertyFlags propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid = nullptr, bool setDefaultValue = false, QUuid defaultValue = QUuid()); - static PropertyFlags propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color = nullptr, bool setDefaultValue = false, QColor defaultValue = QColor()); + static PropertyFlags propertyInteger(const QDomElement &e, const QString& attribute_name, int *entier = nullptr); + static PropertyFlags propertyDouble(const QDomElement &e, const QString& attribute_name, double *reel = nullptr); + static PropertyFlags propertyString(const QDomElement& e, const QString& attribute_name, QString* string = nullptr); + static PropertyFlags propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean = nullptr); + static PropertyFlags propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid = nullptr); + static PropertyFlags propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color = nullptr); static bool validXmlProperty(const QDomElement& e); diff --git a/sources/qetgraphicsitem/conductor.cpp b/sources/qetgraphicsitem/conductor.cpp index 74a94ca16..d9cf0ba50 100644 --- a/sources/qetgraphicsitem/conductor.cpp +++ b/sources/qetgraphicsitem/conductor.cpp @@ -966,7 +966,7 @@ bool Conductor::fromXml(const QDomElement &dom_element) else m_autoNum_seq.fromXml(dom_element.firstChildElement("sequentialNumbers")); - propertyBool(dom_element, "freezeLabel", &m_freeze_label, false); + propertyBool(dom_element, "freezeLabel", &m_freeze_label); setProperties(pr); return return_; @@ -1022,7 +1022,7 @@ QDomElement Conductor::toXml(QDomDocument & doc) const { } } - QDomElement dom_seq = m_autoNum_seq.toXml(doc); + QDomElement dom_seq = m_autoNum_seq.toXml(doc); // swquentialNumbers tag dom_element.appendChild(dom_seq); // Export the properties and text