SVN_SILENT made messages (.desktop file) - always resolve ours
[kdepim.git] / mailcommon / src / tag / tag.h
blob24a23709c3a15d8a4b8bae7f3f2408ea4994c608
1 /* Copyright 2010 Thomas McGuire <mcguire@kde.org>
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU General Public License as
5 published by the Free Software Foundation; either version 2 of
6 the License or (at your option) version 3 or any later version
7 accepted by the membership of KDE e.V. (or its successor approved
8 by the membership of KDE e.V.), which shall act as a proxy
9 defined in Section 14 of version 3 of the license.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef MAILCOMMONTAG_H
20 #define MAILCOMMONTAG_H
22 #include "mailcommon_export.h"
24 #include <QKeySequence>
26 #include <QColor>
27 #include <QSharedPointer>
28 #include <AkonadiCore/tag.h>
30 namespace MailCommon
33 // Our own copy of the tag data.
34 // Useful in the config dialog, because the user might cancel his changes,
35 // in which case we don't write them back.
36 // Also used as a convenience class in the TagActionManager.
37 class MAILCOMMON_EXPORT Tag
39 Q_GADGET
40 public:
42 typedef QSharedPointer<Tag> Ptr;
43 enum SaveFlag {
44 TextColor = 1,
45 BackgroundColor = 1 << 1,
46 Font = 1 << 2
48 typedef QFlags<SaveFlag> SaveFlags;
50 // Returns true if two tags are equal
51 bool operator==(const Tag &other) const;
53 bool operator!=(const Tag &other) const;
55 static Ptr createDefaultTag(const QString &name);
56 // expects a tag with all attributes fetched
57 static Ptr fromAkonadi(const Akonadi::Tag &tag);
59 Akonadi::Tag saveToAkonadi(SaveFlags saveFlags = SaveFlags(TextColor | BackgroundColor | Font)) const;
61 // Compare, based on priority
62 static bool compare(Ptr &tag1, Ptr &tag2);
63 // Compare, based on name
64 static bool compareName(Ptr &tag1, Ptr &tag2);
66 qint64 id() const;
67 QString name() const;
68 Akonadi::Tag tag() const;
70 QString tagName;
71 QColor textColor;
72 QColor backgroundColor;
73 QString iconName;
74 QKeySequence shortcut;
75 bool isBold;
76 bool isItalic;
77 bool inToolbar;
78 bool isImmutable;
79 // Priority, i.e. sort order of the tag. Only used when loading the tag, when saving
80 // the priority is set to the position in the list widget
81 int priority;
83 private:
84 Tag()
85 : isBold(false),
86 isItalic(false),
87 inToolbar(false),
88 isImmutable(false),
89 priority(0)
92 Akonadi::Tag mTag;
94 Q_DECLARE_OPERATORS_FOR_FLAGS(Tag::SaveFlags)
98 #endif