mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +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);
|
||||
}
|
||||
|
||||
if(m_text_item->wasMovedByUser())
|
||||
{
|
||||
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()));
|
||||
m_text_item->toXml(doc, dom_element);
|
||||
|
||||
return(dom_element);
|
||||
}
|
||||
|
||||
@@ -27,9 +27,7 @@
|
||||
*/
|
||||
ConductorTextItem::ConductorTextItem(Conductor *parent_conductor) :
|
||||
DiagramTextItem(parent_conductor),
|
||||
parent_conductor_(parent_conductor),
|
||||
moved_by_user_(false),
|
||||
rotate_by_user_(false)
|
||||
parent_conductor_(parent_conductor)
|
||||
{
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
@@ -61,21 +59,36 @@ Conductor *ConductorTextItem::parentConductor() const {
|
||||
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
|
||||
* Read the properties stored in the xml element given in parameter
|
||||
* @param e
|
||||
*/
|
||||
void ConductorTextItem::fromXml(const QDomElement &e) {
|
||||
if (e.hasAttribute("userx")) {
|
||||
setPos(e.attribute("userx").toDouble(),
|
||||
e.attribute("usery").toDouble());
|
||||
moved_by_user_ = true;
|
||||
}
|
||||
if (e.hasAttribute("rotation")) {
|
||||
setRotation(e.attribute("rotation").toDouble());
|
||||
rotate_by_user_ = true;
|
||||
}
|
||||
|
||||
double userx=0, usery=0;
|
||||
if (PropertiesInterface::propertyDouble(e, "userx", &userx) == PropertiesInterface::PropertyFlags::Success &&
|
||||
PropertiesInterface::propertyDouble(e, "usery", &usery) == PropertiesInterface::PropertyFlags::Success) {
|
||||
setPos(userx, usery);
|
||||
moved_by_user_ = true;
|
||||
}
|
||||
|
||||
double rotation;
|
||||
if (PropertiesInterface::propertyDouble(e, "rotation", &rotation) == PropertiesInterface::PropertyFlags::Success) {
|
||||
setRotation(rotation);
|
||||
rotate_by_user_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,6 +42,7 @@ class ConductorTextItem : public DiagramTextItem
|
||||
enum { Type = UserType + 1006 };
|
||||
Conductor *parentConductor() const;
|
||||
void fromXml(const QDomElement &) override;
|
||||
void toXml(QDomDocument& doc, QDomElement& e);
|
||||
int type() const override { return Type; }
|
||||
virtual bool wasMovedByUser() const;
|
||||
virtual bool wasRotateByUser() const;
|
||||
@@ -61,8 +62,8 @@ class ConductorTextItem : public DiagramTextItem
|
||||
// attributes
|
||||
private:
|
||||
Conductor *parent_conductor_;
|
||||
bool moved_by_user_;
|
||||
bool rotate_by_user_;
|
||||
bool moved_by_user_{false};
|
||||
bool rotate_by_user_{false};
|
||||
QPointF before_mov_pos_;
|
||||
};
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user