Commit ba7e669b authored by Laurent Montel's avatar Laurent Montel 😁

Try to replace by jquery

parent 6f6899bc
......@@ -2787,10 +2787,10 @@ QString ViewerPrivate::recipientsQuickListLinkHtml(bool doShow, const QString &f
{
const QString imgpath(picsPath());
const QString urlHandleShow = QLatin1String("kmail:hideFull") + field + QLatin1String("AddressList");
const QString imgSrcShow = QLatin1String("quicklistOpened.png");
const QString imgSrcShow = QStringLiteral("quicklistOpened.png");
const QString altTextShow = i18n("Hide full address list");
const QString urlHandleHide = QLatin1String("kmail:showFull") + field + QLatin1String("AddressList");
const QString imgSrcHide = QLatin1String("quicklistClosed.png");
const QString imgSrcHide = QStringLiteral("quicklistClosed.png");
const QString altTextHide = i18n("Show full address list");
const QString visibility = QStringLiteral("style=\"display:none;\"");
......@@ -2807,7 +2807,7 @@ QString ViewerPrivate::recipientsQuickListLinkHtml(bool doShow, const QString &f
void ViewerPrivate::toggleFullAddressList(const QString &field)
{
const bool doShow = (field == QLatin1String("To") && showFullToAddressList()) || (field == QLatin1String("Cc") && showFullCcAddressList());
mViewer->toggleFullAddressList(field, bind(&ViewerPrivate::recipientsQuickListLinkHtml, this, doShow, field), doShow);
mViewer->toggleFullAddressList(field, bind(&ViewerPrivate::recipientsQuickListLinkHtml, this, doShow, field));
}
void ViewerPrivate::itemFetchResult(KJob *job)
......
......@@ -43,9 +43,10 @@ QString MailWebEngineScript::injectAttachments(const QString &delayedHtml, const
return source;
}
QString MailWebEngineScript::replaceInnerHtml(const QString &field, const QString &html, bool doShow)
QString MailWebEngineScript::replaceInnerHtml(const QString &field, const QString &html)
{
const QString replaceInnerHtmlStr = QLatin1String("iconFull") + field + QLatin1String("AddressList");
#if 0
const QString source = QString::fromLatin1("(function() {"
"var doShow = %3;"
"var field = \'%4\';"
......@@ -60,11 +61,14 @@ QString MailWebEngineScript::replaceInnerHtml(const QString &field, const QStrin
"}"
"return out;"
"})()").arg(replaceInnerHtmlStr).arg(html).arg(doShow).arg(field);
#endif
const QString source = QString::fromLatin1("qt.jQuery('#%1').append('%2')").arg(replaceInnerHtmlStr).arg(html);
qDebug() << "QString MailWebEngineScript::replaceInnerHtml(const QString &delayedHtml, const QString &elementStr) :" << source;
return source;
return source;
}
#if 0
QString MailWebEngineScript::updateToggleFullAddressList(const QString &field, bool doShow)
{
const QString dotsFullStr = QLatin1String("dotsFull") + field + QLatin1String("AddressList");
......@@ -75,7 +79,6 @@ QString MailWebEngineScript::updateToggleFullAddressList(const QString &field, b
.arg(WebEngineViewer::WebEngineScript::setElementByIdVisible(hiddenFullStr, doShow));
qDebug() << "QString MailWebEngineScript::updateToggleFullAddressList(const QString &delayedHtml, const QString &elementStr) :" << source;
return source;
}
QString MailWebEngineScript::toggleFullAddressList(const QString &field, const QString &html, bool doShow)
......@@ -94,4 +97,5 @@ QString MailWebEngineScript::toggleFullAddressList(const QString &field, const Q
qDebug() << "QString MailWebEngineScript::injectAttachments(const QString &delayedHtml, const QString &elementStr) :" << source;
return source;
}
#endif
......@@ -28,9 +28,9 @@ namespace MessageViewer
namespace MailWebEngineScript
{
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);
//MESSAGEVIEWER_EXPORT QString toggleFullAddressList(const QString &field, const QString &html, bool doShow);
MESSAGEVIEWER_EXPORT QString replaceInnerHtml(const QString &field, const QString &html);
//MESSAGEVIEWER_EXPORT QString updateToggleFullAddressList(const QString &field, bool doShow);
MESSAGEVIEWER_EXPORT QString manageShowHideAttachments();
}
}
......
......@@ -289,7 +289,7 @@ void MailWebEngineView::injectAttachments(const boost::function<QString()> &dela
page()->runJavaScript(MessageViewer::MailWebEngineScript::injectAttachments(html, QStringLiteral("attachmentInjectionPoint")));
}
void MailWebEngineView::toggleFullAddressList(const QString &field, const boost::function<QString()> &delayedHtml, bool doShow)
void MailWebEngineView::toggleFullAddressList(const QString &field, const boost::function<QString()> &delayedHtml)
{
const QString html = delayedHtml();
if (html.isEmpty()) {
......@@ -297,22 +297,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::MailWebEngineScript::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::MailWebEngineScript::updateToggleFullAddressList(field, show));
}
}
page()->runJavaScript(MessageViewer::MailWebEngineScript::replaceInnerHtml(field, html));
}
bool MailWebEngineView::hasVerticalScrollBar() const
......
......@@ -63,7 +63,7 @@ public:
void setAllowExternalContent(bool b);
QList<QAction *> interceptorUrlActions(const WebEngineViewer::WebHitTestResult &result) const;
void toggleFullAddressList(const QString &field, const boost::function<QString()> &delayedHtml, bool doShow);
void toggleFullAddressList(const QString &field, const boost::function<QString()> &delayedHtml);
void manageShowHideAttachments();
public Q_SLOTS:
......@@ -95,7 +95,6 @@ Q_SIGNALS:
private Q_SLOTS:
void handleScrollToAnchor(const QVariant &result);
void updateToggleFullAddressList(const QVariant &result);
void slotWebHitFinished(const WebEngineViewer::WebHitTestResult &result);
void slotLoadFinished();
......
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