Package Camelot :: Package camelot :: Package view :: Package controls :: Package delegates :: Module one2manydelegate |
[frames] | no frames]

# Source Code for Module Camelot.camelot.view.controls.delegates.one2manydelegate

     1  from PyQt4 import QtGui
     2  from PyQt4.QtCore import Qt
     3

     4  from camelot.view.controls import editors
     5  from camelot.core.utils import variant_to_pyobject
     6

     7  import logging
     8  logger = logging.getLogger( 'camelot.view.controls.delegates.one2manydelegate' )
     9

    10 -class One2ManyDelegate( QtGui.QItemDelegate ):
    11      """Custom delegate for many 2 one relations

    12

    13    .. image:: ../_static/onetomany.png

    14    """
    15

    16 -    def __init__( self, parent = None, **kwargs ):
    17          logger.debug( 'create one2manycolumn delegate' )
    18          assert 'delegate' in kwargs
    19          QtGui.QItemDelegate.__init__( self, parent )
    20          self.kwargs = kwargs
    21

    22 -    def createEditor( self, parent, option, index ):
    23          logger.debug( 'create a one2many editor' )
    24          editor = editors.One2ManyEditor( parent = parent, **self.kwargs )
    25          self.setEditorData( editor, index )
    26          return editor
    27

    28 -    def setEditorData( self, editor, index ):
    29          logger.debug( 'set one2many editor data' )
    30          model = variant_to_pyobject( index.data( Qt.EditRole ) )
    31          editor.set_value( model )
    32

    33 -    def setModelData( self, editor, model, index ):
    34          pass
    35