а по этим данным тоже ничего не видно? код не маленький чтобы его сюда весь пихать…
class frmTableModel(QtCore.QAbstractTableModel):
def __init__(self, fileName = QtCore.QString()):
super (frmTableModel, self).__init__()
self.ships = []
self.fileName = fileName
self.dirty = True
# self.srcCodes = set ()
# self.countries = set()
def rowCount (self, index=QtCore.QModelIndex()):
return len(self.ships)
# return 5
def columnCount (self, index=QtCore.QModelIndex()):
return 5
def headerData(self, section, orientation, role=QtCore.Qt.DisplayRole):
if role != QtCore.Qt.DisplayRole:
return
if orientation == QtCore.Qt.Horizontal:
if section == SRCFRMCODE:
return (QtGui.QApplication.translate("MainWindow", "№ дж. вик. (прих.)", None, QtGui.QApplication.UnicodeUTF8))
elif section == FRMCODE:
return (QtGui.QApplication.translate("MainWindow", "№ дж. утв. (прих.)", None, QtGui.QApplication.UnicodeUTF8))
elif section == FORMATIONSRCNAME:
return (QtGui.QApplication.translate("MainWindow", "Найм. дж. утв.", None, QtGui.QApplication.UnicodeUTF8))
elif section == EVOLVINGGASDEPLETION:
return (QtGui.QApplication.translate("MainWindow", "Витрата ПГВС, м3/с", None, QtGui.QApplication.UnicodeUTF8))
elif section == EVOLVINGGASTEMPERATURE:
return (QtGui.QApplication.translate("MainWindow", "Темпер., 0С, ", None, QtGui.QApplication.UnicodeUTF8))
return int(section + 1)
def data (self, index, role=QtCore.Qt.DisplayRole):
if index.isValid() and 0 <= index.row() < len(self.ships):
ship = self.ships [index.row()]
column = index.column()
if role == QtCore.Qt.DisplayRole or role == QtCore.Qt.EditRole:
if column == SRCFRMCODE:
return QtCore.QVariant(ship.srcFrmCode)
elif column == FRMCODE:
return QtCore.QVariant(ship.frmCode)
elif column == FORMATIONSRCNAME:
return QtCore.QVariant(ship.formationSrcName)
elif column == EVOLVINGGASDEPLETION:
return QtCore.QVariant(ship.evolvingGasDepletion)
elif column == EVOLVINGGASTEMPERATURE:
return QtCore.QVariant(ship.evolvingGasTemperature)
return QtCore.QVariant()
return QtCore.QVariant()
def flags(self, index):
if not index.isValid():
return QtCore.Qt.ItemIsEnabled
return QtCore.Qt.ItemFlags(QtCore.QAbstractTableModel.flags(self, index)|QtCore.Qt.ItemIsEditable)
def setData (self, index, value, role=QtCore.Qt.DisplayRole):
if index.isValid() and 0 <= index.row() < len (self.ships):
ship = self.ships [index.row()]
column = index.column()
if column == SRCFRMCODE:
value, ok = value.toInt()
if ok:
ship.srcFrmCode = value
elif column == FRMCODE:
value, ok = value.toInt()
if ok:
ship.frmCode = value
elif column == FORMATIONSRCNAME:
ship.formationSrcName = value.toString()
elif column == EVOLVINGGASDEPLETION:
ship.evolvingGasDepletion = value.toDouble()[0]
elif column == EVOLVINGGASTEMPERATURE:
ship.evolvingGasTemperature = value.toDouble()[0]
self.dirty = True
self.emit(QtCore.SIGNAL("dataChanged(QModelIndex, QModelIndex)"), index, index)
return True
return False
def insertRows (self, position, indexSrcCode, nextFrmCode, rows=1, index=QtCore.QModelIndex()):
self.beginInsertRows(QtCore.QModelIndex(), position, position + rows - 1)
for row in range(rows):
self.ships.insert(position + row, frmShip(indexSrcCode, nextFrmCode, u"Джерело утворення", 0, 0))
self.endInsertRows()
self.dirty = True
return True
def removeRows(self, position, rows, index=QtCore.QModelIndex()):
self.beginRemoveRows(QtCore.QModelIndex(), position, position + rows - 1)
self.ships = self.ships[:position] + self.ships [position + rows:]
self.endRemoveRows()
self.dirty = True
return True