From 5c6e2d7a3aea33ba62bea243c63027ceee448d4a Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Fri, 25 Mar 2016 20:00:52 +0800 Subject: [PATCH] gui/log: send Qt model notifications correctly --- artiq/gui/log.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/artiq/gui/log.py b/artiq/gui/log.py index 1a47428eb..fc2d79def 100644 --- a/artiq/gui/log.py +++ b/artiq/gui/log.py @@ -65,35 +65,30 @@ class Model(QtCore.QAbstractItemModel): self.pending_entries.append((severity, source, timestamp, message.split("\n"))) - def insertRows(self, position, rows=1, index=QtCore.QModelIndex()): - self.beginInsertRows(QtCore.QModelIndex(), position, position+rows-1) - self.endInsertRows() - - def removeRows(self, position, rows=1, index=QtCore.QModelIndex()): - self.beginRemoveRows(QtCore.QModelIndex(), position, position+rows-1) - self.endRemoveRows() - def timer_tick(self): if not self.pending_entries: return nrows = len(self.entries) records = self.pending_entries self.pending_entries = [] + + self.beginInsertRows(QtCore.QModelIndex(), nrows, nrows+len(records)-1) self.entries.extend(records) for rec in records: item = ModelItem(self, len(self.children_by_row)) self.children_by_row.append(item) for i in range(len(rec[3])-1): item.children_by_row.append(ModelItem(item, i)) - self.insertRows(nrows, len(records)) + self.endInsertRows() if len(self.entries) > self.depth: start = len(self.entries) - self.depth + self.beginRemoveRows(QtCore.QModelIndex(), 0, start-1) self.entries = self.entries[start:] self.children_by_row = self.children_by_row[start:] for child in self.children_by_row: child.row -= start - self.removeRows(0, start) + self.endRemoveRows() def index(self, row, column, parent): if parent.isValid():