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->lineEditAuthor->setClearButtonEnabled(true);
SCASSERT(doc != nullptr)
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"));
#endif //defined(Q_OS_MAC)
ui->lineEditAuthor->setText(doc->GetAuthor());
connect(ui->lineEditAuthor, &QLineEdit::editingFinished, this, &DialogPatternProperties::DescEdited);
ui->plainTextEditDescription->setPlainText(doc->GetDescription());
connect(ui->plainTextEditDescription, &QPlainTextEdit::textChanged, this, &DialogPatternProperties::DescEdited);
@ -179,32 +174,11 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat
ui->lineEditPatternNumber->setText(doc->GetPatternNumber());
ui->lineEditCompanyName->setText(doc->GetCompanyName());
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->lineEditPatternNumber, &QLineEdit::editingFinished, this, &DialogPatternProperties::LabelDataChanged);
connect(ui->lineEditCompanyName, &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);
}
@ -538,7 +512,6 @@ void DialogPatternProperties::SaveDescription()
{
doc->SetNotes(ui->plainTextEditTechNotes->document()->toPlainText());
doc->SetDescription(ui->plainTextEditDescription->document()->toPlainText());
doc->SetAuthor(ui->lineEditAuthor->text());
descriptionChanged = false;
emit doc->patternChanged(false);
@ -587,9 +560,6 @@ void DialogPatternProperties::SaveLabelData()
doc->SetPatternNumber(ui->lineEditPatternNumber->text());
doc->SetCompanyName(ui->lineEditCompanyName->text());
doc->SetCustomerName(ui->lineEditCustomerName->text());
doc->SetPatternSize(ui->lineEditSize->text());
doc->SetDateVisible(ui->checkBoxShowDate->isChecked());
doc->SetMesurementsVisible(ui->checkBoxShowMeasurements->isChecked());
labelDataChanged = false;
askSaveLabelData = false;

View File

@ -21,7 +21,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>3</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@ -80,20 +80,6 @@
</item>
</layout>
</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>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<property name="spacing">
@ -1313,37 +1299,9 @@
</property>
</widget>
</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>
</widget>
</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>
</widget>
</widget>

View File

@ -106,7 +106,6 @@ void VPattern::CreateEmptyFile()
unit.appendChild(newNodeText);
patternElement.appendChild(unit);
patternElement.appendChild(createElement(TagAuthor));
patternElement.appendChild(createElement(TagDescription));
patternElement.appendChild(createElement(TagNotes));
@ -149,10 +148,10 @@ void VPattern::Parse(const Document &parse)
SCASSERT(sceneDraw != nullptr)
SCASSERT(sceneDetail != nullptr)
QStringList tags = QStringList() << TagDraw << TagIncrements << TagAuthor << TagDescription << TagNotes
QStringList tags = QStringList() << TagDraw << TagIncrements << TagDescription << TagNotes
<< TagMeasurements << TagVersion << TagGradation << TagImage << TagUnit
<< TagPatternName << TagPatternNum << TagCompanyName << TagCustomerName
<< TagSize << TagShowDate << TagShowMeasurements;
<< TagPatternLabel;
PrepareForParse(parse);
QDomNode domNode = documentElement().firstChild();
while (domNode.isNull() == false)
@ -188,50 +187,41 @@ void VPattern::Parse(const Document &parse)
qCDebug(vXML, "Tag increments.");
ParseIncrementsElement(domElement);
break;
case 2: // TagAuthor
qCDebug(vXML, "Tag author.");
break;
case 3: // TagDescription
case 2: // TagDescription
qCDebug(vXML, "Tag description.");
break;
case 4: // TagNotes
case 3: // TagNotes
qCDebug(vXML, "Tag notes.");
break;
case 5: // TagMeasurements
case 4: // TagMeasurements
qCDebug(vXML, "Tag measurements.");
break;
case 6: // TagVersion
case 5: // TagVersion
qCDebug(vXML, "Tag version.");
break;
case 7: // TagGradation
case 6: // TagGradation
qCDebug(vXML, "Tag gradation.");
break;
case 8: // TagImage
case 7: // TagImage
qCDebug(vXML, "Tag image.");
break;
case 9: // TagUnit
case 8: // TagUnit
qCDebug(vXML, "Tag unit.");
break;
case 10: // TagPatternName
case 9: // TagPatternName
qCDebug(vXML, "Pattern name.");
break;
case 11: // TagPatternNumber
case 10: // TagPatternNumber
qCDebug(vXML, "Pattern number.");
break;
case 12: // TagCompanyName
case 11: // TagCompanyName
qCDebug(vXML, "Company name.");
break;
case 13: // TagCustomerName
case 12: // TagCustomerName
qCDebug(vXML, "Customer name.");
break;
case 14: // TagSize
qCDebug(vXML, "Size");
break;
case 15:
qCDebug(vXML, "Show creation date");
break;
case 16:
qCDebug(vXML, "Show measurements");
case 13: // TagPatternLabel
qCDebug(vXML, "Pattern label.");
break;
default:
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)
{

View File

@ -66,9 +66,6 @@ public:
QRectF ActiveDrawBoundingRect() const;
QString GetAuthor() const;
void SetAuthor(const QString &text);
void AddEmptyIncrement(const QString &name);
void AddEmptyIncrementAfter(const QString &after, 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::TagDetails = QStringLiteral("details");
const QString VAbstractPattern::TagDetail = QStringLiteral("detail");
const QString VAbstractPattern::TagAuthor = QStringLiteral("author");
const QString VAbstractPattern::TagDescription = QStringLiteral("description");
const QString VAbstractPattern::TagNotes = QStringLiteral("notes");
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::TagCompanyName = QStringLiteral("company");
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::TagPath = QStringLiteral("path");
const QString VAbstractPattern::TagNodes = QStringLiteral("nodes");
@ -1332,51 +1328,6 @@ void VAbstractPattern::SetCustomerName(const QString& qsName)
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)
{
@ -1556,25 +1507,21 @@ QDomElement VAbstractPattern::CheckTagExists(const QString &tag)
QDomElement element;
if (list.isEmpty())
{
const QStringList tags = QStringList() << TagUnit << TagImage << TagAuthor << TagDescription << TagNotes
const QStringList tags = QStringList() << TagUnit << TagImage << TagDescription << TagNotes
<< TagGradation << TagPatternName << TagPatternNum << TagCompanyName
<< TagCustomerName << TagPatternLabel << TagSize << TagShowDate
<< TagShowMeasurements;
<< TagCustomerName << TagPatternLabel;
switch (tags.indexOf(tag))
{
case 1: //TagImage
element = createElement(TagImage);
break;
case 2: //TagAuthor
element = createElement(TagAuthor);
break;
case 3: //TagDescription
case 2: //TagDescription
element = createElement(TagDescription);
break;
case 4: //TagNotes
case 3: //TagNotes
element = createElement(TagNotes);
break;
case 5: //TagGradation
case 4: //TagGradation
{
element = createElement(TagGradation);
@ -1587,30 +1534,21 @@ QDomElement VAbstractPattern::CheckTagExists(const QString &tag)
element.appendChild(sizes);
break;
}
case 6: // TagPatternName
case 5: // TagPatternName
element = createElement(TagPatternName);
break;
case 7: // TagPatternNum
case 6: // TagPatternNum
element = createElement(TagPatternNum);
break;
case 8: // TagCompanyName
case 7: // TagCompanyName
element = createElement(TagCompanyName);
break;
case 9: // TagCustomerName
case 8: // TagCustomerName
element = createElement(TagCustomerName);
break;
case 10: // TagPatternLabel
case 9: // TagPatternLabel
element = createElement(TagPatternLabel);
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)
default:
return QDomElement();

View File

@ -147,12 +147,6 @@ public:
void SetPatternNumber(const QString &qsNum);
QString GetCustomerName() const;
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);
QVector<VLabelTemplateLine> GetPatternLabelTemplate() const;
@ -187,7 +181,6 @@ public:
static const QString TagModeling;
static const QString TagDetails;
static const QString TagDetail;
static const QString TagAuthor;
static const QString TagDescription;
static const QString TagImage;
static const QString TagNotes;
@ -216,9 +209,6 @@ public:
static const QString TagCompanyName;
static const QString TagCustomerName;
static const QString TagPatternLabel;
static const QString TagSize;
static const QString TagShowDate;
static const QString TagShowMeasurements;
static const QString TagGrainline;
static const QString TagPath;
static const QString TagNodes;