UI changes for piece label.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-08-17 19:18:03 +03:00
parent 6d967cddf8
commit 09c67a099a
12 changed files with 291 additions and 65 deletions

View File

@ -121,6 +121,15 @@ const QString pl_pExt = QStringLiteral("pExt");
const QString pl_pFileName = QStringLiteral("pFileName"); const QString pl_pFileName = QStringLiteral("pFileName");
const QString pl_mFileName = QStringLiteral("mFileName"); const QString pl_mFileName = QStringLiteral("mFileName");
const QString pl_mExt = QStringLiteral("mExt"); 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 const QStringList labelTemplatePlaceholders = QStringList() << pl_size
<< pl_height << pl_height
@ -133,7 +142,16 @@ const QStringList labelTemplatePlaceholders = QStringList() << pl_size
<< pl_pExt << pl_pExt
<< pl_pFileName << pl_pFileName
<< pl_mFileName << 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 cursorArrowOpenHand = QStringLiteral("://cursor/cursor-arrow-openhand.png");
const QString cursorArrowCloseHand = QStringLiteral("://cursor/cursor-arrow-closehand.png"); const QString cursorArrowCloseHand = QStringLiteral("://cursor/cursor-arrow-closehand.png");

View File

@ -363,6 +363,15 @@ extern const QString pl_pExt;
extern const QString pl_pFileName; extern const QString pl_pFileName;
extern const QString pl_mFileName; extern const QString pl_mFileName;
extern const QString pl_mExt; 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; extern const QStringList labelTemplatePlaceholders;

View File

