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); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(meash->GetData(), NULL_ID, this);
dialog->setWindowTitle(tr("Edit measurement")); dialog->setWindowTitle(tr("Edit measurement"));
dialog->SetMeasurementsMode();
dialog->SetFormula(qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditFormula->toPlainText().replace("\n", " "), dialog->SetFormula(qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditFormula->toPlainText().replace("\n", " "),
true)); true));
const QString postfix = UnitsToStr(mUnit, true);//Show unit in dialog lable (cm, mm or inch) 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; QTableWidget *table = nullptr;
QPlainTextEdit *plainTextEditFormula = nullptr; QPlainTextEdit *plainTextEditFormula = nullptr;
bool incrementMode = true;
if (button == ui->toolButtonExpr) if (button == ui->toolButtonExpr)
{ {
incrementMode = true;
table = ui->tableWidgetIncrement; table = ui->tableWidgetIncrement;
plainTextEditFormula = ui->plainTextEditFormula; plainTextEditFormula = ui->plainTextEditFormula;
} }
else if (button == ui->toolButtonExprPC) else if (button == ui->toolButtonExprPC)
{ {
incrementMode = false;
table = ui->tableWidgetPC; table = ui->tableWidgetPC;
plainTextEditFormula = ui->plainTextEditFormulaPC; plainTextEditFormula = ui->plainTextEditFormulaPC;
} }
@ -1281,6 +1284,8 @@ void DialogIncrements::Fx()
QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(incr->GetData(), NULL_ID, this)); QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(incr->GetData(), NULL_ID, this));
dialog->setWindowTitle(tr("Edit increment")); dialog->setWindowTitle(tr("Edit increment"));
incrementMode ? dialog->SetIncrementsMode() : dialog->SetPreviewCalculationsMode();
dialog->SetFormula(qApp->TrVars()->TryFormulaFromUser(plainTextEditFormula->toPlainText().replace("\n", " "), dialog->SetFormula(qApp->TrVars()->TryFormulaFromUser(plainTextEditFormula->toPlainText().replace("\n", " "),
qApp->Settings()->GetOsSeparator())); qApp->Settings()->GetOsSeparator()));
const QString postfix = UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);

View File

@ -422,6 +422,31 @@ void DialogEditWrongFormula::setPostfix(const QString &value)
postfix = 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 QString DialogEditWrongFormula::GetFormula() const
{ {

View File

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