QGIS API Documentation  3.0.2-Girona (307d082)
qgsexpressionlineedit.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsexpressionlineedit.h
3  ----------------------
4  Date : 18.08.2016
5  Copyright : (C) 2016 Nyall Dawson
6  Email : nyall dot dawson 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 QGSEXPRESSIONLINEEDIT_H
17 #define QGSEXPRESSIONLINEEDIT_H
18 
19 #include <QWidget>
20 #include "qgis.h"
21 #include "qgsexpressioncontext.h"
22 #include "qgsdistancearea.h"
23 #include "qgis_gui.h"
24 #include <memory>
25 
26 class QgsFilterLineEdit;
27 class QToolButton;
28 class QgsDistanceArea;
30 class QgsCodeEditorSQL;
31 
49 class GUI_EXPORT QgsExpressionLineEdit : public QWidget
50 {
51  Q_OBJECT
52 
53  public:
54 
59  explicit QgsExpressionLineEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr );
60 
66  void setExpressionDialogTitle( const QString &title );
67 
72  QString expressionDialogTitle() const { return mExpressionDialogTitle; }
73 
79  void setMultiLine( bool multiLine );
80 
85  void setGeomCalculator( const QgsDistanceArea &distanceArea );
86 
95  void setLayer( QgsVectorLayer *layer );
96 
101  QString expression() const;
102 
107  bool isValidExpression( QString *expressionError SIP_OUT = nullptr ) const;
108 
115  void registerExpressionContextGenerator( const QgsExpressionContextGenerator *generator );
116 
117  signals:
118 
123  void expressionChanged( const QString &expression );
124 
125  public slots:
126 
132  void setExpression( const QString &expression );
133 
134  protected:
135 
136  void changeEvent( QEvent *event ) override;
137 
138  private slots:
139 
141  void expressionEdited( const QString &expression );
142  void expressionEdited();
143 
145  void editExpression();
146 
152  void updateLineEditStyle( const QString &expression = QString() );
153 
154  private:
155  QgsFilterLineEdit *mLineEdit = nullptr;
156  QgsCodeEditorSQL *mCodeEditor = nullptr;
157  QToolButton *mButton = nullptr;
158  QString mExpressionDialogTitle;
159  std::unique_ptr<QgsDistanceArea> mDa;
160  QgsExpressionContext mExpressionContext;
161  const QgsExpressionContextGenerator *mExpressionContextGenerator = nullptr;
162  QgsVectorLayer *mLayer = nullptr;
163 
164  bool isExpressionValid( const QString &expressionStr );
165 
166  friend class TestQgsFieldExpressionWidget;
167 };
168 
169 #endif // QGSEXPRESSIONLINEEDIT_H
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
QString expressionDialogTitle() const
Returns the title used for the expression dialog.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QLineEdit subclass with built in support for clearing the widget&#39;s value and handling custom null val...
Abstract interface for generating an expression context.
A general purpose distance and area calculator, capable of performing ellipsoid based calculations...
A SQL editor based on QScintilla2.
The QgsExpressionLineEdit widget includes a line edit for entering expressions together with a button...
#define SIP_OUT
Definition: qgis_sip.h:51
Represents a vector layer which manages a vector based data sets.