550
const QString ChatMessagePart::addNickLinks( const QString &html ) const
552
QString retVal = html;
554
Kopete::ContactPtrList members = d->manager->members();
555
for ( QPtrListIterator<Kopete::Contact> it( members ); it.current(); ++it )
557
QString nick = (*it)->property( Kopete::Global::Properties::self()->nickName().key() ).value().toString();
558
//FIXME: this is really slow in channels with lots of contacts
559
QString parsed_nick = Kopete::Emoticons::parseEmoticons( nick );
561
if ( nick != parsed_nick )
563
retVal.replace( QRegExp( QString::fromLatin1("([\\s&;>])%1([\\s&;<:])")
564
.arg( QRegExp::escape( parsed_nick ) ) ), QString::fromLatin1("\\1%1\\2").arg( nick ) );
566
if ( nick.length() > 0 && ( retVal.find( nick ) > -1 ) && d->manager->protocol() )
569
QRegExp( QString::fromLatin1("([\\s&;>])(%1)([\\s&;<:])")
570
.arg( QRegExp::escape( nick ) ) ),
571
QString::fromLatin1("\\1<a href=\"kopetemessage://%1/?protocolId=%2&accountId=%3\" class=\"KopeteDisplayName\">\\2</a>\\3")
572
.arg( (*it)->contactId(), d->manager->protocol()->pluginId(), d->manager->account()->accountId() )
576
#if 0 //disabled because it causes crash on exit - Olivier 2006-03-31
577
QString nick = d->manager->myself()->property( Kopete::Global::Properties::self()->nickName().key() ).value().toString();
578
retVal.replace( QRegExp( QString::fromLatin1("([\\s&;>])%1([\\s&;<:])")
579
.arg( QRegExp::escape( Kopete::Emoticons::parseEmoticons( nick ) ) ) ), QString::fromLatin1("\\1%1\\2").arg( nick ) );
584
551
void ChatMessagePart::slotRefreshView()
586
553
DOM::HTMLElement kopeteNode = document().getElementById( QString::fromUtf8("KopeteStyle") );
956
923
// Style formatting for messages(incoming, outgoing, status)
957
QString ChatMessagePart::formatStyleKeywords( const QString &sourceHTML, Kopete::Message &message )
924
QString ChatMessagePart::formatStyleKeywords( const QString &sourceHTML, const Kopete::Message &_message )
926
Kopete::Message message=_message; //we will eventually need to modify it before showing it.
959
927
QString resultHTML = sourceHTML;
960
QString nick, contactId, service, protocolIcon;
928
QString nick, contactId, service, protocolIcon, nickLink;
962
930
if( message.from() )
990
958
protocolIcon = KGlobal::iconLoader()->iconPath( iconName, KIcon::Small );
960
nickLink=QString::fromLatin1("<a href=\"kopetemessage://%1/?protocolId=%2&accountId=%3\" class=\"KopeteDisplayName\">")
961
.arg( QStyleSheet::escape(message.from()->contactId()).replace('"',"""),
962
QStyleSheet::escape(message.from()->protocol()->pluginId()).replace('"',"""),
963
QStyleSheet::escape(message.from()->account()->accountId() ).replace('"',"""));
993
971
// Replace sender (contact nick)
994
resultHTML = resultHTML.replace( QString::fromUtf8("%sender%"), nick );
972
resultHTML = resultHTML.replace( QString::fromUtf8("%sender%"), nickLink+nick+"</a>" );
995
973
// Replace time, by default display only time and display seconds(that was true means).
996
974
resultHTML = resultHTML.replace( QString::fromUtf8("%time%"), KGlobal::locale()->formatTime(message.timestamp().time(), true) );
997
975
// Replace %screenName% (contact ID)
998
resultHTML = resultHTML.replace( QString::fromUtf8("%senderScreenName%"), contactId );
976
resultHTML = resultHTML.replace( QString::fromUtf8("%senderScreenName%"), nickLink+QStyleSheet::escape(contactId)+"</a>" );
999
977
// Replace service name (protocol name)
1000
resultHTML = resultHTML.replace( QString::fromUtf8("%service%"), service );
978
resultHTML = resultHTML.replace( QString::fromUtf8("%service%"), QStyleSheet::escape(service) );
1001
979
// Replace protocolIcon (sender statusIcon)
1002
resultHTML = resultHTML.replace( QString::fromUtf8("%senderStatusIcon%"), protocolIcon );
980
resultHTML = resultHTML.replace( QString::fromUtf8("%senderStatusIcon%"), QStyleSheet::escape(protocolIcon).replace('"',""") );
1004
982
// Look for %time{X}%
1005
983
QRegExp timeRegExp("%time\\{([^}]*)\\}%");
1063
1041
kdDebug(14000) << k_funcinfo << "Map Action message to Status template. " << endl;
1065
QString boldNick = QString::fromUtf8("<b>%1</b> ").arg(nick);
1066
// Don't set the body twice.
1067
if( !message.parsedBody().contains(boldNick) )
1069
QString newBody = boldNick + message.parsedBody();
1070
message.setBody(newBody, Kopete::Message::ParsedHTML );
1043
QString boldNick = QString::fromUtf8("%1<b>%2</b></a> ").arg(nickLink,nick);
1044
QString newBody = boldNick + message.parsedBody();
1045
message.setBody(newBody, Kopete::Message::ParsedHTML );
1074
1048
// Set message direction("rtl"(Right-To-Left) or "ltr"(Left-to-right))