aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2001-01-06 13:31:13 +0800
committerChris Lahey <clahey@src.gnome.org>2001-01-06 13:31:13 +0800
commitc5f64863e3fd5895510a5a890a49114825293812 (patch)
tree21b0ebb32c85424fa40c49fc9ab6b3ce67f24bd9
parent3d0a81c35455e8e8cbc079037e5defa470e4ba17 (diff)
downloadgsoc2013-evolution-c5f64863e3fd5895510a5a890a49114825293812.tar
gsoc2013-evolution-c5f64863e3fd5895510a5a890a49114825293812.tar.gz
gsoc2013-evolution-c5f64863e3fd5895510a5a890a49114825293812.tar.bz2
gsoc2013-evolution-c5f64863e3fd5895510a5a890a49114825293812.tar.lz
gsoc2013-evolution-c5f64863e3fd5895510a5a890a49114825293812.tar.xz
gsoc2013-evolution-c5f64863e3fd5895510a5a890a49114825293812.tar.zst
gsoc2013-evolution-c5f64863e3fd5895510a5a890a49114825293812.zip
Fixed sorting. needs_sorting was getting set to 0 when sorted happens, but
2001-01-06 Christopher James Lahey <clahey@helixcode.com> * e-table-sorter.c, e-table-sorter.h (ets_sort): Fixed sorting. needs_sorting was getting set to 0 when sorted happens, but needs_sorting tells you whether or not the sorter is sorted or not, not whether the sorting has happened. Documented the needs_sorting variable. svn path=/trunk/; revision=7281
-rw-r--r--widgets/table/e-table-sorter.c32
-rw-r--r--widgets/table/e-table-sorter.h1
2 files changed, 3 insertions, 30 deletions
diff --git a/widgets/table/e-table-sorter.c b/widgets/table/e-table-sorter.c
index cf878c56ca..0eb52d42d1 100644
--- a/widgets/table/e-table-sorter.c
+++ b/widgets/table/e-table-sorter.c
@@ -243,32 +243,6 @@ struct _subinfo {
GArray *rowsort; /* an array of row info's */
};
-static int
-qsort_callback_complex(const void *data1, const void *data2)
-{
- gint row1 = ((struct _rowinfo *)data1)->row;
- gint row2 = ((struct _rowinfo *)data2)->row;
- int j;
- int sort_count = e_table_sort_info_sorting_get_count(ets_closure->sort_info);
- int comp_val = 0;
- int ascending = 1;
- for (j = 0; j < sort_count; j++) {
- comp_val = (*(compare_closure[j]))(vals_closure[cols_closure * row1 + j], vals_closure[cols_closure * row2 + j]);
- ascending = ascending_closure[j];
- 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;
-}
-
/* builds the info needed to sort everything */
static struct _subinfo *
ets_sort_build_subset(ETableSorter *ets, struct _group_info *groupinfo, int start, int *end)
@@ -340,7 +314,7 @@ ets_sort_subset(ETableSorter *ets, struct _subinfo *subinfo, int startoffset)
d(printf("sorting subset start %d rows %d\n", startoffset, rowsort->len));
/* first, sort the actual data */
- qsort(rowsort->data, rowsort->len, sizeof(struct _rowinfo), qsort_callback_complex);
+ qsort(rowsort->data, rowsort->len, sizeof(struct _rowinfo), qsort_callback);
/* then put it back in the map table, where appropriate */
offset = startoffset;
@@ -401,7 +375,7 @@ ets_sort_by_group (ETableSorter *ets)
return;
/* get all the rows' sort groups */
- groups = g_malloc(sizeof(struct _group_info) * rows);
+ groups = g_new(struct _group_info, rows);
for (i=0;i<rows;i++) {
groups[i].row = i;
groups[i].group = g_strdup(e_table_model_row_sort_group(ets->source, groups[i].row));
@@ -437,8 +411,6 @@ ets_sort(ETableSorter *ets)
if (ets->sorted)
return;
- ets->needs_sorting = 0;
-
rows = e_table_model_row_count(ets->source);
group_cols = e_table_sort_info_grouping_get_count(ets->sort_info);
cols = e_table_sort_info_sorting_get_count(ets->sort_info) + group_cols;
diff --git a/widgets/table/e-table-sorter.h b/widgets/table/e-table-sorter.h
index 43959a0a93..2f4c5bdf9d 100644
--- a/widgets/table/e-table-sorter.h
+++ b/widgets/table/e-table-sorter.h
@@ -21,6 +21,7 @@ typedef struct {
ETableHeader *full_header;
ETableSortInfo *sort_info;
+ /* If needs_sorting is 0, then model_to_sorted and sorted_to_model are no-ops. */
int needs_sorting;
int *sorted;