Get version information.
--HG-- branch : feature
This commit is contained in:
parent
fb405d5754
commit
51b89a5497
|
@ -64,7 +64,7 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
|
||||||
{
|
{
|
||||||
VDomDocument::ValidateXML("://schema/individual_measurements.xsd", filePath);
|
VDomDocument::ValidateXML("://schema/individual_measurements.xsd", filePath);
|
||||||
m = new VIndividualMeasurements(data);
|
m = new VIndividualMeasurements(data);
|
||||||
m->setContent(filePath);
|
m->setXMLContent(filePath);
|
||||||
}
|
}
|
||||||
catch (VException &e)
|
catch (VException &e)
|
||||||
{
|
{
|
||||||
|
@ -527,7 +527,7 @@ void DialogIncrements::OpenTable()
|
||||||
VDomDocument::ValidateXML("://schema/individual_measurements.xsd", filePath);
|
VDomDocument::ValidateXML("://schema/individual_measurements.xsd", filePath);
|
||||||
|
|
||||||
m1 = new VIndividualMeasurements(data);
|
m1 = new VIndividualMeasurements(data);
|
||||||
m1->setContent(filePath);
|
m1->setXMLContent(filePath);
|
||||||
}
|
}
|
||||||
catch (VException &e)
|
catch (VException &e)
|
||||||
{
|
{
|
||||||
|
@ -567,7 +567,7 @@ void DialogIncrements::OpenTable()
|
||||||
VDomDocument::ValidateXML("://schema/standard_measurements.xsd", filePath);
|
VDomDocument::ValidateXML("://schema/standard_measurements.xsd", filePath);
|
||||||
|
|
||||||
m1 = new VStandardMeasurements(data);
|
m1 = new VStandardMeasurements(data);
|
||||||
m1->setContent(filePath);
|
m1->setXMLContent(filePath);
|
||||||
Unit mUnit = m1->MUnit();
|
Unit mUnit = m1->MUnit();
|
||||||
if (qApp->patternUnit() != mUnit)
|
if (qApp->patternUnit() != mUnit)
|
||||||
{
|
{
|
||||||
|
|
|
@ -111,7 +111,7 @@ void DialogIndividualMeasurements::DialogAccepted()
|
||||||
{
|
{
|
||||||
VDomDocument::ValidateXML("://schema/individual_measurements.xsd", _tablePath);
|
VDomDocument::ValidateXML("://schema/individual_measurements.xsd", _tablePath);
|
||||||
VIndividualMeasurements m(data);
|
VIndividualMeasurements m(data);
|
||||||
m.setContent(_tablePath);
|
m.setXMLContent(_tablePath);
|
||||||
const qint32 index = ui->comboBoxUnits->currentIndex();
|
const qint32 index = ui->comboBoxUnits->currentIndex();
|
||||||
Unit unit = VDomDocument::StrToUnits(ui->comboBoxUnits->itemData(index).toString());
|
Unit unit = VDomDocument::StrToUnits(ui->comboBoxUnits->itemData(index).toString());
|
||||||
m.setUnit(unit);
|
m.setUnit(unit);
|
||||||
|
@ -215,7 +215,7 @@ void DialogIndividualMeasurements::OpenTable()
|
||||||
fileName.clear();
|
fileName.clear();
|
||||||
}
|
}
|
||||||
VIndividualMeasurements m(data);
|
VIndividualMeasurements m(data);
|
||||||
m.setContent(fileName);
|
m.setXMLContent(fileName);
|
||||||
ui->labelGivenName->setText(m.GivenName());
|
ui->labelGivenName->setText(m.GivenName());
|
||||||
ui->labelFamilyName->setText(m.FamilyName());
|
ui->labelFamilyName->setText(m.FamilyName());
|
||||||
ui->lineEditPathExistM->setText(fileName);
|
ui->lineEditPathExistM->setText(fileName);
|
||||||
|
|
|
@ -99,7 +99,7 @@ void DialogStandardMeasurements::DialogAccepted()
|
||||||
{
|
{
|
||||||
VDomDocument::ValidateXML("://schema/standard_measurements.xsd", _tablePath);
|
VDomDocument::ValidateXML("://schema/standard_measurements.xsd", _tablePath);
|
||||||
VStandardMeasurements m(data);
|
VStandardMeasurements m(data);
|
||||||
m.setContent(_tablePath);
|
m.setXMLContent(_tablePath);
|
||||||
qApp->setPatternUnit(m.MUnit());
|
qApp->setPatternUnit(m.MUnit());
|
||||||
}
|
}
|
||||||
catch (VException &e)
|
catch (VException &e)
|
||||||
|
@ -170,7 +170,7 @@ void DialogStandardMeasurements::LoadStandardTables()
|
||||||
{
|
{
|
||||||
VDomDocument::ValidateXML("://schema/standard_measurements.xsd", fi.absoluteFilePath());
|
VDomDocument::ValidateXML("://schema/standard_measurements.xsd", fi.absoluteFilePath());
|
||||||
VStandardMeasurements m(data);
|
VStandardMeasurements m(data);
|
||||||
m.setContent(fi.absoluteFilePath());
|
m.setXMLContent(fi.absoluteFilePath());
|
||||||
if (m.MUnit() == Unit::Inch)
|
if (m.MUnit() == Unit::Inch)
|
||||||
{
|
{
|
||||||
qCWarning(vStMeasur)<<"We do not support inches for standard table. Ignore table"
|
qCWarning(vStMeasur)<<"We do not support inches for standard table. Ignore table"
|
||||||
|
|
|
@ -167,7 +167,7 @@ void MainWindow::ActionNewPP()
|
||||||
path = stMeasurements.tablePath();
|
path = stMeasurements.tablePath();
|
||||||
qCDebug(vMainWindow)<<"Table path:"<<path;
|
qCDebug(vMainWindow)<<"Table path:"<<path;
|
||||||
VStandardMeasurements m(pattern);
|
VStandardMeasurements m(pattern);
|
||||||
m.setContent(path);
|
m.setXMLContent(path);
|
||||||
m.SetSize();
|
m.SetSize();
|
||||||
m.SetHeight();
|
m.SetHeight();
|
||||||
m.Measurements();
|
m.Measurements();
|
||||||
|
@ -201,7 +201,7 @@ void MainWindow::ActionNewPP()
|
||||||
path = indMeasurements.tablePath();
|
path = indMeasurements.tablePath();
|
||||||
qCDebug(vMainWindow)<<"Table path:"<<path;
|
qCDebug(vMainWindow)<<"Table path:"<<path;
|
||||||
VIndividualMeasurements m(pattern);
|
VIndividualMeasurements m(pattern);
|
||||||
m.setContent(path);
|
m.setXMLContent(path);
|
||||||
m.Measurements();
|
m.Measurements();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2352,7 +2352,7 @@ void MainWindow::LoadPattern(const QString &fileName)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
VDomDocument::ValidateXML(VPatternConverter::CurrentSchema(), fileName);
|
VDomDocument::ValidateXML(VPatternConverter::CurrentSchema(), fileName);
|
||||||
doc->setContent(fileName);
|
doc->setXMLContent(fileName);
|
||||||
|
|
||||||
qApp->setPatternUnit(doc->MUnit());
|
qApp->setPatternUnit(doc->MUnit());
|
||||||
qApp->setPatternType(doc->MType());
|
qApp->setPatternType(doc->MType());
|
||||||
|
@ -2369,7 +2369,7 @@ void MainWindow::LoadPattern(const QString &fileName)
|
||||||
{
|
{
|
||||||
VStandardMeasurements m(pattern);
|
VStandardMeasurements m(pattern);
|
||||||
VDomDocument::ValidateXML("://schema/standard_measurements.xsd", path);
|
VDomDocument::ValidateXML("://schema/standard_measurements.xsd", path);
|
||||||
m.setContent(path);
|
m.setXMLContent(path);
|
||||||
if (m.MUnit() == Unit::Inch)
|
if (m.MUnit() == Unit::Inch)
|
||||||
{
|
{
|
||||||
QMessageBox::critical(this, tr("Wrong units."),
|
QMessageBox::critical(this, tr("Wrong units."),
|
||||||
|
|
|
@ -2572,14 +2572,14 @@ void VPattern::UpdateMeasurements()
|
||||||
{
|
{
|
||||||
VStandardMeasurements m(data);
|
VStandardMeasurements m(data);
|
||||||
ValidateXML("://schema/standard_measurements.xsd", path);
|
ValidateXML("://schema/standard_measurements.xsd", path);
|
||||||
m.setContent(path);
|
m.setXMLContent(path);
|
||||||
m.Measurements();
|
m.Measurements();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
VIndividualMeasurements m(data);
|
VIndividualMeasurements m(data);
|
||||||
ValidateXML("://schema/individual_measurements.xsd", path);
|
ValidateXML("://schema/individual_measurements.xsd", path);
|
||||||
m.setContent(path);
|
m.setXMLContent(path);
|
||||||
m.Measurements();
|
m.Measurements();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,9 +27,40 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vabstractconverter.h"
|
#include "vabstractconverter.h"
|
||||||
|
#include "exception/vexception.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VAbstractConverter::VAbstractConverter()
|
VAbstractConverter::VAbstractConverter(const QString &fileName)
|
||||||
:VDomDocument()
|
:VDomDocument(), fileName(fileName)
|
||||||
{
|
{
|
||||||
|
this->setXMLContent(fileName);
|
||||||
|
QString version = GetVersionStr();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString VAbstractConverter::GetVersionStr() const
|
||||||
|
{
|
||||||
|
const QDomNodeList nodeList = this->elementsByTagName(TagVersion);
|
||||||
|
if (nodeList.isEmpty())
|
||||||
|
{
|
||||||
|
const QString errorMsg(tr("Couldn't get version information."));
|
||||||
|
throw VException(errorMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nodeList.count() > 1)
|
||||||
|
{
|
||||||
|
const QString errorMsg(tr("Too many tags <%1> in file.").arg(TagVersion));
|
||||||
|
throw VException(errorMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
const QDomNode domNode = nodeList.at(0);
|
||||||
|
if (domNode.isNull() == false && domNode.isElement())
|
||||||
|
{
|
||||||
|
const QDomElement domElement = domNode.toElement();
|
||||||
|
if (domElement.isNull() == false)
|
||||||
|
{
|
||||||
|
return domElement.text();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QString(QStringLiteral("0.0.0"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,11 +35,14 @@ class VAbstractConverter :public VDomDocument
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VAbstractConverter();
|
VAbstractConverter(const QString &fileName);
|
||||||
virtual ~VAbstractConverter(){}
|
virtual ~VAbstractConverter(){}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VAbstractConverter)
|
Q_DISABLE_COPY(VAbstractConverter)
|
||||||
|
QString fileName;
|
||||||
|
|
||||||
|
QString GetVersionStr() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VABSTRACTCONVERTER_H
|
#endif // VABSTRACTCONVERTER_H
|
||||||
|
|
|
@ -410,7 +410,7 @@ void VDomDocument::ValidateXML(const QString &schema, const QString &fileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VDomDocument::setContent(const QString &fileName)
|
void VDomDocument::setXMLContent(const QString &fileName)
|
||||||
{
|
{
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
if (file.open(QIODevice::ReadOnly) == false)
|
if (file.open(QIODevice::ReadOnly) == false)
|
||||||
|
|
|
@ -106,7 +106,7 @@ public:
|
||||||
qreal GetParametrDouble(const QDomElement& domElement, const QString &name, const QString &defValue) const;
|
qreal GetParametrDouble(const QDomElement& domElement, const QString &name, const QString &defValue) const;
|
||||||
|
|
||||||
static void ValidateXML(const QString &schema, const QString &fileName);
|
static void ValidateXML(const QString &schema, const QString &fileName);
|
||||||
void setContent(const QString &fileName);
|
void setXMLContent(const QString &fileName);
|
||||||
static Unit StrToUnits(const QString &unit);
|
static Unit StrToUnits(const QString &unit);
|
||||||
static QString UnitsToStr(const Unit &unit, const bool translate = false);
|
static QString UnitsToStr(const Unit &unit, const bool translate = false);
|
||||||
virtual bool SaveDocument(const QString &fileName, QString &error);
|
virtual bool SaveDocument(const QString &fileName, QString &error);
|
||||||
|
|
|
@ -29,8 +29,8 @@
|
||||||
#include "vpatternconverter.h"
|
#include "vpatternconverter.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VPatternConverter::VPatternConverter()
|
VPatternConverter::VPatternConverter(const QString &fileName)
|
||||||
:VAbstractConverter()
|
:VAbstractConverter(fileName)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
class VPatternConverter : public VAbstractConverter
|
class VPatternConverter : public VAbstractConverter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VPatternConverter();
|
VPatternConverter(const QString &fileName);
|
||||||
|
|
||||||
static QString CurrentSchema();
|
static QString CurrentSchema();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user