Improve Formula Wizard. Disable data types not available in certain cases.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2018-01-24 19:10:29 +02:00
parent f78f191843
commit 9b5b8dde04
4 changed files with 34 additions and 0 deletions

View File

@ -1224,6 +1224,7 @@ void TMainWindow::Fx()
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(meash->GetData(), NULL_ID, this);
dialog->setWindowTitle(tr("Edit measurement"));
dialog->SetMeasurementsMode();
dialog->SetFormula(qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditFormula->toPlainText().replace("\n", " "),
true));
const QString postfix = UnitsToStr(mUnit, true);//Show unit in dialog lable (cm, mm or inch)

View File

@ -1254,13 +1254,16 @@ void DialogIncrements::Fx()
QTableWidget *table = nullptr;
QPlainTextEdit *plainTextEditFormula = nullptr;
bool incrementMode = true;
if (button == ui->toolButtonExpr)
{
incrementMode = true;
table = ui->tableWidgetIncrement;
plainTextEditFormula = ui->plainTextEditFormula;
}
else if (button == ui->toolButtonExprPC)
{
incrementMode = false;
table = ui->tableWidgetPC;
plainTextEditFormula = ui->plainTextEditFormulaPC;
}
@ -1281,6 +1284,8 @@ void DialogIncrements::Fx()
QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(incr->GetData(), NULL_ID, this));
dialog->setWindowTitle(tr("Edit increment"));
incrementMode ? dialog->SetIncrementsMode() : dialog->SetPreviewCalculationsMode();
dialog->SetFormula(qApp->TrVars()->TryFormulaFromUser(plainTextEditFormula->toPlainText().replace("\n", " "),
qApp->Settings()->GetOsSeparator()));
const QString postfix = UnitsToStr(qApp->patternUnit(), true);

View File

@ -422,6 +422,31 @@ void DialogEditWrongFormula::setPostfix(const QString &value)
postfix = value;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditWrongFormula::SetMeasurementsMode()
{
ui->radioButtonIncrements->setDisabled(true);
SetIncrementsMode();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditWrongFormula::SetIncrementsMode()
{
ui->radioButtonPC->setDisabled(true);
SetPreviewCalculationsMode();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditWrongFormula::SetPreviewCalculationsMode()
{
ui->radioButtonLengthLine->setDisabled(true);
ui->radioButtonLengthSpline->setDisabled(true);
ui->radioButtonAngleLine->setDisabled(true);
ui->radioButtonRadiusesArcs->setDisabled(true);
ui->radioButtonAnglesCurves->setDisabled(true);
ui->radioButtonCLength->setDisabled(true);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogEditWrongFormula::GetFormula() const
{

View File

@ -67,6 +67,9 @@ public:
void setCheckZero(bool value);
void setCheckLessThanZero(bool value);
void setPostfix(const QString &value);
void SetMeasurementsMode();
void SetIncrementsMode();
void SetPreviewCalculationsMode();
public slots:
virtual void DialogAccepted() Q_DECL_OVERRIDE;
virtual void DialogRejected() Q_DECL_OVERRIDE;