mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Whitespace fixes in dive planner
I know this may seem anal retentive... but it's driving me insane. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									9ba7b12767
								
							
						
					
					
						commit
						ff58fd7dca
					
				
					 1 changed files with 60 additions and 64 deletions
				
			
		|  | @ -37,7 +37,7 @@ QStringListModel *airTypes(){ | ||||||
| 	return self; | 	return self; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| QString strForAir(const divedatapoint& p){ | QString strForAir(const divedatapoint& p) { | ||||||
| 	return p.o2 == 209 ? QObject::tr("AIR") | 	return p.o2 == 209 ? QObject::tr("AIR") | ||||||
| 		: p.o2 == 320 ? QObject::tr("EAN32") | 		: p.o2 == 320 ? QObject::tr("EAN32") | ||||||
| 		: p.o2 == 360 ? QObject::tr("EAN36") | 		: p.o2 == 360 ? QObject::tr("EAN36") | ||||||
|  | @ -203,9 +203,9 @@ void DivePlannerGraphics::pointInserted(const QModelIndex& parent, int start , i | ||||||
| 
 | 
 | ||||||
| void DivePlannerGraphics::keyDownAction() | void DivePlannerGraphics::keyDownAction() | ||||||
| { | { | ||||||
| 	if(scene()->selectedItems().count()){ | 	if (scene()->selectedItems().count()) { | ||||||
| 		Q_FOREACH(QGraphicsItem *i, scene()->selectedItems()){ | 		Q_FOREACH(QGraphicsItem *i, scene()->selectedItems()) { | ||||||
| 			if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler*>(i)){ | 			if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler*>(i)) { | ||||||
| 				int row = handles.indexOf(handler); | 				int row = handles.indexOf(handler); | ||||||
| 				divedatapoint dp = plannerModel->at(row); | 				divedatapoint dp = plannerModel->at(row); | ||||||
| 				if (dp.depth / 1000 >= depthLine->maximum()) | 				if (dp.depth / 1000 >= depthLine->maximum()) | ||||||
|  | @ -220,8 +220,8 @@ void DivePlannerGraphics::keyDownAction() | ||||||
| 
 | 
 | ||||||
| void DivePlannerGraphics::keyUpAction() | void DivePlannerGraphics::keyUpAction() | ||||||
| { | { | ||||||
| 	Q_FOREACH(QGraphicsItem *i, scene()->selectedItems()){ | 	Q_FOREACH(QGraphicsItem *i, scene()->selectedItems()) { | ||||||
| 		if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler*>(i)){ | 		if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler*>(i)) { | ||||||
| 			int row = handles.indexOf(handler); | 			int row = handles.indexOf(handler); | ||||||
| 			divedatapoint dp = plannerModel->at(row); | 			divedatapoint dp = plannerModel->at(row); | ||||||
| 
 | 
 | ||||||
|  | @ -237,8 +237,8 @@ void DivePlannerGraphics::keyUpAction() | ||||||
| 
 | 
 | ||||||
| void DivePlannerGraphics::keyLeftAction() | void DivePlannerGraphics::keyLeftAction() | ||||||
| { | { | ||||||
| 	Q_FOREACH(QGraphicsItem *i, scene()->selectedItems()){ | 	Q_FOREACH(QGraphicsItem *i, scene()->selectedItems()) { | ||||||
| 		if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler*>(i)){ | 		if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler*>(i)) { | ||||||
| 			int row = handles.indexOf(handler); | 			int row = handles.indexOf(handler); | ||||||
| 			divedatapoint dp = plannerModel->at(row); | 			divedatapoint dp = plannerModel->at(row); | ||||||
| 
 | 
 | ||||||
|  | @ -249,8 +249,8 @@ void DivePlannerGraphics::keyLeftAction() | ||||||
| 			// maybe this is a good place for a 'goto'?
 | 			// maybe this is a good place for a 'goto'?
 | ||||||
| 			double xpos = timeLine->posAtValue((dp.time - 60) / 60); | 			double xpos = timeLine->posAtValue((dp.time - 60) / 60); | ||||||
| 			bool nextStep = false; | 			bool nextStep = false; | ||||||
| 			Q_FOREACH(DiveHandler *h, handles){ | 			Q_FOREACH(DiveHandler *h, handles) { | ||||||
| 				if (h->pos().x() == xpos){ | 				if (h->pos().x() == xpos) { | ||||||
| 					nextStep = true; | 					nextStep = true; | ||||||
| 					break; | 					break; | ||||||
| 				} | 				} | ||||||
|  | @ -266,8 +266,8 @@ void DivePlannerGraphics::keyLeftAction() | ||||||
| 
 | 
 | ||||||
| void DivePlannerGraphics::keyRightAction() | void DivePlannerGraphics::keyRightAction() | ||||||
| { | { | ||||||
| 	Q_FOREACH(QGraphicsItem *i, scene()->selectedItems()){ | 	Q_FOREACH(QGraphicsItem *i, scene()->selectedItems()) { | ||||||
| 		if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler*>(i)){ | 		if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler*>(i)) { | ||||||
| 			int row = handles.indexOf(handler); | 			int row = handles.indexOf(handler); | ||||||
| 			divedatapoint dp = plannerModel->at(row); | 			divedatapoint dp = plannerModel->at(row); | ||||||
| 			if (dp.time / 60 >= timeLine->maximum()) | 			if (dp.time / 60 >= timeLine->maximum()) | ||||||
|  | @ -277,8 +277,8 @@ void DivePlannerGraphics::keyRightAction() | ||||||
| 			// maybe this is a good place for a 'goto'?
 | 			// maybe this is a good place for a 'goto'?
 | ||||||
| 			double xpos = timeLine->posAtValue((dp.time + 60) / 60); | 			double xpos = timeLine->posAtValue((dp.time + 60) / 60); | ||||||
| 			bool nextStep = false; | 			bool nextStep = false; | ||||||
| 			Q_FOREACH(DiveHandler *h, handles){ | 			Q_FOREACH(DiveHandler *h, handles) { | ||||||
| 				if (h->pos().x() == xpos){ | 				if (h->pos().x() == xpos) { | ||||||
| 					nextStep = true; | 					nextStep = true; | ||||||
| 					break; | 					break; | ||||||
| 				} | 				} | ||||||
|  | @ -295,10 +295,10 @@ void DivePlannerGraphics::keyRightAction() | ||||||
| void DivePlannerGraphics::keyDeleteAction() | void DivePlannerGraphics::keyDeleteAction() | ||||||
| { | { | ||||||
| 	int selCount = scene()->selectedItems().count(); | 	int selCount = scene()->selectedItems().count(); | ||||||
| 	if(selCount){ | 	if(selCount) { | ||||||
| 		QVector<int> selectedIndexes; | 		QVector<int> selectedIndexes; | ||||||
| 		Q_FOREACH(QGraphicsItem *i, scene()->selectedItems()){ | 		Q_FOREACH(QGraphicsItem *i, scene()->selectedItems()) { | ||||||
| 			if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler*>(i)){ | 			if (DiveHandler *handler = qgraphicsitem_cast<DiveHandler*>(i)) { | ||||||
| 				selectedIndexes.push_back(handles.indexOf(handler)); | 				selectedIndexes.push_back(handles.indexOf(handler)); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  | @ -309,7 +309,7 @@ void DivePlannerGraphics::keyDeleteAction() | ||||||
| void DivePlannerGraphics::pointsRemoved(const QModelIndex& , int start, int end) | void DivePlannerGraphics::pointsRemoved(const QModelIndex& , int start, int end) | ||||||
| {	// start and end are inclusive.
 | {	// start and end are inclusive.
 | ||||||
| 	int num = (end - start) + 1; | 	int num = (end - start) + 1; | ||||||
| 	for(int i = num; i != 0; i--){ | 	for(int i = num; i != 0; i--) { | ||||||
| 		delete handles.back(); | 		delete handles.back(); | ||||||
| 		handles.pop_back(); | 		handles.pop_back(); | ||||||
| 		delete gases.back(); | 		delete gases.back(); | ||||||
|  | @ -319,7 +319,7 @@ void DivePlannerGraphics::pointsRemoved(const QModelIndex& , int start, int end) | ||||||
| 	drawProfile(); | 	drawProfile(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool intLessThan(int a, int b){ | bool intLessThan(int a, int b) { | ||||||
| 	return a <= b; | 	return a <= b; | ||||||
| } | } | ||||||
| void DivePlannerPointsModel::removeSelectedPoints(const QVector< int >& rows) | void DivePlannerPointsModel::removeSelectedPoints(const QVector< int >& rows) | ||||||
|  | @ -328,7 +328,7 @@ void DivePlannerPointsModel::removeSelectedPoints(const QVector< int >& rows) | ||||||
| 	QVector<int> v2 = rows; | 	QVector<int> v2 = rows; | ||||||
| 	std::sort(v2.begin(), v2.end(), intLessThan); | 	std::sort(v2.begin(), v2.end(), intLessThan); | ||||||
| 	beginRemoveRows(QModelIndex(), firstRow, rowCount()-1); | 	beginRemoveRows(QModelIndex(), firstRow, rowCount()-1); | ||||||
| 	for(int i = v2.count()-1; i >= 0; i--){ | 	for(int i = v2.count()-1; i >= 0; i--) { | ||||||
| 		divepoints.remove(v2[i]); | 		divepoints.remove(v2[i]); | ||||||
| 	} | 	} | ||||||
| 	endRemoveRows(); | 	endRemoveRows(); | ||||||
|  | @ -336,7 +336,7 @@ void DivePlannerPointsModel::removeSelectedPoints(const QVector< int >& rows) | ||||||
| 
 | 
 | ||||||
| void DivePlannerGraphics::keyEscAction() | void DivePlannerGraphics::keyEscAction() | ||||||
| { | { | ||||||
| 	if (scene()->selectedItems().count()){ | 	if (scene()->selectedItems().count()) { | ||||||
| 		scene()->clearSelection(); | 		scene()->clearSelection(); | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
|  | @ -389,15 +389,15 @@ void DivePlannerGraphics::decreaseDepth() | ||||||
| 
 | 
 | ||||||
| void DivePlannerGraphics::decreaseTime() | void DivePlannerGraphics::decreaseTime() | ||||||
| { | { | ||||||
| 	if (timeLine->maximum() -10 < TIME_INITIAL_MAX){ | 	if (timeLine->maximum() - 10 < TIME_INITIAL_MAX) { | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 	if (timeLine->maximum() - 10 < dpMaxTime){ | 	if (timeLine->maximum() - 10 < dpMaxTime) { | ||||||
| 		qDebug() << timeLine->maximum() << dpMaxTime; | 		qDebug() << timeLine->maximum() << dpMaxTime; | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 	minMinutes -= 10; | 	minMinutes -= 10; | ||||||
| 	timeLine->setMaximum(timeLine->maximum() -10); | 	timeLine->setMaximum(timeLine->maximum() - 10); | ||||||
| 	timeLine->updateTicks(); | 	timeLine->updateTicks(); | ||||||
| 	drawProfile(); | 	drawProfile(); | ||||||
| } | } | ||||||
|  | @ -447,9 +447,8 @@ void DivePlannerGraphics::drawProfile() | ||||||
| 	plannerModel->createTemporaryPlan(); | 	plannerModel->createTemporaryPlan(); | ||||||
| 	struct diveplan diveplan = plannerModel->getDiveplan(); | 	struct diveplan diveplan = plannerModel->getDiveplan(); | ||||||
| 	struct divedatapoint *dp = diveplan.dp; | 	struct divedatapoint *dp = diveplan.dp; | ||||||
| 	while(dp->next){ | 	while(dp->next) | ||||||
| 		dp = dp->next; | 		dp = dp->next; | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
| 	if (!activeDraggedHandler && (timeLine->maximum() < dp->time / 60.0 + 5 || dp->time / 60.0 + 15 < timeLine->maximum())) { | 	if (!activeDraggedHandler && (timeLine->maximum() < dp->time / 60.0 + 5 || dp->time / 60.0 + 15 < timeLine->maximum())) { | ||||||
| 		double newMax = fmax(dp->time / 60.0 + 5, minMinutes); | 		double newMax = fmax(dp->time / 60.0 + 5, minMinutes); | ||||||
|  | @ -458,7 +457,7 @@ void DivePlannerGraphics::drawProfile() | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// Re-position the user generated dive handlers
 | 	// Re-position the user generated dive handlers
 | ||||||
| 	for(int i = 0; i < plannerModel->rowCount(); i++){ | 	for (int i = 0; i < plannerModel->rowCount(); i++) { | ||||||
| 		divedatapoint dp = plannerModel->at(i); | 		divedatapoint dp = plannerModel->at(i); | ||||||
| 		DiveHandler *h = handles.at(i); | 		DiveHandler *h = handles.at(i); | ||||||
| 		h->setPos(timeLine->posAtValue(dp.time / 60), depthLine->posAtValue(dp.depth / 1000)); | 		h->setPos(timeLine->posAtValue(dp.time / 60), depthLine->posAtValue(dp.depth / 1000)); | ||||||
|  | @ -481,7 +480,7 @@ void DivePlannerGraphics::drawProfile() | ||||||
| 	for (dp = diveplan.dp; dp != NULL; dp = dp->next) { | 	for (dp = diveplan.dp; dp != NULL; dp = dp->next) { | ||||||
| 		double xpos = timeLine->posAtValue(dp->time / 60.0); | 		double xpos = timeLine->posAtValue(dp->time / 60.0); | ||||||
| 		double ypos = depthLine->posAtValue(dp->depth / 1000.0); | 		double ypos = depthLine->posAtValue(dp->depth / 1000.0); | ||||||
| 		if(!dp->entered){ | 		if (!dp->entered) { | ||||||
| 			QGraphicsLineItem *item = new QGraphicsLineItem(lastx, lasty, xpos, ypos); | 			QGraphicsLineItem *item = new QGraphicsLineItem(lastx, lasty, xpos, ypos); | ||||||
| 			item->setPen(QPen(QBrush(Qt::red),0)); | 			item->setPen(QPen(QBrush(Qt::red),0)); | ||||||
| 			scene()->addItem(item); | 			scene()->addItem(item); | ||||||
|  | @ -607,13 +606,13 @@ bool DivePlannerGraphics::isPointOutOfBoundaries(const QPointF& point) | ||||||
| 
 | 
 | ||||||
| void DivePlannerGraphics::mousePressEvent(QMouseEvent* event) | void DivePlannerGraphics::mousePressEvent(QMouseEvent* event) | ||||||
| { | { | ||||||
| 	if (event->modifiers()){ | 	if (event->modifiers()) { | ||||||
| 		QGraphicsView::mousePressEvent(event); | 		QGraphicsView::mousePressEvent(event); | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	QPointF mappedPos = mapToScene(event->pos()); | 	QPointF mappedPos = mapToScene(event->pos()); | ||||||
| 	Q_FOREACH(QGraphicsItem *item, scene()->items(mappedPos, Qt::IntersectsItemBoundingRect, Qt::AscendingOrder, transform())){ | 	Q_FOREACH(QGraphicsItem *item, scene()->items(mappedPos, Qt::IntersectsItemBoundingRect, Qt::AscendingOrder, transform())) { | ||||||
| 		if (DiveHandler *h = qgraphicsitem_cast<DiveHandler*>(item)) { | 		if (DiveHandler *h = qgraphicsitem_cast<DiveHandler*>(item)) { | ||||||
| 			activeDraggedHandler = h; | 			activeDraggedHandler = h; | ||||||
| 			activeDraggedHandler->setBrush(Qt::red); | 			activeDraggedHandler->setBrush(Qt::red); | ||||||
|  | @ -645,7 +644,7 @@ DiveHandler::DiveHandler(): QGraphicsEllipseItem() | ||||||
| 
 | 
 | ||||||
| void DiveHandler::mousePressEvent(QGraphicsSceneMouseEvent* event) | void DiveHandler::mousePressEvent(QGraphicsSceneMouseEvent* event) | ||||||
| { | { | ||||||
| 	if (event->modifiers().testFlag(Qt::ControlModifier)){ | 	if (event->modifiers().testFlag(Qt::ControlModifier)) { | ||||||
| 		setSelected(true); | 		setSelected(true); | ||||||
| 	} | 	} | ||||||
| 	// mousePressEvent 'grabs' the mouse and keyboard, annoying.
 | 	// mousePressEvent 'grabs' the mouse and keyboard, annoying.
 | ||||||
|  | @ -823,21 +822,21 @@ Button::Button(QObject* parent): QObject(parent), QGraphicsRectItem() | ||||||
| void Button::setPixmap(const QPixmap& pixmap) | void Button::setPixmap(const QPixmap& pixmap) | ||||||
| { | { | ||||||
| 	icon->setPixmap(pixmap.scaled(20,20, Qt::KeepAspectRatio, Qt::SmoothTransformation)); | 	icon->setPixmap(pixmap.scaled(20,20, Qt::KeepAspectRatio, Qt::SmoothTransformation)); | ||||||
| 	if(pixmap.isNull()){ | 	if(pixmap.isNull()) | ||||||
| 		icon->hide(); | 		icon->hide(); | ||||||
| 	}else{ | 	else | ||||||
| 		icon->show(); | 		icon->show(); | ||||||
| 	} | 
 | ||||||
| 	setRect(childrenBoundingRect()); | 	setRect(childrenBoundingRect()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void Button::setText(const QString& t) | void Button::setText(const QString& t) | ||||||
| { | { | ||||||
| 	text->setText(t); | 	text->setText(t); | ||||||
| 	if(icon->pixmap().isNull()){ | 	if(icon->pixmap().isNull()) { | ||||||
| 		icon->hide(); | 		icon->hide(); | ||||||
| 		text->setPos(0,0); | 		text->setPos(0,0); | ||||||
| 	}else{ | 	} else { | ||||||
| 		icon->show(); | 		icon->show(); | ||||||
| 		text->setPos(22,0); | 		text->setPos(22,0); | ||||||
| 	} | 	} | ||||||
|  | @ -935,21 +934,19 @@ int DivePlannerPointsModel::columnCount(const QModelIndex& parent) const | ||||||
| 
 | 
 | ||||||
| QVariant DivePlannerPointsModel::data(const QModelIndex& index, int role) const | QVariant DivePlannerPointsModel::data(const QModelIndex& index, int role) const | ||||||
| { | { | ||||||
| 	if(role == Qt::DisplayRole){ | 	if(role == Qt::DisplayRole) { | ||||||
| 		divedatapoint p = divepoints.at(index.row()); | 		divedatapoint p = divepoints.at(index.row()); | ||||||
| 		switch(index.column()){ | 		switch(index.column()) { | ||||||
| 			case CCSETPOINT: return p.po2; | 			case CCSETPOINT: return p.po2; | ||||||
| 			case DEPTH: return p.depth / 1000; | 			case DEPTH: return p.depth / 1000; | ||||||
| 			case DURATION: return p.time / 60; | 			case DURATION: return p.time / 60; | ||||||
| 			case GAS: return strForAir(p); | 			case GAS: return strForAir(p); | ||||||
| 		} | 		} | ||||||
| 	} | 	} else if (role == Qt::DecorationRole) { | ||||||
| 	else if (role == Qt::DecorationRole){ | 		switch(index.column()) { | ||||||
| 		switch(index.column()){ |  | ||||||
| 			case REMOVE : return QIcon(":trash"); | 			case REMOVE : return QIcon(":trash"); | ||||||
| 		} | 		} | ||||||
| 	} | 	} else if (role == Qt::FontRole) { | ||||||
| 	else if (role == Qt::FontRole){ |  | ||||||
| 		return  defaultModelFont(); | 		return  defaultModelFont(); | ||||||
| 	} | 	} | ||||||
| 	return QVariant(); | 	return QVariant(); | ||||||
|  | @ -957,9 +954,9 @@ QVariant DivePlannerPointsModel::data(const QModelIndex& index, int role) const | ||||||
| 
 | 
 | ||||||
| bool DivePlannerPointsModel::setData(const QModelIndex& index, const QVariant& value, int role) | bool DivePlannerPointsModel::setData(const QModelIndex& index, const QVariant& value, int role) | ||||||
| { | { | ||||||
| 	if(role == Qt::EditRole){ | 	if(role == Qt::EditRole) { | ||||||
| 		divedatapoint& p = divepoints[index.row()]; | 		divedatapoint& p = divepoints[index.row()]; | ||||||
| 		switch(index.column()){ | 		switch(index.column()) { | ||||||
| 			case DEPTH: p.depth = value.toInt() * 1000; break; | 			case DEPTH: p.depth = value.toInt() * 1000; break; | ||||||
| 			case DURATION: p.time = value.toInt() * 60; break; | 			case DURATION: p.time = value.toInt() * 60; break; | ||||||
| 			case CCSETPOINT:{ | 			case CCSETPOINT:{ | ||||||
|  | @ -985,15 +982,14 @@ bool DivePlannerPointsModel::setData(const QModelIndex& index, const QVariant& v | ||||||
| 
 | 
 | ||||||
| QVariant DivePlannerPointsModel::headerData(int section, Qt::Orientation orientation, int role) const | QVariant DivePlannerPointsModel::headerData(int section, Qt::Orientation orientation, int role) const | ||||||
| { | { | ||||||
| 	if (role == Qt::DisplayRole && orientation == Qt::Horizontal){ | 	if (role == Qt::DisplayRole && orientation == Qt::Horizontal) { | ||||||
| 		switch(section){ | 		switch(section) { | ||||||
| 			case DEPTH: return tr("Final Depth"); | 			case DEPTH: return tr("Final Depth"); | ||||||
| 			case DURATION: return tr("Duration"); | 			case DURATION: return tr("Duration"); | ||||||
| 			case GAS: return tr("Used Gas"); | 			case GAS: return tr("Used Gas"); | ||||||
| 			case CCSETPOINT: return tr("CC Set Point"); | 			case CCSETPOINT: return tr("CC Set Point"); | ||||||
| 		} | 		} | ||||||
| 	} | 	} else if (role == Qt::FontRole) { | ||||||
| 	else if (role == Qt::FontRole){ |  | ||||||
| 		return  defaultModelFont(); | 		return  defaultModelFont(); | ||||||
| 	} | 	} | ||||||
| 	return QVariant(); | 	return QVariant(); | ||||||
|  | @ -1059,18 +1055,19 @@ void DivePlannerPointsModel::setStartTime(const QTime& t) | ||||||
| 	emit dataChanged(createIndex(0, 0), createIndex(rowCount()-1, COLUMNS-1)); | 	emit dataChanged(createIndex(0, 0), createIndex(rowCount()-1, COLUMNS-1)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool divePointsLessThan(const divedatapoint& p1, const divedatapoint& p2){ | bool divePointsLessThan(const divedatapoint& p1, const divedatapoint& p2) | ||||||
|  | { | ||||||
| 	return p1.time <= p2.time; | 	return p1.time <= p2.time; | ||||||
| } | } | ||||||
|  | 
 | ||||||
| int DivePlannerPointsModel::addStop(int meters, int minutes, const QString& gas, int ccpoint) | int DivePlannerPointsModel::addStop(int meters, int minutes, const QString& gas, int ccpoint) | ||||||
| { | { | ||||||
| 	int row = divepoints.count(); | 	int row = divepoints.count(); | ||||||
| 	if(meters == 0 && minutes == 0){ | 	if(meters == 0 && minutes == 0) { | ||||||
| 		if(row == 0){ | 		if(row == 0) { | ||||||
| 			meters = 10000; | 			meters = 10000; | ||||||
| 			minutes = 600; | 			minutes = 600; | ||||||
| 		} | 		} else { | ||||||
| 		else{ |  | ||||||
| 			divedatapoint p = at(row-1); | 			divedatapoint p = at(row-1); | ||||||
| 			meters = p.depth; | 			meters = p.depth; | ||||||
| 			minutes = p.time + 600; | 			minutes = p.time + 600; | ||||||
|  | @ -1078,9 +1075,9 @@ int DivePlannerPointsModel::addStop(int meters, int minutes, const QString& gas, | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// check if there's already a new stop before this one:
 | 	// check if there's already a new stop before this one:
 | ||||||
| 	for(int i = 0; i < divepoints.count(); i++){ | 	for (int i = 0; i < divepoints.count(); i++) { | ||||||
| 		const divedatapoint& dp = divepoints.at(i); | 		const divedatapoint& dp = divepoints.at(i); | ||||||
| 		if (dp.time > minutes ){ | 		if (dp.time > minutes ) { | ||||||
| 			row = i; | 			row = i; | ||||||
| 			break; | 			break; | ||||||
| 		} | 		} | ||||||
|  | @ -1091,11 +1088,11 @@ int DivePlannerPointsModel::addStop(int meters, int minutes, const QString& gas, | ||||||
| 	divedatapoint point; | 	divedatapoint point; | ||||||
| 	point.depth = meters; | 	point.depth = meters; | ||||||
| 	point.time = minutes; | 	point.time = minutes; | ||||||
| 	if (row == 0){ | 	if (row == 0) { | ||||||
| 		point.o2 = 209; | 		point.o2 = 209; | ||||||
| 		point.he = 0; | 		point.he = 0; | ||||||
| 		point.po2 = 0; | 		point.po2 = 0; | ||||||
| 	}else{ | 	} else { | ||||||
| 		divedatapoint before = at(row-1); | 		divedatapoint before = at(row-1); | ||||||
| 		point.o2 = before.o2; | 		point.o2 = before.o2; | ||||||
| 		point.he = before.he; | 		point.he = before.he; | ||||||
|  | @ -1141,10 +1138,10 @@ struct diveplan DivePlannerPointsModel::getDiveplan() | ||||||
| 
 | 
 | ||||||
| void DivePlannerPointsModel::cancelPlan() | void DivePlannerPointsModel::cancelPlan() | ||||||
| { | { | ||||||
| 	if(mode == PLAN && rowCount()){ | 	if (mode == PLAN && rowCount()) { | ||||||
| 		if (QMessageBox::warning(mainWindow(), tr("Save the Plan?"), | 		if (QMessageBox::warning(mainWindow(), tr("Save the Plan?"), | ||||||
| 			tr("You have a working plan, \n are you sure that you wanna cancel it?"), | 			tr("You have a working plan, \n are you sure that you wanna cancel it?"), | ||||||
| 				QMessageBox::Ok | QMessageBox::Cancel) != QMessageBox::Ok){ | 				QMessageBox::Ok | QMessageBox::Cancel) != QMessageBox::Ok) { | ||||||
| 				return; | 				return; | ||||||
| 			} | 			} | ||||||
| 	} | 	} | ||||||
|  | @ -1165,7 +1162,7 @@ void DivePlannerPointsModel::createTemporaryPlan() | ||||||
| 	dp->entered = TRUE; | 	dp->entered = TRUE; | ||||||
| 	diveplan.dp = dp; | 	diveplan.dp = dp; | ||||||
| 	int lastIndex = -1; | 	int lastIndex = -1; | ||||||
| 	for(int i = 0; i < rowCount(); i++){ | 	for (int i = 0; i < rowCount(); i++) { | ||||||
| 		divedatapoint p = at(i); | 		divedatapoint p = at(i); | ||||||
| 		int deltaT = lastIndex != -1 ? p.time - at(lastIndex).time : p.time; | 		int deltaT = lastIndex != -1 ? p.time - at(lastIndex).time : p.time; | ||||||
| 		lastIndex = i; | 		lastIndex = i; | ||||||
|  | @ -1194,9 +1191,8 @@ void DivePlannerPointsModel::deleteTemporaryPlan() | ||||||
| 
 | 
 | ||||||
| void DivePlannerPointsModel::deleteTemporaryPlan(struct divedatapoint *dp) | void DivePlannerPointsModel::deleteTemporaryPlan(struct divedatapoint *dp) | ||||||
| { | { | ||||||
| 	if (!dp){ | 	if (!dp) | ||||||
| 		return; | 		return; | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
| 	deleteTemporaryPlan(dp->next); | 	deleteTemporaryPlan(dp->next); | ||||||
| 	free(dp); | 	free(dp); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue