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, dao, day): super(EditTimeTracksDialog, self).__init__(parent) self.edit_date = day title = _("Time spent on tasks") self.setWindowTitle(title) 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) info = QLabel( _("On the table below you can have two kinds of line. The grey line which shows the time spent on a task computed on the basis of the actual time recordings. Since those are computed automaticaly, you can't change them. The other lines in black, are those that you will encode have encoded yourself. They represent hours to add or remove to those of the grey lines. So, for example, if you want to remove 3 hours on a task, you encode the task with a duration of three hours." ), self) info.setWordWrap(True) top_layout.addWidget(info) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.StandardButton.Cancel) self.buttons.addButton(QDialogButtonBox.Ok) if dao.task_dao.tasks_count() > 0: prototype = [] prototype.append( ImputableSelectorPrototype(None, _('Order Part'), nullable=True)) # BUG today is wrong... Must be the imputation date self.task_on_orderpart_prototype = ProxyTaskComboPrototype( 'task', _('Task'), on_date=date.today(), editable=True, nullable=False) prototype.append(self.task_on_orderpart_prototype) prototype.append( DurationPrototype('duration', _('Duration'), format_as_float=False)) prototype.append( ConstrainedMachineSelectorPrototype('machine_id', _('Machine'), nullable=True)) # prototype.append( TimestampPrototype('start_time',_('Start time'),fix_date=day,nullable=True,editable=True)) # prototype.append( TimestampPrototype('encoding_date',_('Recorded at'),editable=False)) self.controller = PrototypeController(self, prototype) self.controller.setModel(TrackingProxyModel(self, prototype)) self.controller.view.horizontalHeader().setResizeMode( 1, QHeaderView.Stretch) self.controller.view.enable_edit_panel() self.controller.model.rowsInserted.connect(self.data_changed_slot) self.controller.model.rowsRemoved.connect(self.data_changed_slot) self.controller.model.dataChanged.connect(self.data_changed_slot) # self.employee_select = QComboBox() # self.employee_select.setModel(self.dao.employee_dao.list_model()) # self.employee_select.setCurrentIndex(0) # self.set_on_selected_employee() # top_layout.addWidget(self.employee_select) top_layout.addWidget( self.controller.view) # self.time_tracks_view) hlayout = QHBoxLayout() self.sum_hours_label = QLabel("12345") self.sum_hours_label.setObjectName("important") # Used for CSS hlayout.addStretch() hlayout.addWidget(QLabel(_("Sum of durations"))) hlayout.addWidget(self.sum_hours_label) top_layout.addLayout(hlayout) top_layout.addWidget(self.buttons) self.setLayout(top_layout) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) # self.employee_select.activated.connect(self.employee_changed) self.resize(800, 400) self.setSizeGripEnabled(True) else: top_layout.addWidget( QLabel( "There are no task in the system " + "for you to report on. Create some " + "tasks first", self)) top_layout.addWidget(self.buttons) self.setLayout(top_layout) self.buttons.accepted.connect(self.accept_direct) self.buttons.rejected.connect(self.reject)
def __init__(self, parent): super(EditSupplyOrderPanel, self).__init__(parent) self.current_supply_order_id = None self.proto = [] self.proto.append( TextAreaPrototype('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=True)) self.delivery_date_prototype = FutureDatePrototype('description', ('Description'), editable=True, nullable=False) self.model = SupplyOrderPartsModel(self, self.proto) self.controller_part = PrototypeController( self, self.proto, ProxyTableView(None, self.proto)) self.controller_part.setModel(self.model) # self.controller_part.view.verticalHeader().hide() self.controller_part.view.horizontalHeader().setResizeMode( 0, QHeaderView.Stretch) self.print_supply_order_action = QAction(_("Print supply order"), self) # , parent self.print_supply_order_action.triggered.connect( self.print_supply_order) self.print_supply_order_action.setShortcut( QKeySequence(Qt.CTRL + Qt.Key_P)) self.print_supply_order_action.setShortcutContext( Qt.WidgetWithChildrenShortcut) self.addAction(self.print_supply_order_action) self.save_supply_order_action = QAction(_("Save supply order"), self) # , parent self.save_supply_order_action.triggered.connect(self.save) self.save_supply_order_action.setShortcut( QKeySequence(Qt.CTRL + Qt.Key_S)) self.save_supply_order_action.setShortcutContext( Qt.WidgetWithChildrenShortcut) self.addAction(self.save_supply_order_action) self.delete_supply_order_action = QAction(_("Deactivate supply order"), self) # , parent self.delete_supply_order_action.triggered.connect(self.delete) self.addAction(self.delete_supply_order_action) self.next_order_for_supplier_action = QAction( _("Next supplier's order"), self) # , parent self.next_order_for_supplier_action.setShortcut( QKeySequence(Qt.CTRL + Qt.Key_PageDown)) self.next_order_for_supplier_action.setShortcutContext( Qt.WidgetWithChildrenShortcut) self.next_order_for_supplier_action.triggered.connect( self.next_order_for_supplier) self.addAction(self.next_order_for_supplier_action) self.previous_order_for_supplier_action = QAction( _("Previous supplier's order"), self) # , parent self.previous_order_for_supplier_action.setShortcut( QKeySequence(Qt.CTRL + Qt.Key_PageDown)) self.previous_order_for_supplier_action.setShortcutContext( Qt.WidgetWithChildrenShortcut) self.previous_order_for_supplier_action.triggered.connect( self.next_order_for_supplier) self.addAction(self.previous_order_for_supplier_action) self.change_supplier_action = QAction(_("Change supplier"), self) # , parent self.change_supplier_action.triggered.connect(self.change_supplier) self.addAction(self.change_supplier_action) # self.controller_operation.view.addAction(self.reprint_delivery_slip) self.controller_part.view.addAction(self.print_supply_order_action) self.controller_part.view.addAction(self.save_supply_order_action) self.controller_part.view.addAction(self.delete_supply_order_action) navigation = NavBar(self, [(self.next_order_for_supplier_action.text(), self.next_order_for_supplier), (self.previous_order_for_supplier_action.text(), self.previous_order_for_supplier), (_("Action"), self.show_actions)]) navigation.buttons[2].setObjectName("specialMenuButton") self.action_menu = QMenu(navigation.buttons[2]) list_actions = [(self.print_supply_order_action, None), (self.save_supply_order_action, None), (self.delete_supply_order_action, None), (self.change_supplier_action, None)] populate_menu(self.action_menu, self, list_actions, context=Qt.WidgetWithChildrenShortcut) self.title_widget = TitleWidget(_("Supply order"), self, navigation) self.supplier_plate_widget = SupplierPlateWidget(self) self.edit_comment_widget = DescribedTextEdit(_("Comments")) self.edit_comment_widget.setMinimumHeight(20) self.edit_comment_widget.setMinimumWidth(600) self.edit_comment_widget.setMaximumHeight(60) self.edit_comment_widget.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) self.supplier_reference_widget = QLineEdit() self.delivery_date_widget = DateEntryWidget() self.delivery_date_widget.setMaximumWidth(100) self.creation_date_widget = QLabel() self.in_title_label = QLabel() top_layout1 = QHBoxLayout() top_layout1.addWidget(self.in_title_label) top_layout1.addStretch() top_layout1.addWidget(self.supplier_plate_widget) hlayout = QHBoxLayout() hlayout.addWidget(QLabel(_("Delivery date"))) hlayout.addWidget(self.delivery_date_widget) hlayout.addStretch() hlayout3 = QHBoxLayout() hlayout3.addWidget(QLabel(_("Creation date"))) hlayout3.addWidget(self.creation_date_widget) hlayout3.addStretch() hlayout2 = QHBoxLayout() hlayout2.addWidget(QLabel(_("Supplier's reference"))) hlayout2.addWidget(self.supplier_reference_widget) hlayout2.addStretch() vlayout = QVBoxLayout() vlayout.addLayout(hlayout) # delivery date vlayout.addLayout(hlayout3) # creation date vlayout.addLayout(hlayout2) # reference vlayout.addStretch() top_layout2 = QHBoxLayout() top_layout2.addLayout(vlayout) top_layout2.addWidget(self.edit_comment_widget) top_layout2.addStretch() top_layout2.setStretch(0, 0) top_layout2.setStretch(1, 0) # For some reason, the stretch added above is not enough # to push the whole layout to the left. I have to set # it's stretch factor too... top_layout2.setStretch(2, 100) vhead_layout = QVBoxLayout() vhead_layout.addWidget(self.title_widget) top_layout1.setContentsMargins(4, 0, 4, 0) # vhead_layout.addLayout(top_layout1) vhead_layout.addWidget(InlineSubFrame(top_layout1, None)) vhead_layout.addLayout(top_layout2) # top_layout2.setContentsMargins(4,4,4,4) #vhead_layout.addWidget(InlineSubFrame(top_layout2,None)) vhead_layout.addWidget(self.controller_part.view) vhead_layout.setStretch(0, 0) vhead_layout.setStretch(1, 0) vhead_layout.setStretch(2, 0) vhead_layout.setStretch(3, 10) self.setLayout(vhead_layout) self.controller_part.view.enable_edit_panel() # Handling changes in the model (helpful to know if saving # is necessary) self.model_data_changed = False self.model.rowsInserted.connect(self.data_changed_slot) self.model.rowsRemoved.connect(self.data_changed_slot) self.model.dataChanged.connect(self.data_changed_slot) self.supplier_reference_widget.textChanged.connect( self.data_changed2_slot) self.edit_comment_widget.textChanged.connect(self.data_changed2_slot) self.delivery_date_widget.textChanged.connect(self.data_changed2_slot)
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()