# Path: argos/utils/defs.py
# class InvalidInputError(Exception):
#     """ Exception raised when the input is invalid after editing
#     """
#     pass
# 
# Path: argos/qt/bindings.py
# API_PYSIDE2 = 'pyside2'
# API_PYQT5 = 'pyqt5'
# ALL_API = [API_PYQT5, API_PYSIDE2]
# QT_API_NAME = os.environ.get('QT_API')
#     QT_API_NAME = None
#         QT_API_NAME = API_PYQT5
#         QT_API_NAME = API_PYSIDE2
#         QT_API_NAME = API_PYQT5
#         QT_API_NAME = API_PYSIDE2
# 
# Path: argos/qt/misc.py
# def widgetSubCheckBoxRect(widget, option):
#     """ Returns the rectangle of a check box drawn as a sub element of widget
#     """
#     opt = QtWidgets.QStyleOption()
#     opt.initFrom(widget)
#     style = widget.style()
#     return style.subElementRect(QtWidgets.QStyle.SE_ViewItemCheckIndicator, opt, widget)
# 
# Path: argos/widgets/constants.py
# TREE_CELL_SIZE_HINT = QtCore.QSize(100, 20)


import logging
from argos.utils.defs import InvalidInputError
from argos.qt import Qt, QtCore, QtWidgets
from argos.qt.misc import widgetSubCheckBoxRect
from argos.widgets.constants import TREE_CELL_SIZE_HINT
        """ Provides the widget with data to manipulate.
            Calls the setEditorValue of the config tree item at the index.

            :type editor: QWidget
            :type index: QModelIndex

            Reimplemented from QStyledItemDelegate.
        """
        # We take the config value via the model to be consistent with setModelData
        data = index.model().data(index, Qt.EditRole)
        editor.setData(data)


    def setModelData(self, editor, model, index):
        """ Gets data from the editor widget and stores it in the specified model at the item index.
            Does this by calling getEditorValue of the config tree item at the index.

            :type editor: QWidget
            :type model: ConfigTreeModel
            :type index: QModelIndex

            Reimplemented from QStyledItemDelegate.
        """
        try:
            data = editor.getData()
        except InvalidInputError as ex:
            logger.warning(ex)
        else:
            # The value is set via the model so that signals are emitted
            logger.debug("ConfigItemDelegate.setModelData: {}".format(data))

# Path: argos/utils/defs.py
# class InvalidInputError(Exception):
#     """ Exception raised when the input is invalid after editing
#     """
#     pass
# 
# Path: argos/qt/bindings.py
# API_PYSIDE2 = 'pyside2'
# API_PYQT5 = 'pyqt5'
# ALL_API = [API_PYQT5, API_PYSIDE2]
# QT_API_NAME = os.environ.get('QT_API')
#     QT_API_NAME = None
#         QT_API_NAME = API_PYQT5
#         QT_API_NAME = API_PYSIDE2
#         QT_API_NAME = API_PYQT5
#         QT_API_NAME = API_PYSIDE2
# 
# Path: argos/qt/misc.py
# def widgetSubCheckBoxRect(widget, option):
#     """ Returns the rectangle of a check box drawn as a sub element of widget
#     """
#     opt = QtWidgets.QStyleOption()
#     opt.initFrom(widget)
#     style = widget.style()
#     return style.subElementRect(QtWidgets.QStyle.SE_ViewItemCheckIndicator, opt, widget)
# 
# Path: argos/widgets/constants.py
# TREE_CELL_SIZE_HINT = QtCore.QSize(100, 20)


# Path: argos/config/configitemdelegate.py
import logging
from argos.utils.defs import InvalidInputError
from argos.qt import Qt, QtCore, QtWidgets
from argos.qt.misc import widgetSubCheckBoxRect
from argos.widgets.constants import TREE_CELL_SIZE_HINT

        """ Provides the widget with data to manipulate.
            Calls the setEditorValue of the config tree item at the index.

            :type editor: QWidget
            :type index: QModelIndex

            Reimplemented from QStyledItemDelegate.
        """
        # We take the config value via the model to be consistent with setModelData
        data = index.model().data(index, Qt.EditRole)
        editor.setData(data)


    def setModelData(self, editor, model, index):
        """ Gets data from the editor widget and stores it in the specified model at the item index.
            Does this by calling getEditorValue of the config tree item at the index.

            :type editor: QWidget
            :type model: ConfigTreeModel
            :type index: QModelIndex

            Reimplemented from QStyledItemDelegate.
        """
        try:
            data = editor.getData()
        except InvalidInputError as ex:
            logger.warning(ex)
        else:
            # The value is set via the model so that signals are emitted
            logger.debug("ConfigItemDelegate.setModelData: {}".format(data))

            model.setData(index, data, Qt.EditRole)