mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-02-16 06:49:57 +01:00
go on with the work
This commit is contained in:
@@ -141,6 +141,18 @@ bool PartArc::fromXml(const QDomElement &qde) {
|
||||
m_span_angle *= 16;
|
||||
}
|
||||
|
||||
bool PartArc::valideXml(QDomElement& element) {
|
||||
|
||||
if (propertyDouble(element, "x") == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(element, "y") == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(element, "width") == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(element, "height") == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(element, "start") == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(element, "angle") == PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PartArc::shape
|
||||
* @return the shape of this item
|
||||
|
||||
@@ -53,6 +53,7 @@ class PartArc : public AbstractPartEllipse
|
||||
QString xmlName() const override { return(QString("arc")); }
|
||||
QDomElement toXml (QDomDocument &) const override;
|
||||
bool fromXml (const QDomElement &) override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
|
||||
QPainterPath shape() const override;
|
||||
QPainterPath shadowShape() const override;
|
||||
|
||||
@@ -183,12 +183,17 @@ bool PartDynamicTextField::fromXml(const QDomElement &dom_elmt)
|
||||
}
|
||||
|
||||
propertyUuid(dom_elmt, "uuid", &m_uuid, QUuid::createUuid());
|
||||
m_uuid = QUuid(dom_elmt.attribute("uuid", QUuid::createUuid().toString()));
|
||||
setFrame(dom_elmt.attribute("frame", "false") == "true"? true : false);
|
||||
setTextWidth(dom_elmt.attribute("text_width", QString::number(-1)).toDouble());
|
||||
bool frame;
|
||||
propertyBool(dom_elmt, "frame", &frame);
|
||||
|
||||
double text_width;
|
||||
propertyDouble(dom_elmt, "text_width", &text_width, -1);
|
||||
setTextWidth(text_width);
|
||||
|
||||
QMetaEnum me = DynamicElementTextItem::textFromMetaEnum();
|
||||
m_text_from = DynamicElementTextItem::TextFrom(me.keyToValue(dom_elmt.attribute("text_from").toStdString().data()));
|
||||
QString text_from;
|
||||
propertyString(dom_elmt, "text_from", &text_from);
|
||||
m_text_from = DynamicElementTextItem::TextFrom(me.keyToValue(text_from.toStdString().data()));
|
||||
|
||||
me = QMetaEnum::fromType<Qt::Alignment>();
|
||||
QString alignment;
|
||||
@@ -223,6 +228,27 @@ bool PartDynamicTextField::fromXml(const QDomElement &dom_elmt)
|
||||
setColor(QColor(dom_color.text()));
|
||||
}
|
||||
|
||||
bool PartDynamicTextField::valideXml(QDomElement& dom_elmt) {
|
||||
if (propertyDouble(dom_elmt, "x") == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(dom_elmt, "y") == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(dom_elmt, "z") == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(dom_elmt, "rotation") == PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
|
||||
if (propertyUuid(dom_elmt, "uuid") == PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
|
||||
if (propertyString(dom_elmt, "text_from"))
|
||||
return false;
|
||||
|
||||
if(propertyString(dom_elmt, "Halignment") == PropertyFlags::NotFound)
|
||||
return false;
|
||||
if(propertyString(dom_elmt, "Valignment") == PropertyFlags::NotFound)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PartDynamicTextField::fromTextFieldXml
|
||||
* Setup this text from the xml definition of a text field (The xml tagg of a text field is "input");
|
||||
|
||||
@@ -77,6 +77,7 @@ class PartDynamicTextField : public QGraphicsTextItem, public CustomElementPart
|
||||
QDomElement toXml(QDomDocument &dom_doc) const override;
|
||||
bool fromXml(const QDomElement &dom_elmt) override;
|
||||
void fromTextFieldXml(const QDomElement &dom_element);
|
||||
static bool valideXml(QDomElement& dom_elmt);
|
||||
|
||||
DynamicElementTextItem::TextFrom textFrom() const;
|
||||
void setTextFrom (DynamicElementTextItem::TextFrom text_from);
|
||||
|
||||
@@ -132,6 +132,26 @@ bool PartEllipse::fromXml(const QDomElement &qde)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PartEllipse::valideXml(QDomElement& element) {
|
||||
if (element.tagName() == "ellipse")
|
||||
{
|
||||
if (propertyDouble(element, "width") & PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(element, "height") & PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
if (propertyDouble(element, "diameter") & PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if ((propertyDouble(element, "x") & PropertyFlags::NoValidConversion) ||
|
||||
(propertyDouble(element, "y") & PropertyFlags::NoValidConversion))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PartEllipse::shape
|
||||
* @return the shape of this item
|
||||
|
||||
@@ -54,6 +54,7 @@ class PartEllipse : public AbstractPartEllipse
|
||||
QString xmlName() const override { return(QString("ellipse")); }
|
||||
QDomElement toXml (QDomDocument &) const override;
|
||||
bool fromXml (const QDomElement &) override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
QPainterPath shape() const override;
|
||||
QPainterPath shadowShape() const override;
|
||||
void setRect(const QRectF &rect) override {AbstractPartEllipse::setRect(rect); adjusteHandlerPos();}
|
||||
|
||||
@@ -161,6 +161,20 @@ bool PartLine::fromXml(const QDomElement &qde) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PartLine::valideXml(QDomElement& element) const {
|
||||
if (propertyDouble(element, "x1") ||
|
||||
propertyDouble(element, "y1") ||
|
||||
propertyDouble(element, "x2") ||
|
||||
propertyDouble(element, "y2") ||
|
||||
propertyString(element, "end1") ||
|
||||
propertyString(element, "end2") ||
|
||||
propertyDouble(element, "length1") ||
|
||||
propertyDouble(element, "length2") )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PartLine::itemChange
|
||||
* @param change
|
||||
|
||||
@@ -72,6 +72,7 @@ class PartLine : public CustomElementGraphicPart
|
||||
QString xmlName() const override { return(QString("line")); }
|
||||
QDomElement toXml(QDomDocument &) const override;
|
||||
bool fromXml(const QDomElement &) override;
|
||||
bool valideXml(QDomElement& element) const;
|
||||
virtual QPointF sceneP1() const;
|
||||
virtual QPointF sceneP2() const;
|
||||
QPainterPath shape() const override;
|
||||
|
||||
@@ -138,6 +138,11 @@ QDomElement PartPolygon::toXml(QDomDocument &xml_document) const
|
||||
return(xml_element);
|
||||
}
|
||||
|
||||
bool PartPolygon::valideXml(QDomElement& element) {
|
||||
// TODO: implement
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PartPolygon::isUseless
|
||||
* @return true if this part is irrelevant and does not deserve to be Retained / registered.
|
||||
|
||||
@@ -63,6 +63,8 @@ class PartPolygon : public CustomElementGraphicPart
|
||||
QString xmlName() const override { return(QString("polygon")); }
|
||||
bool fromXml(const QDomElement &) override;
|
||||
QDomElement toXml(QDomDocument &) const override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
|
||||
|
||||
QPainterPath shape () const override;
|
||||
QPainterPath shadowShape() const override;
|
||||
|
||||
@@ -141,6 +141,18 @@ bool PartRectangle::fromXml(const QDomElement &qde)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PartRectangle::valideXml(QDomElement& element) {
|
||||
// parameters have default values so no value is not a non valid xml element
|
||||
if ((propertyDouble(element, "x") & PropertyFlags::NoValidConversion) |
|
||||
(propertyDouble(element, "y") & PropertyFlags::NoValidConversion) |
|
||||
(propertyDouble(element, "width") & PropertyFlags::NoValidConversion) |
|
||||
(propertyDouble(element, "width") & PropertyFlags::NoValidConversion) |
|
||||
(propertyDouble(element, "rx") & PropertyFlags::NoValidConversion) |
|
||||
(propertyDouble(element, "ry") & PropertyFlags::NoValidConversion))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PartRectangle::rect
|
||||
* @return : Returns the item's rectangle.
|
||||
|
||||
@@ -62,6 +62,7 @@ class PartRectangle : public CustomElementGraphicPart
|
||||
QString xmlName () const override { return(QString("rect")); }
|
||||
QDomElement toXml (QDomDocument &) const override;
|
||||
bool fromXml (const QDomElement &) override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
|
||||
QRectF rect() const;
|
||||
void setRect(const QRectF &rect);
|
||||
|
||||
@@ -61,6 +61,10 @@ QDomElement PartTerminal::toXml(QDomDocument &xml_document) const {
|
||||
return d->toXml(xml_document);
|
||||
}
|
||||
|
||||
bool PartTerminal::valideXml(QDomElement& element) {
|
||||
return TerminalData::valideXml(element);
|
||||
}
|
||||
|
||||
/**
|
||||
Dessine la borne
|
||||
@param p QPainter a utiliser pour rendre le dessin
|
||||
|
||||
@@ -59,6 +59,8 @@ class PartTerminal : public CustomElementGraphicPart
|
||||
QString xmlName() const override { return(QString("terminal")); }
|
||||
bool fromXml(const QDomElement &) override;
|
||||
QDomElement toXml(QDomDocument &) const override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
|
||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override;
|
||||
|
||||
QPainterPath shape() const override;
|
||||
|
||||
@@ -119,6 +119,30 @@ QDomElement PartText::toXml(QDomDocument &xml_document) const
|
||||
return(xml_element);
|
||||
}
|
||||
|
||||
bool PartText::valideXml(QDomElement& element) {
|
||||
|
||||
if (propertyInteger(element, "size") == PropertyFlags::NotFound ||
|
||||
propertyString(element, "font") == PropertyFlags::NotFound) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (propertyString(element, "color") == PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
|
||||
|
||||
if (propertyString(element, "text"))
|
||||
return false;
|
||||
|
||||
if (propertyDouble(element, "x") == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(element, "y") == PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
|
||||
if (propertyDouble(element, "rotation", 0) == PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@return Les coordonnees du point situe en bas a gauche du texte.
|
||||
*/
|
||||
|
||||
@@ -60,6 +60,7 @@ class PartText : public QGraphicsTextItem, public CustomElementPart
|
||||
QString name() const override { return(QObject::tr("texte", "element part name")); }
|
||||
QString xmlName() const override { return(QString("text")); }
|
||||
bool fromXml(const QDomElement &) override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
QDomElement toXml(QDomDocument &) const override;
|
||||
void setRotation(qreal angle) {(QGraphicsObject::setRotation(QET::correctAngle(angle)));}
|
||||
bool isUseless() const override;
|
||||
|
||||
Reference in New Issue
Block a user