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);
|
||||
m = new VIndividualMeasurements(data);
|
||||
m->setContent(filePath);
|
||||
m->setXMLContent(filePath);
|
||||
}
|
||||
catch (VException &e)
|
||||
{
|
||||
|
@ -527,7 +527,7 @@ void DialogIncrements::OpenTable()
|
|||
VDomDocument::ValidateXML("://schema/individual_measurements.xsd", filePath);
|
||||
|
||||
m1 = new VIndividualMeasurements(data);
|
||||
m1->setContent(filePath);
|
||||
m1->setXMLContent(filePath);
|
||||
}
|
||||
catch (VException &e)
|
||||
{
|
||||
|
@ -567,7 +567,7 @@ void DialogIncrements::OpenTable()
|
|||
VDomDocument::ValidateXML("://schema/standard_measurements.xsd", filePath);
|
||||
|
||||
m1 = new VStandardMeasurements(data);
|
||||
m1->setContent(filePath);
|
||||
m1->setXMLContent(filePath);
|
||||
Unit mUnit = m1->MUnit();
|
||||
if (qApp->patternUnit() != mUnit)
|
||||
{
|
||||
|
|
|
@ -111,7 +111,7 @@ void DialogIndividualMeasurements::DialogAccepted()
|
|||
{
|
||||
VDomDocument::ValidateXML("://schema/individual_measurements.xsd", _tablePath);
|
||||
VIndividualMeasurements m(data);
|
||||
m.setContent(_tablePath);
|
||||
m.setXMLContent(_tablePath);
|
||||
const qint32 index = ui->comboBoxUnits->currentIndex();
|
||||
Unit unit = VDomDocument::StrToUnits(ui->comboBoxUnits->itemData(index).toString());
|
||||
m.setUnit(unit);
|
||||
|
@ -215,7 +215,7 @@ void DialogIndividualMeasurements::OpenTable()
|
|||
fileName.clear();
|
||||
}
|
||||
VIndividualMeasurements m(data);
|
||||
m.setContent(fileName);
|
||||
m.setXMLContent(fileName);
|
||||
ui->labelGivenName->setText(m.GivenName());
|
||||
ui->labelFamilyName->setText(m.FamilyName());
|
||||
ui->lineEditPathExistM->setText(fileName);
|
||||
|
|
|
@ -99,7 +99,7 @@ void DialogStandardMeasurements::DialogAccepted()
|
|||
{
|
||||
VDomDocument::ValidateXML("://schema/standard_measurements.xsd", _tablePath);
|
||||
VStandardMeasurements m(data);
|
||||
m.setContent(_tablePath);
|
||||
m.setXMLContent(_tablePath);
|
||||
qApp->setPatternUnit(m.MUnit());
|
||||
}
|
||||
catch (VException &e)
|
||||
|
@ -170,7 +170,7 @@ void DialogStandardMeasurements::LoadStandardTables()
|
|||
{
|
||||
VDomDocument::ValidateXML("://schema/standard_measurements.xsd", fi.absoluteFilePath());
|
||||
VStandardMeasurements m(data);
|
||||
m.setContent(fi.absoluteFilePath());
|
||||
m.setXMLContent(fi.absoluteFilePath());
|
||||
if (m.MUnit() == Unit::Inch)
|
||||
{
|
||||
qCWarning(vStMeasur)<<"We do not support inches for standard table. Ignore table"
|
||||
|
|
|
@ -167,7 +167,7 @@ void MainWindow::ActionNewPP()
|
|||
path = stMeasurements.tablePath();
|
||||
qCDebug(vMainWindow)<<"Table path:"<<path;
|
||||
VStandardMeasurements m(pattern);
|
||||
m.setContent(path);
|
||||
m.setXMLContent(path);
|
||||
m.SetSize();
|
||||
m.SetHeight();
|
||||
m.Measurements();
|
||||
|
@ -201,7 +201,7 @@ void MainWindow::ActionNewPP()
|
|||
path = indMeasurements.tablePath();
|
||||
qCDebug(vMainWindow)<<"Table path:"<<path;
|
||||
VIndividualMeasurements m(pattern);
|
||||
m.setContent(path);
|
||||
m.setXMLContent(path);
|
||||
m.Measurements();
|
||||
}
|
||||
else
|
||||
|
@ -2352,7 +2352,7 @@ void MainWindow::LoadPattern(const QString &fileName)
|
|||
try
|
||||
{
|
||||
VDomDocument::ValidateXML(VPatternConverter::CurrentSchema(), fileName);
|
||||
doc->setContent(fileName);
|
||||
doc->setXMLContent(fileName);
|
||||
|
||||
qApp->setPatternUnit(doc->MUnit());
|
||||
qApp->setPatternType(doc->MType());
|
||||
|
@ -2369,7 +2369,7 @@ void MainWindow::LoadPattern(const QString &fileName)
|
|||
{
|
||||
VStandardMeasurements m(pattern);
|
||||
VDomDocument::ValidateXML("://schema/standard_measurements.xsd", path);
|
||||
m.setContent(path);
|
||||
m.setXMLContent(path);
|
||||
if (m.MUnit() == Unit::Inch)
|
||||
{
|
||||
QMessageBox::critical(this, tr("Wrong units."),
|
||||
|
|
|
@ -2572,14 +2572,14 @@ void VPattern::UpdateMeasurements()
|
|||
{
|
||||
VStandardMeasurements m(data);
|
||||
ValidateXML("://schema/standard_measurements.xsd", path);
|
||||
m.setContent(path);
|
||||
m.setXMLContent(path);
|
||||
m.Measurements();
|
||||
}
|
||||
else
|
||||
{
|
||||
VIndividualMeasurements m(data);
|
||||
ValidateXML("://schema/individual_measurements.xsd", path);
|
||||
m.setContent(path);
|
||||
m.setXMLContent(path);
|
||||
m.Measurements();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,9 +27,40 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "vabstractconverter.h"
|
||||
#include "exception/vexception.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VAbstractConverter::VAbstractConverter()
|
||||
:VDomDocument()
|
||||
VAbstractConverter::VAbstractConverter(const QString &fileName)
|
||||
: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:
|
||||
VAbstractConverter();
|
||||
VAbstractConverter(const QString &fileName);
|
||||
virtual ~VAbstractConverter(){}
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VAbstractConverter)
|
||||
QString fileName;
|
||||
|
||||
QString GetVersionStr() const;
|
||||
};
|
||||
|
||||
#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);
|
||||
if (file.open(QIODevice::ReadOnly) == false)
|
||||
|
|
|
@ -106,7 +106,7 @@ public:
|
|||
qreal GetParametrDouble(const QDomElement& domElement, const QString &name, const QString &defValue) const;
|
||||
|
||||
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 QString UnitsToStr(const Unit &unit, const bool translate = false);
|
||||
virtual bool SaveDocument(const QString &fileName, QString &error);
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
#include "vpatternconverter.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPatternConverter::VPatternConverter()
|
||||
:VAbstractConverter()
|
||||
VPatternConverter::VPatternConverter(const QString &fileName)
|
||||
:VAbstractConverter(fileName)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
class VPatternConverter : public VAbstractConverter
|
||||
{
|
||||
public:
|
||||
VPatternConverter();
|
||||
VPatternConverter(const QString &fileName);
|
||||
|
||||
static QString CurrentSchema();
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user