Improve on location auto-gps editing

Michael Andreen harv at ruin.nu
Mon Nov 11 12:22:27 UTC 2013


On Tuesday 12 November 2013 02:21:47 Linus Torvalds wrote:
> Tomaz - maybe there is some nicer way to embed that "set_by_hand" flag
> into the actual ui data structure. This separate flag is kind of hacky,
> to say the least. Possibly together with a helper wrapper that does that
> whole
> 
>     ui.coordinates->setText(printGPSCoords(d->latitude.udeg,
> d->longitude.udeg));
> 
> initialization?

It should be possible to use the modified state of the widget, something like:

diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 0c0d99a..ac76c1d 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -287,6 +287,7 @@ void MainTab::updateDiveInfo(int dive)
        UPDATE_TEMP(d, watertemp);
        if (d) {
                ui.coordinates->setText(printGPSCoords(d->latitude.udeg, d->longitude.udeg));
+               ui.coordinates->setModified(d->latitude.udeg || d->longitude.udeg);
                ui.dateTimeEdit->setDateTime(QDateTime::fromTime_t(d->when - gettimezoneoffset()));
                if (mainWindow() && mainWindow()->dive_list()->selectedTrips.count() == 1) {
                        // only use trip relevant fields
@@ -450,6 +451,7 @@ void MainTab::acceptChanges()
                struct dive *curr = current_dive;
                //Reset coordinates field, in case it contains garbage.
                ui.coordinates->setText(printGPSCoords(current_dive->latitude.udeg, current_dive->longitude.udeg));
+               ui.coordinates->setModified(current_dive->latitude.udeg || current_dive->longitude.udeg);
                if (notesBackup[curr].buddy != ui.buddy->text() ||
                        notesBackup[curr].suit != ui.suit->text() ||
                        notesBackup[curr].notes != ui.notes->toPlainText() ||
@@ -556,6 +558,7 @@ void MainTab::rejectChanges()
                ui.notes->setText(notesBackup[curr].notes );
                ui.location->setText(notesBackup[curr].location);
                ui.coordinates->setText(notesBackup[curr].coordinates);
+               ui.coordinates->setModified(curr->latitude.udeg || curr->longitude.udeg);
                ui.buddy->setText(notesBackup[curr].buddy);
                ui.suit->setText(notesBackup[curr].suit);
                ui.divemaster->setText(notesBackup[curr].divemaster);



More information about the subsurface mailing list