changeset 25:155b23da504b

Bugfix and improvements in the process to move/delete entries.
author Ingo Weinzierl <ingo_weinzierl@web.de>
date Sun, 29 Aug 2010 19:56:11 +0200
parents c89721a3f0f8
children 5e4d2810a739
files ChangeLog getan.py getan/states.py getan/view.py
diffstat 4 files changed, 36 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Aug 29 19:10:48 2010 +0200
+++ b/ChangeLog	Sun Aug 29 19:56:11 2010 +0200
@@ -1,3 +1,14 @@
+2010-08-29  Ingo Weinzierl <ingo_weinzierl@web.de>
+
+	* getan/states.py: Enter MoveEntryState and DeleteEntryState only if there
+	  are selected entries.
+
+	* getan/view.py: Updating the footer text of a ListWidget will update the
+	  attribute 'footer' in the ListWidget and call ListWidget._update_view().
+
+	* getan.py: Bugfix: changed the attribute name (entry -> item) when
+	  accessing the EntryList's entries.
+
 2010-08-29  Ingo Weinzierl <ingo_weinzierl@web.de>
 
 	* getan/view.py: Bugfix: switching the time mode in ProjectList will also
--- a/getan.py	Sun Aug 29 19:10:48 2010 +0200
+++ b/getan.py	Sun Aug 29 19:56:11 2010 +0200
@@ -57,14 +57,14 @@
             while True:
                 node = self.entries_view.selection.pop()
                 if node.selected: node.select()
-                entries.append(node.entry)
+                entries.append(node.item)
                 logger.info("GetanController: move entry '%s' (id = %d, "\
                             "project id = %d) to project '%s'"
-                            % (node.entry.desc, node.entry.id,
-                               node.entry.project_id, project.desc))
+                            % (node.item.desc, node.item.id,
+                               node.item.project_id, project.desc))
 
                 if not old_project:
-                    old_project = self.project_by_id(node.entry.project_id)
+                    old_project = self.project_by_id(node.item.project_id)
         except IndexError, err:
             pass
         finally:
@@ -83,14 +83,14 @@
             while True:
                 node = self.entries_view.selection.pop()
                 if node.selected: node.select()
-                entries.append(node.entry)
+                entries.append(node.item)
                 logger.info("GetanController: delete entry '%s' (id = %d, "\
                             "project id = %d)"
-                            % (node.entry.desc, node.entry.id,
-                               node.entry.project_id))
+                            % (node.item.desc, node.item.id,
+                               node.item.project_id))
 
                 if proj is None:
-                    proj = self.project_by_id(node.entry.project_id)
+                    proj = self.project_by_id(node.item.project_id)
         except IndexError, err:
             pass
         finally:
--- a/getan/states.py	Sun Aug 29 19:10:48 2010 +0200
+++ b/getan/states.py	Sun Aug 29 19:56:11 2010 +0200
@@ -349,11 +349,13 @@
             return ret
 
         if 'd' in key:
-            return DeleteEntryState(self.projectlist_state,
-                                    self.controller, self.view)
+            if self.view.selection:
+                return DeleteEntryState(self.projectlist_state,
+                                        self.controller, self.view)
         if 'm' in key:
-            return MoveEntryState(self.projectlist_state,
-                                  self.controller, self.view)
+            if self.view.selection:
+                return MoveEntryState(self.projectlist_state,
+                                      self.controller, self.view)
         return self
 
 
@@ -372,8 +374,11 @@
             return ret
 
         if 'y' in key:
-            self.controller.delete_entries(self.view.selection)
-            self.renew_focus()
+            entries = [x.item for x in self.view.selection]
+            if entries:
+                self.controller.delete_entries(entries)
+                self.renew_focus()
+            self.view.set_footer_text("", 'entry_footer')
             return DefaultEntryListState(self.projectlist_state,
                                          self.controller, self.view)
 
@@ -401,13 +406,13 @@
         if 'y' in key and self.proj:
             logger.debug("MoveEntryState: move selected entries.")
             self.controller.move_selected_entries(self.proj)
+            self.renew_focus()
             self.view.set_footer_text('', 'entry_footer')
             self.proj = None
-            self.renew_focus()
             return DefaultEntryListState(self.projectlist_state,
                                          self.controller, self.view)
 
-        if 'n' in key:
+        if 'n' in key and self.proj:
             self.view.set_footer_text('', 'entry_footer')
             return DefaultEntryListState(self.projectlist_state,
                                          self.controller, self.view)
--- a/getan/view.py	Sun Aug 29 19:10:48 2010 +0200
+++ b/getan/view.py	Sun Aug 29 19:56:11 2010 +0200
@@ -48,10 +48,12 @@
     def set_footer_text(self, text, attr, edit=False):
         if edit:
             logger.debug("ListWidget: set footer text (edit) = '%s'" % text)
-            self.frame.set_footer(urwid.AttrWrap(urwid.Edit(text),attr))
+            self.footer = urwid.AttrWrap(urwid.Edit(text),attr)
+            self._update_view()
         else:
             logger.debug("ListWidget: set footer text = '%s'" % text)
-            self.frame.set_footer(urwid.AttrWrap(urwid.Text(text),attr))
+            self.footer = urwid.AttrWrap(urwid.Text(text),attr)
+            self._update_view()
 
     def row_count(self):
         if not self.rows: return 0
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)