fix: show complete CBB result details
This commit is contained in:
1 parent
86837155ea
commit
2d6acc1180
2 files changed
+64
-3
No files matched your search
@@ -11,11 +11,11 @@ import json
|
|||||||
from cbb_refresh_verify.operation_queue import BatchTaskContext, QueueCancelled, TaskHandoff
|
from cbb_refresh_verify.operation_queue import BatchTaskContext, QueueCancelled, TaskHandoff
|
||||||
|
|
||||||
from PySide6.QtCore import QObject, QThreadPool, Signal, Qt, QTimer
|
from PySide6.QtCore import QObject, QThreadPool, Signal, Qt, QTimer
|
||||||
from PySide6.QtGui import QColor, QIcon
|
from PySide6.QtGui import QColor, QIcon, QTextCursor
|
||||||
from PySide6.QtWidgets import (QWidget, QLineEdit, QPushButton, QFormLayout,
|
from PySide6.QtWidgets import (QWidget, QLineEdit, QPushButton, QFormLayout,
|
||||||
QTextEdit, QFileDialog, QHBoxLayout, QLabel, QSpinBox, QMessageBox, QToolButton,
|
QTextEdit, QFileDialog, QHBoxLayout, QLabel, QSpinBox, QMessageBox, QToolButton,
|
||||||
QTableWidget, QTableWidgetItem, QHeaderView, QCheckBox, QVBoxLayout, QProgressBar, QComboBox,
|
QTableWidget, QTableWidgetItem, QHeaderView, QCheckBox, QVBoxLayout, QProgressBar, QComboBox,
|
||||||
QTabBar, QStackedWidget, QSizePolicy)
|
QTabBar, QStackedWidget, QSizePolicy, QDialog, QDialogButtonBox, QPlainTextEdit)
|
||||||
from PySide6.QtWidgets import QStyle
|
from PySide6.QtWidgets import QStyle
|
||||||
|
|
||||||
|
|
||||||
@@ -188,7 +188,8 @@ class MainWindow(QWidget):
|
|||||||
self.advanced_panel.setVisible(False)
|
self.advanced_panel.setVisible(False)
|
||||||
self.advanced_toggle.toggled.connect(self.advanced_panel.setVisible)
|
self.advanced_toggle.toggled.connect(self.advanced_panel.setVisible)
|
||||||
self.cbb_table = QTableWidget(0, 4)
|
self.cbb_table = QTableWidget(0, 4)
|
||||||
self.cbb_table.setHorizontalHeaderLabels(['CBB 名称', '分区', '状态', '备注'])
|
self.cbb_table.setHorizontalHeaderLabels(['CBB 名称', '分区', '状态', '备注(双击查看)'])
|
||||||
|
self.cbb_table.cellDoubleClicked.connect(self._show_result_detail)
|
||||||
self.cbb_table.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch)
|
self.cbb_table.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch)
|
||||||
self.cbb_table.horizontalHeader().setSectionResizeMode(3, QHeaderView.Stretch)
|
self.cbb_table.horizontalHeader().setSectionResizeMode(3, QHeaderView.Stretch)
|
||||||
for column in (1, 2):
|
for column in (1, 2):
|
||||||
@@ -2037,6 +2038,36 @@ class MainWindow(QWidget):
|
|||||||
self.cbb_table.item(row, 3).setToolTip(detail)
|
self.cbb_table.item(row, 3).setToolTip(detail)
|
||||||
if self.logging_context: self.logging_context.logger.info('cbb_progress %s', line)
|
if self.logging_context: self.logging_context.logger.info('cbb_progress %s', line)
|
||||||
|
|
||||||
|
def _show_result_detail(self, row, column):
|
||||||
|
if column != 3:
|
||||||
|
return
|
||||||
|
item = self.cbb_table.item(row, column)
|
||||||
|
name = self.cbb_table.item(row, 0)
|
||||||
|
if item is None or name is None or not item.toolTip():
|
||||||
|
return
|
||||||
|
|
||||||
|
dialog = QDialog(self)
|
||||||
|
dialog.setAttribute(Qt.WA_DeleteOnClose)
|
||||||
|
dialog.setWindowTitle(f'{name.text()} 结果详情')
|
||||||
|
dialog.resize(660, 380)
|
||||||
|
layout = QVBoxLayout(dialog)
|
||||||
|
text = QPlainTextEdit(dialog)
|
||||||
|
text.setReadOnly(True)
|
||||||
|
text.setPlainText(item.toolTip())
|
||||||
|
text.moveCursor(QTextCursor.Start)
|
||||||
|
layout.addWidget(text)
|
||||||
|
buttons = QDialogButtonBox(QDialogButtonBox.Close, dialog)
|
||||||
|
copy = buttons.addButton('复制全文', QDialogButtonBox.ActionRole)
|
||||||
|
|
||||||
|
def copy_detail():
|
||||||
|
from PySide6.QtWidgets import QApplication
|
||||||
|
QApplication.clipboard().setText(text.toPlainText())
|
||||||
|
|
||||||
|
copy.clicked.connect(copy_detail)
|
||||||
|
buttons.rejected.connect(dialog.close)
|
||||||
|
layout.addWidget(buttons)
|
||||||
|
dialog.show()
|
||||||
|
|
||||||
def _mark_row_ready(self, row):
|
def _mark_row_ready(self, row):
|
||||||
"""Color authoritative READY rows while retaining management selection."""
|
"""Color authoritative READY rows while retaining management selection."""
|
||||||
name_item = self.cbb_table.item(row, 0)
|
name_item = self.cbb_table.item(row, 0)
|
||||||
|
|||||||
@@ -290,3 +290,33 @@ def test_large_catalog_local_filter_and_selection_remain_responsive(qtbot, tmp_p
|
|||||||
print(f'catalog rows={size} load={loaded:.3f}s local_actions={elapsed:.3f}s')
|
print(f'catalog rows={size} load={loaded:.3f}s local_actions={elapsed:.3f}s')
|
||||||
assert elapsed < 2.0
|
assert elapsed < 2.0
|
||||||
assert window.selected_records() == ()
|
assert window.selected_records() == ()
|
||||||
|
|
||||||
|
|
||||||
|
def test_double_click_shows_complete_skipped_reason(qtbot, tmp_path, monkeypatch):
|
||||||
|
from PySide6.QtWidgets import QApplication, QDialog, QPlainTextEdit, QPushButton
|
||||||
|
|
||||||
|
window = load_window(qtbot, tmp_path, monkeypatch)
|
||||||
|
window.show()
|
||||||
|
reason = ('PCB_OPEN_SKIPPED: 检查未通过\n' +
|
||||||
|
'\n'.join(f'共享数据库占用记录 {index}' for index in range(30)) +
|
||||||
|
'\n完整路径 <library>/SymbolLibs/icdb.dat')
|
||||||
|
window._progress({'block': 'Beta', 'stage': 'SKIPPED', 'detail': reason})
|
||||||
|
row = window._row_by_name['Beta']
|
||||||
|
item = window.cbb_table.item(row, 3)
|
||||||
|
window.cbb_table.scrollToItem(item)
|
||||||
|
position = window.cbb_table.visualItemRect(item).center()
|
||||||
|
viewport = window.cbb_table.viewport()
|
||||||
|
assert viewport.rect().contains(position)
|
||||||
|
qtbot.mouseClick(viewport, Qt.LeftButton, pos=position)
|
||||||
|
qtbot.mouseDClick(viewport, Qt.LeftButton, pos=position)
|
||||||
|
dialogs = [dialog for dialog in window.findChildren(QDialog)
|
||||||
|
if dialog.isVisible() and '结果详情' in dialog.windowTitle()]
|
||||||
|
assert len(dialogs) == 1
|
||||||
|
dialog = dialogs[0]
|
||||||
|
text = dialog.findChild(QPlainTextEdit)
|
||||||
|
assert text.isReadOnly()
|
||||||
|
assert text.toPlainText() == reason
|
||||||
|
copy, = [button for button in dialog.findChildren(QPushButton) if button.text() == '复制全文']
|
||||||
|
qtbot.mouseClick(copy, Qt.LeftButton)
|
||||||
|
assert QApplication.clipboard().text() == reason
|
||||||
|
dialog.close()
|
||||||
Reference in new issue
Block a user