16#include <QDialogButtonBox>
35 , mMessageBar( messageBar )
41 mLabelModeComboBox->addItem(
QgsApplication::getThemeIcon( QStringLiteral(
"labelingSingle.svg" ) ), tr(
"Single Labels" ), ModeSingle );
42 mLabelModeComboBox->addItem(
QgsApplication::getThemeIcon( QStringLiteral(
"labelingRuleBased.svg" ) ), tr(
"Rule-based Labeling" ), ModeRuleBased );
45 connect( mEngineSettingsButton, &QAbstractButton::clicked,
this, &QgsLabelingWidget::showEngineConfigDialog );
47 connect( mLabelModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLabelingWidget::labelModeChanged );
51 mEngineSettingsButton->setIconSize( QSize( iconSize16, iconSize16 ) );
56 return qobject_cast<QgsLabelingGui *>( mWidget );
82 QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( mapLayer );
105 mLabelModeComboBox->setCurrentIndex( mLabelModeComboBox->findData( ModeRuleBased ) );
111 mLabelModeComboBox->setCurrentIndex( mLabelModeComboBox->findData( lyr.
drawLabels ? ModeSingle : ModeBlocking ) );
115 mLabelModeComboBox->setCurrentIndex( mLabelModeComboBox->findData( ModeNone ) );
118 if ( QgsLabelingGui *lg = qobject_cast<QgsLabelingGui *>( mWidget ) )
126 const Mode mode =
static_cast< Mode
>( mLabelModeComboBox->currentData().toInt() );
168void QgsLabelingWidget::labelModeChanged(
int index )
171 mStackedWidget->removeWidget( mWidget );
179 const Mode mode =
static_cast< Mode
>( mLabelModeComboBox->currentData().toInt() );
190 mWidget = ruleWidget;
191 mStackedWidget->addWidget( mWidget );
192 mStackedWidget->setCurrentWidget( mWidget );
199 mSimpleSettings.reset();
212 if ( firstChild->settings() )
218 if ( !mSimpleSettings )
223 if ( mSimpleSettings->fieldName.isEmpty() )
234 QgsLabelingGui *simpleWidget =
new QgsLabelingGui( mLayer, mCanvas, *mSimpleSettings,
this );
235 simpleWidget->setContext( context );
237 simpleWidget->setDockMode(
dockMode() );
241 simpleWidget->setLabelMode( QgsLabelingGui::Labels );
243 mWidget = simpleWidget;
252 obstacleWidget->
setSettings( mSimpleSettings->obstacleSettings() );
255 mSimpleSettings->obstacleSettings().setIsObstacle(
true );
256 mSimpleSettings->drawLabels =
false;
260 mSimpleSettings->setObstacleSettings( obstacleWidget->
settings() );
266 mWidget = obstacleWidget;
275 mStackedWidget->addWidget( mWidget );
276 mStackedWidget->setCurrentWidget( mWidget );
286void QgsLabelingWidget::showEngineConfigDialog()
virtual QgsPalLayerSettings settings(const QString &providerId=QString()) const =0
Gets associated label settings.
static QgsPalLayerSettings defaultSettingsForLayer(const QgsVectorLayer *layer)
Returns the default layer settings to use for the specified vector layer.
virtual QString type() const =0
Unique type string of the labeling configuration implementation.
virtual QgsAbstractVectorLayerLabeling * clone() const =0
Returns a new copy of the object.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
Dialog for configuring the labeling engine.
Map canvas is a class for displaying all GIS data types on a canvas.
Base class for all map layer types.
void triggerRepaint(bool deferredUpdate=false)
Will advise the map canvas (and any other interested party) that this layer requires to be repainted.
A bar for displaying non-blocking messages to the user.
Contains settings for how a map layer will be labeled.
bool drawLabels
Whether to draw labels for this layer.
static QgsProject * instance()
Returns the QgsProject singleton instance.
void setDirty(bool b=true)
Flag the project as dirty (modified).
A child rule for QgsRuleBasedLabeling.
QgsRuleBasedLabeling::Rule * clone() const
clone this rule, return new instance
const QgsRuleBasedLabeling::RuleList & children() const
Returns all children rules of this rule.
Rule based labeling for a vector layer.
QgsRuleBasedLabeling::Rule * rootRule()
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
void setMessageBar(QgsMessageBar *bar)
Sets the message bar associated with the widget.
void widgetChanged()
Emitted when the text format defined by the widget changes.
Basic implementation of the labeling interface.
Represents a vector layer which manages a vector based data sets.
void setLabeling(QgsAbstractVectorLayerLabeling *labeling)
Sets labeling configuration.
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
Q_INVOKABLE QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
void setLabelsEnabled(bool enabled)
Sets whether labels should be enabled for the layer.
const QgsAbstractVectorLayerLabeling * labeling() const
Access to const labeling configuration.
QString displayField() const
This is a shorthand for accessing the displayExpression if it is a simple field.
@ VectorLayer
Vector layer.
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly,...
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.