summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorUwe Klotz <uklotz@mixxx.org>2020-05-05 21:06:19 +0200
committerUwe Klotz <uklotz@mixxx.org>2020-05-05 21:32:48 +0200
commitd8f43e60a2f604359bba8844bb3a5b833b60f8b8 (patch)
tree4ca5ba7d6878a1a9bb906b6a951778e9b4a1c031 /src
parentd4572e97a274da2d7802952cca45bf1d5a2ead0f (diff)
Remove internal state switching from WSearchLineEdit
Diffstat (limited to 'src')
-rw-r--r--src/widget/wsearchlineedit.cpp52
-rw-r--r--src/widget/wsearchlineedit.h16
2 files changed, 2 insertions, 66 deletions
diff --git a/src/widget/wsearchlineedit.cpp b/src/widget/wsearchlineedit.cpp
index cdf75d1147..fc00d866d8 100644
--- a/src/widget/wsearchlineedit.cpp
+++ b/src/widget/wsearchlineedit.cpp
@@ -42,18 +42,6 @@ int verifyDebouncingTimeoutMillis(int debouncingTimeoutMillis) {
return debouncingTimeoutMillis;
}
-#if ENABLE_TRACE_LOG
-QDebug operator<<(QDebug dbg, WSearchLineEdit::State state) {
- switch (state) {
- case WSearchLineEdit::State::Active:
- return dbg << "Active";
- case WSearchLineEdit::State::Inactive:
- return dbg << "Inactive";
- DEBUG_ASSERT(!"unreachable");
- return dbg;
-}
-#endif // ENABLE_TRACE_LOG
-
} // namespace
//static
@@ -76,8 +64,7 @@ void WSearchLineEdit::setDebouncingTimeoutMillis(int debouncingTimeoutMillis) {
WSearchLineEdit::WSearchLineEdit(QWidget* pParent)
: QLineEdit(pParent),
WBaseWidget(this),
- m_clearButton(new QToolButton(this)),
- m_state(State::Inactive) {
+ m_clearButton(new QToolButton(this)) {
DEBUG_ASSERT(kEmptySearch.isEmpty());
DEBUG_ASSERT(!kEmptySearch.isNull());
@@ -242,44 +229,12 @@ QString WSearchLineEdit::getSearchText() const {
}
}
-void WSearchLineEdit::switchState(State state) {
-#if ENABLE_TRACE_LOG
- kLogger.trace()
- << "switchState"
- << m_state
- << "->"
- << state;
-#endif // ENABLE_TRACE_LOG
- DEBUG_ASSERT(isEnabled());
- if (m_state == state) {
- // Nothing to do
- return;
- }
- QString text;
- switch (m_state) {
- case State::Active:
- // Active -> Inactive
- // Save the current search text BEFORE switching the state!
- text = getSearchText();
- m_state = State::Inactive;
- break;
- case State::Inactive:
- // Inactive -> Active
- // Get the current search text AFTER switching the state!
- m_state = State::Active;
- text = getSearchText();
- break;
- }
- updateEditBox(text);
-}
-
void WSearchLineEdit::focusInEvent(QFocusEvent* event) {
#if ENABLE_TRACE_LOG
kLogger.trace()
<< "focusInEvent";
#endif // ENABLE_TRACE_LOG
QLineEdit::focusInEvent(event);
- switchState(State::Active);
}
void WSearchLineEdit::focusOutEvent(QFocusEvent* event) {
@@ -294,7 +249,6 @@ void WSearchLineEdit::focusOutEvent(QFocusEvent* event) {
// due to the debouncing timeout!
slotTriggerSearch();
}
- switchState(State::Inactive);
}
void WSearchLineEdit::setTextBlockSignals(const QString& text) {
@@ -317,7 +271,6 @@ void WSearchLineEdit::slotDisableSearch() {
return;
}
setTextBlockSignals(kDisabledText);
- // Set disabled AFTER switching the state!
setEnabled(false);
}
@@ -384,7 +337,6 @@ void WSearchLineEdit::updateEditBox(const QString& text) {
} else {
setTextBlockSignals(text);
}
- m_state = State::Active;
updateClearButton(text);
// This gets rid of the blue mac highlight.
@@ -399,7 +351,7 @@ void WSearchLineEdit::updateClearButton(const QString& text) {
#endif // ENABLE_TRACE_LOG
DEBUG_ASSERT(isEnabled());
- if (text.isEmpty() && m_state != State::Active) {
+ if (text.isEmpty()) {
// Disable while placeholder is shown
m_clearButton->setVisible(false);
// no right padding
diff --git a/src/widget/wsearchlineedit.h b/src/widget/wsearchlineedit.h
index e8a446bac3..b4989b3f90 100644
--- a/src/widget/wsearchlineedit.h
+++ b/src/widget/wsearchlineedit.h
@@ -18,10 +18,6 @@ class WSearchLineEdit : public QLineEdit, public WBaseWidget {
static constexpr int kDefaultDebouncingTimeoutMillis = 300;
static constexpr int kMaxDebouncingTimeoutMillis = 9999;
- // Use 'active' property to apply an alternative style to the
- // placeholder text
- Q_PROPERTY(bool active READ isActive);
-
// TODO(XXX): Replace with a public slot
static void setDebouncingTimeoutMillis(int debouncingTimeoutMillis);
@@ -79,16 +75,4 @@ class WSearchLineEdit : public QLineEdit, public WBaseWidget {
int m_innerHeight;
QTimer m_debouncingTimer;
-
- enum class State {
- Active,
- Inactive,
- };
- State m_state;
-
- void switchState(State state);
-
- bool isActive() const {
- return m_state == State::Active ? true : false;
- }
};