Commit 83724769 authored by Karel Slaný's avatar Karel Slaný

Deleted PageZfoMessageDetail.

parent f7c2bd50
......@@ -60,7 +60,6 @@ ApplicationWindow {
property Component pageSettingsPin: PageSettingsPin {}
property Component pageSettingsStorage: PageSettingsStorage {}
property Component pageSettingsSync: PageSettingsSync {}
property Component pageZfoMessageDetail: PageZfoMessageDetail {}
// header background color
property string mainHeaderBgColor: "#00539b"
......@@ -289,7 +288,7 @@ ApplicationWindow {
*/
console.log("Showing zfo file: " + filePath)
var fileContent = files.rawFileContent(filePath)
mainStack.push(pageZfoMessageDetail, {
mainStack.push(pageMessageDetail, {
"pageView": mainStack,
"fromLocalDb": false,
"rawZfoContent": fileContent
......
......@@ -358,7 +358,7 @@ Component {
if (files.isZfoFile(rFileName)) {
console.log("Attachment is ZFO: " + rFileName)
var fileContent = files.base64ToRaw(rFileContent)
pageView.push(pageZfoMessageDetail, {
pageView.push(pageMessageDetail, {
"pageView": pageView,
"statusBar": statusBar,
"fromLocalDb": false,
......
/*
* Copyright (C) 2014-2017 CZ.NIC
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations including
* the two.
*/
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Window 2.1
import QtGraphicalEffects 1.0
import cz.nic.mobileDatovka.messages 1.0
import cz.nic.mobileDatovka.models 1.0
Component {
id: componentZfoMessageDetail
Item {
id: msgZfoDetailPage
/* These properties must be set by caller. */
property var pageView
property var statusBar
property var fromLocalDb: false
property var rawZfoContent: null /* Raw ZFO file content. */
property string acntName: ""
property string userName: ""
property string msgId: ""
property int msgType
/* These properties are set from within the page. */
property string zfoId /*Prevents infinite loop that would be caused by setting msgId from within the page. */
property string msgAnnotation
property string msgDescrHtml /* Message HTML description. */
property string emailBody
function fillContentFromDb() {
if (!fromLocalDb && (rawZfoContent != null)) {
zfoId = files.msgIdString(rawZfoContent)
msgAnnotation = files.msgAnnotation(rawZfoContent),
msgDescrHtml = files.msgDescriptionHtml(rawZfoContent),
emailBody = files.msgEmailBody(rawZfoContent)
attachmentModel.setZfo(rawZfoContent)
console.log("Loaded page content from ZFO.")
rawZfoContent = null /* There is no need to remember this. */
} else if (fromLocalDb && (userName.length != 0) && (msgId.length != 0)) {
zfoId = msgId
messages.markMessageAsLocallyRead(userName, msgId, true)
msgDescrHtml = messages.getMessageDetail(userName, zfoId)
attachmentModel.setFromDb(userName, zfoId)
console.log("Loaded page content from database.")
if (attachmentList.count == 0) {
emptyList.visible = true
msgDownloadButton.visible = true
attachmentMenuButon.visible = false
}
}
}
onRawZfoContentChanged: {
fillContentFromDb()
}
onUserNameChanged: {
fillContentFromDb()
}
onMsgIdChanged: {
fillContentFromDb()
}
FileListModel {
id: attachmentModel
Component.onCompleted: {
}
}
Rectangle {
id: header
anchors.top: parent.top
width: parent.width
height: headerHeight
color: datovkaPalette.highlight
Image {
id: backElement3
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: defaultMargin
sourceSize.height: navImgHeight
source: "qrc:/ui/back.svg"
}
Rectangle {
anchors.left: parent.left
width: parent.width * 0.5
height: parent.height
color: "transparent"
MouseArea {
anchors.fill: parent
onClicked: {
if (typeof(statusBar) != "undefined") {
statusBar.visible = false
}
pageView.pop(StackView.Immediate)
}
}
}
Column {
anchors.verticalCenter: parent.verticalCenter
anchors.left: backElement3.right
anchors.leftMargin: defaultMargin
Text {
text: fromLocalDb ? (acntName + " (" + userName + ")") : qsTr("Message from ZFO")
font.bold: true
color: datovkaPalette.text
}
Text {
text: {
if (fromLocalDb && (msgType == MessageType.TYPE_RECEIVED)) {
qsTr("Received message") + " " + zfoId
} else if (fromLocalDb && (msgType == MessageType.TYPE_SENT)) {
qsTr("Sent message") + " " + zfoId
} else {
qsTr("Message ID") + " " + zfoId
}
}
font.bold: true
color: datovkaPalette.text
}
}
Row {
anchors.verticalCenter: parent.verticalCenter
spacing: defaultMargin
anchors.right: parent.right
anchors.rightMargin: defaultMargin
Image {
id: msgEmailButton
anchors.verticalCenter: parent.verticalCenter
sourceSize.height: imgHeight
source: "qrc:/ui/reply.svg"
MouseArea {
anchors.fill: parent
onClicked: {
files.sendAttachmentsWithEmailFromZfo(zfoId, msgAnnotation, emailBody)
}
}
}
Image {
id: attachmentSaveButon
anchors.verticalCenter: parent.verticalCenter
sourceSize.height: imgHeight
source: "qrc:/ui/save-to-disk.svg"
MouseArea {
anchors.fill: parent
onClicked: {
files.saveAttachmentsToDisk("", zfoId)
}
}
}
Image {
id: msgDownloadButton
anchors.verticalCenter: parent.verticalCenter
sourceSize.height: imgHeight
source: "qrc:/ui/datovka-email-download.svg"
MouseArea {
anchors.fill: parent
onClicked: {
if (fromLocalDb) {
isds.downloadMessage(userName, msgType, zfoId)
msgDescrHtml = messages.getMessageDetail(userName, zfoId)
attachmentModel.setFromDb(userName, zfoId)
msgDownloadButton.visible = false
attachmentMenuButon.visible = true
}
}
}
}
Image {
id: attachmentMenuButon
anchors.verticalCenter: parent.verticalCenter
sourceSize.height: imgHeight
source: "qrc:/ui/attach-download.svg"
MouseArea {
anchors.fill: parent
onClicked: {
if (fromLocalDb) {
pageView.push(pageMenuMessageDetail, {
"pageView": pageView,
"statusBar": statusBar,
"acntName": acntName,
"userName": userName,
"msgType": msgType,
"msgId": zfoId
}, StackView.Immediate)
}
}
}
}
}
}
Rectangle {
id: messageDetail
anchors.top: header.bottom
width: parent.width
height: parent.height * 0.5
color: datovkaPalette.base
ListModel {
id: messageDetailModel
ListElement {
text: ""
}
}
ListView {
id: messageDetailList
anchors.fill: parent
anchors.margins: defaultMargin
clip: true
spacing: 0
opacity: 1
visible: true
interactive: true
model: messageDetailModel
delegate: Text {
id: messageDetailText
color: datovkaPalette.text
width: parent.width
textFormat: TextEdit.RichText
wrapMode: Text.WordWrap
text: msgDescrHtml
}
}
}
Item {
id: attachmentLabel
anchors.top: messageDetail.bottom
width: parent.width
height: textFontSizeInPixels * 2
Text {
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: defaultMargin
textFormat: TextEdit.RichText
text: "<h3>" + qsTr("Attachments") + "</h3>"
font.bold: true
}
Rectangle {
id: attachmentLabelLine
anchors.bottom: parent.bottom
height: 1
width: parent.width
color: datovkaPalette.mid
}
}
ListView {
id: attachmentList
anchors.top: attachmentLabel.bottom
anchors.bottom: parent.bottom
clip: true
spacing: 1
opacity: 1
visible: true
width: parent.width
interactive: true
model: attachmentModel
onCountChanged: {
if (attachmentList.count == 0) {
emptyList.visible = true
msgDownloadButton.visible = true
attachmentMenuButon.visible = false
} else {
emptyList.visible = false
msgDownloadButton.visible = false
attachmentMenuButon.visible = true
}
}
delegate: Rectangle {
id: attachmentItem
width: parent.width
height: headerHeight
color: datovkaPalette.base
Image {
id: imageAttachment
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
sourceSize.height: imgHeight
source: rFileIcon
}
Item {
anchors.left: imageAttachment.right
anchors.leftMargin: defaultMargin
height: parent.height
width: parent.width
Column {
anchors.verticalCenter: parent.verticalCenter
Text {
id: filenameid
anchors.left: parent.left
text: rFileName
color: datovkaPalette.text
font.bold: true
}
Text {
id: filesizeid
anchors.left: parent.left
text: rFileSize
color: datovkaPalette.mid
font.pointSize: textFontSizeSmall
renderType: Text.NativeRendering
}
}
}
Rectangle {
id: next
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
height: parent.height
width: parent.width * 0.07
color: parent.color
Image {
id: nextImage
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: defaultMargin
sourceSize.height: navImgHeight
source: "qrc:/ui/next.svg"
}
ColorOverlay {
anchors.fill: nextImage
source: nextImage
color: datovkaPalette.text
}
}
MouseArea {
anchors.fill: parent
onClicked: {
locker.ignoreNextSuspension()
if (files.isZfoFile(rFileName)) {
console.log("Attachment is ZFO: " + rFileName)
var fileContent = files.base64ToRaw(rFileContent)
pageView.push(pageZfoMessageDetail, {
"pageView": pageView,
"statusBar": statusBar,
"fromLocalDb": false,
"rawZfoContent": fileContent
}, StackView.Immediate)
} else {
if (!fromLocalDb) {
files.openAttachment(rFileName, rFileContent)
} else {
files.openAttachmentFromDb(userName, zfoId, rFileId)
}
}
}
}
Rectangle {
anchors.top: parent.bottom
height: 1
width: parent.width
color: datovkaPalette.mid
}
}
property bool downloadStart: false
//onContentYChanged: // whenever position changes
//onVerticalVelocityChanged:
//onFlickEnded: // similar to onDragEnded but shorter distance
onMovementEnded: {
if (downloadStart) {
downloadStart = false
if (fromLocalDb) {
isds.downloadMessage(userName, msgType, zfoId)
msgDescrHtml = messages.getMessageDetail(userName, zfoId)
attachmentModel.setFromDb(userName, zfoId)
}
}
}
onDragEnded: {
downloadStart = contentY < -120
}
}
Text {
id: emptyList
visible: false
color: datovkaPalette.text
anchors.centerIn: attachmentList
text: fromLocalDb ? qsTr("Attachments have not been downloaded yet.") : qsTr("No attachments present.")
}
}
}
......@@ -111,6 +111,5 @@
<file>../qml/pages/PageSettingsStorage.qml</file>
<file>../qml/pages/PageSettingsSync.qml</file>
<file>../qml/main.qml</file>
<file>../qml/pages/PageZfoMessageDetail.qml</file>
</qresource>
</RCC>
......@@ -87,7 +87,6 @@ const struct QmlTypeEntry qmlPages[] = {
{ "PageSettingsPin", 1, 0 },
{ "PageSettingsStorage", 1, 0 },
{ "PageSettingsSync", 1, 0 },
{ "PageZfoMessageDetail", 1, 0 },
{ NULL, 0, 0 }
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment