File indexing completed on 2024-05-05 05:52:18
0001 /* This file is part of the Kate project. 0002 * Based on the snippet plugin from KDevelop 4. 0003 * 0004 * SPDX-FileCopyrightText: 2007 Robert Gruber <rgruber@users.sourceforge.net> 0005 * SPDX-FileCopyrightText: 2012 Christoph Cullmann <cullmann@kde.org> 0006 * 0007 * SPDX-License-Identifier: LGPL-2.0-or-later 0008 */ 0009 0010 #pragma once 0011 0012 #include "snippetcompletionmodel.h" 0013 0014 #include <QPointer> 0015 #include <QVariant> 0016 0017 #include <KTextEditor/View> 0018 0019 class Snippet; 0020 0021 /** 0022 * This is the main class of KDevelop's snippet plugin. 0023 * @author Robert Gruber <rgruber@users.sourceforge.net> 0024 */ 0025 class KateSnippetGlobal : public QObject 0026 { 0027 Q_OBJECT 0028 0029 public: 0030 explicit KateSnippetGlobal(QObject *parent, const QVariantList &args = QVariantList()); 0031 ~KateSnippetGlobal() override; 0032 0033 /** 0034 * Inserts the given @p snippet into the currently active view. 0035 * If the current active view is not inherited from KTextEditor::View 0036 * nothing will happen. 0037 */ 0038 void insertSnippet(Snippet *snippet); 0039 0040 static KateSnippetGlobal *self() 0041 { 0042 return s_self; 0043 } 0044 0045 /** 0046 * Code completion model. 0047 * @return code completion model for snippets 0048 */ 0049 SnippetCompletionModel *completionModel() 0050 { 0051 return &m_model; 0052 } 0053 0054 public Q_SLOTS: 0055 /** 0056 * Create snippet for given view, e.g. by using the selection 0057 * @param view view to create snippet for 0058 */ 0059 static void createSnippet(KTextEditor::View *view); 0060 0061 void insertSnippetFromActionData(); 0062 0063 private: 0064 static KateSnippetGlobal *s_self; 0065 SnippetCompletionModel m_model; 0066 QPointer<KTextEditor::View> m_activeViewForDialog; 0067 };