Mailcommon

tag.h
1/* SPDX-FileCopyrightText: 2010 Thomas McGuire <mcguire@kde.org>
2
3 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
4*/
5#pragma once
6
7#include "mailcommon_export.h"
8
9#include <QKeySequence>
10
11#include <Akonadi/Tag>
12#include <QColor>
13#include <QSharedPointer>
14
15namespace MailCommon
16{
17// Our own copy of the tag data.
18// Useful in the config dialog, because the user might cancel his changes,
19// in which case we don't write them back.
20// Also used as a convenience class in the TagActionManager.
21class MAILCOMMON_EXPORT Tag
22{
23 Q_GADGET
24public:
25 using Ptr = QSharedPointer<Tag>;
26 enum SaveFlag { TextColor = 1, BackgroundColor = 1 << 1, Font = 1 << 2 };
27 using SaveFlags = QFlags<SaveFlag>;
28
29 // Returns true if two tags are equal
30 [[nodiscard]] bool operator==(const Tag &other) const;
31
32 [[nodiscard]] bool operator!=(const Tag &other) const;
33
34 static Ptr createDefaultTag(const QString &name);
35 // expects a tag with all attributes fetched
36 static Ptr fromAkonadi(const Akonadi::Tag &tag);
37
38 [[nodiscard]] Akonadi::Tag saveToAkonadi(SaveFlags saveFlags = SaveFlags(TextColor | BackgroundColor | Font)) const;
39
40 // Compare, based on priority
41 static bool compare(const Ptr &tag1, const Ptr &tag2);
42 // Compare, based on name
43 static bool compareName(const Ptr &tag1, const Ptr &tag2);
44
45 qint64 id() const;
46 QString name() const;
47 Akonadi::Tag tag() const;
48
49 QString tagName;
50 QColor textColor;
51 QColor backgroundColor;
52 QString iconName;
54 bool isBold;
55 bool isItalic;
56 bool inToolbar;
57 bool isImmutable;
58 // Priority, i.e. sort order of the tag. Only used when loading the tag, when saving
59 // the priority is set to the position in the list widget
60 int priority;
61
62private:
63 Tag()
64 : isBold(false)
65 , isItalic(false)
66 , inToolbar(false)
67 , isImmutable(false)
68 , priority(0)
69 {
70 }
71
72 Akonadi::Tag mTag;
73};
74Q_DECLARE_OPERATORS_FOR_FLAGS(Tag::SaveFlags)
75}
QString name(StandardShortcut id)
const QList< QKeySequence > & shortcut(StandardShortcut id)
The filter dialog.
bool operator==(const QGraphicsApiFilter &reference, const QGraphicsApiFilter &sample)
bool operator!=(const QGraphicsApiFilter &reference, const QGraphicsApiFilter &sample)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:14:01 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.