mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
6b835710bc
commit
76c52c87a3
19 changed files with 87 additions and 99 deletions
|
@ -67,8 +67,7 @@ QVariant DivesiteImportedModel::data(const QModelIndex &index, int role) const
|
|||
case NEAREST: {
|
||||
// 40075000 is circumference of the earth in meters
|
||||
struct dive_site *nearest_ds =
|
||||
get_dive_site_by_gps_proximity(&ds->location,
|
||||
40075000, *divelog.sites);
|
||||
divelog.sites->get_by_gps_proximity(&ds->location, 40075000);
|
||||
if (nearest_ds)
|
||||
return QString::fromStdString(nearest_ds->name);
|
||||
else
|
||||
|
@ -77,8 +76,7 @@ QVariant DivesiteImportedModel::data(const QModelIndex &index, int role) const
|
|||
case DISTANCE: {
|
||||
unsigned int distance = 0;
|
||||
struct dive_site *nearest_ds =
|
||||
get_dive_site_by_gps_proximity(&ds->location,
|
||||
40075000, *divelog.sites);
|
||||
divelog.sites->get_by_gps_proximity(&ds->location, 40075000);
|
||||
if (nearest_ds)
|
||||
distance = get_distance(&ds->location,
|
||||
&nearest_ds->location);
|
||||
|
@ -135,6 +133,6 @@ void DivesiteImportedModel::repopulate(dive_site_table *sites)
|
|||
lastIndex = (int)importedSitesTable->size() - 1; // Qt: the "last index" is negative for empty lists. Insane.
|
||||
checkStates.resize(importedSitesTable->size());
|
||||
for (size_t row = 0; row < importedSitesTable->size(); row++)
|
||||
checkStates[row] = !get_dive_site_by_gps(&(*importedSitesTable)[row]->location, *divelog.sites);
|
||||
checkStates[row] = !divelog.sites->get_by_gps(&(*importedSitesTable)[row]->location);
|
||||
endResetModel();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue