6import QGroundControl.Controls
7import QGroundControl.FlightMap
10HorizontalFactValueGridTemplate {
12 Layout.preferredWidth: topLayout.width
13 Layout.preferredHeight: topLayout.height
15 property bool settingsUnlocked: false
17 property real _margins: ScreenTools.defaultFontPixelWidth / 2
18 property int _rowMax: 2
19 property real _rowButtonWidth: ScreenTools.minTouchPixels
20 property real _rowButtonHeight: ScreenTools.minTouchPixels / 2
21 property real _editButtonSpacing: 2
23 QGCPalette { id: qgcPal; colorGroupEnabled: enabled }
27 spacing: ScreenTools.defaultFontPixelWidth
30 spacing: parent.spacing
32 id: labelValueColumnLayout
33 spacing: ScreenTools.defaultFontPixelWidth * 1.25
42 columnSpacing: ScreenTools.defaultFontPixelWidth / 4
43 flow: GridLayout.TopToBottom
49 InstrumentValueLabel {
50 Layout.fillHeight: true
51 Layout.alignment: Qt.AlignRight
52 instrumentValueData: object
60 property real _index: index
61 property real maxWidth: 0
62 property var lastCheck: new Date().getTime()
64 function recalcWidth() {
66 for (var i=0; i<valueRepeater.count; i++) {
67 newMaxWidth = Math.max(newMaxWidth, valueRepeater.itemAt(i).contentWidth)
69 maxWidth = Math.min(maxWidth, newMaxWidth)
72 InstrumentValueValue {
73 Layout.fillHeight: true
74 Layout.alignment: Qt.AlignLeft
75 Layout.preferredWidth: valueRepeater.maxWidth
76 instrumentValueData: object
78 property real lastContentWidth
80 Component.onCompleted: {
81 valueRepeater.maxWidth = Math.max(valueRepeater.maxWidth, contentWidth)
82 lastContentWidth = contentWidth
85 onContentWidthChanged: {
86 valueRepeater.maxWidth = Math.max(valueRepeater.maxWidth, contentWidth)
87 lastContentWidth = contentWidth
88 var currentTime = new Date().getTime()
89 if (currentTime - valueRepeater.lastCheck > 30 * 1000) {
90 valueRepeater.lastCheck = currentTime
91 valueRepeater.recalcWidth()
102 visible: settingsUnlocked
105 Layout.preferredWidth: ScreenTools.minTouchPixels
106 Layout.fillHeight: true
112 enabled: (_root.width + (2 * (_rowButtonWidth + _margins))) < screen.width
113 onClicked: appendColumn()
117 Layout.preferredWidth: ScreenTools.minTouchPixels
118 Layout.fillHeight: true
124 enabled: _root.columns.count > 1
125 onClicked: deleteLastColumn()
131 Layout.fillWidth: true
133 visible: settingsUnlocked
136 Layout.fillWidth: true
137 Layout.preferredHeight: ScreenTools.minTouchPixels
143 enabled: (_root.height + (2 * (_rowButtonHeight + _margins))) < (screen.height - ScreenTools.toolbarHeight)
144 onClicked: appendRow()
148 Layout.fillWidth: true
149 Layout.preferredHeight: parent.height
155 enabled: _root.rowCount > 1
156 onClicked: deleteLastRow()
162 x: labelValueColumnLayout.x
163 y: labelValueColumnLayout.y
164 width: labelValueColumnLayout.width
165 height: labelValueColumnLayout.height
166 visible: settingsUnlocked
167 cursorShape:Qt.PointingHandCursor
169 property var mappedLabelValueColumnLayoutPosition: _root.mapFromItem(labelValueColumnLayout, labelValueColumnLayout.x, labelValueColumnLayout.y)
171 onClicked: (mouse) => {
172 var columnGridLayoutItem = labelValueColumnLayout.childAt(mouse.x, mouse.y)
173 //console.log(mouse.x, mouse.y, columnGridLayoutItem)
174 var mappedMouse = labelValueColumnLayout.mapToItem(columnGridLayoutItem, mouse.x, mouse.y)
175 var labelOrDataItem = columnGridLayoutItem.childAt(mappedMouse.x, mappedMouse.y)
176 //console.log(mappedMouse.x, mappedMouse.y, labelOrDataItem, labelOrDataItem ? labelOrDataItem.instrumentValueData : "null", labelOrDataItem && labelOrDataItem.parent ? labelOrDataItem.parent.instrumentValueData : "null")
177 if (labelOrDataItem && labelOrDataItem.instrumentValueData !== undefined) {
178 valueEditDialogFactory.open({ instrumentValueData: labelOrDataItem.instrumentValueData })
183 QGCPopupDialogFactory {
184 id: valueEditDialogFactory
186 dialogComponent: valueEditDialog
192 InstrumentValueEditDialog { }