0617更新

main
parent edd00be72e
commit 325727d6f9

@ -276,6 +276,7 @@ class BlockParameterManageWidget(QWidget):
model = blockView.model model = blockView.model
model.updateColumn(5, '查询中sdadadsda\r\nsdasdsasasad\r\nasdsadsad...') model.updateColumn(5, '查询中sdadadsda\r\nsdasdsasasad\r\nasdsadsad...')
blockView.resizeHeader()
blockName = blockView.blockType blockName = blockView.blockType
blcokIndex = blockView.blcokIndex blcokIndex = blockView.blcokIndex

@ -41,12 +41,12 @@ class VarTableModel(QAbstractTableModel):
self.checkList = ['Unchecked'] * len(self.datas) self.checkList = ['Unchecked'] * len(self.datas)
self.table.proxy.invalidate() self.table.proxy.invalidate()
def updateColumn(self, column, value): def updateColumn(self, row, value):
if column < 0 or column >= self.columnCount(): if row < 0 or row >= self.rowCount():
print("列索引超出范围") print("列索引超出范围")
return return
for row in range(self.rowCount()): # for row in range(self.rowCount()):
self.datas[row][column] = value self.datas[row][5] = value
self.table.proxy.invalidate() self.table.proxy.invalidate()
# self.layoutChanged.emit() # 通知视图数据已更改 # self.layoutChanged.emit() # 通知视图数据已更改
# self.dataChanged.emit() # self.dataChanged.emit()
@ -167,15 +167,26 @@ class VarButtonDelegate(QItemDelegate):
refreshButton.index = [index.row(), index.column()] refreshButton.index = [index.row(), index.column()]
boxLayout = QHBoxLayout() boxLayout = QHBoxLayout()
boxLayout.addLayout(editlineLayout) if objectType == 'TARGET_MODE':
boxLayout.addWidget(startActionBtn) combox = QComboBox()
boxLayout.addWidget(refreshButton) 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') startActionBtn.setObjectName('startActionBtn')
boxLayout.setContentsMargins(0, 0, 0, 0) boxLayout.setContentsMargins(0, 0, 0, 0)
widget = QWidget() widget = QWidget()
# widget.setMinimumHeight(200)
widget.setLayout(boxLayout) widget.setLayout(boxLayout)
self.parent().setIndexWidget( self.parent().setIndexWidget(
index, index,
@ -183,81 +194,53 @@ class VarButtonDelegate(QItemDelegate):
) )
def startAction(self, objectTypeEditlayout): def startAction(self, objectTypeEditlayout = None, modelIndex = None):
sender = self.sender() sender = self.sender()
model = self.parent().model blockView = self.parent()
values = objectTypeEditlayout.getEditlineValue() model = blockView.model
if not values: blockName = blockView.blockType
reply = QMessageBox.question(self.parent(), blcokIndex = blockView.blcokIndex
'警告', print(modelIndex)
"请输入强制值或数字", if modelIndex or str(modelIndex) == '0' :
QMessageBox.Yes) value = modelIndex
return
for value in values: else:
# print(value) index = model.datas[sender.index[0]][0]
pattern = re.compile(r'[^0-9\.-]+') values = objectTypeEditlayout.getEditlineValue()
if not value or re.findall(pattern, str(value)): if not values:
reply = QMessageBox.question(self.parent(), reply = QMessageBox.question(self.parent(),
'警告', '警告',
"请输入强制值或数字", "请输入强制值或数字",
QMessageBox.Yes) QMessageBox.Yes)
return return
index = model.datas[sender.index[0]][0]
# print(index, self.parent().dbModel.__name__, self.parent().blcoknumber + 1)
def refreshData(self): 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, modelIndex = None):
sender = self.sender() sender = self.sender()
blockView = self.parent() blockView = self.parent()
model = blockView.model model = blockView.model
index = model.datas[sender.index[0]][0] index = model.datas[sender.index[0]][0]
blockName = blockView.blockType blockName = blockView.blockType
blcokIndex = blockView.blcokIndex blcokIndex = blockView.blcokIndex
print(blockName, blcokIndex, index)
# print(blockName, blcokIndex, index)
self.loadingDataWidget = LoadingDataWidget() self.loadingDataWidget = LoadingDataWidget()
self.loadingDataWidget.loadData() 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.QtGui import QTextDocument
from PyQt5.QtCore import Qt from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QHeaderView, QAbstractItemView, QTableView, QWidget, QDesktopWidget 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 * from utils.DBModels.DeviceParModels import *
@ -11,20 +11,29 @@ class ParamsVHeader(QHeaderView):
super().__init__(Qt.Vertical, parent) super().__init__(Qt.Vertical, parent)
self.datas = datas self.datas = datas
# print(1111)
def resizeEvent(self, event): def resizeEvent(self, event):
"""Resize table as a whole, need this to enable resizing""" """Resize table as a whole, need this to enable resizing"""
super(QHeaderView, self).resizeEvent(event) super(QHeaderView, self).resizeEvent(event)
for index, content in enumerate(self.datas): for index, content in enumerate(self.datas):
self.setSectionResizeMode(index, QHeaderView.Fixed) self.setSectionResizeMode(index, QHeaderView.Fixed)
desHeight = 50 * (content[2].count('\r\n') + 1) height = 50 * (content[2].count('\r\n') + 1)
valueHeight = 50 * (content[5].count('\r\n') + 1) # valueHeight = 50 * (content[5].count('\r\n') + 1)
height = desHeight if desHeight > valueHeight else valueHeight # height = desHeight if desHeight > valueHeight else valueHeight
self.resizeSection(index, height) # print(height, index)
if content[3] == 'DS-36': if content[3] == 'DS-36':
self.resizeSection(index, height) height = height if height > 5 * 50 else 250
if content[3] == 'DS-34': print(height)
self.resizeSection(index, 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 return
@ -40,7 +49,7 @@ class ParmView(QTableView):
def setHeader(self): def setHeader(self):
self.setItemDelegateForColumn(6, VarButtonDelegate(self)) self.setItemDelegateForColumn(6, VarButtonDelegate(self))
self.setItemDelegateForColumn(5, ComboBoxDelegate(self)) # self.setItemDelegateForColumn(5, ComboBoxDelegate(self))
self.model = VarTableModel(['索引', '参数名', '描述', '数据类型', '访问', '当前值', '输入值'], [], table = self) self.model = VarTableModel(['索引', '参数名', '描述', '数据类型', '访问', '当前值', '输入值'], [], table = self)
@ -60,7 +69,7 @@ class ParmView(QTableView):
self.proxy.setSourceModel(self.model) self.proxy.setSourceModel(self.model)
self.setModel(self.proxy) 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) # self.header.checkClicked.connect(self.model.headerClick)
@ -96,7 +105,9 @@ class ParmView(QTableView):
self.resizeHeader() self.resizeHeader()
def resizeHeader(self): def resizeHeader(self):
# print(self.verticalHeader())
self.setVerticalHeader(ParamsVHeader(self, self.model.datas)) 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') self.editline4.setObjectName('parameEditline')
if self.objectType in ['SCALE_IN', 'SCALE_OUT', 'PV_SCALE']: if self.objectType in ['SCALE_IN', 'SCALE_OUT', 'PV_SCALE']:
self.editline1.setPlaceholderText('请输入高标标度值') self.editline1.setPlaceholderText('高标标度值')
self.editline2.setPlaceholderText('请输入低标标度值') self.editline2.setPlaceholderText('低标标度值')
self.addWidget(self.editline1) self.addWidget(self.editline1)
self.addWidget(self.editline2) self.addWidget(self.editline2)
self.editlineList.extend([self.editline1, self.editline2]) self.editlineList.extend([self.editline1, self.editline2])
if self.dataType == 'DS-36': if self.dataType == 'DS-36':
# layout1 = QHBoxLayout()
# layout2 = QHBoxLayout()
self.editline1.setPlaceholderText('EU_at_lOO %') self.editline1.setPlaceholderText('EU_at_lOO %')
self.editline2.setPlaceholderText('EU_at 0%') self.editline2.setPlaceholderText('EU_at 0%')
self.editline3.setPlaceholderText('单位索引') self.editline3.setPlaceholderText('单位索引')
self.editline4.setPlaceholderText('有效小数点') self.editline4.setPlaceholderText('有效小数点')
# layout1.addWidget()
self.addWidget(self.editline1) self.addWidget(self.editline1)
self.addWidget(self.editline2) self.addWidget(self.editline2)
@ -40,8 +43,8 @@ class ObjectTypeEditlayout(QVBoxLayout):
self.editlineList.extend([self.editline1, self.editline2, self.editline3, self.editline4]) self.editlineList.extend([self.editline1, self.editline2, self.editline3, self.editline4])
if self.dataType == 'DS-50': if self.dataType == 'DS-50':
self.editline1.setPlaceholderText('请输入仿真转换块值状况') self.editline1.setPlaceholderText('仿真转换块值状况')
self.editline2.setPlaceholderText('请输入仿真转换块值') self.editline2.setPlaceholderText('仿真转换块值')
self.editline3.setPlaceholderText('启用或者警用仿真转换块(0:禁用, <>0:启用)') self.editline3.setPlaceholderText('启用或者警用仿真转换块(0:禁用, <>0:启用)')
self.addWidget(self.editline1) self.addWidget(self.editline1)

Loading…
Cancel
Save