aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-08-06 07:00:41 +0800
committerChris Lahey <clahey@src.gnome.org>2000-08-06 07:00:41 +0800
commitc115cff69df04b7580fd8a50e087c7bd53614cec (patch)
tree2cd51ac2167577ed803dc4b6b4aea4a79c041b88
parent089f42f8dd81428b578939f385eb143254a83644 (diff)
downloadgsoc2013-evolution-c115cff69df04b7580fd8a50e087c7bd53614cec.tar
gsoc2013-evolution-c115cff69df04b7580fd8a50e087c7bd53614cec.tar.gz
gsoc2013-evolution-c115cff69df04b7580fd8a50e087c7bd53614cec.tar.bz2
gsoc2013-evolution-c115cff69df04b7580fd8a50e087c7bd53614cec.tar.lz
gsoc2013-evolution-c115cff69df04b7580fd8a50e087c7bd53614cec.tar.xz
gsoc2013-evolution-c115cff69df04b7580fd8a50e087c7bd53614cec.tar.zst
gsoc2013-evolution-c115cff69df04b7580fd8a50e087c7bd53614cec.zip
Added functions to convert from view row to model row or from model row to
2000-08-05 Christopher James Lahey <clahey@helixcode.com> * e-table.c, e-table.h: Added functions to convert from view row to model row or from model row to view row. Also changed e_table_set_cursor_row and e_table_get_cursor_row to take a model row as this works better with the rest of the model. Changed the name of e_table_get_next_row_sorted and e_table_get_prev_row_sorted. (Dropped the _sorted.) svn path=/trunk/; revision=4556
-rw-r--r--widgets/e-table/ChangeLog9
-rw-r--r--widgets/e-table/e-table.c42
-rw-r--r--widgets/e-table/e-table.h9
-rw-r--r--widgets/table/e-table.c42
-rw-r--r--widgets/table/e-table.h9
5 files changed, 89 insertions, 22 deletions
diff --git a/widgets/e-table/ChangeLog b/widgets/e-table/ChangeLog
index eacf84cea9..0bf8bfb5c4 100644
--- a/widgets/e-table/ChangeLog
+++ b/widgets/e-table/ChangeLog
@@ -1,3 +1,12 @@
+2000-08-05 Christopher James Lahey <clahey@helixcode.com>
+
+ * e-table.c, e-table.h: Added functions to convert from view row
+ to model row or from model row to view row. Also changed
+ e_table_set_cursor_row and e_table_get_cursor_row to take a model
+ row as this works better with the rest of the model. Changed the
+ name of e_table_get_next_row_sorted and
+ e_table_get_prev_row_sorted. (Dropped the _sorted.)
+
2000-08-05 Dan Winship <danw@helixcode.com>
* e-table.c (e_table_get_{next,prev}_row_sorted): fix
diff --git a/widgets/e-table/e-table.c b/widgets/e-table/e-table.c
index d9cbbc4779..ca26678607 100644
--- a/widgets/e-table/e-table.c
+++ b/widgets/e-table/e-table.c
@@ -803,13 +803,17 @@ e_table_save_specification (ETable *e_table, gchar *filename)
void
e_table_set_cursor_row (ETable *e_table, int row)
{
- e_table_group_set_cursor_row(e_table->group, row);
+ row = e_table_sorter_model_to_sorted(e_table->sorter, row);
+ if (row != -1)
+ e_table_group_set_cursor_row(e_table->group, row);
}
int
e_table_get_cursor_row (ETable *e_table)
{
- return e_table_group_get_cursor_row(e_table->group);
+ int row = e_table_group_get_cursor_row(e_table->group);
+ row = e_table_sorter_sorted_to_model(e_table->sorter, row);
+ return row;
}
void
@@ -926,27 +930,27 @@ set_scroll_adjustments (ETable *table,
}
gint
-e_table_get_next_row_sorted (ETable *e_table,
- gint model_row)
+e_table_get_next_row (ETable *e_table,
+ gint model_row)
{
if (e_table->sorter) {
int i;
i = e_table_sorter_model_to_sorted(e_table->sorter, model_row);
- if (i < e_table_model_row_count(e_table->model) - 1) {
- i++;
+ i++;
+ if (i < e_table_model_row_count(e_table->model)) {
return e_table_sorter_sorted_to_model(e_table->sorter, i);
} else
return -1;
} else
- if (model_row < e_table_model_row_count(e_table->model))
+ if (model_row < e_table_model_row_count(e_table->model) - 1)
return model_row + 1;
else
return -1;
}
gint
-e_table_get_prev_row_sorted (ETable *e_table,
- gint model_row)
+e_table_get_prev_row (ETable *e_table,
+ gint model_row)
{
if (e_table->sorter) {
int i;
@@ -960,6 +964,26 @@ e_table_get_prev_row_sorted (ETable *e_table,
return model_row - 1;
}
+gint
+e_table_model_to_view_row (ETable *e_table,
+ gint model_row)
+{
+ if (e_table->sorter)
+ return e_table_sorter_model_to_sorted(e_table->sorter, model_row);
+ else
+ return model_row;
+}
+
+gint
+e_table_view_to_model_row (ETable *e_table,
+ gint view_row)
+{
+ if (e_table->sorter)
+ return e_table_sorter_sorted_to_model(e_table->sorter, view_row);
+ else
+ return view_row;
+}
+
struct _ETableDragSourceSite
{
GdkModifierType start_button_mask;
diff --git a/widgets/e-table/e-table.h b/widgets/e-table/e-table.h
index b0e3cd174a..19dcbfecc8 100644
--- a/widgets/e-table/e-table.h
+++ b/widgets/e-table/e-table.h
@@ -182,11 +182,16 @@ void e_table_selected_row_foreach (ETable *e_table,
gpointer closure);
EPrintable *e_table_get_printable (ETable *e_table);
-gint e_table_get_next_row_sorted (ETable *e_table,
+gint e_table_get_next_row (ETable *e_table,
gint model_row);
-gint e_table_get_prev_row_sorted (ETable *e_table,
+gint e_table_get_prev_row (ETable *e_table,
gint model_row);
+gint e_table_model_to_view_row (ETable *e_table,
+ gint model_row);
+gint e_table_view_to_model_row (ETable *e_table,
+ gint view_row);
+
/* Drag & drop stuff. */
/* Target */
diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c
index d9cbbc4779..ca26678607 100644
--- a/widgets/table/e-table.c
+++ b/widgets/table/e-table.c
@@ -803,13 +803,17 @@ e_table_save_specification (ETable *e_table, gchar *filename)
void
e_table_set_cursor_row (ETable *e_table, int row)
{
- e_table_group_set_cursor_row(e_table->group, row);
+ row = e_table_sorter_model_to_sorted(e_table->sorter, row);
+ if (row != -1)
+ e_table_group_set_cursor_row(e_table->group, row);
}
int
e_table_get_cursor_row (ETable *e_table)
{
- return e_table_group_get_cursor_row(e_table->group);
+ int row = e_table_group_get_cursor_row(e_table->group);
+ row = e_table_sorter_sorted_to_model(e_table->sorter, row);
+ return row;
}
void
@@ -926,27 +930,27 @@ set_scroll_adjustments (ETable *table,
}
gint
-e_table_get_next_row_sorted (ETable *e_table,
- gint model_row)
+e_table_get_next_row (ETable *e_table,
+ gint model_row)
{
if (e_table->sorter) {
int i;
i = e_table_sorter_model_to_sorted(e_table->sorter, model_row);
- if (i < e_table_model_row_count(e_table->model) - 1) {
- i++;
+ i++;
+ if (i < e_table_model_row_count(e_table->model)) {
return e_table_sorter_sorted_to_model(e_table->sorter, i);
} else
return -1;
} else
- if (model_row < e_table_model_row_count(e_table->model))
+ if (model_row < e_table_model_row_count(e_table->model) - 1)
return model_row + 1;
else
return -1;
}
gint
-e_table_get_prev_row_sorted (ETable *e_table,
- gint model_row)
+e_table_get_prev_row (ETable *e_table,
+ gint model_row)
{
if (e_table->sorter) {
int i;
@@ -960,6 +964,26 @@ e_table_get_prev_row_sorted (ETable *e_table,
return model_row - 1;
}
+gint
+e_table_model_to_view_row (ETable *e_table,
+ gint model_row)
+{
+ if (e_table->sorter)
+ return e_table_sorter_model_to_sorted(e_table->sorter, model_row);
+ else
+ return model_row;
+}
+
+gint
+e_table_view_to_model_row (ETable *e_table,
+ gint view_row)
+{
+ if (e_table->sorter)
+ return e_table_sorter_sorted_to_model(e_table->sorter, view_row);
+ else
+ return view_row;
+}
+
struct _ETableDragSourceSite
{
GdkModifierType start_button_mask;
diff --git a/widgets/table/e-table.h b/widgets/table/e-table.h
index b0e3cd174a..19dcbfecc8 100644
--- a/widgets/table/e-table.h
+++ b/widgets/table/e-table.h
@@ -182,11 +182,16 @@ void e_table_selected_row_foreach (ETable *e_table,
gpointer closure);
EPrintable *e_table_get_printable (ETable *e_table);
-gint e_table_get_next_row_sorted (ETable *e_table,
+gint e_table_get_next_row (ETable *e_table,
gint model_row);
-gint e_table_get_prev_row_sorted (ETable *e_table,
+gint e_table_get_prev_row (ETable *e_table,
gint model_row);
+gint e_table_model_to_view_row (ETable *e_table,
+ gint model_row);
+gint e_table_view_to_model_row (ETable *e_table,
+ gint view_row);
+
/* Drag & drop stuff. */
/* Target */