mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-04-05 11:59:59 +02: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:
@@ -1268,22 +1268,6 @@ QString Conductor::text() const {
|
||||
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
|
||||
* The text of this conductor
|
||||
@@ -1292,24 +1276,6 @@ void Conductor::setOthersSequential(Conductor *other) {
|
||||
void Conductor::setText(const QString &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;
|
||||
void setText(const QString &);
|
||||
void refreshText();
|
||||
void setOthersSequential (Conductor *);
|
||||
|
||||
public:
|
||||
static bool valideXml (QDomElement &);
|
||||
@@ -117,10 +116,10 @@ class Conductor : public QObject, public QGraphicsPathItem
|
||||
QETDiagramEditor* diagramEditor() const;
|
||||
void editProperty ();
|
||||
|
||||
autonum::sequenceStruct sequenceStruct () const {return m_autoNum_seq;}
|
||||
autonum::sequenceStruct& rSequenceStruct() {return m_autoNum_seq;}
|
||||
autonum::sequentialNumbers sequenceNum () const {return m_autoNum_seq;}
|
||||
autonum::sequentialNumbers& rSequenceNum() {return m_autoNum_seq;}
|
||||
private:
|
||||
autonum::sequenceStruct m_autoNum_seq;
|
||||
autonum::sequentialNumbers m_autoNum_seq;
|
||||
|
||||
public:
|
||||
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());
|
||||
QString formula = xrp.masterLabel();
|
||||
autonum::sequenceStruct seq;
|
||||
autonum::sequentialNumbers seq;
|
||||
QString txt = autonum::AssignVariables::formulaToLabel(formula, seq, elmt->diagram(), elmt);
|
||||
|
||||
if (add_prefix)
|
||||
|
||||
@@ -29,6 +29,35 @@
|
||||
#include "numerotationcontextcommands.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
|
||||
*/
|
||||
@@ -426,16 +455,14 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
|
||||
//uuid of this element
|
||||
uuid_= QUuid(e.attribute("uuid", QUuid::createUuid().toString()));
|
||||
|
||||
//load prefix
|
||||
//load prefix
|
||||
m_prefix = e.attribute("prefix");
|
||||
|
||||
//Load Sequential Values
|
||||
loadSequential(&e,"sequ_",&m_autoNum_seq.unit);
|
||||
loadSequential(&e,"sequf_",&m_autoNum_seq.unit_folio);
|
||||
loadSequential(&e,"seqt_",&m_autoNum_seq.ten);
|
||||
loadSequential(&e,"seqtf_",&m_autoNum_seq.ten_folio);
|
||||
loadSequential(&e,"seqh_",&m_autoNum_seq.hundred);
|
||||
loadSequential(&e,"seqhf_",&m_autoNum_seq.hundred_folio);
|
||||
//Load Sequential Values
|
||||
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"))
|
||||
ElementXmlRetroCompatibility::loadSequential(e, this);
|
||||
else
|
||||
m_autoNum_seq.fromXml(e.firstChildElement("sequentialNumbers"));
|
||||
|
||||
//load informations
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
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
|
||||
@param document Document XML a utiliser
|
||||
@@ -490,46 +502,23 @@ void Element::loadSequential(QDomElement* e, QString seq, QStringList* list) {
|
||||
methode
|
||||
@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");
|
||||
|
||||
// type
|
||||
// type
|
||||
element.setAttribute("type", typeId());
|
||||
// uuid
|
||||
|
||||
// uuid
|
||||
element.setAttribute("uuid", uuid().toString());
|
||||
// prefix
|
||||
|
||||
// prefix
|
||||
element.setAttribute("prefix", m_prefix);
|
||||
|
||||
// Save Element sequential values to Xml
|
||||
// Save Unit Sequential Values
|
||||
for (int i = 0; i < m_autoNum_seq.unit.size(); i++) {
|
||||
element.setAttribute("sequ_" + QString::number(i+1),m_autoNum_seq.unit.at(i));
|
||||
}
|
||||
|
||||
// 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));
|
||||
}
|
||||
// sequential num
|
||||
QDomElement seq = m_autoNum_seq.toXml(document);
|
||||
if (seq.hasChildNodes())
|
||||
element.appendChild(seq);
|
||||
|
||||
// position, selection et orientation
|
||||
element.setAttribute("x", QString("%1").arg(pos().x()));
|
||||
|
||||
@@ -137,8 +137,8 @@ class Element : public QetGraphicsItem
|
||||
//about the herited class like contactelement for know
|
||||
// kind of contact (simple tempo) or number of contact show by the element.
|
||||
|
||||
autonum::sequenceStruct sequenceStruct () const {return m_autoNum_seq;}
|
||||
autonum::sequenceStruct& rSequenceStruct() {return m_autoNum_seq;}
|
||||
autonum::sequentialNumbers sequenceStruct () const {return m_autoNum_seq;}
|
||||
autonum::sequentialNumbers& rSequenceStruct() {return m_autoNum_seq;}
|
||||
|
||||
void setUpFormula(bool code_letter = true);
|
||||
void setPrefix(QString);
|
||||
@@ -153,7 +153,7 @@ class Element : public QetGraphicsItem
|
||||
//ATTRIBUTES
|
||||
protected:
|
||||
DiagramContext m_element_informations, kind_informations_;
|
||||
autonum::sequenceStruct m_autoNum_seq;
|
||||
autonum::sequentialNumbers m_autoNum_seq;
|
||||
|
||||
/**
|
||||
Draw this element
|
||||
@@ -203,7 +203,6 @@ class Element : public QetGraphicsItem
|
||||
void drawHighlight(QPainter *, const QStyleOptionGraphicsItem *);
|
||||
void updatePixmap();
|
||||
void etiToElementLabels(ElementTextItem*);
|
||||
void loadSequential(QDomElement* e, QString seq, QStringList* list);
|
||||
|
||||
protected:
|
||||
virtual void mouseMoveEvent ( QGraphicsSceneMouseEvent *event );
|
||||
|
||||
@@ -609,7 +609,7 @@ void Terminal::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
|
||||
if (use_properties)
|
||||
{
|
||||
Conductor *other = conductors_list.toList().first();
|
||||
new_conductor->setOthersSequential(other);
|
||||
new_conductor->rSequenceNum() = other->sequenceNum();
|
||||
new_conductor->setProperties(others_properties);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user