This patch mostly concerns itself with the following two things:
1. Move code out from kmreaderwin (see new class CSSHelper, whose files
have already been committed).
Into this category fall the simplification and readability
enhancements of the HTML code (adding some newlines, simplifying the
HTML in favour of complicating the CSS a bit, using @media print)
2. Change the semantics of the mCodec member of KMMessage and
KMReaderWin.
To make it short: mCodec is not mOverrideCodec and only ever set to a
non-NULL value iff the codec is forced by the user selecting an
encoding from the Message menu. In all other cases, it's now
calculated from the message(parts). For that, the codec() and
setBodyFromUnicode() and bodyToUnicode() methods have been duplicated
in KMMessage from KMMsgPart (don't you just hate that?).
Walkthrough of the patch:
kmreaderwin.{h,cpp}
- Replace all c* and m*Font members by a single CSSHelper instance.
- readColorConfig(), parts of readConfg(), quoteFontTag() and htmlHead()
were moved from here to CSSHelper
- rename codec()/setCodec() to overrideCodec()/setOverrideCodec()
and provide an autoDetectEncoding() convenience method.
- Remove the QTextCodec parameter from setMsgPart. It now uses
overrideCodec() or the msgPart's own codec.
- s/isfixedFont/isFixedFont/
- split parseMsg( KMMessage*, bool ) into one for
onlyProcessHeaders=false (called again parseMsg(KMMessage*)) and one
for oPH=true (called parseMsgHeader()). The latter then reduces to
writeMsgHeader(), provided one accepts the minor regression that the
[vPart] link is not shown _for *nested*_ messages. This can be readded
later, once KMReaderWin is void of formatting code and OTP is
independent of a KMReaderWin parent. I've left the commented
parseMsgHeader in the momnt of it's death in commented out, so you can
see what I how I came to kill it off for an explicit writeMsgHeader().
- In the old new parseMsg(KMMessage*), there also happened significant
code simplification, mostly by realizing that the the colorbar and tmp
file handling belongs into parseMsg(void) and by removing the oPH=true
case. There's also an instance of simplifying code by using
bodyToUnicode(). At last, the <div id="header"></div> around
writeMsgHeader is superfluous (and wrong, since there is and never was
a div#header CSS selector), since the HeaderStyle's add that already.
- Apply "Inline Method" to writeHTMLStr()
- remove the QTextCodec param from showVCard(). This method is now a
nice one and uses bodyToUnicode()
- rename all fooCodec to fooOverrideCodec
- currently, mCSSHelper is destroyed and re-created whenever it the
config changes. I intend to make CSSHelper a fully functional
ConfigManager later.
- setOverrideCodec now calls update(true) only if the codec was actually
changed.
- In setMsgPart, there's code that "forgets" to strip off <head>, <body>
and <html> tags from HTML parts. I didn't do anything about that yet,
only added a triple-hash.
- Simplify slotAtmSave() by using more guard clauses and esp. by using
QString::section() and QString::replace(QChar,QChar) instead of
rolling our owns.
objecttreeparser.{h,cpp}:
- Use CSShelper
- Create a new CSS class "htmlWarn" for the HTML warning frame to get
rid of the embedded style information.
- simplify quotedHTML() by using new nonQuotedFontTag().
headerstyle.cpp:
- We begin by inserting some newlines to ease the reading of the
resultant HTML code.
- In the fancy header department, we remove almost all class attributes
from the HTML tags. Instead (see csshelper.cpp), we use CSS Selectors
to address the inner tags of the enclosing <div class="fancy header">
Note how that tag matches both the div.header (setting the margin) and
div.fancy.header selectors in csshelper.cpp
- We end with removing the workaround for the apparently long-standing
khtml bug that makes it ignore "padding" on <table>, viz. another
<div></div> pair around the table.
kmfldsearch.cpp:
- Reap fruits of (2).
kmmainwin.cpp:
- Consequence of setCodec -> setOverrideCodec() renaming
- move an #include up to the top
kmmessage.{h,cpp}:
- Copy setBodyFromUnicode(), bodyToUnicode() and rename fooCodec to
fooOverrideCodec.
- Note how the double housekeeping (mAutoDetectEncoding) goes away with
this.
- In html2source(), don't emit <br />, but <br> (we're using HTML 4.01,
not XHTML) and quote ' with ' (well, that's more XHTML-like)
kmreadermainwin.{h,cpp}:
- Since the QTextCodec* parameter was removed from
KMReaderWin::setMsgPart(), use now the explicit setOverrideCodec()
method to set the user-defined codec.
- Remove unused mCodec member
svn path=/trunk/kdepim/; revision=236540
- use a string list to collect all header parts and the join them with ", "
for "brief" header mode.
- move the [vcard] link to after the from address.
svn path=/trunk/kdepim/; revision=201454