0617更新

main
parent edd00be72e
commit 325727d6f9

@ -269,13 +269,14 @@ class BlockParameterManageWidget(QWidget):
"请先连接设备",
QMessageBox.Yes)
return
self.loadingDataWidget = LoadingDataWidget()
self.loadingDataWidget.loadData()
blockView = self.blockLayout.parameStackWidget.currentWidget()
model = blockView.model
model.updateColumn(5, '查询中sdadadsda\r\nsdasdsasasad\r\nasdsadsad...')
blockView.resizeHeader()
blockName = blockView.blockType
blcokIndex = blockView.blcokIndex

@ -41,12 +41,12 @@ class VarTableModel(QAbstractTableModel):
self.checkList = ['Unchecked'] * len(self.datas)
self.table.proxy.invalidate()
def updateColumn(self, column, value):
if column < 0 or column >= self.columnCount():
def updateColumn(self, row, value):
if row < 0 or row >= self.rowCount():
print("列索引超出范围")
return
for row in range(self.rowCount()):
self.datas[row][column] = value
# for row in range(self.rowCount()):
self.datas[row][5] = value
self.table.proxy.invalidate()
# self.layoutChanged.emit() # 通知视图数据已更改
# self.dataChanged.emit()
@ -167,15 +167,26 @@ class VarButtonDelegate(QItemDelegate):
refreshButton.index = [index.row(), index.column()]
boxLayout = QHBoxLayout()
boxLayout.addLayout(editlineLayout)
boxLayout.addWidget(startActionBtn)
boxLayout.addWidget(refreshButton)
if objectType == 'TARGET_MODE':
combox = QComboBox()
combox.addItems(["非服务", "手动初始化", "本地超驰", '手动', '自动', '级联', '远程级联', '远程输出'])
combox.setCurrentIndex(-1)
combox.currentIndexChanged.connect(lambda index : self.startAction(modelIndex = index))
boxLayout.addWidget(combox, 10)
boxLayout.addWidget(refreshButton,1)
else:
boxLayout.addLayout(editlineLayout)
startActionBtn.clicked.connect(lambda: self.startAction(objectTypeEditlayout = editlineLayout))
boxLayout.addWidget(startActionBtn)
boxLayout.addWidget(refreshButton)
startActionBtn.clicked.connect(lambda: self.startAction(editlineLayout))
startActionBtn.setObjectName('startActionBtn')
boxLayout.setContentsMargins(0, 0, 0, 0)
widget = QWidget()
# widget.setMinimumHeight(200)
widget.setLayout(boxLayout)
self.parent().setIndexWidget(
index,
@ -183,81 +194,53 @@ class VarButtonDelegate(QItemDelegate):
)
def startAction(self, objectTypeEditlayout):
def startAction(self, objectTypeEditlayout = None, modelIndex = None):
sender = self.sender()
model = self.parent().model
values = objectTypeEditlayout.getEditlineValue()
if not values:
reply = QMessageBox.question(self.parent(),
'警告',
"请输入强制值或数字",
QMessageBox.Yes)
return
for value in values:
# print(value)
pattern = re.compile(r'[^0-9\.-]+')
if not value or re.findall(pattern, str(value)):
blockView = self.parent()
model = blockView.model
blockName = blockView.blockType
blcokIndex = blockView.blcokIndex
print(modelIndex)
if modelIndex or str(modelIndex) == '0' :
value = modelIndex
else:
index = model.datas[sender.index[0]][0]
values = objectTypeEditlayout.getEditlineValue()
if not values:
reply = QMessageBox.question(self.parent(),
'警告',
"请输入强制值或数字",
QMessageBox.Yes)
'警告',
"请输入强制值或数字",
QMessageBox.Yes)
return
index = model.datas[sender.index[0]][0]
# print(index, self.parent().dbModel.__name__, self.parent().blcoknumber + 1)
for value in values:
# print(value)
pattern = re.compile(r'[^0-9\.-]+')
if not value or re.findall(pattern, str(value)):
reply = QMessageBox.question(self.parent(),
'警告',
"请输入强制值或数字",
QMessageBox.Yes)
return
def refreshData(self):
def refreshData(self, modelIndex = None):
sender = self.sender()
blockView = self.parent()
model = blockView.model
index = model.datas[sender.index[0]][0]
blockName = blockView.blockType
blcokIndex = blockView.blcokIndex
print(blockName, blcokIndex, index)
# print(blockName, blcokIndex, index)
self.loadingDataWidget = LoadingDataWidget()
self.loadingDataWidget.loadData()
self.parent().resizeHeader()
model.updateColumn(sender.index[0],'sss')
# self.parent().resizeHeader()
blockView.proxy.invalidate()
class ComboBoxDelegate(QStyledItemDelegate):
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 = "非服务"
if value:
editor.setCurrentText(value)
else:
super().setEditorData(editor, index)
def setModelData(self, editor, model, index):
if index.row() == 5 and index.column() == 5:
model.setData(index, editor.currentText(), Qt.EditRole)
else:
super().setModelData(editor, model, index)
def updateEditorGeometry(self, editor, option, index):
editor.setGeometry(option.rect)
def changeModel(self, index):
# print(index,111)
pass

