mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
It sounds like PySide2 will not be moving to Python 3.11, so we're stuck on 3.10 without this. Upgrading to a newer Qt also fixes some high DPI bugs (the file browser dialog for save/load is no longer tiny on 4k). https://github.com/pyinstaller/pyinstaller/issues/5414 previously blocked this, but the bug appears to be fixed now.
37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
from PySide6.QtCore import QItemSelectionModel, QPoint
|
|
from PySide6.QtGui import QStandardItemModel
|
|
from PySide6.QtWidgets import QListView
|
|
|
|
from game import Game, game
|
|
from qt_ui.windows.infos.QInfoItem import QInfoItem
|
|
|
|
|
|
class QInfoList(QListView):
|
|
def __init__(self, game: Game):
|
|
super(QInfoList, self).__init__()
|
|
self.model = QStandardItemModel(self)
|
|
self.setModel(self.model)
|
|
self.game = game
|
|
self.update_list()
|
|
|
|
self.selectionModel().setCurrentIndex(
|
|
self.indexAt(QPoint(1, 1)), QItemSelectionModel.Select
|
|
)
|
|
self.selectionModel().selectionChanged.connect(self.on_selected_info_changed)
|
|
|
|
def on_selected_info_changed(self):
|
|
index = self.selectionModel().currentIndex().row()
|
|
|
|
def update_list(self):
|
|
self.model.clear()
|
|
if self.game is not None:
|
|
for i, info in enumerate(reversed(self.game.informations)):
|
|
self.model.appendRow(QInfoItem(info))
|
|
self.selectionModel().setCurrentIndex(
|
|
self.indexAt(QPoint(1, 1)), QItemSelectionModel.Select
|
|
)
|
|
|
|
def setGame(self, game):
|
|
self.game = game
|
|
self.update_list()
|