mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Revamp struct sequenceStruct to class sequentialNumbers.
Element now use methods (toXml and fromXml) of sequentialNumbers to store and load sequential. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4803 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -20,12 +20,114 @@
|
|||||||
#include "element.h"
|
#include "element.h"
|
||||||
#include "diagramposition.h"
|
#include "diagramposition.h"
|
||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
|
#include "qetxml.h"
|
||||||
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
namespace autonum
|
namespace autonum
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief sequentialNumbers::sequentialNumbers
|
||||||
|
*/
|
||||||
|
sequentialNumbers::sequentialNumbers()
|
||||||
|
{}
|
||||||
|
|
||||||
|
sequentialNumbers &sequentialNumbers::operator=(const sequentialNumbers &other)
|
||||||
|
{
|
||||||
|
if (&other == this || other == *this)
|
||||||
|
return (*this);
|
||||||
|
|
||||||
|
unit = other.unit;
|
||||||
|
unit_folio = other.unit_folio;
|
||||||
|
ten = other.ten;
|
||||||
|
ten_folio = other.ten_folio;
|
||||||
|
hundred = other.hundred;
|
||||||
|
hundred_folio = other.hundred_folio;
|
||||||
|
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool sequentialNumbers::operator==(const sequentialNumbers &other) const
|
||||||
|
{
|
||||||
|
if (unit == other.unit && \
|
||||||
|
unit_folio == other.unit_folio && \
|
||||||
|
ten == other.ten && \
|
||||||
|
ten_folio == other.ten_folio && \
|
||||||
|
hundred == other.hundred && \
|
||||||
|
hundred_folio == other.hundred_folio)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool sequentialNumbers::operator!=(const sequentialNumbers &other) const
|
||||||
|
{
|
||||||
|
if (*this == other)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief sequentialNumbers::toXml
|
||||||
|
* export this sequential numbers into a QDomElement.
|
||||||
|
* @param document : QDomDocument used to create the QDomElement
|
||||||
|
* @param tag_name : the tag name used for the QDomElement.
|
||||||
|
* @return A QDomElement, if this sequential have no value, the returned QDomELement is empty
|
||||||
|
*/
|
||||||
|
QDomElement sequentialNumbers::toXml(QDomDocument &document, QString tag_name) const
|
||||||
|
{
|
||||||
|
QDomElement element = document.createElement(tag_name);
|
||||||
|
|
||||||
|
if (!unit.isEmpty())
|
||||||
|
element.appendChild(QETXML::textToDomElement(document, "unit", unit.join(";")));
|
||||||
|
if (!unit_folio.isEmpty())
|
||||||
|
element.appendChild(QETXML::textToDomElement(document, "unitFolio", unit_folio.join(";")));
|
||||||
|
if(!ten.isEmpty())
|
||||||
|
element.appendChild(QETXML::textToDomElement(document, "ten", ten.join(";")));
|
||||||
|
if(!ten_folio.isEmpty())
|
||||||
|
element.appendChild(QETXML::textToDomElement(document, "tenFolio", ten_folio.join(";")));
|
||||||
|
if(!hundred.isEmpty())
|
||||||
|
element.appendChild(QETXML::textToDomElement(document, "hundred", hundred.join(";")));
|
||||||
|
if(!hundred_folio.isEmpty())
|
||||||
|
element.appendChild(QETXML::textToDomElement(document, "hundredFolio", hundred_folio.join(";")));
|
||||||
|
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief sequentialNumbers::fromXml
|
||||||
|
* Import sequential values from a QDomElement
|
||||||
|
* @param element
|
||||||
|
*/
|
||||||
|
void sequentialNumbers::fromXml(const QDomElement &element)
|
||||||
|
{
|
||||||
|
if (!element.hasChildNodes())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QDomElement from;
|
||||||
|
|
||||||
|
from = element.firstChildElement("unit");
|
||||||
|
unit = from.text().split(";");
|
||||||
|
|
||||||
|
from = element.firstChildElement("unitFolio");
|
||||||
|
unit_folio = from.text().split(";");
|
||||||
|
|
||||||
|
from = element.firstChildElement("ten");
|
||||||
|
ten = from.text().split(";");
|
||||||
|
|
||||||
|
from = element.firstChildElement("tenFolio");
|
||||||
|
ten_folio = from.text().split(";");
|
||||||
|
|
||||||
|
from = element.firstChildElement("hundred");
|
||||||
|
hundred = from.text().split(";");
|
||||||
|
|
||||||
|
from = element.firstChildElement("hundredFolio");
|
||||||
|
hundred_folio = from.text().split(";");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief AssignVariables::formulaToLabel
|
* @brief AssignVariables::formulaToLabel
|
||||||
* Return the @formula with variable assigned (ready to be displayed)
|
* Return the @formula with variable assigned (ready to be displayed)
|
||||||
@@ -35,14 +137,14 @@ namespace autonum
|
|||||||
* @param elmt - parent element (if any) of the formula
|
* @param elmt - parent element (if any) of the formula
|
||||||
* @return the string with variable assigned.
|
* @return the string with variable assigned.
|
||||||
*/
|
*/
|
||||||
QString AssignVariables::formulaToLabel(QString formula, sequenceStruct &seqStruct, Diagram *diagram, const Element *elmt)
|
QString AssignVariables::formulaToLabel(QString formula, sequentialNumbers &seqStruct, Diagram *diagram, const Element *elmt)
|
||||||
{
|
{
|
||||||
AssignVariables av(formula, seqStruct, diagram, elmt);
|
AssignVariables av(formula, seqStruct, diagram, elmt);
|
||||||
seqStruct = av.m_seq_struct;
|
seqStruct = av.m_seq_struct;
|
||||||
return av.m_assigned_label;
|
return av.m_assigned_label;
|
||||||
}
|
}
|
||||||
|
|
||||||
AssignVariables::AssignVariables(QString formula, sequenceStruct seqStruct , Diagram *diagram, const Element *elmt):
|
AssignVariables::AssignVariables(QString formula, sequentialNumbers seqStruct , Diagram *diagram, const Element *elmt):
|
||||||
m_diagram(diagram),
|
m_diagram(diagram),
|
||||||
m_arg_formula(formula),
|
m_arg_formula(formula),
|
||||||
m_assigned_label(formula),
|
m_assigned_label(formula),
|
||||||
@@ -203,7 +305,7 @@ namespace autonum
|
|||||||
* to keep up to date the current sequential of folio.
|
* to keep up to date the current sequential of folio.
|
||||||
* @param hashKey : the hash key used to store the sequential for folio type.
|
* @param hashKey : the hash key used to store the sequential for folio type.
|
||||||
*/
|
*/
|
||||||
void setSequential(QString label, sequenceStruct &seqStruct, NumerotationContext &context, Diagram *diagram, QString hashKey)
|
void setSequential(QString label, sequentialNumbers &seqStruct, NumerotationContext &context, Diagram *diagram, QString hashKey)
|
||||||
{
|
{
|
||||||
if (!context.isEmpty())
|
if (!context.isEmpty())
|
||||||
{
|
{
|
||||||
@@ -394,5 +496,4 @@ namespace autonum
|
|||||||
|
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,18 @@ class ElementsLocation;
|
|||||||
|
|
||||||
namespace autonum
|
namespace autonum
|
||||||
{
|
{
|
||||||
struct sequenceStruct {
|
class sequentialNumbers
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
sequentialNumbers();
|
||||||
|
|
||||||
|
sequentialNumbers &operator= (const sequentialNumbers &other);
|
||||||
|
bool operator== (const sequentialNumbers &other) const;
|
||||||
|
bool operator!= (const sequentialNumbers &other) const;
|
||||||
|
|
||||||
|
QDomElement toXml(QDomDocument &document, QString tag_name = QString("sequentialNumbers")) const;
|
||||||
|
void fromXml(const QDomElement &element);
|
||||||
|
|
||||||
QStringList unit;
|
QStringList unit;
|
||||||
QStringList unit_folio;
|
QStringList unit_folio;
|
||||||
QStringList ten;
|
QStringList ten;
|
||||||
@@ -47,10 +58,10 @@ namespace autonum
|
|||||||
class AssignVariables
|
class AssignVariables
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static QString formulaToLabel (QString formula, sequenceStruct &seqStruct, Diagram *diagram, const Element *elmt = nullptr);
|
static QString formulaToLabel (QString formula, sequentialNumbers &seqStruct, Diagram *diagram, const Element *elmt = nullptr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AssignVariables(QString formula, sequenceStruct seqStruct , Diagram *diagram, const Element *elmt = nullptr);
|
AssignVariables(QString formula, sequentialNumbers seqStruct , Diagram *diagram, const Element *elmt = nullptr);
|
||||||
void assignTitleBlockVar();
|
void assignTitleBlockVar();
|
||||||
void assignProjectVar();
|
void assignProjectVar();
|
||||||
void assignSequence();
|
void assignSequence();
|
||||||
@@ -58,13 +69,13 @@ namespace autonum
|
|||||||
Diagram *m_diagram = nullptr;
|
Diagram *m_diagram = nullptr;
|
||||||
QString m_arg_formula;
|
QString m_arg_formula;
|
||||||
QString m_assigned_label;
|
QString m_assigned_label;
|
||||||
sequenceStruct m_seq_struct;
|
sequentialNumbers m_seq_struct;
|
||||||
const Element *m_element = nullptr;
|
const Element *m_element = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
void setSequentialToList(QStringList &list, NumerotationContext &nc, QString type);
|
void setSequentialToList(QStringList &list, NumerotationContext &nc, QString type);
|
||||||
void setFolioSequentialToHash(QStringList &list, QHash<QString, QStringList> &hash, QString autoNumName);
|
void setFolioSequentialToHash(QStringList &list, QHash<QString, QStringList> &hash, QString autoNumName);
|
||||||
void setSequential(QString label, autonum::sequenceStruct &seqStruct, NumerotationContext &context, Diagram *diagram, QString hashKey);
|
void setSequential(QString label, autonum::sequentialNumbers &seqStruct, NumerotationContext &context, Diagram *diagram, QString hashKey);
|
||||||
QString numerotationContextToFormula(const NumerotationContext &nc);
|
QString numerotationContextToFormula(const NumerotationContext &nc);
|
||||||
QString elementPrefixForLocation(const ElementsLocation &location);
|
QString elementPrefixForLocation(const ElementsLocation &location);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ void ConductorAutoNumerotation::numeratePotential()
|
|||||||
cp.text = text_list.first();
|
cp.text = text_list.first();
|
||||||
cp.m_formula = formula_list.first();
|
cp.m_formula = formula_list.first();
|
||||||
m_conductor->setProperties(cp);
|
m_conductor->setProperties(cp);
|
||||||
m_conductor->setOthersSequential(conductor_list.first());
|
m_conductor->rSequenceNum() = conductor_list.first()->sequenceNum();
|
||||||
m_conductor->setText(text_list.first());
|
m_conductor->setText(text_list.first());
|
||||||
}
|
}
|
||||||
//the texts isn't identicals
|
//the texts isn't identicals
|
||||||
@@ -153,10 +153,10 @@ void ConductorAutoNumerotation::numerateNewConductor()
|
|||||||
cp.m_formula = formula;
|
cp.m_formula = formula;
|
||||||
m_conductor->setProperties(cp);
|
m_conductor->setProperties(cp);
|
||||||
|
|
||||||
autonum::setSequential(formula, m_conductor->rSequenceStruct(), context, m_diagram, autoNum_name);
|
autonum::setSequential(formula, m_conductor->rSequenceNum(), context, m_diagram, autoNum_name);
|
||||||
|
|
||||||
NumerotationContextCommands ncc (context, m_diagram);
|
NumerotationContextCommands ncc (context, m_diagram);
|
||||||
m_diagram->project()->addConductorAutoNum(autoNum_name, ncc.next());
|
m_diagram->project()->addConductorAutoNum(autoNum_name, ncc.next());
|
||||||
|
|
||||||
applyText(autonum::AssignVariables::formulaToLabel(formula, m_conductor->rSequenceStruct(), m_diagram));
|
applyText(autonum::AssignVariables::formulaToLabel(formula, m_conductor->rSequenceNum(), m_diagram));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1268,22 +1268,6 @@ QString Conductor::text() const {
|
|||||||
return(label);
|
return(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Conductor::setOthersSequential
|
|
||||||
* Copy sequentials from conductor in argument to this conductor
|
|
||||||
* @param conductor to copy sequentials from
|
|
||||||
*/
|
|
||||||
void Conductor::setOthersSequential(Conductor *other) {
|
|
||||||
QString conductor_currentAutoNum = other->diagram()->project()->conductorCurrentAutoNum();
|
|
||||||
NumerotationContext nc = other->diagram()->project()->conductorAutoNum(conductor_currentAutoNum);
|
|
||||||
m_autoNum_seq.unit = other->m_autoNum_seq.unit;
|
|
||||||
m_autoNum_seq.unit_folio = other->m_autoNum_seq.unit_folio;
|
|
||||||
m_autoNum_seq.ten = other->m_autoNum_seq.ten;
|
|
||||||
m_autoNum_seq.ten_folio = other->m_autoNum_seq.ten_folio;
|
|
||||||
m_autoNum_seq.hundred = other->m_autoNum_seq.hundred;
|
|
||||||
m_autoNum_seq.hundred_folio = other->m_autoNum_seq.hundred_folio;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Conductor::setText
|
* @brief Conductor::setText
|
||||||
* The text of this conductor
|
* The text of this conductor
|
||||||
@@ -1292,24 +1276,6 @@ void Conductor::setOthersSequential(Conductor *other) {
|
|||||||
void Conductor::setText(const QString &t)
|
void Conductor::setText(const QString &t)
|
||||||
{
|
{
|
||||||
text_item->setPlainText(t);
|
text_item->setPlainText(t);
|
||||||
// text_item->setPlainText(t);
|
|
||||||
// if (setSeq && diagram())
|
|
||||||
// {
|
|
||||||
// QString conductor_currentAutoNum = diagram()->project()->conductorCurrentAutoNum();
|
|
||||||
// NumerotationContext nc = diagram()->project()->conductorAutoNum(conductor_currentAutoNum);
|
|
||||||
|
|
||||||
// autonum::setSequential(text(), m_autoNum_seq, nc, diagram(), conductor_currentAutoNum);
|
|
||||||
|
|
||||||
// NumerotationContextCommands ncc (nc);
|
|
||||||
// diagram()->project()->addConductorAutoNum(conductor_currentAutoNum, ncc.next());
|
|
||||||
|
|
||||||
// setSeq = false;
|
|
||||||
// }
|
|
||||||
// if (diagram())
|
|
||||||
// {
|
|
||||||
// QString label = autonum::AssignVariables::formulaToLabel(t, m_autoNum_seq, diagram());
|
|
||||||
// text_item -> setPlainText(label);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -92,7 +92,6 @@ class Conductor : public QObject, public QGraphicsPathItem
|
|||||||
QString text() const;
|
QString text() const;
|
||||||
void setText(const QString &);
|
void setText(const QString &);
|
||||||
void refreshText();
|
void refreshText();
|
||||||
void setOthersSequential (Conductor *);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static bool valideXml (QDomElement &);
|
static bool valideXml (QDomElement &);
|
||||||
@@ -117,10 +116,10 @@ class Conductor : public QObject, public QGraphicsPathItem
|
|||||||
QETDiagramEditor* diagramEditor() const;
|
QETDiagramEditor* diagramEditor() const;
|
||||||
void editProperty ();
|
void editProperty ();
|
||||||
|
|
||||||
autonum::sequenceStruct sequenceStruct () const {return m_autoNum_seq;}
|
autonum::sequentialNumbers sequenceNum () const {return m_autoNum_seq;}
|
||||||
autonum::sequenceStruct& rSequenceStruct() {return m_autoNum_seq;}
|
autonum::sequentialNumbers& rSequenceNum() {return m_autoNum_seq;}
|
||||||
private:
|
private:
|
||||||
autonum::sequenceStruct m_autoNum_seq;
|
autonum::sequentialNumbers m_autoNum_seq;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void setFreezeLabel(bool freeze);
|
void setFreezeLabel(bool freeze);
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ QString CrossRefItem::elementPositionText(const Element *elmt, const bool &add_p
|
|||||||
{
|
{
|
||||||
XRefProperties xrp = m_element->diagram()->defaultXRefProperties(m_element->kindInformations()["type"].toString());
|
XRefProperties xrp = m_element->diagram()->defaultXRefProperties(m_element->kindInformations()["type"].toString());
|
||||||
QString formula = xrp.masterLabel();
|
QString formula = xrp.masterLabel();
|
||||||
autonum::sequenceStruct seq;
|
autonum::sequentialNumbers seq;
|
||||||
QString txt = autonum::AssignVariables::formulaToLabel(formula, seq, elmt->diagram(), elmt);
|
QString txt = autonum::AssignVariables::formulaToLabel(formula, seq, elmt->diagram(), elmt);
|
||||||
|
|
||||||
if (add_prefix)
|
if (add_prefix)
|
||||||
|
|||||||
@@ -29,6 +29,35 @@
|
|||||||
#include "numerotationcontextcommands.h"
|
#include "numerotationcontextcommands.h"
|
||||||
#include "diagramcontext.h"
|
#include "diagramcontext.h"
|
||||||
|
|
||||||
|
class ElementXmlRetroCompatibility
|
||||||
|
{
|
||||||
|
friend class Element;
|
||||||
|
|
||||||
|
static void loadSequential(const QDomElement &dom_element, QString seq, QStringList* list)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
while (!dom_element.attribute(seq + QString::number(i+1)).isEmpty())
|
||||||
|
{
|
||||||
|
list->append(dom_element.attribute(seq + QString::number(i+1)));
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void loadSequential(const QDomElement &dom_element, Element *element)
|
||||||
|
{
|
||||||
|
autonum::sequentialNumbers sn;
|
||||||
|
|
||||||
|
loadSequential(dom_element,"sequ_",&sn.unit);
|
||||||
|
loadSequential(dom_element,"sequf_",&sn.unit_folio);
|
||||||
|
loadSequential(dom_element,"seqt_",&sn.ten);
|
||||||
|
loadSequential(dom_element,"seqtf_",&sn.ten_folio);
|
||||||
|
loadSequential(dom_element,"seqh_",&sn.hundred);
|
||||||
|
loadSequential(dom_element,"seqhf_",&sn.hundred_folio);
|
||||||
|
|
||||||
|
element->rSequenceStruct() = sn;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur pour un element sans scene ni parent
|
Constructeur pour un element sans scene ni parent
|
||||||
*/
|
*/
|
||||||
@@ -430,12 +459,10 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
|
|||||||
m_prefix = e.attribute("prefix");
|
m_prefix = e.attribute("prefix");
|
||||||
|
|
||||||
//Load Sequential Values
|
//Load Sequential Values
|
||||||
loadSequential(&e,"sequ_",&m_autoNum_seq.unit);
|
if (e.hasAttribute("sequ_1") || e.hasAttribute("sequf_1") || e.hasAttribute("seqt_1") || e.hasAttribute("seqtf_1") || e.hasAttribute("seqh_1") || e.hasAttribute("sequf_1"))
|
||||||
loadSequential(&e,"sequf_",&m_autoNum_seq.unit_folio);
|
ElementXmlRetroCompatibility::loadSequential(e, this);
|
||||||
loadSequential(&e,"seqt_",&m_autoNum_seq.ten);
|
else
|
||||||
loadSequential(&e,"seqtf_",&m_autoNum_seq.ten_folio);
|
m_autoNum_seq.fromXml(e.firstChildElement("sequentialNumbers"));
|
||||||
loadSequential(&e,"seqh_",&m_autoNum_seq.hundred);
|
|
||||||
loadSequential(&e,"seqhf_",&m_autoNum_seq.hundred_folio);
|
|
||||||
|
|
||||||
//load informations
|
//load informations
|
||||||
m_element_informations.fromXml(e.firstChildElement("elementInformations"), "elementInformation");
|
m_element_informations.fromXml(e.firstChildElement("elementInformations"), "elementInformation");
|
||||||
@@ -467,21 +494,6 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
|
|||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Load Sequentials to display on element label
|
|
||||||
@param element QDomElement to set Attributes
|
|
||||||
@param Qstring seq to be retrieved
|
|
||||||
@param QStringList list to be inserted values
|
|
||||||
*/
|
|
||||||
void Element::loadSequential(QDomElement* e, QString seq, QStringList* list) {
|
|
||||||
//Load Sequential Values
|
|
||||||
int i = 0;
|
|
||||||
while (!e->attribute(seq + QString::number(i+1)).isEmpty()) {
|
|
||||||
list->append(e->attribute(seq + QString::number(i+1)));
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Permet d'exporter l'element en XML
|
Permet d'exporter l'element en XML
|
||||||
@param document Document XML a utiliser
|
@param document Document XML a utiliser
|
||||||
@@ -490,46 +502,23 @@ void Element::loadSequential(QDomElement* e, QString seq, QStringList* list) {
|
|||||||
methode
|
methode
|
||||||
@return L'element XML representant cet element electrique
|
@return L'element XML representant cet element electrique
|
||||||
*/
|
*/
|
||||||
QDomElement Element::toXml(QDomDocument &document, QHash<Terminal *, int> &table_adr_id) const {
|
QDomElement Element::toXml(QDomDocument &document, QHash<Terminal *, int> &table_adr_id) const
|
||||||
|
{
|
||||||
QDomElement element = document.createElement("element");
|
QDomElement element = document.createElement("element");
|
||||||
|
|
||||||
// type
|
// type
|
||||||
element.setAttribute("type", typeId());
|
element.setAttribute("type", typeId());
|
||||||
|
|
||||||
// uuid
|
// uuid
|
||||||
element.setAttribute("uuid", uuid().toString());
|
element.setAttribute("uuid", uuid().toString());
|
||||||
|
|
||||||
// prefix
|
// prefix
|
||||||
element.setAttribute("prefix", m_prefix);
|
element.setAttribute("prefix", m_prefix);
|
||||||
|
|
||||||
// Save Element sequential values to Xml
|
// sequential num
|
||||||
// Save Unit Sequential Values
|
QDomElement seq = m_autoNum_seq.toXml(document);
|
||||||
for (int i = 0; i < m_autoNum_seq.unit.size(); i++) {
|
if (seq.hasChildNodes())
|
||||||
element.setAttribute("sequ_" + QString::number(i+1),m_autoNum_seq.unit.at(i));
|
element.appendChild(seq);
|
||||||
}
|
|
||||||
|
|
||||||
// Save UnitFolio Sequential Values
|
|
||||||
for (int i = 0; i < m_autoNum_seq.unit_folio.size(); i++) {
|
|
||||||
element.setAttribute("sequf_" + QString::number(i+1),m_autoNum_seq.unit_folio.at(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save Ten Sequential Values
|
|
||||||
for (int i = 0; i < m_autoNum_seq.ten.size(); i++) {
|
|
||||||
element.setAttribute("seqt_" + QString::number(i+1),m_autoNum_seq.ten.at(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save TenFolio Sequential Values
|
|
||||||
for (int i = 0; i < m_autoNum_seq.ten_folio.size(); i++) {
|
|
||||||
element.setAttribute("seqtf_" + QString::number(i+1),m_autoNum_seq.ten_folio.at(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save Hundred Sequential Values
|
|
||||||
for (int i = 0; i < m_autoNum_seq.hundred.size(); i++) {
|
|
||||||
element.setAttribute("seqh_" + QString::number(i+1),m_autoNum_seq.hundred.at(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save Hundred Sequential Values
|
|
||||||
for (int i = 0; i < m_autoNum_seq.hundred_folio.size(); i++) {
|
|
||||||
element.setAttribute("seqhf_" + QString::number(i+1),m_autoNum_seq.hundred_folio.at(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
// position, selection et orientation
|
// position, selection et orientation
|
||||||
element.setAttribute("x", QString("%1").arg(pos().x()));
|
element.setAttribute("x", QString("%1").arg(pos().x()));
|
||||||
|
|||||||
@@ -137,8 +137,8 @@ class Element : public QetGraphicsItem
|
|||||||
//about the herited class like contactelement for know
|
//about the herited class like contactelement for know
|
||||||
// kind of contact (simple tempo) or number of contact show by the element.
|
// kind of contact (simple tempo) or number of contact show by the element.
|
||||||
|
|
||||||
autonum::sequenceStruct sequenceStruct () const {return m_autoNum_seq;}
|
autonum::sequentialNumbers sequenceStruct () const {return m_autoNum_seq;}
|
||||||
autonum::sequenceStruct& rSequenceStruct() {return m_autoNum_seq;}
|
autonum::sequentialNumbers& rSequenceStruct() {return m_autoNum_seq;}
|
||||||
|
|
||||||
void setUpFormula(bool code_letter = true);
|
void setUpFormula(bool code_letter = true);
|
||||||
void setPrefix(QString);
|
void setPrefix(QString);
|
||||||
@@ -153,7 +153,7 @@ class Element : public QetGraphicsItem
|
|||||||
//ATTRIBUTES
|
//ATTRIBUTES
|
||||||
protected:
|
protected:
|
||||||
DiagramContext m_element_informations, kind_informations_;
|
DiagramContext m_element_informations, kind_informations_;
|
||||||
autonum::sequenceStruct m_autoNum_seq;
|
autonum::sequentialNumbers m_autoNum_seq;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Draw this element
|
Draw this element
|
||||||
@@ -203,7 +203,6 @@ class Element : public QetGraphicsItem
|
|||||||
void drawHighlight(QPainter *, const QStyleOptionGraphicsItem *);
|
void drawHighlight(QPainter *, const QStyleOptionGraphicsItem *);
|
||||||
void updatePixmap();
|
void updatePixmap();
|
||||||
void etiToElementLabels(ElementTextItem*);
|
void etiToElementLabels(ElementTextItem*);
|
||||||
void loadSequential(QDomElement* e, QString seq, QStringList* list);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void mouseMoveEvent ( QGraphicsSceneMouseEvent *event );
|
virtual void mouseMoveEvent ( QGraphicsSceneMouseEvent *event );
|
||||||
|
|||||||
@@ -609,7 +609,7 @@ void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
|
|||||||
if (use_properties)
|
if (use_properties)
|
||||||
{
|
{
|
||||||
Conductor *other = conductors_list.toList().first();
|
Conductor *other = conductors_list.toList().first();
|
||||||
new_conductor->setOthersSequential(other);
|
new_conductor->rSequenceNum() = other->sequenceNum();
|
||||||
new_conductor->setProperties(others_properties);
|
new_conductor->setProperties(others_properties);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -254,3 +254,20 @@ bool QETXML::writeXmlFile(const QDomDocument &xml_document, const QString &file_
|
|||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief QETXML::textToDomElement
|
||||||
|
* Return a QDomElement, created from @document, with tag name @tag_name and text @value.
|
||||||
|
* @param document
|
||||||
|
* @param tag_name
|
||||||
|
* @param value
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
QDomElement QETXML::textToDomElement(QDomDocument &document, QString tag_name, QString value)
|
||||||
|
{
|
||||||
|
QDomElement element = document.createElement(tag_name);
|
||||||
|
QDomText text = document.createTextNode(value);
|
||||||
|
|
||||||
|
element.appendChild(text);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ namespace QETXML
|
|||||||
|
|
||||||
bool writeXmlFile(const QDomDocument &xml_document, const QString &file_path, QString *error_message = nullptr);
|
bool writeXmlFile(const QDomDocument &xml_document, const QString &file_path, QString *error_message = nullptr);
|
||||||
|
|
||||||
|
QDomElement textToDomElement (QDomDocument &document, QString tag_name, QString value);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // QETXML_H
|
#endif // QETXML_H
|
||||||
|
|||||||
Reference in New Issue
Block a user