/*!
 *
 * 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    TreatmentHome.qml
 * \author  (last)      Behrouz NematiPour
 * \date    (last)      10-Jan-2024
 * \author  (original)  Behrouz NematiPour
 * \date    (original)  27-Jan-2020
 *
 */

// Qt
import QtQuick 2.12

// Project

//  Qml imports
import "qrc:/globals"
import "qrc:/components"
import "qrc:/pages/treatment/sections"

/*!
 * \brief   ManagerHome is the screen
 * which is the default screen in the "Manager" stack
 */
ScreenItem { id: _root
    property int          bloodFlow_MeasuredFlow_Precision: 0
    property int dialysateInletFlow_MeasuredFlow_Precision: 0

    signal backClicked()

    signal sectionFlowClicked()
    signal sectionVitalsClicked()
    signal sectionPressuresClicked()
    signal sectionTimeClicked()
    signal sectionUltrafiltrationClicked()

    // ---------- COLUMN LEFT
    TreatmentFlows              { id: _flowsTouchArea
        x                   : Variables.screenGridLeftColumnX
        y                   : Variables.screenGridRow3Y
        width               : Variables.screenGridAreaWidth
        height              : Variables.screenGridAreaHeightRow3
        onClicked: {
            sectionFlowClicked()
        }
    }
    Line                        { x: 0; y: Variables.screenGridRow1LineY; length: Variables.screenGridLineLength }
    TreatmentVitals             { id: _vitalsTouchArea
        x       : Variables.screenGridLeftColumnX
        y       : Variables.screenGridRow2Y
        width   : Variables.screenGridAreaWidth
        height  : Variables.screenGridAreaHeightRow2
        onClicked: {
            sectionVitalsClicked()
        }
        notification.text:  qsTr("Interval:" )
                          + " " + (vTreatmentVitals.interval ? (vTreatmentVitals.interval + qsTr("min")) : qsTr("OFF"))
                          + " , "
                          + qsTr("Last Read:")
                          + " " +  vTreatmentVitals.lastRead
        Text { id: _vitalCountdown
            color   : "gray"
            anchors {
                top         : parent.top
                right       : parent.right
                rightMargin : 50
            }
            horizontalAlignment : Text.AlignHCenter
            verticalAlignment   : Text.AlignVCenter
            height  : 15
            width   : 100
            text    : vTreatmentVitals.interval ? ( vTreatmentVitals.countdown ) : ""
            font.pixelSize: 16
        }
    }

    Line                        { x: 0; y: Variables.screenGridRow2LineY; length: Variables.screenGridLineLength }

    TreatmentPressures          { id: _pressuresTouchArea
        x       : Variables.screenGridLeftColumnX
        y       : Variables.screenGridRow1Y
        width   : Variables.screenGridAreaWidth
        height  : Variables.screenGridAreaHeightRow1
        onClicked: {
            sectionPressuresClicked()
        }
    }

    // ---------- COLUMN RIGHT
    TreatmentUltrafiltration    { id: _ultrafiltrationTouchArea;
        x           : Variables.screenGridRightColumnX
        y           : Variables.screenGridRow1Y
        width       : Variables.screenGridAreaWidth
        height      : Variables.screenGridAreaHeightRow1
        onClicked   : {
            sectionUltrafiltrationClicked()
        }
    }
    Line                        { x: Variables.screenGridRightLinesX; y: Variables.screenGridRow1LineY; length: Variables.screenGridLineLength }
    TreatmentSaline             { id: _salineTouchArea
        x           : Variables.screenGridRightColumnX
        y           : Variables.screenGridRow2Y
        width       : Variables.screenGridAreaWidth
        height      : Variables.screenGridAreaHeightRow2
    }
    Line                        { x: Variables.screenGridRightLinesX; y: Variables.screenGridRow2LineY; length: Variables.screenGridLineLength; }
    TreatmentHeparin            { id: _heparinTouchArea
        x           : Variables.screenGridRightColumnX
        y           : Variables.screenGridRow3Y
        width       : Variables.screenGridAreaWidth
        height      : Variables.screenGridAreaHeightRow3
    }

    // ---------- Center
    TreatmentTime               { id: _treatmentTime
        onClicked: {
            sectionTimeClicked()
        }
    }

    onVisibleChanged: {
        if (visible) {
            _mainMenu.hidden = true
            _treatmentMenu.hidden = false
        }
    }
}
