[Kst] kdeextragear-2/kst/kst

Andrew Walker arwalker at sumusltd.com
Thu Jun 17 21:58:44 CEST 2004


CVS commit by arwalker: 

Removed compiler warning
Removed unnecessary define's
Fixed FIXME


  M +15 -16    kst2dplot.cpp   1.93


--- kdeextragear-2/kst/kst/kst2dplot.cpp  #1.92:1.93
@@ -230,4 +230,5 @@ void Kst2DPlot::commonConstructor(const 
   _copy_x = _copy_y = KST::NOPOINT;
   _standardActions |= Delete | Edit | Zoom | Pause;
+  _draggableLabel = -1;
   _type = "plot";
   
@@ -1314,4 +1315,5 @@ void Kst2DPlot::paint(QPainter& p, doubl
 // Optimize - isnan seems expensive, at least in gcc debug mode
 //            cachegrind backs this up.
+#undef isnan
 #define isnan(x) (x != x)
         if (isnan(rX)) {
@@ -2046,11 +2048,9 @@ void Kst2DPlot::mouseMoveEvent(QWidget *
     KstLabel *label = labelList.at(i_label);
     if (label) {
-#define LABEL_TRANSPARENT
       QRegion oldExtents = label->extents;
       QPixmap pm(GetWinRegion().width(), GetWinRegion().height());
       QRect rectBounding = oldExtents.boundingRect();
-
-#ifdef LABEL_TRANSPARENT
       QBitmap bm(GetWinRegion().width(), GetWinRegion().height(), true);
+
       { // Scope is needed to kill off painter before we resize
         QPainter p(&bm);
@@ -2057,5 +2057,4 @@ void Kst2DPlot::mouseMoveEvent(QWidget *
         label->draw(p, 0, label->v_offset, false);
       }
-#endif
 
       pm.fill(KstSettings::globalSettings()->backgroundColor);
@@ -2080,12 +2079,11 @@ void Kst2DPlot::mouseMoveEvent(QWidget *
 
       pm.resize(iWidth, iHeight);
-#ifdef LABEL_TRANSPARENT
       bm.resize(iWidth, iHeight);
       pm.setMask(bm);
-#endif
+
       label->extents = oldExtents; // restore them in case the drag is canceled
       QDragObject *d = new KstLabelDrag(view, static_cast<KstViewWindow*>(view->parent())->caption(), this, i_label, _draggablePoint - GetWinRegion().topLeft() - rectBounding.topLeft(), pm);
       d->dragMove();
-      _draggableLabel = -1;
+      _draggableLabel = -2;
       static_cast<KstViewWidget*>(view)->viewObject()->releaseMouse(this);
     }
@@ -2501,16 +2499,16 @@ void Kst2DPlot::mouseReleaseEvent(QWidge
 
   } else if (_mouse.mode == LABEL_TOOL) {
-    // FIXME: semantic problem here.  If we trigger on mouse press, then we
-    //        break label dragging.  If we trigger on mouse release, then if
-    //        a drag is cancelled with Escape, the release event fires through
-    //        and we open the label editor (incorrectly).
-    int i_label = labelNumber(e);
-
     plotregion = GetPlotRegion();
-    if (i_label >= 0 || plotregion.contains(e->pos()))  {
+
       double x = double(e->x() - plotregion.left()) / double(plotregion.width());
       double y = double(e->y() - plotregion.top()) / double(plotregion.height());
+    int i_label;
+
+    if ((i_label = labelNumber(e)) >= 0 && _draggableLabel == i_label)  {
       KstApp::inst()->labelDialog()->showI(this, i_label, x, y);
+    } else if ( plotregion.contains(e->pos()) && _draggableLabel == -1) {
+      KstApp::inst()->labelDialog()->showI(this, -1, x, y);
     }
+    
     return; // no need to update, and we don't want to set INACTIVE
   }





More information about the Kst mailing list