def __init__( self,
               admin = None,
               parent = None,
               create_inline = False,
               direction = 'onetomany',
               field_name = 'onetomany',
               **kw ):
     CustomEditor.__init__( self, parent )
     self.setObjectName( field_name )
     layout = QtGui.QHBoxLayout()
     layout.setContentsMargins( 0, 0, 0, 0 )
     #
     # Setup table
     #
     from camelot.view.controls.tableview import AdminTableWidget
     # parent set by layout manager
     table = AdminTableWidget(admin, self)
     table.setObjectName('table')
     rowHeight = QtGui.QFontMetrics( self.font() ).height() + 5
     layout.setSizeConstraint( QtGui.QLayout.SetNoConstraint )
     self.setSizePolicy( QtGui.QSizePolicy.Expanding,
                         QtGui.QSizePolicy.Expanding )
     self.setMinimumHeight( rowHeight*5 )
     table.verticalHeader().sectionClicked.connect(
         self.trigger_list_action
     )
     self.admin = admin
     self.direction = direction
     self.create_inline = create_inline
     layout.addWidget( table )
     self.setLayout( layout )
     self.model = None
     self._new_message = None
     self.gui_context = ListActionGuiContext()
     self.gui_context.view = self
     self.gui_context.admin = self.admin
     self.gui_context.item_view = table
     post( self.admin.get_related_toolbar_actions, 
           self.set_right_toolbar_actions,
           args = (Qt.RightToolBarArea, self.direction ) )
Exemple #2
0
 def __init__(self,
              admin=None,
              parent=None,
              create_inline=False,
              direction='onetomany',
              field_name='onetomany',
              column_width=None,
              proxy=None,
              rows=5,
              **kw):
     CustomEditor.__init__(self, parent, column_width=column_width)
     self.setObjectName(field_name)
     layout = QtWidgets.QHBoxLayout()
     layout.setContentsMargins(0, 0, 0, 0)
     #
     # Setup table
     #
     from camelot.view.controls.tableview import AdminTableWidget
     from camelot.view.proxy.collection_proxy import CollectionProxy
     # parent set by layout manager
     table = AdminTableWidget(admin, self)
     table.setObjectName('table')
     layout.setSizeConstraint(QtGui.QLayout.SetNoConstraint)
     self.setSizePolicy(QtGui.QSizePolicy.Expanding,
                        QtGui.QSizePolicy.Expanding)
     self.setMinimumHeight((self._font_height + 5) * rows)
     table.verticalHeader().sectionClicked.connect(self.trigger_list_action)
     model = (proxy or CollectionProxy)(admin)
     table.setModel(model)
     register.register(model, table)
     self.admin = admin
     self.direction = direction
     self.create_inline = create_inline
     layout.addWidget(table)
     self.setLayout(layout)
     self._new_message = None
     self.gui_context = ListActionGuiContext()
     self.gui_context.view = self
     self.gui_context.admin = self.admin
     self.gui_context.item_view = table
     post(self.admin.get_related_toolbar_actions,
          self.set_right_toolbar_actions,
          args=(Qt.RightToolBarArea, self.direction))
     post(self.get_columns, self.set_columns)
    def __init__( self,
                 admin = None,
                 parent = None,
                 create_inline = False,
                 vertical_header_clickable = True,
                 **kw ):
        """
    :param admin: the Admin interface for the objects on the one side of the
    relation

    :param create_inline: if False, then a new entity will be created within a
    new window, if True, it will be created inline

    :param vertical_header_clickable: True if the vertical header is clickable by the user, False if not.

    after creating the editor, set_value needs to be called to set the
    actual data to the editor
    """

        CustomEditor.__init__( self, parent )
        layout = QtGui.QHBoxLayout()
        layout.setContentsMargins( 0, 0, 0, 0 )
        #
        # Setup table
        #
        from camelot.view.controls.tableview import AdminTableWidget
        # parent set by layout manager
        table = AdminTableWidget(admin, self)
        table.setObjectName('table')
        rowHeight = QtGui.QFontMetrics( self.font() ).height() + 5
        layout.setSizeConstraint( QtGui.QLayout.SetNoConstraint )
        self.setSizePolicy( QtGui.QSizePolicy.Expanding,
                            QtGui.QSizePolicy.Expanding )
        self.setMinimumHeight( rowHeight*5 )
        if vertical_header_clickable:
            table.verticalHeader().sectionClicked.connect(
                self.createFormForIndex
            )
        self.admin = admin
        self.create_inline = create_inline
        self.add_button = None
        self.copy_button = None
        self.delete_button = None
        layout.addWidget( table )
        self.setupButtons( layout, table )
        self.setLayout( layout )
        self.model = None
        self._new_message = None
Exemple #4
0
 def __init__(self,
              admin=None,
              parent=None,
              create_inline=False,
              direction='onetomany',
              field_name='onetomany',
              **kw):
     CustomEditor.__init__(self, parent)
     self.setObjectName(field_name)
     layout = QtGui.QHBoxLayout()
     layout.setContentsMargins(0, 0, 0, 0)
     #
     # Setup table
     #
     from camelot.view.controls.tableview import AdminTableWidget
     # parent set by layout manager
     table = AdminTableWidget(admin, self)
     table.setObjectName('table')
     rowHeight = QtGui.QFontMetrics(self.font()).height() + 5
     layout.setSizeConstraint(QtGui.QLayout.SetNoConstraint)
     self.setSizePolicy(QtGui.QSizePolicy.Expanding,
                        QtGui.QSizePolicy.Expanding)
     self.setMinimumHeight(rowHeight * 5)
     table.verticalHeader().sectionClicked.connect(self.trigger_list_action)
     self.admin = admin
     self.direction = direction
     self.create_inline = create_inline
     layout.addWidget(table)
     self.setLayout(layout)
     self.model = None
     self._new_message = None
     self.gui_context = ListActionGuiContext()
     self.gui_context.view = self
     self.gui_context.admin = self.admin
     self.gui_context.item_view = table
     post(self.admin.get_related_toolbar_actions,
          self.set_right_toolbar_actions,
          args=(Qt.RightToolBarArea, self.direction))