mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 08:10:52 +01:00
rebase XMLProperties_New (c0d9bf9) to master
This commit is contained in:
committed by
Martin Marmsoler
parent
73b394527d
commit
f3097fc537
@@ -89,29 +89,37 @@ void PartPolygon::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
|
||||
Import the properties of this polygon from a xml element
|
||||
@param qde : Xml document to use
|
||||
*/
|
||||
void PartPolygon::fromXml(const QDomElement &qde)
|
||||
bool PartPolygon::fromXml(const QDomElement &qde)
|
||||
{
|
||||
stylesFromXml(qde);
|
||||
|
||||
int error_counter = 0;
|
||||
int i = 1;
|
||||
while(true)
|
||||
{
|
||||
if (QET::attributeIsAReal(qde, QString("x%1").arg(i)) &&\
|
||||
QET::attributeIsAReal(qde, QString("y%1").arg(i)))
|
||||
++ i;
|
||||
if (propertyDouble(qde, QString("x%1").arg(i)) == PropertyFlags::Success &&
|
||||
propertyDouble(qde, QString("y%1").arg(i)) == PropertyFlags::Success)
|
||||
i++;
|
||||
|
||||
else break;
|
||||
}
|
||||
|
||||
QPolygonF temp_polygon;
|
||||
double x, y;
|
||||
for (int j = 1 ; j < i ; ++ j)
|
||||
{
|
||||
temp_polygon << QPointF(qde.attribute(QString("x%1").arg(j)).toDouble(),
|
||||
qde.attribute(QString("y%1").arg(j)).toDouble());
|
||||
error_counter += propertyDouble(qde, QString("x%1").arg(j), &x);
|
||||
error_counter += propertyDouble(qde, QString("y%1").arg(j), &y);
|
||||
if (error_counter)
|
||||
return false;
|
||||
temp_polygon << QPointF(x, y);
|
||||
}
|
||||
m_polygon = temp_polygon;
|
||||
|
||||
m_closed = qde.attribute("closed") != "false";
|
||||
if (propertyBool(qde, "closed", &m_closed) != PropertyFlags::Success)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,21 +128,28 @@ void PartPolygon::fromXml(const QDomElement &qde)
|
||||
@param xml_document : Xml document to use for create the xml element
|
||||
@return an xml element that describe this polygon
|
||||
*/
|
||||
const QDomElement PartPolygon::toXml(QDomDocument &xml_document) const
|
||||
QDomElement PartPolygon::toXml(QDomDocument &xml_document) const
|
||||
{
|
||||
QDomElement xml_element = xml_document.createElement("polygon");
|
||||
int i = 1;
|
||||
foreach(QPointF point, m_polygon) {
|
||||
point = mapToScene(point);
|
||||
xml_element.setAttribute(QString("x%1").arg(i), QString("%1").arg(point.x()));
|
||||
xml_element.setAttribute(QString("y%1").arg(i), QString("%1").arg(point.y()));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, QString("x%1").arg(i), point.x()));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, QString("y%1").arg(i), point.y()));
|
||||
++ i;
|
||||
}
|
||||
if (!m_closed) xml_element.setAttribute("closed", "false");
|
||||
stylesToXml(xml_element);
|
||||
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "closed", m_closed));
|
||||
|
||||
stylesToXml(xml_document, xml_element);
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user