Extend list of placeholders.

Added customer email and birth date, all dimensions.
This commit is contained in:
Roman Telezhynskyi 2020-10-16 11:37:49 +03:00
parent 0eaf15f09d
commit 1b2343e537
10 changed files with 176 additions and 73 deletions

View File

@ -14,7 +14,7 @@
<string notr="true"/>
</property>
<property name="windowIcon">
<iconset resource="share/resources/tapeicon.qrc">
<iconset>
<normaloff>:/tapeicon/64x64/logo.png</normaloff>:/tapeicon/64x64/logo.png</iconset>
</property>
<widget class="QWidget" name="centralWidget">
@ -47,11 +47,11 @@
<string/>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tabMeasurements">
<attribute name="icon">
<iconset resource="share/resources/tapeicon.qrc">
<iconset>
<normaloff>:/tapeicon/16x16/measurement.png</normaloff>:/tapeicon/16x16/measurement.png</iconset>
</attribute>
<attribute name="title">
@ -457,7 +457,7 @@
<string notr="true">...</string>
</property>
<property name="icon">
<iconset resource="share/resources/tapeicon.qrc">
<iconset>
<normaloff>:/tapeicon/24x24/fx.png</normaloff>:/tapeicon/24x24/fx.png</iconset>
</property>
<property name="iconSize">
@ -649,7 +649,7 @@
</widget>
<widget class="QWidget" name="tabInformation">
<attribute name="icon">
<iconset resource="share/resources/tapeicon.qrc">
<iconset>
<normaloff>:/tapeicon/16x16/info.png</normaloff>:/tapeicon/16x16/info.png</iconset>
</attribute>
<attribute name="title">
@ -1209,7 +1209,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="share/resources/tapeicon.qrc">
<iconset>
<normaloff>:/tapeicon/24x24/red_plus.png</normaloff>:/tapeicon/24x24/red_plus.png</iconset>
</property>
<property name="text">
@ -1224,7 +1224,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="share/resources/tapeicon.qrc">
<iconset>
<normaloff>:/tapeicon/24x24/orange_plus.png</normaloff>:/tapeicon/24x24/orange_plus.png</iconset>
</property>
<property name="text">
@ -1242,7 +1242,7 @@
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="share/resources/tapeicon.qrc">
<iconset>
<normaloff>:/tapeicon/24x24/padlock_opened.png</normaloff>:/tapeicon/24x24/padlock_opened.png</iconset>
</property>
<property name="text">
@ -1350,7 +1350,7 @@
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="share/resources/tapeicon.qrc">
<iconset>
<normaloff>:/tapeicon/24x24/mannequin.png</normaloff>:/tapeicon/24x24/mannequin.png</iconset>
</property>
<property name="text">
@ -1433,9 +1433,7 @@
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="share/resources/tapeicon.qrc"/>
</resources>
<resources/>
<connections>
<connection>
<sender>actionMeasurementDiagram</sender>

View File

