diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.cpp b/src/app/valentina/core/vtooloptionspropertybrowser.cpp index b3ac5507c..bf031bb7d 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.cpp +++ b/src/app/valentina/core/vtooloptionspropertybrowser.cpp @@ -1544,6 +1544,12 @@ void VToolOptionsPropertyBrowser::ChangeDataToolCutSpline(VPE::VProperty *proper case 61: // AttrNotes SetNotes(property); break; + case 63: // AttrAlias1 + SetAlias1(property); + break; + case 64: // AttrAlias2 + SetAlias2(property); + break; default: qWarning()<<"Unknown property type. id = "<CurveName(), tr("Curve:"), AttrCurve); + AddPropertyAlias1(i, tr("Alias1:")); + AddPropertyAlias2(i, tr("Alias2:")); AddPropertyFormula(tr("Length:"), i->GetFormulaLength(), AttrLength); AddPropertyText(tr("Notes:"), i->GetNotes(), AttrNotes); } @@ -3321,6 +3329,9 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCutSpline() idToProperty[AttrCurve]->setValue(valueCurve); idToProperty[AttrNotes]->setValue(i->GetNotes()); + + idToProperty[AttrAlias1]->setValue(i->GetAliasSuffix1()); + idToProperty[AttrAlias2]->setValue(i->GetAliasSuffix2()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index b1a7c77f9..b09f53dd9 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -2041,6 +2041,8 @@ void VPattern::ParseToolCutSpline(VMainGraphicsScene *scene, QDomElement &domEle initData.formula = GetParametrString(domElement, AttrLength, QChar('0')); const QString f = initData.formula;//need for saving fixed formula; initData.baseCurveId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, NULL_ID_STR); + initData.aliasSuffix1 = GetParametrEmptyString(domElement, AttrAlias1); + initData.aliasSuffix2 = GetParametrEmptyString(domElement, AttrAlias2); VToolCutSpline::Create(initData); //Rewrite attribute formula. Need for situation when we have wrong formula. diff --git a/src/libs/vtools/dialogs/tools/dialogcutspline.cpp b/src/libs/vtools/dialogs/tools/dialogcutspline.cpp index 5834b2ecd..8d1d860c0 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutspline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcutspline.cpp @@ -92,6 +92,9 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, quint32 toolId, QWidget connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutSpline::DeployFormulaTextEdit); connect(ui->comboBoxSpline, &QComboBox::currentTextChanged, this, &DialogCutSpline::SplineChanged); + connect(ui->lineEditAlias1, &QLineEdit::textEdited, this, &DialogCutSpline::ValidateAlias); + connect(ui->lineEditAlias2, &QLineEdit::textEdited, this, &DialogCutSpline::ValidateAlias); + vis = new VisToolCutSpline(data); ui->tabWidget->setCurrentIndex(0); @@ -208,6 +211,55 @@ void DialogCutSpline::SplineChanged() CurrentCurveLength(getSplineId(), const_cast (data)); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutSpline::ValidateAlias() +{ + VSpline spl1; + spl1.SetAliasSuffix(GetAliasSuffix1()); + if (not GetAliasSuffix1().isEmpty() && not data->IsUnique(spl1.GetAlias())) + { + flagAlias1 = false; + ChangeColor(ui->labelAlias1, errorColor); + } + else + { + flagAlias1 = true; + ChangeColor(ui->labelAlias1, OkColor(this)); + } + + VSpline spl2; + spl2.SetAliasSuffix(GetAliasSuffix2()); + if (not GetAliasSuffix2().isEmpty() && not data->IsUnique(spl2.GetAlias())) + { + flagAlias2 = false; + ChangeColor(ui->labelAlias2, errorColor); + } + else + { + flagAlias2 = true; + ChangeColor(ui->labelAlias2, OkColor(this)); + } + + if (spl1.GetAlias() == spl2.GetAlias()) + { + flagAlias1 = false; + ChangeColor(ui->labelAlias1, errorColor); + + flagAlias2 = false; + ChangeColor(ui->labelAlias2, errorColor); + } + else + { + flagAlias1 = true; + ChangeColor(ui->labelAlias1, OkColor(this)); + + flagAlias2 = true; + ChangeColor(ui->labelAlias2, OkColor(this)); + } + + CheckState(); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogCutSpline::DeployFormulaTextEdit() { @@ -279,3 +331,29 @@ QString DialogCutSpline::GetNotes() const { return ui->plainTextEditToolNotes->toPlainText(); } + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutSpline::SetAliasSuffix1(const QString &alias) +{ + ui->lineEditAlias1->setText(alias); + ValidateAlias(); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogCutSpline::GetAliasSuffix1() const +{ + return ui->lineEditAlias1->text(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutSpline::SetAliasSuffix2(const QString &alias) +{ + ui->lineEditAlias2->setText(alias); + ValidateAlias(); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogCutSpline::GetAliasSuffix2() const +{ + return ui->lineEditAlias2->text(); +} diff --git a/src/libs/vtools/dialogs/tools/dialogcutspline.h b/src/libs/vtools/dialogs/tools/dialogcutspline.h index 004baa916..060cb9d8a 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutspline.h +++ b/src/libs/vtools/dialogs/tools/dialogcutspline.h @@ -64,6 +64,12 @@ public: void SetNotes(const QString ¬es); QString GetNotes() const; + + void SetAliasSuffix1(const QString &alias); + QString GetAliasSuffix1() const; + + void SetAliasSuffix2(const QString &alias); + QString GetAliasSuffix2() const; public slots: virtual void ChosenObject(quint32 id, const SceneObject &type) override; /** @@ -82,6 +88,7 @@ protected: virtual bool IsValid() const final; private slots: void SplineChanged(); + void ValidateAlias(); private: Q_DISABLE_COPY(DialogCutSpline) @@ -100,12 +107,14 @@ private: bool flagFormula; bool flagName; + bool flagAlias1{true}; + bool flagAlias2{true}; }; //--------------------------------------------------------------------------------------------------------------------- inline bool DialogCutSpline::IsValid() const { - return flagFormula && flagName; + return flagFormula && flagName && flagAlias1 && flagAlias2; } #endif // DIALOGCUTSPLINE_H diff --git a/src/libs/vtools/dialogs/tools/dialogcutspline.ui b/src/libs/vtools/dialogs/tools/dialogcutspline.ui index eb70a1e36..bd7071a13 100644 --- a/src/libs/vtools/dialogs/tools/dialogcutspline.ui +++ b/src/libs/vtools/dialogs/tools/dialogcutspline.ui @@ -6,8 +6,8 @@ 0 0 - 324 - 240 + 527 + 379 @@ -255,6 +255,26 @@ + + + + Alias1: + + + + + + + + + + Alias2: + + + + + + diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp index 293408b87..84435bcd8 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp @@ -85,6 +85,8 @@ void VToolCutSpline::setDialog() dialogTool->setSplineId(baseCurveId); dialogTool->SetPointName(point->name()); dialogTool->SetNotes(m_notes); + dialogTool->SetAliasSuffix1(m_aliasSuffix1); + dialogTool->SetAliasSuffix2(m_aliasSuffix2); } //--------------------------------------------------------------------------------------------------------------------- @@ -112,6 +114,8 @@ VToolCutSpline* VToolCutSpline::Create(const QPointer &dialog, VMain initData.parse = Document::FullParse; initData.typeCreation = Source::FromGui; initData.notes = dialogTool->GetNotes(); + initData.aliasSuffix1 = dialogTool->GetAliasSuffix1(); + initData.aliasSuffix2 = dialogTool->GetAliasSuffix2(); VToolCutSpline* point = Create(initData); if (point != nullptr) @@ -147,11 +151,17 @@ VToolCutSpline* VToolCutSpline::Create(VToolCutInitData &initData) auto spline1 = QSharedPointer(new VSpline(spl->GetP1(), spl1p2, spl1p3, *p)); auto spline2 = QSharedPointer(new VSpline(*p, spl2p2, spl2p3, spl->GetP4())); + spline1->SetAliasSuffix(initData.aliasSuffix1); + spline2->SetAliasSuffix(initData.aliasSuffix2); + if (initData.typeCreation == Source::FromGui) { initData.id = initData.data->AddGObject(p); initData.data->AddSpline(spline1, NULL_ID, initData.id); initData.data->AddSpline(spline2, NULL_ID, initData.id); + + initData.data->RegisterUniqueName(spline1); + initData.data->RegisterUniqueName(spline2); } else { @@ -159,6 +169,9 @@ VToolCutSpline* VToolCutSpline::Create(VToolCutInitData &initData) initData.data->AddSpline(spline1, NULL_ID, initData.id); initData.data->AddSpline(spline2, NULL_ID, initData.id); + initData.data->RegisterUniqueName(spline1); + initData.data->RegisterUniqueName(spline2); + if (initData.parse != Document::FullParse) { initData.doc->UpdateToolData(initData.id, initData.data); @@ -217,6 +230,10 @@ void VToolCutSpline::SaveDialog(QDomElement &domElement, QList &oldDepe doc->SetAttribute(domElement, AttrName, dialogTool->GetPointName()); doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula()); doc->SetAttribute(domElement, AttrSpline, QString().setNum(dialogTool->getSplineId())); + doc->SetAttributeOrRemoveIf(domElement, AttrAlias1, dialogTool->GetAliasSuffix1(), + dialogTool->GetAliasSuffix1().isEmpty()); + doc->SetAttributeOrRemoveIf(domElement, AttrAlias2, dialogTool->GetAliasSuffix2(), + dialogTool->GetAliasSuffix2().isEmpty()); const QString notes = dialogTool->GetNotes(); doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty()); @@ -286,8 +303,8 @@ QString VToolCutSpline::MakeToolTip() const .arg(qApp->fromPixel(spline1.GetLength())) .arg(UnitsToStr(qApp->patternUnits(), true), curveStr + QLatin1String("2 ") + lengthStr) .arg(qApp->fromPixel(spline2.GetLength())) - .arg(curveStr + QLatin1String(" 1") + tr("label"), spline1.name(), - curveStr + QLatin1String(" 2") + tr("label"), spline2.name()); + .arg(curveStr + QLatin1String(" 1") + tr("label"), spline1.ObjectName(), + curveStr + QLatin1String(" 2") + tr("label"), spline2.ObjectName()); return toolTip; } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h index ed7f7d6fe..953a1a18e 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h @@ -51,7 +51,7 @@ class VToolCutSpline : public VToolCut Q_OBJECT public: virtual void setDialog() override; - static VToolCutSpline *Create(const QPointer &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, + static VToolCutSpline *Create(const QPointer &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); static VToolCutSpline *Create(VToolCutInitData &initData); static const QString ToolType; @@ -71,7 +71,7 @@ protected: private: Q_DISABLE_COPY(VToolCutSpline) - VToolCutSpline(const VToolCutInitData &initData, QGraphicsItem * parent = nullptr); + explicit VToolCutSpline(const VToolCutInitData &initData, QGraphicsItem * parent = nullptr); }; #endif // VTOOLCUTSPLINE_H