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

Mike Fenton mike at staikos.net
Mon Dec 29 19:46:21 CET 2008


SVN commit 903023 by fenton:

Fix child item saving / restoring.
Add saving of SharedAxisBoxItem's.


 M  +1 -1      arrowitem.cpp  
 M  +1 -1      boxitem.cpp  
 M  +2 -0      builtingraphics.cpp  
 M  +1 -1      circleitem.cpp  
 M  +1 -1      ellipseitem.cpp  
 M  +1 -1      labelitem.cpp  
 M  +1 -1      layoutboxitem.cpp  
 M  +1 -1      lineitem.cpp  
 M  +1 -1      pictureitem.cpp  
 M  +1 -1      plotitem.cpp  
 M  +28 -4     sharedaxisboxitem.cpp  
 M  +1 -0      sharedaxisboxitem.h  
 M  +1 -1      svgitem.cpp  
 M  +3 -1      view.cpp  
 M  +16 -4     viewitem.cpp  


--- branches/work/kst/portto4/kst/src/libkstapp/arrowitem.cpp #903022:903023
@@ -125,7 +125,7 @@
   while (!xml.atEnd()) {
     bool validTag = true;
     if (xml.isStartElement()) {
-      if (xml.name().toString() == "arrow") {
+      if (!rc && xml.name().toString() == "arrow") {
         Q_ASSERT(!rc);
         rc = new ArrowItem(view);
         if (parent) {
--- branches/work/kst/portto4/kst/src/libkstapp/boxitem.cpp #903022:903023
@@ -67,7 +67,7 @@
   while (!xml.atEnd()) {
     bool validTag = true;
     if (xml.isStartElement()) {
-      if (xml.name().toString() == "box") {
+      if (!rc && xml.name().toString() == "box") {
         Q_ASSERT(!rc);
         rc = new BoxItem(view);
         if (parent) {
--- branches/work/kst/portto4/kst/src/libkstapp/builtingraphics.cpp #903022:903023
@@ -20,6 +20,7 @@
 #include "svgitem.h"
 #include "arrowitem.h"
 #include "circleitem.h"
+#include "sharedaxisboxitem.h"
 
 namespace Kst {
   namespace Builtins {
@@ -34,6 +35,7 @@
       new PictureItemFactory;
       new PlotItemFactory;
       new SvgItemFactory;
+      new SharedAxisBoxItemFactory;
     }
   }
 }
--- branches/work/kst/portto4/kst/src/libkstapp/circleitem.cpp #903022:903023
@@ -105,7 +105,7 @@
   while (!xml.atEnd()) {
     bool validTag = true;
     if (xml.isStartElement()) {
-      if (xml.name().toString() == "circle") {
+      if (!rc && xml.name().toString() == "circle") {
         Q_ASSERT(!rc);
         rc = new CircleItem(view);
         if (parent) {
--- branches/work/kst/portto4/kst/src/libkstapp/ellipseitem.cpp #903022:903023
@@ -76,7 +76,7 @@
   while (!xml.atEnd()) {
     bool validTag = true;
     if (xml.isStartElement()) {
-      if (xml.name().toString() == "ellipse") {
+      if (!rc && xml.name().toString() == "ellipse") {
         Q_ASSERT(!rc);
         rc = new EllipseItem(view);
         if (parent) {
--- branches/work/kst/portto4/kst/src/libkstapp/labelitem.cpp #903022:903023
@@ -171,7 +171,7 @@
   while (!xml.atEnd()) {
     bool validTag = true;
     if (xml.isStartElement()) {
-      if (xml.name().toString() == "label") {
+      if (!rc && xml.name().toString() == "label") {
       QXmlStreamAttributes attrs = xml.attributes();
       QStringRef av;
       av = attrs.value("text");
--- branches/work/kst/portto4/kst/src/libkstapp/layoutboxitem.cpp #903022:903023
@@ -163,7 +163,7 @@
   while (!xml.atEnd()) {
     bool validTag = true;
     if (xml.isStartElement()) {
-      if (xml.name().toString() == "layoutbox") {
+      if (!rc && xml.name().toString() == "layoutbox") {
         Q_ASSERT(!rc);
         rc = new LayoutBoxItem(view);
         if (parent) {
--- branches/work/kst/portto4/kst/src/libkstapp/lineitem.cpp #903022:903023
@@ -259,7 +259,7 @@
   while (!xml.atEnd()) {
     bool validTag = true;
     if (xml.isStartElement()) {
-      if (xml.name().toString() == "line") {
+      if (!rc && xml.name().toString() == "line") {
         Q_ASSERT(!rc);
         rc = new LineItem(view);
         if (parent) {
--- branches/work/kst/portto4/kst/src/libkstapp/pictureitem.cpp #903022:903023
@@ -94,7 +94,7 @@
   while (!xml.atEnd()) {
     bool validTag = true;
     if (xml.isStartElement()) {
-      if (xml.name().toString() == "picture") {
+      if (!rc && xml.name().toString() == "picture") {
         Q_ASSERT(!rc);
         rc = new PictureItem(view);
         if (parent) {
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #903022:903023
@@ -2460,7 +2460,7 @@
   while (!xml.atEnd()) {
     bool validTag = true;
     if (xml.isStartElement()) {
-      if (xml.name().toString() == "plot") {
+      if (!rc && xml.name().toString() == "plot") {
         Q_ASSERT(!rc);
         rc = new PlotItem(view);
         if (parent) {
--- branches/work/kst/portto4/kst/src/libkstapp/sharedaxisboxitem.cpp #903022:903023
@@ -79,6 +79,7 @@
         plotItem->setParent(this);
         plotItem->setAllowedGripModes(0);
         plotItem->setFlags(0);
+        plotItem->setTiedZoom(true);
         child = plotItem;
       }
     }
@@ -135,9 +136,12 @@
     if (!viewItem)
       continue;
 
-    viewItem->setParent(0);
-    viewItem->setAllowedGripModes(Move | Resize | Rotate);
-    viewItem->setFlags(ItemIsMovable | ItemIsSelectable | ItemIsFocusable);
+    if (PlotItem *plotItem = qobject_cast<PlotItem*>(viewItem)) {
+      plotItem->setParent(0);
+      plotItem->setAllowedGripModes(Move | Resize | Rotate);
+      plotItem->setFlags(ItemIsMovable | ItemIsSelectable | ItemIsFocusable);
+      plotItem->setTiedZoom(false);
+    }
   }
   if (_layout) {
     _layout->reset();
@@ -146,6 +150,25 @@
 }
 
 
+void SharedAxisBoxItem::lockItems() {
+  QList<QGraphicsItem*> list = QGraphicsItem::children();
+  foreach (QGraphicsItem *item, list) {
+    ViewItem *viewItem = qgraphicsitem_cast<ViewItem*>(item);
+    if (!viewItem)
+      continue;
+
+    if (PlotItem *plotItem = qobject_cast<PlotItem*>(viewItem)) {
+      plotItem->setAllowedGripModes(0);
+      plotItem->setFlags(0);
+      plotItem->setTiedZoom(true);
+    }
+  }
+  if (!list.isEmpty()) {
+    setBrush(Qt::white);
+  }
+}
+
+
 void SharedAxisBoxItem::addToMenuForContextEvent(QMenu &menu) {
   menu.addAction(_breakAction);
 }
@@ -194,7 +217,7 @@
   while (!xml.atEnd()) {
     bool validTag = true;
     if (xml.isStartElement()) {
-      if (xml.name().toString() == "sharedaxisbox") {
+      if (!rc && xml.name().toString() == "sharedaxisbox") {
         Q_ASSERT(!rc);
         rc = new SharedAxisBoxItem(view);
         if (parent) {
@@ -224,6 +247,7 @@
     }
     xml.readNext();
   }
+  rc->lockItems();
   return rc;
 }
 
--- branches/work/kst/portto4/kst/src/libkstapp/sharedaxisboxitem.h #903022:903023
@@ -35,6 +35,7 @@
   public slots:
     void breakShare();
     void acceptItems();
+    void lockItems();
 
   private:
     QAction *_breakAction;
--- branches/work/kst/portto4/kst/src/libkstapp/svgitem.cpp #903022:903023
@@ -98,7 +98,7 @@
   while (!xml.atEnd()) {
     bool validTag = true;
     if (xml.isStartElement()) {
-      if (xml.name().toString() == "svg") {
+      if (!rc && xml.name().toString() == "svg") {
         Q_ASSERT(!rc);
         rc = new SvgItem(view);
         if (parent) {
--- branches/work/kst/portto4/kst/src/libkstapp/view.cpp #903022:903023
@@ -125,7 +125,9 @@
   QList<QGraphicsItem*> items = scene()->items();
 
   foreach(QGraphicsItem* viewItem, items) {
-    qgraphicsitem_cast<ViewItem*>(viewItem)->save(xml);
+    if (!viewItem->parentItem()) {
+      qgraphicsitem_cast<ViewItem*>(viewItem)->save(xml);
+    }
   }
 }
 
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #903022:903023
@@ -152,6 +152,15 @@
     xml.writeAttribute("gradient", stopList);
   }
   xml.writeEndElement();
+
+  QList<QGraphicsItem*> list = QGraphicsItem::children();
+  foreach (QGraphicsItem *item, list) {
+    ViewItem *viewItem = qgraphicsitem_cast<ViewItem*>(item);
+    if (!viewItem)
+      continue;
+
+    viewItem->save(xml);
+  }
 }
 
 
@@ -268,6 +277,7 @@
       }
      setViewRect(QRectF(QPointF(x, y), QSizeF(w, h)));
     } else if (xml.name().toString() == "transform") {
+      knownTag = true;
       double m11 = 1.0, m12 = 0, m13 = 0, m21 = 0, m22 = 1.0, m23 = 0, m31 = 0, m32= 0, m33 = 1.0;
       av = attrs.value("m11");
       if (!av.isNull()) {
@@ -309,10 +319,12 @@
     }
   }
 
-  xml.readNext();
-  if (xml.isEndElement()) {
-    if ((xml.name().toString() == expectedTag) ) {
-    validChildTag = true;
+  if (knownTag) {
+    xml.readNext();
+    if (xml.isEndElement()) {
+      if ((xml.name().toString() == expectedTag) ) {
+      validChildTag = true;
+      }
     }
   }
   return knownTag;


More information about the Kst mailing list