]> git.lyx.org Git - features.git/blob - src/frontends/qt/GuiCompleter.h
Remove unused forward declarations
[features.git] / src / frontends / qt / GuiCompleter.h
1 // -*- C++ -*-
2 /**
3  * \file GuiCompleter.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Stefan Schimanski
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef GUICOMPLETER_H
13 #define GUICOMPLETER_H
14
15 #include "DocIterator.h"
16 #include "support/docstring.h"
17
18 #include <QCompleter>
19 #include <QTimer>
20
21 namespace lyx {
22
23 namespace frontend {
24
25 class GuiWorkArea;
26 class CompleterItemDelegate;
27 class GuiCompletionModel;
28
29 class GuiCompleter : private QCompleter
30 {
31         Q_OBJECT
32
33 public:
34         ///
35         GuiCompleter(GuiWorkArea * gui, QObject * parent = 0);
36         ///
37         virtual ~GuiCompleter();
38
39         ///
40         bool popupVisible() const;
41         ///
42         bool inlineVisible() const;
43         ///
44         bool popupPossible(Cursor const & cur) const;
45         ///
46         bool inlinePossible(Cursor const & cur) const;
47         ///
48         bool completionAvailable() const;
49         /// Activate the current completion, i.e. finalize it.
50         void activate();
51         /// Do a completion as far as it is unique, but at least one character.
52         void tab();
53
54         /// Update the visibility of the popup and the inline completion.
55         /// This method might set the update flags of the cursor to request
56         /// a redraw.
57         void updateVisibility(Cursor & cur, bool start, bool keep);
58         /// Update the visibility of the popup and the inline completion.
59         /// This method handles the redraw if needed.
60         void updateVisibility(bool start, bool keep);
61         ///
62         QString currentCompletion() const;
63         ///
64         docstring longestUniqueCompletion() const;
65         ///
66         bool uniqueCompletionAvailable() const;
67
68 public Q_SLOTS:
69         /// Show the popup.
70         void showPopup();
71         /// Show the inline completion.
72         void showInline();
73
74         /// Hide the popup.
75         void hidePopup();
76         /// Hide the inline completion.
77         void hideInline();
78
79 private Q_SLOTS:
80         ///
81         void popupActivated(const QString & completion);
82         ///
83         void popupHighlighted(const QString & completion);
84         ///
85         void updateAvailability();
86         /// the asynchronous part of updatePopup(cur)
87         void asyncUpdatePopup();
88         /// the asynchronous part of hidePopup(cur)
89         void asyncHidePopup();
90         /// the asynchronous part of hideInline(cur)
91         void asyncHideInline();
92
93 private:
94         ///
95         void setCurrentCompletion(QString const & s);
96         ///
97         void showPopup(Cursor const & cur);
98         ///
99         void showInline(Cursor const & cur);
100         ///
101         void hideInline(Cursor const & cur);
102         ///
103         void updatePopup(Cursor const & cur);
104         ///
105         void updateInline(Cursor const & cur, QString const & completion);
106         ///
107         void updatePrefix(Cursor const & cur);
108         ///
109         void updateModel(Cursor const & cur, bool popupUpdate, bool inlineUpdate);
110         ///
111         bool eventFilter(QObject * watched, QEvent * event) override;
112
113         ///
114         GuiWorkArea * gui_;
115         ///
116         DocIterator old_cursor_;
117         ///
118         QTimer popup_timer_;
119         ///
120         QTimer inline_timer_;
121         ///
122         QString last_selection_;
123         /// lock to stop updates of the inline completion
124         int updateLock_;
125         /// the BufferView::inlineCursorPos might be reset by destructive
126         /// operations like backspace. Hence, we have to keep this flag
127         /// in addition to know whether the completion is to be kept visible.
128         bool inlineVisible_;
129         ///
130         bool popupVisible_;
131         /// the model reset is asynchronous in hidePopup/Inline. So let's mark
132         /// a coming reset here by setting it to false.
133         bool modelActive_;
134         ///
135         CompleterItemDelegate * itemDelegate_;
136         ///
137         GuiCompletionModel * model_;
138 }; // GuiCompleter
139
140 } // namespace frontend
141 } // namespace lyx
142
143 #endif // GUICOMPLETER_H