Skip to content

Commit 2b5fb21

Browse files
committedJun 4, 2011
Added expression based labels, simple dialog for entering expressions.
Code still needs some clean up and testing.
1 parent 0e318b0 commit 2b5fb21

12 files changed

+257
-54
lines changed
 

‎src/app/qgslabelinggui.cpp

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@
2424

2525
#include "qgspallabeling.h"
2626
#include "qgslabelengineconfigdialog.h"
27+
#include "qgssearchstring.h"
28+
#include "qgsexpressionbuilder.h"
2729

2830
#include <QColorDialog>
2931
#include <QFontDialog>
30-
32+
#include <QTextEdit>
3133
#include <iostream>
3234
#include <QApplication>
33-
35+
#include <QMessageBox>
3436

3537

3638
QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsMapCanvas* mapCanvas, QWidget* parent )
@@ -44,6 +46,7 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM
4446
connect( btnBufferColor, SIGNAL( clicked() ), this, SLOT( changeBufferColor() ) );
4547
connect( spinBufferSize, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() ) );
4648
connect( btnEngineSettings, SIGNAL( clicked() ), this, SLOT( showEngineConfigDialog() ) );
49+
connect( btnExpression, SIGNAL(clicked()), this, SLOT( showExpressionDialog()));
4750

4851
// set placement methods page based on geometry type
4952
switch ( layer->geometryType() )
@@ -65,12 +68,14 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM
6568
label_19->setEnabled( layer->geometryType() != QGis::Point );
6669
mMinSizeSpinBox->setEnabled( layer->geometryType() != QGis::Point );
6770

68-
populateFieldNames();
69-
7071
// load labeling settings from layer
7172
QgsPalLayerSettings lyr;
7273
lyr.readFromLayer( layer );
74+
populateFieldNames();
7375

76+
//Add the current expression to the bottom of the list.
77+
if (lyr.isExpression)
78+
cboFieldName->addItem(lyr.fieldName);
7479
populateDataDefinedCombos( lyr );
7580

7681
// placement
@@ -184,18 +189,23 @@ QgsLabelingGui::~QgsLabelingGui()
184189

185190
void QgsLabelingGui::apply()
186191
{
187-
layerSettings().writeToLayer( mLayer );
188-
// trigger refresh
189-
if ( mMapCanvas )
190-
{
191-
mMapCanvas->refresh();
192-
}
192+
QgsPalLayerSettings settings = layerSettings();
193+
// If we get here we are good to go.
194+
settings.writeToLayer( mLayer );
195+
// trigger refresh
196+
if ( mMapCanvas )
197+
{
198+
mMapCanvas->refresh();
199+
}
193200
}
194201

195202
QgsPalLayerSettings QgsLabelingGui::layerSettings()
196203
{
197204
QgsPalLayerSettings lyr;
198205
lyr.fieldName = cboFieldName->currentText();
206+
// Check if we are an expression. Also treats expressions with just a column name as non expressions,
207+
// this saves time later so we don't have to parse the expression tree.
208+
lyr.isExpression = mLayer->fieldNameIndex( lyr.fieldName ) == -1;
199209

200210
lyr.dist = 0;
201211
lyr.placementFlags = 0;
@@ -300,7 +310,6 @@ QgsPalLayerSettings QgsLabelingGui::layerSettings()
300310
return lyr;
301311
}
302312

303-
304313
void QgsLabelingGui::populateFieldNames()
305314
{
306315
const QgsFieldMap& fields = mLayer->pendingFields();
@@ -449,6 +458,35 @@ void QgsLabelingGui::showEngineConfigDialog()
449458
dlg.exec();
450459
}
451460

