Mailcommon

filteractionmove.cpp
1 /*
2  * SPDX-FileCopyrightText: 1996-1998 Stefan Taferner <[email protected]>
3  *
4  * SPDX-License-Identifier: GPL-2.0-or-later
5  *
6  */
7 
8 #include "filteractionmove.h"
9 #include "MailCommon/MailUtil"
10 
11 #include "kernel/mailkernel.h"
12 
13 #include <KLocalizedString>
14 
15 using namespace MailCommon;
16 
17 FilterAction *FilterActionMove::newAction()
18 {
19  return new FilterActionMove;
20 }
21 
22 FilterActionMove::FilterActionMove(QObject *parent)
23  : FilterActionWithFolder(QStringLiteral("transfer"), i18n("Move Into Folder"), parent)
24 {
25 }
26 
27 FilterAction::ReturnCode FilterActionMove::process(ItemContext &context, bool) const
28 {
29  if (!mFolder.isValid()) {
30  const Akonadi::Collection targetFolder = CommonKernel->collectionFromId(mFolder.id());
31  if (!targetFolder.isValid()) {
32  return ErrorButGoOn;
33  }
34 
35  context.setMoveTargetCollection(targetFolder);
36  } else {
37  context.setMoveTargetCollection(mFolder);
38  }
39  return GoOn;
40 }
41 
42 SearchRule::RequiredPart FilterActionMove::requiredPart() const
43 {
44  return SearchRule::Envelope;
45 }
46 
47 QString FilterActionMove::sieveCode() const
48 {
49  QString path;
50  if (KernelIf->collectionModel()) {
51  path = MailCommon::Util::fullCollectionPath(mFolder, false);
52  } else {
53  path = QString::number(mFolder.id());
54  }
55  const QString result = QStringLiteral("fileinto \"%1\";").arg(path);
56  return result;
57 }
58 
59 QStringList FilterActionMove::sieveRequires() const
60 {
61  return QStringList() << QStringLiteral("fileinto");
62 }
63 
64 QString FilterActionMove::informationAboutNotValidAction() const
65 {
66  return i18n("Folder destination was not defined.");
67 }
Abstract base class for filter actions with a mail folder as parameter.
QString number(int n, int base)
Abstract base class for mail filter actions.
Definition: filteraction.h:38
QString i18n(const char *text, const TYPE &arg...)
RequiredPart
Possible required parts.
Definition: searchrule.h:68
A helper class for the filtering process.
Definition: itemcontext.h:26
ReturnCode
Describes the possible return codes of filter processing:
Definition: filteraction.h:45
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
bool isValid() const
The filter dialog.
void setMoveTargetCollection(const Akonadi::Collection &collection)
Sets the target collection the item should be moved to.
Definition: itemcontext.cpp:23
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Oct 1 2022 04:00:52 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.