remember selected item in embedded list tabs after change

svn: r12835
This commit is contained in:
Benny Malengier 2009-07-24 06:14:21 +00:00
parent ed2ed4702b
commit 72b0b7361c
3 changed files with 31 additions and 4 deletions

View File

@ -459,6 +459,10 @@ class EmbeddedList(ButtonTab):
"""
#during rebuild, don't do _selection_changed
self.dirty_selection = True
(model, node) = self.selection.get_selected()
selectedpath = None
if node:
selectedpath = model.get_path(node)
try:
self.model = self.construct_model()
except AttributeError, msg:
@ -469,13 +473,22 @@ class EmbeddedList(ButtonTab):
return
self.tree.set_model(self.model)
#reset previous select
if not selectedpath is None:
self.selection.select_path(selectedpath)
#self.selection.select_path(node)
self._set_label()
#model and tree are reset, allow _selection_changed again, and force it
self.dirty_selection = False
self._selection_changed()
self.post_rebuild()
self.post_rebuild(selectedpath)
def post_rebuild(self):
def post_rebuild(self, prebuildpath):
"""
Allow post rebuild embeddedlist specific handling.
@param prebuildpath: path selected before rebuild, None if none
@type prebuildpath: tree path
"""
pass
def rebuild_callback(self):

View File

@ -304,5 +304,12 @@ class EventEmbedList(GroupEmbeddedList):
"""
self._non_native_change()
def post_rebuild(self):
def post_rebuild(self, prebuildpath):
"""
Allow post rebuild specific handling.
@param prebuildpath: path selected before rebuild, None if none
@type prebuildpath: tree path
"""
self.tree.expand_all()
if not prebuildpath is None:
self.selection.select_path(prebuildpath)

View File

@ -198,5 +198,12 @@ class NameEmbedList(GroupEmbeddedList):
if row_from[0] == self._WORKGROUP and row_to[0] == NameModel.DEFINDEX:
self.set_default_name(obj)
def post_rebuild(self):
def post_rebuild(self, prebuildpath):
"""
Allow post rebuild specific handling.
@param prebuildpath: path selected before rebuild, None if none
@type prebuildpath: tree path
"""
self.tree.expand_all()
if not prebuildpath is None:
self.selection.select_path(prebuildpath)