File indexing completed on 2024-11-17 04:45:00
0001 /* 0002 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "folderarchiveaccountinfo.h" 0008 0009 FolderArchiveAccountInfo::FolderArchiveAccountInfo() = default; 0010 0011 FolderArchiveAccountInfo::FolderArchiveAccountInfo(const KConfigGroup &config) 0012 { 0013 readConfig(config); 0014 } 0015 0016 FolderArchiveAccountInfo::~FolderArchiveAccountInfo() = default; 0017 0018 bool FolderArchiveAccountInfo::isValid() const 0019 { 0020 return (mArchiveTopLevelCollectionId > -1) && (!mInstanceName.isEmpty()); 0021 } 0022 0023 void FolderArchiveAccountInfo::setFolderArchiveType(FolderArchiveAccountInfo::FolderArchiveType type) 0024 { 0025 mArchiveType = type; 0026 } 0027 0028 FolderArchiveAccountInfo::FolderArchiveType FolderArchiveAccountInfo::folderArchiveType() const 0029 { 0030 return mArchiveType; 0031 } 0032 0033 void FolderArchiveAccountInfo::setArchiveTopLevel(Akonadi::Collection::Id id) 0034 { 0035 mArchiveTopLevelCollectionId = id; 0036 } 0037 0038 Akonadi::Collection::Id FolderArchiveAccountInfo::archiveTopLevel() const 0039 { 0040 return mArchiveTopLevelCollectionId; 0041 } 0042 0043 QString FolderArchiveAccountInfo::instanceName() const 0044 { 0045 return mInstanceName; 0046 } 0047 0048 void FolderArchiveAccountInfo::setInstanceName(const QString &instance) 0049 { 0050 mInstanceName = instance; 0051 } 0052 0053 void FolderArchiveAccountInfo::setEnabled(bool enabled) 0054 { 0055 mEnabled = enabled; 0056 } 0057 0058 bool FolderArchiveAccountInfo::enabled() const 0059 { 0060 return mEnabled; 0061 } 0062 0063 void FolderArchiveAccountInfo::setKeepExistingStructure(bool b) 0064 { 0065 mKeepExistingStructure = b; 0066 } 0067 0068 bool FolderArchiveAccountInfo::keepExistingStructure() const 0069 { 0070 return mKeepExistingStructure; 0071 } 0072 0073 void FolderArchiveAccountInfo::readConfig(const KConfigGroup &config) 0074 { 0075 mInstanceName = config.readEntry(QStringLiteral("instanceName")); 0076 mArchiveTopLevelCollectionId = config.readEntry(QStringLiteral("topLevelCollectionId"), -1); 0077 mArchiveType = static_cast<FolderArchiveType>(config.readEntry("folderArchiveType", (int)UniqueFolder)); 0078 mEnabled = config.readEntry("enabled", false); 0079 mKeepExistingStructure = config.readEntry("keepExistingStructure", false); 0080 mUseDateFromMessage = config.readEntry("useDateFromMessage", false); 0081 } 0082 0083 void FolderArchiveAccountInfo::writeConfig(KConfigGroup &config) 0084 { 0085 config.writeEntry(QStringLiteral("instanceName"), mInstanceName); 0086 if (mArchiveTopLevelCollectionId > -1) { 0087 config.writeEntry(QStringLiteral("topLevelCollectionId"), mArchiveTopLevelCollectionId); 0088 } else { 0089 config.deleteEntry(QStringLiteral("topLevelCollectionId")); 0090 } 0091 0092 config.writeEntry(QStringLiteral("folderArchiveType"), (int)mArchiveType); 0093 config.writeEntry(QStringLiteral("enabled"), mEnabled); 0094 config.writeEntry("keepExistingStructure", mKeepExistingStructure); 0095 config.writeEntry("useDateFromMessage", mUseDateFromMessage); 0096 } 0097 0098 bool FolderArchiveAccountInfo::operator==(const FolderArchiveAccountInfo &other) const 0099 { 0100 return (mInstanceName == other.instanceName()) && (mArchiveTopLevelCollectionId == other.archiveTopLevel()) && (mArchiveType == other.folderArchiveType()) 0101 && (mEnabled == other.enabled()) && (mKeepExistingStructure == other.keepExistingStructure()) && (mUseDateFromMessage == other.useDateFromMessage()); 0102 } 0103 0104 bool FolderArchiveAccountInfo::useDateFromMessage() const 0105 { 0106 return mUseDateFromMessage; 0107 } 0108 0109 void FolderArchiveAccountInfo::setUseDateFromMessage(bool newUseDateFromMessage) 0110 { 0111 mUseDateFromMessage = newUseDateFromMessage; 0112 }