From e79c281ecc53bc5a558d25849010a20609ef6083 Mon Sep 17 00:00:00 2001 From: Montel Laurent Date: Wed, 25 Oct 2017 13:28:08 +0200 Subject: [PATCH] Don't export "account name" when we export filter as sieve script. Bug found by andris --- src/filter/filteractions/filteractionmove.cpp | 2 +- src/util/mailutil.cpp | 14 ++++++++++++-- src/util/mailutil.h | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/filter/filteractions/filteractionmove.cpp b/src/filter/filteractions/filteractionmove.cpp index 84bf60e..6819146 100644 --- a/src/filter/filteractions/filteractionmove.cpp +++ b/src/filter/filteractions/filteractionmove.cpp @@ -60,7 +60,7 @@ QString FilterActionMove::sieveCode() const { QString path; if (KernelIf->collectionModel()) { - path = MailCommon::Util::fullCollectionPath(mFolder); + path = MailCommon::Util::fullCollectionPath(mFolder, false); } else { path = QString::number(mFolder.id()); } diff --git a/src/util/mailutil.cpp b/src/util/mailutil.cpp index 89238ed..57bc2f9 100644 --- a/src/util/mailutil.cpp +++ b/src/util/mailutil.cpp @@ -103,7 +103,7 @@ bool MailCommon::Util::isLocalCollection(const QString &resource) || resource.contains(QStringLiteral("akonadi_mixedmaildir_resource")); } -QString MailCommon::Util::fullCollectionPath(const Akonadi::Collection &collection) +QString MailCommon::Util::fullCollectionPath(const Akonadi::Collection &collection, bool addAccountName) { QString fullPath; @@ -116,8 +116,18 @@ QString MailCommon::Util::fullCollectionPath(const Akonadi::Collection &collecti fullPath = idx.data().toString(); idx = idx.parent(); while (idx != QModelIndex()) { - fullPath = idx.data().toString() + QLatin1Char('/') + fullPath; + const QString tmp = idx.data().toString() + QLatin1Char('/') + fullPath; idx = idx.parent(); + if (idx != QModelIndex()) { + fullPath = tmp; + } else { + if (!addAccountName) { + break; + } else { + fullPath = tmp; + break; + } + } } return fullPath; } diff --git a/src/util/mailutil.h b/src/util/mailutil.h index c1859ae..0e194fc 100644 --- a/src/util/mailutil.h +++ b/src/util/mailutil.h @@ -68,7 +68,7 @@ MAILCOMMON_EXPORT bool isVirtualCollection(const Akonadi::Collection &col); MAILCOMMON_EXPORT bool isVirtualCollection(const QString &resource); -MAILCOMMON_EXPORT QString fullCollectionPath(const Akonadi::Collection &collection); +MAILCOMMON_EXPORT QString fullCollectionPath(const Akonadi::Collection &collection, bool addAccountName = true); MAILCOMMON_EXPORT bool showJobErrorMessage(KJob *job);