情况中的待执行优化好了
This commit is contained in:
67
gui_app.py
67
gui_app.py
@@ -1471,11 +1471,11 @@ class MainWindow(QMainWindow):
|
||||
try:
|
||||
if not item:
|
||||
return
|
||||
|
||||
|
||||
# 防止递归调用:如果正在更新中,跳过
|
||||
if self.is_updating_table:
|
||||
return
|
||||
|
||||
|
||||
# 检查 item 是否仍然有效(避免访问已删除的对象)
|
||||
try:
|
||||
row = item.row()
|
||||
@@ -1484,7 +1484,8 @@ class MainWindow(QMainWindow):
|
||||
except RuntimeError:
|
||||
# QTableWidgetItem 已被删除
|
||||
return
|
||||
|
||||
|
||||
# 第8列:情况列,联动进度列的显示
|
||||
if col == 8:
|
||||
# 设置标志,防止递归
|
||||
self.is_updating_table = True
|
||||
@@ -1493,7 +1494,8 @@ class MainWindow(QMainWindow):
|
||||
self._set_progress_item(row, text)
|
||||
finally:
|
||||
self.is_updating_table = False
|
||||
|
||||
|
||||
# 其它可编辑列:同步当前行到 configs
|
||||
self._sync_config_from_row(row)
|
||||
except Exception as e:
|
||||
logger.warning(f"表格项改变回调出错: {e}")
|
||||
@@ -1501,30 +1503,35 @@ class MainWindow(QMainWindow):
|
||||
self.is_updating_table = False
|
||||
|
||||
def _set_checkbox_item(self, row, config_index):
|
||||
"""设置勾选框列(第0列),勾选框在单元格内水平、垂直居中"""
|
||||
"""设置勾选框列(第0列),使用嵌套布局确保真正水平+垂直居中"""
|
||||
checkbox = QCheckBox()
|
||||
checkbox.setChecked(self.configs[config_index].get('勾选', False)) # 默认不勾选
|
||||
checkbox.stateChanged.connect(lambda state, idx=config_index: self._on_checkbox_changed(idx, state))
|
||||
checkbox.setStyleSheet(
|
||||
"QCheckBox { margin: 0px; padding: 0px; }"
|
||||
"QCheckBox::indicator { width: 25px; height: 25px; }"
|
||||
"QCheckBox::indicator { width: 20px; height: 20px; }"
|
||||
)
|
||||
|
||||
wrapper = QWidget()
|
||||
# 使用嵌套布局确保水平和垂直都居中
|
||||
outer_layout = QVBoxLayout(wrapper)
|
||||
outer_layout.setContentsMargins(0, 0, 0, 0)
|
||||
outer_layout.setSpacing(0)
|
||||
outer_layout.addStretch()
|
||||
|
||||
inner_layout = QHBoxLayout()
|
||||
inner_layout.setContentsMargins(0, 0, 0, 0)
|
||||
inner_layout.setSpacing(0)
|
||||
inner_layout.addStretch()
|
||||
inner_layout.addWidget(checkbox)
|
||||
inner_layout.addStretch()
|
||||
|
||||
outer_layout.addLayout(inner_layout)
|
||||
outer_layout.addStretch()
|
||||
wrapper.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||||
|
||||
# 外层垂直布局:通过上下 stretch 实现垂直居中
|
||||
v_layout = QVBoxLayout(wrapper)
|
||||
v_layout.setContentsMargins(0, 0, 0, 0)
|
||||
v_layout.setSpacing(0)
|
||||
v_layout.addStretch()
|
||||
|
||||
# 内层水平布局:通过左右 stretch 实现水平居中
|
||||
h_layout = QHBoxLayout()
|
||||
h_layout.setContentsMargins(0, 0, 0, 0)
|
||||
h_layout.setSpacing(0)
|
||||
h_layout.addStretch()
|
||||
h_layout.addWidget(checkbox)
|
||||
h_layout.addStretch()
|
||||
|
||||
v_layout.addLayout(h_layout)
|
||||
v_layout.addStretch()
|
||||
|
||||
self.config_table.setCellWidget(row, 0, wrapper)
|
||||
|
||||
def _on_checkbox_changed(self, config_index, state):
|
||||
@@ -1618,6 +1625,19 @@ class MainWindow(QMainWindow):
|
||||
self._update_checked_count()
|
||||
# 更新状态统计
|
||||
self._update_status_statistics()
|
||||
|
||||
# 重新应用筛选和高亮(保持原有的筛选状态)
|
||||
if has_search_filter:
|
||||
self.filter_table(self.table_search_input.text())
|
||||
elif has_status_filter:
|
||||
# 重新应用状态筛选(隐藏不匹配的行)
|
||||
for row in range(self.config_table.rowCount()):
|
||||
if row < len(self.page_row_indices):
|
||||
config_index = self.page_row_indices[row]
|
||||
if config_index < len(self.configs):
|
||||
config_status = self.configs[config_index].get('情况', '待执行')
|
||||
self.config_table.setRowHidden(row, config_status != self._current_status_filter)
|
||||
|
||||
if is_checked:
|
||||
self._show_infobar("success", "提示", f"已勾选 {visible_count} 行(跨页操作)")
|
||||
else:
|
||||
@@ -3444,6 +3464,11 @@ class MainWindow(QMainWindow):
|
||||
self._set_progress_item(table_row, str(config.get('情况', '待执行')))
|
||||
self._set_action_buttons(table_row, config_index)
|
||||
|
||||
# 确保所有行使用一致的行高
|
||||
default_row_height = self.config_table.verticalHeader().defaultSectionSize()
|
||||
for row in range(self.config_table.rowCount()):
|
||||
self.config_table.setRowHeight(row, default_row_height)
|
||||
|
||||
# 重新启用排序功能(但不会自动排序已填充的数据)
|
||||
self.config_table.setSortingEnabled(True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user