From e7b821c4308c6ed15daed911184980149cce38ff Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 23 May 2017 10:30:21 +0200 Subject: Always use richtext, and avoid using a browser for simple html --- framework/qml/MailViewer.qml | 2 +- framework/src/domain/messageparser.h | 1 + framework/src/domain/messageparser_new.cpp | 28 +++++++++++++++++++++++++++- 3 files changed, 29 insertions(+), 2 deletions(-) (limited to 'framework') diff --git a/framework/qml/MailViewer.qml b/framework/qml/MailViewer.qml index 01f78fb9..3e118a8d 100644 --- a/framework/qml/MailViewer.qml +++ b/framework/qml/MailViewer.qml @@ -16,7 +16,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import QtQuick 2.4 +import QtQuick 2.7 import QtQuick.Controls 1.4 as Controls1 import QtQuick.Layouts 1.1 diff --git a/framework/src/domain/messageparser.h b/framework/src/domain/messageparser.h index 6d52c4b2..de4d8838 100644 --- a/framework/src/domain/messageparser.h +++ b/framework/src/domain/messageparser.h @@ -70,6 +70,7 @@ public: TypeRole = Qt::UserRole + 1, ContentsRole, ContentRole, + IsComplexHtmlContentRole, IsEmbededRole, SecurityLevelRole, EncryptionErrorType, diff --git a/framework/src/domain/messageparser_new.cpp b/framework/src/domain/messageparser_new.cpp index cb399523..c353becf 100644 --- a/framework/src/domain/messageparser_new.cpp +++ b/framework/src/domain/messageparser_new.cpp @@ -21,6 +21,7 @@ #include "mimetreeparser/interface.h" #include +#include Q_DECLARE_METATYPE(Part *) Q_DECLARE_METATYPE(Content *) @@ -315,6 +316,7 @@ QHash NewModel::roleNames() const QHash roles; roles[TypeRole] = "type"; roles[ContentRole] = "content"; + roles[IsComplexHtmlContentRole] = "complexHtmlContent"; roles[IsEmbededRole] = "embeded"; roles[SecurityLevelRole] = "securityLevel"; roles[EncryptionErrorType] = "errorType"; @@ -422,9 +424,30 @@ QVariant NewModel::data(const QModelIndex &index, int role) const return QString::fromLatin1(content->type()); case IsEmbededRole: return data(index.parent(), IsEmbededRole); + case IsComplexHtmlContentRole: { + const auto contentType = data(index, TypeRole).toString(); + if (contentType == "HtmlContent") { + const auto text = content->encodedContent(); + if (text.contains("encodedContent(); - if (data(index, TypeRole).toString() == "HtmlContent") { + const auto contentType = data(index, TypeRole).toString(); + if (contentType == "HtmlContent") { const auto rx = QRegExp("(src)\\s*=\\s*(\"|')(cid:[^\"']+)\\2"); int pos = 0; while ((pos = rx.indexIn(text, pos)) != -1) { @@ -445,6 +468,9 @@ QVariant NewModel::data(const QModelIndex &index, int role) const text.replace(rx.cap(0), QString("src=\"data:%1;base64,%2\"").arg(mimetype, QString::fromLatin1(data.toBase64()))); } } + } else { //We assume plain + //We alwas do richtext (so we get highlighted links and stuff). + return Qt::convertFromPlainText(text); } return text; } -- cgit v1.2.3