diff options
Diffstat (limited to 'qt-models/divetripmodel.h')
-rw-r--r-- | qt-models/divetripmodel.h | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/qt-models/divetripmodel.h b/qt-models/divetripmodel.h index 4993c855f..8ff4524b3 100644 --- a/qt-models/divetripmodel.h +++ b/qt-models/divetripmodel.h @@ -81,24 +81,15 @@ private slots: private: // The model has up to two levels. At the top level, we have either trips or dives // that do not belong to trips. Such a top-level item is represented by the "Item" - // struct. Two cases two consider: - // 1) If "trip" is non-null, then this is a dive-trip and the dives are collected - // in the dives vector. Note that in principle we could also get the dives in a - // trip from the backend, but there they are collected in a linked-list, which is - // 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, which is based on the dive_or_trip structure. + // If it is a trip, additionally, the dives are collected in a vector. + // The items are ordered chronologically according to the dive_or_trip_less_than() + // function, which guarantees a stable ordering even in the case of equal timestamps. + // For dives and trips, it place dives chronologically after trips, so that in + // the default-descending view they are shown before trips. struct Item { - dive_trip *trip; - std::vector<dive *> dives; // std::vector<> instead of QVector for insert() with three iterators + dive_or_trip d_or_t; + std::vector<dive *> dives; // std::vector<> instead of QVector for insert() with three iterators Item(dive_trip *t, const QVector<dive *> &dives); Item(dive_trip *t, dive *d); // Initialize a trip with one dive Item(dive *d); // Initialize a top-level dive @@ -126,7 +117,7 @@ private: void addDivesToTrip(int idx, const QVector<dive *> &dives); dive *diveOrNull(const QModelIndex &index) const; // Returns a dive if this index represents a dive, null otherwise - QPair<dive_trip *, dive *> tripOrDive(const QModelIndex &index) const; + dive_or_trip tripOrDive(const QModelIndex &index) const; // Returns either a pointer to a trip or a dive, or twice null of index is invalid // null, something is really wrong void setupModelData(); |