QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
LoggingCategoriesDialog.qml
Go to the documentation of this file.
1import QGroundControl
2import QGroundControl.Controls
3import QGroundControl.Logging
4import QtQuick
5import QtQuick.Layouts
6
7QGCPopupDialog {
8 id: catDialog
9
10 readonly property var _filteredModel: QGCLoggingCategoryManager.filteredFlatModel
11
12 buttons: Dialog.Close
13 title: qsTr("Logging Categories")
14
15 QGCPalette { id: qgcPal; colorGroupEnabled: enabled }
16
17 QGCCheckBoxSlider {
18 id: _measureSlider
19 visible: false
20 }
21
22 ColumnLayout {
23 SettingsGroupLayout {
24 Layout.fillWidth: true
25 heading: qsTr("Search")
26
27 RowLayout {
28 Layout.fillWidth: true
29 spacing: ScreenTools.defaultFontPixelHeight / 2
30
31 QGCTextField {
32 id: searchText
33 Layout.fillWidth: true
34 placeholderText: qsTr("Filter categories…")
35
36 onTextChanged: _searchDebounce.restart()
37
38 Timer {
39 id: _searchDebounce
40 interval: 200
41 repeat: false
42 onTriggered: QGCLoggingCategoryManager.setFilterText(searchText.text)
43 }
44 }
45
46 QGCButton {
47 text: qsTr("Clear")
48 onClicked: searchText.text = ""
49 }
50 }
51 }
52
53 SettingsGroupLayout {
54 Layout.fillWidth: true
55 heading: qsTr("Active Categories")
56 showDividers: false
57
58 Repeater {
59 model: QGCLoggingCategoryManager.enabledCategories
60
61 QGCCheckBoxSlider {
62 required property string modelData
63
64 Layout.fillWidth: true
65 checked: true
66 text: modelData
67 onToggled: {
68 // Display uses "ADSB.*" but manager stores "ADSB." — strip trailing *
69 const key = modelData.endsWith(".*") ? modelData.slice(0, -1) : modelData
70 QGCLoggingCategoryManager.setCategoryEnabled(key, false)
71 }
72 }
73 }
74
75 QGCButton {
76 text: qsTr("Reset All")
77
78 onClicked: QGCLoggingCategoryManager.disableAllCategories()
79 }
80 }
81
82 // Category list (no search)
83 SettingsGroupLayout {
84 Layout.fillWidth: true
85 heading: qsTr("Categories")
86 visible: searchText.text === ""
87
88 TreeView {
89 id: treeView
90 Layout.preferredWidth: _maxRowWidth
91 Layout.preferredHeight: contentHeight > 0 ? contentHeight : ScreenTools.defaultFontPixelHeight * 30
92 rowSpacing: ScreenTools.defaultFontPixelHeight * 0.25
93 model: QGCLoggingCategoryManager.treeModel
94 interactive: false
95 clip: true
96
97 property real _maxRowWidth: ScreenTools.defaultFontPixelWidth
98
99 delegate: RowLayout {
100 id: treeViewRowLayout
101 implicitWidth: treeView._maxRowWidth
102 spacing: ScreenTools.defaultFontPixelWidth * 0.5
103
104 required property int depth
105 required property bool expanded
106 required property string fullName
107 required property bool hasChildren
108 required property bool categoryEnabled
109 required property int row
110 required property string shortName
111 required property TreeView treeView
112
113 Component.onCompleted: _calcMaxRowWidth();
114 TableView.onReused: _calcMaxRowWidth();
115
116 function _calcMaxRowWidth() {
117 let indentWidth = treeViewRowLayout.depth > 0 ? rowIndent.width : 0
118 let arrowWidth = treeViewRowLayout.hasChildren ? expandArrow.width : 0
119 let checkBoxSliderWidth = _measureSlider.width + ScreenTools.defaultFontPixelWidth * treeViewRowLayout.shortName.length
120 let spacing = (rowIndent.visible ? treeViewRowLayout.spacing : 0) + (treeViewRowLayout.hasChildren ? treeViewRowLayout.spacing : 0)
121 let rowWidth = indentWidth + arrowWidth + checkBoxSliderWidth + spacing
122 //console.log("update", treeViewRowLayout.fullName, indentWidth, arrowWidth, checkBoxSliderWidth, spacing, rowWidth, treeView._maxRowWidth)
123 if (rowWidth > treeView._maxRowWidth) {
124 treeView._maxRowWidth = rowWidth
125 }
126 }
127
128 Item {
129 id: rowIndent
130 Layout.preferredWidth: ScreenTools.defaultFontPixelWidth * treeViewRowLayout.depth
131 Layout.preferredHeight: 1
132 visible: treeViewRowLayout.depth > 0
133 }
134
135 QGCColoredImage {
136 id: expandArrow
137 Layout.preferredWidth: ScreenTools.defaultFontPixelHeight * 0.5
138 Layout.preferredHeight: Layout.preferredWidth
139 color: qgcPal.text
140 fillMode: Image.PreserveAspectFit
141 rotation: treeViewRowLayout.expanded ? 0 : -90
142 source: "/qmlimages/arrow-down.png"
143 visible: treeViewRowLayout.hasChildren
144
145 QGCMouseArea {
146 fillItem: parent
147 onClicked: treeView.toggleExpanded(treeViewRowLayout.row)
148 }
149 }
150
151 QGCCheckBoxSlider {
152 id: checkBoxSlider
153 Layout.fillWidth: true
154 text: treeViewRowLayout.shortName
155 checked: treeViewRowLayout.categoryEnabled
156 onToggled: QGCLoggingCategoryManager.setCategoryEnabled(treeViewRowLayout.fullName, checked)
157 }
158 }
159 }
160 }
161
162 // Flat filtered view (with search)
163 SettingsGroupLayout {
164 heading: qsTr("Search Results")
165 visible: searchText.text !== ""
166
167 QGCListView {
168 id: searchResultsView
169 Layout.preferredWidth: _maxRowWidth
170 Layout.preferredHeight: contentHeight
171 interactive: false
172 clip: true
173 model: _filteredModel
174 spacing: ScreenTools.defaultFontPixelHeight * 0.25
175
176 property real _maxRowWidth: ScreenTools.defaultFontPixelWidth
177
178 delegate: QGCCheckBoxSlider {
179 required property bool categoryEnabled
180 required property string fullName
181
182 width: searchResultsView._maxRowWidth
183 text: fullName
184 checked: categoryEnabled
185 onToggled: QGCLoggingCategoryManager.setCategoryEnabled(fullName, checked)
186
187 Component.onCompleted: _updateMaxWidth()
188 ListView.onReused: _updateMaxWidth()
189
190 function _updateMaxWidth() {
191 let rowWidth = _measureSlider.width + ScreenTools.defaultFontPixelWidth * fullName.length
192 if (rowWidth > searchResultsView._maxRowWidth) {
193 searchResultsView._maxRowWidth = rowWidth
194 }
195 }
196 }
197 }
198
199 QGCLabel {
200 color: qgcPal.colorGrey
201 text: qsTr("No matching categories")
202 visible: searchResultsView.count === 0 && searchText.text !== ""
203 }
204 }
205 }
206}