Mailcommon

filterconverttosieve.cpp
1 /*
2  SPDX-FileCopyrightText: 2013-2022 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #include "filterconverttosieve.h"
8 #include "filter/mailfilter.h"
9 #include "filterconverttosieveresultdialog.h"
10 
11 #include <QPointer>
12 
13 using namespace MailCommon;
14 
15 FilterConvertToSieve::FilterConvertToSieve(const QVector<MailFilter *> &filters)
16  : mListFilters(filters)
17 {
18 }
19 
20 FilterConvertToSieve::~FilterConvertToSieve() = default;
21 
22 void FilterConvertToSieve::convert()
23 {
24  QString result;
25  if (!mListFilters.isEmpty()) {
26  QStringList requiresModule;
27  QString code;
28  for (MailFilter *filter : std::as_const(mListFilters)) {
29  filter->generateSieveScript(requiresModule, code);
30  code += QLatin1Char('\n');
31  }
32  QString requireStr;
33  for (const QString &require : std::as_const(requiresModule)) {
34  requireStr += QStringLiteral("require \"%1\";").arg(require);
35  requireStr += QLatin1Char('\n');
36  }
37  result = requireStr + code;
38  }
39  QPointer<FilterConvertToSieveResultDialog> dlg = new FilterConvertToSieveResultDialog;
40  dlg->setCode(result);
41  dlg->exec();
42  delete dlg;
43 }
The MailFilter class.
Definition: mailfilter.h:28
QFuture< void > filter(Sequence &sequence, KeepFunctor filterFunction)
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
The filter dialog.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Oct 1 2022 04:00:53 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.