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

Mike Fenton mike at staikos.net
Fri Mar 6 22:21:50 CET 2009


SVN commit 936062 by fenton:

Fix parenting problems on object changes.
 - Add parenting check skip for items being updated as the result of parent changes.
 - Fix comparison causing children to reparent when grips extend outside of parent but not the object itself.


 M  +10 -2     viewitem.cpp  
 M  +4 -0      viewitem.h  


--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #936061:936062
@@ -55,6 +55,7 @@
     _lockAspectRatioFixed(false),
     _hasStaticGeometry(false),
     _lockParent(false),
+    _skipNextParentCheck(false),
     _allowsLayout(true),
     _hovering(false),
     _acceptsChildItems(true),
@@ -409,6 +410,7 @@
       continue;
 
 
+    viewItem->setSkipNextParentCheck(true);
     viewItem->updateChildGeometry(oldViewRect, viewRect);
   }
 }
@@ -794,6 +796,7 @@
     parentView()->disconnect(this, SLOT(deleteLater())); //Don't delete ourself
     parentView()->disconnect(this, SLOT(creationPolygonChanged(View::CreationEvent)));
     parentView()->setMouseMode(View::Default);
+
     maybeReparent();
     _creationState = Completed;
     emit creationComplete();
@@ -1290,7 +1293,8 @@
 
 
 bool ViewItem::maybeReparent() {
-  if (lockParent()) {
+  if (lockParent() || skipNextParentCheck()) {
+    setSkipNextParentCheck(false);
     return false;
   }
   //First get a list of all items that collide with this one
@@ -1344,8 +1348,12 @@
   foreach (QGraphicsItem *item, collisions) {
     ViewItem *viewItem = qgraphicsitem_cast<ViewItem*>(item);
 
-    if (!viewItem || !viewItem->acceptsChildItems() || isAncestorOf(viewItem) || !collidesWithItem(viewItem, Qt::ContainsItemShape))
+    if (!viewItem || !viewItem->acceptsChildItems() || isAncestorOf(viewItem) || !collidesWithItem(viewItem, Qt::ContainsItemBoundingRect)) {
+#if DEBUG_REPARENT
+     qDebug() << "rejecting collision" << viewItem << !viewItem->acceptsChildItems() << isAncestorOf(viewItem) << !collidesWithItem(viewItem, Qt::ContainsItemBoundingRect); 
+#endif
       continue;
+    }
 
     if (parentItem() == viewItem) { /*already done*/
 #if DEBUG_REPARENT
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.h #936061:936062
@@ -99,6 +99,9 @@
     bool lockParent() const { return _lockParent; }
     void setLockParent(bool lockParent ) { _lockParent = lockParent; }
 
+    bool skipNextParentCheck() const { return _skipNextParentCheck; }
+    void setSkipNextParentCheck(bool skipNextParentCheck) { _skipNextParentCheck = skipNextParentCheck; }
+
     bool allowsLayout() const { return _allowsLayout; }
     void setAllowsLayout(bool allowsLayout ) { _allowsLayout = allowsLayout; }
 
@@ -254,6 +257,7 @@
     bool _lockAspectRatioFixed;
     bool _hasStaticGeometry;
     bool _lockParent;
+    bool _skipNextParentCheck;
     bool _allowsLayout;
     bool _hovering;
     bool _acceptsChildItems;


More information about the Kst mailing list