Fix reject changes for add/edit

Reject changes was correct only for Edit, but not for Add. When in add
mode we need to retrieve the old dive site, and when in edit mode we
should do nothing.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2015-06-04 00:30:26 -03:00 committed by Dirk Hohndel
parent af22ebf3f1
commit 8ff7826302

View file

@ -113,10 +113,15 @@ void LocationInformationWidget::createDiveSite()
void LocationInformationWidget::rejectChanges()
{
if (currentDs && dive_site_is_empty(currentDs)) {
if (current_mode == CREATE_DIVE_SITE) {
LocationInformationModel::instance()->removeRow(get_divesite_idx(currentDs));
displayed_dive.dive_site_uuid = 0;
if (displayed_dive.dive_site_uuid) {
displayed_dive_site = *get_dive_site_by_uuid(displayed_dive.dive_site_uuid);
}
} else if ((currentDs && dive_site_is_empty(currentDs))) {
LocationInformationModel::instance()->removeRow(get_divesite_idx(currentDs));
}
resetState();
emit stopFilterDiveSite();
emit informationManagementEnded();