[Kde-pim] Newlines in QTextDocument

Stephen Kelly steveire at gmail.com
Tue Mar 3 14:58:04 GMT 2009


Thomas McGuire wrote:

> Hi Stephen,
> 
> On Monday 23 February 2009 18:03:38 Stephen Kelly wrote:
>> You may be aware that there are a few bugs regarding newlines in
>> QTextDocument.
>>
>> One is this:
>> https://bugs.kde.org/show_bug.cgi?id=180207
>>
>> (Can we have a list of the others. Even the closed ones. I want to have
>> one solution to this issue)
> 
> Ok, here the KMail list, after a bit of searching:
> 
> Extra line break after sending message:
> https://bugs.kde.org/show_bug.cgi?id=86925 (this one has many duplicates,
> and I think is solved by the hacky fix in r856835)
> 
> Less line breaks after sending message (opposite of the above, it seems):
> https://bugs.kde.org/show_bug.cgi?id=173877
> 
> When opening HTML draft, empty lines are tripled:
> https://bugs.kde.org/show_bug.cgi?id=180612
> 
> Not related to linebreaks, but to RTL in the composer:
> https://bugs.kde.org/show_bug.cgi?id=181311
> 
> Even more unrelated (happening in plain text version): Wordwrapping broken
> after opening a draft: https://bugs.kde.org/show_bug.cgi?id=105532

Thanks for that. I'll read through them soon. It might be that different MUAs 
will also be causing us headaches.

> Well, I'm sure we can at least add hacks to the newline problem, by
> producing nicer HTML and maybe by having a custom setHtml() method.
> For the whole richtextbuilders stuff, I still want to move some parts of
> KMeditor and KMComposerEdtior to a new textedit library in kdepimlibs,
> which would also use the richtextbuilder stuff. 

Well, we should make sure it works first and solves enough of these problems.

> Moving it to kdepimlibs is
> needed for getting support for inline images in HTML signatures. But I've
> not found the time to do so, yet.
> FWIW, I've also put this as part of a SoC project on the wiki, see
> 
http://techbase.kde.org/Projects/Summer_of_Code/2009/Ideas#Project:_Improvments_in_KMail.27s_HTML_support
> 
>> What we need is some tests with qtextedit to make sure that:
>> * HTML Documents survive round trips through QTextDocument with the same
>> number of newlines.
>> * Browsers also render the generated document correctly.
>> * Documents created in a QTextEdit also adhere to the above.
>> * Documents exported into QTextEdit (with its limited html support) can
>> be exported with the correct number of newlines.
>> * The exported html should be standard and well defined html. Note that
>> the patch I made to Qt does not make valid html according to ogoffart
>> (link below)
>>
>> I think this is mostly a html and css issue.
>>
>> Ahmed has done some investigation, so I hope he will post here too.
>>
>> Other interesting links:
>>
>> http://www.nabble.com/New-qt-patch.-Can-it-go-into-qt-copy--
td20368821.html
>> http://lists.trolltech.com/qt-interest/2008-11/thread00279-0.html
>>
>> At this point, I think the most valuable thing we can get is some test
>> cases and information on what 'valid html' is around newlines etc.
>> Unfortunately the closing </p> tag is optional, and I think that causes
>> headaches.
>>
>> I can do coding work on this, but I need answers to the above so I know
>> what to export. I can't do much of that sort of investigation work though
>> as I'm currently travelling.
> 
> For the tests, the KMail case would be:
> - Preserve linebreaks after saving from draft and opening that draft

That's pretty much the same as a roundtrip  from a document in the editor, 
to a file, back to the editor.

> - After composing the message, the linebreaks, as displayed by KHTML,
> should
>   be the same as they appeared in the composer.

I think at least partly this is a css issue. QTextDocument export adds some 
padding around newlines I think. Part of what needs to be investigated.

> 
> Regards,
> Thomas

Ahmed, I reviewed your patch, but as you wrote, the way it is now leads to
everything in the exported html being double spaced, due to every single
"\n" being replaced with a <br/>.

Unfortunately, that's not really a complete solution to this either. As you 
said, this issue should be handled by Qt, and Ron Goodhearts email is 
encouraging, but I haven't tried it out in Qt4.5 yet. It could solve many of 
these problems, so we can investigate with that.

All the best,

Steve.


_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/



More information about the kde-pim mailing list