diff --git a/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp b/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp index f12456029..0ea2cec92 100644 --- a/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp @@ -202,27 +202,7 @@ void DialogEditWrongFormula::ValChanged(int row) { if (ui->radioButtonStandardTable->isChecked()) { - const QSharedPointer stable = m_data->GetVariable(name); - - QString description; - - if (!stable->IsCustom()) - { - if (VKnownMeasurementsDatabase *db = VAbstractApplication::VApp()->KnownMeasurementsDatabase()) - { - VKnownMeasurements known = db->KnownMeasurements(stable->GetKnownMeasurementsId()); - if (known.IsValid()) - { - description = known.Measurement(stable->GetName()).description; - } - } - } - else - { - description = stable->GetDescription(); - } - - SetDescription(item->text(), *stable->GetValue(), stable->IsSpecialUnits(), description); + SetMeasurementDescription(item, name); } else if (ui->radioButtonIncrements->isChecked() || ui->radioButtonPC->isChecked()) { @@ -267,25 +247,7 @@ void DialogEditWrongFormula::ValChanged(int row) } else if (ui->radioButtonPieceArea->isChecked()) { - const bool specialUnits = false; - const QSharedPointer var = m_data->GetVariable(name); - QString description = tr("Area of piece"); - - try - { - VPiece piece = m_data->GetPiece(var->GetPieceId()); - QString name = piece.GetName(); - if (not name.isEmpty()) - { - description += QStringLiteral(" '%1'").arg(piece.GetName()); - } - } - catch (const VExceptionBadId &) - { - // do nothing - } - - SetDescription(item->text(), *var->GetValue(), specialUnits, description, true); + SetPieceAreaDescription(item, name); } else if (ui->radioButtonFunctions->isChecked()) { @@ -829,6 +791,56 @@ void DialogEditWrongFormula::ShowIncrementsInPreviewCalculation(bool show) ShowVariable(vars); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditWrongFormula::SetMeasurementDescription(QTableWidgetItem *item, const QString &name) +{ + const QSharedPointer stable = m_data->GetVariable(name); + + QString description; + + if (!stable->IsCustom()) + { + if (VKnownMeasurementsDatabase *db = VAbstractApplication::VApp()->KnownMeasurementsDatabase()) + { + VKnownMeasurements known = db->KnownMeasurements(stable->GetKnownMeasurementsId()); + if (known.IsValid()) + { + description = known.Measurement(stable->GetName()).description; + } + } + } + else + { + description = stable->GetDescription(); + } + + SetDescription(item->text(), *stable->GetValue(), stable->IsSpecialUnits(), description); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditWrongFormula::SetPieceAreaDescription(QTableWidgetItem *item, const QString &name) +{ + const bool specialUnits = false; + const QSharedPointer var = m_data->GetVariable(name); + QString description = tr("Area of piece"); + + try + { + VPiece piece = m_data->GetPiece(var->GetPieceId()); + QString name = piece.GetName(); + if (not name.isEmpty()) + { + description += QStringLiteral(" '%1'").arg(piece.GetName()); + } + } + catch (const VExceptionBadId &) + { + // do nothing + } + + SetDescription(item->text(), *var->GetValue(), specialUnits, description, true); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogEditWrongFormula::FilterVariablesEdited(const QString &filter) { diff --git a/src/libs/vtools/dialogs/support/dialogeditwrongformula.h b/src/libs/vtools/dialogs/support/dialogeditwrongformula.h index 882720ba1..20d022c73 100644 --- a/src/libs/vtools/dialogs/support/dialogeditwrongformula.h +++ b/src/libs/vtools/dialogs/support/dialogeditwrongformula.h @@ -153,6 +153,9 @@ private: void ShowFunctions(); void ShowIncrementsInPreviewCalculation(bool show); + void SetMeasurementDescription(QTableWidgetItem *item, const QString &name); + void SetPieceAreaDescription(QTableWidgetItem *item, const QString &name); + void SetDescription(const QString &name, qreal value, bool specialUnits, const QString &description, bool square = false);