From d5c2b1b50d582319745def5b138b2b2bc11582e3 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 14 Aug 2017 19:34:33 +0300 Subject: [PATCH] GetTemplate after editing. --HG-- branch : feature --- .../dialogs/dialogpatternproperties.cpp | 61 ++++++++++++++----- .../dialogs/dialogpatternproperties.h | 6 ++ .../dialogs/support/dialogeditlabel.cpp | 6 +- .../vtools/dialogs/support/dialogeditlabel.h | 4 +- 4 files changed, 57 insertions(+), 20 deletions(-) diff --git a/src/app/valentina/dialogs/dialogpatternproperties.cpp b/src/app/valentina/dialogs/dialogpatternproperties.cpp index f73e26746..9f09d477d 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.cpp +++ b/src/app/valentina/dialogs/dialogpatternproperties.cpp @@ -62,10 +62,12 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat securityChanged(false), labelDataChanged(false), askSaveLabelData(false), + templateDataChanged(false), deleteAction(nullptr), changeImageAction(nullptr), saveImageAction(nullptr), - showImageAction(nullptr) + showImageAction(nullptr), + templateLines() { ui->setupUi(this); @@ -236,6 +238,7 @@ void DialogPatternProperties::Apply() break; case 3: SaveLabelData(); + SaveTemplateData(); break; default: break; @@ -273,10 +276,8 @@ void DialogPatternProperties::Ok() emit doc->patternChanged(false); } - if (labelDataChanged == true) - { - SaveLabelData(); - } + SaveLabelData(); + SaveTemplateData(); close(); } @@ -596,17 +597,31 @@ void DialogPatternProperties::SaveDefValues() //--------------------------------------------------------------------------------------------------------------------- void DialogPatternProperties::SaveLabelData() { - doc->SetPatternName(ui->lineEditPatternName->text()); - doc->SetPatternNumber(ui->lineEditPatternNumber->text()); - doc->SetCompanyName(ui->lineEditCompanyName->text()); - doc->SetCustomerName(ui->lineEditCustomerName->text()); - doc->SetPatternSize(ui->lineEditSize->text()); - doc->SetDateVisible(ui->checkBoxShowDate->isChecked()); - doc->SetMesurementsVisible(ui->checkBoxShowMeasurements->isChecked()); + if (labelDataChanged) + { + doc->SetPatternName(ui->lineEditPatternName->text()); + doc->SetPatternNumber(ui->lineEditPatternNumber->text()); + doc->SetCompanyName(ui->lineEditCompanyName->text()); + doc->SetCustomerName(ui->lineEditCustomerName->text()); + doc->SetPatternSize(ui->lineEditSize->text()); + doc->SetDateVisible(ui->checkBoxShowDate->isChecked()); + doc->SetMesurementsVisible(ui->checkBoxShowMeasurements->isChecked()); - labelDataChanged = false; - askSaveLabelData = false; - emit doc->patternChanged(false); + labelDataChanged = false; + askSaveLabelData = false; + emit doc->patternChanged(false); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogPatternProperties::SaveTemplateData() +{ + if (templateDataChanged) + { + //doc->SetTemplate(templateLines); + templateDataChanged = false; + //emit doc->patternChanged(false); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -873,5 +888,19 @@ void DialogPatternProperties::EditLabel() } DialogEditLabel editor(doc); - editor.exec(); + +// if (templateDataChanged) +// { +// editor.SetTemplate(templateLines); +// } +// else +// { +// editor.SetTemplate(doc->GetTemplate()); +// } + + if (QDialog::Accepted == editor.exec()) + { + templateLines = editor.GetTemplate(); + templateDataChanged = true; + } } diff --git a/src/app/valentina/dialogs/dialogpatternproperties.h b/src/app/valentina/dialogs/dialogpatternproperties.h index d72c8eaae..7c0ee719b 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.h +++ b/src/app/valentina/dialogs/dialogpatternproperties.h @@ -33,6 +33,8 @@ #include "../options.h" #include +#include "../vformat/vlabeltemplate.h" + class VPattern; class VContainer; class QCheckBox; @@ -78,11 +80,14 @@ private: bool securityChanged; bool labelDataChanged; bool askSaveLabelData; + bool templateDataChanged; QAction *deleteAction; QAction *changeImageAction; QAction *saveImageAction; QAction *showImageAction; + QVector templateLines; + void SetHeightsChecked(bool enabled); void SetSizesChecked(bool enabled); void InitHeights(); @@ -98,6 +103,7 @@ private: void SaveGradation(); void SaveDefValues(); void SaveLabelData(); + void SaveTemplateData(); void SetDefaultHeight(const QString &def); void SetDefaultSize(const QString &def); diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp index 542a43137..59a80d36a 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp @@ -315,7 +315,7 @@ void DialogEditLabel::ExportTemplate() VLabelTemplate ltemplate; ltemplate.CreateEmptyTemplate(); - ltemplate.AddLines(PrepareLines()); + ltemplate.AddLines(GetTemplate()); QString error; const bool result = ltemplate.SaveDocument(fileName, error); @@ -388,7 +388,7 @@ void DialogEditLabel::TabChanged(int index) { ui->toolButtonNewLabel->setDisabled(true); ui->toolButtonImportLabel->setDisabled(true); - InitPreviewLines(PrepareLines()); + InitPreviewLines(GetTemplate()); } else { @@ -491,7 +491,7 @@ QString DialogEditLabel::ReplacePlaceholders(QString line) const } //--------------------------------------------------------------------------------------------------------------------- -QVector DialogEditLabel::PrepareLines() const +QVector DialogEditLabel::GetTemplate() const { QVector lines; diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.h b/src/libs/vtools/dialogs/support/dialogeditlabel.h index c02bba8bb..3450af694 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.h +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.h @@ -49,6 +49,8 @@ public: explicit DialogEditLabel(VAbstractPattern *doc, QWidget *parent = nullptr); virtual ~DialogEditLabel(); + QVector GetTemplate() const; + private slots: void ShowLineDetails(); void AddLine(); @@ -76,7 +78,7 @@ private: QString ReplacePlaceholders(QString line) const; - QVector PrepareLines() const; + void InitEditLines(const QVector &lines); void InitPreviewLines(const QVector &lines); };