[Kst] branches/work/kst/portto4/kst/src/libkstapp
Mike Fenton
mike at staikos.net
Mon Mar 10 16:06:24 CET 2008
SVN commit 784054 by fenton:
Fixing Kst Bug Re: Plot Markers for Shift/Ctrl Mouse zoom. Add Keyboard handling and update hoverMouseMove to update the cursor / draw the selection line for zoom.
M +55 -3 plotrenderitem.cpp
M +4 -0 plotrenderitem.h
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.cpp #784053:784054
@@ -24,6 +24,7 @@
#include <QGraphicsSceneHoverEvent>
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsSceneContextMenuEvent>
+#include <QKeyEvent>
// #define CURVE_DRAWING_TIME
@@ -474,6 +475,40 @@
}
+void PlotRenderItem::keyPressEvent(QKeyEvent *event) {
+ const Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();
+ if (modifiers & Qt::ShiftModifier) {
+ setCursor(Qt::SizeVerCursor);
+ _selectionRect.setFrom(QPointF(rect().left(), _lastPos.y()));
+ _selectionRect.setTo(QPointF(rect().right(), _lastPos.y()));
+ } else if (modifiers & Qt::ControlModifier) {
+ setCursor(Qt::SizeHorCursor);
+ _selectionRect.setFrom(QPointF(_lastPos.x(), rect().top()));
+ _selectionRect.setTo(QPointF(_lastPos.x(), rect().bottom()));
+ }
+ ViewItem::keyPressEvent(event);
+
+ if (_selectionRect.isValid()) {
+ update(); //FIXME should optimize instead of redrawing entire curve?
+ }
+}
+
+
+void PlotRenderItem::keyReleaseEvent(QKeyEvent *event) {
+ const Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();
+ if (modifiers & Qt::ShiftModifier) {
+ setCursor(Qt::SizeVerCursor);
+ } else if (modifiers & Qt::ControlModifier) {
+ setCursor(Qt::SizeHorCursor);
+ } else {
+ _selectionRect.reset();
+ updateCursor(_lastPos);
+ update(); //FIXME should optimize instead of redrawing entire curve?
+ }
+ ViewItem::keyReleaseEvent(event);
+}
+
+
void PlotRenderItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
if (parentView()->viewMode() != View::Data) {
event->ignore();
@@ -540,9 +575,25 @@
void PlotRenderItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {
ViewItem::hoverMoveEvent(event);
- updateCursor(event->pos());
- const QPointF p = plotItem()->mapToProjection(event->pos());
- QString message = QString("(%1, %2)").arg(QString::number(p.x(), 'G')).arg(QString::number(p.y()));
+ const QPointF p = event->pos();
+ const Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();
+ if (modifiers & Qt::ShiftModifier) {
+ _lastPos = p;
+ setCursor(Qt::SizeVerCursor);
+ _selectionRect.setFrom(QPointF(rect().left(), p.y()));
+ _selectionRect.setTo(QPointF(rect().right(), p.y()));
+ update(); //FIXME should optimize instead of redrawing entire curve!
+ } else if (modifiers & Qt::ControlModifier) {
+ _lastPos = p;
+ setCursor(Qt::SizeHorCursor);
+ _selectionRect.setFrom(QPointF(p.x(), rect().top()));
+ _selectionRect.setTo(QPointF(p.x(), rect().bottom()));
+ update(); //FIXME should optimize instead of redrawing entire curve!
+ } else {
+ updateCursor(event->pos());
+ }
+ const QPointF point = plotItem()->mapToProjection(event->pos());
+ QString message = QString("(%1, %2)").arg(QString::number(point.x(), 'G')).arg(QString::number(point.y()));
kstApp->mainWindow()->statusBar()->showMessage(message);
}
@@ -778,6 +829,7 @@
void PlotRenderItem::updateCursor(const QPointF &pos) {
+ _lastPos = pos;
if (checkBox().contains(pos)) {
setCursor(Qt::ArrowCursor);
} else {
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.h #784053:784054
@@ -113,6 +113,9 @@
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+ virtual void keyPressEvent(QKeyEvent *event);
+ virtual void keyReleaseEvent(QKeyEvent *event);
+
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
@@ -150,6 +153,7 @@
bool _isYAxisLog;
qreal _xLogBase;
qreal _yLogBase;
+ QPointF _lastPos;
RelationList _relationList;
QRectF _projectionRect;
More information about the Kst
mailing list