8#include "collectionexpirypage.h"
9#include "collectionexpirywidget.h"
11#include "attributes/expirecollectionattribute.h"
13#include <KLocalizedString>
19CollectionExpiryPage::CollectionExpiryPage(
QWidget *parent)
23 setPageTitle(
i18nc(
"@title:tab Expiry settings for a folder.",
"Expiry"));
26CollectionExpiryPage::~CollectionExpiryPage() =
default;
30 return CollectionExpiryWidget::canHandle(col);
33void CollectionExpiryPage::init()
36 mCollectionExpiryWidget =
new CollectionExpiryWidget(
this);
37 connect(mCollectionExpiryWidget, &CollectionExpiryWidget::saveAndExpireRequested,
this, &CollectionExpiryPage::slotSaveAndExpire);
38 connect(mCollectionExpiryWidget, &CollectionExpiryWidget::configChanged,
this, &CollectionExpiryPage::slotConfigChanged);
39 globalVBox->addWidget(mCollectionExpiryWidget);
41 globalVBox->addStretch(100);
44void CollectionExpiryPage::slotConfigChanged(
bool changed)
51 mCollection = collection;
53 const auto *attr = collection.
attribute<MailCommon::ExpireCollectionAttribute>();
56 int daysToExpireUnread;
57 attr->daysToExpire(daysToExpireUnread, daysToExpireRead);
58 MailCommon::CollectionExpirySettings settings;
59 settings.expiryGloballyOn = attr->isAutoExpire();
60 settings.daysToExpireRead = daysToExpireRead;
61 settings.daysToExpireUnread = daysToExpireUnread;
62 settings.mUnreadExpireUnits = attr->unreadExpireUnits();
63 settings.mReadExpireUnits = attr->readExpireUnits();
64 settings.mExpireAction = attr->expireAction();
65 settings.mExpireToFolderId = attr->expireToFolderId();
67 mCollectionExpiryWidget->load(settings);
69 mCollectionExpiryWidget->load({});
77 saveAndExpire(collection,
false,
true);
81void CollectionExpiryPage::saveAndExpire(
Akonadi::Collection &collection,
bool saveSettings,
bool expireNow)
83 mCollectionExpiryWidget->save(collection, saveSettings, expireNow);
87void CollectionExpiryPage::slotSaveAndExpire()
89 saveAndExpire(mCollection,
true,
true);
92void CollectionExpiryPage::slotChanged()
97#include "moc_collectionexpirypage.cpp"
const T * attribute() const
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)