Mailcommon

filterimporterexporter.h
1 /*
2  SPDX-FileCopyrightText: 2007 Till Adam <[email protected]>
3  SPDX-FileCopyrightText: 2012-2022 Laurent Montel <[email protected]>
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 <QStringList>
16 #include <QVector>
17 #include <memory>
18 class QWidget;
19 
20 namespace MailCommon
21 {
22 class MailFilter;
23 
24 /**
25  * @short Utility class that provides persisting of filters to/from KConfig.
26  *
27  * @author Till Adam <[email protected]>
28  */
29 class MAILCOMMON_EXPORT FilterImporterExporter
30 {
31 public:
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  */
55  virtual ~FilterImporterExporter();
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 QVector<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  Q_REQUIRED_RESULT QVector<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 QVector<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 QVector<MailFilter *> readFiltersFromConfig(const KSharedConfig::Ptr &config, QStringList &emptyFilter);
81 
82 private:
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.
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.