mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	QML UI: add function to get cylinder pressures
Since we only show the first cylinder we can also only edit the first cylinder. Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									9c5b97e6cf
								
							
						
					
					
						commit
						f3b35d175a
					
				
					 2 changed files with 28 additions and 1 deletions
				
			
		|  | @ -7,7 +7,7 @@ | |||
| #include "../helpers.h" | ||||
| 
 | ||||
| static QString EMPTY_DIVE_STRING = QStringLiteral("--"); | ||||
| 
 | ||||
| enum returnPressureSelector {START_PRESSURE, END_PRESSURE}; | ||||
| 
 | ||||
| static QString getFormattedWeight(struct dive *dive, unsigned int idx) | ||||
| { | ||||
|  | @ -33,6 +33,17 @@ static QString getFormattedCylinder(struct dive *dive, unsigned int idx) | |||
| 	return fmt; | ||||
| } | ||||
| 
 | ||||
| static QString getPressures(struct dive *dive, enum returnPressureSelector ret) | ||||
| { | ||||
| 	cylinder_t *cyl = &dive->cylinder[0]; | ||||
| 	QString fmt; | ||||
| 	if (ret == START_PRESSURE) | ||||
| 		fmt = get_pressure_string(cyl->start, true); | ||||
| 	if (ret == END_PRESSURE) | ||||
| 		fmt = get_pressure_string(cyl->end, true); | ||||
| 	return fmt; | ||||
| } | ||||
| 
 | ||||
| DiveObjectHelper::DiveObjectHelper(struct dive *d) : | ||||
| 	m_dive(d) | ||||
| { | ||||
|  | @ -269,3 +280,15 @@ QString DiveObjectHelper::getCylinder() const | |||
| 	} | ||||
| 	return getCylinder; | ||||
| } | ||||
| 
 | ||||
| QString DiveObjectHelper::startPressure() const | ||||
| { | ||||
| 	QString startPressure = getPressures(m_dive, START_PRESSURE); | ||||
| 	return startPressure; | ||||
| } | ||||
| 
 | ||||
| QString DiveObjectHelper::endPressure() const | ||||
| { | ||||
| 	QString endPressure = getPressures(m_dive, END_PRESSURE); | ||||
| 	return endPressure; | ||||
| } | ||||
|  |  | |||
|  | @ -35,6 +35,8 @@ class DiveObjectHelper : public QObject { | |||
| 	Q_PROPERTY(QString otu READ otu CONSTANT) | ||||
| 	Q_PROPERTY(QString sumWeight READ sumWeight CONSTANT) | ||||
|     Q_PROPERTY(QString getCylinder READ getCylinder CONSTANT) | ||||
|     Q_PROPERTY(QString startPressure READ startPressure CONSTANT) | ||||
|     Q_PROPERTY(QString endPressure READ endPressure CONSTANT) | ||||
| public: | ||||
| 	DiveObjectHelper(struct dive *dive = NULL); | ||||
| 	~DiveObjectHelper(); | ||||
|  | @ -68,6 +70,8 @@ public: | |||
| 	QString otu() const; | ||||
| 	QString sumWeight() const; | ||||
| 	QString getCylinder() const; | ||||
| 	QString startPressure() const; | ||||
| 	QString endPressure() const; | ||||
| 
 | ||||
| private: | ||||
| 	struct dive *m_dive; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue