automatic indentation update (r12139-r12177)

git-svn-id: http://svn.osgeo.org/qgis/trunk@12178 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
jef 2009-11-18 20:58:09 +00:00
parent 621ee62280
commit 29adf23846
17 changed files with 555 additions and 555 deletions

View File

@ -35,7 +35,7 @@ QgsMeasureDialog::QgsMeasureDialog( QgsMeasureTool* tool, Qt::WFlags f )
: QDialog( tool->canvas()->topLevelWidget(), f ), mTool( tool )
{
setupUi( this );
QPushButton *nb = new QPushButton( tr( "&New" ) );
buttonBox->addButton( nb, QDialogButtonBox::ActionRole );
connect( nb, SIGNAL( clicked() ), this, SLOT( restart() ) );

View File

@ -78,10 +78,10 @@ class CORE_EXPORT QgsMapLayer : public QObject
*/
QString const & name() const;
/** This is the method that does the actual work of
/** This is the method that does the actual work of
* drawing the layer onto a paint device.
* @param QgsRenderContext - describes the extents,
* resolution etc. that should be used when rendering the
* @param QgsRenderContext - describes the extents,
* resolution etc. that should be used when rendering the
* layer.
*/
virtual bool draw( QgsRenderContext& rendererContext );
@ -291,9 +291,9 @@ class CORE_EXPORT QgsMapLayer : public QObject
/** Get the QImage used for caching render operations
* @note This method was added in QGIS 1.4 **/
QImage * cacheImage() { return mpCacheImage; }
/** Set the QImage used for caching render operations
/** Set the QImage used for caching render operations
* @note This method was added in QGIS 1.4 **/
void setCacheImage( QImage * thepImage );
void setCacheImage( QImage * thepImage );
public slots:

View File

@ -212,7 +212,7 @@ void QgsMapRenderer::adjustExtentToSize()
void QgsMapRenderer::render( QPainter* painter )
{
//flag to see if the render context has changed
//flag to see if the render context has changed
//since the last time we rendered. If it hasnt changed we can
//take some shortcuts with rendering
bool mySameAsLastFlag = true;
@ -285,20 +285,20 @@ void QgsMapRenderer::render( QPainter* painter )
mySameAsLastFlag = false;
}
mRenderContext.setLabelingEngine(mLabelingEngine);
mRenderContext.setLabelingEngine( mLabelingEngine );
if ( mLabelingEngine )
mLabelingEngine->init();
// know we know if this render is just a repeat of the last time, we
// know we know if this render is just a repeat of the last time, we
// can clear caches if it has changed
if ( !mySameAsLastFlag )
{
//clear the cache pixmap if we changed resolution / extent
QSettings mySettings;
if ( mySettings.value ( "/qgis/enable_render_caching", false ).toBool() )
{
QgsMapLayerRegistry::instance()->clearAllLayerCaches();
}
//clear the cache pixmap if we changed resolution / extent
QSettings mySettings;
if ( mySettings.value( "/qgis/enable_render_caching", false ).toBool() )
{
QgsMapLayerRegistry::instance()->clearAllLayerCaches();
}
}
bool placeOverlays = false;
@ -322,7 +322,7 @@ void QgsMapRenderer::render( QPainter* painter )
break;
}
// Store the painter in case we need to swap it out for the
// Store the painter in case we need to swap it out for the
// cache painter
QPainter * mypContextPainter = mRenderContext.painter();
@ -422,17 +422,17 @@ void QgsMapRenderer::render( QPainter* painter )
ml->setCacheImage( 0 );
}
}
QSettings mySettings;
if ( ! split )//render caching does not yet cater for split extents
{
if ( mySettings.value ( "/qgis/enable_render_caching", false ).toBool() )
if ( mySettings.value( "/qgis/enable_render_caching", false ).toBool() )
{
if ( !mySameAsLastFlag || ml->cacheImage() == 0 )
if ( !mySameAsLastFlag || ml->cacheImage() == 0 )
{
QgsDebugMsg( "\n\n\nCaching enabled but layer redraw forced by extent change or empty cache\n\n\n" );
QImage * mypImage = new QImage( mRenderContext.painter()->device()->width(),
mRenderContext.painter()->device()->height(), QImage::Format_ARGB32 );
QImage * mypImage = new QImage( mRenderContext.painter()->device()->width(),
mRenderContext.painter()->device()->height(), QImage::Format_ARGB32 );
mypImage->fill( 0 );
ml->setCacheImage( mypImage ); //no need to delete the old one, maplayer does it for you
QPainter * mypPainter = new QPainter( ml->cacheImage() );
@ -440,13 +440,13 @@ void QgsMapRenderer::render( QPainter* painter )
{
mypPainter->setRenderHint( QPainter::Antialiasing );
}
mRenderContext.setPainter( mypPainter );
mRenderContext.setPainter( mypPainter );
}
else if ( mySameAsLastFlag )
{
//draw from cached image
QgsDebugMsg( "\n\n\nCaching enabled --- drawing layer from cached image\n\n\n" );
mypContextPainter->drawImage( 0,0, *(ml->cacheImage()) );
mypContextPainter->drawImage( 0, 0, *( ml->cacheImage() ) );
disconnect( ml, SIGNAL( drawingProgress( int, int ) ), this, SLOT( onDrawingProgress( int, int ) ) );
//short circuit as there is nothing else to do...
continue;
@ -472,7 +472,7 @@ void QgsMapRenderer::render( QPainter* painter )
}
else
{
QgsDebugMsg( "\n\n\nLayer rendered without issues\n\n\n" );
QgsDebugMsg( "\n\n\nLayer rendered without issues\n\n\n" );
}
if ( split )
{
@ -489,16 +489,16 @@ void QgsMapRenderer::render( QPainter* painter )
mRenderContext.painter()->restore();
}
if ( mySettings.value ( "/qgis/enable_render_caching", false ).toBool() )
if ( mySettings.value( "/qgis/enable_render_caching", false ).toBool() )
{
if ( !split )
{
// composite the cached image into our view and then clean up from caching
// by reinstating the painter as it was swapped out for caching renders
delete mRenderContext.painter();
mRenderContext.setPainter( mypContextPainter );
mRenderContext.setPainter( mypContextPainter );
//draw from cached image that we created further up
mypContextPainter->drawImage( 0,0, *(ml->cacheImage()) );
mypContextPainter->drawImage( 0, 0, *( ml->cacheImage() ) );
}
}
disconnect( ml, SIGNAL( drawingProgress( int, int ) ), this, SLOT( onDrawingProgress( int, int ) ) );
@ -506,7 +506,7 @@ void QgsMapRenderer::render( QPainter* painter )
else // layer not visible due to scale
{
QgsDebugMsg( "Layer not rendered because it is not within the defined "
"visibility scale range" );
"visibility scale range" );
}
} // while (li.hasPrevious())
@ -1055,9 +1055,9 @@ bool QgsMapRenderer::writeXML( QDomNode & theNode, QDomDocument & theDoc )
return true;
}
void QgsMapRenderer::setLabelingEngine(QgsLabelingEngineInterface* iface)
void QgsMapRenderer::setLabelingEngine( QgsLabelingEngineInterface* iface )
{
if (mLabelingEngine)
if ( mLabelingEngine )
delete mLabelingEngine;
mLabelingEngine = iface;

View File

@ -42,19 +42,19 @@ class QgsFeature;
*/
class QgsLabelingEngineInterface
{
public:
virtual ~QgsLabelingEngineInterface() {}
public:
virtual ~QgsLabelingEngineInterface() {}
//! called when we're going to start with rendering
virtual void init() = 0;
//! called when starting rendering of a layer
virtual int prepareLayer(QgsVectorLayer* layer, int& attrIndex) = 0;
//! called for every feature
virtual void registerFeature( QgsVectorLayer* layer, QgsFeature& feat ) = 0;
//! called when the map is drawn and labels should be placed
virtual void drawLabeling( QgsRenderContext& context ) = 0;
//! called when we're done with rendering
virtual void exit() = 0;
//! called when we're going to start with rendering
virtual void init() = 0;
//! called when starting rendering of a layer
virtual int prepareLayer( QgsVectorLayer* layer, int& attrIndex ) = 0;
//! called for every feature
virtual void registerFeature( QgsVectorLayer* layer, QgsFeature& feat ) = 0;
//! called when the map is drawn and labels should be placed
virtual void drawLabeling( QgsRenderContext& context ) = 0;
//! called when we're done with rendering
virtual void exit() = 0;
};
@ -178,7 +178,7 @@ class CORE_EXPORT QgsMapRenderer : public QObject
//! Set labeling engine. Previous engine (if any) is deleted.
//! Takes ownership of the engine.
//! Added in QGIS v1.4
void setLabelingEngine(QgsLabelingEngineInterface* iface);
void setLabelingEngine( QgsLabelingEngineInterface* iface );
signals:
@ -234,7 +234,7 @@ class CORE_EXPORT QgsMapRenderer : public QObject
//! current extent to be drawn
QgsRectangle mExtent;
//
/** Last extent to we drew so we know if we can
/** Last extent to we drew so we know if we can
used layer render caching or not. Note there are no
accessors for this as it is intended to internal
use only.

View File

@ -19,7 +19,7 @@
#include "qgsrendercontext.h"
QgsRenderContext::QgsRenderContext()
: mPainter( 0 ),
: mPainter( 0 ),
mCoordTransform( 0 ),
mDrawEditingInformation( false ),
mForceVectorOutput( true ),

View File

@ -76,7 +76,7 @@ class CORE_EXPORT QgsRenderContext
void setRendererScale( double scale ) {mRendererScale = scale;}
void setPainter( QPainter* p ) {mPainter = p;}
//! Added in QGIS v1.4
void setLabelingEngine(QgsLabelingEngineInterface* iface) { mLabelingEngine = iface; }
void setLabelingEngine( QgsLabelingEngineInterface* iface ) { mLabelingEngine = iface; }
private:

View File

@ -6,14 +6,14 @@
#include <QPainter>
QgsSimpleFillSymbolLayerV2::QgsSimpleFillSymbolLayerV2(QColor color, Qt::BrushStyle style, QColor borderColor, Qt::PenStyle borderStyle, double borderWidth)
: mBrushStyle(style), mBorderColor(borderColor), mBorderStyle(borderStyle), mBorderWidth(borderWidth)
QgsSimpleFillSymbolLayerV2::QgsSimpleFillSymbolLayerV2( QColor color, Qt::BrushStyle style, QColor borderColor, Qt::PenStyle borderStyle, double borderWidth )
: mBrushStyle( style ), mBorderColor( borderColor ), mBorderStyle( borderStyle ), mBorderWidth( borderWidth )
{
mColor = color;
}
QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2::create(const QgsStringMap& props)
QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2::create( const QgsStringMap& props )
{
QColor color = DEFAULT_SIMPLEFILL_COLOR;
Qt::BrushStyle style = DEFAULT_SIMPLEFILL_STYLE;
@ -21,18 +21,18 @@ QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2::create(const QgsStringMap& props)
Qt::PenStyle borderStyle = DEFAULT_SIMPLEFILL_BORDERSTYLE;
double borderWidth = DEFAULT_SIMPLEFILL_BORDERWIDTH;
if (props.contains("color"))
color = QgsSymbolLayerV2Utils::decodeColor(props["color"]);
if (props.contains("style"))
style = QgsSymbolLayerV2Utils::decodeBrushStyle(props["style"]);
if (props.contains("color_border"))
borderColor = QgsSymbolLayerV2Utils::decodeColor(props["color_border"]);
if (props.contains("style_border"))
borderStyle = QgsSymbolLayerV2Utils::decodePenStyle(props["style_border"]);
if (props.contains("width_border"))
if ( props.contains( "color" ) )
color = QgsSymbolLayerV2Utils::decodeColor( props["color"] );
if ( props.contains( "style" ) )
style = QgsSymbolLayerV2Utils::decodeBrushStyle( props["style"] );
if ( props.contains( "color_border" ) )
borderColor = QgsSymbolLayerV2Utils::decodeColor( props["color_border"] );
if ( props.contains( "style_border" ) )
borderStyle = QgsSymbolLayerV2Utils::decodePenStyle( props["style_border"] );
if ( props.contains( "width_border" ) )
borderWidth = props["width_border"].toDouble();
return new QgsSimpleFillSymbolLayerV2(color, style, borderColor, borderStyle, borderWidth);
return new QgsSimpleFillSymbolLayerV2( color, style, borderColor, borderStyle, borderWidth );
}
@ -41,54 +41,54 @@ QString QgsSimpleFillSymbolLayerV2::layerType() const
return "SimpleFill";
}
void QgsSimpleFillSymbolLayerV2::startRender(QgsRenderContext& context)
void QgsSimpleFillSymbolLayerV2::startRender( QgsRenderContext& context )
{
mBrush = QBrush(mColor, mBrushStyle);
mPen = QPen(mBorderColor);
mPen.setStyle(mBorderStyle);
mPen.setWidthF(mBorderWidth);
mBrush = QBrush( mColor, mBrushStyle );
mPen = QPen( mBorderColor );
mPen.setStyle( mBorderStyle );
mPen.setWidthF( mBorderWidth );
}
void QgsSimpleFillSymbolLayerV2::stopRender(QgsRenderContext& context)
void QgsSimpleFillSymbolLayerV2::stopRender( QgsRenderContext& context )
{
}
void QgsSimpleFillSymbolLayerV2::renderPolygon(const QPolygonF& points, QList<QPolygonF>* rings, QgsRenderContext& context)
void QgsSimpleFillSymbolLayerV2::renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsRenderContext& context )
{
QPainter* p = context.painter();
p->setBrush(mBrush);
p->setPen(mPen);
if (rings == NULL)
p->setBrush( mBrush );
p->setPen( mPen );
if ( rings == NULL )
{
// simple polygon without holes
p->drawPolygon(points);
p->drawPolygon( points );
}
else
{
// polygon with holes must be drawn using painter path
QPainterPath path;
path.addPolygon(points);
path.addPolygon( points );
QList<QPolygonF>::iterator it;
for (it = rings->begin(); it != rings->end(); ++it)
path.addPolygon(*it);
p->drawPath(path);
for ( it = rings->begin(); it != rings->end(); ++it )
path.addPolygon( *it );
p->drawPath( path );
}
}
QgsStringMap QgsSimpleFillSymbolLayerV2::properties() const
{
QgsStringMap map;
map["color"] = QgsSymbolLayerV2Utils::encodeColor(mColor);
map["style"] = QgsSymbolLayerV2Utils::encodeBrushStyle(mBrushStyle);
map["color_border"] = QgsSymbolLayerV2Utils::encodeColor(mBorderColor);
map["style_border"] = QgsSymbolLayerV2Utils::encodePenStyle(mBorderStyle);
map["width_border"] = QString::number(mBorderWidth);
map["color"] = QgsSymbolLayerV2Utils::encodeColor( mColor );
map["style"] = QgsSymbolLayerV2Utils::encodeBrushStyle( mBrushStyle );
map["color_border"] = QgsSymbolLayerV2Utils::encodeColor( mBorderColor );
map["style_border"] = QgsSymbolLayerV2Utils::encodePenStyle( mBorderStyle );
map["width_border"] = QString::number( mBorderWidth );
return map;
}
QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2::clone() const
{
return new QgsSimpleFillSymbolLayerV2(mColor, mBrushStyle, mBorderColor, mBorderStyle, mBorderWidth);
return new QgsSimpleFillSymbolLayerV2( mColor, mBrushStyle, mBorderColor, mBorderStyle, mBorderWidth );
}

View File

@ -21,7 +21,7 @@ class CORE_EXPORT QgsSimpleFillSymbolLayerV2 : public QgsFillSymbolLayerV2
QColor borderColor = DEFAULT_SIMPLEFILL_BORDERCOLOR,
Qt::PenStyle borderStyle = DEFAULT_SIMPLEFILL_BORDERSTYLE,
double borderWidth = DEFAULT_SIMPLEFILL_BORDERWIDTH );
// static stuff
static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );

View File

@ -101,7 +101,7 @@ QgsSymbolLayerV2* QgsSimpleLineSymbolLayerV2::clone() const
class MyLine
{
public:
MyLine( QPointF p1, QPointF p2 ) : mVertical(false), mIncreasing(false), mT(0.0), mLength(0.0)
MyLine( QPointF p1, QPointF p2 ) : mVertical( false ), mIncreasing( false ), mT( 0.0 ), mLength( 0.0 )
{
if ( p1 == p2 )
return; // invalid
@ -356,7 +356,7 @@ static double _calculateAngle( double x1, double y1, double x2, double y2 )
{
// return angle (in radians) between two points
if ( x1 == x2 )
return M_PI * ( y2 >= y1 ? 1 / 2 : 3 / 2 ); // angle is 90 or 270
return M_PI *( y2 >= y1 ? 1 / 2 : 3 / 2 ); // angle is 90 or 270
double t = ( y2 - y1 ) / ( x2 - x1 );
if ( t >= 0 )

View File

@ -30,7 +30,7 @@ QgsStyleV2::~QgsStyleV2()
QgsStyleV2* QgsStyleV2::defaultStyle() // static
{
if (mDefaultStyle == NULL)
if ( mDefaultStyle == NULL )
{
QString styleFilename = QgsApplication::userStyleV2Path();
@ -49,48 +49,48 @@ QgsStyleV2* QgsStyleV2::defaultStyle() // static
void QgsStyleV2::clear()
{
for (QMap<QString, QgsSymbolV2*>::iterator its = mSymbols.begin(); its != mSymbols.end(); ++its)
for ( QMap<QString, QgsSymbolV2*>::iterator its = mSymbols.begin(); its != mSymbols.end(); ++its )
delete its.value();
for (QMap<QString, QgsVectorColorRampV2*>::iterator itr = mColorRamps.begin(); itr != mColorRamps.end(); ++itr)
for ( QMap<QString, QgsVectorColorRampV2*>::iterator itr = mColorRamps.begin(); itr != mColorRamps.end(); ++itr )
delete itr.value();
mSymbols.clear();
mColorRamps.clear();
}
bool QgsStyleV2::addSymbol(QString name, QgsSymbolV2* symbol)
bool QgsStyleV2::addSymbol( QString name, QgsSymbolV2* symbol )
{
if (!symbol || name.count() == 0)
if ( !symbol || name.count() == 0 )
return false;
// delete previous symbol (if any)
if (mSymbols.contains(name))
delete mSymbols.value(name);
mSymbols.insert(name, symbol);
if ( mSymbols.contains( name ) )
delete mSymbols.value( name );
mSymbols.insert( name, symbol );
return true;
}
bool QgsStyleV2::removeSymbol(QString name)
bool QgsStyleV2::removeSymbol( QString name )
{
if (!mSymbols.contains(name))
if ( !mSymbols.contains( name ) )
return false;
// remove from map and delete
delete mSymbols.take(name);
delete mSymbols.take( name );
return true;
}
QgsSymbolV2* QgsStyleV2::symbol(QString name)
QgsSymbolV2* QgsStyleV2::symbol( QString name )
{
if (!mSymbols.contains(name))
if ( !mSymbols.contains( name ) )
return NULL;
return mSymbols[name]->clone();
}
const QgsSymbolV2* QgsStyleV2::symbolRef(QString name) const
const QgsSymbolV2* QgsStyleV2::symbolRef( QString name ) const
{
if (!mSymbols.contains(name))
if ( !mSymbols.contains( name ) )
return NULL;
return mSymbols[name];
}
@ -106,39 +106,39 @@ QStringList QgsStyleV2::symbolNames()
}
bool QgsStyleV2::addColorRamp(QString name, QgsVectorColorRampV2* colorRamp)
bool QgsStyleV2::addColorRamp( QString name, QgsVectorColorRampV2* colorRamp )
{
if (!colorRamp || name.count() == 0)
if ( !colorRamp || name.count() == 0 )
return false;
// delete previous symbol (if any)
if (mColorRamps.contains(name))
delete mColorRamps.value(name);
mColorRamps.insert(name, colorRamp);
if ( mColorRamps.contains( name ) )
delete mColorRamps.value( name );
mColorRamps.insert( name, colorRamp );
return true;
}
bool QgsStyleV2::removeColorRamp(QString name)
bool QgsStyleV2::removeColorRamp( QString name )
{
if (!mColorRamps.contains(name))
if ( !mColorRamps.contains( name ) )
return false;
// remove from map and delete
delete mColorRamps.take(name);
delete mColorRamps.take( name );
return true;
}
QgsVectorColorRampV2* QgsStyleV2::colorRamp(QString name)
QgsVectorColorRampV2* QgsStyleV2::colorRamp( QString name )
{
if (!mColorRamps.contains(name))
if ( !mColorRamps.contains( name ) )
return NULL;
return mColorRamps[name]->clone();
}
const QgsVectorColorRampV2* QgsStyleV2::colorRampRef(QString name) const
const QgsVectorColorRampV2* QgsStyleV2::colorRampRef( QString name ) const
{
if (!mColorRamps.contains(name))
if ( !mColorRamps.contains( name ) )
return NULL;
return mColorRamps[name];
}
@ -147,71 +147,71 @@ int QgsStyleV2::colorRampCount()
{
return mColorRamps.count();
}
QStringList QgsStyleV2::colorRampNames()
{
return mColorRamps.keys();
}
bool QgsStyleV2::load(QString filename)
bool QgsStyleV2::load( QString filename )
{
mErrorString = QString();
// import xml file
QDomDocument doc("style");
QFile f(filename);
if (!f.open(QFile::ReadOnly))
QDomDocument doc( "style" );
QFile f( filename );
if ( !f.open( QFile::ReadOnly ) )
{
mErrorString = "Couldn't open the style file: " + filename;
return false;
}
// parse the document
if (!doc.setContent(&f))
if ( !doc.setContent( &f ) )
{
mErrorString = "Couldn't parse the style file: " + filename;
f.close();
return false;
}
f.close();
QDomElement docElem = doc.documentElement();
if (docElem.tagName() != "qgis_style")
if ( docElem.tagName() != "qgis_style" )
{
mErrorString = "Incorrect root tag in style: " + docElem.tagName();
return false;
}
// check for style version
QString version = docElem.attribute("version");
if (version != STYLE_CURRENT_VERSION)
QString version = docElem.attribute( "version" );
if ( version != STYLE_CURRENT_VERSION )
{
mErrorString = "Unknown style file version: " + version;
return false;
}
// load symbols
QDomElement symbolsElement = docElem.firstChildElement("symbols");
if (!symbolsElement.isNull())
QDomElement symbolsElement = docElem.firstChildElement( "symbols" );
if ( !symbolsElement.isNull() )
{
mSymbols = QgsSymbolLayerV2Utils::loadSymbols(symbolsElement);
mSymbols = QgsSymbolLayerV2Utils::loadSymbols( symbolsElement );
}
// load color ramps
QDomElement rampsElement = docElem.firstChildElement("colorramps");
QDomElement rampsElement = docElem.firstChildElement( "colorramps" );
QDomElement e = rampsElement.firstChildElement();
while (!e.isNull())
while ( !e.isNull() )
{
if (e.tagName() == "colorramp")
if ( e.tagName() == "colorramp" )
{
QgsVectorColorRampV2* ramp = QgsSymbolLayerV2Utils::loadColorRamp(e);
if (ramp != NULL)
addColorRamp(e.attribute("name"), ramp);
QgsVectorColorRampV2* ramp = QgsSymbolLayerV2Utils::loadColorRamp( e );
if ( ramp != NULL )
addColorRamp( e.attribute( "name" ), ramp );
}
else
{
QgsDebugMsg("unknown tag: " + e.tagName());
QgsDebugMsg( "unknown tag: " + e.tagName() );
}
e = e.nextSiblingElement();
}
@ -222,42 +222,42 @@ bool QgsStyleV2::load(QString filename)
bool QgsStyleV2::save(QString filename)
bool QgsStyleV2::save( QString filename )
{
mErrorString = QString();
if (filename.isEmpty())
if ( filename.isEmpty() )
filename = mFileName;
QDomDocument doc("qgis_style");
QDomElement root = doc.createElement("qgis_style");
root.setAttribute("version", STYLE_CURRENT_VERSION);
doc.appendChild(root);
QDomElement symbolsElem = QgsSymbolLayerV2Utils::saveSymbols(mSymbols, "symbols", doc);
QDomDocument doc( "qgis_style" );
QDomElement root = doc.createElement( "qgis_style" );
root.setAttribute( "version", STYLE_CURRENT_VERSION );
doc.appendChild( root );
QDomElement symbolsElem = QgsSymbolLayerV2Utils::saveSymbols( mSymbols, "symbols", doc );
QDomElement rampsElem = doc.createElement( "colorramps" );
QDomElement rampsElem = doc.createElement("colorramps");
// save color ramps
for (QMap<QString, QgsVectorColorRampV2*>::iterator itr = mColorRamps.begin(); itr != mColorRamps.end(); ++itr)
for ( QMap<QString, QgsVectorColorRampV2*>::iterator itr = mColorRamps.begin(); itr != mColorRamps.end(); ++itr )
{
QDomElement rampEl = QgsSymbolLayerV2Utils::saveColorRamp(itr.key(), itr.value(), doc);
rampsElem.appendChild(rampEl);
QDomElement rampEl = QgsSymbolLayerV2Utils::saveColorRamp( itr.key(), itr.value(), doc );
rampsElem.appendChild( rampEl );
}
root.appendChild(symbolsElem);
root.appendChild(rampsElem);
root.appendChild( symbolsElem );
root.appendChild( rampsElem );
// save
QFile f(filename);
if (!f.open(QFile::WriteOnly))
QFile f( filename );
if ( !f.open( QFile::WriteOnly ) )
{
mErrorString = "Couldn't open file for writing: "+filename;
mErrorString = "Couldn't open file for writing: " + filename;
return false;
}
QTextStream ts(&f);
doc.save(ts, 2);
QTextStream ts( &f );
doc.save( ts, 2 );
f.close();
mFileName = filename;
return true;
}

View File

@ -218,9 +218,9 @@ void QgsSymbol::setNamedPointSymbol( QString name )
QgsDebugMsg( "Name: " + name );
//see if we can resolve the problem...
//
QStringList svgPaths = QgsApplication::svgPaths();
for( int i=0; i<svgPaths.size(); i++)
for ( int i = 0; i < svgPaths.size(); i++ )
{
QgsDebugMsg( "SvgPath: " + svgPaths[i] );
QFileInfo myInfo( myTempName );
@ -515,14 +515,14 @@ bool QgsSymbol::writeXML( QDomNode & item, QDomDocument & document, const QgsVec
QStringList svgPaths = QgsApplication::svgPaths();
for(int i=0; i<svgPaths.size(); i++)
for ( int i = 0; i < svgPaths.size(); i++ )
{
QString dir = QFileInfo( svgPaths[i] ).canonicalFilePath();
if ( !dir.isEmpty() && name.startsWith( dir ) )
{
name = name.mid( dir.size() );
break;
break;
}
}
}

View File

@ -260,9 +260,9 @@ void QgsCategorizedSymbolRendererV2Widget::addCategories()
if ( ramp == NULL )
{
if ( cboCategorizedColorRamp->count() == 0 )
QMessageBox::critical( this, tr("Error"), tr("There are no available color ramps. You can add them in Style Manager.") );
QMessageBox::critical( this, tr( "Error" ), tr( "There are no available color ramps. You can add them in Style Manager." ) );
else
QMessageBox::critical( this, tr("Error"), tr("The selected color ramp is not available.") );
QMessageBox::critical( this, tr( "Error" ), tr( "The selected color ramp is not available." ) );
return;
}

View File

@ -16,46 +16,46 @@
#include <QStandardItem>
QgsRendererV2Widget* QgsGraduatedSymbolRendererV2Widget::create(QgsVectorLayer* layer, QgsStyleV2* style, QgsFeatureRendererV2* renderer)
QgsRendererV2Widget* QgsGraduatedSymbolRendererV2Widget::create( QgsVectorLayer* layer, QgsStyleV2* style, QgsFeatureRendererV2* renderer )
{
return new QgsGraduatedSymbolRendererV2Widget(layer, style, renderer);
return new QgsGraduatedSymbolRendererV2Widget( layer, style, renderer );
}
QgsGraduatedSymbolRendererV2Widget::QgsGraduatedSymbolRendererV2Widget(QgsVectorLayer* layer, QgsStyleV2* style, QgsFeatureRendererV2* renderer)
: QgsRendererV2Widget(layer, style)
QgsGraduatedSymbolRendererV2Widget::QgsGraduatedSymbolRendererV2Widget( QgsVectorLayer* layer, QgsStyleV2* style, QgsFeatureRendererV2* renderer )
: QgsRendererV2Widget( layer, style )
{
// try to recognize the previous renderer
// (null renderer means "no previous renderer")
if (!renderer || renderer->type() != "graduatedSymbol")
if ( !renderer || renderer->type() != "graduatedSymbol" )
{
// we're not going to use it - so let's delete the renderer
delete renderer;
mRenderer = new QgsGraduatedSymbolRendererV2("", QgsRangeList());
mRenderer = new QgsGraduatedSymbolRendererV2( "", QgsRangeList() );
}
else
{
mRenderer = static_cast<QgsGraduatedSymbolRendererV2*>(renderer);
mRenderer = static_cast<QgsGraduatedSymbolRendererV2*>( renderer );
}
// setup user interface
setupUi(this);
setupUi( this );
populateColumns();
populateColorRamps();
QStandardItemModel* mg = new QStandardItemModel(this);
QStandardItemModel* mg = new QStandardItemModel( this );
QStringList labels;
labels << "Range" << "Label";
mg->setHorizontalHeaderLabels(labels);
viewGraduated->setModel(mg);
mg->setHorizontalHeaderLabels( labels );
viewGraduated->setModel( mg );
mGraduatedSymbol = QgsSymbolV2::defaultSymbol(mLayer->geometryType());
mGraduatedSymbol = QgsSymbolV2::defaultSymbol( mLayer->geometryType() );
connect(viewGraduated, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(rangesDoubleClicked(const QModelIndex &)));
connect( viewGraduated, SIGNAL( doubleClicked( const QModelIndex & ) ), this, SLOT( rangesDoubleClicked( const QModelIndex & ) ) );
connect(btnGraduatedClassify, SIGNAL(clicked()), this, SLOT(classifyGraduated()));
connect(btnChangeGraduatedSymbol, SIGNAL(clicked()), this, SLOT(changeGraduatedSymbol()));
connect( btnGraduatedClassify, SIGNAL( clicked() ), this, SLOT( classifyGraduated() ) );
connect( btnChangeGraduatedSymbol, SIGNAL( clicked() ), this, SLOT( changeGraduatedSymbol() ) );
// initialize from previously set renderer
updateUiFromRenderer();
@ -79,20 +79,20 @@ void QgsGraduatedSymbolRendererV2Widget::updateUiFromRenderer()
populateRanges();
// update UI from the graduated renderer (update combo boxes, view)
if (mRenderer->mode() < cboGraduatedMode->count())
if ( mRenderer->mode() < cboGraduatedMode->count() )
cboGraduatedMode->setCurrentIndex( mRenderer->mode() );
if (mRenderer->ranges().count())
if ( mRenderer->ranges().count() )
spinGraduatedClasses->setValue( mRenderer->ranges().count() );
// set column
//disconnect(cboGraduatedColumn, SIGNAL(currentIndexChanged(int)), this, SLOT(graduatedColumnChanged()));
QString attrName = mRenderer->classAttribute();
int idx = cboGraduatedColumn->findText(attrName, Qt::MatchExactly);
cboGraduatedColumn->setCurrentIndex(idx >= 0 ? idx : 0);
int idx = cboGraduatedColumn->findText( attrName, Qt::MatchExactly );
cboGraduatedColumn->setCurrentIndex( idx >= 0 ? idx : 0 );
//connect(cboGraduatedColumn, SIGNAL(currentIndexChanged(int)), this, SLOT(graduatedColumnChanged()));
// set source symbol
if (mRenderer->sourceSymbol())
if ( mRenderer->sourceSymbol() )
{
delete mGraduatedSymbol;
mGraduatedSymbol = mRenderer->sourceSymbol()->clone();
@ -100,15 +100,15 @@ void QgsGraduatedSymbolRendererV2Widget::updateUiFromRenderer()
}
// set source color ramp
if (mRenderer->sourceColorRamp())
if ( mRenderer->sourceColorRamp() )
{
QSize rampIconSize(50,16);
QIcon icon = QgsSymbolLayerV2Utils::colorRampPreviewIcon(mRenderer->sourceColorRamp(), rampIconSize);
if (cboGraduatedColorRamp->itemText(0) == "[source]")
cboGraduatedColorRamp->setItemIcon(0, icon);
QSize rampIconSize( 50, 16 );
QIcon icon = QgsSymbolLayerV2Utils::colorRampPreviewIcon( mRenderer->sourceColorRamp(), rampIconSize );
if ( cboGraduatedColorRamp->itemText( 0 ) == "[source]" )
cboGraduatedColorRamp->setItemIcon( 0, icon );
else
cboGraduatedColorRamp->insertItem(0, icon, "[source]");
cboGraduatedColorRamp->setCurrentIndex(0);
cboGraduatedColorRamp->insertItem( 0, icon, "[source]" );
cboGraduatedColorRamp->setCurrentIndex( 0 );
}
}
@ -120,25 +120,25 @@ void QgsGraduatedSymbolRendererV2Widget::populateColumns()
cboGraduatedColumn->clear();
const QgsFieldMap& flds = mLayer->pendingFields();
QgsFieldMap::ConstIterator it = flds.begin();
for ( ; it != flds.end(); ++it)
for ( ; it != flds.end(); ++it )
{
if (it->type() == QVariant::Double || it->type() == QVariant::Int)
cboGraduatedColumn->addItem(it->name());
if ( it->type() == QVariant::Double || it->type() == QVariant::Int )
cboGraduatedColumn->addItem( it->name() );
}
}
void QgsGraduatedSymbolRendererV2Widget::populateColorRamps()
{
QSize rampIconSize(50,16);
cboGraduatedColorRamp->setIconSize(rampIconSize);
QSize rampIconSize( 50, 16 );
cboGraduatedColorRamp->setIconSize( rampIconSize );
QStringList rampNames = mStyle->colorRampNames();
for (QStringList::iterator it = rampNames.begin(); it != rampNames.end(); ++it)
for ( QStringList::iterator it = rampNames.begin(); it != rampNames.end(); ++it )
{
QgsVectorColorRampV2* ramp = mStyle->colorRamp(*it);
QIcon icon = QgsSymbolLayerV2Utils::colorRampPreviewIcon(ramp, rampIconSize);
cboGraduatedColorRamp->addItem(icon, *it);
QgsVectorColorRampV2* ramp = mStyle->colorRamp( *it );
QIcon icon = QgsSymbolLayerV2Utils::colorRampPreviewIcon( ramp, rampIconSize );
cboGraduatedColorRamp->addItem( icon, *it );
delete ramp;
}
}
@ -153,7 +153,7 @@ void QgsGraduatedSymbolRendererV2Widget::classifyGraduated()
QgsVectorColorRampV2* ramp = NULL;
QString rampName = cboGraduatedColorRamp->currentText();
if (rampName == "[source]")
if ( rampName == "[source]" )
ramp = mRenderer->sourceColorRamp()->clone();
else
ramp = mStyle->colorRamp( rampName );
@ -161,14 +161,14 @@ void QgsGraduatedSymbolRendererV2Widget::classifyGraduated()
if ( ramp == NULL )
{
if ( cboGraduatedColorRamp->count() == 0 )
QMessageBox::critical( this, tr("Error"), tr("There are no available color ramps. You can add them in Style Manager.") );
QMessageBox::critical( this, tr( "Error" ), tr( "There are no available color ramps. You can add them in Style Manager." ) );
else
QMessageBox::critical( this, tr("Error"), tr("The selected color ramp is not available.") );
QMessageBox::critical( this, tr( "Error" ), tr( "The selected color ramp is not available." ) );
return;
}
QgsGraduatedSymbolRendererV2::Mode mode;
if (cboGraduatedMode->currentIndex() == 0)
if ( cboGraduatedMode->currentIndex() == 0 )
mode = QgsGraduatedSymbolRendererV2::EqualInterval;
else
mode = QgsGraduatedSymbolRendererV2::Quantile;
@ -176,15 +176,15 @@ void QgsGraduatedSymbolRendererV2Widget::classifyGraduated()
// create and set new renderer
delete mRenderer;
mRenderer = QgsGraduatedSymbolRendererV2::createRenderer(
mLayer, attrName, classes, mode, mGraduatedSymbol, ramp);
mLayer, attrName, classes, mode, mGraduatedSymbol, ramp );
populateRanges();
}
void QgsGraduatedSymbolRendererV2Widget::changeGraduatedSymbol()
{
QgsSymbolV2SelectorDialog dlg(mGraduatedSymbol, mStyle, this);
if (!dlg.exec())
QgsSymbolV2SelectorDialog dlg( mGraduatedSymbol, mStyle, this );
if ( !dlg.exec() )
return;
updateGraduatedSymbolIcon();
@ -192,42 +192,42 @@ void QgsGraduatedSymbolRendererV2Widget::changeGraduatedSymbol()
void QgsGraduatedSymbolRendererV2Widget::updateGraduatedSymbolIcon()
{
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon(mGraduatedSymbol, btnChangeGraduatedSymbol->iconSize());
btnChangeGraduatedSymbol->setIcon(icon);
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( mGraduatedSymbol, btnChangeGraduatedSymbol->iconSize() );
btnChangeGraduatedSymbol->setIcon( icon );
}
void QgsGraduatedSymbolRendererV2Widget::populateRanges()
{
QStandardItemModel* m = qobject_cast<QStandardItemModel*>(viewGraduated->model());
QStandardItemModel* m = qobject_cast<QStandardItemModel*>( viewGraduated->model() );
m->clear();
QStringList labels;
labels << "Range" << "Label";
m->setHorizontalHeaderLabels(labels);
m->setHorizontalHeaderLabels( labels );
QSize iconSize(16,16);
QSize iconSize( 16, 16 );
int i, count = mRenderer->ranges().count();
for (i = 0; i < count; i++)
for ( i = 0; i < count; i++ )
{
const QgsRendererRangeV2& range = mRenderer->ranges()[i];
QString rangeStr = QString::number(range.lowerValue(),'f',4) + " - " + QString::number(range.upperValue(),'f',4);
QString rangeStr = QString::number( range.lowerValue(), 'f', 4 ) + " - " + QString::number( range.upperValue(), 'f', 4 );
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon(range.symbol(), iconSize);
QStandardItem* item = new QStandardItem(icon, rangeStr);
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( range.symbol(), iconSize );
QStandardItem* item = new QStandardItem( icon, rangeStr );
//item->setData(k); // set attribute value as user role
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
QList<QStandardItem *> list;
list << item << new QStandardItem(range.label());
list << item << new QStandardItem( range.label() );
m->appendRow( list );
}
// make sure that the "range" column has visible context
viewGraduated->resizeColumnToContents(0);
viewGraduated->resizeColumnToContents( 0 );
}
@ -241,25 +241,25 @@ int QgsRendererV2PropertiesDialog::currentRangeRow()
}
*/
void QgsGraduatedSymbolRendererV2Widget::rangesDoubleClicked(const QModelIndex & idx)
void QgsGraduatedSymbolRendererV2Widget::rangesDoubleClicked( const QModelIndex & idx )
{
if (idx.isValid() && idx.column() == 0)
changeRangeSymbol(idx.row());
if ( idx.isValid() && idx.column() == 0 )
changeRangeSymbol( idx.row() );
}
void QgsGraduatedSymbolRendererV2Widget::changeRangeSymbol(int rangeIdx)
void QgsGraduatedSymbolRendererV2Widget::changeRangeSymbol( int rangeIdx )
{
QgsSymbolV2* newSymbol = mRenderer->ranges()[rangeIdx].symbol()->clone();
QgsSymbolV2SelectorDialog dlg(newSymbol, mStyle, this);
if (!dlg.exec())
QgsSymbolV2SelectorDialog dlg( newSymbol, mStyle, this );
if ( !dlg.exec() )
{
delete newSymbol;
return;
}
mRenderer->updateRangeSymbol(rangeIdx, newSymbol);
mRenderer->updateRangeSymbol( rangeIdx, newSymbol );
populateRanges();
}

View File

@ -9,76 +9,76 @@
#include <QPainter>
#include <QPen>
QgsPenStyleComboBox::QgsPenStyleComboBox(QWidget* parent)
: QComboBox(parent)
QgsPenStyleComboBox::QgsPenStyleComboBox( QWidget* parent )
: QComboBox( parent )
{
QList < QPair<Qt::PenStyle, QString> > styles;
styles << qMakePair(Qt::SolidLine, QString("Solid Line"))
<< qMakePair(Qt::DashLine, QString("Dash Line"))
<< qMakePair(Qt::DotLine, QString("Dot Line"))
<< qMakePair(Qt::DashDotLine, QString("Dash Dot Line"))
<< qMakePair(Qt::DashDotDotLine, QString("Dash Dot Dot Line"))
<< qMakePair(Qt::NoPen, QString("No Pen"));
setIconSize(QSize(32,12));
for (int i = 0; i < styles.count(); i++)
styles << qMakePair( Qt::SolidLine, QString( "Solid Line" ) )
<< qMakePair( Qt::DashLine, QString( "Dash Line" ) )
<< qMakePair( Qt::DotLine, QString( "Dot Line" ) )
<< qMakePair( Qt::DashDotLine, QString( "Dash Dot Line" ) )
<< qMakePair( Qt::DashDotDotLine, QString( "Dash Dot Dot Line" ) )
<< qMakePair( Qt::NoPen, QString( "No Pen" ) );
setIconSize( QSize( 32, 12 ) );
for ( int i = 0; i < styles.count(); i++ )
{
Qt::PenStyle style = styles.at(i).first;
QString name = styles.at(i).second;
addItem(iconForPen(style), name, QVariant(style));
Qt::PenStyle style = styles.at( i ).first;
QString name = styles.at( i ).second;
addItem( iconForPen( style ), name, QVariant( style ) );
}
}
Qt::PenStyle QgsPenStyleComboBox::penStyle() const
{
return (Qt::PenStyle) itemData(currentIndex()).toInt();
return ( Qt::PenStyle ) itemData( currentIndex() ).toInt();
}
void QgsPenStyleComboBox::setPenStyle(Qt::PenStyle style)
void QgsPenStyleComboBox::setPenStyle( Qt::PenStyle style )
{
int idx = findData(QVariant(style));
int idx = findData( QVariant( style ) );
setCurrentIndex( idx == -1 ? 0 : idx );
}
QIcon QgsPenStyleComboBox::iconForPen(Qt::PenStyle style)
QIcon QgsPenStyleComboBox::iconForPen( Qt::PenStyle style )
{
QPixmap pix(iconSize());
QPixmap pix( iconSize() );
QPainter p;
pix.fill(Qt::transparent);
p.begin(&pix);
QPen pen(style);
pen.setWidth(2);
p.setPen(pen);
pix.fill( Qt::transparent );
p.begin( &pix );
QPen pen( style );
pen.setWidth( 2 );
p.setPen( pen );
double mid = iconSize().height() / 2.0;
p.drawLine(0,mid,iconSize().width(),mid);
p.drawLine( 0, mid, iconSize().width(), mid );
p.end();
return QIcon(pix);
return QIcon( pix );
}
/////////
// join
QgsPenJoinStyleComboBox::QgsPenJoinStyleComboBox(QWidget* parent)
: QComboBox(parent)
QgsPenJoinStyleComboBox::QgsPenJoinStyleComboBox( QWidget* parent )
: QComboBox( parent )
{
QString path = QgsApplication::defaultThemePath();
addItem(QIcon(path + "/join_bevel.png"), tr("Bevel"), QVariant(Qt::BevelJoin));
addItem(QIcon(path + "/join_miter.png"), tr("Miter"), QVariant(Qt::MiterJoin));
addItem(QIcon(path + "/join_round.png"), tr("Round"), QVariant(Qt::RoundJoin));
addItem( QIcon( path + "/join_bevel.png" ), tr( "Bevel" ), QVariant( Qt::BevelJoin ) );
addItem( QIcon( path + "/join_miter.png" ), tr( "Miter" ), QVariant( Qt::MiterJoin ) );
addItem( QIcon( path + "/join_round.png" ), tr( "Round" ), QVariant( Qt::RoundJoin ) );
}
Qt::PenJoinStyle QgsPenJoinStyleComboBox::penJoinStyle() const
{
return (Qt::PenJoinStyle) itemData(currentIndex()).toInt();
return ( Qt::PenJoinStyle ) itemData( currentIndex() ).toInt();
}
void QgsPenJoinStyleComboBox::setPenJoinStyle(Qt::PenJoinStyle style)
void QgsPenJoinStyleComboBox::setPenJoinStyle( Qt::PenJoinStyle style )
{
int idx = findData(QVariant(style));
int idx = findData( QVariant( style ) );
setCurrentIndex( idx == -1 ? 0 : idx );
}
@ -86,22 +86,22 @@ void QgsPenJoinStyleComboBox::setPenJoinStyle(Qt::PenJoinStyle style)
/////////
// cap
QgsPenCapStyleComboBox::QgsPenCapStyleComboBox(QWidget* parent)
: QComboBox(parent)
QgsPenCapStyleComboBox::QgsPenCapStyleComboBox( QWidget* parent )
: QComboBox( parent )
{
QString path = QgsApplication::defaultThemePath();
addItem(QIcon(path + "/cap_square.png"), tr("Square"), QVariant(Qt::SquareCap));
addItem(QIcon(path + "/cap_flat.png"), tr("Flat"), QVariant(Qt::FlatCap));
addItem(QIcon(path + "/cap_round.png"), tr("Round"), QVariant(Qt::RoundCap));
addItem( QIcon( path + "/cap_square.png" ), tr( "Square" ), QVariant( Qt::SquareCap ) );
addItem( QIcon( path + "/cap_flat.png" ), tr( "Flat" ), QVariant( Qt::FlatCap ) );
addItem( QIcon( path + "/cap_round.png" ), tr( "Round" ), QVariant( Qt::RoundCap ) );
}
Qt::PenCapStyle QgsPenCapStyleComboBox::penCapStyle() const
{
return (Qt::PenCapStyle) itemData(currentIndex()).toInt();
return ( Qt::PenCapStyle ) itemData( currentIndex() ).toInt();
}
void QgsPenCapStyleComboBox::setPenCapStyle(Qt::PenCapStyle style)
void QgsPenCapStyleComboBox::setPenCapStyle( Qt::PenCapStyle style )
{
int idx = findData(QVariant(style));
int idx = findData( QVariant( style ) );
setCurrentIndex( idx == -1 ? 0 : idx );
}

View File

@ -18,37 +18,37 @@
QgsSimpleLineSymbolLayerV2Widget::QgsSimpleLineSymbolLayerV2Widget(QWidget* parent)
: QgsSymbolLayerV2Widget(parent)
QgsSimpleLineSymbolLayerV2Widget::QgsSimpleLineSymbolLayerV2Widget( QWidget* parent )
: QgsSymbolLayerV2Widget( parent )
{
mLayer = NULL;
setupUi(this);
connect(spinWidth, SIGNAL(valueChanged(double)), this, SLOT(penWidthChanged()));
connect(btnChangeColor, SIGNAL(clicked()), this, SLOT(colorChanged()));
connect(cboPenStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(penStyleChanged()));
connect(spinOffset, SIGNAL(valueChanged(double)), this, SLOT(offsetChanged()));
connect(cboCapStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(penStyleChanged()));
connect(cboJoinStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(penStyleChanged()));
setupUi( this );
connect( spinWidth, SIGNAL( valueChanged( double ) ), this, SLOT( penWidthChanged() ) );
connect( btnChangeColor, SIGNAL( clicked() ), this, SLOT( colorChanged() ) );
connect( cboPenStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penStyleChanged() ) );
connect( spinOffset, SIGNAL( valueChanged( double ) ), this, SLOT( offsetChanged() ) );
connect( cboCapStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penStyleChanged() ) );
connect( cboJoinStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( penStyleChanged() ) );
}
void QgsSimpleLineSymbolLayerV2Widget::setSymbolLayer(QgsSymbolLayerV2* layer)
void QgsSimpleLineSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer )
{
if (layer->layerType() != "SimpleLine")
if ( layer->layerType() != "SimpleLine" )
return;
// layer type is correct, we can do the cast
mLayer = static_cast<QgsSimpleLineSymbolLayerV2*>(layer);
mLayer = static_cast<QgsSimpleLineSymbolLayerV2*>( layer );
// set values
spinWidth->setValue(mLayer->width());
btnChangeColor->setColor(mLayer->color());
cboPenStyle->setPenStyle(mLayer->penStyle());
spinOffset->setValue(mLayer->offset());
cboJoinStyle->setPenJoinStyle(mLayer->penJoinStyle());
cboCapStyle->setPenCapStyle(mLayer->penCapStyle());
spinWidth->setValue( mLayer->width() );
btnChangeColor->setColor( mLayer->color() );
cboPenStyle->setPenStyle( mLayer->penStyle() );
spinOffset->setValue( mLayer->offset() );
cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
cboCapStyle->setPenCapStyle( mLayer->penCapStyle() );
}
QgsSymbolLayerV2* QgsSimpleLineSymbolLayerV2Widget::symbolLayer()
@ -58,31 +58,31 @@ QgsSymbolLayerV2* QgsSimpleLineSymbolLayerV2Widget::symbolLayer()
void QgsSimpleLineSymbolLayerV2Widget::penWidthChanged()
{
mLayer->setWidth(spinWidth->value());
mLayer->setWidth( spinWidth->value() );
emit changed();
}
void QgsSimpleLineSymbolLayerV2Widget::colorChanged()
{
QColor color = QColorDialog::getColor(mLayer->color(), this);
if (!color.isValid())
QColor color = QColorDialog::getColor( mLayer->color(), this );
if ( !color.isValid() )
return;
mLayer->setColor(color);
btnChangeColor->setColor(mLayer->color());
mLayer->setColor( color );
btnChangeColor->setColor( mLayer->color() );
emit changed();
}
void QgsSimpleLineSymbolLayerV2Widget::penStyleChanged()
{
mLayer->setPenStyle(cboPenStyle->penStyle());
mLayer->setPenJoinStyle(cboJoinStyle->penJoinStyle());
mLayer->setPenCapStyle(cboCapStyle->penCapStyle());
mLayer->setPenStyle( cboPenStyle->penStyle() );
mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
emit changed();
}
void QgsSimpleLineSymbolLayerV2Widget::offsetChanged()
{
mLayer->setOffset(spinOffset->value());
mLayer->setOffset( spinOffset->value() );
emit changed();
}
@ -90,66 +90,66 @@ void QgsSimpleLineSymbolLayerV2Widget::offsetChanged()
///////////
QgsSimpleMarkerSymbolLayerV2Widget::QgsSimpleMarkerSymbolLayerV2Widget(QWidget* parent)
: QgsSymbolLayerV2Widget(parent)
QgsSimpleMarkerSymbolLayerV2Widget::QgsSimpleMarkerSymbolLayerV2Widget( QWidget* parent )
: QgsSymbolLayerV2Widget( parent )
{
mLayer = NULL;
setupUi(this);
setupUi( this );
QSize size = lstNames->iconSize();
QStringList names;
names << "circle" << "rectangle" << "diamond" << "pentagon" << "cross" << "cross2" << "triangle"
<< "equilateral_triangle" << "star" << "regular_star" << "arrow";
double markerSize = size.width()-1; // keep some space around
for (int i = 0; i < names.count(); ++i)
<< "equilateral_triangle" << "star" << "regular_star" << "arrow";
double markerSize = size.width() - 1; // keep some space around
for ( int i = 0; i < names.count(); ++i )
{
QgsSimpleMarkerSymbolLayerV2* lyr = new QgsSimpleMarkerSymbolLayerV2(names[i], QColor(200,200,200), QColor(0,0,0), markerSize);
QIcon icon = QgsSymbolLayerV2Utils::symbolLayerPreviewIcon(lyr, size);
QListWidgetItem* item = new QListWidgetItem(icon, QString(), lstNames);
item->setData(Qt::UserRole, names[i]);
QgsSimpleMarkerSymbolLayerV2* lyr = new QgsSimpleMarkerSymbolLayerV2( names[i], QColor( 200, 200, 200 ), QColor( 0, 0, 0 ), markerSize );
QIcon icon = QgsSymbolLayerV2Utils::symbolLayerPreviewIcon( lyr, size );
QListWidgetItem* item = new QListWidgetItem( icon, QString(), lstNames );
item->setData( Qt::UserRole, names[i] );
delete lyr;
}
connect(lstNames, SIGNAL(currentRowChanged(int)), this, SLOT(setName()));
connect(btnChangeColorBorder, SIGNAL(clicked()), this, SLOT(setColorBorder()));
connect(btnChangeColorFill, SIGNAL(clicked()), this, SLOT(setColorFill()));
connect(spinSize, SIGNAL(valueChanged(double)), this, SLOT(setSize()));
connect(spinAngle, SIGNAL(valueChanged(double)), this, SLOT(setAngle()));
connect(spinOffsetX, SIGNAL(valueChanged(double)), this, SLOT(setOffset()));
connect(spinOffsetY, SIGNAL(valueChanged(double)), this, SLOT(setOffset()));
connect( lstNames, SIGNAL( currentRowChanged( int ) ), this, SLOT( setName() ) );
connect( btnChangeColorBorder, SIGNAL( clicked() ), this, SLOT( setColorBorder() ) );
connect( btnChangeColorFill, SIGNAL( clicked() ), this, SLOT( setColorFill() ) );
connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize() ) );
connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle() ) );
connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
}
void QgsSimpleMarkerSymbolLayerV2Widget::setSymbolLayer(QgsSymbolLayerV2* layer)
void QgsSimpleMarkerSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer )
{
if (layer->layerType() != "SimpleMarker")
if ( layer->layerType() != "SimpleMarker" )
return;
// layer type is correct, we can do the cast
mLayer = static_cast<QgsSimpleMarkerSymbolLayerV2*>(layer);
mLayer = static_cast<QgsSimpleMarkerSymbolLayerV2*>( layer );
// set values
QString name = mLayer->name();
for (int i = 0; i < lstNames->count(); ++i)
for ( int i = 0; i < lstNames->count(); ++i )
{
if (lstNames->item(i)->data(Qt::UserRole).toString() == name)
if ( lstNames->item( i )->data( Qt::UserRole ).toString() == name )
{
lstNames->setCurrentRow(i);
lstNames->setCurrentRow( i );
break;
}
}
btnChangeColorBorder->setColor(mLayer->borderColor());
btnChangeColorFill->setColor(mLayer->color());
spinSize->setValue(mLayer->size());
spinAngle->setValue(mLayer->angle());
btnChangeColorBorder->setColor( mLayer->borderColor() );
btnChangeColorFill->setColor( mLayer->color() );
spinSize->setValue( mLayer->size() );
spinAngle->setValue( mLayer->angle() );
// without blocking signals the value gets changed because of slot setOffset()
spinOffsetX->blockSignals(true);
spinOffsetX->setValue(mLayer->offset().x());
spinOffsetX->blockSignals(false);
spinOffsetY->blockSignals(true);
spinOffsetY->setValue(mLayer->offset().y());
spinOffsetY->blockSignals(false);
spinOffsetX->blockSignals( true );
spinOffsetX->setValue( mLayer->offset().x() );
spinOffsetX->blockSignals( false );
spinOffsetY->blockSignals( true );
spinOffsetY->setValue( mLayer->offset().y() );
spinOffsetY->blockSignals( false );
}
QgsSymbolLayerV2* QgsSimpleMarkerSymbolLayerV2Widget::symbolLayer()
@ -159,39 +159,39 @@ QgsSymbolLayerV2* QgsSimpleMarkerSymbolLayerV2Widget::symbolLayer()
void QgsSimpleMarkerSymbolLayerV2Widget::setName()
{
mLayer->setName(lstNames->currentItem()->data(Qt::UserRole).toString());
mLayer->setName( lstNames->currentItem()->data( Qt::UserRole ).toString() );
emit changed();
}
void QgsSimpleMarkerSymbolLayerV2Widget::setColorBorder()
{
QColor borderColor = QColorDialog::getColor(mLayer->borderColor(), this);
if (!borderColor.isValid())
QColor borderColor = QColorDialog::getColor( mLayer->borderColor(), this );
if ( !borderColor.isValid() )
return;
mLayer->setBorderColor(borderColor);
btnChangeColorBorder->setColor(mLayer->borderColor());
mLayer->setBorderColor( borderColor );
btnChangeColorBorder->setColor( mLayer->borderColor() );
emit changed();
}
void QgsSimpleMarkerSymbolLayerV2Widget::setColorFill()
{
QColor color = QColorDialog::getColor(mLayer->color(), this);
if (!color.isValid())
QColor color = QColorDialog::getColor( mLayer->color(), this );
if ( !color.isValid() )
return;
mLayer->setColor(color);
btnChangeColorFill->setColor(mLayer->color());
mLayer->setColor( color );
btnChangeColorFill->setColor( mLayer->color() );
emit changed();
}
void QgsSimpleMarkerSymbolLayerV2Widget::setSize()
{
mLayer->setSize(spinSize->value());
mLayer->setSize( spinSize->value() );
emit changed();
}
void QgsSimpleMarkerSymbolLayerV2Widget::setAngle()
{
mLayer->setAngle(spinAngle->value());
mLayer->setAngle( spinAngle->value() );
emit changed();
}
@ -204,34 +204,34 @@ void QgsSimpleMarkerSymbolLayerV2Widget::setOffset()
///////////
QgsSimpleFillSymbolLayerV2Widget::QgsSimpleFillSymbolLayerV2Widget(QWidget* parent)
: QgsSymbolLayerV2Widget(parent)
QgsSimpleFillSymbolLayerV2Widget::QgsSimpleFillSymbolLayerV2Widget( QWidget* parent )
: QgsSymbolLayerV2Widget( parent )
{
mLayer = NULL;
setupUi(this);
connect(btnChangeColor, SIGNAL(clicked()), this, SLOT(setColor()));
connect(cboFillStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(setBrushStyle()));
connect(btnChangeBorderColor, SIGNAL(clicked()), this, SLOT(setBorderColor()));
connect(spinBorderWidth, SIGNAL(valueChanged(double)), this, SLOT(borderWidthChanged()));
connect(cboBorderStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(borderStyleChanged()));
setupUi( this );
connect( btnChangeColor, SIGNAL( clicked() ), this, SLOT( setColor() ) );
connect( cboFillStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setBrushStyle() ) );
connect( btnChangeBorderColor, SIGNAL( clicked() ), this, SLOT( setBorderColor() ) );
connect( spinBorderWidth, SIGNAL( valueChanged( double ) ), this, SLOT( borderWidthChanged() ) );
connect( cboBorderStyle, SIGNAL( currentIndexChanged( int ) ), this, SLOT( borderStyleChanged() ) );
}
void QgsSimpleFillSymbolLayerV2Widget::setSymbolLayer(QgsSymbolLayerV2* layer)
void QgsSimpleFillSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer )
{
if (layer->layerType() != "SimpleFill")
if ( layer->layerType() != "SimpleFill" )
return;
// layer type is correct, we can do the cast
mLayer = static_cast<QgsSimpleFillSymbolLayerV2*>(layer);
mLayer = static_cast<QgsSimpleFillSymbolLayerV2*>( layer );
// set values
btnChangeColor->setColor(mLayer->color());
cboFillStyle->setBrushStyle(mLayer->brushStyle());
btnChangeBorderColor->setColor(mLayer->borderColor());
cboBorderStyle->setPenStyle(mLayer->borderStyle());
spinBorderWidth->setValue(mLayer->borderWidth());
btnChangeColor->setColor( mLayer->color() );
cboFillStyle->setBrushStyle( mLayer->brushStyle() );
btnChangeBorderColor->setColor( mLayer->borderColor() );
cboBorderStyle->setPenStyle( mLayer->borderStyle() );
spinBorderWidth->setValue( mLayer->borderWidth() );
}
QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2Widget::symbolLayer()
@ -241,69 +241,69 @@ QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2Widget::symbolLayer()
void QgsSimpleFillSymbolLayerV2Widget::setColor()
{
QColor color = QColorDialog::getColor(mLayer->color(), this);
if (!color.isValid())
QColor color = QColorDialog::getColor( mLayer->color(), this );
if ( !color.isValid() )
return;
mLayer->setColor(color);
btnChangeColor->setColor(mLayer->color());
mLayer->setColor( color );
btnChangeColor->setColor( mLayer->color() );
emit changed();
}
void QgsSimpleFillSymbolLayerV2Widget::setBorderColor()
{
QColor color = QColorDialog::getColor(mLayer->borderColor(), this);
if (!color.isValid())
QColor color = QColorDialog::getColor( mLayer->borderColor(), this );
if ( !color.isValid() )
return;
mLayer->setBorderColor(color);
btnChangeBorderColor->setColor(mLayer->borderColor());
mLayer->setBorderColor( color );
btnChangeBorderColor->setColor( mLayer->borderColor() );
emit changed();
}
void QgsSimpleFillSymbolLayerV2Widget::setBrushStyle()
{
mLayer->setBrushStyle(cboFillStyle->brushStyle());
mLayer->setBrushStyle( cboFillStyle->brushStyle() );
emit changed();
}
void QgsSimpleFillSymbolLayerV2Widget::borderWidthChanged()
{
mLayer->setBorderWidth(spinBorderWidth->value());
mLayer->setBorderWidth( spinBorderWidth->value() );
emit changed();
}
void QgsSimpleFillSymbolLayerV2Widget::borderStyleChanged()
{
mLayer->setBorderStyle(cboBorderStyle->penStyle());
mLayer->setBorderStyle( cboBorderStyle->penStyle() );
emit changed();
}
///////////
QgsMarkerLineSymbolLayerV2Widget::QgsMarkerLineSymbolLayerV2Widget(QWidget* parent)
: QgsSymbolLayerV2Widget(parent)
QgsMarkerLineSymbolLayerV2Widget::QgsMarkerLineSymbolLayerV2Widget( QWidget* parent )
: QgsSymbolLayerV2Widget( parent )
{
mLayer = NULL;
setupUi(this);
connect(spinInterval, SIGNAL(valueChanged(double)), this, SLOT(setInterval(double)));
connect(btnChangeMarker, SIGNAL(clicked()), this, SLOT(setMarker()));
connect(chkRotateMarker, SIGNAL(clicked()), this, SLOT(setRotate()));
connect(spinOffset, SIGNAL(valueChanged(double)), this, SLOT(setOffset()));
setupUi( this );
connect( spinInterval, SIGNAL( valueChanged( double ) ), this, SLOT( setInterval( double ) ) );
connect( btnChangeMarker, SIGNAL( clicked() ), this, SLOT( setMarker() ) );
connect( chkRotateMarker, SIGNAL( clicked() ), this, SLOT( setRotate() ) );
connect( spinOffset, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
}
void QgsMarkerLineSymbolLayerV2Widget::setSymbolLayer(QgsSymbolLayerV2* layer)
void QgsMarkerLineSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer )
{
if (layer->layerType() != "MarkerLine")
if ( layer->layerType() != "MarkerLine" )
return;
// layer type is correct, we can do the cast
mLayer = static_cast<QgsMarkerLineSymbolLayerV2*>(layer);
mLayer = static_cast<QgsMarkerLineSymbolLayerV2*>( layer );
// set values
spinInterval->setValue( (int) mLayer->interval());
chkRotateMarker->setChecked(mLayer->rotateMarker());
spinOffset->setValue(mLayer->offset());
spinInterval->setValue(( int ) mLayer->interval() );
chkRotateMarker->setChecked( mLayer->rotateMarker() );
spinOffset->setValue( mLayer->offset() );
updateMarker();
}
@ -312,16 +312,16 @@ QgsSymbolLayerV2* QgsMarkerLineSymbolLayerV2Widget::symbolLayer()
return mLayer;
}
void QgsMarkerLineSymbolLayerV2Widget::setInterval(double val)
void QgsMarkerLineSymbolLayerV2Widget::setInterval( double val )
{
mLayer->setInterval(val);
mLayer->setInterval( val );
emit changed();
}
void QgsMarkerLineSymbolLayerV2Widget::setMarker()
{
QgsSymbolV2PropertiesDialog dlg(mLayer->subSymbol(), this);
if (dlg.exec() == 0)
QgsSymbolV2PropertiesDialog dlg( mLayer->subSymbol(), this );
if ( dlg.exec() == 0 )
return;
updateMarker();
@ -330,52 +330,52 @@ void QgsMarkerLineSymbolLayerV2Widget::setMarker()
void QgsMarkerLineSymbolLayerV2Widget::setRotate()
{
mLayer->setRotateMarker(chkRotateMarker->isChecked());
mLayer->setRotateMarker( chkRotateMarker->isChecked() );
emit changed();
}
void QgsMarkerLineSymbolLayerV2Widget::setOffset()
{
mLayer->setOffset(spinOffset->value());
mLayer->setOffset( spinOffset->value() );
emit changed();
}
void QgsMarkerLineSymbolLayerV2Widget::updateMarker()
{
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon(mLayer->subSymbol(), btnChangeMarker->iconSize());
btnChangeMarker->setIcon(icon);
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( mLayer->subSymbol(), btnChangeMarker->iconSize() );
btnChangeMarker->setIcon( icon );
}
///////////
QgsSvgMarkerSymbolLayerV2Widget::QgsSvgMarkerSymbolLayerV2Widget(QWidget* parent)
: QgsSymbolLayerV2Widget(parent)
QgsSvgMarkerSymbolLayerV2Widget::QgsSvgMarkerSymbolLayerV2Widget( QWidget* parent )
: QgsSymbolLayerV2Widget( parent )
{
mLayer = NULL;
setupUi(this);
setupUi( this );
populateList();
connect(viewImages->selectionModel(), SIGNAL(currentChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(setName(const QModelIndex&)));
connect(spinSize, SIGNAL(valueChanged(double)), this, SLOT(setSize()));
connect(spinAngle, SIGNAL(valueChanged(double)), this, SLOT(setAngle()));
connect(spinOffsetX, SIGNAL(valueChanged(double)), this, SLOT(setOffset()));
connect(spinOffsetY, SIGNAL(valueChanged(double)), this, SLOT(setOffset()));
connect( viewImages->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( setName( const QModelIndex& ) ) );
connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setSize() ) );
connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setAngle() ) );
connect( spinOffsetX, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
connect( spinOffsetY, SIGNAL( valueChanged( double ) ), this, SLOT( setOffset() ) );
}
void QgsSvgMarkerSymbolLayerV2Widget::populateList()
{
QStandardItemModel* m = new QStandardItemModel(viewImages);
viewImages->setModel(m);
QStandardItemModel* m = new QStandardItemModel( viewImages );
viewImages->setModel( m );
QString svgPath = QgsApplication::svgPath();
QSvgRenderer renderer;
QPainter painter;
QDir dir( svgPath );
QStringList dl = dir.entryList( QDir::Dirs );
@ -392,51 +392,51 @@ void QgsSvgMarkerSymbolLayerV2Widget::populateList()
{
// TODO test if it is correct SVG
QString entry = *it2;
// render SVG file
renderer.load( dir2.filePath( *it2 ) );
QPixmap pixmap(renderer.defaultSize());
QPixmap pixmap( renderer.defaultSize() );
pixmap.fill();
painter.begin(&pixmap);
renderer.render(&painter);
painter.begin( &pixmap );
renderer.render( &painter );
painter.end();
// add item
QStandardItem* item = new QStandardItem(QIcon(pixmap), *it + "/" + entry);
m->appendRow(item);
QStandardItem* item = new QStandardItem( QIcon( pixmap ), *it + "/" + entry );
m->appendRow( item );
}
}
}
void QgsSvgMarkerSymbolLayerV2Widget::setSymbolLayer(QgsSymbolLayerV2* layer)
void QgsSvgMarkerSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer )
{
if (layer->layerType() != "SvgMarker")
if ( layer->layerType() != "SvgMarker" )
return;
// layer type is correct, we can do the cast
mLayer = static_cast<QgsSvgMarkerSymbolLayerV2*>(layer);
mLayer = static_cast<QgsSvgMarkerSymbolLayerV2*>( layer );
// set values
QStandardItemModel* m = static_cast<QStandardItemModel*>(viewImages->model());
QList<QStandardItem*> items = m->findItems(mLayer->name());
if (items.count() > 0)
QStandardItemModel* m = static_cast<QStandardItemModel*>( viewImages->model() );
QList<QStandardItem*> items = m->findItems( mLayer->name() );
if ( items.count() > 0 )
{
QModelIndex idx = items[0]->index();
viewImages->selectionModel()->select(idx, QItemSelectionModel::SelectCurrent);
viewImages->selectionModel()->select( idx, QItemSelectionModel::SelectCurrent );
}
spinSize->setValue(mLayer->size());
spinAngle->setValue(mLayer->angle());
spinSize->setValue( mLayer->size() );
spinAngle->setValue( mLayer->angle() );
// without blocking signals the value gets changed because of slot setOffset()
spinOffsetX->blockSignals(true);
spinOffsetX->setValue(mLayer->offset().x());
spinOffsetX->blockSignals(false);
spinOffsetY->blockSignals(true);
spinOffsetY->setValue(mLayer->offset().y());
spinOffsetY->blockSignals(false);
spinOffsetX->blockSignals( true );
spinOffsetX->setValue( mLayer->offset().x() );
spinOffsetX->blockSignals( false );
spinOffsetY->blockSignals( true );
spinOffsetY->setValue( mLayer->offset().y() );
spinOffsetY->blockSignals( false );
}
QgsSymbolLayerV2* QgsSvgMarkerSymbolLayerV2Widget::symbolLayer()
@ -444,9 +444,9 @@ QgsSymbolLayerV2* QgsSvgMarkerSymbolLayerV2Widget::symbolLayer()
return mLayer;
}
void QgsSvgMarkerSymbolLayerV2Widget::setName(const QModelIndex& idx)
void QgsSvgMarkerSymbolLayerV2Widget::setName( const QModelIndex& idx )
{
mLayer->setName(idx.data().toString());
mLayer->setName( idx.data().toString() );
//mLayer->setName(lstNames->currentItem()->data(Qt::UserRole).toString());
emit changed();
@ -454,13 +454,13 @@ void QgsSvgMarkerSymbolLayerV2Widget::setName(const QModelIndex& idx)
void QgsSvgMarkerSymbolLayerV2Widget::setSize()
{
mLayer->setSize(spinSize->value());
mLayer->setSize( spinSize->value() );
emit changed();
}
void QgsSvgMarkerSymbolLayerV2Widget::setAngle()
{
mLayer->setAngle(spinAngle->value());
mLayer->setAngle( spinAngle->value() );
emit changed();
}
@ -472,26 +472,26 @@ void QgsSvgMarkerSymbolLayerV2Widget::setOffset()
///////////////
QgsLineDecorationSymbolLayerV2Widget::QgsLineDecorationSymbolLayerV2Widget(QWidget* parent)
: QgsSymbolLayerV2Widget(parent)
QgsLineDecorationSymbolLayerV2Widget::QgsLineDecorationSymbolLayerV2Widget( QWidget* parent )
: QgsSymbolLayerV2Widget( parent )
{
mLayer = NULL;
setupUi(this);
connect(btnChangeColor, SIGNAL(clicked()), this, SLOT(colorChanged()));
setupUi( this );
connect( btnChangeColor, SIGNAL( clicked() ), this, SLOT( colorChanged() ) );
}
void QgsLineDecorationSymbolLayerV2Widget::setSymbolLayer(QgsSymbolLayerV2* layer)
void QgsLineDecorationSymbolLayerV2Widget::setSymbolLayer( QgsSymbolLayerV2* layer )
{
if (layer->layerType() != "LineDecoration")
if ( layer->layerType() != "LineDecoration" )
return;
// layer type is correct, we can do the cast
mLayer = static_cast<QgsLineDecorationSymbolLayerV2*>(layer);
mLayer = static_cast<QgsLineDecorationSymbolLayerV2*>( layer );
// set values
btnChangeColor->setColor(mLayer->color());
btnChangeColor->setColor( mLayer->color() );
}
QgsSymbolLayerV2* QgsLineDecorationSymbolLayerV2Widget::symbolLayer()
@ -501,10 +501,10 @@ QgsSymbolLayerV2* QgsLineDecorationSymbolLayerV2Widget::symbolLayer()
void QgsLineDecorationSymbolLayerV2Widget::colorChanged()
{
QColor color = QColorDialog::getColor(mLayer->color(), this);
if (!color.isValid())
QColor color = QColorDialog::getColor( mLayer->color(), this );
if ( !color.isValid() )
return;
mLayer->setColor(color);
btnChangeColor->setColor(mLayer->color());
mLayer->setColor( color );
btnChangeColor->setColor( mLayer->color() );
emit changed();
}

View File

@ -15,96 +15,96 @@
#include <QInputDialog>
#include <QKeyEvent>
QgsSymbolV2SelectorDialog::QgsSymbolV2SelectorDialog(QgsSymbolV2* symbol, QgsStyleV2* style, QWidget* parent, bool embedded)
: QDialog(parent)
QgsSymbolV2SelectorDialog::QgsSymbolV2SelectorDialog( QgsSymbolV2* symbol, QgsStyleV2* style, QWidget* parent, bool embedded )
: QDialog( parent )
{
mStyle = style;
mSymbol = symbol;
setupUi(this);
setupUi( this );
// can be embedded in renderer properties dialog
if (embedded)
if ( embedded )
{
buttonBox->hide();
layout()->setContentsMargins(0,0,0,0);
layout()->setContentsMargins( 0, 0, 0, 0 );
}
connect(btnSymbolProperties, SIGNAL(clicked()), this, SLOT(changeSymbolProperties()));
connect( btnSymbolProperties, SIGNAL( clicked() ), this, SLOT( changeSymbolProperties() ) );
QStandardItemModel* model = new QStandardItemModel(viewSymbols);
viewSymbols->setModel(model);
connect(viewSymbols, SIGNAL(clicked(const QModelIndex &)), this, SLOT(setSymbolFromStyle(const QModelIndex &)));
QStandardItemModel* model = new QStandardItemModel( viewSymbols );
viewSymbols->setModel( model );
connect( viewSymbols, SIGNAL( clicked( const QModelIndex & ) ), this, SLOT( setSymbolFromStyle( const QModelIndex & ) ) );
populateSymbolView();
updateSymbolPreview();
updateSymbolInfo();
// select correct page in stacked widget
// there's a correspondence between symbol type number and page numbering => exploit it!
stackedWidget->setCurrentIndex(symbol->type());
connect(btnColorMarker, SIGNAL(clicked()), this, SLOT(setSymbolColor()));
connect(btnColorLine, SIGNAL(clicked()), this, SLOT(setSymbolColor()));
connect(btnColorFill, SIGNAL(clicked()), this, SLOT(setSymbolColor()));
connect(spinAngle, SIGNAL(valueChanged(double)), this, SLOT(setMarkerAngle(double)));
connect(spinSize, SIGNAL(valueChanged(double)), this, SLOT(setMarkerSize(double)));
connect(spinWidth, SIGNAL(valueChanged(double)), this, SLOT(setLineWidth(double)));
stackedWidget->setCurrentIndex( symbol->type() );
connect(btnAddToStyle, SIGNAL(clicked()), this, SLOT(addSymbolToStyle()));
connect( btnColorMarker, SIGNAL( clicked() ), this, SLOT( setSymbolColor() ) );
connect( btnColorLine, SIGNAL( clicked() ), this, SLOT( setSymbolColor() ) );
connect( btnColorFill, SIGNAL( clicked() ), this, SLOT( setSymbolColor() ) );
connect( spinAngle, SIGNAL( valueChanged( double ) ), this, SLOT( setMarkerAngle( double ) ) );
connect( spinSize, SIGNAL( valueChanged( double ) ), this, SLOT( setMarkerSize( double ) ) );
connect( spinWidth, SIGNAL( valueChanged( double ) ), this, SLOT( setLineWidth( double ) ) );
connect( btnAddToStyle, SIGNAL( clicked() ), this, SLOT( addSymbolToStyle() ) );
btnSymbolProperties->setIcon( QIcon( QgsApplication::defaultThemePath() + "mActionOptions.png" ) );
btnAddToStyle->setIcon( QIcon( QgsApplication::defaultThemePath() + "symbologyAdd.png" ) );
}
void QgsSymbolV2SelectorDialog::populateSymbolView()
{
{
QSize previewSize = viewSymbols->iconSize();
QPixmap p(previewSize);
QPixmap p( previewSize );
QPainter painter;
QStandardItemModel* model = qobject_cast<QStandardItemModel*>(viewSymbols->model());
if (!model)
QStandardItemModel* model = qobject_cast<QStandardItemModel*>( viewSymbols->model() );
if ( !model )
return;
model->clear();
QStringList names = mStyle->symbolNames();
for (int i = 0; i < names.count(); i++)
for ( int i = 0; i < names.count(); i++ )
{
QgsSymbolV2* s = mStyle->symbol(names[i]);
if (s->type() != mSymbol->type())
QgsSymbolV2* s = mStyle->symbol( names[i] );
if ( s->type() != mSymbol->type() )
{
delete s;
continue;
}
QStandardItem* item = new QStandardItem(names[i]);
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
QStandardItem* item = new QStandardItem( names[i] );
item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
// create preview icon
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon(s, previewSize);
item->setIcon(icon);
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( s, previewSize );
item->setIcon( icon );
// add to model
model->appendRow(item);
model->appendRow( item );
delete s;
}
}
void QgsSymbolV2SelectorDialog::setSymbolFromStyle(const QModelIndex & index)
void QgsSymbolV2SelectorDialog::setSymbolFromStyle( const QModelIndex & index )
{
QString symbolName = index.data().toString();
// get new instance of symbol from style
QgsSymbolV2* s = mStyle->symbol(symbolName);
QgsSymbolV2* s = mStyle->symbol( symbolName );
// remove all symbol layers from original symbol
while (mSymbol->symbolLayerCount())
mSymbol->deleteSymbolLayer(0);
while ( mSymbol->symbolLayerCount() )
mSymbol->deleteSymbolLayer( 0 );
// move all symbol layers to our symbol
while (s->symbolLayerCount())
while ( s->symbolLayerCount() )
{
QgsSymbolLayerV2* sl = s->takeSymbolLayer(0);
mSymbol->appendSymbolLayer(sl);
QgsSymbolLayerV2* sl = s->takeSymbolLayer( 0 );
mSymbol->appendSymbolLayer( sl );
}
// delete the temporary symbol
delete s;
updateSymbolPreview();
updateSymbolInfo();
emit symbolModified();
@ -113,40 +113,40 @@ void QgsSymbolV2SelectorDialog::setSymbolFromStyle(const QModelIndex & index)
void QgsSymbolV2SelectorDialog::updateSymbolPreview()
{
QImage preview = mSymbol->bigSymbolPreviewImage();
lblPreview->setPixmap(QPixmap::fromImage(preview));
lblPreview->setPixmap( QPixmap::fromImage( preview ) );
}
void QgsSymbolV2SelectorDialog::updateSymbolColor()
{
QColor c = mSymbol->color();
btnColorMarker->setColor(c);
btnColorLine->setColor(c);
btnColorFill->setColor(c);
btnColorMarker->setColor( c );
btnColorLine->setColor( c );
btnColorFill->setColor( c );
}
void QgsSymbolV2SelectorDialog::updateSymbolInfo()
{
updateSymbolColor();
if (mSymbol->type() == QgsSymbolV2::Marker)
if ( mSymbol->type() == QgsSymbolV2::Marker )
{
QgsMarkerSymbolV2* markerSymbol = static_cast<QgsMarkerSymbolV2*>(mSymbol);
spinSize->setValue(markerSymbol->size());
spinAngle->setValue(markerSymbol->angle());
QgsMarkerSymbolV2* markerSymbol = static_cast<QgsMarkerSymbolV2*>( mSymbol );
spinSize->setValue( markerSymbol->size() );
spinAngle->setValue( markerSymbol->angle() );
}
else if (mSymbol->type() == QgsSymbolV2::Line)
else if ( mSymbol->type() == QgsSymbolV2::Line )
{
QgsLineSymbolV2* lineSymbol = static_cast<QgsLineSymbolV2*>(mSymbol);
spinWidth->setValue(lineSymbol->width());
QgsLineSymbolV2* lineSymbol = static_cast<QgsLineSymbolV2*>( mSymbol );
spinWidth->setValue( lineSymbol->width() );
}
}
void QgsSymbolV2SelectorDialog::changeSymbolProperties()
{
QgsSymbolV2PropertiesDialog dlg(mSymbol, this);
if (!dlg.exec())
QgsSymbolV2PropertiesDialog dlg( mSymbol, this );
if ( !dlg.exec() )
return;
updateSymbolPreview();
updateSymbolInfo();
emit symbolModified();
@ -155,42 +155,42 @@ void QgsSymbolV2SelectorDialog::changeSymbolProperties()
void QgsSymbolV2SelectorDialog::setSymbolColor()
{
QColor color = QColorDialog::getColor(mSymbol->color(), this);
if (!color.isValid())
QColor color = QColorDialog::getColor( mSymbol->color(), this );
if ( !color.isValid() )
return;
mSymbol->setColor(color);
mSymbol->setColor( color );
updateSymbolColor();
updateSymbolPreview();
emit symbolModified();
}
void QgsSymbolV2SelectorDialog::setMarkerAngle(double angle)
void QgsSymbolV2SelectorDialog::setMarkerAngle( double angle )
{
QgsMarkerSymbolV2* markerSymbol = static_cast<QgsMarkerSymbolV2*>(mSymbol);
if (markerSymbol->angle() == angle)
QgsMarkerSymbolV2* markerSymbol = static_cast<QgsMarkerSymbolV2*>( mSymbol );
if ( markerSymbol->angle() == angle )
return;
markerSymbol->setAngle(angle);
markerSymbol->setAngle( angle );
updateSymbolPreview();
emit symbolModified();
}
void QgsSymbolV2SelectorDialog::setMarkerSize(double size)
void QgsSymbolV2SelectorDialog::setMarkerSize( double size )
{
QgsMarkerSymbolV2* markerSymbol = static_cast<QgsMarkerSymbolV2*>(mSymbol);
if (markerSymbol->size() == size)
QgsMarkerSymbolV2* markerSymbol = static_cast<QgsMarkerSymbolV2*>( mSymbol );
if ( markerSymbol->size() == size )
return;
markerSymbol->setSize(size);
markerSymbol->setSize( size );
updateSymbolPreview();
emit symbolModified();
}
void QgsSymbolV2SelectorDialog::setLineWidth(double width)
void QgsSymbolV2SelectorDialog::setLineWidth( double width )
{
QgsLineSymbolV2* lineSymbol = static_cast<QgsLineSymbolV2*>(mSymbol);
if (lineSymbol->width() == width)
QgsLineSymbolV2* lineSymbol = static_cast<QgsLineSymbolV2*>( mSymbol );
if ( lineSymbol->width() == width )
return;
lineSymbol->setWidth(width);
lineSymbol->setWidth( width );
updateSymbolPreview();
emit symbolModified();
}
@ -198,13 +198,13 @@ void QgsSymbolV2SelectorDialog::setLineWidth(double width)
void QgsSymbolV2SelectorDialog::addSymbolToStyle()
{
bool ok;
QString name = QInputDialog::getText(this, "Symbol name",
"Please enter name for the symbol:", QLineEdit::Normal, "New symbol", &ok);
if (!ok || name.isEmpty())
QString name = QInputDialog::getText( this, "Symbol name",
"Please enter name for the symbol:", QLineEdit::Normal, "New symbol", &ok );
if ( !ok || name.isEmpty() )
return;
// add new symbol to style and re-populate the list
mStyle->addSymbol(name, mSymbol->clone());
mStyle->addSymbol( name, mSymbol->clone() );
// make sure the symbol is stored
mStyle->save();
@ -221,6 +221,6 @@ void QgsSymbolV2SelectorDialog::keyPressEvent( QKeyEvent * e )
}
else
{
QDialog::keyPressEvent(e);
QDialog::keyPressEvent( e );
}
}

View File

@ -308,7 +308,7 @@ int PalLabeling::prepareLayer( QgsVectorLayer* layer, int& attrIndex )
case LayerSettings::Curved: arrangement = P_CURVED; break;
case LayerSettings::Horizontal: arrangement = P_HORIZ; break;
case LayerSettings::Free: arrangement = P_FREE; break;
default: Q_ASSERT( "unsupported placement" && 0 ); return 0; break;
default: Q_ASSERT( "unsupported placement" && 0 ); return 0; break;
}
// create the pal layer
@ -367,7 +367,7 @@ void PalLabeling::init()
SearchMethod s;
switch ( mSearch )
{
default:
default:
case Chain: s = CHAIN; break;
case Popmusic_Tabu: s = POPMUSIC_TABU; break;
case Popmusic_Chain: s = POPMUSIC_CHAIN; break;