aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/e-cal-model.c
diff options
context:
space:
mode:
authorChenthill Palanisamy <pchen@src.gnome.org>2008-09-08 17:31:56 +0800
committerChenthill Palanisamy <pchen@src.gnome.org>2008-09-08 17:31:56 +0800
commitd620820eab5d5f3814debb1b5f0dc7c5a7138973 (patch)
treebdc2e6435990c7425142b18acfac1148dea90978 /calendar/gui/e-cal-model.c
parentc61bef657d2e6c8ab82573f6366761000881db9e (diff)
downloadgsoc2013-evolution-d620820eab5d5f3814debb1b5f0dc7c5a7138973.tar.gz
gsoc2013-evolution-d620820eab5d5f3814debb1b5f0dc7c5a7138973.tar.zst
gsoc2013-evolution-d620820eab5d5f3814debb1b5f0dc7c5a7138973.zip
Fixes #544187.
svn path=/trunk/; revision=36276
Diffstat (limited to 'calendar/gui/e-cal-model.c')
-rw-r--r--calendar/gui/e-cal-model.c124
1 files changed, 112 insertions, 12 deletions
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c
index 42702c1416..d78e4f5dbc 100644
--- a/calendar/gui/e-cal-model.c
+++ b/calendar/gui/e-cal-model.c
@@ -109,6 +109,7 @@ static void remove_client (ECalModel *model, ECalModelClient *client_data);
enum {
TIME_RANGE_CHANGED,
ROW_APPENDED,
+ COMPS_DELETED,
CAL_VIEW_PROGRESS,
CAL_VIEW_DONE,
LAST_SIGNAL
@@ -159,6 +160,16 @@ e_cal_model_class_init (ECalModelClass *klass)
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+
+ signals[COMPS_DELETED] =
+ g_signal_new ("comps_deleted",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ECalModelClass, comps_deleted),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
+
signals[CAL_VIEW_PROGRESS] =
g_signal_new ("cal_view_progress",
G_TYPE_FROM_CLASS (klass),
@@ -1431,13 +1442,21 @@ e_cal_view_objects_added_cb (ECalView *query, GList *objects, gpointer user_data
while ((comp_data = search_by_id_and_client (priv, client,
id))) {
int pos;
+ GSList *list = NULL;
pos = get_position_in_array (priv->objects, comp_data);
+
+ if (!g_ptr_array_remove (priv->objects, comp_data))
+ continue;
+
+ list = g_slist_append (list, comp_data);
+ g_signal_emit (G_OBJECT (model), signals[COMPS_DELETED], 0, list);
+
+ g_slist_free (list);
+ g_object_unref (comp_data);
+
e_table_model_pre_change (E_TABLE_MODEL (model));
e_table_model_row_deleted (E_TABLE_MODEL (model), pos);
-
- if (g_ptr_array_remove (priv->objects, comp_data))
- e_cal_model_free_component_data (comp_data);
}
e_cal_component_free_id (id);
@@ -1473,9 +1492,45 @@ static void
e_cal_view_objects_modified_cb (ECalView *query, GList *objects, gpointer user_data)
{
ECalModel *model = (ECalModel *) user_data;
+ ECalModelPrivate *priv;
+ GList *l, *list = NULL;
+
+ priv = model->priv;
+
+ /* re-add only the recurrence objects */
+ for (l = objects; l != NULL; l = g_list_next (l)) {
+ if (e_cal_util_component_has_recurrences (l->data) && (priv->flags & E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES))
+ g_list_prepend (list, l->data);
+ else {
+ int pos;
+ ECalModelComponent *comp_data;
+ ECalComponentId *id;
+ ECalComponent *comp = e_cal_component_new ();
+ ECal *client = e_cal_view_get_client (query);
+
+ if (!e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (l->data))) {
+ g_object_unref (comp);
+ continue;
+ }
+
+ e_table_model_pre_change (E_TABLE_MODEL (model));
+
+ id = e_cal_component_get_id (comp);
+
+ comp_data = search_by_id_and_client (priv, client, id);
+ icalcomponent_free (comp_data->icalcomp);
+
+ comp_data->icalcomp = icalcomponent_new_clone (l->data);
+ e_cal_model_set_instance_times (comp_data, priv->zone);
+
+ pos = get_position_in_array (priv->objects, comp_data);
+
+ e_table_model_row_changed (E_TABLE_MODEL (model), pos);
+ }
+ }
- /* now re-add all objects */
- e_cal_view_objects_added_cb (query, objects, model);
+ e_cal_view_objects_added_cb (query, list, model);
+ g_list_free (list);
}
static void
@@ -1494,13 +1549,21 @@ e_cal_view_objects_removed_cb (ECalView *query, GList *ids, gpointer user_data)
/* make sure we remove all objects with this UID */
while ((comp_data = search_by_id_and_client (priv, e_cal_view_get_client (query), id))) {
+ GSList *l = NULL;
+
pos = get_position_in_array (priv->objects, comp_data);
+ if (!g_ptr_array_remove (priv->objects, comp_data))
+ continue;
+
+ l = g_slist_append (l, comp_data);
+ g_signal_emit (G_OBJECT (model), signals[COMPS_DELETED], 0, l);
+
+ g_slist_free (l);
+ g_object_unref (comp_data);
+
e_table_model_pre_change (E_TABLE_MODEL (model));
e_table_model_row_deleted (E_TABLE_MODEL (model), pos);
-
- if (g_ptr_array_remove (priv->objects, comp_data))
- e_cal_model_free_component_data (comp_data);
}
}
@@ -1692,11 +1755,18 @@ remove_client_objects (ECalModel *model, ECalModelClient *client_data)
g_return_if_fail (comp_data != NULL);
if (comp_data->client == client_data->client) {
- e_table_model_pre_change (E_TABLE_MODEL (model));
- e_table_model_row_deleted (E_TABLE_MODEL (model), i - 1);
+ GSList *l = NULL;
g_ptr_array_remove (model->priv->objects, comp_data);
- e_cal_model_free_component_data (comp_data);
+
+ l = g_slist_append (l, comp_data);
+ g_signal_emit (G_OBJECT (model), signals[COMPS_DELETED], 0, l);
+
+ g_slist_free (l);
+ g_object_unref (comp_data);
+
+ e_table_model_pre_change (E_TABLE_MODEL (model));
+ e_table_model_row_deleted (E_TABLE_MODEL (model), i - 1);
}
}
@@ -1768,11 +1838,34 @@ e_cal_model_remove_all_clients (ECalModel *model)
}
}
+static GSList *
+get_objects_as_list (ECalModel *model)
+{
+ gint i;
+ GSList *l = NULL;
+ ECalModelPrivate *priv = model->priv;
+
+ for (i = 0; i < priv->objects->len; i++) {
+ ECalModelComponent *comp_data;
+
+ comp_data = g_ptr_array_index (priv->objects, i);
+ if (comp_data == NULL) {
+ g_warning ("comp_data is null\n");
+ continue;
+ }
+
+ l = g_slist_prepend (l, comp_data);
+ }
+
+ return l;
+}
+
static void
redo_queries (ECalModel *model)
{
ECalModelPrivate *priv;
GList *l;
+ GSList *sl, *slist;
int len;
priv = model->priv;
@@ -1802,8 +1895,15 @@ redo_queries (ECalModel *model)
/* clean up the current contents */
e_table_model_pre_change (E_TABLE_MODEL (model));
len = priv->objects->len;
+
+ slist = get_objects_as_list (model);
+ g_ptr_array_set_size (priv->objects, 0);
+ g_signal_emit (G_OBJECT (model), signals[COMPS_DELETED], 0, slist);
+
e_table_model_rows_deleted (E_TABLE_MODEL (model), 0, len);
- clear_objects_array (priv);
+
+ g_slist_foreach (slist, (GFunc)g_object_unref, NULL);
+ g_slist_free (slist);
/* update the query for all clients */
for (l = priv->clients; l != NULL; l = l->next) {