def data(self, index, role): row, col = index.row(), index.column() if not index.isValid(): return '' elif role == Qt.BackgroundRole and self.show_confidence_colors: confidence = self.arraydata[row][self.CONFIDENCE_COL] saturation = 0.40 value = 1.0 red_hue = 0.0 green_hue = 0.333 yellow_hue = 0.1665 if confidence >= 3: return QBrush(QColor.fromHsvF(green_hue, saturation, value)) elif confidence: return QBrush(QColor.fromHsvF(yellow_hue, saturation, value)) else: return QBrush(QColor.fromHsvF(red_hue, saturation, value)) elif role == Qt.CheckStateRole and col == self.ENABLED_COL: if self.arraydata[row][self.ENABLED_COL].checkState(): return Qt.Checked else: return Qt.Unchecked elif role == Qt.DisplayRole and col == self.READER_APP_COL: return unicode(self.arraydata[row][self.READER_APP_COL].text()) elif role == Qt.DisplayRole and col == self.TITLE_COL: return unicode(self.arraydata[row][self.TITLE_COL].text()) elif role == Qt.DisplayRole and col == self.AUTHOR_COL: return unicode(self.arraydata[row][self.AUTHOR_COL].text()) elif role == Qt.DisplayRole and col == self.LAST_ANNOTATION_COL: return unicode( self.arraydata[row][self.LAST_ANNOTATION_COL].text()) elif role == Qt.TextAlignmentRole and (col in self.centered_columns): return Qt.AlignHCenter elif role != Qt.DisplayRole: return None return self.arraydata[index.row()][index.column()]
def data(self, index, role): row, col = index.row(), index.column() if not index.isValid(): return '' elif role == Qt.BackgroundRole and self.show_confidence_colors: confidence = self.arraydata[row][self.CONFIDENCE_COL] saturation = 0.40 value = 1.0 red_hue = 0.0 green_hue = 0.333 yellow_hue = 0.1665 if confidence >= 3: return QBrush(QColor.fromHsvF(green_hue, saturation, value)) elif confidence: return QBrush(QColor.fromHsvF(yellow_hue, saturation, value)) else: return QBrush(QColor.fromHsvF(red_hue, saturation, value)) elif role == Qt.CheckStateRole and col == self.ENABLED_COL: if self.arraydata[row][self.ENABLED_COL].checkState(): return Qt.Checked else: return Qt.Unchecked elif role == Qt.DisplayRole and col == self.READER_APP_COL: return unicode(self.arraydata[row][self.READER_APP_COL].text()) elif role == Qt.DisplayRole and col == self.TITLE_COL: return unicode(self.arraydata[row][self.TITLE_COL].text()) elif role == Qt.DisplayRole and col == self.AUTHOR_COL: return unicode(self.arraydata[row][self.AUTHOR_COL].text()) elif role == Qt.DisplayRole and col == self.LAST_ANNOTATION_COL: return unicode(self.arraydata[row][self.LAST_ANNOTATION_COL].text()) elif role == Qt.TextAlignmentRole and (col in self.centered_columns): return Qt.AlignHCenter elif role != Qt.DisplayRole: return None return self.arraydata[index.row()][index.column()]