From d126e86e81f2249f73b2e690ddec6899c3494f3b Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Sun, 22 Oct 2017 18:29:54 +0200 Subject: [PATCH] Make sure to not re-run the query if the filters haven't changed When changing between the filter line edits in the Browse Data tab, make sure to only re-run the SQL query if the value of the filter line edits have actually changed. See issue #1187. --- src/FilterLineEdit.cpp | 12 ++++++++++-- src/FilterLineEdit.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/FilterLineEdit.cpp b/src/FilterLineEdit.cpp index 38e7a0fc..d00ad628 100644 --- a/src/FilterLineEdit.cpp +++ b/src/FilterLineEdit.cpp @@ -30,8 +30,16 @@ void FilterLineEdit::delayedSignalTimerTriggered() // Stop the timer first to avoid triggering in intervals delaySignalTimer->stop(); - // Emit the delayed signal using the current value - emit delayedTextChanged(text()); + // Only emit text changed signal if the text has actually changed in comparison to the last emitted signal. This is necessary + // because this method is also called whenever the line edit loses focus and not only when its text has definitely been changed. + if(text() != lastValue) + { + // Emit the delayed signal using the current value + emit delayedTextChanged(text()); + + // Remember this value for the next time + lastValue = text(); + } } void FilterLineEdit::keyReleaseEvent(QKeyEvent* event) diff --git a/src/FilterLineEdit.h b/src/FilterLineEdit.h index b1d9fe13..fb803990 100644 --- a/src/FilterLineEdit.h +++ b/src/FilterLineEdit.h @@ -31,6 +31,7 @@ private: QList* filterList; int columnNumber; QTimer* delaySignalTimer; + QString lastValue; }; #endif