aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-07-04 11:01:59 -0300
committerGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-07-04 11:01:59 -0300
commitf457415f7ae8ff3cfd86dc5f629117c78fe56c3c (patch)
treee6b723c38598285c8e74cb31471c67947f3ef6d4 /qt-ui
parentae08a81739eacb0be86811274ecf9ec786626d1b (diff)
downloadsubsurface-f457415f7ae8ff3cfd86dc5f629117c78fe56c3c.tar.gz
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>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/diveplanner.cpp16
-rw-r--r--qt-ui/diveplanner.h3
2 files changed, 18 insertions, 1 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 3e107b10c..a7bd0af4c 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -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;
diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h
index 547e38727..9c8a2b7a6 100644
--- a/qt-ui/diveplanner.h
+++ b/qt-ui/diveplanner.h
@@ -28,6 +28,9 @@ public:
QGraphicsLineItem *to;
int sec;
int mm;
+protected:
+ void mousePressEvent(QGraphicsSceneMouseEvent* event);
+
};
class Ruler : public QGraphicsLineItem{