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