fix: step13 auto-detect report mode on panel load (in _auto_pull_work_dir), not just on generate click
This commit is contained in:
@ -362,13 +362,25 @@ class Step13ReportPanel(QWidget):
|
||||
self.work_dir_edit.setText(str(work_dir))
|
||||
|
||||
def _auto_pull_work_dir(self):
|
||||
"""从主窗口自动同步工作目录到 work_dir_edit(无需用户操作)。"""
|
||||
"""从主窗口自动同步工作目录到 work_dir_edit,并自动检测报告模式。"""
|
||||
mw = self.main_window
|
||||
if mw is not None and getattr(mw, "work_dir", None):
|
||||
wd = str(mw.work_dir)
|
||||
cur = self.work_dir_edit.text().strip()
|
||||
if wd and wd != cur:
|
||||
self.work_dir_edit.setText(wd)
|
||||
# 自动检测报告模式(参考 Step11 逻辑)
|
||||
self._auto_detect_report_mode(wd)
|
||||
|
||||
def _auto_detect_report_mode(self, wd: str):
|
||||
"""根据工作目录内容自动选择报告模式下拉框"""
|
||||
wd_path = Path(wd)
|
||||
ml_dir = wd_path / "9_ML_Prediction"
|
||||
formula_dir = wd_path / "10_WaterIndex_CSV"
|
||||
if ml_dir.is_dir() and list(ml_dir.glob("*.csv")):
|
||||
self.report_mode_cb.setCurrentIndex(0) # ML
|
||||
elif formula_dir.is_dir() and list(formula_dir.glob("*.csv")):
|
||||
self.report_mode_cb.setCurrentIndex(1) # 公式
|
||||
|
||||
def update_from_config(self, work_dir=None, pipeline=None):
|
||||
"""切入面板时由主窗口统一调用,把当前 work_dir 同步到本面板。
|
||||
@ -418,15 +430,6 @@ class Step13ReportPanel(QWidget):
|
||||
)
|
||||
return
|
||||
|
||||
# 自动检测报告模式(参考 Step11 逻辑)
|
||||
wd_path = Path(wd)
|
||||
ml_dir = wd_path / "9_ML_Prediction"
|
||||
formula_dir = wd_path / "10_WaterIndex_CSV"
|
||||
if ml_dir.is_dir() and list(ml_dir.glob("*.csv")):
|
||||
self.report_mode_cb.setCurrentIndex(0) # ML
|
||||
elif formula_dir.is_dir() and list(formula_dir.glob("*.csv")):
|
||||
self.report_mode_cb.setCurrentIndex(1) # 公式
|
||||
|
||||
if self._report_thread and self._report_thread.isRunning():
|
||||
QMessageBox.information(self, "提示", "报告正在生成中,请稍候。")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user