diff options
author | Sandro Knauß <sknauss@kde.org> | 2016-10-19 14:28:08 +0200 |
---|---|---|
committer | Sandro Knauß <sknauss@kde.org> | 2016-10-19 14:28:08 +0200 |
commit | 6833c46a9522be3c55cefe79676293a0a571cbf5 (patch) | |
tree | 6a91b7e00cff34aec70341c24921fd9a1dd095ea /components/mailviewer/qml/MailDataModel.qml | |
parent | be38c2ebaa77b116028cbe34f777e3d8e5cbc776 (diff) | |
download | kube-6833c46a9522be3c55cefe79676293a0a571cbf5.tar.gz kube-6833c46a9522be3c55cefe79676293a0a571cbf5.zip |
use treemodel in qml
Diffstat (limited to 'components/mailviewer/qml/MailDataModel.qml')
-rw-r--r-- | components/mailviewer/qml/MailDataModel.qml | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/components/mailviewer/qml/MailDataModel.qml b/components/mailviewer/qml/MailDataModel.qml new file mode 100644 index 00000000..408d02e8 --- /dev/null +++ b/components/mailviewer/qml/MailDataModel.qml | |||
@@ -0,0 +1,65 @@ | |||
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 | |||
19 | import QtQuick 2.4 | ||
20 | |||
21 | VisualDataModel { | ||
22 | id: mailDataModel | ||
23 | property bool debug: true | ||
24 | delegate: Rectangle { | ||
25 | id: partColumn | ||
26 | width: parent.width | ||
27 | height: childrenRect.height | ||
28 | Loader { | ||
29 | id: partLoader | ||
30 | anchors { | ||
31 | top: parent.top | ||
32 | left: parent.left | ||
33 | } | ||
34 | height: item? item.contentHeight : 0 | ||
35 | width: parent.width | ||
36 | } | ||
37 | Component.onCompleted: { | ||
38 | switch (model.type) { | ||
39 | case "PlainTextContent": | ||
40 | case "Content": | ||
41 | partLoader.source = "TextContent.qml" | ||
42 | partLoader.item.debug = mailDataModel.debug | ||
43 | return; | ||
44 | case "HtmlContent": | ||
45 | partLoader.source = "HtmlContent.qml" | ||
46 | return; | ||
47 | case "Signature": | ||
48 | partLoader.source = "SignaturePart.qml" | ||
49 | partLoader.item.rootIndex = mailDataModel.modelIndex(index) | ||
50 | partLoader.item.debug = mailDataModel.debug | ||
51 | return; | ||
52 | case "Encryption": | ||
53 | partLoader.source = "EncryptionPart.qml" | ||
54 | partLoader.item.rootIndex = mailDataModel.modelIndex(index) | ||
55 | partLoader.item.debug = mailDataModel.debug | ||
56 | return; | ||
57 | } | ||
58 | if (model.hasModelChildren) { | ||
59 | partLoader.source = "MailPart.qml" | ||
60 | partLoader.item.rootIndex = mailDataModel.modelIndex(index) | ||
61 | partLoader.item.debug = mailDataModel.debug | ||
62 | } | ||
63 | } | ||
64 | } | ||
65 | } | ||