Exemplo n.º 1
0
    def tree1StartDrag(self, event):
        print("draggableList startDrag")
        drag = QtGui.QDrag(self)
        selected = self.tree1.currentItem().data(1,0).toPyObject()
        bstream = cPickle.dumps(selected)
        mimeData = QtCore.QMimeData()
        mimeData.setData("application/atom", bstream)

        drag = QtGui.QDrag(self)
        drag.setMimeData(mimeData)
        result = drag.start(QtCore.Qt.CopyAction)
Exemplo n.º 2
0
 def startDrag(self, supportedActions):
     indexes = self.selectedIndexes()
     if len(indexes):
         drag = QtGui.QDrag(self)
         drag.setMimeData(self.model().mimeData(indexes))
         if drag.start(QtCore.Qt.MoveAction) == QtCore.Qt.MoveAction:
             pass
Exemplo n.º 3
0
    def _show_drag_text(self, widget):

        text = self._text_map.get(widget)

        # Put the text into the clipboard
        self._clipboard.clear()
        self._clipboard.setText(text, mode=QtGui.QClipboard.Selection)

        # Create a label for the "drag" display
        label = QtGui.QLabel()
        label.setStyleSheet(self._select_style_sheet)
        label.setSizePolicy(QtGui.QSizePolicy.Ignored,
                            QtGui.QSizePolicy.Ignored)
        label.setFont(self._select_font)
        label.setText(text)

        # Must use this invocation to get boundingRect to interpret newlines
        rect = label.fontMetrics().boundingRect(0, 0, 1000, 1000, 0, text)

        # Create pixmap and render label onto it
        pixmap = QtGui.QPixmap(rect.width(), rect.height())
        label.render(pixmap)

        drag = QtGui.QDrag(self)
        drag.setPixmap(pixmap)

        # Does not seem to work without mimeData
        mime_data = QtCore.QMimeData()
        drag.setMimeData(mime_data)

        # Start the drag
        drag.exec_(QtCore.Qt.CopyAction | QtCore.Qt.MoveAction,
                   QtCore.Qt.CopyAction)
Exemplo n.º 4
0
    def mouseMoveEvent(self, event):

        if self.lastClick[0]:
            if (self.lastClick[1].x() - event.pos().x())**2 + (
                    self.lastClick[1].y() - event.pos().y())**2 > 5:
                if self.lastClick[2] != -1:

                    selectedSlot = self.slots[self.lastClick[2]]
                    selectedItem = selectedSlot.item

                    if selectedItem != None:

                        drag = QtGui.QDrag(self)

                        mimeData = QtCore.QMimeData()
                        mimeData.setText(selectedItem.text() + ";" +
                                         selectedItem.identifier + ";" +
                                         str(selectedSlot.count))

                        pixmap = selectedItem.texture.scaled(50, 50)
                        painter = QtGui.QPainter(pixmap)
                        painter.setCompositionMode(
                            painter.CompositionMode_DestinationIn)
                        painter.fillRect(pixmap.rect(),
                                         QtGui.QColor(0, 0, 0, 127))
                        painter.end()

                        drag.setMimeData(mimeData)
                        drag.setPixmap(pixmap)

                        self.slots[self.lastClick[2]].item = None
                        self.slots[self.lastClick[2]].count = 0

                        drag.exec_(QtCore.Qt.MoveAction)
