Messagelib
8#include "converthtmltoplaintext.h"
10#include <KPIMTextEdit/MarkupDirector>
11#include <KPIMTextEdit/PlainTextMarkupBuilder>
12#include <QTextDocument>
14using namespace MimeTreeParser;
15ConvertHtmlToPlainText::ConvertHtmlToPlainText() =
default;
17ConvertHtmlToPlainText::~ConvertHtmlToPlainText() =
default;
19void ConvertHtmlToPlainText::setHtmlString(
const QString &htmlString)
21 mHtmlString = htmlString;
24QString ConvertHtmlToPlainText::generatePlainText()
26 if (mHtmlString.isEmpty()) {
29 auto pb =
new KPIMTextEdit::PlainTextMarkupBuilder();
31 auto pmd =
new KPIMTextEdit::MarkupDirector(pb);
32 auto doc =
new QTextDocument;
33 doc->setHtml(mHtmlString);
35 pmd->processDocument(doc);
36 QString plainText = pb->getResult();
41 toCleanPlainText(plainText);
45QString ConvertHtmlToPlainText::htmlString()
const
51void ConvertHtmlToPlainText::toCleanPlainText(QString &text)
58 text.remove(QChar(0xFFFC));
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:47:40 by
doxygen 1.13.2 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.