Mailcommon

filteractionmove.cpp
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#include "filteractionmove.h"
9#include "MailCommon/MailUtil"
10
11#include "kernel/mailkernel.h"
12
13#include <KLocalizedString>
14
15using namespace MailCommon;
16
17FilterAction *FilterActionMove::newAction()
18{
19 return new FilterActionMove;
20}
21
22FilterActionMove::FilterActionMove(QObject *parent)
23 : FilterActionWithFolder(QStringLiteral("transfer"), i18n("Move Into Folder"), parent)
24{
25}
26
27FilterAction::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
42SearchRule::RequiredPart FilterActionMove::requiredPart() const
43{
45}
46
47QString FilterActionMove::sieveCode() const
48{
50 if (KernelIf->collectionModel()) {
51 path = MailCommon::Util::fullCollectionRemoveIdPath(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
59QStringList FilterActionMove::sieveRequires() const
60{
61 return QStringList() << QStringLiteral("fileinto");
62}
63
64QString FilterActionMove::informationAboutNotValidAction() const
65{
66 return i18n("Folder destination was not defined.");
67}
68
69#include "moc_filteractionmove.cpp"
bool isValid() const
Abstract base class for filter actions with a mail folder as parameter.
Abstract base class for mail filter actions.
ReturnCode
Describes the possible return codes of filter processing:
@ ErrorButGoOn
A non-critical error occurred.
@ GoOn
Go on with applying filter actions.
A helper class for the filtering process.
Definition itemcontext.h:27
void setMoveTargetCollection(const Akonadi::Collection &collection)
Sets the target collection the item should be moved to.
RequiredPart
Possible required parts.
Definition searchrule.h:70
QString i18n(const char *text, const TYPE &arg...)
QString path(const QString &relativePath)
The filter dialog.
QString arg(Args &&... args) const const
QString number(double n, char format, int precision)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:00:24 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.