Skip to content

Commit

Permalink
Pass pointer to vectorlayer to all simbol widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Jun 8, 2011
1 parent 936d58b commit 066a0ea
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 60 deletions.
2 changes: 1 addition & 1 deletion src/app/qgsannotationwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void QgsAnnotationWidget::on_mMapMarkerButton_clicked()
return;
}
QgsMarkerSymbolV2* markerSymbol = dynamic_cast<QgsMarkerSymbolV2*>( mMarkerSymbol->clone() );
QgsSymbolV2SelectorDialog dlg( markerSymbol, QgsStyleV2::defaultStyle(), this );
QgsSymbolV2SelectorDialog dlg( markerSymbol, QgsStyleV2::defaultStyle(), 0, this );
if ( dlg.exec() == QDialog::Rejected )
{
delete markerSymbol;
Expand Down
8 changes: 5 additions & 3 deletions src/core/symbology-ng/qgssymbollayerv2registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "qgssymbolv2.h"
#include "qgssymbollayerv2.h"

class QgsVectorLayer;

/**
Stores metadata about one symbol layer class.
Expand All @@ -24,7 +26,7 @@ class CORE_EXPORT QgsSymbolLayerV2AbstractMetadata
/** create a symbol layer of this type given the map of properties. */
virtual QgsSymbolLayerV2* createSymbolLayer( const QgsStringMap& map ) = 0;
/** create widget for symbol layer of this type. Can return NULL if there's no GUI */
virtual QgsSymbolLayerV2Widget* createSymbolLayerWidget() { return NULL; }
virtual QgsSymbolLayerV2Widget* createSymbolLayerWidget( const QgsVectorLayer* vl ) { return NULL; }

protected:
QString mName;
Expand All @@ -33,7 +35,7 @@ class CORE_EXPORT QgsSymbolLayerV2AbstractMetadata
};

typedef QgsSymbolLayerV2*( *QgsSymbolLayerV2CreateFunc )( const QgsStringMap& );
typedef QgsSymbolLayerV2Widget*( *QgsSymbolLayerV2WidgetFunc )();
typedef QgsSymbolLayerV2Widget*( *QgsSymbolLayerV2WidgetFunc )( const QgsVectorLayer* );

