Fixed issue #253. Add description, id, size base and height base to Table of

Variables.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-02-26 11:26:43 +02:00
parent 72324c0942
commit 326a790044
5 changed files with 83 additions and 17 deletions

View File

@ -100,6 +100,27 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
if (qApp->patternType() == MeasurementsType::Standard) if (qApp->patternType() == MeasurementsType::Standard)
{ {
ui->toolBoxMeasurements->setItemEnabled(0, false); ui->toolBoxMeasurements->setItemEnabled(0, false);
const QString filePath = doc->MPath();
VStandardMeasurements *mSt;
try
{
VDomDocument::ValidateXML("://schema/standard_measurements.xsd", filePath);
mSt = new VStandardMeasurements(data);
mSt->setXMLContent(filePath);
ui->labelBaseValues->setText(tr("Base size: %1 %3; Base height: %2 %3").arg(mSt->Size())
.arg(mSt->Height()).arg(VDomDocument::UnitsToStr(qApp->patternUnit())));
ui->labelDescription->setText(tr("Description: \"%1\"").arg(mSt->TrDescription()));
delete mSt;
}
catch (VException &e)
{
e.CriticalMessageBox(tr("File error."), this);
delete mSt;
emit DialogClosed(QDialog::Rejected);
return;
}
} }
else else
{ {
@ -133,6 +154,10 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
connect(ui->comboBoxSex, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, connect(ui->comboBoxSex, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogIncrements::SaveSex); &DialogIncrements::SaveSex);
connect(ui->dateEditBirthDate, &QDateEdit::dateChanged, this, &DialogIncrements::SaveBirthDate); connect(ui->dateEditBirthDate, &QDateEdit::dateChanged, this, &DialogIncrements::SaveBirthDate);
// hide fileds that don't exist in individual measurements
ui->labelBaseValues->setVisible(false);
ui->labelDescription->setVisible(false);
} }
ui->toolBoxMeasurements->setCurrentIndex(1); ui->toolBoxMeasurements->setCurrentIndex(1);

View File

@ -118,8 +118,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>559</width> <width>939</width>
<height>82</height> <height>411</height>
</rect> </rect>
</property> </property>
<attribute name="icon"> <attribute name="icon">
@ -290,6 +290,23 @@
<string>Measurements</string> <string>Measurements</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="labelBaseValues">
<property name="text">
<string notr="true">Base size: ; base height: </string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelDescription">
<property name="text">
<string notr="true">Description:</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item> <item>
<widget class="QCheckBox" name="checkBoxHideEmpty"> <widget class="QCheckBox" name="checkBoxHideEmpty">
<property name="text"> <property name="text">

View File

@ -183,16 +183,11 @@ void DialogStandardMeasurements::LoadStandardTables()
} }
else else
{ {
const QString trDesc = qApp->STDescription(m.Id()); const QString desc = m.TrDescription();
if (trDesc.isEmpty() == false) if (desc.isEmpty() == false)
{ {
qCDebug(vStMeasur)<<"Adding user table from"<<fi.absoluteFilePath(); qCDebug(vStMeasur)<<"Adding table from"<<fi.absoluteFilePath();
ui->comboBoxTables->addItem(trDesc, QVariant(fi.absoluteFilePath())); ui->comboBoxTables->addItem(desc, QVariant(fi.absoluteFilePath()));
}
else if (m.Description().isEmpty() == false)
{
qCDebug(vStMeasur)<<"Adding table with id"<<m.Id()<<"from"<<fi.absoluteFilePath();
ui->comboBoxTables->addItem(m.Description(), QVariant(fi.absoluteFilePath()));
} }
} }
} }

View File

@ -51,7 +51,7 @@ VStandardMeasurements::~VStandardMeasurements()
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VStandardMeasurements::Description() QString VStandardMeasurements::OrigDescription ()
{ {
const QString desc = UniqueTagText(TagDescription, ""); const QString desc = UniqueTagText(TagDescription, "");
if (desc.isEmpty()) if (desc.isEmpty())
@ -61,6 +61,20 @@ QString VStandardMeasurements::Description()
return desc; return desc;
} }
//---------------------------------------------------------------------------------------------------------------------
QString VStandardMeasurements::TrDescription()
{
const QString trDesc = qApp->STDescription(Id());
if (trDesc.isEmpty() == false)
{
return trDesc;
}
else
{
return OrigDescription ();
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VStandardMeasurements::Id() QString VStandardMeasurements::Id()
{ {
@ -72,6 +86,18 @@ QString VStandardMeasurements::Id()
return id; return id;
} }
//---------------------------------------------------------------------------------------------------------------------
qreal VStandardMeasurements::Size() const
{
return TakeParametr(TagSize, AttrBase, 50);
}
//---------------------------------------------------------------------------------------------------------------------
qreal VStandardMeasurements::Height() const
{
return TakeParametr(TagHeight, AttrBase, 176);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VStandardMeasurements::ReadMeasurement(const QDomElement &domElement, const QString &tag) void VStandardMeasurements::ReadMeasurement(const QDomElement &domElement, const QString &tag)
{ {
@ -124,15 +150,13 @@ qreal VStandardMeasurements::TakeParametr(const QString &tag, const QString &att
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VStandardMeasurements::SetSize() void VStandardMeasurements::SetSize()
{ {
const qreal value = TakeParametr(TagSize, AttrBase, 50); data->SetSize(Size());
data->SetSize(value);
data->SetSizeName(size_M); data->SetSizeName(size_M);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VStandardMeasurements::SetHeight() void VStandardMeasurements::SetHeight()
{ {
const qreal value = TakeParametr(TagHeight, AttrBase, 176); data->SetHeight(Height());
data->SetHeight(value);
data->SetHeightName(height_M); data->SetHeightName(height_M);
} }

View File

@ -44,8 +44,13 @@ class VStandardMeasurements:public VAbstractMeasurements
public: public:
VStandardMeasurements(VContainer *data); VStandardMeasurements(VContainer *data);
virtual ~VStandardMeasurements(); virtual ~VStandardMeasurements();
QString Description(); QString OrigDescription ();
QString TrDescription ();
QString Id(); QString Id();
qreal Size() const;
qreal Height() const;
void SetSize(); void SetSize();
void SetHeight(); void SetHeight();
static const QString TagMeasurement; static const QString TagMeasurement;