Mailcommon

tag.h
1 /* SPDX-FileCopyrightText: 2010 Thomas McGuire <[email protected]>
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 
15 namespace 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.
21 class MAILCOMMON_EXPORT Tag
22 {
23  Q_GADGET
24 public:
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  Q_REQUIRED_RESULT bool operator==(const Tag &other) const;
31 
32  Q_REQUIRED_RESULT 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  Q_REQUIRED_RESULT 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 
62 private:
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 };
74 Q_DECLARE_OPERATORS_FOR_FLAGS(Tag::SaveFlags)
75 }
const QList< QKeySequence > & shortcut(StandardShortcut id)
bool operator==(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)
bool operator!=(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)
QString name(StandardShortcut id)
The filter dialog.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Sep 24 2022 03:58:15 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.