6import QGroundControl.Controls
10 width: _totalSlots * _itemWidth
11 color: qgcPal.textField
13 property Fact fact: undefined
14 property int digitCount: 4 ///< The minimum number of digits to show for each value
15 property int incrementSlots: 1 ///< The number of visible slots to left/right of center value
17 property int _adjustedDigitCount: Math.max(digitCount, _model.initialValueAtPrecision.toString().length)
18 property int _totalDigitCount: _adjustedDigitCount + 1 + fact.units.length
19 property real _margins: (ScreenTools.implicitTextFieldHeight - ScreenTools.defaultFontPixelHeight) / 2
20 property real _increment: fact.increment
21 property real _value: fact.value
22 property int _decimalPlaces: fact.decimalPlaces
23 property string _units: fact.units
24 property real _prevValue: _value - _increment
25 property real _nextValue: _value + _increment
26 property real _itemWidth: (_totalDigitCount * ScreenTools.defaultFontPixelWidth) + (_margins * 2)
27 property real _itemHeight: ScreenTools.implicitTextFieldHeight
28 property var _valueModel
29 property int _totalSlots: (incrementSlots * 2) + 1
30 property int _currentIndex: _totalSlots / 2
31 property int _currentRelativeIndex: _currentIndex
32 property int _prevIncrementSlots: incrementSlots
33 property int _nextIncrementSlots: incrementSlots
34 property int _selectionWidth: 3
35 property var _model: fact.valueSliderModel()
36 property var _fact: fact
38 QGCPalette { id: qgcPal; colorGroupEnabled: parent.enabled }
39 QGCPalette { id: qgcPalDisabled; colorGroupEnabled: false }
41 function firstVisibleIndex() {
42 return valueListView.contentX / _itemWidth
45 function recalcRelativeIndex() {
46 _currentRelativeIndex = _currentIndex - firstVisibleIndex()
47 _prevIncrementSlots = _currentRelativeIndex
48 _nextIncrementSlots = _totalSlots - _currentRelativeIndex - 1
52 valueListView.positionViewAtIndex(0, ListView.Beginning)
53 _currentIndex = _model.resetInitialValue()
54 valueListView.positionViewAtIndex(_currentIndex, ListView.Center)
58 Component.onCompleted: {
59 valueListView.maximumFlickVelocity = valueListView.maximumFlickVelocity / 2
65 onValueChanged: reset()
68 QGCPopupDialogFactory {
71 dialogComponent: editDialogComponent
75 id: editDialogComponent
77 ParameterEditorDialog {
79 setFocus: ScreenTools.isMobile ? false : true // Works around strange android bug where wrong virtual keyboard is displayed
86 orientation: ListView.Horizontal
87 snapMode: ListView.SnapToItem
94 verticalAlignment: Text.AlignVCenter
95 horizontalAlignment: Text.AlignHCenter
96 text: value + " " + _units
97 color: qgcPal.textFieldText
102 valueListView.focus = true
103 if (_currentIndex === index) {
104 editDialogFactory.open({ title: qsTr("Value Details") })
106 _currentIndex = index
107 valueListView.positionViewAtIndex(_currentIndex, ListView.Center)
108 recalcRelativeIndex()
115 onMovementStarted: valueListView.focus = true
118 _currentIndex = firstVisibleIndex() + _currentRelativeIndex
119 fact.value = _model.valueAtModelIndex(_currentIndex)
125 width: _itemWidth * _prevIncrementSlots
127 color: qgcPal.textField
132 width: _itemWidth * _nextIncrementSlots
134 anchors.right: parent.right
135 color: qgcPal.textField
140 x: _currentRelativeIndex * _itemWidth - _borderWidth
142 width: _itemWidth + (_borderWidth * 2)
143 height: _itemHeight + (_borderWidth * 2)
144 border.width: _borderWidth
145 border.color: qgcPal.brandingBlue
148 readonly property int _borderWidth: 3