Skip to content
Permalink
Browse files

Use QgsExpressionLineEdit for geometry generator expression

The full expression builder widget is too large to fit
comfortable in the geometry generator setting widget,
especially when used in layer styling dock mode.
  • Loading branch information
nyalldawson committed Aug 21, 2016
1 parent ae3d6e7 commit c468a0471c17f25ed2388df387e2a49269dae6df
@@ -3346,23 +3346,20 @@ QgsGeometryGeneratorSymbolLayerWidget::QgsGeometryGeneratorSymbolLayerWidget( co
, mLayer( nullptr )
{
setupUi( this );
modificationExpressionSelector->setMultiLine( true );
modificationExpressionSelector->setLayer( const_cast<QgsVectorLayer*>( vl ) );
modificationExpressionSelector->loadFieldNames();
modificationExpressionSelector->setExpressionContext( createExpressionContext() );
modificationExpressionSelector->registerExpressionContextGenerator( this );
cbxGeometryType->addItem( QgsApplication::getThemeIcon( "/mIconPolygonLayer.svg" ), tr( "Polygon / MultiPolygon" ), QgsSymbol::Fill );
cbxGeometryType->addItem( QgsApplication::getThemeIcon( "/mIconLineLayer.svg" ), tr( "LineString / MultiLineString" ), QgsSymbol::Line );
cbxGeometryType->addItem( QgsApplication::getThemeIcon( "/mIconPointLayer.svg" ), tr( "Point / MultiPoint" ), QgsSymbol::Marker );
connect( modificationExpressionSelector, SIGNAL( expressionParsed( bool ) ), this, SLOT( updateExpression() ) );
connect( modificationExpressionSelector, SIGNAL( expressionChanged( QString ) ), this, SLOT( updateExpression( QString ) ) );
connect( cbxGeometryType, SIGNAL( currentIndexChanged( int ) ), this, SLOT( updateSymbolType() ) );
}

void QgsGeometryGeneratorSymbolLayerWidget::setSymbolLayer( QgsSymbolLayer* l )
{
mLayer = static_cast<QgsGeometryGeneratorSymbolLayer*>( l );

if ( mPresetExpressionContext )
modificationExpressionSelector->setExpressionContext( *mPresetExpressionContext );
modificationExpressionSelector->setExpressionText( mLayer->geometryExpression() );
modificationExpressionSelector->setExpression( mLayer->geometryExpression() );
cbxGeometryType->setCurrentIndex( cbxGeometryType->findData( mLayer->symbolType() ) );
}

@@ -3371,9 +3368,9 @@ QgsSymbolLayer* QgsGeometryGeneratorSymbolLayerWidget::symbolLayer()
return mLayer;
}

void QgsGeometryGeneratorSymbolLayerWidget::updateExpression()
void QgsGeometryGeneratorSymbolLayerWidget::updateExpression( const QString& string )
{
mLayer->setGeometryExpression( modificationExpressionSelector->expressionText() );
mLayer->setGeometryExpression( string );

emit changed();
}
@@ -29,7 +29,7 @@ class QgsMapCanvas;
/** \ingroup gui
* \class QgsSymbolLayerWidget
*/
class GUI_EXPORT QgsSymbolLayerWidget : public QWidget, private QgsExpressionContextGenerator
class GUI_EXPORT QgsSymbolLayerWidget : public QWidget, protected QgsExpressionContextGenerator
{
Q_OBJECT

@@ -797,7 +797,7 @@ class GUI_EXPORT QgsGeometryGeneratorSymbolLayerWidget : public QgsSymbolLayerWi
QgsGeometryGeneratorSymbolLayer* mLayer;

private slots:
void updateExpression();
void updateExpression( const QString& string );
void updateSymbolType();
};

@@ -15,13 +15,7 @@
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="2">
<widget class="QgsExpressionBuilderWidget" name="modificationExpressionSelector" native="true">
<layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
<number>0</number>
</property>
</layout>
</widget>
<widget class="QgsExpressionLineEdit" name="modificationExpressionSelector" native="true"/>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="cbxGeometryType"/>
@@ -43,9 +37,9 @@
</widget>
<customwidgets>
<customwidget>
<class>QgsExpressionBuilderWidget</class>
<class>QgsExpressionLineEdit</class>
<extends>QWidget</extends>
<header>qgsexpressionbuilderwidget.h</header>
<header>qgsexpressionlineedit.h</header>
<container>1</container>
</customwidget>
</customwidgets>

0 comments on commit c468a04

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