summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2016-04-03 10:12:44 +0200
committerMontel Laurent <[email protected]>2016-04-03 10:12:44 +0200
commit89349f17c00b7e618af5e28491adb8f19a21e518 (patch)
treed05f0f9e5b37bcc056830d9fbe5a8d22e144ef55
parent4c7e0a8bbf4f57a0f134fecf8b6b19dc7ca7e95a (diff)
Try to fix expand all addresslist support
-rw-r--r--messageviewer/src/viewer/webengine/mailwebengineview.cpp17
-rw-r--r--messageviewer/src/viewer/webengine/mailwebengineview.h1
-rw-r--r--messageviewer/src/webengine/webenginescript.cpp22
-rw-r--r--messageviewer/src/webengine/webenginescript.h1
4 files changed, 37 insertions, 4 deletions
diff --git a/messageviewer/src/viewer/webengine/mailwebengineview.cpp b/messageviewer/src/viewer/webengine/mailwebengineview.cpp
index cf00cef..c730d55 100644
--- a/messageviewer/src/viewer/webengine/mailwebengineview.cpp
+++ b/messageviewer/src/viewer/webengine/mailwebengineview.cpp
@@ -262,7 +262,22 @@ 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::toggleFullAddressList(field, html, doShow));
+ page()->runJavaScript(MessageViewer::WebEngineScript::replaceInnerHtml(field, html, doShow), invoke(this, &MailWebEngineView::updateToggleFullAddressList));
+}
+
+void MailWebEngineView::updateToggleFullAddressList(const QVariant &result)
+{
+ qDebug()<<" result" << result;
+ if (result.isValid()) {
+ const QList<QVariant> lst = result.toList();
+ if (lst.count() == 1) {
+ const QVariantMap map = lst.at(0).toMap();
+ 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));
+ }
+ }
}
bool MailWebEngineView::hasVerticalScrollBar() const
diff --git a/messageviewer/src/viewer/webengine/mailwebengineview.h b/messageviewer/src/viewer/webengine/mailwebengineview.h
index 271ae98..d87999b 100644
--- a/messageviewer/src/viewer/webengine/mailwebengineview.h
+++ b/messageviewer/src/viewer/webengine/mailwebengineview.h
@@ -83,6 +83,7 @@ Q_SIGNALS:
private Q_SLOTS:
void handleScrollToAnchor(const QVariant &result);
+ void updateToggleFullAddressList(const QVariant &result);
void slotWebHitFinished(const MessageViewer::WebHitTestResult &result);
void slotLoadFinished();
diff --git a/messageviewer/src/webengine/webenginescript.cpp b/messageviewer/src/webengine/webenginescript.cpp
index 3083a5f..ea64756 100644
--- a/messageviewer/src/webengine/webenginescript.cpp
+++ b/messageviewer/src/webengine/webenginescript.cpp
@@ -203,7 +203,8 @@ QString WebEngineScript::injectAttachments(const QString &delayedHtml, const QSt
QString WebEngineScript::replaceInnerHtml(const QString &field, const QString &html, bool doShow)
{
const QString replaceInnerHtmlStr = QLatin1String("iconFull") + field + QLatin1String("AddressList");
- const QString source = QString::fromLatin1("var doShow = %3;"
+ const QString source = QString::fromLatin1("(function() {"
+ "var doShow = %3;"
"var field = \'%4\';"
"var out = [];"
"var element = document.getElementById('%1'); "
@@ -213,8 +214,23 @@ QString WebEngineScript::replaceInnerHtml(const QString &field, const QString &h
" field: field,"
" doShow: doShow"
" });"
- "}").arg(replaceInnerHtmlStr).arg(html).arg(doShow).arg(field);
- qDebug() << "QString WebEngineScript::injectAttachments(const QString &delayedHtml, const QString &elementStr) :"<<source;
+ "}"
+ "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;
}
diff --git a/messageviewer/src/webengine/webenginescript.h b/messageviewer/src/webengine/webenginescript.h
index 411a601..0858d14 100644
--- a/messageviewer/src/webengine/webenginescript.h
+++ b/messageviewer/src/webengine/webenginescript.h
@@ -41,6 +41,7 @@ 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