def setValue(self, value):
		"""
		Set the value of this edit's input object to the given string and 
		handle the messages appropriately.
		"""
		# The only way to get the shorthand location string is to set the existing
		# input to the new full ID and request the string.  This means that when
		# we send the valueChanged signal, it was getting an "old value" identical
		# to the new value.  Setting the input's value to what it used to be before
		# emitting the message has provided a temporary bandaid.
		oldValue = self.input.value
		self.input.value = value
		self.inputHasBeenChangedTo = value 
		if self.input.value != "":
			dataPacketForInput = self.dag.nodeInputDataPacket(self.dagNode, self.input)
			self.input.value = oldValue
			self.lineEdit.setText(depends_data_packet.shorthandScenegraphLocationString(dataPacketForInput))
		else:
			self.lineEdit.setText("")
 def setValue(self, value):
     """
     Set the value of this edit's input object to the given string and 
     handle the messages appropriately.
     """
     # The only way to get the shorthand location string is to set the existing
     # input to the new full ID and request the string.  This means that when
     # we send the valueChanged signal, it was getting an "old value" identical
     # to the new value.  Setting the input's value to what it used to be before
     # emitting the message has provided a temporary bandaid.
     oldValue = self.input.value
     self.input.value = value
     self.inputHasBeenChangedTo = value
     if self.input.value != "":
         dataPacketForInput = self.dag.nodeInputDataPacket(
             self.dagNode, self.input)
         self.input.value = oldValue
         self.lineEdit.setText(
             depends_data_packet.shorthandScenegraphLocationString(
                 dataPacketForInput))
     else:
         self.lineEdit.setText("")
    def rebuild(self, sceneGraph, selectedDagNode):
        """
        Rebuild the current widget, given a scene graph object and the selected
        dag node.  A value of None in the sceneGraph field clears the widget, and
        a value of none in the selectedDagNode field displays all nodes including
        the selected one.
        """
        if not sceneGraph:
            self.tableWidget.setRowCount(0)
            return
        
        # Count the number of rows
        rowCount = len([dp for dp in sceneGraph if dp.sourceNode != selectedDagNode])
        self.tableWidget.setRowCount(rowCount)

        index = 0
        for dataPacket in sceneGraph:
            if dataPacket.sourceNode == selectedDagNode:
                continue
            self.tableWidget.setRowHeight(index, 20)
            
            # If the selected dag node can't read the datatype, make it obvious
            disabled = False
            if selectedDagNode.dataPacketTypesAccepted() and type(dataPacket) not in selectedDagNode.dataPacketTypesAccepted():
                disabled = True

            # Add the text field with enhanced middle-button drag'n'drop functionality
            class DraggableTextWidget(QtGui.QLabel):
                # Signals
                mouseover = QtCore.Signal(depends_node.DagNode)

                def __init__(self, dataPacket, *args):
                    super(DraggableTextWidget, self).__init__(*args)
                    self.pointerToDataPacket = dataPacket
                    self.setStyleSheet("background:transparent;")
                
                def mousePressEvent(self, event):
                    #if event.buttons() != QtCore.Qt.MiddleButton:
                    #   return QtGui.QLabel().mousePressEvent(event)
                    mimeData = QtCore.QMimeData()
                    dragText = depends_data_packet.scenegraphLocationString(self.pointerToDataPacket)
                    mimeData.setText(dragText)
                    drag = QtGui.QDrag(self)
                    drag.setMimeData(mimeData)
                    drag.exec_(QtCore.Qt.CopyAction)
                    #QtGui.QLabel.mousePressEvent(self, event)
                    
                def enterEvent(self, event):
                    self.mouseover.emit([self.pointerToDataPacket.sourceNode])
                    QtGui.QLabel.enterEvent(self, event)
                    
                def leaveEvent(self, event):
                    self.mouseover.emit(None)
                    QtGui.QLabel.leaveEvent(self, event)
            textWidget = DraggableTextWidget(dataPacket)
            
            textWidget.setTextFormat(QtCore.Qt.RichText)
            colorString = "00aa00" if dataPacket.dataPresent() else "aa0000"
            if disabled:
                colorString = "868686"
            textWidget.setText("<html><font color=\"#%s\">&nbsp;%s</font> - %s</html>" % (colorString, dataPacket.typeStr(), depends_data_packet.shorthandScenegraphLocationString(dataPacket)))
            self.tableWidget.setCellWidget(index, 0, textWidget)

            # Chain the text edit mouseover signal out with property name and value
            textWidget.mouseover.connect(self.handleMouseover)
            index += 1

        # Unsure if this is really necessary, but it makes a difference
        self.repaint()
    def rebuild(self, sceneGraph, selectedDagNode):
        """
        Rebuild the current widget, given a scene graph object and the selected
        dag node.  A value of None in the sceneGraph field clears the widget, and
        a value of none in the selectedDagNode field displays all nodes including
        the selected one.
        """
        if not sceneGraph:
            self.tableWidget.setRowCount(0)
            return

        # Count the number of rows
        rowCount = len(
            [dp for dp in sceneGraph if dp.sourceNode != selectedDagNode])
        self.tableWidget.setRowCount(rowCount)

        index = 0
        for dataPacket in sceneGraph:
            if dataPacket.sourceNode == selectedDagNode:
                continue
            self.tableWidget.setRowHeight(index, 20)

            # If the selected dag node can't read the datatype, make it obvious
            disabled = False
            if selectedDagNode.dataPacketTypesAccepted() and type(
                    dataPacket) not in selectedDagNode.dataPacketTypesAccepted(
                    ):
                disabled = True

            # Add the text field with enhanced middle-button drag'n'drop functionality
            class DraggableTextWidget(QtGui.QLabel):
                # Signals
                mouseover = QtCore.Signal(depends_node.DagNode)

                def __init__(self, dataPacket, *args):
                    super(DraggableTextWidget, self).__init__(*args)
                    self.pointerToDataPacket = dataPacket
                    self.setStyleSheet("background:transparent;")

                def mousePressEvent(self, event):
                    #if event.buttons() != QtCore.Qt.MiddleButton:
                    #   return QtGui.QLabel().mousePressEvent(event)
                    mimeData = QtCore.QMimeData()
                    dragText = depends_data_packet.scenegraphLocationString(
                        self.pointerToDataPacket)
                    mimeData.setText(dragText)
                    drag = QtGui.QDrag(self)
                    drag.setMimeData(mimeData)
                    drag.exec_(QtCore.Qt.CopyAction)
                    #QtGui.QLabel.mousePressEvent(self, event)

                def enterEvent(self, event):
                    self.mouseover.emit([self.pointerToDataPacket.sourceNode])
                    QtGui.QLabel.enterEvent(self, event)

                def leaveEvent(self, event):
                    self.mouseover.emit(None)
                    QtGui.QLabel.leaveEvent(self, event)

            textWidget = DraggableTextWidget(dataPacket)

            textWidget.setTextFormat(QtCore.Qt.RichText)
            colorString = "00aa00" if dataPacket.dataPresent() else "aa0000"
            if disabled:
                colorString = "868686"
            textWidget.setText(
                "<html><font color=\"#%s\">&nbsp;%s</font> - %s</html>" %
                (colorString, dataPacket.typeStr(),
                 depends_data_packet.shorthandScenegraphLocationString(
                     dataPacket)))
            self.tableWidget.setCellWidget(index, 0, textWidget)

            # Chain the text edit mouseover signal out with property name and value
            textWidget.mouseover.connect(self.handleMouseover)
            index += 1

        # Unsure if this is really necessary, but it makes a difference
        self.repaint()