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->labelCreationDate->setText(QDate::currentDate().toString(Qt::SystemLocaleLongDate));
ui->lineEditSize->setText(doc->GetPatternSize()); ui->lineEditSize->setText(doc->GetPatternSize());
ui->checkBoxShowDate->setChecked(doc->IsDateVisible()); ui->checkBoxShowDate->setChecked(doc->IsDateVisible());
ui->checkBoxShowMeasurements->setChecked(doc->IsMeasurementsVisible());
connect(ui->lineEditPatternName, &QLineEdit::editingFinished, this, &DialogPatternProperties::GeneralInfoChanged); connect(ui->lineEditPatternName, &QLineEdit::editingFinished, this, &DialogPatternProperties::GeneralInfoChanged);
connect(ui->lineEditPatternNumber, &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->SetCustomerName(ui->lineEditCustomerName->text());
doc->SetPatternSize(ui->lineEditSize->text()); doc->SetPatternSize(ui->lineEditSize->text());
doc->SetDateVisible(ui->checkBoxShowDate->isChecked()); doc->SetDateVisible(ui->checkBoxShowDate->isChecked());
doc->SetMesurementsVisible(ui->checkBoxShowMeasurements->isChecked());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View file

@ -1053,7 +1053,7 @@
<x>10</x> <x>10</x>
<y>10</y> <y>10</y>
<width>401</width> <width>401</width>
<height>221</height> <height>241</height>
</rect> </rect>
</property> </property>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
@ -1068,7 +1068,11 @@
</widget> </widget>
</item> </item>
<item row="2" column="1"> <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>
<item row="3" column="0"> <item row="3" column="0">
<widget class="QLabel" name="label_7"> <widget class="QLabel" name="label_7">
@ -1078,7 +1082,11 @@
</widget> </widget>
</item> </item>
<item row="3" column="1"> <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>
<item row="4" column="0"> <item row="4" column="0">
<widget class="QLabel" name="label_8"> <widget class="QLabel" name="label_8">
@ -1088,7 +1096,11 @@
</widget> </widget>
</item> </item>
<item row="4" column="1"> <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>
<item row="5" column="0"> <item row="5" column="0">
<widget class="QLabel" name="label_10"> <widget class="QLabel" name="label_10">
@ -1098,7 +1110,11 @@
</widget> </widget>
</item> </item>
<item row="5" column="1"> <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>
<item row="7" column="1"> <item row="7" column="1">
<widget class="QLabel" name="labelCreationDate"> <widget class="QLabel" name="labelCreationDate">
@ -1122,9 +1138,20 @@
</widget> </widget>
</item> </item>
<item row="6" column="1"> <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>
<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"> <widget class="QCheckBox" name="checkBoxShowDate">
<property name="text"> <property name="text">
<string>Show date of creation</string> <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 QStringList tags = QStringList() << TagDraw << TagIncrements << TagAuthor << TagDescription << TagNotes
<< TagMeasurements << TagVersion << TagGradation << TagImage << TagUnit << TagMeasurements << TagVersion << TagGradation << TagImage << TagUnit
<< TagPatternName << TagPatternNum << TagCompanyName << TagCustomerName << TagPatternName << TagPatternNum << TagCompanyName << TagCustomerName
<< TagSize << TagShowDate; << TagSize << TagShowDate << TagShowMeasurements;
PrepareForParse(parse); PrepareForParse(parse);
QDomNode domNode = documentElement().firstChild(); QDomNode domNode = documentElement().firstChild();
while (domNode.isNull() == false) while (domNode.isNull() == false)
@ -212,6 +212,9 @@ void VPattern::Parse(const Document &parse)
case 15: case 15:
qCDebug(vXML, "Show creation date"); qCDebug(vXML, "Show creation date");
break; break;
case 16:
qCDebug(vXML, "Show creation measurements");
break;
default: default:
qCDebug(vXML, "Wrong tag name %s", qUtf8Printable(domElement.tagName())); qCDebug(vXML, "Wrong tag name %s", qUtf8Printable(domElement.tagName()));
break; break;

View file

@ -79,6 +79,7 @@
<xs:element name="customer" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element> <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="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="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="measurements" type="xs:string"></xs:element>
<xs:element name="increments" minOccurs="0" maxOccurs="1"> <xs:element name="increments" minOccurs="0" maxOccurs="1">
<xs:complexType> <xs:complexType>

View file

@ -69,7 +69,7 @@ const QString VAbstractPattern::TagCustomerName = QStringLiteral("customer");
const QString VAbstractPattern::TagCompanyName = QStringLiteral("company"); const QString VAbstractPattern::TagCompanyName = QStringLiteral("company");
const QString VAbstractPattern::TagSize = QStringLiteral("size"); const QString VAbstractPattern::TagSize = QStringLiteral("size");
const QString VAbstractPattern::TagShowDate = QStringLiteral("showDate"); const QString VAbstractPattern::TagShowDate = QStringLiteral("showDate");
const QString VAbstractPattern::TagShowMeasurements = QStringLiteral("showMeasurements");
const QString VAbstractPattern::AttrName = QStringLiteral("name"); const QString VAbstractPattern::AttrName = QStringLiteral("name");
const QString VAbstractPattern::AttrVisible = QStringLiteral("visible"); const QString VAbstractPattern::AttrVisible = QStringLiteral("visible");
@ -1085,6 +1085,21 @@ void VAbstractPattern::SetDateVisible(bool bVisible)
emit patternChanged(false); 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 QString VAbstractPattern::GetImage() const
{ {
@ -1199,7 +1214,7 @@ QDomElement VAbstractPattern::CheckTagExists(const QString &tag)
{ {
const QStringList tags = QStringList() << TagUnit << TagImage << TagAuthor << TagDescription << TagNotes const QStringList tags = QStringList() << TagUnit << TagImage << TagAuthor << TagDescription << TagNotes
<< TagGradation << TagPatternName << TagPatternNum << TagCompanyName << TagGradation << TagPatternName << TagPatternNum << TagCompanyName
<< TagCustomerName << TagSize << TagShowDate; << TagCustomerName << TagSize << TagShowDate << TagShowMeasurements;
switch (tags.indexOf(tag)) switch (tags.indexOf(tag))
{ {
case 0: //TagUnit case 0: //TagUnit
@ -1270,6 +1285,11 @@ QDomElement VAbstractPattern::CheckTagExists(const QString &tag)
element = createElement(TagShowDate); element = createElement(TagShowDate);
break; break;
} }
case 12: // TagShowMeasurements
{
element = createElement(TagShowMeasurements);
break;
}
default: default:
{ {

View file

@ -120,6 +120,8 @@ public:
void SetPatternSize(const QString &qsSize); void SetPatternSize(const QString &qsSize);
bool IsDateVisible() const; bool IsDateVisible() const;
void SetDateVisible(bool bVisible); void SetDateVisible(bool bVisible);
bool IsMeasurementsVisible() const;
void SetMesurementsVisible(bool bVisible);
QString GetImage() const; QString GetImage() const;
QString GetImageExtension() const; QString GetImageExtension() const;
@ -178,6 +180,7 @@ public:
static const QString TagCustomerName; static const QString TagCustomerName;
static const QString TagSize; static const QString TagSize;
static const QString TagShowDate; static const QString TagShowDate;
static const QString TagShowMeasurements;
static const QString AttrName; static const QString AttrName;
static const QString AttrVisible; 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); QStringList qslLines = SplitString(tlOut.m_qsText, fW, fm);
for (int iL = 0; iL < qslLines.count(); ++iL) 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]; tlOut.m_qsText = qslLines[iL];
m_liOutput << tlOut; m_liOutput << tlOut;
iY += tlOut.m_iHeight + GetSpacing(); iY += tlOut.m_iHeight + GetSpacing();
@ -275,6 +280,15 @@ void VTextManager::Update(const VAbstractPattern *pDoc)
tl.m_iFontSize = 0; tl.m_iFontSize = 0;
AddLine(tl); 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 // Date
QDate date; QDate date;
if (pDoc->IsDateVisible() == true) 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 (fm.width(qsCurrent + qslWords[i]) > fW)
{ {
// if not, add the current line into the list of text lines // if not, add the current line into the list of text lines
if (qsCurrent.isEmpty() == false)
{
qslLines << qsCurrent; qslLines << qsCurrent;
}
// and set the current line to contain the current word // and set the current line to contain the current word
qsCurrent = qslWords[i]; qsCurrent = qslWords[i];
} }