461+
void QgsLabelingGui::showExpressionDialog()
462+
{
463+
QDialog* dlg = new QDialog();
464+
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok
465+
| QDialogButtonBox::Cancel);
466+
QgsExpressionBuilder* builder = new QgsExpressionBuilder();
467+
QGridLayout* layout = new QGridLayout();
468+
dlg->setLayout(layout);
469+
layout->addWidget(builder);
470+
layout->addWidget(buttonBox);
471+
472+
if ( dlg->exec() )
473+
{
474+
QString expression = builder->getExpressionString();
475+
//Do validation here first before applying
476+
QgsSearchString searchString;
477+
if ( !searchString.setString( expression ) )
478+
{
479+
//expression not valid
480+
QMessageBox::critical( 0, "Syntax error",
481+
"Invalid expression syntax. The error message of the parser is: '" + searchString.parserErrorMsg() + "'" );
482+
return;
483+
}
484+
485+
cboFieldName->addItem(expression);
486+
cboFieldName->setCurrentIndex(cboFieldName->count() - 1);
487+
}
488+
}
489+
452490
void QgsLabelingGui::updateUi()
453491
{
454492
// enable/disable scale-based, buffer

‎src/app/qgslabelinggui.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class QgsLabelingGui : public QDialog, private Ui::QgsLabelingGuiBase
4141
void changeTextColor();
4242
void changeTextFont();
4343
void showEngineConfigDialog();
44+
void showExpressionDialog();
4445
void changeBufferColor();
4546

4647
void updateUi();

‎src/core/qgslabel.cpp

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,14 @@
3434
#include "qgsmaptopixel.h"
3535
#include "qgscoordinatetransform.h"
3636
#include "qgsrendercontext.h"
37+
#include "qgssearchtreenode.h"
38+
#include "qgssearchstring.h"
3739

3840
#include "qgslabelattributes.h"
3941
#include "qgslabel.h"
4042

43+
#include <QMessageBox>
44+
4145
// use M_PI define PI 3.141592654
4246
#ifdef WIN32
4347
#undef M_PI
@@ -103,16 +107,37 @@ void QgsLabel::renderLabel( QgsRenderContext &renderContext,
103107
double x2 = point.x();
104108
double scale = ( x2 - x1 ) * 0.001;
105109

110+
QgsSearchString searchString;
111+
if ( !searchString.setString( " to string (Diameter) + 'mm'" ) )
112+
{
113+
//expression not valid
114+
QMessageBox::critical( 0, "Syntax error", "Invalid expression syntax. The error message of the parser is: '" + searchString.parserErrorMsg() + "'" );
115+
return;
116+
}
117+
118+
//get QgsSearchTreeNode
119+
QgsSearchTreeNode* searchTree = searchString.tree();
120+
if ( !searchTree )
121+
{
122+
return;
123+
}
124+
125+
QgsSearchTreeValue outValue;
126+
searchTree->getValue( outValue, searchTree, mField , feature );
127+
if (outValue.isError())
128+
QMessageBox::critical( 0, "Error in expression tree" , "Error" );
129+
text = outValue.string();
130+
106131
/* Text */
107-
value = fieldValue( Text, feature );
132+
/*value = fieldValue( Text, feature );
108133
if ( value.isEmpty() )
109134
{
110135
text = mLabelAttributes->text();
111136
}
112137
else
113138
{
114139
text = value;
115-
}
140+
} */
116141

117142
/* Font */
118143
value = fieldValue( Family, feature );
@@ -1030,8 +1055,6 @@ void QgsLabel::readXML( const QDomNode& node )
10301055

10311056
} // QgsLabel::readXML()
10321057

1033-
1034-
10351058
void QgsLabel::writeXML( QDomNode & layer_node, QDomDocument & document ) const
10361059
{
10371060
QDomElement labelattributes = document.createElement( "labelattributes" );

‎src/core/qgspallabeling.cpp

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,16 @@
4141
#include "qgsdiagram.h"
4242
#include "qgsdiagramrendererv2.h"
4343
#include "qgslabelsearchtree.h"
44+
#include "qgssearchtreenode.h"
45+
#include "qgssearchstring.h"
46+
4447
#include <qgslogger.h>
4548
#include <qgsvectorlayer.h>
4649
#include <qgsmaplayerregistry.h>
4750
#include <qgsvectordataprovider.h>
4851
#include <qgsgeometry.h>
4952
#include <qgsmaprenderer.h>
50-
53+
#include <QMessageBox>
5154

5255
using namespace pal;
5356

@@ -155,6 +158,7 @@ QgsPalLayerSettings::QgsPalLayerSettings( const QgsPalLayerSettings& s )
155158
{
156159
// copy only permanent stuff
157160
fieldName = s.fieldName;
161+
isExpression = s.isExpression;
158162
placement = s.placement;
159163
placementFlags = s.placementFlags;
160164
textFont = s.textFont;
@@ -276,6 +280,7 @@ void QgsPalLayerSettings::readFromLayer( QgsVectorLayer* layer )
276280
return; // there's no information available
277281

278282
fieldName = layer->customProperty( "labeling/fieldName" ).toString();
283+
isExpression = layer->customProperty( "labeling/isExpression").toBool();
279284
placement = ( Placement ) layer->customProperty( "labeling/placement" ).toInt();
280285
placementFlags = layer->customProperty( "labeling/placementFlags" ).toUInt();
281286
QString fontFamily = layer->customProperty( "labeling/fontFamily" ).toString();
@@ -311,6 +316,7 @@ void QgsPalLayerSettings::writeToLayer( QgsVectorLayer* layer )
311316
layer->setCustomProperty( "labeling", "pal" );
312317

313318
layer->setCustomProperty( "labeling/fieldName", fieldName );
319+
layer->setCustomProperty( "labeling/isExpression", isExpression );
314320
layer->setCustomProperty( "labeling/placement", placement );
315321
layer->setCustomProperty( "labeling/placementFlags", ( unsigned int )placementFlags );
316322

@@ -427,9 +433,36 @@ void QgsPalLayerSettings::calculateLabelSize( const QFontMetricsF* fm, QString t
427433
labelY = qAbs( ptSize.y() - ptZero.y() );
428434
}
429435

430-
void QgsPalLayerSettings::registerFeature( QgsFeature& f, const QgsRenderContext& context )
436+
void QgsPalLayerSettings::registerFeature(QgsVectorLayer* layer, QgsFeature& f, const QgsRenderContext& context )
431437
{
432-
QString labelText = f.attributeMap()[fieldIndex].toString();
438+
QString labelText;
439+
if (isExpression)
440+
{
441+
QgsSearchString searchString;
442+
// We don't do any validating here as we should only have a vaild expression at this point.
443+
searchString.setString( fieldName );
444+
445+
QgsSearchTreeNode* searchTree = searchString.tree();
446+
if ( !searchTree )
447+
{
448+
return;
449+
}
450+
451+
QgsSearchTreeValue outValue;
452+
searchTree->getValue( outValue, searchTree, layer->dataProvider()->fields() , f );
453+
454+
if (outValue.isError())
455+
{
456+
QgsDebugMsg("EXPRESSION ERROR = " + outValue.string());
457+
return;
458+
}
459+
QgsDebugMsg("EXPRESSION OUT VALUE = " + outValue.string());
460+
labelText = outValue.string();
461+
}
462+
else
463+
{
464+
labelText = f.attributeMap()[fieldIndex].toString();
465+
}
433466
double labelX, labelY; // will receive label size
434467
QFont labelFont = textFont;
435468

@@ -569,7 +602,7 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, const QgsRenderContext
569602
// record the created geometry - it will be deleted at the end.
570603
geometries.append( lbl );
571604

572-
// register feature to the layer
605+
// feature to the layer
573606
try
574607
{
575608
if ( !palLayer->registerFeature( lbl->strId(), lbl, labelX, labelY, labelText.toUtf8().constData(),
@@ -689,11 +722,15 @@ int QgsPalLabeling::prepareLayer( QgsVectorLayer* layer, QSet<int>& attrIndices,
689722
if ( !lyrTmp.enabled )
690723
return 0;
691724

692-
// find out which field will be needed
693-
int fldIndex = layer->fieldNameIndex( lyrTmp.fieldName );
694-
if ( fldIndex == -1 )
695-
return 0;
696-
attrIndices.insert( fldIndex );
725+
// If we aren't an expression, we check to see if we can find the column.
726+
int fldIndex ;
727+
if (!lyrTmp.isExpression)
728+
{
729+
fldIndex = layer->fieldNameIndex( lyrTmp.fieldName );
730+
if ( fldIndex == -1)
731+
return 0;
732+
attrIndices.insert( fldIndex );
733+
}
697734

698735
//add indices of data defined fields
699736
QMap< QgsPalLayerSettings::DataDefinedProperties, int >::const_iterator dIt = lyrTmp.dataDefinedProperties.constBegin();
@@ -782,7 +819,7 @@ int QgsPalLabeling::addDiagramLayer( QgsVectorLayer* layer, QgsDiagramLayerSetti
782819
void QgsPalLabeling::registerFeature( QgsVectorLayer* layer, QgsFeature& f, const QgsRenderContext& context )
783820
{
784821
QgsPalLayerSettings& lyr = mActiveLayers[layer];
785-
lyr.registerFeature( f, context );
822+
lyr.registerFeature(layer, f, context );
786823
}
787824

788825
void QgsPalLabeling::registerDiagramFeature( QgsVectorLayer* layer, QgsFeature& feat, const QgsRenderContext& context )
@@ -836,7 +873,7 @@ void QgsPalLabeling::registerDiagramFeature( QgsVectorLayer* layer, QgsFeature&
836873
}
837874
}
838875

839-
// register feature to the layer
876+
// feature to the layer
840877
int ddColX = layerIt.value().xPosColumn;
841878
int ddColY = layerIt.value().yPosColumn;
842879
double ddPosX = 0.0;
@@ -1212,7 +1249,6 @@ void QgsPalLabeling::drawLabel( pal::LabelPosition* label, QPainter* painter, co
12121249

12131250
// TODO: optimize access :)
12141251
const QgsPalLayerSettings& lyr = layer( label->getLayerName() );
1215-
12161252
QString text = (( QgsPalGeometry* )label->getFeaturePart()->getUserGeometry() )->text();
12171253
QString txt = ( label->getPartId() == -1 ? text : QString( text[label->getPartId()] ) );
12181254

‎src/core/qgspallabeling.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class CORE_EXPORT QgsPalLayerSettings
9898
};
9999

100100
QString fieldName;
101+
bool isExpression;
101102
Placement placement;
102103
unsigned int placementFlags;
103104
QFont textFont;
@@ -125,7 +126,7 @@ class CORE_EXPORT QgsPalLayerSettings
125126
void calculateLabelSize( const QFontMetricsF* fm, QString text, double& labelX, double& labelY );
126127

127128
// implementation of register feature hook
128-
void registerFeature( QgsFeature& f, const QgsRenderContext& context );
129+
void registerFeature(QgsVectorLayer* layer, QgsFeature& f, const QgsRenderContext& context );
129130

130131
void readFromLayer( QgsVectorLayer* layer );
131132
void writeToLayer( QgsVectorLayer* layer );

‎src/core/qgssearchtreenode.cpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -586,51 +586,58 @@ QgsSearchTreeValue QgsSearchTreeNode::valueAgainst( const QgsFieldMap& fields,
586586

587587
QgsSearchTreeValue QgsSearchTreeNode::valueAgainst( const QgsFieldMap& fields, QgsFeature &f )
588588
{
589-
QgsDebugMsgLevel( "valueAgainst: " + makeSearchString(), 2 );
589+
QgsDebugMsg( "VALUE AGAINST: " + makeSearchString());
590590

591591
switch ( mType )
592592
{
593593
case tNumber:
594-
QgsDebugMsgLevel( "number: " + QString::number( mNumber ), 2 );
594+
QgsDebugMsg( "number: " + QString::number( mNumber ));
595595
return QgsSearchTreeValue( mNumber );
596596

597597
case tString:
598-
QgsDebugMsgLevel( "text: " + EVAL_STR( mText ), 2 );
598+
QgsDebugMsg( "text: " + EVAL_STR( mText ) );
599599
return QgsSearchTreeValue( mText );
600600

601601
case tColumnRef:
602602
{
603-
QgsDebugMsgLevel( "column (" + mText.toLower() + "): ", 2 );
603+
QgsDebugMsg( "column (" + mText.toLower() + "): " );
604604
// find field index for the column
605605
QgsFieldMap::const_iterator it;
606606
for ( it = fields.begin(); it != fields.end(); it++ )
607607
{
608-
if ( QString::compare( it->name(), mText, Qt::CaseInsensitive ) == 0 )
609-
break;
608+
QgsDebugMsg(it->name());
609+
if ( QString::compare( it->name(), mText, Qt::CaseInsensitive ) == 0 )
610+
break;
610611
}
611612

612613
if ( it == fields.end() )
613614
{
614615
// report missing column if not found
615-
QgsDebugMsgLevel( "ERROR!", 2 );
616+
QgsDebugMsg( "ERROR!" );
616617
return QgsSearchTreeValue( 1, mText );
617618
}
618619

619620
// get the value
620621
QVariant val = f.attributeMap()[it.key()];
622+
QgsAttributeMap::const_iterator its;
623+
for ( its = f.attributeMap().begin(); its != f.attributeMap().end(); its++ )
624+
{
625+
QgsDebugMsg(its->toString());
626+
}
627+
621628
if ( val.isNull() )
622629
{
623-
QgsDebugMsgLevel( " NULL", 2 );
630+
QgsDebugMsg( " NULL" );
624631
return QgsSearchTreeValue();
625632
}
626633
else if ( val.type() == QVariant::Bool || val.type() == QVariant::Int || val.type() == QVariant::Double )
627634
{
628-
QgsDebugMsgLevel( " number: " + QString::number( val.toDouble() ), 2 );
635+
QgsDebugMsg( " number: " + QString::number( val.toDouble() ) );
629636
return QgsSearchTreeValue( val.toDouble() );
630637
}
631638
else
632639
{
633-
QgsDebugMsgLevel( " text: " + EVAL_STR( val.toString() ), 2 );
640+
QgsDebugMsg( " text: " + EVAL_STR( val.toString() ) );
634641
return QgsSearchTreeValue( val.toString() );
635642
}
636643

‎src/core/qgsvectorlayer.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -334,22 +334,19 @@ void QgsVectorLayer::drawLabels( QgsRenderContext& rendererContext )
334334
QgsAttributeList attributes;
335335
if ( mRenderer )
336336
{
337-
attributes = mRenderer->classificationAttributes();
337+
//attributes = mRenderer->classificationAttributes();
338338
}
339339
else if ( mRendererV2 )
340340
{
341-
foreach( QString attrName, mRendererV2->usedAttributes() )
342-
{
343-
int attrNum = fieldNameIndex( attrName );
344-
attributes.append( attrNum );
345-
}
341+
// foreach( QString attrName, mRendererV2->usedAttributes() )
342+
// {
343+
// int attrNum = fieldNameIndex( attrName );
344+
// attributes.append( attrNum );
345+
// }
346346
// make sure the renderer is ready for classification ("symbolForFeature")
347347
mRendererV2->startRender( rendererContext, this );
348348
}
349349

350-
// Add fields required for labels
351-
mLabel->addRequiredFields( attributes );
352-
353350
QgsDebugMsg( "Selecting features based on view extent" );
354351

355352
int featureCount = 0;
@@ -358,7 +355,7 @@ void QgsVectorLayer::drawLabels( QgsRenderContext& rendererContext )
358355
{
359356
// select the records in the extent. The provider sets a spatial filter
360357
// and sets up the selection set for retrieval
361-
select( attributes, rendererContext.extent() );
358+
select( pendingAllAttributesList(), rendererContext.extent() );
362359

363360
QgsFeature fet;
364361
while ( nextFeature( fet ) )
@@ -978,7 +975,7 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
978975
//register label and diagram layer to the labeling engine
979976
prepareLabelingAndDiagrams( rendererContext, attributes, labeling );
980977

981-
select( attributes, rendererContext.extent() );
978+
select( pendingAllAttributesList(), rendererContext.extent() );
982979

983980
if ( mRendererV2->usingSymbolLevels() )
984981
drawRendererV2Levels( rendererContext, labeling );
@@ -1025,7 +1022,7 @@ bool QgsVectorLayer::draw( QgsRenderContext& rendererContext )
10251022
bool labeling = false;
10261023
prepareLabelingAndDiagrams( rendererContext, attributes, labeling );
10271024

1028-
select( attributes, rendererContext.extent() );
1025+
select( pendingAllAttributesList(), rendererContext.extent() );
10291026

10301027
try
10311028
{

‎src/gui/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ qgstextannotationitem.cpp
6969
qgsvertexmarker.cpp
7070
qgsludialog.cpp
7171
qgssearchquerybuilder.cpp
72+
qgsexpressionbuilder.cpp
7273
)
7374

7475
SET(QGIS_GUI_MOC_HDRS
@@ -123,6 +124,7 @@ qgsludialog.h
123124
qgsprojectbadlayerguihandler.h
124125
qgslonglongvalidator.h
125126
qgssearchquerybuilder.h
127+
qgsexpressionbuilder.h
126128
)
127129

128130
QT4_WRAP_CPP(QGIS_GUI_MOC_SRCS ${QGIS_GUI_MOC_HDRS})
@@ -227,6 +229,7 @@ qgsrubberband.h
227229
qgsvertexmarker.h
228230
qgsmaptip.h
229231
qgssearchquerybuilder.h
232+
qgsexpressionbuilder.h
230233
qgsattributeeditor.h
231234
qgsfieldvalidator.h
232235

@@ -243,6 +246,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsmessageviewer.h
243246
${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgscredentialdialog.h
244247
${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsprojectionselectorbase.h
245248
${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsquerybuilderbase.h
249+
${CMAKE_CURRENT_BINARY_DIR}/../ui/ui_qgsexpressionbuilder.h
246250
)
247251

248252

‎src/gui/qgsexpressionbuilder.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/***************************************************************************
2+
qgisexpressionbuilder.cpp - A genric expression string builder widget.
3+
--------------------------------------
4+
Date : 29-May-2011
5+
Copyright : (C) 2006 by Nathan Woodrow
6+
Email : nathan.woodrow at gmail dot com
7+
***************************************************************************
8+
* *
9+
* This program is free software; you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation; either version 2 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
***************************************************************************/
15+
16+
#include "qgsexpressionbuilder.h"
17+
#include "ui_qgsexpressionbuilder.h"
18+
19+
QgsExpressionBuilder::QgsExpressionBuilder(QWidget *parent) :
20+
QWidget(parent)
21+
22+
{
23+
setupUi(this);
24+
}
25+
26+
QgsExpressionBuilder::~QgsExpressionBuilder()
27+
{
28+
29+
}
30+
31+
QString QgsExpressionBuilder::getExpressionString()
32+
{
33+
return this->txtExpressionString->toPlainText();
34+
}

‎src/gui/qgsexpressionbuilder.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/***************************************************************************
2+
qgisexpressionbuilder.h - A genric expression string builder widget.
3+
--------------------------------------
4+
Date : 29-May-2011
5+
Copyright : (C) 2006 by Nathan Woodrow
6+
Email : nathan.woodrow at gmail dot com
7+
***************************************************************************
8+
* *
9+
* This program is free software; you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation; either version 2 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
***************************************************************************/
15+
16+
#ifndef QGSEXPRESSIONBUILDER_H
17+
#define QGSEXPRESSIONBUILDER_H
18+
19+
#include <QWidget>
20+
#include "ui_qgsexpressionbuilder.h"
21+
22+
class QgsExpressionBuilder : public QWidget, private Ui::QgsExpressionBuilder {
23+
Q_OBJECT
24+
public:
25+
QgsExpressionBuilder(QWidget *parent = 0);
26+
~QgsExpressionBuilder();
27+
28+
QString getExpressionString();
29+
};
30+
31+
#endif // QGSEXPRESSIONBUILDER_H

‎src/ui/qgsexpressionbuilder.ui

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>QgsExpressionBuilder</class>
4+
<widget class="QWidget" name="QgsExpressionBuilder">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>400</width>
10+
<height>300</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>Form</string>
15+
</property>
16+
<layout class="QGridLayout" name="gridLayout">
17+
<item row="0" column="0" colspan="2">
18+
<widget class="QTextEdit" name="txtExpressionString"/>
19+
</item>
20+
</layout>
21+
</widget>
22+
<resources/>
23+
<connections/>
24+
</ui>

‎src/ui/qgslabelingguibase.ui

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@
5353
<item>
5454
<widget class="QComboBox" name="cboFieldName"/>
5555
</item>
56+
<item>
57+
<widget class="QToolButton" name="btnExpression">
58+
<property name="text">
59+
<string>...</string>
60+
</property>
61+
</widget>
62+
</item>
5663
</layout>
5764
</item>
5865
<item row="1" column="0">
@@ -393,8 +400,8 @@
393400
<rect>
394401
<x>0</x>
395402
<y>0</y>
396-
<width>643</width>
397-
<height>435</height>
403+
<width>645</width>
404+
<height>488</height>
398405
</rect>
399406
</property>
400407
<layout class="QGridLayout" name="gridLayout_13">
@@ -847,8 +854,8 @@
847854
<rect>
848855
<x>0</x>
849856
<y>0</y>
850-
<width>643</width>
851-
<height>532</height>
857+
<width>645</width>
858+
<height>675</height>
852859
</rect>
853860
</property>
854861
<layout class="QGridLayout" name="gridLayout_11">

0 commit comments

Comments
 (0)
Please sign in to comment.