mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-22 17:50:52 +01:00
move all static xml functions to qetxml
This commit is contained in:
@@ -31,6 +31,8 @@
|
||||
#include "element.h"
|
||||
#include "../QetGraphicsItemModeler/qetgraphicshandleritem.h"
|
||||
|
||||
#include "../qetxml.h"
|
||||
|
||||
#include <QMultiHash>
|
||||
#include <QtDebug>
|
||||
|
||||
@@ -583,11 +585,11 @@ ConductorTextItem *Conductor::textItem() const
|
||||
bool Conductor::valideXml(QDomElement &e){
|
||||
|
||||
// // TODO: seems to short! (see fromXML)
|
||||
// if (propertyDouble(e, "x") ||
|
||||
// propertyDouble(e, "y"))
|
||||
// if (QETXML::propertyDouble(e, "x") ||
|
||||
// QETXML::propertyDouble(e, "y"))
|
||||
// return false;
|
||||
|
||||
// if (propertyBool(e, "freezeLabel"))
|
||||
// if (QETXML::propertyBool(e, "freezeLabel"))
|
||||
// return false;
|
||||
|
||||
return true;
|
||||
@@ -967,8 +969,8 @@ bool Conductor::fromXmlPriv(const QDomElement &dom_element)
|
||||
{
|
||||
// TODO: seems to short!
|
||||
double x=0, y=0;
|
||||
propertyDouble(dom_element, "x", &x);
|
||||
propertyDouble(dom_element, "y", &y);
|
||||
QETXML::propertyDouble(dom_element, "x", &x);
|
||||
QETXML::propertyDouble(dom_element, "y", &y);
|
||||
setPos(x, y);
|
||||
|
||||
bool return_ = pathFromXml(dom_element);
|
||||
@@ -983,7 +985,7 @@ bool Conductor::fromXmlPriv(const QDomElement &dom_element)
|
||||
else
|
||||
m_autoNum_seq.fromXml(dom_element.firstChildElement("sequentialNumbers"));
|
||||
|
||||
propertyBool(dom_element, "freezeLabel", &m_freeze_label);
|
||||
QETXML::propertyBool(dom_element, "freezeLabel", &m_freeze_label);
|
||||
setProperties(pr);
|
||||
|
||||
return return_;
|
||||
@@ -1002,8 +1004,8 @@ bool Conductor::fromXmlPriv(const QDomElement &dom_element)
|
||||
*/
|
||||
void Conductor::toXmlPriv(QDomElement& e) const {
|
||||
|
||||
e.appendChild(createXmlProperty("x", pos().x()));
|
||||
e.appendChild(createXmlProperty("y", pos().y()));
|
||||
e.appendChild(QETXML::createXmlProperty("x", pos().x()));
|
||||
e.appendChild(QETXML::createXmlProperty("y", pos().y()));
|
||||
|
||||
// Terminal is uniquely identified by the uuid of the terminal and the element
|
||||
QUuid terminal = terminal1->uuid();
|
||||
@@ -1012,10 +1014,10 @@ void Conductor::toXmlPriv(QDomElement& e) const {
|
||||
// legacy when the terminal does not have a valid uuid
|
||||
// do not store element1 information, because this is used to determine in the fromXml
|
||||
// process that legacy file format
|
||||
e.appendChild(createXmlProperty("terminal1", terminal1->ID()));
|
||||
e.appendChild(QETXML::createXmlProperty("terminal1", terminal1->ID()));
|
||||
} else {
|
||||
e.appendChild(createXmlProperty("element1", terminalParent));
|
||||
e.appendChild(createXmlProperty("terminal1", terminal));
|
||||
e.appendChild(QETXML::createXmlProperty("element1", terminalParent));
|
||||
e.appendChild(QETXML::createXmlProperty("terminal1", terminal));
|
||||
}
|
||||
|
||||
terminal = terminal2->uuid();
|
||||
@@ -1024,13 +1026,13 @@ void Conductor::toXmlPriv(QDomElement& e) const {
|
||||
// legacy when the terminal does not have a valid uuid
|
||||
// do not store element1 information, because this is used to determine in the fromXml
|
||||
// process that legacy file format
|
||||
e.appendChild(createXmlProperty("terminal2", terminal2->ID()));
|
||||
e.appendChild(QETXML::createXmlProperty("terminal2", terminal2->ID()));
|
||||
} else {
|
||||
e.appendChild(createXmlProperty("element2", terminal2->parentElement()->uuid()));
|
||||
e.appendChild(createXmlProperty("terminal2", terminal2->uuid()));
|
||||
e.appendChild(QETXML::createXmlProperty("element2", terminal2->parentElement()->uuid()));
|
||||
e.appendChild(QETXML::createXmlProperty("terminal2", terminal2->uuid()));
|
||||
}
|
||||
|
||||
e.appendChild(createXmlProperty("freezeLabel", m_freeze_label));
|
||||
e.appendChild(QETXML::createXmlProperty("freezeLabel", m_freeze_label));
|
||||
|
||||
QDomDocument doc;
|
||||
|
||||
@@ -1043,8 +1045,8 @@ void Conductor::toXmlPriv(QDomElement& e) const {
|
||||
foreach(ConductorSegment *segment, segmentsList())
|
||||
{
|
||||
current_segment = doc.createElement("segment");
|
||||
current_segment.appendChild(createXmlProperty("orientation", segment->isHorizontal() ? "horizontal": "vertical"));
|
||||
current_segment.appendChild(createXmlProperty("length", segment -> length()));
|
||||
current_segment.appendChild(QETXML::createXmlProperty("orientation", segment->isHorizontal() ? "horizontal": "vertical"));
|
||||
current_segment.appendChild(QETXML::createXmlProperty("length", segment -> length()));
|
||||
e.appendChild(current_segment);
|
||||
}
|
||||
}
|
||||
@@ -1138,12 +1140,12 @@ bool Conductor::pathFromXml(const QDomElement &e) {
|
||||
|
||||
// le segment doit avoir une longueur
|
||||
qreal segment_length;
|
||||
if (propertyDouble(current_segment, "length", & segment_length))
|
||||
if (QETXML::propertyDouble(current_segment, "length", & segment_length))
|
||||
continue;
|
||||
|
||||
bool isHorizontal = false;
|
||||
QString orientation;
|
||||
if (propertyString(current_segment, "orientation", &orientation) == PropertyFlags::Success) {
|
||||
if (QETXML::propertyString(current_segment, "orientation", &orientation) == QETXML::PropertyFlags::Success) {
|
||||
if (orientation == "horizontal")
|
||||
isHorizontal = true;
|
||||
} else {
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "../diagramcommands.h"
|
||||
#include "../qetgraphicsitem/conductor.h"
|
||||
|
||||
#include "../qetxml.h"
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@param parent_conductor Conducteur auquel ce texte est rattache
|
||||
@@ -64,11 +66,11 @@ Conductor *ConductorTextItem::parentConductor() const
|
||||
void ConductorTextItem::toXml(QDomElement& e) {
|
||||
if(moved_by_user_)
|
||||
{
|
||||
e.appendChild(PropertiesInterface::createXmlProperty("userx", pos().x()));
|
||||
e.appendChild(PropertiesInterface::createXmlProperty("usery", pos().y()));
|
||||
e.appendChild(QETXML::createXmlProperty("userx", pos().x()));
|
||||
e.appendChild(QETXML::createXmlProperty("usery", pos().y()));
|
||||
}
|
||||
if(rotate_by_user_)
|
||||
e.appendChild(PropertiesInterface::createXmlProperty("rotation", rotation()));
|
||||
e.appendChild(QETXML::createXmlProperty("rotation", rotation()));
|
||||
}
|
||||
|
||||
|
||||
@@ -80,14 +82,14 @@ void ConductorTextItem::toXml(QDomElement& e) {
|
||||
void ConductorTextItem::fromXml(const QDomElement &e) {
|
||||
|
||||
double userx=0, usery=0;
|
||||
if (PropertiesInterface::propertyDouble(e, "userx", &userx) == PropertiesInterface::PropertyFlags::Success &&
|
||||
PropertiesInterface::propertyDouble(e, "usery", &usery) == PropertiesInterface::PropertyFlags::Success) {
|
||||
if (QETXML::propertyDouble(e, "userx", &userx) == QETXML::PropertyFlags::Success &&
|
||||
QETXML::propertyDouble(e, "usery", &usery) == QETXML::PropertyFlags::Success) {
|
||||
setPos(userx, usery);
|
||||
moved_by_user_ = true;
|
||||
}
|
||||
|
||||
double rotation;
|
||||
if (PropertiesInterface::propertyDouble(e, "rotation", &rotation) == PropertiesInterface::PropertyFlags::Success) {
|
||||
if (QETXML::propertyDouble(e, "rotation", &rotation) == QETXML::PropertyFlags::Success) {
|
||||
setRotation(rotation);
|
||||
rotate_by_user_ = true;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "../qetgraphicsitem/element.h"
|
||||
#include "conductortextitem.h"
|
||||
|
||||
#include "../qetxml.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
QColor Terminal::neutralColor = QColor(Qt::blue);
|
||||
@@ -758,8 +760,8 @@ QList<Conductor *> Terminal::conductors() const
|
||||
*/
|
||||
void Terminal::toXmlPriv(QDomElement &qdo) const
|
||||
{
|
||||
qdo.appendChild(createXmlProperty("number", number_terminal_));
|
||||
qdo.appendChild(createXmlProperty("nameHidden", name_terminal_hidden));
|
||||
qdo.appendChild(QETXML::createXmlProperty("number", number_terminal_));
|
||||
qdo.appendChild(QETXML::createXmlProperty("nameHidden", name_terminal_hidden));
|
||||
|
||||
// Do not store terminal data in its own child
|
||||
// Bad hack. The problem is that in the diagrams the terminal is described by the position and in the Collection by the dock.
|
||||
@@ -780,10 +782,10 @@ bool Terminal::valideXml(const QDomElement &terminal)
|
||||
if (terminal.tagName() != "terminal") return(false);
|
||||
|
||||
// affuteuse_250h.qet contains in line 8398 terminals which do not have this
|
||||
// if (propertyString(terminal, "number"))
|
||||
// if (QETXML::propertyString(terminal, "number"))
|
||||
// return false;
|
||||
// affuteuse_250h.qet contains in line 8398 terminals which do not have this
|
||||
// if (propertyBool(terminal, "nameHidden"))
|
||||
// if (QETXML::propertyBool(terminal, "nameHidden"))
|
||||
// return false;
|
||||
|
||||
if (!TerminalData::valideXml(terminal))
|
||||
@@ -802,9 +804,9 @@ bool Terminal::valideXml(const QDomElement &terminal)
|
||||
(memes coordonnes, meme orientation), false sinon
|
||||
*/
|
||||
bool Terminal::fromXmlPriv(const QDomElement &terminal) {
|
||||
propertyString(terminal, "number", &number_terminal_);
|
||||
QETXML::propertyString(terminal, "number", &number_terminal_);
|
||||
|
||||
propertyBool(terminal, "nameHidden", &name_terminal_hidden);
|
||||
QETXML::propertyBool(terminal, "nameHidden", &name_terminal_hidden);
|
||||
|
||||
if(!d->fromXml(terminal))
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user