Mailcommon

snippetsmanager.h
1 /*
2  SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
3  SPDX-FileContributor: Tobias Koenig <[email protected]>
4 
5  SPDX-FileCopyrightText: 2019-2022 Laurent Montel <[email protected]>
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>
16 class KActionCollection;
17 
18 class QAbstractItemModel;
19 class QAction;
21 namespace MailCommon
22 {
23 /**
24  * @brief The SnippetInfo struct
25  * @author Laurent Montel <[email protected]>
26  */
27 struct 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 <[email protected]>
48  */
49 class MAILCOMMON_EXPORT SnippetsManager : public QObject
50 {
51  Q_OBJECT
52 public:
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  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  QItemSelectionModel *selectionModel() const;
77 
78  /**
79  * Returns the action that handles adding new snippets.
80  */
81  QAction *addSnippetAction() const;
82 
83  /**
84  * Returns the action that handles editing the currently selected snippet.
85  */
86  QAction *editSnippetAction() const;
87 
88  /**
89  * Returns the action that handles deleting the currently selected snippet.
90  */
91  QAction *deleteSnippetAction() const;
92 
93  /**
94  * Returns the action that handles adding new snippet groups.
95  */
96  QAction *addSnippetGroupAction() const;
97 
98  /**
99  * Returns the action that handles editing the currently selected snippet group.
100  */
101  QAction *editSnippetGroupAction() const;
102 
103  /**
104  * Returns the action that handles deleting the currently selected snippet group.
105  */
106  QAction *deleteSnippetGroupAction() const;
107 
108  /**
109  * Returns the action that handles inserting a snippet into the editor.
110  */
111  QAction *insertSnippetAction() const;
112 
113  /**
114  * Returns whether the currently selected item is a snippet group.
115  */
116  Q_REQUIRED_RESULT bool snippetGroupSelected() const;
117 
118  /**
119  * Returns the name of the currently selected snippet or snippet group.
120  */
121  Q_REQUIRED_RESULT QString selectedName() const;
122 
123 Q_SIGNALS:
124  void insertSnippet();
125  void insertSnippetInfo(const SnippetInfo &info);
126 
127 private:
128  //@cond PRIVATE
129  class SnippetsManagerPrivate;
130  std::unique_ptr<SnippetsManagerPrivate> const d;
131  //@endcond
132 };
133 }
The SnippetsManager class.
The SnippetInfo struct.
The filter dialog.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Sep 24 2022 03:58:15 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.