@ -71,6 +71,8 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat
setWindowFlags(Qt::Window);
#endif
ui->lineEditCustomerEmail->setClearButtonEnabled(true);
SCASSERT(doc != nullptr)
VSettings *settings = qApp->ValentinaSettings();
@ -157,21 +159,29 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat
ui->lineEditPatternNumber->setText(doc->GetPatternNumber());
ui->lineEditCompanyName->setText(doc->GetCompanyName());
ui->lineEditCustomerName->setText(qApp->GetCustomerName());
ui->lineEditCustomerEmail->setText(qApp->CustomerEmail());
ui->dateEditCustomerBirthDate->setDate(qApp->GetCustomerBirthDate());
if (qApp->GetMeasurementsType() == MeasurementsType::Individual)
{
ui->lineEditCustomerName->setText(qApp->GetCustomerName());
ui->lineEditCustomerName->setReadOnly(true);
ui->lineEditCustomerName->setToolTip(tr("The customer name from individual measurements"));
}
else
{
ui->lineEditCustomerName->setText(doc->GetCustomerName());
ui->lineEditCustomerEmail->setReadOnly(true);
ui->lineEditCustomerEmail->setToolTip(tr("The customer email from individual measurements"));
ui->dateEditCustomerBirthDate->setReadOnly(true);
ui->dateEditCustomerBirthDate->setToolTip(tr("The customer birth date from individual measurements"));
}
connect(ui->lineEditPatternName, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged);
connect(ui->lineEditPatternNumber, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged);
connect(ui->lineEditCompanyName, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged);
connect(ui->lineEditCustomerName, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged);
connect(ui->lineEditCustomerEmail, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged);
connect(ui->dateEditCustomerBirthDate, &QDateEdit::editingFinished, this,
&DialogPatternProperties::LabelDataChanged);
connect(ui->pushButtonEditPatternLabel, &QPushButton::clicked, this, &DialogPatternProperties::EditLabel);
connect(ui->pushButtonPatternMaterials, &QPushButton::clicked, this,
&DialogPatternProperties::ManagePatternMaterials);
@ -286,6 +296,8 @@ void DialogPatternProperties::SaveLabelData()
if (qApp->GetMeasurementsType() != MeasurementsType::Individual)
{
doc->SetCustomerName(ui->lineEditCustomerName->text());
doc->SetCustomerBirthDate(ui->dateEditCustomerBirthDate->date());
doc->SetCustomerEmail(ui->lineEditCustomerEmail->text());
}
doc->SetLabelDateFormat(ui->comboBoxDateFormat->currentText());
doc->SetLabelTimeFormat(ui->comboBoxTimeFormat->currentText());

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>726</width>
<height>681</height>
<height>507</height>
</rect>
</property>
<property name="windowTitle">
@ -21,7 +21,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@ -357,26 +357,50 @@
</property>
</widget>
</item>
<item row="4" column="0">
<item row="6" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Date format:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="6" column="1">
<widget class="QComboBox" name="comboBoxDateFormat"/>
</item>
<item row="5" column="0">
<item row="7" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Time format:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<item row="7" column="1">
<widget class="QComboBox" name="comboBoxTimeFormat"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Customer birth date:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QDateEdit" name="dateEditCustomerBirthDate">
<property name="displayFormat">
<string>yyyy-MM-dd</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Customer email:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="lineEditCustomerEmail"/>
</item>
</layout>
</widget>
</item>
@ -417,7 +441,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>90</height>
<height>9000</height>
</size>
</property>
</spacer>
@ -487,7 +511,4 @@
</hints>
</connection>
</connections>
<buttongroups>
<buttongroup name="buttonGroup"/>
</buttongroups>
</ui>

View File

@ -21,6 +21,8 @@
<xs:element name="patternNumber" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="company" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="customer" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="birthDate" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="email" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="patternLabel" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>

View File

