After this commit begin testing.

--HG--
branch : feature
This commit is contained in:
dismine 2014-03-21 12:08:29 +02:00
parent fa06c04cd2
commit 69309730ff
40 changed files with 443 additions and 233 deletions

View File

@ -29,14 +29,23 @@
#include "vmeasurement.h"
VMeasurement::VMeasurement()
:base(0), ksize(50.0), kheight(176.0), gui_text(QString()), number(QString()){}
:base(0), ksize(50.0), kheight(176.0), gui_text(QString()), number(QString()), virtualM(false),
_tagName(QString())
{
}
VMeasurement::VMeasurement(const qreal &base, const qreal &ksize, const qreal &kgrowth,
const QString &gui_text, const QString &number)
:base(base), ksize(ksize), kheight(kgrowth), gui_text(gui_text), number(number){}
const QString &gui_text, const QString &number, const QString &tagName)
:base(base), ksize(ksize), kheight(kgrowth), gui_text(gui_text), number(number), virtualM(false),
_tagName(tagName)
{
VMeasurement::VMeasurement(const qreal &base, const QString &gui_text, const QString &number)
:base(base), ksize(50.0), kheight(176.0), gui_text(gui_text), number(number)
}
VMeasurement::VMeasurement(const qreal &base, const QString &gui_text, const QString &number, const QString &tagName)
:base(base), ksize(50.0), kheight(176.0), gui_text(gui_text), number(number), virtualM(false),
_tagName(tagName)
{
}
@ -52,3 +61,7 @@ qreal VMeasurement::GetValue(const qreal &size, const qreal &height) const
const qreal k_height = ( height - 176.0 ) / 6.0;
return base + k_size * ksize + k_height * kheight;
}

View File

@ -49,15 +49,17 @@ public:
* @param description description of increment
*/
VMeasurement(const qreal &base, const qreal &ksize, const qreal &kheight,
const QString &gui_text = QString(), const QString &number = QString());
const QString &gui_text = QString(), const QString &number = QString(),
const QString &TagName = QString());
VMeasurement(const qreal &base, const QString &gui_text = QString(),
const QString &number = QString());
const QString &number = QString(), const QString &TagName = QString());
~VMeasurement(){}
/**
* @brief GetBase return value in base size and growth
* @return value
*/
qreal GetBase() const;
void setBase(const qreal &value);
/**
* @brief GetKsize return increment in sizes
* @return increment
@ -76,6 +78,10 @@ public:
QString GetNumber() const;
qreal GetValue() const;
qreal GetValue(const qreal &size, const qreal &height) const;
QString TagName() const;
void setTagName(const QString &TagName);
bool Virtual() const;
void setVirtual(bool value);
private:
/**
* @brief base value in base size and growth
@ -94,6 +100,8 @@ private:
*/
QString gui_text;
QString number;
bool virtualM;
QString _tagName;
};
inline qreal VMeasurement::GetBase() const
@ -101,6 +109,11 @@ inline qreal VMeasurement::GetBase() const
return base;
}
inline void VMeasurement::setBase(const qreal &value)
{
base = value;
}
inline qreal VMeasurement::GetKsize() const
{
return ksize;
@ -121,4 +134,24 @@ inline QString VMeasurement::GetNumber() const
return number;
}
inline QString VMeasurement::TagName() const
{
return _tagName;
}
inline void VMeasurement::setTagName(const QString &tagName)
{
_tagName = tagName;
}
inline bool VMeasurement::Virtual() const
{
return virtualM;
}
inline void VMeasurement::setVirtual(bool value)
{
virtualM = value;
}
#endif // VSTANDARDTABLEROW_H

View File

