/*!
 *
 * 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    ManagerHome.qml
 * \date    2019/10/21
 * \author  Behrouz NematiPour
 *
 */

// 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

    property int leftColumnX    :  40
    property int rightColumnX   : 875

    property int row1Y          : 100
    property int row2Y          : 320
    property int row3Y          : 570

    property int lineLength     : 450
    property int leftLinesX     :   0
    property int rightLinesX    : Variables.applicationWidth - lineLength
    property int row1LineY      : 275
    property int row2LineY      : 525

    signal backPressed()

    signal sectionFlowClicked()

    // ---------- COLUMN LEFT
    TreatmentFlows              { id: _flowsTouchArea
        x       : leftColumnX
        y       : row1Y
        onClicked: {
            sectionFlowClicked()
        }
    }
    Line                        { x: 0; y: row1LineY; length: lineLength }
    TreatmentVitals             { id: _vitalsTouchArea
        x       : leftColumnX
        y       : row2Y
    }
    Line                        { x: 0; y: row2LineY; length: lineLength }
    TreatmentPressure           { id: _pressureTouchArea
        arterialMinimum     : -400
        arterialLowerBound  : -300
        arterialUpperBound  :  100
        arterialMaximum     :  400

          venousMinimum     : -100
          venousLowerBound  : -100
          venousUpperBound  :  500
          venousMaximum     :  800

        x                   : leftColumnX
        y                   : row3Y
        width               : _flowsTouchArea.width
    }

    // ---------- COLUMN RIGHT
    TreatmentUltrafiltration    { id: _ultrafiltrationTouchArea;
        x       : rightColumnX
        y       : row1Y
        width   : _flowsTouchArea.width
        minimum : vTreatmentRanges.treatmentRanges_Ultrafiltration_Volume_Min.toFixed(2)
        maximum : vTreatmentRanges.treatmentRanges_Ultrafiltration_Volume_Max.toFixed(2)
        value   : vTreatmentUltrafiltration.ultrafiltration_MeasUFVol.toFixed(2);
        valueEx : 0
    }
    Line                        { x: rightLinesX; y: row1LineY; length: lineLength }
    TreatmentFluid              { id: _fluidManagementTouchArea
        x       : rightColumnX
        y       : row2Y
        width   : _flowsTouchArea.width
    }
    Line                        { x: rightLinesX; y: row2LineY; length: lineLength; }
    TreatmentInfusion           { id: _solutionInfusionTouchArea
        x       : rightColumnX
        y       : row3Y
        width   : _flowsTouchArea.width
    }

    // ---------- Center
    TreatmentTime               { id: _treatmentTime }

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

    Connections { target: _treatmentMenu
        onItemPressed: {
            // TEST : this is a test code since the back button has been removed
            // and also we don't have Treatment complete yet.
            if (vIndex == 0) {
                _treatmentMenu.hidden = true
                backPressed()
            }
        }
    }
}
