aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-02-26 22:26:11 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-04-12 18:19:07 +0300
commitf6e7bdc5ef99d5a5fe71ac4f32511900fa82e804 (patch)
tree398efefad3b84b33eb5e488bdfa5b2482f345cdd /desktop-widgets
parent36644dc9f7540886801bda6131dff36241d9e879 (diff)
downloadsubsurface-f6e7bdc5ef99d5a5fe71ac4f32511900fa82e804.tar.gz
Dive site: add dive site table parameter to dive site functions
To enable undo of dive site functions, it is crucial to work with different dive site tables. Therefore add a dive site table parameter to dive site functions. For now, always pass the global dive site table. Thus, this commit shouldn't alter any functionality. After this change, a simple search for dive_site_table reveals all places where the global dive site table is accessed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/locationinformation.cpp6
-rw-r--r--desktop-widgets/tab-widgets/maintab.cpp4
2 files changed, 5 insertions, 5 deletions
diff --git a/desktop-widgets/locationinformation.cpp b/desktop-widgets/locationinformation.cpp
index 24f45058a..ea52dd8c6 100644
--- a/desktop-widgets/locationinformation.cpp
+++ b/desktop-widgets/locationinformation.cpp
@@ -198,7 +198,7 @@ void LocationInformationWidget::acceptChanges()
if (!ui.diveSiteCoordinates->text().isEmpty())
parseGpsText(ui.diveSiteCoordinates->text(), diveSite->location);
if (dive_site_is_empty(diveSite)) {
- LocationInformationModel::instance()->removeRow(get_divesite_idx(diveSite));
+ LocationInformationModel::instance()->removeRow(get_divesite_idx(diveSite, &dive_site_table));
displayed_dive.dive_site = nullptr;
diveSite = nullptr;
}
@@ -388,7 +388,7 @@ QVariant DiveLocationModel::data(const QModelIndex &index, int role) const
}
// The dive sites are -2 because of the first two items.
- struct dive_site *ds = get_dive_site(index.row() - 2);
+ struct dive_site *ds = get_dive_site(index.row() - 2, &dive_site_table);
return LocationInformationModel::getDiveSiteData(ds, index.column(), role);
}
@@ -522,7 +522,7 @@ static struct dive_site *get_dive_site_name_start_which_str(const QString &str)
{
struct dive_site *ds;
int i;
- for_each_dive_site (i, ds) {
+ for_each_dive_site (i, ds, &dive_site_table) {
QString dsName(ds->name);
if (dsName.toLower().startsWith(str.toLower())) {
return ds;
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp
index d1f13dd13..7f30c8962 100644
--- a/desktop-widgets/tab-widgets/maintab.cpp
+++ b/desktop-widgets/tab-widgets/maintab.cpp
@@ -658,7 +658,7 @@ struct dive_site *MainTab::updateDiveSite(struct dive_site *pickedDs, dive *d)
if (pickedDs == RECENTLY_ADDED_DIVESITE) {
QString name = ui.location->text().isEmpty() ? tr("New dive site") : ui.location->text();
- pickedDs = create_dive_site(qPrintable(name), displayed_dive.when);
+ pickedDs = create_dive_site(qPrintable(name), displayed_dive.when, &dive_site_table);
createdNewDive = true;
}
@@ -856,7 +856,7 @@ void MainTab::acceptChanges()
if (oldDs && !is_dive_site_used(oldDs, false)) {
if (verbose)
qDebug() << "delete now unused dive site" << (oldDs->name ? oldDs->name : "without name");
- delete_dive_site(oldDs);
+ delete_dive_site(oldDs, &dive_site_table);
MapWidget::instance()->reload();
}
// the code above can change the correct uuid for the displayed dive site - and the