From 1239056fb6186279f915c8b3a8af733e74cb6523 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Fri, 25 Sep 2015 13:21:23 -0300 Subject: Center on the dive site also via keyboard Now mouse and keyboard navigation over the list of current dive sites will update the marble globe position. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/locationinformation.cpp | 7 +++++++ qt-ui/locationinformation.h | 5 +++++ qt-ui/maintab.cpp | 1 + 3 files changed, 13 insertions(+) (limited to 'qt-ui') diff --git a/qt-ui/locationinformation.cpp b/qt-ui/locationinformation.cpp index 77f51abde..29ce1548d 100644 --- a/qt-ui/locationinformation.cpp +++ b/qt-ui/locationinformation.cpp @@ -385,6 +385,7 @@ DiveLocationLineEdit::DiveLocationLineEdit(QWidget *parent) : QLineEdit(parent), connect(this, &QLineEdit::textEdited, this, &DiveLocationLineEdit::setTemporaryDiveSiteName); connect(view, &QAbstractItemView::activated, this, &DiveLocationLineEdit::itemActivated); connect(view, &QAbstractItemView::entered, this, &DiveLocationLineEdit::entered); + connect(view, &DiveLocationListView::currentIndexChanged, this, &DiveLocationLineEdit::currentChanged); } bool DiveLocationLineEdit::eventFilter(QObject *o, QEvent *e) @@ -561,3 +562,9 @@ DiveLocationListView::DiveLocationListView(QWidget *parent) { } + +void DiveLocationListView::currentChanged(const QModelIndex& current, const QModelIndex& previous) +{ + QListView::currentChanged(current, previous); + emit currentIndexChanged(current); +} diff --git a/qt-ui/locationinformation.h b/qt-ui/locationinformation.h index 2193b8cdf..0d1a995dd 100644 --- a/qt-ui/locationinformation.h +++ b/qt-ui/locationinformation.h @@ -72,6 +72,10 @@ class DiveLocationListView : public QListView { Q_OBJECT public: DiveLocationListView(QWidget *parent = 0); +protected: + virtual void currentChanged(const QModelIndex& current, const QModelIndex& previous); +signals: + void currentIndexChanged(const QModelIndex& current); }; class DiveLocationLineEdit : public QLineEdit { @@ -90,6 +94,7 @@ public: signals: void diveSiteSelected(uint32_t uuid); void entered(const QModelIndex& index); + void currentChanged(const QModelIndex& index); protected: void keyPressEvent(QKeyEvent *ev); diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index ba345d938..b6266eb33 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -58,6 +58,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), connect(ui.editDiveSiteButton, SIGNAL(clicked()), MainWindow::instance(), SIGNAL(startDiveSiteEdit())); #ifndef NO_MARBLE connect(ui.location, &DiveLocationLineEdit::entered, GlobeGPS::instance(), &GlobeGPS::centerOnIndex); + connect(ui.location, &DiveLocationLineEdit::currentChanged, GlobeGPS::instance(), &GlobeGPS::centerOnIndex); #endif QAction *action = new QAction(tr("Apply changes"), this); -- cgit v1.2.3-70-g09d2