--HG--
branch : feature
This commit is contained in:
dismine 2014-03-28 15:11:46 +02:00
parent 26c8884af0
commit a74351495c
40 changed files with 593 additions and 284 deletions

View File

@ -874,7 +874,7 @@
</xs:simpleType>
<xs:simpleType name="shortMeasurementName">
<xs:restriction base="xs:string">
<xs:pattern value="([\p{L}]|[^0-9])[_\p{L}0-9]*"/>
<xs:pattern value="^([^0-9-*/^+=\s\(\)%:;!]){1,1}([^-*/^+=\s\(\)%:;!]){0,}$"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="units">

View File

@ -213,7 +213,7 @@
</xs:element>
<xs:simpleType name="shortName">
<xs:restriction base="xs:string">
<xs:pattern value="([\p{L}]|[^0-9])[_\p{L}0-9]*"/>
<xs:pattern value="^([^0-9-*/^+=\s\(\)%:;!]){1,1}([^-*/^+=\s\(\)%:;!]){0,}$"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="units">

View File

@ -38,7 +38,7 @@
</xs:element>
<xs:simpleType name="shortMeasurementName">
<xs:restriction base="xs:string">
<xs:pattern value="([\p{L}]|[^0-9])[_\p{L}0-9]*"/>
<xs:pattern value="^([^0-9-*/^+=\s\(\)%:;!]){1,1}([^-*/^+=\s\(\)%:;!]){0,}$"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="units">

View File

@ -81,27 +81,20 @@ void VContainer::setData(const VContainer &data)
switch (i.value()->getType())
{
case (GObject::Arc):
{
CopyGObject<VArc>(data, i.key());
break;
}
case (GObject::Point):
{
CopyGObject<VPointF>(data, i.key());
break;
}
case (GObject::Spline):
{
CopyGObject<VSpline>(data, i.key());
break;
}
case (GObject::SplinePath):
{
CopyGObject<VSplinePath>(data, i.key());
break;
}
default:
qWarning()<<"Don't know how copy this type.";
qDebug()<<"Don't know how copy this type.";
break;
}
}
measurements = *data.DataMeasurements();

View File

@ -272,6 +272,7 @@ public:
* @brief ClearIncrementTable clear increment table
*/
void ClearIncrementTable();
void ClearMeasurements();
/**
* @brief ClearLengthLines clear length lines
*/
@ -478,6 +479,11 @@ inline void VContainer::ClearIncrementTable()
increments.clear();
}
inline void VContainer::ClearMeasurements()
{
measurements.clear();
}
inline void VContainer::ClearLengthLines()
{
lengthLines.clear();

View File

@ -170,7 +170,7 @@ QString DialogHistory::Record(const VToolRecord &tool)
const QDomElement domElement = doc->elementById(QString().setNum(tool.getId()));
if (domElement.isElement() == false)
{
qWarning()<<"Can't find element by id"<<Q_FUNC_INFO;
qDebug()<<"Can't find element by id"<<Q_FUNC_INFO;
return QString(tr("Can't create record."));
}
try
@ -283,7 +283,7 @@ QString DialogHistory::Record(const VToolRecord &tool)
}
else
{
qWarning()<<"Not enough points in splinepath"<<Q_FUNC_INFO;
qDebug()<<"Not enough points in splinepath"<<Q_FUNC_INFO;
return QString(tr("Can't create record."));
}
return record;
@ -375,7 +375,7 @@ QString DialogHistory::Record(const VToolRecord &tool)
}
else
{
qWarning()<<"Not enough points in splinepath"<<Q_FUNC_INFO;
qDebug()<<"Not enough points in splinepath"<<Q_FUNC_INFO;
return QString(tr("Can't create record."));
}
return record;
@ -395,13 +395,13 @@ QString DialogHistory::Record(const VToolRecord &tool)
case Valentina::NodeSplinePath:
break;
default:
qWarning()<<"Got wrong tool type. Ignore.";
qDebug()<<"Got wrong tool type. Ignore.";
break;
}
}
catch (const VExceptionBadId &e)
{
qWarning()<<e.ErrorMessage()<<Q_FUNC_INFO;
qDebug()<<e.ErrorMessage()<<Q_FUNC_INFO;
return QString(tr("Can't create record."));
}
return QString();

View File

