Added the optional measurements line to the pattern info label

--HG--
branch : feature
This commit is contained in:
BojanKverh 2016-07-24 12:30:10 +02:00
parent a625c35616
commit a6e38b54d0
7 changed files with 170 additions and 97 deletions

View File

@ -173,6 +173,7 @@ DialogPatternProperties::DialogPatternProperties(const QString &filePath, VPatte
ui->labelCreationDate->setText(QDate::currentDate().toString(Qt::SystemLocaleLongDate));
ui->lineEditSize->setText(doc->GetPatternSize());
ui->checkBoxShowDate->setChecked(doc->IsDateVisible());
ui->checkBoxShowMeasurements->setChecked(doc->IsMeasurementsVisible());
connect(ui->lineEditPatternName, &QLineEdit::editingFinished, this, &DialogPatternProperties::GeneralInfoChanged);
connect(ui->lineEditPatternNumber, &QLineEdit::editingFinished, this, &DialogPatternProperties::GeneralInfoChanged);
@ -561,6 +562,7 @@ void DialogPatternProperties::SaveGeneralInfo()
doc->SetCustomerName(ui->lineEditCustomerName->text());
doc->SetPatternSize(ui->lineEditSize->text());
doc->SetDateVisible(ui->checkBoxShowDate->isChecked());
doc->SetMesurementsVisible(ui->checkBoxShowMeasurements->isChecked());
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -1053,7 +1053,7 @@
<x>10</x>
<y>10</y>
<width>401</width>
<height>221</height>
<height>241</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
@ -1068,7 +1068,11 @@
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEditPatternName"/>
<widget class="QLineEdit" name="lineEditPatternName">
<property name="maxLength">
<number>30</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_7">
@ -1078,7 +1082,11 @@
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEditPatternNumber"/>
<widget class="QLineEdit" name="lineEditPatternNumber">
<property name="maxLength">
<number>30</number>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_8">
@ -1088,7 +1096,11 @@
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEditCompanyName"/>
<widget class="QLineEdit" name="lineEditCompanyName">
<property name="maxLength">
<number>30</number>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_10">
@ -1098,7 +1110,11 @@
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="lineEditCustomerName"/>
<widget class="QLineEdit" name="lineEditCustomerName">
<property name="maxLength">
<number>30</number>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLabel" name="labelCreationDate">
@ -1122,9 +1138,20 @@
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="lineEditSize"/>
<widget class="QLineEdit" name="lineEditSize">
<property name="maxLength">
<number>30</number>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<item row="9" column="0">
<widget class="QCheckBox" name="checkBoxShowMeasurements">
<property name="text">
<string>Show measurements</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="checkBoxShowDate">
<property name="text">
<string>Show date of creation</string>

View File

@ -134,7 +134,7 @@ void VPattern::Parse(const Document &parse)
QStringList tags = QStringList() << TagDraw << TagIncrements << TagAuthor << TagDescription << TagNotes
<< TagMeasurements << TagVersion << TagGradation << TagImage << TagUnit
<< TagPatternName << TagPatternNum << TagCompanyName << TagCustomerName
<< TagSize << TagShowDate;
<< TagSize << TagShowDate << TagShowMeasurements;
PrepareForParse(parse);
QDomNode domNode = documentElement().firstChild();
while (domNode.isNull() == false)
@ -212,6 +212,9 @@ void VPattern::Parse(const Document &parse)
case 15:
qCDebug(vXML, "Show creation date");
break;
case 16:
qCDebug(vXML, "Show creation measurements");
break;
default:
qCDebug(vXML, "Wrong tag name %s", qUtf8Printable(domElement.tagName()));
break;

View File

@ -79,6 +79,7 @@
<xs:element name="customer" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="size" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="showDate" type="xs:boolean" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="showMeasurements" type="xs:boolean" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="measurements" type="xs:string"></xs:element>
<xs:element name="increments" minOccurs="0" maxOccurs="1">
<xs:complexType>

View File

@ -34,98 +34,98 @@
#include "../exception/vexceptionobjecterror.h"
#include "../vtools/tools/vdatatool.h"
const QString VAbstractPattern::TagPattern = QStringLiteral("pattern");
const QString VAbstractPattern::TagCalculation = QStringLiteral("calculation");
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");
const QString VAbstractPattern::TagMeasurements = QStringLiteral("measurements");
const QString VAbstractPattern::TagIncrements = QStringLiteral("increments");
const QString VAbstractPattern::TagIncrement = QStringLiteral("increment");
const QString VAbstractPattern::TagDraw = QStringLiteral("draw");
const QString VAbstractPattern::TagGroups = QStringLiteral("groups");
const QString VAbstractPattern::TagGroup = QStringLiteral("group");
const QString VAbstractPattern::TagGroupItem = QStringLiteral("item");
const QString VAbstractPattern::TagPoint = QStringLiteral("point");
const QString VAbstractPattern::TagLine = QStringLiteral("line");
const QString VAbstractPattern::TagSpline = QStringLiteral("spline");
const QString VAbstractPattern::TagArc = QStringLiteral("arc");
const QString VAbstractPattern::TagTools = QStringLiteral("tools");
const QString VAbstractPattern::TagOperation = QStringLiteral("operation");
const QString VAbstractPattern::TagGradation = QStringLiteral("gradation");
const QString VAbstractPattern::TagHeights = QStringLiteral("heights");
const QString VAbstractPattern::TagSizes = QStringLiteral("sizes");
const QString VAbstractPattern::TagUnit = QStringLiteral("unit");
const QString VAbstractPattern::TagData = QStringLiteral("data");
const QString VAbstractPattern::TagPatternInfo = QStringLiteral("patternInfo");
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::TagSize = QStringLiteral("size");
const QString VAbstractPattern::TagShowDate = QStringLiteral("showDate");
const QString VAbstractPattern::TagPattern = QStringLiteral("pattern");
const QString VAbstractPattern::TagCalculation = QStringLiteral("calculation");
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");
const QString VAbstractPattern::TagMeasurements = QStringLiteral("measurements");
const QString VAbstractPattern::TagIncrements = QStringLiteral("increments");
const QString VAbstractPattern::TagIncrement = QStringLiteral("increment");
const QString VAbstractPattern::TagDraw = QStringLiteral("draw");
const QString VAbstractPattern::TagGroups = QStringLiteral("groups");
const QString VAbstractPattern::TagGroup = QStringLiteral("group");
const QString VAbstractPattern::TagGroupItem = QStringLiteral("item");
const QString VAbstractPattern::TagPoint = QStringLiteral("point");
const QString VAbstractPattern::TagLine = QStringLiteral("line");
const QString VAbstractPattern::TagSpline = QStringLiteral("spline");
const QString VAbstractPattern::TagArc = QStringLiteral("arc");
const QString VAbstractPattern::TagTools = QStringLiteral("tools");
const QString VAbstractPattern::TagOperation = QStringLiteral("operation");
const QString VAbstractPattern::TagGradation = QStringLiteral("gradation");
const QString VAbstractPattern::TagHeights = QStringLiteral("heights");
const QString VAbstractPattern::TagSizes = QStringLiteral("sizes");
const QString VAbstractPattern::TagUnit = QStringLiteral("unit");
const QString VAbstractPattern::TagData = QStringLiteral("data");
const QString VAbstractPattern::TagPatternInfo = QStringLiteral("patternInfo");
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::TagSize = QStringLiteral("size");
const QString VAbstractPattern::TagShowDate = QStringLiteral("showDate");
const QString VAbstractPattern::TagShowMeasurements = QStringLiteral("showMeasurements");
const QString VAbstractPattern::AttrName = QStringLiteral("name");
const QString VAbstractPattern::AttrVisible = QStringLiteral("visible");
const QString VAbstractPattern::AttrObject = QStringLiteral("object");
const QString VAbstractPattern::AttrTool = QStringLiteral("tool");
const QString VAbstractPattern::AttrType = QStringLiteral("type");
const QString VAbstractPattern::AttrLetter = QStringLiteral("letter");
const QString VAbstractPattern::AttrMaterial = QStringLiteral("material");
const QString VAbstractPattern::AttrUserDefined = QStringLiteral("userDef");
const QString VAbstractPattern::AttrCutNumber = QStringLiteral("cutNumber");
const QString VAbstractPattern::AttrPlacement = QStringLiteral("placement");
const QString VAbstractPattern::AttrName = QStringLiteral("name");
const QString VAbstractPattern::AttrVisible = QStringLiteral("visible");
const QString VAbstractPattern::AttrObject = QStringLiteral("object");
const QString VAbstractPattern::AttrTool = QStringLiteral("tool");
const QString VAbstractPattern::AttrType = QStringLiteral("type");
const QString VAbstractPattern::AttrLetter = QStringLiteral("letter");
const QString VAbstractPattern::AttrMaterial = QStringLiteral("material");
const QString VAbstractPattern::AttrUserDefined = QStringLiteral("userDef");
const QString VAbstractPattern::AttrCutNumber = QStringLiteral("cutNumber");
const QString VAbstractPattern::AttrPlacement = QStringLiteral("placement");
const QString VAbstractPattern::AttrAll = QStringLiteral("all");
const QString VAbstractPattern::AttrAll = QStringLiteral("all");
const QString VAbstractPattern::AttrH92 = QStringLiteral("h92");
const QString VAbstractPattern::AttrH98 = QStringLiteral("h98");
const QString VAbstractPattern::AttrH104 = QStringLiteral("h104");
const QString VAbstractPattern::AttrH110 = QStringLiteral("h110");
const QString VAbstractPattern::AttrH116 = QStringLiteral("h116");
const QString VAbstractPattern::AttrH122 = QStringLiteral("h122");
const QString VAbstractPattern::AttrH128 = QStringLiteral("h128");
const QString VAbstractPattern::AttrH134 = QStringLiteral("h134");
const QString VAbstractPattern::AttrH140 = QStringLiteral("h140");
const QString VAbstractPattern::AttrH146 = QStringLiteral("h146");
const QString VAbstractPattern::AttrH152 = QStringLiteral("h152");
const QString VAbstractPattern::AttrH158 = QStringLiteral("h158");
const QString VAbstractPattern::AttrH164 = QStringLiteral("h164");
const QString VAbstractPattern::AttrH170 = QStringLiteral("h170");
const QString VAbstractPattern::AttrH176 = QStringLiteral("h176");
const QString VAbstractPattern::AttrH182 = QStringLiteral("h182");
const QString VAbstractPattern::AttrH188 = QStringLiteral("h188");
const QString VAbstractPattern::AttrH194 = QStringLiteral("h194");
const QString VAbstractPattern::AttrH92 = QStringLiteral("h92");
const QString VAbstractPattern::AttrH98 = QStringLiteral("h98");
const QString VAbstractPattern::AttrH104 = QStringLiteral("h104");
const QString VAbstractPattern::AttrH110 = QStringLiteral("h110");
const QString VAbstractPattern::AttrH116 = QStringLiteral("h116");
const QString VAbstractPattern::AttrH122 = QStringLiteral("h122");
const QString VAbstractPattern::AttrH128 = QStringLiteral("h128");
const QString VAbstractPattern::AttrH134 = QStringLiteral("h134");
const QString VAbstractPattern::AttrH140 = QStringLiteral("h140");
const QString VAbstractPattern::AttrH146 = QStringLiteral("h146");
const QString VAbstractPattern::AttrH152 = QStringLiteral("h152");
const QString VAbstractPattern::AttrH158 = QStringLiteral("h158");
const QString VAbstractPattern::AttrH164 = QStringLiteral("h164");
const QString VAbstractPattern::AttrH170 = QStringLiteral("h170");
const QString VAbstractPattern::AttrH176 = QStringLiteral("h176");
const QString VAbstractPattern::AttrH182 = QStringLiteral("h182");
const QString VAbstractPattern::AttrH188 = QStringLiteral("h188");
const QString VAbstractPattern::AttrH194 = QStringLiteral("h194");
const QString VAbstractPattern::AttrS22 = QStringLiteral("s22");
const QString VAbstractPattern::AttrS24 = QStringLiteral("s24");
const QString VAbstractPattern::AttrS26 = QStringLiteral("s26");
const QString VAbstractPattern::AttrS28 = QStringLiteral("s28");
const QString VAbstractPattern::AttrS30 = QStringLiteral("s30");
const QString VAbstractPattern::AttrS32 = QStringLiteral("s32");
const QString VAbstractPattern::AttrS34 = QStringLiteral("s34");
const QString VAbstractPattern::AttrS36 = QStringLiteral("s36");
const QString VAbstractPattern::AttrS38 = QStringLiteral("s38");
const QString VAbstractPattern::AttrS40 = QStringLiteral("s40");
const QString VAbstractPattern::AttrS42 = QStringLiteral("s42");
const QString VAbstractPattern::AttrS44 = QStringLiteral("s44");
const QString VAbstractPattern::AttrS46 = QStringLiteral("s46");
const QString VAbstractPattern::AttrS48 = QStringLiteral("s48");
const QString VAbstractPattern::AttrS50 = QStringLiteral("s50");
const QString VAbstractPattern::AttrS52 = QStringLiteral("s52");
const QString VAbstractPattern::AttrS54 = QStringLiteral("s54");
const QString VAbstractPattern::AttrS56 = QStringLiteral("s56");
const QString VAbstractPattern::AttrS22 = QStringLiteral("s22");
const QString VAbstractPattern::AttrS24 = QStringLiteral("s24");
const QString VAbstractPattern::AttrS26 = QStringLiteral("s26");
const QString VAbstractPattern::AttrS28 = QStringLiteral("s28");
const QString VAbstractPattern::AttrS30 = QStringLiteral("s30");
const QString VAbstractPattern::AttrS32 = QStringLiteral("s32");
const QString VAbstractPattern::AttrS34 = QStringLiteral("s34");
const QString VAbstractPattern::AttrS36 = QStringLiteral("s36");
const QString VAbstractPattern::AttrS38 = QStringLiteral("s38");
const QString VAbstractPattern::AttrS40 = QStringLiteral("s40");
const QString VAbstractPattern::AttrS42 = QStringLiteral("s42");
const QString VAbstractPattern::AttrS44 = QStringLiteral("s44");
const QString VAbstractPattern::AttrS46 = QStringLiteral("s46");
const QString VAbstractPattern::AttrS48 = QStringLiteral("s48");
const QString VAbstractPattern::AttrS50 = QStringLiteral("s50");
const QString VAbstractPattern::AttrS52 = QStringLiteral("s52");
const QString VAbstractPattern::AttrS54 = QStringLiteral("s54");
const QString VAbstractPattern::AttrS56 = QStringLiteral("s56");
const QString VAbstractPattern::AttrCustom = QStringLiteral("custom");
const QString VAbstractPattern::AttrDefHeight = QStringLiteral("defHeight");
const QString VAbstractPattern::AttrDefSize = QStringLiteral("defSize");
const QString VAbstractPattern::AttrExtension = QStringLiteral("extension");
const QString VAbstractPattern::AttrCustom = QStringLiteral("custom");
const QString VAbstractPattern::AttrDefHeight = QStringLiteral("defHeight");
const QString VAbstractPattern::AttrDefSize = QStringLiteral("defSize");
const QString VAbstractPattern::AttrExtension = QStringLiteral("extension");
const QString VAbstractPattern::IncrementName = QStringLiteral("name");
const QString VAbstractPattern::IncrementFormula = QStringLiteral("formula");
@ -1085,6 +1085,21 @@ void VAbstractPattern::SetDateVisible(bool bVisible)
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);
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractPattern::GetImage() const
{
@ -1199,7 +1214,7 @@ QDomElement VAbstractPattern::CheckTagExists(const QString &tag)
{
const QStringList tags = QStringList() << TagUnit << TagImage << TagAuthor << TagDescription << TagNotes
<< TagGradation << TagPatternName << TagPatternNum << TagCompanyName
<< TagCustomerName << TagSize << TagShowDate;
<< TagCustomerName << TagSize << TagShowDate << TagShowMeasurements;
switch (tags.indexOf(tag))
{
case 0: //TagUnit
@ -1270,6 +1285,11 @@ QDomElement VAbstractPattern::CheckTagExists(const QString &tag)
element = createElement(TagShowDate);
break;
}
case 12: // TagShowMeasurements
{
element = createElement(TagShowMeasurements);
break;
}
default:
{

View File

@ -120,6 +120,8 @@ public:
void SetPatternSize(const QString &qsSize);
bool IsDateVisible() const;
void SetDateVisible(bool bVisible);
bool IsMeasurementsVisible() const;
void SetMesurementsVisible(bool bVisible);
QString GetImage() const;
QString GetImageExtension() const;
@ -178,6 +180,7 @@ public:
static const QString TagCustomerName;
static const QString TagSize;
static const QString TagShowDate;
static const QString TagShowMeasurements;
static const QString AttrName;
static const QString AttrVisible;

View File

@ -141,6 +141,11 @@ bool VTextManager::IsBigEnough(qreal fW, qreal fH, int iFontSize)
QStringList qslLines = SplitString(tlOut.m_qsText, fW, fm);
for (int iL = 0; iL < qslLines.count(); ++iL)
{
// check if every line fits within the label width
if (fm.width(qslLines[iL]) + 2*GetSpacing() > fW)
{
return false;
}
tlOut.m_qsText = qslLines[iL];
m_liOutput << tlOut;
iY += tlOut.m_iHeight + GetSpacing();
@ -275,6 +280,15 @@ void VTextManager::Update(const VAbstractPattern *pDoc)
tl.m_iFontSize = 0;
AddLine(tl);
}
// Measurements
tl.m_qsText = pDoc->MPath();
if (tl.m_qsText.isEmpty() == false && pDoc->IsMeasurementsVisible() == true)
{
tl.m_eFontWeight = QFont::Normal;
tl.m_eStyle = QFont::StyleNormal;
tl.m_iFontSize = 0;
AddLine(tl);
}
// Date
QDate date;
if (pDoc->IsDateVisible() == true)
@ -317,7 +331,10 @@ QStringList VTextManager::SplitString(const QString &qs, qreal fW, const QFontMe
if (fm.width(qsCurrent + qslWords[i]) > fW)
{
// if not, add the current line into the list of text lines
qslLines << qsCurrent;
if (qsCurrent.isEmpty() == false)
{
qslLines << qsCurrent;
}
// and set the current line to contain the current word
qsCurrent = qslWords[i];
}