mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 16:20:52 +01:00
let conductor textitem export to xml, because the read is also made from it
This commit is contained in:
@@ -1032,13 +1032,7 @@ QDomElement Conductor::toXml(QDomDocument & doc) const {
|
|||||||
dom_element.appendChild(node);
|
dom_element.appendChild(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_text_item->wasMovedByUser())
|
m_text_item->toXml(doc, dom_element);
|
||||||
{
|
|
||||||
dom_element.appendChild(createXmlProperty(doc, "userx", m_text_item->pos().x()));
|
|
||||||
dom_element.appendChild(createXmlProperty(doc, "usery", m_text_item->pos().y()));
|
|
||||||
}
|
|
||||||
if(m_text_item->wasRotateByUser())
|
|
||||||
dom_element.appendChild(createXmlProperty(doc, "rotation", m_text_item->rotation()));
|
|
||||||
|
|
||||||
return(dom_element);
|
return(dom_element);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,9 +27,7 @@
|
|||||||
*/
|
*/
|
||||||
ConductorTextItem::ConductorTextItem(Conductor *parent_conductor) :
|
ConductorTextItem::ConductorTextItem(Conductor *parent_conductor) :
|
||||||
DiagramTextItem(parent_conductor),
|
DiagramTextItem(parent_conductor),
|
||||||
parent_conductor_(parent_conductor),
|
parent_conductor_(parent_conductor)
|
||||||
moved_by_user_(false),
|
|
||||||
rotate_by_user_(false)
|
|
||||||
{
|
{
|
||||||
setAcceptHoverEvents(true);
|
setAcceptHoverEvents(true);
|
||||||
}
|
}
|
||||||
@@ -61,19 +59,34 @@ Conductor *ConductorTextItem::parentConductor() const {
|
|||||||
return(parent_conductor_);
|
return(parent_conductor_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConductorTextItem::toXml(QDomDocument& doc, QDomElement& e) {
|
||||||
|
if(moved_by_user_)
|
||||||
|
{
|
||||||
|
e.appendChild(PropertiesInterface::createXmlProperty(doc, "userx", pos().x()));
|
||||||
|
e.appendChild(PropertiesInterface::createXmlProperty(doc, "usery", pos().y()));
|
||||||
|
}
|
||||||
|
if(rotate_by_user_)
|
||||||
|
e.appendChild(PropertiesInterface::createXmlProperty(doc, "rotation", rotation()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ConductorTextItem::fromXml
|
* @brief ConductorTextItem::fromXml
|
||||||
* Read the properties stored in the xml element given in parameter
|
* Read the properties stored in the xml element given in parameter
|
||||||
* @param e
|
* @param e
|
||||||
*/
|
*/
|
||||||
void ConductorTextItem::fromXml(const QDomElement &e) {
|
void ConductorTextItem::fromXml(const QDomElement &e) {
|
||||||
if (e.hasAttribute("userx")) {
|
|
||||||
setPos(e.attribute("userx").toDouble(),
|
double userx=0, usery=0;
|
||||||
e.attribute("usery").toDouble());
|
if (PropertiesInterface::propertyDouble(e, "userx", &userx) == PropertiesInterface::PropertyFlags::Success &&
|
||||||
|
PropertiesInterface::propertyDouble(e, "usery", &usery) == PropertiesInterface::PropertyFlags::Success) {
|
||||||
|
setPos(userx, usery);
|
||||||
moved_by_user_ = true;
|
moved_by_user_ = true;
|
||||||
}
|
}
|
||||||
if (e.hasAttribute("rotation")) {
|
|
||||||
setRotation(e.attribute("rotation").toDouble());
|
double rotation;
|
||||||
|
if (PropertiesInterface::propertyDouble(e, "rotation", &rotation) == PropertiesInterface::PropertyFlags::Success) {
|
||||||
|
setRotation(rotation);
|
||||||
rotate_by_user_ = true;
|
rotate_by_user_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ class ConductorTextItem : public DiagramTextItem
|
|||||||
enum { Type = UserType + 1006 };
|
enum { Type = UserType + 1006 };
|
||||||
Conductor *parentConductor() const;
|
Conductor *parentConductor() const;
|
||||||
void fromXml(const QDomElement &) override;
|
void fromXml(const QDomElement &) override;
|
||||||
|
void toXml(QDomDocument& doc, QDomElement& e);
|
||||||
int type() const override { return Type; }
|
int type() const override { return Type; }
|
||||||
virtual bool wasMovedByUser() const;
|
virtual bool wasMovedByUser() const;
|
||||||
virtual bool wasRotateByUser() const;
|
virtual bool wasRotateByUser() const;
|
||||||
@@ -61,8 +62,8 @@ class ConductorTextItem : public DiagramTextItem
|
|||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
Conductor *parent_conductor_;
|
Conductor *parent_conductor_;
|
||||||
bool moved_by_user_;
|
bool moved_by_user_{false};
|
||||||
bool rotate_by_user_;
|
bool rotate_by_user_{false};
|
||||||
QPointF before_mov_pos_;
|
QPointF before_mov_pos_;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user