From f97fe9c69bb7e86010718a078f0340ea00f2ca20 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Wed, 27 Jun 2012 17:28:44 +0200 Subject: [PATCH] Mostly port LibraryFilterWidget to qocoa. --- src/library/libraryfilterwidget.cpp | 30 +++++++++-------------------- src/library/libraryfilterwidget.h | 6 ------ src/library/libraryfilterwidget.ui | 8 ++++---- 3 files changed, 13 insertions(+), 31 deletions(-) diff --git a/src/library/libraryfilterwidget.cpp b/src/library/libraryfilterwidget.cpp index 2fefabe1f..75e58f32c 100644 --- a/src/library/libraryfilterwidget.cpp +++ b/src/library/libraryfilterwidget.cpp @@ -22,7 +22,6 @@ #include "ui_libraryfilterwidget.h" #include "ui/iconloader.h" #include "ui/settingsdialog.h" -#include "widgets/maclineedit.h" #include #include @@ -41,7 +40,7 @@ LibraryFilterWidget::LibraryFilterWidget(QWidget *parent) delay_behaviour_(DelayedOnLargeLibraries) { ui_->setupUi(this); - connect(ui_->filter, SIGNAL(returnPressed()), SIGNAL(ReturnPressed())); + //connect(ui_->filter, SIGNAL(returnPressed()), SIGNAL(ReturnPressed())); connect(filter_delay_, SIGNAL(timeout()), SLOT(FilterDelayTimeout())); filter_delay_->setInterval(kFilterDelay); @@ -93,18 +92,7 @@ LibraryFilterWidget::LibraryFilterWidget(QWidget *parent) library_menu_->addSeparator(); ui_->options->setMenu(library_menu_); -#ifdef Q_OS_DARWIN - QString hint = ui_->filter->hint(); - delete ui_->filter; - MacLineEdit* lineedit = new MacLineEdit(this); - ui_->horizontalLayout->insertWidget(1, lineedit); - filter_ = lineedit; - filter_->set_hint(hint); -#else - filter_ = ui_->filter; -#endif - - connect(filter_->widget(), SIGNAL(textChanged(QString)), SLOT(FilterTextChanged(QString))); + connect(ui_->filter, SIGNAL(textChanged(QString)), SLOT(FilterTextChanged(QString))); } LibraryFilterWidget::~LibraryFilterWidget() { @@ -144,7 +132,7 @@ QAction* LibraryFilterWidget::CreateGroupByAction( } void LibraryFilterWidget::FocusOnFilter(QKeyEvent *event) { - ui_->filter->set_focus(); + ui_->filter->setFocus(); QApplication::sendEvent(ui_->filter, event); } @@ -214,12 +202,12 @@ void LibraryFilterWidget::GroupingChanged(const LibraryModel::Grouping& g) { } void LibraryFilterWidget::SetFilterHint(const QString& hint) { - filter_->set_hint(hint); + ui_->filter->setPlaceholderText(hint); } void LibraryFilterWidget::SetQueryMode(QueryOptions::QueryMode query_mode) { - filter_->clear(); - filter_->set_enabled(query_mode == QueryOptions::QueryMode_All); + ui_->filter->clear(); + ui_->filter->setEnabled(query_mode == QueryOptions::QueryMode_All); model_->SetFilterQueryMode(query_mode); } @@ -249,7 +237,7 @@ void LibraryFilterWidget::keyReleaseEvent(QKeyEvent* e) { break; case Qt::Key_Escape: - filter_->clear(); + ui_->filter->clear(); e->accept(); break; } @@ -276,8 +264,8 @@ void LibraryFilterWidget::FilterTextChanged(const QString& text) { } void LibraryFilterWidget::FilterDelayTimeout() { - emit Filter(filter_->text()); + emit Filter(ui_->filter->text()); if (filter_applies_to_model_) { - model_->SetFilterText(filter_->text()); + model_->SetFilterText(ui_->filter->text()); } } diff --git a/src/library/libraryfilterwidget.h b/src/library/libraryfilterwidget.h index 34fe0b1f9..572bb1185 100644 --- a/src/library/libraryfilterwidget.h +++ b/src/library/libraryfilterwidget.h @@ -25,7 +25,6 @@ #include "librarymodel.h" class GroupByDialog; -class LineEditInterface; class SettingsDialog; class Ui_LibraryFilterWidget; @@ -107,11 +106,6 @@ class LibraryFilterWidget : public QWidget { DelayBehaviour delay_behaviour_; QString settings_group_; - - // Since on Mac ui_->filter is nonexistent and on other platforms - // filter_ == ui_->filter, make sure to always use this field and - // not the one in the ui_ object! - LineEditInterface* filter_; }; #endif // LIBRARYFILTERWIDGET_H diff --git a/src/library/libraryfilterwidget.ui b/src/library/libraryfilterwidget.ui index 275c77717..bd69585e9 100644 --- a/src/library/libraryfilterwidget.ui +++ b/src/library/libraryfilterwidget.ui @@ -21,7 +21,7 @@ 0 - + Enter search terms here @@ -98,9 +98,9 @@ - LineEdit - QLineEdit -
widgets/lineedit.h
+ QSearchField + QWidget +
3rdparty/qocoa/qsearchfield.h