def on_action_Edit_activated(self): edit_rows = util.getSelectedRows(self.tableView) if len(edit_rows) != 1: QMessageBox.information(self, u'提示', u'请仅选择一行进行编辑') return record = self.model.records[edit_rows[0]] editdialog = EditDialog(self, record, self.update_count_result) editdialog.show()
def on_action_Delete_activated(self): if QMessageBox.question(self, u'提示', u'确定要删除所选记录吗?', QMessageBox.Yes|QMessageBox.No) == QMessageBox.Yes: remove_rows = util.getSelectedRows(self.tableView) remove_rows.sort() remove_rows.reverse() for row in remove_rows: self.model.removeRows(row) self.model.save() self.update_count_result()