diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-08-16 10:46:30 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-08-16 10:46:30 -0700 |
commit | 9b72217f79f29313d30c87c55f533cc606da6a8f (patch) | |
tree | f3e9eb1d508b1873d20f22ddbbe9ecc0269a3149 /statistics.c | |
parent | 91e7dcc555ada4fe43198327383e895e528c4cc7 (diff) | |
parent | e6ecddfa3d17901847474b67b6121c0c8f56f078 (diff) | |
download | subsurface-9b72217f79f29313d30c87c55f533cc606da6a8f.tar.gz |
Merge branch 'tree2' of git://git.hohndel.org/subsurface
Pull dive-trip grouping from Dirk Hohndel:
"This turned into an updated pull request for the tree2 branch where I
implemented the date based grouping - but is actually a very different
topic: this adds the ability to edit multiple dives (and fixes some
issues with the dive editing overall). The reason for that is that it
reuses some of the infrastructure that I implemented in the tree2
branch for tracking the selected dives. More details in the commit
messages."
* 'tree2' of git://git.hohndel.org/subsurface:
Switch from date based to dive trip based grouping
Redo dive editing
Fix selecting and unselecting summary items
Apply sort functions to the correct model, don't select summary entries
Maintain selected rows when switching between list model and tree model
Create duplicate list model so sorting by columns works again
Improve tree model implementation
Allow date based grouping
Diffstat (limited to 'statistics.c')
-rw-r--r-- | statistics.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/statistics.c b/statistics.c index 19105653c..3a260066a 100644 --- a/statistics.c +++ b/statistics.c @@ -142,25 +142,39 @@ static void process_all_dives(struct dive *dive, struct dive **prev_dive) } } -void process_selected_dives(GList *selected_dives, GtkTreeModel *model) +/* make sure we skip the selected summary entries */ +void process_selected_dives(GList *selected_dives, int *selectiontracker, GtkTreeModel *model) { struct dive *dp; - unsigned int i; + unsigned int i, j; + int idx; GtkTreeIter iter; GtkTreePath *path; memset(&stats_selection, 0, sizeof(stats_selection)); - stats_selection.selection_size = amount_selected; - for (i = 0; i < amount_selected; ++i) { + /* adjust amount_selected and remove negative index entries from list */ + for (i = 0, j = 0; j < amount_selected; ++i) { GValue value = {0, }; 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); + if (idx > 0) { + dp = get_dive(idx); + if (dp) { + selectiontracker[j] = idx; + process_dive(dp, &stats_selection); + j++; + continue; + } + } } - process_dive(dp, &stats_selection); + /* we didn't process it, so shorten the list */ + amount_selected--; } + /* record the actual number of dives selected */ + stats_selection.selection_size = amount_selected; } static void set_label(GtkWidget *w, const char *fmt, ...) |