PageSendMessage.qml 39.4 KB
Newer Older
1
/*
2
 * Copyright (C) 2014-2019 CZ.NIC
3 4 5 6 7 8 9 10
 *
 * 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
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 13 14
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 17 18 19 20 21 22 23 24 25 26 27 28
 *
 * 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.1
import QtQuick.Layouts 1.3
import QtGraphicalEffects 1.0
import cz.nic.mobileDatovka 1.0
Martin Straka's avatar
Martin Straka committed
29
import cz.nic.mobileDatovka.files 1.0
30 31 32 33 34 35 36 37 38
import cz.nic.mobileDatovka.messages 1.0
import cz.nic.mobileDatovka.models 1.0

Item {
    id: pageSendMessage

    /* These properties must be set by caller. */
    property var pageView
    property var statusBar
39
    property string acntName
40 41 42 43 44
    property string userName
    property string msgId
    property int msgType
    property string action: "new"

45 46 47 48 49
    /*
     * These properties are constants and specifies some attachment size limits.
     * Do not change these! See ISDS documentation about more message limit info.
     */
    property int max_ATTACHMENT_FILES: 900
50
    property int max_ATTACHMENT_SIZE_BYTES: 20971520 // = 20 * 1024 * 1024.
51
    property int max_ATTACHMENT_SIZE_MB: 20
52
    property int max_OVM_ATTACHMENT_SIZE_BYTES: 52428800 // = 50 * 1024 * 1024.
53 54
    property int max_OVM_ATTACHMENT_SIZE_MB: 50

Martin Straka's avatar
Martin Straka committed
55 56
    property string text_COLOR_RED: "#ff0000"

57 58
    property bool iOS: false

59 60 61
    /* This property holds total attachment size in bytes */
    property int totalAttachmentSizeBytes: 0

62 63
    /* This property defines mandate textinput width. */
    property int mandateFieldLenght : defaultTextFont.font.pointSize * 4
Martin Straka's avatar
Martin Straka committed
64 65

    /* This property holds message type for sending. */
Martin Straka's avatar
Martin Straka committed
66
    property string dmType: ""
67 68 69 70 71 72

    /* Return file name from file path */
    function getFileNameFromPath(filePath) {
        return filePath.replace(/^.*[\\\/]/, '')
    }

73 74
    /* Check attachment number ans size. */
    function attachmentSizeOk() {
75 76 77 78 79 80 81 82
        attachmentsSizeLabel.color = datovkaPalette.text
        var attachmentNumber = sendMsgAttachmentModel.rowCount()
        if (attachmentNumber === 0) {
            attachmentsSizeLabel.text = qsTr("Total size of attachments is %1 B.").arg(0)
            return false;
        }
        if (attachmentNumber >= max_ATTACHMENT_FILES) {
            attachmentsSizeLabel.text = qsTr("The permitted number of (%1) attachments has been exceeded.").arg(max_ATTACHMENT_FILES)
Martin Straka's avatar
Martin Straka committed
83
            attachmentsSizeLabel.color = text_COLOR_RED
84 85 86 87
            return false
        }
        if (totalAttachmentSizeBytes >= max_OVM_ATTACHMENT_SIZE_BYTES) {
            attachmentsSizeLabel.text = qsTr("Total size of attachments exceeds %1 MB.").arg(max_OVM_ATTACHMENT_SIZE_MB)
Martin Straka's avatar
Martin Straka committed
88
            attachmentsSizeLabel.color = text_COLOR_RED
89 90 91 92
            return false
        }
        if (totalAttachmentSizeBytes >= max_ATTACHMENT_SIZE_BYTES) {
            attachmentsSizeLabel.text = qsTr("Total size of attachments exceeds %1 MB. Most of the data boxes cannot receive messages larger than %1 MB. However, some OVM data boxes can receive message up to %2 MB.").arg(max_ATTACHMENT_SIZE_MB).arg(max_OVM_ATTACHMENT_SIZE_MB)
Martin Straka's avatar
Martin Straka committed
93
            attachmentsSizeLabel.color = text_COLOR_RED
94 95 96
            return true
        }
        if (totalAttachmentSizeBytes >= 1024) {
97
            attachmentsSizeLabel.text = qsTr("Total size of attachments is ~%1 kB.").arg(Math.round(totalAttachmentSizeBytes/1024))
98 99 100 101 102 103
        } else {
            attachmentsSizeLabel.text = qsTr("Total size of attachments is %1 B.").arg(totalAttachmentSizeBytes)
        }
        return true
    }

Martin Straka's avatar
Martin Straka committed
104
    /* Set mandate fields in QML */
