summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/locationinformation.cpp
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2017-11-27 00:26:46 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2017-11-27 22:59:22 +0100
commita084ea5b261b10d336f7a474a5b57705550d8825 (patch)
treec27cc5ca6905f340a2eddd268e62d903e4fa2b78 /desktop-widgets/locationinformation.cpp
parentfe69b304b2496233142d9018ab5c6a7675ea089c (diff)
downloadsubsurface-a084ea5b261b10d336f7a474a5b57705550d8825.tar.gz
locationinformation: don't update map location on typing
Currently when the user is typing new coordinates the marker on the map changes location right away. Disable that and add a 'flag' button that should be pressed instead. Also make the coordinates update when pressing Enter or when the text field loses focus. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'desktop-widgets/locationinformation.cpp')
-rw-r--r--desktop-widgets/locationinformation.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/desktop-widgets/locationinformation.cpp b/desktop-widgets/locationinformation.cpp
index ad00198b7..454c4c68f 100644
--- a/desktop-widgets/locationinformation.cpp
+++ b/desktop-widgets/locationinformation.cpp
@@ -38,6 +38,9 @@ LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBo
connect(ui.geoCodeButton, SIGNAL(clicked()), this, SLOT(reverseGeocode()));
connect(this, SIGNAL(nameChanged(const QString &, const QString &)),
LocationFilterModel::instance(), SLOT(changeName(const QString &, const QString &)));
+ connect(ui.updateLocationButton, SIGNAL(clicked()), this, SLOT(updateLocationOnMap()));
+ connect(ui.diveSiteCoordinates, SIGNAL(returnPressed()), this, SLOT(updateLocationOnMap()));
+ ui.diveSiteCoordinates->installEventFilter(this);
SsrfSortFilterProxyModel *filter_model = new SsrfSortFilterProxyModel(this);
filter_model->setSourceModel(LocationInformationModel::instance());
@@ -58,7 +61,7 @@ LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBo
MapWidget::instance(), &MapWidget::updateCurrentDiveSiteCoordinatesToMap);
}
-bool LocationInformationWidget::eventFilter(QObject *, QEvent *ev)
+bool LocationInformationWidget::eventFilter(QObject *object, QEvent *ev)
{
if (ev->type() == QEvent::ContextMenu) {
QContextMenuEvent *ctx = (QContextMenuEvent *)ev;
@@ -66,10 +69,18 @@ bool LocationInformationWidget::eventFilter(QObject *, QEvent *ev)
contextMenu.addAction(tr("Merge into current site"), this, SLOT(mergeSelectedDiveSites()));
contextMenu.exec(ctx->globalPos());
return true;
+ } else if (ev->type() == QEvent::FocusOut && object == ui.diveSiteCoordinates) {
+ emit coordinatesChanged();
}
return false;
}
+void LocationInformationWidget::enableLocationButtons(bool enable)
+{
+ ui.geoCodeButton->setEnabled(enable);
+ ui.updateLocationButton->setEnabled(enable);
+}
+
void LocationInformationWidget::mergeSelectedDiveSites()
{
if (QMessageBox::warning(MainWindow::instance(), tr("Merging dive sites"),
@@ -137,7 +148,7 @@ void LocationInformationWidget::updateGpsCoordinates()
QString oldText = ui.diveSiteCoordinates->text();
const char *coords = printGPSCoords(displayed_dive_site.latitude.udeg, displayed_dive_site.longitude.udeg);
ui.diveSiteCoordinates->setText(coords);
- ui.geoCodeButton->setEnabled(dive_site_has_gps_location(&displayed_dive_site));
+ enableLocationButtons(dive_site_has_gps_location(&displayed_dive_site));
free((void *)coords);
if (oldText != ui.diveSiteCoordinates->text())
markChangedWidget(ui.diveSiteCoordinates);
@@ -222,7 +233,7 @@ void LocationInformationWidget::showEvent(QShowEvent *ev)
{
if (displayed_dive_site.uuid) {
updateLabels();
- ui.geoCodeButton->setEnabled(dive_site_has_gps_location(&displayed_dive_site));
+ enableLocationButtons(dive_site_has_gps_location(&displayed_dive_site));
QSortFilterProxyModel *m = qobject_cast<QSortFilterProxyModel *>(ui.diveSiteListView->model());
emit startFilterDiveSite(displayed_dive_site.uuid);
if (m)
@@ -274,10 +285,9 @@ void LocationInformationWidget::on_diveSiteCoordinates_textChanged(const QString
displayed_dive_site.latitude.udeg = lrint(latitude * 1000000);
displayed_dive_site.longitude.udeg = lrint(longitude * 1000000);
markChangedWidget(ui.diveSiteCoordinates);
- emit coordinatesChanged();
- ui.geoCodeButton->setEnabled(latitude != 0 && longitude != 0);
+ enableLocationButtons(latitude != 0 && longitude != 0);
} else {
- ui.geoCodeButton->setEnabled(false);
+ enableLocationButtons(false);
}
}
free((void *)coords);
@@ -324,6 +334,11 @@ void LocationInformationWidget::reverseGeocode()
updateLabels();
}
+void LocationInformationWidget::updateLocationOnMap()
+{
+ emit coordinatesChanged();
+}
+
DiveLocationFilterProxyModel::DiveLocationFilterProxyModel(QObject *parent)
{
Q_UNUSED(parent)