[Kst] kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Fri May 28 10:43:34 CEST 2004


CVS commit by staikos: 

more off-by-one style bug fixes


  M +5 -3      kst.cpp   1.125
  M +37 -8     kst2dplot.cpp   1.38


--- kdeextragear-2/kst/kst/kst.cpp  #1.124:1.125
@@ -194,10 +194,10 @@ KstApp::KstApp(QWidget *parent, const ch
 
     iMenuCount = menuBar()->count();
-    for (iMenuIndex=0; iMenuIndex<iMenuCount; iMenuIndex++) {
+    for (iMenuIndex = 0; iMenuIndex < iMenuCount; iMenuIndex++) {
       iMenuId = menuBar()->idAt(iMenuIndex);
       if (iMenuId != -1) {
         strMenuTitle =  menuBar()->text(iMenuId);
-        if (strMenuTitle.compare(i18n("&Help"))==0) {
-          menuBar()->insertItem( i18n("&Window"), windowMenu(), 100, iMenuIndex);
+        if (strMenuTitle.compare(i18n("&Help")) == 0) {
+          menuBar()->insertItem(i18n("&Window"), windowMenu(), 100, iMenuIndex);
           bAddedWindowMenu = true;
           break;
@@ -211,4 +211,6 @@ KstApp::KstApp(QWidget *parent, const ch
   }
 
+  // FIXME: should not create new window unconditionally.  We may load a window
+  //        from disk!
   KstViewWindow *w = new KstViewWindow;
   w->setCaption(i18n("Default"));

--- kdeextragear-2/kst/kst/kst2dplot.cpp  #1.37:1.38
@@ -1807,5 +1807,5 @@ void Kst2DPlot::mouseMoveEvent(QWidget *
     QPixmap pm(GetWinRegion().width(), GetWinRegion().height());
     pm.fill(KstSettings::globalSettings()->backgroundColor);
-    QRect rectBounding = oldExtents.boundingRect( );
+    QRect rectBounding = oldExtents.boundingRect();
 
     { // Scope is needed to kill off painter before we resize
@@ -1841,5 +1841,5 @@ void Kst2DPlot::mouseMoveEvent(QWidget *
     QPixmap pm(GetWinRegion().width(), GetWinRegion().height());
     pm.fill(KstSettings::globalSettings()->backgroundColor);
-    QRect rectBounding = oldExtents.boundingRect( );
+    QRect rectBounding = oldExtents.boundingRect();
 
     { // Scope is needed to kill off painter before we resize
@@ -2051,7 +2051,5 @@ void Kst2DPlot::mouseReleaseEvent(QWidge
   QRect newg = _mouse.mouseRect();
   if (_mouse.mode == XY_ZOOMBOX) {
-    if (newg.width() > _mouse.minMove &&
-        newg.height() > _mouse.minMove) {
-
+    if (_mouse.rectBigEnough()) {
       QPainter p;
       p.begin(view);
@@ -2078,5 +2077,10 @@ void Kst2DPlot::mouseReleaseEvent(QWidge
     }
   } else if (_mouse.mode == Y_ZOOMBOX) {
-    if (newg.height() > _mouse.minMove) {
+    if (newg.height() >= _mouse.minMove) {
+      QPainter p;
+      p.begin(view);
+      p.setRasterOp(Qt::NotROP);
+      p.drawWinFocusRect(newg);
+      p.end();
 
       getLScale(xmin, ymin, xmax, ymax);
@@ -2094,5 +2098,11 @@ void Kst2DPlot::mouseReleaseEvent(QWidge
     }
   } else if (_mouse.mode == X_ZOOMBOX) {
-    if (newg.width() > _mouse.minMove) {
+    if (newg.width() >= _mouse.minMove) {
+      QPainter p;
+      p.begin(view);
+      p.setRasterOp(Qt::NotROP);
+      p.drawWinFocusRect(newg);
+      p.end();
+
       getLScale(xmin, ymin, xmax, ymax);
       plotregion = GetPlotRegion();
@@ -2227,6 +2237,25 @@ void Kst2DPlot::keyReleaseEvent(QWidget 
     if (_mouse.mode != INACTIVE) {
       KstMouseModeType newType = XY_ZOOMBOX; // FIXME: wrong
-      QPoint newp = _mouse.lastLocation;
+      QPoint c = view->mapFromGlobal(QCursor::pos());
+      QRect pr = GetPlotRegion();
+      int x, y;
+      // likewise wrong with above.  change.
+      if (c.x() > pr.right()) {
+        x = pr.right() + 1;
+      } else if (c.x() < pr.left()) {
+        x = pr.left();
+      } else {
+        x = c.x();
+      }
 
+      if (c.y() > pr.bottom()) {
+        y = pr.bottom() + 1;
+      } else if (c.y() < pr.top()) {
+        y = pr.top();
+      } else {
+        y = c.y();
+      }
+
+      QPoint newp(x, y);
       QPainter p;
       p.begin(view);





More information about the Kst mailing list