summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2015-09-25 14:51:10 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-09-27 06:43:18 -0400
commit64453893a0d8f88f4c70b5606d133b1acc68d10b (patch)
treed7d448d202cbce6e9a18cd856fb46198135c1956 /qt-ui
parent94d05d1cb6c5a63540a82e32056b89456e494fcb (diff)
downloadsubsurface-64453893a0d8f88f4c70b5606d133b1acc68d10b.tar.gz
Do not set text on the Location LineEdit
Since the location is only true with a valid uuid, set the uuid on it, it will search for a valid name and set there. this fixes a few inconsistencies handling the locations. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/locationinformation.cpp12
-rw-r--r--qt-ui/locationinformation.h2
-rw-r--r--qt-ui/maintab.cpp13
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);