Revert to the old values of Cylinders and Weigthsystems on cancel

This patch enables canceling the edition of cylinders and weigth
systems, as soon as the user press cancel, the old values are
re-populated on all selected entries.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
Tomaz Canabrava 2013-09-25 14:10:15 -03:00
parent 4f0112c420
commit 26cec576ee
2 changed files with 21 additions and 0 deletions

View file

@ -148,6 +148,14 @@ void MainTab::enableEdition()
notesBackup[mydive].airtemp = get_temperature_string(mydive->airtemp, true);
notesBackup[mydive].watertemp = get_temperature_string(mydive->watertemp, true);
notesBackup[mydive].datetime = QDateTime::fromTime_t(mydive->when - gettimezoneoffset()).toString(QString("M/d/yy h:mm"));
// maybe this is a place for memset?
for (int i = 0; i < MAX_CYLINDERS; i++) {
notesBackup[mydive].cylinders[i] = mydive->cylinder[i];
}
for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) {
notesBackup[mydive].weigthsystem[i] = mydive->weightsystem[i];
}
}
editMode = DIVE;
}
@ -507,7 +515,18 @@ void MainTab::rejectChanges()
mydive->longitude = notesBackup[mydive].longitude;
mydive->rating = notesBackup[mydive].rating;
mydive->visibility = notesBackup[mydive].visibility;
// maybe this is a place for memset?
for (int i = 0; i < MAX_CYLINDERS; i++) {
mydive->cylinder[i] = notesBackup[mydive].cylinders[i];
}
for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) {
mydive->weightsystem[i] = notesBackup[mydive].weigthsystem[i];
}
}
multiEditEquipmentPlaceholder = *get_dive(selected_dive);
cylindersModel->setDive(&multiEditEquipmentPlaceholder);
weightModel->setDive(&multiEditEquipmentPlaceholder);
}
ui->diveNotesMessage->animatedHide();

View file

@ -34,6 +34,8 @@ struct NotesBackup{
int rating;
int visibility;
QString divemaster;
cylinder_t cylinders[MAX_CYLINDERS];
weightsystem_t weigthsystem[MAX_WEIGHTSYSTEMS ];
};
struct Completers{