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