mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Profile: take int instead of bool in DiveEventItem::recalculatePos
The goal here is to slowly make animation speed a variable of the profile widget, not of the global preferences. Currently the code does some trickeries with setting / unsetting the global animation speed. Start by not taking a bool "instant" but a speed in DiveEventItem::recalculatePos(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
		
							parent
							
								
									5886550434
								
							
						
					
					
						commit
						74244b3cfe
					
				
					 3 changed files with 12 additions and 11 deletions
				
			
		| 
						 | 
					@ -32,20 +32,21 @@ DiveEventItem::~DiveEventItem()
 | 
				
			||||||
void DiveEventItem::setHorizontalAxis(DiveCartesianAxis *axis)
 | 
					void DiveEventItem::setHorizontalAxis(DiveCartesianAxis *axis)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	hAxis = axis;
 | 
						hAxis = axis;
 | 
				
			||||||
	recalculatePos(true);
 | 
						recalculatePos(0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DiveEventItem::setModel(DivePlotDataModel *model)
 | 
					void DiveEventItem::setModel(DivePlotDataModel *model)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	dataModel = model;
 | 
						dataModel = model;
 | 
				
			||||||
	recalculatePos(true);
 | 
						recalculatePos(0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DiveEventItem::setVerticalAxis(DiveCartesianAxis *axis)
 | 
					void DiveEventItem::setVerticalAxis(DiveCartesianAxis *axis, int speed)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	vAxis = axis;
 | 
						vAxis = axis;
 | 
				
			||||||
	recalculatePos(true);
 | 
						recalculatePos(0);
 | 
				
			||||||
	connect(vAxis, SIGNAL(sizeChanged()), this, SLOT(recalculatePos()));
 | 
						connect(vAxis, &DiveCartesianAxis::sizeChanged, this,
 | 
				
			||||||
 | 
							[speed, this] { recalculatePos(speed); });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct event *DiveEventItem::getEvent()
 | 
					struct event *DiveEventItem::getEvent()
 | 
				
			||||||
| 
						 | 
					@ -62,7 +63,7 @@ void DiveEventItem::setEvent(struct event *ev, struct gasmix lastgasmix)
 | 
				
			||||||
	internalEvent = clone_event(ev);
 | 
						internalEvent = clone_event(ev);
 | 
				
			||||||
	setupPixmap(lastgasmix);
 | 
						setupPixmap(lastgasmix);
 | 
				
			||||||
	setupToolTipString(lastgasmix);
 | 
						setupToolTipString(lastgasmix);
 | 
				
			||||||
	recalculatePos(true);
 | 
						recalculatePos(0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DiveEventItem::setupPixmap(struct gasmix lastgasmix)
 | 
					void DiveEventItem::setupPixmap(struct gasmix lastgasmix)
 | 
				
			||||||
| 
						 | 
					@ -268,7 +269,7 @@ int DiveEventItem::depthAtTime(int time)
 | 
				
			||||||
	return dataModel->data(dataModel->index(result.first().row(), DivePlotDataModel::DEPTH)).toInt();
 | 
						return dataModel->data(dataModel->index(result.first().row(), DivePlotDataModel::DEPTH)).toInt();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DiveEventItem::recalculatePos(bool instant)
 | 
					void DiveEventItem::recalculatePos(int speed)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (!vAxis || !hAxis || !internalEvent || !dataModel)
 | 
						if (!vAxis || !hAxis || !internalEvent || !dataModel)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
| 
						 | 
					@ -286,7 +287,7 @@ void DiveEventItem::recalculatePos(bool instant)
 | 
				
			||||||
		show();
 | 
							show();
 | 
				
			||||||
	qreal x = hAxis->posAtValue(internalEvent->time.seconds);
 | 
						qreal x = hAxis->posAtValue(internalEvent->time.seconds);
 | 
				
			||||||
	qreal y = vAxis->posAtValue(depth);
 | 
						qreal y = vAxis->posAtValue(depth);
 | 
				
			||||||
	if (!instant)
 | 
						if (speed > 0)
 | 
				
			||||||
		Animations::moveTo(this, x, y);
 | 
							Animations::moveTo(this, x, y);
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		setPos(x, y);
 | 
							setPos(x, y);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,13 +16,13 @@ public:
 | 
				
			||||||
	void setEvent(struct event *ev, struct gasmix lastgasmix);
 | 
						void setEvent(struct event *ev, struct gasmix lastgasmix);
 | 
				
			||||||
	struct event *getEvent();
 | 
						struct event *getEvent();
 | 
				
			||||||
	void eventVisibilityChanged(const QString &eventName, bool visible);
 | 
						void eventVisibilityChanged(const QString &eventName, bool visible);
 | 
				
			||||||
	void setVerticalAxis(DiveCartesianAxis *axis);
 | 
						void setVerticalAxis(DiveCartesianAxis *axis, int speed);
 | 
				
			||||||
	void setHorizontalAxis(DiveCartesianAxis *axis);
 | 
						void setHorizontalAxis(DiveCartesianAxis *axis);
 | 
				
			||||||
	void setModel(DivePlotDataModel *model);
 | 
						void setModel(DivePlotDataModel *model);
 | 
				
			||||||
	bool shouldBeHidden();
 | 
						bool shouldBeHidden();
 | 
				
			||||||
public
 | 
					public
 | 
				
			||||||
slots:
 | 
					slots:
 | 
				
			||||||
	void recalculatePos(bool instant = false);
 | 
						void recalculatePos(int animationSpeed);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	void setupToolTipString(struct gasmix lastgasmix);
 | 
						void setupToolTipString(struct gasmix lastgasmix);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -788,7 +788,7 @@ void ProfileWidget2::plotDive(const struct dive *d, bool force, bool doClearPict
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
		DiveEventItem *item = new DiveEventItem();
 | 
							DiveEventItem *item = new DiveEventItem();
 | 
				
			||||||
		item->setHorizontalAxis(timeAxis);
 | 
							item->setHorizontalAxis(timeAxis);
 | 
				
			||||||
		item->setVerticalAxis(profileYAxis);
 | 
							item->setVerticalAxis(profileYAxis, qPrefDisplay::animation_speed());
 | 
				
			||||||
		item->setModel(dataModel);
 | 
							item->setModel(dataModel);
 | 
				
			||||||
		item->setEvent(event, lastgasmix);
 | 
							item->setEvent(event, lastgasmix);
 | 
				
			||||||
		item->setZValue(2);
 | 
							item->setZValue(2);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue