core: remove accessor get_dive_site_for_dive()

This function does nothing at all, callers may just access
dive::dive_site directly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-06-30 18:36:29 +02:00 committed by bstoeger
parent 718523e01d
commit 731052c776
10 changed files with 11 additions and 17 deletions

View file

@ -2496,11 +2496,6 @@ depth_t dive::gas_mnd(struct gasmix mix, depth_t end, int roundto) const
return depth_t { (int)lrint(((double)mbar_to_depth(maxambient)) / roundto) * roundto };
}
struct dive_site *get_dive_site_for_dive(const struct dive *dive)
{
return dive->dive_site;
}
std::string get_dive_country(const struct dive *dive)
{
struct dive_site *ds = dive->dive_site;

View file

@ -160,7 +160,6 @@ struct dive_components {
extern fraction_t best_o2(depth_t depth, const struct dive *dive, bool in_planner);
extern fraction_t best_he(depth_t depth, const struct dive *dive, bool o2narcotic, fraction_t fo2);
extern struct dive_site *get_dive_site_for_dive(const struct dive *dive);
extern std::string get_dive_country(const struct dive *dive);
extern std::string get_dive_location(const struct dive *dive);
extern struct divecomputer *get_dive_dc(struct dive *dive, int nr);

View file

@ -172,7 +172,7 @@ static int get_hex(const char *line)
static void parse_dive_gps(char *line, struct git_parser_state *state)
{
location_t location;
struct dive_site *ds = get_dive_site_for_dive(state->active_dive.get());
struct dive_site *ds = state->active_dive->dive_site;
parse_location(line, &location);
if (!ds) {
@ -211,7 +211,7 @@ static std::string get_first_converted_string(struct git_parser_state *state)
static void parse_dive_location(char *, struct git_parser_state *state)
{
std::string name = get_first_converted_string(state);
struct dive_site *ds = get_dive_site_for_dive(state->active_dive.get());
struct dive_site *ds = state->active_dive->dive_site;
if (!ds) {
ds = state->log->sites.get_by_name(name);
if (!ds)

View file

@ -1144,7 +1144,7 @@ static void gps_lat(const char *buffer, struct dive *dive, struct parser_state *
{
const char *end;
location_t location = { };
struct dive_site *ds = get_dive_site_for_dive(dive);
struct dive_site *ds = dive->dive_site;
location.lat = parse_degrees(buffer, &end);
if (!ds) {
@ -1161,7 +1161,7 @@ static void gps_long(const char *buffer, struct dive *dive, struct parser_state
{
const char *end;
location_t location = { };
struct dive_site *ds = get_dive_site_for_dive(dive);
struct dive_site *ds = dive->dive_site;
location.lon = parse_degrees(buffer, &end);
if (!ds) {

View file

@ -190,7 +190,7 @@ static void put_HTML_samples(struct membuffer *b, const struct dive &dive)
static void put_HTML_coordinates(struct membuffer *b, const struct dive &dive)
{
struct dive_site *ds = get_dive_site_for_dive(&dive);
struct dive_site *ds = dive.dive_site;
if (!ds)
return;
degrees_t latitude = ds->location.lat;

View file

@ -35,7 +35,7 @@ static void writeMarkers(struct membuffer *b, bool selected_only)
for (auto &dive: divelog.dives) {
if (selected_only && !dive->selected)
continue;
struct dive_site *ds = get_dive_site_for_dive(dive.get());
struct dive_site *ds = dive->dive_site;
if (!ds || !ds->has_gps_location())
continue;
put_degrees(b, ds->location.lat, "temp = new google.maps.Marker({position: new google.maps.LatLng(", "");

View file

@ -666,7 +666,7 @@ void DiveLocationLineEdit::setCurrentDiveSite(struct dive *d)
{
location_t currentLocation;
if (d) {
currDs = get_dive_site_for_dive(d);
currDs = d->dive_site;
currentLocation = d->get_gps_location();
} else {
currDs = nullptr;

View file

@ -286,7 +286,7 @@ void MainWindow::editDiveSite(dive_site *ds)
void MainWindow::startDiveSiteEdit()
{
if (current_dive)
editDiveSite(get_dive_site_for_dive(current_dive));
editDiveSite(current_dive->dive_site);
}
void MainWindow::enableDisableCloudActions()

View file

@ -135,7 +135,7 @@ void MapWidgetHelper::selectedLocationChanged(struct dive_site *ds_in)
QGeoCoordinate locationCoord = location->coordinate;
for (auto [idx, dive]: enumerated_range(divelog.dives)) {
struct dive_site *ds = get_dive_site_for_dive(dive.get());
struct dive_site *ds = dive->dive_site;
if (!ds || !ds->has_gps_location())
continue;
#ifndef SUBSURFACE_MOBILE
@ -163,7 +163,7 @@ void MapWidgetHelper::selectVisibleLocations()
{
QList<int> selectedDiveIds;
for (auto [idx, dive]: enumerated_range(divelog.dives)) {
struct dive_site *ds = get_dive_site_for_dive(dive.get());
struct dive_site *ds = dive->dive_site;
if (!ds || ds->has_gps_location())
continue;
const qreal latitude = ds->location.lat.udeg * 0.000001;

View file

@ -1064,7 +1064,7 @@ parsed:
bool QMLManager::checkLocation(DiveSiteChange &res, struct dive *d, QString location, QString gps)
{
struct dive_site *ds = get_dive_site_for_dive(d);
struct dive_site *ds = d->dive_site;
bool changed = false;
QString oldLocation = QString::fromStdString(get_dive_location(d));
if (oldLocation != location) {