From 1974c19eadd497e355ac985a00d0571f3e6c7712 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20Knau=C3=9F?= Date: Tue, 11 Oct 2016 16:18:50 +0200 Subject: create model for new mailviewer --- components/CMakeLists.txt | 1 + components/mailviewer/qml/DummyApp.qml | 55 ++++++++++++++++ components/mailviewer/qml/HtmlPart.qml | 2 +- components/mailviewer/qml/MailPart.qml | 36 ++++++----- components/mailviewer/qml/TextPart.qml | 4 +- components/mailviewer/qml/dummyapp.qml | 90 --------------------------- components/package/contents/ui/MailViewer.qml | 31 ++++++--- 7 files changed, 102 insertions(+), 117 deletions(-) create mode 100644 components/mailviewer/qml/DummyApp.qml delete mode 100644 components/mailviewer/qml/dummyapp.qml (limited to 'components') diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 4fad0387..66e27822 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -24,6 +24,7 @@ find_package(KF5 REQUIRED COMPONENTS Package) install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kube/components) install(DIRECTORY package/contents/ui/ DESTINATION ${QML_INSTALL_DIR}/org/kube/components) +install(DIRECTORY mailviewer/qml/ DESTINATION ${QML_INSTALL_DIR}/org/kube/components) include(${CMAKE_SOURCE_DIR}/KF5KirigamiMacros.cmake) kirigami_package_breeze_icons(ICONS applications-graphics view-list-icons folder-sync view-list-details configure document-edit dialog-cancel document-decrypt mail-reply-sender bookmarks folder) diff --git a/components/mailviewer/qml/DummyApp.qml b/components/mailviewer/qml/DummyApp.qml new file mode 100644 index 00000000..acb91ac1 --- /dev/null +++ b/components/mailviewer/qml/DummyApp.qml @@ -0,0 +1,55 @@ +/* + 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/HtmlPart.qml b/components/mailviewer/qml/HtmlPart.qml index f1add75c..f812ecb4 100644 --- a/components/mailviewer/qml/HtmlPart.qml +++ b/components/mailviewer/qml/HtmlPart.qml @@ -24,7 +24,7 @@ import QtWebEngine 1.2 Item { id: root - property string content: model.htmlContent + property string content: model.content property int contentHeight: helperView.contentHeight; //FIXME workaround until QtWebEngine 1.3 with contentsSize diff --git a/components/mailviewer/qml/MailPart.qml b/components/mailviewer/qml/MailPart.qml index 966337cd..d47b4c5f 100644 --- a/components/mailviewer/qml/MailPart.qml +++ b/components/mailviewer/qml/MailPart.qml @@ -21,24 +21,22 @@ import QtQuick 2.4 Item { id: root - height: partColumn.height + 40 + height: partColumn.height + 20 width: delegateRoot.width Column { id: partColumn - anchors { top: parent.top left: parent.left right: parent.right - margins: 20 + margins: 10 } - spacing: 10 + spacing: 5 Repeater { - model: content - + model: contents delegate: Column { id: delegateRoot @@ -49,23 +47,29 @@ Item { } 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; - case "frame": - loader.source = "Frame.qml" - break; - case "plaintext": - loader.source = "TextPart.qml"; - break; - case "html": - loader.source = "HtmlPart.qml"; - break; } } } diff --git a/components/mailviewer/qml/TextPart.qml b/components/mailviewer/qml/TextPart.qml index 5f183852..0267682f 100644 --- a/components/mailviewer/qml/TextPart.qml +++ b/components/mailviewer/qml/TextPart.qml @@ -21,8 +21,8 @@ import QtQuick 2.4 Text { width: delegateRoot.width - text: model.textContent + text: model.content wrapMode: Text.WordWrap - color: embeded ? "grey" : "black" + color: model.securityLevel //embeded ? "grey" : "black" } diff --git a/components/mailviewer/qml/dummyapp.qml b/components/mailviewer/qml/dummyapp.qml deleted file mode 100644 index a186f0f1..00000000 --- a/components/mailviewer/qml/dummyapp.qml +++ /dev/null @@ -1,90 +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 - -Rectangle { - id: app - - width: 1200 - height: 700 - - Rectangle { - anchors.fill: parent - - color: "black" - - opacity: 0.8 - - } - - Rectangle { - - anchors.centerIn: parent - - height: mainColumn.height + 50 - width: parent.width * 0.9 - - Column { - id: mainColumn - - anchors.centerIn: parent - - width: parent.width - 50 - - spacing: 10 - - Repeater { - model: MailModel {} - - delegate: Column { - id: delegateRoot - - width: mainColumn.width - - Loader { - id: loader - } - - Component.onCompleted: { - switch (model.type) { - case "red": - loader.source = "Rect2.qml"; - break; - case "green": - loader.source = "Rect1.qml"; - break; - case "encrypted": - loader.source = "EncryptedPart.qml"; - break; - case "frame": - loader.source = "Frame.qml"; - break; - case "plaintext": - loader.source = "TextPart.qml"; - break; - case "html": - loader.source = "HtmlPart.qml"; - break; - } - } - } - } - } - } -} diff --git a/components/package/contents/ui/MailViewer.qml b/components/package/contents/ui/MailViewer.qml index 5365be66..347f30de 100644 --- a/components/package/contents/ui/MailViewer.qml +++ b/components/package/contents/ui/MailViewer.qml @@ -27,8 +27,8 @@ Item { id: root property variant message; property string html; - property bool enablePartTreeView : false - property int desiredHeight: enablePartTreeView ? topPartLoader.height+450 : topPartLoader.height; + property bool enablePartTreeView : true; + property int desiredHeight: enablePartTreeView ? topPartLoader.height + dummyApp.height + mailStructure.height + 50 : topPartLoader.height + dummyApp.height + 50; Rectangle { id: rootRectangle @@ -41,6 +41,19 @@ Item { verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff Column { spacing:2 + Text { + text: "New Mailviewer:" + color: "blue" + } + DummyApp { + id: dummyApp + height: 800 + width: rootRectangle.width + } + Text { + text: "Old Mailviewer:" + color: "blue" + } MessagePartTree { id: topPartLoader // width: rootRectangle.width @@ -48,6 +61,7 @@ Item { width: topPartLoader.contentWidth >= rootRectangle.width ? topPartLoader.contentWidth : rootRectangle.width } TreeView { + id: mailStructure visible: enablePartTreeView width: rootRectangle.width height: 400 @@ -57,16 +71,17 @@ Item { width: 300 } TableViewColumn { - role: "isHidden" - title: "Hidden" + role: "embeded" + title: "Embeded" width: 60 } TableViewColumn { - role: "text" - title: "Text" - width: 600 + role: "content" + title: "Content" + width: 200 } - model: messageParser.partTree + //model: messageParser.partTree + model: messageParser.newTree } } } -- cgit v1.2.3 From fb12fcddb68e96580028072daa595d82fb3dd0ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20Knau=C3=9F?= Date: Wed, 12 Oct 2016 14:23:20 +0200 Subject: get the correct size for NewMailViewer in qml --- components/CMakeLists.txt | 2 +- components/mailviewer/qml/MailViewer.qml | 60 +++++++++++++++++++++++++++ components/mailviewer/qml/qmldir | 3 ++ components/package/contents/ui/MailViewer.qml | 10 ++--- 4 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 components/mailviewer/qml/MailViewer.qml create mode 100644 components/mailviewer/qml/qmldir (limited to 'components') diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 66e27822..30a9d09c 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -24,7 +24,7 @@ find_package(KF5 REQUIRED COMPONENTS Package) install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kube/components) install(DIRECTORY package/contents/ui/ DESTINATION ${QML_INSTALL_DIR}/org/kube/components) -install(DIRECTORY mailviewer/qml/ DESTINATION ${QML_INSTALL_DIR}/org/kube/components) +install(DIRECTORY mailviewer/qml/ DESTINATION ${QML_INSTALL_DIR}/org/kube/mailviewer) include(${CMAKE_SOURCE_DIR}/KF5KirigamiMacros.cmake) kirigami_package_breeze_icons(ICONS applications-graphics view-list-icons folder-sync view-list-details configure document-edit dialog-cancel document-decrypt mail-reply-sender bookmarks folder) diff --git a/components/mailviewer/qml/MailViewer.qml b/components/mailviewer/qml/MailViewer.qml new file mode 100644 index 00000000..f5714e25 --- /dev/null +++ b/components/mailviewer/qml/MailViewer.qml @@ -0,0 +1,60 @@ +/* + 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: mailviewer + height: mainColumn.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 + } + + Component.onCompleted: { + switch (model.type) { + case "AlternativePart": + case "SinglePart": + loader.source = "MailPart.qml"; + break; + } + } + } + } + } +} diff --git a/components/mailviewer/qml/qmldir b/components/mailviewer/qml/qmldir new file mode 100644 index 00000000..0d87b779 --- /dev/null +++ b/components/mailviewer/qml/qmldir @@ -0,0 +1,3 @@ +module org.kube.mailviewer + +MailViewer 1.0 MailViewer.qml diff --git a/components/package/contents/ui/MailViewer.qml b/components/package/contents/ui/MailViewer.qml index 347f30de..02d84728 100644 --- a/components/package/contents/ui/MailViewer.qml +++ b/components/package/contents/ui/MailViewer.qml @@ -22,13 +22,14 @@ import QtQuick.Controls 1.4 import QtQuick.Layouts 1.1 import org.kube.framework.domain 1.0 as KubeFramework +import org.kube.mailviewer 1.0 as MV Item { id: root property variant message; property string html; property bool enablePartTreeView : true; - property int desiredHeight: enablePartTreeView ? topPartLoader.height + dummyApp.height + mailStructure.height + 50 : topPartLoader.height + dummyApp.height + 50; + property int desiredHeight: enablePartTreeView ? topPartLoader.height + newMailViewer.height + mailStructure.height + 50 : topPartLoader.height + newMailViewer.height + 50; Rectangle { id: rootRectangle @@ -40,14 +41,13 @@ Item { anchors.margins: 0 verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff Column { - spacing:2 + spacing: 2 Text { text: "New Mailviewer:" color: "blue" } - DummyApp { - id: dummyApp - height: 800 + MV.MailViewer { + id: newMailViewer width: rootRectangle.width } Text { -- cgit v1.2.3 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 ---------- components/package/contents/ui/MailViewer.qml | 6 +++ 15 files changed, 337 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') 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" -} diff --git a/components/package/contents/ui/MailViewer.qml b/components/package/contents/ui/MailViewer.qml index 02d84728..f8e0a33b 100644 --- a/components/package/contents/ui/MailViewer.qml +++ b/components/package/contents/ui/MailViewer.qml @@ -48,6 +48,7 @@ Item { } MV.MailViewer { id: newMailViewer + debug: false width: rootRectangle.width } Text { @@ -75,6 +76,11 @@ Item { title: "Embeded" width: 60 } + TableViewColumn { + role: "securityLevel" + title: "SecurityLevel" + width: 60 + } TableViewColumn { role: "content" title: "Content" -- cgit v1.2.3