-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCompletedLineEdit.h
46 lines (31 loc) · 930 Bytes
/
CompletedLineEdit.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
#ifndef COMPLETEDLINEEDIT_H
#define COMPLETEDLINEEDIT_H
#include <QLineEdit>
#include <QtSql>
class QAbstractItemModel;
class CompletedLineEdit : public QLineEdit
{
Q_OBJECT
public:
CompletedLineEdit(QWidget *parent = 0);
~CompletedLineEdit();
void setCompleter(QCompleter *c);
QCompleter *completer() const;
void createFromSimpleDatabaseTable( QSqlDatabase db, const QString& tableName );
void readWordsAndCreateCompleter( bool isReread = false );
protected:
bool event(QEvent* event) Q_DECL_OVERRIDE;
void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
void focusInEvent(QFocusEvent *e) Q_DECL_OVERRIDE;
private slots:
void insertCompletion(const QString &completion);
private:
QString textUnderCursor() const;
QPair<int, int> wordRangeUnderCursor() const;
private:
QCompleter *c;
static QMap<QString,QStringList> completerList;
QSqlDatabase db;
QString tableName;
};
#endif // COMPLETEDLINEEDIT_H