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()
dataset/ETHPy150Open andrew-gardner/dependsworkflow/depends/depends_scenegraph_widget.py/SceneGraphWidget.rebuild/original