Exemplo n.º 5
0
    def mousePressEvent(self, event):
        child = self.childAt(event.pos())
        if not child:
            return

        pixmap = QtGui.QPixmap(child.pixmap())

        itemData = QtCore.QByteArray()
        dataStream = QtCore.QDataStream(itemData, QtCore.QIODevice.WriteOnly)
        dataStream << pixmap << QtCore.QPoint(event.pos() - child.pos())

        mimeData = QtCore.QMimeData()
        mimeData.setData('application/x-dnditemdata', itemData)

        drag = QtGui.QDrag(self)
        drag.setMimeData(mimeData)
        drag.setPixmap(pixmap)
        drag.setHotSpot(event.pos() - child.pos())

        tempPixmap = QtGui.QPixmap(pixmap)
        painter = QtGui.QPainter()
        painter.begin(tempPixmap)
        painter.fillRect(pixmap.rect(), QtGui.QColor(127, 127, 127, 127))
        painter.end()

        child.setPixmap(tempPixmap)

        if drag.exec_(QtCore.Qt.CopyAction | QtCore.Qt.MoveAction, QtCore.Qt.CopyAction) == QtCore.Qt.MoveAction:
            child.close()
        else:
            child.show()
            child.setPixmap(pixmap)
Exemplo n.º 6
0
    def performSingleClickAction(self):

        self.bTimer = False
        if self.bDoubleClick:
            return

        label = self.__getLabelName()  #= self.childAt(self.event.pos())
        if not label:
            return
        mimeData = QtCore.QMimeData()
        indices = self.selectedIndexes()
        if len(indices) > 0:
            index = indices[0]
            item = self.model().item(index.row(), 0)
            labelName = item.getFullSignalName()
            mimeData.setText(labelName)
            labelNameList = labelName.split("|")
            qlabel = QtGui.QLabel(labelNameList[0])
            pixmap = QtGui.QPixmap(qlabel.size())
            qlabel.render(pixmap)

            drag = QtGui.QDrag(self)
            drag.setMimeData(mimeData)
            drag.setPixmap(pixmap)

            dropAction = drag.exec_(
                QtCore.Qt.CopyAction | QtCore.Qt.MoveAction,
                QtCore.Qt.CopyAction)
            if dropAction == QtCore.Qt.MoveAction:
                label.close()
Exemplo n.º 7
0
    def start_drag(self):
        drag = QtGui.QDrag(self)
        mimeData = QtCore.QMimeData()
        ds = self.doc.data.get('0:kiln/Ts', False)
        if ds is False:
            ds = self.doc.data.get('0:kiln/T')
        T = ds.data[self.doc_idx]
        # Text copy
        mimeData.setData(
            "text/plain", 'point:{}:{}:{}'.format(self.base_dataset_path,
                                                  self.t, T))
        # Image copy
        ba = QtCore.QByteArray()
        buf = QtCore.QBuffer(ba)
        buf.open(QtCore.QIODevice.WriteOnly)
        self.img.save(buf, 'PNG')
        mimeData.setData("image/png", ba)
        ba1 = QtCore.QByteArray()
        buf1 = QtCore.QBuffer(ba1)
        buf1.open(QtCore.QIODevice.WriteOnly)
        self.img.save(buf1, 'BMP')
        mimeData.setData("image/bmp", ba1)
        # File copy
        name = '{}_{}.png'.format(
            self.base_dataset_path.replace('/', '_').replace(':', ''),
            self.idx)
        name = os.path.join(self.decoder.tmpdir, name)
        self.img.save(name, 'PNG')
        mimeData.setData("text/uri-list", "file:///" + name)

        mimeData.setImageData(self.img)
        drag.setMimeData(mimeData)
        drag.setPixmap(self.lbl_img.pixmap())
        logging.debug('start drag', mimeData.text())
        drag.exec_()
Exemplo n.º 8
0
 def graphicsMouseMoveEvent(self, event, itemId=0):
     """This function is called by the owned TrackGraphicsItem to handle
     its mouseMoveEvent. Reimplemented in the ResizableItem class to begin
     a drag operation on corners."""
     if event.buttons() == Qt.LeftButton and \
        self.simulation.context == utils.Context.EDITOR_SCENERY:
         if QtCore.QLineF(event.scenePos(),
                      event.buttonDownScenePos(Qt.LeftButton)).length() \
                     < 3.0:
             return
         drag = QtGui.QDrag(event.widget())
         mime = QtCore.QMimeData()
         pos = event.buttonDownScenePos(Qt.LeftButton) - self.origin
         if QtCore.QRectF(-5, -5, 9, 9).contains(pos):
             movedEnd = "start"
         elif QtCore.QRectF(self.end.x() - self.origin.x() - 5,
                            self.end.y() - self.origin.y() - 5, 9,
                            9).contains(pos):
             movedEnd = "end"
             pos -= self.end - self.origin
         #elif self._gi[itemId].shape().contains(pos):
         else:
             movedEnd = "origin"
         if movedEnd is not None:
             mime.setText(self.tiType + "#" + str(self.tiId) + "#" +
                          str(pos.x()) + "#" + str(pos.y()) + "#" +
                          movedEnd)
             drag.setMimeData(mime)
             drag.exec_()
Exemplo n.º 9
0
    def mouseMoveEvent(self, e):
        drag = QtGui.QDrag(self)
        mimeData = QtCore.QMimeData()
        drag.setMimeData(mimeData)

        drag.setPixmap(QtGui.QPixmap.fromImage(self.createPixmap()))
        dropAction = drag.start(QtCore.Qt.MoveAction)
Exemplo n.º 10
0
 def _dragdrop(self, e):
     mimeData = QtCore.QMimeData()
     mimeData.setColorData(self.color)
     drag = QtGui.QDrag(self)
     drag.setMimeData(mimeData)
     drag.setHotSpot(e.pos() - self.rect().topLeft())
     dropAction = drag.start(QtCore.Qt.MoveAction)
Exemplo n.º 11
0
    def startDrag(self, event):
        index = self.indexAt(event.pos())
        if not index.isValid():
            return

        # # selected is the relevant person object
        selected = self.model().data(index, QtCore.Qt.UserRole)

        # # convert to  a bytestream
        bstream = cPickle.dumps(selected)
        mimeData = QtCore.QMimeData()
        mimeData.setData("application/x-person", bstream)

        drag = QtGui.QDrag(self)
        drag.setMimeData(mimeData)

        # example 1 - the object itself

        pixmap = QtGui.QPixmap()
        pixmap = pixmap.grabWidget(self, self.rectForIndex(index))

        # example 2 -  a plain pixmap
        # pixmap = QtGui.QPixmap(100, self.height()/2)
        # pixmap.fill(QtGui.QColor("orange"))
        drag.setPixmap(pixmap)

        drag.setHotSpot(QtCore.QPoint(pixmap.width() / 2, pixmap.height() / 2))
        drag.setPixmap(pixmap)
        result = drag.start(QtCore.Qt.MoveAction)
        if result:  # == QtCore.Qt.MoveAction:
            self.model().removeRow(index.row())
Exemplo n.º 12
0
    def mouseMoveEvent(self, e):
        QtGui.QToolButton.mouseMoveEvent(self, e)
        if e.buttons() == QtCore.Qt.LeftButton and self.dragStartPoint:
            x, y = e.x(), e.y()
            ox, oy = self.dragStartPoint
            dx2 = (x - ox)**2
            dy2 = (y - oy)**2
            d2 = dx2 + dy2
            if d2 > MIN_DRAG_DISTANCE**2:
                mimeData = QtCore.QMimeData()
                mimeData.setText(self.key)

                drag = QtGui.QDrag(self)
                drag.setPixmap(self.icon().pixmap(16, 16))
                drag.setMimeData(mimeData)

                dragstartQPoint = QtCore.QPoint(self.dragStartPoint[0],
                                                self.dragStartPoint[1])
                drag.setHotSpot(dragstartQPoint - self.rect().topLeft())

                self.parent.layout().removeWidget(self)
                self.parent.keys.remove(self.key)
                self.parent.parent.prjconn.call.updateDirectLinks(
                    self.parent.keys)
                self.hide()

                dropAction = drag.start(QtCore.Qt.MoveAction)

                if (self.parent.layout().count() <= 1):
                    self.parent.dragInfoLabel.show()
