mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Change get_dive_by_diveid to get_dive_by_uniq_id
The original name was a really bad choice as we have a 'diveid' as part of struct divecomputer - and that is not the diveid that is being used here. Instead we use the 'id' member of struct dive which holds the "unique ID" for this dive. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									c4899aa8f1
								
							
						
					
					
						commit
						cae51ff0aa
					
				
					 5 changed files with 15 additions and 15 deletions
				
			
		
							
								
								
									
										2
									
								
								dive.h
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								dive.h
									
										
									
									
									
								
							|  | @ -436,7 +436,7 @@ static inline struct dive *get_dive_by_uemis_diveid(uint32_t diveid, uint32_t de | ||||||
| 	return NULL; | 	return NULL; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static inline struct dive *get_dive_by_diveid(int id) | static inline struct dive *get_dive_by_uniq_id(int id) | ||||||
| { | { | ||||||
| 	int i; | 	int i; | ||||||
| 	struct dive *dive = NULL; | 	struct dive *dive = NULL; | ||||||
|  |  | ||||||
|  | @ -1056,7 +1056,7 @@ static int nitrox_sort_value(struct dive *dive) | ||||||
| QVariant DiveItem::data(int column, int role) const | QVariant DiveItem::data(int column, int role) const | ||||||
| { | { | ||||||
| 	QVariant retVal; | 	QVariant retVal; | ||||||
| 	struct dive *dive = get_dive_by_diveid(diveId); | 	struct dive *dive = get_dive_by_uniq_id(diveId); | ||||||
| 
 | 
 | ||||||
| 	switch (role) { | 	switch (role) { | ||||||
| 	case Qt::TextAlignmentRole: | 	case Qt::TextAlignmentRole: | ||||||
|  | @ -1203,7 +1203,7 @@ bool DiveItem::setData(const QModelIndex &index, const QVariant &value, int role | ||||||
| 		if (d->number == v) | 		if (d->number == v) | ||||||
| 			return false; | 			return false; | ||||||
| 	} | 	} | ||||||
| 	d = get_dive_by_diveid(diveId); | 	d = get_dive_by_uniq_id(diveId); | ||||||
| 	d->number = value.toInt(); | 	d->number = value.toInt(); | ||||||
| 	mark_divelist_changed(true); | 	mark_divelist_changed(true); | ||||||
| 	return true; | 	return true; | ||||||
|  | @ -1211,7 +1211,7 @@ bool DiveItem::setData(const QModelIndex &index, const QVariant &value, int role | ||||||
| 
 | 
 | ||||||
| QString DiveItem::displayDate() const | QString DiveItem::displayDate() const | ||||||
| { | { | ||||||
| 	struct dive *dive = get_dive_by_diveid(diveId); | 	struct dive *dive = get_dive_by_uniq_id(diveId); | ||||||
| 	return get_dive_date_string(dive->when); | 	return get_dive_date_string(dive->when); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -1219,7 +1219,7 @@ QString DiveItem::displayDepth() const | ||||||
| { | { | ||||||
| 	QString fract, str; | 	QString fract, str; | ||||||
| 	const int scale = 1000; | 	const int scale = 1000; | ||||||
| 	struct dive *dive = get_dive_by_diveid(diveId); | 	struct dive *dive = get_dive_by_uniq_id(diveId); | ||||||
| 	if (get_units()->length == units::METERS) { | 	if (get_units()->length == units::METERS) { | ||||||
| 		fract = QString::number((unsigned)(dive->maxdepth.mm % scale) / 100); | 		fract = QString::number((unsigned)(dive->maxdepth.mm % scale) / 100); | ||||||
| 		str = QString("%1.%2").arg((unsigned)(dive->maxdepth.mm / scale)).arg(fract, 1, QChar('0')); | 		str = QString("%1.%2").arg((unsigned)(dive->maxdepth.mm / scale)).arg(fract, 1, QChar('0')); | ||||||
|  | @ -1233,7 +1233,7 @@ QString DiveItem::displayDepth() const | ||||||
| QString DiveItem::displayDuration() const | QString DiveItem::displayDuration() const | ||||||
| { | { | ||||||
| 	int hrs, mins, secs; | 	int hrs, mins, secs; | ||||||
| 	struct dive *dive = get_dive_by_diveid(diveId); | 	struct dive *dive = get_dive_by_uniq_id(diveId); | ||||||
| 	secs = dive->duration.seconds % 60; | 	secs = dive->duration.seconds % 60; | ||||||
| 	mins = dive->duration.seconds / 60; | 	mins = dive->duration.seconds / 60; | ||||||
| 	hrs = mins / 60; | 	hrs = mins / 60; | ||||||
|  | @ -1251,7 +1251,7 @@ QString DiveItem::displayDuration() const | ||||||
| QString DiveItem::displayTemperature() const | QString DiveItem::displayTemperature() const | ||||||
| { | { | ||||||
| 	QString str; | 	QString str; | ||||||
| 	struct dive *dive = get_dive_by_diveid(diveId); | 	struct dive *dive = get_dive_by_uniq_id(diveId); | ||||||
| 	if (!dive->watertemp.mkelvin) | 	if (!dive->watertemp.mkelvin) | ||||||
| 		return str; | 		return str; | ||||||
| 	if (get_units()->temperature == units::CELSIUS) | 	if (get_units()->temperature == units::CELSIUS) | ||||||
|  | @ -1264,7 +1264,7 @@ QString DiveItem::displayTemperature() const | ||||||
| QString DiveItem::displaySac() const | QString DiveItem::displaySac() const | ||||||
| { | { | ||||||
| 	QString str; | 	QString str; | ||||||
| 	struct dive *dive = get_dive_by_diveid(diveId); | 	struct dive *dive = get_dive_by_uniq_id(diveId); | ||||||
| 	if (get_units()->volume == units::LITER) | 	if (get_units()->volume == units::LITER) | ||||||
| 		str = QString::number(dive->sac / 1000.0, 'f', 1).append(tr(" l/min")); | 		str = QString::number(dive->sac / 1000.0, 'f', 1).append(tr(" l/min")); | ||||||
| 	else | 	else | ||||||
|  | @ -1280,7 +1280,7 @@ QString DiveItem::displayWeight() const | ||||||
| 
 | 
 | ||||||
| int DiveItem::weight() const | int DiveItem::weight() const | ||||||
| { | { | ||||||
| 	struct dive *dive = get_dive_by_diveid(diveId); | 	struct dive *dive = get_dive_by_uniq_id(diveId); | ||||||
| 	weight_t tw = { total_weight(dive) }; | 	weight_t tw = { total_weight(dive) }; | ||||||
| 	return tw.grams; | 	return tw.grams; | ||||||
| } | } | ||||||
|  | @ -1900,7 +1900,7 @@ QVariant ProfilePrintModel::data(const QModelIndex &index, int role) const | ||||||
| 
 | 
 | ||||||
| 	switch (role) { | 	switch (role) { | ||||||
| 	case Qt::DisplayRole: { | 	case Qt::DisplayRole: { | ||||||
| 		struct dive *dive = get_dive_by_diveid(diveId); | 		struct dive *dive = get_dive_by_uniq_id(diveId); | ||||||
| 		struct DiveItem di; | 		struct DiveItem di; | ||||||
| 		di.diveId = diveId; | 		di.diveId = diveId; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -178,7 +178,7 @@ void DivePlotDataModel::emitDataChanged() | ||||||
| 
 | 
 | ||||||
| void DivePlotDataModel::calculateDecompression() | void DivePlotDataModel::calculateDecompression() | ||||||
| { | { | ||||||
| 	struct dive *d = get_dive_by_diveid(id()); | 	struct dive *d = get_dive_by_uniq_id(id()); | ||||||
| 	struct divecomputer *dc = select_dc(d); | 	struct divecomputer *dc = select_dc(d); | ||||||
| 	init_decompression(d); | 	init_decompression(d); | ||||||
| 	calculate_deco_information(d, dc, &pInfo, false); | 	calculate_deco_information(d, dc, &pInfo, false); | ||||||
|  |  | ||||||
|  | @ -427,7 +427,7 @@ void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QMo | ||||||
| 	int last_pressure[MAX_CYLINDERS] = { 0, }; | 	int last_pressure[MAX_CYLINDERS] = { 0, }; | ||||||
| 	int last_time[MAX_CYLINDERS] = { 0, }; | 	int last_time[MAX_CYLINDERS] = { 0, }; | ||||||
| 	struct plot_data *entry; | 	struct plot_data *entry; | ||||||
| 	struct dive *dive = get_dive_by_diveid(dataModel->id()); | 	struct dive *dive = get_dive_by_uniq_id(dataModel->id()); | ||||||
| 
 | 
 | ||||||
| 	cyl = -1; | 	cyl = -1; | ||||||
| 	for (int i = 0, count = dataModel->rowCount(); i < count; i++) { | 	for (int i = 0, count = dataModel->rowCount(); i < count; i++) { | ||||||
|  | @ -489,7 +489,7 @@ void DiveGasPressureItem::paint(QPainter *painter, const QStyleOptionGraphicsIte | ||||||
| 	QPen pen; | 	QPen pen; | ||||||
| 	pen.setCosmetic(true); | 	pen.setCosmetic(true); | ||||||
| 	pen.setWidth(2); | 	pen.setWidth(2); | ||||||
| 	struct dive *d = get_dive_by_diveid(dataModel->id()); | 	struct dive *d = get_dive_by_uniq_id(dataModel->id()); | ||||||
| 	struct plot_data *entry = dataModel->data().entry; | 	struct plot_data *entry = dataModel->data().entry; | ||||||
| 	Q_FOREACH(const QPolygonF & poly, polygons) { | 	Q_FOREACH(const QPolygonF & poly, polygons) { | ||||||
| 		for (int i = 1, count = poly.count(); i < count; i++, entry++) { | 		for (int i = 1, count = poly.count(); i < count; i++, entry++) { | ||||||
|  |  | ||||||
|  | @ -227,7 +227,7 @@ void ProfileWidget2::replot() | ||||||
| { | { | ||||||
| 	int diveId = dataModel->id(); | 	int diveId = dataModel->id(); | ||||||
| 	dataModel->clear(); | 	dataModel->clear(); | ||||||
| 	plotDives(QList<dive *>() << get_dive_by_diveid(diveId)); | 	plotDives(QList<dive *>() << get_dive_by_uniq_id(diveId)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ProfileWidget2::setupItemSizes() | void ProfileWidget2::setupItemSizes() | ||||||
|  | @ -808,7 +808,7 @@ void ProfileWidget2::changeGas() | ||||||
| 	int diveId = dataModel->id(); | 	int diveId = dataModel->id(); | ||||||
| 	int o2, he; | 	int o2, he; | ||||||
| 	int seconds = timeAxis->valueAt(scenePos); | 	int seconds = timeAxis->valueAt(scenePos); | ||||||
| 	struct dive *d = get_dive_by_diveid(diveId); | 	struct dive *d = get_dive_by_uniq_id(diveId); | ||||||
| 
 | 
 | ||||||
| 	validate_gas(gas.toUtf8().constData(), &o2, &he); | 	validate_gas(gas.toUtf8().constData(), &o2, &he); | ||||||
| 	add_gas_switch_event(d, get_dive_dc(d, diveComputer), seconds, get_gasidx(d, o2, he)); | 	add_gas_switch_event(d, get_dive_dc(d, diveComputer), seconds, get_gasidx(d, o2, he)); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue