/*!
 *
 * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved.
 * \copyright                                                       \n
 *          THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM,  \n
 *          IN PART OR IN WHOLE,                                    \n
 *          WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. \n
 *
 * \file    ConfirmTreatmentTable.qml
 * \date    2020/08/25
 * \author  Peter Lucia
 *
 */

// Qt
import QtQuick 2.12

// Project

//  Qml imports
import "qrc:/globals"
import "qrc:/components"

Rectangle {
    id: _root
    objectName: "ConfirmTreatmentTable"
    width: Variables.createTreatmentTableWidth
    height: Variables.createTreatmentTableHeight
    color: Colors.backgroundDialog

    Rectangle {
        id: _header
        width: parent.width
        height: Variables.createTreatmentHeaderHeight
        color: "transparent"
        radius: 5

        Rectangle {
            id: _treatment_profile_id
            objectName: _root.objectName + "_treatment_profile_id"
            height: 40
            width: height
            anchors.top: _header.top
            anchors.left: _header.left
            anchors.topMargin: Variables.createTreatmentMargin
            anchors.leftMargin: Variables.createTreatmentMargin
            color: Colors.createTrProfileID
            radius: 5

            Text {
                id: _treatment_profile_id_text
                objectName: _treatment_profile_id.objectName + "_treatment_profile_id_text"
                color: Colors.backgroundDialog
                text: "1"
                font.pixelSize: Fonts.fontPixelTextRectTitle
                anchors.centerIn: _treatment_profile_id
                font.bold: true
            }
        }

        Text {
            id: _treatment_profile_name
            objectName: _root.objectName + "_treatment_profile_name"
            anchors.bottom: _treatment_profile_id.bottom
            anchors.left: _treatment_profile_id.right
            anchors.topMargin: Variables.createTreatmentMargin
            anchors.leftMargin: 20
            text: "New Treatment"
            color: "white"
            font.pixelSize: Fonts.createTreatmentFontSize
        }
    }

    Text {
        id: _prescription
        objectName: _root.objectName + "_prescription"
        text: "PRESCRIPTION"
        font.pixelSize: Fonts.crTreatmentTableFontSize
        color: "white"
        anchors.left: parent.left
        anchors.top: _header.bottom
        anchors.leftMargin: Variables.createTreatmentMargin
    }

    Text {
        id: _operating_parameters
        objectName: _root.objectName + "_operating_parameters"
        text: "OPERATING PARAMETERS"
        font.pixelSize: Fonts.crTreatmentTableFontSize
        color: "white"
        anchors.top: _header.bottom
        anchors.left: _root.horizontalCenter
    }

    ConfirmTreatmentSubTable {
        id: _left_table
        anchors.top: _prescription.bottom
        anchors.left: _root.left
        anchors.leftMargin: Variables.createTreatmentMargin
        anchors.topMargin: Variables.createTreatmentTableMargin
        anchors.bottom: parent.bottom
        width: parent.width - 2*Variables.createTreatmentMargin
        height: _root.height - _header.height
        prescriptionKeys: vTreatmentCreate.doGetPrescriptionParameterNames()
        prescriptionValues: vTreatmentCreate.doGetPrescriptionParameterValues()
        operatingKeys: vTreatmentCreate.doGetOperatingParameterNames()
        operatingValues: vTreatmentCreate.doGetOperatingParameterValues()
        onVisibleChanged: {
            if (visible) {
                prescriptionKeys = vTreatmentCreate.doGetPrescriptionParameterNames()
                prescriptionValues = vTreatmentCreate.doGetPrescriptionParameterValues()
                operatingKeys = vTreatmentCreate.doGetOperatingParameterNames()
                operatingValues = vTreatmentCreate.doGetOperatingParameterValues()
            }
        }
    }
}
