Skip to content

Commit

Permalink
project file transformation from 0.10.0 to 0.11.0
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@8653 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Jun 18, 2008
1 parent 42e0ae5 commit bd7127c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
45 changes: 44 additions & 1 deletion src/core/qgsprojectfiletransform.cpp
Expand Up @@ -22,6 +22,7 @@
#include "qgslogger.h"
#include <QTextStream>
#include <QDomDocument>
#include <QPixmap> //to find out screen resolution

typedef QgsProjectVersion PFV;

Expand All @@ -30,7 +31,9 @@ QgsProjectFileTransform::transform QgsProjectFileTransform::transformers[] = {
{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)
Expand Down Expand Up @@ -234,3 +237,43 @@ void QgsProjectFileTransform::transform091to0100()

};

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);
}
}
}
1 change: 1 addition & 0 deletions src/core/qgsprojectfiletransform.h
Expand Up @@ -76,6 +76,7 @@ class QgsProjectFileTransform
void transformNull() {}; // Do absolutely nothing
void transform081to090();
void transform091to0100();
void transform0100to0110();
};


Expand Down

0 comments on commit bd7127c

Please sign in to comment.