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

Mike Fenton mike at staikos.net
Mon Jan 5 20:34:12 CET 2009


SVN commit 906223 by fenton:

Fix saving to skip saving of items that are hidden (have been undone and not redone).


 M  +9 -7      arrowitem.cpp  
 M  +5 -3      boxitem.cpp  
 M  +5 -3      circleitem.cpp  
 M  +5 -3      ellipseitem.cpp  
 M  +9 -7      labelitem.cpp  
 M  +13 -11    layoutboxitem.cpp  
 M  +5 -3      lineitem.cpp  
 M  +12 -10    pictureitem.cpp  
 M  +51 -49    plotitem.cpp  
 M  +5 -3      sharedaxisboxitem.cpp  
 M  +8 -6      svgitem.cpp  


--- branches/work/kst/portto4/kst/src/libkstapp/arrowitem.cpp #906222:906223
@@ -87,13 +87,15 @@
 
 
 void ArrowItem::save(QXmlStreamWriter &xml) {
-  xml.writeStartElement("arrow");
-  xml.writeAttribute("startarrowhead", QVariant(_startArrowHead).toString());
-  xml.writeAttribute("endarrowhead", QVariant(_startArrowHead).toString());
-  xml.writeAttribute("startarrowheadscale", QVariant(_startArrowScale).toString());
-  xml.writeAttribute("endarrowheadscale", QVariant(_endArrowScale).toString());
-  ViewItem::save(xml);
-  xml.writeEndElement();
+  if (isVisible()) {
+    xml.writeStartElement("arrow");
+    xml.writeAttribute("startarrowhead", QVariant(_startArrowHead).toString());
+    xml.writeAttribute("endarrowhead", QVariant(_startArrowHead).toString());
+    xml.writeAttribute("startarrowheadscale", QVariant(_startArrowScale).toString());
+    xml.writeAttribute("endarrowheadscale", QVariant(_endArrowScale).toString());
+    ViewItem::save(xml);
+    xml.writeEndElement();
+  }
 }
 
 
--- branches/work/kst/portto4/kst/src/libkstapp/boxitem.cpp #906222:906223
@@ -38,9 +38,11 @@
 
 
 void BoxItem::save(QXmlStreamWriter &xml) {
-  xml.writeStartElement("box");
-  ViewItem::save(xml);
-  xml.writeEndElement();
+  if (isVisible()) {
+    xml.writeStartElement("box");
+    ViewItem::save(xml);
+    xml.writeEndElement();
+  }
 }
 
 
--- branches/work/kst/portto4/kst/src/libkstapp/circleitem.cpp #906222:906223
@@ -41,9 +41,11 @@
 
 
 void CircleItem::save(QXmlStreamWriter &xml) {
-  xml.writeStartElement("circle");
-  ViewItem::save(xml);
-  xml.writeEndElement();
+  if (isVisible()) {
+    xml.writeStartElement("circle");
+    ViewItem::save(xml);
+    xml.writeEndElement();
+  }
 }
 
 
--- branches/work/kst/portto4/kst/src/libkstapp/ellipseitem.cpp #906222:906223
@@ -34,9 +34,11 @@
 
 
 void EllipseItem::save(QXmlStreamWriter &xml) {
-  xml.writeStartElement("ellipse");
-  ViewItem::save(xml);
-  xml.writeEndElement();
+  if (isVisible()) {
+    xml.writeStartElement("ellipse");
+    ViewItem::save(xml);
+    xml.writeEndElement();
+  }
 }
 
 
--- branches/work/kst/portto4/kst/src/libkstapp/labelitem.cpp #906222:906223
@@ -73,13 +73,15 @@
 
 
 void LabelItem::save(QXmlStreamWriter &xml) {
-  xml.writeStartElement("label");
-  xml.writeAttribute("text", _text);
-  xml.writeAttribute("scale", QVariant(_scale).toString());
-  xml.writeAttribute("color", QVariant(_color).toString());
-  xml.writeAttribute("font", QVariant(_font).toString());
-  ViewItem::save(xml);
-  xml.writeEndElement();
+  if (isVisible()) {
+    xml.writeStartElement("label");
+    xml.writeAttribute("text", _text);
+    xml.writeAttribute("scale", QVariant(_scale).toString());
+    xml.writeAttribute("color", QVariant(_color).toString());
+    xml.writeAttribute("font", QVariant(_font).toString());
+    ViewItem::save(xml);
+    xml.writeEndElement();
+  }
 }
 
 