Exemplo n.º 13
0
    def mouseMoveEvent(self, e):
        # if e.buttons() != QtCore.Qt.RightButton:
        #     return

        # write the relative cursor position to mime data
        mimeData = QtCore.QMimeData()
        # simple string with 'x,y'
        mimeData.setText('%d,%d' % (e.x(), e.y()))

        # let's make it fancy. we'll show a "ghost" of the button as we drag
        # grab the button to a pixmap
        pixmap = QtGui.QPixmap.grabWidget(self)

        # below 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()

        # make a QDrag
        drag = QtGui.QDrag(self)
        # put our MimeData
        drag.setMimeData(mimeData)
        # set its Pixmap
        drag.setPixmap(pixmap)
        # shift the Pixmap so that it coincides with the cursor position
        drag.setHotSpot(e.pos())

        # start the drag operation
        # exec_ will return the accepted action from dropEvent
        if drag.exec_(QtCore.Qt.CopyAction
                      | QtCore.Qt.MoveAction) == QtCore.Qt.MoveAction:
            print 'moved'
        else:
            print 'copied'
Exemplo n.º 14
0
    def startDrag(self, dropActions):
        item = self.currentItem()

        # check parent name and return if top level node
        if item.parent() == None:
            return

        # get dir name
        dirName = unicode(item.parent().text(0))

        # get node from library
        nodeName = unicode(item.text(0))

        # set custom data
        data = QtCore.QByteArray()
        stream = QtCore.QDataStream(data, QtCore.QIODevice.WriteOnly)
        stream << item.parent().text(0) << item.text(0)
        mimeData = QtCore.QMimeData()
        mimeData.setData('application/x-text', data)

        # set drag
        drag = QtGui.QDrag(self)
        drag.setMimeData(mimeData)
        drag.setPixmap(QtGui.QPixmap(':/node.png'))
        drag.start(QtCore.Qt.CopyAction)
Exemplo n.º 15
0
 def mouseMoveEvent(self, event):
     """Mouse move event to start drag & drop"""
     if event.buttons() == QtCore.Qt.LeftButton and self.dragStartPos and \
             globalref.docRef.selection and \
             (event.pos() - self.dragStartPos).manhattanLength() > \
             QtGui.QApplication.startDragDistance() and \
             globalref.options.boolData('DragTree'):
         oldSelect = globalref.docRef.selection[:]
         drag = QtGui.QDrag(self)
         drag.setMimeData(self.mimeData())
         dropAction = drag.start(QtCore.Qt.MoveAction
                                 | QtCore.Qt.CopyAction)
         if dropAction == QtCore.Qt.MoveAction:
             if drag.target() == None:  # move to different session
                 if globalref.docRef.root in oldSelect:
                     return  # can't delete root
                 undoParents = filter(
                     None,
                     [item.parent for item in globalref.docRef.selection])
                 globalref.docRef.undoStore.addChildListUndo(undoParents)
                 globalref.docRef.selection.replace([undoParents[0]])
             elif filter(None, [
                     node.hasDescendant(globalref.docRef.selection[0])
                     for node in oldSelect
             ]):
                 return  # don't delete if drag to descendant
             for item in oldSelect:
                 item.delete()
             globalref.updateViewAll()
Exemplo n.º 16
0
    def tree2StartDrag(self, event):
        print ("draggableList startDrag")
        index = self.tree2.indexAt(event.pos())
        drag = QtGui.QDrag(self)
        selected = self.tree2.currentItem().data(1,0).toPyObject()
        bstream = cPickle.dumps(selected)
        mimeData = QtCore.QMimeData()
        mimeData.setData("application/atom", bstream)

        drag = QtGui.QDrag(self)
        drag.setMimeData(mimeData)
        result = drag.start(QtCore.Qt.MoveAction)
        if result == QtCore.Qt.MoveAction:
            logging.info("Drag done with {} Moveaction is {}".format(result, QtCore.Qt.MoveAction))
        else:
            logging.info("Drag done with {}".format(result))
Exemplo n.º 17
0
    def startDrag(self, event):
        index = self.indexAt(event.pos())
        if not index.isValid():
            return

        # selected is the relevant person object
        selectedApp = self.model().data(index, QtCore.Qt.UserRole)

        if not selectedApp.unscheduled:
            event.ignore()
            return
        if index not in self.selectedIndexes():
            self.setCurrentIndex(index)

        # convert to  a bytestream
        bstream = cPickle.dumps(selectedApp)
        mimeData = QtCore.QMimeData()
        mimeData.setData("application/x-appointment", bstream)
        drag = QtGui.QDrag(self)

        drag.setMimeData(mimeData)
        drag.setDragCursor(QtGui.QPixmap(), QtCore.Qt.MoveAction)

        pixmap = QtGui.QPixmap()
        pixmap = pixmap.grabWidget(self, self.rectForIndex(index))
        drag.setPixmap(pixmap)
        drag.setHotSpot(QtCore.QPoint(-10, 0))

        drag.start(QtCore.Qt.CopyAction)
Exemplo n.º 18
0
 def startDrag(self, supportedActions):
     """Start drag, *without* using pixmap."""
     items = self.selectedItems()
     if items:
         drag = QtGui.QDrag(self)
         drag.setMimeData(self.mimeData(items))
         drag.start(supportedActions)
Exemplo n.º 19
0
 def start_drag(self):
     """Begin a drag and drop event"""
     drag = QtGui.QDrag(self)
     mimeData = QtCore.QMimeData()
     mimeData.setData("text/plain", self.prop['kid'])
     drag.setMimeData(mimeData)
     drag.exec_()
Exemplo n.º 20
0
    def mouseMoveEvent(self, event):
        """ If the mouse moves far enough when the left mouse button is held
            down, start a drag and drop operation.
        """
        if not event.buttons() & QtCore.Qt.LeftButton:
            return

        if (event.pos() - self.dragStartPosition).manhattanLength() \
             < QtGui.QApplication.startDragDistance():
            return

        if not self.hasImage:
            return

        drag = QtGui.QDrag(self)
        mimeData = QtCore.QMimeData()

        output = QtCore.QByteArray()
        outputBuffer = QtCore.QBuffer(output)
        outputBuffer.open(QtCore.QIODevice.WriteOnly)
        self.imageLabel.pixmap().toImage().save(outputBuffer, 'PNG')
        outputBuffer.close()
        mimeData.setData('image/png', output)

        drag.setMimeData(mimeData)
        drag.setPixmap(self.imageLabel.pixmap().scaled(64, 64, QtCore.Qt.KeepAspectRatio))
        drag.setHotSpot(QtCore.QPoint(drag.pixmap().width() / 2,
                                      drag.pixmap().height()))
        drag.start()
Exemplo n.º 21
0
    def startDrag(self, supported_actions):
        indices = self.selectionModel().selectedIndexes()
        indices = [i for i in indices if i.flags() & Qt.ItemIsDragEnabled]
        if indices:
            data = self.model().mimeData(indices)
            if not data:
                return

            drag = QtGui.QDrag(self)
            drag.setMimeData(data)

            default_action = QtCore.Qt.IgnoreAction
            if hasattr(self, "defaultDropAction") and \
                    self.defaultDropAction() != Qt.IgnoreAction and \
                    supported_actions & self.defaultDropAction():
                default_action = self.defaultDropAction()
            elif (supported_actions & Qt.CopyAction
                  and self.dragDropMode() != self.InternalMove):
                default_action = Qt.CopyAction
            res = drag.exec_(supported_actions, default_action)
            if res == Qt.MoveAction:
                selected = self.selectionModel().selectedIndexes()
                rows = list(map(QtCore.QModelIndex.row, selected))
                for s1, s2 in reversed(list(slices(rows))):
                    delslice(self.model(), s1, s2)
