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/individual_measurements/v0.2.0.xsd");
102 return QStringLiteral(
"://schema/individual_measurements/v0.3.0.xsd");
104 return QStringLiteral(
"://schema/individual_measurements/v0.3.1.xsd");
106 return QStringLiteral(
"://schema/individual_measurements/v0.3.2.xsd");
157 "Check attribute read-only.");
171 "Time to refactor the code.");
173 QDomElement rootElement = this->documentElement();
174 QDomNode refChild = rootElement.firstChildElement(
"version");
176 QDomElement ro = createElement(QStringLiteral(
"read-only"));
177 const QDomText roNodeText = createTextNode(
"false");
178 ro.appendChild(roNodeText);
179 refChild = rootElement.insertAfter(ro, refChild);
181 refChild = rootElement.insertAfter(createElement(QStringLiteral(
"notes")), refChild);
183 QDomElement unit = createElement(
"unit");
185 rootElement.insertAfter(unit, refChild);
193 "Time to refactor the code.");
195 return UniqueTagText(QStringLiteral(
"unit"), QStringLiteral(
"cm"));
203 "Time to refactor the code.");
205 const QString tagBM = QStringLiteral(
"body-measurements");
207 QDomElement bm = createElement(tagBM);
211 for (
int i = 0; i < keys.size(); ++i)
217 foreach(
const QString &val, list )
219 const QDomNodeList nodeList = this->elementsByTagName(val);
220 if (nodeList.isEmpty())
225 const qreal value =
GetParametrDouble(nodeList.at(0).toElement(), QStringLiteral(
"value"),
"0.0");
227 if (not qFuzzyIsNull(value))
233 bm.appendChild(
AddMV0_3_0(keys.at(i), resValue));
236 QDomElement rootElement = this->documentElement();
237 const QDomNodeList listBM = elementsByTagName(tagBM);
238 rootElement.replaceChild(bm, listBM.at(0));
246 "Time to refactor the code.");
248 QDomElement element = createElement(QStringLiteral(
"m"));
251 SetAttribute(element, QStringLiteral(
"value"), QString().setNum(value));
252 SetAttribute(element, QStringLiteral(
"description"), QString(
""));
253 SetAttribute(element, QStringLiteral(
"full_name"), QString(
""));
263 "Time to refactor the code.");
265 const QDomNodeList nodeList = this->elementsByTagName(QStringLiteral(
"sex"));
266 QDomElement sex = nodeList.at(0).toElement();
268 QDomElement gender = createElement(QStringLiteral(
"gender"));
269 gender.appendChild(createTextNode(sex.text()));
271 QDomElement parent = sex.parentNode().toElement();
272 parent.replaceChild(gender, sex);
280 "Time to refactor the code.");
282 QDomElement pm_system = createElement(QStringLiteral(
"pm_system"));
283 pm_system.appendChild(createTextNode(QStringLiteral(
"998")));
285 const QDomNodeList nodeList = this->elementsByTagName(QStringLiteral(
"personal"));
286 QDomElement personal = nodeList.at(0).toElement();
288 QDomElement parent = personal.parentNode().toElement();
289 parent.insertBefore(pm_system, personal);
297 "Time to refactor the code.");
300 auto i = names.constBegin();
301 while (i != names.constEnd())
303 const QDomNodeList nodeList = this->elementsByTagName(QStringLiteral(
"m"));
304 if (nodeList.isEmpty())
310 for (
int ii = 0; ii < nodeList.size(); ++ii)
312 const QString attrName = QStringLiteral(
"name");
313 QDomElement element = nodeList.at(ii).toElement();
315 if (name == i.value())
330 "Time to refactor the code.");
344 "Time to refactor the code.");
356 "Time to refactor the code.");
368 "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 ".".
virtual void DowngradeToCurrentMaxVersion() Q_DECL_OVERRIDE
static Q_DECL_CONSTEXPR const int MeasurementMinVer
void ConvertMeasurementsToV0_3_3()
virtual void ApplyPatches() Q_DECL_OVERRIDE
void AddNewTagsForV0_3_0()
static const QString MeasurementMaxVerStr
void ConvertMeasurementsToV0_3_0()
QDomElement AddMV0_3_0(const QString &name, qreal value)
virtual QString XSDSchema(int ver) const Q_DECL_OVERRIDE
VVITConverter(const QString &fileName)
virtual bool IsReadOnly() const Q_DECL_OVERRIDE
static const QString CurrentSchema
static Q_DECL_CONSTEXPR const int MeasurementMaxVer
static const QString MeasurementMinVerStr
#define CONVERTER_VERSION_CHECK(major, minor, patch)
static const QString strTagRead_Only