예제 #1
0
파일: python.py 프로젝트: wiz21b/koi
    def _make_menu(self, instance_name, title,list_actions,target):
        global configuration

        menu = QMenu(title)
        # self._populate_menu(menu,list_actions)
        populate_menu(menu,target,list_actions)
        self.menuBar().addMenu(menu)
        self.menus.append( (instance_name, menu) )
예제 #2
0
    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)
예제 #3
0
    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)
예제 #4
0
    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)