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 {
68 NotEncrypted,
69 PartiallyEncrypted,
70 FullyEncrypted,
71 EncryptionStateUnknown
72 };
73
74 enum SignatureState {
75 NotSigned,
76 PartiallySigned,
77 FullySigned,
78 SignatureStateUnknown
79 };
80
81 explicit MessageItem();
82 ~MessageItem() override;
83
84public:
85 /// Returns the list of tags for this item.
86 virtual QList<Tag *> tagList() const;
87
88 /**
89 * Returns Tag associated to this message that has the specified id or 0
90 * if no such tag exists. mTagList will be 0 in 99% of the cases.
91 */
92 const Tag *findTag(const QString &szTagId) const;
93
94 [[nodiscard]] QString tagListDescription() const;
95
96 /// Deletes all cached tags. The next time someone asks this item for the tags, they are
97 /// fetched again
98 void invalidateTagCache();
99
100 const QColor &textColor() const;
101
102 const QColor &backgroundColor() const;
103
104 [[nodiscard]] bool isBold() const
105 {
106 return font().bold();
107 }
108
109 [[nodiscard]] bool isItalic() const
110 {
111 return font().italic();
112 }
113
114 [[nodiscard]] SignatureState signatureState() const;
115
116 void setSignatureState(SignatureState state);
117
118 [[nodiscard]] EncryptionState encryptionState() const;
119
120 void setEncryptionState(EncryptionState state);
121
122 [[nodiscard]] QByteArray messageIdMD5() const;
123
124 void setMessageIdMD5(const QByteArray &md5);
125
126 [[nodiscard]] QByteArray inReplyToIdMD5() const;
127
128 void setInReplyToIdMD5(const QByteArray &md5);
129
130 [[nodiscard]] QByteArray referencesIdMD5() const;
131
132 void setReferencesIdMD5(const QByteArray &md5);
133
134 void setSubjectIsPrefixed(bool subjectIsPrefixed);
135
136 [[nodiscard]] bool subjectIsPrefixed() const;
137
138 [[nodiscard]] QByteArray strippedSubjectMD5() const;
139
140 void setStrippedSubjectMD5(const QByteArray &md5);
141
142 [[nodiscard]] bool aboutToBeRemoved() const;
143
144 void setAboutToBeRemoved(bool aboutToBeRemoved);
145
146 [[nodiscard]] ThreadingStatus threadingStatus() const;
147
148 void setThreadingStatus(ThreadingStatus threadingStatus);
149
150 [[nodiscard]] unsigned long uniqueId() const;
151
152 Akonadi::Item akonadiItem() const;
153 void setAkonadiItem(const Akonadi::Item &item);
154
155 MessageItem *topmostMessage();
156
157 QString accessibleText(const MessageList::Core::Theme *theme, int columnIndex);
158
159 /**
160 * Appends the whole subtree originating at this item
161 * to the specified list. This item is included!
162 */
163 void subTreeToList(QList<MessageItem *> &list);
164
165 //
166 // Colors and fonts shared by all message items.
167 // textColor() and font() will take the message status into account and return
168 // one of these.
169 // Call these setters only once when reading the colors from the config file.
170 //
171 static void setUnreadMessageColor(const QColor &color);
172 static void setImportantMessageColor(const QColor &color);
173 static void setToDoMessageColor(const QColor &color);
174 static void setGeneralFont(const QFont &font);
175 static void setUnreadMessageFont(const QFont &font);
176 static void setImportantMessageFont(const QFont &font);
177 static void setToDoMessageFont(const QFont &font);
178
179protected:
180 explicit MessageItem(MessageItemPrivate *dd);
181
182private:
183 MESSAGELIST_NO_EXPORT const QFont &font() const;
184
185 MESSAGELIST_NO_EXPORT QString accessibleTextForField(Theme::ContentItem::Type field);
186
187 Q_DECLARE_PRIVATE(MessageItem)
188};
189
190class FakeItemPrivate;
191
192/// A message item that can have a fake tag list and a fake annotation
193class FakeItem : public MessageItem
194{
195public:
196 explicit FakeItem();
197 ~FakeItem() override;
198
199 /// Reimplemented to return the fake tag list
200 QList<Tag *> tagList() const override;
201
202 /// Sets a list of fake tags for this item
203 void setFakeTags(const QList<Tag *> &tagList);
204
205private:
206 Q_DECLARE_PRIVATE(FakeItem)
207};
208} // namespace Core
209} // 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 Mon Nov 4 2024 16:33:26 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.