[QGIS Commit] r8653 - trunk/qgis/src/core

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Jun 18 03:49:59 EDT 2008


Author: mhugent
Date: 2008-06-18 03:49:58 -0400 (Wed, 18 Jun 2008)
New Revision: 8653

Modified:
   trunk/qgis/src/core/qgsprojectfiletransform.cpp
   trunk/qgis/src/core/qgsprojectfiletransform.h
Log:
project file transformation from 0.10.0 to 0.11.0

Modified: trunk/qgis/src/core/qgsprojectfiletransform.cpp
===================================================================
--- trunk/qgis/src/core/qgsprojectfiletransform.cpp	2008-06-17 00:20:19 UTC (rev 8652)
+++ trunk/qgis/src/core/qgsprojectfiletransform.cpp	2008-06-18 07:49:58 UTC (rev 8653)
@@ -22,6 +22,7 @@
 #include "qgslogger.h"
 #include <QTextStream>
 #include <QDomDocument>
+#include <QPixmap> //to find out screen resolution
 
 typedef QgsProjectVersion PFV;
 
@@ -30,7 +31,9 @@
   {PFV(0,8,0), PFV(0,8,1), &QgsProjectFileTransform::transformNull},
   {PFV(0,8,1), PFV(0,9,0), &QgsProjectFileTransform::transform081to090},
   {PFV(0,9,0), PFV(0,9,1), &QgsProjectFileTransform::transformNull},
-  {PFV(0,9,1), PFV(0,10,0), &QgsProjectFileTransform::transform091to0100}
+  {PFV(0,9,1), PFV(0,10,0), &QgsProjectFileTransform::transform091to0100},
+  {PFV(0,9,2), PFV(0,10,0), &QgsProjectFileTransform::transformNull},
+  {PFV(0,10,0), PFV(0,11,0), &QgsProjectFileTransform::transform0100to0110}
 };
 
 bool QgsProjectFileTransform::updateRevision(QgsProjectVersion newVersion)
@@ -234,3 +237,43 @@
 
 };
 
+void QgsProjectFileTransform::transform0100to0110()
+{
+  if ( ! mDom.isNull() )
+    {
+      //Change 'outlinewidth' in QgsSymbol
+      QPixmap thePixmap;
+      int screenDpi = (thePixmap.logicalDpiX() + thePixmap.logicalDpiY()) / 2;
+      double widthScaleFactor = 25.4 / screenDpi;
+
+      QDomNodeList outlineWidthList = mDom.elementsByTagName("outlinewidth");
+      for(int i = 0; i < outlineWidthList.size(); ++i)
+	{
+	  //calculate new width
+	  QDomElement currentOutlineElem = outlineWidthList.at(i).toElement();
+	  double outlineWidth = currentOutlineElem.text().toDouble();
+	  outlineWidth *= widthScaleFactor;
+
+	  //replace old text node
+	  QDomNode outlineTextNode = currentOutlineElem.firstChild();
+	  QDomText newOutlineText = mDom.createTextNode(QString::number(outlineWidth));
+	  currentOutlineElem.replaceChild(newOutlineText, outlineTextNode);
+	  
+	}
+
+      //Change 'pointsize' in QgsSymbol
+      QDomNodeList pointSizeList = mDom.elementsByTagName("pointsize");
+      for(int i = 0; i < pointSizeList.size(); ++i)
+	{
+	  //calculate new size
+	  QDomElement currentPointSizeElem = pointSizeList.at(i).toElement();
+	  double pointSize = currentPointSizeElem.text().toDouble();
+	  pointSize *= widthScaleFactor;
+	  
+	  //replace old text node
+	  QDomNode pointSizeTextNode = currentPointSizeElem.firstChild();
+	  QDomText newPointSizeText = mDom.createTextNode(QString::number((int)pointSize));
+	  currentPointSizeElem.replaceChild(newPointSizeText, pointSizeTextNode);
+	}
+    }
+}

Modified: trunk/qgis/src/core/qgsprojectfiletransform.h
===================================================================
--- trunk/qgis/src/core/qgsprojectfiletransform.h	2008-06-17 00:20:19 UTC (rev 8652)
+++ trunk/qgis/src/core/qgsprojectfiletransform.h	2008-06-18 07:49:58 UTC (rev 8653)
@@ -76,6 +76,7 @@
   void transformNull() {}; // Do absolutely nothing
   void transform081to090();
   void transform091to0100();
+  void transform0100to0110();
 };
 
 



More information about the QGIS-commit mailing list