Element : start use ElementData

Element now use ElementData for namelist and element information
This commit is contained in:
joshua
2021-02-16 23:31:54 +01:00
parent be2067148e
commit ce318ac667
2 changed files with 32 additions and 32 deletions

View File

@@ -464,8 +464,8 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
m_state = QET::GIOK; m_state = QET::GIOK;
return(false); return(false);
} }
//Extract the names
m_names.fromXml(xml_def_elmt); m_data.fromXml(xml_def_elmt);
setToolTip(name()); setToolTip(name());
//load kind informations //load kind informations
@@ -473,7 +473,7 @@ bool Element::buildFromXml(const QDomElement &xml_def_elmt, int *state)
xml_def_elmt.firstChildElement("kindInformations"), xml_def_elmt.firstChildElement("kindInformations"),
"kindInformation"); "kindInformation");
//load element information //load element information
m_element_informations.fromXml( m_data.m_informations.fromXml(
xml_def_elmt.firstChildElement("elementInformations"), xml_def_elmt.firstChildElement("elementInformations"),
"elementInformation"); "elementInformation");
@@ -877,7 +877,7 @@ bool Element::fromXml(
//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.
if((deti->textFrom() == DynamicElementTextItem::ElementInfo) if((deti->textFrom() == DynamicElementTextItem::ElementInfo)
&& (deti->infoName() == "label")) && (deti->infoName() == "label"))
m_element_informations.addValue( m_data.m_informations.addValue(
"label", "label",
dom_input.attribute("text")); dom_input.attribute("text"));
@@ -974,8 +974,8 @@ bool Element::fromXml(
} }
//retrocompatibility with older version //retrocompatibility with older version
if(dc.value("label").toString().isEmpty() && if(dc.value("label").toString().isEmpty() &&
!m_element_informations.value("label").toString().isEmpty()) !m_data.m_informations.value("label").toString().isEmpty())
dc.addValue("label", m_element_informations.value("label")); dc.addValue("label", m_data.m_informations.value("label"));
//We must to block the update of the alignment when load the information //We must to block the update of the alignment when load the information
//otherwise the pos of the text will not be the same as it was at save time. //otherwise the pos of the text will not be the same as it was at save time.
@@ -1001,15 +1001,15 @@ bool Element::fromXml(
{ {
//#2 the element information must have label not empty and visible //#2 the element information must have label not empty and visible
//and a least comment or location not empty and visible //and a least comment or location not empty and visible
QString label = m_element_informations.value( QString label = m_data.m_informations.value(
"label").toString(); "label").toString();
QString comment = m_element_informations.value( QString comment = m_data.m_informations.value(
"comment").toString(); "comment").toString();
QString location = m_element_informations.value( QString location = m_data.m_informations.value(
"location").toString(); "location").toString();
bool la = m_element_informations.keyMustShow("label"); bool la = m_data.m_informations.keyMustShow("label");
bool c = m_element_informations.keyMustShow("comment"); bool c = m_data.m_informations.keyMustShow("comment");
bool lo = m_element_informations.keyMustShow("location"); bool lo = m_data.m_informations.keyMustShow("location");
if((m_link_type != Master) || if((m_link_type != Master) ||
((m_link_type == Master) && ((m_link_type == Master) &&
@@ -1254,10 +1254,10 @@ QDomElement Element::toXml(
} }
//save information of this element //save information of this element
if (! m_element_informations.keys().isEmpty()) { if (! m_data.m_informations.keys().isEmpty()) {
QDomElement infos = QDomElement infos =
document.createElement("elementInformations"); document.createElement("elementInformations");
m_element_informations.toXml(infos, "elementInformation"); m_data.m_informations.toXml(infos, "elementInformation");
element.appendChild(infos); element.appendChild(infos);
} }
@@ -1601,14 +1601,14 @@ QString Element::linkTypeToString() const
*/ */
void Element::setElementInformations(DiagramContext dc) void Element::setElementInformations(DiagramContext dc)
{ {
if (m_element_informations == dc) { if (m_data.m_informations == dc) {
return; return;
} }
DiagramContext old_info = m_element_informations; DiagramContext old_info = m_data.m_informations;
m_element_informations = dc; m_data.m_informations = dc;
m_element_informations.addValue("label", actualLabel()); //Update the label if there is a formula m_data.m_informations.addValue("label", actualLabel()); //Update the label if there is a formula
emit elementInfoChange(old_info, m_element_informations); emit elementInfoChange(old_info, m_data.m_informations);
} }
/** /**
@@ -1722,7 +1722,7 @@ void Element::setUpFormula(bool code_letter)
->project() ->project()
->elementAutoNumCurrentFormula(); ->elementAutoNumCurrentFormula();
m_element_informations.addValue("formula", formula); m_data.m_informations.addValue("formula", formula);
QString element_currentAutoNum = diagram() QString element_currentAutoNum = diagram()
->project() ->project()
@@ -1743,9 +1743,9 @@ void Element::setUpFormula(bool code_letter)
if(!m_freeze_label && !formula.isEmpty()) if(!m_freeze_label && !formula.isEmpty())
{ {
DiagramContext dc = m_element_informations; DiagramContext dc = m_data.m_informations;
m_element_informations.addValue("label", actualLabel()); m_data.m_informations.addValue("label", actualLabel());
emit elementInfoChange(dc, m_element_informations); emit elementInfoChange(dc, m_data.m_informations);
} }
} }
} }
@@ -1798,11 +1798,11 @@ void Element::freezeNewAddedElement()
*/ */
QString Element::actualLabel() QString Element::actualLabel()
{ {
if (m_element_informations.value("formula").toString().isEmpty()) { if (m_data.m_informations.value("formula").toString().isEmpty()) {
return m_element_informations.value("label").toString(); return m_data.m_informations.value("label").toString();
} else { } else {
return autonum::AssignVariables::formulaToLabel( return autonum::AssignVariables::formulaToLabel(
m_element_informations.value( m_data.m_informations.value(
"formula").toString(), "formula").toString(),
m_autoNum_seq, m_autoNum_seq,
diagram(), diagram(),
@@ -1814,9 +1814,8 @@ QString Element::actualLabel()
@brief Element::name @brief Element::name
@return the human name of this element @return the human name of this element
*/ */
QString Element::name() const QString Element::name() const {
{ return m_data.m_names_list.name(m_location.baseName());
return m_names.name(m_location.baseName());
} }
ElementsLocation Element::location() const ElementsLocation Element::location() const

View File

@@ -24,6 +24,7 @@
#include "../diagramcontext.h" #include "../diagramcontext.h"
#include "../qet.h" #include "../qet.h"
#include "qetgraphicsitem.h" #include "qetgraphicsitem.h"
#include "../properties/elementdata.h"
#include <QHash> #include <QHash>
#include <QPicture> #include <QPicture>
@@ -100,7 +101,7 @@ class Element : public QetGraphicsItem
//METHODS related to information //METHODS related to information
DiagramContext elementInformations()const DiagramContext elementInformations()const
{return m_element_informations;} {return m_data.m_informations;}
virtual void setElementInformations(DiagramContext dc); virtual void setElementInformations(DiagramContext dc);
DiagramContext kindInformations() const DiagramContext kindInformations() const
{return m_kind_informations;} {return m_kind_informations;}
@@ -220,16 +221,16 @@ class Element : public QetGraphicsItem
kind m_link_type = Element::Simple; kind m_link_type = Element::Simple;
//ATTRIBUTES related to informations //ATTRIBUTES related to informations
DiagramContext m_element_informations, m_kind_informations; DiagramContext m_kind_informations;
autonum::sequentialNumbers m_autoNum_seq; autonum::sequentialNumbers m_autoNum_seq;
bool m_freeze_label = false; bool m_freeze_label = false;
QString m_F_str; QString m_F_str;
ElementsLocation m_location; ElementsLocation m_location;
NamesList m_names;
QList <Terminal *> m_terminals; QList <Terminal *> m_terminals;
const QPicture m_picture; const QPicture m_picture;
const QPicture m_low_zoom_picture; const QPicture m_low_zoom_picture;
ElementData m_data;
private: private:
bool m_must_highlight = false; bool m_must_highlight = false;