Re: [evolution-patches] Fix for #264449 [Tasks]
- From: "Jukaku Mubeen" <jmubeen novell com>
- To: "Jukaku Mubeen" <JMubeen novell com>, "P Chenthill" <PChenthill novell com>
- Cc: evolution-patches gnome org
- Subject: Re: [evolution-patches] Fix for #264449 [Tasks]
- Date: Sat, 01 Oct 2005 07:12:54 -0600
Hi,
Attached is patch with necessary changes.
Thanks, Mubeen
>>> chen <pchenthill novell com> 09/08/05 14:25 PM >>>
Hi,
The function hide of tasks should not be present in e-cal-model,
probably can be moved to e-calendar-table. We need to get all the
objects to be displayed only when the configuration is changed for
displaying the completed tasks. This also cover the color change for to
show the due (for today) and over due tasks.
priv->objects->len - 1);
+ } else {
+ e_table_model_pre_change (E_TABLE_MODEL
(model));
+ pos = get_position_in_array
(priv->objects, comp_data);
+ e_table_model_row_changed (E_TABLE_MODEL
(model), pos);
+ }
+
Is it necessary to emit a row changed signal here ?
thanks, Chenthill.
Mon, 2005-08-29 at 04:53 -0600, Jukaku Mubeen wrote:
> Hi,
>
> Attached is modified patch to fix the bug.
> Changelog explains it all.
>
> Thanks,
> Mubeen
> _______________________________________________
> evolution-patches mailing list
> evolution-patches lists ximian com
> http://lists.ximian.com/mailman/listinfo/evolution-patches
Index: calendar/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.2802.2.14
diff -u -p -r1.2802.2.14 ChangeLog
--- calendar/ChangeLog 1 Oct 2005 06:19:15 -0000 1.2802.2.14
+++ calendar/ChangeLog 1 Oct 2005 12:51:51 -0000
@@ -1,3 +1,27 @@
+2005-10-01 Mubeen Jukaku <jmubeen novell com>
+
+ Fixes #264449
+ * gui/e-tasks.c: (update_view_cb),
+ (config_hide_completed_tasks_changed_cb): Use hide_completed_tasks
+ instead of update_view
+ * gui/gnome-cal.c (update_todo_view_cb),
+ (config_hide_completed_tasks_changed_cb): ditto
+ * gui/e-calendar-table.[ch]:
+ (e_cal_model_hide_completed_tasks): New function to hide
+ completed tasks
+ * gui/calendar-config.[ch]:
+ (calendar_config_get_hide_completed_tasks_sexp): Added a parameter
+ get_completed to get completed or not completed tasks
+ * gui/misc.[ch]:
+ (get_position_in_array): Moved from gui/e-cal-model.c
+ * gui/e-cal-model.[ch]:
+ (e_cal_model_set_instance_times): Renamed from static function
+ set_instance_times
+ * gui/e-cal-model-tasks.[ch]:
+ Globalized structure ECalModelTasksDueStatus.
+ (e_cal_model_tasks_get_due_status): Renamed from static function
+ get_due_status
+
2005-10-01 P. S. Chakravarthi <pchakravarthi novell com>
Fixes #269685
Index: calendar/gui/calendar-config.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/calendar-config.c,v
retrieving revision 1.77
diff -u -p -r1.77 calendar-config.c
--- calendar/gui/calendar-config.c 13 Jul 2005 10:36:14 -0000 1.77
+++ calendar/gui/calendar-config.c 1 Oct 2005 12:52:47 -0000
@@ -1077,11 +1077,13 @@ calendar_config_set_default_reminder_uni
/**
* calendar_config_get_hide_completed_tasks_sexp:
*
+ * @get_completed: Whether to form subexpression that
+ * gets completed or not completed tasks.
* Returns the subexpression to use to filter out completed tasks according
* to the config settings. The returned sexp should be freed.
**/
char*
-calendar_config_get_hide_completed_tasks_sexp (void)
+calendar_config_get_hide_completed_tasks_sexp (gboolean get_completed)
{
char *sexp = NULL;
@@ -1094,8 +1096,11 @@ calendar_config_get_hide_completed_tasks
if (value == 0) {
/* If the value is 0, we want to hide completed tasks
- immediately, so we filter out all completed tasks.*/
- sexp = g_strdup ("(not is-completed?)");
+ immediately, so we filter out all complete/incomplete tasks.*/
+ if (!get_completed)
+ sexp = g_strdup ("(not is-completed?)");
+ else
+ sexp = g_strdup ("(is-completed?)");
} else {
char *isodate;
icaltimezone *zone;
@@ -1126,7 +1131,10 @@ calendar_config_get_hide_completed_tasks
/* Convert the time to an ISO date string, and build
the query sub-expression. */
isodate = isodate_from_time_t (t);
- sexp = g_strdup_printf ("(not (completed-before? (make-time \"%s\")))", isodate);
+ if (!get_completed)
+ sexp = g_strdup_printf ("(not (completed-before? (make-time \"%s\")))", isodate);
+ else
+ sexp = g_strdup_printf ("(completed-before? (make-time \"%s\"))", isodate);
}
}
Index: calendar/gui/calendar-config.h
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/calendar-config.h,v
retrieving revision 1.39
diff -u -p -r1.39 calendar-config.h
--- calendar/gui/calendar-config.h 30 May 2005 09:14:26 -0000 1.39
+++ calendar/gui/calendar-config.h 1 Oct 2005 12:53:29 -0000
@@ -183,7 +183,7 @@ gint calendar_config_get_hide_complete
void calendar_config_set_hide_completed_tasks_value(gint value);
guint calendar_config_add_notification_hide_completed_tasks_value (GConfClientNotifyFunc func, gpointer data);
-char* calendar_config_get_hide_completed_tasks_sexp (void);
+char * calendar_config_get_hide_completed_tasks_sexp (gboolean get_completed);
/* Confirmation options */
gboolean calendar_config_get_confirm_delete (void);
Index: calendar/gui/e-tasks.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-tasks.c,v
retrieving revision 1.120.2.1
diff -u -p -r1.120.2.1 e-tasks.c
--- calendar/gui/e-tasks.c 29 Sep 2005 12:49:17 -0000 1.120.2.1
+++ calendar/gui/e-tasks.c 1 Oct 2005 12:54:01 -0000
@@ -291,7 +291,7 @@ update_view (ETasks *tasks)
model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
- if ((new_sexp = calendar_config_get_hide_completed_tasks_sexp()) != NULL) {
+ if ((new_sexp = calendar_config_get_hide_completed_tasks_sexp (FALSE)) != NULL) {
real_sexp = g_strdup_printf ("(and %s %s)", new_sexp, priv->sexp);
e_cal_model_set_search_query (model, real_sexp);
g_free (new_sexp);
@@ -302,10 +302,26 @@ update_view (ETasks *tasks)
e_cal_component_preview_clear (E_CAL_COMPONENT_PREVIEW (priv->preview));
}
+static void
+hide_completed_tasks (ETasks *tasks, gboolean config_changed)
+{
+ ETasksPrivate *priv;
+ ECalModel *model;
+
+ g_return_if_fail (tasks != NULL);
+ g_return_if_fail (E_IS_TASKS (tasks));
+
+ priv = tasks->priv;
+
+ model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
+
+ e_calendar_table_hide_completed_tasks (e_tasks_get_calendar_table (tasks), priv->clients_list, config_changed);
+}
+
static gboolean
update_view_cb (ETasks *tasks)
{
- update_view (tasks);
+ hide_completed_tasks (tasks, FALSE);
return TRUE;
}
@@ -313,7 +329,7 @@ update_view_cb (ETasks *tasks)
static void
config_hide_completed_tasks_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
{
- update_view (data);
+ hide_completed_tasks (data, TRUE);
}
static void
Index: calendar/gui/gnome-cal.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/gnome-cal.c,v
retrieving revision 1.386.2.1
diff -u -p -r1.386.2.1 gnome-cal.c
--- calendar/gui/gnome-cal.c 29 Sep 2005 12:49:17 -0000 1.386.2.1
+++ calendar/gui/gnome-cal.c 1 Oct 2005 12:54:28 -0000
@@ -1135,7 +1135,7 @@ update_todo_view (GnomeCalendar *gcal)
model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo));
- if ((sexp = calendar_config_get_hide_completed_tasks_sexp()) != NULL) {
+ if ((sexp = calendar_config_get_hide_completed_tasks_sexp (FALSE)) != NULL) {
priv->todo_sexp = g_strdup_printf ("(and %s %s)", sexp, priv->sexp);
e_cal_model_set_search_query (model, priv->todo_sexp);
g_free (sexp);
@@ -1146,10 +1146,23 @@ update_todo_view (GnomeCalendar *gcal)
}
+static void
+hide_completed_tasks (GnomeCalendar *gcal, gboolean config_changed)
+{
+ GnomeCalendarPrivate *priv;
+
+ g_return_if_fail (gcal != NULL);
+ g_return_if_fail (GNOME_IS_CALENDAR(gcal));
+
+ priv = gcal->priv;
+
+ e_calendar_table_hide_completed_tasks (E_CALENDAR_TABLE (priv->todo), priv->clients_list[E_CAL_SOURCE_TYPE_TODO], config_changed);
+}
+
static gboolean
update_todo_view_cb (GnomeCalendar *gcal)
{
- update_todo_view(gcal);
+ hide_completed_tasks (gcal, FALSE);
return TRUE;
}
@@ -1172,7 +1185,7 @@ update_marcus_bains_line_cb (GnomeCalend
static void
config_hide_completed_tasks_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
{
- update_todo_view (data);
+ hide_completed_tasks (data, TRUE);
}
static void
Index: calendar/gui/misc.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/misc.c,v
retrieving revision 1.4
diff -u -p -r1.4 misc.c
--- calendar/gui/misc.c 17 Jan 2005 13:39:19 -0000 1.4
+++ calendar/gui/misc.c 1 Oct 2005 12:55:16 -0000
@@ -78,3 +78,16 @@ get_uri_without_password (const char *fu
return uristr;
}
+
+gint
+get_position_in_array (GPtrArray *objects, gpointer item)
+{
+ gint i;
+
+ for (i = 0; i < objects->len; i++) {
+ if (g_ptr_array_index (objects, i) == item)
+ return i;
+ }
+
+ return -1;
+}
Index: calendar/gui/misc.h
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/misc.h,v
retrieving revision 1.3
diff -u -p -r1.3 misc.h
--- calendar/gui/misc.h 9 Dec 2002 21:26:53 -0000 1.3
+++ calendar/gui/misc.h 1 Oct 2005 12:55:30 -0000
@@ -26,5 +26,6 @@
gboolean string_is_empty (const char *value);
char *get_uri_without_password (const char *uri);
+gint get_position_in_array (GPtrArray *objects, gpointer item);
#endif
Index: calendar/gui/e-cal-model.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-cal-model.c,v
retrieving revision 1.61.2.1
diff -u -p -r1.61.2.1 e-cal-model.c
--- calendar/gui/e-cal-model.c 30 Sep 2005 13:46:14 -0000 1.61.2.1
+++ calendar/gui/e-cal-model.c 1 Oct 2005 12:56:03 -0000
@@ -1268,19 +1268,6 @@ search_by_uid_and_client (ECalModelPriva
return NULL;
}
-static gint
-get_position_in_array (GPtrArray *objects, gpointer item)
-{
- gint i;
-
- for (i = 0; i < objects->len; i++) {
- if (g_ptr_array_index (objects, i) == item)
- return i;
- }
-
- return -1;
-}
-
typedef struct {
ECal *client;
ECalView *query;
@@ -1313,21 +1300,6 @@ add_instance_cb (ECalComponent *comp, ti
return TRUE;
}
-static void
-set_instance_times (ECalModelComponent *comp_data, icaltimezone *zone)
-{
- struct icaltimetype recur_time, start_time, end_time;
-
- recur_time = icalcomponent_get_recurrenceid (comp_data->icalcomp);
- start_time = icalcomponent_get_dtstart (comp_data->icalcomp);
- end_time = icalcomponent_get_dtend (comp_data->icalcomp);
-
- comp_data->instance_start = icaltime_as_timet (start_time);
-
- comp_data->instance_end = comp_data->instance_start +
- (icaltime_as_timet (end_time) - icaltime_as_timet (start_time));
-}
-
/* We do this check since the calendar items are downloaded from the server in the open_method,
since the default timezone might not be set there */
static void
@@ -1395,7 +1367,7 @@ e_cal_view_objects_added_cb (ECalView *q
comp_data = g_new0 (ECalModelComponent, 1);
comp_data->client = g_object_ref (e_cal_view_get_client (query));
comp_data->icalcomp = icalcomponent_new_clone (l->data);
- set_instance_times (comp_data, priv->zone);
+ e_cal_model_set_instance_times (comp_data, priv->zone);
comp_data->dtstart = comp_data->dtend = comp_data->due = comp_data->completed = NULL;
comp_data->color = NULL;
@@ -2094,4 +2066,32 @@ e_cal_model_generate_instances (ECalMode
mdata.cb_data = cb_data;
e_cal_generate_instances_for_object (comp_data->client, comp_data->icalcomp, start, end, cb, &mdata);
}
+}
+
+/**
+ * e_cal_model_get_object_array
+ */
+GPtrArray *
+e_cal_model_get_object_array (ECalModel *model)
+{
+ GPtrArray *objects = NULL;
+
+ g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
+
+ return model->priv->objects;
+}
+
+void
+e_cal_model_set_instance_times (ECalModelComponent *comp_data, icaltimezone *zone)
+{
+ struct icaltimetype recur_time, start_time, end_time;
+
+ recur_time = icalcomponent_get_recurrenceid (comp_data->icalcomp);
+ start_time = icalcomponent_get_dtstart (comp_data->icalcomp);
+ end_time = icalcomponent_get_dtend (comp_data->icalcomp);
+
+ comp_data->instance_start = icaltime_as_timet (start_time);
+
+ comp_data->instance_end = comp_data->instance_start +
+ (icaltime_as_timet (end_time) - icaltime_as_timet (start_time));
}
Index: calendar/gui/e-cal-model.h
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-cal-model.h,v
retrieving revision 1.16
diff -u -p -r1.16 e-cal-model.h
--- calendar/gui/e-cal-model.h 2 Jul 2005 14:54:44 -0000 1.16
+++ calendar/gui/e-cal-model.h 1 Oct 2005 12:56:40 -0000
@@ -152,6 +152,8 @@ void e_cal_model_generate
time_t end,
ECalRecurInstanceFn cb,
gpointer cb_data);
+GPtrArray * e_cal_model_get_object_array (ECalModel *model);
+void e_cal_model_set_instance_times (ECalModelComponent *comp_data, icaltimezone *zone);
Index: calendar/gui/e-cal-model-tasks.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-cal-model-tasks.c,v
retrieving revision 1.31
diff -u -p -r1.31 e-cal-model-tasks.c
--- calendar/gui/e-cal-model-tasks.c 27 Jul 2005 10:53:37 -0000 1.31
+++ calendar/gui/e-cal-model-tasks.c 1 Oct 2005 12:57:19 -0000
@@ -386,70 +386,10 @@ is_complete (ECalModelComponent *comp_da
return FALSE;
}
-typedef enum {
- E_CAL_MODEL_TASKS_DUE_NEVER,
- E_CAL_MODEL_TASKS_DUE_FUTURE,
- E_CAL_MODEL_TASKS_DUE_TODAY,
- E_CAL_MODEL_TASKS_DUE_OVERDUE,
- E_CAL_MODEL_TASKS_DUE_COMPLETE
-} ECalModelTasksDueStatus;
-
-
-static ECalModelTasksDueStatus
-get_due_status (ECalModelTasks *model, ECalModelComponent *comp_data)
-{
- icalproperty *prop;
-
- /* First, do we have a due date? */
- prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_DUE_PROPERTY);
- if (!prop)
- return E_CAL_MODEL_TASKS_DUE_NEVER;
- else {
- struct icaltimetype now_tt, due_tt;
- icaltimezone *zone;
-
- /* Second, is it already completed? */
- if (is_complete (comp_data))
- return E_CAL_MODEL_TASKS_DUE_COMPLETE;
-
- /* Third, are we overdue as of right now? */
- due_tt = icalproperty_get_due (prop);
- if (due_tt.is_date) {
- int cmp;
-
- now_tt = icaltime_current_time_with_zone (e_cal_model_get_timezone (E_CAL_MODEL (model)));
- cmp = icaltime_compare_date_only (due_tt, now_tt);
-
- if (cmp < 0)
- return E_CAL_MODEL_TASKS_DUE_OVERDUE;
- else if (cmp == 0)
- return E_CAL_MODEL_TASKS_DUE_TODAY;
- else
- return E_CAL_MODEL_TASKS_DUE_FUTURE;
- } else {
- /* Get the current time in the same timezone as the DUE date.*/
- if (!e_cal_get_timezone (comp_data->client, icaltime_get_tzid (due_tt), &zone, NULL))
- return E_CAL_MODEL_TASKS_DUE_FUTURE;
-
- now_tt = icaltime_current_time_with_zone (zone);
-
- if (icaltime_compare (due_tt, now_tt) <= 0)
- return E_CAL_MODEL_TASKS_DUE_OVERDUE;
- else
- if (icaltime_compare_date_only (due_tt, now_tt) == 0)
- return E_CAL_MODEL_TASKS_DUE_TODAY;
- else
- return E_CAL_MODEL_TASKS_DUE_FUTURE;
- }
- }
-
- return E_CAL_MODEL_TASKS_DUE_NEVER;
-}
-
static gboolean
is_overdue (ECalModelTasks *model, ECalModelComponent *comp_data)
{
- switch (get_due_status (model, comp_data)) {
+ switch (e_cal_model_tasks_get_due_status (model, comp_data)) {
case E_CAL_MODEL_TASKS_DUE_NEVER:
case E_CAL_MODEL_TASKS_DUE_FUTURE:
case E_CAL_MODEL_TASKS_DUE_COMPLETE:
@@ -1034,7 +974,7 @@ ecmt_get_color_for_component (ECalModel
g_return_val_if_fail (E_IS_CAL_MODEL_TASKS (model), NULL);
g_return_val_if_fail (comp_data != NULL, NULL);
- switch (get_due_status ((ECalModelTasks *) model, comp_data)) {
+ switch (e_cal_model_tasks_get_due_status ((ECalModelTasks *) model, comp_data)) {
case E_CAL_MODEL_TASKS_DUE_TODAY:
return calendar_config_get_tasks_due_today_color ();
case E_CAL_MODEL_TASKS_DUE_OVERDUE:
@@ -1111,4 +1051,55 @@ e_cal_model_tasks_mark_task_complete (EC
e_table_model_row_changed (E_TABLE_MODEL (model), model_row);
}
+}
+
+ECalModelTasksDueStatus
+e_cal_model_tasks_get_due_status (ECalModelTasks *model, ECalModelComponent *comp_data)
+{
+ icalproperty *prop;
+
+ /* First, do we have a due date? */
+ prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_DUE_PROPERTY);
+ if (!prop)
+ return E_CAL_MODEL_TASKS_DUE_NEVER;
+ else {
+ struct icaltimetype now_tt, due_tt;
+ icaltimezone *zone;
+
+ /* Second, is it already completed? */
+ if (is_complete (comp_data))
+ return E_CAL_MODEL_TASKS_DUE_COMPLETE;
+
+ /* Third, are we overdue as of right now? */
+ due_tt = icalproperty_get_due (prop);
+ if (due_tt.is_date) {
+ int cmp;
+
+ now_tt = icaltime_current_time_with_zone (e_cal_model_get_timezone (E_CAL_MODEL (model)));
+ cmp = icaltime_compare_date_only (due_tt, now_tt);
+
+ if (cmp < 0)
+ return E_CAL_MODEL_TASKS_DUE_OVERDUE;
+ else if (cmp == 0)
+ return E_CAL_MODEL_TASKS_DUE_TODAY;
+ else
+ return E_CAL_MODEL_TASKS_DUE_FUTURE;
+ } else {
+ /* Get the current time in the same timezone as the DUE date.*/
+ if (!e_cal_get_timezone (comp_data->client, icaltime_get_tzid (due_tt), &zone, NULL))
+ return E_CAL_MODEL_TASKS_DUE_FUTURE;
+
+ now_tt = icaltime_current_time_with_zone (zone);
+
+ if (icaltime_compare (due_tt, now_tt) <= 0)
+ return E_CAL_MODEL_TASKS_DUE_OVERDUE;
+ else
+ if (icaltime_compare_date_only (due_tt, now_tt) == 0)
+ return E_CAL_MODEL_TASKS_DUE_TODAY;
+ else
+ return E_CAL_MODEL_TASKS_DUE_FUTURE;
+ }
+ }
+
+ return E_CAL_MODEL_TASKS_DUE_NEVER;
}
Index: calendar/gui/e-cal-model-tasks.h
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-cal-model-tasks.h,v
retrieving revision 1.3
diff -u -p -r1.3 e-cal-model-tasks.h
--- calendar/gui/e-cal-model-tasks.h 9 Aug 2003 09:01:35 -0000 1.3
+++ calendar/gui/e-cal-model-tasks.h 1 Oct 2005 12:59:13 -0000
@@ -49,6 +49,14 @@ typedef enum {
E_CAL_MODEL_TASKS_FIELD_LAST
} ECalModelTasksField;
+typedef enum {
+ E_CAL_MODEL_TASKS_DUE_NEVER,
+ E_CAL_MODEL_TASKS_DUE_FUTURE,
+ E_CAL_MODEL_TASKS_DUE_TODAY,
+ E_CAL_MODEL_TASKS_DUE_OVERDUE,
+ E_CAL_MODEL_TASKS_DUE_COMPLETE
+} ECalModelTasksDueStatus;
+
typedef struct {
ECalModel model;
ECalModelTasksPrivate *priv;
@@ -62,6 +70,7 @@ GType e_cal_model_tasks_get_ty
ECalModelTasks *e_cal_model_tasks_new (void);
void e_cal_model_tasks_mark_task_complete (ECalModelTasks *model, gint model_row);
+ECalModelTasksDueStatus e_cal_model_tasks_get_due_status (ECalModelTasks *model, ECalModelComponent *comp_data);
G_END_DECLS
Index: calendar/gui/e-calendar-table.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-calendar-table.c,v
retrieving revision 1.139.2.2
diff -u -p -r1.139.2.2 e-calendar-table.c
--- calendar/gui/e-calendar-table.c 30 Sep 2005 16:45:14 -0000 1.139.2.2
+++ calendar/gui/e-calendar-table.c 1 Oct 2005 12:59:50 -0000
@@ -55,6 +55,7 @@
#include "print.h"
#include <e-util/e-icon-factory.h>
#include "e-cal-popup.h"
+#include "misc.h"
extern ECompEditorRegistry *comp_editor_registry;
@@ -89,6 +90,10 @@ static struct tm e_calendar_table_get_cu
gpointer data);
static void mark_row_complete_cb (int model_row, gpointer data);
+static void hide_completed_rows (ECalModel *model, GList *clients_list, char *hide_sexp, GPtrArray *comp_objects);
+static void show_completed_rows (ECalModel *model, GList *clients_list, char *show_sexp, GPtrArray *comp_objects);
+static void update_due_tasks (ECalModel *model, GList *clients_list, char *update_sexp, GPtrArray *comp_objects);
+
/* Signal IDs */
enum {
USER_CREATED,
@@ -1274,6 +1279,106 @@ e_calendar_table_on_key_press (ETable *t
return FALSE;
}
+static void
+hide_completed_rows (ECalModel *model, GList *clients_list, char *hide_sexp, GPtrArray *comp_objects)
+{
+ GList *l, *m, *objects;
+ ECal *client;
+ int pos;
+
+ for (l = clients_list; l != NULL; l = l->next) {
+ client = l->data;
+
+ if (!e_cal_get_object_list (client, hide_sexp, &objects, NULL)) {
+ g_warning (G_STRLOC ": Could not get the objects");
+
+ continue;
+ }
+
+ for (m = objects; m; m = m->next) {
+ ECalModelComponent *comp_data;
+
+ if ((comp_data = e_cal_model_get_component_for_uid (model, icalcomponent_get_uid (m->data)))) {
+ e_table_model_pre_change (E_TABLE_MODEL (model));
+ pos = get_position_in_array (comp_objects, comp_data);
+ e_table_model_row_deleted (E_TABLE_MODEL (model), pos);
+
+ g_ptr_array_remove (comp_objects, comp_data);
+ }
+ }
+
+ g_list_foreach (objects, (GFunc) icalcomponent_free, NULL);
+ g_list_free (objects);
+ }
+}
+
+static void
+show_completed_rows (ECalModel *model, GList *clients_list, char *show_sexp, GPtrArray *comp_objects)
+{
+ GList *l, *m, *objects;
+ ECal *client;
+
+ for (l = clients_list; l != NULL; l = l->next) {
+ client = l->data;
+
+ if (!e_cal_get_object_list (client, show_sexp, &objects, NULL)) {
+ g_warning (G_STRLOC ": Could not get the objects");
+
+ continue;
+ }
+
+ for (m = objects; m; m = m->next) {
+ ECalModelComponent *comp_data;
+
+ if ((comp_data = e_cal_model_get_component_for_uid (model, icalcomponent_get_uid (m->data)))) {
+ e_table_model_pre_change (E_TABLE_MODEL (model));
+ comp_data = g_new0 (ECalModelComponent, 1);
+ comp_data->client = client;
+ comp_data->icalcomp = icalcomponent_new_clone (m->data);
+ e_cal_model_set_instance_times (comp_data,
+ e_cal_model_get_timezone (model));
+ comp_data->dtstart = comp_data->dtend = comp_data->due = comp_data->completed = NULL;
+ comp_data->color = NULL;
+
+ g_ptr_array_add (comp_objects, comp_data);
+ e_table_model_row_inserted (E_TABLE_MODEL (model), comp_objects->len - 1);
+ }
+ }
+ }
+}
+
+static void
+update_due_tasks (ECalModel *model, GList *clients_list, char *update_sexp, GPtrArray *comp_objects)
+{
+ GList *l, *m, *objects;
+ ECal *client;
+ ECalModelTasksDueStatus status;
+ int pos;
+
+ for (l = clients_list; l != NULL; l = l->next) {
+ client = l->data;
+
+ if (!e_cal_get_object_list (client, update_sexp, &objects, NULL)) {
+ g_warning (G_STRLOC ": Could not get the objects");
+
+ continue;
+ }
+
+ for (m = objects; m; m = m->next) {
+ ECalModelComponent *comp_data;
+
+ e_cal_model_get_component_for_uid (model, icalcomponent_get_uid (m->data));
+ status = e_cal_model_tasks_get_due_status (E_CAL_MODEL_TASKS (model), comp_data);
+ if((status == E_CAL_MODEL_TASKS_DUE_TODAY) || (status == E_CAL_MODEL_TASKS_DUE_OVERDUE))
+ {
+ e_table_model_pre_change (E_TABLE_MODEL (model));
+ pos = get_position_in_array (comp_objects, comp_data);
+ e_table_model_row_changed (E_TABLE_MODEL (model), pos);
+ }
+ }
+ }
+}
+
/* Loads the state of the table (headers shown etc.) from the given file. */
void
e_calendar_table_load_state (ECalendarTable *cal_table,
@@ -1384,4 +1489,53 @@ e_calendar_table_set_status_message (ECa
e_activity_handler_operation_progressing (cal_table->activity_handler, cal_table->activity_id, message, progress);
}
+}
+
+/**
+ * e_calendar_table_hide_completed_tasks:
+ * @table: A calendar table model.
+ * @client_list: Clients List
+ *
+ * Hide completed tasks.
+ */
+void
+e_calendar_table_hide_completed_tasks (ECalendarTable *table, GList *clients_list, gboolean config_changed)
+{
+ ECalModel *model;
+ static GMutex *mutex = NULL;
+ char *hide_sexp, *show_sexp, *update_sexp;
+ GPtrArray *comp_objects = NULL;
+
+ if (!mutex)
+ mutex = g_mutex_new ();
+
+ g_mutex_lock (mutex);
+
+ model = e_calendar_table_get_model (table);
+ comp_objects = e_cal_model_get_object_array (model);
+
+ hide_sexp = calendar_config_get_hide_completed_tasks_sexp (TRUE);
+ show_sexp = calendar_config_get_hide_completed_tasks_sexp (FALSE);
+ update_sexp = g_strdup ("(not is-completed?)");
+
+ /* If hide option is unchecked */
+ if (!(hide_sexp && show_sexp))
+ show_sexp = g_strdup ("(is-completed?)");
+
+ /* Delete rows from model*/
+ if (hide_sexp) {
+ hide_completed_rows (model, clients_list, hide_sexp, comp_objects);
+ }
+
+ /* Insert rows into model */
+ if (config_changed) {
+ show_completed_rows (model, clients_list, show_sexp, comp_objects);
+ }
+
+ update_due_tasks (model, clients_list, update_sexp, comp_objects);
+
+ g_free (hide_sexp);
+ g_free (show_sexp);
+ g_free (update_sexp);
+ g_mutex_unlock (mutex);
}
Index: calendar/gui/e-calendar-table.h
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-calendar-table.h,v
retrieving revision 1.28
diff -u -p -r1.28 e-calendar-table.h
--- calendar/gui/e-calendar-table.h 25 Jul 2005 07:53:18 -0000 1.28
+++ calendar/gui/e-calendar-table.h 1 Oct 2005 13:01:04 -0000
@@ -108,6 +108,7 @@ void e_calendar_table_open_task (ECa
ECalModelComponent *comp_data,
gboolean assign);
ECalModelComponent * e_calendar_table_get_selected_comp (ECalendarTable *cal_table);
+void e_calendar_table_hide_completed_tasks (ECalendarTable *table, GList *clients_list, gboolean config_changed);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]