1 /*
2     SPDX-FileCopyrightText: 2014 Sven Brauch <svenbrauch@gmail.com>
3 
4     SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #ifndef KATEKEYWORDCOMPLETIONMODEL_H
8 #define KATEKEYWORDCOMPLETIONMODEL_H
9 
10 #include "codecompletionmodelcontrollerinterface.h"
11 #include "ktexteditor/codecompletionmodel.h"
12 
13 /**
14  * @brief Highlighting-file based keyword completion for the editor.
15  *
16  * This model offers completion of language-specific keywords based on information
17  * taken from the kate syntax files. It queries the highlighting engine to get the
18  * correct context for a given cursor position, then suggests all keyword items
19  * from the XML file for the active language.
20  */
21 class KateKeywordCompletionModel : public KTextEditor::CodeCompletionModel, public KTextEditor::CodeCompletionModelControllerInterface
22 {
23     Q_OBJECT
24     Q_INTERFACES(KTextEditor::CodeCompletionModelControllerInterface)
25 
26 public:
27     explicit KateKeywordCompletionModel(QObject *parent);
28     QVariant data(const QModelIndex &index, int role) const override;
29     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
30     QModelIndex parent(const QModelIndex &index) const override;
31     QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
32     void completionInvoked(KTextEditor::View *view, const KTextEditor::Range &range, InvocationType invocationType) override;
33     KTextEditor::Range completionRange(KTextEditor::View *view, const KTextEditor::Cursor &position) override;
34     bool shouldAbortCompletion(KTextEditor::View *view, const KTextEditor::Range &range, const QString &currentCompletion) override;
35     bool shouldStartCompletion(KTextEditor::View *view, const QString &insertedText, bool userInsertion, const KTextEditor::Cursor &position) override;
36     MatchReaction matchingItem(const QModelIndex &matched) override;
37     bool shouldHideItemsWithEqualNames() const override;
38 
39 private:
40     QList<QString> m_items;
41 };
42 
43 #endif // KATEKEYWORDCOMPLETIONMODEL_H
44 
45 // kate: indent-width 4; replace-tabs on
46