List to speed up reading a template by many pieces.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-08-15 11:38:36 +03:00
parent 882cf360e2
commit 3b60eaff08
2 changed files with 14 additions and 4 deletions

View File

@ -194,6 +194,7 @@ const QString VAbstractPattern::NodeSpline = QStringLiteral("NodeSpline");
const QString VAbstractPattern::NodeSplinePath = QStringLiteral("NodeSplinePath");
QHash<quint32, VDataTool*> VAbstractPattern::tools = QHash<quint32, VDataTool*>();
QVector<VLabelTemplateLine> VAbstractPattern::patternLabelLines = QVector<VLabelTemplateLine>();
namespace
{
@ -1381,17 +1382,24 @@ void VAbstractPattern::SetPatternLabelTemplate(const QVector<VLabelTemplateLine>
QDomElement tag = CheckTagExists(TagPatternLabel);
RemoveAllChildren(tag);
SetLabelTemplate(tag, lines);
patternLabelLines = lines;
}
//---------------------------------------------------------------------------------------------------------------------
QVector<VLabelTemplateLine> VAbstractPattern::GetPatternLabelTemplate() const
{
if (patternLabelLines.isEmpty())
{
const QDomNodeList list = elementsByTagName(TagPatternLabel);
if (list.isEmpty())
{
return QVector<VLabelTemplateLine>();
}
return GetLabelTemplate(list.at(0).toElement());
patternLabelLines = GetLabelTemplate(list.at(0).toElement());
}
return patternLabelLines;
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -387,6 +387,8 @@ protected:
/** @brief tools list with pointer on tools. */
static QHash<quint32, VDataTool*> tools;
/** @brief patternLabelLines list to speed up reading a template by many pieces. */
static QVector<VLabelTemplateLine> patternLabelLines;
static void ToolExists(const quint32 &id);
static VPiecePath ParsePathNodes(const QDomElement &domElement);