diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-10-29 20:17:53 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-11-01 07:28:15 -0700 |
commit | ab894c9b64ca5cceef87d1835f3a84103668ffc9 (patch) | |
tree | 0e61eb8ea4af3895713351d76419566a9c183e7d /qt-models/divetripmodel.h | |
parent | 6fb3a499e67bc5375e66faef5969afee99a74d25 (diff) | |
download | subsurface-ab894c9b64ca5cceef87d1835f3a84103668ffc9.tar.gz |
Dive list: implement custom lessThan function
The dive list was sorted using the default-sorter of
QSortFilterProxy model. This is mighty inflexible as it
considers only one column. This has the funky effect that
for rows with identical elements, the sort order depends
on the previous sorting.
Implement a lessThan() function in the MultiFilterSortModel,
which simply hands the sorting down to the actual model.
This might be considered a layering violation, but it makes
things so much easier.
Sadly, it seems like the column-to-be-sorted is transported
in the provided indices. Therefore, the comparison is chosen
using a switch for *every* comparison. It would seem much
more logical to set a function pointer once and use that.
Further investigations are necessary.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/divetripmodel.h')
-rw-r--r-- | qt-models/divetripmodel.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/qt-models/divetripmodel.h b/qt-models/divetripmodel.h index b372a981f..4993c855f 100644 --- a/qt-models/divetripmodel.h +++ b/qt-models/divetripmodel.h @@ -34,7 +34,6 @@ public: STAR_ROLE = Qt::UserRole + 1, DIVE_ROLE, TRIP_ROLE, - SORT_ROLE, DIVE_IDX, SELECTED_ROLE }; @@ -56,6 +55,10 @@ public: QModelIndex index(int row, int column, const QModelIndex &parent) const; QModelIndex parent(const QModelIndex &index) const; void filterFinished(); + + // Used for sorting. This is a bit of a layering violation, as sorting should be performed + // by the higher-up QSortFilterProxyModel, but it makes things so much easier! + bool lessThan(const QModelIndex &i1, const QModelIndex &i2) const; signals: // The propagation of selection changes is complex. // The control flow of dive-selection goes: |