aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorChenthill Palanisamy <pchen@src.gnome.org>2005-10-03 14:16:51 +0800
committerChenthill Palanisamy <pchen@src.gnome.org>2005-10-03 14:16:51 +0800
commit7a102381acf224110cfe32fcc0905a103268abde (patch)
tree3797369272088bdacc8706e1abff2eca92e1bdfe /calendar
parent263e728c125f4312867084d9b85b41caabec6a4f (diff)
downloadgsoc2013-evolution-7a102381acf224110cfe32fcc0905a103268abde.tar.gz
gsoc2013-evolution-7a102381acf224110cfe32fcc0905a103268abde.tar.zst
gsoc2013-evolution-7a102381acf224110cfe32fcc0905a103268abde.zip
fixes #264449.
svn path=/trunk/; revision=30467
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog23
-rw-r--r--calendar/gui/calendar-config.c16
-rw-r--r--calendar/gui/calendar-config.h2
-rw-r--r--calendar/gui/e-cal-model-tasks.c28
-rw-r--r--calendar/gui/e-cal-model-tasks.h1
-rw-r--r--calendar/gui/e-cal-model.c58
-rw-r--r--calendar/gui/e-cal-model.h2
-rw-r--r--calendar/gui/e-calendar-table.c117
-rw-r--r--calendar/gui/e-calendar-table.h1
-rw-r--r--calendar/gui/e-tasks.c28
-rw-r--r--calendar/gui/gnome-cal.c25
-rw-r--r--calendar/gui/misc.c13
-rw-r--r--calendar/gui/misc.h1
13 files changed, 274 insertions, 41 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 3ccf847896..7e94b4054c 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,26 @@
+2005-10-03 Mubeen Jukaku <jmubeen@novell.com>
+
+ Fixes #264449
+ * gui/e-tasks.c: (update_view_cb),
+ (config_process_completed_tasks_changed_cb): Use process_completed_tasks
+ instead of update_view
+ * gui/gnome-cal.c (update_todo_view_cb),
+ (config_process_completed_tasks_changed_cb): ditto
+ * gui/e-calendar-table.[ch]:
+ (e_cal_model_process_completed_tasks): New function to hide
+ completed tasks
+ * gui/calendar-config.[ch]:
+ (calendar_config_get_process_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
+ (search_by_uid_and_client): fix for client is NULL
+ * gui/e-cal-model-tasks.[ch]:
+ (e_cal_model_tasks_update_due_tasks): Update due tasks
+
2005-10-01 Viren.L <lviren@novell.com>
Fixes #257649
diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c
index aa2b565b52..db57821c56 100644
--- a/calendar/gui/calendar-config.c
+++ b/calendar/gui/calendar-config.c
@@ -1077,11 +1077,13 @@ calendar_config_set_default_reminder_units (CalUnits units)
/**
* 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_sexp (void)
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_sexp (void)
/* 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);
}
}
diff --git a/calendar/gui/calendar-config.h b/calendar/gui/calendar-config.h
index 3d3840a911..6135f08933 100644
--- a/calendar/gui/calendar-config.h
+++ b/calendar/gui/calendar-config.h
@@ -183,7 +183,7 @@ gint calendar_config_get_hide_completed_tasks_value(void);
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);
diff --git a/calendar/gui/e-cal-model-tasks.c b/calendar/gui/e-cal-model-tasks.c
index 688aab7fbe..5b0adca17e 100644
--- a/calendar/gui/e-cal-model-tasks.c
+++ b/calendar/gui/e-cal-model-tasks.c
@@ -1112,3 +1112,31 @@ e_cal_model_tasks_mark_task_complete (ECalModelTasks *model, gint model_row)
e_table_model_row_changed (E_TABLE_MODEL (model), model_row);
}
}
+
+/**
+ * e_cal_model_tasks_update_due_tasks
+ */
+void
+e_cal_model_tasks_update_due_tasks (ECalModelTasks *model)
+{
+ gint row, row_count;
+ ECalModelTasksPrivate *priv;
+ ECalModelComponent *comp_data;
+ ECalModelTasksDueStatus status;
+
+ g_return_if_fail (E_IS_CAL_MODEL_TASKS (model));
+
+ row_count = e_table_model_row_count (E_TABLE_MODEL (model));
+ priv = model->priv;
+
+ for (row = 0; row < row_count; row++)
+ {
+ comp_data = e_cal_model_get_component_at (E_CAL_MODEL (model), row);
+ status = 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));
+ e_table_model_row_changed (E_TABLE_MODEL (model), row);
+ }
+ }
+}
diff --git a/calendar/gui/e-cal-model-tasks.h b/calendar/gui/e-cal-model-tasks.h
index b7c5786ab4..0c10f3a6fe 100644
--- a/calendar/gui/e-cal-model-tasks.h
+++ b/calendar/gui/e-cal-model-tasks.h
@@ -62,6 +62,7 @@ GType e_cal_model_tasks_get_type (void);
ECalModelTasks *e_cal_model_tasks_new (void);
void e_cal_model_tasks_mark_task_complete (ECalModelTasks *model, gint model_row);
+void e_cal_model_tasks_update_due_tasks (ECalModelTasks *model);
G_END_DECLS
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c
index 792b8b2893..d20793f9ae 100644
--- a/calendar/gui/e-cal-model.c
+++ b/calendar/gui/e-cal-model.c
@@ -1259,7 +1259,7 @@ search_by_uid_and_client (ECalModelPrivate *priv, ECal *client, const char *uid)
tmp_uid = icalcomponent_get_uid (comp_data->icalcomp);
if (tmp_uid && *tmp_uid) {
- if (comp_data->client == client && !strcmp (uid, tmp_uid))
+ if ((!client || comp_data->client == client) && !strcmp (uid, tmp_uid))
return comp_data;
}
}
@@ -1268,19 +1268,6 @@ search_by_uid_and_client (ECalModelPrivate *priv, ECal *client, const char *uid)
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, time_t instance_start, time_t instance_end
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 *query, GList *objects, gpointer user_data
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;
@@ -2095,3 +2067,29 @@ e_cal_model_generate_instances (ECalModel *model, time_t start, time_t end,
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)
+{
+ 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));
+}
diff --git a/calendar/gui/e-cal-model.h b/calendar/gui/e-cal-model.h
index b48462418e..cc8ea4d648 100644
--- a/calendar/gui/e-cal-model.h
+++ b/calendar/gui/e-cal-model.h
@@ -152,6 +152,8 @@ void e_cal_model_generate_instances (ECalModel
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);
diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c
index f789fe40d8..d339ccaf8b 100644
--- a/calendar/gui/e-calendar-table.c
+++ b/calendar/gui/e-calendar-table.c
@@ -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,9 @@ static struct tm e_calendar_table_get_current_time (ECellDateEdit *ecde,
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);
+
/* Signal IDs */
enum {
USER_CREATED,
@@ -1274,6 +1278,74 @@ e_calendar_table_on_key_press (ETable *table,
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 (!(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);
+ }
+ }
+ }
+}
+
/* Loads the state of the table (headers shown etc.) from the given file. */
void
e_calendar_table_load_state (ECalendarTable *cal_table,
@@ -1385,3 +1457,48 @@ e_calendar_table_set_status_message (ECalendarTable *cal_table, const gchar *mes
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_process_completed_tasks (ECalendarTable *table, GList *clients_list, gboolean config_changed)
+{
+ ECalModel *model;
+ static GMutex *mutex = NULL;
+ char *hide_sexp, *show_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);
+
+ /* 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);
+ }
+
+ g_free (hide_sexp);
+ g_free (show_sexp);
+ g_mutex_unlock (mutex);
+}
diff --git a/calendar/gui/e-calendar-table.h b/calendar/gui/e-calendar-table.h
index 04006f1157..427192259e 100644
--- a/calendar/gui/e-calendar-table.h
+++ b/calendar/gui/e-calendar-table.h
@@ -108,6 +108,7 @@ void e_calendar_table_open_task (ECalendarTable *cal_table,
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
diff --git a/calendar/gui/e-tasks.c b/calendar/gui/e-tasks.c
index dc6401d330..bf281e83d3 100644
--- a/calendar/gui/e-tasks.c
+++ b/calendar/gui/e-tasks.c
@@ -56,6 +56,7 @@
#include "e-tasks.h"
#include "common/authentication.h"
#include "e-cal-menu.h"
+#include "e-cal-model-tasks.h"
/* Private part of the GnomeCalendar structure */
@@ -291,7 +292,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 +303,31 @@ update_view (ETasks *tasks)
e_cal_component_preview_clear (E_CAL_COMPONENT_PREVIEW (priv->preview));
}
+static void
+process_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_process_completed_tasks (e_tasks_get_calendar_table (tasks), priv->clients_list, config_changed);
+}
+
static gboolean
update_view_cb (ETasks *tasks)
{
- update_view (tasks);
+ ECalModel *model;
+
+ model = e_calendar_table_get_model (E_CALENDAR_TABLE (tasks->priv->tasks_view));
+
+ process_completed_tasks (tasks, FALSE);
+ e_cal_model_tasks_update_due_tasks (E_CAL_MODEL_TASKS (model));
return TRUE;
}
@@ -313,7 +335,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);
+ process_completed_tasks (data, TRUE);
}
static void
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index e0e68fb723..a2c62ae152 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -81,6 +81,7 @@
#include "common/authentication.h"
#include "e-cal-popup.h"
#include "e-cal-menu.h"
+#include "e-cal-model-tasks.h"
/* FIXME glib 2.4 and above has this */
#ifndef G_MAXINT32
@@ -1135,7 +1136,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 +1147,28 @@ update_todo_view (GnomeCalendar *gcal)
}
+static void
+process_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_process_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);
+ ECalModel *model;
+
+ model = e_calendar_table_get_model (E_CALENDAR_TABLE (gcal->priv->todo));
+
+ process_completed_tasks (gcal, FALSE);
+ e_cal_model_tasks_update_due_tasks (E_CAL_MODEL_TASKS (model));
return TRUE;
}
@@ -1172,7 +1191,7 @@ update_marcus_bains_line_cb (GnomeCalendar *gcal)
static void
config_hide_completed_tasks_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data)
{
- update_todo_view (data);
+ process_completed_tasks (data, TRUE);
}
static void
diff --git a/calendar/gui/misc.c b/calendar/gui/misc.c
index 332283172b..026cd8417e 100644
--- a/calendar/gui/misc.c
+++ b/calendar/gui/misc.c
@@ -78,3 +78,16 @@ get_uri_without_password (const char *full_uri)
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;
+}
diff --git a/calendar/gui/misc.h b/calendar/gui/misc.h
index d32739f9f5..7f89788f2c 100644
--- a/calendar/gui/misc.h
+++ b/calendar/gui/misc.h
@@ -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