@ -31,6 +31,7 @@
#include "../../widgets/doubledelegate.h"
#include "../../widgets/textdelegate.h"
#include "../../exception/vexception.h"
#include "../../xml/vstandardmeasurements.h"
#include <QPushButton>
#include <QFile>
@ -39,26 +40,48 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
: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);
if (qApp->patternType() == Pattern::Individual)
{
const QString filePath = doc->MPath();
try
{
VDomDocument::ValidateXML("://schema/individual_measurements.xsd", filePath);
m = new VIndividualMeasurements(data);
m->setContent(filePath);
}
catch(VException &e)
{
e.CriticalMessageBox(tr("File error."), this);
emit DialogClosed(QDialog::Rejected);
return;
}
}
//Same regex in each shema files. Don't forget synchronize.
TextDelegate *textDelegate = new TextDelegate("^([^0-9-*/^+=\\s\\(\\)%:;!]){1,1}([^-*/^+=\\s\\(\\)%:;!]){0,}$",
ui->tableWidgetIncrement);
ui->tableWidgetIncrement->setItemDelegateForColumn(0, textDelegate);// name
DoubleSpinBoxDelegate *doubleDelegate = new DoubleSpinBoxDelegate(ui->tableWidgetIncrement);
ui->tableWidgetIncrement->setItemDelegateForColumn(2, doubleDelegate);// base value
ui->tableWidgetIncrement->setItemDelegateForColumn(3, doubleDelegate);// in sizes
ui->tableWidgetIncrement->setItemDelegateForColumn(4, doubleDelegate);// in heights
FillMeasurements();
FillIncrements();
FillLengthLines();
FillLengthSplines();
FillLengthArcs();
if (qApp->patternType() == Pattern::Standard)
{
ui->labelBirthDate->setVisible(false);
ui->lineEditBirthDate->setVisible(false);
ui->labelFamilyName->setVisible(false);
ui->lineEditFamilyName->setVisible(false);
ui->labelGivenName->setVisible(false);
ui->lineEditGivenName->setVisible(false);
ui->labelSex->setVisible(false);
ui->lineEditSex->setVisible(false);
ui->pagePersonalInformation->setVisible(false);
}
else
{
QRegExpValidator *reg = new QRegExpValidator(QRegExp("\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"));
ui->lineEditMail->setValidator(reg);
ui->tableWidgetMeasurements->setColumnHidden( 1, true );// calculated value
ui->tableWidgetMeasurements->setColumnHidden( 3, true );// in sizes
ui->tableWidgetMeasurements->setColumnHidden( 4, true );// in heights
@ -69,17 +92,32 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
ui->tableWidgetMeasurements->setItemDelegateForColumn(2, doubleDelegate);// base value
connect(ui->tableWidgetMeasurements, &QTableWidget::cellChanged, this, &DialogIncrements::MeasurementsChanged);
connect(ui->tableWidgetMeasurements, &QTableWidget::cellChanged, this, &DialogIncrements::MeasurementChanged);
ui->lineEditGivenName->setText(m->GivenName());
ui->lineEditFamilyName->setText(m->FamilyName());
ui->comboBoxSex->addItem(tr("male"),QVariant(m->GenderToStr(VIndividualMeasurements::Male)));
ui->comboBoxSex->addItem(tr("female"),QVariant(m->GenderToStr(VIndividualMeasurements::Female)));
qint32 index = ui->comboBoxSex->findData(m->GenderToStr(m->Sex()));
if (index != -1)
{
ui->comboBoxSex->setCurrentIndex(index);
}
ui->dateEditBirthDate->setDate(m->BirthDate());
ui->lineEditMail->setText(m->Mail());
connect(ui->lineEditGivenName, &QLineEdit::editingFinished, this, &DialogIncrements::SaveGivenName);
connect(ui->lineEditFamilyName, &QLineEdit::editingFinished, this, &DialogIncrements::SaveFamilyName);
connect(ui->lineEditMail, &QLineEdit::editingFinished, this, &DialogIncrements::SaveEmail);
connect(ui->comboBoxSex, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogIncrements::SaveSex);
connect(ui->dateEditBirthDate, &QDateEdit::dateChanged, this, &DialogIncrements::SaveBirthDate);
}
ui->toolBoxMeasurements->setCurrentIndex(1);
FillMeasurements();
FillIncrements();
FillLengthLines();
FillLengthSplines();
FillLengthArcs();
connect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, &DialogIncrements::IncrementChanged);
connect(ui->toolButtonAdd, &QPushButton::clicked, this, &DialogIncrements::clickedToolButtonAdd);
connect(ui->toolButtonRemove, &QPushButton::clicked, this, &DialogIncrements::clickedToolButtonRemove);
@ -90,22 +128,7 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
ui->tabWidget->setCurrentIndex(0);
if (qApp->patternType() == Pattern::Individual)
{
QString filePath = doc->MPath();
try
{
VDomDocument::ValidateXML("://schema/individual_measurements.xsd", filePath);
m = new VIndividualMeasurements(data);
m->setContent(filePath);
}
catch(VException &e)
{
qWarning()<<"File error."<<e.ErrorMessage()<<e.DetailedInformation()<<Q_FUNC_INFO;
emit DialogClosed(QDialog::Rejected);
return;
}
}
connect(ui->toolButtonOpenMeasurements, &QToolButton::clicked, this, &DialogIncrements::OpenTable);
}
void DialogIncrements::FillMeasurements()
@ -132,12 +155,20 @@ void DialogIncrements::FillMeasurements()
item->setTextAlignment(Qt::AlignHCenter);
item->setFont(QFont("Times", 12, QFont::Bold));
item->setToolTip(m.GetDescription());
// set the item non-editable (view only), and non-selectable
Qt::ItemFlags flags = item->flags();
flags &= ~(Qt::ItemIsSelectable | Qt::ItemIsEditable); // reset/clear the flag
item->setFlags(flags);
ui->tableWidgetMeasurements->setItem(currentRow, 0, item);
if (qApp->patternType() == Pattern::Standard)
{
QTableWidgetItem *item = new QTableWidgetItem(QString().setNum(data->GetValueStandardTableRow(iMap.key())));
item->setTextAlignment(Qt::AlignHCenter);
// set the item non-editable (view only), and non-selectable
Qt::ItemFlags flags = item->flags();
flags &= ~(Qt::ItemIsSelectable | Qt::ItemIsEditable); // reset/clear the flag
item->setFlags(flags);
ui->tableWidgetMeasurements->setItem(currentRow, 1, item);
}
@ -149,15 +180,27 @@ void DialogIncrements::FillMeasurements()
{
QTableWidgetItem *item = new QTableWidgetItem(QString().setNum(m.GetKsize()));
item->setTextAlignment(Qt::AlignHCenter);
// set the item non-editable (view only), and non-selectable
Qt::ItemFlags flags = item->flags();
flags &= ~(Qt::ItemIsSelectable | Qt::ItemIsEditable); // reset/clear the flag
item->setFlags(flags);
ui->tableWidgetMeasurements->setItem(currentRow, 3, item);
item = new QTableWidgetItem(QString().setNum(m.GetKheight()));
item->setTextAlignment(Qt::AlignHCenter);
// set the item non-editable (view only), and non-selectable
flags = item->flags();
flags &= ~(Qt::ItemIsSelectable | Qt::ItemIsEditable); // reset/clear the flag
item->setFlags(flags);
ui->tableWidgetMeasurements->setItem(currentRow, 4, item);
}
item = new QTableWidgetItem(m.GetNumber());
item->setTextAlignment(Qt::AlignHCenter);
// set the item non-editable (view only), and non-selectable
flags = item->flags();
flags &= ~(Qt::ItemIsSelectable | Qt::ItemIsEditable); // reset/clear the flag
item->setFlags(flags);
ui->tableWidgetMeasurements->setItem(currentRow, 5, item);
}
ui->tableWidgetMeasurements->verticalHeader()->setDefaultSectionSize(20);
@ -339,8 +382,10 @@ void DialogIncrements::FillLengthArcs()
void DialogIncrements::FullUpdateFromFile()
{
disconnect(ui->tableWidgetMeasurements, &QTableWidget::cellChanged, this, &DialogIncrements::MeasurementChanged);
ui->tableWidgetMeasurements->clearContents();
FillMeasurements();
connect(ui->tableWidgetMeasurements, &QTableWidget::cellChanged, this, &DialogIncrements::MeasurementChanged);
disconnect(ui->tableWidgetIncrement, &QTableWidget::cellChanged, this, &DialogIncrements::IncrementChanged);
ui->tableWidgetIncrement->clearContents();
@ -357,6 +402,139 @@ void DialogIncrements::FullUpdateFromFile()
FillLengthArcs();
}
void DialogIncrements::SaveGivenName()
{
m->setGivenName(ui->lineEditGivenName->text());
if (m->SaveDocument(doc->MPath()) == false)
{
qDebug()<<"Can't save GivenName";
}
}
void DialogIncrements::SaveFamilyName()
{
m->setFamilyName(ui->lineEditFamilyName->text());
if (m->SaveDocument(doc->MPath()) == false)
{
qDebug()<<"Can't save FamilyName";
}
}
void DialogIncrements::SaveEmail()
{
m->setMail(ui->lineEditMail->text());
if (m->SaveDocument(doc->MPath()) == false)
{
qDebug()<<"Can't save Email";
}
}
void DialogIncrements::SaveSex(int index)
{
m->setSex(m->StrToGender(ui->comboBoxSex->itemData(index).toString()));
if (m->SaveDocument(doc->MPath()) == false)
{
qDebug()<<"Can't save Sex";
}
}
void DialogIncrements::SaveBirthDate(const QDate & date)
{
m->setBirthDate(date);
if (m->SaveDocument(doc->MPath()) == false)
{
qDebug()<<"Can't save BirthDate";
}
}
void DialogIncrements::OpenTable()
{
QString text = tr("Measurements use different units than pattern. This pattern required measurements in %1")
.arg(doc->UnitsToStr(qApp->patternUnit()));
if (qApp->patternType() == Pattern::Individual)
{
const QString filter(tr("Individual measurements (*.vit)"));
const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), QDir::homePath(), filter);
if (filePath.isEmpty())
{
return;
}
VIndividualMeasurements *m1 = nullptr;
try
{
VDomDocument::ValidateXML("://schema/individual_measurements.xsd", filePath);
m1 = new VIndividualMeasurements(data);
m1->setContent(filePath);
}
catch(VException &e)
{
e.CriticalMessageBox(tr("File error."), this);
delete m1;
emit DialogClosed(QDialog::Rejected);
return;
}
Valentina::Units mUnit = m1->Unit();
if (qApp->patternUnit() != mUnit)
{
QMessageBox::critical(this, tr("Wrong units."), text);
delete m1;
return;
}
delete m;
m = m1;
data->ClearMeasurements();
m->Measurements();
emit FullUpdateTree();
doc->SetPath(filePath);
emit haveLiteChange();
}
else
{
const QString filter(tr("Standard measurements (*.vst)"));
const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), QDir::homePath(), filter);
if (filePath.isEmpty())
{
return;
}
VStandardMeasurements *m1 = nullptr;
try
{
VDomDocument::ValidateXML("://schema/standard_measurements.xsd", filePath);
m1 = new VStandardMeasurements(data);
m1->setContent(filePath);
Valentina::Units mUnit = m1->Unit();
if (qApp->patternUnit() != mUnit)
{
QMessageBox::critical(this, tr("Wrong units."), text);
delete m1;
return;
}
m1->SetSize();
m1->SetHeight();
data->ClearMeasurements();
m1->Measurements();
delete m1;
emit FullUpdateTree();
doc->SetPath(filePath);
emit haveLiteChange();
}
catch(VException &e)
{
e.CriticalMessageBox(tr("File error."), this);
delete m1;
emit DialogClosed(QDialog::Rejected);
return;
}
}
}
void DialogIncrements::clickedToolButtonAdd()
{
ui->tableWidgetIncrement->setFocus(Qt::OtherFocusReason);
@ -467,7 +645,7 @@ void DialogIncrements::IncrementChanged ( qint32 row, qint32 column )
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement() == false)
{
qWarning()<<"Cant't find increment with id = "<<id<<Q_FUNC_INFO;
qDebug()<<"Cant't find increment with id = "<<id<<Q_FUNC_INFO;
return;
}
this->row = row;
@ -512,45 +690,50 @@ void DialogIncrements::IncrementChanged ( qint32 row, qint32 column )
emit haveLiteChange();
}
void DialogIncrements::MeasurementsChanged(qint32 row, qint32 column)
void DialogIncrements::MeasurementChanged(qint32 row, qint32 column)
{
switch (column)
{
case 2:// value 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);
QDomNodeList list = m->elementsByTagName(tag);
QDomElement domElement = list.at(0).toElement();
if (domElement.isElement() == false)
{
qWarning()<<"Cant't find measurement "<<tag<<Q_FUNC_INFO;
qDebug()<<"Cant't find measurement "<<tag<<Q_FUNC_INFO;
return;
}
switch (column)
m->SetAttribute(domElement, VIndividualMeasurements::AttrValue, item->text());
if (m->SaveDocument(doc->MPath()) == false)
{
case 2:
{
m.SetAttribute(domElement, VIndividualMeasurements::AttrValue, item->text());
qDebug()<<"Can't save measurement";
}
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;
qDebug()<<"Can't convert toDouble measurement value"<<Q_FUNC_INFO;
}
else
{
measur.setBase(base);
}
data->UpdateMeasurement(itemName->text(), measur);
data->ClearMeasurements();
m->Measurements();
emit FullUpdateTree();
break;
}
default:
break;
}
emit haveLiteChange();
}
void DialogIncrements::closeEvent(QCloseEvent *event)
@ -562,4 +745,5 @@ void DialogIncrements::closeEvent(QCloseEvent *event)
DialogIncrements::~DialogIncrements()
{
delete ui;
delete m;
}

View File

@ -68,11 +68,17 @@ public slots:
* @param column number of column
*/
void IncrementChanged ( qint32 row, qint32 column );
void MeasurementsChanged ( qint32 row, qint32 column );
void MeasurementChanged ( qint32 row, qint32 column );
/**
* @brief FullUpdateFromFile update information in tables form file
*/
void FullUpdateFromFile();
void SaveGivenName();
void SaveFamilyName();
void SaveEmail();
void SaveSex(int index);
void SaveBirthDate(const QDate & date);
void OpenTable();
signals:
/**
* @brief FullUpdateTree signal update data for dom document

View File

@ -39,7 +39,7 @@
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tabStandard">
<property name="sizePolicy">
@ -71,7 +71,7 @@
</widget>
</item>
<item alignment="Qt::AlignTop">
<widget class="QToolButton" name="toolButtonAnotherTable">
<widget class="QToolButton" name="toolButtonOpenMeasurements">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -107,7 +107,10 @@
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="page">
<widget class="QWidget" name="pagePersonalInformation">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
@ -119,34 +122,8 @@
<attribute name="label">
<string>Personal information</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>6</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QLabel" name="labelFamilyName">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Family name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditFamilyName"/>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="labelGivenName">
@ -172,7 +149,33 @@
</item>
</layout>
</item>
<item row="0" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>6</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QLabel" name="labelFamilyName">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Family name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditFamilyName"/>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="labelBirthDate">
@ -194,11 +197,15 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditBirthDate"/>
<widget class="QDateEdit" name="dateEditBirthDate">
<property name="displayFormat">
<string>yyyy-MM-dd</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="labelSex">
@ -220,11 +227,18 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditSex"/>
<widget class="QComboBox" name="comboBoxSex">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<item row="1" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="labelMail">
@ -251,14 +265,8 @@
</layout>
</item>
</layout>
<zorder></zorder>
<zorder></zorder>
<zorder></zorder>
<zorder></zorder>
<zorder>layoutWidget</zorder>
<zorder>label_5</zorder>
</widget>
<widget class="QWidget" name="page_2">
<widget class="QWidget" name="pageMeasurements">
<property name="geometry">
<rect>
<x>0</x>
@ -277,7 +285,7 @@
<bool>true</bool>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
<set>QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed</set>
</property>
<property name="alternatingRowColors">
<bool>true</bool>

View File

@ -108,17 +108,17 @@ void DialogIndividualMeasurements::DialogAccepted()
QFile iMeasur(_tablePath);
if (iMeasur.open(QIODevice::WriteOnly| QIODevice::Truncate))
{
const int Indent = 4;
const int indent = 4;
QTextStream out(&iMeasur);
out.setCodec("UTF-8");
m.save(out, Indent);
m.save(out, indent);
iMeasur.close();
}
}
catch(VException &e)
{
e.CriticalMessageBox(tr("File error."), this);
qWarning()<<"File error."<<e.ErrorMessage()<<e.DetailedInformation()<<Q_FUNC_INFO;
qDebug()<<"File error."<<e.ErrorMessage()<<e.DetailedInformation()<<Q_FUNC_INFO;
DialogRejected();
}
accept();
@ -215,7 +215,7 @@ void DialogIndividualMeasurements::LoadIndividualTables()
}
catch(VException &e)
{
qWarning()<<"File error."<<e.ErrorMessage()<<e.DetailedInformation()<<Q_FUNC_INFO;
qDebug()<<"File error."<<e.ErrorMessage()<<e.DetailedInformation()<<Q_FUNC_INFO;
continue;
}
}
@ -239,6 +239,11 @@ void DialogIndividualMeasurements::OpenTable()
{
const QString filter(tr("Individual measurements (*.vit)"));
QString fileName = QFileDialog::getOpenFileName(this, tr("Open file"), QDir::homePath(), filter);
if (fileName.isEmpty())
{
return;
}
try
{
VDomDocument::ValidateXML("://schema/individual_measurements.xsd", fileName);

View File

@ -40,24 +40,24 @@ namespace Ui
class DialogIndividualMeasurements : public QDialog
{
Q_OBJECT
public:
DialogIndividualMeasurements(VContainer *data, const QString &patternPieceName, QWidget *parent = nullptr);
~DialogIndividualMeasurements();
QString name() const;
QString tablePath() const;
public slots:
void OpenTable();
void NewTable();
void CheckState();
void DialogAccepted();
void DialogRejected();
private:
Q_DISABLE_COPY(DialogIndividualMeasurements)
Ui::DialogIndividualMeasurements *ui;
QString _name;
QString _tablePath;
VContainer *data;
void DialogAccepted();
void DialogRejected();
void CheckState();
void LoadIndividualTables();
void OpenTable();
void NewTable();
void InitUnits();
};

View File

@ -88,7 +88,7 @@ void DialogStandardMeasurements::DialogAccepted()
catch(VException &e)
{
e.CriticalMessageBox(tr("File error."), this);
qWarning()<<"File error."<<e.ErrorMessage()<<e.DetailedInformation()<<Q_FUNC_INFO;
qDebug()<<"File error."<<e.ErrorMessage()<<e.DetailedInformation()<<Q_FUNC_INFO;
return;
}
@ -153,7 +153,7 @@ void DialogStandardMeasurements::LoadStandardTables()
}
catch(VException &e)
{
qWarning()<<"File error."<<e.ErrorMessage()<<e.DetailedInformation()<<Q_FUNC_INFO;
qDebug()<<"File error."<<e.ErrorMessage()<<e.DetailedInformation()<<Q_FUNC_INFO;
continue;
}
}

View File

@ -45,15 +45,16 @@ public:
~DialogStandardMeasurements();
QString name() const;
QString tablePath() const;
public slots:
void DialogAccepted();
void DialogRejected();
void CheckState();
private:
Q_DISABLE_COPY(DialogStandardMeasurements)
Ui::DialogStandardMeasurements *ui;
VContainer *data;
QString _name;
QString _tablePath;
void DialogAccepted();
void DialogRejected();
void CheckState();
void LoadStandardTables();
};

View File

@ -81,7 +81,7 @@ void DialogDetail::ChoosedObject(quint32 id, const Valentina::Scenes &type)
NewItem(id, Valentina::NodeSplinePath, NodeDetail::Contour);
break;
default:
qWarning()<<tr("Got wrong scene object. Ignore.");
qDebug()<<tr("Got wrong scene object. Ignore.");
break;
}
ui.toolButtonDelete->setEnabled(true);
@ -136,7 +136,7 @@ void DialogDetail::NewItem(quint32 id, const Valentina::Tools &typeTool, const N
break;
}
default:
qWarning()<<"Got wrong tools. Ignore.";
qDebug()<<"Got wrong tools. Ignore.";
break;
}

View File

@ -258,7 +258,7 @@ void DialogTool::ChangeCurrentText(QComboBox *box, const QString &value)
}
else
{
qWarning()<<"Can't find object by name"<<value;
qDebug()<<"Can't find object by name"<<value;
}
}

View File

@ -102,7 +102,7 @@ QPainterPath VArc::GetPath() const
}
else
{
qWarning()<<"points.count() < 2"<<Q_FUNC_INFO;
qDebug()<<"points.count() < 2"<<Q_FUNC_INFO;
}
return path;
}

View File

@ -115,7 +115,7 @@ bool VDetail::OnEdge(const quint32 &p1, const quint32 &p2) const
QVector<VNodeDetail> list = listNodePoint();
if (list.size() < 3)
{
qWarning()<<"Not enough points.";
qDebug()<<"Not enough points.";
return false;
}
ptrdiff_t i = indexOfNode(list, p1);
@ -151,7 +151,7 @@ ptrdiff_t VDetail::Edge(const quint32 &p1, const quint32 &p2) const
{
if (OnEdge(p1, p2) == false)
{
qWarning()<<"Points don't on edge.";
qDebug()<<"Points don't on edge.";
return -1;
}
@ -176,7 +176,7 @@ void VDetail::NodeOnEdge(const quint32 &index, VNodeDetail &p1, VNodeDetail &p2)
QVector<VNodeDetail> list = listNodePoint();
if (index > static_cast<quint32>(list.size()))
{
qWarning()<<"Wrong edge index index ="<<index;
qDebug()<<"Wrong edge index index ="<<index;
return;
}
p1 = list.at(index);
@ -277,6 +277,6 @@ ptrdiff_t VDetail::indexOfNode(const QVector<VNodeDetail> &list, const quint32 &
return i;
}
}
qWarning()<<"Can't find node.";
qDebug()<<"Can't find node.";
return -1;
}

View File

@ -125,7 +125,7 @@ QPainterPath VEquidistant::ContourPath(const quint32 &idDetail, const VContainer
}
break;
default:
qWarning()<<"Get wrong tool type. Ignore."<<detail.at(i).getTypeTool();
qDebug()<<"Get wrong tool type. Ignore."<<detail.at(i).getTypeTool();
break;
}
}
@ -189,7 +189,7 @@ QVector<QPointF> VEquidistant::CorrectEquidistantPoints(const QVector<QPointF> &
QVector<QPointF> correctPoints;
if (points.size()<4)//Better don't check if only three points. We can destroy equidistant.
{
qWarning()<<"Only three points.";
qDebug()<<"Only three points.";
return points;
}
//Clear equivalent points
@ -371,7 +371,7 @@ QVector<QPointF> VEquidistant::EkvPoint(const QLineF &line1, const QLineF &line2
QVector<QPointF> points;
if (line1.p2() != line2.p2())
{
qWarning()<<"Last point of two lines must be equal.";
qDebug()<<"Last point of two lines must be equal.";
}
QPointF CrosPoint;
QLineF bigLine1 = ParallelLine(line1, width );

View File

@ -134,7 +134,7 @@ qreal VSpline::LengthT(qreal t) const
{
if (t < 0 || t > 1)
{
qWarning()<<"Wrong value t.";
qDebug()<<"Wrong value t.";
return 0;
}
QLineF seg1_2 ( GetP1 ().toQPointF(), GetP2 () );
@ -564,7 +564,7 @@ QPainterPath VSpline::GetPath() const
}
else
{
qWarning()<<"points.count() < 2"<<Q_FUNC_INFO;
qDebug()<<"points.count() < 2"<<Q_FUNC_INFO;
}
return splinePath;
}

View File

@ -36,7 +36,7 @@ VSplinePoint::VSplinePoint(VPointF pSpline, qreal kAsm1, qreal angle1, qreal kAs
{
if (qFuzzyCompare(qAbs(angle1-angle2), 180) == false)
{
qWarning()<<"angle1 and angle2 are not equal.";
qDebug()<<"angle1 and angle2 are not equal.";
}
SetAngle2(angle2);
}

View File

@ -108,6 +108,11 @@ void MainWindow::ActionNewDraw()
{
patternPieceName = stMeasurements.name();
path = stMeasurements.tablePath();
VStandardMeasurements m(pattern);
m.setContent(path);
m.SetSize();
m.SetHeight();
m.Measurements();
}
else
{
@ -122,6 +127,9 @@ void MainWindow::ActionNewDraw()
{
patternPieceName = indMeasurements.name();
path = indMeasurements.tablePath();
VIndividualMeasurements m(pattern);
m.setContent(path);
m.Measurements();
}
else
{
@ -140,7 +148,7 @@ void MainWindow::ActionNewDraw()
}
if (doc->appendDraw(patternPieceName) == false)
{
qWarning()<<"Error creating pattern with the name "<<patternPieceName<<".";
qDebug()<<"Error creating pattern with the name "<<patternPieceName<<".";
return;
}
disconnect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
@ -742,7 +750,7 @@ void MainWindow::CancelTool()
currentScene->clearSelection();
break;
default:
qWarning()<<"Got wrong tool type. Ignored.";
qDebug()<<"Got wrong tool type. Ignored.";
break;
}
}
@ -1111,62 +1119,10 @@ void MainWindow::MinimumScrollBar()
bool MainWindow::SavePattern(const QString &fileName)
{
try
{
doc->TestUniqueId();
}
catch (const VExceptionWrongId &e)
{
e.CriticalMessageBox(tr("Error no unique id."), this);
return false;
}
if (fileName.isEmpty())
{
qWarning()<<"Got empty file name.";
return false;
}
//Writing in temporary file
QFileInfo tempInfo(fileName);
QString temp = tempInfo.absolutePath() + "/" + tempInfo.baseName() + ".tmp";
QFile tempFile(temp);
if (tempFile.open(QIODevice::WriteOnly| QIODevice::Truncate))
{
const int Indent = 4;
QTextStream out(&tempFile);
out.setCodec("UTF-8");
doc->save(out, Indent);
tempFile.close();
}
//Replace temp file our
bool result = false;
QFile patternFile(fileName);
// We need here temporary file because we need restore pattern after error of copying temp file.
QTemporaryFile tempOfPattern;
if (tempOfPattern.open())
{
patternFile.copy(tempOfPattern.fileName());
}
if ( patternFile.exists() == false || patternFile.remove() )
{
if ( tempFile.copy(patternFile.fileName()) == false )
{
qWarning()<<"Could not copy temp file to pattern file"<<Q_FUNC_INFO;
tempOfPattern.copy(fileName);
result = false;
}
else
{
result = true;
}
}
else
{
qWarning()<<"Could not remove pattern file"<<Q_FUNC_INFO;
result = false;
}
const bool result = doc->SaveDocument(fileName);
if (result)
{
tempFile.remove();
if (tempInfo.suffix() != "autosave")
{
setCurrentFile(fileName);
@ -1183,7 +1139,7 @@ void MainWindow::AutoSavePattern()
QString autofile = curFile +".autosave";
if (SavePattern(autofile) == false)
{
qWarning()<<"Can not save pattern"<<Q_FUNC_INFO;
qDebug()<<"Can not save pattern"<<Q_FUNC_INFO;
}
}
}

View File

@ -240,7 +240,7 @@ void TableWindow::saveScene()
PsFile(name);
break;
default:
qWarning() << "Bad file suffix"<<Q_FUNC_INFO;
qDebug() << "Bad file suffix"<<Q_FUNC_INFO;
break;
}
paper->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine())));

View File

@ -70,7 +70,7 @@ QPointF VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Li
qreal dist = line.length();
if (dist>toolLength)
{
qWarning()<<"Correction of length in shoulder point tool. Parameter length too small.";
qDebug()<<"Correction of length in shoulder point tool. Parameter length too small.";
toolLength = dist;
}
if (qFuzzyCompare(dist, toolLength))

View File

@ -37,6 +37,7 @@ VToolSinglePoint::VToolSinglePoint (VPattern *doc, VContainer *data, quint32 id,
{
baseColor = Qt::red;
currentColor = baseColor;
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
ignoreFullUpdate = true;
this->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);

View File

@ -231,7 +231,7 @@ void VToolSplinePath::RefreshDataInFile()
QDomElement domElement = doc->elementById(QString().setNum(id));
if (domElement.isElement() == false)
{
qWarning()<<"Can't find element with id="<<id<<"in pattern file";
qDebug()<<"Can't find element with id="<<id<<"in pattern file";
return;
}
VSplinePath splPath = *VAbstractTool::data.GeometricObject<const VSplinePath *>(id);

View File

@ -152,7 +152,7 @@ QPointF VToolTriangle::FindPoint(const QPointF &axisP1, const QPointF &axisP2, c
if (c*c < a*a + b*b)
{
//Still don't know why this code handled. Need to think about that.
qWarning()<<"Can't find point."<<Q_FUNC_INFO;
qDebug()<<"Can't find point."<<Q_FUNC_INFO;
return line.p2();
}
}

View File

@ -58,17 +58,17 @@ void VAbstractNode::DeleteNode()
}
else
{
qWarning()<<"parent isn't element"<<Q_FUNC_INFO;
qDebug()<<"parent isn't element"<<Q_FUNC_INFO;
}
}
else
{
qWarning()<<"parent isNull"<<Q_FUNC_INFO;
qDebug()<<"parent isNull"<<Q_FUNC_INFO;
}
}
else
{
qWarning()<<"Can't get element by id form file = "<<id<<Q_FUNC_INFO;
qDebug()<<"Can't get element by id form file = "<<id<<Q_FUNC_INFO;
}
}
}

View File

@ -241,17 +241,17 @@ void VAbstractTool::DeleteTool(QGraphicsItem *tool)
}
else
{
qWarning()<<"parent isn't element"<<Q_FUNC_INFO;
qDebug()<<"parent isn't element"<<Q_FUNC_INFO;
}
}
else
{
qWarning()<<"parent isNull"<<Q_FUNC_INFO;
qDebug()<<"parent isNull"<<Q_FUNC_INFO;
}
}
else
{
qWarning()<<"Can't get element by id form file = "<<id<<Q_FUNC_INFO;
qDebug()<<"Can't get element by id form file = "<<id<<Q_FUNC_INFO;
}
}
}

View File

@ -69,7 +69,7 @@ VToolDetail::VToolDetail(VPattern *doc, VContainer *data, const quint32 &id, con
InitTool<VNodeSplinePath>(scene, detail[i]);
break;
default:
qWarning()<<"Get wrong tool type. Ignore.";
qDebug()<<"Get wrong tool type. Ignore.";
break;
}
doc->IncrementReferens(detail[i].getId());
@ -137,7 +137,7 @@ void VToolDetail::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern
}
break;
default:
qWarning()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
qDebug()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
break;
}
VNodeDetail node(id, detail[i].getTypeTool(), NodeDetail::Contour);
@ -395,7 +395,7 @@ void VToolDetail::AddNode(QDomElement &domElement, const VNodeDetail &node)
doc->SetAttribute(nod, AttrType, NodeSplinePath);
break;
default:
qWarning()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
qDebug()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
break;
}
domElement.appendChild(nod);

View File

@ -216,7 +216,7 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VPattern *doc, VContainer
}
break;
default:
qWarning()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
qDebug()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
break;
}
newDetail.append(VNodeDetail(id, det.at(i).getTypeTool(), NodeDetail::Contour));
@ -364,7 +364,7 @@ void VToolUnionDetails::UpdatePoints(const quint32 &idDetail, VContainer *data,
}
break;
default:
qWarning()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
qDebug()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
break;
}
}
@ -682,7 +682,7 @@ void VToolUnionDetails::AddNode(QDomElement &domElement, const VNodeDetail &node
doc->SetAttribute(nod, AttrType, QStringLiteral("NodeSplinePath"));
break;
default:
qWarning()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
qDebug()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO;
break;
}
domElement.appendChild(nod);

View File

@ -30,7 +30,8 @@
#include <QLineEdit>
TextDelegate::TextDelegate(QObject *parent): QItemDelegate(parent), lastText(QString("Name_"))
TextDelegate::TextDelegate(const QString &regex, QObject *parent): QItemDelegate(parent), lastText(QString("Name_")),
regex(regex)
{
//Little hack. Help save lineedit text in const method.
connect(this, &TextDelegate::SaveText, this, &TextDelegate::InitText);
@ -42,7 +43,7 @@ QWidget *TextDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem
Q_UNUSED(index);
QLineEdit *editor = new QLineEdit(parent);
//Same regex pattern in xsd file
editor->setValidator( new QRegExpValidator(QRegExp("([\\p{L}]|[^0-9])[_\\p{L}0-9]*")) );
editor->setValidator( new QRegExpValidator(QRegExp(regex)) );
connect(editor, &QLineEdit::editingFinished, this, &TextDelegate::commitAndCloseEditor);
return editor;
}

View File

@ -43,7 +43,7 @@ public:
* @brief TextDelegate constructor.
* @param parent parent widget.
*/
explicit TextDelegate(QObject *parent = nullptr);
TextDelegate(const QString &regex, QObject *parent = nullptr);
/**
* @brief createEditorReturns the widget used to edit the item specified by index for editing. The parent widget and
* style option are used to control how the editor widget appears.
@ -96,6 +96,7 @@ private:
* @brief lastValue last saved value.
*/
QString lastText;
QString regex;
};
#endif // TEXTDELEGATE_H

