# 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/inspector/registry.py
# class InspectorRegItem(BaseRegItem):
#     """ Class to keep track of a registered Inspector.
#         Has a create() method that functions as an Inspector factory.
#     """
#     FIELDS  = BaseRegItem.FIELDS[:1] + ['shortCut'] + BaseRegItem.FIELDS[1:]
#     TYPES   = BaseRegItem.TYPES[:1] + [RegType.ShortCut] + BaseRegItem.TYPES[1:]
#     LABELS  = BaseRegItem.LABELS[:1] + ['Shortcut'] + BaseRegItem.LABELS[1:]
#     STRETCH = BaseRegItem.STRETCH[:1] + [False] + BaseRegItem.STRETCH[1:]
# 
# 
#     def __init__(self, name='', absClassName='', pythonPath='', shortCut=''):
#         """ Constructor. See the ClassRegItem class doc string for the parameter help.
#         """
#         super(InspectorRegItem, self).__init__(name=name, absClassName=absClassName,
#                                                pythonPath=pythonPath)
#         self._data['shortCut'] = shortCut
# 
# 
#     @property
#     def shortCut(self):
#         """ Keyboard short cut
#         """
#         return self._data['shortCut']
# 
# 
#     @property
#     def axesNames(self):
#         """ The axes names of the inspector.
#         """
#         return [] if self.cls is None else self.cls.axesNames()
# 
#     @property
#     def nDims(self):
#         """ The number of axes of this inspector.
#         """
#         return len(self.axesNames)
# 
# 
#     def create(self, collector, tryImport=True):
#         """ Creates an inspector of the registered and passes the collector to the constructor.
#             Tries to import the class if tryImport is True.
#             Raises ImportError if the class could not be imported.
#         """
#         cls = self.getClass(tryImport=tryImport)
#         if not self.successfullyImported:
#             raise ImportError("Class not successfully imported: {}".format(self.exception))
#         return cls(collector)
# 
# Path: argos/utils/cls.py
# def check_class(obj, target_class, allow_none = False):
#     """ Checks that the  obj is a (sub)type of target_class.
#         Raises a TypeError if this is not the case.
# 
#         :param obj: object whos type is to be checked
#         :type obj: any type
#         :param target_class: target type/class
#         :type target_class: any class or type
#         :param allow_none: if true obj may be None
#         :type allow_none: boolean
#     """
#     if not isinstance(obj, target_class):
#         if not (allow_none and obj is None):
#             raise TypeError("obj must be a of type {}, got: {}"
#                             .format(target_class, type(obj)))


import logging
from argos.qt import Qt, QtCore, QtWidgets
from argos.inspector.registry import InspectorRegItem
from argos.utils.cls import check_class
from argos.widgets.pluginsdialog import RegistryTab
# ancestors public methods and attributes.
# pylint: disable=R0901, R0902, R0904, W0201

class OpenInspectorDialog(QtWidgets.QDialog):
    """ Dialog window that allows the user to open an inspector plugins.

        SIDE EFFECT: will try to import all underlying inspector classes.
            This is done so that help and number of dimensions can be displayed.
    """

    def __init__(self, registry, onlyShowImported=False, parent=None):
        """ Constructor
        """
        super(OpenInspectorDialog, self).__init__(parent=parent)

        self._registry = registry

        self.setWindowTitle('Open Inspector')
        self.setModal(True)
        layout = QtWidgets.QVBoxLayout(self)

        attrNames = ['name', 'library', 'nDims']
        headerSizes = [250, 250, None]

        self.inspectorTab = RegistryTab(registry, attrNames=attrNames, headerSizes=headerSizes,
                                        onlyShowImported=onlyShowImported)
        self.inspectorTab.tableView.sortByColumn(1, Qt.AscendingOrder) # sort by library
        layout.addWidget(self.inspectorTab)

        # Buttons

