dcs_liberation/qt_ui/widgets/combos/QArrivalAirfieldSelector.py
Dan Albert 2a75d14e0e Revert upgrade to pyside6.
This appears to be incompatible with pyinstaller. I get the following
when trying to run the executable generated with pyside6:

```
Traceback (most recent call last):
  File "qt_ui\main.py", line 29, in <module>
  File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
  File "qt_ui\windows\QLiberationWindow.py", line 28, in <module>
  File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
  File "qt_ui\widgets\map\QLiberationMap.py", line 11, in <module>
ImportError: could not import module 'PySide6.QtPrintSupport'
```
2021-11-21 17:39:43 -08:00

47 lines
1.4 KiB
Python

"""Combo box for selecting a departure airfield."""
from typing import Iterable, Optional
from PySide2.QtWidgets import QComboBox
from dcs.unittype import FlyingType
from game.dcs.aircrafttype import AircraftType
from game.theater.controlpoint import ControlPoint
class QArrivalAirfieldSelector(QComboBox):
"""A combo box for selecting a flight's arrival or divert airfield.
The combo box will automatically be populated with all airfields the given
aircraft type is able to land at.
"""
def __init__(
self,
destinations: Iterable[ControlPoint],
aircraft: Optional[AircraftType],
optional_text: str,
) -> None:
super().__init__()
self.destinations = list(destinations)
self.aircraft = aircraft
self.optional_text = optional_text
self.rebuild_selector()
self.setCurrentIndex(0)
def change_aircraft(self, aircraft: Optional[FlyingType]) -> None:
if self.aircraft == aircraft:
return
self.aircraft = aircraft
self.rebuild_selector()
def rebuild_selector(self) -> None:
self.clear()
if self.aircraft is None:
return
for destination in self.destinations:
if destination.can_operate(self.aircraft):
self.addItem(destination.name, destination)
self.model().sort(0)
self.insertItem(0, self.optional_text, None)
self.setCurrentIndex(0)