瀏覽代碼

Merge branch 'master' of http://oa.sccehui.com:6101/cmc-coding2/ControlNetwork

wzp 5 月之前
父節點
當前提交
226d507393
共有 5 個檔案被更改,包括 90 行新增6 行删除
  1. 6
    0
      Back/GC/GCshow.py
  2. 14
    1
      Back/GS/GSshow.py
  3. 14
    0
      Back/WD/WDshow.py
  4. 47
    1
      Front/main.py
  5. 9
    4
      Front/modules/ui_functions.py

+ 6
- 0
Back/GC/GCshow.py 查看文件

1
 import sqlite3
1
 import sqlite3
2
 
2
 
3
 from PySide6.QtGui import QStandardItemModel, QStandardItem
3
 from PySide6.QtGui import QStandardItemModel, QStandardItem
4
+from PySide6.QtCore import QItemSelectionModel
4
 
5
 
5
 
6
 
6
 def main_function(ui, db_path, utf_en):
7
 def main_function(ui, db_path, utf_en):
167
     ui.reconTableView1.setModel(output_model)
168
     ui.reconTableView1.setModel(output_model)
168
     ui.reconTableView1.show()
169
     ui.reconTableView1.show()
169
 
170
 
171
+    # 返回一个选择模型
172
+    selectionModel = QItemSelectionModel(input_model)  # Item选择模型
173
+    ui.resultTableView1.setSelectionModel(selectionModel)
174
+    return selectionModel
175
+
170
     # 关闭数据库连接
176
     # 关闭数据库连接
171
     cursor1.close()
177
     cursor1.close()
172
     db1.close()
178
     db1.close()

+ 14
- 1
Back/GS/GSshow.py 查看文件

2
 
2
 
3
 from PySide6.QtGui import QStandardItemModel
3
 from PySide6.QtGui import QStandardItemModel
4
 from Back.Program_Run.data_show import *
4
 from Back.Program_Run.data_show import *
5
-
5
+from PySide6.QtCore import QItemSelectionModel
6
 
6
 
7
 def main_function(ui, db_path, utf_en):
7
 def main_function(ui, db_path, utf_en):
8
     # 就用已有的选项卡
8
     # 就用已有的选项卡
84
 
84
 
85
     ui.printTableView.setHtml(str0)
85
     ui.printTableView.setHtml(str0)
86
 
86
 
87
+    # 关闭数据库连接
88
+    cursor1.close()
89
+    db1.close()
90
+
87
 
91
 
88
 def search_show_function(ui, db_path, utf_en):
92
 def search_show_function(ui, db_path, utf_en):
89
     # 就用已有的选项卡
93
     # 就用已有的选项卡
182
 <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt;">          </span><span style=" font-size:14pt; font-weight:700;">X、Y</span><span style=" font-size:14pt;">为{str1}已知系统的{str2}归算坐标。</span></p></body></html>"""
186
 <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt;">          </span><span style=" font-size:14pt; font-weight:700;">X、Y</span><span style=" font-size:14pt;">为{str1}已知系统的{str2}归算坐标。</span></p></body></html>"""
183
 
187
 
184
     ui.printTableView1.setHtml(str0)
188
     ui.printTableView1.setHtml(str0)
189
+
190
+    # 关闭数据库连接
191
+    cursor1.close()
192
+    db1.close()
193
+
194
+    # 返回一个选择模型
195
+    selectionModel = QItemSelectionModel(model0)  # Item选择模型
196
+    ui.resultTableView1.setSelectionModel(selectionModel)
197
+    return selectionModel

+ 14
- 0
Back/WD/WDshow.py 查看文件

2
 import sqlite3
2
 import sqlite3
3
 
3
 
4
 from PySide6.QtGui import QStandardItemModel
4
 from PySide6.QtGui import QStandardItemModel
5
+from PySide6.QtCore import QItemSelectionModel
5
 
6
 
6
 
7
 
7
 # 计算结束后的显示
8
 # 计算结束后的显示
74
 <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt;">          </span><span style=" font-size:14pt; font-weight:700;">X、Y</span><span style=" font-size:14pt;">为""" + str1 + """已知系统的""" + str2 + """归算坐标。</span></p></body></html>"""
75
 <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt;">          </span><span style=" font-size:14pt; font-weight:700;">X、Y</span><span style=" font-size:14pt;">为""" + str1 + """已知系统的""" + str2 + """归算坐标。</span></p></body></html>"""
