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 #pragma once
0008 
0009 #include "messageviewer_export.h"
0010 #include <GrantleeTheme/GrantleeTheme>
0011 #include <KTextTemplate/TemplateLoader>
0012 #include <QString>
0013 namespace KMime
0014 {
0015 class Message;
0016 }
0017 
0018 namespace MessageViewer
0019 {
0020 class HeaderStyle;
0021 /**
0022  * @brief The GrantleeHeaderFormatter class
0023  * @author Laurent Montel <montel@kde.org>
0024  */
0025 class MESSAGEVIEWER_EXPORT GrantleeHeaderFormatter
0026 {
0027 public:
0028     struct GrantleeHeaderFormatterSettings {
0029         GrantleeHeaderFormatterSettings() = default;
0030 
0031         GrantleeTheme::Theme theme;
0032         bool isPrinting = false;
0033         mutable const MessageViewer::HeaderStyle *style = nullptr;
0034         KMime::Message *message = nullptr;
0035         bool showEmoticons = true;
0036     };
0037 
0038     explicit GrantleeHeaderFormatter();
0039     ~GrantleeHeaderFormatter();
0040 
0041     [[nodiscard]] QString toHtml(const GrantleeHeaderFormatterSettings &settings) const;
0042 
0043     [[nodiscard]] QString toHtml(const QStringList &displayExtraHeaders,
0044                                  const QString &absolutPath,
0045                                  const QString &filename,
0046                                  const MessageViewer::HeaderStyle *style,
0047                                  KMime::Message *message,
0048                                  bool isPrinting) const;
0049 
0050 private:
0051     [[nodiscard]] QString format(const QString &absolutePath,
0052                                  const KTextTemplate::Template &headerTemplate,
0053                                  const QStringList &displayExtraHeaders,
0054                                  bool isPrinting,
0055                                  const MessageViewer::HeaderStyle *style,
0056                                  KMime::Message *message,
0057                                  bool showEmoticons = true) const;
0058     class GrantleeHeaderFormatterPrivate;
0059     std::unique_ptr<GrantleeHeaderFormatterPrivate> const d;
0060 };
0061 }