feat(DBNMQTTool): 脱机日志翻页 — 上一页/下一页 + 自动填充起始序号 (2026-08-18)
- 按钮行新增 ◀上一页/下一页▶ (拉取成功后启用) - 下一页: 锚点 = 当前页最后一条 seq+1 (快照/事件流均精确), 空记录按 start+count 步进 - 上一页: max(1, 当前起始-条数), 边界保护 - offscreen 6 场景验证全过
This commit is contained in:
@@ -363,18 +363,30 @@ class MainWindow(QMainWindow):
|
||||
btn_row6 = QHBoxLayout()
|
||||
b9 = QPushButton("统计")
|
||||
b9.clicked.connect(self._query_log_stat)
|
||||
self._btn_log_prev = QPushButton("◀ 上一页")
|
||||
self._btn_log_prev.clicked.connect(self._page_log_prev)
|
||||
self._btn_log_prev.setEnabled(False)
|
||||
self._btn_log_prev.setToolTip("起始序号 = 当前页第一条 - 条数(下限 1)")
|
||||
b10 = QPushButton("拉取日志")
|
||||
b10.clicked.connect(self._query_log)
|
||||
self._btn_log_next = QPushButton("下一页 ▶")
|
||||
self._btn_log_next.clicked.connect(self._page_log_next)
|
||||
self._btn_log_next.setEnabled(False)
|
||||
self._btn_log_next.setToolTip("起始序号 = 当前页最后一条 seq + 1")
|
||||
b11 = QPushButton("清除日志")
|
||||
b11.clicked.connect(self._clear_log)
|
||||
btn_row6.addWidget(b9)
|
||||
btn_row6.addWidget(self._btn_log_prev)
|
||||
btn_row6.addWidget(b10)
|
||||
btn_row6.addWidget(self._btn_log_next)
|
||||
btn_row6.addWidget(b11)
|
||||
btn_row6.addStretch()
|
||||
g6_layout.addLayout(btn_row6, 1, 0, 1, 4)
|
||||
|
||||
self._log_rec_text = QPlainTextEdit()
|
||||
self._log_rec_text.setReadOnly(True)
|
||||
# 脱机日志翻页状态 (翻页锚点)
|
||||
self._log_page_last_seq = 0 # 当前页最后一条 seq; 0 = 无有效页
|
||||
self._log_rec_text.setMaximumHeight(150)
|
||||
self._log_rec_text.setFont(QFont("Consolas", 9))
|
||||
g6_layout.addWidget(self._log_rec_text, 2, 0, 1, 4)
|
||||
@@ -1158,6 +1170,26 @@ class MainWindow(QMainWindow):
|
||||
stream=self._selected_log_stream(),
|
||||
))
|
||||
|
||||
def _page_log_prev(self):
|
||||
"""上一页: 起始序号 = max(1, 当前起始 - 条数), 自动拉取"""
|
||||
start = self._edit_log_start_seq.value()
|
||||
count = self._edit_log_count.value()
|
||||
new_start = max(1, start - count)
|
||||
self._edit_log_start_seq.setValue(new_start)
|
||||
self._log(f"翻页: 上一页 → 起始序号 {new_start}")
|
||||
self._query_log()
|
||||
|
||||
def _page_log_next(self):
|
||||
"""下一页: 起始序号 = 当前页最后一条 seq + 1, 自动拉取"""
|
||||
if self._log_page_last_seq > 0:
|
||||
new_start = self._log_page_last_seq + 1
|
||||
else:
|
||||
# 无有效页锚点 (拉取返回空), 按页大小步进
|
||||
new_start = self._edit_log_start_seq.value() + self._edit_log_count.value()
|
||||
self._edit_log_start_seq.setValue(new_start)
|
||||
self._log(f"翻页: 下一页 → 起始序号 {new_start}")
|
||||
self._query_log()
|
||||
|
||||
def _clear_log(self):
|
||||
"""log_clear: 清除脱机日志 (按当前流, 审计留痕, 设备侧阻塞)"""
|
||||
stream = self._selected_log_stream()
|
||||
@@ -1230,6 +1262,14 @@ class MainWindow(QMainWindow):
|
||||
self._log_rec_text.setPlainText("\n".join(lines))
|
||||
self._log(f"log_query[{stream_name}]: start_seq={start_seq} got {len(records)}")
|
||||
|
||||
# 更新翻页状态: 锚点 = 当前页最后一条 seq; 拉取成功即启用翻页按钮
|
||||
if records:
|
||||
self._log_page_last_seq = records[-1].get("seq", 0)
|
||||
else:
|
||||
self._log_page_last_seq = 0
|
||||
self._btn_log_prev.setEnabled(True)
|
||||
self._btn_log_next.setEnabled(True)
|
||||
|
||||
# ================================================================
|
||||
# UI 更新
|
||||
# ================================================================
|
||||
|
||||
Reference in New Issue
Block a user