View File

@ -362,3 +362,81 @@ QString VDomDocument::UnitsToStr(const Valentina::Units &unit)
}
return result;
}
bool VDomDocument::SaveDocument(const QString &fileName)
{
if (fileName.isEmpty())
{
qDebug()<<"Got empty file name.";
return false;
}
//Writing in temporary file
QFileInfo tempInfo(fileName);
QString temp = tempInfo.absolutePath() + "/" + tempInfo.baseName() + ".tmp";
QFile tempFile(temp);
if (tempFile.open(QIODevice::WriteOnly| QIODevice::Truncate))
{
const int indent = 4;
QTextStream out(&tempFile);
out.setCodec("UTF-8");
save(out, indent);
tempFile.close();
}
//Replace temp file our
bool result = false;
QFile patternFile(fileName);
// We need here temporary file because we need restore document after error of copying temp file.
QTemporaryFile tempOfPattern;
if (tempOfPattern.open())
{
patternFile.copy(tempOfPattern.fileName());
}
if ( patternFile.exists() == false || patternFile.remove() )
{
if ( tempFile.copy(patternFile.fileName()) == false )
{
qDebug()<<"Could not copy temp file to document file"<<Q_FUNC_INFO;
tempOfPattern.copy(fileName);
result = false;
}
else
{
tempFile.remove();
result = true;
}
}
else
{
qDebug()<<"Could not remove document file"<<Q_FUNC_INFO;
result = false;
}
return result;
}
void VDomDocument::setTagText(const QString &tag, const QString &text)
{
const QDomNodeList nodeList = this->elementsByTagName(tag);
if (nodeList.isEmpty())
{
qDebug()<<"Can't save tag "<<tag<<Q_FUNC_INFO;
return;
}
else
{
const QDomNode domNode = nodeList.at(0);
if (domNode.isNull() == false && domNode.isElement())
{
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
QDomElement parent = domElement.parentNode().toElement();
QDomElement newTag = createElement(tag);
const QDomText newTagText = createTextNode(text);
newTag.appendChild(newTagText);
parent.replaceChild(newTag, domElement);
return;
}
}
}
}

