QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 "qgsexpressioncontext.h"
21 #include "qgsdistancearea.h"
22 
23 class QgsFilterLineEdit;
24 class QToolButton;
25 class QgsDistanceArea;
26 class QgsExpressionContextGenerator;
27 class QgsCodeEditorSQL;
28 
45 class GUI_EXPORT QgsExpressionLineEdit : public QWidget
46 {
47  Q_OBJECT
48 
49  public:
50 
55  explicit QgsExpressionLineEdit( QWidget *parent = nullptr );
56 
61  void setExpressionDialogTitle( const QString& title );
62 
66  QString expressionDialogTitle() const { return mExpressionDialogTitle; }
67 
72  void setMultiLine( bool multiLine );
73 
77  void setGeomCalculator( const QgsDistanceArea &distanceArea );
78 
83  void setLayer( QgsVectorLayer* layer );
84 
88  QString expression() const;
89 
94  bool isValidExpression( QString *expressionError = nullptr ) const;
95 
96  signals:
97 
101  void expressionChanged( const QString& expression );
102 
103  public slots:
104 
109  void setExpression( const QString& expression );
110 
111  protected:
112  void changeEvent( QEvent* event ) override;
113 
114  private slots:
116  void expressionEdited( const QString& expression );
117  void expressionEdited();
118 
120  void editExpression();
121 
127  void updateLineEditStyle( const QString& expression = QString() );
128 
129  private:
130  QgsFilterLineEdit* mLineEdit;
131  QgsCodeEditorSQL* mCodeEditor;
132  QToolButton* mButton;
133  QString mExpressionDialogTitle;
135  QgsExpressionContext mExpressionContext;
136  QgsVectorLayer* mLayer;
137 
138  bool isExpressionValid( const QString& expressionStr );
139 
140  friend class TestQgsFieldExpressionWidget;
141 };
142 
143 #endif // QGSEXPRESSIONLINEEDIT_H
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...
virtual void changeEvent(QEvent *event)
General purpose distance and area calculator.
A SQL editor based on QScintilla2.
The QgsExpressionLineEdit widget includes a line edit for entering expressions together with a button...
Represents a vector layer which manages a vector based data sets.