diff --git a/sources/diagram.cpp b/sources/diagram.cpp
index 0a8a395c1..2efa92d5f 100644
--- a/sources/diagram.cpp
+++ b/sources/diagram.cpp
@@ -317,6 +317,13 @@ QDomDocument Diagram::toXml(bool whole_content) {
QDomElement default_conductor = document.createElement("defaultconductor");
defaultConductorProperties.toXml(default_conductor);
racine.appendChild(default_conductor);
+
+ //autonumerotation of conductor
+ if (!getNumerotation(Diagram::Conductors).isEmpty()) {
+ QDomElement autonum = document.createElement("autonum");
+ autonum.appendChild(getNumerotation(Diagram::Conductors).toXML(document, "conductor"));
+ racine.appendChild(autonum);
+ }
}
document.appendChild(racine);
@@ -460,6 +467,16 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
if (!default_conductor_elmt.isNull()) {
defaultConductorProperties.fromXml(default_conductor_elmt);
}
+ // find the first element autonum
+ QDomElement num_auto = root.firstChildElement("autonum");
+ if (!num_auto.isNull()) {
+ QDomElement num_conductor = num_auto.firstChildElement("conductor");
+ //set the auto-numerotation of conductor
+ if (!num_conductor.isNull()) {
+ NumerotationContext nc(num_conductor);
+ setNumerotation(Diagram::Conductors, nc);
+ }
+ }
}
// si la racine n'a pas d'enfant : le chargement est fini (schema vide)
diff --git a/sources/numerotationcontext.cpp b/sources/numerotationcontext.cpp
index 61933ed87..a99063f8b 100644
--- a/sources/numerotationcontext.cpp
+++ b/sources/numerotationcontext.cpp
@@ -16,6 +16,20 @@
along with QElectroTech. If not, see .
*/
#include "numerotationcontext.h"
+#include "qet.h"
+
+/**
+ * Constructor
+ */
+NumerotationContext::NumerotationContext(){
+}
+
+/**
+ * Constructor from xml
+ */
+NumerotationContext::NumerotationContext(QDomElement &e) {
+ fromXML(e);
+}
/**
* @brief NumerotationContext::clear, clear the content
@@ -64,6 +78,14 @@ int NumerotationContext::size() const {
return (content_.size());
}
+/**
+ * @brief NumerotationContext::isEmpty
+ * @return true if numerotation contet is empty
+ */
+bool NumerotationContext::isEmpty() const {
+ if (content_.size() > 0) return false;
+ return true;
+}
/**
* @brief NumerotationContext::itemAt
* @return the content at position @i 1:type 2:value 3:increase
@@ -103,3 +125,29 @@ bool NumerotationContext::keyIsAcceptable(const QString &type) const {
bool NumerotationContext::keyIsNumber(const QString &type) const {
return (type.contains(QRegExp(validRegExpNumber())));
}
+
+/**
+ * @brief NumerotationContext::toXML
+ * Save the numerotation context in a QDomElement under the element name @str
+ */
+QDomElement NumerotationContext::toXML(QDomDocument &d, QString str) {
+ QDomElement num_auto = d.createElement(str);
+ for (int i=0; i
#include
+#include
+
/**
This class represents a numerotation context, i.e. the data (type, value, increase)
of a numerotation at a given time. It is notably used by conductor
@@ -28,16 +30,21 @@
class NumerotationContext
{
public:
+ NumerotationContext ();
+ NumerotationContext (QDomElement &);
void clear();
bool addValue(const QString &, const QVariant & = QVariant(1), const int = 1);
QString operator[] (const int &) const;
void operator << (const NumerotationContext &);
int size() const;
+ bool isEmpty() const;
QStringList itemAt(const int) const;
QString validRegExpNum () const;
QString validRegExpNumber() const;
bool keyIsAcceptable (const QString &) const;
bool keyIsNumber(const QString &) const;
+ QDomElement toXML(QDomDocument &, QString);
+ void fromXML(QDomElement &);
private:
QStringList content_;