Added general info parameters to VPattern and updated pattern properties dialog accordingly

--HG--
branch : feature
This commit is contained in:
BojanKverh 2016-06-26 16:49:51 +02:00
parent e68fa3a0f3
commit 065621f8c2
5 changed files with 250 additions and 2 deletions

View File

@ -55,6 +55,7 @@ DialogPatternProperties::DialogPatternProperties(const QString &filePath, VPatte
gradationChanged(false), gradationChanged(false),
defaultChanged(false), defaultChanged(false),
securityChanged(false), securityChanged(false),
generalInfoChanged(false),
deleteAction(nullptr), deleteAction(nullptr),
changeImageAction(nullptr), changeImageAction(nullptr),
saveImageAction(nullptr), saveImageAction(nullptr),
@ -159,6 +160,17 @@ DialogPatternProperties::DialogPatternProperties(const QString &filePath, VPatte
gradationChanged = false; gradationChanged = false;
defaultChanged = false; defaultChanged = false;
securityChanged = false; securityChanged = false;
ui->lineEditPatternName->setText(doc->GetPatternName());
ui->lineEditPatternNumber->setText(doc->GetPatternNumber());
ui->lineEditCompanyName->setText(doc->GetCompanyName());
ui->lineEditCustomerName->setText(doc->GetCustomerName());
ui->labelCreationDate->setText(doc->GetCreationDate().toString(Qt::SystemLocaleLongDate));
connect(ui->lineEditPatternName, &QLineEdit::editingFinished, this, &DialogPatternProperties::GeneralInfoChanged);
connect(ui->lineEditPatternNumber, &QLineEdit::editingFinished, this, &DialogPatternProperties::GeneralInfoChanged);
connect(ui->lineEditCompanyName, &QLineEdit::editingFinished, this, &DialogPatternProperties::GeneralInfoChanged);
connect(ui->lineEditCustomerName, &QLineEdit::editingFinished, this, &DialogPatternProperties::GeneralInfoChanged);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -189,6 +201,12 @@ void DialogPatternProperties::Apply()
securityChanged = false; securityChanged = false;
emit doc->patternChanged(false); emit doc->patternChanged(false);
break; break;
case 3:
SaveGeneralInfo();
generalInfoChanged = false;
emit doc->patternChanged(false);
break;
default: default:
break; break;
} }
@ -225,6 +243,13 @@ void DialogPatternProperties::Ok()
emit doc->patternChanged(false); emit doc->patternChanged(false);
} }
if (generalInfoChanged == true)
{
SaveGeneralInfo();
generalInfoChanged = false;
emit doc->patternChanged(false);
}
close(); close();
} }
@ -378,6 +403,12 @@ void DialogPatternProperties::SecurityValueChanged()
securityChanged = true; securityChanged = true;
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::GeneralInfoChanged()
{
generalInfoChanged = true;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::SetHeightsChecked(bool enabled) void DialogPatternProperties::SetHeightsChecked(bool enabled)
{ {
@ -514,6 +545,15 @@ void DialogPatternProperties::SaveDefValues()
defaultChanged = false; defaultChanged = false;
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::SaveGeneralInfo()
{
doc->SetPatternName(ui->lineEditPatternName->text());
doc->SetPatternNumber(ui->lineEditPatternNumber->text());
doc->SetCompanyName(ui->lineEditCompanyName->text());
doc->SetCustomerName(ui->lineEditCustomerName->text());
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::SetDefaultHeight(const QString &def) void DialogPatternProperties::SetDefaultHeight(const QString &def)
{ {

View File

@ -64,6 +64,7 @@ private slots:
void ToggleComboBox(); void ToggleComboBox();
void DefValueChanged(); void DefValueChanged();
void SecurityValueChanged(); void SecurityValueChanged();
void GeneralInfoChanged();
void DeleteImage(); void DeleteImage();
void SaveImage(); void SaveImage();
void ShowImage(); void ShowImage();
@ -81,6 +82,7 @@ private:
bool gradationChanged; bool gradationChanged;
bool defaultChanged; bool defaultChanged;
bool securityChanged; bool securityChanged;
bool generalInfoChanged;
QAction *deleteAction; QAction *deleteAction;
QAction *changeImageAction; QAction *changeImageAction;
QAction *saveImageAction; QAction *saveImageAction;
@ -101,6 +103,7 @@ private:
void SaveDescription(); void SaveDescription();
void SaveGradation(); void SaveGradation();
void SaveDefValues(); void SaveDefValues();
void SaveGeneralInfo();
void SetDefaultHeight(const QString &def); void SetDefaultHeight(const QString &def);
void SetDefaultSize(const QString &def); void SetDefaultSize(const QString &def);

View File

@ -21,7 +21,7 @@
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>3</number>
</property> </property>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="tab">
<attribute name="title"> <attribute name="title">
@ -1043,6 +1043,80 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>General info</string>
</attribute>
<widget class="QWidget" name="formLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>401</width>
<height>171</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Pattern name:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEditPatternName"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Pattern number:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEditPatternNumber"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Company/Designer name:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEditCompanyName"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Customer name:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="lineEditCustomerName"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Created:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="labelCreationDate">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</widget> </widget>
</item> </item>
<item> <item>

View File

@ -62,6 +62,11 @@ const QString VAbstractPattern::TagSizes = QStringLiteral("sizes");
const QString VAbstractPattern::TagUnit = QStringLiteral("unit"); const QString VAbstractPattern::TagUnit = QStringLiteral("unit");
const QString VAbstractPattern::TagData = QStringLiteral("data"); const QString VAbstractPattern::TagData = QStringLiteral("data");
const QString VAbstractPattern::TagMCP = QStringLiteral("mcp"); const QString VAbstractPattern::TagMCP = QStringLiteral("mcp");
const QString VAbstractPattern::TagPatternName = QStringLiteral("patternName");
const QString VAbstractPattern::TagPatternNum = QStringLiteral("patternNumber");
const QString VAbstractPattern::TagCustomerName = QStringLiteral("customer");
const QString VAbstractPattern::TagCompanyName = QStringLiteral("company");
const QString VAbstractPattern::TagCreationDate = QStringLiteral("created");
const QString VAbstractPattern::AttrName = QStringLiteral("name"); const QString VAbstractPattern::AttrName = QStringLiteral("name");
const QString VAbstractPattern::AttrVisible = QStringLiteral("visible"); const QString VAbstractPattern::AttrVisible = QStringLiteral("visible");
@ -985,6 +990,89 @@ void VAbstractPattern::SetNotes(const QString &text)
emit patternChanged(false); emit patternChanged(false);
} }
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractPattern::GetPatternName() const
{
return UniqueTagText(TagPatternName);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetPatternName(QString qsName)
{
CheckTagExists(TagPatternName);
setTagText(TagPatternName, qsName);
modified = true;
emit patternChanged(false);
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractPattern::GetCompanyName() const
{
return UniqueTagText(TagCompanyName);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetCompanyName(QString qsName)
{
CheckTagExists(TagCompanyName);
setTagText(TagCompanyName, qsName);
modified = true;
emit patternChanged(false);
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractPattern::GetPatternNumber() const
{
return UniqueTagText(TagPatternNum);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetPatternNumber(QString qsNum)
{
CheckTagExists(TagPatternNum);
setTagText(TagPatternNum, qsNum);
modified = true;
emit patternChanged(false);
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractPattern::GetCustomerName() const
{
return UniqueTagText(TagCustomerName);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetCustomerName(QString qsName)
{
CheckTagExists(TagCustomerName);
setTagText(TagCustomerName, qsName);
modified = true;
emit patternChanged(false);
}
//---------------------------------------------------------------------------------------------------------------------
QDate VAbstractPattern::GetCreationDate() const
{
QStringList qsl = UniqueTagText(TagCreationDate).split(".");
if (qsl.count() == 3)
{
bool bDay;
bool bMonth;
bool bYear;
int iDay = qsl[0].toInt(&bDay);
int iMonth = qsl[1].toInt(&bMonth);
int iYear = qsl[2].toInt(&bYear);
if (bDay == true && bMonth == true && bYear == true)
{
QDate date;
date.setDate(iYear, iMonth, iDay);
return date;
}
}
return QDate::currentDate();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VAbstractPattern::GetImage() const QString VAbstractPattern::GetImage() const
{ {
@ -1109,7 +1197,8 @@ QDomElement VAbstractPattern::CheckTagExists(const QString &tag)
if (list.isEmpty()) if (list.isEmpty())
{ {
const QStringList tags = QStringList() << TagUnit << TagImage << TagAuthor << TagDescription << TagNotes const QStringList tags = QStringList() << TagUnit << TagImage << TagAuthor << TagDescription << TagNotes
<< TagGradation; << TagGradation << TagPatternName << TagPatternNum << TagCompanyName
<< TagCustomerName << TagCreationDate;
switch (tags.indexOf(tag)) switch (tags.indexOf(tag))
{ {
case 0: //TagUnit case 0: //TagUnit
@ -1150,6 +1239,32 @@ QDomElement VAbstractPattern::CheckTagExists(const QString &tag)
element.appendChild(sizes); element.appendChild(sizes);
break; break;
} }
case 6: // TagPatternName
{
element = createElement(TagPatternName);
break;
}
case 7: // TagPatternName
{
element = createElement(TagPatternNum);
break;
}
case 8: // TagPatternName
{
element = createElement(TagCompanyName);
break;
}
case 9: // TagPatternName
{
element = createElement(TagCustomerName);
break;
}
case 10: // TagPatternName
{
element = createElement(TagCreationDate);
break;
}
default: default:
{ {
return QDomElement(); return QDomElement();

View File

@ -33,6 +33,7 @@
#include "vtoolrecord.h" #include "vtoolrecord.h"
#include <QObject> #include <QObject>
#include <QDate>
enum class Document : char { LiteParse, LitePPParse, FullParse }; enum class Document : char { LiteParse, LitePPParse, FullParse };
enum class LabelType : char {NewPatternPiece, NewLabel}; enum class LabelType : char {NewPatternPiece, NewLabel};
@ -107,6 +108,16 @@ public:
QString GetNotes() const; QString GetNotes() const;
void SetNotes(const QString &text); void SetNotes(const QString &text);
QString GetPatternName() const;
void SetPatternName(QString qsName);
QString GetCompanyName() const;
void SetCompanyName(QString qsName);
QString GetPatternNumber() const;
void SetPatternNumber(QString qsNum);
QString GetCustomerName() const;
void SetCustomerName(QString qsName);
QDate GetCreationDate() const;
QString GetImage() const; QString GetImage() const;
QString GetImageExtension() const; QString GetImageExtension() const;
void SetImage(const QString &text, const QString &extension); void SetImage(const QString &text, const QString &extension);
@ -157,6 +168,11 @@ public:
static const QString TagUnit; static const QString TagUnit;
static const QString TagData; static const QString TagData;
static const QString TagMCP; static const QString TagMCP;
static const QString TagPatternName;
static const QString TagPatternNum;
static const QString TagCompanyName;
static const QString TagCustomerName;
static const QString TagCreationDate;
static const QString AttrName; static const QString AttrName;
static const QString AttrVisible; static const QString AttrVisible;