From ab894c9b64ca5cceef87d1835f3a84103668ffc9 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 29 Oct 2018 20:17:53 +0100 Subject: 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 --- qt-models/filtermodels.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'qt-models/filtermodels.h') diff --git a/qt-models/filtermodels.h b/qt-models/filtermodels.h index f579df1a9..8830e99c3 100644 --- a/qt-models/filtermodels.h +++ b/qt-models/filtermodels.h @@ -11,6 +11,7 @@ struct dive; struct dive_trip; +class DiveTripModel; class FilterModelBase : public QAbstractListModel { Q_OBJECT @@ -127,6 +128,7 @@ public: void divesDeleted(const QVector &dives); bool showDive(const struct dive *d) const; int divesDisplayed; + bool lessThan(const QModelIndex &, const QModelIndex &) const override; public slots: void myInvalidate(); @@ -142,6 +144,7 @@ private: MultiFilterSortModel(QObject *parent = 0); QList models; struct dive_site *curr_dive_site; + DiveTripModel *model; }; #endif -- cgit v1.2.3-70-g09d2