summaryrefslogtreecommitdiffstats
path: root/qt-models/gpslistmodel.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2016-01-08 13:11:49 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-01-08 08:04:04 -0800
commit89eed5d36e611f882dbf1e2686ad389f65688fa1 (patch)
treeb7e185df6424d46c9d992ea388a03d4a6b19fd7e /qt-models/gpslistmodel.cpp
parent7b155774c5105f84303e869317fc946b11b3e78b (diff)
downloadsubsurface-89eed5d36e611f882dbf1e2686ad389f65688fa1.tar.gz
Untangle Library Linkage
with the adittion of gpslistmodel/location, the libraries qt-models had a direct dependency on subsurface-core, and subsurface-core had a direct dependency on qt-models, this is bad. Moving a bit of code around I'v managed to clean this out, and also to clear a bit of uneeded code (GpsTracker and gpsTracker where basically the same thing.) Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-models/gpslistmodel.cpp')
-rw-r--r--qt-models/gpslistmodel.cpp54
1 files changed, 15 insertions, 39 deletions
diff --git a/qt-models/gpslistmodel.cpp b/qt-models/gpslistmodel.cpp
index 6bd1cfdf0..2c6fe6b5c 100644
--- a/qt-models/gpslistmodel.cpp
+++ b/qt-models/gpslistmodel.cpp
@@ -1,38 +1,6 @@
#include "gpslistmodel.h"
#include "helpers.h"
-GpsTracker::GpsTracker()
-{
- m_latitude = 0;
- m_longitude = 0;
- m_when = 0;
- m_name = QString();
-}
-
-GpsTracker::~GpsTracker()
-{
-}
-
-uint64_t GpsTracker::when() const
-{
- return m_when;
-}
-
-int32_t GpsTracker::latitude() const
-{
- return m_latitude;
-}
-
-int32_t GpsTracker::longitude() const
-{
- return m_longitude;
-}
-
-QString GpsTracker::name() const
-{
- return m_name;
-}
-
GpsListModel *GpsListModel::m_instance = NULL;
GpsListModel::GpsListModel(QObject *parent) : QAbstractListModel(parent)
@@ -40,13 +8,21 @@ GpsListModel::GpsListModel(QObject *parent) : QAbstractListModel(parent)
m_instance = this;
}
-void GpsListModel::addGpsFix(gpsTracker *g)
+void GpsListModel::addGpsFix(gpsTracker g)
{
beginInsertColumns(QModelIndex(), rowCount(), rowCount());
- m_gpsFixes.append(GpsTracker(g));
+ m_gpsFixes.append(g);
endInsertRows();
}
+void GpsListModel::update()
+{
+ QVector<gpsTracker> trackers = GpsLocation::instance()->currentGPSInfo();
+ beginResetModel();
+ m_gpsFixes = trackers;
+ endResetModel();
+}
+
void GpsListModel::clear()
{
if (m_gpsFixes.count()) {
@@ -66,16 +42,16 @@ QVariant GpsListModel::data(const QModelIndex &index, int role) const
if (index.row() < 0 || index.row() > m_gpsFixes.count())
return QVariant();
- const GpsTracker &gt = m_gpsFixes[index.row()];
+ const gpsTracker &gt = m_gpsFixes[index.row()];
if (role == GpsDateRole)
- return get_short_dive_date_string(gt.when());
+ return get_short_dive_date_string(gt.when);
else if (role == GpsNameRole)
- return QString(gt.name());
+ return gt.name;
else if (role == GpsLatitudeRole)
- return QString::number(gt.latitude() / 1000000.0, 'f', 6);
+ return QString::number(gt.latitude.udeg / 1000000.0, 'f', 6);
else if (role == GpsLongitudeRole)
- return QString::number(gt.longitude() / 1000000.0, 'f', 6);
+ return QString::number(gt.longitude.udeg / 1000000.0, 'f', 6);
return QVariant();
}