diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-06-08 17:58:16 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-06-08 20:45:29 -0700 |
commit | c9113a1f429e74717c90261458a8aadde7e391f8 (patch) | |
tree | c8d0a58f518e38dcb6b848c41f8698901e62b694 | |
parent | 1ee38b4e5ea07eee14835706672e9ea55754a6eb (diff) | |
download | subsurface-c9113a1f429e74717c90261458a8aadde7e391f8.tar.gz |
Sort 'dive number' column by date, not number
Ok, so this sounds insane, but it fixes our currently broken sorting
of dive trips vs plain dives not in trips.
The reason for that is simple: the dive trips are sorted by date, but
that's column #0, and for plain dives is the dive number.
So currently the trip-vs-dive sorting looks at the date of the trip,
and compares that to the number of the dive. Since the date of the
trip is expressed as seconds-since-1970-in-UTC, unsurprisingly the
dive number is generally much smaller (even for some very avid divers
;), and so the plain dives end up sorting way at the bottom (or at the
top, if you do "oldest trips first"
Since the dive number *should* sort as the date, this stupid attached
patch just makes us return the dive date instead.
Now, there are other possible solutions to this:
- make the date of the dive be column 0, and make the dive number be column 1.
Quite frankly, while more logical for this particular problem, it
probably sucks as a solution. We do want to have a column we can sort
dives by that is date-based, but doesn't include trips. And while the
dive number *should* sort identically to the date one, the fact is
that you can have dives without any numbering, so it doesn't.
In contrast, all dives have dates, and sorting numbered dives by
date should still result in sane behavior (and if it doesn't, then the
insanity comes from the dive numbering, and odd sorting is the fault
of the user and indicative of a problem)
- We could possibly do something magical like sorting dives by number
when they are inside trips, or when no trips exist at all. But then
we'd sort by date when there are trips and the dive is outside the
trip. But quite frankly, that just sounds insane.
So on the whole, I don't love this patch, but it seems to be the least
confusing of the possibilities.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-ui/models.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 045592deb..86773fd52 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -835,7 +835,7 @@ QVariant DiveItem::data(int column, int role) const break; case SORT_ROLE: switch (column) { - case NR: retVal = dive->number; break; + case NR: retVal = (qulonglong) dive->when; break; case DATE: retVal = (qulonglong) dive->when; break; case RATING: retVal = dive->rating; break; case DEPTH: retVal = dive->maxdepth.mm; break; |