mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
add methods to save/load autonumerotation of conductor to .qet file
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2171 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -16,6 +16,20 @@
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#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<content_.size(); ++i) {
|
||||
QStringList strl = itemAt(i);
|
||||
QDomElement part = d.createElement("part");
|
||||
part.setAttribute("type", strl.at(0));
|
||||
part.setAttribute("value", strl.at(1));
|
||||
part.setAttribute("increase", strl.at(2));
|
||||
num_auto.appendChild(part);
|
||||
}
|
||||
return num_auto;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief NumerotationContext::fromXML
|
||||
* load numerotation context from @e
|
||||
*/
|
||||
void NumerotationContext::fromXML(QDomElement &e) {
|
||||
clear();
|
||||
foreach(QDomElement qde, QET::findInDomElement(e, "part")) addValue(qde.attribute("type"), qde.attribute("value"), qde.attribute("increase").toInt());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user