Commit 1d2d37fe authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Adapt to new api

parent ab56d462
......@@ -58,7 +58,7 @@ QString CustomHeaderStyle::format(KMime::Message *message) const
// considered left-to-right, they are ignored when determining its
// direction.
const QString subjectDir = MessageViewer::HeaderStyleUtil::subjectDirectionString(message);
const QString subjectDir = mHeaderStyleUtil.subjectDirectionString(message);
QString headerStr;
const QStringList headersToDisplay = strategy->headersToDisplay();
......@@ -78,9 +78,9 @@ QString CustomHeaderStyle::format(KMime::Message *message) const
Q_FOREACH (const QString &headerToDisplay, headersToDisplay) {
if (headerToDisplay.toLower() == QLatin1String("subject")) {
headerStr += QStringLiteral("<div dir=\"%1\"><b style=\"font-size:130%\">").arg(subjectDir) +
MessageViewer::HeaderStyleUtil::subjectString(message) + QLatin1String("</b></div>\n");
mHeaderStyleUtil.subjectString(message) + QLatin1String("</b></div>\n");
} else if (headerToDisplay.toLower() == QLatin1String("date")) {
headerStr.append(i18n("Date: ") + MessageViewer::HeaderStyleUtil::strToHtml(MessageViewer::HeaderStyleUtil::dateString(message, isPrinting(), /* short = */ false)) + QLatin1String("<br/>\n"));
headerStr.append(i18n("Date: ") + mHeaderStyleUtil.strToHtml(mHeaderStyleUtil.dateString(message, isPrinting(), /* short = */ false)) + QLatin1String("<br/>\n"));
} else if (headerToDisplay.toLower() == QLatin1String("from")) {
headerStr.append(i18n("From: ") +
StringUtil::emailAddrAsAnchor(message->from(), StringUtil::DisplayFullAddress, QString(), StringUtil::ShowLink));
......@@ -91,7 +91,7 @@ QString CustomHeaderStyle::format(KMime::Message *message) const
if (strategy->showHeader(QStringLiteral("organization"))
&& message->organization(false))
headerStr.append(QLatin1String("&nbsp;&nbsp;(") +
MessageViewer::HeaderStyleUtil::strToHtml(message->organization()->asUnicodeString()) + QLatin1Char(')'));
mHeaderStyleUtil.strToHtml(message->organization()->asUnicodeString()) + QLatin1Char(')'));
headerStr.append(QLatin1String("<br/>\n"));
} else if (headerToDisplay.toLower() == QLatin1String("to")) {
headerStr.append(i18nc("To-field of the mailheader.", "To: ") +
......@@ -114,7 +114,7 @@ QString CustomHeaderStyle::format(KMime::Message *message) const
} else {
const QByteArray header = headerToDisplay.toLatin1();
if (message->headerByType(header)) {
headerStr.append(MessageViewer::HeaderStyleUtil::strToHtml(i18n("%1: ", headerToDisplay) + message->headerByType(header)->asUnicodeString()) + QLatin1String("<br/>\n"));
headerStr.append(mHeaderStyleUtil.strToHtml(i18n("%1: ", headerToDisplay) + message->headerByType(header)->asUnicodeString()) + QLatin1String("<br/>\n"));
}
}
}
......@@ -130,7 +130,7 @@ QString CustomHeaderStyle::formatAllMessageHeaders(KMime::Message *message, cons
while (header) {
const QString headerType = QLatin1String(header->type());
if (!headersToHide.contains(headerType) || !headersToHide.contains(headerType.toLower())) {
result += MessageViewer::HeaderStyleUtil::strToHtml(headerType) + QLatin1String(": ") + header->asUnicodeString();
result += mHeaderStyleUtil.strToHtml(headerType) + QLatin1String(": ") + header->asUnicodeString();
result += QLatin1String("<br />\n");
}
delete header;
......
......@@ -20,6 +20,8 @@
#include "messageviewer/headerstyle.h"
#include <headerstyle_util.h>
namespace MessageViewer
{
......@@ -35,6 +37,8 @@ public:
private:
QString format(KMime::Message *message) const Q_DECL_OVERRIDE;
QString formatAllMessageHeaders(KMime::Message *message, const QStringList &headersToHide) const;
MessageViewer::HeaderStyleUtil mHeaderStyleUtil;
};
}
......
......@@ -78,7 +78,7 @@ QString EnterpriseHeaderStyle::format(KMime::Message *message) const
headerStr +=
QLatin1String("<div style=\"margin-left: 10px; top: 0px;\"><span style=\"font-size: 0.8em; font-weight: bold;\">")
+ MessageViewer::HeaderStyleUtil::dateString(message, isPrinting(), /* shortDate */ false) + QLatin1String("</span></div>"
+ mHeaderStyleUtil.dateString(message, isPrinting(), /* shortDate */ false) + QLatin1String("</span></div>"
// #0057ae
"<table style=\"background: ") + activeColorDark.name() + QLatin1String("; border-collapse:collapse; top: 14px; min-width: 200px; \" cellpadding=0> \n"
" <tr> \n"
......@@ -101,7 +101,7 @@ QString EnterpriseHeaderStyle::format(KMime::Message *message) const
QLatin1String(" <tr> \n"
" <td style=\"font-size: 0.5em; text-align: right; padding-left: 5px; padding-right: 24px; ") + borderSettings + QLatin1String("\"></td> \n"
" <td style=\"font-weight: bolder; font-size: 120%; padding-right: 91px; ") + borderSettings + QLatin1String("\">");
headerStr += MessageViewer::HeaderStyleUtil::subjectString(message) + QLatin1String("</td> \n"
headerStr += mHeaderStyleUtil.subjectString(message) + QLatin1String("</td> \n"
" </tr> \n");
}
......
......@@ -19,6 +19,8 @@
#define ENTREPRISEHEADERSTYLE_H
#include "messageviewer/headerstyle.h"
#include <headerstyle_util.h>
namespace MessageViewer
{
......@@ -34,6 +36,8 @@ public:
QString format(KMime::Message *message) const Q_DECL_OVERRIDE;
bool hasAttachmentQuickList() const Q_DECL_OVERRIDE;
private:
MessageViewer::HeaderStyleUtil mHeaderStyleUtil;
};
}
......
......@@ -84,17 +84,17 @@ QString FancyHeaderStyle::format(KMime::Message *message) const
// considered left-to-right, they are ignored when determining its
// direction.
const QString subjectDir = MessageViewer::HeaderStyleUtil::subjectDirectionString(message);
const QString subjectDir = mHeaderStyleUtil.subjectDirectionString(message);
// Spam header display.
// If the spamSpamStatus config value is true then we look for headers
// from a few spam filters and try to create visually meaningful graphics
// out of the spam scores.
const QString spamHTML = MessageViewer::HeaderStyleUtil::spamStatus(message);
const QString spamHTML = mHeaderStyleUtil.spamStatus(message);
QString userHTML;
MessageViewer::HeaderStyleUtil::xfaceSettings xface = MessageViewer::HeaderStyleUtil::xface(this, message);
MessageViewer::HeaderStyleUtil::xfaceSettings xface = mHeaderStyleUtil.xface(this, message);
if (!xface.photoURL.isEmpty()) {
//qCDebug(MESSAGEVIEWER_LOG) << "Got a photo:" << xface.photoURL;
userHTML = QStringLiteral("<img src=\"%1\" width=\"%2\" height=\"%3\">")
......@@ -111,7 +111,7 @@ QString FancyHeaderStyle::format(KMime::Message *message) const
headerStr += QStringLiteral("<div dir=\"%1\">%2</div>\n")
.arg(subjectDir)
.arg(MessageViewer::HeaderStyleUtil::subjectString(message, flags));
.arg(mHeaderStyleUtil.subjectString(message, flags));
}
headerStr += QLatin1String("<table class=\"outer\"><tr><td width=\"100%\"><table>\n");
//headerStr += "<table>\n";
......@@ -120,7 +120,7 @@ QString FancyHeaderStyle::format(KMime::Message *message) const
// QString::arg is not possible
if (strategy->showHeader(QStringLiteral("from"))) {
const QVector<KMime::Types::Mailbox> resentFrom = MessageViewer::HeaderStyleUtil::resentFromList(message);
const QVector<KMime::Types::Mailbox> resentFrom = mHeaderStyleUtil.resentFromList(message);
headerStr += QStringLiteral("<tr><th>%1</th>\n"
"<td>")
.arg(i18n("From: "))
......@@ -136,13 +136,13 @@ QString FancyHeaderStyle::format(KMime::Message *message) const
+ (!message->organization(false)
? QString()
: QLatin1String("&nbsp;&nbsp;(")
+ MessageViewer::HeaderStyleUtil::strToHtml(message->organization()->asUnicodeString())
+ mHeaderStyleUtil.strToHtml(message->organization()->asUnicodeString())
+ QLatin1Char(')'))
+ QLatin1String("</td></tr>\n");
}
// to line
if (strategy->showHeader(QStringLiteral("to"))) {
const QVector<KMime::Types::Mailbox> resentTo = MessageViewer::HeaderStyleUtil::resentToList(message);
const QVector<KMime::Types::Mailbox> resentTo = mHeaderStyleUtil.resentToList(message);
QString to;
if (message->headerByType("Resent-To")) {
......@@ -181,15 +181,15 @@ QString FancyHeaderStyle::format(KMime::Message *message) const
headerStr.append(QStringLiteral("<tr><th>%1</th>\n"
"<td dir=\"%2\">%3</td></tr>\n")
.arg(i18n("Date: "))
.arg(MessageViewer::HeaderStyleUtil::directionOf(MessageViewer::HeaderStyleUtil::dateStr(message->date()->dateTime())))
.arg(MessageViewer::HeaderStyleUtil::strToHtml(MessageViewer::HeaderStyleUtil::dateString(message, isPrinting(), /* short = */ false))));
.arg(mHeaderStyleUtil.directionOf(mHeaderStyleUtil.dateStr(message->date()->dateTime())))
.arg(mHeaderStyleUtil.strToHtml(mHeaderStyleUtil.dateString(message, isPrinting(), /* short = */ false))));
if (MessageViewer::MessageViewerSettings::self()->showUserAgent()) {
if (strategy->showHeader(QStringLiteral("user-agent"))) {
if (auto hdr = message->userAgent(false)) {
headerStr.append(QStringLiteral("<tr><th>%1</th>\n"
"<td>%2</td></tr>\n")
.arg(i18n("User-Agent: "))
.arg(MessageViewer::HeaderStyleUtil::strToHtml(hdr->asUnicodeString())));
.arg(mHeaderStyleUtil.strToHtml(hdr->asUnicodeString())));
}
}
......@@ -198,7 +198,7 @@ QString FancyHeaderStyle::format(KMime::Message *message) const
headerStr.append(QStringLiteral("<tr><th>%1</th>\n"
"<td>%2</td></tr>\n")
.arg(i18n("X-Mailer: "))
.arg(MessageViewer::HeaderStyleUtil::strToHtml(message->headerByType("X-Mailer")->asUnicodeString())));
.arg(mHeaderStyleUtil.strToHtml(message->headerByType("X-Mailer")->asUnicodeString())));
}
}
}
......@@ -210,9 +210,9 @@ QString FancyHeaderStyle::format(KMime::Message *message) const
headerStr.append(QStringLiteral("<tr><th>%1</th>\n"
"<td>%2/%3, <strong>%4</strong></td></tr>\n")
.arg(i18n("Bugzilla: "))
.arg(MessageViewer::HeaderStyleUtil::strToHtml(product))
.arg(MessageViewer::HeaderStyleUtil::strToHtml(component))
.arg(MessageViewer::HeaderStyleUtil::strToHtml(status)));
.arg(mHeaderStyleUtil.strToHtml(product))
.arg(mHeaderStyleUtil.strToHtml(component))
.arg(mHeaderStyleUtil.strToHtml(status)));
}
if (strategy->showHeader(QStringLiteral("disposition-notification-to")) && message->headerByType("Disposition-Notification-To")) {
......
......@@ -19,9 +19,11 @@
#define FANCYHEADERSTYLE_H
#include "messageviewer/headerstyle.h"
#include <headerstyle_util.h>
namespace MessageViewer
{
class HeaderStyleUtil;
class FancyHeaderStyle : public HeaderStyle
{
public:
......@@ -34,6 +36,8 @@ public:
QString format(KMime::Message *message) const Q_DECL_OVERRIDE;
bool hasAttachmentQuickList() const Q_DECL_OVERRIDE;
private:
MessageViewer::HeaderStyleUtil mHeaderStyleUtil;
};
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment