Skip to content

Commit

Permalink
bugfixes and functions returning master / user's style file path
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/branches/symbology-ng-branch@10779 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed May 13, 2009
1 parent eed03a2 commit b5d6a9e
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 15 deletions.
10 changes: 10 additions & 0 deletions src/core/qgsapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@ const QString QgsApplication::svgPath()
return mPkgDataPath + QString( "/svg/" );
}

const QString QgsApplication::userStyleV2Path()
{
return qgisSettingsDirPath() + QString( "symbology-ng-style.xml" );
}

const QString QgsApplication::defaultStyleV2Path()
{
return mPkgDataPath + QString( "/resources/symbology-ng-style.xml" );
}

QgsApplication::endian_t QgsApplication::endian()
{
return ( htonl( 1 ) == 1 ) ? XDR : NDR ;
Expand Down
6 changes: 6 additions & 0 deletions src/core/qgsapplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ class CORE_EXPORT QgsApplication: public QApplication
//! Returns the path to the default theme directory.
static const QString defaultThemePath();

//! Returns the path to user's style. Added in QGIS 1.2
static const QString userStyleV2Path();

//! Returns the path to default style (works as a starting point). Added in QGIS 1.2
static const QString defaultStyleV2Path();

//! Alters prefix path - used by 3rd party apps
static void setPrefixPath( const QString thePrefixPath, bool useDefaultPaths = FALSE );

Expand Down
5 changes: 3 additions & 2 deletions src/core/symbology-ng/qgsmarkersymbollayerv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "qgsrendercontext.h"
#include "qgsapplication.h"
#include "qgslogger.h"

#include <QPainter>
#include <QSvgRenderer>
Expand Down Expand Up @@ -43,7 +44,7 @@ QgsSymbolLayerV2* QgsSimpleMarkerSymbolLayerV2::create(const QgsStringMap& props
if (props.contains("size"))
size = props["size"].toDouble();
if (props.contains("angle"))
size = props["angle"].toDouble();
angle = props["angle"].toDouble();

return new QgsSimpleMarkerSymbolLayerV2(name, color, borderColor, size, angle);
}
Expand Down Expand Up @@ -253,7 +254,7 @@ QgsSymbolLayerV2* QgsSvgMarkerSymbolLayerV2::create(const QgsStringMap& props)
if (props.contains("size"))
size = props["size"].toDouble();
if (props.contains("angle"))
size = props["angle"].toDouble();
angle = props["angle"].toDouble();

return new QgsSvgMarkerSymbolLayerV2(name, size, angle);
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology-ng/qgsstylev2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ bool QgsStyleV2::save(QString filename)

// save
QFile f(filename);
if (!f.open(QFile::ReadWrite))
if (!f.open(QFile::WriteOnly))
{
mErrorString = "Couldn't open file for writing: "+filename;
return false;
Expand Down
28 changes: 16 additions & 12 deletions src/core/symbology-ng/qgssymbolv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,19 @@ void QgsSymbolV2::dump()
}
}

QgsSymbolLayerV2List QgsSymbolV2::cloneLayers() const
{
QgsSymbolLayerV2List lst;
for (QgsSymbolLayerV2List::const_iterator it = mLayers.begin(); it != mLayers.end(); ++it)
{
QgsSymbolLayerV2* layer = (*it)->clone();
layer->setLocked( (*it)->isLocked() );
lst.append( layer );
}
return lst;
}


///////////////////


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

QgsSymbolV2* QgsMarkerSymbolV2::clone() const
{
QgsSymbolLayerV2List lst;
for (QgsSymbolLayerV2List::const_iterator it = mLayers.begin(); it != mLayers.end(); ++it)
lst.append( (*it)->clone() );
return new QgsMarkerSymbolV2(lst);
return new QgsMarkerSymbolV2( cloneLayers() );
}


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

QgsSymbolV2* QgsLineSymbolV2::clone() const
{
QgsSymbolLayerV2List lst;
for (QgsSymbolLayerV2List::const_iterator it = mLayers.begin(); it != mLayers.end(); ++it)
lst.append( (*it)->clone() );
return new QgsLineSymbolV2(lst);
return new QgsLineSymbolV2( cloneLayers() );
}

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

QgsSymbolV2* QgsFillSymbolV2::clone() const
{
QgsSymbolLayerV2List lst;
for (QgsSymbolLayerV2List::const_iterator it = mLayers.begin(); it != mLayers.end(); ++it)
lst.append( (*it)->clone() );
return new QgsFillSymbolV2(lst);
return new QgsFillSymbolV2( cloneLayers() );
}
2 changes: 2 additions & 0 deletions src/core/symbology-ng/qgssymbolv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class QgsSymbolV2

protected:
QgsSymbolV2(SymbolType type, QgsSymbolLayerV2List layers); // can't be instantiated

QgsSymbolLayerV2List cloneLayers() const;

SymbolType mType;
QgsSymbolLayerV2List mLayers;
Expand Down

0 comments on commit b5d6a9e

Please sign in to comment.