diff --git a/kmail/headerstyle.cpp b/kmail/headerstyle.cpp index 7d0d6fc4..9e654d68 100644 --- a/kmail/headerstyle.cpp +++ b/kmail/headerstyle.cpp @@ -623,7 +623,7 @@ namespace KMail { int zone = origDate.Zone(); // kdDebug() << "FancyHeaderStyle::format() zone offset (in minutes): " << zone << endl; - // copyed fro mimelib -- code to determine local timezone + // copyed from mimelib -- code to determine local timezone time_t t_now = time((time_t*) 0); #if defined(HAVE_GMTIME_R) struct tm utc; @@ -642,7 +642,6 @@ namespace KMail { t_utc = 24 * t_utc + utc.tm_hour; t_utc = 60 * t_utc + utc.tm_min; t_utc = 60 * t_utc + utc.tm_sec; - int lzone = (int) (t_local - t_utc) / 60; // kdDebug() << "FancyHeaderStyle::format() local zone offset (in minutes): " << lzone << endl; @@ -705,7 +704,7 @@ namespace KMail { // kdDebug() << "FancyHeaderStyle::format() current time: " << currTime << " (" << timeofday << ")" << endl; timeHTML.append( TQString( - "
%4
%5
%6
" ) diff --git a/kmail/kmreaderwin.cpp b/kmail/kmreaderwin.cpp index 7d370f5e..3aadb963 100644 --- a/kmail/kmreaderwin.cpp +++ b/kmail/kmreaderwin.cpp @@ -4,7 +4,7 @@ // define this to copy all html that is written to the readerwindow to // filehtmlwriter.out in the current working directory -//#define KMAIL_READER_HTML_DEBUG 1 +// #define KMAIL_READER_HTML_DEBUG 1 #include @@ -415,6 +415,7 @@ KMReaderWin::KMReaderWin(TQWidget *aParent, mUpdateReaderWinTimer( 0, "mUpdateReaderWinTimer" ), mResizeTimer( 0, "mResizeTimer" ), mDelayedMarkTimer( 0, "mDelayedMarkTimer" ), + mHeaderRefreshTimer( 0, "mHeaderRefreshTimer" ), mOldGlobalOverrideEncoding( "---" ), // init with dummy value mCSSHelper( 0 ), mRootNode( 0 ), @@ -472,6 +473,8 @@ KMReaderWin::KMReaderWin(TQWidget *aParent, TQT_TQOBJECT(this), TQT_SLOT(slotDelayedResize()) ); connect( &mDelayedMarkTimer, TQT_SIGNAL(timeout()), TQT_TQOBJECT(this), TQT_SLOT(slotTouchMessage()) ); + connect( &mHeaderRefreshTimer, TQT_SIGNAL(timeout()), + TQT_TQOBJECT(this), TQT_SLOT(updateHeader()) ); } @@ -1174,8 +1177,6 @@ void KMReaderWin::setMsg( KMMessage* aMsg, bool force, bool updateOnly ) aMsg->attach( this ); mAtmUpdate = false; - // connect to the updates if we have hancy headers - mDelayedMarkTimer.stop(); mMessage = 0; @@ -1227,6 +1228,8 @@ void KMReaderWin::setMsg( KMMessage* aMsg, bool force, bool updateOnly ) else slotTouchMessage(); } + + mHeaderRefreshTimer.start( 1000, false ); } //----------------------------------------------------------------------------- @@ -1664,6 +1667,66 @@ kdDebug(5006) << "KMReaderWin - composing unencrypted message" << endl; } +//----------------------------------------------------------------------------- +void KMReaderWin::updateHeader() +{ + /* + * TODO: mess around with KHTML DOM some more and figure out how to + * replace the entire header div w/out flickering to hell and back + * + * DOM::NodeList divs(mViewer->document().documentElement().getElementsByTagName("div")); + * static_cast(divs.item(0)).setInnerHTML(writeMsgHeader()); + */ + + KMMessage* currentMessage = message(); + + if (currentMessage && + mHeaderStyle == HeaderStyle::fancy() && + currentMessage->parent()) + { + int i; + int divNumber = -1; + DOM::NodeList divs(mViewer->document().documentElement().getElementsByTagName("div")); + DOM::NodeList headerDivs(static_cast(divs.item(0)).getElementsByTagName("div")); + for (i=0; i<((int)headerDivs.length()); i++) { + if (static_cast(headerDivs.item(i)).id().string() == "sendersCurrentTime") { + divNumber = i; + break; + } + } + + if (divNumber >= 0) { + DOM::HTMLDivElement elem = static_cast(headerDivs.item(i)); + + // HACK + // Get updated time information + TQString latestHeader = headerStyle()->format( currentMessage, headerStrategy(), "", mPrinting, false ); + int startPos = latestHeader.find("
= 0) { + latestHeader = latestHeader.mid(startPos); + int endPos = latestHeader.find("
"); + if (endPos >= 0) { + endPos = endPos + 6; + latestHeader.truncate(endPos); + + TQString divText = latestHeader; + TQString divStyle = latestHeader; + + divText = divText.mid(divText.find(">")+1); + divText.truncate(divText.find("")); + + divStyle = divStyle.mid(TQString("
asHREF( "body" ); - return headerStyle()->format( aMsg, headerStrategy(), href, mPrinting, topLevel ); + return headerStyle()->format( aMsg, headerStrategy(), href, mPrinting, topLevel ); } diff --git a/kmail/kmreaderwin.h b/kmail/kmreaderwin.h index 6251a484..81256e8c 100644 --- a/kmail/kmreaderwin.h +++ b/kmail/kmreaderwin.h @@ -379,6 +379,7 @@ public slots: void slotDocumentChanged(); void slotDocumentDone(); void slotTextSelected(bool); + void updateHeader(); /** An URL has been activate with a click. */ void slotUrlOpen(const KURL &url, const KParts::URLArgs &args); @@ -566,6 +567,7 @@ private: TQTimer mUpdateReaderWinTimer; TQTimer mResizeTimer; TQTimer mDelayedMarkTimer; + TQTimer mHeaderRefreshTimer; TQString mOverrideEncoding; TQString mOldGlobalOverrideEncoding; // used to detect changes of the global override character encoding bool mMsgDisplay;