|
@@ -14,7 +14,7 @@
|
14
|
14
|
#
|
15
|
15
|
# ///////////////////////////////////////////////////////////////
|
16
|
16
|
from PySide6.QtWidgets import QFileDialog,QWidget, QVBoxLayout, QTreeWidget, QApplication, QTreeWidgetItem
|
17
|
|
-from PySide6.QtCore import Signal, Slot,Qt,QObject
|
|
17
|
+from PySide6.QtCore import Signal, Qt, Slot, QObject
|
18
|
18
|
from PySide6.QtSql import QSqlTableModel,QSqlDatabase
|
19
|
19
|
import sqlite3
|
20
|
20
|
from PySide6.QtGui import QIcon
|
|
@@ -94,8 +94,6 @@ class ElTreeData(QObject):
|
94
|
94
|
"""
|
95
|
95
|
items_changed: Signal = Signal(str)
|
96
|
96
|
styleSheet_changed: Signal = Signal(str)
|
97
|
|
- itemClicked: Signal = Signal(object)
|
98
|
|
- itemDoubleClicked: Signal = Signal(object)
|
99
|
97
|
|
100
|
98
|
def __init__(self, items: list[TreeWidgetItem] = None, styleSheet: str = None):
|
101
|
99
|
super(ElTreeData, self).__init__()
|
|
@@ -175,7 +173,7 @@ class MainWindow(QMainWindow):
|
175
|
173
|
# 成果预览
|
176
|
174
|
widgets.btn_new.clicked.connect(self.buttonClick)
|
177
|
175
|
# 数据一览
|
178
|
|
-
|
|
176
|
+ widgets.btn_data.clicked.connect(self.buttonClick)
|
179
|
177
|
# 皮肤切换
|
180
|
178
|
widgets.btn_message.clicked.connect(self.buttonClick)
|
181
|
179
|
# 打开上传文件夹
|
|
@@ -194,6 +192,9 @@ class MainWindow(QMainWindow):
|
194
|
192
|
|
195
|
193
|
widgets.settingsTopBtn.clicked.connect(openCloseRightBox)
|
196
|
194
|
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
197
|
198
|
# 展示APP
|
198
|
199
|
# ///////////////////////////////////////////////////////////////
|
199
|
200
|
self.show()
|
|
@@ -223,13 +224,21 @@ class MainWindow(QMainWindow):
|
223
|
224
|
widgets.stackedWidget.setCurrentWidget(widgets.home)
|
224
|
225
|
widgets.btn_home.setStyleSheet(UIFunctions.selectMenu(widgets.btn_home.styleSheet()))
|
225
|
226
|
|
|
227
|
+ #初始化树状组件
|
|
228
|
+ #///////////////////////////////////////////////////////////////
|
|
229
|
+ self.itemClicked: Signal = Signal(object)
|
|
230
|
+ self.itemDoubleClicked: Signal = Signal(object)
|
|
231
|
+ sqll = self.sql_init()
|
|
232
|
+ sqltree = ElTreeData(items=sqll)
|
|
233
|
+ self.data = sqltree
|
|
234
|
+ # 将按钮的点击信号绑定到当前类的点击信号
|
|
235
|
+ # 信号改为展示方法,这里同导出展示
|
|
236
|
+ widgets.allTreeWidget.itemClicked.connect(lambda extend: print("单击->扩展数据为:", extend))
|
|
237
|
+ widgets.allTreeWidget.itemDoubleClicked.connect(lambda extend: print("双击->扩展数据为:", extend))
|
|
238
|
+ self.__render_items(True)
|
|
239
|
+
|
226
|
240
|
self.bind()
|
227
|
241
|
|
228
|
|
- #treewidget
|
229
|
|
- self.data = ElTreeData
|
230
|
|
- widgets.allTreeWidget.itemClicked.connect(lambda item: self.itemClicked.emit(item.data(0, Qt.UserRole + 1)))
|
231
|
|
- widgets.allTreeWidget.itemDoubleClicked.connect(lambda item: self.itemDoubleClicked.emit(item.data(0, Qt.UserRole + 1)))
|
232
|
|
- # self.__render_items(True)
|
233
|
242
|
|
234
|
243
|
def __render_items(self, is_clear: bool):
|
235
|
244
|
if is_clear:
|
|
@@ -257,8 +266,7 @@ class MainWindow(QMainWindow):
|
257
|
266
|
def bind(self):
|
258
|
267
|
# 计算
|
259
|
268
|
widgets.compute.clicked.connect(self.computeClick)
|
260
|
|
- #数据库展示(初始化)
|
261
|
|
- widgets.btn_data.clicked.connect(self.dataClick)
|
|
269
|
+ widgets.search.clicked.connect(self.searchClick)
|
262
|
270
|
|
263
|
271
|
#删除tableview
|
264
|
272
|
def delete_table_view(table_view):
|
|
@@ -508,23 +516,33 @@ class MainWindow(QMainWindow):
|
508
|
516
|
xx = xx + 1
|
509
|
517
|
return model
|
510
|
518
|
|
511
|
|
-
|
512
|
|
-
|
513
|
|
- def dataClick(self):
|
514
|
|
- # GET BUTTON CLICKED
|
515
|
|
- btn = self.sender()
|
516
|
|
- btnName = btn.objectName()
|
|
519
|
+ #设一个全局变量,存数据库中所有的包含内容(数据库-三种方法-表)
|
|
520
|
+ dblist = []
|
|
521
|
+ global dblist
|
|
522
|
+ #初始化数据一览(数据库全展示)
|
|
523
|
+ def sql_init(self):
|
517
|
524
|
#初始化全部数据库
|
518
|
525
|
inpath = r'D:\4work_now\20240819GS\20241211\SQL'
|
519
|
526
|
#读取所有的数据库名
|
520
|
|
- list1 = []
|
|
527
|
+ sqlitem = []
|
|
528
|
+ id = 1
|
521
|
529
|
for filename in os.listdir(inpath):
|
|
530
|
+ #数据库
|
522
|
531
|
dbname = filename.split('.',-1)[0]
|
523
|
532
|
dbpath = os.path.join(inpath,filename)
|
524
|
|
- lista = []
|
525
|
|
- lista.append(dbname)
|
526
|
|
- lista.append(dbpath)
|
527
|
|
- list1.append(lista)
|
|
533
|
+ sqlitem.append(TreeWidgetItem(id,0,dbname,icon=QIcon("D:/4work_now/20240819GS/20241211/Front/images/icons/cil-clone.png")))
|
|
534
|
+ pid = id
|
|
535
|
+ id = id + 1
|
|
536
|
+ #三种方法
|
|
537
|
+ sqlitem.append(TreeWidgetItem(id, pid, '水准测段高差稳定计算', icon=QIcon("D:/4work_now/20240819GS/20241211/Front/images/icons/cil-description.png")))
|
|
538
|
+ gcid = id
|
|
539
|
+ id = id + 1
|
|
540
|
+ sqlitem.append(TreeWidgetItem(id, pid, '控制网复测平面基准计算', icon=QIcon("D:/4work_now/20240819GS/20241211/Front/images/icons/cil-description.png")))
|
|
541
|
+ gsid = id
|
|
542
|
+ id = id + 1
|
|
543
|
+ sqlitem.append(TreeWidgetItem(id, pid, '平面控制网稳定性计算', icon=QIcon("D:/4work_now/20240819GS/20241211/Front/images/icons/cil-description.png")))
|
|
544
|
+ wdid = id
|
|
545
|
+ id = id + 1
|
528
|
546
|
#读取所有的表名(三种方式往下)
|
529
|
547
|
db1 = sqlite3.connect(dbpath)
|
530
|
548
|
#获取游标
|
|
@@ -532,31 +550,90 @@ class MainWindow(QMainWindow):
|
532
|
550
|
sqlstr1 = 'SELECT TableName FROM GC_Input_Param;'
|
533
|
551
|
cursor1.execute(sqlstr1)
|
534
|
552
|
result1 = cursor1.fetchall()
|
|
553
|
+ for re1 in result1:
|
|
554
|
+ str1 = re1[0].decode('utf-8')
|
|
555
|
+ sqlitem.append(TreeWidgetItem(id, gcid, str1, icon=QIcon("D:/4work_now/20240819GS/20241211/Front/images/icons/cil-file.png"),extend=str1))
|
|
556
|
+ list1 = []
|
|
557
|
+ list1.append(dbname)
|
|
558
|
+ list1.append('水准测段高差稳定计算')
|
|
559
|
+ list1.append(str1)
|
|
560
|
+ dblist.append(list1)
|
|
561
|
+ id = id + 1
|
535
|
562
|
sqlstr2 = 'SELECT TableName FROM GS_Input_Param;'
|
536
|
563
|
cursor1.execute(sqlstr2)
|
537
|
564
|
result2 = cursor1.fetchall()
|
|
565
|
+ for re2 in result2:
|
|
566
|
+ str2 = re2[0].decode('utf-8')
|
|
567
|
+ sqlitem.append(TreeWidgetItem(id, gsid, str2, icon=QIcon("D:/4work_now/20240819GS/20241211/Front/images/icons/cil-file.png"),extend=str2))
|
|
568
|
+ list2 = []
|
|
569
|
+ list2.append(dbname)
|
|
570
|
+ list2.append('控制网复测平面基准计算')
|
|
571
|
+ list2.append(str2)
|
|
572
|
+ dblist.append(list2)
|
|
573
|
+ id = id + 1
|
538
|
574
|
sqlstr3 = 'SELECT TableName FROM WD_Input_Param;'
|
539
|
575
|
cursor1.execute(sqlstr3)
|
540
|
576
|
result3 = cursor1.fetchall()
|
541
|
|
- atw_button = ElTreeData(items=[
|
542
|
|
- TreeWidgetItem(1, 0, "User", icon=QIcon("D:/4work_now/20240819GS/20241211/Front/images/icons/cil_file.png"), extend={'id': 1}),
|
543
|
|
- TreeWidgetItem(2, 1, "Child", icon=QIcon("D:/4work_now/20240819GS/20241211/Front/images/icons/cil_file.png"), extend={'id': 2}),
|
544
|
|
- TreeWidgetItem(3, 1, "Child", icon=QIcon("D:/4work_now/20240819GS/20241211/Front/images/icons/cil_file.png"), extend={'id': 3}),
|
545
|
|
- TreeWidgetItem(4, 2, "Child", icon=QIcon("D:/4work_now/20240819GS/20241211/Front/images/icons/cil_file.png"), extend={'id': 4}),
|
546
|
|
- TreeWidgetItem(5, 2, "Child", icon=QIcon("D:/4work_now/20240819GS/20241211/Front/images/icons/cil_file.png"), extend={'id': 5}),
|
547
|
|
- TreeWidgetItem(6, 5, "Child", icon=QIcon("D:/4work_now/20240819GS/20241211/Front/images/icons/cil_file.png"), extend={'id': 6}),
|
548
|
|
- TreeWidgetItem(7, 5, "Child", extend={'id': 7}),
|
549
|
|
- TreeWidgetItem(8, 5, "Child", extend={'id': 8}),
|
550
|
|
- TreeWidgetItem(9, 8, "Child", extend={'id': 9}),
|
551
|
|
- ])
|
552
|
|
-
|
553
|
|
- # atw_button.itemClicked.connect(lambda extend: print("单击->扩展数据为:", extend))
|
554
|
|
- # atw_button.itemDoubleClicked.connect(lambda extend: print("双击->扩展数据为:", extend))
|
555
|
|
- # atw_button.show()
|
556
|
|
- widgets.stackedWidget.setCurrentWidget(widgets.datainfo)
|
557
|
|
- UIFunctions.resetStyle(self, btnName) # RESET ANOTHERS BUTTONS SELECTED
|
558
|
|
- btn.setStyleSheet(UIFunctions.selectMenu(btn.styleSheet()))
|
559
|
|
-
|
|
577
|
+ for re3 in result3:
|
|
578
|
+ str3 = re3[0].decode('utf-8')
|
|
579
|
+ sqlitem.append(TreeWidgetItem(id, wdid, str3, icon=QIcon("D:/4work_now/20240819GS/20241211/Front/images/icons/cil-file.png"),extend=str3))
|
|
580
|
+ list3 = []
|
|
581
|
+ list3.append(dbname)
|
|
582
|
+ list3.append('平面控制网稳定性计算')
|
|
583
|
+ list3.append(str3)
|
|
584
|
+ dblist.append(list3)
|
|
585
|
+ id = id + 1
|
|
586
|
+ return sqlitem
|
|
587
|
+
|
|
588
|
+ #关键词查询
|
|
589
|
+ def sql_search(self):
|
|
590
|
+ # GET BUTTON CLICKED
|
|
591
|
+ btn = self.sender()
|
|
592
|
+ btnName = btn.objectName()
|
|
593
|
+ #获取文本
|
|
594
|
+ text1 = self.ui.lineEdit_2.text()
|
|
595
|
+ #符合的list
|
|
596
|
+ fhlist = []
|
|
597
|
+ #查询(待优化)
|
|
598
|
+ for list1 in dblist:
|
|
599
|
+ for li in list1:
|
|
600
|
+ if text1 in li:
|
|
601
|
+ fhlist.append(list1)
|
|
602
|
+ break
|
|
603
|
+ #更新item值
|
|
604
|
+ sqlitem = []
|
|
605
|
+ #前两层是否一致
|
|
606
|
+ str1 = ''
|
|
607
|
+ str2 = ''
|
|
608
|
+ id = 1
|
|
609
|
+ pid = 0
|
|
610
|
+ fid = 0
|
|
611
|
+ for list2 in fhlist:
|
|
612
|
+ dbname = list2[0]
|
|
613
|
+ if dbname != str1:
|
|
614
|
+ str1 = dbname
|
|
615
|
+ sqlitem.append(TreeWidgetItem(id, 0, dbname, icon=QIcon(
|
|
616
|
+ "D:/4work_now/20240819GS/20241211/Front/images/icons/cil-clone.png")))
|
|
617
|
+ pid = id
|
|
618
|
+ id = id + 1
|
|
619
|
+ mename = list2[1]
|
|
620
|
+ if mename != str2:
|
|
621
|
+ str2 = mename
|
|
622
|
+ sqlitem.append(TreeWidgetItem(id, pid, mename, icon=QIcon(
|
|
623
|
+ "D:/4work_now/20240819GS/20241211/Front/images/icons/cil-description.png")))
|
|
624
|
+ fid = id
|
|
625
|
+ id = id + 1
|
|
626
|
+ sqlitem.append(TreeWidgetItem(id, fid, list2[2], icon=QIcon(
|
|
627
|
+ "D:/4work_now/20240819GS/20241211/Front/images/icons/cil-file.png"), extend=list2[2]))
|
|
628
|
+ #展示
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+ #直接这个基础上改点选输出表格(未改)
|
560
|
637
|
def computeClick(self):
|
561
|
638
|
# GET BUTTON CLICKED
|
562
|
639
|
btn = self.sender()
|