From 9d283a6283463a9801b3a9bfb8af052a9c4a4736 Mon Sep 17 00:00:00 2001 From: dismine Date: Sat, 18 Jan 2014 17:20:53 +0200 Subject: [PATCH 1/4] Chenged main document element name. --HG-- branch : feature --- src/xml/vdomdocument.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/xml/vdomdocument.cpp b/src/xml/vdomdocument.cpp index 51a034214..87af9b76b 100644 --- a/src/xml/vdomdocument.cpp +++ b/src/xml/vdomdocument.cpp @@ -125,7 +125,11 @@ bool VDomDocument::find(const QDomElement &node, const QString& id) void VDomDocument::CreateEmptyFile() { - QDomElement domElement = this->createElement("lekalo"); + QDomElement domElement = this->createElement("pattern"); + QDomAttr domAttr = createAttribute("xmlns"); + domAttr.setValue("http://www.opengis.net/kml/2.2"); + domElement.setAttributeNode(domAttr); + this->appendChild(domElement); QDomNode xmlNode = this->createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""); this->insertBefore(xmlNode, this->firstChild()); From af7a18808278cb7a18179bd1339ac67af08c7ce7 Mon Sep 17 00:00:00 2001 From: dismine Date: Sun, 19 Jan 2014 12:00:20 +0200 Subject: [PATCH 2/4] Schema. --HG-- branch : feature --- Valentina.pro | 5 +- share/resources/schema.qrc | 5 + share/resources/schema/pattern.xsd | 185 ++++++++++++++++++++ src/exception/vexception.cpp | 17 ++ src/exception/vexception.h | 1 + src/mainwindow.cpp | 267 ++++++++++++++++++----------- src/mainwindow.h | 2 + src/tools/vabstracttool.h | 4 +- src/xml/vdomdocument.cpp | 3 - 9 files changed, 386 insertions(+), 103 deletions(-) create mode 100644 share/resources/schema.qrc create mode 100644 share/resources/schema/pattern.xsd diff --git a/Valentina.pro b/Valentina.pro index 78f02f597..1749518c6 100644 --- a/Valentina.pro +++ b/Valentina.pro @@ -6,7 +6,7 @@ # Use out-of-source builds (shadow builds) -QT += core gui widgets xml svg printsupport +QT += core gui widgets xml svg printsupport xmlpatterns TEMPLATE = app @@ -44,7 +44,8 @@ include(src/xml/xml.pri) RESOURCES += \ share/resources/icon.qrc \ share/resources/cursor.qrc \ - share/resources/theme.qrc + share/resources/theme.qrc \ + share/resources/schema.qrc OTHER_FILES += share/resources/valentina.rc \ share/resources/icon/64x64/icon64x64.ico diff --git a/share/resources/schema.qrc b/share/resources/schema.qrc new file mode 100644 index 000000000..ddc4b4e88 --- /dev/null +++ b/share/resources/schema.qrc @@ -0,0 +1,5 @@ + + + schema/pattern.xsd + + diff --git a/share/resources/schema/pattern.xsd b/share/resources/schema/pattern.xsd new file mode 100644 index 000000000..afc28d690 --- /dev/null +++ b/share/resources/schema/pattern.xsd @@ -0,0 +1,185 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/exception/vexception.cpp b/src/exception/vexception.cpp index 478a7613f..3778f3341 100644 --- a/src/exception/vexception.cpp +++ b/src/exception/vexception.cpp @@ -27,6 +27,7 @@ *************************************************************************/ #include "vexception.h" +#include VException::VException(const QString &what):QException(), what(what) { @@ -38,3 +39,19 @@ QString VException::ErrorMessage() const QString error = QString("Exception: %1").arg(what); return error; } + +void VException::CriticalMessageBox(const QString &situation) const +{ + QMessageBox msgBox; + msgBox.setWindowTitle("Critical error!"); + msgBox.setText(situation); + msgBox.setInformativeText(ErrorMessage()); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setDefaultButton(QMessageBox::Ok); + if (DetailedInformation().isEmpty() == false) + { + msgBox.setDetailedText(DetailedInformation()); + } + msgBox.setIcon(QMessageBox::Critical); + msgBox.exec(); +} diff --git a/src/exception/vexception.h b/src/exception/vexception.h index ce58a7e27..06e939891 100644 --- a/src/exception/vexception.h +++ b/src/exception/vexception.h @@ -74,6 +74,7 @@ public: * @return string with error */ inline QString What() const {return what;} + virtual void CriticalMessageBox(const QString &situation) const; protected: /** * @brief what string with error diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f29c7b2b1..d8dae5b8b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -43,6 +43,35 @@ #include #include #include +#include +#include +#include +#include + +class MessageHandler : public QAbstractMessageHandler +{ +public: + MessageHandler() : QAbstractMessageHandler(0), m_messageType(QtMsgType()), m_description(QString()), + m_sourceLocation(QSourceLocation()){} + inline QString statusMessage() const {return m_description;} + inline qint64 line() const {return m_sourceLocation.line();} + inline qint64 column() const {return m_sourceLocation.column();} +protected: + virtual void handleMessage(QtMsgType type, const QString &description, + const QUrl &identifier, const QSourceLocation &sourceLocation) + { + Q_UNUSED(type); + Q_UNUSED(identifier); + + m_messageType = type; + m_description = description; + m_sourceLocation = sourceLocation; + } +private: + QtMsgType m_messageType; + QString m_description; + QSourceLocation m_sourceLocation; +}; MainWindow::MainWindow(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainWindow), pattern(0), doc(0), tool(Tool::ArrowTool), currentScene(0), @@ -1211,6 +1240,65 @@ void MainWindow::MinimumScrollBar() verScrollBar->setValue(verScrollBar->minimum()); } +bool MainWindow::ValidatePattern(const QString &schema, const QString &fileName, QString &errorMsg, qint64 &errorLine, + qint64 &errorColumn) const +{ + QFile pattern(fileName); + if (pattern.open(QIODevice::ReadOnly) == false) + { + errorMsg = QString(tr("Can't open pattern file.")); + errorLine = -1; + errorColumn = -1; + return false; + } + if(schema.isEmpty()) + { + errorMsg = QString(tr("Empty schema path.")); + errorLine = -1; + errorColumn = -1; + return false; + } + QFile fileSchema(schema); + if(fileSchema.open(QIODevice::ReadOnly) == false) + { + errorMsg = QString(tr("Can't open schema file.")); + errorLine = -1; + errorColumn = -1; + return false; + } + + MessageHandler messageHandler; + QXmlSchema sch; + sch.setMessageHandler(&messageHandler); + sch.load(&fileSchema, QUrl::fromLocalFile(fileSchema.fileName())); + + bool errorOccurred = false; + if (!sch.isValid()) + { + errorOccurred = true; + } + else + { + QXmlSchemaValidator validator(sch); + if (!validator.validate(&pattern, QUrl::fromLocalFile(pattern.fileName()))) + { + errorOccurred = true; + } + } + + if (errorOccurred) + { + errorMsg = messageHandler.statusMessage(); + errorLine = messageHandler.line(); + errorColumn = messageHandler.column(); + return false; + } + else + { + return true; + } +} + bool MainWindow::SafeSaveing(const QString &fileName) const { try @@ -1318,119 +1406,100 @@ void MainWindow::OpenPattern(const QString &fileName) } QFile file(fileName); QString errorMsg; - qint32 errorLine = 0; - qint32 errorColumn = 0; + qint64 errorLine = 0; + qint64 errorColumn = 0; if (file.open(QIODevice::ReadOnly)) { - if (doc->setContent(&file, &errorMsg, &errorLine, &errorColumn)) + if(ValidatePattern("://schema/pattern.xsd", fileName, errorMsg, errorLine, errorColumn)) { - disconnect(comboBoxDraws, static_cast(&QComboBox::currentIndexChanged), - this, &MainWindow::currentDrawChanged); - try + qint32 errorLine = 0; + qint32 errorColumn = 0; + if (doc->setContent(&file, &errorMsg, &errorLine, &errorColumn)) { - doc->Parse(Document::FullParse, sceneDraw, sceneDetails); - } - catch (const VExceptionObjectError &e) - { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error parsing file.")); - msgBox.setInformativeText(e.ErrorMessage()); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setDetailedText(e.DetailedInformation()); - msgBox.setIcon(QMessageBox::Critical); - msgBox.exec(); - file.close(); - Clear(); - return; - } - catch (const VExceptionConversionError &e) - { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error can't convert value.")); - msgBox.setInformativeText(e.ErrorMessage()); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setIcon(QMessageBox::Critical); - msgBox.exec(); - file.close(); - Clear(); - return; - } - catch (const VExceptionEmptyParameter &e) - { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error empty parameter.")); - msgBox.setInformativeText(e.ErrorMessage()); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setDetailedText(e.DetailedInformation()); - msgBox.setIcon(QMessageBox::Critical); - msgBox.exec(); - file.close(); - Clear(); - return; - } - catch (const VExceptionWrongParameterId &e) - { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error wrong id.")); - msgBox.setInformativeText(e.ErrorMessage()); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setDetailedText(e.DetailedInformation()); - msgBox.setIcon(QMessageBox::Critical); - msgBox.exec(); - file.close(); - Clear(); - return; - } - catch (const VExceptionUniqueId &e) - { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error no unique id.")); - msgBox.setInformativeText(e.ErrorMessage()); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setDetailedText(e.DetailedInformation()); - msgBox.setIcon(QMessageBox::Critical); - msgBox.exec(); - file.close(); - Clear(); - return; - } - connect(comboBoxDraws, static_cast(&QComboBox::currentIndexChanged), - this, &MainWindow::currentDrawChanged); - QString nameDraw = doc->GetNameActivDraw(); - qint32 index = comboBoxDraws->findText(nameDraw); - if ( index != -1 ) - { // -1 for not found - comboBoxDraws->setCurrentIndex(index); - } - if (comboBoxDraws->count() > 0) - { - SetEnableTool(true); + disconnect(comboBoxDraws, static_cast(&QComboBox::currentIndexChanged), + this, &MainWindow::currentDrawChanged); + try + { + doc->Parse(Document::FullParse, sceneDraw, sceneDetails); + } + catch (const VExceptionObjectError &e) + { + e.CriticalMessageBox(tr("Error parsing file.")); + file.close(); + Clear(); + return; + } + catch (const VExceptionConversionError &e) + { + e.CriticalMessageBox(tr("Error can't convert value.")); + file.close(); + Clear(); + return; + } + catch (const VExceptionEmptyParameter &e) + { + e.CriticalMessageBox(tr("Error empty parameter.")); + file.close(); + Clear(); + return; + } + catch (const VExceptionWrongParameterId &e) + { + e.CriticalMessageBox(tr("Error wrong id.")); + file.close(); + Clear(); + return; + } + catch (const VExceptionUniqueId &e) + { + e.CriticalMessageBox(tr("Error no unique id.")); + file.close(); + Clear(); + return; + } + connect(comboBoxDraws, static_cast(&QComboBox::currentIndexChanged), + this, &MainWindow::currentDrawChanged); + QString nameDraw = doc->GetNameActivDraw(); + qint32 index = comboBoxDraws->findText(nameDraw); + if ( index != -1 ) + { // -1 for not found + comboBoxDraws->setCurrentIndex(index); + } + if (comboBoxDraws->count() > 0) + { + SetEnableTool(true); + } + else + { + SetEnableTool(false); + } + SetEnableWidgets(true); } else { - SetEnableTool(false); + QMessageBox msgBox; + msgBox.setWindowTitle(tr("Error!")); + msgBox.setText(tr("Parsing pattern file error.")); + msgBox.setInformativeText(errorMsg); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setDefaultButton(QMessageBox::Ok); + QString error = QString(tr("Error in line %1 column %2")).arg(errorLine).arg(errorColumn); + msgBox.setDetailedText(error); + msgBox.exec(); + file.close(); + Clear(); + return; } - SetEnableWidgets(true); } else { QMessageBox msgBox; msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error parsing pattern file.")); + msgBox.setText(tr("Validation file error.")); msgBox.setInformativeText(errorMsg); msgBox.setStandardButtons(QMessageBox::Ok); msgBox.setDefaultButton(QMessageBox::Ok); - QString error = QString(tr("Error in line %1 column %2")).arg(errorLine, errorColumn); + QString error = QString(tr("Error in line %1 column %2")).arg(errorLine).arg(errorColumn); msgBox.setDetailedText(error); msgBox.exec(); file.close(); @@ -1439,6 +1508,10 @@ void MainWindow::OpenPattern(const QString &fileName) } file.close(); } + else + { + qWarning()<fileName = fileName; QFileInfo info(fileName); QString title(info.fileName()); diff --git a/src/mainwindow.h b/src/mainwindow.h index 632773304..9f065b4cc 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -559,6 +559,8 @@ private: * @brief MinimumScrollBar */ void MinimumScrollBar(); + bool ValidatePattern(const QString &schema, const QString &fileName, QString &errorMsg, qint64 &errorLine, + qint64 &errorColumn) const; template /** * @brief AddToolToDetail diff --git a/src/tools/vabstracttool.h b/src/tools/vabstracttool.h index ce6faaced..592740618 100644 --- a/src/tools/vabstracttool.h +++ b/src/tools/vabstracttool.h @@ -317,7 +317,9 @@ protected: void AddAttribute(QDomElement &domElement, const QString &name, const T &value) { QDomAttr domAttr = doc->createAttribute(name); - domAttr.setValue(QString().setNum(value)); + QString val = QString().setNum(value); + val = val.replace(",", "."); + domAttr.setValue(val); domElement.setAttributeNode(domAttr); } private: diff --git a/src/xml/vdomdocument.cpp b/src/xml/vdomdocument.cpp index 87af9b76b..37a0c3af6 100644 --- a/src/xml/vdomdocument.cpp +++ b/src/xml/vdomdocument.cpp @@ -126,9 +126,6 @@ bool VDomDocument::find(const QDomElement &node, const QString& id) void VDomDocument::CreateEmptyFile() { QDomElement domElement = this->createElement("pattern"); - QDomAttr domAttr = createAttribute("xmlns"); - domAttr.setValue("http://www.opengis.net/kml/2.2"); - domElement.setAttributeNode(domAttr); this->appendChild(domElement); QDomNode xmlNode = this->createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""); From d269e45858210cc399fbda7e843a2b3f58373922 Mon Sep 17 00:00:00 2001 From: dismine Date: Mon, 20 Jan 2014 16:00:38 +0200 Subject: [PATCH 3/4] Schema fixes. --HG-- branch : feature --- share/resources/schema/pattern.xsd | 256 ++++++++++-------- src/dialogs/dialogincrements.cpp | 6 +- src/tools/drawTools/vtoolalongline.cpp | 42 +-- src/tools/drawTools/vtoolarc.cpp | 28 +- src/tools/drawTools/vtoolbisector.cpp | 48 ++-- src/tools/drawTools/vtoolcutarc.cpp | 30 +- src/tools/drawTools/vtoolcutspline.cpp | 30 +- src/tools/drawTools/vtoolcutsplinepath.cpp | 30 +- src/tools/drawTools/vtoolendline.cpp | 42 +-- src/tools/drawTools/vtoolheight.cpp | 42 +-- src/tools/drawTools/vtoolline.cpp | 14 +- src/tools/drawTools/vtoollineintersect.cpp | 42 +-- src/tools/drawTools/vtoolnormal.cpp | 48 ++-- src/tools/drawTools/vtoolpoint.cpp | 4 +- src/tools/drawTools/vtoolpointofcontact.cpp | 42 +-- .../drawTools/vtoolpointofintersection.cpp | 30 +- src/tools/drawTools/vtoolshoulderpoint.cpp | 48 ++-- src/tools/drawTools/vtoolsinglepoint.cpp | 34 +-- src/tools/drawTools/vtoolspline.cpp | 56 ++-- src/tools/drawTools/vtoolsplinepath.cpp | 28 +- src/tools/drawTools/vtooltriangle.cpp | 42 +-- src/tools/nodeDetails/vnodearc.cpp | 12 +- src/tools/nodeDetails/vnodepoint.cpp | 24 +- src/tools/nodeDetails/vnodespline.cpp | 12 +- src/tools/nodeDetails/vnodesplinepath.cpp | 12 +- src/tools/vabstracttool.h | 12 +- src/tools/vtooldetail.cpp | 52 ++-- src/tools/vtooluniondetails.cpp | 30 +- 28 files changed, 555 insertions(+), 541 deletions(-) diff --git a/share/resources/schema/pattern.xsd b/share/resources/schema/pattern.xsd index afc28d690..4bed79202 100644 --- a/share/resources/schema/pattern.xsd +++ b/share/resources/schema/pattern.xsd @@ -9,12 +9,12 @@ - - - - - - + + + + + + @@ -26,124 +26,142 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -163,7 +181,7 @@ - + diff --git a/src/dialogs/dialogincrements.cpp b/src/dialogs/dialogincrements.cpp index f78e57f7e..9f668329d 100644 --- a/src/dialogs/dialogincrements.cpp +++ b/src/dialogs/dialogincrements.cpp @@ -442,7 +442,7 @@ void DialogIncrements::cellChanged ( qint32 row, qint32 column ) if (domElement.isElement()) { bool ok = false; - qreal value = item->text().toDouble(&ok); + qreal value = item->text().replace(",", ".").toDouble(&ok); if (ok) { domElement.setAttribute("base", value); @@ -462,7 +462,7 @@ void DialogIncrements::cellChanged ( qint32 row, qint32 column ) domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute("ksize", item->text().toDouble()); + domElement.setAttribute("ksize", item->text().replace(",", ".").toDouble()); this->column = 4; emit FullUpdateTree(); } @@ -474,7 +474,7 @@ void DialogIncrements::cellChanged ( qint32 row, qint32 column ) domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute("kgrowth", item->text().toDouble()); + domElement.setAttribute("kgrowth", item->text().replace(",", ".").toDouble()); this->column = 5; emit FullUpdateTree(); } diff --git a/src/tools/drawTools/vtoolalongline.cpp b/src/tools/drawTools/vtoolalongline.cpp index 978d18b6f..d08b36ec9 100644 --- a/src/tools/drawTools/vtoolalongline.cpp +++ b/src/tools/drawTools/vtoolalongline.cpp @@ -69,11 +69,11 @@ void VToolAlongLine::FullUpdateFromGui(int result) QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrName, dialogAlongLine->getPointName()); - domElement.setAttribute(AttrTypeLine, dialogAlongLine->getTypeLine()); - domElement.setAttribute(AttrLength, dialogAlongLine->getFormula()); - domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogAlongLine->getFirstPointId())); - domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogAlongLine->getSecondPointId())); + SetAttribute(domElement, AttrName, dialogAlongLine->getPointName()); + SetAttribute(domElement, AttrTypeLine, dialogAlongLine->getTypeLine()); + SetAttribute(domElement, AttrLength, dialogAlongLine->getFormula()); + SetAttribute(domElement, AttrFirstPoint, dialogAlongLine->getFirstPointId()); + SetAttribute(domElement, AttrSecondPoint, dialogAlongLine->getSecondPointId()); emit FullUpdateTree(); } } @@ -101,16 +101,16 @@ void VToolAlongLine::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point->name()); - AddAttribute(domElement, AttrMx, toMM(point->mx())); - AddAttribute(domElement, AttrMy, toMM(point->my())); + SetAttribute(domElement, AttrId, id); + SetAttribute(domElement, AttrType, ToolType); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrMx, toMM(point->mx())); + SetAttribute(domElement, AttrMy, toMM(point->my())); - AddAttribute(domElement, AttrTypeLine, typeLine); - AddAttribute(domElement, AttrLength, formula); - AddAttribute(domElement, AttrFirstPoint, basePointId); - AddAttribute(domElement, AttrSecondPoint, secondPointId); + SetAttribute(domElement, AttrTypeLine, typeLine); + SetAttribute(domElement, AttrLength, formula); + SetAttribute(domElement, AttrFirstPoint, basePointId); + SetAttribute(domElement, AttrSecondPoint, secondPointId); AddToCalculation(domElement); } @@ -121,13 +121,13 @@ void VToolAlongLine::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrMx, toMM(point->mx())); - domElement.setAttribute(AttrMy, toMM(point->my())); - domElement.setAttribute(AttrName, point->name()); - domElement.setAttribute(AttrTypeLine, typeLine); - domElement.setAttribute(AttrLength, formula); - domElement.setAttribute(AttrFirstPoint, basePointId); - domElement.setAttribute(AttrSecondPoint, secondPointId); + SetAttribute(domElement, AttrMx, toMM(point->mx())); + SetAttribute(domElement, AttrMy, toMM(point->my())); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrTypeLine, typeLine); + SetAttribute(domElement, AttrLength, formula); + SetAttribute(domElement, AttrFirstPoint, basePointId); + SetAttribute(domElement, AttrSecondPoint, secondPointId); } } diff --git a/src/tools/drawTools/vtoolarc.cpp b/src/tools/drawTools/vtoolarc.cpp index 9169fd6ad..bc9dce3f8 100644 --- a/src/tools/drawTools/vtoolarc.cpp +++ b/src/tools/drawTools/vtoolarc.cpp @@ -144,10 +144,10 @@ void VToolArc::FullUpdateFromGui(int result) QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrCenter, QString().setNum(dialogArc->GetCenter())); - domElement.setAttribute(AttrRadius, dialogArc->GetRadius()); - domElement.setAttribute(AttrAngle1, dialogArc->GetF1()); - domElement.setAttribute(AttrAngle2, dialogArc->GetF2()); + SetAttribute(domElement, AttrCenter, QString().setNum(dialogArc->GetCenter())); + SetAttribute(domElement, AttrRadius, dialogArc->GetRadius()); + SetAttribute(domElement, AttrAngle1, dialogArc->GetF1()); + SetAttribute(domElement, AttrAngle2, dialogArc->GetF2()); emit FullUpdateTree(); } } @@ -194,12 +194,12 @@ void VToolArc::AddToFile() const VArc *arc = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrCenter, arc->GetCenter().id()); - AddAttribute(domElement, AttrRadius, arc->GetFormulaRadius()); - AddAttribute(domElement, AttrAngle1, arc->GetFormulaF1()); - AddAttribute(domElement, AttrAngle2, arc->GetFormulaF2()); + SetAttribute(domElement, AttrId, id); + SetAttribute(domElement, AttrType, ToolType); + SetAttribute(domElement, AttrCenter, arc->GetCenter().id()); + SetAttribute(domElement, AttrRadius, arc->GetFormulaRadius()); + SetAttribute(domElement, AttrAngle1, arc->GetFormulaF1()); + SetAttribute(domElement, AttrAngle2, arc->GetFormulaF2()); AddToCalculation(domElement); } @@ -210,10 +210,10 @@ void VToolArc::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrCenter, arc->GetCenter().id()); - domElement.setAttribute(AttrRadius, arc->GetFormulaRadius()); - domElement.setAttribute(AttrAngle1, arc->GetFormulaF1()); - domElement.setAttribute(AttrAngle2, arc->GetFormulaF2()); + SetAttribute(domElement, AttrCenter, arc->GetCenter().id()); + SetAttribute(domElement, AttrRadius, arc->GetFormulaRadius()); + SetAttribute(domElement, AttrAngle1, arc->GetFormulaF1()); + SetAttribute(domElement, AttrAngle2, arc->GetFormulaF2()); } } diff --git a/src/tools/drawTools/vtoolbisector.cpp b/src/tools/drawTools/vtoolbisector.cpp index 8393cd93c..c57ffc44e 100644 --- a/src/tools/drawTools/vtoolbisector.cpp +++ b/src/tools/drawTools/vtoolbisector.cpp @@ -164,12 +164,12 @@ void VToolBisector::FullUpdateFromGui(int result) QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrName, dialogBisector->getPointName()); - domElement.setAttribute(AttrTypeLine, dialogBisector->getTypeLine()); - domElement.setAttribute(AttrLength, dialogBisector->getFormula()); - domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogBisector->getFirstPointId())); - domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogBisector->getSecondPointId())); - domElement.setAttribute(AttrThirdPoint, QString().setNum(dialogBisector->getThirdPointId())); + SetAttribute(domElement, AttrName, dialogBisector->getPointName()); + SetAttribute(domElement, AttrTypeLine, dialogBisector->getTypeLine()); + SetAttribute(domElement, AttrLength, dialogBisector->getFormula()); + SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogBisector->getFirstPointId())); + SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogBisector->getSecondPointId())); + SetAttribute(domElement, AttrThirdPoint, QString().setNum(dialogBisector->getThirdPointId())); emit FullUpdateTree(); } } @@ -197,17 +197,17 @@ void VToolBisector::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point->name()); - AddAttribute(domElement, AttrMx, toMM(point->mx())); - AddAttribute(domElement, AttrMy, toMM(point->my())); + SetAttribute(domElement, AttrId, id); + SetAttribute(domElement, AttrType, ToolType); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrMx, toMM(point->mx())); + SetAttribute(domElement, AttrMy, toMM(point->my())); - AddAttribute(domElement, AttrTypeLine, typeLine); - AddAttribute(domElement, AttrLength, formula); - AddAttribute(domElement, AttrFirstPoint, firstPointId); - AddAttribute(domElement, AttrSecondPoint, basePointId); - AddAttribute(domElement, AttrThirdPoint, thirdPointId); + SetAttribute(domElement, AttrTypeLine, typeLine); + SetAttribute(domElement, AttrLength, formula); + SetAttribute(domElement, AttrFirstPoint, firstPointId); + SetAttribute(domElement, AttrSecondPoint, basePointId); + SetAttribute(domElement, AttrThirdPoint, thirdPointId); AddToCalculation(domElement); } @@ -218,14 +218,14 @@ void VToolBisector::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrMx, toMM(point->mx())); - domElement.setAttribute(AttrMy, toMM(point->my())); - domElement.setAttribute(AttrName, point->name()); - domElement.setAttribute(AttrTypeLine, typeLine); - domElement.setAttribute(AttrLength, formula); - domElement.setAttribute(AttrFirstPoint, firstPointId); - domElement.setAttribute(AttrSecondPoint, basePointId); - domElement.setAttribute(AttrThirdPoint, thirdPointId); + SetAttribute(domElement, AttrMx, toMM(point->mx())); + SetAttribute(domElement, AttrMy, toMM(point->my())); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrTypeLine, typeLine); + SetAttribute(domElement, AttrLength, formula); + SetAttribute(domElement, AttrFirstPoint, firstPointId); + SetAttribute(domElement, AttrSecondPoint, basePointId); + SetAttribute(domElement, AttrThirdPoint, thirdPointId); } } diff --git a/src/tools/drawTools/vtoolcutarc.cpp b/src/tools/drawTools/vtoolcutarc.cpp index ef24503c6..530ec0b61 100644 --- a/src/tools/drawTools/vtoolcutarc.cpp +++ b/src/tools/drawTools/vtoolcutarc.cpp @@ -171,9 +171,9 @@ void VToolCutArc::FullUpdateFromGui(int result) QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrName, dialogCutArc->getPointName()); - domElement.setAttribute(AttrLength, dialogCutArc->getFormula()); - domElement.setAttribute(AttrArc, QString().setNum(dialogCutArc->getArcId())); + SetAttribute(domElement, AttrName, dialogCutArc->getPointName()); + SetAttribute(domElement, AttrLength, dialogCutArc->getFormula()); + SetAttribute(domElement, AttrArc, QString().setNum(dialogCutArc->getArcId())); emit FullUpdateTree(); } } @@ -223,14 +223,14 @@ void VToolCutArc::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point->name()); - AddAttribute(domElement, AttrMx, toMM(point->mx())); - AddAttribute(domElement, AttrMy, toMM(point->my())); + SetAttribute(domElement, AttrId, id); + SetAttribute(domElement, AttrType, ToolType); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrMx, toMM(point->mx())); + SetAttribute(domElement, AttrMy, toMM(point->my())); - AddAttribute(domElement, AttrLength, formula); - AddAttribute(domElement, AttrArc, arcId); + SetAttribute(domElement, AttrLength, formula); + SetAttribute(domElement, AttrArc, arcId); AddToCalculation(domElement); } @@ -241,11 +241,11 @@ void VToolCutArc::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrName, point->name()); - domElement.setAttribute(AttrMx, toMM(point->mx())); - domElement.setAttribute(AttrMy, toMM(point->my())); - domElement.setAttribute(AttrLength, formula); - domElement.setAttribute(AttrArc, arcId); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrMx, toMM(point->mx())); + SetAttribute(domElement, AttrMy, toMM(point->my())); + SetAttribute(domElement, AttrLength, formula); + SetAttribute(domElement, AttrArc, arcId); } } diff --git a/src/tools/drawTools/vtoolcutspline.cpp b/src/tools/drawTools/vtoolcutspline.cpp index 86cbe343d..8f4fac639 100644 --- a/src/tools/drawTools/vtoolcutspline.cpp +++ b/src/tools/drawTools/vtoolcutspline.cpp @@ -172,9 +172,9 @@ void VToolCutSpline::FullUpdateFromGui(int result) QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrName, dialogCutSpline->getPointName()); - domElement.setAttribute(AttrLength, dialogCutSpline->getFormula()); - domElement.setAttribute(AttrSpline, QString().setNum(dialogCutSpline->getSplineId())); + SetAttribute(domElement, AttrName, dialogCutSpline->getPointName()); + SetAttribute(domElement, AttrLength, dialogCutSpline->getFormula()); + SetAttribute(domElement, AttrSpline, QString().setNum(dialogCutSpline->getSplineId())); emit FullUpdateTree(); } } @@ -224,14 +224,14 @@ void VToolCutSpline::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point->name()); - AddAttribute(domElement, AttrMx, toMM(point->mx())); - AddAttribute(domElement, AttrMy, toMM(point->my())); + SetAttribute(domElement, AttrId, id); + SetAttribute(domElement, AttrType, ToolType); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrMx, toMM(point->mx())); + SetAttribute(domElement, AttrMy, toMM(point->my())); - AddAttribute(domElement, AttrLength, formula); - AddAttribute(domElement, AttrSpline, splineId); + SetAttribute(domElement, AttrLength, formula); + SetAttribute(domElement, AttrSpline, splineId); AddToCalculation(domElement); } @@ -242,11 +242,11 @@ void VToolCutSpline::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrName, point->name()); - domElement.setAttribute(AttrMx, toMM(point->mx())); - domElement.setAttribute(AttrMy, toMM(point->my())); - domElement.setAttribute(AttrLength, formula); - domElement.setAttribute(AttrSpline, splineId); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrMx, toMM(point->mx())); + SetAttribute(domElement, AttrMy, toMM(point->my())); + SetAttribute(domElement, AttrLength, formula); + SetAttribute(domElement, AttrSpline, splineId); } } diff --git a/src/tools/drawTools/vtoolcutsplinepath.cpp b/src/tools/drawTools/vtoolcutsplinepath.cpp index d6698e907..eb95355db 100644 --- a/src/tools/drawTools/vtoolcutsplinepath.cpp +++ b/src/tools/drawTools/vtoolcutsplinepath.cpp @@ -249,9 +249,9 @@ void VToolCutSplinePath::FullUpdateFromGui(int result) QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrName, dialogCutSplinePath->getPointName()); - domElement.setAttribute(AttrLength, dialogCutSplinePath->getFormula()); - domElement.setAttribute(AttrSplinePath, QString().setNum(dialogCutSplinePath->getSplinePathId())); + SetAttribute(domElement, AttrName, dialogCutSplinePath->getPointName()); + SetAttribute(domElement, AttrLength, dialogCutSplinePath->getFormula()); + SetAttribute(domElement, AttrSplinePath, QString().setNum(dialogCutSplinePath->getSplinePathId())); emit FullUpdateTree(); } } @@ -301,14 +301,14 @@ void VToolCutSplinePath::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point->name()); - AddAttribute(domElement, AttrMx, toMM(point->mx())); - AddAttribute(domElement, AttrMy, toMM(point->my())); + SetAttribute(domElement, AttrId, id); + SetAttribute(domElement, AttrType, ToolType); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrMx, toMM(point->mx())); + SetAttribute(domElement, AttrMy, toMM(point->my())); - AddAttribute(domElement, AttrLength, formula); - AddAttribute(domElement, AttrSplinePath, splinePathId); + SetAttribute(domElement, AttrLength, formula); + SetAttribute(domElement, AttrSplinePath, splinePathId); AddToCalculation(domElement); } @@ -319,11 +319,11 @@ void VToolCutSplinePath::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrName, point->name()); - domElement.setAttribute(AttrMx, toMM(point->mx())); - domElement.setAttribute(AttrMy, toMM(point->my())); - domElement.setAttribute(AttrLength, formula); - domElement.setAttribute(AttrSplinePath, splinePathId); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrMx, toMM(point->mx())); + SetAttribute(domElement, AttrMy, toMM(point->my())); + SetAttribute(domElement, AttrLength, formula); + SetAttribute(domElement, AttrSplinePath, splinePathId); } } diff --git a/src/tools/drawTools/vtoolendline.cpp b/src/tools/drawTools/vtoolendline.cpp index f2f69cd92..a41e3796e 100644 --- a/src/tools/drawTools/vtoolendline.cpp +++ b/src/tools/drawTools/vtoolendline.cpp @@ -140,11 +140,11 @@ void VToolEndLine::FullUpdateFromGui(int result) QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrName, dialogEndLine->getPointName()); - domElement.setAttribute(AttrTypeLine, dialogEndLine->getTypeLine()); - domElement.setAttribute(AttrLength, dialogEndLine->getFormula()); - domElement.setAttribute(AttrAngle, QString().setNum(dialogEndLine->getAngle())); - domElement.setAttribute(AttrBasePoint, QString().setNum(dialogEndLine->getBasePointId())); + SetAttribute(domElement, AttrName, dialogEndLine->getPointName()); + SetAttribute(domElement, AttrTypeLine, dialogEndLine->getTypeLine()); + SetAttribute(domElement, AttrLength, dialogEndLine->getFormula()); + SetAttribute(domElement, AttrAngle, QString().setNum(dialogEndLine->getAngle())); + SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogEndLine->getBasePointId())); emit FullUpdateTree(); } } @@ -161,16 +161,16 @@ void VToolEndLine::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point->name()); - AddAttribute(domElement, AttrMx, toMM(point->mx())); - AddAttribute(domElement, AttrMy, toMM(point->my())); + SetAttribute(domElement, AttrId, id); + SetAttribute(domElement, AttrType, ToolType); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrMx, toMM(point->mx())); + SetAttribute(domElement, AttrMy, toMM(point->my())); - AddAttribute(domElement, AttrTypeLine, typeLine); - AddAttribute(domElement, AttrLength, formula); - AddAttribute(domElement, AttrAngle, angle); - AddAttribute(domElement, AttrBasePoint, basePointId); + SetAttribute(domElement, AttrTypeLine, typeLine); + SetAttribute(domElement, AttrLength, formula); + SetAttribute(domElement, AttrAngle, angle); + SetAttribute(domElement, AttrBasePoint, basePointId); AddToCalculation(domElement); } @@ -181,12 +181,12 @@ void VToolEndLine::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrName, point->name()); - domElement.setAttribute(AttrMx, toMM(point->mx())); - domElement.setAttribute(AttrMy, toMM(point->my())); - domElement.setAttribute(AttrTypeLine, typeLine); - domElement.setAttribute(AttrLength, formula); - domElement.setAttribute(AttrAngle, angle); - domElement.setAttribute(AttrBasePoint, basePointId); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrMx, toMM(point->mx())); + SetAttribute(domElement, AttrMy, toMM(point->my())); + SetAttribute(domElement, AttrTypeLine, typeLine); + SetAttribute(domElement, AttrLength, formula); + SetAttribute(domElement, AttrAngle, angle); + SetAttribute(domElement, AttrBasePoint, basePointId); } } diff --git a/src/tools/drawTools/vtoolheight.cpp b/src/tools/drawTools/vtoolheight.cpp index 35802c133..2d096ffa3 100644 --- a/src/tools/drawTools/vtoolheight.cpp +++ b/src/tools/drawTools/vtoolheight.cpp @@ -155,11 +155,11 @@ void VToolHeight::FullUpdateFromGui(int result) QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrName, dialogHeight->getPointName()); - domElement.setAttribute(AttrTypeLine, dialogHeight->getTypeLine()); - domElement.setAttribute(AttrBasePoint, QString().setNum(dialogHeight->getBasePointId())); - domElement.setAttribute(AttrP1Line, QString().setNum(dialogHeight->getP1LineId())); - domElement.setAttribute(AttrP2Line, QString().setNum(dialogHeight->getP2LineId())); + SetAttribute(domElement, AttrName, dialogHeight->getPointName()); + SetAttribute(domElement, AttrTypeLine, dialogHeight->getTypeLine()); + SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogHeight->getBasePointId())); + SetAttribute(domElement, AttrP1Line, QString().setNum(dialogHeight->getP1LineId())); + SetAttribute(domElement, AttrP2Line, QString().setNum(dialogHeight->getP2LineId())); emit FullUpdateTree(); } } @@ -181,16 +181,16 @@ void VToolHeight::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point->name()); - AddAttribute(domElement, AttrMx, toMM(point->mx())); - AddAttribute(domElement, AttrMy, toMM(point->my())); + SetAttribute(domElement, AttrId, id); + SetAttribute(domElement, AttrType, ToolType); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrMx, toMM(point->mx())); + SetAttribute(domElement, AttrMy, toMM(point->my())); - AddAttribute(domElement, AttrTypeLine, typeLine); - AddAttribute(domElement, AttrBasePoint, basePointId); - AddAttribute(domElement, AttrP1Line, p1LineId); - AddAttribute(domElement, AttrP2Line, p2LineId); + SetAttribute(domElement, AttrTypeLine, typeLine); + SetAttribute(domElement, AttrBasePoint, basePointId); + SetAttribute(domElement, AttrP1Line, p1LineId); + SetAttribute(domElement, AttrP2Line, p2LineId); AddToCalculation(domElement); @@ -202,12 +202,12 @@ void VToolHeight::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrName, point->name()); - domElement.setAttribute(AttrMx, toMM(point->mx())); - domElement.setAttribute(AttrMy, toMM(point->my())); - domElement.setAttribute(AttrTypeLine, typeLine); - domElement.setAttribute(AttrBasePoint, basePointId); - domElement.setAttribute(AttrP1Line, p1LineId); - domElement.setAttribute(AttrP2Line, p2LineId); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrMx, toMM(point->mx())); + SetAttribute(domElement, AttrMy, toMM(point->my())); + SetAttribute(domElement, AttrTypeLine, typeLine); + SetAttribute(domElement, AttrBasePoint, basePointId); + SetAttribute(domElement, AttrP1Line, p1LineId); + SetAttribute(domElement, AttrP2Line, p2LineId); } } diff --git a/src/tools/drawTools/vtoolline.cpp b/src/tools/drawTools/vtoolline.cpp index e55890a26..d7af297ce 100644 --- a/src/tools/drawTools/vtoolline.cpp +++ b/src/tools/drawTools/vtoolline.cpp @@ -118,8 +118,8 @@ void VToolLine::FullUpdateFromGui(int result) QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogLine->getFirstPoint())); - domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogLine->getSecondPoint())); + SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogLine->getFirstPoint())); + SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogLine->getSecondPoint())); emit FullUpdateTree(); } } @@ -163,9 +163,9 @@ void VToolLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) void VToolLine::AddToFile() { QDomElement domElement = doc->createElement(TagName); - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrFirstPoint, firstPoint); - AddAttribute(domElement, AttrSecondPoint, secondPoint); + SetAttribute(domElement, AttrId, id); + SetAttribute(domElement, AttrFirstPoint, firstPoint); + SetAttribute(domElement, AttrSecondPoint, secondPoint); AddToCalculation(domElement); } @@ -175,8 +175,8 @@ void VToolLine::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrFirstPoint, firstPoint); - domElement.setAttribute(AttrSecondPoint, secondPoint); + SetAttribute(domElement, AttrFirstPoint, firstPoint); + SetAttribute(domElement, AttrSecondPoint, secondPoint); } } diff --git a/src/tools/drawTools/vtoollineintersect.cpp b/src/tools/drawTools/vtoollineintersect.cpp index 6cd5d6123..04ace6d25 100644 --- a/src/tools/drawTools/vtoollineintersect.cpp +++ b/src/tools/drawTools/vtoollineintersect.cpp @@ -146,11 +146,11 @@ void VToolLineIntersect::FullUpdateFromGui(int result) QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrName, dialogLineIntersect->getPointName()); - domElement.setAttribute(AttrP1Line1, QString().setNum(dialogLineIntersect->getP1Line1())); - domElement.setAttribute(AttrP2Line1, QString().setNum(dialogLineIntersect->getP2Line1())); - domElement.setAttribute(AttrP1Line2, QString().setNum(dialogLineIntersect->getP1Line2())); - domElement.setAttribute(AttrP2Line2, QString().setNum(dialogLineIntersect->getP2Line2())); + SetAttribute(domElement, AttrName, dialogLineIntersect->getPointName()); + SetAttribute(domElement, AttrP1Line1, QString().setNum(dialogLineIntersect->getP1Line1())); + SetAttribute(domElement, AttrP2Line1, QString().setNum(dialogLineIntersect->getP2Line1())); + SetAttribute(domElement, AttrP1Line2, QString().setNum(dialogLineIntersect->getP1Line2())); + SetAttribute(domElement, AttrP2Line2, QString().setNum(dialogLineIntersect->getP2Line2())); emit FullUpdateTree(); } } @@ -178,16 +178,16 @@ void VToolLineIntersect::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point->name()); - AddAttribute(domElement, AttrMx, toMM(point->mx())); - AddAttribute(domElement, AttrMy, toMM(point->my())); + SetAttribute(domElement, AttrId, id); + SetAttribute(domElement, AttrType, ToolType); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrMx, toMM(point->mx())); + SetAttribute(domElement, AttrMy, toMM(point->my())); - AddAttribute(domElement, AttrP1Line1, p1Line1); - AddAttribute(domElement, AttrP2Line1, p2Line1); - AddAttribute(domElement, AttrP1Line2, p1Line2); - AddAttribute(domElement, AttrP2Line2, p2Line2); + SetAttribute(domElement, AttrP1Line1, p1Line1); + SetAttribute(domElement, AttrP2Line1, p2Line1); + SetAttribute(domElement, AttrP1Line2, p1Line2); + SetAttribute(domElement, AttrP2Line2, p2Line2); AddToCalculation(domElement); } @@ -198,13 +198,13 @@ void VToolLineIntersect::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrName, point->name()); - domElement.setAttribute(AttrMx, toMM(point->mx())); - domElement.setAttribute(AttrMy, toMM(point->my())); - domElement.setAttribute(AttrP1Line1, p1Line1); - domElement.setAttribute(AttrP2Line1, p2Line1); - domElement.setAttribute(AttrP1Line2, p1Line2); - domElement.setAttribute(AttrP2Line2, p2Line2); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrMx, toMM(point->mx())); + SetAttribute(domElement, AttrMy, toMM(point->my())); + SetAttribute(domElement, AttrP1Line1, p1Line1); + SetAttribute(domElement, AttrP2Line1, p2Line1); + SetAttribute(domElement, AttrP1Line2, p1Line2); + SetAttribute(domElement, AttrP2Line2, p2Line2); } } diff --git a/src/tools/drawTools/vtoolnormal.cpp b/src/tools/drawTools/vtoolnormal.cpp index dcceb0f8d..5b58ab0fa 100644 --- a/src/tools/drawTools/vtoolnormal.cpp +++ b/src/tools/drawTools/vtoolnormal.cpp @@ -149,12 +149,12 @@ void VToolNormal::FullUpdateFromGui(int result) QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrName, dialogNormal->getPointName()); - domElement.setAttribute(AttrTypeLine, dialogNormal->getTypeLine()); - domElement.setAttribute(AttrLength, dialogNormal->getFormula()); - domElement.setAttribute(AttrAngle, QString().setNum(dialogNormal->getAngle())); - domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogNormal->getFirstPointId())); - domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogNormal->getSecondPointId())); + SetAttribute(domElement, AttrName, dialogNormal->getPointName()); + SetAttribute(domElement, AttrTypeLine, dialogNormal->getTypeLine()); + SetAttribute(domElement, AttrLength, dialogNormal->getFormula()); + SetAttribute(domElement, AttrAngle, QString().setNum(dialogNormal->getAngle())); + SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogNormal->getFirstPointId())); + SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogNormal->getSecondPointId())); emit FullUpdateTree(); } } @@ -182,17 +182,17 @@ void VToolNormal::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point->name()); - AddAttribute(domElement, AttrMx, toMM(point->mx())); - AddAttribute(domElement, AttrMy, toMM(point->my())); + SetAttribute(domElement, AttrId, id); + SetAttribute(domElement, AttrType, ToolType); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrMx, toMM(point->mx())); + SetAttribute(domElement, AttrMy, toMM(point->my())); - AddAttribute(domElement, AttrTypeLine, typeLine); - AddAttribute(domElement, AttrLength, formula); - AddAttribute(domElement, AttrAngle, angle); - AddAttribute(domElement, AttrFirstPoint, basePointId); - AddAttribute(domElement, AttrSecondPoint, secondPointId); + SetAttribute(domElement, AttrTypeLine, typeLine); + SetAttribute(domElement, AttrLength, formula); + SetAttribute(domElement, AttrAngle, angle); + SetAttribute(domElement, AttrFirstPoint, basePointId); + SetAttribute(domElement, AttrSecondPoint, secondPointId); AddToCalculation(domElement); } @@ -203,14 +203,14 @@ void VToolNormal::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrName, point->name()); - domElement.setAttribute(AttrMx, toMM(point->mx())); - domElement.setAttribute(AttrMy, toMM(point->my())); - domElement.setAttribute(AttrTypeLine, typeLine); - domElement.setAttribute(AttrLength, formula); - domElement.setAttribute(AttrAngle, angle); - domElement.setAttribute(AttrFirstPoint, basePointId); - domElement.setAttribute(AttrSecondPoint, secondPointId); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrMx, toMM(point->mx())); + SetAttribute(domElement, AttrMy, toMM(point->my())); + SetAttribute(domElement, AttrTypeLine, typeLine); + SetAttribute(domElement, AttrLength, formula); + SetAttribute(domElement, AttrAngle, angle); + SetAttribute(domElement, AttrFirstPoint, basePointId); + SetAttribute(domElement, AttrSecondPoint, secondPointId); } } diff --git a/src/tools/drawTools/vtoolpoint.cpp b/src/tools/drawTools/vtoolpoint.cpp index e5ff1e066..0e2efcde6 100644 --- a/src/tools/drawTools/vtoolpoint.cpp +++ b/src/tools/drawTools/vtoolpoint.cpp @@ -65,8 +65,8 @@ void VToolPoint::UpdateNamePosition(qreal mx, qreal my) QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrMx, toMM(mx)); - domElement.setAttribute(AttrMy, toMM(my)); + SetAttribute(domElement, AttrMx, toMM(mx)); + SetAttribute(domElement, AttrMy, toMM(my)); emit toolhaveChange(); } } diff --git a/src/tools/drawTools/vtoolpointofcontact.cpp b/src/tools/drawTools/vtoolpointofcontact.cpp index 85ea30731..63aa548be 100644 --- a/src/tools/drawTools/vtoolpointofcontact.cpp +++ b/src/tools/drawTools/vtoolpointofcontact.cpp @@ -169,11 +169,11 @@ void VToolPointOfContact::FullUpdateFromGui(int result) QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrName, dialogPointOfContact->getPointName()); - domElement.setAttribute(AttrRadius, dialogPointOfContact->getRadius()); - domElement.setAttribute(AttrCenter, QString().setNum(dialogPointOfContact->getCenter())); - domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogPointOfContact->getFirstPoint())); - domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogPointOfContact->getSecondPoint())); + SetAttribute(domElement, AttrName, dialogPointOfContact->getPointName()); + SetAttribute(domElement, AttrRadius, dialogPointOfContact->getRadius()); + SetAttribute(domElement, AttrCenter, QString().setNum(dialogPointOfContact->getCenter())); + SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogPointOfContact->getFirstPoint())); + SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogPointOfContact->getSecondPoint())); emit FullUpdateTree(); } } @@ -201,16 +201,16 @@ void VToolPointOfContact::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point->name()); - AddAttribute(domElement, AttrMx, toMM(point->mx())); - AddAttribute(domElement, AttrMy, toMM(point->my())); + SetAttribute(domElement, AttrId, id); + SetAttribute(domElement, AttrType, ToolType); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrMx, toMM(point->mx())); + SetAttribute(domElement, AttrMy, toMM(point->my())); - AddAttribute(domElement, AttrRadius, radius); - AddAttribute(domElement, AttrCenter, center); - AddAttribute(domElement, AttrFirstPoint, firstPointId); - AddAttribute(domElement, AttrSecondPoint, secondPointId); + SetAttribute(domElement, AttrRadius, radius); + SetAttribute(domElement, AttrCenter, center); + SetAttribute(domElement, AttrFirstPoint, firstPointId); + SetAttribute(domElement, AttrSecondPoint, secondPointId); AddToCalculation(domElement); } @@ -221,13 +221,13 @@ void VToolPointOfContact::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrName, point->name()); - domElement.setAttribute(AttrMx, toMM(point->mx())); - domElement.setAttribute(AttrMy, toMM(point->my())); - domElement.setAttribute(AttrRadius, radius); - domElement.setAttribute(AttrCenter, center); - domElement.setAttribute(AttrFirstPoint, firstPointId); - domElement.setAttribute(AttrSecondPoint, secondPointId); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrMx, toMM(point->mx())); + SetAttribute(domElement, AttrMy, toMM(point->my())); + SetAttribute(domElement, AttrRadius, radius); + SetAttribute(domElement, AttrCenter, center); + SetAttribute(domElement, AttrFirstPoint, firstPointId); + SetAttribute(domElement, AttrSecondPoint, secondPointId); } } diff --git a/src/tools/drawTools/vtoolpointofintersection.cpp b/src/tools/drawTools/vtoolpointofintersection.cpp index c403dcd92..60330edb3 100644 --- a/src/tools/drawTools/vtoolpointofintersection.cpp +++ b/src/tools/drawTools/vtoolpointofintersection.cpp @@ -119,9 +119,9 @@ void VToolPointOfIntersection::FullUpdateFromGui(int result) QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrName, dialogPointOfIntersection->getPointName()); - domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogPointOfIntersection->getFirstPointId())); - domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogPointOfIntersection->getSecondPointId())); + SetAttribute(domElement, AttrName, dialogPointOfIntersection->getPointName()); + SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogPointOfIntersection->getFirstPointId())); + SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogPointOfIntersection->getSecondPointId())); emit FullUpdateTree(); } } @@ -149,14 +149,14 @@ void VToolPointOfIntersection::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point->name()); - AddAttribute(domElement, AttrMx, toMM(point->mx())); - AddAttribute(domElement, AttrMy, toMM(point->my())); + SetAttribute(domElement, AttrId, id); + SetAttribute(domElement, AttrType, ToolType); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrMx, toMM(point->mx())); + SetAttribute(domElement, AttrMy, toMM(point->my())); - AddAttribute(domElement, AttrFirstPoint, firstPointId); - AddAttribute(domElement, AttrSecondPoint, secondPointId); + SetAttribute(domElement, AttrFirstPoint, firstPointId); + SetAttribute(domElement, AttrSecondPoint, secondPointId); AddToCalculation(domElement); } @@ -167,10 +167,10 @@ void VToolPointOfIntersection::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrName, point->name()); - domElement.setAttribute(AttrName, toMM(point->mx())); - domElement.setAttribute(AttrName, toMM(point->my())); - domElement.setAttribute(AttrFirstPoint, firstPointId); - domElement.setAttribute(AttrSecondPoint, secondPointId); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrName, toMM(point->mx())); + SetAttribute(domElement, AttrName, toMM(point->my())); + SetAttribute(domElement, AttrFirstPoint, firstPointId); + SetAttribute(domElement, AttrSecondPoint, secondPointId); } } diff --git a/src/tools/drawTools/vtoolshoulderpoint.cpp b/src/tools/drawTools/vtoolshoulderpoint.cpp index ea46e79c4..6bc21c411 100644 --- a/src/tools/drawTools/vtoolshoulderpoint.cpp +++ b/src/tools/drawTools/vtoolshoulderpoint.cpp @@ -172,12 +172,12 @@ void VToolShoulderPoint::FullUpdateFromGui(int result) QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrName, dialogShoulderPoint->getPointName()); - domElement.setAttribute(AttrTypeLine, dialogShoulderPoint->getTypeLine()); - domElement.setAttribute(AttrLength, dialogShoulderPoint->getFormula()); - domElement.setAttribute(AttrP1Line, QString().setNum(dialogShoulderPoint->getP1Line())); - domElement.setAttribute(AttrP2Line, QString().setNum(dialogShoulderPoint->getP2Line())); - domElement.setAttribute(AttrPShoulder, QString().setNum(dialogShoulderPoint->getPShoulder())); + SetAttribute(domElement, AttrName, dialogShoulderPoint->getPointName()); + SetAttribute(domElement, AttrTypeLine, dialogShoulderPoint->getTypeLine()); + SetAttribute(domElement, AttrLength, dialogShoulderPoint->getFormula()); + SetAttribute(domElement, AttrP1Line, QString().setNum(dialogShoulderPoint->getP1Line())); + SetAttribute(domElement, AttrP2Line, QString().setNum(dialogShoulderPoint->getP2Line())); + SetAttribute(domElement, AttrPShoulder, QString().setNum(dialogShoulderPoint->getPShoulder())); emit FullUpdateTree(); } } @@ -205,17 +205,17 @@ void VToolShoulderPoint::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point->name()); - AddAttribute(domElement, AttrMx, toMM(point->mx())); - AddAttribute(domElement, AttrMy, toMM(point->my())); + SetAttribute(domElement, AttrId, id); + SetAttribute(domElement, AttrType, ToolType); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrMx, toMM(point->mx())); + SetAttribute(domElement, AttrMy, toMM(point->my())); - AddAttribute(domElement, AttrTypeLine, typeLine); - AddAttribute(domElement, AttrLength, formula); - AddAttribute(domElement, AttrP1Line, basePointId); - AddAttribute(domElement, AttrP2Line, p2Line); - AddAttribute(domElement, AttrPShoulder, pShoulder); + SetAttribute(domElement, AttrTypeLine, typeLine); + SetAttribute(domElement, AttrLength, formula); + SetAttribute(domElement, AttrP1Line, basePointId); + SetAttribute(domElement, AttrP2Line, p2Line); + SetAttribute(domElement, AttrPShoulder, pShoulder); AddToCalculation(domElement); } @@ -226,14 +226,14 @@ void VToolShoulderPoint::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrName, point->name()); - domElement.setAttribute(AttrName, toMM(point->mx())); - domElement.setAttribute(AttrName, toMM(point->my())); - domElement.setAttribute(AttrTypeLine, typeLine); - domElement.setAttribute(AttrLength, formula); - domElement.setAttribute(AttrP1Line, basePointId); - domElement.setAttribute(AttrP2Line, p2Line); - domElement.setAttribute(AttrPShoulder, pShoulder); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrName, toMM(point->mx())); + SetAttribute(domElement, AttrName, toMM(point->my())); + SetAttribute(domElement, AttrTypeLine, typeLine); + SetAttribute(domElement, AttrLength, formula); + SetAttribute(domElement, AttrP1Line, basePointId); + SetAttribute(domElement, AttrP2Line, p2Line); + SetAttribute(domElement, AttrPShoulder, pShoulder); } } diff --git a/src/tools/drawTools/vtoolsinglepoint.cpp b/src/tools/drawTools/vtoolsinglepoint.cpp index 8b6b6cc69..c98ec47f9 100644 --- a/src/tools/drawTools/vtoolsinglepoint.cpp +++ b/src/tools/drawTools/vtoolsinglepoint.cpp @@ -63,13 +63,13 @@ void VToolSinglePoint::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point->name()); - AddAttribute(domElement, AttrX, toMM(point->x())); - AddAttribute(domElement, AttrY, toMM(point->y())); - AddAttribute(domElement, AttrMx, toMM(point->mx())); - AddAttribute(domElement, AttrMy, toMM(point->my())); + SetAttribute(domElement, AttrId, id); + SetAttribute(domElement, AttrType, ToolType); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrX, toMM(point->x())); + SetAttribute(domElement, AttrY, toMM(point->y())); + SetAttribute(domElement, AttrMx, toMM(point->mx())); + SetAttribute(domElement, AttrMy, toMM(point->my())); AddToCalculation(domElement); } @@ -80,11 +80,11 @@ void VToolSinglePoint::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrName, point->name()); - domElement.setAttribute(AttrX, QString().setNum(toMM(point->x()))); - domElement.setAttribute(AttrY, QString().setNum(toMM(point->y()))); - domElement.setAttribute(AttrMx, QString().setNum(toMM(point->mx()))); - domElement.setAttribute(AttrMy, QString().setNum(toMM(point->my()))); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrX, QString().setNum(toMM(point->x()))); + SetAttribute(domElement, AttrY, QString().setNum(toMM(point->y()))); + SetAttribute(domElement, AttrMx, QString().setNum(toMM(point->mx()))); + SetAttribute(domElement, AttrMy, QString().setNum(toMM(point->my()))); } } @@ -110,8 +110,8 @@ QVariant VToolSinglePoint::itemChange(QGraphicsItem::GraphicsItemChange change, QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrX, QString().setNum(toMM(newPos.x()))); - domElement.setAttribute(AttrY, QString().setNum(toMM(newPos.y()))); + SetAttribute(domElement, AttrX, QString().setNum(toMM(newPos.x()))); + SetAttribute(domElement, AttrY, QString().setNum(toMM(newPos.y()))); QList list = this->scene()->views(); VAbstractTool::NewSceneRect(this->scene(), list[0]); @@ -157,9 +157,9 @@ void VToolSinglePoint::FullUpdateFromGui(int result) QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrName, name); - domElement.setAttribute(AttrX, QString().setNum(toMM(p.x()))); - domElement.setAttribute(AttrY, QString().setNum(toMM(p.y()))); + SetAttribute(domElement, AttrName, name); + SetAttribute(domElement, AttrX, QString().setNum(toMM(p.x()))); + SetAttribute(domElement, AttrY, QString().setNum(toMM(p.y()))); //I don't now why but signal does not work. doc->FullUpdateTree(); } diff --git a/src/tools/drawTools/vtoolspline.cpp b/src/tools/drawTools/vtoolspline.cpp index 2f30be4fc..102a9a34d 100644 --- a/src/tools/drawTools/vtoolspline.cpp +++ b/src/tools/drawTools/vtoolspline.cpp @@ -168,13 +168,13 @@ void VToolSpline::FullUpdateFromGui(int result) QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrPoint1, spl.GetP1().id()); - domElement.setAttribute(AttrPoint4, spl.GetP4().id()); - domElement.setAttribute(AttrAngle1, spl.GetAngle1()); - domElement.setAttribute(AttrAngle2, spl.GetAngle2()); - domElement.setAttribute(AttrKAsm1, spl.GetKasm1()); - domElement.setAttribute(AttrKAsm2, spl.GetKasm2()); - domElement.setAttribute(AttrKCurve, spl.GetKcurve()); + SetAttribute(domElement, AttrPoint1, spl.GetP1().id()); + SetAttribute(domElement, AttrPoint4, spl.GetP4().id()); + SetAttribute(domElement, AttrAngle1, spl.GetAngle1()); + SetAttribute(domElement, AttrAngle2, spl.GetAngle2()); + SetAttribute(domElement, AttrKAsm1, spl.GetKasm1()); + SetAttribute(domElement, AttrKAsm2, spl.GetKasm2()); + SetAttribute(domElement, AttrKCurve, spl.GetKcurve()); emit FullUpdateTree(); } } @@ -198,11 +198,11 @@ void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const Sp QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrAngle1, QString().setNum(spl.GetAngle1())); - domElement.setAttribute(AttrAngle2, QString().setNum(spl.GetAngle2())); - domElement.setAttribute(AttrKAsm1, QString().setNum(spl.GetKasm1())); - domElement.setAttribute(AttrKAsm2, QString().setNum(spl.GetKasm2())); - domElement.setAttribute(AttrKCurve, QString().setNum(spl.GetKcurve())); + SetAttribute(domElement, AttrAngle1, QString().setNum(spl.GetAngle1())); + SetAttribute(domElement, AttrAngle2, QString().setNum(spl.GetAngle2())); + SetAttribute(domElement, AttrKAsm1, QString().setNum(spl.GetKasm1())); + SetAttribute(domElement, AttrKAsm2, QString().setNum(spl.GetKasm2())); + SetAttribute(domElement, AttrKCurve, QString().setNum(spl.GetKcurve())); emit FullUpdateTree(); } } @@ -217,15 +217,15 @@ void VToolSpline::AddToFile() const VSpline *spl = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrPoint1, spl->GetP1().id()); - AddAttribute(domElement, AttrPoint4, spl->GetP4().id()); - AddAttribute(domElement, AttrAngle1, spl->GetAngle1()); - AddAttribute(domElement, AttrAngle2, spl->GetAngle2()); - AddAttribute(domElement, AttrKAsm1, spl->GetKasm1()); - AddAttribute(domElement, AttrKAsm2, spl->GetKasm2()); - AddAttribute(domElement, AttrKCurve, spl->GetKcurve()); + SetAttribute(domElement, AttrId, id); + SetAttribute(domElement, AttrType, ToolType); + SetAttribute(domElement, AttrPoint1, spl->GetP1().id()); + SetAttribute(domElement, AttrPoint4, spl->GetP4().id()); + SetAttribute(domElement, AttrAngle1, spl->GetAngle1()); + SetAttribute(domElement, AttrAngle2, spl->GetAngle2()); + SetAttribute(domElement, AttrKAsm1, spl->GetKasm1()); + SetAttribute(domElement, AttrKAsm2, spl->GetKasm2()); + SetAttribute(domElement, AttrKCurve, spl->GetKcurve()); AddToCalculation(domElement); } @@ -236,13 +236,13 @@ void VToolSpline::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrPoint1, spl->GetP1().id()); - domElement.setAttribute(AttrPoint4, spl->GetP4().id()); - domElement.setAttribute(AttrAngle1, spl->GetAngle1()); - domElement.setAttribute(AttrAngle2, spl->GetAngle2()); - domElement.setAttribute(AttrKAsm1, spl->GetKasm1()); - domElement.setAttribute(AttrKAsm2, spl->GetKasm2()); - domElement.setAttribute(AttrKCurve, spl->GetKcurve()); + SetAttribute(domElement, AttrPoint1, spl->GetP1().id()); + SetAttribute(domElement, AttrPoint4, spl->GetP4().id()); + SetAttribute(domElement, AttrAngle1, spl->GetAngle1()); + SetAttribute(domElement, AttrAngle2, spl->GetAngle2()); + SetAttribute(domElement, AttrKAsm1, spl->GetKasm1()); + SetAttribute(domElement, AttrKAsm2, spl->GetKasm2()); + SetAttribute(domElement, AttrKCurve, spl->GetKcurve()); } } diff --git a/src/tools/drawTools/vtoolsplinepath.cpp b/src/tools/drawTools/vtoolsplinepath.cpp index 905a7d1c6..4ec238d9c 100644 --- a/src/tools/drawTools/vtoolsplinepath.cpp +++ b/src/tools/drawTools/vtoolsplinepath.cpp @@ -157,7 +157,7 @@ void VToolSplinePath::FullUpdateFromGui(int result) QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrKCurve, QString().setNum(splPath.getKCurve())); + SetAttribute(domElement, AttrKCurve, QString().setNum(splPath.getKCurve())); UpdatePathPoint(domElement, splPath); emit FullUpdateTree(); } @@ -185,7 +185,7 @@ void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, cons QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrKCurve, QString().setNum(splPath.getKCurve())); + SetAttribute(domElement, AttrKCurve, QString().setNum(splPath.getKCurve())); UpdatePathPoint(domElement, splPath); emit FullUpdateTree(); } @@ -214,10 +214,10 @@ void VToolSplinePath::UpdatePathPoint(QDomNode& node, VSplinePath &path) if (domElement.isNull() == false) { VSplinePoint p = path[i]; - domElement.setAttribute(AttrPSpline, p.P().id()); - domElement.setAttribute(AttrKAsm1, p.KAsm1()); - domElement.setAttribute(AttrKAsm2, p.KAsm2()); - domElement.setAttribute(AttrAngle, p.Angle2()); + SetAttribute(domElement, AttrPSpline, p.P().id()); + SetAttribute(domElement, AttrKAsm1, p.KAsm1()); + SetAttribute(domElement, AttrKAsm2, p.KAsm2()); + SetAttribute(domElement, AttrAngle, p.Angle2()); } } } @@ -263,9 +263,9 @@ void VToolSplinePath::AddToFile() VSplinePath splPath = *VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrKCurve, splPath.getKCurve()); + SetAttribute(domElement, AttrId, id); + SetAttribute(domElement, AttrType, ToolType); + SetAttribute(domElement, AttrKCurve, splPath.getKCurve()); for (qint32 i = 0; i < splPath.CountPoint(); ++i) { @@ -301,7 +301,7 @@ void VToolSplinePath::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrKCurve, QString().setNum(splPath.getKCurve())); + SetAttribute(domElement, AttrKCurve, QString().setNum(splPath.getKCurve())); UpdatePathPoint(domElement, splPath); } @@ -312,10 +312,10 @@ void VToolSplinePath::AddPathPoint(QDomElement &domElement, const VSplinePoint & { QDomElement pathPoint = doc->createElement(AttrPathPoint); - AddAttribute(pathPoint, AttrPSpline, splPoint.P().id()); - AddAttribute(pathPoint, AttrKAsm1, splPoint.KAsm1()); - AddAttribute(pathPoint, AttrKAsm2, splPoint.KAsm2()); - AddAttribute(pathPoint, AttrAngle, splPoint.Angle2()); + SetAttribute(pathPoint, AttrPSpline, splPoint.P().id()); + SetAttribute(pathPoint, AttrKAsm1, splPoint.KAsm1()); + SetAttribute(pathPoint, AttrKAsm2, splPoint.KAsm2()); + SetAttribute(pathPoint, AttrAngle, splPoint.Angle2()); domElement.appendChild(pathPoint); } diff --git a/src/tools/drawTools/vtooltriangle.cpp b/src/tools/drawTools/vtooltriangle.cpp index 12b59448f..183b19df4 100644 --- a/src/tools/drawTools/vtooltriangle.cpp +++ b/src/tools/drawTools/vtooltriangle.cpp @@ -172,11 +172,11 @@ void VToolTriangle::FullUpdateFromGui(int result) QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrName, dialogTriangle->getPointName()); - domElement.setAttribute(AttrAxisP1, QString().setNum(dialogTriangle->getAxisP1Id())); - domElement.setAttribute(AttrAxisP2, QString().setNum(dialogTriangle->getAxisP2Id())); - domElement.setAttribute(AttrFirstPoint, QString().setNum(dialogTriangle->getFirstPointId())); - domElement.setAttribute(AttrSecondPoint, QString().setNum(dialogTriangle->getSecondPointId())); + SetAttribute(domElement, AttrName, dialogTriangle->getPointName()); + SetAttribute(domElement, AttrAxisP1, QString().setNum(dialogTriangle->getAxisP1Id())); + SetAttribute(domElement, AttrAxisP2, QString().setNum(dialogTriangle->getAxisP2Id())); + SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTriangle->getFirstPointId())); + SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTriangle->getSecondPointId())); emit FullUpdateTree(); } @@ -207,16 +207,16 @@ void VToolTriangle::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrName, point->name()); - AddAttribute(domElement, AttrMx, toMM(point->mx())); - AddAttribute(domElement, AttrMy, toMM(point->my())); + SetAttribute(domElement, AttrId, id); + SetAttribute(domElement, AttrType, ToolType); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrMx, toMM(point->mx())); + SetAttribute(domElement, AttrMy, toMM(point->my())); - AddAttribute(domElement, AttrAxisP1, axisP1Id); - AddAttribute(domElement, AttrAxisP2, axisP2Id); - AddAttribute(domElement, AttrFirstPoint, firstPointId); - AddAttribute(domElement, AttrSecondPoint, secondPointId); + SetAttribute(domElement, AttrAxisP1, axisP1Id); + SetAttribute(domElement, AttrAxisP2, axisP2Id); + SetAttribute(domElement, AttrFirstPoint, firstPointId); + SetAttribute(domElement, AttrSecondPoint, secondPointId); AddToCalculation(domElement); } @@ -227,12 +227,12 @@ void VToolTriangle::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrName, point->name()); - domElement.setAttribute(AttrMx, toMM(point->mx())); - domElement.setAttribute(AttrMy, toMM(point->my())); - domElement.setAttribute(AttrAxisP1, axisP1Id); - domElement.setAttribute(AttrAxisP2, axisP2Id); - domElement.setAttribute(AttrFirstPoint, firstPointId); - domElement.setAttribute(AttrSecondPoint, secondPointId); + SetAttribute(domElement, AttrName, point->name()); + SetAttribute(domElement, AttrMx, toMM(point->mx())); + SetAttribute(domElement, AttrMy, toMM(point->my())); + SetAttribute(domElement, AttrAxisP1, axisP1Id); + SetAttribute(domElement, AttrAxisP2, axisP2Id); + SetAttribute(domElement, AttrFirstPoint, firstPointId); + SetAttribute(domElement, AttrSecondPoint, secondPointId); } } diff --git a/src/tools/nodeDetails/vnodearc.cpp b/src/tools/nodeDetails/vnodearc.cpp index 2a9208197..c2375e625 100644 --- a/src/tools/nodeDetails/vnodearc.cpp +++ b/src/tools/nodeDetails/vnodearc.cpp @@ -93,12 +93,12 @@ void VNodeArc::AddToFile() { QDomElement domElement = doc->createElement(TagName); - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrIdObject, idNode); + SetAttribute(domElement, AttrId, id); + SetAttribute(domElement, AttrType, ToolType); + SetAttribute(domElement, AttrIdObject, idNode); if (idTool != 0) { - AddAttribute(domElement, AttrIdTool, idTool); + SetAttribute(domElement, AttrIdTool, idTool); } AddToModeling(domElement); @@ -109,10 +109,10 @@ void VNodeArc::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrIdObject, idNode); + SetAttribute(domElement, AttrIdObject, idNode); if (idTool != 0) { - domElement.setAttribute(AttrIdTool, idTool); + SetAttribute(domElement, AttrIdTool, idTool); } } } diff --git a/src/tools/nodeDetails/vnodepoint.cpp b/src/tools/nodeDetails/vnodepoint.cpp index 5d48ce2a5..f28b82e96 100644 --- a/src/tools/nodeDetails/vnodepoint.cpp +++ b/src/tools/nodeDetails/vnodepoint.cpp @@ -105,14 +105,14 @@ void VNodePoint::AddToFile() const VPointF *point = VAbstractTool::data.GeometricObject(id); QDomElement domElement = doc->createElement(TagName); - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrIdObject, idNode); - AddAttribute(domElement, AttrMx, toMM(point->mx())); - AddAttribute(domElement, AttrMy, toMM(point->my())); + SetAttribute(domElement, AttrId, id); + SetAttribute(domElement, AttrType, ToolType); + SetAttribute(domElement, AttrIdObject, idNode); + SetAttribute(domElement, AttrMx, toMM(point->mx())); + SetAttribute(domElement, AttrMy, toMM(point->my())); if (idTool != 0) { - AddAttribute(domElement, AttrIdTool, idTool); + SetAttribute(domElement, AttrIdTool, idTool); } AddToModeling(domElement); @@ -124,12 +124,12 @@ void VNodePoint::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrIdObject, idNode); - domElement.setAttribute(AttrMx, toMM(point->mx())); - domElement.setAttribute(AttrMy, toMM(point->my())); + SetAttribute(domElement, AttrIdObject, idNode); + SetAttribute(domElement, AttrMx, toMM(point->mx())); + SetAttribute(domElement, AttrMy, toMM(point->my())); if (idTool != 0) { - domElement.setAttribute(AttrIdTool, idTool); + SetAttribute(domElement, AttrIdTool, idTool); } } } @@ -172,8 +172,8 @@ void VNodePoint::UpdateNamePosition(qreal mx, qreal my) QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrMx, QString().setNum(toMM(mx))); - domElement.setAttribute(AttrMy, QString().setNum(toMM(my))); + SetAttribute(domElement, AttrMx, QString().setNum(toMM(mx))); + SetAttribute(domElement, AttrMy, QString().setNum(toMM(my))); emit toolhaveChange(); } } diff --git a/src/tools/nodeDetails/vnodespline.cpp b/src/tools/nodeDetails/vnodespline.cpp index f6ce6014d..2746cd11e 100644 --- a/src/tools/nodeDetails/vnodespline.cpp +++ b/src/tools/nodeDetails/vnodespline.cpp @@ -96,12 +96,12 @@ void VNodeSpline::AddToFile() { QDomElement domElement = doc->createElement(TagName); - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrIdObject, idNode); + SetAttribute(domElement, AttrId, id); + SetAttribute(domElement, AttrType, ToolType); + SetAttribute(domElement, AttrIdObject, idNode); if (idTool != 0) { - AddAttribute(domElement, AttrIdTool, idTool); + SetAttribute(domElement, AttrIdTool, idTool); } AddToModeling(domElement); @@ -112,10 +112,10 @@ void VNodeSpline::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrIdObject, QString().setNum(idNode)); + SetAttribute(domElement, AttrIdObject, QString().setNum(idNode)); if (idTool != 0) { - domElement.setAttribute(AttrIdTool, idTool); + SetAttribute(domElement, AttrIdTool, idTool); } } } diff --git a/src/tools/nodeDetails/vnodesplinepath.cpp b/src/tools/nodeDetails/vnodesplinepath.cpp index 590fd4f19..58c998da9 100644 --- a/src/tools/nodeDetails/vnodesplinepath.cpp +++ b/src/tools/nodeDetails/vnodesplinepath.cpp @@ -100,12 +100,12 @@ void VNodeSplinePath::AddToFile() { QDomElement domElement = doc->createElement(TagName); - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrIdObject, idNode); + SetAttribute(domElement, AttrId, id); + SetAttribute(domElement, AttrType, ToolType); + SetAttribute(domElement, AttrIdObject, idNode); if (idTool != 0) { - AddAttribute(domElement, AttrIdTool, idTool); + SetAttribute(domElement, AttrIdTool, idTool); } AddToModeling(domElement); @@ -116,10 +116,10 @@ void VNodeSplinePath::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrIdObject, QString().setNum(idNode)); + SetAttribute(domElement, AttrIdObject, QString().setNum(idNode)); if (idTool != 0) { - domElement.setAttribute(AttrIdTool, idTool); + SetAttribute(domElement, AttrIdTool, idTool); } } } diff --git a/src/tools/vabstracttool.h b/src/tools/vabstracttool.h index 592740618..2db87e517 100644 --- a/src/tools/vabstracttool.h +++ b/src/tools/vabstracttool.h @@ -314,23 +314,19 @@ protected: * @param name * @param value */ - void AddAttribute(QDomElement &domElement, const QString &name, const T &value) + void SetAttribute(QDomElement &domElement, const QString &name, const T &value) { - QDomAttr domAttr = doc->createAttribute(name); QString val = QString().setNum(value); val = val.replace(",", "."); - domAttr.setValue(val); - domElement.setAttributeNode(domAttr); + domElement.setAttribute(name, val); } private: Q_DISABLE_COPY(VAbstractTool) }; template <> -inline void VAbstractTool::AddAttribute(QDomElement &domElement, const QString &name, const QString &value) +inline void VAbstractTool::SetAttribute(QDomElement &domElement, const QString &name, const QString &value) { - QDomAttr domAttr = doc->createAttribute(name); - domAttr.setValue(value); - domElement.setAttributeNode(domAttr); + domElement.setAttribute(name, value); } #endif // VABSTRACTTOOL_H diff --git a/src/tools/vtooldetail.cpp b/src/tools/vtooldetail.cpp index 42a23f9fd..b5861f466 100644 --- a/src/tools/vtooldetail.cpp +++ b/src/tools/vtooldetail.cpp @@ -176,10 +176,10 @@ void VToolDetail::FullUpdateFromGui(int result) if (domElement.isElement()) { VDetail det = dialogDetail->getDetails(); - domElement.setAttribute(AttrName, det.getName()); - domElement.setAttribute(AttrSupplement, QString().setNum(det.getSupplement())); - domElement.setAttribute(AttrClosed, QString().setNum(det.getClosed())); - domElement.setAttribute(AttrWidth, QString().setNum(det.getWidth())); + SetAttribute(domElement, AttrName, det.getName()); + SetAttribute(domElement, AttrSupplement, QString().setNum(det.getSupplement())); + SetAttribute(domElement, AttrClosed, QString().setNum(det.getClosed())); + SetAttribute(domElement, AttrWidth, QString().setNum(det.getWidth())); RemoveAllChild(domElement); for (ptrdiff_t i = 0; i < det.CountNode(); ++i) { @@ -207,13 +207,13 @@ void VToolDetail::AddToFile() VDetail detail = VAbstractTool::data.GetDetail(id); QDomElement domElement = doc->createElement(TagName); - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrName, detail.getName()); - AddAttribute(domElement, AttrMx, toMM(detail.getMx())); - AddAttribute(domElement, AttrMy, toMM(detail.getMy())); - AddAttribute(domElement, AttrSupplement, detail.getSupplement()); - AddAttribute(domElement, AttrClosed, detail.getClosed()); - AddAttribute(domElement, AttrWidth, detail.getWidth()); + SetAttribute(domElement, AttrId, id); + SetAttribute(domElement, AttrName, detail.getName()); + SetAttribute(domElement, AttrMx, toMM(detail.getMx())); + SetAttribute(domElement, AttrMy, toMM(detail.getMy())); + SetAttribute(domElement, AttrSupplement, detail.getSupplement()); + SetAttribute(domElement, AttrClosed, detail.getClosed()); + SetAttribute(domElement, AttrWidth, detail.getWidth()); for (ptrdiff_t i = 0; i < detail.CountNode(); ++i) { @@ -234,10 +234,10 @@ void VToolDetail::RefreshDataInFile() if (domElement.isElement()) { VDetail det = VAbstractTool::data.GetDetail(id); - domElement.setAttribute(AttrName, det.getName()); - domElement.setAttribute(AttrSupplement, QString().setNum(det.getSupplement())); - domElement.setAttribute(AttrClosed, QString().setNum(det.getClosed())); - domElement.setAttribute(AttrWidth, QString().setNum(det.getWidth())); + SetAttribute(domElement, AttrName, det.getName()); + SetAttribute(domElement, AttrSupplement, QString().setNum(det.getSupplement())); + SetAttribute(domElement, AttrClosed, QString().setNum(det.getClosed())); + SetAttribute(domElement, AttrWidth, QString().setNum(det.getWidth())); RemoveAllChild(domElement); for (ptrdiff_t i = 0; i < det.CountNode(); ++i) { @@ -256,8 +256,8 @@ QVariant VToolDetail::itemChange(QGraphicsItem::GraphicsItemChange change, const QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrMx, QString().setNum(toMM(newPos.x()))); - domElement.setAttribute(AttrMy, QString().setNum(toMM(newPos.y()))); + SetAttribute(domElement, AttrMx, QString().setNum(toMM(newPos.x()))); + SetAttribute(domElement, AttrMy, QString().setNum(toMM(newPos.y()))); QList list = this->scene()->views(); VAbstractTool::NewSceneRect(this->scene(), list[0]); @@ -346,30 +346,30 @@ void VToolDetail::AddNode(QDomElement &domElement, const VNodeDetail &node) { QDomElement nod = doc->createElement(TagNode); - AddAttribute(nod, AttrIdObject, node.getId()); - AddAttribute(nod, AttrMx, toMM(node.getMx())); - AddAttribute(nod, AttrMy, toMM(node.getMy())); + SetAttribute(nod, AttrIdObject, node.getId()); + SetAttribute(nod, AttrMx, toMM(node.getMx())); + SetAttribute(nod, AttrMy, toMM(node.getMy())); if (node.getTypeNode() == NodeDetail::Contour) { - AddAttribute(nod, AttrNodeType, NodeTypeContour); + SetAttribute(nod, AttrNodeType, NodeTypeContour); } else { - AddAttribute(nod, AttrNodeType, NodeTypeModeling); + SetAttribute(nod, AttrNodeType, NodeTypeModeling); } switch (node.getTypeTool()) { case (Tool::NodeArc): - AddAttribute(nod, AttrType, QStringLiteral("NodeArc")); + SetAttribute(nod, AttrType, QStringLiteral("NodeArc")); break; case (Tool::NodePoint): - AddAttribute(nod, AttrType, QStringLiteral("NodePoint")); + SetAttribute(nod, AttrType, QStringLiteral("NodePoint")); break; case (Tool::NodeSpline): - AddAttribute(nod, AttrType, QStringLiteral("NodeSpline")); + SetAttribute(nod, AttrType, QStringLiteral("NodeSpline")); break; case (Tool::NodeSplinePath): - AddAttribute(nod, AttrType, QStringLiteral("NodeSplinePath")); + SetAttribute(nod, AttrType, QStringLiteral("NodeSplinePath")); break; default: qWarning()<<"May be wrong tool type!!! Ignoring."<createElement(TagName); - AddAttribute(domElement, AttrId, id); - AddAttribute(domElement, AttrType, ToolType); - AddAttribute(domElement, AttrIndexD1, indexD1); - AddAttribute(domElement, AttrIndexD2, indexD2); + SetAttribute(domElement, AttrId, id); + SetAttribute(domElement, AttrType, ToolType); + SetAttribute(domElement, AttrIndexD1, indexD1); + SetAttribute(domElement, AttrIndexD2, indexD2); AddDetail(domElement, d1); AddDetail(domElement, d2); @@ -686,8 +686,8 @@ void VToolUnionDetails::RefreshDataInFile() QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { - domElement.setAttribute(AttrIndexD1, indexD1); - domElement.setAttribute(AttrIndexD2, indexD2); + SetAttribute(domElement, AttrIndexD1, indexD1); + SetAttribute(domElement, AttrIndexD2, indexD2); QDomNode domNode = domElement.firstChild(); domNode = UpdateDetail(domNode, d1); @@ -711,30 +711,30 @@ void VToolUnionDetails::AddNode(QDomElement &domElement, const VNodeDetail &node { QDomElement nod = doc->createElement(TagNode); - AddAttribute(nod, AttrIdObject, node.getId()); - AddAttribute(nod, AttrMx, toMM(node.getMx())); - AddAttribute(nod, AttrMy, toMM(node.getMy())); + SetAttribute(nod, AttrIdObject, node.getId()); + SetAttribute(nod, AttrMx, toMM(node.getMx())); + SetAttribute(nod, AttrMy, toMM(node.getMy())); if (node.getTypeNode() == NodeDetail::Contour) { - AddAttribute(nod, AttrNodeType, NodeTypeContour); + SetAttribute(nod, AttrNodeType, NodeTypeContour); } else { - AddAttribute(nod, AttrNodeType, NodeTypeModeling); + SetAttribute(nod, AttrNodeType, NodeTypeModeling); } switch (node.getTypeTool()) { case (Tool::NodeArc): - AddAttribute(nod, AttrType, QStringLiteral("NodeArc")); + SetAttribute(nod, AttrType, QStringLiteral("NodeArc")); break; case (Tool::NodePoint): - AddAttribute(nod, AttrType, QStringLiteral("NodePoint")); + SetAttribute(nod, AttrType, QStringLiteral("NodePoint")); break; case (Tool::NodeSpline): - AddAttribute(nod, AttrType, QStringLiteral("NodeSpline")); + SetAttribute(nod, AttrType, QStringLiteral("NodeSpline")); break; case (Tool::NodeSplinePath): - AddAttribute(nod, AttrType, QStringLiteral("NodeSplinePath")); + SetAttribute(nod, AttrType, QStringLiteral("NodeSplinePath")); break; default: qWarning()<<"May be wrong tool type!!! Ignoring."< Date: Mon, 20 Jan 2014 16:21:25 +0200 Subject: [PATCH 4/4] Comment string in pattern file. --HG-- branch : feature --- src/xml/vdomdocument.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/xml/vdomdocument.cpp b/src/xml/vdomdocument.cpp index 37a0c3af6..6012b4875 100644 --- a/src/xml/vdomdocument.cpp +++ b/src/xml/vdomdocument.cpp @@ -128,6 +128,8 @@ void VDomDocument::CreateEmptyFile() QDomElement domElement = this->createElement("pattern"); this->appendChild(domElement); + QDomComment info = this->createComment("Valentina pattern format."); + domElement.appendChild(info); QDomNode xmlNode = this->createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""); this->insertBefore(xmlNode, this->firstChild()); QDomElement incrElement = this->createElement("increments");