Example #1
0
    def __init__(self, parent=None):
        
        from camelot.view.controls.formview import FormWidget
        from camelot.view.proxy.collection_proxy import CollectionProxy
        
        super(FormPage, self).__init__(parent)
        assert self.Data
        self.setTitle(unicode(self.get_title()))
        self.setSubTitle(unicode(self.get_sub_title()))
        self.setPixmap(QtGui.QWizard.LogoPixmap, self.get_icon().getQPixmap())
        self._data = self.Data()
        self._complete = False
        
        admin = self.get_admin()
        self._model = CollectionProxy(admin, lambda:[self._data], admin.get_fields)
        validator = self._model.get_validator()
        
        layout = QtGui.QVBoxLayout()
        form = FormWidget(self, admin)
        validator.validity_changed_signal.connect( self._validity_changed )
        form.set_model(self._model)
        layout.addWidget(form)
        self.setLayout(layout)

        if hasattr(admin, 'form_size'):
            self.setMinimumSize(admin.form_size[0], admin.form_size[1])
Example #2
0
    def __init__(
        self,
        obj,
        admin,
        title=_("Please complete"),
        subtitle=_("Complete the form and press the OK button"),
        icon=Icon("tango/22x22/categories/preferences-system.png"),
        parent=None,
        flags=QtCore.Qt.Dialog,
    ):
        from camelot.view.controls.formview import FormWidget
        from camelot.view.proxy.collection_proxy import CollectionProxy

        super(ChangeObjectDialog, self).__init__("", parent, flags)

        self.setWindowTitle(admin.get_verbose_name())
        self.set_banner_logo_pixmap(icon.getQPixmap())
        self.set_banner_title(unicode(title))
        self.set_banner_subtitle(unicode(subtitle))
        self.banner_widget().setStyleSheet("background-color: white;")

        model = CollectionProxy(admin, lambda: [obj], admin.get_fields)
        validator = model.get_validator()
        layout = QtGui.QHBoxLayout()
        layout.setObjectName("form_and_actions_layout")
        form_widget = FormWidget(parent=self, admin=admin)
        layout.addWidget(form_widget)
        validator.validity_changed_signal.connect(self._validity_changed)
        form_widget.set_model(model)
        form_widget.setObjectName("form")
        self.main_widget().setLayout(layout)

        self.gui_context = FormActionGuiContext()
        self.gui_context.workspace = self
        self.gui_context.admin = admin
        self.gui_context.view = self
        self.gui_context.widget_mapper = self.findChild(QtGui.QDataWidgetMapper, "widget_mapper")

        cancel_button = QtGui.QPushButton(ugettext("Cancel"))
        cancel_button.setObjectName("cancel")
        ok_button = QtGui.QPushButton(ugettext("OK"))
        ok_button.setObjectName("ok")
        ok_button.setEnabled(False)
        layout = QtGui.QHBoxLayout()
        layout.setDirection(QtGui.QBoxLayout.RightToLeft)
        layout.addWidget(ok_button)
        layout.addWidget(cancel_button)
        layout.addStretch()
        self.buttons_widget().setLayout(layout)
        cancel_button.pressed.connect(self.reject)
        ok_button.pressed.connect(self.accept)

        # do inital validation, so the validity changed signal is valid
        self._validity_changed(0)

        # set the actions in the actions panel
        get_actions = admin.get_form_actions
        post(functools.update_wrapper(functools.partial(get_actions, None), get_actions), self.set_actions)
