Mailcommon

filteractiondict.h
1/*
2 * SPDX-FileCopyrightText: 1996-1998 Stefan Taferner <taferner@kde.org>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 *
6 */
7
8#pragma once
9
10#include "mailcommon_export.h"
11
12#include <QList>
13#include <QMultiHash>
14#include <QString>
15namespace MailCommon
16{
17class FilterAction;
18
19using FilterActionNewFunc = FilterAction *(*)();
20
21/**
22 * @short Auxiliary struct for FilterActionDict.
23 */
25 QString label, name;
26 FilterActionNewFunc create;
27};
28
29/**
30 * @short List of known FilterAction-types.
31 *
32 * Dictionary that contains a list of all registered filter actions
33 * with their creation functions. They are hard-coded into the
34 * constructor. If you want to add a new FilterAction, make
35 * sure you add the details of it in init, too.
36 *
37 * You will be able to find a description of a FilterAction by
38 * looking up either it's (english) name or it's (i18n) label:
39 * <pre>
40 * FilterActionDict dict;
41 * // get name of the action with label "move into folder":
42 * dict[i18n("move into folder")]->name; // == "transfer"
43 * // create one such action:
44 * FilterAction *action = dict["transfer"]->create();
45 * </pre>
46 *
47 * You can iterate over all known filter actions by using list.
48 *
49 * @author Marc Mutz <mutz@kde.org>, based on work by Stefan Taferner <taferner@kde.org>
50 * @see FilterAction FilterActionDesc Filter
51 */
52class FilterActionDict : public QMultiHash<QString, FilterActionDesc *>
53{
54public:
55 /**
56 * Creates the filter action dictionary.
57 */
58 MAILCOMMON_EXPORT FilterActionDict();
59
60 /**
61 * Destroys the filter action dictionary.
62 */
63 MAILCOMMON_EXPORT virtual ~FilterActionDict();
64
65 /**
66 * Overloaded member function, provided for convenience. Thin
67 * wrapper around QDict::insert and QPtrList::insert.
68 * Inserts the resulting FilterActionDesc
69 * thrice: First with the name, then with the label as key into the
70 * QDict, then into the QPtrList. For that, it creates an
71 * instance of the action internally and deletes it again after
72 * querying it for name and label.
73 */
74 MAILCOMMON_EXPORT void insert(FilterActionNewFunc aNewFunc);
75
76 /**
77 * Provides read-only access to a list of all known filter
78 * actions.
79 */
80 MAILCOMMON_EXPORT const QList<FilterActionDesc *> &list() const;
81
82protected:
83 /**
84 * Populate the dictionary with all known FilterAction
85 * types. Called automatically from the constructor.
86 */
87 virtual void init();
88
89private:
91};
92}
List of known FilterAction-types.
virtual void init()
Populate the dictionary with all known FilterAction types.
MAILCOMMON_EXPORT void insert(FilterActionNewFunc aNewFunc)
Overloaded member function, provided for convenience.
MAILCOMMON_EXPORT FilterActionDict()
Creates the filter action dictionary.
virtual MAILCOMMON_EXPORT ~FilterActionDict()
Destroys the filter action dictionary.
MAILCOMMON_EXPORT const QList< FilterActionDesc * > & list() const
Provides read-only access to a list of all known filter actions.
The filter dialog.
Auxiliary struct for FilterActionDict.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:01 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.