# 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/togglecolumn.py
# class ToggleColumnTreeView(QtWidgets.QTreeView, ToggleColumnMixIn):
#     """ A QTreeView where right clicking on the header allows the user to show/hide columns
#     """
#     def horizontalHeader(self):
#         """ Returns the horizontal header (of type QHeaderView).
# 
#             Override this if the horizontalHeader() function does not exist.
#         """
#         return self.header()
# 
# Path: argos/widgets/constants.py
# COLLECTOR_TREE_ICON_SIZE = QtCore.QSize(20, 20)
# 
# 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
import numpy as np
from argos.qt import Qt, QtCore, QtGui, QtWidgets, QtSlot
from argos.qt.togglecolumn import ToggleColumnTreeView
from argos.widgets.constants import COLLECTOR_TREE_ICON_SIZE
from argos.utils.cls import check_class
        # If the remaining total is less than zero, just set the widths to the size hints (a
        # horizontal scrollbar will appear).
        for idx, newWidth in zip(indexSpin, newSpinBoxWidths):
            header.resizeSection(idx, round(newWidth))



class CollectorSpinBox(QtWidgets.QSpinBox):
    """ A spinbox for use in the collector.
        Overrides the sizeHint so that is not truncated when large dimension names are selected
    """
    def __init__(self, *args, **kwargs):
        """ Constructor
        """
        super(CollectorSpinBox, self).__init__(*args, **kwargs)
        self._cachedSizeHint = None


    def sizeHint(self):
        """ Reimplemented from the C++ Qt source of QAbstractSpinBox.sizeHint, but without
            truncating to a maximum of 18 characters.
        """
        # The cache is invalid after the prefix, postfix and other properties
        # have been set. I disabled it because sizeHint isn't called that often.
        #if self._cachedSizeHint is not None:
        #    return self._cachedSizeHint

        orgSizeHint = super(CollectorSpinBox, self).sizeHint()

        self.ensurePolished()

# 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/togglecolumn.py
# class ToggleColumnTreeView(QtWidgets.QTreeView, ToggleColumnMixIn):
#     """ A QTreeView where right clicking on the header allows the user to show/hide columns
#     """
#     def horizontalHeader(self):
#         """ Returns the horizontal header (of type QHeaderView).
# 
#             Override this if the horizontalHeader() function does not exist.
#         """
#         return self.header()
# 
# Path: argos/widgets/constants.py
# COLLECTOR_TREE_ICON_SIZE = QtCore.QSize(20, 20)
# 
# 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/collect/collectortree.py
import logging
import numpy as np
from argos.qt import Qt, QtCore, QtGui, QtWidgets, QtSlot
from argos.qt.togglecolumn import ToggleColumnTreeView
from argos.widgets.constants import COLLECTOR_TREE_ICON_SIZE
from argos.utils.cls import check_class

        # If the remaining total is less than zero, just set the widths to the size hints (a
        # horizontal scrollbar will appear).
        for idx, newWidth in zip(indexSpin, newSpinBoxWidths):
            header.resizeSection(idx, round(newWidth))



class CollectorSpinBox(QtWidgets.QSpinBox):
    """ A spinbox for use in the collector.
        Overrides the sizeHint so that is not truncated when large dimension names are selected
    """
    def __init__(self, *args, **kwargs):
        """ Constructor
        """
        super(CollectorSpinBox, self).__init__(*args, **kwargs)
        self._cachedSizeHint = None


    def sizeHint(self):
        """ Reimplemented from the C++ Qt source of QAbstractSpinBox.sizeHint, but without
            truncating to a maximum of 18 characters.
        """
        # The cache is invalid after the prefix, postfix and other properties
        # have been set. I disabled it because sizeHint isn't called that often.
        #if self._cachedSizeHint is not None:
        #    return self._cachedSizeHint

        orgSizeHint = super(CollectorSpinBox, self).sizeHint()

        self.ensurePolished()

        fm = QtGui.QFontMetrics(self.fontMetrics())