<s> from PySide import QtGui , QtCore <EOL> from . . fe import FE <EOL> from . . widget_factory import EditorFactory <EOL> from . . base_editor import BaseValueEditor <EOL> import combo_box_editor <EOL> class ListViewEditor ( BaseValueEditor ) : <EOL> def __init__ ( self , valueController , parent = None ) : <EOL> super ( ListViewEditor , self ) . __init__ ( valueController , parent = parent ) <EOL> hbox = QtGui . QHBoxLayout ( ) <EOL> self . _editor = QtGui . QListWidget ( self ) <EOL> self . __items = valueController . getOption ( '<STR_LIT>' ) <EOL> for item in self . __items : <EOL> self . _editor . addItem ( str ( item ) ) <EOL> self . _editor . setMaximumHeight ( <NUM_LIT> ) <EOL> hbox . addWidget ( self . _editor , <NUM_LIT:1> ) <EOL> hbox . addStretch ( <NUM_LIT:0> ) <EOL> hbox . setContentsMargins ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> self . setLayout ( hbox ) <EOL> self . setSizePolicy ( QtGui . QSizePolicy . Preferred , QtGui . QSizePolicy . Fixed ) <EOL> self . updateEditorValue ( ) <EOL> if self . isEditable ( ) : <EOL> self . _editor . itemSelectionChanged . connect ( self . _setValueToController ) <EOL> else : <EOL> self . _editor . setReadOnly ( True ) <EOL> def getEditorValue ( self ) : <EOL> return self . __items [ self . _editor . currentRow ( ) ] <EOL> def setEditorValue ( self , value ) : <EOL> self . _updatingEditor = True <EOL> if value in self . __items : <EOL> index = self . __items . index ( value ) <EOL> else : <EOL> index = <NUM_LIT:0> <EOL> self . _editor . setCurrentItem ( self . _editor . item ( index ) ) <EOL> self . _updatingEditor = False <EOL> @ classmethod <EOL> def canDisplay ( cls , valueController ) : <EOL> return valueController . getDataType ( ) == '<STR_LIT>' and valueController . hasOption ( '<STR_LIT>' ) <EOL> EditorFactory . registerEditorClass ( ListViewEditor ) </s>