Example #3
0
 def __init__( self, 
               obj, 
               admin,
               title =  _('Please complete'),
               subtitle = _('Complete the form and press the OK button'),
               icon = Icon('tango/22x22/categories/preferences-system.png'),
               parent=None, 
               flags=QtCore.Qt.Dialog ):
     from camelot.view.controls.formview import FormWidget
     from camelot.view.proxy.collection_proxy import CollectionProxy
     super(ChangeObjectDialog, self).__init__( '', parent, flags )
     
     self.setWindowTitle( admin.get_verbose_name() )
     self.set_banner_logo_pixmap( icon.getQPixmap() )
     self.set_banner_title( unicode(title) )
     self.set_banner_subtitle( unicode(subtitle) )
     self.banner_widget().setStyleSheet('background-color: white;')
     
     model = CollectionProxy(admin, lambda:[obj], admin.get_fields)
     validator = model.get_validator()
     layout = QtGui.QVBoxLayout()
     form_widget = FormWidget( parent=self, admin=admin )
     layout.addWidget( form_widget )
     validator.validity_changed_signal.connect( self._validity_changed )
     form_widget.set_model( model )
     form_widget.setObjectName( 'form' )
     self.main_widget().setLayout(layout)
 
     cancel_button = QtGui.QPushButton( ugettext('Cancel') )
     cancel_button.setObjectName( 'cancel' )
     ok_button = QtGui.QPushButton( ugettext('OK') )
     ok_button.setObjectName( 'ok' )
     ok_button.setEnabled( False )
     layout = QtGui.QHBoxLayout()
     layout.setDirection( QtGui.QBoxLayout.RightToLeft )
     layout.addWidget( ok_button )
     layout.addWidget( cancel_button )
     layout.addStretch()
     self.buttons_widget().setLayout( layout )
     cancel_button.pressed.connect( self.reject )
     ok_button.pressed.connect( self.accept )
     
     # do inital validation, so the validity changed signal is valid
     self._validity_changed( 0 )
Example #4
0
 def __init__( self, 
               obj, 
               admin,
               title =  _('Please complete'),
               subtitle = _('Complete the form and press the OK button'),
               icon = Icon('tango/22x22/categories/preferences-system.png'),
               parent=None, 
               flags=QtCore.Qt.Dialog ):
     from camelot.view.controls.formview import FormWidget
     from camelot.view.proxy.collection_proxy import CollectionProxy
     super(ChangeObjectDialog, self).__init__( '', parent, flags )
     
     self.setWindowTitle( admin.get_verbose_name() )
     self.set_banner_logo_pixmap( icon.getQPixmap() )
     self.set_banner_title( unicode(title) )
     self.set_banner_subtitle( unicode(subtitle) )
     self.banner_widget().setStyleSheet('background-color: white;')
     
     model = CollectionProxy(admin, lambda:[obj], admin.get_fields)
     validator = model.get_validator()
     layout = QtGui.QHBoxLayout()
     layout.setObjectName( 'form_and_actions_layout' )
     form_widget = FormWidget( parent=self, admin=admin )
     layout.addWidget( form_widget )
     validator.validity_changed_signal.connect( self._validity_changed )
     form_widget.set_model( model )
     form_widget.setObjectName( 'form' )
     if hasattr(admin, 'form_size') and admin.form_size:
         form_widget.setMinimumSize(admin.form_size[0], admin.form_size[1])          
     self.main_widget().setLayout(layout)
 
     self.gui_context = FormActionGuiContext()
     self.gui_context.workspace = self
     self.gui_context.admin = admin
     self.gui_context.view = self
     self.gui_context.widget_mapper = self.findChild( QtGui.QDataWidgetMapper, 
                                                      'widget_mapper' )
     
     cancel_button = QtGui.QPushButton( ugettext('Cancel') )
     cancel_button.setObjectName( 'cancel' )
     ok_button = QtGui.QPushButton( ugettext('OK') )
     ok_button.setObjectName( 'ok' )
     ok_button.setEnabled( False )
     layout = QtGui.QHBoxLayout()
     layout.setDirection( QtGui.QBoxLayout.RightToLeft )
     layout.addWidget( ok_button )
     layout.addWidget( cancel_button )
     layout.addStretch()
     self.buttons_widget().setLayout( layout )
     cancel_button.pressed.connect( self.reject )
     ok_button.pressed.connect( self.accept )
     admin._apply_form_state( self )
     
     # do inital validation, so the validity changed signal is valid
     self._validity_changed( 0 )
     
     # set the actions in the actions panel
     get_actions = admin.get_form_actions
     post( functools.update_wrapper( functools.partial( get_actions, 
                                                        None ),
                                     get_actions ),
           self.set_actions )