After this commit begin testing.
--HG-- branch : feature
This commit is contained in:
parent
fa06c04cd2
commit
69309730ff
|
@ -29,14 +29,23 @@
|
||||||
#include "vmeasurement.h"
|
#include "vmeasurement.h"
|
||||||
|
|
||||||
VMeasurement::VMeasurement()
|
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,
|
VMeasurement::VMeasurement(const qreal &base, const qreal &ksize, const qreal &kgrowth,
|
||||||
const QString &gui_text, const QString &number)
|
const QString &gui_text, const QString &number, const QString &tagName)
|
||||||
:base(base), ksize(ksize), kheight(kgrowth), gui_text(gui_text), number(number){}
|
: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;
|
const qreal k_height = ( height - 176.0 ) / 6.0;
|
||||||
return base + k_size * ksize + k_height * kheight;
|
return base + k_size * ksize + k_height * kheight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,15 +49,17 @@ public:
|
||||||
* @param description description of increment
|
* @param description description of increment
|
||||||
*/
|
*/
|
||||||
VMeasurement(const qreal &base, const qreal &ksize, const qreal &kheight,
|
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(),
|
VMeasurement(const qreal &base, const QString &gui_text = QString(),
|
||||||
const QString &number = QString());
|
const QString &number = QString(), const QString &TagName = QString());
|
||||||
~VMeasurement(){}
|
~VMeasurement(){}
|
||||||
/**
|
/**
|
||||||
* @brief GetBase return value in base size and growth
|
* @brief GetBase return value in base size and growth
|
||||||
* @return value
|
* @return value
|
||||||
*/
|
*/
|
||||||
qreal GetBase() const;
|
qreal GetBase() const;
|
||||||
|
void setBase(const qreal &value);
|
||||||
/**
|
/**
|
||||||
* @brief GetKsize return increment in sizes
|
* @brief GetKsize return increment in sizes
|
||||||
* @return increment
|
* @return increment
|
||||||
|
@ -76,6 +78,10 @@ public:
|
||||||
QString GetNumber() const;
|
QString GetNumber() const;
|
||||||
qreal GetValue() const;
|
qreal GetValue() const;
|
||||||
qreal GetValue(const qreal &size, const qreal &height) 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:
|
private:
|
||||||
/**
|
/**
|
||||||
* @brief base value in base size and growth
|
* @brief base value in base size and growth
|
||||||
|
@ -94,6 +100,8 @@ private:
|
||||||
*/
|
*/
|
||||||
QString gui_text;
|
QString gui_text;
|
||||||
QString number;
|
QString number;
|
||||||
|
bool virtualM;
|
||||||
|
QString _tagName;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline qreal VMeasurement::GetBase() const
|
inline qreal VMeasurement::GetBase() const
|
||||||
|
@ -101,6 +109,11 @@ inline qreal VMeasurement::GetBase() const
|
||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void VMeasurement::setBase(const qreal &value)
|
||||||
|
{
|
||||||
|
base = value;
|
||||||
|
}
|
||||||
|
|
||||||
inline qreal VMeasurement::GetKsize() const
|
inline qreal VMeasurement::GetKsize() const
|
||||||
{
|
{
|
||||||
return ksize;
|
return ksize;
|
||||||
|
@ -121,4 +134,24 @@ inline QString VMeasurement::GetNumber() const
|
||||||
return number;
|
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
|
#endif // VSTANDARDTABLEROW_H
|
||||||
|
|
|
@ -33,17 +33,18 @@
|
||||||
#include "../../exception/vexception.h"
|
#include "../../exception/vexception.h"
|
||||||
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *parent)
|
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);
|
ui->setupUi(this);
|
||||||
TextDelegate *textDelegate = new TextDelegate(ui->tableWidgetIncrement);
|
TextDelegate *textDelegate = new TextDelegate(ui->tableWidgetIncrement);
|
||||||
ui->tableWidgetIncrement->setItemDelegateForColumn(0, textDelegate);
|
ui->tableWidgetIncrement->setItemDelegateForColumn(0, textDelegate);// name
|
||||||
DoubleSpinBoxDelegate *doubleDelegate = new DoubleSpinBoxDelegate(ui->tableWidgetIncrement);
|
DoubleSpinBoxDelegate *doubleDelegate = new DoubleSpinBoxDelegate(ui->tableWidgetIncrement);
|
||||||
ui->tableWidgetIncrement->setItemDelegateForColumn(2, doubleDelegate);
|
ui->tableWidgetIncrement->setItemDelegateForColumn(2, doubleDelegate);// base value
|
||||||
ui->tableWidgetIncrement->setItemDelegateForColumn(3, doubleDelegate);
|
ui->tableWidgetIncrement->setItemDelegateForColumn(3, doubleDelegate);// in sizes
|
||||||
ui->tableWidgetIncrement->setItemDelegateForColumn(4, doubleDelegate);
|
ui->tableWidgetIncrement->setItemDelegateForColumn(4, doubleDelegate);// in heights
|
||||||
|
|
||||||
if (qApp->patternType() == Pattern::Standard)
|
if (qApp->patternType() == Pattern::Standard)
|
||||||
{
|
{
|
||||||
|
@ -58,16 +59,15 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui->tableWidgetMeasurements->setColumnHidden( 1, true );
|
ui->tableWidgetMeasurements->setColumnHidden( 1, true );// calculated value
|
||||||
ui->tableWidgetMeasurements->setColumnHidden( 3, true );
|
ui->tableWidgetMeasurements->setColumnHidden( 3, true );// in sizes
|
||||||
ui->tableWidgetMeasurements->setColumnHidden( 4, true );
|
ui->tableWidgetMeasurements->setColumnHidden( 4, true );// in heights
|
||||||
|
|
||||||
ui->tableWidgetIncrement->setColumnHidden( 1, true );
|
ui->tableWidgetIncrement->setColumnHidden( 1, true );// calculated value
|
||||||
ui->tableWidgetIncrement->setColumnHidden( 3, true );
|
ui->tableWidgetIncrement->setColumnHidden( 3, true );// in sizes
|
||||||
ui->tableWidgetIncrement->setColumnHidden( 4, true );
|
ui->tableWidgetIncrement->setColumnHidden( 4, true );// in heights
|
||||||
|
|
||||||
ui->tableWidgetMeasurements->setItemDelegateForColumn(0, textDelegate);
|
ui->tableWidgetMeasurements->setItemDelegateForColumn(2, doubleDelegate);// base value
|
||||||
ui->tableWidgetMeasurements->setItemDelegateForColumn(2, doubleDelegate);
|
|
||||||
|
|
||||||
connect(ui->tableWidgetMeasurements, &QTableWidget::cellChanged, this, &DialogIncrements::MeasurementsChanged);
|
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);
|
connect(this->doc, &VPattern::FullUpdateFromFile, this, &DialogIncrements::FullUpdateFromFile);
|
||||||
|
|
||||||
ui->tabWidget->setCurrentIndex(0);
|
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()
|
void DialogIncrements::FillMeasurements()
|
||||||
{
|
{
|
||||||
const QHash<QString, VMeasurement> *table = data->DataMeasurements();
|
const QHash<QString, VMeasurement> *table = data->DataMeasurements();
|
||||||
qint32 currentRow = -1;
|
|
||||||
QHashIterator<QString, VMeasurement> i(*table);
|
QHashIterator<QString, VMeasurement> i(*table);
|
||||||
ui->tableWidgetMeasurements->setRowCount ( table->size() );
|
QMap<QString, VMeasurement> map;
|
||||||
|
//Sorting QHash by id
|
||||||
while (i.hasNext())
|
while (i.hasNext())
|
||||||
{
|
{
|
||||||
i.next();
|
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++;
|
currentRow++;
|
||||||
|
|
||||||
QTableWidgetItem *item = new QTableWidgetItem(QString(i.key()));
|
QTableWidgetItem *item = new QTableWidgetItem(QString(iMap.key()));
|
||||||
item->setTextAlignment(Qt::AlignHCenter);
|
item->setTextAlignment(Qt::AlignHCenter);
|
||||||
item->setFont(QFont("Times", 12, QFont::Bold));
|
item->setFont(QFont("Times", 12, QFont::Bold));
|
||||||
item->setToolTip(m.GetDescription());
|
item->setToolTip(m.GetDescription());
|
||||||
|
@ -109,7 +154,7 @@ void DialogIncrements::FillMeasurements()
|
||||||
|
|
||||||
if (qApp->patternType() == Pattern::Standard)
|
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);
|
item->setTextAlignment(Qt::AlignHCenter);
|
||||||
ui->tableWidgetMeasurements->setItem(currentRow, 1, item);
|
ui->tableWidgetMeasurements->setItem(currentRow, 1, item);
|
||||||
}
|
}
|
||||||
|
@ -133,9 +178,9 @@ void DialogIncrements::FillMeasurements()
|
||||||
item->setTextAlignment(Qt::AlignHCenter);
|
item->setTextAlignment(Qt::AlignHCenter);
|
||||||
ui->tableWidgetMeasurements->setItem(currentRow, 5, item);
|
ui->tableWidgetMeasurements->setItem(currentRow, 5, item);
|
||||||
}
|
}
|
||||||
|
ui->tableWidgetMeasurements->verticalHeader()->setDefaultSectionSize(20);
|
||||||
ui->tableWidgetMeasurements->resizeColumnsToContents();
|
ui->tableWidgetMeasurements->resizeColumnsToContents();
|
||||||
ui->tableWidgetMeasurements->resizeRowsToContents();
|
ui->tableWidgetMeasurements->resizeRowsToContents();
|
||||||
ui->tableWidgetMeasurements->verticalHeader()->setDefaultSectionSize(20);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogIncrements::FillIncrements()
|
void DialogIncrements::FillIncrements()
|
||||||
|
@ -305,21 +350,20 @@ void DialogIncrements::FillLengthArcs()
|
||||||
item->setTextAlignment(Qt::AlignHCenter);
|
item->setTextAlignment(Qt::AlignHCenter);
|
||||||
ui->tableWidgetArcs->setItem(currentRow, 1, item);
|
ui->tableWidgetArcs->setItem(currentRow, 1, item);
|
||||||
}
|
}
|
||||||
|
ui->tableWidgetArcs->verticalHeader()->setDefaultSectionSize(20);
|
||||||
ui->tableWidgetArcs->resizeColumnsToContents();
|
ui->tableWidgetArcs->resizeColumnsToContents();
|
||||||
ui->tableWidgetArcs->resizeRowsToContents();
|
ui->tableWidgetArcs->resizeRowsToContents();
|
||||||
ui->tableWidgetArcs->verticalHeader()->setDefaultSectionSize(20);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogIncrements::FullUpdateFromFile()
|
void DialogIncrements::FullUpdateFromFile()
|
||||||
{
|
{
|
||||||
disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
|
|
||||||
&DialogIncrements::IncrementChanged);
|
|
||||||
|
|
||||||
ui->tableWidgetMeasurements->clearContents();
|
ui->tableWidgetMeasurements->clearContents();
|
||||||
FillMeasurements();
|
FillMeasurements();
|
||||||
|
|
||||||
|
disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, &DialogIncrements::IncrementChanged);
|
||||||
ui->tableWidgetIncrement->clearContents();
|
ui->tableWidgetIncrement->clearContents();
|
||||||
FillIncrements();
|
FillIncrements();
|
||||||
|
connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, &DialogIncrements::IncrementChanged);
|
||||||
|
|
||||||
ui->tableWidgetLines->clearContents();
|
ui->tableWidgetLines->clearContents();
|
||||||
FillLengthLines();
|
FillLengthLines();
|
||||||
|
@ -329,9 +373,6 @@ void DialogIncrements::FullUpdateFromFile()
|
||||||
|
|
||||||
ui->tableWidgetArcs->clearContents();
|
ui->tableWidgetArcs->clearContents();
|
||||||
FillLengthArcs();
|
FillLengthArcs();
|
||||||
|
|
||||||
connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this,
|
|
||||||
&DialogIncrements::IncrementChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogIncrements::clickedToolButtonAdd()
|
void DialogIncrements::clickedToolButtonAdd()
|
||||||
|
@ -350,15 +391,12 @@ void DialogIncrements::clickedToolButtonAdd()
|
||||||
num++;
|
num++;
|
||||||
} while (data->IncrementTableContains(name));
|
} while (data->IncrementTableContains(name));
|
||||||
|
|
||||||
quint32 id = data->getNextId();
|
const quint32 id = data->getNextId();
|
||||||
qreal base = 0;
|
const QString description(tr("Description"));
|
||||||
qreal ksize = 0;
|
VIncrement incr = VIncrement(id, 0, 0, 0, description);
|
||||||
qreal kgrowth = 0;
|
|
||||||
QString description = QString(tr("Description"));
|
|
||||||
VIncrement incr = VIncrement(id, base, ksize, kgrowth, description);
|
|
||||||
data->AddIncrement(name, incr);
|
data->AddIncrement(name, incr);
|
||||||
|
|
||||||
AddIncrementToFile(id, name, base, ksize, kgrowth, description);
|
AddIncrementToFile(id, name, 0, 0, 0, description);
|
||||||
|
|
||||||
QTableWidgetItem *item = new QTableWidgetItem(name);
|
QTableWidgetItem *item = new QTableWidgetItem(name);
|
||||||
item->setTextAlignment(Qt::AlignHCenter);
|
item->setTextAlignment(Qt::AlignHCenter);
|
||||||
|
@ -367,7 +405,7 @@ void DialogIncrements::clickedToolButtonAdd()
|
||||||
ui->tableWidgetIncrement->setItem(currentRow, 0, item);
|
ui->tableWidgetIncrement->setItem(currentRow, 0, item);
|
||||||
ui->tableWidgetIncrement->setCurrentCell(currentRow, 0, QItemSelectionModel::ClearAndSelect);
|
ui->tableWidgetIncrement->setCurrentCell(currentRow, 0, QItemSelectionModel::ClearAndSelect);
|
||||||
|
|
||||||
item = new QTableWidgetItem("0");
|
item = new QTableWidgetItem("0");// calculated value
|
||||||
item->setTextAlignment(Qt::AlignHCenter);
|
item->setTextAlignment(Qt::AlignHCenter);
|
||||||
// set the item non-editable (view only), and non-selectable
|
// set the item non-editable (view only), and non-selectable
|
||||||
Qt::ItemFlags flags = item->flags();
|
Qt::ItemFlags flags = item->flags();
|
||||||
|
@ -375,19 +413,19 @@ void DialogIncrements::clickedToolButtonAdd()
|
||||||
item->setFlags(flags);
|
item->setFlags(flags);
|
||||||
ui->tableWidgetIncrement->setItem(currentRow, 1, item);
|
ui->tableWidgetIncrement->setItem(currentRow, 1, item);
|
||||||
|
|
||||||
item = new QTableWidgetItem("0");
|
item = new QTableWidgetItem("0");// base value
|
||||||
item->setTextAlignment(Qt::AlignHCenter);
|
item->setTextAlignment(Qt::AlignHCenter);
|
||||||
ui->tableWidgetIncrement->setItem(currentRow, 2, item);
|
ui->tableWidgetIncrement->setItem(currentRow, 2, item);
|
||||||
|
|
||||||
item = new QTableWidgetItem("0");
|
item = new QTableWidgetItem("0");// in sizes
|
||||||
item->setTextAlignment(Qt::AlignHCenter);
|
item->setTextAlignment(Qt::AlignHCenter);
|
||||||
ui->tableWidgetIncrement->setItem(currentRow, 3, item);
|
ui->tableWidgetIncrement->setItem(currentRow, 3, item);
|
||||||
|
|
||||||
item = new QTableWidgetItem("0");
|
item = new QTableWidgetItem("0"); // in heights
|
||||||
item->setTextAlignment(Qt::AlignHCenter);
|
item->setTextAlignment(Qt::AlignHCenter);
|
||||||
ui->tableWidgetIncrement->setItem(currentRow, 4, item);
|
ui->tableWidgetIncrement->setItem(currentRow, 4, item);
|
||||||
|
|
||||||
item = new QTableWidgetItem(tr("Description"));
|
item = new QTableWidgetItem(description);
|
||||||
item->setTextAlignment(Qt::AlignHCenter);
|
item->setTextAlignment(Qt::AlignHCenter);
|
||||||
ui->tableWidgetIncrement->setItem(currentRow, 5, item);
|
ui->tableWidgetIncrement->setItem(currentRow, 5, item);
|
||||||
|
|
||||||
|
@ -409,7 +447,7 @@ void DialogIncrements::clickedToolButtonRemove()
|
||||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
if (domElement.isElement())
|
if (domElement.isElement())
|
||||||
{
|
{
|
||||||
QDomNodeList list = doc->elementsByTagName("increments");
|
QDomNodeList list = doc->elementsByTagName(VPattern::TagIncrements);
|
||||||
list.at(0).removeChild(domElement);
|
list.at(0).removeChild(domElement);
|
||||||
}
|
}
|
||||||
ui->tableWidgetIncrement->removeRow(row);
|
ui->tableWidgetIncrement->removeRow(row);
|
||||||
|
@ -422,134 +460,115 @@ void DialogIncrements::clickedToolButtonRemove()
|
||||||
emit haveLiteChange();
|
emit haveLiteChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogIncrements::AddIncrementToFile(quint32 id, QString name, qreal base, qreal ksize, qreal kgrowth,
|
void DialogIncrements::AddIncrementToFile(const quint32 &id, const QString &name, const qreal &base, const qreal &ksize,
|
||||||
QString description)
|
const qreal &kheight, const QString &description)
|
||||||
{
|
{
|
||||||
QDomNodeList list = doc->elementsByTagName("increments");
|
QDomElement element = doc->createElement(VPattern::TagIncrement);
|
||||||
QDomElement element = doc->createElement("increment");
|
|
||||||
|
|
||||||
QDomAttr drawAttr = doc->createAttribute("id");
|
doc->SetAttribute(element, VDomDocument::AttrId, id);
|
||||||
drawAttr.setValue(QString().setNum(id));
|
doc->SetAttribute(element, VPattern::IncrementName, name);
|
||||||
element.setAttributeNode(drawAttr);
|
doc->SetAttribute(element, VPattern::IncrementBase, base);
|
||||||
|
doc->SetAttribute(element, VPattern::IncrementKsize, ksize);
|
||||||
drawAttr = doc->createAttribute("name");
|
doc->SetAttribute(element, VPattern::IncrementKgrowth, kheight);
|
||||||
drawAttr.setValue(name);
|
doc->SetAttribute(element, VPattern::IncrementDescription, description);
|
||||||
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);
|
|
||||||
|
|
||||||
|
QDomNodeList list = doc->elementsByTagName(VPattern::TagIncrements);
|
||||||
list.at(0).appendChild(element);
|
list.at(0).appendChild(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogIncrements::IncrementChanged ( qint32 row, qint32 column )
|
void DialogIncrements::IncrementChanged ( qint32 row, qint32 column )
|
||||||
{
|
{
|
||||||
QTableWidgetItem *item = nullptr;
|
|
||||||
QTableWidgetItem *itemName = nullptr;
|
const QTableWidgetItem *itemName = ui->tableWidgetIncrement->item(row, 0);
|
||||||
quint32 id;
|
const QTableWidgetItem *item = ui->tableWidgetIncrement->item(row, column);
|
||||||
QDomElement domElement;
|
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;
|
this->row = row;
|
||||||
switch (column)
|
switch (column)
|
||||||
{
|
{
|
||||||
case 0: // name
|
case 0: // VPattern::IncrementName
|
||||||
item = ui->tableWidgetIncrement->item(row, 0);
|
doc->SetAttribute(domElement, VPattern::IncrementName, item->text());
|
||||||
id = qvariant_cast<quint32>(item->data(Qt::UserRole));
|
|
||||||
domElement = doc->elementById(QString().setNum(id));
|
|
||||||
if (domElement.isElement())
|
|
||||||
{
|
|
||||||
domElement.setAttribute("name", item->text());
|
|
||||||
data->ClearIncrementTable();
|
data->ClearIncrementTable();
|
||||||
this->column = 2;
|
this->column = 2;
|
||||||
emit FullUpdateTree();
|
emit FullUpdateTree();
|
||||||
emit haveLiteChange();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 2: // base
|
case 2: // VPattern::IncrementBase
|
||||||
itemName = ui->tableWidgetIncrement->item(row, 0);
|
doc->SetAttribute(domElement, VPattern::IncrementBase, item->text());
|
||||||
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;
|
this->column = 3;
|
||||||
emit FullUpdateTree();
|
emit FullUpdateTree();
|
||||||
emit haveLiteChange();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw VException(tr("Can't convert toDouble value."));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 3: // ksize
|
case 3: // VPattern::IncrementKsize
|
||||||
itemName = ui->tableWidgetIncrement->item(row, 0);
|
doc->SetAttribute(domElement, VPattern::IncrementKsize, item->text());
|
||||||
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;
|
this->column = 4;
|
||||||
emit FullUpdateTree();
|
emit FullUpdateTree();
|
||||||
emit haveLiteChange();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 4: // kgrowth
|
case 4: // VPattern::IncrementKgrowth
|
||||||
itemName = ui->tableWidgetIncrement->item(row, 0);
|
doc->SetAttribute(domElement, VPattern::IncrementKgrowth, item->text());
|
||||||
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;
|
this->column = 5;
|
||||||
emit FullUpdateTree();
|
emit FullUpdateTree();
|
||||||
emit haveLiteChange();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 5: // description
|
case 5: // VPattern::IncrementDescription
|
||||||
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());
|
doc->SetAttribute(domElement, VPattern::IncrementDescription, item->text());
|
||||||
VIncrement incr = data->GetIncrement(itemName->text());
|
VIncrement incr = data->GetIncrement(itemName->text());
|
||||||
incr.setDescription(item->text());
|
incr.setDescription(item->text());
|
||||||
data->UpdateIncrement(itemName->text(), incr);
|
data->UpdateIncrement(itemName->text(), incr);
|
||||||
ui->tableWidgetIncrement->resizeColumnsToContents();
|
ui->tableWidgetIncrement->resizeColumnsToContents();
|
||||||
ui->tableWidgetIncrement->resizeRowsToContents();
|
ui->tableWidgetIncrement->resizeRowsToContents();
|
||||||
ui->tableWidgetIncrement->setCurrentCell( row, 0 );
|
this->column = 0;
|
||||||
emit haveLiteChange();
|
ui->tableWidgetIncrement->setCurrentCell( row, this->column );
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
emit haveLiteChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogIncrements::MeasurementsChanged(qint32 row, qint32 column)
|
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)
|
void DialogIncrements::closeEvent(QCloseEvent *event)
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include "../tools/dialogtool.h"
|
#include "../tools/dialogtool.h"
|
||||||
#include "../../xml/vpattern.h"
|
#include "../../xml/vpattern.h"
|
||||||
|
#include "../../xml/vindividualmeasurements.h"
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
|
@ -105,6 +106,7 @@ private:
|
||||||
* @brief column save number of column current selected cell
|
* @brief column save number of column current selected cell
|
||||||
*/
|
*/
|
||||||
qint32 column;
|
qint32 column;
|
||||||
|
VIndividualMeasurements *m;
|
||||||
/**
|
/**
|
||||||
* @brief FillMeasurements load measurements data
|
* @brief FillMeasurements load measurements data
|
||||||
*/
|
*/
|
||||||
|
@ -131,11 +133,11 @@ private:
|
||||||
* @param name name
|
* @param name name
|
||||||
* @param base base value
|
* @param base base value
|
||||||
* @param ksize increment in sizes
|
* @param ksize increment in sizes
|
||||||
* @param kgrowth increment in growths
|
* @param kheight increment in heights
|
||||||
* @param description description of increment
|
* @param description description of increment
|
||||||
*/
|
*/
|
||||||
void AddIncrementToFile(quint32 id, QString name, qreal base, qreal ksize, qreal kgrowth,
|
void AddIncrementToFile(const quint32 &id, const QString &name, const qreal &base,
|
||||||
QString description);
|
const qreal &ksize, const qreal &kheight, const QString &description);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DIALOGINCREMENTS_H
|
#endif // DIALOGINCREMENTS_H
|
||||||
|
|
|
@ -217,7 +217,7 @@ void DialogIndividualMeasurements::LoadIndividualTables()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
VDomDocument::ValidatePattern("://schema/standard_measurements.xsd", allFiles.at(i));
|
VDomDocument::ValidatePattern("://schema/individual_measurements.xsd", allFiles.at(i));
|
||||||
}
|
}
|
||||||
catch(VException &e)
|
catch(VException &e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -49,8 +49,9 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
:QMainWindow(parent), ui(new Ui::MainWindow), pattern(nullptr), doc(nullptr), tool(Valentina::ArrowTool),
|
:QMainWindow(parent), ui(new Ui::MainWindow), pattern(nullptr), doc(nullptr), tool(Valentina::ArrowTool),
|
||||||
currentScene(nullptr), sceneDraw(nullptr), sceneDetails(nullptr), mouseCoordinate(nullptr), helpLabel(nullptr),
|
currentScene(nullptr), sceneDraw(nullptr), sceneDetails(nullptr), mouseCoordinate(nullptr), helpLabel(nullptr),
|
||||||
view(nullptr), isInitialized(false), dialogTable(0), dialogTool(nullptr), dialogHistory(nullptr),
|
view(nullptr), isInitialized(false), dialogTable(0), dialogTool(nullptr), dialogHistory(nullptr),
|
||||||
comboBoxDraws(nullptr), curFile(QString()), mode(Valentina::Calculation), currentDrawIndex(0), currentToolBoxIndex(0),
|
comboBoxDraws(nullptr), curFile(QString()), mode(Valentina::Calculation), currentDrawIndex(0),
|
||||||
drawMode(true), recentFileActs{0, 0, 0, 0, 0}, separatorAct(nullptr), autoSaveTimer(nullptr)
|
currentToolBoxIndex(0), drawMode(true), recentFileActs{0, 0, 0, 0, 0}, separatorAct(nullptr),
|
||||||
|
autoSaveTimer(nullptr)
|
||||||
{
|
{
|
||||||
CreateActions();
|
CreateActions();
|
||||||
CreateMenus();
|
CreateMenus();
|
||||||
|
|
|
@ -84,7 +84,7 @@ void VToolAlongLine::AddToFile()
|
||||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||||
QDomElement domElement = doc->createElement(TagName);
|
QDomElement domElement = doc->createElement(TagName);
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrId, id);
|
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
|
||||||
doc->SetAttribute(domElement, AttrType, ToolType);
|
doc->SetAttribute(domElement, AttrType, ToolType);
|
||||||
doc->SetAttribute(domElement, AttrName, point->name());
|
doc->SetAttribute(domElement, AttrName, point->name());
|
||||||
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
||||||
|
|
|
@ -182,7 +182,7 @@ void VToolArc::AddToFile()
|
||||||
const VArc *arc = VAbstractTool::data.GeometricObject<const VArc *>(id);
|
const VArc *arc = VAbstractTool::data.GeometricObject<const VArc *>(id);
|
||||||
QDomElement domElement = doc->createElement(TagName);
|
QDomElement domElement = doc->createElement(TagName);
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrId, id);
|
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
|
||||||
doc->SetAttribute(domElement, AttrType, ToolType);
|
doc->SetAttribute(domElement, AttrType, ToolType);
|
||||||
doc->SetAttribute(domElement, AttrCenter, arc->GetCenter().id());
|
doc->SetAttribute(domElement, AttrCenter, arc->GetCenter().id());
|
||||||
doc->SetAttribute(domElement, AttrRadius, arc->GetFormulaRadius());
|
doc->SetAttribute(domElement, AttrRadius, arc->GetFormulaRadius());
|
||||||
|
|
|
@ -182,7 +182,7 @@ void VToolBisector::AddToFile()
|
||||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||||
QDomElement domElement = doc->createElement(TagName);
|
QDomElement domElement = doc->createElement(TagName);
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrId, id);
|
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
|
||||||
doc->SetAttribute(domElement, AttrType, ToolType);
|
doc->SetAttribute(domElement, AttrType, ToolType);
|
||||||
doc->SetAttribute(domElement, AttrName, point->name());
|
doc->SetAttribute(domElement, AttrName, point->name());
|
||||||
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
||||||
|
|
|
@ -205,7 +205,7 @@ void VToolCutArc::AddToFile()
|
||||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||||
QDomElement domElement = doc->createElement(TagName);
|
QDomElement domElement = doc->createElement(TagName);
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrId, id);
|
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
|
||||||
doc->SetAttribute(domElement, AttrType, ToolType);
|
doc->SetAttribute(domElement, AttrType, ToolType);
|
||||||
doc->SetAttribute(domElement, AttrName, point->name());
|
doc->SetAttribute(domElement, AttrName, point->name());
|
||||||
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
||||||
|
|
|
@ -201,7 +201,7 @@ void VToolCutSpline::AddToFile()
|
||||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||||
QDomElement domElement = doc->createElement(TagName);
|
QDomElement domElement = doc->createElement(TagName);
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrId, id);
|
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
|
||||||
doc->SetAttribute(domElement, AttrType, ToolType);
|
doc->SetAttribute(domElement, AttrType, ToolType);
|
||||||
doc->SetAttribute(domElement, AttrName, point->name());
|
doc->SetAttribute(domElement, AttrName, point->name());
|
||||||
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
||||||
|
|
|
@ -275,7 +275,7 @@ void VToolCutSplinePath::AddToFile()
|
||||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||||
QDomElement domElement = doc->createElement(TagName);
|
QDomElement domElement = doc->createElement(TagName);
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrId, id);
|
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
|
||||||
doc->SetAttribute(domElement, AttrType, ToolType);
|
doc->SetAttribute(domElement, AttrType, ToolType);
|
||||||
doc->SetAttribute(domElement, AttrName, point->name());
|
doc->SetAttribute(domElement, AttrName, point->name());
|
||||||
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
||||||
|
|
|
@ -148,7 +148,7 @@ void VToolEndLine::AddToFile()
|
||||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||||
QDomElement domElement = doc->createElement(TagName);
|
QDomElement domElement = doc->createElement(TagName);
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrId, id);
|
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
|
||||||
doc->SetAttribute(domElement, AttrType, ToolType);
|
doc->SetAttribute(domElement, AttrType, ToolType);
|
||||||
doc->SetAttribute(domElement, AttrName, point->name());
|
doc->SetAttribute(domElement, AttrName, point->name());
|
||||||
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
||||||
|
|
|
@ -154,7 +154,7 @@ void VToolHeight::AddToFile()
|
||||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||||
QDomElement domElement = doc->createElement(TagName);
|
QDomElement domElement = doc->createElement(TagName);
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrId, id);
|
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
|
||||||
doc->SetAttribute(domElement, AttrType, ToolType);
|
doc->SetAttribute(domElement, AttrType, ToolType);
|
||||||
doc->SetAttribute(domElement, AttrName, point->name());
|
doc->SetAttribute(domElement, AttrName, point->name());
|
||||||
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
||||||
|
|
|
@ -155,7 +155,7 @@ void VToolLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||||
void VToolLine::AddToFile()
|
void VToolLine::AddToFile()
|
||||||
{
|
{
|
||||||
QDomElement domElement = doc->createElement(TagName);
|
QDomElement domElement = doc->createElement(TagName);
|
||||||
doc->SetAttribute(domElement, AttrId, id);
|
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
|
||||||
doc->SetAttribute(domElement, AttrFirstPoint, firstPoint);
|
doc->SetAttribute(domElement, AttrFirstPoint, firstPoint);
|
||||||
doc->SetAttribute(domElement, AttrSecondPoint, secondPoint);
|
doc->SetAttribute(domElement, AttrSecondPoint, secondPoint);
|
||||||
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
|
doc->SetAttribute(domElement, AttrTypeLine, typeLine);
|
||||||
|
|
|
@ -165,7 +165,7 @@ void VToolLineIntersect::AddToFile()
|
||||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||||
QDomElement domElement = doc->createElement(TagName);
|
QDomElement domElement = doc->createElement(TagName);
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrId, id);
|
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
|
||||||
doc->SetAttribute(domElement, AttrType, ToolType);
|
doc->SetAttribute(domElement, AttrType, ToolType);
|
||||||
doc->SetAttribute(domElement, AttrName, point->name());
|
doc->SetAttribute(domElement, AttrName, point->name());
|
||||||
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
||||||
|
|
|
@ -168,7 +168,7 @@ void VToolNormal::AddToFile()
|
||||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||||
QDomElement domElement = doc->createElement(TagName);
|
QDomElement domElement = doc->createElement(TagName);
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrId, id);
|
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
|
||||||
doc->SetAttribute(domElement, AttrType, ToolType);
|
doc->SetAttribute(domElement, AttrType, ToolType);
|
||||||
doc->SetAttribute(domElement, AttrName, point->name());
|
doc->SetAttribute(domElement, AttrName, point->name());
|
||||||
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
||||||
|
|
|
@ -188,7 +188,7 @@ void VToolPointOfContact::AddToFile()
|
||||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||||
QDomElement domElement = doc->createElement(TagName);
|
QDomElement domElement = doc->createElement(TagName);
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrId, id);
|
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
|
||||||
doc->SetAttribute(domElement, AttrType, ToolType);
|
doc->SetAttribute(domElement, AttrType, ToolType);
|
||||||
doc->SetAttribute(domElement, AttrName, point->name());
|
doc->SetAttribute(domElement, AttrName, point->name());
|
||||||
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
||||||
|
|
|
@ -138,7 +138,7 @@ void VToolPointOfIntersection::AddToFile()
|
||||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||||
QDomElement domElement = doc->createElement(TagName);
|
QDomElement domElement = doc->createElement(TagName);
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrId, id);
|
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
|
||||||
doc->SetAttribute(domElement, AttrType, ToolType);
|
doc->SetAttribute(domElement, AttrType, ToolType);
|
||||||
doc->SetAttribute(domElement, AttrName, point->name());
|
doc->SetAttribute(domElement, AttrName, point->name());
|
||||||
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
||||||
|
|
|
@ -190,7 +190,7 @@ void VToolShoulderPoint::AddToFile()
|
||||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||||
QDomElement domElement = doc->createElement(TagName);
|
QDomElement domElement = doc->createElement(TagName);
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrId, id);
|
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
|
||||||
doc->SetAttribute(domElement, AttrType, ToolType);
|
doc->SetAttribute(domElement, AttrType, ToolType);
|
||||||
doc->SetAttribute(domElement, AttrName, point->name());
|
doc->SetAttribute(domElement, AttrName, point->name());
|
||||||
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
||||||
|
|
|
@ -66,7 +66,7 @@ void VToolSinglePoint::AddToFile()
|
||||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||||
QDomElement domElement = doc->createElement(TagName);
|
QDomElement domElement = doc->createElement(TagName);
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrId, id);
|
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
|
||||||
doc->SetAttribute(domElement, AttrType, ToolType);
|
doc->SetAttribute(domElement, AttrType, ToolType);
|
||||||
doc->SetAttribute(domElement, AttrName, point->name());
|
doc->SetAttribute(domElement, AttrName, point->name());
|
||||||
doc->SetAttribute(domElement, AttrX, qApp->fromPixel(point->x()));
|
doc->SetAttribute(domElement, AttrX, qApp->fromPixel(point->x()));
|
||||||
|
|
|
@ -176,7 +176,7 @@ void VToolSpline::AddToFile()
|
||||||
const VSpline *spl = VAbstractTool::data.GeometricObject<const VSpline *>(id);
|
const VSpline *spl = VAbstractTool::data.GeometricObject<const VSpline *>(id);
|
||||||
QDomElement domElement = doc->createElement(TagName);
|
QDomElement domElement = doc->createElement(TagName);
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrId, id);
|
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
|
||||||
doc->SetAttribute(domElement, AttrType, ToolType);
|
doc->SetAttribute(domElement, AttrType, ToolType);
|
||||||
doc->SetAttribute(domElement, AttrPoint1, spl->GetP1().id());
|
doc->SetAttribute(domElement, AttrPoint1, spl->GetP1().id());
|
||||||
doc->SetAttribute(domElement, AttrPoint4, spl->GetP4().id());
|
doc->SetAttribute(domElement, AttrPoint4, spl->GetP4().id());
|
||||||
|
|
|
@ -214,7 +214,7 @@ void VToolSplinePath::AddToFile()
|
||||||
VSplinePath splPath = *VAbstractTool::data.GeometricObject<const VSplinePath *>(id);
|
VSplinePath splPath = *VAbstractTool::data.GeometricObject<const VSplinePath *>(id);
|
||||||
QDomElement domElement = doc->createElement(TagName);
|
QDomElement domElement = doc->createElement(TagName);
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrId, id);
|
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
|
||||||
doc->SetAttribute(domElement, AttrType, ToolType);
|
doc->SetAttribute(domElement, AttrType, ToolType);
|
||||||
doc->SetAttribute(domElement, AttrKCurve, splPath.getKCurve());
|
doc->SetAttribute(domElement, AttrKCurve, splPath.getKCurve());
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,7 @@ void VToolTriangle::AddToFile()
|
||||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||||
QDomElement domElement = doc->createElement(TagName);
|
QDomElement domElement = doc->createElement(TagName);
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrId, id);
|
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
|
||||||
doc->SetAttribute(domElement, AttrType, ToolType);
|
doc->SetAttribute(domElement, AttrType, ToolType);
|
||||||
doc->SetAttribute(domElement, AttrName, point->name());
|
doc->SetAttribute(domElement, AttrName, point->name());
|
||||||
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
||||||
|
|
|
@ -93,7 +93,7 @@ void VNodeArc::AddToFile()
|
||||||
{
|
{
|
||||||
QDomElement domElement = doc->createElement(TagName);
|
QDomElement domElement = doc->createElement(TagName);
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrId, id);
|
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
|
||||||
doc->SetAttribute(domElement, AttrType, ToolType);
|
doc->SetAttribute(domElement, AttrType, ToolType);
|
||||||
doc->SetAttribute(domElement, AttrIdObject, idNode);
|
doc->SetAttribute(domElement, AttrIdObject, idNode);
|
||||||
if (idTool != 0)
|
if (idTool != 0)
|
||||||
|
|
|
@ -105,7 +105,7 @@ void VNodePoint::AddToFile()
|
||||||
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
const VPointF *point = VAbstractTool::data.GeometricObject<const VPointF *>(id);
|
||||||
QDomElement domElement = doc->createElement(TagName);
|
QDomElement domElement = doc->createElement(TagName);
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrId, id);
|
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
|
||||||
doc->SetAttribute(domElement, AttrType, ToolType);
|
doc->SetAttribute(domElement, AttrType, ToolType);
|
||||||
doc->SetAttribute(domElement, AttrIdObject, idNode);
|
doc->SetAttribute(domElement, AttrIdObject, idNode);
|
||||||
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx()));
|
||||||
|
|
|
@ -97,7 +97,7 @@ void VNodeSpline::AddToFile()
|
||||||
{
|
{
|
||||||
QDomElement domElement = doc->createElement(TagName);
|
QDomElement domElement = doc->createElement(TagName);
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrId, id);
|
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
|
||||||
doc->SetAttribute(domElement, AttrType, ToolType);
|
doc->SetAttribute(domElement, AttrType, ToolType);
|
||||||
doc->SetAttribute(domElement, AttrIdObject, idNode);
|
doc->SetAttribute(domElement, AttrIdObject, idNode);
|
||||||
if (idTool != 0)
|
if (idTool != 0)
|
||||||
|
|
|
@ -100,7 +100,7 @@ void VNodeSplinePath::AddToFile()
|
||||||
{
|
{
|
||||||
QDomElement domElement = doc->createElement(TagName);
|
QDomElement domElement = doc->createElement(TagName);
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrId, id);
|
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
|
||||||
doc->SetAttribute(domElement, AttrType, ToolType);
|
doc->SetAttribute(domElement, AttrType, ToolType);
|
||||||
doc->SetAttribute(domElement, AttrIdObject, idNode);
|
doc->SetAttribute(domElement, AttrIdObject, idNode);
|
||||||
if (idTool != 0)
|
if (idTool != 0)
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
|
|
||||||
#include "vabstracttool.h"
|
#include "vabstracttool.h"
|
||||||
|
|
||||||
const QString VAbstractTool::AttrId = QStringLiteral("id");
|
|
||||||
const QString VAbstractTool::AttrType = QStringLiteral("type");
|
const QString VAbstractTool::AttrType = QStringLiteral("type");
|
||||||
const QString VAbstractTool::AttrMx = QStringLiteral("mx");
|
const QString VAbstractTool::AttrMx = QStringLiteral("mx");
|
||||||
const QString VAbstractTool::AttrMy = QStringLiteral("my");
|
const QString VAbstractTool::AttrMy = QStringLiteral("my");
|
||||||
|
|
|
@ -102,7 +102,6 @@ public:
|
||||||
* @param c c value
|
* @param c c value
|
||||||
*/
|
*/
|
||||||
static void LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c);
|
static void LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c);
|
||||||
static const QString AttrId;
|
|
||||||
static const QString AttrType;
|
static const QString AttrType;
|
||||||
static const QString AttrMx;
|
static const QString AttrMx;
|
||||||
static const QString AttrMy;
|
static const QString AttrMy;
|
||||||
|
|
|
@ -228,7 +228,7 @@ void VToolDetail::AddToFile()
|
||||||
VDetail detail = VAbstractTool::data.GetDetail(id);
|
VDetail detail = VAbstractTool::data.GetDetail(id);
|
||||||
QDomElement domElement = doc->createElement(TagName);
|
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, AttrName, detail.getName());
|
||||||
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(detail.getMx()));
|
doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(detail.getMx()));
|
||||||
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(detail.getMy()));
|
doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(detail.getMy()));
|
||||||
|
|
|
@ -615,7 +615,7 @@ void VToolUnionDetails::AddToFile()
|
||||||
{
|
{
|
||||||
QDomElement domElement = doc->createElement(TagName);
|
QDomElement domElement = doc->createElement(TagName);
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrId, id);
|
doc->SetAttribute(domElement, VDomDocument::AttrId, id);
|
||||||
doc->SetAttribute(domElement, AttrType, ToolType);
|
doc->SetAttribute(domElement, AttrType, ToolType);
|
||||||
doc->SetAttribute(domElement, AttrIndexD1, indexD1);
|
doc->SetAttribute(domElement, AttrIndexD1, indexD1);
|
||||||
doc->SetAttribute(domElement, AttrIndexD2, indexD2);
|
doc->SetAttribute(domElement, AttrIndexD2, indexD2);
|
||||||
|
|
|
@ -77,6 +77,12 @@ inline qint64 MessageHandler::column() const
|
||||||
return m_sourceLocation.column();
|
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)
|
VDomDocument::VDomDocument(VContainer *data)
|
||||||
: QDomDocument(), data(data), map(QHash<QString, QDomElement>())
|
: 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)
|
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;
|
this->map[value] = node;
|
||||||
if (value == id)
|
if (value == id)
|
||||||
{
|
{
|
||||||
|
@ -311,7 +317,7 @@ void VDomDocument::setContent(QIODevice *dev)
|
||||||
Valentina::Units VDomDocument::Units(const QString &unit)
|
Valentina::Units VDomDocument::Units(const QString &unit)
|
||||||
{
|
{
|
||||||
QStringList units;
|
QStringList units;
|
||||||
units << "mm" << "cm" << "in";
|
units << UnitMM << UnitCM << UnitIN;
|
||||||
Valentina::Units result = Valentina::Cm;
|
Valentina::Units result = Valentina::Cm;
|
||||||
switch (units.indexOf(unit))
|
switch (units.indexOf(unit))
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,6 +47,11 @@ class VDomDocument : public QDomDocument
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(VDomDocument)
|
Q_DECLARE_TR_FUNCTIONS(VDomDocument)
|
||||||
public:
|
public:
|
||||||
|
static const QString AttrId;
|
||||||
|
static const QString AttrUnit;
|
||||||
|
static const QString UnitMM;
|
||||||
|
static const QString UnitCM;
|
||||||
|
static const QString UnitIN;
|
||||||
/**
|
/**
|
||||||
* @brief VDomDocument constructor.
|
* @brief VDomDocument constructor.
|
||||||
* @param data container with variables.
|
* @param data container with variables.
|
||||||
|
@ -162,13 +167,20 @@ template <>
|
||||||
inline void VDomDocument::SetAttribute<Valentina::Units>(QDomElement &domElement, const QString &name,
|
inline void VDomDocument::SetAttribute<Valentina::Units>(QDomElement &domElement, const QString &name,
|
||||||
const Valentina::Units &value)
|
const Valentina::Units &value)
|
||||||
{
|
{
|
||||||
if (value == Valentina::Cm || value == Valentina::Mm)
|
switch(value)
|
||||||
{
|
{
|
||||||
|
case Valentina::Mm:
|
||||||
|
domElement.setAttribute(name, "mm");
|
||||||
|
break;
|
||||||
|
case Valentina::Cm:
|
||||||
domElement.setAttribute(name, "cm");
|
domElement.setAttribute(name, "cm");
|
||||||
}
|
break;
|
||||||
else
|
case Valentina::In:
|
||||||
{
|
|
||||||
domElement.setAttribute(name, "in");
|
domElement.setAttribute(name, "in");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
domElement.setAttribute(name, "cm");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,13 +28,25 @@
|
||||||
|
|
||||||
#include "vindividualmeasurements.h"
|
#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)
|
VIndividualMeasurements::VIndividualMeasurements(VContainer *data):VDomDocument(data)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Valentina::Units VIndividualMeasurements::Unit()
|
Valentina::Units VIndividualMeasurements::Unit()
|
||||||
{
|
{
|
||||||
const QString unit = UniqueTagText("unit", "cm");
|
const QString unit = UniqueTagText(AttrUnit, UnitCM);
|
||||||
return VDomDocument::Units(unit);
|
return VDomDocument::Units(unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,24 +157,24 @@ void VIndividualMeasurements::Measurement(const QString &tag)
|
||||||
const QDomElement domElement = domNode.toElement();
|
const QDomElement domElement = domNode.toElement();
|
||||||
if (domElement.isNull() == false)
|
if (domElement.isNull() == false)
|
||||||
{
|
{
|
||||||
const bool ignore = QVariant(GetParametrString(domElement, "ignore", "false")).toBool();
|
const bool ignore = QVariant(GetParametrString(domElement, AttrIgnore, "false")).toBool();
|
||||||
if (ignore)
|
if (ignore)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const QString name = GetParametrString(domElement, "name", "");
|
const QString name = GetParametrString(domElement, AttrName, "");
|
||||||
if (name.isEmpty())
|
if (name.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const QString m_number = GetParametrString(domElement, "m_number", "");
|
const QString m_number = GetParametrString(domElement, AttrM_number, "");
|
||||||
const QString gui_text = GetParametrString(domElement, "gui_text", "");
|
const QString gui_text = GetParametrString(domElement, AttrGui_text, "");
|
||||||
const qreal value = GetParametrDouble(domElement, "value", "0.0");
|
const qreal value = GetParametrDouble(domElement, AttrValue, "0.0");
|
||||||
const QString description = GetParametrString(domElement, "description", "");
|
const QString description = GetParametrString(domElement, AttrDescription, "");
|
||||||
|
|
||||||
if (Unit() == Valentina::Mm)//Convert to Cm.
|
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())
|
if (m_number.isEmpty())
|
||||||
{
|
{
|
||||||
qWarning()<<"Can't find language-independent measurement name for "<< tag;
|
qWarning()<<"Can't find language-independent measurement name for "<< tag;
|
||||||
|
@ -170,12 +182,14 @@ void VIndividualMeasurements::Measurement(const QString &tag)
|
||||||
}
|
}
|
||||||
else
|
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.
|
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())
|
if (m_number.isEmpty())
|
||||||
{
|
{
|
||||||
qWarning()<<"Can't find language-independent measurement name for "<< tag;
|
qWarning()<<"Can't find language-independent measurement name for "<< tag;
|
||||||
|
@ -183,7 +197,9 @@ void VIndividualMeasurements::Measurement(const QString &tag)
|
||||||
}
|
}
|
||||||
else
|
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()
|
QString VIndividualMeasurements::Language()
|
||||||
{
|
{
|
||||||
return UniqueTagText("lang", "en");
|
return UniqueTagText(AttrLang, "en");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VIndividualMeasurements::FamilyName()
|
QString VIndividualMeasurements::FamilyName()
|
||||||
{
|
{
|
||||||
return UniqueTagText("family-name", "");
|
return UniqueTagText(AttrFamily_name, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VIndividualMeasurements::GivenName()
|
QString VIndividualMeasurements::GivenName()
|
||||||
{
|
{
|
||||||
return UniqueTagText("given-name", "");
|
return UniqueTagText(AttrGiven_name, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VIndividualMeasurements::BirthDate()
|
QString VIndividualMeasurements::BirthDate()
|
||||||
{
|
{
|
||||||
return UniqueTagText("birth-date", "");
|
return UniqueTagText(AttrBirth_date, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VIndividualMeasurements::Sex()
|
QString VIndividualMeasurements::Sex()
|
||||||
{
|
{
|
||||||
return UniqueTagText("sex", "");
|
return UniqueTagText(AttrSex, "");
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,17 @@ public:
|
||||||
QString GivenName();
|
QString GivenName();
|
||||||
QString BirthDate();
|
QString BirthDate();
|
||||||
QString Sex();
|
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
|
#endif // VINDIVIDUALMEASUREMENTS_H
|
||||||
|
|
|
@ -57,6 +57,7 @@ const QString VPattern::TagTools = QStringLiteral("tools");
|
||||||
|
|
||||||
const QString VPattern::AttrName = QStringLiteral("name");
|
const QString VPattern::AttrName = QStringLiteral("name");
|
||||||
const QString VPattern::AttrType = QStringLiteral("type");
|
const QString VPattern::AttrType = QStringLiteral("type");
|
||||||
|
const QString VPattern::AttrPath = QStringLiteral("path");
|
||||||
|
|
||||||
const QString VPattern::IncrementName = QStringLiteral("name");
|
const QString VPattern::IncrementName = QStringLiteral("name");
|
||||||
const QString VPattern::IncrementBase = QStringLiteral("base");
|
const QString VPattern::IncrementBase = QStringLiteral("base");
|
||||||
|
@ -84,9 +85,9 @@ void VPattern::CreateEmptyFile(const QString &tablePath)
|
||||||
patternElement.appendChild(createElement(TagNotes));
|
patternElement.appendChild(createElement(TagNotes));
|
||||||
|
|
||||||
QDomElement measurements = createElement(TagMeasurements);
|
QDomElement measurements = createElement(TagMeasurements);
|
||||||
SetAttribute(measurements, "unit", qApp->patternUnit());
|
SetAttribute(measurements, AttrUnit, qApp->patternUnit());
|
||||||
SetAttribute(measurements, "type", qApp->patternType());
|
SetAttribute(measurements, AttrType, qApp->patternType());
|
||||||
SetAttribute(measurements, "path", tablePath);
|
SetAttribute(measurements, AttrPath, tablePath);
|
||||||
patternElement.appendChild(measurements);
|
patternElement.appendChild(measurements);
|
||||||
|
|
||||||
patternElement.appendChild(createElement(TagIncrements));
|
patternElement.appendChild(createElement(TagIncrements));
|
||||||
|
@ -412,6 +413,79 @@ bool VPattern::GetActivNodeElement(const QString &name, QDomElement &element)
|
||||||
return false;
|
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()
|
void VPattern::FullUpdateTree()
|
||||||
{
|
{
|
||||||
VMainGraphicsScene *scene = new VMainGraphicsScene();
|
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.");
|
QString message = tr("Got wrong parameter id. Need only id > 0.");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
id = GetParametrUInt(domElement, VAbstractTool::AttrId, "0");
|
id = GetParametrUInt(domElement, VDomDocument::AttrId, "0");
|
||||||
if (id <= 0)
|
if (id <= 0)
|
||||||
{
|
{
|
||||||
throw VExceptionWrongId(message, domElement);
|
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
|
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);
|
const quint32 id = GetParametrId(node);
|
||||||
if (vector.contains(id))
|
if (vector.contains(id))
|
||||||
|
|
|
@ -165,6 +165,9 @@ public:
|
||||||
* @return true if found.
|
* @return true if found.
|
||||||
*/
|
*/
|
||||||
bool GetActivNodeElement(const QString& name, QDomElement& element);
|
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 TagPattern;
|
||||||
static const QString TagCalculation;
|
static const QString TagCalculation;
|
||||||
static const QString TagModeling;
|
static const QString TagModeling;
|
||||||
|
@ -183,6 +186,7 @@ public:
|
||||||
static const QString TagTools;
|
static const QString TagTools;
|
||||||
static const QString AttrName;
|
static const QString AttrName;
|
||||||
static const QString AttrType;
|
static const QString AttrType;
|
||||||
|
static const QString AttrPath;
|
||||||
static const QString IncrementName;
|
static const QString IncrementName;
|
||||||
static const QString IncrementBase;
|
static const QString IncrementBase;
|
||||||
static const QString IncrementKsize;
|
static const QString IncrementKsize;
|
||||||
|
|
|
@ -29,19 +29,30 @@
|
||||||
#include "vstandardmeasurements.h"
|
#include "vstandardmeasurements.h"
|
||||||
#include <QDebug>
|
#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)
|
VStandardMeasurements::VStandardMeasurements(VContainer *data):VDomDocument(data)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Valentina::Units VStandardMeasurements::Unit()
|
Valentina::Units VStandardMeasurements::Unit()
|
||||||
{
|
{
|
||||||
const QString unit = UniqueTagText("unit", "cm");
|
const QString unit = UniqueTagText(AttrUnit, UnitCM);
|
||||||
return VDomDocument::Units(unit);
|
return VDomDocument::Units(unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VStandardMeasurements::Description()
|
QString VStandardMeasurements::Description()
|
||||||
{
|
{
|
||||||
const QString desc = UniqueTagText("description", "");
|
const QString desc = UniqueTagText(TagDescription, "");
|
||||||
if (desc.isEmpty())
|
if (desc.isEmpty())
|
||||||
{
|
{
|
||||||
qWarning()<<"Empty description in standard table."<<Q_FUNC_INFO;
|
qWarning()<<"Empty description in standard table."<<Q_FUNC_INFO;
|
||||||
|
@ -51,7 +62,7 @@ QString VStandardMeasurements::Description()
|
||||||
|
|
||||||
void VStandardMeasurements::Measurements()
|
void VStandardMeasurements::Measurements()
|
||||||
{
|
{
|
||||||
const QDomNodeList nodeList = this->elementsByTagName("measurement");
|
const QDomNodeList nodeList = this->elementsByTagName(TagMeasurement);
|
||||||
if (nodeList.isEmpty())
|
if (nodeList.isEmpty())
|
||||||
{
|
{
|
||||||
qWarning()<<"Measurement list is empty"<<Q_FUNC_INFO;
|
qWarning()<<"Measurement list is empty"<<Q_FUNC_INFO;
|
||||||
|
@ -67,16 +78,16 @@ void VStandardMeasurements::Measurements()
|
||||||
const QDomElement domElement = domNode.toElement();
|
const QDomElement domElement = domNode.toElement();
|
||||||
if (domElement.isNull() == false)
|
if (domElement.isNull() == false)
|
||||||
{
|
{
|
||||||
const QString name = GetParametrString(domElement, "name", "");
|
const QString name = GetParametrString(domElement, AttrName, "");
|
||||||
if (name.isEmpty())
|
if (name.isEmpty())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const QString gui_text = GetParametrString(domElement, "gui_text", "");
|
const QString gui_text = GetParametrString(domElement, AttrGui_text, "");
|
||||||
const qreal base = GetParametrDouble(domElement, "base", "0.0");
|
const qreal base = GetParametrDouble(domElement, AttrBase, "0.0");
|
||||||
const qreal size_increace = GetParametrDouble(domElement, "size_increace", "0.0");
|
const qreal size_increace = GetParametrDouble(domElement, AttrSize_increace, "0.0");
|
||||||
const qreal height_increase = GetParametrDouble(domElement, "height_increase", "0.0");
|
const qreal height_increase = GetParametrDouble(domElement, AttrHeight_increase, "0.0");
|
||||||
const QString number = GetParametrString(domElement, "number", "");
|
const QString number = GetParametrString(domElement, AttrNumber, "");
|
||||||
|
|
||||||
if (Unit() == Valentina::Mm)// Convert to Cm.
|
if (Unit() == Valentina::Mm)// Convert to Cm.
|
||||||
{
|
{
|
||||||
|
@ -96,7 +107,7 @@ void VStandardMeasurements::Measurements()
|
||||||
|
|
||||||
void VStandardMeasurements::SetSize()
|
void VStandardMeasurements::SetSize()
|
||||||
{
|
{
|
||||||
const QDomNodeList nodeList = this->elementsByTagName("size");
|
const QDomNodeList nodeList = this->elementsByTagName(TagSize);
|
||||||
if (nodeList.isEmpty())
|
if (nodeList.isEmpty())
|
||||||
{
|
{
|
||||||
data->SetSize(50);
|
data->SetSize(50);
|
||||||
|
@ -110,8 +121,8 @@ void VStandardMeasurements::SetSize()
|
||||||
const QDomElement domElement = domNode.toElement();
|
const QDomElement domElement = domNode.toElement();
|
||||||
if (domElement.isNull() == false)
|
if (domElement.isNull() == false)
|
||||||
{
|
{
|
||||||
const QString name = GetParametrString(domElement, "name", "Сг");
|
const QString name = GetParametrString(domElement, AttrName, "Сг");
|
||||||
const qreal base = GetParametrDouble(domElement, "base", "50.0");
|
const qreal base = GetParametrDouble(domElement, AttrBase, "50.0");
|
||||||
if (Unit() == Valentina::Mm)// Convert to Cm.
|
if (Unit() == Valentina::Mm)// Convert to Cm.
|
||||||
{
|
{
|
||||||
data->SetSize(base/10.0);
|
data->SetSize(base/10.0);
|
||||||
|
@ -129,7 +140,7 @@ void VStandardMeasurements::SetSize()
|
||||||
|
|
||||||
void VStandardMeasurements::SetHeight()
|
void VStandardMeasurements::SetHeight()
|
||||||
{
|
{
|
||||||
const QDomNodeList nodeList = this->elementsByTagName("height");
|
const QDomNodeList nodeList = this->elementsByTagName(TagHeight);
|
||||||
if (nodeList.isEmpty())
|
if (nodeList.isEmpty())
|
||||||
{
|
{
|
||||||
data->SetHeight(176);
|
data->SetHeight(176);
|
||||||
|
@ -143,8 +154,8 @@ void VStandardMeasurements::SetHeight()
|
||||||
const QDomElement domElement = domNode.toElement();
|
const QDomElement domElement = domNode.toElement();
|
||||||
if (domElement.isNull() == false)
|
if (domElement.isNull() == false)
|
||||||
{
|
{
|
||||||
const QString name = GetParametrString(domElement, "name", "Р");
|
const QString name = GetParametrString(domElement, AttrName, "Р");
|
||||||
const qreal base = GetParametrDouble(domElement, "base", "176.0");
|
const qreal base = GetParametrDouble(domElement, AttrBase, "176.0");
|
||||||
if (Unit() == Valentina::Mm)// Convert to Cm.
|
if (Unit() == Valentina::Mm)// Convert to Cm.
|
||||||
{
|
{
|
||||||
data->SetHeight(base/10.0);
|
data->SetHeight(base/10.0);
|
||||||
|
|
|
@ -41,6 +41,16 @@ public:
|
||||||
void Measurements();
|
void Measurements();
|
||||||
void SetSize();
|
void SetSize();
|
||||||
void SetHeight();
|
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:
|
public slots:
|
||||||
void Update();
|
void Update();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user