? showheader.patch Index: kmreaderwin.cpp =================================================================== RCS file: /home/kde/kdenetwork/kmail/kmreaderwin.cpp,v retrieving revision 1.532 diff -u -3 -p -b -B -r1.532 kmreaderwin.cpp --- kmreaderwin.cpp 2002/08/13 11:28:09 1.532 +++ kmreaderwin.cpp 2002/08/18 12:34:42 @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -1731,6 +1732,13 @@ void KMReaderWin::readConfig(void) mHtmlMail = config->readBoolEntry( "htmlMail", false ); mAtmInline = config->readNumEntry("attach-inline", 100); mHeaderStyle = (HeaderStyle)config->readNumEntry("hdr-style", HdrFancy); + int ehs; + for (ehs=HdrFancy-1; ehs < HdrAll;ehs++) { + mShowAllHeaders[ehs] = config->readBoolEntry("showAllHeaders_"+QString::number(ehs+1), ehs+1 == HdrAll); + mHeadersHide[ehs] = config->readListEntry("hideExtraHeaders_"+QString::number(ehs+1)); + mHeadersShow[ehs] = config->readListEntry("showExtraHeaders_"+QString::number(ehs+1)); + } + mAttachmentStyle = (AttachmentStyle)config->readNumEntry("attmnt-style", SmartAttmnt); mLoadExternal = config->readBoolEntry( "htmlLoadExternal", false ); @@ -3204,6 +3212,30 @@ kdDebug(5006) << "KMReaderWin - finish } } +//----------------------------------------------------------------------------- +QString KMReaderWin::visibleHeadersToString(KMMessage* aMsg, QString formatString) +{ + QString returnstring; + DwHeaders headers = aMsg->headers(); + DwField *field = headers.FirstField(); + while (field) { + const char *fname = field->FieldNameStr().c_str(); + if ( mShowAllHeaders[mHeaderStyle - 1] + ? !mHeadersHide[mHeaderStyle - 1].contains(QString(fname)) + : mHeadersShow[mHeaderStyle - 1].contains(QString(fname))) { + QString fs = formatString; + if (fs.contains("%1")) fs = fs.arg(fname); + if (fs.contains("%2")) { + fs = fs.arg(i18n((QString(fname)+": ").latin1())); + } + if (fs.contains("%3")) fs = fs.arg(strToHtml(field->FieldBodyStr().c_str())); + returnstring.append(fs); + } + + field = field->Next(); + } + return returnstring; +} //----------------------------------------------------------------------------- QString KMReaderWin::writeMsgHeader(KMMessage* aMsg, bool hasVCard) @@ -3251,6 +3283,7 @@ QString KMReaderWin::writeMsgHeader(KMMe } headerStr.append(" "+strToHtml(aMsg->dateShortStr()) + ")"); + headerStr.append(visibleHeadersToString(aMsg, "
%2%3
")); if (hasVCard) { @@ -3276,6 +3309,7 @@ QString KMReaderWin::writeMsgHeader(KMMe if (!aMsg->cc().isEmpty()) headerStr.append(i18n("CC: ")+ KMMessage::emailAddrAsAnchor(aMsg->cc(),FALSE) + "
"); + headerStr.append(visibleHeadersToString(aMsg, "
%2%3
")); break; case HdrFancy: @@ -3316,6 +3350,8 @@ QString KMReaderWin::writeMsgHeader(KMMe .arg(KMMessage::emailAddrAsAnchor(aMsg->cc(),FALSE))); } + headerStr.append(visibleHeadersToString(aMsg, "%2%3")); + // the date QString dateString; if (mPrinting) @@ -3376,13 +3412,14 @@ QString KMReaderWin::writeMsgHeader(KMMe headerStr.append(i18n("Reply to: ")+ KMMessage::emailAddrAsAnchor(aMsg->replyTo(),FALSE) + "
"); } + headerStr.append(visibleHeadersToString(aMsg, "
%2%3
")); break; case HdrAll: // we force the direction to ltr here, even in a arabic/hebrew UI, // as the headers are almost all Latin1 headerStr += "
"; - headerStr += strToHtml(aMsg->headerAsString(), true); + headerStr.append(visibleHeadersToString(aMsg, "
%2%3
")); if (hasVCard) { headerStr.append("
"+i18n("[vCard]")+""); Index: kmreaderwin.h =================================================================== RCS file: /home/kde/kdenetwork/kmail/kmreaderwin.h,v retrieving revision 1.126 diff -u -3 -p -b -B -r1.126 kmreaderwin.h --- kmreaderwin.h 2002/08/07 10:03:15 1.126 +++ kmreaderwin.h 2002/08/18 12:34:42 @@ -21,6 +21,7 @@ class QFrame; class QMultiLineEdit; class QScrollBar; class QString; +class QStringList; class QTabDialog; class QLabel; class QHBox; @@ -389,7 +390,18 @@ protected: /** Cleanup the attachment temp files */ virtual void removeTempFiles(); - + /** write all headers that are not listed in mHideExtraHeaders[mHeaderStyle-1] + to a string, using the formatString. + @param aMsg The Message from which to extract the headers + @param formatString Format String for a header, expected to + take 3 Arguments: +
    +
  • %1: Headerfield Name
  • +
  • %2: Translated Headerfield Name
  • +
  • %3: Headerfield Body
  • +
+ */ + QString visibleHeadersToString(KMMessage* aMsg, QString formatString); private: /** extracted parts from writeBodyStr() */ class PartMetaData; @@ -413,6 +425,9 @@ protected: QLabel *mColorBar; KHTMLPart *mViewer; HeaderStyle mHeaderStyle; + bool mShowAllHeaders[HdrAll]; + QStringList mHeadersHide[HdrAll]; + QStringList mHeadersShow[HdrAll]; AttachmentStyle mAttachmentStyle; bool mAutoDelete; QFont mBodyFont, mFixedFont;