aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2010-01-20 22:48:31 +0800
committerMilan Crha <mcrha@redhat.com>2010-01-20 22:48:31 +0800
commit41dfcdb070f5c052908ca15bb304c91ae637795c (patch)
treed606ed14fc7d7c97e1a13d268e31209303ec5d34 /calendar
parent7861651506746fe8cbd15e4cec9ab38d8e1073f3 (diff)
downloadgsoc2013-evolution-41dfcdb070f5c052908ca15bb304c91ae637795c.tar.gz
gsoc2013-evolution-41dfcdb070f5c052908ca15bb304c91ae637795c.tar.zst
gsoc2013-evolution-41dfcdb070f5c052908ca15bb304c91ae637795c.zip
Bug #606301 - Slow sort by subject
Diffstat (limited to 'calendar')
-rw-r--r--calendar/gui/e-cal-list-view.c30
-rw-r--r--calendar/gui/e-cell-date-edit-text.c25
-rw-r--r--calendar/gui/e-cell-date-edit-text.h2
-rw-r--r--calendar/gui/e-memo-table.c31
-rw-r--r--calendar/gui/e-task-table.c115
5 files changed, 92 insertions, 111 deletions
diff --git a/calendar/gui/e-cal-list-view.c b/calendar/gui/e-cal-list-view.c
index 1097749ffd..1d3e0e114a 100644
--- a/calendar/gui/e-cal-list-view.c
+++ b/calendar/gui/e-cal-list-view.c
@@ -101,34 +101,6 @@ e_cal_list_view_class_init (ECalListViewClass *class)
view_class->get_visible_time_range = e_cal_list_view_get_visible_time_range;
}
-static gint
-date_compare_cb (gconstpointer a, gconstpointer b)
-{
- ECellDateEditValue *dv1 = (ECellDateEditValue *) a;
- ECellDateEditValue *dv2 = (ECellDateEditValue *) b;
- struct icaltimetype tt;
-
- /* First check if either is NULL. NULL dates sort last. */
- if (!dv1 || !dv2) {
- if (dv1 == dv2)
- return 0;
- else if (dv1)
- return -1;
- else
- return 1;
- }
-
- /* Copy the 2nd value and convert it to the same timezone as the
- first. */
- tt = dv2->tt;
-
- icaltimezone_convert_time (&tt, dv2->zone, dv1->zone);
-
- /* Now we can compare them. */
-
- return icaltime_compare (dv1->tt, tt);
-}
-
static void
e_cal_list_view_init (ECalListView *cal_list_view)
{
@@ -269,7 +241,7 @@ setup_e_table (ECalListView *cal_list_view)
/* Sorting */
e_table_extras_add_compare (extras, "date-compare",
- date_compare_cb);
+ e_cell_date_edit_compare_cb);
/* set proper format component for a default 'date' cell renderer */
cell = e_table_extras_get_cell (extras, "date");
diff --git a/calendar/gui/e-cell-date-edit-text.c b/calendar/gui/e-cell-date-edit-text.c
index bebec0fcda..37886680e5 100644
--- a/calendar/gui/e-cell-date-edit-text.c
+++ b/calendar/gui/e-cell-date-edit-text.c
@@ -361,3 +361,28 @@ e_cell_date_edit_text_set_use_24_hour_format (ECellDateEditText *ecd,
g_object_notify (G_OBJECT (ecd), "use-24-hour-format");
}
+gint
+e_cell_date_edit_compare_cb (gconstpointer a, gconstpointer b, gpointer cmp_cache)
+{
+ ECellDateEditValue *dv1 = (ECellDateEditValue *) a;
+ ECellDateEditValue *dv2 = (ECellDateEditValue *) b;
+ struct icaltimetype tt;
+
+ /* First check if either is NULL. NULL dates sort last. */
+ if (!dv1 || !dv2) {
+ if (dv1 == dv2)
+ return 0;
+ else if (dv1)
+ return -1;
+ else
+ return 1;
+ }
+
+ /* Copy the 2nd value and convert it to the same timezone as the first. */
+ tt = dv2->tt;
+
+ icaltimezone_convert_time (&tt, dv2->zone, dv1->zone);
+
+ /* Now we can compare them. */
+ return icaltime_compare (dv1->tt, tt);
+}
diff --git a/calendar/gui/e-cell-date-edit-text.h b/calendar/gui/e-cell-date-edit-text.h
index a49b68d36b..335374c141 100644
--- a/calendar/gui/e-cell-date-edit-text.h
+++ b/calendar/gui/e-cell-date-edit-text.h
@@ -81,6 +81,8 @@ void e_cell_date_edit_text_set_use_24_hour_format
(ECellDateEditText *ecd,
gboolean use_24_hour);
+gint e_cell_date_edit_compare_cb (gconstpointer a, gconstpointer b, gpointer cmp_cache);
+
G_END_DECLS
#endif /* _E_CELL_DATE_EDIT_TEXT_H_ */
diff --git a/calendar/gui/e-memo-table.c b/calendar/gui/e-memo-table.c
index 11c74820a6..459fff3e15 100644
--- a/calendar/gui/e-memo-table.c
+++ b/calendar/gui/e-memo-table.c
@@ -164,35 +164,6 @@ memo_table_get_current_time (ECellDateEdit *ecde,
return tmp_tm;
}
-static gint
-memo_table_date_compare_cb (gconstpointer a,
- gconstpointer b)
-{
- ECellDateEditValue *dv1 = (ECellDateEditValue *) a;
- ECellDateEditValue *dv2 = (ECellDateEditValue *) b;
- struct icaltimetype tt;
-
- /* First check if either is NULL. NULL dates sort last. */
- if (!dv1 || !dv2) {
- if (dv1 == dv2)
- return 0;
- else if (dv1)
- return -1;
- else
- return 1;
- }
-
- /* Copy the 2nd value and convert it to the same timezone as the
- first. */
- tt = dv2->tt;
-
- icaltimezone_convert_time (&tt, dv2->zone, dv1->zone);
-
- /* Now we can compare them. */
-
- return icaltime_compare (dv1->tt, tt);
-}
-
static void
memo_table_model_cal_view_progress_cb (EMemoTable *memo_table,
const gchar *message,
@@ -420,7 +391,7 @@ memo_table_constructed (GObject *object)
/* Sorting */
e_table_extras_add_compare (
- extras, "date-compare", memo_table_date_compare_cb);
+ extras, "date-compare", e_cell_date_edit_compare_cb);
/* Create pixmaps */
diff --git a/calendar/gui/e-task-table.c b/calendar/gui/e-task-table.c
index 4a378f2daf..b39af94db0 100644
--- a/calendar/gui/e-task-table.c
+++ b/calendar/gui/e-task-table.c
@@ -47,6 +47,7 @@
#include <e-util/e-util-private.h>
#include <table/e-cell-date-edit.h>
#include <table/e-cell-percent.h>
+#include <table/e-table-sorting-utils.h>
#include <libecal/e-cal-time-util.h>
#include <libedataserver/e-time-utils.h>
@@ -140,37 +141,7 @@ task_table_emit_user_created (ETaskTable *task_table)
}
static gint
-task_table_date_compare_cb (gconstpointer a,
- gconstpointer b)
-{
- ECellDateEditValue *dv1 = (ECellDateEditValue *) a;
- ECellDateEditValue *dv2 = (ECellDateEditValue *) b;
- struct icaltimetype tt;
-
- /* First check if either is NULL. NULL dates sort last. */
- if (!dv1 || !dv2) {
- if (dv1 == dv2)
- return 0;
- else if (dv1)
- return -1;
- else
- return 1;
- }
-
- /* Copy the 2nd value and convert it to the same timezone as the
- first. */
- tt = dv2->tt;
-
- icaltimezone_convert_time (&tt, dv2->zone, dv1->zone);
-
- /* Now we can compare them. */
-
- return icaltime_compare (dv1->tt, tt);
-}
-
-static gint
-task_table_percent_compare_cb (gconstpointer a,
- gconstpointer b)
+task_table_percent_compare_cb (gconstpointer a, gconstpointer b, gpointer cmp_cache)
{
gint percent1 = GPOINTER_TO_INT (a);
gint percent2 = GPOINTER_TO_INT (b);
@@ -179,8 +150,7 @@ task_table_percent_compare_cb (gconstpointer a,
}
static gint
-task_table_priority_compare_cb (gconstpointer a,
- gconstpointer b)
+task_table_priority_compare_cb (gconstpointer a, gconstpointer b, gpointer cmp_cache)
{
gint priority1, priority2;
@@ -197,9 +167,42 @@ task_table_priority_compare_cb (gconstpointer a,
return (priority1 < priority2) ? -1 : (priority1 > priority2);
}
+static const gchar *
+get_cache_str (gpointer cmp_cache, const gchar *str)
+{
+ const gchar *value;
+
+ if (!cmp_cache || !str)
+ return str;
+
+ value = e_table_sorting_utils_lookup_cmp_cache (cmp_cache, str);
+ if (!value) {
+ gchar *ckey;
+
+ ckey = g_utf8_collate_key (str, -1);
+ e_table_sorting_utils_add_to_cmp_cache (cmp_cache, (gchar *) str, ckey);
+ value = ckey;
+ }
+
+ return value;
+}
+
+static gboolean
+same_cache_string (gpointer cmp_cache, const gchar *str_a, const gchar *str_b)
+{
+ if (!cmp_cache)
+ return g_utf8_collate (str_a, str_b) == 0;
+
+ str_b = get_cache_str (cmp_cache, str_b);
+
+ g_return_val_if_fail (str_a != NULL, FALSE);
+ g_return_val_if_fail (str_b != NULL, FALSE);
+
+ return strcmp (str_a, str_b) == 0;
+}
+
static gint
-task_table_status_compare_cb (gconstpointer a,
- gconstpointer b)
+task_table_status_compare_cb (gconstpointer a, gconstpointer b, gpointer cmp_cache)
{
const gchar *string_a = a;
const gchar *string_b = b;
@@ -208,25 +211,33 @@ task_table_status_compare_cb (gconstpointer a,
if (string_a == NULL || *string_a == '\0')
status_a = -1;
- else if (!g_utf8_collate (string_a, _("Not Started")))
- status_a = 0;
- else if (!g_utf8_collate (string_a, _("In Progress")))
- status_a = 1;
- else if (!g_utf8_collate (string_a, _("Completed")))
- status_a = 2;
- else if (!g_utf8_collate (string_a, _("Canceled")))
- status_a = 3;
+ else {
+ const gchar *cache_str = get_cache_str (cmp_cache, string_a);
+
+ if (same_cache_string (cmp_cache, cache_str, _("Not Started")))
+ status_a = 0;
+ else if (same_cache_string (cmp_cache, cache_str, _("In Progress")))
+ status_a = 1;
+ else if (same_cache_string (cmp_cache, cache_str, _("Completed")))
+ status_a = 2;
+ else if (same_cache_string (cmp_cache, cache_str, _("Canceled")))
+ status_a = 3;
+ }
if (string_b == NULL || *string_b == '\0')
status_b = -1;
- else if (!g_utf8_collate (string_b, _("Not Started")))
- status_b = 0;
- else if (!g_utf8_collate (string_b, _("In Progress")))
- status_b = 1;
- else if (!g_utf8_collate (string_b, _("Completed")))
- status_b = 2;
- else if (!g_utf8_collate (string_b, _("Canceled")))
- status_b = 3;
+ else {
+ const gchar *cache_str = get_cache_str (cmp_cache, string_b);
+
+ if (same_cache_string (cmp_cache, cache_str, _("Not Started")))
+ status_b = 0;
+ else if (same_cache_string (cmp_cache, cache_str, _("In Progress")))
+ status_b = 1;
+ else if (same_cache_string (cmp_cache, cache_str, _("Completed")))
+ status_b = 2;
+ else if (same_cache_string (cmp_cache, cache_str, _("Canceled")))
+ status_b = 3;
+ }
return (status_a < status_b) ? -1 : (status_a > status_b);
}
@@ -589,7 +600,7 @@ task_table_constructed (GObject *object)
e_table_extras_add_cell (extras, "calstatus", popup_cell);
e_table_extras_add_compare (extras, "date-compare",
- task_table_date_compare_cb);
+ e_cell_date_edit_compare_cb);
e_table_extras_add_compare (extras, "percent-compare",
task_table_percent_compare_cb);
e_table_extras_add_compare (extras, "priority-compare",