]> git.sur5r.net Git - minitube/blobdiff - src/autocomplete.h
Fix updating QUrl query parameters with Qt5.
[minitube] / src / autocomplete.h
index 9773380db7514520f5435c1933aea72f9045e5a9..df6089b389881220702fa59b73cc76ee9ff30138 100644 (file)
@@ -1,33 +1,75 @@
-#ifndef GOOGLESUGGEST_H
-#define GOOGLESUGGEST_H
+/* $BEGIN_LICENSE
+
+This file is part of Minitube.
+Copyright 2009, Flavio Tordini <flavio.tordini@gmail.com>
+
+Minitube is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+Minitube is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Minitube.  If not, see <http://www.gnu.org/licenses/>.
+
+$END_LICENSE */
+#ifndef AUTOCOMPLETE_H
+#define AUTOCOMPLETE_H
 
 #include <QtGui>
 
-class GSuggestCompletion : public QObject {
+class Suggester;
+class Suggestion;
+class SearchLineEdit;
+
+QT_FORWARD_DECLARE_CLASS(QListWidget)
+QT_FORWARD_DECLARE_CLASS(QListWidgetItem)
+QT_FORWARD_DECLARE_CLASS(QLineEdit)
+
+class AutoComplete : public QObject {
+
     Q_OBJECT
 
 public:
-    GSuggestCompletion(QWidget *parent, QLineEdit *editor);
-    ~GSuggestCompletion();
-    bool eventFilter(QObject *obj, QEvent *ev);
-    void showCompletion(const QStringList &choices);
-
-public slots:
-    void doneCompletion();
+    AutoComplete(SearchLineEdit *buddy, QLineEdit *lineEdit);
+    void setSuggester(Suggester* suggester);
+    QListWidget* getPopup() { return popup; }
     void preventSuggest();
     void enableSuggest();
-    void autoSuggest();
-    void handleNetworkData(QByteArray response);
-    void currentItemChanged(QListWidgetItem *current);
+
+signals:
+    void suggestionAccepted(Suggestion *suggestion);
+    void suggestionAccepted(const QString &value);
+
+protected:
+    bool eventFilter(QObject *obj, QEvent *ev);
+
+private slots:
+    void acceptSuggestion();
+    void suggest();
+    void itemEntered(QListWidgetItem *item);
+    void currentItemChanged(QListWidgetItem *item);
+    void suggestionsReady(const QList<Suggestion*> &suggestions);
+    void adjustPosition();
+    void enableItemHovering();
 
 private:
-    QWidget *buddy;
-    QLineEdit *editor;
+    void showSuggestions(const QList<Suggestion*> &suggestions);
+    void hideSuggestions();
+
+    SearchLineEdit *buddy;
+    QLineEdit *lineEdit;
     QString originalText;
     QListWidget *popup;
     QTimer *timer;
     bool enabled;
-
+    Suggester *suggester;
+    QList<Suggestion*> suggestions;
+    bool itemHovering;
 };
 
-#endif // GOOGLESUGGEST_H
+#endif // AUTOCOMPLETE_H