Disable fields if a list is empty.
--HG-- branch : develop
This commit is contained in:
parent
b4c1e68eb4
commit
da077a5b59
|
@ -621,7 +621,7 @@ void TMainWindow::Remove()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui->groupBoxDetails->setEnabled(false);
|
MFields(false);
|
||||||
|
|
||||||
ui->lineEditName->blockSignals(true);
|
ui->lineEditName->blockSignals(true);
|
||||||
ui->lineEditName->setText("");
|
ui->lineEditName->setText("");
|
||||||
|
@ -815,6 +815,8 @@ void TMainWindow::AddKnown()
|
||||||
ui->tableWidget->selectRow(currentRow);
|
ui->tableWidget->selectRow(currentRow);
|
||||||
|
|
||||||
MeasurementsWasSaved(false);
|
MeasurementsWasSaved(false);
|
||||||
|
|
||||||
|
MFields(ui->tableWidget->rowCount() > 0);
|
||||||
}
|
}
|
||||||
delete dialog;
|
delete dialog;
|
||||||
}
|
}
|
||||||
|
@ -932,7 +934,7 @@ void TMainWindow::ShowMData()
|
||||||
{
|
{
|
||||||
if (ui->tableWidget->rowCount() > 0)
|
if (ui->tableWidget->rowCount() > 0)
|
||||||
{
|
{
|
||||||
ui->groupBoxDetails->setEnabled(true);
|
MFields(true);
|
||||||
|
|
||||||
QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), 0); // name
|
QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), 0); // name
|
||||||
QSharedPointer<VMeasurement> meash;
|
QSharedPointer<VMeasurement> meash;
|
||||||
|
@ -944,7 +946,7 @@ void TMainWindow::ShowMData()
|
||||||
catch(const VExceptionBadId &e)
|
catch(const VExceptionBadId &e)
|
||||||
{
|
{
|
||||||
Q_UNUSED(e);
|
Q_UNUSED(e);
|
||||||
ui->groupBoxDetails->setEnabled(false);
|
MFields(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1009,35 +1011,12 @@ void TMainWindow::ShowMData()
|
||||||
ui->plainTextEditFormula->blockSignals(false);
|
ui->plainTextEditFormula->blockSignals(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m->ReadOnly())
|
MeasurementReadOnly(m->ReadOnly());
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
MFields(false);
|
MFields(false);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
MFields(true);
|
|
||||||
|
|
||||||
if (mType == MeasurementsType::Individual)
|
|
||||||
{
|
|
||||||
ui->plainTextEditFormula->setReadOnly(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (meash->IsCustom())
|
|
||||||
{
|
|
||||||
ui->plainTextEditDescription->setReadOnly(false);
|
|
||||||
ui->lineEditName->setReadOnly(false);
|
|
||||||
ui->lineEditFullName->setReadOnly(false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ui->plainTextEditDescription->setReadOnly(true);
|
|
||||||
ui->lineEditName->setReadOnly(true);
|
|
||||||
ui->lineEditFullName->setReadOnly(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Controls(); // Buttons remove, up, down
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -1817,6 +1796,10 @@ void TMainWindow::Controls()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void TMainWindow::MFields(bool enabled)
|
void TMainWindow::MFields(bool enabled)
|
||||||
{
|
{
|
||||||
|
ui->lineEditName->setEnabled(enabled);
|
||||||
|
ui->plainTextEditDescription->setEnabled(enabled);
|
||||||
|
ui->lineEditFullName->setEnabled(enabled);
|
||||||
|
|
||||||
if (mType == MeasurementsType::Standard)
|
if (mType == MeasurementsType::Standard)
|
||||||
{
|
{
|
||||||
ui->doubleSpinBoxBaseValue->setEnabled(enabled);
|
ui->doubleSpinBoxBaseValue->setEnabled(enabled);
|
||||||
|
@ -1825,6 +1808,7 @@ void TMainWindow::MFields(bool enabled)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
ui->plainTextEditFormula->setEnabled(enabled);
|
||||||
ui->pushButtonGrow->setEnabled(enabled);
|
ui->pushButtonGrow->setEnabled(enabled);
|
||||||
ui->toolButtonExpr->setEnabled(enabled);
|
ui->toolButtonExpr->setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
@ -1912,30 +1896,10 @@ void TMainWindow::GUIReadOnly(bool ro)
|
||||||
ui->actionReadOnly->setIcon(QIcon("://tapeicon/24x24/padlock_opened.png"));
|
ui->actionReadOnly->setIcon(QIcon("://tapeicon/24x24/padlock_opened.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->plainTextEditNotes->setReadOnly(ro);
|
|
||||||
ui->actionAddCustom->setDisabled(ro);
|
ui->actionAddCustom->setDisabled(ro);
|
||||||
ui->actionAddKnown->setDisabled(ro);
|
ui->actionAddKnown->setDisabled(ro);
|
||||||
|
|
||||||
ui->lineEditName->setDisabled(false);
|
ui->plainTextEditNotes->setReadOnly(ro);
|
||||||
if (not ro)
|
|
||||||
{
|
|
||||||
if (QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), 0))
|
|
||||||
{
|
|
||||||
if (nameField->text().indexOf(CustomMSign) == 0) // Check if custom
|
|
||||||
{
|
|
||||||
ui->lineEditName->setReadOnly(ro);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ui->lineEditName->setReadOnly(ro);
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->plainTextEditDescription->setDisabled(false);
|
|
||||||
ui->plainTextEditDescription->setReadOnly(ro);
|
|
||||||
ui->lineEditFullName->setDisabled(false);
|
|
||||||
ui->lineEditFullName->setReadOnly(ro);
|
|
||||||
|
|
||||||
if (mType == MeasurementsType::Individual)
|
if (mType == MeasurementsType::Individual)
|
||||||
{
|
{
|
||||||
|
@ -1944,18 +1908,52 @@ void TMainWindow::GUIReadOnly(bool ro)
|
||||||
ui->dateEditBirthDate->setReadOnly(ro);
|
ui->dateEditBirthDate->setReadOnly(ro);
|
||||||
ui->comboBoxSex->setDisabled(ro);
|
ui->comboBoxSex->setDisabled(ro);
|
||||||
ui->lineEditEmail->setReadOnly(ro);
|
ui->lineEditEmail->setReadOnly(ro);
|
||||||
|
}
|
||||||
|
|
||||||
ui->plainTextEditFormula->setDisabled(false);
|
MeasurementReadOnly(ro);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void TMainWindow::MeasurementReadOnly(bool ro)
|
||||||
|
{
|
||||||
|
if (ro == false)
|
||||||
|
{
|
||||||
|
if (QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), 0))
|
||||||
|
{
|
||||||
|
if (nameField->text().indexOf(CustomMSign) == 0) // Check if custom
|
||||||
|
{
|
||||||
|
ui->lineEditName->setReadOnly(ro);
|
||||||
|
ui->plainTextEditDescription->setReadOnly(ro);
|
||||||
|
ui->lineEditFullName->setReadOnly(ro);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // known measurement
|
||||||
|
ui->lineEditName->setReadOnly(not ro);
|
||||||
|
ui->plainTextEditDescription->setReadOnly(not ro);
|
||||||
|
ui->lineEditFullName->setReadOnly(not ro);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->lineEditName->setReadOnly(ro);
|
||||||
|
ui->plainTextEditDescription->setReadOnly(ro);
|
||||||
|
ui->lineEditFullName->setReadOnly(ro);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mType == MeasurementsType::Individual)
|
||||||
|
{
|
||||||
ui->plainTextEditFormula->setReadOnly(ro);
|
ui->plainTextEditFormula->setReadOnly(ro);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui->doubleSpinBoxBaseValue->setDisabled(ro);
|
ui->doubleSpinBoxBaseValue->setReadOnly(ro);
|
||||||
ui->doubleSpinBoxInSizes->setDisabled(ro);
|
ui->doubleSpinBoxInSizes->setReadOnly(ro);
|
||||||
ui->doubleSpinBoxInHeights->setDisabled(ro);
|
ui->doubleSpinBoxInHeights->setReadOnly(ro);
|
||||||
|
|
||||||
gradationHeights->setDisabled(ro);
|
|
||||||
gradationSizes->setDisabled(ro);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Controls(); // Buttons remove, up, down
|
Controls(); // Buttons remove, up, down
|
||||||
|
|
|
@ -162,15 +162,15 @@ private:
|
||||||
void RefreshData();
|
void RefreshData();
|
||||||
void RefreshTable();
|
void RefreshTable();
|
||||||
|
|
||||||
void Controls();
|
|
||||||
void MFields(bool enabled);
|
|
||||||
|
|
||||||
QString ClearCustomName(const QString &name) const;
|
QString ClearCustomName(const QString &name) const;
|
||||||
|
|
||||||
bool EvalFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label);
|
bool EvalFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label);
|
||||||
|
|
||||||
void Open(const QString &pathTo, const QString &filter);
|
void Open(const QString &pathTo, const QString &filter);
|
||||||
void GUIReadOnly(bool ro);
|
void GUIReadOnly(bool ro);
|
||||||
|
void MeasurementReadOnly(bool ro);
|
||||||
|
void Controls();
|
||||||
|
void MFields(bool enabled);
|
||||||
|
|
||||||
void ReadSettings();
|
void ReadSettings();
|
||||||
void WriteSettings();
|
void WriteSettings();
|
||||||
|
|
|
@ -94,6 +94,9 @@
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBoxDetails">
|
<widget class="QGroupBox" name="groupBoxDetails">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user