Commit f42903a9 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

run git clang-format

parent 98634c19
#include "dummykernel.h"
#include <KIdentityManagement/kidentitymanagement/identitymanager.h>
#include <MessageComposer/AkonadiSender>
#include <MailCommon/FolderCollectionMonitor>
#include <AkonadiCore/session.h>
#include <AkonadiCore/entitytreemodel.h>
#include <AkonadiCore/entitymimetypefiltermodel.h>
#include <AkonadiCore/changerecorder.h>
#include <AkonadiCore/entitymimetypefiltermodel.h>
#include <AkonadiCore/entitytreemodel.h>
#include <AkonadiCore/session.h>
#include <KIdentityManagement/kidentitymanagement/identitymanager.h>
#include <KSharedConfig>
#include <MailCommon/FolderCollectionMonitor>
#include <MessageComposer/AkonadiSender>
DummyKernel::DummyKernel(QObject *parent)
: QObject(parent)
......
......@@ -3,12 +3,14 @@
#include <MailCommon/MailInterfaces>
namespace Akonadi {
namespace Akonadi
{
class EntityTreeModel;
class EntityMimeTypeFilterModel;
}
namespace MailCommon {
namespace MailCommon
{
class FolderCollectionMonitor;
}
......
......@@ -10,12 +10,12 @@
#include <KConfigGroup>
#include <KSharedConfig>
#include <entitytreemodel.h>
#include <changerecorder.h>
#include <control.h>
#include <qtest_akonadi.h>
#include <favoritecollectionsmodel.h>
#include <entitytreemodel.h>
#include <favoritecollectionorderproxymodel.h>
#include <changerecorder.h>
#include <favoritecollectionsmodel.h>
#include <qtest_akonadi.h>
using namespace Akonadi;
using namespace MailCommon;
......@@ -27,6 +27,7 @@ class FavoriteProxyTest : public QObject
private Q_SLOTS:
void initTestCase();
void testReordering();
private:
EntityTreeModel *createETM();
};
......@@ -82,7 +83,7 @@ void FavoriteProxyTest::testReordering()
QList<Collection::Id> collectionIds;
QStringList labels;
QStringList order;
for (const QString &folderName : { QStringLiteral("res2"), QStringLiteral("res3") }) {
for (const QString &folderName : {QStringLiteral("res2"), QStringLiteral("res3")}) {
const QModelIndex index = getIndex(folderName, model);
QVERIFY(index.isValid());
const Akonadi::Collection favoriteCollection = index.data(EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
......
......@@ -8,32 +8,32 @@
#include <qtest_akonadi.h>
#include <AkonadiCore/Item>
#include <AkonadiCore/Collection>
#include <AkonadiCore/Item>
#include <AkonadiCore/ItemFetchScope>
#include <AkonadiCore/AgentType>
#include <AkonadiCore/AgentInstanceCreateJob>
#include <AkonadiCore/AgentManager>
#include <AkonadiCore/SearchCreateJob>
#include <AkonadiCore/SearchQuery>
#include <AkonadiCore/CollectionDeleteJob>
#include <AkonadiCore/AgentType>
#include <AkonadiCore/CollectionCreateJob>
#include <AkonadiCore/CollectionDeleteJob>
#include <AkonadiCore/CollectionFetchJob>
#include <AkonadiCore/CollectionMoveJob>
#include <AkonadiCore/EntityOrderProxyModel>
#include <AkonadiCore/SearchCreateJob>
#include <AkonadiCore/SearchQuery>
#include <KMime/Message>
#include "folder/entitycollectionorderproxymodel.h"
#include <MailCommon/FolderTreeWidget>
#include <MailCommon/FolderTreeView>
#include <MailCommon/FolderTreeWidget>
#include <MailCommon/MailKernel>
#include <QTreeView>
#include <QDebug>
#include <QStandardPaths>
#include <QTest>
#include <QTreeView>
#include "dummykernel.cpp"
......@@ -54,9 +54,7 @@ private Q_SLOTS:
CommonKernel->registerSettingsIf(kernel);
mFolderTreeWidget = new MailCommon::FolderTreeWidget(nullptr);
const QStringList resourceOrder{
"akonadi_knut_resource_2", "akonadi_knut_resource_0"
}; // _1 isn't specified so it goes at the end
const QStringList resourceOrder{"akonadi_knut_resource_2", "akonadi_knut_resource_0"}; // _1 isn't specified so it goes at the end
mFolderTreeWidget->entityOrderProxy()->setTopLevelOrder(resourceOrder);
mCollectionModel = KernelIf->collectionModel();
......@@ -65,9 +63,7 @@ private Q_SLOTS:
// One knut resource is already defined in the unittestenv, so that it's below "Search" in the ETM.
QTRY_COMPARE(mCollectionModel->rowCount(), 2);
QCOMPARE(mTopModel->rowCount(), 1); // Search doesn't appear yet
mFolderNames = QStringList{
"res1"
};
mFolderNames = QStringList{"res1"};
QCOMPARE(collectNames(mTopModel), mFolderNames);
}
......@@ -92,7 +88,9 @@ private Q_SLOTS:
QTRY_COMPARE(mCollectionModel->rowCount(), 2);
QTRY_COMPARE(mTopModel->rowCount(), 2);
const QStringList names = collectNames(mTopModel);
QCOMPARE(names, QStringList() << "res1" << "Search");
QCOMPARE(names,
QStringList() << "res1"
<< "Search");
const int rowOfSearch = names.indexOf("Search");
const QModelIndex searchParent = mTopModel->index(rowOfSearch, 0);
QCOMPARE(mTopModel->rowCount(searchParent), 1); // the actual child search folder
......@@ -129,15 +127,11 @@ private Q_SLOTS:
{
// Test creating more knut resources.
// This tests that ETM and proxies on top update correctly, and it tests toplevel collection order.
const QVector<int> numFolders{
1, 5, 2
};
const QVector<int> numFolders{1, 5, 2};
QVector<Collection> topLevelCollections;
const AgentType agentType = AgentManager::self()->type(QStringLiteral("akonadi_knut_resource"));
QVERIFY(agentType.isValid());
mFolderNames = QStringList{
"res3", "res1", "res2"
}; // according to resourceOrder above (the folder names are defined in testdata-res*.xml)
mFolderNames = QStringList{"res3", "res1", "res2"}; // according to resourceOrder above (the folder names are defined in testdata-res*.xml)
// Create resources
const int numResources = numFolders.count();
......@@ -182,7 +176,7 @@ private Q_SLOTS:
for (int number = 0; number < parentCount; ++number) {
Collection mailCollection;
mailCollection.setParentCollection(currentColl);
mailCollection.setName(QStringLiteral("sub%1").arg(number+1));
mailCollection.setName(QStringLiteral("sub%1").arg(number + 1));
auto collCreateJob = new CollectionCreateJob(mailCollection);
AKVERIFYEXEC(collCreateJob);
currentColl = collCreateJob->collection();
......@@ -202,7 +196,7 @@ private Q_SLOTS:
AKVERIFYEXEC(collMoveJob);
// wait for Akonadi::Monitor::collectionMoved
QTRY_COMPARE(mCollectionModel->rowCount(res2Index), origRowCount+1);
QTRY_COMPARE(mCollectionModel->rowCount(res2Index), origRowCount + 1);
#ifdef SHOW_WIDGET
QTest::qWait(1000);
......@@ -217,7 +211,7 @@ private:
if (job->exec()) {
const Collection::List collections = job->collections();
for (const Collection &col : collections) {
//qDebug() << col.resource() << col.mimeType();
// qDebug() << col.resource() << col.mimeType();
if (col.resource() == identifier) {
return col;
}
......
......@@ -4,12 +4,13 @@
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include <Akonadi/KMime/NewMailNotifierAttribute>
#include "collectionpage/attributes/expirecollectionattribute.h"
#include <Akonadi/KMime/NewMailNotifierAttribute>
#include <AkonadiCore/attributefactory.h>
namespace {
namespace
{
// Anonymous namespace; function is invisible outside this file.
bool dummy()
{
......
......@@ -117,14 +117,9 @@ ExpireCollectionAttribute::ExpireUnits ExpireCollectionAttribute::readExpireUnit
bool ExpireCollectionAttribute::operator==(const ExpireCollectionAttribute &other) const
{
return (mExpireMessages == other.isAutoExpire())
&& (mUnreadExpireAge == other.unreadExpireAge())
&& (mReadExpireAge == other.readExpireAge())
&& (mUnreadExpireUnits == other.unreadExpireUnits())
&& (mReadExpireUnits == other.readExpireUnits())
&& (mExpireAction == other.expireAction())
&& (mExpireToFolderId == other.expireToFolderId())
&& (mExpireMessagesWithValidDate == other.expireMessagesWithValidDate());
return (mExpireMessages == other.isAutoExpire()) && (mUnreadExpireAge == other.unreadExpireAge()) && (mReadExpireAge == other.readExpireAge())
&& (mUnreadExpireUnits == other.unreadExpireUnits()) && (mReadExpireUnits == other.readExpireUnits()) && (mExpireAction == other.expireAction())
&& (mExpireToFolderId == other.expireToFolderId()) && (mExpireMessagesWithValidDate == other.expireMessagesWithValidDate());
}
int ExpireCollectionAttribute::daysToExpire(int number, ExpireCollectionAttribute::ExpireUnits units)
......@@ -138,7 +133,7 @@ int ExpireCollectionAttribute::daysToExpire(int number, ExpireCollectionAttribut
// rather than assuming 31day months.
return number * 31;
default: // this avoids a compiler warning (not handled enumeration values)
;
;
}
return -1;
}
......@@ -195,7 +190,7 @@ void ExpireCollectionAttribute::deserialize(const QByteArray &data)
s >> mExpireMessagesWithValidDate;
}
QDebug operator <<(QDebug d, const ExpireCollectionAttribute &t)
QDebug operator<<(QDebug d, const ExpireCollectionAttribute &t)
{
d << " mExpireMessages " << t.isAutoExpire();
d << " mUnreadExpireAge " << t.unreadExpireAge();
......
......@@ -14,7 +14,8 @@
#include <Collection>
#include <QDebug>
namespace MailCommon {
namespace MailCommon
{
class MAILCOMMON_EXPORT ExpireCollectionAttribute : public Akonadi::Attribute
{
public:
......@@ -25,18 +26,9 @@ public:
* expireNever is used to switch off message expiry, and expireMaxUnits
* must always be the last in the list (for bounds checking).
*/
enum ExpireUnits {
ExpireNever = 0,
ExpireDays = 1,
ExpireWeeks = 2,
ExpireMonths = 3,
ExpireMaxUnits = 4
};
enum ExpireAction {
ExpireDelete = 0,
ExpireMove = 1
};
enum ExpireUnits { ExpireNever = 0, ExpireDays = 1, ExpireWeeks = 2, ExpireMonths = 3, ExpireMaxUnits = 4 };
enum ExpireAction { ExpireDelete = 0, ExpireMove = 1 };
Q_REQUIRED_RESULT QByteArray type() const override;
ExpireCollectionAttribute *clone() const override;
......@@ -123,9 +115,9 @@ public:
private:
static int daysToExpire(int number, ExpireCollectionAttribute::ExpireUnits units);
bool mExpireMessages = false; // true if old messages are expired
int mUnreadExpireAge = 28; // Given in unreadExpireUnits
int mReadExpireAge = 14; // Given in readExpireUnits
bool mExpireMessages = false; // true if old messages are expired
int mUnreadExpireAge = 28; // Given in unreadExpireUnits
int mReadExpireAge = 14; // Given in readExpireUnits
ExpireCollectionAttribute::ExpireUnits mUnreadExpireUnits = ExpireNever;
ExpireCollectionAttribute::ExpireUnits mReadExpireUnits = ExpireNever;
ExpireCollectionAttribute::ExpireAction mExpireAction = ExpireDelete;
......@@ -133,5 +125,5 @@ private:
bool mExpireMessagesWithValidDate = false;
};
}
MAILCOMMON_EXPORT QDebug operator <<(QDebug d, const MailCommon::ExpireCollectionAttribute &t);
MAILCOMMON_EXPORT QDebug operator<<(QDebug d, const MailCommon::ExpireCollectionAttribute &t);
#endif /* EXPIRATIONCOLLECTIONATTRIBUTE_H */
......@@ -5,8 +5,8 @@
*/
#include "expirecollectionattributetest.h"
#include <QTest>
#include "../attributes/expirecollectionattribute.h"
#include <QTest>
Q_DECLARE_METATYPE(MailCommon::ExpireCollectionAttribute::ExpireUnits)
Q_DECLARE_METATYPE(MailCommon::ExpireCollectionAttribute::ExpireAction)
......@@ -30,7 +30,7 @@ void ExpireCollectionAttributeTest::shouldHaveDefaultValue()
QCOMPARE(attr.expireAction(), MailCommon::ExpireCollectionAttribute::ExpireDelete);
QCOMPARE(attr.unreadExpireUnits(), MailCommon::ExpireCollectionAttribute::ExpireNever);
QCOMPARE(attr.readExpireUnits(), MailCommon::ExpireCollectionAttribute::ExpireNever);
QCOMPARE(attr.expireToFolderId(), (qint64) - 1);
QCOMPARE(attr.expireToFolderId(), (qint64)-1);
}
void ExpireCollectionAttributeTest::shouldAssignValue_data()
......@@ -43,16 +43,16 @@ void ExpireCollectionAttributeTest::shouldAssignValue_data()
QTest::addColumn<MailCommon::ExpireCollectionAttribute::ExpireAction>("expireaction");
QTest::addColumn<Akonadi::Collection::Id>("akonadiid");
QTest::newRow("add autoexpire") << true << 28 << 14 << MailCommon::ExpireCollectionAttribute::ExpireNever << MailCommon::ExpireCollectionAttribute::ExpireNever
<< MailCommon::ExpireCollectionAttribute::ExpireDelete << qint64(5);
QTest::newRow("change action") << true << 28 << 14 << MailCommon::ExpireCollectionAttribute::ExpireNever << MailCommon::ExpireCollectionAttribute::ExpireNever
<< MailCommon::ExpireCollectionAttribute::ExpireMove << qint64(5);
QTest::newRow("add autoexpire") << true << 28 << 14 << MailCommon::ExpireCollectionAttribute::ExpireNever
<< MailCommon::ExpireCollectionAttribute::ExpireNever << MailCommon::ExpireCollectionAttribute::ExpireDelete << qint64(5);
QTest::newRow("change action") << true << 28 << 14 << MailCommon::ExpireCollectionAttribute::ExpireNever
<< MailCommon::ExpireCollectionAttribute::ExpireNever << MailCommon::ExpireCollectionAttribute::ExpireMove << qint64(5);
QTest::newRow("change age") << true << 150 << 1 << MailCommon::ExpireCollectionAttribute::ExpireNever << MailCommon::ExpireCollectionAttribute::ExpireNever
<< MailCommon::ExpireCollectionAttribute::ExpireMove << qint64(5);
QTest::newRow("change units") << true << 15 << 1 << MailCommon::ExpireCollectionAttribute::ExpireDays << MailCommon::ExpireCollectionAttribute::ExpireDays
<< MailCommon::ExpireCollectionAttribute::ExpireMove << qint64(5);
QTest::newRow("change units2") << true << 150 << 18 << MailCommon::ExpireCollectionAttribute::ExpireMonths << MailCommon::ExpireCollectionAttribute::ExpireWeeks
<< MailCommon::ExpireCollectionAttribute::ExpireMove << qint64(6);
QTest::newRow("change units2") << true << 150 << 18 << MailCommon::ExpireCollectionAttribute::ExpireMonths
<< MailCommon::ExpireCollectionAttribute::ExpireWeeks << MailCommon::ExpireCollectionAttribute::ExpireMove << qint64(6);
}
void ExpireCollectionAttributeTest::shouldAssignValue()
......@@ -92,16 +92,16 @@ void ExpireCollectionAttributeTest::shouldCloneAttr_data()
QTest::addColumn<MailCommon::ExpireCollectionAttribute::ExpireAction>("expireaction");
QTest::addColumn<Akonadi::Collection::Id>("akonadiid");
QTest::newRow("add autoexpire") << true << 28 << 14 << MailCommon::ExpireCollectionAttribute::ExpireNever << MailCommon::ExpireCollectionAttribute::ExpireNever
<< MailCommon::ExpireCollectionAttribute::ExpireDelete << qint64(5);
QTest::newRow("change action") << true << 28 << 14 << MailCommon::ExpireCollectionAttribute::ExpireNever << MailCommon::ExpireCollectionAttribute::ExpireNever
<< MailCommon::ExpireCollectionAttribute::ExpireMove << qint64(5);
QTest::newRow("add autoexpire") << true << 28 << 14 << MailCommon::ExpireCollectionAttribute::ExpireNever
<< MailCommon::ExpireCollectionAttribute::ExpireNever << MailCommon::ExpireCollectionAttribute::ExpireDelete << qint64(5);
QTest::newRow("change action") << true << 28 << 14 << MailCommon::ExpireCollectionAttribute::ExpireNever
<< MailCommon::ExpireCollectionAttribute::ExpireNever << MailCommon::ExpireCollectionAttribute::ExpireMove << qint64(5);
QTest::newRow("change age") << true << 150 << 1 << MailCommon::ExpireCollectionAttribute::ExpireNever << MailCommon::ExpireCollectionAttribute::ExpireNever
<< MailCommon::ExpireCollectionAttribute::ExpireMove << qint64(5);
QTest::newRow("change units") << true << 15 << 1 << MailCommon::ExpireCollectionAttribute::ExpireDays << MailCommon::ExpireCollectionAttribute::ExpireDays
<< MailCommon::ExpireCollectionAttribute::ExpireMove << qint64(5);
QTest::newRow("change units2") << true << 150 << 18 << MailCommon::ExpireCollectionAttribute::ExpireMonths << MailCommon::ExpireCollectionAttribute::ExpireWeeks
<< MailCommon::ExpireCollectionAttribute::ExpireMove << qint64(6);
QTest::newRow("change units2") << true << 150 << 18 << MailCommon::ExpireCollectionAttribute::ExpireMonths
<< MailCommon::ExpireCollectionAttribute::ExpireWeeks << MailCommon::ExpireCollectionAttribute::ExpireMove << qint64(6);
}
void ExpireCollectionAttributeTest::shouldCloneAttr()
......@@ -136,16 +136,16 @@ void ExpireCollectionAttributeTest::shouldSerializedValue_data()
QTest::addColumn<MailCommon::ExpireCollectionAttribute::ExpireAction>("expireaction");
QTest::addColumn<Akonadi::Collection::Id>("akonadiid");
QTest::newRow("add autoexpire") << true << 28 << 14 << MailCommon::ExpireCollectionAttribute::ExpireNever << MailCommon::ExpireCollectionAttribute::ExpireNever
<< MailCommon::ExpireCollectionAttribute::ExpireDelete << qint64(5);
QTest::newRow("change action") << true << 28 << 14 << MailCommon::ExpireCollectionAttribute::ExpireNever << MailCommon::ExpireCollectionAttribute::ExpireNever
<< MailCommon::ExpireCollectionAttribute::ExpireMove << qint64(5);
QTest::newRow("add autoexpire") << true << 28 << 14 << MailCommon::ExpireCollectionAttribute::ExpireNever
<< MailCommon::ExpireCollectionAttribute::ExpireNever << MailCommon::ExpireCollectionAttribute::ExpireDelete << qint64(5);
QTest::newRow("change action") << true << 28 << 14 << MailCommon::ExpireCollectionAttribute::ExpireNever
<< MailCommon::ExpireCollectionAttribute::ExpireNever << MailCommon::ExpireCollectionAttribute::ExpireMove << qint64(5);
QTest::newRow("change age") << true << 150 << 1 << MailCommon::ExpireCollectionAttribute::ExpireNever << MailCommon::ExpireCollectionAttribute::ExpireNever
<< MailCommon::ExpireCollectionAttribute::ExpireMove << qint64(5);
QTest::newRow("change units") << true << 15 << 1 << MailCommon::ExpireCollectionAttribute::ExpireDays << MailCommon::ExpireCollectionAttribute::ExpireDays
<< MailCommon::ExpireCollectionAttribute::ExpireMove << qint64(5);
QTest::newRow("change units2") << true << 150 << 18 << MailCommon::ExpireCollectionAttribute::ExpireMonths << MailCommon::ExpireCollectionAttribute::ExpireWeeks
<< MailCommon::ExpireCollectionAttribute::ExpireMove << qint64(6);
QTest::newRow("change units2") << true << 150 << 18 << MailCommon::ExpireCollectionAttribute::ExpireMonths
<< MailCommon::ExpireCollectionAttribute::ExpireWeeks << MailCommon::ExpireCollectionAttribute::ExpireMove << qint64(6);
}
void ExpireCollectionAttributeTest::shouldSerializedValue()
......
......@@ -5,8 +5,8 @@
*/
#include "collectionexpiryjob.h"
#include "util/mailutil.h"
#include "mailcommon_debug.h"
#include "util/mailutil.h"
#include <AkonadiCore/CollectionModifyJob>
......
......@@ -7,10 +7,11 @@
#ifndef COLLECTIONEXPIRYJOB_H
#define COLLECTIONEXPIRYJOB_H
#include <QObject>
#include <AkonadiCore/Collection>
#include <QObject>
class KJob;
namespace MailCommon {
namespace MailCommon
{
class CollectionExpiryJob : public QObject
{
Q_OBJECT
......
......@@ -10,9 +10,9 @@
#include "attributes/expirecollectionattribute.h"
#include "folder/foldersettings.h"
#include "util/mailutil.h"
#include "kernel/mailkernel.h"
#include "mailcommon_debug.h"
#include "util/mailutil.h"
#include <KLocalizedString>
#include <QVBoxLayout>
......@@ -44,7 +44,7 @@ void CollectionExpiryPage::init()
connect(mCollectionExpiryWidget, &CollectionExpiryWidget::configChanged, this, &CollectionExpiryPage::slotConfigChanged);
globalVBox->addWidget(mCollectionExpiryWidget);
globalVBox->addStretch(100); // eat all superfluous space
globalVBox->addStretch(100); // eat all superfluous space
}
void CollectionExpiryPage::slotConfigChanged(bool changed)
......
......@@ -13,7 +13,8 @@
#include <Collection>
#include <CollectionPropertiesPage>
namespace MailCommon {
namespace MailCommon
{
class CollectionExpiryWidget;
/**
* @brief The CollectionExpiryPage class
......
......@@ -5,23 +5,23 @@
*/
#include "collectionexpirywidget.h"
#include "collectionexpiryjob.h"
#include "kernel/mailkernel.h"
#include "folderrequester.h"
#include "attributes/expirecollectionattribute.h"
#include "collectionexpiryjob.h"
#include "folder/foldersettings.h"
#include "util/mailutil.h"
#include "folderrequester.h"
#include "kernel/mailkernel.h"
#include "mailcommon_debug.h"
#include "util/mailutil.h"
#include <CollectionModifyJob>
#include <KPluralHandlingSpinBox>
#include <KMessageBox>
#include <KPluralHandlingSpinBox>
#include <QCheckBox>
#include <QGroupBox>
#include <QPushButton>
#include <QRadioButton>
#include <QVBoxLayout>
#include <QCheckBox>
#include <QPushButton>
using namespace MailCommon;
......@@ -96,7 +96,7 @@ CollectionExpiryWidget::CollectionExpiryWidget(QWidget *parent)
connect(mExpireNowPB, &QPushButton::clicked, this, &CollectionExpiryWidget::saveAndExpireRequested);
globalVBox->addWidget(mExpireNowPB, 0, Qt::AlignRight);
globalVBox->addStretch(100); // eat all superfluous space
globalVBox->addStretch(100); // eat all superfluous space
mDeletePermanentlyRB->setChecked(true);
slotUpdateControls();
}
......@@ -134,15 +134,11 @@ void CollectionExpiryWidget::load(const MailCommon::CollectionExpirySettings &se
{
if (settings.isValid()) {
bool expiryGloballyOn = settings.expiryGloballyOn;
if (expiryGloballyOn
&& settings.mReadExpireUnits != ExpireCollectionAttribute::ExpireNever
&& settings.daysToExpireRead >= 0) {
if (expiryGloballyOn && settings.mReadExpireUnits != ExpireCollectionAttribute::ExpireNever && settings.daysToExpireRead >= 0) {
mExpireReadMailCB->setChecked(true);
mExpireReadMailSB->setValue(settings.daysToExpireRead);
}
if (expiryGloballyOn
&& settings.mUnreadExpireUnits != ExpireCollectionAttribute::ExpireNever
&& settings.daysToExpireUnread >= 0) {
if (expiryGloballyOn && settings.mUnreadExpireUnits != ExpireCollectionAttribute::ExpireNever && settings.daysToExpireUnread >= 0) {
mExpireUnreadMailCB->setChecked(true);
mExpireUnreadMailSB->setValue(settings.daysToExpireUnread);
}
......@@ -172,10 +168,11 @@ bool CollectionExpiryWidget::validateExpireFolder(bool expireNow)
const bool enableGlobally = mExpireReadMailCB->isChecked() || mExpireUnreadMailCB->isChecked();
const Akonadi::Collection expireToFolder = mFolderSelector->collection();
if (enableGlobally && mMoveToRB->isChecked() && !expireToFolder.isValid()) {
KMessageBox::error(this, i18n("Please select a folder to expire messages into.\nIf this is not done, expired messages will be permanently deleted."),
KMessageBox::error(this,
i18n("Please select a folder to expire messages into.\nIf this is not done, expired messages will be permanently deleted."),
i18n("No Folder Selected"));
mDeletePermanentlyRB->setChecked(true);
expireNow = false; // settings are not valid
expireNow = false; // settings are not valid
}
return expireNow;
}
......@@ -186,10 +183,12 @@ MailCommon::ExpireCollectionAttribute *CollectionExpiryWidget::assignFolderAttri
MailCommon::ExpireCollectionAttribute *attribute = nullptr;
if (expireToFolder.isValid() && mMoveToRB->isChecked()) {
if (expireToFolder.id() == collection.id()) {
KMessageBox::error(this, i18n("Please select a different folder than the current folder to expire messages into.\nIf this is not done, expired messages will be permanently deleted."),
KMessageBox::error(this,
i18n("Please select a different folder than the current folder to expire messages into.\nIf this is not done, expired messages "
"will be permanently deleted."),
i18n("Wrong Folder Selected"));
mDeletePermanentlyRB->setChecked(true);
expireNow = false; // settings are not valid
expireNow = false; // settings are not valid
} else {
attribute = collection.attribute<MailCommon::ExpireCollectionAttribute>(Akonadi::Collection::AddIfMissing);
attribute->setExpireToFolderId(expireToFolder.id());
......@@ -209,8 +208,10 @@ CollectionExpirySettings CollectionExpiryWidget::settings() const
// we always write out days now
settings.daysToExpireRead = mExpireReadMailSB->value();
settings.daysToExpireUnread = mExpireUnreadMailSB->value();
settings.mReadExpireUnits = mExpireReadMailCB->isChecked() ? MailCommon::ExpireCollectionAttribute::ExpireDays : MailCommon::ExpireCollectionAttribute::ExpireNever;
settings.mUnreadExpireUnits = mExpireUnreadMailCB->isChecked() ? MailCommon::ExpireCollectionAttribute::ExpireDays : MailCommon::ExpireCollectionAttribute::ExpireNever;
settings.mReadExpireUnits =
mExpireReadMailCB->isChecked() ? MailCommon::ExpireCollectionAttribute::ExpireDays : MailCommon::ExpireCollectionAttribute::ExpireNever;
settings.mUnreadExpireUnits =
mExpireUnreadMailCB->isChecked() ? MailCommon::ExpireCollectionAttribute::ExpireDays : MailCommon::ExpireCollectionAttribute::ExpireNever;
if (mDeletePermanentlyRB->isChecked()) {
settings.mExpireAction = ExpireCollectionAttribute::ExpireDelete;
......
......@@ -15,18 +15,15 @@ class KPluralHandlingSpinBox;
class QRadioButton;
class QPushButton;
class KJob;
namespace MailCommon {
class FolderRequester;
struct MAILCOMMON_EXPORT CollectionExpirySettings
namespace MailCommon
{
class FolderRequester;
struct MAILCOMMON_EXPORT CollectionExpirySettings {
Q_REQUIRED_RESULT bool isValid() const
{
return daysToExpireRead != -1
|| daysToExpireUnread != -1
|| mUnreadExpireUnits != ExpireCollectionAttribute::ExpireNever
|| mReadExpireUnits != ExpireCollectionAttribute::ExpireNever
|| mExpireAction != ExpireCollectionAttribute::ExpireDelete
|| mExpireToFolderId != -1;
return daysToExpireRead != -1 || daysToExpireUnread != -1 || mUnreadExpireUnits != ExpireCollectionAttribute::ExpireNever
|| mReadExpireUnits != ExpireCollectionAttribute::ExpireNever || mExpireAction != ExpireCollectionAttribute::ExpireDelete
|| mExpireToFolderId != -1;
}
bool expiryGloballyOn = false;
......
......@@ -8,32 +8,32 @@
#include "collectiongeneralwidget.h"
#include "collectiontypeutil.h"
#include "incidencesforwidget.h"
#include <PimCommonAkonadi/ContentTypeWidget>
#include <PimCommonAkonadi/CollectionAnnotationsAttribute>
#include "folder/foldersettings.h"
#include "incidencesforwidget.h"
#include "kernel/mailkernel.h"
#include "util/mailutil_p.h"
#include <PimCommonAkonadi/CollectionAnnotationsAttribute>
#include <PimCommonAkonadi/ContentTypeWidget>
#include <PimCommon/PimUtil>
#include <AgentManager>
#include <AttributeFactory>
#include <Collection>
#include <CollectionModifyJob>
#include <EntityDisplayAttribute>
#include <PimCommon/PimUtil>