summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/package/contents/ui/ContentView.qml60
-rw-r--r--components/package/contents/ui/MailViewer.qml27
-rw-r--r--components/package/contents/ui/MessagePartTree.qml89
-rw-r--r--components/package/contents/ui/TextView.qml32
-rw-r--r--components/package/contents/ui/WebView.qml55
5 files changed, 4 insertions, 259 deletions
diff --git a/components/package/contents/ui/ContentView.qml b/components/package/contents/ui/ContentView.qml
deleted file mode 100644
index 099d5c5d..00000000
--- a/components/package/contents/ui/ContentView.qml
+++ /dev/null
@@ -1,60 +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
19import QtQuick 2.4
20import QtQuick.Controls 1.3
21
22Item {
23 id: root
24 property int nestingLevel;
25 property bool isHtml;
26 property string content;
27 property string contentType;
28 property int contentWidth: contentLoader.item.contentWidth
29 property int contentHeight: contentLoader.item.contentHeight
30 Rectangle {
31 id: contentRect
32
33 //Only for development
34 // border.width: 1
35 // border.color: "black"
36 // radius: 5
37 // anchors.leftMargin: nestingLevel * 5
38 anchors.fill: parent
39
40 Loader {
41 id: contentLoader
42 property string content: root.content
43 anchors.fill: parent
44 sourceComponent: isHtml ? htmlComponent : textComponent
45 }
46
47 Component {
48 id: textComponent
49 TextView {
50 content: root.content
51 }
52 }
53 Component {
54 id: htmlComponent
55 WebView {
56 content: root.content
57 }
58 }
59 }
60}
diff --git a/components/package/contents/ui/MailViewer.qml b/components/package/contents/ui/MailViewer.qml
index 150ee5aa..4ee170bd 100644
--- a/components/package/contents/ui/MailViewer.qml
+++ b/components/package/contents/ui/MailViewer.qml
@@ -27,40 +27,21 @@ Item {
27 id: root 27 id: root
28 property variant message; 28 property variant message;
29 property string html; 29 property string html;
30 property int desiredHeight: topPartLoader.height + newMailViewer.height + 20 30 property int desiredHeight: mailViewer.height + 20
31 property variant attachments 31 property variant attachments
32 32
33 clip: true 33 clip: true
34 34
35 MV.MailViewer { 35 MV.MailViewer {
36 id: newMailViewer 36 id: mailViewer
37 debug: false 37 debug: false
38 width: parent.width 38 width: parent.width
39 } 39 }
40 40
41 //BEGIN old mail viewer
42
43 MessagePartTree {
44 id: topPartLoader
45 anchors.top: newMailViewer.bottom
46
47 Text {
48 text: "old mailviewer"
49 color: "blue"
50 }
51
52 visible: false
53 // width: parent.width
54 height: topPartLoader.contentHeight
55 width: topPartLoader.contentWidth >= parent.width ? topPartLoader.contentWidth : parent.width
56 }
57
58 //END old mail viewer
59
60 Controls1.TreeView { 41 Controls1.TreeView {
61 id: mailStructure 42 id: mailStructure
62 anchors.top: messageParser.attachments.rowCount() > 0 ? attachments.bottom : newMailViewer.bottom 43 anchors.top: messageParser.attachments.rowCount() > 0 ? attachments.bottom : mailViewer.bottom
63 visible: newMailViewer.debug 44 visible: mailViewer.debug
64 width: parent.width 45 width: parent.width
65 height: 400 46 height: 400
66 Controls1.TableViewColumn { 47 Controls1.TableViewColumn {
diff --git a/components/package/contents/ui/MessagePartTree.qml b/components/package/contents/ui/MessagePartTree.qml
deleted file mode 100644
index a904f42c..00000000
--- a/components/package/contents/ui/MessagePartTree.qml
+++ /dev/null
@@ -1,89 +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
19import QtQuick 2.4
20import QtQuick.Controls 1.3
21
22Item {
23 id: root
24 property alias rootIndex: visualModel.rootIndex
25 property int nestingLevel: 0
26 property int contentHeight: messagePartRect.height
27 property int contentWidth: 0
28 Rectangle {
29 id: messagePartRect
30 height: partListView.contentHeight
31 width: root.width
32 VisualDataModel {
33 id: visualModel
34 model: messageParser.partTree
35 delegate: Rectangle {
36 id: delegateRect
37 visible: !model.isHidden
38 width: childrenRect.width
39 height: childrenRect.height
40 // color: Qt.rgba(Math.random(),Math.random(),Math.random(),1)
41 ContentView {
42 id: contentView
43 anchors.top: delegateRect.top
44 anchors.left: delegateRect.left
45 width: messagePartRect.width
46 height: contentHeight
47 content: model.text
48 isHtml: model.isHtml
49 visible: model.hasContent
50 onVisibleChanged: {
51 //Resize to 0 if it is not visible so the partLoader has the right offset
52 if (!visible) {
53 height = 0
54 }
55 }
56 onContentWidthChanged: {
57 root.contentWidth = contentWidth > root.contentWidth ? contentWidth : root.contentWidth
58 }
59 contentType: model.type
60 }
61 Loader {
62 id: partLoader
63 anchors.top: contentView.bottom
64 anchors.left: contentView.left
65 visible: model.hasModelChildren
66 active: model.hasModelChildren
67 height: item ? item.contentHeight : 0
68 width: messagePartRect.width
69 }
70 Component.onCompleted: {
71 if (model.hasModelChildren) {
72 partLoader.source = "MessagePartTree.qml"
73 partLoader.item.rootIndex = visualModel.modelIndex(index)
74 partLoader.item.nestingLevel = root.nestingLevel + 1
75 }
76 }
77 }
78 }
79
80 ListView {
81 id: partListView
82 model: visualModel
83 anchors.left: parent.left
84 anchors.top: parent.top
85 anchors.right: parent.right
86 height: parent.height
87 }
88 }
89}
diff --git a/components/package/contents/ui/TextView.qml b/components/package/contents/ui/TextView.qml
deleted file mode 100644
index 7fd1272f..00000000
--- a/components/package/contents/ui/TextView.qml
+++ /dev/null
@@ -1,32 +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
19import QtQuick 2.7
20
21Item {
22 id: root
23 property string content;
24 property int contentWidth: 0;
25 property int contentHeight: textView.contentHeight;
26 Text {
27 id: textView
28 wrapMode: Text.WordWrap
29 anchors.fill: parent
30 text: content
31 }
32}
diff --git a/components/package/contents/ui/WebView.qml b/components/package/contents/ui/WebView.qml
deleted file mode 100644
index 509c9809..00000000
--- a/components/package/contents/ui/WebView.qml
+++ /dev/null
@@ -1,55 +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
19import QtQuick 2.7
20import QtWebEngine 1.3
21
22Item {
23 id: root
24 property string content;
25 property int contentWidth: 0;
26 property int contentHeight: 0;
27 WebEngineView {
28 id: htmlView
29 anchors.fill: parent
30 onLoadingChanged: {
31 // console.debug("Status is ", loadRequest.status);
32 // console.debug("Url is ", loadRequest.url);
33 if (loadRequest.errorCode) {
34 console.warn("Error is ", loadRequest.errorString);
35 }
36 }
37 Component.onCompleted: {
38 loadHtml(content, "file:///")
39 }
40 onContentsSizeChanged: {
41 root.contentWidth = contentsSize.width
42 root.contentHeight = contentsSize.height
43 }
44 activeFocusOnPress: false
45 settings {
46 autoLoadImages: true
47 javascriptCanOpenWindows: false
48 javascriptEnabled: true
49 localStorageEnabled: false
50 }
51 }
52 onContentChanged: {
53 htmlView.loadHtml(content, "file:///");
54 }
55}