diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2015-06-26 20:42:14 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-06-26 18:50:23 -0700 |
commit | 4426cf706f296541b199705eb2ee015c64deb530 (patch) | |
tree | 3765575de91277b300a3419264e827b02d8638b2 /qt-ui/maintab.cpp | |
parent | 7763b95e5f0929fcdfaba95f69dff28950f5486a (diff) | |
download | subsurface-4426cf706f296541b199705eb2ee015c64deb530.tar.gz |
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>
Diffstat (limited to 'qt-ui/maintab.cpp')
-rw-r--r-- | qt-ui/maintab.cpp | 24 |
1 files 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; |