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

Mike Fenton mike at staikos.net
Mon Jan 19 17:43:13 CET 2009


SVN commit 913641 by fenton:

Fix negative size drawing bug.


 M  +29 -0     labelitem.cpp  
 M  +3 -0      labelitem.h  
 M  +0 -6      viewitem.cpp  


--- branches/work/kst/portto4/kst/src/libkstapp/labelitem.cpp #913640:913641
@@ -133,6 +133,35 @@
 }
 
 
+void LabelItem::creationPolygonChanged(View::CreationEvent event) {
+  if (event != View::MouseRelease) {
+    ViewItem::creationPolygonChanged(event);
+    return;
+  }
+
+  if (event == View::MouseRelease) {
+    const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MouseRelease));
+    QRectF newRect(rect().x(), rect().y(),
+                   poly.last().x() - rect().x(),
+                   poly.last().y() - rect().y());
+
+    if (newRect.isNull()) {
+      // Special case for labels that don't need to have a size for creation to ensure proper parenting.
+      newRect.setSize(QSize(1, 1));
+    }
+
+    setViewRect(newRect.normalized());
+
+    parentView()->disconnect(this, SLOT(deleteLater())); //Don't delete ourself
+    parentView()->disconnect(this, SLOT(creationPolygonChanged(View::CreationEvent)));
+    parentView()->setMouseMode(View::Default);
+    maybeReparent();
+    emit creationComplete();
+    return;
+  }
+}
+
+
 void CreateLabelCommand::createItem() {
   bool ok = false;
   QString text;
--- branches/work/kst/portto4/kst/src/libkstapp/labelitem.h #913640:913641
@@ -45,6 +45,9 @@
   public Q_SLOTS:
     virtual void edit();
 
+  protected Q_SLOTS:
+    virtual void creationPolygonChanged(View::CreationEvent event);
+
   private:
     Label::Parsed *_parsed;
     QString _text;
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #913640:913641
@@ -761,12 +761,6 @@
     QRectF newRect(rect().x(), rect().y(),
                    poly.last().x() - rect().x(),
                    poly.last().y() - rect().y());
-
-    if (!newRect.isValid()) {
-      // Special case for labels that don't need to have a size for creation to ensure proper parenting.
-      newRect.setSize(QSize(1, 1));
-    }
-
     setViewRect(newRect.normalized());
 
     parentView()->disconnect(this, SLOT(deleteLater())); //Don't delete ourself


More information about the Kst mailing list