Added missed signal. Little refactoring. ref #581.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-11-10 08:53:44 +02:00
parent 7e3ebe7ca2
commit 91d43c4b26
2 changed files with 34 additions and 16 deletions

View File

@ -85,6 +85,11 @@ DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, const qui
this->formulaBaseHeight = ui->plainTextEditFormula->height(); this->formulaBaseHeight = ui->plainTextEditFormula->height();
ui->plainTextEditFormula->installEventFilter(this); 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); InitOkCancel(ui);
flagFormula = false; flagFormula = false;
CheckState(); CheckState();
@ -95,19 +100,6 @@ DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, const qui
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogEditWrongFormula::FormulaChanged); connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogEditWrongFormula::FormulaChanged);
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogEditWrongFormula::DeployFormulaTextEdit); 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 //Disable Qt::WaitCursor
#ifndef QT_NO_CURSOR #ifndef QT_NO_CURSOR
if (QApplication::overrideCursor() != nullptr) if (QApplication::overrideCursor() != nullptr)
@ -411,16 +403,37 @@ void DialogEditWrongFormula::InitVariables()
ui->radioButtonStandardTable->setChecked(true); ui->radioButtonStandardTable->setChecked(true);
Measurements(); 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, &DialogEditWrongFormula::Measurements);
connect(ui->radioButtonStandardTable, &QRadioButton::clicked, this, ClearFilterFormulaInputs);
connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogEditWrongFormula::Increments); 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, &DialogEditWrongFormula::LengthLines);
connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, ClearFilterFormulaInputs);
connect(ui->radioButtonLengthSpline, &QRadioButton::clicked, this, &DialogEditWrongFormula::LengthCurves); 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->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, &DialogEditWrongFormula::RadiusArcs);
connect(ui->radioButtonRadiusesArcs, &QRadioButton::clicked, this, ClearFilterFormulaInputs);
connect(ui->radioButtonAnglesCurves, &QRadioButton::clicked, this, &DialogEditWrongFormula::AnglesCurves); 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, &DialogEditWrongFormula::CurvesCLength);
connect(ui->radioButtonCLength, &QRadioButton::clicked, this, ClearFilterFormulaInputs);
connect(ui->radioButtonFunctions, &QRadioButton::clicked, this, &DialogEditWrongFormula::Functions); 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); ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
} }
void DialogEditWrongFormula::on_filterFormulaInputs_textEdited(const QString &filter) //---------------------------------------------------------------------------------------------------------------------
void DialogEditWrongFormula::FilterVariablesEdited(const QString &filter)
{ {
ui->tableWidget->blockSignals(true); ui->tableWidget->blockSignals(true);
// hide all rows // hide all rows
for (auto i = 0; i < ui->tableWidget->rowCount(); i++) for (auto i = 0; i < ui->tableWidget->rowCount(); i++)
{
ui->tableWidget->hideRow(i); ui->tableWidget->hideRow(i);
}
// show rows with matched filter // show rows with matched filter
for (auto item : ui->tableWidget->findItems(filter, Qt::MatchContains)) for (auto item : ui->tableWidget->findItems(filter, Qt::MatchContains))
{
ui->tableWidget->showRow(item->row()); ui->tableWidget->showRow(item->row());
}
ui->tableWidget->blockSignals(false); ui->tableWidget->blockSignals(false);
} }

View File

@ -97,7 +97,7 @@ protected:
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
virtual void showEvent( QShowEvent *event ) Q_DECL_OVERRIDE; virtual void showEvent( QShowEvent *event ) Q_DECL_OVERRIDE;
private slots: private slots:
void on_filterFormulaInputs_textEdited(const QString &filter); void FilterVariablesEdited(const QString &filter);
private: private:
Q_DISABLE_COPY(DialogEditWrongFormula) Q_DISABLE_COPY(DialogEditWrongFormula)
Ui::DialogEditWrongFormula *ui; Ui::DialogEditWrongFormula *ui;