mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	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>
This commit is contained in:
		
							parent
							
								
									edf4fbd38a
								
							
						
					
					
						commit
						bea552bf0d
					
				
					 8 changed files with 0 additions and 126 deletions
				
			
		|  | @ -152,7 +152,6 @@ SOURCES += subsurface-mobile-main.cpp \ | |||
| 	mobile-widgets/themeinterface.cpp \ | ||||
| 	qt-models/divesummarymodel.cpp \ | ||||
| 	qt-models/diveplotdatamodel.cpp \ | ||||
| 	qt-models/gpslistmodel.cpp \ | ||||
| 	qt-models/completionmodels.cpp \ | ||||
| 	qt-models/divelocationmodel.cpp \ | ||||
| 	qt-models/maplocationmodel.cpp \ | ||||
|  | @ -311,7 +310,6 @@ HEADERS += \ | |||
| 	map-widget/qmlmapwidgethelper.h \ | ||||
| 	qt-models/divesummarymodel.h \ | ||||
| 	qt-models/diveplotdatamodel.h \ | ||||
| 	qt-models/gpslistmodel.h \ | ||||
| 	qt-models/divelocationmodel.h \ | ||||
| 	qt-models/completionmodels.h \ | ||||
| 	qt-models/weightsysteminfomodel.h \ | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
| #include "core/gpslocation.h" | ||||
| #include "core/divesite.h" | ||||
| #include "core/dive.h" | ||||
| #include "qt-models/gpslistmodel.h" | ||||
| #include "core/pref.h" | ||||
| #include "core/qthelper.h" | ||||
| #include "core/errorhelper.h" | ||||
|  |  | |||
|  | @ -20,7 +20,6 @@ | |||
| 
 | ||||
| #include <QBluetoothLocalDevice> | ||||
| 
 | ||||
| #include "qt-models/gpslistmodel.h" | ||||
| #include "qt-models/completionmodels.h" | ||||
| #include "qt-models/messagehandlermodel.h" | ||||
| #include "qt-models/tankinfomodel.h" | ||||
|  | @ -1684,22 +1683,14 @@ void QMLManager::applyGpsData() | |||
| 		changesNeedSaving(); | ||||
| } | ||||
| 
 | ||||
| void QMLManager::populateGpsData() | ||||
| { | ||||
| 	if (GpsListModel::instance()) | ||||
| 		GpsListModel::instance()->update(); | ||||
| } | ||||
| 
 | ||||
| void QMLManager::clearGpsData() | ||||
| { | ||||
| 	GpsLocation::instance()->clearGpsData(); | ||||
| 	populateGpsData(); | ||||
| } | ||||
| 
 | ||||
| void QMLManager::deleteGpsFix(quint64 when) | ||||
| { | ||||
| 	GpsLocation::instance()->deleteGpsFix(when); | ||||
| 	populateGpsData(); | ||||
| } | ||||
| 
 | ||||
| QString QMLManager::logText() const | ||||
|  |  | |||
|  | @ -214,7 +214,6 @@ public slots: | |||
| 	void redo(); | ||||
| 	int addDive(); | ||||
| 	void applyGpsData(); | ||||
| 	void populateGpsData(); | ||||
| 	void cancelDownloadDC(); | ||||
| 	void clearGpsData(); | ||||
| 	QString getCombinedLogs(); | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
|  | @ -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; | ||||
| } | ||||
|  | @ -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
 | ||||
|  | @ -19,7 +19,6 @@ | |||
| #include "mobile-widgets/statsmanager.h" | ||||
| #include "stats/chartlistmodel.h" | ||||
| #include "qt-models/divesummarymodel.h" | ||||
| #include "qt-models/gpslistmodel.h" | ||||
| #include "qt-models/messagehandlermodel.h" | ||||
| #include "qt-models/mobilelistmodel.h" | ||||
| #include "profile-widget/qmlprofile.h" | ||||
|  | @ -116,12 +115,6 @@ void run_mobile_ui(double initial_font_size) | |||
| 	// this is frustrating, but we appear to need different import paths on different OSs
 | ||||
| 	engine.addImportPath(":"); | ||||
| 	engine.addImportPath("qrc://imports"); | ||||
| 	QSortFilterProxyModel *gpsSortModel = new QSortFilterProxyModel(nullptr); | ||||
| 	gpsSortModel->setSourceModel(GpsListModel::instance()); | ||||
| 	gpsSortModel->setDynamicSortFilter(true); | ||||
| 	gpsSortModel->setSortRole(GpsListModel::GpsWhenRole); | ||||
| 	gpsSortModel->sort(0, Qt::DescendingOrder); | ||||
| 	ctxt->setContextProperty("gpsModel", gpsSortModel); | ||||
| 	ctxt->setContextProperty("vendorList", vendorList); | ||||
| 	ctxt->setContextProperty("swipeModel", MobileModels::instance()->swipeModel()); | ||||
| 	ctxt->setContextProperty("diveModel", MobileModels::instance()->listModel()); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue