core: move dive-site-table functions into class

There were a number of free standing functions acting on a
dive-site-table. Make them member functions. This allows
for shorter names. Use the get_idx() function of the base
class, which returns a size_t instead of an int (since that
is what the standard, somewhat unfortunately, uses).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-05-11 14:22:33 +02:00 committed by bstoeger
parent 6b835710bc
commit 76c52c87a3
19 changed files with 87 additions and 99 deletions

View file

@ -1069,7 +1069,7 @@ bool QMLManager::checkLocation(DiveSiteChange &res, struct dive *d, QString loca
bool changed = false;
QString oldLocation = QString::fromStdString(get_dive_location(d));
if (oldLocation != location) {
ds = get_dive_site_by_name(location.toStdString(), *divelog.sites);
ds = divelog.sites->get_by_name(location.toStdString());
if (!ds && !location.isEmpty()) {
res.createdDs = std::make_unique<dive_site>(qPrintable(location));
res.changed = true;
@ -1816,7 +1816,7 @@ QString QMLManager::getVersion() const
QString QMLManager::getGpsFromSiteName(const QString &siteName)
{
struct dive_site *ds = get_dive_site_by_name(siteName.toStdString(), *divelog.sites);
struct dive_site *ds = divelog.sites->get_by_name(siteName.toStdString());
if (!ds)
return QString();
return printGPSCoords(&ds->location);