Make possible to 'select' an handler by ctrl+click

Make possible to select an handler by ctrl+click on it,
this will be used in the future for the shortcut actions,
like delete, arrow keys, and such.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
Tomaz Canabrava 2013-07-04 11:01:59 -03:00
parent ae08a81739
commit f457415f7a
2 changed files with 18 additions and 1 deletions

View file

@ -363,6 +363,10 @@ bool DivePlannerGraphics::isPointOutOfBoundaries(const QPointF& point)
void DivePlannerGraphics::mousePressEvent(QMouseEvent* event)
{
if (event->modifiers()){
QGraphicsView::mousePressEvent(event);
}
QPointF mappedPos = mapToScene(event->pos());
Q_FOREACH(QGraphicsItem *item, scene()->items(mappedPos, Qt::IntersectsItemBoundingRect, Qt::AscendingOrder, transform())){
if (DiveHandler *h = qgraphicsitem_cast<DiveHandler*>(item)) {
@ -371,7 +375,6 @@ void DivePlannerGraphics::mousePressEvent(QMouseEvent* event)
originalHandlerPos = activeDraggedHandler->pos();
}
}
QGraphicsView::mousePressEvent(event);
}
void DivePlannerGraphics::mouseReleaseEvent(QMouseEvent* event)
@ -406,10 +409,21 @@ DiveHandler::DiveHandler(): QGraphicsEllipseItem(), from(0), to(0)
{
setRect(-5,-5,10,10);
setFlag(QGraphicsItem::ItemIgnoresTransformations);
setFlag(QGraphicsItem::ItemIsSelectable);
setBrush(Qt::white);
setZValue(2);
}
void DiveHandler::mousePressEvent(QGraphicsSceneMouseEvent* event)
{
if (event->modifiers().testFlag(Qt::ControlModifier)){
setSelected(true);
}
// mousePressEvent 'grabs' the mouse and keyboard, annoying.
ungrabMouse();
ungrabKeyboard();
}
void Ruler::setMaximum(double maximum)
{
max = maximum;

View file

@ -28,6 +28,9 @@ public:
QGraphicsLineItem *to;
int sec;
int mm;
protected:
void mousePressEvent(QGraphicsSceneMouseEvent* event);
};
class Ruler : public QGraphicsLineItem{