View File

@ -123,11 +123,13 @@ public:
void setContent(const QString &fileName);
static Valentina::Units StrToUnits(const QString &unit);
static QString UnitsToStr(const Valentina::Units &unit);
virtual bool SaveDocument(const QString &fileName);
protected:
/**
* @brief data container with data.
*/
VContainer *data;
void setTagText(const QString &tag, const QString &text);
private:
Q_DISABLE_COPY(VDomDocument)

View File

@ -41,6 +41,10 @@ const QString VIndividualMeasurements::TagGiven_name = QStringLiteral("given-na
const QString VIndividualMeasurements::TagBirth_date = QStringLiteral("birth-date");
const QString VIndividualMeasurements::TagSex = QStringLiteral("sex");
const QString VIndividualMeasurements::TagUnit = QStringLiteral("unit");
const QString VIndividualMeasurements::TagEmail = QStringLiteral("email");
const QString VIndividualMeasurements::SexMale = QStringLiteral("male");
const QString VIndividualMeasurements::SexFemale = QStringLiteral("female");
VIndividualMeasurements::VIndividualMeasurements(VContainer *data):VDomDocument(data)
{
@ -54,30 +58,7 @@ Valentina::Units VIndividualMeasurements::Unit() const
void VIndividualMeasurements::setUnit(const Valentina::Units &unit)
{
const QDomNodeList nodeList = this->elementsByTagName(AttrUnit);
if (nodeList.isEmpty())
{
qWarning()<<"Can't save measurements units"<<Q_FUNC_INFO;
return;
}
else
{
const QDomNode domNode = nodeList.at(0);
if (domNode.isNull() == false && domNode.isElement())
{
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
QDomElement parent = domElement.parentNode().toElement();
QDomElement newUnit = createElement(TagUnit);
QDomText newUnitValue = createTextNode(UnitsToStr(unit));
newUnit.appendChild(newUnitValue);
parent.replaceChild(newUnit, domElement);
return;
}
}
}
setTagText(TagUnit, UnitsToStr(unit));
}
void VIndividualMeasurements::Measurements()
@ -176,7 +157,7 @@ void VIndividualMeasurements::Measurement(const QString &tag)
const QDomNodeList nodeList = this->elementsByTagName(tag);
if (nodeList.isEmpty())
{
qWarning()<<"Measurement" << tag <<"doesn't exist"<<Q_FUNC_INFO;
qDebug()<<"Measurement" << tag <<"doesn't exist"<<Q_FUNC_INFO;
return;
}
else
@ -207,7 +188,7 @@ void VIndividualMeasurements::Measurement(const QString &tag)
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;
qDebug()<<"Can't find language-independent measurement name for "<< tag;
return;
}
else
@ -222,7 +203,7 @@ void VIndividualMeasurements::Measurement(const QString &tag)
data->AddMeasurement(name, VMeasurement(value, gui_text, description, tag));
if (m_number.isEmpty())
{
qWarning()<<"Can't find language-independent measurement name for "<< tag;
qDebug()<<"Can't find language-independent measurement name for "<< tag;
return;
}
else
@ -237,27 +218,86 @@ void VIndividualMeasurements::Measurement(const QString &tag)
}
}
QString VIndividualMeasurements::Language()
QString VIndividualMeasurements::Language() const
{
return UniqueTagText(TagLang, "en");
}
QString VIndividualMeasurements::FamilyName()
QString VIndividualMeasurements::FamilyName() const
{
return UniqueTagText(TagFamily_name, "");
}
QString VIndividualMeasurements::GivenName()
void VIndividualMeasurements::setFamilyName(const QString &text)
{
setTagText(TagFamily_name, text);
}
QString VIndividualMeasurements::GivenName() const
{
return UniqueTagText(TagGiven_name, "");
}
QString VIndividualMeasurements::BirthDate()
void VIndividualMeasurements::setGivenName(const QString &text)
{
return UniqueTagText(TagBirth_date, "");
setTagText(TagGiven_name, text);
}
QString VIndividualMeasurements::Sex()
QDate VIndividualMeasurements::BirthDate() const
{
return UniqueTagText(TagSex, "");
const QString date = UniqueTagText(TagBirth_date, "1900-01-01");
return QDate::fromString(date, "yyyy-MM-dd");
}
void VIndividualMeasurements::setBirthDate(const QDate &date)
{
setTagText(TagBirth_date, date.toString("yyyy-MM-dd"));
}
VIndividualMeasurements::Genders VIndividualMeasurements::Sex() const
{
return StrToGender(UniqueTagText(TagSex, ""));
}
void VIndividualMeasurements::setSex(const VIndividualMeasurements::Genders &sex)
{
setTagText(TagSex, GenderToStr(sex));
}
QString VIndividualMeasurements::Mail() const
{
return UniqueTagText(TagEmail, "");
}
void VIndividualMeasurements::setMail(const QString &text)
{
setTagText(TagEmail, text);
}
QString VIndividualMeasurements::GenderToStr(const VIndividualMeasurements::Genders &sex)
{
switch (sex)
{
case Male:
return SexMale;
case Female:
return SexFemale;
default:
return SexMale;
}
}
VIndividualMeasurements::Genders VIndividualMeasurements::StrToGender(const QString &sex)
{
QStringList genders;
genders << SexMale << SexFemale;
switch (genders.indexOf(sex))
{
case 0: // SexMale
return Male;
case 1: // SexFemale
return Female;
default:
return Male;
}
}