@ -87,6 +87,8 @@ const QString VAbstractPattern::TagPatternInfo = QStringLiteral("patternInf
const QString VAbstractPattern::TagPatternName = QStringLiteral("patternName");
const QString VAbstractPattern::TagPatternNum = QStringLiteral("patternNumber");
const QString VAbstractPattern::TagCustomerName = QStringLiteral("customer");
const QString VAbstractPattern::TagCustomerBirthDate = QStringLiteral("birthDate");
const QString VAbstractPattern::TagCustomerEmail = QStringLiteral("email");
const QString VAbstractPattern::TagCompanyName = QStringLiteral("company");
const QString VAbstractPattern::TagPatternLabel = QStringLiteral("patternLabel");
const QString VAbstractPattern::TagWatermark = QStringLiteral("watermark");
@ -1000,6 +1002,38 @@ void VAbstractPattern::SetCustomerName(const QString& qsName)
emit patternChanged(false);
}
//---------------------------------------------------------------------------------------------------------------------
QDate VAbstractPattern::GetCustomerBirthDate() const
{
return QDate::fromString(UniqueTagText(TagCustomerBirthDate), "yyyy-MM-dd");
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetCustomerBirthDate(const QDate &date)
{
CheckTagExists(TagCustomerBirthDate);
setTagText(TagCustomerBirthDate, date.toString("yyyy-MM-dd"));
patternLabelWasChanged = true;
modified = true;
emit patternChanged(false);
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractPattern::GetCustomerEmail() const
{
return UniqueTagText(TagCustomerEmail);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetCustomerEmail(const QString &email)
{
CheckTagExists(TagCustomerEmail);
setTagText(TagCustomerEmail, email);
patternLabelWasChanged = true;
modified = true;
emit patternChanged(false);
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractPattern::GetLabelDateFormat() const
{
@ -1351,10 +1385,12 @@ QDomElement VAbstractPattern::CheckTagExists(const QString &tag)
TagPatternNum, // 5
TagCompanyName, // 6
TagCustomerName, // 7
TagPatternLabel, // 8
TagWatermark, // 9
TagPatternMaterials, // 10
TagFinalMeasurements // 11
TagCustomerBirthDate, // 8
TagCustomerEmail, // 9
TagPatternLabel, // 10
TagWatermark, // 11
TagPatternMaterials, // 12
TagFinalMeasurements // 13
};
switch (tags.indexOf(tag))
@ -1380,16 +1416,22 @@ QDomElement VAbstractPattern::CheckTagExists(const QString &tag)
case 7: // TagCustomerName
element = createElement(TagCustomerName);
break;
case 8: // TagPatternLabel
case 8: // TagCustomerBirthDate
element = createElement(TagCustomerBirthDate);
break;
case 9: // TagCustomerEmail
element = createElement(TagCustomerEmail);
break;
case 10: // TagPatternLabel
element = createElement(TagPatternLabel);
break;
case 9: // TagWatermark
case 11: // TagWatermark
element = createElement(TagWatermark);
break;
case 10: // TagPatternMaterials
case 12: // TagPatternMaterials
element = createElement(TagPatternMaterials);
break;
case 11: // TagFinalMeasurements
case 13: // TagFinalMeasurements
element = createElement(TagFinalMeasurements);
break;
case 0: //TagUnit (Mandatory tag)

View File

@ -165,6 +165,12 @@ public:
QString GetCustomerName() const;
void SetCustomerName(const QString& qsName);
QDate GetCustomerBirthDate() const;
void SetCustomerBirthDate(const QDate& date);
QString GetCustomerEmail() const;
void SetCustomerEmail(const QString& email);
QString GetLabelDateFormat() const;
void SetLabelDateFormat(const QString &format);
@ -252,6 +258,8 @@ public:
static const QString TagPatternNum;
static const QString TagCompanyName;
static const QString TagCustomerName;
static const QString TagCustomerBirthDate;
static const QString TagCustomerEmail;
static const QString TagPatternLabel;
static const QString TagWatermark;
static const QString TagPatternMaterials;

View File

@ -185,38 +185,39 @@ QMap<QString, QString> PreparePlaceholders(const VAbstractPattern *doc)
placeholders.insert(pl_patternNumber, doc->GetPatternNumber());
placeholders.insert(pl_author, doc->GetCompanyName());
placeholders.insert(pl_mUnits, UnitsToStr(qApp->MeasurementsUnits(), true));
placeholders.insert(pl_pUnits, UnitsToStr(qApp->patternUnits(), true));
placeholders.insert(pl_mSizeUnits, UnitsToStr(qApp->DimensionSizeUnits(), true));
if (qApp->GetMeasurementsType() == MeasurementsType::Individual)
{
placeholders.insert(pl_customer, qApp->GetCustomerName());
const QString birthDate = locale.toString(qApp->GetCustomerBirthDate(), doc->GetLabelDateFormat());
placeholders.insert(pl_birthDate, birthDate);
placeholders.insert(pl_email, qApp->CustomerEmail());
}
else
{
placeholders.insert(pl_customer, doc->GetCustomerName());
const QString birthDate = locale.toString(doc->GetCustomerBirthDate(), doc->GetLabelDateFormat());
placeholders.insert(pl_birthDate, birthDate);
placeholders.insert(pl_email, doc->GetCustomerEmail());
}
placeholders.insert(pl_pExt, QStringLiteral("val"));
placeholders.insert(pl_pFileName, QFileInfo(qApp->GetPatternPath()).baseName());
placeholders.insert(pl_mFileName, QFileInfo(doc->MPath()).baseName());
QString curSize;
QString curHeight;
QString mExt;
if (qApp->GetMeasurementsType() == MeasurementsType::Multisize)
{
curSize = QString::number(VContainer::size(valentinaNamespace));
curHeight = QString::number(VContainer::height(valentinaNamespace));
mExt = QStringLiteral("vst");
}
else if (qApp->GetMeasurementsType() == MeasurementsType::Individual)
{
curSize = QString::number(VContainer::size(valentinaNamespace));
curHeight = QString::number(VContainer::height(valentinaNamespace));
mExt = QStringLiteral("vit");
}
placeholders.insert(pl_size, curSize);
placeholders.insert(pl_height, curHeight);
placeholders.insert(pl_mExt, mExt);
placeholders.insert(pl_height, QString::number(qApp->GetDimensionHeight()));
placeholders.insert(pl_size, QString::number(qApp->GetDimensionSize()));
placeholders.insert(pl_hip, QString::number(qApp->GetDimensionHip()));
placeholders.insert(pl_waist, QString::number(qApp->GetDimensionWaist()));
placeholders.insert(pl_mExt, qApp->GetMeasurementsType() == MeasurementsType::Multisize ? QString("vst")
: QString("vit"));
const QMap<int, QString> materials = doc->GetPatternMaterials();
for (int i = 0; i < userMaterialPlaceholdersQuantity; ++i)

View File

@ -149,17 +149,24 @@ const QStringList builInFunctions = QStringList() << degTorad_F
const QString pl_size = QStringLiteral("size");
const QString pl_height = QStringLiteral("height");
const QString pl_hip = QStringLiteral("hip");
const QString pl_waist = QStringLiteral("waist");
const QString pl_date = QStringLiteral("date");
const QString pl_time = QStringLiteral("time");
const QString pl_birthDate = QStringLiteral("birthDate");
const QString pl_patternName = QStringLiteral("patternName");
const QString pl_patternNumber = QStringLiteral("patternNumber");
const QString pl_author = QStringLiteral("author");
const QString pl_customer = QStringLiteral("customer");
const QString pl_email = QStringLiteral("email");
const QString pl_userMaterial = QStringLiteral("userMaterial");
const QString pl_pExt = QStringLiteral("pExt");
const QString pl_pUnits = QStringLiteral("pUnits");
const QString pl_pFileName = QStringLiteral("pFileName");
const QString pl_mFileName = QStringLiteral("mFileName");
const QString pl_mExt = QStringLiteral("mExt");
const QString pl_mUnits = QStringLiteral("mUnits");
const QString pl_mSizeUnits = QStringLiteral("mSizeUnits");
const QString pl_pLetter = QStringLiteral("pLetter");
const QString pl_pAnnotation = QStringLiteral("pAnnotation");
const QString pl_pOrientation = QStringLiteral("pOrientation");
@ -639,6 +646,8 @@ QString UnitsToStr(const Unit &unit, const bool translate)
case Unit::Px:
translate ? result = QObject::tr("px") : result = unitPX;
break;
case Unit::LAST_UNIT_DO_NOT_USE:
break;
case Unit::Cm:
default:
translate ? result = QObject::tr("cm") : result = unitCM;

View File

@ -403,17 +403,24 @@ extern const QStringList builInFunctions;
// Placeholders
extern const QString pl_size;
extern const QString pl_height;
extern const QString pl_hip;
extern const QString pl_waist;
extern const QString pl_date;
extern const QString pl_time;
extern const QString pl_birthDate;
extern const QString pl_patternName;
extern const QString pl_patternNumber;
extern const QString pl_author;
extern const QString pl_customer;
extern const QString pl_email;
extern const QString pl_userMaterial;
extern const QString pl_pExt;
extern const QString pl_pUnits;
extern const QString pl_pFileName;
extern const QString pl_mFileName;
extern const QString pl_mExt;
extern const QString pl_mUnits;
extern const QString pl_mSizeUnits;
extern const QString pl_pLetter;
extern const QString pl_pAnnotation;
extern const QString pl_pOrientation;

View File

@ -500,13 +500,27 @@ void DialogEditLabel::InitPlaceholders()
m_placeholders.insert(pl_patternNumber, qMakePair(tr("Pattern number"), m_doc->GetPatternNumber()));
m_placeholders.insert(pl_author, qMakePair(tr("Company name or designer name"), m_doc->GetCompanyName()));
m_placeholders.insert(pl_mUnits, qMakePair(tr("Measurements units"), UnitsToStr(qApp->MeasurementsUnits(), true)));
m_placeholders.insert(pl_pUnits, qMakePair(tr("Pattern units"), UnitsToStr(qApp->patternUnits(), true)));
m_placeholders.insert(pl_mSizeUnits, qMakePair(tr("Size units"), UnitsToStr(qApp->DimensionSizeUnits(), true)));
if (qApp->GetMeasurementsType() == MeasurementsType::Individual)
{
m_placeholders.insert(pl_customer, qMakePair(tr("Customer name"), qApp->GetCustomerName()));
const QString birthDate = locale.toString(qApp->GetCustomerBirthDate(), m_doc->GetLabelDateFormat());
m_placeholders.insert(pl_birthDate, qMakePair(tr("Customer birth date"), birthDate));
m_placeholders.insert(pl_email, qMakePair(tr("Customer email"), qApp->CustomerEmail()));
}
else
{
m_placeholders.insert(pl_customer, qMakePair(tr("Customer name"), m_doc->GetCustomerName()));
const QString birthDate = locale.toString(m_doc->GetCustomerBirthDate(), m_doc->GetLabelDateFormat());
m_placeholders.insert(pl_birthDate, qMakePair(tr("Customer birth date"), birthDate));
m_placeholders.insert(pl_email, qMakePair(tr("Customer email"), m_doc->GetCustomerEmail()));
}
m_placeholders.insert(pl_pExt, qMakePair(tr("Pattern extension"), QString("val")));
@ -517,25 +531,14 @@ void DialogEditLabel::InitPlaceholders()
const QString measurementsFilePath = QFileInfo(m_doc->MPath()).baseName();
m_placeholders.insert(pl_mFileName, qMakePair(tr("Measurments file name"), measurementsFilePath));
QString curSize;
QString curHeight;
QString mExt;
if (qApp->GetMeasurementsType() == MeasurementsType::Multisize)
{
curSize = QString::number(VContainer::size(valentinaNamespace));
curHeight = QString::number(VContainer::height(valentinaNamespace));
mExt = "vst";
}
else if (qApp->GetMeasurementsType() == MeasurementsType::Individual)
{
curSize = QString::number(VContainer::size(valentinaNamespace));
curHeight = QString::number(VContainer::height(valentinaNamespace));
mExt = "vit";
}
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));
m_placeholders.insert(pl_height, qMakePair(tr("Height"), QString::number(qApp->GetDimensionHeight())));
m_placeholders.insert(pl_size, qMakePair(tr("Size"), QString::number(qApp->GetDimensionSize())));
m_placeholders.insert(pl_hip, qMakePair(tr("Hip"), QString::number(qApp->GetDimensionHip())));
m_placeholders.insert(pl_waist, qMakePair(tr("Waist"), QString::number(qApp->GetDimensionWaist())));
m_placeholders.insert(pl_mExt,
qMakePair(tr("Measurments extension"),
qApp->GetMeasurementsType() == MeasurementsType::Multisize ? QString("vst")
: QString("vit")));
const QString materialDescription = tr("User material");
const QMap<int, QString> materials = m_doc->GetPatternMaterials();