diff --git a/src/app/valentina/dialogs/dialogincrements.cpp b/src/app/valentina/dialogs/dialogincrements.cpp index e5780293b..1d76488cc 100644 --- a/src/app/valentina/dialogs/dialogincrements.cpp +++ b/src/app/valentina/dialogs/dialogincrements.cpp @@ -979,16 +979,7 @@ void DialogIncrements::SaveIncrName(const QString &text) newName = name; } - if (lineEdit == ui->lineEditName) - { - doc->SetIncrementName(nameField->text(), newName); - - } - else if (lineEdit == ui->lineEditNamePC) - { - doc->SetPreviewCalculationName(nameField->text(), newName); - } - + doc->SetIncrementName(nameField->text(), newName); QVector expression = doc->ListIncrementExpressions(); doc->ReplaceNameInFormula(expression, nameField->text(), newName); @@ -1030,16 +1021,7 @@ void DialogIncrements::SaveIncrDescription() } const QTableWidgetItem *nameField = table->item(row, 0); - - if (textEdit == ui->plainTextEditDescription) - { - doc->SetIncrementDescription(nameField->text(), textEdit->toPlainText()); - } - else if (textEdit == ui->plainTextEditDescriptionPC) - { - doc->SetPreviewCalculationDescription(nameField->text(), textEdit->toPlainText()); - } - + doc->SetIncrementDescription(nameField->text(), textEdit->toPlainText()); LocalUpdateTree(); const QTextCursor cursor = textEdit->textCursor(); @@ -1112,16 +1094,7 @@ void DialogIncrements::SaveIncrFormula() try { const QString formula = qApp->TrVars()->FormulaFromUser(text, qApp->Settings()->GetOsSeparator()); - - if (textEdit == ui->plainTextEditFormula) - { - doc->SetIncrementFormula(nameField->text(), formula); - } - else if (textEdit == ui->plainTextEditFormulaPC) - { - doc->SetPreviewCalculationFormula(nameField->text(), formula); - } - + doc->SetIncrementFormula(nameField->text(), formula); } catch (qmu::QmuParserError &e) // Just in case something bad will happen { diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 6e39c932e..35544e646 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -3161,34 +3161,12 @@ void VPattern::MoveDownIncrement(const QString &type, const QString &name) } //--------------------------------------------------------------------------------------------------------------------- -void VPattern::SetIncrementName(const QString &type, const QString &name, const QString &text) +void VPattern::SetIncrementAttribute(const QString &name, const QString &attr, const QString &text) { QDomElement node = FindIncrement(name); if (not node.isNull()) { - SetAttribute(node, IncrementName, text); - emit patternChanged(false); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPattern::SetIncrementFormula(const QString &type, const QString &name, const QString &text) -{ - QDomElement node = FindIncrement(name); - if (not node.isNull()) - { - SetAttribute(node, IncrementFormula, text); - emit patternChanged(false); - } -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPattern::SetIncrementDescription(const QString &type, const QString &name, const QString &text) -{ - QDomElement node = FindIncrement(name); - if (not node.isNull()) - { - SetAttribute(node, IncrementDescription, text); + SetAttribute(node, attr, text); emit patternChanged(false); } } @@ -3552,37 +3530,19 @@ void VPattern::MoveDownPreviewCalculation(const QString &name) //--------------------------------------------------------------------------------------------------------------------- void VPattern::SetIncrementName(const QString &name, const QString &text) { - SetIncrementName(TagIncrement, name, text); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPattern::SetPreviewCalculationName(const QString &name, const QString &text) -{ - SetIncrementName(TagPreviewCalculations, name, text); + SetIncrementAttribute(name, IncrementName, text); } //--------------------------------------------------------------------------------------------------------------------- void VPattern::SetIncrementFormula(const QString &name, const QString &text) { - SetIncrementFormula(TagIncrement, name, text); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPattern::SetPreviewCalculationFormula(const QString &name, const QString &text) -{ - SetIncrementFormula(TagPreviewCalculations, name, text); + SetIncrementAttribute(name, IncrementFormula, text); } //--------------------------------------------------------------------------------------------------------------------- void VPattern::SetIncrementDescription(const QString &name, const QString &text) { - SetIncrementDescription(TagIncrement, name, text); -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPattern::SetPreviewCalculationDescription(const QString &name, const QString &text) -{ - SetIncrementDescription(TagPreviewCalculations, name, text); + SetIncrementAttribute(name, IncrementDescription, text); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/xml/vpattern.h b/src/app/valentina/xml/vpattern.h index 0968b9851..d3a98c638 100644 --- a/src/app/valentina/xml/vpattern.h +++ b/src/app/valentina/xml/vpattern.h @@ -82,13 +82,8 @@ public: void MoveDownPreviewCalculation(const QString &name); void SetIncrementName(const QString &name, const QString &text); - void SetPreviewCalculationName(const QString &name, const QString &text); - void SetIncrementFormula(const QString &name, const QString &text); - void SetPreviewCalculationFormula(const QString &name, const QString &text); - void SetIncrementDescription(const QString &name, const QString &text); - void SetPreviewCalculationDescription(const QString &name, const QString &text); void ReplaceNameInFormula(QVector &expressions, const QString &name, const QString &newName); @@ -242,9 +237,8 @@ private: void RemoveIncrement(const QString &type, const QString &name); void MoveUpIncrement(const QString &type, const QString &name); void MoveDownIncrement(const QString &type, const QString &name); - void SetIncrementName(const QString &type, const QString &name, const QString &text); - void SetIncrementFormula(const QString &type, const QString &name, const QString &text); - void SetIncrementDescription(const QString &type, const QString &name, const QString &text); + + void SetIncrementAttribute(const QString &name, const QString &attr, const QString &text); }; #endif // VPATTERN_H