summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorUwe Klotz <uklotz@mixxx.org>2020-05-05 13:32:35 +0200
committerUwe Klotz <uklotz@mixxx.org>2020-05-05 14:09:21 +0200
commit79a0206d21fd5c4514144ba2190e2c9e4e591d6e (patch)
treef295ddd49e493ed906f506c819cbf18989eb00b1 /src
parenta62c5e82be15accdc3cb6dd1667526037e458a4e (diff)
Remove redundant methods and invocations
Diffstat (limited to 'src')
-rw-r--r--src/widget/wsearchlineedit.cpp59
-rw-r--r--src/widget/wsearchlineedit.h8
2 files changed, 14 insertions, 53 deletions
diff --git a/src/widget/wsearchlineedit.cpp b/src/widget/wsearchlineedit.cpp
index 6990cfef98..9d0ff2b86f 100644
--- a/src/widget/wsearchlineedit.cpp
+++ b/src/widget/wsearchlineedit.cpp
@@ -131,7 +131,7 @@ WSearchLineEdit::WSearchLineEdit(QWidget* pParent)
// Ensures the text does not obscure the clear image.
setStyleSheet(clearButtonStyleSheet(clearButtonSize.width() + m_frameWidth + 1));
- showPlaceholder();
+ refreshState();
}
void WSearchLineEdit::setup(const QDomNode& node, const SkinContext& context) {
@@ -296,9 +296,6 @@ void WSearchLineEdit::focusOutEvent(QFocusEvent* event) {
slotTriggerSearch();
}
switchState(State::Inactive);
- if (getSearchText().isEmpty()) {
- showPlaceholder();
- }
}
void WSearchLineEdit::setTextBlockSignals(const QString& text) {
@@ -363,27 +360,22 @@ void WSearchLineEdit::slotTriggerSearch() {
emit search(getSearchText());
}
-bool WSearchLineEdit::shouldShowPlaceholder(const QString& text) const {
- DEBUG_ASSERT(isEnabled());
- return text.isEmpty() && m_state != State::Active;
-}
-
-void WSearchLineEdit::showPlaceholder() {
+void WSearchLineEdit::refreshState() {
#if ENABLE_TRACE_LOG
kLogger.trace()
- << "showPlaceholder"
- << getSearchText();
+ << "refreshState";
#endif // ENABLE_TRACE_LOG
- DEBUG_ASSERT(getSearchText() == kEmptySearch);
- DEBUG_ASSERT(shouldShowPlaceholder(getSearchText()));
-
- updateClearButton(kEmptySearch);
+ if (isEnabled()) {
+ enableSearch(getSearchText());
+ } else {
+ slotDisableSearch();
+ }
}
-void WSearchLineEdit::showSearchText(const QString& text) {
+void WSearchLineEdit::updateEditBox(const QString& text) {
#if ENABLE_TRACE_LOG
kLogger.trace()
- << "showSearchText"
+ << "updateEditBox"
<< text;
#endif // ENABLE_TRACE_LOG
DEBUG_ASSERT(isEnabled());
@@ -400,40 +392,15 @@ void WSearchLineEdit::showSearchText(const QString& text) {
setAttribute(Qt::WA_MacShowFocusRect, false);
}
-void WSearchLineEdit::refreshState() {
-#if ENABLE_TRACE_LOG
- kLogger.trace()
- << "refreshState";
-#endif // ENABLE_TRACE_LOG
- if (isEnabled()) {
- enableSearch(getSearchText());
- } else {
- slotDisableSearch();
- }
-}
-
-void WSearchLineEdit::updateEditBox(const QString& text) {
-#if ENABLE_TRACE_LOG
- kLogger.trace()
- << "updateEditBox"
- << text;
-#endif // ENABLE_TRACE_LOG
- // Updating the placeholder or search text implicitly updates
- // both the text and the clear button
- if (shouldShowPlaceholder(text)) {
- showPlaceholder();
- } else {
- showSearchText(text);
- }
-}
-
void WSearchLineEdit::updateClearButton(const QString& text) {
#if ENABLE_TRACE_LOG
kLogger.trace()
<< "updateClearButton"
<< text;
#endif // ENABLE_TRACE_LOG
- if (shouldShowPlaceholder(text)) {
+ DEBUG_ASSERT(isEnabled());
+
+ if (text.isEmpty() && m_state != State::Active) {
// 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 2a1bfdfc9a..e8a446bac3 100644
--- a/src/widget/wsearchlineedit.h
+++ b/src/widget/wsearchlineedit.h
@@ -64,14 +64,8 @@ class WSearchLineEdit : public QLineEdit, public WBaseWidget {
void refreshState();
- void updateEditBox(const QString& text);
-
- void showPlaceholder();
- bool shouldShowPlaceholder(const QString& text) const;
-
void enableSearch(const QString& text);
- void showSearchText(const QString& text);
-
+ void updateEditBox(const QString& text);
void updateClearButton(const QString& text);
QString getSearchText() const;