# Path: Qt.py

# 
# Path: ts2/simulation.py
# BUILTIN_OPTIONS = {
#     "title": "",
#     "description": "",
#     "clientToken": "client-secret",
#     "version": __FILE_FORMAT__,
#     "timeFactor": 5,
#     "currentTime": "06:00:00",
#     "warningSpeed": 8.3,
#     "currentScore": 0,
#     "defaultMaxSpeed": 44.44,
#     "defaultMinimumStopTime": [(45, 75, 70), (75, 90, 30)],
#     "defaultDelayAtEntry": [(-60, 0, 50), (0, 60, 50)],
#     "trackCircuitBased": False,
#     "defaultSignalVisibility": 100,
#     "wrongPlatformPenalty": 5,
#     "wrongDestinationPenalty": 100,
#     "latePenalty": 1
# }
# def json_hook(dct):
# def load(simulationWindow, jsonStream):
# def onTrackItemChanged(sim, msg):
# def onRouteActivated(sim, msg):
# def onRouteDeactivated(sim, msg):
# def onClockChanged(sim, msg):
# def onTrainChanged(sim, msg):
# def onMessageReceived(sim, msg):
# def onOptionsChanged(sim, msg):
# def onStateChanged(sim, msg):
#     def __init__(self, options, trackItems, routes, trainTypes, services,
#                  trns, messageLogger, signalLibrary):
#     def loadMessageLogger(self, messageLogger):
#     def loadRoutes(self, routes):
#     def loadTrackItems(self, trackItems):
#     def loadTrainTypes(self, trainTypes):
#     def loadServices(self, services):
#     def loadTrains(self, trns):
#     def initialize(self, simulationWindow):
#     def for_json(self):
#     def saveGame(self, fileName):
#     def scene(self):
#     def messageLogger(self):
#     def scorer(self):
#     def context(self):
#     def option(self, key):
#     def setOption(self, key, value):
#     def startTime(self):
#     def currentTime(self):
#     def serviceListModel(self):
#     def selectedServiceModel(self):
#     def trainListModel(self):
#     def selectedTrainModel(self):
#     def routes(self):
#     def trainTypes(self):
#     def trains(self):
#     def addTrain(self, train):
#     def trackItems(self):
#     def trackItem(self, tiId):
#     def place(self, placeCode, raise_if_not_found=True):
#     def places(self):
#     def service(self, serviceCode):
#     def services(self):
#     def registerGraphicsItem(self, graphicItem):
#     def updateContext(self, tabNum):
#     def activateRoute(self, siId, persistent=False, force=False):
#     def desactivateRoute(self, siId):
#     def onPause(self, paused):
#     def pause(self, paused=True):
#         def onIsStarted(msg):
#     def setTimeFactor(self, timeFactor):
#         def timeFactorSet(msg):
#     def timerOut(self):
#     def onOptionsChanged(self, msg):
#     def updateSelection(self):
#     def updatePlaces(self):
#     def findRoutes(self, si1, si2):
#     def createTrackItemsLinks(self):
#     def checkTrackItemsLinks(self):
#     def distanceBetween(p1, p2):
#     def getLineItem(self, placeCode, trackCode):
# class Simulation(QtCore.QObject):


from Qt import QtCore, QtWidgets
from ts2 import simulation

class TrainListView(QtWidgets.QTreeView):
    """ TODO Document TrainListView class"""

    def __init__(self, parent):
        super().__init__(parent)
        self.simulation = None
        self.setItemsExpandable(False)
        self.setRootIsDecorated(False)
        self.setHeaderHidden(False)
        self.setSortingEnabled(True)

    trainSelected = QtCore.pyqtSignal(str)

    @QtCore.pyqtSlot(int)
    def updateTrainSelection(self, trainId):
        index = self.model().index(trainId, 0)
        self.selectionModel().select(index,
                                     QtCore.QItemSelectionModel.Rows |
                                     QtCore.QItemSelectionModel.ClearAndSelect)

    @QtCore.pyqtSlot(simulation.Simulation)
    def setupTrainList(self, sim):
        self.simulation = sim
        # if self.model() is None:
        # trainsSortedModel = QSortFilterProxyModel()
        # trainsSortedModel.setSourceModel()
        self.setModel(self.simulation.trainListModel)
        self.header().setStretchLastSection(False)
        self.header().setSortIndicatorShown(False)

# Path: Qt.py

