[Kst] extragear/graphics/kst/kst

Andrew Walker arwalker at sumusltd.com
Thu Nov 17 00:47:36 CET 2005


SVN commit 480900 by arwalker:

make code slightly more legible

 M  +11 -8     kstviewobject.cpp  


--- trunk/extragear/graphics/kst/kst/kstviewobject.cpp #480899:480900
@@ -605,13 +605,16 @@
 
 void KstViewObject::cleanup(int cols) {
   KstViewObjectList childrenCopy;
+  int rows;
+  int cnt;
+    
   for (KstViewObjectList::ConstIterator i = _children.begin(); i != _children.end(); ++i) {
     if ((*i)->followsFlow()) {
       childrenCopy.append(*i);
     }
   }
-
-  int cnt = childrenCopy.count();
+  
+  cnt = childrenCopy.count();
   if (cnt < 1) {
     return;
   }
@@ -627,20 +630,19 @@
   } else {
     if (cols > 0) {
       _columns = cols;
-//    } else if (_columns <= 0) {
     } else if (cols <= 0){
       _columns = QMAX(1, int(sqrt(cnt)));
     }
-  }
+  }  
+  rows = ( cnt + _columns - 1 ) / _columns;
 
   double minDistance = 0.0;
   int pos = 0;
   int x = 0;
   int y = 0;
   int w = _geom.width() / _columns;
-  int lastRow = cnt / _columns;
-  int h = _geom.height() / (lastRow + (cnt % _columns > 0 ? 1 : 0));
-
+  int h = _geom.height() / rows;
+    
   //kstdDebug() << "cleanup with w=" << w << " and h=" << h << endl;
   //kstdDebug() << "columns=" << _columns  << endl;
   for (int i = 0; i < cnt; ++i) {
@@ -654,7 +656,7 @@
     }
 
     // adjust the last row to be sure that we don't spill over
-    if ((pos + 1) / _columns > lastRow) {
+    if (pos / _columns == rows - 1) {
       sz.setHeight(_geom.height() - y);
     }
 
@@ -672,6 +674,7 @@
       KstViewObjectPtr vop = *nearest;
       vop->move(pt);
       vop->resize(sz);
+      vop->lowerToBottom();
       childrenCopy.remove(vop);
     }
 


More information about the Kst mailing list