summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-ui/maintab.cpp19
-rw-r--r--qt-ui/maintab.h3
2 files changed, 16 insertions, 6 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index f4c0d3af3..e5204a285 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -1275,20 +1275,29 @@ void MainTab::on_tagWidget_textChanged()
* mostly the same ). Check the currentTrip there to see if it`s being
* correctly triggered.
*/
-void MainTab::on_location_currentTextChanged(const QString &text)
+
+
+void MainTab::on_location_currentIndexChanged(int idx)
{
if (editMode == IGNORE || acceptingEdit == true)
return;
+
if (currentTrip) {
free(displayedTrip.location);
displayedTrip.location = strdup(qPrintable(ui.location->currentText()));
}
- if (current_dive && text == QString(get_dive_site_by_uuid(displayed_dive.dive_site_uuid)->name))
+
+ if (!get_dive_site(idx))
return;
- uint32_t uuid = ui.location->currentData(LocationInformationModel::DIVE_SITE_UUID).toInt();
- displayed_dive.dive_site_uuid = uuid;
- markChangedWidget(ui.location);
+ if (current_dive) {
+ struct dive_site *ds_from_dive = get_dive_site_by_uuid(displayed_dive.dive_site_uuid);
+ if(ds_from_dive && ui.location->currentText() == ds_from_dive->name)
+ return;
+ displayed_dive.dive_site_uuid = get_dive_site(idx)->uuid;
+ markChangedWidget(ui.location);
+ emit diveSiteChanged();
+ }
}
/* TODO:
diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h
index 2d2f9679c..7fb06bc88 100644
--- a/qt-ui/maintab.h
+++ b/qt-ui/maintab.h
@@ -57,6 +57,7 @@ signals:
void addDiveFinished();
void dateTimeChanged();
void requestDiveSiteEdit(uint32_t uuid);
+ void diveSiteChanged();
public
slots:
void addCylinder_clicked();
@@ -64,7 +65,7 @@ slots:
void updateDiveInfo(bool clear = false);
void acceptChanges();
void rejectChanges();
- void on_location_currentTextChanged(const QString &text);
+ void on_location_currentIndexChanged(int idx);
void on_divemaster_textChanged();
void on_buddy_textChanged();
void on_suit_textChanged(const QString &text);