mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
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>
This commit is contained in:
parent
7a1ceee4e7
commit
f40612d48d
1 changed files with 8 additions and 1 deletions
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue