summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2016-04-02 11:20:53 +0200
committerMontel Laurent <[email protected]>2016-04-02 11:20:53 +0200
commit7f6a15b855c00ac0b34817176b2da29afe3d14d1 (patch)
tree8a87cdc875746ffc248dd342632e731d9c89eb0d
parent40bcd0f744786ef6c3aff8718703ac10b9f7b608 (diff)
Add more javascript script
-rw-r--r--messageviewer/src/viewer/webengine/mailwebengineview.cpp16
-rw-r--r--messageviewer/src/webengine/webenginescript.cpp9
-rw-r--r--messageviewer/src/webengine/webenginescript.h1
3 files changed, 13 insertions, 13 deletions
diff --git a/messageviewer/src/viewer/webengine/mailwebengineview.cpp b/messageviewer/src/viewer/webengine/mailwebengineview.cpp
index e40a8ad..bd0c102 100644
--- a/messageviewer/src/viewer/webengine/mailwebengineview.cpp
+++ b/messageviewer/src/viewer/webengine/mailwebengineview.cpp
@@ -259,22 +259,12 @@ void MailWebEngineView::scrollPageUp(int percent)
void MailWebEngineView::injectAttachments(const boost::function<QString()> &delayedHtml)
{
const QString html = delayedHtml();
- qDebug()<<" void MailWebEngineView::injectAttachments(const boost::function<QString()> &delayedHtml) not implemented " << delayedHtml;
if (html.isEmpty()) {
return;
}
- //TODO
-#if 0
- QWebElement doc = page()->currentFrame()->documentElement();
- QWebElement injectionPoint = doc.findFirst(QStringLiteral("*#attachmentInjectionPoint"));
- if (injectionPoint.isNull()) {
- return;
- }
-
-
- assert(injectionPoint.tagName().toLower() == QLatin1String("div"));
- injectionPoint.setInnerXml(html)
-#endif
+ qDebug()<<" void MailWebEngineView::injectAttachments(const boost::function<QString()> &delayedHtml) " << html;
+ //TODO verify
+ page()->runJavaScript(MessageViewer::WebEngineScript::injectAttachments(html, QStringLiteral("*#attachmentInjectionPoint")));
}
bool MailWebEngineView::replaceInnerHtml(const QString &id, const boost::function<QString()> &delayedHtml)
diff --git a/messageviewer/src/webengine/webenginescript.cpp b/messageviewer/src/webengine/webenginescript.cpp
index 1aa73fe..aa71eba 100644
--- a/messageviewer/src/webengine/webenginescript.cpp
+++ b/messageviewer/src/webengine/webenginescript.cpp
@@ -187,3 +187,12 @@ QString WebEngineScript::replaceInnerHtml()
//TODO
return {};
}
+
+QString WebEngineScript::injectAttachments(const QString &delayedHtml, const QString &elementStr)
+{
+ const QString source = QString::fromLatin1("var element = document.getElementById('%1'); "
+ "if (element) { "
+ " element.innerHTML = '%2';"
+ "}").arg(elementStr).arg(delayedHtml);
+ return source;
+}
diff --git a/messageviewer/src/webengine/webenginescript.h b/messageviewer/src/webengine/webenginescript.h
index cdee3c4..dff856a 100644
--- a/messageviewer/src/webengine/webenginescript.h
+++ b/messageviewer/src/webengine/webenginescript.h
@@ -39,6 +39,7 @@ MESSAGEVIEWER_EXPORT QString scrollPercentage(int percent);
MESSAGEVIEWER_EXPORT QString scrollToRelativePosition(int pos);
MESSAGEVIEWER_EXPORT QString removeStyleToElement(const QString &element);
MESSAGEVIEWER_EXPORT QString replaceInnerHtml();
+MESSAGEVIEWER_EXPORT QString injectAttachments(const QString &delayedHtml, const QString &element);
}
}
#endif // WEBENGINESCRIPT_H