From 88130f10846c85aad0f19eb2c256583b379cde32 Mon Sep 17 00:00:00 2001 From: Raina Date: Wed, 9 Nov 2016 18:25:52 -0800 Subject: [PATCH 1/3] Resolves #581. User can now filter input lists by keyword in function wizard. --HG-- branch : feature --- .hgignore | 3 ++ ChangeLog.txt | 1 + .../support/dialogeditwrongformula.cpp | 28 +++++++++++++++++++ .../dialogs/support/dialogeditwrongformula.h | 2 ++ .../dialogs/support/dialogeditwrongformula.ui | 7 +++++ 5 files changed, 41 insertions(+) diff --git a/.hgignore b/.hgignore index acd48da3d..44edfcd0f 100644 --- a/.hgignore +++ b/.hgignore @@ -159,3 +159,6 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk + +# Understand IDE file +*.udb \ No newline at end of file diff --git a/ChangeLog.txt b/ChangeLog.txt index 4b8cb815b..edfbb8795 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,4 +1,5 @@ # Version 0.5.0 +- [#581] User can now filter input lists by keyword in function wizard. - [#24] User can now add labels with different information on the detail - [#505] New installer script based on Inno Setup 5. - Size of preferences dialog in both Valentina and Tape app is now preserved between sessions diff --git a/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp b/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp index b9603cfaa..dc26a0032 100644 --- a/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp @@ -95,6 +95,19 @@ DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, const qui connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogEditWrongFormula::FormulaChanged); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogEditWrongFormula::DeployFormulaTextEdit); + // clear text filter every time when new radio button selected + auto clearFilterFormulaInputs = [=] () { ui->filterFormulaInputs->clear(); }; + + connect(ui->radioButtonStandardTable, &QRadioButton::clicked, this, clearFilterFormulaInputs); + connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, clearFilterFormulaInputs); + connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, clearFilterFormulaInputs); + connect(ui->radioButtonLengthSpline, &QRadioButton::clicked, this, clearFilterFormulaInputs); + connect(ui->radioButtonAngleLine, &QRadioButton::clicked, this, clearFilterFormulaInputs); + connect(ui->radioButtonRadiusesArcs, &QRadioButton::clicked, this, clearFilterFormulaInputs); + connect(ui->radioButtonAnglesCurves, &QRadioButton::clicked, this, clearFilterFormulaInputs); + connect(ui->radioButtonCLength, &QRadioButton::clicked, this, clearFilterFormulaInputs); + connect(ui->radioButtonFunctions, &QRadioButton::clicked, this, clearFilterFormulaInputs); + //Disable Qt::WaitCursor #ifndef QT_NO_CURSOR if (QApplication::overrideCursor() != nullptr) @@ -529,3 +542,18 @@ void DialogEditWrongFormula::ShowFunctions() ui->tableWidget->selectRow(0); ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); } + +void DialogEditWrongFormula::on_filterFormulaInputs_textEdited(const QString &filter) +{ + ui->tableWidget->blockSignals(true); + + // hide all rows + for (auto i = 0; i < ui->tableWidget->rowCount(); i++) + ui->tableWidget->hideRow(i); + + // show rows with matched filter + for (auto item : ui->tableWidget->findItems(filter, Qt::MatchContains)) + ui->tableWidget->showRow(item->row()); + + ui->tableWidget->blockSignals(false); +} diff --git a/src/libs/vtools/dialogs/support/dialogeditwrongformula.h b/src/libs/vtools/dialogs/support/dialogeditwrongformula.h index 2e1255e85..d4d42d076 100644 --- a/src/libs/vtools/dialogs/support/dialogeditwrongformula.h +++ b/src/libs/vtools/dialogs/support/dialogeditwrongformula.h @@ -96,6 +96,8 @@ protected: virtual void CheckState() Q_DECL_OVERRIDE; virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; virtual void showEvent( QShowEvent *event ) Q_DECL_OVERRIDE; +private slots: + void on_filterFormulaInputs_textEdited(const QString &filter); private: Q_DISABLE_COPY(DialogEditWrongFormula) Ui::DialogEditWrongFormula *ui; diff --git a/src/libs/vtools/dialogs/support/dialogeditwrongformula.ui b/src/libs/vtools/dialogs/support/dialogeditwrongformula.ui index 8f952605e..edc6da1ba 100644 --- a/src/libs/vtools/dialogs/support/dialogeditwrongformula.ui +++ b/src/libs/vtools/dialogs/support/dialogeditwrongformula.ui @@ -355,6 +355,13 @@ + + + + Filter list by keyword + + + From 91d43c4b26e2379f5dab0bde119f15b2df6e3d83 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 10 Nov 2016 08:53:44 +0200 Subject: [PATCH 2/3] Added missed signal. Little refactoring. ref #581. --HG-- branch : develop --- .../support/dialogeditwrongformula.cpp | 48 +++++++++++++------ .../dialogs/support/dialogeditwrongformula.h | 2 +- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp b/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp index dc26a0032..ea3407582 100644 --- a/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp @@ -85,6 +85,11 @@ DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, const qui this->formulaBaseHeight = ui->plainTextEditFormula->height(); ui->plainTextEditFormula->installEventFilter(this); +#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) + ui->filterFormulaInputs->setClearButtonEnabled(true); +#endif + connect(ui->filterFormulaInputs, &QLineEdit::textChanged, this, &DialogEditWrongFormula::FilterVariablesEdited); + InitOkCancel(ui); flagFormula = false; CheckState(); @@ -95,19 +100,6 @@ DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, const qui connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogEditWrongFormula::FormulaChanged); connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogEditWrongFormula::DeployFormulaTextEdit); - // clear text filter every time when new radio button selected - auto clearFilterFormulaInputs = [=] () { ui->filterFormulaInputs->clear(); }; - - connect(ui->radioButtonStandardTable, &QRadioButton::clicked, this, clearFilterFormulaInputs); - connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, clearFilterFormulaInputs); - connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, clearFilterFormulaInputs); - connect(ui->radioButtonLengthSpline, &QRadioButton::clicked, this, clearFilterFormulaInputs); - connect(ui->radioButtonAngleLine, &QRadioButton::clicked, this, clearFilterFormulaInputs); - connect(ui->radioButtonRadiusesArcs, &QRadioButton::clicked, this, clearFilterFormulaInputs); - connect(ui->radioButtonAnglesCurves, &QRadioButton::clicked, this, clearFilterFormulaInputs); - connect(ui->radioButtonCLength, &QRadioButton::clicked, this, clearFilterFormulaInputs); - connect(ui->radioButtonFunctions, &QRadioButton::clicked, this, clearFilterFormulaInputs); - //Disable Qt::WaitCursor #ifndef QT_NO_CURSOR if (QApplication::overrideCursor() != nullptr) @@ -411,16 +403,37 @@ void DialogEditWrongFormula::InitVariables() ui->radioButtonStandardTable->setChecked(true); Measurements(); + // clear text filter every time when new radio button selected + auto ClearFilterFormulaInputs = [=] () { ui->filterFormulaInputs->clear(); }; + connect(ui->radioButtonStandardTable, &QRadioButton::clicked, this, &DialogEditWrongFormula::Measurements); + connect(ui->radioButtonStandardTable, &QRadioButton::clicked, this, ClearFilterFormulaInputs); + connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogEditWrongFormula::Increments); + connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, ClearFilterFormulaInputs); + connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogEditWrongFormula::LengthLines); + connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, ClearFilterFormulaInputs); + connect(ui->radioButtonLengthSpline, &QRadioButton::clicked, this, &DialogEditWrongFormula::LengthCurves); + connect(ui->radioButtonLengthSpline, &QRadioButton::clicked, this, ClearFilterFormulaInputs); + connect(ui->radioButtonAngleLine, &QRadioButton::clicked, this, &DialogEditWrongFormula::AngleLines); - connect(ui->checkBoxHideEmpty, &QCheckBox::stateChanged, this, &DialogEditWrongFormula::Measurements); + connect(ui->radioButtonAngleLine, &QRadioButton::clicked, this, ClearFilterFormulaInputs); + connect(ui->radioButtonRadiusesArcs, &QRadioButton::clicked, this, &DialogEditWrongFormula::RadiusArcs); + connect(ui->radioButtonRadiusesArcs, &QRadioButton::clicked, this, ClearFilterFormulaInputs); + connect(ui->radioButtonAnglesCurves, &QRadioButton::clicked, this, &DialogEditWrongFormula::AnglesCurves); + connect(ui->radioButtonAnglesCurves, &QRadioButton::clicked, this, ClearFilterFormulaInputs); + connect(ui->radioButtonCLength, &QRadioButton::clicked, this, &DialogEditWrongFormula::CurvesCLength); + connect(ui->radioButtonCLength, &QRadioButton::clicked, this, ClearFilterFormulaInputs); + connect(ui->radioButtonFunctions, &QRadioButton::clicked, this, &DialogEditWrongFormula::Functions); + connect(ui->radioButtonFunctions, &QRadioButton::clicked, this, ClearFilterFormulaInputs); + + connect(ui->checkBoxHideEmpty, &QCheckBox::stateChanged, this, &DialogEditWrongFormula::Measurements); } //--------------------------------------------------------------------------------------------------------------------- @@ -543,17 +556,22 @@ void DialogEditWrongFormula::ShowFunctions() ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); } -void DialogEditWrongFormula::on_filterFormulaInputs_textEdited(const QString &filter) +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditWrongFormula::FilterVariablesEdited(const QString &filter) { ui->tableWidget->blockSignals(true); // hide all rows for (auto i = 0; i < ui->tableWidget->rowCount(); i++) + { ui->tableWidget->hideRow(i); + } // show rows with matched filter for (auto item : ui->tableWidget->findItems(filter, Qt::MatchContains)) + { ui->tableWidget->showRow(item->row()); + } ui->tableWidget->blockSignals(false); } diff --git a/src/libs/vtools/dialogs/support/dialogeditwrongformula.h b/src/libs/vtools/dialogs/support/dialogeditwrongformula.h index d4d42d076..247aeb33c 100644 --- a/src/libs/vtools/dialogs/support/dialogeditwrongformula.h +++ b/src/libs/vtools/dialogs/support/dialogeditwrongformula.h @@ -97,7 +97,7 @@ protected: virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; virtual void showEvent( QShowEvent *event ) Q_DECL_OVERRIDE; private slots: - void on_filterFormulaInputs_textEdited(const QString &filter); + void FilterVariablesEdited(const QString &filter); private: Q_DISABLE_COPY(DialogEditWrongFormula) Ui::DialogEditWrongFormula *ui; From c4b934602100c1929345847d42f41f9ceae1b342 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 10 Nov 2016 11:15:52 +0200 Subject: [PATCH 3/3] Fixed issue #586. Valentina crashes if clear input filter string. --HG-- branch : develop --- .../support/dialogeditwrongformula.cpp | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp b/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp index ea3407582..1a07b83e6 100644 --- a/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditwrongformula.cpp @@ -561,16 +561,33 @@ void DialogEditWrongFormula::FilterVariablesEdited(const QString &filter) { ui->tableWidget->blockSignals(true); - // hide all rows - for (auto i = 0; i < ui->tableWidget->rowCount(); i++) + // If filter is empty findItems() for unknown reason returns nullptr items. + // See issue #586. https://bitbucket.org/dismine/valentina/issues/586/valentina-crashes-if-clear-input-filter + if (filter.isEmpty()) { - ui->tableWidget->hideRow(i); + // show all rows + for (auto i = 0; i < ui->tableWidget->rowCount(); ++i) + { + ui->tableWidget->showRow(i); + } } - - // show rows with matched filter - for (auto item : ui->tableWidget->findItems(filter, Qt::MatchContains)) + else { - ui->tableWidget->showRow(item->row()); + // hide all rows + for (auto i = 0; i < ui->tableWidget->rowCount(); i++) + { + ui->tableWidget->hideRow(i); + } + + // show rows with matched filter + for (auto item : ui->tableWidget->findItems(filter, Qt::MatchContains)) + { + // If filter is empty findItems() for unknown reason returns nullptr items. + if (item) + { + ui->tableWidget->showRow(item->row()); + } + } } ui->tableWidget->blockSignals(false);