diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2021-09-11 14:41:09 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-09-13 11:21:34 -0700 |
commit | bea552bf0d69e73be9a223369c72bcc122ddff08 (patch) | |
tree | 46d05ad06ceeb6fcb99cb67c10285a601c564776 /qt-models | |
parent | edf4fbd38afb6397bdee393dbf75acc317989be8 (diff) | |
download | subsurface-bea552bf0d69e73be9a223369c72bcc122ddff08.tar.gz |
mobile: remove GpsListModel
This is only needed to show the list of GPS fixes obtained with
the now removed location service.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/CMakeLists.txt | 2 | ||||
-rw-r--r-- | qt-models/gpslistmodel.cpp | 72 | ||||
-rw-r--r-- | qt-models/gpslistmodel.h | 32 |
3 files changed, 0 insertions, 106 deletions
diff --git a/qt-models/CMakeLists.txt b/qt-models/CMakeLists.txt index 3c1ded741..3210bac7c 100644 --- a/qt-models/CMakeLists.txt +++ b/qt-models/CMakeLists.txt @@ -55,8 +55,6 @@ set(SUBSURFACE_DESKTOP_MODELS_LIB_SRCS set(SUBSURFACE_MOBILE_MODELS_LIB_SRCS divesummarymodel.cpp divesummarymodel.h - gpslistmodel.cpp - gpslistmodel.h messagehandlermodel.cpp messagehandlermodel.h mobilelistmodel.cpp diff --git a/qt-models/gpslistmodel.cpp b/qt-models/gpslistmodel.cpp deleted file mode 100644 index 1cb6c8271..000000000 --- a/qt-models/gpslistmodel.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include "qt-models/gpslistmodel.h" -#include "core/subsurface-qt/divelistnotifier.h" -#include "core/qthelper.h" -#include <QVector> - -GpsListModel::GpsListModel() -{ - connect(&diveListNotifier, &DiveListNotifier::dataReset, this, &GpsListModel::update); -} - -void GpsListModel::update() -{ - GpsLocation *glp = GpsLocation::instance(); - if (!glp) - return; - QVector<gpsTracker> trackers = QVector<gpsTracker>::fromList(glp->currentGPSInfo().values()); - beginResetModel(); - m_gpsFixes = trackers; - endResetModel(); -} - -void GpsListModel::clear() -{ - if (m_gpsFixes.count()) { - beginRemoveRows(QModelIndex(), 0, m_gpsFixes.count() - 1); - m_gpsFixes.clear(); - endRemoveRows(); - } -} - -int GpsListModel::rowCount(const QModelIndex&) const -{ - return m_gpsFixes.count(); -} - -QVariant GpsListModel::data(const QModelIndex &index, int role) const -{ - if (index.row() < 0 || index.row() > m_gpsFixes.count()) - return QVariant(); - - const gpsTracker > = m_gpsFixes[index.row()]; - - if (role == GpsDateRole) - return get_short_dive_date_string(gt.when); - else if (role == GpsWhenRole) - return gt.when; - else if (role == GpsNameRole) - return gt.name; - else if (role == GpsLatitudeRole) - return QString::number(gt.location.lat.udeg / 1000000.0, 'f', 6); - else if (role == GpsLongitudeRole) - return QString::number(gt.location.lon.udeg / 1000000.0, 'f', 6); - return QVariant(); -} - -QHash<int, QByteArray> GpsListModel::roleNames() const -{ - QHash<int, QByteArray> roles; - roles[GpsDateRole] = "date"; - roles[GpsWhenRole] = "when"; - roles[GpsNameRole] = "name"; - roles[GpsLatitudeRole] = "latitude"; - roles[GpsLongitudeRole] = "longitude"; - return roles; -} - -GpsListModel *GpsListModel::instance() -{ - static GpsListModel self; - return &self; -} diff --git a/qt-models/gpslistmodel.h b/qt-models/gpslistmodel.h deleted file mode 100644 index bce84c985..000000000 --- a/qt-models/gpslistmodel.h +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#ifndef GPSLISTMODEL_H -#define GPSLISTMODEL_H - -#include "core/gpslocation.h" -#include <QObject> -#include <QAbstractListModel> - -class GpsListModel : public QAbstractListModel -{ - Q_OBJECT -public: - enum GpsListRoles { - GpsDateRole = Qt::UserRole + 1, - GpsNameRole, - GpsLatitudeRole, - GpsLongitudeRole, - GpsWhenRole - }; - - static GpsListModel *instance(); - void clear(); - int rowCount(const QModelIndex &parent = QModelIndex()) const; - QHash<int, QByteArray> roleNames() const; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - void update(); -private: - GpsListModel(); - QVector<gpsTracker> m_gpsFixes; -}; - -#endif // GPSLISTMODEL_H |