Messagelib

headerstyle_util.h
1/*
2 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <KTextToHTML>
10#include <QString>
11#include <QVariantHash>
12
13#include "messageviewer/spamheaderanalyzer.h"
14#include <KMime/DateFormatter>
15#include <KMime/KMimeMessage>
16
17#include "messageviewer/headerstyle.h"
18#include "messageviewer/viewer.h"
19#include "messageviewer_export.h"
20namespace MessageViewer
21{
22/**
23 * @brief The HeaderStyleUtil class
24 * @author Laurent Montel <montel@kde.org>
25 */
26class MESSAGEVIEWER_EXPORT HeaderStyleUtil
27{
28public:
30 struct xfaceSettings {
31 xfaceSettings()
32 : photoWidth(60)
33 , photoHeight(60)
34 {
35 }
36
37 QString photoURL;
38 int photoWidth;
39 int photoHeight;
40 };
42 ShortDate, /**< Locale Short date format, e.g. 08-04-2007 */
43 LongDate, /**< Locale Long date format, e.g. Sunday 08 April 2007 */
44 FancyShortDate, /**< Same as ShortDate for dates a week or more ago. For more
45 recent dates, it is represented as Today, Yesterday, or
46 the weekday name. */
47 FancyLongDate, /**< Same as LongDate for dates a week or more ago. For more
48 recent dates, it is represented as Today, Yesterday, or
49 the weekday name. */
50 CustomDate
51 };
52
53 [[nodiscard]] QString directionOf(const QString &str) const;
54
55 [[nodiscard]] static QString strToHtml(const QString &str, KTextToHTML::Options flags = KTextToHTML::PreserveSpaces);
56 [[nodiscard]] static QString dateString(KMime::Message *message, HeaderStyleUtilDateFormat dateFormat);
57 [[nodiscard]] static QString dateString(const QDateTime &date, HeaderStyleUtilDateFormat dateFormat);
58
59 [[nodiscard]] QString subjectString(KMime::Message *message, KTextToHTML::Options flags = KTextToHTML::PreserveSpaces) const;
60
61 [[nodiscard]] QString subjectDirectionString(KMime::Message *message) const;
62
63 [[nodiscard]] QString spamStatus(KMime::Message *message) const;
64
65 [[nodiscard]] static QString dateStr(const QDateTime &dateTime);
66
67 [[nodiscard]] static QString dateShortStr(const QDateTime &dateTime);
68
69 [[nodiscard]] MESSAGEVIEWER_DEPRECATED static QSharedPointer<KMime::Headers::Generics::MailboxList> resentFromList(KMime::Message *message);
70
71 [[nodiscard]] MESSAGEVIEWER_DEPRECATED static QSharedPointer<KMime::Headers::Generics::MailboxList> resentToList(KMime::Message *message);
72
73 [[nodiscard]] xfaceSettings xface(const HeaderStyle *style, KMime::Message *message) const;
74
75private:
76 void updateXFaceSettings(QImage photo, xfaceSettings &settings) const;
77 [[nodiscard]] QString
78 drawSpamMeter(SpamError spamError, double percent, double confidence, const QString &filterHeader, const QString &confidenceHeader) const;
79 [[nodiscard]] QString imgToDataUrl(const QImage &image) const;
80};
81}
The HeaderStyleUtil class.
@ LongDate
Locale Long date format, e.g.
@ ShortDate
Locale Short date format, e.g.
This class encapsulates the visual appearance of message headers.
Definition headerstyle.h:47
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:55:44 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.