Fix long-standing bug of Senders Current Time not refreshing

pull/21/head
Timothy Pearson 12 years ago
parent 5f8b00b956
commit e4cc0ead9f

@ -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>"
)

@ -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<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 )
{

@ -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;

Loading…
Cancel
Save