[Kde-pim] Newlines in QTextDocument

Ahm ed zrchrn at gmail.com
Tue Feb 24 06:46:41 GMT 2009


Hey, this is Ahmed Ghonim. I have been working a little on fixing bug
#180207

What I have basically done is I created a sperate Qt application with a
QTextEdit and a WebView. This application allows me to export files to html,
and the reload them (if anyone's interested in this app let me know, but
it's really quite trivial). This way I can focus on a solution for this
problem, while not having to deal with the extra layer of complexity
involved with programming kjots itself (esp. since I am new to kjots api).
Once I found a "solution" I ported it to kjots to make sure it worked. I
check this for bullet support, as well as spacing. It's in the latter that
issues arise.

I got the idea for this from the kjots in kde 3.5. (While testing Debian
Lenny). But there are some differences.
The patch for kjots is attached and it's against the latest svn as of 4pm
New York time. But it's not a "final" way of doing this. Personally I think
it can be improved a lot. For this patch to work I would need to do checks
to make sure it doesn't insert a <br/> every time that enter is pressed
(which is essentially what this does now). 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/>.

The other issue is, once a document is exported to html, the actual editor
becomes double spaced as well. I'm puzzled about that.

One other  method that I have considered is post-processing the html file.
So once the "qtiffied" html file is exported, another function is called
that checks the file for vaild html and fixes the known issues related to
QTextEdit. Or something to that effect. That class would also have the
reverse functions, so as a file is imported it re-converts the file back to
"qt-html", so <br/> is replaced with the evil <p.style....> line etc.

Ultimately I think it might be better to work directly with trolltech on
this one. Perhaps implement an exportToHtml() function for QTextEdit that
reformats to proper HTML. I am assuming they use these custom styles as it
is easier to manipulate.



Sorry if this is some what poorly worded, it's been a long day (good, but
long).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kjots-fixhtmlexport.patch
Type: text/x-diff
Size: 1960 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20090224/fdd60152/attachment.patch>
-------------- next part --------------
_______________________________________________
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