Compare commits

..

15 Commits

Author SHA1 Message Date
Martin Marmsoler ada65f10e7 default color was wrong 2020-10-19 21:22:00 +02:00
Martin Marmsoler 33328b30cd Merge branch 'XMLProperties_Rebase1' of ssh://git.tuxfamily.org/gitroot/qet/qet into XMLProperties_Rebase1 2020-10-19 20:05:38 +02:00
Martin Marmsoler b0a6b8fd05 initialize TerminalData with nullpoint to not having an invalid value 2020-10-19 20:02:29 +02:00
Martin Marmsoler af83e8bf1b remove not needed variable 2020-10-19 20:02:00 +02:00
Martin Marmsoler 4a7772b003 fix problems in partrectangle 2020-10-19 19:56:05 +02:00
Simon De Backer 253ac4d816 Add destructor to Machine_info class to fix segfault 2020-10-19 16:56:09 +02:00
Martin Marmsoler a54b6192d0 fix compile issues 2020-10-19 11:07:04 +02:00
Martin Marmsoler 0873904598 replace 4 spaces by a tab 2020-10-17 20:25:30 +02:00
Martin Marmsoler 229bc2f9d9 rebase XMLProperties_New (c0d9bf9) to master 2020-10-16 14:23:51 +02:00
Martin Marmsoler 31f05c58b9 replace tabs by 4 spaces 2020-10-16 11:45:17 +02:00
artgg7300 a65675b53e translated hungarian files 2020-10-15 20:17:03 +02:00
Laurent Trinques c39ef0a999 Update en fr translation 2020-10-15 18:54:08 +02:00
dlee99 ff84a71d97 modified: lang/qet_nl.qm
modified:   lang/qet_nl.ts
2020-10-14 23:15:59 +02:00
Laurent Trinques 434c3dfbfb Update TS files 2020-10-14 21:00:33 +02:00
Laurent Trinques 096f8f58e1 Updatre de translation, thanks Lars 2020-10-14 20:58:35 +02:00
100 changed files with 14041 additions and 12405 deletions
+467 -413
View File
File diff suppressed because it is too large Load Diff
+467 -413
View File
File diff suppressed because it is too large Load Diff
+467 -413
View File
File diff suppressed because it is too large Load Diff
+467 -413
View File
File diff suppressed because it is too large Load Diff
+467 -413
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+535 -479
View File
File diff suppressed because it is too large Load Diff
+467 -413
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+467 -413
View File
File diff suppressed because it is too large Load Diff
+467 -413
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+473 -419
View File
File diff suppressed because it is too large Load Diff
+467 -413
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+462 -408
View File
File diff suppressed because it is too large Load Diff
+467 -413
View File
File diff suppressed because it is too large Load Diff
+467 -413
View File
File diff suppressed because it is too large Load Diff
+473 -419
View File
File diff suppressed because it is too large Load Diff
+467 -413
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+462 -408
View File
File diff suppressed because it is too large Load Diff
+467 -413
View File
File diff suppressed because it is too large Load Diff
+470 -413
View File
File diff suppressed because it is too large Load Diff
+467 -413
View File
File diff suppressed because it is too large Load Diff
+467 -413
View File
File diff suppressed because it is too large Load Diff
+467 -413
View File
File diff suppressed because it is too large Load Diff
+473 -419
View File
File diff suppressed because it is too large Load Diff
+473 -419
View File
File diff suppressed because it is too large Load Diff
+473 -419
View File
File diff suppressed because it is too large Load Diff
+467 -413
View File
File diff suppressed because it is too large Load Diff
+473 -419
View File
File diff suppressed because it is too large Load Diff
@@ -190,16 +190,16 @@ QString FileElementCollectionItem::name() const
*/ */
QString FileElementCollectionItem::collectionPath() const QString FileElementCollectionItem::collectionPath() const
{ {
QStandardItem* parent_ = parent();
if (isCollectionRoot()) { if (isCollectionRoot()) {
if (m_path == QETApp::commonElementsDirN()) if (m_path == QETApp::commonElementsDirN())
return "common://"; return "common://";
else else
return "custom://"; return "custom://";
} }
else if (parent_ && parent()->type() == FileElementCollectionItem::Type) else if (parent() && parent()->type()
{ == FileElementCollectionItem::Type) {
ElementCollectionItem *eci = static_cast<ElementCollectionItem*>(parent()); ElementCollectionItem *eci =
static_cast<ElementCollectionItem*>(parent());
if (eci->isCollectionRoot()) if (eci->isCollectionRoot())
return eci->collectionPath() + m_path; return eci->collectionPath() + m_path;
else else
@@ -50,7 +50,8 @@ class QetGraphicsHandlerItem : public QGraphicsItem
QWidget *widget) override; QWidget *widget) override;
private: private:
QRectF m_handler_rect,m_br; QRectF m_handler_rect,
m_br;
qreal m_size; qreal m_size;
QColor m_color{Qt::black}; QColor m_color{Qt::black};
QPen m_pen; QPen m_pen;
+8 -3
View File
@@ -78,10 +78,15 @@ bool BorderProperties::operator==(const BorderProperties &bp) {
bool BorderProperties::operator!=(const BorderProperties &bp) { bool BorderProperties::operator!=(const BorderProperties &bp) {
return(!(*this == bp)); return(!(*this == bp));
} }
/** /**
@brief BorderProperties::toXml @brief BorderProperties::toXml
@param dom_doc Exports dimensions as XML attributes added to element e.
@return \~French Exporte les dimensions sous formes d'attributs XML ajoutes a l'element e.
\~ @param e :
XML element to which attributes will be added
\~French Element XML auquel seront ajoutes des attributs
*/ */
QDomElement BorderProperties::toXml(QDomDocument &dom_doc) const { QDomElement BorderProperties::toXml(QDomDocument &dom_doc) const {
@@ -162,7 +167,7 @@ void BorderProperties::toSettings(QSettings &settings, const QString &prefix) co
\~ @param prefix : prefix to be added before the names of the parameters \~ @param prefix : prefix to be added before the names of the parameters
\~French prefixe a ajouter devant les noms des parametres \~French prefixe a ajouter devant les noms des parametres
*/ */
void BorderProperties::fromSettings(const QSettings &settings, const QString &prefix) { void BorderProperties::fromSettings(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();
+1 -1
View File
@@ -41,7 +41,7 @@ class BorderProperties : public PropertiesInterface {
bool fromXml(const QDomElement &) override; bool fromXml(const QDomElement &) override;
static bool valideXml(QDomElement& e); static bool valideXml(QDomElement& e);
void toSettings(QSettings &, const QString & = QString()) const override; void toSettings(QSettings &, const QString & = QString()) const override;
void fromSettings(const QSettings &, const QString & = QString()) override; void fromSettings(QSettings &, const QString & = QString()) override;
static BorderProperties defaultProperties(); static BorderProperties defaultProperties();
+45 -51
View File
@@ -207,12 +207,12 @@ void SingleLineProperties::drawPen(QPainter *painter,
} }
/** /**
@brief SingleLineProperties::toXml Exporte les parametres du conducteur unifilaire sous formes d'attributs XML
@param doc ajoutes a l'element e.
@return @param e Element XML auquel seront ajoutes des attributs
*/ */
QDomElement SingleLineProperties::toXml(QDomDocument &doc) const QDomElement SingleLineProperties::toXml(QDomDocument &doc) const {
{
QDomElement e = doc.createElement("SingleLine"); QDomElement e = doc.createElement("SingleLine");
e.appendChild(createXmlProperty(doc, "ground", hasGround)); e.appendChild(createXmlProperty(doc, "ground", hasGround));
e.appendChild(createXmlProperty(doc, "neutral", hasNeutral)); e.appendChild(createXmlProperty(doc, "neutral", hasNeutral));
@@ -294,6 +294,7 @@ ConductorProperties::~ConductorProperties()
*/ */
QDomElement ConductorProperties::toXml(QDomDocument& doc) const QDomElement ConductorProperties::toXml(QDomDocument& doc) const
{ {
QDomElement e = doc.createElement("defaultconductor"); QDomElement e = doc.createElement("defaultconductor");
e.appendChild(createXmlProperty(doc, "type", typeToString(type))); e.appendChild(createXmlProperty(doc, "type", typeToString(type)));
@@ -319,7 +320,9 @@ QDomElement ConductorProperties::toXml(QDomDocument& doc) const
e.appendChild(createXmlProperty(doc, "onetextperfolio", m_one_text_per_folio)); e.appendChild(createXmlProperty(doc, "onetextperfolio", m_one_text_per_folio));
e.appendChild(createXmlProperty(doc, "onetextperfolio", verti_rotate_text)); e.appendChild(createXmlProperty(doc, "onetextperfolio", verti_rotate_text));
e.appendChild(createXmlProperty(doc, "horizrotatetext", horiz_rotate_text)); e.appendChild(createXmlProperty(doc, "horizrotatetext", horiz_rotate_text));
// TODO: implement
//e.setAttribute("cable", m_cable);
// e.setAttribute("bus", m_bus);
QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>(); QMetaEnum me = QMetaEnum::fromType<Qt::Alignment>();
e.appendChild(createXmlProperty(doc, "horizontal-alignment", me.valueToKey(m_horizontal_alignment))); e.appendChild(createXmlProperty(doc, "horizontal-alignment", me.valueToKey(m_horizontal_alignment)));
e.appendChild(createXmlProperty(doc, "vertical-alignment", me.valueToKey(m_vertical_alignment))); e.appendChild(createXmlProperty(doc, "vertical-alignment", me.valueToKey(m_vertical_alignment)));
@@ -351,8 +354,7 @@ bool ConductorProperties::fromXml(const QDomElement &e)
readStyle(style_string); readStyle(style_string);
QString type_t; QString type_t;
if (propertyString(e, "type", &type_t) == PropertyFlags::Success) if (propertyString(e, "type", &type_t) == PropertyFlags::Success) {
{
if (type_t == typeToString(Single)) if (type_t == typeToString(Single))
{ {
// get specific properties for single conductor // get specific properties for single conductor
@@ -365,15 +367,15 @@ bool ConductorProperties::fromXml(const QDomElement &e)
//Keep retrocompatible with version older than 0,4 //Keep retrocompatible with version older than 0,4
//If the propertie @type is simple (removed since QET 0,4), we set text no visible. //If the propertie @type is simple (removed since QET 0,4), we set text no visible.
//@TODO remove this code for qet 0.6 or later //@TODO remove this code for qet 0.6 or later
#if TODO_LIST
#pragma message("@TODO remove this code for qet 0.6 or later")
#endif
if (type_t == "simple") m_show_text = false; if (type_t == "simple") m_show_text = false;
} }
} }
propertyString(e, "num", &text); propertyString(e, "num", &text);
// TODO: implement:
//m_cable = e.attribute("cable");
//m_bus = e.attribute("bus");
// get text color // get text color
propertyColor(e, "text_color", &text_color); propertyColor(e, "text_color", &text_color);
propertyString(e, "formula", &m_formula); propertyString(e, "formula", &m_formula);
@@ -399,13 +401,7 @@ bool ConductorProperties::fromXml(const QDomElement &e)
return true; return true;
} }
/** bool ConductorProperties::valideXml(QDomElement& e) {
@brief ConductorProperties::valideXml
@param e
@return
*/
bool ConductorProperties::valideXml(QDomElement& e)
{
if (propertyColor(e, "color") || if (propertyColor(e, "color") ||
propertyBool(e, "bicolor") || propertyBool(e, "bicolor") ||
propertyColor(e, "color2") || propertyColor(e, "color2") ||
@@ -445,8 +441,8 @@ void ConductorProperties::toSettings(QSettings &settings, const QString &prefix)
settings.setValue(prefix + "text", text); settings.setValue(prefix + "text", text);
settings.setValue(prefix + "text_color", text_color.name()); settings.setValue(prefix + "text_color", text_color.name());
settings.setValue(prefix + "formula", m_formula); settings.setValue(prefix + "formula", m_formula);
//settings.setValue(prefix + "cable", m_cable); settings.setValue(prefix + "cable", m_cable);
//settings.setValue(prefix + "bus", m_bus); settings.setValue(prefix + "bus", m_bus);
settings.setValue(prefix + "function", m_function); settings.setValue(prefix + "function", m_function);
settings.setValue(prefix + "tension_protocol", m_tension_protocol); settings.setValue(prefix + "tension_protocol", m_tension_protocol);
settings.setValue(prefix + "conductor_color", m_wire_color); settings.setValue(prefix + "conductor_color", m_wire_color);
@@ -469,7 +465,7 @@ void ConductorProperties::toSettings(QSettings &settings, const QString &prefix)
@param settings Parametres a lire @param settings Parametres a lire
@param prefix prefixe a ajouter devant les noms des parametres @param prefix prefixe a ajouter devant les noms des parametres
*/ */
void ConductorProperties::fromSettings(const QSettings &settings, const QString &prefix) void ConductorProperties::fromSettings(QSettings &settings, const QString &prefix)
{ {
QColor settings_color = QColor(settings.value(prefix + "color").toString()); QColor settings_color = QColor(settings.value(prefix + "color").toString());
color = (settings_color.isValid()? settings_color : QColor(Qt::black)); color = (settings_color.isValid()? settings_color : QColor(Qt::black));
@@ -489,8 +485,8 @@ void ConductorProperties::fromSettings(const QSettings &settings, const QString
QColor settings_text_color = QColor(settings.value(prefix + "text_color").toString()); QColor settings_text_color = QColor(settings.value(prefix + "text_color").toString());
text_color = (settings_text_color.isValid()? settings_text_color : QColor(Qt::black)); text_color = (settings_text_color.isValid()? settings_text_color : QColor(Qt::black));
m_formula = settings.value(prefix + "formula", "").toString(); m_formula = settings.value(prefix + "formula", "").toString();
//m_cable = settings.value(prefix + "cable", "").toString(); m_cable = settings.value(prefix + "cable", "").toString();
//m_bus = settings.value(prefix + "bus", "").toString(); m_bus = settings.value(prefix + "bus", "").toString();
m_function = settings.value(prefix + "function", "").toString(); m_function = settings.value(prefix + "function", "").toString();
m_tension_protocol = settings.value(prefix + "tension_protocol", "").toString(); m_tension_protocol = settings.value(prefix + "tension_protocol", "").toString();
m_wire_color = settings.value(prefix + "conductor_color", "").toString(); m_wire_color = settings.value(prefix + "conductor_color", "").toString();
@@ -545,8 +541,8 @@ void ConductorProperties::applyForEqualAttributes(QList<ConductorProperties> lis
text = cp.text; text = cp.text;
text_color = cp.text_color; text_color = cp.text_color;
m_formula = cp.m_formula; m_formula = cp.m_formula;
//m_cable = cp.m_cable; m_cable = cp.m_cable;
//m_bus = cp.m_bus; m_bus = cp.m_bus;
m_function = cp.m_function; m_function = cp.m_function;
m_tension_protocol = cp.m_tension_protocol; m_tension_protocol = cp.m_tension_protocol;
m_wire_color = cp.m_wire_color; m_wire_color = cp.m_wire_color;
@@ -648,27 +644,27 @@ void ConductorProperties::applyForEqualAttributes(QList<ConductorProperties> lis
m_formula = s_value; m_formula = s_value;
equal = true; equal = true;
// //cable //cable
// s_value = clist.first().m_cable; s_value = clist.first().m_cable;
// for(ConductorProperties cp : clist) for(ConductorProperties cp : clist)
// { {
// if (cp.m_cable != s_value) if (cp.m_cable != s_value)
// equal = false; equal = false;
// } }
// if (equal) if (equal)
// m_cable = s_value; m_cable = s_value;
// equal = true; equal = true;
// //bus //bus
// s_value = clist.first().m_bus; s_value = clist.first().m_bus;
// for(ConductorProperties cp : clist) for(ConductorProperties cp : clist)
// { {
// if (cp.m_bus != s_value) if (cp.m_bus != s_value)
// equal = false; equal = false;
// } }
// if (equal) if (equal)
// m_bus = s_value; m_bus = s_value;
// equal = true; equal = true;
//function //function
s_value = clist.first().m_function; s_value = clist.first().m_function;
@@ -835,9 +831,8 @@ bool ConductorProperties::operator==(const ConductorProperties &other) const
other.text == text &&\ other.text == text &&\
other.text_color == text_color &&\ other.text_color == text_color &&\
other.m_formula == m_formula &&\ other.m_formula == m_formula &&\
/* other.m_cable == m_cable &&\ other.m_cable == m_cable &&\
other.m_bus == m_bus &&\ other.m_bus == m_bus &&\
*/
other.m_function == m_function &&\ other.m_function == m_function &&\
other.m_tension_protocol == m_tension_protocol &&\ other.m_tension_protocol == m_tension_protocol &&\
other.m_wire_color == m_wire_color && \ other.m_wire_color == m_wire_color && \
@@ -967,9 +962,8 @@ void SingleLineProperties::toSettings(QSettings &settings,
@param settings Parametres a lire @param settings Parametres a lire
@param prefix prefix a ajouter devant les noms des parametres @param prefix prefix a ajouter devant les noms des parametres
*/ */
void SingleLineProperties::fromSettings( void SingleLineProperties::fromSettings(QSettings &settings,
const QSettings &settings, const QString &prefix) const QString &prefix) {
{
hasGround = settings.value(prefix + "hasGround", true).toBool(); hasGround = settings.value(prefix + "hasGround", true).toBool();
hasNeutral = settings.value(prefix + "hasNeutral", true).toBool(); hasNeutral = settings.value(prefix + "hasNeutral", true).toBool();
phases = settings.value(prefix + "phases", 1).toInt(); phases = settings.value(prefix + "phases", 1).toInt();
+13 -8
View File
@@ -42,15 +42,14 @@ class SingleLineProperties: public PropertiesInterface {
QDomElement toXml(QDomDocument& doc) const override; QDomElement toXml(QDomDocument& doc) const override;
bool fromXml(const QDomElement &) override; bool fromXml(const QDomElement &) override;
static bool valideXml(QDomElement& element); static bool valideXml(QDomElement& element);
void toSettings(QSettings &, const QString & = QString()) const override; void toSettings(QSettings &, const QString & = QString()) const;
void fromSettings(const QSettings &, const QString & = QString()) override; void fromSettings(QSettings &, const QString & = QString());
/// Whether the singleline conductor should display the ground symbol /// Whether the singleline conductor should display the ground symbol
bool hasGround{true}; bool hasGround{true};
/// Whether the singleline conductor should display the neutral symbol /// Whether the singleline conductor should display the neutral symbol
bool hasNeutral{true}; bool hasNeutral{true};
/// Protective Earth Neutral: visually merge neutral and ground /// Protective Earth Neutral: visually merge neutral and ground
bool is_pen{false}; bool is_pen{false};
int operator==(const SingleLineProperties &) const; int operator==(const SingleLineProperties &) const;
@@ -82,6 +81,7 @@ class ConductorProperties: public PropertiesInterface
*/ */
enum ConductorType { Single, Multi }; enum ConductorType { Single, Multi };
//Attributes //Attributes
ConductorType type{ConductorType::Single}; ConductorType type{ConductorType::Single};
@@ -90,17 +90,21 @@ class ConductorProperties: public PropertiesInterface
m_color_2{QColor(Qt::black)}, m_color_2{QColor(Qt::black)},
text_color{QColor(Qt::black)}; text_color{QColor(Qt::black)};
QString text, QString
text,
m_function, m_function,
m_tension_protocol, m_tension_protocol,
m_wire_color, m_wire_color,
m_wire_section, m_wire_section,
m_formula; m_formula,
m_bus,
m_cable;
int text_size{9}, int text_size{9},
m_dash_size = 1; m_dash_size = 1;
double cond_size{1}, double
cond_size{1},
verti_rotate_text, verti_rotate_text,
horiz_rotate_text; horiz_rotate_text;
@@ -108,7 +112,8 @@ class ConductorProperties: public PropertiesInterface
m_one_text_per_folio{true}, m_one_text_per_folio{true},
m_bicolor = false; m_bicolor = false;
Qt::Alignment m_horizontal_alignment = Qt::AlignBottom, Qt::Alignment
m_horizontal_alignment = Qt::AlignBottom,
m_vertical_alignment = Qt::AlignRight; m_vertical_alignment = Qt::AlignRight;
Qt::PenStyle style{Qt::PenStyle::SolidLine}; Qt::PenStyle style{Qt::PenStyle::SolidLine};
@@ -120,7 +125,7 @@ class ConductorProperties: public PropertiesInterface
bool fromXml(const QDomElement &) override; bool fromXml(const QDomElement &) override;
static bool valideXml(QDomElement& element); static bool valideXml(QDomElement& element);
void toSettings(QSettings &, const QString & = QString()) const override; void toSettings(QSettings &, const QString & = QString()) const override;
void fromSettings(const QSettings &, const QString & = QString()) override; 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);
+67 -63
View File
@@ -734,20 +734,19 @@ QDomDocument Diagram::toXml(bool whole_content) {
// schema properties // schema properties
// proprietes du schema // proprietes du schema
if (whole_content) if (whole_content) {
{
// TODO: compare with old version // TODO: compare with old version
border_and_titleblock.titleBlockToXml(dom_root); border_and_titleblock.titleBlockToXml(dom_root);
border_and_titleblock.borderToXml(dom_root); border_and_titleblock.borderToXml(dom_root);
// Default conductor properties // Default conductor properties
dom_root.appendChild(defaultConductorProperties.toXml(document)); dom_root.appendChild(defaultConductorProperties.toXml(document));
document.createElement("defaultconductor");
// Conductor autonum // Conductor autonum
if (!m_conductors_autonum_name.isEmpty()) if (!m_conductors_autonum_name.isEmpty()) {
{ dom_root.setAttribute("conductorAutonum",
dom_root.setAttribute( m_conductors_autonum_name);
"conductorAutonum",m_conductors_autonum_name);
} }
//Default New Element //Default New Element
@@ -914,12 +913,12 @@ QDomDocument Diagram::toXml(bool whole_content) {
} }
} }
// correspondence table between the addresses of the terminals and their ids
// table de correspondance entre les adresses des bornes et leurs ids // table de correspondance entre les adresses des bornes et leurs ids
if (!list_elements.isEmpty()) { if (!list_elements.isEmpty()) {
auto dom_elements = document.createElement("elements"); auto dom_elements = document.createElement("elements");
for (auto elmt : list_elements) for (auto elmt : list_elements) {
{
dom_elements.appendChild(elmt->toXml(document)); dom_elements.appendChild(elmt->toXml(document));
} }
dom_root.appendChild(dom_elements); dom_root.appendChild(dom_elements);
@@ -927,8 +926,7 @@ QDomDocument Diagram::toXml(bool whole_content) {
if (!list_conductors.isEmpty()) { if (!list_conductors.isEmpty()) {
auto dom_conductors = document.createElement("conductors"); auto dom_conductors = document.createElement("conductors");
for (auto cond : list_conductors) for (auto cond : list_conductors) {
{
dom_conductors.appendChild(cond->toXml(document)); dom_conductors.appendChild(cond->toXml(document));
} }
dom_root.appendChild(dom_conductors); dom_root.appendChild(dom_conductors);
@@ -1084,28 +1082,25 @@ bool Diagram::initFromXml(QDomElement &document,
/** /**
@brief findTerminal @brief findTerminal
@param conductor_index Find terminal to which the conductor should be connected
@param conductor @param conductor_index 1 or 2 depending on which terminal is searched
@param table_adr_id @param f Conductor xml element
@param added_elements @param table_adr_id Hash table to all terminal id assignement (legacy)
@param added_elements Elements found in the xml file
@return @return
*/ */
Terminal* findTerminal( Terminal* findTerminal(int conductor_index,
int conductor_index,
QDomElement& conductor, QDomElement& conductor,
QHash<int, Terminal *>& table_adr_id, QHash<int,
QList<Element *>& added_elements) Terminal *>& table_adr_id,
{ QList<Element *>& added_elements) {
assert(conductor_index == 1 || conductor_index == 2); assert(conductor_index == 1 || conductor_index == 2);
QString element_index = "element" + QString::number(conductor_index); QString element_index = "element" + QString::number(conductor_index);
QString terminal_index = "terminal" + QString::number(conductor_index); QString terminal_index = "terminal" + QString::number(conductor_index);
QUuid element_uuid; QUuid element_uuid;
if (PropertiesInterface::propertyUuid( if (PropertiesInterface::propertyUuid(conductor, element_index, &element_uuid) == PropertiesInterface::PropertyFlags::Success) {
conductor, element_index, &element_uuid)
== PropertiesInterface::PropertyFlags::Success)
{
// element1 did not exist in the conductor part of the xml until prior 0.7 // element1 did not exist in the conductor part of the xml until prior 0.7
// It is used as an indicator that uuid's are used to identify terminals // It is used as an indicator that uuid's are used to identify terminals
bool element_found = false; bool element_found = false;
@@ -1114,8 +1109,7 @@ Terminal* findTerminal(
continue; continue;
element_found = true; element_found = true;
QUuid terminal_uuid; QUuid terminal_uuid;
PropertiesInterface::propertyUuid( PropertiesInterface::propertyUuid(conductor, terminal_index, &terminal_uuid);
conductor, terminal_index, &terminal_uuid);
for (auto terminal: element->terminals()) { for (auto terminal: element->terminals()) {
if (terminal->uuid() != terminal_uuid) if (terminal->uuid() != terminal_uuid)
continue; continue;
@@ -1141,11 +1135,7 @@ Terminal* findTerminal(
} else { } else {
// Backward compatibility. Until version 0.7 a generated id is used to link the terminal. // Backward compatibility. Until version 0.7 a generated id is used to link the terminal.
int id_p1 = -1; int id_p1 = -1;
if ( if (PropertiesInterface::propertyInteger(conductor, terminal_index, &id_p1) != PropertiesInterface::PropertyFlags::Success) {
PropertiesInterface::propertyInteger(
conductor, terminal_index, &id_p1)
!= PropertiesInterface::PropertyFlags::Success)
{
qDebug() << "diagramm.cpp:findTerminal(): Reading Id was not successfull"; qDebug() << "diagramm.cpp:findTerminal(): Reading Id was not successfull";
} }
if (!table_adr_id.contains(id_p1)) { if (!table_adr_id.contains(id_p1)) {
@@ -1161,18 +1151,39 @@ Terminal* findTerminal(
/** /**
@brief Diagram::fromXml @brief Diagram::fromXml
@param document Imports the described schema in an XML element. If a position is
@param position specified, the imported elements are positioned in such a way that the
@param consider_informations upper left corner of the smallest rectangle that can surround them all
@param content_ptr (the bounding rect) either at this position.
@return \~French Importe le schema decrit dans un element XML.
Si une position est precisee,
les elements importes sont positionnes de maniere a ce que le
coin superieur gauche du plus petit rectangle pouvant les entourant tous
(le bounding rect) soit a cette position.
\~ @param document :
The XML document to analyze
\~French Le document XML a analyser
\~ @param position :
The position of the diagram matters
\~French La position du schema importe
\~ @param consider_informations :
If true, additional information
(author, title, ...) will be taken into account
\~French Si vrai, les informations complementaires
(auteur, titre, ...) seront prises en compte
\~ @param content_ptr :
if this pointer to a DiagramContent is different from 0,
it will be filled with the content added to the schema by the fromXml
\~French si ce pointeur vers un DiagramContent est different de 0,
il sera rempli avec le contenu ajoute au schema par le fromXml
\~ @return
true if the import was successful, false otherwise
\~French true si l'import a reussi, false sinon
*/ */
bool Diagram::fromXml( bool Diagram::fromXml(QDomElement &document,
QDomElement &document,
QPointF position, QPointF position,
bool consider_informations, bool consider_informations,
DiagramContent *content_ptr) DiagramContent *content_ptr) {
{
const QDomElement& root = document; const QDomElement& root = document;
// The first element must be a diagram // The first element must be a diagram
if (root.tagName() != "diagram") return(false); if (root.tagName() != "diagram") return(false);
@@ -1180,14 +1191,8 @@ bool Diagram::fromXml(
qDebug() << "Diagram::fromXml; Diagram: " << root.attribute("title"); qDebug() << "Diagram::fromXml; Diagram: " << root.attribute("title");
// Read attributes of this diagram // Read attributes of this diagram
if (consider_informations) { if (consider_informations)
// Version of diagram {
bool conv_ok;
qreal version_value = root.attribute("version").toDouble(&conv_ok);
if (conv_ok) {
diagram_qet_version_ = version_value;
}
// Load border and titleblock // Load border and titleblock
border_and_titleblock.titleBlockFromXml(root); border_and_titleblock.titleBlockFromXml(root);
border_and_titleblock.borderFromXml(root); border_and_titleblock.borderFromXml(root);
@@ -1282,11 +1287,11 @@ bool Diagram::fromXml(
} }
} }
} }
//Load all elements from the collection in the XML //Load all elements from the XML
QList<Element *> added_elements; QList<Element *> added_elements;
QHash<int, Terminal *> table_adr_id; QHash<int, Terminal *> table_adr_id;
foreach (QDomElement element_xml, foreach (QDomElement element_xml,
QET::findInDomElement(root, "elements", "element")) // read all elements from the diagram QET::findInDomElement(root, "elements", "element"))
{ {
if (!Element::valideXml(element_xml)) continue; if (!Element::valideXml(element_xml)) continue;
@@ -1301,9 +1306,9 @@ bool Diagram::fromXml(
} }
int state = 0; int state = 0;
Element *nvel_elmt =
// Create element from the collection ElementFactory::Instance() -> createElement(
Element *nvel_elmt = ElementFactory::Instance() -> createElement(element_location, nullptr, &state); // read element definition from the collection! element_location, nullptr, &state);
if (state) if (state)
{ {
QString debug_message = QString debug_message =
@@ -1317,9 +1322,8 @@ bool Diagram::fromXml(
} }
addItem(nvel_elmt); addItem(nvel_elmt);
//Loading fail, remove item from the diagram //Loading fail, remove item from the diagram
if (!nvel_elmt->fromXml(element_xml, table_adr_id)) // load element definition from the diagram if (!nvel_elmt->fromXml(element_xml, table_adr_id))
{ {
removeItem(nvel_elmt); removeItem(nvel_elmt);
delete nvel_elmt; delete nvel_elmt;
@@ -1365,24 +1369,24 @@ bool Diagram::fromXml(
// Load conductor // Load conductor
QList<Conductor *> added_conductors; QList<Conductor *> added_conductors;
foreach (QDomElement f, QET::findInDomElement(root,
foreach (QDomElement conductorElement, "conductors",
QET::findInDomElement(root, "conductors", "conductor")) "conductor"))
{ {
if (!Conductor::valideXml(conductorElement)) continue; if (!Conductor::valideXml(f)) continue;
//Check if terminal that conductor must be linked is know //Check if terminal that conductor must be linked is know
Terminal* p1 = findTerminal(1, conductorElement, table_adr_id, added_elements); Terminal* p1 = findTerminal(1, f, table_adr_id, added_elements);
Terminal* p2 = findTerminal(2, conductorElement, table_adr_id, added_elements); Terminal* p2 = findTerminal(2, f, table_adr_id, added_elements);
if (p1 && p2 && p1 != p2) // why the condition for unequal is required? if (p1 && p2 && p1 != p2)// TODO: why the condition for unequal is required?
{ {
Conductor *c = new Conductor(p1, p2); Conductor *c = new Conductor(p1, p2);
if (c->isValid()) if (c->isValid())
{ {
addItem(c); addItem(c);
c -> fromXml(conductorElement); c -> fromXml(f);
added_conductors << c; added_conductors << c;
} }
else else
@@ -1528,7 +1532,7 @@ void Diagram::refreshContents()
/** /**
@brief Diagram::addItem @brief Diagram::addItem
Réimplemented from QGraphicsScene::addItem(QGraphicsItem *item) R??implemented from QGraphicsScene::addItem(QGraphicsItem *item)
Do some specific operation if item need it (for exemple an element) Do some specific operation if item need it (for exemple an element)
@param item @param item
*/ */
+27 -14
View File
@@ -168,20 +168,31 @@ class Diagram : public QGraphicsScene
// methods related to XML import/export // methods related to XML import/export
QDomDocument toXml(bool = true); QDomDocument toXml(bool = true);
bool initFromXml(QDomElement &, QPointF = QPointF(), bool initFromXml(QDomElement &,
bool = true, DiagramContent * = nullptr); QPointF = QPointF(),
bool fromXml( bool = true,
QDomDocument &, QPointF = QPointF(), DiagramContent * = nullptr);
bool = true, DiagramContent * = nullptr); bool fromXml(QDomDocument &,
bool fromXml( QPointF = QPointF(),
QDomElement &, QPointF = QPointF(), bool = true,
bool = true, DiagramContent * = nullptr); DiagramContent * = nullptr);
void folioSequentialsToXml( bool fromXml(QDomElement &,
QHash<QString, QStringList>*, QDomElement *, const QString&, QPointF = QPointF(),
const QString&, QDomDocument *); bool = true,
void folioSequentialsFromXml( DiagramContent * = nullptr);
const QDomElement&, QHash<QString,QStringList>*, const QString&, void folioSequentialsToXml(QHash<QString,
const QString&, const QString&,const QString&); QStringList>*,
QDomElement *,
const QString&,
const QString&,
QDomDocument *);
void folioSequentialsFromXml(const QDomElement&,
QHash<QString,
QStringList>*,
const QString&,
const QString&,
const QString&,
const QString&);
void refreshContents(); void refreshContents();
@@ -271,6 +282,8 @@ class Diagram : public QGraphicsScene
/// from the diagram within elements collection /// from the diagram within elements collection
void findElementRequired(const ElementsLocation &); void findElementRequired(const ElementsLocation &);
/// Signal emitted when users wish to edit an element from the diagram
void editElementRequired(const ElementsLocation &);
void diagramActivated(); void diagramActivated();
}; };
Q_DECLARE_METATYPE(Diagram *) Q_DECLARE_METATYPE(Diagram *)
+4 -6
View File
@@ -209,17 +209,15 @@ void DiagramContext::toSettings(QSettings &settings, const QString &array_name)
Read this context properties from \a settings by running through the array Read this context properties from \a settings by running through the array
named \a array_name. named \a array_name.
*/ */
void DiagramContext::fromSettings(const QSettings &settings, const QString &array_name) { void DiagramContext::fromSettings(QSettings &settings, const QString &array_name) {
// TODO: find better solution than const cast int size = settings.beginReadArray(array_name);
QSettings& s = const_cast<QSettings&>(settings);
int size = s.beginReadArray(array_name);
for (int i = 0 ; i < size; ++ i) { for (int i = 0 ; i < size; ++ i) {
s.setArrayIndex(i); settings.setArrayIndex(i);
QString key = settings.value("name").toString(); QString key = settings.value("name").toString();
if (key.isEmpty()) continue; if (key.isEmpty()) continue;
addValue(key, settings.value("value").toString()); addValue(key, settings.value("value").toString());
} }
s.endArray(); settings.endArray();
} }
/** /**
+1 -1
View File
@@ -79,7 +79,7 @@ class DiagramContext
void fromXml(const QDomElement &, const QString & = "property"); void fromXml(const QDomElement &, const QString & = "property");
void fromXml(const pugi::xml_node &dom_element, const QString &tag_name = "property"); void fromXml(const pugi::xml_node &dom_element, const QString &tag_name = "property");
void toSettings(QSettings &, const QString &) const; void toSettings(QSettings &, const QString &) const;
void fromSettings(const QSettings &, const QString &); void fromSettings(QSettings &, const QString &);
static QString validKeyRegExp(); static QString validKeyRegExp();
@@ -161,8 +161,7 @@ void CustomElementGraphicPart::setAntialiased(const bool b)
Each style separate by ; and name-style/value are separate by : Each style separate by ; and name-style/value are separate by :
@param qde : QDOmElement used to write the style. @param qde : QDOmElement used to write the style.
*/ */
void CustomElementGraphicPart::stylesToXml( void CustomElementGraphicPart::stylesToXml(QDomDocument &xml_document, QDomElement &qde) const
QDomDocument &xml_document, QDomElement &qde) const
{ {
QString css_like_styles; QString css_like_styles;
@@ -513,15 +512,19 @@ void CustomElementGraphicPart::stylesFromXml(const QDomElement &qde)
QString style_string; QString style_string;
propertyString(qde, "style", &style_string); propertyString(qde, "style", &style_string);
//Get the list of pair style/value //Get the list of pair style/value
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ### Qt 6: remove
QStringList styles = style_string.split(";", QString::SkipEmptyParts); QStringList styles = qde.attribute("style").split(";", QString::SkipEmptyParts);
#else #else
#if TODO_LIST #if TODO_LIST
#pragma message("@TODO remove code for QT 5.14 or later") #pragma message("@TODO remove code for QT 5.14 or later")
#endif #endif
QStringList styles = qde.attribute("style").split(";", Qt::SkipEmptyParts); QStringList styles = qde.attribute("style").split(";", Qt::SkipEmptyParts);
#endif #endif
//Check each pair of style //Check each pair of style
QRegularExpression rx("^\\s*([a-z-]+)\\s*:\\s*([a-zA-Z-]+)\\s*$"); QRegularExpression rx("^\\s*([a-z-]+)\\s*:\\s*([a-zA-Z-]+)\\s*$");
foreach (QString style, styles) foreach (QString style, styles)
@@ -1327,7 +1330,7 @@ void CustomElementGraphicPart::mouseReleaseEvent(QGraphicsSceneMouseEvent *event
if((event->button() & Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable) && m_origin_pos != pos()) if((event->button() & Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable) && m_origin_pos != pos())
{ {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(this, "pos", QVariant(m_origin_pos), QVariant(pos())); QPropertyUndoCommand *undo = new QPropertyUndoCommand(this, "pos", QVariant(m_origin_pos), QVariant(pos()));
undo->setText(tr("Déplacer une primitive")); undo->setText(tr("D??placer une primitive"));
undo->enableAnimation(); undo->enableAnimation();
elementScene()->undoStack().push(undo); elementScene()->undoStack().push(undo);
} }
+7 -7
View File
@@ -97,10 +97,10 @@ void PartArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *options,
} }
/** /**
* @brief PartArc::toXml @brief PartArc::toXml
* Export this arc in xml Export this arc in xml
* @param xml_document : Xml document to use for create the xml element. @param xml_document : Xml document to use for create the xml element.
* @return : an xml element that describe this arc @return : an xml element that describe this arc
*/ */
QDomElement PartArc::toXml(QDomDocument &xml_document) const QDomElement PartArc::toXml(QDomDocument &xml_document) const
{ {
@@ -122,9 +122,9 @@ QDomElement PartArc::toXml(QDomDocument &xml_document) const
} }
/** /**
* @brief PartArc::fromXml @brief PartArc::fromXml
* Import the properties of this arc from a xml element. Import the properties of this arc from a xml element.
* @param qde : Xml document to use. @param qde : Xml document to use.
*/ */
bool PartArc::fromXml(const QDomElement &qde) { bool PartArc::fromXml(const QDomElement &qde) {
stylesFromXml(qde); stylesFromXml(qde);
+2
View File
@@ -54,6 +54,8 @@ class PartArc : public AbstractPartEllipse
QDomElement toXml (QDomDocument &) const override; QDomElement toXml (QDomDocument &) const override;
bool fromXml (const QDomElement &) override; bool fromXml (const QDomElement &) override;
static bool valideXml(QDomElement& element); static bool valideXml(QDomElement& element);
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
QPainterPath shape() const override; QPainterPath shape() const override;
QPainterPath shadowShape() const override; QPainterPath shadowShape() const override;
@@ -88,9 +88,9 @@ void PartDynamicTextField::handleUserTransformation(
} }
/** /**
* @brief PartDynamicTextField::toXml @brief PartDynamicTextField::toXml
* @param document @param dom_doc
* @return @return
*/ */
QDomElement PartDynamicTextField::toXml(QDomDocument &dom_doc) const QDomElement PartDynamicTextField::toXml(QDomDocument &dom_doc) const
{ {
@@ -106,7 +106,6 @@ QDomElement PartDynamicTextField::toXml(QDomDocument &dom_doc) const
root_element.appendChild(createXmlProperty(dom_doc, "frame", m_frame)); root_element.appendChild(createXmlProperty(dom_doc, "frame", m_frame));
root_element.appendChild(createXmlProperty(dom_doc, "text_width", m_text_width)); root_element.appendChild(createXmlProperty(dom_doc, "text_width", m_text_width));
QMetaEnum me = DynamicElementTextItem::textFromMetaEnum(); QMetaEnum me = DynamicElementTextItem::textFromMetaEnum();
root_element.appendChild(createXmlProperty(dom_doc, "text_from", me.valueToKey(m_text_from))); root_element.appendChild(createXmlProperty(dom_doc, "text_from", me.valueToKey(m_text_from)));
@@ -128,6 +127,7 @@ QDomElement PartDynamicTextField::toXml(QDomDocument &dom_doc) const
QDomElement dom_text = dom_doc.createElement("text"); QDomElement dom_text = dom_doc.createElement("text");
dom_text.appendChild(dom_doc.createTextNode(toPlainText())); dom_text.appendChild(dom_doc.createTextNode(toPlainText()));
root_element.appendChild(dom_text); root_element.appendChild(dom_text);
//Info name //Info name
if(!m_info_name.isEmpty()) { if(!m_info_name.isEmpty()) {
QDomElement dom_info_name = dom_doc.createElement("info_name"); QDomElement dom_info_name = dom_doc.createElement("info_name");
@@ -153,8 +153,8 @@ QDomElement PartDynamicTextField::toXml(QDomDocument &dom_doc) const
} }
/** /**
* @brief PartDynamicTextField::fromXml @brief PartDynamicTextField::fromXml
* @param element @param dom_elmt
*/ */
bool PartDynamicTextField::fromXml(const QDomElement &dom_elmt) bool PartDynamicTextField::fromXml(const QDomElement &dom_elmt)
{ {
@@ -162,8 +162,8 @@ bool PartDynamicTextField::fromXml(const QDomElement &dom_elmt)
qDebug() << "PartDynamicTextField::fromXml : Wrong tagg name"; qDebug() << "PartDynamicTextField::fromXml : Wrong tagg name";
return false; return false;
} }
double x=0, y=0, z=0, rot=0;
double x=0, y=0, z=0, rot=0;
if (propertyDouble(dom_elmt, "x", &x) == PropertyFlags::NoValidConversion || if (propertyDouble(dom_elmt, "x", &x) == PropertyFlags::NoValidConversion ||
propertyDouble(dom_elmt, "y", &y) == PropertyFlags::NoValidConversion || propertyDouble(dom_elmt, "y", &y) == PropertyFlags::NoValidConversion ||
propertyDouble(dom_elmt, "z", &z) == PropertyFlags::NoValidConversion || propertyDouble(dom_elmt, "z", &z) == PropertyFlags::NoValidConversion ||
@@ -180,8 +180,7 @@ bool PartDynamicTextField::fromXml(const QDomElement &dom_elmt)
QFont font_; QFont font_;
font_.fromString(font); font_.fromString(font);
setFont(font_); setFont(font_);
} } else { //Keep compatibility TODO remove in futur
else {
#if TODO_LIST #if TODO_LIST
#pragma message("@TODO remove in futur") #pragma message("@TODO remove in futur")
#endif #endif
@@ -207,7 +206,8 @@ bool PartDynamicTextField::fromXml(const QDomElement &dom_elmt)
if(propertyString(dom_elmt, "Halignment", &alignment) != PropertyFlags::NotFound) if(propertyString(dom_elmt, "Halignment", &alignment) != PropertyFlags::NotFound)
setAlignment(Qt::Alignment(me.keyToValue(alignment.toStdString().data()))); setAlignment(Qt::Alignment(me.keyToValue(alignment.toStdString().data())));
if(propertyString(dom_elmt, "Valignment", &alignment) != PropertyFlags::NotFound) if(propertyString(dom_elmt, "Valignment", &alignment) != PropertyFlags::NotFound)
setAlignment(Qt::Alignment(me.keyToValue(alignment.toStdString().data())) | this->alignment()); setAlignment(Qt::Alignment(
me.keyToValue(dom_elmt.attribute("Valignment").toStdString().data())) | this -> alignment());
//Text //Text
QDomElement dom_text = dom_elmt.firstChildElement("text"); QDomElement dom_text = dom_elmt.firstChildElement("text");
@@ -498,7 +498,7 @@ void PartDynamicTextField::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
m_origine_pos != pos()) { m_origine_pos != pos()) {
QPropertyUndoCommand *undo =\ QPropertyUndoCommand *undo =\
new QPropertyUndoCommand(this, "pos", QVariant(m_origine_pos), QVariant(pos())); new QPropertyUndoCommand(this, "pos", QVariant(m_origine_pos), QVariant(pos()));
undo -> setText(tr("Déplacer un champ texte")); undo -> setText(tr("D??placer un champ texte"));
undo -> enableAnimation(); undo -> enableAnimation();
elementScene() -> undoStack().push(undo); elementScene() -> undoStack().push(undo);
} }
@@ -79,6 +79,9 @@ class PartDynamicTextField : public QGraphicsTextItem, public CustomElementPart
bool 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);
static bool valideXml(QDomElement& dom_elmt); static bool valideXml(QDomElement& dom_elmt);
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
DynamicElementTextItem::TextFrom textFrom() const; DynamicElementTextItem::TextFrom textFrom() const;
void setTextFrom (DynamicElementTextItem::TextFrom text_from); void setTextFrom (DynamicElementTextItem::TextFrom text_from);
QString text() const; QString text() const;
+7 -7
View File
@@ -78,10 +78,10 @@ void PartEllipse::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
} }
/** /**
* @brief PartEllipse::toXml @brief PartEllipse::toXml
* Export this ellipse in xml Export this ellipse in xml
* @param xml_document : Xml document to use for create the xml element. @param xml_document : Xml document to use for create the xml element.
* @return : an xml element that describe this ellipse @return : an xml element that describe this ellipse
*/ */
QDomElement PartEllipse::toXml(QDomDocument &xml_document) const QDomElement PartEllipse::toXml(QDomDocument &xml_document) const
{ {
@@ -108,9 +108,9 @@ QDomElement PartEllipse::toXml(QDomDocument &xml_document) const
} }
/** /**
* @brief PartEllipse::fromXml @brief PartEllipse::fromXml
* Import the properties of this ellipse from a xml element. Import the properties of this ellipse from a xml element.
* @param qde : Xml document to use. @param qde : Xml document to use.
*/ */
bool PartEllipse::fromXml(const QDomElement &qde) bool PartEllipse::fromXml(const QDomElement &qde)
{ {
@@ -55,6 +55,8 @@ class PartEllipse : public AbstractPartEllipse
QDomElement toXml (QDomDocument &) const override; QDomElement toXml (QDomDocument &) const override;
bool fromXml (const QDomElement &) override; bool fromXml (const QDomElement &) override;
static bool valideXml(QDomElement& element); static bool valideXml(QDomElement& element);
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
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();}
+8 -9
View File
@@ -104,10 +104,10 @@ void PartLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *options,
} }
/** /**
* @brief PartLine::toXml @brief PartLine::toXml
* Export this line in xml Export this line in xml
* @param xml_document : Xml document to use for create the xml element. @param xml_document : Xml document to use for create the xml element.
* @return an xml element that describe this line @return an xml element that describe this line
*/ */
QDomElement PartLine::toXml(QDomDocument &xml_document) const QDomElement PartLine::toXml(QDomDocument &xml_document) const
{ {
@@ -131,12 +131,11 @@ QDomElement PartLine::toXml(QDomDocument &xml_document) const
} }
/** /**
* @brief PartLine::fromXml @brief PartLine::fromXml
* Import the properties of this line from a xml element. Import the properties of this line from a xml element.
* @param qde : Xml document to use @param qde : Xml document to use
*/ */
bool PartLine::fromXml(const QDomElement &qde) bool PartLine::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;
+2
View File
@@ -73,6 +73,8 @@ class PartLine : public CustomElementGraphicPart
QDomElement toXml(QDomDocument &) const override; QDomElement toXml(QDomDocument &) const override;
bool fromXml(const QDomElement &) override; bool fromXml(const QDomElement &) override;
bool valideXml(QDomElement& element) const; bool valideXml(QDomElement& element) const;
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
virtual QPointF sceneP1() const; virtual QPointF sceneP1() const;
virtual QPointF sceneP2() const; virtual QPointF sceneP2() const;
QPainterPath shape() const override; QPainterPath shape() const override;
+8 -8
View File
@@ -85,9 +85,9 @@ void PartPolygon::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
} }
/** /**
* @brief PartPolygon::fromXml @brief PartPolygon::fromXml
* Import the properties of this polygon from a xml element Import the properties of this polygon from a xml element
* @param qde : Xml document to use @param qde : Xml document to use
*/ */
bool PartPolygon::fromXml(const QDomElement &qde) bool PartPolygon::fromXml(const QDomElement &qde)
{ {
@@ -123,10 +123,10 @@ bool PartPolygon::fromXml(const QDomElement &qde)
} }
/** /**
* @brief PartPolygon::toXml @brief PartPolygon::toXml
* Export this polygin in xml Export this polygin in xml
* @param xml_document : Xml document to use for create the xml element @param xml_document : Xml document to use for create the xml element
* @return an xml element that describe this polygon @return an xml element that describe this polygon
*/ */
QDomElement PartPolygon::toXml(QDomDocument &xml_document) const QDomElement PartPolygon::toXml(QDomDocument &xml_document) const
{ {
@@ -540,7 +540,7 @@ void PartPolygon::insertPoint()
if(new_polygon != m_polygon) if(new_polygon != m_polygon)
{ {
//Wrap the undo for avoid to merge the undo commands when user add several points. //Wrap the undo for avoid to merge the undo commands when user add several points.
QUndoCommand *undo = new QUndoCommand(tr("Ajouter un point à un polygone")); QUndoCommand *undo = new QUndoCommand(tr("Ajouter un point ?? un polygone"));
new QPropertyUndoCommand(this, "polygon", m_polygon, new_polygon, undo); new QPropertyUndoCommand(this, "polygon", m_polygon, new_polygon, undo);
elementScene()->undoStack().push(undo); elementScene()->undoStack().push(undo);
} }
@@ -64,6 +64,8 @@ class PartPolygon : public CustomElementGraphicPart
bool fromXml(const QDomElement &) override; bool fromXml(const QDomElement &) override;
QDomElement toXml(QDomDocument &) const override; QDomElement toXml(QDomDocument &) const override;
static bool valideXml(QDomElement& element); static bool valideXml(QDomElement& element);
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
QPainterPath shape () const override; QPainterPath shape () const override;
@@ -93,6 +93,7 @@ QDomElement PartRectangle::toXml(QDomDocument &xml_document) const
xml_element.appendChild(createXmlProperty(xml_document, "y", top_left.y())); xml_element.appendChild(createXmlProperty(xml_document, "y", top_left.y()));
xml_element.appendChild(createXmlProperty(xml_document, "width", m_rect.width())); xml_element.appendChild(createXmlProperty(xml_document, "width", m_rect.width()));
xml_element.appendChild(createXmlProperty(xml_document, "height", m_rect.height())); xml_element.appendChild(createXmlProperty(xml_document, "height", m_rect.height()));
QRectF rect = m_rect.normalized(); QRectF rect = m_rect.normalized();
qreal x = m_xRadius; qreal x = m_xRadius;
if (x > rect.width()/2) { if (x > rect.width()/2) {
@@ -130,10 +131,10 @@ bool PartRectangle::fromXml(const QDomElement &qde)
setPos(mapFromScene(x, y)); setPos(mapFromScene(x, y));
if (propertyDouble(qde, "width", &w) == PropertyFlags::NoValidConversion || if (propertyDouble(qde, "width", &w) == PropertyFlags::NoValidConversion ||
propertyDouble(qde, "width", &h) == PropertyFlags::NoValidConversion) propertyDouble(qde, "height", &h) == PropertyFlags::NoValidConversion)
return false; return false;
QRectF rect(QPointF(x,y), QSizeF(w, h)); QRectF rect(QPointF(0,0), QSizeF(w, h));
setRect(rect.normalized()); setRect(rect.normalized());
@@ -152,7 +153,7 @@ bool PartRectangle::valideXml(QDomElement& element) {
if ((propertyDouble(element, "x") & PropertyFlags::NoValidConversion) | if ((propertyDouble(element, "x") & PropertyFlags::NoValidConversion) |
(propertyDouble(element, "y") & PropertyFlags::NoValidConversion) | (propertyDouble(element, "y") & PropertyFlags::NoValidConversion) |
(propertyDouble(element, "width") & PropertyFlags::NoValidConversion) | (propertyDouble(element, "width") & PropertyFlags::NoValidConversion) |
(propertyDouble(element, "width") & PropertyFlags::NoValidConversion) | (propertyDouble(element, "height") & PropertyFlags::NoValidConversion) |
(propertyDouble(element, "rx") & PropertyFlags::NoValidConversion) | (propertyDouble(element, "rx") & PropertyFlags::NoValidConversion) |
(propertyDouble(element, "ry") & PropertyFlags::NoValidConversion)) (propertyDouble(element, "ry") & PropertyFlags::NoValidConversion))
return false; return false;
@@ -63,6 +63,8 @@ class PartRectangle : public CustomElementGraphicPart
QDomElement toXml (QDomDocument &) const override; QDomElement toXml (QDomDocument &) const override;
bool fromXml (const QDomElement &) override; bool fromXml (const QDomElement &) override;
static bool valideXml(QDomElement& element); static bool valideXml(QDomElement& element);
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
QRectF rect() const; QRectF rect() const;
void setRect(const QRectF &rect); void setRect(const QRectF &rect);
+3 -5
View File
@@ -47,7 +47,6 @@ PartTerminal::~PartTerminal()
*/ */
bool PartTerminal::fromXml(const QDomElement &xml_elmt) { bool PartTerminal::fromXml(const QDomElement &xml_elmt) {
QUuid uuid;
// update part and add uuid, which is used in the new version to connect terminals together // update part and add uuid, which is used in the new version to connect terminals together
// if the attribute not exists, means, the element is created with an older version of qet. So use the legacy approach // if the attribute not exists, means, the element is created with an older version of qet. So use the legacy approach
// to identify terminals // to identify terminals
@@ -67,8 +66,8 @@ bool PartTerminal::fromXml(const QDomElement &xml_elmt) {
@param xml_document Document XML a utiliser pour creer l'element XML @param xml_document Document XML a utiliser pour creer l'element XML
@return un element XML decrivant la borne @return un element XML decrivant la borne
*/ */
QDomElement PartTerminal::toXml(QDomDocument &xml_document) const QDomElement PartTerminal::toXml(QDomDocument &xml_document) const {
{
QDomElement qdo = xml_document.createElement("terminal"); QDomElement qdo = xml_document.createElement("terminal");
qdo.appendChild(createXmlProperty(xml_document, "uuid", d->m_uuid)); qdo.appendChild(createXmlProperty(xml_document, "uuid", d->m_uuid));
@@ -84,8 +83,7 @@ QDomElement PartTerminal::toXml(QDomDocument &xml_document) const
return qdo; return qdo;
} }
bool PartTerminal::valideXml(QDomElement& element) bool PartTerminal::valideXml(QDomElement& element) {
{
return TerminalData::valideXml(element); return TerminalData::valideXml(element);
} }
+7 -3
View File
@@ -56,8 +56,12 @@ class PartTerminal : public CustomElementGraphicPart {
bool fromXml(const QDomElement &) override; bool fromXml(const QDomElement &) override;
QDomElement toXml(QDomDocument &) const override; QDomElement toXml(QDomDocument &) const override;
static bool valideXml(QDomElement& element); static bool valideXml(QDomElement& element);
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override; void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
void paint(
QPainter *painter,
const QStyleOptionGraphicsItem *,
QWidget *) override;
QPainterPath shape() const override; QPainterPath shape() const override;
QPainterPath shadowShape() const override {return shape();} QPainterPath shadowShape() const override {return shape();}
@@ -75,7 +79,7 @@ class PartTerminal : public CustomElementGraphicPart {
private: private:
void updateSecondPoint(); void updateSecondPoint();
TerminalData* d; // pointer to the terminal data TerminalData* d{nullptr}; // pointer to the terminal data
private: private:
QPointF saved_position_; QPointF saved_position_;
+2
View File
@@ -60,6 +60,8 @@ class PartText : public QGraphicsTextItem, public CustomElementPart {
QString xmlName() const override { return(QString("text")); } QString xmlName() const override { return(QString("text")); }
bool fromXml(const QDomElement &) override; bool fromXml(const QDomElement &) override;
static bool valideXml(QDomElement& element); static bool valideXml(QDomElement& element);
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
QDomElement toXml(QDomDocument &) const override; 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;
+8
View File
@@ -150,6 +150,14 @@ void Machine_info::send_info_to_debug()
} }
} }
/**
@brief Machine_info::~Machine_info
destructor
*/
Machine_info::~Machine_info()
{
}
/** /**
@brief Machine_info::init_get_Screen_info @brief Machine_info::init_get_Screen_info
Finds the largest screen and saves the values Finds the largest screen and saves the values
+1
View File
@@ -34,6 +34,7 @@ public:
int32_t i_max_screen_height(); int32_t i_max_screen_height();
QString compilation_info(); QString compilation_info();
void send_info_to_debug(); void send_info_to_debug();
~Machine_info();
signals: signals:
+10 -1
View File
@@ -16,7 +16,6 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "propertiesinterface.h" #include "propertiesinterface.h"
#include <QDebug> #include <QDebug>
/*! /*!
@@ -31,10 +30,20 @@ namespace {
const QString colorS = "color"; const QString colorS = "color";
} }
/**
@brief PropertiesInterface::PropertiesInterface
*/
PropertiesInterface::PropertiesInterface() PropertiesInterface::PropertiesInterface()
{ {
} }
/**
@brief PropertiesInterface::~PropertiesInterface
*/
PropertiesInterface::~PropertiesInterface()
{
}
bool PropertiesInterface::valideXml(QDomElement& element) { bool PropertiesInterface::valideXml(QDomElement& element) {
qDebug(QString("ValideXml() is not implemented. File: %1, Line: %2").arg(__FILE__).arg(__LINE__).toStdString().data()); qDebug(QString("ValideXml() is not implemented. File: %1, Line: %2").arg(__FILE__).arg(__LINE__).toStdString().data());
return false; return false;
+31 -4
View File
@@ -35,11 +35,38 @@ 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 virtual ~PropertiesInterface();
virtual void toSettings (QSettings &settings, const QString& = QString()) const {Q_UNUSED(settings)}; /**
virtual void fromSettings (const QSettings &settings, const QString& = QString()) {Q_UNUSED(settings)}; @brief toSettings
// Save/load properties to xml element Save properties to setting file.
@param settings : is use for prefix a word
befor the name of each paramètre
@param QString
*/
virtual void toSettings(QSettings &,
const QString & = QString()) const =0;
/**
@brief fromSettings
load properties to setting file.
@param settings : is use for prefix a word
befor the name of each paramètre
@param QString
*/
virtual void fromSettings(QSettings &,
const QString & = QString()) = 0;
/**
@brief toXml
Save properties to xml element
@param xml_document
@return QDomElement
*/
virtual QDomElement toXml (QDomDocument &xml_document) const =0; virtual QDomElement toXml (QDomDocument &xml_document) const =0;
/**
@brief fromXml
load properties to xml element
@param xml_element
@return true / false
*/
virtual bool fromXml (const QDomElement &xml_element) =0; virtual bool fromXml (const QDomElement &xml_element) =0;
static bool valideXml(QDomElement& element); static bool valideXml(QDomElement& element);
+38 -5
View File
@@ -33,15 +33,33 @@ void TerminalData::setParent(QGraphicsObject* parent)
q = parent; q = parent;
} }
void TerminalData::toSettings(QSettings& settings, const QString&) const /**
@brief TerminalData::toSettings
Save properties to setting file.
QString is use for prefix a word befor the name of each paramètre
@param settings UNUSED
@param prefix UNUSED
*/
void TerminalData::toSettings(QSettings &settings, const QString &prefix) const
{ {
Q_UNUSED(settings); Q_UNUSED(settings);
Q_UNUSED(prefix);
} }
void TerminalData::fromSettings(const QSettings& settings, const QString&) /**
@brief TerminalData::fromSettings
load properties to setting file.
QString is use for prefix a word befor the name of each paramètre
@param settings UNUSED
@param prefix UNUSED
*/
void TerminalData::fromSettings(QSettings &settings, const QString& prefix)
{ {
Q_UNUSED(settings); Q_UNUSED(settings);
Q_UNUSED(prefix);
} }
/** /**
@@ -60,7 +78,8 @@ QDomElement TerminalData::toXml(QDomDocument &xml_document) const
{ {
QDomElement xml_element = xml_document.createElement("terminaldata"); QDomElement xml_element = xml_document.createElement("terminaldata");
// write the position of the terminal
// Write name and number to XML
// m_pos cannot be stored, because in the partterminal it will not be updated. // m_pos cannot be stored, because in the partterminal it will not be updated.
// In PartTerminal m_pos is the position of the dock, in Terminal m_pos is the second side of the terminal // In PartTerminal m_pos is the position of the dock, in Terminal m_pos is the second side of the terminal
// This is hold for legacy compability reason // This is hold for legacy compability reason
@@ -72,10 +91,22 @@ QDomElement TerminalData::toXml(QDomDocument &xml_document) const
return(xml_element); return(xml_element);
} }
/*
@brief TerminalData::fromXml
load properties to xml element
@note This method is only called from the PartTerminal
and should never called from the Terminal class
@param xml_element
@return true if succeeded / false if the attribute is not real
*/
bool TerminalData::fromXml (const QDomElement &xml_element) // RETURNS True bool TerminalData::fromXml (const QDomElement &xml_element) // RETURNS True
{ {
qreal term_x = 0.0;
qreal term_y = 0.0;
// reads the position of the terminal
// lit la position de la borne // 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; return false;
@@ -89,6 +120,8 @@ bool TerminalData::fromXml (const QDomElement &xml_element) // RETURNS True
// do not write uuid from this class, because only PartTerminal::fromXml need // do not write uuid from this class, because only PartTerminal::fromXml need
// to write it to xml file. Terminal::fromXml does not need. // to write it to xml file. Terminal::fromXml does not need.
// if the attribute not exists, means, the element is created with an
// older version of qet. So use the legacy approach
//if (propertyString(xml_element, "name", &m_name)) //if (propertyString(xml_element, "name", &m_name))
@@ -99,9 +132,9 @@ bool TerminalData::fromXml (const QDomElement &xml_element) // RETURNS True
if (propertyString(xml_element, "orientation", &o)) if (propertyString(xml_element, "orientation", &o))
return false; return false;
// read the orientation of the terminal
// lit l'orientation de la borne // lit l'orientation de la borne
m_orientation = orientationFromString(o); m_orientation = orientationFromString(o);
return true; return true;
} }
+37 -33
View File
@@ -26,54 +26,58 @@ class TerminalData : public PropertiesInterface
void init(); void init();
void setParent(QGraphicsObject* parent); void setParent(QGraphicsObject* parent);
void toSettings(QSettings &settings,
// Save/load properties to setting file. QString is use for prefix a word befor the name of each paramètre const QString& prefix = QString()) const override;
void toSettings( void fromSettings(QSettings &settings,
QSettings &settings, const QString& = QString()) const override; const QString& = QString()) override;
void fromSettings(
const QSettings &settings, const QString& = QString()) override;
// Save/load properties to xml element
// This method is only called from the PartTerminal and should never called from the Terminal class
QDomElement toXml(QDomDocument &xml_element) const override; QDomElement toXml(QDomDocument &xml_element) const override;
bool fromXml(const QDomElement &xml_element) override; bool fromXml(const QDomElement &xml_element) override;
static bool valideXml(const 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
public: public:
/*! /**
* \brief m_orientation @brief m_orientation
* Orientation of the terminal Orientation of the terminal
*/ */
Qet::Orientation m_orientation{Qet::Orientation::North}; Qet::Orientation m_orientation{Qet::Orientation::North};
/*! /**
* \brief second_point @brief second_point
* Position of the second point of the terminal in scene coordinates Position of the second point of the terminal
in scene coordinates
*/ */
QPointF second_point{0,0}; QPointF second_point{0,0};
/*! /**
* \brief m_uuid @brief m_uuid
* Uuid of the terminal. Uuid of the terminal.
*
* In elementscene.cpp an element gets a new uuid when saving the element. In the current state In elementscene.cpp an element gets a new uuid when
* each connection is made by using the local position of the terminal and a dynamic id. In the new saving the element. In the current state
* case, each terminal should have it's own uuid to identify it uniquely. When changing each time this each connection is made by using the local position
* uuid, the conductor after updating the part is anymore valid. So if in the loaded document a uuid exists, of the terminal and a dynamic id. In the new
* use this one and don't create a new one. case, each terminal should have it's own uuid to
identify it uniquely. When changing each time this
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; // default is an invalid uuid. QUuid m_uuid; // default is an invalid uuid.
/*! /**
* \brief m_name @brief m_name
* Name of the element. It can be used to create wiring harness tables Name of the element.
It can be used to create wiring harness tables
*/ */
QString m_name; QString m_name;
/*! /**
* \brief m_pos @brief m_pos
* Position of the terminal. The second point is calculated from this position and the orientation Position of the terminal. The second point is calculated
* Important: this variable is only updated during read from xml and not during mouse move! from this position and the orientation
* It is used to store the initial position so that PartTerminal and Terminal have access to it. @note
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{0,0}; QPointF m_pos{0,0};
private: private:
+5 -4
View File
@@ -35,8 +35,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( void XRefProperties::toSettings(QSettings &settings,
QSettings &settings,
const QString &prefix) const const QString &prefix) const
{ {
settings.setValue(prefix + "showpowerctc", m_show_power_ctc); settings.setValue(prefix + "showpowerctc", m_show_power_ctc);
@@ -66,7 +65,8 @@ void XRefProperties::toSettings(
@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(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();
@@ -101,6 +101,7 @@ QDomElement XRefProperties::toXml(QDomDocument &xml_document) const
xml_element.appendChild(createXmlProperty(xml_document, "displayhas", m_display == Cross? "cross" : "contacts")); xml_element.appendChild(createXmlProperty(xml_document, "displayhas", m_display == Cross? "cross" : "contacts"));
xml_element.appendChild(createXmlProperty(xml_document, "snapto", m_snap_to == Bottom? "bottom" : "label")); xml_element.appendChild(createXmlProperty(xml_document, "snapto", m_snap_to == Bottom? "bottom" : "label"));
QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>(); QMetaEnum var = QMetaEnum::fromType<Qt::Alignment>();
xml_element.appendChild(createXmlProperty(xml_document, "xrefpos", var.valueToKey(m_xref_pos))); xml_element.appendChild(createXmlProperty(xml_document, "xrefpos", var.valueToKey(m_xref_pos)));
xml_element.appendChild(createXmlProperty(xml_document, "offset", m_offset)); xml_element.appendChild(createXmlProperty(xml_document, "offset", m_offset));
@@ -146,7 +147,7 @@ bool XRefProperties::fromXml(const QDomElement &xml_element) {
propertyString(xml_element, "slave_label", &m_slave_label); propertyString(xml_element, "slave_label", &m_slave_label);
QString value; QString value;
foreach (QString key, m_prefix_keys) { foreach (QString key, m_prefix_keys) {
if (!propertyString(xml_element, key + "prefix", &value)); if (!propertyString(xml_element, key + "prefix", &value))
m_prefix.insert(key, value); m_prefix.insert(key, value);
} }
return true; return true;
+2 -1
View File
@@ -43,7 +43,8 @@ class XRefProperties : public PropertiesInterface
}; };
void toSettings (QSettings &settings, const QString& = QString()) const override; void toSettings (QSettings &settings, const QString& = QString()) const override;
void fromSettings (const QSettings &settings, const QString& = QString()) override; void fromSettings (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;
+6
View File
@@ -28,6 +28,12 @@
#include <QActionGroup> #include <QActionGroup>
/** /**
Permet de convertir une chaine de caracteres ("n", "s", "e" ou "w")
en orientation. Si la chaine fait plusieurs caracteres, seul le
premier est pris en compte. En cas d'incoherence, Qet::North est
retourne.
@param s Chaine de caractere cense representer une orientation
@return l'orientation designee par la chaine de caractere
Indique si deux orientations de Borne sont sur le meme axe (Vertical / Horizontal). Indique si deux orientations de Borne sont sur le meme axe (Vertical / Horizontal).
@param a La premiere orientation de Borne @param a La premiere orientation de Borne
@param b La seconde orientation de Borne @param b La seconde orientation de Borne
+92 -18
View File
@@ -573,12 +573,20 @@ ConductorTextItem *Conductor::textItem() const
} }
/** /**
@brief Conductor::valideXml Methode de validation d'element XML
@param e @param e Un element XML sense represente un Conducteur
@return true @return true si l'element XML represente bien un Conducteur ; false sinon
*/ */
bool Conductor::valideXml(QDomElement &e) bool Conductor::valideXml(QDomElement &e){
{
// // TODO: seems to short! (see fromXML)
// if (propertyDouble(e, "x") ||
// propertyDouble(e, "y"))
// return false;
// if (propertyBool(e, "freezeLabel"))
// return false;
return true; return true;
} }
@@ -949,7 +957,7 @@ void Conductor::pointsToSegments(const QList<QPointF>& points_list) {
/** /**
@brief Conductor::fromXml @brief Conductor::fromXml
Load the conductor and her information from xml element Load the conductor and her information from xml element
@param e @param dom_element
@return true is loading success else return false @return true is loading success else return false
*/ */
bool Conductor::fromXml(const QDomElement &dom_element) bool Conductor::fromXml(const QDomElement &dom_element)
@@ -978,13 +986,21 @@ bool Conductor::fromXml(const QDomElement &dom_element)
return return_; return return_;
} }
// does not support legacy method // does not support legacy method
// dom_element.setAttribute("terminal1", table_adr_id.value(terminal1)); /*!
QDomElement Conductor::toXml(QDomDocument & doc) const @brief Conductor::toXml
{ Exporte les caracteristiques du conducteur sous forme d'une element XML.
@param dom_document :
Le document XML a utiliser pour creer l'element XML
@param table_adr_id :
Hash stockant les correspondances entre les ids des
bornes dans le document XML et leur adresse en memoire
@return Un element XML representant le conducteur
*/
QDomElement Conductor::toXml(QDomDocument & doc) const {
QDomElement dom_element = doc.createElement("conductor"); QDomElement dom_element = doc.createElement("conductor");
dom_element.appendChild(createXmlProperty(doc, "x", pos().x())); dom_element.appendChild(createXmlProperty(doc, "x", pos().x()));
dom_element.appendChild(createXmlProperty(doc, "y", pos().y())); dom_element.appendChild(createXmlProperty(doc, "y", pos().y()));
@@ -1046,11 +1062,69 @@ QDomElement Conductor::toXml(QDomDocument & doc) const
} }
/** /**
@brief Conductor::pathFromXml Exporte les caracteristiques du conducteur sous forme d'une element XML.
Generate the path (of the line) from xml file by checking @param d Le document XML a utiliser pour creer l'element XML
the segments in the xml file @param table_adr_id Hash stockant les correspondances entre les ids des
@param e bornes dans le document XML et leur adresse en memoire
@return true if generate path success else return false @return Un element XML representant le conducteur
*/
//QDomElement Conductor::toXml(QDomDocument &dom_document, QHash<Terminal *, int> &table_adr_id) const
//{
// QDomElement dom_element = dom_document.createElement("conductor");
// dom_element.setAttribute("x", QString::number(pos().x()));
// dom_element.setAttribute("y", QString::number(pos().y()));
// // Terminal is uniquely identified by the uuid of the terminal and the element
// if (terminal1->uuid().isNull()) {
// // legacy method to identify the terminal
// dom_element.setAttribute("terminal1", table_adr_id.value(terminal1)); // for backward compability
// } else {
// dom_element.setAttribute("element1", terminal1->parentElement()->uuid().toString());
// dom_element.setAttribute("terminal1", terminal1->uuid().toString());
// }
// if (terminal2->uuid().isNull()) {
// // legacy method to identify the terminal
// dom_element.setAttribute("terminal2", table_adr_id.value(terminal2)); // for backward compability
// } else {
// dom_element.setAttribute("element2", terminal2->parentElement()->uuid().toString());
// dom_element.setAttribute("terminal2", terminal2->uuid().toString());
// }
// dom_element.setAttribute("freezeLabel", m_freeze_label? "true" : "false");
// // on n'exporte les segments du conducteur que si ceux-ci ont
// // ete modifies par l'utilisateur
// if (modified_path)
// {
// // parcours et export des segments
// QDomElement current_segment;
// foreach(ConductorSegment *segment, segmentsList())
// {
// current_segment = dom_document.createElement("segment");
// current_segment.setAttribute("orientation", segment -> isHorizontal() ? "horizontal" : "vertical");
// current_segment.setAttribute("length", QString("%1").arg(segment -> length()));
// dom_element.appendChild(current_segment);
// }
// }
// QDomElement dom_seq = m_autoNum_seq.toXml(dom_document);
// dom_element.appendChild(dom_seq);
// // Export the properties and text
// m_properties.toXml(dom_document);
// if(m_text_item->wasMovedByUser())
// {
// dom_element.setAttribute("userx", QString::number(m_text_item->pos().x()));
// dom_element.setAttribute("usery", QString::number(m_text_item->pos().y()));
// }
// if(m_text_item->wasRotateByUser())
// dom_element.setAttribute("rotation", QString::number(m_text_item->rotation()));
// return(dom_element);
//}
/**
*/ */
bool Conductor::pathFromXml(const QDomElement &e) { bool Conductor::pathFromXml(const QDomElement &e) {
// parcourt les elements XML "segment" et en extrait deux listes de longueurs // parcourt les elements XML "segment" et en extrait deux listes de longueurs
@@ -1327,7 +1401,7 @@ void Conductor::calculateTextItemPosition()
} }
//Adjust the position of text if his rotation //Adjust the position of text if his rotation
//is 0° or 270°, to be exactly centered to the conductor //is 0?? or 270??, to be exactly centered to the conductor
if (m_text_item -> rotation() == 0) if (m_text_item -> rotation() == 0)
{ {
text_pos.rx() -= m_text_item -> boundingRect().width()/2; text_pos.rx() -= m_text_item -> boundingRect().width()/2;
@@ -1604,12 +1678,12 @@ void Conductor::displayedTextChanged()
new_value.setValue(new_properties); new_value.setValue(new_properties);
QUndoCommand *undo = new QUndoCommand(tr("Modifier les propriétés d'un conducteur", "undo caption")); QUndoCommand *undo = new QUndoCommand(tr("Modifier les propri??t??s d'un conducteur", "undo caption"));
new QPropertyUndoCommand(this, "properties", old_value, new_value, undo); new QPropertyUndoCommand(this, "properties", old_value, new_value, undo);
if (!relatedPotentialConductors().isEmpty()) if (!relatedPotentialConductors().isEmpty())
{ {
undo->setText(tr("Modifier les propriétés de plusieurs conducteurs", "undo caption")); undo->setText(tr("Modifier les propri??t??s de plusieurs conducteurs", "undo caption"));
foreach (Conductor *potential_conductor, relatedPotentialConductors()) foreach (Conductor *potential_conductor, relatedPotentialConductors())
{ {
+2 -1
View File
@@ -102,8 +102,9 @@ class Conductor : public QGraphicsObject, public PropertiesInterface
public: public:
static bool valideXml (QDomElement &); static bool valideXml (QDomElement &);
bool fromXml (const QDomElement &) override; bool fromXml (const QDomElement &) override;
//QDomElement toXml (QDomDocument &, QHash<Terminal *, int> &) const;
QDomElement toXml (QDomDocument &doc) const override; QDomElement toXml (QDomDocument &doc) const override;
void toSettings(QSettings &, const QString & = QString()) const override {}
void fromSettings(QSettings &, const QString & = QString()) override {}
private: private:
bool pathFromXml(const QDomElement &); bool pathFromXml(const QDomElement &);
@@ -20,8 +20,6 @@
#include "qetapp.h" #include "qetapp.h"
#include "richtext/richtexteditor_p.h" #include "richtext/richtexteditor_p.h"
#include "diagram.h" #include "diagram.h"
#include "dynamicelementtextitem.h"
/** /**
@brief DiagramTextItem::DiagramTextItem @brief DiagramTextItem::DiagramTextItem
@@ -220,24 +218,12 @@ QRectF DiagramTextItem::frameRect() const
void DiagramTextItem::setHtml(const QString &text) void DiagramTextItem::setHtml(const QString &text)
{ {
DynamicElementTextItem* abc = dynamic_cast<DynamicElementTextItem*>(this);
if (abc) {
if (abc->searchedElement) {
int stop = 1;
}
}
QGraphicsTextItem::setHtml(text); QGraphicsTextItem::setHtml(text);
m_is_html = true; m_is_html = true;
} }
void DiagramTextItem::setPlainText(const QString &text) void DiagramTextItem::setPlainText(const QString &text)
{ {
DynamicElementTextItem* abc = dynamic_cast<DynamicElementTextItem*>(this);
if (abc) {
if (abc->searchedElement) {
int stop = 1;
}
}
QGraphicsTextItem::setPlainText(text); QGraphicsTextItem::setPlainText(text);
m_is_html = false; m_is_html = false;
} }
@@ -257,16 +243,6 @@ bool DiagramTextItem::isHtml() const
*/ */
void DiagramTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void DiagramTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{ {
DynamicElementTextItem* abc = dynamic_cast<DynamicElementTextItem*>(this);
if (abc) {
if (abc->searchedElement) {
int stop = 1;
QString text = toPlainText();
qDebug() << text;
}
}
painter -> setRenderHint(QPainter::Antialiasing, false); painter -> setRenderHint(QPainter::Antialiasing, false);
QGraphicsTextItem::paint(painter, option, widget); QGraphicsTextItem::paint(painter, option, widget);
@@ -325,9 +325,6 @@ DynamicElementTextItem::TextFrom DynamicElementTextItem::textFrom() const
*/ */
void DynamicElementTextItem::setTextFrom(DynamicElementTextItem::TextFrom text_from) void DynamicElementTextItem::setTextFrom(DynamicElementTextItem::TextFrom text_from)
{ {
if (searchedElement)
int stop = true;
if(m_text_from == text_from) if(m_text_from == text_from)
return; return;
@@ -392,9 +389,6 @@ QString DynamicElementTextItem::text() const
*/ */
void DynamicElementTextItem::setText(const QString &text) void DynamicElementTextItem::setText(const QString &text)
{ {
if (m_text == "14" && text == "")
int a = 54;
m_text_old = m_text;
m_text = text; m_text = text;
if(m_text_from == DynamicElementTextItem::UserText) if(m_text_from == DynamicElementTextItem::UserText)
setPlainText(m_text); setPlainText(m_text);
@@ -411,9 +405,6 @@ void DynamicElementTextItem::setInfoName(const QString &info_name)
QString old_info_name = m_info_name; QString old_info_name = m_info_name;
m_info_name = info_name; m_info_name = info_name;
if (searchedElement)
int stop = true;
if(old_info_name == "label") if(old_info_name == "label")
{ {
@@ -1334,8 +1325,6 @@ void DynamicElementTextItem::updateXref()
void DynamicElementTextItem::setPlainText(const QString &text) void DynamicElementTextItem::setPlainText(const QString &text)
{ {
if (text == "14")
searchedElement = true;
if (toPlainText() == text) if (toPlainText() == text)
return; return;
@@ -104,7 +104,6 @@ class DynamicElementTextItem : public DiagramTextItem
void setTextWidth(qreal width); void setTextWidth(qreal width);
void setXref_item(Qt::AlignmentFlag m_exHrefPos); void setXref_item(Qt::AlignmentFlag m_exHrefPos);
bool searchedElement{false};
protected: protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event) override; void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
@@ -141,8 +140,8 @@ class DynamicElementTextItem : public DiagramTextItem
m_master_element, m_master_element,
m_other_report; m_other_report;
QPointer <Conductor> m_watched_conductor; QPointer <Conductor> m_watched_conductor;
QString m_text, QString
m_text_old, m_text,
m_info_name, m_info_name,
m_composite_text, m_composite_text,
m_report_formula, m_report_formula,
@@ -150,10 +149,12 @@ class DynamicElementTextItem : public DiagramTextItem
DynamicElementTextItem::TextFrom m_text_from = UserText; DynamicElementTextItem::TextFrom m_text_from = UserText;
QUuid m_uuid; QUuid m_uuid;
QMetaObject::Connection m_report_formula_con; QMetaObject::Connection m_report_formula_con;
QList<QMetaObject::Connection> m_formula_connection, QList<QMetaObject::Connection>
m_formula_connection,
m_update_slave_Xref_connection; m_update_slave_Xref_connection;
QColor m_user_color{QColor()}; QColor m_user_color{QColor()};
bool m_frame = false, bool
m_frame = false,
m_first_scene_change = true; m_first_scene_change = true;
CrossRefItem *m_Xref_item = nullptr; CrossRefItem *m_Xref_item = nullptr;
QGraphicsTextItem *m_slave_Xref_item = nullptr; QGraphicsTextItem *m_slave_Xref_item = nullptr;
+39 -44
View File
@@ -73,15 +73,16 @@ class ElementXmlRetroCompatibility
/** /**
@brief Element::Element @brief Element::Element
New element from xml @param location : location of this element
@param location, location of this element @param parent : parent graphics item
@param parent, parent graphics item @param state : state of the instanciation
@param state, state of the instanciation @param link_type
*/ */
Element::Element( Element::Element(
const ElementsLocation &location, const ElementsLocation &location,
QGraphicsItem *parent, QGraphicsItem *parent,
int *state, kind link_type) : int *state,
kind link_type) :
QetGraphicsItem(parent), QetGraphicsItem(parent),
m_link_type (link_type), m_link_type (link_type),
m_location (location) m_location (location)
@@ -420,9 +421,9 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
if (conv_ok && QET::version.toDouble() < element_version) if (conv_ok && QET::version.toDouble() < element_version)
{ {
std::cerr << qPrintable( std::cerr << qPrintable(
QObject::tr("Avertissement : l'élément " QObject::tr("Avertissement : l'??l??ment "
" a été enregistré avec une version" " a ??t?? enregistr?? avec une version"
" ultérieure de QElectroTech.") " ult??rieure de QElectroTech.")
) << std::endl; ) << std::endl;
} }
} }
@@ -476,8 +477,7 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
if (elmts.tagName() == "description") if (elmts.tagName() == "description")
{ {
//Minor workaround to find if there is a "input" tagg as label. //Minor workaround to find if there is a "input" tagg as label.
//If not, we set the tagg "label" to the first "input. Why one must have a tagg label? //If not, we set the tagg "label" to the first "input.
// is label a required field?
QList <QDomElement> input_field; QList <QDomElement> input_field;
bool have_label = false; bool have_label = false;
for (QDomElement input_node = node.firstChildElement("input") ; for (QDomElement input_node = node.firstChildElement("input") ;
@@ -647,12 +647,6 @@ DynamicElementTextItem *Element::parseDynamicText(
*/ */
Terminal *Element::parseTerminal(const QDomElement &dom_element) Terminal *Element::parseTerminal(const QDomElement &dom_element)
{ {
TerminalData* data = new TerminalData();
if (!data->fromXml(dom_element)) {
delete data;
return nullptr;
}
if (!Terminal::valideXml(dom_element)) if (!Terminal::valideXml(dom_element))
return nullptr; return nullptr;
@@ -671,7 +665,8 @@ Terminal *Element::parseTerminal(const QDomElement &dom_element)
else else
return (a->dockConductor().y() < b->dockConductor().y()); return (a->dockConductor().y() < b->dockConductor().y());
}); });
return(new_terminal); // TODO: makes not sense
return(new_terminal); // TODO: makes no sense
} }
/** /**
@@ -713,8 +708,7 @@ bool Element::valideXml(QDomElement &e) {
*/ */
bool Element::fromXml( bool Element::fromXml(
QDomElement &e, QDomElement &e,
QHash<int, QHash<int, Terminal *> &table_id_adr)
Terminal *> &table_id_adr)
{ {
m_state = QET::GILoadingFromXml; m_state = QET::GILoadingFromXml;
/* /*
@@ -722,7 +716,8 @@ bool Element::fromXml(
ce recensement servira lors de la mise en place des fils ce recensement servira lors de la mise en place des fils
*/ */
QList<QDomElement> liste_terminals; // terminals in the element in the diagram QList<QDomElement> liste_terminals; // terminals in the element in the diagram
foreach(QDomElement qde, QET::findInDomElement(e, "terminals", "terminal")) { foreach(QDomElement qde,
QET::findInDomElement(e, "terminals", "terminal")) {
if (Terminal::valideXml(qde)) liste_terminals << qde; if (Terminal::valideXml(qde)) liste_terminals << qde;
} }
@@ -733,8 +728,7 @@ bool Element::fromXml(
for(QGraphicsItem *qgi: childItems()) { // TODO: Where the Terminals are added as childs? for(QGraphicsItem *qgi: childItems()) { // TODO: Where the Terminals are added as childs?
if (Terminal *p = qgraphicsitem_cast<Terminal *>(qgi)) { if (Terminal *p = qgraphicsitem_cast<Terminal *>(qgi)) {
bool terminal_trouvee = false; bool terminal_trouvee = false;
for(QDomElement qde: liste_terminals) for(QDomElement qde: liste_terminals) {
{
// The position in the collection element definition is the origin position (originPos). // The position in the collection element definition is the origin position (originPos).
// The position in the diagram element definition is the position where the conductor is connected (dock position) // The position in the diagram element definition is the position where the conductor is connected (dock position)
// Therefore a simple operator overloading is not possible. // Therefore a simple operator overloading is not possible.
@@ -788,9 +782,9 @@ bool Element::fromXml(
} }
//load uuid of connected elements //load uuid of connected elements
QList <QDomElement> uuid_list = QET::findInDomElement(e, QList <QDomElement> uuid_list = QET::findInDomElement(e, "links_uuids", "link_uuid");
"links_uuids", foreach (QDomElement qdo, uuid_list) tmp_uuids_link << qdo.attribute("uuid");
"link_uuid");
foreach (QDomElement qdo, uuid_list) foreach (QDomElement qdo, uuid_list)
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
tmp_uuids_link << qdo.attribute("uuid"); tmp_uuids_link << qdo.attribute("uuid");
@@ -809,8 +803,6 @@ bool Element::fromXml(
QString fl = e.attribute("freezeLabel", "false"); QString fl = e.attribute("freezeLabel", "false");
m_freeze_label = fl == "false"? false : true; m_freeze_label = fl == "false"? false : true;
// TODO: why element information is not read?
//Load Sequential Values //Load Sequential Values
if (e.hasAttribute("sequ_1") if (e.hasAttribute("sequ_1")
|| e.hasAttribute("sequf_1") || e.hasAttribute("sequf_1")
@@ -846,10 +838,11 @@ bool Element::fromXml(
//************************// //************************//
//***Dynamic texts item***// //***Dynamic texts item***//
//************************// //************************// read from the diagram section
// read from the diagram section for (const QDomElement& qde : QET::findInDomElement(
// this is not done in the older versions, because there only inputs are available. e,
for (const QDomElement& qde : QET::findInDomElement(e, "dynamic_texts", DynamicElementTextItem::xmlTagName())) "dynamic_texts",
DynamicElementTextItem::xmlTagName()))
{ {
DynamicElementTextItem *deti = new DynamicElementTextItem(this); DynamicElementTextItem *deti = new DynamicElementTextItem(this);
addDynamicTextItem(deti); addDynamicTextItem(deti);
@@ -859,27 +852,27 @@ bool Element::fromXml(
//************************// //************************//
//***Element texts item***// //***Element texts item***//
//************************// //************************//
QList<QDomElement> inputs = QET::findInDomElement(e, "inputs", "input"); // inputs in diagram section QList<QDomElement> inputs = QET::findInDomElement(e, "inputs", "input"); // inputs in diagram section
//First case, we check for the text item converted to dynamic text item //First case, we check for the text item converted to dynamic text item
const QList <DynamicElementTextItem *> conv_deti_list = const QList <DynamicElementTextItem *> conv_deti_list =
m_converted_text_from_xml_description.keys(); m_converted_text_from_xml_description.keys();
QList <DynamicElementTextItem *> successfully_converted; QList <DynamicElementTextItem *> successfully_converted;
const QList <QDomElement> dom_inputs = inputs; const QList <QDomElement> dom_inputs = inputs;
// TODO: Legacy (0.7 and prior) for (DynamicElementTextItem *deti : conv_deti_list)
for (DynamicElementTextItem *deti : conv_deti_list) // elements read from the element collection definition
{ {
for(const QDomElement& dom_input : dom_inputs) // elements in the diagram section for(const QDomElement& dom_input : dom_inputs)
{ {
//we use the same method used in ElementTextItem::fromXml
//we use the same method used in ElementTextItem::fromXml to compar and know if the input dom element is for one of the text stored. //to compar and know if the input dom element is for one of the text stored.
//The comparaison is made from the text position : if the position of the text is the same as the position stored in 'input' dom element //The comparaison is made from the text position :
//if the position of the text is the same as the position stored in 'input' dom element
//that mean this is the good text //that mean this is the good text
// This is only used when in the diagram description the text elements are stored in the "inputs" section. In 0.8 and higher, if (qFuzzyCompare(qreal(dom_input.attribute("x").toDouble()),
// texts are stored in directly in the "dynamic_elmt_text" section m_converted_text_from_xml_description.value(deti).x()) &&
if (qFuzzyCompare(qreal(dom_input.attribute("x").toDouble()), m_converted_text_from_xml_description.value(deti).x()) && qFuzzyCompare(qreal(dom_input.attribute("y").toDouble()),
qFuzzyCompare(qreal(dom_input.attribute("y").toDouble()), m_converted_text_from_xml_description.value(deti).y())) m_converted_text_from_xml_description.value(deti).y()))
{ {
//Once again this 'if', is only for retrocompatibility with old old old project //Once again this 'if', is only for retrocompatibility with old old old project
//when element text with tagg "label" is not null, but the element information "label" is. //when element text with tagg "label" is not null, but the element information "label" is.
@@ -1083,6 +1076,7 @@ bool Element::fromXml(
} }
QPointF pos = deti->pos(); QPointF pos = deti->pos();
// TODO: check
if (m_link_type !=PreviousReport if (m_link_type !=PreviousReport
|| m_link_type !=NextReport) || m_link_type !=NextReport)
{ {
@@ -1186,8 +1180,8 @@ bool Element::fromXml(
\~ @return The XML element representing this electrical element \~ @return The XML element representing this electrical element
\~French L'element XML representant cet element electrique \~French L'element XML representant cet element electrique
*/ */
QDomElement Element::toXml(
QDomElement Element::toXml(QDomDocument &document) const QDomDocument &document) const
{ {
QDomElement element = document.createElement("element"); QDomElement element = document.createElement("element");
@@ -1214,6 +1208,7 @@ QDomElement Element::toXml(QDomDocument &document) const
element.setAttribute("z", QString::number(this->zValue())); element.setAttribute("z", QString::number(this->zValue()));
element.setAttribute("orientation", QString::number(orientation())); element.setAttribute("orientation", QString::number(orientation()));
// registration of device terminals
// enregistrement des bornes de l'appareil // enregistrement des bornes de l'appareil
QDomElement xml_terminals = document.createElement("terminals"); QDomElement xml_terminals = document.createElement("terminals");
// for each child of the element // for each child of the element
+8 -5
View File
@@ -46,9 +46,11 @@ class Element : public QetGraphicsItem // TODO: derive from propertiesInterface!
public: public:
/** /**
@brief The kind enum @brief The kind enum
Used to know the kind of this element (master, slave, report ect...) Used to know the kind of this element
(master, slave, report ect...)
*/ */
enum kind {Simple = 1, enum kind {
Simple = 1,
NextReport = 2, NextReport = 2,
PreviousReport = 4, PreviousReport = 4,
AllReport = 6, AllReport = 6,
@@ -56,9 +58,9 @@ class Element : public QetGraphicsItem // TODO: derive from propertiesInterface!
Slave = 16, Slave = 16,
Terminale = 32}; Terminale = 32};
Element( Element(const ElementsLocation &location,
const ElementsLocation &location, QGraphicsItem * = nullptr,
QGraphicsItem * parent= nullptr, int *state = nullptr, int *state = nullptr,
Element::kind link_type = Element::Simple); Element::kind link_type = Element::Simple);
~Element() override; ~Element() override;
private: private:
@@ -132,6 +134,7 @@ class Element : public QetGraphicsItem // TODO: derive from propertiesInterface!
virtual QDomElement toXml(QDomDocument &) const; virtual QDomElement toXml(QDomDocument &) const;
QUuid uuid() const; QUuid uuid() const;
int orientation() const; int orientation() const;
//METHODS related to texts //METHODS related to texts
void addDynamicTextItem(DynamicElementTextItem *deti = nullptr); void addDynamicTextItem(DynamicElementTextItem *deti = nullptr);
void removeDynamicTextItem(DynamicElementTextItem *deti); void removeDynamicTextItem(DynamicElementTextItem *deti);
@@ -108,8 +108,7 @@ class ElementTextItemGroup : public QObject, public QGraphicsItemGroup // TODO:
private: private:
Qt::Alignment m_alignment = Qt::AlignJustify; Qt::Alignment m_alignment = Qt::AlignJustify;
QString m_name; QString m_name;
bool bool m_first_move = true,
m_first_move = true,
m_hold_to_bottom_of_page = false, m_hold_to_bottom_of_page = false,
m_block_alignment_update = false, m_block_alignment_update = false,
m_frame = false; m_frame = false;
+5 -5
View File
@@ -662,7 +662,7 @@ void QetShapeItem::insertPoint()
if(new_polygon != m_polygon) if(new_polygon != m_polygon)
{ {
//Wrap the undo for avoid to merge the undo commands when user add several points. //Wrap the undo for avoid to merge the undo commands when user add several points.
QUndoCommand *undo = new QUndoCommand(tr("Ajouter un point à un polygone")); QUndoCommand *undo = new QUndoCommand(tr("Ajouter un point ?? un polygone"));
new QPropertyUndoCommand(this, "polygon", m_polygon, new_polygon, undo); new QPropertyUndoCommand(this, "polygon", m_polygon, new_polygon, undo);
diagram()->undoStack().push(undo); diagram()->undoStack().push(undo);
} }
@@ -853,9 +853,9 @@ bool QetShapeItem::fromXml(const QDomElement &e)
QString type = e.attribute("type"); QString type = e.attribute("type");
#if TODO_LIST #if TODO_LIST
#pragma message("@TODO Compatibility for version older than N°4075, shape type was stored with an int") #pragma message("@TODO Compatibility for version older than N??4075, shape type was stored with an int")
#endif #endif
//@TODO Compatibility for version older than N°4075, shape type was stored with an int //@TODO Compatibility for version older than N??4075, shape type was stored with an int
if (type.size() == 1) if (type.size() == 1)
{ {
switch(e.attribute("type","0").toInt()) switch(e.attribute("type","0").toInt())
@@ -866,7 +866,7 @@ bool QetShapeItem::fromXml(const QDomElement &e)
case 3: m_shapeType = Polygon; break; case 3: m_shapeType = Polygon; break;
} }
} }
//For version after N°4075, shape is stored with a string //For version after N??4075, shape is stored with a string
else else
{ {
QMetaEnum me = metaObject()->enumerator(metaObject()->indexOfEnumerator("ShapeType")); QMetaEnum me = metaObject()->enumerator(metaObject()->indexOfEnumerator("ShapeType"));
@@ -1015,7 +1015,7 @@ QString QetShapeItem::name() const
switch (m_shapeType) { switch (m_shapeType) {
case Line: return tr("une ligne"); case Line: return tr("une ligne");
case Rectangle: return tr("un rectangle"); case Rectangle: return tr("un rectangle");
case Ellipse: return tr("une éllipse"); case Ellipse: return tr("une ??llipse");
case Polygon: return tr("une polyligne"); case Polygon: return tr("une polyligne");
default: return tr("une shape"); default: return tr("une shape");
} }
+5 -4
View File
@@ -26,13 +26,14 @@
Default constructor Default constructor
@param location location of xml definition @param location location of xml definition
@param qgi parent QGraphicItem @param qgi parent QGraphicItem
@param s parent diagram
@param state int used to know if the creation of element have error @param state int used to know if the creation of element have error
*/ */
SlaveElement::SlaveElement( SlaveElement::SlaveElement(const ElementsLocation &location,
const ElementsLocation &location, QGraphicsItem *parent, int *state) : QGraphicsItem *qgi,
Element(location, parent, state, Element::Slave) int *state) :
Element(location, qgi, state, Element::Slave)
{ {
m_xref_item = nullptr;
} }
/** /**
+1 -1
View File
@@ -27,7 +27,7 @@ class SlaveElement : public Element
public: public:
explicit SlaveElement ( explicit SlaveElement (
const ElementsLocation &, const ElementsLocation &,
QGraphicsItem * parent= nullptr, QGraphicsItem * = nullptr,
int * = nullptr); int * = nullptr);
~SlaveElement() override; ~SlaveElement() override;
void linkToElement(Element *elmt) override; void linkToElement(Element *elmt) override;
+6 -4
View File
@@ -40,7 +40,8 @@ const qreal Terminal::Z = 1000;
@param name of terminal @param name of terminal
@param hiddenName @param hiddenName
*/ */
void Terminal::init(QString number, QString name, bool hiddenName) void Terminal::init(
QString number, QString name, bool hiddenName)
{ {
// calcul de la position du point d'amarrage a l'element // calcul de la position du point d'amarrage a l'element
dock_elmt_ = d->m_pos; dock_elmt_ = d->m_pos;
@@ -798,7 +799,8 @@ QDomElement Terminal::toXml(QDomDocument &doc) const
@param terminal Le QDomElement a analyser @param terminal Le QDomElement a analyser
@return true si le QDomElement passe en parametre est une borne, false sinon @return true si le QDomElement passe en parametre est une borne, false sinon
*/ */
bool Terminal::valideXml(const QDomElement &terminal) { bool Terminal::valideXml(const QDomElement &terminal)
{
if (terminal.tagName() != "terminal") return(false); if (terminal.tagName() != "terminal") return(false);
// affuteuse_250h.qet contains in line 8398 terminals which do not have this // affuteuse_250h.qet contains in line 8398 terminals which do not have this
@@ -823,8 +825,7 @@ bool Terminal::valideXml(const QDomElement &terminal) {
@return true si la borne "se reconnait" @return true si la borne "se reconnait"
(memes coordonnes, meme orientation), false sinon (memes coordonnes, meme orientation), false sinon
*/ */
bool Terminal::fromXml(const QDomElement &terminal) bool Terminal::fromXml(const QDomElement &terminal) {
{
propertyString(terminal, "number", &number_terminal_); propertyString(terminal, "number", &number_terminal_);
propertyBool(terminal, "nameHidden", &name_terminal_hidden); propertyBool(terminal, "nameHidden", &name_terminal_hidden);
@@ -832,6 +833,7 @@ bool Terminal::fromXml(const QDomElement &terminal)
if(!d->fromXml(terminal)) if(!d->fromXml(terminal))
return false; return false;
init(number_terminal_, d->m_name, name_terminal_hidden); // initialize dock_elmt_. This must be done after Terminal data is initialized init(number_terminal_, d->m_name, name_terminal_hidden); // initialize dock_elmt_. This must be done after Terminal data is initialized
return true; return true;
} }
+8 -6
View File
@@ -79,7 +79,6 @@ class Terminal : public QGraphicsObject, public PropertiesInterface
Diagram *diagram () const; Diagram *diagram () const;
Element *parentElement () const; Element *parentElement () const;
QUuid uuid () const; QUuid uuid () const;
int ID() const; int ID() const;
QPointF dockPos(); QPointF dockPos();
QPointF originPos(); QPointF originPos();
@@ -94,7 +93,6 @@ class Terminal : public QGraphicsObject, public PropertiesInterface
void updateConductor(); void updateConductor();
bool isLinkedTo(Terminal *); bool isLinkedTo(Terminal *);
bool canBeLinkedTo(Terminal *); bool canBeLinkedTo(Terminal *);
void setID(int id); void setID(int id);
// methods related to XML import/export // methods related to XML import/export
@@ -102,6 +100,9 @@ class Terminal : public QGraphicsObject, public PropertiesInterface
bool fromXml (const QDomElement &) override; bool fromXml (const QDomElement &) override;
QDomElement toXml (QDomDocument &) const override; QDomElement toXml (QDomDocument &) const override;
void toSettings(QSettings &,const QString & = QString()) const override {/*TODO: implement*/}
void fromSettings(QSettings &,const QString & = QString()) override{/*TODO: implement*/}
protected: protected:
// methods related to events management // methods related to events management
void hoverEnterEvent (QGraphicsSceneHoverEvent *) override; void hoverEnterEvent (QGraphicsSceneHoverEvent *) override;
@@ -117,7 +118,7 @@ class Terminal : public QGraphicsObject, public PropertiesInterface
static const qreal terminalSize; static const qreal terminalSize;
static const qreal Z; 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 // The assignement is in the cpp file
/// default color /// default color
static QColor neutralColor; static QColor neutralColor;
@@ -134,7 +135,7 @@ class Terminal : public QGraphicsObject, public PropertiesInterface
QGraphicsLineItem *m_help_line_a{nullptr}; QGraphicsLineItem *m_help_line_a{nullptr};
TerminalData* d; TerminalData* d{nullptr};
/// Parent electrical element /// Parent electrical element
Element *parent_element_{nullptr}; Element *parent_element_{nullptr};
@@ -155,10 +156,9 @@ class Terminal : public QGraphicsObject, public PropertiesInterface
/// Whether the mouse pointer is hovering the terminal /// Whether the mouse pointer is hovering the terminal
bool hovered_{false}; bool hovered_{false};
/// Color used for the hover effect /// Color used for the hover effect
QColor hovered_color_{Terminal::hovered_color_}; QColor hovered_color_{Terminal::neutralColor};
/// Number of Terminal /// Number of Terminal
QString number_terminal_; QString number_terminal_;
bool name_terminal_hidden{true}; bool name_terminal_hidden{true};
/// legacy id used by the conductor to find the terminal. From 0.8x on the uuid is used instead. /// legacy id used by the conductor to find the terminal. From 0.8x on the uuid is used instead.
@@ -187,6 +187,8 @@ inline QString Terminal::number() const
{ {
return(number_terminal_); return(number_terminal_);
} }
QList<Terminal *> relatedPotentialTerminal (const Terminal *terminal, QList<Terminal *> relatedPotentialTerminal (const Terminal *terminal,
const bool all_diagram = true); const bool all_diagram = true);
+6 -1
View File
@@ -23,7 +23,12 @@
*/ */
HelperCell::HelperCell(QGraphicsItem *parent) : HelperCell::HelperCell(QGraphicsItem *parent) :
QGraphicsObject(parent), QGraphicsObject(parent),
QGraphicsLayoutItem() QGraphicsLayoutItem(),
background_color(Qt::white),
foreground_color(Qt::black),
label(),
orientation(Qt::Horizontal),
index(-1)
{ {
setGraphicsItem(this); setGraphicsItem(this);
setFlag(QGraphicsItem::ItemIsSelectable, false); setFlag(QGraphicsItem::ItemIsSelectable, false);
+7 -6
View File
@@ -65,12 +65,13 @@ bool TitleBlockProperties::operator!=(const TitleBlockProperties &ip) {
return(!(*this == ip)); return(!(*this == ip));
} }
/**
@brief TitleBlockProperties::toXml
@param e
*/
void TitleBlockProperties::toXml(QDomElement &e) const {
/**
Exporte le cartouche sous formes d'attributs XML ajoutes a l'element e.
@param e Element XML auquel seront ajoutes des attributs
*/
void TitleBlockProperties::toXml(QDomElement &e) const
{
e.setAttribute("author", author); e.setAttribute("author", author);
e.setAttribute("title", title); e.setAttribute("title", title);
e.setAttribute("filename", filename); e.setAttribute("filename", filename);
@@ -170,7 +171,7 @@ void TitleBlockProperties::toSettings(QSettings &settings, const QString &prefix
@param settings Parametres a lire @param settings Parametres a lire
@param prefix prefixe a ajouter devant les noms des parametres @param prefix prefixe a ajouter devant les noms des parametres
*/ */
void TitleBlockProperties::fromSettings(const QSettings &settings, const QString &prefix) { void TitleBlockProperties::fromSettings(QSettings &settings, const QString &prefix) {
title = settings.value(prefix + "title").toString(); title = settings.value(prefix + "title").toString();
author = settings.value(prefix + "author").toString(); author = settings.value(prefix + "author").toString();
filename = settings.value(prefix + "filename").toString(); filename = settings.value(prefix + "filename").toString();
+1 -1
View File
@@ -45,7 +45,7 @@ class TitleBlockProperties: public PropertiesInterface {
void toXml(QDomElement &e) const; void toXml(QDomElement &e) const;
bool fromXml(const QDomElement &) override; bool fromXml(const QDomElement &) override;
void toSettings(QSettings &, const QString & = QString()) const override; void toSettings(QSettings &, const QString & = QString()) const override;
void fromSettings(const QSettings &, const QString & = QString()) override; void fromSettings(QSettings &, const QString & = QString()) override;
void setAutoPageNum(QString autonum) {auto_page_num = autonum;} void setAutoPageNum(QString autonum) {auto_page_num = autonum;}
+4 -4
View File
@@ -84,8 +84,8 @@ void ConductorPropertiesWidget::setProperties(
ui->m_formula_le -> setText (m_properties.m_formula); ui->m_formula_le -> setText (m_properties.m_formula);
ui->m_text_le -> setText (m_properties.text); ui->m_text_le -> setText (m_properties.text);
ui->m_function_le -> setText (m_properties.m_function); ui->m_function_le -> setText (m_properties.m_function);
// ui->m_cable_le -> setText (m_properties.m_cable); ui->m_cable_le -> setText (m_properties.m_cable);
// ui->m_bus_le -> setText (m_properties.m_bus); ui->m_bus_le -> setText (m_properties.m_bus);
ui->m_tension_protocol_le -> setText (m_properties.m_tension_protocol); ui->m_tension_protocol_le -> setText (m_properties.m_tension_protocol);
ui->m_wire_color_le -> setText (m_properties.m_wire_color); ui->m_wire_color_le -> setText (m_properties.m_wire_color);
ui->m_wire_section_le -> setText (m_properties.m_wire_section); ui->m_wire_section_le -> setText (m_properties.m_wire_section);
@@ -130,8 +130,8 @@ ConductorProperties ConductorPropertiesWidget::properties() const
properties_.text = ui -> m_text_le -> text(); properties_.text = ui -> m_text_le -> text();
properties_.text_color = ui -> m_text_color_kpb->color(); properties_.text_color = ui -> m_text_color_kpb->color();
properties_.m_function = ui -> m_function_le->text(); properties_.m_function = ui -> m_function_le->text();
// properties_.m_cable = ui -> m_cable_le->text(); properties_.m_cable = ui -> m_cable_le->text();
// properties_.m_bus = ui -> m_bus_le->text(); properties_.m_bus = ui -> m_bus_le->text();
properties_.m_tension_protocol = ui -> m_tension_protocol_le->text(); properties_.m_tension_protocol = ui -> m_tension_protocol_le->text();
properties_.m_wire_color = ui -> m_wire_color_le->text(); properties_.m_wire_color = ui -> m_wire_color_le->text();
properties_.m_wire_section = ui -> m_wire_section_le->text(); properties_.m_wire_section = ui -> m_wire_section_le->text();
-6
View File
@@ -1269,8 +1269,6 @@ void DynamicElementTextModel::enableGroupRotationAndPos(
void DynamicElementTextModel::itemDataChanged(QStandardItem *qsi) void DynamicElementTextModel::itemDataChanged(QStandardItem *qsi)
{ {
DynamicElementTextItem *deti = textFromItem(qsi); DynamicElementTextItem *deti = textFromItem(qsi);
if (deti->searchedElement)
int stop = 1;
ElementTextItemGroup *etig = groupFromItem(qsi); ElementTextItemGroup *etig = groupFromItem(qsi);
if (!deti && !etig) if (!deti && !etig)
return; return;
@@ -1416,10 +1414,6 @@ void DynamicElementTextModel::setConnection(ElementTextItemGroup *group, bool se
void DynamicElementTextModel::updateDataFromText(DynamicElementTextItem *deti, void DynamicElementTextModel::updateDataFromText(DynamicElementTextItem *deti,
ValueType type) ValueType type)
{ {
if (deti->searchedElement)
int stop = 1;
QStandardItem *qsi = m_texts_list.value(deti); QStandardItem *qsi = m_texts_list.value(deti);
if (!qsi) if (!qsi)
return; return;