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>
class Suggester;
-class SearchLineEdit;
+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(SearchLineEdit *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:
- SearchLineEdit *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