@ -121,3 +121,42 @@ void VPieceLabelData::SetLetter(QString qsLetter)
{ {
d->m_qsLetter = qsLetter.left(3); 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<VLabelTemplateLine> VPieceLabelData::GetLabelTemplate() const
{
return d->m_lines;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::SetLabelTemplate(const QVector<VLabelTemplateLine> &lines)
{
d->m_lines = lines;
}

View File

@ -35,6 +35,7 @@
#include "floatitemdef.h" #include "floatitemdef.h"
class VPieceLabelDataPrivate; class VPieceLabelDataPrivate;
class VLabelTemplateLine;
/** /**
* @brief The VPieceLabelData class holds some information about a single * @brief The VPieceLabelData class holds some information about a single
@ -69,6 +70,15 @@ public:
const QString& GetLetter() const; const QString& GetLetter() const;
void SetLetter(QString qsLetter); void SetLetter(QString qsLetter);
int GetQuantity() const;
void SetQuantity(int val);
bool IsOnFold() const;
void SetOnFold(bool onFold);
QVector<VLabelTemplateLine> GetLabelTemplate() const;
void SetLabelTemplate(const QVector<VLabelTemplateLine> &lines);
private: private:
QSharedDataPointer<VPieceLabelDataPrivate> d; QSharedDataPointer<VPieceLabelDataPrivate> d;
}; };

View File

@ -31,9 +31,11 @@
#include <QSharedData> #include <QSharedData>
#include <QString> #include <QString>
#include <QVector>
#include "../vmisc/diagnostic.h" #include "../vmisc/diagnostic.h"
#include "floatitemdef.h" #include "floatitemdef.h"
#include "../ifc/ifcdef.h"
QT_WARNING_PUSH QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Weffc++") QT_WARNING_DISABLE_GCC("-Weffc++")
@ -44,13 +46,19 @@ class VPieceLabelDataPrivate : public QSharedData
public: public:
VPieceLabelDataPrivate() VPieceLabelDataPrivate()
: m_qsLetter(), : m_qsLetter(),
m_conMCP() m_conMCP(),
m_quantity(1),
m_onFold(false),
m_lines()
{} {}
VPieceLabelDataPrivate(const VPieceLabelDataPrivate &data) VPieceLabelDataPrivate(const VPieceLabelDataPrivate &data)
: QSharedData(data), : QSharedData(data),
m_qsLetter(data.m_qsLetter), 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; ~VPieceLabelDataPrivate() Q_DECL_EQ_DEFAULT;
@ -60,6 +68,11 @@ public:
/** @brief m_conMCP List of material, cut, placement tuples */ /** @brief m_conMCP List of material, cut, placement tuples */
MCPContainer m_conMCP; MCPContainer m_conMCP;
int m_quantity;
bool m_onFold;
QVector<VLabelTemplateLine> m_lines;
private: private:
VPieceLabelDataPrivate &operator=(const VPieceLabelDataPrivate &) Q_DECL_EQ_DELETE; VPieceLabelDataPrivate &operator=(const VPieceLabelDataPrivate &) Q_DECL_EQ_DELETE;
}; };

View File

@ -469,6 +469,15 @@ void VTranslateVars::InitPlaceholder()
placeholders.insert(pl_pFileName, translate("VTranslateVars", "pFileName", "placeholder")); placeholders.insert(pl_pFileName, translate("VTranslateVars", "pFileName", "placeholder"));
placeholders.insert(pl_mFileName, translate("VTranslateVars", "mFileName", "placeholder")); placeholders.insert(pl_mFileName, translate("VTranslateVars", "mFileName", "placeholder"));
placeholders.insert(pl_mExt, translate("VTranslateVars", "mExt", "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 #undef translate

View File

@ -34,6 +34,8 @@
#include "../ifc/xml/vabstractpattern.h" #include "../ifc/xml/vabstractpattern.h"
#include "../ifc/exception/vexception.h" #include "../ifc/exception/vexception.h"
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vpiece.h"
#include "../vpatterndb/floatItemData/vpiecelabeldata.h"
#include <QDir> #include <QDir>
#include <QMessageBox> #include <QMessageBox>
@ -462,6 +464,7 @@ void DialogEditLabel::InitPlaceholdersMenu()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogEditLabel::InitPlaceholders() void DialogEditLabel::InitPlaceholders()
{ {
// Pattern tags
QLocale locale(qApp->Settings()->GetLocale()); QLocale locale(qApp->Settings()->GetLocale());
m_placeholders.insert(pl_date, qMakePair(tr("Date"), locale.toString(QDate::currentDate()))); m_placeholders.insert(pl_date, qMakePair(tr("Date"), locale.toString(QDate::currentDate())));
m_placeholders.insert(pl_time, qMakePair(tr("Time"), locale.toString(QTime::currentTime()))); 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_size, qMakePair(tr("Size"), curSize));
m_placeholders.insert(pl_height, qMakePair(tr("Height"), curHeight)); m_placeholders.insert(pl_height, qMakePair(tr("Height"), curHeight));
m_placeholders.insert(pl_mExt, qMakePair(tr("Measurments extension"), mExt)); 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<VLabelTemplateLine> &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<VLabelTemplateLine> &lines) void DialogEditLabel::InitPreviewLines(const QVector<VLabelTemplateLine> &lines)
{ {

View File

@ -40,6 +40,7 @@ namespace Ui
class VLabelTemplateLine; class VLabelTemplateLine;
class QMenu; class QMenu;
class VAbstractPattern; class VAbstractPattern;
class VPiece;
class DialogEditLabel : public QDialog class DialogEditLabel : public QDialog
{ {
@ -52,6 +53,8 @@ public:
QVector<VLabelTemplateLine> GetTemplate() const; QVector<VLabelTemplateLine> GetTemplate() const;
void SetTemplate(const QVector<VLabelTemplateLine> &lines); void SetTemplate(const QVector<VLabelTemplateLine> &lines);
void SetPiece(const VPiece &piece);
private slots: private slots:
void ShowLineDetails(); void ShowLineDetails();
void AddLine(); void AddLine();

View File

@ -42,6 +42,7 @@
#include "dialogpiecepath.h" #include "dialogpiecepath.h"
#include "../../../undocommands/savepiecepathoptions.h" #include "../../../undocommands/savepiecepathoptions.h"
#include "../../support/dialogeditwrongformula.h" #include "../../support/dialogeditwrongformula.h"
#include "../../support/dialogeditlabel.h"
#include "../../../tools/vtoolseamallowance.h" #include "../../../tools/vtoolseamallowance.h"
#include <QMenu> #include <QMenu>
@ -123,7 +124,8 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 &
m_timerWidth(nullptr), m_timerWidth(nullptr),
m_timerWidthBefore(nullptr), m_timerWidthBefore(nullptr),
m_timerWidthAfter(nullptr), m_timerWidthAfter(nullptr),
m_saWidth(0) m_saWidth(0),
m_templateLines()
{ {
ui->setupUi(this); ui->setupUi(this);
@ -246,6 +248,9 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece)
m_my = piece.GetMy(); m_my = piece.GetMy();
uiTabLabels->lineEditLetter->setText(piece.GetPatternPieceData().GetLetter()); 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(); m_conMCP.clear();
for (int i = 0; i < piece.GetPatternPieceData().GetMCPCount(); ++i) for (int i = 0; i < piece.GetPatternPieceData().GetMCPCount(); ++i)
@ -2099,6 +2104,19 @@ void DialogSeamAllowance::PatternPinPointChanged()
CheckState(); 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 VPiece DialogSeamAllowance::CreatePiece() const
{ {
@ -2116,6 +2134,9 @@ VPiece DialogSeamAllowance::CreatePiece() const
piece.SetMy(m_my); piece.SetMy(m_my);
piece.SetFormulaSAWidth(GetFormulaFromUser(uiTabPaths->plainTextEditFormulaWidth), m_saWidth); piece.SetFormulaSAWidth(GetFormulaFromUser(uiTabPaths->plainTextEditFormulaWidth), m_saWidth);
piece.GetPatternPieceData().SetLetter(uiTabLabels->lineEditLetter->text()); 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) 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->pushButtonRemove, &QPushButton::clicked, this, &DialogSeamAllowance::Remove);
connect(uiTabLabels->listWidgetMCP, &QListWidget::itemClicked, this, &DialogSeamAllowance::SetEditMode); connect(uiTabLabels->listWidgetMCP, &QListWidget::itemClicked, this, &DialogSeamAllowance::SetEditMode);
connect(uiTabLabels->comboBoxMaterial, &QComboBox::currentTextChanged, this, &DialogSeamAllowance::MaterialChanged); connect(uiTabLabels->comboBoxMaterial, &QComboBox::currentTextChanged, this, &DialogSeamAllowance::MaterialChanged);
connect(uiTabLabels->pushButtonEditPieceLabel, &QPushButton::clicked, this, &DialogSeamAllowance::EditLabel);
SetAddMode(); SetAddMode();
} }

View File

@ -156,6 +156,8 @@ private slots:
void DetailPinPointChanged(); void DetailPinPointChanged();
void PatternPinPointChanged(); void PatternPinPointChanged();
void EditLabel();
private: private:
Q_DISABLE_COPY(DialogSeamAllowance) Q_DISABLE_COPY(DialogSeamAllowance)
@ -215,6 +217,8 @@ private:
QTimer *m_timerWidthAfter; QTimer *m_timerWidthAfter;
qreal m_saWidth; qreal m_saWidth;
QVector<VLabelTemplateLine> m_templateLines;
VPiece CreatePiece() const; VPiece CreatePiece() const;
void NewMainPathItem(const VPieceNode &node); void NewMainPathItem(const VPieceNode &node);

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>566</width> <width>579</width>
<height>596</height> <height>500</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -28,8 +28,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>546</width> <width>559</width>
<height>576</height> <height>480</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
@ -44,14 +44,45 @@
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="QSplitter" name="splitter"> <layout class="QHBoxLayout" name="horizontalLayout_30">
<item>
<widget class="QLabel" name="label_13">
<property name="text">
<string>Label template:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonEditPieceLabel">
<property name="toolTip">
<string>Edit pattern label</string>
</property>
<property name="text">
<string>Edit template</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<widget class="QWidget" name="layoutWidget1"> <property name="sizeHint" stdset="0">
<layout class="QVBoxLayout" name="verticalLayout_7"> <size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item> <item>
<layout class="QFormLayout" name="formLayout_3"> <widget class="QGroupBox" name="groupBoxLabelData">
<property name="title">
<string>Label data</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy"> <property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum> <enum>QFormLayout::ExpandingFieldsGrow</enum>
</property> </property>
@ -92,8 +123,50 @@
</property> </property>
</widget> </widget>
</item> </item>
</layout> <item row="2" column="0">
<widget class="QLabel" name="labelQuantity">
<property name="text">
<string>Quantity:</string>
</property>
</widget>
</item> </item>
<item row="2" column="1">
<widget class="QSpinBox" name="spinBoxQuantity">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Placement:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="checkBoxFold">
<property name="text">
<string>on fold</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QWidget" name="layoutWidget1">
<layout class="QVBoxLayout" name="verticalLayout_7">
<item> <item>
<widget class="QGroupBox" name="groupBox_2"> <widget class="QGroupBox" name="groupBox_2">
<property name="title"> <property name="title">