/*!
 *
 * Copyright (c) 2020-2024 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    TreatmentAdjustmentPressuresLimits.qml
 * \author  (last)      Vy
 * \date    (last)      07-Sep-2023
 * \author  (original)  Behrouz NematiPour
 * \date    (original)  01-Nov-2020
 *
 */

// Qt
import QtQuick 2.12

// Project

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

/*!
 * \brief   TreatmentAdjustmentPressures.qml is the screen
 *          To adjust the treatment inline blood pressure ranges of Arterial and venous
 */
TreatmentAdjustmentBase { id: _root
    objectName: "_TreatmentAdjustmentPressuresLimits"  // SquishQt testability

    readonly property alias arterialPressureLimitWindow : _arterialWindow.value
    readonly property alias venousPressureLimitWindow   : _venousWindow.value
    readonly property alias venousPressureLimitAsymtrc  : _venousAsymmetricWindow.value
    readonly property alias tmpLimitWindow              : _tmpWindow.value

    titleText: qsTr("Pressure Window Limit Settings")
    height              : Variables.smallDialogHeight
    width               : Variables.smallDialogWidth

    onAboutToShow: {
        _arterialWindow.value           = vTreatmentPressureOcclusion.arterialPressure
        _venousWindow.value             = vTreatmentPressureOcclusion.venousPressure
        _venousAsymmetricWindow.value   = 0 // vTreatmentPressureOcclusion.venousLongPressure
        _tmpWindow.value                = vTreatmentPressureOcclusion.tmpPressure
    }

    Item { id: _contentItem
        objectName: "_contentItem"
        anchors {
            top: parent.top
            bottom: notification.top
            left: parent.left
            right: parent.right
        }

        Item { id: _contentArea
            objectName: "_contentArea"
            anchors {
                top: parent.top
                bottom: _confirmButton.top
                left: parent.left
                right: parent.right
            }

            Column { id: _controlColumn
                objectName: "_controlColumn"
                anchors.centerIn: parent
                spacing: Variables.defaultMargin

                LabelUnitValueAdjuster { id: _arterialWindow
                    objectName          : "_arterialWindow"
                    text                : qsTr("Arterial Window")
                    titleFontSize       : Fonts.fontPixelContainerTitleSmall
                    unitText            : Variables.unitTextPressure
                    unitFontSize        : Fonts.fontPixelContainerUnitSmall
                    isActive            : true
                    minimum             : vTreatmentPressureOcclusion.arterialMin
                    maximum             : vTreatmentPressureOcclusion.arterialMax
                    step                : vTreatmentRanges.arterialPressureLimitWindowRes

                    onDidChange         : function(vValue) { value = vValue }
                }

                LabelUnitValueAdjuster { id: _venousWindow
                    objectName          : "_venousWindow"
                    text                : qsTr("Venous Window")
                    titleFontSize       : _arterialWindow.titleFontSize
                    unitText            : Variables.unitTextPressure
                    unitFontSize        : _arterialWindow.unitFontSize
                    isActive            : true
                    minimum             : vTreatmentPressureOcclusion.venousMin
                    maximum             : vTreatmentPressureOcclusion.venousMax
                    step                : vTreatmentRanges.venousPressureLimitWindowRes

                    onDidChange         : function(vValue) { value = vValue }
                }

                LabelUnitValueAdjuster { id: _venousAsymmetricWindow
                    objectName          : "_venousAsymmetricWindow"
                    text                : qsTr("Venous Asymmetric Window")
                    titleFontSize       : _arterialWindow.titleFontSize
                    unitText            : Variables.unitTextPressure
                    unitFontSize        : _arterialWindow.unitFontSize
                    isActive            : true
                    minimum             : vTreatmentRanges.venousPressureLimitAsymtrcMin
                    maximum             : vTreatmentRanges.venousPressureLimitAsymtrcMax
                    step                : vTreatmentRanges.venousPressureLimitAsymtrcRes

                    onDidChange         : function(vValue) { value = vValue }
                }

                LabelUnitValueAdjuster { id: _tmpWindow
                    objectName          : "_tmpWindow"
                    text                : qsTr("TMP Window")
                    titleFontSize       : _arterialWindow.titleFontSize
                    unitText            : Variables.unitTextPressure
                    unitFontSize        : _arterialWindow.unitFontSize
                    isActive            : true
                    minimum             : vTreatmentPressureOcclusion.tmpMin
                    maximum             : vTreatmentPressureOcclusion.tmpMax
                    step                : vTreatmentRanges.transmembranePressureLimitWindowRes

                    onDidChange         : function(vValue) { value = vValue }
                }
            }
        }

        TouchRect { id: _confirmButton
            objectName  : "_confirmButton"
            anchors {
                bottom          : parent.bottom
                bottomMargin    : Variables.defaultMargin
                horizontalCenter: parent.horizontalCenter
            }
            width       : Variables.defaultButtonWidth
            height      : Variables.defaultButtonHeight
            text {
                text        : qsTr("Confirm")
                font.weight : Font.Medium
            }
            isDefault   : true

            onClicked   : {
                _root.confirmClicked()
            }
        }
    }
}
