def dragObject(self): if not self.selectedIndexes(): return item = self.selectedItems()[0] role = item.data(0, QtCore.Qt.UserRole) if role == 'Folder': return text = 'KrakenComponent:' + role mimeData = QtCore.QMimeData() mimeData.setText(text) drag = QtGui.QDrag(self) drag.setMimeData(mimeData) drag.setHotSpot(QtCore.QPoint(90, 23)) ghostComponent = QtGui.QPixmap(180, 46) ghostComponent.fill(QtGui.QColor(67, 143, 153, 80)) drag.setPixmap(ghostComponent) drag.start(QtCore.Qt.IgnoreAction)
def getSelectedNodesCentroid(self): selectedNodes = self.getSelectedNodes() leftMostNode = None topMostNode = None for node in selectedNodes: nodePos = node.getGraphPos() if leftMostNode is None: leftMostNode = node else: if nodePos.x() < leftMostNode.getGraphPos().x(): leftMostNode = node if topMostNode is None: topMostNode = node else: if nodePos.y() < topMostNode.getGraphPos().y(): topMostNode = node xPos = leftMostNode.getGraphPos().x() yPos = topMostNode.getGraphPos().y() pos = QtCore.QPoint(xPos, yPos) return pos
def pasteMirroredConnected(self): graphView = self.getGraphView() clipboardData = self.graphView.getClipboardData() pos = clipboardData['copyPos'] + QtCore.QPoint(20, 20) graphView.pasteSettings(pos, mirrored=True, createConnectionsToExistingNodes=True)