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

KDE's Doxygen guidelines are available online.