Change the Location from a LineEdit to a ComboBox

And hook up every method that was changed.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2015-05-29 21:13:16 -03:00 committed by Dirk Hohndel
parent abb6773490
commit 88549d1874
2 changed files with 12 additions and 10 deletions

View file

@ -414,7 +414,7 @@ bool MainTab::isEditing()
void MainTab::showLocation() void MainTab::showLocation()
{ {
ui.location->setText(get_dive_location(&displayed_dive)); ui.location->setCurrentText(get_dive_location(&displayed_dive));
} }
void MainTab::updateDiveInfo(bool clear) void MainTab::updateDiveInfo(bool clear)
@ -461,7 +461,7 @@ void MainTab::updateDiveInfo(bool clear)
if (!clear) { if (!clear) {
struct dive_site *ds = get_dive_site_by_uuid(displayed_dive.dive_site_uuid); struct dive_site *ds = get_dive_site_by_uuid(displayed_dive.dive_site_uuid);
if (ds) if (ds)
ui.location->setText(ds->name); ui.location->setCurrentText(ds->name);
else else
ui.location->clear(); ui.location->clear();
// Subsurface always uses "local time" as in "whatever was the local time at the location" // Subsurface always uses "local time" as in "whatever was the local time at the location"
@ -494,7 +494,7 @@ void MainTab::updateDiveInfo(bool clear)
ui.watertemp->setVisible(false); ui.watertemp->setVisible(false);
// rename the remaining fields and fill data from selected trip // rename the remaining fields and fill data from selected trip
ui.LocationLabel->setText(tr("Trip location")); ui.LocationLabel->setText(tr("Trip location"));
ui.location->setText(currentTrip->location); ui.location->setCurrentText(currentTrip->location);
ui.NotesLabel->setText(tr("Trip notes")); ui.NotesLabel->setText(tr("Trip notes"));
ui.notes->setText(currentTrip->notes); ui.notes->setText(currentTrip->notes);
clearEquipment(); clearEquipment();
@ -1248,7 +1248,7 @@ void MainTab::on_location_textChanged(const QString &text)
return; return;
if (currentTrip) { if (currentTrip) {
free(displayedTrip.location); free(displayedTrip.location);
displayedTrip.location = strdup(ui.location->text().toUtf8().data()); displayedTrip.location = strdup(qPrintable(ui.location->currentText()));
} }
markChangedWidget(ui.location); markChangedWidget(ui.location);
} }
@ -1257,7 +1257,7 @@ void MainTab::on_location_textChanged(const QString &text)
void MainTab::on_location_editingFinished() void MainTab::on_location_editingFinished()
{ {
// find the dive site or create it // find the dive site or create it
const char *name = copy_string(qPrintable(ui.location->text())); const char *name = copy_string(qPrintable(ui.location->currentText()));
uint32_t uuid = get_dive_site_uuid_by_name(name, NULL); uint32_t uuid = get_dive_site_uuid_by_name(name, NULL);
if (!uuid) if (!uuid)
uuid = create_dive_site(name); uuid = create_dive_site(name);
@ -1433,7 +1433,7 @@ void MainTab::showAndTriggerEditSelective(struct dive_components what)
if (what.visibility) if (what.visibility)
ui.visibility->setCurrentStars(displayed_dive.visibility); ui.visibility->setCurrentStars(displayed_dive.visibility);
if (what.divesite) if (what.divesite)
ui.location->setText(get_dive_location(&displayed_dive)); ui.location->setCurrentText(get_dive_location(&displayed_dive));
if (what.tags) { if (what.tags) {
char buf[1024]; char buf[1024];
taglist_get_tagstring(displayed_dive.tag_list, buf, 1024); taglist_get_tagstring(displayed_dive.tag_list, buf, 1024);

View file

@ -186,9 +186,12 @@
<number>2</number> <number>2</number>
</property> </property>
<item> <item>
<widget class="QLineEdit" name="location"> <widget class="QComboBox" name="location">
<property name="readOnly"> <property name="sizePolicy">
<bool>false</bool> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
</widget> </widget>
</item> </item>
@ -1255,7 +1258,6 @@
<tabstop>timeEdit</tabstop> <tabstop>timeEdit</tabstop>
<tabstop>airtemp</tabstop> <tabstop>airtemp</tabstop>
<tabstop>watertemp</tabstop> <tabstop>watertemp</tabstop>
<tabstop>location</tabstop>
<tabstop>divemaster</tabstop> <tabstop>divemaster</tabstop>
<tabstop>buddy</tabstop> <tabstop>buddy</tabstop>
<tabstop>rating</tabstop> <tabstop>rating</tabstop>