diff --git a/src/budget/_account.py b/src/budget/_account.py index b3737cb..abf3930 100644 --- a/src/budget/_account.py +++ b/src/budget/_account.py @@ -38,42 +38,6 @@ class AccountTab(TabPage): 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): # 创建添加数据对话框 @@ -113,16 +77,13 @@ class AccountTab(TabPage): # descriptionLine.setText(self.transData[self.rows[0].row()][6]) button1 = QPushButton("Confirm") - button3 = QPushButton("Delete") button2 = QPushButton("Abort") buttonLayout = QHBoxLayout() buttonLayout.addWidget(button1) - buttonLayout.addWidget(button3) buttonLayout.addWidget(button2) button1.clicked.connect(self.aDialog.accept) - button3.clicked.connect(self.onAccountDeleteClicked) button2.clicked.connect(self.aDialog.reject) layout = QFormLayout() diff --git a/src/budget/_category.py b/src/budget/_category.py index 0eb4818..19c48c6 100644 --- a/src/budget/_category.py +++ b/src/budget/_category.py @@ -42,9 +42,6 @@ class CategoryTab(TabPage): self.setLayout(categoryLayout) - def onCategoryDeleteClicked(self): - pass - def onCategoryModifyClicked(self): # 创建添加数据对话框 self.cDialog = QDialog(self) @@ -83,15 +80,12 @@ class CategoryTab(TabPage): line3.setText(data[0][2]) button1 = QPushButton("Confirm") - button3 = QPushButton("Delete") button2 = QPushButton("Abort") buttonLayout = QHBoxLayout() buttonLayout.addWidget(button1) - buttonLayout.addWidget(button3) buttonLayout.addWidget(button2) button1.clicked.connect(self.cDialog.accept) - button3.clicked.connect(self.onCategoryDeleteClicked) button2.clicked.connect(self.cDialog.reject) layout = QFormLayout()