# 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/inspector/registry.py
# class InspectorRegItem(BaseRegItem):
#     """ Class to keep track of a registered Inspector.
#         Has a create() method that functions as an Inspector factory.
#     """
#     FIELDS  = BaseRegItem.FIELDS[:1] + ['shortCut'] + BaseRegItem.FIELDS[1:]
#     TYPES   = BaseRegItem.TYPES[:1] + [RegType.ShortCut] + BaseRegItem.TYPES[1:]
#     LABELS  = BaseRegItem.LABELS[:1] + ['Shortcut'] + BaseRegItem.LABELS[1:]
#     STRETCH = BaseRegItem.STRETCH[:1] + [False] + BaseRegItem.STRETCH[1:]
# 
# 
#     def __init__(self, name='', absClassName='', pythonPath='', shortCut=''):
#         """ Constructor. See the ClassRegItem class doc string for the parameter help.
#         """
#         super(InspectorRegItem, self).__init__(name=name, absClassName=absClassName,
#                                                pythonPath=pythonPath)
#         self._data['shortCut'] = shortCut
# 
# 
#     @property
#     def shortCut(self):
#         """ Keyboard short cut
#         """
#         return self._data['shortCut']
# 
# 
#     @property
#     def axesNames(self):
#         """ The axes names of the inspector.
#         """
#         return [] if self.cls is None else self.cls.axesNames()
# 
#     @property
#     def nDims(self):
#         """ The number of axes of this inspector.
#         """
#         return len(self.axesNames)
# 
# 
#     def create(self, collector, tryImport=True):
#         """ Creates an inspector of the registered and passes the collector to the constructor.
#             Tries to import the class if tryImport is True.
#             Raises ImportError if the class could not be imported.
#         """
#         cls = self.getClass(tryImport=tryImport)
#         if not self.successfullyImported:
#             raise ImportError("Class not successfully imported: {}".format(self.exception))
#         return cls(collector)
# 
# Path: argos/utils/cls.py
# def check_class(obj, target_class, allow_none = False):
#     """ Checks that the  obj is a (sub)type of target_class.
#         Raises a TypeError if this is not the case.
# 
#         :param obj: object whos type is to be checked
#         :type obj: any type
#         :param target_class: target type/class
#         :type target_class: any class or type
#         :param allow_none: if true obj may be None
#         :type allow_none: boolean
#     """
#     if not isinstance(obj, target_class):
#         if not (allow_none and obj is None):
#             raise TypeError("obj must be a of type {}, got: {}"
#                             .format(target_class, type(obj)))


# Path: argos/inspector/dialog.py
import logging
from argos.qt import Qt, QtCore, QtWidgets
from argos.inspector.registry import InspectorRegItem
from argos.utils.cls import check_class
from argos.widgets.pluginsdialog import RegistryTab

# ancestors public methods and attributes.
# pylint: disable=R0901, R0902, R0904, W0201

class OpenInspectorDialog(QtWidgets.QDialog):
    """ Dialog window that allows the user to open an inspector plugins.

        SIDE EFFECT: will try to import all underlying inspector classes.
            This is done so that help and number of dimensions can be displayed.
    """

    def __init__(self, registry, onlyShowImported=False, parent=None):
        """ Constructor
        """
        super(OpenInspectorDialog, self).__init__(parent=parent)

        self._registry = registry

        self.setWindowTitle('Open Inspector')
        self.setModal(True)
        layout = QtWidgets.QVBoxLayout(self)

        attrNames = ['name', 'library', 'nDims']
        headerSizes = [250, 250, None]

        self.inspectorTab = RegistryTab(registry, attrNames=attrNames, headerSizes=headerSizes,
                                        onlyShowImported=onlyShowImported)
        self.inspectorTab.tableView.sortByColumn(1, Qt.AscendingOrder) # sort by library
        layout.addWidget(self.inspectorTab)

        # Buttons

        buttonBox = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok |