|
|
|
@ -5,7 +5,7 @@ import qtawesome
|
|
|
|
|
from PyQt5 import QtGui,QtCore,QtWidgets
|
|
|
|
|
from PyQt5.QtCore import QAbstractTableModel, QModelIndex, Qt, QVariant, QSize
|
|
|
|
|
|
|
|
|
|
from PyQt5.QtWidgets import QItemDelegate, QHBoxLayout, QWidget, QTableView, QMessageBox, QComboBox
|
|
|
|
|
from PyQt5.QtWidgets import QItemDelegate, QHBoxLayout, QWidget, QTableView, QMessageBox, QComboBox, QStyleOptionViewItem
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from protocol.Celery.MBTCPMaster import app as MBTCPMApp
|
|
|
|
@ -76,6 +76,7 @@ class VarTableModel(QAbstractTableModel):
|
|
|
|
|
self.checkList = ['Unchecked'] * len(self.datas)
|
|
|
|
|
# self.layoutChanged.emit()
|
|
|
|
|
self.table.proxy.invalidate()
|
|
|
|
|
self.refreshComboBox()
|
|
|
|
|
|
|
|
|
|
def append_data(self, x):
|
|
|
|
|
|
|
|
|
@ -195,12 +196,16 @@ class VarTableModel(QAbstractTableModel):
|
|
|
|
|
self.table.proxy.invalidate()
|
|
|
|
|
|
|
|
|
|
def refreshComboBox(self):
|
|
|
|
|
# print(self.table.rowCount())
|
|
|
|
|
for i in range(len(self.datas)):
|
|
|
|
|
cbRow = str('cb' + str(i) + '5')
|
|
|
|
|
index = self.index(i, 5)
|
|
|
|
|
delegate = self.table.itemDelegate(index)
|
|
|
|
|
comboBox = getattr(delegate, cbRow)
|
|
|
|
|
|
|
|
|
|
delegate.paint(self.table, QStyleOptionViewItem(), index)
|
|
|
|
|
try:
|
|
|
|
|
comboBox = getattr(delegate, cbRow)
|
|
|
|
|
except Exception as e:
|
|
|
|
|
continue
|
|
|
|
|
if self.datas[i][5] in [0, 1]:
|
|
|
|
|
comboBox.setCurrentIndex(self.datas[i][5])
|
|
|
|
|
elif self.datas[i][5] in [3, 4]:
|
|
|
|
@ -267,6 +272,7 @@ class VarButtonDelegate(QItemDelegate):
|
|
|
|
|
comboBox.addItem('BADC', 3)
|
|
|
|
|
comboBox.addItem('DCBA', 4)
|
|
|
|
|
comboBox.setCurrentText(self.parent().model.datas[index.row()][index.column()])
|
|
|
|
|
comboBox.setMinimumWidth(30)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
comboBox.currentIndexChanged.connect(self.indexChange)
|
|
|
|
@ -439,18 +445,15 @@ class VarButtonDelegate(QItemDelegate):
|
|
|
|
|
trend = ActualTrend(varName = name)
|
|
|
|
|
trend.show()
|
|
|
|
|
|
|
|
|
|
class ModbusTypeBox(VarButtonDelegate):
|
|
|
|
|
class ModbusTypeBox(QItemDelegate):
|
|
|
|
|
def __init__(self, parent=None):
|
|
|
|
|
super(ModbusTypeBox, self).__init__(parent)
|
|
|
|
|
|
|
|
|
|
def paint(self, painter, option, index):
|
|
|
|
|
if not self.parent().indexWidget(index):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if index.column() == 5:
|
|
|
|
|
data = self.parent().model.datas[index.row()]
|
|
|
|
|
comBox = str('cb' + str(index.row()) + str(index.column()))
|
|
|
|
|
setattr(self, comBox, QComboBox(self.parent()))
|
|
|
|
|
setattr(self, comBox, QComboBox())
|
|
|
|
|
comboBox = getattr(self, comBox)
|
|
|
|
|
|
|
|
|
|
item = ['Coil Status', 'Input Status', 'Input Register', 'Holding Register']
|
|
|
|
@ -472,6 +475,7 @@ class ModbusTypeBox(VarButtonDelegate):
|
|
|
|
|
comboBox.setObjectName('ModbusTypeBox')
|
|
|
|
|
comboBox.setEditable(True)
|
|
|
|
|
comboBox.lineEdit().setAlignment(Qt.AlignCenter)
|
|
|
|
|
comboBox.setMinimumWidth(200)
|
|
|
|
|
# comboBox.setEnabled(False)
|
|
|
|
|
h_box_layout = QHBoxLayout()
|
|
|
|
|
h_box_layout.addWidget(comboBox)
|
|
|
|
@ -495,6 +499,7 @@ class ModbusTypeBox(VarButtonDelegate):
|
|
|
|
|
index,
|
|
|
|
|
widget
|
|
|
|
|
)
|
|
|
|
|
self.parent().openPersistentEditor(index)
|
|
|
|
|
|
|
|
|
|
def indexChange(self):
|
|
|
|
|
sender = self.sender()
|
|
|
|
|