mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Make gaschange from contex menu act as a gaschange
so it affect no longer the previous leg but all the following ones with the same gas (i.e. until the next gaschange). This makes the add dive/planner behaviour more consistent with the rest of the program regarding gas changes. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									907ccb0b71
								
							
						
					
					
						commit
						043bd3afb7
					
				
					 2 changed files with 14 additions and 1 deletions
				
			
		|  | @ -241,7 +241,7 @@ void DiveHandler::changeGas() | |||
| { | ||||
| 	QAction *action = qobject_cast<QAction *>(sender()); | ||||
| 	QModelIndex index = plannerModel->index(parentIndex(), DivePlannerPointsModel::GAS); | ||||
| 	plannerModel->setData(index, action->text()); | ||||
| 	plannerModel->gaschange(index.sibling(index.row() + 1, index.column()), action->text()); | ||||
| } | ||||
| 
 | ||||
| void DiveHandler::mouseMoveEvent(QGraphicsSceneMouseEvent *event) | ||||
|  | @ -741,6 +741,18 @@ bool DivePlannerPointsModel::setData(const QModelIndex &index, const QVariant &v | |||
| 	return QAbstractItemModel::setData(index, value, role); | ||||
| } | ||||
| 
 | ||||
| void DivePlannerPointsModel::gaschange(const QModelIndex &index, QString newgas) | ||||
| { | ||||
| 	int i = index.row(); | ||||
| 	gasmix oldgas = divepoints[i].gasmix; | ||||
| 	gasmix gas = { 0 }; | ||||
| 	if (!validate_gas(newgas.toUtf8().data(), &gas)) | ||||
| 		return; | ||||
| 	while (i < plannerModel->rowCount() && gasmix_distance(&oldgas, &divepoints[i].gasmix) == 0) | ||||
| 		divepoints[i++].gasmix = gas; | ||||
| 	emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1)); | ||||
| } | ||||
| 
 | ||||
| QVariant DivePlannerPointsModel::headerData(int section, Qt::Orientation orientation, int role) const | ||||
| { | ||||
| 	if (role == Qt::DisplayRole && orientation == Qt::Horizontal) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue