Desktop: enable clearing of dive site

Clearing dive site did not work for two reasons:
1) We didn't get a signal when editing was finished.
2) When clearing the dive site, the "add new dive site" site was set.

Thus, connect to the editingFinished signal and in
DiveLocationLineEdit::currDiveSite() return a null pointer if
the string is empty.

This means that it is not possible to have a dive site with an
empty string, but that shouldn't be a problem, right?

Fixes #2148

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-06-30 23:08:02 +02:00 committed by Dirk Hohndel
parent f451f7d9a5
commit 02e94de062
2 changed files with 4 additions and 3 deletions

View file

@ -432,9 +432,8 @@ bool DiveLocationLineEdit::eventFilter(QObject *, QEvent *e)
void DiveLocationLineEdit::focusOutEvent(QFocusEvent *ev)
{
if (!view->isVisible()) {
if (!view->isVisible())
QLineEdit::focusOutEvent(ev);
}
}
void DiveLocationLineEdit::itemActivated(const QModelIndex &index)
@ -601,7 +600,8 @@ DiveLocationLineEdit::DiveSiteType DiveLocationLineEdit::currDiveSiteType() cons
struct dive_site *DiveLocationLineEdit::currDiveSite() const
{
return currDs;
// If there is no text, this corresponds to the empty dive site
return text().trimmed().isEmpty() ? nullptr : currDs;
}
DiveLocationListView::DiveLocationListView(QWidget*)