If formula is empty set to default value.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-03-13 15:00:32 +02:00
parent c6d19c3b9b
commit ce1c96528e
2 changed files with 63 additions and 16 deletions

View File

@ -2461,8 +2461,13 @@ QVector<T> DialogSeamAllowance::GetPieceInternals(const QListWidget *list) const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetGrainlineAngle(const QString &angleFormula) void DialogSeamAllowance::SetGrainlineAngle(QString angleFormula)
{ {
if (angleFormula.isEmpty())
{
angleFormula = QString("0");
}
const QString formula = qApp->TrVars()->FormulaToUser(angleFormula, qApp->Settings()->GetOsSeparator()); const QString formula = qApp->TrVars()->FormulaToUser(angleFormula, qApp->Settings()->GetOsSeparator());
// increase height if needed. // increase height if needed.
if (formula.length() > 80) if (formula.length() > 80)
@ -2475,98 +2480,140 @@ void DialogSeamAllowance::SetGrainlineAngle(const QString &angleFormula)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetGrainlineLength(const QString &lengthFormula) void DialogSeamAllowance::SetGrainlineLength(QString lengthFormula)
{ {
if (lengthFormula.isEmpty())
{
lengthFormula = QString().setNum(UnitConvertor(1, Unit::Cm, *data->GetPatternUnit()));
}
const QString formula = qApp->TrVars()->FormulaToUser(lengthFormula, qApp->Settings()->GetOsSeparator()); const QString formula = qApp->TrVars()->FormulaToUser(lengthFormula, qApp->Settings()->GetOsSeparator());
// increase height if needed. // increase height if needed.
if (formula.length() > 80) if (formula.length() > 80)
{ {
this->DeployGrainlineLength(); this->DeployGrainlineLength();
} }
ui->lineEditLenFormula->setPlainText(formula); ui->lineEditLenFormula->setPlainText(formula);
MoveCursorToEnd(ui->lineEditLenFormula); MoveCursorToEnd(ui->lineEditLenFormula);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetDLWidth(const QString &widthFormula) void DialogSeamAllowance::SetDLWidth(QString widthFormula)
{ {
if (widthFormula.isEmpty())
{
widthFormula = QString().setNum(UnitConvertor(1, Unit::Cm, *data->GetPatternUnit()));
}
const QString formula = qApp->TrVars()->FormulaToUser(widthFormula, qApp->Settings()->GetOsSeparator()); const QString formula = qApp->TrVars()->FormulaToUser(widthFormula, qApp->Settings()->GetOsSeparator());
// increase height if needed. // increase height if needed.
if (formula.length() > 80) if (formula.length() > 80)
{ {
this->DeployDLWidth(); this->DeployDLWidth();
} }
ui->lineEditDLWidthFormula->setPlainText(formula); ui->lineEditDLWidthFormula->setPlainText(formula);
MoveCursorToEnd(ui->lineEditDLWidthFormula); MoveCursorToEnd(ui->lineEditDLWidthFormula);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetDLHeight(const QString &heightFormula) void DialogSeamAllowance::SetDLHeight(QString heightFormula)
{ {
if (heightFormula.isEmpty())
{
heightFormula = QString().setNum(UnitConvertor(1, Unit::Cm, *data->GetPatternUnit()));
}
const QString formula = qApp->TrVars()->FormulaToUser(heightFormula, qApp->Settings()->GetOsSeparator()); const QString formula = qApp->TrVars()->FormulaToUser(heightFormula, qApp->Settings()->GetOsSeparator());
// increase height if needed. // increase height if needed.
if (formula.length() > 80) if (formula.length() > 80)
{ {
this->DeployDLHeight(); this->DeployDLHeight();
} }
ui->lineEditDLHeightFormula->setPlainText(formula); ui->lineEditDLHeightFormula->setPlainText(formula);
MoveCursorToEnd(ui->lineEditDLHeightFormula); MoveCursorToEnd(ui->lineEditDLHeightFormula);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetDLAngle(const QString &angleFormula) void DialogSeamAllowance::SetDLAngle(QString angleFormula)
{ {
if (angleFormula.isEmpty())
{
angleFormula = QString("0");
}
const QString formula = qApp->TrVars()->FormulaToUser(angleFormula, qApp->Settings()->GetOsSeparator()); const QString formula = qApp->TrVars()->FormulaToUser(angleFormula, qApp->Settings()->GetOsSeparator());
// increase height if needed. // increase height if needed.
if (formula.length() > 80) if (formula.length() > 80)
{ {
this->DeployDLAngle(); this->DeployDLAngle();
} }
ui->lineEditDLAngleFormula->setPlainText(formula); ui->lineEditDLAngleFormula->setPlainText(formula);
MoveCursorToEnd(ui->lineEditDLAngleFormula); MoveCursorToEnd(ui->lineEditDLAngleFormula);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetPLWidth(const QString &widthFormula) void DialogSeamAllowance::SetPLWidth(QString widthFormula)
{ {
if (widthFormula.isEmpty())
{
widthFormula = QString().setNum(UnitConvertor(1, Unit::Cm, *data->GetPatternUnit()));
}
const QString formula = qApp->TrVars()->FormulaToUser(widthFormula, qApp->Settings()->GetOsSeparator()); const QString formula = qApp->TrVars()->FormulaToUser(widthFormula, qApp->Settings()->GetOsSeparator());
// increase height if needed. // increase height if needed.
if (formula.length() > 80) if (formula.length() > 80)
{ {
this->DeployPLWidth(); this->DeployPLWidth();
} }
ui->lineEditPLWidthFormula->setPlainText(formula); ui->lineEditPLWidthFormula->setPlainText(formula);
MoveCursorToEnd(ui->lineEditPLWidthFormula); MoveCursorToEnd(ui->lineEditPLWidthFormula);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetPLHeight(const QString &heightFormula) void DialogSeamAllowance::SetPLHeight(QString heightFormula)
{ {
if (heightFormula.isEmpty())
{
heightFormula = QString().setNum(UnitConvertor(1, Unit::Cm, *data->GetPatternUnit()));
}
const QString formula = qApp->TrVars()->FormulaToUser(heightFormula, qApp->Settings()->GetOsSeparator()); const QString formula = qApp->TrVars()->FormulaToUser(heightFormula, qApp->Settings()->GetOsSeparator());
// increase height if needed. // increase height if needed.
if (formula.length() > 80) if (formula.length() > 80)
{ {
this->DeployPLHeight(); this->DeployPLHeight();
} }
ui->lineEditPLHeightFormula->setPlainText(formula); ui->lineEditPLHeightFormula->setPlainText(formula);
MoveCursorToEnd(ui->lineEditPLHeightFormula); MoveCursorToEnd(ui->lineEditPLHeightFormula);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetPLAngle(const QString &angleFormula) void DialogSeamAllowance::SetPLAngle(QString angleFormula)
{ {
if (angleFormula.isEmpty())
{
angleFormula = QString("0");
}
const QString formula = qApp->TrVars()->FormulaToUser(angleFormula, qApp->Settings()->GetOsSeparator()); const QString formula = qApp->TrVars()->FormulaToUser(angleFormula, qApp->Settings()->GetOsSeparator());
// increase height if needed. // increase height if needed.
if (formula.length() > 80) if (formula.length() > 80)
{ {
this->DeployPLAngle(); this->DeployPLAngle();
} }
ui->lineEditPLAngleFormula->setPlainText(formula); ui->lineEditPLAngleFormula->setPlainText(formula);
MoveCursorToEnd(ui->lineEditPLAngleFormula); MoveCursorToEnd(ui->lineEditPLAngleFormula);

View File

@ -230,16 +230,16 @@ private:
template <typename T> template <typename T>
QVector<T> GetPieceInternals(const QListWidget *list) const; QVector<T> GetPieceInternals(const QListWidget *list) const;
void SetGrainlineAngle(const QString &angleFormula); void SetGrainlineAngle(QString angleFormula);
void SetGrainlineLength(const QString &lengthFormula); void SetGrainlineLength(QString lengthFormula);
void SetDLWidth(const QString &widthFormula); void SetDLWidth(QString widthFormula);
void SetDLHeight(const QString &heightFormula); void SetDLHeight(QString heightFormula);
void SetDLAngle(const QString &angleFormula); void SetDLAngle(QString angleFormula);
void SetPLWidth(const QString &widthFormula); void SetPLWidth(QString widthFormula);
void SetPLHeight(const QString &heightFormula); void SetPLHeight(QString heightFormula);
void SetPLAngle(const QString &angleFormula); void SetPLAngle(QString angleFormula);
}; };
#endif // DIALOGSEAMALLOWANCE_H #endif // DIALOGSEAMALLOWANCE_H