def __init__(self, parent): self.key_field = 'machine_id' list_prototype = [] list_prototype.append( TextLinePrototype('fullname', _('Name'), editable=False)) form_prototype = [ TextLinePrototype('fullname', _('Name'), nullable=False), OperationDefinitionPrototype( 'operation_definition_id', _('Operation'), operation_definition_cache.all_on_order_part(), nullable=False), BooleanPrototype('is_active', _('Active'), nullable=False), MachineZonePrototype('clock_zone', _('Zone'), nullable=True) ] super(EditMachinesDialog, self).__init__( parent, _("Machine edit"), _("Machines"), _("Detail"), Machine, list_prototype, form_prototype, 'fullname', index_builder=lambda o: text_search_normalize(o.fullname)) self.setMinimumWidth(800)
def __init__(self, parent): self.key_field = 'employee_id' user_class_prototype = [] user_class_prototype.append( TextLinePrototype('name', _('Name'), editable=False)) form_prototype = [ TextLinePrototype('name', _('Name'), nullable=False), RoleEditPrototype( 'roles', _('Roles'), ) ] super(EditUserClass, self).__init__( parent, _("User class edit"), _("User Class"), _("Detail"), UserClass, user_class_prototype, form_prototype, 'name', index_builder=lambda o: text_search_normalize(o.name)) self.setMinimumWidth(800)
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,parent): global dao super(EditDeliverySlipDialog,self).__init__(parent) title = _("Create delivery slip") self.setWindowTitle(title) top_layout = QVBoxLayout() self.title_widget = TitleWidget(title,self) top_layout.addWidget(self.title_widget) self.info_label = QLabel() self.info_label.setWordWrap(True) top_layout.addWidget(self.info_label) self.buttons = QDialogButtonBox() self.buttons.addButton( QDialogButtonBox.StandardButton.Cancel) self.buttons.addButton( QDialogButtonBox.Ok) order_part_prototype = [] order_part_prototype.append( TextLinePrototype('human_identifier',_('Part n.'),editable=False)) order_part_prototype.append( TextLinePrototype('description',_('Description'),editable=False)) order_part_prototype.append( IntegerNumberPrototype('qty',_('Qty plan.'),editable=False)) order_part_prototype.append( IntegerNumberPrototype('tex2',_('Qty so far'),editable=False)) order_part_prototype.append( IntegerNumberPrototype(None,_('Qty out now'),nullable=True)) self.qty_out_column = len(order_part_prototype) - 1 # order_part_prototype.append( IntegerNumberPrototype(None,_('Reglages'),nullable=True)) # order_part_prototype.append( IntegerNumberPrototype(None,_('Derogation'),nullable=True)) # order_part_prototype.append( IntegerNumberPrototype(None,_('Rebus'),nullable=True)) self.controller_part = PrototypeController(self, order_part_prototype,None,freeze_row_count=True) self.controller_part.view.horizontalHeader().setResizeMode(QHeaderView.ResizeToContents) self.controller_part.view.horizontalHeader().setResizeMode(1,QHeaderView.Stretch) self.controller_part.setModel(TrackingProxyModel(self,order_part_prototype)) self.close_order_checkbox = QCheckBox(_("Close the order")) top_layout.addWidget(self.controller_part.view) # self.time_tracks_view) # top_layout.addWidget(self._make_units_qaulifications_gui()) top_layout.addWidget(self.close_order_checkbox) top_layout.addWidget(self.buttons) self.setLayout(top_layout) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) sg = QDesktopWidget().screenGeometry() self.setMinimumWidth(0.5*sg.width()) self.setMinimumHeight(0.3*sg.height()) self.slip_id = None
def __init__(self,parent): table_prototype = [ TextLinePrototype('fullname',_('Name'),editable=False) ] form_prototype = [ TextLinePrototype('fullname',_('Name'),nullable=False), TextLinePrototype('phone',_('Phone'),nullable=True), TextLinePrototype('phone2',_('Phone 2'),nullable=True), TextLinePrototype('fax',_('Fax'),nullable=True), TextLinePrototype('email',_('E-Mail'),nullable=True), TextLinePrototype('address1',_('Address 1'),nullable=True), TextLinePrototype('address2','',nullable=True), TextLinePrototype('country',_('Country'),nullable=True), TextAreaPrototype('notes',_('Notes'),nullable=True)] super(EditSupplierDialog,self).__init__(parent,_("Edit supplier"),_("Suppliers"),_("Detail"), Supplier,table_prototype,form_prototype,'fullname',lambda s:s.indexed_fullname)
def __init__(self,parent): table_prototype = [] table_prototype.append( TextLinePrototype('fullname',_('Name'),editable=False)) form_prototype = [ TextLinePrototype('fullname',_('Name'),nullable=False), TextLinePrototype('phone',_('Phone'),nullable=True), TextLinePrototype('phone2',_('Phone 2'),nullable=True), TextLinePrototype('fax',_('Fax'),nullable=True), TextLinePrototype('email',_('E-Mail'),nullable=True), TextLinePrototype('address1',_('Address 1'),nullable=True), TextLinePrototype('address2','',nullable=True), TextLinePrototype('country',_('Country'),nullable=True), TextAreaPrototype('notes',_('Notes'),nullable=True), # customer id is an integer but no value must be None, not zero. # FIXME Ideally, I should not be using a textlineprototype for this... TextLinePrototype('customer_id',_('ID'),editable=False,empty_string_as_None=True)] super(EditCustomerDialog,self).__init__(parent,_("Edit customer"),_("Customers"),_("Detail"), Customer,table_prototype,form_prototype,'fullname',index_builder=lambda o:o.indexed_fullname)
def __init__(self, parent): self.key_field = 'operation_definition_id' table_prototype = [ TextLinePrototype('description', _('Description'), editable=False), TextLinePrototype('short_id', _('ID'), editable=False) ] form_prototype = [ TextLinePrototype('short_id', _('Short ID'), nullable=False), TextLinePrototype('description', _('Description'), nullable=False), BooleanPrototype('imputable', _('Imputable'), default=True, nullable=False), BooleanPrototype('on_order', _('On orders'), nullable=False), BooleanPrototype('on_operation', _('On operations'), default=True, nullable=False), OperationDefinitionPeriodsPrototype('periods', _('Periods'), editable=True) ] super(EditOperationDefinitionsDialog, self).__init__(parent, _("Edit operations"), _("All operations"), _("Operation"), OperationDefinition, table_prototype, form_prototype, OperationDefinition.description, lambda opdef: opdef.short_id + opdef.description) self.list_view.horizontalHeader().setStretchLastSection(False) self.list_view.horizontalHeader().setResizeMode(0, QHeaderView.Stretch) self.list_view.horizontalHeader().setResizeMode( 1, QHeaderView.ResizeToContents) self.setMinimumWidth(800)
def __init__(self,parent,dao): self.key_field = 'employee_id' employee_prototype = [] employee_prototype.append( TextLinePrototype('fullname',_('Name'),editable=False)) form_prototype = [ TextLinePrototype('fullname',_('Name'),nullable=False), PicturePrototype('image',_('Picture'),nullable=True), BooleanPrototype('is_active',_('Active'),nullable=False,default=True), TextLinePrototype('login',_('Login'),nullable=False), PasswordPrototype('password',_('Password')), RoleEditPrototype('roles',_('Roles'))] # super(EditEmployeeDialog,self).__init__(parent, # _("Employee edit"), # _("All employees"), # _("Employee data"), # employee_prototype, # form_prototype) super(EditEmployeeDialog,self).__init__(parent,_("Employee edit"),_("Employees"),_("Detail"), Employee,employee_prototype,form_prototype,'fullname',index_builder=lambda o:text_search_normalize(o.fullname)) self.setMinimumWidth(800)
def __init__(self, parent): global dao super(ChooseSupplierDialog, self).__init__(parent) title = _("Choose supplier") self.setWindowTitle(title) top_layout = QVBoxLayout() self.title_widget = TitleWidget(title, self) top_layout.addWidget(self.title_widget) self.supplier_plate_widget = SupplierContactDataWidget(self) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.StandardButton.Cancel) self.buttons.addButton(QDialogButtonBox.Ok) hlayout = QHBoxLayout() # suppliers = dao.supplier_dao.all_frozen() suppliers = generic_load_all_frozen(Supplier, Supplier.fullname) table_prototype = [ TextLinePrototype('fullname', _('Name'), editable=False) ] self.filter_view = QuickPrototypedFilter(table_prototype, self) self.filter_view.selected_object_changed.connect( self.supplier_plate_widget.set_contact_data) self.filter_view.set_data(suppliers, lambda c: c.indexed_fullname) hlayout.addWidget(self.filter_view) hlayout.addWidget(self.supplier_plate_widget, 1000) # hlayout.addStretch() top_layout.addLayout(hlayout) #top_layout.addStretch() top_layout.addWidget(self.buttons) self.setLayout(top_layout) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) self.filter_view.list_view.doubleClicked.connect(self._item_selected)
def __init__(self,parent): super(DeliverySlipPanel,self).__init__(parent) title = _("Delivery slips") self.slip_data = None self.set_panel_title(_("Delivery slip overview")) self.reprint_delivery_slip = QAction(_("Reprint delivery slip"),self) # , parent self.reprint_delivery_slip.triggered.connect( self.reprint) # self.reprint_delivery_slip.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_V)) self.reprint_delivery_slip.setShortcutContext(Qt.WidgetWithChildrenShortcut) # self.controller_operation.view.addAction(self.reprint_delivery_slip) self.desactivate_delivery_slip = QAction(_("Desactivate delivery slip"),self) # , parent self.desactivate_delivery_slip.triggered.connect( self.desactivate) self.desactivate_delivery_slip.setShortcutContext(Qt.WidgetWithChildrenShortcut) self.activate_delivery_slip = QAction(_("Activate delivery slip"),self) # , parent self.activate_delivery_slip.triggered.connect( self.activate) self.activate_delivery_slip.setShortcutContext(Qt.WidgetWithChildrenShortcut) self.delete_delivery_slip = QAction(_("Delete delivery slip"),self) # , parent self.delete_delivery_slip.triggered.connect( self.delete) self.delete_delivery_slip.setShortcutContext(Qt.WidgetWithChildrenShortcut) filter_family = FilterQuery.DELIVERY_SLIPS_FAMILY self.filter_widget = PersistentFilter( filter_family, suggestion_finder) self.filter_widget.apply_filter.connect(self.apply_filter_slot) self.filter_widget.hide() navigation = NavBar( self, [ (self.filter_widget.get_filters_combo(), None), (_("Edit filter"),self._toggle_edit_filters), (_("Action"),self.show_actions) ] ) self.title_widget = TitleWidget(title, self, navigation) # navigation) self.action_menu = QMenu(navigation.buttons[0]) list_actions = [ (self.reprint_delivery_slip,None), (self.activate_delivery_slip,None), (self.desactivate_delivery_slip,None), # (self.delete_delivery_slip,None) ] populate_menu(self.action_menu, self, list_actions, context=Qt.WidgetWithChildrenShortcut) # self.setWindowTitle(title) top_layout = QVBoxLayout(self) # self.filter_line_edit = QLineEdit() # self.filter_line_edit = QueryLineEdit(suggestion_finder) initialize_customer_cache() # FIXME Not the place to do that # filter_family = 'delivery_slips' # self.filter_name = FiltersCombo(self, filter_family) # filter_widget = PersistentFilter(filter_family, self.filter_name) # filter_widget.apply_filter.connect(self.apply_filter_slot) self.proto = [] self.proto.append( IntegerNumberPrototype('delivery_slip_id',_("Slip Nr"), editable=False)) self.proto.append( DatePrototype('creation',_('Date'), editable=False)) self.proto.append( TextLinePrototype('fullname',_('Customer'), editable=False)) self.proto.append( TextLinePrototype('user_label',_('Order'), editable=False)) self.search_results_model = DeliverySlipPanelModel(self.proto, self) self.search_results_view = PrototypedQuickView(self.proto, self) self.search_results_view.setModel(self.search_results_model) self.search_results_view.verticalHeader().hide() self.search_results_view.horizontalHeader().setResizeMode(1, QHeaderView.ResizeToContents) self.search_results_view.horizontalHeader().setResizeMode(2, QHeaderView.Stretch) self.search_results_view.horizontalHeader().setSortIndicatorShown(True) self.search_results_view.horizontalHeader().setSortIndicator(0,Qt.AscendingOrder) self.search_results_view.horizontalHeader().sectionClicked.connect(self._section_clicked) self.search_results_view.setSelectionBehavior(QAbstractItemView.SelectRows) self.search_results_view.setSelectionMode(QAbstractItemView.SingleSelection) self.search_results_view.selectionModel().currentRowChanged.connect(self.row_selected) self.slip_part_view = DeliverySlipViewWidget(self) hlayout_results = QHBoxLayout() # w = SubFrame(_("Delivery slips"),self.search_results_view,None) hlayout_results.addWidget(self.search_results_view) w = SubFrame(_("Detail"),self.slip_part_view,None) hlayout_results.addWidget(w) top_layout.addWidget(self.title_widget) top_layout.addWidget(self.filter_widget) top_layout.addLayout(hlayout_results) top_layout.setStretch(2,100) self.setLayout(top_layout) self.filter_widget.load_last_filter( configuration)
def load_order_for_item(stock_item): parts = session().query(SupplyOrderPart).filter( SupplyOrderPart.stock_item == stock_item).all() list_supply_order_parts.show(parts) list.selectionChanged.connect(load_order_for_item) layout = hlayout(list_item, detail_item) # ensuite on voudrait un moyen de filtrer # L'utilisateur voit sa liste et il veut la filtrer. Il ne pense pas en # terme de requête DB prototype = [ TextLinePrototype('stock_code', _("Item Nr"), editable=False), 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)
class TemplatesCollectionWidget(DocumentCollectionWidget): prototype = PrototypeArray([ FilenamePrototype('filename', _("Filename")), TextLinePrototype('description', _("Description"), editable=True), TextLinePrototype('reference', _("Horse Ref."), editable=False), EmptyPrototype(_("Actions")) ]) def __init__(self, parent=None, doc_service=None): super(TemplatesCollectionWidget, self).__init__(parent, doc_service, used_category_short_name=None, prototype=self.prototype) def categories(self): return [] def _apply_pending_changes(self): """ As the edit widget delays its modification, we have to add a function that will commit the modifications ASAP. I do it this way so that all the modification management is done at the same place. :return: """ actions = self.model.export_objects_as_actions() for action_type, document, op_ndx in actions: if action_type == DBObjectActionTypes.TO_DELETE: remove_document(document.document_id) elif action_type == DBObjectActionTypes.TO_CREATE: pass # Creation is done directly elif action_type == DBObjectActionTypes.TO_UPDATE: self.documents_service.update_name_and_description( document.document_id, document.filename, document.description) self.refresh_templates_list() def refresh_templates_list(self): documents = sorted(list(self.documents_service.all_templates()), key=lambda d: (("B" if d.reference else "A") + d.filename)) self.model.load_documents(documents) @Slot(QModelIndex, QModelIndex) def _data_edited(self, top_left, bottom_right): super(TemplatesCollectionWidget, self)._data_edited(top_left, bottom_right) if self.track_edits: self._apply_pending_changes() @Slot() def model_reset(self): mainlog.debug("model reset") for row in range(self.model.rowCount()): self._set_widget_buttons(row) # Make the buttons as small as possible self.view.resizeColumnToContents(self.model.columnCount() - 1) self.view.resizeRowsToContents() self.view.horizontalHeader().setResizeMode(0, QHeaderView.Stretch) self.view.horizontalHeader().setResizeMode(1, QHeaderView.Stretch) self.view.resizeColumnToContents(3) self.view.resizeColumnToContents(2) @Slot() def delete_remote_clicked(self, button_id): doc_id = self.button_data[button_id] doc = self.model.locate_object(lambda obj: obj.document_id == doc_id) if doc.reference and \ not confirmationBox(_("Confirmation for deleting reference template"), _("You're about to delete a reference template document. These documents are used by some parts of this program. Deleting them will break those parts. So you should immediately upload another template with the same reference. OK to proceed ?")): return elif not confirmationBox( _("Deleting a template"), _("Are you sure you want to remove {}").format(doc.filename)): return try: self.model.delete_document(doc) self._apply_pending_changes() except Exception as ex: showErrorBox(_("There was an error while deleting a document"), ex=ex) def _add_file(self, full_path_client): """ Adds a file to the templates. First it is uploaded and then it is added to the list of files. """ if self._test_file_access(full_path_client): progress_bar = make_progress(_("Uploading"), 100) def progress_tracker(percent): progress_bar.setValue(int(percent)) try: doc_id = upload_template(full_path_client, progress_tracker, 0) except Exception as exc: progress_bar.close() showErrorBox(_( "There was a problem while uploading the file {} to the server" ).format(os.path.basename(full_path_client)), ex=exc, object_name="file_upload_error") return self.refresh_templates_list() def _replace_file(self, full_path_client, document): if self._test_file_access(full_path_client): progress_bar = make_progress(_("Replacing"), 100) def progress_tracker(percent): progress_bar.setValue(int(percent)) try: doc_id = upload_template(full_path_client, progress_tracker, document.document_id) self.refresh_templates_list() except Exception as exc: progress_bar.close() showErrorBox(_( "There was a problem while uploading the file to the server" ), ex=exc, object_name="file_upload_error") return #def dropEvent(self, e): def animated_drop_event_handler(self, e, selected_drop_zone): if len(e.mimeData().urls()) > 1: return super(TemplatesCollectionWidgetDialog, self).dropEvent(e) elif len(e.mimeData().urls()) == 1: # Pay attention, the vent we got here is tied to the view, not to this # widget. So mapToGlobal has to be called on the view too... z = self.view.viewport().mapFromGlobal( self.view.mapToGlobal(e.pos())) drop_row = self.view.rowAt(z.y()) # mainlog.debug("mapped y {} -> {} -> {}".format(e.pos().y(), glo.y(), z.y())) mainlog.debug("row at {} for y {}".format(drop_row, z.y())) full_path_client = e.mimeData().urls()[0].toString().replace( 'file:///', '') if drop_row == -1: mainlog.debug("Adding a template on drag/drop event") self._add_file(full_path_client) else: document = self.model.object_at(drop_row) # button_id = self.model.index( drop_row,0 ).data(Qt.UserRole + 1) # doc_id, dummy_path, file_size, description = self.button_data[button_id] # mainlog.debug("Replacing {} with doc_id={}".format( full_path_client, document.document_id)) if document.reference: if not confirmationBox( _("Replacing a Horse reference document"), _("You're about to replace a reference document ({}, {}). " "This can potentially break the program. You should make " "a copy of the current version of that document before " "proceeding. Do you still want to go on ?"). format(document.description, document.reference)): return self._replace_file(full_path_client, document)
def __init__(self, dao, parent, edit_date): super(EditTaskActionReportsDialog, self).__init__(parent) title = _("Task actions records") self.setWindowTitle(title) self.dao = dao top_layout = QVBoxLayout() self.title_widget = TitleWidget(title, self) top_layout.addWidget(self.title_widget) hlayout = QHBoxLayout() self.timesheet_info_label = QLabel("Name", self) hlayout.addWidget(self.timesheet_info_label) hlayout.addStretch() top_layout.addLayout(hlayout) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.StandardButton.Cancel) self.buttons.addButton(QDialogButtonBox.Ok) prototype = [] # prototype.append( EmployeePrototype('reporter', _('Description'), dao.employee_dao.all())) prototype.append( OrderPartOnTaskPrototype(None, _('Order Part'), editable=True, nullable=True)) # BUG today is wrong... Must be the imputation date self.task_on_orderpart_prototype = TaskOnOrderPartPrototype( 'task', _('Task'), on_date=date.today(), editable=True, nullable=True) prototype.append(self.task_on_orderpart_prototype) prototype.append( TaskActionTypePrototype('kind', _('Action'), editable=True, nullable=False)) prototype.append( TimestampPrototype('time', _('Hour'), editable=True, nullable=False, fix_date=edit_date)) prototype.append( TimestampPrototype('report_time', _('Recorded at'), editable=False)) prototype.append( TextLinePrototype('origin_location', _('Origin'), editable=False)) prototype.append( TextLinePrototype('editor', _('Editor'), editable=False, default='master')) self.controller = PrototypeController(self, prototype) self.controller.setModel(TrackingProxyModel(self, prototype)) self.controller.view.enable_edit_panel() top_layout.addWidget(self.controller.view) # self.time_tracks_view) top_layout.addWidget(self.buttons) self.setLayout(top_layout) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject)
def __init__(self,parent): super(TimeTracksOverviewWidget,self).__init__(parent) self.base_date = date.today() headers = QStandardItemModel(1, 31 + 1) headers.setHeaderData(0, Qt.Orientation.Horizontal, _("Employee")) for i in range(31): headers.setHeaderData(i+1, Qt.Orientation.Horizontal, "{}".format(i+1)) self._table_model = QStandardItemModel(1, 31+1, None) self.headers_view = QHeaderView(Qt.Orientation.Horizontal,self) self.header_model = headers self.headers_view.setResizeMode(QHeaderView.ResizeToContents) self.headers_view.setModel(self.header_model) # qt's doc : The view does *not* take ownership self.table_view = QTableView(None) self.table_view.setModel(self._table_model) self.table_view.setHorizontalHeader(self.headers_view) self.table_view.verticalHeader().hide() self.table_view.setAlternatingRowColors(True) # self.table_view.setSelectionBehavior(QAbstractItemView.SelectRows) self.table_view.setEditTriggers(QAbstractItemView.NoEditTriggers) navbar = NavBar(self, [ (_("Month before"), self.month_before), (_("Today"),self.month_today), (_("Month after"), self.month_after)]) self.title_box = TitleWidget(_("Time Records Overview"),self,navbar) self.vlayout = QVBoxLayout(self) self.vlayout.setObjectName("Vlayout") self.vlayout.addWidget(self.title_box) self.setLayout(self.vlayout) self.hours_per_pers_subframe = SubFrame(_("Hours worked per person"), self.table_view, self) self.vlayout.addWidget(self.hours_per_pers_subframe) hlayout = QHBoxLayout() prototype = [] prototype.append( OrderPartOnTaskPrototype(None, _('Order Part'))) prototype.append( TaskOnOrderPartPrototype('task', _('Task'),on_date=date.today())) prototype.append( DurationPrototype('duration',_('Duration'))) prototype.append( TimestampPrototype('start_time',_('Start time'),fix_date=date.today())) prototype.append( DatePrototype('encoding_date',_('Recorded at'),editable=False)) self.controller = PrototypeController(self,prototype) self.controller.setModel(TrackingProxyModel(self,prototype)) self.controller.view.setColumnWidth(1,300) self.controller.view.horizontalHeader().setResizeMode(QHeaderView.ResizeToContents) self.controller.view.horizontalHeader().setResizeMode(1,QHeaderView.Stretch) navbar = NavBar(self, [ (_("Edit"), self.edit_timetrack_no_ndx)]) self.hours_on_day_subframe = SubFrame(_("Total times on day"), self.controller.view, self,navbar) hlayout.addWidget(self.hours_on_day_subframe) prototype = [] # prototype.append( EmployeePrototype('reporter', _('Description'), dao.employee_dao.all())) prototype.append( TaskDisplayPrototype('task', _('Task'))) self.pointage_timestamp_prototype = TimestampPrototype('time',_('Hour'),editable=False,fix_date=date.today()) prototype.append( self.pointage_timestamp_prototype) prototype.append( TaskActionTypePrototype('kind',_('Action'))) prototype.append( TextLinePrototype('origin_location',_('Origin'))) prototype.append( TextLinePrototype('editor',_('Editor'),editable=False,default='master')) self.controller_actions = PrototypeController(self,prototype) self.controller_actions.setModel(ActionReportModel(self,prototype)) navbar = NavBar(self, [ (_("Edit"), self.editTaskActionReports)]) hlayout.addWidget(SubFrame(_("Time records"),self.controller_actions.view,self,navbar)) self.controller_actions.view.setEditTriggers(QAbstractItemView.NoEditTriggers) self.controller_actions.view.doubleClicked.connect(self.editTaskActionReports) self.controller_actions.view.horizontalHeader().setResizeMode(0,QHeaderView.Stretch) self.controller_actions.view.horizontalHeader().setResizeMode(3,QHeaderView.ResizeToContents) self.controller_actions.view.horizontalHeader().setResizeMode(4,QHeaderView.ResizeToContents) self.vlayout.addLayout(hlayout) self.vlayout.setStretch(0,0) self.vlayout.setStretch(1,300) self.vlayout.setStretch(2,200) # self.table_view.setSelectionBehavior(QAbstractItemView.SelectRows) #self.table_view.entered.connect(self.cell_entered) self.table_view.selectionModel().currentChanged.connect(self.cell_entered) self.table_view.doubleClicked.connect(self.edit_timetrack) self.controller.view.selectionModel().currentChanged.connect(self.timetrack_changed) self.controller.view.setEditTriggers(QAbstractItemView.NoEditTriggers) self.refresh_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)