feat: 取消delete功能

This commit is contained in:
iridiumR 2023-06-05 17:42:36 +08:00
parent e7b3bbbf65
commit 35d8cad28f
No known key found for this signature in database
GPG key ID: 49735733EB1A32C8
2 changed files with 0 additions and 45 deletions

View file

@ -38,42 +38,6 @@ class AccountTab(TabPage):
self.setLayout(accountLayout) self.setLayout(accountLayout)
def onAccountDeleteClicked(self):
# 新建对话框,询问是否删除
dialog = QDialog(self)
dialog.setWindowTitle('Delete Account')
label1 = QLabel("Are you sure to delete this account?")
label2 = QLabel("This action cannot be undone.")
buttonBox = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)
buttonBox.accepted.connect(dialog.accept)
buttonBox.rejected.connect(dialog.reject)
layout = QVBoxLayout()
layout.addWidget(label1)
layout.addWidget(label2)
layout.addWidget(buttonBox)
layout.setSpacing(12)
layout.setContentsMargins(15, 15, 15, 15)
dialog.setMinimumWidth(400)
dialog.setLayout(layout)
# 若确认删除,则执行删除操作
if dialog.exec() == QDialog.DialogCode.Accepted:
index = self.accountComboBox.currentIndex()
if (index == -1):
QMessageBox.critical(self, 'Error', 'No account selected')
return
a_id = self.rows[index][0]
self.pg.execute("DELETE FROM account WHERE a_id=%s", (a_id,))
self.selected()
QMessageBox.information(self, 'Success', 'Account deleted')
# 关闭原来的对话框
self.aDialog.close()
def onAccountModifyClicked(self): def onAccountModifyClicked(self):
# 创建添加数据对话框 # 创建添加数据对话框
@ -113,16 +77,13 @@ class AccountTab(TabPage):
# descriptionLine.setText(self.transData[self.rows[0].row()][6]) # descriptionLine.setText(self.transData[self.rows[0].row()][6])
button1 = QPushButton("Confirm") button1 = QPushButton("Confirm")
button3 = QPushButton("Delete")
button2 = QPushButton("Abort") button2 = QPushButton("Abort")
buttonLayout = QHBoxLayout() buttonLayout = QHBoxLayout()
buttonLayout.addWidget(button1) buttonLayout.addWidget(button1)
buttonLayout.addWidget(button3)
buttonLayout.addWidget(button2) buttonLayout.addWidget(button2)
button1.clicked.connect(self.aDialog.accept) button1.clicked.connect(self.aDialog.accept)
button3.clicked.connect(self.onAccountDeleteClicked)
button2.clicked.connect(self.aDialog.reject) button2.clicked.connect(self.aDialog.reject)
layout = QFormLayout() layout = QFormLayout()

View file

@ -42,9 +42,6 @@ class CategoryTab(TabPage):
self.setLayout(categoryLayout) self.setLayout(categoryLayout)
def onCategoryDeleteClicked(self):
pass
def onCategoryModifyClicked(self): def onCategoryModifyClicked(self):
# 创建添加数据对话框 # 创建添加数据对话框
self.cDialog = QDialog(self) self.cDialog = QDialog(self)
@ -83,15 +80,12 @@ class CategoryTab(TabPage):
line3.setText(data[0][2]) line3.setText(data[0][2])
button1 = QPushButton("Confirm") button1 = QPushButton("Confirm")
button3 = QPushButton("Delete")
button2 = QPushButton("Abort") button2 = QPushButton("Abort")
buttonLayout = QHBoxLayout() buttonLayout = QHBoxLayout()
buttonLayout.addWidget(button1) buttonLayout.addWidget(button1)
buttonLayout.addWidget(button3)
buttonLayout.addWidget(button2) buttonLayout.addWidget(button2)
button1.clicked.connect(self.cDialog.accept) button1.clicked.connect(self.cDialog.accept)
button3.clicked.connect(self.onCategoryDeleteClicked)
button2.clicked.connect(self.cDialog.reject) button2.clicked.connect(self.cDialog.reject)
layout = QFormLayout() layout = QFormLayout()