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>
This commit is contained in:
Tomaz Canabrava 2015-09-25 14:51:10 -03:00 committed by Dirk Hohndel
parent 94d05d1cb6
commit 64453893a0
3 changed files with 21 additions and 6 deletions

View file

@ -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();

View file

@ -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;

View file

@ -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);