summaryrefslogtreecommitdiffstats
path: root/components/package/contents/ui/MessagePartTree.qml
diff options
context:
space:
mode:
Diffstat (limited to 'components/package/contents/ui/MessagePartTree.qml')
-rw-r--r--components/package/contents/ui/MessagePartTree.qml66
1 files changed, 66 insertions, 0 deletions
diff --git a/components/package/contents/ui/MessagePartTree.qml b/components/package/contents/ui/MessagePartTree.qml
new file mode 100644
index 00000000..9a08b356
--- /dev/null
+++ b/components/package/contents/ui/MessagePartTree.qml
@@ -0,0 +1,66 @@
1import QtQuick 2.4
2import QtQuick.Controls 1.3
3
4Item {
5 id: root
6 property alias rootIndex: visualModel.rootIndex
7 property int nestingLevel: 0
8 property int desiredHeight: messagePartRect.height
9 Rectangle {
10 id: messagePartRect
11 height: partListView.contentHeight
12 width: root.width
13 VisualDataModel {
14 id: visualModel
15 model: messageParser.partTree
16 delegate: Rectangle {
17 id: delegateRect
18 // visible: !model.isAttachment
19 width: childrenRect.width
20 height: childrenRect.height
21 // color: Qt.rgba(Math.random(),Math.random(),Math.random(),1)
22 ContentView {
23 id: contentView
24 anchors.top: delegateRect.top
25 anchors.left: delegateRect.left
26 width: messagePartRect.width
27 content: model.text
28 isHtml: model.isHtml
29 visible: model.hasContent
30 onVisibleChanged: {
31 //Resize to 0 if it is not visible so the partLoader has the right offset
32 if (!visible) {
33 height = 0
34 }
35 }
36 contentType: model.type
37 }
38 Loader {
39 id: partLoader
40 anchors.top: contentView.bottom
41 anchors.left: contentView.left
42 width: messagePartRect.width
43 visible: model.hasModelChildren
44 active: model.hasModelChildren
45 height: item ? item.desiredHeight : 0
46 }
47 Component.onCompleted: {
48 if (model.hasModelChildren) {
49 partLoader.source = "MessagePartTree.qml"
50 partLoader.item.rootIndex = visualModel.modelIndex(index)
51 partLoader.item.nestingLevel = root.nestingLevel + 1
52 }
53 }
54 }
55 }
56
57 ListView {
58 id: partListView
59 model: visualModel
60 anchors.left: parent.left
61 anchors.top: parent.top
62 anchors.right: parent.right
63 height: parent.height
64 }
65 }
66}