75
     ui.printTableView.setHtml(str0)
76
     ui.printTableView.setHtml(str0)
76
 
77
 
78
+    # 关闭数据库连接
79
+    cursor1.close()
80
+    db1.close()
81
+
77
 
82
 
78
 def search_show_function(ui, db_path, utf_en):
83
 def search_show_function(ui, db_path, utf_en):
79
     # 只显示头两个tab
84
     # 只显示头两个tab
165
 <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt;">式中:</span><span style=" font-size:14pt; font-weight:700; color:#000000;">x、y</span><span style=" font-size:14pt;">为</span><span style=" font-size:14pt; color:#000000;">""" + str2 + """</span><span style=" font-size:14pt;">坐标;</span></p>
170
 <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt;">式中:</span><span style=" font-size:14pt; font-weight:700; color:#000000;">x、y</span><span style=" font-size:14pt;">为</span><span style=" font-size:14pt; color:#000000;">""" + str2 + """</span><span style=" font-size:14pt;">坐标;</span></p>
166
 <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt;">          </span><span style=" font-size:14pt; font-weight:700;">X、Y</span><span style=" font-size:14pt;">为""" + str1 + """已知系统的""" + str2 + """归算坐标。</span></p></body></html>"""
171
 <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt;">          </span><span style=" font-size:14pt; font-weight:700;">X、Y</span><span style=" font-size:14pt;">为""" + str1 + """已知系统的""" + str2 + """归算坐标。</span></p></body></html>"""
167
     ui.printTableView1.setHtml(str0)
172
     ui.printTableView1.setHtml(str0)
173
+
174
+    # 关闭数据库连接
175
+    cursor1.close()
176
+    db1.close()
177
+
178
+    #返回一个选择模型
179
+    selectionModel = QItemSelectionModel(model0)  # Item选择模型
180
+    ui.resultTableView1.setSelectionModel(selectionModel)
181
+    return selectionModel

+ 47
- 1
Front/main.py 查看文件

469
         # tree_button.itemClicked.connect(self.itembuttonClick)
469
         # tree_button.itemClicked.connect(self.itembuttonClick)
470
         # tree_button.itemDoubleClicked.connect(self.itembuttonClick)
470
         # tree_button.itemDoubleClicked.connect(self.itembuttonClick)
471
 
471
 
472
+
473
+    #单元格的右键
474
+    def show_custom_context_menu(self, pos):
475
+        # 创建一个右键菜单
476
+        menu = QMenu(self.ui.resultTableView1)
477
+        menu.setStyleSheet("QMenu { background-color: #FFFFFF; }")
478
+        # 获取选中单元格的索引
479
+        index = self.ui.resultTableView1.indexAt(pos)
480
+        # # 添加菜单项和对应的操作
481
+        # action_1 = QAction("操作1", self)
482
+        # action_1.triggered.connect(lambda: self.do_something(index))
483
+        # menu.addAction(action_1)
484
+        # 添加菜单项和对应的操作
485
+        action_1 = QAction("删除该行", self)
486
+        action_1.triggered.connect(self.seleceModel_itemclicked)
487
+        menu.addAction(action_1)
488
+        action_2 = QAction("编辑单元格", self)
489
+        action_2.triggered.connect(self.seleceModel_itemclicked)
490
+        menu.addAction(action_2)
491
+        action_3 = QAction("添加数据", self)
492
+        action_3.triggered.connect(self.seleceModel_itemclicked)
493
+        menu.addAction(action_3)
494
+        menu.exec(self.ui.resultTableView1.mapToGlobal(pos))
495
+
472
     def closeEvent(self, event):
496
     def closeEvent(self, event):
473
         # 停止监控
497
         # 停止监控
474
         self.observer.stop()
498
         self.observer.stop()
754
         # 隐藏默认label
778
         # 隐藏默认label
755
         self.ui.defaultLabel.setVisible(False)
779
         self.ui.defaultLabel.setVisible(False)
756
 
780
 
781
+
782
+
757
     # 全树的item展示
783
     # 全树的item展示
758
     def itembuttonClick(self):
784
     def itembuttonClick(self):
759
         # 判定是否获取的是根节点
785
         # 判定是否获取的是根节点
781
             inpath = os.path.abspath('../SQL')
807
             inpath = os.path.abspath('../SQL')
