changeset 312:dc92981ec591

Avoid resetting the focus when changing from DeleteEntryState back to the DefaultEntryListState This change will avoids resetting the focus of the current entry in the EntryList to the first entry.
author Björn Ricks <bjoern.ricks@intevation.de>
date Fri, 11 Oct 2013 12:09:06 +0200
parents 349b4571e120
children eb05d803249e
files getan/states.py
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/getan/states.py	Fri Oct 11 12:06:42 2013 +0200
+++ b/getan/states.py	Fri Oct 11 12:09:06 2013 +0200
@@ -523,11 +523,13 @@
         if keys.get_entry_delete() in key:
             if self.view.selection:
                 self.set_next_state(DeleteEntryState(self.projectlist_state,
+                                                     self,
                                                      self.controller,
                                                      self.view))
             else:
                 entry = self.view.item_in_focus()
                 self.set_next_state(DeleteEntryState(self.projectlist_state,
+                                                     self,
                                                      self.controller, self.view,
                                                      [entry]))
             return True
@@ -555,10 +557,11 @@
         'delete': _("Really delete this entry? (y/n)"),
     }
 
-    def __init__(self, state, controller, view, entries=None):
+    def __init__(self, state, old_state, controller, view, entries=None):
         super(DeleteEntryState, self).__init__(state, controller, view)
         self.view.set_footer_text(self.msg('delete'), 'question')
         self.entries = entries
+        self.old_state = old_state
         if not self.entries:
             self.entries = [x.item for x in self.view.selection]
 
@@ -569,17 +572,15 @@
                 self.controller.delete_entries(self.entries)
                 self.renew_focus()
             self.view.set_footer_text("", 'entry_footer')
-            self.set_next_state(DefaultEntryListState(self.projectlist_state,
-                                                      self.controller,
-                                                      self.view))
+            # avoid creating new DefaultEntryListState and setting focus
+            self.set_next_state(self.old_state)
             self.controller.project_view.show_total_time()
             return True
 
         if 'n' in key or keys.get_escape() in key:
             self.view.set_footer_text("", 'entry_footer')
-            self.set_next_state(DefaultEntryListState(self.projectlist_state,
-                                                      self.controller,
-                                                      self.view))
+            # avoid creating new DefaultEntryListState and setting focus
+            self.set_next_state(self.old_state)
             return True
 
         return False
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)