/*!
 *
 * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved.
 * \copyright
 * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN
 * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER.
 *
 * \file    PostTreatmentMainStack.qml
 * \author  (last)      Behrouz NematiPour
 * \date    (last)      20-Apr-2021
 * \author  (original)  Behrouz NematiPour
 * \date    (original)  20-Apr-2021
 *
 */

// Qt
import QtQuick 2.12


// Project
//  Qml imports
import "qrc:/globals"
import "qrc:/components"
import "qrc:/compounds"
import "qrc:/pages/posttreatment"

/*!
 * \brief   the post treatment Treatment Log review screen
 */
PostTreatmentBase { id: _root
    signal itemClicked(int vIndex)

    readonly property alias itemsText : _parametersGrid.itemsText
    readonly property alias itemsValue: _parametersGrid.itemsValue
    readonly property alias itemsUnit : _parametersGrid.itemsUnit

    header.confirmText.text: qsTr("NEXT")

    ExportButton {
        anchors.top     : parent.top
        anchors.left    : parent.left
        exportFunction  : vPostTreatmentAdjustmentTreatmentLog.doExport
        enabled         : vPostTreatmentAdjustmentTreatmentLog.isIdle && _GuiView.usbReady
    }

    ScrollBar {
        anchors.fill: _flickable
        flickable   : _flickable
        backColor   : Colors.backgroundDialog
    }

    Flickable { id: _flickable
        clip: true
        anchors {
            top             : _root.title.bottom
            topMargin       : Variables.minVGap * 2 // * 2 : it was too close to title and also better with rows not half cut.
            bottom          : _root.bottom
            bottomMargin    : Variables.notificationHeight + Variables.minVGap
            horizontalCenter: parent.horizontalCenter
        }
        width        : parent.width - Variables.minVGap2 * 2 // * 2 : for each side
        contentWidth : width
        contentHeight: _parametersGrid.height

        TouchGrid { id: _parametersGrid
            height          : rowCount * ( rowSpacing + itemHeight  ) + itemHeight
            width           : parent.width
            colCount        : 2
            rowCount        : 17
            itemWidth       : 575
            rowSpacing      : 0
            columnSpacing   : 50
            lineColor       : Colors.backgroundMain
            itemsText       : vPostTreatmentAdjustmentTreatmentLog.parametersTitle
            itemsValue      : vPostTreatmentAdjustmentTreatmentLog.parametersText
            itemsUnit       : vPostTreatmentAdjustmentTreatmentLog.parametersUnit
            itemsValueLeftMargin    : 350 // if decreased maybe covered by title
            itemsUnitLeftMargin     : 470 // if increased will be covered by chevron if touchable
            itemsTouchable  : [
                0,0,0,0,1,0,0,0,0,0,
                1,0,0,0,0,0,0,0,0,0,
                0,0,0,0,0,0,0,0,0,0,
                0,0,0,0,0,0,0,0,0,0,
            ]
            onItemClicked: _root.itemClicked(vIndex)
        }
    }
}