/**
Convenience metadata class that uses static functions to create symbol layer and its widget.
Expand All @@ -53,7 +55,7 @@ class CORE_EXPORT QgsSymbolLayerV2Metadata : public QgsSymbolLayerV2AbstractMeta
void setWidgetFunction( QgsSymbolLayerV2WidgetFunc f ) { mWidgetFunc = f; }

virtual QgsSymbolLayerV2* createSymbolLayer( const QgsStringMap& map ) { return mCreateFunc ? mCreateFunc( map ) : NULL; }
virtual QgsSymbolLayerV2Widget* createSymbolLayerWidget() { return mWidgetFunc ? mWidgetFunc() : NULL; }
virtual QgsSymbolLayerV2Widget* createSymbolLayerWidget( const QgsVectorLayer* vl ) { return mWidgetFunc ? mWidgetFunc( vl ) : NULL; }

protected:
QgsSymbolLayerV2CreateFunc mCreateFunc;
Expand Down
4 changes: 2 additions & 2 deletions src/gui/symbology-ng/qgscategorizedsymbolrendererv2widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ QgsFeatureRendererV2* QgsCategorizedSymbolRendererV2Widget::renderer()

void QgsCategorizedSymbolRendererV2Widget::changeCategorizedSymbol()
{
QgsSymbolV2SelectorDialog dlg( mCategorizedSymbol, mStyle, this );
QgsSymbolV2SelectorDialog dlg( mCategorizedSymbol, mStyle, mLayer, this );
if ( !dlg.exec() )
return;

Expand Down Expand Up @@ -207,7 +207,7 @@ void QgsCategorizedSymbolRendererV2Widget::changeCategorySymbol()
int catIdx = mRenderer->categoryIndexForValue( k );
QgsSymbolV2* newSymbol = mRenderer->categories()[catIdx].symbol()->clone();

QgsSymbolV2SelectorDialog dlg( newSymbol, mStyle, this );
QgsSymbolV2SelectorDialog dlg( newSymbol, mStyle, mLayer, this );
if ( !dlg.exec() )
{
delete newSymbol;
Expand Down
4 changes: 2 additions & 2 deletions src/gui/symbology-ng/qgsgraduatedsymbolrendererv2widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void QgsGraduatedSymbolRendererV2Widget::classifyGraduated()

void QgsGraduatedSymbolRendererV2Widget::changeGraduatedSymbol()
{
QgsSymbolV2SelectorDialog dlg( mGraduatedSymbol, mStyle, this );
QgsSymbolV2SelectorDialog dlg( mGraduatedSymbol, mStyle, mLayer, this );
if ( !dlg.exec() )
return;

Expand Down Expand Up @@ -268,7 +268,7 @@ void QgsGraduatedSymbolRendererV2Widget::changeRangeSymbol( int rangeIdx )
{
QgsSymbolV2* newSymbol = mRenderer->ranges()[rangeIdx].symbol()->clone();

QgsSymbolV2SelectorDialog dlg( newSymbol, mStyle, this );
QgsSymbolV2SelectorDialog dlg( newSymbol, mStyle, mLayer, this );
if ( !dlg.exec() )
{
delete newSymbol;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/symbology-ng/qgsrulebasedrendererv2widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ QgsRendererRulePropsDialog::QgsRendererRulePropsDialog( const QgsRuleBasedRender
spinMaxScale->setValue( rule.scaleMaxDenom() );
}

QgsSymbolV2SelectorDialog* symbolSel = new QgsSymbolV2SelectorDialog( mRule.symbol(), style, this, true );
QgsSymbolV2SelectorDialog* symbolSel = new QgsSymbolV2SelectorDialog( mRule.symbol(), style, mLayer, this, true );
QVBoxLayout* l = new QVBoxLayout;
l->addWidget( symbolSel );
groupSymbol->setLayout( l );
Expand Down
2 changes: 1 addition & 1 deletion src/gui/symbology-ng/qgssinglesymbolrendererv2widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ QgsSingleSymbolRendererV2Widget::QgsSingleSymbolRendererV2Widget( QgsVectorLayer
mSingleSymbol = mRenderer->symbol()->clone();

// setup ui
mSelector = new QgsSymbolV2SelectorDialog( mSingleSymbol, mStyle, NULL, true );
mSelector = new QgsSymbolV2SelectorDialog( mSingleSymbol, mStyle, mLayer, NULL, true );
connect( mSelector, SIGNAL( symbolModified() ), this, SLOT( changeSingleSymbol() ) );

QVBoxLayout* layout = new QVBoxLayout;
Expand Down
4 changes: 2 additions & 2 deletions src/gui/symbology-ng/qgsstylev2managerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ bool QgsStyleV2ManagerDialog::addSymbol()
}

// get symbol design
QgsSymbolV2PropertiesDialog dlg( symbol, this );
QgsSymbolV2PropertiesDialog dlg( symbol, 0, this );
if ( dlg.exec() == 0 )
{
delete symbol;
Expand Down Expand Up @@ -384,7 +384,7 @@ bool QgsStyleV2ManagerDialog::editSymbol()
QgsSymbolV2* symbol = mStyle->symbol( symbolName );

// let the user edit the symbol and update list when done
QgsSymbolV2PropertiesDialog dlg( symbol, this );
QgsSymbolV2PropertiesDialog dlg( symbol, 0, this );
if ( dlg.exec() == 0 )
{
delete symbol;
Expand Down
40 changes: 20 additions & 20 deletions src/gui/symbology-ng/qgssymbollayerv2widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@



QgsSimpleLineSymbolLayerV2Widget::QgsSimpleLineSymbolLayerV2Widget( QWidget* parent )
: QgsSymbolLayerV2Widget( parent )
QgsSimpleLineSymbolLayerV2Widget::QgsSimpleLineSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent )
: QgsSymbolLayerV2Widget( parent, vl )
{
mLayer = NULL;

Expand Down Expand Up @@ -158,8 +158,8 @@ void QgsSimpleLineSymbolLayerV2Widget::updatePatternIcon()
///////////


QgsSimpleMarkerSymbolLayerV2Widget::QgsSimpleMarkerSymbolLayerV2Widget( QWidget* parent )
: QgsSymbolLayerV2Widget( parent )
QgsSimpleMarkerSymbolLayerV2Widget::QgsSimpleMarkerSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent )
: QgsSymbolLayerV2Widget( parent, vl )
{
mLayer = NULL;

Expand Down Expand Up @@ -286,8 +286,8 @@ void QgsSimpleMarkerSymbolLayerV2Widget::setOffset()

///////////

QgsSimpleFillSymbolLayerV2Widget::QgsSimpleFillSymbolLayerV2Widget( QWidget* parent )
: QgsSymbolLayerV2Widget( parent )
QgsSimpleFillSymbolLayerV2Widget::QgsSimpleFillSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent )
: QgsSymbolLayerV2Widget( parent, vl )
{
mLayer = NULL;

Expand Down Expand Up @@ -389,8 +389,8 @@ void QgsSimpleFillSymbolLayerV2Widget::offsetChanged()

///////////

QgsMarkerLineSymbolLayerV2Widget::QgsMarkerLineSymbolLayerV2Widget( QWidget* parent )
: QgsSymbolLayerV2Widget( parent )
QgsMarkerLineSymbolLayerV2Widget::QgsMarkerLineSymbolLayerV2Widget(const QgsVectorLayer* vl, QWidget* parent )
: QgsSymbolLayerV2Widget( parent, vl )
{
mLayer = NULL;

Expand Down Expand Up @@ -446,7 +446,7 @@ void QgsMarkerLineSymbolLayerV2Widget::setInterval( double val )

void QgsMarkerLineSymbolLayerV2Widget::setMarker()
{
QgsSymbolV2PropertiesDialog dlg( mLayer->subSymbol(), this );
QgsSymbolV2PropertiesDialog dlg( mLayer->subSymbol(), mVectorLayer, this );
if ( dlg.exec() == 0 )
return;
updateMarker();
Expand Down Expand Up @@ -495,8 +495,8 @@ void QgsMarkerLineSymbolLayerV2Widget::setPlacement()
///////////


QgsSvgMarkerSymbolLayerV2Widget::QgsSvgMarkerSymbolLayerV2Widget( QWidget* parent )
: QgsSymbolLayerV2Widget( parent )
QgsSvgMarkerSymbolLayerV2Widget::QgsSvgMarkerSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent )
: QgsSymbolLayerV2Widget( parent, vl )
{
mLayer = NULL;

Expand Down Expand Up @@ -642,8 +642,8 @@ void QgsSvgMarkerSymbolLayerV2Widget::setOffset()

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

QgsLineDecorationSymbolLayerV2Widget::QgsLineDecorationSymbolLayerV2Widget( QWidget* parent )
: QgsSymbolLayerV2Widget( parent )
QgsLineDecorationSymbolLayerV2Widget::QgsLineDecorationSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent )
: QgsSymbolLayerV2Widget( parent, vl )
{
mLayer = NULL;

Expand Down Expand Up @@ -698,7 +698,7 @@ void QgsLineDecorationSymbolLayerV2Widget::penWidthChanged()

#include <QFileDialog>

QgsSVGFillSymbolLayerWidget::QgsSVGFillSymbolLayerWidget( QWidget* parent ): QgsSymbolLayerV2Widget( parent )
QgsSVGFillSymbolLayerWidget::QgsSVGFillSymbolLayerWidget( const QgsVectorLayer* vl, QWidget* parent ): QgsSymbolLayerV2Widget( parent, vl )
{
mLayer = 0;
setupUi( this );
Expand Down Expand Up @@ -784,7 +784,7 @@ void QgsSVGFillSymbolLayerWidget::insertIcons()

void QgsSVGFillSymbolLayerWidget::on_mChangeOutlinePushButton_clicked()
{
QgsSymbolV2PropertiesDialog dlg( mLayer->subSymbol(), this );
QgsSymbolV2PropertiesDialog dlg( mLayer->subSymbol(), mVectorLayer, this );
if ( dlg.exec() == QDialog::Rejected )
{
return;
Expand Down Expand Up @@ -814,8 +814,8 @@ void QgsSVGFillSymbolLayerWidget::updateOutlineIcon()

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

QgsFontMarkerSymbolLayerV2Widget::QgsFontMarkerSymbolLayerV2Widget( QWidget* parent )
: QgsSymbolLayerV2Widget( parent )
QgsFontMarkerSymbolLayerV2Widget::QgsFontMarkerSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent )
: QgsSymbolLayerV2Widget( parent, vl )
{
mLayer = NULL;

Expand Down Expand Up @@ -915,8 +915,8 @@ void QgsFontMarkerSymbolLayerV2Widget::setOffset()
///////////////


QgsCentroidFillSymbolLayerV2Widget::QgsCentroidFillSymbolLayerV2Widget( QWidget* parent )
: QgsSymbolLayerV2Widget( parent )
QgsCentroidFillSymbolLayerV2Widget::QgsCentroidFillSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent )
: QgsSymbolLayerV2Widget( parent, vl )
{
mLayer = NULL;

Expand Down Expand Up @@ -944,7 +944,7 @@ QgsSymbolLayerV2* QgsCentroidFillSymbolLayerV2Widget::symbolLayer()

void QgsCentroidFillSymbolLayerV2Widget::setMarker()
{
QgsSymbolV2PropertiesDialog dlg( mLayer->subSymbol(), this );
QgsSymbolV2PropertiesDialog dlg( mLayer->subSymbol(), mVectorLayer, this );
if ( dlg.exec() == 0 )
return;
updateMarker();
Expand Down
42 changes: 23 additions & 19 deletions src/gui/symbology-ng/qgssymbollayerv2widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@
#include <QWidget>

class QgsSymbolLayerV2;
class QgsVectorLayer;


class GUI_EXPORT QgsSymbolLayerV2Widget : public QWidget
{
Q_OBJECT

public:
QgsSymbolLayerV2Widget( QWidget* parent ) : QWidget( parent ) {}
QgsSymbolLayerV2Widget( QWidget* parent, const QgsVectorLayer* vl = 0 ) : QWidget( parent ), mVectorLayer( vl ) {}
virtual ~QgsSymbolLayerV2Widget() {}

virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) = 0;
virtual QgsSymbolLayerV2* symbolLayer() = 0;

protected:
const QgsVectorLayer* mVectorLayer;

signals:
void changed();
};
Expand All @@ -33,9 +37,9 @@ class GUI_EXPORT QgsSimpleLineSymbolLayerV2Widget : public QgsSymbolLayerV2Widge
Q_OBJECT

public:
QgsSimpleLineSymbolLayerV2Widget( QWidget* parent = NULL );
QgsSimpleLineSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = NULL );

static QgsSymbolLayerV2Widget* create() { return new QgsSimpleLineSymbolLayerV2Widget(); }
static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) { return new QgsSimpleLineSymbolLayerV2Widget( vl ); }

// from base class
virtual void setSymbolLayer( QgsSymbolLayerV2* layer );
Expand Down Expand Up @@ -68,9 +72,9 @@ class GUI_EXPORT QgsSimpleMarkerSymbolLayerV2Widget : public QgsSymbolLayerV2Wid
Q_OBJECT

public:
QgsSimpleMarkerSymbolLayerV2Widget( QWidget* parent = NULL );
QgsSimpleMarkerSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = NULL );

static QgsSymbolLayerV2Widget* create() { return new QgsSimpleMarkerSymbolLayerV2Widget(); }
static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) { return new QgsSimpleMarkerSymbolLayerV2Widget( vl ); }

// from base class
virtual void setSymbolLayer( QgsSymbolLayerV2* layer );
Expand Down Expand Up @@ -99,9 +103,9 @@ class GUI_EXPORT QgsSimpleFillSymbolLayerV2Widget : public QgsSymbolLayerV2Widge
Q_OBJECT

public:
QgsSimpleFillSymbolLayerV2Widget( QWidget* parent = NULL );
QgsSimpleFillSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = NULL );

static QgsSymbolLayerV2Widget* create() { return new QgsSimpleFillSymbolLayerV2Widget(); }
static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) { return new QgsSimpleFillSymbolLayerV2Widget( vl ); }

// from base class
virtual void setSymbolLayer( QgsSymbolLayerV2* layer );
Expand Down Expand Up @@ -131,9 +135,9 @@ class GUI_EXPORT QgsMarkerLineSymbolLayerV2Widget : public QgsSymbolLayerV2Widge
Q_OBJECT

public:
QgsMarkerLineSymbolLayerV2Widget( QWidget* parent = NULL );
QgsMarkerLineSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = NULL );

static QgsSymbolLayerV2Widget* create() { return new QgsMarkerLineSymbolLayerV2Widget(); }
static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) { return new QgsMarkerLineSymbolLayerV2Widget( vl ); }

// from base class
virtual void setSymbolLayer( QgsSymbolLayerV2* layer );
Expand Down Expand Up @@ -166,9 +170,9 @@ class GUI_EXPORT QgsSvgMarkerSymbolLayerV2Widget : public QgsSymbolLayerV2Widget
Q_OBJECT

public:
QgsSvgMarkerSymbolLayerV2Widget( QWidget* parent = NULL );
QgsSvgMarkerSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = NULL );

static QgsSymbolLayerV2Widget* create() { return new QgsSvgMarkerSymbolLayerV2Widget(); }
static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) { return new QgsSvgMarkerSymbolLayerV2Widget( vl ); }

// from base class
virtual void setSymbolLayer( QgsSymbolLayerV2* layer );
Expand Down Expand Up @@ -199,9 +203,9 @@ class GUI_EXPORT QgsLineDecorationSymbolLayerV2Widget : public QgsSymbolLayerV2W
Q_OBJECT

public:
QgsLineDecorationSymbolLayerV2Widget( QWidget* parent = NULL );
QgsLineDecorationSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = NULL );

static QgsSymbolLayerV2Widget* create() { return new QgsLineDecorationSymbolLayerV2Widget(); }
static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) { return new QgsLineDecorationSymbolLayerV2Widget( vl ); }

// from base class
virtual void setSymbolLayer( QgsSymbolLayerV2* layer );
Expand All @@ -226,9 +230,9 @@ class GUI_EXPORT QgsSVGFillSymbolLayerWidget : public QgsSymbolLayerV2Widget, pr
Q_OBJECT

public:
QgsSVGFillSymbolLayerWidget( QWidget* parent = NULL );
QgsSVGFillSymbolLayerWidget( const QgsVectorLayer* vl, QWidget* parent = NULL );

static QgsSymbolLayerV2Widget* create() { return new QgsSVGFillSymbolLayerWidget(); }
static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) { return new QgsSVGFillSymbolLayerWidget( vl ); }

// from base class
virtual void setSymbolLayer( QgsSymbolLayerV2* layer );
Expand Down Expand Up @@ -263,9 +267,9 @@ class GUI_EXPORT QgsFontMarkerSymbolLayerV2Widget : public QgsSymbolLayerV2Widge
Q_OBJECT

public:
QgsFontMarkerSymbolLayerV2Widget( QWidget* parent = NULL );
QgsFontMarkerSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = NULL );

static QgsSymbolLayerV2Widget* create() { return new QgsFontMarkerSymbolLayerV2Widget(); }
static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) { return new QgsFontMarkerSymbolLayerV2Widget( vl ); }

// from base class
virtual void setSymbolLayer( QgsSymbolLayerV2* layer );
Expand Down Expand Up @@ -296,9 +300,9 @@ class GUI_EXPORT QgsCentroidFillSymbolLayerV2Widget : public QgsSymbolLayerV2Wid
Q_OBJECT

public:
QgsCentroidFillSymbolLayerV2Widget( QWidget* parent = NULL );
QgsCentroidFillSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = NULL );

static QgsSymbolLayerV2Widget* create() { return new QgsCentroidFillSymbolLayerV2Widget(); }
static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) { return new QgsCentroidFillSymbolLayerV2Widget( vl ); }

// from base class
virtual void setSymbolLayer( QgsSymbolLayerV2* layer );
Expand Down
6 changes: 3 additions & 3 deletions src/gui/symbology-ng/qgssymbolv2propertiesdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ static void _initWidgetFunctions()

//////////

QgsSymbolV2PropertiesDialog::QgsSymbolV2PropertiesDialog( QgsSymbolV2* symbol, QWidget* parent )
: QDialog( parent ), mSymbol( symbol )
QgsSymbolV2PropertiesDialog::QgsSymbolV2PropertiesDialog( QgsSymbolV2* symbol, const QgsVectorLayer* vl, QWidget* parent )
: QDialog( parent ), mSymbol( symbol ), mVectorLayer( vl )
{
setupUi( this );

Expand Down Expand Up @@ -247,7 +247,7 @@ void QgsSymbolV2PropertiesDialog::loadPropertyWidgets()
if ( am == NULL ) // check whether the metadata is assigned
continue;

QgsSymbolLayerV2Widget* w = am->createSymbolLayerWidget();
QgsSymbolLayerV2Widget* w = am->createSymbolLayerWidget( mVectorLayer );
if ( w == NULL ) // check whether the function returns correct widget
continue;

Expand Down
Loading

0 comments on commit 066a0ea

Please sign in to comment.