diff options
Diffstat (limited to 'kopete/libkopete/kopetemessage.cpp')
-rw-r--r-- | kopete/libkopete/kopetemessage.cpp | 104 |
1 files changed, 52 insertions, 52 deletions
diff --git a/kopete/libkopete/kopetemessage.cpp b/kopete/libkopete/kopetemessage.cpp index 0dfedd69..566091e4 100644 --- a/kopete/libkopete/kopetemessage.cpp +++ b/kopete/libkopete/kopetemessage.cpp @@ -21,9 +21,9 @@ #include <tqcolor.h> #include <tqbuffer.h> #include <tqimage.h> -#include <tqstylesheet.h> +#include <stylesheet.h> #include <tqregexp.h> -#include <tqtextcodec.h> +#include <textcodec.h> #include <kdebug.h> #include <klocale.h> #include <kiconloader.h> @@ -83,14 +83,14 @@ Message::Private::Private( const TQDateTime &timeStamp, const Contact *from, } Message::Message() -: d( new Private( TQDateTime::tqcurrentDateTime(), 0L, TQPtrList<Contact>(), TQString(), Internal, +: d( new Private( TQDateTime::currentDateTime(), 0L, TQPtrList<Contact>(), TQString(), Internal, TQString(), TypeNormal ) ) { } Message::Message( const Contact *fromKC, const TQPtrList<Contact> &toKC, const TQString &body, MessageDirection direction, MessageFormat f, const TQString &requestedPlugin, MessageType type ) -: d( new Private( TQDateTime::tqcurrentDateTime(), fromKC, toKC, TQString(), direction, requestedPlugin, type ) ) +: d( new Private( TQDateTime::currentDateTime(), fromKC, toKC, TQString(), direction, requestedPlugin, type ) ) { doSetBody( body, f ); } @@ -100,13 +100,13 @@ Message::Message( const Contact *fromKC, const Contact *toKC, const TQString &bo { TQPtrList<Contact> to; to.append(toKC); - d = new Private( TQDateTime::tqcurrentDateTime(), fromKC, to, TQString(), direction, requestedPlugin, type ); + d = new Private( TQDateTime::currentDateTime(), fromKC, to, TQString(), direction, requestedPlugin, type ); doSetBody( body, f ); } Message::Message( const Contact *fromKC, const TQPtrList<Contact> &toKC, const TQString &body, const TQString &subject, MessageDirection direction, MessageFormat f, const TQString &requestedPlugin, MessageType type ) - : d( new Private( TQDateTime::tqcurrentDateTime(), fromKC, toKC, subject, direction, requestedPlugin, type ) ) + : d( new Private( TQDateTime::currentDateTime(), fromKC, toKC, subject, direction, requestedPlugin, type ) ) { doSetBody( body, f ); } @@ -199,20 +199,20 @@ void Message::doSetBody( const TQString &_body, Message::MessageFormat f ) { //This is coming from the RichTextEditor component. //Strip off the containing HTML document - body.replace( TQRegExp( TQString::tqfromLatin1(".*<body[^>]*>(.*)</body>.*") ), TQString::tqfromLatin1("\\1") ); + body.replace( TQRegExp( TQString::fromLatin1(".*<body[^>]*>(.*)</body>.*") ), TQString::fromLatin1("\\1") ); //Strip <p> tags - body.replace( TQString::tqfromLatin1("<p>"), TQString() ); + body.replace( TQString::fromLatin1("<p>"), TQString() ); //Replace </p> with a <br/> - body.replace( TQString::tqfromLatin1("</p>"), TQString::tqfromLatin1("<br/>") ); + body.replace( TQString::fromLatin1("</p>"), TQString::fromLatin1("<br/>") ); //Remove trailing </br> - if ( body.endsWith( TQString::tqfromLatin1("<br/>") ) ) + if ( body.endsWith( TQString::fromLatin1("<br/>") ) ) body.truncate( body.length() - 5 ); - body.remove( TQString::tqfromLatin1("\n") ); - body.replace( TQRegExp( TQString::tqfromLatin1( "\\s\\s" ) ), TQString::tqfromLatin1( " " ) ); + body.remove( TQString::fromLatin1("\n") ); + body.replace( TQRegExp( TQString::fromLatin1( "\\s\\s" ) ), TQString::fromLatin1( " " ) ); } /* else if( f == ParsedHTML ) @@ -266,10 +266,10 @@ TQString Message::unescape( const TQString &xml ) TQString match = data.mid( pos + 1, matchWidth - 2 ).simplifyWhiteSpace(); int elemEndPos = match.find( ' ' ); TQString elem = ( elemEndPos == -1 ? match.lower() : match.left( elemEndPos ).lower() ); - if ( elem == TQString::tqfromLatin1( "img" ) ) + if ( elem == TQString::fromLatin1( "img" ) ) { // Replace smileys with their original text' - const TQString attrTitle = TQString::tqfromLatin1( "title=\"" ); + const TQString attrTitle = TQString::fromLatin1( "title=\"" ); int titlePos = match.find( attrTitle, elemEndPos ); int titleEndPos = match.find( '"', titlePos + attrTitle.length() ); if( titlePos == -1 || titleEndPos == -1 ) @@ -286,8 +286,8 @@ TQString Message::unescape( const TQString &xml ) pos += orig.length(); } } - else if ( elem == TQString::tqfromLatin1( "/p" ) || elem == TQString::tqfromLatin1( "/div" ) || - elem == TQString::tqfromLatin1( "br" ) ) + else if ( elem == TQString::fromLatin1( "/p" ) || elem == TQString::fromLatin1( "/div" ) || + elem == TQString::fromLatin1( "br" ) ) { // Replace paragraph, div and line breaks with a newline data.replace( pos, matchWidth, '\n' ); @@ -302,12 +302,12 @@ TQString Message::unescape( const TQString &xml ) } // Replace stuff starting with '&' - data.replace( TQString::tqfromLatin1( ">" ), TQString::tqfromLatin1( ">" ) ); - data.replace( TQString::tqfromLatin1( "<" ), TQString::tqfromLatin1( "<" ) ); - data.replace( TQString::tqfromLatin1( """ ), TQString::tqfromLatin1( "\"" ) ); - data.replace( TQString::tqfromLatin1( " " ), TQString::tqfromLatin1( " " ) ); - data.replace( TQString::tqfromLatin1( "&" ), TQString::tqfromLatin1( "&" ) ); - data.replace( TQString::tqfromLatin1( " " ), TQString::tqfromLatin1( " " ) ); //this one is used in jabber: note, we should escape all &#xx; + data.replace( TQString::fromLatin1( ">" ), TQString::fromLatin1( ">" ) ); + data.replace( TQString::fromLatin1( "<" ), TQString::fromLatin1( "<" ) ); + data.replace( TQString::fromLatin1( """ ), TQString::fromLatin1( "\"" ) ); + data.replace( TQString::fromLatin1( " " ), TQString::fromLatin1( " " ) ); + data.replace( TQString::fromLatin1( "&" ), TQString::fromLatin1( "&" ) ); + data.replace( TQString::fromLatin1( " " ), TQString::fromLatin1( " " ) ); //this one is used in jabber: note, we should escape all &#xx; return data; } @@ -316,13 +316,13 @@ TQString Message::escape( const TQString &text ) { TQString html = TQStyleSheet::escape( text ); //Replace carriage returns inside the text - html.replace( TQString::tqfromLatin1( "\n" ), TQString::tqfromLatin1( "<br />" ) ); + html.replace( TQString::fromLatin1( "\n" ), TQString::fromLatin1( "<br />" ) ); //Replace a tab with 4 spaces - html.replace( TQString::tqfromLatin1( "\t" ), TQString::tqfromLatin1( " " ) ); + html.replace( TQString::fromLatin1( "\t" ), TQString::fromLatin1( " " ) ); //Replace multiple spaces with //do not replace every space so we break the linebreak - html.replace( TQRegExp( TQString::tqfromLatin1( "\\s\\s" ) ), TQString::tqfromLatin1( " " ) ); + html.replace( TQRegExp( TQString::fromLatin1( "\\s\\s" ) ), TQString::fromLatin1( " " ) ); return html; } @@ -373,11 +373,11 @@ TQString Message::parsedBody() const static TQString makeRegExp( const char *pattern ) { - const TQString urlChar = TQString::tqfromLatin1( "\\+\\-\\w\\./#@&;:=\\?~%_,\\!\\$\\*\\(\\)" ); - const TQString boundaryStart = TQString::tqfromLatin1( "(^|[^%1])(" ).tqarg( urlChar ); - const TQString boundaryEnd = TQString::tqfromLatin1( ")([^%1]|$)" ).tqarg( urlChar ); + const TQString urlChar = TQString::fromLatin1( "\\+\\-\\w\\./#@&;:=\\?~%_,\\!\\$\\*\\(\\)" ); + const TQString boundaryStart = TQString::fromLatin1( "(^|[^%1])(" ).arg( urlChar ); + const TQString boundaryEnd = TQString::fromLatin1( ")([^%1]|$)" ).arg( urlChar ); - return boundaryStart + TQString::tqfromLatin1(pattern) + boundaryEnd; + return boundaryStart + TQString::fromLatin1(pattern) + boundaryEnd; } TQString Message::parseLinks( const TQString &message, MessageFormat format ) @@ -411,38 +411,38 @@ TQString Message::parseLinks( const TQString &message, MessageFormat format ) TQString body = curr.mid( tagclose + 1 ); *it = tag + parseLinks( body, PlainText ); } - return entries.join(TQString::tqfromLatin1("<")); + return entries.join(TQString::fromLatin1("<")); } TQString result = message; // common subpatterns - may not contain matching parens! - const TQString name = TQString::tqfromLatin1( "[\\w\\+\\-=_\\.]+" ); - const TQString userAndPassword = TQString::tqfromLatin1( "(?:%1(?::%1)?\\@)" ).tqarg( name ); - const TQString urlChar = TQString::tqfromLatin1( "\\+\\-\\w\\./#@&;:=\\?~%_,\\!\\$\\*\\(\\)" ); - const TQString urlSection = TQString::tqfromLatin1( "[%1]+" ).tqarg( urlChar ); - const TQString domain = TQString::tqfromLatin1( "[\\-\\w_]+(?:\\.[\\-\\w_]+)+" ); + const TQString name = TQString::fromLatin1( "[\\w\\+\\-=_\\.]+" ); + const TQString userAndPassword = TQString::fromLatin1( "(?:%1(?::%1)?\\@)" ).arg( name ); + const TQString urlChar = TQString::fromLatin1( "\\+\\-\\w\\./#@&;:=\\?~%_,\\!\\$\\*\\(\\)" ); + const TQString urlSection = TQString::fromLatin1( "[%1]+" ).arg( urlChar ); + const TQString domain = TQString::fromLatin1( "[\\-\\w_]+(?:\\.[\\-\\w_]+)+" ); //Replace http/https/ftp links: // Replace (stuff)://[user:password@](linkstuff) with a link result.replace( - TQRegExp( makeRegExp("\\w+://%1?\\w%2").tqarg( userAndPassword, urlSection ) ), - TQString::tqfromLatin1("\\1<a href=\"\\2\" title=\"\\2\">\\2</a>\\3" ) ); + TQRegExp( makeRegExp("\\w+://%1?\\w%2").arg( userAndPassword, urlSection ) ), + TQString::fromLatin1("\\1<a href=\"\\2\" title=\"\\2\">\\2</a>\\3" ) ); // Replace www.X.Y(linkstuff) with a http: link result.replace( - TQRegExp( makeRegExp("%1?www\\.%2%3").tqarg( userAndPassword, domain, urlSection ) ), - TQString::tqfromLatin1("\\1<a href=\"http://\\2\" title=\"http://\\2\">\\2</a>\\3" ) ); + TQRegExp( makeRegExp("%1?www\\.%2%3").arg( userAndPassword, domain, urlSection ) ), + TQString::fromLatin1("\\1<a href=\"http://\\2\" title=\"http://\\2\">\\2</a>\\3" ) ); //Replace Email Links // Replace user@domain with a mailto: link result.replace( - TQRegExp( makeRegExp("%1@%2").tqarg( name, domain ) ), - TQString::tqfromLatin1("\\1<a href=\"mailto:\\2\" title=\"mailto:\\2\">\\2</a>\\3") ); + TQRegExp( makeRegExp("%1@%2").arg( name, domain ) ), + TQString::fromLatin1("\\1<a href=\"mailto:\\2\" title=\"mailto:\\2\">\\2</a>\\3") ); //Workaround for Bug 85061: Highlighted URLs adds a ' ' after the URL itself // the trailing is included in the url. - result.replace( TQRegExp( TQString::tqfromLatin1("(<a href=\"[^\"]+)( )(\")") ) , TQString::tqfromLatin1("\\1\\3") ); + result.replace( TQRegExp( TQString::fromLatin1("(<a href=\"[^\"]+)( )(\")") ) , TQString::fromLatin1("\\1\\3") ); return result; } @@ -486,8 +486,8 @@ TQColor Message::bg() const TQFont Message::font() const { - //TQDomElement bodyNode = d->xmlDoc.elementsByTagName( TQString::tqfromLatin1("body") ).item(0).toElement(); - //return TQFont( bodyNode.attribute( TQString::tqfromLatin1("font") ), bodyNode.attribute( TQString::tqfromLatin1("fontsize") ).toInt() ); + //TQDomElement bodyNode = d->xmlDoc.elementsByTagName( TQString::fromLatin1("body") ).item(0).toElement(); + //return TQFont( bodyNode.attribute( TQString::fromLatin1("font") ), bodyNode.attribute( TQString::fromLatin1("fontsize") ).toInt() ); return d->font; } @@ -531,11 +531,11 @@ TQString Message::getHtmlStyleAttribute() const // Affect foreground(color) and background color to message. if( !d->fgOverride && d->fgColor.isValid() ) { - styleAttribute += TQString::fromUtf8("color: %1; ").tqarg(d->fgColor.name()); + styleAttribute += TQString::fromUtf8("color: %1; ").arg(d->fgColor.name()); } if( !d->bgOverride && d->bgColor.isValid() ) { - styleAttribute += TQString::fromUtf8("background-color: %1; ").tqarg(d->bgColor.name()); + styleAttribute += TQString::fromUtf8("background-color: %1; ").arg(d->bgColor.name()); } // Affect font parameters. @@ -543,15 +543,15 @@ TQString Message::getHtmlStyleAttribute() const { TQString fontstr; if(!d->font.family().isNull()) - fontstr+=TQString::tqfromLatin1("font-family: ")+d->font.family()+TQString::tqfromLatin1("; "); + fontstr+=TQString::fromLatin1("font-family: ")+d->font.family()+TQString::fromLatin1("; "); if(d->font.italic()) - fontstr+=TQString::tqfromLatin1("font-style: italic; "); + fontstr+=TQString::fromLatin1("font-style: italic; "); if(d->font.strikeOut()) - fontstr+=TQString::tqfromLatin1("text-decoration: line-through; "); + fontstr+=TQString::fromLatin1("text-decoration: line-through; "); if(d->font.underline()) - fontstr+=TQString::tqfromLatin1("text-decoration: underline; "); + fontstr+=TQString::fromLatin1("text-decoration: underline; "); if(d->font.bold()) - fontstr+=TQString::tqfromLatin1("font-weight: bold;"); + fontstr+=TQString::fromLatin1("font-weight: bold;"); styleAttribute += fontstr; } @@ -629,7 +629,7 @@ TQString Message::decodeString( const TQCString &message, const TQTextCodec *pro kdDebug(14000) << k_funcinfo << "Using latin1 and cleaning string" << endl; //No codec decoded. Just decode latin1, and clean out any junk. - TQString result = TQString::tqfromLatin1( message ); + TQString result = TQString::fromLatin1( message ); const uint length = message.length(); for( uint i = 0; i < length; ++i ) { |