def refresh_vh_assignments(self): '''self.removeTab(1) self.listTab2 = self.create_list_tab(["Od", "Do", "PESEL oficera", "ID pojazdu"], Connector.get_filtered('"Przydzial-pojazd"', ["data_od", "data_do", "pesel_oficera", "id_pojazdu"], " WHERE (SELECT id_jednostki FROM oficerowie WHERE pesel LIKE pesel_oficera) = " + self.unit_id + " ORDER BY data_od DESC"), "pojazdy") self.insertTab(1, self.listTab2, "Pojazdy") self.setCurrentIndex(1)''' if self.tabela_pojazdy is not None: check = self.vh_check.isChecked() filter = "" if not check: filter = " AND (data_do >= current_date OR data_do is NULL) " layout = self.listTab2.layout() layout.removeWidget(self.tabela_pojazdy) self.tabela_pojazdy = create_table( ["Od", "Do", "PESEL oficera", "ID pojazdu"], Connector.get_filtered( '"Przydzial-pojazd"', ["data_od", "data_do", "pesel_oficera", "id_pojazdu"], " WHERE (SELECT id_jednostki FROM oficerowie WHERE pesel LIKE pesel_oficera) = " + self.unit_id + filter + " ORDER BY data_od DESC")) self.tabela_pojazdy.cellDoubleClicked.connect( self.vh_assignment_preview) layout.addWidget(self.tabela_pojazdy, 1, 0, 1, 2)
def refresh_buildings(self): '''self.removeTab(1) self.listTab1 = self.create_list_tab(["Oznaczenie", "Rola"], Connector.get_filtered("budynki", ["oznaczenie", "rola_budynku"], " WHERE id_jednostki = " + self.unit_id + " AND (UPPER(oznaczenie) LIKE UPPER('%" + self.filter_budynki.text() + "%')" + " OR UPPER(rola_budynku) LIKE UPPER('%" + self.filter_budynki.text() + "%'))" + " ORDER BY oznaczenie ASC"), "budynki") self.insertTab(1, self.listTab1, "Budynki") self.setCurrentIndex(1)''' if self.tabela_budynki is not None: layout = self.listTab1.layout() layout.removeWidget(self.tabela_budynki) self.tabela_budynki = create_table(["Oznaczenie", "Rola"], Connector.get_filtered("budynki", ["oznaczenie", "rola_budynku"], " WHERE id_jednostki = " + self.unit_id + " AND (UPPER(oznaczenie) LIKE UPPER('%" + self.filter_budynki.text() + "%')" + " OR UPPER(rola_budynku) LIKE UPPER('%" + self.filter_budynki.text() + "%'))" + " ORDER BY oznaczenie ASC")) self.tabela_budynki.cellDoubleClicked.connect(self.building_preview) layout.addWidget(self.tabela_budynki, 0, 0, 1, 3) if not self.initiation: self.refresh_c_box()
def refresh_eq_assignments(self): '''self.removeTab(0) self.listTab1 = self.create_list_tab(["Od", "Do", "PESEL oficera", "Numer seryjny"], Connector.get_filtered('"Przydzial-ekwipunek"', ["data_od", "data_do", "pesel_oficera", "numer_seryjny"], " WHERE (SELECT id_jednostki FROM oficerowie WHERE pesel LIKE pesel_oficera) = " + self.unit_id + " ORDER BY data_od DESC"), "ekwipunek") self.insertTab(0, self.listTab1, "Ekwipunek") self.setCurrentIndex(0)''' if self.tabela_eq is not None: check = self.eq_check.isChecked() filter = "" if not check: filter = " AND (data_do >= current_date OR data_do is NULL) " layout = self.listTab1.layout() layout.removeWidget(self.tabela_eq) self.tabela_eq = create_table( ["Od", "Do", "PESEL oficera", "Numer seryjny"], Connector.get_filtered( '"Przydzial-ekwipunek"', ["data_od", "data_do", "pesel_oficera", "numer_seryjny"], " WHERE (SELECT id_jednostki FROM oficerowie WHERE pesel LIKE pesel_oficera) = " + self.unit_id + filter + " ORDER BY data_od DESC")) self.tabela_eq.cellDoubleClicked.connect( self.eq_assignment_preview) layout.addWidget(self.tabela_eq, 1, 0, 1, 2)
def refresh_officers(self): '''self.removeTab(3) self.listTab3 = self.create_list_tab(["Imię", "Nazwisko", "PESEL"], Connector.get_filtered("oficerowie", ["imie", "nazwisko", "pesel"], " WHERE id_jednostki = " + self.unit_id + " AND (UPPER(imie) LIKE UPPER('%" + self.filter_oficerowie.text() + "%')" + " OR UPPER(nazwisko) LIKE UPPER('%" + self.filter_oficerowie.text() + "%')" + " OR UPPER(pesel) LIKE UPPER('%" + self.filter_oficerowie.text() + "%'))" + " ORDER BY nazwisko, imie ASC"), "oficerowie") self.insertTab(3, self.listTab3, "Oficerowie") self.setCurrentIndex(3)''' if self.tabela_oficerowie is not None: layout = self.listTab3.layout() layout.removeWidget(self.tabela_oficerowie) self.tabela_oficerowie = create_table(["Imię", "Nazwisko", "PESEL"], Connector.get_filtered("oficerowie", ["imie", "nazwisko", "pesel"], " WHERE id_jednostki = " + self.unit_id + " AND (UPPER(imie) LIKE UPPER('%" + self.filter_oficerowie.text() + "%')" + " OR UPPER(nazwisko) LIKE UPPER('%" + self.filter_oficerowie.text() + "%')" + " OR UPPER(pesel) LIKE UPPER('%" + self.filter_oficerowie.text() + "%'))" + " ORDER BY nazwisko, imie ASC")) self.tabela_oficerowie.cellDoubleClicked.connect(self.officer_preview) layout.addWidget(self.tabela_oficerowie, 0, 0, 1, 3) if not self.initiation: self.refresh_c_box()
def refresh_vehicles(self): '''self.removeTab(2) self.listTab2 = self.create_list_tab(["ID", "Producent", "Model"], Connector.get_filtered("pojazdy", ["id_pojazdu", "producent", "model"], " WHERE id_jednostki = " + self.unit_id + " AND (UPPER(model) LIKE UPPER('%" + self.filter_pojazdy.text() + "%')" + " OR UPPER(producent) LIKE UPPER('%" + self.filter_pojazdy.text() + "%'))" + " ORDER BY id_pojazdu ASC"), "pojazdy") self.insertTab(2, self.listTab2, "Pojazdy") self.setCurrentIndex(2)''' if self.tabela_pojazdy is not None: layout = self.listTab2.layout() layout.removeWidget(self.tabela_pojazdy) self.tabela_pojazdy = create_table(["ID", "Producent", "Model"], Connector.get_filtered("pojazdy", ["id_pojazdu", "producent", "model"], " WHERE id_jednostki = " + self.unit_id + " AND (UPPER(model) LIKE UPPER('%" + self.filter_pojazdy.text() + "%')" + " OR UPPER(producent) LIKE UPPER('%" + self.filter_pojazdy.text() + "%'))" + " ORDER BY id_pojazdu ASC")) self.tabela_pojazdy.cellDoubleClicked.connect(self.vehicle_preview) layout.addWidget(self.tabela_pojazdy, 0, 0, 1, 3) if not self.initiation: self.refresh_c_box()
def set_jednostki(self): self.jednostki = create_table( ['Identyfikator', 'Nazwa'], Connector.get_filtered( "jednostki", ["identyfikator", "nazwa"], " WHERE UPPER(nazwa) LIKE UPPER('%" + self.filter.text() + "%')" + " ORDER BY identyfikator ASC")) self.refresh_unit_box()
def create_list_tab(self, column_names, items, type): tab = QWidget() #layout = QVBoxLayout() layout = QGridLayout() tabela = create_table(column_names, items) layout.addWidget(tabela, 0, 0, 1, 3) filter = QLineEdit() filter.setValidator(QRegExpValidator(QRegExp(rx))) filter.setPlaceholderText("Wyszukaj...") #buttons = QGroupBox("Zarządzanie") #boxLayout = QHBoxLayout() addButton = QPushButton("Dodaj") rmvButton = QPushButton("Usuń") editButton = QPushButton("Edytuj") #boxLayout.addWidget(addButton) #boxLayout.addWidget(rmvButton) #boxLayout.addWidget(editButton) #buttons.setLayout(boxLayout) # addButton.clicked.connect(show_add_windows(type, id)) if type == "budynki": addButton.clicked.connect(self.add_building) rmvButton.clicked.connect(self.delete_buildings) editButton.clicked.connect(self.edit_building) self.filter_budynki = filter self.filter_budynki.returnPressed.connect(self.refresh_buildings) layout.addWidget(self.filter_budynki, 1, 0, 1, 3) self.tabela_budynki = tabela self.tabela_budynki.cellDoubleClicked.connect(self.building_preview) if type == "pojazdy": addButton.clicked.connect(self.add_vehicle) rmvButton.clicked.connect(self.delete_vehicles) editButton.clicked.connect(self.edit_vehicle) self.filter_pojazdy = filter self.filter_pojazdy.returnPressed.connect(self.refresh_vehicles) layout.addWidget(self.filter_pojazdy, 1, 0, 1, 3) self.tabela_pojazdy = tabela self.tabela_pojazdy.cellDoubleClicked.connect(self.vehicle_preview) if type == "oficerowie": addButton.clicked.connect(self.add_officer) rmvButton.clicked.connect(self.delete_officers) editButton.clicked.connect(self.edit_officer) self.filter_oficerowie = filter self.filter_oficerowie.returnPressed.connect(self.refresh_officers) layout.addWidget(self.filter_oficerowie, 1, 0, 1, 3) self.tabela_oficerowie = tabela self.tabela_oficerowie.cellDoubleClicked.connect(self.officer_preview) #layout.addWidget(buttons) layout.addWidget(addButton, 2, 0) layout.addWidget(rmvButton, 2, 1) layout.addWidget(editButton, 2, 2) tab.setLayout(layout) return tab
def refresh_eq(self): self.equipment = create_table( ['Numer seryjny', 'Producent', 'Model'], Connector.get_filtered( "ekwipunek", ["numer_seryjny", "producent", "model"], " WHERE UPPER(producent) LIKE UPPER('%" + self.filter.text() + "%')" + " OR UPPER(model) LIKE UPPER('%" + self.filter.text() + "%')" + " ORDER BY producent, model ASC")) self.equipment.cellDoubleClicked.connect(self.open_eq) self.layout.removeWidget(self.equipment) self.layout.addWidget(self.equipment, 0, 0, 1, 3)
def create_list_tab(self, column_names, items, type): tab = QWidget() layout = QGridLayout() checkExpired = QCheckBox("Pokaż przedawnione") layout.addWidget(checkExpired, 0, 0) tabela = create_table(column_names, items) layout.addWidget(tabela, 1, 0, 1, 2) #buttons = QGroupBox("Zarządzanie") #boxLayout = QHBoxLayout() addButton = QPushButton("Dodaj") rmvButton = QPushButton("Usuń") layout.addWidget(addButton, 2, 0) layout.addWidget(rmvButton, 2, 1) #boxLayout.addWidget(addButton) #boxLayout.addWidget(rmvButton) #buttons.setLayout(boxLayout) # addButton.clicked.connect(show_add_windows(type, id)) if type == "ekwipunek": checkExpired.stateChanged.connect(self.refresh_eq_assignments) addButton.clicked.connect(self.add_eq_assignment) rmvButton.clicked.connect(self.delete_eq_assignments) self.eq_check = checkExpired self.tabela_eq = tabela self.tabela_eq.cellDoubleClicked.connect( self.eq_assignment_preview) if type == "pojazdy": checkExpired.stateChanged.connect(self.refresh_vh_assignments) addButton.clicked.connect(self.add_vh_assignment) rmvButton.clicked.connect(self.delete_vh_assignments) self.vh_check = checkExpired self.tabela_pojazdy = tabela self.tabela_pojazdy.cellDoubleClicked.connect( self.vh_assignment_preview) #layout.addWidget(buttons) tab.setLayout(layout) return tab
def create_list_tab(self, column_names, items, type): tab = QWidget() layout = QGridLayout() tabela = create_table(column_names, items) layout.addWidget(tabela, 0, 0, 1, 3) #buttons = QGroupBox("Zarządzanie") #boxLayout = QHBoxLayout() addButton = QPushButton("Dodaj") rmvButton = QPushButton("Anuluj") finishButton = QPushButton("Zakończ") #boxLayout.addWidget(addButton) #boxLayout.addWidget(rmvButton) #boxLayout.addWidget(finishButton) #buttons.setLayout(boxLayout) layout.addWidget(addButton, 1, 0) layout.addWidget(rmvButton, 1, 1) layout.addWidget(finishButton, 1, 2) # addButton.clicked.connect(show_add_windows(type, id)) if type == "ekwipunek": addButton.clicked.connect(self.add_eq_order) rmvButton.clicked.connect(self.delete_eq_order) finishButton.clicked.connect(self.finish_eq_order) self.tabela_eq = tabela self.tabela_eq.cellDoubleClicked.connect(self.eq_order_preview) if type == "pojazdy": addButton.clicked.connect(self.add_vh_order) rmvButton.clicked.connect(self.delete_vh_order) finishButton.clicked.connect(self.finish_vh_order) self.tabela_pojazdy = tabela self.tabela_pojazdy.cellDoubleClicked.connect( self.vh_order_preview) #layout.addWidget(buttons) tab.setLayout(layout) return tab