1 #ifndef COMPLETERWINDOW_H
2 #define COMPLETERWINDOW_H
3 
4 #include "expectedtoken.h"
5 #include "completionhelper.h"
6 #include "guiSQLiteStudio_global.h"
7 #include <QDialog>
8 #include <QModelIndex>
9 
10 namespace Ui {
11     class CompleterWindow;
12 }
13 
14 class CompleterModel;
15 class QSizeGrip;
16 class SqlEditor;
17 
18 class GUI_API_EXPORT CompleterWindow : public QDialog
19 {
20         Q_OBJECT
21 
22     public:
23         explicit CompleterWindow(SqlEditor* parent = 0);
24         ~CompleterWindow();
25 
26         void reset();
27         void setData(const CompletionHelper::Results& completionResults);
28         void setDb(Db* db);
29         ExpectedTokenPtr getSelected();
30         int getNumberOfCharsToRemove();
31         void shringFilterBy(int chars);
32         void extendFilterBy(const QString& text);
33         bool immediateResolution();
34 
35     protected:
36         void changeEvent(QEvent *e);
37         void keyPressEvent(QKeyEvent* e);
38         void showEvent(QShowEvent* e);
39 
40     private:
41         void updateCurrent();
42         QString getStatusMsg(const QModelIndex& index);
43         void updateFilter();
44         void init();
45 
46         Ui::CompleterWindow *ui = nullptr;
47         CompleterModel* model = nullptr;
48         SqlEditor* sqlEditor = nullptr;
49         QString filter;
50         Db* db = nullptr;
51         bool wrappedFilter = false;
52 
53     private slots:
54         void focusOut();
55         void doubleClicked(const QModelIndex& index);
56         void currentRowChanged(const QModelIndex& current, const QModelIndex& previous);
57 
58     signals:
59         void textTyped(const QString& text);
60         void backspacePressed();
61         void leftPressed();
62         void rightPressed();
63 };
64 
65 #endif // COMPLETERWINDOW_H
66