diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.0) -set(PIM_VERSION "5.6.40") +set(PIM_VERSION "5.6.41") project(mailcommon VERSION ${PIM_VERSION}) diff --git a/src/filter/filtermanager.h b/src/filter/filtermanager.h --- a/src/filter/filtermanager.h +++ b/src/filter/filtermanager.h @@ -51,7 +51,8 @@ Outbound = 0x2, Explicit = 0x4, BeforeOutbound = 0x8, - All = Inbound | BeforeOutbound | Outbound | Explicit + AllFolders = 0x16, ///< Apply the filter on all folders, not just inbox + All = Inbound | BeforeOutbound | Outbound | Explicit | AllFolders }; /** diff --git a/src/filter/kmfilterdialog.h b/src/filter/kmfilterdialog.h --- a/src/filter/kmfilterdialog.h +++ b/src/filter/kmfilterdialog.h @@ -224,7 +224,7 @@ /** Lets the user select whether to apply this filter on inbound/outbound messages, both, or only on explicit CTRL-J. */ - QCheckBox *mApplyOnIn, *mApplyOnOut, *mApplyBeforeOut, *mApplyOnCtrlJ; + QCheckBox *mApplyOnIn, *mApplyOnOut, *mApplyBeforeOut, *mApplyOnCtrlJ, *mApplyOnAllFolders; /** For a filter applied to inbound messages selects whether to apply this filter to all accounts or to selected accounts only. */ diff --git a/src/filter/kmfilterdialog.cpp b/src/filter/kmfilterdialog.cpp --- a/src/filter/kmfilterdialog.cpp +++ b/src/filter/kmfilterdialog.cpp @@ -264,28 +264,35 @@ = new QCheckBox(i18n("Apply this filter on manual &filtering"), mAdvOptsGroup); gl->addWidget(mApplyOnCtrlJ, 6, 0, 1, 4); + mApplyOnAllFolders = new QCheckBox(i18n("Apply this filter on inbound emails in all folders"), mAdvOptsGroup); + mApplyOnAllFolders->setToolTip(i18n("

The filter will be applied on inbound emails from all folders " + "belonging to all accounts selected above. This is useful when using local filters " + "with IMAP accounts where new emails may have already been moved to different folders " + "by server-side filters.

