From 4426cf706f296541b199705eb2ee015c64deb530 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 26 Jun 2015 20:42:14 -0300 Subject: Dive site rewrite: do not use Qt Model Match Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 9022625f7..8bb2892ad 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -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; -- cgit v1.2.3-70-g09d2