summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2016-04-06 07:08:48 +0200
committerMontel Laurent <[email protected]>2016-04-06 07:08:48 +0200
commit964ded9a51caa99087487b859b0f53aea1b1fe89 (patch)
treec7c26a1a72f78302f7921b42dd5f6b1b4b43175a
parent0304dd06a899dec527bfad83e25b9ebdbf696d75 (diff)
Use mailwebenginescript
-rw-r--r--messageviewer/src/viewer/webengine/mailwebengineview.cpp7
-rw-r--r--messageviewer/src/webengine/webenginescript.cpp62
-rw-r--r--messageviewer/src/webengine/webenginescript.h4
3 files changed, 4 insertions, 69 deletions
diff --git a/messageviewer/src/viewer/webengine/mailwebengineview.cpp b/messageviewer/src/viewer/webengine/mailwebengineview.cpp
index dda5ce9..8f87783 100644
--- a/messageviewer/src/viewer/webengine/mailwebengineview.cpp
+++ b/messageviewer/src/viewer/webengine/mailwebengineview.cpp
@@ -19,6 +19,7 @@
#include "mailwebenginepage.h"
#include "webengine/webengineaccesskey/webengineaccesskey.h"
#include "webengine/webenginescript.h"
+#include "mailwebenginescript.h"
#include "messageviewer/messageviewersettings.h"
#include "loadexternalreferencesurlinterceptor/loadexternalreferencesurlinterceptor.h"
#include "cidreferencesurlinterceptor/cidreferencesurlinterceptor.h"
@@ -251,7 +252,7 @@ void MailWebEngineView::injectAttachments(const boost::function<QString()> &dela
if (html.isEmpty()) {
return;
}
- page()->runJavaScript(MessageViewer::WebEngineScript::injectAttachments(html, QStringLiteral("attachmentInjectionPoint")));
+ page()->runJavaScript(MessageViewer::MailWebEngineScript::injectAttachments(html, QStringLiteral("attachmentInjectionPoint")));
}
void MailWebEngineView::toggleFullAddressList(const QString &field, const boost::function<QString()> &delayedHtml, bool doShow)
@@ -262,7 +263,7 @@ void MailWebEngineView::toggleFullAddressList(const QString &field, const boost:
}
qDebug() << "void MailWebEngineView::toggleFullAddressList(const QString &field, const boost::function<QString()> &delayedHtml, bool doShow)" << html << " fields " << field;
- page()->runJavaScript(MessageViewer::WebEngineScript::replaceInnerHtml(field, html, doShow), invoke(this, &MailWebEngineView::updateToggleFullAddressList));
+ page()->runJavaScript(MessageViewer::MailWebEngineScript::replaceInnerHtml(field, html, doShow), invoke(this, &MailWebEngineView::updateToggleFullAddressList));
}
void MailWebEngineView::updateToggleFullAddressList(const QVariant &result)
@@ -275,7 +276,7 @@ void MailWebEngineView::updateToggleFullAddressList(const QVariant &result)
qDebug() << "map !!!! " << map;
const bool show = map.value(QStringLiteral("show")).toBool();
const QString field = map.value(QStringLiteral("field")).toString();
- page()->runJavaScript(MessageViewer::WebEngineScript::updateToggleFullAddressList(field, show));
+ page()->runJavaScript(MessageViewer::MailWebEngineScript::updateToggleFullAddressList(field, show));
}
}
}
diff --git a/messageviewer/src/webengine/webenginescript.cpp b/messageviewer/src/webengine/webenginescript.cpp
index 32a8a93..e9b6bf9 100644
--- a/messageviewer/src/webengine/webenginescript.cpp
+++ b/messageviewer/src/webengine/webenginescript.cpp
@@ -189,65 +189,3 @@ QString WebEngineScript::scrollToRelativePosition(int pos)
const QString source = QString::fromLatin1("window.scrollTo(window.scrollX, %1); [window.scrollX, window.scrollY];").arg(pos);
return source;
}
-
-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);
- qDebug() << "QString WebEngineScript::injectAttachments(const QString &delayedHtml, const QString &elementStr) :" << source;
- return source;
-}
-
-QString WebEngineScript::replaceInnerHtml(const QString &field, const QString &html, bool doShow)
-{
- const QString replaceInnerHtmlStr = QLatin1String("iconFull") + field + QLatin1String("AddressList");
- const QString source = QString::fromLatin1("(function() {"
- "var doShow = %3;"
- "var field = \'%4\';"
- "var out = [];"
- "var element = document.getElementById('%1'); "
- "if (element) { "
- " element.innerHTML = '%2';"
- " out.push({"
- " field: field,"
- " doShow: doShow"
- " });"
- "}"
- "return out;"
- "})()").arg(replaceInnerHtmlStr).arg(html).arg(doShow).arg(field);
- qDebug() << "QString WebEngineScript::replaceInnerHtml(const QString &delayedHtml, const QString &elementStr) :" << source;
- return source;
-
-}
-
-QString WebEngineScript::updateToggleFullAddressList(const QString &field, bool doShow)
-{
- const QString dotsFullStr = QLatin1String("dotsFull") + field + QLatin1String("AddressList");
- const QString hiddenFullStr = QLatin1String("hiddenFull") + field + QLatin1String("AddressList");
- const QString source = QString::fromLatin1(" %1;"
- " %2;")
- .arg(MessageViewer::WebEngineScript::setElementByIdVisible(dotsFullStr, !doShow))
- .arg(MessageViewer::WebEngineScript::setElementByIdVisible(hiddenFullStr, doShow));
- qDebug() << "QString WebEngineScript::updateToggleFullAddressList(const QString &delayedHtml, const QString &elementStr) :" << source;
- return source;
-
-}
-
-QString WebEngineScript::toggleFullAddressList(const QString &field, const QString &html, bool doShow)
-{
- const QString replaceInnerHtmlStr = QLatin1String("iconFull") + field + QLatin1String("AddressList");
- const QString dotsFullStr = QLatin1String("dotsFull") + field + QLatin1String("AddressList");
- const QString hiddenFullStr = QLatin1String("hiddenFull") + field + QLatin1String("AddressList");
- const QString source = QString::fromLatin1("var element = document.getElementById('%1'); "
- "if (element) { "
- " element.innerHTML = '%2';"
- " %3;"
- " %4;"
- "}").arg(replaceInnerHtmlStr).arg(html)
- .arg(MessageViewer::WebEngineScript::setElementByIdVisible(dotsFullStr, !doShow))
- .arg(MessageViewer::WebEngineScript::setElementByIdVisible(hiddenFullStr, doShow));
- qDebug() << "QString WebEngineScript::injectAttachments(const QString &delayedHtml, const QString &elementStr) :" << source;
- return source;
-}
diff --git a/messageviewer/src/webengine/webenginescript.h b/messageviewer/src/webengine/webenginescript.h
index 0858d14..e768d39 100644
--- a/messageviewer/src/webengine/webenginescript.h
+++ b/messageviewer/src/webengine/webenginescript.h
@@ -38,10 +38,6 @@ MESSAGEVIEWER_EXPORT QString scrollUp(int pixel);
MESSAGEVIEWER_EXPORT QString scrollPercentage(int percent);
MESSAGEVIEWER_EXPORT QString scrollToRelativePosition(int pos);
MESSAGEVIEWER_EXPORT QString removeStyleToElement(const QString &element);
-MESSAGEVIEWER_EXPORT QString injectAttachments(const QString &delayedHtml, const QString &element);
-MESSAGEVIEWER_EXPORT QString toggleFullAddressList(const QString &field, const QString &html, bool doShow);
-MESSAGEVIEWER_EXPORT QString replaceInnerHtml(const QString &field, const QString &html, bool doShow);
-MESSAGEVIEWER_EXPORT QString updateToggleFullAddressList(const QString &field, bool doShow);
}
}
#endif // WEBENGINESCRIPT_H