File indexing completed on 2024-12-08 06:41:46
0001 /* 0002 This file is part of the KDE project 0003 SPDX-FileCopyrightText: 2005 Hamish Rodda <rodda@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef CODECOMPLETIONTEST_MODEL_H 0009 #define CODECOMPLETIONTEST_MODEL_H 0010 0011 #include <QStringList> 0012 #include <ktexteditor/codecompletionmodel.h> 0013 0014 namespace KTextEditor 0015 { 0016 class View; 0017 } 0018 0019 class CodeCompletionTestModel : public KTextEditor::CodeCompletionModel 0020 { 0021 Q_OBJECT 0022 0023 public: 0024 explicit CodeCompletionTestModel(KTextEditor::View *parent = nullptr, const QString &startText = QString()); 0025 0026 KTextEditor::View *view() const; 0027 0028 void completionInvoked(KTextEditor::View *view, const KTextEditor::Range &range, InvocationType invocationType) override; 0029 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0030 0031 private: 0032 QString m_startText; 0033 bool m_autoStartText; 0034 }; 0035 0036 class AbbreviationCodeCompletionTestModel : public CodeCompletionTestModel 0037 { 0038 Q_OBJECT 0039 0040 public: 0041 explicit AbbreviationCodeCompletionTestModel(KTextEditor::View *parent = nullptr, const QString &startText = QString()); 0042 0043 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0044 0045 private: 0046 QStringList m_items; 0047 }; 0048 0049 class AsyncCodeCompletionTestModel : public CodeCompletionTestModel 0050 { 0051 Q_OBJECT 0052 0053 public: 0054 explicit AsyncCodeCompletionTestModel(KTextEditor::View *parent = nullptr, const QString &startText = QString()); 0055 0056 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; 0057 void completionInvoked(KTextEditor::View *view, const KTextEditor::Range &range, InvocationType invocationType) override; 0058 void setItems(const QStringList &items); 0059 0060 private: 0061 QStringList m_items; 0062 }; 0063 0064 #endif