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 {
27 TextColor = 1,
28 BackgroundColor = 1 << 1,
29 Font = 1 << 2
30 };
31 using SaveFlags = QFlags<SaveFlag>;
32
33 // Returns true if two tags are equal
34 [[nodiscard]] bool operator==(const Tag &other) const;
35
36 [[nodiscard]] bool operator!=(const Tag &other) const;
37
38 static Ptr createDefaultTag(const QString &name);
39 // expects a tag with all attributes fetched
40 static Ptr fromAkonadi(const Akonadi::Tag &tag);
41
42 [[nodiscard]] Akonadi::Tag saveToAkonadi(SaveFlags saveFlags = SaveFlags(TextColor | BackgroundColor | Font)) const;
43
44 // Compare, based on priority
45 static bool compare(const Ptr &tag1, const Ptr &tag2);
46 // Compare, based on name
47 static bool compareName(const Ptr &tag1, const Ptr &tag2);
48
49 [[nodiscard]] qint64 id() const;
50 [[nodiscard]] QString name() const;
51 [[nodiscard]] Akonadi::Tag tag() const;
52
53 QString tagName;
54 QColor textColor;
55 QColor backgroundColor;
56 QString iconName;
58 bool isBold;
59 bool isItalic;
60 bool inToolbar;
61 bool isImmutable;
62 // Priority, i.e. sort order of the tag. Only used when loading the tag, when saving
63 // the priority is set to the position in the list widget
64 int priority;
65
66private:
67 Tag()
68 : isBold(false)
69 , isItalic(false)
70 , inToolbar(false)
71 , isImmutable(false)
72 , priority(0)
73 {
74 }
75
76 Akonadi::Tag mTag;
77};
78Q_DECLARE_OPERATORS_FOR_FLAGS(Tag::SaveFlags)
79}
KIOCORE_EXPORT bool operator!=(const UDSEntry &entry, const UDSEntry &other)
QString name(StandardAction id)
const QList< QKeySequence > & shortcut(StandardShortcut id)
bool operator==(const StyleDelim &l, const StyleDelim &r)
The filter dialog.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:01 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.