]> git.sur5r.net Git - minitube/blobdiff - src/autocomplete.h
Upload 3.9.3-2 to unstable
[minitube] / src / autocomplete.h
index 0962770513621d12280e065d559bf7905ea7a5a6..a7263e6d4ae8944070a29c670f7e71c03d2293c7 100644 (file)
@@ -1,41 +1,75 @@
-#ifndef SUGGESTCOMPLETION_H
-#define SUGGESTCOMPLETION_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 Suggester;
+class Suggestion;
+class SearchWidget;
+
+QT_FORWARD_DECLARE_CLASS(QListWidget)
+QT_FORWARD_DECLARE_CLASS(QListWidgetItem)
+QT_FORWARD_DECLARE_CLASS(QLineEdit)
 
 class AutoComplete : public QObject {
+
     Q_OBJECT
 
 public:
-    AutoComplete(QWidget *parent, QLineEdit *editor);
-    ~AutoComplete();
-    bool eventFilter(QObject *obj, QEvent *ev);
-    void showCompletion(const QStringList &choices);
+    AutoComplete(SearchWidget *buddy, QLineEdit *lineEdit);
     void setSuggester(Suggester* suggester);
     QListWidget* getPopup() { return popup; }
-
-public slots:
-    void doneCompletion();
     void preventSuggest();
     void enableSuggest();
-    void autoSuggest();
-    void currentItemChanged(QListWidgetItem *current);
-    void suggestionsReady(QStringList suggestions);
 
 signals:
-    void suggestionAccepted(const QString &suggestion);
+    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 QVector<Suggestion*> &suggestions);
+    void adjustPosition();
+    void enableItemHovering();
 
 private:
-    QWidget *buddy;
-    QLineEdit *editor;
+    void showSuggestions(const QVector<Suggestion*> &suggestions);
+    void hideSuggestions();
+
+    SearchWidget *buddy;
+    QLineEdit *lineEdit;
     QString originalText;
     QListWidget *popup;
     QTimer *timer;
     bool enabled;
-    Suggester* suggester;
-
+    Suggester *suggester;
+    QVector<Suggestion*> suggestions;
+    bool itemHovering;
 };
 
-#endif // SUGGESTCOMPLETION_H
+#endif // AUTOCOMPLETE_H