View File

@ -30,20 +30,29 @@
#define VINDIVIDUALMEASUREMENTS_H
#include "vdomdocument.h"
#include <QDate>
class VIndividualMeasurements:public VDomDocument
{
public:
enum Sex { Male, Female };
Q_DECLARE_FLAGS(Genders, Sex)
VIndividualMeasurements(VContainer *data);
Valentina::Units Unit() const;
void setUnit(const Valentina::Units &unit);
void Measurements();
void Measurement(const QString &tag);
QString Language();
QString FamilyName();
QString GivenName();
QString BirthDate();
QString Sex();
QString Language() const;
QString FamilyName() const;
void setFamilyName(const QString &text);
QString GivenName() const;
void setGivenName(const QString &text);
QDate BirthDate() const;
void setBirthDate(const QDate &date);
VIndividualMeasurements::Genders Sex() const;
void setSex(const VIndividualMeasurements::Genders &sex);
QString Mail() const;
void setMail(const QString &text);
static const QString AttrIgnore;
static const QString AttrName;
static const QString AttrM_number;
@ -57,6 +66,17 @@ public:
static const QString TagBirth_date;
static const QString TagSex;
static const QString TagUnit;
static const QString TagEmail;
static const QString SexMale;
static const QString SexFemale;
static QString GenderToStr(const VIndividualMeasurements::Genders &sex);
static VIndividualMeasurements::Genders StrToGender(const QString &sex);
private:
void Measurement(const QString &tag);
};
Q_DECLARE_OPERATORS_FOR_FLAGS( VIndividualMeasurements::Genders )
#endif // VINDIVIDUALMEASUREMENTS_H

