Refactoring.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-08-14 19:44:20 +03:00
parent d5c2b1b50d
commit 10e1c2fbfa
2 changed files with 47 additions and 51 deletions

View File

@ -221,20 +221,13 @@ void DialogPatternProperties::Apply()
{ {
case 0: case 0:
SaveDescription(); SaveDescription();
descriptionChanged = false;
emit doc->patternChanged(false);
break; break;
case 1: case 1:
SaveGradation(); SaveGradation();
gradationChanged = false;
SaveDefValues(); SaveDefValues();
defaultChanged = false;
emit doc->patternChanged(false);
break; break;
case 2: case 2:
doc->SetReadOnly(ui->checkBoxPatternReadOnly->isChecked()); SaveReadOnlyState();
securityChanged = false;
emit doc->patternChanged(false);
break; break;
case 3: case 3:
SaveLabelData(); SaveLabelData();
@ -248,34 +241,10 @@ void DialogPatternProperties::Apply()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::Ok() void DialogPatternProperties::Ok()
{ {
if (descriptionChanged) SaveDescription();
{ SaveGradation();
SaveDescription(); SaveDefValues();
descriptionChanged = false; SaveReadOnlyState();
emit doc->patternChanged(false);
}
if (gradationChanged)
{
SaveGradation();
gradationChanged = false;
emit doc->patternChanged(false);
}
if (defaultChanged)
{
SaveDefValues();
defaultChanged = false;
emit doc->patternChanged(false);
}
if (securityChanged)
{
doc->SetReadOnly(ui->checkBoxPatternReadOnly->isChecked());
securityChanged = false;
emit doc->patternChanged(false);
}
SaveLabelData(); SaveLabelData();
SaveTemplateData(); SaveTemplateData();
@ -565,33 +534,48 @@ void DialogPatternProperties::CheckApplyOk()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::SaveDescription() void DialogPatternProperties::SaveDescription()
{ {
doc->SetNotes(ui->plainTextEditTechNotes->document()->toPlainText()); if (descriptionChanged)
doc->SetDescription(ui->plainTextEditDescription->document()->toPlainText()); {
doc->SetAuthor(ui->lineEditAuthor->text()); doc->SetNotes(ui->plainTextEditTechNotes->document()->toPlainText());
doc->SetDescription(ui->plainTextEditDescription->document()->toPlainText());
doc->SetAuthor(ui->lineEditAuthor->text());
descriptionChanged = false;
emit doc->patternChanged(false);
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::SaveGradation() void DialogPatternProperties::SaveGradation()
{ {
doc->SetGradationHeights(heights); if (gradationChanged)
doc->SetGradationSizes(sizes); {
emit UpdateGradation(); doc->SetGradationHeights(heights);
doc->SetGradationSizes(sizes);
emit UpdateGradation();
gradationChanged = false;
emit doc->patternChanged(false);
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::SaveDefValues() void DialogPatternProperties::SaveDefValues()
{ {
if (ui->radioButtonDefFromM->isChecked()) if (defaultChanged)
{ {
doc->SetDefCustom(false); if (ui->radioButtonDefFromM->isChecked())
{
doc->SetDefCustom(false);
}
else
{
doc->SetDefCustom(true);
doc->SetDefCustomHeight(ui->comboBoxHeight->currentText().toInt());
doc->SetDefCustomSize(ui->comboBoxSize->currentText().toInt());
}
defaultChanged = false;
emit doc->patternChanged(false);
} }
else
{
doc->SetDefCustom(true);
doc->SetDefCustomHeight(ui->comboBoxHeight->currentText().toInt());
doc->SetDefCustomSize(ui->comboBoxSize->currentText().toInt());
}
defaultChanged = false;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -624,6 +608,17 @@ void DialogPatternProperties::SaveTemplateData()
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::SaveReadOnlyState()
{
if (securityChanged)
{
doc->SetReadOnly(ui->checkBoxPatternReadOnly->isChecked());
securityChanged = false;
emit doc->patternChanged(false);
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::SetDefaultHeight(const QString &def) void DialogPatternProperties::SetDefaultHeight(const QString &def)
{ {

View File

@ -104,6 +104,7 @@ private:
void SaveDefValues(); void SaveDefValues();
void SaveLabelData(); void SaveLabelData();
void SaveTemplateData(); void SaveTemplateData();
void SaveReadOnlyState();
void SetDefaultHeight(const QString &def); void SetDefaultHeight(const QString &def);
void SetDefaultSize(const QString &def); void SetDefaultSize(const QString &def);