diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-04-29 16:58:09 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-04-29 16:58:09 +0200 |
commit | 21f7851f044cd8b6e38c821ce12d7e1b291cae27 (patch) | |
tree | fac2a5229e29ec99b4ad10fbafe3d83a850b132a /components/package/contents/ui/MessagePartTree.qml | |
parent | 23d8c802eb2c0e60224a019c69d253c222010be9 (diff) | |
download | kube-21f7851f044cd8b6e38c821ce12d7e1b291cae27.tar.gz kube-21f7851f044cd8b6e38c821ce12d7e1b291cae27.zip |
Push missing files
Diffstat (limited to 'components/package/contents/ui/MessagePartTree.qml')
-rw-r--r-- | components/package/contents/ui/MessagePartTree.qml | 66 |
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 @@ | |||
1 | import QtQuick 2.4 | ||
2 | import QtQuick.Controls 1.3 | ||
3 | |||
4 | Item { | ||
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 | } | ||