Mailcommon

filteractionwidget.h
1/*
2 SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
3 SPDX-FileCopyrightText: 2010 Andras Mantia <andras@kdab.com>
4 SPDX-FileCopyrightText: Marc Mutz <mutz@kde.org>
5
6 based upon work by Stefan Taferner <taferner@kde.org>
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>
17namespace MailCommon
18{
19class FilterAction;
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 <mutz@kde.org>
38 * @see MailCommon::FilterAction MailCommon::MailFilter FilterActionWidgetLister
39 */
41{
43
44public:
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 */
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 [[nodiscard]] MailCommon::FilterAction *action() const;
76
77 void updateAddRemoveButton(bool addButtonEnabled, bool removeButtonEnabled);
78
80 void filterModified();
81 void addFilterWidget(QWidget *);
82 void removeFilterWidget(QWidget *);
83
84private:
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 <mutz@kde.org>
95 * @see MailCommon::FilterAction MailCommon::MailFilter FilterActionWidget
96 */
97class MAILCOMMON_EXPORT FilterActionWidgetLister : public KPIM::KWidgetLister
98{
100
101public:
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 */
113
114 /**
115 * Sets the @p list of filter actions, the lister will create FilterActionWidgets for.
116 */
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
126public Q_SLOTS:
127 /**
128 * Resets the action widgets.
129 */
130 void reset();
131 void slotAddWidget(QWidget *);
132 void slotRemoveWidget(QWidget *);
133
135 void filterModified();
136
137protected:
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
150private:
151 //@cond PRIVATE
152 class FilterActionWidgetListerPrivate;
153 std::unique_ptr<FilterActionWidgetListerPrivate> const d;
154 //@endcond
155 void connectWidget(QWidget *widget, FilterAction *filterAction);
156};
157}
void setActionList(QList< FilterAction * > *list)
Sets the list of filter actions, the lister will create FilterActionWidgets for.
void reset()
Resets the action widgets.
void updateActionList()
Updates the action list according to the current action widget values.
QWidget * createWidget(QWidget *) override
~FilterActionWidgetLister() override
Destroys the filter action widget lister.
FilterActionWidgetLister(QWidget *parent=nullptr)
Creates a new filter action widget lister.
A widget to edit a single MailCommon::FilterAction.
~FilterActionWidget() override
Destroys the filter action widget.
void setAction(const MailCommon::FilterAction *action)
Sets the filter action.
FilterActionWidget(QWidget *parent=nullptr)
Creates a filter action widget with no type selected.
MailCommon::FilterAction * action() const
Returns the filter action.
Abstract base class for mail filter actions.
The filter dialog.
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QObject * parent() const const
QWidget(QWidget *parent, Qt::WindowFlags f)
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 31 2025 11:58:04 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.