")); + gl->addWidget(mApplyOnAllFolders, 7, 0, 1, 4); + mStopProcessingHere = new QCheckBox(i18n("If this filter &matches, stop processing here"), mAdvOptsGroup); - gl->addWidget(mStopProcessingHere, 7, 0, 1, 4); + gl->addWidget(mStopProcessingHere, 8, 0, 1, 4); mConfigureShortcut = new QCheckBox(i18n("Add this filter to the Apply Filter menu"), mAdvOptsGroup); - gl->addWidget(mConfigureShortcut, 8, 0, 1, 2); + gl->addWidget(mConfigureShortcut, 9, 0, 1, 2); QLabel *keyButtonLabel = new QLabel(i18n("Shortcut:"), mAdvOptsGroup); keyButtonLabel->setAlignment(Qt::AlignVCenter | Qt::AlignRight); - gl->addWidget(keyButtonLabel, 8, 2, 1, 1); + gl->addWidget(keyButtonLabel, 9, 2, 1, 1); mKeySeqWidget = new KKeySequenceWidget(mAdvOptsGroup); mKeySeqWidget->setObjectName(QStringLiteral("FilterShortcutSelector")); - gl->addWidget(mKeySeqWidget, 8, 3, 1, 1); + gl->addWidget(mKeySeqWidget, 9, 3, 1, 1); mKeySeqWidget->setEnabled(false); mKeySeqWidget->setModifierlessAllowed(true); mKeySeqWidget->setCheckActionCollections(actionCollection); mConfigureToolbar = new QCheckBox(i18n("Additionally add this filter to the toolbar"), mAdvOptsGroup); - gl->addWidget(mConfigureToolbar, 9, 0, 1, 4); + gl->addWidget(mConfigureToolbar, 10, 0, 1, 4); mConfigureToolbar->setEnabled(false); QWidget *hbox = new QWidget(mAdvOptsGroup); @@ -303,7 +310,7 @@ mFilterActionIconButton->setIcon(QIcon::fromTheme(QStringLiteral("system-run"))); mFilterActionIconButton->setEnabled(false); - gl->addWidget(hbox, 10, 0, 1, 4); + gl->addWidget(hbox, 11, 0, 1, 4); mAdvOptsGroup->setLayout(gl); } @@ -335,6 +342,7 @@ connect(mApplyOnForTraditional, &QAbstractButton::clicked, this, &KMFilterDialog::slotApplicabilityChanged); connect(mApplyOnForChecked, &QAbstractButton::clicked, this, &KMFilterDialog::slotApplicabilityChanged); connect(mApplyBeforeOut, &QAbstractButton::clicked, this, &KMFilterDialog::slotApplicabilityChanged); + connect(mApplyOnAllFolders, &QAbstractButton::clicked, this, &KMFilterDialog::slotApplicabilityChanged); connect(mApplyOnOut, &QAbstractButton::clicked, this, &KMFilterDialog::slotApplicabilityChanged); connect(mApplyOnCtrlJ, &QAbstractButton::clicked, this, &KMFilterDialog::slotApplicabilityChanged); connect(mAccountList, &KMFilterAccountList::itemChanged, this, &KMFilterDialog::slotApplicableAccountsChanged); @@ -529,6 +537,7 @@ qCDebug(MAILCOMMON_LOG) << "apply on outbound ==" << aFilter->applyOnOutbound(); qCDebug(MAILCOMMON_LOG) << "apply before outbound == " << aFilter->applyBeforeOutbound(); qCDebug(MAILCOMMON_LOG) << "apply on explicit ==" << aFilter->applyOnExplicit(); + qCDebug(MAILCOMMON_LOG) << "apply on all folders inboud == " << aFilter->applyOnAllFoldersInbound(); // NOTE: setting these values activates the slot that sets them in // the filter! So make sure we have the correct values _before_ we @@ -538,6 +547,7 @@ const bool applyOnTraditional = aFilter->applicability() == MailFilter::ButImap; const bool applyBeforeOut = aFilter->applyBeforeOutbound(); const bool applyOnOut = aFilter->applyOnOutbound(); + const bool applyOnAllFolders = aFilter->applyOnAllFoldersInbound(); const bool applyOnExplicit = aFilter->applyOnExplicit(); const bool stopHere = aFilter->stopProcessingHere(); const bool configureShortcut = aFilter->configureShortcut(); @@ -550,6 +560,7 @@ mApplyOnForTraditional->setEnabled(applyOnIn); mApplyOnForChecked->setEnabled(applyOnIn); mApplyOnForAll->setChecked(applyOnForAll); + mApplyOnAllFolders->setChecked(applyOnAllFolders); mApplyOnForTraditional->setChecked(applyOnTraditional); mApplyOnForChecked->setChecked(!applyOnForAll && !applyOnTraditional); mAccountList->setEnabled(mApplyOnForChecked->isEnabled() && mApplyOnForChecked->isChecked()); @@ -589,6 +600,7 @@ mFilter->setApplyBeforeOutbound(mApplyBeforeOut->isChecked()); mFilter->setApplyOnOutbound(mApplyOnOut->isChecked()); mFilter->setApplyOnExplicit(mApplyOnCtrlJ->isChecked()); + mFilter->setApplyOnAllFoldersInbound(mApplyOnAllFolders->isChecked()); if (mApplyOnForAll->isChecked()) { mFilter->setApplicability(MailFilter::All); mFilter->clearApplyOnAccount(); @@ -615,6 +627,7 @@ << (mFilter->applyOnInbound() ? "incoming " : "") << (mFilter->applyOnOutbound() ? "outgoing " : "") << (mFilter->applyBeforeOutbound() ? "before_outgoing " : "") + << (mFilter->applyOnAllFoldersInbound() ? "all folders inboud " : "") << (mFilter->applyOnExplicit() ? "explicit CTRL-J" : ""); } } diff --git a/src/filter/mailfilter.h b/src/filter/mailfilter.h --- a/src/filter/mailfilter.h +++ b/src/filter/mailfilter.h @@ -199,6 +199,16 @@ */ void setApplicability(AccountType aApply = All); + /** Sets whether the filter should be applied on inbound emails in all + folders, not just Inbox. + */ + void setApplyOnAllFoldersInbound(bool aApply = true); + + /** Returns whether the filter should be applied on inbound emails in all + folders, not just Inbox. + */ + bool applyOnAllFoldersInbound() const; + /** @return true if this filter should be applied on inbound messages for all accounts, or false if this filter is to be applied on a specified set of accounts only. @@ -327,6 +337,7 @@ bool bApplyBeforeOutbound : 1; bool bApplyOnOutbound : 1; bool bApplyOnExplicit : 1; + bool bApplyOnAllFolders : 1; bool bStopProcessingHere : 1; bool bConfigureShortcut : 1; bool bConfigureToolbar : 1; diff --git a/src/filter/mailfilter.cpp b/src/filter/mailfilter.cpp --- a/src/filter/mailfilter.cpp +++ b/src/filter/mailfilter.cpp @@ -54,6 +54,7 @@ bApplyBeforeOutbound = false; bApplyOnOutbound = false; bApplyOnExplicit = true; + bApplyOnAllFolders = false; bStopProcessingHere = true; bConfigureShortcut = false; bConfigureToolbar = false; @@ -76,6 +77,7 @@ bApplyBeforeOutbound = aFilter.applyBeforeOutbound(); bApplyOnOutbound = aFilter.applyOnOutbound(); bApplyOnExplicit = aFilter.applyOnExplicit(); + bApplyOnAllFolders = aFilter.applyOnAllFoldersInbound(); bStopProcessingHere = aFilter.stopProcessingHere(); bConfigureShortcut = aFilter.configureShortcut(); bConfigureToolbar = aFilter.configureToolbar(); @@ -236,6 +238,16 @@ return bApplyOnExplicit; } +void MailFilter::setApplyOnAllFoldersInbound(bool aApply) +{ + bApplyOnAllFolders = aApply; +} + +bool MailFilter::applyOnAllFoldersInbound() const +{ + return bApplyOnAllFolders; +} + void MailFilter::setApplicability(AccountType aApply) { mApplicability = aApply; @@ -402,12 +414,14 @@ bApplyOnOutbound = false; bApplyOnInbound = true; bApplyOnExplicit = true; + bApplyOnAllFolders = false; mApplicability = ButImap; } else { bApplyBeforeOutbound = bool(sets.contains(QStringLiteral("before-send-mail"))); bApplyOnInbound = bool(sets.contains(QStringLiteral("check-mail"))); bApplyOnOutbound = bool(sets.contains(QStringLiteral("send-mail"))); bApplyOnExplicit = bool(sets.contains(QStringLiteral("manual-filtering"))); + bApplyOnAllFolders = bool(sets.contains(QStringLiteral("all-folders"))); mApplicability = (AccountType)config.readEntry( "Applicability", (int)ButImap); } @@ -530,6 +544,9 @@ if (bApplyOnExplicit) { sets.append(QStringLiteral("manual-filtering")); } + if (bApplyOnAllFolders) { + sets.append(QStringLiteral("all-folders")); + } config.writeEntry("apply-on", sets); config.writeEntry("StopProcessingHere", bStopProcessingHere); @@ -642,6 +659,9 @@ if (bApplyOnExplicit) { result += " Explicit"; } + if (bApplyOnAllFolders) { + result += " All Folders"; + } result += '\n'; if (bApplyOnInbound && mApplicability == All) { result += "This filter applies to all accounts.\n"; @@ -689,6 +709,7 @@ stream << filter.bApplyBeforeOutbound; stream << filter.bApplyOnOutbound; stream << filter.bApplyOnExplicit; + stream << filter.bApplyOnAllFolders; stream << filter.bStopProcessingHere; stream << filter.bConfigureShortcut; stream << filter.bConfigureToolbar; @@ -708,6 +729,7 @@ bool bApplyBeforeOutbound; bool bApplyOnOutbound; bool bApplyOnExplicit; + bool bApplyOnAllFolders; bool bStopProcessingHere; bool bConfigureShortcut; bool bConfigureToolbar; @@ -747,6 +769,7 @@ stream >> bApplyBeforeOutbound; stream >> bApplyOnOutbound; stream >> bApplyOnExplicit; + stream >> bApplyOnAllFolders; stream >> bStopProcessingHere; stream >> bConfigureShortcut; stream >> bConfigureToolbar; @@ -760,6 +783,7 @@ filter.bApplyBeforeOutbound = bApplyBeforeOutbound; filter.bApplyOnOutbound = bApplyOnOutbound; filter.bApplyOnExplicit = bApplyOnExplicit; + filter.bApplyOnAllFolders = bApplyOnAllFolders; filter.bStopProcessingHere = bStopProcessingHere; filter.bConfigureShortcut = bConfigureShortcut; filter.bConfigureToolbar = bConfigureToolbar;