File indexing completed on 2024-04-14 11:11:07

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 class CodeCompletionInterface;
0018 }
0019 
0020 class CodeCompletionTestModel : public KTextEditor::CodeCompletionModel
0021 {
0022     Q_OBJECT
0023 
0024 public:
0025     explicit CodeCompletionTestModel(KTextEditor::View *parent = nullptr, const QString &startText = QString());
0026 
0027     KTextEditor::View *view() const;
0028     KTextEditor::CodeCompletionInterface *cc() const;
0029 
0030     void completionInvoked(KTextEditor::View *view, const KTextEditor::Range &range, InvocationType invocationType) override;
0031     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
0032 
0033 private:
0034     QString m_startText;
0035     bool m_autoStartText;
0036 };
0037 
0038 class AbbreviationCodeCompletionTestModel : public CodeCompletionTestModel
0039 {
0040     Q_OBJECT
0041 
0042 public:
0043     explicit AbbreviationCodeCompletionTestModel(KTextEditor::View *parent = nullptr, const QString &startText = QString());
0044 
0045     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
0046 
0047 private:
0048     QStringList m_items;
0049 };
0050 
0051 class AsyncCodeCompletionTestModel : public CodeCompletionTestModel
0052 {
0053     Q_OBJECT
0054 
0055 public:
0056     explicit AsyncCodeCompletionTestModel(KTextEditor::View *parent = nullptr, const QString &startText = QString());
0057 
0058     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
0059     void completionInvoked(KTextEditor::View *view, const KTextEditor::Range &range, InvocationType invocationType) override;
0060     void setItems(const QStringList &items);
0061 
0062 private:
0063     QStringList m_items;
0064 };
0065 
0066 #endif