mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Do not draw empty property rows.
This commit is contained in:
parent
6c5b35d704
commit
efc2915628
@ -1,3 +1,4 @@
|
|||||||
|
import itertools
|
||||||
import logging
|
import logging
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|
||||||
@ -23,7 +24,9 @@ class PropertyEditor(QGridLayout):
|
|||||||
self.flight_member = flight_member
|
self.flight_member = flight_member
|
||||||
self.flight_member_update_listeners: list[Callable[[FlightMember], None]] = []
|
self.flight_member_update_listeners: list[Callable[[FlightMember], None]] = []
|
||||||
|
|
||||||
for row, prop in enumerate(flight.unit_type.iter_props()):
|
last_label: QWidget | None = None
|
||||||
|
row = itertools.count()
|
||||||
|
for prop in flight.unit_type.iter_props():
|
||||||
if prop.label is None:
|
if prop.label is None:
|
||||||
if prop.control != "label":
|
if prop.control != "label":
|
||||||
logging.error(
|
logging.error(
|
||||||
@ -44,15 +47,26 @@ class PropertyEditor(QGridLayout):
|
|||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Draw any deferred label if this is a real control.
|
||||||
|
if last_label is not None and widget is not None:
|
||||||
|
self.addWidget(last_label, next(row), 0)
|
||||||
|
last_label = None
|
||||||
|
|
||||||
label = prop.label
|
label = prop.label
|
||||||
if widget is None:
|
if widget is None:
|
||||||
label = f"<strong>{label}</label>"
|
label = f"<strong>{label}</label>"
|
||||||
self.addWidget(QLabel(label), row, 0)
|
|
||||||
|
|
||||||
# If prop.control is "label", widget will be None. We only need to add the
|
label = QLabel(label)
|
||||||
# label, not the control.
|
if widget is None:
|
||||||
if widget is not None:
|
# The "control" is only a section label. Defer adding it to the layout
|
||||||
self.addWidget(widget, row, 1)
|
# so that we can skip empty sections.
|
||||||
|
last_label = label
|
||||||
|
else:
|
||||||
|
# Else the label is for the control itself and should be drawn
|
||||||
|
# immediately.
|
||||||
|
this_row = next(row)
|
||||||
|
self.addWidget(label, this_row, 0)
|
||||||
|
self.addWidget(widget, this_row, 1)
|
||||||
|
|
||||||
def control_for_property(self, prop: UnitPropertyDescription) -> QWidget | None:
|
def control_for_property(self, prop: UnitPropertyDescription) -> QWidget | None:
|
||||||
# Valid values are:
|
# Valid values are:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user