Skip to content
Permalink
Browse files

When using new symbology, embed renderer properties into vector layer…

… properties, symbology tab.

git-svn-id: http://svn.osgeo.org/qgis/branches/symbology-ng-branch@11156 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Jul 23, 2009
1 parent da2894a commit b0754044fcb8e92ef4eef1c88c73aeaca5a963f5
@@ -573,6 +573,9 @@ public:
QgsStyleV2();
~QgsStyleV2();

//! return default application-wide style
static QgsStyleV2* defaultStyle();

//! remove all contents of the style
void clear();

@@ -34,7 +34,7 @@ class QgsRendererV2PropertiesDialog : QDialog //, private Ui::QgsRendererV2Props
%End

public:
QgsRendererV2PropertiesDialog(QgsVectorLayer* layer, QgsStyleV2* style, QWidget* parent = NULL);
QgsRendererV2PropertiesDialog(QgsVectorLayer* layer, QgsStyleV2* style, QWidget* parent = NULL, bool embedded = false);

public slots:
void changeSingleSymbol();
@@ -1038,24 +1038,7 @@ void QgisApp::createActions()
#include "qgsrendererv2propertiesdialog.h"
#include "qgsstylev2managerdialog.h"

static QgsStyleV2* gStyleV2 = NULL;

static void _initStyle()
{
if (gStyleV2 == NULL)
{
QString styleFilename = QgsApplication::userStyleV2Path();

// copy default style if user style doesn't exist
if ( !QFile::exists( styleFilename ) )
{
QFile::copy( QgsApplication::defaultStyleV2Path(), styleFilename );
}

gStyleV2 = new QgsStyleV2;
gStyleV2->load( styleFilename );
}
}

void QgisApp::toggleRendererV2()
{
@@ -1067,9 +1050,7 @@ void QgisApp::toggleRendererV2()
}
QgsVectorLayer* vlayer = static_cast<QgsVectorLayer*>(layer);

_initStyle();

QgsRendererV2PropertiesDialog dlg(vlayer, gStyleV2, this);
QgsRendererV2PropertiesDialog dlg(vlayer, QgsStyleV2::defaultStyle(), this);
if (!dlg.exec())
return;

@@ -1080,9 +1061,7 @@ void QgisApp::toggleRendererV2()

void QgisApp::showStyleManagerV2()
{
_initStyle();

QgsStyleV2ManagerDialog dlg(gStyleV2, QgsApplication::userStyleV2Path(), this);
QgsStyleV2ManagerDialog dlg(QgsStyleV2::defaultStyle(), QgsApplication::userStyleV2Path(), this);
dlg.exec();
}

@@ -56,6 +56,9 @@
#include <QComboBox>
#include <QCheckBox>

#include "qgsrendererv2propertiesdialog.h"
#include "qgsstylev2.h"

#if QT_VERSION < 0x040300
#define toPlainText() text()
#endif
@@ -439,10 +442,24 @@ void QgsVectorLayerProperties::reset( void )
legendtypecombobox->addItem( tr( "Unique Value" ) );
}
}

//find out the type of renderer in the vectorlayer, create a dialog with these settings and add it to the form
delete mRendererDialog;
mRendererDialog = 0;

if (layer->isUsingRendererV2())
{
mRendererDialog = new QgsRendererV2PropertiesDialog(layer, QgsStyleV2::defaultStyle(), NULL, true);

// hide unused widgets
legendtypecombobox->hide();
legendtypelabel->hide();
lblTransparencyPercent->hide();
sliderTransparency->hide();
}
else
{

QString rtype = layer->renderer()->name();
if ( rtype == "Single Symbol" )
{
@@ -465,16 +482,17 @@ void QgsVectorLayerProperties::reset( void )
legendtypecombobox->setCurrentIndex( 3 );
}

QObject::connect( legendtypecombobox, SIGNAL( activated( const QString & ) ), this,
SLOT( alterLayerDialog( const QString & ) ) );

}

if ( mRendererDialog )
{
widgetStackRenderers->addWidget( mRendererDialog );
widgetStackRenderers->setCurrentWidget( mRendererDialog );
}


QObject::connect( legendtypecombobox, SIGNAL( activated( const QString & ) ), this,
SLOT( alterLayerDialog( const QString & ) ) );

// reset fields in label dialog
layer->label()->setFields( layer->pendingFields() );

@@ -611,32 +629,43 @@ void QgsVectorLayerProperties::apply()
}
}

QgsSingleSymbolDialog *sdialog =
dynamic_cast < QgsSingleSymbolDialog * >( widgetStackRenderers->currentWidget() );
QgsGraduatedSymbolDialog *gdialog =
dynamic_cast < QgsGraduatedSymbolDialog * >( widgetStackRenderers->currentWidget() );
QgsContinuousColorDialog *cdialog =
dynamic_cast < QgsContinuousColorDialog * >( widgetStackRenderers->currentWidget() );
QgsUniqueValueDialog* udialog =
dynamic_cast< QgsUniqueValueDialog * >( widgetStackRenderers->currentWidget() );

if ( sdialog )
if (layer->isUsingRendererV2())
{
sdialog->apply();
QgsRendererV2PropertiesDialog* dlg =
static_cast<QgsRendererV2PropertiesDialog*>(widgetStackRenderers->currentWidget());
dlg->apply();
}
else if ( gdialog )
{
gdialog->apply();
}
else if ( cdialog )
{
cdialog->apply();
}
else if ( udialog )
else
{
udialog->apply();

QgsSingleSymbolDialog *sdialog =
dynamic_cast < QgsSingleSymbolDialog * >( widgetStackRenderers->currentWidget() );
QgsGraduatedSymbolDialog *gdialog =
dynamic_cast < QgsGraduatedSymbolDialog * >( widgetStackRenderers->currentWidget() );
QgsContinuousColorDialog *cdialog =
dynamic_cast < QgsContinuousColorDialog * >( widgetStackRenderers->currentWidget() );
QgsUniqueValueDialog* udialog =
dynamic_cast< QgsUniqueValueDialog * >( widgetStackRenderers->currentWidget() );

if ( sdialog )
{
sdialog->apply();
}
else if ( gdialog )
{
gdialog->apply();
}
else if ( cdialog )
{
cdialog->apply();
}
else if ( udialog )
{
udialog->apply();
}
layer->setTransparency( static_cast < unsigned int >( 255 - sliderTransparency->value() ) );

}
layer->setTransparency( static_cast < unsigned int >( 255 - sliderTransparency->value() ) );

//apply overlay dialogs
for ( QList<QgsApplyDialog*>::iterator it = mOverlayDialogs.begin(); it != mOverlayDialogs.end(); ++it )
@@ -6,6 +6,7 @@

#include "qgssymbollayerv2registry.h"

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

#include <QDomDocument>
@@ -15,6 +16,8 @@

#define STYLE_CURRENT_VERSION "0"

QgsStyleV2* QgsStyleV2::mDefaultStyle = NULL;


QgsStyleV2::QgsStyleV2()
{
@@ -25,6 +28,25 @@ QgsStyleV2::~QgsStyleV2()
clear();
}

QgsStyleV2* QgsStyleV2::defaultStyle() // static
{
if (mDefaultStyle == NULL)
{
QString styleFilename = QgsApplication::userStyleV2Path();

// copy default style if user style doesn't exist
if ( !QFile::exists( styleFilename ) )
{
QFile::copy( QgsApplication::defaultStyleV2Path(), styleFilename );
}

mDefaultStyle = new QgsStyleV2;
mDefaultStyle->load( styleFilename );
}
return mDefaultStyle;
}


void QgsStyleV2::clear()
{
for (QMap<QString, QgsSymbolV2*>::iterator its = mSymbols.begin(); its != mSymbols.end(); ++its)
@@ -23,6 +23,9 @@ class QgsStyleV2

QgsStyleV2();
~QgsStyleV2();

//! return default application-wide style
static QgsStyleV2* defaultStyle();

//! remove all contents of the style
void clear();
@@ -90,6 +93,8 @@ class QgsStyleV2
QgsVectorColorRampV2Map mColorRamps;

QString mErrorString;

static QgsStyleV2* mDefaultStyle;
};


@@ -17,7 +17,7 @@
#include <QStandardItemModel>
#include <QStandardItem>

QgsRendererV2PropertiesDialog::QgsRendererV2PropertiesDialog(QgsVectorLayer* layer, QgsStyleV2* style, QWidget* parent)
QgsRendererV2PropertiesDialog::QgsRendererV2PropertiesDialog(QgsVectorLayer* layer, QgsStyleV2* style, QWidget* parent, bool embedded)
: QDialog(parent), mStyle(style)
{
mLayer = layer;
@@ -33,6 +33,12 @@ QgsRendererV2PropertiesDialog::QgsRendererV2PropertiesDialog(QgsVectorLayer* lay

setupUi(this);

// can be embedded in vector layer properties
if (embedded)
{
buttonBox->hide();
}

connect(buttonBox, SIGNAL(accepted()), this, SLOT(onOK()));

connect(btnSymbolLevels, SIGNAL(clicked()), this, SLOT(symbolLevels()));
@@ -91,11 +97,15 @@ QgsRendererV2PropertiesDialog::~QgsRendererV2PropertiesDialog()
delete mRenderer;
}

void QgsRendererV2PropertiesDialog::onOK()
void QgsRendererV2PropertiesDialog::apply()
{
mLayer->setRendererV2(mRenderer);
mRenderer = NULL;
}

void QgsRendererV2PropertiesDialog::onOK()
{
apply();
accept();
}

@@ -18,7 +18,7 @@ class QgsRendererV2PropertiesDialog : public QDialog, private Ui::QgsRendererV2P
Q_OBJECT

public:
QgsRendererV2PropertiesDialog(QgsVectorLayer* layer, QgsStyleV2* style, QWidget* parent = NULL);
QgsRendererV2PropertiesDialog(QgsVectorLayer* layer, QgsStyleV2* style, QWidget* parent = NULL, bool embedded = false);
~QgsRendererV2PropertiesDialog();

public slots:
@@ -39,6 +39,7 @@ public slots:
void symbolLevels();

void onOK();
void apply();

protected:

@@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>839</width>
<height>675</height>
<width>500</width>
<height>600</height>
</rect>
</property>
<property name="minimumSize" >

0 comments on commit b075404

Please sign in to comment.
You can’t perform that action at this time.