Selections are persistent when rows inserted, rows automatically prune when 60s w/o reply
This commit is contained in:
parent
372e925277
commit
86a7bbbb2a
@ -238,10 +238,15 @@ class mainwindow(QtGui.QMainWindow):
|
||||
self.ui.text_livedata.append(msgstr)
|
||||
self.ui.text_livedata.verticalScrollBar().setSliderPosition(self.ui.text_livedata.verticalScrollBar().maximum())
|
||||
|
||||
#all this does is fade the ICAOs out as their last report gets older
|
||||
#TODO: fading is only done on paint() -- should you call paint() repeatedly to update when no data is received?
|
||||
#fades the ICAOs out as their last report gets older,
|
||||
#and display ident if available, ICAO otherwise
|
||||
class ICAOViewDelegate(QtGui.QStyledItemDelegate):
|
||||
def paint(self, painter, option, index):
|
||||
if option.state & QtGui.QStyle.State_Selected:
|
||||
painter.setBrush(QtGui.QPalette().highlight())
|
||||
#painter.setBrush(QtGui.QBrush(QtCore.Qt.red))
|
||||
painter.drawRect(option.rect)
|
||||
|
||||
if index.model().data(index.model().index(index.row(), 9)) != QtCore.QVariant():
|
||||
paintstr = index.model().data(index.model().index(index.row(), 9)).toString()
|
||||
else:
|
||||
@ -322,15 +327,30 @@ class dashboard_data_model(QtCore.QAbstractTableModel):
|
||||
#or inside the for loop, use dataChanged on each changed field (might be better)
|
||||
self.dataChanged.emit(self.createIndex(row, 0), self.createIndex(row, len(self._colnames)-1))
|
||||
else:
|
||||
#find new inserted row number
|
||||
icaos.append(record["icao"])
|
||||
newrowoffset = sorted(icaos).index(record["icao"])
|
||||
self.beginInsertRows(QtCore.QModelIndex(), newrowoffset, newrowoffset)
|
||||
newrecord = [None for x in xrange(len(self._colnames))]
|
||||
for col in xrange(0, len(self._colnames)):
|
||||
if self._colnames[col] in record:
|
||||
newrecord[col] = record[self._colnames[col]]
|
||||
self._data.append(newrecord)
|
||||
self._data = sorted(self._data, key = lambda x: x[0]) #sort by icao
|
||||
#create index to new row and use beginInsertRows/endInsertRows to tell the model that there's a new record in town
|
||||
self.reset()
|
||||
self.endInsertRows()
|
||||
self.lock.release()
|
||||
self.prune()
|
||||
|
||||
#weeds out ICAOs older than 5 minutes
|
||||
def prune(self):
|
||||
self.lock.acquire()
|
||||
for (index,row) in enumerate(self._data):
|
||||
if time.time() - row[1] >= 60:
|
||||
self.beginRemoveRows(QtCore.QModelIndex(), index, index)
|
||||
self._data.pop(index)
|
||||
self.endRemoveRows()
|
||||
self.lock.release()
|
||||
|
||||
|
||||
class dashboard_output(air_modes.modes_parse.modes_parse):
|
||||
def __init__(self, mypos, model):
|
||||
|
Loading…
Reference in New Issue
Block a user