Mailcommon

filterimporterexporter.h
1/*
2 SPDX-FileCopyrightText: 2007 Till Adam <adam@kde.org>
3 SPDX-FileCopyrightText: 2012-2024 Laurent Montel <montel@kde.org>
4
5 SPDX-License-Identifier: GPL-2.0-or-later
6*/
7
8#pragma once
9
10#include "mailcommon_export.h"
11
12#include <KSharedConfig>
13#include <QUrl>
14
15#include <QList>
16#include <QStringList>
17#include <memory>
18class QWidget;
19
20namespace MailCommon
21{
22class MailFilter;
23
24/**
25 * @short Utility class that provides persisting of filters to/from KConfig.
26 *
27 * @author Till Adam <till@kdab.net>
28 */
29class MAILCOMMON_EXPORT FilterImporterExporter
30{
31public:
32 enum FilterType {
33 KMailFilter = 0,
34 ThunderBirdFilter = 1,
35 EvolutionFilter = 2,
36 SylpheedFilter = 3,
37 ProcmailFilter = 4,
38 BalsaFilter = 5,
39 ClawsMailFilter = 6,
40 IcedoveFilter = 7,
41 GmailFilter = 8,
42 SeaMonkeyFilter = 9,
43 };
44
45 /**
46 * Creates a new filter importer/exporter.
47 *
48 * @param parent The parent widget.
49 */
50 explicit FilterImporterExporter(QWidget *parent = nullptr);
51
52 /**
53 * Destroys the filter importer/exporter.
54 */
56
57 /**
58 * Exports the given @p filters to a file which
59 * is asked from the user. The list to export is also
60 * presented for confirmation/selection.
61 */
62 void exportFilters(const QList<MailFilter *> &filters, const QUrl &fileName = QUrl(), bool saveAll = false);
63
64 /**
65 * Imports filters. Ask the user where to import them from
66 * and which filters to import.
67 */
68 [[nodiscard]] QList<MailFilter *>
69 importFilters(bool &canceled, FilterImporterExporter::FilterType type = FilterImporterExporter::KMailFilter, const QString &filename = QString());
70
71 /**
72 * Writes the given list of @p filters to the given @p config file.
73 */
74 static void writeFiltersToConfig(const QList<MailFilter *> &filters, KSharedConfig::Ptr config, bool exportFilter = false);
75
76 /**
77 * Reads a list of filters from the given @p config file.
78 * Return list of empty filter
79 */
80 static QList<MailFilter *> readFiltersFromConfig(const KSharedConfig::Ptr &config, QStringList &emptyFilter);
81
82private:
83 //@cond PRIVATE
84 Q_DISABLE_COPY(FilterImporterExporter)
85
86 class FilterImporterExporterPrivate;
87 std::unique_ptr<FilterImporterExporterPrivate> const d;
88 //@endcond
89};
90}
Utility class that provides persisting of filters to/from KConfig.
virtual ~FilterImporterExporter()
Destroys the filter importer/exporter.
The filter dialog.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 6 2024 12:02:04 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.