[Kst] extragear/graphics/kst/src/libkstapp

George Staikos staikos at kde.org
Mon May 29 18:47:40 CEST 2006


SVN commit 546280 by staikos:

back out 544672 again until it's done without piling view handling into
KstViewObject


 M  +43 -10    ksttoplevelview.cpp  
 M  +0 -39     kstviewobject.cpp  
 M  +0 -2      kstviewobject.h  


--- trunk/extragear/graphics/kst/src/libkstapp/ksttoplevelview.cpp #546279:546280
@@ -703,21 +703,54 @@
   r.moveTopLeft(topLeft);
   _moveOffsetSticky = QPoint(0, 0);
       
-  int xMin = STICKY_THRESHOLD;
-  int yMin = STICKY_THRESHOLD;
+  int iXMin = STICKY_THRESHOLD;
+  int iYMin = STICKY_THRESHOLD;
 
-  snapToBorders(&xMin, &yMin, _selectionList, _pressTarget, r);
+  // check for "sticky" borders
+  for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
+    if (_selectionList.find(*i) == _selectionList.end() && _pressTarget != *i) {           
+      const QRect rect((*i)->geometry());
 
-  if (labs(xMin) < STICKY_THRESHOLD) {
-    _moveOffsetSticky.setX(xMin);
-    topLeft.setX(topLeft.x() - xMin);
+      int overlapLo = r.top() > rect.top() ? r.top() : rect.top();
+      int overlapHi = r.bottom() < rect.bottom() ? r.bottom() : rect.bottom();
+      if (overlapHi - overlapLo > 0) {
+        if (labs(r.left() - rect.left()) < labs(iXMin)) {
+          iXMin = r.left() - rect.left();
+        } else if (labs(r.left() - rect.right()) < labs(iXMin)) {
+          iXMin = r.left() - rect.right();              
+        } else if (labs(r.right() - rect.left()) < labs(iXMin)) {
+          iXMin = r.right() - rect.left();
+        } else if (labs(r.right() - rect.right()) < labs(iXMin)) {
+          iXMin = r.right() - rect.right();
+        }                 
+      }
+
+      overlapLo = r.left() > rect.left() ? r.left() : rect.left();
+      overlapHi = r.right() < rect.right() ? r.right() : rect.right();
+      if (overlapHi - overlapLo > 0) {
+        if (labs(r.top() - rect.top()) < labs(iYMin)) {
+          iYMin = r.top() - rect.top();
+        } else if (labs(r.top() - rect.bottom()) < labs(iYMin)) {
+          iYMin = r.top() - rect.bottom();              
+        } else if (labs(r.bottom() - rect.top()) < labs(iYMin)) {
+          iYMin = r.bottom() - rect.top();
+        } else if (labs(r.bottom() - rect.bottom()) < labs(iYMin)) {
+          iYMin = r.bottom() - rect.bottom();
+        }
+      }
+    }
   }
-  if (labs(yMin) < STICKY_THRESHOLD) {
-    _moveOffsetSticky.setY(yMin);
-    topLeft.setY(topLeft.y() - yMin);
+
+  if (labs(iXMin) < STICKY_THRESHOLD) {
+    _moveOffsetSticky.setX(iXMin);
+    topLeft.setX(topLeft.x() - iXMin);
   }
+  if (labs(iYMin) < STICKY_THRESHOLD) {
+    _moveOffsetSticky.setY(iYMin);
+    topLeft.setY(topLeft.y() - iYMin);
+  }
 
-  r.moveTopLeft(topLeft);
+  r.moveTopLeft(topLeft);      
 
   if (!_geom.contains(r, true)) {
     slideInto(_geom, r);
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewobject.cpp #546279:546280
@@ -1451,45 +1451,6 @@
 }
 
 
-void KstViewObject::snapToBorders(int *xMin, int *yMin, const KstViewObjectList &selectionList, const KstViewObjectPtr &pressTarget, const QRect &r) const {
-  for (KstViewObjectList::ConstIterator i = _children.begin(); i != _children.end(); ++i) {
-    (*i)->snapToBorders(xMin, yMin, selectionList, pressTarget, r);
-    
-    if (selectionList.find(*i) == selectionList.end() && pressTarget != *i) {
-      const QRect rect((*i)->geometry());
-        
-      int overlapLo = r.top() > rect.top() ? r.top() : rect.top();
-      int overlapHi = r.bottom() < rect.bottom() ? r.bottom() : rect.bottom();
-      if (overlapHi - overlapLo > 0) {
-        if (labs(r.left() - rect.left()) < labs(*xMin)) {
-          *xMin = r.left() - rect.left();
-        } else if (labs(r.left() - rect.right()) < labs(*xMin)) {
-          *xMin = r.left() - rect.right();
-        } else if (labs(r.right() - rect.left()) < labs(*xMin)) {
-          *xMin = r.right() - rect.left();
-        } else if (labs(r.right() - rect.right()) < labs(*xMin)) {
-          *xMin = r.right() - rect.right();
-        }
-      }
-  
-      overlapLo = r.left() > rect.left() ? r.left() : rect.left();
-      overlapHi = r.right() < rect.right() ? r.right() : rect.right();
-      if (overlapHi - overlapLo > 0) {
-        if (labs(r.top() - rect.top()) < labs(*yMin)) {
-          *yMin = r.top() - rect.top();
-        } else if (labs(r.top() - rect.bottom()) < labs(*yMin)) {
-          *yMin = r.top() - rect.bottom();
-        } else if (labs(r.bottom() - rect.top()) < labs(*yMin)) {
-          *yMin = r.bottom() - rect.top();
-        } else if (labs(r.bottom() - rect.bottom()) < labs(*yMin)) {
-          *yMin = r.bottom() - rect.bottom();
-        }
-      }
-    }
-  }
-}
-
-
 bool KstViewObject::isSelected() const {
   return _selected;
 }
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewobject.h #546279:546280
@@ -160,8 +160,6 @@
     virtual void updateSelection(const QRect& region);
     bool isContainer() const;
     
-    virtual void snapToBorders(int *xMin, int *yMin, const KstViewObjectList &selectionList, const KstViewObjectPtr &pressTarget, const QRect &r) const;
-    
     KstViewObjectPtr parent() const;
 
     void recursively(void (KstViewObject::*)(), bool self = false);


More information about the Kst mailing list