mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Improved Mission Planning flight selection behaviour.
This commit is contained in:
@@ -38,7 +38,7 @@ class QMissionPlanning(QDialog):
|
||||
self.planned_flight_view.set_flight_planner(self.planner)
|
||||
self.selected_cp = self.captured_cp[0]
|
||||
|
||||
self.planned_flight_view.selectionModel().setCurrentIndex(self.planned_flight_view.indexAt(QPoint(1, 1)), QItemSelectionModel.Select)
|
||||
self.planned_flight_view.selectionModel().setCurrentIndex(self.planned_flight_view.indexAt(QPoint(1, 1)), QItemSelectionModel.Rows)
|
||||
self.planned_flight_view.selectionModel().selectionChanged.connect(self.on_flight_selection_change)
|
||||
|
||||
if len(self.planned_flight_view.flight_planner.flights) > 0:
|
||||
@@ -83,15 +83,24 @@ class QMissionPlanning(QDialog):
|
||||
else:
|
||||
self.planned_flight_view.set_flight_planner(None)
|
||||
|
||||
print(self.selected_cp.id)
|
||||
|
||||
def on_flight_selection_change(self):
|
||||
index = self.planned_flight_view.selectionModel().currentIndex().row()
|
||||
flight = self.planner.flights[index]
|
||||
|
||||
print("On flight selection change")
|
||||
|
||||
index = self.planned_flight_view.selectionModel().currentIndex().row()
|
||||
self.planned_flight_view.repaint();
|
||||
|
||||
if self.flight_planner is not None:
|
||||
self.flight_planner.clearTabs()
|
||||
|
||||
try:
|
||||
flight = self.planner.flights[index]
|
||||
except IndexError:
|
||||
flight = None
|
||||
self.flight_planner = QFlightPlanner(flight, self.game, self.planner)
|
||||
self.layout.addWidget(self.flight_planner, 0, 1)
|
||||
|
||||
|
||||
def on_add_flight(self):
|
||||
possible_aircraft_type = list(self.selected_cp.base.aircraft.keys())
|
||||
|
||||
@@ -110,7 +119,8 @@ class QMissionPlanning(QDialog):
|
||||
def on_delete_flight(self):
|
||||
index = self.planned_flight_view.selectionModel().currentIndex().row()
|
||||
self.planner.remove_flight(index)
|
||||
self.planned_flight_view.set_flight_planner(self.planner)
|
||||
self.planned_flight_view.set_flight_planner(self.planner, index)
|
||||
|
||||
|
||||
def on_start(self):
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from PySide2.QtCore import QSize
|
||||
from PySide2.QtCore import QSize, QItemSelectionModel, QPoint
|
||||
from PySide2.QtGui import QStandardItemModel
|
||||
from PySide2.QtWidgets import QListView
|
||||
from PySide2.QtWidgets import QListView, QAbstractItemView
|
||||
|
||||
from gen.flights.ai_flight_planner import FlightPlanner
|
||||
from qt_ui.windows.mission.QFlightItem import QFlightItem
|
||||
@@ -13,18 +13,29 @@ class QPlannedFlightsView(QListView):
|
||||
self.model = QStandardItemModel(self)
|
||||
self.setModel(self.model)
|
||||
self.setIconSize(QSize(91, 24))
|
||||
self.setSelectionBehavior(QAbstractItemView.SelectItems)
|
||||
if flight_planner:
|
||||
self.set_flight_planner(flight_planner)
|
||||
|
||||
def update_content(self):
|
||||
def update_content(self, row=0):
|
||||
for i, f in enumerate(self.flight_planner.flights):
|
||||
self.model.appendRow(QFlightItem(f))
|
||||
self.setSelectedFlight(row)
|
||||
self.repaint()
|
||||
|
||||
def setSelectedFlight(self, row):
|
||||
self.selectionModel().clearSelection()
|
||||
index = self.model.index(row, 0)
|
||||
if not index.isValid():
|
||||
index = self.model.index(0, 0)
|
||||
self.selectionModel().setCurrentIndex(index, QItemSelectionModel.Select)
|
||||
self.repaint()
|
||||
|
||||
def clear_layout(self):
|
||||
self.model.removeRows(0, self.model.rowCount())
|
||||
|
||||
def set_flight_planner(self, flight_planner: FlightPlanner):
|
||||
def set_flight_planner(self, flight_planner: FlightPlanner, row=0):
|
||||
self.clear_layout()
|
||||
self.flight_planner = flight_planner
|
||||
if self.flight_planner:
|
||||
self.update_content()
|
||||
self.update_content(row)
|
||||
|
||||
@@ -111,6 +111,6 @@ class QFlightCreator(QDialog):
|
||||
self.planner.flights.append(flight)
|
||||
self.planner.custom_flights.append(flight)
|
||||
if self.flight_view is not None:
|
||||
self.flight_view.set_flight_planner(self.planner)
|
||||
self.flight_view.set_flight_planner(self.planner, len(self.planner.flights)-1)
|
||||
self.close()
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ class QFlightPlanner(QTabWidget):
|
||||
|
||||
def __init__(self, flight: Flight, game: Game, planner):
|
||||
super(QFlightPlanner, self).__init__()
|
||||
self.tabCount = 0
|
||||
if flight:
|
||||
self.general_settings_tab = QGeneralFlightSettingsTab(flight, game, planner)
|
||||
self.payload_tab = QFlightPayloadTab(flight, game)
|
||||
@@ -18,9 +19,15 @@ class QFlightPlanner(QTabWidget):
|
||||
self.addTab(self.general_settings_tab, "General Flight settings")
|
||||
self.addTab(self.payload_tab, "Payload")
|
||||
self.addTab(self.waypoint_tab, "Waypoints")
|
||||
self.tabCount = 3
|
||||
else:
|
||||
tabError = QFrame()
|
||||
l = QGridLayout()
|
||||
l.addWidget(QLabel("No flight selected"))
|
||||
tabError.setLayout(l)
|
||||
self.addTab(tabError, "No flight")
|
||||
self.addTab(tabError, "No flight")
|
||||
self.tabCount = 1
|
||||
|
||||
def clearTabs(self):
|
||||
for i in range(self.tabCount):
|
||||
self.removeTab(i)
|
||||
Reference in New Issue
Block a user