File indexing completed on 2024-12-22 05:00:50
0001 /* 0002 SPDX-FileCopyrightText: 2012-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 #pragma once 0007 0008 #include <Akonadi/Collection> 0009 #include <KConfigGroup> 0010 #include <MailCommon/BackupJob> 0011 #include <QDate> 0012 #include <QUrl> 0013 0014 class ArchiveMailInfo 0015 { 0016 public: 0017 explicit ArchiveMailInfo(const KConfigGroup &config); 0018 ArchiveMailInfo(const ArchiveMailInfo &info); 0019 ArchiveMailInfo(); 0020 0021 ~ArchiveMailInfo(); 0022 0023 ArchiveMailInfo &operator=(const ArchiveMailInfo &old); 0024 0025 enum ArchiveUnit { 0026 ArchiveDays = 0, 0027 ArchiveWeeks, 0028 ArchiveMonths, 0029 ArchiveYears, 0030 }; 0031 0032 [[nodiscard]] QUrl realUrl(const QString &folderName, bool &dirExist) const; 0033 0034 [[nodiscard]] bool isValid() const; 0035 0036 [[nodiscard]] Akonadi::Collection::Id saveCollectionId() const; 0037 void setSaveCollectionId(Akonadi::Collection::Id collectionId); 0038 0039 void setSaveSubCollection(bool b); 0040 [[nodiscard]] bool saveSubCollection() const; 0041 0042 void setUrl(const QUrl &url); 0043 [[nodiscard]] QUrl url() const; 0044 0045 void readConfig(const KConfigGroup &config); 0046 void writeConfig(KConfigGroup &config); 0047 0048 void setArchiveType(MailCommon::BackupJob::ArchiveType type); 0049 [[nodiscard]] MailCommon::BackupJob::ArchiveType archiveType() const; 0050 0051 void setArchiveUnit(ArchiveMailInfo::ArchiveUnit unit); 0052 [[nodiscard]] ArchiveMailInfo::ArchiveUnit archiveUnit() const; 0053 0054 void setArchiveAge(int age); 0055 [[nodiscard]] int archiveAge() const; 0056 0057 void setLastDateSaved(QDate date); 0058 [[nodiscard]] QDate lastDateSaved() const; 0059 0060 [[nodiscard]] int maximumArchiveCount() const; 0061 void setMaximumArchiveCount(int max); 0062 0063 [[nodiscard]] QStringList listOfArchive(const QString &foldername, bool &dirExist) const; 0064 0065 [[nodiscard]] bool isEnabled() const; 0066 void setEnabled(bool b); 0067 0068 [[nodiscard]] bool operator==(const ArchiveMailInfo &other) const; 0069 0070 [[nodiscard]] bool useRange() const; 0071 void setUseRange(bool newUseRange); 0072 0073 [[nodiscard]] QList<int> range() const; 0074 void setRange(const QList<int> &newRanges); 0075 0076 private: 0077 [[nodiscard]] QString dirArchive(bool &dirExit) const; 0078 QDate mLastDateSaved; 0079 int mArchiveAge = 1; 0080 MailCommon::BackupJob::ArchiveType mArchiveType = MailCommon::BackupJob::Zip; 0081 ArchiveUnit mArchiveUnit = ArchiveMailInfo::ArchiveDays; 0082 Akonadi::Collection::Id mSaveCollectionId = -1; 0083 QUrl mPath; 0084 QList<int> mRanges; 0085 int mMaximumArchiveCount = 0; 0086 bool mSaveSubCollection = false; 0087 bool mIsEnabled = true; 0088 bool mUseRange = false; 0089 };