diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-06-28 13:20:35 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-06-28 13:20:35 -0500 |
commit | e4cc0ead9fb403ee429406eaaacda0afae5dd006 (patch) | |
tree | b94243e7f4f2c52886aa069fddfcf74e29a6e590 | |
parent | 5f8b00b9567d41d1f4681e2240528b9fce2d7b3b (diff) | |
download | tdepim-e4cc0ead9fb403ee429406eaaacda0afae5dd006.tar.gz tdepim-e4cc0ead9fb403ee429406eaaacda0afae5dd006.zip |
Fix long-standing bug of Senders Current Time not refreshing
-rw-r--r-- | kmail/headerstyle.cpp | 9 | ||||
-rw-r--r-- | kmail/kmreaderwin.cpp | 71 | ||||
-rw-r--r-- | kmail/kmreaderwin.h | 2 |
3 files changed, 73 insertions, 9 deletions
diff --git a/kmail/headerstyle.cpp b/kmail/headerstyle.cpp index 7d0d6fc4b..9e654d68c 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( - "<div style=\"" + "<div id=\"sendersCurrentTime\" style=\"" "border:1px solid %1;" "color:%2;" "background-image:%3;" @@ -714,8 +713,8 @@ namespace KMail { "text-align:center;" "font-size:12px;" "padding:2px;" - "width:140px;" - "height:50px;" + "width:150px;" + "height:45px;" "margin: 0px 0px 3px 0px;" "\" class=\"curtime\">%4<br />%5<br />%6</div>" ) diff --git a/kmail/kmreaderwin.cpp b/kmail/kmreaderwin.cpp index 7d370f5ee..3aadb9631 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 <config.h> @@ -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 ); } //----------------------------------------------------------------------------- @@ -1665,6 +1668,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<DOM::HTMLDivElement>(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<DOM::HTMLDivElement>(divs.item(0)).getElementsByTagName("div")); + for (i=0; i<((int)headerDivs.length()); i++) { + if (static_cast<DOM::HTMLDivElement>(headerDivs.item(i)).id().string() == "sendersCurrentTime") { + divNumber = i; + break; + } + } + + if (divNumber >= 0) { + DOM::HTMLDivElement elem = static_cast<DOM::HTMLDivElement>(headerDivs.item(i)); + + // HACK + // Get updated time information + TQString latestHeader = headerStyle()->format( currentMessage, headerStrategy(), "", mPrinting, false ); + int startPos = latestHeader.find("<div id=\"sendersCurrentTime\" style=\""); + if (startPos >= 0) { + latestHeader = latestHeader.mid(startPos); + int endPos = latestHeader.find("</div>"); + 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("</div>")); + + divStyle = divStyle.mid(TQString("<div id=\"sendersCurrentTime\" style=\"").length()); + divStyle.truncate(divStyle.find("\"")); + + elem.setInnerHTML(divText); + elem.setAttribute("style", divStyle); + elem.applyChanges(); + } + } + } + } +} + +//----------------------------------------------------------------------------- TQString KMReaderWin::writeMsgHeader( KMMessage* aMsg, partNode *vCardNode, bool topLevel ) { kdFatal( !headerStyle(), 5006 ) @@ -1675,7 +1738,7 @@ TQString KMReaderWin::writeMsgHeader( KMMessage* aMsg, partNode *vCardNode, bool if ( vCardNode ) href = vCardNode->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 6251a4849..81256e8c5 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; |