gui/DictSync: better support of nested structs

This commit is contained in:
Sebastien Bourdeauducq 2015-07-14 17:30:55 +02:00
parent 1edeb5a13f
commit 55cd41444e
1 changed files with 18 additions and 2 deletions

View File

@ -6,13 +6,29 @@ class _DictSyncSubstruct:
self.update_cb = update_cb
self.ref = ref
def __getitem__(self, key):
return _DictSyncSubstruct(self.update_cb, self.ref[key])
def append(self, x):
self.ref.append(x)
self.update_cb()
def insert(self, i, x):
self.ref.insert(i, x)
self.update_cb()
def pop(self, i=-1):
self.ref.pop(i)
self.update_cb()
def __setitem__(self, key, value):
self.ref[key] = value
self.update_cb()
def __delitem__(self, key):
self.ref.__delitem__(key)
self.update_cb()
def __getitem__(self, key):
return _DictSyncSubstruct(self.update_cb, self.ref[key])
class DictSyncModel(QtCore.QAbstractTableModel):
def __init__(self, headers, parent, init):