core: convert taxonomy.c to C++

Since the taxonomy is now a real C++ struct with constructor
and destructor, dive_site has to be converted to C++ as well.

A bit hairy for now, but will ultimately be distinctly simpler.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-05-04 13:39:04 +02:00 committed by bstoeger
parent 3c1401785b
commit 3f8b4604be
39 changed files with 259 additions and 336 deletions

View file

@ -63,7 +63,7 @@ QVariant DivesiteImportedModel::data(const QModelIndex &index, int role) const
case LOCATION:
return printGPSCoords(&ds->location);
case COUNTRY:
return taxonomy_get_country(&ds->taxonomy);
return QString::fromStdString(taxonomy_get_country(ds->taxonomy));
case NEAREST: {
// 40075000 is circumference of the earth in meters
struct dive_site *nearest_ds =

View file

@ -351,7 +351,7 @@ QVariant DiveTripModelBase::diveData(const struct dive *d, int column, int role)
case PHOTOS:
break;
case COUNTRY:
return QString(get_dive_country(d));
return QString::fromStdString(get_dive_country(d));
case BUDDIES:
return QString(d->buddy);
case DIVEGUIDE:
@ -1770,7 +1770,7 @@ bool DiveTripModelList::lessThan(const QModelIndex &i1, const QModelIndex &i2) c
case PHOTOS:
return lessThanHelper(countPhotos(d1) - countPhotos(d2), row_diff);
case COUNTRY:
return lessThanHelper(strCmp(get_dive_country(d1), get_dive_country(d2)), row_diff);
return lessThanHelper(strCmp(get_dive_country(d1).c_str(), get_dive_country(d2).c_str()), row_diff);
case BUDDIES:
return lessThanHelper(strCmp(d1->buddy, d2->buddy), row_diff);
case DIVEGUIDE: