Mailcommon

snippetsmanager.h
1/*
2 SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
3 SPDX-FileContributor: Tobias Koenig <tokoe@kdab.com>
4
5 SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org>
6
7 SPDX-License-Identifier: LGPL-2.0-or-later
8*/
9
10#pragma once
11
12#include "mailcommon_export.h"
13
14#include <QObject>
15#include <memory>
17
19class QAction;
21namespace MailCommon
22{
23/**
24 * @brief The SnippetInfo struct
25 * @author Laurent Montel <montel@kde.org>
26 */
27struct MAILCOMMON_EXPORT SnippetInfo {
28 SnippetInfo(const QString &_subject, const QString &_text, const QString &_to, const QString &_cc, const QString &_bcc, const QString &_attachment)
29 : subject(_subject)
30 , text(_text)
31 , to(_to)
32 , cc(_cc)
33 , bcc(_bcc)
34 , attachment(_attachment)
35 {
36 }
37
38 QString subject;
39 QString text;
40 QString to;
41 QString cc;
42 QString bcc;
43 QString attachment;
44};
45/**
46 * @brief The SnippetsManager class
47 * @author Laurent Montel <montel@kde.org>
48 */
49class MAILCOMMON_EXPORT SnippetsManager : public QObject
50{
51 Q_OBJECT
52public:
53 /**
54 * Creates a new snippets manager.
55 *
56 * @param actionCollection The action collection where the manager will
57 * register the snippet shortcuts at.
58 * @param parent The parent object.
59 * @param widget The widget.
60 */
61 explicit SnippetsManager(KActionCollection *actionCollection, QObject *parent = nullptr, QWidget *widget = nullptr);
62
63 /**
64 * Destroys the snippets manager.
65 */
66 ~SnippetsManager() override;
67 /**
68 * Returns the model that represents the snippets.
69 */
70 [[nodiscard]] QAbstractItemModel *model() const;
71
72 /**
73 * Returns the selection model that is used by the manager to select the
74 * snippet or snippet group to work on.
75 */
76 [[nodiscard]] QItemSelectionModel *selectionModel() const;
77
78 /**
79 * Returns the action that handles adding new snippets.
80 */
81 [[nodiscard]] QAction *addSnippetAction() const;
82
83 /**
84 * Returns the action that handles editing the currently selected snippet.
85 */
86 [[nodiscard]] QAction *editSnippetAction() const;
87
88 /**
89 * Returns the action that handles deleting the currently selected snippet.
90 */
91 [[nodiscard]] QAction *deleteSnippetAction() const;
92
93 /**
94 * Returns the action that handles adding new snippet groups.
95 */
96 [[nodiscard]] QAction *addSnippetGroupAction() const;
97
98 /**
99 * Returns the action that handles editing the currently selected snippet group.
100 */
101 [[nodiscard]] QAction *editSnippetGroupAction() const;
102
103 /**
104 * Returns the action that handles deleting the currently selected snippet group.
105 */
106 [[nodiscard]] QAction *deleteSnippetGroupAction() const;
107
108 /**
109 * Returns the action that handles inserting a snippet into the editor.
110 */
111 [[nodiscard]] QAction *insertSnippetAction() const;
112
113 /**
114 * Returns whether the currently selected item is a snippet group.
115 */
116 [[nodiscard]] bool snippetGroupSelected() const;
117
118 /**
119 * Returns the name of the currently selected snippet or snippet group.
120 */
121 [[nodiscard]] QString selectedName() const;
122
123Q_SIGNALS:
124 void insertSnippet();
125 void insertSnippetInfo(const SnippetInfo &info);
126
127private:
128 //@cond PRIVATE
129 class SnippetsManagerPrivate;
130 std::unique_ptr<SnippetsManagerPrivate> const d;
131 //@endcond
132};
133}
The SnippetsManager class.
The filter dialog.
The SnippetInfo struct.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:58:44 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.