def __init__(self,parent=None): super(DeliverySlipViewWidget,self).__init__(parent) self.delivery_slip_part_proto = [] # self.delivery_slip_part_proto.append( OrderPartDisplayPrototype('order_part',_('Part'), editable=False)) self.delivery_slip_part_proto.append( TextLinePrototype('part_label',_('Part'), editable=False)) self.delivery_slip_part_proto.append( TextLinePrototype('description',_('Description'), editable=False)) self.delivery_slip_part_proto.append( IntegerNumberPrototype('quantity_out',_('Q. out'), editable=False)) # self.controller_operation = PrototypeController(self, # self.delivery_slip_part_proto, # ProxyTableView(None,self.delivery_slip_part_proto)) # # self.controller_operation.view.verticalHeader().hide() # self.controller_operation.setModel(TrackingProxyModel(self,self.delivery_slip_part_proto)) self.model = PrototypedModelView(self.delivery_slip_part_proto, self) self.view = PrototypedQuickView(self.delivery_slip_part_proto, self) self.view.setModel(self.model) self.view.horizontalHeader().setResizeMode(QHeaderView.ResizeToContents) # Description column wide enough self.view.horizontalHeader().setResizeMode(1,QHeaderView.Stretch) self.view.verticalHeader().hide() layout = QHBoxLayout() layout.setContentsMargins(0,0,0,0) # layout.addWidget(self.controller_operation.view) layout.addWidget(self.view) self.setLayout(layout)
def __init__(self, table_prototype, parent): super(QuickPrototypedFilter, self).__init__(parent) self.list_model = PrototypedModelView(table_prototype, self) self.list_model_filtered = FilteringModel(self) self.list_model_filtered.setSourceModel(self.list_model) self.line_in = FilterLineEdit() self.line_in.key_down.connect(self._focus_on_list) self.line_in.textChanged.connect(self._filter_changed) self.list_view = PrototypedQuickView(table_prototype, self) self.list_view.setTabKeyNavigation(False) self.list_view.horizontalHeader().hide() self.list_view.verticalHeader().hide() self.list_view.horizontalHeader().setStretchLastSection(True) self.list_view.setModel(self.list_model_filtered) vlayout = QVBoxLayout() vlayout.setContentsMargins(0, 0, 0, 0) vlayout.addWidget(self.line_in) vlayout.addWidget(self.list_view) self.setLayout(vlayout) self.list_view.selectionModel().currentChanged.connect( self._selected_item_changed) # FIXME Clear ownership issue self.last_selected_object = None self.line_in.setFocus() QWidget.setTabOrder(self.line_in, self.list_view)
def __init__(self,parent=None): super(OperationsOverviewWidget,self).__init__(parent) self.operation_prototype = [] self.operation_prototype.append( OperationDefinitionPrototype('operation_definition_id',_('Op.'),operation_definition_cache.all_on_order_part(), editable=False)) self.operation_prototype.append( TextAreaPrototype('description',_('Description'),nullable=True,editable=False)) self.operation_prototype.append( FloatNumberPrototype('value',_('Value'),nullable=True,editable=False)) self.operation_prototype.append( DurationPrototype('planned_hours',_('Planned time'),nullable=True,editable=False)) # operation_prototype.append( DurationPrototype('t_reel',_('Used time'),nullable=False,editable=False)) self.operation_prototype.append( DurationPrototype('done_hours',_('Imputations'),editable=False)) # operation_prototype.append( TextLinePrototype('note',_('Note'),editable=True,nullable=True,hidden=True)) self.model = PrototypedModelView(self.operation_prototype,self) self.view = PrototypedQuickView(self.operation_prototype,self) self.view.setModel(self.model) self.view.verticalHeader().hide() self.view.horizontalHeader().setResizeMode(QHeaderView.ResizeToContents) # Description column wide enough self.view.horizontalHeader().setResizeMode(1,QHeaderView.Stretch) self.view.setWordWrap(True) self.view.setSelectionBehavior(QAbstractItemView.SelectRows) self.view.setSelectionMode(QAbstractItemView.ExtendedSelection) # self.controller_operation = PrototypeController(self, # self.operation_prototype, # ProxyTableView(None,self.operation_prototype)) # self.controller_operation.view.verticalHeader().hide() # # self.controller_operation.setModel(TrackingProxyModel(None,operation_prototype)) # self.controller_operation.setModel(TrackingProxyModel(self,self.operation_prototype)) # self.controller_operation.view.horizontalHeader().setResizeMode(QHeaderView.ResizeToContents) # Description column wide enough # self.controller_operation.view.horizontalHeader().setResizeMode(1,QHeaderView.Stretch) # self.controller_operation.view.setSelectionBehavior(QAbstractItemView.SelectRows) layout = QHBoxLayout() layout.setContentsMargins(0,0,0,0) layout.addWidget(self.view) self.setLayout(layout) self.copy_operations_action = QAction(_("Copy operations"),self.view) self.copy_operations_action.triggered.connect( self.copy_operations_slot) self.copy_operations_action.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_C)) self.copy_operations_action.setShortcutContext(Qt.WidgetWithChildrenShortcut) self.view.addAction(self.copy_operations_action)
TextLinePrototype('fullname', _('Fullname'), editable=False) ] filter = PersistentFilter(QueryLineEdit(), 'supply_orders_overview') service = None def apply_filter(f): if f == '12134': objects = service.findByCode(f) model.loadObjects(objects) else: objects = service.findByQueryString(f) model.loadObjects(objects) filter.activated.connect(apply_filter) model = PrototypedModelView(prototype, None) list_view = PrototypedQuickView(prototype, None) detail_view = None layout = hlayout(SubFrame("Stock items", vlayout(filter, list_view), None), SubFrame("Details", detail_view, None)) w = QWidget() w.setLayout(l) w.show() app.exec_()
def __init__(self,parent,dialog_title,list_title,form_title,mapped_klass,table_prototype,form_prototype,sort_criterion,index_builder): """ sort_criterion is a SQLAlchemy colum used when querying the list of edited objects to sort it. index_builder : a function that takes an object of the mapped class and returns a string suitable for index building. """ super(MetaFormDialog,self).__init__(parent) self.index_builder = index_builder self.sort_criterion = sort_criterion self.form_prototype = form_prototype self.mapped_klass = mapped_klass # Locate the primary key # this will work only with a one-field PK pk_column = list(filter( lambda c:c.primary_key, self.mapped_klass.__table__.columns))[0] self.key_field = pk_column.name self.in_save = False # The current item is the one currently shown in the # form. If it's None, then the form contains data # for a soon-to-be created item. Else, it's a frozen # copy. Since we work on frozen stuff, we can carry # the object around safely self.current_item = None self.list_model = PrototypedModelView(table_prototype, self) self.list_model_filtered = FilteringModel(self) self.list_model_filtered.setSourceModel(self.list_model) self.line_in = FilterLineEdit() self.line_in.key_down.connect(self._focus_on_list) self.line_in.textChanged.connect(self._filter_changed) self.list_view = PrototypedQuickView(table_prototype, self) self.list_view.setTabKeyNavigation(False) self.setWindowTitle(dialog_title) self.title_widget = TitleWidget(dialog_title,self) self.list_view.setModel(self.list_model_filtered) self.list_view.horizontalHeader().hide() self.list_view.verticalHeader().hide() self.list_view.horizontalHeader().setStretchLastSection(True) blayout = QVBoxLayout() b = QPushButton(_("New")) b.setObjectName("newButton") b.clicked.connect(self.create_action) blayout.addWidget(b) b = QPushButton(_("Save")) b.setObjectName("saveButton") b.clicked.connect(self.save_action) blayout.addWidget(b) b = QPushButton(_("Delete")) b.setObjectName("deleteButton") b.clicked.connect(self.delete_action) blayout.addWidget(b) blayout.addStretch() self.buttons = QDialogButtonBox() self.buttons.addButton( QDialogButtonBox.Ok) # BUG According to QLayout, the layout takes ownership of the widget # therefore, we have to pay attention when deleting... form_layout = QFormLayout() for p in self.form_prototype: w = p.edit_widget(self) w.setEnabled(p.is_editable) w.setObjectName("form_" + p.field) form_layout.addRow( p.title, w) top_layout = QVBoxLayout() top_layout.addWidget(self.title_widget) hl = QHBoxLayout() vlayout = QVBoxLayout() vlayout.addWidget(self.line_in) vlayout.addWidget(self.list_view) # gbox = QGroupBox(list_title,self) # gbox.setLayout(vlayout) gbox = SubFrame(list_title,vlayout,self) hl.addWidget(gbox) # gbox = QGroupBox(form_title,self) # gbox.setLayout(form_layout) gbox = SubFrame(form_title,form_layout,self) hl.addWidget(gbox) hl.addLayout(blayout) # hl.setStretch(0,0.3) # hl.setStretch(1,0.7) # hl.setStretch(2,0) top_layout.addLayout(hl) top_layout.addWidget(self.buttons) self.setLayout(top_layout) # QWidget takes ownership of the layout self.buttons.accepted.connect(self.reject) QWidget.setTabOrder(self.line_in, self.list_view) nb_objs = self._refresh_list() self.line_in.setFocus() self.list_view.selectionModel().currentChanged.connect(self.selected_item_changed) # FIXME Clear ownership issue if nb_objs > 0: self.list_view.selectRow(0) else: # Special case to automaticaly enter creation mode when # the list is empty self.create_action()
def __init__(self, parent): super(SupplyOrderOverview, self).__init__(parent) initialize_supplier_cache() self.set_panel_title(_("Supply Orders")) # navigation = NavBar( self, # [ (_("Action"),self.show_actions) ] ) # self.action_menu = QMenu(navigation.buttons[0]) title = _("Supply orders") # self.setWindowTitle(title) filter_family = FilterQuery.SUPPLIER_ORDER_SLIPS_FAMILY self.filter_widget = PersistentFilter(filter_family) self.filter_widget.apply_filter.connect(self._apply_filter) self.filter_widget.hide() self.proto = [] self.proto.append( TextLinePrototype('human_identifier', _("Part Nr"), editable=False)) self.proto.append( TextLinePrototype('supplier_fullname', _('Supplier'), editable=False)) self.proto.append( DatePrototype('expected_delivery_date', _('Deadline'), editable=True, nullable=False)) self.proto.append( TextLinePrototype('description', _('Description'), editable=True, nullable=False)) self.proto.append( FloatNumberPrototype('quantity', _('Quantity'), editable=True, nullable=False)) self.proto.append( FloatNumberPrototype('unit_price', _('Unit price'), editable=True, nullable=False)) self.proto.append( DatePrototype('creation_date', _('Creation date'), editable=False, nullable=False)) # self.proto.append( DatePrototype('creation_date',_('Creation'), editable=False)) # self.proto.append( DatePrototype('expected_delivery_date',_('Expected\ndelivery'), editable=False)) # self.proto.append( TextLinePrototype('supplier_fullname',_('Supplier'), editable=False)) self.search_results_model = PrototypedModelView(self.proto, self) self.search_results_view = PrototypedQuickView(self.proto, self) self.search_results_view.setModel(self.search_results_model) self.search_results_view.horizontalHeader().setSortIndicatorShown(True) self.search_results_view.verticalHeader().hide() self.search_results_view.verticalHeader().setResizeMode( QHeaderView.ResizeToContents) self.search_results_view.doubleClicked.connect( self._supply_order_double_clicked) self.search_results_view.activated.connect( self._supply_order_double_clicked) self.search_results_view.horizontalHeader().sectionClicked.connect( self.section_clicked) top_layout = QVBoxLayout(self) navigation = NavBar(self, [(self.filter_widget.get_filters_combo(), None), (_("Edit filter"), self._toggle_edit_filters)]) self.title_widget = TitleWidget(title, self, navigation) # navigation) hlayout_results = QHBoxLayout() # w = SubFrame(_("Supply order parts"),self.search_results_view,None) hlayout_results.addWidget(self.search_results_view) w = SubFrame(_("Supply order detail"), self._make_supply_order_detail_view(), None) hlayout_results.addWidget(w) hlayout_results.setStretch(0, 2) hlayout_results.setStretch(0, 1) top_layout.addWidget(self.title_widget) top_layout.addWidget(self.filter_widget) top_layout.addLayout(hlayout_results) top_layout.setStretch(3, 100) self.setLayout(top_layout) self.search_results_view.setSelectionBehavior( QAbstractItemView.SelectRows) self.search_results_view.setSelectionMode( QAbstractItemView.SingleSelection) # self.search_results_view.activated.connect(self.row_activated) self.search_results_view.selectionModel().currentRowChanged.connect( self.row_selected) # self.detail_view.doubleClicked.connect(self._supply_order_double_clicked) # pub.subscribe(self.refresh_panel, 'supply_order.changed') # pub.subscribe(self.refresh_panel, 'supply_order.deleted') # self.filter_widget.select_default_filter() self.filter_widget.load_last_filter(configuration)