def __init__(self, parent, remote_documents_service): super(NonConformityDialog, self).__init__(parent) self._quality_widget = Nonconformity2Widget(self, remote_documents_service) title = _("Create a non conformity") self.setWindowTitle(title) top_layout = QVBoxLayout() self.title_widget = TitleWidget(title, self) top_layout.addWidget(self.title_widget) self._explanation = QLabel() self._explanation.setWordWrap(True) top_layout.addWidget(self._explanation) top_layout.addWidget(self._quality_widget) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.Ok) self.buttons.addButton(QDialogButtonBox.Cancel) 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(AddPeriodDialog, self).__init__(parent) t = _("Add a period for an operation definition") self.setWindowTitle(t) self.title_widget = TitleWidget(t, self) top_layout = QVBoxLayout() top_layout.addWidget(self.title_widget) hlayout = QHBoxLayout() hlayout.addWidget(QLabel(_("Start time"), self)) self.date_edit = QLineEdit(self) hlayout.addWidget(self.date_edit) top_layout.addLayout(hlayout) hlayout = QHBoxLayout() hlayout.addWidget(QLabel(_("Hourly cost"), self)) self.hourly_cost = QLineEdit(self) hlayout.addWidget(self.hourly_cost) top_layout.addLayout(hlayout) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.Ok) top_layout.addWidget(self.buttons) self.setLayout(top_layout) # QWidget takes ownership of the layout self.buttons.accepted.connect(self.accepted)
def __init__(self,parent): global dao super(CreateNewOrderDialog,self).__init__(parent) self.current_customer = None title = _("Create new order") self.setWindowTitle(title) top_layout = QVBoxLayout() self.title_widget = TitleWidget(title,self) top_layout.addWidget(self.title_widget) self.customer_plate_widget = CustomerPlateWidget(self) self.buttons = QDialogButtonBox() self.buttons.addButton( QDialogButtonBox.StandardButton.Cancel) self.buttons.addButton( QDialogButtonBox.Ok) hlayout = QHBoxLayout() self.customer_select = AutoCompleteComboBox(None, self, None) self.customer_select.section_width = None # [300] view = [] keys = [] ref = [] customers = dao.customer_dao.all() for c in customers: view.append([c.fullname]) keys.append(c.fullname) ref.append(c) session().close() # FIXME bad data layer / presentation layer separation here self.customer_select.make_model( view, keys, ref ) self.customer_plate_widget.set_customer(customers[0]) hlayout.addWidget(QLabel(_("Customer")), 0, Qt.AlignTop) hlayout.addWidget(self.customer_select, 0, Qt.AlignTop) hlayout.addWidget(self.customer_plate_widget, 1000, Qt.AlignTop) hlayout.addStretch() top_layout.addLayout(hlayout) # hlayout = QHBoxLayout() # self.order_select = AutoCompleteComboBox() # self.order_select.setEnabled(False) # self.order_select.section_width = [100,300] # hlayout.addWidget(QLabel(_("Clone order"))) # self.enable_clone = QCheckBox() # hlayout.addWidget(self.enable_clone) # hlayout.addWidget(self.order_select) # 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.customer_select.activated.connect(self.customer_selected) self.customer_select.list_view.itemSelected.connect(self.customer_selected)
def __init__(self, info_text, no_date_allowed = True): super(DatePick, self).__init__() self.accepted_date = None layout = QVBoxLayout() title = _("Pick a date") self.setWindowTitle(title) layout.addWidget(TitleWidget(title, self)) self.info_label =QLabel(info_text) self.qw = QCalendarWidget() self.info_label.setWordWrap(True) self.info_label.setMaximumWidth(self.qw.minimumWidth()) layout.addWidget( self.info_label) layout.addWidget( self.qw) self.qw.activated.connect(self.date_chosen) self.buttons = QDialogButtonBox() if no_date_allowed: self.buttons.addButton( QPushButton("No date"), QDialogButtonBox.ButtonRole.AcceptRole) self.buttons.addButton( QDialogButtonBox.StandardButton.Cancel) self.buttons.addButton( QDialogButtonBox.Ok) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) layout.addWidget(self.buttons) layout.addStretch() self.setLayout(layout)
def __init__(self, parent, remote_indicators_service, title, indicators): super(IndicatorsPanel, self).__init__(parent) self.remote_indicators_service = remote_indicators_service self.month_chooser = MonthChooser(self.MONTHS_STEP) month_before, month_today, month_after = self.month_chooser.navbar_buttons_tuples( ) self.month_chooser.month_changed.connect(self._month_changed) self.set_panel_title(title) self.indicators = indicators vlayout = QVBoxLayout(self) navigation = NavBar(None, [ month_before, month_today, month_after, (_("Recompute"), self._clear_cache), (_("Export to Excel"), self._export_to_excel) ]) self.title_box = TitleWidget( title, self, navigation) # + date.today().strftime("%B %Y"),self) vlayout.addWidget(self.title_box) # Pay attention, subframes holds a reference to each # subframe widget ! ind_layout, self._sub_frames = self._layout_indicators(self.indicators) vlayout.addLayout(ind_layout) self.setLayout(vlayout)
def __init__(self, parent): super(AboutDemoDialog, self).__init__(parent) title = _("Welcome to {}...").format( configuration.get("Globals", "name")) self.setWindowTitle(title) top_layout = QVBoxLayout() self.title_widget = TitleWidget(title, self) top_layout.addWidget(self.title_widget) text = QLabel( _(""" <p>Welcome to the demo of {0}. This demo is fully functional and it comes with an example database. That should be enough to have a full tour of {0}.</p> <p>The first screen you'll see is a list of orders that were done in our imaginary company. If you double click on one of them, you'll see its details. From there on, you can browse around and test everything.</p> <p>As it is the demo version, all the data you'll change will be visible on internet. The demonstration database will be reased from time to time.</p> <p>Enjoy and feel free to contact us in case of problems : <a href="mailto:[email protected]">[email protected]</a></p> """).format(configuration.get("Globals", "name"))) text.setTextFormat(Qt.RichText) text.setWordWrap(True) top_layout.addWidget(text) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.Ok) 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): global dao super(DeleteLastDeliverySlipDialog,self).__init__(parent) title = _("Delete the last 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) top_layout.addWidget(self.buttons) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) self.setLayout(top_layout)
def __init__(self, parent, doc_service): super(TemplatesCollectionWidgetDialog, self).__init__(parent) layout = QVBoxLayout() self.setWindowTitle(_("Templates library")) tw = TitleWidget(_("Templates library"), self) layout.addWidget(tw) l = QLabel( _("Here you can add or remove templates documents from the library. " "If needed, you can change their name and add a description. " "If you want to replace a reference document (one with a special " "Horse reference, then simply drag and drop the document on " "the appropriate row")) l.setWordWrap(True) layout.addWidget(l) self.widget = TemplatesCollectionWidget(self, doc_service) layout.addWidget(self.widget) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.Ok) self.buttons.accepted.connect(self.accept) layout.addWidget(self.buttons) self.setLayout(layout) place_dialog_on_screen(self, 0.5, 0.7)
def __init__(self, parent): global configuration super(EditConfigurationDialog, self).__init__(parent) title = _("Preferences") self.setWindowTitle(title) self.title_widget = TitleWidget(title, self) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.Ok) self.buttons.addButton(QDialogButtonBox.Cancel) self.font_select = QCheckBox() self.server_address = QLineEdit() form_layout = QFormLayout() form_layout.addRow(_("Fonts"), self.font_select) form_layout.addRow(_("Server's IP address"), self.server_address) top_layout = QVBoxLayout() top_layout.addWidget(self.title_widget) top_layout.addLayout(form_layout) top_layout.addWidget(self.buttons) self.setLayout(top_layout) # QWidget takes ownership of the layout self.buttons.accepted.connect(self.save_and_accept) self.buttons.rejected.connect(self.cancel) self._load_configuration(configuration)
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): global dao super(FindOrderDialog,self).__init__(parent) title = _("Find order") self.setWindowTitle(title) top_layout = QVBoxLayout() self.title_widget = TitleWidget(title,self) top_layout.addWidget(self.title_widget) hlayout = QHBoxLayout() hlayout.addWidget(QLabel(_("Search"))) self.search_criteria = QLineEdit() self.search_criteria.setObjectName("search_criteria") hlayout.addWidget(self.search_criteria) top_layout.addLayout(hlayout) self.search_results_view = QTableView() self.headers_view = QHeaderView(Qt.Orientation.Horizontal) self.header_model = make_header_model([_("Preorder Nr"),_("Order Nr"),_("Customer Nr"),_("Customer"),_("Order Part")]) self.headers_view.setModel(self.header_model) # qt's doc : The view does *not* take ownership (bt there's something with the selecion mode self.search_results_model = QStandardItemModel() self.search_results_view.setModel(self.search_results_model) self.search_results_view.setEditTriggers(QAbstractItemView.NoEditTriggers) self.search_results_view.setHorizontalHeader(self.headers_view) self.search_results_view.verticalHeader().hide() # self.search_results_view.horizontalHeader().setResizeMode(QHeaderView.ResizeToContents) self.search_results_view.horizontalHeader().setResizeMode(3, QHeaderView.Stretch) self.search_results_view.horizontalHeader().setResizeMode(4, QHeaderView.Stretch) self.search_results_view.setSelectionBehavior(QAbstractItemView.SelectRows) self.buttons = QDialogButtonBox() self.buttons.addButton( QDialogButtonBox.StandardButton.Cancel) self.buttons.addButton( QDialogButtonBox.Ok) self.buttons.button(QDialogButtonBox.Ok).setObjectName("go_search") top_layout.addWidget(self.search_results_view) top_layout.setStretch(2,1000) top_layout.addWidget(self.buttons) self.setLayout(top_layout) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) self.search_results_view.activated.connect(self.row_activated) self.search_criteria.returnPressed.connect(self.search_criteria_submitted) self.setMinimumSize(800,640)
def __init__(self, parent): super(AboutDialog, self).__init__(parent) title = _("About {}...").format(configuration.get("Globals", "name")) self.setWindowTitle(title) top_layout = QVBoxLayout() self.title_widget = TitleWidget(title, self) top_layout.addWidget(self.title_widget) text = QLabel(u"{}<br/>Version : {}<br/><br/>".format( copyright(), str(configuration.this_version)) + _("""This program is given to you with a few important freedoms and duties as specified in the license below. <b>We believe they will help to make a better world</b>. They are also <b>legally binding</b> (see Free Software Foundation's website), so make sure you read the license carefully. We give you the right to <ul> <li>run the program,</li> <li>inspect it to make sure it is safe to use,</li> <li>modify it to suit your needs,</li> <li>distribute copies of it,</li> </ul> as long as you give those freedoms and duties to anybody you give this program to. """)) text.setTextFormat(Qt.RichText) text.setWordWrap(True) # text.setMaximumWidth(400) top_layout.addWidget(text) browser = QTextBrowser() browser.setLineWrapMode(QTextEdit.NoWrap) browser.setPlainText(license()) browser.setMinimumWidth(browser.document().documentLayout(). documentSize().toSize().width()) browser.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) top_layout.addWidget(browser) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.Ok) 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): global configuration super(TimeReportingScannerDialog, self).__init__(parent) self.presence_dialog = PresenceDialog(self) self.time_edit_dialog = TimeEditDialog(self) self.time_edit_dialog.setMinimumWidth(500) title = _("Time reporting scanner") self.setWindowTitle(title) self.title_widget = TitleWidget(title, self) info = QLabel( _("The picture below show the various actions reported for the employee (vertical lines). It also show the time spent on tasks (coloured bars). Right click on any timeline to add new actions or delete existing ones. Click anywhere else to add actions on task which are not shown below. The green bar shows the presence of the employee during the day; it doesn't show actual work. The actual work is shown on the blue bars." ), self) info.setWordWrap(True) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.Ok) self.buttons.addButton(QDialogButtonBox.Cancel) self.thinfont = QFont("Arial", 8, QFont.Normal) self.view = TheView(self) # self.view.setRenderHint(QPainter.Antialiasing) self.view.setAlignment(Qt.AlignLeft | Qt.AlignTop) self.view.add_presence_report_action.triggered.connect( self.add_presence_report) self.view.add_task_report_action.triggered.connect( self.add_task_report) self.view.delete_report_action.triggered.connect(self.delete_report) top_layout = QVBoxLayout() top_layout.addWidget(self.title_widget) top_layout.addWidget(info) top_layout.addWidget(self.view) top_layout.addWidget(self.buttons) self.setLayout(top_layout) # QWidget takes ownership of the layout self.buttons.accepted.connect(self.save_and_accept) self.buttons.rejected.connect(self.cancel) self.changed = False
def __init__(self, parent, user_session): super(LoginDialog, self).__init__(parent) self.user = None self.user_session = user_session title = _("{} Login").format(configuration.get("Globals", "name")) self.setWindowTitle(title) self.title_widget = TitleWidget(title, self) self.userid = QLineEdit() self.password = QLineEdit() self.password.setEchoMode(QLineEdit.Password) self.remember_me = QCheckBox() form_layout = QFormLayout() form_layout.addRow(_("User ID"), self.userid) form_layout.addRow(_("Password"), self.password) form_layout.addRow(_("Remember me"), self.remember_me) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.Ok) top_layout = QVBoxLayout() top_layout.addWidget(self.title_widget) top_layout.addWidget(QLabel(_("Please identify yourself"))) top_layout.addLayout(form_layout) top_layout.addWidget(self.buttons) self.setLayout(top_layout) # QWidget takes ownership of the layout self.buttons.accepted.connect(self.try_login) self.buttons.rejected.connect(self.cancel) self.userid.textEdited.connect(self.login_changed) if configuration.get("AutoLogin", "user"): self.remember_me.setCheckState(Qt.Checked) self.userid.setText(configuration.get("AutoLogin", "user")) self.password.setText(configuration.get("AutoLogin", "password")) mainlog.debug("__init__ login dialog")
def __init__(self, parent, find_order_slot): super(WeekOverviewWidget, self).__init__(parent) self.nb_weeks = 3 td = date.today() self.base_date = td - timedelta(days=td.weekday()) # Align on monday self.quick_order_view = QuickOrderViewWidget(self) self.weekview_layout = QHBoxLayout(None) self.weeks = [] for i in range(self.nb_weeks): w = WeekViewWidget(self) self.weeks.append(w) self.weekview_layout.addWidget(w) w.table_view.focus_in.connect(self.quick_order_view.selected_order) w.table_view.selectionModel().currentChanged.connect( self.quick_order_view.selected_order) w.table_view.out_left.connect(self.week_before) w.table_view.out_right.connect(self.week_after) self.weekview_layout.addWidget(self.quick_order_view) navbar = NavBar(self, [(_("Week before"), self.week_before), (_("Week after"), self.week_after), (_("Find"), find_order_slot)]) # (_("Today"),self.week _today), navbar.buttons[2].setObjectName("specialMenuButton") self.vlayout = QVBoxLayout(None) self.vlayout.addWidget( TitleWidget(_("Deadlines Overview"), self, navbar)) self.vlayout.addLayout(self.weekview_layout) self.vlayout.setStretch(0, 0) self.vlayout.setStretch(1, 200) self.setLayout(self.vlayout) self.focus()
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): global configuration super(OrderWorkflowDialog,self).__init__(parent) self.grey_pen = QPen(Qt.gray) title = _("Order workflow") self.setWindowTitle(title) self.title_widget = TitleWidget(title,self) self.buttons = QDialogButtonBox() self.buttons.addButton( QDialogButtonBox.Ok) self.buttons.addButton( QDialogButtonBox.Cancel) self.thinfont = QFont() if configuration.font_select: self.thinfont.setPointSize(self.thinfont.pointSize()*2) self.scene = QGraphicsScene() self.scene.selectionChanged.connect(self.selectionChanged) self.view = QGraphicsView(self) self.view.setRenderHint(QPainter.Antialiasing) self.view.setScene(self.scene) top_layout = QVBoxLayout() top_layout.addWidget(self.title_widget) top_layout.addWidget(self.view) top_layout.addWidget(self.buttons) self.setLayout(top_layout) # QWidget takes ownership of the layout self.buttons.accepted.connect(self.save_and_accept) self.buttons.rejected.connect(self.cancel) self.initial_state = None self.selected_state = None self._drawNodes(self.scene,self.selected_state,self.initial_state)
def __init__(self, parent): super(PrintPreorderDialog, self).__init__(parent) title = _("Print preorder") self.setWindowTitle(title) top_layout = QVBoxLayout() self.title_widget = TitleWidget(title, self) top_layout.addWidget(self.title_widget) info = QLabel( _("Here you can give a small message that will be printed togetehr with the preorder." ), self) info.setWordWrap(True) top_layout.addWidget(info) top_layout.addWidget(QLabel(_("Header text"))) self.message_text_area = QTextEdit() top_layout.addWidget(self.message_text_area) top_layout.addWidget(QLabel(_("Footer text"))) self.message_text_area_footer = QTextEdit() top_layout.addWidget(self.message_text_area_footer) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.StandardButton.Cancel) self.buttons.addButton(QDialogButtonBox.Ok) 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, 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(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)
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,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, find_order_action_slot, create_delivery_slip_action, show_prices=True): super(OrderOverviewWidget, self).__init__(parent) self.set_panel_title(_("Order Overview")) self.base_date = date.today() self.touched_row = set() # maps order_id -> monthlygoal (true or false) self.touched_orders = dict() self.create_delivery_slip_action = create_delivery_slip_action # self.edit_action = QAction(_('Edit order'),self) # self.edit_action.triggered.connect( self.edit_order_slot) # self.past_orders_overview = PastOrdersOverviewWidget(None,None,None,show_prices) self.current_orders_overview = CurrentOrdersOverviewWidget( None, None, None, show_prices) self.current_orders_overview.order_part_activated_signal.connect( self.order_part_activated_slot) self.current_orders_overview.order_parts_changed.connect( self.order_parts_changed_slot) # self.past_orders_overview.order_part_activated_signal.connect(self.order_part_activated_slot) self.vlayout = QVBoxLayout(self) # self.select_active_orders = QRadioButton(_("Production"),self) # self.select_active_orders.setToolTip(_("Order that are in production (as specified by their state)")) # # self.select_preorders = QRadioButton(_("Preorders"),self) # # self.select_orders_on_hold = QRadioButton(_("Dormant"),self) # self.select_orders_on_hold.setToolTip(_("Orders that are either on hold or to be defined (as specified by their state)")) # self.select_orders_finished = QRadioButton(_("Finished"),self) # self.select_orders_finished.setToolTip(_("Orders that were marked as completed this month")) # # self.select_orders_aborted = QRadioButton(_("Aborted"),self) # self.select_orders_aborted.setToolTip(_("Orders that were prematurely cancelled")) # I need a button group which is exclusive but # which also allows *all* the buttons to bl cleared # at once. The regular exclusive flags forces # us to have always one button checked... # self.button_group = QButtonGroup(self) # self.button_group.addButton(self.select_active_orders) # self.button_group.addButton(self.select_preorders) # self.button_group.addButton(self.select_orders_on_hold) # self.button_group.addButton(self.select_orders_finished) # self.button_group.addButton(self.select_orders_aborted) # self.button_group.setExclusive(False) # self.button_group.buttonClicked.connect(self.button_clicked) # I need to be able to unselect all buttons (in case I use the super filter) # self.select_active_orders.setAutoExclusive(False) # self.select_preorders.setAutoExclusive(False) # self.select_orders_on_hold.setAutoExclusive(False) # self.select_orders_finished.setAutoExclusive(False) # self.select_orders_aborted.setAutoExclusive(False) # self.select_active_orders.setChecked(True) # Preselects active order self.persistent_filter = PersistentFilter( FilterQuery.ORDER_PARTS_OVERVIEW_FAMILY, find_suggestions) self.persistent_filter.apply_filter.connect(self.super_filter) navigation = NavBar( self, [(self.persistent_filter.get_filters_combo(), None), (_("Edit filter"), self._toggle_edit_filters), (_("Find"), find_order_action_slot)]) self.persistent_filter.hide() # self.persistent_filter.select_default_filter() # navigation.buttons[7].setObjectName("specialMenuButton") # self.save_filter_action = QAction(_("Save filter"),self) # self.save_filter_action.triggered.connect( self.save_filter_action_slot) # self.save_filter_as_action = QAction(_("Save filter as"),self) # self.save_filter_as_action.triggered.connect( self.save_filter_as_action_slot) # self.delete_filter_action = QAction(_("Delete filter"),self) # self.delete_filter_action.triggered.connect( self.delete_filter_action_slot) def action_to_button(action): b = QPushButton(action.text()) b.clicked.connect(action.trigger) return b # self.action_menu = QMenu(navigation.buttons[8]) # self.filter_menu = QMenu("Filter menu") # self.filter_menu.addAction("filter alpha") # self.filter_menu.addAction("filter beta") # list_actions = [ (self.save_filter_action,None,None), # (self.save_filter_as_action,None,None), # (self.delete_filter_action, None,None), # (self.filter_menu, None,None) ] # populate_menu(self.action_menu, self, list_actions, context=Qt.WidgetWithChildrenShortcut) self.title_box = TitleWidget( _("Orders overview"), self, navigation) # + date.today().strftime("%B %Y"),self) self.vlayout.addWidget(self.title_box) self.vlayout.addWidget(self.persistent_filter) # hlayout_god_mode = QHBoxLayout() # hlayout_god_mode.addWidget(QLabel(_("Filter :"))) # self.filter_name = QComboBox() # self.filter_name.setMinimumWidth(100) # # self.filter_name.setEditable(True) # I use activated so that reselecting the same index # triggers an action (for example, clears a badly # edited filter) # self.filter_name.activated.connect(self.filter_activated_slot) # hlayout_god_mode.addWidget(self.filter_name) # hlayout_god_mode.addWidget(QLabel(_("Query :"))) # hlayout_god_mode.addWidget(self.super_filter_entry) # # self.completion.setParent(self.super_filter_entry) # self.super_filter_entry.cursorPositionChanged.connect(self.cursorPositionChanged_slot) # # self.super_filter_entry.editingFinished.connect(self.completEditFinished_slot) # # self.super_filter_entry.returnPressed.connect(self.super_filter) # self.share_filter = QCheckBox(_("Shared")) # hlayout_god_mode.addWidget(self.share_filter) # self.super_filter_button = QPushButton(_("Filter")) # hlayout_god_mode.addWidget(self.super_filter_button) # self.save_filter_button = action_to_button(self.save_filter_action) # hlayout_god_mode.addWidget(self.save_filter_button) # hlayout_god_mode.addWidget(action_to_button(self.save_filter_as_action)) # self.delete_filter_button = action_to_button(self.delete_filter_action) # hlayout_god_mode.addWidget(self.delete_filter_button) # self.vlayout.addLayout(hlayout_god_mode) # self.super_filter_button.clicked.connect(self.super_filter) # self.select_active_orders.clicked.connect(self.refresh_action) # self.select_preorders.clicked.connect(self.refresh_action) # self.select_orders_on_hold.clicked.connect(self.refresh_action) # self.select_orders_finished.clicked.connect(self.refresh_action) # self.select_orders_aborted.clicked.connect(self.refresh_action) self.current_orders_overview.data_changed_signal.connect( self.set_title) self.stack_layout = QStackedLayout() self.stack_layout.addWidget(self.current_orders_overview) # self.stack_layout.addWidget(self.past_orders_overview) self.vlayout.addLayout(self.stack_layout) self.setLayout(self.vlayout) # self._load_available_queries() self.persistent_filter.load_last_filter(configuration)
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 __init__(self, parent, order_overview_widget, find_order_slot): global configuration super(PostViewWidget, self).__init__(parent) self.set_panel_title(_("Post overview")) self.bold_font = QFont(self.font()) self.bold_font.setBold(True) self.nb_cols = 8 # Number of columns in the operation definition table self.order_overview_widget = order_overview_widget self.button = QPushButton(_("Refresh"), self) self.button.clicked.connect(self.refresh_action) self.sort_by_deadline_button = QRadioButton(_("By deadline"), self) self.sort_by_deadline_button.toggled.connect(self.sort_by_deadline) self.sort_by_size_button = QRadioButton(_("By hours left to do"), self) self.sort_by_size_button.toggled.connect(self.sort_by_size) # hlayout = QHBoxLayout() # hlayout.setObjectName("halyout") # hlayout.setContentsMargins(0,0,0,0) # hlayout.addWidget(self.sort_by_deadline_button) # hlayout.addWidget(self.sort_by_size_button) # hlayout.addWidget(self.button) # hlayout.addStretch() self.navbar = NavBar(self, [(self.sort_by_deadline_button, None), (self.sort_by_size_button, None), (self.button, None), (_("Find"), find_order_slot)]) self.navbar.buttons[3].setObjectName("specialMenuButton") self.vlayout = QVBoxLayout(self) self.vlayout.setObjectName("Vlayout") self.vlayout.addWidget( TitleWidget(_("Posts Overview"), self, self.navbar)) self._table_model = QStandardItemModel(1, self.nb_cols, self) self.table_view = QTableView(None) self.table_view.setModel(self._table_model) self.table_view.selectionModel().currentChanged.connect( self.operation_selected) self.table_view.verticalHeader().hide() self.table_view.horizontalHeader().hide() self.table_view.setEditTriggers(QAbstractItemView.NoEditTriggers) self.table_view.setSelectionBehavior(QAbstractItemView.SelectRows) # This forces Qt to expand layout once I fill data in # FIXME dirty but I really don't get why setting # the mini width to something smaller (that happens at # startup, on first refresh) doesn't work self.table_view.setMinimumWidth(1) self.table_view.setMaximumWidth(1) self.post_view_scene = PostViewScene(self, order_overview_widget) self.post_view_scene_view = QGraphicsView(self) self.post_view_scene_view.setScene(self.post_view_scene) self.post_view_scene_view.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.splitter = QSplitter(Qt.Horizontal) self.splitter.addWidget( SubFrame(_("Posts"), self.table_view, self.splitter)) self.splitter.addWidget( SubFrame(_("Workload"), self.post_view_scene_view, self.splitter)) # self.splitter.setStretchFactor(0,1) self.splitter.setStretchFactor(1, 1) self.vlayout.addWidget(self.splitter) # hlayout = QHBoxLayout() # hlayout.addWidget(SubFrame(_("Posts"),self.table_view,self)) # hlayout.addWidget(SubFrame(_("Workload"),self.post_view_scene_view,self)) # hlayout.setStretch(1,1) # self.vlayout.addLayout(hlayout) self.vlayout.setStretch(0, 0) self.vlayout.setStretch(1, 1) self.setLayout(self.vlayout) self.timer = QTimer(self) self.timer.timeout.connect(self.slidePostsScene) self.current_view_y = 0
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, find_order_action_slot): super(PresenceOverviewWidget, self).__init__(parent) self.set_panel_title(_("Presence overview")) self.base_date = date.today() headers = QStandardItemModel(1, 31 + 3) self._table_model = QStandardItemModel(1, 31 + 3, 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 = TableViewSignaledEvents(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.setEditTriggers(QAbstractItemView.NoEditTriggers) self.table_view.setContextMenuPolicy(Qt.CustomContextMenu) self.table_view.customContextMenuRequested.connect( self.popup_context_menu) self.copy_action = QAction(_("Copy order parts"), self.table_view) self.copy_action.triggered.connect(self.copy_slot) self.copy_action.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_C)) self.copy_action.setShortcutContext(Qt.WidgetWithChildrenShortcut) self.table_view.addAction(self.copy_action) self.select_all_action = QAction(_("Select all"), self.table_view) self.select_all_action.triggered.connect(self.select_all_slot) self.select_all_action.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_A)) self.select_all_action.setShortcutContext( Qt.WidgetWithChildrenShortcut) self.table_view.addAction(self.select_all_action) # self.table_view.setSelectionBehavior(QAbstractItemView.SelectItems) # self.table_view.setSelectionMode(QAbstractItemView.SingleSelection) navbar = NavBar(self, [(_("Month before"), self.month_before), (_("Today"), self.month_today), (_("Action"), self.show_actions), (_("Month after"), self.month_after), (_("Find"), find_order_action_slot)]) self.action_menu = QMenu(navbar.buttons[2]) navbar.buttons[2].setObjectName("specialMenuButton") navbar.buttons[4].setObjectName("specialMenuButton") self._make_days_off_menu_and_action_group() list_actions = [ # (_("Edit"),self.edit_tars, None, None), (_("Edit"), self.edit_timetrack_no_ndx, None, None), (_("Month correction"), self.edit_month_correction, None, [RoleType.modify_monthly_time_track_correction]), (self.days_off_menu, None), (self.copy_action, None), (self.select_all_action, None) ] # (_("Insert holidays"),self.create_holidays, None, None), # (_("Delete holidays"),self.delete_holidays, None, None) ] populate_menu(self.action_menu, self, list_actions) # mainlog.debug("tile widget") self.title_box = TitleWidget(_("Presence Overview"), self, navbar) self.vlayout = QVBoxLayout(self) self.vlayout.setObjectName("Vlayout") self.vlayout.addWidget(self.title_box) self.hours_per_pers_subframe = SubFrame(_("Overview"), self.table_view, self) self.vlayout.addWidget(self.hours_per_pers_subframe) self.time_report_view = TimeReportView(self) self.days_off_panel = self._make_total_days_off_panel() vbox = QVBoxLayout() vbox.addWidget(self.days_off_panel) vbox.addStretch() vbox.setStretch(0, 0) vbox.setStretch(1, 1) hlayout = QHBoxLayout() hlayout.addWidget(self.time_report_view) hlayout.addLayout(vbox) hlayout.setStretch(0, 1) self.detail_subframe = SubFrame(_("Day"), hlayout, self) self.vlayout.addWidget(self.detail_subframe) self.setLayout(self.vlayout) # dbox = QVBoxLayout() # dbox.addWidget(QLabel("kjkljkj")) # self.total_active_hours = LabeledValue(_("Total activity")) # dbox.addWidget(self.total_active_hours) # hbox = QHBoxLayout() # hbox.addWidget(self.table_view) # hbox.addLayout(dbox) # self.selection_model = self.table_view.selectionModel() # mainlog.debug(m) #sm = QItemSelectionModel(self.table_view.model()) #sm.setModel(self.table_view.model()) # self.table_view.setSelectionModel(self.selection_model) self.table_view.selectionModel().currentChanged.connect( self.cell_entered) self.table_view.doubleClickedCell.connect(self.edit_timetrack)
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, dao): super(ReprintDeliverySlipDialog, self).__init__(parent) self.dao = dao title = _("Print a delivery slip") self.setWindowTitle(title) top_layout = QVBoxLayout() self.title_widget = TitleWidget(title, None) self.buttons = QDialogButtonBox() self.buttons.addButton(QDialogButtonBox.StandardButton.Cancel) self.buttons.addButton(QDialogButtonBox.Ok) hlayout = QHBoxLayout() hlayout.addWidget(QLabel(_("Slip number"))) self.slip_number = QLineEdit() hlayout.addWidget(self.slip_number) hlayout.addStretch() self.search_results_view = QTableView() self.search_results_model = QStandardItemModel() self.search_results_model.setHorizontalHeaderLabels( [_("Slip Nr"), _("Date"), _("Customer"), _("Order")]) self.search_results_view.setModel(self.search_results_model) # self.search_results_view.setHorizontalHeader(self.headers_view) self.search_results_view.setEditTriggers( QAbstractItemView.NoEditTriggers) self.search_results_view.horizontalHeader().setResizeMode( 1, QHeaderView.ResizeToContents) self.search_results_view.horizontalHeader().setResizeMode( 2, QHeaderView.Stretch) self.search_results_view.verticalHeader().hide() self.slip_part_view = DeliverySlipViewWidget(self) hlayout_results = QHBoxLayout() hlayout_results.addWidget(self.search_results_view) hlayout_results.addWidget(self.slip_part_view) self.search_results_model.removeRows( 0, self.search_results_model.rowCount()) delivery_slips = self.dao.delivery_slip_part_dao.find_recent() for slip in delivery_slips: self.search_results_model.appendRow([ QStandardItem(str(slip[0])), QStandardItem(date_to_dmy(slip[1])), QStandardItem(slip[2]), QStandardItem(slip[3]) ]) top_layout.addWidget(self.title_widget) top_layout.addLayout(hlayout) top_layout.addLayout(hlayout_results) top_layout.addWidget(self.buttons) top_layout.setStretch(2, 100) self.setLayout(top_layout) self.search_results_view.setSelectionBehavior( QAbstractItemView.SelectRows) self.search_results_view.setSelectionMode( QAbstractItemView.SingleSelection) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) self.search_results_view.activated.connect(self.row_activated) self.search_results_view.selectionModel().currentRowChanged.connect( self.row_selected)