summaryrefslogtreecommitdiffstats
path: root/qt-models/divelistmodel.h
diff options
context:
space:
mode:
authorGravatar Grace Karanja <gracie.karanja89@gmail.com>2015-06-09 22:20:44 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-20 14:26:56 -0700
commitb7e4b35cde1f1a6be01818eac94732186a1b99ab (patch)
tree4dfa16a09d9e0ec8526d05ce1b4107b8c122d81e /qt-models/divelistmodel.h
parentbf882416f92fef648f8951a55b4b06dacf56bc3b (diff)
downloadsubsurface-b7e4b35cde1f1a6be01818eac94732186a1b99ab.tar.gz
Add DiveListModel
This model will be used to show the dives in QML. This commit adds the model, and the means to link it to QML. Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-models/divelistmodel.h')
-rw-r--r--qt-models/divelistmodel.h100
1 files changed, 100 insertions, 0 deletions
diff --git a/qt-models/divelistmodel.h b/qt-models/divelistmodel.h
new file mode 100644
index 000000000..96f16912a
--- /dev/null
+++ b/qt-models/divelistmodel.h
@@ -0,0 +1,100 @@
+#ifndef DIVELISTMODEL_H
+#define DIVELISTMODEL_H
+
+#include <QAbstractListModel>
+#include "dive.h"
+
+class Dive {
+public:
+ Dive(dive* d);
+
+ QString date() const;
+ void setDate(const QString &date);
+
+ QString location() const;
+ void setLocation(const QString &location);
+
+ QString sac() const;
+ void setSac(const QString &sac);
+
+ QString gas() const;
+ void setGas(const QString &gas);
+
+ QString cylinder() const;
+ void setCylinder(const QString &cylinder);
+
+ QString suit() const;
+ void setSuit(const QString &suit);
+
+ QString weight() const;
+ void setWeight(const QString &weight);
+
+ QString temp() const;
+ void setTemp(const QString &temp);
+
+ QString duration() const;
+ void setDuration(const QString &duration);
+
+ QString depth() const;
+ void setDepth(const QString &depth);
+
+ QString rating() const;
+ void setRating(const QString &rating);
+
+ dive *thisDive() const;
+ void setThisDive(dive *thisDive);
+
+ QString diveNumber() const;
+ void setDiveNumber(const QString &diveNumber);
+
+private:
+ QString m_diveNumber;
+ QString m_date;
+ QString m_rating;
+ QString m_depth;
+ QString m_duration;
+ QString m_temp;
+ QString m_weight;
+ QString m_suit;
+ QString m_cylinder;
+ QString m_gas;
+ QString m_sac;
+ QString m_location;
+
+
+ dive *m_thisDive;
+};
+
+class DiveListModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+
+ enum DiveListRoles {
+ DiveNumberRole = Qt::UserRole + 1,
+ DiveDateRole,
+ DiveRatingRole,
+ DiveDepthRole,
+ DiveDurationRole,
+ DiveTemperatureRole,
+ DiveWeightRole,
+ DiveSuitRole,
+ DiveCylinderRole,
+ DiveGasRole,
+ DiveSacRole,
+ DiveLocationRole
+ };
+
+ static DiveListModel *instance();
+ DiveListModel(QObject *parent = 0);
+ void addDive(dive *d);
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ QHash<int, QByteArray> roleNames() const;
+
+private:
+ QList<Dive> m_dives;
+ static DiveListModel *m_instance;
+};
+
+#endif // DIVELISTMODEL_H