mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Handle add dive cancel correctly
This should leave the program in a consistent state after add dive was cancelled (and do the right thing in case the dive list was empty). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									a683a217b9
								
							
						
					
					
						commit
						662b1061f0
					
				
					 2 changed files with 5 additions and 3 deletions
				
			
		|  | @ -544,6 +544,7 @@ void MainTab::resetPallete() | ||||||
| 
 | 
 | ||||||
| void MainTab::rejectChanges() | void MainTab::rejectChanges() | ||||||
| { | { | ||||||
|  | 	EditMode lastMode = editMode; | ||||||
| 	tabBar()->setTabIcon(0, QIcon()); // Notes
 | 	tabBar()->setTabIcon(0, QIcon()); // Notes
 | ||||||
| 	tabBar()->setTabIcon(1, QIcon()); // Equipment
 | 	tabBar()->setTabIcon(1, QIcon()); // Equipment
 | ||||||
| 
 | 
 | ||||||
|  | @ -552,11 +553,11 @@ void MainTab::rejectChanges() | ||||||
| 		ui.notes->setText(notesBackup[NULL].notes ); | 		ui.notes->setText(notesBackup[NULL].notes ); | ||||||
| 		ui.location->setText(notesBackup[NULL].location); | 		ui.location->setText(notesBackup[NULL].location); | ||||||
| 	} else { | 	} else { | ||||||
| 		if (editMode == ADD) { | 		if (lastMode == ADD) { | ||||||
| 			// clean up
 | 			// clean up
 | ||||||
| 			DivePlannerPointsModel::instance()->cancelPlan(); | 			DivePlannerPointsModel::instance()->cancelPlan(); | ||||||
| 			delete_single_dive(selected_dive); | 			delete_single_dive(selected_dive); | ||||||
| 		} else if (editMode == MANUALLY_ADDED_DIVE ) { | 		} else if (lastMode == MANUALLY_ADDED_DIVE ) { | ||||||
| 			DivePlannerPointsModel::instance()->undoEdition(); // that's BOGUS... just copy the original dive back and be done with it...
 | 			DivePlannerPointsModel::instance()->undoEdition(); // that's BOGUS... just copy the original dive back and be done with it...
 | ||||||
| 		} | 		} | ||||||
| 		struct dive *curr = current_dive; | 		struct dive *curr = current_dive; | ||||||
|  | @ -617,7 +618,7 @@ void MainTab::rejectChanges() | ||||||
| 	ui.equipmentButtonBox->hide(); | 	ui.equipmentButtonBox->hide(); | ||||||
| 	notesBackup.clear(); | 	notesBackup.clear(); | ||||||
| 	resetPallete(); | 	resetPallete(); | ||||||
| 	if (editMode == ADD || editMode == MANUALLY_ADDED_DIVE) { | 	if (lastMode == ADD || lastMode == MANUALLY_ADDED_DIVE) { | ||||||
| 		// more clean up
 | 		// more clean up
 | ||||||
| 		updateDiveInfo(selected_dive); | 		updateDiveInfo(selected_dive); | ||||||
| 		mainWindow()->showProfile(); | 		mainWindow()->showProfile(); | ||||||
|  |  | ||||||
|  | @ -68,6 +68,7 @@ MainWindow::MainWindow() : helpView(0) | ||||||
| void MainWindow::refreshDisplay() | void MainWindow::refreshDisplay() | ||||||
| { | { | ||||||
| 	ui.InfoWidget->reload(); | 	ui.InfoWidget->reload(); | ||||||
|  | 	ui.ProfileWidget->refresh(); | ||||||
| 	ui.globe->reload(); | 	ui.globe->reload(); | ||||||
| 	ui.ListWidget->reload(DiveTripModel::CURRENT); | 	ui.ListWidget->reload(DiveTripModel::CURRENT); | ||||||
| 	ui.ListWidget->setFocus(); | 	ui.ListWidget->setFocus(); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue