From 09a9ec285521cf76a1950d450a0ce2f62c4d1da4 Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Tue, 16 Aug 2016 23:13:34 +0300 Subject: [PATCH 1/4] 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 + + + From 74b30fa3774c885ac2f2d17c3229b56bcce9f3c4 Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Tue, 16 Aug 2016 23:15:54 +0300 Subject: [PATCH 2/4] Fixed misprint. --HG-- branch : feature --- src/libs/vpatterndb/vtranslatevars.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/vpatterndb/vtranslatevars.cpp b/src/libs/vpatterndb/vtranslatevars.cpp index 768aac5b8..d3c0a04e4 100644 --- a/src/libs/vpatterndb/vtranslatevars.cpp +++ b/src/libs/vpatterndb/vtranslatevars.cpp @@ -403,7 +403,7 @@ void VTranslateVars::InitFunctions() functions.insert(cosh_F, translate("VTranslateVars", "cosh", "hyperbolic cosine")); functions.insert(tanh_F, translate("VTranslateVars", "tanh", "hyperbolic tangens function")); functions.insert(asinh_F, translate("VTranslateVars", "asinh", "hyperbolic arcus sine function")); - functions.insert(acosh_F, translate("VTranslateVars", "acosh", "hyperbolic arcus tangens function")); + functions.insert(acosh_F, translate("VTranslateVars", "acosh", "hyperbolic arcus cosine function")); functions.insert(atanh_F, translate("VTranslateVars", "atanh", "hyperbolic arcur tangens function")); functions.insert(log2_F, translate("VTranslateVars", "log2", "logarithm to the base 2")); functions.insert(log10_F, translate("VTranslateVars", "log10", "logarithm to the base 10")); From a5484c04de7ec4ac55bd960b6867501615aab19f Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Tue, 16 Aug 2016 23:17:03 +0300 Subject: [PATCH 3/4] Updated Changelog.txt. --HG-- branch : feature --- ChangeLog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index b6fb43eec..a608e438e 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -36,6 +36,7 @@ - [#496] Selector for selecting which pieces to print. - [#520] Improve Union tool. An option to select about original pieces. - [#262] Automatic Update notification. +- [#424] Improve Formula Wizard dialog. # Version 0.4.5 - [#435] Valentina doesn't change the cursor. From 00649770e3334e492366ca552b47781a5bb5f51c Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Wed, 17 Aug 2016 23:13:54 +0300 Subject: [PATCH 4/4] Little fixes. --HG-- branch : feature --- .../vtools/dialogs/support/dialogeditwrongformula.cpp | 11 +++++------ .../vtools/dialogs/support/dialogeditwrongformula.ui | 6 ++++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp b/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp index 761521e39..7bc6e8ab2 100644 --- a/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp @@ -506,16 +506,15 @@ void DialogEditWrongFormula::ShowFunctions() ui->tableWidget->setColumnHidden(ColumnFullName, true); ui->labelDescription->setText(""); - QMap var = qApp->TrVars()->GetFunctions(); - QMapIterator iMap(var); - while (iMap.hasNext()) + QMap::const_iterator i = qApp->TrVars()->GetFunctions().constBegin(); + while (i != qApp->TrVars()->GetFunctions().constEnd()) { - iMap.next(); ui->tableWidget->setRowCount(ui->tableWidget->rowCount() + 1); - QTableWidgetItem *item = new QTableWidgetItem(iMap.key()); + QTableWidgetItem *item = new QTableWidgetItem(i.value().translate()); item->setFont(QFont("Times", 12, QFont::Bold)); ui->tableWidget->setItem(ui->tableWidget->rowCount()-1, ColumnName, item); - item->setToolTip(iMap.value().getMdisambiguation()); + item->setToolTip(i.value().getMdisambiguation()); + ++i; } ui->tableWidget->blockSignals(false); diff --git a/src/libs/vtools/dialogs/support/dialogeditwrongformula.ui b/src/libs/vtools/dialogs/support/dialogeditwrongformula.ui index 698699c66..9a6c353ae 100644 --- a/src/libs/vtools/dialogs/support/dialogeditwrongformula.ui +++ b/src/libs/vtools/dialogs/support/dialogeditwrongformula.ui @@ -331,6 +331,12 @@ + + + 0 + 0 + + Functions