Performance improvement. Speed up method VDomDocument::elementById.
--HG-- branch : develop
This commit is contained in:
parent
ca66c8ebe2
commit
acc340bff1
|
@ -2207,7 +2207,7 @@ QString VAbstractPattern::GetGroupName(quint32 id)
|
||||||
QDomElement groups = CreateGroups();
|
QDomElement groups = CreateGroups();
|
||||||
if (not groups.isNull())
|
if (not groups.isNull())
|
||||||
{
|
{
|
||||||
QDomElement group = elementById(id);
|
QDomElement group = elementById(id, TagGroup);
|
||||||
if (group.isElement())
|
if (group.isElement())
|
||||||
{
|
{
|
||||||
name = GetParametrString(group, AttrName, name);
|
name = GetParametrString(group, AttrName, name);
|
||||||
|
@ -2238,7 +2238,7 @@ void VAbstractPattern::SetGroupName(quint32 id, const QString &name)
|
||||||
QDomElement groups = CreateGroups();
|
QDomElement groups = CreateGroups();
|
||||||
if (not groups.isNull())
|
if (not groups.isNull())
|
||||||
{
|
{
|
||||||
QDomElement group = elementById(id);
|
QDomElement group = elementById(id, TagGroup);
|
||||||
if (group.isElement())
|
if (group.isElement())
|
||||||
{
|
{
|
||||||
group.setAttribute(AttrName, name);
|
group.setAttribute(AttrName, name);
|
||||||
|
@ -2311,7 +2311,7 @@ QMap<quint32, QPair<QString, bool> > VAbstractPattern::GetGroups()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
bool VAbstractPattern::GetGroupVisivility(quint32 id)
|
bool VAbstractPattern::GetGroupVisivility(quint32 id)
|
||||||
{
|
{
|
||||||
QDomElement group = elementById(id);
|
QDomElement group = elementById(id, TagGroup);
|
||||||
if (group.isElement())
|
if (group.isElement())
|
||||||
{
|
{
|
||||||
return GetParametrBool(group, AttrVisible, trueStr);
|
return GetParametrBool(group, AttrVisible, trueStr);
|
||||||
|
@ -2326,7 +2326,7 @@ bool VAbstractPattern::GetGroupVisivility(quint32 id)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractPattern::SetGroupVisivility(quint32 id, bool visible)
|
void VAbstractPattern::SetGroupVisivility(quint32 id, bool visible)
|
||||||
{
|
{
|
||||||
QDomElement group = elementById(id);
|
QDomElement group = elementById(id, TagGroup);
|
||||||
if (group.isElement())
|
if (group.isElement())
|
||||||
{
|
{
|
||||||
SetAttribute(group, AttrVisible, visible);
|
SetAttribute(group, AttrVisible, visible);
|
||||||
|
|
|
@ -194,7 +194,7 @@ VDomDocument::VDomDocument()
|
||||||
* @param id value id attribute.
|
* @param id value id attribute.
|
||||||
* @return dom element.
|
* @return dom element.
|
||||||
*/
|
*/
|
||||||
QDomElement VDomDocument::elementById(const QString& id)
|
QDomElement VDomDocument::elementById(const QString& id, const QString &tagName)
|
||||||
{
|
{
|
||||||
if (map.contains(id))
|
if (map.contains(id))
|
||||||
{
|
{
|
||||||
|
@ -206,18 +206,38 @@ QDomElement VDomDocument::elementById(const QString& id)
|
||||||
map.remove(id);
|
map.remove(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->find(this->documentElement(), id))
|
if (tagName.isEmpty())
|
||||||
{
|
{
|
||||||
return map[id];
|
if (this->find(this->documentElement(), id))
|
||||||
|
{
|
||||||
|
return map[id];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const QDomNodeList list = elementsByTagName(tagName);
|
||||||
|
for (int i=0; i < list.size(); ++i)
|
||||||
|
{
|
||||||
|
const QDomElement domElement = list.at(i).toElement();
|
||||||
|
if (not domElement.isNull() && domElement.hasAttribute(AttrId))
|
||||||
|
{
|
||||||
|
const QString value = domElement.attribute(AttrId);
|
||||||
|
this->map[value] = domElement;
|
||||||
|
if (value == id)
|
||||||
|
{
|
||||||
|
return domElement;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QDomElement();
|
return QDomElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QDomElement VDomDocument::elementById(quint32 id)
|
QDomElement VDomDocument::elementById(quint32 id, const QString &tagName)
|
||||||
{
|
{
|
||||||
return elementById(QString().setNum(id));
|
return elementById(QString().setNum(id), tagName);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -88,8 +88,8 @@ public:
|
||||||
|
|
||||||
VDomDocument();
|
VDomDocument();
|
||||||
virtual ~VDomDocument() Q_DECL_EQ_DEFAULT;
|
virtual ~VDomDocument() Q_DECL_EQ_DEFAULT;
|
||||||
QDomElement elementById(const QString& id);
|
QDomElement elementById(const QString& id, const QString &tagName = QString());
|
||||||
QDomElement elementById(quint32 id);
|
QDomElement elementById(quint32 id, const QString &tagName = QString());
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const;
|
void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const;
|
||||||
|
|
|
@ -106,7 +106,7 @@ void VDrawTool::ChangedNameDraw(const QString &oldName, const QString &newName)
|
||||||
void VDrawTool::SaveDialogChange()
|
void VDrawTool::SaveDialogChange()
|
||||||
{
|
{
|
||||||
qCDebug(vTool, "Saving tool options after using dialog");
|
qCDebug(vTool, "Saving tool options after using dialog");
|
||||||
QDomElement oldDomElement = doc->elementById(id);
|
QDomElement oldDomElement = doc->elementById(id, getTagName());
|
||||||
if (oldDomElement.isElement())
|
if (oldDomElement.isElement())
|
||||||
{
|
{
|
||||||
QDomElement newDomElement = oldDomElement.cloneNode().toElement();
|
QDomElement newDomElement = oldDomElement.cloneNode().toElement();
|
||||||
|
@ -138,7 +138,7 @@ void VDrawTool::AddToFile()
|
||||||
void VDrawTool::SaveOption(QSharedPointer<VGObject> &obj)
|
void VDrawTool::SaveOption(QSharedPointer<VGObject> &obj)
|
||||||
{
|
{
|
||||||
qCDebug(vTool, "Saving tool options");
|
qCDebug(vTool, "Saving tool options");
|
||||||
QDomElement oldDomElement = doc->elementById(id);
|
QDomElement oldDomElement = doc->elementById(id, getTagName());
|
||||||
if (oldDomElement.isElement())
|
if (oldDomElement.isElement())
|
||||||
{
|
{
|
||||||
QDomElement newDomElement = oldDomElement.cloneNode().toElement();
|
QDomElement newDomElement = oldDomElement.cloneNode().toElement();
|
||||||
|
@ -179,7 +179,7 @@ bool VDrawTool::CorrectDisable(bool disable, const QString &namePP) const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VDrawTool::ReadAttributes()
|
void VDrawTool::ReadAttributes()
|
||||||
{
|
{
|
||||||
const QDomElement domElement = doc->elementById(id);
|
const QDomElement domElement = doc->elementById(id, getTagName());
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
ReadToolAttributes(domElement);
|
ReadToolAttributes(domElement);
|
||||||
|
|
|
@ -90,7 +90,7 @@ void VAbstractNode::incrementReferens()
|
||||||
doc->IncrementReferens(node->getIdTool());
|
doc->IncrementReferens(node->getIdTool());
|
||||||
}
|
}
|
||||||
ShowNode();
|
ShowNode();
|
||||||
QDomElement domElement = doc->elementById(id);
|
QDomElement domElement = doc->elementById(id, getTagName());
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::InUse);
|
doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::InUse);
|
||||||
|
@ -117,7 +117,7 @@ void VAbstractNode::decrementReferens()
|
||||||
doc->DecrementReferens(node->getIdTool());
|
doc->DecrementReferens(node->getIdTool());
|
||||||
}
|
}
|
||||||
HideNode();
|
HideNode();
|
||||||
QDomElement domElement = doc->elementById(id);
|
QDomElement domElement = doc->elementById(id, getTagName());
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::NotInUse);
|
doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::NotInUse);
|
||||||
|
|
|
@ -230,7 +230,7 @@ void VNodePoint::NameChangePosition(const QPointF &pos)
|
||||||
*/
|
*/
|
||||||
void VNodePoint::UpdateNamePosition(qreal mx, qreal my)
|
void VNodePoint::UpdateNamePosition(qreal mx, qreal my)
|
||||||
{
|
{
|
||||||
QDomElement domElement = doc->elementById(id);
|
QDomElement domElement = doc->elementById(id, getTagName());
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
doc->SetAttribute(domElement, AttrMx, QString().setNum(qApp->fromPixel(mx)));
|
doc->SetAttribute(domElement, AttrMx, QString().setNum(qApp->fromPixel(mx)));
|
||||||
|
|
|
@ -146,7 +146,7 @@ void VToolPiecePath::incrementReferens()
|
||||||
IncrementNodes(VAbstractTool::data.GetPiecePath(id));
|
IncrementNodes(VAbstractTool::data.GetPiecePath(id));
|
||||||
}
|
}
|
||||||
ShowNode();
|
ShowNode();
|
||||||
QDomElement domElement = doc->elementById(id);
|
QDomElement domElement = doc->elementById(id, getTagName());
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::InUse);
|
doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::InUse);
|
||||||
|
@ -169,7 +169,7 @@ void VToolPiecePath::decrementReferens()
|
||||||
DecrementNodes(VAbstractTool::data.GetPiecePath(id));
|
DecrementNodes(VAbstractTool::data.GetPiecePath(id));
|
||||||
}
|
}
|
||||||
HideNode();
|
HideNode();
|
||||||
QDomElement domElement = doc->elementById(id);
|
QDomElement domElement = doc->elementById(id, getTagName());
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::NotInUse);
|
doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::NotInUse);
|
||||||
|
|
|
@ -857,7 +857,7 @@ void VToolSeamAllowance::AddToFile()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolSeamAllowance::RefreshDataInFile()
|
void VToolSeamAllowance::RefreshDataInFile()
|
||||||
{
|
{
|
||||||
QDomElement domElement = doc->elementById(id);
|
QDomElement domElement = doc->elementById(id, getTagName());
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
// Refresh only parts that we possibly need to update
|
// Refresh only parts that we possibly need to update
|
||||||
|
|
|
@ -97,7 +97,7 @@ namespace
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VPiecePath GetPiecePath(int piece, VAbstractPattern *doc, quint32 id)
|
VPiecePath GetPiecePath(int piece, VAbstractPattern *doc, quint32 id)
|
||||||
{
|
{
|
||||||
const QDomElement tool = doc->elementById(id);
|
const QDomElement tool = doc->elementById(id, VAbstractPattern::TagTools);
|
||||||
if (tool.isNull())
|
if (tool.isNull())
|
||||||
{
|
{
|
||||||
VException e(QString("Can't get tool by id='%1'.").arg(id));
|
VException e(QString("Can't get tool by id='%1'.").arg(id));
|
||||||
|
@ -140,7 +140,7 @@ VPiecePath GetPiece2MainPath(VAbstractPattern *doc, quint32 id)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QVector<CustomSARecord> GetPiece2CSAPaths(VAbstractPattern *doc, quint32 id)
|
QVector<CustomSARecord> GetPiece2CSAPaths(VAbstractPattern *doc, quint32 id)
|
||||||
{
|
{
|
||||||
const QDomElement tool = doc->elementById(id);
|
const QDomElement tool = doc->elementById(id, VAbstractPattern::TagTools);
|
||||||
if (tool.isNull())
|
if (tool.isNull())
|
||||||
{
|
{
|
||||||
VException e(QString("Can't get tool by id='%1'.").arg(id));
|
VException e(QString("Can't get tool by id='%1'.").arg(id));
|
||||||
|
@ -171,7 +171,7 @@ QVector<CustomSARecord> GetPiece2CSAPaths(VAbstractPattern *doc, quint32 id)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QVector<quint32> GetPiece2InternalPaths(VAbstractPattern *doc, quint32 id)
|
QVector<quint32> GetPiece2InternalPaths(VAbstractPattern *doc, quint32 id)
|
||||||
{
|
{
|
||||||
const QDomElement tool = doc->elementById(id);
|
const QDomElement tool = doc->elementById(id, VAbstractPattern::TagTools);
|
||||||
if (tool.isNull())
|
if (tool.isNull())
|
||||||
{
|
{
|
||||||
VException e(QString("Can't get tool by id='%1'.").arg(id));
|
VException e(QString("Can't get tool by id='%1'.").arg(id));
|
||||||
|
@ -202,7 +202,7 @@ QVector<quint32> GetPiece2InternalPaths(VAbstractPattern *doc, quint32 id)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QVector<quint32> GetPiece2Pins(VAbstractPattern *doc, quint32 id)
|
QVector<quint32> GetPiece2Pins(VAbstractPattern *doc, quint32 id)
|
||||||
{
|
{
|
||||||
const QDomElement tool = doc->elementById(id);
|
const QDomElement tool = doc->elementById(id, VAbstractPattern::TagTools);
|
||||||
if (tool.isNull())
|
if (tool.isNull())
|
||||||
{
|
{
|
||||||
VException e(QString("Can't get tool by id='%1'.").arg(id));
|
VException e(QString("Can't get tool by id='%1'.").arg(id));
|
||||||
|
@ -233,13 +233,13 @@ QVector<quint32> GetPiece2Pins(VAbstractPattern *doc, quint32 id)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString DrawName(VAbstractPattern *doc, quint32 d1id, quint32 d2id)
|
QString DrawName(VAbstractPattern *doc, quint32 d1id, quint32 d2id)
|
||||||
{
|
{
|
||||||
const QDomElement detail1 = doc->elementById(d1id);
|
const QDomElement detail1 = doc->elementById(d1id, VAbstractPattern::TagDetail);
|
||||||
if (detail1.isNull())
|
if (detail1.isNull())
|
||||||
{
|
{
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QDomElement detail2 = doc->elementById(d2id);
|
const QDomElement detail2 = doc->elementById(d2id, VAbstractPattern::TagDetail);
|
||||||
if (detail2.isNull())
|
if (detail2.isNull())
|
||||||
{
|
{
|
||||||
return QString();
|
return QString();
|
||||||
|
@ -656,7 +656,7 @@ void FindIndexJ(qint32 pointsD2, const VPiecePath &d2Path, quint32 indexD2, qint
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QDomElement GetTagChildren(VAbstractPattern *doc, quint32 id)
|
QDomElement GetTagChildren(VAbstractPattern *doc, quint32 id)
|
||||||
{
|
{
|
||||||
QDomElement toolUnion = doc->elementById(id);
|
QDomElement toolUnion = doc->elementById(id, VAbstractPattern::TagTools);
|
||||||
if (toolUnion.isNull())
|
if (toolUnion.isNull())
|
||||||
{
|
{
|
||||||
VException e(QString("Can't get tool by id='%1'.").arg(id));
|
VException e(QString("Can't get tool by id='%1'.").arg(id));
|
||||||
|
@ -717,7 +717,7 @@ void SavePinsChildren(VAbstractPattern *doc, quint32 id, const QVector<quint32>
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QVector<quint32> GetChildren(VAbstractPattern *doc, quint32 id, const QString &tagName)
|
QVector<quint32> GetChildren(VAbstractPattern *doc, quint32 id, const QString &tagName)
|
||||||
{
|
{
|
||||||
const QDomElement toolUnion = doc->elementById(id);
|
const QDomElement toolUnion = doc->elementById(id, VAbstractPattern::TagTools);
|
||||||
if (toolUnion.isNull())
|
if (toolUnion.isNull())
|
||||||
{
|
{
|
||||||
return QVector<quint32>();
|
return QVector<quint32>();
|
||||||
|
@ -1390,7 +1390,7 @@ void VToolUnionDetails::incrementReferens()
|
||||||
doc->IncrementReferens(objects.at(i));
|
doc->IncrementReferens(objects.at(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement domElement = doc->elementById(id);
|
QDomElement domElement = doc->elementById(id, getTagName());
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::InUse);
|
doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::InUse);
|
||||||
|
@ -1410,7 +1410,7 @@ void VToolUnionDetails::decrementReferens()
|
||||||
doc->DecrementReferens(objects.at(i));
|
doc->DecrementReferens(objects.at(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement domElement = doc->elementById(id);
|
QDomElement domElement = doc->elementById(id, getTagName());
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::NotInUse);
|
doc->SetParametrUsage(domElement, AttrInUse, NodeUsage::NotInUse);
|
||||||
|
@ -1558,7 +1558,7 @@ void VToolUnionDetails::AddToModeling(const QDomElement &domElement)
|
||||||
QVector<quint32> VToolUnionDetails::GetReferenceObjects() const
|
QVector<quint32> VToolUnionDetails::GetReferenceObjects() const
|
||||||
{
|
{
|
||||||
QVector<quint32> list;
|
QVector<quint32> list;
|
||||||
const QDomElement tool = doc->elementById(id);
|
const QDomElement tool = doc->elementById(id, getTagName());
|
||||||
if (tool.isNull())
|
if (tool.isNull())
|
||||||
{
|
{
|
||||||
return list;
|
return list;
|
||||||
|
|
|
@ -61,7 +61,7 @@ void AddGroup::undo()
|
||||||
QDomElement groups = doc->CreateGroups();
|
QDomElement groups = doc->CreateGroups();
|
||||||
if (not groups.isNull())
|
if (not groups.isNull())
|
||||||
{
|
{
|
||||||
QDomElement group = doc->elementById(nodeId);
|
QDomElement group = doc->elementById(nodeId, VAbstractPattern::TagGroup);
|
||||||
if (group.isElement())
|
if (group.isElement())
|
||||||
{
|
{
|
||||||
group.setAttribute(VAbstractPattern::AttrVisible, trueStr);
|
group.setAttribute(VAbstractPattern::AttrVisible, trueStr);
|
||||||
|
|
|
@ -53,7 +53,7 @@ void AddPiece::undo()
|
||||||
QDomElement details = GetDetailsSection();
|
QDomElement details = GetDetailsSection();
|
||||||
if (not details.isNull())
|
if (not details.isNull())
|
||||||
{
|
{
|
||||||
QDomElement domElement = doc->elementById(nodeId);
|
QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagDetail);
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
if (details.removeChild(domElement).isNull())
|
if (details.removeChild(domElement).isNull())
|
||||||
|
|
|
@ -50,7 +50,7 @@ DeletePiece::DeletePiece(VAbstractPattern *doc, quint32 id, const VPiece &detail
|
||||||
{
|
{
|
||||||
setText(tr("delete tool"));
|
setText(tr("delete tool"));
|
||||||
nodeId = id;
|
nodeId = id;
|
||||||
QDomElement domElement = doc->elementById(id);
|
QDomElement domElement = doc->elementById(id, VAbstractPattern::TagDetail);
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
xml = domElement.cloneNode().toElement();
|
xml = domElement.cloneNode().toElement();
|
||||||
|
@ -91,7 +91,7 @@ void DeletePiece::redo()
|
||||||
{
|
{
|
||||||
qCDebug(vUndo, "Redo.");
|
qCDebug(vUndo, "Redo.");
|
||||||
|
|
||||||
QDomElement domElement = doc->elementById(nodeId);
|
QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagDetail);
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
m_parentNode.removeChild(domElement);
|
m_parentNode.removeChild(domElement);
|
||||||
|
|
|
@ -86,7 +86,7 @@ void DelGroup::redo()
|
||||||
QDomElement groups = doc->CreateGroups();
|
QDomElement groups = doc->CreateGroups();
|
||||||
if (not groups.isNull())
|
if (not groups.isNull())
|
||||||
{
|
{
|
||||||
QDomElement group = doc->elementById(nodeId);
|
QDomElement group = doc->elementById(nodeId, VAbstractPattern::TagGroup);
|
||||||
if (group.isElement())
|
if (group.isElement())
|
||||||
{
|
{
|
||||||
group.setAttribute(VAbstractPattern::AttrVisible, trueStr);
|
group.setAttribute(VAbstractPattern::AttrVisible, trueStr);
|
||||||
|
|
|
@ -54,7 +54,7 @@ MoveDoubleLabel::MoveDoubleLabel(VAbstractPattern *doc, const double &x, const d
|
||||||
setText(tr("move the second dart label"));
|
setText(tr("move the second dart label"));
|
||||||
}
|
}
|
||||||
|
|
||||||
const QDomElement domElement = doc->elementById(m_idTool);
|
const QDomElement domElement = doc->elementById(m_idTool, VAbstractPattern::TagPoint);
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
if (type == DoublePoint::FirstPoint)
|
if (type == DoublePoint::FirstPoint)
|
||||||
|
@ -134,7 +134,7 @@ void MoveDoubleLabel::Do(double mx, double my)
|
||||||
qCDebug(vUndo, "New my2 %f", my);
|
qCDebug(vUndo, "New my2 %f", my);
|
||||||
}
|
}
|
||||||
|
|
||||||
QDomElement domElement = doc->elementById(m_idTool);
|
QDomElement domElement = doc->elementById(m_idTool, VAbstractPattern::TagPoint);
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
if (m_type == DoublePoint::FirstPoint)
|
if (m_type == DoublePoint::FirstPoint)
|
||||||
|
|
|
@ -44,7 +44,7 @@ MoveLabel::MoveLabel(VAbstractPattern *doc, const double &x, const double &y, co
|
||||||
{
|
{
|
||||||
setText(tr("move point label"));
|
setText(tr("move point label"));
|
||||||
|
|
||||||
QDomElement domElement = doc->elementById(nodeId);
|
QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagPoint);
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
m_oldMx = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMx, "0.0"));
|
m_oldMx = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMx, "0.0"));
|
||||||
|
@ -95,7 +95,7 @@ void MoveLabel::Do(double mx, double my)
|
||||||
qCDebug(vUndo, "New mx %f", mx);
|
qCDebug(vUndo, "New mx %f", mx);
|
||||||
qCDebug(vUndo, "New my %f", my);
|
qCDebug(vUndo, "New my %f", my);
|
||||||
|
|
||||||
QDomElement domElement = doc->elementById(nodeId);
|
QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagPoint);
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
doc->SetAttribute(domElement, AttrMx, QString().setNum(qApp->fromPixel(mx)));
|
doc->SetAttribute(domElement, AttrMx, QString().setNum(qApp->fromPixel(mx)));
|
||||||
|
|
|
@ -118,7 +118,7 @@ void OperationMoveLabel::Do(double mx, double my)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QDomElement OperationMoveLabel::GetDestinationObject(quint32 idTool, quint32 idPoint) const
|
QDomElement OperationMoveLabel::GetDestinationObject(quint32 idTool, quint32 idPoint) const
|
||||||
{
|
{
|
||||||
const QDomElement tool = doc->elementById(idTool);
|
const QDomElement tool = doc->elementById(idTool, VAbstractPattern::TagOperation);
|
||||||
if (tool.isElement())
|
if (tool.isElement())
|
||||||
{
|
{
|
||||||
QDomElement correctDest;
|
QDomElement correctDest;
|
||||||
|
|
|
@ -52,7 +52,7 @@ MovePiece::MovePiece(VAbstractPattern *doc, const double &x, const double &y, co
|
||||||
nodeId = id;
|
nodeId = id;
|
||||||
|
|
||||||
SCASSERT(scene != nullptr)
|
SCASSERT(scene != nullptr)
|
||||||
QDomElement domElement = doc->elementById(id);
|
QDomElement domElement = doc->elementById(id, VAbstractPattern::TagDetail);
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
m_oldX = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMx, "0.0"));
|
m_oldX = qApp->toPixel(doc->GetParametrDouble(domElement, AttrMx, "0.0"));
|
||||||
|
@ -74,7 +74,7 @@ void MovePiece::undo()
|
||||||
{
|
{
|
||||||
qCDebug(vUndo, "Undo.");
|
qCDebug(vUndo, "Undo.");
|
||||||
|
|
||||||
QDomElement domElement = doc->elementById(nodeId);
|
QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagDetail);
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
SaveCoordinates(domElement, m_oldX, m_oldY);
|
SaveCoordinates(domElement, m_oldX, m_oldY);
|
||||||
|
@ -93,7 +93,7 @@ void MovePiece::redo()
|
||||||
{
|
{
|
||||||
qCDebug(vUndo, "Redo.");
|
qCDebug(vUndo, "Redo.");
|
||||||
|
|
||||||
QDomElement domElement = doc->elementById(nodeId);
|
QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagDetail);
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
SaveCoordinates(domElement, m_newX, m_newY);
|
SaveCoordinates(domElement, m_newX, m_newY);
|
||||||
|
|
|
@ -101,7 +101,7 @@ int MoveSpline::id() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void MoveSpline::Do(const VSpline &spl)
|
void MoveSpline::Do(const VSpline &spl)
|
||||||
{
|
{
|
||||||
QDomElement domElement = doc->elementById(nodeId);
|
QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagSpline);
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
doc->SetAttribute(domElement, AttrPoint1, spl.GetP1().id());
|
doc->SetAttribute(domElement, AttrPoint1, spl.GetP1().id());
|
||||||
|
|
|
@ -100,7 +100,7 @@ int MoveSplinePath::id() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void MoveSplinePath::Do(const VSplinePath &splPath)
|
void MoveSplinePath::Do(const VSplinePath &splPath)
|
||||||
{
|
{
|
||||||
QDomElement domElement = doc->elementById(nodeId);
|
QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagSpline);
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
VToolSplinePath::UpdatePathPoints(doc, domElement, splPath);
|
VToolSplinePath::UpdatePathPoints(doc, domElement, splPath);
|
||||||
|
|
|
@ -50,7 +50,7 @@ MoveSPoint::MoveSPoint(VAbstractPattern *doc, const double &x, const double &y,
|
||||||
qCDebug(vUndo, "SPoint newY %f", newY);
|
qCDebug(vUndo, "SPoint newY %f", newY);
|
||||||
|
|
||||||
SCASSERT(scene != nullptr)
|
SCASSERT(scene != nullptr)
|
||||||
QDomElement domElement = doc->elementById(id);
|
QDomElement domElement = doc->elementById(id, VAbstractPattern::TagPoint);
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
oldX = qApp->toPixel(doc->GetParametrDouble(domElement, AttrX, "0.0"));
|
oldX = qApp->toPixel(doc->GetParametrDouble(domElement, AttrX, "0.0"));
|
||||||
|
@ -120,7 +120,7 @@ void MoveSPoint::Do(double x, double y)
|
||||||
qCDebug(vUndo, "Move to x %f", x);
|
qCDebug(vUndo, "Move to x %f", x);
|
||||||
qCDebug(vUndo, "Move to y %f", y);
|
qCDebug(vUndo, "Move to y %f", y);
|
||||||
|
|
||||||
QDomElement domElement = doc->elementById(nodeId);
|
QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagPoint);
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
doc->SetAttribute(domElement, AttrX, QString().setNum(qApp->fromPixel(x)));
|
doc->SetAttribute(domElement, AttrX, QString().setNum(qApp->fromPixel(x)));
|
||||||
|
|
|
@ -64,7 +64,7 @@ void SavePieceOptions::undo()
|
||||||
{
|
{
|
||||||
qCDebug(vUndo, "Undo.");
|
qCDebug(vUndo, "Undo.");
|
||||||
|
|
||||||
QDomElement domElement = doc->elementById(nodeId);
|
QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagDetail);
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
VToolSeamAllowance::AddAttributes(doc, domElement, nodeId, m_oldDet);
|
VToolSeamAllowance::AddAttributes(doc, domElement, nodeId, m_oldDet);
|
||||||
|
@ -95,7 +95,7 @@ void SavePieceOptions::redo()
|
||||||
{
|
{
|
||||||
qCDebug(vUndo, "Redo.");
|
qCDebug(vUndo, "Redo.");
|
||||||
|
|
||||||
QDomElement domElement = doc->elementById(nodeId);
|
QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagDetail);
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
VToolSeamAllowance::AddAttributes(doc, domElement, nodeId, m_newDet);
|
VToolSeamAllowance::AddAttributes(doc, domElement, nodeId, m_newDet);
|
||||||
|
|
|
@ -58,7 +58,7 @@ void SavePiecePathOptions::undo()
|
||||||
{
|
{
|
||||||
qCDebug(vUndo, "Undo.");
|
qCDebug(vUndo, "Undo.");
|
||||||
|
|
||||||
QDomElement domElement = doc->elementById(nodeId);
|
QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagPath);
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
VToolPiecePath::AddAttributes(doc, domElement, nodeId, m_oldPath);
|
VToolPiecePath::AddAttributes(doc, domElement, nodeId, m_oldPath);
|
||||||
|
@ -82,7 +82,7 @@ void SavePiecePathOptions::redo()
|
||||||
{
|
{
|
||||||
qCDebug(vUndo, "Redo.");
|
qCDebug(vUndo, "Redo.");
|
||||||
|
|
||||||
QDomElement domElement = doc->elementById(nodeId);
|
QDomElement domElement = doc->elementById(nodeId, VAbstractPattern::TagPath);
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
VToolPiecePath::AddAttributes(doc, domElement, nodeId, m_newPath);
|
VToolPiecePath::AddAttributes(doc, domElement, nodeId, m_newPath);
|
||||||
|
|
|
@ -101,7 +101,7 @@ bool TogglePieceInLayout::getNewState() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void TogglePieceInLayout::Do(bool state)
|
void TogglePieceInLayout::Do(bool state)
|
||||||
{
|
{
|
||||||
QDomElement detail = doc->elementById(m_id);
|
QDomElement detail = doc->elementById(m_id, VAbstractPattern::TagDetail);
|
||||||
if (detail.isElement())
|
if (detail.isElement())
|
||||||
{
|
{
|
||||||
if (state == false)
|
if (state == false)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user