diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-05-29 16:17:04 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-06-04 12:57:04 +0200 |
commit | e452707fdfbd61be1e5633b516b653b7337e7865 (patch) | |
tree | 1e1d4b48ebf8d381f292436f2ba04b8763edc5de /components/mailviewer | |
parent | 5a1033bdace740799a6e03389bee30e5a4de5d44 (diff) | |
download | kube-e452707fdfbd61be1e5633b516b653b7337e7865.tar.gz kube-e452707fdfbd61be1e5633b516b653b7337e7865.zip |
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)
Diffstat (limited to 'components/mailviewer')
-rw-r--r-- | components/mailviewer/contents/ui/EncryptionPart.qml | 77 | ||||
-rw-r--r-- | components/mailviewer/contents/ui/ErrorPart.qml (renamed from components/mailviewer/contents/ui/SignaturePart.qml) | 38 | ||||
-rw-r--r-- | components/mailviewer/contents/ui/MailDataModel.qml | 45 |
3 files changed, 11 insertions, 149 deletions
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 @@ | |||
1 | /* | ||
2 | Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net> | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License along | ||
15 | with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | ||
18 | |||
19 | import QtQuick 2.4 | ||
20 | |||
21 | Item { | ||
22 | id: encryption | ||
23 | property alias rootIndex: visualModel.rootIndex | ||
24 | property alias model: visualModel.model | ||
25 | property alias debug: visualModel.debug | ||
26 | property variant securityLevel | ||
27 | property variant errorType | ||
28 | property string errorString | ||
29 | height: partListView.height | ||
30 | width: parent.width | ||
31 | |||
32 | MailDataModel { | ||
33 | id: visualModel | ||
34 | } | ||
35 | |||
36 | Column { | ||
37 | id: partListView | ||
38 | anchors { | ||
39 | top: parent.top | ||
40 | left: parent.left | ||
41 | } | ||
42 | width: parent.width | ||
43 | spacing: 5 | ||
44 | Text { | ||
45 | width: parent.width | ||
46 | visible: encryption.debug | ||
47 | text: model.type | ||
48 | } | ||
49 | Text { | ||
50 | visible: errorType || encryption.debug | ||
51 | text: errorType + ": " + errorString | ||
52 | } | ||
53 | BorderImage { | ||
54 | width: parent.width | ||
55 | height: childrenRect.height + 40 | ||
56 | border { left: 5; top: 5; right: 6; bottom: 6 } | ||
57 | horizontalTileMode: BorderImage.Round | ||
58 | verticalTileMode: BorderImage.Round | ||
59 | |||
60 | source: /* "securityborders"+ */ securityLevel +".png" | ||
61 | ListView { | ||
62 | model: visualModel | ||
63 | anchors { | ||
64 | top: parent.top | ||
65 | left: parent.left | ||
66 | margins: 20 | ||
67 | } | ||
68 | height: contentHeight | ||
69 | width: parent.width - 40 | ||
70 | |||
71 | spacing: 20 | ||
72 | |||
73 | interactive: false | ||
74 | } | ||
75 | } | ||
76 | } | ||
77 | } | ||
diff --git a/components/mailviewer/contents/ui/SignaturePart.qml b/components/mailviewer/contents/ui/ErrorPart.qml index 5e88f963..734d5c5f 100644 --- a/components/mailviewer/contents/ui/SignaturePart.qml +++ b/components/mailviewer/contents/ui/ErrorPart.qml | |||
@@ -1,5 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net> | 2 | Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net> |
3 | Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsys.com> | ||
3 | 4 | ||
4 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
@@ -19,18 +20,12 @@ | |||
19 | import QtQuick 2.4 | 20 | import QtQuick 2.4 |
20 | 21 | ||
21 | Item { | 22 | Item { |
22 | id: signature | 23 | id: root |
23 | property alias rootIndex: visualModel.rootIndex | 24 | property variant errorType |
24 | property alias model: visualModel.model | 25 | property string errorString |
25 | property alias debug: visualModel.debug | ||
26 | property variant securityLevel | ||
27 | property string type | ||
28 | height: partListView.height | 26 | height: partListView.height |
29 | width: parent.width | 27 | width: parent.width |
30 | 28 | ||
31 | MailDataModel { | ||
32 | id: visualModel | ||
33 | } | ||
34 | Column { | 29 | Column { |
35 | id: partListView | 30 | id: partListView |
36 | anchors { | 31 | anchors { |
@@ -40,30 +35,7 @@ Item { | |||
40 | width: parent.width | 35 | width: parent.width |
41 | spacing: 5 | 36 | spacing: 5 |
42 | Text { | 37 | Text { |
43 | width: parent.width | 38 | text: "An error occured: " + errorString |
44 | visible: signature.debug | ||
45 | text: type | ||
46 | } | ||
47 | BorderImage { | ||
48 | width: parent.width | ||
49 | height: childrenRect.height + 40 | ||
50 | border { left: 5; top: 5; right: 6; bottom: 6 } | ||
51 | horizontalTileMode: BorderImage.Round | ||
52 | verticalTileMode: BorderImage.Round | ||
53 | source: /* "securityborders"+ */ securityLevel +".png" | ||
54 | ListView { | ||
55 | model: visualModel | ||
56 | anchors { | ||
57 | top: parent.top | ||
58 | left: parent.left | ||
59 | margins: 20 | ||
60 | } | ||
61 | height: contentHeight | ||
62 | width: parent.width - 40 | ||
63 | |||
64 | spacing: 20 | ||
65 | interactive: false | ||
66 | } | ||
67 | } | 39 | } |
68 | } | 40 | } |
69 | } | 41 | } |
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 | |||
22 | DelegateModel { | 22 | DelegateModel { |
23 | id: mailDataModel | 23 | id: mailDataModel |
24 | property bool debug: true | 24 | property bool debug: true |
25 | function getPartType(type, hasModelChildren, forcePlain) { | ||
26 | switch (type) { | ||
27 | case "PlainTextContent": | ||
28 | case "Content": | ||
29 | return "plain"; | ||
30 | case "HtmlContent": | ||
31 | if (forcePlain) { | ||
32 | return "plain"; | ||
33 | } | ||
34 | return "html"; | ||
35 | case "Signature": | ||
36 | return "signature"; | ||
37 | case "Encryption": | ||
38 | return "encryption"; | ||
39 | } | ||
40 | if (hasModelChildren) { | ||
41 | return "envelope"; | ||
42 | } | ||
43 | return ""; | ||
44 | } | ||
45 | 25 | ||
46 | delegate: Item { | 26 | delegate: Item { |
47 | id: partColumn | 27 | id: partColumn |
@@ -57,40 +37,27 @@ DelegateModel { | |||
57 | width: parent.width | 37 | width: parent.width |
58 | } | 38 | } |
59 | Component.onCompleted: { | 39 | Component.onCompleted: { |
60 | //If the content is not complex, avoid using a full browser | 40 | switch (model.type) { |
61 | var forcePlain = !model.complexHtmlContent | ||
62 | var partType = getPartType(model.type, model.hasModelChildren, forcePlain); | ||
63 | |||
64 | switch (partType) { | ||
65 | case "plain": | 41 | case "plain": |
66 | partLoader.setSource("TextContent.qml", | 42 | partLoader.setSource("TextContent.qml", |
67 | {"content": model.content, | 43 | {"content": model.content, |
68 | "embedded": model.embeded, | 44 | "embedded": model.embeded, |
45 | "securityLevel": model.securityLevel, | ||
69 | "type": model.type, | 46 | "type": model.type, |
70 | "debug": debug}) | 47 | "debug": debug}) |
71 | break | 48 | break |
72 | case "html": | 49 | case "html": |
73 | partLoader.setSource("HtmlContent.qml", | 50 | partLoader.setSource("HtmlContent.qml", |
74 | {"content": model.content, | 51 | {"content": model.content, |
75 | "debug": debug}) | ||
76 | break; | ||
77 | case "signature": | ||
78 | partLoader.setSource("SignaturePart.qml", | ||
79 | {"rootIndex": mailDataModel.modelIndex(index), | ||
80 | "securityLevel": model.securityLevel, | 52 | "securityLevel": model.securityLevel, |
81 | "model": mailDataModel.model, | ||
82 | "type": model.type, | ||
83 | "debug": debug}) | 53 | "debug": debug}) |
84 | break; | 54 | break; |
85 | case "encryption": | 55 | case "error": |
86 | partLoader.setSource("EncryptionPart.qml", | 56 | partLoader.setSource("ErrorPart.qml", |
87 | {"rootIndex": mailDataModel.modelIndex(index), | 57 | { |
88 | "securityLevel": model.securityLevel, | ||
89 | "type": model.type, | ||
90 | "model": mailDataModel.model, | ||
91 | "errorType": model.errorType, | 58 | "errorType": model.errorType, |
92 | "errorString": model.errorString, | 59 | "errorString": model.errorString, |
93 | "debug": debug}) | 60 | }) |
94 | break; | 61 | break; |
95 | case "envelope": | 62 | case "envelope": |
96 | partLoader.setSource("MailPart.qml", | 63 | partLoader.setSource("MailPart.qml", |