Fix new/existing dive site choices

Only set the currType and currUuid if text changed.
This is needed because if you hit key_down it would
set NEW_DIVE_SITE because a keypress on the lineedit was
due.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2015-09-22 17:20:55 -03:00 committed by Dirk Hohndel
parent 80b42bd28b
commit 4b8eec6c58

View file

@ -489,6 +489,10 @@ void DiveLocationLineEdit::itemActivated(const QModelIndex& index)
currType = uuid == 1 ? NEW_DIVE_SITE : EXISTING_DIVE_SITE;
currUuid = uuid;
setText(index.data().toString());
if(currUuid == NEW_DIVE_SITE)
qDebug() << "Setting a New dive site";
else
qDebug() << "Setting a Existing dive site";
}
void DiveLocationLineEdit::refreshDiveSiteCache()
@ -533,6 +537,11 @@ void DiveLocationLineEdit::keyPressEvent(QKeyEvent *ev)
ev->key() != Qt::Key_Right &&
ev->key() != Qt::Key_Escape &&
ev->key() != Qt::Key_Return ) {
if(ev->key() != Qt::Key_Up && ev->key() != Qt::Key_Down) {
currType = NEW_DIVE_SITE;
currUuid = RECENTLY_ADDED_DIVESITE;
}
showPopup();
} else if (ev->key() == Qt::Key_Escape) {
view->hide();