mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Allow editing segment duration. This shifts all following waypoints.
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									6f1e071a54
								
							
						
					
					
						commit
						eb26823b34
					
				
					 1 changed files with 8 additions and 4 deletions
				
			
		|  | @ -388,6 +388,7 @@ bool DivePlannerPointsModel::setData(const QModelIndex &index, const QVariant &v | ||||||
| { | { | ||||||
| 	int o2 = 0; | 	int o2 = 0; | ||||||
| 	int he = 0; | 	int he = 0; | ||||||
|  | 	int i, shift; | ||||||
| 	if (role == Qt::EditRole) { | 	if (role == Qt::EditRole) { | ||||||
| 		divedatapoint &p = divepoints[index.row()]; | 		divedatapoint &p = divepoints[index.row()]; | ||||||
| 		switch (index.column()) { | 		switch (index.column()) { | ||||||
|  | @ -398,10 +399,13 @@ bool DivePlannerPointsModel::setData(const QModelIndex &index, const QVariant &v | ||||||
| 			p.time = value.toInt() * 60; | 			p.time = value.toInt() * 60; | ||||||
| 			break; | 			break; | ||||||
| 		case DURATION: | 		case DURATION: | ||||||
| 			if (index.row()) | 			i = index.row(); | ||||||
| 				p.time = value.toInt() * 60 + divepoints[index.row() - 1].time; | 			if (i) | ||||||
|  | 				shift = divepoints[i].time - divepoints[i - 1].time - value.toInt() * 60; | ||||||
| 			else | 			else | ||||||
| 				p.time = value.toInt() * 60; | 				shift = divepoints[i].time - value.toInt() * 60; | ||||||
|  | 			while (i < divepoints.size()) | ||||||
|  | 				divepoints[i++].time -= shift; | ||||||
| 			break; | 			break; | ||||||
| 		case CCSETPOINT: { | 		case CCSETPOINT: { | ||||||
| 			int po2 = 0; | 			int po2 = 0; | ||||||
|  | @ -445,7 +449,7 @@ QVariant DivePlannerPointsModel::headerData(int section, Qt::Orientation orienta | ||||||
| 
 | 
 | ||||||
| Qt::ItemFlags DivePlannerPointsModel::flags(const QModelIndex &index) const | Qt::ItemFlags DivePlannerPointsModel::flags(const QModelIndex &index) const | ||||||
| { | { | ||||||
| 	if (index.column() != DURATION && index.column() != REMOVE) | 	if (index.column() != REMOVE) | ||||||
| 		return QAbstractItemModel::flags(index) | Qt::ItemIsEditable; | 		return QAbstractItemModel::flags(index) | Qt::ItemIsEditable; | ||||||
| 	else | 	else | ||||||
| 		return QAbstractItemModel::flags(index); | 		return QAbstractItemModel::flags(index); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue