changeset 18:4242b263fad4

allow adding/subtracting times while a project is running
author Thomas Arendsen Hein <thomas@intevation.de>
date Tue, 18 Aug 2009 16:07:21 +0200
parents 2712fc2b8276
children a9d58053bef7
files getan
diffstat 1 files changed, 54 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/getan	Tue Aug 18 15:45:12 2009 +0200
+++ b/getan	Tue Aug 18 16:07:21 2009 +0200
@@ -634,7 +634,60 @@
             stdscr.erase()
             ofs = self.render()
             stdscr.refresh()
-            
+            signal.signal(signal.SIGALRM, alarm_handler)
+            signal.alarm(1)
+        elif c == ord('+'):
+            signal.signal(signal.SIGALRM, signal.SIG_IGN)
+            stdscr.erase()
+            ofs = self.render()
+            old_cur = cursor_visible(1)
+            curses.echo()
+            stdscr.addstr(ofs + 1, 3, "Enter time to add: ")
+            timespec = stdscr.getstr()
+            try:
+                seconds = human_seconds(timespec)
+                if seconds > 0:
+                    self.current_project.start_time -= timedelta(seconds=seconds)
+            except ValueError:
+                pass
+            curses.noecho()
+            cursor_visible(old_cur)
+            stdscr.erase()
+            ofs = self.render()
+            stdscr.refresh()
+            signal.signal(signal.SIGALRM, alarm_handler)
+            signal.alarm(1)
+        elif c == ord('-'):
+            signal.signal(signal.SIGALRM, signal.SIG_IGN)
+            stdscr.erase()
+            ofs = self.render()
+            old_cur = cursor_visible(1)
+            curses.echo()
+            stdscr.addstr(ofs + 1, 3, "Enter time to subtract: ")
+            timespec = stdscr.getstr()
+            try:
+                seconds = human_seconds(timespec)
+                if seconds > 0:
+                    now = datetime.now()
+                    self.current_project.start_time += timedelta(seconds=seconds)
+                    if self.current_project.start_time > now:
+                        seconds = self.current_project.start_time - now
+                        self.current_project.start_time = now
+                        cur = None
+                        try:
+                            cur = self.con.cursor()
+                            self.current_project.substractTime(cur, seconds)
+                        finally:
+                            tolerantClose(cur)
+            except ValueError:
+                pass
+            curses.noecho()
+            cursor_visible(old_cur)
+            stdscr.erase()
+            ofs = self.render()
+            stdscr.refresh()
+            signal.signal(signal.SIGALRM, alarm_handler)
+            signal.alarm(1)
         elif curses.ascii.isascii(c):
             project_node = self.selection.findProject(chr(c))
             if project_node is None:
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)