QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
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_sip.h"
22#include "qgis_gui.h"
23#include <memory>
24
26class QToolButton;
27class QgsDistanceArea;
30
47class GUI_EXPORT QgsExpressionLineEdit : public QWidget
48{
49 Q_OBJECT
50
51 public:
56 explicit QgsExpressionLineEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr );
58
64 void setExpressionDialogTitle( const QString &title );
65
70 QString expressionDialogTitle() const { return mExpressionDialogTitle; }
71
77 void setMultiLine( bool multiLine );
78
86 QString expectedOutputFormat() const;
87
94 void setExpectedOutputFormat( const QString &expected );
95
100 void setGeomCalculator( const QgsDistanceArea &distanceArea );
101
110 void setLayer( QgsVectorLayer *layer );
111
116 QString expression() const;
117
123 bool isValidExpression( QString *expressionError SIP_OUT = nullptr ) const;
124
131 void registerExpressionContextGenerator( const QgsExpressionContextGenerator *generator );
132
133 signals:
134
139 void expressionChanged( const QString &expression );
140
141 public slots:
142
148 void setExpression( const QString &expression );
149
150 protected:
151 void changeEvent( QEvent *event ) override;
152
153 private slots:
154
156 void expressionEdited( const QString &expression );
157 void expressionEdited();
158
160 void editExpression();
161
167 void updateLineEditStyle( const QString &expression = QString() );
168
169 private:
170 QgsFilterLineEdit *mLineEdit = nullptr;
171 QgsCodeEditorExpression *mCodeEditor = nullptr;
172 QToolButton *mButton = nullptr;
173 QString mExpressionDialogTitle;
174 std::unique_ptr<QgsDistanceArea> mDa;
175 QgsExpressionContext mExpressionContext;
176 const QgsExpressionContextGenerator *mExpressionContextGenerator = nullptr;
177 QgsVectorLayer *mLayer = nullptr;
178 QString mExpectedOutputFormat;
179
180 bool isExpressionValid( const QString &expressionStr );
181
182 friend class TestQgsFieldExpressionWidget;
183};
184
185#endif // QGSEXPRESSIONLINEEDIT_H
A QGIS expression editor based on QScintilla2.
A general purpose distance and area calculator, capable of performing ellipsoid based calculations.
Abstract interface for generating an expression context.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
The QgsExpressionLineEdit widget includes a line edit for entering expressions together with a button...
QString expressionDialogTitle() const
Returns the title used for the expression dialog.
~QgsExpressionLineEdit() override
void expressionChanged(const QString &expression)
Emitted when the expression is changed.
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
Represents a vector layer which manages a vector based data sets.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_OUT
Definition qgis_sip.h:58