From f0fd255cdcf4c8884ee8524a3be9fc90bf24ac25 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 20 Jan 2003 22:38:14 +0000 Subject: [PATCH] - make "all headers" work again (kludge) - in plain: only display organization if from is displayed svn path=/trunk/kdepim/; revision=201545 --- headerstyle.cpp | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/headerstyle.cpp b/headerstyle.cpp index 5b26672aa..a08547351 100644 --- a/headerstyle.cpp +++ b/headerstyle.cpp @@ -20,6 +20,10 @@ #include "interfaces/htmlwriter.h" +#include +#include +#include + #include #include #include @@ -172,6 +176,9 @@ namespace KMail { QString format( const KMMessage * message, const HeaderStrategy * strategy, const QString & vCardName, bool printing ) const; + + private: + QString formatAllMessageHeaders( const KMMessage * message ) const; }; QString PlainHeaderStyle::format( const KMMessage * message, @@ -181,13 +188,10 @@ namespace KMail { if ( !strategy ) strategy = HeaderStrategy::rich(); - // ### from kmreaderwin begin - // The direction of the header is determined according to the direction // of the application layout. QString dir = ( QApplication::reverseLayout() ? "rtl" : "ltr" ); - QString headerStr = QString("
").arg(dir); // However, the direction of the message subject within the header is // determined according to the contents of the subject itself. Since @@ -213,6 +217,15 @@ namespace KMail { dateString = message->dateStr(); } + QString headerStr = QString("
").arg(dir); + + if ( strategy->headersToDisplay().isEmpty() + && strategy->defaultPolicy() == HeaderStrategy::Display ) { + // crude way to emulate "all" headers: + headerStr += formatAllMessageHeaders( message ); + return headerStr + "
"; + } + //case HdrLong: if ( strategy->showHeader( "subject" ) ) headerStr += QString("
" + @@ -228,15 +241,13 @@ namespace KMail { if ( !vCardName.isEmpty() ) headerStr.append("  " + i18n("[vCard]") + "" ); + if ( strategy->showHeader( "organization" ) + && !message->headerField("Organization").isEmpty()) + headerStr.append("  (" + + strToHtml(message->headerField("Organization")) + ")"); + headerStr.append("
"); } - if ( strategy->showHeader( "organization" ) - && !message->headerField("Organization").isEmpty()) - headerStr.append("  (" + - strToHtml(message->headerField("Organization")) + ")"); - - headerStr.append("
"); - if ( strategy->showHeader( "to" ) ) headerStr.append(i18n("To: ")+ KMMessage::emailAddrAsAnchor(message->to(),FALSE) + "
"); @@ -258,6 +269,19 @@ namespace KMail { return headerStr; } + QString PlainHeaderStyle::formatAllMessageHeaders( const KMMessage * message ) const { + const DwHeaders & headers = message->headers(); + QString result; + + for ( const DwField * field = headers.FirstField() ; field ; field = field->Next() ) { + result += ( field->FieldNameStr() + ": " ).c_str(); + result += strToHtml( field->FieldBodyStr().c_str() ); + result += "
"; + } + + return result; + } + // // FancyHeaderStyle: // Like PlainHeaderStyle, but with slick frames and background colours.