Show fields for known neasurements.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-08-01 17:36:56 +03:00
parent 78329af822
commit 32ec3fd83c
3 changed files with 40 additions and 13 deletions

View File

@ -769,33 +769,42 @@ void TMainWindow::ChangedHeight(const QString &text)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void TMainWindow::ShowMData() void TMainWindow::ShowMData()
{ {
Controls(); // Buttons remove, up, down
if (ui->tableWidget->rowCount() > 0) if (ui->tableWidget->rowCount() > 0)
{ {
ui->groupBoxDetails->setEnabled(true); ui->groupBoxDetails->setEnabled(true);
QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), 0); QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), 0); // name
QSharedPointer<VMeasurement> meash = data->GetVariable<VMeasurement>(nameField->text()); QSharedPointer<VMeasurement> meash;
try
{
meash = data->GetVariable<VMeasurement>(qApp->TrVars()->MFromUser(nameField->text()));
}
catch(const VExceptionBadId &e)
{
Q_UNUSED(e);
ui->groupBoxDetails->setEnabled(false);
return;
}
ui->lineEditName->blockSignals(true); ui->lineEditName->blockSignals(true);
ui->lineEditName->setText(ClearCustomName(meash->GetName()));
ui->lineEditName->blockSignals(false);
ui->plainTextEditDescription->blockSignals(true); ui->plainTextEditDescription->blockSignals(true);
ui->lineEditFullName->blockSignals(true);
if (meash->IsCustom()) if (meash->IsCustom())
{ {
ui->plainTextEditDescription->setPlainText(meash->GetDescription()); ui->plainTextEditDescription->setPlainText(meash->GetDescription());
ui->lineEditFullName->setText(meash->GetGuiText());
ui->lineEditName->setText(ClearCustomName(meash->GetName()));
} }
else else
{ {
//Show from known description //Show known
ui->plainTextEditDescription->setPlainText(""); ui->plainTextEditDescription->setPlainText(qApp->TrVars()->Description(meash->GetName()));
ui->lineEditFullName->setText(qApp->TrVars()->GuiText(meash->GetName()));
ui->lineEditName->setText(nameField->text());
} }
ui->lineEditName->blockSignals(false);
ui->plainTextEditDescription->blockSignals(false); ui->plainTextEditDescription->blockSignals(false);
ui->lineEditFullName->blockSignals(true);
ui->lineEditFullName->setText(meash->GetGuiText());
ui->lineEditFullName->blockSignals(false); ui->lineEditFullName->blockSignals(false);
if (mType == MeasurementsType::Standard) if (mType == MeasurementsType::Standard)
@ -805,7 +814,7 @@ void TMainWindow::ShowMData()
ui->doubleSpinBoxInSizes->blockSignals(true); ui->doubleSpinBoxInSizes->blockSignals(true);
ui->doubleSpinBoxInHeights->blockSignals(true); ui->doubleSpinBoxInHeights->blockSignals(true);
ui->labelCalculatedValue->setText(QString().setNum(data->GetTableValue(nameField->text(), mType))); ui->labelCalculatedValue->setText(QString().setNum(data->GetTableValue(meash->GetName(), mType)));
ui->doubleSpinBoxBaseValue->setValue(static_cast<int>(meash->GetBase())); ui->doubleSpinBoxBaseValue->setValue(static_cast<int>(meash->GetBase()));
ui->doubleSpinBoxInSizes->setValue(static_cast<int>(meash->GetKsize())); ui->doubleSpinBoxInSizes->setValue(static_cast<int>(meash->GetKsize()));
ui->doubleSpinBoxInHeights->setValue(static_cast<int>(meash->GetKheight())); ui->doubleSpinBoxInHeights->setValue(static_cast<int>(meash->GetKheight()));
@ -862,6 +871,8 @@ void TMainWindow::ShowMData()
ui->lineEditFullName->setReadOnly(true); ui->lineEditFullName->setReadOnly(true);
} }
} }
Controls(); // Buttons remove, up, down
} }
} }

View File

@ -393,6 +393,21 @@ QString VTranslateVars::MToUser(const QString &measurement) const
return measurements.value(measurement).translate(); return measurements.value(measurement).translate();
} }
//---------------------------------------------------------------------------------------------------------------------
QString VTranslateVars::MFromUser(const QString &measurement) const
{
QMap<QString, QmuTranslation>::const_iterator i = measurements.constBegin();
while (i != measurements.constEnd())
{
if (measurement == i.value().translate())
{
return i.key();
}
++i;
}
return measurement;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VTranslateVars::MNumber(const QString &measurement) const QString VTranslateVars::MNumber(const QString &measurement) const
{ {

View File

@ -48,6 +48,7 @@ public:
QString VarFromUser(const QString &var) const; QString VarFromUser(const QString &var) const;
QString MToUser(const QString &measurement) const; QString MToUser(const QString &measurement) const;
QString MFromUser(const QString &measurement) const;
QString MNumber(const QString &measurement) const; QString MNumber(const QString &measurement) const;
QString MFormula(const QString &measurement) const; QString MFormula(const QString &measurement) const;
QString GuiText(const QString &measurement) const; QString GuiText(const QString &measurement) const;