------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. http://bugs.kde.org/show_bug.cgi?id=127016 ogoffart kde org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |FIXED ------- Additional Comments From ogoffart kde org 2006-06-21 00:19 ------- SVN commit 553398 by ogoffart: Remove the addNickLinks function, it was completelly wrong and bugged (i don't want to insult his author of course) add the link at the source instead. BUG: 127780 BUG: 127016 M +22 -48 chatmessagepart.cpp M +1 -3 chatmessagepart.h --- branches/kopete/0.12/kopete/kopete/chatwindow/chatmessagepart.cpp #553397:553398 @ -34,6 +34,7 @ #include <qregexp.h> #include <qvaluelist.h> #include <qtimer.h> +#include <qstylesheet.h> // KHTML::DOM includes #include <dom/dom_doc.h> @ -547,40 +548,6 @ #endif } -const QString ChatMessagePart::addNickLinks( const QString &html ) const -{ - QString retVal = html; - - Kopete::ContactPtrList members = d->manager->members(); - for ( QPtrListIterator<Kopete::Contact> it( members ); it.current(); ++it ) - { - QString nick = (*it)->property( Kopete::Global::Properties::self()->nickName().key() ).value().toString(); - //FIXME: this is really slow in channels with lots of contacts - QString parsed_nick = Kopete::Emoticons::parseEmoticons( nick ); - - if ( nick != parsed_nick ) - { - retVal.replace( QRegExp( QString::fromLatin1("([\\s&;>])%1([\\s&;<:])") - .arg( QRegExp::escape( parsed_nick ) ) ), QString::fromLatin1("\\1%1\\2").arg( nick ) ); - } - if ( nick.length() > 0 && ( retVal.find( nick ) > -1 ) && d->manager->protocol() ) - { - retVal.replace( - QRegExp( QString::fromLatin1("([\\s&;>])(%1)([\\s&;<:])") - .arg( QRegExp::escape( nick ) ) ), - QString::fromLatin1("\\1<a href=\"kopetemessage://%1/?protocolId=%2&accountId=%3\" class=\"KopeteDisplayName\">\\2</a>\\3") - .arg( (*it)->contactId(), d->manager->protocol()->pluginId(), d->manager->account()->accountId() ) - ); - } - } -#if 0 //disabled because it causes crash on exit - Olivier 2006-03-31 - QString nick = d->manager->myself()->property( Kopete::Global::Properties::self()->nickName().key() ).value().toString(); - retVal.replace( QRegExp( QString::fromLatin1("([\\s&;>])%1([\\s&;<:])") - .arg( QRegExp::escape( Kopete::Emoticons::parseEmoticons( nick ) ) ) ), QString::fromLatin1("\\1%1\\2").arg( nick ) ); -#endif - return retVal; -} - void ChatMessagePart::slotRefreshView() { DOM::HTMLElement kopeteNode = document().getElementById( QString::fromUtf8("KopeteStyle") ); @ -954,10 +921,11 @ } // Style formatting for messages(incoming, outgoing, status) -QString ChatMessagePart::formatStyleKeywords( const QString &sourceHTML, Kopete::Message &message ) +QString ChatMessagePart::formatStyleKeywords( const QString &sourceHTML, const Kopete::Message &_message ) { + Kopete::Message message=_message; //we will eventually need to modify it before showing it. QString resultHTML = sourceHTML; - QString nick, contactId, service, protocolIcon; + QString nick, contactId, service, protocolIcon, nickLink; if( message.from() ) { @ -988,18 +956,28 @ } protocolIcon = KGlobal::iconLoader()->iconPath( iconName, KIcon::Small ); + + nickLink=QString::fromLatin1("<a href=\"kopetemessage://%1/?protocolId=%2&accountId=%3\" class=\"KopeteDisplayName\">") + .arg( QStyleSheet::escape(message.from()->contactId()).replace('"',"""), + QStyleSheet::escape(message.from()->protocol()->pluginId()).replace('"',"""), + QStyleSheet::escape(message.from()->account()->accountId() ).replace('"',""")); } + else + { + nickLink="<a>"; + } + // Replace sender (contact nick) - resultHTML = resultHTML.replace( QString::fromUtf8("%sender%"), nick ); + resultHTML = resultHTML.replace( QString::fromUtf8("%sender%"), nickLink+nick+"</a>" ); // Replace time, by default display only time and display seconds(that was true means). resultHTML = resultHTML.replace( QString::fromUtf8("%time%"), KGlobal::locale()->formatTime(message.timestamp().time(), true) ); // Replace %screenName% (contact ID) - resultHTML = resultHTML.replace( QString::fromUtf8("%senderScreenName%"), contactId ); + resultHTML = resultHTML.replace( QString::fromUtf8("%senderScreenName%"), nickLink+QStyleSheet::escape(contactId)+"</a>" ); // Replace service name (protocol name) - resultHTML = resultHTML.replace( QString::fromUtf8("%service%"), service ); + resultHTML = resultHTML.replace( QString::fromUtf8("%service%"), QStyleSheet::escape(service) ); // Replace protocolIcon (sender statusIcon) - resultHTML = resultHTML.replace( QString::fromUtf8("%senderStatusIcon%"), protocolIcon ); + resultHTML = resultHTML.replace( QString::fromUtf8("%senderStatusIcon%"), QStyleSheet::escape(protocolIcon).replace('"',""") ); // Look for %time{X}% QRegExp timeRegExp("%time\\{([^}]*)\\}%"); @ -1062,13 +1040,9 @ { kdDebug(14000) << k_funcinfo << "Map Action message to Status template. " << endl; - QString boldNick = QString::fromUtf8("<b>%1</b> ").arg(nick); - // Don't set the body twice. - if( !message.parsedBody().contains(boldNick) ) - { - QString newBody = boldNick + message.parsedBody(); - message.setBody(newBody, Kopete::Message::ParsedHTML ); - } + QString boldNick = QString::fromUtf8("%1<b>%2</b></a> ").arg(nickLink,nick); + QString newBody = boldNick + message.parsedBody(); + message.setBody(newBody, Kopete::Message::ParsedHTML ); } // Set message direction("rtl"(Right-To-Left) or "ltr"(Left-to-right)) @ -1109,7 +1083,7 @ resultHTML = resultHTML.replace( QString::fromUtf8("%message%"), formatMessageBody(message) ); // TODO: %status - resultHTML = addNickLinks( resultHTML ); +// resultHTML = addNickLinks( resultHTML ); return resultHTML; } --- branches/kopete/0.12/kopete/kopete/chatwindow/chatmessagepart.h #553397:553398 @ -171,8 +171,6 @ const QString styleHTML() const; - const QString addNickLinks( const QString &html ) const; - Kopete::Contact *contactFromNode( const DOM::Node &n ) const; /** @ -194,7 +192,7 @ * * return the resulting HTML with replaced keywords. */ - QString formatStyleKeywords( const QString &sourceHTML, Kopete::Message &message ); + QString formatStyleKeywords( const QString &sourceHTML, const Kopete::Message &message ); /** * Format(replace) style keywords for header and footers. * For messages, use formatStyleKeywords(const QString &sourceHTML, Kopete::Message &message) instead. _______________________________________________ kopete-devel mailing list kopete-devel@kde.org https://mail.kde.org/mailman/listinfo/kopete-devel