7#include "templateparserextracthtmlinfo.h"
8#include "templateextracthtmlelementfrommail.h"
9#include "templateextracttextfrommail.h"
10#include "templateparser_debug.h"
12using namespace TemplateParser;
14TemplateParserExtractHtmlInfo::TemplateParserExtractHtmlInfo(
QObject *parent)
19TemplateParserExtractHtmlInfo::~TemplateParserExtractHtmlInfo()
21 if (mTemplateWebEngineView) {
24 if (mExtractHtmlElementWebEngineView) {
29void TemplateParserExtractHtmlInfo::setHtmlForExtractingTextPlain(
const QString &html)
31 mHtmlForExtractingTextPlain = html;
34void TemplateParserExtractHtmlInfo::setHtmlForExtractionHeaderAndBody(
const QString &html)
36 mHtmlForExtractionHeaderAndBody = html;
39void TemplateParserExtractHtmlInfo::setTemplate(
const QString &str)
44void TemplateParserExtractHtmlInfo::start()
47 mResult.mTemplate = mTemplateStr;
48 if (!mHtmlForExtractingTextPlain.
isEmpty()) {
50 connect(mTemplateWebEngineView, &TemplateExtractTextFromMail::loadContentDone,
this, &TemplateParserExtractHtmlInfo::slotExtractToPlainTextFinished);
51 mTemplateWebEngineView->setHtmlContent(mHtmlForExtractingTextPlain);
53 qCDebug(TEMPLATEPARSER_LOG) <<
"html string is empty for extracting to plainText";
54 slotExtractToPlainTextFinished(
false);
58void TemplateParserExtractHtmlInfo::slotExtractToPlainTextFinished(
bool success)
61 mResult.mPlainText = mTemplateWebEngineView->plainText();
63 qCDebug(TEMPLATEPARSER_LOG) <<
"Impossible to extract plaintext";
65 if (!mHtmlForExtractionHeaderAndBody.
isEmpty()) {
66 mExtractHtmlElementWebEngineView =
new TemplateExtractHtmlElementFromMail;
67 connect(mExtractHtmlElementWebEngineView,
68 &TemplateExtractHtmlElementFromMail::loadContentDone,
70 &TemplateParserExtractHtmlInfo::slotExtractHtmlElementFinished);
71 mExtractHtmlElementWebEngineView->setHtmlContent(mHtmlForExtractionHeaderAndBody);
73 qCDebug(TEMPLATEPARSER_LOG) <<
"html string is empty for extracting to header and body";
74 slotExtractHtmlElementFinished(
false);
78void TemplateParserExtractHtmlInfo::slotExtractHtmlElementFinished(
bool success)
81 mResult.mBodyElement = mExtractHtmlElementWebEngineView->bodyElement();
82 mResult.mHeaderElement = mExtractHtmlElementWebEngineView->headerElement();
83 mResult.mHtmlElement = mExtractHtmlElementWebEngineView->htmlElement();
85 qCDebug(TEMPLATEPARSER_LOG) <<
"Impossible to extract html element";
91#include "moc_templateparserextracthtmlinfo.cpp"
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool isEmpty() const const