File indexing completed on 2024-11-10 04:50:03
0001 /* 0002 * SPDX-FileCopyrightText: 1996-1998 Stefan Taferner <taferner@kde.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 * 0006 */ 0007 0008 #include "filteractionmove.h" 0009 #include "MailCommon/MailUtil" 0010 0011 #include "kernel/mailkernel.h" 0012 0013 #include <KLocalizedString> 0014 0015 using namespace MailCommon; 0016 0017 FilterAction *FilterActionMove::newAction() 0018 { 0019 return new FilterActionMove; 0020 } 0021 0022 FilterActionMove::FilterActionMove(QObject *parent) 0023 : FilterActionWithFolder(QStringLiteral("transfer"), i18n("Move Into Folder"), parent) 0024 { 0025 } 0026 0027 FilterAction::ReturnCode FilterActionMove::process(ItemContext &context, bool) const 0028 { 0029 if (!mFolder.isValid()) { 0030 const Akonadi::Collection targetFolder = CommonKernel->collectionFromId(mFolder.id()); 0031 if (!targetFolder.isValid()) { 0032 return ErrorButGoOn; 0033 } 0034 0035 context.setMoveTargetCollection(targetFolder); 0036 } else { 0037 context.setMoveTargetCollection(mFolder); 0038 } 0039 return GoOn; 0040 } 0041 0042 SearchRule::RequiredPart FilterActionMove::requiredPart() const 0043 { 0044 return SearchRule::Envelope; 0045 } 0046 0047 QString FilterActionMove::sieveCode() const 0048 { 0049 QString path; 0050 if (KernelIf->collectionModel()) { 0051 path = MailCommon::Util::fullCollectionRemoveIdPath(mFolder, false); 0052 } else { 0053 path = QString::number(mFolder.id()); 0054 } 0055 const QString result = QStringLiteral("fileinto \"%1\";").arg(path); 0056 return result; 0057 } 0058 0059 QStringList FilterActionMove::sieveRequires() const 0060 { 0061 return QStringList() << QStringLiteral("fileinto"); 0062 } 0063 0064 QString FilterActionMove::informationAboutNotValidAction() const 0065 { 0066 return i18n("Folder destination was not defined."); 0067 } 0068 0069 #include "moc_filteractionmove.cpp"