summaryrefslogtreecommitdiffstats
path: root/statistics.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2012-08-20 05:48:07 -0700
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2012-08-20 05:48:07 -0700
commit972669d6363c163ed6d3b737cbd6b1bd534f3d7b (patch)
treea95115c2231bd7ce81480a9e3dd107d8cc4c6cab /statistics.c
parent38f92f780ac3a9345bcb34d297ade0eadbd903ea (diff)
downloadsubsurface-972669d6363c163ed6d3b737cbd6b1bd534f3d7b.tar.gz
Rework dive selection logic
This completely changes how we keep track of selected dives: instead of having an array listing the selection ("selectiontracker") or trusting the gtk selection information, just save the information about whether a dive is selected in the dive itself. That makes it trivial to keep track of the state of selection across group collapse/expand events, or when changing the tree view model. It also ends up simplifying the code and logic in other ways. HOWEVER, it does currently (re-)introduce an annoying oddity with gtk: if you collapse a dive trip that has individual selections, gtk will forget those selections ("out of sight, out of mind"), and when you do *new* selections, the old hidden ones remain. So there's some games required to make gtk do sane things. We may need to either explicitly drop selections when collapsing trips, or make sure the group entry gets selected when collapsing a group that has selections in it. Or something. There may be other issues introduced by this too. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'statistics.c')
-rw-r--r--statistics.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/statistics.c b/statistics.c
index 0f6fbe047..0a23f9022 100644
--- a/statistics.c
+++ b/statistics.c
@@ -143,24 +143,21 @@ static void process_all_dives(struct dive *dive, struct dive **prev_dive)
}
/* make sure we skip the selected summary entries */
-void process_selected_dives(GList *selected_dives, int *selectiontracker, GtkTreeModel *model)
+void process_selected_dives(void)
{
- struct dive *dp;
- unsigned int i;
- int idx;
+ struct dive *dive;
+ unsigned int i, nr;
memset(&stats_selection, 0, sizeof(stats_selection));
- for (i = 0; i < amount_selected; ++i) {
- idx = selectiontracker[i];
- if (idx > 0) {
- dp = get_dive(idx);
- if (dp) {
- process_dive(dp, &stats_selection);
- }
+ nr = 0;
+ for (i = 0; (dive = get_dive(i)) != NULL; ++i) {
+ if (dive->selected) {
+ process_dive(dive, &stats_selection);
+ nr++;
}
}
- stats_selection.selection_size = amount_selected;
+ stats_selection.selection_size = nr;
}
static void set_label(GtkWidget *w, const char *fmt, ...)