From d16418158d22a039e2a9a9665a5b337aed5f510a Mon Sep 17 00:00:00 2001 From: Damon Chaplin Date: Sun, 28 Oct 2001 22:13:13 +0000 Subject: get the tasks directly from the CalendarModel, so we get the filtering & 2001-10-28 Damon Chaplin * gui/print.c (print_todo_details): get the tasks directly from the CalendarModel, so we get the filtering & sorting for free. Fixes bug #10280. Hmm. This seems too easy. It isn't going to work is it... * gui/gnome-cal.c (gnome_calendar_get_task_pad): new function to get the TaskPad ECalendarTable, for printing. * gui/calendar-model.c: * gui/calendar-config.c (calendar_config_get_hide_completed_tasks_sexp): split this out from calendar-model.c so we could use it for printing, but ended up doing that a different way. * gui/dialogs/task-page.c (init_widgets): removed a duplicated signal connected to field_changed_cb(). svn path=/trunk/; revision=14302 --- calendar/gui/calendar-model.c | 56 ++++--------------------------------------- 1 file changed, 5 insertions(+), 51 deletions(-) (limited to 'calendar/gui/calendar-model.c') diff --git a/calendar/gui/calendar-model.c b/calendar/gui/calendar-model.c index 7e8cc5665b..f039a3d7e1 100644 --- a/calendar/gui/calendar-model.c +++ b/calendar/gui/calendar-model.c @@ -1897,8 +1897,7 @@ adjust_query_sexp (CalendarModel *model, const char *sexp) CalendarModelPrivate *priv; CalObjType type; char *type_sexp; - char *completed_sexp = ""; - gboolean free_completed_sexp = FALSE; + char *completed_sexp; char *new_sexp; priv = model->priv; @@ -1916,58 +1915,13 @@ adjust_query_sexp (CalendarModel *model, const char *sexp) /* Create a sub-expression for filtering out completed tasks, based on the config settings. */ - if (calendar_config_get_hide_completed_tasks ()) { - CalUnits units; - gint value; - - units = calendar_config_get_hide_completed_tasks_units (); - value = calendar_config_get_hide_completed_tasks_value (); - - if (value == 0) { - /* If the value is 0, we want to hide completed tasks - immediately, so we filter out all completed tasks.*/ - completed_sexp = "(not is-completed?)"; - } else { - char *location, *isodate; - icaltimezone *zone; - struct icaltimetype tt; - time_t t; - - /* Get the current time, and subtract the appropriate - number of days/hours/minutes. */ - location = calendar_config_get_timezone (); - zone = icaltimezone_get_builtin_timezone (location); - tt = icaltime_current_time_with_zone (zone); - - switch (units) { - case CAL_DAYS: - icaltime_adjust (&tt, -value, 0, 0, 0); - break; - case CAL_HOURS: - icaltime_adjust (&tt, 0, -value, 0, 0); - break; - case CAL_MINUTES: - icaltime_adjust (&tt, 0, 0, -value, 0); - break; - default: - g_assert_not_reached (); - } - - t = icaltime_as_timet_with_zone (tt, zone); - - /* Convert the time to an ISO date string, and build - the query sub-expression. */ - isodate = isodate_from_time_t (t); - completed_sexp = g_strdup_printf ("(not (completed-before? (make-time \"%s\")))", isodate); - free_completed_sexp = TRUE; - } - } + completed_sexp = calendar_config_get_hide_completed_tasks_sexp (); new_sexp = g_strdup_printf ("(and %s %s %s)", type_sexp, - completed_sexp, sexp); + completed_sexp ? completed_sexp : "", + sexp); g_free (type_sexp); - if (free_completed_sexp) - g_free (completed_sexp); + g_free (completed_sexp); #if 0 g_print ("Calendar model sexp:\n%s\n", new_sexp); -- cgit v1.2.3