16#include <QDialogButtonBox>
20#include "moc_qgslabelingwidget.cpp"
37 , mMessageBar( messageBar )
43 mLabelModeComboBox->addItem(
QgsApplication::getThemeIcon( QStringLiteral(
"labelingSingle.svg" ) ), tr(
"Single Labels" ), ModeSingle );
44 mLabelModeComboBox->addItem(
QgsApplication::getThemeIcon( QStringLiteral(
"labelingRuleBased.svg" ) ), tr(
"Rule-based Labeling" ), ModeRuleBased );
47 connect( mLabelRulesButton, &QAbstractButton::clicked,
this, &QgsLabelingWidget::showLabelingEngineRulesPrivate );
48 connect( mEngineSettingsButton, &QAbstractButton::clicked,
this, &QgsLabelingWidget::showEngineConfigDialogPrivate );
50 connect( mLabelModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsLabelingWidget::labelModeChanged );
54 mEngineSettingsButton->setIconSize( QSize( iconSize16, iconSize16 ) );
55 mLabelRulesButton->setIconSize( QSize( iconSize16, iconSize16 ) );
60 return qobject_cast<QgsLabelingGui *>( mWidget );
86 QgsVectorLayer *layer = qobject_cast<QgsVectorLayer *>( mapLayer );
109 mLabelModeComboBox->setCurrentIndex( mLabelModeComboBox->findData( ModeRuleBased ) );
115 mLabelModeComboBox->setCurrentIndex( mLabelModeComboBox->findData( lyr.
drawLabels ? ModeSingle : ModeBlocking ) );
119 mLabelModeComboBox->setCurrentIndex( mLabelModeComboBox->findData( ModeNone ) );
122 if ( QgsLabelingGui *lg = qobject_cast<QgsLabelingGui *>( mWidget ) )
130 const Mode mode =
static_cast<Mode
>( mLabelModeComboBox->currentData().toInt() );
172void QgsLabelingWidget::labelModeChanged(
int index )
175 mStackedWidget->removeWidget( mWidget );
183 const Mode mode =
static_cast<Mode
>( mLabelModeComboBox->currentData().toInt() );
194 mWidget = ruleWidget;
195 mStackedWidget->addWidget( mWidget );
196 mStackedWidget->setCurrentWidget( mWidget );
203 mSimpleSettings.reset();
216 if ( firstChild->settings() )
222 if ( !mSimpleSettings )
227 if ( mSimpleSettings->fieldName.isEmpty() )
238 QgsLabelingGui *simpleWidget =
new QgsLabelingGui( mLayer, mCanvas, *mSimpleSettings,
this );
239 simpleWidget->setContext( context );
241 simpleWidget->setDockMode(
dockMode() );
245 simpleWidget->setLabelMode( QgsLabelingGui::Labels );
247 mWidget = simpleWidget;
256 obstacleWidget->
setSettings( mSimpleSettings->obstacleSettings() );
259 mSimpleSettings->obstacleSettings().setIsObstacle(
true );
260 mSimpleSettings->drawLabels =
false;
263 mSimpleSettings->setObstacleSettings( obstacleWidget->
settings() );
269 mWidget = obstacleWidget;
278 mStackedWidget->addWidget( mWidget );
279 mStackedWidget->setCurrentWidget( mWidget );
294 QList<QgsAbstractLabelingEngineRule *> rules;
298 rules << const_cast<QgsAbstractLabelingEngineRule *>( rule );
327 parent->activateWindow();
331void QgsLabelingWidget::showLabelingEngineRulesPrivate()
350 parent->activateWindow();
354void QgsLabelingWidget::showEngineConfigDialogPrivate()
The Qgis class provides global constants for use throughout the application.
Abstract base class for labeling engine rules.
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.
A dialog which allows configuration of a list of labeling engine rules.
QList< QgsAbstractLabelingEngineRule * > rules() const
Returns the rules shown in the dialog.
void setRules(const QList< QgsAbstractLabelingEngineRule * > &rules)
Sets the rules to show in the dialog.
Stores global configuration for labeling engine.
void setRules(const QList< QgsAbstractLabelingEngineRule * > &rules)
Sets the labeling engine rules which must be satisfied while placing labels.
QList< QgsAbstractLabelingEngineRule * > rules()
Returns a list of labeling engine rules which must be satisfied while placing labels.
Map canvas is a class for displaying all GIS data types on a canvas.
void refreshAllLayers()
Reload all layers (including refreshing layer properties from their data sources),...
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 setLabelingEngineSettings(const QgsLabelingEngineSettings &settings)
Sets project's global labeling engine settings.
const QgsLabelingEngineSettings & labelingEngineSettings() const
Returns project's global labeling engine settings.
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.
void setLabelsEnabled(bool enabled)
Sets whether labels should be enabled for the layer.
const QgsAbstractVectorLayerLabeling * labeling() const
Access to const labeling configuration.
Q_INVOKABLE Qgis::GeometryType geometryType() const
Returns point, line or polygon.
QString displayField() const
This is a shorthand for accessing the displayExpression if it is a simple field.
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly,...
@ Unknown
Unknown/invalid format.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.