diff --git a/sources/conductorproperties.cpp b/sources/conductorproperties.cpp index 8d8bb7178..22d047a43 100644 --- a/sources/conductorproperties.cpp +++ b/sources/conductorproperties.cpp @@ -327,19 +327,28 @@ bool ConductorProperties::fromXml(const QDomElement &e) propertyInteger(e, "dash-size", &m_dash_size); // read style of conductor - readStyle(e.attribute("style")); + QString style_string; + propertyString(e, "style", &style_string); + readStyle(style_string); QString type_t; - propertyString(e, "type", &type_t); - - if (type_t == typeToString(Single)) - { - // get specific properties for single conductor - singleLineProperties.fromXml(e); - type = Single; - } - else - type = Multi; + if (propertyString(e, "type", &type_t) == PropertyFlags::Success) { + if (type_t == typeToString(Single)) + { + // get specific properties for single conductor + singleLineProperties.fromXml(e); + type = Single; + } + else if (type_t == typeToString(Multi)) + type = Multi; + else { + //Keep retrocompatible with version older than 0,4 + //If the propertie @type is simple (removed since QET 0,4), we set text no visible. + //@TODO remove this code for qet 0.6 or later + + if (type_t == "simple") m_show_text = false; + } + } propertyString(e, "num", &text); @@ -360,17 +369,10 @@ bool ConductorProperties::fromXml(const QDomElement &e) QMetaEnum me = QMetaEnum::fromType(); QString alinment_temp; - lksjdflj - propertyString(e, "horizontal-alignment", &alinment_temp, "AlignBottom"); - m_horizontal_alignment = Qt::Alignment(me.keyToValue(alinment_temp.toStdString().data())); - propertyString(e, "vertical-alignment", &alinment_temp, "AlignRight"); - m_vertical_alignment = Qt::Alignment(me.keyToValue(alinment_temp.toStdString().data())); - - //Keep retrocompatible with version older than 0,4 - //If the propertie @type is simple (removed since QET 0,4), we set text no visible. - //@TODO remove this code for qet 0.6 or later - - if (type_t == "simple") m_show_text = false; + if (propertyString(e, "horizontal-alignment", &alinment_temp, "AlignBottom") == PropertyFlags::Success) + m_horizontal_alignment = Qt::Alignment(me.keyToValue(alinment_temp.toStdString().data())); + if (propertyString(e, "vertical-alignment", &alinment_temp, "AlignRight") == 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 4e1f26cb9..87a23a411 100644 --- a/sources/editor/graphicspart/partarc.cpp +++ b/sources/editor/graphicspart/partarc.cpp @@ -122,10 +122,10 @@ bool PartArc::fromXml(const QDomElement &qde) { stylesFromXml(qde); double x, y, w, h; - if (propertyDouble(qde, "x", &x, 0) == PropertyFlags::NoValidConversion || - propertyDouble(qde, "y", &y, 0) == PropertyFlags::NoValidConversion || - propertyDouble(qde, "width", &w, 0) == PropertyFlags::NoValidConversion || - propertyDouble(qde, "height", &h, 0) == PropertyFlags::NoValidConversion) + 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) return false; m_rect = QRectF(mapFromScene(x, y), QSizeF(w, h) ); diff --git a/sources/editor/graphicspart/partellipse.cpp b/sources/editor/graphicspart/partellipse.cpp index ffc75e073..f29358469 100644 --- a/sources/editor/graphicspart/partellipse.cpp +++ b/sources/editor/graphicspart/partellipse.cpp @@ -112,19 +112,19 @@ bool PartEllipse::fromXml(const QDomElement &qde) if (qde.tagName() == "ellipse") { - if (propertyDouble(qde, "width", &width, 0) == PropertyFlags::NoValidConversion || - propertyDouble(qde, "height", &height, 0) == PropertyFlags::NoValidConversion) + if (propertyDouble(qde, "width", &width, true, 0) == PropertyFlags::NoValidConversion || + propertyDouble(qde, "height", &height, true, 0) == PropertyFlags::NoValidConversion) return false; } else { - if (propertyDouble(qde, "diameter", &width, 0) == PropertyFlags::NoValidConversion) + if (propertyDouble(qde, "diameter", &width, true, 0) == PropertyFlags::NoValidConversion) return false; height = width; } - if (propertyDouble(qde, "x", &x, 0) == PropertyFlags::NoValidConversion || - propertyDouble(qde, "y", &y, 0) == PropertyFlags::NoValidConversion) + if (propertyDouble(qde, "x", &x, true, 0) == PropertyFlags::NoValidConversion || + propertyDouble(qde, "y", &y, true, 0) == PropertyFlags::NoValidConversion) return false; m_rect = QRectF(mapFromScene(x, y), QSizeF(width, height)); diff --git a/sources/editor/graphicspart/partline.cpp b/sources/editor/graphicspart/partline.cpp index d9a66b196..df7b41b71 100644 --- a/sources/editor/graphicspart/partline.cpp +++ b/sources/editor/graphicspart/partline.cpp @@ -151,9 +151,6 @@ bool PartLine::fromXml(const QDomElement &qde) { first_end = Qet::endTypeFromString(s); - first_length = 1.5; - second_length = 1.5; - if (propertyDouble(qde, "length1", &first_length) == PropertyFlags::NoValidConversion || propertyDouble(qde, "length2", &second_length) == PropertyFlags::NoValidConversion) return false; diff --git a/sources/editor/graphicspart/partline.h b/sources/editor/graphicspart/partline.h index 5e8ccf971..8b10de65a 100644 --- a/sources/editor/graphicspart/partline.h +++ b/sources/editor/graphicspart/partline.h @@ -118,10 +118,10 @@ class PartLine : public CustomElementGraphicPart /*****************/ Qet::EndType first_end; - qreal first_length; + qreal first_length{1.5}; Qet::EndType second_end; - qreal second_length; + qreal second_length{1.5}; QList saved_points_; QLineF m_line; int m_vector_index = -1; diff --git a/sources/editor/graphicspart/partrectangle.cpp b/sources/editor/graphicspart/partrectangle.cpp index 170068f00..85c44032e 100644 --- a/sources/editor/graphicspart/partrectangle.cpp +++ b/sources/editor/graphicspart/partrectangle.cpp @@ -117,22 +117,22 @@ bool PartRectangle::fromXml(const QDomElement &qde) stylesFromXml(qde); double x, y, w, h, rx, ry; - if (propertyDouble(qde, "x", &x, 0) == PropertyFlags::NoValidConversion || - propertyDouble(qde, "y", &y, 0) == PropertyFlags::NoValidConversion) + if (propertyDouble(qde, "x", &x, true, 0) == PropertyFlags::NoValidConversion || + propertyDouble(qde, "y", &y, true, 0) == PropertyFlags::NoValidConversion) return false; setPos(mapFromScene(x, y)); - if (propertyDouble(qde, "width", &w, 0) == PropertyFlags::NoValidConversion || - propertyDouble(qde, "width", &h, 0) == PropertyFlags::NoValidConversion) + if (propertyDouble(qde, "width", &w, true, 0) == PropertyFlags::NoValidConversion || + propertyDouble(qde, "width", &h, true, 0) == PropertyFlags::NoValidConversion) return false; - QRectF rect(QPointF(0,0), QSizeF(w, h)); + QRectF rect(QPointF(x,y), QSizeF(w, h)); setRect(rect.normalized()); - if (propertyDouble(qde, "rx", &rx, 0) == PropertyFlags::NoValidConversion || - propertyDouble(qde, "ry", &ry, 0) == PropertyFlags::NoValidConversion) + if (propertyDouble(qde, "rx", &rx, true, 0) == PropertyFlags::NoValidConversion || + propertyDouble(qde, "ry", &ry, true, 0) == PropertyFlags::NoValidConversion) return false; setXRadius(rx); diff --git a/sources/editor/graphicspart/partterminal.cpp b/sources/editor/graphicspart/partterminal.cpp index a957e6fa7..0d13c372f 100644 --- a/sources/editor/graphicspart/partterminal.cpp +++ b/sources/editor/graphicspart/partterminal.cpp @@ -49,8 +49,7 @@ bool PartTerminal::fromXml(const QDomElement &xml_elmt) { // update part and add uuid, which is used in the new version to connect terminals together // if the attribute not exists, means, the element is created with an older version of qet. So use the legacy approach // to identify terminals - if (propertyUuid(xml_elmt, "uuid", &uuid) == PropertyFlags::Success) - d->m_uuid = QUuid(uuid); + propertyUuid(xml_elmt, "uuid", &d->m_uuid); if (!d->fromXml(xml_elmt)) return false; diff --git a/sources/editor/graphicspart/parttext.cpp b/sources/editor/graphicspart/parttext.cpp index 6ba0eecbb..b76666b0b 100644 --- a/sources/editor/graphicspart/parttext.cpp +++ b/sources/editor/graphicspart/parttext.cpp @@ -78,22 +78,22 @@ bool PartText::fromXml(const QDomElement &xml_element) return false; } - QString color; + QColor color; QString text; - propertyString(xml_element, "color", &color, "#000000"); - setDefaultTextColor(QColor(color)); + propertyColor(xml_element, "color", &color); + setDefaultTextColor(color); propertyString(xml_element, "text", &text); setPlainText(text); double x, y, rot; - if (propertyDouble(xml_element, "x", &x, 0) == PropertyFlags::NoValidConversion || - propertyDouble(xml_element, "y", &y, 0) == PropertyFlags::NoValidConversion) + if (propertyDouble(xml_element, "x", &x, true, 0) == PropertyFlags::NoValidConversion || + propertyDouble(xml_element, "y", &y, true, 0) == PropertyFlags::NoValidConversion) return false; setPos(x, y); - if (propertyDouble(xml_element, "rotation", &rot, 0) == PropertyFlags::NoValidConversion) + if (propertyDouble(xml_element, "rotation", &rot, true, 0) == PropertyFlags::NoValidConversion) return false; setRotation(rot); diff --git a/sources/properties/propertiesinterface.h b/sources/properties/propertiesinterface.h index 1419598bf..e75d5f43e 100644 --- a/sources/properties/propertiesinterface.h +++ b/sources/properties/propertiesinterface.h @@ -56,7 +56,7 @@ class PropertiesInterface static QDomElement property(const QDomElement& e, const QString& name); static bool attribute(const QDomElement& e, const QString& attribute_name, const QString& type, QString* attr); - typedef enum PropertyFlags { + enum PropertyFlags { Success = 0, NotFound = 1, NoValidConversion = 2, diff --git a/sources/qetgraphicsitem/conductor.cpp b/sources/qetgraphicsitem/conductor.cpp index 64accc001..74a94ca16 100644 --- a/sources/qetgraphicsitem/conductor.cpp +++ b/sources/qetgraphicsitem/conductor.cpp @@ -949,10 +949,9 @@ void Conductor::pointsToSegments(const QList& points_list) { bool Conductor::fromXml(const QDomElement &dom_element) { // TODO: seems to short! - double x, y; + double x=0, y=0; propertyDouble(dom_element, "x", &x); propertyDouble(dom_element, "y", &y); - setPos(x, y); bool return_ = pathFromXml(dom_element); diff --git a/sources/titleblockproperties.cpp b/sources/titleblockproperties.cpp index 4f60b2668..021029f54 100644 --- a/sources/titleblockproperties.cpp +++ b/sources/titleblockproperties.cpp @@ -96,6 +96,7 @@ void TitleBlockProperties::toXml(QDomElement &e) const { } QDomElement TitleBlockProperties::toXml(QDomDocument &d) const { + Q_UNUSED(d) qDebug() << "NOT IMPLEMENTED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"; return QDomElement(); } @@ -126,10 +127,10 @@ bool TitleBlockProperties::fromXml(const QDomElement &e) { display_at = (display_at_temp == "bottom" ? Qt::BottomEdge : Qt::RightEdge); // otherwise it gets default in header file // reads the template used to render the title block - if (propertyString(e, "titleblocktemplate", &template_name)) { + if (propertyString(e, "titleblocktemplate", &template_name) == PropertyFlags::Success) { QString tbc; - propertyString(e, "titleblocktemplateCollection", &tbc); - collection = QET::qetCollectionFromString(tbc); + if (propertyString(e, "titleblocktemplateCollection", &tbc) == PropertyFlags::Success) + collection = QET::qetCollectionFromString(tbc); } // reads the additional fields used to fill the title block