/*!
 * 
 * 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 TreatmentStart.qml
 * \author (last) Behrouz NemaiPour
 * \date (last) 08-Jun-2020
 * \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

    property int areaWidth      : 400
    property int areaHeightRow1 : 170
    property int areaHeightRow2 : 225
    property int areaHeightRow3 : 200

    property int leftColumnX    :  40
    property int rightColumnX   : Variables.applicationWidth - leftColumnX - areaWidth

    property int row1Y          : 100
    property int row2Y          : 290 // 320
    property int row3Y          : 540 // 570

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

    signal backClicked()

    signal sectionFlowClicked()
    signal sectionTimeClicked()
    signal sectionUltrafiltrationClicked()

    // ---------- COLUMN LEFT
    TreatmentFlows              { id: _flowsTouchArea
        x       : leftColumnX
        y       : row1Y
        width   : areaWidth
        height  : areaHeightRow1
        onClicked: {
            sectionFlowClicked()
        }
    }
    Line                        { x: 0; y: row1LineY; length: lineLength }
    TreatmentVitals             { id: _vitalsTouchArea
        x       : leftColumnX
        y       : row2Y
        width   : areaWidth
        height  : areaHeightRow2
    }
    Line                        { x: 0; y: row2LineY; length: lineLength }
    TreatmentPressure           { id: _pressureTouchArea
        // TEST : these values are test values.
        arterialMinimum     : -400
        arterialLowerBound  : -300
        arterialUpperBound  :  100
        arterialMaximum     :  400

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

        x                   : leftColumnX
        y                   : row3Y
        width       : areaWidth
        height      : areaHeightRow3
    }

    // ---------- COLUMN RIGHT
    TreatmentUltrafiltration    { id: _ultrafiltrationTouchArea;
        x           : rightColumnX
        y           : row1Y
        width       : areaWidth
        height      : areaHeightRow1
        onClicked   : {
            sectionUltrafiltrationClicked()
        }
    }
    Line                        { x: rightLinesX; y: row1LineY; length: lineLength }
    TreatmentSaline             { id: _SalineTouchArea
        x       : rightColumnX
        y       : row2Y
        width       : areaWidth
        height      : areaHeightRow2
    }
    Line                        { x: rightLinesX; y: row2LineY; length: lineLength; }
    TreatmentFluid              { id: _heparinTouchArea
        // TODO : Another component should be inherited from this for Heparin
        buttonText: qsTr("PAUSE DELIVERY")

        x       : rightColumnX
        y       : row3Y
        width       : areaWidth
        height      : areaHeightRow3
        title   : qsTr("HEPARIN")
        cumulativeVisible: false
    }

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

    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
                backClicked()
            }
        }
    }
}
