CheckTagExists returns QDomElement

--HG--
branch : feature
This commit is contained in:
Valentina Zhuravska 2016-04-06 05:31:42 +03:00
parent 9eeeb7baa8
commit de221559f3
2 changed files with 21 additions and 13 deletions

View File

@ -1045,56 +1045,64 @@ void VAbstractPattern::SetActivPP(const QString &name)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::CheckTagExists(const QString &tag) QDomElement VAbstractPattern::CheckTagExists(const QString &tag)
{ {
QDomNodeList list = elementsByTagName(tag); const QDomNodeList list = elementsByTagName(tag);
if (list.size() == 0) QDomElement element;
if (list.isEmpty())
{ {
const QStringList tags = QStringList() << TagUnit << TagImage << TagAuthor << TagDescription << TagNotes const QStringList tags = QStringList() << TagUnit << TagImage << TagAuthor << TagDescription << TagNotes
<< TagGradation; << TagGradation;
switch (tags.indexOf(tag)) switch (tags.indexOf(tag))
{ {
case 0: //TagUnit case 0: //TagUnit
{
return QDomElement();
break;// Mandatory tag break;// Mandatory tag
}
case 1: //TagImage case 1: //TagImage
{ {
InsertTag(tags, createElement(TagImage)); element = createElement(TagImage);
break; break;
} }
case 2: //TagAuthor case 2: //TagAuthor
{ {
InsertTag(tags, createElement(TagAuthor)); element = createElement(TagAuthor);
break; break;
} }
case 3: //TagDescription case 3: //TagDescription
{ {
InsertTag(tags, createElement(TagDescription)); element = createElement(TagDescription);
break; break;
} }
case 4: //TagNotes case 4: //TagNotes
{ {
InsertTag(tags, createElement(TagNotes)); element = createElement(TagNotes);
break; break;
} }
case 5: //TagGradation case 5: //TagGradation
{ {
QDomElement gradation = createElement(TagGradation); element = createElement(TagGradation);
QDomElement heights = createElement(TagHeights); QDomElement heights = createElement(TagHeights);
heights.setAttribute(AttrAll, QLatin1Literal("true")); heights.setAttribute(AttrAll, QLatin1Literal("true"));
gradation.appendChild(heights); element.appendChild(heights);
QDomElement sizes = createElement(TagSizes); QDomElement sizes = createElement(TagSizes);
sizes.setAttribute(AttrAll, QLatin1Literal("true")); sizes.setAttribute(AttrAll, QLatin1Literal("true"));
gradation.appendChild(sizes); element.appendChild(sizes);
InsertTag(tags, gradation);
break; break;
} }
default: default:
{
return QDomElement();
break; break;
} }
} }
InsertTag(tags, element);
return element;
}
return list.at(0).toElement();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -264,7 +264,7 @@ protected:
void SetActivPP(const QString& name); void SetActivPP(const QString& name);
void CheckTagExists(const QString &tag); QDomElement CheckTagExists(const QString &tag);
void InsertTag(const QStringList &tags, const QDomElement &element); void InsertTag(const QStringList &tags, const QDomElement &element);
private: private: