QGIS API Documentation  2.11.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
qgsexpressionbuilderdialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgisexpressionbuilderdialog.h - A genric expression string builder dialog.
3  --------------------------------------
4  Date : 29-May-2011
5  Copyright : (C) 2011 by Nathan Woodrow
6  Email : woodrow.nathan 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 
17 #include <QSettings>
18 
20  : QDialog( parent ), mRecentKey( key )
21 {
22  setupUi( this );
23 
24  QPushButton* okButton = buttonBox->button( QDialogButtonBox::Ok );
25  connect( builder, SIGNAL( expressionParsed( bool ) ), okButton, SLOT( setEnabled( bool ) ) );
26 
27  builder->setExpressionContext( context );
28  builder->setLayer( layer );
29  builder->setExpressionText( startText );
30  builder->loadFieldNames();
31  builder->loadRecent( mRecentKey );
32 
33  QSettings settings;
34  restoreGeometry( settings.value( "/Windows/ExpressionBuilderDialog/geometry" ).toByteArray() );
35 }
36 
38 {
39  return builder;
40 }
41 
43 {
44  builder->setExpressionText( text );
45 }
46 
48 {
49  return builder->expressionText();
50 }
51 
53 {
54  return builder->expressionContext();
55 }
56 
58 {
59  builder->setExpressionContext( context );
60 }
61 
63 {
64  QDialog::done( r );
65 
66  QSettings settings;
67  settings.setValue( "/Windows/ExpressionBuilderDialog/geometry", saveGeometry() );
68 }
69 
71 {
72  builder->saveToRecent( mRecentKey );
74 }
75 
77 {
78  // Store in child widget only.
79  builder->setGeomCalculator( da );
80 }
QByteArray toByteArray() const
void setupUi(QWidget *widget)
void setExpressionText(const QString &text)
QgsExpressionBuilderWidget * expressionBuilder()
The builder widget that is used by the dialog.
virtual void done(int r)
void setValue(const QString &key, const QVariant &value)
void setEnabled(bool)
bool restoreGeometry(const QByteArray &geometry)
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context for the dialog.
QgsExpressionContext expressionContext() const
Returns the expression context for the dialog.
void setGeomCalculator(const QgsDistanceArea &da)
Sets geometry calculator used in distance/area calculations.
virtual void accept()
General purpose distance and area calculator.
A reusable widget that can be used to build a expression string.
QVariant value(const QString &key, const QVariant &defaultValue) const
QByteArray saveGeometry() const
QgsExpressionBuilderDialog(QgsVectorLayer *layer, QString startText=QString(), QWidget *parent=NULL, QString key="generic", const QgsExpressionContext &context=QgsExpressionContext())
virtual void done(int r) override
Is called when the dialog get accepted or rejected Used to save geometry.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Represents a vector layer which manages a vector based data sets.