core: include divesite table directly in divelog

Having this as a pointer is an artifact from the C/C++ split.
The divesitetable header is small enough so that we can
include it directly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-06-08 16:30:24 +02:00 committed by bstoeger
parent 7792f54a73
commit 5af9d28291
29 changed files with 90 additions and 91 deletions

View file

@ -388,8 +388,8 @@ bool DiveLocationFilterProxyModel::lessThan(const QModelIndex &source_left, cons
// If there is a current location, sort by that - otherwise use the provided column
if (has_location(&currentLocation)) {
// The dive sites are -2 because of the first two items.
auto loc1 = (*divelog.sites)[source_left.row() - 2]->location;
auto loc2 = (*divelog.sites)[source_right.row() - 2]->location;
auto loc1 = (divelog.sites)[source_left.row() - 2]->location;
auto loc2 = (divelog.sites)[source_right.row() - 2]->location;
return get_distance(loc1, currentLocation) < get_distance(loc2, currentLocation);
}
return source_left.data().toString().compare(source_right.data().toString(), Qt::CaseInsensitive) < 0;
@ -411,7 +411,7 @@ QVariant DiveLocationModel::data(const QModelIndex &index, int role) const
static const QIcon plusIcon(":list-add-icon");
static const QIcon geoCode(":geotag-icon");
if (index.row() < 0 || index.row() >= (int)divelog.sites->size() + 2)
if (index.row() < 0 || index.row() >= (int)divelog.sites.size() + 2)
return QVariant();
if (index.row() <= 1) { // two special cases.
@ -431,7 +431,7 @@ QVariant DiveLocationModel::data(const QModelIndex &index, int role) const
}
// The dive sites are -2 because of the first two items.
const auto &ds = (*divelog.sites)[index.row() - 2];
const auto &ds = (divelog.sites)[index.row() - 2];
return LocationInformationModel::getDiveSiteData(*ds, index.column(), role);
}
@ -442,7 +442,7 @@ int DiveLocationModel::columnCount(const QModelIndex&) const
int DiveLocationModel::rowCount(const QModelIndex&) const
{
return (int)divelog.sites->size() + 2;
return (int)divelog.sites.size() + 2;
}
Qt::ItemFlags DiveLocationModel::flags(const QModelIndex &index) const
@ -563,7 +563,7 @@ void DiveLocationLineEdit::refreshDiveSiteCache()
static struct dive_site *get_dive_site_name_start_which_str(const QString &str)
{
for (const auto &ds: *divelog.sites) {
for (const auto &ds: divelog.sites) {
QString dsName = QString::fromStdString(ds->name);
if (dsName.toLower().startsWith(str.toLower()))
return ds.get();