mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
6fb3a499e6
commit
ab894c9b64
4 changed files with 97 additions and 47 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue