mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-29 23:40:51 +01:00
rebase XMLProperties_New (c0d9bf9) to master
This commit is contained in:
committed by
Martin Marmsoler
parent
73b394527d
commit
f3097fc537
@@ -26,9 +26,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);
|
||||
}
|
||||
@@ -62,19 +60,34 @@ 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());
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user