mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Add userProperties
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
- 17 colonnes affichees de 60.0 px de large pour 20.0px de haut
|
||||
- 8 lignes affichees de 80.0 px de haut pour 20.0px de large
|
||||
*/
|
||||
BorderProperties::BorderProperties()
|
||||
BorderProperties::BorderProperties(): PropertiesInterface("border")
|
||||
{
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ bool BorderProperties::operator!=(const BorderProperties &bp) {
|
||||
}
|
||||
|
||||
/**
|
||||
@brief BorderProperties::toXml
|
||||
@brief BorderProperties::toXmlPriv
|
||||
Exports dimensions as XML attributes added to element e.
|
||||
\~French Exporte les dimensions sous formes d'attributs XML ajoutes a l'element e.
|
||||
|
||||
@@ -88,22 +88,17 @@ bool BorderProperties::operator!=(const BorderProperties &bp) {
|
||||
XML element to which attributes will be added
|
||||
\~French Element XML auquel seront ajoutes des attributs
|
||||
*/
|
||||
QDomElement BorderProperties::toXml(QDomDocument &dom_doc) const {
|
||||
|
||||
QDomElement e = dom_doc.createElement("border");
|
||||
|
||||
e.appendChild(createXmlProperty(dom_doc, "cols", columns_count));
|
||||
e.appendChild(createXmlProperty(dom_doc, "colsize", columns_width));
|
||||
e.appendChild(createXmlProperty(dom_doc, "rows", rows_count));
|
||||
e.appendChild(createXmlProperty(dom_doc, "rowsize", rows_height));
|
||||
e.appendChild(createXmlProperty(dom_doc, "displayrows", display_rows));
|
||||
e.appendChild(createXmlProperty(dom_doc, "displaycols", display_columns));
|
||||
|
||||
return e;
|
||||
void BorderProperties::toXmlPriv(QDomElement& e) const {
|
||||
e.appendChild(createXmlProperty("cols", columns_count));
|
||||
e.appendChild(createXmlProperty("colsize", columns_width));
|
||||
e.appendChild(createXmlProperty("rows", rows_count));
|
||||
e.appendChild(createXmlProperty("rowsize", rows_height));
|
||||
e.appendChild(createXmlProperty("displayrows", display_rows));
|
||||
e.appendChild(createXmlProperty("displaycols", display_columns));
|
||||
}
|
||||
|
||||
/**RETURNS True
|
||||
@brief BorderProperties::fromXml
|
||||
/*!RETURNS True
|
||||
@brief BorderProperties::fromXmlPriv
|
||||
Import dimensions from XML attributes of element e
|
||||
\~French Importe les dimensions a partir des attributs XML de l'element e
|
||||
|
||||
@@ -111,7 +106,7 @@ QDomElement BorderProperties::toXml(QDomDocument &dom_doc) const {
|
||||
XML element whose attributes will be read
|
||||
\~French Element XML dont les attributs seront lus
|
||||
*/
|
||||
bool BorderProperties::fromXml(const QDomElement &e) {
|
||||
bool BorderProperties::fromXmlPriv(const QDomElement &e) {
|
||||
|
||||
if (propertyInteger(e, "cols", &columns_count) == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(e, "colsize", &columns_width) == PropertyFlags::NoValidConversion ||
|
||||
|
||||
@@ -37,8 +37,8 @@ class BorderProperties : public PropertiesInterface {
|
||||
bool operator==(const BorderProperties &);
|
||||
bool operator!=(const BorderProperties &);
|
||||
|
||||
QDomElement toXml(QDomDocument &dom_doc) const override;
|
||||
bool fromXml(const QDomElement &) override;
|
||||
void toXmlPriv(QDomElement&) const override;
|
||||
bool fromXmlPriv(const QDomElement &) override;
|
||||
static bool valideXml(QDomElement& e);
|
||||
void toSettings(QSettings &, const QString & = QString()) const override;
|
||||
void fromSettings(QSettings &, const QString & = QString()) override;
|
||||
|
||||
@@ -207,8 +207,8 @@ QRectF BorderTitleBlock::insideBorderRect() const
|
||||
Exports the title block current values to XML.
|
||||
@param xml_elmt the XML element attributes will be added to
|
||||
*/
|
||||
void BorderTitleBlock::titleBlockToXml(QDomElement& doc) {
|
||||
exportTitleBlock().toXml(doc);
|
||||
QDomElement BorderTitleBlock::titleBlockToXml(QDomDocument& doc) {
|
||||
return exportTitleBlock().toXml(doc);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -174,7 +174,7 @@ class BorderTitleBlock : public QObject
|
||||
void setPreviousFolioNum(const QString &previous);
|
||||
void setNextFolioNum(const QString &next);
|
||||
|
||||
void titleBlockToXml(QDomElement &doc);
|
||||
QDomElement titleBlockToXml(QDomDocument &doc);
|
||||
void titleBlockFromXml(const QDomElement &);
|
||||
void borderToXml(QDomElement &);
|
||||
void borderFromXml(const QDomElement &);
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
/**
|
||||
Constructeur par defaut
|
||||
*/
|
||||
SingleLineProperties::SingleLineProperties()
|
||||
SingleLineProperties::SingleLineProperties(): PropertiesInterface("SingleLine")
|
||||
{
|
||||
}
|
||||
|
||||
@@ -211,17 +211,14 @@ void SingleLineProperties::drawPen(QPainter *painter,
|
||||
ajoutes a l'element e.
|
||||
@param e Element XML auquel seront ajoutes des attributs
|
||||
*/
|
||||
QDomElement SingleLineProperties::toXml(QDomDocument &doc) const {
|
||||
void SingleLineProperties::toXmlPriv(QDomElement& e) const {
|
||||
|
||||
QDomElement e = doc.createElement("SingleLine");
|
||||
e.appendChild(createXmlProperty(doc, "ground", hasGround));
|
||||
e.appendChild(createXmlProperty(doc, "neutral", hasNeutral));
|
||||
e.appendChild(createXmlProperty(doc, "phase", phases));
|
||||
e.appendChild(createXmlProperty("ground", hasGround));
|
||||
e.appendChild(createXmlProperty("neutral", hasNeutral));
|
||||
e.appendChild(createXmlProperty("phase", phases));
|
||||
|
||||
if (isPen())
|
||||
e.appendChild(createXmlProperty(doc, "pen", true));
|
||||
|
||||
return e;
|
||||
e.appendChild(createXmlProperty("pen", true));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,7 +226,7 @@ QDomElement SingleLineProperties::toXml(QDomDocument &doc) const {
|
||||
de l'element e
|
||||
@param e Element XML dont les attributs seront lus
|
||||
*/
|
||||
bool SingleLineProperties::fromXml(const QDomElement &e) {
|
||||
bool SingleLineProperties::fromXmlPriv(const QDomElement &e) {
|
||||
if (propertyBool(e, "ground", &hasGround) != PropertyFlags::Success ||
|
||||
propertyBool(e, "neutral", &hasNeutral) != PropertyFlags::Success)
|
||||
return false;
|
||||
@@ -266,17 +263,7 @@ bool SingleLineProperties::valideXml(QDomElement& e) {
|
||||
multifilaire noir dont le texte est "_"
|
||||
*/
|
||||
ConductorProperties::ConductorProperties() :
|
||||
type(Multi),
|
||||
color(Qt::black),
|
||||
text_color(Qt::black),
|
||||
text("_"),
|
||||
text_size(9),
|
||||
cond_size(1),
|
||||
verti_rotate_text(270),
|
||||
horiz_rotate_text(0),
|
||||
m_show_text(true),
|
||||
m_one_text_per_folio(false),
|
||||
style(Qt::SolidLine)
|
||||
PropertiesInterface("defaultconductor")
|
||||
{}
|
||||
|
||||
/**
|
||||
@@ -292,46 +279,45 @@ ConductorProperties::~ConductorProperties()
|
||||
Export conductor propertie, in the XML element 'e'
|
||||
@param e the xml element
|
||||
*/
|
||||
QDomElement ConductorProperties::toXml(QDomDocument& doc) const
|
||||
void ConductorProperties::toXmlPriv(QDomElement& e) const
|
||||
{
|
||||
|
||||
QDomElement e = doc.createElement("defaultconductor");
|
||||
e.appendChild(createXmlProperty("type", typeToString(type)));
|
||||
e.appendChild(createXmlProperty("color", color));
|
||||
|
||||
e.appendChild(createXmlProperty(doc, "type", typeToString(type)));
|
||||
e.appendChild(createXmlProperty(doc, "color", color));
|
||||
|
||||
e.appendChild(createXmlProperty(doc, "bicolor", m_bicolor));
|
||||
e.appendChild(createXmlProperty(doc, "color2", m_color_2));
|
||||
e.appendChild(createXmlProperty(doc, "dash-size", m_dash_size));
|
||||
e.appendChild(createXmlProperty("bicolor", m_bicolor));
|
||||
e.appendChild(createXmlProperty("color2", m_color_2));
|
||||
e.appendChild(createXmlProperty("dash-size", m_dash_size));
|
||||
|
||||
if (type == Single)
|
||||
{
|
||||
QDomDocument doc;
|
||||
e.appendChild(singleLineProperties.toXml(doc));
|
||||
}
|
||||
|
||||
e.appendChild(createXmlProperty(doc, "num", text));
|
||||
e.appendChild(createXmlProperty(doc, "text_color", text_color));
|
||||
e.appendChild(createXmlProperty(doc, "formula", m_formula));
|
||||
e.appendChild(createXmlProperty(doc, "function", m_function));
|
||||
e.appendChild(createXmlProperty(doc, "tension_protocol", m_tension_protocol));
|
||||
e.appendChild(createXmlProperty(doc, "conductor_color", m_wire_color));
|
||||
e.appendChild(createXmlProperty(doc, "conductor_section", m_wire_section));
|
||||
e.appendChild(createXmlProperty(doc, "numsize", text_size));
|
||||
e.appendChild(createXmlProperty(doc, "condsize", cond_size));
|
||||
e.appendChild(createXmlProperty(doc, "displaytext", m_show_text));
|
||||
e.appendChild(createXmlProperty(doc, "onetextperfolio", m_one_text_per_folio));
|
||||
e.appendChild(createXmlProperty(doc, "vertirotatetext", verti_rotate_text));
|
||||
e.appendChild(createXmlProperty(doc, "horizrotatetext", horiz_rotate_text));
|
||||
e.appendChild(createXmlProperty("num", text));
|
||||
e.appendChild(createXmlProperty("text_color", text_color));
|
||||
e.appendChild(createXmlProperty("formula", m_formula));
|
||||
e.appendChild(createXmlProperty("function", m_function));
|
||||
e.appendChild(createXmlProperty("tension_protocol", m_tension_protocol));
|
||||
e.appendChild(createXmlProperty("conductor_color", m_wire_color));
|
||||
e.appendChild(createXmlProperty("conductor_section", m_wire_section));
|
||||
e.appendChild(createXmlProperty("numsize", text_size));
|
||||
e.appendChild(createXmlProperty("condsize", cond_size));
|
||||
e.appendChild(createXmlProperty("displaytext", m_show_text));
|
||||
e.appendChild(createXmlProperty("onetextperfolio", m_one_text_per_folio));
|
||||
e.appendChild(createXmlProperty("vertirotatetext", verti_rotate_text));
|
||||
e.appendChild(createXmlProperty("horizrotatetext", horiz_rotate_text));
|
||||
// TODO: implement
|
||||
//e.setAttribute("cable", m_cable);
|
||||
// e.setAttribute("bus", m_bus);
|
||||
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
|
||||
e.appendChild(createXmlProperty(doc, "horizontal-alignment", me.valueToKey(m_horizontal_alignment)));
|
||||
e.appendChild(createXmlProperty(doc, "vertical-alignment", me.valueToKey(m_vertical_alignment)));
|
||||
e.appendChild(createXmlProperty("horizontal-alignment", me.valueToKey(m_horizontal_alignment)));
|
||||
e.appendChild(createXmlProperty("vertical-alignment", me.valueToKey(m_vertical_alignment)));
|
||||
|
||||
QString conductor_style = writeStyle();
|
||||
if (!conductor_style.isEmpty())
|
||||
e.appendChild(createXmlProperty(doc, "style", conductor_style));
|
||||
|
||||
return e;
|
||||
e.appendChild(createXmlProperty("style", conductor_style));
|
||||
}
|
||||
|
||||
|
||||
@@ -340,7 +326,7 @@ QDomElement ConductorProperties::toXml(QDomDocument& doc) const
|
||||
Import conductor propertie, from the attribute of the xml element 'e'
|
||||
@param e the xml document
|
||||
*/
|
||||
bool ConductorProperties::fromXml(const QDomElement &e)
|
||||
bool ConductorProperties::fromXmlPriv(const QDomElement &e)
|
||||
{
|
||||
// get conductor color
|
||||
propertyColor(e, "color", &color);
|
||||
|
||||
@@ -39,8 +39,8 @@ class SingleLineProperties: public PropertiesInterface {
|
||||
unsigned short int phasesCount();
|
||||
bool isPen() const;
|
||||
void draw(QPainter *, QET::ConductorSegmentType, const QRectF &);
|
||||
QDomElement toXml(QDomDocument& doc) const override;
|
||||
bool fromXml(const QDomElement &) override;
|
||||
void toXmlPriv(QDomElement&) const override;
|
||||
bool fromXmlPriv(const QDomElement &) override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
void toSettings(QSettings &, const QString & = QString()) const;
|
||||
void fromSettings(QSettings &, const QString & = QString());
|
||||
@@ -83,7 +83,7 @@ class ConductorProperties: public PropertiesInterface
|
||||
|
||||
|
||||
//Attributes
|
||||
ConductorType type{ConductorType::Single};
|
||||
ConductorType type{ConductorType::Multi};
|
||||
|
||||
// TODO: set default values!
|
||||
QColor color{QColor(Qt::black)},
|
||||
@@ -91,7 +91,7 @@ class ConductorProperties: public PropertiesInterface
|
||||
text_color{QColor(Qt::black)};
|
||||
|
||||
QString
|
||||
text,
|
||||
text{"_"},
|
||||
m_function,
|
||||
m_tension_protocol,
|
||||
m_wire_color,
|
||||
@@ -105,11 +105,11 @@ class ConductorProperties: public PropertiesInterface
|
||||
|
||||
double
|
||||
cond_size{1},
|
||||
verti_rotate_text,
|
||||
horiz_rotate_text;
|
||||
verti_rotate_text{270},
|
||||
horiz_rotate_text{0};
|
||||
|
||||
bool m_show_text{true},
|
||||
m_one_text_per_folio{true},
|
||||
m_one_text_per_folio{false},
|
||||
m_bicolor = false;
|
||||
|
||||
Qt::Alignment
|
||||
@@ -121,8 +121,8 @@ class ConductorProperties: public PropertiesInterface
|
||||
SingleLineProperties singleLineProperties;
|
||||
|
||||
// methods
|
||||
QDomElement toXml(QDomDocument &doc) const override;
|
||||
bool fromXml(const QDomElement &) override;
|
||||
void toXmlPriv(QDomElement&) const override;
|
||||
bool fromXmlPriv(const QDomElement &) override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
void toSettings(QSettings &, const QString & = QString()) const override;
|
||||
void fromSettings(QSettings &, const QString & = QString()) override;
|
||||
|
||||
@@ -738,7 +738,7 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
||||
// proprietes du schema
|
||||
if (whole_content) {
|
||||
// TODO: compare with old version
|
||||
border_and_titleblock.titleBlockToXml(dom_root);
|
||||
dom_root.appendChild(border_and_titleblock.titleBlockToXml(document));
|
||||
border_and_titleblock.borderToXml(dom_root);
|
||||
|
||||
// Default conductor properties
|
||||
|
||||
@@ -79,8 +79,8 @@ class AbstractPartEllipse : public CustomElementGraphicPart
|
||||
protected:
|
||||
QList<QPointF> saved_points_;
|
||||
QRectF m_rect;
|
||||
qreal m_start_angle;
|
||||
qreal m_span_angle;
|
||||
qreal m_start_angle{0};
|
||||
qreal m_span_angle{-1440};
|
||||
QVector<QetGraphicsHandlerItem *> m_handler_vector;
|
||||
};
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ void CustomElementGraphicPart::setAntialiased(const bool b)
|
||||
Each style separate by ; and name-style/value are separate by :
|
||||
@param qde : QDOmElement used to write the style.
|
||||
*/
|
||||
void CustomElementGraphicPart::stylesToXml(QDomDocument &xml_document, QDomElement &qde) const
|
||||
void CustomElementGraphicPart::stylesToXml(QDomElement &qde) const
|
||||
{
|
||||
QString css_like_styles;
|
||||
|
||||
@@ -497,8 +497,8 @@ void CustomElementGraphicPart::stylesToXml(QDomDocument &xml_document, QDomEleme
|
||||
else if (_color == HTMLGrayBlackColor) css_like_styles += "HTMLGrayBlack";
|
||||
else if (_color == NoneColor) css_like_styles += "none";
|
||||
|
||||
qde.appendChild(createXmlProperty(xml_document, "style", css_like_styles));
|
||||
qde.appendChild(createXmlProperty(xml_document, "antialias", _antialiased ? "true" : "false"));
|
||||
qde.appendChild(createXmlProperty("style", css_like_styles));
|
||||
qde.appendChild(createXmlProperty("antialias", _antialiased ? "true" : "false"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -303,7 +303,7 @@ class CustomElementGraphicPart : public QGraphicsObject, public CustomElementPar
|
||||
virtual void resetAllHandlerColor() {}
|
||||
|
||||
protected:
|
||||
void stylesToXml (QDomDocument &xml_document, QDomElement &) const;
|
||||
void stylesToXml (QDomElement &) const;
|
||||
void stylesFromXml(const QDomElement &);
|
||||
void resetStyles ();
|
||||
void applyStylesToQPainter(QPainter &) const;
|
||||
|
||||
@@ -31,8 +31,7 @@
|
||||
PartArc::PartArc(QETElementEditor *editor, QGraphicsItem *parent) :
|
||||
AbstractPartEllipse(editor, parent)
|
||||
{
|
||||
m_start_angle = 0;
|
||||
m_span_angle = -1440;
|
||||
setTagName("arc");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,23 +101,22 @@ void PartArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *options,
|
||||
@param xml_document : Xml document to use for create the xml element.
|
||||
@return : an xml element that describe this arc
|
||||
*/
|
||||
QDomElement PartArc::toXml(QDomDocument &xml_document) const
|
||||
void PartArc::toXmlPriv(QDomElement& e) const
|
||||
{
|
||||
QDomElement xml_element = xml_document.createElement("arc");
|
||||
e.setTagName("arc");
|
||||
QPointF top_left(sceneTopLeft());
|
||||
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "x", top_left.x()));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "y", top_left.y()));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "width", rect().width()));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "height", rect().height()));
|
||||
e.appendChild(createXmlProperty("x", top_left.x()));
|
||||
e.appendChild(createXmlProperty("y", top_left.y()));
|
||||
e.appendChild(createXmlProperty("width", rect().width()));
|
||||
e.appendChild(createXmlProperty("height", rect().height()));
|
||||
|
||||
//to maintain compatibility with the previous version, we write the angle in degrees.
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "start", m_start_angle / 16));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "angle", m_span_angle / 16));
|
||||
e.appendChild(createXmlProperty("start", m_start_angle / 16));
|
||||
e.appendChild(createXmlProperty("angle", m_span_angle / 16));
|
||||
|
||||
|
||||
stylesToXml(xml_document, xml_element);
|
||||
return(xml_element);
|
||||
stylesToXml(e);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,7 +124,7 @@ QDomElement PartArc::toXml(QDomDocument &xml_document) const
|
||||
Import the properties of this arc from a xml element.
|
||||
@param qde : Xml document to use.
|
||||
*/
|
||||
bool PartArc::fromXml(const QDomElement &qde) {
|
||||
bool PartArc::fromXmlPriv(const QDomElement &qde) {
|
||||
stylesFromXml(qde);
|
||||
|
||||
double x=0, y=0, w=0, h=0;
|
||||
|
||||
@@ -51,8 +51,8 @@ class PartArc : public AbstractPartEllipse
|
||||
//Name and XML
|
||||
QString name() const override { return(QObject::tr("arc", "element part name")); }
|
||||
QString xmlName() const override { return(QString("arc")); }
|
||||
QDomElement toXml (QDomDocument &) const override;
|
||||
bool fromXml (const QDomElement &) override;
|
||||
void toXmlPriv(QDomElement&) const override;
|
||||
bool fromXmlPriv (const QDomElement &) override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||
|
||||
@@ -30,6 +30,7 @@ PartDynamicTextField::PartDynamicTextField(QETElementEditor *editor, QGraphicsIt
|
||||
CustomElementPart(editor),
|
||||
m_uuid(QUuid::createUuid())
|
||||
{
|
||||
setTagName(xmlName());
|
||||
setDefaultTextColor(Qt::black);
|
||||
setFont(QETApp::dynamicTextsItemFont());
|
||||
QSettings settings;
|
||||
@@ -93,71 +94,72 @@ void PartDynamicTextField::handleUserTransformation(
|
||||
@param dom_doc
|
||||
@return
|
||||
*/
|
||||
QDomElement PartDynamicTextField::toXml(QDomDocument &dom_doc) const
|
||||
void PartDynamicTextField::toXmlPriv(QDomElement& e) const
|
||||
{
|
||||
QDomElement root_element = dom_doc.createElement(xmlName());
|
||||
|
||||
root_element.appendChild(createXmlProperty(dom_doc, "x", pos().x()));
|
||||
root_element.appendChild(createXmlProperty(dom_doc, "y", pos().y()));
|
||||
root_element.appendChild(createXmlProperty(dom_doc, "z", zValue()));
|
||||
root_element.appendChild(createXmlProperty(dom_doc, "rotation", QET::correctAngle(rotation())));
|
||||
e.appendChild(createXmlProperty("x", pos().x()));
|
||||
e.appendChild(createXmlProperty("y", pos().y()));
|
||||
e.appendChild(createXmlProperty("z", zValue()));
|
||||
e.appendChild(createXmlProperty("rotation", QET::correctAngle(rotation())));
|
||||
|
||||
root_element.appendChild(createXmlProperty(dom_doc, "font", font().toString()));
|
||||
root_element.appendChild(createXmlProperty(dom_doc, "uuid", m_uuid));
|
||||
root_element.appendChild(createXmlProperty(dom_doc, "frame", m_frame));
|
||||
root_element.appendChild(createXmlProperty(dom_doc, "text_width", m_text_width));
|
||||
e.appendChild(createXmlProperty("font", font().toString()));
|
||||
e.appendChild(createXmlProperty("uuid", m_uuid));
|
||||
e.appendChild(createXmlProperty("frame", m_frame));
|
||||
e.appendChild(createXmlProperty("text_width", m_text_width));
|
||||
|
||||
QMetaEnum me = DynamicElementTextItem::textFromMetaEnum();
|
||||
root_element.appendChild(createXmlProperty(dom_doc, "text_from", me.valueToKey(m_text_from)));
|
||||
e.appendChild(createXmlProperty("text_from", me.valueToKey(m_text_from)));
|
||||
|
||||
me = QMetaEnum::fromType<Qt::Alignment>();
|
||||
if(this -> alignment() &Qt::AlignRight)
|
||||
root_element.appendChild(createXmlProperty(dom_doc, "Halignment", me.valueToKey(Qt::AlignRight)));
|
||||
e.appendChild(createXmlProperty("Halignment", me.valueToKey(Qt::AlignRight)));
|
||||
else if(this -> alignment() &Qt::AlignLeft)
|
||||
root_element.appendChild(createXmlProperty(dom_doc, "Halignment", me.valueToKey(Qt::AlignLeft)));
|
||||
e.appendChild(createXmlProperty("Halignment", me.valueToKey(Qt::AlignLeft)));
|
||||
else if(this -> alignment() &Qt::AlignHCenter)
|
||||
root_element.appendChild(createXmlProperty(dom_doc, "Halignment", me.valueToKey(Qt::AlignHCenter)));
|
||||
e.appendChild(createXmlProperty("Halignment", me.valueToKey(Qt::AlignHCenter)));
|
||||
|
||||
if(this -> alignment() &Qt::AlignBottom)
|
||||
root_element.appendChild(createXmlProperty(dom_doc, "Valignment", me.valueToKey(Qt::AlignBottom)));
|
||||
e.appendChild(createXmlProperty("Valignment", me.valueToKey(Qt::AlignBottom)));
|
||||
else if(this -> alignment() & Qt::AlignTop)
|
||||
root_element.appendChild(createXmlProperty(dom_doc, "Valignment", me.valueToKey(Qt::AlignTop)));
|
||||
e.appendChild(createXmlProperty("Valignment", me.valueToKey(Qt::AlignTop)));
|
||||
else if(this -> alignment() &Qt::AlignVCenter)
|
||||
root_element.appendChild(createXmlProperty(dom_doc, "Valignment", me.valueToKey(Qt::AlignVCenter)));
|
||||
e.appendChild(createXmlProperty("Valignment", me.valueToKey(Qt::AlignVCenter)));
|
||||
|
||||
QDomDocument dom_doc;
|
||||
QDomElement dom_text = dom_doc.createElement("text");
|
||||
dom_text.appendChild(dom_doc.createTextNode(toPlainText()));
|
||||
root_element.appendChild(dom_text);
|
||||
e.appendChild(dom_text);
|
||||
|
||||
//Info name
|
||||
// TODO: move it into a property
|
||||
if(!m_info_name.isEmpty()) {
|
||||
QDomElement dom_info_name = dom_doc.createElement("info_name");
|
||||
dom_info_name.appendChild(dom_doc.createTextNode(m_info_name));
|
||||
root_element.appendChild(dom_info_name);
|
||||
e.appendChild(dom_info_name);
|
||||
}
|
||||
|
||||
//Composite text
|
||||
// TODO: move it into a property
|
||||
if(!m_composite_text.isEmpty()) {
|
||||
QDomElement dom_comp_text = dom_doc.createElement("composite_text");
|
||||
dom_comp_text.appendChild(dom_doc.createTextNode(m_composite_text));
|
||||
root_element.appendChild(dom_comp_text);
|
||||
e.appendChild(dom_comp_text);
|
||||
}
|
||||
|
||||
//Color
|
||||
// TODO: move it into a property
|
||||
if(color() != QColor(Qt::black)) {
|
||||
QDomElement dom_color = dom_doc.createElement("color");
|
||||
dom_color.appendChild(dom_doc.createTextNode(color().name()));
|
||||
root_element.appendChild(dom_color);
|
||||
e.appendChild(dom_color);
|
||||
}
|
||||
|
||||
return root_element;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief PartDynamicTextField::fromXml
|
||||
@param dom_elmt
|
||||
*/
|
||||
bool PartDynamicTextField::fromXml(const QDomElement &dom_elmt)
|
||||
bool PartDynamicTextField::fromXmlPriv(const QDomElement &dom_elmt)
|
||||
{
|
||||
if (dom_elmt.tagName() != xmlName()) {
|
||||
qDebug() << "PartDynamicTextField::fromXml : Wrong tagg name";
|
||||
|
||||
@@ -75,8 +75,8 @@ class PartDynamicTextField : public QGraphicsTextItem, public CustomElementPart
|
||||
void startUserTransformation(const QRectF &initial_selection_rect) override;
|
||||
void handleUserTransformation(const QRectF &initial_selection_rect, const QRectF &new_selection_rect) override;
|
||||
|
||||
QDomElement toXml(QDomDocument &dom_doc) const override;
|
||||
bool fromXml(const QDomElement &dom_elmt) override;
|
||||
void toXmlPriv(QDomElement&) const override;
|
||||
bool fromXmlPriv(const QDomElement &dom_elmt) override;
|
||||
void fromTextFieldXml(const QDomElement &dom_element);
|
||||
static bool valideXml(QDomElement& dom_elmt);
|
||||
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||
|
||||
@@ -79,41 +79,37 @@ void PartEllipse::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
|
||||
}
|
||||
|
||||
/**
|
||||
@brief PartEllipse::toXml
|
||||
@brief PartEllipse::toXmlPriv
|
||||
Export this ellipse in xml
|
||||
@param xml_document : Xml document to use for create the xml element.
|
||||
@return : an xml element that describe this ellipse
|
||||
*/
|
||||
QDomElement PartEllipse::toXml(QDomDocument &xml_document) const
|
||||
void PartEllipse::toXmlPriv(QDomElement& e) const
|
||||
{
|
||||
QDomElement xml_element;
|
||||
if (qFuzzyCompare(rect().width(), rect().height()))
|
||||
{
|
||||
xml_element = xml_document.createElement("circle");
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "diameter", rect().width()));
|
||||
e.setTagName("circle");
|
||||
e.appendChild(createXmlProperty("diameter", rect().width()));
|
||||
}
|
||||
else
|
||||
{
|
||||
xml_element = xml_document.createElement("ellipse");
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "width", rect().width()));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "height", rect().height()));
|
||||
e.setTagName("ellipse");
|
||||
e.appendChild(createXmlProperty("width", rect().width()));
|
||||
e.appendChild(createXmlProperty("height", rect().height()));
|
||||
}
|
||||
|
||||
QPointF top_left(sceneTopLeft());
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "x", top_left.x()));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "y", top_left.y()));
|
||||
e.appendChild(createXmlProperty("x", top_left.x()));
|
||||
e.appendChild(createXmlProperty("y", top_left.y()));
|
||||
|
||||
stylesToXml(xml_document, xml_element);
|
||||
|
||||
return(xml_element);
|
||||
stylesToXml(e);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief PartEllipse::fromXml
|
||||
@brief PartEllipse::fromXmlPriv
|
||||
Import the properties of this ellipse from a xml element.
|
||||
@param qde : Xml document to use.
|
||||
*/
|
||||
bool PartEllipse::fromXml(const QDomElement &qde)
|
||||
bool PartEllipse::fromXmlPriv(const QDomElement &qde)
|
||||
{
|
||||
stylesFromXml(qde);
|
||||
double x=0, y=0, width=0, height=0;
|
||||
|
||||
@@ -52,8 +52,8 @@ class PartEllipse : public AbstractPartEllipse
|
||||
//Name and XML
|
||||
QString name() const override { return(QObject::tr("ellipse", "element part name")); }
|
||||
QString xmlName() const override { return(QString("ellipse")); }
|
||||
QDomElement toXml (QDomDocument &) const override;
|
||||
bool fromXml (const QDomElement &) override;
|
||||
void toXmlPriv(QDomElement&) const override;
|
||||
bool fromXmlPriv(const QDomElement &) override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||
|
||||
@@ -30,13 +30,10 @@
|
||||
@param parent : parent item
|
||||
*/
|
||||
PartLine::PartLine(QETElementEditor *editor, QGraphicsItem *parent) :
|
||||
CustomElementGraphicPart(editor, parent),
|
||||
first_end(Qet::None),
|
||||
first_length(1.5),
|
||||
second_end(Qet::None),
|
||||
second_length(1.5),
|
||||
m_undo_command(nullptr)
|
||||
{}
|
||||
CustomElementGraphicPart(editor, parent)
|
||||
{
|
||||
setTagName("line");
|
||||
}
|
||||
|
||||
/// Destructeur
|
||||
PartLine::~PartLine()
|
||||
@@ -105,30 +102,27 @@ void PartLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *options,
|
||||
}
|
||||
|
||||
/**
|
||||
@brief PartLine::toXml
|
||||
@brief PartLine::toXmlPriv
|
||||
Export this line in xml
|
||||
@param xml_document : Xml document to use for create the xml element.
|
||||
@return an xml element that describe this line
|
||||
*/
|
||||
QDomElement PartLine::toXml(QDomDocument &xml_document) const
|
||||
void PartLine::toXmlPriv(QDomElement& e) const
|
||||
{
|
||||
QPointF p1(sceneP1());
|
||||
QPointF p2(sceneP2());
|
||||
|
||||
QDomElement xml_element = xml_document.createElement("line");
|
||||
e.appendChild(createXmlProperty("x1", p1.x()));
|
||||
e.appendChild(createXmlProperty("y1", p1.y()));
|
||||
e.appendChild(createXmlProperty("x2", p2.x()));
|
||||
e.appendChild(createXmlProperty("y2", p2.y()));
|
||||
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "x1", p1.x()));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "y1", p1.y()));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "x2", p2.x()));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "y2", p2.y()));
|
||||
e.appendChild(createXmlProperty("end1", Qet::endTypeToString(first_end)));
|
||||
e.appendChild(createXmlProperty("length1", first_length));
|
||||
e.appendChild(createXmlProperty("end2", Qet::endTypeToString(second_end)));
|
||||
e.appendChild(createXmlProperty("length2", second_length));
|
||||
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "end1", Qet::endTypeToString(first_end)));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "length1", first_length));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "end2", Qet::endTypeToString(second_end)));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "length2", second_length));
|
||||
|
||||
stylesToXml(xml_document, xml_element);
|
||||
return(xml_element);
|
||||
stylesToXml(e);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,7 +130,7 @@ QDomElement PartLine::toXml(QDomDocument &xml_document) const
|
||||
Import the properties of this line from a xml element.
|
||||
@param qde : Xml document to use
|
||||
*/
|
||||
bool PartLine::fromXml(const QDomElement &qde) {
|
||||
bool PartLine::fromXmlPriv(const QDomElement &qde) {
|
||||
stylesFromXml(qde);
|
||||
|
||||
double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
|
||||
|
||||
@@ -70,8 +70,8 @@ class PartLine : public CustomElementGraphicPart
|
||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
||||
QString name() const override { return(QObject::tr("ligne", "element part name")); }
|
||||
QString xmlName() const override { return(QString("line")); }
|
||||
QDomElement toXml(QDomDocument &) const override;
|
||||
bool fromXml(const QDomElement &) override;
|
||||
void toXmlPriv(QDomElement&) const override;
|
||||
bool fromXmlPriv(const QDomElement &) override;
|
||||
bool valideXml(QDomElement& element) const;
|
||||
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||
@@ -117,15 +117,15 @@ class PartLine : public CustomElementGraphicPart
|
||||
QRectF secondEndCircleRect() const;
|
||||
|
||||
/*****************/
|
||||
Qet::EndType first_end;
|
||||
Qet::EndType first_end{Qet::EndType::None};
|
||||
qreal first_length{1.5};
|
||||
|
||||
Qet::EndType second_end;
|
||||
Qet::EndType second_end{Qet::EndType::None};
|
||||
qreal second_length{1.5};
|
||||
QList<QPointF> saved_points_;
|
||||
QLineF m_line;
|
||||
int m_vector_index = -1;
|
||||
QPropertyUndoCommand *m_undo_command;
|
||||
QPropertyUndoCommand *m_undo_command{nullptr};
|
||||
QVector<QetGraphicsHandlerItem *> m_handler_vector;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -35,6 +35,7 @@ PartPolygon::PartPolygon(QETElementEditor *editor, QGraphicsItem *parent) :
|
||||
m_closed(false),
|
||||
m_undo_command(nullptr)
|
||||
{
|
||||
setTagName("polygon");
|
||||
m_insert_point = new QAction(tr("Ajouter un point"), this);
|
||||
m_insert_point->setIcon(QET::Icons::Add);
|
||||
connect(m_insert_point, &QAction::triggered, this, &PartPolygon::insertPoint);
|
||||
@@ -89,7 +90,7 @@ void PartPolygon::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
|
||||
Import the properties of this polygon from a xml element
|
||||
@param qde : Xml document to use
|
||||
*/
|
||||
bool PartPolygon::fromXml(const QDomElement &qde)
|
||||
bool PartPolygon::fromXmlPriv(const QDomElement &qde)
|
||||
{
|
||||
stylesFromXml(qde);
|
||||
|
||||
@@ -123,26 +124,23 @@ bool PartPolygon::fromXml(const QDomElement &qde)
|
||||
}
|
||||
|
||||
/**
|
||||
@brief PartPolygon::toXml
|
||||
@brief PartPolygon::toXmlPriv
|
||||
Export this polygin in xml
|
||||
@param xml_document : Xml document to use for create the xml element
|
||||
@return an xml element that describe this polygon
|
||||
@param e: properties get part of this DomElement
|
||||
*/
|
||||
QDomElement PartPolygon::toXml(QDomDocument &xml_document) const
|
||||
void PartPolygon::toXmlPriv(QDomElement& e) const
|
||||
{
|
||||
QDomElement xml_element = xml_document.createElement("polygon");
|
||||
int i = 1;
|
||||
foreach(QPointF point, m_polygon) {
|
||||
point = mapToScene(point);
|
||||
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()));
|
||||
e.appendChild(createXmlProperty(QString("x%1").arg(i), point.x()));
|
||||
e.appendChild(createXmlProperty(QString("y%1").arg(i), point.y()));
|
||||
++ i;
|
||||
}
|
||||
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "closed", m_closed));
|
||||
e.appendChild(createXmlProperty("closed", m_closed));
|
||||
|
||||
stylesToXml(xml_document, xml_element);
|
||||
return(xml_element);
|
||||
stylesToXml(e);
|
||||
}
|
||||
|
||||
bool PartPolygon::valideXml(QDomElement& element) {
|
||||
|
||||
@@ -61,8 +61,8 @@ class PartPolygon : public CustomElementGraphicPart
|
||||
|
||||
QString name() const override { return(QObject::tr("polygone", "element part name")); }
|
||||
QString xmlName() const override { return(QString("polygon")); }
|
||||
bool fromXml(const QDomElement &) override;
|
||||
QDomElement toXml(QDomDocument &) const override;
|
||||
bool fromXmlPriv(const QDomElement &) override;
|
||||
void toXmlPriv(QDomElement&) const override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||
@@ -109,7 +109,7 @@ class PartPolygon : public CustomElementGraphicPart
|
||||
void removePoint();
|
||||
|
||||
|
||||
bool m_closed;
|
||||
bool m_closed{false};
|
||||
QList<QPointF> saved_points_;
|
||||
QPolygonF m_polygon;
|
||||
QPropertyUndoCommand *m_undo_command;
|
||||
|
||||
@@ -30,7 +30,9 @@
|
||||
*/
|
||||
PartRectangle::PartRectangle(QETElementEditor *editor, QGraphicsItem *parent) :
|
||||
CustomElementGraphicPart(editor, parent)
|
||||
{}
|
||||
{
|
||||
setTagName("rect");
|
||||
}
|
||||
|
||||
/**
|
||||
@brief PartRectangle::~PartRectangle
|
||||
@@ -80,20 +82,19 @@ void PartRectangle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
|
||||
}
|
||||
|
||||
/**
|
||||
@brief PartRectangle::toXml
|
||||
@brief PartRectangle::toXmlPriv
|
||||
Export this rectangle in xml
|
||||
@param xml_document : Xml document to use for create the xml element.
|
||||
@return an xml element that describe this ellipse
|
||||
*/
|
||||
QDomElement PartRectangle::toXml(QDomDocument &xml_document) const
|
||||
void PartRectangle::toXmlPriv(QDomElement& e) const
|
||||
{
|
||||
QDomElement xml_element = xml_document.createElement("rect");
|
||||
QPointF top_left(sceneTopLeft());
|
||||
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "x", top_left.x()));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "y", top_left.y()));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "width", m_rect.width()));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "height", m_rect.height()));
|
||||
e.appendChild(createXmlProperty("x", top_left.x()));
|
||||
e.appendChild(createXmlProperty("y", top_left.y()));
|
||||
e.appendChild(createXmlProperty("width", m_rect.width()));
|
||||
e.appendChild(createXmlProperty("height", m_rect.height()));
|
||||
|
||||
QRectF rect = m_rect.normalized();
|
||||
qreal x = m_xRadius;
|
||||
@@ -105,14 +106,13 @@ QDomElement PartRectangle::toXml(QDomDocument &xml_document) const
|
||||
y = rect.height()/2;
|
||||
}
|
||||
|
||||
xml_element.setAttribute("rx", QString::number(m_xRadius));
|
||||
xml_element.setAttribute("ry", QString::number(m_yRadius));
|
||||
e.setAttribute("rx", QString::number(m_xRadius));
|
||||
e.setAttribute("ry", QString::number(m_yRadius));
|
||||
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "rx", m_xRadius));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "ry", m_yRadius));
|
||||
e.appendChild(createXmlProperty("rx", m_xRadius));
|
||||
e.appendChild(createXmlProperty("ry", m_yRadius));
|
||||
|
||||
stylesToXml(xml_document, xml_element);
|
||||
return(xml_element);
|
||||
stylesToXml(e);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,7 +120,7 @@ QDomElement PartRectangle::toXml(QDomDocument &xml_document) const
|
||||
Import the properties of this rectangle from a xml element.
|
||||
@param qde : Xml document to use.
|
||||
*/
|
||||
bool PartRectangle::fromXml(const QDomElement &qde)
|
||||
bool PartRectangle::fromXmlPriv(const QDomElement &qde)
|
||||
{
|
||||
stylesFromXml(qde);
|
||||
|
||||
|
||||
@@ -60,8 +60,8 @@ class PartRectangle : public CustomElementGraphicPart
|
||||
QString name () const override { return(QObject::tr("rectangle", "element part name")); }
|
||||
|
||||
QString xmlName () const override { return(QString("rect")); }
|
||||
QDomElement toXml (QDomDocument &) const override;
|
||||
bool fromXml (const QDomElement &) override;
|
||||
void toXmlPriv(QDomElement&) const override;
|
||||
bool fromXmlPriv (const QDomElement &) override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
PartTerminal::PartTerminal(QETElementEditor *editor, QGraphicsItem *parent) :
|
||||
CustomElementGraphicPart(editor, parent)
|
||||
{
|
||||
setTagName("terminal");
|
||||
d = new TerminalData(this);
|
||||
d->m_name = tr("terminal");
|
||||
d -> m_orientation = Qet::North;
|
||||
@@ -46,7 +47,7 @@ PartTerminal::~PartTerminal()
|
||||
Importe les proprietes d'une borne depuis un element XML
|
||||
@param xml_elmt Element XML a lire
|
||||
*/
|
||||
bool PartTerminal::fromXml(const QDomElement &xml_elmt) {
|
||||
bool PartTerminal::fromXmlPriv(const QDomElement &xml_elmt) {
|
||||
|
||||
// update part and add uuid, which is used in the new version to connect terminals together
|
||||
// if the attribute not exists, means, the element is created with an older version of qet. So use the legacy approach
|
||||
@@ -67,21 +68,16 @@ bool PartTerminal::fromXml(const QDomElement &xml_elmt) {
|
||||
@param xml_document Document XML a utiliser pour creer l'element XML
|
||||
@return un element XML decrivant la borne
|
||||
*/
|
||||
QDomElement PartTerminal::toXml(QDomDocument &xml_document) const {
|
||||
void PartTerminal::toXmlPriv(QDomElement& e) const {
|
||||
|
||||
QDomElement qdo = xml_document.createElement("terminal");
|
||||
|
||||
qdo.appendChild(createXmlProperty(xml_document, "uuid", d->m_uuid));
|
||||
e.appendChild(createXmlProperty("uuid", d->m_uuid));
|
||||
|
||||
d->m_pos = pos();
|
||||
|
||||
// Do not store terminal data in its own child
|
||||
QDomElement terminalDataElement = d->toXml(xml_document);
|
||||
for (int i=0; i < terminalDataElement.childNodes().length(); i++) {
|
||||
qdo.appendChild(terminalDataElement.childNodes().at(i).cloneNode()); // cloneNode() is important, otherwise no deep clone is made
|
||||
}
|
||||
QDomDocument doc = e.ownerDocument();
|
||||
e.appendChild(d->toXml(doc));
|
||||
|
||||
return qdo;
|
||||
}
|
||||
|
||||
bool PartTerminal::valideXml(QDomElement& element) {
|
||||
|
||||
@@ -56,8 +56,8 @@ class PartTerminal : public CustomElementGraphicPart
|
||||
*/
|
||||
int type() const override { return Type; }
|
||||
QString xmlName() const override { return(QString("terminal")); }
|
||||
bool fromXml(const QDomElement &) override;
|
||||
QDomElement toXml(QDomDocument &) const override;
|
||||
bool fromXmlPriv(const QDomElement &) override;
|
||||
void toXmlPriv(QDomElement&) const override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||
|
||||
@@ -67,7 +67,7 @@ PartText::~PartText()
|
||||
Importe les proprietes d'un texte statique depuis un element XML
|
||||
@param xml_element Element XML a lire
|
||||
*/
|
||||
bool PartText::fromXml(const QDomElement &xml_element)
|
||||
bool PartText::fromXmlPriv(const QDomElement &xml_element)
|
||||
{
|
||||
int size;
|
||||
QString font;
|
||||
@@ -117,18 +117,16 @@ bool PartText::fromXml(const QDomElement &xml_element)
|
||||
@param xml_document Document XML a utiliser pour creer l'element XML
|
||||
@return un element XML decrivant le texte statique
|
||||
*/
|
||||
QDomElement PartText::toXml(QDomDocument &xml_document) const
|
||||
void PartText::toXmlPriv(QDomElement& e) const
|
||||
{
|
||||
QDomElement xml_element = xml_document.createElement(xmlName());
|
||||
//QDomElement xml_element = xml_document.createElement(xmlName());
|
||||
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "x", pos().x()));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "y", pos().y()));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "text", toPlainText()));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "font", font().toString()));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "rotation", rotation()));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "color", defaultTextColor().name()));
|
||||
|
||||
return(xml_element);
|
||||
e.appendChild(createXmlProperty("x", pos().x()));
|
||||
e.appendChild(createXmlProperty("y", pos().y()));
|
||||
e.appendChild(createXmlProperty("text", toPlainText()));
|
||||
e.appendChild(createXmlProperty("font", font().toString()));
|
||||
e.appendChild(createXmlProperty("rotation", rotation()));
|
||||
e.appendChild(createXmlProperty("color", defaultTextColor().name()));
|
||||
}
|
||||
|
||||
bool PartText::valideXml(QDomElement& element) {
|
||||
|
||||
@@ -59,11 +59,11 @@ class PartText : public QGraphicsTextItem, public CustomElementPart {
|
||||
int type() const override { return Type; }
|
||||
QString name() const override { return(QObject::tr("texte", "element part name")); }
|
||||
QString xmlName() const override { return(QString("text")); }
|
||||
bool fromXml(const QDomElement &) override;
|
||||
bool fromXmlPriv(const QDomElement &) override;
|
||||
static bool valideXml(QDomElement& element);
|
||||
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||
QDomElement toXml(QDomDocument &) const override;
|
||||
void toXmlPriv(QDomElement&) const override;
|
||||
void setRotation(qreal angle) {(QGraphicsObject::setRotation(QET::correctAngle(angle)));}
|
||||
bool isUseless() const override;
|
||||
QRectF sceneGeometricRect() const override;
|
||||
|
||||
@@ -29,9 +29,8 @@ void ElementData::fromSettings(QSettings &settings, const QString& prefix) {
|
||||
Q_UNUSED(prefix)
|
||||
}
|
||||
|
||||
QDomElement ElementData::toXml(QDomDocument &xml_element) const {
|
||||
Q_UNUSED(xml_element)
|
||||
return QDomElement();
|
||||
void ElementData::toXmlPriv(QDomElement& e) const {
|
||||
Q_UNUSED(e)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,7 +41,7 @@ QDomElement ElementData::toXml(QDomDocument &xml_element) const {
|
||||
* @param xml_element : tagName must be 'definition'
|
||||
* @return true is successfuly loaded
|
||||
*/
|
||||
bool ElementData::fromXml(const QDomElement &xml_element)
|
||||
bool ElementData::fromXmlPriv(const QDomElement &xml_element)
|
||||
{
|
||||
if(xml_element.tagName() != "definition" ||
|
||||
xml_element.attribute("type") != "element") {
|
||||
|
||||
@@ -87,8 +87,8 @@ class ElementData : public PropertiesInterface
|
||||
|
||||
void toSettings(QSettings &settings, const QString& prefix = QString()) const override;
|
||||
void fromSettings(QSettings &settings, const QString& prefix = QString()) override;
|
||||
QDomElement toXml(QDomDocument &xml_element) const override;
|
||||
bool fromXml(const QDomElement &xml_element) override;
|
||||
void toXmlPriv(QDomElement &) const override;
|
||||
bool fromXmlPriv(const QDomElement &xml_element) override;
|
||||
QDomElement kindInfoToXml(QDomDocument &document);
|
||||
|
||||
bool operator==(const ElementData &data) const;
|
||||
|
||||
@@ -28,12 +28,23 @@ namespace {
|
||||
const QString stringS = "string";
|
||||
const QString uuidS = "uuid";
|
||||
const QString colorS = "color";
|
||||
|
||||
const QString userPropertiesS = "userProperties";
|
||||
|
||||
PropertiesInterface::PropertyFlags debug(PropertiesInterface::PropertyFlags flag, const QDomElement &e, const QString& attribute_name, const QString& attr, const QString& type)
|
||||
{
|
||||
if (flag == PropertiesInterface::PropertyFlags::NoValidConversion)
|
||||
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "No valid Conversion: " << attribute_name << ". type: " << type << ". value: " << attr;
|
||||
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief PropertiesInterface::PropertiesInterface
|
||||
*/
|
||||
PropertiesInterface::PropertiesInterface()
|
||||
PropertiesInterface::PropertiesInterface(const QString &tagname):
|
||||
mTagName(tagname)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -44,12 +55,36 @@ PropertiesInterface::~PropertiesInterface()
|
||||
{
|
||||
}
|
||||
|
||||
void PropertiesInterface::setTagName(const QString& tagname)
|
||||
{
|
||||
mTagName = tagname;
|
||||
}
|
||||
|
||||
QDomElement PropertiesInterface::toXml (QDomDocument &xml_document) const
|
||||
{
|
||||
QDomElement element = xml_document.createElement(mTagName);
|
||||
toXmlPriv(element);
|
||||
propertiesToXml(element);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
bool PropertiesInterface::fromXml (const QDomElement &xml_element)
|
||||
{
|
||||
if (!fromXmlPriv(xml_element))
|
||||
return false;
|
||||
|
||||
if (!propertiesFromXml(xml_element))
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PropertiesInterface::valideXml(QDomElement& element) {
|
||||
qDebug(QString("ValideXml() is not implemented. File: %1, Line: %2").arg(__FILE__).arg(__LINE__).toStdString().data());
|
||||
return false;
|
||||
}
|
||||
|
||||
QDomElement PropertiesInterface::createXmlProperty(QDomDocument &doc, const QString& name, const QString value) {
|
||||
QDomElement PropertiesInterface::createXmlProperty(const QString& name, const QString value) {
|
||||
QDomDocument doc;
|
||||
QDomElement p = doc.createElement("property");
|
||||
p.setAttribute("name", name);
|
||||
p.setAttribute("type", stringS);
|
||||
@@ -57,7 +92,8 @@ QDomElement PropertiesInterface::createXmlProperty(QDomDocument &doc, const QStr
|
||||
return p;
|
||||
}
|
||||
|
||||
QDomElement PropertiesInterface::createXmlProperty(QDomDocument &doc, const QString& name, const char* value) {
|
||||
QDomElement PropertiesInterface::createXmlProperty(const QString& name, const char* value) {
|
||||
QDomDocument doc;
|
||||
QDomElement p = doc.createElement("property");
|
||||
p.setAttribute("name", name);
|
||||
p.setAttribute("type", stringS);
|
||||
@@ -65,7 +101,8 @@ QDomElement PropertiesInterface::createXmlProperty(QDomDocument &doc, const QStr
|
||||
return p;
|
||||
}
|
||||
|
||||
QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QString& name, const int value) {
|
||||
QDomElement PropertiesInterface::createXmlProperty(const QString& name, const int value) {
|
||||
QDomDocument doc;
|
||||
QDomElement p = doc.createElement("property");
|
||||
p.setAttribute("name", name);
|
||||
p.setAttribute("type", integerS);
|
||||
@@ -73,7 +110,8 @@ QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QStr
|
||||
return p;
|
||||
}
|
||||
|
||||
QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QString& name, const double value) {
|
||||
QDomElement PropertiesInterface::createXmlProperty(const QString& name, const double value) {
|
||||
QDomDocument doc;
|
||||
QDomElement p = doc.createElement("property");
|
||||
p.setAttribute("name", name);
|
||||
p.setAttribute("type", doubleS);
|
||||
@@ -81,7 +119,8 @@ QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QStr
|
||||
return p;
|
||||
}
|
||||
|
||||
QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QString& name, const bool value) {
|
||||
QDomElement PropertiesInterface::createXmlProperty(const QString& name, const bool value) {
|
||||
QDomDocument doc;
|
||||
QDomElement p = doc.createElement("property");
|
||||
p.setAttribute("name", name);
|
||||
p.setAttribute("type", boolS);
|
||||
@@ -89,7 +128,8 @@ QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QStr
|
||||
return p;
|
||||
}
|
||||
|
||||
QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QString& name, const QUuid value) {
|
||||
QDomElement PropertiesInterface::createXmlProperty(const QString& name, const QUuid value) {
|
||||
QDomDocument doc;
|
||||
QDomElement p = doc.createElement("property");
|
||||
p.setAttribute("name", name);
|
||||
p.setAttribute("type", uuidS);
|
||||
@@ -97,7 +137,8 @@ QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QStr
|
||||
return p;
|
||||
}
|
||||
|
||||
QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QString& name, const QColor value) {
|
||||
QDomElement PropertiesInterface::createXmlProperty(const QString& name, const QColor value) {
|
||||
QDomDocument doc;
|
||||
QDomElement p = doc.createElement("property");
|
||||
p.setAttribute("name", name);
|
||||
p.setAttribute("type", colorS);
|
||||
@@ -167,11 +208,14 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyInteger(const QD
|
||||
return PropertyFlags::NotFound;
|
||||
}
|
||||
|
||||
return debug(propertyInteger(attr, entier), e, attribute_name, attr, integerS);
|
||||
}
|
||||
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyInteger(const QString& value, int* entier) {
|
||||
// verifie la validite de l'attribut
|
||||
bool ok;
|
||||
int tmp = attr.toInt(&ok);
|
||||
int tmp = value.toInt(&ok);
|
||||
if (!ok) {
|
||||
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "No valid Conversion: " << attribute_name << ". type: " << integerS << ". value: " << attr;
|
||||
return PropertyFlags::NoValidConversion;
|
||||
}
|
||||
|
||||
@@ -189,11 +233,15 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyDouble(const QDo
|
||||
return PropertyFlags::NotFound;
|
||||
}
|
||||
|
||||
return debug(propertyDouble(attr, reel), e, attribute_name, attr, doubleS);
|
||||
}
|
||||
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyDouble(const QString& value, double* reel)
|
||||
{
|
||||
// verifie la validite de l'attribut
|
||||
bool ok;
|
||||
double tmp = attr.toDouble(&ok);
|
||||
double tmp = value.toDouble(&ok);
|
||||
if (!ok) {
|
||||
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "No valid Conversion: " << attribute_name << ". type: " << doubleS << ". value: " << attr;
|
||||
return PropertyFlags::NoValidConversion;
|
||||
}
|
||||
|
||||
@@ -211,16 +259,20 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyBool(const QDomE
|
||||
return PropertyFlags::NotFound;
|
||||
}
|
||||
|
||||
return debug(propertyBool(attr, boolean), e, attribute_name, attr, boolS);
|
||||
}
|
||||
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyBool(const QString& value, bool* boolean)
|
||||
{
|
||||
// verifie la validite de l'attribut
|
||||
bool ok;
|
||||
bool tmp = attr.toInt(&ok);
|
||||
bool tmp = value.toInt(&ok);
|
||||
if (!ok) {
|
||||
if (attr == "true" || attr == "1")
|
||||
if (value == "true" || value == "1")
|
||||
tmp = true;
|
||||
else if (attr == "false" || attr == "0")
|
||||
else if (value == "false" || value == "0")
|
||||
tmp = false;
|
||||
else {
|
||||
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "No valid Conversion: " << attribute_name << ". type: " << integerS << ". value: " << attr;
|
||||
return PropertyFlags::NoValidConversion;
|
||||
}
|
||||
}
|
||||
@@ -239,10 +291,14 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyColor(const QDom
|
||||
return PropertyFlags::NotFound;
|
||||
}
|
||||
|
||||
return debug(propertyColor(attr, color), e, attribute_name, attr, colorS);
|
||||
}
|
||||
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyColor(const QString& value, QColor* color)
|
||||
{
|
||||
// verifie la validite de l'attribut
|
||||
QColor tmp = QColor(attr);
|
||||
QColor tmp = QColor(value);
|
||||
if (!tmp.isValid()) {
|
||||
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "No valid Conversion: " << attribute_name << ". type: " << colorS << ". value: " << attr;
|
||||
return PropertyFlags::NoValidConversion;
|
||||
}
|
||||
|
||||
@@ -259,14 +315,18 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyUuid(const QDomE
|
||||
return PropertyFlags::NotFound;
|
||||
}
|
||||
|
||||
if (QUuid(attr).isNull()){
|
||||
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "No valid Conversion: " << attribute_name << ". type: " << uuidS << ". value: " << attr;
|
||||
return debug(propertyUuid(attr, uuid), e, attribute_name, attr, uuidS);
|
||||
}
|
||||
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyUuid(const QString& value, QUuid* uuid)
|
||||
{
|
||||
if (QUuid(value).isNull()){
|
||||
return PropertyFlags::NoValidConversion;
|
||||
}
|
||||
|
||||
|
||||
if (uuid != nullptr)
|
||||
*uuid = QUuid(attr);
|
||||
*uuid = QUuid(value);
|
||||
|
||||
return PropertyFlags::Success;
|
||||
}
|
||||
@@ -336,3 +396,110 @@ QString PropertiesInterface::orientationToString(Qet::Orientation o) {
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief PropertiesInterface::propertiesToXml
|
||||
* Write all user properties to the DomElement \p e
|
||||
* \param e
|
||||
*/
|
||||
void PropertiesInterface::propertiesToXml(QDomElement& e) const
|
||||
{
|
||||
QDomDocument doc = e.ownerDocument();
|
||||
auto up = doc.createElement(userPropertiesS);
|
||||
for (auto i = properties.begin(); i != properties.end(); ++i)
|
||||
{
|
||||
auto type = i.value().type();
|
||||
switch(type) {
|
||||
case QVariant::Type::String:
|
||||
up.appendChild(createXmlProperty(i.key(), i.value().toString())); break;
|
||||
case QVariant::Type::Int:
|
||||
up.appendChild(createXmlProperty(i.key(), i.value().toInt())); break;
|
||||
case QVariant::Type::Double:
|
||||
up.appendChild(createXmlProperty(i.key(), i.value().toDouble())); break;
|
||||
case QVariant::Type::Bool:
|
||||
up.appendChild(createXmlProperty(i.key(), i.value().toBool())); break;
|
||||
// case QVariant::Type::Color:
|
||||
// // TODO: correct?
|
||||
// up.appendChild(createXmlProperty(i.key(), i.value().toString())); break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
e.appendChild(up);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief PropertiesInterface::propertiesFromXml
|
||||
* Read all user properties from the DomElement& e
|
||||
* \param e
|
||||
* \return
|
||||
*/
|
||||
bool PropertiesInterface::propertiesFromXml(const QDomElement& e)
|
||||
{
|
||||
QDomNodeList l = e.childNodes();
|
||||
for (int i=0; i < l.count(); i++)
|
||||
{
|
||||
QDomElement userProperties = l.at(i).toElement();
|
||||
if (userProperties.tagName() != userPropertiesS)
|
||||
continue;
|
||||
|
||||
QDomElement userProperty;
|
||||
for (int up_index = 0; up_index < userProperties.childNodes().length(); up_index++)
|
||||
{
|
||||
userProperty = userProperties.childNodes().at(up_index).toElement();
|
||||
|
||||
QString name = userProperty.attribute("name");
|
||||
QString type = userProperty.attribute("type");
|
||||
QString value = userProperty.attribute("value");
|
||||
|
||||
if (type == integerS)
|
||||
{
|
||||
int i;
|
||||
if (propertyInteger(value, &i) == PropertyFlags::Success)
|
||||
properties[name] = QVariant(i);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else if (type == doubleS)
|
||||
{
|
||||
double d;
|
||||
if (propertyDouble(value, &d) == PropertyFlags::Success)
|
||||
properties[name] = QVariant(d);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else if (type == boolS)
|
||||
{
|
||||
bool b;
|
||||
if (propertyBool(value, &b) == PropertyFlags::Success)
|
||||
properties[name] = QVariant(b);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else if (type == uuidS)
|
||||
{
|
||||
QUuid u;
|
||||
if (propertyUuid(value, &u) == PropertyFlags::Success)
|
||||
properties[name] = QVariant(u);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else if (type == colorS)
|
||||
{
|
||||
QColor c;
|
||||
if (propertyColor(value, &c) == PropertyFlags::Success)
|
||||
properties[name] = QVariant(c);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else if (type == stringS)
|
||||
{
|
||||
properties[name] = QVariant(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "Not a valid property type!";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,52 @@
|
||||
#include "sources/qet.h"
|
||||
#include <QUuid>
|
||||
|
||||
//struct Property {
|
||||
// enum class Type {
|
||||
// String,
|
||||
// Int,
|
||||
// Double,
|
||||
// Bool,
|
||||
// Uuid,
|
||||
// Color
|
||||
// };
|
||||
// Property(enum Type type, QVariant& value): type(type), value(value) {};
|
||||
// enum Type type;
|
||||
// QVariant value;
|
||||
//};
|
||||
|
||||
//class Property_T
|
||||
//{
|
||||
//public:
|
||||
// enum class Type {
|
||||
// String,
|
||||
// Int,
|
||||
// Double,
|
||||
// Bool,
|
||||
// Uuid,
|
||||
// Color
|
||||
// };
|
||||
// Property_T(enum Type type): mType(type)
|
||||
// {}
|
||||
//public:
|
||||
// enum Type mType;
|
||||
//};
|
||||
|
||||
//class PropertyDouble: Property_T
|
||||
//{
|
||||
//public:
|
||||
// PropertyDouble(double& value): Property_T(Property_T::Type::Double), mValue(value) {};
|
||||
//public:
|
||||
// double mValue;
|
||||
//};
|
||||
|
||||
class DomElement: public QDomElement
|
||||
{
|
||||
public:
|
||||
DomElement(): QDomElement() {};
|
||||
DomElement(QDomElement& e): QDomElement(e) {};
|
||||
};
|
||||
|
||||
/**
|
||||
@brief The PropertiesInterface class
|
||||
This class is an interface for have common way
|
||||
@@ -34,7 +80,7 @@
|
||||
class PropertiesInterface
|
||||
{
|
||||
public:
|
||||
PropertiesInterface();
|
||||
PropertiesInterface(const QString& tagname = "Properties");
|
||||
virtual ~PropertiesInterface();
|
||||
/**
|
||||
@brief toSettings
|
||||
@@ -60,26 +106,26 @@ class PropertiesInterface
|
||||
@param xml_document
|
||||
@return QDomElement
|
||||
*/
|
||||
virtual QDomElement toXml (QDomDocument &xml_document) const =0;
|
||||
virtual QDomElement toXml (QDomDocument &xml_document) const;
|
||||
/**
|
||||
@brief fromXml
|
||||
load properties to xml element
|
||||
@param xml_element
|
||||
@return true / false
|
||||
*/
|
||||
virtual bool fromXml (const QDomElement &xml_element) =0;
|
||||
virtual bool fromXml (const QDomElement &xml_element);
|
||||
static bool valideXml(QDomElement& element);
|
||||
|
||||
/*!
|
||||
* Use this functions to add properties to the xml document
|
||||
*/
|
||||
static QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const QString value);
|
||||
static QDomElement createXmlProperty(QDomDocument &doc, const QString& name, const char* value);
|
||||
static QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const int value);
|
||||
static QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const double value);
|
||||
static QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const bool value);
|
||||
static QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const QUuid value);
|
||||
static QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const QColor value);
|
||||
static QDomElement createXmlProperty(const QString& name, const QString value);
|
||||
static QDomElement createXmlProperty(const QString& name, const char* value);
|
||||
static QDomElement createXmlProperty(const QString& name, const int value);
|
||||
static QDomElement createXmlProperty(const QString& name, const double value);
|
||||
static QDomElement createXmlProperty(const QString& name, const bool value);
|
||||
static QDomElement createXmlProperty(const QString& name, const QUuid value);
|
||||
static QDomElement createXmlProperty(const QString& name, const QColor value);
|
||||
|
||||
static QDomElement property(const QDomElement& e, const QString& name);
|
||||
static bool attribute(const QDomElement& e, const QString& attribute_name, const QString& type, QString* attr);
|
||||
@@ -91,17 +137,23 @@ class PropertiesInterface
|
||||
// = 4
|
||||
};
|
||||
|
||||
static PropertyFlags propertyInteger(const QString& value, int* entry = nullptr);
|
||||
static PropertyFlags propertyInteger(const QDomElement &e, const QString& attribute_name, int *entier = nullptr);
|
||||
static PropertyFlags propertyDouble(const QString& value, double* entry = nullptr);
|
||||
static PropertyFlags propertyDouble(const QDomElement &e, const QString& attribute_name, double *reel = nullptr);
|
||||
static PropertyFlags propertyString(const QDomElement& e, const QString& attribute_name, QString* string = nullptr);
|
||||
static PropertyFlags propertyBool(const QString& value, bool* entry = nullptr);
|
||||
static PropertyFlags propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean = nullptr);
|
||||
static PropertyFlags propertyUuid(const QString& value, QUuid* entry = nullptr);
|
||||
static PropertyFlags propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid = nullptr);
|
||||
static PropertyFlags propertyColor(const QString& value, QColor* entry = nullptr);
|
||||
static PropertyFlags propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color = nullptr);
|
||||
|
||||
|
||||
static bool validXmlProperty(const QDomElement& e);
|
||||
|
||||
QVariant XmlProperty(const QDomElement& element);
|
||||
void setTagName(const QString& tagname);
|
||||
|
||||
/**
|
||||
Permet de convertir une chaine de caracteres ("n", "s", "e" ou "w")
|
||||
@@ -118,6 +170,15 @@ class PropertiesInterface
|
||||
@return une chaine de caractere representant l'orientation
|
||||
*/
|
||||
static QString orientationToString(Qet::Orientation o);
|
||||
|
||||
private:
|
||||
virtual void toXmlPriv (QDomElement &e) const =0;
|
||||
virtual bool fromXmlPriv (const QDomElement &e) =0;
|
||||
void propertiesToXml(QDomElement& e) const;
|
||||
bool propertiesFromXml (const QDomElement &e);
|
||||
|
||||
QHash<QString, QVariant> properties;
|
||||
QString mTagName{""};
|
||||
};
|
||||
|
||||
#endif // PROPERTIESINTERFACE_H
|
||||
|
||||
@@ -21,13 +21,13 @@
|
||||
#include <QDebug>
|
||||
|
||||
TerminalData::TerminalData():
|
||||
PropertiesInterface()
|
||||
PropertiesInterface("terminaldata")
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
TerminalData::TerminalData(QGraphicsObject *parent):
|
||||
PropertiesInterface(),
|
||||
PropertiesInterface("terminaldata"),
|
||||
q(parent)
|
||||
{
|
||||
init();
|
||||
@@ -81,35 +81,33 @@ void TerminalData::fromSettings(QSettings &settings, const QString& prefix)
|
||||
}
|
||||
|
||||
/**
|
||||
@brief TerminalData::toXml
|
||||
@brief TerminalData::toXmlPriv
|
||||
Save properties to xml element
|
||||
write the name, number, position and orientation of the terminal
|
||||
to xml_element
|
||||
|
||||
@note This method is only called from the PartTerminal
|
||||
and should never called from the Terminal class
|
||||
@param xml_document
|
||||
@return xml_element : DomElement with
|
||||
@param e: element to store the properties
|
||||
the name, number, position and orientation of the terminal
|
||||
*/
|
||||
QDomElement TerminalData::toXml(QDomDocument &xml_document) const
|
||||
void TerminalData::toXmlPriv(QDomElement& e) const
|
||||
{
|
||||
QDomElement xml_element = xml_document.createElement("terminaldata");
|
||||
// TODO:
|
||||
//QDomElement xml_element = xml_document.createElement("terminaldata");
|
||||
|
||||
// m_pos cannot be stored, because in the partterminal it will not be updated.
|
||||
// In PartTerminal m_pos is the position of the dock, in Terminal m_pos is the second side of the terminal
|
||||
// This is hold for legacy compability reason
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "x", m_pos.x()));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "y", m_pos.y()));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "name", m_name));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "orientation", orientationToString(m_orientation)));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "type", typeToString(m_type)));
|
||||
|
||||
return(xml_element);
|
||||
e.appendChild(createXmlProperty("x", m_pos.x()));
|
||||
e.appendChild(createXmlProperty("y", m_pos.y()));
|
||||
e.appendChild(createXmlProperty("name", m_name));
|
||||
e.appendChild(createXmlProperty("orientation", orientationToString(m_orientation)));
|
||||
e.appendChild(createXmlProperty("type", typeToString(m_type)));
|
||||
}
|
||||
|
||||
/*
|
||||
@brief TerminalData::fromXml
|
||||
@brief TerminalData::fromXmlPriv
|
||||
load properties to xml element
|
||||
|
||||
@note This method is only called from the PartTerminal
|
||||
@@ -117,7 +115,7 @@ QDomElement TerminalData::toXml(QDomDocument &xml_document) const
|
||||
@param xml_element
|
||||
@return true if succeeded / false if the attribute is not real
|
||||
*/
|
||||
bool TerminalData::fromXml (const QDomElement &xml_element) // RETURNS True
|
||||
bool TerminalData::fromXmlPriv(const QDomElement &xml_element)
|
||||
{
|
||||
qreal term_x = 0.0;
|
||||
qreal term_y = 0.0;
|
||||
|
||||
@@ -56,8 +56,8 @@ class TerminalData : public PropertiesInterface
|
||||
const QString& prefix = QString()) const override;
|
||||
void fromSettings(QSettings &settings,
|
||||
const QString& = QString()) override;
|
||||
QDomElement toXml(QDomDocument &xml_element) const override;
|
||||
bool fromXml(const QDomElement &xml_element) override;
|
||||
void toXmlPriv(QDomElement &) const override;
|
||||
bool fromXmlPriv(const QDomElement &xml_element) override;
|
||||
|
||||
static bool valideXml(const QDomElement &xml_element);
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
*/
|
||||
XRefProperties::XRefProperties()
|
||||
{
|
||||
setTagName("xref");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,36 +93,32 @@ void XRefProperties::fromSettings(QSettings &settings,
|
||||
@param xml_document : QDomElement to use for saving
|
||||
@return QDomElement
|
||||
*/
|
||||
QDomElement XRefProperties::toXml(QDomDocument &xml_document) const
|
||||
void XRefProperties::toXmlPriv(QDomElement& e) const
|
||||
{
|
||||
|
||||
QDomElement xml_element = xml_document.createElement("xref");
|
||||
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "type", m_key));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "showpowerctc", m_show_power_ctc));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "displayhas", m_display == Cross? "cross" : "contacts"));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "snapto", m_snap_to == Bottom? "bottom" : "label"));
|
||||
e.appendChild(createXmlProperty("type", m_key));
|
||||
e.appendChild(createXmlProperty("showpowerctc", m_show_power_ctc));
|
||||
e.appendChild(createXmlProperty("displayhas", m_display == Cross? "cross" : "contacts"));
|
||||
e.appendChild(createXmlProperty("snapto", m_snap_to == Bottom? "bottom" : "label"));
|
||||
|
||||
|
||||
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "xrefpos", var.valueToKey(m_xref_pos)));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "offset", m_offset));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "master_label", m_master_label));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "slave_label", m_slave_label));
|
||||
e.appendChild(createXmlProperty("xrefpos", var.valueToKey(m_xref_pos)));
|
||||
e.appendChild(createXmlProperty("offset", m_offset));
|
||||
e.appendChild(createXmlProperty("master_label", m_master_label));
|
||||
e.appendChild(createXmlProperty("slave_label", m_slave_label));
|
||||
|
||||
foreach (QString key, m_prefix.keys()) {
|
||||
xml_element.appendChild(createXmlProperty(xml_document, key + "prefix", m_prefix.value(key)));
|
||||
e.appendChild(createXmlProperty(key + "prefix", m_prefix.value(key)));
|
||||
}
|
||||
|
||||
return xml_element;
|
||||
}
|
||||
|
||||
/** RETURNS True
|
||||
@brief XRefProperties::fromXml
|
||||
@brief XRefProperties::fromXmlPriv
|
||||
Load from xml
|
||||
@param xml_element: QDomElement to use for load
|
||||
*/
|
||||
bool XRefProperties::fromXml(const QDomElement &xml_element) {
|
||||
bool XRefProperties::fromXmlPriv(const QDomElement &xml_element) {
|
||||
|
||||
if (propertyBool(xml_element, "showpowerctc", &m_show_power_ctc))
|
||||
return false;
|
||||
|
||||
@@ -45,8 +45,8 @@ class XRefProperties : public PropertiesInterface
|
||||
void toSettings (QSettings &settings, const QString& = QString()) const override;
|
||||
void fromSettings (QSettings &settings,
|
||||
const QString& = QString()) override;
|
||||
QDomElement toXml (QDomDocument &xml_document) const override;
|
||||
bool fromXml(const QDomElement &xml_element) override;
|
||||
void toXmlPriv(QDomElement&) const override;
|
||||
bool fromXmlPriv(const QDomElement &xml_element) override;
|
||||
|
||||
static QHash<QString, XRefProperties> defaultProperties();
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ Conductor::Conductor(Terminal *p1, Terminal* p2) :
|
||||
terminal1(p1),
|
||||
terminal2(p2)
|
||||
{
|
||||
setTagName("conductor");
|
||||
//set Zvalue at 11 to be upper than the DiagramImageItem and element
|
||||
setZValue(11);
|
||||
m_previous_z_value = zValue();
|
||||
@@ -962,7 +963,7 @@ void Conductor::pointsToSegments(const QList<QPointF>& points_list) {
|
||||
@param dom_element
|
||||
@return true is loading success else return false
|
||||
*/
|
||||
bool Conductor::fromXml(const QDomElement &dom_element)
|
||||
bool Conductor::fromXmlPriv(const QDomElement &dom_element)
|
||||
{
|
||||
// TODO: seems to short!
|
||||
double x=0, y=0;
|
||||
@@ -990,7 +991,7 @@ bool Conductor::fromXml(const QDomElement &dom_element)
|
||||
|
||||
// does not support legacy method
|
||||
/*!
|
||||
@brief Conductor::toXml
|
||||
@brief Conductor::toXmlPriv
|
||||
Exporte les caracteristiques du conducteur sous forme d'une element XML.
|
||||
@param dom_document :
|
||||
Le document XML a utiliser pour creer l'element XML
|
||||
@@ -999,12 +1000,10 @@ bool Conductor::fromXml(const QDomElement &dom_element)
|
||||
bornes dans le document XML et leur adresse en memoire
|
||||
@return Un element XML representant le conducteur
|
||||
*/
|
||||
QDomElement Conductor::toXml(QDomDocument & doc) const {
|
||||
QDomElement dom_element = doc.createElement("conductor");
|
||||
void Conductor::toXmlPriv(QDomElement& e) const {
|
||||
|
||||
|
||||
dom_element.appendChild(createXmlProperty(doc, "x", pos().x()));
|
||||
dom_element.appendChild(createXmlProperty(doc, "y", pos().y()));
|
||||
e.appendChild(createXmlProperty("x", pos().x()));
|
||||
e.appendChild(createXmlProperty("y", pos().y()));
|
||||
|
||||
// Terminal is uniquely identified by the uuid of the terminal and the element
|
||||
QUuid terminal = terminal1->uuid();
|
||||
@@ -1013,10 +1012,10 @@ QDomElement Conductor::toXml(QDomDocument & doc) 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
|
||||
dom_element.appendChild(createXmlProperty(doc, "terminal1", terminal1->ID()));
|
||||
e.appendChild(createXmlProperty("terminal1", terminal1->ID()));
|
||||
} else {
|
||||
dom_element.appendChild(createXmlProperty(doc, "element1", terminalParent));
|
||||
dom_element.appendChild(createXmlProperty(doc, "terminal1", terminal));
|
||||
e.appendChild(createXmlProperty("element1", terminalParent));
|
||||
e.appendChild(createXmlProperty("terminal1", terminal));
|
||||
}
|
||||
|
||||
terminal = terminal2->uuid();
|
||||
@@ -1025,13 +1024,15 @@ QDomElement Conductor::toXml(QDomDocument & doc) 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
|
||||
dom_element.appendChild(createXmlProperty(doc, "terminal2", terminal2->ID()));
|
||||
e.appendChild(createXmlProperty("terminal2", terminal2->ID()));
|
||||
} else {
|
||||
dom_element.appendChild(createXmlProperty(doc, "element2", terminal2->parentElement()->uuid()));
|
||||
dom_element.appendChild(createXmlProperty(doc, "terminal2", terminal2->uuid()));
|
||||
e.appendChild(createXmlProperty("element2", terminal2->parentElement()->uuid()));
|
||||
e.appendChild(createXmlProperty("terminal2", terminal2->uuid()));
|
||||
}
|
||||
|
||||
dom_element.appendChild(createXmlProperty(doc, "freezeLabel", m_freeze_label));
|
||||
e.appendChild(createXmlProperty("freezeLabel", m_freeze_label));
|
||||
|
||||
QDomDocument doc;
|
||||
|
||||
// on n'exporte les segments du conducteur que si ceux-ci ont
|
||||
// ete modifies par l'utilisateur
|
||||
@@ -1042,25 +1043,23 @@ QDomElement Conductor::toXml(QDomDocument & doc) const {
|
||||
foreach(ConductorSegment *segment, segmentsList())
|
||||
{
|
||||
current_segment = doc.createElement("segment");
|
||||
current_segment.appendChild(createXmlProperty(doc, "orientation", segment->isHorizontal() ? "horizontal": "vertical"));
|
||||
current_segment.appendChild(createXmlProperty(doc, "length", segment -> length()));
|
||||
dom_element.appendChild(current_segment);
|
||||
current_segment.appendChild(createXmlProperty("orientation", segment->isHorizontal() ? "horizontal": "vertical"));
|
||||
current_segment.appendChild(createXmlProperty("length", segment -> length()));
|
||||
e.appendChild(current_segment);
|
||||
}
|
||||
}
|
||||
|
||||
QDomElement dom_seq = m_autoNum_seq.toXml(doc); // swquentialNumbers tag
|
||||
dom_element.appendChild(dom_seq);
|
||||
e.appendChild(dom_seq);
|
||||
|
||||
// Export the properties and text
|
||||
QDomElement conductorProperties = m_properties.toXml(doc);
|
||||
for (int i=0; i < conductorProperties.childNodes().count(); i++) {
|
||||
QDomNode node = conductorProperties.childNodes().at(i).cloneNode(); // cloneNode() is important!
|
||||
dom_element.appendChild(node);
|
||||
e.appendChild(node);
|
||||
}
|
||||
|
||||
m_text_item->toXml(doc, dom_element);
|
||||
|
||||
return(dom_element);
|
||||
m_text_item->toXml(e);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -102,8 +102,8 @@ class Conductor : public QGraphicsObject, public PropertiesInterface
|
||||
|
||||
public:
|
||||
static bool valideXml (QDomElement &);
|
||||
bool fromXml (const QDomElement &) override;
|
||||
QDomElement toXml (QDomDocument &doc) const override;
|
||||
bool fromXmlPriv(const QDomElement &) override;
|
||||
void toXmlPriv(QDomElement&) const override;
|
||||
void toSettings(QSettings &, const QString & = QString()) const override {}
|
||||
void fromSettings(QSettings &, const QString & = QString()) override {}
|
||||
private:
|
||||
|
||||
@@ -61,14 +61,14 @@ Conductor *ConductorTextItem::parentConductor() const
|
||||
return(parent_conductor_);
|
||||
}
|
||||
|
||||
void ConductorTextItem::toXml(QDomDocument& doc, QDomElement& e) {
|
||||
void ConductorTextItem::toXml(QDomElement& e) {
|
||||
if(moved_by_user_)
|
||||
{
|
||||
e.appendChild(PropertiesInterface::createXmlProperty(doc, "userx", pos().x()));
|
||||
e.appendChild(PropertiesInterface::createXmlProperty(doc, "usery", pos().y()));
|
||||
e.appendChild(PropertiesInterface::createXmlProperty("userx", pos().x()));
|
||||
e.appendChild(PropertiesInterface::createXmlProperty("usery", pos().y()));
|
||||
}
|
||||
if(rotate_by_user_)
|
||||
e.appendChild(PropertiesInterface::createXmlProperty(doc, "rotation", rotation()));
|
||||
e.appendChild(PropertiesInterface::createXmlProperty("rotation", rotation()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ class ConductorTextItem : public DiagramTextItem
|
||||
enum { Type = UserType + 1006 };
|
||||
Conductor *parentConductor() const;
|
||||
void fromXml(const QDomElement &) override;
|
||||
void toXml(QDomDocument& doc, QDomElement& e);
|
||||
void toXml(QDomElement& e);
|
||||
int type() const override { return Type; }
|
||||
virtual bool wasMovedByUser() const;
|
||||
virtual bool wasRotateByUser() const;
|
||||
|
||||
@@ -86,7 +86,7 @@ DynamicElementTextItem::DynamicElementTextItem()
|
||||
@param dom_doc
|
||||
@return
|
||||
*/
|
||||
QDomElement DynamicElementTextItem::toXml(QDomDocument &dom_doc) const
|
||||
QDomElement DynamicElementTextItem::toXml(QDomDocument& dom_doc) const
|
||||
{
|
||||
QDomElement root_element = dom_doc.createElement(xmlTagName());
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ class DynamicElementTextItem : public DiagramTextItem
|
||||
DynamicElementTextItem(const DynamicElementTextItem &);
|
||||
|
||||
public:
|
||||
QDomElement toXml(QDomDocument &dom_doc) const override;
|
||||
QDomElement toXml(QDomDocument&) const override;
|
||||
void fromXml(const QDomElement &dom_elmt) override;
|
||||
|
||||
Element *parentElement() const;
|
||||
|
||||
@@ -40,7 +40,7 @@ class IndependentTextItem : public DiagramTextItem
|
||||
int type() const override { return Type; }
|
||||
|
||||
void fromXml(const QDomElement &) override;
|
||||
QDomElement toXml(QDomDocument &) const override;
|
||||
QDomElement toXml(QDomDocument&) const override;
|
||||
|
||||
protected:
|
||||
void focusOutEvent(QFocusEvent *event) override;
|
||||
|
||||
@@ -92,6 +92,7 @@ void Terminal::init(
|
||||
QString name,
|
||||
bool hiddenName)
|
||||
{
|
||||
setTagName("terminal");
|
||||
// definition du pount d'amarrage pour un conducteur
|
||||
d->m_pos = pf;
|
||||
|
||||
@@ -750,34 +751,22 @@ QList<Conductor *> Terminal::conductors() const
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Terminal::toXml
|
||||
@brief Terminal::toXmlPriv
|
||||
Methode d'export en XML
|
||||
@param doc Le Document XML a utiliser pour creer l'element XML
|
||||
@return un QDomElement representant cette borne
|
||||
*/
|
||||
QDomElement Terminal::toXml(QDomDocument &doc) const
|
||||
void Terminal::toXmlPriv(QDomElement &qdo) const
|
||||
{
|
||||
QDomElement qdo = doc.createElement("terminal");
|
||||
|
||||
qdo.appendChild(createXmlProperty(doc, "number", number_terminal_));
|
||||
qdo.appendChild(createXmlProperty(doc, "nameHidden", name_terminal_hidden));
|
||||
|
||||
// store terminal data too!
|
||||
qdo.appendChild(createXmlProperty("number", number_terminal_));
|
||||
qdo.appendChild(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.
|
||||
QPointF tempPos = d->m_pos;
|
||||
d->m_pos = dock_elmt_;
|
||||
QDomElement terminalDataElement = d->toXml(doc);
|
||||
d->toXmlPriv(qdo); // TerminalData
|
||||
d->m_pos = tempPos;
|
||||
|
||||
int childsCount = terminalDataElement.childNodes().count();
|
||||
for (int i=0; i < childsCount; i++) {
|
||||
QDomNode node = terminalDataElement.childNodes().at(i).cloneNode(); // cloneNode() is important, otherwise no deep clone is made
|
||||
qdo.appendChild(node);
|
||||
}
|
||||
|
||||
return(qdo);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -812,7 +801,7 @@ bool Terminal::valideXml(const QDomElement &terminal)
|
||||
@return true si la borne "se reconnait"
|
||||
(memes coordonnes, meme orientation), false sinon
|
||||
*/
|
||||
bool Terminal::fromXml(const QDomElement &terminal) {
|
||||
bool Terminal::fromXmlPriv(const QDomElement &terminal) {
|
||||
propertyString(terminal, "number", &number_terminal_);
|
||||
|
||||
propertyBool(terminal, "nameHidden", &name_terminal_hidden);
|
||||
|
||||
@@ -100,8 +100,8 @@ class Terminal : public QGraphicsObject, public PropertiesInterface
|
||||
|
||||
// methods related to XML import/export
|
||||
static bool valideXml(const QDomElement &);
|
||||
bool fromXml (const QDomElement &) override;
|
||||
QDomElement toXml (QDomDocument &) const override;
|
||||
bool fromXmlPriv (const QDomElement &) override;
|
||||
void toXmlPriv(QDomElement &) const override;
|
||||
|
||||
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
|
||||
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
|
||||
|
||||
@@ -65,28 +65,25 @@ bool TitleBlockProperties::operator!=(const TitleBlockProperties &ip) {
|
||||
return(!(*this == ip));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Exporte le cartouche sous formes d'attributs XML ajoutes a l'element e.
|
||||
@param e Element XML auquel seront ajoutes des attributs
|
||||
*/
|
||||
void TitleBlockProperties::toXml(QDomElement &e) const
|
||||
{
|
||||
e.setAttribute("author", author);
|
||||
e.setAttribute("title", title);
|
||||
e.setAttribute("filename", filename);
|
||||
e.setAttribute("plant", plant);
|
||||
e.setAttribute("locmach", locmach);
|
||||
e.setAttribute("indexrev",indexrev);
|
||||
e.setAttribute("version", version);
|
||||
e.setAttribute("folio", folio);
|
||||
e.setAttribute("auto_page_num", auto_page_num);
|
||||
e.setAttribute("date", exportDate());
|
||||
e.setAttribute("displayAt", (display_at == Qt::BottomEdge? "bottom" : "right"));
|
||||
void TitleBlockProperties::toXmlPriv(QDomElement& e) const {
|
||||
e.appendChild(createXmlProperty("author", author));
|
||||
e.appendChild(createXmlProperty("title", title));
|
||||
e.appendChild(createXmlProperty("filename", filename));
|
||||
e.appendChild(createXmlProperty("plant", plant));
|
||||
e.appendChild(createXmlProperty("locmach", locmach));
|
||||
e.appendChild(createXmlProperty("indexrev", indexrev));
|
||||
e.appendChild(createXmlProperty("version", version));
|
||||
e.appendChild(createXmlProperty("folio", folio));
|
||||
e.appendChild(createXmlProperty("date", exportDate()));
|
||||
e.appendChild(createXmlProperty("display_at", display_at == Qt::BottomEdge? "bottom" : "right"));
|
||||
if (!template_name.isEmpty())
|
||||
{
|
||||
e.setAttribute("titleblocktemplate", template_name);
|
||||
e.setAttribute("titleblocktemplateCollection", QET::qetCollectionToString(collection));
|
||||
e.appendChild(createXmlProperty("titleblocktemplate", template_name));
|
||||
e.appendChild(createXmlProperty("titleblocktemplateCollection", QET::qetCollectionToString(collection)));
|
||||
}
|
||||
|
||||
if (context.keys().count()) {
|
||||
@@ -94,19 +91,14 @@ void TitleBlockProperties::toXml(QDomElement &e) const
|
||||
context.toXml(properties);
|
||||
e.appendChild(properties);
|
||||
}
|
||||
}
|
||||
|
||||
QDomElement TitleBlockProperties::toXml(QDomDocument &d) const {
|
||||
Q_UNUSED(d)
|
||||
qDebug() << "NOT IMPLEMENTED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
|
||||
return QDomElement();
|
||||
}
|
||||
|
||||
/** RETURNS True
|
||||
Importe le cartouche a partir des attributs XML de l'element e
|
||||
@param e Element XML dont les attributs seront lus
|
||||
*/
|
||||
bool TitleBlockProperties::fromXml(const QDomElement &e) {
|
||||
bool TitleBlockProperties::fromXmlPriv(const QDomElement &e) {
|
||||
|
||||
|
||||
// reads the historical fields
|
||||
|
||||
@@ -41,9 +41,8 @@ class TitleBlockProperties: public PropertiesInterface {
|
||||
bool operator==(const TitleBlockProperties &);
|
||||
bool operator!=(const TitleBlockProperties &);
|
||||
|
||||
QDomElement toXml(QDomDocument &e) const override;
|
||||
void toXml(QDomElement &e) const;
|
||||
bool fromXml(const QDomElement &) override;
|
||||
void toXmlPriv(QDomElement &e) const override;
|
||||
bool fromXmlPriv(const QDomElement &) override;
|
||||
void toSettings(QSettings &, const QString & = QString()) const override;
|
||||
void fromSettings(QSettings &, const QString & = QString()) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user