2017-04-27 20:25:32 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2015-05-29 21:19:44 -03:00
|
|
|
#ifndef DIVELOCATIONMODEL_H
|
|
|
|
#define DIVELOCATIONMODEL_H
|
|
|
|
|
2015-07-01 18:46:27 -03:00
|
|
|
#include <QAbstractTableModel>
|
2015-06-22 17:24:15 -03:00
|
|
|
#include <QStringListModel>
|
2018-10-08 19:29:47 +02:00
|
|
|
#include <QSortFilterProxyModel>
|
2015-06-01 13:54:13 -07:00
|
|
|
#include <stdint.h>
|
2016-04-04 22:02:03 -07:00
|
|
|
#include "core/units.h"
|
2015-08-31 20:37:49 -03:00
|
|
|
|
2015-08-25 21:03:20 -03:00
|
|
|
#define RECENTLY_ADDED_DIVESITE 1
|
|
|
|
|
2015-07-01 18:46:27 -03:00
|
|
|
class LocationInformationModel : public QAbstractTableModel {
|
2015-05-29 21:19:44 -03:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2018-10-09 12:26:58 +02:00
|
|
|
// Common columns, roles and accessor function for all dive-site models.
|
|
|
|
// Thus, different views can connect to different models.
|
2015-07-01 18:46:27 -03:00
|
|
|
enum Columns { UUID, NAME, LATITUDE, LONGITUDE, COORDS, DESCRIPTION, NOTES, TAXONOMY_1, TAXONOMY_2, TAXONOMY_3, COLUMNS};
|
2015-08-31 21:35:17 -03:00
|
|
|
enum Roles { UUID_ROLE = Qt::UserRole + 1 };
|
2018-10-09 12:26:58 +02:00
|
|
|
static QVariant getDiveSiteData(const struct dive_site *ds, int column, int role);
|
|
|
|
|
|
|
|
LocationInformationModel(QObject *obj = 0);
|
2015-05-29 22:22:24 -03:00
|
|
|
static LocationInformationModel *instance();
|
2015-07-01 18:46:27 -03:00
|
|
|
int columnCount(const QModelIndex &parent) const;
|
2015-05-29 21:19:44 -03:00
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
|
|
|
QVariant data(const QModelIndex &index = QModelIndex(), int role = Qt::DisplayRole) const;
|
2015-06-01 23:13:51 -03:00
|
|
|
bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
|
|
|
|
|
2015-05-29 22:22:24 -03:00
|
|
|
public slots:
|
2015-05-29 21:19:44 -03:00
|
|
|
void update();
|
2018-01-28 15:21:28 +01:00
|
|
|
QStringList allSiteNames() const;
|
2015-05-29 21:19:44 -03:00
|
|
|
private:
|
2018-01-28 15:21:28 +01:00
|
|
|
QStringList locationNames;
|
2015-05-29 21:19:44 -03:00
|
|
|
};
|
|
|
|
|
2018-10-08 19:01:45 +02:00
|
|
|
// To access only divesites at the given GPS coordinates with the exception of a given dive site
|
|
|
|
class GPSLocationInformationModel : public QSortFilterProxyModel {
|
|
|
|
Q_OBJECT
|
|
|
|
private:
|
|
|
|
uint32_t ignoreUuid;
|
2018-10-20 14:12:15 -04:00
|
|
|
location_t location;
|
2018-10-08 19:01:45 +02:00
|
|
|
bool filterAcceptsRow(int sourceRow, const QModelIndex &source_parent) const override;
|
|
|
|
public:
|
|
|
|
GPSLocationInformationModel(QObject *parent = nullptr);
|
2018-10-20 14:12:15 -04:00
|
|
|
void set(uint32_t ignoreUuid, const location_t &);
|
|
|
|
void setCoordinates(const location_t &);
|
2018-10-08 19:01:45 +02:00
|
|
|
};
|
|
|
|
|
2015-06-22 17:24:15 -03:00
|
|
|
class GeoReferencingOptionsModel : public QStringListModel {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
static GeoReferencingOptionsModel *instance();
|
|
|
|
private:
|
|
|
|
GeoReferencingOptionsModel(QObject *parent = 0);
|
|
|
|
};
|
|
|
|
|
2015-05-29 21:19:44 -03:00
|
|
|
#endif
|