mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
7763b95e5f
commit
4426cf706f
1 changed files with 14 additions and 10 deletions
|
@ -1305,21 +1305,27 @@ void MainTab::on_location_editingFinished()
|
||||||
if (editMode == IGNORE || acceptingEdit == true)
|
if (editMode == IGNORE || acceptingEdit == true)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (ui.location->text().isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
if (currentTrip) {
|
if (currentTrip) {
|
||||||
free(displayedTrip.location);
|
free(displayedTrip.location);
|
||||||
displayedTrip.location = strdup(qPrintable(ui.location->text()));
|
displayedTrip.location = strdup(qPrintable(ui.location->text()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString currText = 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()));
|
uint32_t uuid = create_dive_site(qPrintable(ui.location->text()));
|
||||||
displayed_dive.dive_site_uuid = uuid;
|
displayed_dive.dive_site_uuid = uuid;
|
||||||
copy_dive_site(get_dive_site_by_uuid(uuid), &displayed_dive_site);
|
copy_dive_site(get_dive_site_by_uuid(uuid), &displayed_dive_site);
|
||||||
|
@ -1332,8 +1338,6 @@ void MainTab::on_location_editingFinished()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int idx = list.first().row();
|
|
||||||
|
|
||||||
if (!get_dive_site(idx))
|
if (!get_dive_site(idx))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue