|
@@ -227,7 +227,10 @@ class MainWindow(QMainWindow):
|
227
|
227
|
# ...此处为省略代码...
|
228
|
228
|
global widgets
|
229
|
229
|
widgets = self.ui
|
230
|
|
-
|
|
230
|
+ widgets.search.clicked.connect(self.buttonClick)
|
|
231
|
+ # 设置 datainfo 页面的焦点策略,使其能够捕获键盘事件
|
|
232
|
+ widgets.datainfo.setFocusPolicy(Qt.StrongFocus)
|
|
233
|
+ widgets.datainfo.keyPressEvent = self.datainfo_keyPressEvent
|
231
|
234
|
# 是否使用系统自带标题栏 True是不使用,False使用
|
232
|
235
|
# ///////////////////////////////////////////////////////////////
|
233
|
236
|
Settings.ENABLE_CUSTOM_TITLE_BAR = True
|
|
@@ -584,7 +587,8 @@ class MainWindow(QMainWindow):
|
584
|
587
|
search_button = ElTree1(ElTreeData(sqlitem))
|
585
|
588
|
search_button.itemClicked.connect(self.itembuttonClick1)
|
586
|
589
|
search_button.itemDoubleClicked.connect(self.itembuttonClick1)
|
587
|
|
-
|
|
590
|
+ # 隐藏默认label
|
|
591
|
+ self.ui.defaultLabel.setVisible(False)
|
588
|
592
|
# 全树的item展示
|
589
|
593
|
def itembuttonClick(self):
|
590
|
594
|
# 判定是否获取的是根节点
|
|
@@ -592,6 +596,8 @@ class MainWindow(QMainWindow):
|
592
|
596
|
select_item = self.ui.allTreeWidget.currentItem()
|
593
|
597
|
# 获取点击的item的text和它对应的上两个节点
|
594
|
598
|
str1 = select_item.text(0)
|
|
599
|
+ current_text = '' # 初始化 current_text
|
|
600
|
+ str3 = '' # 初始化 str3
|
595
|
601
|
try:
|
596
|
602
|
pa_item = select_item.parent()
|
597
|
603
|
current_text = pa_item.text(0)
|
|
@@ -619,6 +625,8 @@ class MainWindow(QMainWindow):
|
619
|
625
|
select_item = self.ui.qureyTreeWidget.currentItem()
|
620
|
626
|
# 获取点击的item的text和它对应的上两个节点
|
621
|
627
|
str1 = select_item.text(0)
|
|
628
|
+ current_text = '' # 初始化 current_text
|
|
629
|
+ str3 = '' # 初始化 str3
|
622
|
630
|
try:
|
623
|
631
|
pa_item = select_item.parent()
|
624
|
632
|
current_text = pa_item.text(0)
|
|
@@ -639,6 +647,16 @@ class MainWindow(QMainWindow):
|
639
|
647
|
# 数据库路径,哪种方法,表名
|
640
|
648
|
UIFunctions.search_data_to_show(self, file_path, current_text, str1)
|
641
|
649
|
|
|
650
|
+# 键盘回车事件,目前用于搜索按钮
|
|
651
|
+ def datainfo_keyPressEvent(self, event):
|
|
652
|
+ if event.key() == Qt.Key_Return or event.key() == Qt.Key_Enter:
|
|
653
|
+ # 检查 lineEdit_2 中是否有内容
|
|
654
|
+ if widgets.lineEdit_2.text():
|
|
655
|
+ # 模拟 search 按钮点击事件
|
|
656
|
+ self.ui.search.click()
|
|
657
|
+ else:
|
|
658
|
+ # 调用默认的 keyPressEvent 处理其他按键事件
|
|
659
|
+ super(widgets.datainfo.__class__, widgets.datainfo).keyPressEvent(event)
|
642
|
660
|
|
643
|
661
|
if __name__ == "__main__":
|
644
|
662
|
app = QApplication(sys.argv)
|