Merge with develop.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-09-20 08:53:44 +03:00
commit 795438c202
15 changed files with 230 additions and 107 deletions

View File

@ -110,8 +110,7 @@ TMainWindow::TMainWindow(QWidget *parent)
ui->lineEditFind->setClearButtonEnabled(true);
ui->lineEditName->setClearButtonEnabled(true);
ui->lineEditFullName->setClearButtonEnabled(true);
ui->lineEditGivenName->setClearButtonEnabled(true);
ui->lineEditFamilyName->setClearButtonEnabled(true);
ui->lineEditCustomerName->setClearButtonEnabled(true);
ui->lineEditEmail->setClearButtonEnabled(true);
ui->lineEditFind->installEventFilter(this);
@ -990,21 +989,11 @@ void TMainWindow::OpenAt(QAction *where)
#endif //defined(Q_OS_MAC)
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SaveGivenName()
void TMainWindow::SaveCustomerName()
{
if (m->GivenName() != ui->lineEditGivenName->text())
if (m->Customer() != ui->lineEditCustomerName->text())
{
m->SetGivenName(ui->lineEditGivenName->text());
MeasurementsWasSaved(false);
}
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SaveFamilyName()
{
if (m->FamilyName() != ui->lineEditFamilyName->text())
{
m->SetFamilyName(ui->lineEditFamilyName->text());
m->SetCustomer(ui->lineEditCustomerName->text());
MeasurementsWasSaved(false);
}
}
@ -2019,12 +2008,10 @@ void TMainWindow::InitWindow()
HackWidget(&ui->pushButtonGrow);
// Tab Information
HackWidget(&ui->lineEditGivenName);
HackWidget(&ui->lineEditFamilyName);
HackWidget(&ui->lineEditCustomerName);
HackWidget(&ui->comboBoxGender);
HackWidget(&ui->lineEditEmail);
HackWidget(&ui->labelGivenName);
HackWidget(&ui->labelFamilyName);
HackWidget(&ui->labelCustomerName);
HackWidget(&ui->labelBirthDate);
HackWidget(&ui->dateEditBirthDate);
HackWidget(&ui->labelGender);
@ -2061,8 +2048,7 @@ void TMainWindow::InitWindow()
{
ui->labelMType->setText(tr("Individual measurements"));
ui->lineEditGivenName->setEnabled(true);
ui->lineEditFamilyName->setEnabled(true);
ui->lineEditCustomerName->setEnabled(true);
ui->dateEditBirthDate->setEnabled(true);
ui->comboBoxGender->setEnabled(true);
ui->lineEditEmail->setEnabled(true);
@ -2081,8 +2067,7 @@ void TMainWindow::InitWindow()
HackWidget(&ui->labelBaseHeight);
HackWidget(&ui->labelBaseHeightValue);
ui->lineEditGivenName->setText(m->GivenName());
ui->lineEditFamilyName->setText(m->FamilyName());
ui->lineEditCustomerName->setText(m->Customer());
ui->comboBoxGender->clear();
InitGender(ui->comboBoxGender);
@ -2098,8 +2083,7 @@ void TMainWindow::InitWindow()
ui->lineEditEmail->setText(m->Email());
connect(ui->lineEditGivenName, &QLineEdit::editingFinished, this, &TMainWindow::SaveGivenName);
connect(ui->lineEditFamilyName, &QLineEdit::editingFinished, this, &TMainWindow::SaveFamilyName);
connect(ui->lineEditCustomerName, &QLineEdit::editingFinished, this, &TMainWindow::SaveCustomerName);
connect(ui->lineEditEmail, &QLineEdit::editingFinished, this, &TMainWindow::SaveEmail);
connect(ui->comboBoxGender, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&TMainWindow::SaveGender);

View File

@ -91,8 +91,7 @@ private slots:
void OpenAt(QAction *where);
#endif //defined(Q_OS_MAC)
void SaveGivenName();
void SaveFamilyName();
void SaveCustomerName();
void SaveEmail();
void SaveGender(int index);
void SaveBirthDate(const QDate & date);

View File

@ -682,14 +682,14 @@
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="labelGivenName">
<widget class="QLabel" name="labelCustomerName">
<property name="text">
<string>Given name:</string>
<string>Customer name:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="lineEditGivenName">
<widget class="QLineEdit" name="lineEditCustomerName">
<property name="enabled">
<bool>false</bool>
</property>
@ -705,36 +705,13 @@
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="labelFamilyName">
<property name="text">
<string>Family name:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="lineEditFamilyName">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="placeholderText">
<string>Customer's family name</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="labelBirthDate">
<property name="text">
<string>Birth date:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<item row="6" column="1">
<widget class="QDateEdit" name="dateEditBirthDate">
<property name="enabled">
<bool>false</bool>
@ -769,14 +746,14 @@
</property>
</widget>
</item>
<item row="8" column="0">
<item row="7" column="0">
<widget class="QLabel" name="labelGender">
<property name="text">
<string>Gender:</string>
</property>
</widget>
</item>
<item row="8" column="1">
<item row="7" column="1">
<widget class="QComboBox" name="comboBoxGender">
<property name="enabled">
<bool>false</bool>
@ -795,14 +772,14 @@
</property>
</widget>
</item>
<item row="9" column="0">
<item row="8" column="0">
<widget class="QLabel" name="labelEmail">
<property name="text">
<string>Email:</string>
</property>
</widget>
</item>
<item row="9" column="1">
<item row="8" column="1">
<widget class="QLineEdit" name="lineEditEmail">
<property name="enabled">
<bool>false</bool>
@ -818,14 +795,14 @@
</property>
</widget>
</item>
<item row="10" column="0">
<item row="9" column="0">
<widget class="QLabel" name="labelNotes">
<property name="text">
<string>Notes:</string>
</property>
</widget>
</item>
<item row="10" column="1">
<item row="9" column="1">
<widget class="QPlainTextEdit" name="plainTextEditNotes">
<property name="enabled">
<bool>false</bool>
@ -850,7 +827,7 @@
<x>0</x>
<y>0</y>
<width>835</width>
<height>19</height>
<height>25</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">

View File

@ -180,7 +180,17 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat
ui->lineEditPatternName->setText(doc->GetPatternName());
ui->lineEditPatternNumber->setText(doc->GetPatternNumber());
ui->lineEditCompanyName->setText(doc->GetCompanyName());
if (qApp->patternType() == 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());
}
connect(ui->lineEditPatternName, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged);
connect(ui->lineEditPatternNumber, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged);
@ -601,7 +611,10 @@ void DialogPatternProperties::SaveLabelData()
doc->SetPatternName(ui->lineEditPatternName->text());
doc->SetPatternNumber(ui->lineEditPatternNumber->text());
doc->SetCompanyName(ui->lineEditCompanyName->text());
if (qApp->patternType() != MeasurementsType::Individual)
{
doc->SetCustomerName(ui->lineEditCustomerName->text());
}
doc->SetLabelDateFormat(ui->comboBoxDateFormat->currentText());
doc->SetLabelTimeFormat(ui->comboBoxTimeFormat->currentText());

View File

@ -465,6 +465,10 @@ bool MainWindow::LoadMeasurements(const QString &path)
try
{
qApp->setPatternType(m->Type());
if (m->Type() == MeasurementsType::Individual)
{
qApp->SetCustomerName(m->Customer());
}
ToolBarOption();
pattern->ClearVariables(VarType::Measurement);
m->ReadMeasurements();
@ -520,6 +524,10 @@ bool MainWindow::UpdateMeasurements(const QString &path, int size, int height)
{
pattern->ClearVariables(VarType::Measurement);
m->ReadMeasurements();
if (m->Type() == MeasurementsType::Individual)
{
qApp->SetCustomerName(m->Customer());
}
}
catch (VExceptionEmptyParameter &e)
{

View File

@ -49,6 +49,7 @@
<file>schema/individual_measurements/v0.3.1.xsd</file>
<file>schema/individual_measurements/v0.3.2.xsd</file>
<file>schema/individual_measurements/v0.3.3.xsd</file>
<file>schema/individual_measurements/v0.4.0.xsd</file>
<file>schema/label_template/v1.0.0.xsd</file>
</qresource>
</RCC>

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="vit">
<xs:complexType>
<xs:sequence>
<xs:element name="version" type="formatVersion"/>
<xs:element name="read-only" type="xs:boolean"/>
<xs:element name="notes" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="unit" type="units"/>
<xs:element name="pm_system" type="psCode"/>
<xs:element name="personal">
<xs:complexType>
<xs:sequence>
<xs:element name="customer" type="xs:string"/>
<xs:element name="birth-date" type="xs:date"/>
<xs:element name="gender" type="gender"/>
<xs:element name="email" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="body-measurements">
<xs:complexType>
<xs:sequence>
<xs:element name="m" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="name" type="shortName" use="required"/>
<xs:attribute name="value" type="xs:string" use="required"/>
<xs:attribute name="full_name" type="xs:string"/>
<xs:attribute name="description" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="measurementName">
<xs:selector xpath="body-measurements/m"/>
<xs:field xpath="@name"/>
</xs:unique>
</xs:element>
<xs:simpleType name="shortName">
<xs:restriction base="xs:string">
<xs:pattern value="^([^\p{Nd}\p{Zs}*/&amp;|!&lt;&gt;^\-()+=?:;'\&quot;]){1,1}([^\p{Zs}*/&amp;|!&lt;&gt;^\-()+=?:;\&quot;]){0,}$"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="formatVersion">
<xs:restriction base="xs:string">
<xs:pattern value="^(0|([1-9][0-9]*))\.(0|([1-9][0-9]*))\.(0|([1-9][0-9]*))$"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="units">
<xs:restriction base="xs:string">
<xs:enumeration value="mm"/>
<xs:enumeration value="cm"/>
<xs:enumeration value="inch"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="gender">
<xs:restriction base="xs:string">
<xs:enumeration value="unknown"/>
<xs:enumeration value="male"/>
<xs:enumeration value="female"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="psCode">
<xs:restriction base="xs:string">
<xs:pattern value="^^(([0-9]|[1-4][0-9]|5[0-4])|998)$"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

View File

@ -53,13 +53,19 @@
*/
const QString VVITConverter::MeasurementMinVerStr = QStringLiteral("0.2.0");
const QString VVITConverter::MeasurementMaxVerStr = QStringLiteral("0.3.3");
const QString VVITConverter::CurrentSchema = QStringLiteral("://schema/individual_measurements/v0.3.3.xsd");
const QString VVITConverter::MeasurementMaxVerStr = QStringLiteral("0.4.0");
const QString VVITConverter::CurrentSchema = QStringLiteral("://schema/individual_measurements/v0.4.0.xsd");
//VVITConverter::MeasurementMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
//VVITConverter::MeasurementMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
// The list of all string we use for conversion
// Better to use global variables because repeating QStringLiteral blows up code size
static const QString strTagRead_Only = QStringLiteral("read-only");
static const QString strGivenName = QStringLiteral("given-name");
static const QString strFamilyName = QStringLiteral("family-name");
static const QString strCustomer = QStringLiteral("customer");
static const QString strPersonal = QStringLiteral("personal");
//---------------------------------------------------------------------------------------------------------------------
VVITConverter::VVITConverter(const QString &fileName)
@ -82,6 +88,8 @@ QString VVITConverter::XSDSchema(int ver) const
case (0x000302):
return QStringLiteral("://schema/individual_measurements/v0.3.2.xsd");
case (0x000303):
return QStringLiteral("://schema/individual_measurements/v0.3.3.xsd");
case (0x000400):
return CurrentSchema;
default:
InvalidVersion(ver);
@ -112,6 +120,10 @@ void VVITConverter::ApplyPatches()
ValidateXML(XSDSchema(0x000303), m_convertedFileName);
V_FALLTHROUGH
case (0x000303):
ToV0_4_0();
ValidateXML(XSDSchema(0x000400), m_convertedFileName);
V_FALLTHROUGH
case (0x000400):
break;
default:
InvalidVersion(m_ver);
@ -130,7 +142,7 @@ void VVITConverter::DowngradeToCurrentMaxVersion()
bool VVITConverter::IsReadOnly() const
{
// Check if attribute read-only was not changed in file format
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMaxVer == CONVERTER_VERSION_CHECK(0, 3, 3),
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMaxVer == CONVERTER_VERSION_CHECK(0, 4, 0),
"Check attribute read-only.");
// Possibly in future attribute read-only will change position etc.
@ -299,6 +311,43 @@ void VVITConverter::ConvertMeasurementsToV0_3_3()
}
}
//---------------------------------------------------------------------------------------------------------------------
void VVITConverter::ConverCustomerNameToV0_4_0()
{
// Find root tag
const QDomNodeList personalList = this->elementsByTagName(strPersonal);
if (personalList.isEmpty())
{
return;
}
QDomNode personal = personalList.at(0);
// Given name
QString givenName;
const QDomNodeList givenNameList = this->elementsByTagName(strGivenName);
if (not givenNameList.isEmpty())
{
QDomNode givenNameNode = givenNameList.at(0);
givenName = givenNameNode.toElement().text();
personal.removeChild(givenNameNode);
}
// Family name
QString familyName;
const QDomNodeList familyNameList = this->elementsByTagName(strFamilyName);
if (not familyNameList.isEmpty())
{
QDomNode familyNameNode = familyNameList.at(0);
familyName = familyNameNode.toElement().text();
personal.removeChild(familyNameNode);
}
QDomElement customer = createElement(strCustomer);
customer.appendChild(createTextNode(givenName + QLatin1Char(' ') + familyName));
personal.insertBefore(customer, personal.firstChild());
}
//---------------------------------------------------------------------------------------------------------------------
void VVITConverter::ToV0_3_0()
{
@ -348,3 +397,15 @@ void VVITConverter::ToV0_3_3()
ConvertMeasurementsToV0_3_3();
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VVITConverter::ToV0_4_0()
{
// TODO. Delete if minimal supported version is 0.4.0
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < CONVERTER_VERSION_CHECK(0, 4, 0),
"Time to refactor the code.");
SetVersion(QStringLiteral("0.4.0"));
ConverCustomerNameToV0_4_0();
Save();
}

View File

@ -48,14 +48,8 @@ public:
static const QString MeasurementMaxVerStr;
static const QString CurrentSchema;
// GCC 4.6 doesn't allow constexpr and const together
#if !defined(__INTEL_COMPILER) && !defined(__clang__) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) <= 406
static Q_DECL_CONSTEXPR int MeasurementMinVer = CONVERTER_VERSION_CHECK(0, 2, 0);
static Q_DECL_CONSTEXPR int MeasurementMaxVer = CONVERTER_VERSION_CHECK(0, 3, 3);
#else
static Q_DECL_CONSTEXPR const int MeasurementMinVer = CONVERTER_VERSION_CHECK(0, 2, 0);
static Q_DECL_CONSTEXPR const int MeasurementMaxVer = CONVERTER_VERSION_CHECK(0, 3, 3);
#endif
static Q_DECL_CONSTEXPR const int MeasurementMaxVer = CONVERTER_VERSION_CHECK(0, 4, 0);
protected:
virtual int MinVer() const Q_DECL_OVERRIDE;
@ -80,11 +74,13 @@ private:
void GenderV0_3_1();
void PM_SystemV0_3_2();
void ConvertMeasurementsToV0_3_3();
void ConverCustomerNameToV0_4_0();
void ToV0_3_0();
void ToV0_3_1();
void ToV0_3_2();
void ToV0_3_3();
void ToV0_4_0();
};
//---------------------------------------------------------------------------------------------------------------------

