New field full name.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-07-25 11:54:39 +03:00
parent 7484d9e807
commit 5697d45b2d
5 changed files with 76 additions and 4 deletions

View File

@ -418,6 +418,10 @@ void TMainWindow::Remove()
ui->plainTextEditDescription->setPlainText(""); ui->plainTextEditDescription->setPlainText("");
ui->plainTextEditDescription->blockSignals(false); ui->plainTextEditDescription->blockSignals(false);
ui->lineEditFullName->blockSignals(true);
ui->lineEditFullName->setText("");
ui->lineEditFullName->blockSignals(false);
if (mType == MeasurementsType::Standard) if (mType == MeasurementsType::Standard)
{ {
ui->labelCalculatedValue->blockSignals(true); ui->labelCalculatedValue->blockSignals(true);
@ -664,6 +668,10 @@ void TMainWindow::ShowMData()
} }
ui->plainTextEditDescription->blockSignals(false); ui->plainTextEditDescription->blockSignals(false);
ui->lineEditFullName->blockSignals(true);
ui->lineEditFullName->setText(meash->GetGuiText());
ui->lineEditFullName->blockSignals(false);
if (mType == MeasurementsType::Standard) if (mType == MeasurementsType::Standard)
{ {
ui->labelCalculatedValue->blockSignals(true); ui->labelCalculatedValue->blockSignals(true);
@ -936,6 +944,29 @@ void TMainWindow::SaveMDescription()
ui->plainTextEditDescription->setTextCursor(cursor); ui->plainTextEditDescription->setTextCursor(cursor);
} }
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SaveMFullName()
{
const int row = ui->tableWidget->currentRow();
if (row == -1)
{
return;
}
QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), 0);
m->SetMFullName(nameField->text(), ui->lineEditFullName->text());
MeasurementsWasSaved(false);
RefreshData();
ui->tableWidget->blockSignals(true);
ui->tableWidget->selectRow(row);
ui->tableWidget->blockSignals(false);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TMainWindow::SetupMenu() void TMainWindow::SetupMenu()
{ {
@ -1097,6 +1128,7 @@ void TMainWindow::InitWindow()
connect(ui->lineEditName, &QLineEdit::editingFinished, this, &TMainWindow::SaveMName); connect(ui->lineEditName, &QLineEdit::editingFinished, this, &TMainWindow::SaveMName);
connect(ui->plainTextEditDescription, &QPlainTextEdit::textChanged, this, &TMainWindow::SaveMDescription); connect(ui->plainTextEditDescription, &QPlainTextEdit::textChanged, this, &TMainWindow::SaveMDescription);
connect(ui->lineEditFullName, &QLineEdit::editingFinished, this, &TMainWindow::SaveMFullName);
InitTable(); InitTable();
} }
@ -1391,6 +1423,7 @@ void TMainWindow::MFields(bool enabled)
{ {
ui->lineEditName->setEnabled(enabled); ui->lineEditName->setEnabled(enabled);
ui->plainTextEditDescription->setEnabled(enabled); ui->plainTextEditDescription->setEnabled(enabled);
ui->lineEditFullName->setEnabled(enabled);
if (mType == MeasurementsType::Standard) if (mType == MeasurementsType::Standard)
{ {

View File

@ -94,6 +94,7 @@ private slots:
void SaveMSizeIncrease(double value); void SaveMSizeIncrease(double value);
void SaveMHeightIncrease(double value); void SaveMHeightIncrease(double value);
void SaveMDescription(); void SaveMDescription();
void SaveMFullName();
private: private:
Q_DISABLE_COPY(TMainWindow) Q_DISABLE_COPY(TMainWindow)

View File

@ -233,14 +233,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="0"> <item row="10" column="0">
<widget class="QLabel" name="label_7"> <widget class="QLabel" name="label_7">
<property name="text"> <property name="text">
<string>Description:</string> <string>Description:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="1"> <item row="10" column="1">
<widget class="QPlainTextEdit" name="plainTextEditDescription"> <widget class="QPlainTextEdit" name="plainTextEditDescription">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@ -365,6 +365,20 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="0">
<widget class="QLabel" name="labelFullName">
<property name="text">
<string>Full name:</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QLineEdit" name="lineEditFullName">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@ -54,6 +54,7 @@ const QString VMeasurements::AttrSizeIncrease = QStringLiteral("size_increase"
const QString VMeasurements::AttrHeightIncrease = QStringLiteral("height_increase"); const QString VMeasurements::AttrHeightIncrease = QStringLiteral("height_increase");
const QString VMeasurements::AttrDescription = QStringLiteral("description"); const QString VMeasurements::AttrDescription = QStringLiteral("description");
const QString VMeasurements::AttrName = QStringLiteral("name"); const QString VMeasurements::AttrName = QStringLiteral("name");
const QString VMeasurements::AttrFullName = QStringLiteral("full_name");
const QString VMeasurements::SexMale = QStringLiteral("male"); const QString VMeasurements::SexMale = QStringLiteral("male");
const QString VMeasurements::SexFemale = QStringLiteral("female"); const QString VMeasurements::SexFemale = QStringLiteral("female");
@ -179,6 +180,16 @@ void VMeasurements::ReadMeasurements() const
Q_UNUSED(e) Q_UNUSED(e)
} }
QString fullName;
try
{
fullName = GetParametrString(dom, AttrFullName);
}
catch (VExceptionEmptyParameter &e)
{
Q_UNUSED(e)
}
VMeasurement *meash; VMeasurement *meash;
if (type == MeasurementsType::Standard) if (type == MeasurementsType::Standard)
{ {
@ -186,14 +197,14 @@ void VMeasurements::ReadMeasurements() const
const qreal ksize = GetParametrDouble(dom, AttrSizeIncrease, "0"); const qreal ksize = GetParametrDouble(dom, AttrSizeIncrease, "0");
const qreal kheight = GetParametrDouble(dom, AttrHeightIncrease, "0"); const qreal kheight = GetParametrDouble(dom, AttrHeightIncrease, "0");
meash = new VMeasurement(i, name, BaseSize(), BaseHeight(), base, ksize, kheight, "", description); meash = new VMeasurement(i, name, BaseSize(), BaseHeight(), base, ksize, kheight, fullName, description);
} }
else else
{ {
QString formula = GetParametrString(dom, AttrValue, "0"); QString formula = GetParametrString(dom, AttrValue, "0");
bool ok = false; bool ok = false;
const qreal value = EvalFormula(data, formula, &ok); const qreal value = EvalFormula(data, formula, &ok);
meash = new VMeasurement(data, i, name, value, formula, ok, "", description); meash = new VMeasurement(data, i, name, value, formula, ok, fullName, description);
} }
data->AddVariable(name, meash); data->AddVariable(name, meash);
} }
@ -415,6 +426,16 @@ void VMeasurements::SetMDescription(const QString &name, const QString &text)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void VMeasurements::SetMFullName(const QString &name, const QString &text)
{
QDomElement node = FindM(name);
if (not node.isNull())
{
SetAttribute(node, AttrFullName, text);
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VMeasurements::GenderToStr(const SexType &sex) QString VMeasurements::GenderToStr(const SexType &sex)
{ {
@ -566,6 +587,7 @@ QDomElement VMeasurements::MakeEmpty(const QString &name)
{ {
SetAttribute(element, AttrValue, QString("0")); SetAttribute(element, AttrValue, QString("0"));
SetAttribute(element, AttrDescription, QString("")); SetAttribute(element, AttrDescription, QString(""));
SetAttribute(element, AttrFullName, QString(""));
} }
return element; return element;

View File

@ -83,6 +83,7 @@ public:
void SetMSizeIncrease(const QString &name, double value); void SetMSizeIncrease(const QString &name, double value);
void SetMHeightIncrease(const QString &name, double value); void SetMHeightIncrease(const QString &name, double value);
void SetMDescription(const QString &name, const QString &text); void SetMDescription(const QString &name, const QString &text);
void SetMFullName(const QString &name, const QString &text);
static const QString TagVST; static const QString TagVST;
static const QString TagVIT; static const QString TagVIT;
@ -106,6 +107,7 @@ public:
static const QString AttrHeightIncrease; static const QString AttrHeightIncrease;
static const QString AttrDescription; static const QString AttrDescription;
static const QString AttrName; static const QString AttrName;
static const QString AttrFullName;
static const QString SexMale; static const QString SexMale;
static const QString SexFemale; static const QString SexFemale;