forked from bicomsystems/outcall2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SearchBox.h
59 lines (44 loc) · 1.02 KB
/
SearchBox.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef SEARCHBOX_H
#define SEARCHBOX_H
#include <QObject>
#include <QLineEdit>
class QTimer;
class QTreeWidget;
class SearchBoxCompleter : public QObject
{
Q_OBJECT
public:
SearchBoxCompleter(QLineEdit *parent = 0);
~SearchBoxCompleter();
bool eventFilter(QObject *obj, QEvent *ev);
void showCompletion(const QStringList &choices);
void setFilter(QString filter);
void setData(QStringList data);
protected slots:
void preventSuggest();
void autoSuggest();
void onSelected();
signals:
void selected(QString text);
private:
QLineEdit *m_editor;
QTreeWidget *m_popup;
QTimer *m_timer;
QStringList m_data;
QString m_filter;
};
class SearchBox : public QLineEdit
{
Q_OBJECT
public:
SearchBox(QWidget *parent = 0);
void setFilter(QString filter);
void setData(QStringList data);
protected slots:
void onSelected(QString text);
signals:
void selected(QString text);
private:
SearchBoxCompleter *m_completer;
};
#endif // SEARCHBOX_H