Skip to content

Commit b5d6a9e

Browse files
author
wonder
committed
bugfixes and functions returning master / user's style file path
git-svn-id: http://svn.osgeo.org/qgis/branches/symbology-ng-branch@10779 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent eed03a2 commit b5d6a9e

6 files changed

Lines changed: 38 additions & 15 deletions

File tree

src/core/qgsapplication.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,16 @@ const QString QgsApplication::svgPath()
272272
return mPkgDataPath + QString( "/svg/" );
273273
}
274274

275+
const QString QgsApplication::userStyleV2Path()
276+
{
277+
return qgisSettingsDirPath() + QString( "symbology-ng-style.xml" );
278+
}
279+
280+
const QString QgsApplication::defaultStyleV2Path()
281+
{
282+
return mPkgDataPath + QString( "/resources/symbology-ng-style.xml" );
283+
}
284+
275285
QgsApplication::endian_t QgsApplication::endian()
276286
{
277287
return ( htonl( 1 ) == 1 ) ? XDR : NDR ;

src/core/qgsapplication.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ class CORE_EXPORT QgsApplication: public QApplication
111111
//! Returns the path to the default theme directory.
112112
static const QString defaultThemePath();
113113

114+
//! Returns the path to user's style. Added in QGIS 1.2
115+
static const QString userStyleV2Path();
116+
117+
//! Returns the path to default style (works as a starting point). Added in QGIS 1.2
118+
static const QString defaultStyleV2Path();
119+
114120
//! Alters prefix path - used by 3rd party apps
115121
static void setPrefixPath( const QString thePrefixPath, bool useDefaultPaths = FALSE );
116122

src/core/symbology-ng/qgsmarkersymbollayerv2.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "qgsrendercontext.h"
66
#include "qgsapplication.h"
7+
#include "qgslogger.h"
78

89
#include <QPainter>
910
#include <QSvgRenderer>
@@ -43,7 +44,7 @@ QgsSymbolLayerV2* QgsSimpleMarkerSymbolLayerV2::create(const QgsStringMap& props
4344
if (props.contains("size"))
4445
size = props["size"].toDouble();
4546
if (props.contains("angle"))
46-
size = props["angle"].toDouble();
47+
angle = props["angle"].toDouble();
4748

4849
return new QgsSimpleMarkerSymbolLayerV2(name, color, borderColor, size, angle);
4950
}
@@ -253,7 +254,7 @@ QgsSymbolLayerV2* QgsSvgMarkerSymbolLayerV2::create(const QgsStringMap& props)
253254
if (props.contains("size"))
254255
size = props["size"].toDouble();
255256
if (props.contains("angle"))
256-
size = props["angle"].toDouble();
257+
angle = props["angle"].toDouble();
257258

258259
return new QgsSvgMarkerSymbolLayerV2(name, size, angle);
259260
}

src/core/symbology-ng/qgsstylev2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ bool QgsStyleV2::save(QString filename)
411411

412412
// save
413413
QFile f(filename);
414-
if (!f.open(QFile::ReadWrite))
414+
if (!f.open(QFile::WriteOnly))
415415
{
416416
mErrorString = "Couldn't open file for writing: "+filename;
417417
return false;

src/core/symbology-ng/qgssymbolv2.cpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,19 @@ void QgsSymbolV2::dump()
198198
}
199199
}
200200

201+
QgsSymbolLayerV2List QgsSymbolV2::cloneLayers() const
202+
{
203+
QgsSymbolLayerV2List lst;
204+
for (QgsSymbolLayerV2List::const_iterator it = mLayers.begin(); it != mLayers.end(); ++it)
205+
{
206+
QgsSymbolLayerV2* layer = (*it)->clone();
207+
layer->setLocked( (*it)->isLocked() );
208+
lst.append( layer );
209+
}
210+
return lst;
211+
}
212+
213+
201214
///////////////////
202215

203216

@@ -263,10 +276,7 @@ void QgsMarkerSymbolV2::renderPoint(const QPointF& point, QgsRenderContext& cont
263276

264277
QgsSymbolV2* QgsMarkerSymbolV2::clone() const
265278
{
266-
QgsSymbolLayerV2List lst;
267-
for (QgsSymbolLayerV2List::const_iterator it = mLayers.begin(); it != mLayers.end(); ++it)
268-
lst.append( (*it)->clone() );
269-
return new QgsMarkerSymbolV2(lst);
279+
return new QgsMarkerSymbolV2( cloneLayers() );
270280
}
271281

272282

@@ -315,10 +325,7 @@ void QgsLineSymbolV2::renderPolyline(const QPolygonF& points, QgsRenderContext&
315325

316326
QgsSymbolV2* QgsLineSymbolV2::clone() const
317327
{
318-
QgsSymbolLayerV2List lst;
319-
for (QgsSymbolLayerV2List::const_iterator it = mLayers.begin(); it != mLayers.end(); ++it)
320-
lst.append( (*it)->clone() );
321-
return new QgsLineSymbolV2(lst);
328+
return new QgsLineSymbolV2( cloneLayers() );
322329
}
323330

324331
///////////////////
@@ -343,8 +350,5 @@ void QgsFillSymbolV2::renderPolygon(const QPolygonF& points, QList<QPolygonF>* r
343350

344351
QgsSymbolV2* QgsFillSymbolV2::clone() const
345352
{
346-
QgsSymbolLayerV2List lst;
347-
for (QgsSymbolLayerV2List::const_iterator it = mLayers.begin(); it != mLayers.end(); ++it)
348-
lst.append( (*it)->clone() );
349-
return new QgsFillSymbolV2(lst);
353+
return new QgsFillSymbolV2( cloneLayers() );
350354
}

src/core/symbology-ng/qgssymbolv2.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class QgsSymbolV2
7070

7171
protected:
7272
QgsSymbolV2(SymbolType type, QgsSymbolLayerV2List layers); // can't be instantiated
73+
74+
QgsSymbolLayerV2List cloneLayers() const;
7375

7476
SymbolType mType;
7577
QgsSymbolLayerV2List mLayers;

0 commit comments

Comments
 (0)