Exemplo n.º 22
0
    def mouseMoveEvent(self, e):
        """
		Start a drag operation and drop it if it was accepted by item overview

		Arguments:
		e -- a mouse event
		"""

        if e.buttons() != QtCore.Qt.LeftButton:
            return

        mimedata = QtCore.QMimeData()
        mimedata.setText("__osnew__ %s" % self.item)

        drag = QtGui.QDrag(self)
        drag.setMimeData(mimedata)
        drag.setHotSpot(e.pos() - self.rect().topLeft())
        drag.setPixmap(self.pixmap)

        if drag.start(QtCore.Qt.CopyAction) == QtCore.Qt.CopyAction:
            if self.item == "loop":
                self.main_window.drop_item(self.main_window.add_loop)
            elif self.item == "sequence":
                self.main_window.drop_item(self.main_window.add_sequence)
            else:
                self.main_window.drop_item(self.item)
        else:
            debug.msg("drop cancelled")
Exemplo n.º 23
0
    def startDrag(self, event):
        # item is of type NodeListItem
        item = self.currentItem()
        # nodeData is the data (BaseNode type) that item was created with
        nodeData = nt.NodeTypes[item.dictKey]
        #nodeData = mayaNodesModule.MayaNodes[item.dictKey])

        i = id(nodeData)
        self.d[i] = nodeData
        pickleData = cPickle.dumps(i)

        data = QtCore.QByteArray.fromRawData(pickleData)

        mimeData = QtCore.QMimeData()
        mimeData.setData("application/x-imgname", data)

        drag = QtGui.QDrag(self)
        drag.setMimeData(mimeData)

        # Setting the icon that the mouse cursor displays
        icon = item.icon()
        pixmap = icon.pixmap(48, 48)
        drag.setPixmap(pixmap.scaled(pixmap.height() * .5,
                                     pixmap.width() * .5))
        # Actually starts the dragging
        drag.exec_()
Exemplo n.º 24
0
    def mouseMoveEvent(self, e):
        QtGui.QListView.mouseMoveEvent(self, e)
        print "call mouseMove"
#        if e.buttons() != QtCore.Qt.RightButton:
#            return

        # write the relative cursor position to mime data
        mimeData = QtCore.QMimeData()
        # simple string with 'x,y'
        mimeData.setText('%d,%d' % (e.x(), e.y()))

        # let's make it fancy. we'll show a "ghost" of the button as we drag
        # grab the button to a pixmap
        pixmap = self.create_mini_pixmap()

        # make a QDrag
        drag = QtGui.QDrag(self)
        # put our MimeData
        drag.setMimeData(mimeData)
        # set its Pixmap
        drag.setPixmap(pixmap)
        # shift the Pixmap so that it coincides with the cursor position
        drag.setHotSpot(QtCore.QPoint(0, 0))
        print 'source : ', drag.source(), '    dest : ', drag.target()

        # start the drag operation
        # exec_ will return the accepted action from dropEvent
        a = drag.exec_(QtCore.Qt.CopyAction | QtCore.Qt.MoveAction)
        if a == QtCore.Qt.MoveAction:
            print 'moved'
        else:
            print 'copied'
        print "drop action : ", a
        print "copy - move", QtCore.Qt.CopyAction, QtCore.Qt.MoveAction
        print 'source : ', drag.source(), '    dest : ', drag.target()
Exemplo n.º 25
0
def send(drag_src, data):
    """
	desc:
		Starts a drag event, and embeds a data dictionary as json text in the
		mimedata.

	arguments:
		drag_src:
			desc:	The source widget.
			type:	QWidget
		data:
			desc:	A data dictionary. The 'type' key identifies the type of
					data that is being dropped.
			type:	dict

	returns:
		desc:		A drag object. The start function is called automatically.
		type:		QDrag
	"""

    text = json.dumps(data).decode('utf-8')
    mimedata = QtCore.QMimeData()
    mimedata.setText(text)
    drag = QtGui.QDrag(drag_src)
    drag.setMimeData(mimedata)
    drag.start()
