KPimTextEdit

plaintextmarkupbuilder.h
1/*
2 SPDX-FileCopyrightText: 2019-2021 Montel Laurent <montel@kde.org>
3 based on grantlee PlainTextMarkupBuilder
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6
7*/
8
9#pragma once
10#include "abstractmarkupbuilder.h"
11#include "kpimtextedit_export.h"
12
13#define LETTERSINALPHABET 26
14#define DIGITSOFFSET 10
15
16namespace KPIMTextEdit
17{
18class PlainTextMarkupBuilderPrivate;
19class KPIMTEXTEDIT_EXPORT PlainTextMarkupBuilder : virtual public KPIMTextEdit::AbstractMarkupBuilder
20{
21public:
22 /** Construct a new PlainTextHTMLMarkupBuilder. */
23 PlainTextMarkupBuilder();
24
25 ~PlainTextMarkupBuilder() override;
26
27 void setQuotePrefix(const QString &prefix);
28
29 void beginStrong() override;
30 void endStrong() override;
31 void beginEmph() override;
32 void endEmph() override;
33 void beginUnderline() override;
34 void endUnderline() override;
35 void beginStrikeout() override;
36 void endStrikeout() override;
37
38 void beginAnchor(const QString &href = QString(), const QString &name = QString()) override;
39
40 void endAnchor() override;
41
42 void beginParagraph(Qt::Alignment a = Qt::AlignLeft, qreal top = 0.0, qreal bottom = 0.0, qreal left = 0.0, qreal right = 0.0, bool leftToRightText = false)
43 override;
44
45 void endParagraph() override;
46 void addNewline() override;
47
48 void insertHorizontalRule(int width = -1) override;
49
50 void insertImage(const QString &src, qreal width, qreal height) override;
51
52 void beginList(QTextListFormat::Style style) override;
53
54 void endList() override;
55
56 void beginListItem() override;
57
58 void endListItem() override;
59
60 void beginSuperscript() override;
61
62 void endSuperscript() override;
63
64 void beginSubscript() override;
65
66 void endSubscript() override;
67
68 void beginTable(qreal cellpadding, qreal cellspacing, const QString &width) override;
69
70 void beginTableRow() override;
71
72 void beginTableHeaderCell(const QString &width, int colSpan, int rowSpan) override;
73
74 void beginTableCell(const QString &width, int colSpan, int rowSpan) override;
75
76 void appendLiteralText(const QString &text) override;
77
78 void appendRawText(const QString &text) override;
79
80 /**
81 Adds a reference to @p reference to the internal list of references in the
82 document.
83 */
84 [[nodiscard]] int addReference(const QString &reference);
85
86 /**
87 Returns the finalised plain text markup, including references at the end.
88 */
89 [[nodiscard]] QString getResult() override;
90
91 [[nodiscard]] bool isQuoteBlock(qreal top, qreal bottom, qreal left, qreal right) const;
92
93 void beginForeground(const QBrush &brush) override;
94 void endForeground() override;
95 void beginBackground(const QBrush &brush) override;
96 void endBackground() override;
97 void beginFontFamily(const QString &family) override;
98 void endFontFamily() override;
99 void beginFontPointSize(int size) override;
100 void endFontPointSize() override;
101 void endTable() override;
102 void endTableRow() override;
103 void endTableHeaderCell() override;
104 void endTableCell() override;
105 void beginHeader(int level) override;
106 void endHeader(int level) override;
107 void addSingleBreakLine() override;
108
109private:
110 PlainTextMarkupBuilderPrivate *const d_ptr;
111 Q_DECLARE_PRIVATE(PlainTextMarkupBuilder)
112};
113}
Interface for creating marked-up text output.
typedef Alignment
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:55:51 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.