[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/KDE/4.6/kdenetwork/kopete/plugins/history
From: Pali Rohár <pali.rohar () gmail ! com>
Date: 2010-12-28 14:10:53
Message-ID: 20101228141053.3C6CEAC8AD () svn ! kde ! org
[Download RAW message or body]
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 <QtCore/QTextStream>
#include <QtCore/QList>
#include <QtCore/QDate>
+#include <QtGui/QTextDocument>
#include <kdebug.h>
#include <kstandarddirs.h>
@@ -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("<span title=\"%1\">%2</span>")
- .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("<span style=\"color:%1\" \
title=\"%2\">%3</span>")
- .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("<span title=\"%1\">%2</span>")
- .arg( timestamp.toString(Qt::LocalDate), msg.escapedBody() ));
+ .arg( timestamp.toString(Qt::LocalDate), message ));
}
if(reverseOrder)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic