]> git.sur5r.net Git - minitube/blob - src/searchlineedit.h
5f9fd858d3496cf0ded401c2cb593af14ca704fb
[minitube] / src / searchlineedit.h
1 #ifndef SEARCHLINEEDIT_H
2 #define SEARCHLINEEDIT_H
3
4 #include "urllineedit.h"
5 #include "autocomplete.h"
6
7 #include <QLineEdit>
8 #include <QAbstractButton>
9
10 QT_BEGIN_NAMESPACE
11 class QMenu;
12 QT_END_NAMESPACE
13
14 class SearchButton;
15 class Suggester;
16
17 /*
18     Clear button on the right hand side of the search widget.
19     Hidden by default
20     "A circle with an X in it"
21  */
22 class ClearButton : public QAbstractButton
23 {
24     Q_OBJECT
25
26 public:
27     ClearButton(QWidget *parent = 0);
28     void paintEvent(QPaintEvent *event);
29
30 public slots:
31     void textChanged(const QString &text);
32 };
33
34
35 class SearchLineEdit : public ExLineEdit
36 {
37     Q_OBJECT
38     Q_PROPERTY(QString inactiveText READ inactiveText WRITE setInactiveText)
39
40 signals:
41     void textChanged(const QString &text);
42     void textEdited(const QString &text);
43     void search(const QString &text);
44     void suggestionAccepted(Suggestion *suggestion);
45
46 public:
47     SearchLineEdit(QWidget *parent = 0);
48
49     QString inactiveText() const;
50     void setInactiveText(const QString &text);
51
52     QMenu *menu() const;
53     void setMenu(QMenu *menu);
54     void updateGeometries();
55     void enableSuggest();
56     void preventSuggest();
57     void selectAll() { lineEdit()->selectAll(); }
58     void setSuggester(Suggester *suggester) { completion->setSuggester(suggester); }
59     void setText(const QString &text) { lineEdit()->setText(text); }
60
61 protected:
62     void resizeEvent(QResizeEvent *event);
63     void paintEvent(QPaintEvent *event);
64     void focusInEvent(QFocusEvent *event);
65
66 private slots:
67     void returnPressed();
68
69 private:
70     SearchButton *m_searchButton;
71     QString m_inactiveText;
72     AutoComplete *completion;
73 };
74
75 #endif // SEARCHLINEEDIT_H
76