4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Stefan Schimanski
9 * Full author contact details are available in file CREDITS.
12 #ifndef GUICOMPLETER_H
13 #define GUICOMPLETER_H
15 #include "frontends/WorkArea.h"
17 #include "DocIterator.h"
18 #include "FuncRequest.h"
19 #include "qt_helpers.h"
20 #include "support/docstring.h"
22 #include <QAbstractItemModel>
24 #include <QStringListModel>
35 class GuiCompleter : private QCompleter
41 GuiCompleter(GuiWorkArea * gui, QObject * parent = 0);
43 virtual ~GuiCompleter();
46 bool popupVisible() const;
48 bool inlineVisible() const;
50 bool popupPossible(Cursor const & cur) const;
52 bool inlinePossible(Cursor const & cur) const;
53 /// Activate the current completion, i.e. finalize it.
55 /// Do a completion as far as it is unique, but at least one character.
58 /// Update the visibility of the popup and the inline completion.
59 /// This method might set the update flags of the cursor to request
61 void updateVisibility(Cursor & cur, bool start, bool keep, bool cursorInView = true);
62 /// Update the visibility of the popup and the inline completion.
63 /// This method handles the redraw if needed.
64 void updateVisibility(bool start, bool keep);
66 QString currentCompletion() const;
68 docstring longestUniqueCompletion() const;
73 /// Show the inline completion.
78 void popupActivated(const QString & completion);
80 void popupHighlighted(const QString & completion);
84 void setCurrentCompletion(QString const & s);
86 void showPopup(Cursor & cur);
88 void showInline(Cursor & cur);
90 void updatePopup(Cursor & cur);
92 void updateInline(Cursor & cur, QString const & completion);
94 void updatePrefix(Cursor & cur);
96 void updateModel(Cursor & cur, bool popupUpdate, bool inlineUpdate);
98 bool eventFilter(QObject * watched, QEvent * event);
103 DocIterator old_cursor_;
107 QTimer inline_timer_;
109 QString last_selection_;
112 } // namespace frontend
115 #endif // GUICOMPLETER_H