Skip to content

Commit c468a04

Browse files
committedAug 21, 2016
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.
1 parent ae3d6e7 commit c468a04

File tree

3 files changed

+11
-20
lines changed

3 files changed

+11
-20
lines changed
 

‎src/gui/symbology-ng/qgssymbollayerwidget.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3346,23 +3346,20 @@ QgsGeometryGeneratorSymbolLayerWidget::QgsGeometryGeneratorSymbolLayerWidget( co
33463346
, mLayer( nullptr )
33473347
{
33483348
setupUi( this );
3349+
modificationExpressionSelector->setMultiLine( true );
33493350
modificationExpressionSelector->setLayer( const_cast<QgsVectorLayer*>( vl ) );
3350-
modificationExpressionSelector->loadFieldNames();
3351-
modificationExpressionSelector->setExpressionContext( createExpressionContext() );
3351+
modificationExpressionSelector->registerExpressionContextGenerator( this );
33523352
cbxGeometryType->addItem( QgsApplication::getThemeIcon( "/mIconPolygonLayer.svg" ), tr( "Polygon / MultiPolygon" ), QgsSymbol::Fill );
33533353
cbxGeometryType->addItem( QgsApplication::getThemeIcon( "/mIconLineLayer.svg" ), tr( "LineString / MultiLineString" ), QgsSymbol::Line );
33543354
cbxGeometryType->addItem( QgsApplication::getThemeIcon( "/mIconPointLayer.svg" ), tr( "Point / MultiPoint" ), QgsSymbol::Marker );
3355-
connect( modificationExpressionSelector, SIGNAL( expressionParsed( bool ) ), this, SLOT( updateExpression() ) );
3355+
connect( modificationExpressionSelector, SIGNAL( expressionChanged( QString ) ), this, SLOT( updateExpression( QString ) ) );
33563356
connect( cbxGeometryType, SIGNAL( currentIndexChanged( int ) ), this, SLOT( updateSymbolType() ) );
33573357
}
33583358

33593359
void QgsGeometryGeneratorSymbolLayerWidget::setSymbolLayer( QgsSymbolLayer* l )
33603360
{
33613361
mLayer = static_cast<QgsGeometryGeneratorSymbolLayer*>( l );
3362-
3363-
if ( mPresetExpressionContext )
3364-
modificationExpressionSelector->setExpressionContext( *mPresetExpressionContext );
3365-
modificationExpressionSelector->setExpressionText( mLayer->geometryExpression() );
3362+
modificationExpressionSelector->setExpression( mLayer->geometryExpression() );
33663363
cbxGeometryType->setCurrentIndex( cbxGeometryType->findData( mLayer->symbolType() ) );
33673364
}
33683365

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

3374-
void QgsGeometryGeneratorSymbolLayerWidget::updateExpression()
3371+
void QgsGeometryGeneratorSymbolLayerWidget::updateExpression( const QString& string )
33753372
{
3376-
mLayer->setGeometryExpression( modificationExpressionSelector->expressionText() );
3373+
mLayer->setGeometryExpression( string );
33773374

33783375
emit changed();
33793376
}

‎src/gui/symbology-ng/qgssymbollayerwidget.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class QgsMapCanvas;
2929
/** \ingroup gui
3030
* \class QgsSymbolLayerWidget
3131
*/
32-
class GUI_EXPORT QgsSymbolLayerWidget : public QWidget, private QgsExpressionContextGenerator
32+
class GUI_EXPORT QgsSymbolLayerWidget : public QWidget, protected QgsExpressionContextGenerator
3333
{
3434
Q_OBJECT
3535

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

799799
private slots:
800-
void updateExpression();
800+
void updateExpression( const QString& string );
801801
void updateSymbolType();
802802
};
803803

‎src/ui/symbollayer/qgsgeometrygeneratorwidgetbase.ui

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,7 @@
1515
</property>
1616
<layout class="QGridLayout" name="gridLayout">
1717
<item row="1" column="0" colspan="2">
18-
<widget class="QgsExpressionBuilderWidget" name="modificationExpressionSelector" native="true">
19-
<layout class="QGridLayout" name="gridLayout_2">
20-
<property name="margin">
21-
<number>0</number>
22-
</property>
23-
</layout>
24-
</widget>
18+
<widget class="QgsExpressionLineEdit" name="modificationExpressionSelector" native="true"/>
2519
</item>
2620
<item row="0" column="1">
2721
<widget class="QComboBox" name="cbxGeometryType"/>
@@ -43,9 +37,9 @@
4337
</widget>
4438
<customwidgets>
4539
<customwidget>
46-
<class>QgsExpressionBuilderWidget</class>
40+
<class>QgsExpressionLineEdit</class>
4741
<extends>QWidget</extends>
48-
<header>qgsexpressionbuilderwidget.h</header>
42+
<header>qgsexpressionlineedit.h</header>
4943
<container>1</container>
5044
</customwidget>
5145
</customwidgets>

0 commit comments

Comments
 (0)
Please sign in to comment.