diff options
-rw-r--r-- | qt-ui/locationinformation.cpp | 12 | ||||
-rw-r--r-- | qt-ui/locationinformation.h | 2 | ||||
-rw-r--r-- | qt-ui/maintab.cpp | 13 |
3 files changed, 21 insertions, 6 deletions
diff --git a/qt-ui/locationinformation.cpp b/qt-ui/locationinformation.cpp index 29ce1548d..90d7dae6c 100644 --- a/qt-ui/locationinformation.cpp +++ b/qt-ui/locationinformation.cpp @@ -538,6 +538,18 @@ void DiveLocationLineEdit::fixPopupPosition() } } +void DiveLocationLineEdit::setCurrentDiveSiteUuid(uint32_t uuid) +{ + currUuid = uuid; + if(uuid == 0) { + currType = NO_DIVE_SITE; + } + struct dive_site *ds = get_dive_site_by_uuid(uuid); + if(!ds) + clear(); + setText(ds->name); +} + void DiveLocationLineEdit::showPopup() { fixPopupPosition(); diff --git a/qt-ui/locationinformation.h b/qt-ui/locationinformation.h index 0d1a995dd..2905a11bc 100644 --- a/qt-ui/locationinformation.h +++ b/qt-ui/locationinformation.h @@ -90,6 +90,7 @@ public: DiveSiteType currDiveSiteType() const; uint32_t currDiveSiteUuid() const; void fixPopupPosition(); + void setCurrentDiveSiteUuid(uint32_t uuid); signals: void diveSiteSelected(uint32_t uuid); @@ -102,6 +103,7 @@ protected: void showPopup(); private: + using QLineEdit::setText; DiveLocationFilterProxyModel *proxy; DiveLocationModel *model; DiveLocationListView *view; diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index b6266eb33..d52966924 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -220,7 +220,7 @@ void MainTab::setCurrentLocationIndex() if (current_dive) { struct dive_site *ds = get_dive_site_by_uuid(current_dive->dive_site_uuid); if (ds) - ui.location->setText(ds->name); + ui.location->setCurrentDiveSiteUuid(ds->uuid); else ui.location->clear(); } @@ -416,7 +416,7 @@ bool MainTab::isEditing() void MainTab::showLocation() { if (get_dive_site_by_uuid(displayed_dive.dive_site_uuid)) - ui.location->setText(get_dive_location(&displayed_dive)); + ui.location->setCurrentDiveSiteUuid(displayed_dive.dive_site_uuid); else ui.location->clear(); } @@ -510,7 +510,7 @@ void MainTab::updateDiveInfo(bool clear) } locationTag += ")</small></small>"; } - ui.location->setText(ds->name); + ui.location->setCurrentDiveSiteUuid(ds->uuid); ui.locationTags->setText(locationTag); } else { ui.location->clear(); @@ -548,7 +548,8 @@ void MainTab::updateDiveInfo(bool clear) // rename the remaining fields and fill data from selected trip ui.LocationLabel->setText(tr("Trip location")); ui.locationTags->clear(); - ui.location->setText(currentTrip->location); + //TODO: Fix this. + //ui.location->setText(currentTrip->location); ui.NotesLabel->setText(tr("Trip notes")); ui.notes->setText(currentTrip->notes); clearEquipment(); @@ -807,7 +808,7 @@ void MainTab::refreshDisplayedDiveSite() { if (displayed_dive_site.uuid) { copy_dive_site(get_dive_site_by_uuid(displayed_dive_site.uuid), &displayed_dive_site); - ui.location->setText(displayed_dive_site.name); + ui.location->setCurrentDiveSiteUuid(displayed_dive_site.uuid); } } @@ -1616,7 +1617,7 @@ void MainTab::showAndTriggerEditSelective(struct dive_components what) if (what.visibility) ui.visibility->setCurrentStars(displayed_dive.visibility); if (what.divesite) - ui.location->setText(get_dive_location(&displayed_dive)); + ui.location->setCurrentDiveSiteUuid(displayed_dive.dive_site_uuid); if (what.tags) { char buf[1024]; taglist_get_tagstring(displayed_dive.tag_list, buf, 1024); |