Messagelib

headerstyle_util.h
1 /*
2  SPDX-FileCopyrightText: 2013-2021 Laurent Montel <[email protected]>
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"
20 namespace MessageViewer
21 {
22 /**
23  * @brief The HeaderStyleUtil class
24  * @author Laurent Montel <[email protected]>
25  */
26 class MESSAGEVIEWER_EXPORT HeaderStyleUtil
27 {
28 public:
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  Q_REQUIRED_RESULT QString directionOf(const QString &str) const;
54 
55  static Q_REQUIRED_RESULT QString strToHtml(const QString &str, KTextToHTML::Options flags = KTextToHTML::PreserveSpaces);
56  static Q_REQUIRED_RESULT QString dateString(KMime::Message *message, HeaderStyleUtilDateFormat dateFormat);
57  static Q_REQUIRED_RESULT QString dateString(const QDateTime &date, HeaderStyleUtilDateFormat dateFormat);
58 
59  Q_REQUIRED_RESULT QString subjectString(KMime::Message *message, KTextToHTML::Options flags = KTextToHTML::PreserveSpaces) const;
60 
61  Q_REQUIRED_RESULT QString subjectDirectionString(KMime::Message *message) const;
62 
63  Q_REQUIRED_RESULT QString spamStatus(KMime::Message *message) const;
64 
65  static Q_REQUIRED_RESULT QString dateStr(const QDateTime &dateTime);
66 
67  static Q_REQUIRED_RESULT QString dateShortStr(const QDateTime &dateTime);
68 
69  MESSAGEVIEWER_DEPRECATED static Q_REQUIRED_RESULT QSharedPointer<KMime::Headers::Generics::MailboxList> resentFromList(KMime::Message *message);
70 
71  MESSAGEVIEWER_DEPRECATED static Q_REQUIRED_RESULT QSharedPointer<KMime::Headers::Generics::MailboxList> resentToList(KMime::Message *message);
72 
73  Q_REQUIRED_RESULT xfaceSettings xface(const HeaderStyle *style, KMime::Message *message) const;
74 
75 private:
76  void updateXFaceSettings(QImage photo, xfaceSettings &settings) const;
77  Q_REQUIRED_RESULT QString
78  drawSpamMeter(SpamError spamError, double percent, double confidence, const QString &filterHeader, const QString &confidenceHeader) const;
79  Q_REQUIRED_RESULT QString imgToDataUrl(const QImage &image) const;
80 };
81 }
82 
This class encapsulates the visual appearance of message headers.
Definition: headerstyle.h:46
Locale Long date format, e.g.
The HeaderStyleUtil class.
Locale Short date format, e.g.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Dec 6 2021 23:04:57 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.