Refactoring. More good looking code.
--HG-- branch : feature
This commit is contained in:
parent
f6e511e43c
commit
28f806a779
|
@ -200,7 +200,7 @@ void DialogHistory::FillTable()
|
|||
*/
|
||||
QString DialogHistory::Record(const VToolRecord &tool)
|
||||
{
|
||||
const QDomElement domElem = doc->elementById(QString().setNum(tool.getId()));
|
||||
const QDomElement domElem = doc->elementById(tool.getId());
|
||||
if (domElem.isElement() == false)
|
||||
{
|
||||
qDebug()<<"Can't find element by id"<<Q_FUNC_INFO;
|
||||
|
|
|
@ -678,7 +678,7 @@ void DialogIncrements::clickedToolButtonRemove()
|
|||
data->RemoveIncrement(itemName->text());
|
||||
|
||||
quint32 id = qvariant_cast<quint32>(itemName->data(Qt::UserRole));
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
QDomElement domElement = doc->elementById(id);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
QDomNodeList list = doc->elementsByTagName(VPattern::TagIncrements);
|
||||
|
@ -750,7 +750,7 @@ void DialogIncrements::IncrementChanged ( qint32 row, qint32 column )
|
|||
const QTableWidgetItem *itemName = ui->tableWidgetIncrement->item(row, 0);
|
||||
const QTableWidgetItem *item = ui->tableWidgetIncrement->item(row, column);
|
||||
const quint32 id = qvariant_cast<quint32>(itemName->data(Qt::UserRole));
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
QDomElement domElement = doc->elementById(id);
|
||||
if (domElement.isElement() == false)
|
||||
{
|
||||
qCDebug(vDialog)<<"Cant't find increment with id = "<<id<<Q_FUNC_INFO;
|
||||
|
|
|
@ -114,7 +114,7 @@ void VDrawTool::FullUpdateFromGuiApply()
|
|||
void VDrawTool::SaveDialogChange()
|
||||
{
|
||||
qCDebug(vTool)<<"Saving tool options after using dialog";
|
||||
QDomElement oldDomElement = doc->elementById(QString().setNum(id));
|
||||
QDomElement oldDomElement = doc->elementById(id);
|
||||
if (oldDomElement.isElement())
|
||||
{
|
||||
QDomElement newDomElement = oldDomElement.cloneNode().toElement();
|
||||
|
@ -148,7 +148,7 @@ void VDrawTool::AddToFile()
|
|||
*/
|
||||
void VDrawTool::RefreshDataInFile()
|
||||
{
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
QDomElement domElement = doc->elementById(id);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
|
||||
|
@ -176,7 +176,7 @@ QColor VDrawTool::CorrectColor(const QColor &color) const
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VDrawTool::ReadAttributes()
|
||||
{
|
||||
const QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
const QDomElement domElement = doc->elementById(id);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
ReadToolAttributes(domElement);
|
||||
|
|
|
@ -146,7 +146,7 @@ void VToolCut::FullUpdateCurveFromFile(const QString &attrCurve)
|
|||
{
|
||||
Q_ASSERT_X(attrCurve.isEmpty() == false, Q_FUNC_INFO, "attribute name is empty");
|
||||
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
QDomElement domElement = doc->elementById(id);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
formula = domElement.attribute(AttrLength, "");
|
||||
|
|
|
@ -275,7 +275,7 @@ void VToolLine::AddToFile()
|
|||
*/
|
||||
void VToolLine::RefreshDataInFile()
|
||||
{
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
QDomElement domElement = doc->elementById(id);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
QSharedPointer<VGObject> obj = QSharedPointer<VGObject> ();
|
||||
|
|
|
@ -335,7 +335,7 @@ void VToolSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
*/
|
||||
void VToolSplinePath::RefreshDataInFile()
|
||||
{
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
QDomElement domElement = doc->elementById(id);
|
||||
if (domElement.isElement() == false)
|
||||
{
|
||||
qDebug()<<"Can't find element with id="<<id<<"in pattern file";
|
||||
|
|
|
@ -99,7 +99,7 @@ void VAbstractNode::decrementReferens()
|
|||
if (_referens <= 0)
|
||||
{
|
||||
doc->DecrementReferens(idNode);
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
QDomElement domElement = doc->elementById(id);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
QDomNode element = domElement.parentNode();
|
||||
|
|
|
@ -164,7 +164,7 @@ void VNodeArc::AddToFile()
|
|||
*/
|
||||
void VNodeArc::RefreshDataInFile()
|
||||
{
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
QDomElement domElement = doc->elementById(id);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
doc->SetAttribute(domElement, AttrIdObject, idNode);
|
||||
|
|
|
@ -180,7 +180,7 @@ void VNodePoint::AddToFile()
|
|||
void VNodePoint::RefreshDataInFile()
|
||||
{
|
||||
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
QDomElement domElement = doc->elementById(id);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
doc->SetAttribute(domElement, AttrIdObject, idNode);
|
||||
|
@ -253,7 +253,7 @@ void VNodePoint::NameChangePosition(const QPointF &pos)
|
|||
*/
|
||||
void VNodePoint::UpdateNamePosition(qreal mx, qreal my)
|
||||
{
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
QDomElement domElement = doc->elementById(id);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
doc->SetAttribute(domElement, AttrMx, QString().setNum(qApp->fromPixel(mx)));
|
||||
|
|
|
@ -167,7 +167,7 @@ void VNodeSpline::AddToFile()
|
|||
*/
|
||||
void VNodeSpline::RefreshDataInFile()
|
||||
{
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
QDomElement domElement = doc->elementById(id);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
doc->SetAttribute(domElement, AttrIdObject, QString().setNum(idNode));
|
||||
|
|
|
@ -170,7 +170,7 @@ void VNodeSplinePath::AddToFile()
|
|||
*/
|
||||
void VNodeSplinePath::RefreshDataInFile()
|
||||
{
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
QDomElement domElement = doc->elementById(id);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
doc->SetAttribute(domElement, AttrIdObject, QString().setNum(idNode));
|
||||
|
|
|
@ -310,7 +310,7 @@ int VAbstractTool::ConfirmDeletion()
|
|||
void VAbstractTool::SaveOption(QSharedPointer<VGObject> &obj)
|
||||
{
|
||||
qCDebug(vTool)<<"Saving tool options";
|
||||
QDomElement oldDomElement = doc->elementById(QString().setNum(id));
|
||||
QDomElement oldDomElement = doc->elementById(id);
|
||||
if (oldDomElement.isElement())
|
||||
{
|
||||
QDomElement newDomElement = oldDomElement.cloneNode().toElement();
|
||||
|
|
|
@ -304,7 +304,7 @@ void VToolDetail::AddToFile()
|
|||
*/
|
||||
void VToolDetail::RefreshDataInFile()
|
||||
{
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
QDomElement domElement = doc->elementById(id);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
VDetail det = VAbstractTool::data.GetDetail(id);
|
||||
|
|
|
@ -750,7 +750,7 @@ void VToolUnionDetails::AddToFile()
|
|||
*/
|
||||
void VToolUnionDetails::RefreshDataInFile()
|
||||
{
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
QDomElement domElement = doc->elementById(id);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
doc->SetAttribute(domElement, AttrIndexD1, indexD1);
|
||||
|
|
|
@ -50,7 +50,7 @@ void AddDet::undo()
|
|||
QDomElement element;
|
||||
if (doc->GetActivNodeElement(VPattern::TagDetails, element))
|
||||
{
|
||||
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||
QDomElement domElement = doc->elementById(nodeId);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
if (element.removeChild(domElement).isNull())
|
||||
|
|
|
@ -49,7 +49,7 @@ void AddDetNode::undo()
|
|||
QDomElement modelingElement;
|
||||
if (doc->GetActivNodeElement(VPattern::TagModeling, modelingElement))
|
||||
{
|
||||
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||
QDomElement domElement = doc->elementById(nodeId);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
if (modelingElement.removeChild(domElement).isNull())
|
||||
|
|
|
@ -56,7 +56,7 @@ void AddToCalc::undo()
|
|||
QDomElement calcElement;
|
||||
if (doc->GetActivNodeElement(VPattern::TagCalculation, calcElement))
|
||||
{
|
||||
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||
QDomElement domElement = doc->elementById(nodeId);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
if (calcElement.removeChild(domElement).isNull())
|
||||
|
@ -102,7 +102,7 @@ void AddToCalc::redo()
|
|||
}
|
||||
else
|
||||
{
|
||||
QDomElement refElement = doc->elementById(QString().setNum(cursor));
|
||||
QDomElement refElement = doc->elementById(cursor);
|
||||
if (refElement.isElement())
|
||||
{
|
||||
calcElement.insertAfter(xml, refElement);
|
||||
|
|
|
@ -49,7 +49,7 @@ void AddUnionDetails::undo()
|
|||
QDomElement modelingElement;
|
||||
if (doc->GetActivNodeElement(VPattern::TagModeling, modelingElement))
|
||||
{
|
||||
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||
QDomElement domElement = doc->elementById(nodeId);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
if (modelingElement.removeChild(domElement).isNull())
|
||||
|
|
|
@ -36,7 +36,7 @@ DeleteDetail::DeleteDetail(VPattern *doc, quint32 id, QUndoCommand *parent)
|
|||
{
|
||||
setText(tr("Delete tool"));
|
||||
nodeId = id;
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
QDomElement domElement = doc->elementById(id);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
xml = domElement.cloneNode().toElement();
|
||||
|
@ -77,7 +77,7 @@ void DeleteDetail::redo()
|
|||
{
|
||||
qCDebug(vUndo)<<"Redo.";
|
||||
|
||||
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||
QDomElement domElement = doc->elementById(nodeId);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
parentNode.removeChild(domElement);
|
||||
|
|
|
@ -42,7 +42,7 @@ MoveDetail::MoveDetail(VPattern *doc, const double &x, const double &y, const qu
|
|||
nodeId = id;
|
||||
|
||||
SCASSERT(scene != nullptr);
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
QDomElement domElement = doc->elementById(id);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
oldX = qApp->toPixel(doc->GetParametrDouble(domElement, VAbstractTool::AttrMx, "0.0"));
|
||||
|
@ -64,7 +64,7 @@ void MoveDetail::undo()
|
|||
{
|
||||
qCDebug(vUndo)<<"Undo.";
|
||||
|
||||
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||
QDomElement domElement = doc->elementById(nodeId);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
SaveCoordinates(domElement, oldX, oldY);
|
||||
|
@ -86,7 +86,7 @@ void MoveDetail::redo()
|
|||
{
|
||||
qCDebug(vUndo)<<"Redo.";
|
||||
|
||||
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||
QDomElement domElement = doc->elementById(nodeId);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
SaveCoordinates(domElement, newX, newY);
|
||||
|
|
|
@ -46,7 +46,7 @@ MoveLabel::MoveLabel(VPattern *doc, const double &x, const double &y, const quin
|
|||
qCDebug(vUndo)<<"Label new My"<<newMy;
|
||||
|
||||
SCASSERT(scene != nullptr);
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
QDomElement domElement = doc->elementById(id);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
oldMx = qApp->toPixel(doc->GetParametrDouble(domElement, VAbstractTool::AttrMx, "0.0"));
|
||||
|
@ -114,7 +114,7 @@ void MoveLabel::Do(double mx, double my)
|
|||
qCDebug(vUndo)<<"New mx"<<mx;
|
||||
qCDebug(vUndo)<<"New my"<<my;
|
||||
|
||||
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||
QDomElement domElement = doc->elementById(nodeId);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
doc->SetAttribute(domElement, VAbstractTool::AttrMx, QString().setNum(qApp->fromPixel(mx)));
|
||||
|
|
|
@ -88,7 +88,7 @@ int MoveSpline::id() const
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void MoveSpline::Do(const VSpline &spl)
|
||||
{
|
||||
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||
QDomElement domElement = doc->elementById(nodeId);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
doc->SetAttribute(domElement, VAbstractTool::AttrAngle1, QString().setNum(spl.GetAngle1()));
|
||||
|
|
|
@ -86,7 +86,7 @@ int MoveSplinePath::id() const
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void MoveSplinePath::Do(const VSplinePath &splPath)
|
||||
{
|
||||
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||
QDomElement domElement = doc->elementById(nodeId);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
doc->SetAttribute(domElement, VToolSplinePath::AttrKCurve, QString().setNum(splPath.GetKCurve()));
|
||||
|
|
|
@ -46,7 +46,7 @@ MoveSPoint::MoveSPoint(VPattern *doc, const double &x, const double &y, const qu
|
|||
qCDebug(vUndo)<<"SPoint newY"<<newY;
|
||||
|
||||
SCASSERT(scene != nullptr);
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
QDomElement domElement = doc->elementById(id);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
oldX = qApp->toPixel(doc->GetParametrDouble(domElement, VAbstractTool::AttrX, "0.0"));
|
||||
|
@ -114,7 +114,7 @@ void MoveSPoint::Do(double x, double y)
|
|||
qCDebug(vUndo)<<"Move to x"<<x;
|
||||
qCDebug(vUndo)<<"Move to y"<<y;
|
||||
|
||||
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||
QDomElement domElement = doc->elementById(nodeId);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
doc->SetAttribute(domElement, VAbstractTool::AttrX, QString().setNum(qApp->fromPixel(x)));
|
||||
|
|
|
@ -48,7 +48,7 @@ void SaveDetailOptions::undo()
|
|||
{
|
||||
qCDebug(vUndo)<<"Undo.";
|
||||
|
||||
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||
QDomElement domElement = doc->elementById(nodeId);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
SaveDet(domElement, oldDet);
|
||||
|
@ -85,7 +85,7 @@ void SaveDetailOptions::redo()
|
|||
{
|
||||
qCDebug(vUndo)<<"Redo.";
|
||||
|
||||
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||
QDomElement domElement = doc->elementById(nodeId);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
SaveDet(domElement, newDet);
|
||||
|
|
|
@ -48,7 +48,7 @@ void SaveToolOptions::undo()
|
|||
{
|
||||
qCDebug(vUndo)<<"Undo.";
|
||||
|
||||
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||
QDomElement domElement = doc->elementById(nodeId);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
domElement.parentNode().replaceChild(oldXml, domElement);
|
||||
|
@ -67,7 +67,7 @@ void SaveToolOptions::redo()
|
|||
{
|
||||
qCDebug(vUndo)<<"Redo.";
|
||||
|
||||
QDomElement domElement = doc->elementById(QString().setNum(nodeId));
|
||||
QDomElement domElement = doc->elementById(nodeId);
|
||||
if (domElement.isElement())
|
||||
{
|
||||
domElement.parentNode().replaceChild(newXml, domElement);
|
||||
|
|
|
@ -134,6 +134,12 @@ QDomElement VDomDocument::elementById(const QString& id)
|
|||
return QDomElement();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QDomElement VDomDocument::elementById(quint32 id)
|
||||
{
|
||||
return elementById(QString().setNum(id));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Removes all children of a given element tag. RENAME: removeAllChildren
|
||||
|
|
|
@ -81,6 +81,7 @@ public:
|
|||
VDomDocument();
|
||||
virtual ~VDomDocument();
|
||||
QDomElement elementById(const QString& id);
|
||||
QDomElement elementById(quint32 id);
|
||||
void removeAllChilds(QDomElement &element);
|
||||
template <typename T>
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user