def __upload_refresh_item(self, reply, parent_item, *args, **kwargs):
""" Called by __upload_finished, if it is possible to add the new item
at the correct position in the tree, without refreshing the whole tree.
"""
item = json.loads(safe_decode(reply.readAll().data()))
# Remove old item first, before adding new one
updateIndex = kwargs.get('updateIndex')
if not updateIndex is None:
parent_item.takeChild(updateIndex)
# Add the item as a new item to the tree
new_item, kind = self.tree.add_item(parent_item, item['data'])
# Set new item as currently selected item
self.tree.setCurrentItem(new_item)
# Store item in kwargs so callback functions can use it
kwargs['new_item'] = new_item
# Perform the afterUploadCallback if it has been specified
after_upload_cb = kwargs.pop('afterUploadCallback', None)
if callable(after_upload_cb):
after_upload_cb(*args, **kwargs)
评论列表
文章目录