From 6833c46a9522be3c55cefe79676293a0a571cbf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20Knau=C3=9F?= Date: Wed, 19 Oct 2016 14:28:08 +0200 Subject: use treemodel in qml --- components/mailviewer/qml/DummyApp.qml | 55 -------------------- components/mailviewer/qml/EncryptedPart.qml | 43 ---------------- components/mailviewer/qml/EncryptionPart.qml | 68 +++++++++++++++++++++++++ components/mailviewer/qml/HtmlContent.qml | 48 ++++++++++++++++++ components/mailviewer/qml/HtmlPart.qml | 48 ------------------ components/mailviewer/qml/MailDataModel.qml | 65 ++++++++++++++++++++++++ components/mailviewer/qml/MailModel.qml | 50 ------------------ components/mailviewer/qml/MailModel2.qml | 28 ---------- components/mailviewer/qml/MailPart.qml | 76 +++++++--------------------- components/mailviewer/qml/MailViewer.qml | 52 +++++++------------ components/mailviewer/qml/SignaturePart.qml | 66 ++++++++++++++++++++++++ components/mailviewer/qml/SignedPart.qml | 44 ---------------- components/mailviewer/qml/TextContent.qml | 47 +++++++++++++++++ components/mailviewer/qml/TextPart.qml | 28 ---------- 14 files changed, 331 insertions(+), 387 deletions(-) delete mode 100644 components/mailviewer/qml/DummyApp.qml delete mode 100644 components/mailviewer/qml/EncryptedPart.qml create mode 100644 components/mailviewer/qml/EncryptionPart.qml create mode 100644 components/mailviewer/qml/HtmlContent.qml delete mode 100644 components/mailviewer/qml/HtmlPart.qml create mode 100644 components/mailviewer/qml/MailDataModel.qml delete mode 100644 components/mailviewer/qml/MailModel.qml delete mode 100644 components/mailviewer/qml/MailModel2.qml create mode 100644 components/mailviewer/qml/SignaturePart.qml delete mode 100644 components/mailviewer/qml/SignedPart.qml create mode 100644 components/mailviewer/qml/TextContent.qml delete mode 100644 components/mailviewer/qml/TextPart.qml (limited to 'components/mailviewer') diff --git a/components/mailviewer/qml/DummyApp.qml b/components/mailviewer/qml/DummyApp.qml deleted file mode 100644 index acb91ac1..00000000 --- a/components/mailviewer/qml/DummyApp.qml +++ /dev/null @@ -1,55 +0,0 @@ -/* - Copyright (C) 2016 Michael Bohlender, - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -import QtQuick 2.4 - -Item { -Column { - anchors { - top: parent.top - left: parent.left - right: parent.right - margins: 20 - } - - spacing: 10 - width: parent.width - Repeater { - model: messageParser.newTree - - delegate: Column { - id: delegateRoot - - width: parent.width - - Loader { - id: loader - } - - Component.onCompleted: { - switch (model.type) { - case "AlternativePart": - case "SinglePart": - loader.source = "MailPart.qml"; - break; - } - } - } - } -} -} diff --git a/components/mailviewer/qml/EncryptedPart.qml b/components/mailviewer/qml/EncryptedPart.qml deleted file mode 100644 index 18a5d588..00000000 --- a/components/mailviewer/qml/EncryptedPart.qml +++ /dev/null @@ -1,43 +0,0 @@ -/* - Copyright (C) 2016 Michael Bohlender, - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -import QtQuick 2.4 -import QtQuick.Controls 1.5 - -Item { - - height: mailPart.height + 20 - width: mailPart.width + 20 - - BorderImage { - - anchors.fill: parent - border { left: 40; top: 40; right: 40; bottom: 40 } - horizontalTileMode: BorderImage.Round - verticalTileMode: BorderImage.Round - - source: "securityborders" + model.securityLevel + ".png" - } - - MailPart { - id: mailPart - - anchors.centerIn: parent - - } -} diff --git a/components/mailviewer/qml/EncryptionPart.qml b/components/mailviewer/qml/EncryptionPart.qml new file mode 100644 index 00000000..a1adea43 --- /dev/null +++ b/components/mailviewer/qml/EncryptionPart.qml @@ -0,0 +1,68 @@ +/* + Copyright (C) 2016 Michael Bohlender, + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +import QtQuick 2.4 + +Item { + id: encryption + property alias rootIndex: visualModel.rootIndex + property bool debug: true + height: partListView.height + width: parent.width + + MailDataModel { + id: visualModel + debug: encryption.debug + model: messageParser.newTree + } + + Column { + id: partListView + anchors { + top: parent.top + left: parent.left + } + width: parent.width + spacing: 5 + Text { + width: parent.width + visible: encryption.debug + text: model.type + } + BorderImage { + width: parent.width + height: childrenRect.height + 40 + border { left: 10; top: 10; right: 10; bottom: 10 } + horizontalTileMode: BorderImage.Round + verticalTileMode: BorderImage.Round + + source: "securityborders"+ model.securityLevel +".png" + ListView { + model: visualModel + anchors { + top: parent.top + left: parent.left + margins: 20 + } + spacing: 20 + height: contentHeight + width: parent.width - 40 + } + } + } +} diff --git a/components/mailviewer/qml/HtmlContent.qml b/components/mailviewer/qml/HtmlContent.qml new file mode 100644 index 00000000..15bd1915 --- /dev/null +++ b/components/mailviewer/qml/HtmlContent.qml @@ -0,0 +1,48 @@ +/* + Copyright (C) 2016 Michael Bohlender, + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +import QtQuick 2.4 +import QtQuick.Controls 1.3 +import QtWebKit 3.0 +// import QtWebEngine 1.3 //This would give use contentsSize +import QtWebEngine 1.2 + +Item { + id: root + property string content: model.content + property int contentHeight: helperView.contentHeight; + //FIXME workaround until QtWebEngine 1.3 with contentsSize + + height: contentHeight + width: partColumn.width + + WebView { + id: helperView + visible: false + Component.onCompleted: loadHtml(content, "file:///") + } + WebEngineView { + id: htmlView + anchors.fill: parent + Component.onCompleted: loadHtml(content, "file:///") + } + onContentChanged: { + htmlView.loadHtml(content, "file:///"); + helperView.loadHtml(content, "file:///"); + } +} diff --git a/components/mailviewer/qml/HtmlPart.qml b/components/mailviewer/qml/HtmlPart.qml deleted file mode 100644 index f812ecb4..00000000 --- a/components/mailviewer/qml/HtmlPart.qml +++ /dev/null @@ -1,48 +0,0 @@ -/* - Copyright (C) 2016 Michael Bohlender, - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -import QtQuick 2.4 -import QtQuick.Controls 1.3 -import QtWebKit 3.0 -// import QtWebEngine 1.3 //This would give use contentsSize -import QtWebEngine 1.2 - -Item { - id: root - property string content: model.content - property int contentHeight: helperView.contentHeight; - //FIXME workaround until QtWebEngine 1.3 with contentsSize - - height: contentHeight - width: delegateRoot.width - - WebView { - id: helperView - visible: false - Component.onCompleted: loadHtml(content, "file:///") - } - WebEngineView { - id: htmlView - anchors.fill: parent - Component.onCompleted: loadHtml(content, "file:///") - } - onContentChanged: { - htmlView.loadHtml(content, "file:///"); - helperView.loadHtml(content, "file:///"); - } -} 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 @@ +/* + Copyright (C) 2016 Michael Bohlender, + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +import QtQuick 2.4 + +VisualDataModel { + id: mailDataModel + property bool debug: true + delegate: Rectangle { + id: partColumn + width: parent.width + height: childrenRect.height + Loader { + id: partLoader + anchors { + top: parent.top + left: parent.left + } + height: item? item.contentHeight : 0 + width: parent.width + } + Component.onCompleted: { + switch (model.type) { + case "PlainTextContent": + case "Content": + partLoader.source = "TextContent.qml" + partLoader.item.debug = mailDataModel.debug + return; + case "HtmlContent": + partLoader.source = "HtmlContent.qml" + return; + case "Signature": + partLoader.source = "SignaturePart.qml" + partLoader.item.rootIndex = mailDataModel.modelIndex(index) + partLoader.item.debug = mailDataModel.debug + return; + case "Encryption": + partLoader.source = "EncryptionPart.qml" + partLoader.item.rootIndex = mailDataModel.modelIndex(index) + partLoader.item.debug = mailDataModel.debug + return; + } + if (model.hasModelChildren) { + partLoader.source = "MailPart.qml" + partLoader.item.rootIndex = mailDataModel.modelIndex(index) + partLoader.item.debug = mailDataModel.debug + } + } + } +} diff --git a/components/mailviewer/qml/MailModel.qml b/components/mailviewer/qml/MailModel.qml deleted file mode 100644 index d18f5ece..00000000 --- a/components/mailviewer/qml/MailModel.qml +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright (C) 2016 Michael Bohlender, - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -import QtQuick 2.4 - -ListModel { - - ListElement { - type: "encrypted" - securityLevel: "GREEN" - content: [ - ListElement { - type: "plaintext" - textContent: "Moin, \n find the forwarded mail below. \n \n - M" - embeded: false - }, - ListElement { - type: "embeded" - sender: "Senderson" - date: "05/05/2055" - content: [ - ListElement{ - type: "plaintext" - textContent: "sender mc senderson is a sender. sender mc senderson is a sender. sender mc senderson is a mc senderson is a sender sender mc senderson is a sender sender mc senderson is a sender sender mc senderson is a sender sender mc senderson is a sender sender mc a sender sender mc is a sender sender mc senderson is a sendersender mc senderson is a sender" - embeded: true - }] - } - ] - } - ListElement { - type: "plaintext" - textContent: "footer mc footerson" - embeded: false - } -} diff --git a/components/mailviewer/qml/MailModel2.qml b/components/mailviewer/qml/MailModel2.qml deleted file mode 100644 index 9ea45d57..00000000 --- a/components/mailviewer/qml/MailModel2.qml +++ /dev/null @@ -1,28 +0,0 @@ -/* - Copyright (C) 2016 Michael Bohlender, - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -import QtQuick 2.4 - -ListModel { - - ListElement { - type: "html" - htmlContent: "

Some Heading

My some paragraph.

" - } -} - diff --git a/components/mailviewer/qml/MailPart.qml b/components/mailviewer/qml/MailPart.qml index d47b4c5f..ad51a7ba 100644 --- a/components/mailviewer/qml/MailPart.qml +++ b/components/mailviewer/qml/MailPart.qml @@ -20,67 +20,27 @@ import QtQuick 2.4 Item { id: root + property alias rootIndex: visualModel.rootIndex + property bool debug: true + height: partListView.height + 10 + width: parent.width + + MailDataModel { + id: visualModel + debug: root.debug + model: messageParser.newTree + } - height: partColumn.height + 20 - width: delegateRoot.width - - Column { - id: partColumn + ListView { + id: partListView + model: visualModel anchors { - top: parent.top - left: parent.left - right: parent.right - margins: 10 + top: parent.top + left: parent.left + margins: 5 } - spacing: 5 - - Repeater { - model: contents - delegate: Column { - id: delegateRoot - - width: partColumn.width - - Loader { - id: loader - } - - Component.onCompleted: { - switch (model.type) { - case "AlternativePart": - case "SinglePart": - loader.source = "MailPart.qml"; - break; - - case "PlainTextContent": - case "Content": - loader.source = "TextPart.qml"; - break; - case "HtmlContent": - loader.source = "HtmlPart.qml"; - break; - - case "alternativeframe": - loader.source = "Frame.qml" - break; - case "encrypted": - loader.source = "EncryptedPart.qml"; - break; - case "embeded": - loader.source = "EmbededPart.qml"; - break; - } - } - } - } - - - Item { - id: footer - - height: 5 - width: 10 - } + height: contentHeight + width: parent.width - 10 } } diff --git a/components/mailviewer/qml/MailViewer.qml b/components/mailviewer/qml/MailViewer.qml index f5714e25..86a96913 100644 --- a/components/mailviewer/qml/MailViewer.qml +++ b/components/mailviewer/qml/MailViewer.qml @@ -19,42 +19,28 @@ import QtQuick 2.4 Item { - id: mailviewer - height: mainColumn.height + 50 + id: root + property alias rootIndex: visualModel.rootIndex + property bool debug: true + height: partListView.height + 50 width: parent.width * 0.9 - Column { - id: mainColumn - anchors { - top: parent.top - left: parent.left - right: parent.right - margins: 20 - } - spacing: 10 - width: parent.width - 50 - - Repeater { - model: messageParser.newTree - - delegate: Column { - id: delegateRoot - - width: mainColumn.width - - Loader { - id: loader - } + MailDataModel { + id: visualModel + debug: root.debug + model: messageParser.newTree + } - Component.onCompleted: { - switch (model.type) { - case "AlternativePart": - case "SinglePart": - loader.source = "MailPart.qml"; - break; - } - } - } + ListView { + id: partListView + model: visualModel + anchors { + top: parent.top + left: parent.left + margins: 5 } + spacing: 5 + height: contentHeight + width: parent.width - 10 } } diff --git a/components/mailviewer/qml/SignaturePart.qml b/components/mailviewer/qml/SignaturePart.qml new file mode 100644 index 00000000..8a0e33ce --- /dev/null +++ b/components/mailviewer/qml/SignaturePart.qml @@ -0,0 +1,66 @@ +/* + Copyright (C) 2016 Michael Bohlender, + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +import QtQuick 2.4 + +Item { + id: signature + property alias rootIndex: visualModel.rootIndex + property bool debug: true + height: partListView.height + width: parent.width + + MailDataModel { + id: visualModel + debug: signature.debug + model: messageParser.newTree + } + Column { + id: partListView + anchors { + top: parent.top + left: parent.left + } + width: parent.width + spacing: 5 + Text { + width: parent.width + visible: signature.debug + text: model.type + } + BorderImage { + width: parent.width + height: childrenRect.height + 40 + border { left: 10; top: 10; right: 10; bottom: 10 } + horizontalTileMode: BorderImage.Round + verticalTileMode: BorderImage.Round + source: "securityborders"+ model.securityLevel +".png" + ListView { + model: visualModel + anchors { + top: parent.top + left: parent.left + margins: 20 + } + spacing: 20 + height: contentHeight + width: parent.width - 40 + } + } + } +} diff --git a/components/mailviewer/qml/SignedPart.qml b/components/mailviewer/qml/SignedPart.qml deleted file mode 100644 index f0daedeb..00000000 --- a/components/mailviewer/qml/SignedPart.qml +++ /dev/null @@ -1,44 +0,0 @@ -/* - Copyright (C) 2016 Michael Bohlender, - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -import QtQuick 2.4 -import QtQuick.Controls 1.5 - -Item { - - height: mailPart.height + 20 - width: mailPart.width + 20 - - BorderImage { - - anchors.fill: parent - border { left: 40; top: 40; right: 40; bottom: 40 } - horizontalTileMode: BorderImage.Round - verticalTileMode: BorderImage.Round - - source: "securityborders" + model.securityLevel + ".png" - } - - MailPart { - id: mailPart - - anchors.centerIn: parent - - } -} - diff --git a/components/mailviewer/qml/TextContent.qml b/components/mailviewer/qml/TextContent.qml new file mode 100644 index 00000000..2e0167d4 --- /dev/null +++ b/components/mailviewer/qml/TextContent.qml @@ -0,0 +1,47 @@ +/* + Copyright (C) 2016 Michael Bohlender, + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +import QtQuick 2.4 +Item { + id: textItem + property bool debug: true + width: partColumn.width + height: textColumn.height + Column { + id: textColumn + anchors { + top: parent.top + left: parent.left + } + width: parent.width + spacing: 5 + Text { + width: parent.width + visible: textItem.debug + text: model.type + } + Text { + width: parent.width + + text: model.content + wrapMode: Text.WordWrap + + color: model.embeded ? "grey" : "black" + } + } +} diff --git a/components/mailviewer/qml/TextPart.qml b/components/mailviewer/qml/TextPart.qml deleted file mode 100644 index 0267682f..00000000 --- a/components/mailviewer/qml/TextPart.qml +++ /dev/null @@ -1,28 +0,0 @@ -/* - Copyright (C) 2016 Michael Bohlender, - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -import QtQuick 2.4 - -Text { - width: delegateRoot.width - - text: model.content - wrapMode: Text.WordWrap - - color: model.securityLevel //embeded ? "grey" : "black" -} -- cgit v1.2.3