[QGIS Commit] r9062 - branches/advanced_printing_branch/src/app/composer

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat Aug 16 03:57:54 EDT 2008


Author: mhugent
Date: 2008-08-16 03:57:54 -0400 (Sat, 16 Aug 2008)
New Revision: 9062

Modified:
   branches/advanced_printing_branch/src/app/composer/qgscomposer.cpp
   branches/advanced_printing_branch/src/app/composer/qgscomposerpicture.cpp
Log:
XML reading and writing for composer picture

Modified: branches/advanced_printing_branch/src/app/composer/qgscomposer.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposer.cpp	2008-08-15 14:15:09 UTC (rev 9061)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposer.cpp	2008-08-16 07:57:54 UTC (rev 9062)
@@ -1274,6 +1274,18 @@
       mComposition->update();
     }
 
+  //composer pictures
+  QDomNodeList composerPictureList = composerElem.elementsByTagName("ComposerPicture");
+  for(int i = 0; i < composerPictureList.size(); ++i)
+    {
+      QDomElement currentPictureElem = composerPictureList.at(i).toElement();
+      QgsComposerPicture* newPicture = new QgsComposerPicture(mComposition);
+      newPicture->readXML(currentPictureElem, doc);
+      addComposerPicture(newPicture);
+      mComposition->addItem(newPicture);
+      mComposition->update();
+    }
+
   mView->setComposition(mComposition);
 }
 

Modified: branches/advanced_printing_branch/src/app/composer/qgscomposerpicture.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposerpicture.cpp	2008-08-15 14:15:09 UTC (rev 9061)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposerpicture.cpp	2008-08-16 07:57:54 UTC (rev 9062)
@@ -17,6 +17,8 @@
 /* $Id$ */
 
 #include "qgscomposerpicture.h"
+#include <QDomDocument>
+#include <QDomElement>
 #include <QFileInfo>
 #include <QImageReader>
 #include <QPainter>
@@ -189,10 +191,39 @@
 
 bool QgsComposerPicture::writeXML(QDomElement& elem, QDomDocument & doc)
 {
-  return false; //soon...
+  if(elem.isNull())
+    {
+      return false;
+    }
+  QDomElement composerPictureElem = doc.createElement("ComposerPicture");
+  composerPictureElem.setAttribute("file", mSourceFile.fileName());
+  composerPictureElem.setAttribute("rotation", QString::number(mRotation));
+  _writeXML(composerPictureElem, doc);
+  elem.appendChild(composerPictureElem);
+  return true;
 }
 
 bool QgsComposerPicture::readXML(const QDomElement& itemElem, const QDomDocument& doc)
 {
+  if(itemElem.isNull())
+    {
+      return false;
+    }
+
+  QDomNodeList composerItemList = itemElem.elementsByTagName("ComposerItem");
+  if(composerItemList.size() > 0)
+    {
+      _readXML(composerItemList.at(0).toElement(), doc);
+    }
+
+  mSvgCacheUpToDate = false;
+  mDefaultSvgSize = QSize(0, 0);
+  mCachedDpi = 0;
+  
+  QString fileName = itemElem.attribute("file");
+  setPictureFile(fileName);
+  
+  mRotation = itemElem.attribute("rotation").toDouble();
+
   return false; //soon...
 }



More information about the QGIS-commit mailing list