summaryrefslogtreecommitdiffstats
path: root/qt-ui/maintab.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-02 21:33:03 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-07-03 09:37:55 -0700
commit66870add77e62b95d15cc6a8e76838cc0462a77f (patch)
treedbe66ced05037216c2e7e534f8fd9523b6946adc /qt-ui/maintab.cpp
parent20d9fafd7cc5d5b0fde5a4ace8c59d6bfed20c75 (diff)
downloadsubsurface-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.cpp22
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(&current_dive->cylinder[0], &displayed_dive.cylinder[0], sizeof(cylinder_t) * MAX_CYLINDERS) ||
+ memcmp(&current_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