def data(self, index, role=QtCore.Qt.DisplayRole): row = index.row() column = index.column() if role == QtCore.Qt.DisplayRole and column == 8: comment = forceString(self._items[row].value('drugComment')) if comment: comment = u'Для аптеки: ' + comment rlsCode = forceInt(self._items[row].value('rlsCode')) if rlsCode > 0: rlsCodeRecord = QtGui.qApp.db.getRecordEx( 'rbRLS', 'name', 'code=%s' % rlsCode) if rlsCodeRecord: rlsCode = forceString(rlsCodeRecord.value('name')) if rlsCode: if comment: comment += '; ' comment += u'Рекомендованный препарат: ' + rlsCode return toVariant(comment) elif role == QtCore.Qt.BackgroundRole: return toVariant(self.getRowColor(row)) elif role == QtCore.Qt.ToolTipRole: return CRecordListModel.data(self, index, Qt.DisplayRole) else: return CRecordListModel.data(self, index, role)
def data(self, index, role=QtCore.Qt.DisplayRole): column = index.column() row = index.row() if role == QtCore.Qt.DisplayRole: if column == 0: return QtCore.QVariant(row + 1) elif column == self.getColIndex('actionType_id'): record = self._items[row] outName = forceString(record.value('specifiedName')) actionTypeId = forceRef(record.value('actionType_id')) if actionTypeId: actionType = CActionTypeCache.getById(actionTypeId) if actionType: outName = actionType.name + ' ' + outName if outName else actionType.name return QtCore.QVariant(outName) elif column in self._propertyColsIndexes: record = self._items[row] actionTypeId = forceRef(record.value('actionType_id')) values = self._mapActionTypeIdToPropertyValues.get( actionTypeId, None) if values: fieldName = self._cols[column].fieldName() cellValues = values.get(fieldName, None) if cellValues: action = self._idToAction[actionTypeId] propertyType = cellValues['propertyType'] prop = action.getPropertyById(propertyType.id) return toVariant(prop.getText()) elif role == QtCore.Qt.FontRole: record = self._items[row] actionTypeId = forceRef(record.value('actionType_id')) if self._existsActionsModel.hasActionTypeId( actionTypeId ) or actionTypeId in self._mainActionTypesAnalyses: return self._qBoldFont return CRecordListModel.data(self, index, role)
def data(self, index, role=QtCore.Qt.DisplayRole): if index.column() == 0 and role == QtCore.Qt.CheckStateRole: row = index.row() item = self.items()[row] status = forceInt(item.value('status')) return toVariant(QtCore.Qt.Checked if status == 0 else QtCore.Qt.Unchecked) elif role == QtCore.Qt.ToolTipRole: row = index.row() item = self.items()[row] reason = forceString(item.value('reason')) if reason: return toVariant(reason) elif role == QtCore.Qt.FontRole: row = index.row() item = self.items()[row] reason = forceString(item.value('reason')) if reason: font = QtGui.QFont() font.setBold(True) return toVariant(font) else: return CRecordListModel.data(self, index, role)
def data(self, index, role=QtCore.Qt.DisplayRole): if role == QtCore.Qt.ForegroundRole: row = index.row() return toVariant(self.getRowColor(row)) else: return CRecordListModel.data(self, index, role)