# 
# Path: ts2/simulation.py
# BUILTIN_OPTIONS = {
#     "title": "",
#     "description": "",
#     "clientToken": "client-secret",
#     "version": __FILE_FORMAT__,
#     "timeFactor": 5,
#     "currentTime": "06:00:00",
#     "warningSpeed": 8.3,
#     "currentScore": 0,
#     "defaultMaxSpeed": 44.44,
#     "defaultMinimumStopTime": [(45, 75, 70), (75, 90, 30)],
#     "defaultDelayAtEntry": [(-60, 0, 50), (0, 60, 50)],
#     "trackCircuitBased": False,
#     "defaultSignalVisibility": 100,
#     "wrongPlatformPenalty": 5,
#     "wrongDestinationPenalty": 100,
#     "latePenalty": 1
# }
# def json_hook(dct):
# def load(simulationWindow, jsonStream):
# def onTrackItemChanged(sim, msg):
# def onRouteActivated(sim, msg):
# def onRouteDeactivated(sim, msg):
# def onClockChanged(sim, msg):
# def onTrainChanged(sim, msg):
# def onMessageReceived(sim, msg):
# def onOptionsChanged(sim, msg):
# def onStateChanged(sim, msg):
#     def __init__(self, options, trackItems, routes, trainTypes, services,
#                  trns, messageLogger, signalLibrary):
#     def loadMessageLogger(self, messageLogger):
#     def loadRoutes(self, routes):
#     def loadTrackItems(self, trackItems):
#     def loadTrainTypes(self, trainTypes):
#     def loadServices(self, services):
#     def loadTrains(self, trns):
#     def initialize(self, simulationWindow):
#     def for_json(self):
#     def saveGame(self, fileName):
#     def scene(self):
#     def messageLogger(self):
#     def scorer(self):
#     def context(self):
#     def option(self, key):
#     def setOption(self, key, value):
#     def startTime(self):
#     def currentTime(self):
#     def serviceListModel(self):
#     def selectedServiceModel(self):
#     def trainListModel(self):
#     def selectedTrainModel(self):
#     def routes(self):
#     def trainTypes(self):
#     def trains(self):
#     def addTrain(self, train):
#     def trackItems(self):
#     def trackItem(self, tiId):
#     def place(self, placeCode, raise_if_not_found=True):
#     def places(self):
#     def service(self, serviceCode):
#     def services(self):
#     def registerGraphicsItem(self, graphicItem):
#     def updateContext(self, tabNum):
#     def activateRoute(self, siId, persistent=False, force=False):
#     def desactivateRoute(self, siId):
#     def onPause(self, paused):
#     def pause(self, paused=True):
#         def onIsStarted(msg):
#     def setTimeFactor(self, timeFactor):
#         def timeFactorSet(msg):
#     def timerOut(self):
#     def onOptionsChanged(self, msg):
#     def updateSelection(self):
#     def updatePlaces(self):
#     def findRoutes(self, si1, si2):
#     def createTrackItemsLinks(self):
#     def checkTrackItemsLinks(self):
#     def distanceBetween(p1, p2):
#     def getLineItem(self, placeCode, trackCode):
# class Simulation(QtCore.QObject):


# Path: ts2/gui/trainlistview.py
from Qt import QtCore, QtWidgets
from ts2 import simulation


class TrainListView(QtWidgets.QTreeView):
    """ TODO Document TrainListView class"""

    def __init__(self, parent):
        super().__init__(parent)
        self.simulation = None
        self.setItemsExpandable(False)
        self.setRootIsDecorated(False)
        self.setHeaderHidden(False)
        self.setSortingEnabled(True)

    trainSelected = QtCore.pyqtSignal(str)

    @QtCore.pyqtSlot(int)
    def updateTrainSelection(self, trainId):
        index = self.model().index(trainId, 0)
        self.selectionModel().select(index,
                                     QtCore.QItemSelectionModel.Rows |
                                     QtCore.QItemSelectionModel.ClearAndSelect)

    @QtCore.pyqtSlot(simulation.Simulation)
    def setupTrainList(self, sim):
        self.simulation = sim
        # if self.model() is None:
        # trainsSortedModel = QSortFilterProxyModel()
        # trainsSortedModel.setSourceModel()
        self.setModel(self.simulation.trainListModel)
        self.header().setStretchLastSection(False)
        self.header().setSortIndicatorShown(False)

        self.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)