aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/e-cal-model.c
diff options
context:
space:
mode:
authorChenthill Palanisamy <pchen@src.gnome.org>2005-10-11 17:07:24 +0800
committerChenthill Palanisamy <pchen@src.gnome.org>2005-10-11 17:07:24 +0800
commit25317085c402d37406b4ecbd4a13289a09c9385e (patch)
tree5a81db73505858bee8d1bc1656bec2238dd71851 /calendar/gui/e-cal-model.c
parent08e459d65f1d1895bf6d6d8dad15bec33b733550 (diff)
downloadgsoc2013-evolution-25317085c402d37406b4ecbd4a13289a09c9385e.tar
gsoc2013-evolution-25317085c402d37406b4ecbd4a13289a09c9385e.tar.gz
gsoc2013-evolution-25317085c402d37406b4ecbd4a13289a09c9385e.tar.bz2
gsoc2013-evolution-25317085c402d37406b4ecbd4a13289a09c9385e.tar.lz
gsoc2013-evolution-25317085c402d37406b4ecbd4a13289a09c9385e.tar.xz
gsoc2013-evolution-25317085c402d37406b4ecbd4a13289a09c9385e.tar.zst
gsoc2013-evolution-25317085c402d37406b4ecbd4a13289a09c9385e.zip
fixes #266144, #317575.
svn path=/trunk/; revision=30503
Diffstat (limited to 'calendar/gui/e-cal-model.c')
-rw-r--r--calendar/gui/e-cal-model.c69
1 files changed, 34 insertions, 35 deletions
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c
index d20793f9ae..02acdd7411 100644
--- a/calendar/gui/e-cal-model.c
+++ b/calendar/gui/e-cal-model.c
@@ -1244,10 +1244,9 @@ find_client_data (ECalModel *model, ECal *client)
return NULL;
}
-/* Pass NULL for the client if we just want to find based on uid */
/* FIXME how do we prevent the same UID is different calendars? */
static ECalModelComponent *
-search_by_uid_and_client (ECalModelPrivate *priv, ECal *client, const char *uid)
+search_by_id_and_client (ECalModelPrivate *priv, ECal *client, const ECalComponentId *id)
{
gint i;
@@ -1255,19 +1254,27 @@ search_by_uid_and_client (ECalModelPrivate *priv, ECal *client, const char *uid)
ECalModelComponent *comp_data = g_ptr_array_index (priv->objects, i);
if (comp_data) {
- const char *tmp_uid;
+ const char *uid, *rid;
+ gboolean has_rid = (id->rid && *id->rid);
- tmp_uid = icalcomponent_get_uid (comp_data->icalcomp);
- if (tmp_uid && *tmp_uid) {
- if ((!client || comp_data->client == client) && !strcmp (uid, tmp_uid))
+ uid = icalcomponent_get_uid (comp_data->icalcomp);
+ rid = icaltime_as_ical_string (icalcomponent_get_recurrenceid (comp_data->icalcomp));
+
+ if (uid && *uid) {
+ if ((!client || comp_data->client == client) && !strcmp (id->uid, uid)) {
+ if (has_rid) {
+ if (!(rid && *rid && !strcmp (rid, id->rid)))
+ continue;
+ }
return comp_data;
+ }
}
}
}
return NULL;
}
-
+
typedef struct {
ECal *client;
ECalView *query;
@@ -1335,10 +1342,15 @@ e_cal_view_objects_added_cb (ECalView *query, GList *objects, gpointer user_data
for (l = objects; l; l = l->next) {
ECalModelComponent *comp_data;
+ ECalComponentId *id;
+ ECalComponent *comp = e_cal_component_new ();
+
+ e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (l->data));
+ id = e_cal_component_get_id (comp);
/* remove the components if they are already present and re-add them */
- while ((comp_data = search_by_uid_and_client (priv, e_cal_view_get_client (query),
- icalcomponent_get_uid (l->data)))) {
+ while ((comp_data = search_by_id_and_client (priv, NULL,
+ id))) {
int pos;
pos = get_position_in_array (priv->objects, comp_data);
@@ -1348,9 +1360,11 @@ e_cal_view_objects_added_cb (ECalView *query, GList *objects, gpointer user_data
e_cal_model_free_component_data (comp_data);
}
+ e_cal_component_free_id (id);
+ g_object_unref (comp);
ensure_dates_are_in_default_zone (l->data);
- if ((priv->flags & E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES)) {
+ if (e_cal_util_component_has_recurrences (l->data) && (priv->flags & E_CAL_MODEL_FLAGS_EXPAND_RECURRENCES)) {
RecurrenceExpansionData rdata;
rdata.client = e_cal_view_get_client (query);
@@ -1386,28 +1400,12 @@ e_cal_view_objects_modified_cb (ECalView *query, GList *objects, gpointer user_d
priv = model->priv;
- for (l = objects; l; l = l->next) {
- ECalModelComponent *comp_data;
-
- /* remove all recurrences and re-add them after generating them */
- while ((comp_data = search_by_uid_and_client (priv, e_cal_view_get_client (query),
- icalcomponent_get_uid (l->data)))) {
- int pos;
-
- pos = get_position_in_array (priv->objects, comp_data);
- e_table_model_row_deleted (E_TABLE_MODEL (model), pos);
-
- g_ptr_array_remove (priv->objects, comp_data);
- e_cal_model_free_component_data (comp_data);
- }
- }
-
/* now re-add all objects */
e_cal_view_objects_added_cb (query, objects, model);
}
static void
-e_cal_view_objects_removed_cb (ECalView *query, GList *uids, gpointer user_data)
+e_cal_view_objects_removed_cb (ECalView *query, GList *ids, gpointer user_data)
{
ECalModelPrivate *priv;
ECalModel *model = (ECalModel *) user_data;
@@ -1415,14 +1413,15 @@ e_cal_view_objects_removed_cb (ECalView *query, GList *uids, gpointer user_data)
priv = model->priv;
- for (l = uids; l; l = l->next) {
- ECalModelComponent *comp_data;
+ for (l = ids; l; l = l->next) {
+ ECalModelComponent *comp_data = NULL;
+ ECalComponentId *id = l->data;
int pos;
e_table_model_pre_change (E_TABLE_MODEL (model));
/* make sure we remove all objects with this UID */
- while ((comp_data = search_by_uid_and_client (priv, e_cal_view_get_client (query), l->data))) {
+ while ((comp_data = search_by_id_and_client (priv, e_cal_view_get_client (query), id))) {
pos = get_position_in_array (priv->objects, comp_data);
e_table_model_row_deleted (E_TABLE_MODEL (model), pos);
@@ -1911,7 +1910,7 @@ e_cal_model_get_component_at (ECalModel *model, gint row)
}
ECalModelComponent *
-e_cal_model_get_component_for_uid (ECalModel *model, const char *uid)
+e_cal_model_get_component_for_uid (ECalModel *model, const ECalComponentId *id)
{
ECalModelPrivate *priv;
@@ -1919,8 +1918,8 @@ e_cal_model_get_component_for_uid (ECalModel *model, const char *uid)
priv = model->priv;
- return search_by_uid_and_client (priv, NULL, uid);
-}
+ return search_by_id_and_client (priv, NULL, id);
+}
/**
* e_cal_model_date_value_to_string
@@ -2088,8 +2087,8 @@ e_cal_model_set_instance_times (ECalModelComponent *comp_data, icaltimezone *zon
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_start = icaltime_as_timet_with_zone (start_time, zone);
comp_data->instance_end = comp_data->instance_start +
- (icaltime_as_timet (end_time) - icaltime_as_timet (start_time));
+ (icaltime_as_timet_with_zone (end_time, zone) - icaltime_as_timet_with_zone (start_time, zone));
}