[Kst] kdeextragear-2/kst

George Staikos staikos at kde.org
Wed Jul 7 19:43:27 CEST 2004


CVS commit by staikos: 

mouse wheel support for plots, minus Control button which I'm not sure about
yet.


  M +0 -1      devel-docs/RELEASE_PLAN-0.98   1.10
  M +51 -0     kst/kst2dplot.cpp   1.138


--- kdeextragear-2/kst/devel-docs/RELEASE_PLAN-0.98  #1.9:1.10
@@ -29,5 +29,4 @@
 o status messages/progress for lengthy actions 
 o algorithm to size and cascade plots initially
-o mouse wheel scrolling
 o Something before 0% and at 50% cause progress updates for data wizard to not
   work well

--- kdeextragear-2/kst/kst/kst2dplot.cpp  #1.137:1.138
@@ -3340,5 +3340,56 @@ void Kst2DPlot::setDirty() {
 
 
+#ifndef WHEEL_DELTA
+#define WHEEL_DELTA 120
+#endif
+
 void Kst2DPlot::wheelEvent(QWidget *view, QWheelEvent *e) {
+  KstViewWidget *vw = dynamic_cast<KstViewWidget*>(view);
+  if (!vw || !GetPlotRegion().contains(e->pos())) {
+    return;
+  }
+
+  bool forward = e->delta() >= 0;
+  int absDelta = forward ? e->delta() : -e->delta();
+  bool alt = e->state() & Qt::AltButton;
+  if (e->state() & Qt::ControlButton) {
+    // Advance?  Something else?
+  } else if (e->state() & Qt::ShiftButton) {
+    for (int i = 0; i < absDelta/WHEEL_DELTA; ++i) {
+      if (forward) {
+        if (alt) {
+          yZoomIn(vw);
+        } else {
+          xZoomIn(vw);
+        }
+      } else {
+        if (alt) {
+          yZoomOut(vw);
+        } else {
+          xZoomOut(vw);
+        }
+      }
+    }
+    vw->paint();
+  } else {
+    for (int i = 0; i < absDelta/WHEEL_DELTA; ++i) {
+      if (forward) {
+        if (alt) {
+          moveUp(vw);
+        } else {
+          moveRight(vw);
+        }
+      } else {
+        if (alt) {
+          moveDown(vw);
+        } else {
+          moveLeft(vw);
+        }
+      }
+    }
+    vw->paint();
+  }
+
+  e->accept();
 }
 





More information about the Kst mailing list