[kgraphviewer-devel] [KGraphViewer/libkgraphviz] 3607c59: Enable multiple selection with shift+mouse
Kevin Funk
krf at electrostorm.net
Wed Jan 12 17:56:32 CET 2011
commit 3607c599ad962fb605e14662169b8575f43e9360
branch libkgraphviz
Author: Kevin Funk <krf at electrostorm.net>
Date: Wed Jan 12 17:54:09 2011 +0100
Enable multiple selection with shift+mouse
diff --git a/src/kgraphviz/dotgraphview.cpp b/src/kgraphviz/dotgraphview.cpp
index a3cae62..fc6bfd7 100644
--- a/src/kgraphviz/dotgraphview.cpp
+++ b/src/kgraphviz/dotgraphview.cpp
@@ -851,7 +851,6 @@ bool DotGraphView::displayGraph()
void DotGraphView::focusInEvent(QFocusEvent*)
{
- Q_D(DotGraphView);
if (!scene())
return;
@@ -871,8 +870,12 @@ void DotGraphView::keyPressEvent(QKeyEvent* e)
return;
}
+ // give a hint about drag mode when pressing control
+ if (e->modifiers() == Qt::ShiftModifier) {
+ setCursor(Qt::CrossCursor);
+ }
// move canvas...
- if (e->key() == Qt::Key_Home)
+ else if (e->key() == Qt::Key_Home)
scrollContentsBy(int(-scene()->width()),0);
else if (e->key() == Qt::Key_End)
scrollContentsBy(int(scene()->width()),0);
@@ -895,14 +898,23 @@ void DotGraphView::keyPressEvent(QKeyEvent* e)
}
}
-void DotGraphView::wheelEvent(QWheelEvent* e)
+void DotGraphView::keyReleaseEvent(QKeyEvent* e)
{
Q_D(DotGraphView);
+ if (d->m_editingMode != SelectingElements)
+ unsetCursor();
+
+ QGraphicsView::keyReleaseEvent(e);
+}
+
+void DotGraphView::wheelEvent(QWheelEvent* e)
+{
if (!scene())
{
e->ignore();
return;
}
+
e->accept();
if (e->state() == Qt::ShiftModifier)
{
@@ -1095,6 +1107,11 @@ void DotGraphView::mousePressEvent(QMouseEvent* e)
{
d->m_editingMode = None;
}
+ else {
+ if (e->modifiers() == Qt::ShiftModifier) {
+ prepareSelectElements();
+ }
+ }
}
}
@@ -1705,6 +1722,7 @@ void DotGraphView::slotSelectNode(const QString& nodeName)
CanvasElement* canvasElement = node->canvasElement();
if (canvasElement !=0) {
+ scene()->clearSelection();
canvasElement->setSelected(true);
}
}
diff --git a/src/kgraphviz/dotgraphview.h b/src/kgraphviz/dotgraphview.h
index 27ddce7..0f05d90 100644
--- a/src/kgraphviz/dotgraphview.h
+++ b/src/kgraphviz/dotgraphview.h
@@ -159,6 +159,7 @@ protected:
void mouseReleaseEvent(QMouseEvent*);
void mouseDoubleClickEvent(QMouseEvent*);
void keyPressEvent(QKeyEvent*);
+ void keyReleaseEvent(QKeyEvent*);
void focusInEvent(QFocusEvent*);
void focusOutEvent(QFocusEvent*);
void wheelEvent(QWheelEvent* e);
More information about the kgraphviewer-devel
mailing list