File indexing completed on 2024-04-21 04:34:26
0001 /* 0002 Copyright (C) 2009 Niko Sams <niko.sams@gmail.com> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License version 2 as published by the Free Software Foundation. 0007 0008 This library is distributed in the hope that it will be useful, 0009 but WITHOUT ANY WARRANTY; without even the implied warranty of 0010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0011 Library General Public License for more details. 0012 0013 You should have received a copy of the GNU Library General Public License 0014 along with this library; see the file COPYING.LIB. If not, write to 0015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0016 Boston, MA 02110-1301, USA. 0017 */ 0018 0019 #ifndef CSS_CODECOMPLETIONMODEL_H 0020 #define CSS_CODECOMPLETIONMODEL_H 0021 0022 #include <KTextEditor/CodeCompletionModel> 0023 #include <KTextEditor/CodeCompletionModelControllerInterface> 0024 0025 namespace Css { 0026 0027 class CodeCompletionModel : public KTextEditor::CodeCompletionModel, public KTextEditor::CodeCompletionModelControllerInterface 0028 { 0029 Q_OBJECT 0030 Q_INTERFACES(KTextEditor::CodeCompletionModelControllerInterface) 0031 0032 public: 0033 CodeCompletionModel(QObject *parent); 0034 void completionInvoked(KTextEditor::View* view, const KTextEditor::Range& range, InvocationType invocationType) override; 0035 0036 QVariant data(const QModelIndex & index, int role) const override; 0037 0038 KTextEditor::Range completionRange(KTextEditor::View* view, const KTextEditor::Cursor &position) override; 0039 bool shouldAbortCompletion(KTextEditor::View* view, const KTextEditor::Range& range, const QString ¤tCompletion) override; 0040 bool shouldStartCompletion(KTextEditor::View* view, const QString& insertedText, bool userInsertion, const KTextEditor::Cursor& position) override; 0041 0042 virtual void executeCompletionItem2(KTextEditor::Document* document, const KTextEditor::Range& word, const QModelIndex& index) const; 0043 0044 enum CompletionContext { 0045 NoContext, 0046 SelectorContext, 0047 PropertyContext, 0048 ValueContext 0049 }; 0050 private: 0051 CompletionContext m_completionContext; 0052 QList<QString> m_items; 0053 }; 0054 0055 } 0056 0057 #endif // CSS_CODECOMPLETIONMODEL_H