Messagelib

messageitem.h
1 /******************************************************************************
2  *
3  * SPDX-FileCopyrightText: 2008 Szymon Tomasz Stefanek <[email protected]>
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  *
7  *******************************************************************************/
8 
9 #ifndef MESSAGELIST_CORE_MESSAGEITEM_H
10 #define MESSAGELIST_CORE_MESSAGEITEM_H
11 
12 #include "core/item.h"
13 #include "core/modelinvariantindex.h"
14 
15 #include <QPixmap>
16 #include <QString>
17 #include <QColor>
18 #include <QFont>
19 #include <messagelist_export.h>
20 #include "theme.h"
21 
22 namespace Akonadi {
23 class Item;
24 }
25 
26 namespace MessageList {
27 namespace Core {
28 class MessageItemPrivate;
32 class MESSAGELIST_EXPORT MessageItem : public Item, public ModelInvariantIndex
33 {
34 public:
35  class MESSAGELIST_EXPORT Tag
36  {
37  public:
38  explicit Tag(const QPixmap &pix, const QString &tagName, const QString &tagId);
39  ~Tag();
40  const QPixmap &pixmap() const;
41  const QString &name() const;
42  const QString &id() const;
43  const QColor &textColor() const;
44  const QColor &backgroundColor() const;
45  const QFont &font() const;
46  int priority() const;
47 
48  void setTextColor(const QColor &textColor);
49  void setBackgroundColor(const QColor &backgroundColor);
50  void setFont(const QFont &font);
51  void setPriority(int priority);
52 
53  private:
54  class Private;
55  Private *const d;
56  };
57 
62  NonThreadable
63  };
64 
65  enum EncryptionState {
66  NotEncrypted,
67  PartiallyEncrypted,
68  FullyEncrypted,
69  EncryptionStateUnknown
70  };
71 
72  enum SignatureState {
73  NotSigned,
74  PartiallySigned,
75  FullySigned,
76  SignatureStateUnknown
77  };
78 
79  explicit MessageItem();
80  virtual ~MessageItem();
81 
82 public:
83 
85  virtual QList< Tag * > tagList() const;
86 
88  virtual bool hasAnnotation() const;
89 
91  Q_REQUIRED_RESULT QString annotation() const;
92 
94  void editAnnotation(QWidget *parent);
95 
100  const Tag *findTag(const QString &szTagId) const;
101 
102  Q_REQUIRED_RESULT QString tagListDescription() const;
103 
106  void invalidateTagCache();
107 
109  void invalidateAnnotationCache();
110 
111  const QColor &textColor() const;
112 
113  const QColor &backgroundColor() const;
114 
115  Q_REQUIRED_RESULT bool isBold() const
116  {
117  return font().bold();
118  }
119 
120  Q_REQUIRED_RESULT bool isItalic() const
121  {
122  return font().italic();
123  }
124 
125  Q_REQUIRED_RESULT SignatureState signatureState() const;
126 
127  void setSignatureState(SignatureState state);
128 
129  Q_REQUIRED_RESULT EncryptionState encryptionState() const;
130 
131  void setEncryptionState(EncryptionState state);
132 
133  Q_REQUIRED_RESULT QByteArray messageIdMD5() const;
134 
135  void setMessageIdMD5(const QByteArray &md5);
136 
137  Q_REQUIRED_RESULT QByteArray inReplyToIdMD5() const;
138 
139  void setInReplyToIdMD5(const QByteArray &md5);
140 
141  Q_REQUIRED_RESULT QByteArray referencesIdMD5() const;
142 
143  void setReferencesIdMD5(const QByteArray &md5);
144 
145  void setSubjectIsPrefixed(bool subjectIsPrefixed);
146 
147  Q_REQUIRED_RESULT bool subjectIsPrefixed() const;
148 
149  Q_REQUIRED_RESULT QByteArray strippedSubjectMD5() const;
150 
151  void setStrippedSubjectMD5(const QByteArray &md5);
152 
153  Q_REQUIRED_RESULT bool aboutToBeRemoved() const;
154 
155  void setAboutToBeRemoved(bool aboutToBeRemoved);
156 
157  Q_REQUIRED_RESULT ThreadingStatus threadingStatus() const;
158 
159  void setThreadingStatus(ThreadingStatus threadingStatus);
160 
161  Q_REQUIRED_RESULT unsigned long uniqueId() const;
162 
163  Akonadi::Item akonadiItem() const;
164  void setAkonadiItem(const Akonadi::Item &item);
165 
166  MessageItem *topmostMessage();
167 
168  QString accessibleText(const MessageList::Core::Theme *theme, int columnIndex);
169 
174  void subTreeToList(QVector<MessageItem *> &list);
175 
176  //
177  // Colors and fonts shared by all message items.
178  // textColor() and font() will take the message status into account and return
179  // one of these.
180  // Call these setters only once when reading the colors from the config file.
181  //
182  static void setUnreadMessageColor(const QColor &color);
183  static void setImportantMessageColor(const QColor &color);
184  static void setToDoMessageColor(const QColor &color);
185  static void setGeneralFont(const QFont &font);
186  static void setUnreadMessageFont(const QFont &font);
187  static void setImportantMessageFont(const QFont &font);
188  static void setToDoMessageFont(const QFont &font);
189 
190 protected:
191  explicit MessageItem(MessageItemPrivate *dd);
192 private:
193  const QFont &font() const;
194 
195  QString accessibleTextForField(Theme::ContentItem::Type field);
196 
197  Q_DECLARE_PRIVATE(MessageItem)
198 };
199 
200 class FakeItemPrivate;
201 
203 class FakeItem : public MessageItem
204 {
205 public:
206 
207  explicit FakeItem();
208  ~FakeItem() override;
209 
211  QList< Tag * > tagList() const override;
212 
214  void setFakeTags(const QList< Tag * > &tagList);
215 
217  bool hasAnnotation() const override;
218 
219 private:
220  Q_DECLARE_PRIVATE(FakeItem)
221 };
222 } // namespace Core
223 } // namespace MessageList
224 
225 #endif
The MessageItem class.
Definition: messageitem.h:32
this message might belong to a thread but its parent is actually missing
Definition: messageitem.h:61
this message found an imperfect parent to attach to (might be fixed later)
Definition: messageitem.h:60
this message found a perfect parent to attach to
Definition: messageitem.h:59
Type
The available ContentItem types.
Definition: theme.h:106
A single item of the MessageList tree managed by MessageList::Model.
Definition: item.h:34
A message item that can have a fake tag list and a fake annotation.
Definition: messageitem.h:203
The Theme class defines the visual appearance of the MessageList.
Definition: theme.h:47
An invariant index that can be ALWAYS used to reference an item inside a QAbstractItemModel.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Jan 19 2021 23:17:25 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.