From 648d1f18977aa271f6503c3c2428027dcc0ea320 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 4 Nov 2020 15:25:23 +0200 Subject: [PATCH] Alias field for tool Spline. --- .../core/vtooloptionspropertybrowser.cpp | 6 +++++ src/app/valentina/xml/vpattern.cpp | 1 + .../vtools/dialogs/tools/dialogspline.cpp | 25 +++++++++++++++++++ src/libs/vtools/dialogs/tools/dialogspline.h | 5 +++- src/libs/vtools/dialogs/tools/dialogspline.ui | 16 +++++++++++- .../tools/drawTools/toolcurve/vtoolspline.cpp | 2 ++ 6 files changed, 53 insertions(+), 2 deletions(-) diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.cpp b/src/app/valentina/core/vtooloptionspropertybrowser.cpp index 2868d7c99..dd9ca1c0b 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.cpp +++ b/src/app/valentina/core/vtooloptionspropertybrowser.cpp @@ -2012,6 +2012,9 @@ void VToolOptionsPropertyBrowser::ChangeDataToolSpline(VPE::VProperty *property) case 61: // AttrNotes SetNotes(property); break; + case 62: // AttrAlias + SetAlias(property); + break; default: qWarning()<<"Unknown property type. id = "<setValue(valueApproximationScale); idToProperty[AttrNotes]->setValue(i->GetNotes()); + + idToProperty[AttrAlias]->setValue(i->GetAliasSuffix()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 3552b695f..1e3dd94e3 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -2557,6 +2557,7 @@ void VPattern::ParseToolSpline(VMainGraphicsScene *scene, QDomElement &domElemen initData.penStyle = GetParametrString(domElement, AttrPenStyle, TypeLineLine); initData.duplicate = GetParametrUInt(domElement, AttrDuplicate, QChar('0')); initData.approximationScale = GetParametrDouble(domElement, AttrAScale, QChar('0')); + initData.aliasSuffix = GetParametrEmptyString(domElement, AttrAlias); VToolSpline *spl = VToolSpline::Create(initData); diff --git a/src/libs/vtools/dialogs/tools/dialogspline.cpp b/src/libs/vtools/dialogs/tools/dialogspline.cpp index a9abdb46e..94cde26a4 100644 --- a/src/libs/vtools/dialogs/tools/dialogspline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogspline.cpp @@ -148,6 +148,8 @@ DialogSpline::DialogSpline(const VContainer *data, quint32 toolId, QWidget *pare connect(ui->pushButtonGrowLength1, &QPushButton::clicked, this, &DialogSpline::DeployLength1TextEdit); connect(ui->pushButtonGrowLength2, &QPushButton::clicked, this, &DialogSpline::DeployLength2TextEdit); + connect(ui->lineEditAlias, &QLineEdit::textEdited, this, &DialogSpline::ValidateAlias); + vis = new VisToolSpline(data); auto path = qobject_cast(vis); SCASSERT(path != nullptr) @@ -432,6 +434,25 @@ void DialogSpline::EvalLength2() Eval(formulaData, flagLength2); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogSpline::ValidateAlias() +{ + VSpline spline = spl; + spline.SetAliasSuffix(ui->lineEditAlias->text()); + if (not ui->lineEditAlias->text().isEmpty() && not data->IsUnique(spline.GetAlias())) + { + flagAlias = false; + ChangeColor(ui->labelAlias, errorColor); + } + else + { + flagAlias = true; + ChangeColor(ui->labelAlias, OkColor(this)); + } + + CheckState(); +} + //--------------------------------------------------------------------------------------------------------------------- VSpline DialogSpline::CurrentSpline() const { @@ -458,6 +479,7 @@ VSpline DialogSpline::CurrentSpline() const spline.SetApproximationScale(ui->doubleSpinBoxApproximationScale->value()); spline.SetPenStyle(GetComboBoxCurrentData(ui->comboBoxPenStyle, TypeLineLine)); spline.SetColor(GetComboBoxCurrentData(ui->comboBoxColor, ColorBlack)); + spline.SetAliasSuffix(ui->lineEditAlias->text()); return spline; } @@ -588,6 +610,9 @@ void DialogSpline::SetSpline(const VSpline &spline) ui->plainTextEditLength2F->setPlainText(length2F); ui->lineEditSplineName->setText(qApp->TrVars()->VarToUser(spl.name())); + ui->lineEditAlias->setText(spl.GetAliasSuffix()); + ValidateAlias(); + auto path = qobject_cast(vis); SCASSERT(path != nullptr) diff --git a/src/libs/vtools/dialogs/tools/dialogspline.h b/src/libs/vtools/dialogs/tools/dialogspline.h index 214e26d39..c268cc825 100644 --- a/src/libs/vtools/dialogs/tools/dialogspline.h +++ b/src/libs/vtools/dialogs/tools/dialogspline.h @@ -88,6 +88,8 @@ private slots: void EvalAngle2(); void EvalLength1(); void EvalLength2(); + + void ValidateAlias(); private: Q_DISABLE_COPY(DialogSpline) @@ -117,6 +119,7 @@ private: bool flagLength1; bool flagLength2; bool flagError; + bool flagAlias{true}; const QSharedPointer GetP1() const; const QSharedPointer GetP4() const; @@ -127,7 +130,7 @@ private: //--------------------------------------------------------------------------------------------------------------------- inline bool DialogSpline::IsValid() const { - return flagAngle1 && flagAngle2 && flagLength1 && flagLength2 && flagError; + return flagAngle1 && flagAngle2 && flagLength1 && flagLength2 && flagError && flagAlias; } #endif // DIALOGSPLINE_H diff --git a/src/libs/vtools/dialogs/tools/dialogspline.ui b/src/libs/vtools/dialogs/tools/dialogspline.ui index 9a16011a9..9afc1f1cf 100644 --- a/src/libs/vtools/dialogs/tools/dialogspline.ui +++ b/src/libs/vtools/dialogs/tools/dialogspline.ui @@ -7,7 +7,7 @@ 0 0 532 - 452 + 482 @@ -925,6 +925,20 @@ + + + + Alias: + + + + + + + true + + + diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp index 60d6abf7b..2e0e6d6f0 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp @@ -227,6 +227,7 @@ VToolSpline *VToolSpline::Create(VToolSplineInitData &initData) spline->SetColor(initData.color); spline->SetPenStyle(initData.penStyle); spline->SetApproximationScale(initData.approximationScale); + spline->SetAliasSuffix(initData.aliasSuffix); return VToolSpline::Create(initData, spline); } @@ -651,6 +652,7 @@ void VToolSpline::SetSplineAttributes(QDomElement &domElement, const VSpline &sp doc->SetAttribute(domElement, AttrPenStyle, spl.GetPenStyle()); doc->SetAttribute(domElement, AttrAScale, spl.GetApproximationScale()); doc->SetAttributeOrRemoveIf(domElement, AttrDuplicate, spl.GetDuplicate(), spl.GetDuplicate() <= 0); + doc->SetAttributeOrRemoveIf(domElement, AttrAlias, spl.GetAliasSuffix(), spl.GetAliasSuffix().isEmpty()); if (domElement.hasAttribute(AttrKCurve)) {