Dive site rewrite: do not use Qt Model Match

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-06-26 20:42:14 -03:00 committed by Dirk Hohndel
parent 7763b95e5f
commit 4426cf706f

View file

@ -1305,21 +1305,27 @@ void MainTab::on_location_editingFinished()
if (editMode == IGNORE || acceptingEdit == true)
return;
if (ui.location->text().isEmpty())
return;
if (currentTrip) {
free(displayedTrip.location);
displayedTrip.location = strdup(qPrintable(ui.location->text()));
}
QString currText = ui.location->text();
QModelIndexList list = LocationInformationModel::instance()->match(
LocationInformationModel::instance()->index(0,0),
Qt::DisplayRole,
currText,
1,
Qt::MatchExactly
);
if (list.isEmpty()) {
struct dive_site *ds;
int idx;
bool found = false;
for_each_dive_site (idx,ds) {
if (same_string(ds->name, qPrintable(currText))) {
found = true;
break;
}
}
if (!found) {
uint32_t uuid = create_dive_site(qPrintable(ui.location->text()));
displayed_dive.dive_site_uuid = uuid;
copy_dive_site(get_dive_site_by_uuid(uuid), &displayed_dive_site);
@ -1332,8 +1338,6 @@ void MainTab::on_location_editingFinished()
return;
}
int idx = list.first().row();
if (!get_dive_site(idx))
return;