Fix issues

This commit is contained in:
Martin Marmsoler
2020-10-07 08:05:01 +02:00
parent b958848194
commit a1cf3711a1
11 changed files with 55 additions and 57 deletions

View File

@@ -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 (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 == typeToString(Single))
{
// get specific properties for single conductor
singleLineProperties.fromXml(e);
type = Single;
}
else
type = Multi;
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<Qt::Alignment>();
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;
}

View File

@@ -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) );

View File

@@ -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));

View File

@@ -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;

View File

@@ -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<QPointF> saved_points_;
QLineF m_line;
int m_vector_index = -1;

View File

@@ -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);

View File

@@ -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;

View File

@@ -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);

View File

@@ -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,

View File

@@ -949,10 +949,9 @@ void Conductor::pointsToSegments(const QList<QPointF>& 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);

View File

@@ -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