aboutsummaryrefslogtreecommitdiffstats
path: root/qt-models/divetripmodel.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-08-26 14:42:38 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-11 16:22:27 -0700
commitf836b9ae97bc8109e1acdd1859bd41a5dc53f7f3 (patch)
treed7e0ce6ca0265ebf01103273384a4594f99e0838 /qt-models/divetripmodel.h
parent0cca36377b01fc10063ecc67f5471ce80d133991 (diff)
downloadsubsurface-f836b9ae97bc8109e1acdd1859bd41a5dc53f7f3.tar.gz
Dive list: unify sorting in core and Qt-model
Ultimately, we want to use a single dive-list and not replicate it in the Qt-model code. To this goal, let's start with using the same sort function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/divetripmodel.h')
-rw-r--r--qt-models/divetripmodel.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/qt-models/divetripmodel.h b/qt-models/divetripmodel.h
index c8050a6da..fb3c3395d 100644
--- a/qt-models/divetripmodel.h
+++ b/qt-models/divetripmodel.h
@@ -138,6 +138,14 @@ private:
// quite inconvenient to access.
// 2) If "trip" is null, this is a dive and dives is supposed to contain exactly
// one element, which is the corresponding dive.
+ //
+ // Top-level items are ordered by timestamp. For dives, the core function
+ // dive_less_than is used, which guarantees a stable ordering even in the
+ // case of equal timestamps. For dives and trips, place dives before trips
+ // in the case of an equal timestamp. For trips with equal timestamps, the
+ // order is currently undefined. This is currently not a problem, because
+ // the core doesn't have a list of sorted trips. But nevertheless something
+ // to keep in mind.
struct Item {
dive_trip *trip;
std::vector<dive *> dives; // std::vector<> instead of QVector for insert() with three iterators
@@ -148,6 +156,8 @@ private:
dive *getDive() const; // Helper function: returns top-level-dive or null
timestamp_t when() const; // Helper function: start time of dive *or* trip
};
+ // Comparison function between dive and arbitrary entry
+ static bool dive_before_entry(const dive *d, const Item &entry);
// Access trips and dives
int findTripIdx(const dive_trip *trip) const;