[PATCH] Sort "loose" dives properly in-between trips

Miika Turkia miika.turkia at gmail.com
Mon Jan 7 08:53:21 PST 2013


When clicking the dive trip column, the dive trips are sorted, but any
dives that do not belong to a trip are thrown at the end of the list.
This patch will position the independent dives to their proper place in
the dive (trip) list.

Signed-off-by: Miika Turkia <miika.turkia at gmail.com>
---
 divelist.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/divelist.c b/divelist.c
index 6397f62..b1eac31 100644
--- a/divelist.c
+++ b/divelist.c
@@ -1461,8 +1461,15 @@ static gint dive_nr_sort(GtkTreeModel *model,
 			tripb = b->divetrip;
 	}
 
-	if (!tripa || !tripb)
+	if (!tripa && !tripb)
 		return 0;
+
+	if (!tripa && tripb)
+		return when_a < tripb->when ? -1 : 1;
+
+	if (tripa && !tripb)
+		return tripa->when < when_b ? -1 : 1;
+
 	if (tripa->when < tripb->when)
 		return -1;
 	if (tripa->when > tripb->when)
-- 
1.7.9.5



More information about the subsurface mailing list