Determines if a drag is taking place, and initiates it

def mouseMoveEvent(self, event):
        """Determines if a drag is taking place, and initiates it"""
        super(AbstractDragView, self).mouseMoveEvent(event)
        if self.dragStartPosition is None or \
            (event.pos() - self.dragStartPosition).manhattanLength() < QtGui.QApplication.startDragDistance():
            # change cursor to reflect actions for what its hovering on
            index = self.indexAt(event.pos())
            cursor = self.model().data(index, CursorRole)
            self.setCursor(cursor)
            return
        # mouse has been dragged past a threshold distance

        index = self.indexAt(self.dragStartPosition)
        if not index.isValid():
            return
        # grab the pixmap first, as it may be cleared from component,
        # and slows GUI due to redraw.
        pixmap = self.grabImage(index)

        # get the item at the drug index
        selected = self.model().data(index, self.DragRole)
        if selected is None:
            return
            
        ## convert to  a bytestream
        bstream = cPickle.dumps(selected)
        mimeData = QtCore.QMimeData()
        mimeData.setData("application/x-protocol", bstream)

        # save this component in case the drag ends not in a droppable region, 
        # and we want to return it to it's original place
        self.limbo_component = selected
        self.originalPos = index
        
        drag = QtGui.QDrag(self)
        drag.setMimeData(mimeData)

        # this makes the pixmap half transparent
        painter = QtGui.QPainter(pixmap)
        painter.setCompositionMode(painter.CompositionMode_DestinationIn)
        painter.fillRect(pixmap.rect(), QtGui.QColor(0, 0, 0, 127))
        painter.end()
        
        drag.setPixmap(pixmap)

        x, y = self.indexXY(index)
        drag.setHotSpot(QtCore.QPoint(event.x()-x, event.y()-y))
        # drag.setHotSpot(QtCore.QPoint(pixmap.width()/2, pixmap.height()/2))
        drag.setPixmap(pixmap)

        self.model().removeItem(index)
        result = drag.exec_(QtCore.Qt.MoveAction)