mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
fe69b304b2
commit
a084ea5b26
3 changed files with 46 additions and 14 deletions
|
@ -54,20 +54,20 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="2" rowspan="2" colspan="2">
|
||||
<item row="7" column="2" rowspan="2" colspan="3">
|
||||
<widget class="QPlainTextEdit" name="diveSiteNotes">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::ClickFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2" colspan="2">
|
||||
<item row="1" column="2" colspan="3">
|
||||
<widget class="QLineEdit" name="diveSiteName"/>
|
||||
</item>
|
||||
<item row="5" column="2" colspan="2">
|
||||
<item row="5" column="2" colspan="3">
|
||||
<widget class="QLineEdit" name="diveSiteDescription"/>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<item row="3" column="4">
|
||||
<widget class="QToolButton" name="geoCodeButton">
|
||||
<property name="toolTip">
|
||||
<string>Reverse geo lookup</string>
|
||||
|
@ -81,7 +81,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="4">
|
||||
<item row="0" column="0" colspan="5">
|
||||
<widget class="KMessageWidget" name="diveSiteMessage">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -91,7 +91,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0" colspan="4">
|
||||
<item row="9" column="0" colspan="5">
|
||||
<widget class="QGroupBox" name="diveSiteGroupBox">
|
||||
<property name="title">
|
||||
<string>Dive sites on same coordinates</string>
|
||||
|
@ -139,7 +139,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2" colspan="2">
|
||||
<item row="4" column="2" colspan="3">
|
||||
<widget class="QLabel" name="locationTags">
|
||||
<property name="text">
|
||||
<string/>
|
||||
|
@ -153,9 +153,23 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2" colspan="2">
|
||||
<item row="2" column="2" colspan="3">
|
||||
<widget class="QLineEdit" name="diveSiteCountry"/>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QToolButton" name="updateLocationButton">
|
||||
<property name="toolTip">
|
||||
<string>Update location on map</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../subsurface.qrc">
|
||||
<normaloff>:/mapwidget-marker-selected</normaloff>:/mapwidget-marker-selected</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
@ -170,6 +184,7 @@
|
|||
<tabstop>diveSiteName</tabstop>
|
||||
<tabstop>diveSiteCountry</tabstop>
|
||||
<tabstop>diveSiteCoordinates</tabstop>
|
||||
<tabstop>updateLocationButton</tabstop>
|
||||
<tabstop>geoCodeButton</tabstop>
|
||||
<tabstop>diveSiteDescription</tabstop>
|
||||
<tabstop>diveSiteNotes</tabstop>
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -15,6 +15,7 @@ public:
|
|||
|
||||
protected:
|
||||
void showEvent(QShowEvent *);
|
||||
void enableLocationButtons(bool enable);
|
||||
|
||||
public slots:
|
||||
void acceptChanges();
|
||||
|
@ -33,6 +34,7 @@ public slots:
|
|||
void mergeSelectedDiveSites();
|
||||
private slots:
|
||||
void updateLabels();
|
||||
void updateLocationOnMap();
|
||||
signals:
|
||||
void startEditDiveSite(uint32_t uuid);
|
||||
void endEditDiveSite();
|
||||
|
|
Loading…
Add table
Reference in a new issue