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),
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;
}
}

View File

@ -33,6 +33,8 @@
#include "../options.h"
#include <QMap>
#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<VLabelTemplateLine> 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);

View File

@ -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<VLabelTemplateLine> DialogEditLabel::PrepareLines() const
QVector<VLabelTemplateLine> DialogEditLabel::GetTemplate() const
{
QVector<VLabelTemplateLine> lines;

View File

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