File indexing completed on 2025-01-05 04:49:29

0001 /*
0002    SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 #pragma once
0007 
0008 #include "quicktext_export.h"
0009 #include <QTreeView>
0010 class QContextMenuEvent;
0011 
0012 class QuicktextManager;
0013 class QUICKTEXT_EXPORT QuicktextTreeWidget : public QTreeView
0014 {
0015     Q_OBJECT
0016 public:
0017     explicit QuicktextTreeWidget(QuicktextManager *manager, QWidget *parent = nullptr);
0018     ~QuicktextTreeWidget() override;
0019 
0020     QuicktextManager *snippetsManager() const;
0021 
0022 protected:
0023     void contextMenuEvent(QContextMenuEvent *) override;
0024     void dropEvent(QDropEvent *) override;
0025 
0026 Q_SIGNALS:
0027     void insertSnippetText(const QString &str);
0028 
0029     void addSnippet();
0030     void editSnippet();
0031     void addSnippetGroup();
0032     void editSnippetGroup();
0033 
0034 private:
0035     void deleteSnippet();
0036     void deleteSnippetGroup();
0037     void selectionWasChanged();
0038     QuicktextManager *const mSnippetsManager;
0039     QAction *mAddSnippetAction = nullptr;
0040     QAction *mEditSnippetAction = nullptr;
0041     QAction *mDeleteSnippetAction = nullptr;
0042     QAction *mAddSnippetGroupAction = nullptr;
0043     QAction *mEditSnippetGroupAction = nullptr;
0044     QAction *mDeleteSnippetGroupAction = nullptr;
0045 };