|
@@ -629,13 +629,13 @@ class MainWindow(QMainWindow):
|
629
|
629
|
# action_1.triggered.connect(lambda: self.do_something(index))
|
630
|
630
|
# menu.addAction(action_1)
|
631
|
631
|
# 添加菜单项和对应的操作
|
632
|
|
- action_1 = QAction("删除该行", self)
|
633
|
|
- action_1.triggered.connect(self.del_Dataclicked)
|
634
|
|
- menu.addAction(action_1)
|
635
|
632
|
action_2 = QAction("编辑单元格", self)
|
636
|
633
|
action_2.triggered.connect(self.edit_dataclicked)
|
637
|
634
|
menu.addAction(action_2)
|
638
|
|
- action_3 = QAction("添加数据", self)
|
|
635
|
+ action_1 = QAction("删除该行", self)
|
|
636
|
+ action_1.triggered.connect(self.del_Dataclicked)
|
|
637
|
+ menu.addAction(action_1)
|
|
638
|
+ action_3 = QAction("添加一行", self)
|
639
|
639
|
action_3.triggered.connect(self.add_Dataclicked)
|
640
|
640
|
menu.addAction(action_3)
|
641
|
641
|
menu.exec(self.ui.resultTableView1.mapToGlobal(pos))
|
|
@@ -1017,38 +1017,12 @@ class MainWindow(QMainWindow):
|
1017
|
1017
|
|
1018
|
1018
|
# 右键对应行可删除对应行
|
1019
|
1019
|
def del_Dataclicked(self):
|
1020
|
|
- select_item = self.ui.allTreeWidget.currentItem()
|
1021
|
|
- if select_item == None:
|
1022
|
|
- select_item = self.ui.qureyTreeWidget.currentItem()
|
1023
|
|
- # 获取数据库路径和表名
|
1024
|
|
- tablename = select_item.text(0)
|
1025
|
|
- tablename_utf8 = tablename.encode('utf-8')
|
1026
|
|
- # 获取父节点
|
1027
|
|
- parent_item = select_item.parent()
|
1028
|
|
- parent_name = parent_item.text(0)
|
1029
|
|
- dbname = parent_item.parent().text(0)
|
1030
|
|
- dbpath = os.path.join(os.path.abspath('../SQL'), f"{dbname}.db")
|
1031
|
1020
|
curIndex = self.selectModel.currentIndex()
|
1032
|
|
- # self.ui.resultTableView1.model().removeRow(curIndex.row())
|
1033
|
|
- col = curIndex.column()
|
1034
|
|
- row = curIndex.row()
|
1035
|
|
- # 重新组织表的内容,方便重新计算
|
1036
|
|
- UIFunctions.del_row_from_db(self, row, parent_name, tablename_utf8, dbpath)
|
1037
|
|
- # 1秒后自动跳转
|
1038
|
|
- QTimer.singleShot(1000, lambda: self.simulateButtonClick("btn_new"))
|
1039
|
|
- # 刷新树和tableview
|
1040
|
|
- self.refresh_tree()
|
1041
|
|
-
|
1042
|
|
- # 数据库路径,哪种方法,表名
|
1043
|
|
- self.selectModel = UIFunctions.search_data_to_show(self, dbpath, parent_name, tablename)
|
1044
|
|
- # self.ui.resultTableView1.doubleClicked.connect(self.seleceModel_itemclicked)
|
1045
|
|
-
|
1046
|
|
- # 设置右键菜单策略为CustomContextMenu
|
1047
|
|
- self.ui.resultTableView1.setContextMenuPolicy(Qt.CustomContextMenu)
|
1048
|
|
-
|
1049
|
|
- # 关联自定义的右键菜单方法到customContextMenuRequested信号
|
1050
|
|
- self.ui.resultTableView1.customContextMenuRequested.connect(self.show_custom_context_menu)
|
|
1021
|
+ self.ui.resultTableView1.model().removeRow(curIndex.row())
|
|
1022
|
+ # 所有条件都可以开启编辑
|
|
1023
|
+ self.ui.resultTableView1.setEditTriggers(QTableView.EditTrigger.AllEditTriggers)
|
1051
|
1024
|
|
|
1025
|
+ #编辑完了集中读取
|
1052
|
1026
|
def update_dataclicked(self):
|
1053
|
1027
|
inputmodel = self.ui.resultTableView1.model()
|
1054
|
1028
|
# 转化为list
|