105 106 107 108 109 110
    function setMandate(isdsEnvelope) {
        dmLegalTitleLaw.text = isdsEnvelope.dmLegalTitleLawStr
        dmLegalTitleYear.text = isdsEnvelope.dmLegalTitleYearStr
        dmLegalTitleSect.text = isdsEnvelope.dmLegalTitleSect
        dmLegalTitlePar.text = isdsEnvelope.dmLegalTitlePar
        dmLegalTitlePoint.text = isdsEnvelope.dmLegalTitlePoint
111 112
    }

113 114
    /* Set reply message data and add recipient to model */
    function setReplyData(userName, msgId) {
115
        headerBar.title = qsTr("Reply %1").arg(msgId)
116
        // get some message envelope data and add recipient to recipient model
117 118
        var isdsEnvelope = messages.getMsgEnvelopeDataAndSetRecipient(userName, msgId, recipBoxModel)
        dmAnnotation.text = "Re: " + isdsEnvelope.dmAnnotation
Martin Straka's avatar
Martin Straka committed
119
        // swap sender ref and ident data to recipient (reply)
120 121 122 123 124
        dmSenderRefNumber.text = isdsEnvelope.dmRecipientRefNumber
        dmSenderIdent.text = isdsEnvelope.dmRecipientIdent
        dmRecipientRefNumber.text = isdsEnvelope.dmSenderRefNumber
        dmRecipientIdent.text = isdsEnvelope.dmSenderIdent
        if (isdsEnvelope.dmType === "I") {
Martin Straka's avatar
Martin Straka committed
125 126 127 128 129 130
            replyPDZ.visible = true
            dmType = "O"
        } else {
            replyPDZ.visible = false
            dmType = ""
        }
131
        setMandate(isdsEnvelope)
Martin Straka's avatar
Martin Straka committed
132 133
    }

134 135
    /* Set message envelope data and files to attachment model*/
    function setTemplateData(userName, msgId) {
136
        headerBar.title = qsTr("Forward %1").arg(msgId)
Martin Straka's avatar
Martin Straka committed
137
        // get some message envelope data, recipient model must be null (no recipient)
138 139 140 141 142 143 144
        var isdsEnvelope = messages.getMsgEnvelopeDataAndSetRecipient(userName, msgId, null)
        dmAnnotation.text = isdsEnvelope.dmAnnotation
        dmSenderRefNumber.text = isdsEnvelope.dmSenderRefNumber
        dmSenderIdent.text = isdsEnvelope.dmSenderIdent
        dmRecipientRefNumber.text = isdsEnvelope.dmRecipientRefNumber
        dmRecipientIdent.text = isdsEnvelope.dmRecipientIdent
        setMandate(isdsEnvelope)
145
        sendMsgAttachmentModel.setFromDb(userName, msgId)
146
        totalAttachmentSizeBytes = sendMsgAttachmentModel.dataSizeSum()
147
        attachmentSizeOk()
148 149
    }

Martin Straka's avatar
Martin Straka committed
150 151
    /* Set message forward data and add ZFO file to model */
    function setForwardZfoData(userName, msgId) {
152
        headerBar.title = qsTr("Forward ZFO %1").arg(msgId)
153 154
        var isdsEnvelope = messages.getMsgEnvelopeDataAndSetRecipient(userName, msgId, null)
        dmAnnotation.text = "Fwd: " + isdsEnvelope.dmAnnotation
Martin Straka's avatar
Martin Straka committed
155 156 157 158
        var fileName = (msgType == MessageType.TYPE_SENT) ? "ODZ_" + msgId + ".zfo" : "DDZ_" + msgId + ".zfo"
        var zfoSize = zfo.getZfoSizeFromDb(userName, msgId)
        // Zfo file must exist in the local database so zfoSize must be > 0
        if (zfoSize > 0) {
159
            sendMsgAttachmentModel.appendFileFromPath(FileIdType.DB_ZFO_ID, fileName, "", zfoSize)
160
            totalAttachmentSizeBytes = sendMsgAttachmentModel.dataSizeSum()
Martin Straka's avatar
Martin Straka committed
161 162 163 164 165 166 167
        } else {
            mainPanel.visible = false
            errorText.text = qsTr("ZFO file of message %1 is not available. Download complete message to get it before forwarding.").arg(msgId)
            errorText.visible = true
        }
    }

