mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
WIP
This commit is contained in:
@@ -46,7 +46,7 @@ class QetGraphicsHandlerItem : public QGraphicsItem
|
||||
QRectF m_handler_rect,
|
||||
m_br;
|
||||
qreal m_size;
|
||||
QColor m_color;
|
||||
QColor m_color{Qt::black};
|
||||
QPen m_pen;
|
||||
|
||||
public:
|
||||
|
||||
@@ -32,15 +32,7 @@
|
||||
- 17 colonnes affichees de 60.0 px de large pour 20.0px de haut
|
||||
- 8 lignes affichees de 80.0 px de haut pour 20.0px de large
|
||||
*/
|
||||
BorderProperties::BorderProperties() :
|
||||
columns_count(17),
|
||||
columns_width(60.0),
|
||||
columns_header_height(20.0),
|
||||
display_columns(true),
|
||||
rows_count(8),
|
||||
rows_height(80.0),
|
||||
rows_header_width(20.0),
|
||||
display_rows(true)
|
||||
BorderProperties::BorderProperties()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -103,11 +95,12 @@ QDomElement BorderProperties::toXml(QDomDocument &dom_doc) const {
|
||||
e.appendChild(createXmlProperty(dom_doc, "rows", rows_count));
|
||||
e.appendChild(createXmlProperty(dom_doc, "rowsize", rows_height));
|
||||
e.appendChild(createXmlProperty(dom_doc, "displayrows", display_rows));
|
||||
e.appendChild(createXmlProperty(dom_doc, "displaycols", display_columns));
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
/**
|
||||
/**RETURNS True
|
||||
@brief BorderProperties::fromXml
|
||||
- Import dimensions from XML attributes of element e
|
||||
- Importe les dimensions a partir des attributs XML de l'element e
|
||||
@@ -137,6 +130,7 @@ bool BorderProperties::valideXml(QDomElement& e) {
|
||||
propertyBool(e, "displaycols") == PropertyFlags::Success ||
|
||||
propertyBool(e, "displayrows") == PropertyFlags::Success)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,14 +46,14 @@ class BorderProperties : public PropertiesInterface {
|
||||
static BorderProperties defaultProperties();
|
||||
|
||||
// attributes
|
||||
int columns_count; ///< Columns count
|
||||
qreal columns_width; ///< Columns width
|
||||
qreal columns_header_height; ///< Column headers height
|
||||
bool display_columns; ///< Whether to display column headers
|
||||
int columns_count{17}; ///< Columns count
|
||||
qreal columns_width{60.0}; ///< Columns width
|
||||
qreal columns_header_height{20.0}; ///< Column headers height
|
||||
bool display_columns{true}; ///< Whether to display column headers
|
||||
|
||||
int rows_count; ///< Rows count
|
||||
qreal rows_height; ///< Rows height
|
||||
qreal rows_header_width; ///< Row headers width
|
||||
bool display_rows; ///< Whether to display row headers
|
||||
int rows_count{8}; ///< Rows count
|
||||
qreal rows_height{80.0}; ///< Rows height
|
||||
qreal rows_header_width{20.0}; ///< Row headers width
|
||||
bool display_rows{true}; ///< Whether to display row headers
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -22,11 +22,7 @@
|
||||
/**
|
||||
Constructeur par defaut
|
||||
*/
|
||||
SingleLineProperties::SingleLineProperties() :
|
||||
hasGround(true),
|
||||
hasNeutral(true),
|
||||
is_pen(false),
|
||||
phases(1)
|
||||
SingleLineProperties::SingleLineProperties()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -282,9 +278,7 @@ QDomElement ConductorProperties::toXml(QDomDocument& doc) const
|
||||
QDomElement e = doc.createElement("defaultconductor");
|
||||
|
||||
e.appendChild(createXmlProperty(doc, "type", typeToString(type)));
|
||||
|
||||
if (color != QColor(Qt::black))
|
||||
e.appendChild(createXmlProperty(doc, "color", color));
|
||||
e.appendChild(createXmlProperty(doc, "color", color));
|
||||
|
||||
e.appendChild(createXmlProperty(doc, "bicolor", m_bicolor));
|
||||
e.appendChild(createXmlProperty(doc, "color2", m_color_2));
|
||||
@@ -294,7 +288,7 @@ QDomElement ConductorProperties::toXml(QDomDocument& doc) const
|
||||
e.appendChild(singleLineProperties.toXml(doc));
|
||||
|
||||
e.appendChild(createXmlProperty(doc, "num", text));
|
||||
e.appendChild(createXmlProperty(doc, "text_color", text_color.name()));
|
||||
e.appendChild(createXmlProperty(doc, "text_color", text_color));
|
||||
e.appendChild(createXmlProperty(doc, "formula", m_formula));
|
||||
e.appendChild(createXmlProperty(doc, "function", m_function));
|
||||
e.appendChild(createXmlProperty(doc, "tension_protocol", m_tension_protocol));
|
||||
@@ -319,7 +313,7 @@ QDomElement ConductorProperties::toXml(QDomDocument& doc) const
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/** RETURNS True
|
||||
* @brief ConductorProperties::fromXml
|
||||
* Import conductor propertie, from the attribute of the xml element 'e'
|
||||
* @param e the xml document
|
||||
@@ -328,9 +322,9 @@ bool ConductorProperties::fromXml(const QDomElement &e)
|
||||
{
|
||||
// get conductor color
|
||||
propertyColor(e, "color", &color);
|
||||
propertyBool(e, "bicolor", &m_bicolor, false);
|
||||
propertyBool(e, "bicolor", &m_bicolor);
|
||||
propertyColor(e, "color2", &m_color_2);
|
||||
propertyInteger(e, "dash-size", &m_dash_size, 1);
|
||||
propertyInteger(e, "dash-size", &m_dash_size);
|
||||
|
||||
// read style of conductor
|
||||
readStyle(e.attribute("style"));
|
||||
@@ -356,10 +350,10 @@ bool ConductorProperties::fromXml(const QDomElement &e)
|
||||
propertyString(e, "tension_protocol", &m_tension_protocol);
|
||||
propertyString(e, "conductor_color", &m_wire_color);
|
||||
propertyString(e, "conductor_section", &m_wire_section);
|
||||
propertyInteger(e, "numsize", &text_size, 9);
|
||||
propertyDouble(e, "condsize", &cond_size, 1);
|
||||
propertyBool(e, "displaytext", &m_show_text, true);
|
||||
propertyBool(e, "onetextperfolio", &m_one_text_per_folio, 0);
|
||||
propertyInteger(e, "numsize", &text_size);
|
||||
propertyDouble(e, "condsize", &cond_size);
|
||||
propertyBool(e, "displaytext", &m_show_text);
|
||||
propertyBool(e, "onetextperfolio", &m_one_text_per_folio);
|
||||
propertyDouble(e, "vertirotatetext", &verti_rotate_text);
|
||||
propertyDouble(e, "horizrotatetext", &horiz_rotate_text);
|
||||
|
||||
@@ -376,6 +370,8 @@ bool ConductorProperties::fromXml(const QDomElement &e)
|
||||
//@TODO remove this code for qet 0.6 or later
|
||||
|
||||
if (type_t == "simple") m_show_text = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ConductorProperties::valideXml(QDomElement& e) {
|
||||
|
||||
@@ -45,17 +45,17 @@ class SingleLineProperties: public PropertiesInterface {
|
||||
void fromSettings(const QSettings &, const QString & = QString()) override;
|
||||
|
||||
/// Whether the singleline conductor should display the ground symbol
|
||||
bool hasGround;
|
||||
bool hasGround{true};
|
||||
/// Whether the singleline conductor should display the neutral symbol
|
||||
bool hasNeutral;
|
||||
bool hasNeutral{true};
|
||||
/// Protective Earth Neutral: visually merge neutral and ground
|
||||
bool is_pen;
|
||||
bool is_pen{false};
|
||||
|
||||
int operator==(const SingleLineProperties &) const;
|
||||
int operator!=(const SingleLineProperties &) const;
|
||||
|
||||
private:
|
||||
unsigned short int phases;
|
||||
unsigned short int phases{1};
|
||||
void drawGround (QPainter *, QET::ConductorSegmentType, QPointF, qreal);
|
||||
void drawNeutral(QPainter *, QET::ConductorSegmentType, QPointF, qreal);
|
||||
void drawPen(QPainter *, QET::ConductorSegmentType, QPointF, qreal);
|
||||
@@ -80,11 +80,12 @@ class ConductorProperties: public PropertiesInterface
|
||||
|
||||
|
||||
//Attributes
|
||||
ConductorType type;
|
||||
ConductorType type{ConductorType::Single};
|
||||
|
||||
QColor color,
|
||||
m_color_2,
|
||||
text_color;
|
||||
// TODO: set default values!
|
||||
QColor color{QColor(Qt::black)},
|
||||
m_color_2{QColor(Qt::black)},
|
||||
text_color{QColor(Qt::black)};
|
||||
|
||||
QString text,
|
||||
m_function,
|
||||
@@ -93,21 +94,21 @@ class ConductorProperties: public PropertiesInterface
|
||||
m_wire_section,
|
||||
m_formula;
|
||||
|
||||
int text_size,
|
||||
int text_size{9},
|
||||
m_dash_size = 1;
|
||||
|
||||
double cond_size,
|
||||
double cond_size{1},
|
||||
verti_rotate_text,
|
||||
horiz_rotate_text;
|
||||
|
||||
bool m_show_text,
|
||||
m_one_text_per_folio,
|
||||
bool m_show_text{true},
|
||||
m_one_text_per_folio{true},
|
||||
m_bicolor = false;
|
||||
|
||||
Qt::Alignment m_horizontal_alignment = Qt::AlignBottom,
|
||||
m_vertical_alignment = Qt::AlignRight;
|
||||
|
||||
Qt::PenStyle style;
|
||||
Qt::PenStyle style{Qt::PenStyle::SolidLine};
|
||||
|
||||
SingleLineProperties singleLineProperties;
|
||||
|
||||
|
||||
@@ -924,9 +924,11 @@ Terminal* findTerminal(int conductor_index, QDomElement& f, QHash<int, Terminal
|
||||
@return true si l'import a reussi, false sinon
|
||||
*/
|
||||
bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_informations, DiagramContent *content_ptr) {
|
||||
const QDomElement& root = document;
|
||||
const QDomElement& root = document;
|
||||
// The first element must be a diagram
|
||||
if (root.tagName() != "diagram") return(false);
|
||||
|
||||
qDebug() << "Diagram::fromXml; Diagram: " << root.attribute("title");
|
||||
|
||||
// Read attributes of this diagram
|
||||
if (consider_informations) {
|
||||
|
||||
@@ -96,7 +96,7 @@ class Diagram : public QGraphicsScene
|
||||
/// margin around the diagram
|
||||
static const qreal margin;
|
||||
/// background color of diagram
|
||||
static QColor background_color;
|
||||
static QColor background_color; // default value set in cpp file
|
||||
/// Hash containing max values for folio sequential autonums in this diagram
|
||||
QHash <QString, QStringList> m_elmt_unitfolio_max;
|
||||
QHash <QString, QStringList> m_elmt_tenfolio_max;
|
||||
|
||||
@@ -41,7 +41,6 @@ DiagramPrintDialog::DiagramPrintDialog(QETProject *project, QWidget *parent) :
|
||||
|
||||
// orientation paysage par defaut
|
||||
printer_ -> setOrientation(QPrinter::Landscape);
|
||||
backup_diagram_background_color = Diagram::background_color;
|
||||
Diagram::background_color = Qt::white;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,6 +88,6 @@ class DiagramPrintDialog : public QWidget
|
||||
QLineEdit *filepath_field_;
|
||||
QPushButton *browse_button_;
|
||||
QDialogButtonBox *buttons_;
|
||||
QColor backup_diagram_background_color;
|
||||
QColor backup_diagram_background_color{Diagram::background_color};
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -139,6 +139,8 @@ bool PartArc::fromXml(const QDomElement &qde) {
|
||||
if (propertyDouble(qde, "angle", &m_span_angle) == PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
m_span_angle *= 16;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PartArc::valideXml(QDomElement& element) {
|
||||
|
||||
@@ -160,12 +160,12 @@ bool PartDynamicTextField::fromXml(const QDomElement &dom_elmt)
|
||||
return false;
|
||||
}
|
||||
|
||||
double x, y, z, rot;
|
||||
double x=0, y=0, z=0, rot=0;
|
||||
|
||||
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)
|
||||
if (propertyDouble(dom_elmt, "x", &x) == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(dom_elmt, "y", &y) == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(dom_elmt, "z", &z) == PropertyFlags::NoValidConversion ||
|
||||
propertyDouble(dom_elmt, "rotation", &rot) == PropertyFlags::NoValidConversion)
|
||||
return false;
|
||||
|
||||
QGraphicsTextItem::setPos(x, y);
|
||||
@@ -182,12 +182,12 @@ bool PartDynamicTextField::fromXml(const QDomElement &dom_elmt)
|
||||
setFont(QETApp::dynamicTextsItemFont(9));
|
||||
}
|
||||
|
||||
propertyUuid(dom_elmt, "uuid", &m_uuid, QUuid::createUuid());
|
||||
propertyUuid(dom_elmt, "uuid", &m_uuid);
|
||||
bool frame;
|
||||
propertyBool(dom_elmt, "frame", &frame);
|
||||
|
||||
double text_width;
|
||||
propertyDouble(dom_elmt, "text_width", &text_width, -1);
|
||||
propertyDouble(dom_elmt, "text_width", &text_width, true, -1);
|
||||
setTextWidth(text_width);
|
||||
|
||||
QMetaEnum me = DynamicElementTextItem::textFromMetaEnum();
|
||||
@@ -226,6 +226,8 @@ bool PartDynamicTextField::fromXml(const QDomElement &dom_elmt)
|
||||
QDomElement dom_color = dom_elmt.firstChildElement("color");
|
||||
if(!dom_color.isNull())
|
||||
setColor(QColor(dom_color.text()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PartDynamicTextField::valideXml(QDomElement& dom_elmt) {
|
||||
|
||||
@@ -117,7 +117,7 @@ class PartDynamicTextField : public QGraphicsTextItem, public CustomElementPart
|
||||
m_info_name,
|
||||
m_composite_text;
|
||||
DynamicElementTextItem::TextFrom m_text_from = DynamicElementTextItem::UserText;
|
||||
QUuid m_uuid;
|
||||
QUuid m_uuid{QUuid::createUuid()};
|
||||
bool m_frame = false,
|
||||
m_first_add = true,
|
||||
m_block_alignment = false;
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
#include "propertiesinterface.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
/*!
|
||||
* Available property types
|
||||
*/
|
||||
@@ -46,6 +48,14 @@ QDomElement PropertiesInterface::createXmlProperty(QDomDocument &doc, const QStr
|
||||
return p;
|
||||
}
|
||||
|
||||
QDomElement PropertiesInterface::createXmlProperty(QDomDocument &doc, const QString& name, const char* value) const {
|
||||
QDomElement p = doc.createElement("property");
|
||||
p.setAttribute("name", name);
|
||||
p.setAttribute("type", stringS);
|
||||
p.setAttribute("value", value);
|
||||
return p;
|
||||
}
|
||||
|
||||
QDomElement PropertiesInterface::createXmlProperty(QDomDocument& doc, const QString& name, const int value) const {
|
||||
QDomElement p = doc.createElement("property");
|
||||
p.setAttribute("name", name);
|
||||
@@ -112,14 +122,18 @@ bool PropertiesInterface::attribute(const QDomElement& e, const QString& attribu
|
||||
if (p.isNull()) {
|
||||
// check if legacy property is available,
|
||||
// where the property is inside the element as attribute
|
||||
if (!e.hasAttribute(attribute_name))
|
||||
if (!e.hasAttribute(attribute_name)) {
|
||||
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "Property " << attribute_name << "is not available";
|
||||
return false;
|
||||
}
|
||||
|
||||
*attr = e.attribute(attribute_name);
|
||||
|
||||
} else {
|
||||
if (p.attribute("type") != type)
|
||||
if (p.attribute("type") != type) {
|
||||
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ", Property: " << attribute_name << "(" << p.attribute("type") << ") has not type: " << type;
|
||||
return false;
|
||||
}
|
||||
|
||||
*attr = p.attribute("value");
|
||||
|
||||
@@ -136,20 +150,23 @@ bool PropertiesInterface::attribute(const QDomElement& e, const QString& attribu
|
||||
* \return True if reading an integer was successful, else False. If the attribute was not found,
|
||||
* \p entier is not valid and the return value is False
|
||||
*/
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyInteger(const QDomElement &e, const QString& attribute_name, int* entier, int defaultValue) {
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyInteger(const QDomElement &e, const QString& attribute_name, int* entier, bool setDefaultValue, int defaultValue) {
|
||||
|
||||
QString attr;
|
||||
|
||||
if (!attribute(e, attribute_name, integerS, &attr)) {
|
||||
*entier = defaultValue;
|
||||
if (entier && setDefaultValue)
|
||||
*entier = defaultValue;
|
||||
return PropertyFlags::NotFound;
|
||||
}
|
||||
|
||||
// verifie la validite de l'attribut
|
||||
bool ok;
|
||||
int tmp = attr.toInt(&ok);
|
||||
if (!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)
|
||||
*entier = tmp;
|
||||
@@ -157,20 +174,23 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyInteger(const QD
|
||||
return PropertyFlags::Success;
|
||||
}
|
||||
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyDouble(const QDomElement &e, const QString& attribute_name, double* reel, double defaultValue) {
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyDouble(const QDomElement &e, const QString& attribute_name, double* reel, bool setDefaultValue, double defaultValue) {
|
||||
|
||||
QString attr;
|
||||
|
||||
if (!attribute(e, attribute_name, doubleS, &attr)) {
|
||||
*reel = defaultValue;
|
||||
if (reel && setDefaultValue)
|
||||
*reel = defaultValue;
|
||||
return PropertyFlags::NotFound;
|
||||
}
|
||||
|
||||
// verifie la validite de l'attribut
|
||||
bool ok;
|
||||
double tmp = attr.toDouble(&ok);
|
||||
if (!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)
|
||||
*reel = tmp;
|
||||
@@ -178,20 +198,29 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyDouble(const QDo
|
||||
return PropertyFlags::Success;
|
||||
}
|
||||
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean, bool defaultValue) {
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean, bool setDefaultValue, bool defaultValue) {
|
||||
|
||||
QString attr;
|
||||
|
||||
if (!attribute(e, attribute_name, integerS, &attr)) {
|
||||
*boolean = defaultValue;
|
||||
if (!attribute(e, attribute_name, boolS, &attr)) {
|
||||
if (boolean && setDefaultValue)
|
||||
*boolean = defaultValue;
|
||||
return PropertyFlags::NotFound;
|
||||
}
|
||||
|
||||
// verifie la validite de l'attribut
|
||||
bool ok;
|
||||
bool tmp = attr.toInt(&ok);
|
||||
if (!ok)
|
||||
return PropertyFlags::NoValidConversion;
|
||||
if (!ok) {
|
||||
if (attr == "true")
|
||||
tmp = true;
|
||||
else if (attr == "false")
|
||||
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)
|
||||
*boolean = tmp;
|
||||
@@ -199,19 +228,22 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyBool(const QDomE
|
||||
return PropertyFlags::Success;
|
||||
}
|
||||
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color, QColor defaultValue) {
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color, bool setDefaultValue, QColor defaultValue) {
|
||||
|
||||
QString attr;
|
||||
|
||||
if (!attribute(e, attribute_name, colorS, &attr)) {
|
||||
*color = defaultValue;
|
||||
if (color && setDefaultValue)
|
||||
*color = defaultValue;
|
||||
return PropertyFlags::NotFound;
|
||||
}
|
||||
|
||||
// verifie la validite de l'attribut
|
||||
QColor tmp = QColor(attr);
|
||||
if (!tmp.isValid())
|
||||
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)
|
||||
*color = tmp;
|
||||
@@ -219,25 +251,33 @@ PropertiesInterface::PropertyFlags PropertiesInterface::propertyColor(const QDom
|
||||
return PropertyFlags::Success;
|
||||
}
|
||||
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid, QUuid defaultValue) {
|
||||
PropertiesInterface::PropertyFlags PropertiesInterface::propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid, bool setDefaultValue, QUuid defaultValue) {
|
||||
QString attr;
|
||||
|
||||
if (!attribute(e, attribute_name, uuidS, &attr)) {
|
||||
*uuid = defaultValue;
|
||||
if (uuid && setDefaultValue)
|
||||
*uuid = defaultValue;
|
||||
return PropertyFlags::NotFound;
|
||||
}
|
||||
|
||||
if (QUuid(attr).isNull()){
|
||||
qDebug() << "\t\t\t" << "Tagname: " << e.tagName() << ". " << "No valid Conversion: " << attribute_name << ". type: " << uuidS << ". value: " << attr;
|
||||
return PropertyFlags::NoValidConversion;
|
||||
}
|
||||
|
||||
|
||||
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, bool setDefaultValue, QString defaultValue) {
|
||||
|
||||
QString attr;
|
||||
if (!attribute(e, attribute_name, stringS, &attr)) {
|
||||
*string = defaultValue;
|
||||
if (string && setDefaultValue)
|
||||
*string = defaultValue;
|
||||
return PropertyFlags::NotFound;
|
||||
}
|
||||
|
||||
@@ -263,6 +303,8 @@ bool PropertiesInterface::validXmlProperty(const QDomElement& e) {
|
||||
|
||||
if (!e.hasAttribute("value"))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -275,10 +317,12 @@ bool PropertiesInterface::validXmlProperty(const QDomElement& e) {
|
||||
*/
|
||||
Qet::Orientation PropertiesInterface::orientationFromString(const QString &s) {
|
||||
QChar c = s[0];
|
||||
if (c == 'e') return(Qet::East);
|
||||
else if (c == 's') return(Qet::South);
|
||||
else if (c == 'w') return (Qet::West);
|
||||
else return(Qet::North);
|
||||
// in some cases/ old projects? (affuteuse_250h.qet) numbers instead of characters are
|
||||
// used for the orientation
|
||||
if (c == 'e' || c == '1') return(Qet::East);
|
||||
else if (c == 's' || c == '2') return(Qet::South);
|
||||
else if (c == 'w' || c == '3') return (Qet::West);
|
||||
else return(Qet::North); // c == '0'
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,6 +46,7 @@ class PropertiesInterface
|
||||
* Use this functions to add properties to the xml document
|
||||
*/
|
||||
QDomElement createXmlProperty(QDomDocument& doc, const QString& name, const QString value) const;
|
||||
QDomElement createXmlProperty(QDomDocument &doc, const QString& name, const char* 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 bool value) const;
|
||||
@@ -62,12 +63,15 @@ class PropertiesInterface
|
||||
// = 4
|
||||
};
|
||||
|
||||
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 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 defaultValue = false);
|
||||
static PropertyFlags propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid = nullptr, QUuid defaultValue = QUuid());
|
||||
static PropertyFlags propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color = nullptr, QColor defaultValue = QColor());
|
||||
/*!
|
||||
* Try not using the default Value feature. It is better to initialize the class members in the class definition!
|
||||
*/
|
||||
static PropertyFlags propertyInteger(const QDomElement &e, const QString& attribute_name, int *entier = nullptr, bool setDefaultValue = false, int defaultValue = std::numeric_limits<int>::quiet_NaN());
|
||||
static PropertyFlags propertyDouble(const QDomElement &e, const QString& attribute_name, double *reel = nullptr, bool setDefaultValue = false, double defaultValue = std::numeric_limits<double>::quiet_NaN());
|
||||
static PropertyFlags propertyString(const QDomElement& e, const QString& attribute_name, QString* string = nullptr, bool setDefaultValue = false, QString defaultValue = QString());
|
||||
static PropertyFlags propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean = nullptr, bool setDefaultValue = false, bool defaultValue = false);
|
||||
static PropertyFlags propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid = nullptr, bool setDefaultValue = false, QUuid defaultValue = QUuid());
|
||||
static PropertyFlags propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color = nullptr, bool setDefaultValue = false, QColor defaultValue = QColor());
|
||||
|
||||
|
||||
static bool validXmlProperty(const QDomElement& e);
|
||||
|
||||
@@ -45,42 +45,41 @@ QDomElement TerminalData::toXml(QDomDocument &xml_document) const
|
||||
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "x", q->scenePos().x()));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "y", q->scenePos().y()));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "uuid", m_uuid.toString()));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "uuid", m_uuid));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "name", m_name));
|
||||
xml_element.appendChild(createXmlProperty(xml_document, "orientation", orientationToString(m_orientation)));
|
||||
|
||||
return(xml_element);
|
||||
}
|
||||
bool TerminalData::fromXml (const QDomElement &xml_element)
|
||||
bool TerminalData::fromXml (const QDomElement &xml_element) // RETURNS True
|
||||
{
|
||||
// lit la position de la borne
|
||||
qreal term_x = 0.0, term_y = 0.0;
|
||||
|
||||
if (!propertyDouble(xml_element, "x", &term_x))
|
||||
if (propertyDouble(xml_element, "x", &term_x))
|
||||
return false;
|
||||
|
||||
if (!propertyDouble(xml_element, "y", &term_y))
|
||||
if (propertyDouble(xml_element, "y", &term_y))
|
||||
return false;
|
||||
|
||||
m_pos = QPointF(term_x, term_y);
|
||||
|
||||
//emit posFromXML(QPointF(term_x, term_y));
|
||||
|
||||
QString uuid;
|
||||
if (!propertyString(xml_element, "uuid", &uuid))
|
||||
return false;
|
||||
|
||||
QUuid uuid;
|
||||
// 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
|
||||
// to identify terminals
|
||||
if (!uuid.isEmpty())
|
||||
if (propertyUuid(xml_element, "uuid", &uuid) == PropertyFlags::Success)
|
||||
m_uuid = QUuid(uuid);
|
||||
|
||||
if (!propertyString(xml_element, "name", &m_name))
|
||||
return false;
|
||||
|
||||
//if (propertyString(xml_element, "name", &m_name))
|
||||
// return false;
|
||||
propertyString(xml_element, "name", &m_name); // some parts do not have a name. Example: affuteuse_250h.qet, Terminal at x="0" y="-20"
|
||||
|
||||
QString o;
|
||||
if (!propertyString(xml_element, "orientation", &o))
|
||||
if (propertyString(xml_element, "orientation", &o))
|
||||
return false;
|
||||
|
||||
// lit l'orientation de la borne
|
||||
@@ -89,18 +88,19 @@ bool TerminalData::fromXml (const QDomElement &xml_element)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TerminalData::valideXml(QDomElement& xml_element) {
|
||||
bool TerminalData::valideXml(const QDomElement& xml_element) {
|
||||
if (propertyDouble(xml_element, "x"))
|
||||
return false;
|
||||
|
||||
if (propertyDouble(xml_element, "y"))
|
||||
return false;
|
||||
|
||||
if (propertyString(xml_element, "uuid"))
|
||||
return false;
|
||||
// legacy elements do not have an uuid
|
||||
// if (propertyUuid(xml_element, "uuid"))
|
||||
// return false;
|
||||
|
||||
if (propertyString(xml_element, "name"))
|
||||
return false;
|
||||
//if (propertyString(xml_element, "name")) // some parts do not have a name. Example: affuteuse_250h.qet, Terminal at x="0" y="-20"
|
||||
// return false;
|
||||
|
||||
if (propertyString(xml_element, "orientation"))
|
||||
return false;
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
QDomElement toXml(QDomDocument &xml_element) const override;
|
||||
bool fromXml(const QDomElement &xml_element) override;
|
||||
|
||||
static bool valideXml(QDomElement &xml_element);
|
||||
static bool valideXml(const QDomElement &xml_element);
|
||||
|
||||
// must be public, because this class is a private member of PartTerminal/Terminal and they must
|
||||
// access this data
|
||||
@@ -44,12 +44,12 @@ public:
|
||||
* \brief m_orientation
|
||||
* Orientation of the terminal
|
||||
*/
|
||||
Qet::Orientation m_orientation;
|
||||
Qet::Orientation m_orientation{Qet::Orientation::North};
|
||||
/*!
|
||||
* \brief second_point
|
||||
* Position of the second point of the terminal in scene coordinates
|
||||
*/
|
||||
QPointF second_point;
|
||||
QPointF second_point{0,0};
|
||||
/*!
|
||||
* \brief m_uuid
|
||||
* Uuid of the terminal.
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
* uuid, the conductor after updating the part is anymore valid. So if in the loaded document a uuid exists,
|
||||
* use this one and don't create a new one.
|
||||
*/
|
||||
QUuid m_uuid;
|
||||
QUuid m_uuid; // default is an invalid uuid.
|
||||
/*!
|
||||
* \brief m_name
|
||||
* Name of the element. It can be used to create wiring harness tables
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
* Important: this variable is only updated during read from xml and not during mouse move!
|
||||
* It is used to store the initial position so that PartTerminal and Terminal have access to it.
|
||||
*/
|
||||
QPointF m_pos;
|
||||
QPointF m_pos{0,0};
|
||||
private:
|
||||
QGraphicsObject* q{nullptr};
|
||||
};
|
||||
|
||||
@@ -116,14 +116,14 @@ QDomElement XRefProperties::toXml(QDomDocument &xml_document) const {
|
||||
return xml_element;
|
||||
}
|
||||
|
||||
/**
|
||||
/** RETURNS True
|
||||
* @brief XRefProperties::fromXml
|
||||
* Load from xml
|
||||
* @param xml_element: QDomElement to use for load
|
||||
*/
|
||||
bool XRefProperties::fromXml(const QDomElement &xml_element) {
|
||||
|
||||
if (!propertyBool(xml_element, "showpowerctc", &m_show_power_ctc))
|
||||
if (propertyBool(xml_element, "showpowerctc", &m_show_power_ctc))
|
||||
return false;
|
||||
|
||||
QString display;
|
||||
|
||||
@@ -76,14 +76,7 @@ class ConductorXmlRetroCompatibility
|
||||
*/
|
||||
Conductor::Conductor(Terminal *p1, Terminal* p2) :
|
||||
terminal1(p1),
|
||||
terminal2(p2),
|
||||
m_mouse_over(false),
|
||||
m_text_item(nullptr),
|
||||
segments(nullptr),
|
||||
m_moving_segment(false),
|
||||
modified_path(false),
|
||||
has_to_save_profile(false),
|
||||
must_highlight_(Conductor::None)
|
||||
terminal2(p2)
|
||||
{
|
||||
//set Zvalue at 11 to be upper than the DiagramImageItem and element
|
||||
setZValue(11);
|
||||
@@ -574,13 +567,13 @@ ConductorTextItem *Conductor::textItem() const {
|
||||
*/
|
||||
bool Conductor::valideXml(QDomElement &e){
|
||||
|
||||
// TODO: seems to short! (see fromXML)
|
||||
if (propertyDouble(e, "x") ||
|
||||
propertyDouble(e, "y"))
|
||||
return false;
|
||||
// // TODO: seems to short! (see fromXML)
|
||||
// if (propertyDouble(e, "x") ||
|
||||
// propertyDouble(e, "y"))
|
||||
// return false;
|
||||
|
||||
if (propertyBool(e, "freezeLabel"))
|
||||
return false;
|
||||
// if (propertyBool(e, "freezeLabel"))
|
||||
// return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -956,8 +949,11 @@ void Conductor::pointsToSegments(const QList<QPointF>& points_list) {
|
||||
bool Conductor::fromXml(const QDomElement &dom_element)
|
||||
{
|
||||
// TODO: seems to short!
|
||||
setPos(dom_element.attribute("x", nullptr).toDouble(),
|
||||
dom_element.attribute("y", nullptr).toDouble());
|
||||
double x, y;
|
||||
propertyDouble(dom_element, "x", &x);
|
||||
propertyDouble(dom_element, "y", &y);
|
||||
|
||||
setPos(x, y);
|
||||
|
||||
bool return_ = pathFromXml(dom_element);
|
||||
|
||||
@@ -971,8 +967,7 @@ bool Conductor::fromXml(const QDomElement &dom_element)
|
||||
else
|
||||
m_autoNum_seq.fromXml(dom_element.firstChildElement("sequentialNumbers"));
|
||||
|
||||
m_freeze_label = dom_element.attribute("freezeLabel") == "true"? true : false;
|
||||
|
||||
propertyBool(dom_element, "freezeLabel", &m_freeze_label, false);
|
||||
setProperties(pr);
|
||||
|
||||
return return_;
|
||||
|
||||
@@ -156,28 +156,28 @@ class Conductor : public QGraphicsObject, public PropertiesInterface
|
||||
|
||||
QVector<QetGraphicsHandlerItem *> m_handler_vector;
|
||||
int m_vector_index = -1;
|
||||
bool m_mouse_over;
|
||||
bool m_mouse_over{false};
|
||||
/// Functional properties
|
||||
ConductorProperties m_properties;
|
||||
/// Text input for non simple, non-singleline conductors
|
||||
ConductorTextItem *m_text_item;
|
||||
ConductorTextItem *m_text_item{nullptr};
|
||||
/// Segments composing the conductor
|
||||
ConductorSegment *segments;
|
||||
ConductorSegment *segments{nullptr};
|
||||
/// Attributs related to mouse interaction
|
||||
bool m_moving_segment;
|
||||
bool m_moving_segment{false};
|
||||
int moved_point;
|
||||
qreal m_previous_z_value;
|
||||
ConductorSegment *m_moved_segment;
|
||||
QPointF before_mov_text_pos_;
|
||||
/// Whether the conductor was manually modified by users
|
||||
bool modified_path;
|
||||
bool modified_path{false};
|
||||
/// Whether the current profile should be saved as soon as possible
|
||||
bool has_to_save_profile;
|
||||
bool has_to_save_profile{false};
|
||||
/// conductor profile: "photography" of what the conductor is supposed to look
|
||||
/// like - there is one profile per kind of traject
|
||||
ConductorProfilesGroup conductor_profiles;
|
||||
/// Define whether and how the conductor should be highlighted
|
||||
Highlight must_highlight_;
|
||||
Highlight must_highlight_{Conductor::None};
|
||||
bool m_valid;
|
||||
bool m_freeze_label = false;
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ class DynamicElementTextItem : public DiagramTextItem
|
||||
QMetaObject::Connection m_report_formula_con;
|
||||
QList<QMetaObject::Connection> m_formula_connection,
|
||||
m_update_slave_Xref_connection;
|
||||
QColor m_user_color;
|
||||
QColor m_user_color{QColor()};
|
||||
bool m_frame = false,
|
||||
m_first_scene_change = true;
|
||||
CrossRefItem *m_Xref_item = nullptr;
|
||||
|
||||
@@ -65,6 +65,7 @@ class ElementXmlRetroCompatibility
|
||||
|
||||
/**
|
||||
* @brief Element::Element
|
||||
* New element from xml
|
||||
* @param location, location of this element
|
||||
* @param parent, parent graphics item
|
||||
* @param state, state of the instanciation
|
||||
@@ -83,6 +84,7 @@ Element::Element(const ElementsLocation &location, QGraphicsItem *parent, int *s
|
||||
}
|
||||
}
|
||||
int elmt_state;
|
||||
qDebug() << "\tCollection Path: " << location.collectionPath();
|
||||
buildFromXml(location.xml(), &elmt_state);
|
||||
if (state) {
|
||||
*state = elmt_state;
|
||||
@@ -438,12 +440,16 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
|
||||
QDomElement qde = n.toElement();
|
||||
if (qde.isNull())
|
||||
continue;
|
||||
|
||||
qDebug() << "\t\tElement.cpp:buildFromXml;parseElement: " << qde.tagName();
|
||||
|
||||
if (parseElement(qde)) {
|
||||
qDebug() << "\t\t\tParsing Element success";
|
||||
++ parsed_elements_count;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "\t\t\tParsing Element no success";
|
||||
if (state)
|
||||
*state = 7;
|
||||
m_state = QET::GIOK;
|
||||
@@ -467,13 +473,11 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
|
||||
m_state = QET::GIOK;
|
||||
return(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (state)
|
||||
*state = 0;
|
||||
m_state = QET::GIOK;
|
||||
return(true);
|
||||
}
|
||||
|
||||
if (state)
|
||||
*state = 0;
|
||||
m_state = QET::GIOK;
|
||||
return(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -570,11 +574,11 @@ DynamicElementTextItem *Element::parseDynamicText(const QDomElement &dom_element
|
||||
Terminal *Element::parseTerminal(const QDomElement &dom_element)
|
||||
{
|
||||
|
||||
TerminalData* data = new TerminalData();
|
||||
if (!data->fromXml(dom_element)) {
|
||||
delete data;
|
||||
if (!TerminalData::valideXml(dom_element))
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TerminalData* data = new TerminalData();
|
||||
data->fromXml(dom_element);
|
||||
|
||||
Terminal *new_terminal = new Terminal(data, this);
|
||||
m_terminals << new_terminal;
|
||||
@@ -643,17 +647,20 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
|
||||
|
||||
QHash<int, Terminal *> priv_id_adr;
|
||||
int terminals_non_trouvees = 0;
|
||||
foreach(QGraphicsItem *qgi, childItems()) {
|
||||
// The added childs from the collection now must match with the terminals from the diagram. Iterate through
|
||||
// all Terminals in the collection and in the diagram to link them together
|
||||
foreach(QGraphicsItem *qgi, childItems()) { // Where the Terminals are added as childs?
|
||||
if (Terminal *p = qgraphicsitem_cast<Terminal *>(qgi)) {
|
||||
bool terminal_trouvee = false;
|
||||
foreach(QDomElement qde, liste_terminals) {
|
||||
if (p -> fromXml(qde)) {
|
||||
qDebug() << "Matching Terminal found.";
|
||||
priv_id_adr.insert(qde.attribute("id").toInt(), p);
|
||||
terminal_trouvee = true;
|
||||
// We used to break here, because we did not expect
|
||||
// several terminals to share the same position.
|
||||
// Of course, it finally happened.
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!terminal_trouvee) ++ terminals_non_trouvees;
|
||||
}
|
||||
@@ -661,6 +668,7 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
|
||||
|
||||
if (terminals_non_trouvees > 0)
|
||||
{
|
||||
qDebug() << "element.cpp: Element::fromXML; Elements not found: " << terminals_non_trouvees;
|
||||
m_state = QET::GIOK;
|
||||
return(false);
|
||||
}
|
||||
|
||||
@@ -384,6 +384,7 @@ QDomElement ElementTextItemGroup::toXml(QDomDocument &dom_document) const
|
||||
return dom_element;
|
||||
}
|
||||
|
||||
// TOOD: inherit from propertiesinterface
|
||||
/**
|
||||
* @brief ElementTextItemGroup::fromXml
|
||||
* Import data of this group from xml
|
||||
|
||||
@@ -108,7 +108,7 @@ class ElementTextItemGroup : public QObject, public QGraphicsItemGroup // TODO:
|
||||
m_hold_to_bottom_of_page = false,
|
||||
m_block_alignment_update = false,
|
||||
m_frame = false;
|
||||
QPointF m_initial_position;
|
||||
QPointF m_initial_position{QPointF(0,0)};
|
||||
int m_vertical_adjustment = 0;
|
||||
CrossRefItem *m_Xref_item = nullptr;
|
||||
Element *m_parent_element = nullptr;
|
||||
|
||||
@@ -49,6 +49,7 @@ IndependentTextItem::IndependentTextItem(const QString &text) :
|
||||
IndependentTextItem::~IndependentTextItem() {
|
||||
}
|
||||
|
||||
// TODO: inherit from PropertiesInterface
|
||||
/**
|
||||
Permet de lire le texte a mettre dans le champ a partir d'un element XML.
|
||||
Cette methode se base sur la position du champ pour assigner ou non la
|
||||
|
||||
@@ -25,10 +25,7 @@
|
||||
* @param parent, Parent Item
|
||||
*/
|
||||
QetGraphicsItem::QetGraphicsItem(QGraphicsItem *parent):
|
||||
QGraphicsObject(parent),
|
||||
is_movable_(true),
|
||||
m_first_move(true),
|
||||
snap_to_grid_(true)
|
||||
QGraphicsObject(parent)
|
||||
{}
|
||||
|
||||
QetGraphicsItem::~QetGraphicsItem()
|
||||
|
||||
@@ -53,10 +53,10 @@ class QetGraphicsItem : public QGraphicsObject
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
|
||||
protected:
|
||||
bool is_movable_;
|
||||
bool m_first_move;
|
||||
bool snap_to_grid_;
|
||||
QPointF m_mouse_to_origin_movement;
|
||||
bool is_movable_{true};
|
||||
bool m_first_move{true};
|
||||
bool snap_to_grid_{true};
|
||||
QPointF m_mouse_to_origin_movement{QPointF(0,0)};
|
||||
QET::GraphicsItemState m_state = QET:: GIOK;
|
||||
|
||||
};
|
||||
|
||||
@@ -830,6 +830,7 @@ void QetShapeItem::handlerMouseReleaseEvent(QetGraphicsHandlerItem *qghi, QGraph
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: inherit from Propertiesinterface!
|
||||
/**
|
||||
* @brief QetShapeItem::fromXml
|
||||
* Build this item from the xml description
|
||||
|
||||
@@ -41,8 +41,6 @@ const qreal Terminal::Z = 1000;
|
||||
@param name of terminal
|
||||
*/
|
||||
void Terminal::init(QString number, QString name, bool hiddenName) {
|
||||
|
||||
hovered_color_ = Terminal::neutralColor;
|
||||
|
||||
// calcul de la position du point d'amarrage a l'element
|
||||
dock_elmt_ = d->m_pos;
|
||||
@@ -62,11 +60,9 @@ void Terminal::init(QString number, QString name, bool hiddenName) {
|
||||
|
||||
// QRectF null
|
||||
br_ = new QRectF();
|
||||
previous_terminal_ = nullptr;
|
||||
// divers
|
||||
setAcceptHoverEvents(true);
|
||||
setAcceptedMouseButtons(Qt::LeftButton);
|
||||
hovered_ = false;
|
||||
setToolTip(QObject::tr("Borne", "tooltip"));
|
||||
setZValue(Z);
|
||||
}
|
||||
@@ -753,7 +749,7 @@ bool Terminal::valideXml(QDomElement &terminal) {
|
||||
return false;
|
||||
|
||||
QString o;
|
||||
if (!propertyString(terminal, "orientation", &o))
|
||||
if (propertyString(terminal, "orientation", &o))
|
||||
return false;
|
||||
|
||||
Qet::Orientation terminal_or = orientationFromString(o);
|
||||
@@ -767,7 +763,7 @@ bool Terminal::valideXml(QDomElement &terminal) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
/** RETURNS True
|
||||
@brief Terminal::fromXml
|
||||
Permet de savoir si un element XML represente cette borne. Attention,
|
||||
l'element XML n'est pas verifie
|
||||
@@ -795,11 +791,12 @@ bool Terminal::fromXml(const QDomElement &terminal) {
|
||||
if (propertyString(terminal, "orientation", &o))
|
||||
return false;
|
||||
|
||||
return (
|
||||
qFuzzyCompare(x, dock_elmt_.x()) &&
|
||||
qFuzzyCompare(y, dock_elmt_.y()) &&
|
||||
(orientationFromString(o) == d->m_orientation)
|
||||
);
|
||||
if (!qFuzzyCompare(x, dock_elmt_.x()) ||
|
||||
!qFuzzyCompare(y, dock_elmt_.y()) ||
|
||||
orientationFromString(o) != d->m_orientation)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -109,9 +109,10 @@ class Terminal : public QGraphicsObject, public PropertiesInterface
|
||||
|
||||
static const qreal terminalSize;
|
||||
static const qreal Z;
|
||||
// Various static colors used for hover effects
|
||||
// Various static colors used for hover effects.
|
||||
// The assignement is in the cpp file
|
||||
/// default color
|
||||
static QColor neutralColor;
|
||||
static QColor neutralColor;
|
||||
/// color for legal actions
|
||||
static QColor allowedColor;
|
||||
/// color for allowed but fuzzy or not recommended actions
|
||||
@@ -140,11 +141,11 @@ class Terminal : public QGraphicsObject, public PropertiesInterface
|
||||
*/
|
||||
QRectF *br_{nullptr};
|
||||
/// Last terminal seen through an attached conductor
|
||||
Terminal *previous_terminal_;
|
||||
Terminal *previous_terminal_{nullptr};
|
||||
/// Whether the mouse pointer is hovering the terminal
|
||||
bool hovered_;
|
||||
bool hovered_{false};
|
||||
/// Color used for the hover effect
|
||||
QColor hovered_color_;
|
||||
QColor hovered_color_{Terminal::hovered_color_};
|
||||
/// Number of Terminal
|
||||
QString number_terminal_;
|
||||
/// Name of Terminal
|
||||
|
||||
@@ -23,12 +23,7 @@
|
||||
*/
|
||||
HelperCell::HelperCell(QGraphicsItem *parent) :
|
||||
QGraphicsObject(parent),
|
||||
QGraphicsLayoutItem(),
|
||||
background_color(Qt::white),
|
||||
foreground_color(Qt::black),
|
||||
label(),
|
||||
orientation(Qt::Horizontal),
|
||||
index(-1)
|
||||
QGraphicsLayoutItem()
|
||||
{
|
||||
setGraphicsItem(this);
|
||||
setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||
|
||||
@@ -37,11 +37,11 @@ class HelperCell : public QGraphicsObject, public QGraphicsLayoutItem {
|
||||
|
||||
// attributes
|
||||
public:
|
||||
QColor background_color; ///< Background color when rendering this cell
|
||||
QColor foreground_color; ///< Text color when rendering this cell
|
||||
QColor background_color{Qt::white}; ///< Background color when rendering this cell
|
||||
QColor foreground_color{Qt::black}; ///< Text color when rendering this cell
|
||||
QString label; ///< Label displayed in this cell
|
||||
Qt::Orientation orientation; ///< Orientation of this cell
|
||||
int index; ///< Index of this cell
|
||||
Qt::Orientation orientation{Qt::Horizontal}; ///< Orientation of this cell
|
||||
int index{-1}; ///< Index of this cell
|
||||
|
||||
// methods
|
||||
public:
|
||||
|
||||
@@ -36,6 +36,7 @@ class SplittedHelperCell : public HelperCell {
|
||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = nullptr) override;
|
||||
|
||||
// attributes
|
||||
// colors are set in the constructor
|
||||
QColor split_background_color; ///< Background color on the split side
|
||||
QColor split_foreground_color; ///< Text color on the split side
|
||||
QString split_label; ///< Text displayed on the split side
|
||||
|
||||
@@ -23,11 +23,7 @@
|
||||
Constructeur. Initialise un objet TitleBlockProperties avec tous les champs
|
||||
vides (date vide + useDate a UseDateValue).
|
||||
*/
|
||||
TitleBlockProperties::TitleBlockProperties() :
|
||||
date(),
|
||||
useDate(UseDateValue),
|
||||
display_at(Qt::BottomEdge),
|
||||
collection (QET::QetCollection::Common)
|
||||
TitleBlockProperties::TitleBlockProperties()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -87,7 +83,8 @@ QDomElement TitleBlockProperties::toXml(QDomDocument &xml_document) const {
|
||||
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"));
|
||||
QString disp_at = display_at == Qt::BottomEdge? "bottom" : "right";
|
||||
e.appendChild(createXmlProperty(xml_document, "displayAt", disp_at));
|
||||
|
||||
if (!template_name.isEmpty())
|
||||
{
|
||||
@@ -104,7 +101,7 @@ QDomElement TitleBlockProperties::toXml(QDomDocument &xml_document) const {
|
||||
return e;
|
||||
}
|
||||
|
||||
/**
|
||||
/** RETURNS True
|
||||
Importe le cartouche a partir des attributs XML de l'element e
|
||||
@param e Element XML dont les attributs seront lus
|
||||
*/
|
||||
@@ -141,6 +138,7 @@ bool TitleBlockProperties::fromXml(const QDomElement &e) {
|
||||
foreach (QDomElement e, QET::findInDomElement(e, "properties")) {
|
||||
context.fromXml(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -63,11 +63,11 @@ class TitleBlockProperties: public PropertiesInterface {
|
||||
QString version; ///< Version (displayed by the default template)
|
||||
QString folio; ///< Folio information (displayed by the default template)
|
||||
QString auto_page_num;
|
||||
DateManagement useDate; ///< Wheter to use the date attribute
|
||||
DateManagement useDate{UseDateValue}; ///< Wheter to use the date attribute
|
||||
QString template_name; ///< Name of the template used to render the title block - an empty string means "the default template provided by the application"
|
||||
DiagramContext context; ///< Container for the additional, user-defined fields
|
||||
Qt::Edge display_at; ///< Edge to display the titleblock
|
||||
QET::QetCollection collection; ///<Specify the location of the title block
|
||||
Qt::Edge display_at{Qt::Edge::BottomEdge}; ///< Edge to display the titleblock
|
||||
QET::QetCollection collection{QET::QetCollection::Common}; ///<Specify the location of the title block
|
||||
|
||||
private:
|
||||
QString exportDate() const;
|
||||
|
||||
Reference in New Issue
Block a user