def table_add_clicked(self, table_data): """Add a row in table with TableData""" table_data.widget.clearSelection() w = CustomDialog(self, *table_data.dialog_items(), window_title='Add item') res = w.result() if res: # If ok pressed self.cur.execute(table_data.add(res)) self.con.commit() self.table_update(table_data)
def table_edit_clicked(self, table_data: BaseTableData): """Edits selected rows in table with TableData""" rows = get_selected_rows(table_data.widget) if not rows: # If rows not selected QMessageBox.information(self, 'Information', f'No selected rows') return i, row = rows[0] table_data.widget.selectRow(i) w = CustomDialog(self, *table_data.dialog_items(row), window_title='Edit item') res = w.result() if res: # If ok pressed res.insert(0, row[0]) self.cur.execute(table_data.edit(res)) self.con.commit() self.table_update(table_data)