diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-07-02 21:33:03 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-07-03 09:37:55 -0700 |
commit | 66870add77e62b95d15cc6a8e76838cc0462a77f (patch) | |
tree | dbe66ced05037216c2e7e534f8fd9523b6946adc /qt-ui/maintab.cpp | |
parent | 20d9fafd7cc5d5b0fde5a4ace8c59d6bfed20c75 (diff) | |
download | subsurface-66870add77e62b95d15cc6a8e76838cc0462a77f.tar.gz |
UI restructure: track if any data was modified
Instead of comparing the dive structures (which doesn't work since the
strings are actually copies), track if the user made changes.
Cylinders and weights still need to be compared as they are handled in
different widgets.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/maintab.cpp')
-rw-r--r-- | qt-ui/maintab.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 049ad7fb7..69adb6cda 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -251,6 +251,7 @@ void MainTab::enableEdition(EditMode newEditMode) { if (current_dive == NULL || editMode != NONE) return; + modified = false; if ((newEditMode == DIVE || newEditMode == NONE) && current_dive->dc.model && strcmp(current_dive->dc.model, "manually added dive") == 0) { @@ -818,7 +819,11 @@ void MainTab::resetPallete() void MainTab::rejectChanges() { EditMode lastMode = editMode; - if (lastMode != NONE && current_dive && memcmp(&displayed_dive, current_dive, sizeof(struct dive))) { + + if (lastMode != NONE && current_dive && + (modified || + memcmp(¤t_dive->cylinder[0], &displayed_dive.cylinder[0], sizeof(cylinder_t) * MAX_CYLINDERS) || + memcmp(¤t_dive->cylinder[0], &displayed_dive.weightsystem[0], sizeof(weightsystem_t) * MAX_WEIGHTSYSTEMS))) { if (QMessageBox::warning(MainWindow::instance(), TITLE_OR_TEXT(tr("Discard the Changes?"), tr("You are about to discard your changes.")), QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard) != QMessageBox::Discard) { @@ -889,13 +894,14 @@ void MainTab::rejectChanges() } #undef EDIT_TEXT2 -void markChangedWidget(QWidget *w) +void MainTab::markChangedWidget(QWidget *w) { QPalette p; qreal h, s, l, a; qApp->palette().color(QPalette::Text).getHslF(&h, &s, &l, &a); p.setBrush(QPalette::Base, (l <= 0.3) ? QColor(Qt::yellow).lighter() : (l <= 0.6) ? QColor(Qt::yellow).light() : /* else */ QColor(Qt::yellow).darker(300)); w->setPalette(p); + modified = true; } void MainTab::on_buddy_textChanged() @@ -1082,15 +1088,21 @@ void MainTab::on_coordinates_textChanged(const QString &text) void MainTab::on_rating_valueChanged(int value) { - displayed_dive.rating = value; + if (displayed_dive.rating != value) { + displayed_dive.rating = value; + modified = true; + } } void MainTab::on_visibility_valueChanged(int value) { - displayed_dive.visibility = value; + if (displayed_dive.visibility != value) { + displayed_dive.visibility = value; + modified = true; + } } -#undef MODIFY_SELECTED_DIVESVES +#undef MODIFY_SELECTED_DIVES #undef EDIT_TEXT #undef EDIT_VALUE |