forked from M-Labs/artiq
1
0
Fork 0

gui/log: display level and date information in tooltips

This commit is contained in:
Sebastien Bourdeauducq 2016-01-23 22:17:08 -05:00
parent ae19f1c75d
commit 56cbf261b0
1 changed files with 9 additions and 13 deletions

View File

@ -25,7 +25,7 @@ class Model(QtCore.QAbstractTableModel):
def __init__(self, init): def __init__(self, init):
QtCore.QAbstractTableModel.__init__(self) QtCore.QAbstractTableModel.__init__(self)
self.headers = ["Level", "Source", "Time", "Message"] self.headers = ["Source", "Message"]
self.entries = list(map(_make_wrappable, init)) self.entries = list(map(_make_wrappable, init))
self.pending_entries = [] self.pending_entries = []
@ -85,7 +85,7 @@ class Model(QtCore.QAbstractTableModel):
def data(self, index, role): def data(self, index, role):
if index.isValid(): if index.isValid():
if (role == QtCore.Qt.FontRole if (role == QtCore.Qt.FontRole
and index.column() == 3): and index.column() == 1):
return self.fixed_font return self.fixed_font
elif role == QtCore.Qt.BackgroundRole: elif role == QtCore.Qt.BackgroundRole:
level = self.entries[index.row()][0] level = self.entries[index.row()][0]
@ -105,13 +105,13 @@ class Model(QtCore.QAbstractTableModel):
v = self.entries[index.row()] v = self.entries[index.row()]
column = index.column() column = index.column()
if column == 0: if column == 0:
return log_level_to_name(v[0])
elif column == 1:
return v[1] return v[1]
elif column == 2:
return time.strftime("%m/%d %H:%M:%S", time.localtime(v[2]))
else: else:
return v[3] return v[3]
elif role == QtCore.Qt.ToolTipRole:
v = self.entries[index.row()]
return (log_level_to_name(v[0]) + ", " +
time.strftime("%m/%d %H:%M:%S", time.localtime(v[2])))
class _LogFilterProxyModel(QSortFilterProxyModel): class _LogFilterProxyModel(QSortFilterProxyModel):
@ -123,15 +123,11 @@ class _LogFilterProxyModel(QSortFilterProxyModel):
def filterAcceptsRow(self, sourceRow, sourceParent): def filterAcceptsRow(self, sourceRow, sourceParent):
model = self.sourceModel() model = self.sourceModel()
index = model.index(sourceRow, 0, sourceParent) accepted_level = model.entries[sourceRow][0] >= self.min_level
data = model.data(index, QtCore.Qt.DisplayRole)
accepted_level = getattr(logging, data) >= self.min_level
if self.freetext: if self.freetext:
index = model.index(sourceRow, 1, sourceParent) data_source = model.entries[sourceRow][1]
data_source = model.data(index, QtCore.Qt.DisplayRole) data_message = model.entries[sourceRow][3]
index = model.index(sourceRow, 3, sourceParent)
data_message = model.data(index, QtCore.Qt.DisplayRole)
accepted_freetext = (self.freetext in data_source accepted_freetext = (self.freetext in data_source
or self.freetext in data_message) or self.freetext in data_message)
else: else: