code: def index_at_event(self, event):
          
          # find index at mouse position
          globalpos = event.globalPos()
          viewport = self.viewport()
          pos = viewport.mapFromGlobal(globalpos)
          i = self.indexAt(pos)
          n = self.get_total_indentation(i)
          if pos.x() > n:
              return i
          else:
              return QtCore.QModelIndex()
docs: Get the index under the position of the given MouseEvent
  
          This implementation takes the indentation into account.
  
          :param event: the mouse event
          :type event: :class:`QtGui.QMouseEvent`
          :returns: the index
          :rtype: :class:`QtCore.QModelIndex`
          :raises: None