File indexing completed on 2024-05-05 05:52:19

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: 2010 Milian Wolff <mail@milianw.de>
0006  *  SPDX-FileCopyrightText: 2012 Christoph Cullmann <cullmann@kde.org>
0007  *
0008  *  SPDX-License-Identifier: LGPL-2.0-or-later
0009  */
0010 
0011 #pragma once
0012 
0013 #include <KConfigGroup>
0014 #include <QStandardItemModel>
0015 
0016 class SnippetRepository;
0017 class KateSnippetGlobal;
0018 
0019 namespace KTextEditor
0020 {
0021 }
0022 
0023 /**
0024  * This class is implemented as singelton.
0025  * It represents the model containing all snippet repositories with their snippets.
0026  * @author Robert Gruber <rgruber@users.sourceforge.net>
0027  * @author Milian Wolff <mail@milianw.de>
0028  */
0029 class SnippetStore : public QStandardItemModel
0030 {
0031     Q_OBJECT
0032 
0033 public:
0034     /**
0035      * Initialize the SnippetStore.
0036      */
0037     static void init();
0038     /**
0039      * Returns the SnippetStore. Call init() to set it up first.
0040      */
0041     static SnippetStore *self();
0042 
0043     ~SnippetStore() override;
0044     static KConfigGroup getConfig();
0045     bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
0046     /**
0047      * Returns the repository for the given @p file if there is any.
0048      */
0049     SnippetRepository *repositoryForFile(const QString &file);
0050 
0051 private:
0052     SnippetStore();
0053 
0054     Qt::ItemFlags flags(const QModelIndex &index) const override;
0055 
0056     static SnippetStore *m_self;
0057 };