From 325af1b38425d5314f836f44b1bf84e0e77aa7b0 Mon Sep 17 00:00:00 2001 From: "ZHANGXUXU\\95193" <951937200@qq.com> Date: Mon, 17 Jun 2024 18:47:44 +0800 Subject: [PATCH] 0617 --- UI/BlockParameterManageWidget.py | 14 ++++++++------ UI/BlockParameterModel.py | 13 ++++++++++--- UI/BlockParameterView.py | 3 ++- model/ProjectModel/BlockManage.py | 2 +- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/UI/BlockParameterManageWidget.py b/UI/BlockParameterManageWidget.py index b7d3d0c..86c6ce9 100644 --- a/UI/BlockParameterManageWidget.py +++ b/UI/BlockParameterManageWidget.py @@ -10,7 +10,8 @@ from utils.DBModels.DeviceParModels import * from utils import Globals from UI.LoadingDataWidget import LoadingDataWidget -from model.ProjectModel.BlockManage import BlockManage +from model.ProjectModel.BlockManage import BlockManage, BlockType + class HideTextDelegate(QStyledItemDelegate): @@ -60,6 +61,7 @@ class DynamicAddBlock(QHBoxLayout): self.buttonlist = [] self.blockViewlist = [] self.tbList = ['PressureTranslationBlock', 'TemperatureTranslationBlock', 'LevelTranslationBlock', 'FlowTranslationBlock'] #存放四个转换块 + self.enumList = [BlockType.TB.pressureTB, BlockType.TB.tempTB, BlockType.TB.levelTB, BlockType.TB.flowTB] self.initUI() def initUI(self): @@ -78,7 +80,7 @@ class DynamicAddBlock(QHBoxLayout): pblockBtn.clicked.connect(lambda _, pbbtn = pblockBtn: self.switchParameterWidget(pbbtn)) self.addWidget(pblockBtn, 3) self.buttonlist.append(pblockBtn) - physicalBlockView = ParmView(PhysicalBlock, i) + physicalBlockView = ParmView(PhysicalBlock, i, BlockType.PB) self.blockViewlist.append(physicalBlockView) if i == 0: pblockBtn.setChecked(True) @@ -94,7 +96,7 @@ class DynamicAddBlock(QHBoxLayout): fblockBtn.clicked.connect(lambda _, fbbtn = fblockBtn: self.switchParameterWidget(fbbtn)) self.addWidget(fblockBtn, 3) self.buttonlist.append(fblockBtn) - aiFunctionBlockView = ParmView(AIFunctionBlock, i) + aiFunctionBlockView = ParmView(AIFunctionBlock, i, BlockType.FB) self.blockViewlist.append(aiFunctionBlockView) for i in range(tbNumber): @@ -119,8 +121,8 @@ class DynamicAddBlock(QHBoxLayout): tblayout.setSpacing(0) self.addWidget(tbwidget, 5) self.buttonlist.append(tblockBtn) - for tb in self.tbList: - tbBlockView = ParmView(globals()[tb], i) + for tb, enum in zip(self.tbList, self.enumList): + tbBlockView = ParmView(globals()[tb], i, enum) self.blockViewlist.append(tbBlockView) self.parameterButtonGroup = QButtonGroup() @@ -234,7 +236,7 @@ class BlockParameterManageWidget(QWidget): model = blockView.model model.updateColumn(5, '查询中sdadadsda\r\nsdasdsasasad\r\nasdsadsad...') - blockName = blockView.dbModel.__name__ + blockName = blockView.blockType blcoknumber = blockView.blcoknumber + 1 print(blockName, blcoknumber) diff --git a/UI/BlockParameterModel.py b/UI/BlockParameterModel.py index b1a9cc8..432ef5a 100644 --- a/UI/BlockParameterModel.py +++ b/UI/BlockParameterModel.py @@ -217,22 +217,26 @@ class VarButtonDelegate(QItemDelegate): self.parent().resizeHeader() class ComboBoxDelegate(QStyledItemDelegate): - def __init__(self, parent=None): + def __init__(self, comboxIndex, parent=None): super(ComboBoxDelegate, self).__init__(parent) + self.currIndex = None + self.comboxIndex = comboxIndex def createEditor(self, parent, option, index): # 仅在第二列第二行创建编辑器 if index.row() == 5 and index.column() == 5: comboBox = QComboBox(parent) + comboBox.currentIndexChanged.connect(lambda index : self.changeModel(index)) comboBox.addItems(["非服务", "手动初始化", "本地超驰", '手动', '自动', '级联', '远程级联', '远程输出']) + comboBox.setCurrentIndex(self.comboxIndex) return comboBox else: return super().createEditor(parent, option, index) def setEditorData(self, editor, index): if index.row() == 5 and index.column() == 5: - # value = index.model().data(index, Qt.EditRole) - value = "非服务" + value = index.model().data(index, Qt.EditRole) + # value = "非服务" if value: editor.setCurrentText(value) else: @@ -247,3 +251,6 @@ class ComboBoxDelegate(QStyledItemDelegate): def updateEditorGeometry(self, editor, option, index): editor.setGeometry(option.rect) + def changeModel(self, index): + print(index,111) + diff --git a/UI/BlockParameterView.py b/UI/BlockParameterView.py index 90cb587..7f82140 100644 --- a/UI/BlockParameterView.py +++ b/UI/BlockParameterView.py @@ -29,10 +29,11 @@ class ParamsVHeader(QHeaderView): class ParmView(QTableView): - def __init__(self, dbModel = None, blcoknumber = None): + def __init__(self, dbModel = None, blcoknumber = None, blockType = None): super().__init__() self.dbModel = dbModel self.blcoknumber = blcoknumber + self.blockType = blockType self.setHeader() self.setupUi() self.setData() diff --git a/model/ProjectModel/BlockManage.py b/model/ProjectModel/BlockManage.py index f8da4d5..78f8210 100644 --- a/model/ProjectModel/BlockManage.py +++ b/model/ProjectModel/BlockManage.py @@ -10,7 +10,7 @@ from model.ProjectModel.ParmManage import Parm class BlockType(Enum): class TB(Enum): - phyTB = -1 + flowTB = -1 tempTB = -2 levelTB = -3 # 物位转换块 pressureTB = -4