From: Flavio Date: Thu, 28 Jun 2012 15:48:01 +0000 (+0200) Subject: Set searchbox text X-Git-Tag: 1.8~3 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=289c1248571cd31b08025d447c19cdb3c02bb463;p=minitube Set searchbox text --- diff --git a/src/SearchView.cpp b/src/SearchView.cpp index 9428736..ad6fe92 100644 --- a/src/SearchView.cpp +++ b/src/SearchView.cpp @@ -335,6 +335,9 @@ void SearchView::watchKeywords(QString query) { return; } + if (typeCombo->currentIndex() == 0) + queryEdit->setText(query); + SearchParams *searchParams = new SearchParams(); searchParams->setKeywords(query); diff --git a/src/autocomplete.cpp b/src/autocomplete.cpp index 2ba1826..ac09e9c 100644 --- a/src/autocomplete.cpp +++ b/src/autocomplete.cpp @@ -1,9 +1,15 @@ #include "autocomplete.h" #include "suggester.h" +#ifdef APP_MAC +#include "searchlineedit_mac.h" +#else +#include "searchlineedit.h" +#endif -AutoComplete::AutoComplete(QWidget *parent, QLineEdit *editor): - QObject(parent), buddy(parent), editor(editor), suggester(0) { +AutoComplete::AutoComplete(SearchLineEdit *parent, QLineEdit *editor): + QObject(parent), editor(editor), suggester(0) { + buddy = parent; enabled = true; popup = new QListWidget; @@ -49,7 +55,7 @@ bool AutoComplete::eventFilter(QObject *obj, QEvent *ev) { if (ev->type() == QEvent::MouseButtonPress) { popup->hide(); buddy->setFocus(); - editor->setText(originalText); + buddy->setText(originalText); return true; } @@ -133,7 +139,7 @@ void AutoComplete::doneCompletion() { buddy->setFocus(); QListWidgetItem *item = popup->currentItem(); if (item) { - editor->setText(item->text()); + buddy->setText(item->text()); emit suggestionAccepted(item->text()); } } @@ -182,7 +188,7 @@ void AutoComplete::currentItemChanged(QListWidgetItem *current) { if (current) { // qDebug() << "current" << current->text(); current->setSelected(true); - editor->setText(current->text()); + buddy->setText(current->text()); editor->setSelection(originalText.length(), editor->text().length()); } } diff --git a/src/autocomplete.h b/src/autocomplete.h index 0962770..0f0e267 100644 --- a/src/autocomplete.h +++ b/src/autocomplete.h @@ -4,12 +4,13 @@ #include class Suggester; +class SearchLineEdit; class AutoComplete : public QObject { Q_OBJECT public: - AutoComplete(QWidget *parent, QLineEdit *editor); + AutoComplete(SearchLineEdit *parent, QLineEdit *editor); ~AutoComplete(); bool eventFilter(QObject *obj, QEvent *ev); void showCompletion(const QStringList &choices); @@ -28,7 +29,7 @@ signals: void suggestionAccepted(const QString &suggestion); private: - QWidget *buddy; + SearchLineEdit *buddy; QLineEdit *editor; QString originalText; QListWidget *popup; diff --git a/src/searchlineedit.h b/src/searchlineedit.h index da01ca8..9094435 100644 --- a/src/searchlineedit.h +++ b/src/searchlineedit.h @@ -96,6 +96,7 @@ public: void preventSuggest(); void selectAll() { lineEdit()->selectAll(); } void setSuggester(Suggester *suggester) { completion->setSuggester(suggester); } + void setText(const QString &text) { lineEdit()->setText(text); } protected: void resizeEvent(QResizeEvent *event);