mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-27 20:58:47 +00:00
core: replace same_location by operator==()
And operator!=() in the negative case. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
2df30a4144
commit
db4b972897
8 changed files with 15 additions and 35 deletions
|
@ -281,7 +281,7 @@ bool EditDiveSiteLocation::workToBeDone()
|
|||
bool old_ok = has_location(&ds->location);
|
||||
if (ok != old_ok)
|
||||
return true;
|
||||
return ok && !same_location(&value, &ds->location);
|
||||
return ok && value != ds->location;
|
||||
}
|
||||
|
||||
void EditDiveSiteLocation::redo()
|
||||
|
|
|
@ -57,7 +57,7 @@ struct dive_site *get_dive_site_by_gps(const location_t *loc, struct dive_site_t
|
|||
int i;
|
||||
struct dive_site *ds;
|
||||
for_each_dive_site (i, ds, ds_table) {
|
||||
if (same_location(loc, &ds->location))
|
||||
if (*loc == ds->location)
|
||||
return ds;
|
||||
}
|
||||
return NULL;
|
||||
|
@ -71,7 +71,7 @@ struct dive_site *get_dive_site_by_gps_and_name(const std::string &name, const l
|
|||
int i;
|
||||
struct dive_site *ds;
|
||||
for_each_dive_site (i, ds, ds_table) {
|
||||
if (same_location(loc, &ds->location) && ds->name == name)
|
||||
if (*loc == ds->location && ds->name == name)
|
||||
return ds;
|
||||
}
|
||||
return NULL;
|
||||
|
@ -273,7 +273,7 @@ static void merge_string(std::string &a, const std::string &b)
|
|||
static bool same_dive_site(const struct dive_site *a, const struct dive_site *b)
|
||||
{
|
||||
return a->name == b->name
|
||||
&& same_location(&a->location, &b->location)
|
||||
&& a->location == b->location
|
||||
&& a->description == b->description
|
||||
&& a->notes == b->notes;
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ static void parse_dive_gps(char *line, struct git_parser_state *state)
|
|||
ds = create_dive_site_with_gps(std::string(), &location, state->log->sites);
|
||||
add_dive_to_dive_site(state->active_dive, ds);
|
||||
} else {
|
||||
if (dive_site_has_gps_location(ds) && !same_location(&ds->location, &location)) {
|
||||
if (dive_site_has_gps_location(ds) && ds->location != location) {
|
||||
std::string coords = printGPSCoordsC(&location);
|
||||
// we have a dive site that already has GPS coordinates
|
||||
// note 1: there will be much less copying once the core
|
||||
|
|
|
@ -1209,7 +1209,7 @@ static void gps_in_dive(const char *buffer, struct dive *dive, struct parser_sta
|
|||
add_dive_to_dive_site(dive, ds);
|
||||
} else {
|
||||
if (dive_site_has_gps_location(ds) &&
|
||||
has_location(&location) && !same_location(&ds->location, &location)) {
|
||||
has_location(&location) && ds->location != location) {
|
||||
// Houston, we have a problem
|
||||
report_info("dive site uuid in dive, but gps location (%10.6f/%10.6f) different from dive location (%10.6f/%10.6f)",
|
||||
ds->location.lat.udeg / 1000000.0, ds->location.lon.udeg / 1000000.0,
|
||||
|
|
|
@ -268,31 +268,6 @@ bool parseGpsText(const QString &gps_text, double *latitude, double *longitude)
|
|||
pos == normalized.size();
|
||||
}
|
||||
|
||||
#if 0 // we'll need something like this for the dive site management, eventually
|
||||
bool gpsHasChanged(struct dive *dive, struct dive *master, const QString &gps_text, bool *parsed_out)
|
||||
{
|
||||
location_t location;
|
||||
bool ignore;
|
||||
bool *parsed = parsed_out ?: &ignore;
|
||||
*parsed = true;
|
||||
|
||||
/* if we have a master and the dive's gps address is different from it,
|
||||
* don't change the dive */
|
||||
if (master && !same_location(&master->location, &dive->location))
|
||||
return false;
|
||||
|
||||
if (!(*parsed = parseGpsText(gps_text, location)))
|
||||
return false;
|
||||
|
||||
/* if dive gps didn't change, nothing changed */
|
||||
if (same_location(&dive->location, location))
|
||||
return false;
|
||||
/* ok, update the dive and mark things changed */
|
||||
dive->location = location;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
static xmlDocPtr get_stylesheet_doc(const xmlChar *uri, xmlDictPtr, int, void *, xsltLoadType)
|
||||
{
|
||||
std::string filename = std::string(":/xslt/") + (const char *)uri;
|
||||
|
|
|
@ -138,9 +138,14 @@ static inline bool has_location(const location_t *loc)
|
|||
return loc->lat.udeg || loc->lon.udeg;
|
||||
}
|
||||
|
||||
static inline bool same_location(const location_t *a, const location_t *b)
|
||||
static inline bool operator==(const location_t &a, const location_t &b)
|
||||
{
|
||||
return (a->lat.udeg == b->lat.udeg) && (a->lon.udeg == b->lon.udeg);
|
||||
return (a.lat.udeg == b.lat.udeg) && (a.lon.udeg == b.lon.udeg);
|
||||
}
|
||||
|
||||
static inline bool operator!=(const location_t &a, const location_t &b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
static inline location_t create_location(double lat, double lon)
|
||||
|
|
|
@ -475,7 +475,7 @@ void LocationFilterDelegate::paint(QPainter *painter, const QStyleOptionViewItem
|
|||
if (dive_site_has_gps_location(ds) && currentDiveHasGPS) {
|
||||
// so we are showing a completion and both the current dive site and the completion
|
||||
// have a GPS fix... so let's show the distance
|
||||
if (same_location(&ds->location, ¤tLocation)) {
|
||||
if (ds->location == currentLocation) {
|
||||
bottomText += tr(" (same GPS fix)");
|
||||
} else {
|
||||
int distanceMeters = get_distance(&ds->location, ¤tLocation);
|
||||
|
|
|
@ -294,7 +294,7 @@ bool GPSLocationInformationModel::filterAcceptsRow(int sourceRow, const QModelIn
|
|||
if (!ds || ds == ignoreDs || ds == RECENTLY_ADDED_DIVESITE || !has_location(&ds->location))
|
||||
return false;
|
||||
|
||||
return distance <= 0 ? same_location(&ds->location, &location)
|
||||
return distance <= 0 ? ds->location == location
|
||||
: (int64_t)get_distance(&ds->location, &location) * 1000 <= distance; // We need 64 bit to represent distances in mm
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue