aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table/e-table-sorted-variable.c
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-06-02 09:52:27 +0800
committerChris Lahey <clahey@src.gnome.org>2000-06-02 09:52:27 +0800
commit2b418bb61aea51d04c289a958398c5b416572130 (patch)
tree0ccf918b4ba9857c92a648559bbcbcacd0c1f8c2 /widgets/table/e-table-sorted-variable.c
parent5ab6198e11a0ca19e7fcb99ee483b95eb46a8ee8 (diff)
downloadgsoc2013-evolution-2b418bb61aea51d04c289a958398c5b416572130.tar.gz
gsoc2013-evolution-2b418bb61aea51d04c289a958398c5b416572130.tar.zst
gsoc2013-evolution-2b418bb61aea51d04c289a958398c5b416572130.zip
Made the sort when inserting a signal row be syncronous.
2000-06-01 Christopher James Lahey <clahey@helixcode.com> * e-table-sorted-variable.c: Made the sort when inserting a signal row be syncronous. svn path=/trunk/; revision=3358
Diffstat (limited to 'widgets/table/e-table-sorted-variable.c')
-rw-r--r--widgets/table/e-table-sorted-variable.c49
1 files changed, 44 insertions, 5 deletions
diff --git a/widgets/table/e-table-sorted-variable.c b/widgets/table/e-table-sorted-variable.c
index 0d2ecce800..7ea2eac04b 100644
--- a/widgets/table/e-table-sorted-variable.c
+++ b/widgets/table/e-table-sorted-variable.c
@@ -98,6 +98,41 @@ etsv_sort_idle(ETableSortedVariable *etsv)
return FALSE;
}
+/* This takes source rows. */
+static int
+etsv_compare(ETableSortedVariable *etsv, int row1, int row2)
+{
+ int j;
+ int sort_count = e_table_sort_info_sorting_get_count(etsv->sort_info);
+ int comp_val = 0;
+ int ascending = 1;
+ ETableSubset *etss = E_TABLE_SUBSET(etsv);
+
+ for (j = 0; j < sort_count; j++) {
+ ETableSortColumn column = e_table_sort_info_sorting_get_nth(etsv->sort_info, j);
+ ETableCol *col;
+ if (column.column > e_table_header_count (etsv->full_header))
+ col = e_table_header_get_column (etsv->full_header, e_table_header_count (etsv->full_header) - 1);
+ else
+ col = e_table_header_get_column (etsv->full_header, column.column);
+ comp_val = (*col->compare)(e_table_model_value_at (etss->source, col->col_idx, row1),
+ e_table_model_value_at (etss->source, col->col_idx, row2));
+ ascending = column.ascending;
+ if (comp_val != 0)
+ break;
+ }
+ if (comp_val == 0) {
+ if (row1 < row2)
+ comp_val = -1;
+ if (row1 > row2)
+ comp_val = 1;
+ }
+ if (!ascending)
+ comp_val = -comp_val;
+ return comp_val;
+}
+
+
static void
etsv_add (ETableSubsetVariable *etssv,
gint row)
@@ -107,7 +142,7 @@ etsv_add (ETableSubsetVariable *etssv,
ETableSortedVariable *etsv = E_TABLE_SORTED_VARIABLE (etssv);
int i;
- if (etss->n_map + 1 > etssv->n_vals_allocated){
+ if (etss->n_map + 1 > etssv->n_vals_allocated) {
etssv->n_vals_allocated += INCREMENT_AMOUNT;
etss->map_table = g_realloc (etss->map_table, (etssv->n_vals_allocated) * sizeof(int));
}
@@ -115,13 +150,17 @@ etsv_add (ETableSubsetVariable *etssv,
for ( i = 0; i < etss->n_map; i++ )
if (etss->map_table[i] >= row)
etss->map_table[i] ++;
- etss->map_table[etss->n_map] = row;
- etss->n_map++;
+ i = etss->n_map;
if (etsv->sort_idle_id == 0) {
- etsv->sort_idle_id = g_idle_add_full(30, (GSourceFunc) etsv_sort_idle, etsv, NULL);
+ i = 0;
+ while (etsv_compare(etsv, etss->map_table[i], row) < 0)
+ i++;
+ memmove(etss->map_table + i + 1, etss->map_table + i, etss->n_map - i);
}
+ etss->map_table[i] = row;
+ etss->n_map++;
if (!etm->frozen)
- e_table_model_row_inserted (etm, etss->n_map - 1);
+ e_table_model_row_inserted (etm, i);
}
static void