def __init__(self, parent, init): ListSyncModel.__init__(self, ["Level", "Source", "Time", "Message"], parent, init) self.fixed_font = QtGui.QFont() self.fixed_font.setFamily("Monospace") self.white = QtGui.QBrush(QtGui.QColor(255, 255, 255)) self.black = QtGui.QBrush(QtGui.QColor(0, 0, 0)) self.debug_fg = QtGui.QBrush(QtGui.QColor(55, 55, 55)) self.warning_bg = QtGui.QBrush(QtGui.QColor(255, 255, 180)) self.error_bg = QtGui.QBrush(QtGui.QColor(255, 150, 150))
def data(self, index, role): if (role == QtCore.Qt.FontRole and index.isValid() and index.column() == 3): return self.fixed_font elif role == QtCore.Qt.BackgroundRole and index.isValid(): level = self.backing_store[index.row()][0] if level >= logging.ERROR: return self.error_bg elif level >= logging.WARNING: return self.warning_bg else: return self.white elif role == QtCore.Qt.ForegroundRole and index.isValid(): level = self.backing_store[index.row()][0] if level <= logging.DEBUG: return self.debug_fg else: return self.black else: return ListSyncModel.data(self, index, role)
def data(self, index, role): if (role == QtCore.Qt.FontRole and index.isValid() and index.column() == 1): return self.fixed_font else: return ListSyncModel.data(self, index, role)
def __init__(self, parent, init): ListSyncModel.__init__(self, ["RID", "Message"], parent, init) self.fixed_font = QtGui.QFont() self.fixed_font.setFamily("Monospace")