Little fixes
--HG-- branch : feature
This commit is contained in:
parent
55a2da02cc
commit
ebab22d6ca
|
@ -172,18 +172,18 @@ void VPattern::Parse(const Document &parse)
|
|||
case 4: // TagNotes
|
||||
qCDebug(vXML, "Tag notes.");
|
||||
break;
|
||||
case 5: // TagImage
|
||||
qCDebug(vXML, "Tag image.");
|
||||
break;
|
||||
case 6: // TagMeasurements
|
||||
case 5: // TagMeasurements
|
||||
qCDebug(vXML, "Tag measurements.");
|
||||
break;
|
||||
case 7: // TagVersion
|
||||
case 6: // TagVersion
|
||||
qCDebug(vXML, "Tag version.");
|
||||
break;
|
||||
case 8: // TagGradation
|
||||
case 7: // TagGradation
|
||||
qCDebug(vXML, "Tag gradation.");
|
||||
break;
|
||||
case 8: // TagImage
|
||||
qCDebug(vXML, "Tag image.");
|
||||
break;
|
||||
case 9: // TagUnit
|
||||
qCDebug(vXML, "Tag unit.");
|
||||
break;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
<xs:complexType>
|
||||
<xs:sequence minOccurs="1" maxOccurs="unbounded">
|
||||
<xs:element name="version" type="formatVersion"></xs:element>
|
||||
<xs:element name="unit" type="units"></xs:element>
|
||||
<xs:element name="image" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:simpleContent>
|
||||
|
@ -14,7 +15,6 @@
|
|||
</xs:simpleContent>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="unit" type="units"></xs:element>
|
||||
<xs:element name="author" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
|
||||
<xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
|
||||
<xs:element name="notes" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
|
||||
|
|
|
@ -100,6 +100,7 @@ const QString VAbstractPattern::AttrS56 = QStringLiteral("s56");
|
|||
const QString VAbstractPattern::AttrCustom = QStringLiteral("custom");
|
||||
const QString VAbstractPattern::AttrDefHeight = QStringLiteral("defHeight");
|
||||
const QString VAbstractPattern::AttrDefSize = QStringLiteral("defSize");
|
||||
const QString VAbstractPattern::AttrExtension = QStringLiteral("extension");
|
||||
|
||||
const QString VAbstractPattern::IncrementName = QStringLiteral("name");
|
||||
const QString VAbstractPattern::IncrementFormula = QStringLiteral("formula");
|
||||
|
@ -926,7 +927,7 @@ QString VAbstractPattern::GetImage() const
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VAbstractPattern::GetImageExtension() const
|
||||
{
|
||||
const QString defExt = "PNG";
|
||||
const QString defExt = QStringLiteral("PNG");
|
||||
const QDomNodeList nodeList = this->elementsByTagName(TagImage);
|
||||
if (nodeList.isEmpty())
|
||||
{
|
||||
|
@ -940,15 +941,8 @@ QString VAbstractPattern::GetImageExtension() const
|
|||
const QDomElement domElement = domNode.toElement();
|
||||
if (domElement.isNull() == false)
|
||||
{
|
||||
const QString ext = domElement.attribute(QString("extension"), "");
|
||||
if (ext.isEmpty())
|
||||
{
|
||||
return defExt;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ext;
|
||||
}
|
||||
const QString ext = domElement.attribute(AttrExtension, defExt);
|
||||
return ext;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -964,7 +958,7 @@ void VAbstractPattern::SetImage(const QString &text, const QString &extension)
|
|||
for (int i=0; i < list.size(); ++i)
|
||||
{
|
||||
QDomElement dom = list.at(i).toElement();
|
||||
dom.setAttribute(QString("extension"), extension);
|
||||
dom.setAttribute(AttrExtension, extension);
|
||||
}
|
||||
modified = true;
|
||||
emit patternChanged(false);
|
||||
|
@ -1056,49 +1050,30 @@ void VAbstractPattern::CheckTagExists(const QString &tag)
|
|||
QDomNodeList list = elementsByTagName(tag);
|
||||
if (list.size() == 0)
|
||||
{
|
||||
QStringList tags = QStringList() << TagVersion << TagImage << TagAuthor << TagDescription << TagNotes
|
||||
const QStringList tags = QStringList() << TagUnit << TagImage << TagAuthor << TagDescription << TagNotes
|
||||
<< TagGradation;
|
||||
QDomElement pattern = documentElement();
|
||||
switch (tags.indexOf(tag))
|
||||
{
|
||||
case 0: //TagVersion
|
||||
case 0: //TagUnit
|
||||
break;// Mandatory tag
|
||||
case 1: //TagImage
|
||||
{
|
||||
pattern.insertAfter(createElement(TagImage), elementsByTagName(TagVersion).at(0));
|
||||
SetVersion();
|
||||
InsertTag(tags, createElement(TagImage));
|
||||
break;
|
||||
}
|
||||
case 2: //TagAuthor
|
||||
pattern.insertAfter(createElement(TagAuthor), elementsByTagName(TagVersion).at(0));
|
||||
SetVersion();
|
||||
{
|
||||
InsertTag(tags, createElement(TagAuthor));
|
||||
break;
|
||||
}
|
||||
case 3: //TagDescription
|
||||
{
|
||||
for (int i = tags.indexOf(tag)-1; i >= 0; --i)
|
||||
{
|
||||
QDomNodeList list = elementsByTagName(tags.at(i));
|
||||
if (list.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
pattern.insertAfter(createElement(TagDescription), list.at(0));
|
||||
}
|
||||
SetVersion();
|
||||
InsertTag(tags, createElement(TagDescription));
|
||||
break;
|
||||
}
|
||||
case 4: //TagNotes
|
||||
{
|
||||
for (int i = tags.indexOf(tag)-1; i >= 0; --i)
|
||||
{
|
||||
QDomNodeList list = elementsByTagName(tags.at(i));
|
||||
if (list.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
pattern.insertAfter(createElement(TagNotes), list.at(0));
|
||||
}
|
||||
SetVersion();
|
||||
InsertTag(tags, createElement(TagNotes));
|
||||
break;
|
||||
}
|
||||
case 5: //TagGradation
|
||||
|
@ -1113,17 +1088,7 @@ void VAbstractPattern::CheckTagExists(const QString &tag)
|
|||
sizes.setAttribute(AttrAll, QLatin1Literal("true"));
|
||||
gradation.appendChild(sizes);
|
||||
|
||||
for (int i = tags.indexOf(tag)-1; i >= 0; --i)
|
||||
{
|
||||
QDomNodeList list = elementsByTagName(tags.at(i));
|
||||
if (list.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
pattern.insertAfter(gradation, list.at(0));
|
||||
break;
|
||||
}
|
||||
SetVersion();
|
||||
InsertTag(tags, gradation);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -1132,6 +1097,23 @@ void VAbstractPattern::CheckTagExists(const QString &tag)
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractPattern::InsertTag(QStringList tags, QDomElement element)
|
||||
{
|
||||
QDomElement pattern = documentElement();
|
||||
for (int i = tags.indexOf(element.tagName())-1; i >= 0; --i)
|
||||
{
|
||||
QDomNodeList list = elementsByTagName(tags.at(i));
|
||||
if (list.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
pattern.insertAfter(element, list.at(0));
|
||||
return;
|
||||
}
|
||||
SetVersion();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QStringList VAbstractPattern::ListIncrements() const
|
||||
{
|
||||
|
|
|
@ -187,6 +187,7 @@ public:
|
|||
static const QString AttrCustom;
|
||||
static const QString AttrDefHeight;
|
||||
static const QString AttrDefSize;
|
||||
static const QString AttrExtension;
|
||||
|
||||
static const QString IncrementName;
|
||||
static const QString IncrementFormula;
|
||||
|
@ -264,6 +265,7 @@ protected:
|
|||
void SetActivPP(const QString& name);
|
||||
|
||||
void CheckTagExists(const QString &tag);
|
||||
void InsertTag(QStringList tags, QDomElement element);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VAbstractPattern)
|
||||
|
|
Loading…
Reference in New Issue
Block a user