summaryrefslogtreecommitdiffstats
path: root/qt-models/gpslistmodel.h
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2016-01-07 21:43:22 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-01-07 21:43:22 -0800
commit1eda61e1158de19a47acdfc5525f5f0df002052f (patch)
treefd981938b70fe20c20b3ea2ffc90abd9db74de9a /qt-models/gpslistmodel.h
parentce3a78efcac2c9b6bd215bc191560a64c54fd628 (diff)
parentb6ae6979e530fa32dbdb472a2e9698cb719945a8 (diff)
downloadsubsurface-1eda61e1158de19a47acdfc5525f5f0df002052f.tar.gz
Merge branch 'gpsList'
Diffstat (limited to 'qt-models/gpslistmodel.h')
-rw-r--r--qt-models/gpslistmodel.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/qt-models/gpslistmodel.h b/qt-models/gpslistmodel.h
new file mode 100644
index 000000000..35a5a03c4
--- /dev/null
+++ b/qt-models/gpslistmodel.h
@@ -0,0 +1,57 @@
+#ifndef GPSLISTMODEL_H
+#define GPSLISTMODEL_H
+
+#include "gpslocation.h"
+#include <QObject>
+#include <QAbstractListModel>
+
+class GpsTracker
+{
+private:
+ quint64 m_when;
+ qint32 m_latitude;
+ qint32 m_longitude;
+ QString m_name;
+
+public:
+ GpsTracker(struct gpsTracker *gt)
+ {
+ m_when = gt->when;
+ m_latitude = gt->latitude.udeg;
+ m_longitude = gt->longitude.udeg;
+ m_name = gt->name;
+ }
+ GpsTracker();
+ ~GpsTracker();
+ uint64_t when() const;
+ int32_t latitude() const;
+ int32_t longitude() const;
+ QString name() const;
+};
+
+class GpsListModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+
+ enum GpsListRoles {
+ GpsDateRole = Qt::UserRole + 1,
+ GpsNameRole,
+ GpsLatitudeRole,
+ GpsLongitudeRole
+ };
+
+ static GpsListModel *instance();
+ GpsListModel(QObject *parent = 0);
+ void addGpsFix(struct gpsTracker *g);
+ void clear();
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ QHash<int, QByteArray> roleNames() const;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+
+private:
+ QList<GpsTracker> m_gpsFixes;
+ static GpsListModel *m_instance;
+};
+
+#endif // GPSLISTMODEL_H