File indexing completed on 2025-03-09 04:54:32

0001 /*
0002    SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "grantleeheaderstyle.h"
0008 #include "header/grantleeheaderformatter.h"
0009 #include <GrantleeTheme/GrantleeTheme>
0010 
0011 #include <KMime/KMimeMessage>
0012 
0013 using namespace MessageViewer;
0014 class MessageViewer::GrantleeHeaderStylePrivate
0015 {
0016 public:
0017     GrantleeHeaderStylePrivate()
0018         : mGrantleeFormatter(new GrantleeHeaderFormatter)
0019     {
0020     }
0021 
0022     ~GrantleeHeaderStylePrivate()
0023     {
0024         delete mGrantleeFormatter;
0025     }
0026 
0027     GrantleeHeaderFormatter *const mGrantleeFormatter;
0028 };
0029 
0030 GrantleeHeaderStyle::GrantleeHeaderStyle()
0031     : HeaderStyle()
0032     , d(new MessageViewer::GrantleeHeaderStylePrivate)
0033 {
0034 }
0035 
0036 GrantleeHeaderStyle::~GrantleeHeaderStyle() = default;
0037 
0038 const char *GrantleeHeaderStyle::name() const
0039 {
0040     return "grantlee";
0041 }
0042 
0043 QString GrantleeHeaderStyle::format(KMime::Message *message) const
0044 {
0045     if (!message) {
0046         return {};
0047     }
0048 
0049     GrantleeHeaderFormatter::GrantleeHeaderFormatterSettings settings;
0050     settings.isPrinting = isPrinting();
0051     settings.theme = theme();
0052     settings.style = this;
0053     settings.message = message;
0054     settings.showEmoticons = showEmoticons();
0055     return d->mGrantleeFormatter->toHtml(settings);
0056 }