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>
27 #include <QSharedPointer>
28 #include <AkonadiCore/tag.h>
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
42 typedef QSharedPointer
<Tag
> Ptr
;
45 BackgroundColor
= 1 << 1,
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
);
68 Akonadi::Tag
tag() const;
72 QColor backgroundColor
;
74 QKeySequence shortcut
;
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
94 Q_DECLARE_OPERATORS_FOR_FLAGS(Tag::SaveFlags
)