Mailcommon

filteractionwidget.h
1 /*
2  SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
3  SPDX-FileCopyrightText: 2010 Andras Mantia <[email protected]>
4  SPDX-FileCopyrightText: Marc Mutz <[email protected]>
5 
6  based upon work by Stefan Taferner <[email protected]>
7 
8  SPDX-License-Identifier: GPL-2.0-or-later
9 */
10 
11 #pragma once
12 
13 #include "mailcommon_export.h"
14 
15 #include <Libkdepim/KWidgetLister>
16 #include <QList>
17 namespace MailCommon
18 {
19 class FilterAction;
20 class FilterActionWidget;
21 
22 /**
23  * @short A widget to edit a single MailCommon::FilterAction.
24  *
25  * This widgets allows to edit a single MailCommon::FilterAction (in fact
26  * any derived class that is registered in
27  * KMFilterActionDict). It consists of a combo box which allows to
28  * select the type of actions this widget should act upon.
29  *
30  * You can load a MailCommon::FilterAction into this widget with setAction,
31  * and retrieve the result of user action with action.
32  * The widget will copy it's setting into the corresponding
33  * parameter widget. For that, it internally creates an instance of
34  * every MailCommon::FilterAction in KMFilterActionDict and asks each
35  * one to create a parameter widget.
36  *
37  * @author Marc Mutz <[email protected]>
38  * @see MailCommon::FilterAction MailCommon::MailFilter FilterActionWidgetLister
39  */
41 {
42  Q_OBJECT
43 
44 public:
45  /**
46  * Creates a filter action widget with no type selected.
47  *
48  * @param parent The parent widget.
49  */
50  explicit FilterActionWidget(QWidget *parent = nullptr);
51 
52  /**
53  * Destroys the filter action widget.
54  */
55  ~FilterActionWidget() override;
56 
57  /**
58  * Sets the filter action.
59  *
60  * The action's type is determined and the corresponding widget
61  * it loaded with @p action's parameters and then raised.
62  *
63  * If @p action is @c 0, the widget is cleared.
64  * @note The widget takes ownership of the passed action.
65  */
67 
68  /**
69  * Returns the filter action.
70  *
71  * This method is necessary because the type of actions can
72  * change during editing. Therefore the widget always creates a new
73  * action object from the data in the combo box and returns that.
74  */
75  Q_REQUIRED_RESULT MailCommon::FilterAction *action() const;
76 
77  void updateAddRemoveButton(bool addButtonEnabled, bool removeButtonEnabled);
78 
79 Q_SIGNALS:
80  void filterModified();
81  void addFilterWidget(QWidget *);
82  void removeFilterWidget(QWidget *);
83 
84 private:
85  //@cond PRIVATE
86  class FilterActionWidgetPrivate;
87  std::unique_ptr<FilterActionWidgetPrivate> const d;
88  //@endcond
89 };
90 
91 /**
92  * @short A container widget for a list of FilterActionWidgets.
93  *
94  * @author Marc Mutz <[email protected]>
95  * @see MailCommon::FilterAction MailCommon::MailFilter FilterActionWidget
96  */
97 class MAILCOMMON_EXPORT FilterActionWidgetLister : public KPIM::KWidgetLister
98 {
99  Q_OBJECT
100 
101 public:
102  /**
103  * Creates a new filter action widget lister.
104  *
105  * @param parent The parent widget.
106  */
107  explicit FilterActionWidgetLister(QWidget *parent = nullptr);
108 
109  /**
110  * Destroys the filter action widget lister.
111  */
112  ~FilterActionWidgetLister() override;
113 
114  /**
115  * Sets the @p list of filter actions, the lister will create FilterActionWidgets for.
116  */
117  void setActionList(QList<FilterAction *> *list);
118 
119  /**
120  * Updates the action list according to the current action widget values.
121  */
122  void updateActionList();
123 
124  void reconnectWidget(FilterActionWidget *w);
125 
126 public Q_SLOTS:
127  /**
128  * Resets the action widgets.
129  */
130  void reset();
131  void slotAddWidget(QWidget *);
132  void slotRemoveWidget(QWidget *);
133 
134 Q_SIGNALS:
135  void filterModified();
136 
137 protected:
138  /**
139  * @copydoc KPIM::KWidgetLister::clearWidget
140  */
141  void clearWidget(QWidget *) override;
142 
143  /**
144  * @copydoc KPIM::KWidgetLister::createWidget
145  */
146  QWidget *createWidget(QWidget *) override;
147 
148  void updateAddRemoveButton();
149 
150 private:
151  //@cond PRIVATE
152  class FilterActionWidgetListerPrivate;
153  std::unique_ptr<FilterActionWidgetListerPrivate> const d;
154  //@endcond
155  void connectWidget(QWidget *widget, FilterAction *filterAction);
156 };
157 }
Q_OBJECTQ_OBJECT
void setAction(const MailCommon::FilterAction *action)
Sets the filter action.
A container widget for a list of FilterActionWidgets.
A widget to edit a single MailCommon::FilterAction.
~FilterActionWidget() override
Destroys the filter action widget.
Abstract base class for mail filter actions.
Definition: filteraction.h:38
MailCommon::FilterAction * action() const
Returns the filter action.
Q_SIGNALSQ_SIGNALS
FilterActionWidget(QWidget *parent=nullptr)
Creates a filter action widget with no type selected.
QObject * parent() const const
The filter dialog.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Sep 26 2023 03:56:33 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.