Update history and MRU lists when objects are deleted
svn: r14580
This commit is contained in:
parent
9efe53787d
commit
f21fb8d6d8
@ -80,10 +80,22 @@ class History(gen.utils.Callback):
|
|||||||
'mru-changed' : (list, )
|
'mru-changed' : (list, )
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, dbstate, nav_type):
|
||||||
gen.utils.Callback.__init__(self)
|
gen.utils.Callback.__init__(self)
|
||||||
self.clear()
|
self.clear()
|
||||||
|
|
||||||
|
dbstate.connect('database-changed', self.connect_signals)
|
||||||
|
self.signal_map = {}
|
||||||
|
self.signal_map[nav_type.lower() + '-delete'] = self.handles_removed
|
||||||
|
self.signal_map[nav_type.lower() + '-rebuild'] = self.history_changed
|
||||||
|
|
||||||
|
def connect_signals(self, dbstate):
|
||||||
|
"""
|
||||||
|
Connects database signals when the database has changed.
|
||||||
|
"""
|
||||||
|
for sig in self.signal_map:
|
||||||
|
dbstate.connect(sig, self.signal_map[sig])
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
"""
|
"""
|
||||||
Clears the history, resetting the values back to their defaults
|
Clears the history, resetting the values back to their defaults
|
||||||
@ -191,6 +203,22 @@ class History(gen.utils.Callback):
|
|||||||
if not self.at_end():
|
if not self.at_end():
|
||||||
self.history = self.history[0:self.index+1]
|
self.history = self.history[0:self.index+1]
|
||||||
|
|
||||||
|
def handles_removed(self, handle_list):
|
||||||
|
"""
|
||||||
|
Called in response to an object-delete signal.
|
||||||
|
Removes a list of handles from the history.
|
||||||
|
"""
|
||||||
|
for handle in handle_list:
|
||||||
|
self.remove(handle)
|
||||||
|
|
||||||
|
def history_changed(self):
|
||||||
|
"""
|
||||||
|
Called in response to an object-rebuild signal.
|
||||||
|
Objects in the history list may have been deleted.
|
||||||
|
"""
|
||||||
|
self.clear()
|
||||||
|
self.emit('mru-changed', (self.mru, ))
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Recent Docs Menu
|
# Recent Docs Menu
|
||||||
@ -370,13 +398,13 @@ class DisplayState(gen.utils.Callback):
|
|||||||
"""
|
"""
|
||||||
return self.history_lookup.get((nav_type, nav_group))
|
return self.history_lookup.get((nav_type, nav_group))
|
||||||
|
|
||||||
def register(self, nav_type, nav_group):
|
def register(self, dbstate, nav_type, nav_group):
|
||||||
"""
|
"""
|
||||||
Create a history and navigation object for the specified
|
Create a history and navigation object for the specified
|
||||||
navigation type and group, if they don't exist.
|
navigation type and group, if they don't exist.
|
||||||
"""
|
"""
|
||||||
if (nav_type, nav_group) not in self.history_lookup:
|
if (nav_type, nav_group) not in self.history_lookup:
|
||||||
history = History()
|
history = History(dbstate, nav_type)
|
||||||
self.history_lookup[(nav_type, nav_group)] = history
|
self.history_lookup[(nav_type, nav_group)] = history
|
||||||
|
|
||||||
def get_active(self, nav_type, nav_group=0):
|
def get_active(self, nav_type, nav_group=0):
|
||||||
|
@ -68,7 +68,7 @@ class Gramplet(object):
|
|||||||
Connect the given method to the active-changed signal for the
|
Connect the given method to the active-changed signal for the
|
||||||
navigation type requested.
|
navigation type requested.
|
||||||
"""
|
"""
|
||||||
self.uistate.register(nav_type, self.nav_group)
|
self.uistate.register(self.dbstate, nav_type, self.nav_group)
|
||||||
history = self.uistate.get_history(nav_type, self.nav_group)
|
history = self.uistate.get_history(nav_type, self.nav_group)
|
||||||
self.connect(history, "active-changed", method)
|
self.connect(history, "active-changed", method)
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ class NavigationView(PageView):
|
|||||||
self.nav_group = nav_group
|
self.nav_group = nav_group
|
||||||
self.mru_active = DISABLED
|
self.mru_active = DISABLED
|
||||||
|
|
||||||
self.uistate.register(self.navigation_type(), self.nav_group)
|
self.uistate.register(state, self.navigation_type(), self.nav_group)
|
||||||
|
|
||||||
|
|
||||||
def navigation_type(self):
|
def navigation_type(self):
|
||||||
|
@ -297,10 +297,6 @@ class BasePersonView(ListView):
|
|||||||
# commit the transaction
|
# commit the transaction
|
||||||
self.dbstate.db.transaction_commit(trans, active_name)
|
self.dbstate.db.transaction_commit(trans, active_name)
|
||||||
|
|
||||||
# select the previously active person, turn off the busy cursor
|
|
||||||
history = self.uistate.get_history(self.navigation_type(),
|
|
||||||
self.navigation_group())
|
|
||||||
history.remove(person.handle)
|
|
||||||
self.uistate.set_busy_cursor(False)
|
self.uistate.set_busy_cursor(False)
|
||||||
|
|
||||||
def dummy_report(self, obj):
|
def dummy_report(self, obj):
|
||||||
|
Loading…
Reference in New Issue
Block a user