[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdenetwork/kopete/protocols/oscar
From: Roman Jarosz <kedgedev () centrum ! cz>
Date: 2008-12-07 11:18:35
Message-ID: 1228648715.624697.24005.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 893722 by rjarosz:
Fix bug 175532 Outgoing AIM messages have HTML line break prepended.
BUG: 175532
M +14 -6 aimcontactbase.cpp
M +1 -1 aimcontactbase.h
--- trunk/KDE/kdenetwork/kopete/protocols/oscar/aimcontactbase.cpp #893721:893722
@@ -112,8 +112,14 @@
QTextCharFormat defaultCharFormat;
for ( QTextBlock it = doc.begin(); it != doc.end(); it = it.next() )
{
- s += brMargin( it.blockFormat().topMargin(), defaultCharFormat.fontPointSize() );
+ QTextBlockFormat blockFormat = it.blockFormat();
+ // Plain text message has p tags without margin attributes and Qt's topMargin()
+ // returns default margins so we will end up with line break before text.
+ if ( message.format() != Qt::PlainText || it.blockNumber() != 0 )
+ s += brMargin( blockFormat.topMargin(), defaultCharFormat.fontPointSize() );
+
+ bool lastFragmentHasLineSeparator = false;
for ( QTextBlock::iterator it2 = it.begin(); !(it2.atEnd()); ++it2 )
{
QTextFragment currentFragment = it2.fragment();
@@ -151,12 +157,14 @@
s += ( format.hasProperty(QTextFormat::FontItalic) ) ? "<I>" : "</I>";
if ( format.fontUnderline() != defaultCharFormat.fontUnderline() )
s += ( format.hasProperty(QTextFormat::FontUnderline) ) ? "<U>" : "</U>";
-
- s += Qt::escape(currentFragment.text());
+
+ QString text = currentFragment.text();
+ lastFragmentHasLineSeparator = text.endsWith( QChar::LineSeparator );
+ s += Qt::escape( text );
defaultCharFormat = format;
}
}
- s += brMargin( it.blockFormat().bottomMargin(), defaultCharFormat.fontPointSize(), \
true ); + s += brMargin( blockFormat.bottomMargin(), \
defaultCharFormat.fontPointSize(), !lastFragmentHasLineSeparator ); }
s.replace( QChar::LineSeparator, "<BR>" );
@@ -265,13 +273,13 @@
return 7;
}
-QString AIMContactBase::brMargin( int margin, int fontPointSize, bool endBlock ) \
const +QString AIMContactBase::brMargin( int margin, int fontPointSize, bool forceBr \
) const {
int brHeight = ( fontPointSize == 0 ) ? 12 : fontPointSize;
int brCount = margin / brHeight;
if ( brCount <= 0 )
- return ( endBlock ) ? "<BR>" : "";
+ return ( forceBr ) ? "<BR>" : "";
QString s;
while ( brCount-- > 0 )
--- trunk/KDE/kdenetwork/kopete/protocols/oscar/aimcontactbase.h #893721:893722
@@ -53,7 +53,7 @@
private:
int aimFontSize( int size ) const;
- QString brMargin( int margin, int fontPointSize, bool endBlock = false ) const;
+ QString brMargin( int margin, int fontPointSize, bool forceBr = false ) const;
QDateTime m_lastAutoresponseTime;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic