valentina/tools/vabstracttool.cpp

82 lines
2.7 KiB
C++
Raw Normal View History

#pragma GCC diagnostic ignored "-Weffc++"
2013-07-25 20:39:51 +02:00
#include "vabstracttool.h"
2013-07-29 14:55:40 +02:00
#include <QDebug>
#pragma GCC diagnostic pop
2013-07-25 20:39:51 +02:00
VAbstractTool::VAbstractTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent):
VDataTool(data, parent){
2013-07-25 20:39:51 +02:00
this->doc = doc;
2013-07-25 20:39:51 +02:00
this->id = id;
nameActivDraw = doc->GetNameActivDraw();
ignoreContextMenuEvent = false;//don't ignore context menu events;
connect(this->doc, &VDomDocument::ChangedActivDraw, this, &VAbstractTool::ChangedActivDraw);
connect(this->doc, &VDomDocument::ChangedNameDraw, this, &VAbstractTool::ChangedNameDraw);
connect(this, &VAbstractTool::toolhaveChange, this->doc, &VDomDocument::haveLiteChange);
2013-07-25 20:39:51 +02:00
connect(this->doc, &VDomDocument::FullUpdateFromFile, this, &VAbstractTool::FullUpdateFromFile);
2013-07-29 14:55:40 +02:00
connect(this, &VAbstractTool::FullUpdateTree, this->doc, &VDomDocument::FullUpdateTree);
2013-07-25 20:39:51 +02:00
}
void VAbstractTool::ChangedNameDraw(const QString oldName, const QString newName){
if(nameActivDraw == oldName){
nameActivDraw = newName;
}
}
void VAbstractTool::ChangedActivDraw(const QString newName){
if(nameActivDraw == newName){
ignoreContextMenuEvent = false;
} else {
ignoreContextMenuEvent = true;
}
}
void VAbstractTool::AddAttribute(QDomElement &domElement, const QString &name, const qint64 &value){
QDomAttr domAttr = doc->createAttribute(name);
domAttr.setValue(QString().setNum(value));
domElement.setAttributeNode(domAttr);
}
void VAbstractTool::AddAttribute(QDomElement &domElement, const QString &name, const qint32 &value){
QDomAttr domAttr = doc->createAttribute(name);
domAttr.setValue(QString().setNum(value));
domElement.setAttributeNode(domAttr);
}
void VAbstractTool::AddAttribute(QDomElement &domElement, const QString &name, const qreal &value){
QDomAttr domAttr = doc->createAttribute(name);
domAttr.setValue(QString().setNum(value));
domElement.setAttributeNode(domAttr);
}
void VAbstractTool::AddAttribute(QDomElement &domElement, const QString &name, const QString &value){
QDomAttr domAttr = doc->createAttribute(name);
domAttr.setValue(value);
domElement.setAttributeNode(domAttr);
}
VAbstractTool::~VAbstractTool(){
}
2013-07-29 14:55:40 +02:00
void VAbstractTool::AddToCalculation(const QDomElement &domElement){
QDomElement calcElement;
bool ok = doc->GetActivCalculationElement(calcElement);
if(ok){
calcElement.appendChild(domElement);
} else {
qCritical()<<"Не можу знайти тег калькуляції."<< Q_FUNC_INFO;
}
}
const VContainer *VAbstractTool::getData()const{
return &data;
}
void VAbstractTool::setData(const VContainer &value){
data = value;
}
void VAbstractTool::setDialog(){
}