From 25a58421cc39a7328877962bbfa8e325f33bd24d Mon Sep 17 00:00:00 2001 From: BojanKverh Date: Sat, 16 Jul 2016 01:12:51 +0200 Subject: [PATCH] Added pattern size field and creation date visibility flag to pattern properties --HG-- branch : feature --- .../dialogs/dialogpatternproperties.cpp | 4 + .../dialogs/dialogpatternproperties.ui | 27 ++++-- src/app/valentina/xml/vpattern.cpp | 8 +- src/libs/ifc/schema/pattern/v0.3.3.xsd | 2 + src/libs/ifc/xml/vabstractpattern.cpp | 45 +++++++++- src/libs/ifc/xml/vabstractpattern.h | 6 ++ src/libs/vpatterndb/vpatterndb.pri | 6 +- src/libs/vpatterndb/vpatterndb.pro | 7 -- src/libs/vtools/tools/vtextgraphicsitem.cpp | 5 +- src/libs/vtools/tools/vtooldetail.cpp | 82 +++++++++++++------ 10 files changed, 149 insertions(+), 43 deletions(-) diff --git a/src/app/valentina/dialogs/dialogpatternproperties.cpp b/src/app/valentina/dialogs/dialogpatternproperties.cpp index 85b96a291..7a54a0267 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.cpp +++ b/src/app/valentina/dialogs/dialogpatternproperties.cpp @@ -166,6 +166,8 @@ DialogPatternProperties::DialogPatternProperties(const QString &filePath, VPatte ui->lineEditCompanyName->setText(doc->GetCompanyName()); ui->lineEditCustomerName->setText(doc->GetCustomerName()); ui->labelCreationDate->setText(doc->GetCreationDate().toString(Qt::SystemLocaleLongDate)); + ui->lineEditSize->setText(doc->GetPatternSize()); + ui->checkBoxShowDate->setChecked(doc->IsDateVisible()); connect(ui->lineEditPatternName, &QLineEdit::editingFinished, this, &DialogPatternProperties::GeneralInfoChanged); connect(ui->lineEditPatternNumber, &QLineEdit::editingFinished, this, &DialogPatternProperties::GeneralInfoChanged); @@ -552,6 +554,8 @@ void DialogPatternProperties::SaveGeneralInfo() 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()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/dialogs/dialogpatternproperties.ui b/src/app/valentina/dialogs/dialogpatternproperties.ui index 1d09d1a41..7521f8945 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.ui +++ b/src/app/valentina/dialogs/dialogpatternproperties.ui @@ -1053,7 +1053,7 @@ 10 10 401 - 171 + 221 @@ -1100,17 +1100,34 @@ - + + + + + + + + Created: - - + + - + Pattern size: + + + + + + + + + + Show date of creation diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index d83a82193..29f1fb9d3 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -139,7 +139,7 @@ void VPattern::Parse(const Document &parse) QStringList tags = QStringList() << TagDraw << TagIncrements << TagAuthor << TagDescription << TagNotes << TagMeasurements << TagVersion << TagGradation << TagImage << TagUnit << TagPatternName << TagPatternNum << TagCompanyName << TagCustomerName - << TagCreationDate; + << TagCreationDate << TagSize << TagShowDate; PrepareForParse(parse); QDomNode domNode = documentElement().firstChild(); while (domNode.isNull() == false) @@ -214,6 +214,12 @@ void VPattern::Parse(const Document &parse) case 14: // TagCreationDate qCDebug(vXML, "Creation date."); break; + case 15: // TagSize + qCDebug(vXML, "Size"); + break; + case 16: + qCDebug(vXML, "Show creation date"); + break; default: qCDebug(vXML, "Wrong tag name %s", qUtf8Printable(domElement.tagName())); break; diff --git a/src/libs/ifc/schema/pattern/v0.3.3.xsd b/src/libs/ifc/schema/pattern/v0.3.3.xsd index 9f622d42e..0f24bcc0c 100644 --- a/src/libs/ifc/schema/pattern/v0.3.3.xsd +++ b/src/libs/ifc/schema/pattern/v0.3.3.xsd @@ -23,6 +23,8 @@ + + diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index de5d12f41..ab85684cd 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -68,6 +68,9 @@ 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::TagSize = QStringLiteral("size"); +const QString VAbstractPattern::TagShowDate = QStringLiteral("showDate"); + const QString VAbstractPattern::AttrName = QStringLiteral("name"); const QString VAbstractPattern::AttrVisible = QStringLiteral("visible"); @@ -1076,6 +1079,36 @@ QDate VAbstractPattern::GetCreationDate() const return QDate::currentDate(); } +//--------------------------------------------------------------------------------------------------------------------- +QString VAbstractPattern::GetPatternSize() const +{ + return UniqueTagText(TagSize); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractPattern::SetPatternSize(QString qsSize) +{ + CheckTagExists(TagSize); + setTagText(TagSize, qsSize); + modified = true; + emit patternChanged(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VAbstractPattern::IsDateVisible() const +{ + return UniqueTagText(TagShowDate) != QStringLiteral("false"); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractPattern::SetDateVisible(bool bVisible) +{ + CheckTagExists(TagShowDate); + setTagText(TagShowDate, bVisible == true? QStringLiteral("true") : QStringLiteral("false")); + modified = true; + emit patternChanged(false); +} + //--------------------------------------------------------------------------------------------------------------------- QString VAbstractPattern::GetImage() const { @@ -1178,7 +1211,7 @@ QDomElement VAbstractPattern::CheckTagExists(const QString &tag) { const QStringList tags = QStringList() << TagUnit << TagImage << TagAuthor << TagDescription << TagNotes << TagGradation << TagPatternName << TagPatternNum << TagCompanyName - << TagCustomerName << TagCreationDate; + << TagCustomerName << TagCreationDate << TagSize << TagShowDate; switch (tags.indexOf(tag)) { case 0: //TagUnit @@ -1244,6 +1277,16 @@ QDomElement VAbstractPattern::CheckTagExists(const QString &tag) element = createElement(TagCreationDate); break; } + case 11: // TagSize + { + element = createElement(TagSize); + break; + } + case 12: // TagShowDate + { + element = createElement(TagShowDate); + break; + } default: { diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index 0ca26d050..c9e8d9380 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -117,6 +117,10 @@ public: QString GetCustomerName() const; void SetCustomerName(QString qsName); QDate GetCreationDate() const; + QString GetPatternSize() const; + void SetPatternSize(QString qsSize); + bool IsDateVisible() const; + void SetDateVisible(bool bVisible); QString GetImage() const; QString GetImageExtension() const; @@ -174,6 +178,8 @@ public: static const QString TagCompanyName; static const QString TagCustomerName; static const QString TagCreationDate; + static const QString TagSize; + static const QString TagShowDate; static const QString AttrName; static const QString AttrVisible; diff --git a/src/libs/vpatterndb/vpatterndb.pri b/src/libs/vpatterndb/vpatterndb.pri index b0507d074..b2e055a6e 100644 --- a/src/libs/vpatterndb/vpatterndb.pri +++ b/src/libs/vpatterndb/vpatterndb.pri @@ -18,7 +18,8 @@ SOURCES += \ $$PWD/variables/vmeasurement.cpp \ $$PWD/variables/vvariable.cpp \ $$PWD/vformula.cpp \ - $$PWD/vpatternpiecedata.cpp + $$PWD/vpatternpiecedata.cpp \ + $$PWD/vpatterninfogeometry.cpp win32-msvc*:SOURCES += $$PWD/stable.cpp @@ -51,4 +52,5 @@ HEADERS += \ $$PWD/variables/vvariable.h \ $$PWD/variables/vvariable_p.h \ $$PWD/vformula.h \ - $$PWD/vpatternpiecedata.h + $$PWD/vpatternpiecedata.h \ + $$PWD/vpatterninfogeometry.h diff --git a/src/libs/vpatterndb/vpatterndb.pro b/src/libs/vpatterndb/vpatterndb.pro index bb5d3d0bc..28d254840 100644 --- a/src/libs/vpatterndb/vpatterndb.pro +++ b/src/libs/vpatterndb/vpatterndb.pro @@ -100,10 +100,3 @@ CONFIG(debug, debug|release){ } } } - -HEADERS += \ - vpatterninfogeometry.h - -SOURCES += \ - vpatterninfogeometry.cpp - diff --git a/src/libs/vtools/tools/vtextgraphicsitem.cpp b/src/libs/vtools/tools/vtextgraphicsitem.cpp index 3b98e8f80..7380f65c9 100644 --- a/src/libs/vtools/tools/vtextgraphicsitem.cpp +++ b/src/libs/vtools/tools/vtextgraphicsitem.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include "../vmisc/def.h" @@ -311,7 +312,7 @@ void VTextGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent* pME) m_dAngle = GetAngle(pME->scenePos()); return; } - double dAng = 180*(GetAngle(pME->scenePos()) - m_dAngle)/M_PI; + double dAng = qRadiansToDegrees(GetAngle(pME->scenePos()) - m_dAngle); rectBB.setTopLeft(m_ptStartPos); rectBB.setWidth(m_rectBoundingBox.width()); rectBB.setHeight(m_rectBoundingBox.height()); @@ -480,7 +481,7 @@ QRectF VTextGraphicsItem::GetBoundingRect(QRectF rectBB, qreal dRot) const qreal dY1 = 0; qreal dY2 = 0; - double dAng = M_PI*dRot/180; + double dAng = qDegreesToRadians(dRot); for (int i = 0; i < 4; ++i) { QPointF pt = apt[i] - ptCenter; diff --git a/src/libs/vtools/tools/vtooldetail.cpp b/src/libs/vtools/tools/vtooldetail.cpp index 446e41a28..c89cc6970 100644 --- a/src/libs/vtools/tools/vtooldetail.cpp +++ b/src/libs/vtools/tools/vtooldetail.cpp @@ -689,16 +689,25 @@ void VToolDetail::UpdateLabel() TextLine tl; // letter tl.m_qsText = data.GetLetter(); - tl.m_eAlign = Qt::AlignCenter; - tl.m_eFontWeight = QFont::Bold; - tl.m_eStyle = QFont::StyleNormal; - tl.m_iFontSize = 6; - dataLabel->AddLine(tl); + if (tl.m_qsText.isEmpty() == false) + { + tl.m_eAlign = Qt::AlignCenter; + tl.m_eFontWeight = QFont::Bold; + tl.m_eStyle = QFont::StyleNormal; + tl.m_iFontSize = 6; + dataLabel->AddLine(tl); + } + + // name tl.m_qsText = detail.getName(); - tl.m_eAlign = Qt::AlignCenter; - tl.m_eFontWeight = QFont::DemiBold; - tl.m_iFontSize = 2; - dataLabel->AddLine(tl); + if (tl.m_qsText.isEmpty() == false) + { + tl.m_eAlign = Qt::AlignCenter; + tl.m_eFontWeight = QFont::DemiBold; + tl.m_iFontSize = 2; + dataLabel->AddLine(tl); + } + // MCP tl.m_eAlign = Qt::AlignLeft | Qt::AlignVCenter; tl.m_eFontWeight = QFont::Normal; @@ -761,33 +770,56 @@ void VToolDetail::UpdatePatternInfo() // Company name tl.m_qsText = doc->GetCompanyName(); - tl.m_eAlign = Qt::AlignCenter; - tl.m_eFontWeight = QFont::DemiBold; - tl.m_eStyle = QFont::StyleNormal; - tl.m_iFontSize = 4; - patternInfo->AddLine(tl); + if (tl.m_qsText.isEmpty() == false) + { + tl.m_eAlign = Qt::AlignCenter; + tl.m_eFontWeight = QFont::DemiBold; + tl.m_eStyle = QFont::StyleNormal; + tl.m_iFontSize = 4; + patternInfo->AddLine(tl); + } // Pattern name tl.m_qsText = doc->GetPatternName(); - tl.m_eFontWeight = QFont::Normal; - tl.m_iFontSize = 2; - patternInfo->AddLine(tl); + if (tl.m_qsText.isEmpty() == false) + { + tl.m_eFontWeight = QFont::Normal; + tl.m_iFontSize = 2; + patternInfo->AddLine(tl); + } // Pattern number tl.m_qsText = doc->GetPatternNumber(); - tl.m_iFontSize = 0; - tl.m_eAlign = Qt::AlignLeft | Qt::AlignVCenter; - patternInfo->AddLine(tl); + if (tl.m_qsText.isEmpty() == false) + { + tl.m_iFontSize = 0; + tl.m_eAlign = Qt::AlignLeft | Qt::AlignVCenter; + patternInfo->AddLine(tl); + } // Customer name tl.m_qsText = doc->GetCustomerName(); - tl.m_eStyle = QFont::StyleItalic; - patternInfo->AddLine(tl); + if (tl.m_qsText.isEmpty() == false) + { + tl.m_eStyle = QFont::StyleItalic; + patternInfo->AddLine(tl); + } + + // Size + tl.m_qsText = doc->GetPatternSize(); + if (tl.m_qsText.isEmpty() == false) + { + tl.m_eStyle = QFont::StyleNormal; + patternInfo->AddLine(tl); + } // Creation date - QStringList qslDate = doc->GetCreationDate().toString(Qt::SystemLocaleLongDate).split(", "); - tl.m_qsText = qslDate.last(); - patternInfo->AddLine(tl); + if (doc->IsDateVisible() == true) + { + QStringList qslDate = doc->GetCreationDate().toString(Qt::SystemLocaleLongDate).split(", "); + tl.m_qsText = qslDate.last(); + patternInfo->AddLine(tl); + } QPointF pt = geom.GetPos(); QRectF rectBB;