[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kopete-devel
Subject:    Re: [kopete-devel] my first bugfix :)
From:       Olivier Goffart <ogoffart () kde ! org>
Date:       2005-06-03 7:17:50
Message-ID: 200506030917.54343.ogoffart () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


Le Jeudi 2 Juin 2005 10:27, Chani a écrit  :
> err... I fixed a minor bug with emoticons. they were showing up nearly
> everywhere except people's names in chatwindows, and it really bugs me...
> as far as I can tell, the code that was supposed to add them was actually
> removing them.
> things were even weirder in status messages when someone changed their
> name- sometimes they would show up and sometimes they wouldn't.
> I think I've fixed both those problems, although I'm not quite certain
> about the status messages. they might just be pretending to be fixed... :)
> changing the style was also making strange changes to which emoticons
> showed up, which might just be part of the same bug, becuse it's not
> happening right now either.
>
> anyways, I was told to send the output of svn diff to this mailing list..
> so... here it is...

well, the patch is quite difficult to read.
next time you send a patch, please actually attach it in a joined file,  
because kmail will add word wrap which make the patch difficult to read. 
In addition to that, it is impossible to apply the patch, or open it with 
kompare.

Also, it would be nice if the name of functions were added, like it was with 
cvs diff.    i do'nt know exactly how to do.
svn  diff -x "-pu" --diff-cmd `which diff` 
works, but is a quite long command,  maybe someone else know, i'm interested 
because patch with -p are easier to read.


About the patch i don't know if it's correct.

The Philosiphy of the (old) function you modify is the following (IIRC)
1) Nicks were showed without emoticons in the chat window, so remove the 
emoticons in nicks that are inside the message.
2) Add a link so that a popup menu may be shown when someone write someone's 
nick.

IMO, this function is broken because
1) nick emoticons now appears now in the chat window
2) i don't see the interest off adding nick links, specially because it is 
very slow in a IRC channel.

you tried to repair 1# ,  but in fact you broke the whole function

I have done fast two untested patch.
correct.diff  remove the behavior #1 , but let the behavior #2 untouched.
dream.diff  remove completely addNickLinks

personally, i would, if other agree,  commit dream.diff :-)

["correct.diff" (text/x-diff)]

Index: chatmessagepart.cpp
===================================================================
--- chatmessagepart.cpp	(revision 421268)
+++ chatmessagepart.cpp	(working copy)
@@ -400,25 +400,16 @@ const QString ChatMessagePart::addNickLi
 		//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 ) )
+		if ( nick.length() > 0 && ( retVal.find( parsed_nick ) > -1 ) )
 		{
 			retVal.replace(
 				QRegExp( QString::fromLatin1("([\\s&;>])(%1)([\\s&;<:])")
-					.arg( QRegExp::escape( nick ) )  ),
+					.arg( QRegExp::escape( parsed_nick ) )  ),
 			QString::fromLatin1("\\1<a \
href=\"kopetemessage://%1/?protocolId=%2&accountId=%3\" \
                class=\"KopeteDisplayName\">\\2</a>\\3")
 				.arg( (*it)->contactId(), m_manager->protocol()->pluginId(), \
m_manager->account()->accountId() )  );
 		}
 	}
-	QString nick = m_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 ) );
-
 	return retVal;
 }
 


["dream.diff" (text/x-diff)]

Index: chatmessagepart.cpp
===================================================================
--- chatmessagepart.cpp	(revision 421268)
+++ chatmessagepart.cpp	(working copy)
@@ -369,7 +369,7 @@ void ChatMessagePart::appendMessage( Kop
 	{
 		QDomDocument domMessage = message.asXML();
 		domMessage.documentElement().setAttribute( QString::fromLatin1( "id" ), \
                QString::number( messageId ) );
-		QString resultHTML = addNickLinks( d->xsltParser->transform( domMessage.toString() \
) ); +		QString resultHTML = d->xsltParser->transform( domMessage.toString() ) ;
 
 		QString direction = ( message.plainBody().isRightToLeft() ? \
QString::fromLatin1("rtl") : QString::fromLatin1("ltr") );  DOM::HTMLElement newNode \
= document().createElement( QString::fromLatin1("span") ); @@ -389,38 +389,6 @@ void \
ChatMessagePart::appendMessage( Kop  }
 }
 
-const QString ChatMessagePart::addNickLinks( const QString &html ) const
-{
-	QString retVal = html;
-
-	Kopete::ContactPtrList members = m_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 ) )
-		{
-			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(), m_manager->protocol()->pluginId(), \
                m_manager->account()->accountId() )
-			);
-		}
-	}
-	QString nick = m_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 ) );
-
-	return retVal;
-}
 
 void ChatMessagePart::slotRefreshNodes()
 {
@@ -448,7 +416,7 @@ void ChatMessagePart::slotRefreshView()
 
 void ChatMessagePart::slotTransformComplete( const QVariant &result )
 {
-	htmlDocument().body().setInnerHTML( addNickLinks( result.toString() ) );
+	htmlDocument().body().setInnerHTML( result.toString() );
 
 	if ( !scrollPressed )
 		QTimer::singleShot( 1, this, SLOT( slotScrollView() ) );
Index: chatmessagepart.h
===================================================================
--- chatmessagepart.h	(revision 421268)
+++ chatmessagepart.h	(working copy)
@@ -165,8 +165,6 @@ private:
 
 	const QString styleHTML() const;
 
-	const QString addNickLinks( const QString &html ) const;
-
 	Kopete::Contact *contactFromNode( const DOM::Node &n ) const;
 
 	/**


[Attachment #9 (application/pgp-signature)]

_______________________________________________
kopete-devel mailing list
kopete-devel@kde.org
https://mail.kde.org/mailman/listinfo/kopete-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic