summaryrefslogtreecommitdiffstats
path: root/qt-ui/locationinformation.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2015-09-22 14:31:56 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-09-23 14:15:22 -0700
commiteb2c78e9536f55f972154c9595ccb588318935d9 (patch)
treef063a3d3cc0e76a9290dbaf6fd92cf8403c82bd5 /qt-ui/locationinformation.cpp
parentfdec250723549453e714580724231ee2fb866907 (diff)
downloadsubsurface-eb2c78e9536f55f972154c9595ccb588318935d9.tar.gz
Random fixes and improvements
Whitespace fixes, constructor fixes, new slot (still unused) Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/locationinformation.cpp')
-rw-r--r--qt-ui/locationinformation.cpp35
1 files changed, 17 insertions, 18 deletions
diff --git a/qt-ui/locationinformation.cpp b/qt-ui/locationinformation.cpp
index a66b96c19..71def344e 100644
--- a/qt-ui/locationinformation.cpp
+++ b/qt-ui/locationinformation.cpp
@@ -410,12 +410,10 @@ bool DiveLocationModel::setData(const QModelIndex& index, const QVariant& value,
return true;
}
-DiveLocationLineEdit::DiveLocationLineEdit(QWidget *parent)
+DiveLocationLineEdit::DiveLocationLineEdit(QWidget *parent) : QLineEdit(parent),
+ proxy(new DiveLocationFilterProxyModel()), model(new DiveLocationModel()), view(new DiveLocationListView())
{
location_line_edit = this;
- proxy = new DiveLocationFilterProxyModel();
- model = new DiveLocationModel();
- view = new DiveLocationListView();
proxy->setSourceModel(model);
proxy->setFilterKeyColumn(DiveLocationModel::NAME);
@@ -429,19 +427,24 @@ DiveLocationLineEdit::DiveLocationLineEdit(QWidget *parent)
view->setSelectionMode(QAbstractItemView::SingleSelection);
view->setParent(0, Qt::Popup);
view->installEventFilter(this);
- view->setFocusProxy(location_line_edit);
+ view->setFocusPolicy(Qt::NoFocus);
+ view->setFocusProxy(this);
connect(this, &QLineEdit::textEdited, this, &DiveLocationLineEdit::setTemporaryDiveSiteName);
+ connect(this, &QLineEdit::editingFinished, this, &DiveLocationLineEdit::setDiveSiteName);
connect(view, &QAbstractItemView::activated, this, &DiveLocationLineEdit::itemActivated);
}
+void DiveLocationLineEdit::setDiveSiteName()
+{
+
+}
+
bool DiveLocationLineEdit::eventFilter(QObject *o, QEvent *e)
{
if(e->type() == QEvent::KeyPress) {
QKeyEvent *keyEv = (QKeyEvent*) e;
- qDebug() << view->focusProxy()->objectName();
-
if (keyEv->key() == Qt::Key_Escape) {
view->hide();
return true;
@@ -451,15 +454,12 @@ bool DiveLocationLineEdit::eventFilter(QObject *o, QEvent *e)
view->hide();
return false;
}
-
event(e);
- }
-
- if(e->type() == QEvent::MouseButtonPress ) {
- if (!view->underMouse()) {
- view->hide();
- return true;
- }
+ } else if(e->type() == QEvent::MouseButtonPress ) {
+ if (!view->underMouse()) {
+ view->hide();
+ return true;
+ }
}
return false;
@@ -507,7 +507,6 @@ void DiveLocationLineEdit::setTemporaryDiveSiteName(const QString& s)
void DiveLocationLineEdit::keyPressEvent(QKeyEvent *ev)
{
- qDebug() << "Pressing key" << ev->key();
QLineEdit::keyPressEvent(ev);
if(ev->key() != Qt::Key_Left &&
ev->key() != Qt::Key_Right &&
@@ -554,8 +553,8 @@ void DiveLocationLineEdit::showPopup()
view->setGeometry(pos.x(), pos.y(), w, h);
if (!view->isVisible()) {
- view->show();
- view->setFocus();
+ proxy->invalidate();
+ view->show();
}
}