40 #include <QMessageBox> 42 static bool _initRenderer(
const QString &name,
QgsRendererWidgetFunc f,
const QString &iconName = QString() )
54 if ( !iconName.isEmpty() )
63 static void _initRendererWidgetFunctions()
65 static bool sInitialized =
false;
89 mLayerRenderingGroupBox->setSettingGroup( QStringLiteral(
"layerRenderingGroupBox" ) );
95 layout()->setContentsMargins( 0, 0, 0, 0 );
99 _initRendererWidgetFunctions();
103 Q_FOREACH (
const QString &name, renderers )
109 cboRenderers->setCurrentIndex( -1 );
115 connect( checkboxEnableOrderBy, &QAbstractButton::toggled, btnOrderBy, &QWidget::setEnabled );
116 connect( btnOrderBy, &QAbstractButton::clicked,
this, &QgsRendererPropertiesDialog::showOrderByDialog );
120 QList<QWidget *> widgets;
121 widgets << mOpacityWidget
123 << checkboxEnableOrderBy
124 << mBlendModeComboBox
125 << mFeatureBlendComboBox
134 Q_FOREACH ( QWidget *widget, widgets )
138 connect( w, SIGNAL( changed ),
this, slot );
142 connect( w, SIGNAL( fieldChanged( QString ) ),
this, slot );
144 else if (
QgsOpacityWidget *w = qobject_cast<QgsOpacityWidget *>( widget ) )
146 connect( w, SIGNAL( opacityChanged(
double ) ),
this, slot );
148 else if ( QComboBox *w = qobject_cast<QComboBox *>( widget ) )
150 connect( w, SIGNAL( currentIndexChanged(
int ) ),
this, slot );
152 else if ( QSpinBox *w = qobject_cast<QSpinBox *>( widget ) )
154 connect( w, SIGNAL( valueChanged(
int ) ),
this, slot );
156 else if ( QDoubleSpinBox *w = qobject_cast<QDoubleSpinBox *>( widget ) )
158 connect( w, SIGNAL( valueChanged(
double ) ),
this, slot );
160 else if (
QgsColorButton *w = qobject_cast<QgsColorButton *>( widget ) )
162 connect( w, SIGNAL( colorChanged( QColor ) ),
this, slot );
164 else if ( QCheckBox *w = qobject_cast<QCheckBox *>( widget ) )
166 connect( w, SIGNAL( toggled(
bool ) ),
this, slot );
168 else if ( QLineEdit *w = qobject_cast<QLineEdit *>( widget ) )
170 connect( w, SIGNAL( textEdited( QString ) ),
this, slot );
171 connect( w, SIGNAL( textChanged( QString ) ),
this, slot );
175 connect( w, SIGNAL( changed() ),
this, slot );
198 mDockMode = dockMode;
199 mEffectWidget->setDockMode( dockMode );
207 if ( cboRenderers->currentIndex() == -1 )
209 QgsDebugMsg( QStringLiteral(
"No current item -- this should never happen!" ) );
213 QString rendererName = cboRenderers->currentData().toString();
265 stackedWidget->setCurrentWidget( pageNoWidget );
315 QDialog *dlg =
new QDialog();
316 QString key = QStringLiteral(
"/UI/paneldialog/%1" ).arg( panel->
panelTitle() );
318 dlg->restoreGeometry( settings.
value( key ).toByteArray() );
320 dlg->setLayout(
new QVBoxLayout() );
321 dlg->layout()->addWidget( panel );
322 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Ok );
323 connect( buttonBox, &QDialogButtonBox::accepted, dlg, &QDialog::accept );
324 dlg->layout()->addWidget( buttonBox );
326 settings.
setValue( key, dlg->saveGeometry() );
331 void QgsRendererPropertiesDialog::syncToLayer()
359 checkboxEnableOrderBy->setChecked(
true );
363 btnOrderBy->setEnabled(
false );
364 checkboxEnableOrderBy->setChecked(
false );
372 int rendererIdx = cboRenderers->findData( rendererName );
373 cboRenderers->setCurrentIndex( rendererIdx );
376 Q_ASSERT( rendererIdx != -1 &&
"there must be a renderer!" );
381 void QgsRendererPropertiesDialog::showOrderByDialog()
396 checkboxEnableOrderBy->setChecked( orderByEnabled );
399 void QgsRendererPropertiesDialog::updateUIState(
bool hidden )
401 mLayerRenderingGroupBox->setHidden( hidden );
402 cboRenderers->setHidden( hidden );
409 if ( !isWindow() && e->key() == Qt::Key_Escape )
415 QDialog::keyPressEvent( e );
QStringList renderersList(QgsRendererAbstractMetadata::LayerTypes layerTypes=QgsRendererAbstractMetadata::All) const
Returns a list of available renderers.
void widgetChanged()
Emitted when something on the widget has changed.
This is a dialog to build and manage a list of order by clauses.
void onOK()
Apply and accept the changes for the dialog.
QgsRendererWidget * mActiveWidget
void setRenderer(QgsFeatureRenderer *r)
Set renderer which will be invoked to represent this layer.
void setOrderBy(const QgsFeatureRequest::OrderBy &orderBy)
Set the order by to manage.
void apply()
Apply the changes from the dialog to the layer.
void setDockMode(bool dockMode)
Set the widget in dock mode which tells the widget to emit panel widgets and not open dialogs...
void openPanel(QgsPanelWidget *panel)
Open a panel or dialog depending on dock mode setting If dock mode is true this method will emit the ...
This class is a composition of two QSettings instances:
~QgsRendererPropertiesDialog() override
void connectValueChanged(const QList< QWidget * > &widgets, const char *slot)
Connect the given slot to the value changed event for the set of widgets Each widget is checked for t...
void setFeatureBlendMode(QPainter::CompositionMode blendMode)
Sets the blending mode used for rendering each feature.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
QgsMapCanvas * mMapCanvas
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the dialog.
void setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer.
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
Map canvas is a class for displaying all GIS data types on a canvas.
virtual QgsPaintEffect * clone() const =0
Duplicates an effect by creating a deep copy of the effect.
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the renderer.
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
QPainter::CompositionMode featureBlendMode() const
Returns the current blending mode for features.
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the renderer.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown...
void layerVariablesChanged()
Emitted when expression context variables on the associated vector layers have been changed...
QgsRendererWidget *(* QgsRendererWidgetFunc)(QgsVectorLayer *, QgsStyle *, QgsFeatureRenderer *)
QgsPaintEffect * mPaintEffect
QgsRendererAbstractMetadata * rendererMetadata(const QString &rendererName)
Returns the metadata for a specified renderer.
QgsFeatureRenderer * renderer()
Returns renderer.
bool orderByEnabled() const
Returns whether custom ordering will be applied before features are processed by this renderer...
void setOrderBy(const QgsFeatureRequest::OrderBy &orderBy)
Define the order in which features shall be processed by this renderer.
void showPanel(QgsPanelWidget *panel)
Emit when you require a panel to be show in the interface.
QgsFeatureRequest::OrderBy mOrderBy
void keyPressEvent(QKeyEvent *event) override
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
void rendererChanged()
called when user changes renderer type
QgsFeatureRequest::OrderBy orderBy() const
Gets the order in which features shall be processed by this renderer.
QgsRendererPropertiesDialog(QgsVectorLayer *layer, QgsStyle *style, bool embedded=false, QWidget *parent=nullptr)
Constructor for QgsRendererPropertiesDialog.
QgsFeatureRequest::OrderBy orderBy()
Gets the order by defined in the dialog.
Represents a vector layer which manages a vector based data sets.
void setOrderByEnabled(bool enabled)
Sets whether custom ordering should be applied before features are processed by this renderer...
static QgsRendererRegistry * rendererRegistry()
Returns the application's renderer registry, used for managing vector layer renderers.
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
Represents a list of OrderByClauses, with the most important first and the least important last...
void setOpacity(double opacity)
Sets the opacity for the vector layer, where opacity is a value between 0 (totally transparent) and 1...