@@ -741,6 +741,7 @@ def search_tab_change(self, index):
741
741
self .search_window .last_tab = index
742
742
743
743
def do_replace (self ):
744
+ global data_list
744
745
logger .info (f'do_replace() 替换当前单元格内容' )
745
746
source_text = self .search_window .text_edit_list [self .search_window .last_tab ].text ()
746
747
if not source_text :
@@ -750,10 +751,12 @@ def do_replace(self):
750
751
pat = re .compile (re .escape (source_text ), re .IGNORECASE )
751
752
result = pat .sub (target_text , self .tableWidget .currentItem ().text ())
752
753
logger .info (result )
754
+ data_list [self .tableWidget .currentItem ().row ()][self .tableWidget .currentItem ().column ()] = result
753
755
self .tableWidget .currentItem ().setText (result )
754
756
self .do_search ()
755
757
756
758
def do_replace_all (self ):
759
+ global data_list
757
760
logger .info (f'do_replace_all() 替换全部单元格内容' )
758
761
source_text = self .search_window .text_edit_list [self .search_window .last_tab ].text ()
759
762
if not source_text :
@@ -776,6 +779,8 @@ def do_replace_all(self):
776
779
item = QTableWidgetItem (d )
777
780
if cy in config ['center_columns' ]:
778
781
item .setTextAlignment (Qt .AlignCenter )
782
+ # 注意这里要更新data_list的数据
783
+ data_list [cx ][cy ] = d
779
784
self .tableWidget .setItem (cx , cy , item )
780
785
781
786
self .tableWidget .blockSignals (False )
@@ -992,6 +997,7 @@ def on_save_click(self):
992
997
993
998
@pyqtSlot ()
994
999
def on_clean_row_click (self ):
1000
+ global data_list
995
1001
# 防止触发 cellChange 事件导致重复更新
996
1002
self .tableWidget .blockSignals (True )
997
1003
data_list = clean_data_list ()
0 commit comments