782
             file_path = inpath + '/' + str3 + '.db'
808
             file_path = inpath + '/' + str3 + '.db'
783
             # 数据库路径,哪种方法,表名
809
             # 数据库路径,哪种方法,表名
784
-            UIFunctions.search_data_to_show(self, file_path, current_text, str1)
810
+            self.selectModel = UIFunctions.search_data_to_show(self, file_path, current_text, str1)
811
+            # self.ui.resultTableView1.doubleClicked.connect(self.seleceModel_itemclicked)
812
+
813
+            # 设置右键菜单策略为CustomContextMenu
814
+            self.ui.resultTableView1.setContextMenuPolicy(Qt.CustomContextMenu)
815
+
816
+            # 关联自定义的右键菜单方法到customContextMenuRequested信号
817
+            self.ui.resultTableView1.customContextMenuRequested.connect(self.show_custom_context_menu)
818
+
819
+    #右键对应行可删除对应行(只是视图上)
820
+    def seleceModel_itemclicked(self):
821
+        curIndex = self.selectModel.currentIndex()
822
+        self.ui.resultTableView1.model().removeRow(curIndex.row())
823
+        kk = 1
785
 
824
 
786
     # 搜索的item展示
825
     # 搜索的item展示
787
     def itembuttonClick1(self):
826
     def itembuttonClick1(self):
811
             file_path = inpath + '/' + str3 + '.db'
850
             file_path = inpath + '/' + str3 + '.db'
812
             # 数据库路径,哪种方法,表名
851
             # 数据库路径,哪种方法,表名
813
             UIFunctions.search_data_to_show(self, file_path, current_text, str1)
852
             UIFunctions.search_data_to_show(self, file_path, current_text, str1)
853
+            # self.ui.resultTableView1.doubleClicked.connect(self.seleceModel_itemclicked)
854
+
855
+            # 设置右键菜单策略为CustomContextMenu
856
+            self.ui.resultTableView1.setContextMenuPolicy(Qt.CustomContextMenu)
857
+
858
+            # 关联自定义的右键菜单方法到customContextMenuRequested信号
859
+            self.ui.resultTableView1.customContextMenuRequested.connect(self.show_custom_context_menu)
814
 
860
 
815
     # 键盘回车事件,目前用于搜索按钮
861
     # 键盘回车事件,目前用于搜索按钮
816
     def datainfo_keyPressEvent(self, event):
862
     def datainfo_keyPressEvent(self, event):

+ 9
- 4
Front/modules/ui_functions.py 查看文件

20
 
20
 
21
 from main import *
21
 from main import *
22
 import importlib
22
 import importlib
23
+
24
+from select import select
25
+
23
 from Back.GC import GC, GCExport
26
 from Back.GC import GC, GCExport
24
 from Back.GS import GS, GSExport
27
 from Back.GS import GS, GSExport
25
 from Back.WD import WD, WDExport
28
 from Back.WD import WD, WDExport
365
     # 数据一览,点击查询
368
     # 数据一览,点击查询
366
     def search_data_to_show(self, file_path, current_text, tablename):
369
     def search_data_to_show(self, file_path, current_text, tablename):
367
         utf_en = tablename.encode('utf-8')  # 转换文件名为utf-8编码形式
370
         utf_en = tablename.encode('utf-8')  # 转换文件名为utf-8编码形式
368
-        # 高差部分我没改
369
         if current_text == "水准测段高差稳定计算":
371
         if current_text == "水准测段高差稳定计算":
370
-            GCshow.search_show_function(self.ui, file_path, utf_en)
372
+            selectModel = GCshow.search_show_function(self.ui, file_path, utf_en)
373
+            return selectModel
371
         elif current_text == "控制网复测平面基准计算":
374
         elif current_text == "控制网复测平面基准计算":
372
-            GSshow.search_show_function(self.ui, file_path, utf_en)
375
+            selectModel = GSshow.search_show_function(self.ui, file_path, utf_en)
376
+            return selectModel
373
         elif current_text == "平面控制网稳定性计算":
377
         elif current_text == "平面控制网稳定性计算":
374
-            WDshow.search_show_function(self.ui, file_path, utf_en)
378
+            selectModel = WDshow.search_show_function(self.ui, file_path, utf_en)
379
+            return selectModel
375
     # END - GUI DEFINITIONS
380
     # END - GUI DEFINITIONS

Loading…
取消
儲存