<s> from PySide import QtCore , QtGui <EOL> import depends_node <EOL> import depends_data_packet <EOL> """<STR_LIT>""" <EOL> class SceneGraphWidget ( QtGui . QWidget ) : <EOL> """<STR_LIT>""" <EOL> mouseover = QtCore . Signal ( depends_node . DagNode ) <EOL> def __init__ ( self , parent = None ) : <EOL> """<STR_LIT:U+0020>""" <EOL> QtGui . QWidget . __init__ ( self , parent ) <EOL> self . mainLayout = QtGui . QVBoxLayout ( self ) <EOL> self . mainLayout . setAlignment ( QtCore . Qt . AlignTop ) <EOL> self . setLayout ( self . mainLayout ) <EOL> self . setMinimumWidth ( <NUM_LIT> ) <EOL> self . tableWidget = QtGui . QTableWidget ( ) <EOL> self . tableWidget . setRowCount ( <NUM_LIT:0> ) <EOL> self . tableWidget . setColumnCount ( <NUM_LIT:1> ) <EOL> self . tableWidget . horizontalHeader ( ) . hide ( ) <EOL> self . tableWidget . horizontalHeader ( ) . setStretchLastSection ( True ) <EOL> self . tableWidget . horizontalHeader ( ) . setResizeMode ( <NUM_LIT:1> , QtGui . QHeaderView . Stretch ) <EOL> self . tableWidget . verticalHeader ( ) . hide ( ) <EOL> self . tableWidget . setEditTriggers ( QtGui . QTableWidget . NoEditTriggers ) <EOL> self . tableWidget . setFocusPolicy ( QtCore . Qt . NoFocus ) <EOL> self . tableWidget . setStyleSheet ( "<STR_LIT>" ) <EOL> self . mainLayout . addWidget ( self . tableWidget ) <EOL> def highlightRowsUsingNodes ( self , dagNodes ) : <EOL> """<STR_LIT>""" <EOL> if dagNodes is None : <EOL> self . tableWidget . clearSelection ( ) <EOL> return <EOL> for dagNode in dagNodes : <EOL> for row in range ( self . tableWidget . rowCount ( ) ) : <EOL> widget = self . tableWidget . cellWidget ( row , <NUM_LIT:0> ) <EOL> if widget . pointerToDataPacket . sourceNode is dagNode : <EOL> self . tableWidget . selectRow ( row ) <EOL> def handleMouseover ( self , dagNodes ) : <EOL> """<STR_LIT>""" <EOL> self . highlightRowsUsingNodes ( dagNodes ) <EOL> self . mouseover . emit ( dagNodes ) <EOL> def rebuild ( self , sceneGraph , selectedDagNode ) : <EOL> """<STR_LIT>""" <EOL> if not sceneGraph : <EOL> self . tableWidget . setRowCount ( <NUM_LIT:0> ) <EOL> return <EOL> rowCount = len ( [ dp for dp in sceneGraph if dp . sourceNode != selectedDagNode ] ) <EOL> self . tableWidget . setRowCount ( rowCount ) <EOL> index = <NUM_LIT:0> <EOL> for dataPacket in sceneGraph : <EOL> if dataPacket . sourceNode == selectedDagNode : <EOL> continue <EOL> self . tableWidget . setRowHeight ( index , <NUM_LIT:20> ) <EOL> disabled = False <EOL> if selectedDagNode . dataPacketTypesAccepted ( ) and type ( dataPacket ) not in selectedDagNode . dataPacketTypesAccepted ( ) : <EOL> disabled = True <EOL> class DraggableTextWidget ( QtGui . QLabel ) : <EOL> mouseover = QtCore . Signal ( depends_node . DagNode ) <EOL> def __init__ ( self , dataPacket , * args ) : <EOL> super ( DraggableTextWidget , self ) . __init__ ( * args ) <EOL> self . pointerToDataPacket = dataPacket <EOL> self . setStyleSheet ( "<STR_LIT>" ) <EOL> def mousePressEvent ( self , event ) : <EOL> mimeData = QtCore . QMimeData ( ) <EOL> dragText = depends_data_packet . scenegraphLocationString ( self . pointerToDataPacket ) <EOL> mimeData . setText ( dragText ) <EOL> drag = QtGui . QDrag ( self ) <EOL> drag . setMimeData ( mimeData ) <EOL> drag . exec_ ( QtCore . Qt . CopyAction ) <EOL> def enterEvent ( self , event ) : <EOL> self . mouseover . emit ( [ self . pointerToDataPacket . sourceNode ] ) <EOL> QtGui . QLabel . enterEvent ( self , event ) <EOL> def leaveEvent ( self , event ) : <EOL> self . mouseover . emit ( None ) <EOL> QtGui . QLabel . leaveEvent ( self , event ) <EOL> textWidget = DraggableTextWidget ( dataPacket ) <EOL> textWidget . setTextFormat ( QtCore . Qt . RichText ) <EOL> colorString = "<STR_LIT>" if dataPacket . dataPresent ( ) else "<STR_LIT>" <EOL> if disabled : <EOL> colorString = "<STR_LIT>" <EOL> textWidget . setText ( "<STR_LIT>" % ( colorString , dataPacket . typeStr ( ) , depends_data_packet . shorthandScenegraphLocationString ( dataPacket ) ) ) <EOL> self . tableWidget . setCellWidget ( index , <NUM_LIT:0> , textWidget ) <EOL> textWidget . mouseover . connect ( self . handleMouseover ) <EOL> index += <NUM_LIT:1> <EOL> self . repaint ( ) </s>
