1
/***************************************************************************
3
* This program is free software; you can redistribute it and/or modify *
4
* it under the terms of the GNU General Public License as published by *
5
* the Free Software Foundation; either version 2 of the License, or *
6
* (at your option) any later version. *
8
***************************************************************************/
13
#include <QtCore/QList>
14
#include <QtCore/QRegExp>
15
#include <QtGui/QColor>
25
* \brief Part of message that has text and formatting (or an image)
27
* This class represents a part of message - text with formatting or an image.
28
* Each \see Message is constructed from a series of message parts.
30
* Method isImage is used to distinguish image-parts from text-parts.
32
* There are two kinds of image parts:
34
* <li>not-yet-received image parts -
35
* they contains informations about sender of image, and image size and crc32
36
* (used with Gadu-Gadu protocol to assign incoming images with messages).
38
* <li>received image parts -
39
* they contains only local image path
61
* Creates text message part with formatting.
62
* @arg content content of message
63
* @arg bold if true, the whole part is presented with bold font
64
* @arg italic if true, the whole part is presented with italic font
65
* @arg underline if true, the whole part is presented with underline font
66
* @arg color color of whole part
68
MessagePart(const QString &content, bool bold, bool italic, bool underline, QColor color);
71
* Creates image message part. All informations are used to
72
* assign an image to this part, when the real image is received from sender.
74
* @arg imageSender sender of the image
75
* @arg imageSize size of the image
76
* @arg imageCrc32 crc32 of the image
78
MessagePart(UinType imageSender, int imageSize, int imageCrc32);
81
* Creates image message part.
82
* @arg imagePath local image path
84
MessagePart(const QString &imagePath);
85
virtual ~MessagePart();
87
bool isImage() const { return Image; }
88
bool isEmpty() const { return !Image && Content.isEmpty(); }
90
QString content() const { return Content; }
91
bool bold() const { return Bold; }
92
bool italic() const { return Italic; }
93
bool underline() const { return Underline; }
94
QColor color() const { return Color; }
96
QString imagePath() const { return ImagePath; }
99
* Converts message part to HTML - either formatted text or image.
100
* @return HTML representation of message parh.
102
QString toHtml() const;
108
* \brief Rich message (incoming or outcoming).
110
* This class represens incoming or outgoing message. Some protocols (like GG) uses its own
111
* formatting, so this class acts like abstraction over all used formatting methods in Kadu.
113
* Message is splited into parts (\see MessagePart) - each part can contain text and formatting or an image.
115
* Each message has an <code>id</code> field that is used by protocols to store its message sequental number.
117
class KADUAPI Message
119
static QRegExp ImageRegExp;
120
static void parseImages(Message &message, const QString &messageString, bool b, bool i, bool u, QColor color);
122
QList<MessagePart> Parts;
127
* Creates an empty message.
132
* Creates a message with one, non-formatted text part.
134
* @arg messageString content of new message
136
Message(const QString &messageString);
141
* Creates a message from given HTML document. The bold, italic, underline and
142
* color formatting are preserved and stored into result object.
143
* It also extracts images and inserts in into message.
145
* @arg messageDocument HTML document to parse
146
* @return Message representation of HTML document
148
static Message parse(const QTextDocument *messageDocument);
151
* Returns all parts that composes this message.
152
* @return All parts that composes this message.
154
QList<MessagePart> parts() const;
157
* Append a new part to message.
158
* @arg part New part to append.
160
void append(MessagePart part);
163
* Append a new part to message.
164
* @arg part New part to append.
166
Message & operator << (MessagePart part);
168
void setId(int id) { Id = id; }
169
int id() { return Id; }
172
* Returns true if message does not have any parts or if all parts are empty.
173
* @return True if message is empty.
175
bool isEmpty() const;
178
* Returns message content, without formatting or images.
179
* @return Plain message content.
181
QString toPlain() const;
184
* Converts message to HTML, with formatting and images. Resulting code is
185
* not a full HTML page - only the content.
186
* @return HTML representation of message.
188
QString toHtml() const;