View File

@ -184,7 +184,7 @@ bool VPattern::SetNameDraw(const QString &name)
}
else
{
qWarning()<<"Can't find activ draw"<<Q_FUNC_INFO;
qDebug()<<"Can't find activ draw"<<Q_FUNC_INFO;
return false;
}
}
@ -237,7 +237,7 @@ void VPattern::Parse(const Document::Documents &parse, VMainGraphicsScene *scene
case 5: // TagMeasurements
break;
default:
qWarning()<<"Wrong tag name"<<Q_FUNC_INFO;
qDebug()<<"Wrong tag name"<<Q_FUNC_INFO;
break;
}
}
@ -435,7 +435,7 @@ void VPattern::SetPath(const QString &path)
{
if (path.isEmpty())
{
qWarning()<<"Path to measurements is empty"<<Q_FUNC_INFO;
qDebug()<<"Path to measurements is empty"<<Q_FUNC_INFO;
return;
}
QDomNodeList list = elementsByTagName(TagMeasurements);
@ -447,7 +447,7 @@ void VPattern::SetPath(const QString &path)
}
else
{
qWarning()<<"Can't save path to measurements"<<Q_FUNC_INFO;
qDebug()<<"Can't save path to measurements"<<Q_FUNC_INFO;
}
}
@ -510,6 +510,20 @@ Pattern::Measurements VPattern::MType() const
}
}
bool VPattern::SaveDocument(const QString &fileName)
{
try
{
TestUniqueId();
}
catch (const VExceptionWrongId &e)
{
e.CriticalMessageBox(tr("Error no unique id."));
return false;
}
return VDomDocument::SaveDocument(fileName);
}
void VPattern::FullUpdateTree()
{
VMainGraphicsScene *scene = new VMainGraphicsScene();
@ -578,7 +592,7 @@ void VPattern::ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScen
ParseDetails(sceneDetail, domElement, parse);
break;
default:
qWarning()<<"Wrong tag name"<<Q_FUNC_INFO;
qDebug()<<"Wrong tag name"<<Q_FUNC_INFO;
break;
}
}
@ -628,7 +642,7 @@ void VPattern::ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *
ParseToolsElement(scene, domElement, parse, domElement.attribute(AttrType, ""));
break;
default:
qWarning()<<"Wrong tag name"<<Q_FUNC_INFO;
qDebug()<<"Wrong tag name"<<Q_FUNC_INFO;
break;
}
}
@ -685,7 +699,7 @@ void VPattern::ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDomEle
tool = Valentina::NodeSplinePath;
break;
default:
qWarning()<<"Wrong node type."<<Q_FUNC_INFO;
qDebug()<<"Wrong node type."<<Q_FUNC_INFO;
break;
}
detail.append(VNodeDetail(id, tool, nodeType, mx, my));
@ -1084,7 +1098,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, const QDomElement &d
}
break;
default:
qWarning() << "Illegal point type in VDomDocument::ParsePointElement().";
qDebug() << "Illegal point type in VDomDocument::ParsePointElement().";
break;
}
}
@ -1228,7 +1242,7 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &
}
break;
default:
qWarning() << "Illegal spline type in VDomDocument::ParseSplineElement().";
qDebug() << "Illegal spline type in VDomDocument::ParseSplineElement().";
break;
}
}
@ -1283,7 +1297,7 @@ void VPattern::ParseArcElement(VMainGraphicsScene *scene, const QDomElement &dom
}
break;
default:
qWarning() << "Illegal arc type in VDomDocument::ParseArcElement().";
qDebug() << "Illegal arc type in VDomDocument::ParseArcElement().";
break;
}
}
@ -1320,7 +1334,7 @@ void VPattern::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &d
}
break;
default:
qWarning() << "Illegal tools type in VDomDocument::ParseToolsElement().";
qDebug() << "Illegal tools type in VDomDocument::ParseToolsElement().";
break;
}
}

View File

@ -193,6 +193,7 @@ public:
static const QString IncrementKsize;
static const QString IncrementKgrowth;
static const QString IncrementDescription;
virtual bool SaveDocument(const QString &fileName);
signals:
/**
* @brief ChangedActivDraw change active pattern peace.

View File

@ -55,7 +55,7 @@ QString VStandardMeasurements::Description()
const QString desc = UniqueTagText(TagDescription, "");
if (desc.isEmpty())
{
qWarning()<<"Empty description in standard table."<<Q_FUNC_INFO;
qDebug()<<"Empty description in standard table."<<Q_FUNC_INFO;
}
return desc;
}
@ -65,7 +65,7 @@ void VStandardMeasurements::Measurements()
const QDomNodeList nodeList = this->elementsByTagName(TagMeasurement);
if (nodeList.isEmpty())
{
qWarning()<<"Measurement list is empty"<<Q_FUNC_INFO;
qDebug()<<"Measurement list is empty"<<Q_FUNC_INFO;
return;
}
else
@ -170,8 +170,3 @@ void VStandardMeasurements::SetHeight()
}
}
}
void VStandardMeasurements::Update()
{
Measurements();
}

View File

@ -31,9 +31,8 @@
#include "vdomdocument.h"
class VStandardMeasurements:public QObject, public VDomDocument
class VStandardMeasurements:public VDomDocument
{
Q_OBJECT
public:
VStandardMeasurements(VContainer *data);
Valentina::Units Unit();
@ -51,8 +50,6 @@ public:
static const QString AttrSize_increace;
static const QString AttrHeight_increase;
static const QString AttrNumber;
public slots:
void Update();
};
#endif // VSTANDARDMEASUREMENTS_H