168 169
    /* Append one file into send model */
    function appendFileToSendModel(filePath) {
170 171
            var isInFiletList = false
            for (var i = 0; i < sendMsgAttachmentModel.rowCount(); i++) {
172
                if (sendMsgAttachmentModel.filePathFromRow(i) === filePath) {
173 174 175 176 177
                    isInFiletList = true
                    break
                }
            }
            if (!isInFiletList) {
178 179
                var fileName = getFileNameFromPath(filePath)
                var fileSizeBytes = files.getAttachmentSizeInBytes(filePath)
180
                sendMsgAttachmentModel.appendFileFromPath(FileIdType.NO_FILE_ID,
181
                    fileName, filePath, fileSizeBytes)
182 183
                totalAttachmentSizeBytes = sendMsgAttachmentModel.dataSizeSum()
            }
184 185 186 187 188 189 190
    }

    /* Append file list into send model */
    function appendFilesToSendModel(pathListModel) {
        var listLength = pathListModel.count
        for (var j = 0; j < listLength; ++j) {
            appendFileToSendModel(pathListModel.get(j).path)
191 192 193 194
        }
        pathListModel.clear()
    }

195
    Component.onCompleted: {
196
        iOS = files.isIos()
Martin Straka's avatar
Martin Straka committed
197 198 199 200
        actionButton.enabled = false
        initPDZ.visible = false
        initPDZ.checked = false
        replyPDZ.visible = false
201
        replyPDZ.checked = false
Martin Straka's avatar
Martin Straka committed
202 203 204
        var boxEffectiveOVM = accounts.boxEffectiveOVM(userName)
        dmOVM.visible = boxEffectiveOVM
        dmAllowSubstDelivery.visible = boxEffectiveOVM
205
        if (action === "new") {
Martin Straka's avatar
Martin Straka committed
206
            initPDZ.visible = !boxEffectiveOVM
207
            headerBar.title = qsTr("New message")
208 209
        } else if (action === "reply") {
            setReplyData(userName, msgId)
210
        } else if (action === "template") {
Martin Straka's avatar
Martin Straka committed
211
            initPDZ.visible = !boxEffectiveOVM
212
            setTemplateData(userName, msgId)
Martin Straka's avatar
Martin Straka committed
213
        } else if (action == "fwdzfo") {
Martin Straka's avatar
Martin Straka committed
214
            initPDZ.visible = !boxEffectiveOVM
Martin Straka's avatar
Martin Straka committed
215
            setForwardZfoData(userName, msgId)
216 217 218
        }
    }

219
    Component.onDestruction: {
220
       if (iOS) {
221
            iOSHelper.clearSendAndTmpDirs()
222
       }
223 224 225
       statusBar.visible = false
    }

226
    /* File dialog for choose of files from the storage */
227 228
    FileDialogue {
        id: fileDialogue
229
        multiSelect: true
230
        onFinished: appendFilesToSendModel(pathListModel)
231 232 233
    }

    /* Holds send message recipent list model */
234
    DataboxListModel {
235
        id: recipBoxModel
236 237 238 239 240
        Component.onCompleted: {
        }
    }

    /* Holds send message attachment list model */
Martin Straka's avatar
Martin Straka committed
241
    FileListModel {
242 243 244 245 246 247 248 249
        id: sendMsgAttachmentModel
        Component.onCompleted: {
        }
    }

    PageHeader {
        id: headerBar
        title: qsTr("Create message")
250 251
        onBackClicked: {
            pageView.pop(StackView.Immediate)
252
        }
253
        AccessibleOverlaidImageButton {
254 255 256 257
            id: actionButton
            anchors.verticalCenter: parent.verticalCenter
            anchors.right: parent.right
            anchors.rightMargin: defaultMargin
258 259
            image.sourceSize.height: imgHeightHeader
            image.source: "qrc:/ui/send-msg.svg"
260 261 262 263
            accessibleName: qsTr("Send message")
            onClicked: {
                actionButton.enabled = false
                mainPanel.doSendRequest()
264 265 266
            }
        }
    } // PageHeader
267
    AccessibleText {
268 269 270 271 272 273 274 275 276
        id: errorText
        visible: false
        color: datovkaPalette.text
        anchors.centerIn: parent
        width: parent.width
        horizontalAlignment: Text.AlignHCenter
        wrapMode: Text.Wrap
        text: qsTr("Error during message creation.")
    }