@ -33,17 +33,18 @@
#include "../../exception/vexception.h"
#include <QPushButton>
#include <QFile>
DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *parent)
:DialogTool(data, parent), ui(new Ui::DialogIncrements), data(data), doc(doc), row(0), column(0)
:DialogTool(data, parent), ui(new Ui::DialogIncrements), data(data), doc(doc), row(0), column(0), m(nullptr)
{
ui->setupUi(this);
TextDelegate *textDelegate = new TextDelegate(ui->tableWidgetIncrement);
ui->tableWidgetIncrement->setItemDelegateForColumn(0, textDelegate);
ui->tableWidgetIncrement->setItemDelegateForColumn(0, textDelegate);// name
DoubleSpinBoxDelegate *doubleDelegate = new DoubleSpinBoxDelegate(ui->tableWidgetIncrement);
ui->tableWidgetIncrement->setItemDelegateForColumn(2, doubleDelegate);
ui->tableWidgetIncrement->setItemDelegateForColumn(3, doubleDelegate);
ui->tableWidgetIncrement->setItemDelegateForColumn(4, doubleDelegate);
ui->tableWidgetIncrement->setItemDelegateForColumn(2, doubleDelegate);// base value
ui->tableWidgetIncrement->setItemDelegateForColumn(3, doubleDelegate);// in sizes
ui->tableWidgetIncrement->setItemDelegateForColumn(4, doubleDelegate);// in heights
if (qApp->patternType() == Pattern::Standard)
{
@ -58,16 +59,15 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
}
else
{
ui->tableWidgetMeasurements->setColumnHidden( 1, true );
ui->tableWidgetMeasurements->setColumnHidden( 3, true );
ui->tableWidgetMeasurements->setColumnHidden( 4, true );
ui->tableWidgetMeasurements->setColumnHidden( 1, true );// calculated value
ui->tableWidgetMeasurements->setColumnHidden( 3, true );// in sizes
ui->tableWidgetMeasurements->setColumnHidden( 4, true );// in heights
ui->tableWidgetIncrement->setColumnHidden( 1, true );
ui->tableWidgetIncrement->setColumnHidden( 3, true );
ui->tableWidgetIncrement->setColumnHidden( 4, true );
ui->tableWidgetIncrement->setColumnHidden( 1, true );// calculated value
ui->tableWidgetIncrement->setColumnHidden( 3, true );// in sizes
ui->tableWidgetIncrement->setColumnHidden( 4, true );// in heights
ui->tableWidgetMeasurements->setItemDelegateForColumn(0, textDelegate);
ui->tableWidgetMeasurements->setItemDelegateForColumn(2, doubleDelegate);
ui->tableWidgetMeasurements->setItemDelegateForColumn(2, doubleDelegate);// base value
connect(ui->tableWidgetMeasurements, &QTableWidget::cellChanged, this, &DialogIncrements::MeasurementsChanged);
}
@ -87,21 +87,66 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
connect(this->doc, &VPattern::FullUpdateFromFile, this, &DialogIncrements::FullUpdateFromFile);
ui->tabWidget->setCurrentIndex(0);
if (qApp->patternType() == Pattern::Individual)
{
QString filePath = doc->MPath();
QFile file(filePath);
if (file.open(QIODevice::ReadOnly))
{
try
{
VDomDocument::ValidatePattern("://schema/individual_measurements.xsd", filePath);
}
catch(VException &e)
{
qWarning()<<"Validation file error."<<e.ErrorMessage()<<e.DetailedInformation()<<Q_FUNC_INFO;
emit DialogClosed(QDialog::Rejected);
return;
}
m = new VIndividualMeasurements(data);
try
{
m->setContent(&file);
}
catch(VException &e)
{
qWarning()<<"Parsing measurements file error."<<e.ErrorMessage()<<e.DetailedInformation()<<Q_FUNC_INFO;
emit DialogClosed(QDialog::Rejected);
return;
}
file.close();
}
else
{
qWarning()<<tr("Cannot read file %1:\n%2.").arg(filePath).arg(file.errorString()) << Q_FUNC_INFO;
}
}
}
void DialogIncrements::FillMeasurements()
{
const QHash<QString, VMeasurement> *table = data->DataMeasurements();
qint32 currentRow = -1;
QHashIterator<QString, VMeasurement> i(*table);
ui->tableWidgetMeasurements->setRowCount ( table->size() );
QMap<QString, VMeasurement> map;
//Sorting QHash by id
while (i.hasNext())
{
i.next();
VMeasurement m = i.value();
map.insert(i.key(), i.value());
}
qint32 currentRow = -1;
QMapIterator<QString, VMeasurement> iMap(map);
ui->tableWidgetMeasurements->setRowCount ( table->size() );
while (iMap.hasNext())
{
iMap.next();
VMeasurement m = iMap.value();
currentRow++;
QTableWidgetItem *item = new QTableWidgetItem(QString(i.key()));
QTableWidgetItem *item = new QTableWidgetItem(QString(iMap.key()));
item->setTextAlignment(Qt::AlignHCenter);
item->setFont(QFont("Times", 12, QFont::Bold));
item->setToolTip(m.GetDescription());
@ -109,7 +154,7 @@ void DialogIncrements::FillMeasurements()
if (qApp->patternType() == Pattern::Standard)
{
QTableWidgetItem *item = new QTableWidgetItem(QString().setNum(data->GetValueStandardTableRow(i.key())));
QTableWidgetItem *item = new QTableWidgetItem(QString().setNum(data->GetValueStandardTableRow(iMap.key())));
item->setTextAlignment(Qt::AlignHCenter);
ui->tableWidgetMeasurements->setItem(currentRow, 1, item);
}
@ -133,9 +178,9 @@ void DialogIncrements::FillMeasurements()
item->setTextAlignment(Qt::AlignHCenter);
ui->tableWidgetMeasurements->setItem(currentRow, 5, item);
}
ui->tableWidgetMeasurements->verticalHeader()->setDefaultSectionSize(20);
ui->tableWidgetMeasurements->resizeColumnsToContents();
ui->tableWidgetMeasurements->resizeRowsToContents();
ui->tableWidgetMeasurements->verticalHeader()->setDefaultSectionSize(20);
}
void DialogIncrements::FillIncrements()
@ -305,21 +350,20 @@ void DialogIncrements::FillLengthArcs()
item->setTextAlignment(Qt::AlignHCenter);
ui->tableWidgetArcs->setItem(currentRow, 1, item);
}
ui->tableWidgetArcs->verticalHeader()->setDefaultSectionSize(20);
ui->tableWidgetArcs->resizeColumnsToContents();
ui->tableWidgetArcs->resizeRowsToContents();
ui->tableWidgetArcs->verticalHeader()->setDefaultSectionSize(20);
}
void DialogIncrements::FullUpdateFromFile()
{
disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
&DialogIncrements::IncrementChanged);
ui->tableWidgetMeasurements->clearContents();
FillMeasurements();
disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, &DialogIncrements::IncrementChanged);
ui->tableWidgetIncrement->clearContents();
FillIncrements();
connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, &DialogIncrements::IncrementChanged);
ui->tableWidgetLines->clearContents();
FillLengthLines();
@ -329,9 +373,6 @@ void DialogIncrements::FullUpdateFromFile()
ui->tableWidgetArcs->clearContents();
FillLengthArcs();
connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
&DialogIncrements::IncrementChanged);
}
void DialogIncrements::clickedToolButtonAdd()
@ -350,15 +391,12 @@ void DialogIncrements::clickedToolButtonAdd()
num++;
} while (data->IncrementTableContains(name));
quint32 id = data->getNextId();
qreal base = 0;
qreal ksize = 0;
qreal kgrowth = 0;
QString description = QString(tr("Description"));
VIncrement incr = VIncrement(id, base, ksize, kgrowth, description);
const quint32 id = data->getNextId();
const QString description(tr("Description"));
VIncrement incr = VIncrement(id, 0, 0, 0, description);
data->AddIncrement(name, incr);
AddIncrementToFile(id, name, base, ksize, kgrowth, description);
AddIncrementToFile(id, name, 0, 0, 0, description);
QTableWidgetItem *item = new QTableWidgetItem(name);
item->setTextAlignment(Qt::AlignHCenter);
@ -367,7 +405,7 @@ void DialogIncrements::clickedToolButtonAdd()
ui->tableWidgetIncrement->setItem(currentRow, 0, item);
ui->tableWidgetIncrement->setCurrentCell(currentRow, 0, QItemSelectionModel::ClearAndSelect);
item = new QTableWidgetItem("0");
item = new QTableWidgetItem("0");// calculated value
item->setTextAlignment(Qt::AlignHCenter);
// set the item non-editable (view only), and non-selectable
Qt::ItemFlags flags = item->flags();
@ -375,19 +413,19 @@ void DialogIncrements::clickedToolButtonAdd()
item->setFlags(flags);
ui->tableWidgetIncrement->setItem(currentRow, 1, item);
item = new QTableWidgetItem("0");
item = new QTableWidgetItem("0");// base value
item->setTextAlignment(Qt::AlignHCenter);
ui->tableWidgetIncrement->setItem(currentRow, 2, item);
item = new QTableWidgetItem("0");
item = new QTableWidgetItem("0");// in sizes
item->setTextAlignment(Qt::AlignHCenter);
ui->tableWidgetIncrement->setItem(currentRow, 3, item);
item = new QTableWidgetItem("0");
item = new QTableWidgetItem("0"); // in heights
item->setTextAlignment(Qt::AlignHCenter);
ui->tableWidgetIncrement->setItem(currentRow, 4, item);
item = new QTableWidgetItem(tr("Description"));
item = new QTableWidgetItem(description);
item->setTextAlignment(Qt::AlignHCenter);
ui->tableWidgetIncrement->setItem(currentRow, 5, item);
@ -409,7 +447,7 @@ void DialogIncrements::clickedToolButtonRemove()
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
QDomNodeList list = doc->elementsByTagName("increments");
QDomNodeList list = doc->elementsByTagName(VPattern::TagIncrements);
list.at(0).removeChild(domElement);
}
ui->tableWidgetIncrement->removeRow(row);
@ -422,134 +460,115 @@ void DialogIncrements::clickedToolButtonRemove()
emit haveLiteChange();
}
void DialogIncrements::AddIncrementToFile(quint32 id, QString name, qreal base, qreal ksize, qreal kgrowth,
QString description)
void DialogIncrements::AddIncrementToFile(const quint32 &id, const QString &name, const qreal &base, const qreal &ksize,
const qreal &kheight, const QString &description)
{
QDomNodeList list = doc->elementsByTagName("increments");
QDomElement element = doc->createElement("increment");
QDomElement element = doc->createElement(VPattern::TagIncrement);
QDomAttr drawAttr = doc->createAttribute("id");
drawAttr.setValue(QString().setNum(id));
element.setAttributeNode(drawAttr);
drawAttr = doc->createAttribute("name");
drawAttr.setValue(name);
element.setAttributeNode(drawAttr);
drawAttr = doc->createAttribute("base");
drawAttr.setValue(QString().setNum(base));
element.setAttributeNode(drawAttr);
drawAttr = doc->createAttribute("ksize");
drawAttr.setValue(QString().setNum(ksize));
element.setAttributeNode(drawAttr);
drawAttr = doc->createAttribute("kgrowth");
drawAttr.setValue(QString().setNum(kgrowth));
element.setAttributeNode(drawAttr);
drawAttr = doc->createAttribute("description");
drawAttr.setValue(description);
element.setAttributeNode(drawAttr);
doc->SetAttribute(element, VDomDocument::AttrId, id);
doc->SetAttribute(element, VPattern::IncrementName, name);
doc->SetAttribute(element, VPattern::IncrementBase, base);
doc->SetAttribute(element, VPattern::IncrementKsize, ksize);
doc->SetAttribute(element, VPattern::IncrementKgrowth, kheight);
doc->SetAttribute(element, VPattern::IncrementDescription, description);
QDomNodeList list = doc->elementsByTagName(VPattern::TagIncrements);
list.at(0).appendChild(element);
}
void DialogIncrements::IncrementChanged ( qint32 row, qint32 column )
{
QTableWidgetItem *item = nullptr;
QTableWidgetItem *itemName = nullptr;
quint32 id;
QDomElement domElement;
const QTableWidgetItem *itemName = ui->tableWidgetIncrement->item(row, 0);
const QTableWidgetItem *item = ui->tableWidgetIncrement->item(row, column);
const quint32 id = qvariant_cast<quint32>(itemName->data(Qt::UserRole));
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement() == false)
{
qWarning()<<"Cant't find increment with id = "<<id<<Q_FUNC_INFO;
return;
}
this->row = row;
switch (column)
{
case 0: // name
item = ui->tableWidgetIncrement->item(row, 0);
id = qvariant_cast<quint32>(item->data(Qt::UserRole));
domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute("name", item->text());
data->ClearIncrementTable();
this->column = 2;
emit FullUpdateTree();
emit haveLiteChange();
}
case 0: // VPattern::IncrementName
doc->SetAttribute(domElement, VPattern::IncrementName, item->text());
data->ClearIncrementTable();
this->column = 2;
emit FullUpdateTree();
break;
case 2: // base
itemName = ui->tableWidgetIncrement->item(row, 0);
item = ui->tableWidgetIncrement->item(row, column);
id = qvariant_cast<quint32>(itemName->data(Qt::UserRole));
domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
bool ok = false;
qreal value = item->text().replace(",", ".").toDouble(&ok);
if (ok)
{
domElement.setAttribute("base", value);
this->column = 3;
emit FullUpdateTree();
emit haveLiteChange();
}
else
{
throw VException(tr("Can't convert toDouble value."));
}
}
case 2: // VPattern::IncrementBase
doc->SetAttribute(domElement, VPattern::IncrementBase, item->text());
this->column = 3;
emit FullUpdateTree();
break;
case 3: // ksize
itemName = ui->tableWidgetIncrement->item(row, 0);
item = ui->tableWidgetIncrement->item(row, column);
id = qvariant_cast<quint32>(itemName->data(Qt::UserRole));
domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute("ksize", item->text().replace(",", ".").toDouble());
this->column = 4;
emit FullUpdateTree();
emit haveLiteChange();
}
case 3: // VPattern::IncrementKsize
doc->SetAttribute(domElement, VPattern::IncrementKsize, item->text());
this->column = 4;
emit FullUpdateTree();
break;
case 4: // kgrowth
itemName = ui->tableWidgetIncrement->item(row, 0);
item = ui->tableWidgetIncrement->item(row, column);
id = qvariant_cast<quint32>(itemName->data(Qt::UserRole));
domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute("kgrowth", item->text().replace(",", ".").toDouble());
this->column = 5;
emit FullUpdateTree();
emit haveLiteChange();
}
case 4: // VPattern::IncrementKgrowth
doc->SetAttribute(domElement, VPattern::IncrementKgrowth, item->text());
this->column = 5;
emit FullUpdateTree();
break;
case 5: // description
itemName = ui->tableWidgetIncrement->item(row, 0);
item = ui->tableWidgetIncrement->item(row, column);
id = qvariant_cast<quint32>(itemName->data(Qt::UserRole));
domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement())
{
domElement.setAttribute("description", item->text());
VIncrement incr = data->GetIncrement(itemName->text());
incr.setDescription(item->text());
data->UpdateIncrement(itemName->text(), incr);
ui->tableWidgetIncrement->resizeColumnsToContents();
ui->tableWidgetIncrement->resizeRowsToContents();
ui->tableWidgetIncrement->setCurrentCell( row, 0 );
emit haveLiteChange();
}
case 5: // VPattern::IncrementDescription
{
doc->SetAttribute(domElement, VPattern::IncrementDescription, item->text());
VIncrement incr = data->GetIncrement(itemName->text());
incr.setDescription(item->text());
data->UpdateIncrement(itemName->text(), incr);
ui->tableWidgetIncrement->resizeColumnsToContents();
ui->tableWidgetIncrement->resizeRowsToContents();
this->column = 0;
ui->tableWidgetIncrement->setCurrentCell( row, this->column );
break;
}
default:
break;
}
emit haveLiteChange();
}
void DialogIncrements::MeasurementsChanged(qint32 row, qint32 column)
{
const QTableWidgetItem *itemName = ui->tableWidgetMeasurements->item(row, 0);
QTableWidgetItem *item = ui->tableWidgetMeasurements->item(row, 2);
VMeasurement measur = data->GetMeasurement(itemName->text());
const QString tag = measur.TagName();
VIndividualMeasurements m(data);
QDomNodeList list = m.elementsByTagName(tag);
QDomElement domElement = list.at(0).toElement();
if (domElement.isElement() == false)
{
qWarning()<<"Cant't find measurement "<<tag<<Q_FUNC_INFO;
return;
}
switch (column)
{
case 2:
{
m.SetAttribute(domElement, VIndividualMeasurements::AttrValue, item->text());
bool ok = false;
const qreal base = item->text().replace(",", ".").toDouble(&ok);
if (ok == false)
{
measur.setBase(0);
item->setText("0");
qWarning()<<"Can't convert toDouble measurement value"<<Q_FUNC_INFO;
}
else
{
measur.setBase(base);
}
data->UpdateMeasurement(itemName->text(), measur);
break;
}
default:
break;
}
emit haveLiteChange();
}
void DialogIncrements::closeEvent(QCloseEvent *event)

