summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-10-26 05:45:15 (GMT)
committerMontel Laurent <montel@kde.org>2016-10-26 05:47:08 (GMT)
commit7e1fd7a141c6e056726794a0315421c41607be6b (patch)
tree30efaec7b5871ce8fcb36d5d91deccfe2b1f4f01
parent95f03987971a4c252bcbe9843992a10188895da1 (diff)
Cache header pointer
-rw-r--r--plugins/messageviewerheaderplugins/fancyheaderstyleplugin/fancyheaderstyle.cpp49
1 files changed, 31 insertions, 18 deletions
diff --git a/plugins/messageviewerheaderplugins/fancyheaderstyleplugin/fancyheaderstyle.cpp b/plugins/messageviewerheaderplugins/fancyheaderstyleplugin/fancyheaderstyle.cpp
index 1d4aa2d..4013495 100644
--- a/plugins/messageviewerheaderplugins/fancyheaderstyleplugin/fancyheaderstyle.cpp
+++ b/plugins/messageviewerheaderplugins/fancyheaderstyleplugin/fancyheaderstyle.cpp
@@ -197,33 +197,46 @@ QString FancyHeaderStyle::format(KMime::Message *message) const
}
if (strategy->showHeader(QStringLiteral("x-mailer"))) {
- if (message->headerByType("X-Mailer")) {
+ if (auto hrd = message->headerByType("X-Mailer")) {
headerStr.append(QStringLiteral("<tr><th>%1</th>\n"
"<td>%2</td></tr>\n")
.arg(i18n("X-Mailer: "))
- .arg(mHeaderStyleUtil.strToHtml(message->headerByType("X-Mailer")->asUnicodeString())));
+ .arg(mHeaderStyleUtil.strToHtml(hrd->asUnicodeString())));
}
}
}
- if (strategy->showHeader(QStringLiteral("x-bugzilla-url")) && message->headerByType("X-Bugzilla-URL")) {
- const QString product = message->headerByType("X-Bugzilla-Product") ? message->headerByType("X-Bugzilla-Product")->asUnicodeString() : QString();
- const QString component = message->headerByType("X-Bugzilla-Component") ? message->headerByType("X-Bugzilla-Component")->asUnicodeString() : QString();
- const QString status = message->headerByType("X-Bugzilla-Status") ? message->headerByType("X-Bugzilla-Status")->asUnicodeString() : QString();
- headerStr.append(QStringLiteral("<tr><th>%1</th>\n"
- "<td>%2/%3, <strong>%4</strong></td></tr>\n")
- .arg(i18n("Bugzilla: "))
- .arg(mHeaderStyleUtil.strToHtml(product))
- .arg(mHeaderStyleUtil.strToHtml(component))
- .arg(mHeaderStyleUtil.strToHtml(status)));
+ if (strategy->showHeader(QStringLiteral("x-bugzilla-url"))) {
+ if (message->headerByType("X-Bugzilla-URL")) {
+ QString product;
+ if (auto hrd = message->headerByType("X-Bugzilla-Product")) {
+ product = hrd->asUnicodeString();
+ }
+ QString component;
+ if (auto hrd = message->headerByType("X-Bugzilla-Component")) {
+ component = hrd->asUnicodeString();
+ }
+ QString status;
+ if (auto hrd = message->headerByType("X-Bugzilla-Status")) {
+ status = hrd->asUnicodeString();
+ }
+ headerStr.append(QStringLiteral("<tr><th>%1</th>\n"
+ "<td>%2/%3, <strong>%4</strong></td></tr>\n")
+ .arg(i18n("Bugzilla: "))
+ .arg(mHeaderStyleUtil.strToHtml(product))
+ .arg(mHeaderStyleUtil.strToHtml(component))
+ .arg(mHeaderStyleUtil.strToHtml(status)));
+ }
}
- if (strategy->showHeader(QStringLiteral("disposition-notification-to")) && message->headerByType("Disposition-Notification-To")) {
- const QString to = message->headerByType("Disposition-Notification-To") ? message->headerByType("Disposition-Notification-To")->asUnicodeString() : QString();
- headerStr.append(QStringLiteral("<tr><th>%1</th>\n"
- "<td>%2</tr>\n")
- .arg(i18n("MDN To: "))
- .arg(mHeaderStyleUtil.strToHtml(to)));
+ if (strategy->showHeader(QStringLiteral("disposition-notification-to"))){
+ if (auto hrd = message->headerByType("Disposition-Notification-To")) {
+ const QString to = hrd->asUnicodeString();
+ headerStr.append(QStringLiteral("<tr><th>%1</th>\n"
+ "<td>%2</tr>\n")
+ .arg(i18n("MDN To: "))
+ .arg(mHeaderStyleUtil.strToHtml(to)));
+ }
}
if (!spamHTML.isEmpty())