277
    Item {
278 279 280 281 282
        id: mainPanel
        anchors.top: headerBar.bottom
        anchors.bottom: parent.bottom
        width: parent.width

283 284 285
        Connections {
            target: isds
            onRunSendMessageSig: {
286
                actionButton.enabled = false
Martin Straka's avatar
Martin Straka committed
287
                isds.sendMessage(userName, msgId, dmAnnotation.text.toString(),
Martin Straka's avatar
Martin Straka committed
288
                    recipBoxModel, sendMsgAttachmentModel,
289 290 291 292 293
                    dmLegalTitleLaw.text.toString(), dmLegalTitleYear.text.toString(),
                    dmLegalTitleSect.text.toString(), dmLegalTitlePar.text.toString(),
                    dmLegalTitlePoint.text.toString(), dmToHands.text.toString(),
                    dmRecipientRefNumber.text.toString(), dmRecipientIdent.text.toString(),
                    dmSenderRefNumber.text.toString(), dmSenderIdent.text.toString(),
Martin Straka's avatar
Martin Straka committed
294 295
                    dmOVM.checked, dmPublishOwnID.checked, dmAllowSubstDelivery.checked,
                    dmPersonalDelivery.checked, dmType)
296 297 298
            }
        }

299
        function doSendRequest() {
300
            isds.doIsdsAction("sendMessage", userName)
301 302 303 304
        }

        /* Enable send message button if all required fields are filled */
        function areReguiredFieldsFilled() {
305
            actionButton.enabled = (attachmentSizeOk() && (dmAnnotation.text.toString() !== "") && (recipBoxModel.rowCount() > 0))
306 307 308
        }

        TabBar {
309 310
            id: tabBar
            z: 1
311 312
            width: parent.width
            Repeater {
313
                model: [qsTr("General"), qsTr("Recipients"), qsTr("Attachments"), qsTr("Additional")]
314
                AccessibleTabButton {
315
                    text: modelData
316
                    width: Math.max(100, tabBar.width / 4)
317 318 319 320 321
                }
            }
        } // TabBar
        StackLayout {
            width: parent.width
322
            anchors.top: tabBar.bottom
323
            anchors.bottom: parent.bottom
324 325 326
            currentIndex: tabBar.currentIndex
            onCurrentIndexChanged: {
                tabGeneral.contentY = 0
327
                tabAdditional.contentY = 0
328
            }
329
//----SUBJECT SECTION------------
330
            Flickable {
331
                id: tabGeneral
332 333 334 335 336 337 338
                z: 0
                anchors.fill: parent
                contentHeight: generalContent.implicitHeight
                Pane {
                    id: generalContent
                    anchors.fill: parent
                    Column {
339 340 341
                        anchors.right: parent.right
                        anchors.left: parent.left
                        spacing: formItemVerticalSpacing
342
                        AccessibleText {
343 344
                            color: datovkaPalette.mid
                            wrapMode: Text.Wrap
345
                            horizontalAlignment: Text.AlignHCenter
346
                            width: parent.width
347
                            text: qsTr("Please fill in the subject of the message, select at least one recipient data box and specify at least one attachment file before sending the message.")
348
                        }
Martin Straka's avatar
Martin Straka committed
349 350 351
                        Text {
                            text: " "
                        }
352
                        AccessibleText {
353 354
                            color: datovkaPalette.text
                            font.bold: true
355
                            text: qsTr("Sender account")
356
                        }
357
                        AccessibleText {
358 359 360
                            color: datovkaPalette.text
                            text: acntName + " (" + userName + ")"
                        }
361 362 363
                        Text {
                            text: " "
                        }
364
                        AccessibleText {
365
                            color: datovkaPalette.text
366
                            font.bold: true
367 368
                            text: qsTr("Subject")
                        }
369
                        AccessibleTextField {
370
                            id: dmAnnotation
371
                            width: parent.width
372 373 374 375 376 377 378
                            height: inputItemHeight
                            font.pointSize: defaultTextFont.font.pointSize
                            placeholderText: qsTr("Enter subject")
                            InputLineMenu {
                                id: subjectMenu
                                inputTextControl: dmAnnotation
                                isPassword: false
379
                            }
380 381 382 383
                            onPressAndHold: {
                                if (settings.useExplicitClipboardOperations()) {
                                    subjectMenu.implicitWidth = computeMenuWidth(subjectMenu)
                                    subjectMenu.open()
384 385
                                }
                            }
386 387 388
                            onTextChanged: {
                                mainPanel.areReguiredFieldsFilled()
                            }
389
                        }
390
                        AccessibleSwitch {
391 392 393 394
                            id: dmPublishOwnID
                            text: qsTr("Include sender identification")
                            font.pointSize: defaultTextFont.font.pointSize
                            checked: true
Martin Straka's avatar
Martin Straka committed
395
                        }
396
                        AccessibleSwitch {
397 398 399 400 401
                            id: dmPersonalDelivery
                            text: qsTr("Personal delivery")
                            font.pointSize: defaultTextFont.font.pointSize
                            checked: false
                        }
402
                        AccessibleSwitch {
403 404 405 406 407 408
                            id: dmAllowSubstDelivery
                            visible: false
                            text: qsTr("Allow acceptance through fiction")
                            font.pointSize: defaultTextFont.font.pointSize
                            checked: true
                        }
409
                        AccessibleSwitch {
410 411 412 413 414 415
                            id: dmOVM
                            visible: false
                            text: qsTr("Send as OVM")
                            font.pointSize: defaultTextFont.font.pointSize
                            checked: true
                        }
416
                        AccessibleSwitch {
417 418 419 420 421 422 423 424 425
                            id: initPDZ
                            visible: false
                            text: qsTr("Pay transfer charges for reply")
                            font.pointSize: defaultTextFont.font.pointSize
                            checked: false
                            onClicked: {
                                (initPDZ.checked) ? dmType = "I" : dmType = ""
                            }
                        }
426
                        AccessibleSwitch {
427 428
                            id: replyPDZ
                            visible: false
429
                            text: qsTr("Use transfer charges from recipient")
430
                            font.pointSize: defaultTextFont.font.pointSize
431
                            checked: false
432 433 434
                            onClicked: {
                                (replyPDZ.checked) ? dmType = "O" : dmType = ""
                            }
Martin Straka's avatar
Martin Straka committed
435
                        }
436 437 438
                    } // Column
                } // Pane
            } // Flickable
439 440 441 442 443 444 445 446 447 448 449
//----RECIPIENTS SECTION------------
            Item {
                id: tabRecipients
                Item {
                    id: buttonMenu
                    anchors.left: parent.left
                    anchors.right: parent.right
                    height: inputItemHeight
                    Row {
                        spacing: formItemVerticalSpacing * 5
                        anchors.horizontalCenter: parent.horizontalCenter
450
                        AccessibleButton {
Martin Straka's avatar
Martin Straka committed
451 452 453
                            id: addContact
                            height: inputItemHeight
                            font.pointSize: defaultTextFont.font.pointSize
454
                            text: qsTr("Add")
Martin Straka's avatar
Martin Straka committed
455 456 457 458 459 460 461 462 463
                            onClicked: {
                                pageView.push(pageContactList, {
                                        "pageView": pageView,
                                        "statusBar": statusBar,
                                        "userName": userName,
                                        "recipBoxModel": recipBoxModel
                                    }, StackView.Immediate)
                            }
                        }
464
                        AccessibleButton {
465 466 467
                            id: findDS
                            height: inputItemHeight
                            font.pointSize: defaultTextFont.font.pointSize
468
                            text: qsTr("Find")
469 470 471 472 473
                            onClicked: {
                                pageView.push(pageDataboxSearch, {
                                        "pageView": pageView,
                                        "statusBar": statusBar,
                                        "userName": userName,
474
                                        "recipBoxModel": recipBoxModel
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490
                                    }, StackView.Immediate)
                            }
                        }
                    } // Row
                } // Item
                DataboxList {
                    id: recipientList
                    anchors.top: buttonMenu.bottom
                    anchors.bottom: parent.bottom
                    clip: true
                    spacing: 1
                    opacity: 1
                    visible: true
                    width: parent.width
                    height: 600
                    interactive: true
491
                    model: recipBoxModel
492
                    canRemoveBoxes: true
493
                    localContactFormat: true
494 495 496
                    onCountChanged: {
                        mainPanel.areReguiredFieldsFilled()
                    }
497
                    onBoxRemove: {
498
                        recipBoxModel.removeEntry(boxId)
499
                    }
500 501 502 503 504
                } // DataboxList
            }
//----ATTACHMENT SECTION------------
            Item {
                id: tabAttachments
505
                Connections {
Martin Straka's avatar
Martin Straka committed
506
                   target: iOSHelper
507 508 509 510 511 512
                    onFileSelectedSig: {
                        if (filePath !== "") {
                            appendFileToSendModel(filePath)
                        }
                    }
                }
513 514 515
                AccessibleButton {
                    id: addFile
                    height: inputItemHeight
516
                    anchors.horizontalCenter: parent.horizontalCenter
517 518 519 520
                    font.pointSize: defaultTextFont.font.pointSize
                    text: qsTr("Add file")
                    onClicked: {
                        iOS ? iOSHelper.openDocumentPickerController() : fileDialogue.raise(qsTr("Select files"), ["*.*"], true, "")
521 522 523 524 525 526 527
                    }
                }
                Component {
                    id: attachmentDelegate
                    Rectangle {
                        id: attachmentItem
                        width: parent.width
528
                        height: attachmentListSend.delegateHeight
529
                        color: datovkaPalette.base
530
                        MouseArea {
531
                            function handleClick() {
Martin Straka's avatar
Martin Straka committed
532
                                // fileId is set and is valid, use files from database
533
                                if (rFileId > 0) {
Martin Straka's avatar
Martin Straka committed
534 535
                                    if (files.isZfoFile(rFileName)) {
                                        pageView.push(pageMessageDetail, {
536 537 538
                                            "pageView": pageView,
                                            "statusBar": statusBar,
                                            "fromLocalDb": false,
539
                                            "rawZfoContent": files.getFileRawContentFromDb(userName, rFileId)})
Martin Straka's avatar
Martin Straka committed
540
                                    } else {
541
                                        files.openAttachmentFromDb(userName, rFileId)
Martin Straka's avatar
Martin Straka committed
542
                                    }
543 544 545 546 547 548
                                } else if (rFileId == FileIdType.DB_ZFO_ID)  {
                                        pageView.push(pageMessageDetail, {
                                            "pageView": pageView,
                                            "statusBar": statusBar,
                                            "fromLocalDb": false,
                                            "rawZfoContent": zfo.getZfoContentFromDb(userName, msgId)})
549
                                } else {
Martin Straka's avatar
Martin Straka committed
550 551 552 553 554 555 556 557 558
                                    if (files.isZfoFile(getFileNameFromPath(rFilePath))) {
                                        pageView.push(pageMessageDetail, {
                                            "pageView": pageView,
                                            "statusBar": statusBar,
                                            "fromLocalDb": false,
                                            "rawZfoContent": files.rawFileContent(rFilePath)})
                                    } else {
                                        files.openAttachmentFromPath(rFilePath)
                                    }
559 560
                                }
                            }
561 562 563 564 565 566 567 568 569 570 571

                            anchors.fill: parent

                            Accessible.role: Accessible.Button
                            Accessible.name: qsTr("Open file '%1'.").arg(rFileName)
                            Accessible.onPressAction: {
                                handleClick()
                            }
                            onClicked: {
                                handleClick()
                            }
572
                        }
573 574 575 576
                        Image {
                            id: imageAttachment
                            anchors.left: parent.left
                            anchors.verticalCenter: parent.verticalCenter
577
                            sourceSize.height: attachmentListSend.delegateHeight * 0.8
578
                            source: files.getAttachmentFileIcon(rFileName)
579 580 581 582 583 584 585 586 587 588 589
                        }
                        Item {
                            anchors.left: imageAttachment.right
                            anchors.leftMargin: defaultMargin
                            height: parent.height
                            width: parent.width
                            Column {
                                width: parent.width
                                anchors.verticalCenter: parent.verticalCenter
                                spacing: defaultMargin
                                Text {
Martin Straka's avatar
Martin Straka committed
590
                                    text: rFileName
591 592 593 594
                                    color: datovkaPalette.text
                                    font.bold: true
                                }
                                Text {
595
                                    text: if (rFilePath != "") {
Martin Straka's avatar
Martin Straka committed
596
                                        iOS ? iOSHelper.getShortSendFilePath(rFilePath) : rFilePath
597 598
                                    } else {
                                        qsTr("Local database")
Martin Straka's avatar
Martin Straka committed
599
                                    }
600 601 602 603
                                    color: datovkaPalette.mid
                                    font.pointSize: textFontSizeSmall
                                }
                                Text {
Karel Slaný's avatar
Karel Slaný committed
604
                                    text: rFileSizeStr
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621
                                    color: datovkaPalette.mid
                                    font.pointSize: textFontSizeSmall
                                }
                            }
                        }
                        Rectangle {
                            id: remove
                            anchors.verticalCenter: parent.verticalCenter
                            anchors.right: parent.right
                            height: parent.height
                            width: parent.width * 0.07
                            color: parent.color
                            Image {
                                id: removeImage
                                anchors.verticalCenter: parent.verticalCenter
                                anchors.right: parent.right
                                anchors.rightMargin: defaultMargin
622
                                sourceSize.height: navImgHeight
623 624 625 626 627 628 629 630
                                source: "qrc:/ui/remove.svg"
                            }
                            ColorOverlay {
                                anchors.fill: removeImage
                                source: removeImage
                                color: datovkaPalette.windowText
                            }
                            MouseArea {
631 632
                                function handleClick() {
                                    sendMsgAttachmentModel.removeItem(index)
633
                                    totalAttachmentSizeBytes = sendMsgAttachmentModel.dataSizeSum()
634 635
                                }

636
                                anchors.fill: parent
637 638 639

                                Accessible.role: Accessible.Button
                                Accessible.name: qsTr("Remove file '%1' from list.").arg(rFileName)
640 641
                                Accessible.onScrollDownAction: attachmentListSend.scrollDown()
                                Accessible.onScrollUpAction: attachmentListSend.scrollUp()
642 643 644
                                Accessible.onPressAction: {
                                    handleClick()
                                }
645
                                onClicked: {
646
                                    handleClick()
647 648 649 650 651 652 653 654 655 656 657
                                }
                            }
                        } // Rectangle
                        Rectangle {
                            anchors.top: parent.bottom
                            height: 1
                            width: parent.width
                            color: datovkaPalette.dark
                        }
                    } // Rectangle
                } // Component
658 659 660 661 662
                AccessibleText {
                    id: attachmentsSizeLabel
                    color: datovkaPalette.text
                    anchors.left: parent.left
                    anchors.leftMargin: defaultMargin
663
                    anchors.top: addFile.bottom
664 665 666 667 668 669 670 671
                    anchors.topMargin: defaultMargin
                    anchors.right: parent.right
                    anchors.rightMargin: defaultMargin
                    horizontalAlignment: Text.AlignHCenter
                    wrapMode: Text.Wrap
                    font.pointSize: textFontSizeSmall
                    text: qsTr("Total size of attachments is %1 B.").arg(totalAttachmentSizeBytes)
                }
672
                ScrollableListView {
673
                    id: attachmentListSend
674
                    delegateHeight: listItemHeight
675 676
                    anchors.top: attachmentsSizeLabel.bottom
                    anchors.bottom: parent.bottom
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692
                    clip: true
                    spacing: 1
                    opacity: 1
                    visible: true
                    width: parent.width
                    height: 600
                    interactive: true
                    model: sendMsgAttachmentModel
                    delegate: attachmentDelegate
                    onCountChanged: {
                        mainPanel.areReguiredFieldsFilled()
                    }
                    ScrollIndicator.vertical: ScrollIndicator {}
                } // Listview
            }
//----ADDITIONALS SECTION------------
693
            Flickable {
694
                id: tabAdditional
695 696 697 698 699 700
                z: 0
                anchors.fill: parent
                contentHeight: additonalsContent.implicitHeight
                Pane {
                    id: additonalsContent
                    anchors.fill: parent
701 702 703 704
                    Column {
                        anchors.right: parent.right
                        anchors.left: parent.left
                        spacing: formItemVerticalSpacing
705
    //---Mandate---------------------
706
                        AccessibleText {
707 708
                            font.bold: true
                            text: qsTr("Mandate")
709
                        }
710
                        Row {
711
                            width: parent.width
712
                            spacing: defaultMargin
713
                            AccessibleTextField {
714 715 716 717 718 719
                                id: dmLegalTitleLaw
                                width: mandateFieldLenght
                                height: inputItemHeight
                                maximumLength: 4
                                font.pointSize: defaultTextFont.font.pointSize
                            }
720
                            AccessibleText {
721 722 723
                                anchors.verticalCenter: parent.verticalCenter
                                text: "/"
                            }
724
                            AccessibleTextField {
725 726 727 728 729 730
                                id: dmLegalTitleYear
                                width: mandateFieldLenght
                                height: inputItemHeight
                                maximumLength: 4
                                font.pointSize: defaultTextFont.font.pointSize
                            }
731
                            AccessibleText {
732 733 734
                                anchors.verticalCenter: parent.verticalCenter
                                text: "§"
                            }
735
                            AccessibleTextField {
736 737 738 739 740 741
                                id: dmLegalTitleSect
                                width: mandateFieldLenght
                                height: inputItemHeight
                                maximumLength: 4
                                font.pointSize: defaultTextFont.font.pointSize
                            }
742
                            AccessibleText {
743 744 745
                                anchors.verticalCenter: parent.verticalCenter
                                text: qsTr("par.")
                            }
746
                            AccessibleTextField {
747 748 749 750 751 752
                                id: dmLegalTitlePar
                                width: mandateFieldLenght / 2
                                height: inputItemHeight
                                maximumLength: 2
                                font.pointSize: defaultTextFont.font.pointSize
                            }
753
                            AccessibleText {
754 755 756
                                anchors.verticalCenter: parent.verticalCenter
                                text: qsTr("let.")
                            }
757
                            AccessibleTextField {
758 759 760 761 762 763 764 765
                                id: dmLegalTitlePoint
                                width: mandateFieldLenght / 2
                                height: inputItemHeight
                                maximumLength: 2
                                font.pointSize: defaultTextFont.font.pointSize
                            }
                        }
    //---Our ref.number---------------------
766
                        AccessibleText {
767 768
                            font.bold: true
                            text: qsTr("Our reference number")
769
                        }
770
                        AccessibleTextField {
771
                            id: dmSenderRefNumber
772 773
                            height: inputItemHeight
                            font.pointSize: defaultTextFont.font.pointSize
774
                            placeholderText: qsTr("Enter our reference number")
775
                            width: parent.width
776 777 778 779 780 781 782 783 784 785 786
                            InputLineMenu {
                                id: r2c2M
                                inputTextControl: dmSenderRefNumber
                                isPassword: false
                            }
                            onPressAndHold: {
                                if (settings.useExplicitClipboardOperations()) {
                                    r2c2M.implicitWidth = computeMenuWidth(r2c2M)
                                    r2c2M.open()
                                }
                            }
787
                        }
788
    //---Our file mark---------------------
789
                        AccessibleText {
790 791
                            font.bold: true
                            text: qsTr("Our file mark")
792
                        }
793
                        AccessibleTextField {
794
                            id: dmSenderIdent
795 796
                            height: inputItemHeight
                            font.pointSize: defaultTextFont.font.pointSize
797
                            placeholderText: qsTr("Enter our file mark")
798
                            width: parent.width
799 800 801 802 803 804 805 806 807 808 809
                            InputLineMenu {
                                id: r3c2M
                                inputTextControl: dmSenderIdent
                                isPassword: false
                            }
                            onPressAndHold: {
                                if (settings.useExplicitClipboardOperations()) {
                                    r3c2M.implicitWidth = computeMenuWidth(r3c2M)
                                    r3c2M.open()
                                }
                            }
810
                        }
811
    //---Your ref.number---------------------
812
                        AccessibleText {
813 814
                            font.bold: true
                            text: qsTr("Your reference number")
815
                        }
816
                        AccessibleTextField {
817
                            id: dmRecipientRefNumber
818 819
                            height: inputItemHeight
                            font.pointSize: defaultTextFont.font.pointSize
820
                            placeholderText: qsTr("Enter your reference number")
821
                            width: parent.width
822 823 824 825 826 827 828 829 830 831 832
                            InputLineMenu {
                                id: r4c2M
                                inputTextControl: dmRecipientRefNumber
                                isPassword: false
                            }
                            onPressAndHold: {
                                if (settings.useExplicitClipboardOperations()) {
                                    r4c2M.implicitWidth = computeMenuWidth(r4c2M)
                                    r4c2M.open()
                                }
                            }
833
                        }
834
    //---Your file mark---------------------
835
                        AccessibleText {
836 837
                            font.bold: true
                            text: qsTr("Your file mark")
838
                        }
839
                        AccessibleTextField {
840
                            id: dmRecipientIdent
841 842
                            height: inputItemHeight
                            font.pointSize: defaultTextFont.font.pointSize
843
                            placeholderText: qsTr("Enter your file mark")
844
                            width: parent.width
845 846 847 848
                            InputLineMenu {
                                id: r5c2M
                                inputTextControl: dmRecipientIdent
                                isPassword: false
849
                            }
850 851 852 853 854
                            onPressAndHold: {
                                if (settings.useExplicitClipboardOperations()) {
                                    r5c2M.implicitWidth = computeMenuWidth(r5c2M)
                                    r5c2M.open()
                                }
855 856
                            }
                        }
857
    //---To hands---------------------
858
                        AccessibleText {
859 860
                            font.bold: true
                            text: qsTr("To hands")
861
                        }
862
                        AccessibleTextField {
863 864 865 866
                            id: dmToHands
                            height: inputItemHeight
                            font.pointSize: defaultTextFont.font.pointSize
                            placeholderText: qsTr("Enter name")
867
                            width: parent.width
868 869 870 871
                            InputLineMenu {
                                id: r6c2M
                                inputTextControl: dmToHands
                                isPassword: false
872
                            }
873 874 875 876 877
                            onPressAndHold: {
                                if (settings.useExplicitClipboardOperations()) {
                                    r6c2M.implicitWidth = computeMenuWidth(r6c2M)
                                    r6c2M.open()
                                }
878 879
                            }
                        }
880
                    } // Column
881 882
                 } // Pane
            } // Flickable
883
        } //StackLayout
884
    } // Item
885 886 887
    Connections {
        // Connection is activated when message sending was successful.
        target: isds
888 889
        onSentMessageFinished: {
            (closePage) ? pageView.pop(StackView.Immediate) : actionButton.enabled = true
890 891
        }
    } // Connections
892
} // Item