From 09a9ec285521cf76a1950d450a0ce2f62c4d1da4 Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Tue, 16 Aug 2016 23:13:34 +0300 Subject: [PATCH] Resolved Issue #424. Improve Formula Wizard dialog. --HG-- branch : feature --- src/libs/vpatterndb/vtranslatevars.cpp | 6 +++ src/libs/vpatterndb/vtranslatevars.h | 1 + .../support/dialogeditwrongformula.cpp | 45 +++++++++++++++++++ .../dialogs/support/dialogeditwrongformula.h | 2 + .../dialogs/support/dialogeditwrongformula.ui | 7 +++ 5 files changed, 61 insertions(+) diff --git a/src/libs/vpatterndb/vtranslatevars.cpp b/src/libs/vpatterndb/vtranslatevars.cpp index 62c66aa23..768aac5b8 100644 --- a/src/libs/vpatterndb/vtranslatevars.cpp +++ b/src/libs/vpatterndb/vtranslatevars.cpp @@ -946,3 +946,9 @@ void VTranslateVars::Retranslate() InitFunctions(); InitPostfixOperators(); } + +//--------------------------------------------------------------------------------------------------------------------- +QMap VTranslateVars::GetFunctions() const +{ + return functions; +} diff --git a/src/libs/vpatterndb/vtranslatevars.h b/src/libs/vpatterndb/vtranslatevars.h index 17ab3f718..badace6f0 100644 --- a/src/libs/vpatterndb/vtranslatevars.h +++ b/src/libs/vpatterndb/vtranslatevars.h @@ -61,6 +61,7 @@ public: QString FormulaToUser(const QString &formula, bool osSeparator) const; virtual void Retranslate() Q_DECL_OVERRIDE; + QMap GetFunctions() const; private: Q_DISABLE_COPY(VTranslateVars) diff --git a/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp b/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp index 8625a6fbb..761521e39 100644 --- a/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp @@ -217,6 +217,11 @@ void DialogEditWrongFormula::ValChanged(int row) degreeSymbol, tr("Curve angle")); return; } + if (ui->radioButtonFunctions->isChecked()) + { + ui->labelDescription->setText(item->toolTip()); + return; + } } //--------------------------------------------------------------------------------------------------------------------- @@ -309,6 +314,16 @@ void DialogEditWrongFormula::Increments() ShowVariable(data->DataIncrements()); } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Functions show in list functions + */ +void DialogEditWrongFormula::Functions() +{ + ui->checkBoxHideEmpty->setEnabled(false); + ShowFunctions(); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogEditWrongFormula::CheckState() { @@ -384,6 +399,7 @@ void DialogEditWrongFormula::InitVariables() connect(ui->checkBoxHideEmpty, &QCheckBox::stateChanged, this, &DialogEditWrongFormula::Measurements); connect(ui->radioButtonRadiusesArcs, &QRadioButton::clicked, this, &DialogEditWrongFormula::RadiusArcs); connect(ui->radioButtonAnglesCurves, &QRadioButton::clicked, this, &DialogEditWrongFormula::AnglesCurves); + connect(ui->radioButtonFunctions, &QRadioButton::clicked, this, &DialogEditWrongFormula::Functions); } //--------------------------------------------------------------------------------------------------------------------- @@ -477,3 +493,32 @@ void DialogEditWrongFormula::ShowMeasurements(const QMaptableWidget->selectRow(0); ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); } + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowFunctions show functions in list + */ +void DialogEditWrongFormula::ShowFunctions() +{ + ui->tableWidget->blockSignals(true); + ui->tableWidget->clearContents(); + ui->tableWidget->setRowCount(0); + ui->tableWidget->setColumnHidden(ColumnFullName, true); + ui->labelDescription->setText(""); + + QMap var = qApp->TrVars()->GetFunctions(); + QMapIterator iMap(var); + while (iMap.hasNext()) + { + iMap.next(); + ui->tableWidget->setRowCount(ui->tableWidget->rowCount() + 1); + QTableWidgetItem *item = new QTableWidgetItem(iMap.key()); + item->setFont(QFont("Times", 12, QFont::Bold)); + ui->tableWidget->setItem(ui->tableWidget->rowCount()-1, ColumnName, item); + item->setToolTip(iMap.value().getMdisambiguation()); + } + + ui->tableWidget->blockSignals(false); + ui->tableWidget->selectRow(0); + ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); +} diff --git a/src/libs/vtools/dialogs/support/dialogeditwrongformula.h b/src/libs/vtools/dialogs/support/dialogeditwrongformula.h index efb4fb0e9..3eed52e9c 100644 --- a/src/libs/vtools/dialogs/support/dialogeditwrongformula.h +++ b/src/libs/vtools/dialogs/support/dialogeditwrongformula.h @@ -90,6 +90,7 @@ public slots: void LengthCurves(); void AngleLines(); void Increments(); + void Functions(); protected: virtual void CheckState() Q_DECL_OVERRIDE; virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; @@ -113,6 +114,7 @@ private: template void ShowVariable(const QMap &var); void ShowMeasurements(const QMap > &var); + void ShowFunctions(); void SetDescription(const QString &name, qreal value, const QString &unit, const QString &description); }; diff --git a/src/libs/vtools/dialogs/support/dialogeditwrongformula.ui b/src/libs/vtools/dialogs/support/dialogeditwrongformula.ui index c639d559a..698699c66 100644 --- a/src/libs/vtools/dialogs/support/dialogeditwrongformula.ui +++ b/src/libs/vtools/dialogs/support/dialogeditwrongformula.ui @@ -329,6 +329,13 @@ + + + + Functions + + +