55 #include <QDomNodeList>
58 #include <QLatin1String>
62 #include <QStaticStringData>
63 #include <QStringData>
64 #include <QStringDataPtr>
66 #include "../exception/vexception.h"
67 #include "../vmisc/def.h"
100 return QStringLiteral(
"://schema/standard_measurements/v0.3.0.xsd");
102 return QStringLiteral(
"://schema/standard_measurements/v0.4.0.xsd");
104 return QStringLiteral(
"://schema/standard_measurements/v0.4.1.xsd");
106 return QStringLiteral(
"://schema/standard_measurements/v0.4.2.xsd");
108 return QStringLiteral(
"://schema/standard_measurements/v0.4.3.xsd");
163 "Check attribute read-only.");
177 "Time to refactor the code.");
179 QDomElement rootElement = this->documentElement();
180 QDomNode refChild = rootElement.firstChildElement(
"version");
183 QDomElement ro = createElement(QStringLiteral(
"read-only"));
184 const QDomText roNodeText = createTextNode(
"false");
185 ro.appendChild(roNodeText);
186 refChild = rootElement.insertAfter(ro, refChild);
190 QDomElement notes = createElement(QStringLiteral(
"notes"));
191 const QDomText nodeText = createTextNode(
UniqueTagText(QStringLiteral(
"description")));
192 notes.appendChild(nodeText);
193 rootElement.insertAfter(notes, refChild);
202 "Time to refactor the code.");
204 QDomElement rootElement = this->documentElement();
207 const QDomNodeList nodeList = this->elementsByTagName(QStringLiteral(
"description"));
208 if (not nodeList.isEmpty())
210 rootElement.removeChild(nodeList.at(0));
215 const QDomNodeList nodeList = this->elementsByTagName(QStringLiteral(
"id"));
216 if (not nodeList.isEmpty())
218 rootElement.removeChild(nodeList.at(0));
228 "Time to refactor the code.");
230 const QString tagBM = QStringLiteral(
"body-measurements");
232 QDomElement bm = createElement(tagBM);
236 for (
int i = 0; i < keys.size(); ++i)
239 qreal resSizeIncrease = 0;
240 qreal resHeightIncrease = 0;
244 foreach(
const QString &val, list )
246 const QDomNodeList nodeList = this->elementsByTagName(val);
247 if (nodeList.isEmpty())
252 QDomElement m = nodeList.at(0).toElement();
254 const qreal size_increase =
GetParametrDouble(m, QStringLiteral(
"size_increase"),
"0.0");
255 const qreal height_increase =
GetParametrDouble(m, QStringLiteral(
"height_increase"),
"0.0");
257 if (not qFuzzyIsNull(value))
260 resSizeIncrease = size_increase;
261 resHeightIncrease = height_increase;
265 bm.appendChild(
AddMV0_4_0(keys.at(i), resValue, resSizeIncrease, resHeightIncrease));
268 QDomElement rootElement = this->documentElement();
269 const QDomNodeList listBM = elementsByTagName(tagBM);
270 rootElement.replaceChild(bm, listBM.at(0));
278 "Time to refactor the code.");
280 QDomElement element = createElement(QStringLiteral(
"m"));
283 SetAttribute(element, QStringLiteral(
"base"), QString().setNum(value));
284 SetAttribute(element, QStringLiteral(
"size_increase"), QString().setNum(sizeIncrease));
285 SetAttribute(element, QStringLiteral(
"height_increase"), QString().setNum(heightIncrease));
286 SetAttribute(element, QStringLiteral(
"description"), QString(
""));
287 SetAttribute(element, QStringLiteral(
"full_name"), QString(
""));
297 "Time to refactor the code.");
299 QDomElement pm_system = createElement(QStringLiteral(
"pm_system"));
300 pm_system.appendChild(createTextNode(QStringLiteral(
"998")));
302 const QDomNodeList nodeList = this->elementsByTagName(QStringLiteral(
"size"));
303 QDomElement personal = nodeList.at(0).toElement();
305 QDomElement parent = personal.parentNode().toElement();
306 parent.insertBefore(pm_system, personal);
314 "Time to refactor the code.");
317 auto i = names.constBegin();
318 while (i != names.constEnd())
320 const QDomNodeList nodeList = this->elementsByTagName(QStringLiteral(
"m"));
321 if (nodeList.isEmpty())
327 for (
int ii = 0; ii < nodeList.size(); ++ii)
329 const QString attrName = QStringLiteral(
"name");
330 QDomElement element = nodeList.at(ii).toElement();
332 if (name == i.value())
347 "Time to refactor the code.");
362 "Time to refactor the code.");
374 "Time to refactor the code.");
386 "Time to refactor the code.");
397 "Time to refactor the code.");
void SetVersion(const QString &version)
Q_NORETURN void InvalidVersion(int ver) const
void ValidateInputFile(const QString ¤tSchema) const
QString m_convertedFileName
static QMap< QString, QString > OldNamesToNewNames_InV0_3_3()
static QMultiMap< QString, QString > OldNamesToNewNames_InV0_3_0()
static QString GetParametrString(const QDomElement &domElement, const QString &name, const QString &defValue=QString())
Returns the string value of the given attribute. RENAME: see above.
static void ValidateXML(const QString &schema, const QString &fileName)
ValidateXML validate xml file by xsd schema.
static qreal GetParametrDouble(const QDomElement &domElement, const QString &name, const QString &defValue)
Returns the double value of the given attribute.
QString UniqueTagText(const QString &tagName, const QString &defVal=QString()) const
void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const
SetAttribute set attribute in pattern file. Replace "," by ".".
static const QString MeasurementMaxVerStr
static Q_DECL_CONSTEXPR const int MeasurementMaxVer
virtual void DowngradeToCurrentMaxVersion() Q_DECL_OVERRIDE
static Q_DECL_CONSTEXPR const int MeasurementMinVer
virtual bool IsReadOnly() const Q_DECL_OVERRIDE
static const QString CurrentSchema
QDomElement AddMV0_4_0(const QString &name, qreal value, qreal sizeIncrease, qreal heightIncrease)
VVSTConverter(const QString &fileName)
void ConvertMeasurementsToV0_4_0()
void RemoveTagsForV0_4_0()
void AddNewTagsForV0_4_0()
void ConvertMeasurementsToV0_4_2()
virtual void ApplyPatches() Q_DECL_OVERRIDE
static const QString MeasurementMinVerStr
virtual QString XSDSchema(int ver) const Q_DECL_OVERRIDE
#define CONVERTER_VERSION_CHECK(major, minor, patch)
static const QString strTagRead_Only