Skip to content
Permalink
Browse files

[symbology] resurrect symbol levels dialog (fixes #16996)

  • Loading branch information
nirvn committed Sep 12, 2017
1 parent 5796783 commit 5e7dadd575cac089344db9e7abe78275a98227da
@@ -8,13 +8,18 @@




class QgsSymbolLevelsDialog : QDialog
{

%TypeHeaderCode
#include "qgssymbollevelsdialog.h"
%End
public:
QgsSymbolLevelsDialog( QgsFeatureRenderer *renderer, bool usingSymbolLevels, QWidget *parent = 0 );
%Docstring
Constructor for QgsSymbolLevelsDialog
%End

~QgsSymbolLevelsDialog();

@@ -33,8 +38,11 @@ class QgsSymbolLevelsDialog : QDialog
protected:




private:
QgsSymbolLevelsDialog();

};


@@ -251,11 +251,9 @@ void QgsRendererWidget::changeSymbolAngle()

void QgsRendererWidget::showSymbolLevelsDialog( QgsFeatureRenderer *r )
{
QgsSymbolLevelsDialog dlg( r->legendSymbolItems(), r->usingSymbolLevels(), this );

QgsSymbolLevelsDialog dlg( r, r->usingSymbolLevels(), this );
if ( dlg.exec() )
{
r->setUsingSymbolLevels( dlg.usingLevels() );
emit widgetChanged();
}
}
@@ -396,10 +396,12 @@ void QgsRuleBasedRendererWidget::keyPressEvent( QKeyEvent *event )

void QgsRuleBasedRendererWidget::setRenderingOrder()
{
QgsSymbolLevelsDialog dlg( mRenderer->legendSymbolItems(), true, this );
QgsSymbolLevelsDialog dlg( mRenderer, true, this );
dlg.setForceOrderingEnabled( true );

dlg.exec();
if ( dlg.exec() )
{
emit widgetChanged();
}
}

void QgsRuleBasedRendererWidget::saveSectionWidth( int section, int oldSize, int newSize )
@@ -28,8 +28,9 @@

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

QgsSymbolLevelsDialog::QgsSymbolLevelsDialog( const QgsLegendSymbolList &list, bool usingSymbolLevels, QWidget *parent )
QgsSymbolLevelsDialog::QgsSymbolLevelsDialog( QgsFeatureRenderer *renderer, bool usingSymbolLevels, QWidget *parent )
: QDialog( parent )
, mRenderer( renderer )
, mForceOrderingEnabled( false )
{
setupUi( this );
@@ -42,13 +43,17 @@ QgsSymbolLevelsDialog::QgsSymbolLevelsDialog( const QgsLegendSymbolList &list, b
chkEnable->setChecked( usingSymbolLevels );

connect( chkEnable, &QAbstractButton::clicked, this, &QgsSymbolLevelsDialog::updateUi );
connect( buttonBox, &QDialogButtonBox::accepted, this, &QgsSymbolLevelsDialog::apply );
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsSymbolLevelsDialog::showHelp );

// only consider entries with symbols
Q_FOREACH ( const QgsLegendSymbolItem &item, list )
if ( mRenderer )
{
if ( item.symbol() )
mList << item;
// only consider entries with symbols
Q_FOREACH ( const QgsLegendSymbolItem &item, mRenderer->legendSymbolItems() )
{
if ( item.symbol() )
mList << item;
}
}

int maxLayers = 0;
@@ -128,6 +133,20 @@ void QgsSymbolLevelsDialog::updateUi()
tableLevels->setEnabled( chkEnable->isChecked() );
}

void QgsSymbolLevelsDialog::apply()
{
for ( int i = 0; i < mList.count(); i++ )
{
QgsSymbol *sym = mList.at( i ).symbol();
for ( int layer = 0; layer < sym->symbolLayerCount(); layer++ )
{
mRenderer->setLegendSymbolItem( mList.at( i ).ruleKey(), sym->clone() );
}
}

mRenderer->setUsingSymbolLevels( usingLevels() );
}

void QgsSymbolLevelsDialog::setDefaultLevels()
{
for ( int i = 0; i < mList.count(); i++ )
@@ -20,8 +20,9 @@
#include <QList>
#include <QItemDelegate>

#include "qgsrenderer.h"
#include "qgshelp.h"
#include "qgsrenderer.h"

#include "ui_qgssymbollevelsdialogbase.h"
#include "qgis_gui.h"

@@ -32,8 +33,8 @@ class GUI_EXPORT QgsSymbolLevelsDialog : public QDialog, private Ui::QgsSymbolLe
{
Q_OBJECT
public:
//! \note not available in Python bindings
QgsSymbolLevelsDialog( const QgsLegendSymbolList &list, bool usingSymbolLevels, QWidget *parent = nullptr ) SIP_SKIP;
//! Constructor for QgsSymbolLevelsDialog
QgsSymbolLevelsDialog( QgsFeatureRenderer *renderer, bool usingSymbolLevels, QWidget *parent = nullptr );

~QgsSymbolLevelsDialog();

@@ -48,6 +49,9 @@ class GUI_EXPORT QgsSymbolLevelsDialog : public QDialog, private Ui::QgsSymbolLe
void renderingPassChanged( int row, int column );

private slots:
//! Apply button
void apply();

void showHelp();

protected:
@@ -58,13 +62,17 @@ class GUI_EXPORT QgsSymbolLevelsDialog : public QDialog, private Ui::QgsSymbolLe

//! maximal number of layers from all symbols
int mMaxLayers;

QgsFeatureRenderer *mRenderer;
QgsLegendSymbolList mList;

//! whether symbol layers always should be used (default false)
bool mForceOrderingEnabled;

private:
#ifdef SIP_RUN
QgsSymbolLevelsDialog();

#endif
};

0 comments on commit 5e7dadd

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