diff options
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/divelocationmodel.cpp | 16 | ||||
-rw-r--r-- | qt-models/divelocationmodel.h | 8 |
2 files changed, 12 insertions, 12 deletions
diff --git a/qt-models/divelocationmodel.cpp b/qt-models/divelocationmodel.cpp index c1a7308f4..18be89806 100644 --- a/qt-models/divelocationmodel.cpp +++ b/qt-models/divelocationmodel.cpp @@ -41,7 +41,7 @@ QVariant LocationInformationModel::getDiveSiteData(const struct dive_site *ds, i case Qt::EditRole: case Qt::DisplayRole : switch(column) { - case UUID: return ds->uuid; + case DIVESITE: return QVariant::fromValue<void*>((void *)ds); // Not nice: casting away const case NAME: return ds->name; case LATITUDE: return ds->location.lat.udeg; case LONGITUDE: return ds->location.lon.udeg; @@ -102,7 +102,8 @@ bool LocationInformationModel::removeRows(int row, int, const QModelIndex&) return true; } -GeoReferencingOptionsModel *GeoReferencingOptionsModel::instance() { +GeoReferencingOptionsModel *GeoReferencingOptionsModel::instance() +{ static GeoReferencingOptionsModel *self = new GeoReferencingOptionsModel(); return self; } @@ -118,24 +119,23 @@ GeoReferencingOptionsModel::GeoReferencingOptionsModel(QObject *parent) : QStrin bool GPSLocationInformationModel::filterAcceptsRow(int sourceRow, const QModelIndex &parent) const { - uint32_t uuid = sourceModel()->index(sourceRow, LocationInformationModel::UUID, parent).data().toUInt(); - if (uuid == ignoreUuid || uuid == RECENTLY_ADDED_DIVESITE) + struct dive_site *ds = (struct dive_site *)sourceModel()->index(sourceRow, LocationInformationModel::DIVESITE, parent).data().value<void *>(); + if (ds == ignoreDs || ds == RECENTLY_ADDED_DIVESITE) return false; - struct dive_site *ds = get_dive_site_by_uuid(uuid); return ds && same_location(&ds->location, &location); } GPSLocationInformationModel::GPSLocationInformationModel(QObject *parent) : QSortFilterProxyModel(parent), - ignoreUuid(0), + ignoreDs(nullptr), location({{0},{0}}) { setSourceModel(LocationInformationModel::instance()); } -void GPSLocationInformationModel::set(uint32_t ignoreUuidIn, const location_t &locationIn) +void GPSLocationInformationModel::set(const struct dive_site *ignoreDsIn, const location_t &locationIn) { - ignoreUuid = ignoreUuidIn; + ignoreDs = ignoreDsIn; location = locationIn; invalidate(); } diff --git a/qt-models/divelocationmodel.h b/qt-models/divelocationmodel.h index 5f95d5975..407031590 100644 --- a/qt-models/divelocationmodel.h +++ b/qt-models/divelocationmodel.h @@ -8,14 +8,14 @@ #include <stdint.h> #include "core/units.h" -#define RECENTLY_ADDED_DIVESITE 1 +#define RECENTLY_ADDED_DIVESITE ((struct dive_site *)~0) class LocationInformationModel : public QAbstractTableModel { Q_OBJECT public: // Common columns, roles and accessor function for all dive-site models. // Thus, different views can connect to different models. - enum Columns { UUID, NAME, LATITUDE, LONGITUDE, COORDS, DESCRIPTION, NOTES, TAXONOMY_1, TAXONOMY_2, TAXONOMY_3, COLUMNS}; + enum Columns { DIVESITE, NAME, LATITUDE, LONGITUDE, COORDS, DESCRIPTION, NOTES, TAXONOMY_1, TAXONOMY_2, TAXONOMY_3, COLUMNS}; enum Roles { DIVESITE_ROLE = Qt::UserRole + 1 }; static QVariant getDiveSiteData(const struct dive_site *ds, int column, int role); @@ -37,12 +37,12 @@ private: class GPSLocationInformationModel : public QSortFilterProxyModel { Q_OBJECT private: - uint32_t ignoreUuid; + const struct dive_site *ignoreDs; location_t location; bool filterAcceptsRow(int sourceRow, const QModelIndex &source_parent) const override; public: GPSLocationInformationModel(QObject *parent = nullptr); - void set(uint32_t ignoreUuid, const location_t &); + void set(const struct dive_site *ignoreDs, const location_t &); void setCoordinates(const location_t &); }; |