mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 22:00:35 +01:00
update
This commit is contained in:
@@ -94,13 +94,17 @@ bool BorderProperties::operator!=(const BorderProperties &bp) {
|
|||||||
- XML element to which attributes will be added
|
- XML element to which attributes will be added
|
||||||
- Element XML auquel seront ajoutes des attributs
|
- Element XML auquel seront ajoutes des attributs
|
||||||
*/
|
*/
|
||||||
void BorderProperties::toXml(QDomElement &e) const {
|
QDomElement BorderProperties::toXml(QDomDocument &dom_doc) const {
|
||||||
e.setAttribute("cols", columns_count);
|
|
||||||
e.setAttribute("colsize", QString("%1").arg(columns_width));
|
QDomElement e = dom_doc.createElement("border");
|
||||||
e.setAttribute("rows", rows_count);
|
|
||||||
e.setAttribute("rowsize", QString("%1").arg(rows_height));
|
e.appendChild(createXmlProperty(dom_doc, "cols", columns_count));
|
||||||
e.setAttribute("displaycols", display_columns ? "true" : "false");
|
e.appendChild(createXmlProperty(dom_doc, "colsize", columns_width));
|
||||||
e.setAttribute("displayrows", display_rows ? "true" : "false");
|
e.appendChild(createXmlProperty(dom_doc, "rows", rows_count));
|
||||||
|
e.appendChild(createXmlProperty(dom_doc, "rowsize", rows_height));
|
||||||
|
e.appendChild(createXmlProperty(dom_doc, "displayrows", display_rows));
|
||||||
|
|
||||||
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -111,13 +115,28 @@ void BorderProperties::toXml(QDomElement &e) const {
|
|||||||
- XML element whose attributes will be read
|
- XML element whose attributes will be read
|
||||||
- Element XML dont les attributs seront lus
|
- Element XML dont les attributs seront lus
|
||||||
*/
|
*/
|
||||||
void BorderProperties::fromXml(QDomElement &e) {
|
bool BorderProperties::fromXml(const QDomElement &e) {
|
||||||
if (e.hasAttribute("cols")) columns_count = e.attribute("cols").toInt();
|
|
||||||
if (e.hasAttribute("colsize")) columns_width = e.attribute("colsize").toInt();
|
if (propertyInteger(e, "cols", &columns_count) == PropertyFlags::NoValidConversion ||
|
||||||
if (e.hasAttribute("rows")) rows_count = e.attribute("rows").toInt();
|
propertyDouble(e, "colsize", &columns_width) == PropertyFlags::NoValidConversion ||
|
||||||
if (e.hasAttribute("rowsize")) rows_height = e.attribute("rowsize").toInt();
|
propertyInteger(e, "rows", &rows_count) == PropertyFlags::NoValidConversion ||
|
||||||
if (e.hasAttribute("displaycols")) display_columns = e.attribute("displaycols") == "true";
|
propertyDouble(e, "rowsize", &rows_height) == PropertyFlags::NoValidConversion ||
|
||||||
if (e.hasAttribute("displayrows")) display_rows = e.attribute("displayrows") == "true";
|
propertyBool(e, "displaycols", &display_columns) == PropertyFlags::NoValidConversion ||
|
||||||
|
propertyBool(e, "displayrows", &display_rows) == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BorderProperties::valideXml(QDomElement& e) const {
|
||||||
|
|
||||||
|
if (propertyInteger(e, "cols") == PropertyFlags::Success &&
|
||||||
|
propertyDouble(e, "colsize") == PropertyFlags::Success &&
|
||||||
|
propertyInteger(e, "rows") == PropertyFlags::Success &&
|
||||||
|
propertyDouble(e, "rowsize") == PropertyFlags::Success &&
|
||||||
|
propertyBool(e, "displaycols") == PropertyFlags::Success &&
|
||||||
|
propertyBool(e, "displayrows") == PropertyFlags::Success)
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -151,7 +170,7 @@ void BorderProperties::toSettings(QSettings &settings, const QString &prefix) co
|
|||||||
- prefix to be added before the names of the parameters
|
- prefix to be added before the names of the parameters
|
||||||
- prefixe a ajouter devant les noms des parametres
|
- prefixe a ajouter devant les noms des parametres
|
||||||
*/
|
*/
|
||||||
void BorderProperties::fromSettings(QSettings &settings, const QString &prefix) {
|
void BorderProperties::fromSettings(const QSettings &settings, const QString &prefix) {
|
||||||
columns_count = settings.value(prefix + "cols", columns_count).toInt();
|
columns_count = settings.value(prefix + "cols", columns_count).toInt();
|
||||||
columns_width = qRound(settings.value(prefix + "colsize", columns_width).toDouble());
|
columns_width = qRound(settings.value(prefix + "colsize", columns_width).toDouble());
|
||||||
display_columns = settings.value(prefix + "displaycols", display_columns).toBool();
|
display_columns = settings.value(prefix + "displaycols", display_columns).toBool();
|
||||||
|
|||||||
@@ -20,13 +20,15 @@
|
|||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
#include <QtXml>
|
#include <QtXml>
|
||||||
|
|
||||||
|
#include "propertiesinterface.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The BorderProperties class
|
@brief The BorderProperties class
|
||||||
This class is a container for dimensions and display properties of a
|
This class is a container for dimensions and display properties of a
|
||||||
diagram.
|
diagram.
|
||||||
@remark Attributes are public
|
@remark Attributes are public
|
||||||
*/
|
*/
|
||||||
class BorderProperties {
|
class BorderProperties : public PropertiesInterface {
|
||||||
public:
|
public:
|
||||||
// constructor, destructor, operators
|
// constructor, destructor, operators
|
||||||
BorderProperties();
|
BorderProperties();
|
||||||
@@ -35,10 +37,11 @@ class BorderProperties {
|
|||||||
bool operator==(const BorderProperties &);
|
bool operator==(const BorderProperties &);
|
||||||
bool operator!=(const BorderProperties &);
|
bool operator!=(const BorderProperties &);
|
||||||
|
|
||||||
void toXml(QDomElement &) const;
|
QDomElement toXml(QDomDocument &dom_doc) const override;
|
||||||
void fromXml(QDomElement &);
|
bool fromXml(const QDomElement &) override;
|
||||||
void toSettings(QSettings &, const QString & = QString()) const;
|
bool valideXml(QDomElement& e) const override;
|
||||||
void fromSettings(QSettings &, const QString & = QString());
|
void toSettings(QSettings &, const QString & = QString()) const override;
|
||||||
|
void fromSettings(const QSettings &, const QString & = QString()) override;
|
||||||
|
|
||||||
static BorderProperties defaultProperties();
|
static BorderProperties defaultProperties();
|
||||||
|
|
||||||
|
|||||||
@@ -245,8 +245,10 @@ 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
|
||||||
*/
|
*/
|
||||||
void ConductorProperties::toXml(QDomElement &e) const
|
void ConductorProperties::toXml(QDomDocument& doc) const
|
||||||
{
|
{
|
||||||
|
|
||||||
|
QDomElement conductor_elmt = xml_document.createElement("conductors");
|
||||||
e.setAttribute("type", typeToString(type));
|
e.setAttribute("type", typeToString(type));
|
||||||
|
|
||||||
if (color != QColor(Qt::black))
|
if (color != QColor(Qt::black))
|
||||||
|
|||||||
@@ -22,12 +22,14 @@
|
|||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
|
#include "propertiesinterface.h"
|
||||||
|
|
||||||
class QPainter;
|
class QPainter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This class represents the properties of a singleline conductor.
|
This class represents the properties of a singleline conductor.
|
||||||
*/
|
*/
|
||||||
class SingleLineProperties {
|
class SingleLineProperties: public PropertiesInterface {
|
||||||
public:
|
public:
|
||||||
SingleLineProperties();
|
SingleLineProperties();
|
||||||
virtual ~SingleLineProperties();
|
virtual ~SingleLineProperties();
|
||||||
@@ -36,10 +38,10 @@ class SingleLineProperties {
|
|||||||
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 &);
|
||||||
void toXml(QDomElement &) const;
|
void toXml(QDomElement &) const override;
|
||||||
void fromXml(QDomElement &);
|
void fromXml(QDomElement &) override;
|
||||||
void toSettings(QSettings &, const QString & = QString()) const;
|
void toSettings(QSettings &, const QString & = QString()) const override;
|
||||||
void fromSettings(QSettings &, const QString & = QString());
|
void fromSettings(QSettings &, const QString & = QString()) override;
|
||||||
|
|
||||||
/// Whether the singleline conductor should display the ground symbol
|
/// Whether the singleline conductor should display the ground symbol
|
||||||
bool hasGround;
|
bool hasGround;
|
||||||
@@ -62,7 +64,7 @@ class SingleLineProperties {
|
|||||||
This class represents the functional properties of a particular conductor,
|
This class represents the functional properties of a particular conductor,
|
||||||
i.e. properties other than path and terminals.
|
i.e. properties other than path and terminals.
|
||||||
*/
|
*/
|
||||||
class ConductorProperties
|
class ConductorProperties: public PropertiesInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ConductorProperties();
|
ConductorProperties();
|
||||||
@@ -109,10 +111,10 @@ class ConductorProperties
|
|||||||
SingleLineProperties singleLineProperties;
|
SingleLineProperties singleLineProperties;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
void toXml(QDomElement &) const;
|
void toXml(QDomDocument &doc) const override;
|
||||||
void fromXml(QDomElement &);
|
void fromXml(QDomElement &) override;
|
||||||
void toSettings(QSettings &, const QString & = QString()) const;
|
void toSettings(QSettings &, const QString & = QString()) const override;
|
||||||
void fromSettings(QSettings &, const QString & = QString());
|
void fromSettings(QSettings &, const QString & = QString()) override;
|
||||||
static QString typeToString(ConductorType);
|
static QString typeToString(ConductorType);
|
||||||
void applyForEqualAttributes(QList<ConductorProperties> list);
|
void applyForEqualAttributes(QList<ConductorProperties> list);
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ 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
|
||||||
*/
|
*/
|
||||||
const QDomElement PartArc::toXml(QDomDocument &xml_document) const {
|
QDomElement PartArc::toXml(QDomDocument &xml_document) const {
|
||||||
QDomElement xml_element = xml_document.createElement("arc");
|
QDomElement xml_element = xml_document.createElement("arc");
|
||||||
QPointF top_left(sceneTopLeft());
|
QPointF top_left(sceneTopLeft());
|
||||||
|
|
||||||
@@ -118,23 +118,26 @@ const 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.
|
||||||
*/
|
*/
|
||||||
void PartArc::fromXml(const QDomElement &qde) {
|
bool PartArc::fromXml(const QDomElement &qde) {
|
||||||
stylesFromXml(qde);
|
stylesFromXml(qde);
|
||||||
|
|
||||||
double x = 0, y = 0, w = 0, h = 0; // default values
|
double x, y, w, h;
|
||||||
propertyDouble(qde, "x", &x);
|
if (propertyDouble(qde, "x", &x, 0) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(qde, "y", &y);
|
propertyDouble(qde, "y", &y, 0) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(qde, "width", &w);
|
propertyDouble(qde, "width", &w, 0) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(qde, "height", &h);
|
propertyDouble(qde, "height", &h, 0) == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
m_rect = QRectF(mapFromScene(x, y), QSizeF(w, h) );
|
m_rect = QRectF(mapFromScene(x, y), QSizeF(w, h) );
|
||||||
|
|
||||||
m_start_angle = 0;
|
m_start_angle = 0;
|
||||||
propertyDouble(qde, "start", &m_start_angle);
|
if (propertyDouble(qde, "start", &m_start_angle) == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
m_start_angle *= 16;
|
m_start_angle *= 16;
|
||||||
|
|
||||||
m_span_angle = -1440;
|
m_span_angle = -1440;
|
||||||
propertyDouble(qde, "angle", &m_span_angle);
|
if (propertyDouble(qde, "angle", &m_span_angle) == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
m_span_angle *= 16;
|
m_span_angle *= 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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")); }
|
||||||
const QDomElement toXml (QDomDocument &) const override;
|
QDomElement toXml (QDomDocument &) const override;
|
||||||
void fromXml (const QDomElement &) override;
|
bool fromXml (const QDomElement &) override;
|
||||||
|
|
||||||
QPainterPath shape() const override;
|
QPainterPath shape() const override;
|
||||||
QPainterPath shadowShape() const override;
|
QPainterPath shadowShape() const override;
|
||||||
|
|||||||
@@ -85,37 +85,38 @@ void PartDynamicTextField::handleUserTransformation(const QRectF &initial_select
|
|||||||
* @param document
|
* @param document
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
const QDomElement PartDynamicTextField::toXml(QDomDocument &dom_doc) const
|
QDomElement PartDynamicTextField::toXml(QDomDocument &dom_doc) const
|
||||||
{
|
{
|
||||||
QDomElement root_element = dom_doc.createElement(xmlName());
|
QDomElement root_element = dom_doc.createElement(xmlName());
|
||||||
|
|
||||||
root_element.setAttribute("x", QString::number(pos().x()));
|
root_element.appendChild(createXmlProperty(dom_doc, "x", pos().x()));
|
||||||
root_element.setAttribute("y", QString::number(pos().y()));
|
root_element.appendChild(createXmlProperty(dom_doc, "y", pos().y()));
|
||||||
root_element.setAttribute("z", QString::number(zValue()));
|
root_element.appendChild(createXmlProperty(dom_doc, "z", zValue()));
|
||||||
root_element.setAttribute("rotation", QString::number(QET::correctAngle(rotation())));
|
root_element.appendChild(createXmlProperty(dom_doc, "rotation", QET::correctAngle(rotation())));
|
||||||
root_element.setAttribute("font", font().toString());
|
|
||||||
root_element.setAttribute("uuid", m_uuid.toString());
|
root_element.appendChild(createXmlProperty(dom_doc, "font", font().toString()));
|
||||||
root_element.setAttribute("frame", m_frame? "true" : "false");
|
root_element.appendChild(createXmlProperty(dom_doc, "uuid", m_uuid));
|
||||||
root_element.setAttribute("text_width", QString::number(m_text_width));
|
root_element.appendChild(createXmlProperty(dom_doc, "frame", m_frame));
|
||||||
|
root_element.appendChild(createXmlProperty(dom_doc, "text_width", m_text_width));
|
||||||
|
|
||||||
|
|
||||||
QMetaEnum me = DynamicElementTextItem::textFromMetaEnum();
|
QMetaEnum me = DynamicElementTextItem::textFromMetaEnum();
|
||||||
root_element.setAttribute("text_from", me.valueToKey(m_text_from));
|
root_element.appendChild(createXmlProperty(dom_doc, "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.appendChild(createXmlProperty(dom_doc, "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.appendChild(createXmlProperty(dom_doc, "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.appendChild(createXmlProperty(dom_doc, "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.appendChild(createXmlProperty(dom_doc, "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.appendChild(createXmlProperty(dom_doc, "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.appendChild(createXmlProperty(dom_doc, "Valignment", me.valueToKey(Qt::AlignVCenter)));
|
||||||
|
|
||||||
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()));
|
||||||
@@ -152,27 +153,36 @@ const QDomElement PartDynamicTextField::toXml(QDomDocument &dom_doc) const
|
|||||||
* @brief PartDynamicTextField::fromXml
|
* @brief PartDynamicTextField::fromXml
|
||||||
* @param element
|
* @param element
|
||||||
*/
|
*/
|
||||||
void PartDynamicTextField::fromXml(const QDomElement &dom_elmt)
|
bool PartDynamicTextField::fromXml(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";
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QGraphicsTextItem::setPos(dom_elmt.attribute("x", QString::number(0)).toDouble(),
|
double x, y, z, rot;
|
||||||
dom_elmt.attribute("y", QString::number(0)).toDouble());
|
|
||||||
setZValue(dom_elmt.attribute("z", QString::number(zValue())).toDouble());
|
|
||||||
QGraphicsTextItem::setRotation(dom_elmt.attribute("rotation", QString::number(0)).toDouble());
|
|
||||||
|
|
||||||
if (dom_elmt.hasAttribute("font"))
|
if (propertyDouble(dom_elmt, "x", &x, 0) == PropertyFlags::NoValidConversion ||
|
||||||
|
propertyDouble(dom_elmt, "y", &y, 0) == PropertyFlags::NoValidConversion ||
|
||||||
|
propertyDouble(dom_elmt, "z", &z, 0) == PropertyFlags::NoValidConversion ||
|
||||||
|
propertyDouble(dom_elmt, "rotation", &rot, 0) == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
QGraphicsTextItem::setPos(x, y);
|
||||||
|
setZValue(z);
|
||||||
|
QGraphicsTextItem::setRotation(rot);
|
||||||
|
|
||||||
|
QString font;
|
||||||
|
if (propertyString(dom_elmt, "font", &font) == PropertyFlags::Success)
|
||||||
{
|
{
|
||||||
QFont font_;
|
QFont font_;
|
||||||
font_.fromString(dom_elmt.attribute("font"));
|
font_.fromString(font);
|
||||||
setFont(font_);
|
setFont(font_);
|
||||||
} else { //Keep compatibility TODO remove in futur
|
} else { //Keep compatibility TODO remove in futur
|
||||||
setFont(QETApp::dynamicTextsItemFont(9));
|
setFont(QETApp::dynamicTextsItemFont(9));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
propertyUuid(dom_elmt, "uuid", &m_uuid, QUuid::createUuid());
|
||||||
m_uuid = QUuid(dom_elmt.attribute("uuid", QUuid::createUuid().toString()));
|
m_uuid = QUuid(dom_elmt.attribute("uuid", QUuid::createUuid().toString()));
|
||||||
setFrame(dom_elmt.attribute("frame", "false") == "true"? true : false);
|
setFrame(dom_elmt.attribute("frame", "false") == "true"? true : false);
|
||||||
setTextWidth(dom_elmt.attribute("text_width", QString::number(-1)).toDouble());
|
setTextWidth(dom_elmt.attribute("text_width", QString::number(-1)).toDouble());
|
||||||
@@ -181,10 +191,11 @@ void PartDynamicTextField::fromXml(const QDomElement &dom_elmt)
|
|||||||
m_text_from = DynamicElementTextItem::TextFrom(me.keyToValue(dom_elmt.attribute("text_from").toStdString().data()));
|
m_text_from = DynamicElementTextItem::TextFrom(me.keyToValue(dom_elmt.attribute("text_from").toStdString().data()));
|
||||||
|
|
||||||
me = QMetaEnum::fromType<Qt::Alignment>();
|
me = QMetaEnum::fromType<Qt::Alignment>();
|
||||||
if(dom_elmt.hasAttribute("Halignment"))
|
QString alignment;
|
||||||
setAlignment(Qt::Alignment(me.keyToValue(dom_elmt.attribute("Halignment").toStdString().data())));
|
if(propertyString(dom_elmt, "Halignment", &alignment) != PropertyFlags::NotFound)
|
||||||
if(dom_elmt.hasAttribute(("Valignment")))
|
setAlignment(Qt::Alignment(me.keyToValue(alignment.toStdString().data())));
|
||||||
setAlignment(Qt::Alignment(me.keyToValue(dom_elmt.attribute("Valignment").toStdString().data())) | this->alignment());
|
if(propertyString(dom_elmt, "Valignment", &alignment) != PropertyFlags::NotFound)
|
||||||
|
setAlignment(Qt::Alignment(me.keyToValue(alignment.toStdString().data())) | this->alignment());
|
||||||
|
|
||||||
//Text
|
//Text
|
||||||
QDomElement dom_text = dom_elmt.firstChildElement("text");
|
QDomElement dom_text = dom_elmt.firstChildElement("text");
|
||||||
|
|||||||
@@ -74,8 +74,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;
|
||||||
|
|
||||||
const QDomElement toXml(QDomDocument &dom_doc) const override;
|
QDomElement toXml(QDomDocument &dom_doc) const override;
|
||||||
void fromXml(const QDomElement &dom_elmt) override;
|
bool fromXml(const QDomElement &dom_elmt) override;
|
||||||
void fromTextFieldXml(const QDomElement &dom_element);
|
void fromTextFieldXml(const QDomElement &dom_element);
|
||||||
|
|
||||||
DynamicElementTextItem::TextFrom textFrom() const;
|
DynamicElementTextItem::TextFrom textFrom() const;
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ void PartEllipse::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
|
|||||||
* @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
|
||||||
*/
|
*/
|
||||||
const QDomElement PartEllipse::toXml(QDomDocument &xml_document) const
|
QDomElement PartEllipse::toXml(QDomDocument &xml_document) const
|
||||||
{
|
{
|
||||||
QDomElement xml_element;
|
QDomElement xml_element;
|
||||||
if (qFuzzyCompare(rect().width(), rect().height()))
|
if (qFuzzyCompare(rect().width(), rect().height()))
|
||||||
@@ -105,26 +105,31 @@ const QDomElement PartEllipse::toXml(QDomDocument &xml_document) const
|
|||||||
* 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.
|
||||||
*/
|
*/
|
||||||
void PartEllipse::fromXml(const QDomElement &qde)
|
bool PartEllipse::fromXml(const QDomElement &qde)
|
||||||
{
|
{
|
||||||
stylesFromXml(qde);
|
stylesFromXml(qde);
|
||||||
double x = 0, y = 0, width = 0, height = 0;
|
double x, y, width, height;
|
||||||
|
|
||||||
if (qde.tagName() == "ellipse")
|
if (qde.tagName() == "ellipse")
|
||||||
{
|
{
|
||||||
propertyDouble(qde, "width", &width);
|
if (propertyDouble(qde, "width", &width, 0) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(qde, "height", &height);
|
propertyDouble(qde, "height", &height, 0) == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
propertyDouble(qde, "diameter", &width);
|
if (propertyDouble(qde, "diameter", &width, 0) == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
height = width;
|
height = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
propertyDouble(qde, "x", &x);
|
if (propertyDouble(qde, "x", &x, 0) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(qde, "y", &y);
|
propertyDouble(qde, "y", &y, 0) == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
m_rect = QRectF(mapFromScene(x, y), QSizeF(width, height));
|
m_rect = QRectF(mapFromScene(x, y), QSizeF(width, height));
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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")); }
|
||||||
const QDomElement toXml (QDomDocument &) const override;
|
QDomElement toXml (QDomDocument &) const override;
|
||||||
void fromXml (const QDomElement &) override;
|
bool fromXml (const QDomElement &) override;
|
||||||
QPainterPath shape() const override;
|
QPainterPath shape() const override;
|
||||||
QPainterPath shadowShape() const override;
|
QPainterPath shadowShape() const override;
|
||||||
void setRect(const QRectF &rect) override {AbstractPartEllipse::setRect(rect); adjusteHandlerPos();}
|
void setRect(const QRectF &rect) override {AbstractPartEllipse::setRect(rect); adjusteHandlerPos();}
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ void PartLine::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 line
|
* @return an xml element that describe this line
|
||||||
*/
|
*/
|
||||||
const QDomElement PartLine::toXml(QDomDocument &xml_document) const
|
QDomElement PartLine::toXml(QDomDocument &xml_document) const
|
||||||
{
|
{
|
||||||
QPointF p1(sceneP1());
|
QPointF p1(sceneP1());
|
||||||
QPointF p2(sceneP2());
|
QPointF p2(sceneP2());
|
||||||
@@ -128,30 +128,37 @@ const 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
|
||||||
*/
|
*/
|
||||||
void PartLine::fromXml(const QDomElement &qde) {
|
bool PartLine::fromXml(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;
|
||||||
propertyDouble(qde, "x1", &x1);
|
if (propertyDouble(qde, "x1", &x1) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(qde, "y1", &y1);
|
propertyDouble(qde, "y1", &y1) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(qde, "x2", &x2);
|
propertyDouble(qde, "x2", &x2) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(qde, "y2", &y2);
|
propertyDouble(qde, "y2", &y2) == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
m_line = QLineF(mapFromScene(x1, y1),
|
m_line = QLineF(mapFromScene(x1, y1),
|
||||||
mapFromScene(x2, y2));
|
mapFromScene(x2, y2));
|
||||||
|
|
||||||
QString s;
|
QString s;
|
||||||
propertyString(qde, "end1", &s);
|
if (propertyString(qde, "end1", &s) != PropertyFlags::Success)
|
||||||
|
return false;
|
||||||
first_end = Qet::endTypeFromString(s);
|
first_end = Qet::endTypeFromString(s);
|
||||||
|
|
||||||
propertyString(qde, "end2", &s);
|
if (propertyString(qde, "end2", &s) != PropertyFlags::Success)
|
||||||
|
return false;
|
||||||
|
|
||||||
first_end = Qet::endTypeFromString(s);
|
first_end = Qet::endTypeFromString(s);
|
||||||
|
|
||||||
first_length = 1.5;
|
first_length = 1.5;
|
||||||
second_length = 1.5;
|
second_length = 1.5;
|
||||||
|
|
||||||
propertyDouble(qde, "length1", &first_length);
|
if (propertyDouble(qde, "length1", &first_length) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(qde, "length2", &second_length);
|
propertyDouble(qde, "length2", &second_length) == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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")); }
|
||||||
const QDomElement toXml(QDomDocument &) const override;
|
QDomElement toXml(QDomDocument &) const override;
|
||||||
void fromXml(const QDomElement &) override;
|
bool fromXml(const QDomElement &) override;
|
||||||
virtual QPointF sceneP1() const;
|
virtual QPointF sceneP1() const;
|
||||||
virtual QPointF sceneP2() const;
|
virtual QPointF sceneP2() const;
|
||||||
QPainterPath shape() const override;
|
QPainterPath shape() const override;
|
||||||
|
|||||||
@@ -82,15 +82,16 @@ 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
|
||||||
*/
|
*/
|
||||||
void PartPolygon::fromXml(const QDomElement &qde)
|
bool PartPolygon::fromXml(const QDomElement &qde)
|
||||||
{
|
{
|
||||||
stylesFromXml(qde);
|
stylesFromXml(qde);
|
||||||
|
|
||||||
|
int error_counter = 0;
|
||||||
int i = 1;
|
int i = 1;
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
if (propertyDouble(qde, QString("x%1").arg(i)) &&
|
if (propertyDouble(qde, QString("x%1").arg(i)) == PropertyFlags::Success &&
|
||||||
propertyDouble(qde, QString("y%1").arg(i)))
|
propertyDouble(qde, QString("y%1").arg(i)) == PropertyFlags::Success)
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
else break;
|
else break;
|
||||||
@@ -100,13 +101,18 @@ void PartPolygon::fromXml(const QDomElement &qde)
|
|||||||
double x, y;
|
double x, y;
|
||||||
for (int j = 1 ; j < i ; ++ j)
|
for (int j = 1 ; j < i ; ++ j)
|
||||||
{
|
{
|
||||||
propertyDouble(qde, QString("x%1").arg(j), &x);
|
error_counter += propertyDouble(qde, QString("x%1").arg(j), &x);
|
||||||
propertyDouble(qde, QString("y%1").arg(j), &y);
|
error_counter += propertyDouble(qde, QString("y%1").arg(j), &y);
|
||||||
|
if (error_counter)
|
||||||
|
return false;
|
||||||
temp_polygon << QPointF(x, y);
|
temp_polygon << QPointF(x, y);
|
||||||
}
|
}
|
||||||
m_polygon = temp_polygon;
|
m_polygon = temp_polygon;
|
||||||
|
|
||||||
propertyBool(qde, "closed", &m_closed);
|
if (propertyBool(qde, "closed", &m_closed) != PropertyFlags::Success)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -115,7 +121,7 @@ void PartPolygon::fromXml(const QDomElement &qde)
|
|||||||
* @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 polygon
|
* @return an xml element that describe this polygon
|
||||||
*/
|
*/
|
||||||
const QDomElement PartPolygon::toXml(QDomDocument &xml_document) const
|
QDomElement PartPolygon::toXml(QDomDocument &xml_document) const
|
||||||
{
|
{
|
||||||
QDomElement xml_element = xml_document.createElement("polygon");
|
QDomElement xml_element = xml_document.createElement("polygon");
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|||||||
@@ -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")); }
|
||||||
void fromXml(const QDomElement &) override;
|
bool fromXml(const QDomElement &) override;
|
||||||
const QDomElement toXml(QDomDocument &) const override;
|
QDomElement toXml(QDomDocument &) const override;
|
||||||
|
|
||||||
QPainterPath shape () const override;
|
QPainterPath shape () const override;
|
||||||
QPainterPath shadowShape() const override;
|
QPainterPath shadowShape() const override;
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ void PartRectangle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
|
|||||||
* @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
|
||||||
*/
|
*/
|
||||||
const QDomElement PartRectangle::toXml(QDomDocument &xml_document) const
|
QDomElement PartRectangle::toXml(QDomDocument &xml_document) const
|
||||||
{
|
{
|
||||||
QDomElement xml_element = xml_document.createElement("rect");
|
QDomElement xml_element = xml_document.createElement("rect");
|
||||||
QPointF top_left(sceneTopLeft());
|
QPointF top_left(sceneTopLeft());
|
||||||
@@ -112,18 +112,33 @@ const 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.
|
||||||
*/
|
*/
|
||||||
void PartRectangle::fromXml(const QDomElement &qde)
|
bool PartRectangle::fromXml(const QDomElement &qde)
|
||||||
{
|
{
|
||||||
stylesFromXml(qde);
|
stylesFromXml(qde);
|
||||||
setPos(mapFromScene(qde.attribute("x", "0").toDouble(),
|
|
||||||
qde.attribute("y", "0").toDouble()));
|
|
||||||
|
|
||||||
QRectF rect(QPointF(0,0), QSizeF(qde.attribute("width", "0").toDouble(),
|
double x, y, w, h, rx, ry;
|
||||||
qde.attribute("height", "0").toDouble()));
|
if (propertyDouble(qde, "x", &x, 0) == PropertyFlags::NoValidConversion ||
|
||||||
|
propertyDouble(qde, "y", &y, 0) == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
setPos(mapFromScene(x, y));
|
||||||
|
|
||||||
|
if (propertyDouble(qde, "width", &w, 0) == PropertyFlags::NoValidConversion ||
|
||||||
|
propertyDouble(qde, "width", &h, 0) == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
QRectF rect(QPointF(0,0), QSizeF(w, h));
|
||||||
|
|
||||||
setRect(rect.normalized());
|
setRect(rect.normalized());
|
||||||
setXRadius(qde.attribute("rx", "0").toDouble());
|
|
||||||
setYRadius(qde.attribute("ry", "0").toDouble());
|
if (propertyDouble(qde, "rx", &rx, 0) == PropertyFlags::NoValidConversion ||
|
||||||
|
propertyDouble(qde, "ry", &ry, 0) == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
setXRadius(rx);
|
||||||
|
setYRadius(ry);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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")); }
|
||||||
const QDomElement toXml (QDomDocument &) const override;
|
QDomElement toXml (QDomDocument &) const override;
|
||||||
void fromXml (const QDomElement &) override;
|
bool fromXml (const QDomElement &) override;
|
||||||
|
|
||||||
QRectF rect() const;
|
QRectF rect() const;
|
||||||
void setRect(const QRectF &rect);
|
void setRect(const QRectF &rect);
|
||||||
|
|||||||
@@ -42,10 +42,14 @@ 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
|
||||||
*/
|
*/
|
||||||
void PartTerminal::fromXml(const QDomElement &xml_elmt) {
|
bool PartTerminal::fromXml(const QDomElement &xml_elmt) {
|
||||||
d->fromXml(xml_elmt);
|
if (!d->fromXml(xml_elmt))
|
||||||
|
return false;
|
||||||
|
|
||||||
setPos(d->m_pos);
|
setPos(d->m_pos);
|
||||||
updateSecondPoint();
|
updateSecondPoint();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,7 +57,7 @@ void 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
|
||||||
*/
|
*/
|
||||||
const QDomElement PartTerminal::toXml(QDomDocument &xml_document) const {
|
QDomElement PartTerminal::toXml(QDomDocument &xml_document) const {
|
||||||
return d->toXml(xml_document);
|
return d->toXml(xml_document);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ class PartTerminal : public CustomElementGraphicPart
|
|||||||
int type() const override { return Type; }
|
int type() const override { return Type; }
|
||||||
QString name() const override { return d->m_name; }
|
QString name() const override { return d->m_name; }
|
||||||
QString xmlName() const override { return(QString("terminal")); }
|
QString xmlName() const override { return(QString("terminal")); }
|
||||||
void fromXml(const QDomElement &) override;
|
bool fromXml(const QDomElement &) override;
|
||||||
const QDomElement toXml(QDomDocument &) const override;
|
QDomElement toXml(QDomDocument &) const override;
|
||||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override;
|
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override;
|
||||||
|
|
||||||
QPainterPath shape() const override;
|
QPainterPath shape() const override;
|
||||||
|
|||||||
@@ -55,10 +55,8 @@ 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
|
||||||
*/
|
*/
|
||||||
void PartText::fromXml(const QDomElement &xml_element)
|
bool PartText::fromXml(const QDomElement &xml_element)
|
||||||
{
|
{
|
||||||
bool ok;
|
|
||||||
|
|
||||||
int size;
|
int size;
|
||||||
QString font;
|
QString font;
|
||||||
|
|
||||||
@@ -76,6 +74,8 @@ void PartText::fromXml(const QDomElement &xml_element)
|
|||||||
QFont font_;
|
QFont font_;
|
||||||
font_.fromString(font);
|
font_.fromString(font);
|
||||||
setFont(font_);
|
setFont(font_);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString color;
|
QString color;
|
||||||
@@ -88,12 +88,16 @@ void PartText::fromXml(const QDomElement &xml_element)
|
|||||||
setPlainText(text);
|
setPlainText(text);
|
||||||
|
|
||||||
double x, y, rot;
|
double x, y, rot;
|
||||||
propertyDouble(xml_element, "x", &x, 0);
|
if (propertyDouble(xml_element, "x", &x, 0) == PropertyFlags::NoValidConversion ||
|
||||||
propertyDouble(xml_element, "y", &y, 0);
|
propertyDouble(xml_element, "y", &y, 0) == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
setPos(x, y);
|
setPos(x, y);
|
||||||
|
|
||||||
propertyDouble(xml_element, "rotation", &rot, 0);
|
if (propertyDouble(xml_element, "rotation", &rot, 0) == PropertyFlags::NoValidConversion)
|
||||||
|
return false;
|
||||||
setRotation(rot);
|
setRotation(rot);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -101,7 +105,7 @@ void 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
|
||||||
*/
|
*/
|
||||||
const QDomElement PartText::toXml(QDomDocument &xml_document) const
|
QDomElement PartText::toXml(QDomDocument &xml_document) const
|
||||||
{
|
{
|
||||||
QDomElement xml_element = xml_document.createElement(xmlName());
|
QDomElement xml_element = xml_document.createElement(xmlName());
|
||||||
|
|
||||||
|
|||||||
@@ -59,8 +59,8 @@ 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")); }
|
||||||
void fromXml(const QDomElement &) override;
|
bool fromXml(const QDomElement &) override;
|
||||||
const QDomElement toXml(QDomDocument &) const override;
|
QDomElement toXml(QDomDocument &) 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;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ namespace {
|
|||||||
const QString doubleS = "double";
|
const QString doubleS = "double";
|
||||||
const QString boolS = "bool";
|
const QString boolS = "bool";
|
||||||
const QString stringS = "string";
|
const QString stringS = "string";
|
||||||
|
const QString uuidS = "uuid";
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertiesInterface::PropertiesInterface()
|
PropertiesInterface::PropertiesInterface()
|
||||||
@@ -63,11 +64,19 @@ QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QStr
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QString& name, const QUuid value) const {
|
||||||
|
QDomElement p = doc.createElement("property");
|
||||||
|
p.setAttribute("name", name);
|
||||||
|
p.setAttribute("type", uuidS);
|
||||||
|
p.setAttribute("value", value.toString());
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
QDomElement PropertiesInterface::property(const QDomElement& e, const QString& name) {
|
QDomElement PropertiesInterface::property(const QDomElement& e, const QString& name) {
|
||||||
for (int i=0; i < e.childNodes().count(); i++) {
|
for (int i=0; i < e.childNodes().count(); i++) {
|
||||||
QDomElement child = e.childNodes().at(i).toElement();
|
QDomElement child = e.childNodes().at(i).toElement();
|
||||||
if (!validXmlProperty(child))
|
if (!validXmlProperty(child))
|
||||||
return QDomElement();
|
continue; // there might also non property childs
|
||||||
|
|
||||||
if (child.attribute("name") == name)
|
if (child.attribute("name") == name)
|
||||||
return child;
|
return child;
|
||||||
@@ -155,12 +164,12 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyDouble(const QDo
|
|||||||
return PropertyFlags::Success;
|
return PropertyFlags::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean, bool defaulValue) {
|
PropertiesInterface::PropertyFlags PropertiesInterface::propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean, bool defaultValue) {
|
||||||
|
|
||||||
QString attr;
|
QString attr;
|
||||||
|
|
||||||
if (!attribute(e, attribute_name, integerS, &attr)) {
|
if (!attribute(e, attribute_name, integerS, &attr)) {
|
||||||
*boolean = defaulValue;
|
*boolean = defaultValue;
|
||||||
return PropertyFlags::NotFound;
|
return PropertyFlags::NotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,6 +185,20 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyBool(const QDomE
|
|||||||
return PropertyFlags::Success;
|
return PropertyFlags::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PropertiesInterface::PropertyFlags PropertiesInterface::propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid, QUuid defaultValue) {
|
||||||
|
QString attr;
|
||||||
|
|
||||||
|
if (!attribute(e, attribute_name, uuidS, &attr)) {
|
||||||
|
*uuid = defaultValue;
|
||||||
|
return PropertyFlags::NotFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uuid != nullptr)
|
||||||
|
*uuid = QUuid(attr);
|
||||||
|
|
||||||
|
return PropertyFlags::Success;
|
||||||
|
}
|
||||||
|
|
||||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyString(const QDomElement& e, const QString& attribute_name, QString* string, QString defaultValue) {
|
PropertiesInterface::PropertyFlags PropertiesInterface::propertyString(const QDomElement& e, const QString& attribute_name, QString* string, QString defaultValue) {
|
||||||
|
|
||||||
QString attr;
|
QString attr;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <QDomElement>
|
#include <QDomElement>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include "qet.h"
|
#include "qet.h"
|
||||||
|
#include <QUuid>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The PropertiesInterface class
|
* @brief The PropertiesInterface class
|
||||||
@@ -33,8 +34,8 @@ class PropertiesInterface
|
|||||||
public:
|
public:
|
||||||
PropertiesInterface();
|
PropertiesInterface();
|
||||||
// Save/load properties to setting file. QString is use for prefix a word befor the name of each paramètre
|
// Save/load properties to setting file. QString is use for prefix a word befor the name of each paramètre
|
||||||
virtual void toSettings (QSettings &settings, const QString = QString()) const =0;
|
virtual void toSettings (QSettings &settings, const QString& = QString()) const =0;
|
||||||
virtual void fromSettings (const QSettings &settings, const QString = QString()) =0;
|
virtual void fromSettings (const QSettings &settings, const QString& = QString()) =0;
|
||||||
// Save/load properties to xml element
|
// Save/load properties to xml element
|
||||||
virtual QDomElement toXml (QDomDocument &xml_document) const =0;
|
virtual QDomElement toXml (QDomDocument &xml_document) const =0;
|
||||||
virtual bool fromXml (const QDomElement &xml_element) =0;
|
virtual bool fromXml (const QDomElement &xml_element) =0;
|
||||||
@@ -47,12 +48,13 @@ class PropertiesInterface
|
|||||||
QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const int value) const;
|
QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const int value) const;
|
||||||
QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const double value) const;
|
QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const double value) const;
|
||||||
QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const bool value) const;
|
QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const bool value) const;
|
||||||
|
QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const QUuid value) const;
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
typedef enum PropertyFlags {
|
typedef enum PropertyFlags {
|
||||||
Success,
|
Success = 0,
|
||||||
NotFound,
|
NotFound,
|
||||||
NoValidConversion,
|
NoValidConversion,
|
||||||
};
|
};
|
||||||
@@ -60,7 +62,8 @@ class PropertiesInterface
|
|||||||
static PropertyFlags propertyInteger(const QDomElement &e, const QString& attribute_name, int *entier = nullptr, int defaultValue = std::numeric_limits<int>::quiet_NaN());
|
static PropertyFlags propertyInteger(const QDomElement &e, const QString& attribute_name, int *entier = nullptr, int defaultValue = std::numeric_limits<int>::quiet_NaN());
|
||||||
static PropertyFlags propertyDouble(const QDomElement &e, const QString& attribute_name, double *reel = nullptr, double defaultValue = std::numeric_limits<double>::quiet_NaN());
|
static PropertyFlags propertyDouble(const QDomElement &e, const QString& attribute_name, double *reel = nullptr, double defaultValue = std::numeric_limits<double>::quiet_NaN());
|
||||||
static PropertyFlags propertyString(const QDomElement& e, const QString& attribute_name, QString* string = nullptr, QString defaultValue = QString());
|
static PropertyFlags propertyString(const QDomElement& e, const QString& attribute_name, QString* string = nullptr, QString defaultValue = QString());
|
||||||
static PropertyFlags propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean = nullptr, bool defaulValue = false);
|
static PropertyFlags propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean = nullptr, bool defaultValue = false);
|
||||||
|
static PropertyFlags propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid = nullptr, QUuid defaultValue = QUuid());
|
||||||
|
|
||||||
static bool validXmlProperty(const QDomElement& e);
|
static bool validXmlProperty(const QDomElement& e);
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ XRefProperties::XRefProperties()
|
|||||||
* @param settings: QSettings to use
|
* @param settings: QSettings to use
|
||||||
* @param prefix: prefix before properties name
|
* @param prefix: prefix before properties name
|
||||||
*/
|
*/
|
||||||
void XRefProperties::toSettings(QSettings &settings, const QString prefix) const {
|
void XRefProperties::toSettings(QSettings &settings, const QString &prefix) const {
|
||||||
settings.setValue(prefix + "showpowerctc", m_show_power_ctc);
|
settings.setValue(prefix + "showpowerctc", m_show_power_ctc);
|
||||||
QString display = m_display == Cross? "cross" : "contacts";
|
QString display = m_display == Cross? "cross" : "contacts";
|
||||||
settings.setValue(prefix + "displayhas", display);
|
settings.setValue(prefix + "displayhas", display);
|
||||||
@@ -69,7 +69,7 @@ void XRefProperties::toSettings(QSettings &settings, const QString prefix) const
|
|||||||
* @param settings: QSettings to use
|
* @param settings: QSettings to use
|
||||||
* @param prefix: prefix before properties name
|
* @param prefix: prefix before properties name
|
||||||
*/
|
*/
|
||||||
void XRefProperties::fromSettings(const QSettings &settings, const QString prefix)
|
void XRefProperties::fromSettings(const QSettings &settings, const QString &prefix)
|
||||||
{
|
{
|
||||||
m_show_power_ctc = settings.value(prefix + "showpowerctc", true).toBool();
|
m_show_power_ctc = settings.value(prefix + "showpowerctc", true).toBool();
|
||||||
QString display = settings.value(prefix + "displayhas", "cross").toString();
|
QString display = settings.value(prefix + "displayhas", "cross").toString();
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ class XRefProperties : public PropertiesInterface
|
|||||||
Label
|
Label
|
||||||
};
|
};
|
||||||
|
|
||||||
void toSettings (QSettings &settings, const QString = QString()) const override;
|
void toSettings (QSettings &settings, const QString& = QString()) const override;
|
||||||
void fromSettings (const QSettings &settings, const QString = QString()) override;
|
void fromSettings (const QSettings &settings, const QString& = QString()) override;
|
||||||
QDomElement toXml (QDomDocument &xml_document) const override;
|
QDomElement toXml (QDomDocument &xml_document) const override;
|
||||||
bool fromXml(const QDomElement &xml_element) override;
|
bool fromXml(const QDomElement &xml_element) override;
|
||||||
bool valideXml(QDomElement& element) const override;
|
bool valideXml(QDomElement& element) const override;
|
||||||
|
|||||||
@@ -1483,19 +1483,13 @@ void QETProject::writeDefaultPropertiesXml(QDomElement &xml_element)
|
|||||||
QDomDocument xml_document = xml_element.ownerDocument();
|
QDomDocument xml_document = xml_element.ownerDocument();
|
||||||
|
|
||||||
// export size of border
|
// export size of border
|
||||||
QDomElement border_elmt = xml_document.createElement("border");
|
xml_element.appendChild(default_border_properties_.toXml(xml_document));
|
||||||
default_border_properties_.toXml(border_elmt);
|
|
||||||
xml_element.appendChild(border_elmt);
|
|
||||||
|
|
||||||
// export content of titleblock
|
// export content of titleblock
|
||||||
QDomElement titleblock_elmt = xml_document.createElement("inset");
|
xml_element.appendChild(default_titleblock_properties_.toXml(xml_document));
|
||||||
default_titleblock_properties_.toXml(titleblock_elmt);
|
|
||||||
xml_element.appendChild(titleblock_elmt);
|
|
||||||
|
|
||||||
// exporte default conductor
|
// exporte default conductor
|
||||||
QDomElement conductor_elmt = xml_document.createElement("conductors");
|
xml_element.appendChild(default_conductor_properties_.toXml(xml_document));
|
||||||
default_conductor_properties_.toXml(conductor_elmt);
|
|
||||||
xml_element.appendChild(conductor_elmt);
|
|
||||||
|
|
||||||
// export default report properties
|
// export default report properties
|
||||||
QDomElement report_elmt = xml_document.createElement("report");
|
QDomElement report_elmt = xml_document.createElement("report");
|
||||||
|
|||||||
@@ -73,22 +73,26 @@ bool TitleBlockProperties::operator!=(const TitleBlockProperties &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 {
|
QDomElement TitleBlockProperties::toXml(QDomDocument &xml_document) const {
|
||||||
e.setAttribute("author", author);
|
|
||||||
e.setAttribute("title", title);
|
QDomElement e = xml_document.createElement("inset");
|
||||||
e.setAttribute("filename", filename);
|
|
||||||
e.setAttribute("plant", plant);
|
e.appendChild(createXmlProperty(xml_document, "author", author));
|
||||||
e.setAttribute("locmach", locmach);
|
e.appendChild(createXmlProperty(xml_document, "title", title));
|
||||||
e.setAttribute("indexrev",indexrev);
|
e.appendChild(createXmlProperty(xml_document, "filename", filename));
|
||||||
e.setAttribute("version", version);
|
e.appendChild(createXmlProperty(xml_document, "plant", plant));
|
||||||
e.setAttribute("folio", folio);
|
e.appendChild(createXmlProperty(xml_document, "locmach", locmach));
|
||||||
e.setAttribute("auto_page_num", auto_page_num);
|
e.appendChild(createXmlProperty(xml_document, "indexrev", indexrev));
|
||||||
e.setAttribute("date", exportDate());
|
e.appendChild(createXmlProperty(xml_document, "version", version));
|
||||||
e.setAttribute("displayAt", (display_at == Qt::BottomEdge? "bottom" : "right"));
|
e.appendChild(createXmlProperty(xml_document, "folio", folio));
|
||||||
|
e.appendChild(createXmlProperty(xml_document, "auto_page_num", auto_page_num));
|
||||||
|
e.appendChild(createXmlProperty(xml_document, "date", exportDate()));
|
||||||
|
e.appendChild(createXmlProperty(xml_document, "displayAt", display_at == Qt::BottomEdge? "bottom" : "right"));
|
||||||
|
|
||||||
if (!template_name.isEmpty())
|
if (!template_name.isEmpty())
|
||||||
{
|
{
|
||||||
e.setAttribute("titleblocktemplate", template_name);
|
e.appendChild(createXmlProperty(xml_document, "titleblocktemplate", template_name));
|
||||||
e.setAttribute("titleblocktemplateCollection", QET::qetCollectionToString(collection));
|
e.appendChild(createXmlProperty(xml_document, "titleblocktemplateCollection", QET::qetCollectionToString(collection)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context.keys().count()) {
|
if (context.keys().count()) {
|
||||||
@@ -96,13 +100,15 @@ void TitleBlockProperties::toXml(QDomElement &e) const {
|
|||||||
context.toXml(properties);
|
context.toXml(properties);
|
||||||
e.appendChild(properties);
|
e.appendChild(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
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
|
||||||
*/
|
*/
|
||||||
void TitleBlockProperties::fromXml(const QDomElement &e) {
|
bool TitleBlockProperties::fromXml(const QDomElement &e) {
|
||||||
// reads the historical fields
|
// reads the historical fields
|
||||||
if (e.hasAttribute("author")) author = e.attribute("author");
|
if (e.hasAttribute("author")) author = e.attribute("author");
|
||||||
if (e.hasAttribute("title")) title = e.attribute("title");
|
if (e.hasAttribute("title")) title = e.attribute("title");
|
||||||
|
|||||||
@@ -21,12 +21,14 @@
|
|||||||
#include "diagramcontext.h"
|
#include "diagramcontext.h"
|
||||||
#include "qet.h"
|
#include "qet.h"
|
||||||
|
|
||||||
|
#include "propertiesinterface.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This class provides a container for the properties of a particular title
|
This class provides a container for the properties of a particular title
|
||||||
block, i.e. title, author, date, filename, folio, template, custom
|
block, i.e. title, author, date, filename, folio, template, custom
|
||||||
properties, ...
|
properties, ...
|
||||||
*/
|
*/
|
||||||
class TitleBlockProperties {
|
class TitleBlockProperties: public PropertiesInterface {
|
||||||
public:
|
public:
|
||||||
TitleBlockProperties();
|
TitleBlockProperties();
|
||||||
virtual ~TitleBlockProperties();
|
virtual ~TitleBlockProperties();
|
||||||
@@ -39,8 +41,8 @@ class TitleBlockProperties {
|
|||||||
bool operator==(const TitleBlockProperties &);
|
bool operator==(const TitleBlockProperties &);
|
||||||
bool operator!=(const TitleBlockProperties &);
|
bool operator!=(const TitleBlockProperties &);
|
||||||
|
|
||||||
void toXml(QDomElement &) const;
|
QDomElement toXml(QDomDocument &xml_document) const override;
|
||||||
void fromXml(const QDomElement &);
|
bool fromXml(const QDomElement &) override;
|
||||||
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());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user