aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2011-02-18 02:33:58 +0800
committerMilan Crha <mcrha@redhat.com>2011-02-18 02:33:58 +0800
commitb1008815feab6b7a95fd0f11c18a7f018b1a605b (patch)
treeb3689745af1a9b4c31e3110f374c5e7eba1efa3c /calendar
parent2ee58bbcb1c4e098999ff2cdef7133477addb330 (diff)
downloadgsoc2013-evolution-b1008815feab6b7a95fd0f11c18a7f018b1a605b.tar
gsoc2013-evolution-b1008815feab6b7a95fd0f11c18a7f018b1a605b.tar.gz
gsoc2013-evolution-b1008815feab6b7a95fd0f11c18a7f018b1a605b.tar.bz2
gsoc2013-evolution-b1008815feab6b7a95fd0f11c18a7f018b1a605b.tar.lz
gsoc2013-evolution-b1008815feab6b7a95fd0f11c18a7f018b1a605b.tar.xz
gsoc2013-evolution-b1008815feab6b7a95fd0f11c18a7f018b1a605b.tar.zst
gsoc2013-evolution-b1008815feab6b7a95fd0f11c18a7f018b1a605b.zip
Order matters, process master object first, then detached instances
Diffstat (limited to 'calendar')
-rw-r--r--calendar/gui/e-cal-model.c42
1 files changed, 40 insertions, 2 deletions
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c
index a8206d50c1..d0b0c988d3 100644
--- a/calendar/gui/e-cal-model.c
+++ b/calendar/gui/e-cal-model.c
@@ -2133,17 +2133,53 @@ ensure_dates_are_in_default_zone (ECalModel *model,
}
}
+static gint
+place_master_object_first_cb (gconstpointer p1, gconstpointer p2)
+{
+ icalcomponent *c1 = (icalcomponent *) p1, *c2 = (icalcomponent *) p2;
+ const gchar *uid1, *uid2;
+ gint res;
+
+ g_return_val_if_fail (c1 != NULL, 0);
+ g_return_val_if_fail (c2 != NULL, 0);
+
+ uid1 = icalcomponent_get_uid (c1);
+ uid2 = icalcomponent_get_uid (c2);
+
+ res = g_strcmp0 (uid1, uid2);
+ if (res == 0) {
+ struct icaltimetype rid1, rid2;
+
+ rid1 = icalcomponent_get_recurrenceid (c1);
+ rid2 = icalcomponent_get_recurrenceid (c2);
+
+ if (icaltime_is_null_time (rid1)) {
+ if (!icaltime_is_null_time (rid2))
+ res = -1;
+ } else if (icaltime_is_null_time (rid2)) {
+ res = 1;
+ } else {
+ res = icaltime_compare (rid1, rid2);
+ }
+ }
+
+ return res;
+}
+
static void e_cal_view_objects_added_cb (ECalView *query, GList *objects, ECalModel *model);
static void
process_added (ECalView *query, GList *objects, ECalModel *model)
{
ECalModelPrivate *priv;
- GList *l;
+ GList *l, *copy;
priv = model->priv;
- for (l = objects; l; l = l->next) {
+ /* order matters, process master object first, then detached instances */
+ copy = g_list_sort (g_list_copy (objects), place_master_object_first_cb);
+
+ for (l = copy; l; l = l->next) {
ECalModelComponent *comp_data;
ECalComponentId *id;
ECalComponent *comp = e_cal_component_new ();
@@ -2205,6 +2241,8 @@ process_added (ECalView *query, GList *objects, ECalModel *model)
e_table_model_row_inserted (E_TABLE_MODEL (model), priv->objects->len - 1);
}
}
+
+ g_list_free (copy);
}
static void