SVN commit 1209899 by pali:
Support rich html messages in history
M +27 -4 historylogger.cpp
--- branches/KDE/4.6/kdenetwork/kopete/plugins/history/historylogger.cpp #1209898:1209899
@@ -25,6 +25,7 @@
#include
#include
#include
+#include
#include
#include
@@ -292,7 +293,13 @@
msgElem.setAttribute( "nick", msg.from()->property( Kopete::Global::Properties::self()->nickName() ).value().toString() ); //do we have to set this?
msgElem.setAttribute( "time", msg.timestamp().toString("d h:m:s") );
- QDomText msgNode = doc.createTextNode( msg.plainBody() );
+ QDomText msgNode;
+
+ if ( msg.format() != Qt::PlainText )
+ msgNode = doc.createTextNode( msg.escapedBody() );
+ else
+ msgNode = doc.createTextNode( Qt::escape(msg.plainBody()) );
+
docElem.appendChild( msgElem );
msgElem.appendChild( msgNode );
@@ -397,9 +404,17 @@
to.append( dir==Kopete::Message::Inbound ? contact->account()->myself() : contact );
Kopete::Message msg(from, to);
+
+ QString message;
+ if ( Qt::mightBeRichText(msgElem2.text()) ) {
+ message = msgElem2.text();
+ } else {
msg.setPlainBody( msgElem2.text() );
+ message = msg.escapedBody();
+ }
+
msg.setHtmlBody( QString::fromLatin1("%2")
- .arg( dt.toString(Qt::LocalDate), msg.escapedBody() ));
+ .arg( dt.toString(Qt::LocalDate), message ));
msg.setTimestamp( dt );
msg.setDirection( dir );
@@ -627,18 +642,26 @@
Kopete::Message msg(from, to);
msg.setTimestamp( timestamp );
msg.setDirection( dir );
+
+ QString message;
+ if ( Qt::mightBeRichText(msgElem.text()) ) {
+ message = msgElem.text();
+ } else {
msg.setPlainBody( msgElem.text() );
+ message = msg.escapedBody();
+ }
+
if (colorize)
{
msg.setHtmlBody( QString::fromLatin1("%3")
- .arg( fgColor.name(), timestamp.toString(Qt::LocalDate), msg.escapedBody() ));
+ .arg( fgColor.name(), timestamp.toString(Qt::LocalDate), message ));
msg.setForegroundColor( fgColor );
msg.addClass( "history" );
}
else
{
msg.setHtmlBody( QString::fromLatin1("%2")
- .arg( timestamp.toString(Qt::LocalDate), msg.escapedBody() ));
+ .arg( timestamp.toString(Qt::LocalDate), message ));
}
if(reverseOrder)