1 /* 2 SPDX-FileCopyrightText: 2009-2021 Laurent Montel <montel@kde.org> 3 4 SPDX-License-Identifier: GPL-2.0-or-later 5 */ 6 7 #pragma once 8 9 #include "mailcommon_export.h" 10 #include <MessageViewer/Viewer> 11 12 #include <MessageCore/MailingList> 13 using MessageCore::MailingList; 14 15 #include <Akonadi/Collection> 16 #include <Akonadi/CollectionStatistics> 17 18 #include <KIO/Job> 19 #include <KSharedConfig> 20 #include <QKeySequence> 21 22 namespace MailCommon 23 { 24 /** 25 * @brief The FolderSettings class 26 * @author Laurent Montel <montel@kde.org> 27 */ 28 class MAILCOMMON_EXPORT FolderSettings : public QObject 29 { 30 Q_OBJECT 31 32 public: 33 static QSharedPointer<FolderSettings> forCollection(const Akonadi::Collection &coll, bool writeConfig = true); 34 35 ~FolderSettings() override; 36 37 void setCollection(const Akonadi::Collection &collection); 38 39 static QString configGroupName(const Akonadi::Collection &col); 40 static void clearCache(); 41 static void resetHtmlFormat(); 42 43 Q_REQUIRED_RESULT bool isWriteConfig() const; 44 void setWriteConfig(bool writeConfig); 45 46 void writeConfig() const; 47 void readConfig(); 48 49 Q_REQUIRED_RESULT QString name() const; 50 51 Q_REQUIRED_RESULT bool isReadOnly() const; 52 53 Q_REQUIRED_RESULT bool isStructural() const; 54 55 Q_REQUIRED_RESULT bool isSystemFolder() const; 56 57 Q_REQUIRED_RESULT qint64 count() const; 58 59 Q_REQUIRED_RESULT bool canDeleteMessages() const; 60 61 Q_REQUIRED_RESULT bool canCreateMessages() const; 62 63 Q_REQUIRED_RESULT bool isValid() const; 64 65 Q_REQUIRED_RESULT Akonadi::Collection::Rights rights() const; 66 67 Q_REQUIRED_RESULT Akonadi::CollectionStatistics statistics() const; 68 69 void setShortcut(const QKeySequence &); 70 const QKeySequence &shortcut() const; 71 72 /** 73 * Get / set whether the default identity should be used instead of the 74 * identity specified by setIdentity(). 75 */ 76 void setUseDefaultIdentity(bool useDefaultIdentity); 77 Q_REQUIRED_RESULT bool useDefaultIdentity() const; 78 79 void setIdentity(uint identity); 80 Q_REQUIRED_RESULT uint identity() const; 81 82 /** 83 * Returns true if this folder is associated with a mailing-list. 84 */ 85 void setMailingListEnabled(bool enabled); 86 Q_REQUIRED_RESULT bool isMailingListEnabled() const; 87 88 void setMailingList(const MailingList &mlist); 89 90 MailingList mailingList() const; 91 92 /** 93 * Returns true if the replies to mails from this folder should be 94 * put in the same folder. 95 */ 96 Q_REQUIRED_RESULT bool putRepliesInSameFolder() const; 97 void setPutRepliesInSameFolder(bool b); 98 99 /** 100 * Returns true if this folder should be hidden from all folder selection dialogs 101 */ 102 Q_REQUIRED_RESULT bool hideInSelectionDialog() const; 103 void setHideInSelectionDialog(bool hide); 104 105 Q_REQUIRED_RESULT QString mailingListPostAddress() const; 106 107 Q_REQUIRED_RESULT uint fallBackIdentity() const; 108 Q_REQUIRED_RESULT MessageViewer::Viewer::DisplayFormatMessage formatMessage() const; 109 void setFormatMessage(MessageViewer::Viewer::DisplayFormatMessage formatMessage); 110 111 Q_REQUIRED_RESULT bool folderHtmlLoadExtPreference() const; 112 void setFolderHtmlLoadExtPreference(bool folderHtmlLoadExtPreference); 113 114 protected Q_SLOTS: 115 void slotIdentitiesChanged(); 116 117 private: 118 explicit FolderSettings(const Akonadi::Collection &col, bool writeconfig); 119 QString resource() const; 120 121 Akonadi::Collection mCollection; 122 123 /** Mailing list attributes */ 124 bool mMailingListEnabled; 125 MailingList mMailingList; 126 127 bool mUseDefaultIdentity; 128 uint mIdentity; 129 130 MessageViewer::Viewer::DisplayFormatMessage mFormatMessage = MessageViewer::Viewer::Unknown; 131 /** Should replies to messages in this folder be put in here? */ 132 bool mPutRepliesInSameFolder = false; 133 134 /** Should this folder be hidden in the folder selection dialog? */ 135 bool mHideInSelectionDialog = false; 136 137 bool mFolderHtmlLoadExtPreference = false; 138 139 /** shortcut associated with this folder or null, if none is configured. */ 140 QKeySequence mShortcut; 141 bool mWriteConfig; 142 }; 143 } 144 145