forked from M-Labs/artiq
1
0
Fork 0

gui/models/DictSyncTreeSepModel: fix item row update

This commit is contained in:
Sebastien Bourdeauducq 2015-11-17 22:39:46 +08:00
parent 7bebc52959
commit 537fa2287b
1 changed files with 6 additions and 0 deletions

View File

@ -276,6 +276,8 @@ class DictSyncTreeSepModel(QtCore.QAbstractItemModel):
self.beginInsertRows(self._index_item(parent), row, row) self.beginInsertRows(self._index_item(parent), row, row)
parent.children_by_row.insert(row, item) parent.children_by_row.insert(row, item)
for next_item in parent.children_by_row[row+1:]:
next_item.row += 1
name_dict[name] = item name_dict[name] = item
self.endInsertRows() self.endInsertRows()
@ -308,6 +310,8 @@ class DictSyncTreeSepModel(QtCore.QAbstractItemModel):
self.beginRemoveRows(self._index_item(parent), row, row) self.beginRemoveRows(self._index_item(parent), row, row)
del parent.children_leaves_by_name[name] del parent.children_leaves_by_name[name]
del parent.children_by_row[row] del parent.children_by_row[row]
for next_item in parent.children_by_row[row:]:
next_item.row -= 1
self.endRemoveRows() self.endRemoveRows()
else: else:
# node # node
@ -319,6 +323,8 @@ class DictSyncTreeSepModel(QtCore.QAbstractItemModel):
self.beginRemoveRows(self._index_item(parent), row, row) self.beginRemoveRows(self._index_item(parent), row, row)
del parent.children_nodes_by_name[name] del parent.children_nodes_by_name[name]
del parent.children_by_row[row] del parent.children_by_row[row]
for next_item in parent.children_by_row[row:]:
next_item.row -= 1
self.endRemoveRows() self.endRemoveRows()
def __delitem__(self, k): def __delitem__(self, k):