Warning, file /pim/mailcommon/src/tag/tag.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* SPDX-FileCopyrightText: 2010 Thomas McGuire <mcguire@kde.org> 0002 0003 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 */ 0005 #pragma once 0006 0007 #include "mailcommon_export.h" 0008 0009 #include <QKeySequence> 0010 0011 #include <Akonadi/Tag> 0012 #include <QColor> 0013 #include <QSharedPointer> 0014 0015 namespace MailCommon 0016 { 0017 // Our own copy of the tag data. 0018 // Useful in the config dialog, because the user might cancel his changes, 0019 // in which case we don't write them back. 0020 // Also used as a convenience class in the TagActionManager. 0021 class MAILCOMMON_EXPORT Tag 0022 { 0023 Q_GADGET 0024 public: 0025 using Ptr = QSharedPointer<Tag>; 0026 enum SaveFlag { TextColor = 1, BackgroundColor = 1 << 1, Font = 1 << 2 }; 0027 using SaveFlags = QFlags<SaveFlag>; 0028 0029 // Returns true if two tags are equal 0030 [[nodiscard]] bool operator==(const Tag &other) const; 0031 0032 [[nodiscard]] bool operator!=(const Tag &other) const; 0033 0034 static Ptr createDefaultTag(const QString &name); 0035 // expects a tag with all attributes fetched 0036 static Ptr fromAkonadi(const Akonadi::Tag &tag); 0037 0038 [[nodiscard]] Akonadi::Tag saveToAkonadi(SaveFlags saveFlags = SaveFlags(TextColor | BackgroundColor | Font)) const; 0039 0040 // Compare, based on priority 0041 static bool compare(const Ptr &tag1, const Ptr &tag2); 0042 // Compare, based on name 0043 static bool compareName(const Ptr &tag1, const Ptr &tag2); 0044 0045 qint64 id() const; 0046 QString name() const; 0047 Akonadi::Tag tag() const; 0048 0049 QString tagName; 0050 QColor textColor; 0051 QColor backgroundColor; 0052 QString iconName; 0053 QKeySequence shortcut; 0054 bool isBold; 0055 bool isItalic; 0056 bool inToolbar; 0057 bool isImmutable; 0058 // Priority, i.e. sort order of the tag. Only used when loading the tag, when saving 0059 // the priority is set to the position in the list widget 0060 int priority; 0061 0062 private: 0063 Tag() 0064 : isBold(false) 0065 , isItalic(false) 0066 , inToolbar(false) 0067 , isImmutable(false) 0068 , priority(0) 0069 { 0070 } 0071 0072 Akonadi::Tag mTag; 0073 }; 0074 Q_DECLARE_OPERATORS_FOR_FLAGS(Tag::SaveFlags) 0075 }