Dive site: show distance to current dive using extra data

Currently, in the dive-site selection widget the distance to
the dive site of the current dive is shown. Instead, use the
recently introduced dive_get_gps_location() function. Thus,
the actual GPS coordinates extracted by libdivecomputer are
used.

The function is only called when the current dive changes
and the location is stored in the item delegate.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-04-25 09:35:46 +02:00 committed by Dirk Hohndel
parent c7e1c40b0e
commit e76298a8a7
4 changed files with 20 additions and 8 deletions

View file

@ -371,7 +371,7 @@ DiveLocationLineEdit::DiveLocationLineEdit(QWidget *parent) : QLineEdit(parent),
view->setModel(proxy);
view->setModelColumn(LocationInformationModel::NAME);
view->setItemDelegate(new LocationFilterDelegate());
view->setItemDelegate(&delegate);
view->setEditTriggers(QAbstractItemView::NoEditTriggers);
view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view->setSelectionBehavior(QAbstractItemView::SelectRows);
@ -570,6 +570,7 @@ void DiveLocationLineEdit::setCurrentDiveSite(struct dive *d)
location_t currentLocation = d ? dive_get_gps_location(d) : location_t{0, 0};
proxy->setCurrentLocation(currentLocation);
delegate.setCurrentLocation(currentLocation);
}
void DiveLocationLineEdit::showPopup()