View File

@ -31,6 +31,7 @@
#include "../tools/dialogtool.h"
#include "../../xml/vpattern.h"
#include "../../xml/vindividualmeasurements.h"
namespace Ui
{
@ -105,6 +106,7 @@ private:
* @brief column save number of column current selected cell
*/
qint32 column;
VIndividualMeasurements *m;
/**
* @brief FillMeasurements load measurements data
*/
@ -131,11 +133,11 @@ private:
* @param name name
* @param base base value
* @param ksize increment in sizes
* @param kgrowth increment in growths
* @param kheight increment in heights
* @param description description of increment
*/
void AddIncrementToFile(quint32 id, QString name, qreal base, qreal ksize, qreal kgrowth,
QString description);
void AddIncrementToFile(const quint32 &id, const QString &name, const qreal &base,
const qreal &ksize, const qreal &kheight, const QString &description);
};
#endif // DIALOGINCREMENTS_H

View File

@ -217,7 +217,7 @@ void DialogIndividualMeasurements::LoadIndividualTables()
{
try
{
VDomDocument::ValidatePattern("://schema/standard_measurements.xsd", allFiles.at(i));
VDomDocument::ValidatePattern("://schema/individual_measurements.xsd", allFiles.at(i));
}
catch(VException &e)
{

View File

@ -49,8 +49,9 @@ MainWindow::MainWindow(QWidget *parent)
:QMainWindow(parent), ui(new Ui::MainWindow), pattern(nullptr), doc(nullptr), tool(Valentina::ArrowTool),
currentScene(nullptr), sceneDraw(nullptr), sceneDetails(nullptr), mouseCoordinate(nullptr), helpLabel(nullptr),
view(nullptr), isInitialized(false), dialogTable(0), dialogTool(nullptr), dialogHistory(nullptr),
comboBoxDraws(nullptr), curFile(QString()), mode(Valentina::Calculation), currentDrawIndex(0), currentToolBoxIndex(0),
drawMode(true), recentFileActs{0, 0, 0, 0, 0}, separatorAct(nullptr), autoSaveTimer(nullptr)
comboBoxDraws(nullptr), curFile(QString()), mode(Valentina::Calculation), currentDrawIndex(0),
currentToolBoxIndex(0), drawMode(true), recentFileActs{0, 0, 0, 0, 0}, separatorAct(nullptr),
autoSaveTimer(nullptr)
{
CreateActions();
CreateMenus();

View File

@ -84,7 +84,7 @@ void VToolAlongLine::AddToFile()
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));

View File

@ -182,7 +182,7 @@ void VToolArc::AddToFile()
const VArc *arc = VAbstractTool::data.GeometricObject<const VArc *>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrCenter, arc->GetCenter().id());
doc->SetAttribute(domElement, AttrRadius, arc->GetFormulaRadius());

View File

@ -182,7 +182,7 @@ void VToolBisector::AddToFile()
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));

View File

@ -205,7 +205,7 @@ void VToolCutArc::AddToFile()
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));

View File

@ -201,7 +201,7 @@ void VToolCutSpline::AddToFile()
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));

View File

@ -275,7 +275,7 @@ void VToolCutSplinePath::AddToFile()
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));

View File

@ -148,7 +148,7 @@ void VToolEndLine::AddToFile()
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));

View File

@ -154,7 +154,7 @@ void VToolHeight::AddToFile()
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));

View File

@ -155,7 +155,7 @@ void VToolLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
void VToolLine::AddToFile()
{
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrFirstPoint, firstPoint);
doc->SetAttribute(domElement, AttrSecondPoint, secondPoint);
doc->SetAttribute(domElement, AttrTypeLine, typeLine);

View File

@ -165,7 +165,7 @@ void VToolLineIntersect::AddToFile()
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));

View File

@ -168,7 +168,7 @@ void VToolNormal::AddToFile()
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));

View File

@ -188,7 +188,7 @@ void VToolPointOfContact::AddToFile()
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));

View File

@ -138,7 +138,7 @@ void VToolPointOfIntersection::AddToFile()
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));

View File

@ -190,7 +190,7 @@ void VToolShoulderPoint::AddToFile()
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));

View File

@ -66,7 +66,7 @@ void VToolSinglePoint::AddToFile()
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrX, qApp->fromPixel(point->x()));

View File

@ -176,7 +176,7 @@ void VToolSpline::AddToFile()
const VSpline *spl = VAbstractTool::data.GeometricObject<const VSpline *>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrPoint1, spl->GetP1().id());
doc->SetAttribute(domElement, AttrPoint4, spl->GetP4().id());

View File

@ -214,7 +214,7 @@ void VToolSplinePath::AddToFile()
VSplinePath splPath = *VAbstractTool::data.GeometricObject<const VSplinePath *>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrKCurve, splPath.getKCurve());

View File

@ -194,7 +194,7 @@ void VToolTriangle::AddToFile()
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrName, point->name());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));

View File

@ -93,7 +93,7 @@ void VNodeArc::AddToFile()
{
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrIdObject, idNode);
if (idTool != 0)

View File

@ -105,7 +105,7 @@ void VNodePoint::AddToFile()
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrIdObject, idNode);
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));

View File

@ -97,7 +97,7 @@ void VNodeSpline::AddToFile()
{
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrIdObject, idNode);
if (idTool != 0)

View File

@ -100,7 +100,7 @@ void VNodeSplinePath::AddToFile()
{
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrIdObject, idNode);
if (idTool != 0)

View File

@ -28,7 +28,6 @@
#include "vabstracttool.h"
const QString VAbstractTool::AttrId = QStringLiteral("id");
const QString VAbstractTool::AttrType = QStringLiteral("type");
const QString VAbstractTool::AttrMx = QStringLiteral("mx");
const QString VAbstractTool::AttrMy = QStringLiteral("my");

View File

@ -102,7 +102,6 @@ public:
* @param c c value
*/
static void LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c);
static const QString AttrId;
static const QString AttrType;
static const QString AttrMx;
static const QString AttrMy;

View File

@ -228,7 +228,7 @@ void VToolDetail::AddToFile()
VDetail detail = VAbstractTool::data.GetDetail(id);
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrName, detail.getName());
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(detail.getMx()));
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(detail.getMy()));

View File

