mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Planner: set up a cylinder, even if no current dive is selected
If there was no current dive we didn't set up any cylinder at all which was a bit awkward as we use AIR but have no cylinder corresponding to it, which breaks assumptions elsewhere. Instead we use either the default cylinder or make one up. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									5afabfc9eb
								
							
						
					
					
						commit
						412317c91f
					
				
					 3 changed files with 27 additions and 10 deletions
				
			
		|  | @ -6,9 +6,9 @@ | |||
| #include "maintab.h" | ||||
| #include "tableview.h" | ||||
| 
 | ||||
| #include "../dive.h" | ||||
| #include "../divelist.h" | ||||
| #include "../planner.h" | ||||
| #include "dive.h" | ||||
| #include "divelist.h" | ||||
| #include "planner.h" | ||||
| #include "display.h" | ||||
| #include "helpers.h" | ||||
| 
 | ||||
|  | @ -23,6 +23,7 @@ | |||
| #include <QColor> | ||||
| 
 | ||||
| #include <algorithm> | ||||
| #include <string.h> | ||||
| 
 | ||||
| #define TIME_INITIAL_MAX 30 | ||||
| 
 | ||||
|  | @ -110,9 +111,28 @@ void DivePlannerPointsModel::copyCylinders(dive *d) | |||
| 	copy_cylinders(stagingDive, d); | ||||
| } | ||||
| 
 | ||||
| void DivePlannerPointsModel::copyCylindersFrom(dive *d) | ||||
| // copy the tanks from the current dive, or the default cylinder
 | ||||
| // or an unknown cylinder
 | ||||
| // setup the cylinder widget accordingly
 | ||||
| void DivePlannerPointsModel::setupCylinders() | ||||
| { | ||||
| 	copy_cylinders(d, stagingDive); | ||||
| 	if (!stagingDive) | ||||
| 		return; | ||||
| 
 | ||||
| 	if (current_dive) { | ||||
| 		copy_cylinders(current_dive, stagingDive); | ||||
| 	} else { | ||||
| 		if (!same_string(prefs.default_cylinder, "")) { | ||||
| 			fill_default_cylinder(&stagingDive->cylinder[0]); | ||||
| 		} else { | ||||
| 			// roughly an AL80
 | ||||
| 			stagingDive->cylinder[0].type.description = strdup(tr("unknown").toUtf8().constData()); | ||||
| 			stagingDive->cylinder[0].type.size.mliter = 11100; | ||||
| 			stagingDive->cylinder[0].type.workingpressure.mbar = 207000; | ||||
| 			stagingDive->cylinder[0].used = true; | ||||
| 		} | ||||
| 	} | ||||
| 	CylindersModel::instance()->copyFromDive(stagingDive); | ||||
| } | ||||
| 
 | ||||
| QStringList &DivePlannerPointsModel::getGasList() | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue