Package Camelot :: Package camelot :: Package view :: Package controls :: Package editors :: Module manytomanyeditor |
[frames] | no frames]

# Source Code for Module Camelot.camelot.view.controls.editors.manytomanyeditor

     1  from one2manyeditor import One2ManyEditor, QtGui, QtCore
     2  from customeditor import editingFinished
     3  from abstractmanytooneeditor import AbstractManyToOneEditor
     4

     5  from camelot.view.art import Icon
     6  from camelot.view.model_thread import model_function, post
     7

     8 -class ManyToManyEditor( One2ManyEditor, AbstractManyToOneEditor ):
     9

    10 -    def setupButtons( self, layout ):
    11          button_layout = QtGui.QVBoxLayout()
    12          button_layout.setSpacing( 0 )
    13          remove_button = QtGui.QToolButton()
    14          remove_button.setIcon( Icon( 'tango/16x16/actions/list-remove.png' ).getQIcon() )
    15          remove_button.setAutoRaise( True )
    16          remove_button.setFixedHeight( self.get_height() )
    17          self.connect( remove_button,

    18                       QtCore.SIGNAL( 'clicked()' ),

    19                       self.removeSelectedRows )
    20          add_button = QtGui.QToolButton()
    21          add_button.setIcon( Icon( 'tango/16x16/actions/list-add.png' ).getQIcon() )
    22          add_button.setAutoRaise( True )
    23          add_button.setFixedHeight( self.get_height() )
    24          self.connect( add_button, QtCore.SIGNAL( 'clicked()' ), self.createSelectView )
    25  #    new_button = QtGui.QToolButton()

    26  #    new_button.setIcon(Icon('tango/16x16/actions/document-new.png').getQIcon())

    27  #    new_button.setAutoRaise(True)

    28  #    self.connect(new_button, QtCore.SIGNAL('clicked()'), self.newRow)

    29          button_layout.addStretch()
    30          button_layout.addWidget( add_button )
    31          button_layout.addWidget( remove_button )
    32  #    button_layout.addWidget(new_button)

    33          layout.addLayout( button_layout )
    34

    35 -    def selectEntity( self, entity_instance_getter ):
    36

    37          @model_function
    38          def insert():
    39              o = entity_instance_getter()
    40              self.model.insertEntityInstance( 0, o )
    41

    42          post( insert, self.editingFinished )
    43

    44 -    def editingFinished(self, *args):
    45          self.emit( editingFinished )
    46

    47 -    def removeSelectedRows( self ):
    48          """Remove the selected rows in this tableview, but don't delete them"""
    49          for row in set( map( lambda x: x.row(), self.table.selectedIndexes() ) ):
    50              self.model.removeRow( row, delete = False )
    51          self.emit( editingFinished )
    52