Hide empty categories when filtering

When filtering the OS list, if all items in a category/sublist are
filtered out then don't show the category/sublist.

Also, clear the selected OS when the HW device is changed, otherwise you
can get weird effects like having an incompatible (hw, os) pair selected
or the highlighted OS moving when the items in the OS list change.
This commit is contained in:
David Turner 2023-10-19 11:50:29 +01:00 committed by Tom Dewey
parent a29d2c9d7c
commit 9a7fc7bf3c

View file

@ -1444,6 +1444,11 @@ ApplicationWindow {
if ("subitems" in entry) { if ("subitems" in entry) {
filterItems(entry["subitems"], tags, hwTagMatchingType) filterItems(entry["subitems"], tags, hwTagMatchingType)
// If this sub-list has no items then hide it
if (entry["subitems"].length == 0) {
list.splice(i, 1)
}
} }
} }
} }
@ -1655,6 +1660,15 @@ ApplicationWindow {
} }
}) })
// When the HW device is changed, reset the OS selection otherwise
// you get a weird effect with the selection moving around in the list
// when the user next opens the OS list, and the user could still have
// an OS selected which isn't compatible with this HW device
oslist.currentIndex = -1
osswipeview.currentIndex = 0
osbutton.text = qsTr("CHOOSE OS")
writebutton.enabled = false
hwbutton.text = hwmodel.name hwbutton.text = hwmodel.name
hwpopup.close() hwpopup.close()
} }