Messagelib

htmlblock.h
1 /*
2  SPDX-FileCopyrightText: 2015 Sandro KnauƟ <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "messageviewer_export.h"
10 
11 #include <QSharedPointer>
12 #include <QString>
13 
14 namespace KMime
15 {
16 class Content;
17 }
18 
19 namespace MessageViewer
20 {
21 class HtmlWriter;
22 /**
23  * @brief The HTMLBlock class
24  */
25 class MESSAGEVIEWER_EXPORT HTMLBlock
26 {
27 public:
29 
30  HTMLBlock();
31 
32  virtual ~HTMLBlock();
33 
34  Q_REQUIRED_RESULT Q_REQUIRED_RESULT QString enter();
35  Q_REQUIRED_RESULT Q_REQUIRED_RESULT QString exit();
36 
37 protected:
38  Q_REQUIRED_RESULT QString dir() const;
39  virtual QString enterString() const = 0;
40  virtual QString exitString() const = 0;
41 
42 private:
43  bool entered = false;
44 };
45 
46 // The attachment mark is a div that is placed around the attachment. It is used for drawing
47 // a yellow border around the attachment when scrolling to it. When scrolling to it, the border
48 // color of the div is changed, see KMReaderWin::scrollToAttachment().
49 /**
50  * @brief The AttachmentMarkBlock class
51  */
52 class MESSAGEVIEWER_EXPORT AttachmentMarkBlock : public HTMLBlock
53 {
54 public:
56  ~AttachmentMarkBlock() override;
57 
58 protected:
59  Q_REQUIRED_RESULT QString enterString() const override;
60  Q_REQUIRED_RESULT QString exitString() const override;
61 
62 private:
63  void internalEnter();
64  void internalExit();
65 
66  KMime::Content *const mNode;
67  HtmlWriter *const mWriter;
68 };
69 
70 // Make sure the whole content is relative, so that nothing is painted over the header
71 // if a malicious message uses absolute positioning.
72 // Also force word wrapping, which is useful for printing, see https://issues.kolab.org/issue3992.
73 class RootBlock : public HTMLBlock
74 {
75 public:
76  explicit RootBlock(HtmlWriter *writer);
77  ~RootBlock() override;
78 
79 protected:
80  QString enterString() const override;
81  QString exitString() const override;
82 
83 private:
84  void internalEnter();
85  void internalExit();
86 
87  HtmlWriter *mWriter = nullptr;
88 };
89 }
The AttachmentMarkBlock class.
Definition: htmlblock.h:52
An interface for HTML sinks.
Definition: htmlwriter.h:28
The HTMLBlock class.
Definition: htmlblock.h:25
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Dec 4 2021 23:12:53 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.