2import QGroundControl.Controls
3import QGroundControl.Logging
10 readonly property var _filteredModel: QGCLoggingCategoryManager.filteredFlatModel
13 title: qsTr("Logging Categories")
15 QGCPalette { id: qgcPal; colorGroupEnabled: enabled }
24 Layout.fillWidth: true
25 heading: qsTr("Search")
28 Layout.fillWidth: true
29 spacing: ScreenTools.defaultFontPixelHeight / 2
33 Layout.fillWidth: true
34 placeholderText: qsTr("Filter categories…")
36 onTextChanged: _searchDebounce.restart()
42 onTriggered: QGCLoggingCategoryManager.setFilterText(searchText.text)
48 onClicked: searchText.text = ""
54 Layout.fillWidth: true
55 heading: qsTr("Active Categories")
59 model: QGCLoggingCategoryManager.enabledCategories
62 required property string modelData
64 Layout.fillWidth: true
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)
76 text: qsTr("Reset All")
78 onClicked: QGCLoggingCategoryManager.disableAllCategories()
82 // Category list (no search)
84 Layout.fillWidth: true
85 heading: qsTr("Categories")
86 visible: searchText.text === ""
90 Layout.preferredWidth: _maxRowWidth
91 Layout.maximumHeight: ScreenTools.defaultFontPixelHeight * 40
92 Layout.preferredHeight: contentHeight > 0 ? Math.min(contentHeight, ScreenTools.defaultFontPixelHeight * 40)
93 : ScreenTools.defaultFontPixelHeight * 30
94 rowSpacing: ScreenTools.defaultFontPixelHeight * 0.25
95 model: QGCLoggingCategoryManager.treeModel
98 property real _maxRowWidth: ScreenTools.defaultFontPixelWidth
100 delegate: RowLayout {
101 id: treeViewRowLayout
102 implicitWidth: treeView._maxRowWidth
103 spacing: ScreenTools.defaultFontPixelWidth * 0.5
105 required property int depth
106 required property bool expanded
107 required property string fullName
108 required property bool hasChildren
109 required property bool categoryEnabled
110 required property int row
111 required property string shortName
112 required property TreeView treeView
114 Component.onCompleted: _calcMaxRowWidth();
115 TableView.onReused: _calcMaxRowWidth();
117 function _calcMaxRowWidth() {
118 let indentWidth = treeViewRowLayout.depth > 0 ? rowIndent.width : 0
119 let arrowWidth = treeViewRowLayout.hasChildren ? expandArrow.width : 0
120 let checkBoxSliderWidth = _measureSlider.width + ScreenTools.defaultFontPixelWidth * treeViewRowLayout.shortName.length
121 let spacing = (rowIndent.visible ? treeViewRowLayout.spacing : 0) + (treeViewRowLayout.hasChildren ? treeViewRowLayout.spacing : 0)
122 let rowWidth = indentWidth + arrowWidth + checkBoxSliderWidth + spacing
123 //console.log("update", treeViewRowLayout.fullName, indentWidth, arrowWidth, checkBoxSliderWidth, spacing, rowWidth, treeView._maxRowWidth)
124 if (rowWidth > treeView._maxRowWidth) {
125 treeView._maxRowWidth = rowWidth
131 Layout.preferredWidth: ScreenTools.defaultFontPixelWidth * treeViewRowLayout.depth
132 Layout.preferredHeight: 1
133 visible: treeViewRowLayout.depth > 0
138 Layout.preferredWidth: ScreenTools.defaultFontPixelHeight * 0.5
139 Layout.preferredHeight: Layout.preferredWidth
141 fillMode: Image.PreserveAspectFit
142 rotation: treeViewRowLayout.expanded ? 0 : -90
143 source: "/qmlimages/arrow-down.png"
144 visible: treeViewRowLayout.hasChildren
148 onClicked: treeView.toggleExpanded(treeViewRowLayout.row)
154 Layout.fillWidth: true
155 text: treeViewRowLayout.shortName
156 checked: treeViewRowLayout.categoryEnabled
157 onToggled: QGCLoggingCategoryManager.setCategoryEnabled(treeViewRowLayout.fullName, checked)
163 // Flat filtered view (with search)
164 SettingsGroupLayout {
165 heading: qsTr("Search Results")
166 visible: searchText.text !== ""
169 id: searchResultsView
170 Layout.preferredWidth: _maxRowWidth
171 Layout.preferredHeight: Math.min(contentHeight, ScreenTools.defaultFontPixelHeight * 40)
173 model: _filteredModel
174 spacing: ScreenTools.defaultFontPixelHeight * 0.25
176 property real _maxRowWidth: ScreenTools.defaultFontPixelWidth
178 delegate: QGCCheckBoxSlider {
179 required property bool categoryEnabled
180 required property string fullName
182 width: searchResultsView._maxRowWidth
184 checked: categoryEnabled
185 onToggled: QGCLoggingCategoryManager.setCategoryEnabled(fullName, checked)
187 Component.onCompleted: _updateMaxWidth()
188 ListView.onReused: _updateMaxWidth()
190 function _updateMaxWidth() {
191 let rowWidth = _measureSlider.width + ScreenTools.defaultFontPixelWidth * fullName.length
192 if (rowWidth > searchResultsView._maxRowWidth) {
193 searchResultsView._maxRowWidth = rowWidth
200 color: qgcPal.colorGrey
201 text: qsTr("No matching categories")
202 visible: searchResultsView.count === 0 && searchText.text !== ""