Convert label width and height to pattern units.
--HG-- branch : feature
This commit is contained in:
parent
f48325cc52
commit
4f38a31f25
|
@ -119,6 +119,7 @@ static const QString strDetail = QStringLiteral("detail");
|
||||||
static const QString strSupplement = QStringLiteral("supplement");
|
static const QString strSupplement = QStringLiteral("supplement");
|
||||||
static const QString strClosed = QStringLiteral("closed");
|
static const QString strClosed = QStringLiteral("closed");
|
||||||
static const QString strWidth = QStringLiteral("width");
|
static const QString strWidth = QStringLiteral("width");
|
||||||
|
static const QString strHeight = QStringLiteral("height");
|
||||||
static const QString strNode = QStringLiteral("node");
|
static const QString strNode = QStringLiteral("node");
|
||||||
static const QString strNodes = QStringLiteral("nodes");
|
static const QString strNodes = QStringLiteral("nodes");
|
||||||
static const QString strData = QStringLiteral("data");
|
static const QString strData = QStringLiteral("data");
|
||||||
|
@ -669,6 +670,8 @@ void VPatternConverter::ToV0_4_4()
|
||||||
"Time to refactor the code.");
|
"Time to refactor the code.");
|
||||||
|
|
||||||
SetVersion(QStringLiteral("0.4.4"));
|
SetVersion(QStringLiteral("0.4.4"));
|
||||||
|
LabelTagToV0_4_4(strData);
|
||||||
|
LabelTagToV0_4_4(strPatternInfo);
|
||||||
Save();
|
Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1944,6 +1947,58 @@ QDomElement VPatternConverter::GetUnionChildrenNodesV0_4_0(const QDomElement &de
|
||||||
return tagNodes;
|
return tagNodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPatternConverter::LabelTagToV0_4_4(const QString &tagName)
|
||||||
|
{
|
||||||
|
// TODO. Delete if minimal supported version is 0.4.4
|
||||||
|
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 4, 4),
|
||||||
|
"Time to refactor the code.");
|
||||||
|
|
||||||
|
Unit unit = Unit::Cm;
|
||||||
|
const QStringList units = QStringList() << "mm" << "cm" << "inch";
|
||||||
|
switch (units.indexOf(UniqueTagText(strUnit)))
|
||||||
|
{
|
||||||
|
case 0:// mm
|
||||||
|
unit = Unit::Mm;
|
||||||
|
break;
|
||||||
|
case 1:// cm
|
||||||
|
unit = Unit::Cm;
|
||||||
|
break;
|
||||||
|
case 2:// in
|
||||||
|
unit = Unit::Inch;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto ConvertData = [unit](QDomElement &dom, const QString &attribute)
|
||||||
|
{
|
||||||
|
if (dom.hasAttribute(attribute))
|
||||||
|
{
|
||||||
|
QString valStr = dom.attribute(attribute, "1");
|
||||||
|
bool ok = false;
|
||||||
|
qreal val = valStr.toDouble(&ok);
|
||||||
|
if (not ok)
|
||||||
|
{
|
||||||
|
val = 1;
|
||||||
|
}
|
||||||
|
dom.setAttribute(attribute, QString().setNum(FromPixel(val, unit)));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const QDomNodeList list = elementsByTagName(tagName);
|
||||||
|
for (int i=0; i < list.size(); ++i)
|
||||||
|
{
|
||||||
|
QDomElement dom = list.at(i).toElement();
|
||||||
|
|
||||||
|
if (not dom.isNull())
|
||||||
|
{
|
||||||
|
ConvertData(dom, strWidth);
|
||||||
|
ConvertData(dom, strHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPatternConverter::TagUnionDetailsToV0_4_0()
|
void VPatternConverter::TagUnionDetailsToV0_4_0()
|
||||||
{
|
{
|
||||||
|
|
|
@ -146,6 +146,8 @@ private:
|
||||||
void TagUnionDetailsToV0_4_0();
|
void TagUnionDetailsToV0_4_0();
|
||||||
QDomElement GetUnionDetailNodesV0_4_0(const QDomElement &detail);
|
QDomElement GetUnionDetailNodesV0_4_0(const QDomElement &detail);
|
||||||
QDomElement GetUnionChildrenNodesV0_4_0(const QDomElement &detail);
|
QDomElement GetUnionChildrenNodesV0_4_0(const QDomElement &detail);
|
||||||
|
|
||||||
|
void LabelTagToV0_4_4(const QString &tagName);
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user