--- branches/work/kst/portto4/kst/src/libkstapp/layoutboxitem.cpp #906222:906223
@@ -54,21 +54,23 @@
 
 
 void LayoutBoxItem::save(QXmlStreamWriter &xml) {
-  xml.writeStartElement("layoutbox");
-  ViewItem::save(xml);
+  if (isVisible()) {
+    xml.writeStartElement("layoutbox");
+    ViewItem::save(xml);
 
-  QList<QGraphicsItem*> list = QGraphicsItem::children();
-  foreach (QGraphicsItem *item, list) {
-    ViewItem *viewItem = qgraphicsitem_cast<ViewItem*>(item);
-    if (!viewItem)
-      continue;
+    QList<QGraphicsItem*> list = QGraphicsItem::children();
+    foreach (QGraphicsItem *item, list) {
+      ViewItem *viewItem = qgraphicsitem_cast<ViewItem*>(item);
+      if (!viewItem)
+        continue;
 
-    xml.writeStartElement("layoutitem");
-    xml.writeAttribute("name", viewItem->name());
+      xml.writeStartElement("layoutitem");
+      xml.writeAttribute("name", viewItem->name());
+      xml.writeEndElement();
+    }
+
     xml.writeEndElement();
   }
-
-  xml.writeEndElement();
 }
 
 
--- branches/work/kst/portto4/kst/src/libkstapp/lineitem.cpp #906222:906223
@@ -45,9 +45,11 @@
 
 
 void LineItem::save(QXmlStreamWriter &xml) {
-  xml.writeStartElement("line");
-  ViewItem::save(xml);
-  xml.writeEndElement();
+  if (isVisible()) {
+    xml.writeStartElement("line");
+    ViewItem::save(xml);
+    xml.writeEndElement();
+  }
 }
 
 
--- branches/work/kst/portto4/kst/src/libkstapp/pictureitem.cpp #906222:906223
@@ -39,16 +39,18 @@
 
 
 void PictureItem::save(QXmlStreamWriter &xml) {
-  xml.writeStartElement("picture");
-  ViewItem::save(xml);
-  xml.writeStartElement("data");
-  QByteArray qba;
-  QBuffer buffer(&qba);
-  buffer.open(QIODevice::WriteOnly);
-  QImage(_image).save(&buffer, "PNG"); // writes image into ba in PNG format
-  xml.writeCharacters(qCompress(qba).toBase64());
-  xml.writeEndElement();
-  xml.writeEndElement();
+  if (isVisible()) {
+    xml.writeStartElement("picture");
+    ViewItem::save(xml);
+    xml.writeStartElement("data");
+    QByteArray qba;
+    QBuffer buffer(&qba);
+    buffer.open(QIODevice::WriteOnly);
+    QImage(_image).save(&buffer, "PNG"); // writes image into ba in PNG format
+    xml.writeCharacters(qCompress(qba).toBase64());
+    xml.writeEndElement();
+    xml.writeEndElement();
+  }
 }
 
 
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #906222:906223
@@ -144,58 +144,60 @@
 
 
 void PlotItem::save(QXmlStreamWriter &xml) {
-  xml.writeStartElement("plot");
-  xml.writeAttribute("tiedzoom", QVariant(_isTiedZoom).toString());
-  xml.writeAttribute("leftlabelvisible", QVariant(_isLeftLabelVisible).toString());
-  xml.writeAttribute("bottomlabelvisible", QVariant(_isBottomLabelVisible).toString());
-  xml.writeAttribute("rightlabelvisible", QVariant(_isRightLabelVisible).toString());
-  xml.writeAttribute("toplabelvisible", QVariant(_isTopLabelVisible).toString());
-  xml.writeAttribute("globalfont", QVariant(_globalFont).toString());
-  xml.writeAttribute("globalfontscale", QVariant(_globalFontScale).toString());
-  xml.writeAttribute("globalfontcolor", QVariant(_globalFontColor).toString());
-  xml.writeAttribute("leftlabeloverride", _leftLabelOverride);
-  xml.writeAttribute("leftlabeluseglobal", QVariant(_leftFontUseGlobal).toString());
-  xml.writeAttribute("leftlabelfont", QVariant(_leftLabelFont).toString());
-  xml.writeAttribute("leftlabelfontscale", QVariant(_leftLabelFontScale).toString());
-  xml.writeAttribute("leftlabelfontcolor", QVariant(_leftLabelFontColor).toString());
-  xml.writeAttribute("bottomlabeloverride", _bottomLabelOverride);
-  xml.writeAttribute("bottomlabeluseglobal", QVariant(_bottomFontUseGlobal).toString());
-  xml.writeAttribute("bottomlabelfont", QVariant(_bottomLabelFont).toString());
-  xml.writeAttribute("bottomlabelfontscale", QVariant(_bottomLabelFontScale).toString());
-  xml.writeAttribute("bottomlabelfontcolor", QVariant(_bottomLabelFontColor).toString());
-  xml.writeAttribute("toplabeloverride", _topLabelOverride);
-  xml.writeAttribute("toplabeluseglobal", QVariant(_topFontUseGlobal).toString());
-  xml.writeAttribute("toplabelfont", QVariant(_topLabelFont).toString());
-  xml.writeAttribute("toplabelfontscale", QVariant(_topLabelFontScale).toString());
-  xml.writeAttribute("toplabelfontcolor", QVariant(_topLabelFontColor).toString());
-  xml.writeAttribute("rightlabeloverride", _rightLabelOverride);
-  xml.writeAttribute("rightlabeluseglobal", QVariant(_rightFontUseGlobal).toString());
-  xml.writeAttribute("rightlabelfont", QVariant(_rightLabelFont).toString());
-  xml.writeAttribute("rightlabelfontscale", QVariant(_rightLabelFontScale).toString());
-  xml.writeAttribute("rightlabelfontcolor", QVariant(_rightLabelFontColor).toString());
-  xml.writeAttribute("numberlabelfont", QVariant(_numberLabelFont).toString());
-  xml.writeAttribute("numberlabeluseglobal", QVariant(_numberFontUseGlobal).toString());
-  xml.writeAttribute("numberlabelfontscale", QVariant(_numberLabelFontScale).toString());
-  xml.writeAttribute("numberlabelfontcolor", QVariant(_numberLabelFontColor).toString());
-  xml.writeAttribute("showlegend", QVariant(_showLegend).toString());
-  saveNameInfo(xml, GNUM);
+  if (isVisible()) {
+    xml.writeStartElement("plot");
+    xml.writeAttribute("tiedzoom", QVariant(_isTiedZoom).toString());
+    xml.writeAttribute("leftlabelvisible", QVariant(_isLeftLabelVisible).toString());
+    xml.writeAttribute("bottomlabelvisible", QVariant(_isBottomLabelVisible).toString());
+    xml.writeAttribute("rightlabelvisible", QVariant(_isRightLabelVisible).toString());
+    xml.writeAttribute("toplabelvisible", QVariant(_isTopLabelVisible).toString());
+    xml.writeAttribute("globalfont", QVariant(_globalFont).toString());
+    xml.writeAttribute("globalfontscale", QVariant(_globalFontScale).toString());
+    xml.writeAttribute("globalfontcolor", QVariant(_globalFontColor).toString());
+    xml.writeAttribute("leftlabeloverride", _leftLabelOverride);
+    xml.writeAttribute("leftlabeluseglobal", QVariant(_leftFontUseGlobal).toString());
+    xml.writeAttribute("leftlabelfont", QVariant(_leftLabelFont).toString());
+    xml.writeAttribute("leftlabelfontscale", QVariant(_leftLabelFontScale).toString());
+    xml.writeAttribute("leftlabelfontcolor", QVariant(_leftLabelFontColor).toString());
+    xml.writeAttribute("bottomlabeloverride", _bottomLabelOverride);
+    xml.writeAttribute("bottomlabeluseglobal", QVariant(_bottomFontUseGlobal).toString());
+    xml.writeAttribute("bottomlabelfont", QVariant(_bottomLabelFont).toString());
+    xml.writeAttribute("bottomlabelfontscale", QVariant(_bottomLabelFontScale).toString());
+    xml.writeAttribute("bottomlabelfontcolor", QVariant(_bottomLabelFontColor).toString());
+    xml.writeAttribute("toplabeloverride", _topLabelOverride);
+    xml.writeAttribute("toplabeluseglobal", QVariant(_topFontUseGlobal).toString());
+    xml.writeAttribute("toplabelfont", QVariant(_topLabelFont).toString());
+    xml.writeAttribute("toplabelfontscale", QVariant(_topLabelFontScale).toString());
+    xml.writeAttribute("toplabelfontcolor", QVariant(_topLabelFontColor).toString());
+    xml.writeAttribute("rightlabeloverride", _rightLabelOverride);
+    xml.writeAttribute("rightlabeluseglobal", QVariant(_rightFontUseGlobal).toString());
+    xml.writeAttribute("rightlabelfont", QVariant(_rightLabelFont).toString());
+    xml.writeAttribute("rightlabelfontscale", QVariant(_rightLabelFontScale).toString());
+    xml.writeAttribute("rightlabelfontcolor", QVariant(_rightLabelFontColor).toString());
+    xml.writeAttribute("numberlabelfont", QVariant(_numberLabelFont).toString());
+    xml.writeAttribute("numberlabeluseglobal", QVariant(_numberFontUseGlobal).toString());
+    xml.writeAttribute("numberlabelfontscale", QVariant(_numberLabelFontScale).toString());
+    xml.writeAttribute("numberlabelfontcolor", QVariant(_numberLabelFontColor).toString());
+    xml.writeAttribute("showlegend", QVariant(_showLegend).toString());
+    saveNameInfo(xml, GNUM);
 
-  ViewItem::save(xml);
-  legend()->saveInPlot(xml);
+    ViewItem::save(xml);
+    legend()->saveInPlot(xml);
 
-  foreach (PlotRenderItem *renderer, renderItems()) {
-    renderer->saveInPlot(xml);
+    foreach (PlotRenderItem *renderer, renderItems()) {
+      renderer->saveInPlot(xml);
+    }
+    _xAxis->saveInPlot(xml, QString("xaxis"));
+    _yAxis->saveInPlot(xml, QString("yaxis"));
+
+    xml.writeStartElement("projectionrect");
+    xml.writeAttribute("x", QVariant(projectionRect().x()).toString());
+    xml.writeAttribute("y", QVariant(projectionRect().y()).toString());
+    xml.writeAttribute("width", QVariant(projectionRect().width()).toString());
+    xml.writeAttribute("height", QVariant(projectionRect().height()).toString());
+    xml.writeEndElement();
+    xml.writeEndElement();
   }
-  _xAxis->saveInPlot(xml, QString("xaxis"));
-  _yAxis->saveInPlot(xml, QString("yaxis"));
-
-  xml.writeStartElement("projectionrect");
-  xml.writeAttribute("x", QVariant(projectionRect().x()).toString());
-  xml.writeAttribute("y", QVariant(projectionRect().y()).toString());
-  xml.writeAttribute("width", QVariant(projectionRect().width()).toString());
-  xml.writeAttribute("height", QVariant(projectionRect().height()).toString());
-  xml.writeEndElement();
-  xml.writeEndElement();
 }
 
 
--- branches/work/kst/portto4/kst/src/libkstapp/sharedaxisboxitem.cpp #906222:906223
@@ -50,9 +50,11 @@
 
 
 void SharedAxisBoxItem::save(QXmlStreamWriter &xml) {
-  xml.writeStartElement("sharedaxisbox");
-  ViewItem::save(xml);
-  xml.writeEndElement();
+  if (isVisible()) {
+    xml.writeStartElement("sharedaxisbox");
+    ViewItem::save(xml);
+    xml.writeEndElement();
+  }
 }
 
 
--- branches/work/kst/portto4/kst/src/libkstapp/svgitem.cpp #906222:906223
@@ -57,12 +57,14 @@
 
 
 void SvgItem::save(QXmlStreamWriter &xml) {
-  xml.writeStartElement("svg");
-  ViewItem::save(xml);
-  xml.writeStartElement("data");
-  xml.writeCharacters(qCompress(_svgData).toBase64());
-  xml.writeEndElement();
-  xml.writeEndElement();
+  if (isVisible()) {
+    xml.writeStartElement("svg");
+    ViewItem::save(xml);
+    xml.writeStartElement("data");
+    xml.writeCharacters(qCompress(_svgData).toBase64());
+    xml.writeEndElement();
+    xml.writeEndElement();
+  }
 }
 
 


More information about the Kst mailing list