@ -615,7 +615,7 @@ void VToolUnionDetails::AddToFile()
{
QDomElement domElement = doc->createElement(TagName);
doc->SetAttribute(domElement, AttrId, id);
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
doc->SetAttribute(domElement, AttrType, ToolType);
doc->SetAttribute(domElement, AttrIndexD1, indexD1);
doc->SetAttribute(domElement, AttrIndexD2, indexD2);

View File

@ -77,6 +77,12 @@ inline qint64 MessageHandler::column() const
return m_sourceLocation.column();
}
const QString VDomDocument::AttrId = QStringLiteral("id");
const QString VDomDocument::AttrUnit = QStringLiteral("unit");
const QString VDomDocument::UnitMM = QStringLiteral("mm");
const QString VDomDocument::UnitCM = QStringLiteral("cm");
const QString VDomDocument::UnitIN = QStringLiteral("in");
VDomDocument::VDomDocument(VContainer *data)
: QDomDocument(), data(data), map(QHash<QString, QDomElement>())
{
@ -122,9 +128,9 @@ void VDomDocument::removeAllChilds(QDomElement &element)
bool VDomDocument::find(const QDomElement &node, const QString& id)
{
if (node.hasAttribute("id"))
if (node.hasAttribute(AttrId))
{
const QString value = node.attribute("id");
const QString value = node.attribute(AttrId);
this->map[value] = node;
if (value == id)
{
@ -311,7 +317,7 @@ void VDomDocument::setContent(QIODevice *dev)
Valentina::Units VDomDocument::Units(const QString &unit)
{
QStringList units;
units << "mm" << "cm" << "in";
units << UnitMM << UnitCM << UnitIN;
Valentina::Units result = Valentina::Cm;
switch (units.indexOf(unit))
{

View File

@ -47,6 +47,11 @@ class VDomDocument : public QDomDocument
{
Q_DECLARE_TR_FUNCTIONS(VDomDocument)
public:
static const QString AttrId;
static const QString AttrUnit;
static const QString UnitMM;
static const QString UnitCM;
static const QString UnitIN;
/**
* @brief VDomDocument constructor.
* @param data container with variables.
@ -162,13 +167,20 @@ template <>
inline void VDomDocument::SetAttribute<Valentina::Units>(QDomElement &domElement, const QString &name,
const Valentina::Units &value)
{
if (value == Valentina::Cm || value == Valentina::Mm)
switch(value)
{
domElement.setAttribute(name, "cm");
}
else
{
domElement.setAttribute(name, "in");
case Valentina::Mm:
domElement.setAttribute(name, "mm");
break;
case Valentina::Cm:
domElement.setAttribute(name, "cm");
break;
case Valentina::In:
domElement.setAttribute(name, "in");
break;
default:
domElement.setAttribute(name, "cm");
break;
}
}

View File

@ -28,13 +28,25 @@
#include "vindividualmeasurements.h"
const QString VIndividualMeasurements::AttrIgnore = QStringLiteral("ignore");
const QString VIndividualMeasurements::AttrName = QStringLiteral("name");
const QString VIndividualMeasurements::AttrM_number = QStringLiteral("m_number");
const QString VIndividualMeasurements::AttrGui_text = QStringLiteral("gui_text");
const QString VIndividualMeasurements::AttrValue = QStringLiteral("value");
const QString VIndividualMeasurements::AttrDescription = QStringLiteral("description");
const QString VIndividualMeasurements::AttrLang = QStringLiteral("lang");
const QString VIndividualMeasurements::AttrFamily_name = QStringLiteral("family-name");
const QString VIndividualMeasurements::AttrGiven_name = QStringLiteral("given-name");
const QString VIndividualMeasurements::AttrBirth_date = QStringLiteral("birth-date");
const QString VIndividualMeasurements::AttrSex = QStringLiteral("sex");
VIndividualMeasurements::VIndividualMeasurements(VContainer *data):VDomDocument(data)
{
}
Valentina::Units VIndividualMeasurements::Unit()
{
const QString unit = UniqueTagText("unit", "cm");
const QString unit = UniqueTagText(AttrUnit, UnitCM);
return VDomDocument::Units(unit);
}
@ -145,24 +157,24 @@ void VIndividualMeasurements::Measurement(const QString &tag)
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
const bool ignore = QVariant(GetParametrString(domElement, "ignore", "false")).toBool();
const bool ignore = QVariant(GetParametrString(domElement, AttrIgnore, "false")).toBool();
if (ignore)
{
return;
}
const QString name = GetParametrString(domElement, "name", "");
const QString name = GetParametrString(domElement, AttrName, "");
if (name.isEmpty())
{
return;
}
const QString m_number = GetParametrString(domElement, "m_number", "");
const QString gui_text = GetParametrString(domElement, "gui_text", "");
const qreal value = GetParametrDouble(domElement, "value", "0.0");
const QString description = GetParametrString(domElement, "description", "");
const QString m_number = GetParametrString(domElement, AttrM_number, "");
const QString gui_text = GetParametrString(domElement, AttrGui_text, "");
const qreal value = GetParametrDouble(domElement, AttrValue, "0.0");
const QString description = GetParametrString(domElement, AttrDescription, "");
if (Unit() == Valentina::Mm)//Convert to Cm.
{
data->AddMeasurement(name, VMeasurement(value/10.0, gui_text, description));
data->AddMeasurement(name, VMeasurement(value/10.0, gui_text, description, tag));
if (m_number.isEmpty())
{
qWarning()<<"Can't find language-independent measurement name for "<< tag;
@ -170,12 +182,14 @@ void VIndividualMeasurements::Measurement(const QString &tag)
}
else
{
data->AddMeasurement(m_number, VMeasurement(value/10.0, gui_text, description));
VMeasurement m(value/10.0, gui_text, description, tag);
m.setVirtual(true);
data->AddMeasurement(m_number, m);
}
}
else//Cm or inch.
{
data->AddMeasurement(name, VMeasurement(value, gui_text, description));
data->AddMeasurement(name, VMeasurement(value, gui_text, description, tag));
if (m_number.isEmpty())
{
qWarning()<<"Can't find language-independent measurement name for "<< tag;
@ -183,7 +197,9 @@ void VIndividualMeasurements::Measurement(const QString &tag)
}
else
{
data->AddMeasurement(m_number, VMeasurement(value, gui_text, description));
VMeasurement m(value, gui_text, description, tag);
m.setVirtual(true);
data->AddMeasurement(m_number, m);
}
}
}
@ -193,25 +209,25 @@ void VIndividualMeasurements::Measurement(const QString &tag)
QString VIndividualMeasurements::Language()
{
return UniqueTagText("lang", "en");
return UniqueTagText(AttrLang, "en");
}
QString VIndividualMeasurements::FamilyName()
{
return UniqueTagText("family-name", "");
return UniqueTagText(AttrFamily_name, "");
}
QString VIndividualMeasurements::GivenName()
{
return UniqueTagText("given-name", "");
return UniqueTagText(AttrGiven_name, "");
}
QString VIndividualMeasurements::BirthDate()
{
return UniqueTagText("birth-date", "");
return UniqueTagText(AttrBirth_date, "");
}
QString VIndividualMeasurements::Sex()
{
return UniqueTagText("sex", "");
return UniqueTagText(AttrSex, "");
}

View File

@ -43,6 +43,17 @@ public:
QString GivenName();
QString BirthDate();
QString Sex();
static const QString AttrIgnore;
static const QString AttrName;
static const QString AttrM_number;
static const QString AttrGui_text;
static const QString AttrValue;
static const QString AttrDescription;
static const QString AttrLang;
static const QString AttrFamily_name;
static const QString AttrGiven_name;
static const QString AttrBirth_date;
static const QString AttrSex;
};
#endif // VINDIVIDUALMEASUREMENTS_H

View File

@ -57,6 +57,7 @@ const QString VPattern::TagTools = QStringLiteral("tools");
const QString VPattern::AttrName = QStringLiteral("name");
const QString VPattern::AttrType = QStringLiteral("type");
const QString VPattern::AttrPath = QStringLiteral("path");
const QString VPattern::IncrementName = QStringLiteral("name");
const QString VPattern::IncrementBase = QStringLiteral("base");
@ -84,9 +85,9 @@ void VPattern::CreateEmptyFile(const QString &tablePath)
patternElement.appendChild(createElement(TagNotes));
QDomElement measurements = createElement(TagMeasurements);
SetAttribute(measurements, "unit", qApp->patternUnit());
SetAttribute(measurements, "type", qApp->patternType());
SetAttribute(measurements, "path", tablePath);
SetAttribute(measurements, AttrUnit, qApp->patternUnit());
SetAttribute(measurements, AttrType, qApp->patternType());
SetAttribute(measurements, AttrPath, tablePath);
patternElement.appendChild(measurements);
patternElement.appendChild(createElement(TagIncrements));
@ -412,6 +413,79 @@ bool VPattern::GetActivNodeElement(const QString &name, QDomElement &element)
return false;
}
QString VPattern::MPath() const
{
QDomNodeList list = elementsByTagName(VPattern::TagMeasurements);
QDomElement element = list.at(0).toElement();
if (element.isElement())
{
return GetParametrString(element, AttrPath);
}
else
{
return QString();
}
}
Valentina::Units VPattern::MUnit() const
{
QDomNodeList list = elementsByTagName(VPattern::TagMeasurements);
QDomElement element = list.at(0).toElement();
if (element.isElement())
{
QStringList units;
units << "mm" << "cm" << "in";
QString unit = GetParametrString(element, AttrUnit);
switch(units.indexOf(unit))
{
case 0:// mm
return Valentina::Mm;
break;
case 1:// cm
return Valentina::Cm;
break;
case 2:// in
return Valentina::In;
break;
default:
return Valentina::Cm;
break;
}
}
else
{
return Valentina::Cm;
}
}
Pattern::Measurements VPattern::MType() const
{
QDomNodeList list = elementsByTagName(VPattern::TagMeasurements);
QDomElement element = list.at(0).toElement();
if (element.isElement())
{
QString type = GetParametrString(element, AttrType);
QStringList types;
types << "standard" << "individual";
switch(types.indexOf(type))
{
case 0:// standard
return Pattern::Standard;
break;
case 1:// individual
return Pattern::Individual;
break;
default:
return Pattern::Individual;
break;
}
}
else
{
return Pattern::Individual;
}
}
void VPattern::FullUpdateTree()
{
VMainGraphicsScene *scene = new VMainGraphicsScene();
@ -1263,7 +1337,7 @@ quint32 VPattern::GetParametrId(const QDomElement &domElement) const
QString message = tr("Got wrong parameter id. Need only id > 0.");
try
{
id = GetParametrUInt(domElement, VAbstractTool::AttrId, "0");
id = GetParametrUInt(domElement, VDomDocument::AttrId, "0");
if (id <= 0)
{
throw VExceptionWrongId(message, domElement);
@ -1280,7 +1354,7 @@ quint32 VPattern::GetParametrId(const QDomElement &domElement) const
void VPattern::CollectId(const QDomElement &node, QVector<quint32> &vector) const
{
if (node.hasAttribute(VAbstractTool::AttrId))
if (node.hasAttribute(VDomDocument::AttrId))
{
const quint32 id = GetParametrId(node);
if (vector.contains(id))

View File

@ -165,6 +165,9 @@ public:
* @return true if found.
*/
bool GetActivNodeElement(const QString& name, QDomElement& element);
QString MPath() const;
Valentina::Units MUnit() const;
Pattern::Measurements MType() const;
static const QString TagPattern;
static const QString TagCalculation;
static const QString TagModeling;
@ -183,6 +186,7 @@ public:
static const QString TagTools;
static const QString AttrName;
static const QString AttrType;
static const QString AttrPath;
static const QString IncrementName;
static const QString IncrementBase;
static const QString IncrementKsize;

View File

@ -29,19 +29,30 @@
#include "vstandardmeasurements.h"
#include <QDebug>
const QString VStandardMeasurements::TagMeasurement = QStringLiteral("measurement");
const QString VStandardMeasurements::TagDescription = QStringLiteral("description");
const QString VStandardMeasurements::TagSize = QStringLiteral("size");
const QString VStandardMeasurements::TagHeight = QStringLiteral("height");
const QString VStandardMeasurements::AttrName = QStringLiteral("name");
const QString VStandardMeasurements::AttrGui_text = QStringLiteral("gui_text");
const QString VStandardMeasurements::AttrBase = QStringLiteral("base");
const QString VStandardMeasurements::AttrSize_increace = QStringLiteral("size_increace");
const QString VStandardMeasurements::AttrHeight_increase = QStringLiteral("height_increase");
const QString VStandardMeasurements::AttrNumber = QStringLiteral("number");
VStandardMeasurements::VStandardMeasurements(VContainer *data):VDomDocument(data)
{
}
Valentina::Units VStandardMeasurements::Unit()
{
const QString unit = UniqueTagText("unit", "cm");
const QString unit = UniqueTagText(AttrUnit, UnitCM);
return VDomDocument::Units(unit);
}
QString VStandardMeasurements::Description()
{
const QString desc = UniqueTagText("description", "");
const QString desc = UniqueTagText(TagDescription, "");
if (desc.isEmpty())
{
qWarning()<<"Empty description in standard table."<<Q_FUNC_INFO;
@ -51,7 +62,7 @@ QString VStandardMeasurements::Description()
void VStandardMeasurements::Measurements()
{
const QDomNodeList nodeList = this->elementsByTagName("measurement");
const QDomNodeList nodeList = this->elementsByTagName(TagMeasurement);
if (nodeList.isEmpty())
{
qWarning()<<"Measurement list is empty"<<Q_FUNC_INFO;
@ -67,23 +78,23 @@ void VStandardMeasurements::Measurements()
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
const QString name = GetParametrString(domElement, "name", "");
const QString name = GetParametrString(domElement, AttrName, "");
if (name.isEmpty())
{
continue;
}
const QString gui_text = GetParametrString(domElement, "gui_text", "");
const qreal base = GetParametrDouble(domElement, "base", "0.0");
const qreal size_increace = GetParametrDouble(domElement, "size_increace", "0.0");
const qreal height_increase = GetParametrDouble(domElement, "height_increase", "0.0");
const QString number = GetParametrString(domElement, "number", "");
const QString gui_text = GetParametrString(domElement, AttrGui_text, "");
const qreal base = GetParametrDouble(domElement, AttrBase, "0.0");
const qreal size_increace = GetParametrDouble(domElement, AttrSize_increace, "0.0");
const qreal height_increase = GetParametrDouble(domElement, AttrHeight_increase, "0.0");
const QString number = GetParametrString(domElement, AttrNumber, "");
if (Unit() == Valentina::Mm)//Convert to Cm.
if (Unit() == Valentina::Mm)// Convert to Cm.
{
data->AddMeasurement(name, VMeasurement(base/10.0, size_increace/10.0, height_increase/10.0,
gui_text, number));
}
else//Cm or inch.
else// Cm or inch.
{
data->AddMeasurement(name, VMeasurement(base, size_increace, height_increase,
gui_text, number));
@ -96,7 +107,7 @@ void VStandardMeasurements::Measurements()
void VStandardMeasurements::SetSize()
{
const QDomNodeList nodeList = this->elementsByTagName("size");
const QDomNodeList nodeList = this->elementsByTagName(TagSize);
if (nodeList.isEmpty())
{
data->SetSize(50);
@ -110,14 +121,14 @@ void VStandardMeasurements::SetSize()
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
const QString name = GetParametrString(domElement, "name", "Сг");
const qreal base = GetParametrDouble(domElement, "base", "50.0");
if (Unit() == Valentina::Mm)//Convert to Cm.
const QString name = GetParametrString(domElement, AttrName, "Сг");
const qreal base = GetParametrDouble(domElement, AttrBase, "50.0");
if (Unit() == Valentina::Mm)// Convert to Cm.
{
data->SetSize(base/10.0);
data->SetSizeName(name);
}
else//Cm or inch.
else// Cm or inch.
{
data->SetSize(base);
data->SetSizeName(name);
@ -129,7 +140,7 @@ void VStandardMeasurements::SetSize()
void VStandardMeasurements::SetHeight()
{
const QDomNodeList nodeList = this->elementsByTagName("height");
const QDomNodeList nodeList = this->elementsByTagName(TagHeight);
if (nodeList.isEmpty())
{
data->SetHeight(176);
@ -143,14 +154,14 @@ void VStandardMeasurements::SetHeight()
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
const QString name = GetParametrString(domElement, "name", "Р");
const qreal base = GetParametrDouble(domElement, "base", "176.0");
if (Unit() == Valentina::Mm)//Convert to Cm.
const QString name = GetParametrString(domElement, AttrName, "Р");
const qreal base = GetParametrDouble(domElement, AttrBase, "176.0");
if (Unit() == Valentina::Mm)// Convert to Cm.
{
data->SetHeight(base/10.0);
data->SetHeightName(name);
}
else//Cm or inch.
else// Cm or inch.
{
data->SetHeight(base);
data->SetHeightName(name);

View File

@ -41,6 +41,16 @@ public:
void Measurements();
void SetSize();
void SetHeight();
static const QString TagMeasurement;
static const QString TagDescription;
static const QString TagSize;
static const QString TagHeight;
static const QString AttrName;
static const QString AttrGui_text;
static const QString AttrBase;
static const QString AttrSize_increace;
static const QString AttrHeight_increase;
static const QString AttrNumber;
public slots:
void Update();
};