Messagelib

messageitem.h
1/******************************************************************************
2 *
3 * SPDX-FileCopyrightText: 2008 Szymon Tomasz Stefanek <pragma@kvirc.net>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 *
7 *******************************************************************************/
8
9#pragma once
10
11#include "core/item.h"
12#include "core/modelinvariantindex.h"
13
14#include "messagelist_export.h"
15#include "theme.h"
16#include <QColor>
17#include <QFont>
18#include <QPixmap>
19#include <QString>
20
21namespace Akonadi
22{
23class Item;
24}
25
26namespace MessageList
27{
28namespace Core
29{
30class MessageItemPrivate;
31/**
32 * @brief The MessageItem class
33 */
34class MESSAGELIST_EXPORT MessageItem : public Item, public ModelInvariantIndex
35{
36public:
37 class MESSAGELIST_EXPORT Tag
38 {
39 public:
40 explicit Tag(const QPixmap &pix, const QString &tagName, const QString &tagId);
41 ~Tag();
42 const QPixmap &pixmap() const;
43 const QString &name() const;
44 const QString &id() const;
45 const QColor &textColor() const;
46 const QColor &backgroundColor() const;
47 const QFont &font() const;
48 int priority() const;
49
50 void setTextColor(const QColor &textColor);
51 void setBackgroundColor(const QColor &backgroundColor);
52 void setFont(const QFont &font);
53 void setPriority(int priority);
54
55 private:
56 class TagPrivate;
57 std::unique_ptr<TagPrivate> const d;
58 };
59
61 PerfectParentFound, ///< this message found a perfect parent to attach to
62 ImperfectParentFound, ///< this message found an imperfect parent to attach to (might be fixed later)
63 ParentMissing, ///< this message might belong to a thread but its parent is actually missing
64 NonThreadable ///< this message does not look as being threadable
65 };
66
67 enum EncryptionState { NotEncrypted, PartiallyEncrypted, FullyEncrypted, EncryptionStateUnknown };
68
69 enum SignatureState { NotSigned, PartiallySigned, FullySigned, SignatureStateUnknown };
70
71 explicit MessageItem();
72 ~MessageItem() override;
73
74public:
75 /// Returns the list of tags for this item.
76 virtual QList<Tag *> tagList() const;
77
78 /**
79 * Returns Tag associated to this message that has the specified id or 0
80 * if no such tag exists. mTagList will be 0 in 99% of the cases.
81 */
82 const Tag *findTag(const QString &szTagId) const;
83
84 [[nodiscard]] QString tagListDescription() const;
85
86 /// Deletes all cached tags. The next time someone asks this item for the tags, they are
87 /// fetched again
88 void invalidateTagCache();
89
90 const QColor &textColor() const;
91
92 const QColor &backgroundColor() const;
93
94 [[nodiscard]] bool isBold() const
95 {
96 return font().bold();
97 }
98
99 [[nodiscard]] bool isItalic() const
100 {
101 return font().italic();
102 }
103
104 [[nodiscard]] SignatureState signatureState() const;
105
106 void setSignatureState(SignatureState state);
107
108 [[nodiscard]] EncryptionState encryptionState() const;
109
110 void setEncryptionState(EncryptionState state);
111
112 [[nodiscard]] QByteArray messageIdMD5() const;
113
114 void setMessageIdMD5(const QByteArray &md5);
115
116 [[nodiscard]] QByteArray inReplyToIdMD5() const;
117
118 void setInReplyToIdMD5(const QByteArray &md5);
119
120 [[nodiscard]] QByteArray referencesIdMD5() const;
121
122 void setReferencesIdMD5(const QByteArray &md5);
123
124 void setSubjectIsPrefixed(bool subjectIsPrefixed);
125
126 [[nodiscard]] bool subjectIsPrefixed() const;
127
128 [[nodiscard]] QByteArray strippedSubjectMD5() const;
129
130 void setStrippedSubjectMD5(const QByteArray &md5);
131
132 [[nodiscard]] bool aboutToBeRemoved() const;
133
134 void setAboutToBeRemoved(bool aboutToBeRemoved);
135
136 [[nodiscard]] ThreadingStatus threadingStatus() const;
137
138 void setThreadingStatus(ThreadingStatus threadingStatus);
139
140 [[nodiscard]] unsigned long uniqueId() const;
141
142 Akonadi::Item akonadiItem() const;
143 void setAkonadiItem(const Akonadi::Item &item);
144
145 MessageItem *topmostMessage();
146
147 QString accessibleText(const MessageList::Core::Theme *theme, int columnIndex);
148
149 /**
150 * Appends the whole subtree originating at this item
151 * to the specified list. This item is included!
152 */
153 void subTreeToList(QList<MessageItem *> &list);
154
155 //
156 // Colors and fonts shared by all message items.
157 // textColor() and font() will take the message status into account and return
158 // one of these.
159 // Call these setters only once when reading the colors from the config file.
160 //
161 static void setUnreadMessageColor(const QColor &color);
162 static void setImportantMessageColor(const QColor &color);
163 static void setToDoMessageColor(const QColor &color);
164 static void setGeneralFont(const QFont &font);
165 static void setUnreadMessageFont(const QFont &font);
166 static void setImportantMessageFont(const QFont &font);
167 static void setToDoMessageFont(const QFont &font);
168
169protected:
170 explicit MessageItem(MessageItemPrivate *dd);
171
172private:
173 MESSAGELIST_NO_EXPORT const QFont &font() const;
174
175 MESSAGELIST_NO_EXPORT QString accessibleTextForField(Theme::ContentItem::Type field);
176
177 Q_DECLARE_PRIVATE(MessageItem)
178};
179
180class FakeItemPrivate;
181
182/// A message item that can have a fake tag list and a fake annotation
183class FakeItem : public MessageItem
184{
185public:
186 explicit FakeItem();
187 ~FakeItem() override;
188
189 /// Reimplemented to return the fake tag list
190 QList<Tag *> tagList() const override;
191
192 /// Sets a list of fake tags for this item
193 void setFakeTags(const QList<Tag *> &tagList);
194
195private:
196 Q_DECLARE_PRIVATE(FakeItem)
197};
198} // namespace Core
199} // namespace MessageList
A message item that can have a fake tag list and a fake annotation.
void setFakeTags(const QList< Tag * > &tagList)
Sets a list of fake tags for this item.
QList< Tag * > tagList() const override
Reimplemented to return the fake tag list.
A single item of the MessageList tree managed by MessageList::Model.
Definition item.h:36
The MessageItem class.
Definition messageitem.h:35
@ ImperfectParentFound
this message found an imperfect parent to attach to (might be fixed later)
Definition messageitem.h:62
@ ParentMissing
this message might belong to a thread but its parent is actually missing
Definition messageitem.h:63
@ PerfectParentFound
this message found a perfect parent to attach to
Definition messageitem.h:61
An invariant index that can be ALWAYS used to reference an item inside a QAbstractItemModel.
The Theme class defines the visual appearance of the MessageList.
Definition theme.h:48
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 19 2024 11:56:56 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.