From e452707fdfbd61be1e5633b516b653b7337e7865 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 29 May 2017 16:17:04 +0200 Subject: Reduced the messagetreeparser to aproximately what we actually require While in a much more managable state it's still not pretty. However, further refactoring can now gradually happen as we need to do further work on it. Things that should happen eventually: * Simplify the logic that creates the messageparts (we don't need the whole formatter plugin complexity) * Get rid of the nodehelper (let the parts hold the necessary data) * Get rid of partmetadata (let the part handleit) --- .../mailviewer/contents/ui/EncryptionPart.qml | 77 ---------------------- components/mailviewer/contents/ui/ErrorPart.qml | 41 ++++++++++++ .../mailviewer/contents/ui/MailDataModel.qml | 45 ++----------- .../mailviewer/contents/ui/SignaturePart.qml | 69 ------------------- 4 files changed, 47 insertions(+), 185 deletions(-) delete mode 100644 components/mailviewer/contents/ui/EncryptionPart.qml create mode 100644 components/mailviewer/contents/ui/ErrorPart.qml delete mode 100644 components/mailviewer/contents/ui/SignaturePart.qml (limited to 'components/mailviewer') diff --git a/components/mailviewer/contents/ui/EncryptionPart.qml b/components/mailviewer/contents/ui/EncryptionPart.qml deleted file mode 100644 index e72c30f9..00000000 --- a/components/mailviewer/contents/ui/EncryptionPart.qml +++ /dev/null @@ -1,77 +0,0 @@ -/* - Copyright (C) 2016 Michael Bohlender, - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -import QtQuick 2.4 - -Item { - id: encryption - property alias rootIndex: visualModel.rootIndex - property alias model: visualModel.model - property alias debug: visualModel.debug - property variant securityLevel - property variant errorType - property string errorString - height: partListView.height - width: parent.width - - MailDataModel { - id: visualModel - } - - Column { - id: partListView - anchors { - top: parent.top - left: parent.left - } - width: parent.width - spacing: 5 - Text { - width: parent.width - visible: encryption.debug - text: model.type - } - Text { - visible: errorType || encryption.debug - text: errorType + ": " + errorString - } - BorderImage { - width: parent.width - height: childrenRect.height + 40 - border { left: 5; top: 5; right: 6; bottom: 6 } - horizontalTileMode: BorderImage.Round - verticalTileMode: BorderImage.Round - - source: /* "securityborders"+ */ securityLevel +".png" - ListView { - model: visualModel - anchors { - top: parent.top - left: parent.left - margins: 20 - } - height: contentHeight - width: parent.width - 40 - - spacing: 20 - - interactive: false - } - } - } -} diff --git a/components/mailviewer/contents/ui/ErrorPart.qml b/components/mailviewer/contents/ui/ErrorPart.qml new file mode 100644 index 00000000..734d5c5f --- /dev/null +++ b/components/mailviewer/contents/ui/ErrorPart.qml @@ -0,0 +1,41 @@ +/* + Copyright (C) 2016 Michael Bohlender, + Copyright (C) 2017 Christian Mollekopf, + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +import QtQuick 2.4 + +Item { + id: root + property variant errorType + property string errorString + height: partListView.height + width: parent.width + + Column { + id: partListView + anchors { + top: parent.top + left: parent.left + } + width: parent.width + spacing: 5 + Text { + text: "An error occured: " + errorString + } + } +} diff --git a/components/mailviewer/contents/ui/MailDataModel.qml b/components/mailviewer/contents/ui/MailDataModel.qml index 6a4beda5..99bd0dc2 100644 --- a/components/mailviewer/contents/ui/MailDataModel.qml +++ b/components/mailviewer/contents/ui/MailDataModel.qml @@ -22,26 +22,6 @@ import QtQml.Models 2.2 DelegateModel { id: mailDataModel property bool debug: true - function getPartType(type, hasModelChildren, forcePlain) { - switch (type) { - case "PlainTextContent": - case "Content": - return "plain"; - case "HtmlContent": - if (forcePlain) { - return "plain"; - } - return "html"; - case "Signature": - return "signature"; - case "Encryption": - return "encryption"; - } - if (hasModelChildren) { - return "envelope"; - } - return ""; - } delegate: Item { id: partColumn @@ -57,40 +37,27 @@ DelegateModel { width: parent.width } Component.onCompleted: { - //If the content is not complex, avoid using a full browser - var forcePlain = !model.complexHtmlContent - var partType = getPartType(model.type, model.hasModelChildren, forcePlain); - - switch (partType) { + switch (model.type) { case "plain": partLoader.setSource("TextContent.qml", {"content": model.content, "embedded": model.embeded, + "securityLevel": model.securityLevel, "type": model.type, "debug": debug}) break case "html": partLoader.setSource("HtmlContent.qml", {"content": model.content, - "debug": debug}) - break; - case "signature": - partLoader.setSource("SignaturePart.qml", - {"rootIndex": mailDataModel.modelIndex(index), "securityLevel": model.securityLevel, - "model": mailDataModel.model, - "type": model.type, "debug": debug}) break; - case "encryption": - partLoader.setSource("EncryptionPart.qml", - {"rootIndex": mailDataModel.modelIndex(index), - "securityLevel": model.securityLevel, - "type": model.type, - "model": mailDataModel.model, + case "error": + partLoader.setSource("ErrorPart.qml", + { "errorType": model.errorType, "errorString": model.errorString, - "debug": debug}) + }) break; case "envelope": partLoader.setSource("MailPart.qml", diff --git a/components/mailviewer/contents/ui/SignaturePart.qml b/components/mailviewer/contents/ui/SignaturePart.qml deleted file mode 100644 index 5e88f963..00000000 --- a/components/mailviewer/contents/ui/SignaturePart.qml +++ /dev/null @@ -1,69 +0,0 @@ -/* - Copyright (C) 2016 Michael Bohlender, - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -import QtQuick 2.4 - -Item { - id: signature - property alias rootIndex: visualModel.rootIndex - property alias model: visualModel.model - property alias debug: visualModel.debug - property variant securityLevel - property string type - height: partListView.height - width: parent.width - - MailDataModel { - id: visualModel - } - Column { - id: partListView - anchors { - top: parent.top - left: parent.left - } - width: parent.width - spacing: 5 - Text { - width: parent.width - visible: signature.debug - text: type - } - BorderImage { - width: parent.width - height: childrenRect.height + 40 - border { left: 5; top: 5; right: 6; bottom: 6 } - horizontalTileMode: BorderImage.Round - verticalTileMode: BorderImage.Round - source: /* "securityborders"+ */ securityLevel +".png" - ListView { - model: visualModel - anchors { - top: parent.top - left: parent.left - margins: 20 - } - height: contentHeight - width: parent.width - 40 - - spacing: 20 - interactive: false - } - } - } -} -- cgit v1.2.3