[Kst] branches/work/kst/portto4/kst/src/libkstapp

Mike Fenton mike at staikos.net
Tue Jan 13 20:09:56 CET 2009


SVN commit 910596 by fenton:

Add PlotItemDialog / CurveDialog launching based on mouse click/doubleclick on plot items.


 M  +9 -0      plotitem.cpp  
 M  +1 -0      plotitem.h  
 M  +25 -0     plotrenderitem.cpp  
 M  +1 -0      plotrenderitem.h  


--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #910595:910596
@@ -39,6 +39,7 @@
 
 #include <QMenu>
 #include <QDebug>
+#include <QGraphicsSceneMouseEvent>
 
 // Zoom Debugging.  0 Off, 1 On.
 #define DEBUG_ZOOM 0
@@ -2211,6 +2212,14 @@
 }
 
 
+void PlotItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
+  if (event->button() == Qt::LeftButton) {
+    edit();
+    event->ignore();
+  }
+}
+
+
 void PlotItem::zoomFixedExpression(const QRectF &projection) {
 #if DEBUG_ZOOM
   qDebug() << "zoomFixedExpression" << projection << "current" << projectionRect();
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.h #910595:910596
@@ -241,6 +241,7 @@
 
   protected:
     virtual QString _automaticDescriptiveName() const;
+    virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
 
   Q_SIGNALS:
     void marginsChanged();
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.cpp #910595:910596
@@ -354,6 +354,31 @@
 }
 
 
+void PlotRenderItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
+  const QPointF point = plotItem()->mapToProjection(event->pos());
+  qreal range = qMax(plotItem()->xMax() - plotItem()->xMin(), plotItem()->yMax() - plotItem()->yMin());
+  double distance;
+  bool first = true;
+  RelationPtr closestRelation = 0;
+  foreach (RelationPtr relation, _relationList) {
+    double relationsDistance = relation->distanceToPoint(point.x(), range, point.y());
+    if (first) {
+      distance = relationsDistance;
+      closestRelation = relation;
+      first = false;
+    } else {
+      if (distance > relationsDistance) {
+        distance = relationsDistance;
+        closestRelation = relation;
+      }
+    }
+  }
+  if (closestRelation) {
+    closestRelation->showEditDialog();
+  }
+}
+
+
 void PlotRenderItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
   if (parentView()->viewMode() != View::Data) {
     event->ignore();
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.h #910595:910596
@@ -79,6 +79,7 @@
     virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
     virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
     virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+    virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
 
     virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
 


More information about the Kst mailing list