def get_pos_in_delegate(self, index, globalpos):
        """Map the global position to the position relative to the
        given index

        :param index: the index to map to
        :type index: :class:`QtCore.QModelIndex`
        :param globalpos: the global position
        :type globalpos: :class:`QtCore.QPoint`
        :returns: The position relative to the given index
        :rtype: :class:`QtCore.QPoint`
        :raises: None
        """
        rect = self.visualRect(index)  # rect of the index
        p = self.viewport().mapToGlobal(rect.topLeft())
        return globalpos - p
Map the global position to the position relative to the
        given index

        :param index: the index to map to
        :type index: :class:`QtCore.QModelIndex`
        :param globalpos: the global position
        :type globalpos: :class:`QtCore.QPoint`
        :returns: The position relative to the given index
        :rtype: :class:`QtCore.QPoint`
        :raises: None