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