mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 13:10:19 +00:00
Handle double clicks on globe during dive edit mode
When we are editing or adding a dive, the globe widget needs to act differently. Instead of directly changing the lat/lon of selected dives, it needs populate the coordinate text field as if this information was entered by the user (effectively all it is is a way to more conveniently enter coordinates). As a side effect, this also allows us to change the location once it has been added (you just need to go into dive edit mode to do so). There is one weird issue that occasionally (and I can't quite reproduce this) I get lat/lon very close to 0/0 (as if the globe widget was centered on 0/0 and not on whatever it is actually showing). That still needs to be addressed. Fixes #239 Fixes #131 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
0877d93457
commit
7886719443
4 changed files with 26 additions and 1 deletions
|
@ -212,6 +212,16 @@ void GlobeGPS::prepareForGetDiveCoordinates(dive* dive)
|
|||
editingDiveCoords = dive;
|
||||
}
|
||||
|
||||
void GlobeGPS::diveEditMode()
|
||||
{
|
||||
if (messageWidget->isVisible())
|
||||
messageWidget->animatedHide();
|
||||
messageWidget->setMessageType(KMessageWidget::Warning);
|
||||
messageWidget->setText(QObject::tr("Editing dive - move the map and double-click to set the dive location"));
|
||||
messageWidget->setWordWrap(true);
|
||||
messageWidget->animatedShow();
|
||||
}
|
||||
|
||||
void GlobeGPS::changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::Unit unit)
|
||||
{
|
||||
// convert to degrees if in radian.
|
||||
|
@ -241,7 +251,12 @@ void GlobeGPS::changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::U
|
|||
void GlobeGPS::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
qreal lat, lon;
|
||||
if (editingDiveCoords && geoCoordinates(event->pos().x(), event->pos().y(), lon, lat, GeoDataCoordinates::Degree)) {
|
||||
// there could be two scenarios that got us here; let's check if we are editing a dive
|
||||
if (mainWindow()->information()->isEditing() &&
|
||||
geoCoordinates(event->pos().x(), event->pos().y(), lon, lat, GeoDataCoordinates::Degree)) {
|
||||
mainWindow()->information()->updateCoordinatesText(lat, lon);
|
||||
} else if (editingDiveCoords &&
|
||||
geoCoordinates(event->pos().x(), event->pos().y(), lon, lat, GeoDataCoordinates::Degree)) {
|
||||
changeDiveGeoPosition(lon, lat, GeoDataCoordinates::Degree);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ public:
|
|||
GlobeGPS(QWidget *parent);
|
||||
void reload();
|
||||
void centerOn(struct dive* dive);
|
||||
void diveEditMode();
|
||||
|
||||
protected:
|
||||
/* reimp */ void resizeEvent(QResizeEvent *event);
|
||||
|
|
|
@ -123,6 +123,7 @@ void MainTab::enableEdition(EditMode newEditMode)
|
|||
return;
|
||||
|
||||
mainWindow()->dive_list()->setEnabled(false);
|
||||
mainWindow()->globe()->diveEditMode();
|
||||
// We may be editing one or more dives here. backup everything.
|
||||
notesBackup.clear();
|
||||
ui.notesButtonBox->show();
|
||||
|
@ -835,6 +836,13 @@ QString MainTab::printGPSCoords(int lat, int lon)
|
|||
return result;
|
||||
}
|
||||
|
||||
void MainTab::updateCoordinatesText(qreal lat, qreal lon)
|
||||
{
|
||||
int ulat = rint(lat * 1000000);
|
||||
int ulon = rint(lon * 1000000);
|
||||
ui.coordinates->setText(printGPSCoords(ulat, ulon));
|
||||
}
|
||||
|
||||
void MainTab::updateGpsCoordinates(const struct dive *dive)
|
||||
{
|
||||
if (dive) {
|
||||
|
|
|
@ -59,6 +59,7 @@ public:
|
|||
void initialUiSetup();
|
||||
void equipmentPlusUpdate();
|
||||
bool isEditing();
|
||||
void updateCoordinatesText(qreal lat, qreal lon);
|
||||
public slots:
|
||||
void addCylinder_clicked();
|
||||
void addWeight_clicked();
|
||||
|
|
Loading…
Reference in a new issue