From 30a27ee85ae83985551f65ef98e41276709e23a8 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 22 Apr 2020 14:32:25 +0300 Subject: [PATCH] UUID field for piece. --- src/app/valentina/xml/vpattern.cpp | 1 + src/libs/ifc/ifcdef.cpp | 1 + src/libs/ifc/ifcdef.h | 1 + src/libs/ifc/schema.qrc | 1 + src/libs/ifc/schema/pattern/v0.8.8.xsd | 1260 +++++++++++++++++ src/libs/ifc/xml/vpatternconverter.cpp | 45 +- src/libs/ifc/xml/vpatternconverter.h | 5 +- src/libs/vlayout/vabstractpiece.cpp | 21 +- src/libs/vlayout/vabstractpiece.h | 4 + src/libs/vlayout/vabstractpiece_p.h | 13 +- src/libs/vlayout/vlayoutpiece.cpp | 2 + .../tools/piece/dialogseamallowance.cpp | 92 +- .../dialogs/tools/piece/dialogseamallowance.h | 5 +- .../dialogs/tools/piece/tabs/tabpaths.ui | 161 ++- src/libs/vtools/tools/vtoolseamallowance.cpp | 2 + 15 files changed, 1524 insertions(+), 90 deletions(-) create mode 100644 src/libs/ifc/schema/pattern/v0.8.8.xsd diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 763ae9415..f3a6824cb 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -829,6 +829,7 @@ void VPattern::ParseDetailElement(QDomElement &domElement, const Document &parse VToolSeamAllowanceInitData initData; initData.id = GetParametrId(domElement); initData.detail.SetName(GetParametrString(domElement, AttrName, tr("Detail"))); + initData.detail.SetUUID(GetParametrEmptyString(domElement, AttrUUID)); initData.detail.SetMx(qApp->toPixel(GetParametrDouble(domElement, AttrMx, QStringLiteral("0.0")))); initData.detail.SetMy(qApp->toPixel(GetParametrDouble(domElement, AttrMy, QStringLiteral("0.0")))); initData.detail.SetSeamAllowance(GetParametrBool(domElement, VToolSeamAllowance::AttrSeamAllowance, falseStr)); diff --git a/src/libs/ifc/ifcdef.cpp b/src/libs/ifc/ifcdef.cpp index e592264c6..2bd0d6095 100644 --- a/src/libs/ifc/ifcdef.cpp +++ b/src/libs/ifc/ifcdef.cpp @@ -47,6 +47,7 @@ const QString AttrType = QStringLiteral("type"); const QString AttrMx = QStringLiteral("mx"); const QString AttrMy = QStringLiteral("my"); const QString AttrName = QStringLiteral("name"); +const QString AttrUUID = QStringLiteral("uuid"); const QString AttrMx1 = QStringLiteral("mx1"); const QString AttrMy1 = QStringLiteral("my1"); const QString AttrName1 = QStringLiteral("name1"); diff --git a/src/libs/ifc/ifcdef.h b/src/libs/ifc/ifcdef.h index ae91d264e..788dc86fd 100644 --- a/src/libs/ifc/ifcdef.h +++ b/src/libs/ifc/ifcdef.h @@ -65,6 +65,7 @@ extern const QString AttrType; extern const QString AttrMx; extern const QString AttrMy; extern const QString AttrName; +extern const QString AttrUUID; extern const QString AttrMx1; extern const QString AttrMy1; extern const QString AttrName1; diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index 5d41d6883..79d978c82 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -59,6 +59,7 @@ schema/pattern/v0.8.5.xsd schema/pattern/v0.8.6.xsd schema/pattern/v0.8.7.xsd + schema/pattern/v0.8.8.xsd schema/standard_measurements/v0.3.0.xsd schema/standard_measurements/v0.4.0.xsd schema/standard_measurements/v0.4.1.xsd diff --git a/src/libs/ifc/schema/pattern/v0.8.8.xsd b/src/libs/ifc/schema/pattern/v0.8.8.xsd new file mode 100644 index 000000000..514cd8f0d --- /dev/null +++ b/src/libs/ifc/schema/pattern/v0.8.8.xsd @@ -0,0 +1,1260 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index a38a9dbfc..40790aa98 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include "../exception/vexception.h" #include "../exception/vexceptionemptyparameter.h" @@ -59,8 +60,8 @@ class QDomElement; */ const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.4"); -const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.7"); -const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.7.xsd"); +const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.8"); +const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.8.xsd"); //VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! @@ -135,6 +136,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, strMy, (QLatin1String("my"))) //Q_GLOBAL_STATIC_WITH_ARGS(const QString, strForbidFlipping, (QLatin1String("forbidFlipping"))) //Q_GLOBAL_STATIC_WITH_ARGS(const QString, strInLayout, (QLatin1String("inLayout"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, strSeamAllowance, (QLatin1String("seamAllowance"))) +Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUUID, (QLatin1String("uuid"))) //Q_GLOBAL_STATIC_WITH_ARGS(const QString, strNodeType, (QLatin1String("nodeType"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, strDet, (QLatin1String("det"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTypeObject, (QLatin1String("typeObject"))) @@ -237,7 +239,8 @@ QString VPatternConverter::XSDSchema(int ver) const std::make_pair(FORMAT_VERSION(0, 8, 4), QStringLiteral("://schema/pattern/v0.8.4.xsd")), std::make_pair(FORMAT_VERSION(0, 8, 5), QStringLiteral("://schema/pattern/v0.8.5.xsd")), std::make_pair(FORMAT_VERSION(0, 8, 6), QStringLiteral("://schema/pattern/v0.8.6.xsd")), - std::make_pair(FORMAT_VERSION(0, 8, 7), CurrentSchema) + std::make_pair(FORMAT_VERSION(0, 8, 7), QStringLiteral("://schema/pattern/v0.8.7.xsd")), + std::make_pair(FORMAT_VERSION(0, 8, 8), CurrentSchema) }; if (schemas.contains(ver)) @@ -486,6 +489,10 @@ void VPatternConverter::ApplyPatches() ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 7))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 8, 7)): + ToV0_8_8(); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 8))); + Q_FALLTHROUGH(); + case (FORMAT_VERSION(0, 8, 8)): break; default: InvalidVersion(m_ver); @@ -503,7 +510,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion() bool VPatternConverter::IsReadOnly() const { // Check if attribute readOnly was not changed in file format - Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FORMAT_VERSION(0, 8, 7), + Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FORMAT_VERSION(0, 8, 8), "Check attribute readOnly."); // Possibly in future attribute readOnly will change position etc. @@ -1143,6 +1150,17 @@ void VPatternConverter::ToV0_8_7() Save(); } +//--------------------------------------------------------------------------------------------------------------------- +void VPatternConverter::ToV0_8_8() +{ + // TODO. Delete if minimal supported version is 0.8.8 + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FORMAT_VERSION(0, 8, 8), + "Time to refactor the code."); + SetVersion(QStringLiteral("0.8.8")); + AddPieceUUIDV0_8_8(); + Save(); +} + //--------------------------------------------------------------------------------------------------------------------- void VPatternConverter::TagUnitToV0_2_0() { @@ -2662,6 +2680,25 @@ void VPatternConverter::AddTagPreviewCalculationsV0_6_2() } } +//--------------------------------------------------------------------------------------------------------------------- +void VPatternConverter::AddPieceUUIDV0_8_8() +{ + // TODO. Delete if minimal supported version is 0.8.8 + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FORMAT_VERSION(0, 8, 8), + "Time to refactor the code."); + + const QDomNodeList list = elementsByTagName(*strDetail); + for (int i=0; i < list.size(); ++i) + { + QDomElement dom = list.at(i).toElement(); + + if (not dom.isNull()) + { + dom.setAttribute(*strUUID, QUuid::createUuid().toString()); + } + } +} + //--------------------------------------------------------------------------------------------------------------------- void VPatternConverter::TagUnionDetailsToV0_4_0() { diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h index 1adaabee3..6c0367932 100644 --- a/src/libs/ifc/xml/vpatternconverter.h +++ b/src/libs/ifc/xml/vpatternconverter.h @@ -53,7 +53,7 @@ public: static const QString PatternMaxVerStr; static const QString CurrentSchema; static Q_DECL_CONSTEXPR const int PatternMinVer = FORMAT_VERSION(0, 1, 4); - static Q_DECL_CONSTEXPR const int PatternMaxVer = FORMAT_VERSION(0, 8, 7); + static Q_DECL_CONSTEXPR const int PatternMaxVer = FORMAT_VERSION(0, 8, 8); protected: virtual int MinVer() const override; @@ -130,6 +130,7 @@ private: void ToV0_8_5(); void ToV0_8_6(); void ToV0_8_7(); + void ToV0_8_8(); void TagUnitToV0_2_0(); void TagIncrementToV0_2_0(); @@ -182,6 +183,8 @@ private: void RemoveUniqueTagV0_6_0(const QString &tag); void AddTagPreviewCalculationsV0_6_2(); + + void AddPieceUUIDV0_8_8(); }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index ff7eef16b..8869ad633 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -49,7 +49,7 @@ #include const quint32 VAbstractPieceData::streamHeader = 0x05CDD73A; // CRC-32Q string "VAbstractPieceData" -const quint16 VAbstractPieceData::classVersion = 2; +const quint16 VAbstractPieceData::classVersion = 3; const qreal maxL = 3.5; @@ -1652,6 +1652,25 @@ void VAbstractPiece::SetPriority(uint value) d->m_priority = value; } +//--------------------------------------------------------------------------------------------------------------------- +QUuid VAbstractPiece::GetUUID() const +{ + return d->m_uuid; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractPiece::SetUUID(const QUuid &uuid) +{ + d->m_uuid = uuid; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractPiece::SetUUID(const QString &uuid) +{ + const QUuid temp = QUuid(uuid); + d->m_uuid = temp.isNull() ? QUuid::createUuid() : temp; +} + //--------------------------------------------------------------------------------------------------------------------- qreal VSAPoint::GetSABefore(qreal width) const { diff --git a/src/libs/vlayout/vabstractpiece.h b/src/libs/vlayout/vabstractpiece.h index adff3056b..f787503a6 100644 --- a/src/libs/vlayout/vabstractpiece.h +++ b/src/libs/vlayout/vabstractpiece.h @@ -91,6 +91,10 @@ public: uint GetPriority() const; void SetPriority(uint value); + QUuid GetUUID() const; + void SetUUID(const QUuid &uuid); + void SetUUID(const QString &uuid); + static QVector Equidistant(QVector points, qreal width, const QString &name); static qreal SumTrapezoids(const QVector &points); static QVector CheckLoops(const QVector &points); diff --git a/src/libs/vlayout/vabstractpiece_p.h b/src/libs/vlayout/vabstractpiece_p.h index 91d0efbe5..6aa88ad06 100644 --- a/src/libs/vlayout/vabstractpiece_p.h +++ b/src/libs/vlayout/vabstractpiece_p.h @@ -32,6 +32,7 @@ #include #include #include +#include #include "../vmisc/diagnostic.h" #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) @@ -62,7 +63,8 @@ public: m_width(piece.m_width), m_mx(piece.m_mx), m_my(piece.m_my), - m_priority(piece.m_priority) + m_priority(piece.m_priority), + m_uuid(piece.m_uuid) {} ~VAbstractPieceData() Q_DECL_EQ_DEFAULT; @@ -81,6 +83,7 @@ public: qreal m_mx{0}; qreal m_my{0}; uint m_priority{0}; + QUuid m_uuid{QUuid::createUuid()}; private: Q_DISABLE_ASSIGN(VAbstractPieceData) @@ -111,6 +114,9 @@ inline QDataStream &operator<<(QDataStream &dataStream, const VAbstractPieceData // Added in classVersion = 2 dataStream << piece.m_priority; + // Added in classVersion = 3 + dataStream << piece.m_uuid; + return dataStream; } @@ -155,6 +161,11 @@ inline QDataStream &operator>>(QDataStream &dataStream, VAbstractPieceData &piec dataStream >> piece.m_priority; } + if (actualClassVersion >= 3) + { + dataStream >> piece.m_uuid; + } + return dataStream; } diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index 7d4fbb5cb..ed6b5a2bb 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include "../vpatterndb/floatItemData/vpatternlabeldata.h" #include "../vpatterndb/floatItemData/vpiecelabeldata.h" @@ -452,6 +453,7 @@ VLayoutPiece VLayoutPiece::Create(const VPiece &piece, vidtype id, const VContai det.SetMy(piece.GetMy()); det.SetName(piece.GetName()); + det.SetUUID(piece.GetUUID()); det.SetSAWidth(qApp->toPixel(piece.GetSAWidth())); det.SetForbidFlipping(piece.IsForbidFlipping()); diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index 86db51444..ba2738625 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -53,6 +53,7 @@ #include #include +#include #include enum TabOrder {Paths=0, Pins=1, Labels=2, Grainline=3, Passmarks=4, PlaceLabels=5, Count=6}; @@ -117,6 +118,7 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, quint32 toolId, flagFormulaAfter(true), flagMainPathIsValid(true), flagName(true), //We have default name of piece. + flagUUID(true), flagFormula(true), m_bAddMode(true), m_dialog(), @@ -149,6 +151,7 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, quint32 toolId, EnableApply(applyAllowed); InitMainPathTab(); + InitPieceTab(); InitSeamAllowanceTab(); InitInternalPathsTab(); InitPatternPieceDataTab(); @@ -318,6 +321,7 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece) uiTabPaths->checkBoxSeams->setChecked(piece.IsSeamAllowance()); uiTabPaths->checkBoxBuiltIn->setChecked(piece.IsSeamAllowanceBuiltIn()); uiTabPaths->lineEditName->setText(piece.GetName()); + uiTabPaths->lineEditUUID->setText(piece.GetUUID().toString()); uiTabPaths->spinBoxPriority->setValue(static_cast(piece.GetPriority())); uiTabPaths->plainTextEditFormulaWidth->setPlainText( @@ -493,7 +497,7 @@ void DialogSeamAllowance::CheckState() if (flagFormula && flagFormulaBefore && flagFormulaAfter) { - if (flagMainPathIsValid && flagName) + if (flagMainPathIsValid && flagName && flagUUID) { m_ftb->SetTabText(TabOrder::Paths, tr("Paths")); } @@ -508,9 +512,9 @@ void DialogSeamAllowance::CheckState() uiTabPaths->tabWidget->setTabIcon(uiTabPaths->tabWidget->indexOf(uiTabPaths->tabSeamAllowance), icon); } - if (flagMainPathIsValid && flagName) + if (flagMainPathIsValid) { - if (flagFormula && flagFormulaBefore && flagFormulaAfter) + if (flagFormula && flagFormulaBefore && flagFormulaAfter && flagName && flagUUID) { m_ftb->SetTabText(TabOrder::Paths, tr("Paths")); } @@ -532,6 +536,22 @@ void DialogSeamAllowance::CheckState() uiTabPaths->tabWidget->setTabIcon(uiTabPaths->tabWidget->indexOf(uiTabPaths->tabMainPath), icon); } + if (flagName && flagUUID) + { + if (flagFormula && flagFormulaBefore && flagFormulaAfter && flagMainPathIsValid) + { + m_ftb->SetTabText(TabOrder::Paths, tr("Paths")); + } + uiTabPaths->tabWidget->setTabIcon(uiTabPaths->tabWidget->indexOf(uiTabPaths->tabPiece), QIcon()); + } + else + { + m_ftb->SetTabText(TabOrder::Paths, tr("Paths") + '*'); + const QIcon icon = QIcon::fromTheme("dialog-warning", + QIcon(":/icons/win.icon.theme/16x16/status/dialog-warning.png")); + uiTabPaths->tabWidget->setTabIcon(uiTabPaths->tabWidget->indexOf(uiTabPaths->tabPiece), icon); + } + uiTabPaths->comboBoxNodes->setEnabled(flagFormulaBefore && flagFormulaAfter); if (uiTabPassmarks->comboBoxPassmarks->count() == 0) @@ -620,6 +640,30 @@ void DialogSeamAllowance::NameDetailChanged() CheckState(); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::DetailUUIDChanged() +{ + QLineEdit* edit = qobject_cast(sender()); + if (edit) + { + QRegularExpression re("^$|^{[0-9a-fA-F]{8}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{4}\\-" + "[0-9a-fA-F]{12}}$"); + QRegularExpressionMatch match = re.match(edit->text()); + + if (match.hasMatch()) + { + flagUUID = true; + ChangeColor(uiTabPaths->labelEditUUID, OkColor(this)); + } + else + { + flagUUID = false; + ChangeColor(uiTabPaths->labelEditUUID, errorColor); + } + } + CheckState(); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::ShowMainPathContextMenu(const QPoint &pos) { @@ -2454,6 +2498,7 @@ VPiece DialogSeamAllowance::CreatePiece() const piece.SetSeamAllowanceBuiltIn(uiTabPaths->checkBoxBuiltIn->isChecked()); piece.SetHideMainPath(uiTabPaths->checkBoxHideMainPath->isChecked()); piece.SetName(uiTabPaths->lineEditName->text()); + piece.SetUUID(uiTabPaths->lineEditUUID->text()); piece.SetPriority(static_cast(uiTabPaths->spinBoxPriority->value())); piece.SetFormulaSAWidth(GetFormulaFromUser(uiTabPaths->plainTextEditFormulaWidth), m_saWidth); piece.GetPatternPieceData().SetLetter(uiTabLabels->lineEditLetter->text()); @@ -2831,6 +2876,29 @@ void DialogSeamAllowance::InitFancyTabBar() //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::InitMainPathTab() +{ + uiTabPaths->checkBoxHideMainPath->setChecked(qApp->Settings()->IsHideMainPath()); + + uiTabPaths->listWidgetMainPath->setContextMenuPolicy(Qt::CustomContextMenu); + connect(uiTabPaths->listWidgetMainPath, &QListWidget::customContextMenuRequested, this, + &DialogSeamAllowance::ShowMainPathContextMenu); + connect(uiTabPaths->listWidgetMainPath->model(), &QAbstractItemModel::rowsMoved, this, + &DialogSeamAllowance::ListChanged); + connect(uiTabPaths->listWidgetMainPath, &QListWidget::itemSelectionChanged, this, + &DialogSeamAllowance::SetMoveControls); + + connect(uiTabPaths->toolButtonTop, &QToolButton::clicked, this, + [this](){MoveListRowTop(uiTabPaths->listWidgetMainPath);}); + connect(uiTabPaths->toolButtonUp, &QToolButton::clicked, this, + [this](){MoveListRowUp(uiTabPaths->listWidgetMainPath);}); + connect(uiTabPaths->toolButtonDown, &QToolButton::clicked, this, + [this](){MoveListRowDown(uiTabPaths->listWidgetMainPath);}); + connect(uiTabPaths->toolButtonBottom, &QToolButton::clicked, this, + [this](){MoveListRowBottom(uiTabPaths->listWidgetMainPath);}); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::InitPieceTab() { connect(uiTabPaths->lineEditName, &QLineEdit::textChanged, this, &DialogSeamAllowance::NameDetailChanged); @@ -2855,24 +2923,8 @@ void DialogSeamAllowance::InitMainPathTab() uiTabPaths->checkBoxForbidFlipping->setChecked(qApp->Settings()->GetForbidWorkpieceFlipping()); uiTabPaths->checkBoxForceFlipping->setChecked(qApp->Settings()->GetForceWorkpieceFlipping()); - uiTabPaths->checkBoxHideMainPath->setChecked(qApp->Settings()->IsHideMainPath()); - uiTabPaths->listWidgetMainPath->setContextMenuPolicy(Qt::CustomContextMenu); - connect(uiTabPaths->listWidgetMainPath, &QListWidget::customContextMenuRequested, this, - &DialogSeamAllowance::ShowMainPathContextMenu); - connect(uiTabPaths->listWidgetMainPath->model(), &QAbstractItemModel::rowsMoved, this, - &DialogSeamAllowance::ListChanged); - connect(uiTabPaths->listWidgetMainPath, &QListWidget::itemSelectionChanged, this, - &DialogSeamAllowance::SetMoveControls); - - connect(uiTabPaths->toolButtonTop, &QToolButton::clicked, this, - [this](){MoveListRowTop(uiTabPaths->listWidgetMainPath);}); - connect(uiTabPaths->toolButtonUp, &QToolButton::clicked, this, - [this](){MoveListRowUp(uiTabPaths->listWidgetMainPath);}); - connect(uiTabPaths->toolButtonDown, &QToolButton::clicked, this, - [this](){MoveListRowDown(uiTabPaths->listWidgetMainPath);}); - connect(uiTabPaths->toolButtonBottom, &QToolButton::clicked, this, - [this](){MoveListRowBottom(uiTabPaths->listWidgetMainPath);}); + connect(uiTabPaths->lineEditUUID, &QLineEdit::textChanged, this, &DialogSeamAllowance::DetailUUIDChanged); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h index 6a7250ef6..c51e9054d 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h @@ -85,6 +85,7 @@ protected: private slots: void NameDetailChanged(); + void DetailUUIDChanged(); void ShowMainPathContextMenu(const QPoint &pos); void ShowCustomSAContextMenu(const QPoint &pos); void ShowInternalPathsContextMenu(const QPoint &pos); @@ -192,6 +193,7 @@ private: bool flagFormulaPassmarkLength{true}; bool flagMainPathIsValid; bool flagName; + bool flagUUID; bool flagFormula; bool m_bAddMode; @@ -247,6 +249,7 @@ private: void InitFancyTabBar(); void InitMainPathTab(); + void InitPieceTab(); void InitSeamAllowanceTab(); void InitNodesList(); void InitPassmarksList(); @@ -292,7 +295,7 @@ private: //--------------------------------------------------------------------------------------------------------------------- inline bool DialogSeamAllowance::IsValid() const { - return flagName && flagMainPathIsValid && flagFormula && flagFormulaBefore && flagFormulaAfter + return flagName && flagUUID && flagMainPathIsValid && flagFormula && flagFormulaBefore && flagFormulaAfter && (flagGFormulas || flagGPin) && flagDLAngle && (flagDLFormulas || flagDPin) && flagPLAngle && (flagPLFormulas || flagPPin) && flagFormulaPassmarkLength; } diff --git a/src/libs/vtools/dialogs/tools/piece/tabs/tabpaths.ui b/src/libs/vtools/dialogs/tools/piece/tabs/tabpaths.ui index ed9beef50..32b77c95c 100644 --- a/src/libs/vtools/dialogs/tools/piece/tabs/tabpaths.ui +++ b/src/libs/vtools/dialogs/tools/piece/tabs/tabpaths.ui @@ -6,8 +6,8 @@ 0 0 - 426 - 637 + 422 + 624 @@ -28,8 +28,8 @@ 0 0 - 406 - 617 + 402 + 604 @@ -73,64 +73,6 @@ - - - - QFormLayout::ExpandingFieldsGrow - - - - - Name of detail: - - - - - - - Detail - - - Name can't be empty - - - - - - - Priority: - - - - - - - Controls priority in layout. 0 - no priority. - - - - - - - - - Forbid piece be mirrored in a layout. - - - Forbid flipping - - - - - - - Force piece to be always flipped in a layout. - - - Force flipping - - - @@ -248,6 +190,101 @@ + + + Piece + + + + + + + + UUID: + + + + + + + Priority: + + + + + + + Name of detail: + + + + + + + Controls priority in layout. 0 - no priority. + + + + + + + Detail + + + Name can't be empty + + + + + + + Universally Unique IDentifier of piece. Used to identifier piece while updating manual layout. Left empty to generate new value. + + + {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} + + + true + + + + + + + + + Forbid piece be mirrored in a layout. + + + Forbid flipping + + + + + + + Force piece to be always flipped in a layout. + + + Force flipping + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + Seam allowance diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 1e6e65f9a..ab6a16476 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -64,6 +64,7 @@ #include #include #include +#include // Current version of seam allowance tag need for backward compatibility const quint8 VToolSeamAllowance::pieceVersion = 2; @@ -270,6 +271,7 @@ void VToolSeamAllowance::AddAttributes(VAbstractPattern *doc, QDomElement &domEl doc->SetAttribute(domElement, VDomDocument::AttrId, id); doc->SetAttribute(domElement, AttrName, piece.GetName()); + doc->SetAttribute(domElement, AttrUUID, piece.GetUUID().toString()); doc->SetAttribute(domElement, AttrVersion, QString().setNum(pieceVersion)); doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(piece.GetMx())); doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(piece.GetMy()));