File indexing completed on 2024-04-14 03:55:03
0001 /* 0002 SPDX-FileCopyrightText: 2014 Sven Brauch <svenbrauch@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KATEKEYWORDCOMPLETIONMODEL_H 0008 #define KATEKEYWORDCOMPLETIONMODEL_H 0009 0010 #include "codecompletionmodelcontrollerinterface.h" 0011 #include "ktexteditor/codecompletionmodel.h" 0012 0013 /** 0014 * @brief Highlighting-file based keyword completion for the editor. 0015 * 0016 * This model offers completion of language-specific keywords based on information 0017 * taken from the kate syntax files. It queries the highlighting engine to get the 0018 * correct context for a given cursor position, then suggests all keyword items 0019 * from the XML file for the active language. 0020 */ 0021 class KateKeywordCompletionModel : public KTextEditor::CodeCompletionModel, public KTextEditor::CodeCompletionModelControllerInterface 0022 { 0023 Q_OBJECT 0024 Q_INTERFACES(KTextEditor::CodeCompletionModelControllerInterface) 0025 0026 public: 0027 explicit KateKeywordCompletionModel(QObject *parent); 0028 QVariant data(const QModelIndex &index, int role) const override; 0029 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0030 QModelIndex parent(const QModelIndex &index) const override; 0031 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; 0032 void completionInvoked(KTextEditor::View *view, const KTextEditor::Range &range, InvocationType invocationType) override; 0033 KTextEditor::Range completionRange(KTextEditor::View *view, const KTextEditor::Cursor &position) override; 0034 bool shouldAbortCompletion(KTextEditor::View *view, const KTextEditor::Range &range, const QString ¤tCompletion) override; 0035 bool shouldStartCompletion(KTextEditor::View *view, const QString &insertedText, bool userInsertion, const KTextEditor::Cursor &position) override; 0036 MatchReaction matchingItem(const QModelIndex &matched) override; 0037 bool shouldHideItemsWithEqualNames() const override; 0038 0039 private: 0040 QList<QString> m_items; 0041 }; 0042 0043 #endif // KATEKEYWORDCOMPLETIONMODEL_H 0044 0045 // kate: indent-width 4; replace-tabs on