Fix keyboard inconsistencies

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-23 13:56:49 -03:00 committed by Dirk Hohndel
parent 4b8eec6c58
commit 7d863b5c28
2 changed files with 4 additions and 9 deletions

View file

@ -433,15 +433,9 @@ DiveLocationLineEdit::DiveLocationLineEdit(QWidget *parent) : QLineEdit(parent),
view->setFocusProxy(this); view->setFocusProxy(this);
connect(this, &QLineEdit::textEdited, this, &DiveLocationLineEdit::setTemporaryDiveSiteName); connect(this, &QLineEdit::textEdited, this, &DiveLocationLineEdit::setTemporaryDiveSiteName);
connect(this, &QLineEdit::editingFinished, this, &DiveLocationLineEdit::setDiveSiteName);
connect(view, &QAbstractItemView::activated, this, &DiveLocationLineEdit::itemActivated); connect(view, &QAbstractItemView::activated, this, &DiveLocationLineEdit::itemActivated);
} }
void DiveLocationLineEdit::setDiveSiteName()
{
}
bool DiveLocationLineEdit::eventFilter(QObject *o, QEvent *e) bool DiveLocationLineEdit::eventFilter(QObject *o, QEvent *e)
{ {
if(e->type() == QEvent::KeyPress) { if(e->type() == QEvent::KeyPress) {
@ -458,8 +452,7 @@ bool DiveLocationLineEdit::eventFilter(QObject *o, QEvent *e)
return false; return false;
} }
if (keyEv->key() == Qt::Key_Space || if (keyEv->key() == Qt::Key_Tab){
keyEv->key() == Qt::Key_Tab){
itemActivated(view->currentIndex()); itemActivated(view->currentIndex());
view->hide(); view->hide();
return false; return false;
@ -493,6 +486,8 @@ void DiveLocationLineEdit::itemActivated(const QModelIndex& index)
qDebug() << "Setting a New dive site"; qDebug() << "Setting a New dive site";
else else
qDebug() << "Setting a Existing dive site"; qDebug() << "Setting a Existing dive site";
if(view->isVisible())
view->hide();
} }
void DiveLocationLineEdit::refreshDiveSiteCache() void DiveLocationLineEdit::refreshDiveSiteCache()
@ -585,6 +580,7 @@ void DiveLocationLineEdit::showPopup()
if (!view->isVisible()) { if (!view->isVisible()) {
setTemporaryDiveSiteName(text()); setTemporaryDiveSiteName(text());
proxy->invalidate(); proxy->invalidate();
view->setCurrentIndex( view->model()->index(0,1));
view->show(); view->show();
} }
} }

View file

@ -96,7 +96,6 @@ public:
void setTemporaryDiveSiteName(const QString& s); void setTemporaryDiveSiteName(const QString& s);
bool eventFilter(QObject*, QEvent*); bool eventFilter(QObject*, QEvent*);
void itemActivated(const QModelIndex& index); void itemActivated(const QModelIndex& index);
void setDiveSiteName();
DiveSiteType currDiveSiteType() const; DiveSiteType currDiveSiteType() const;
uint32_t currDiveSiteUuid() const; uint32_t currDiveSiteUuid() const;