Fixed issue #938. Dialog Seam Allowance doesn't block user from saving broken
formula. (grafted from 829e2d26bb6e63c8bdbf541caac22a1e7f76602b) --HG-- branch : develop
This commit is contained in:
parent
666818e23c
commit
3b3d1e1b4f
|
@ -23,6 +23,7 @@
|
|||
- [#924] Valentina produces wrong passmark for rollback case.
|
||||
- [#930] Valentina doesn't update translation for variables after dynamic language switch.
|
||||
- [#931] Variable translation for Greek and Chinese are broken.
|
||||
- [#938] Dialog Seam Allowance doesn't block user from saving broken formula.
|
||||
|
||||
# Version 0.6.1 October 23, 2018
|
||||
- [#885] Regression. Broken support for multi size measurements.
|
||||
|
|
|
@ -1030,13 +1030,29 @@ VPieceLabelData VPattern::ParsePieceDataTag(const QDomElement &domElement, VPiec
|
|||
ppData.SetOnFold(GetParametrBool(domElement, AttrOnFold, falseStr));
|
||||
ppData.SetPos(QPointF(GetParametrDouble(domElement, AttrMx, QChar('0')),
|
||||
GetParametrDouble(domElement, AttrMy, QChar('0'))));
|
||||
ppData.SetLabelWidth(GetParametrString(domElement, AttrWidth, QChar('1')));
|
||||
ppData.SetLabelHeight(GetParametrString(domElement, AttrHeight, QChar('1')));
|
||||
ppData.SetFontSize(static_cast<int>(GetParametrUInt(domElement, VToolSeamAllowance::AttrFont, QChar('0'))));
|
||||
ppData.SetRotation(GetParametrString(domElement, AttrRotation, QChar('0')));
|
||||
ppData.SetCenterPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrCenterPin, NULL_ID_STR));
|
||||
ppData.SetTopLeftPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrTopLeftPin, NULL_ID_STR));
|
||||
ppData.SetBottomRightPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomRightPin, NULL_ID_STR));
|
||||
|
||||
const quint32 topLeftPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrTopLeftPin, NULL_ID_STR);
|
||||
const quint32 bottomRightPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomRightPin, NULL_ID_STR);
|
||||
|
||||
if (topLeftPin != NULL_ID && bottomRightPin != NULL_ID && topLeftPin != bottomRightPin)
|
||||
{
|
||||
ppData.SetTopLeftPin(topLeftPin);
|
||||
ppData.SetBottomRightPin(bottomRightPin);
|
||||
ppData.SetCenterPin(NULL_ID);
|
||||
ppData.SetLabelWidth(QChar('1'));
|
||||
ppData.SetLabelHeight(QChar('1'));
|
||||
}
|
||||
else
|
||||
{
|
||||
ppData.SetTopLeftPin(NULL_ID);
|
||||
ppData.SetBottomRightPin(NULL_ID);
|
||||
ppData.SetCenterPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrCenterPin, NULL_ID_STR));
|
||||
ppData.SetLabelWidth(GetParametrString(domElement, AttrWidth, QChar('1')));
|
||||
ppData.SetLabelHeight(GetParametrString(domElement, AttrHeight, QChar('1')));
|
||||
}
|
||||
|
||||
ppData.SetLabelTemplate(GetLabelTemplate(domElement));
|
||||
return ppData;
|
||||
}
|
||||
|
@ -1047,13 +1063,29 @@ VPatternLabelData VPattern::ParsePiecePatternInfo(const QDomElement &domElement,
|
|||
patternInfo.SetVisible(GetParametrBool(domElement, AttrVisible, trueStr));
|
||||
patternInfo.SetPos(QPointF(GetParametrDouble(domElement, AttrMx, QChar('0')),
|
||||
GetParametrDouble(domElement, AttrMy, QChar('0'))));
|
||||
patternInfo.SetLabelWidth(GetParametrString(domElement, AttrWidth, QChar('1')));
|
||||
patternInfo.SetLabelHeight(GetParametrString(domElement, AttrHeight, QChar('1')));
|
||||
patternInfo.SetFontSize(static_cast<int>(GetParametrUInt(domElement, VToolSeamAllowance::AttrFont, QChar('0'))));
|
||||
patternInfo.SetRotation(GetParametrString(domElement, AttrRotation, QChar('0')));
|
||||
patternInfo.SetCenterPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrCenterPin, NULL_ID_STR));
|
||||
patternInfo.SetTopLeftPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrTopLeftPin, NULL_ID_STR));
|
||||
patternInfo.SetBottomRightPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomRightPin, NULL_ID_STR));
|
||||
|
||||
const quint32 topLeftPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrTopLeftPin, NULL_ID_STR);
|
||||
const quint32 bottomRightPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomRightPin, NULL_ID_STR);
|
||||
|
||||
if (topLeftPin != NULL_ID && bottomRightPin != NULL_ID && topLeftPin != bottomRightPin)
|
||||
{
|
||||
patternInfo.SetTopLeftPin(topLeftPin);
|
||||
patternInfo.SetBottomRightPin(bottomRightPin);
|
||||
patternInfo.SetCenterPin(NULL_ID);
|
||||
patternInfo.SetLabelWidth(QChar('1'));
|
||||
patternInfo.SetLabelHeight(QChar('1'));
|
||||
}
|
||||
else
|
||||
{
|
||||
patternInfo.SetTopLeftPin(NULL_ID);
|
||||
patternInfo.SetBottomRightPin(NULL_ID);
|
||||
patternInfo.SetCenterPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrCenterPin, NULL_ID_STR));
|
||||
patternInfo.SetLabelWidth(GetParametrString(domElement, AttrWidth, QChar('1')));
|
||||
patternInfo.SetLabelHeight(GetParametrString(domElement, AttrHeight, QChar('1')));
|
||||
}
|
||||
|
||||
return patternInfo;
|
||||
}
|
||||
|
||||
|
@ -1063,12 +1095,30 @@ VGrainlineData VPattern::ParsePieceGrainline(const QDomElement &domElement, VGra
|
|||
gGeometry.SetVisible(GetParametrBool(domElement, AttrVisible, falseStr));
|
||||
gGeometry.SetPos(QPointF(GetParametrDouble(domElement, AttrMx, QChar('0')),
|
||||
GetParametrDouble(domElement, AttrMy, QChar('0'))));
|
||||
gGeometry.SetLength(GetParametrString(domElement, AttrLength, QChar('1')));
|
||||
gGeometry.SetRotation(GetParametrString(domElement, AttrRotation, QStringLiteral("90")));
|
||||
gGeometry.SetArrowType(static_cast<ArrowType>(GetParametrUInt(domElement, AttrArrows, QChar('0'))));
|
||||
gGeometry.SetCenterPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrCenterPin, NULL_ID_STR));
|
||||
gGeometry.SetTopPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrTopPin, NULL_ID_STR));
|
||||
gGeometry.SetBottomPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomPin, NULL_ID_STR));
|
||||
|
||||
const quint32 topPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrTopPin, NULL_ID_STR);
|
||||
const quint32 bottomPin = GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomPin, NULL_ID_STR);
|
||||
|
||||
if (topPin != NULL_ID && bottomPin != NULL_ID && topPin != bottomPin)
|
||||
{
|
||||
gGeometry.SetTopPin(topPin);
|
||||
gGeometry.SetBottomPin(bottomPin);
|
||||
|
||||
gGeometry.SetLength(QChar('1'));
|
||||
gGeometry.SetRotation(QString::number(90));
|
||||
gGeometry.SetCenterPin(NULL_ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
gGeometry.SetTopPin(NULL_ID);
|
||||
gGeometry.SetBottomPin(NULL_ID);
|
||||
|
||||
gGeometry.SetLength(GetParametrString(domElement, AttrLength, QChar('1')));
|
||||
gGeometry.SetRotation(GetParametrString(domElement, AttrRotation, QString::number(90)));
|
||||
gGeometry.SetCenterPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrCenterPin, NULL_ID_STR));
|
||||
}
|
||||
|
||||
return gGeometry;
|
||||
}
|
||||
|
||||
|
|
|
@ -234,8 +234,17 @@ void ReadExpressionAttribute(QVector<VFormulaField> &expressions, const QDomElem
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QList<QString> GetTokens(const VFormulaField &formula)
|
||||
{
|
||||
QScopedPointer<qmu::QmuTokenParser> cal(new qmu::QmuTokenParser(formula.expression, false, false));
|
||||
return cal->GetTokens().values();
|
||||
try
|
||||
{
|
||||
QScopedPointer<qmu::QmuTokenParser> cal(new qmu::QmuTokenParser(formula.expression, false, false));
|
||||
return cal->GetTokens().values();
|
||||
}
|
||||
catch (const qmu::QmuParserError &e)
|
||||
{
|
||||
qWarning() << QObject::tr("Cannot get tokens from formula '%1'. Parser error: %2.")
|
||||
.arg(formula.expression, e.GetMsg());
|
||||
return QList<QString>();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -1782,7 +1782,6 @@ void DialogSeamAllowance::EnabledGrainline()
|
|||
{
|
||||
if (uiTabGrainline->groupBoxGrainline->isChecked() == true)
|
||||
{
|
||||
UpdateGrainlineValues();
|
||||
GrainlinePinPointChanged();
|
||||
}
|
||||
else
|
||||
|
@ -2256,6 +2255,7 @@ void DialogSeamAllowance::GrainlinePinPointChanged()
|
|||
m_ftb->SetTabText(TabOrder::Grainline, tr("Grainline"));
|
||||
}
|
||||
}
|
||||
EnableGrainlineFormulaControls(not flagGPin);
|
||||
UpdateGrainlineValues();
|
||||
ChangeColor(uiTabGrainline->labelGrainlineTopPin, color);
|
||||
ChangeColor(uiTabGrainline->labelGrainlineBottomPin, color);
|
||||
|
@ -2289,6 +2289,7 @@ void DialogSeamAllowance::DetailPinPointChanged()
|
|||
QIcon(":/icons/win.icon.theme/16x16/status/dialog-warning.png"));
|
||||
uiTabLabels->tabWidget->setTabIcon(uiTabLabels->tabWidget->indexOf(uiTabLabels->tabLabels), icon);
|
||||
}
|
||||
EnableDetailLabelFormulaControls(not flagDPin);
|
||||
UpdateDetailLabelValues();
|
||||
ChangeColor(uiTabLabels->labelDLTopLeftPin, color);
|
||||
ChangeColor(uiTabLabels->labelDLBottomRightPin, color);
|
||||
|
@ -2322,6 +2323,7 @@ void DialogSeamAllowance::PatternPinPointChanged()
|
|||
QIcon(":/icons/win.icon.theme/16x16/status/dialog-warning.png"));
|
||||
uiTabLabels->tabWidget->setTabIcon(uiTabLabels->tabWidget->indexOf(uiTabLabels->tabLabels), icon);
|
||||
}
|
||||
EnablePatternLabelFormulaControls(not flagPPin);
|
||||
UpdatePatternLabelValues();
|
||||
ChangeColor(uiTabLabels->labelPLTopLeftPin, color);
|
||||
ChangeColor(uiTabLabels->labelPLBottomRightPin, color);
|
||||
|
@ -2367,29 +2369,65 @@ VPiece DialogSeamAllowance::CreatePiece() const
|
|||
piece.GetPatternPieceData().SetQuantity(uiTabLabels->spinBoxQuantity->value());
|
||||
piece.GetPatternPieceData().SetOnFold(uiTabLabels->checkBoxFold->isChecked());
|
||||
piece.GetPatternPieceData().SetLabelTemplate(m_templateLines);
|
||||
piece.GetPatternPieceData().SetLabelWidth(GetFormulaFromUser(uiTabLabels->lineEditDLWidthFormula));
|
||||
piece.GetPatternPieceData().SetLabelHeight(GetFormulaFromUser(uiTabLabels->lineEditDLHeightFormula));
|
||||
piece.GetPatternPieceData().SetRotation(GetFormulaFromUser(uiTabLabels->lineEditDLAngleFormula));
|
||||
piece.GetPatternPieceData().SetVisible(uiTabLabels->groupBoxDetailLabel->isChecked());
|
||||
piece.GetPatternPieceData().SetCenterPin(getCurrentObjectId(uiTabLabels->comboBoxDLCenterPin));
|
||||
piece.GetPatternPieceData().SetTopLeftPin(getCurrentObjectId(uiTabLabels->comboBoxDLTopLeftPin));
|
||||
piece.GetPatternPieceData().SetBottomRightPin(getCurrentObjectId(uiTabLabels->comboBoxDLBottomRightPin));
|
||||
|
||||
if (not flagDPin)
|
||||
{
|
||||
piece.GetPatternPieceData().SetLabelWidth(GetFormulaFromUser(uiTabLabels->lineEditDLWidthFormula));
|
||||
piece.GetPatternPieceData().SetLabelHeight(GetFormulaFromUser(uiTabLabels->lineEditDLHeightFormula));
|
||||
piece.GetPatternPieceData().SetCenterPin(getCurrentObjectId(uiTabLabels->comboBoxDLCenterPin));
|
||||
piece.GetPatternPieceData().SetTopLeftPin(NULL_ID);
|
||||
piece.GetPatternPieceData().SetBottomRightPin(NULL_ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
piece.GetPatternPieceData().SetLabelWidth(QString::number(1));
|
||||
piece.GetPatternPieceData().SetLabelHeight(QString::number(1));
|
||||
piece.GetPatternPieceData().SetCenterPin(NULL_ID);
|
||||
piece.GetPatternPieceData().SetTopLeftPin(getCurrentObjectId(uiTabLabels->comboBoxDLTopLeftPin));
|
||||
piece.GetPatternPieceData().SetBottomRightPin(getCurrentObjectId(uiTabLabels->comboBoxDLBottomRightPin));
|
||||
}
|
||||
|
||||
piece.GetPatternInfo().SetVisible(uiTabLabels->groupBoxPatternLabel->isChecked());
|
||||
piece.GetPatternInfo().SetCenterPin(getCurrentObjectId(uiTabLabels->comboBoxPLCenterPin));
|
||||
piece.GetPatternInfo().SetTopLeftPin(getCurrentObjectId(uiTabLabels->comboBoxPLTopLeftPin));
|
||||
piece.GetPatternInfo().SetBottomRightPin(getCurrentObjectId(uiTabLabels->comboBoxPLBottomRightPin));
|
||||
piece.GetPatternInfo().SetLabelWidth(GetFormulaFromUser(uiTabLabels->lineEditPLWidthFormula));
|
||||
piece.GetPatternInfo().SetLabelHeight(GetFormulaFromUser(uiTabLabels->lineEditPLHeightFormula));
|
||||
piece.GetPatternInfo().SetRotation(GetFormulaFromUser(uiTabLabels->lineEditPLAngleFormula));
|
||||
|
||||
if (not flagPPin)
|
||||
{
|
||||
piece.GetPatternInfo().SetCenterPin(getCurrentObjectId(uiTabLabels->comboBoxPLCenterPin));
|
||||
piece.GetPatternInfo().SetTopLeftPin(NULL_ID);
|
||||
piece.GetPatternInfo().SetBottomRightPin(NULL_ID);
|
||||
piece.GetPatternInfo().SetLabelWidth(GetFormulaFromUser(uiTabLabels->lineEditPLWidthFormula));
|
||||
piece.GetPatternInfo().SetLabelHeight(GetFormulaFromUser(uiTabLabels->lineEditPLHeightFormula));
|
||||
}
|
||||
else
|
||||
{
|
||||
piece.GetPatternInfo().SetCenterPin(NULL_ID);
|
||||
piece.GetPatternInfo().SetTopLeftPin(getCurrentObjectId(uiTabLabels->comboBoxPLTopLeftPin));
|
||||
piece.GetPatternInfo().SetBottomRightPin(getCurrentObjectId(uiTabLabels->comboBoxPLBottomRightPin));
|
||||
piece.GetPatternInfo().SetLabelWidth(QString::number(1));
|
||||
piece.GetPatternInfo().SetLabelHeight(QString::number(1));
|
||||
}
|
||||
|
||||
piece.GetGrainlineGeometry().SetVisible(uiTabGrainline->groupBoxGrainline->isChecked());
|
||||
piece.GetGrainlineGeometry().SetRotation(GetFormulaFromUser(uiTabGrainline->lineEditRotFormula));
|
||||
piece.GetGrainlineGeometry().SetLength(GetFormulaFromUser(uiTabGrainline->lineEditLenFormula));
|
||||
piece.GetGrainlineGeometry().SetArrowType(static_cast<ArrowType>(uiTabGrainline->comboBoxArrow->currentIndex()));
|
||||
piece.GetGrainlineGeometry().SetCenterPin(getCurrentObjectId(uiTabGrainline->comboBoxGrainlineCenterPin));
|
||||
piece.GetGrainlineGeometry().SetTopPin(getCurrentObjectId(uiTabGrainline->comboBoxGrainlineTopPin));
|
||||
piece.GetGrainlineGeometry().SetBottomPin(getCurrentObjectId(uiTabGrainline->comboBoxGrainlineBottomPin));
|
||||
|
||||
if (not flagGPin)
|
||||
{
|
||||
piece.GetGrainlineGeometry().SetRotation(GetFormulaFromUser(uiTabGrainline->lineEditRotFormula));
|
||||
piece.GetGrainlineGeometry().SetLength(GetFormulaFromUser(uiTabGrainline->lineEditLenFormula));
|
||||
piece.GetGrainlineGeometry().SetCenterPin(getCurrentObjectId(uiTabGrainline->comboBoxGrainlineCenterPin));
|
||||
piece.GetGrainlineGeometry().SetTopPin(NULL_ID);
|
||||
piece.GetGrainlineGeometry().SetBottomPin(NULL_ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
piece.GetGrainlineGeometry().SetRotation(QString::number(90));
|
||||
piece.GetGrainlineGeometry().SetLength(QChar('1'));
|
||||
piece.GetGrainlineGeometry().SetCenterPin(NULL_ID);
|
||||
piece.GetGrainlineGeometry().SetTopPin(getCurrentObjectId(uiTabGrainline->comboBoxGrainlineTopPin));
|
||||
piece.GetGrainlineGeometry().SetBottomPin(getCurrentObjectId(uiTabGrainline->comboBoxGrainlineBottomPin));
|
||||
}
|
||||
|
||||
return piece;
|
||||
}
|
||||
|
@ -3344,6 +3382,48 @@ QString DialogSeamAllowance::GetDefaultPieceName() const
|
|||
return name;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSeamAllowance::EnableGrainlineFormulaControls(bool enable)
|
||||
{
|
||||
uiTabGrainline->pushButtonRot->setEnabled(enable);
|
||||
uiTabGrainline->lineEditRotFormula->setEnabled(enable);
|
||||
uiTabGrainline->pushButtonShowRot->setEnabled(enable);
|
||||
|
||||
uiTabGrainline->pushButtonLen->setEnabled(enable);
|
||||
uiTabGrainline->lineEditLenFormula->setEnabled(enable);
|
||||
uiTabGrainline->pushButtonShowLen->setEnabled(enable);
|
||||
|
||||
uiTabGrainline->comboBoxGrainlineCenterPin->setEnabled(enable);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSeamAllowance::EnableDetailLabelFormulaControls(bool enable)
|
||||
{
|
||||
uiTabLabels->pushButtonDLWidth->setEnabled(enable);
|
||||
uiTabLabels->lineEditDLWidthFormula->setEnabled(enable);
|
||||
uiTabLabels->pushButtonShowDLWidth->setEnabled(enable);
|
||||
|
||||
uiTabLabels->pushButtonDLHeight->setEnabled(enable);
|
||||
uiTabLabels->lineEditDLHeightFormula->setEnabled(enable);
|
||||
uiTabLabels->pushButtonShowDLHeight->setEnabled(enable);
|
||||
|
||||
uiTabLabels->comboBoxDLCenterPin->setEnabled(enable);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSeamAllowance::EnablePatternLabelFormulaControls(bool enable)
|
||||
{
|
||||
uiTabLabels->pushButtonPLWidth->setEnabled(enable);
|
||||
uiTabLabels->lineEditPLWidthFormula->setEnabled(enable);
|
||||
uiTabLabels->pushButtonShowPLWidth->setEnabled(enable);
|
||||
|
||||
uiTabLabels->pushButtonPLHeight->setEnabled(enable);
|
||||
uiTabLabels->lineEditPLHeightFormula->setEnabled(enable);
|
||||
uiTabLabels->pushButtonShowPLHeight->setEnabled(enable);
|
||||
|
||||
uiTabLabels->comboBoxPLCenterPin->setEnabled(enable);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSeamAllowance::SetMoveControls()
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/************************************************************************
|
||||
/************************************************************************
|
||||
**
|
||||
** @file dialogseamallowance.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
|
@ -276,6 +276,10 @@ private:
|
|||
VPlaceLabelItem CurrentPlaceLabel(quint32 id) const;
|
||||
|
||||
QString GetDefaultPieceName() const;
|
||||
|
||||
void EnableGrainlineFormulaControls(bool enable);
|
||||
void EnableDetailLabelFormulaControls(bool enable);
|
||||
void EnablePatternLabelFormulaControls(bool enable);
|
||||
};
|
||||
|
||||
#endif // DIALOGSEAMALLOWANCE_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user