diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-05-01 22:42:49 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-05-02 10:03:57 +0200 |
commit | dd582091bc72ddf61a66d2bc3a3e0ce47f2296b5 (patch) | |
tree | 87c75371e5076b70c9cc09157f4cb88ca45a4ad2 /components/mailviewer | |
parent | 4e416d546a68513f05ef10d41d05e0a9c6d5ecf6 (diff) | |
download | kube-dd582091bc72ddf61a66d2bc3a3e0ce47f2296b5.tar.gz kube-dd582091bc72ddf61a66d2bc3a3e0ce47f2296b5.zip |
Mailviewer
Diffstat (limited to 'components/mailviewer')
-rw-r--r-- | components/mailviewer/contents/ui/EncryptionPart.qml | 14 | ||||
-rw-r--r-- | components/mailviewer/contents/ui/HtmlContent.qml | 2 | ||||
-rw-r--r-- | components/mailviewer/contents/ui/MailDataModel.qml | 86 | ||||
-rw-r--r-- | components/mailviewer/contents/ui/MailPart.qml | 5 | ||||
-rw-r--r-- | components/mailviewer/contents/ui/MailViewer.qml | 5 | ||||
-rw-r--r-- | components/mailviewer/contents/ui/SignaturePart.qml | 11 | ||||
-rw-r--r-- | components/mailviewer/contents/ui/TextContent.qml | 11 |
7 files changed, 89 insertions, 45 deletions
diff --git a/components/mailviewer/contents/ui/EncryptionPart.qml b/components/mailviewer/contents/ui/EncryptionPart.qml index 058c9af7..e72c30f9 100644 --- a/components/mailviewer/contents/ui/EncryptionPart.qml +++ b/components/mailviewer/contents/ui/EncryptionPart.qml | |||
@@ -21,14 +21,16 @@ import QtQuick 2.4 | |||
21 | Item { | 21 | Item { |
22 | id: encryption | 22 | id: encryption |
23 | property alias rootIndex: visualModel.rootIndex | 23 | property alias rootIndex: visualModel.rootIndex |
24 | property bool debug: true | 24 | property alias model: visualModel.model |
25 | property alias debug: visualModel.debug | ||
26 | property variant securityLevel | ||
27 | property variant errorType | ||
28 | property string errorString | ||
25 | height: partListView.height | 29 | height: partListView.height |
26 | width: parent.width | 30 | width: parent.width |
27 | 31 | ||
28 | MailDataModel { | 32 | MailDataModel { |
29 | id: visualModel | 33 | id: visualModel |
30 | debug: encryption.debug | ||
31 | model: messageParser.newTree | ||
32 | } | 34 | } |
33 | 35 | ||
34 | Column { | 36 | Column { |
@@ -45,8 +47,8 @@ Item { | |||
45 | text: model.type | 47 | text: model.type |
46 | } | 48 | } |
47 | Text { | 49 | Text { |
48 | visible: model.errorType || encryption.debug | 50 | visible: errorType || encryption.debug |
49 | text: model.errorType + ": " + model.errorString | 51 | text: errorType + ": " + errorString |
50 | } | 52 | } |
51 | BorderImage { | 53 | BorderImage { |
52 | width: parent.width | 54 | width: parent.width |
@@ -55,7 +57,7 @@ Item { | |||
55 | horizontalTileMode: BorderImage.Round | 57 | horizontalTileMode: BorderImage.Round |
56 | verticalTileMode: BorderImage.Round | 58 | verticalTileMode: BorderImage.Round |
57 | 59 | ||
58 | source: /* "securityborders"+ */ model.securityLevel +".png" | 60 | source: /* "securityborders"+ */ securityLevel +".png" |
59 | ListView { | 61 | ListView { |
60 | model: visualModel | 62 | model: visualModel |
61 | anchors { | 63 | anchors { |
diff --git a/components/mailviewer/contents/ui/HtmlContent.qml b/components/mailviewer/contents/ui/HtmlContent.qml index f3bfb4c9..1946bb2e 100644 --- a/components/mailviewer/contents/ui/HtmlContent.qml +++ b/components/mailviewer/contents/ui/HtmlContent.qml | |||
@@ -23,7 +23,7 @@ import QtWebEngine 1.3 | |||
23 | 23 | ||
24 | Item { | 24 | Item { |
25 | id: root | 25 | id: root |
26 | property string content: model.content | 26 | property string content |
27 | //We have to give it a minimum size so the html content starts to expand | 27 | //We have to give it a minimum size so the html content starts to expand |
28 | property int contentHeight: 10; | 28 | property int contentHeight: 10; |
29 | 29 | ||
diff --git a/components/mailviewer/contents/ui/MailDataModel.qml b/components/mailviewer/contents/ui/MailDataModel.qml index e0e65c49..8a42630a 100644 --- a/components/mailviewer/contents/ui/MailDataModel.qml +++ b/components/mailviewer/contents/ui/MailDataModel.qml | |||
@@ -22,6 +22,27 @@ 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 | delegate: Item { | 46 | delegate: Item { |
26 | id: partColumn | 47 | id: partColumn |
27 | width: parent.width | 48 | width: parent.width |
@@ -36,30 +57,47 @@ DelegateModel { | |||
36 | width: parent.width | 57 | width: parent.width |
37 | } | 58 | } |
38 | Component.onCompleted: { | 59 | Component.onCompleted: { |
39 | switch (model.type) { | 60 | var isHtml = false |
40 | case "PlainTextContent": | 61 | var forcePlain = false |
41 | case "Content": | 62 | var partType = getPartType(model.type, model.hasModelChildren, forcePlain); |
42 | partLoader.source = "TextContent.qml" | 63 | |
43 | partLoader.item.debug = mailDataModel.debug | 64 | switch (partType) { |
44 | return; | 65 | case "plain": |
45 | case "HtmlContent": | 66 | partLoader.setSource("TextContent.qml", |
46 | partLoader.source = "HtmlContent.qml" | 67 | {"isHtml": isHtml, |
47 | return; | 68 | "content": model.content, |
48 | case "Signature": | 69 | "embedded": model.embeded, |
49 | partLoader.source = "SignaturePart.qml" | 70 | "type": model.type, |
50 | partLoader.item.rootIndex = mailDataModel.modelIndex(index) | 71 | "debug": debug}) |
51 | partLoader.item.debug = mailDataModel.debug | 72 | break |
52 | return; | 73 | case "html": |
53 | case "Encryption": | 74 | partLoader.setSource("HtmlContent.qml", |
54 | partLoader.source = "EncryptionPart.qml" | 75 | {"content": model.content, |
55 | partLoader.item.rootIndex = mailDataModel.modelIndex(index) | 76 | "debug": debug}) |
56 | partLoader.item.debug = mailDataModel.debug | 77 | break; |
57 | return; | 78 | case "signature": |
58 | } | 79 | partLoader.setSource("SignaturePart.qml", |
59 | if (model.hasModelChildren) { | 80 | {"rootIndex": mailDataModel.modelIndex(index), |
60 | partLoader.source = "MailPart.qml" | 81 | "securityLevel": model.securityLevel, |
61 | partLoader.item.rootIndex = mailDataModel.modelIndex(index) | 82 | "type": model.type, |
62 | partLoader.item.debug = mailDataModel.debug | 83 | "debug": debug}) |
84 | break; | ||
85 | case "encryption": | ||
86 | partLoader.setSource("EncryptionPart.qml", | ||
87 | {"rootIndex": mailDataModel.modelIndex(index), | ||
88 | "securityLevel": model.securityLevel, | ||
89 | "type": model.type, | ||
90 | "model": mailDataModel.model, | ||
91 | "errorType": model.errorType, | ||
92 | "errorString": model.errorString, | ||
93 | "debug": debug}) | ||
94 | break; | ||
95 | case "envelope": | ||
96 | partLoader.setSource("MailPart.qml", | ||
97 | {"rootIndex": mailDataModel.modelIndex(index), | ||
98 | "model": mailDataModel.model, | ||
99 | "debug": debug}) | ||
100 | break; | ||
63 | } | 101 | } |
64 | } | 102 | } |
65 | } | 103 | } |
diff --git a/components/mailviewer/contents/ui/MailPart.qml b/components/mailviewer/contents/ui/MailPart.qml index 30bf1ee0..bf534e85 100644 --- a/components/mailviewer/contents/ui/MailPart.qml +++ b/components/mailviewer/contents/ui/MailPart.qml | |||
@@ -21,14 +21,13 @@ import QtQuick 2.4 | |||
21 | Item { | 21 | Item { |
22 | id: root | 22 | id: root |
23 | property alias rootIndex: visualModel.rootIndex | 23 | property alias rootIndex: visualModel.rootIndex |
24 | property bool debug: true | 24 | property alias model: visualModel.model |
25 | property alias debug: visualModel.debug | ||
25 | height: partListView.height + 10 | 26 | height: partListView.height + 10 |
26 | width: parent.width | 27 | width: parent.width |
27 | 28 | ||
28 | MailDataModel { | 29 | MailDataModel { |
29 | id: visualModel | 30 | id: visualModel |
30 | debug: root.debug | ||
31 | model: messageParser.newTree | ||
32 | } | 31 | } |
33 | 32 | ||
34 | ListView { | 33 | ListView { |
diff --git a/components/mailviewer/contents/ui/MailViewer.qml b/components/mailviewer/contents/ui/MailViewer.qml index 0f7efca2..23307009 100644 --- a/components/mailviewer/contents/ui/MailViewer.qml +++ b/components/mailviewer/contents/ui/MailViewer.qml | |||
@@ -21,13 +21,12 @@ import QtQuick 2.4 | |||
21 | Item { | 21 | Item { |
22 | id: root | 22 | id: root |
23 | property alias rootIndex: visualModel.rootIndex | 23 | property alias rootIndex: visualModel.rootIndex |
24 | property bool debug: false | 24 | property alias model: visualModel.model |
25 | property alias debug: visualModel.debug | ||
25 | height: partListView.height | 26 | height: partListView.height |
26 | 27 | ||
27 | MailDataModel { | 28 | MailDataModel { |
28 | id: visualModel | 29 | id: visualModel |
29 | debug: root.debug | ||
30 | model: messageParser.newTree | ||
31 | } | 30 | } |
32 | 31 | ||
33 | ListView { | 32 | ListView { |
diff --git a/components/mailviewer/contents/ui/SignaturePart.qml b/components/mailviewer/contents/ui/SignaturePart.qml index 0a2fe525..5e88f963 100644 --- a/components/mailviewer/contents/ui/SignaturePart.qml +++ b/components/mailviewer/contents/ui/SignaturePart.qml | |||
@@ -21,14 +21,15 @@ import QtQuick 2.4 | |||
21 | Item { | 21 | Item { |
22 | id: signature | 22 | id: signature |
23 | property alias rootIndex: visualModel.rootIndex | 23 | property alias rootIndex: visualModel.rootIndex |
24 | property bool debug: true | 24 | property alias model: visualModel.model |
25 | property alias debug: visualModel.debug | ||
26 | property variant securityLevel | ||
27 | property string type | ||
25 | height: partListView.height | 28 | height: partListView.height |
26 | width: parent.width | 29 | width: parent.width |
27 | 30 | ||
28 | MailDataModel { | 31 | MailDataModel { |
29 | id: visualModel | 32 | id: visualModel |
30 | debug: signature.debug | ||
31 | model: messageParser.newTree | ||
32 | } | 33 | } |
33 | Column { | 34 | Column { |
34 | id: partListView | 35 | id: partListView |
@@ -41,7 +42,7 @@ Item { | |||
41 | Text { | 42 | Text { |
42 | width: parent.width | 43 | width: parent.width |
43 | visible: signature.debug | 44 | visible: signature.debug |
44 | text: model.type | 45 | text: type |
45 | } | 46 | } |
46 | BorderImage { | 47 | BorderImage { |
47 | width: parent.width | 48 | width: parent.width |
@@ -49,7 +50,7 @@ Item { | |||
49 | border { left: 5; top: 5; right: 6; bottom: 6 } | 50 | border { left: 5; top: 5; right: 6; bottom: 6 } |
50 | horizontalTileMode: BorderImage.Round | 51 | horizontalTileMode: BorderImage.Round |
51 | verticalTileMode: BorderImage.Round | 52 | verticalTileMode: BorderImage.Round |
52 | source: /* "securityborders"+ */ model.securityLevel +".png" | 53 | source: /* "securityborders"+ */ securityLevel +".png" |
53 | ListView { | 54 | ListView { |
54 | model: visualModel | 55 | model: visualModel |
55 | anchors { | 56 | anchors { |
diff --git a/components/mailviewer/contents/ui/TextContent.qml b/components/mailviewer/contents/ui/TextContent.qml index ec0dc487..63573d81 100644 --- a/components/mailviewer/contents/ui/TextContent.qml +++ b/components/mailviewer/contents/ui/TextContent.qml | |||
@@ -23,7 +23,11 @@ import org.kube.framework 1.0 as Kube | |||
23 | Item { | 23 | Item { |
24 | id: textItem | 24 | id: textItem |
25 | 25 | ||
26 | property string content | ||
26 | property bool debug: true | 27 | property bool debug: true |
28 | property bool embedded: true | ||
29 | property bool isHtml: true | ||
30 | property string type | ||
27 | 31 | ||
28 | width: partColumn.width | 32 | width: partColumn.width |
29 | height: textColumn.height | 33 | height: textColumn.height |
@@ -45,17 +49,18 @@ Item { | |||
45 | readOnly: true | 49 | readOnly: true |
46 | selectByMouse: true | 50 | selectByMouse: true |
47 | 51 | ||
48 | text: model.content | 52 | text: content |
49 | wrapMode: Text.WordWrap | 53 | wrapMode: Text.WordWrap |
54 | textFormat: textItem.isHtml ? Text.RichText : Text.PlainText | ||
50 | 55 | ||
51 | color: model.embeded ? Kube.Colors.diabledTextColor : Kube.Colors.textColor | 56 | color: embedded ? Kube.Colors.diabledTextColor : Kube.Colors.textColor |
52 | } | 57 | } |
53 | 58 | ||
54 | //BEGIN debug | 59 | //BEGIN debug |
55 | Text { | 60 | Text { |
56 | width: parent.width | 61 | width: parent.width |
57 | visible: textItem.debug | 62 | visible: textItem.debug |
58 | text: model.type | 63 | text: type |
59 | } | 64 | } |
60 | //END debug | 65 | //END debug |
61 | } | 66 | } |