summaryrefslogtreecommitdiffstats
path: root/statistics.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2012-08-13 14:53:07 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-08-14 12:43:16 -0700
commitdc9d0e23e5d158ea4775021b2f629e7f90b5377c (patch)
tree9b3719c76116ee83a5d87962f3f088bb20289d9c /statistics.c
parent27a505e579057596ab10f7381c471b870ce86f87 (diff)
downloadsubsurface-dc9d0e23e5d158ea4775021b2f629e7f90b5377c.tar.gz
Maintain selected rows when switching between list model and tree model
We keep track of the DIVE_INDEX of all selected dives and simply re-select those dives after changing model (date based sort or sort by other column). There are a few TODOs left. We lose the sort direction (ascending / descending) when switching models. We also don't correctly deal with the user selecting summary rows in the tree model. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'statistics.c')
-rw-r--r--statistics.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/statistics.c b/statistics.c
index 19105653c..adfc9c77a 100644
--- a/statistics.c
+++ b/statistics.c
@@ -142,10 +142,11 @@ static void process_all_dives(struct dive *dive, struct dive **prev_dive)
}
}
-void process_selected_dives(GList *selected_dives, GtkTreeModel *model)
+void process_selected_dives(GList *selected_dives, int *selectiontracker, GtkTreeModel *model)
{
struct dive *dp;
unsigned int i;
+ int idx;
GtkTreeIter iter;
GtkTreePath *path;
@@ -157,9 +158,13 @@ void process_selected_dives(GList *selected_dives, GtkTreeModel *model)
path = g_list_nth_data(selected_dives, i);
if (gtk_tree_model_get_iter(model, &iter, path)) {
gtk_tree_model_get_value(model, &iter, 0, &value);
- dp = get_dive(g_value_get_int(&value));
+ idx = g_value_get_int(&value);
+ dp = get_dive(idx);
+ if (dp) {
+ selectiontracker[i] = idx;
+ process_dive(dp, &stats_selection);
+ }
}
- process_dive(dp, &stats_selection);
}
}