def set_value( self, model ): model = CustomEditor.set_value( self, model ) table = self.findChild(QtGui.QWidget, 'table') if table and model and model != self.model: self.model = model table.setModel( model ) register.register( self.model, table ) post( model._extend_cache, self.update_delegates )
def set_model(self, model): widget_mapper = self.findChild(QtWidgets.QDataWidgetMapper, 'widget_mapper') if model is not None: model.dataChanged.connect(self._data_changed) model.layoutChanged.connect(self._layout_changed) model.modelReset.connect(self._model_reset) model.rowsInserted.connect(self._layout_changed) model.rowsRemoved.connect(self._layout_changed) if widget_mapper is not None: widget_mapper.setModel( model ) register.register( model, widget_mapper )
def set_value(self, model): model = CustomEditor.set_value(self, model) table = self.findChild(QtGui.QWidget, "table") if table and model and model != self.model: self.model = model table.setModel(model) register.register(self.model, table) model_context = self.gui_context.create_model_context() for toolbar in self.findChildren(QtGui.QToolBar): for qaction in toolbar.actions(): post(qaction.action.get_state, qaction.set_state, args=(model_context,)) post(model._extend_cache, self.update_delegates)
def setModel( self, model ): assert object_thread( self ) # # An editor might be open that is no longer available for the new # model. Not closing this editor, results in assertion failures # in qt, resulting in segfaults in the debug build. # self.close_editor() # # Editor, closed. it should be safe to change the model # QtGui.QTableView.setModel( self, model ) register.register( model, self ) self.selectionModel().currentChanged.connect( self.activated )
def setModel(self, model): assert object_thread(self) # # An editor might be open that is no longer available for the new # model. Not closing this editor, results in assertion failures # in qt, resulting in segfaults in the debug build. # self.close_editor() # # Editor, closed. it should be safe to change the model # QtGui.QTableView.setModel(self, model) register.register(model, self) self.selectionModel().currentChanged.connect(self.activated)
def set_value(self, model): model = CustomEditor.set_value(self, model) table = self.findChild(QtGui.QWidget, 'table') if table and model and model != self.model: self.model = model table.setModel(model) register.register(self.model, table) model_context = self.gui_context.create_model_context() for toolbar in self.findChildren(QtGui.QToolBar): for qaction in toolbar.actions(): post(qaction.action.get_state, qaction.set_state, args=(model_context, )) post(model._extend_cache, self.update_delegates)
def set_model(self, model): self._model = model self._model.dataChanged.connect( self._data_changed ) self._model.layoutChanged.connect( self._layout_changed ) self._model.item_delegate_changed_signal.connect( self._item_delegate_changed ) self._model.setObjectName( 'model' ) widget_mapper = self.findChild(QtGui.QDataWidgetMapper, 'widget_mapper' ) if widget_mapper: widget_mapper.setModel( model ) register.register( model, widget_mapper ) def get_columns_and_form(): return (self._model.getColumns(), self._admin.get_form_display()) post(get_columns_and_form, self._set_columns_and_form)
def set_model(self, model): self._model = model self._model.dataChanged.connect(self._data_changed) self._model.layoutChanged.connect(self._layout_changed) self._model.item_delegate_changed_signal.connect( self._item_delegate_changed) self._model.setObjectName('model') widget_mapper = self.findChild(QtGui.QDataWidgetMapper, 'widget_mapper') if widget_mapper: widget_mapper.setModel(model) register.register(model, widget_mapper) def get_columns_and_form(): return (self._model.getColumns(), self._admin.get_form_display()) post(get_columns_and_form, self._set_columns_and_form)
def setModel(self, model): # # An editor might be open that is no longer available for the new # model. Not closing this editor, results in assertion failures # in qt, resulting in segfaults in the debug build. # self.close_editor() # # Editor, closed. it should be safe to change the model # QtGui.QTableView.setModel(self, model) frozen_table_view = self.findChild(QtGui.QWidget, 'frozen_table_view') if frozen_table_view: model.layoutChanged.connect(self._update_frozen_table) frozen_table_view.setModel(model) self._update_frozen_table() register.register(model, self) self.selectionModel().currentChanged.connect(self.activated)
def setModel(self, model): # # An editor might be open that is no longer available for the new # model. Not closing this editor, results in assertion failures # in qt, resulting in segfaults in the debug build. # self.close_editor() # # Editor, closed. it should be safe to change the model # QtGui.QTableView.setModel(self, model) frozen_table_view = self.findChild(QtGui.QWidget, "frozen_table_view") if frozen_table_view: model.layoutChanged.connect(self._update_frozen_table) frozen_table_view.setModel(model) self._update_frozen_table() register.register(model, self) self.selectionModel().currentChanged.connect(self.activated)
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 setModel(self, model): assert object_thread(self) # # An editor might be open that is no longer available for the new # model. Not closing this editor, results in assertion failures # in qt, resulting in segfaults in the debug build. # self.close_editor() # # Editor, closed. it should be safe to change the model # QtWidgets.QTableView.setModel(self, model) register.register(model, self) # assign selection model to local variable to keep it alive during # method call, or PySide segfaults selection_model = self.selectionModel() selection_model.currentChanged.connect(self._current_changed) model.modelReset.connect(self.update_headers) self.update_headers()
def show_top_level(view, parent): """Show a widget as a top level window :param view: the widget extend AbstractView :param parent: the widget with regard to which the top level window will be placed. """ from camelot.view.register import register # # Register the view with reference to itself. This will keep # the Python object alive as long as the Qt object is not # destroyed. Hence Python will not trigger the deletion of the # view as long as the window is not closed # register(view, view) # # set the parent to None to avoid the window being destructed # once the parent gets destructed # view.setParent(None) view.setWindowFlags(QtCore.Qt.Window) # # Make the window title blank to prevent the something # like main.py or pythonw being displayed # view.setWindowTitle(u'') view.title_changed_signal.connect(view.setWindowTitle) view.icon_changed_signal.connect(view.setWindowIcon) view.setAttribute(QtCore.Qt.WA_DeleteOnClose) # # position the new window in the center of the same screen # as the parent # screen = QtGui.QApplication.desktop().screenNumber(parent) available = QtGui.QApplication.desktop().availableGeometry(screen) point = QtCore.QPoint(available.x() + available.width() / 2, available.y() + available.height() / 2) point = QtCore.QPoint(point.x() - view.width() / 2, point.y() - view.height() / 2) view.move(point) #view.setWindowModality(QtCore.Qt.WindowModal) view.show()
def show_top_level(view, parent): """Show a widget as a top level window :param view: the widget extend AbstractView :param parent: the widget with regard to which the top level window will be placed. """ from camelot.view.register import register # # Register the view with reference to itself. This will keep # the Python object alive as long as the Qt object is not # destroyed. Hence Python will not trigger the deletion of the # view as long as the window is not closed # register( view, view ) # # set the parent to None to avoid the window being destructed # once the parent gets destructed # view.setParent( None ) view.setWindowFlags(QtCore.Qt.Window) # # Make the window title blank to prevent the something # like main.py or pythonw being displayed # view.setWindowTitle( u'' ) view.title_changed_signal.connect( view.setWindowTitle ) view.icon_changed_signal.connect( view.setWindowIcon ) view.setAttribute(QtCore.Qt.WA_DeleteOnClose) # # position the new window in the center of the same screen # as the parent # screen = QtGui.QApplication.desktop().screenNumber(parent) available = QtGui.QApplication.desktop().availableGeometry(screen) point = QtCore.QPoint(available.x() + available.width()/2, available.y() + available.height()/2) point = QtCore.QPoint(point.x()-view.width()/2, point.y()-view.height()/2) view.move( point ) #view.setWindowModality(QtCore.Qt.WindowModal) view.show()
def show_top_level(view, parent, state=None): """Show a widget as a top level window. If a parent window is given, the new window will have the same modality as the parent. :param view: the widget extend AbstractView :param parent: the widget with regard to which the top level window will be placed. :param state: the state of the form, 'maximized', or 'left' or 'right', ... """ from camelot.view.register import register # # Register the view with reference to itself. This will keep # the Python object alive as long as the Qt object is not # destroyed. Hence Python will not trigger the deletion of the # view as long as the window is not closed # register(view, view) # # set the parent to None to avoid the window being destructed # once the parent gets destructed # view.setParent(None) view.setWindowFlags(QtCore.Qt.Window) # # Make the window title blank to prevent the something # like main.py or pythonw being displayed # view.setWindowTitle(u' ') view.title_changed_signal.connect(view.setWindowTitle) view.icon_changed_signal.connect(view.setWindowIcon) view.setAttribute(QtCore.Qt.WA_DeleteOnClose) apply_form_state(view, parent, state) if parent is not None: view.setWindowModality(parent.windowModality()) view.show()
def gui_run( self, gui_context ): from camelot.view.register import register main_window = self.render( gui_context ) register( main_window, main_window ) main_window.show()