Index: sources/gui/qml/components/GridSelection.qml =================================================================== diff -u -rdb92783a0a9dab0ddf2b68c51d15b1ae1cb3ddcc -r2ef03b2ce51b4dc507f66e9671953a8e0824bde9 --- sources/gui/qml/components/GridSelection.qml (.../GridSelection.qml) (revision db92783a0a9dab0ddf2b68c51d15b1ae1cb3ddcc) +++ sources/gui/qml/components/GridSelection.qml (.../GridSelection.qml) (revision 2ef03b2ce51b4dc507f66e9671953a8e0824bde9) @@ -1,15 +1,15 @@ /*! * - * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. + * 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 RectSelectCreateTreatment.qml - * \author (last) Peter Lucia - * \date (last) 06-Oct-2020 + * \file GridSelection.qml + * \author (last) Behrouz NematiPour + * \date (last) 12-Jan-2024 * \author (original) Peter Lucia - * \date (original) 03-Aug-2020 + * \date (original) 25-Sep-2020 * */ @@ -28,24 +28,40 @@ * where only one option is selected by the user */ Rectangle { id: _root - property int rowCount : 2 - property int colCount : 2 + property int rowCount : _rowCount + property int colCount : _colCount property int curIndex : -1 property int optionHeight : Variables.gridSelectionButtonHeight property int optionWidth : Variables.gridSelectionButtonWidth property alias title : _title.text property var labels : [] + property bool active : false + property bool valid : true + readonly property int _itemCount: labels.length + readonly property int _rowCount : Math.ceil( _itemCount / _colCount ) + readonly property int _colCount : 2 + anchors.horizontalCenter: parent.horizontalCenter color : Colors.transparent - height : _root.rowCount * _root.optionHeight + height : _root.rowCount * _root.optionHeight + _title.height + _grid.anchors.topMargin width : _root.colCount * _root.optionWidth signal clicked(int vIndex) + function clear() { + _root.curIndex = -1 + _root.active = false + } + + function reset(vIndex) { + _root.curIndex = vIndex + _root.active = true + } + Text { id : _title text : "" - color : Colors.textMain; + color : _root.valid ? Colors.textMain : Colors.createTreatmentInvalidParam font.pixelSize : Fonts.fontPixelFluidText } @@ -66,13 +82,11 @@ height : _root.optionHeight width : _root.optionWidth radius : Variables.dialogRadius - Binding on selected { - when : _root.curIndex > -1 - value : index === _root.curIndex - } + selected : _root.curIndex > -1 ? index === _root.curIndex : false onClicked: { _root.curIndex = index _root.clicked ( index ) + _root.active = true } } }