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: 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 <QDialog>
0014 
0015 #include <memory>
0016 
0017 namespace KTextEditor
0018 {
0019 class View;
0020 }
0021 
0022 class SnippetRepository;
0023 class Snippet;
0024 
0025 namespace Ui
0026 {
0027 class EditSnippetBase;
0028 }
0029 
0030 /**
0031  * This dialog is used to create/edit snippets in a given repository.
0032  *
0033  * @author Milian Wolff <mail@milianw.de>
0034  */
0035 class EditSnippet : public QDialog
0036 {
0037     Q_OBJECT
0038 
0039 public:
0040     /// @p snippet set to 0 when you want to create a new snippet.
0041     explicit EditSnippet(SnippetRepository *repo, Snippet *snippet, QWidget *parent = nullptr);
0042     ~EditSnippet() override;
0043 
0044     void setSnippetText(const QString &text);
0045 
0046     void reject() override;
0047 
0048 private:
0049     std::unique_ptr<Ui::EditSnippetBase> const m_ui;
0050     SnippetRepository *m_repo;
0051     Snippet *m_snippet;
0052     KTextEditor::View *m_snippetView;
0053     KTextEditor::View *m_scriptsView;
0054     KTextEditor::View *m_testView;
0055     bool m_topBoxModified;
0056     QPushButton *m_okButton;
0057 
0058 private Q_SLOTS:
0059     void test();
0060     void save();
0061     void validate();
0062     void topBoxModified();
0063 };