diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-11-13 22:23:59 +0900 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-11-13 22:23:59 +0900 |
commit | dee1645de010611b4571df0ef6678ee2a3115655 (patch) | |
tree | 99a91d9b04521dd3da5ab1aeca81e70e13044d72 | |
parent | 1a3ea5636a7671e18c9f220e3ba181ef62740df8 (diff) | |
download | subsurface-dee1645de010611b4571df0ef6678ee2a3115655.tar.gz |
Correct behavior when adding a dive to an empty list and canceling the add
We need to leave the widget disabled and the date / time and coordinates
cleared.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-ui/maintab.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 3dcb24df0..961686fb9 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -572,8 +572,14 @@ void MainTab::rejectChanges() ui.visibility->setCurrentStars(notesBackup[curr].visibility); ui.airtemp->setText(notesBackup[curr].airtemp); ui.watertemp->setText(notesBackup[curr].watertemp); - ui.dateTimeEdit->setDateTime(QDateTime::fromString(notesBackup[curr].datetime, QString("M/d/y h:mm"))); ui.tagWidget->setText(notesBackup[curr].tags); + // it's a little harder to do the right thing for the date time widget + if (curr) { + ui.dateTimeEdit->setDateTime(QDateTime::fromString(notesBackup[curr].datetime, QString("M/d/y h:mm"))); + } else { + QLineEdit *le = ui.dateTimeEdit->findChild<QLineEdit*>(); + le->setText(""); + } struct dive *mydive; for (int i = 0; i < dive_table.nr; i++) { @@ -610,6 +616,7 @@ void MainTab::rejectChanges() } else { cylindersModel->clear(); weightModel->clear(); + setEnabled(false); } } @@ -817,7 +824,10 @@ QString MainTab::printGPSCoords(int lat, int lon) void MainTab::updateGpsCoordinates(const struct dive *dive) { - ui.coordinates->setText(printGPSCoords(dive->latitude.udeg, dive->longitude.udeg)); - ui.coordinates->setModified(dive->latitude.udeg || dive->longitude.udeg); - + if (dive) { + ui.coordinates->setText(printGPSCoords(dive->latitude.udeg, dive->longitude.udeg)); + ui.coordinates->setModified(dive->latitude.udeg || dive->longitude.udeg); + } else { + ui.coordinates->clear(); + } } |