Improve performance. Calling method RefreshDataInFile() slows down parsing.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-08-02 11:34:44 +03:00
parent 0894f686ef
commit ca66c8ebe2
27 changed files with 9 additions and 194 deletions

View File

@ -198,7 +198,7 @@ QDomElement VDomDocument::elementById(const QString& id)
{
if (map.contains(id))
{
QDomElement e = map[id];
const QDomElement e = map[id];
if (e.parentNode().nodeType() != QDomNode::BaseNode)
{
return e;
@ -241,7 +241,7 @@ bool VDomDocument::find(const QDomElement &node, const QString& id)
for (qint32 i=0; i<node.childNodes().length(); ++i)
{
QDomNode n = node.childNodes().at(i);
const QDomNode n = node.childNodes().at(i);
if (n.isElement())
{
if (this->find(n.toElement(), id))

View File

@ -425,21 +425,6 @@ void VAbstractOperation::AddToFile()
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::RefreshDataInFile()
{
QDomElement domElement = doc->elementById(id);
if (domElement.isElement())
{
QSharedPointer<VGObject> obj = VContainer::GetFakeGObject(id);
SaveOptions(domElement, obj);
}
else
{
qCDebug(vTool, "Can't find tool with id = %u", id);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::UpdateNamePosition(quint32 id)
{

View File

@ -118,7 +118,6 @@ protected:
QGraphicsItem *parent = nullptr);
virtual void AddToFile() Q_DECL_OVERRIDE;
virtual void RefreshDataInFile() Q_DECL_OVERRIDE;
void UpdateNamePosition(quint32 id);
void SaveSourceDestination(QDomElement &tag);

View File

@ -363,18 +363,3 @@ void VToolDoublePoint::AddToFile()
SaveOptions(domElement, obj);
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolDoublePoint::RefreshDataInFile()
{
QDomElement domElement = doc->elementById(id);
if (domElement.isElement())
{
QSharedPointer<VGObject> obj = VContainer::GetFakeGObject(id);
SaveOptions(domElement, obj);
}
else
{
qCDebug(vTool, "Can't find tool with id = %u", id);
}
}

View File

@ -93,7 +93,6 @@ protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
virtual void AddToFile() Q_DECL_OVERRIDE;
virtual void RefreshDataInFile() Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VToolDoublePoint)

View File

@ -134,24 +134,6 @@ void VDrawTool::AddToFile()
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VDrawTool::RefreshDataInFile()
{
QDomElement domElement = doc->elementById(id);
if (domElement.isElement())
{
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOptions(domElement, obj);
}
else
{
qCDebug(vTool, "Can't find tool with id = %u", id);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VDrawTool::SaveOption(QSharedPointer<VGObject> &obj)
{

View File

@ -93,7 +93,6 @@ protected:
virtual void SaveDialog(QDomElement &domElement)=0;
virtual void SaveDialogChange() Q_DECL_FINAL;
virtual void AddToFile() Q_DECL_OVERRIDE;
virtual void RefreshDataInFile() Q_DECL_OVERRIDE;
void SaveOption(QSharedPointer<VGObject> &obj);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);

View File

@ -287,24 +287,6 @@ void VToolLine::AddToFile()
AddToCalculation(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolLine::RefreshDataInFile()
{
QDomElement domElement = doc->elementById(id);
if (domElement.isElement())
{
QSharedPointer<VGObject> obj = QSharedPointer<VGObject> ();
SaveOptions(domElement, obj);
}
else
{
qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO;
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverEnterEvent handle hover enter events.

View File

@ -92,7 +92,6 @@ public slots:
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
virtual void AddToFile() Q_DECL_OVERRIDE;
virtual void RefreshDataInFile() Q_DECL_OVERRIDE;
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
virtual void RemoveReferens() Q_DECL_OVERRIDE;

View File

@ -136,20 +136,3 @@ void VNodeArc::AddToFile()
AddToModeling(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VNodeArc::RefreshDataInFile()
{
QDomElement domElement = doc->elementById(id);
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrIdObject, idNode);
if (idTool != NULL_ID)
{
doc->SetAttribute(domElement, AttrIdTool, idTool);
}
}
}

View File

@ -58,7 +58,6 @@ public slots:
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
protected:
virtual void AddToFile() Q_DECL_OVERRIDE;
virtual void RefreshDataInFile() Q_DECL_OVERRIDE;
virtual void ShowNode() Q_DECL_OVERRIDE {}
virtual void HideNode() Q_DECL_OVERRIDE {}
private:

View File

@ -107,20 +107,6 @@ void VNodeEllipticalArc::AddToFile()
AddToModeling(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeEllipticalArc::RefreshDataInFile()
{
QDomElement domElement = doc->elementById(id);
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrIdObject, idNode);
if (idTool != NULL_ID)
{
doc->SetAttribute(domElement, AttrIdTool, idTool);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
VNodeEllipticalArc::VNodeEllipticalArc(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc,
const Source &typeCreation, const QString &drawName, const quint32 &idTool,

View File

@ -56,7 +56,6 @@ public slots:
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
protected:
virtual void AddToFile() Q_DECL_OVERRIDE;
virtual void RefreshDataInFile() Q_DECL_OVERRIDE;
virtual void ShowNode() Q_DECL_OVERRIDE {}
virtual void HideNode() Q_DECL_OVERRIDE {}
private:

View File

@ -177,26 +177,6 @@ void VNodePoint::AddToFile()
AddToModeling(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VNodePoint::RefreshDataInFile()
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
QDomElement domElement = doc->elementById(id);
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrIdObject, idNode);
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my()));
if (idTool != NULL_ID)
{
doc->SetAttribute(domElement, AttrIdTool, idTool);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VNodePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
{

View File

@ -77,7 +77,6 @@ public slots:
void AllowLabelSelecting(bool enabled);
protected:
virtual void AddToFile() Q_DECL_OVERRIDE;
virtual void RefreshDataInFile() Q_DECL_OVERRIDE;
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
virtual void UpdateNamePosition(qreal mx, qreal my);

View File

@ -140,20 +140,3 @@ void VNodeSpline::AddToFile()
AddToModeling(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VNodeSpline::RefreshDataInFile()
{
QDomElement domElement = doc->elementById(id);
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrIdObject, QString().setNum(idNode));
if (idTool != NULL_ID)
{
doc->SetAttribute(domElement, AttrIdTool, idTool);
}
}
}

View File

@ -60,7 +60,6 @@ public slots:
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
protected:
virtual void AddToFile () Q_DECL_OVERRIDE;
virtual void RefreshDataInFile() Q_DECL_OVERRIDE;
virtual void ShowNode() Q_DECL_OVERRIDE {}
virtual void HideNode() Q_DECL_OVERRIDE {}
private:

View File

@ -138,20 +138,3 @@ void VNodeSplinePath::AddToFile()
AddToModeling(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VNodeSplinePath::RefreshDataInFile()
{
QDomElement domElement = doc->elementById(id);
if (domElement.isElement())
{
doc->SetAttribute(domElement, AttrIdObject, QString().setNum(idNode));
if (idTool != 0)
{
doc->SetAttribute(domElement, AttrIdTool, idTool);
}
}
}

View File

@ -59,7 +59,6 @@ public slots:
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
protected:
virtual void AddToFile() Q_DECL_OVERRIDE;
virtual void RefreshDataInFile() Q_DECL_OVERRIDE;
virtual void ShowNode() Q_DECL_OVERRIDE {}
virtual void HideNode() Q_DECL_OVERRIDE {}
private:

View File

@ -252,19 +252,6 @@ void VToolPiecePath::AddToFile()
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPiecePath::RefreshDataInFile()
{
QDomElement domElement = doc->elementById(id);
if (domElement.isElement())
{
if (idTool != NULL_ID)
{
doc->SetAttribute(domElement, AttrIdTool, idTool);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPiecePath::ShowNode()
{

View File

@ -63,7 +63,6 @@ public slots:
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
protected:
virtual void AddToFile() Q_DECL_OVERRIDE;
virtual void RefreshDataInFile() Q_DECL_OVERRIDE;
virtual void ShowNode() Q_DECL_OVERRIDE;
virtual void HideNode() Q_DECL_OVERRIDE;
virtual void ToolCreation(const Source &typeCreation) Q_DECL_OVERRIDE;

View File

@ -152,12 +152,6 @@ void VToolPin::AddToFile()
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPin::RefreshDataInFile()
{
// do nothing
}
//---------------------------------------------------------------------------------------------------------------------
VToolPin::VToolPin(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 pointId, quint32 pieceId,
const Source &typeCreation, const QString &drawName, const quint32 &idTool, QObject *qoParent)

View File

@ -52,7 +52,6 @@ public slots:
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
protected:
virtual void AddToFile() Q_DECL_OVERRIDE;
virtual void RefreshDataInFile() Q_DECL_OVERRIDE;
virtual void ShowNode() Q_DECL_OVERRIDE {}
virtual void HideNode() Q_DECL_OVERRIDE {}
private:

View File

@ -403,6 +403,12 @@ void VAbstractTool::ToolSelectionType(const SelectionType &type)
selectionType = type;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractTool::RefreshDataInFile()
{
// do nothing
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractTool::ToolCreation(const Source &typeCreation)
{

View File

@ -121,7 +121,7 @@ protected:
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
virtual void RefreshDataInFile()=0;
virtual void RefreshDataInFile();
/**
* @brief RemoveReferens decrement value of reference.
*/

View File

@ -1512,15 +1512,6 @@ void VToolUnionDetails::AddToFile()
AddToModeling(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them.
*/
void VToolUnionDetails::RefreshDataInFile()
{
// do nothing
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddDetail add detail to xml file.

View File

@ -111,7 +111,6 @@ public slots:
virtual void AllowSelecting(bool) Q_DECL_OVERRIDE {}
protected:
virtual void AddToFile() Q_DECL_OVERRIDE;
virtual void RefreshDataInFile() Q_DECL_OVERRIDE;
virtual void SetVisualization() Q_DECL_OVERRIDE {}
private:
Q_DISABLE_COPY(VToolUnionDetails)