summaryrefslogtreecommitdiffstats
path: root/components/mailviewer/contents/ui/MailDataModel.qml
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-05-29 16:17:04 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-06-04 12:57:04 +0200
commite452707fdfbd61be1e5633b516b653b7337e7865 (patch)
tree1e1d4b48ebf8d381f292436f2ba04b8763edc5de /components/mailviewer/contents/ui/MailDataModel.qml
parent5a1033bdace740799a6e03389bee30e5a4de5d44 (diff)
downloadkube-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/contents/ui/MailDataModel.qml')
-rw-r--r--components/mailviewer/contents/ui/MailDataModel.qml45
1 files changed, 6 insertions, 39 deletions
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
22DelegateModel { 22DelegateModel {
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",