mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Created a cross that follows the mouse on the dive planner.
Created a cross that follows the mouse on the dive planner, this will help the user to know where it is placing the stop. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
parent
b1c526ddb4
commit
88e7aa36be
2 changed files with 25 additions and 2 deletions
|
@ -10,8 +10,17 @@ DivePlanner* DivePlanner::instance()
|
||||||
|
|
||||||
DivePlanner::DivePlanner(QWidget* parent): QGraphicsView(parent)
|
DivePlanner::DivePlanner(QWidget* parent): QGraphicsView(parent)
|
||||||
{
|
{
|
||||||
|
setMouseTracking(true);
|
||||||
setScene( new QGraphicsScene());
|
setScene( new QGraphicsScene());
|
||||||
scene()->setSceneRect(0,0,100,100);
|
scene()->setSceneRect(0,0,100,100);
|
||||||
|
|
||||||
|
verticalLine = new QGraphicsLineItem(0,0,0, 100);
|
||||||
|
verticalLine->setPen(QPen(Qt::DotLine));
|
||||||
|
scene()->addItem(verticalLine);
|
||||||
|
|
||||||
|
horizontalLine = new QGraphicsLineItem(0,0,100,0);
|
||||||
|
horizontalLine->setPen(QPen(Qt::DotLine));
|
||||||
|
scene()->addItem(horizontalLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivePlanner::mouseDoubleClickEvent(QMouseEvent* event)
|
void DivePlanner::mouseDoubleClickEvent(QMouseEvent* event)
|
||||||
|
@ -69,3 +78,16 @@ void DivePlanner::showEvent(QShowEvent* event)
|
||||||
fitInView(sceneRect(), Qt::KeepAspectRatio);
|
fitInView(sceneRect(), Qt::KeepAspectRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DivePlanner::mouseMoveEvent(QMouseEvent* event)
|
||||||
|
{
|
||||||
|
QPointF mappedPos = mapToScene(event->pos());
|
||||||
|
if (mappedPos.x() > sceneRect().width()
|
||||||
|
|| mappedPos.x() < 0
|
||||||
|
|| mappedPos.y() < 0
|
||||||
|
|| mappedPos.y() > sceneRect().height())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
verticalLine->setLine(mappedPos.x(), 0, mappedPos.x(), 100);
|
||||||
|
horizontalLine->setLine(0, mappedPos.y(), 100, mappedPos.y());
|
||||||
|
}
|
||||||
|
|
|
@ -12,13 +12,14 @@ protected:
|
||||||
virtual void mouseDoubleClickEvent(QMouseEvent* event);
|
virtual void mouseDoubleClickEvent(QMouseEvent* event);
|
||||||
virtual void showEvent(QShowEvent* event);
|
virtual void showEvent(QShowEvent* event);
|
||||||
virtual void resizeEvent(QResizeEvent* event);
|
virtual void resizeEvent(QResizeEvent* event);
|
||||||
|
virtual void mouseMoveEvent(QMouseEvent* event);
|
||||||
void clear_generated_deco();
|
void clear_generated_deco();
|
||||||
void create_deco_stop();
|
void create_deco_stop();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DivePlanner(QWidget* parent = 0);
|
DivePlanner(QWidget* parent = 0);
|
||||||
QList<QGraphicsLineItem*> lines;
|
QList<QGraphicsLineItem*> lines;
|
||||||
QList<QGraphicsEllipseItem*> handles;
|
QList<QGraphicsEllipseItem*> handles;
|
||||||
|
QGraphicsLineItem *verticalLine;
|
||||||
|
QGraphicsLineItem *horizontalLine;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue