summaryrefslogtreecommitdiffstats
path: root/qt-models/divelistmodel.h
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2016-01-28 18:23:14 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-01-28 18:33:22 -0800
commitaf9f07626a010b78289d68c7b4d388bdeeec9fa4 (patch)
tree26ff24210c89a8499d7ef01e3ba24a49970e0e76 /qt-models/divelistmodel.h
parentdbe9bad0aaa8d0cac63166d3b1b4a9a189ef12c8 (diff)
downloadsubsurface-af9f07626a010b78289d68c7b4d388bdeeec9fa4.tar.gz
Add our own sort proxy class which provides two helper functions
These can then be used from QML to map the index into the model (the sort model corresponds directly to the indices in QML) to the dive id and back. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-models/divelistmodel.h')
-rw-r--r--qt-models/divelistmodel.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/qt-models/divelistmodel.h b/qt-models/divelistmodel.h
index 8f52680a4..675619640 100644
--- a/qt-models/divelistmodel.h
+++ b/qt-models/divelistmodel.h
@@ -2,11 +2,22 @@
#define DIVELISTMODEL_H
#include <QAbstractListModel>
+#include <QSortFilterProxyModel>
#include "dive.h"
#include "helpers.h"
#include "subsurface-qt/DiveObjectHelper.h"
+class DiveListSortModel : public QSortFilterProxyModel
+{
+ Q_OBJECT
+public:
+ DiveListSortModel(QObject *parent = 0);
+public slots:
+ int getDiveId(int idx);
+ int getIdxForId(int id);
+};
+
class DiveListModel : public QAbstractListModel
{
Q_OBJECT
@@ -25,6 +36,7 @@ public:
void updateDive(int i, dive *d);
void clear();
int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int getDiveId(int idx) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
QHash<int, QByteArray> roleNames() const;
QString startAddDive();