Skip to content

Commit 3347faf

Browse files
committed
feat(model)!: add MTableModel sync_relation parameter
1 parent 54008e4 commit 3347faf

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

dayu_widgets/item_model.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,14 @@ def setData(self, index, value, role=QtCore.Qt.EditRole):
233233
set_obj_value(data_obj, key, value)
234234
self.dataChanged.emit(index, index)
235235

236-
# 更新它的children
237-
for row, sub_obj in enumerate(get_obj_value(data_obj, "children", [])):
238-
set_obj_value(sub_obj, key, value)
239-
sub_index = self.index(row, index.column(), index)
240-
self.dataChanged.emit(sub_index, sub_index)
241-
236+
# 是否同步更新parent, child
242237
if self.sync_relation:
238+
# 更新它的children
239+
for row, sub_obj in enumerate(get_obj_value(data_obj, "children", [])):
240+
set_obj_value(sub_obj, key, value)
241+
sub_index = self.index(row, index.column(), index)
242+
self.dataChanged.emit(sub_index, sub_index)
243+
243244
# 更新它的parent
244245
parent_index = index.parent()
245246
if parent_index.isValid():

0 commit comments

Comments
 (0)