summaryrefslogtreecommitdiffstats
path: root/qt-models/divelistmodel.h
diff options
context:
space:
mode:
Diffstat (limited to 'qt-models/divelistmodel.h')
-rw-r--r--qt-models/divelistmodel.h39
1 files changed, 35 insertions, 4 deletions
diff --git a/qt-models/divelistmodel.h b/qt-models/divelistmodel.h
index d9e0928dc..92e7a9291 100644
--- a/qt-models/divelistmodel.h
+++ b/qt-models/divelistmodel.h
@@ -7,15 +7,46 @@
#include "core/subsurface-qt/DiveObjectHelper.h"
+class CollapsedDiveListSortModel : public QSortFilterProxyModel
+{
+ Q_OBJECT
+public:
+ static CollapsedDiveListSortModel *instance();
+ void setSourceModel(QAbstractItemModel *sourceModel);
+ Q_INVOKABLE QString tripTitle(const QString &trip);
+ Q_INVOKABLE QString tripShortDate(const QString &trip);
+ Q_INVOKABLE void setActiveTrip(const QString &trip);
+ Q_INVOKABLE QString activeTrip() const;
+ // super subtle optimization alert - in order to reduce the number of model accesses from QML,
+ // the two states where we show the dive in question have odd numbers
+ enum CollapsedState {
+ DontShow = 0,
+ ShowDive = 1,
+ ShowTrip = 2,
+ ShowDiveAndTrip = 3
+ };
+ void updateFilterState();
+ void updateSelectionState();
+
+protected:
+ bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
+
+private:
+ CollapsedDiveListSortModel();
+ bool isExpanded(struct dive_trip *dt) const;
+ QString m_activeTrip;
+};
+
class DiveListSortModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
static DiveListSortModel *instance();
void setSourceModel(QAbstractItemModel *sourceModel);
+ QString getFilterString() const;
Q_INVOKABLE void reload();
- Q_INVOKABLE QString tripTitle(const QString &trip);
- Q_INVOKABLE QString tripShortDate(const QString &trip);
+ QString filterString;
+ void updateFilterState();
public slots:
int getIdxForId(int id);
void setFilter(QString f);
@@ -25,8 +56,6 @@ protected:
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
private:
DiveListSortModel();
- QString filterString;
- void updateFilterState();
};
QString formatSac(const dive *d);
@@ -74,6 +103,8 @@ public:
StartPressureRole,
EndPressureRole,
FirstGasRole,
+ CollapsedRole,
+ SelectedRole,
};
static DiveListModel *instance();