Clear unused tags from code.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-08-16 16:56:07 +03:00
parent 3cd0c10f07
commit bc36e9bac3
6 changed files with 26 additions and 198 deletions

View File

@ -71,8 +71,6 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat
{ {
ui->setupUi(this); ui->setupUi(this);
ui->lineEditAuthor->setClearButtonEnabled(true);
SCASSERT(doc != nullptr) SCASSERT(doc != nullptr)
qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c()); qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
@ -99,9 +97,6 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat
ui->pushButtonShowInExplorer->setText(tr("Show in Finder")); ui->pushButtonShowInExplorer->setText(tr("Show in Finder"));
#endif //defined(Q_OS_MAC) #endif //defined(Q_OS_MAC)
ui->lineEditAuthor->setText(doc->GetAuthor());
connect(ui->lineEditAuthor, &QLineEdit::editingFinished, this, &DialogPatternProperties::DescEdited);
ui->plainTextEditDescription->setPlainText(doc->GetDescription()); ui->plainTextEditDescription->setPlainText(doc->GetDescription());
connect(ui->plainTextEditDescription, &QPlainTextEdit::textChanged, this, &DialogPatternProperties::DescEdited); connect(ui->plainTextEditDescription, &QPlainTextEdit::textChanged, this, &DialogPatternProperties::DescEdited);
@ -179,32 +174,11 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat
ui->lineEditPatternNumber->setText(doc->GetPatternNumber()); ui->lineEditPatternNumber->setText(doc->GetPatternNumber());
ui->lineEditCompanyName->setText(doc->GetCompanyName()); ui->lineEditCompanyName->setText(doc->GetCompanyName());
ui->lineEditCustomerName->setText(doc->GetCustomerName()); ui->lineEditCustomerName->setText(doc->GetCustomerName());
ui->checkBoxShowDate->setText(ui->checkBoxShowDate->text()
.arg(QDate::currentDate().toString(Qt::SystemLocaleLongDate)));
ui->lineEditSize->setText(doc->GetPatternSize());
const QString plSize = QLatin1String("%") + qApp->TrVars()->PlaceholderToUser(pl_size) + QLatin1String("%");
const QString plHeight = QLatin1String("%") + qApp->TrVars()->PlaceholderToUser(pl_height) + QLatin1String("%");
ui->lineEditSize->setToolTip(tr("Use %1 and %2 to insert pattern size and height").arg(plSize, plHeight));
ui->checkBoxShowDate->setChecked(doc->IsDateVisible());
if (doc->MPath().isEmpty() == true)
{
ui->checkBoxShowMeasurements->setChecked(false);
ui->checkBoxShowMeasurements->setEnabled(false);
}
else
{
ui->checkBoxShowMeasurements->setChecked(doc->IsMeasurementsVisible());
}
connect(ui->lineEditPatternName, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged); connect(ui->lineEditPatternName, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged);
connect(ui->lineEditPatternNumber, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged); connect(ui->lineEditPatternNumber, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged);
connect(ui->lineEditCompanyName, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged); connect(ui->lineEditCompanyName, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged);
connect(ui->lineEditCustomerName, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged); connect(ui->lineEditCustomerName, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged);
connect(ui->lineEditSize, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged);
connect(ui->checkBoxShowDate, &QCheckBox::stateChanged, this, &DialogPatternProperties::LabelDataChanged);
connect(ui->checkBoxShowMeasurements, &QCheckBox::stateChanged, this, &DialogPatternProperties::LabelDataChanged);
connect(ui->pushButtonEditPatternLabel, &QPushButton::clicked, this, &DialogPatternProperties::EditLabel); connect(ui->pushButtonEditPatternLabel, &QPushButton::clicked, this, &DialogPatternProperties::EditLabel);
} }
@ -538,7 +512,6 @@ void DialogPatternProperties::SaveDescription()
{ {
doc->SetNotes(ui->plainTextEditTechNotes->document()->toPlainText()); doc->SetNotes(ui->plainTextEditTechNotes->document()->toPlainText());
doc->SetDescription(ui->plainTextEditDescription->document()->toPlainText()); doc->SetDescription(ui->plainTextEditDescription->document()->toPlainText());
doc->SetAuthor(ui->lineEditAuthor->text());
descriptionChanged = false; descriptionChanged = false;
emit doc->patternChanged(false); emit doc->patternChanged(false);
@ -587,9 +560,6 @@ void DialogPatternProperties::SaveLabelData()
doc->SetPatternNumber(ui->lineEditPatternNumber->text()); doc->SetPatternNumber(ui->lineEditPatternNumber->text());
doc->SetCompanyName(ui->lineEditCompanyName->text()); doc->SetCompanyName(ui->lineEditCompanyName->text());
doc->SetCustomerName(ui->lineEditCustomerName->text()); doc->SetCustomerName(ui->lineEditCustomerName->text());
doc->SetPatternSize(ui->lineEditSize->text());
doc->SetDateVisible(ui->checkBoxShowDate->isChecked());
doc->SetMesurementsVisible(ui->checkBoxShowMeasurements->isChecked());
labelDataChanged = false; labelDataChanged = false;
askSaveLabelData = false; askSaveLabelData = false;

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">
@ -80,20 +80,6 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Author:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditAuthor"/>
</item>
</layout>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_7"> <layout class="QHBoxLayout" name="horizontalLayout_7">
<property name="spacing"> <property name="spacing">
@ -1313,37 +1299,9 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Pattern size:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEditSize">
<property name="maxLength">
<number>40</number>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="checkBoxShowDate">
<property name="text">
<string>Show date of layout creation (%1)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxShowMeasurements">
<property name="text">
<string>Show measurements file</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</widget> </widget>

View File

@ -106,7 +106,6 @@ void VPattern::CreateEmptyFile()
unit.appendChild(newNodeText); unit.appendChild(newNodeText);
patternElement.appendChild(unit); patternElement.appendChild(unit);
patternElement.appendChild(createElement(TagAuthor));
patternElement.appendChild(createElement(TagDescription)); patternElement.appendChild(createElement(TagDescription));
patternElement.appendChild(createElement(TagNotes)); patternElement.appendChild(createElement(TagNotes));
@ -149,10 +148,10 @@ void VPattern::Parse(const Document &parse)
SCASSERT(sceneDraw != nullptr) SCASSERT(sceneDraw != nullptr)
SCASSERT(sceneDetail != nullptr) SCASSERT(sceneDetail != nullptr)
QStringList tags = QStringList() << TagDraw << TagIncrements << TagAuthor << TagDescription << TagNotes QStringList tags = QStringList() << TagDraw << TagIncrements << TagDescription << TagNotes
<< TagMeasurements << TagVersion << TagGradation << TagImage << TagUnit << TagMeasurements << TagVersion << TagGradation << TagImage << TagUnit
<< TagPatternName << TagPatternNum << TagCompanyName << TagCustomerName << TagPatternName << TagPatternNum << TagCompanyName << TagCustomerName
<< TagSize << TagShowDate << TagShowMeasurements; << TagPatternLabel;
PrepareForParse(parse); PrepareForParse(parse);
QDomNode domNode = documentElement().firstChild(); QDomNode domNode = documentElement().firstChild();
while (domNode.isNull() == false) while (domNode.isNull() == false)
@ -188,50 +187,41 @@ void VPattern::Parse(const Document &parse)
qCDebug(vXML, "Tag increments."); qCDebug(vXML, "Tag increments.");
ParseIncrementsElement(domElement); ParseIncrementsElement(domElement);
break; break;
case 2: // TagAuthor case 2: // TagDescription
qCDebug(vXML, "Tag author.");
break;
case 3: // TagDescription
qCDebug(vXML, "Tag description."); qCDebug(vXML, "Tag description.");
break; break;
case 4: // TagNotes case 3: // TagNotes
qCDebug(vXML, "Tag notes."); qCDebug(vXML, "Tag notes.");
break; break;
case 5: // TagMeasurements case 4: // TagMeasurements
qCDebug(vXML, "Tag measurements."); qCDebug(vXML, "Tag measurements.");
break; break;
case 6: // TagVersion case 5: // TagVersion
qCDebug(vXML, "Tag version."); qCDebug(vXML, "Tag version.");
break; break;
case 7: // TagGradation case 6: // TagGradation
qCDebug(vXML, "Tag gradation."); qCDebug(vXML, "Tag gradation.");
break; break;
case 8: // TagImage case 7: // TagImage
qCDebug(vXML, "Tag image."); qCDebug(vXML, "Tag image.");
break; break;
case 9: // TagUnit case 8: // TagUnit
qCDebug(vXML, "Tag unit."); qCDebug(vXML, "Tag unit.");
break; break;
case 10: // TagPatternName case 9: // TagPatternName
qCDebug(vXML, "Pattern name."); qCDebug(vXML, "Pattern name.");
break; break;
case 11: // TagPatternNumber case 10: // TagPatternNumber
qCDebug(vXML, "Pattern number."); qCDebug(vXML, "Pattern number.");
break; break;
case 12: // TagCompanyName case 11: // TagCompanyName
qCDebug(vXML, "Company name."); qCDebug(vXML, "Company name.");
break; break;
case 13: // TagCustomerName case 12: // TagCustomerName
qCDebug(vXML, "Customer name."); qCDebug(vXML, "Customer name.");
break; break;
case 14: // TagSize case 13: // TagPatternLabel
qCDebug(vXML, "Size"); qCDebug(vXML, "Pattern label.");
break;
case 15:
qCDebug(vXML, "Show creation date");
break;
case 16:
qCDebug(vXML, "Show measurements");
break; break;
default: default:
qCDebug(vXML, "Wrong tag name %s", qUtf8Printable(domElement.tagName())); qCDebug(vXML, "Wrong tag name %s", qUtf8Printable(domElement.tagName()));
@ -3393,21 +3383,6 @@ void VPattern::ParseIncrementsElement(const QDomNode &node)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
QString VPattern::GetAuthor() const
{
return UniqueTagText(TagAuthor, qApp->ValentinaSettings()->GetUser());
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::SetAuthor(const QString &text)
{
CheckTagExists(TagAuthor);
setTagText(TagAuthor, text);
modified = true;
emit patternChanged(false);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPattern::AddEmptyIncrement(const QString &name) void VPattern::AddEmptyIncrement(const QString &name)
{ {

View File

@ -66,9 +66,6 @@ public:
QRectF ActiveDrawBoundingRect() const; QRectF ActiveDrawBoundingRect() const;
QString GetAuthor() const;
void SetAuthor(const QString &text);
void AddEmptyIncrement(const QString &name); void AddEmptyIncrement(const QString &name);
void AddEmptyIncrementAfter(const QString &after, const QString &name); void AddEmptyIncrementAfter(const QString &after, const QString &name);
void RemoveIncrement(const QString &name); void RemoveIncrement(const QString &name);

View File

@ -59,7 +59,6 @@ const QString VAbstractPattern::TagCalculation = QStringLiteral("calculatio
const QString VAbstractPattern::TagModeling = QStringLiteral("modeling"); const QString VAbstractPattern::TagModeling = QStringLiteral("modeling");
const QString VAbstractPattern::TagDetails = QStringLiteral("details"); const QString VAbstractPattern::TagDetails = QStringLiteral("details");
const QString VAbstractPattern::TagDetail = QStringLiteral("detail"); const QString VAbstractPattern::TagDetail = QStringLiteral("detail");
const QString VAbstractPattern::TagAuthor = QStringLiteral("author");
const QString VAbstractPattern::TagDescription = QStringLiteral("description"); const QString VAbstractPattern::TagDescription = QStringLiteral("description");
const QString VAbstractPattern::TagNotes = QStringLiteral("notes"); const QString VAbstractPattern::TagNotes = QStringLiteral("notes");
const QString VAbstractPattern::TagImage = QStringLiteral("image"); const QString VAbstractPattern::TagImage = QStringLiteral("image");
@ -88,9 +87,6 @@ const QString VAbstractPattern::TagPatternNum = QStringLiteral("patternNum
const QString VAbstractPattern::TagCustomerName = QStringLiteral("customer"); const QString VAbstractPattern::TagCustomerName = QStringLiteral("customer");
const QString VAbstractPattern::TagCompanyName = QStringLiteral("company"); const QString VAbstractPattern::TagCompanyName = QStringLiteral("company");
const QString VAbstractPattern::TagPatternLabel = QStringLiteral("patternLabel"); const QString VAbstractPattern::TagPatternLabel = QStringLiteral("patternLabel");
const QString VAbstractPattern::TagSize = QStringLiteral("size");
const QString VAbstractPattern::TagShowDate = QStringLiteral("showDate");
const QString VAbstractPattern::TagShowMeasurements = QStringLiteral("showMeasurements");
const QString VAbstractPattern::TagGrainline = QStringLiteral("grainline"); const QString VAbstractPattern::TagGrainline = QStringLiteral("grainline");
const QString VAbstractPattern::TagPath = QStringLiteral("path"); const QString VAbstractPattern::TagPath = QStringLiteral("path");
const QString VAbstractPattern::TagNodes = QStringLiteral("nodes"); const QString VAbstractPattern::TagNodes = QStringLiteral("nodes");
@ -1332,51 +1328,6 @@ void VAbstractPattern::SetCustomerName(const QString& qsName)
emit patternChanged(false); emit patternChanged(false);
} }
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractPattern::GetPatternSize() const
{
return UniqueTagText(TagSize);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetPatternSize(const QString& qsSize)
{
CheckTagExists(TagSize);
setTagText(TagSize, qsSize);
modified = true;
emit patternChanged(false);
}
//---------------------------------------------------------------------------------------------------------------------
bool VAbstractPattern::IsDateVisible() const
{
return UniqueTagText(TagShowDate) != falseStr;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetDateVisible(bool bVisible)
{
CheckTagExists(TagShowDate);
setTagText(TagShowDate, bVisible == true? trueStr : falseStr);
modified = true;
emit patternChanged(false);
}
//---------------------------------------------------------------------------------------------------------------------
bool VAbstractPattern::IsMeasurementsVisible() const
{
return UniqueTagText(TagShowMeasurements) == trueStr;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetMesurementsVisible(bool bVisible)
{
CheckTagExists(TagShowMeasurements);
setTagText(TagShowMeasurements, bVisible == true? trueStr : falseStr);
modified = true;
emit patternChanged(false);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetPatternLabelTemplate(const QVector<VLabelTemplateLine> &lines) void VAbstractPattern::SetPatternLabelTemplate(const QVector<VLabelTemplateLine> &lines)
{ {
@ -1556,25 +1507,21 @@ QDomElement VAbstractPattern::CheckTagExists(const QString &tag)
QDomElement element; QDomElement element;
if (list.isEmpty()) if (list.isEmpty())
{ {
const QStringList tags = QStringList() << TagUnit << TagImage << TagAuthor << TagDescription << TagNotes const QStringList tags = QStringList() << TagUnit << TagImage << TagDescription << TagNotes
<< TagGradation << TagPatternName << TagPatternNum << TagCompanyName << TagGradation << TagPatternName << TagPatternNum << TagCompanyName
<< TagCustomerName << TagPatternLabel << TagSize << TagShowDate << TagCustomerName << TagPatternLabel;
<< TagShowMeasurements;
switch (tags.indexOf(tag)) switch (tags.indexOf(tag))
{ {
case 1: //TagImage case 1: //TagImage
element = createElement(TagImage); element = createElement(TagImage);
break; break;
case 2: //TagAuthor case 2: //TagDescription
element = createElement(TagAuthor);
break;
case 3: //TagDescription
element = createElement(TagDescription); element = createElement(TagDescription);
break; break;
case 4: //TagNotes case 3: //TagNotes
element = createElement(TagNotes); element = createElement(TagNotes);
break; break;
case 5: //TagGradation case 4: //TagGradation
{ {
element = createElement(TagGradation); element = createElement(TagGradation);
@ -1587,30 +1534,21 @@ QDomElement VAbstractPattern::CheckTagExists(const QString &tag)
element.appendChild(sizes); element.appendChild(sizes);
break; break;
} }
case 6: // TagPatternName case 5: // TagPatternName
element = createElement(TagPatternName); element = createElement(TagPatternName);
break; break;
case 7: // TagPatternNum case 6: // TagPatternNum
element = createElement(TagPatternNum); element = createElement(TagPatternNum);
break; break;
case 8: // TagCompanyName case 7: // TagCompanyName
element = createElement(TagCompanyName); element = createElement(TagCompanyName);
break; break;
case 9: // TagCustomerName case 8: // TagCustomerName
element = createElement(TagCustomerName); element = createElement(TagCustomerName);
break; break;
case 10: // TagPatternLabel case 9: // TagPatternLabel
element = createElement(TagPatternLabel); element = createElement(TagPatternLabel);
break; break;
case 11: // TagSize
element = createElement(TagSize);
break;
case 12: // TagShowDate
element = createElement(TagShowDate);
break;
case 13: // TagShowMeasurements
element = createElement(TagShowMeasurements);
break;
case 0: //TagUnit (Mandatory tag) case 0: //TagUnit (Mandatory tag)
default: default:
return QDomElement(); return QDomElement();

View File

@ -147,12 +147,6 @@ public:
void SetPatternNumber(const QString &qsNum); void SetPatternNumber(const QString &qsNum);
QString GetCustomerName() const; QString GetCustomerName() const;
void SetCustomerName(const QString& qsName); void SetCustomerName(const QString& qsName);
QString GetPatternSize() const;
void SetPatternSize(const QString &qsSize);
bool IsDateVisible() const;
void SetDateVisible(bool bVisible);
bool IsMeasurementsVisible() const;
void SetMesurementsVisible(bool bVisible);
void SetPatternLabelTemplate(const QVector<VLabelTemplateLine> &lines); void SetPatternLabelTemplate(const QVector<VLabelTemplateLine> &lines);
QVector<VLabelTemplateLine> GetPatternLabelTemplate() const; QVector<VLabelTemplateLine> GetPatternLabelTemplate() const;
@ -187,7 +181,6 @@ public:
static const QString TagModeling; static const QString TagModeling;
static const QString TagDetails; static const QString TagDetails;
static const QString TagDetail; static const QString TagDetail;
static const QString TagAuthor;
static const QString TagDescription; static const QString TagDescription;
static const QString TagImage; static const QString TagImage;
static const QString TagNotes; static const QString TagNotes;
@ -216,9 +209,6 @@ public:
static const QString TagCompanyName; static const QString TagCompanyName;
static const QString TagCustomerName; static const QString TagCustomerName;
static const QString TagPatternLabel; static const QString TagPatternLabel;
static const QString TagSize;
static const QString TagShowDate;
static const QString TagShowMeasurements;
static const QString TagGrainline; static const QString TagGrainline;
static const QString TagPath; static const QString TagPath;
static const QString TagNodes; static const QString TagNodes;