]> git.sur5r.net Git - minitube/blobdiff - src/autocomplete.h
Fix updating QUrl query parameters with Qt5.
[minitube] / src / autocomplete.h
index 65673f9fb5973b0e753ff21708bf81af51f4f034..df6089b389881220702fa59b73cc76ee9ff30138 100644 (file)
@@ -17,49 +17,59 @@ 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 SUGGESTCOMPLETION_H
-#define SUGGESTCOMPLETION_H
+#ifndef AUTOCOMPLETE_H
+#define AUTOCOMPLETE_H
 
 #include <QtGui>
-#if QT_VERSION >= 0x050000
-#include <QtWidgets>
-#endif
 
 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:
-    AutoComplete(SearchLineEdit *parent, QLineEdit *editor);
-    ~AutoComplete();
-    bool eventFilter(QObject *obj, QEvent *ev);
-    void showCompletion(const QStringList &choices);
+    AutoComplete(SearchLineEdit *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 QList<Suggestion*> &suggestions);
+    void adjustPosition();
+    void enableItemHovering();
 
 private:
+    void showSuggestions(const QList<Suggestion*> &suggestions);
+    void hideSuggestions();
+
     SearchLineEdit *buddy;
-    QLineEdit *editor;
+    QLineEdit *lineEdit;
     QString originalText;
     QListWidget *popup;
     QTimer *timer;
     bool enabled;
-    Suggester* suggester;
-
+    Suggester *suggester;
+    QList<Suggestion*> suggestions;
+    bool itemHovering;
 };
 
-#endif // SUGGESTCOMPLETION_H
+#endif // AUTOCOMPLETE_H