summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/completionmodels.cpp14
-rw-r--r--qt-ui/divecomponentselection.ui57
-rw-r--r--qt-ui/filtermodels.cpp4
-rw-r--r--qt-ui/globe.cpp51
-rw-r--r--qt-ui/locationInformation.ui75
-rw-r--r--qt-ui/maintab.cpp100
-rw-r--r--qt-ui/maintab.h7
-rw-r--r--qt-ui/maintab.ui130
-rw-r--r--qt-ui/mainwindow.cpp26
-rw-r--r--qt-ui/mainwindow.h5
-rw-r--r--qt-ui/models.cpp6
-rw-r--r--qt-ui/printlayout.cpp2
-rw-r--r--qt-ui/simplewidgets.cpp97
-rw-r--r--qt-ui/simplewidgets.h25
-rw-r--r--qt-ui/socialnetworks.cpp2
-rw-r--r--qt-ui/subsurfacewebservices.cpp51
16 files changed, 451 insertions, 201 deletions
diff --git a/qt-ui/completionmodels.cpp b/qt-ui/completionmodels.cpp
index fd3cc7504..f2e70afd1 100644
--- a/qt-ui/completionmodels.cpp
+++ b/qt-ui/completionmodels.cpp
@@ -40,9 +40,21 @@
CREATE_CSV_UPDATE_METHOD(BuddyCompletionModel, buddy);
CREATE_CSV_UPDATE_METHOD(DiveMasterCompletionModel, divemaster);
-CREATE_UPDATE_METHOD(LocationCompletionModel, location);
CREATE_UPDATE_METHOD(SuitCompletionModel, suit);
+void LocationCompletionModel::updateModel()
+{
+ QStringList list;
+ struct dive_site *ds;
+ int i = 0;
+ for_each_dive_site(i, ds) {
+ if (!list.contains(ds->name))
+ list.append(ds->name);
+ }
+ std::sort(list.begin(), list.end());
+ setStringList(list);
+}
+
void TagCompletionModel::updateModel()
{
if (g_tag_list == NULL)
diff --git a/qt-ui/divecomponentselection.ui b/qt-ui/divecomponentselection.ui
index dbd0839ba..7eade039b 100644
--- a/qt-ui/divecomponentselection.ui
+++ b/qt-ui/divecomponentselection.ui
@@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>308</width>
- <height>263</height>
+ <width>401</width>
+ <height>317</height>
</rect>
</property>
<property name="sizePolicy">
@@ -41,9 +41,9 @@
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
- <widget class="QCheckBox" name="location">
+ <widget class="QCheckBox" name="divesite">
<property name="text">
- <string>Location</string>
+ <string>Dive site</string>
</property>
</widget>
</item>
@@ -54,34 +54,6 @@
</property>
</widget>
</item>
- <item row="1" column="0">
- <widget class="QCheckBox" name="gps">
- <property name="text">
- <string>GPS coordinates</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QCheckBox" name="divemaster">
- <property name="text">
- <string>Divemaster</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QCheckBox" name="buddy">
- <property name="text">
- <string>Buddy</string>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QCheckBox" name="rating">
- <property name="text">
- <string>Rating</string>
- </property>
- </widget>
- </item>
<item row="5" column="0">
<widget class="QCheckBox" name="visibility">
<property name="text">
@@ -117,6 +89,27 @@
</property>
</widget>
</item>
+ <item row="1" column="0">
+ <widget class="QCheckBox" name="divemaster">
+ <property name="text">
+ <string>Divemaster</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QCheckBox" name="buddy">
+ <property name="text">
+ <string>Buddy</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QCheckBox" name="rating">
+ <property name="text">
+ <string>Rating</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
diff --git a/qt-ui/filtermodels.cpp b/qt-ui/filtermodels.cpp
index 378f46735..f44ab7cf8 100644
--- a/qt-ui/filtermodels.cpp
+++ b/qt-ui/filtermodels.cpp
@@ -249,7 +249,7 @@ bool LocationFilterModel::doFilter(struct dive *d, QModelIndex &index0, QAbstrac
return true;
}
// Checked means 'Show', Unchecked means 'Hide'.
- QString location(d->location);
+ QString location(get_dive_location(d));
// only show empty location dives if the user checked that.
if (location.isEmpty()) {
if (rowCount() > 0)
@@ -277,7 +277,7 @@ void LocationFilterModel::repopulate()
struct dive *dive;
int i = 0;
for_each_dive (i, dive) {
- QString location(dive->location);
+ QString location(get_dive_location(dive));
if (!location.isEmpty() && !list.contains(location)) {
list.append(location);
}
diff --git a/qt-ui/globe.cpp b/qt-ui/globe.cpp
index cda408ddc..91bb4e858 100644
--- a/qt-ui/globe.cpp
+++ b/qt-ui/globe.cpp
@@ -164,10 +164,11 @@ void GlobeGPS::mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit unit)
QList<int> selectedDiveIds;
for_each_dive (idx, dive) {
long lat_diff, lon_diff;
- if (!dive_has_gps_location(dive))
+ struct dive_site *ds = get_dive_site_for_dive(dive);
+ if (!dive_site_has_gps_location(ds))
continue;
- lat_diff = labs(dive->latitude.udeg - lat_udeg);
- lon_diff = labs(dive->longitude.udeg - lon_udeg);
+ lat_diff = labs(ds->latitude.udeg - lat_udeg);
+ lon_diff = labs(ds->longitude.udeg - lon_udeg);
if (lat_diff > 180000000)
lat_diff = 360000000 - lat_diff;
if (lon_diff > 180000000)
@@ -186,6 +187,7 @@ void GlobeGPS::mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit unit)
void GlobeGPS::repopulateLabels()
{
+ struct dive_site *ds;
if (loadedDives) {
model()->treeModel()->removeDocument(loadedDives);
delete loadedDives;
@@ -204,12 +206,16 @@ void GlobeGPS::repopulateLabels()
// don't show that flag, it's either already shown as displayed_dive
// or it's the one that we are moving right now...
continue;
- if (dive_has_gps_location(dive)) {
- GeoDataPlacemark *place = new GeoDataPlacemark(dive->location);
- place->setCoordinate(dive->longitude.udeg / 1000000.0, dive->latitude.udeg / 1000000.0, 0, GeoDataCoordinates::Degree);
+ if (idx == -1)
+ ds = &displayed_dive_site;
+ else
+ ds = get_dive_site_for_dive(dive);
+ if (dive_site_has_gps_location(ds)) {
+ GeoDataPlacemark *place = new GeoDataPlacemark(ds->name);
+ place->setCoordinate(ds->longitude.udeg / 1000000.0, ds->latitude.udeg / 1000000.0, 0, GeoDataCoordinates::Degree);
// don't add dive locations twice, unless they are at least 50m apart
- if (locationMap[QString(dive->location)]) {
- GeoDataCoordinates existingLocation = locationMap[QString(dive->location)]->coordinate();
+ if (locationMap[QString(ds->name)]) {
+ GeoDataCoordinates existingLocation = locationMap[QString(ds->name)]->coordinate();
GeoDataLineString segment = GeoDataLineString();
segment.append(existingLocation);
GeoDataCoordinates newLocation = place->coordinate();
@@ -220,7 +226,7 @@ void GlobeGPS::repopulateLabels()
if (dist < 0.05)
continue;
}
- locationMap[QString(dive->location)] = place;
+ locationMap[QString(ds->name)] = place;
loadedDives->append(place);
}
}
@@ -236,23 +242,23 @@ void GlobeGPS::reload()
void GlobeGPS::centerOnCurrentDive()
{
- struct dive *dive = current_dive;
+ struct dive_site *ds = get_dive_site_for_dive(current_dive);
// dive has changed, if we had the 'editingDive', hide it.
- if (messageWidget->isVisible() && (!dive || dive_has_gps_location(dive) || amount_selected != 1))
+ if (messageWidget->isVisible() && (!ds || dive_site_has_gps_location(ds) || amount_selected != 1))
messageWidget->hide();
editingDiveLocation = false;
- if (!dive)
+ if (!ds)
return;
- qreal longitude = dive->longitude.udeg / 1000000.0;
- qreal latitude = dive->latitude.udeg / 1000000.0;
+ qreal longitude = ds->longitude.udeg / 1000000.0;
+ qreal latitude = ds->latitude.udeg / 1000000.0;
- if ((!dive_has_gps_location(dive) || MainWindow::instance()->information()->isEditing()) && amount_selected == 1) {
+ if ((!dive_site_has_gps_location(ds) || MainWindow::instance()->information()->isEditing()) && amount_selected == 1) {
prepareForGetDiveCoordinates();
return;
}
- if (!dive_has_gps_location(dive)) {
+ if (!dive_site_has_gps_location(ds)) {
zoomOutForNoGPS();
return;
}
@@ -309,8 +315,10 @@ void GlobeGPS::prepareForGetDiveCoordinates()
}
}
+// This needs to update the dive site, not just this dive
void GlobeGPS::changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::Unit unit)
{
+ struct dive_site *ds;
messageWidget->hide();
if (MainWindow::instance()->dive_list()->selectionModel()->selection().isEmpty())
@@ -324,8 +332,8 @@ void GlobeGPS::changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::U
centerOn(lon, lat, true);
// change the location of the displayed_dive and put the UI in edit mode
- displayed_dive.latitude.udeg = lrint(lat * 1000000.0);
- displayed_dive.longitude.udeg = lrint(lon * 1000000.0);
+ displayed_dive_site.latitude.udeg = lrint(lat * 1000000.0);
+ displayed_dive_site.longitude.udeg = lrint(lon * 1000000.0);
emit(coordinatesChanged());
repopulateLabels();
editingDiveLocation = false;
@@ -341,7 +349,12 @@ void GlobeGPS::mousePressEvent(QMouseEvent *event)
// there could be two scenarios that got us here; let's check if we are editing a dive
if (MainWindow::instance()->information()->isEditing() && clickOnGlobe) {
- MainWindow::instance()->information()->updateCoordinatesText(lat, lon);
+ //
+ // FIXME
+ // TODO
+ //
+ // this needs to do this on the dive site screen
+ // MainWindow::instance()->information()->updateCoordinatesText(lat, lon);
repopulateLabels();
} else if (clickOnGlobe) {
changeDiveGeoPosition(lon, lat, GeoDataCoordinates::Degree);
diff --git a/qt-ui/locationInformation.ui b/qt-ui/locationInformation.ui
new file mode 100644
index 000000000..658395b35
--- /dev/null
+++ b/qt-ui/locationInformation.ui
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>LocationInformation</class>
+ <widget class="QGroupBox" name="LocationInformation">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>GroupBox</string>
+ </property>
+ <property name="title">
+ <string>Dive Site</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0" colspan="2">
+ <widget class="KMessageWidget" name="diveSiteMessage" native="true"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Name</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="diveSiteName"/>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Coordinates</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLineEdit" name="diveSiteCoordinates"/>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Description</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QLineEdit" name="diveSiteDescription"/>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Notes</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QPlainTextEdit" name="diveSiteNotes"/>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>KMessageWidget</class>
+ <extends>QWidget</extends>
+ <header>kmessagewidget.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index e0da97a2d..b78280d7a 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -49,18 +49,19 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
ui.extraData->setModel(extraDataModel);
closeMessage();
+ connect(ui.manageDiveSite, SIGNAL(clicked()), this, SLOT(prepareDiveSiteEdit()));
+
QAction *action = new QAction(tr("Apply changes"), this);
connect(action, SIGNAL(triggered(bool)), this, SLOT(acceptChanges()));
addMessageAction(action);
action = new QAction(tr("Discard changes"), this);
connect(action, SIGNAL(triggered(bool)), this, SLOT(rejectChanges()));
+ addMessageAction(action);
QShortcut *closeKey = new QShortcut(QKeySequence(Qt::Key_Escape), this);
connect(closeKey, SIGNAL(activated()), this, SLOT(escDetected()));
- addMessageAction(action);
-
if (qApp->style()->objectName() == "oxygen")
setDocumentMode(true);
else
@@ -71,7 +72,6 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
setEnabled(false);
ui.location->installEventFilter(this);
- ui.coordinates->installEventFilter(this);
ui.divemaster->installEventFilter(this);
ui.buddy->installEventFilter(this);
ui.suit->installEventFilter(this);
@@ -212,6 +212,10 @@ MainTab::~MainTab()
}
}
+void MainTab::prepareDiveSiteEdit() {
+ emit requestDiveSiteEdit(displayed_dive.dive_site_uuid);
+}
+
void MainTab::toggleTriggeredColumn()
{
QAction *action = qobject_cast<QAction *>(sender());
@@ -391,6 +395,11 @@ bool MainTab::isEditing()
return editMode != NONE;
}
+void MainTab::showLocation()
+{
+ ui.location->setText(get_dive_location(&displayed_dive));
+}
+
void MainTab::updateDiveInfo(bool clear)
{
// don't execute this while adding / planning a dive
@@ -424,9 +433,7 @@ void MainTab::updateDiveInfo(bool clear)
else
ui.notes->setPlainText(tmp);
}
-
UPDATE_TEXT(displayed_dive, notes);
- UPDATE_TEXT(displayed_dive, location);
UPDATE_TEXT(displayed_dive, suit);
UPDATE_TEXT(displayed_dive, divemaster);
UPDATE_TEXT(displayed_dive, buddy);
@@ -435,7 +442,11 @@ void MainTab::updateDiveInfo(bool clear)
ui.DiveType->setCurrentIndex(displayed_dive.dc.divemode);
if (!clear) {
- updateGpsCoordinates();
+ struct dive_site *ds = get_dive_site_by_uuid(displayed_dive.dive_site_uuid);
+ if (ds)
+ ui.location->setText(ds->name);
+ else
+ ui.location->clear();
// Subsurface always uses "local time" as in "whatever was the local time at the location"
// so all time stamps have no time zone information and are in UTC
QDateTime localTime = QDateTime::fromTime_t(displayed_dive.when - gettimezoneoffset(displayed_dive.when));
@@ -446,8 +457,6 @@ void MainTab::updateDiveInfo(bool clear)
setTabText(0, tr("Trip notes"));
currentTrip = *MainWindow::instance()->dive_list()->selectedTrips().begin();
// only use trip relevant fields
- ui.coordinates->setVisible(false);
- ui.CoordinatedLabel->setVisible(false);
ui.divemaster->setVisible(false);
ui.DivemasterLabel->setVisible(false);
ui.buddy->setVisible(false);
@@ -477,8 +486,6 @@ void MainTab::updateDiveInfo(bool clear)
setTabText(0, tr("Dive notes"));
currentTrip = NULL;
// make all the fields visible writeable
- ui.coordinates->setVisible(true);
- ui.CoordinatedLabel->setVisible(true);
ui.divemaster->setVisible(true);
ui.buddy->setVisible(true);
ui.suit->setVisible(true);
@@ -647,8 +654,8 @@ void MainTab::updateDiveInfo(bool clear)
clearStats();
clearEquipment();
ui.rating->setCurrentStars(0);
- ui.coordinates->clear();
ui.visibility->setCurrentStars(0);
+ ui.location->clear();
}
editMode = NONE;
ui.cylinders->view()->hideColumn(CylindersModel::DEPTH);
@@ -756,8 +763,6 @@ void MainTab::acceptChanges()
copy_samples(&displayed_dive.dc, &current_dive->dc);
}
struct dive *cd = current_dive;
- //Reset coordinates field, in case it contains garbage.
- updateGpsCoordinates();
// now check if something has changed and if yes, edit the selected dives that
// were identical with the master dive shown (and mark the divelist as changed)
if (!same_string(displayed_dive.buddy, cd->buddy))
@@ -785,17 +790,6 @@ void MainTab::acceptChanges()
time_t offset = cd->when - displayed_dive.when;
MODIFY_SELECTED_DIVES(mydive->when -= offset;);
}
- if (displayed_dive.latitude.udeg != cd->latitude.udeg ||
- displayed_dive.longitude.udeg != cd->longitude.udeg)
- MODIFY_SELECTED_DIVES(
- if (copyPaste ||
- (same_string(mydive->location, cd->location) &&
- mydive->latitude.udeg == cd->latitude.udeg &&
- mydive->longitude.udeg == cd->longitude.udeg))
- gpsHasChanged(mydive, cd, ui.coordinates->text(), 0);
- );
- if (!same_string(displayed_dive.location, cd->location))
- MODIFY_SELECTED_DIVES(EDIT_TEXT(location));
saveTags();
@@ -901,7 +895,6 @@ void MainTab::resetPallete()
ui.buddy->setPalette(p);
ui.notes->setPalette(p);
ui.location->setPalette(p);
- ui.coordinates->setPalette(p);
ui.divemaster->setPalette(p);
ui.suit->setPalette(p);
ui.airtemp->setPalette(p);
@@ -1139,8 +1132,17 @@ void MainTab::on_location_textChanged(const QString &text)
free(displayedTrip.location);
displayedTrip.location = strdup(ui.location->text().toUtf8().data());
} else {
- free(displayed_dive.location);
- displayed_dive.location = strdup(ui.location->text().toUtf8().data());
+ // this means we switched dive sites... this requires a lot more thinking
+ //
+ //
+ // FIXME
+ //
+ // TODO
+ //
+ //
+ //
+ // free(displayed_dive.location);
+ // displayed_dive.location = strdup(ui.location->text().toUtf8().data());
}
markChangedWidget(ui.location);
}
@@ -1148,25 +1150,12 @@ void MainTab::on_location_textChanged(const QString &text)
// If we have GPS data for the location entered, add it.
void MainTab::on_location_editingFinished()
{
- // if we have a location and no GPS data, look up the GPS data;
- // but if the GPS data was intentionally cleared then don't
- if (!currentTrip &&
- !same_string(displayed_dive.location, "") &&
- ui.coordinates->text().trimmed().isEmpty() &&
- !(editMode == DIVE && dive_has_gps_location(current_dive))) {
- struct dive *dive;
- int i = 0;
- for_each_dive (i, dive) {
- if (same_string(displayed_dive.location, dive->location) &&
- (dive->latitude.udeg || dive->longitude.udeg)) {
- displayed_dive.latitude = dive->latitude;
- displayed_dive.longitude = dive->longitude;
- MainWindow::instance()->globe()->reload();
- updateGpsCoordinates();
- break;
- }
- }
- }
+ // find the dive site or create it
+ const char *name = ui.location->text().toUtf8().data();
+ uint32_t uuid = get_dive_site_uuid_by_name(name, NULL);
+ if (!uuid)
+ uuid = create_dive_site(name);
+ displayed_dive.dive_site_uuid = uuid;
}
void MainTab::on_suit_textChanged(const QString &text)
@@ -1199,6 +1188,7 @@ void MainTab::on_notes_textChanged()
markChangedWidget(ui.notes);
}
+#if 0 // we'll need something like this for the dive site management
void MainTab::on_coordinates_textChanged(const QString &text)
{
if (editMode == IGNORE || acceptingEdit == true)
@@ -1215,6 +1205,7 @@ void MainTab::on_coordinates_textChanged(const QString &text)
ui.coordinates->setPalette(p); // marks things red
}
}
+#endif
void MainTab::on_rating_valueChanged(int value)
{
@@ -1266,6 +1257,7 @@ void MainTab::editWeightWidget(const QModelIndex &index)
ui.weights->edit(index);
}
+#if 0 // we'll need this for dive sites
void MainTab::updateCoordinatesText(qreal lat, qreal lon)
{
int ulat = rint(lat * 1000000);
@@ -1278,9 +1270,16 @@ void MainTab::updateGpsCoordinates()
if (editMode == NONE)
enableEdition();
- ui.coordinates->setText(printGPSCoords(displayed_dive.latitude.udeg, displayed_dive.longitude.udeg));
- ui.coordinates->setModified(displayed_dive.latitude.udeg || displayed_dive.longitude.udeg);
+ struct dive_site *ds = get_dive_site_by_uuid(displayed_dive.dive_site_uuid);
+ if (ds && dive_site_has_gps_location(ds)) {
+ ui.coordinates->setText(printGPSCoords(ds->latitude.udeg, ds->longitude.udeg));
+ ui.coordinates->setModified(true);
+ } else if (!ui.coordinates->text().isEmpty()) {
+ ui.coordinates->setModified(true);
+ ui.coordinates->clear();
+ }
}
+#endif
void MainTab::escDetected()
{
@@ -1312,7 +1311,6 @@ void MainTab::showAndTriggerEditSelective(struct dive_components what)
// take the data in our copyPasteDive and apply it to selected dives
enableEdition();
copyPaste = true;
- SHOW_SELECTIVE(location);
SHOW_SELECTIVE(buddy);
SHOW_SELECTIVE(divemaster);
SHOW_SELECTIVE(suit);
@@ -1327,8 +1325,8 @@ void MainTab::showAndTriggerEditSelective(struct dive_components what)
ui.rating->setCurrentStars(displayed_dive.rating);
if (what.visibility)
ui.visibility->setCurrentStars(displayed_dive.visibility);
- if (what.gps)
- updateGpsCoordinates();
+ if (what.divesite)
+ ui.location->setText(get_dive_location(&displayed_dive));
if (what.tags) {
char buf[1024];
taglist_get_tagstring(displayed_dive.tag_list, buf, 1024);
diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h
index a279baf7a..8869b068e 100644
--- a/qt-ui/maintab.h
+++ b/qt-ui/maintab.h
@@ -10,6 +10,7 @@
#include <QTabWidget>
#include <QDialog>
#include <QMap>
+#include <QUuid>
#include "ui_maintab.h"
#include "completionmodels.h"
@@ -55,7 +56,7 @@ public:
signals:
void addDiveFinished();
void dateTimeChanged();
-
+ void requestDiveSiteEdit(uint32_t uuid);
public
slots:
void addCylinder_clicked();
@@ -65,7 +66,6 @@ slots:
void rejectChanges();
void on_location_textChanged(const QString &text);
void on_location_editingFinished();
- void on_coordinates_textChanged(const QString &text);
void on_divemaster_textChanged();
void on_buddy_textChanged();
void on_suit_textChanged(const QString &text);
@@ -92,7 +92,8 @@ slots:
void escDetected(void);
void photoDoubleClicked(const QString filePath);
void removeSelectedPhotos();
- void updateGpsCoordinates();
+ void prepareDiveSiteEdit();
+ void showLocation();
private:
Ui::MainTab ui;
diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui
index 48bad01aa..5267863ff 100644
--- a/qt-ui/maintab.ui
+++ b/qt-ui/maintab.ui
@@ -22,7 +22,8 @@
<number>0</number>
</property>
<item row="2" column="1">
- <widget class="KMessageWidget" name="diveNotesMessage" native="true"/>
+ <widget class="KMessageWidget" name="diveNotesMessage" native="true">
+ </widget>
</item>
<item row="3" column="1">
<widget class="QScrollArea" name="scrollArea">
@@ -40,8 +41,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>443</width>
- <height>758</height>
+ <width>441</width>
+ <height>753</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
@@ -131,7 +132,7 @@
</widget>
</item>
<item>
- <widget class="QPushButton" name="pushButton">
+ <widget class="QPushButton" name="manageDiveSite">
<property name="text">
<string>manage</string>
</property>
@@ -140,40 +141,6 @@
</layout>
</item>
<item>
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="0" column="0">
- <widget class="QLabel" name="CoordinatedLabel">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Coordinates</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QLabel" name="TypeLabel">
- <property name="text">
- <string>Dive mode</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLineEdit" name="coordinates">
- <property name="readOnly">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QComboBox" name="DiveType"/>
- </item>
- </layout>
- </item>
- <item>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="DivemasterLabel">
@@ -276,36 +243,50 @@
</layout>
</item>
<item>
- <widget class="QLabel" name="TagLabel">
- <property name="text">
- <string>Tags</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="TagWidget" name="tagWidget">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>0</height>
- </size>
- </property>
- <property name="verticalScrollBarPolicy">
- <enum>Qt::ScrollBarAlwaysOff</enum>
- </property>
- <property name="horizontalScrollBarPolicy">
- <enum>Qt::ScrollBarAlwaysOff</enum>
- </property>
- <property name="lineWrapMode">
- <enum>QPlainTextEdit::NoWrap</enum>
- </property>
- </widget>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="1" column="1">
+ <widget class="QComboBox" name="DiveType"/>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="TagLabel">
+ <property name="text">
+ <string>Tags</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="TypeLabel">
+ <property name="text">
+ <string>Dive mode</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="TagWidget" name="tagWidget">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="verticalScrollBarPolicy">
+ <enum>Qt::ScrollBarAlwaysOff</enum>
+ </property>
+ <property name="horizontalScrollBarPolicy">
+ <enum>Qt::ScrollBarAlwaysOff</enum>
+ </property>
+ <property name="lineWrapMode">
+ <enum>QPlainTextEdit::NoWrap</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
<item>
<widget class="QLabel" name="NotesLabel">
@@ -400,8 +381,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>454</width>
- <height>752</height>
+ <width>68</width>
+ <height>40</height>
</rect>
</property>
<layout class="QGridLayout" name="equipmentTabScrollAreaLayout">
@@ -456,8 +437,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>454</width>
- <height>752</height>
+ <width>441</width>
+ <height>363</height>
</rect>
</property>
<layout class="QGridLayout" name="diveInfoScrollAreaLayout">
@@ -773,8 +754,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>454</width>
- <height>752</height>
+ <width>446</width>
+ <height>215</height>
</rect>
</property>
<layout class="QGridLayout" name="statsScrollAreaLayout">
@@ -1036,7 +1017,6 @@
<tabstop>rating</tabstop>
<tabstop>visibility</tabstop>
<tabstop>suit</tabstop>
- <tabstop>tagWidget</tabstop>
<tabstop>notes</tabstop>
</tabstops>
<resources>
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 257f394d6..56f885409 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -67,12 +67,15 @@ MainWindow::MainWindow() : QMainWindow(),
PlannerSettingsWidget *plannerSettings = new PlannerSettingsWidget();
DivePlannerWidget *plannerWidget = new DivePlannerWidget();
PlannerDetails *plannerDetails = new PlannerDetails();
+ LocationInformationWidget *locationInformation = new LocationInformationWidget();
registerApplicationState("Default", mainTab, profileWidget, diveListView, globeGps );
registerApplicationState("AddDive", mainTab, profileWidget, diveListView, globeGps );
registerApplicationState("EditDive", mainTab, profileWidget, diveListView, globeGps );
registerApplicationState("PlanDive", plannerWidget, profileWidget, plannerSettings, plannerDetails );
registerApplicationState("EditPlannedDive", plannerWidget, profileWidget, diveListView, globeGps );
+ registerApplicationState("EditDiveSite",locationInformation, profileWidget, diveListView, globeGps );
+
setApplicationState("Default");
ui.multiFilter->hide();
@@ -108,6 +111,11 @@ MainWindow::MainWindow() : QMainWindow(),
connect(DivePlannerPointsModel::instance(), SIGNAL(planCreated()), this, SLOT(planCreated()));
connect(DivePlannerPointsModel::instance(), SIGNAL(planCanceled()), this, SLOT(planCanceled()));
connect(plannerDetails->printPlan(), SIGNAL(pressed()), divePlannerWidget(), SLOT(printDecoPlan()));
+ connect(mainTab, SIGNAL(requestDiveSiteEdit(uint32_t)), this, SLOT(enableDiveSiteEdit(uint32_t)));
+ connect(locationInformation, SIGNAL(informationManagementEnded()), this, SLOT(setDefaultState()));
+ connect(locationInformation, SIGNAL(informationManagementEnded()), this, SLOT(refreshDisplay()));
+ connect(locationInformation, SIGNAL(informationManagementEnded()), information(), SLOT(showLocation()));
+
#ifdef NO_PRINTING
ui.printPlan->hide();
ui.menuFile->removeAction(ui.actionPrint);
@@ -128,7 +136,7 @@ MainWindow::MainWindow() : QMainWindow(),
#ifdef NO_MARBLE
ui.menuView->removeAction(ui.actionViewGlobe);
#else
- connect(globe(), SIGNAL(coordinatesChanged()), information(), SLOT(updateGpsCoordinates()));
+ connect(globe(), SIGNAL(coordinatesChanged()), locationInformation, SLOT(updateGpsCoordinates()));
#endif
#ifdef NO_USERMANUAL
ui.menuHelp->removeAction(ui.actionUserManual);
@@ -205,6 +213,18 @@ PlannerSettingsWidget *MainWindow::divePlannerSettingsWidget() {
return qobject_cast<PlannerSettingsWidget*>(applicationState["PlanDive"].bottomLeft);
}
+LocationInformationWidget *MainWindow::locationInformationWidget() {
+ return qobject_cast<LocationInformationWidget*>(applicationState["EditDiveSite"].topLeft);
+}
+
+void MainWindow::enableDiveSiteEdit(uint32_t id) {
+ setApplicationState("EditDiveSite");
+}
+
+void MainWindow::setDefaultState() {
+ setApplicationState("Default");
+}
+
void MainWindow::setLoadedWithFiles(bool f)
{
filesAsArguments = f;
@@ -255,6 +275,7 @@ void MainWindow::current_dive_changed(int divenr)
}
graphics()->plotDive();
information()->updateDiveInfo();
+ locationInformationWidget()->setLocationId(displayed_dive.dive_site_uuid);
}
void MainWindow::on_actionNew_triggered()
@@ -334,6 +355,8 @@ void MainWindow::closeCurrentFile()
clear_git_id();
while (dive_table.nr)
delete_single_dive(0);
+ while (dive_site_table.nr)
+ delete_dive_site(get_dive_site(0)->uuid);
free((void *)existing_filename);
existing_filename = NULL;
@@ -532,6 +555,7 @@ void MainWindow::setupForAddAndPlan(const char *model)
// setup the dive cylinders
DivePlannerPointsModel::instance()->clear();
DivePlannerPointsModel::instance()->setupCylinders();
+ locationInformationWidget()->setLocationId(0);
}
void MainWindow::on_actionReplanDive_triggered()
diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h
index 25771d650..85a63123b 100644
--- a/qt-ui/mainwindow.h
+++ b/qt-ui/mainwindow.h
@@ -10,6 +10,7 @@
#include <QMainWindow>
#include <QAction>
#include <QUrl>
+#include <QUuid>
#include "ui_mainwindow.h"
@@ -68,7 +69,7 @@ public:
GlobeGPS *globe();
DivePlannerWidget *divePlannerWidget();
PlannerSettingsWidget *divePlannerSettingsWidget();
-
+ LocationInformationWidget *locationInformationWidget();
void showError(QString message);
void setTitle(enum MainWindowTitleFormat format);
@@ -159,6 +160,8 @@ slots:
void on_paste_triggered();
void on_actionFilterTags_triggered();
void on_actionConfigure_Dive_Computer_triggered();
+ void enableDiveSiteEdit(uint32_t id);
+ void setDefaultState();
protected:
void closeEvent(QCloseEvent *);
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index ac2f7d899..19f0d12c0 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -1191,7 +1191,7 @@ QVariant DiveItem::data(int column, int role) const
retVal = dive->maxcns;
break;
case LOCATION:
- retVal = QString(dive->location);
+ retVal = QString(get_dive_location(dive));
break;
}
break;
@@ -1232,7 +1232,7 @@ QVariant DiveItem::data(int column, int role) const
retVal = dive->maxcns;
break;
case LOCATION:
- retVal = QString(dive->location);
+ retVal = QString(get_dive_location(dive));
break;
case GAS:
const char *gas_string = get_dive_gas_string(dive);
@@ -2110,7 +2110,7 @@ QVariant ProfilePrintModel::data(const QModelIndex &index, int role) const
}
if (row == 1) {
if (col == 0)
- return QString(dive->location);
+ return QString(get_dive_location(dive));
if (col == 3)
return QString(tr("Duration: %1 min")).arg(di.displayDuration());
}
diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp
index d9752d235..4be5fef73 100644
--- a/qt-ui/printlayout.cpp
+++ b/qt-ui/printlayout.cpp
@@ -462,7 +462,7 @@ void PrintLayout::addTablePrintDataRow(TablePrintModel *model, int row, struct d
model->setData(model->index(row, 3), di.displayDuration(), Qt::DisplayRole);
model->setData(model->index(row, 4), dive->divemaster, Qt::DisplayRole);
model->setData(model->index(row, 5), dive->buddy, Qt::DisplayRole);
- model->setData(model->index(row, 6), dive->location, Qt::DisplayRole);
+ model->setData(model->index(row, 6), get_dive_location(dive), Qt::DisplayRole);
}
void PrintLayout::addTablePrintHeadingRow(TablePrintModel *model, int row) const
diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp
index 5c08a3f7e..27050f6e2 100644
--- a/qt-ui/simplewidgets.cpp
+++ b/qt-ui/simplewidgets.cpp
@@ -6,6 +6,7 @@
#include <QShortcut>
#include <QCalendarWidget>
#include <QKeyEvent>
+#include <QAction>
#include "file.h"
#include "mainwindow.h"
@@ -456,8 +457,7 @@ DiveComponentSelection::DiveComponentSelection(QWidget *parent, struct dive *tar
{
ui.setupUi(this);
what = _what;
- UI_FROM_COMPONENT(location);
- UI_FROM_COMPONENT(gps);
+ UI_FROM_COMPONENT(divesite);
UI_FROM_COMPONENT(divemaster);
UI_FROM_COMPONENT(buddy);
UI_FROM_COMPONENT(rating);
@@ -477,8 +477,7 @@ DiveComponentSelection::DiveComponentSelection(QWidget *parent, struct dive *tar
void DiveComponentSelection::buttonClicked(QAbstractButton *button)
{
if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) {
- COMPONENT_FROM_UI(location);
- COMPONENT_FROM_UI(gps);
+ COMPONENT_FROM_UI(divesite);
COMPONENT_FROM_UI(divemaster);
COMPONENT_FROM_UI(buddy);
COMPONENT_FROM_UI(rating);
@@ -646,3 +645,93 @@ void MultiFilter::closeFilter()
MultiFilterSortModel::instance()->clearFilter();
hide();
}
+#include <QDebug>
+#include <QShowEvent>
+
+LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBox(parent)
+{
+ ui.setupUi(this);
+ ui.diveSiteMessage->setText("You are editing the Dive Site");
+ ui.diveSiteMessage->setCloseButtonVisible(false);
+
+ QAction *action = new QAction(tr("Apply changes"), this);
+ connect(action, SIGNAL(triggered(bool)), this, SLOT(acceptChanges()));
+ ui.diveSiteMessage->addAction(action);
+
+ action = new QAction(tr("Discard changes"), this);
+ connect(action, SIGNAL(triggered(bool)), this, SLOT(rejectChanges()));
+ ui.diveSiteMessage->addAction(action);
+}
+
+void LocationInformationWidget::setLocationId(uint32_t uuid)
+{
+ currentDs = get_dive_site_by_uuid(uuid);
+
+ if (!currentDs) {
+ currentDs = get_dive_site_by_uuid(create_dive_site(""));
+ displayed_dive.dive_site_uuid = currentDs->uuid;
+ ui.diveSiteName->clear();
+ ui.diveSiteDescription->clear();
+ ui.diveSiteNotes->clear();
+ ui.diveSiteCoordinates->clear();
+ }
+ displayed_dive_site = *currentDs;
+ ui.diveSiteName->setText(displayed_dive_site.name);
+ ui.diveSiteDescription->setText(displayed_dive_site.description);
+ ui.diveSiteNotes->setPlainText(displayed_dive_site.notes);
+ ui.diveSiteCoordinates->setText(printGPSCoords(displayed_dive_site.latitude.udeg, displayed_dive_site.longitude.udeg));
+}
+
+void LocationInformationWidget::updateGpsCoordinates()
+{
+ ui.diveSiteCoordinates->setText(printGPSCoords(displayed_dive_site.latitude.udeg, displayed_dive_site.longitude.udeg));
+ MainWindow::instance()->setApplicationState("EditDiveSite");
+}
+
+void LocationInformationWidget::acceptChanges()
+{
+ char *uiString;
+ currentDs->latitude = displayed_dive_site.latitude;
+ currentDs->longitude = displayed_dive_site.longitude;
+ uiString = ui.diveSiteName->text().toUtf8().data();
+ if (!same_string(uiString, currentDs->name)) {
+ free(currentDs->name);
+ currentDs->name = copy_string(uiString);
+ }
+ uiString = ui.diveSiteDescription->text().toUtf8().data();
+ if (!same_string(uiString, currentDs->description)) {
+ free(currentDs->description);
+ currentDs->description = copy_string(uiString);
+ }
+ uiString = ui.diveSiteNotes->document()->toPlainText().toUtf8().data();
+ if (!same_string(uiString, currentDs->notes)) {
+ free(currentDs->notes);
+ currentDs->notes = copy_string(uiString);
+ }
+ if (dive_site_is_empty(currentDs)) {
+ delete_dive_site(currentDs->uuid);
+ displayed_dive.dive_site_uuid = 0;
+ setLocationId(0);
+ } else {
+ setLocationId(currentDs->uuid);
+ }
+ mark_divelist_changed(true);
+ emit informationManagementEnded();
+}
+
+void LocationInformationWidget::rejectChanges()
+{
+ Q_ASSERT(currentDs != NULL);
+ if (dive_site_is_empty(currentDs)) {
+ delete_dive_site(currentDs->uuid);
+ displayed_dive.dive_site_uuid = 0;
+ setLocationId(0);
+ } else {
+ setLocationId(currentDs->uuid);
+ }
+ emit informationManagementEnded();
+}
+
+void LocationInformationWidget::showEvent(QShowEvent *ev) {
+ ui.diveSiteMessage->setCloseButtonVisible(false);
+}
diff --git a/qt-ui/simplewidgets.h b/qt-ui/simplewidgets.h
index 8d5b4f73c..d0cb60508 100644
--- a/qt-ui/simplewidgets.h
+++ b/qt-ui/simplewidgets.h
@@ -6,6 +6,7 @@ class QAbstractButton;
class QNetworkReply;
#include <QWidget>
+#include <QGroupBox>
#include <QDialog>
#include <stdint.h>
@@ -214,6 +215,30 @@ private:
Ui::FilterWidget ui;
};
+#include "ui_locationInformation.h"
+
+class LocationInformationWidget : public QGroupBox {
+Q_OBJECT
+public:
+ LocationInformationWidget(QWidget *parent = 0);
+
+public slots:
+ void acceptChanges();
+ void rejectChanges();
+
+ void showEvent(QShowEvent *);
+
+ void setLocationId(uint32_t uuid);
+ void updateGpsCoordinates(void);
+
+signals:
+ void informationManagementEnded();
+
+private:
+ struct dive_site *currentDs;
+ Ui::LocationInformation ui;
+};
+
bool isGnome3Session();
QImage grayImage(const QImage &coloredImg);
diff --git a/qt-ui/socialnetworks.cpp b/qt-ui/socialnetworks.cpp
index 21ccf9354..6a81d5db7 100644
--- a/qt-ui/socialnetworks.cpp
+++ b/qt-ui/socialnetworks.cpp
@@ -302,7 +302,7 @@ void SocialNetworkDialog::selectionChanged()
tr("min", "abbreviation for minutes")));
}
if (ui->Location->isChecked()) {
- fullText += tr("Dive location: %1 \n").arg(d->location);
+ fullText += tr("Dive location: %1 \n").arg(get_dive_location(d));
}
if (ui->Buddy->isChecked()) {
fullText += tr("Buddy: %1 \n").arg(d->buddy);
diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp
index 72e7e3d27..17c15583f 100644
--- a/qt-ui/subsurfacewebservices.cpp
+++ b/qt-ui/subsurfacewebservices.cpp
@@ -29,7 +29,25 @@
#endif
struct dive_table gps_location_table;
-static bool merge_locations_into_dives(void);
+
+// we don't overwrite any existing GPS info in the dive
+// so get the dive site and if there is none or there is one without GPS fix, add it
+static void copy_gps_location(struct dive *from, struct dive *to)
+{
+ struct dive_site *ds = get_dive_site_for_dive(to);
+ if (!ds || !dive_site_has_gps_location(ds)) {
+ struct dive_site *gds = get_dive_site_for_dive(from);
+ if (!ds) {
+ // simply link to the one created for the fake dive
+ to->dive_site_uuid = gds->uuid;
+ } else {
+ ds->latitude = gds->latitude;
+ ds->longitude = gds->longitude;
+ if (same_string(ds->name, ""))
+ ds->name = copy_string(gds->name);
+ }
+ }
+}
#define SAME_GROUP 6 * 3600 // six hours
//TODO: C Code. static functions are not good if we plan to have a test for them.
@@ -42,14 +60,14 @@ static bool merge_locations_into_dives(void)
for_each_dive (i, dive) {
if (!dive_has_gps_location(dive)) {
- for (j = tracer; (gpsfix = get_gps_location(j, &gps_location_table)) !=NULL; j++) {
+ for (j = tracer; (gpsfix = get_dive_from_table(j, &gps_location_table)) !=NULL; j++) {
if (dive_within_time_range (dive, gpsfix->when, SAME_GROUP)) {
/*
* If position is fixed during dive. This is the good one.
* Asign and mark position, and end gps_location loop
*/
if ((dive->when <= gpsfix->when && gpsfix->when <= dive->when + dive->duration.seconds)) {
- copy_gps_location(gpsfix,dive);
+ copy_gps_location(gpsfix, dive);
changed++;
tracer = j;
break;
@@ -57,7 +75,7 @@ static bool merge_locations_into_dives(void)
/*
* If it is not, check if there are more position fixes in SAME_GROUP range
*/
- if ((nextgpsfix = get_gps_location(j+1,&gps_location_table)) &&
+ if ((nextgpsfix = get_dive_from_table(j+1,&gps_location_table)) &&
dive_within_time_range (dive, nextgpsfix->when, SAME_GROUP)) {
/*
* If distance from gpsfix to end of dive is shorter than distance between
@@ -65,7 +83,7 @@ static bool merge_locations_into_dives(void)
* If not, simply fail and nextgpsfix will be evaluated in next iteration.
*/
if ((dive->when + dive->duration.seconds - gpsfix->when) < (nextgpsfix->when - gpsfix->when)) {
- copy_gps_location(gpsfix,dive);
+ copy_gps_location(gpsfix, dive);
tracer = j;
break;
}
@@ -73,7 +91,7 @@ static bool merge_locations_into_dives(void)
* If no more positions in range, the actual is the one. Asign, mark and end loop.
*/
} else {
- copy_gps_location(gpsfix,dive);
+ copy_gps_location(gpsfix, dive);
changed++;
tracer = j;
break;
@@ -329,10 +347,19 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton *button)
ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
switch (ui.buttonBox->buttonRole(button)) {
case QDialogButtonBox::ApplyRole: {
+ int i;
+ struct dive *d;
+ struct dive_site *ds;
clear_table(&gps_location_table);
QByteArray url = tr("Webservice").toLocal8Bit();
parse_xml_buffer(url.data(), downloadedData.data(), downloadedData.length(), &gps_location_table, NULL);
-
+ // make sure we mark all the dive sites that were created
+ for (i = 0; i < gps_location_table.nr; i++) {
+ d = get_dive_from_table(i, &gps_location_table);
+ ds = get_dive_site_by_uuid(d->dive_site_uuid);
+ if (ds)
+ ds->notes = strdup("SubsurfaceWebservice");
+ }
/* now merge the data in the gps_location table into the dive_table */
if (merge_locations_into_dives()) {
mark_divelist_changed(true);
@@ -361,6 +388,16 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton *button)
hide();
close();
resetState();
+ /* and now clean up and remove all the extra dive sites that were created */
+ QSet<uint32_t> usedUuids;
+ for_each_dive(i, d) {
+ if (d->dive_site_uuid)
+ usedUuids.insert(d->dive_site_uuid);
+ }
+ for_each_dive_site(i, ds) {
+ if (!usedUuids.contains(ds->uuid) && same_string(ds->notes, "SubsurfaceWebservice"))
+ delete_dive_site(ds->uuid);
+ }
} break;
case QDialogButtonBox::RejectRole:
if (reply != NULL && reply->isOpen()) {