@ -2,7 +2,7 @@ from PyQt5 import QtCore
from PyQt5.QtGui import QTextDocument
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QHeaderView, QAbstractItemView, QTableView, QWidget, QDesktopWidget
from UI.BlockParameterModel import VarTableModel, VarButtonDelegate, ComboBoxDelegate
from UI.BlockParameterModel import VarTableModel, VarButtonDelegate
from utils.DBModels.DeviceParModels import *
@ -10,21 +10,30 @@ class ParamsVHeader(QHeaderView):
def __init__(self, parent, datas):
super().__init__(Qt.Vertical, parent)
self.datas = datas
# print(1111)
def resizeEvent(self, event):
"""Resize table as a whole, need this to enable resizing"""
super(QHeaderView, self).resizeEvent(event)
for index, content in enumerate(self.datas):
self.setSectionResizeMode(index, QHeaderView.Fixed)
desHeight = 50 * (content[2].count('\r\n') + 1)
valueHeight = 50 * (content[5].count('\r\n') + 1)
height = desHeight if desHeight > valueHeight else valueHeight
self.resizeSection(index, height)
height = 50 * (content[2].count('\r\n') + 1)
# valueHeight = 50 * (content[5].count('\r\n') + 1)
# height = desHeight if desHeight > valueHeight else valueHeight
# print(height, index)
if content[3] == 'DS-36':
self.resizeSection(index, height)
if content[3] == 'DS-34':
self.resizeSection(index, height)
height = height if height > 5 * 50 else 250
print(height)
# self.resizeSection(index, height)
if content[3] == 'DS-37':
height = height if height > 4 * 50 else 200
if content[3] == 'DS-39':
height = height if height > 7 * 50 else 350
if content[3] == 'DS-50':
height = height if height > 4 * 50 else 200
# self.resizeSection(index, height)
self.resizeSection(index, height)
return
@ -40,7 +49,7 @@ class ParmView(QTableView):
def setHeader(self):
self.setItemDelegateForColumn(6, VarButtonDelegate(self))
self.setItemDelegateForColumn(5, ComboBoxDelegate(self))
# self.setItemDelegateForColumn(5, ComboBoxDelegate(self))
self.model = VarTableModel(['索引', '参数名', '描述', '数据类型', '访问', '当前值', '输入值'], [], table = self)
@ -60,7 +69,7 @@ class ParmView(QTableView):
self.proxy.setSourceModel(self.model)
self.setModel(self.proxy)
self.setCustomColumnWidths([1, 3, 9, 2, 2, 2, 2])
self.setCustomColumnWidths([1, 3, 8, 2, 2, 2, 3])
# self.header.checkClicked.connect(self.model.headerClick)
@ -96,7 +105,9 @@ class ParmView(QTableView):
self.resizeHeader()
def resizeHeader(self):
# print(self.verticalHeader())
self.setVerticalHeader(ParamsVHeader(self, self.model.datas))
# QtCore.QTimer.singleShot(0, self.verticalHeader().updateGeometry)

@ -21,17 +21,20 @@ class ObjectTypeEditlayout(QVBoxLayout):
self.editline4.setObjectName('parameEditline')
if self.objectType in ['SCALE_IN', 'SCALE_OUT', 'PV_SCALE']:
self.editline1.setPlaceholderText('请输入高标标度值')
self.editline2.setPlaceholderText('请输入低标标度值')
self.editline1.setPlaceholderText('高标标度值')
self.editline2.setPlaceholderText('低标标度值')
self.addWidget(self.editline1)
self.addWidget(self.editline2)
self.editlineList.extend([self.editline1, self.editline2])
if self.dataType == 'DS-36':
# layout1 = QHBoxLayout()
# layout2 = QHBoxLayout()
self.editline1.setPlaceholderText('EU_at_lOO %')
self.editline2.setPlaceholderText('EU_at 0%')
self.editline3.setPlaceholderText('单位索引')
self.editline4.setPlaceholderText('有效小数点')
# layout1.addWidget()
self.addWidget(self.editline1)
self.addWidget(self.editline2)
@ -40,8 +43,8 @@ class ObjectTypeEditlayout(QVBoxLayout):
self.editlineList.extend([self.editline1, self.editline2, self.editline3, self.editline4])
if self.dataType == 'DS-50':
self.editline1.setPlaceholderText('请输入仿真转换块值状况')
self.editline2.setPlaceholderText('请输入仿真转换块值')
self.editline1.setPlaceholderText('仿真转换块值状况')
self.editline2.setPlaceholderText('仿真转换块值')
self.editline3.setPlaceholderText('启用或者警用仿真转换块(0:禁用, <>0:启用)')
self.addWidget(self.editline1)

Loading…
Cancel
Save