subsurface/qthelper.h
Dirk Hohndel 9405895285 Improve GPS string handling
This adds support for two more GPS coordinate formats and also fixes a
couple of issues with the previous implementation.

We used to only support full degrees and decimal minutes. We now also
support fully decimal and degrees, minutes and decimal seconds.

The previous implementation would color the input field red if either it
couldn't parse the string, or if it was able to parse it but it was the
same as the previous location. That's misleading.

The previous implementation also changed all gps coordinates to the new
coordinates in a multi-dive edit - instead of just changing the ones that
are the same as the master dive.

Fixes #387

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-23 14:59:38 -08:00

45 lines
1.4 KiB
C++

#ifndef QTHELPER_H
#define QTHELPER_H
#include <QMultiMap>
#include <QString>
#include <stdint.h>
#include "dive.h"
#include "divelist.h"
#include <QTranslator>
// global pointers for our translation
extern QTranslator *qtTranslator, *ssrfTranslator;
class DiveComputerNode {
public:
DiveComputerNode(QString m, uint32_t d, QString s, QString f, QString n) : model(m), deviceId(d), serialNumber(s), firmware(f), nickName(n) {};
bool operator ==(const DiveComputerNode &a) const;
bool operator !=(const DiveComputerNode &a) const;
bool changesValues(const DiveComputerNode &b) const;
QString model;
uint32_t deviceId;
QString serialNumber;
QString firmware;
QString nickName;
};
class DiveComputerList {
public:
DiveComputerList();
~DiveComputerList();
const DiveComputerNode *getExact(QString m, uint32_t d);
const DiveComputerNode *get(QString m);
void addDC(QString m, uint32_t d, QString n = "", QString s = "", QString f = "");
void rmDC(QString m, uint32_t d);
DiveComputerNode matchDC(QString m, uint32_t d);
DiveComputerNode matchModel(QString m);
QMultiMap<QString, class DiveComputerNode> dcMap;
QMultiMap<QString, class DiveComputerNode> dcWorkingMap;
};
QString weight_string(int weight_in_grams);
bool gpsHasChanged(struct dive* dive, struct dive *master, const QString &gps_text, bool *parsed);
QList<int> getDivesInTrip(dive_trip_t *trip);
#endif // QTHELPER_H