]> git.sur5r.net Git - minitube/commitdiff
Set searchbox text
authorFlavio <flavio@odisseo.local>
Thu, 28 Jun 2012 15:48:01 +0000 (17:48 +0200)
committerFlavio <flavio@odisseo.local>
Thu, 28 Jun 2012 15:48:01 +0000 (17:48 +0200)
src/SearchView.cpp
src/autocomplete.cpp
src/autocomplete.h
src/searchlineedit.h

index 942873646627d1e494d6e593c85d2886b58356a8..ad6fe92a896810e213948edec191b505dcaafef1 100644 (file)
@@ -335,6 +335,9 @@ void SearchView::watchKeywords(QString query) {
         return;
     }
 
+    if (typeCombo->currentIndex() == 0)
+        queryEdit->setText(query);
+
     SearchParams *searchParams = new SearchParams();
     searchParams->setKeywords(query);
 
index 2ba1826016aef47ac859e8eaccdf7c096e7aefd8..ac09e9c5510b90bd08a4b4e2491b61982bb5b4ea 100644 (file)
@@ -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());
     }
 }
index 0962770513621d12280e065d559bf7905ea7a5a6..0f0e267c3f0b3276e49e27ffe1037b91d4af01f4 100644 (file)
@@ -4,12 +4,13 @@
 #include <QtGui>
 
 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;
index da01ca8afec2ae87fdd49f7045dbba84f0b90583..909443556fd2612f3e67b663faa0ba5189c5b1fa 100644 (file)
@@ -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);