summaryrefslogtreecommitdiffstats
path: root/qt-models/divelistmodel.h
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2016-01-07 16:01:24 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-01-08 08:04:44 -0800
commit25aa80846b84c0b3cd3e0b0256a046e1e92fb1db (patch)
treec9934f39f2e039e5877af7ee0d3b0d96c5a1debf /qt-models/divelistmodel.h
parentc022f5c4f71f3e7670ed458d714d96fd6e88c55b (diff)
downloadsubsurface-25aa80846b84c0b3cd3e0b0256a046e1e92fb1db.tar.gz
Move Dive class from qthelper.h/cpp to it's own file
and rename it to DiveObjectHelper, since it should be an QObject based class to make it easier on the QML, grantlee and widgets side to display the dive's internal data. each Q_PROPERTY defined in the DiveObjectHelper.h file can be acessed directly via it's name. So, if you are on a model that returns a dive, acess it's name by dive.name Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-models/divelistmodel.h')
-rw-r--r--qt-models/divelistmodel.h27
1 files changed, 6 insertions, 21 deletions
diff --git a/qt-models/divelistmodel.h b/qt-models/divelistmodel.h
index f050faab3..5265cd1b0 100644
--- a/qt-models/divelistmodel.h
+++ b/qt-models/divelistmodel.h
@@ -2,8 +2,10 @@
#define DIVELISTMODEL_H
#include <QAbstractListModel>
+
#include "dive.h"
#include "helpers.h"
+#include "subsurface-qt/DiveObjectHelper.h"
class DiveListModel : public QAbstractListModel
{
@@ -11,26 +13,8 @@ class DiveListModel : public QAbstractListModel
public:
enum DiveListRoles {
- DiveNumberRole = Qt::UserRole + 1,
- DiveTripRole,
- DiveDateRole,
- DiveDateStringRole,
- DiveRatingRole,
- DiveDepthRole,
- DiveDurationRole,
- DiveWaterTemperatureRole,
- DiveAirTemperatureRole,
- DiveWeightRole,
- DiveSuitRole,
- DiveCylinderRole,
- DiveGasRole,
- DiveSacRole,
- DiveLocationRole,
- DiveGPSRole,
- DiveNotesRole,
- DiveBuddyRole,
- DiveMasterRole,
- DiveIdRole
+ DiveRole = Qt::UserRole + 1,
+ DiveDateRole
};
static DiveListModel *instance();
@@ -42,8 +26,9 @@ public:
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
QHash<int, QByteArray> roleNames() const;
QString startAddDive();
+ Q_INVOKABLE DiveObjectHelper* at(int i);
private:
- QList<Dive> m_dives;
+ QList<DiveObjectHelper*> m_dives;
static DiveListModel *m_instance;
};