From 0ba832ef12382939ef93bb5d7f81b63c9deb7e5d Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Tue, 25 Aug 2015 20:26:45 -0300 Subject: Move dive site list to its correct position When we are in display dive mode, and then edit the location text edit, going to edit dive mode, the location text edit will be moved a bit below of it's original position but the Dive Site List would be already opened, and stuck on it's original position, covering the dive list. This patch fixes that. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 26 ++++++++++++++++++++++++++ qt-ui/maintab.h | 1 + 2 files changed, 27 insertions(+) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index ec25fe36e..960b7edf8 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -226,6 +226,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), connect(ReverseGeoLookupThread::instance(), &QThread::finished, this, &MainTab::setCurrentLocationIndex); + ui.location->installEventFilter(this); acceptingEdit = false; } @@ -240,6 +241,31 @@ MainTab::~MainTab() } } +bool MainTab::eventFilter(QObject *obj, QEvent *ev) +{ + QMoveEvent *mEv; + QResizeEvent *rEv; + QLineEdit *line = qobject_cast(obj); + + if (ev->type() == QEvent::MouseMove || ev->type() == QEvent::HoverMove || ev->type() == QEvent::Paint) + return false; + + if (line) { + if (ev->type() == QEvent::Resize) { + if (line->completer()->popup()->isVisible()) { + QListView *choices = qobject_cast(line->completer()->popup()); + QPoint p = ui.location->mapToGlobal(ui.location->pos()); + choices->setGeometry( + choices->geometry().x(), + p.y() + 3, + choices->geometry().width(), + choices->geometry().height()); + } + } + } + return false; +} + void MainTab::setCurrentLocationIndex() { if (current_dive) { diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h index 332285949..6a55580b7 100644 --- a/qt-ui/maintab.h +++ b/qt-ui/maintab.h @@ -54,6 +54,7 @@ public: void updateCoordinatesText(qreal lat, qreal lon); void nextInputField(QKeyEvent *event); void showAndTriggerEditSelective(struct dive_components what); + virtual bool eventFilter(QObject*, QEvent*); signals: void addDiveFinished(); -- cgit v1.2.3-70-g09d2