diff --git a/src/ui/linechart/LinechartWidget.cc b/src/ui/linechart/LinechartWidget.cc index 5f63085a317a0ec319699f803ec755dcfa1ae1ed..df439dcb5e68bea79b6b3d6ca00d4fa288d7a8ea 100644 --- a/src/ui/linechart/LinechartWidget.cc +++ b/src/ui/linechart/LinechartWidget.cc @@ -87,7 +87,7 @@ LinechartWidget::LinechartWidget(int systemid, QWidget *parent) : QWidget(parent // Create curve list headings connect(ui.recolorButton, &QPushButton::clicked, this, &LinechartWidget::recolor); connect(ui.shortNameCheckBox, &QCheckBox::clicked, this, &LinechartWidget::setShortNames); - connect(ui.plotFilterLineEdit, &QLineEdit::textChanged, this, &LinechartWidget::filterCurves); + connect(ui.plotFilterLineEdit, &QLineEdit::textChanged, this, &LinechartWidget::_restartFilterTimeout); QShortcut *shortcut = new QShortcut(this); shortcut->setKey(QKeySequence(Qt::CTRL + Qt::Key_F)); connect(shortcut, &QShortcut::activated, this, &LinechartWidget::setPlotFilterLineEditFocus); @@ -126,6 +126,9 @@ LinechartWidget::LinechartWidget(int systemid, QWidget *parent) : QWidget(parent readSettings(); pUnit->setVisible(ui.showUnitsCheckBox->isChecked()); connect(ui.showUnitsCheckBox, &QCheckBox::clicked, pUnit, &QLabel::setVisible); + + _filterTimer.setInterval(500); + connect(&_filterTimer, &QTimer::timeout, this, &LinechartWidget::_filterTimeout); } LinechartWidget::~LinechartWidget() @@ -671,6 +674,16 @@ void LinechartWidget::filterCurve(const QString &key, bool match) } } +void LinechartWidget::_restartFilterTimeout(void) +{ + _filterTimer.start(); +} + +void LinechartWidget::_filterTimeout(void) +{ + filterCurves(ui.plotFilterLineEdit->text()); +} + void LinechartWidget::filterCurves(const QString &filter) { //qDebug() << "filterCurves: filter: " << filter; diff --git a/src/ui/linechart/LinechartWidget.h b/src/ui/linechart/LinechartWidget.h index 372acfa43690cc27d1016b88d2c8381b0888c9ae..99e61caea759f85661275a653542562db1f85970 100644 --- a/src/ui/linechart/LinechartWidget.h +++ b/src/ui/linechart/LinechartWidget.h @@ -194,6 +194,12 @@ signals: /** @brief This signal is emitted once a logfile has been finished writing */ void logfileWritten(QString fileName); +private slots: + void _filterTimeout(void); + void _restartFilterTimeout(void); + +private: + QTimer _filterTimer; }; #endif // LINECHARTWIDGET_H