mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 13:10:19 +00:00
Mobile: update dive site model if dive sites are created
Always keep the dive site model up to date when adding dive sites. This hopefully avoids creation of invalid indexes followed by crashes. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
f18ea2e3b6
commit
0cce3ef2a8
2 changed files with 14 additions and 2 deletions
|
@ -333,13 +333,19 @@ void QMLManager::openLocalThenRemote(QString url)
|
||||||
updateAllGlobalLists();
|
updateAllGlobalLists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QMLManager::updateSiteList()
|
||||||
|
{
|
||||||
|
LocationInformationModel::instance()->update();
|
||||||
|
emit locationListChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void QMLManager::updateAllGlobalLists()
|
void QMLManager::updateAllGlobalLists()
|
||||||
{
|
{
|
||||||
buddyModel.updateModel(); emit buddyListChanged();
|
buddyModel.updateModel(); emit buddyListChanged();
|
||||||
suitModel.updateModel(); emit suitListChanged();
|
suitModel.updateModel(); emit suitListChanged();
|
||||||
divemasterModel.updateModel(); emit divemasterListChanged();
|
divemasterModel.updateModel(); emit divemasterListChanged();
|
||||||
// TODO: Probably not needed anymore, as the dive site list is generated on the fly!
|
// TODO: Probably not needed anymore, as the dive site list is generated on the fly!
|
||||||
LocationInformationModel::instance()->update(); emit locationListChanged();
|
updateSiteList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QMLManager::mergeLocalRepo()
|
void QMLManager::mergeLocalRepo()
|
||||||
|
@ -774,7 +780,7 @@ void QMLManager::refreshDiveList()
|
||||||
DiveListModel::instance()->addAllDives();
|
DiveListModel::instance()->addAllDives();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setupDivesite(struct dive *d, struct dive_site *ds, double lat, double lon, const char *locationtext)
|
void QMLManager::setupDivesite(struct dive *d, struct dive_site *ds, double lat, double lon, const char *locationtext)
|
||||||
{
|
{
|
||||||
location_t location = create_location(lat, lon);
|
location_t location = create_location(lat, lon);
|
||||||
if (ds) {
|
if (ds) {
|
||||||
|
@ -782,6 +788,8 @@ static void setupDivesite(struct dive *d, struct dive_site *ds, double lat, doub
|
||||||
} else {
|
} else {
|
||||||
unregister_dive_from_dive_site(d);
|
unregister_dive_from_dive_site(d);
|
||||||
add_dive_to_dive_site(d, create_dive_site_with_gps(locationtext, &location, &dive_site_table));
|
add_dive_to_dive_site(d, create_dive_site_with_gps(locationtext, &location, &dive_site_table));
|
||||||
|
// We created a new dive site - let the dive site model know.
|
||||||
|
updateSiteList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -902,6 +910,8 @@ bool QMLManager::checkLocation(DiveObjectHelper *myDive, struct dive *d, QString
|
||||||
ds = create_dive_site(qPrintable(location), &dive_site_table);
|
ds = create_dive_site(qPrintable(location), &dive_site_table);
|
||||||
unregister_dive_from_dive_site(d);
|
unregister_dive_from_dive_site(d);
|
||||||
add_dive_to_dive_site(d, ds);
|
add_dive_to_dive_site(d, ds);
|
||||||
|
// We created a new dive site - let the dive site model know.
|
||||||
|
updateSiteList();
|
||||||
}
|
}
|
||||||
// now make sure that the GPS coordinates match - if the user changed the name but not
|
// now make sure that the GPS coordinates match - if the user changed the name but not
|
||||||
// the GPS coordinates, this still does the right thing as the now new dive site will
|
// the GPS coordinates, this still does the right thing as the now new dive site will
|
||||||
|
|
|
@ -236,6 +236,8 @@ private:
|
||||||
QString m_progressMessage;
|
QString m_progressMessage;
|
||||||
bool m_btEnabled;
|
bool m_btEnabled;
|
||||||
void updateAllGlobalLists();
|
void updateAllGlobalLists();
|
||||||
|
void updateSiteList();
|
||||||
|
void setupDivesite(struct dive *d, struct dive_site *ds, double lat, double lon, const char *locationtext);
|
||||||
QString m_pluggedInDeviceName;
|
QString m_pluggedInDeviceName;
|
||||||
bool m_showNonDiveComputers;
|
bool m_showNonDiveComputers;
|
||||||
struct dive *m_copyPasteDive = NULL;
|
struct dive *m_copyPasteDive = NULL;
|
||||||
|
|
Loading…
Reference in a new issue