Skip to content

Commit bd7127c

Browse files
author
mhugent
committedJun 18, 2008
project file transformation from 0.10.0 to 0.11.0
git-svn-id: http://svn.osgeo.org/qgis/trunk@8653 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 42e0ae5 commit bd7127c

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed
 

‎src/core/qgsprojectfiletransform.cpp

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "qgslogger.h"
2323
#include <QTextStream>
2424
#include <QDomDocument>
25+
#include <QPixmap> //to find out screen resolution
2526

2627
typedef QgsProjectVersion PFV;
2728

@@ -30,7 +31,9 @@ QgsProjectFileTransform::transform QgsProjectFileTransform::transformers[] = {
3031
{PFV(0,8,0), PFV(0,8,1), &QgsProjectFileTransform::transformNull},
3132
{PFV(0,8,1), PFV(0,9,0), &QgsProjectFileTransform::transform081to090},
3233
{PFV(0,9,0), PFV(0,9,1), &QgsProjectFileTransform::transformNull},
33-
{PFV(0,9,1), PFV(0,10,0), &QgsProjectFileTransform::transform091to0100}
34+
{PFV(0,9,1), PFV(0,10,0), &QgsProjectFileTransform::transform091to0100},
35+
{PFV(0,9,2), PFV(0,10,0), &QgsProjectFileTransform::transformNull},
36+
{PFV(0,10,0), PFV(0,11,0), &QgsProjectFileTransform::transform0100to0110}
3437
};
3538

3639
bool QgsProjectFileTransform::updateRevision(QgsProjectVersion newVersion)
@@ -234,3 +237,43 @@ void QgsProjectFileTransform::transform091to0100()
234237

235238
};
236239

240+
void QgsProjectFileTransform::transform0100to0110()
241+
{
242+
if ( ! mDom.isNull() )
243+
{
244+
//Change 'outlinewidth' in QgsSymbol
245+
QPixmap thePixmap;
246+
int screenDpi = (thePixmap.logicalDpiX() + thePixmap.logicalDpiY()) / 2;
247+
double widthScaleFactor = 25.4 / screenDpi;
248+
249+
QDomNodeList outlineWidthList = mDom.elementsByTagName("outlinewidth");
250+
for(int i = 0; i < outlineWidthList.size(); ++i)
251+
{
252+
//calculate new width
253+
QDomElement currentOutlineElem = outlineWidthList.at(i).toElement();
254+
double outlineWidth = currentOutlineElem.text().toDouble();
255+
outlineWidth *= widthScaleFactor;
256+
257+
//replace old text node
258+
QDomNode outlineTextNode = currentOutlineElem.firstChild();
259+
QDomText newOutlineText = mDom.createTextNode(QString::number(outlineWidth));
260+
currentOutlineElem.replaceChild(newOutlineText, outlineTextNode);
261+
262+
}
263+
264+
//Change 'pointsize' in QgsSymbol
265+
QDomNodeList pointSizeList = mDom.elementsByTagName("pointsize");
266+
for(int i = 0; i < pointSizeList.size(); ++i)
267+
{
268+
//calculate new size
269+
QDomElement currentPointSizeElem = pointSizeList.at(i).toElement();
270+
double pointSize = currentPointSizeElem.text().toDouble();
271+
pointSize *= widthScaleFactor;
272+
273+
//replace old text node
274+
QDomNode pointSizeTextNode = currentPointSizeElem.firstChild();
275+
QDomText newPointSizeText = mDom.createTextNode(QString::number((int)pointSize));
276+
currentPointSizeElem.replaceChild(newPointSizeText, pointSizeTextNode);
277+
}
278+
}
279+
}

‎src/core/qgsprojectfiletransform.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class QgsProjectFileTransform
7676
void transformNull() {}; // Do absolutely nothing
7777
void transform081to090();
7878
void transform091to0100();
79+
void transform0100to0110();
7980
};
8081

8182

0 commit comments

Comments
 (0)
Please sign in to comment.