Commit 89349f17 authored by Laurent Montel's avatar Laurent Montel 😁

Try to fix expand all addresslist support

parent 4c7e0a8b
......@@ -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
......
......@@ -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();
......
......@@ -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;
}
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment