|
@@ -87,23 +87,22 @@ class FormWindow(Ui_Form, MdiActionWindow):
|
|
|
self.reportButton.clicked.connect(self.report_virtual_timing)
|
|
self.reportButton.clicked.connect(self.report_virtual_timing)
|
|
|
self.reportButton.setHidden(not instan._hasReportVirtualTimingButton)
|
|
self.reportButton.setHidden(not instan._hasReportVirtualTimingButton)
|
|
|
if instan._hasCrossProbeMenu:
|
|
if instan._hasCrossProbeMenu:
|
|
|
- self.tableView.customContextMenuRequested.connect(self.right_click_menu)
|
|
|
|
|
|
|
+ self.tableWidget.customContextMenuRequested.connect(self.right_click_menu)
|
|
|
|
|
|
|
|
- self.tableView.setModel(FormWindow.get_form_model(self.instan.Form))
|
|
|
|
|
- self.tableView.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
|
|
|
|
|
|
|
+ self.tableWidget.setModel(FormWindow.get_form_model(self.instan.Form))
|
|
|
|
|
+ self.tableWidget.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
|
|
|
|
|
|
|
|
self.mdisubwin:QMdiSubWindow = mainWindow.mdiArea.addSubWindow(self)
|
|
self.mdisubwin:QMdiSubWindow = mainWindow.mdiArea.addSubWindow(self)
|
|
|
self.mdisubwin.setAttribute(Qt.WA_DeleteOnClose)
|
|
self.mdisubwin.setAttribute(Qt.WA_DeleteOnClose)
|
|
|
self.mdisubwin.setWindowIcon(QIcon(":/icon/resource/todo-line.png"))
|
|
self.mdisubwin.setWindowIcon(QIcon(":/icon/resource/todo-line.png"))
|
|
|
# mdisubwin.move(mdiArea.x()+(mdiArea.width()-self.width())/2 + self.width()*0.8,mdiArea.y()+(mdiArea.height()-self.height())/2)
|
|
# mdisubwin.move(mdiArea.x()+(mdiArea.width()-self.width())/2 + self.width()*0.8,mdiArea.y()+(mdiArea.height()-self.height())/2)
|
|
|
self.mdisubwin.show()
|
|
self.mdisubwin.show()
|
|
|
- width = FormWindow.get_table_width(self.tableView, self)
|
|
|
|
|
|
|
+ width = FormWindow.get_table_width(self.tableWidget, self)
|
|
|
self.mdisubwin.resize(width, self.height())
|
|
self.mdisubwin.resize(width, self.height())
|
|
|
# 必须要show之后才能 ensure_subwin_in_midarea,因为没有显示时Form窗口大小是不正确的
|
|
# 必须要show之后才能 ensure_subwin_in_midarea,因为没有显示时Form窗口大小是不正确的
|
|
|
# 移动到鼠标 pos 位置
|
|
# 移动到鼠标 pos 位置
|
|
|
if pos:
|
|
if pos:
|
|
|
self.mdisubwin.move(ensure_subwin_in_midarea(mdiArea, self, pos))
|
|
self.mdisubwin.move(ensure_subwin_in_midarea(mdiArea, self, pos))
|
|
|
- self.reportButton.clicked.connect(lambda: print(self.geometry()))
|
|
|
|
|
|
|
|
|
|
def get_form_model(form:GuiType._GuiForm):
|
|
def get_form_model(form:GuiType._GuiForm):
|
|
|
model = QStandardItemModel(0, len(form.FixedRow))
|
|
model = QStandardItemModel(0, len(form.FixedRow))
|
|
@@ -113,11 +112,11 @@ class FormWindow(Ui_Form, MdiActionWindow):
|
|
|
model.appendRow(row_items)
|
|
model.appendRow(row_items)
|
|
|
return model
|
|
return model
|
|
|
|
|
|
|
|
- def get_table_width(tableView:QTableView, win):
|
|
|
|
|
|
|
+ def get_table_width(tableWidget:QTableWidget, win:MdiActionWindow):
|
|
|
# 表格与窗口的边距宽度
|
|
# 表格与窗口的边距宽度
|
|
|
width = 28
|
|
width = 28
|
|
|
- for i in range(tableView.horizontalHeader().count()):
|
|
|
|
|
- width += tableView.columnWidth(i)
|
|
|
|
|
|
|
+ for i in range(tableWidget.horizontalHeader().count()):
|
|
|
|
|
+ width += tableWidget.columnWidth(i)
|
|
|
if width < win.width():
|
|
if width < win.width():
|
|
|
width = win.width()
|
|
width = win.width()
|
|
|
return width
|
|
return width
|
|
@@ -128,62 +127,67 @@ class FormWindow(Ui_Form, MdiActionWindow):
|
|
|
pop_menu.triggered.connect(self.crossprobe)
|
|
pop_menu.triggered.connect(self.crossprobe)
|
|
|
pop_menu.exec_(QCursor.pos())
|
|
pop_menu.exec_(QCursor.pos())
|
|
|
|
|
|
|
|
- def get_row(tableView:QTableView):
|
|
|
|
|
|
|
+ def get_row(tableWidget:QTableView):
|
|
|
form_row = []
|
|
form_row = []
|
|
|
- for col in range(tableView.model().columnCount()):
|
|
|
|
|
- form_row.append(tableView.model().index(tableView.currentIndex().row(), col).data())
|
|
|
|
|
|
|
+ for col in range(tableWidget.model().columnCount()):
|
|
|
|
|
+ form_row.append(tableWidget.model().index(tableWidget.currentIndex().row(), col).data())
|
|
|
return form_row
|
|
return form_row
|
|
|
|
|
|
|
|
def crossprobe(self, action):
|
|
def crossprobe(self, action):
|
|
|
- form_row = FormWindow.get_row(self.tableView)
|
|
|
|
|
|
|
+ form_row = FormWindow.get_row(self.tableWidget)
|
|
|
line_text_win = self.instan.CrossProbe(form_row)
|
|
line_text_win = self.instan.CrossProbe(form_row)
|
|
|
LineEditWin(self.mainWindow, line_text_win)
|
|
LineEditWin(self.mainWindow, line_text_win)
|
|
|
|
|
|
|
|
def report_virtual_timing(self):
|
|
def report_virtual_timing(self):
|
|
|
- form_row = FormWindow.get_row(self.tableView)
|
|
|
|
|
|
|
+ if self.tableWidget.currentIndex().row() == -1:
|
|
|
|
|
+ return
|
|
|
|
|
+ form_row = FormWindow.get_row(self.tableWidget)
|
|
|
thread = threading.Thread(target=self.instan.ReportVirtualTiming, args=(form_row, self.mainWindow.GUI,))
|
|
thread = threading.Thread(target=self.instan.ReportVirtualTiming, args=(form_row, self.mainWindow.GUI,))
|
|
|
thread.start()
|
|
thread.start()
|
|
|
|
|
|
|
|
|
|
+
|
|
|
class MultiFormWin(Ui_Form, MdiActionWindow):
|
|
class MultiFormWin(Ui_Form, MdiActionWindow):
|
|
|
def __init__(self, mainWindow, instan:GuiType._GuiWinFormMulti) -> None:
|
|
def __init__(self, mainWindow, instan:GuiType._GuiWinFormMulti) -> None:
|
|
|
super().__init__(mainWindow)
|
|
super().__init__(mainWindow)
|
|
|
self.setupUi(self)
|
|
self.setupUi(self)
|
|
|
self.init_multi_form_ui()
|
|
self.init_multi_form_ui()
|
|
|
self.setWindowTitle(instan.Title)
|
|
self.setWindowTitle(instan.Title)
|
|
|
- MultiFormWin.set_form_multi(self.tableView, self.sheets, instan.Forms)
|
|
|
|
|
|
|
+ MultiFormWin.set_form_multi(self.tableWidget, self.sheets, instan.Forms)
|
|
|
|
|
|
|
|
self.instan = instan
|
|
self.instan = instan
|
|
|
- self.sheets.activated.connect(lambda index: MultiFormWin.activate_table_sheet(self.tableView, self.instan.Forms, index))
|
|
|
|
|
|
|
+ self.sheets.activated.connect(lambda index: MultiFormWin.activate_table_sheet(self.tableWidget, self.instan.Forms, index))
|
|
|
self.reportButton.clicked.connect(self.report_virtual_timing)
|
|
self.reportButton.clicked.connect(self.report_virtual_timing)
|
|
|
|
|
|
|
|
mdiArea:QMdiArea = mainWindow.mdiArea
|
|
mdiArea:QMdiArea = mainWindow.mdiArea
|
|
|
mdisub = mdiArea.addSubWindow(self)
|
|
mdisub = mdiArea.addSubWindow(self)
|
|
|
- width = self.tableView.horizontalHeader().width() * self.tableView.horizontalHeader().count() + 25
|
|
|
|
|
|
|
+ width = self.tableWidget.horizontalHeader().width() * self.tableWidget.horizontalHeader().count() + 25
|
|
|
mdisub.setWindowIcon(QIcon(":/icon/resource/todo-line.png"))
|
|
mdisub.setWindowIcon(QIcon(":/icon/resource/todo-line.png"))
|
|
|
mdisub.resize(width, self.height())
|
|
mdisub.resize(width, self.height())
|
|
|
mdisub.show()
|
|
mdisub.show()
|
|
|
|
|
|
|
|
- def set_form_multi(tableView:QTableView, sheets:QComboBox, multi_form:GuiType._GuiFormMulti):
|
|
|
|
|
|
|
+ def set_form_multi(tableWidget:QTableView, sheets:QComboBox, multi_form:GuiType._GuiFormMulti):
|
|
|
sheets.clear()
|
|
sheets.clear()
|
|
|
for sheet_name in multi_form.Names:
|
|
for sheet_name in multi_form.Names:
|
|
|
sheets.addItem(sheet_name)
|
|
sheets.addItem(sheet_name)
|
|
|
if sheets.count() > 0:
|
|
if sheets.count() > 0:
|
|
|
form = multi_form.GetForm(sheets.currentIndex())
|
|
form = multi_form.GetForm(sheets.currentIndex())
|
|
|
model = FormWindow.get_form_model(form)
|
|
model = FormWindow.get_form_model(form)
|
|
|
- tableView.setModel(model)
|
|
|
|
|
|
|
+ tableWidget.setModel(model)
|
|
|
|
|
|
|
|
- def activate_table_sheet(tableView, form_multi_instan, index):
|
|
|
|
|
|
|
+ def activate_table_sheet(tableWidget, form_multi_instan, index):
|
|
|
model = FormWindow.get_form_model(form_multi_instan.GetForm(index))
|
|
model = FormWindow.get_form_model(form_multi_instan.GetForm(index))
|
|
|
- tableView.setModel(model)
|
|
|
|
|
|
|
+ tableWidget.setModel(model)
|
|
|
|
|
|
|
|
def crossprobe(self, action):
|
|
def crossprobe(self, action):
|
|
|
- form_row = FormWindow.get_row(self.tableView)
|
|
|
|
|
|
|
+ form_row = FormWindow.get_row(self.tableWidget)
|
|
|
form_name = self.sheets.currentText()
|
|
form_name = self.sheets.currentText()
|
|
|
line_text_win = self.instan.CrossProbe(form_name, form_row)
|
|
line_text_win = self.instan.CrossProbe(form_name, form_row)
|
|
|
LineEditWin(self.mainWindow, line_text_win)
|
|
LineEditWin(self.mainWindow, line_text_win)
|
|
|
|
|
|
|
|
def report_virtual_timing(self):
|
|
def report_virtual_timing(self):
|
|
|
- form_row = FormWindow.get_row(self.tableView)
|
|
|
|
|
|
|
+ if self.tableWidget.currentIndex().row() == -1:
|
|
|
|
|
+ return
|
|
|
|
|
+ form_row = FormWindow.get_row(self.tableWidget)
|
|
|
thread = threading.Thread(target=self.instan.ReportVirtualTiming, args=(self.sheets.currentText(), form_row, self.mainWindow.GUI,))
|
|
thread = threading.Thread(target=self.instan.ReportVirtualTiming, args=(self.sheets.currentText(), form_row, self.mainWindow.GUI,))
|
|
|
thread.start()
|
|
thread.start()
|
|
|
|
|
|
|
@@ -191,17 +195,7 @@ class MultiFormWin(Ui_Form, MdiActionWindow):
|
|
|
self.horizontalLayout_2 = QHBoxLayout()
|
|
self.horizontalLayout_2 = QHBoxLayout()
|
|
|
self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
|
|
self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
|
|
|
self.sheets = QComboBox(self.centralwidget)
|
|
self.sheets = QComboBox(self.centralwidget)
|
|
|
- self.sheets.setObjectName(u"sheets")
|
|
|
|
|
- sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
|
|
|
|
|
- sizePolicy.setHorizontalStretch(0)
|
|
|
|
|
- sizePolicy.setVerticalStretch(0)
|
|
|
|
|
- sizePolicy.setHeightForWidth(self.sheets.sizePolicy().hasHeightForWidth())
|
|
|
|
|
- self.tableView.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
|
|
|
|
|
- self.tableView.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
|
|
|
|
|
- self.tableView.customContextMenuRequested.connect(self.right_click_menu)
|
|
|
|
|
-
|
|
|
|
|
- self.sheets.setSizePolicy(sizePolicy)
|
|
|
|
|
-
|
|
|
|
|
|
|
+ self.sheets.setObjectName(u"sheets")
|
|
|
self.horizontalLayout_2.addWidget(self.sheets)
|
|
self.horizontalLayout_2.addWidget(self.sheets)
|
|
|
|
|
|
|
|
self.horizontalSpacer_3 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
|
|
self.horizontalSpacer_3 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
|
|
@@ -213,6 +207,10 @@ class MultiFormWin(Ui_Form, MdiActionWindow):
|
|
|
|
|
|
|
|
self.verticalLayout.insertLayout(0,self.horizontalLayout_2)
|
|
self.verticalLayout.insertLayout(0,self.horizontalLayout_2)
|
|
|
|
|
|
|
|
|
|
+ self.tableWidget.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
|
|
|
|
|
+ self.tableWidget.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
|
|
|
|
|
+ self.tableWidget.customContextMenuRequested.connect(self.right_click_menu)
|
|
|
|
|
+
|
|
|
def right_click_menu(self, pos):
|
|
def right_click_menu(self, pos):
|
|
|
pop_menu = QMenu()
|
|
pop_menu = QMenu()
|
|
|
pop_menu.addAction(QAction('Crossprobe', pop_menu))
|
|
pop_menu.addAction(QAction('Crossprobe', pop_menu))
|
|
@@ -315,6 +313,11 @@ class SideBarWin(Ui_SideBar, MdiActionWindow):
|
|
|
self.mdisubwin.resize(self.width(), mdiArea.height())
|
|
self.mdisubwin.resize(self.width(), mdiArea.height())
|
|
|
self.mdisubwin.show()
|
|
self.mdisubwin.show()
|
|
|
|
|
|
|
|
|
|
+ def closeEvent(self, event: QCloseEvent):
|
|
|
|
|
+ event.ignore()
|
|
|
|
|
+ self.mdisubwin.hide()
|
|
|
|
|
+ self.menuWindow_action.setChecked(False)
|
|
|
|
|
+
|
|
|
def right_click_menu(self, pos):
|
|
def right_click_menu(self, pos):
|
|
|
sender = self.sender()
|
|
sender = self.sender()
|
|
|
pop_menu = QMenu()
|
|
pop_menu = QMenu()
|
|
@@ -419,26 +422,16 @@ class SideBarWin(Ui_SideBar, MdiActionWindow):
|
|
|
sub_tree_rows = item.tree_row.GetSubTreeRows()
|
|
sub_tree_rows = item.tree_row.GetSubTreeRows()
|
|
|
for row in sub_tree_rows:
|
|
for row in sub_tree_rows:
|
|
|
self.set_tree_row(item, row)
|
|
self.set_tree_row(item, row)
|
|
|
-
|
|
|
|
|
- # def activate_table_sheet(self, index):
|
|
|
|
|
- # model = FormWindow.get_form_model(self.form_multi_instan.GetForm(index))
|
|
|
|
|
- # self.tableView.setModel(model)
|
|
|
|
|
- # def set_form_multi(self, multi_form:GuiType._GuiFormMulti):
|
|
|
|
|
- # self.sheets.clear()
|
|
|
|
|
- # for sheet_name in multi_form.Names:
|
|
|
|
|
- # self.sheets.addItem(sheet_name)
|
|
|
|
|
- # if self.sheets.count() > 0:
|
|
|
|
|
- # form = multi_form.GetForm(self.sheets.currentIndex())
|
|
|
|
|
- # model = FormWindow.get_form_model(form)
|
|
|
|
|
- # self.tableView.setModel(model)
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
def set_tree_row(self, parent:TreeWidgetItem, tree_row:GuiType._GuiTreeRow):
|
|
def set_tree_row(self, parent:TreeWidgetItem, tree_row:GuiType._GuiTreeRow):
|
|
|
tree_widget_item = self.add_tree_row(parent, tree_row)
|
|
tree_widget_item = self.add_tree_row(parent, tree_row)
|
|
|
if tree_row.HasSubTreeRows:
|
|
if tree_row.HasSubTreeRows:
|
|
|
# 只添加一个子节点,让父节点变成可展开形式
|
|
# 只添加一个子节点,让父节点变成可展开形式
|
|
|
sub_tree_row:GuiType._GuiTreeRow = tree_row.GetSubTreeRows()[0]
|
|
sub_tree_row:GuiType._GuiTreeRow = tree_row.GetSubTreeRows()[0]
|
|
|
self.add_tree_row(tree_widget_item, sub_tree_row)
|
|
self.add_tree_row(tree_widget_item, sub_tree_row)
|
|
|
|
|
+ return tree_widget_item
|
|
|
|
|
|
|
|
|
|
+ # 树形控件设置数据
|
|
|
def set_tree(self, tree:GuiType._GuiTree):
|
|
def set_tree(self, tree:GuiType._GuiTree):
|
|
|
# 树
|
|
# 树
|
|
|
header_item = self.treeWidget.headerItem()
|
|
header_item = self.treeWidget.headerItem()
|
|
@@ -447,8 +440,11 @@ class SideBarWin(Ui_SideBar, MdiActionWindow):
|
|
|
for tree_row in tree.TreeRows:
|
|
for tree_row in tree.TreeRows:
|
|
|
# 根节点
|
|
# 根节点
|
|
|
self.set_tree_row(self.treeWidget, tree_row)
|
|
self.set_tree_row(self.treeWidget, tree_row)
|
|
|
-
|
|
|
|
|
|
|
+ # 默认选择第一行
|
|
|
|
|
+ if self.treeWidget.topLevelItemCount():
|
|
|
|
|
+ self.treeWidget.setItemSelected(self.treeWidget.topLevelItem(0), True)
|
|
|
|
|
|
|
|
|
|
+
|
|
|
class SubWindows(QObject):
|
|
class SubWindows(QObject):
|
|
|
sig = Signal(object)
|
|
sig = Signal(object)
|
|
|
def __init__(self, parent):
|
|
def __init__(self, parent):
|