diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index 48302b807..aa216823e 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -504,38 +504,6 @@ void VPMainWindow::InitProperties() //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::InitPropertyTabCurrentPiece() { - connect(ui->lineEditCurrentPieceName, &QLineEdit::textEdited, this, [this](const QString &text) - { - QList selectedPieces = SelectedPieces(); - if (selectedPieces.size() == 1) - { - VPPiecePtr selectedPiece = selectedPieces.first(); - if (not selectedPiece.isNull()) - { - selectedPiece->SetName(text); - LayoutWasSaved(false); - } - } - }); - - connect(ui->plainTextEditCurrentPieceUUID, &QPlainTextEdit::textChanged, this, [this]() - { - QList selectedPieces = SelectedPieces(); - if (selectedPieces.size() == 1) - { - VPPiecePtr selectedPiece = selectedPieces.first(); - if (not selectedPiece.isNull()) - { - const QUuid temp = QUuid(ui->plainTextEditCurrentPieceUUID->toPlainText()); - if (not temp.isNull()) - { - selectedPiece->SetUUID(temp); - } - LayoutWasSaved(false); - } - } - }); - connect(ui->checkBoxCurrentPieceShowSeamline, &QCheckBox::toggled, this, [this](bool checked) { QList selectedPieces = SelectedPieces(); @@ -956,6 +924,7 @@ void VPMainWindow::SetPropertyTabCurrentPieceData() // set the value to the current piece SetLineEditValue(ui->lineEditCurrentPieceName, selectedPiece->GetName()); SetPlainTextEditValue(ui->plainTextEditCurrentPieceUUID, selectedPiece->GetUUID().toString()); + SetLineEditValue(ui->lineEditCurrentPieceGradationId, selectedPiece->GetGradationId()); // SetCheckBoxValue(ui->checkBoxCurrentPieceShowSeamline, selectedPiece->GetShowSeamLine()); SetCheckBoxValue(ui->checkBoxCurrentPieceMirrorPiece, selectedPiece->IsMirror()); diff --git a/src/app/puzzle/vpmainwindow.ui b/src/app/puzzle/vpmainwindow.ui index 9ca639200..9255cdd16 100644 --- a/src/app/puzzle/vpmainwindow.ui +++ b/src/app/puzzle/vpmainwindow.ui @@ -189,7 +189,7 @@ QTabWidget::Rounded - 3 + 0 @@ -331,6 +331,20 @@ + + + + Gradation id: + + + + + + + true + + + @@ -1874,8 +1888,8 @@ - + diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 395ad7363..bdaffe4f4 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -876,6 +876,7 @@ void VPattern::ParseDetailElement(QDomElement &domElement, const Document &parse initData.id = GetParametrId(domElement); initData.detail.SetName(GetParametrString(domElement, AttrName, tr("Detail"))); initData.detail.SetUUID(GetParametrEmptyString(domElement, AttrUUID)); + initData.detail.SetGradationLabel(GetParametrEmptyString(domElement, AttrGradationLabel)); initData.detail.SetMx(VAbstractValApplication::VApp() ->toPixel(GetParametrDouble(domElement, AttrMx, QStringLiteral("0.0")))); initData.detail.SetMy(VAbstractValApplication::VApp() diff --git a/src/libs/ifc/ifcdef.cpp b/src/libs/ifc/ifcdef.cpp index dc62134c4..4763c56ce 100644 --- a/src/libs/ifc/ifcdef.cpp +++ b/src/libs/ifc/ifcdef.cpp @@ -48,6 +48,7 @@ const QString AttrMx = QStringLiteral("mx"); const QString AttrMy = QStringLiteral("my"); const QString AttrName = QStringLiteral("name"); const QString AttrUUID = QStringLiteral("uuid"); +const QString AttrGradationLabel = QStringLiteral("gradationLabel"); 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 66b3351e7..7a51d80b5 100644 --- a/src/libs/ifc/ifcdef.h +++ b/src/libs/ifc/ifcdef.h @@ -66,6 +66,7 @@ extern const QString AttrMx; extern const QString AttrMy; extern const QString AttrName; extern const QString AttrUUID; +extern const QString AttrGradationLabel; 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 77690e539..16a95db94 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -63,6 +63,7 @@ schema/pattern/v0.8.9.xsd schema/pattern/v0.8.10.xsd schema/pattern/v0.8.11.xsd + schema/pattern/v0.8.12.xsd schema/multisize_measurements/v0.3.0.xsd schema/multisize_measurements/v0.4.0.xsd schema/multisize_measurements/v0.4.1.xsd diff --git a/src/libs/ifc/schema/pattern/v0.8.12.xsd b/src/libs/ifc/schema/pattern/v0.8.12.xsd new file mode 100644 index 000000000..9b20f38f9 --- /dev/null +++ b/src/libs/ifc/schema/pattern/v0.8.12.xsd @@ -0,0 +1,1134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index 2a158b988..cd70a1af7 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -60,8 +60,8 @@ class QDomElement; */ const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.4"); -const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.11"); -const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.11.xsd"); +const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.12"); +const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.12.xsd"); //VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! @@ -244,7 +244,8 @@ QString VPatternConverter::XSDSchema(int ver) const std::make_pair(FORMAT_VERSION(0, 8, 8), QStringLiteral("://schema/pattern/v0.8.8.xsd")), std::make_pair(FORMAT_VERSION(0, 8, 9), QStringLiteral("://schema/pattern/v0.8.9.xsd")), std::make_pair(FORMAT_VERSION(0, 8, 10), QStringLiteral("://schema/pattern/v0.8.10.xsd")), - std::make_pair(FORMAT_VERSION(0, 8, 11), CurrentSchema) + std::make_pair(FORMAT_VERSION(0, 8, 11), QStringLiteral("://schema/pattern/v0.8.11.xsd")), + std::make_pair(FORMAT_VERSION(0, 8, 12), CurrentSchema) }; if (schemas.contains(ver)) @@ -509,6 +510,10 @@ void VPatternConverter::ApplyPatches() ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 11))); Q_FALLTHROUGH(); case (FORMAT_VERSION(0, 8, 11)): + ToV0_8_12(); + ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 12))); + Q_FALLTHROUGH(); + case (FORMAT_VERSION(0, 8, 12)): break; default: InvalidVersion(m_ver); @@ -526,7 +531,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, 11), + Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FORMAT_VERSION(0, 8, 12), "Check attribute readOnly."); // Possibly in future attribute readOnly will change position etc. @@ -1208,6 +1213,16 @@ void VPatternConverter::ToV0_8_11() Save(); } +//--------------------------------------------------------------------------------------------------------------------- +void VPatternConverter::ToV0_8_12() +{ + // TODO. Delete if minimal supported version is 0.8.12 + Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FORMAT_VERSION(0, 8, 12), + "Time to refactor the code."); + SetVersion(QStringLiteral("0.8.12")); + Save(); +} + //--------------------------------------------------------------------------------------------------------------------- void VPatternConverter::TagUnitToV0_2_0() { diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h index 64534111d..e30289b7a 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, 11); + static Q_DECL_CONSTEXPR const int PatternMaxVer = FORMAT_VERSION(0, 8, 12); protected: virtual int MinVer() const override; @@ -134,6 +134,7 @@ private: void ToV0_8_9(); void ToV0_8_10(); void ToV0_8_11(); + void ToV0_8_12(); void TagUnitToV0_2_0(); void TagIncrementToV0_2_0(); diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index 7a0112880..c52219852 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -1631,7 +1631,7 @@ void VAbstractPiece::SetUUID(const QString &uuid) } //--------------------------------------------------------------------------------------------------------------------- -QString VAbstractPiece::GetUniqueID() const +auto VAbstractPiece::GetUniqueID() const -> QString { return d->m_uuid.toString(); } diff --git a/src/libs/vlayout/vabstractpiece.h b/src/libs/vlayout/vabstractpiece.h index fbeef6416..1d74135db 100644 --- a/src/libs/vlayout/vabstractpiece.h +++ b/src/libs/vlayout/vabstractpiece.h @@ -100,7 +100,7 @@ public: * @brief GetUniqueID returns unique piece id. Combines UUID and gradation label. * @return unique piece id. */ - QString GetUniqueID() const; + virtual QString GetUniqueID() const; static QVector Equidistant(QVector points, qreal width, const QString &name); static qreal SumTrapezoids(const QVector &points); diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index 9f518628e..abf892bfe 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -429,6 +429,87 @@ QVector ConvertPassmarks(const VPiece &piece, const VContainer return layoutPassmarks; } + +//--------------------------------------------------------------------------------------------------------------------- +auto PrepareGradationPlaceholders(const VContainer *data) -> QMap +{ + SCASSERT(data != nullptr) + + QMap placeholders; + + QString heightValue = QString::number(VAbstractValApplication::VApp()->GetDimensionHeight()); + placeholders.insert(pl_height, heightValue); + + QString sizeValue = QString::number(VAbstractValApplication::VApp()->GetDimensionSize()); + placeholders.insert(pl_size, sizeValue); + + QString hipValue = QString::number(VAbstractValApplication::VApp()->GetDimensionHip()); + placeholders.insert(pl_hip, hipValue); + + QString waistValue = QString::number(VAbstractValApplication::VApp()->GetDimensionWaist()); + placeholders.insert(pl_waist, waistValue); + + { + QString label = VAbstractValApplication::VApp()->GetDimensionHeightLabel(); + placeholders.insert(pl_heightLabel, not label.isEmpty() ? label : heightValue); + + label = VAbstractValApplication::VApp()->GetDimensionSizeLabel(); + placeholders.insert(pl_sizeLabel, not label.isEmpty() ? label : sizeValue); + + label = VAbstractValApplication::VApp()->GetDimensionHipLabel(); + placeholders.insert(pl_hipLabel, not label.isEmpty() ? label : hipValue); + + label = VAbstractValApplication::VApp()->GetDimensionWaistLabel(); + placeholders.insert(pl_waistLabel, not label.isEmpty() ? label : waistValue); + } + + { + const QMap > measurements = data->DataMeasurements(); + auto i = measurements.constBegin(); + while (i != measurements.constEnd()) + { + placeholders.insert(pl_measurement + i.key(), QString::number(*i.value()->GetValue())); + ++i; + } + } + + return placeholders; +} + +//--------------------------------------------------------------------------------------------------------------------- +auto ReplacePlaceholders(const QMap &placeholders, QString line) -> QString +{ + QChar per('%'); + + auto TestDimension = [per, placeholders, line](const QString &placeholder, const QString &errorMsg) + { + if (line.contains(per+placeholder+per) && placeholders.value(placeholder) == QChar('0')) + { + VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; + } + }; + + TestDimension(pl_height, QObject::tr("No data for the height dimension.")); + TestDimension(pl_size, QObject::tr("No data for the size dimension.")); + TestDimension(pl_hip, QObject::tr("No data for the hip dimension.")); + TestDimension(pl_waist, QObject::tr("No data for the waist dimension.")); + + auto i = placeholders.constBegin(); + while (i != placeholders.constEnd()) + { + line.replace(per+i.key()+per, i.value()); + ++i; + } + return line; +} + +//--------------------------------------------------------------------------------------------------------------------- +auto PrepareGradationId(const QString &label, const VContainer *pattern) -> QString +{ + const QMap placeholders = PrepareGradationPlaceholders(pattern); + return ReplacePlaceholders(placeholders, label); +} } // Friend functions @@ -506,6 +587,7 @@ VLayoutPiece VLayoutPiece::Create(const VPiece &piece, vidtype id, const VContai det.SetName(piece.GetName()); det.SetUUID(piece.GetUUID()); + det.SetGradationId(PrepareGradationId(piece.GetGradationLabel(), pattern)); det.SetSAWidth(VAbstractValApplication::VApp()->toPixel(piece.GetSAWidth())); det.SetForbidFlipping(piece.IsForbidFlipping()); @@ -558,6 +640,19 @@ VLayoutPiece VLayoutPiece::Create(const VPiece &piece, vidtype id, const VContai return det; } +//--------------------------------------------------------------------------------------------------------------------- +auto VLayoutPiece::GetUniqueID() const -> QString +{ + QString id = VAbstractPiece::GetUniqueID(); + + if (not d->m_gradationId.isEmpty()) + { + id = id + '_' + d->m_gradationId; + } + + return id; +} + //--------------------------------------------------------------------------------------------------------------------- template auto VLayoutPiece::Map(QVector points) const -> QVector @@ -1573,6 +1668,18 @@ void VLayoutPiece::SetMirror(bool value) d->mirror = value; } +//--------------------------------------------------------------------------------------------------------------------- +void VLayoutPiece::SetGradationId(const QString &id) +{ + d->m_gradationId = id; +} + +//--------------------------------------------------------------------------------------------------------------------- +auto VLayoutPiece::GetGradationId() const -> QString +{ + return d->m_gradationId; +} + //--------------------------------------------------------------------------------------------------------------------- QLineF VLayoutPiece::Edge(const QVector &path, int i) const { diff --git a/src/libs/vlayout/vlayoutpiece.h b/src/libs/vlayout/vlayoutpiece.h index 568ba4308..0d9581989 100644 --- a/src/libs/vlayout/vlayoutpiece.h +++ b/src/libs/vlayout/vlayoutpiece.h @@ -73,6 +73,8 @@ public: static VLayoutPiece Create(const VPiece &piece, vidtype id, const VContainer *pattern); + virtual auto GetUniqueID() const -> QString override; + QVector GetMappedContourPoints() const; QVector GetContourPoints() const; void SetCountourPoints(const QVector &points, bool hideMainPath = false); @@ -132,6 +134,9 @@ public: bool IsMirror() const; void SetMirror(bool value); + void SetGradationId(const QString &id); + auto GetGradationId() const -> QString; + void Translate(const QPointF &p); void Translate(qreal dx, qreal dy); void Scale(qreal sx, qreal sy); diff --git a/src/libs/vlayout/vlayoutpiece_p.h b/src/libs/vlayout/vlayoutpiece_p.h index 129d654ab..9f435121a 100644 --- a/src/libs/vlayout/vlayoutpiece_p.h +++ b/src/libs/vlayout/vlayoutpiece_p.h @@ -77,7 +77,8 @@ public: m_placeLabels(detail.m_placeLabels), m_square(detail.m_square), m_quantity(detail.m_quantity), - m_id(detail.m_id) + m_id(detail.m_id), + m_gradationId(detail.m_gradationId) {} ~VLayoutPieceData() Q_DECL_EQ_DEFAULT; @@ -137,6 +138,8 @@ public: /** @brief m_id keep id of original piece. */ vidtype m_id; + QString m_gradationId{}; + private: Q_DISABLE_ASSIGN(VLayoutPieceData) @@ -175,6 +178,7 @@ inline QDataStream &operator<<(QDataStream &dataStream, const VLayoutPieceData & // Added in classVersion = 3 dataStream << piece.m_tmDetail; dataStream << piece.m_tmPattern; + dataStream << piece.m_gradationId; return dataStream; } @@ -232,6 +236,7 @@ inline QDataStream &operator>>(QDataStream &dataStream, VLayoutPieceData &piece) { dataStream >> piece.m_tmDetail; dataStream >> piece.m_tmPattern; + dataStream >> piece.m_gradationId; } return dataStream; diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index 6e08481c4..daeabbf58 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -748,6 +748,18 @@ QVector VPiece::SeamAllowancePointsWithRotation(const VContainer *data, return Equidistant(pointsEkv, width, GetName()); } +//--------------------------------------------------------------------------------------------------------------------- +void VPiece::SetGradationLabel(const QString &label) +{ + d->m_gradationLabel = label; +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VPiece::GetGradationLabel() const +{ + return d->m_gradationLabel; +} + //--------------------------------------------------------------------------------------------------------------------- QVector VPiece::GetUnitedPath(const VContainer *data) const { diff --git a/src/libs/vpatterndb/vpiece.h b/src/libs/vpatterndb/vpiece.h index 674baecb0..19e4232ea 100644 --- a/src/libs/vpatterndb/vpiece.h +++ b/src/libs/vpatterndb/vpiece.h @@ -134,6 +134,9 @@ public: QVector SeamAllowancePointsWithRotation(const VContainer *data, int makeFirst) const; + void SetGradationLabel(const QString &label); + auto GetGradationLabel() const -> QString; + static void DumpPiece(const VPiece &piece, const VContainer *data); private: QSharedDataPointer d; diff --git a/src/libs/vpatterndb/vpiece_p.h b/src/libs/vpatterndb/vpiece_p.h index 5a8ed79e4..1d33a7310 100644 --- a/src/libs/vpatterndb/vpiece_p.h +++ b/src/libs/vpatterndb/vpiece_p.h @@ -73,7 +73,8 @@ public: m_ppData(detail.m_ppData), m_piPatternInfo(detail.m_piPatternInfo), m_glGrainline(detail.m_glGrainline), - m_formulaWidth(detail.m_formulaWidth) + m_formulaWidth(detail.m_formulaWidth), + m_gradationLabel(detail.m_gradationLabel) {} ~VPieceData(); @@ -100,6 +101,8 @@ public: QString m_formulaWidth; + QString m_gradationLabel{}; + private: Q_DISABLE_ASSIGN(VPieceData) }; diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index d533c6744..b63ec21e7 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -168,7 +168,8 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, quint32 toolId, m_templateLines(), m_undoStack(), m_newPlaceLabels(), - m_newPaths() + m_newPaths(), + m_placeholdersMenu(new QMenu(this)) { ui->setupUi(this); @@ -350,6 +351,7 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece) uiTabPaths->checkBoxBuiltIn->setChecked(piece.IsSeamAllowanceBuiltIn()); uiTabPaths->lineEditName->setText(piece.GetName()); uiTabPaths->lineEditUUID->setText(piece.GetUUID().toString()); + uiTabPaths->lineEditGradationLabel->setText(piece.GetGradationLabel()); uiTabPaths->spinBoxPriority->setValue(static_cast(piece.GetPriority())); uiTabPaths->plainTextEditFormulaWidth->setPlainText( @@ -2581,6 +2583,7 @@ VPiece DialogSeamAllowance::CreatePiece() const piece.SetHideMainPath(uiTabPaths->checkBoxHideMainPath->isChecked()); piece.SetName(uiTabPaths->lineEditName->text()); piece.SetUUID(uiTabPaths->lineEditUUID->text()); + piece.SetGradationLabel(uiTabPaths->lineEditGradationLabel->text()); piece.SetPriority(static_cast(uiTabPaths->spinBoxPriority->value())); piece.SetFormulaSAWidth(GetFormulaFromUser(uiTabPaths->plainTextEditFormulaWidth), m_saWidth); piece.GetPatternPieceData().SetLetter(uiTabLabels->lineEditLetter->text()); @@ -3025,6 +3028,12 @@ void DialogSeamAllowance::InitPieceTab() [this](){MoveListRowDown(uiTabPaths->listWidgetMainPath);}); connect(uiTabPaths->lineEditUUID, &QLineEdit::textChanged, this, &DialogSeamAllowance::DetailUUIDChanged); + + InitGradationPlaceholders(); + InitGradationPlaceholdersMenu(); + + m_placeholdersMenu->setStyleSheet(QStringLiteral("QMenu { menu-scrollable: 1; }")); + uiTabPaths->pushButtonGradationPlaceholder->setMenu(m_placeholdersMenu); } //--------------------------------------------------------------------------------------------------------------------- @@ -3863,6 +3872,71 @@ void DialogSeamAllowance::SavePatternMaterialData() } } +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::InitGradationPlaceholdersMenu() +{ + QChar per('%'); + auto i = m_gradationPlaceholders.constBegin(); + while (i != m_gradationPlaceholders.constEnd()) + { + auto value = i.value(); + QAction *action = m_placeholdersMenu->addAction(value.first); + action->setData(per + i.key() + per); + connect(action, &QAction::triggered, this, &DialogSeamAllowance::InsertGradationPlaceholder); + ++i; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::InitGradationPlaceholders() +{ + // Pattern tags + QLocale locale(VAbstractApplication::VApp()->Settings()->GetLocale()); + + QString heightValue = QString::number(VAbstractValApplication::VApp()->GetDimensionHeight()); + m_gradationPlaceholders.insert(pl_height, qMakePair(tr("Height", "dimension"), heightValue)); + + QString sizeValue = QString::number(VAbstractValApplication::VApp()->GetDimensionSize()); + m_gradationPlaceholders.insert(pl_size, qMakePair(tr("Size", "dimension"), sizeValue)); + + QString hipValue = QString::number(VAbstractValApplication::VApp()->GetDimensionHip()); + m_gradationPlaceholders.insert(pl_hip, qMakePair(tr("Hip", "dimension"), hipValue)); + + QString waistValue = QString::number(VAbstractValApplication::VApp()->GetDimensionWaist()); + m_gradationPlaceholders.insert(pl_waist, qMakePair(tr("Waist", "dimension"), waistValue)); + + { + QString label = VAbstractValApplication::VApp()->GetDimensionHeightLabel(); + m_gradationPlaceholders.insert(pl_heightLabel, qMakePair(tr("Height label", "dimension"), + not label.isEmpty() ? label : heightValue)); + + label = VAbstractValApplication::VApp()->GetDimensionSizeLabel(); + m_gradationPlaceholders.insert(pl_sizeLabel, qMakePair(tr("Size label", "dimension"), + not label.isEmpty() ? label : sizeValue)); + + label = VAbstractValApplication::VApp()->GetDimensionHipLabel(); + m_gradationPlaceholders.insert(pl_hipLabel, qMakePair(tr("Hip label", "dimension"), + not label.isEmpty() ? label : hipValue)); + + label = VAbstractValApplication::VApp()->GetDimensionWaistLabel(); + m_gradationPlaceholders.insert(pl_waistLabel, qMakePair(tr("Waist label", "dimension"), + not label.isEmpty() ? label : waistValue)); + } + + { + const QMap > measurements = data->DataMeasurements(); + auto i = measurements.constBegin(); + while (i != measurements.constEnd()) + { + QString description = i.value()->GetGuiText().isEmpty() ? i.key() : i.value()->GetGuiText(); + m_gradationPlaceholders.insert(pl_measurement + i.key(), + qMakePair(tr("Measurement: %1").arg(description), + QString::number(*i.value()->GetValue()))); + ++i; + } + } +} + //--------------------------------------------------------------------------------------------------------------------- void DialogSeamAllowance::SetMoveControls() { @@ -3955,3 +4029,14 @@ void DialogSeamAllowance::ManagePatternMaterials() } } } + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::InsertGradationPlaceholder() +{ + QAction *action = qobject_cast(sender()); + if (action) + { + uiTabPaths->lineEditGradationLabel->insert(action->data().toString()); + uiTabPaths->lineEditGradationLabel->setFocus(); + } +} diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h index a89fcd125..dc0b46a37 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h @@ -164,6 +164,8 @@ private slots: void EditPatternLabel(); void ManagePatternMaterials(); + void InsertGradationPlaceholder(); + private: Q_DISABLE_COPY(DialogSeamAllowance) @@ -242,6 +244,10 @@ private: QString m_defLabelValue{}; + QMenu *m_placeholdersMenu; + + QMap> m_gradationPlaceholders{}; + VPiece CreatePiece() const; void NewMainPathItem(const VPieceNode &node); @@ -311,6 +317,9 @@ private: void SavePatternLabelData(); void SavePatternTemplateData(); void SavePatternMaterialData(); + + void InitGradationPlaceholdersMenu(); + void InitGradationPlaceholders(); }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/piece/tabs/tabpaths.ui b/src/libs/vtools/dialogs/tools/piece/tabs/tabpaths.ui index 32b77c95c..bdea248e8 100644 --- a/src/libs/vtools/dialogs/tools/piece/tabs/tabpaths.ui +++ b/src/libs/vtools/dialogs/tools/piece/tabs/tabpaths.ui @@ -28,15 +28,15 @@ 0 0 - 402 - 604 + 394 + 612 - 0 + 1 @@ -197,10 +197,13 @@ - - + + - UUID: + Detail + + + Name can't be empty @@ -225,16 +228,6 @@ - - - - Detail - - - Name can't be empty - - - @@ -248,6 +241,41 @@ + + + + UUID: + + + + + + + Gradation label: + + + + + + + + + %size%_%height% + + + true + + + + + + + Insert… + + + + + diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 953dcb8c9..b8087d2e6 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -332,6 +332,8 @@ 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->SetAttributeOrRemoveIf(domElement, AttrGradationLabel, piece.GetGradationLabel(), + [](const QString &label){return label.isEmpty();}); doc->SetAttribute(domElement, AttrVersion, QString().setNum(pieceVersion)); doc->SetAttribute(domElement, AttrMx, VAbstractValApplication::VApp()->fromPixel(piece.GetMx())); doc->SetAttribute(domElement, AttrMy, VAbstractValApplication::VApp()->fromPixel(piece.GetMy()));