diff --git a/data/edit_dialog.ui b/data/edit_dialog.ui index 529f985590315bea18ea7df660d16425d99892ff..f26a4a1dd81c9d8d11f735d81567f36eac26de22 100644 --- a/data/edit_dialog.ui +++ b/data/edit_dialog.ui @@ -2,17 +2,6 @@ - - 100 - 1 - 2 - 10 - - - 60 - 10 - 30 - 24 12 @@ -24,10 +13,24 @@ 10 30 - + + 100 + 1 + 2 + 10 + + + 60 + 10 + 30 + True False + 12 + 12 + 12 + 12 vertical 6 @@ -52,7 +55,7 @@ False True - 1 + 2 @@ -65,7 +68,7 @@ False True - 2 + 3 @@ -102,7 +105,7 @@ False True - 3 + 4 @@ -115,7 +118,7 @@ False True - 4 + 5 @@ -155,7 +158,52 @@ False True - 5 + 6 + + + + + True + False + 0 + none + + + True + True + in + + + + True + True + Comments about this activity + 5 + 5 + 5 + 5 + GTK_INPUT_HINT_SPELLCHECK | GTK_INPUT_HINT_NONE + + + + + + + + True + False + Comments + + + + + False + True + 8 diff --git a/data/main_window.ui b/data/main_window.ui index bc5f95d13d0fe8ebc7260daa23e1bdf0ff836a54..738a0f2561eb9ac93625557e14253c06348f4d18 100644 --- a/data/main_window.ui +++ b/data/main_window.ui @@ -539,6 +539,54 @@ 3 + + + + True + False + 0 + none + + + True + True + in + + + + True + True + Comments about this activity + 5 + 5 + 5 + 5 + GTK_INPUT_HINT_SPELLCHECK | GTK_INPUT_HINT_NONE + + + + + + + + True + False + Comments + + + + + False + True + 4 + + + + True @@ -551,7 +599,7 @@ False True - 4 + 5 diff --git a/data/timetrack.css b/data/timetrack.css index 6acb15431c978229fd823d63b41ccee91aecbade..342b5a677ecfa9c8e1866b657c75a499e379eb3b 100644 --- a/data/timetrack.css +++ b/data/timetrack.css @@ -32,3 +32,12 @@ list row { background-image: none; text-shadow: none; } + +.comments-frame { + border: 1px solid @borders; +} + +.activity-comment { + padding: 6px; + font-size: small; +} diff --git a/timetrack/activity.py b/timetrack/activity.py index f4312909255be34f68092212308ce607a9fc8759..45d20d8482ecee12918e20773e8b233abbef179c 100644 --- a/timetrack/activity.py +++ b/timetrack/activity.py @@ -54,14 +54,16 @@ class Activity(GObject.Object): start: datetime = datetime.now() stop: Optional[datetime] = None id: Optional[int] = None + comments: Optional[str] = None def __init__(self, name="activity", start=datetime.now(), - stop=None, id=None): + stop=None, id=None, comments=None): super().__init__() self.name = name self.start = start self.stop = stop self.id = id + self.comments = comments or "" @property def seconds(self): @@ -86,6 +88,7 @@ class ActivityWidget(Gtk.Box): label = NotImplemented time_label = NotImplemented start_label = NotImplemented + comments = NotImplemented activity = NotImplemented activity_id = None @@ -118,8 +121,16 @@ class ActivityWidget(Gtk.Box): box2.pack_start(self.start_label, True, True, 6) + self.comments = Gtk.Label(label=act.comments) + self.comments.set_xalign(0.0) + self.comments.set_line_wrap(True) + context = self.comments.get_style_context() + context.add_class("dim-label") + context.add_class("activity-comment") + self.pack_start(box2, False, False, 6) self.add(box1) + self.add(self.comments) self.show_all() diff --git a/timetrack/db.py b/timetrack/db.py index 8c87c3de5a36884dbe2fc8615a172c9eeca793ac..cc9d9a6902443828c858bc742b4303611156ff2b 100644 --- a/timetrack/db.py +++ b/timetrack/db.py @@ -63,11 +63,13 @@ class DB: query = ''' UPDATE activities - SET activity = ?, start_date = ?, stop_date = ?, seconds = ? + SET activity = ?, start_date = ?, stop_date = ?, seconds = ?, + comments= ? WHERE id = ? ''' - c.execute(query, (act.name, act.start, act.stop, act.seconds, act.id)) + c.execute(query, (act.name, act.start, act.stop, act.seconds, + act.comments, act.id)) self.connection.commit() return act.id @@ -91,7 +93,8 @@ class DB: id, activity, start_date as "d1 [datetime]", - stop_date as "d2 [datetime]" + stop_date as "d2 [datetime]", + comments FROM activities WHERE id = ? ''' @@ -100,7 +103,8 @@ class DB: if not rows: return None row = rows[0] - return Activity(id=row[0], name=row[1], start=row[2], stop=row[3]) + return Activity(id=row[0], name=row[1], start=row[2], stop=row[3], + comments=row[4]) def get_last(self, limit=10, offset=0): c = self.connection.cursor() @@ -110,14 +114,16 @@ class DB: id, activity, start_date as "d1 [datetime]", - stop_date as "d2 [datetime]" + stop_date as "d2 [datetime]", + comments FROM activities ORDER BY start_date desc LIMIT {} OFFSET {} '''.format(limit, offset) for row in c.execute(query): - yield Activity(id=row[0], name=row[1], start=row[2], stop=row[3]) + yield Activity(id=row[0], name=row[1], start=row[2], stop=row[3], + comments=row[4]) def get_by_name(self, name, limit=10, offset=0): c = self.connection.cursor() @@ -127,7 +133,8 @@ class DB: id, activity, start_date as "d1 [datetime]", - stop_date as "d2 [datetime]" + stop_date as "d2 [datetime]", + comments FROM activities WHERE activity = ? ORDER BY start_date desc @@ -135,7 +142,8 @@ class DB: '''.format(limit, offset) for row in c.execute(query, (name, )): - yield Activity(id=row[0], name=row[1], start=row[2], stop=row[3]) + yield Activity(id=row[0], name=row[1], start=row[2], stop=row[3], + comments=row[4]) def report(self, start=None, end=None, activity=None): c = self.connection.cursor() diff --git a/timetrack/edit.py b/timetrack/edit.py index 79d77576798770e44ec027ad23234c187b09a981..ebefd6dde51aac69ddc1201b1434ed8ec50d374a 100644 --- a/timetrack/edit.py +++ b/timetrack/edit.py @@ -30,6 +30,7 @@ class EditDialog(Gtk.Dialog): self.start_date = builder.get_object("edit-calendar") self.start_hour = builder.get_object("edit-hour") self.start_minute = builder.get_object("edit-minute") + self.comments = builder.get_object("comments") self.working_hour = builder.get_object("edit-working-hour") self.working_minute = builder.get_object("edit-working-minute") @@ -61,6 +62,7 @@ class EditDialog(Gtk.Dialog): act = self.db.get(self.activity_id) self.activity_name.set_text(act.name) + self.comments.get_buffer().set_text(act.comments) self.start_date.set_property("day", act.start.day) self.start_date.set_property("month", act.start.month - 1) self.start_date.set_property("year", act.start.year) @@ -96,6 +98,11 @@ class EditDialog(Gtk.Dialog): name = self.activity_name.get_text() date = self.start_date.get_date() + comments_buf = self.comments.get_buffer() + comments_start = comments_buf.get_start_iter() + comments_end = comments_buf.get_end_iter() + comments = comments_buf.get_text(comments_start, comments_end, False) + start_h = self.start_hour.get_value() start_m = self.start_minute.get_value() @@ -110,7 +117,8 @@ class EditDialog(Gtk.Dialog): activity = Activity(id=self.activity_id, name=name, start=start_date, - stop=stop_date) + stop=stop_date, + comments=comments) aid = self.db.update(activity) activity.id = aid diff --git a/timetrack/main_window.py b/timetrack/main_window.py index af87e3a06f4a898d3f52b87b695dbdaa241d8ab3..49468e264bd0c821e8e67d176e7447b1ef9a9c71 100644 --- a/timetrack/main_window.py +++ b/timetrack/main_window.py @@ -130,6 +130,7 @@ class MainWindow(Gtk.ApplicationWindow): self.current_minute = self.builder.get_object('current-minute') self.current_day = self.builder.get_object('current-day') self.current_timer = self.builder.get_object('current-timer') + self.current_comments = self.builder.get_object('current-comments') self.current_name.bind_property('text', self.activity_label, 'label') self.timer.bind_property('label', self.current_timer, 'label') @@ -138,6 +139,7 @@ class MainWindow(Gtk.ApplicationWindow): self.current_hour.connect('changed', self.change_current) self.current_minute.connect('changed', self.change_current) self.current_day.connect('day-selected', self.change_current) + self.current_comments.get_buffer().connect('changed', self.change_current) def create_report(self): self.report_stack = self.builder.get_object('report-stack') @@ -550,9 +552,11 @@ class MainWindow(Gtk.ApplicationWindow): self.current_name.set_text(activity.name) self.current_hour.set_value(activity.start.hour) self.current_minute.set_value(activity.start.minute) - self.current_day.year = activity.start.year - self.current_day.month = activity.start.month - 1 - self.current_day.day = activity.start.day + self.current_day.select_month(activity.start.month - 1, + activity.start.year) + self.current_day.select_day(activity.start.day) + + self.current_comments.get_buffer().set_text(activity.comments) def change_current(self, *args, **kwargs): if not self.activity_id or not self.start_date: @@ -561,6 +565,11 @@ class MainWindow(Gtk.ApplicationWindow): new_date = self.current_day.get_date() name = self.current_name.get_text() + comments_buf = self.current_comments.get_buffer() + comments_start = comments_buf.get_start_iter() + comments_end = comments_buf.get_end_iter() + comments = comments_buf.get_text(comments_start, comments_end, False) + self.start_date = datetime(new_date.year, new_date.month + 1, new_date.day, @@ -569,5 +578,7 @@ class MainWindow(Gtk.ApplicationWindow): activity = Activity(id=self.activity_id, name=name, - start=self.start_date, stop=None) + start=self.start_date, + stop=None, + comments=comments) self.application.db.update(activity)