GetTemplate after editing.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-08-14 19:34:33 +03:00
parent 0f4c993c83
commit d5c2b1b50d
4 changed files with 57 additions and 20 deletions

View File

@ -62,10 +62,12 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat
securityChanged(false), securityChanged(false),
labelDataChanged(false), labelDataChanged(false),
askSaveLabelData(false), askSaveLabelData(false),
templateDataChanged(false),
deleteAction(nullptr), deleteAction(nullptr),
changeImageAction(nullptr), changeImageAction(nullptr),
saveImageAction(nullptr), saveImageAction(nullptr),
showImageAction(nullptr) showImageAction(nullptr),
templateLines()
{ {
ui->setupUi(this); ui->setupUi(this);
@ -236,6 +238,7 @@ void DialogPatternProperties::Apply()
break; break;
case 3: case 3:
SaveLabelData(); SaveLabelData();
SaveTemplateData();
break; break;
default: default:
break; break;
@ -273,10 +276,8 @@ void DialogPatternProperties::Ok()
emit doc->patternChanged(false); emit doc->patternChanged(false);
} }
if (labelDataChanged == true) SaveLabelData();
{ SaveTemplateData();
SaveLabelData();
}
close(); close();
} }
@ -596,17 +597,31 @@ void DialogPatternProperties::SaveDefValues()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::SaveLabelData() void DialogPatternProperties::SaveLabelData()
{ {
doc->SetPatternName(ui->lineEditPatternName->text()); if (labelDataChanged)
doc->SetPatternNumber(ui->lineEditPatternNumber->text()); {
doc->SetCompanyName(ui->lineEditCompanyName->text()); doc->SetPatternName(ui->lineEditPatternName->text());
doc->SetCustomerName(ui->lineEditCustomerName->text()); doc->SetPatternNumber(ui->lineEditPatternNumber->text());
doc->SetPatternSize(ui->lineEditSize->text()); doc->SetCompanyName(ui->lineEditCompanyName->text());
doc->SetDateVisible(ui->checkBoxShowDate->isChecked()); doc->SetCustomerName(ui->lineEditCustomerName->text());
doc->SetMesurementsVisible(ui->checkBoxShowMeasurements->isChecked()); doc->SetPatternSize(ui->lineEditSize->text());
doc->SetDateVisible(ui->checkBoxShowDate->isChecked());
doc->SetMesurementsVisible(ui->checkBoxShowMeasurements->isChecked());
labelDataChanged = false; labelDataChanged = false;
askSaveLabelData = false; askSaveLabelData = false;
emit doc->patternChanged(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); 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;
}
} }

View File

@ -33,6 +33,8 @@
#include "../options.h" #include "../options.h"
#include <QMap> #include <QMap>
#include "../vformat/vlabeltemplate.h"
class VPattern; class VPattern;
class VContainer; class VContainer;
class QCheckBox; class QCheckBox;
@ -78,11 +80,14 @@ private:
bool securityChanged; bool securityChanged;
bool labelDataChanged; bool labelDataChanged;
bool askSaveLabelData; bool askSaveLabelData;
bool templateDataChanged;
QAction *deleteAction; QAction *deleteAction;
QAction *changeImageAction; QAction *changeImageAction;
QAction *saveImageAction; QAction *saveImageAction;
QAction *showImageAction; QAction *showImageAction;
QVector<VLabelTemplateLine> templateLines;
void SetHeightsChecked(bool enabled); void SetHeightsChecked(bool enabled);
void SetSizesChecked(bool enabled); void SetSizesChecked(bool enabled);
void InitHeights(); void InitHeights();
@ -98,6 +103,7 @@ private:
void SaveGradation(); void SaveGradation();
void SaveDefValues(); void SaveDefValues();
void SaveLabelData(); void SaveLabelData();
void SaveTemplateData();
void SetDefaultHeight(const QString &def); void SetDefaultHeight(const QString &def);
void SetDefaultSize(const QString &def); void SetDefaultSize(const QString &def);

View File

@ -315,7 +315,7 @@ void DialogEditLabel::ExportTemplate()
VLabelTemplate ltemplate; VLabelTemplate ltemplate;
ltemplate.CreateEmptyTemplate(); ltemplate.CreateEmptyTemplate();
ltemplate.AddLines(PrepareLines()); ltemplate.AddLines(GetTemplate());
QString error; QString error;
const bool result = ltemplate.SaveDocument(fileName, error); const bool result = ltemplate.SaveDocument(fileName, error);
@ -388,7 +388,7 @@ void DialogEditLabel::TabChanged(int index)
{ {
ui->toolButtonNewLabel->setDisabled(true); ui->toolButtonNewLabel->setDisabled(true);
ui->toolButtonImportLabel->setDisabled(true); ui->toolButtonImportLabel->setDisabled(true);
InitPreviewLines(PrepareLines()); InitPreviewLines(GetTemplate());
} }
else else
{ {
@ -491,7 +491,7 @@ QString DialogEditLabel::ReplacePlaceholders(QString line) const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<VLabelTemplateLine> DialogEditLabel::PrepareLines() const QVector<VLabelTemplateLine> DialogEditLabel::GetTemplate() const
{ {
QVector<VLabelTemplateLine> lines; QVector<VLabelTemplateLine> lines;

View File

@ -49,6 +49,8 @@ public:
explicit DialogEditLabel(VAbstractPattern *doc, QWidget *parent = nullptr); explicit DialogEditLabel(VAbstractPattern *doc, QWidget *parent = nullptr);
virtual ~DialogEditLabel(); virtual ~DialogEditLabel();
QVector<VLabelTemplateLine> GetTemplate() const;
private slots: private slots:
void ShowLineDetails(); void ShowLineDetails();
void AddLine(); void AddLine();
@ -76,7 +78,7 @@ private:
QString ReplacePlaceholders(QString line) const; QString ReplacePlaceholders(QString line) const;
QVector<VLabelTemplateLine> PrepareLines() const;
void InitEditLines(const QVector<VLabelTemplateLine> &lines); void InitEditLines(const QVector<VLabelTemplateLine> &lines);
void InitPreviewLines(const QVector<VLabelTemplateLine> &lines); void InitPreviewLines(const QVector<VLabelTemplateLine> &lines);
}; };