Exemplo n.º 26
0
 def startDrag(self, event):
     text = self.selectedItems()[0].text(0)
     value = "\t$str=\"%s\""%text
     mimeData = QtCore.QMimeData()
     mimeData.setData("text/plain", value)
     drag = QtGui.QDrag(self)
     drag.setMimeData(mimeData)
     result = drag.start(Qt.MoveAction)
Exemplo n.º 27
0
 def mouseMoveEvent(self, event):
     if event.buttons() == QtCore.Qt.LeftButton:
         mimeData = QtCore.QMimeData()
         drag = QtGui.QDrag(self)
         mimeData.setText('9')
         drag.setMimeData(mimeData)
         drag.setHotSpot(event.pos())
         dropAction = drag.start(QtCore.Qt.MoveAction)      
Exemplo n.º 28
0
	def mouseMoveEvent(self,e):
		if e.buttons()!=QtCore.Qt.RightButton:
			return
		mimeData=QtCore.QMimeData()
		drag=QtGui.QDrag(self)
		drag.setMimeData(mimeData)
		drag.setHotSpot(e.pos()-self.rect().topLeft())
		dropAction=drag.start(QtCore.Qt.MoveAction)	
Exemplo n.º 29
0
    def startDrag(self):
        self.mimeData = MimeData()
        self.mimeData.dataRequested.connect(self.createData, QtCore.Qt.DirectConnection)

        drag = QtGui.QDrag(self)
        drag.setMimeData(self.mimeData)
        drag.setPixmap(QtGui.QPixmap(':/images/drag.png'))
        drag.exec_(QtCore.Qt.CopyAction)
Exemplo n.º 30
0
        def mouseMoveEvent(self, event):

            # Determine if the current movement is detected as a drag
            if not self.dragStartPos.isNull() and (
                (event.pos() - self.dragStartPos).manhattanLength() <
                    QtGui.QApplication.startDragDistance()):
                self.dragInitiated = True

            # If the current movement is a drag initiated by the left button
            if (((event.buttons() & QtCore.Qt.LeftButton))
                    and self.dragInitiated):

                # Stop the move event
                finishMoveEvent = QtGui.QMouseEvent(QtCore.QEvent.MouseMove,
                                                    event.pos(),
                                                    QtCore.Qt.NoButton,
                                                    QtCore.Qt.NoButton,
                                                    QtCore.Qt.NoModifier)
                QtGui.QTabBar.mouseMoveEvent(self, finishMoveEvent)

                # Convert the move event into a drag
                drag = QtGui.QDrag(self)
                mimeData = QtCore.QMimeData()
                mimeData.setData('action', 'application/tab-detach')
                drag.setMimeData(mimeData)

                # Create the appearance of dragging the tab content
                pixmap = QtGui.QPixmap.grabWindow(
                    self.parentWidget().currentWidget().winId())
                targetPixmap = QtGui.QPixmap(pixmap.size())
                targetPixmap.fill(QtCore.Qt.transparent)
                painter = QtGui.QPainter(targetPixmap)
                painter.setOpacity(0.85)
                painter.drawPixmap(0, 0, pixmap)
                painter.end()
                drag.setPixmap(targetPixmap)

                # Initiate the drag
                dropAction = drag.exec_(QtCore.Qt.MoveAction
                                        | QtCore.Qt.CopyAction)

                # If the drag completed outside of the tab bar, detach the tab and move
                # the content to the current cursor position
                if dropAction == QtCore.Qt.IgnoreAction:
                    event.accept()
                    self.onDetachTabSignal.emit(self.tabAt(self.dragStartPos),
                                                self.mouseCursor.pos())

                # Else if the drag completed inside the tab bar, move the selected tab to the new position
                elif dropAction == QtCore.Qt.MoveAction:
                    if not self.dragDropedPos.isNull():
                        event.accept()
                        self.onMoveTabSignal.emit(
                            self.tabAt(self.dragStartPos),
                            self.tabAt(self.dragDropedPos))
            else:
                QtGui.QTabBar.mouseMoveEvent(self, event)