|
|
|
@ -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
|
|
|
|
|
|
|
|
|
|