Warning, file /pim/mailcommon/src/snippets/snippetsmanager.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002   SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
0003   SPDX-FileContributor: Tobias Koenig <tokoe@kdab.com>
0004 
0005   SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org>
0006 
0007   SPDX-License-Identifier: LGPL-2.0-or-later
0008 */
0009 
0010 #pragma once
0011 
0012 #include "mailcommon_export.h"
0013 
0014 #include <QObject>
0015 #include <memory>
0016 class KActionCollection;
0017 
0018 class QAbstractItemModel;
0019 class QAction;
0020 class QItemSelectionModel;
0021 namespace MailCommon
0022 {
0023 /**
0024  * @brief The SnippetInfo struct
0025  * @author Laurent Montel <montel@kde.org>
0026  */
0027 struct MAILCOMMON_EXPORT SnippetInfo {
0028     SnippetInfo(const QString &_subject, const QString &_text, const QString &_to, const QString &_cc, const QString &_bcc, const QString &_attachment)
0029         : subject(_subject)
0030         , text(_text)
0031         , to(_to)
0032         , cc(_cc)
0033         , bcc(_bcc)
0034         , attachment(_attachment)
0035     {
0036     }
0037 
0038     QString subject;
0039     QString text;
0040     QString to;
0041     QString cc;
0042     QString bcc;
0043     QString attachment;
0044 };
0045 /**
0046  * @brief The SnippetsManager class
0047  * @author Laurent Montel <montel@kde.org>
0048  */
0049 class MAILCOMMON_EXPORT SnippetsManager : public QObject
0050 {
0051     Q_OBJECT
0052 public:
0053     /**
0054      * Creates a new snippets manager.
0055      *
0056      * @param actionCollection The action collection where the manager will
0057      *                         register the snippet shortcuts at.
0058      * @param parent The parent object.
0059      * @param widget The widget.
0060      */
0061     explicit SnippetsManager(KActionCollection *actionCollection, QObject *parent = nullptr, QWidget *widget = nullptr);
0062 
0063     /**
0064      * Destroys the snippets manager.
0065      */
0066     ~SnippetsManager() override;
0067     /**
0068      * Returns the model that represents the snippets.
0069      */
0070     QAbstractItemModel *model() const;
0071 
0072     /**
0073      * Returns the selection model that is used by the manager to select the
0074      * snippet or snippet group to work on.
0075      */
0076     QItemSelectionModel *selectionModel() const;
0077 
0078     /**
0079      * Returns the action that handles adding new snippets.
0080      */
0081     QAction *addSnippetAction() const;
0082 
0083     /**
0084      * Returns the action that handles editing the currently selected snippet.
0085      */
0086     QAction *editSnippetAction() const;
0087 
0088     /**
0089      * Returns the action that handles deleting the currently selected snippet.
0090      */
0091     QAction *deleteSnippetAction() const;
0092 
0093     /**
0094      * Returns the action that handles adding new snippet groups.
0095      */
0096     QAction *addSnippetGroupAction() const;
0097 
0098     /**
0099      * Returns the action that handles editing the currently selected snippet group.
0100      */
0101     QAction *editSnippetGroupAction() const;
0102 
0103     /**
0104      * Returns the action that handles deleting the currently selected snippet group.
0105      */
0106     QAction *deleteSnippetGroupAction() const;
0107 
0108     /**
0109      * Returns the action that handles inserting a snippet into the editor.
0110      */
0111     QAction *insertSnippetAction() const;
0112 
0113     /**
0114      * Returns whether the currently selected item is a snippet group.
0115      */
0116     [[nodiscard]] bool snippetGroupSelected() const;
0117 
0118     /**
0119      * Returns the name of the currently selected snippet or snippet group.
0120      */
0121     [[nodiscard]] QString selectedName() const;
0122 
0123 Q_SIGNALS:
0124     void insertSnippet();
0125     void insertSnippetInfo(const SnippetInfo &info);
0126 
0127 private:
0128     //@cond PRIVATE
0129     class SnippetsManagerPrivate;
0130     std::unique_ptr<SnippetsManagerPrivate> const d;
0131     //@endcond
0132 };
0133 }