forked from M-Labs/artiq
fix DictSyncModel
This commit is contained in:
parent
13a36bf911
commit
eebe0fefd8
@ -121,15 +121,19 @@ class DictSyncModel(QtCore.QAbstractTableModel):
|
|||||||
old_row = self.row_to_key.index(k)
|
old_row = self.row_to_key.index(k)
|
||||||
new_row = self._find_row(k, v)
|
new_row = self._find_row(k, v)
|
||||||
if old_row == new_row:
|
if old_row == new_row:
|
||||||
|
self.backing_store[k] = v
|
||||||
self.dataChanged.emit(self.index(old_row, 0),
|
self.dataChanged.emit(self.index(old_row, 0),
|
||||||
self.index(old_row, len(self.headers)-1))
|
self.index(old_row, len(self.headers)-1))
|
||||||
else:
|
else:
|
||||||
self.beginMoveRows(QtCore.QModelIndex(), old_row, old_row,
|
begin = min(old_row, new_row)
|
||||||
QtCore.QModelIndex(), new_row)
|
end = max(old_row, new_row)
|
||||||
|
self.beginMoveRows(QtCore.QModelIndex(), begin + 1, end - 1,
|
||||||
|
QtCore.QModelIndex(), begin)
|
||||||
self.backing_store[k] = v
|
self.backing_store[k] = v
|
||||||
self.row_to_key[old_row], self.row_to_key[new_row] = \
|
self.row_to_key.pop(old_row)
|
||||||
self.row_to_key[new_row], self.row_to_key[old_row]
|
if old_row < new_row:
|
||||||
if old_row != new_row:
|
new_row -= 1
|
||||||
|
self.row_to_key.insert(new_row, k)
|
||||||
self.endMoveRows()
|
self.endMoveRows()
|
||||||
else:
|
else:
|
||||||
row = self._find_row(k, v)
|
row = self._find_row(k, v)
|
||||||
|
Loading…
Reference in New Issue
Block a user