diff --git a/share/resources/schema/individual_measurements.xsd b/share/resources/schema/individual_measurements.xsd
index 39928eaa9..55cd7f9a3 100644
--- a/share/resources/schema/individual_measurements.xsd
+++ b/share/resources/schema/individual_measurements.xsd
@@ -874,7 +874,7 @@
-
+
diff --git a/share/resources/schema/pattern.xsd b/share/resources/schema/pattern.xsd
index 532c2a12e..1f1b0c00c 100644
--- a/share/resources/schema/pattern.xsd
+++ b/share/resources/schema/pattern.xsd
@@ -213,7 +213,7 @@
-
+
diff --git a/share/resources/schema/standard_measurements.xsd b/share/resources/schema/standard_measurements.xsd
index ebff0c5bf..4ac6eb0d5 100644
--- a/share/resources/schema/standard_measurements.xsd
+++ b/share/resources/schema/standard_measurements.xsd
@@ -38,7 +38,7 @@
-
+
diff --git a/src/container/vcontainer.cpp b/src/container/vcontainer.cpp
index 9f3209a21..b108b3b81 100644
--- a/src/container/vcontainer.cpp
+++ b/src/container/vcontainer.cpp
@@ -81,27 +81,20 @@ void VContainer::setData(const VContainer &data)
switch (i.value()->getType())
{
case (GObject::Arc):
- {
CopyGObject(data, i.key());
break;
- }
case (GObject::Point):
- {
CopyGObject(data, i.key());
break;
- }
case (GObject::Spline):
- {
CopyGObject(data, i.key());
break;
- }
case (GObject::SplinePath):
- {
CopyGObject(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();
diff --git a/src/container/vcontainer.h b/src/container/vcontainer.h
index 88a4a1329..6ccf5c1e1 100644
--- a/src/container/vcontainer.h
+++ b/src/container/vcontainer.h
@@ -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();
diff --git a/src/dialogs/app/dialoghistory.cpp b/src/dialogs/app/dialoghistory.cpp
index fbf9e1576..5c21887d8 100644
--- a/src/dialogs/app/dialoghistory.cpp
+++ b/src/dialogs/app/dialoghistory.cpp
@@ -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"<
#include
@@ -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(&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."<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 = "<text());
+ 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();
+ QDomNodeList list = m->elementsByTagName(tag);
+ QDomElement domElement = list.at(0).toElement();
+ if (domElement.isElement() == false)
+ {
+ qDebug()<<"Cant't find measurement "<SetAttribute(domElement, VIndividualMeasurements::AttrValue, item->text());
+ if (m->SaveDocument(doc->MPath()) == false)
+ {
+ 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"<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;
}
diff --git a/src/dialogs/app/dialogincrements.h b/src/dialogs/app/dialogincrements.h
index eb920b00c..c988f5b1e 100644
--- a/src/dialogs/app/dialogincrements.h
+++ b/src/dialogs/app/dialogincrements.h
@@ -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
diff --git a/src/dialogs/app/dialogincrements.ui b/src/dialogs/app/dialogincrements.ui
index ae387ab7a..f3a0d3c19 100644
--- a/src/dialogs/app/dialogincrements.ui
+++ b/src/dialogs/app/dialogincrements.ui
@@ -39,7 +39,7 @@
QTabWidget::North
- 0
+ 1
@@ -71,7 +71,7 @@
-
-
+
0
@@ -107,7 +107,10 @@
1
-
+
+
+ true
+
0
@@ -119,34 +122,8 @@
Personal information
-
-
-
-
-
- 6
-
-
- QLayout::SetDefaultConstraint
-
-
-
-
-
-
- 0
- 0
-
-
-
- Family name
-
-
-
- -
-
-
-
-
- -
+
+
-
-
@@ -172,7 +149,33 @@
- -
+
-
+
+
+ 6
+
+
+ QLayout::SetDefaultConstraint
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ Family name
+
+
+
+ -
+
+
+
+
+ -
-
@@ -194,11 +197,15 @@
-
-
+
+
+ yyyy-MM-dd
+
+
- -
+
-
-
@@ -220,11 +227,18 @@
-
-
+
+
+
+ 0
+ 0
+
+
+
- -
+
-
-
@@ -251,14 +265,8 @@
-
-
-
-
- layoutWidget
- label_5
-
+
0
@@ -277,7 +285,7 @@
true
- QAbstractItemView::NoEditTriggers
+ QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed
true
diff --git a/src/dialogs/app/dialogindividualmeasurements.cpp b/src/dialogs/app/dialogindividualmeasurements.cpp
index 19096b078..ef332c049 100644
--- a/src/dialogs/app/dialogindividualmeasurements.cpp
+++ b/src/dialogs/app/dialogindividualmeasurements.cpp
@@ -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."<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;
}
diff --git a/src/dialogs/tools/dialogtool.cpp b/src/dialogs/tools/dialogtool.cpp
index 37387ce34..320dea50a 100644
--- a/src/dialogs/tools/dialogtool.cpp
+++ b/src/dialogs/tools/dialogtool.cpp
@@ -258,7 +258,7 @@ void DialogTool::ChangeCurrentText(QComboBox *box, const QString &value)
}
else
{
- qWarning()<<"Can't find object by name"< 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 list = listNodePoint();
if (index > static_cast(list.size()))
{
- qWarning()<<"Wrong edge index index ="< VEquidistant::CorrectEquidistantPoints(const QVector &
QVector 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 VEquidistant::EkvPoint(const QLineF &line1, const QLineF &line2
QVector 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 );
diff --git a/src/geometry/vspline.cpp b/src/geometry/vspline.cpp
index 5b731da0e..a3457a45b 100644
--- a/src/geometry/vspline.cpp
+++ b/src/geometry/vspline.cpp
@@ -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"<appendDraw(patternPieceName) == false)
{
- qWarning()<<"Error creating pattern with the name "<(&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"<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"<setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine())));
diff --git a/src/tools/drawTools/vtoolshoulderpoint.cpp b/src/tools/drawTools/vtoolshoulderpoint.cpp
index 255fd6bfe..4aa522f9c 100644
--- a/src/tools/drawTools/vtoolshoulderpoint.cpp
+++ b/src/tools/drawTools/vtoolshoulderpoint.cpp
@@ -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))
diff --git a/src/tools/drawTools/vtoolsinglepoint.cpp b/src/tools/drawTools/vtoolsinglepoint.cpp
index 561c0646d..f88570791 100644
--- a/src/tools/drawTools/vtoolsinglepoint.cpp
+++ b/src/tools/drawTools/vtoolsinglepoint.cpp
@@ -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);
diff --git a/src/tools/drawTools/vtoolsplinepath.cpp b/src/tools/drawTools/vtoolsplinepath.cpp
index fd0f47c00..523c5e087 100644
--- a/src/tools/drawTools/vtoolsplinepath.cpp
+++ b/src/tools/drawTools/vtoolsplinepath.cpp
@@ -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);
diff --git a/src/tools/drawTools/vtooltriangle.cpp b/src/tools/drawTools/vtooltriangle.cpp
index b757ea2cc..4bfbb486e 100644
--- a/src/tools/drawTools/vtooltriangle.cpp
+++ b/src/tools/drawTools/vtooltriangle.cpp
@@ -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."<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."<SetAttribute(nod, AttrType, NodeSplinePath);
break;
default:
- qWarning()<<"May be wrong tool type!!! Ignoring."<SetAttribute(nod, AttrType, QStringLiteral("NodeSplinePath"));
break;
default:
- qWarning()<<"May be wrong tool type!!! Ignoring."<
-TextDelegate::TextDelegate(QObject *parent): QItemDelegate(parent), lastText(QString("Name_"))
+TextDelegate::TextDelegate(const QString ®ex, 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;
}
diff --git a/src/widgets/textdelegate.h b/src/widgets/textdelegate.h
index 442ca1a3d..c904e2223 100644
--- a/src/widgets/textdelegate.h
+++ b/src/widgets/textdelegate.h
@@ -43,7 +43,7 @@ public:
* @brief TextDelegate constructor.
* @param parent parent widget.
*/
- explicit TextDelegate(QObject *parent = nullptr);
+ TextDelegate(const QString ®ex, 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
diff --git a/src/xml/vdomdocument.cpp b/src/xml/vdomdocument.cpp
index f6494543a..402e4f2cb 100644
--- a/src/xml/vdomdocument.cpp
+++ b/src/xml/vdomdocument.cpp
@@ -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"<elementsByTagName(tag);
+ if (nodeList.isEmpty())
+ {
+ qDebug()<<"Can't save tag "<elementsByTagName(AttrUnit);
- if (nodeList.isEmpty())
- {
- qWarning()<<"Can't save measurements units"<elementsByTagName(tag);
if (nodeList.isEmpty())
{
- qWarning()<<"Measurement" << tag <<"doesn't exist"<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;
+ }
}
diff --git a/src/xml/vindividualmeasurements.h b/src/xml/vindividualmeasurements.h
index de5b37150..7af71045e 100644
--- a/src/xml/vindividualmeasurements.h
+++ b/src/xml/vindividualmeasurements.h
@@ -30,20 +30,29 @@
#define VINDIVIDUALMEASUREMENTS_H
#include "vdomdocument.h"
+#include
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();
+ void setUnit(const Valentina::Units &unit);
+ void Measurements();
+ 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
diff --git a/src/xml/vpattern.cpp b/src/xml/vpattern.cpp
index e9f72eb28..16e5b320d 100644
--- a/src/xml/vpattern.cpp
+++ b/src/xml/vpattern.cpp
@@ -184,7 +184,7 @@ bool VPattern::SetNameDraw(const QString &name)
}
else
{
- qWarning()<<"Can't find activ draw"<elementsByTagName(TagMeasurement);
if (nodeList.isEmpty())
{
- qWarning()<<"Measurement list is empty"<