mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
map: use value semantics for MapLocation
This makes memory management more simple, as not explicit deletion is necessary. A rather large commit, because changing QVector<> to std::vector<> is propagated up the call chain. Adds a new range_contains() helper function for collection types such as std::vector<>. I didn't want to call it contains(), since we already have a contains function for strings and let's keep argument overloading simple. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
e39dea3d68
commit
6b835710bc
17 changed files with 84 additions and 75 deletions
|
@ -46,18 +46,18 @@ void MapWidgetHelper::centerOnDiveSite(struct dive_site *ds)
|
|||
}
|
||||
}
|
||||
|
||||
void MapWidgetHelper::setSelected(const QVector<dive_site *> &divesites)
|
||||
void MapWidgetHelper::setSelected(const std::vector<dive_site *> divesites)
|
||||
{
|
||||
m_mapLocationModel->setSelected(divesites);
|
||||
m_mapLocationModel->setSelected(std::move(divesites));
|
||||
m_mapLocationModel->selectionChanged();
|
||||
updateEditMode();
|
||||
}
|
||||
|
||||
void MapWidgetHelper::centerOnSelectedDiveSite()
|
||||
{
|
||||
QVector<struct dive_site *> selDS = m_mapLocationModel->selectedDs();
|
||||
std::vector<struct dive_site *> selDS = m_mapLocationModel->selectedDs();
|
||||
|
||||
if (selDS.isEmpty()) {
|
||||
if (selDS.empty()) {
|
||||
// no selected dives with GPS coordinates
|
||||
QMetaObject::invokeMethod(m_map, "deselectMapLocation");
|
||||
return;
|
||||
|
@ -128,7 +128,7 @@ void MapWidgetHelper::selectedLocationChanged(struct dive_site *ds_in)
|
|||
|
||||
if (!ds_in)
|
||||
return;
|
||||
MapLocation *location = m_mapLocationModel->getMapLocation(ds_in);
|
||||
const MapLocation *location = m_mapLocationModel->getMapLocation(ds_in);
|
||||
if (!location)
|
||||
return;
|
||||
QGeoCoordinate locationCoord = location->coordinate;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue