summaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-10-08 22:23:47 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-09 21:00:44 -0700
commitf40612d48d7c4ae33a99a10e0ac497b10f7b98aa (patch)
tree01affb1a81ad032fc9c7be69ae01760c170c5955 /desktop-widgets
parent7a1ceee4e791d8fcc44b571b7453d2ebb2308388 (diff)
downloadsubsurface-f40612d48d7c4ae33a99a10e0ac497b10f7b98aa.tar.gz
Map: avoid ugly "invalid dive site" message in location box
Under certain conditions the user was presented an ugly "invalid dive site" message. The condition would arise because the proxy-model which selects the list of dive sites and the code which creates a proposed dive site name had different filter conditions: - The proxy would select any dive site containing the text - The name-proposing code searched for dive sites *starting* with the text. If the user entered a text contained by a dive site name, but no dive site would start with the second line was filled with a dummy text. This text would be kept if it contained the text entered by the user. To avoid this problem, if no dive site is found, use an empty string instead. This will be filtered out by the proxy because it does not contain the user-entered string. Yes, that's horribly subtle, therefore add a comment. But ultimately, this should be solved in a less brittle way. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/locationinformation.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/desktop-widgets/locationinformation.cpp b/desktop-widgets/locationinformation.cpp
index 73d4aeab1..3ebc3d020 100644
--- a/desktop-widgets/locationinformation.cpp
+++ b/desktop-widgets/locationinformation.cpp
@@ -562,11 +562,18 @@ static struct dive_site *get_dive_site_name_start_which_str(const QString &str)
void DiveLocationLineEdit::setTemporaryDiveSiteName(const QString&)
{
+ // This function fills the first two entries with potential names of
+ // a dive site to be generated. The first entry is simply the entered
+ // text. The second entry is the first known dive site name starting
+ // with the entered text.
QModelIndex i0 = model->index(0, DiveLocationModel::NAME);
QModelIndex i1 = model->index(1, DiveLocationModel::NAME);
model->setData(i0, text());
- QString i1_name = INVALID_DIVE_SITE_NAME;
+ // Note: if i1_name stays empty, the line will automatically
+ // be filtered out by the proxy filter, as it does not contain
+ // the user entered text.
+ QString i1_name;
if (struct dive_site *ds = get_dive_site_name_start_which_str(text())) {
const QString orig_name = QString(ds->name).toLower();
const QString new_name = text().toLower();