Add display name property for unit types.

Unlike the variant ID, this can be changed without breaking save compat.
This commit is contained in:
Dan Albert
2023-08-09 21:41:51 -07:00
committed by Raffson
parent 0ec375ad89
commit f5f11ff3ac
18 changed files with 45 additions and 32 deletions

View File

@@ -611,12 +611,12 @@ class AircraftTypeList(QListView):
self.add_aircraft_type(aircraft)
def remove_aircraft_type(self, aircraft: AircraftType):
for item in self.item_model.findItems(aircraft.variant_id):
for item in self.item_model.findItems(aircraft.display_name):
self.item_model.removeRow(item.row())
self.page_index_changed.emit(self.selectionModel().currentIndex().row())
def add_aircraft_type(self, aircraft: AircraftType):
aircraft_item = QStandardItem(aircraft.variant_id)
aircraft_item = QStandardItem(aircraft.display_name)
icon = self.icon_for(aircraft)
if icon is not None:
aircraft_item.setIcon(icon)
@@ -728,7 +728,7 @@ class AirWingConfigurationTab(QWidget):
)
# Add Squadron
if not self.type_list.item_model.findItems(selected_type.variant_id):
if not self.type_list.item_model.findItems(selected_type.display_name):
self.type_list.add_aircraft_type(selected_type)
# TODO Select the newly added type
self.squadrons_panel.add_squadron_to_panel(squadron)
@@ -814,8 +814,8 @@ class SquadronAircraftTypeSelector(QComboBox):
super().__init__()
self.setSizeAdjustPolicy(self.AdjustToContents)
for type in sorted(types, key=lambda type: type.variant_id):
self.addItem(type.variant_id, type)
for type in sorted(types, key=lambda type: type.display_name):
self.addItem(type.display_name, type)
if selected_aircraft:
self.setCurrentText(selected_aircraft)