diff --git a/src/libs/vmisc/def.cpp b/src/libs/vmisc/def.cpp index 7d5ad5402..32fe7f6bf 100644 --- a/src/libs/vmisc/def.cpp +++ b/src/libs/vmisc/def.cpp @@ -121,6 +121,15 @@ const QString pl_pExt = QStringLiteral("pExt"); const QString pl_pFileName = QStringLiteral("pFileName"); const QString pl_mFileName = QStringLiteral("mFileName"); const QString pl_mExt = QStringLiteral("mExt"); +const QString pl_pLetter = QStringLiteral("pLetter"); +const QString pl_pName = QStringLiteral("pName"); +const QString pl_pQuantity = QStringLiteral("pQuantity"); +const QString pl_mFabric = QStringLiteral("mFabric"); +const QString pl_mLining = QStringLiteral("mLining"); +const QString pl_mInterfacing = QStringLiteral("mInterfacing"); +const QString pl_mInterlining = QStringLiteral("mInterlining"); +const QString pl_wCut = QStringLiteral("wCut"); +const QString pl_wOnFold = QStringLiteral("wOnFold"); const QStringList labelTemplatePlaceholders = QStringList() << pl_size << pl_height @@ -133,7 +142,16 @@ const QStringList labelTemplatePlaceholders = QStringList() << pl_size << pl_pExt << pl_pFileName << pl_mFileName - << pl_mExt; + << pl_mExt + << pl_pLetter + << pl_pName + << pl_pQuantity + << pl_mFabric + << pl_mLining + << pl_mInterfacing + << pl_mInterlining + << pl_wCut + << pl_wOnFold; const QString cursorArrowOpenHand = QStringLiteral("://cursor/cursor-arrow-openhand.png"); const QString cursorArrowCloseHand = QStringLiteral("://cursor/cursor-arrow-closehand.png"); diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index 653fdad36..4cec58455 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -363,6 +363,15 @@ extern const QString pl_pExt; extern const QString pl_pFileName; extern const QString pl_mFileName; extern const QString pl_mExt; +extern const QString pl_pLetter; +extern const QString pl_pName; +extern const QString pl_pQuantity; +extern const QString pl_mFabric; +extern const QString pl_mLining; +extern const QString pl_mInterfacing; +extern const QString pl_mInterlining; +extern const QString pl_wCut; +extern const QString pl_wOnFold; extern const QStringList labelTemplatePlaceholders; diff --git a/src/libs/vpatterndb/floatItemData/vpiecelabeldata.cpp b/src/libs/vpatterndb/floatItemData/vpiecelabeldata.cpp index 06d641933..792b319ca 100644 --- a/src/libs/vpatterndb/floatItemData/vpiecelabeldata.cpp +++ b/src/libs/vpatterndb/floatItemData/vpiecelabeldata.cpp @@ -121,3 +121,42 @@ void VPieceLabelData::SetLetter(QString qsLetter) { d->m_qsLetter = qsLetter.left(3); } + +//--------------------------------------------------------------------------------------------------------------------- +int VPieceLabelData::GetQuantity() const +{ + return d->m_quantity; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPieceLabelData::SetQuantity(int val) +{ + if (val >= 1) + { + d->m_quantity = val; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VPieceLabelData::IsOnFold() const +{ + return d->m_onFold; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPieceLabelData::SetOnFold(bool onFold) +{ + d->m_onFold = onFold; +} + +//--------------------------------------------------------------------------------------------------------------------- +QVector VPieceLabelData::GetLabelTemplate() const +{ + return d->m_lines; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPieceLabelData::SetLabelTemplate(const QVector &lines) +{ + d->m_lines = lines; +} diff --git a/src/libs/vpatterndb/floatItemData/vpiecelabeldata.h b/src/libs/vpatterndb/floatItemData/vpiecelabeldata.h index 5831c2626..978417174 100644 --- a/src/libs/vpatterndb/floatItemData/vpiecelabeldata.h +++ b/src/libs/vpatterndb/floatItemData/vpiecelabeldata.h @@ -35,6 +35,7 @@ #include "floatitemdef.h" class VPieceLabelDataPrivate; +class VLabelTemplateLine; /** * @brief The VPieceLabelData class holds some information about a single @@ -69,6 +70,15 @@ public: const QString& GetLetter() const; void SetLetter(QString qsLetter); + int GetQuantity() const; + void SetQuantity(int val); + + bool IsOnFold() const; + void SetOnFold(bool onFold); + + QVector GetLabelTemplate() const; + void SetLabelTemplate(const QVector &lines); + private: QSharedDataPointer d; }; diff --git a/src/libs/vpatterndb/floatItemData/vpiecelabeldata_p.h b/src/libs/vpatterndb/floatItemData/vpiecelabeldata_p.h index d2ea60154..22757b4d0 100644 --- a/src/libs/vpatterndb/floatItemData/vpiecelabeldata_p.h +++ b/src/libs/vpatterndb/floatItemData/vpiecelabeldata_p.h @@ -31,9 +31,11 @@ #include #include +#include #include "../vmisc/diagnostic.h" #include "floatitemdef.h" +#include "../ifc/ifcdef.h" QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Weffc++") @@ -44,13 +46,19 @@ class VPieceLabelDataPrivate : public QSharedData public: VPieceLabelDataPrivate() : m_qsLetter(), - m_conMCP() + m_conMCP(), + m_quantity(1), + m_onFold(false), + m_lines() {} VPieceLabelDataPrivate(const VPieceLabelDataPrivate &data) : QSharedData(data), m_qsLetter(data.m_qsLetter), - m_conMCP(data.m_conMCP) + m_conMCP(data.m_conMCP), + m_quantity(data.m_quantity), + m_onFold(data.m_onFold), + m_lines(data.m_lines) {} ~VPieceLabelDataPrivate() Q_DECL_EQ_DEFAULT; @@ -60,6 +68,11 @@ public: /** @brief m_conMCP List of material, cut, placement tuples */ MCPContainer m_conMCP; + int m_quantity; + bool m_onFold; + + QVector m_lines; + private: VPieceLabelDataPrivate &operator=(const VPieceLabelDataPrivate &) Q_DECL_EQ_DELETE; }; diff --git a/src/libs/vpatterndb/vpiece.h b/src/libs/vpatterndb/vpiece.h index 9a2cc340c..3f3c99f94 100644 --- a/src/libs/vpatterndb/vpiece.h +++ b/src/libs/vpatterndb/vpiece.h @@ -104,11 +104,11 @@ public: QVector MissingInternalPaths(const VPiece &det) const; QVector MissingPins(const VPiece &det) const; - void SetPatternPieceData(const VPieceLabelData &data); + void SetPatternPieceData(const VPieceLabelData &data); VPieceLabelData& GetPatternPieceData(); const VPieceLabelData& GetPatternPieceData() const; - void SetPatternInfo(const VPatternLabelData &info); + void SetPatternInfo(const VPatternLabelData &info); VPatternLabelData& GetPatternInfo(); const VPatternLabelData& GetPatternInfo() const; diff --git a/src/libs/vpatterndb/vtranslatevars.cpp b/src/libs/vpatterndb/vtranslatevars.cpp index 4952e0f21..09a8737fc 100644 --- a/src/libs/vpatterndb/vtranslatevars.cpp +++ b/src/libs/vpatterndb/vtranslatevars.cpp @@ -457,18 +457,27 @@ void VTranslateVars::InitPostfixOperators() //--------------------------------------------------------------------------------------------------------------------- void VTranslateVars::InitPlaceholder() { - placeholders.insert(pl_size, translate("VTranslateVars", "size", "placeholder")); - placeholders.insert(pl_height, translate("VTranslateVars", "height", "placeholder")); - placeholders.insert(pl_date, translate("VTranslateVars", "date", "placeholder")); - placeholders.insert(pl_time, translate("VTranslateVars", "time", "placeholder")); - placeholders.insert(pl_patternName, translate("VTranslateVars", "patternName", "placeholder")); + placeholders.insert(pl_size, translate("VTranslateVars", "size", "placeholder")); + placeholders.insert(pl_height, translate("VTranslateVars", "height", "placeholder")); + placeholders.insert(pl_date, translate("VTranslateVars", "date", "placeholder")); + placeholders.insert(pl_time, translate("VTranslateVars", "time", "placeholder")); + placeholders.insert(pl_patternName, translate("VTranslateVars", "patternName", "placeholder")); placeholders.insert(pl_patternNumber, translate("VTranslateVars", "patternNumber", "placeholder")); - placeholders.insert(pl_author, translate("VTranslateVars", "author", "placeholder")); - placeholders.insert(pl_customer, translate("VTranslateVars", "customer", "placeholder")); - placeholders.insert(pl_pExt, translate("VTranslateVars", "pExt", "placeholder")); - placeholders.insert(pl_pFileName, translate("VTranslateVars", "pFileName", "placeholder")); - placeholders.insert(pl_mFileName, translate("VTranslateVars", "mFileName", "placeholder")); - placeholders.insert(pl_mExt, translate("VTranslateVars", "mExt", "placeholder")); + placeholders.insert(pl_author, translate("VTranslateVars", "author", "placeholder")); + placeholders.insert(pl_customer, translate("VTranslateVars", "customer", "placeholder")); + placeholders.insert(pl_pExt, translate("VTranslateVars", "pExt", "placeholder")); + placeholders.insert(pl_pFileName, translate("VTranslateVars", "pFileName", "placeholder")); + placeholders.insert(pl_mFileName, translate("VTranslateVars", "mFileName", "placeholder")); + placeholders.insert(pl_mExt, translate("VTranslateVars", "mExt", "placeholder")); + placeholders.insert(pl_pLetter, translate("VTranslateVars", "pLetter", "placeholder")); + placeholders.insert(pl_pName, translate("VTranslateVars", "pName", "placeholder")); + placeholders.insert(pl_pQuantity, translate("VTranslateVars", "pQuantity", "placeholder")); + placeholders.insert(pl_mFabric, translate("VTranslateVars", "mFabric", "placeholder")); + placeholders.insert(pl_mLining, translate("VTranslateVars", "mLining", "placeholder")); + placeholders.insert(pl_mInterfacing, translate("VTranslateVars", "mInterfacing", "placeholder")); + placeholders.insert(pl_mInterlining, translate("VTranslateVars", "mInterlining", "placeholder")); + placeholders.insert(pl_wCut, translate("VTranslateVars", "wCut", "placeholder")); + placeholders.insert(pl_wOnFold, translate("VTranslateVars", "wOnFold", "placeholder")); } #undef translate diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp index 75f67227c..3149b9f1f 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp @@ -34,6 +34,8 @@ #include "../ifc/xml/vabstractpattern.h" #include "../ifc/exception/vexception.h" #include "../vpatterndb/vcontainer.h" +#include "../vpatterndb/vpiece.h" +#include "../vpatterndb/floatItemData/vpiecelabeldata.h" #include #include @@ -462,6 +464,7 @@ void DialogEditLabel::InitPlaceholdersMenu() //--------------------------------------------------------------------------------------------------------------------- void DialogEditLabel::InitPlaceholders() { + // Pattern tags QLocale locale(qApp->Settings()->GetLocale()); m_placeholders.insert(pl_date, qMakePair(tr("Date"), locale.toString(QDate::currentDate()))); m_placeholders.insert(pl_time, qMakePair(tr("Time"), locale.toString(QTime::currentTime()))); @@ -496,6 +499,17 @@ void DialogEditLabel::InitPlaceholders() m_placeholders.insert(pl_size, qMakePair(tr("Size"), curSize)); m_placeholders.insert(pl_height, qMakePair(tr("Height"), curHeight)); m_placeholders.insert(pl_mExt, qMakePair(tr("Measurments extension"), mExt)); + + // Piece tags + m_placeholders.insert(pl_pLetter, qMakePair(tr("Piece letter"), QString(""))); + m_placeholders.insert(pl_pName, qMakePair(tr("Piece name"), QString(""))); + m_placeholders.insert(pl_pQuantity, qMakePair(tr("Quantity"), QString(""))); + m_placeholders.insert(pl_mFabric, qMakePair(tr("Material: Fabric"), tr("Fabric"))); + m_placeholders.insert(pl_mLining, qMakePair(tr("Material: Lining"), tr("Lining"))); + m_placeholders.insert(pl_mInterfacing, qMakePair(tr("Material: Interfacing"), tr("Interfacing"))); + m_placeholders.insert(pl_mInterlining, qMakePair(tr("Material: Interlining"), tr("Interlining"))); + m_placeholders.insert(pl_wCut, qMakePair(tr("Word: Cut"), tr("Cut"))); + m_placeholders.insert(pl_wOnFold, qMakePair(tr("Word: on fold"), QString("")));// By default should be empty } //--------------------------------------------------------------------------------------------------------------------- @@ -567,6 +581,18 @@ void DialogEditLabel::SetTemplate(const QVector &lines) } } +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditLabel::SetPiece(const VPiece &piece) +{ + m_placeholders[pl_pLetter].second = piece.GetPatternPieceData().GetLetter(); + m_placeholders[pl_pName].second = piece.GetName(); + m_placeholders[pl_pQuantity].second = QString::number(piece.GetPatternPieceData().GetQuantity()); + if (piece.GetPatternPieceData().IsOnFold()) + { + m_placeholders[pl_wOnFold].second = tr("on fold"); + } +} + //--------------------------------------------------------------------------------------------------------------------- void DialogEditLabel::InitPreviewLines(const QVector &lines) { diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.h b/src/libs/vtools/dialogs/support/dialogeditlabel.h index 13800f784..d2df21aa3 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.h +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.h @@ -40,6 +40,7 @@ namespace Ui class VLabelTemplateLine; class QMenu; class VAbstractPattern; +class VPiece; class DialogEditLabel : public QDialog { @@ -52,6 +53,8 @@ public: QVector GetTemplate() const; void SetTemplate(const QVector &lines); + void SetPiece(const VPiece &piece); + private slots: void ShowLineDetails(); void AddLine(); diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index 38074d721..dfd5ce7d6 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -42,6 +42,7 @@ #include "dialogpiecepath.h" #include "../../../undocommands/savepiecepathoptions.h" #include "../../support/dialogeditwrongformula.h" +#include "../../support/dialogeditlabel.h" #include "../../../tools/vtoolseamallowance.h" #include @@ -123,7 +124,8 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 & m_timerWidth(nullptr), m_timerWidthBefore(nullptr), m_timerWidthAfter(nullptr), - m_saWidth(0) + m_saWidth(0), + m_templateLines() { ui->setupUi(this); @@ -246,6 +248,9 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece) m_my = piece.GetMy(); uiTabLabels->lineEditLetter->setText(piece.GetPatternPieceData().GetLetter()); + uiTabLabels->spinBoxQuantity->setValue(piece.GetPatternPieceData().GetQuantity()); + uiTabLabels->checkBoxFold->setChecked(piece.GetPatternPieceData().IsOnFold()); + m_templateLines = piece.GetPatternPieceData().GetLabelTemplate(); m_conMCP.clear(); for (int i = 0; i < piece.GetPatternPieceData().GetMCPCount(); ++i) @@ -2099,6 +2104,19 @@ void DialogSeamAllowance::PatternPinPointChanged() CheckState(); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogSeamAllowance::EditLabel() +{ + DialogEditLabel editor(qApp->getCurrentDocument()); + editor.SetTemplate(m_templateLines); + editor.SetPiece(GetPiece()); + + if (QDialog::Accepted == editor.exec()) + { + m_templateLines = editor.GetTemplate(); + } +} + //--------------------------------------------------------------------------------------------------------------------- VPiece DialogSeamAllowance::CreatePiece() const { @@ -2116,6 +2134,9 @@ VPiece DialogSeamAllowance::CreatePiece() const piece.SetMy(m_my); piece.SetFormulaSAWidth(GetFormulaFromUser(uiTabPaths->plainTextEditFormulaWidth), m_saWidth); piece.GetPatternPieceData().SetLetter(uiTabLabels->lineEditLetter->text()); + piece.GetPatternPieceData().SetQuantity(uiTabLabels->spinBoxQuantity->value()); + piece.GetPatternPieceData().SetOnFold(uiTabLabels->checkBoxFold->isChecked()); + piece.GetPatternPieceData().SetLabelTemplate(m_templateLines); for (int i = 0; i < m_conMCP.count(); ++i) { @@ -2673,6 +2694,7 @@ void DialogSeamAllowance::InitPatternPieceDataTab() connect(uiTabLabels->pushButtonRemove, &QPushButton::clicked, this, &DialogSeamAllowance::Remove); connect(uiTabLabels->listWidgetMCP, &QListWidget::itemClicked, this, &DialogSeamAllowance::SetEditMode); connect(uiTabLabels->comboBoxMaterial, &QComboBox::currentTextChanged, this, &DialogSeamAllowance::MaterialChanged); + connect(uiTabLabels->pushButtonEditPieceLabel, &QPushButton::clicked, this, &DialogSeamAllowance::EditLabel); SetAddMode(); } diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h index 570511782..ed89ee6da 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h @@ -156,6 +156,8 @@ private slots: void DetailPinPointChanged(); void PatternPinPointChanged(); + void EditLabel(); + private: Q_DISABLE_COPY(DialogSeamAllowance) @@ -215,6 +217,8 @@ private: QTimer *m_timerWidthAfter; qreal m_saWidth; + QVector m_templateLines; + VPiece CreatePiece() const; void NewMainPathItem(const VPieceNode &node); diff --git a/src/libs/vtools/dialogs/tools/piece/tabs/tablabels.ui b/src/libs/vtools/dialogs/tools/piece/tabs/tablabels.ui index 543012c83..a44f5c0ec 100644 --- a/src/libs/vtools/dialogs/tools/piece/tabs/tablabels.ui +++ b/src/libs/vtools/dialogs/tools/piece/tabs/tablabels.ui @@ -6,8 +6,8 @@ 0 0 - 566 - 596 + 579 + 500 @@ -28,8 +28,8 @@ 0 0 - 546 - 576 + 559 + 480 @@ -43,6 +43,123 @@ Piece label data + + + + + + Label template: + + + + + + + Edit pattern label + + + Edit template + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Label data + + + + QFormLayout::ExpandingFieldsGrow + + + + + Letter: + + + + + + + 3 + + + Letter of pattern piece + + + + + + + Name of detail: + + + + + + + Detail + + + 30 + + + Name can't be empty + + + + + + + Quantity: + + + + + + + 1 + + + 9999 + + + 1 + + + + + + + Placement: + + + + + + + on fold + + + + + + @@ -50,50 +167,6 @@ - - - - QFormLayout::ExpandingFieldsGrow - - - - - Letter: - - - - - - - 3 - - - Letter of pattern piece - - - - - - - Name of detail: - - - - - - - Detail - - - 30 - - - Name can't be empty - - - - -