summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-05-01 22:42:49 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-05-02 10:03:57 +0200
commitdd582091bc72ddf61a66d2bc3a3e0ce47f2296b5 (patch)
tree87c75371e5076b70c9cc09157f4cb88ca45a4ad2
parent4e416d546a68513f05ef10d41d05e0a9c6d5ecf6 (diff)
downloadkube-dd582091bc72ddf61a66d2bc3a3e0ce47f2296b5.tar.gz
kube-dd582091bc72ddf61a66d2bc3a3e0ce47f2296b5.zip
Mailviewer
-rw-r--r--components/mailviewer/contents/ui/EncryptionPart.qml14
-rw-r--r--components/mailviewer/contents/ui/HtmlContent.qml2
-rw-r--r--components/mailviewer/contents/ui/MailDataModel.qml86
-rw-r--r--components/mailviewer/contents/ui/MailPart.qml5
-rw-r--r--components/mailviewer/contents/ui/MailViewer.qml5
-rw-r--r--components/mailviewer/contents/ui/SignaturePart.qml11
-rw-r--r--components/mailviewer/contents/ui/TextContent.qml11
-rw-r--r--framework/qml/MailViewer.qml10
-rw-r--r--framework/src/domain/messageparser.cpp5
-rw-r--r--framework/src/domain/messageparser.h2
10 files changed, 101 insertions, 50 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
21Item { 21Item {
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
24Item { 24Item {
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
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 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
21Item { 21Item {
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
21Item { 21Item {
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
21Item { 21Item {
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
23Item { 23Item {
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 }
diff --git a/framework/qml/MailViewer.qml b/framework/qml/MailViewer.qml
index 487da576..01f78fb9 100644
--- a/framework/qml/MailViewer.qml
+++ b/framework/qml/MailViewer.qml
@@ -26,21 +26,23 @@ import org.kube.framework 1.0 as Kube
26Item { 26Item {
27 id: root 27 id: root
28 property variant message; 28 property variant message;
29 property string html;
30 property int desiredHeight: mailViewer.height + 20 29 property int desiredHeight: mailViewer.height + 20
31 property variant attachments 30 property variant attachments: messageParser.attachments
32 31
33 clip: true 32 clip: true
34 33
35 MV.MailViewer { 34 MV.MailViewer {
35 anchors.top: root.top
36 id: mailViewer 36 id: mailViewer
37 model: messageParser.newTree
37 debug: false 38 debug: false
38 width: parent.width 39 width: parent.width
39 } 40 }
40 41
41 Controls1.TreeView { 42 Controls1.TreeView {
42 id: mailStructure 43 id: mailStructure
43 anchors.top: messageParser.attachments.rowCount() > 0 ? attachments.bottom : mailViewer.bottom 44 // anchors.fill: parent
45 // anchors.top: root.attachments.rowCount() > 0 ? attachments.bottom : mailViewer.bottom
44 visible: mailViewer.debug 46 visible: mailViewer.debug
45 width: parent.width 47 width: parent.width
46 height: 400 48 height: 400
@@ -71,6 +73,4 @@ Item {
71 id: messageParser 73 id: messageParser
72 message: root.message 74 message: root.message
73 } 75 }
74 attachments: messageParser.attachments
75 html: messageParser.html
76} 76}
diff --git a/framework/src/domain/messageparser.cpp b/framework/src/domain/messageparser.cpp
index ea2ecbf1..46ffe79d 100644
--- a/framework/src/domain/messageparser.cpp
+++ b/framework/src/domain/messageparser.cpp
@@ -62,6 +62,11 @@ QString MessageParser::html() const
62 return d->mHtml; 62 return d->mHtml;
63} 63}
64 64
65bool MessageParser::isSimpleHtml() const
66{
67 return d->mHtml.contains("foobar");
68}
69
65QVariant MessageParser::message() const 70QVariant MessageParser::message() const
66{ 71{
67 return QVariant(); 72 return QVariant();
diff --git a/framework/src/domain/messageparser.h b/framework/src/domain/messageparser.h
index aeeed93c..2c4febaf 100644
--- a/framework/src/domain/messageparser.h
+++ b/framework/src/domain/messageparser.h
@@ -48,6 +48,7 @@ class MessageParser : public QObject
48 Q_OBJECT 48 Q_OBJECT
49 Q_PROPERTY (QVariant message READ message WRITE setMessage) 49 Q_PROPERTY (QVariant message READ message WRITE setMessage)
50 Q_PROPERTY (QString html READ html NOTIFY htmlChanged) 50 Q_PROPERTY (QString html READ html NOTIFY htmlChanged)
51 Q_PROPERTY (bool isSimpleHtml READ isSimpleHtml NOTIFY htmlChanged)
51 Q_PROPERTY (QAbstractItemModel* partTree READ partTree NOTIFY htmlChanged) 52 Q_PROPERTY (QAbstractItemModel* partTree READ partTree NOTIFY htmlChanged)
52 Q_PROPERTY (QAbstractItemModel* newTree READ newTree NOTIFY htmlChanged) 53 Q_PROPERTY (QAbstractItemModel* newTree READ newTree NOTIFY htmlChanged)
53 Q_PROPERTY (QAbstractItemModel* attachments READ attachments NOTIFY htmlChanged) 54 Q_PROPERTY (QAbstractItemModel* attachments READ attachments NOTIFY htmlChanged)
@@ -57,6 +58,7 @@ public:
57 ~MessageParser(); 58 ~MessageParser();
58 59
59 QString html() const; 60 QString html() const;
61 bool isSimpleHtml() const;
60 62
61 QVariant message() const; 63 QVariant message() const;
62 void setMessage(const QVariant &to); 64 void setMessage(const QVariant &to);