# Path: Qt.py



from Qt import QtWidgets, Qt
        code = index.data(Qt.EditRole)
        startSearchIndex = simulation.trainTypesModel.index(0, 0)
        trainTypeIndexes = simulation.trainTypesModel.match(
            startSearchIndex, Qt.DisplayRole, code, 1,
            Qt.MatchExactly | Qt.MatchWrap
        )
        if len(trainTypeIndexes) > 0:
            trainTypeIndex = trainTypeIndexes[0].row()
        else:
            trainTypeIndex = 0
        editor.setCurrentIndex(trainTypeIndex)

    def setModelData(self, editor, model, index):
        """Sets the values from the combo box to the model after editing"""
        code = editor.currentText()
        model.setData(index, code, Qt.EditRole)

    def updateEditorGeometry(self, editor, option, index):
        """Sets the editor geometry."""
        editor.setGeometry(option.rect)


class PlacesDelegate(QtWidgets.QStyledItemDelegate):
    """PlacesDelegate is a delegate that provides a combo box for
    selecting a Place.
    """

    def createEditor(self, parent, option, index):
        """Creates the editor, i.e. a combo box for selecting a place."""
        simulation = index.model().simulation

# Path: Qt.py



# Path: ts2/editor/delegates.py
from Qt import QtWidgets, Qt

        code = index.data(Qt.EditRole)
        startSearchIndex = simulation.trainTypesModel.index(0, 0)
        trainTypeIndexes = simulation.trainTypesModel.match(
            startSearchIndex, Qt.DisplayRole, code, 1,
            Qt.MatchExactly | Qt.MatchWrap
        )
        if len(trainTypeIndexes) > 0:
            trainTypeIndex = trainTypeIndexes[0].row()
        else:
            trainTypeIndex = 0
        editor.setCurrentIndex(trainTypeIndex)

    def setModelData(self, editor, model, index):
        """Sets the values from the combo box to the model after editing"""
        code = editor.currentText()
        model.setData(index, code, Qt.EditRole)

    def updateEditorGeometry(self, editor, option, index):
        """Sets the editor geometry."""
        editor.setGeometry(option.rect)


class PlacesDelegate(QtWidgets.QStyledItemDelegate):
    """PlacesDelegate is a delegate that provides a combo box for
    selecting a Place.
    """

    def createEditor(self, parent, option, index):
        """Creates the editor, i.e. a combo box for selecting a place."""
        simulation = index.model().simulation

        comboBox = QtWidgets.QComboBox(parent)