Mailcommon

collectionexpirywidget.h
1 /*
2  SPDX-FileCopyrightText: 2020-2022 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 #include "mailcommon_export.h"
9 
10 #include <MailCommon/ExpireCollectionAttribute>
11 #include <QWidget>
12 class QCheckBox;
14 class QRadioButton;
15 class QPushButton;
16 namespace MailCommon
17 {
18 class FolderRequester;
19 struct MAILCOMMON_EXPORT CollectionExpirySettings {
20  Q_REQUIRED_RESULT bool isValid() const;
21 
22  bool expiryGloballyOn = false;
23  bool expiryMessagesWithInvalidDate = false;
24  int daysToExpireRead = -1;
25  int daysToExpireUnread = -1;
26  ExpireCollectionAttribute::ExpireUnits mUnreadExpireUnits = ExpireCollectionAttribute::ExpireNever;
27  ExpireCollectionAttribute::ExpireUnits mReadExpireUnits = ExpireCollectionAttribute::ExpireNever;
28  ExpireCollectionAttribute::ExpireAction mExpireAction = ExpireCollectionAttribute::ExpireDelete;
29  Akonadi::Collection::Id mExpireToFolderId = -1;
30 };
31 
32 class MAILCOMMON_EXPORT CollectionExpiryWidget : public QWidget
33 {
34  Q_OBJECT
35 public:
36  explicit CollectionExpiryWidget(QWidget *parent = nullptr);
37  ~CollectionExpiryWidget() override;
38 
39  void load(const MailCommon::CollectionExpirySettings &settings);
40  void save(Akonadi::Collection &collection, bool saveSettings, bool expireNow);
41  void save(const CollectionExpirySettings &collectionExpirySettings, Akonadi::Collection &collection, bool saveSettings, bool expireNow);
42  Q_REQUIRED_RESULT CollectionExpirySettings settings() const;
43  void hideExpireNowButton();
44  Q_REQUIRED_RESULT static bool canHandle(const Akonadi::Collection &col);
45 Q_SIGNALS:
46  void saveAndExpireRequested();
47  void configChanged(bool changed = true);
48 
49 private:
50  Q_REQUIRED_RESULT bool validateExpireFolder(bool expireNow);
51  Q_REQUIRED_RESULT MailCommon::ExpireCollectionAttribute *assignFolderAttribute(Akonadi::Collection &collection, bool &expireNow);
52  void slotChanged();
53  KPluralHandlingSpinBox *const mExpireReadMailSB;
54  KPluralHandlingSpinBox *const mExpireUnreadMailSB;
55  QRadioButton *mMoveToRB = nullptr;
56  FolderRequester *const mFolderSelector;
57  QRadioButton *mDeletePermanentlyRB = nullptr;
58  QPushButton *const mExpireNowPB;
59  QCheckBox *const mExpireMailWithInvalidDateCB;
60 };
61 }
62 MAILCOMMON_EXPORT QDebug operator<<(QDebug d, const MailCommon::CollectionExpirySettings &t);
QAction * load(const QObject *recvr, const char *slot, QObject *parent)
QDataStream & operator<<(QDataStream &out, const KDateTime &dateTime)
bool isValid(QStringView ifopt)
const QList< QKeySequence > & save()
The filter dialog.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Sep 24 2022 03:58:14 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.