KTextEditor

katekeywordcompletion.h
1 /*
2  SPDX-FileCopyrightText: 2014 Sven Brauch <[email protected]>
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  */
22 {
23  Q_OBJECT
25 
26 public:
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;
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
Q_OBJECTQ_OBJECT
An item model for providing code completion, and meta information for enhanced presentation.
bool shouldAbortCompletion(KTextEditor::View *view, const KTextEditor::Range &range, const QString &currentCompletion) override
This function decides if the completion should be aborted.
Highlighting-file based keyword completion for the editor.
void completionInvoked(KTextEditor::View *view, const KTextEditor::Range &range, InvocationType invocationType) override
This function is responsible to generating / updating the list of current completions.
An object representing a section of text, from one Cursor to another.
MatchReaction matchingItem(const QModelIndex &matched) override
Called whenever an item in the completion-list perfectly matches the current filter text.
bool shouldStartCompletion(KTextEditor::View *view, const QString &insertedText, bool userInsertion, const KTextEditor::Cursor &position) override
This function decides if the automatic completion should be started when the user entered some text.
The Cursor represents a position in a Document.
Definition: cursor.h:71
A text widget with KXMLGUIClient that represents a Document.
Definition: view.h:146
Q_INTERFACES(...)
bool shouldHideItemsWithEqualNames() const override
When multiple completion models are used at the same time, it may happen that multiple models add ite...
KTextEditor::Range completionRange(KTextEditor::View *view, const KTextEditor::Cursor &position) override
This function returns the completion range that will be used for the current completion.
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Mar 23 2023 03:59:01 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.