View File

@ -62,8 +62,7 @@ const QString VMeasurements::TagNotes = QStringLiteral("notes");
const QString VMeasurements::TagSize = QStringLiteral("size");
const QString VMeasurements::TagHeight = QStringLiteral("height");
const QString VMeasurements::TagPersonal = QStringLiteral("personal");
const QString VMeasurements::TagFamilyName = QStringLiteral("family-name");
const QString VMeasurements::TagGivenName = QStringLiteral("given-name");
const QString VMeasurements::TagCustomer = QStringLiteral("customer");
const QString VMeasurements::TagBirthDate = QStringLiteral("birth-date");
const QString VMeasurements::TagGender = QStringLiteral("gender");
const QString VMeasurements::TagPMSystem = QStringLiteral("pm_system");
@ -402,32 +401,17 @@ void VMeasurements::SetNotes(const QString &text)
}
//---------------------------------------------------------------------------------------------------------------------
QString VMeasurements::FamilyName() const
QString VMeasurements::Customer() const
{
return UniqueTagText(TagFamilyName, "");
return UniqueTagText(TagCustomer, "");
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurements::SetFamilyName(const QString &text)
void VMeasurements::SetCustomer(const QString &text)
{
if (not IsReadOnly())
{
setTagText(TagFamilyName, text);
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VMeasurements::GivenName() const
{
return UniqueTagText(TagGivenName, "");
}
//---------------------------------------------------------------------------------------------------------------------
void VMeasurements::SetGivenName(const QString &text)
{
if (not IsReadOnly())
{
setTagText(TagGivenName, text);
setTagText(TagCustomer, text);
}
}
@ -786,8 +770,7 @@ void VMeasurements::CreateEmptyIndividualFile(Unit unit)
mElement.appendChild(system);
QDomElement personal = createElement(TagPersonal);
personal.appendChild(createElement(TagFamilyName));
personal.appendChild(createElement(TagGivenName));
personal.appendChild(createElement(TagCustomer));
QDomElement date = createElement(TagBirthDate);
date.appendChild(createTextNode(defBirthDate));

View File

@ -72,11 +72,8 @@ public:
QString Notes() const;
void SetNotes(const QString &text);
QString FamilyName() const;
void SetFamilyName(const QString &text);
QString GivenName() const;
void SetGivenName(const QString &text);
QString Customer() const;
void SetCustomer(const QString &text);
QDate BirthDate() const;
void SetBirthDate(const QDate &date);
@ -111,8 +108,7 @@ public:
static const QString TagSize;
static const QString TagHeight;
static const QString TagPersonal;
static const QString TagFamilyName;
static const QString TagGivenName;
static const QString TagCustomer;
static const QString TagBirthDate;
static const QString TagGender;
static const QString TagPMSystem;

View File

@ -77,7 +77,16 @@ QMap<QString, QString> PreparePlaceholders(const VAbstractPattern *doc)
placeholders.insert(pl_patternName, doc->GetPatternName());
placeholders.insert(pl_patternNumber, doc->GetPatternNumber());
placeholders.insert(pl_author, doc->GetCompanyName());
if (qApp->patternType() == MeasurementsType::Individual)
{
placeholders.insert(pl_customer, qApp->GetCustomerName());
}
else
{
placeholders.insert(pl_customer, doc->GetCustomerName());
}
placeholders.insert(pl_pExt, QString("val"));
placeholders.insert(pl_pFileName, QFileInfo(qApp->GetPPath()).baseName());
placeholders.insert(pl_mFileName, QFileInfo(doc->MPath()).baseName());

View File

@ -58,6 +58,7 @@ VAbstractApplication::VAbstractApplication(int &argc, char **argv)
currentScene(nullptr),
sceneView(nullptr),
doc(nullptr),
m_customerName(),
openingPattern(false)
{
QString rules;

View File

@ -77,6 +77,9 @@ public:
MeasurementsType patternType() const;
void setPatternType(const MeasurementsType &patternType);
QString GetCustomerName() const;
void SetCustomerName(const QString &name);
virtual void OpenSettings()=0;
VCommonSettings *Settings();
@ -140,6 +143,7 @@ private:
VMainGraphicsView *sceneView;
VAbstractPattern *doc;
QString m_customerName;
/**
* @brief openingPattern true when we opening pattern. If something will be wrong in formula this help understand if
@ -150,6 +154,18 @@ private:
void ClearTranslation();
};
//---------------------------------------------------------------------------------------------------------------------
inline QString VAbstractApplication::GetCustomerName() const
{
return m_customerName;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VAbstractApplication::SetCustomerName(const QString &name)
{
m_customerName = name;
}
//---------------------------------------------------------------------------------------------------------------------
inline QString VAbstractApplication::GetPPath() const
{

View File

@ -457,9 +457,17 @@ void DialogEditLabel::InitPlaceholders()
m_placeholders.insert(pl_patternName, qMakePair(tr("Pattern name"), m_doc->GetPatternName()));
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_author, qMakePair(tr("Company name or designer name"), m_doc->GetCompanyName()));
if (qApp->patternType() == MeasurementsType::Individual)
{
m_placeholders.insert(pl_customer, qMakePair(tr("Customer name"), qApp->GetCustomerName()));
}
else
{
m_placeholders.insert(pl_customer, qMakePair(tr("Customer name"), m_doc->GetCustomerName()));
}
m_placeholders.insert(pl_pExt, qMakePair(tr("Pattern extension"), QString("val")));
const QString patternFilePath = QFileInfo(qApp->GetPPath()).baseName();